Lines Matching refs:i2c
139 static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat);
173 static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret) in s3c24xx_i2c_master_complete() argument
175 dev_dbg(i2c->dev, "master_complete %d\n", ret); in s3c24xx_i2c_master_complete()
177 i2c->msg_ptr = 0; in s3c24xx_i2c_master_complete()
178 i2c->msg = NULL; in s3c24xx_i2c_master_complete()
179 i2c->msg_idx++; in s3c24xx_i2c_master_complete()
180 i2c->msg_num = 0; in s3c24xx_i2c_master_complete()
182 i2c->msg_idx = ret; in s3c24xx_i2c_master_complete()
184 if (!(i2c->quirks & QUIRK_POLL)) in s3c24xx_i2c_master_complete()
185 wake_up(&i2c->wait); in s3c24xx_i2c_master_complete()
188 static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_disable_ack() argument
192 tmp = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_disable_ack()
193 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_disable_ack()
196 static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_enable_ack() argument
200 tmp = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_enable_ack()
201 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_enable_ack()
205 static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_disable_irq() argument
209 tmp = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_disable_irq()
210 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_disable_irq()
213 static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_enable_irq() argument
217 tmp = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_enable_irq()
218 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_enable_irq()
221 static bool is_ack(struct s3c24xx_i2c *i2c) in is_ack() argument
226 if (readl(i2c->regs + S3C2410_IICCON) in is_ack()
228 if (!(readl(i2c->regs + S3C2410_IICSTAT) in is_ack()
234 dev_err(i2c->dev, "ack was not received\n"); in is_ack()
241 static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, in s3c24xx_i2c_message_start() argument
261 s3c24xx_i2c_enable_ack(i2c); in s3c24xx_i2c_message_start()
263 iiccon = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_message_start()
264 writel(stat, i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_message_start()
266 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); in s3c24xx_i2c_message_start()
267 writeb(addr, i2c->regs + S3C2410_IICDS); in s3c24xx_i2c_message_start()
273 ndelay(i2c->tx_setup); in s3c24xx_i2c_message_start()
275 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); in s3c24xx_i2c_message_start()
276 writel(iiccon, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_message_start()
279 writel(stat, i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_message_start()
281 if (i2c->quirks & QUIRK_POLL) { in s3c24xx_i2c_message_start()
282 while ((i2c->msg_num != 0) && is_ack(i2c)) { in s3c24xx_i2c_message_start()
283 i2c_s3c_irq_nextbyte(i2c, stat); in s3c24xx_i2c_message_start()
284 stat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_message_start()
287 dev_err(i2c->dev, "deal with arbitration loss\n"); in s3c24xx_i2c_message_start()
292 static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret) in s3c24xx_i2c_stop() argument
294 unsigned long iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_stop()
296 dev_dbg(i2c->dev, "STOP\n"); in s3c24xx_i2c_stop()
332 if (i2c->quirks & QUIRK_HDMIPHY) { in s3c24xx_i2c_stop()
339 writel(iicstat, i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_stop()
341 i2c->state = STATE_STOP; in s3c24xx_i2c_stop()
343 s3c24xx_i2c_master_complete(i2c, ret); in s3c24xx_i2c_stop()
344 s3c24xx_i2c_disable_irq(i2c); in s3c24xx_i2c_stop()
355 static inline int is_lastmsg(struct s3c24xx_i2c *i2c) in is_lastmsg() argument
357 return i2c->msg_idx >= (i2c->msg_num - 1); in is_lastmsg()
363 static inline int is_msglast(struct s3c24xx_i2c *i2c) in is_msglast() argument
370 if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) in is_msglast()
373 return i2c->msg_ptr == i2c->msg->len-1; in is_msglast()
379 static inline int is_msgend(struct s3c24xx_i2c *i2c) in is_msgend() argument
381 return i2c->msg_ptr >= i2c->msg->len; in is_msgend()
387 static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) in i2c_s3c_irq_nextbyte() argument
393 switch (i2c->state) { in i2c_s3c_irq_nextbyte()
396 dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__); in i2c_s3c_irq_nextbyte()
400 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__); in i2c_s3c_irq_nextbyte()
401 s3c24xx_i2c_disable_irq(i2c); in i2c_s3c_irq_nextbyte()
410 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { in i2c_s3c_irq_nextbyte()
412 dev_dbg(i2c->dev, "ack was not received\n"); in i2c_s3c_irq_nextbyte()
413 s3c24xx_i2c_stop(i2c, -ENXIO); in i2c_s3c_irq_nextbyte()
417 if (i2c->msg->flags & I2C_M_RD) in i2c_s3c_irq_nextbyte()
418 i2c->state = STATE_READ; in i2c_s3c_irq_nextbyte()
420 i2c->state = STATE_WRITE; in i2c_s3c_irq_nextbyte()
426 if (is_lastmsg(i2c) && i2c->msg->len == 0) { in i2c_s3c_irq_nextbyte()
427 s3c24xx_i2c_stop(i2c, 0); in i2c_s3c_irq_nextbyte()
431 if (i2c->state == STATE_READ) in i2c_s3c_irq_nextbyte()
444 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) { in i2c_s3c_irq_nextbyte()
446 dev_dbg(i2c->dev, "WRITE: No Ack\n"); in i2c_s3c_irq_nextbyte()
448 s3c24xx_i2c_stop(i2c, -ECONNREFUSED); in i2c_s3c_irq_nextbyte()
455 if (!is_msgend(i2c)) { in i2c_s3c_irq_nextbyte()
456 byte = i2c->msg->buf[i2c->msg_ptr++]; in i2c_s3c_irq_nextbyte()
457 writeb(byte, i2c->regs + S3C2410_IICDS); in i2c_s3c_irq_nextbyte()
466 ndelay(i2c->tx_setup); in i2c_s3c_irq_nextbyte()
468 } else if (!is_lastmsg(i2c)) { in i2c_s3c_irq_nextbyte()
471 dev_dbg(i2c->dev, "WRITE: Next Message\n"); in i2c_s3c_irq_nextbyte()
473 i2c->msg_ptr = 0; in i2c_s3c_irq_nextbyte()
474 i2c->msg_idx++; in i2c_s3c_irq_nextbyte()
475 i2c->msg++; in i2c_s3c_irq_nextbyte()
478 if (i2c->msg->flags & I2C_M_NOSTART) { in i2c_s3c_irq_nextbyte()
480 if (i2c->msg->flags & I2C_M_RD) { in i2c_s3c_irq_nextbyte()
486 dev_dbg(i2c->dev, in i2c_s3c_irq_nextbyte()
488 s3c24xx_i2c_stop(i2c, -EINVAL); in i2c_s3c_irq_nextbyte()
495 s3c24xx_i2c_message_start(i2c, i2c->msg); in i2c_s3c_irq_nextbyte()
496 i2c->state = STATE_START; in i2c_s3c_irq_nextbyte()
501 s3c24xx_i2c_stop(i2c, 0); in i2c_s3c_irq_nextbyte()
511 byte = readb(i2c->regs + S3C2410_IICDS); in i2c_s3c_irq_nextbyte()
512 i2c->msg->buf[i2c->msg_ptr++] = byte; in i2c_s3c_irq_nextbyte()
515 if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) in i2c_s3c_irq_nextbyte()
516 i2c->msg->len += byte; in i2c_s3c_irq_nextbyte()
518 if (is_msglast(i2c)) { in i2c_s3c_irq_nextbyte()
521 if (is_lastmsg(i2c)) in i2c_s3c_irq_nextbyte()
522 s3c24xx_i2c_disable_ack(i2c); in i2c_s3c_irq_nextbyte()
524 } else if (is_msgend(i2c)) { in i2c_s3c_irq_nextbyte()
529 if (is_lastmsg(i2c)) { in i2c_s3c_irq_nextbyte()
531 dev_dbg(i2c->dev, "READ: Send Stop\n"); in i2c_s3c_irq_nextbyte()
533 s3c24xx_i2c_stop(i2c, 0); in i2c_s3c_irq_nextbyte()
536 dev_dbg(i2c->dev, "READ: Next Transfer\n"); in i2c_s3c_irq_nextbyte()
538 i2c->msg_ptr = 0; in i2c_s3c_irq_nextbyte()
539 i2c->msg_idx++; in i2c_s3c_irq_nextbyte()
540 i2c->msg++; in i2c_s3c_irq_nextbyte()
550 tmp = readl(i2c->regs + S3C2410_IICCON); in i2c_s3c_irq_nextbyte()
552 writel(tmp, i2c->regs + S3C2410_IICCON); in i2c_s3c_irq_nextbyte()
562 struct s3c24xx_i2c *i2c = dev_id; in s3c24xx_i2c_irq() local
566 status = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_irq()
570 dev_err(i2c->dev, "deal with arbitration loss\n"); in s3c24xx_i2c_irq()
573 if (i2c->state == STATE_IDLE) { in s3c24xx_i2c_irq()
574 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n"); in s3c24xx_i2c_irq()
576 tmp = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_irq()
578 writel(tmp, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_irq()
586 i2c_s3c_irq_nextbyte(i2c, status); in s3c24xx_i2c_irq()
601 static inline void s3c24xx_i2c_disable_bus(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_disable_bus() argument
606 tmp = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_disable_bus()
608 writel(tmp, i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_disable_bus()
611 tmp = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_disable_bus()
614 writel(tmp, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_disable_bus()
621 static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_set_master() argument
627 iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_set_master()
641 static void s3c24xx_i2c_wait_idle(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_wait_idle() argument
650 dev_dbg(i2c->dev, "waiting for bus idle\n"); in s3c24xx_i2c_wait_idle()
663 iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_wait_idle()
666 iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_wait_idle()
683 iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_wait_idle()
687 dev_warn(i2c->dev, "timeout waiting for bus idle\n"); in s3c24xx_i2c_wait_idle()
693 static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, in s3c24xx_i2c_doxfer() argument
699 ret = s3c24xx_i2c_set_master(i2c); in s3c24xx_i2c_doxfer()
701 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); in s3c24xx_i2c_doxfer()
706 i2c->msg = msgs; in s3c24xx_i2c_doxfer()
707 i2c->msg_num = num; in s3c24xx_i2c_doxfer()
708 i2c->msg_ptr = 0; in s3c24xx_i2c_doxfer()
709 i2c->msg_idx = 0; in s3c24xx_i2c_doxfer()
710 i2c->state = STATE_START; in s3c24xx_i2c_doxfer()
712 s3c24xx_i2c_enable_irq(i2c); in s3c24xx_i2c_doxfer()
713 s3c24xx_i2c_message_start(i2c, msgs); in s3c24xx_i2c_doxfer()
715 if (i2c->quirks & QUIRK_POLL) { in s3c24xx_i2c_doxfer()
716 ret = i2c->msg_idx; in s3c24xx_i2c_doxfer()
719 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); in s3c24xx_i2c_doxfer()
724 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); in s3c24xx_i2c_doxfer()
726 ret = i2c->msg_idx; in s3c24xx_i2c_doxfer()
733 dev_dbg(i2c->dev, "timeout\n"); in s3c24xx_i2c_doxfer()
735 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); in s3c24xx_i2c_doxfer()
738 if (i2c->quirks & QUIRK_HDMIPHY) in s3c24xx_i2c_doxfer()
741 s3c24xx_i2c_wait_idle(i2c); in s3c24xx_i2c_doxfer()
743 s3c24xx_i2c_disable_bus(i2c); in s3c24xx_i2c_doxfer()
746 i2c->state = STATE_IDLE; in s3c24xx_i2c_doxfer()
758 struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data; in s3c24xx_i2c_xfer() local
762 ret = clk_enable(i2c->clk); in s3c24xx_i2c_xfer()
768 ret = s3c24xx_i2c_doxfer(i2c, msgs, num); in s3c24xx_i2c_xfer()
771 clk_disable(i2c->clk); in s3c24xx_i2c_xfer()
775 dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry); in s3c24xx_i2c_xfer()
780 clk_disable(i2c->clk); in s3c24xx_i2c_xfer()
830 static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) in s3c24xx_i2c_clockrate() argument
832 struct s3c2410_platform_i2c *pdata = i2c->pdata; in s3c24xx_i2c_clockrate()
833 unsigned long clkin = clk_get_rate(i2c->clk); in s3c24xx_i2c_clockrate()
839 i2c->clkrate = clkin; in s3c24xx_i2c_clockrate()
842 dev_dbg(i2c->dev, "pdata desired frequency %lu\n", pdata->frequency); in s3c24xx_i2c_clockrate()
851 dev_err(i2c->dev, in s3c24xx_i2c_clockrate()
859 iiccon = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_clockrate()
866 if (i2c->quirks & QUIRK_POLL) in s3c24xx_i2c_clockrate()
869 writel(iiccon, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_clockrate()
871 if (i2c->quirks & QUIRK_S3C2440) { in s3c24xx_i2c_clockrate()
884 dev_dbg(i2c->dev, "IICLC=%08lx\n", sda_delay); in s3c24xx_i2c_clockrate()
885 writel(sda_delay, i2c->regs + S3C2440_IICLC); in s3c24xx_i2c_clockrate()
898 struct s3c24xx_i2c *i2c = freq_to_i2c(nb); in s3c24xx_i2c_cpufreq_transition() local
903 delta_f = clk_get_rate(i2c->clk) - i2c->clkrate; in s3c24xx_i2c_cpufreq_transition()
912 i2c_lock_bus(&i2c->adap, I2C_LOCK_ROOT_ADAPTER); in s3c24xx_i2c_cpufreq_transition()
913 ret = s3c24xx_i2c_clockrate(i2c, &got); in s3c24xx_i2c_cpufreq_transition()
914 i2c_unlock_bus(&i2c->adap, I2C_LOCK_ROOT_ADAPTER); in s3c24xx_i2c_cpufreq_transition()
917 dev_err(i2c->dev, "cannot find frequency (%d)\n", ret); in s3c24xx_i2c_cpufreq_transition()
919 dev_info(i2c->dev, "setting freq %d\n", got); in s3c24xx_i2c_cpufreq_transition()
925 static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_register_cpufreq() argument
927 i2c->freq_transition.notifier_call = s3c24xx_i2c_cpufreq_transition; in s3c24xx_i2c_register_cpufreq()
929 return cpufreq_register_notifier(&i2c->freq_transition, in s3c24xx_i2c_register_cpufreq()
933 static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_deregister_cpufreq() argument
935 cpufreq_unregister_notifier(&i2c->freq_transition, in s3c24xx_i2c_deregister_cpufreq()
940 static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_register_cpufreq() argument
945 static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_deregister_cpufreq() argument
951 static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_parse_dt_gpio() argument
955 if (i2c->quirks & QUIRK_NO_GPIO) in s3c24xx_i2c_parse_dt_gpio()
959 i2c->gpios[i] = devm_gpiod_get_index(i2c->dev, NULL, in s3c24xx_i2c_parse_dt_gpio()
961 if (IS_ERR(i2c->gpios[i])) { in s3c24xx_i2c_parse_dt_gpio()
962 dev_err(i2c->dev, "i2c gpio invalid at index %d\n", i); in s3c24xx_i2c_parse_dt_gpio()
970 static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_parse_dt_gpio() argument
979 static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) in s3c24xx_i2c_init() argument
986 pdata = i2c->pdata; in s3c24xx_i2c_init()
990 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD); in s3c24xx_i2c_init()
992 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); in s3c24xx_i2c_init()
994 writel(0, i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_init()
995 writel(0, i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_init()
999 if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) { in s3c24xx_i2c_init()
1000 dev_err(i2c->dev, "cannot meet bus frequency required\n"); in s3c24xx_i2c_init()
1006 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq); in s3c24xx_i2c_init()
1007 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02x\n", in s3c24xx_i2c_init()
1008 readl(i2c->regs + S3C2410_IICCON)); in s3c24xx_i2c_init()
1018 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) in s3c24xx_i2c_parse_dt() argument
1020 struct s3c2410_platform_i2c *pdata = i2c->pdata; in s3c24xx_i2c_parse_dt()
1040 i2c->sysreg = syscon_regmap_lookup_by_phandle(np, in s3c24xx_i2c_parse_dt()
1042 if (IS_ERR(i2c->sysreg)) in s3c24xx_i2c_parse_dt()
1045 regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), 0); in s3c24xx_i2c_parse_dt()
1049 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) { } in s3c24xx_i2c_parse_dt() argument
1054 struct s3c24xx_i2c *i2c; in s3c24xx_i2c_probe() local
1067 i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL); in s3c24xx_i2c_probe()
1068 if (!i2c) in s3c24xx_i2c_probe()
1071 i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in s3c24xx_i2c_probe()
1072 if (!i2c->pdata) in s3c24xx_i2c_probe()
1075 i2c->quirks = s3c24xx_get_device_quirks(pdev); in s3c24xx_i2c_probe()
1076 i2c->sysreg = ERR_PTR(-ENOENT); in s3c24xx_i2c_probe()
1078 memcpy(i2c->pdata, pdata, sizeof(*pdata)); in s3c24xx_i2c_probe()
1080 s3c24xx_i2c_parse_dt(pdev->dev.of_node, i2c); in s3c24xx_i2c_probe()
1082 strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name)); in s3c24xx_i2c_probe()
1083 i2c->adap.owner = THIS_MODULE; in s3c24xx_i2c_probe()
1084 i2c->adap.algo = &s3c24xx_i2c_algorithm; in s3c24xx_i2c_probe()
1085 i2c->adap.retries = 2; in s3c24xx_i2c_probe()
1086 i2c->adap.class = I2C_CLASS_DEPRECATED; in s3c24xx_i2c_probe()
1087 i2c->tx_setup = 50; in s3c24xx_i2c_probe()
1089 init_waitqueue_head(&i2c->wait); in s3c24xx_i2c_probe()
1092 i2c->dev = &pdev->dev; in s3c24xx_i2c_probe()
1093 i2c->clk = devm_clk_get(&pdev->dev, "i2c"); in s3c24xx_i2c_probe()
1094 if (IS_ERR(i2c->clk)) { in s3c24xx_i2c_probe()
1099 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); in s3c24xx_i2c_probe()
1103 i2c->regs = devm_ioremap_resource(&pdev->dev, res); in s3c24xx_i2c_probe()
1105 if (IS_ERR(i2c->regs)) in s3c24xx_i2c_probe()
1106 return PTR_ERR(i2c->regs); in s3c24xx_i2c_probe()
1109 i2c->regs, res); in s3c24xx_i2c_probe()
1112 i2c->adap.algo_data = i2c; in s3c24xx_i2c_probe()
1113 i2c->adap.dev.parent = &pdev->dev; in s3c24xx_i2c_probe()
1114 i2c->pctrl = devm_pinctrl_get_select_default(i2c->dev); in s3c24xx_i2c_probe()
1117 if (i2c->pdata->cfg_gpio) in s3c24xx_i2c_probe()
1118 i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); in s3c24xx_i2c_probe()
1119 else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) in s3c24xx_i2c_probe()
1123 ret = clk_prepare_enable(i2c->clk); in s3c24xx_i2c_probe()
1129 ret = s3c24xx_i2c_init(i2c); in s3c24xx_i2c_probe()
1130 clk_disable(i2c->clk); in s3c24xx_i2c_probe()
1133 clk_unprepare(i2c->clk); in s3c24xx_i2c_probe()
1141 if (!(i2c->quirks & QUIRK_POLL)) { in s3c24xx_i2c_probe()
1142 i2c->irq = ret = platform_get_irq(pdev, 0); in s3c24xx_i2c_probe()
1145 clk_unprepare(i2c->clk); in s3c24xx_i2c_probe()
1149 ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, in s3c24xx_i2c_probe()
1150 0, dev_name(&pdev->dev), i2c); in s3c24xx_i2c_probe()
1152 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); in s3c24xx_i2c_probe()
1153 clk_unprepare(i2c->clk); in s3c24xx_i2c_probe()
1158 ret = s3c24xx_i2c_register_cpufreq(i2c); in s3c24xx_i2c_probe()
1161 clk_unprepare(i2c->clk); in s3c24xx_i2c_probe()
1171 i2c->adap.nr = i2c->pdata->bus_num; in s3c24xx_i2c_probe()
1172 i2c->adap.dev.of_node = pdev->dev.of_node; in s3c24xx_i2c_probe()
1174 platform_set_drvdata(pdev, i2c); in s3c24xx_i2c_probe()
1178 ret = i2c_add_numbered_adapter(&i2c->adap); in s3c24xx_i2c_probe()
1181 s3c24xx_i2c_deregister_cpufreq(i2c); in s3c24xx_i2c_probe()
1182 clk_unprepare(i2c->clk); in s3c24xx_i2c_probe()
1186 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); in s3c24xx_i2c_probe()
1192 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); in s3c24xx_i2c_remove() local
1194 clk_unprepare(i2c->clk); in s3c24xx_i2c_remove()
1198 s3c24xx_i2c_deregister_cpufreq(i2c); in s3c24xx_i2c_remove()
1200 i2c_del_adapter(&i2c->adap); in s3c24xx_i2c_remove()
1208 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); in s3c24xx_i2c_suspend_noirq() local
1210 i2c_mark_adapter_suspended(&i2c->adap); in s3c24xx_i2c_suspend_noirq()
1212 if (!IS_ERR(i2c->sysreg)) in s3c24xx_i2c_suspend_noirq()
1213 regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &i2c->sys_i2c_cfg); in s3c24xx_i2c_suspend_noirq()
1220 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); in s3c24xx_i2c_resume_noirq() local
1223 if (!IS_ERR(i2c->sysreg)) in s3c24xx_i2c_resume_noirq()
1224 regmap_write(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, i2c->sys_i2c_cfg); in s3c24xx_i2c_resume_noirq()
1226 ret = clk_enable(i2c->clk); in s3c24xx_i2c_resume_noirq()
1229 s3c24xx_i2c_init(i2c); in s3c24xx_i2c_resume_noirq()
1230 clk_disable(i2c->clk); in s3c24xx_i2c_resume_noirq()
1231 i2c_mark_adapter_resumed(&i2c->adap); in s3c24xx_i2c_resume_noirq()