• Home
  • Raw
  • Download

Lines Matching refs:i2c_bus

29 struct i2c_bus {  struct
41 static void set_packet_mode(struct i2c_bus *i2c_bus) in set_packet_mode() argument
47 if (i2c_bus->type == TYPE_DVC) { in set_packet_mode()
48 struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs; in set_packet_mode()
52 writel(config, &i2c_bus->regs->cnfg); in set_packet_mode()
57 setbits_le32(&i2c_bus->regs->sl_cnfg, I2C_SL_CNFG_NEWSL_MASK); in set_packet_mode()
61 static void i2c_reset_controller(struct i2c_bus *i2c_bus) in i2c_reset_controller() argument
64 reset_assert(&i2c_bus->reset_ctl); in i2c_reset_controller()
66 reset_deassert(&i2c_bus->reset_ctl); in i2c_reset_controller()
70 set_packet_mode(i2c_bus); in i2c_reset_controller()
73 static int i2c_init_clock(struct i2c_bus *i2c_bus, unsigned rate) in i2c_init_clock() argument
77 ret = reset_assert(&i2c_bus->reset_ctl); in i2c_init_clock()
80 ret = clk_enable(&i2c_bus->clk); in i2c_init_clock()
83 ret = clk_set_rate(&i2c_bus->clk, rate); in i2c_init_clock()
86 ret = reset_deassert(&i2c_bus->reset_ctl); in i2c_init_clock()
93 static void i2c_init_controller(struct i2c_bus *i2c_bus) in i2c_init_controller() argument
95 if (!i2c_bus->speed) in i2c_init_controller()
97 debug("%s: speed=%d\n", __func__, i2c_bus->speed); in i2c_init_controller()
103 i2c_init_clock(i2c_bus, i2c_bus->speed * 2 * 8); in i2c_init_controller()
105 if (i2c_bus->type == TYPE_114) { in i2c_init_controller()
117 int clk_div_stdfst_mode = readl(&i2c_bus->regs->clk_div) >> 16; in i2c_init_controller()
119 (clk_div_stdfst_mode + 1) * i2c_bus->speed * 2; in i2c_init_controller()
123 i2c_init_clock(i2c_bus, rate); in i2c_init_controller()
127 i2c_reset_controller(i2c_bus); in i2c_init_controller()
130 if (i2c_bus->type == TYPE_DVC) { /* only for DVC I2C */ in i2c_init_controller()
131 struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs; in i2c_init_controller()
137 funcmux_select(i2c_bus->clk.id, i2c_bus->pinmux_config); in i2c_init_controller()
142 struct i2c_bus *i2c_bus, in send_packet_headers() argument
152 data |= i2c_bus->id << PKT_HDR1_CTLR_ID_SHIFT; in send_packet_headers()
153 writel(data, &i2c_bus->control->tx_fifo); in send_packet_headers()
158 writel(data, &i2c_bus->control->tx_fifo); in send_packet_headers()
171 writel(data, &i2c_bus->control->tx_fifo); in send_packet_headers()
230 static int send_recv_packets(struct i2c_bus *i2c_bus, in send_recv_packets() argument
233 struct i2c_control *control = i2c_bus->control; in send_recv_packets()
246 send_packet_headers(i2c_bus, trans, 1, in send_recv_packets()
301 i2c_reset_controller(i2c_bus); in send_recv_packets()
306 static int tegra_i2c_write_data(struct i2c_bus *i2c_bus, u32 addr, u8 *data, in tegra_i2c_write_data() argument
320 error = send_recv_packets(i2c_bus, &trans_info); in tegra_i2c_write_data()
327 static int tegra_i2c_read_data(struct i2c_bus *i2c_bus, u32 addr, u8 *data, in tegra_i2c_read_data() argument
339 error = send_recv_packets(i2c_bus, &trans_info); in tegra_i2c_read_data()
348 struct i2c_bus *i2c_bus = dev_get_priv(dev); in tegra_i2c_set_bus_speed() local
350 i2c_bus->speed = speed; in tegra_i2c_set_bus_speed()
351 i2c_init_controller(i2c_bus); in tegra_i2c_set_bus_speed()
358 struct i2c_bus *i2c_bus = dev_get_priv(dev); in tegra_i2c_probe() local
362 i2c_bus->id = dev->seq; in tegra_i2c_probe()
363 i2c_bus->type = dev_get_driver_data(dev); in tegra_i2c_probe()
364 i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr(dev); in tegra_i2c_probe()
365 if ((ulong)i2c_bus->regs == FDT_ADDR_T_NONE) { in tegra_i2c_probe()
370 ret = reset_get_by_name(dev, "i2c", &i2c_bus->reset_ctl); in tegra_i2c_probe()
375 ret = clk_get_by_name(dev, "div-clk", &i2c_bus->clk); in tegra_i2c_probe()
386 i2c_bus->pinmux_config = FUNCMUX_DEFAULT; in tegra_i2c_probe()
401 i2c_bus->control = in tegra_i2c_probe()
402 &((struct dvc_ctlr *)i2c_bus->regs)->control; in tegra_i2c_probe()
404 i2c_bus->control = &i2c_bus->regs->control; in tegra_i2c_probe()
406 i2c_init_controller(i2c_bus); in tegra_i2c_probe()
408 is_dvc ? "dvc" : "i2c", dev->seq, i2c_bus->regs, i2c_bus->speed); in tegra_i2c_probe()
414 static int i2c_write_data(struct i2c_bus *i2c_bus, uchar chip, uchar *buffer, in i2c_write_data() argument
427 rc = tegra_i2c_write_data(i2c_bus, chip << 1, buffer, len, in i2c_write_data()
436 static int i2c_read_data(struct i2c_bus *i2c_bus, uchar chip, uchar *buffer, in i2c_read_data() argument
443 rc = tegra_i2c_read_data(i2c_bus, chip << 1, buffer, len); in i2c_read_data()
462 struct i2c_bus *i2c_bus = dev_get_priv(bus); in tegra_i2c_probe_chip() local
467 rc = tegra_i2c_write_data(i2c_bus, chip_addr << 1, &reg, sizeof(reg), in tegra_i2c_probe_chip()
476 struct i2c_bus *i2c_bus = dev_get_priv(bus); in tegra_i2c_xfer() local
485 ret = i2c_read_data(i2c_bus, msg->addr, msg->buf, in tegra_i2c_xfer()
488 ret = i2c_write_data(i2c_bus, msg->addr, msg->buf, in tegra_i2c_xfer()
534 .priv_auto_alloc_size = sizeof(struct i2c_bus),