[PATCH] i2c: designware: Add base addr info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add i2c hw base address in the adapter name and when the device is
probed.

Output:
root@qt5222:~# dmesg | grep -i syno
[    0.347045] i2c_designware AMDI0010:00: Synopsys DesignWare I2C
adapter at 0xfedc4000
[    0.348843] i2c_designware AMDI0010:01: Synopsys DesignWare I2C
adapter at 0xfedc5000
root@qt5222:~# i2cdetect -l | grep -i desig
i2c-1   i2c             Synopsys DesignWare I2C adapter at 0xfedc5000
I2C adapter
i2c-0   i2c             Synopsys DesignWare I2C adapter at 0xfedc4000
I2C adapter

Signed-off-by: Daniel Gomez <daniel@xxxxxxxx>
---

Hi,
We think it might be interesting to add the physical address if you have
multiple adapters like the above example so we don't write to the wrong
device. Could it be possible to add this patch?

Thanks


 drivers/i2c/busses/i2c-designware-core.h    | 1 +
 drivers/i2c/busses/i2c-designware-master.c  | 2 +-
 drivers/i2c/busses/i2c-designware-platdrv.c | 6 +++++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 5392b82f68a4..8c56a7ec8693 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -241,6 +241,7 @@ struct dw_i2c_dev {
 	struct regmap		*sysmap;
 	void __iomem		*base;
 	void __iomem		*ext;
+	phys_addr_t		base_addr;
 	struct completion	cmd_complete;
 	struct clk		*clk;
 	struct clk		*pclk;
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index dd27b9dbe931..5e78b0aec2d3 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -767,7 +767,7 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
 		return ret;

 	snprintf(adap->name, sizeof(adap->name),
-		 "Synopsys DesignWare I2C adapter");
+		 "Synopsys DesignWare I2C adapter at 0x%llx", dev->base_addr);
 	adap->retries = 3;
 	adap->algo = &i2c_dw_algo;
 	adap->quirks = &i2c_dw_quirks;
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 0dfeb2d11603..c8ffcc85bc51 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -178,6 +178,7 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
 static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev->dev);
+	struct resource *res;
 	int ret;

 	switch (dev->flags & MODEL_MASK) {
@@ -185,7 +186,8 @@ static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
 		ret = bt1_i2c_request_regs(dev);
 		break;
 	default:
-		dev->base = devm_platform_ioremap_resource(pdev, 0);
+		dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+		dev->base_addr = res->start;
 		ret = PTR_ERR_OR_ZERO(dev->base);
 		break;
 	}
@@ -313,6 +315,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	if (ret)
 		goto exit_probe;

+	dev_info(&pdev->dev, "%s\n", adap->name);
+
 	return ret;

 exit_probe:
--
2.30.2




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux