Lines Matching refs:i2c_base
117 static int wait_for_bb(struct i2c *i2c_base, int waitdelay) argument
122 writew(0xFFFF, &i2c_base->stat); /* clear current interrupts...*/
124 while ((stat = readw(&i2c_base->stat) & I2C_STAT_BB) && timeout--) {
127 while ((stat = readw(&i2c_base->irqstatus_raw) &
130 writew(stat, &i2c_base->stat);
139 writew(0xFFFF, &i2c_base->stat); /* clear delayed stuff*/
147 static u16 wait_for_event(struct i2c *i2c_base, int waitdelay) argument
155 status = readw(&i2c_base->stat);
158 status = readw(&i2c_base->irqstatus_raw);
173 writew(0xFFFF, &i2c_base->stat);
180 static void flush_fifo(struct i2c *i2c_base) argument
189 stat = readw(&i2c_base->stat);
191 readb(&i2c_base->data);
192 writew(I2C_STAT_RRDY, &i2c_base->stat);
199 static int __omap24_i2c_setspeed(struct i2c *i2c_base, uint speed, argument
252 writew(0, &i2c_base->con);
253 writew(psc, &i2c_base->psc);
254 writew(scll, &i2c_base->scll);
255 writew(sclh, &i2c_base->sclh);
256 writew(I2C_CON_EN, &i2c_base->con);
257 writew(0xFFFF, &i2c_base->stat); /* clear all pending status */
262 static void omap24_i2c_deblock(struct i2c *i2c_base) argument
269 orgsystest = readw(&i2c_base->systest);
273 writew(systest, &i2c_base->systest);
276 writew(systest, &i2c_base->systest);
280 writew(systest, &i2c_base->systest);
287 writew(systest, &i2c_base->systest);
291 writew(systest, &i2c_base->systest);
297 writew(systest, &i2c_base->systest);
300 writew(systest, &i2c_base->systest);
304 writew(orgsystest, &i2c_base->systest);
307 static void __omap24_i2c_init(struct i2c *i2c_base, int speed, int slaveadd, argument
314 if (readw(&i2c_base->con) & I2C_CON_EN) {
315 writew(0, &i2c_base->con);
319 writew(0x2, &i2c_base->sysc); /* for ES2 after soft reset */
322 writew(I2C_CON_EN, &i2c_base->con);
323 while (!(readw(&i2c_base->syss) & I2C_SYSS_RDONE) && timeout--) {
331 if (0 != __omap24_i2c_setspeed(i2c_base, speed, waitdelay)) {
337 writew(slaveadd, &i2c_base->oa);
345 I2C_IE_NACK_IE | I2C_IE_AL_IE, &i2c_base->ie);
348 flush_fifo(i2c_base);
349 writew(0xFFFF, &i2c_base->stat);
352 if (wait_for_bb(i2c_base, *waitdelay))
354 omap24_i2c_deblock(i2c_base);
364 static int __omap24_i2c_probe(struct i2c *i2c_base, int waitdelay, uchar chip) argument
369 if (chip == readw(&i2c_base->oa))
373 if (wait_for_bb(i2c_base, waitdelay))
377 writew(chip, &i2c_base->sa);
380 I2C_CON_STP, &i2c_base->con);
382 status = wait_for_event(i2c_base, waitdelay);
403 writew(I2C_CON_MST | I2C_CON_TRX, &i2c_base->con); /* Reset */
406 I2C_CON_STP, &i2c_base->con); /* STP */
409 flush_fifo(i2c_base);
410 writew(0xFFFF, &i2c_base->stat);
427 static int __omap24_i2c_read(struct i2c *i2c_base, int waitdelay, uchar chip, argument
474 if (wait_for_bb(i2c_base, waitdelay))
478 writew(alen, &i2c_base->cnt);
480 writew(chip, &i2c_base->sa);
487 I2C_CON_TRX, &i2c_base->con);
491 I2C_CON_TRX, &i2c_base->con);
495 status = wait_for_event(i2c_base, waitdelay);
514 &i2c_base->data);
515 writew(I2C_STAT_XRDY, &i2c_base->stat);
519 writew(I2C_STAT_ARDY, &i2c_base->stat);
525 writew(chip, &i2c_base->sa);
527 writew(len, &i2c_base->cnt);
531 &i2c_base->con);
535 status = wait_for_event(i2c_base, waitdelay);
552 *buffer++ = readb(&i2c_base->data);
553 writew(I2C_STAT_RRDY, &i2c_base->stat);
556 writew(I2C_STAT_ARDY, &i2c_base->stat);
562 flush_fifo(i2c_base);
563 writew(0xFFFF, &i2c_base->stat);
568 static int __omap24_i2c_write(struct i2c *i2c_base, int waitdelay, uchar chip, argument
620 if (wait_for_bb(i2c_base, waitdelay))
624 writew(alen + len, &i2c_base->cnt);
626 writew(chip, &i2c_base->sa);
629 I2C_CON_STP, &i2c_base->con);
633 status = wait_for_event(i2c_base, waitdelay);
649 writeb((addr >> (8 * alen)) & 0xff, &i2c_base->data);
650 writew(I2C_STAT_XRDY, &i2c_base->stat);
660 status = wait_for_event(i2c_base, waitdelay);
668 writeb(buffer[i], &i2c_base->data);
669 writew(I2C_STAT_XRDY, &i2c_base->stat);
682 status = wait_for_event(i2c_base, waitdelay);
688 flush_fifo(i2c_base);
689 writew(0xFFFF, &i2c_base->stat);
733 struct i2c *i2c_base = omap24_get_base(adap); local
735 return __omap24_i2c_read(i2c_base, adap->waitdelay, chip, addr,
743 struct i2c *i2c_base = omap24_get_base(adap); local
745 return __omap24_i2c_write(i2c_base, adap->waitdelay, chip, addr,
751 struct i2c *i2c_base = omap24_get_base(adap); local
754 ret = __omap24_i2c_setspeed(i2c_base, speed, &adap->waitdelay);
767 struct i2c *i2c_base = omap24_get_base(adap); local
769 return __omap24_i2c_init(i2c_base, speed, slaveadd, &adap->waitdelay);
774 struct i2c *i2c_base = omap24_get_base(adap); local
776 return __omap24_i2c_probe(i2c_base, adap->waitdelay, chip);