Lines Matching +full:mv64xxx +full:- +full:i2c
2 * Driver for the i2c controller on the Marvell line of host bridges
16 #include <linux/i2c.h>
59 /* Register defines (I2C bridge) */
178 drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK | in mv64xxx_i2c_prepare_for_io()
181 if (msg->flags & I2C_M_RD) in mv64xxx_i2c_prepare_for_io()
184 if (msg->flags & I2C_M_TEN) { in mv64xxx_i2c_prepare_for_io()
185 drv_data->addr1 = 0xf0 | (((u32)msg->addr & 0x300) >> 7) | dir; in mv64xxx_i2c_prepare_for_io()
186 drv_data->addr2 = (u32)msg->addr & 0xff; in mv64xxx_i2c_prepare_for_io()
188 drv_data->addr1 = MV64XXX_I2C_ADDR_ADDR((u32)msg->addr) | dir; in mv64xxx_i2c_prepare_for_io()
189 drv_data->addr2 = 0; in mv64xxx_i2c_prepare_for_io()
205 if (drv_data->offload_enabled) { in mv64xxx_i2c_hw_init()
206 writel(0, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_CONTROL); in mv64xxx_i2c_hw_init()
207 writel(0, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_TIMING); in mv64xxx_i2c_hw_init()
208 writel(0, drv_data->reg_base + in mv64xxx_i2c_hw_init()
210 writel(0, drv_data->reg_base + in mv64xxx_i2c_hw_init()
214 writel(0, drv_data->reg_base + drv_data->reg_offsets.soft_reset); in mv64xxx_i2c_hw_init()
215 writel(MV64XXX_I2C_BAUD_DIV_M(drv_data->freq_m) | MV64XXX_I2C_BAUD_DIV_N(drv_data->freq_n), in mv64xxx_i2c_hw_init()
216 drv_data->reg_base + drv_data->reg_offsets.clock); in mv64xxx_i2c_hw_init()
217 writel(0, drv_data->reg_base + drv_data->reg_offsets.addr); in mv64xxx_i2c_hw_init()
218 writel(0, drv_data->reg_base + drv_data->reg_offsets.ext_addr); in mv64xxx_i2c_hw_init()
220 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_hw_init()
221 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_hw_init()
232 if (drv_data->state == MV64XXX_I2C_STATE_IDLE) { in mv64xxx_i2c_fsm()
233 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
242 drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_1; in mv64xxx_i2c_fsm()
243 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_ADDR_1_ACK; in mv64xxx_i2c_fsm()
248 if (drv_data->msg->flags & I2C_M_TEN) { in mv64xxx_i2c_fsm()
249 drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_2; in mv64xxx_i2c_fsm()
250 drv_data->state = in mv64xxx_i2c_fsm()
257 if ((drv_data->bytes_left == 0) in mv64xxx_i2c_fsm()
258 || (drv_data->aborting in mv64xxx_i2c_fsm()
259 && (drv_data->byte_posn != 0))) { in mv64xxx_i2c_fsm()
260 if (drv_data->send_stop || drv_data->aborting) { in mv64xxx_i2c_fsm()
261 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
262 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
264 drv_data->action = in mv64xxx_i2c_fsm()
266 drv_data->state = in mv64xxx_i2c_fsm()
270 drv_data->action = MV64XXX_I2C_ACTION_SEND_DATA; in mv64xxx_i2c_fsm()
271 drv_data->state = in mv64xxx_i2c_fsm()
273 drv_data->bytes_left--; in mv64xxx_i2c_fsm()
279 if (drv_data->msg->flags & I2C_M_TEN) { in mv64xxx_i2c_fsm()
280 drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_2; in mv64xxx_i2c_fsm()
281 drv_data->state = in mv64xxx_i2c_fsm()
287 if (drv_data->bytes_left == 0) { in mv64xxx_i2c_fsm()
288 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
289 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
295 drv_data->action = MV64XXX_I2C_ACTION_CONTINUE; in mv64xxx_i2c_fsm()
297 drv_data->action = MV64XXX_I2C_ACTION_RCV_DATA; in mv64xxx_i2c_fsm()
298 drv_data->bytes_left--; in mv64xxx_i2c_fsm()
300 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA; in mv64xxx_i2c_fsm()
302 if ((drv_data->bytes_left == 1) || drv_data->aborting) in mv64xxx_i2c_fsm()
303 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK; in mv64xxx_i2c_fsm()
307 drv_data->action = MV64XXX_I2C_ACTION_RCV_DATA_STOP; in mv64xxx_i2c_fsm()
308 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
315 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
316 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
317 drv_data->rc = -ENXIO; in mv64xxx_i2c_fsm()
321 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_fsm()
322 "mv64xxx_i2c_fsm: Ctlr Error -- state: 0x%x, " in mv64xxx_i2c_fsm()
324 drv_data->state, status, drv_data->msg->addr, in mv64xxx_i2c_fsm()
325 drv_data->msg->flags); in mv64xxx_i2c_fsm()
326 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
328 drv_data->rc = -EIO; in mv64xxx_i2c_fsm()
334 drv_data->msg = drv_data->msgs; in mv64xxx_i2c_send_start()
335 drv_data->byte_posn = 0; in mv64xxx_i2c_send_start()
336 drv_data->bytes_left = drv_data->msg->len; in mv64xxx_i2c_send_start()
337 drv_data->aborting = 0; in mv64xxx_i2c_send_start()
338 drv_data->rc = 0; in mv64xxx_i2c_send_start()
340 mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); in mv64xxx_i2c_send_start()
341 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START, in mv64xxx_i2c_send_start()
342 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_send_start()
348 switch(drv_data->action) { in mv64xxx_i2c_do_action()
351 BUG_ON(drv_data->num_msgs == 0); in mv64xxx_i2c_do_action()
353 drv_data->msgs++; in mv64xxx_i2c_do_action()
354 drv_data->num_msgs--; in mv64xxx_i2c_do_action()
357 if (drv_data->errata_delay) in mv64xxx_i2c_do_action()
365 drv_data->send_stop = drv_data->num_msgs == 1; in mv64xxx_i2c_do_action()
369 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
370 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
374 writel(drv_data->addr1, in mv64xxx_i2c_do_action()
375 drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
376 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
377 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
381 writel(drv_data->addr2, in mv64xxx_i2c_do_action()
382 drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
383 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
384 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
388 writel(drv_data->msg->buf[drv_data->byte_posn++], in mv64xxx_i2c_do_action()
389 drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
390 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
391 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
395 drv_data->msg->buf[drv_data->byte_posn++] = in mv64xxx_i2c_do_action()
396 readl(drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
397 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
398 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
402 drv_data->msg->buf[drv_data->byte_posn++] = in mv64xxx_i2c_do_action()
403 readl(drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
404 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_INTEN; in mv64xxx_i2c_do_action()
405 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP, in mv64xxx_i2c_do_action()
406 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
407 drv_data->block = 0; in mv64xxx_i2c_do_action()
408 if (drv_data->errata_delay) in mv64xxx_i2c_do_action()
411 wake_up(&drv_data->waitq); in mv64xxx_i2c_do_action()
416 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_do_action()
418 drv_data->action); in mv64xxx_i2c_do_action()
419 drv_data->rc = -EIO; in mv64xxx_i2c_do_action()
422 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_INTEN; in mv64xxx_i2c_do_action()
423 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP, in mv64xxx_i2c_do_action()
424 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
425 drv_data->block = 0; in mv64xxx_i2c_do_action()
426 wake_up(&drv_data->waitq); in mv64xxx_i2c_do_action()
437 buf[0] = readl(drv_data->reg_base + MV64XXX_I2C_REG_RX_DATA_LO); in mv64xxx_i2c_read_offload_rx_data()
438 buf[1] = readl(drv_data->reg_base + MV64XXX_I2C_REG_RX_DATA_HI); in mv64xxx_i2c_read_offload_rx_data()
440 memcpy(msg->buf, buf, msg->len); in mv64xxx_i2c_read_offload_rx_data()
448 cause = readl(drv_data->reg_base + in mv64xxx_i2c_intr_offload()
453 status = readl(drv_data->reg_base + in mv64xxx_i2c_intr_offload()
457 drv_data->rc = -EIO; in mv64xxx_i2c_intr_offload()
461 drv_data->rc = 0; in mv64xxx_i2c_intr_offload()
467 if (drv_data->num_msgs == 1 && drv_data->msgs[0].flags & I2C_M_RD) { in mv64xxx_i2c_intr_offload()
468 mv64xxx_i2c_read_offload_rx_data(drv_data, drv_data->msgs); in mv64xxx_i2c_intr_offload()
469 drv_data->msgs++; in mv64xxx_i2c_intr_offload()
470 drv_data->num_msgs--; in mv64xxx_i2c_intr_offload()
476 else if (drv_data->num_msgs == 2 && in mv64xxx_i2c_intr_offload()
477 !(drv_data->msgs[0].flags & I2C_M_RD) && in mv64xxx_i2c_intr_offload()
478 drv_data->msgs[1].flags & I2C_M_RD) { in mv64xxx_i2c_intr_offload()
479 mv64xxx_i2c_read_offload_rx_data(drv_data, drv_data->msgs + 1); in mv64xxx_i2c_intr_offload()
480 drv_data->msgs += 2; in mv64xxx_i2c_intr_offload()
481 drv_data->num_msgs -= 2; in mv64xxx_i2c_intr_offload()
485 writel(0, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_CONTROL); in mv64xxx_i2c_intr_offload()
486 writel(0, drv_data->reg_base + in mv64xxx_i2c_intr_offload()
488 drv_data->block = 0; in mv64xxx_i2c_intr_offload()
490 wake_up(&drv_data->waitq); in mv64xxx_i2c_intr_offload()
502 spin_lock(&drv_data->lock); in mv64xxx_i2c_intr()
504 if (drv_data->offload_enabled) in mv64xxx_i2c_intr()
507 while (readl(drv_data->reg_base + drv_data->reg_offsets.control) & in mv64xxx_i2c_intr()
509 status = readl(drv_data->reg_base + drv_data->reg_offsets.status); in mv64xxx_i2c_intr()
513 if (drv_data->irq_clear_inverted) in mv64xxx_i2c_intr()
514 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_IFLG, in mv64xxx_i2c_intr()
515 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_intr()
519 spin_unlock(&drv_data->lock); in mv64xxx_i2c_intr()
527 * I2C Msg Execution Routines
538 time_left = wait_event_timeout(drv_data->waitq, in mv64xxx_i2c_wait_for_completion()
539 !drv_data->block, drv_data->adapter.timeout); in mv64xxx_i2c_wait_for_completion()
541 spin_lock_irqsave(&drv_data->lock, flags); in mv64xxx_i2c_wait_for_completion()
543 drv_data->rc = -ETIMEDOUT; in mv64xxx_i2c_wait_for_completion()
546 drv_data->rc = time_left; /* errno value */ in mv64xxx_i2c_wait_for_completion()
550 if (abort && drv_data->block) { in mv64xxx_i2c_wait_for_completion()
551 drv_data->aborting = 1; in mv64xxx_i2c_wait_for_completion()
552 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_wait_for_completion()
554 time_left = wait_event_timeout(drv_data->waitq, in mv64xxx_i2c_wait_for_completion()
555 !drv_data->block, drv_data->adapter.timeout); in mv64xxx_i2c_wait_for_completion()
557 if ((time_left <= 0) && drv_data->block) { in mv64xxx_i2c_wait_for_completion()
558 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_wait_for_completion()
559 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_wait_for_completion()
560 "mv64xxx: I2C bus locked, block: %d, " in mv64xxx_i2c_wait_for_completion()
561 "time_left: %d\n", drv_data->block, in mv64xxx_i2c_wait_for_completion()
566 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_wait_for_completion()
575 spin_lock_irqsave(&drv_data->lock, flags); in mv64xxx_i2c_execute_msg()
577 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND; in mv64xxx_i2c_execute_msg()
579 drv_data->send_stop = is_last; in mv64xxx_i2c_execute_msg()
580 drv_data->block = 1; in mv64xxx_i2c_execute_msg()
582 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_execute_msg()
585 return drv_data->rc; in mv64xxx_i2c_execute_msg()
591 struct i2c_msg *msg = drv_data->msgs; in mv64xxx_i2c_prepare_tx()
594 memcpy(buf, msg->buf, msg->len); in mv64xxx_i2c_prepare_tx()
596 writel(buf[0], drv_data->reg_base + MV64XXX_I2C_REG_TX_DATA_LO); in mv64xxx_i2c_prepare_tx()
597 writel(buf[1], drv_data->reg_base + MV64XXX_I2C_REG_TX_DATA_HI); in mv64xxx_i2c_prepare_tx()
603 struct i2c_msg *msgs = drv_data->msgs; in mv64xxx_i2c_offload_xfer()
604 int num = drv_data->num_msgs; in mv64xxx_i2c_offload_xfer()
608 spin_lock_irqsave(&drv_data->lock, flags); in mv64xxx_i2c_offload_xfer()
619 size_t len = msgs[0].len - 1; in mv64xxx_i2c_offload_xfer()
627 size_t len = msgs[0].len - 1; in mv64xxx_i2c_offload_xfer()
637 size_t lentx = msgs[0].len - 1; in mv64xxx_i2c_offload_xfer()
638 size_t lenrx = msgs[1].len - 1; in mv64xxx_i2c_offload_xfer()
650 drv_data->block = 1; in mv64xxx_i2c_offload_xfer()
651 writel(ctrl_reg, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_CONTROL); in mv64xxx_i2c_offload_xfer()
652 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_offload_xfer()
656 return drv_data->rc; in mv64xxx_i2c_offload_xfer()
662 return msg->len <= 8 && msg->len >= 1; in mv64xxx_i2c_valid_offload_sz()
668 struct i2c_msg *msgs = drv_data->msgs; in mv64xxx_i2c_can_offload()
669 int num = drv_data->num_msgs; in mv64xxx_i2c_can_offload()
671 if (!drv_data->offload_enabled) in mv64xxx_i2c_can_offload()
700 * I2C Core Support Routines (Interface to higher level I2C code)
716 BUG_ON(drv_data->msgs != NULL); in mv64xxx_i2c_xfer()
717 drv_data->msgs = msgs; in mv64xxx_i2c_xfer()
718 drv_data->num_msgs = num; in mv64xxx_i2c_xfer()
728 drv_data->num_msgs = 0; in mv64xxx_i2c_xfer()
729 drv_data->msgs = NULL; in mv64xxx_i2c_xfer()
747 { .compatible = "allwinner,sun4i-a10-i2c", .data = &mv64xxx_i2c_regs_sun4i},
748 { .compatible = "allwinner,sun6i-a31-i2c", .data = &mv64xxx_i2c_regs_sun4i},
749 { .compatible = "marvell,mv64xxx-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
750 { .compatible = "marvell,mv78230-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
751 { .compatible = "marvell,mv78230-a0-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
761 if (drv_data->clk_n_base_0) in mv64xxx_calc_freq()
777 delta = req_freq - freq; in mv64xxx_find_baud_factors()
779 drv_data->freq_m = m; in mv64xxx_find_baud_factors()
780 drv_data->freq_n = n; in mv64xxx_find_baud_factors()
796 struct device_node *np = dev->of_node; in mv64xxx_of_config()
800 /* CLK is mandatory when using DT to describe the i2c bus. We in mv64xxx_of_config()
804 if (IS_ERR(drv_data->clk)) { in mv64xxx_of_config()
805 rc = -ENODEV; in mv64xxx_of_config()
808 tclk = clk_get_rate(drv_data->clk); in mv64xxx_of_config()
810 if (of_property_read_u32(np, "clock-frequency", &bus_freq)) in mv64xxx_of_config()
813 if (of_device_is_compatible(np, "allwinner,sun4i-a10-i2c") || in mv64xxx_of_config()
814 of_device_is_compatible(np, "allwinner,sun6i-a31-i2c")) in mv64xxx_of_config()
815 drv_data->clk_n_base_0 = true; in mv64xxx_of_config()
818 rc = -EINVAL; in mv64xxx_of_config()
822 drv_data->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); in mv64xxx_of_config()
823 if (IS_ERR(drv_data->rstc)) { in mv64xxx_of_config()
824 rc = PTR_ERR(drv_data->rstc); in mv64xxx_of_config()
827 reset_control_deassert(drv_data->rstc); in mv64xxx_of_config()
832 drv_data->adapter.timeout = HZ; in mv64xxx_of_config()
836 return -ENODEV; in mv64xxx_of_config()
838 memcpy(&drv_data->reg_offsets, device->data, sizeof(drv_data->reg_offsets)); in mv64xxx_of_config()
844 if (of_device_is_compatible(np, "marvell,mv78230-i2c")) { in mv64xxx_of_config()
845 drv_data->offload_enabled = true; in mv64xxx_of_config()
848 drv_data->errata_delay = true; in mv64xxx_of_config()
851 if (of_device_is_compatible(np, "marvell,mv78230-a0-i2c")) { in mv64xxx_of_config()
852 drv_data->offload_enabled = false; in mv64xxx_of_config()
855 drv_data->errata_delay = true; in mv64xxx_of_config()
858 if (of_device_is_compatible(np, "allwinner,sun6i-a31-i2c")) in mv64xxx_of_config()
859 drv_data->irq_clear_inverted = true; in mv64xxx_of_config()
869 return -ENODEV; in mv64xxx_of_config()
877 struct mv64xxx_i2c_pdata *pdata = dev_get_platdata(&pd->dev); in mv64xxx_i2c_probe()
880 if ((!pdata && !pd->dev.of_node)) in mv64xxx_i2c_probe()
881 return -ENODEV; in mv64xxx_i2c_probe()
883 drv_data = devm_kzalloc(&pd->dev, sizeof(struct mv64xxx_i2c_data), in mv64xxx_i2c_probe()
886 return -ENOMEM; in mv64xxx_i2c_probe()
888 drv_data->reg_base = devm_platform_ioremap_resource(pd, 0); in mv64xxx_i2c_probe()
889 if (IS_ERR(drv_data->reg_base)) in mv64xxx_i2c_probe()
890 return PTR_ERR(drv_data->reg_base); in mv64xxx_i2c_probe()
892 strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", in mv64xxx_i2c_probe()
893 sizeof(drv_data->adapter.name)); in mv64xxx_i2c_probe()
895 init_waitqueue_head(&drv_data->waitq); in mv64xxx_i2c_probe()
896 spin_lock_init(&drv_data->lock); in mv64xxx_i2c_probe()
899 drv_data->clk = devm_clk_get(&pd->dev, NULL); in mv64xxx_i2c_probe()
900 if (PTR_ERR(drv_data->clk) == -EPROBE_DEFER) in mv64xxx_i2c_probe()
901 return -EPROBE_DEFER; in mv64xxx_i2c_probe()
902 if (!IS_ERR(drv_data->clk)) in mv64xxx_i2c_probe()
903 clk_prepare_enable(drv_data->clk); in mv64xxx_i2c_probe()
905 drv_data->reg_clk = devm_clk_get(&pd->dev, "reg"); in mv64xxx_i2c_probe()
906 if (PTR_ERR(drv_data->reg_clk) == -EPROBE_DEFER) in mv64xxx_i2c_probe()
907 return -EPROBE_DEFER; in mv64xxx_i2c_probe()
908 if (!IS_ERR(drv_data->reg_clk)) in mv64xxx_i2c_probe()
909 clk_prepare_enable(drv_data->reg_clk); in mv64xxx_i2c_probe()
911 drv_data->irq = platform_get_irq(pd, 0); in mv64xxx_i2c_probe()
914 drv_data->freq_m = pdata->freq_m; in mv64xxx_i2c_probe()
915 drv_data->freq_n = pdata->freq_n; in mv64xxx_i2c_probe()
916 drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout); in mv64xxx_i2c_probe()
917 drv_data->offload_enabled = false; in mv64xxx_i2c_probe()
918 memcpy(&drv_data->reg_offsets, &mv64xxx_i2c_regs_mv64xxx, sizeof(drv_data->reg_offsets)); in mv64xxx_i2c_probe()
919 } else if (pd->dev.of_node) { in mv64xxx_i2c_probe()
920 rc = mv64xxx_of_config(drv_data, &pd->dev); in mv64xxx_i2c_probe()
924 if (drv_data->irq < 0) { in mv64xxx_i2c_probe()
925 rc = drv_data->irq; in mv64xxx_i2c_probe()
929 drv_data->adapter.dev.parent = &pd->dev; in mv64xxx_i2c_probe()
930 drv_data->adapter.algo = &mv64xxx_i2c_algo; in mv64xxx_i2c_probe()
931 drv_data->adapter.owner = THIS_MODULE; in mv64xxx_i2c_probe()
932 drv_data->adapter.class = I2C_CLASS_DEPRECATED; in mv64xxx_i2c_probe()
933 drv_data->adapter.nr = pd->id; in mv64xxx_i2c_probe()
934 drv_data->adapter.dev.of_node = pd->dev.of_node; in mv64xxx_i2c_probe()
936 i2c_set_adapdata(&drv_data->adapter, drv_data); in mv64xxx_i2c_probe()
940 rc = request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, in mv64xxx_i2c_probe()
943 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_probe()
944 "mv64xxx: Can't register intr handler irq%d: %d\n", in mv64xxx_i2c_probe()
945 drv_data->irq, rc); in mv64xxx_i2c_probe()
947 } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) { in mv64xxx_i2c_probe()
948 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_probe()
949 "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); in mv64xxx_i2c_probe()
956 free_irq(drv_data->irq, drv_data); in mv64xxx_i2c_probe()
958 reset_control_assert(drv_data->rstc); in mv64xxx_i2c_probe()
960 clk_disable_unprepare(drv_data->reg_clk); in mv64xxx_i2c_probe()
961 clk_disable_unprepare(drv_data->clk); in mv64xxx_i2c_probe()
971 i2c_del_adapter(&drv_data->adapter); in mv64xxx_i2c_remove()
972 free_irq(drv_data->irq, drv_data); in mv64xxx_i2c_remove()
973 reset_control_assert(drv_data->rstc); in mv64xxx_i2c_remove()
974 clk_disable_unprepare(drv_data->reg_clk); in mv64xxx_i2c_remove()
975 clk_disable_unprepare(drv_data->clk); in mv64xxx_i2c_remove()
1012 MODULE_DESCRIPTION("Marvell mv64xxx host bridge i2c ctlr driver");