36 #include <linux/pci.h>
82 #define SCL_WAIT_USEC 1000
87 #define TWSI_BUF_WAIT_USEC 60
108 for (rise_usec =
SCL_WAIT_USEC; rise_usec > 0; rise_usec -= 2) {
114 qib_dev_err(dd,
"SCL interface stuck low > %d uSec\n",
117 i2c_wait_for_writes(dd);
129 i2c_wait_for_writes(dd);
139 mask = (1
UL << bnum);
144 i2c_wait_for_writes(dd);
145 return (read_val & mask) >> bnum;
158 ack_received = sda_in(dd, 1);
160 ack_received = sda_in(dd, 1) == 0;
173 static int rd_byte(
struct qib_devdata *dd,
int last)
179 for (bit_cntr = 7; bit_cntr >= 0; --bit_cntr) {
182 data |= sda_in(dd, 0);
209 for (bit_cntr = 7; bit_cntr >= 0; bit_cntr--) {
210 bit = (data >> bit_cntr) & 1;
215 return (!i2c_ackrcv(dd)) ? 1 : 0;
264 int clock_cycles_left = 9;
290 while (clock_cycles_left--) {
294 was_high |= sda_in(dd, 0);
304 if ((pins & mask) != mask)
319 #define QIB_TWSI_START 0x100
320 #define QIB_TWSI_STOP 0x200
332 ret = wr_byte(dd, data);
340 #define QIB_TEMP_DEV 0x98
381 ret = qib_twsi_wr(dd, addr, 0);
386 "Failed to write interface read addr %02X\n",
411 *bp++ = rd_byte(dd, !len);
433 const void *
buffer,
int len)
437 int max_wait_time,
i;
443 if (qib_twsi_wr(dd, (addr << 1) |
WRITE_CMD,
451 ret = qib_twsi_wr(dd, addr, 0);
454 "Failed to write interface write addr %02X\n",
460 sub_len =
min(len, 4);
464 for (i = 0; i < sub_len; i++)
465 if (qib_twsi_wr(dd, *bp++, 0))
484 if (!--max_wait_time)