devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] omap-gpmc wait pin additions
@ 2022-09-02  9:10 B. Niedermayr
  2022-09-02  9:10 ` [PATCH v2 1/3] memory: omap-gpmc: allow shared wait pins B. Niedermayr
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: B. Niedermayr @ 2022-09-02  9:10 UTC (permalink / raw)
  To: linux-omap, devicetree; +Cc: rogerq, tony, krzk, robh+dt

From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

There is currently no possibility for the gpmc to set either the
waitp-pin polarity or use the same wait-pin for different cs-regions.

While the current implementation may fullfill most usecases, it may not
be sufficient for more complex setups (e.g. FPGA/ASIC interfaces), where
more complex interfacing options where possible.

For example interfacing an ASIC which offers multiple cs-regions but
only one waitpin the current driver and dt-bindings are not sufficient.

While using the same waitpin for different cs-regions worked for older
kernels (4.14) the omap-gpmc.c driver refused to probe (-EBUSY) with
newer kernels (>5.10).

Changes since v1: 
  * Rebase against recent 6.0.0-rc3 kernel, but the maintainers list
    stays the same!

  ./scripts/get_maintainer.pl drivers/memory/omap-gpmc.c
  Roger Quadros <rogerq@kernel.org> (maintainer:OMAP GENERAL PURPOSE MEMORY CONTROLLER SUPPORT)
  Tony Lindgren <tony@atomide.com> (maintainer:OMAP GENERAL PURPOSE MEMORY CONTROLLER SUPPORT)
  Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> (maintainer:MEMORY CONTROLLER DRIVERS)
  linux-omap@vger.kernel.org (open list:OMAP GENERAL PURPOSE MEMORY CONTROLLER SUPPORT)
  linux-kernel@vger.kernel.org (open list:MEMORY CONTROLLER DRIVERS)
  
  ./scripts/get_maintainer.pl Documentation/devicetree/bindings/memory-controllers/ti,gpmc-child.yaml 
  Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> (maintainer:MEMORY CONTROLLER DRIVERS)
  Rob Herring <robh+dt@kernel.org> (maintainer:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS)
  Tony Lindgren <tony@atomide.com> (in file)
  Roger Quadros <rogerq@kernel.org> (in file)
  linux-kernel@vger.kernel.org (open list:MEMORY CONTROLLER DRIVERS)
  devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS)



Benedikt Niedermayr (3):
  memory: omap-gpmc: allow shared wait pins
  memory: omap-gpmc: add support for wait pin polarity
  dt-bindings: memory-controllers: gpmc-child: Add binding for
    wait-pin-polarity

 .../memory-controllers/ti,gpmc-child.yaml     |  7 ++++
 drivers/memory/omap-gpmc.c                    | 38 +++++++++++++++----
 include/linux/platform_data/gpmc-omap.h       |  1 +
 3 files changed, 39 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] memory: omap-gpmc: allow shared wait pins
  2022-09-02  9:10 [PATCH v2 0/3] omap-gpmc wait pin additions B. Niedermayr
@ 2022-09-02  9:10 ` B. Niedermayr
  2022-09-02  9:10 ` [PATCH v2 2/3] memory: omap-gpmc: add support for wait pin polarity B. Niedermayr
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: B. Niedermayr @ 2022-09-02  9:10 UTC (permalink / raw)
  To: linux-omap, devicetree; +Cc: rogerq, tony, krzk, robh+dt

From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

Newer kernels refuse to probe when using the same wait pin for
different chipselect regions.

But this may be a usecase when connecting for example FPGA or ASIC
modules to the gpmc, which only got one wait pin installed.

Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
 drivers/memory/omap-gpmc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 2351f2708da2..579903457415 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -2215,9 +2215,13 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 							 GPIO_ACTIVE_HIGH,
 							 GPIOD_IN);
 		if (IS_ERR(waitpin_desc)) {
-			dev_err(&pdev->dev, "invalid wait-pin: %d\n", wait_pin);
 			ret = PTR_ERR(waitpin_desc);
-			goto err;
+			if (ret == -EBUSY) {
+				dev_info(&pdev->dev, "shared wait-pin: %d\n", wait_pin);
+			} else {
+				dev_err(&pdev->dev, "invalid wait-pin: %d\n", wait_pin);
+				goto err;
+			}
 		}
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] memory: omap-gpmc: add support for wait pin polarity
  2022-09-02  9:10 [PATCH v2 0/3] omap-gpmc wait pin additions B. Niedermayr
  2022-09-02  9:10 ` [PATCH v2 1/3] memory: omap-gpmc: allow shared wait pins B. Niedermayr
