Lines Matching +full:bus +full:- +full:addr

1 // SPDX-License-Identifier: GPL-2.0-or-later
22 MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
27 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ##arg); \
38 struct cx25821_i2c *bus = i2c_adap->algo_data; in i2c_slave_did_ack() local
39 struct cx25821_dev *dev = bus->dev; in i2c_slave_did_ack()
40 return cx_read(bus->reg_stat) & 0x01; in i2c_slave_did_ack()
45 struct cx25821_i2c *bus = i2c_adap->algo_data; in i2c_is_busy() local
46 struct cx25821_dev *dev = bus->dev; in i2c_is_busy()
47 return cx_read(bus->reg_stat) & 0x02 ? 1 : 0; in i2c_is_busy()
69 struct cx25821_i2c *bus = i2c_adap->algo_data; in i2c_sendbytes() local
70 struct cx25821_dev *dev = bus->dev; in i2c_sendbytes()
71 u32 wdata, addr, ctrl; in i2c_sendbytes() local
75 dprintk(1, "%s(msg->wlen=%d, nextmsg->rlen=%d)\n", __func__, in i2c_sendbytes()
76 msg->len, joined_rlen); in i2c_sendbytes()
78 dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); in i2c_sendbytes()
81 if (msg->len == 0) { in i2c_sendbytes()
82 cx_write(bus->reg_addr, msg->addr << 25); in i2c_sendbytes()
83 cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); in i2c_sendbytes()
86 return -EIO; in i2c_sendbytes()
89 return -EIO; in i2c_sendbytes()
96 addr = (msg->addr << 25) | msg->buf[0]; in i2c_sendbytes()
97 wdata = msg->buf[0]; in i2c_sendbytes()
99 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); in i2c_sendbytes()
101 if (msg->len > 1) in i2c_sendbytes()
106 cx_write(bus->reg_addr, addr); in i2c_sendbytes()
107 cx_write(bus->reg_wdata, wdata); in i2c_sendbytes()
108 cx_write(bus->reg_ctrl, ctrl); in i2c_sendbytes()
122 for (cnt = 1; cnt < msg->len; cnt++) { in i2c_sendbytes()
124 wdata = msg->buf[cnt]; in i2c_sendbytes()
125 ctrl = bus->i2c_period | (1 << 12) | (1 << 2); in i2c_sendbytes()
127 if (cnt < msg->len - 1) in i2c_sendbytes()
132 cx_write(bus->reg_addr, addr); in i2c_sendbytes()
133 cx_write(bus->reg_wdata, wdata); in i2c_sendbytes()
134 cx_write(bus->reg_ctrl, ctrl); in i2c_sendbytes()
144 dprintk(1, " %02x", msg->buf[cnt]); in i2c_sendbytes()
150 return msg->len; in i2c_sendbytes()
153 retval = -EIO; in i2c_sendbytes()
163 struct cx25821_i2c *bus = i2c_adap->algo_data; in i2c_readbytes() local
164 struct cx25821_dev *dev = bus->dev; in i2c_readbytes()
169 dprintk(1, "6-%s(msg->len=%d)\n", __func__, msg->len); in i2c_readbytes()
172 if (msg->len == 0) { in i2c_readbytes()
173 cx_write(bus->reg_addr, msg->addr << 25); in i2c_readbytes()
174 cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2) | 1); in i2c_readbytes()
176 return -EIO; in i2c_readbytes()
178 return -EIO; in i2c_readbytes()
188 dprintk(1, " <R %02x", (msg->addr << 1) + 1); in i2c_readbytes()
191 for (cnt = 0; cnt < msg->len; cnt++) { in i2c_readbytes()
193 ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; in i2c_readbytes()
195 if (cnt < msg->len - 1) in i2c_readbytes()
198 cx_write(bus->reg_addr, msg->addr << 25); in i2c_readbytes()
199 cx_write(bus->reg_ctrl, ctrl); in i2c_readbytes()
206 msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; in i2c_readbytes()
209 dprintk(1, " %02x", msg->buf[cnt]); in i2c_readbytes()
215 return msg->len; in i2c_readbytes()
217 retval = -EIO; in i2c_readbytes()
226 struct cx25821_i2c *bus = i2c_adap->algo_data; in i2c_xfer() local
227 struct cx25821_dev *dev = bus->dev; in i2c_xfer()
233 dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", in i2c_xfer()
234 __func__, num, msgs[i].addr, msgs[i].len); in i2c_xfer()
240 msgs[i].addr == msgs[i + 1].addr) { in i2c_xfer()
289 int cx25821_i2c_register(struct cx25821_i2c *bus) in cx25821_i2c_register() argument
291 struct cx25821_dev *dev = bus->dev; in cx25821_i2c_register()
293 dprintk(1, "%s(bus = %d)\n", __func__, bus->nr); in cx25821_i2c_register()
295 bus->i2c_adap = cx25821_i2c_adap_template; in cx25821_i2c_register()
296 bus->i2c_client = cx25821_i2c_client_template; in cx25821_i2c_register()
297 bus->i2c_adap.dev.parent = &dev->pci->dev; in cx25821_i2c_register()
299 strscpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); in cx25821_i2c_register()
301 bus->i2c_adap.algo_data = bus; in cx25821_i2c_register()
302 i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); in cx25821_i2c_register()
303 i2c_add_adapter(&bus->i2c_adap); in cx25821_i2c_register()
305 bus->i2c_client.adapter = &bus->i2c_adap; in cx25821_i2c_register()
308 bus->i2c_client.addr = (0x88 >> 1); in cx25821_i2c_register()
310 return bus->i2c_rc; in cx25821_i2c_register()
313 int cx25821_i2c_unregister(struct cx25821_i2c *bus) in cx25821_i2c_unregister() argument
315 i2c_del_adapter(&bus->i2c_adap); in cx25821_i2c_unregister()
322 /* write 0 to bus 2 addr 0x144 via i2x_xfer() */
335 msg.addr = 0x44;
340 i2c_xfer(&dev->i2c_bus[0].i2c_adap, &msg, 1);
344 int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) in cx25821_i2c_read() argument
346 struct i2c_client *client = &bus->i2c_client; in cx25821_i2c_read()
348 u8 addr[2] = { 0, 0 }; in cx25821_i2c_read() local
353 .addr = client->addr, in cx25821_i2c_read()
356 .buf = addr, in cx25821_i2c_read()
358 .addr = client->addr, in cx25821_i2c_read()
365 addr[0] = (reg_addr >> 8); in cx25821_i2c_read()
366 addr[1] = (reg_addr & 0xff); in cx25821_i2c_read()
367 msgs[0].addr = 0x44; in cx25821_i2c_read()
368 msgs[1].addr = 0x44; in cx25821_i2c_read()
370 i2c_xfer(client->adapter, msgs, 2); in cx25821_i2c_read()
378 int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value) in cx25821_i2c_write() argument
380 struct i2c_client *client = &bus->i2c_client; in cx25821_i2c_write()
386 .addr = client->addr, in cx25821_i2c_write()
399 client->flags = 0; in cx25821_i2c_write()
400 msgs[0].addr = 0x44; in cx25821_i2c_write()
402 retval = i2c_xfer(client->adapter, msgs, 1); in cx25821_i2c_write()