Lines Matching +full:i2c +full:- +full:scl +full:- +full:clk +full:- +full:low +full:- +full:timeout +full:- +full:us
1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for the Renesas R-Car I2C unit
5 * Copyright (C) 2014-19 Wolfram Sang <wsa@sang-engineering.com>
6 * Copyright (C) 2011-2019 Renesas Electronics Corporation
8 * Copyright (C) 2012-14 Renesas Solutions Corp.
11 * This file is based on the drivers/i2c/busses/i2c-sh7760.c
12 * (c) 2005-2008 MSC Vertriebsges.m.b.H, Manuel Lauss <mlau@msc-ge.com>
15 #include <linux/clk.h>
18 #include <linux/dma-mapping.h>
23 #include <linux/i2c.h>
24 #include <linux/i2c-smbus.h>
45 #define ICMPR 0x2C /* SCL mask control */
46 #define ICHPR 0x30 /* SCL HIGH control */
47 #define ICLPR 0x34 /* SCL LOW control */
58 #define MDBS BIT(7) /* non-fifo mode switch */
59 #define FSCL BIT(6) /* override SCL pin */
94 #define HLSE BIT(1) /* HIGH/LOW Separate Control Enable */
95 #define SME BIT(0) /* SCL Mask Enable */
98 #define TCYC17 0x0f /* 17*Tcyc delay 1st bit between SDA and SCL */
102 /* SCL low/high ratio 5:4 to meet all I2C timing specs (incl safety margin) */
107 * Thus, we simply use 20 which works for low and high speeds.
146 struct clk *clk; member
171 #define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
172 #define rcar_i2c_is_recv(p) ((p)->msg->flags & I2C_M_RD)
176 writel(val, priv->io + reg); in rcar_i2c_write()
181 return readl(priv->io + reg); in rcar_i2c_read()
186 writel(~val & 0x7f, priv->io + ICMSR); in rcar_i2c_clear_irq()
202 priv->recovery_icmcr |= FSCL; in rcar_i2c_set_scl()
204 priv->recovery_icmcr &= ~FSCL; in rcar_i2c_set_scl()
206 rcar_i2c_write(priv, ICMCR, priv->recovery_icmcr); in rcar_i2c_set_scl()
214 priv->recovery_icmcr |= FSDA; in rcar_i2c_set_sda()
216 priv->recovery_icmcr &= ~FSDA; in rcar_i2c_set_sda()
218 rcar_i2c_write(priv, ICMCR, priv->recovery_icmcr); in rcar_i2c_set_sda()
243 if (priv->devtype < I2C_RCAR_GEN3) { in rcar_i2c_init()
244 rcar_i2c_write(priv, ICCCR, priv->icccr); in rcar_i2c_init()
248 if (priv->flags & ID_P_FMPLUS) in rcar_i2c_init()
252 rcar_i2c_write(priv, ICCCR, priv->icccr); in rcar_i2c_init()
253 rcar_i2c_write(priv, ICMPR, priv->smd); in rcar_i2c_init()
254 rcar_i2c_write(priv, ICHPR, priv->schd); in rcar_i2c_init()
255 rcar_i2c_write(priv, ICLPR, priv->scld); in rcar_i2c_init()
265 ret = readl_poll_timeout(priv->io + ICMCR, val, !(val & FSDA), 10, in rcar_i2c_bus_barrier()
266 priv->adap.timeout); in rcar_i2c_bus_barrier()
269 priv->recovery_icmcr = MDBS | OBPC | FSDA | FSCL; in rcar_i2c_bus_barrier()
270 ret = i2c_recover_bus(&priv->adap); in rcar_i2c_bus_barrier()
278 u32 cdf, round, ick, sum, scl, cdf_width; in rcar_i2c_clock_calculate() local
290 priv->smd = RCAR_DEFAULT_SMD; in rcar_i2c_clock_calculate()
293 * calculate SCL clock in rcar_i2c_clock_calculate()
298 * SCL = ick / (20 + SCGD * 8 + F[(ticf + tr + intd) * ick]) in rcar_i2c_clock_calculate()
301 * SCL = clkp / (8 + SMD * 2 + SCLD + SCHD +F[(ticf + tr + intd) * clkp]) in rcar_i2c_clock_calculate()
303 * ick : I2C internal clock < 20 MHz in rcar_i2c_clock_calculate()
304 * ticf : I2C SCL falling time in rcar_i2c_clock_calculate()
305 * tr : I2C SCL rising time in rcar_i2c_clock_calculate()
308 * F[] : integer up-valuation in rcar_i2c_clock_calculate()
310 rate = clk_get_rate(priv->clk); in rcar_i2c_clock_calculate()
312 cdf_width = (priv->devtype == I2C_RCAR_GEN1) ? 2 : 3; in rcar_i2c_clock_calculate()
316 if (t.bus_freq_hz > I2C_MAX_FAST_MODE_FREQ && priv->devtype >= I2C_RCAR_GEN4) in rcar_i2c_clock_calculate()
317 priv->flags |= ID_P_FMPLUS; in rcar_i2c_clock_calculate()
319 priv->flags &= ~ID_P_FMPLUS; in rcar_i2c_clock_calculate()
321 /* On Gen3+, we use cdf only for the filters, not as a SCL divider */ in rcar_i2c_clock_calculate()
322 ick = rate / (priv->devtype < I2C_RCAR_GEN3 ? (cdf + 1) : 1); in rcar_i2c_clock_calculate()
335 if (priv->devtype < I2C_RCAR_GEN3) { in rcar_i2c_clock_calculate()
338 * SCL = ick / (20 + 8 * SCGD + F[(ticf + tr + intd) * ick]) in rcar_i2c_clock_calculate()
339 * 20 + 8 * SCGD + F[...] = ick / SCL in rcar_i2c_clock_calculate()
340 * SCGD = ((ick / SCL) - 20 - F[...]) / 8 in rcar_i2c_clock_calculate()
341 * Result (= SCL) should be less than bus_speed for hardware safety in rcar_i2c_clock_calculate()
344 scgd = DIV_ROUND_UP(scgd - 20 - round, 8); in rcar_i2c_clock_calculate()
345 scl = ick / (20 + 8 * scgd + round); in rcar_i2c_clock_calculate()
350 dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u, SCGD: %u\n", in rcar_i2c_clock_calculate()
351 scl, t.bus_freq_hz, rate, round, cdf, scgd); in rcar_i2c_clock_calculate()
353 priv->icccr = scgd << cdf_width | cdf; in rcar_i2c_clock_calculate()
361 * SCL = clkp / (8 + 2 * SMD + SCLD + SCHD + F[(ticf + tr + intd) * clkp]) in rcar_i2c_clock_calculate()
362 * SCL = clkp / (8 + 2 * SMD + RCAR_SCLD_RATIO * x in rcar_i2c_clock_calculate()
367 * SCL = clkp / (8 + 2 * smd + sum_ratio * x + F[...]) in rcar_i2c_clock_calculate()
368 * 8 + 2 * smd + sum_ratio * x + F[...] = clkp / SCL in rcar_i2c_clock_calculate()
369 * x = ((clkp / SCL) - 8 - 2 * smd - F[...]) / sum_ratio in rcar_i2c_clock_calculate()
372 x = DIV_ROUND_UP(x - 8 - 2 * priv->smd - round, sum_ratio); in rcar_i2c_clock_calculate()
373 scl = rate / (8 + 2 * priv->smd + sum_ratio * x + round); in rcar_i2c_clock_calculate()
378 priv->icccr = cdf; in rcar_i2c_clock_calculate()
379 priv->schd = RCAR_SCHD_RATIO * x; in rcar_i2c_clock_calculate()
380 priv->scld = RCAR_SCLD_RATIO * x; in rcar_i2c_clock_calculate()
381 if (priv->smd >= priv->schd) in rcar_i2c_clock_calculate()
382 priv->smd = priv->schd - 1; in rcar_i2c_clock_calculate()
384 dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u SCHD %u SCLD %u SMD %u\n", in rcar_i2c_clock_calculate()
385 scl, t.bus_freq_hz, rate, round, cdf, priv->schd, priv->scld, priv->smd); in rcar_i2c_clock_calculate()
391 dev_err(dev, "it is impossible to calculate best SCL\n"); in rcar_i2c_clock_calculate()
392 return -EINVAL; in rcar_i2c_clock_calculate()
404 bool rep_start = !(priv->flags & ID_REP_AFTER_RD); in rcar_i2c_prepare_msg()
406 priv->pos = 0; in rcar_i2c_prepare_msg()
407 priv->flags &= ID_P_MASK; in rcar_i2c_prepare_msg()
409 if (priv->msgs_left == 1) in rcar_i2c_prepare_msg()
410 priv->flags |= ID_LAST_MSG; in rcar_i2c_prepare_msg()
412 rcar_i2c_write(priv, ICMAR, i2c_8bit_addr_from_msg(priv->msg)); in rcar_i2c_prepare_msg()
413 if (priv->flags & ID_P_NOT_ATOMIC) in rcar_i2c_prepare_msg()
423 priv->msg = msgs; in rcar_i2c_first_msg()
424 priv->msgs_left = num; in rcar_i2c_first_msg()
431 priv->msg++; in rcar_i2c_next_msg()
432 priv->msgs_left--; in rcar_i2c_next_msg()
439 struct dma_chan *chan = priv->dma_direction == DMA_FROM_DEVICE in rcar_i2c_cleanup_dma()
440 ? priv->dma_rx : priv->dma_tx; in rcar_i2c_cleanup_dma()
446 dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg), in rcar_i2c_cleanup_dma()
447 sg_dma_len(&priv->sg), priv->dma_direction); in rcar_i2c_cleanup_dma()
450 if (priv->devtype >= I2C_RCAR_GEN3 && in rcar_i2c_cleanup_dma()
451 priv->dma_direction == DMA_FROM_DEVICE) in rcar_i2c_cleanup_dma()
452 priv->flags |= ID_P_NO_RXDMA; in rcar_i2c_cleanup_dma()
454 priv->dma_direction = DMA_NONE; in rcar_i2c_cleanup_dma()
464 priv->pos += sg_dma_len(&priv->sg); in rcar_i2c_dma_callback()
472 struct i2c_msg *msg = priv->msg; in rcar_i2c_dma()
473 bool read = msg->flags & I2C_M_RD; in rcar_i2c_dma()
475 struct dma_chan *chan = read ? priv->dma_rx : priv->dma_tx; in rcar_i2c_dma()
483 if (!(priv->flags & ID_P_NOT_ATOMIC) || IS_ERR(chan) || msg->len < RCAR_MIN_DMA_LEN || in rcar_i2c_dma()
484 !(msg->flags & I2C_M_DMA_SAFE) || (read && priv->flags & ID_P_NO_RXDMA)) in rcar_i2c_dma()
492 buf = priv->msg->buf; in rcar_i2c_dma()
493 len = priv->msg->len - 2; in rcar_i2c_dma()
498 buf = priv->msg->buf + 1; in rcar_i2c_dma()
499 len = priv->msg->len - 1; in rcar_i2c_dma()
502 dma_addr = dma_map_single(chan->device->dev, buf, len, dir); in rcar_i2c_dma()
503 if (dma_mapping_error(chan->device->dev, dma_addr)) { in rcar_i2c_dma()
508 sg_dma_len(&priv->sg) = len; in rcar_i2c_dma()
509 sg_dma_address(&priv->sg) = dma_addr; in rcar_i2c_dma()
511 priv->dma_direction = dir; in rcar_i2c_dma()
513 txdesc = dmaengine_prep_slave_sg(chan, &priv->sg, 1, in rcar_i2c_dma()
522 txdesc->callback = rcar_i2c_dma_callback; in rcar_i2c_dma()
523 txdesc->callback_param = priv; in rcar_i2c_dma()
544 struct i2c_msg *msg = priv->msg; in rcar_i2c_irq_send()
555 if (priv->pos == 1 && rcar_i2c_dma(priv)) in rcar_i2c_irq_send()
558 if (priv->pos < msg->len) { in rcar_i2c_irq_send()
564 * [ICRXTX] -> [SHIFT] -> [I2C bus] in rcar_i2c_irq_send()
566 rcar_i2c_write(priv, ICRXTX, msg->buf[priv->pos]); in rcar_i2c_irq_send()
567 priv->pos++; in rcar_i2c_irq_send()
571 * It is on _SHIFT_ register, and will sent to I2C bus. in rcar_i2c_irq_send()
574 * [ICRXTX] -> [SHIFT] -> [I2C bus] in rcar_i2c_irq_send()
577 if (priv->flags & ID_LAST_MSG) in rcar_i2c_irq_send()
593 struct i2c_msg *msg = priv->msg; in rcar_i2c_irq_recv()
594 bool recv_len_init = priv->pos == 0 && msg->flags & I2C_M_RECV_LEN; in rcar_i2c_irq_recv()
608 } else if (priv->pos < msg->len) { in rcar_i2c_irq_recv()
612 msg->buf[priv->pos] = data; in rcar_i2c_irq_recv()
615 priv->flags |= ID_DONE | ID_EPROTO; in rcar_i2c_irq_recv()
618 msg->len += msg->buf[0]; in rcar_i2c_irq_recv()
625 priv->pos++; in rcar_i2c_irq_recv()
632 if (priv->pos + 1 == msg->len && !recv_len_init) { in rcar_i2c_irq_recv()
633 if (priv->flags & ID_LAST_MSG) { in rcar_i2c_irq_recv()
637 priv->flags |= ID_REP_AFTER_RD; in rcar_i2c_irq_recv()
641 if (priv->pos == msg->len && !(priv->flags & ID_LAST_MSG)) in rcar_i2c_irq_recv()
662 i2c_slave_event(priv->slave, I2C_SLAVE_READ_REQUESTED, &value); in rcar_i2c_slave_irq()
666 i2c_slave_event(priv->slave, I2C_SLAVE_WRITE_REQUESTED, &value); in rcar_i2c_slave_irq()
671 /* Clear SSR, too, because of old STOPs to other clients than us */ in rcar_i2c_slave_irq()
677 i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value); in rcar_i2c_slave_irq()
683 /* master wants to write to us */ in rcar_i2c_slave_irq()
688 ret = i2c_slave_event(priv->slave, I2C_SLAVE_WRITE_RECEIVED, &value); in rcar_i2c_slave_irq()
694 /* master wants to read from us */ in rcar_i2c_slave_irq()
696 i2c_slave_event(priv->slave, I2C_SLAVE_READ_PROCESSED, &value); in rcar_i2c_slave_irq()
705 * This driver has a lock-free design because there are IP cores (at least
706 * R-Car Gen2) which have an inherent race condition in their hardware design.
712 * R-Car Gen3 seems to have this fixed but earlier versions than R-Car Gen2 are
726 priv->flags |= ID_DONE | ID_ARBLOST; in rcar_i2c_irq()
733 if (priv->flags & ID_P_NOT_ATOMIC) in rcar_i2c_irq()
735 priv->flags |= ID_NACK; in rcar_i2c_irq()
741 priv->msgs_left--; /* The last message also made it */ in rcar_i2c_irq()
742 priv->flags |= ID_DONE; in rcar_i2c_irq()
752 if (priv->flags & ID_DONE) { in rcar_i2c_irq()
755 if (priv->flags & ID_P_NOT_ATOMIC) in rcar_i2c_irq()
756 wake_up(&priv->wait); in rcar_i2c_irq()
768 if (likely(!(priv->flags & ID_REP_AFTER_RD))) in rcar_i2c_gen2_irq()
773 if (priv->flags & ID_P_NOT_ATOMIC) in rcar_i2c_gen2_irq()
786 if (priv->flags & ID_P_NOT_ATOMIC) in rcar_i2c_gen3_irq()
793 if (likely(!(priv->flags & ID_REP_AFTER_RD) && msr)) in rcar_i2c_gen3_irq()
845 read = msg->flags & I2C_M_RD; in rcar_i2c_request_dma()
847 chan = read ? priv->dma_rx : priv->dma_tx; in rcar_i2c_request_dma()
848 if (PTR_ERR(chan) != -EPROBE_DEFER) in rcar_i2c_request_dma()
852 chan = rcar_i2c_request_dma_chan(dev, dir, priv->res->start + ICRXTX); in rcar_i2c_request_dma()
855 priv->dma_rx = chan; in rcar_i2c_request_dma()
857 priv->dma_tx = chan; in rcar_i2c_request_dma()
862 if (!IS_ERR(priv->dma_tx)) { in rcar_i2c_release_dma()
863 dma_release_channel(priv->dma_tx); in rcar_i2c_release_dma()
864 priv->dma_tx = ERR_PTR(-EPROBE_DEFER); in rcar_i2c_release_dma()
867 if (!IS_ERR(priv->dma_rx)) { in rcar_i2c_release_dma()
868 dma_release_channel(priv->dma_rx); in rcar_i2c_release_dma()
869 priv->dma_rx = ERR_PTR(-EPROBE_DEFER); in rcar_i2c_release_dma()
873 /* I2C is a special case, we need to poll the status of a reset */
878 ret = reset_control_reset(priv->rstc); in rcar_i2c_do_reset()
883 100, false, priv->rstc); in rcar_i2c_do_reset()
895 priv->flags |= ID_P_NOT_ATOMIC; in rcar_i2c_master_xfer()
905 if (priv->devtype >= I2C_RCAR_GEN3) { in rcar_i2c_master_xfer()
906 priv->flags &= ~ID_P_NO_RXDMA; in rcar_i2c_master_xfer()
919 time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE, in rcar_i2c_master_xfer()
920 num * adap->timeout); in rcar_i2c_master_xfer()
923 if (priv->dma_direction != DMA_NONE) in rcar_i2c_master_xfer()
928 ret = -ETIMEDOUT; in rcar_i2c_master_xfer()
929 } else if (priv->flags & ID_NACK) { in rcar_i2c_master_xfer()
930 ret = -ENXIO; in rcar_i2c_master_xfer()
931 } else if (priv->flags & ID_ARBLOST) { in rcar_i2c_master_xfer()
932 ret = -EAGAIN; in rcar_i2c_master_xfer()
933 } else if (priv->flags & ID_EPROTO) { in rcar_i2c_master_xfer()
934 ret = -EPROTO; in rcar_i2c_master_xfer()
936 ret = num - priv->msgs_left; /* The number of transfer */ in rcar_i2c_master_xfer()
941 if (ret < 0 && ret != -ENXIO) in rcar_i2c_master_xfer()
942 dev_err(dev, "error %d : %x\n", ret, priv->flags); in rcar_i2c_master_xfer()
957 priv->flags &= ~ID_P_NOT_ATOMIC; in rcar_i2c_master_xfer_atomic()
969 j = jiffies + num * adap->timeout; in rcar_i2c_master_xfer_atomic()
976 if (priv->devtype < I2C_RCAR_GEN3) in rcar_i2c_master_xfer_atomic()
983 } while (!(priv->flags & ID_DONE) && time_left); in rcar_i2c_master_xfer_atomic()
987 ret = -ETIMEDOUT; in rcar_i2c_master_xfer_atomic()
988 } else if (priv->flags & ID_NACK) { in rcar_i2c_master_xfer_atomic()
989 ret = -ENXIO; in rcar_i2c_master_xfer_atomic()
990 } else if (priv->flags & ID_ARBLOST) { in rcar_i2c_master_xfer_atomic()
991 ret = -EAGAIN; in rcar_i2c_master_xfer_atomic()
992 } else if (priv->flags & ID_EPROTO) { in rcar_i2c_master_xfer_atomic()
993 ret = -EPROTO; in rcar_i2c_master_xfer_atomic()
995 ret = num - priv->msgs_left; /* The number of transfer */ in rcar_i2c_master_xfer_atomic()
1000 if (ret < 0 && ret != -ENXIO) in rcar_i2c_master_xfer_atomic()
1001 dev_err(dev, "error %d : %x\n", ret, priv->flags); in rcar_i2c_master_xfer_atomic()
1008 struct rcar_i2c_priv *priv = i2c_get_adapdata(slave->adapter); in rcar_reg_slave()
1010 if (priv->slave) in rcar_reg_slave()
1011 return -EBUSY; in rcar_reg_slave()
1013 if (slave->flags & I2C_CLIENT_TEN) in rcar_reg_slave()
1014 return -EAFNOSUPPORT; in rcar_reg_slave()
1019 priv->slave = slave; in rcar_reg_slave()
1020 rcar_i2c_write(priv, ICSAR, slave->addr); in rcar_reg_slave()
1030 struct rcar_i2c_priv *priv = i2c_get_adapdata(slave->adapter); in rcar_unreg_slave()
1032 WARN_ON(!priv->slave); in rcar_unreg_slave()
1035 disable_irq(priv->irq); in rcar_unreg_slave()
1038 enable_irq(priv->irq); in rcar_unreg_slave()
1042 priv->slave = NULL; in rcar_unreg_slave()
1062 if (priv->flags & ID_P_HOST_NOTIFY) in rcar_i2c_func()
1081 { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_GEN1 },
1082 { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_GEN1 },
1083 { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_GEN2 },
1084 { .compatible = "renesas,i2c-r8a7791", .data = (void *)I2C_RCAR_GEN2 },
1085 { .compatible = "renesas,i2c-r8a7792", .data = (void *)I2C_RCAR_GEN2 },
1086 { .compatible = "renesas,i2c-r8a7793", .data = (void *)I2C_RCAR_GEN2 },
1087 { .compatible = "renesas,i2c-r8a7794", .data = (void *)I2C_RCAR_GEN2 },
1088 { .compatible = "renesas,i2c-r8a7795", .data = (void *)I2C_RCAR_GEN3 },
1089 { .compatible = "renesas,i2c-r8a7796", .data = (void *)I2C_RCAR_GEN3 },
1091 { .compatible = "renesas,i2c-r8a779f0", .data = (void *)I2C_RCAR_GEN3 },
1092 { .compatible = "renesas,rcar-gen1-i2c", .data = (void *)I2C_RCAR_GEN1 },
1093 { .compatible = "renesas,rcar-gen2-i2c", .data = (void *)I2C_RCAR_GEN2 },
1094 { .compatible = "renesas,rcar-gen3-i2c", .data = (void *)I2C_RCAR_GEN3 },
1095 { .compatible = "renesas,rcar-gen4-i2c", .data = (void *)I2C_RCAR_GEN4 },
1104 struct device *dev = &pdev->dev; in rcar_i2c_probe()
1114 return -ENOMEM; in rcar_i2c_probe()
1116 priv->clk = devm_clk_get(dev, NULL); in rcar_i2c_probe()
1117 if (IS_ERR(priv->clk)) { in rcar_i2c_probe()
1119 return PTR_ERR(priv->clk); in rcar_i2c_probe()
1122 priv->io = devm_platform_get_and_ioremap_resource(pdev, 0, &priv->res); in rcar_i2c_probe()
1123 if (IS_ERR(priv->io)) in rcar_i2c_probe()
1124 return PTR_ERR(priv->io); in rcar_i2c_probe()
1126 priv->devtype = (enum rcar_i2c_type)of_device_get_match_data(dev); in rcar_i2c_probe()
1127 init_waitqueue_head(&priv->wait); in rcar_i2c_probe()
1129 adap = &priv->adap; in rcar_i2c_probe()
1130 adap->nr = pdev->id; in rcar_i2c_probe()
1131 adap->algo = &rcar_i2c_algo; in rcar_i2c_probe()
1132 adap->class = I2C_CLASS_DEPRECATED; in rcar_i2c_probe()
1133 adap->retries = 3; in rcar_i2c_probe()
1134 adap->dev.parent = dev; in rcar_i2c_probe()
1135 adap->dev.of_node = dev->of_node; in rcar_i2c_probe()
1136 adap->bus_recovery_info = &rcar_i2c_bri; in rcar_i2c_probe()
1137 adap->quirks = &rcar_i2c_quirks; in rcar_i2c_probe()
1139 strscpy(adap->name, pdev->name, sizeof(adap->name)); in rcar_i2c_probe()
1142 sg_init_table(&priv->sg, 1); in rcar_i2c_probe()
1143 priv->dma_direction = DMA_NONE; in rcar_i2c_probe()
1144 priv->dma_rx = priv->dma_tx = ERR_PTR(-EPROBE_DEFER); in rcar_i2c_probe()
1157 if (priv->devtype < I2C_RCAR_GEN3) { in rcar_i2c_probe()
1162 /* Stay always active when multi-master to keep arbitration working */ in rcar_i2c_probe()
1163 if (of_property_read_bool(dev->of_node, "multi-master")) in rcar_i2c_probe()
1164 priv->flags |= ID_P_PM_BLOCKED; in rcar_i2c_probe()
1168 if (of_property_read_bool(dev->of_node, "smbus")) in rcar_i2c_probe()
1169 priv->flags |= ID_P_HOST_NOTIFY; in rcar_i2c_probe()
1171 if (priv->devtype >= I2C_RCAR_GEN3) { in rcar_i2c_probe()
1172 priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); in rcar_i2c_probe()
1173 if (IS_ERR(priv->rstc)) { in rcar_i2c_probe()
1174 ret = PTR_ERR(priv->rstc); in rcar_i2c_probe()
1178 ret = reset_control_status(priv->rstc); in rcar_i2c_probe()
1186 priv->irq = ret; in rcar_i2c_probe()
1187 ret = devm_request_irq(dev, priv->irq, irqhandler, irqflags, dev_name(dev), priv); in rcar_i2c_probe()
1189 dev_err(dev, "cannot get irq %d\n", priv->irq); in rcar_i2c_probe()
1199 if (priv->flags & ID_P_HOST_NOTIFY) { in rcar_i2c_probe()
1200 priv->host_notify_client = i2c_new_slave_host_notify_device(adap); in rcar_i2c_probe()
1201 if (IS_ERR(priv->host_notify_client)) { in rcar_i2c_probe()
1202 ret = PTR_ERR(priv->host_notify_client); in rcar_i2c_probe()
1212 i2c_del_adapter(&priv->adap); in rcar_i2c_probe()
1214 if (priv->flags & ID_P_PM_BLOCKED) in rcar_i2c_probe()
1224 struct device *dev = &pdev->dev; in rcar_i2c_remove()
1226 if (priv->host_notify_client) in rcar_i2c_remove()
1227 i2c_free_slave_host_notify_device(priv->host_notify_client); in rcar_i2c_remove()
1228 i2c_del_adapter(&priv->adap); in rcar_i2c_remove()
1230 if (priv->flags & ID_P_PM_BLOCKED) in rcar_i2c_remove()
1239 i2c_mark_adapter_suspended(&priv->adap); in rcar_i2c_suspend()
1247 i2c_mark_adapter_resumed(&priv->adap); in rcar_i2c_resume()
1257 .name = "i2c-rcar",
1268 MODULE_DESCRIPTION("Renesas R-Car I2C bus driver");