Lines Matching full:bus

173 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus);
175 static int aspeed_i2c_recover_bus(struct aspeed_i2c_bus *bus) in aspeed_i2c_recover_bus() argument
181 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
182 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
185 /* Bus is idle: no recovery needed. */ in aspeed_i2c_recover_bus()
188 dev_dbg(bus->dev, "SCL hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
191 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
192 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
193 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
196 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
198 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
201 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
204 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
207 /* Bus error. */ in aspeed_i2c_recover_bus()
209 dev_dbg(bus->dev, "SDA hung (state %x), attempting recovery\n", in aspeed_i2c_recover_bus()
212 reinit_completion(&bus->cmd_complete); in aspeed_i2c_recover_bus()
215 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_recover_bus()
216 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
219 &bus->cmd_complete, bus->adap.timeout); in aspeed_i2c_recover_bus()
221 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_recover_bus()
224 else if (bus->cmd_err) in aspeed_i2c_recover_bus()
227 else if (!(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_recover_bus()
233 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
238 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_recover_bus()
240 return aspeed_i2c_reset(bus); in aspeed_i2c_recover_bus()
244 static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_slave_irq() argument
247 struct i2c_client *slave = bus->slave; in aspeed_i2c_slave_irq()
253 command = readl(bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
258 bus->slave_state = ASPEED_I2C_SLAVE_START; in aspeed_i2c_slave_irq()
262 if (bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_slave_irq()
265 dev_dbg(bus->dev, "slave irq status 0x%08x, cmd 0x%08x\n", in aspeed_i2c_slave_irq()
270 value = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_slave_irq()
272 if (bus->slave_state == ASPEED_I2C_SLAVE_START) { in aspeed_i2c_slave_irq()
274 bus->slave_state = in aspeed_i2c_slave_irq()
277 bus->slave_state = in aspeed_i2c_slave_irq()
286 bus->slave_state = ASPEED_I2C_SLAVE_STOP; in aspeed_i2c_slave_irq()
289 bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { in aspeed_i2c_slave_irq()
291 bus->slave_state = ASPEED_I2C_SLAVE_STOP; in aspeed_i2c_slave_irq()
294 switch (bus->slave_state) { in aspeed_i2c_slave_irq()
297 dev_err(bus->dev, "Unexpected ACK on read request.\n"); in aspeed_i2c_slave_irq()
298 bus->slave_state = ASPEED_I2C_SLAVE_READ_PROCESSED; in aspeed_i2c_slave_irq()
300 writel(value, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_slave_irq()
301 writel(ASPEED_I2CD_S_TX_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
305 dev_err(bus->dev, in aspeed_i2c_slave_irq()
311 writel(value, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_slave_irq()
312 writel(ASPEED_I2CD_S_TX_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_slave_irq()
315 bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED; in aspeed_i2c_slave_irq()
323 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
329 dev_err(bus->dev, "unknown slave_state: %d\n", in aspeed_i2c_slave_irq()
330 bus->slave_state); in aspeed_i2c_slave_irq()
331 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_slave_irq()
339 /* precondition: bus.lock has been acquired. */
340 static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_start() argument
343 struct i2c_msg *msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_do_start()
350 * command when the bus comes back to the idle state. in aspeed_i2c_do_start()
352 if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) { in aspeed_i2c_do_start()
353 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_do_start()
358 bus->master_state = ASPEED_I2C_MASTER_START; in aspeed_i2c_do_start()
359 bus->buf_index = 0; in aspeed_i2c_do_start()
368 writel(slave_addr, bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_do_start()
369 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_start()
372 /* precondition: bus.lock has been acquired. */
373 static void aspeed_i2c_do_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_do_stop() argument
375 bus->master_state = ASPEED_I2C_MASTER_STOP; in aspeed_i2c_do_stop()
376 writel(ASPEED_I2CD_M_STOP_CMD, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_do_stop()
379 /* precondition: bus.lock has been acquired. */
380 static void aspeed_i2c_next_msg_or_stop(struct aspeed_i2c_bus *bus) in aspeed_i2c_next_msg_or_stop() argument
382 if (bus->msgs_index + 1 < bus->msgs_count) { in aspeed_i2c_next_msg_or_stop()
383 bus->msgs_index++; in aspeed_i2c_next_msg_or_stop()
384 aspeed_i2c_do_start(bus); in aspeed_i2c_next_msg_or_stop()
386 aspeed_i2c_do_stop(bus); in aspeed_i2c_next_msg_or_stop()
403 static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) in aspeed_i2c_master_irq() argument
411 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
423 dev_dbg(bus->dev, "received error interrupt: 0x%08x\n", in aspeed_i2c_master_irq()
426 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE) { in aspeed_i2c_master_irq()
427 bus->cmd_err = ret; in aspeed_i2c_master_irq()
428 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
434 if (bus->master_state == ASPEED_I2C_MASTER_INACTIVE || in aspeed_i2c_master_irq()
435 bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_irq()
438 /* We are in an invalid state; reset bus to a known state. */ in aspeed_i2c_master_irq()
439 if (!bus->msgs) { in aspeed_i2c_master_irq()
440 dev_err(bus->dev, "bus in unknown state. irq_status: 0x%x\n", in aspeed_i2c_master_irq()
442 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
443 if (bus->master_state != ASPEED_I2C_MASTER_STOP && in aspeed_i2c_master_irq()
444 bus->master_state != ASPEED_I2C_MASTER_INACTIVE) in aspeed_i2c_master_irq()
445 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
448 msg = &bus->msgs[bus->msgs_index]; in aspeed_i2c_master_irq()
455 if (bus->master_state == ASPEED_I2C_MASTER_START) { in aspeed_i2c_master_irq()
465 writel(readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_irq()
467 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
468 bus->master_state = ASPEED_I2C_MASTER_PENDING; in aspeed_i2c_master_irq()
469 dev_dbg(bus->dev, in aspeed_i2c_master_irq()
476 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
477 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
482 bus->cmd_err = -ENXIO; in aspeed_i2c_master_irq()
483 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
488 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
492 bus->master_state = ASPEED_I2C_MASTER_RX_FIRST; in aspeed_i2c_master_irq()
494 bus->master_state = ASPEED_I2C_MASTER_TX_FIRST; in aspeed_i2c_master_irq()
497 switch (bus->master_state) { in aspeed_i2c_master_irq()
500 dev_dbg(bus->dev, "slave NACKed TX\n"); in aspeed_i2c_master_irq()
504 dev_err(bus->dev, "slave failed to ACK TX\n"); in aspeed_i2c_master_irq()
510 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
511 bus->master_state = ASPEED_I2C_MASTER_TX; in aspeed_i2c_master_irq()
512 writel(msg->buf[bus->buf_index++], in aspeed_i2c_master_irq()
513 bus->base + ASPEED_I2C_BYTE_BUF_REG); in aspeed_i2c_master_irq()
515 bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
517 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
527 dev_err(bus->dev, "master failed to RX\n"); in aspeed_i2c_master_irq()
532 recv_byte = readl(bus->base + ASPEED_I2C_BYTE_BUF_REG) >> 8; in aspeed_i2c_master_irq()
533 msg->buf[bus->buf_index++] = recv_byte; in aspeed_i2c_master_irq()
537 bus->cmd_err = -EPROTO; in aspeed_i2c_master_irq()
538 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
546 if (bus->buf_index < msg->len) { in aspeed_i2c_master_irq()
547 bus->master_state = ASPEED_I2C_MASTER_RX; in aspeed_i2c_master_irq()
549 if (bus->buf_index + 1 == msg->len) in aspeed_i2c_master_irq()
551 writel(command, bus->base + ASPEED_I2C_CMD_REG); in aspeed_i2c_master_irq()
553 aspeed_i2c_next_msg_or_stop(bus); in aspeed_i2c_master_irq()
558 dev_err(bus->dev, in aspeed_i2c_master_irq()
561 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
567 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
570 dev_err(bus->dev, in aspeed_i2c_master_irq()
573 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
578 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_irq()
579 bus->cmd_err = -EINVAL; in aspeed_i2c_master_irq()
583 bus->cmd_err = -EIO; in aspeed_i2c_master_irq()
584 aspeed_i2c_do_stop(bus); in aspeed_i2c_master_irq()
587 bus->msgs = NULL; in aspeed_i2c_master_irq()
588 if (bus->cmd_err) in aspeed_i2c_master_irq()
589 bus->master_xfer_result = bus->cmd_err; in aspeed_i2c_master_irq()
591 bus->master_xfer_result = bus->msgs_index + 1; in aspeed_i2c_master_irq()
592 complete(&bus->cmd_complete); in aspeed_i2c_master_irq()
599 struct aspeed_i2c_bus *bus = dev_id; in aspeed_i2c_bus_irq() local
602 spin_lock(&bus->lock); in aspeed_i2c_bus_irq()
603 irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
606 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
607 readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
619 if (bus->master_state != ASPEED_I2C_MASTER_INACTIVE && in aspeed_i2c_bus_irq()
620 bus->master_state != ASPEED_I2C_MASTER_PENDING) { in aspeed_i2c_bus_irq()
621 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
624 irq_handled |= aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
626 irq_handled = aspeed_i2c_slave_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
629 irq_handled |= aspeed_i2c_master_irq(bus, in aspeed_i2c_bus_irq()
637 if (bus->master_state == ASPEED_I2C_MASTER_PENDING && in aspeed_i2c_bus_irq()
638 bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) in aspeed_i2c_bus_irq()
639 aspeed_i2c_do_start(bus); in aspeed_i2c_bus_irq()
641 irq_handled = aspeed_i2c_master_irq(bus, irq_remaining); in aspeed_i2c_bus_irq()
646 dev_err(bus->dev, in aspeed_i2c_bus_irq()
653 bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
654 readl(bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_bus_irq()
656 spin_unlock(&bus->lock); in aspeed_i2c_bus_irq()
663 struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap); in aspeed_i2c_master_xfer() local
666 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
667 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
669 /* If bus is busy in a single master environment, attempt recovery. */ in aspeed_i2c_master_xfer()
670 if (!bus->multi_master && in aspeed_i2c_master_xfer()
671 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
675 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
676 ret = aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
679 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
682 bus->cmd_err = 0; in aspeed_i2c_master_xfer()
683 bus->msgs = msgs; in aspeed_i2c_master_xfer()
684 bus->msgs_index = 0; in aspeed_i2c_master_xfer()
685 bus->msgs_count = num; in aspeed_i2c_master_xfer()
687 reinit_completion(&bus->cmd_complete); in aspeed_i2c_master_xfer()
688 aspeed_i2c_do_start(bus); in aspeed_i2c_master_xfer()
689 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
691 time_left = wait_for_completion_timeout(&bus->cmd_complete, in aspeed_i2c_master_xfer()
692 bus->adap.timeout); in aspeed_i2c_master_xfer()
696 * If timed out and bus is still busy in a multi master in aspeed_i2c_master_xfer()
699 if (bus->multi_master && in aspeed_i2c_master_xfer()
700 (readl(bus->base + ASPEED_I2C_CMD_REG) & in aspeed_i2c_master_xfer()
702 aspeed_i2c_recover_bus(bus); in aspeed_i2c_master_xfer()
708 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_master_xfer()
709 if (bus->master_state == ASPEED_I2C_MASTER_PENDING) in aspeed_i2c_master_xfer()
710 bus->master_state = ASPEED_I2C_MASTER_INACTIVE; in aspeed_i2c_master_xfer()
711 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_master_xfer()
716 return bus->master_xfer_result; in aspeed_i2c_master_xfer()
725 /* precondition: bus.lock has been acquired. */
726 static void __aspeed_i2c_reg_slave(struct aspeed_i2c_bus *bus, u16 slave_addr) in __aspeed_i2c_reg_slave() argument
731 addr_reg_val = readl(bus->base + ASPEED_I2C_DEV_ADDR_REG); in __aspeed_i2c_reg_slave()
734 writel(addr_reg_val, bus->base + ASPEED_I2C_DEV_ADDR_REG); in __aspeed_i2c_reg_slave()
737 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
739 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in __aspeed_i2c_reg_slave()
744 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_reg_slave() local
747 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reg_slave()
748 if (bus->slave) { in aspeed_i2c_reg_slave()
749 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
753 __aspeed_i2c_reg_slave(bus, client->addr); in aspeed_i2c_reg_slave()
755 bus->slave = client; in aspeed_i2c_reg_slave()
756 bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; in aspeed_i2c_reg_slave()
757 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reg_slave()
764 struct aspeed_i2c_bus *bus = i2c_get_adapdata(client->adapter); in aspeed_i2c_unreg_slave() local
768 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_unreg_slave()
769 if (!bus->slave) { in aspeed_i2c_unreg_slave()
770 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
775 func_ctrl_reg_val = readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
777 writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_unreg_slave()
779 bus->slave = NULL; in aspeed_i2c_unreg_slave()
780 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_unreg_slave()
880 /* precondition: bus.lock has been acquired. */
881 static int aspeed_i2c_init_clk(struct aspeed_i2c_bus *bus) in aspeed_i2c_init_clk() argument
885 divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency); in aspeed_i2c_init_clk()
886 clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
890 clk_reg_val |= bus->get_clk_reg_val(bus->dev, divisor); in aspeed_i2c_init_clk()
891 writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1); in aspeed_i2c_init_clk()
892 writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2); in aspeed_i2c_init_clk()
897 /* precondition: bus.lock has been acquired. */
898 static int aspeed_i2c_init(struct aspeed_i2c_bus *bus, in aspeed_i2c_init() argument
905 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
907 ret = aspeed_i2c_init_clk(bus); in aspeed_i2c_init()
912 bus->multi_master = true; in aspeed_i2c_init()
917 writel(readl(bus->base + ASPEED_I2C_FUN_CTRL_REG) | fun_ctrl_reg, in aspeed_i2c_init()
918 bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_init()
922 if (bus->slave) in aspeed_i2c_init()
923 __aspeed_i2c_reg_slave(bus, bus->slave->addr); in aspeed_i2c_init()
927 writel(ASPEED_I2CD_INTR_ALL, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_init()
932 static int aspeed_i2c_reset(struct aspeed_i2c_bus *bus) in aspeed_i2c_reset() argument
934 struct platform_device *pdev = to_platform_device(bus->dev); in aspeed_i2c_reset()
938 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_reset()
941 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_reset()
942 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_reset()
944 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_reset()
946 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_reset()
953 .compatible = "aspeed,ast2400-i2c-bus",
957 .compatible = "aspeed,ast2500-i2c-bus",
961 .compatible = "aspeed,ast2600-i2c-bus",
971 struct aspeed_i2c_bus *bus; in aspeed_i2c_probe_bus() local
976 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); in aspeed_i2c_probe_bus()
977 if (!bus) in aspeed_i2c_probe_bus()
981 bus->base = devm_ioremap_resource(&pdev->dev, res); in aspeed_i2c_probe_bus()
982 if (IS_ERR(bus->base)) in aspeed_i2c_probe_bus()
983 return PTR_ERR(bus->base); in aspeed_i2c_probe_bus()
988 bus->parent_clk_frequency = clk_get_rate(parent_clk); in aspeed_i2c_probe_bus()
992 bus->rst = devm_reset_control_get_shared(&pdev->dev, NULL); in aspeed_i2c_probe_bus()
993 if (IS_ERR(bus->rst)) { in aspeed_i2c_probe_bus()
996 return PTR_ERR(bus->rst); in aspeed_i2c_probe_bus()
998 reset_control_deassert(bus->rst); in aspeed_i2c_probe_bus()
1001 "bus-frequency", &bus->bus_frequency); in aspeed_i2c_probe_bus()
1004 "Could not read bus-frequency property\n"); in aspeed_i2c_probe_bus()
1005 bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ; in aspeed_i2c_probe_bus()
1010 bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; in aspeed_i2c_probe_bus()
1012 bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) in aspeed_i2c_probe_bus()
1016 spin_lock_init(&bus->lock); in aspeed_i2c_probe_bus()
1017 init_completion(&bus->cmd_complete); in aspeed_i2c_probe_bus()
1018 bus->adap.owner = THIS_MODULE; in aspeed_i2c_probe_bus()
1019 bus->adap.retries = 0; in aspeed_i2c_probe_bus()
1020 bus->adap.algo = &aspeed_i2c_algo; in aspeed_i2c_probe_bus()
1021 bus->adap.dev.parent = &pdev->dev; in aspeed_i2c_probe_bus()
1022 bus->adap.dev.of_node = pdev->dev.of_node; in aspeed_i2c_probe_bus()
1023 strlcpy(bus->adap.name, pdev->name, sizeof(bus->adap.name)); in aspeed_i2c_probe_bus()
1024 i2c_set_adapdata(&bus->adap, bus); in aspeed_i2c_probe_bus()
1026 bus->dev = &pdev->dev; in aspeed_i2c_probe_bus()
1029 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_probe_bus()
1030 writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); in aspeed_i2c_probe_bus()
1032 * bus.lock does not need to be held because the interrupt handler has in aspeed_i2c_probe_bus()
1035 ret = aspeed_i2c_init(bus, pdev); in aspeed_i2c_probe_bus()
1041 0, dev_name(&pdev->dev), bus); in aspeed_i2c_probe_bus()
1045 ret = i2c_add_adapter(&bus->adap); in aspeed_i2c_probe_bus()
1049 platform_set_drvdata(pdev, bus); in aspeed_i2c_probe_bus()
1051 dev_info(bus->dev, "i2c bus %d registered, irq %d\n", in aspeed_i2c_probe_bus()
1052 bus->adap.nr, irq); in aspeed_i2c_probe_bus()
1059 struct aspeed_i2c_bus *bus = platform_get_drvdata(pdev); in aspeed_i2c_remove_bus() local
1062 spin_lock_irqsave(&bus->lock, flags); in aspeed_i2c_remove_bus()
1065 writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); in aspeed_i2c_remove_bus()
1066 writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); in aspeed_i2c_remove_bus()
1068 spin_unlock_irqrestore(&bus->lock, flags); in aspeed_i2c_remove_bus()
1070 reset_control_assert(bus->rst); in aspeed_i2c_remove_bus()
1072 i2c_del_adapter(&bus->adap); in aspeed_i2c_remove_bus()
1081 .name = "aspeed-i2c-bus",
1088 MODULE_DESCRIPTION("Aspeed I2C Bus Driver");