@ 2022-09-02  9:10 ` B. Niedermayr
  2022-09-02  9:10 ` [PATCH v2 3/3] dt-bindings: memory-controllers: gpmc-child: Add binding for wait-pin-polarity B. Niedermayr
  2022-09-05  6:44 ` [PATCH v2 0/3] omap-gpmc wait pin additions Krzysztof Kozlowski
  3 siblings, 0 replies; 7+ messages in thread
From: B. Niedermayr @ 2022-09-02  9:10 UTC (permalink / raw)
  To: linux-omap, devicetree; +Cc: rogerq, tony, krzk, robh+dt

From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

Setting the wait pin polarity from the device tree is currently not
possible. The device tree property "gpmc,wait-pin-polarity" can be used
for that. If this property is missing the previous default value
is used instead, which preserves backwards compatibility.

The wait pin polarity is then set via the gpiochip
direction_input callback function.

Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
 drivers/memory/omap-gpmc.c              | 30 ++++++++++++++++++++-----
 include/linux/platform_data/gpmc-omap.h |  1 +
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 579903457415..be3c35ae9619 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -35,6 +35,8 @@
 
 #include <linux/platform_data/mtd-nand-omap2.h>
 
+#include "../gpio/gpiolib.h"
+
 #define	DEVICE_NAME		"omap-gpmc"
 
 /* GPMC register offsets */
@@ -1980,6 +1982,11 @@ void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
 							"gpmc,wait-on-read");
 		p->wait_on_write = of_property_read_bool(np,
 							 "gpmc,wait-on-write");
+		p->wait_pin_polarity = of_property_read_u32(np,
+								 "gpmc,wait-pin-polarity",
+								 &p->wait_pin_polarity);
+		if (p->wait_pin_polarity < 0)
+			p->wait_pin_polarity = GPIO_ACTIVE_HIGH;
 		if (!p->wait_on_read && !p->wait_on_write)
 			pr_debug("%s: rd/wr wait monitoring not enabled!\n",
 				 __func__);
@@ -2210,10 +2217,11 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	if (gpmc_s.wait_on_read || gpmc_s.wait_on_write) {
 		unsigned int wait_pin = gpmc_s.wait_pin;
 
-		waitpin_desc = gpiochip_request_own_desc(&gpmc->gpio_chip,
-							 wait_pin, "WAITPIN",
-							 GPIO_ACTIVE_HIGH,
-							 GPIOD_IN);
+		waitpin_desc =
+			gpiochip_request_own_desc(&gpmc->gpio_chip,
+				wait_pin, "WAITPIN",
+				gpmc_s.wait_pin_polarity ? GPIO_ACTIVE_HIGH : GPIO_ACTIVE_LOW,
+				GPIOD_IN);
 		if (IS_ERR(waitpin_desc)) {
 			ret = PTR_ERR(waitpin_desc);
 			if (ret == -EBUSY) {
@@ -2342,7 +2350,19 @@ static int gpmc_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
 static int gpmc_gpio_direction_input(struct gpio_chip *chip,
 				     unsigned int offset)
 {
-	return 0;	/* we're input only */
+	u32 reg;
+	struct gpio_desc *desc = gpiochip_get_desc(chip, offset);
+
+	offset += 8;
+	reg = gpmc_read_reg(GPMC_CONFIG);
+
+	if (BIT(FLAG_ACTIVE_LOW) & desc->flags)
+		reg &= ~BIT(offset);
+	else
+		reg |= BIT(offset);
+
+	gpmc_write_reg(GPMC_CONFIG, reg);
+	return 0;
 }
 
 static int gpmc_gpio_direction_output(struct gpio_chip *chip,
diff --git a/include/linux/platform_data/gpmc-omap.h b/include/linux/platform_data/gpmc-omap.h
index c9cc4e32435d..bf4f2246f31d 100644
--- a/include/linux/platform_data/gpmc-omap.h
+++ b/include/linux/platform_data/gpmc-omap.h
@@ -149,6 +149,7 @@ struct gpmc_settings {
 	u32 device_width;	/* device bus width (8 or 16 bit) */
 	u32 mux_add_data;	/* multiplex address & data */
 	u32 wait_pin;		/* wait-pin to be used */
+	u32 wait_pin_polarity;	/* wait-pin polarity */
 };
 
 /* Data for each chip select */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] dt-bindings: memory-controllers: gpmc-child: Add binding for wait-pin-polarity
  2022-09-02  9:10 [PATCH v2 0/3] omap-gpmc wait pin additions B. Niedermayr
  2022-09-02  9:10 ` [PATCH v2 1/3] memory: omap-gpmc: allow shared wait pins B. Niedermayr
  2022-09-02  9:10 ` [PATCH v2 2/3] memory: omap-gpmc: add support for wait pin polarity B. Niedermayr
@ 2022-09-02  9:10 ` B. Niedermayr
  2022-09-05  6:44 ` [PATCH v2 0/3] omap-gpmc wait pin additions Krzysztof Kozlowski
  3 siblings, 0 replies; 7+ messages in thread
From: B. Niedermayr @ 2022-09-02  9:10 UTC (permalink / raw)
  To: linux-omap, devicetree; +Cc: rogerq, tony, krzk, robh+dt

From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

Add a new dt-binding for the wait-pin-polarity property

Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
 .../bindings/memory-controllers/ti,gpmc-child.yaml         | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/memory-controllers/ti,gpmc-child.yaml b/Documentation/devicetree/bindings/memory-controllers/ti,gpmc-child.yaml
index 6e3995bb1630..7c721206f10b 100644
--- a/Documentation/devicetree/bindings/memory-controllers/ti,gpmc-child.yaml
+++ b/Documentation/devicetree/bindings/memory-controllers/ti,gpmc-child.yaml
@@ -230,6 +230,13 @@ properties:
       Wait-pin used by client. Must be less than "gpmc,num-waitpins".
     $ref: /schemas/types.yaml#/definitions/uint32
 
+  gpmc,wait-pin-polarity:
+    description: |
+      Wait-pin polarity used by the clien. It relates to the pin defined
+      with "gpmc,wait-pin".
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0
+
   gpmc,wait-on-read:
     description: Enables wait monitoring on reads.
     type: boolean
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] omap-gpmc wait pin additions
  2022-09-02  9:10 [PATCH v2 0/3] omap-gpmc wait pin additions B. Niedermayr
                   ` (2 preceding siblings ...)
  2022-09-02  9:10 ` [PATCH v2 3/3] dt-bindings: memory-controllers: gpmc-child: Add binding for wait-pin-polarity B. Niedermayr
@ 2022-09-05  6:44 ` Krzysztof Kozlowski
  2022-09-05  7:15   ` Niedermayr, BENEDIKT
  3 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-05  6:44 UTC (permalink / raw)
  To: B. Niedermayr, linux-omap, devicetree; +Cc: rogerq, tony, robh+dt

On 02/09/2022 12:10, B. Niedermayr wrote:
> From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> 
> There is currently no possibility for the gpmc to set either the
> waitp-pin polarity or use the same wait-pin for different cs-regions.
> 
> While the current implementation may fullfill most usecases, it may not
> be sufficient for more complex setups (e.g. FPGA/ASIC interfaces), where
> more complex interfacing options where possible.
> 
> For example interfacing an ASIC which offers multiple cs-regions but
> only one waitpin the current driver and dt-bindings are not sufficient.
> 
> While using the same waitpin for different cs-regions worked for older
> kernels (4.14) the omap-gpmc.c driver refused to probe (-EBUSY) with
> newer kernels (>5.10).
> 
> Changes since v1: 
>   * Rebase against recent 6.0.0-rc3 kernel, but the maintainers list
>     stays the same!

No... thanks for rebasing yet still you use wrong address email.

> 
>   ./scripts/get_maintainer.pl drivers/memory/omap-gpmc.c
>   Roger Quadros <rogerq@kernel.org> (maintainer:OMAP GENERAL PURPOSE MEMORY CONTROLLER SUPPORT)
>   Tony Lindgren <tony@atomide.com> (maintainer:OMAP GENERAL PURPOSE MEMORY CONTROLLER SUPPORT)
>   Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> (maintainer:MEMORY CONTROLLER DRIVERS)

Different address email.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] omap-gpmc wait pin additions
  2022-09-05  6:44 ` [PATCH v2 0/3] omap-gpmc wait pin additions Krzysztof Kozlowski
