Lines Matching +full:pctrl +full:- +full:syscon
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* linux/drivers/i2c/busses/i2c-s3c2410.c
29 #include <linux/mfd/syscon.h>
34 #include <linux/platform_data/i2c-s3c2410.h>
117 struct pinctrl *pctrl; member
127 .name = "s3c2410-i2c",
130 .name = "s3c2440-i2c",
133 .name = "s3c2440-hdmiphy-i2c",
143 { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 },
144 { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 },
145 { .compatible = "samsung,s3c2440-hdmiphy-i2c",
147 { .compatible = "samsung,exynos5-sata-phy-i2c",
159 if (pdev->dev.of_node) { in s3c24xx_get_device_quirks()
162 match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); in s3c24xx_get_device_quirks()
163 return (kernel_ulong_t)match->data; in s3c24xx_get_device_quirks()
166 return platform_get_device_id(pdev)->driver_data; in s3c24xx_get_device_quirks()
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()
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()
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()
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()
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()
225 for (tries = 50; tries; --tries) { in is_ack()
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()
244 unsigned int addr = (msg->addr & 0x7f) << 1; in s3c24xx_i2c_message_start()
251 if (msg->flags & I2C_M_RD) { in s3c24xx_i2c_message_start()
257 if (msg->flags & I2C_M_REV_DIR_ADDR) in s3c24xx_i2c_message_start()
260 /* todo - check for whether ack wanted or not */ 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()
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()
294 unsigned long iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_stop()
296 dev_dbg(i2c->dev, "STOP\n"); in s3c24xx_i2c_stop()
300 * 1) I2CSTAT.5 = 0 - Clear BUSY (or 'generate STOP') in s3c24xx_i2c_stop()
301 * 2) I2CCON.4 = 0 - Clear IRQPEND in s3c24xx_i2c_stop()
303 * 4*) I2CSTAT.4 = 0 - Clear TXRXEN in s3c24xx_i2c_stop()
309 * Master->Slave when they complete generating a STOP condition. in s3c24xx_i2c_stop()
322 * To avoid these extra post-STOP transactions on HDMI phy devices, we 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()
357 return i2c->msg_idx >= (i2c->msg_num - 1); in is_lastmsg()
366 * msg->len is always 1 for the first byte of smbus block read. in is_msglast()
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()
381 return i2c->msg_ptr >= i2c->msg->len; in is_msgend()
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()
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()
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()
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()
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()
487 "missing START before write->read\n"); 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()
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()
531 dev_dbg(i2c->dev, "READ: Send Stop\n"); 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()
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()
597 * If there is an event on the bus, or we have a pre-existing event at
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()
626 while (timeout-- > 0) { in s3c24xx_i2c_set_master()
627 iicstat = readl(i2c->regs + S3C2410_IICSTAT); in s3c24xx_i2c_set_master()
635 return -ETIMEDOUT; in s3c24xx_i2c_set_master()
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()
664 while ((iicstat & S3C2410_IICSTAT_START) && --spins) { 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()
701 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); in s3c24xx_i2c_doxfer()
702 ret = -EAGAIN; 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()
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()
746 i2c->state = STATE_IDLE; in s3c24xx_i2c_doxfer()
758 struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data; in s3c24xx_i2c_xfer()
762 ret = clk_enable(i2c->clk); in s3c24xx_i2c_xfer()
766 for (retry = 0; retry < adap->retries; retry++) { in s3c24xx_i2c_xfer()
770 if (ret != -EAGAIN) { 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()
781 return -EREMOTEIO; in s3c24xx_i2c_xfer()
811 calc_divs += calc_div1-1; in s3c24xx_i2c_calcdivisor()
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()
844 target_frequency = pdata->frequency ?: I2C_MAX_STANDARD_MODE_FREQ; in s3c24xx_i2c_clockrate()
851 dev_err(i2c->dev, in s3c24xx_i2c_clockrate()
854 return -EINVAL; in s3c24xx_i2c_clockrate()
859 iiccon = readl(i2c->regs + S3C2410_IICCON); in s3c24xx_i2c_clockrate()
861 iiccon |= (divs-1); 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()
874 if (pdata->sda_delay) { in s3c24xx_i2c_clockrate()
875 sda_delay = clkin * pdata->sda_delay; 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()
903 delta_f = clk_get_rate(i2c->clk) - i2c->clkrate; in s3c24xx_i2c_cpufreq_transition()
905 /* if we're post-change and the input clock has slowed down in s3c24xx_i2c_cpufreq_transition()
906 * or at pre-change and the clock is about to speed up, then in s3c24xx_i2c_cpufreq_transition()
912 i2c_lock_bus(&i2c->adap, I2C_LOCK_ROOT_ADAPTER); 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()
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()
935 cpufreq_unregister_notifier(&i2c->freq_transition, in s3c24xx_i2c_deregister_cpufreq()
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()
963 return -EINVAL; in s3c24xx_i2c_parse_dt_gpio()
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()
1000 dev_err(i2c->dev, "cannot meet bus frequency required\n"); in s3c24xx_i2c_init()
1001 return -EINVAL; in s3c24xx_i2c_init()
1004 /* todo - check that the i2c lines aren't being dragged anywhere */ 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()
1020 struct s3c2410_platform_i2c *pdata = i2c->pdata; in s3c24xx_i2c_parse_dt()
1026 pdata->bus_num = -1; /* i2c bus number is dynamically assigned */ in s3c24xx_i2c_parse_dt()
1027 of_property_read_u32(np, "samsung,i2c-sda-delay", &pdata->sda_delay); in s3c24xx_i2c_parse_dt()
1028 of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr); in s3c24xx_i2c_parse_dt()
1029 of_property_read_u32(np, "samsung,i2c-max-bus-freq", in s3c24xx_i2c_parse_dt()
1030 (u32 *)&pdata->frequency); in s3c24xx_i2c_parse_dt()
1034 * interrupts for 4-channel HS-I2C controller are enabled. in s3c24xx_i2c_parse_dt()
1036 * are available then re-configure the interrupts via the in s3c24xx_i2c_parse_dt()
1040 i2c->sysreg = syscon_regmap_lookup_by_phandle(np, in s3c24xx_i2c_parse_dt()
1041 "samsung,sysreg-phandle"); 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()
1059 if (!pdev->dev.of_node) { in s3c24xx_i2c_probe()
1060 pdata = dev_get_platdata(&pdev->dev); in s3c24xx_i2c_probe()
1062 dev_err(&pdev->dev, "no platform data\n"); in s3c24xx_i2c_probe()
1063 return -EINVAL; in s3c24xx_i2c_probe()
1067 i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL); in s3c24xx_i2c_probe()
1069 return -ENOMEM; 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()
1073 return -ENOMEM; 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()
1095 dev_err(&pdev->dev, "cannot get clock\n"); in s3c24xx_i2c_probe()
1096 return -ENOENT; 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()
1108 dev_dbg(&pdev->dev, "registers %p (%p)\n", 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()
1120 return -EINVAL; in s3c24xx_i2c_probe()
1123 ret = clk_prepare_enable(i2c->clk); in s3c24xx_i2c_probe()
1125 dev_err(&pdev->dev, "I2C clock enable failed\n"); in s3c24xx_i2c_probe()
1130 clk_disable(i2c->clk); in s3c24xx_i2c_probe()
1132 dev_err(&pdev->dev, "I2C controller init failed\n"); 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()
1144 dev_err(&pdev->dev, "cannot find IRQ\n"); 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()
1160 dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); 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()
1176 pm_runtime_enable(&pdev->dev); in s3c24xx_i2c_probe()
1178 ret = i2c_add_numbered_adapter(&i2c->adap); in s3c24xx_i2c_probe()
1180 pm_runtime_disable(&pdev->dev); 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()
1194 clk_unprepare(i2c->clk); in s3c24xx_i2c_remove()
1196 pm_runtime_disable(&pdev->dev); in s3c24xx_i2c_remove()
1200 i2c_del_adapter(&i2c->adap); in s3c24xx_i2c_remove()
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()
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()
1230 clk_disable(i2c->clk); in s3c24xx_i2c_resume_noirq()
1231 i2c_mark_adapter_resumed(&i2c->adap); in s3c24xx_i2c_resume_noirq()
1253 .name = "s3c-i2c",