Skip to contentSkip to conversation

memory: omap-gpmc: Add AM64 SoC support

PATCH Superseded Roger Quadros 3 participants 14 messages Dec 17, 2021 – Dec 20, 2021

Subsystems (6)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Roger Quadros

author maintainer
#0 lore raw

v3 cover memory: omap-gpmc: Add AM64 SoC support

Hi,

TI's AM64 SoC contains one GPMC module. Add driver support for it.

cheers,
-roger

Changelog:
v3
- use compatible match table for checking for NAND controller node in GPMC driver.

v2
- update DT binding doc to make reg-names and power-domains property required only for specific SoC.

Roger Quadros (4):
dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64
memory: omap-gpmc: Add support for GPMC on AM64 SoC
memory: omap-gpmc: Use a compatible match table when checking for NAND
controller
arm64: arch_k3: Select GPMC device driver

 .../bindings/memory-controllers/ti,gpmc.yaml  | 23 ++++++++-
 arch/arm64/Kconfig.platforms                  |  1 +
 drivers/memory/omap-gpmc.c                    | 48 ++++++++++++++-----
 drivers/mtd/nand/raw/omap2.c                  |  2 +-
 include/linux/platform_data/mtd-nand-omap2.h  |  5 ++
 5 files changed, 66 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v3 1/4 dt-bindings: memory-controllers: ti,gpmc: Add compatible for AM64

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.

---
 .../bindings/memory-controllers/ti,gpmc.yaml  | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/memory-controllers/ti,gpmc.yaml +22 -1
index 25b42d68f9b3..64dc9d398d9a 100644
@@ -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:
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v3 2/4 memory: omap-gpmc: Add support for GPMC on AM64 SoC

In reply to 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.

---
 drivers/memory/omap-gpmc.c | 40 ++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)
drivers/memory/omap-gpmc.c +30 -10
index be0858bff4d3..624153048182 100644
@@ -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;
Signature · 1 line
2.17.1
author maintainer
#3 lore raw

PATCH v3 3/4 memory: omap-gpmc: Use a compatible match table when checking for NAND controller

In reply to Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +7 -1
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +1 -1
index b26d4947af02..fff834ee726f 100644
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };
include/linux/platform_data/mtd-nand-omap2.h +5 -0
index de6ada739121..e1bb90a8db03 100644
@@ -61,4 +61,9 @@ struct gpmc_nand_regs {
 	void __iomem	*gpmc_bch_result5[GPMC_BCH_NUM_REMAINDER];
 	void __iomem	*gpmc_bch_result6[GPMC_BCH_NUM_REMAINDER];
 };
+
+#if defined(CONFIG_MTD_NAND_OMAP2)
+extern const struct of_device_id omap_nand_ids[];
+#endif
+
 #endif
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v3 3/4] memory: omap-gpmc: Use a compatible match table when checking for NAND controller

Quoted 23 lines · Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +1 -0
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",

drivers/memory/omap-gpmc.c static int gpmc_probe_generic_child(struct platform_device *pdev, · line 2187

Quoted 5 lines
drivers/memory/omap-gpmc.c +1 -1
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)

if (IS_ENABLED()) is preferred. If needed, you could make omap_nand_ids symbol visible always (so without ifdef around it), because extern structure should not have impact when not defined (if I recall correctly...).

Quoted 13 lines
drivers/memory/omap-gpmc.c +5 -0
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +0 -0
index b26d4947af02..fff834ee726f 100644

drivers/mtd/nand/raw/omap2.c static int omap_nand_remove(struct platform_device *pdev) · line 2358

Quoted 8 lines
drivers/mtd/nand/raw/omap2.c +1 -1
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };

I think OMAP2 NAND driver can be a module, so this should have EXPORT_SYMBOL.

Quoted 6 lines
include/linux/platform_data/mtd-nand-omap2.h +0 -0
index de6ada739121..e1bb90a8db03 100644

