devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64
@ 2021-12-08 12:46 Roger Quadros
  2021-12-08 12:46 ` [PATCH v2 2/4] memory: omap-gpmc: Add support for GPMC on AM64 SoC Roger Quadros
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Roger Quadros @ 2021-12-08 12:46 UTC (permalink / raw)
  To: krzysztof.kozlowski, tony
  Cc: kishon, nm, vigneshr, linux-omap, linux-arm-kernel, linux-kernel,
	devicetree, Roger Quadros, Rob Herring

AM64 SoC contains the GPMC module. Add compatible for it.

Newer SoCs don't necessarily map GPMC data region at the same place
as legacy SoCs. Add reg-names "data", to provide this information to
the device driver.

Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 .../bindings/memory-controllers/ti,gpmc.yaml  | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/memory-controllers/ti,gpmc.yaml b/Documentation/devicetree/bindings/memory-controllers/ti,gpmc.yaml
index 25b42d68f9b3..64dc9d398d9a 100644
--- a/Documentation/devicetree/bindings/memory-controllers/ti,gpmc.yaml
+++ b/Documentation/devicetree/bindings/memory-controllers/ti,gpmc.yaml
@@ -23,13 +23,20 @@ properties:
     items:
       - enum:
           - ti,am3352-gpmc
+          - ti,am64-gpmc
           - ti,omap2420-gpmc
           - ti,omap2430-gpmc
           - ti,omap3430-gpmc
           - ti,omap4430-gpmc
 
   reg:
-    maxItems: 1
+    minItems: 1
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: data
 
   interrupts:
     maxItems: 1
@@ -44,6 +51,9 @@ properties:
     items:
       - const: fck
 
+  power-domains:
+    maxItems: 1
+
   dmas:
     items:
       - description: DMA channel for GPMC NAND prefetch
@@ -133,6 +143,17 @@ required:
   - "#address-cells"
   - "#size-cells"
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: ti,am64-gpmc
+    then:
+      required:
+        - reg-names
+        - power-domains
+
 additionalProperties: false
 
 examples:
-- 
2.17.1


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

* [PATCH v2 2/4] memory: omap-gpmc: Add support for GPMC on AM64 SoC
  2021-12-08 12:46 [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Roger Quadros
@ 2021-12-08 12:46 ` Roger Quadros
  2021-12-08 12:46 ` [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility Roger Quadros
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2021-12-08 12:46 UTC (permalink / raw)
  To: krzysztof.kozlowski, tony
  Cc: kishon, nm, vigneshr, linux-omap, linux-arm-kernel, linux-kernel,
	devicetree, Roger Quadros

The TI's AM64 SoC has the GPMC module. Add compatible for it.

Traditionally GPMC external addresses have always been mapped to first
1GB physical address. However newer platforms, can have it mapped
at different locations. Support this address provision via device tree.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 drivers/memory/omap-gpmc.c | 40 ++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index be0858bff4d3..624153048182 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -237,6 +237,7 @@ struct gpmc_device {
 	struct omap3_gpmc_regs context;
 	int nirqs;
 	unsigned int is_suspended:1;
+	struct resource *data;
 };
 
 static struct irq_domain *gpmc_irq_domain;
@@ -1456,12 +1457,18 @@ static void gpmc_mem_exit(void)
 	}
 }
 
-static void gpmc_mem_init(void)
+static void gpmc_mem_init(struct gpmc_device *gpmc)
 {
 	int cs;
 
-	gpmc_mem_root.start = GPMC_MEM_START;
-	gpmc_mem_root.end = GPMC_MEM_END;
+	if (!gpmc->data) {
+		/* All legacy devices have same data IO window */
+		gpmc_mem_root.start = GPMC_MEM_START;
+		gpmc_mem_root.end = GPMC_MEM_END;
+	} else {
+		gpmc_mem_root.start = gpmc->data->start;
+		gpmc_mem_root.end = gpmc->data->end;
+	}
 
 	/* Reserve all regions that has been set up by bootloader */
 	for (cs = 0; cs < gpmc_cs_num; cs++) {
@@ -1888,6 +1895,7 @@ static const struct of_device_id gpmc_dt_ids[] = {
 	{ .compatible = "ti,omap3430-gpmc" },	/* omap3430 & omap3630 */
 	{ .compatible = "ti,omap4430-gpmc" },	/* omap4430 & omap4460 & omap543x */
 	{ .compatible = "ti,am3352-gpmc" },	/* am335x devices */
+	{ .compatible = "ti,am64-gpmc" },
 	{ }
 };
 
@@ -2502,13 +2510,25 @@ static int gpmc_probe(struct platform_device *pdev)
 	gpmc->dev = &pdev->dev;
 	platform_set_drvdata(pdev, gpmc);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENOENT;
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
+	if (!res) {
+		/* legacy DT */
+		gpmc_base = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(gpmc_base))
+			return PTR_ERR(gpmc_base);
+	} else {
+		gpmc_base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(gpmc_base))
+			return PTR_ERR(gpmc_base);
+
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "data");
+		if (!res) {
+			dev_err(&pdev->dev, "couldn't get data reg resource\n");
+			return -ENOENT;
+		}
 
-	gpmc_base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(gpmc_base))
-		return PTR_ERR(gpmc_base);
+		gpmc->data = res;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
@@ -2562,7 +2582,7 @@ static int gpmc_probe(struct platform_device *pdev)
 	dev_info(gpmc->dev, "GPMC revision %d.%d\n", GPMC_REVISION_MAJOR(l),
 		 GPMC_REVISION_MINOR(l));
 
-	gpmc_mem_init();
+	gpmc_mem_init(gpmc);
 	rc = gpmc_gpio_init(gpmc);
 	if (rc)
 		goto gpio_init_failed;
-- 
2.17.1


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

* [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility
  2021-12-08 12:46 [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Roger Quadros
  2021-12-08 12:46 ` [PATCH v2 2/4] memory: omap-gpmc: Add support for GPMC on AM64 SoC Roger Quadros
