Lines Matching +full:bus +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-or-later
15 #include <media/v4l2-common.h>
23 MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
39 struct cx23885_i2c *bus = i2c_adap->algo_data; in i2c_slave_did_ack() local
40 struct cx23885_dev *dev = bus->dev; in i2c_slave_did_ack()
41 return cx_read(bus->reg_stat) & 0x01; in i2c_slave_did_ack()
46 struct cx23885_i2c *bus = i2c_adap->algo_data; in i2c_is_busy() local
47 struct cx23885_dev *dev = bus->dev; in i2c_is_busy()
48 return cx_read(bus->reg_stat) & 0x02 ? 1 : 0; in i2c_is_busy()
70 struct cx23885_i2c *bus = i2c_adap->algo_data; in i2c_sendbytes() local
71 struct cx23885_dev *dev = bus->dev; in i2c_sendbytes()
72 u32 wdata, addr, ctrl; in i2c_sendbytes() local
76 dprintk(1, "%s(msg->wlen=%d, nextmsg->rlen=%d)\n", __func__, in i2c_sendbytes()
77 msg->len, joined_rlen); in i2c_sendbytes()
79 dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); in i2c_sendbytes()
82 if (msg->len == 0) { in i2c_sendbytes()
83 cx_write(bus->reg_addr, msg->addr << 25); in i2c_sendbytes()
84 cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); in i2c_sendbytes()
86 return -EIO; in i2c_sendbytes()
88 return -ENXIO; in i2c_sendbytes()
96 addr = (msg->addr << 25) | msg->buf[0]; in i2c_sendbytes()
97 wdata = msg->buf[0]; in i2c_sendbytes()
98 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); in i2c_sendbytes()
100 if (msg->len > 1) in i2c_sendbytes()
105 cx_write(bus->reg_addr, addr); in i2c_sendbytes()
106 cx_write(bus->reg_wdata, wdata); in i2c_sendbytes()
107 cx_write(bus->reg_ctrl, ctrl); in i2c_sendbytes()
112 printk(KERN_DEBUG " <W %02x %02x", msg->addr << 1, msg->buf[0]); in i2c_sendbytes()
117 for (cnt = 1; cnt < msg->len; cnt++) { in i2c_sendbytes()
119 wdata = msg->buf[cnt]; in i2c_sendbytes()
120 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); in i2c_sendbytes()
122 if (cnt < msg->len - 1) in i2c_sendbytes()
127 cx_write(bus->reg_addr, addr); in i2c_sendbytes()
128 cx_write(bus->reg_wdata, wdata); in i2c_sendbytes()
129 cx_write(bus->reg_ctrl, ctrl); in i2c_sendbytes()
134 pr_cont(" %02x", msg->buf[cnt]); in i2c_sendbytes()
139 return msg->len; in i2c_sendbytes()
142 retval = -EIO; in i2c_sendbytes()
151 struct cx23885_i2c *bus = i2c_adap->algo_data; in i2c_readbytes() local
152 struct cx23885_dev *dev = bus->dev; in i2c_readbytes()
158 dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); in i2c_readbytes()
161 if (msg->len == 0) { in i2c_readbytes()
162 cx_write(bus->reg_addr, msg->addr << 25); in i2c_readbytes()
163 cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2) | 1); in i2c_readbytes()
165 return -EIO; in i2c_readbytes()
167 return -ENXIO; in i2c_readbytes()
178 dprintk(1, " <R %02x", (msg->addr << 1) + 1); in i2c_readbytes()
181 for (cnt = 0; cnt < msg->len; cnt++) { in i2c_readbytes()
183 ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; in i2c_readbytes()
185 if (cnt < msg->len - 1) in i2c_readbytes()
188 cx_write(bus->reg_addr, msg->addr << 25); in i2c_readbytes()
189 cx_write(bus->reg_ctrl, ctrl); in i2c_readbytes()
193 msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; in i2c_readbytes()
195 dprintk(1, " %02x", msg->buf[cnt]); in i2c_readbytes()
200 return msg->len; in i2c_readbytes()
203 retval = -EIO; in i2c_readbytes()
217 dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", in i2c_xfer()
218 __func__, num, msgs[i].addr, msgs[i].len); in i2c_xfer()
223 msgs[i].addr == msgs[i + 1].addr) { in i2c_xfer()
254 /* ----------------------------------------------------------------------- */
289 c->addr = i; in do_i2c_scan()
299 int cx23885_i2c_register(struct cx23885_i2c *bus) in cx23885_i2c_register() argument
301 struct cx23885_dev *dev = bus->dev; in cx23885_i2c_register()
303 dprintk(1, "%s(bus = %d)\n", __func__, bus->nr); in cx23885_i2c_register()
305 bus->i2c_adap = cx23885_i2c_adap_template; in cx23885_i2c_register()
306 bus->i2c_client = cx23885_i2c_client_template; in cx23885_i2c_register()
307 bus->i2c_adap.dev.parent = &dev->pci->dev; in cx23885_i2c_register()
309 strscpy(bus->i2c_adap.name, bus->dev->name, in cx23885_i2c_register()
310 sizeof(bus->i2c_adap.name)); in cx23885_i2c_register()
312 bus->i2c_adap.algo_data = bus; in cx23885_i2c_register()
313 i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); in cx23885_i2c_register()
314 i2c_add_adapter(&bus->i2c_adap); in cx23885_i2c_register()
316 bus->i2c_client.adapter = &bus->i2c_adap; in cx23885_i2c_register()
318 if (0 == bus->i2c_rc) { in cx23885_i2c_register()
319 dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr); in cx23885_i2c_register()
321 pr_info("%s: scan bus %d:\n", in cx23885_i2c_register()
322 dev->name, bus->nr); in cx23885_i2c_register()
323 do_i2c_scan(dev->name, &bus->i2c_client); in cx23885_i2c_register()
326 pr_warn("%s: i2c bus %d register FAILED\n", in cx23885_i2c_register()
327 dev->name, bus->nr); in cx23885_i2c_register()
330 if (0 == bus->i2c_rc) { in cx23885_i2c_register()
340 i2c_new_scanned_device(&bus->i2c_adap, &info, addr_list, in cx23885_i2c_register()
344 return bus->i2c_rc; in cx23885_i2c_register()
347 int cx23885_i2c_unregister(struct cx23885_i2c *bus) in cx23885_i2c_unregister() argument
349 i2c_del_adapter(&bus->i2c_adap); in cx23885_i2c_unregister()
355 /* write 0 to bus 2 addr 0x144 via i2x_xfer() */ in cx23885_av_clk()
368 msg.addr = 0x44; in cx23885_av_clk()
373 i2c_xfer(&dev->i2c_bus[2].i2c_adap, &msg, 1); in cx23885_av_clk()