include/linux/platform_data/mtd-nand-omap2.h struct gpmc_nand_regs { · line 69

Quoted 9 lines
include/linux/platform_data/mtd-nand-omap2.h +5 -0
@@ -61,4 +61,9 @@ struct gpmc_nand_regs {
 	void __iomem	*gpmc_bch_result5[GPMC_BCH_NUM_REMAINDER];
 	void __iomem	*gpmc_bch_result6[GPMC_BCH_NUM_REMAINDER];
 };
+
+#if defined(CONFIG_MTD_NAND_OMAP2)
+extern const struct of_device_id omap_nand_ids[];
+#endif
+
 #endif

Best regards,
Krzysztof

author maintainer
#5 lore raw

Re: [PATCH v3 3/4] memory: omap-gpmc: Use a compatible match table when checking for NAND controller

Quoted 27 lines · Krzysztof Kozlowski
Quoted 26 lines · Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +1 -0
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
Quoted 7 lines

drivers/memory/omap-gpmc.c static int gpmc_probe_generic_child(struct platform_device *pdev, · line 2187

Quoted 2 lines
drivers/memory/omap-gpmc.c +1 -1
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)

if (IS_ENABLED()) is preferred. If needed, you could make omap_nand_ids symbol visible always (so without ifdef around it), because extern structure should not have impact when not defined (if I recall correctly...).

OK.

Quoted 17 lines
Quoted 17 lines
drivers/memory/omap-gpmc.c +5 -0
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +0 -0
index b26d4947af02..fff834ee726f 100644
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
Quoted 8 lines

drivers/mtd/nand/raw/omap2.c static int omap_nand_remove(struct platform_device *pdev) · line 2358

Quoted 5 lines
drivers/mtd/nand/raw/omap2.c +1 -1
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };

I think OMAP2 NAND driver can be a module, so this should have EXPORT_SYMBOL.

Indeed. Good catch!

Quoted 12 lines
Quoted 12 lines
include/linux/platform_data/mtd-nand-omap2.h +3 -0
index de6ada739121..e1bb90a8db03 100644
@@ -61,4 +61,9 @@ struct gpmc_nand_regs {
 	void __iomem	*gpmc_bch_result5[GPMC_BCH_NUM_REMAINDER];
 	void __iomem	*gpmc_bch_result6[GPMC_BCH_NUM_REMAINDER];
 };
+
+#if defined(CONFIG_MTD_NAND_OMAP2)
+extern const struct of_device_id omap_nand_ids[];
Quoted 9 lines

include/linux/platform_data/mtd-nand-omap2.h struct gpmc_nand_regs { · line 69

Quoted 4 lines
include/linux/platform_data/mtd-nand-omap2.h +2 -0
+#endif
+
 #endif

Best regards,
Krzysztof

cheers,
-roger

author maintainer
#6 lore raw

Re: [PATCH v3 3/4] memory: omap-gpmc: Use a compatible match table when checking for NAND controller

In reply to Krzysztof Kozlowski
Quoted 51 lines · Krzysztof Kozlowski
Quoted 23 lines · Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +1 -0
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",

drivers/memory/omap-gpmc.c static int gpmc_probe_generic_child(struct platform_device *pdev, · line 2187

Quoted 5 lines
drivers/memory/omap-gpmc.c +1 -1
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)

if (IS_ENABLED()) is preferred. If needed, you could make omap_nand_ids symbol visible always (so without ifdef around it), because extern structure should not have impact when not defined (if I recall correctly...).

Quoted 16 lines
drivers/memory/omap-gpmc.c +5 -0
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +0 -0
index b26d4947af02..fff834ee726f 100644
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
Quoted 8 lines

drivers/mtd/nand/raw/omap2.c static int omap_nand_remove(struct platform_device *pdev) · line 2358

Quoted 5 lines
drivers/mtd/nand/raw/omap2.c +1 -1
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };

I think OMAP2 NAND driver can be a module, so this should have EXPORT_SYMBOL.

To make it work in all combinations (e.g. omap_gpmc built in and nand/raw/omap2.c as module) I had to define omap_nand_ids table as static in the linux/platform_data/mtd-nand-omap2.h header.

EXPORT_SYMBOL will of course be not required there. ;)

Quoted 12 lines
Quoted 12 lines
include/linux/platform_data/mtd-nand-omap2.h +3 -0
index de6ada739121..e1bb90a8db03 100644
@@ -61,4 +61,9 @@ struct gpmc_nand_regs {
 	void __iomem	*gpmc_bch_result5[GPMC_BCH_NUM_REMAINDER];
 	void __iomem	*gpmc_bch_result6[GPMC_BCH_NUM_REMAINDER];
 };
+
+#if defined(CONFIG_MTD_NAND_OMAP2)
+extern const struct of_device_id omap_nand_ids[];
Quoted 9 lines