@ 2021-12-08 12:46 ` Roger Quadros
  2021-12-15 16:03   ` Rob Herring
  2021-12-08 12:46 ` [PATCH v2 4/4] arm64: arch_k3: Select GPMC device driver Roger Quadros
  2021-12-15 16:03 ` [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Rob Herring
  3 siblings, 1 reply; 7+ messages in thread
From: Roger Quadros @ 2021-12-08 12:46 UTC (permalink / raw)
  To: krzysztof.kozlowski, tony
  Cc: kishon, nm, vigneshr, linux-omap, linux-arm-kernel, linux-kernel,
	devicetree, Roger Quadros

We have added new compatibles for controller so just checking for
"ti,omap2-nand" compatible is not enough. Check for "nand" node name
as well.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 drivers/memory/omap-gpmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index 624153048182..9f0062a262db 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -2183,7 +2183,8 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+	if (of_device_is_compatible(child, "ti,omap2-nand") ||
+	    of_node_name_eq(child, "nand")) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
-- 
2.17.1


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

* [PATCH v2 4/4] arm64: arch_k3: Select GPMC device driver
  2021-12-08 12:46 [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Roger Quadros
  2021-12-08 12:46 ` [PATCH v2 2/4] memory: omap-gpmc: Add support for GPMC on AM64 SoC Roger Quadros
  2021-12-08 12:46 ` [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility Roger Quadros
@ 2021-12-08 12:46 ` Roger Quadros
  2021-12-15 16:03 ` [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Rob Herring
  3 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2021-12-08 12:46 UTC (permalink / raw)
  To: krzysztof.kozlowski, tony
  Cc: kishon, nm, vigneshr, linux-omap, linux-arm-kernel, linux-kernel,
	devicetree, Roger Quadros

The GPMC controller is present on some K3 SoCs.
It provides access to NOR/NAND flashes and asynchronous
SRAM-like memories and ASICs.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 1aa8b7073218..f447b120f863 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -122,6 +122,7 @@ config ARCH_K3
 	select TI_SCI_INTR_IRQCHIP
 	select TI_SCI_INTA_IRQCHIP
 	select TI_K3_SOCINFO
+	select OMAP_GPMC
 	help
 	  This enables support for Texas Instruments' K3 multicore SoC
 	  architecture.
-- 
2.17.1


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

* Re: [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility
  2021-12-08 12:46 ` [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility Roger Quadros
@ 2021-12-15 16:03   ` Rob Herring
  2021-12-17  7:35     ` Roger Quadros
  0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2021-12-15 16:03 UTC (permalink / raw)
  To: Roger Quadros
  Cc: krzysztof.kozlowski, tony, kishon, nm, vigneshr, linux-omap,
	linux-arm-kernel, linux-kernel, devicetree

On Wed, Dec 08, 2021 at 02:46:10PM +0200, Roger Quadros wrote:
> We have added new compatibles for controller so just checking for
> "ti,omap2-nand" compatible is not enough. Check for "nand" node name
> as well.
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> ---
>  drivers/memory/omap-gpmc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index 624153048182..9f0062a262db 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -2183,7 +2183,8 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
>  		}
>  	}
>  
> -	if (of_device_is_compatible(child, "ti,omap2-nand")) {
> +	if (of_device_is_compatible(child, "ti,omap2-nand") ||
> +	    of_node_name_eq(child, "nand")) {

It would be better to stick with compatible strings. You can match 
against a match table. This should be 'nand-controller' really if this 
binding had a proper split between the controller and nand chips.

Rob

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

* Re: [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64
  2021-12-08 12:46 [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Roger Quadros
                   ` (2 preceding siblings ...)
  2021-12-08 12:46 ` [PATCH v2 4/4] arm64: arch_k3: Select GPMC device driver Roger Quadros
@ 2021-12-15 16:03 ` Rob Herring
  3 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2021-12-15 16:03 UTC (permalink / raw)
  To: Roger Quadros
  Cc: linux-kernel, Rob Herring, devicetree, kishon, nm,
	linux-arm-kernel, linux-omap, tony, krzysztof.kozlowski,
	vigneshr

On Wed, 08 Dec 2021 14:46:08 +0200, Roger Quadros wrote:
> AM64 SoC contains the GPMC module. Add compatible for it.
> 
> Newer SoCs don't necessarily map GPMC data region at the same place
> as legacy SoCs. Add reg-names "data", to provide this information to
> the device driver.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> ---
>  .../bindings/memory-controllers/ti,gpmc.yaml  | 23 ++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility
  2021-12-15 16:03   ` Rob Herring
@ 2021-12-17  7:35     ` Roger Quadros
  0 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2021-12-17  7:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: krzysztof.kozlowski, tony, kishon, nm, vigneshr, linux-omap,
	linux-arm-kernel, linux-kernel, devicetree

Hi Rob,

On 15/12/2021 18:03, Rob Herring wrote:
> On Wed, Dec 08, 2021 at 02:46:10PM +0200, Roger Quadros wrote:
>> We have added new compatibles for controller so just checking for
>> "ti,omap2-nand" compatible is not enough. Check for "nand" node name
>> as well.
>>
>> Signed-off-by: Roger Quadros <rogerq@kernel.org>
>> ---
>>  drivers/memory/omap-gpmc.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
>> index 624153048182..9f0062a262db 100644
>> --- a/drivers/memory/omap-gpmc.c
>> +++ b/drivers/memory/omap-gpmc.c
>> @@ -2183,7 +2183,8 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
>>  		}
>>  	}
>>  
>> -	if (of_device_is_compatible(child, "ti,omap2-nand")) {
>> +	if (of_device_is_compatible(child, "ti,omap2-nand") ||
>> +	    of_node_name_eq(child, "nand")) {
> 
> It would be better to stick with compatible strings. You can match 
> against a match table. This should be 'nand-controller' really if this 
> binding had a proper split between the controller and nand chips.

OK. I will change this to use compatible strings using a match table.

The 'nand-controller' + 'nand' chip change will be done in a separate series
sometime later.

cheers,
-roger

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

end of thread, other threads:[~2021-12-17  7:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 12:46 [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Roger Quadros
2021-12-08 12:46 ` [PATCH v2 2/4] memory: omap-gpmc: Add support for GPMC on AM64 SoC Roger Quadros
2021-12-08 12:46 ` [PATCH v2 3/4] memory: omap-gpmc: check for nand node name instead of just compatibility Roger Quadros
2021-12-15 16:03   ` Rob Herring
2021-12-17  7:35     ` Roger Quadros
2021-12-08 12:46 ` [PATCH v2 4/4] arm64: arch_k3: Select GPMC device driver Roger Quadros
2021-12-15 16:03 ` [PATCH v2 1/4] dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64 Rob Herring

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).