Lines Matching refs:adap
68 #define setsda(adap,val) adap->setsda(adap->data, val) argument
69 #define setscl(adap,val) adap->setscl(adap->data, val) argument
70 #define getsda(adap) adap->getsda(adap->data) argument
71 #define getscl(adap) adap->getscl(adap->data) argument
73 static inline void sdalo(struct i2c_algo_bit_data *adap) in sdalo() argument
75 setsda(adap,0); in sdalo()
76 udelay(adap->udelay); in sdalo()
79 static inline void sdahi(struct i2c_algo_bit_data *adap) in sdahi() argument
81 setsda(adap,1); in sdahi()
82 udelay(adap->udelay); in sdahi()
85 static inline void scllo(struct i2c_algo_bit_data *adap) in scllo() argument
87 setscl(adap,0); in scllo()
88 udelay(adap->udelay); in scllo()
98 static inline int sclhi(struct i2c_algo_bit_data *adap) in sclhi() argument
102 setscl(adap,1); in sclhi()
104 udelay(adap->udelay); in sclhi()
107 if (adap->getscl == NULL ) in sclhi()
110 while (! getscl(adap) ) { in sclhi()
116 setscl(adap,1); in sclhi()
117 if (time_after_eq(jiffies, start+adap->timeout)) { in sclhi()
132 static void i2c_start(struct i2c_algo_bit_data *adap) in i2c_start() argument
136 sdalo(adap); in i2c_start()
137 scllo(adap); in i2c_start()
140 static void i2c_repstart(struct i2c_algo_bit_data *adap) in i2c_repstart() argument
144 setsda(adap,1); in i2c_repstart()
145 setscl(adap,1); in i2c_repstart()
146 udelay(adap->udelay); in i2c_repstart()
148 sdalo(adap); in i2c_repstart()
149 scllo(adap); in i2c_repstart()
153 static void i2c_stop(struct i2c_algo_bit_data *adap) in i2c_stop() argument
157 sdalo(adap); in i2c_stop()
158 sclhi(adap); in i2c_stop()
159 sdahi(adap); in i2c_stop()
176 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in i2c_outb() local
182 setsda(adap,sb); in i2c_outb()
183 udelay(adap->udelay); in i2c_outb()
185 if (sclhi(adap)<0) { /* timed out */ in i2c_outb()
186 sdahi(adap); /* we don't want to block the net */ in i2c_outb()
192 setscl(adap, 0 ); in i2c_outb()
193 udelay(adap->udelay); in i2c_outb()
195 sdahi(adap); in i2c_outb()
196 if (sclhi(adap)<0){ /* timeout */ in i2c_outb()
200 ack=getsda(adap); /* ack: sda is pulled low ->success. */ in i2c_outb()
205 scllo(adap); in i2c_outb()
217 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in i2c_inb() local
222 sdahi(adap); in i2c_inb()
224 if (sclhi(adap)<0) { /* timeout */ in i2c_inb()
228 if ( getsda(adap) ) in i2c_inb()
230 scllo(adap); in i2c_inb()
241 static int test_bus(struct i2c_algo_bit_data *adap, char* name) { in test_bus() argument
243 sda=getsda(adap); in test_bus()
244 if (adap->getscl==NULL) { in test_bus()
248 scl=getscl(adap); in test_bus()
250 name,getscl(adap),getsda(adap)); in test_bus()
255 sdalo(adap); in test_bus()
256 printk("i2c-algo-bit.o:1 scl: %d sda: %d \n",getscl(adap), in test_bus()
257 getsda(adap)); in test_bus()
258 if ( 0 != getsda(adap) ) { in test_bus()
260 sdahi(adap); in test_bus()
263 if ( 0 == getscl(adap) ) { in test_bus()
268 sdahi(adap); in test_bus()
269 printk("i2c-algo-bit.o:2 scl: %d sda: %d \n",getscl(adap), in test_bus()
270 getsda(adap)); in test_bus()
271 if ( 0 == getsda(adap) ) { in test_bus()
273 sdahi(adap); in test_bus()
276 if ( 0 == getscl(adap) ) { in test_bus()
281 scllo(adap); in test_bus()
282 printk("i2c-algo-bit.o:3 scl: %d sda: %d \n",getscl(adap), in test_bus()
283 getsda(adap)); in test_bus()
284 if ( 0 != getscl(adap) ) { in test_bus()
286 sclhi(adap); in test_bus()
289 if ( 0 == getsda(adap) ) { in test_bus()
294 sclhi(adap); in test_bus()
295 printk("i2c-algo-bit.o:4 scl: %d sda: %d \n",getscl(adap), in test_bus()
296 getsda(adap)); in test_bus()
297 if ( 0 == getscl(adap) ) { in test_bus()
299 sclhi(adap); in test_bus()
302 if ( 0 == getsda(adap) ) { in test_bus()
310 sdahi(adap); in test_bus()
311 sclhi(adap); in test_bus()
328 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in try_address() local
334 i2c_stop(adap); in try_address()
338 i2c_start(adap); in try_address()
339 udelay(adap->udelay); in try_address()
348 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in sendbytes() local
366 i2c_stop(adap); in sendbytes()
379 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in readbytes() local
392 sdalo(adap); in readbytes()
395 sdahi(adap); /* neg. ack on last byte */ in readbytes()
398 if (sclhi(adap)<0) { /* timeout */ in readbytes()
399 sdahi(adap); in readbytes()
403 scllo(adap); in readbytes()
404 sdahi(adap); in readbytes()
423 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in bit_doAddress() local
445 i2c_repstart(adap); in bit_doAddress()
472 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; in bit_xfer() local
476 i2c_start(adap); in bit_xfer()
481 i2c_repstart(adap); in bit_xfer()
506 i2c_stop(adap); in bit_xfer()
516 static u32 bit_func(struct i2c_adapter *adap) in bit_func() argument
536 int i2c_bit_add_bus(struct i2c_adapter *adap) in i2c_bit_add_bus() argument
539 struct i2c_algo_bit_data *bit_adap = adap->algo_data; in i2c_bit_add_bus()
542 int ret = test_bus(bit_adap, adap->name); in i2c_bit_add_bus()
548 adap->name)); in i2c_bit_add_bus()
552 adap->id |= i2c_bit_algo.id; in i2c_bit_add_bus()
553 adap->algo = &i2c_bit_algo; in i2c_bit_add_bus()
555 adap->timeout = 100; /* default values, should */ in i2c_bit_add_bus()
556 adap->retries = 3; /* be replaced by defines */ in i2c_bit_add_bus()
562 adap->name); in i2c_bit_add_bus()
565 ack = i2c_outb(adap,i); in i2c_bit_add_bus()
579 return i2c_add_adapter(adap); in i2c_bit_add_bus()
583 int i2c_bit_del_bus(struct i2c_adapter *adap) in i2c_bit_del_bus() argument
587 if ((res = i2c_del_adapter(adap)) < 0) in i2c_bit_del_bus()
590 DEB2(printk("i2c-algo-bit.o: adapter unregistered: %s\n",adap->name)); in i2c_bit_del_bus()