lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 10 May 2020 12:50:17 +0300
From:   Serge Semin <Sergey.Semin@...kalelectronics.ru>
To:     Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>
CC:     Serge Semin <Sergey.Semin@...kalelectronics.ru>,
        Serge Semin <fancer.lancer@...il.com>,
        Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        Paul Burton <paulburton@...nel.org>,
        Ralf Baechle <ralf@...ux-mips.org>,
        Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        <linux-mips@...r.kernel.org>, <devicetree@...r.kernel.org>,
        Wolfram Sang <wsa@...-dreams.de>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Hans de Goede <hdegoede@...hat.com>,
        Hanjun Guo <guohanjun@...wei.com>, <linux-i2c@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 11/12] i2c: designware: Use provided regmap instead of reg resource

This is a preparation patch before adding a glue platform driver for the
Baikal-T1 I2C controller. Since the i2c controller registers are indirectly
accessed by means of the Baikal-T1 System Controller registers we need to
have a way to disable the default registers mapping setup procedure and
make the DW I2C core/platform code to use a provided by a glue driver
regmap.

Signed-off-by: Serge Semin <Sergey.Semin@...kalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
Cc: Paul Burton <paulburton@...nel.org>
Cc: Ralf Baechle <ralf@...ux-mips.org>
Cc: Rob Herring <robh+dt@...nel.org>
Cc: Frank Rowand <frowand.list@...il.com>
Cc: linux-mips@...r.kernel.org
Cc: devicetree@...r.kernel.org
---
 drivers/i2c/busses/i2c-designware-common.c  |  7 +++++++
 drivers/i2c/busses/i2c-designware-platdrv.c | 14 ++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index 35c5ad7e274e..141ea0651a8f 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -133,6 +133,13 @@ int i2c_dw_init_regmap(struct dw_i2c_dev *dev)
 	u32 reg;
 	int ret;
 
+	/*
+	 * Skip detecting the registers map configuration if the regmap has
+	 * already been provided by a higher code.
+	 */
+	if (dev->map)
+		return 0;
+
 	ret = i2c_dw_acquire_lock(dev);
 	if (ret)
 		return ret;
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index f577e2a92a4f..9d131a64ea81 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -212,10 +212,16 @@ int i2c_dw_plat_setup(struct dw_i2c_dev *dev)
 	if (dev->irq < 0)
 		return dev->irq;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	dev->base = devm_ioremap_resource(&pdev->dev, mem);
-	if (IS_ERR(dev->base))
-		return PTR_ERR(dev->base);
+	/*
+	 * Don't try to get the controller registers MMIO space if regmap has
+	 * been provided by a higher level code.
+	 */
+	if (!dev->map) {
+		mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		dev->base = devm_ioremap_resource(&pdev->dev, mem);
+		if (IS_ERR(dev->base))
+			return PTR_ERR(dev->base);
+	}
 
 	dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
 	if (IS_ERR(dev->rst))
-- 
2.25.1

Powered by blists - more mailing lists