23 #include <linux/module.h>
25 #include <linux/i2c.h>
34 #define dprintk_i2c(fmt, args...) \
37 printk(KERN_DEBUG fmt, ##args); \
40 static int stk1160_i2c_busy_wait(
struct stk1160 *
dev,
u8 wait_bit_mask)
51 if (flag & wait_bit_mask)
88 rc = stk1160_i2c_busy_wait(dev, 0x04);
95 static int stk1160_i2c_read_reg(
struct stk1160 *dev,
u8 addr,
115 rc = stk1160_i2c_busy_wait(dev, 0x01);
130 static int stk1160_i2c_check_for_device(
struct stk1160 *dev,
150 rc = stk1160_i2c_busy_wait(dev, 0x01);
161 static int stk1160_i2c_xfer(
struct i2c_adapter *i2c_adap,
162 struct i2c_msg msgs[],
int num)
167 for (i = 0; i < num; i++) {
168 addr = msgs[
i].
addr << 1;
173 rc = stk1160_i2c_check_for_device(dev, addr);
185 }
else if (i + 1 < num && msgs[i].len <= 2 &&
186 (msgs[i + 1].
flags & I2C_M_RD) &&
187 msgs[i].addr == msgs[i + 1].addr) {
189 if (msgs[i].len != 1 || msgs[i + 1].len != 1) {
197 rc = stk1160_i2c_read_reg(dev, addr, msgs[i].
buf[0],
206 if (msgs[i].len != 2) {
213 msgs[i].
buf[0], msgs[i].buf[1]);
215 rc = stk1160_i2c_write_reg(dev, addr, msgs[i].
buf[0],
239 .master_xfer = stk1160_i2c_xfer,
250 .name =
"stk1160 internal",