Lines Matching +full:i2c +full:- +full:r1p10

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * I2C bus driver for the Cadence I2C controller.
5 * Copyright (C) 2009 - 2014 Xilinx, Inc.
10 #include <linux/i2c.h>
21 /* Register offsets for the I2C device. */
24 #define CDNS_I2C_ADDR_OFFSET 0x08 /* I2C Address Register, RW */
25 #define CDNS_I2C_DATA_OFFSET 0x0C /* I2C Data Register, RW */
60 * I2C Address Register Bit mask definitions
62 * bits. A write access to this register always initiates a transfer if the I2C
65 #define CDNS_I2C_ADDR_MASK 0x000003FF /* I2C Address Mask */
68 * I2C Interrupt Registers Bit mask definitions
121 #define CDNS_I2C_TRANSFER_SIZE(max) ((max) - 3)
123 #define DRIVER_NAME "cdns-i2c"
134 #define cdns_i2c_readreg(offset) readl_relaxed(id->membase + offset)
135 #define cdns_i2c_writereg(val, offset) writel_relaxed(val, id->membase + offset)
139 * enum cdns_i2c_mode - I2C Controller current operating mode
141 * @CDNS_I2C_MODE_SLAVE: I2C controller operating in slave mode
142 * @CDNS_I2C_MODE_MASTER: I2C Controller operating in master mode
150 * enum cdns_i2c_slave_state - Slave state when I2C is operating in slave mode
152 * @CDNS_I2C_SLAVE_STATE_IDLE: I2C slave idle
153 * @CDNS_I2C_SLAVE_STATE_SEND: I2C slave sending data to master
154 * @CDNS_I2C_SLAVE_STATE_RECV: I2C slave receiving data from master
164 * struct cdns_i2c - I2C device private data structure
167 * @membase: Base address of the I2C device
168 * @adap: I2C adapter instance
177 * @input_clk: Input clock to I2C controller
178 * @i2c_clk: Maximum I2C clock speed
183 * @quirks: flag for broken hold bit usage in r1p10
185 * @rinfo: I2C GPIO recovery information
188 * @dev_mode: I2C operating role(master/slave).
189 * @slave_state: I2C Slave state(idle/read/write).
232 * cdns_i2c_clear_bus_hold - Clear bus hold bit
247 (id->curr_recv_count == id->fifo_depth + 1)); in cdns_is_holdquirk()
260 id->dev_mode = mode; in cdns_i2c_set_mode()
261 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE; in cdns_i2c_set_mode()
265 /* Enable i2c master */ in cdns_i2c_set_mode()
266 cdns_i2c_writereg(id->ctrl_reg_diva_divb | in cdns_i2c_set_mode()
278 /* Enable i2c slave */ in cdns_i2c_set_mode()
279 cdns_i2c_writereg(id->ctrl_reg_diva_divb & in cdns_i2c_set_mode()
284 cdns_i2c_writereg(id->slave->addr & CDNS_I2C_ADDR_MASK, in cdns_i2c_set_mode()
300 if (id->slave_state == CDNS_I2C_SLAVE_STATE_IDLE) { in cdns_i2c_slave_rcv_data()
301 id->slave_state = CDNS_I2C_SLAVE_STATE_RECV; in cdns_i2c_slave_rcv_data()
302 i2c_slave_event(id->slave, I2C_SLAVE_WRITE_REQUESTED, NULL); in cdns_i2c_slave_rcv_data()
309 while (bytes--) { in cdns_i2c_slave_rcv_data()
311 i2c_slave_event(id->slave, I2C_SLAVE_WRITE_RECEIVED, &data); in cdns_i2c_slave_rcv_data()
320 if (id->slave_state == CDNS_I2C_SLAVE_STATE_IDLE) { in cdns_i2c_slave_send_data()
321 id->slave_state = CDNS_I2C_SLAVE_STATE_SEND; in cdns_i2c_slave_send_data()
322 i2c_slave_event(id->slave, I2C_SLAVE_READ_REQUESTED, &data); in cdns_i2c_slave_send_data()
324 i2c_slave_event(id->slave, I2C_SLAVE_READ_PROCESSED, &data); in cdns_i2c_slave_send_data()
332 * cdns_i2c_slave_isr - Interrupt handler for the I2C device in slave role
333 * @ptr: Pointer to I2C device private data
336 * the I2C device in slave role.
362 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE; in cdns_i2c_slave_isr()
363 i2c_slave_event(id->slave, I2C_SLAVE_STOP, NULL); in cdns_i2c_slave_isr()
372 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE; in cdns_i2c_slave_isr()
373 i2c_slave_event(id->slave, I2C_SLAVE_STOP, NULL); in cdns_i2c_slave_isr()
380 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE; in cdns_i2c_slave_isr()
381 i2c_slave_event(id->slave, I2C_SLAVE_STOP, NULL); in cdns_i2c_slave_isr()
390 * cdns_i2c_master_isr - Interrupt handler for the I2C device in master role
391 * @ptr: Pointer to I2C device private data
394 * the error interrupts of the I2C device in master role.
410 id->err_status = 0; in cdns_i2c_master_isr()
422 updatetx = id->recv_count > id->curr_recv_count; in cdns_i2c_master_isr()
425 if (id->p_recv_buf && in cdns_i2c_master_isr()
431 if (id->recv_count > 0) { in cdns_i2c_master_isr()
432 *(id->p_recv_buf)++ = in cdns_i2c_master_isr()
434 id->recv_count--; in cdns_i2c_master_isr()
435 id->curr_recv_count--; in cdns_i2c_master_isr()
442 if (id->recv_count <= id->fifo_depth && in cdns_i2c_master_isr()
443 !id->bus_hold_flag) in cdns_i2c_master_isr()
447 dev_err(id->adap.dev.parent, in cdns_i2c_master_isr()
449 id->err_status |= CDNS_I2C_IXR_TO; in cdns_i2c_master_isr()
461 * maintain transfer size non-zero while performing a large in cdns_i2c_master_isr()
467 (id->curr_recv_count - id->fifo_depth)) in cdns_i2c_master_isr()
474 if (((int)(id->recv_count) - id->fifo_depth) > in cdns_i2c_master_isr()
475 id->transfer_size) { in cdns_i2c_master_isr()
476 cdns_i2c_writereg(id->transfer_size, in cdns_i2c_master_isr()
478 id->curr_recv_count = id->transfer_size + in cdns_i2c_master_isr()
479 id->fifo_depth; in cdns_i2c_master_isr()
481 cdns_i2c_writereg(id->recv_count - in cdns_i2c_master_isr()
482 id->fifo_depth, in cdns_i2c_master_isr()
484 id->curr_recv_count = id->recv_count; in cdns_i2c_master_isr()
489 if ((isr_status & CDNS_I2C_IXR_COMP) && !id->recv_count) { in cdns_i2c_master_isr()
490 if (!id->bus_hold_flag) in cdns_i2c_master_isr()
499 if ((isr_status & CDNS_I2C_IXR_COMP) && !id->p_recv_buf) { in cdns_i2c_master_isr()
504 if (id->send_count) { in cdns_i2c_master_isr()
505 avail_bytes = id->fifo_depth - in cdns_i2c_master_isr()
507 if (id->send_count > avail_bytes) in cdns_i2c_master_isr()
510 bytes_to_send = id->send_count; in cdns_i2c_master_isr()
512 while (bytes_to_send--) { in cdns_i2c_master_isr()
514 (*(id->p_send_buf)++), in cdns_i2c_master_isr()
516 id->send_count--; in cdns_i2c_master_isr()
526 if (!id->send_count && !id->bus_hold_flag) in cdns_i2c_master_isr()
533 id->err_status |= isr_status & CDNS_I2C_IXR_ERR_INTR_MASK; in cdns_i2c_master_isr()
534 if (id->err_status) in cdns_i2c_master_isr()
538 complete(&id->xfer_done); in cdns_i2c_master_isr()
544 * cdns_i2c_isr - Interrupt handler for the I2C device
545 * @irq: irq number for the I2C device
549 * i2c controller.
558 if (id->dev_mode == CDNS_I2C_MODE_SLAVE) in cdns_i2c_isr()
565 * cdns_i2c_mrecv - Prepare and start a master receive operation
566 * @id: pointer to the i2c device structure
578 id->p_recv_buf = id->p_msg->buf; in cdns_i2c_mrecv()
579 id->recv_count = id->p_msg->len; in cdns_i2c_mrecv()
587 * byte, plus one checksum byte if PEC is enabled. p_msg->len will be 2 if in cdns_i2c_mrecv()
590 if (id->p_msg->flags & I2C_M_RECV_LEN) in cdns_i2c_mrecv()
591 id->recv_count = I2C_SMBUS_BLOCK_MAX + id->p_msg->len; in cdns_i2c_mrecv()
593 id->curr_recv_count = id->recv_count; in cdns_i2c_mrecv()
599 if (id->recv_count > id->fifo_depth) in cdns_i2c_mrecv()
614 if (id->recv_count > id->transfer_size) { in cdns_i2c_mrecv()
615 cdns_i2c_writereg(id->transfer_size, in cdns_i2c_mrecv()
617 id->curr_recv_count = id->transfer_size; in cdns_i2c_mrecv()
619 cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET); in cdns_i2c_mrecv()
623 if (!id->bus_hold_flag && id->recv_count <= id->fifo_depth) { in cdns_i2c_mrecv()
626 if (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT) in cdns_i2c_mrecv()
631 addr = id->p_msg->addr; in cdns_i2c_mrecv()
662 * cdns_i2c_msend - Prepare and start a master send operation
663 * @id: pointer to the i2c device
672 id->p_recv_buf = NULL; in cdns_i2c_msend()
673 id->p_send_buf = id->p_msg->buf; in cdns_i2c_msend()
674 id->send_count = id->p_msg->len; in cdns_i2c_msend()
685 if (id->send_count > id->fifo_depth) in cdns_i2c_msend()
698 avail_bytes = id->fifo_depth - in cdns_i2c_msend()
701 if (id->send_count > avail_bytes) in cdns_i2c_msend()
704 bytes_to_send = id->send_count; in cdns_i2c_msend()
706 while (bytes_to_send--) { in cdns_i2c_msend()
707 cdns_i2c_writereg((*(id->p_send_buf)++), CDNS_I2C_DATA_OFFSET); in cdns_i2c_msend()
708 id->send_count--; in cdns_i2c_msend()
715 if (!id->bus_hold_flag && !id->send_count) in cdns_i2c_msend()
717 /* Set the slave address in address register - triggers operation. */ in cdns_i2c_msend()
718 cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK, in cdns_i2c_msend()
725 * cdns_i2c_master_reset - Reset the interface
726 * @adap: pointer to the i2c adapter driver instance
733 struct cdns_i2c *id = adap->algo_data; in cdns_i2c_master_reset()
759 id->p_msg = msg; in cdns_i2c_process_msg()
760 id->err_status = 0; in cdns_i2c_process_msg()
761 reinit_completion(&id->xfer_done); in cdns_i2c_process_msg()
765 if (msg->flags & I2C_M_TEN) { in cdns_i2c_process_msg()
776 if (msg->flags & I2C_M_RD) in cdns_i2c_process_msg()
782 msg_timeout = msecs_to_jiffies((1000 * msg->len * BITS_PER_BYTE) / id->i2c_clk); in cdns_i2c_process_msg()
786 if (msg_timeout < adap->timeout) in cdns_i2c_process_msg()
787 msg_timeout = adap->timeout; in cdns_i2c_process_msg()
790 time_left = wait_for_completion_timeout(&id->xfer_done, msg_timeout); in cdns_i2c_process_msg()
793 return -ETIMEDOUT; in cdns_i2c_process_msg()
800 if (id->err_status & CDNS_I2C_IXR_ARB_LOST) in cdns_i2c_process_msg()
801 return -EAGAIN; in cdns_i2c_process_msg()
803 if (msg->flags & I2C_M_RECV_LEN) in cdns_i2c_process_msg()
804 msg->len += min_t(unsigned int, msg->buf[0], I2C_SMBUS_BLOCK_MAX); in cdns_i2c_process_msg()
810 * cdns_i2c_master_xfer - The main i2c transfer function
811 * @adap: pointer to the i2c adapter driver instance
812 * @msgs: pointer to the i2c message structure
824 struct cdns_i2c *id = adap->algo_data; in cdns_i2c_master_xfer()
830 ret = pm_runtime_resume_and_get(id->dev); in cdns_i2c_master_xfer()
835 /* Check i2c operating mode and switch if possible */ in cdns_i2c_master_xfer()
836 if (id->dev_mode == CDNS_I2C_MODE_SLAVE) { in cdns_i2c_master_xfer()
837 if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE) { in cdns_i2c_master_xfer()
838 ret = -EAGAIN; in cdns_i2c_master_xfer()
852 ret = readl_relaxed_poll_timeout(id->membase + CDNS_I2C_SR_OFFSET, in cdns_i2c_master_xfer()
857 ret = -EAGAIN; in cdns_i2c_master_xfer()
858 if (id->adap.bus_recovery_info) in cdns_i2c_master_xfer()
863 hold_quirk = !!(id->quirks & CDNS_I2C_BROKEN_HOLD_BIT); in cdns_i2c_master_xfer()
876 for (count = 0; (count < num - 1 && hold_quirk); count++) { in cdns_i2c_master_xfer()
878 dev_warn(adap->dev.parent, in cdns_i2c_master_xfer()
880 ret = -EOPNOTSUPP; in cdns_i2c_master_xfer()
884 id->bus_hold_flag = 1; in cdns_i2c_master_xfer()
889 id->bus_hold_flag = 0; in cdns_i2c_master_xfer()
894 if (count == (num - 1)) in cdns_i2c_master_xfer()
895 id->bus_hold_flag = 0; in cdns_i2c_master_xfer()
902 if (id->err_status) { in cdns_i2c_master_xfer()
905 if (id->err_status & CDNS_I2C_IXR_NACK) { in cdns_i2c_master_xfer()
906 ret = -ENXIO; in cdns_i2c_master_xfer()
909 ret = -EIO; in cdns_i2c_master_xfer()
919 /* Switch i2c mode to slave */ in cdns_i2c_master_xfer()
924 pm_runtime_mark_last_busy(id->dev); in cdns_i2c_master_xfer()
925 pm_runtime_put_autosuspend(id->dev); in cdns_i2c_master_xfer()
930 * cdns_i2c_func - Returns the supported features of the I2C driver
931 * @adap: pointer to the i2c adapter structure
952 struct cdns_i2c *id = container_of(slave->adapter, struct cdns_i2c, in cdns_reg_slave()
955 if (id->slave) in cdns_reg_slave()
956 return -EBUSY; in cdns_reg_slave()
958 if (slave->flags & I2C_CLIENT_TEN) in cdns_reg_slave()
959 return -EAFNOSUPPORT; in cdns_reg_slave()
961 ret = pm_runtime_resume_and_get(id->dev); in cdns_reg_slave()
966 id->slave = slave; in cdns_reg_slave()
968 /* Enable I2C slave */ in cdns_reg_slave()
976 struct cdns_i2c *id = container_of(slave->adapter, struct cdns_i2c, in cdns_unreg_slave()
979 pm_runtime_put(id->dev); in cdns_unreg_slave()
982 id->slave = NULL; in cdns_unreg_slave()
984 /* Enable I2C master */ in cdns_unreg_slave()
1001 * cdns_i2c_calc_divs - Calculate clock dividers
1002 * @f: I2C clock frequency
1007 * f is used as input and output variable. As input it is used as target I2C
1008 * frequency. On function exit f holds the actually resulting I2C frequency.
1027 return -EINVAL; in cdns_i2c_calc_divs()
1029 last_error = -1; in cdns_i2c_calc_divs()
1035 div_b--; in cdns_i2c_calc_divs()
1042 current_error = fscl - actual_fscl; in cdns_i2c_calc_divs()
1060 * cdns_i2c_setclk - This function sets the serial clock rate for the I2C device
1061 * @clk_in: I2C clock input frequency in Hz
1062 * @id: Pointer to the I2C device structure
1080 unsigned long fscl = id->i2c_clk; in cdns_i2c_setclk()
1086 ctrl_reg = id->ctrl_reg; in cdns_i2c_setclk()
1090 id->ctrl_reg = ctrl_reg; in cdns_i2c_setclk()
1093 id->ctrl_reg_diva_divb = ctrl_reg & (CDNS_I2C_CR_DIVA_MASK | in cdns_i2c_setclk()
1100 * cdns_i2c_clk_notifier_cb - Clock rate change callback
1108 * New dividers are written to the HW in the pre- or post change notification
1121 if (pm_runtime_suspended(id->dev)) in cdns_i2c_clk_notifier_cb()
1127 unsigned long input_clk = ndata->new_rate; in cdns_i2c_clk_notifier_cb()
1128 unsigned long fscl = id->i2c_clk; in cdns_i2c_clk_notifier_cb()
1134 dev_warn(id->adap.dev.parent, in cdns_i2c_clk_notifier_cb()
1140 if (ndata->new_rate > ndata->old_rate) in cdns_i2c_clk_notifier_cb()
1141 cdns_i2c_setclk(ndata->new_rate, id); in cdns_i2c_clk_notifier_cb()
1146 id->input_clk = ndata->new_rate; in cdns_i2c_clk_notifier_cb()
1148 if (ndata->new_rate < ndata->old_rate) in cdns_i2c_clk_notifier_cb()
1149 cdns_i2c_setclk(ndata->new_rate, id); in cdns_i2c_clk_notifier_cb()
1153 if (ndata->new_rate > ndata->old_rate) in cdns_i2c_clk_notifier_cb()
1154 cdns_i2c_setclk(ndata->old_rate, id); in cdns_i2c_clk_notifier_cb()
1162 * cdns_i2c_runtime_suspend - Runtime suspend method for the driver
1173 clk_disable(xi2c->clk); in cdns_i2c_runtime_suspend()
1182 i2c_mark_adapter_suspended(&xi2c->adap); in cdns_i2c_suspend()
1191 * cdns_i2c_init - Controller initialisation
1194 * Initialise the i2c controller.
1199 cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET); in cdns_i2c_init()
1201 * Cadence I2C controller has a bug wherein it generates in cdns_i2c_init()
1211 * cdns_i2c_runtime_resume - Runtime resume
1223 ret = clk_enable(xi2c->clk); in cdns_i2c_runtime_resume()
1248 i2c_mark_adapter_resumed(&xi2c->adap); in cdns_i2c_resume()
1264 { .compatible = "cdns,i2c-r1p10", .data = &r1p10_i2c_def },
1265 { .compatible = "cdns,i2c-r1p14",},
1271 * cdns_i2c_detect_transfer_size - Detect the maximum transfer size supported
1275 * Cadence I2C controller.
1296 id->transfer_size = CDNS_I2C_TRANSFER_SIZE(val); in cdns_i2c_detect_transfer_size()
1302 * cdns_i2c_probe - Platform registration call
1305 * This function does all the memory allocation and registration for the i2c
1318 id = devm_kzalloc(&pdev->dev, sizeof(*id), GFP_KERNEL); in cdns_i2c_probe()
1320 return -ENOMEM; in cdns_i2c_probe()
1322 id->dev = &pdev->dev; in cdns_i2c_probe()
1325 match = of_match_node(cdns_i2c_of_match, pdev->dev.of_node); in cdns_i2c_probe()
1326 if (match && match->data) { in cdns_i2c_probe()
1327 const struct cdns_platform_data *data = match->data; in cdns_i2c_probe()
1328 id->quirks = data->quirks; in cdns_i2c_probe()
1331 id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev); in cdns_i2c_probe()
1332 if (IS_ERR(id->rinfo.pinctrl)) { in cdns_i2c_probe()
1333 int err = PTR_ERR(id->rinfo.pinctrl); in cdns_i2c_probe()
1335 dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); in cdns_i2c_probe()
1336 if (err != -ENODEV) in cdns_i2c_probe()
1339 id->adap.bus_recovery_info = &id->rinfo; in cdns_i2c_probe()
1342 id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem); in cdns_i2c_probe()
1343 if (IS_ERR(id->membase)) in cdns_i2c_probe()
1344 return PTR_ERR(id->membase); in cdns_i2c_probe()
1350 id->adap.owner = THIS_MODULE; in cdns_i2c_probe()
1351 id->adap.dev.of_node = pdev->dev.of_node; in cdns_i2c_probe()
1352 id->adap.algo = &cdns_i2c_algo; in cdns_i2c_probe()
1353 id->adap.timeout = CDNS_I2C_TIMEOUT; in cdns_i2c_probe()
1354 id->adap.retries = 3; /* Default retry value. */ in cdns_i2c_probe()
1355 id->adap.algo_data = id; in cdns_i2c_probe()
1356 id->adap.dev.parent = &pdev->dev; in cdns_i2c_probe()
1357 init_completion(&id->xfer_done); in cdns_i2c_probe()
1358 snprintf(id->adap.name, sizeof(id->adap.name), in cdns_i2c_probe()
1359 "Cadence I2C at %08lx", (unsigned long)r_mem->start); in cdns_i2c_probe()
1361 id->clk = devm_clk_get(&pdev->dev, NULL); in cdns_i2c_probe()
1362 if (IS_ERR(id->clk)) in cdns_i2c_probe()
1363 return dev_err_probe(&pdev->dev, PTR_ERR(id->clk), in cdns_i2c_probe()
1366 id->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL); in cdns_i2c_probe()
1367 if (IS_ERR(id->reset)) in cdns_i2c_probe()
1368 return dev_err_probe(&pdev->dev, PTR_ERR(id->reset), in cdns_i2c_probe()
1371 ret = clk_prepare_enable(id->clk); in cdns_i2c_probe()
1373 dev_err(&pdev->dev, "Unable to enable clock.\n"); in cdns_i2c_probe()
1375 ret = reset_control_deassert(id->reset); in cdns_i2c_probe()
1377 dev_err_probe(&pdev->dev, ret, in cdns_i2c_probe()
1378 "Failed to de-assert reset.\n"); in cdns_i2c_probe()
1382 pm_runtime_set_autosuspend_delay(id->dev, CNDS_I2C_PM_TIMEOUT); in cdns_i2c_probe()
1383 pm_runtime_use_autosuspend(id->dev); in cdns_i2c_probe()
1384 pm_runtime_set_active(id->dev); in cdns_i2c_probe()
1385 pm_runtime_enable(id->dev); in cdns_i2c_probe()
1387 id->clk_rate_change_nb.notifier_call = cdns_i2c_clk_notifier_cb; in cdns_i2c_probe()
1388 if (clk_notifier_register(id->clk, &id->clk_rate_change_nb)) in cdns_i2c_probe()
1389 dev_warn(&pdev->dev, "Unable to register clock notifier.\n"); in cdns_i2c_probe()
1390 id->input_clk = clk_get_rate(id->clk); in cdns_i2c_probe()
1392 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", in cdns_i2c_probe()
1393 &id->i2c_clk); in cdns_i2c_probe()
1394 if (ret || (id->i2c_clk > I2C_MAX_FAST_MODE_FREQ)) in cdns_i2c_probe()
1395 id->i2c_clk = I2C_MAX_STANDARD_MODE_FREQ; in cdns_i2c_probe()
1399 id->dev_mode = CDNS_I2C_MODE_MASTER; in cdns_i2c_probe()
1400 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE; in cdns_i2c_probe()
1402 id->ctrl_reg = CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS; in cdns_i2c_probe()
1404 id->fifo_depth = CDNS_I2C_FIFO_DEPTH_DEFAULT; in cdns_i2c_probe()
1405 of_property_read_u32(pdev->dev.of_node, "fifo-depth", &id->fifo_depth); in cdns_i2c_probe()
1409 ret = cdns_i2c_setclk(id->input_clk, id); in cdns_i2c_probe()
1411 dev_err(&pdev->dev, "invalid SCL clock: %u Hz\n", id->i2c_clk); in cdns_i2c_probe()
1412 ret = -EINVAL; in cdns_i2c_probe()
1416 ret = devm_request_irq(&pdev->dev, irq, cdns_i2c_isr, 0, in cdns_i2c_probe()
1419 dev_err(&pdev->dev, "cannot get irq %d\n", irq); in cdns_i2c_probe()
1424 ret = i2c_add_adapter(&id->adap); in cdns_i2c_probe()
1428 dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n", in cdns_i2c_probe()
1429 id->i2c_clk / 1000, (unsigned long)r_mem->start, irq); in cdns_i2c_probe()
1434 clk_notifier_unregister(id->clk, &id->clk_rate_change_nb); in cdns_i2c_probe()
1435 reset_control_assert(id->reset); in cdns_i2c_probe()
1437 clk_disable_unprepare(id->clk); in cdns_i2c_probe()
1438 pm_runtime_disable(&pdev->dev); in cdns_i2c_probe()
1439 pm_runtime_set_suspended(&pdev->dev); in cdns_i2c_probe()
1444 * cdns_i2c_remove - Unregister the device after releasing the resources
1455 pm_runtime_disable(&pdev->dev); in cdns_i2c_remove()
1456 pm_runtime_set_suspended(&pdev->dev); in cdns_i2c_remove()
1457 pm_runtime_dont_use_autosuspend(&pdev->dev); in cdns_i2c_remove()
1459 i2c_del_adapter(&id->adap); in cdns_i2c_remove()
1460 clk_notifier_unregister(id->clk, &id->clk_rate_change_nb); in cdns_i2c_remove()
1461 reset_control_assert(id->reset); in cdns_i2c_remove()
1462 clk_disable_unprepare(id->clk); in cdns_i2c_remove()
1478 MODULE_DESCRIPTION("Cadence I2C bus driver");