@ 2022-09-05  7:15   ` Niedermayr, BENEDIKT
  0 siblings, 0 replies; 7+ messages in thread
From: Niedermayr, BENEDIKT @ 2022-09-05  7:15 UTC (permalink / raw)
  To: devicetree@vger.kernel.org, krzk@kernel.org,
	linux-omap@vger.kernel.org
  Cc: rogerq@kernel.org, tony@atomide.com, robh+dt@kernel.org

On Mon, 2022-09-05 at 09:44 +0300, Krzysztof Kozlowski wrote:
> On 02/09/2022 12:10, B. Niedermayr wrote:
> > From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> > 
> > There is currently no possibility for the gpmc to set either the
> > waitp-pin polarity or use the same wait-pin for different cs-
> > regions.
> > 
> > While the current implementation may fullfill most usecases, it may
> > not
> > be sufficient for more complex setups (e.g. FPGA/ASIC interfaces),
> > where
> > more complex interfacing options where possible.
> > 
> > For example interfacing an ASIC which offers multiple cs-regions
> > but
> > only one waitpin the current driver and dt-bindings are not
> > sufficient.
> > 
> > While using the same waitpin for different cs-regions worked for
> > older
> > kernels (4.14) the omap-gpmc.c driver refused to probe (-EBUSY)
> > with
> > newer kernels (>5.10).
> > 
> > Changes since v1: 
> >   * Rebase against recent 6.0.0-rc3 kernel, but the maintainers
> > list
> >     stays the same!
> 
> No... thanks for rebasing yet still you use wrong address email.
> 
> >   ./scripts/get_maintainer.pl drivers/memory/omap-gpmc.c
> >   Roger Quadros <rogerq@kernel.org> (maintainer:OMAP GENERAL
> > PURPOSE MEMORY CONTROLLER SUPPORT)
> >   Tony Lindgren <tony@atomide.com> (maintainer:OMAP GENERAL PURPOSE
> > MEMORY CONTROLLER SUPPORT)
> >   Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > (maintainer:MEMORY CONTROLLER DRIVERS)
> 
> Different address email.
> 
> 
> Best regards,
> Krzysztof
Ok now I see: 
  krzk@kernel.org  has changed to krzysztof.kozlowski@linaro.org




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 0/3] omap-gpmc wait pin additions
@ 2022-09-05  7:17 B. Niedermayr
  0 siblings, 0 replies; 7+ messages in thread
From: B. Niedermayr @ 2022-09-05  7:17 UTC (permalink / raw)
  To: linux-omap, devicetree; +Cc: rogerq, tony, krzysztof.kozlowski, robh+dt

From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

There is currently no possibility for the gpmc to set either the
waitp-pin polarity or use the same wait-pin for different cs-regions.

While the current implementation may fullfill most usecases, it may not
be sufficient for more complex setups (e.g. FPGA/ASIC interfaces), where
more complex interfacing options where possible.

For example interfacing an ASIC which offers multiple cs-regions but
only one waitpin the current driver and dt-bindings are not sufficient.

While using the same waitpin for different cs-regions worked for older
kernels (4.14) the omap-gpmc.c driver refused to probe (-EBUSY) with
newer kernels (>5.10).

Changes since v1: 
  * Rebase against recent 6.0.0-rc3 kernel, but the maintainers list
    stays the same!
  * Updated eMail recipients list


Benedikt Niedermayr (3):
  memory: omap-gpmc: allow shared wait pins
  memory: omap-gpmc: add support for wait pin polarity
  dt-bindings: memory-controllers: gpmc-child: Add binding for
    wait-pin-polarity

 .../memory-controllers/ti,gpmc-child.yaml     |  7 ++++
 drivers/memory/omap-gpmc.c                    | 38 +++++++++++++++----
 include/linux/platform_data/gpmc-omap.h       |  1 +
 3 files changed, 39 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-05  7:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-02  9:10 [PATCH v2 0/3] omap-gpmc wait pin additions B. Niedermayr
2022-09-02  9:10 ` [PATCH v2 1/3] memory: omap-gpmc: allow shared wait pins B. Niedermayr
2022-09-02  9:10 ` [PATCH v2 2/3] memory: omap-gpmc: add support for wait pin polarity B. Niedermayr
2022-09-02  9:10 ` [PATCH v2 3/3] dt-bindings: memory-controllers: gpmc-child: Add binding for wait-pin-polarity B. Niedermayr
2022-09-05  6:44 ` [PATCH v2 0/3] omap-gpmc wait pin additions Krzysztof Kozlowski
2022-09-05  7:15   ` Niedermayr, BENEDIKT
  -- strict thread matches above, loose matches on Subject: below --
2022-09-05  7:17 B. Niedermayr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).