include/linux/platform_data/mtd-nand-omap2.h struct gpmc_nand_regs { · line 69

Quoted 4 lines
include/linux/platform_data/mtd-nand-omap2.h +2 -0
+#endif
+
 #endif

Best regards,
Krzysztof

cheers,
-roger

#7 lore raw

Re: [PATCH v3 3/4] memory: omap-gpmc: Use a compatible match table when checking for NAND controller

Quoted 63 lines · Roger Quadros
Quoted 51 lines · Krzysztof Kozlowski
Quoted 23 lines · Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +1 -0
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",

drivers/memory/omap-gpmc.c static int gpmc_probe_generic_child(struct platform_device *pdev, · line 2187

Quoted 5 lines
drivers/memory/omap-gpmc.c +1 -1
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)

if (IS_ENABLED()) is preferred. If needed, you could make omap_nand_ids symbol visible always (so without ifdef around it), because extern structure should not have impact when not defined (if I recall correctly...).

Quoted 16 lines
drivers/memory/omap-gpmc.c +5 -0
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +0 -0
index b26d4947af02..fff834ee726f 100644
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
Quoted 8 lines

drivers/mtd/nand/raw/omap2.c static int omap_nand_remove(struct platform_device *pdev) · line 2358

Quoted 5 lines
drivers/mtd/nand/raw/omap2.c +1 -1
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };

I think OMAP2 NAND driver can be a module, so this should have EXPORT_SYMBOL.

Quoted 6 lines

To make it work in all combinations (e.g. omap_gpmc built in and nand/raw/omap2.c as module) I had to define omap_nand_ids table as static in the linux/platform_data/mtd-nand-omap2.h header.

EXPORT_SYMBOL will of course be not required there. ;)

Which case exactly does it require to be static in the header?

Best regards,
Krzysztof

author maintainer
#8 lore raw

Re: [PATCH v3 3/4] memory: omap-gpmc: Use a compatible match table when checking for NAND controller

Quoted 64 lines · Krzysztof Kozlowski
Quoted 63 lines · Roger Quadros
Quoted 59 lines · Krzysztof Kozlowski
Quoted 23 lines · Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +1 -0
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",

drivers/memory/omap-gpmc.c static int gpmc_probe_generic_child(struct platform_device *pdev, · line 2187

Quoted 5 lines
drivers/memory/omap-gpmc.c +1 -1
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)

if (IS_ENABLED()) is preferred. If needed, you could make omap_nand_ids symbol visible always (so without ifdef around it), because extern structure should not have impact when not defined (if I recall correctly...).

Quoted 13 lines
drivers/memory/omap-gpmc.c +5 -0
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +0 -0
index b26d4947af02..fff834ee726f 100644

drivers/mtd/nand/raw/omap2.c static int omap_nand_remove(struct platform_device *pdev) · line 2358

Quoted 8 lines
drivers/mtd/nand/raw/omap2.c +1 -1
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };

I think OMAP2 NAND driver can be a module, so this should have EXPORT_SYMBOL.

Quoted 7 lines
Quoted 6 lines

To make it work in all combinations (e.g. omap_gpmc built in and nand/raw/omap2.c as module) I had to define omap_nand_ids table as static in the linux/platform_data/mtd-nand-omap2.h header.

EXPORT_SYMBOL will of course be not required there. ;)

Which case exactly does it require to be static in the header?

Maybe there is a better way to do it.
e.g. If omap_gpmc.c is built-in and nand/raw/omap2.c is not built or built as a module, what better way we can use?

--
cheers,
-roger

#9 lore raw

Re: [PATCH v3 3/4] memory: omap-gpmc: Use a compatible match table when checking for NAND controller

Quoted 71 lines · Roger Quadros
Quoted 68 lines · Krzysztof Kozlowski
Quoted 67 lines · Roger Quadros
Quoted 51 lines · Krzysztof Kozlowski
Quoted 23 lines · Roger Quadros

As more compatibles can be added to the GPMC NAND controller driver use a compatible match table.

---
 drivers/memory/omap-gpmc.c                   | 8 +++++++-
 drivers/mtd/nand/raw/omap2.c                 | 2 +-
 include/linux/platform_data/mtd-nand-omap2.h | 5 +++++
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/memory/omap-gpmc.c +1 -0
index 624153048182..814ddb45c13d 100644
@@ -2091,6 +2091,7 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 	u32 val;
 	struct gpio_desc *waitpin_desc = NULL;
 	struct gpmc_device *gpmc = platform_get_drvdata(pdev);
