Lines Matching refs:adap
87 #define get_clock(adap) adap->getclock(adap->data) argument
88 #define iic_outw(adap, reg, val) adap->setiic(adap->data, reg, val) argument
89 #define iic_inw(adap, reg) adap->getiic(adap->data, reg) argument
94 static void iic_start(struct i2c_algo_iic_data *adap) in iic_start() argument
96 iic_outw(adap,ITE_I2CHCR,ITE_CMD); in iic_start()
99 static void iic_stop(struct i2c_algo_iic_data *adap) in iic_stop() argument
101 iic_outw(adap,ITE_I2CHCR,0); in iic_stop()
102 iic_outw(adap,ITE_I2CHSR,ITE_I2CHSR_TDI); in iic_stop()
105 static void iic_reset(struct i2c_algo_iic_data *adap) in iic_reset() argument
107 iic_outw(adap, PM_IBSR, iic_inw(adap, PM_IBSR) | 0x80); in iic_reset()
111 static int wait_for_bb(struct i2c_algo_iic_data *adap) in wait_for_bb() argument
116 status = iic_inw(adap, ITE_I2CHSR); in wait_for_bb()
120 status = iic_inw(adap, ITE_I2CHSR); in wait_for_bb()
125 iic_reset(adap); in wait_for_bb()
142 static int wait_for_pin(struct i2c_algo_iic_data *adap, short *status) { in wait_for_pin() argument
146 timeout = wait_for_bb(adap); in wait_for_pin()
153 *status = iic_inw(adap, ITE_I2CHSR); in wait_for_pin()
156 adap->waitforpin(); in wait_for_pin()
157 *status = iic_inw(adap, ITE_I2CHSR); in wait_for_pin()
166 static int wait_for_fe(struct i2c_algo_iic_data *adap, short *status) in wait_for_fe() argument
170 *status = iic_inw(adap, ITE_I2CFSR); in wait_for_fe()
174 iic_inw(adap, ITE_I2CFSR); in wait_for_fe()
183 static int iic_init (struct i2c_algo_iic_data *adap) in iic_init() argument
188 i=iic_inw(adap, PM_DSR)& 0xff7f; in iic_init()
189 iic_outw(adap, PM_DSR, i); in iic_init()
192 i = iic_inw(adap, GPIO_CCR) & 0xfc0f; in iic_init()
193 iic_outw(adap,GPIO_CCR,i); in iic_init()
196 iic_outw(adap,ITE_I2CSAR, 0); in iic_init()
197 iic_outw(adap,ITE_I2CSSAR, 0); in iic_init()
200 iic_outw(adap,ITE_I2CCKCNT, get_clock(adap)); in iic_init()
203 iic_outw(adap,ITE_I2CSHDR, 0x0a); in iic_init()
204 iic_outw(adap,ITE_I2CRSUR, 0x0a); in iic_init()
205 iic_outw(adap,ITE_I2CPSUR, 0x0a); in iic_init()
208 iic_outw(adap,ITE_I2CHCR, ITE_I2CHCR_IE | ITE_I2CHCR_HCE); in iic_init()
211 iic_outw(adap,ITE_I2CFBCR, 0x0); in iic_init()
214 iic_inw(adap, ITE_I2CHSR))); in iic_init()
223 static int test_bus(struct i2c_algo_iic_data *adap, char *name) { in test_bus() argument
226 sda=getsda(adap); in test_bus()
227 if (adap->getscl==NULL) { in test_bus()
231 scl=getscl(adap); in test_bus()
233 name,getscl(adap),getsda(adap)); in test_bus()
235 printk("test_bus: %s seems to be busy.\n",adap->name); in test_bus()
238 sdalo(adap); in test_bus()
239 printk("test_bus:1 scl: %d sda: %d \n",getscl(adap), in test_bus()
240 getsda(adap)); in test_bus()
241 if ( 0 != getsda(adap) ) { in test_bus()
243 sdahi(adap); in test_bus()
246 if ( 0 == getscl(adap) ) { in test_bus()
251 sdahi(adap); in test_bus()
252 printk("test_bus:2 scl: %d sda: %d \n",getscl(adap), in test_bus()
253 getsda(adap)); in test_bus()
254 if ( 0 == getsda(adap) ) { in test_bus()
256 sdahi(adap); in test_bus()
259 if ( 0 == getscl(adap) ) { in test_bus()
261 adap->name); in test_bus()
264 scllo(adap); in test_bus()
265 printk("test_bus:3 scl: %d sda: %d \n",getscl(adap), in test_bus()
266 getsda(adap)); in test_bus()
267 if ( 0 != getscl(adap) ) { in test_bus()
269 sclhi(adap); in test_bus()
272 if ( 0 == getsda(adap) ) { in test_bus()
277 sclhi(adap); in test_bus()
278 printk("test_bus:4 scl: %d sda: %d \n",getscl(adap), in test_bus()
279 getsda(adap)); in test_bus()
280 if ( 0 == getscl(adap) ) { in test_bus()
282 sclhi(adap); in test_bus()
285 if ( 0 == getsda(adap) ) { in test_bus()
293 sdahi(adap); in test_bus()
294 sclhi(adap); in test_bus()
305 static inline int try_address(struct i2c_algo_iic_data *adap, in try_address() argument
312 iic_outw(adap, ITE_I2CSAR, addr); in try_address()
313 iic_start(adap); in try_address()
314 if (wait_for_pin(adap, &status) == 0) { in try_address()
316 iic_stop(adap); in try_address()
317 iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH); in try_address()
322 iic_stop(adap); in try_address()
323 udelay(adap->udelay); in try_address()
334 struct i2c_algo_iic_data *adap = i2c_adap->algo_data; in iic_sendbytes() local
343 iic_outw(adap, ITE_I2CSSAR, (unsigned short)buf[wrcount++]); in iic_sendbytes()
354 iic_outw(adap, ITE_I2CFBCR, 32); in iic_sendbytes()
358 iic_outw(adap, ITE_I2CFDR, tmp.word); in iic_sendbytes()
362 iic_inw(adap, ITE_I2CFSR); in iic_sendbytes()
363 iic_inw(adap, ITE_I2CFBCR); in iic_sendbytes()
365 iic_outw(adap, ITE_I2CHCR, ITE_WRITE); /* Issue WRITE command */ in iic_sendbytes()
368 timeout = wait_for_pin(adap, &status); in iic_sendbytes()
370 iic_stop(adap); in iic_sendbytes()
375 iic_stop(adap); in iic_sendbytes()
382 iic_outw(adap, ITE_I2CFBCR, remainder); in iic_sendbytes()
386 iic_outw(adap, ITE_I2CFDR, tmp.word); in iic_sendbytes()
390 iic_inw(adap, ITE_I2CFSR); in iic_sendbytes()
391 iic_inw(adap, ITE_I2CFBCR); in iic_sendbytes()
393 iic_outw(adap, ITE_I2CHCR, ITE_WRITE); /* Issue WRITE command */ in iic_sendbytes()
395 timeout = wait_for_pin(adap, &status); in iic_sendbytes()
397 iic_stop(adap); in iic_sendbytes()
403 iic_stop(adap); in iic_sendbytes()
409 iic_stop(adap); in iic_sendbytes()
419 struct i2c_algo_iic_data *adap = i2c_adap->algo_data; in iic_readbytes() local
431 iic_outw(adap, ITE_I2CFBCR, 32); in iic_readbytes()
433 iic_outw(adap, ITE_I2CHCR, ITE_SREAD); in iic_readbytes()
435 iic_outw(adap, ITE_I2CHCR, ITE_READ); /* Issue READ command */ in iic_readbytes()
437 timeout = wait_for_pin(adap, &status); in iic_readbytes()
439 iic_stop(adap); in iic_readbytes()
445 iic_stop(adap); in iic_readbytes()
451 timeout = wait_for_fe(adap, &status); in iic_readbytes()
453 iic_stop(adap); in iic_readbytes()
459 tmp.word = iic_inw(adap, ITE_I2CFDR); in iic_readbytes()
465 iic_inw(adap, ITE_I2CFSR); in iic_readbytes()
473 iic_outw(adap, ITE_I2CFBCR, remainder); in iic_readbytes()
475 iic_outw(adap, ITE_I2CHCR, ITE_SREAD); in iic_readbytes()
477 iic_outw(adap, ITE_I2CHCR, ITE_READ); /* Issue READ command */ in iic_readbytes()
479 timeout = wait_for_pin(adap, &status); in iic_readbytes()
481 iic_stop(adap); in iic_readbytes()
487 iic_stop(adap); in iic_readbytes()
492 timeout = wait_for_fe(adap, &status); in iic_readbytes()
494 iic_stop(adap); in iic_readbytes()
500 tmp.word = iic_inw(adap, ITE_I2CFDR); in iic_readbytes()
506 iic_inw(adap, ITE_I2CFSR); in iic_readbytes()
510 iic_stop(adap); in iic_readbytes()
565 static inline int iic_doAddress(struct i2c_algo_iic_data *adap, in iic_doAddress() argument
577 ret = try_address(adap, addr, retries); in iic_doAddress()
582 iic_outw(adap,msg->addr & 0x7f); in iic_doAddress()
588 i2c_repstart(adap); in iic_doAddress()
590 ret = try_address(adap, addr, retries); in iic_doAddress()
608 if (iic_inw(adap, ITE_I2CSAR) != addr) { in iic_doAddress()
609 iic_outw(adap, ITE_I2CSAR, addr); in iic_doAddress()
610 ret = try_address(adap, addr, retries); in iic_doAddress()
634 struct i2c_algo_iic_data *adap = i2c_adap->algo_data; in iic_xfer() local
651 timeout = wait_for_bb(adap); in iic_xfer()
658 iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH); in iic_xfer()
661 ret = iic_doAddress(adap, pmsg, i2c_adap->retries); in iic_xfer()
704 struct i2c_algo_iic_data *adap = adapter->algo_data; in algo_control() local
718 iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH); in algo_control()
721 iic_outw(adap, ITE_I2CSAR,s_msg.addr<<1); in algo_control()
722 iic_outw(adap, ITE_I2CSSAR,s_msg.waddr & 0xff); in algo_control()
735 static u32 iic_func(struct i2c_adapter *adap) in iic_func() argument
758 int i2c_iic_add_bus(struct i2c_adapter *adap) in i2c_iic_add_bus() argument
762 struct i2c_algo_iic_data *iic_adap = adap->algo_data; in i2c_iic_add_bus()
765 int ret = test_bus(iic_adap, adap->name); in i2c_iic_add_bus()
771 adap->name)); in i2c_iic_add_bus()
775 adap->id |= iic_algo.id; in i2c_iic_add_bus()
776 adap->algo = &iic_algo; in i2c_iic_add_bus()
778 adap->timeout = 100; /* default values, should */ in i2c_iic_add_bus()
779 adap->retries = 3; /* be replaced by defines */ in i2c_iic_add_bus()
780 adap->flags = 0; in i2c_iic_add_bus()
792 adap->name); in i2c_iic_add_bus()
807 return i2c_add_adapter(adap); in i2c_iic_add_bus()
811 int i2c_iic_del_bus(struct i2c_adapter *adap) in i2c_iic_del_bus() argument
814 if ((res = i2c_del_adapter(adap)) < 0) in i2c_iic_del_bus()
816 DEB2(printk("i2c-algo-ite: adapter unregistered: %s\n",adap->name)); in i2c_iic_del_bus()