Lines Matching refs:i2c_bus

32 struct i2c_bus {  struct
44 static void set_packet_mode(struct i2c_bus *i2c_bus) in set_packet_mode() argument
50 if (i2c_bus->type == TYPE_DVC) { in set_packet_mode()
51 struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs; in set_packet_mode()
55 writel(config, &i2c_bus->regs->cnfg); in set_packet_mode()
60 setbits_le32(&i2c_bus->regs->sl_cnfg, I2C_SL_CNFG_NEWSL_MASK); in set_packet_mode()
64 static void i2c_reset_controller(struct i2c_bus *i2c_bus) in i2c_reset_controller() argument
67 reset_assert(&i2c_bus->reset_ctl); in i2c_reset_controller()
69 reset_deassert(&i2c_bus->reset_ctl); in i2c_reset_controller()
73 set_packet_mode(i2c_bus); in i2c_reset_controller()
76 static int i2c_init_clock(struct i2c_bus *i2c_bus, unsigned rate) in i2c_init_clock() argument
80 ret = reset_assert(&i2c_bus->reset_ctl); in i2c_init_clock()
83 ret = clk_enable(&i2c_bus->clk); in i2c_init_clock()
86 ret = clk_set_rate(&i2c_bus->clk, rate); in i2c_init_clock()
89 ret = reset_deassert(&i2c_bus->reset_ctl); in i2c_init_clock()
96 static void i2c_init_controller(struct i2c_bus *i2c_bus) in i2c_init_controller() argument
98 if (!i2c_bus->speed) in i2c_init_controller()
100 debug("%s: speed=%d\n", __func__, i2c_bus->speed); in i2c_init_controller()
106 i2c_init_clock(i2c_bus, i2c_bus->speed * 2 * 8); in i2c_init_controller()
108 if (i2c_bus->type == TYPE_114) { in i2c_init_controller()
120 int clk_div_stdfst_mode = readl(&i2c_bus->regs->clk_div) >> 16; in i2c_init_controller()
122 (clk_div_stdfst_mode + 1) * i2c_bus->speed * 2; in i2c_init_controller()
126 i2c_init_clock(i2c_bus, rate); in i2c_init_controller()
130 i2c_reset_controller(i2c_bus); in i2c_init_controller()
133 if (i2c_bus->type == TYPE_DVC) { /* only for DVC I2C */ in i2c_init_controller()
134 struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs; in i2c_init_controller()
140 funcmux_select(i2c_bus->clk.id, i2c_bus->pinmux_config); in i2c_init_controller()
145 struct i2c_bus *i2c_bus, in send_packet_headers() argument
155 data |= i2c_bus->id << PKT_HDR1_CTLR_ID_SHIFT; in send_packet_headers()
156 writel(data, &i2c_bus->control->tx_fifo); in send_packet_headers()
161 writel(data, &i2c_bus->control->tx_fifo); in send_packet_headers()
174 writel(data, &i2c_bus->control->tx_fifo); in send_packet_headers()
233 static int send_recv_packets(struct i2c_bus *i2c_bus, in send_recv_packets() argument
236 struct i2c_control *control = i2c_bus->control; in send_recv_packets()
249 send_packet_headers(i2c_bus, trans, 1, in send_recv_packets()
304 i2c_reset_controller(i2c_bus); in send_recv_packets()
309 static int tegra_i2c_write_data(struct i2c_bus *i2c_bus, u32 addr, u8 *data, in tegra_i2c_write_data() argument
323 error = send_recv_packets(i2c_bus, &trans_info); in tegra_i2c_write_data()
330 static int tegra_i2c_read_data(struct i2c_bus *i2c_bus, u32 addr, u8 *data, in tegra_i2c_read_data() argument
342 error = send_recv_packets(i2c_bus, &trans_info); in tegra_i2c_read_data()
351 struct i2c_bus *i2c_bus = dev_get_priv(dev); in tegra_i2c_set_bus_speed() local
353 i2c_bus->speed = speed; in tegra_i2c_set_bus_speed()
354 i2c_init_controller(i2c_bus); in tegra_i2c_set_bus_speed()
361 struct i2c_bus *i2c_bus = dev_get_priv(dev); in tegra_i2c_probe() local
365 i2c_bus->id = dev_seq(dev); in tegra_i2c_probe()
366 i2c_bus->type = dev_get_driver_data(dev); in tegra_i2c_probe()
367 i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr(dev); in tegra_i2c_probe()
368 if ((ulong)i2c_bus->regs == FDT_ADDR_T_NONE) { in tegra_i2c_probe()
373 ret = reset_get_by_name(dev, "i2c", &i2c_bus->reset_ctl); in tegra_i2c_probe()
378 ret = clk_get_by_name(dev, "div-clk", &i2c_bus->clk); in tegra_i2c_probe()
389 i2c_bus->pinmux_config = FUNCMUX_DEFAULT; in tegra_i2c_probe()
404 i2c_bus->control = in tegra_i2c_probe()
405 &((struct dvc_ctlr *)i2c_bus->regs)->control; in tegra_i2c_probe()
407 i2c_bus->control = &i2c_bus->regs->control; in tegra_i2c_probe()
409 i2c_init_controller(i2c_bus); in tegra_i2c_probe()
411 is_dvc ? "dvc" : "i2c", dev_seq(dev), i2c_bus->regs, in tegra_i2c_probe()
412 i2c_bus->speed); in tegra_i2c_probe()
418 static int i2c_write_data(struct i2c_bus *i2c_bus, uchar chip, uchar *buffer, in i2c_write_data() argument
431 rc = tegra_i2c_write_data(i2c_bus, chip << 1, buffer, len, in i2c_write_data()
440 static int i2c_read_data(struct i2c_bus *i2c_bus, uchar chip, uchar *buffer, in i2c_read_data() argument
447 rc = tegra_i2c_read_data(i2c_bus, chip << 1, buffer, len); in i2c_read_data()
466 struct i2c_bus *i2c_bus = dev_get_priv(bus); in tegra_i2c_probe_chip() local
471 rc = tegra_i2c_write_data(i2c_bus, chip_addr << 1, &reg, sizeof(reg), in tegra_i2c_probe_chip()
480 struct i2c_bus *i2c_bus = dev_get_priv(bus); in tegra_i2c_xfer() local
489 ret = i2c_read_data(i2c_bus, msg->addr, msg->buf, in tegra_i2c_xfer()
492 ret = i2c_write_data(i2c_bus, msg->addr, msg->buf, in tegra_i2c_xfer()
527 .priv_auto = sizeof(struct i2c_bus),