Lines Matching full:omap
3 * TI OMAP I2C master mode driver
31 #include <linux/platform_data/i2c-omap.h>
265 static int omap_i2c_xfer_data(struct omap_i2c_dev *omap);
267 static inline void omap_i2c_write_reg(struct omap_i2c_dev *omap, in omap_i2c_write_reg() argument
270 writew_relaxed(val, omap->base + in omap_i2c_write_reg()
271 (omap->regs[reg] << omap->reg_shift)); in omap_i2c_write_reg()
274 static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *omap, int reg) in omap_i2c_read_reg() argument
276 return readw_relaxed(omap->base + in omap_i2c_read_reg()
277 (omap->regs[reg] << omap->reg_shift)); in omap_i2c_read_reg()
280 static void __omap_i2c_init(struct omap_i2c_dev *omap) in __omap_i2c_init() argument
283 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); in __omap_i2c_init()
286 omap_i2c_write_reg(omap, OMAP_I2C_PSC_REG, omap->pscstate); in __omap_i2c_init()
289 omap_i2c_write_reg(omap, OMAP_I2C_SCLL_REG, omap->scllstate); in __omap_i2c_init()
290 omap_i2c_write_reg(omap, OMAP_I2C_SCLH_REG, omap->sclhstate); in __omap_i2c_init()
291 if (omap->rev >= OMAP_I2C_REV_ON_3430_3530) in __omap_i2c_init()
292 omap_i2c_write_reg(omap, OMAP_I2C_WE_REG, omap->westate); in __omap_i2c_init()
295 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); in __omap_i2c_init()
307 if (omap->iestate) in __omap_i2c_init()
308 omap_i2c_write_reg(omap, OMAP_I2C_IE_REG, omap->iestate); in __omap_i2c_init()
311 static int omap_i2c_reset(struct omap_i2c_dev *omap) in omap_i2c_reset() argument
316 if (omap->rev >= OMAP_I2C_OMAP1_REV_2) { in omap_i2c_reset()
317 sysc = omap_i2c_read_reg(omap, OMAP_I2C_SYSC_REG); in omap_i2c_reset()
320 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, in omap_i2c_reset()
321 omap_i2c_read_reg(omap, OMAP_I2C_CON_REG) & in omap_i2c_reset()
324 omap_i2c_write_reg(omap, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK); in omap_i2c_reset()
328 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); in omap_i2c_reset()
329 while (!(omap_i2c_read_reg(omap, OMAP_I2C_SYSS_REG) & in omap_i2c_reset()
332 dev_warn(omap->dev, "timeout waiting " in omap_i2c_reset()
340 omap_i2c_write_reg(omap, OMAP_I2C_SYSC_REG, sysc); in omap_i2c_reset()
342 if (omap->rev > OMAP_I2C_REV_ON_3430_3530) { in omap_i2c_reset()
344 omap->bb_valid = 0; in omap_i2c_reset()
351 static int omap_i2c_init(struct omap_i2c_dev *omap) in omap_i2c_init() argument
360 if (omap->rev >= OMAP_I2C_REV_ON_3430_3530) { in omap_i2c_init()
366 omap->westate = OMAP_I2C_WE_ALL; in omap_i2c_init()
369 if (omap->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) { in omap_i2c_init()
376 fclk = clk_get(omap->dev, "fck"); in omap_i2c_init()
379 dev_err(omap->dev, "could not get fck: %i\n", error); in omap_i2c_init()
400 if (!(omap->flags & OMAP_I2C_FLAG_SIMPLE_CLOCK)) { in omap_i2c_init()
408 if (omap->speed > 400 || in omap_i2c_init()
409 omap->flags & OMAP_I2C_FLAG_FORCE_19200_INT_CLK) in omap_i2c_init()
411 else if (omap->speed > 100) in omap_i2c_init()
415 fclk = clk_get(omap->dev, "fck"); in omap_i2c_init()
418 dev_err(omap->dev, "could not get fck: %i\n", error); in omap_i2c_init()
430 if (omap->speed > 400) { in omap_i2c_init()
439 scl = fclk_rate / omap->speed; in omap_i2c_init()
442 } else if (omap->speed > 100) { in omap_i2c_init()
446 scl = internal_clk / omap->speed; in omap_i2c_init()
451 fsscll = internal_clk / (omap->speed * 2) - 7; in omap_i2c_init()
452 fssclh = internal_clk / (omap->speed * 2) - 5; in omap_i2c_init()
461 scll = fclk_rate / (omap->speed * 2) - 7 + psc; in omap_i2c_init()
462 sclh = fclk_rate / (omap->speed * 2) - 7 + psc; in omap_i2c_init()
465 omap->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | in omap_i2c_init()
467 OMAP_I2C_IE_AL) | ((omap->fifo_size) ? in omap_i2c_init()
470 omap->pscstate = psc; in omap_i2c_init()
471 omap->scllstate = scll; in omap_i2c_init()
472 omap->sclhstate = sclh; in omap_i2c_init()
474 if (omap->rev <= OMAP_I2C_REV_ON_3430_3530) { in omap_i2c_init()
476 omap->bb_valid = 1; in omap_i2c_init()
479 __omap_i2c_init(omap); in omap_i2c_init()
487 static int omap_i2c_recover_bus(struct omap_i2c_dev *omap) in omap_i2c_recover_bus() argument
491 systest = omap_i2c_read_reg(omap, OMAP_I2C_SYSTEST_REG); in omap_i2c_recover_bus()
497 return i2c_recover_bus(&omap->adapter); in omap_i2c_recover_bus()
503 static int omap_i2c_wait_for_bb(struct omap_i2c_dev *omap) in omap_i2c_wait_for_bb() argument
508 while (omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) { in omap_i2c_wait_for_bb()
510 return omap_i2c_recover_bus(omap); in omap_i2c_wait_for_bb()
545 static int omap_i2c_wait_for_bb_valid(struct omap_i2c_dev *omap) in omap_i2c_wait_for_bb_valid() argument
552 if (omap->bb_valid) in omap_i2c_wait_for_bb_valid()
557 stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); in omap_i2c_wait_for_bb_valid()
570 systest = omap_i2c_read_reg(omap, OMAP_I2C_SYSTEST_REG); in omap_i2c_wait_for_bb_valid()
596 dev_warn(omap->dev, "timeout waiting for bus ready\n"); in omap_i2c_wait_for_bb_valid()
597 return omap_i2c_recover_bus(omap); in omap_i2c_wait_for_bb_valid()
603 omap->bb_valid = 1; in omap_i2c_wait_for_bb_valid()
607 static void omap_i2c_resize_fifo(struct omap_i2c_dev *omap, u8 size, bool is_rx) in omap_i2c_resize_fifo() argument
611 if (omap->flags & OMAP_I2C_FLAG_NO_FIFO) in omap_i2c_resize_fifo()
621 omap->threshold = clamp(size, (u8) 1, omap->fifo_size); in omap_i2c_resize_fifo()
623 buf = omap_i2c_read_reg(omap, OMAP_I2C_BUF_REG); in omap_i2c_resize_fifo()
628 buf |= ((omap->threshold - 1) << 8) | OMAP_I2C_BUF_RXFIF_CLR; in omap_i2c_resize_fifo()
632 buf |= (omap->threshold - 1) | OMAP_I2C_BUF_TXFIF_CLR; in omap_i2c_resize_fifo()
635 omap_i2c_write_reg(omap, OMAP_I2C_BUF_REG, buf); in omap_i2c_resize_fifo()
637 if (omap->rev < OMAP_I2C_REV_ON_3630) in omap_i2c_resize_fifo()
638 omap->b_hw = 1; /* Enable hardware fixes */ in omap_i2c_resize_fifo()
641 if (omap->set_mpu_wkup_lat != NULL) in omap_i2c_resize_fifo()
642 omap->latency = (1000000 * omap->threshold) / in omap_i2c_resize_fifo()
643 (1000 * omap->speed / 8); in omap_i2c_resize_fifo()
646 static void omap_i2c_wait(struct omap_i2c_dev *omap) in omap_i2c_wait() argument
649 u16 mask = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG); in omap_i2c_wait()
653 stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); in omap_i2c_wait()
664 struct omap_i2c_dev *omap = i2c_get_adapdata(adap); in omap_i2c_xfer_msg() local
669 dev_dbg(omap->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", in omap_i2c_xfer_msg()
672 omap->receiver = !!(msg->flags & I2C_M_RD); in omap_i2c_xfer_msg()
673 omap_i2c_resize_fifo(omap, msg->len, omap->receiver); in omap_i2c_xfer_msg()
675 omap_i2c_write_reg(omap, OMAP_I2C_SA_REG, msg->addr); in omap_i2c_xfer_msg()
678 omap->buf = msg->buf; in omap_i2c_xfer_msg()
679 omap->buf_len = msg->len; in omap_i2c_xfer_msg()
681 /* make sure writes to omap->buf_len are ordered */ in omap_i2c_xfer_msg()
684 omap_i2c_write_reg(omap, OMAP_I2C_CNT_REG, omap->buf_len); in omap_i2c_xfer_msg()
687 w = omap_i2c_read_reg(omap, OMAP_I2C_BUF_REG); in omap_i2c_xfer_msg()
689 omap_i2c_write_reg(omap, OMAP_I2C_BUF_REG, w); in omap_i2c_xfer_msg()
692 reinit_completion(&omap->cmd_complete); in omap_i2c_xfer_msg()
693 omap->cmd_err = 0; in omap_i2c_xfer_msg()
698 if (omap->speed > 400) in omap_i2c_xfer_msg()
708 if (!omap->b_hw && stop) in omap_i2c_xfer_msg()
715 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, w); in omap_i2c_xfer_msg()
720 if (omap->b_hw && stop) { in omap_i2c_xfer_msg()
722 u16 con = omap_i2c_read_reg(omap, OMAP_I2C_CON_REG); in omap_i2c_xfer_msg()
724 con = omap_i2c_read_reg(omap, OMAP_I2C_CON_REG); in omap_i2c_xfer_msg()
728 dev_err(omap->dev, "controller timed out " in omap_i2c_xfer_msg()
737 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, w); in omap_i2c_xfer_msg()
745 timeout = wait_for_completion_timeout(&omap->cmd_complete, in omap_i2c_xfer_msg()
749 omap_i2c_wait(omap); in omap_i2c_xfer_msg()
750 ret = omap_i2c_xfer_data(omap); in omap_i2c_xfer_msg()
757 dev_err(omap->dev, "controller timed out\n"); in omap_i2c_xfer_msg()
758 omap_i2c_reset(omap); in omap_i2c_xfer_msg()
759 __omap_i2c_init(omap); in omap_i2c_xfer_msg()
763 if (likely(!omap->cmd_err)) in omap_i2c_xfer_msg()
767 if (omap->cmd_err & (OMAP_I2C_STAT_ROVR | OMAP_I2C_STAT_XUDF)) { in omap_i2c_xfer_msg()
768 omap_i2c_reset(omap); in omap_i2c_xfer_msg()
769 __omap_i2c_init(omap); in omap_i2c_xfer_msg()
773 if (omap->cmd_err & OMAP_I2C_STAT_AL) in omap_i2c_xfer_msg()
776 if (omap->cmd_err & OMAP_I2C_STAT_NACK) { in omap_i2c_xfer_msg()
780 w = omap_i2c_read_reg(omap, OMAP_I2C_CON_REG); in omap_i2c_xfer_msg()
782 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, w); in omap_i2c_xfer_msg()
797 struct omap_i2c_dev *omap = i2c_get_adapdata(adap); in omap_i2c_xfer_common() local
801 r = pm_runtime_get_sync(omap->dev); in omap_i2c_xfer_common()
805 r = omap_i2c_wait_for_bb_valid(omap); in omap_i2c_xfer_common()
809 r = omap_i2c_wait_for_bb(omap); in omap_i2c_xfer_common()
813 if (omap->set_mpu_wkup_lat != NULL) in omap_i2c_xfer_common()
814 omap->set_mpu_wkup_lat(omap->dev, omap->latency); in omap_i2c_xfer_common()
826 omap_i2c_wait_for_bb(omap); in omap_i2c_xfer_common()
828 if (omap->set_mpu_wkup_lat != NULL) in omap_i2c_xfer_common()
829 omap->set_mpu_wkup_lat(omap->dev, -1); in omap_i2c_xfer_common()
832 pm_runtime_mark_last_busy(omap->dev); in omap_i2c_xfer_common()
833 pm_runtime_put_autosuspend(omap->dev); in omap_i2c_xfer_common()
857 omap_i2c_complete_cmd(struct omap_i2c_dev *omap, u16 err) in omap_i2c_complete_cmd() argument
859 omap->cmd_err |= err; in omap_i2c_complete_cmd()
860 complete(&omap->cmd_complete); in omap_i2c_complete_cmd()
864 omap_i2c_ack_stat(struct omap_i2c_dev *omap, u16 stat) in omap_i2c_ack_stat() argument
866 omap_i2c_write_reg(omap, OMAP_I2C_STAT_REG, stat); in omap_i2c_ack_stat()
869 static inline void i2c_omap_errata_i207(struct omap_i2c_dev *omap, u16 stat) in i2c_omap_errata_i207() argument
880 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RDR); in i2c_omap_errata_i207()
883 if (!(omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG) in i2c_omap_errata_i207()
887 if (omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG) in i2c_omap_errata_i207()
889 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RDR); in i2c_omap_errata_i207()
890 dev_dbg(omap->dev, "RDR when bus is busy.\n"); in i2c_omap_errata_i207()
903 struct omap_i2c_dev *omap = dev_id; in omap_i2c_omap1_isr() local
906 if (pm_runtime_suspended(omap->dev)) in omap_i2c_omap1_isr()
909 iv = omap_i2c_read_reg(omap, OMAP_I2C_IV_REG); in omap_i2c_omap1_isr()
914 dev_err(omap->dev, "Arbitration lost\n"); in omap_i2c_omap1_isr()
915 omap_i2c_complete_cmd(omap, OMAP_I2C_STAT_AL); in omap_i2c_omap1_isr()
918 omap_i2c_complete_cmd(omap, OMAP_I2C_STAT_NACK); in omap_i2c_omap1_isr()
919 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, OMAP_I2C_CON_STP); in omap_i2c_omap1_isr()
922 omap_i2c_complete_cmd(omap, 0); in omap_i2c_omap1_isr()
925 if (omap->buf_len) { in omap_i2c_omap1_isr()
926 w = omap_i2c_read_reg(omap, OMAP_I2C_DATA_REG); in omap_i2c_omap1_isr()
927 *omap->buf++ = w; in omap_i2c_omap1_isr()
928 omap->buf_len--; in omap_i2c_omap1_isr()
929 if (omap->buf_len) { in omap_i2c_omap1_isr()
930 *omap->buf++ = w >> 8; in omap_i2c_omap1_isr()
931 omap->buf_len--; in omap_i2c_omap1_isr()
934 dev_err(omap->dev, "RRDY IRQ while no data requested\n"); in omap_i2c_omap1_isr()
937 if (omap->buf_len) { in omap_i2c_omap1_isr()
938 w = *omap->buf++; in omap_i2c_omap1_isr()
939 omap->buf_len--; in omap_i2c_omap1_isr()
940 if (omap->buf_len) { in omap_i2c_omap1_isr()
941 w |= *omap->buf++ << 8; in omap_i2c_omap1_isr()
942 omap->buf_len--; in omap_i2c_omap1_isr()
944 omap_i2c_write_reg(omap, OMAP_I2C_DATA_REG, w); in omap_i2c_omap1_isr()
946 dev_err(omap->dev, "XRDY IRQ while no data to send\n"); in omap_i2c_omap1_isr()
963 static int errata_omap3_i462(struct omap_i2c_dev *omap) in errata_omap3_i462() argument
969 stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); in errata_omap3_i462()
974 omap_i2c_ack_stat(omap, (OMAP_I2C_STAT_XRDY | in errata_omap3_i462()
977 omap->cmd_err |= OMAP_I2C_STAT_NACK; in errata_omap3_i462()
978 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_NACK); in errata_omap3_i462()
982 dev_err(omap->dev, "Arbitration lost\n"); in errata_omap3_i462()
983 omap->cmd_err |= OMAP_I2C_STAT_AL; in errata_omap3_i462()
984 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_AL); in errata_omap3_i462()
994 dev_err(omap->dev, "timeout waiting on XUDF bit\n"); in errata_omap3_i462()
1001 static void omap_i2c_receive_data(struct omap_i2c_dev *omap, u8 num_bytes, in omap_i2c_receive_data() argument
1007 w = omap_i2c_read_reg(omap, OMAP_I2C_DATA_REG); in omap_i2c_receive_data()
1008 *omap->buf++ = w; in omap_i2c_receive_data()
1009 omap->buf_len--; in omap_i2c_receive_data()
1015 if (omap->flags & OMAP_I2C_FLAG_16BIT_DATA_REG) { in omap_i2c_receive_data()
1016 *omap->buf++ = w >> 8; in omap_i2c_receive_data()
1017 omap->buf_len--; in omap_i2c_receive_data()
1022 static int omap_i2c_transmit_data(struct omap_i2c_dev *omap, u8 num_bytes, in omap_i2c_transmit_data() argument
1028 w = *omap->buf++; in omap_i2c_transmit_data()
1029 omap->buf_len--; in omap_i2c_transmit_data()
1035 if (omap->flags & OMAP_I2C_FLAG_16BIT_DATA_REG) { in omap_i2c_transmit_data()
1036 w |= *omap->buf++ << 8; in omap_i2c_transmit_data()
1037 omap->buf_len--; in omap_i2c_transmit_data()
1040 if (omap->errata & I2C_OMAP_ERRATA_I462) { in omap_i2c_transmit_data()
1043 ret = errata_omap3_i462(omap); in omap_i2c_transmit_data()
1048 omap_i2c_write_reg(omap, OMAP_I2C_DATA_REG, w); in omap_i2c_transmit_data()
1054 static int omap_i2c_xfer_data(struct omap_i2c_dev *omap) in omap_i2c_xfer_data() argument
1061 bits = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG); in omap_i2c_xfer_data()
1062 stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); in omap_i2c_xfer_data()
1066 if (omap->receiver) in omap_i2c_xfer_data()
1077 dev_dbg(omap->dev, "IRQ (ISR = 0x%04x)\n", stat); in omap_i2c_xfer_data()
1079 dev_warn(omap->dev, "Too much work in one IRQ\n"); in omap_i2c_xfer_data()
1084 omap->cmd_err |= OMAP_I2C_STAT_NACK; in omap_i2c_xfer_data()
1085 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_NACK); in omap_i2c_xfer_data()
1094 dev_err(omap->dev, "Arbitration lost\n"); in omap_i2c_xfer_data()
1096 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_AL); in omap_i2c_xfer_data()
1103 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_ARDY); in omap_i2c_xfer_data()
1107 omap_i2c_ack_stat(omap, (OMAP_I2C_STAT_RRDY | in omap_i2c_xfer_data()
1118 if (omap->fifo_size) in omap_i2c_xfer_data()
1119 num_bytes = omap->buf_len; in omap_i2c_xfer_data()
1121 if (omap->errata & I2C_OMAP_ERRATA_I207) { in omap_i2c_xfer_data()
1122 i2c_omap_errata_i207(omap, stat); in omap_i2c_xfer_data()
1123 num_bytes = (omap_i2c_read_reg(omap, in omap_i2c_xfer_data()
1127 omap_i2c_receive_data(omap, num_bytes, true); in omap_i2c_xfer_data()
1128 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RDR); in omap_i2c_xfer_data()
1135 if (omap->threshold) in omap_i2c_xfer_data()
1136 num_bytes = omap->threshold; in omap_i2c_xfer_data()
1138 omap_i2c_receive_data(omap, num_bytes, false); in omap_i2c_xfer_data()
1139 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RRDY); in omap_i2c_xfer_data()
1147 if (omap->fifo_size) in omap_i2c_xfer_data()
1148 num_bytes = omap->buf_len; in omap_i2c_xfer_data()
1150 ret = omap_i2c_transmit_data(omap, num_bytes, true); in omap_i2c_xfer_data()
1154 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_XDR); in omap_i2c_xfer_data()
1162 if (omap->threshold) in omap_i2c_xfer_data()
1163 num_bytes = omap->threshold; in omap_i2c_xfer_data()
1165 ret = omap_i2c_transmit_data(omap, num_bytes, false); in omap_i2c_xfer_data()
1169 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_XRDY); in omap_i2c_xfer_data()
1174 dev_err(omap->dev, "Receive overrun\n"); in omap_i2c_xfer_data()
1176 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_ROVR); in omap_i2c_xfer_data()
1181 dev_err(omap->dev, "Transmit underflow\n"); in omap_i2c_xfer_data()
1183 omap_i2c_ack_stat(omap, OMAP_I2C_STAT_XUDF); in omap_i2c_xfer_data()
1195 struct omap_i2c_dev *omap = dev_id; in omap_i2c_isr_thread() local
1197 ret = omap_i2c_xfer_data(omap); in omap_i2c_isr_thread()
1199 omap_i2c_complete_cmd(omap, ret); in omap_i2c_isr_thread()
1346 struct omap_i2c_dev *omap; in omap_i2c_probe() local
1361 omap = devm_kzalloc(&pdev->dev, sizeof(struct omap_i2c_dev), GFP_KERNEL); in omap_i2c_probe()
1362 if (!omap) in omap_i2c_probe()
1365 omap->base = devm_platform_ioremap_resource(pdev, 0); in omap_i2c_probe()
1366 if (IS_ERR(omap->base)) in omap_i2c_probe()
1367 return PTR_ERR(omap->base); in omap_i2c_probe()
1374 omap->flags = pdata->flags; in omap_i2c_probe()
1378 omap->speed = freq / 1000; in omap_i2c_probe()
1380 omap->speed = pdata->clkrate; in omap_i2c_probe()
1381 omap->flags = pdata->flags; in omap_i2c_probe()
1382 omap->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; in omap_i2c_probe()
1385 omap->dev = &pdev->dev; in omap_i2c_probe()
1386 omap->irq = irq; in omap_i2c_probe()
1388 platform_set_drvdata(pdev, omap); in omap_i2c_probe()
1389 init_completion(&omap->cmd_complete); in omap_i2c_probe()
1391 omap->reg_shift = (omap->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3; in omap_i2c_probe()
1393 pm_runtime_enable(omap->dev); in omap_i2c_probe()
1394 pm_runtime_set_autosuspend_delay(omap->dev, OMAP_I2C_PM_TIMEOUT); in omap_i2c_probe()
1395 pm_runtime_use_autosuspend(omap->dev); in omap_i2c_probe()
1397 r = pm_runtime_resume_and_get(omap->dev); in omap_i2c_probe()
1407 rev = readw_relaxed(omap->base + 0x04); in omap_i2c_probe()
1409 omap->scheme = OMAP_I2C_SCHEME(rev); in omap_i2c_probe()
1410 switch (omap->scheme) { in omap_i2c_probe()
1412 omap->regs = (u8 *)reg_map_ip_v1; in omap_i2c_probe()
1413 omap->rev = omap_i2c_read_reg(omap, OMAP_I2C_REV_REG); in omap_i2c_probe()
1414 minor = OMAP_I2C_REV_SCHEME_0_MAJOR(omap->rev); in omap_i2c_probe()
1415 major = OMAP_I2C_REV_SCHEME_0_MAJOR(omap->rev); in omap_i2c_probe()
1419 omap->regs = (u8 *)reg_map_ip_v2; in omap_i2c_probe()
1421 omap_i2c_read_reg(omap, OMAP_I2C_IP_V2_REVNB_LO); in omap_i2c_probe()
1424 omap->rev = rev; in omap_i2c_probe()
1427 omap->errata = 0; in omap_i2c_probe()
1429 if (omap->rev >= OMAP_I2C_REV_ON_2430 && in omap_i2c_probe()
1430 omap->rev < OMAP_I2C_REV_ON_4430_PLUS) in omap_i2c_probe()
1431 omap->errata |= I2C_OMAP_ERRATA_I207; in omap_i2c_probe()
1433 if (omap->rev <= OMAP_I2C_REV_ON_3430_3530) in omap_i2c_probe()
1434 omap->errata |= I2C_OMAP_ERRATA_I462; in omap_i2c_probe()
1436 if (!(omap->flags & OMAP_I2C_FLAG_NO_FIFO)) { in omap_i2c_probe()
1440 s = (omap_i2c_read_reg(omap, OMAP_I2C_BUFSTAT_REG) >> 14) & 0x3; in omap_i2c_probe()
1441 omap->fifo_size = 0x8 << s; in omap_i2c_probe()
1449 omap->fifo_size = (omap->fifo_size / 2); in omap_i2c_probe()
1451 if (omap->rev < OMAP_I2C_REV_ON_3630) in omap_i2c_probe()
1452 omap->b_hw = 1; /* Enable hardware fixes */ in omap_i2c_probe()
1455 if (omap->set_mpu_wkup_lat != NULL) in omap_i2c_probe()
1456 omap->latency = (1000000 * omap->fifo_size) / in omap_i2c_probe()
1457 (1000 * omap->speed / 8); in omap_i2c_probe()
1469 omap->mux_state = mux_state; in omap_i2c_probe()
1470 r = mux_state_select(omap->mux_state); in omap_i2c_probe()
1478 r = omap_i2c_init(omap); in omap_i2c_probe()
1482 if (omap->rev < OMAP_I2C_OMAP1_REV_2) in omap_i2c_probe()
1483 r = devm_request_irq(&pdev->dev, omap->irq, omap_i2c_omap1_isr, in omap_i2c_probe()
1484 IRQF_NO_SUSPEND, pdev->name, omap); in omap_i2c_probe()
1486 r = devm_request_threaded_irq(&pdev->dev, omap->irq, in omap_i2c_probe()
1489 pdev->name, omap); in omap_i2c_probe()
1492 dev_err(omap->dev, "failure requesting irq %i\n", omap->irq); in omap_i2c_probe()
1496 adap = &omap->adapter; in omap_i2c_probe()
1497 i2c_set_adapdata(adap, omap); in omap_i2c_probe()
1500 strscpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); in omap_i2c_probe()
1513 dev_info(omap->dev, "bus %d rev%d.%d at %d kHz\n", adap->nr, in omap_i2c_probe()
1514 major, minor, omap->speed); in omap_i2c_probe()
1516 pm_runtime_mark_last_busy(omap->dev); in omap_i2c_probe()
1517 pm_runtime_put_autosuspend(omap->dev); in omap_i2c_probe()
1522 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); in omap_i2c_probe()
1524 if (omap->mux_state) in omap_i2c_probe()
1525 mux_state_deselect(omap->mux_state); in omap_i2c_probe()
1527 pm_runtime_dont_use_autosuspend(omap->dev); in omap_i2c_probe()
1528 pm_runtime_put_sync(omap->dev); in omap_i2c_probe()
1537 struct omap_i2c_dev *omap = platform_get_drvdata(pdev); in omap_i2c_remove() local
1540 i2c_del_adapter(&omap->adapter); in omap_i2c_remove()
1542 if (omap->mux_state) in omap_i2c_remove()
1543 mux_state_deselect(omap->mux_state); in omap_i2c_remove()
1547 dev_err(omap->dev, "Failed to resume hardware, skip disable\n"); in omap_i2c_remove()
1549 omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); in omap_i2c_remove()
1558 struct omap_i2c_dev *omap = dev_get_drvdata(dev); in omap_i2c_runtime_suspend() local
1560 omap->iestate = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG); in omap_i2c_runtime_suspend()
1562 if (omap->scheme == OMAP_I2C_SCHEME_0) in omap_i2c_runtime_suspend()
1563 omap_i2c_write_reg(omap, OMAP_I2C_IE_REG, 0); in omap_i2c_runtime_suspend()
1565 omap_i2c_write_reg(omap, OMAP_I2C_IP_V2_IRQENABLE_CLR, in omap_i2c_runtime_suspend()
1568 if (omap->rev < OMAP_I2C_OMAP1_REV_2) { in omap_i2c_runtime_suspend()
1569 omap_i2c_read_reg(omap, OMAP_I2C_IV_REG); /* Read clears */ in omap_i2c_runtime_suspend()
1571 omap_i2c_write_reg(omap, OMAP_I2C_STAT_REG, omap->iestate); in omap_i2c_runtime_suspend()
1574 omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); in omap_i2c_runtime_suspend()
1584 struct omap_i2c_dev *omap = dev_get_drvdata(dev); in omap_i2c_runtime_resume() local
1588 if (!omap->regs) in omap_i2c_runtime_resume()
1591 __omap_i2c_init(omap); in omap_i2c_runtime_resume()
1628 MODULE_DESCRIPTION("TI OMAP I2C bus adapter");