diff options
author | Jae Hyun Yoo <jae.hyun.yoo@intel.com> | 2019-09-23 23:48:49 +0300 |
---|---|---|
committer | Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 2021-11-05 10:22:09 +0300 |
commit | a23b10f1e9b77f158bf55fb153ad00f5c557f376 (patch) | |
tree | 18d50055a3eacd49be985bb4b49882f793793e23 /drivers/i2c | |
parent | f94395088a335407bbaa24bfb1bd26cc8b838d8e (diff) | |
download | linux-a23b10f1e9b77f158bf55fb153ad00f5c557f376.tar.xz |
Refine initialization flow in I2C driver
Since we enabled I2C busses in u-boot, we need to disable the I2C
bus and clear all garbage interrupts when kernel probes the bus.
This commit refines the initialization flow by adding a bus reset
at the beginning of probe function and by moving bus init function
after interrupt handling setup.
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-aspeed.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 1354e2b04cdf..eeb622715527 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -1600,6 +1600,11 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev) bus->dev = &pdev->dev; + /* Disable bus and clean up any left over interrupt state. */ + writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG); + writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); + writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); + parent_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(parent_clk)) return PTR_ERR(parent_clk); @@ -1642,23 +1647,16 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev) strlcpy(bus->adap.name, pdev->name, sizeof(bus->adap.name)); i2c_set_adapdata(&bus->adap, bus); - /* Clean up any left over interrupt state. */ - writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG); - writel(0xffffffff, bus->base + ASPEED_I2C_INTR_STS_REG); - /* - * bus.lock does not need to be held because the interrupt handler has - * not been enabled yet. - */ - ret = aspeed_i2c_init(bus, pdev); - if (ret < 0) - goto out_free_dma_buf; - irq = irq_of_parse_and_map(pdev->dev.of_node, 0); ret = devm_request_irq(&pdev->dev, irq, aspeed_i2c_bus_irq, 0, dev_name(&pdev->dev), bus); if (ret < 0) goto out_free_dma_buf; + ret = aspeed_i2c_init(bus, pdev); + if (ret < 0) + goto out_free_dma_buf; + ret = i2c_add_adapter(&bus->adap); if (ret < 0) goto out_free_dma_buf; |