Lines Matching full:bus

172 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus);
174 static int aspeed_i2c_recover_bus(struct aspeed_i2c_bus *bus) in aspeed_i2c_recover_bus() argument
180 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
181 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
184 /* Bus is idle: no recovery needed. */ in aspeed_i2c_recover_bus()
187 dev_dbg(bus->dev, "SCL hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
190 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
191 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
192 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
195 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
197 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
200 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
203 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
206 /* Bus error. */ in aspeed_i2c_recover_bus()
208 dev_dbg(bus->dev, "SDA hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
211 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
214 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
215 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
218 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
220 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
223 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
226 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
232 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
237 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
239 return aspeed_i2c_reset(bus); in aspeed_i2c_recover_bus()
243 static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_slave_irq() argument
246 struct i2c_client *slave = bus->slave; in aspeed_i2c_slave_irq()
252 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
257 bus->slave_state = ASPEED_I2C_SLAVE_START; in aspeed_i2c_slave_irq()
261 if (bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_slave_irq()
264 dev_dbg(bus->dev, "slave irq status 0x%08x, cmd 0x%08x\n", in aspeed_i2c_slave_irq()
269 value = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_slave_irq()
271 if (bus->slave_state == ASPEED_I2C_SLAVE_START) { in aspeed_i2c_slave_irq()
273 bus->slave_state = in aspeed_i2c_slave_irq()
276 bus->slave_state = in aspeed_i2c_slave_irq()
285 bus->slave_state = ASPEED_I2C_SLAVE_STOP; in aspeed_i2c_slave_irq()
288 bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { in aspeed_i2c_slave_irq()
290 bus->slave_state = ASPEED_I2C_SLAVE_STOP; in aspeed_i2c_slave_irq()
293 switch (bus->slave_state) { in aspeed_i2c_slave_irq()
296 dev_err(bus->dev, "Unexpected ACK on read request.\n"); in aspeed_i2c_slave_irq()
297 bus->slave_state = ASPEED_I2C_SLAVE_READ_PROCESSED; in aspeed_i2c_slave_irq()
299 writel(value, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_slave_irq()
300 writel(ASPEED_I2CD_S_TX_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
304 dev_err(bus->dev, in aspeed_i2c_slave_irq()
310 writel(value, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_slave_irq()
311 writel(ASPEED_I2CD_S_TX_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
314 bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED; in aspeed_i2c_slave_irq()
322 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
328 dev_err(bus->dev, "unknown slave_state: %d\n", in aspeed_i2c_slave_irq()
329 bus->slave_state); in aspeed_i2c_slave_irq()
330 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
338 /* precondition: bus.lock has been acquired. */
339 static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_start() argument
342 struct i2c_msg *msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_do_start()
349 * command when the bus comes back to the idle state. in aspeed_i2c_do_start()
351 if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) { in aspeed_i2c_do_start()
352 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_do_start()
357 bus->master_state = ASPEED_I2C_MASTER_START; in aspeed_i2c_do_start()
358 bus->buf_index = 0; in aspeed_i2c_do_start()
367 writel(slave_addr, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_do_start()
368 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_start()
371 /* precondition: bus.lock has been acquired. */
372 static void aspeed_i2c_do_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_stop() argument
374 bus->master_state = ASPEED_I2C_MASTER_STOP; in aspeed_i2c_do_stop()
375 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_stop()
378 /* precondition: bus.lock has been acquired. */
379 static void aspeed_i2c_next_msg_or_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_next_msg_or_stop() argument
381 if (bus->msgs_index + 1 < bus->msgs_count) { in aspeed_i2c_next_msg_or_stop()
382 bus->msgs_index++; in aspeed_i2c_next_msg_or_stop()
383 aspeed_i2c_do_start(bus); in aspeed_i2c_next_msg_or_stop()
385 aspeed_i2c_do_stop(bus); in aspeed_i2c_next_msg_or_stop()
402 static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_master_irq() argument
410 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
422 dev_dbg(bus->dev, "received error interrupt: 0x%08x\n", in aspeed_i2c_master_irq()
425 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE) { in aspeed_i2c_master_irq()
426 bus->cmd_err = ret; in aspeed_i2c_master_irq()
427 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
433 if (bus->master_state == ASPEED_I2C_MASTER_INACTIVE || in aspeed_i2c_master_irq()
434 bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_irq()
437 /* We are in an invalid state; reset bus to a known state. */ in aspeed_i2c_master_irq()
438 if (!bus->msgs) { in aspeed_i2c_master_irq()
439 dev_err(bus->dev, "bus in unknown state. irq_status: 0x%x\n", in aspeed_i2c_master_irq()
441 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
442 if (bus->master_state != ASPEED_I2C_MASTER_STOP && in aspeed_i2c_master_irq()
443 bus->master_state != ASPEED_I2C_MASTER_INACTIVE) in aspeed_i2c_master_irq()
444 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
447 msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_master_irq()
454 if (bus->master_state == ASPEED_I2C_MASTER_START) { in aspeed_i2c_master_irq()
464 writel(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_irq()
466 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
467 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_master_irq()
468 dev_dbg(bus->dev, in aspeed_i2c_master_irq()
475 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
476 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
481 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
482 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
487 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
491 bus->master_state = ASPEED_I2C_MASTER_RX_FIRST; in aspeed_i2c_master_irq()
493 bus->master_state = ASPEED_I2C_MASTER_TX_FIRST; in aspeed_i2c_master_irq()
496 switch (bus->master_state) { in aspeed_i2c_master_irq()
499 dev_dbg(bus->dev, "slave NACKed TX\n"); in aspeed_i2c_master_irq()
503 dev_err(bus->dev, "slave failed to ACK TX\n"); in aspeed_i2c_master_irq()
509 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
510 bus->master_state = ASPEED_I2C_MASTER_TX; in aspeed_i2c_master_irq()
511 writel(msg->buf[bus->buf_index++], in aspeed_i2c_master_irq()
512 bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_master_irq()
514 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
516 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
526 dev_err(bus->dev, "master failed to RX\n"); in aspeed_i2c_master_irq()
531 recv_byte = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_master_irq()
532 msg->buf[bus->buf_index++] = recv_byte; in aspeed_i2c_master_irq()
536 bus->cmd_err = -EPROTO; in aspeed_i2c_master_irq()
537 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
545 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
546 bus->master_state = ASPEED_I2C_MASTER_RX; in aspeed_i2c_master_irq()
548 if (bus->buf_index + 1 == msg->len) in aspeed_i2c_master_irq()
550 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
552 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
557 dev_err(bus->dev, in aspeed_i2c_master_irq()
560 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
566 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
569 dev_err(bus->dev, in aspeed_i2c_master_irq()
572 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
577 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
578 bus->cmd_err = -EINVAL; in aspeed_i2c_master_irq()
582 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
583 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
586 bus->msgs = NULL; in aspeed_i2c_master_irq()
587 if (bus->cmd_err) in aspeed_i2c_master_irq()
588 bus->master_xfer_result = bus->cmd_err; in aspeed_i2c_master_irq()
590 bus->master_xfer_result = bus->msgs_index + 1; in aspeed_i2c_master_irq()
591 complete(&bus->cmd_complete); in aspeed_i2c_master_irq()
598 struct aspeed_i2c_bus *bus = dev_id; in aspeed_i2c_bus_irq() local
601 spin_lock(&bus->lock); in aspeed_i2c_bus_irq()
602 irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
605 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
616 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE && in aspeed_i2c_bus_irq()
617 bus->master_state != ASPEED_I2C_MASTER_PENDING) { in aspeed_i2c_bus_irq()
618 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
621 irq_handled |= aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
623 irq_handled = aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
626 irq_handled |= aspeed_i2c_master_irq(bus, in aspeed_i2c_bus_irq()
634 if (bus->master_state == ASPEED_I2C_MASTER_PENDING && in aspeed_i2c_bus_irq()
635 bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_bus_irq()
636 aspeed_i2c_do_start(bus); in aspeed_i2c_bus_irq()
638 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
643 dev_err(bus->dev, in aspeed_i2c_bus_irq()
650 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
651 spin_unlock(&bus->lock); in aspeed_i2c_bus_irq()
658 struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap); in aspeed_i2c_master_xfer() local
661 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
662 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
664 /* If bus is busy in a single master environment, attempt recovery. */ in aspeed_i2c_master_xfer()
665 if (!bus->multi_master && in aspeed_i2c_master_xfer()
666 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
670 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
671 ret = aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
674 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
677 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
678 bus->msgs = msgs; in aspeed_i2c_master_xfer()
679 bus->msgs_index = 0; in aspeed_i2c_master_xfer()
680 bus->msgs_count = num; in aspeed_i2c_master_xfer()
682 reinit_completion(&bus->cmd_complete); in aspeed_i2c_master_xfer()
683 aspeed_i2c_do_start(bus); in aspeed_i2c_master_xfer()
684 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
686 time_left = wait_for_completion_timeout(&bus->cmd_complete, in aspeed_i2c_master_xfer()
687 bus->adap.timeout); in aspeed_i2c_master_xfer()
691 * If timed out and bus is still busy in a multi master in aspeed_i2c_master_xfer()
694 if (bus->multi_master && in aspeed_i2c_master_xfer()
695 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
697 aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
703 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
704 if (bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_xfer()
705 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_xfer()
706 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
711 return bus->master_xfer_result; in aspeed_i2c_master_xfer()
720 /* precondition: bus.lock has been acquired. */
721 static void __aspeed_i2c_reg_slave(struct aspeed_i2c_bus *bus, u16 slave_addr) in __aspeed_i2c_reg_slave() argument
726 addr_reg_val = readl(bus->base + ASPEED_I2C_DEV_ADDR_REG); in __aspeed_i2c_reg_slave()
729 writel(addr_reg_val, bus->base + ASPEED_I2C_DEV_ADDR_REG); in __aspeed_i2c_reg_slave()
732 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
734 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
739 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_reg_slave() local
742 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reg_slave()
743 if (bus->slave) { in aspeed_i2c_reg_slave()
744 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
748 __aspeed_i2c_reg_slave(bus, client->addr); in aspeed_i2c_reg_slave()
750 bus->slave = client; in aspeed_i2c_reg_slave()
751 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_reg_slave()
752 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
759 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_unreg_slave() local
763 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_unreg_slave()
764 if (!bus->slave) { in aspeed_i2c_unreg_slave()
765 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
770 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
772 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
774 bus->slave = NULL; in aspeed_i2c_unreg_slave()
775 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
875 /* precondition: bus.lock has been acquired. */
876 static int aspeed_i2c_init_clk(struct aspeed_i2c_bus *bus) in aspeed_i2c_init_clk() argument
880 divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency); in aspeed_i2c_init_clk()
881 clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
885 clk_reg_val |= bus->get_clk_reg_val(bus->dev, divisor); in aspeed_i2c_init_clk()
886 writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
887 writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2); in aspeed_i2c_init_clk()
892 /* precondition: bus.lock has been acquired. */
893 static int aspeed_i2c_init(struct aspeed_i2c_bus *bus, in aspeed_i2c_init() argument
900 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
902 ret = aspeed_i2c_init_clk(bus); in aspeed_i2c_init()
907 bus->multi_master = true; in aspeed_i2c_init()
912 writel(readl(bus->base + ASPEED_I2C_FUN_CTRL_REG) | fun_ctrl_reg, in aspeed_i2c_init()
913 bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
917 if (bus->slave) in aspeed_i2c_init()
918 __aspeed_i2c_reg_slave(bus, bus->slave->addr); in aspeed_i2c_init()
922 writel(ASPEED_I2CD_INTR_ALL, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_init()
927 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus) in aspeed_i2c_reset() argument
929 struct platform_device *pdev = to_platform_device(bus->dev); in aspeed_i2c_reset()
933 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reset()
936 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_reset()
937 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_reset()
939 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_reset()
941 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reset()
948 .compatible = "aspeed,ast2400-i2c-bus",
952 .compatible = "aspeed,ast2500-i2c-bus",
962 struct aspeed_i2c_bus *bus; in aspeed_i2c_probe_bus() local
967 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); in aspeed_i2c_probe_bus()
968 if (!bus) in aspeed_i2c_probe_bus()
972 bus->base = devm_ioremap_resource(&pdev->dev, res); in aspeed_i2c_probe_bus()
973 if (IS_ERR(bus->base)) in aspeed_i2c_probe_bus()
974 return PTR_ERR(bus->base); in aspeed_i2c_probe_bus()
979 bus->parent_clk_frequency = clk_get_rate(parent_clk); in aspeed_i2c_probe_bus()
983 bus->rst = devm_reset_control_get_shared(&pdev->dev, NULL); in aspeed_i2c_probe_bus()
984 if (IS_ERR(bus->rst)) { in aspeed_i2c_probe_bus()
987 return PTR_ERR(bus->rst); in aspeed_i2c_probe_bus()
989 reset_control_deassert(bus->rst); in aspeed_i2c_probe_bus()
992 "bus-frequency", &bus->bus_frequency); in aspeed_i2c_probe_bus()
995 "Could not read bus-frequency property\n"); in aspeed_i2c_probe_bus()
996 bus->bus_frequency = 100000; in aspeed_i2c_probe_bus()
1001 bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; in aspeed_i2c_probe_bus()
1003 bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) in aspeed_i2c_probe_bus()
1007 spin_lock_init(&bus->lock); in aspeed_i2c_probe_bus()
1008 init_completion(&bus->cmd_complete); in aspeed_i2c_probe_bus()
1009 bus->adap.owner = THIS_MODULE; in aspeed_i2c_probe_bus()
1010 bus->adap.retries = 0; in aspeed_i2c_probe_bus()
1011 bus->adap.algo = &aspeed_i2c_algo; in aspeed_i2c_probe_bus()
1012 bus->adap.dev.parent = &pdev->dev; in aspeed_i2c_probe_bus()
1013 bus->adap.dev.of_node = pdev->dev.of_node; in aspeed_i2c_probe_bus()
1014 strlcpy(bus->adap.name, pdev->name, sizeof(bus->adap.name)); in aspeed_i2c_probe_bus()
1015 i2c_set_adapdata(&bus->adap, bus); in aspeed_i2c_probe_bus()
1017 bus->dev = &pdev->dev; in aspeed_i2c_probe_bus()
1020 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_probe_bus()
1021 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_probe_bus()
1023 * bus.lock does not need to be held because the interrupt handler has in aspeed_i2c_probe_bus()
1026 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_probe_bus()
1032 0, dev_name(&pdev->dev), bus); in aspeed_i2c_probe_bus()
1036 ret = i2c_add_adapter(&bus->adap); in aspeed_i2c_probe_bus()
1040 platform_set_drvdata(pdev, bus); in aspeed_i2c_probe_bus()
1042 dev_info(bus->dev, "i2c bus %d registered, irq %d\n", in aspeed_i2c_probe_bus()
1043 bus->adap.nr, irq); in aspeed_i2c_probe_bus()
1050 struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev); in aspeed_i2c_remove_bus() local
1053 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_remove_bus()
1056 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_remove_bus()
1057 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_remove_bus()
1059 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_remove_bus()
1061 reset_control_assert(bus->rst); in aspeed_i2c_remove_bus()
1063 i2c_del_adapter(&bus->adap); in aspeed_i2c_remove_bus()
1072 .name = "aspeed-i2c-bus",
1079 MODULE_DESCRIPTION("Aspeed I2C Bus Driver");