Lines Matching refs:i2c_base
220 static int wait_for_bb(void __iomem *i2c_base, int ip_rev, int waitdelay) in wait_for_bb() argument
230 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in wait_for_bb()
232 while ((stat = omap_i2c_read_reg(i2c_base, ip_rev, irq_stat_reg) & in wait_for_bb()
234 omap_i2c_write_reg(i2c_base, ip_rev, stat, OMAP_I2C_STAT_REG); in wait_for_bb()
244 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in wait_for_bb()
252 static u16 wait_for_event(void __iomem *i2c_base, int ip_rev, int waitdelay) in wait_for_event() argument
262 status = omap_i2c_read_reg(i2c_base, ip_rev, irq_stat_reg); in wait_for_event()
275 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in wait_for_event()
282 static void flush_fifo(void __iomem *i2c_base, int ip_rev) in flush_fifo() argument
291 stat = omap_i2c_read_reg(i2c_base, ip_rev, OMAP_I2C_STAT_REG); in flush_fifo()
293 omap_i2c_read_reg(i2c_base, ip_rev, OMAP_I2C_DATA_REG); in flush_fifo()
294 omap_i2c_write_reg(i2c_base, ip_rev, in flush_fifo()
302 static int __omap24_i2c_setspeed(void __iomem *i2c_base, int ip_rev, uint speed, in __omap24_i2c_setspeed() argument
357 omap_i2c_write_reg(i2c_base, ip_rev, 0, OMAP_I2C_CON_REG); in __omap24_i2c_setspeed()
358 omap_i2c_write_reg(i2c_base, ip_rev, psc, OMAP_I2C_PSC_REG); in __omap24_i2c_setspeed()
359 omap_i2c_write_reg(i2c_base, ip_rev, scll, OMAP_I2C_SCLL_REG); in __omap24_i2c_setspeed()
360 omap_i2c_write_reg(i2c_base, ip_rev, sclh, OMAP_I2C_SCLH_REG); in __omap24_i2c_setspeed()
361 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN, OMAP_I2C_CON_REG); in __omap24_i2c_setspeed()
364 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in __omap24_i2c_setspeed()
369 static void omap24_i2c_deblock(void __iomem *i2c_base, int ip_rev) in omap24_i2c_deblock() argument
376 orgsystest = omap_i2c_read_reg(i2c_base, ip_rev, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
381 omap_i2c_write_reg(i2c_base, ip_rev, systest, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
384 omap_i2c_write_reg(i2c_base, ip_rev, systest, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
388 omap_i2c_write_reg(i2c_base, ip_rev, systest, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
395 omap_i2c_write_reg(i2c_base, ip_rev, in omap24_i2c_deblock()
400 omap_i2c_write_reg(i2c_base, ip_rev, in omap24_i2c_deblock()
407 omap_i2c_write_reg(i2c_base, ip_rev, systest, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
410 omap_i2c_write_reg(i2c_base, ip_rev, systest, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
414 omap_i2c_write_reg(i2c_base, ip_rev, orgsystest, OMAP_I2C_SYSTEST_REG); in omap24_i2c_deblock()
417 static void __omap24_i2c_init(void __iomem *i2c_base, int ip_rev, int speed, in __omap24_i2c_init() argument
424 if (omap_i2c_read_reg(i2c_base, ip_rev, OMAP_I2C_CON_REG) & in __omap24_i2c_init()
426 omap_i2c_write_reg(i2c_base, ip_rev, 0, OMAP_I2C_CON_REG); in __omap24_i2c_init()
431 omap_i2c_write_reg(i2c_base, ip_rev, 0x2, OMAP_I2C_SYSC_REG); in __omap24_i2c_init()
434 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN, OMAP_I2C_CON_REG); in __omap24_i2c_init()
435 while (!(omap_i2c_read_reg(i2c_base, ip_rev, OMAP_I2C_SYSS_REG) & in __omap24_i2c_init()
444 if (__omap24_i2c_setspeed(i2c_base, ip_rev, speed, waitdelay)) { in __omap24_i2c_init()
450 omap_i2c_write_reg(i2c_base, ip_rev, slaveadd, OMAP_I2C_OA_REG); in __omap24_i2c_init()
457 omap_i2c_write_reg(i2c_base, ip_rev, I2C_IE_XRDY_IE | in __omap24_i2c_init()
464 flush_fifo(i2c_base, ip_rev); in __omap24_i2c_init()
465 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in __omap24_i2c_init()
468 if (wait_for_bb(i2c_base, ip_rev, *waitdelay)) in __omap24_i2c_init()
470 omap24_i2c_deblock(i2c_base, ip_rev); in __omap24_i2c_init()
480 static int __omap24_i2c_probe(void __iomem *i2c_base, int ip_rev, int waitdelay, in __omap24_i2c_probe() argument
486 if (chip == omap_i2c_read_reg(i2c_base, ip_rev, OMAP_I2C_OA_REG)) in __omap24_i2c_probe()
490 if (wait_for_bb(i2c_base, ip_rev, waitdelay)) in __omap24_i2c_probe()
494 omap_i2c_write_reg(i2c_base, ip_rev, chip, OMAP_I2C_SA_REG); in __omap24_i2c_probe()
497 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST | in __omap24_i2c_probe()
501 status = wait_for_event(i2c_base, ip_rev, waitdelay); in __omap24_i2c_probe()
522 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_MST | I2C_CON_TRX, in __omap24_i2c_probe()
525 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST | in __omap24_i2c_probe()
531 flush_fifo(i2c_base, ip_rev); in __omap24_i2c_probe()
532 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in __omap24_i2c_probe()
549 static int __omap24_i2c_read(void __iomem *i2c_base, int ip_rev, int waitdelay, in __omap24_i2c_read() argument
599 if (wait_for_bb(i2c_base, ip_rev, waitdelay)) in __omap24_i2c_read()
603 omap_i2c_write_reg(i2c_base, ip_rev, alen, OMAP_I2C_CNT_REG); in __omap24_i2c_read()
605 omap_i2c_write_reg(i2c_base, ip_rev, chip, OMAP_I2C_SA_REG); in __omap24_i2c_read()
611 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST | in __omap24_i2c_read()
615 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST | in __omap24_i2c_read()
621 status = wait_for_event(i2c_base, ip_rev, waitdelay); in __omap24_i2c_read()
640 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_read()
643 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_read()
649 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_read()
658 omap_i2c_write_reg(i2c_base, ip_rev, chip, OMAP_I2C_SA_REG); in __omap24_i2c_read()
660 omap_i2c_write_reg(i2c_base, ip_rev, len, OMAP_I2C_CNT_REG); in __omap24_i2c_read()
662 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST | in __omap24_i2c_read()
667 status = wait_for_event(i2c_base, ip_rev, waitdelay); in __omap24_i2c_read()
684 *buffer++ = omap_i2c_read_reg(i2c_base, ip_rev, in __omap24_i2c_read()
686 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_read()
690 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_read()
697 flush_fifo(i2c_base, ip_rev); in __omap24_i2c_read()
698 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in __omap24_i2c_read()
703 static int __omap24_i2c_write(void __iomem *i2c_base, int ip_rev, int waitdelay, in __omap24_i2c_write() argument
756 if (wait_for_bb(i2c_base, ip_rev, waitdelay)) in __omap24_i2c_write()
760 omap_i2c_write_reg(i2c_base, ip_rev, alen + len, OMAP_I2C_CNT_REG); in __omap24_i2c_write()
762 omap_i2c_write_reg(i2c_base, ip_rev, chip, OMAP_I2C_SA_REG); in __omap24_i2c_write()
764 omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST | in __omap24_i2c_write()
770 status = wait_for_event(i2c_base, ip_rev, waitdelay); in __omap24_i2c_write()
786 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_write()
789 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_write()
801 status = wait_for_event(i2c_base, ip_rev, waitdelay); in __omap24_i2c_write()
809 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_write()
811 omap_i2c_write_reg(i2c_base, ip_rev, in __omap24_i2c_write()
826 status = wait_for_event(i2c_base, ip_rev, waitdelay); in __omap24_i2c_write()
832 flush_fifo(i2c_base, ip_rev); in __omap24_i2c_write()
833 omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG); in __omap24_i2c_write()
886 void __iomem *i2c_base = omap24_get_base(adap); in omap24_i2c_read() local
889 return __omap24_i2c_read(i2c_base, ip_rev, adap->waitdelay, chip, addr, in omap24_i2c_read()
896 void __iomem *i2c_base = omap24_get_base(adap); in omap24_i2c_write() local
899 return __omap24_i2c_write(i2c_base, ip_rev, adap->waitdelay, chip, addr, in omap24_i2c_write()
905 void __iomem *i2c_base = omap24_get_base(adap); in omap24_i2c_setspeed() local
909 ret = __omap24_i2c_setspeed(i2c_base, ip_rev, speed, &adap->waitdelay); in omap24_i2c_setspeed()
922 void __iomem *i2c_base = omap24_get_base(adap); in omap24_i2c_init() local
925 return __omap24_i2c_init(i2c_base, ip_rev, speed, slaveadd, in omap24_i2c_init()
931 void __iomem *i2c_base = omap24_get_base(adap); in omap24_i2c_probe() local
934 return __omap24_i2c_probe(i2c_base, ip_rev, adap->waitdelay, chip); in omap24_i2c_probe()