+	bool is_nand = false;
 
 	if (of_property_read_u32(child, "reg", &cs) < 0) {
 		dev_err(&pdev->dev, "%pOF has no 'reg' property\n",

drivers/memory/omap-gpmc.c static int gpmc_probe_generic_child(struct platform_device *pdev, · line 2187

Quoted 5 lines
drivers/memory/omap-gpmc.c +1 -1
@@ -2183,7 +2184,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
 		}
 	}
 
-	if (of_device_is_compatible(child, "ti,omap2-nand")) {
+#if defined(CONFIG_MTD_NAND_OMAP2)

if (IS_ENABLED()) is preferred. If needed, you could make omap_nand_ids symbol visible always (so without ifdef around it), because extern structure should not have impact when not defined (if I recall correctly...).

Quoted 16 lines
drivers/memory/omap-gpmc.c +5 -0
+	if (of_match_node(omap_nand_ids, child))
+		is_nand = true;
+#endif
+
+	if (is_nand) {
 		/* NAND specific setup */
 		val = 8;
 		of_property_read_u32(child, "nand-bus-width", &val);
drivers/mtd/nand/raw/omap2.c +0 -0
index b26d4947af02..fff834ee726f 100644
@@ -2352,7 +2352,7 @@ static int omap_nand_remove(struct platform_device *pdev)
 	return ret;
 }
 
Quoted 8 lines

drivers/mtd/nand/raw/omap2.c static int omap_nand_remove(struct platform_device *pdev) · line 2358

Quoted 5 lines
drivers/mtd/nand/raw/omap2.c +1 -1
-static const struct of_device_id omap_nand_ids[] = {
+const struct of_device_id omap_nand_ids[] = {
 	{ .compatible = "ti,omap2-nand", },
 	{},
 };

I think OMAP2 NAND driver can be a module, so this should have EXPORT_SYMBOL.

To make it work in all combinations (e.g. omap_gpmc built in and nand/raw/omap2.c as module) I had to define omap_nand_ids table as static in the linux/platform_data/mtd-nand-omap2.h header.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

EXPORT_SYMBOL will of course be not required there. ;)

Which case exactly does it require to be static in the header?

Maybe there is a better way to do it.
e.g. If omap_gpmc.c is built-in and nand/raw/omap2.c is not built or built as a module, what better way we can use?

Ah, you are right, that is the tricky configuration. It could be a separate built-in source file which is being selected by OMAP_GPMC and MTD_NAND_OMAP2, but it would be also an overkill for one-item array.

I guess your solution with header is the easiest.

Best regards,
Krzysztof

author maintainer
#10 lore raw

PATCH v3 4/4 arm64: arch_k3: Select GPMC device driver

In reply to 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.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
index 1aa8b7073218..f447b120f863 100644
@@ -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.
Signature · 1 line
2.17.1
Acked-by on v3 4/4
#11 lore raw

Re: [PATCH v3 4/4] arm64: arch_k3: Select GPMC device driver

Quoted 9 lines · 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.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)

FWIW:

Other option would be to make it "default ARCH_K3" in OMAP_GPMC, but this is fine for me.

Best regards,
Krzysztof

#12 lore raw

Re: [PATCH v3 4/4] arm64: arch_k3: Select GPMC device driver

In reply to Roger Quadros
Quoted 14 lines · 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.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +0 -0
index 1aa8b7073218..f447b120f863 100644

arch/arm64/Kconfig.platforms config ARCH_K3 · line 125

Quoted 4 lines
arch/arm64/Kconfig.platforms +1 -0
@@ -122,6 +122,7 @@ config ARCH_K3
 	select TI_SCI_INTR_IRQCHIP
 	select TI_SCI_INTA_IRQCHIP
 	select TI_K3_SOCINFO
+	select OMAP_GPMC

I dont think GPMC should be part of the select list here. instead defconfig patch is prefered. the existance and usage of the same are limited and it is NOT a core functional component required to boot up a K3 platform.

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
author maintainer
#13 lore raw

Re: [PATCH v3 4/4] arm64: arch_k3: Select GPMC device driver

Nishanth,

Quoted 10 lines · Nishanth Menon
Quoted 9 lines · 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.

---
 arch/arm64/Kconfig.platforms | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

arch/arm64/Kconfig.platforms config ARCH_K3 · line 125

Quoted 9 lines
arch/arm64/Kconfig.platforms +1 -0
index 1aa8b7073218..f447b120f863 100644
@@ -122,6 +122,7 @@ config ARCH_K3
 	select TI_SCI_INTR_IRQCHIP
 	select TI_SCI_INTA_IRQCHIP
 	select TI_K3_SOCINFO
+	select OMAP_GPMC

I dont think GPMC should be part of the select list here. instead defconfig patch is prefered. the existance and usage of the same are limited and it is NOT a core functional component required to boot up a K3 platform.

Since OMAP_GPMC is not visible it cannot be enabled via defconfig file. I tried to make it visible in earlier revision of this patchset but it looks like OMAP_GPMC config was meant to be not a visible option form the beginning.

All legacy platforms have been selecting it in some way or the other but I agree with you that selecting it at SOC level may not be the best option.

If not here, any suggestions where should I select it from? Maybe from mtd/nand/raw/Kconfig if GPMC NAND driver is enabled?

cheers,
-roger