Lines Matching +full:mv78230 +full:- +full:i2c
2 * Driver for the i2c controller on the Marvell line of host bridges
16 #include <linux/i2c.h>
61 /* Register defines (I2C bridge) */
182 drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK | in mv64xxx_i2c_prepare_for_io()
185 if (!drv_data->atomic) in mv64xxx_i2c_prepare_for_io()
186 drv_data->cntl_bits |= MV64XXX_I2C_REG_CONTROL_INTEN; in mv64xxx_i2c_prepare_for_io()
188 if (msg->flags & I2C_M_RD) in mv64xxx_i2c_prepare_for_io()
191 if (msg->flags & I2C_M_TEN) { in mv64xxx_i2c_prepare_for_io()
192 drv_data->addr1 = 0xf0 | (((u32)msg->addr & 0x300) >> 7) | dir; in mv64xxx_i2c_prepare_for_io()
193 drv_data->addr2 = (u32)msg->addr & 0xff; in mv64xxx_i2c_prepare_for_io()
195 drv_data->addr1 = MV64XXX_I2C_ADDR_ADDR((u32)msg->addr) | dir; in mv64xxx_i2c_prepare_for_io()
196 drv_data->addr2 = 0; in mv64xxx_i2c_prepare_for_io()
212 if (drv_data->offload_enabled) { in mv64xxx_i2c_hw_init()
213 writel(0, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_CONTROL); in mv64xxx_i2c_hw_init()
214 writel(0, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_TIMING); in mv64xxx_i2c_hw_init()
215 writel(0, drv_data->reg_base + in mv64xxx_i2c_hw_init()
217 writel(0, drv_data->reg_base + in mv64xxx_i2c_hw_init()
221 writel(0, drv_data->reg_base + drv_data->reg_offsets.soft_reset); in mv64xxx_i2c_hw_init()
222 writel(MV64XXX_I2C_BAUD_DIV_M(drv_data->freq_m) | MV64XXX_I2C_BAUD_DIV_N(drv_data->freq_n), in mv64xxx_i2c_hw_init()
223 drv_data->reg_base + drv_data->reg_offsets.clock); in mv64xxx_i2c_hw_init()
224 writel(0, drv_data->reg_base + drv_data->reg_offsets.addr); in mv64xxx_i2c_hw_init()
225 writel(0, drv_data->reg_base + drv_data->reg_offsets.ext_addr); in mv64xxx_i2c_hw_init()
227 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_hw_init()
229 if (drv_data->errata_delay) in mv64xxx_i2c_hw_init()
232 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_hw_init()
243 if (drv_data->state == MV64XXX_I2C_STATE_IDLE) { in mv64xxx_i2c_fsm()
244 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
253 drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_1; in mv64xxx_i2c_fsm()
254 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_ADDR_1_ACK; in mv64xxx_i2c_fsm()
259 if (drv_data->msg->flags & I2C_M_TEN) { in mv64xxx_i2c_fsm()
260 drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_2; in mv64xxx_i2c_fsm()
261 drv_data->state = in mv64xxx_i2c_fsm()
268 if ((drv_data->bytes_left == 0) in mv64xxx_i2c_fsm()
269 || (drv_data->aborting in mv64xxx_i2c_fsm()
270 && (drv_data->byte_posn != 0))) { in mv64xxx_i2c_fsm()
271 if (drv_data->send_stop || drv_data->aborting) { in mv64xxx_i2c_fsm()
272 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
273 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
275 drv_data->action = in mv64xxx_i2c_fsm()
277 drv_data->state = in mv64xxx_i2c_fsm()
281 drv_data->action = MV64XXX_I2C_ACTION_SEND_DATA; in mv64xxx_i2c_fsm()
282 drv_data->state = in mv64xxx_i2c_fsm()
284 drv_data->bytes_left--; in mv64xxx_i2c_fsm()
290 if (drv_data->msg->flags & I2C_M_TEN) { in mv64xxx_i2c_fsm()
291 drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_2; in mv64xxx_i2c_fsm()
292 drv_data->state = in mv64xxx_i2c_fsm()
298 if (drv_data->bytes_left == 0) { in mv64xxx_i2c_fsm()
299 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
300 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
306 drv_data->action = MV64XXX_I2C_ACTION_CONTINUE; in mv64xxx_i2c_fsm()
308 drv_data->action = MV64XXX_I2C_ACTION_RCV_DATA; in mv64xxx_i2c_fsm()
309 drv_data->bytes_left--; in mv64xxx_i2c_fsm()
311 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA; in mv64xxx_i2c_fsm()
313 if ((drv_data->bytes_left == 1) || drv_data->aborting) in mv64xxx_i2c_fsm()
314 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK; in mv64xxx_i2c_fsm()
318 drv_data->action = MV64XXX_I2C_ACTION_RCV_DATA_STOP; in mv64xxx_i2c_fsm()
319 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
326 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
327 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_fsm()
328 drv_data->rc = -ENXIO; in mv64xxx_i2c_fsm()
332 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_fsm()
333 "mv64xxx_i2c_fsm: Ctlr Error -- state: 0x%x, " in mv64xxx_i2c_fsm()
335 drv_data->state, status, drv_data->msg->addr, in mv64xxx_i2c_fsm()
336 drv_data->msg->flags); in mv64xxx_i2c_fsm()
337 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; in mv64xxx_i2c_fsm()
339 i2c_recover_bus(&drv_data->adapter); in mv64xxx_i2c_fsm()
340 drv_data->rc = -EAGAIN; in mv64xxx_i2c_fsm()
346 drv_data->msg = drv_data->msgs; in mv64xxx_i2c_send_start()
347 drv_data->byte_posn = 0; in mv64xxx_i2c_send_start()
348 drv_data->bytes_left = drv_data->msg->len; in mv64xxx_i2c_send_start()
349 drv_data->aborting = 0; in mv64xxx_i2c_send_start()
350 drv_data->rc = 0; in mv64xxx_i2c_send_start()
352 mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); in mv64xxx_i2c_send_start()
353 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START, in mv64xxx_i2c_send_start()
354 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_send_start()
360 switch(drv_data->action) { in mv64xxx_i2c_do_action()
363 BUG_ON(drv_data->num_msgs == 0); in mv64xxx_i2c_do_action()
365 drv_data->msgs++; in mv64xxx_i2c_do_action()
366 drv_data->num_msgs--; in mv64xxx_i2c_do_action()
369 if (drv_data->errata_delay) in mv64xxx_i2c_do_action()
377 drv_data->send_stop = drv_data->num_msgs == 1; in mv64xxx_i2c_do_action()
381 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
382 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
386 writel(drv_data->addr1, in mv64xxx_i2c_do_action()
387 drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
388 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
389 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
393 writel(drv_data->addr2, in mv64xxx_i2c_do_action()
394 drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
395 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
396 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
400 writel(drv_data->msg->buf[drv_data->byte_posn++], in mv64xxx_i2c_do_action()
401 drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
402 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
403 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
407 drv_data->msg->buf[drv_data->byte_posn++] = in mv64xxx_i2c_do_action()
408 readl(drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
409 writel(drv_data->cntl_bits, in mv64xxx_i2c_do_action()
410 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
414 drv_data->msg->buf[drv_data->byte_posn++] = in mv64xxx_i2c_do_action()
415 readl(drv_data->reg_base + drv_data->reg_offsets.data); in mv64xxx_i2c_do_action()
416 if (!drv_data->atomic) in mv64xxx_i2c_do_action()
417 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_INTEN; in mv64xxx_i2c_do_action()
418 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP, in mv64xxx_i2c_do_action()
419 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
420 drv_data->block = 0; in mv64xxx_i2c_do_action()
421 if (drv_data->errata_delay) in mv64xxx_i2c_do_action()
424 wake_up(&drv_data->waitq); in mv64xxx_i2c_do_action()
429 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_do_action()
431 drv_data->action); in mv64xxx_i2c_do_action()
432 drv_data->rc = -EIO; in mv64xxx_i2c_do_action()
435 if (!drv_data->atomic) in mv64xxx_i2c_do_action()
436 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_INTEN; in mv64xxx_i2c_do_action()
437 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP, in mv64xxx_i2c_do_action()
438 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_do_action()
439 drv_data->block = 0; in mv64xxx_i2c_do_action()
440 wake_up(&drv_data->waitq); in mv64xxx_i2c_do_action()
451 buf[0] = readl(drv_data->reg_base + MV64XXX_I2C_REG_RX_DATA_LO); in mv64xxx_i2c_read_offload_rx_data()
452 buf[1] = readl(drv_data->reg_base + MV64XXX_I2C_REG_RX_DATA_HI); in mv64xxx_i2c_read_offload_rx_data()
454 memcpy(msg->buf, buf, msg->len); in mv64xxx_i2c_read_offload_rx_data()
462 cause = readl(drv_data->reg_base + in mv64xxx_i2c_intr_offload()
467 status = readl(drv_data->reg_base + in mv64xxx_i2c_intr_offload()
471 drv_data->rc = -EIO; in mv64xxx_i2c_intr_offload()
475 drv_data->rc = 0; in mv64xxx_i2c_intr_offload()
481 if (drv_data->num_msgs == 1 && drv_data->msgs[0].flags & I2C_M_RD) { in mv64xxx_i2c_intr_offload()
482 mv64xxx_i2c_read_offload_rx_data(drv_data, drv_data->msgs); in mv64xxx_i2c_intr_offload()
483 drv_data->msgs++; in mv64xxx_i2c_intr_offload()
484 drv_data->num_msgs--; in mv64xxx_i2c_intr_offload()
490 else if (drv_data->num_msgs == 2 && in mv64xxx_i2c_intr_offload()
491 !(drv_data->msgs[0].flags & I2C_M_RD) && in mv64xxx_i2c_intr_offload()
492 drv_data->msgs[1].flags & I2C_M_RD) { in mv64xxx_i2c_intr_offload()
493 mv64xxx_i2c_read_offload_rx_data(drv_data, drv_data->msgs + 1); in mv64xxx_i2c_intr_offload()
494 drv_data->msgs += 2; in mv64xxx_i2c_intr_offload()
495 drv_data->num_msgs -= 2; in mv64xxx_i2c_intr_offload()
499 writel(0, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_CONTROL); in mv64xxx_i2c_intr_offload()
500 writel(0, drv_data->reg_base + in mv64xxx_i2c_intr_offload()
502 drv_data->block = 0; in mv64xxx_i2c_intr_offload()
504 wake_up(&drv_data->waitq); in mv64xxx_i2c_intr_offload()
516 spin_lock(&drv_data->lock); in mv64xxx_i2c_intr()
518 if (drv_data->offload_enabled) in mv64xxx_i2c_intr()
521 while (readl(drv_data->reg_base + drv_data->reg_offsets.control) & in mv64xxx_i2c_intr()
531 if (drv_data->atomic) in mv64xxx_i2c_intr()
534 status = readl(drv_data->reg_base + drv_data->reg_offsets.status); in mv64xxx_i2c_intr()
538 if (drv_data->irq_clear_inverted) in mv64xxx_i2c_intr()
539 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_IFLG, in mv64xxx_i2c_intr()
540 drv_data->reg_base + drv_data->reg_offsets.control); in mv64xxx_i2c_intr()
544 spin_unlock(&drv_data->lock); in mv64xxx_i2c_intr()
552 * I2C Msg Execution Routines
563 time_left = wait_event_timeout(drv_data->waitq, in mv64xxx_i2c_wait_for_completion()
564 !drv_data->block, drv_data->adapter.timeout); in mv64xxx_i2c_wait_for_completion()
566 spin_lock_irqsave(&drv_data->lock, flags); in mv64xxx_i2c_wait_for_completion()
568 drv_data->rc = -ETIMEDOUT; in mv64xxx_i2c_wait_for_completion()
571 drv_data->rc = time_left; /* errno value */ in mv64xxx_i2c_wait_for_completion()
575 if (abort && drv_data->block) { in mv64xxx_i2c_wait_for_completion()
576 drv_data->aborting = 1; in mv64xxx_i2c_wait_for_completion()
577 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_wait_for_completion()
579 time_left = wait_event_timeout(drv_data->waitq, in mv64xxx_i2c_wait_for_completion()
580 !drv_data->block, drv_data->adapter.timeout); in mv64xxx_i2c_wait_for_completion()
582 if ((time_left <= 0) && drv_data->block) { in mv64xxx_i2c_wait_for_completion()
583 drv_data->state = MV64XXX_I2C_STATE_IDLE; in mv64xxx_i2c_wait_for_completion()
584 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_wait_for_completion()
585 "mv64xxx: I2C bus locked, block: %d, " in mv64xxx_i2c_wait_for_completion()
586 "time_left: %d\n", drv_data->block, in mv64xxx_i2c_wait_for_completion()
589 i2c_recover_bus(&drv_data->adapter); in mv64xxx_i2c_wait_for_completion()
592 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_wait_for_completion()
597 ktime_t timeout = ktime_add_ms(ktime_get(), drv_data->adapter.timeout); in mv64xxx_i2c_wait_polling()
599 while (READ_ONCE(drv_data->block) && in mv64xxx_i2c_wait_polling()
612 spin_lock_irqsave(&drv_data->lock, flags); in mv64xxx_i2c_execute_msg()
614 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND; in mv64xxx_i2c_execute_msg()
616 drv_data->send_stop = is_last; in mv64xxx_i2c_execute_msg()
617 drv_data->block = 1; in mv64xxx_i2c_execute_msg()
619 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_execute_msg()
621 if (!drv_data->atomic) in mv64xxx_i2c_execute_msg()
626 return drv_data->rc; in mv64xxx_i2c_execute_msg()
632 struct i2c_msg *msg = drv_data->msgs; in mv64xxx_i2c_prepare_tx()
635 memcpy(buf, msg->buf, msg->len); in mv64xxx_i2c_prepare_tx()
637 writel(buf[0], drv_data->reg_base + MV64XXX_I2C_REG_TX_DATA_LO); in mv64xxx_i2c_prepare_tx()
638 writel(buf[1], drv_data->reg_base + MV64XXX_I2C_REG_TX_DATA_HI); in mv64xxx_i2c_prepare_tx()
644 struct i2c_msg *msgs = drv_data->msgs; in mv64xxx_i2c_offload_xfer()
645 int num = drv_data->num_msgs; in mv64xxx_i2c_offload_xfer()
649 spin_lock_irqsave(&drv_data->lock, flags); in mv64xxx_i2c_offload_xfer()
660 size_t len = msgs[0].len - 1; in mv64xxx_i2c_offload_xfer()
668 size_t len = msgs[0].len - 1; in mv64xxx_i2c_offload_xfer()
678 size_t lentx = msgs[0].len - 1; in mv64xxx_i2c_offload_xfer()
679 size_t lenrx = msgs[1].len - 1; in mv64xxx_i2c_offload_xfer()
691 drv_data->block = 1; in mv64xxx_i2c_offload_xfer()
692 writel(ctrl_reg, drv_data->reg_base + MV64XXX_I2C_REG_BRIDGE_CONTROL); in mv64xxx_i2c_offload_xfer()
693 spin_unlock_irqrestore(&drv_data->lock, flags); in mv64xxx_i2c_offload_xfer()
697 return drv_data->rc; in mv64xxx_i2c_offload_xfer()
703 return msg->len <= 8 && msg->len >= 1; in mv64xxx_i2c_valid_offload_sz()
709 struct i2c_msg *msgs = drv_data->msgs; in mv64xxx_i2c_can_offload()
710 int num = drv_data->num_msgs; in mv64xxx_i2c_can_offload()
712 if (!drv_data->offload_enabled) in mv64xxx_i2c_can_offload()
741 * I2C Core Support Routines (Interface to higher level I2C code)
757 rc = pm_runtime_resume_and_get(&adap->dev); in mv64xxx_i2c_xfer_core()
761 BUG_ON(drv_data->msgs != NULL); in mv64xxx_i2c_xfer_core()
762 drv_data->msgs = msgs; in mv64xxx_i2c_xfer_core()
763 drv_data->num_msgs = num; in mv64xxx_i2c_xfer_core()
765 if (mv64xxx_i2c_can_offload(drv_data) && !drv_data->atomic) in mv64xxx_i2c_xfer_core()
773 drv_data->num_msgs = 0; in mv64xxx_i2c_xfer_core()
774 drv_data->msgs = NULL; in mv64xxx_i2c_xfer_core()
776 pm_runtime_mark_last_busy(&adap->dev); in mv64xxx_i2c_xfer_core()
777 pm_runtime_put_autosuspend(&adap->dev); in mv64xxx_i2c_xfer_core()
787 drv_data->atomic = 0; in mv64xxx_i2c_xfer()
796 drv_data->atomic = 1; in mv64xxx_i2c_xfer_atomic()
814 { .compatible = "allwinner,sun4i-a10-i2c", .data = &mv64xxx_i2c_regs_sun4i},
815 { .compatible = "allwinner,sun6i-a31-i2c", .data = &mv64xxx_i2c_regs_sun4i},
816 { .compatible = "marvell,mv64xxx-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
817 { .compatible = "marvell,mv78230-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
818 { .compatible = "marvell,mv78230-a0-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
828 if (drv_data->clk_n_base_0) in mv64xxx_calc_freq()
844 delta = req_freq - freq; in mv64xxx_find_baud_factors()
846 drv_data->freq_m = m; in mv64xxx_find_baud_factors()
847 drv_data->freq_n = n; in mv64xxx_find_baud_factors()
863 struct device_node *np = dev->of_node; in mv64xxx_of_config()
867 /* CLK is mandatory when using DT to describe the i2c bus. We in mv64xxx_of_config()
871 if (!drv_data->clk) { in mv64xxx_of_config()
872 rc = -ENODEV; in mv64xxx_of_config()
875 tclk = clk_get_rate(drv_data->clk); in mv64xxx_of_config()
877 if (of_property_read_u32(np, "clock-frequency", &bus_freq)) in mv64xxx_of_config()
880 if (of_device_is_compatible(np, "allwinner,sun4i-a10-i2c") || in mv64xxx_of_config()
881 of_device_is_compatible(np, "allwinner,sun6i-a31-i2c")) in mv64xxx_of_config()
882 drv_data->clk_n_base_0 = true; in mv64xxx_of_config()
885 rc = -EINVAL; in mv64xxx_of_config()
889 drv_data->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); in mv64xxx_of_config()
890 if (IS_ERR(drv_data->rstc)) { in mv64xxx_of_config()
891 rc = PTR_ERR(drv_data->rstc); in mv64xxx_of_config()
898 drv_data->adapter.timeout = HZ; in mv64xxx_of_config()
902 return -ENODEV; in mv64xxx_of_config()
904 memcpy(&drv_data->reg_offsets, device->data, sizeof(drv_data->reg_offsets)); in mv64xxx_of_config()
910 if (of_device_is_compatible(np, "marvell,mv78230-i2c")) { in mv64xxx_of_config()
911 drv_data->offload_enabled = true; in mv64xxx_of_config()
914 drv_data->errata_delay = true; in mv64xxx_of_config()
917 if (of_device_is_compatible(np, "marvell,mv78230-a0-i2c")) { in mv64xxx_of_config()
918 drv_data->offload_enabled = false; in mv64xxx_of_config()
921 drv_data->errata_delay = true; in mv64xxx_of_config()
924 if (of_device_is_compatible(np, "allwinner,sun6i-a31-i2c")) in mv64xxx_of_config()
925 drv_data->irq_clear_inverted = true; in mv64xxx_of_config()
935 return -ENODEV; in mv64xxx_of_config()
942 struct i2c_bus_recovery_info *rinfo = &drv_data->rinfo; in mv64xxx_i2c_init_recovery_info()
944 rinfo->pinctrl = devm_pinctrl_get(dev); in mv64xxx_i2c_init_recovery_info()
945 if (IS_ERR(rinfo->pinctrl)) { in mv64xxx_i2c_init_recovery_info()
946 if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER) in mv64xxx_i2c_init_recovery_info()
947 return -EPROBE_DEFER; in mv64xxx_i2c_init_recovery_info()
949 return PTR_ERR(rinfo->pinctrl); in mv64xxx_i2c_init_recovery_info()
950 } else if (!rinfo->pinctrl) { in mv64xxx_i2c_init_recovery_info()
951 return -ENODEV; in mv64xxx_i2c_init_recovery_info()
954 drv_data->adapter.bus_recovery_info = rinfo; in mv64xxx_i2c_init_recovery_info()
963 reset_control_assert(drv_data->rstc); in mv64xxx_i2c_runtime_suspend()
964 clk_disable_unprepare(drv_data->reg_clk); in mv64xxx_i2c_runtime_suspend()
965 clk_disable_unprepare(drv_data->clk); in mv64xxx_i2c_runtime_suspend()
975 clk_prepare_enable(drv_data->clk); in mv64xxx_i2c_runtime_resume()
976 clk_prepare_enable(drv_data->reg_clk); in mv64xxx_i2c_runtime_resume()
977 reset_control_reset(drv_data->rstc); in mv64xxx_i2c_runtime_resume()
988 struct mv64xxx_i2c_pdata *pdata = dev_get_platdata(&pd->dev); in mv64xxx_i2c_probe()
991 if ((!pdata && !pd->dev.of_node)) in mv64xxx_i2c_probe()
992 return -ENODEV; in mv64xxx_i2c_probe()
994 drv_data = devm_kzalloc(&pd->dev, sizeof(struct mv64xxx_i2c_data), in mv64xxx_i2c_probe()
997 return -ENOMEM; in mv64xxx_i2c_probe()
999 drv_data->reg_base = devm_platform_ioremap_resource(pd, 0); in mv64xxx_i2c_probe()
1000 if (IS_ERR(drv_data->reg_base)) in mv64xxx_i2c_probe()
1001 return PTR_ERR(drv_data->reg_base); in mv64xxx_i2c_probe()
1003 strscpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", in mv64xxx_i2c_probe()
1004 sizeof(drv_data->adapter.name)); in mv64xxx_i2c_probe()
1006 init_waitqueue_head(&drv_data->waitq); in mv64xxx_i2c_probe()
1007 spin_lock_init(&drv_data->lock); in mv64xxx_i2c_probe()
1010 drv_data->clk = devm_clk_get(&pd->dev, NULL); in mv64xxx_i2c_probe()
1011 if (IS_ERR(drv_data->clk)) { in mv64xxx_i2c_probe()
1012 if (PTR_ERR(drv_data->clk) == -EPROBE_DEFER) in mv64xxx_i2c_probe()
1013 return -EPROBE_DEFER; in mv64xxx_i2c_probe()
1014 drv_data->clk = NULL; in mv64xxx_i2c_probe()
1017 drv_data->reg_clk = devm_clk_get(&pd->dev, "reg"); in mv64xxx_i2c_probe()
1018 if (IS_ERR(drv_data->reg_clk)) { in mv64xxx_i2c_probe()
1019 if (PTR_ERR(drv_data->reg_clk) == -EPROBE_DEFER) in mv64xxx_i2c_probe()
1020 return -EPROBE_DEFER; in mv64xxx_i2c_probe()
1021 drv_data->reg_clk = NULL; in mv64xxx_i2c_probe()
1024 drv_data->irq = platform_get_irq(pd, 0); in mv64xxx_i2c_probe()
1025 if (drv_data->irq < 0) in mv64xxx_i2c_probe()
1026 return drv_data->irq; in mv64xxx_i2c_probe()
1029 drv_data->freq_m = pdata->freq_m; in mv64xxx_i2c_probe()
1030 drv_data->freq_n = pdata->freq_n; in mv64xxx_i2c_probe()
1031 drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout); in mv64xxx_i2c_probe()
1032 drv_data->offload_enabled = false; in mv64xxx_i2c_probe()
1033 memcpy(&drv_data->reg_offsets, &mv64xxx_i2c_regs_mv64xxx, sizeof(drv_data->reg_offsets)); in mv64xxx_i2c_probe()
1034 } else if (pd->dev.of_node) { in mv64xxx_i2c_probe()
1035 rc = mv64xxx_of_config(drv_data, &pd->dev); in mv64xxx_i2c_probe()
1040 rc = mv64xxx_i2c_init_recovery_info(drv_data, &pd->dev); in mv64xxx_i2c_probe()
1041 if (rc == -EPROBE_DEFER) in mv64xxx_i2c_probe()
1044 drv_data->adapter.dev.parent = &pd->dev; in mv64xxx_i2c_probe()
1045 drv_data->adapter.algo = &mv64xxx_i2c_algo; in mv64xxx_i2c_probe()
1046 drv_data->adapter.owner = THIS_MODULE; in mv64xxx_i2c_probe()
1047 drv_data->adapter.class = I2C_CLASS_DEPRECATED; in mv64xxx_i2c_probe()
1048 drv_data->adapter.nr = pd->id; in mv64xxx_i2c_probe()
1049 drv_data->adapter.dev.of_node = pd->dev.of_node; in mv64xxx_i2c_probe()
1051 i2c_set_adapdata(&drv_data->adapter, drv_data); in mv64xxx_i2c_probe()
1053 pm_runtime_set_autosuspend_delay(&pd->dev, MSEC_PER_SEC); in mv64xxx_i2c_probe()
1054 pm_runtime_use_autosuspend(&pd->dev); in mv64xxx_i2c_probe()
1055 pm_runtime_enable(&pd->dev); in mv64xxx_i2c_probe()
1056 if (!pm_runtime_enabled(&pd->dev)) { in mv64xxx_i2c_probe()
1057 rc = mv64xxx_i2c_runtime_resume(&pd->dev); in mv64xxx_i2c_probe()
1062 rc = request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, in mv64xxx_i2c_probe()
1065 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_probe()
1067 drv_data->irq, rc); in mv64xxx_i2c_probe()
1069 } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) { in mv64xxx_i2c_probe()
1070 dev_err(&drv_data->adapter.dev, in mv64xxx_i2c_probe()
1071 "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); in mv64xxx_i2c_probe()
1078 free_irq(drv_data->irq, drv_data); in mv64xxx_i2c_probe()
1080 pm_runtime_disable(&pd->dev); in mv64xxx_i2c_probe()
1081 if (!pm_runtime_status_suspended(&pd->dev)) in mv64xxx_i2c_probe()
1082 mv64xxx_i2c_runtime_suspend(&pd->dev); in mv64xxx_i2c_probe()
1092 i2c_del_adapter(&drv_data->adapter); in mv64xxx_i2c_remove()
1093 free_irq(drv_data->irq, drv_data); in mv64xxx_i2c_remove()
1094 pm_runtime_disable(&pd->dev); in mv64xxx_i2c_remove()
1095 if (!pm_runtime_status_suspended(&pd->dev)) in mv64xxx_i2c_remove()
1096 mv64xxx_i2c_runtime_suspend(&pd->dev); in mv64xxx_i2c_remove()
1119 MODULE_DESCRIPTION("Marvell mv64xxx host bridge i2c ctlr driver");