Lines Matching full:bus
171 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus);
173 static int aspeed_i2c_recover_bus(struct aspeed_i2c_bus *bus) in aspeed_i2c_recover_bus() argument
179 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
180 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
183 /* Bus is idle: no recovery needed. */ in aspeed_i2c_recover_bus()
186 dev_dbg(bus->dev, "SCL hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
189 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
190 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
191 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
194 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
196 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
199 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
202 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
205 /* Bus error. */ in aspeed_i2c_recover_bus()
207 dev_dbg(bus->dev, "SDA hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
210 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
213 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
214 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
217 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
219 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
222 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
225 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
231 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
236 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
238 return aspeed_i2c_reset(bus); in aspeed_i2c_recover_bus()
242 static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_slave_irq() argument
245 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()
318 * returns an errno, the bus driver should nack the next incoming byte. in aspeed_i2c_slave_irq()
321 writel(ASPEED_I2CD_M_S_RX_CMD_LAST, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
328 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
334 dev_err(bus->dev, "unknown slave_state: %d\n", in aspeed_i2c_slave_irq()
335 bus->slave_state); in aspeed_i2c_slave_irq()
336 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
344 /* precondition: bus.lock has been acquired. */
345 static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_start() argument
348 struct i2c_msg *msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_do_start()
355 * command when the bus comes back to the idle state. in aspeed_i2c_do_start()
357 if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) { in aspeed_i2c_do_start()
358 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_do_start()
363 bus->master_state = ASPEED_I2C_MASTER_START; in aspeed_i2c_do_start()
364 bus->buf_index = 0; in aspeed_i2c_do_start()
373 writel(slave_addr, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_do_start()
374 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_start()
377 /* precondition: bus.lock has been acquired. */
378 static void aspeed_i2c_do_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_stop() argument
380 bus->master_state = ASPEED_I2C_MASTER_STOP; in aspeed_i2c_do_stop()
381 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_stop()
384 /* precondition: bus.lock has been acquired. */
385 static void aspeed_i2c_next_msg_or_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_next_msg_or_stop() argument
387 if (bus->msgs_index + 1 < bus->msgs_count) { in aspeed_i2c_next_msg_or_stop()
388 bus->msgs_index++; in aspeed_i2c_next_msg_or_stop()
389 aspeed_i2c_do_start(bus); in aspeed_i2c_next_msg_or_stop()
391 aspeed_i2c_do_stop(bus); in aspeed_i2c_next_msg_or_stop()
408 static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_master_irq() argument
416 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
428 dev_dbg(bus->dev, "received error interrupt: 0x%08x\n", in aspeed_i2c_master_irq()
431 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE) { in aspeed_i2c_master_irq()
432 bus->cmd_err = ret; in aspeed_i2c_master_irq()
433 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
439 if (bus->master_state == ASPEED_I2C_MASTER_INACTIVE || in aspeed_i2c_master_irq()
440 bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_irq()
443 /* We are in an invalid state; reset bus to a known state. */ in aspeed_i2c_master_irq()
444 if (!bus->msgs) { in aspeed_i2c_master_irq()
445 dev_err(bus->dev, "bus in unknown state. irq_status: 0x%x\n", in aspeed_i2c_master_irq()
447 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
448 if (bus->master_state != ASPEED_I2C_MASTER_STOP && in aspeed_i2c_master_irq()
449 bus->master_state != ASPEED_I2C_MASTER_INACTIVE) in aspeed_i2c_master_irq()
450 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
453 msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_master_irq()
460 if (bus->master_state == ASPEED_I2C_MASTER_START) { in aspeed_i2c_master_irq()
470 writel(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_irq()
472 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
473 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_master_irq()
474 dev_dbg(bus->dev, in aspeed_i2c_master_irq()
481 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
482 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
487 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
488 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
493 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
497 bus->master_state = ASPEED_I2C_MASTER_RX_FIRST; in aspeed_i2c_master_irq()
499 bus->master_state = ASPEED_I2C_MASTER_TX_FIRST; in aspeed_i2c_master_irq()
502 switch (bus->master_state) { in aspeed_i2c_master_irq()
505 dev_dbg(bus->dev, "slave NACKed TX\n"); in aspeed_i2c_master_irq()
509 dev_err(bus->dev, "slave failed to ACK TX\n"); in aspeed_i2c_master_irq()
515 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
516 bus->master_state = ASPEED_I2C_MASTER_TX; in aspeed_i2c_master_irq()
517 writel(msg->buf[bus->buf_index++], in aspeed_i2c_master_irq()
518 bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_master_irq()
520 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
522 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
532 dev_err(bus->dev, "master failed to RX\n"); in aspeed_i2c_master_irq()
537 recv_byte = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_master_irq()
538 msg->buf[bus->buf_index++] = recv_byte; in aspeed_i2c_master_irq()
542 bus->cmd_err = -EPROTO; in aspeed_i2c_master_irq()
543 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
551 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
552 bus->master_state = ASPEED_I2C_MASTER_RX; in aspeed_i2c_master_irq()
554 if (bus->buf_index + 1 == msg->len) in aspeed_i2c_master_irq()
556 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
558 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
563 dev_err(bus->dev, in aspeed_i2c_master_irq()
566 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
572 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
575 dev_err(bus->dev, in aspeed_i2c_master_irq()
578 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
583 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
584 bus->cmd_err = -EINVAL; in aspeed_i2c_master_irq()
588 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
589 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
592 bus->msgs = NULL; in aspeed_i2c_master_irq()
593 if (bus->cmd_err) in aspeed_i2c_master_irq()
594 bus->master_xfer_result = bus->cmd_err; in aspeed_i2c_master_irq()
596 bus->master_xfer_result = bus->msgs_index + 1; in aspeed_i2c_master_irq()
597 complete(&bus->cmd_complete); in aspeed_i2c_master_irq()
604 struct aspeed_i2c_bus *bus = dev_id; in aspeed_i2c_bus_irq() local
607 spin_lock(&bus->lock); in aspeed_i2c_bus_irq()
608 irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
611 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
612 readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
624 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE && in aspeed_i2c_bus_irq()
625 bus->master_state != ASPEED_I2C_MASTER_PENDING) { in aspeed_i2c_bus_irq()
626 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
629 irq_handled |= aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
631 irq_handled = aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
634 irq_handled |= aspeed_i2c_master_irq(bus, in aspeed_i2c_bus_irq()
642 if (bus->master_state == ASPEED_I2C_MASTER_PENDING && in aspeed_i2c_bus_irq()
643 bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_bus_irq()
644 aspeed_i2c_do_start(bus); in aspeed_i2c_bus_irq()
646 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
651 dev_err(bus->dev, in aspeed_i2c_bus_irq()
658 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
659 readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
661 spin_unlock(&bus->lock); in aspeed_i2c_bus_irq()
668 struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap); in aspeed_i2c_master_xfer() local
671 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
672 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
674 /* If bus is busy in a single master environment, attempt recovery. */ in aspeed_i2c_master_xfer()
675 if (!bus->multi_master && in aspeed_i2c_master_xfer()
676 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
680 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
681 ret = aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
684 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
687 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
688 bus->msgs = msgs; in aspeed_i2c_master_xfer()
689 bus->msgs_index = 0; in aspeed_i2c_master_xfer()
690 bus->msgs_count = num; in aspeed_i2c_master_xfer()
692 reinit_completion(&bus->cmd_complete); in aspeed_i2c_master_xfer()
693 aspeed_i2c_do_start(bus); in aspeed_i2c_master_xfer()
694 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
696 time_left = wait_for_completion_timeout(&bus->cmd_complete, in aspeed_i2c_master_xfer()
697 bus->adap.timeout); in aspeed_i2c_master_xfer()
701 * If timed out and bus is still busy in a multi master in aspeed_i2c_master_xfer()
704 if (bus->multi_master && in aspeed_i2c_master_xfer()
705 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
707 aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
713 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
714 if (bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_xfer()
715 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_xfer()
716 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
721 return bus->master_xfer_result; in aspeed_i2c_master_xfer()
730 /* precondition: bus.lock has been acquired. */
731 static void __aspeed_i2c_reg_slave(struct aspeed_i2c_bus *bus, u16 slave_addr) in __aspeed_i2c_reg_slave() argument
740 * end up with additional phantom devices responding on the bus. in __aspeed_i2c_reg_slave()
743 writel(addr_reg_val, bus->base + ASPEED_I2C_DEV_ADDR_REG); in __aspeed_i2c_reg_slave()
746 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
748 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
753 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_reg_slave() local
756 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reg_slave()
757 if (bus->slave) { in aspeed_i2c_reg_slave()
758 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
762 __aspeed_i2c_reg_slave(bus, client->addr); in aspeed_i2c_reg_slave()
764 bus->slave = client; in aspeed_i2c_reg_slave()
765 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_reg_slave()
766 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
773 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_unreg_slave() local
777 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_unreg_slave()
778 if (!bus->slave) { in aspeed_i2c_unreg_slave()
779 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
784 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
786 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
788 bus->slave = NULL; in aspeed_i2c_unreg_slave()
789 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
889 /* precondition: bus.lock has been acquired. */
890 static int aspeed_i2c_init_clk(struct aspeed_i2c_bus *bus) in aspeed_i2c_init_clk() argument
894 divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency); in aspeed_i2c_init_clk()
895 clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
899 clk_reg_val |= bus->get_clk_reg_val(bus->dev, divisor); in aspeed_i2c_init_clk()
900 writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
901 writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2); in aspeed_i2c_init_clk()
906 /* precondition: bus.lock has been acquired. */
907 static int aspeed_i2c_init(struct aspeed_i2c_bus *bus, in aspeed_i2c_init() argument
914 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
916 ret = aspeed_i2c_init_clk(bus); in aspeed_i2c_init()
921 bus->multi_master = true; in aspeed_i2c_init()
926 writel(readl(bus->base + ASPEED_I2C_FUN_CTRL_REG) | fun_ctrl_reg, in aspeed_i2c_init()
927 bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
931 if (bus->slave) in aspeed_i2c_init()
932 __aspeed_i2c_reg_slave(bus, bus->slave->addr); in aspeed_i2c_init()
936 writel(ASPEED_I2CD_INTR_ALL, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_init()
941 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus) in aspeed_i2c_reset() argument
943 struct platform_device *pdev = to_platform_device(bus->dev); in aspeed_i2c_reset()
947 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reset()
950 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_reset()
951 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_reset()
953 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_reset()
955 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reset()
962 .compatible = "aspeed,ast2400-i2c-bus",
966 .compatible = "aspeed,ast2500-i2c-bus",
970 .compatible = "aspeed,ast2600-i2c-bus",
980 struct aspeed_i2c_bus *bus; in aspeed_i2c_probe_bus() local
985 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); in aspeed_i2c_probe_bus()
986 if (!bus) in aspeed_i2c_probe_bus()
990 bus->base = devm_ioremap_resource(&pdev->dev, res); in aspeed_i2c_probe_bus()
991 if (IS_ERR(bus->base)) in aspeed_i2c_probe_bus()
992 return PTR_ERR(bus->base); in aspeed_i2c_probe_bus()
997 bus->parent_clk_frequency = clk_get_rate(parent_clk); in aspeed_i2c_probe_bus()
1001 bus->rst = devm_reset_control_get_shared(&pdev->dev, NULL); in aspeed_i2c_probe_bus()
1002 if (IS_ERR(bus->rst)) { in aspeed_i2c_probe_bus()
1005 return PTR_ERR(bus->rst); in aspeed_i2c_probe_bus()
1007 reset_control_deassert(bus->rst); in aspeed_i2c_probe_bus()
1010 "bus-frequency", &bus->bus_frequency); in aspeed_i2c_probe_bus()
1013 "Could not read bus-frequency property\n"); in aspeed_i2c_probe_bus()
1014 bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ; in aspeed_i2c_probe_bus()
1019 bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; in aspeed_i2c_probe_bus()
1021 bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) in aspeed_i2c_probe_bus()
1025 spin_lock_init(&bus->lock); in aspeed_i2c_probe_bus()
1026 init_completion(&bus->cmd_complete); in aspeed_i2c_probe_bus()
1027 bus->adap.owner = THIS_MODULE; in aspeed_i2c_probe_bus()
1028 bus->adap.retries = 0; in aspeed_i2c_probe_bus()
1029 bus->adap.algo = &aspeed_i2c_algo; in aspeed_i2c_probe_bus()
1030 bus->adap.dev.parent = &pdev->dev; in aspeed_i2c_probe_bus()
1031 bus->adap.dev.of_node = pdev->dev.of_node; in aspeed_i2c_probe_bus()
1032 strscpy(bus->adap.name, pdev->name, sizeof(bus->adap.name)); in aspeed_i2c_probe_bus()
1033 i2c_set_adapdata(&bus->adap, bus); in aspeed_i2c_probe_bus()
1035 bus->dev = &pdev->dev; in aspeed_i2c_probe_bus()
1038 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_probe_bus()
1039 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_probe_bus()
1041 * bus.lock does not need to be held because the interrupt handler has in aspeed_i2c_probe_bus()
1044 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_probe_bus()
1050 0, dev_name(&pdev->dev), bus); in aspeed_i2c_probe_bus()
1054 ret = i2c_add_adapter(&bus->adap); in aspeed_i2c_probe_bus()
1058 platform_set_drvdata(pdev, bus); in aspeed_i2c_probe_bus()
1060 dev_info(bus->dev, "i2c bus %d registered, irq %d\n", in aspeed_i2c_probe_bus()
1061 bus->adap.nr, irq); in aspeed_i2c_probe_bus()
1068 struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev); in aspeed_i2c_remove_bus() local
1071 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_remove_bus()
1074 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_remove_bus()
1075 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_remove_bus()
1077 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_remove_bus()
1079 reset_control_assert(bus->rst); in aspeed_i2c_remove_bus()
1081 i2c_del_adapter(&bus->adap); in aspeed_i2c_remove_bus()
1090 .name = "aspeed-i2c-bus",
1097 MODULE_DESCRIPTION("Aspeed I2C Bus Driver");