From: Abhishek Paliwal <abhishek.pali...@aricent.com> From: David Daney <david.da...@cavium.com>
... to allow interaction with cvmx-twsi code. Signed-off-by: David Daney <david.da...@cavium.com> Signed-off-by: Abhishek Paliwal <abhishek.pali...@aricent.com> --- arch/mips/include/asm/octeon/octeon.h | 2 ++ drivers/i2c/busses/i2c-octeon.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h index 58e8beb..dc42317 100644 --- a/arch/mips/include/asm/octeon/octeon.h +++ b/arch/mips/include/asm/octeon/octeon.h @@ -268,6 +268,8 @@ void octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t); extern void octeon_fixup_irqs(void); +int octeon_i2c_cvmx2i2c(unsigned int cvmx_twsi_bus_num); + int register_co_cache_error_notifier(struct notifier_block *nb); int unregister_co_cache_error_notifier(struct notifier_block *nb); #define CO_CACHE_ERROR_RECOVERABLE 0 diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index 96d88d0..0cbfc8f 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c @@ -80,6 +80,7 @@ struct octeon_i2c { struct device *dev; int broken_irq_mode; bool octeon_i2c_hlc_enabled; + int cvmx_channel; }; /** @@ -903,6 +904,17 @@ static int octeon_i2c_initlowlevel(struct octeon_i2c *i2c) return 0; } +static int octeon_i2c_cvmx_map[2] = {-ENODEV, -ENODEV}; + +int octeon_i2c_cvmx2i2c(unsigned int cvmx_twsi_bus_num) +{ + if (cvmx_twsi_bus_num < ARRAY_SIZE(octeon_i2c_cvmx_map)) + return octeon_i2c_cvmx_map[cvmx_twsi_bus_num]; + else + return -ENODEV; +} +EXPORT_SYMBOL(octeon_i2c_cvmx2i2c); + static int octeon_i2c_probe(struct platform_device *pdev) { int irq, result = 0; @@ -920,6 +932,7 @@ static int octeon_i2c_probe(struct platform_device *pdev) result = -ENOMEM; goto out; } + i2c->cvmx_channel = -1; i2c->dev = &pdev->dev; res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -947,6 +960,17 @@ static int octeon_i2c_probe(struct platform_device *pdev) i2c->sys_freq = octeon_get_io_clock_rate(); + switch (res_mem->start) { + case 0x1180000001000: + i2c->cvmx_channel = 0; + break; + case 0x1180000001200: + i2c->cvmx_channel = 1; + break; + default: + break; + } + if (!devm_request_mem_region(&pdev->dev, res_mem->start, resource_size(res_mem), res_mem->name)) { dev_err(i2c->dev, "request_mem_region failed\n"); @@ -990,6 +1014,8 @@ static int octeon_i2c_probe(struct platform_device *pdev) goto out; } dev_info(i2c->dev, "version %s\n", DRV_VERSION); + if (i2c->cvmx_channel >= 0) + octeon_i2c_cvmx_map[i2c->cvmx_channel] = i2c->adap.nr; return 0; @@ -1001,6 +1027,8 @@ static int octeon_i2c_remove(struct platform_device *pdev) { struct octeon_i2c *i2c = platform_get_drvdata(pdev); + if (i2c->cvmx_channel >= 0) + octeon_i2c_cvmx_map[i2c->cvmx_channel] = -ENODEV; i2c_del_adapter(&i2c->adap); return 0; }; -- 1.8.1.4 -- _______________________________________________ linux-yocto mailing list linux-yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/linux-yocto