Lines Matching refs:adap

57 #define set_pcf(adap, ctl, val) adap->setpcf(adap->data, ctl, val)  argument
58 #define get_pcf(adap, ctl) adap->getpcf(adap->data, ctl) argument
59 #define get_own(adap) adap->getown(adap->data) argument
60 #define get_clock(adap) adap->getclock(adap->data) argument
61 #define i2c_outb(adap, val) adap->setpcf(adap->data, 0, val) argument
62 #define i2c_inb(adap) adap->getpcf(adap->data, 0) argument
66 static void i2c_start(struct i2c_algo_pcf_data *adap) in i2c_start() argument
69 set_pcf(adap, 1, I2C_PCF_START); in i2c_start()
72 static void i2c_repstart(struct i2c_algo_pcf_data *adap) in i2c_repstart() argument
75 set_pcf(adap, 1, I2C_PCF_REPSTART); in i2c_repstart()
79 static void i2c_stop(struct i2c_algo_pcf_data *adap) in i2c_stop() argument
82 set_pcf(adap, 1, I2C_PCF_STOP); in i2c_stop()
86 static int wait_for_bb(struct i2c_algo_pcf_data *adap) { in wait_for_bb() argument
91 status = get_pcf(adap, 1); in wait_for_bb()
95 status = get_pcf(adap, 1); in wait_for_bb()
112 static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) { in wait_for_pin() argument
116 *status = get_pcf(adap, 1); in wait_for_pin()
119 adap->waitforpin(); in wait_for_pin()
120 *status = get_pcf(adap, 1); in wait_for_pin()
140 static int pcf_init_8584 (struct i2c_algo_pcf_data *adap) in pcf_init_8584() argument
144 DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n", get_pcf(adap, 1))); in pcf_init_8584()
147 set_pcf(adap, 1, I2C_PCF_PIN); in pcf_init_8584()
151 if ((temp = get_pcf(adap, 1)) != (0)) { in pcf_init_8584()
157 i2c_outb(adap, get_own(adap)); in pcf_init_8584()
159 if ((temp = i2c_inb(adap)) != get_own(adap)) { in pcf_init_8584()
165 set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1); in pcf_init_8584()
167 if ((temp = get_pcf(adap, 1)) != I2C_PCF_ES1) { in pcf_init_8584()
173 i2c_outb(adap, get_clock(adap)); in pcf_init_8584()
175 if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) { in pcf_init_8584()
181 set_pcf(adap, 1, I2C_PCF_IDLE); in pcf_init_8584()
184 if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) { in pcf_init_8584()
198 static inline int try_address(struct i2c_algo_pcf_data *adap, in try_address() argument
203 i2c_outb(adap, addr); in try_address()
204 i2c_start(adap); in try_address()
205 status = get_pcf(adap, 1); in try_address()
206 if (wait_for_pin(adap, &status) >= 0) { in try_address()
208 i2c_stop(adap); in try_address()
212 i2c_stop(adap); in try_address()
213 udelay(adap->udelay); in try_address()
224 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; in pcf_sendbytes() local
230 i2c_outb(adap, buf[wrcount]); in pcf_sendbytes()
231 timeout = wait_for_pin(adap, &status); in pcf_sendbytes()
233 i2c_stop(adap); in pcf_sendbytes()
240 i2c_stop(adap); in pcf_sendbytes()
248 i2c_stop(adap); in pcf_sendbytes()
251 i2c_repstart(adap); in pcf_sendbytes()
262 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; in pcf_readbytes() local
267 if (wait_for_pin(adap, &status)) { in pcf_readbytes()
268 i2c_stop(adap); in pcf_readbytes()
275 i2c_stop(adap); in pcf_readbytes()
282 set_pcf(adap, 1, I2C_PCF_ESO); in pcf_readbytes()
286 i2c_stop(adap); in pcf_readbytes()
288 i2c_repstart(adap); in pcf_readbytes()
293 buf[i - 1] = i2c_inb(adap); in pcf_readbytes()
295 i2c_inb(adap); /* dummy read */ in pcf_readbytes()
303 static inline int pcf_doAddress(struct i2c_algo_pcf_data *adap, in pcf_doAddress() argument
314 ret = try_address(adap, addr, retries); in pcf_doAddress()
320 i2c_outb(adap,msg->addr & 0x7f); in pcf_doAddress()
327 i2c_repstart(adap); in pcf_doAddress()
330 ret = try_address(adap, addr, retries); in pcf_doAddress()
342 i2c_outb(adap, addr); in pcf_doAddress()
351 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; in pcf_xfer() local
358 timeout = wait_for_bb(adap); in pcf_xfer()
372 ret = pcf_doAddress(adap, pmsg, i2c_adap->retries); in pcf_xfer()
376 i2c_start(adap); in pcf_xfer()
380 timeout = wait_for_pin(adap, &status); in pcf_xfer()
382 i2c_stop(adap); in pcf_xfer()
391 i2c_stop(adap); in pcf_xfer()
434 static u32 pcf_func(struct i2c_adapter *adap) in pcf_func() argument
453 int i2c_pcf_add_bus(struct i2c_adapter *adap) in i2c_pcf_add_bus() argument
456 struct i2c_algo_pcf_data *pcf_adap = adap->algo_data; in i2c_pcf_add_bus()
459 adap->name)); in i2c_pcf_add_bus()
463 adap->id |= pcf_algo.id; in i2c_pcf_add_bus()
464 adap->algo = &pcf_algo; in i2c_pcf_add_bus()
466 adap->timeout = 100; /* default values, should */ in i2c_pcf_add_bus()
467 adap->retries = 3; /* be replaced by defines */ in i2c_pcf_add_bus()
480 adap->name); in i2c_pcf_add_bus()
484 adap->name); in i2c_pcf_add_bus()
501 return i2c_add_adapter(adap); in i2c_pcf_add_bus()
505 int i2c_pcf_del_bus(struct i2c_adapter *adap) in i2c_pcf_del_bus() argument
508 if ((res = i2c_del_adapter(adap)) < 0) in i2c_pcf_del_bus()
510 DEB2(printk("i2c-algo-pcf.o: adapter unregistered: %s\n",adap->name)); in i2c_pcf_del_bus()