Lines Matching full:bus

171 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus);
173 /* precondition: bus.lock has been acquired. */
174 static void aspeed_i2c_do_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_stop() argument
176 bus->master_state = ASPEED_I2C_MASTER_STOP; in aspeed_i2c_do_stop()
177 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_stop()
180 static int aspeed_i2c_recover_bus(struct aspeed_i2c_bus *bus) in aspeed_i2c_recover_bus() argument
186 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
187 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
190 /* Bus is idle: no recovery needed. */ in aspeed_i2c_recover_bus()
193 dev_dbg(bus->dev, "SCL hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
196 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
197 aspeed_i2c_do_stop(bus); in aspeed_i2c_recover_bus()
198 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
201 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
203 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
206 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
209 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
212 /* Bus error. */ in aspeed_i2c_recover_bus()
214 dev_dbg(bus->dev, "SDA hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
217 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
220 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
221 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
224 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
226 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
229 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
232 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
238 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
243 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
245 return aspeed_i2c_reset(bus); in aspeed_i2c_recover_bus()
249 static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_slave_irq() argument
252 struct i2c_client *slave = bus->slave; in aspeed_i2c_slave_irq()
267 bus->slave_state = ASPEED_I2C_SLAVE_STOP; in aspeed_i2c_slave_irq()
271 bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { in aspeed_i2c_slave_irq()
273 bus->slave_state = ASPEED_I2C_SLAVE_STOP; in aspeed_i2c_slave_irq()
277 if (bus->slave_state == ASPEED_I2C_SLAVE_STOP) { in aspeed_i2c_slave_irq()
279 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
288 bus->slave_state = ASPEED_I2C_SLAVE_START; in aspeed_i2c_slave_irq()
295 if (bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_slave_irq()
298 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
299 dev_dbg(bus->dev, "slave irq status 0x%08x, cmd 0x%08x\n", in aspeed_i2c_slave_irq()
304 value = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_slave_irq()
306 if (bus->slave_state == ASPEED_I2C_SLAVE_START) { in aspeed_i2c_slave_irq()
308 bus->slave_state = in aspeed_i2c_slave_irq()
311 bus->slave_state = in aspeed_i2c_slave_irq()
317 switch (bus->slave_state) { in aspeed_i2c_slave_irq()
320 dev_err(bus->dev, "Unexpected ACK on read request.\n"); in aspeed_i2c_slave_irq()
321 bus->slave_state = ASPEED_I2C_SLAVE_READ_PROCESSED; in aspeed_i2c_slave_irq()
323 writel(value, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_slave_irq()
324 writel(ASPEED_I2CD_S_TX_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
328 dev_err(bus->dev, in aspeed_i2c_slave_irq()
334 writel(value, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_slave_irq()
335 writel(ASPEED_I2CD_S_TX_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
338 bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED; in aspeed_i2c_slave_irq()
342 * returns an errno, the bus driver should nack the next incoming byte. in aspeed_i2c_slave_irq()
345 writel(ASPEED_I2CD_M_S_RX_CMD_LAST, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
357 dev_err(bus->dev, "unknown slave_state: %d\n", in aspeed_i2c_slave_irq()
358 bus->slave_state); in aspeed_i2c_slave_irq()
359 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
367 /* precondition: bus.lock has been acquired. */
368 static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_start() argument
371 struct i2c_msg *msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_do_start()
378 * command when the bus comes back to the idle state. in aspeed_i2c_do_start()
380 if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) { in aspeed_i2c_do_start()
381 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_do_start()
386 bus->master_state = ASPEED_I2C_MASTER_START; in aspeed_i2c_do_start()
387 bus->buf_index = 0; in aspeed_i2c_do_start()
396 writel(slave_addr, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_do_start()
397 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_start()
400 /* precondition: bus.lock has been acquired. */
401 static void aspeed_i2c_next_msg_or_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_next_msg_or_stop() argument
403 if (bus->msgs_index + 1 < bus->msgs_count) { in aspeed_i2c_next_msg_or_stop()
404 bus->msgs_index++; in aspeed_i2c_next_msg_or_stop()
405 aspeed_i2c_do_start(bus); in aspeed_i2c_next_msg_or_stop()
407 aspeed_i2c_do_stop(bus); in aspeed_i2c_next_msg_or_stop()
424 static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_master_irq() argument
432 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
444 dev_dbg(bus->dev, "received error interrupt: 0x%08x\n", in aspeed_i2c_master_irq()
447 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE) { in aspeed_i2c_master_irq()
449 bus->cmd_err = ret; in aspeed_i2c_master_irq()
450 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
456 if (bus->master_state == ASPEED_I2C_MASTER_INACTIVE || in aspeed_i2c_master_irq()
457 bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_irq()
460 /* We are in an invalid state; reset bus to a known state. */ in aspeed_i2c_master_irq()
461 if (!bus->msgs) { in aspeed_i2c_master_irq()
462 dev_err(bus->dev, "bus in unknown state. irq_status: 0x%x\n", in aspeed_i2c_master_irq()
464 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
465 if (bus->master_state != ASPEED_I2C_MASTER_STOP && in aspeed_i2c_master_irq()
466 bus->master_state != ASPEED_I2C_MASTER_INACTIVE) in aspeed_i2c_master_irq()
467 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
470 msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_master_irq()
477 if (bus->master_state == ASPEED_I2C_MASTER_START) { in aspeed_i2c_master_irq()
487 writel(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_irq()
489 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
490 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_master_irq()
491 dev_dbg(bus->dev, in aspeed_i2c_master_irq()
498 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
499 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
504 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
505 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
510 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
514 bus->master_state = ASPEED_I2C_MASTER_RX_FIRST; in aspeed_i2c_master_irq()
516 bus->master_state = ASPEED_I2C_MASTER_TX_FIRST; in aspeed_i2c_master_irq()
519 switch (bus->master_state) { in aspeed_i2c_master_irq()
522 dev_dbg(bus->dev, "slave NACKed TX\n"); in aspeed_i2c_master_irq()
526 dev_err(bus->dev, "slave failed to ACK TX\n"); in aspeed_i2c_master_irq()
532 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
533 bus->master_state = ASPEED_I2C_MASTER_TX; in aspeed_i2c_master_irq()
534 writel(msg->buf[bus->buf_index++], in aspeed_i2c_master_irq()
535 bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_master_irq()
537 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
539 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
549 dev_err(bus->dev, "master failed to RX\n"); in aspeed_i2c_master_irq()
554 recv_byte = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_master_irq()
555 msg->buf[bus->buf_index++] = recv_byte; in aspeed_i2c_master_irq()
559 bus->cmd_err = -EPROTO; in aspeed_i2c_master_irq()
560 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
568 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
569 bus->master_state = ASPEED_I2C_MASTER_RX; in aspeed_i2c_master_irq()
571 if (bus->buf_index + 1 == msg->len) in aspeed_i2c_master_irq()
573 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
575 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
580 dev_err(bus->dev, in aspeed_i2c_master_irq()
583 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
589 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
592 dev_err(bus->dev, in aspeed_i2c_master_irq()
595 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
600 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
601 bus->cmd_err = -EINVAL; in aspeed_i2c_master_irq()
605 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
606 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
609 bus->msgs = NULL; in aspeed_i2c_master_irq()
610 if (bus->cmd_err) in aspeed_i2c_master_irq()
611 bus->master_xfer_result = bus->cmd_err; in aspeed_i2c_master_irq()
613 bus->master_xfer_result = bus->msgs_index + 1; in aspeed_i2c_master_irq()
614 complete(&bus->cmd_complete); in aspeed_i2c_master_irq()
621 struct aspeed_i2c_bus *bus = dev_id; in aspeed_i2c_bus_irq() local
624 spin_lock(&bus->lock); in aspeed_i2c_bus_irq()
625 irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
628 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
629 readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
641 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE && in aspeed_i2c_bus_irq()
642 bus->master_state != ASPEED_I2C_MASTER_PENDING) { in aspeed_i2c_bus_irq()
643 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
646 irq_handled |= aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
648 irq_handled = aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
651 irq_handled |= aspeed_i2c_master_irq(bus, in aspeed_i2c_bus_irq()
659 if (bus->master_state == ASPEED_I2C_MASTER_PENDING && in aspeed_i2c_bus_irq()
660 bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_bus_irq()
661 aspeed_i2c_do_start(bus); in aspeed_i2c_bus_irq()
663 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
668 dev_err(bus->dev, in aspeed_i2c_bus_irq()
675 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
676 readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
678 spin_unlock(&bus->lock); in aspeed_i2c_bus_irq()
685 struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap); in aspeed_i2c_master_xfer() local
688 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
689 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
691 /* If bus is busy in a single master environment, attempt recovery. */ in aspeed_i2c_master_xfer()
692 if (!bus->multi_master && in aspeed_i2c_master_xfer()
693 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
697 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
698 ret = aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
701 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
704 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
705 bus->msgs = msgs; in aspeed_i2c_master_xfer()
706 bus->msgs_index = 0; in aspeed_i2c_master_xfer()
707 bus->msgs_count = num; in aspeed_i2c_master_xfer()
709 reinit_completion(&bus->cmd_complete); in aspeed_i2c_master_xfer()
710 aspeed_i2c_do_start(bus); in aspeed_i2c_master_xfer()
711 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
713 time_left = wait_for_completion_timeout(&bus->cmd_complete, in aspeed_i2c_master_xfer()
714 bus->adap.timeout); in aspeed_i2c_master_xfer()
719 * recovery. But if the bus is idle, we still need to reset the in aspeed_i2c_master_xfer()
722 if (bus->multi_master && in aspeed_i2c_master_xfer()
723 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
725 aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
727 aspeed_i2c_reset(bus); in aspeed_i2c_master_xfer()
733 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
734 if (bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_xfer()
735 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_xfer()
736 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
741 return bus->master_xfer_result; in aspeed_i2c_master_xfer()
750 /* precondition: bus.lock has been acquired. */
751 static void __aspeed_i2c_reg_slave(struct aspeed_i2c_bus *bus, u16 slave_addr) in __aspeed_i2c_reg_slave() argument
760 * end up with additional phantom devices responding on the bus. in __aspeed_i2c_reg_slave()
763 writel(addr_reg_val, bus->base + ASPEED_I2C_DEV_ADDR_REG); in __aspeed_i2c_reg_slave()
766 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
768 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
770 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in __aspeed_i2c_reg_slave()
775 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_reg_slave() local
778 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reg_slave()
779 if (bus->slave) { in aspeed_i2c_reg_slave()
780 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
784 __aspeed_i2c_reg_slave(bus, client->addr); in aspeed_i2c_reg_slave()
786 bus->slave = client; in aspeed_i2c_reg_slave()
787 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
794 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_unreg_slave() local
798 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_unreg_slave()
799 if (!bus->slave) { in aspeed_i2c_unreg_slave()
800 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
805 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
807 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
809 bus->slave = NULL; in aspeed_i2c_unreg_slave()
810 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
910 /* precondition: bus.lock has been acquired. */
911 static int aspeed_i2c_init_clk(struct aspeed_i2c_bus *bus) in aspeed_i2c_init_clk() argument
915 divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency); in aspeed_i2c_init_clk()
916 clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
920 clk_reg_val |= bus->get_clk_reg_val(bus->dev, divisor); in aspeed_i2c_init_clk()
921 writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
922 writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2); in aspeed_i2c_init_clk()
927 /* precondition: bus.lock has been acquired. */
928 static int aspeed_i2c_init(struct aspeed_i2c_bus *bus, in aspeed_i2c_init() argument
935 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
937 ret = aspeed_i2c_init_clk(bus); in aspeed_i2c_init()
942 bus->multi_master = true; in aspeed_i2c_init()
947 writel(readl(bus->base + ASPEED_I2C_FUN_CTRL_REG) | fun_ctrl_reg, in aspeed_i2c_init()
948 bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
952 if (bus->slave) in aspeed_i2c_init()
953 __aspeed_i2c_reg_slave(bus, bus->slave->addr); in aspeed_i2c_init()
957 writel(ASPEED_I2CD_INTR_ALL, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_init()
962 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus) in aspeed_i2c_reset() argument
964 struct platform_device *pdev = to_platform_device(bus->dev); in aspeed_i2c_reset()
968 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reset()
971 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_reset()
972 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_reset()
974 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_reset()
976 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reset()
983 .compatible = "aspeed,ast2400-i2c-bus",
987 .compatible = "aspeed,ast2500-i2c-bus",
991 .compatible = "aspeed,ast2600-i2c-bus",
1001 struct aspeed_i2c_bus *bus; in aspeed_i2c_probe_bus() local
1005 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); in aspeed_i2c_probe_bus()
1006 if (!bus) in aspeed_i2c_probe_bus()
1009 bus->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in aspeed_i2c_probe_bus()
1010 if (IS_ERR(bus->base)) in aspeed_i2c_probe_bus()
1011 return PTR_ERR(bus->base); in aspeed_i2c_probe_bus()
1016 bus->parent_clk_frequency = clk_get_rate(parent_clk); in aspeed_i2c_probe_bus()
1020 bus->rst = devm_reset_control_get_shared(&pdev->dev, NULL); in aspeed_i2c_probe_bus()
1021 if (IS_ERR(bus->rst)) { in aspeed_i2c_probe_bus()
1024 return PTR_ERR(bus->rst); in aspeed_i2c_probe_bus()
1026 reset_control_deassert(bus->rst); in aspeed_i2c_probe_bus()
1029 "bus-frequency", &bus->bus_frequency); in aspeed_i2c_probe_bus()
1032 "Could not read bus-frequency property\n"); in aspeed_i2c_probe_bus()
1033 bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ; in aspeed_i2c_probe_bus()
1038 bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; in aspeed_i2c_probe_bus()
1040 bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) in aspeed_i2c_probe_bus()
1044 spin_lock_init(&bus->lock); in aspeed_i2c_probe_bus()
1045 init_completion(&bus->cmd_complete); in aspeed_i2c_probe_bus()
1046 bus->adap.owner = THIS_MODULE; in aspeed_i2c_probe_bus()
1047 bus->adap.retries = 0; in aspeed_i2c_probe_bus()
1048 bus->adap.algo = &aspeed_i2c_algo; in aspeed_i2c_probe_bus()
1049 bus->adap.dev.parent = &pdev->dev; in aspeed_i2c_probe_bus()
1050 bus->adap.dev.of_node = pdev->dev.of_node; in aspeed_i2c_probe_bus()
1051 strscpy(bus->adap.name, pdev->name, sizeof(bus->adap.name)); in aspeed_i2c_probe_bus()
1052 i2c_set_adapdata(&bus->adap, bus); in aspeed_i2c_probe_bus()
1054 bus->dev = &pdev->dev; in aspeed_i2c_probe_bus()
1057 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_probe_bus()
1058 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_probe_bus()
1060 * bus.lock does not need to be held because the interrupt handler has in aspeed_i2c_probe_bus()
1063 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_probe_bus()
1069 0, dev_name(&pdev->dev), bus); in aspeed_i2c_probe_bus()
1073 ret = i2c_add_adapter(&bus->adap); in aspeed_i2c_probe_bus()
1077 platform_set_drvdata(pdev, bus); in aspeed_i2c_probe_bus()
1079 dev_info(bus->dev, "i2c bus %d registered, irq %d\n", in aspeed_i2c_probe_bus()
1080 bus->adap.nr, irq); in aspeed_i2c_probe_bus()
1087 struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev); in aspeed_i2c_remove_bus() local
1090 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_remove_bus()
1093 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_remove_bus()
1094 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_remove_bus()
1096 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_remove_bus()
1098 reset_control_assert(bus->rst); in aspeed_i2c_remove_bus()
1100 i2c_del_adapter(&bus->adap); in aspeed_i2c_remove_bus()
1107 .name = "aspeed-i2c-bus",
1114 MODULE_DESCRIPTION("Aspeed I2C Bus Driver");