8 #define FC_MAX_I2C_RETRIES 100000
32 deb_i2c(
"suffering from an i2c ack_error\n");
36 deb_i2c(
"tried %d times i2c operation, "
37 "never finished or too many ack errors.\n", i);
61 ret = flexcop_i2c_operation(i2c->
fc, &r100);
63 deb_i2c(
"Retrying operation\n");
65 ret = flexcop_i2c_operation(i2c->
fc, &r100);
76 deb_i2c(
"read: r100: %08x, r104: %08x\n", r100.
raw, r104.
raw);
99 deb_i2c(
"write: r100: %08x, r104: %08x\n", r100.
raw, r104.
raw);
103 return flexcop_i2c_operation(fc, &r100);
111 #ifdef DUMP_I2C_MESSAGES
115 u16 bytes_to_transfer;
124 #ifdef DUMP_I2C_MESSAGES
130 printk(
"%02x): %02x ", chipaddr, addr);
142 bytes_to_transfer = len > 4 ? 4 : len;
144 r100.
tw_sm_c_100.total_bytes = bytes_to_transfer - 1;
148 ret = flexcop_i2c_read4(i2c, r100, buf);
150 ret = flexcop_i2c_write4(i2c->
fc, r100, buf);
152 #ifdef DUMP_I2C_MESSAGES
153 for (i = 0; i < bytes_to_transfer; i++)
160 buf += bytes_to_transfer;
161 addr += bytes_to_transfer;
162 len -= bytes_to_transfer;
165 #ifdef DUMP_I2C_MESSAGES
175 static int flexcop_master_xfer(
struct i2c_adapter *i2c_adap,
176 struct i2c_msg msgs[],
int num)
185 if (num == 1 && msgs[0].
flags ==
I2C_M_RD && msgs[0].len <= 1)
191 for (i = 0; i < num; i++) {
195 msgs[i].buf[0], msgs[i+1].buf,
200 msgs[i].buf[0], &msgs[i].buf[1],
203 deb_i2c(
"i2c master_xfer failed");
221 .master_xfer = flexcop_master_xfer,
222 .functionality = flexcop_i2c_func,