Skip to contentSkip to conversation

ARM: davinci: remove the mach-specific aemif driver - part 1

PATCH RESEND In review Bartosz Golaszewski 4 participants 18 messages Apr 17, 2018 – Apr 25, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover ARM: davinci: remove the mach-specific aemif driver - part 1

From: Bartosz Golaszewski <[email protected]>

This is the first part of changes required to remove duplicate aemif support from mach-davinci.

I actually noticed that one of my previous changes from 2017 broke nand in legacy mode - the clock lookup no longer works. This series addresses it as well.

First patch just uses a static string for the ti-aemif driver name.

The second adds support for board files to the aemif driver.

Last two add nand support to da850-lcdk in legacy mode and make da850-evm use the platform driver instead of the mach-specific one.

If these patches get accepted, I'll prepere a follow-up moving all other boards to the new platform driver.

This series applies on top of v8 of David Lechner's CCF series.

v1 -> v2:
- drop the first two patches, which are no longer needed with David's psc driver

Bartosz Golaszewski (4):
memory: aemif: don't rely on kbuild for driver's name
memory: aemif: add support for board files
ARM: davinci: add aemif & nand support to da850-lcdk in legacy mode
ARM: davinci: use aemif platform driver in legacy mode for da850-evm

 arch/arm/mach-davinci/board-da850-evm.c     |  93 +++++++-------
 arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
 drivers/memory/ti-aemif.c                   |  59 +++++----
 include/linux/platform_data/ti-aemif.h      |   9 ++
 4 files changed, 230 insertions(+), 63 deletions(-)
Signature · 1 line
2.17.0
#1 lore raw

PATCH RESEND v2 1/4 memory: aemif: don't rely on kbuild for driver's name

From: Bartosz Golaszewski <[email protected]>

We want to use aemif from board files. Use a static name in the driver's code.

---
 drivers/memory/ti-aemif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/ti-aemif.c +1 -1
index 2744b1b91b57..588e58d40d1b 100644
@@ -422,7 +422,7 @@ static struct platform_driver aemif_driver = {
 	.probe = aemif_probe,
 	.remove = aemif_remove,
 	.driver = {
-		.name = KBUILD_MODNAME,
+		.name = "ti-aemif",
 		.of_match_table = of_match_ptr(aemif_of_match),
 	},
 };
Signature · 1 line
2.17.0
#2 lore raw

PATCH RESEND v2 2/4 memory: aemif: add support for board files

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Currently aemif is supported in two places separately. By the platform driver in drivers/memory and by a hand crafted driver in mach-davinci.

We want to drop the latter but also keep the legacy mode. Add support for board files to the aemif driver.

The new structure in platform data currently only contains the chip select number, since currently existing users don't require anything else, but it can be extended in the future.

---
 drivers/memory/ti-aemif.c              | 57 +++++++++++++++++---------
 include/linux/platform_data/ti-aemif.h |  9 ++++
 2 files changed, 46 insertions(+), 20 deletions(-)
drivers/memory/ti-aemif.c +37 -20
index 588e58d40d1b..27d2b076f465 100644
@@ -339,9 +339,6 @@ static int aemif_probe(struct platform_device *pdev)
 	struct aemif_platform_data *pdata;
 	struct of_dev_auxdata *dev_lookup;
 
-	if (np == NULL)
-		return 0;
-
 	aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL);
 	if (!aemif)
 		return -ENOMEM;
@@ -363,8 +360,10 @@ static int aemif_probe(struct platform_device *pdev)
 
 	aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC;
 
-	if (of_device_is_compatible(np, "ti,da850-aemif"))
+	if (np && of_device_is_compatible(np, "ti,da850-aemif"))
 		aemif->cs_offset = 2;
+	else if (pdata)
+		aemif->cs_offset = pdata->cs_offset;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	aemif->base = devm_ioremap_resource(dev, res);
@@ -373,15 +372,23 @@ static int aemif_probe(struct platform_device *pdev)
 		goto error;
 	}
 
-	/*
-	 * For every controller device node, there is a cs device node that
-	 * describe the bus configuration parameters. This functions iterate
-	 * over these nodes and update the cs data array.
-	 */
-	for_each_available_child_of_node(np, child_np) {
-		ret = of_aemif_parse_abus_config(pdev, child_np);
-		if (ret < 0)
-			goto error;
+	if (np) {
+		/*
+		 * For every controller device node, there is a cs device node
+		 * that describe the bus configuration parameters. This
+		 * functions iterate over these nodes and update the cs data
+		 * array.
+		 */
+		for_each_available_child_of_node(np, child_np) {
+			ret = of_aemif_parse_abus_config(pdev, child_np);
+			if (ret < 0)
+				goto error;
+		}
+	} else if (pdata && pdata->num_abus_data > 0) {
+		for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
+			aemif->cs_data[i].cs = pdata->abus_data->cs;
+			aemif_get_hw_params(pdev, i);
+		}
 	}
 
 	for (i = 0; i < aemif->num_cs; i++) {
@@ -394,14 +401,24 @@ static int aemif_probe(struct platform_device *pdev)
 	}
 
 	/*
-	 * Create a child devices explicitly from here to
-	 * guarantee that the child will be probed after the AEMIF timing
-	 * parameters are set.
+	 * Create a child devices explicitly from here to guarantee that the
+	 * child will be probed after the AEMIF timing parameters are set.
 	 */
-	for_each_available_child_of_node(np, child_np) {
-		ret = of_platform_populate(child_np, NULL, dev_lookup, dev);
-		if (ret < 0)
-			goto error;
+	if (np) {
+		for_each_available_child_of_node(np, child_np) {
+			ret = of_platform_populate(child_np, NULL,
+						   dev_lookup, dev);
+			if (ret < 0)
+				goto error;
+		}
+	} else {
+		for (i = 0; i < pdata->num_sub_devices; i++) {
+			ret = platform_device_register(&pdata->sub_devices[i]);
+			if (ret) {
+				dev_warn(dev, "Error register sub device %s\n",
+					 pdata->sub_devices[i].name);
+			}
+		}
 	}
 
 	return 0;
include/linux/platform_data/ti-aemif.h +9 -0
index ac72e115093c..dfe8901128c9 100644
@@ -16,8 +16,17 @@
 
 #include <linux/of_platform.h>
 
+struct aemif_abus_data {
+	u32 cs;
+};
+
 struct aemif_platform_data {
 	struct of_dev_auxdata *dev_lookup;
+	u32 cs_offset;
+	struct aemif_abus_data *abus_data;
+	size_t num_abus_data;
+	struct platform_device *sub_devices;
+	size_t num_sub_devices;
 };
 
 #endif /* __TI_DAVINCI_AEMIF_DATA_H__ */
Signature · 1 line
2.17.0
#3 lore raw

Re: [RESEND PATCH v2 2/4] memory: aemif: add support for board files

Quoted 37 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Currently aemif is supported in two places separately. By the platform driver in drivers/memory and by a hand crafted driver in mach-davinci.

We want to drop the latter but also keep the legacy mode. Add support for board files to the aemif driver.

The new structure in platform data currently only contains the chip select number, since currently existing users don't require anything else, but it can be extended in the future.

---
 drivers/memory/ti-aemif.c              | 57 +++++++++++++++++---------
 include/linux/platform_data/ti-aemif.h |  9 ++++
 2 files changed, 46 insertions(+), 20 deletions(-)
drivers/memory/ti-aemif.c +2 -7
index 588e58d40d1b..27d2b076f465 100644
@@ -394,14 +401,24 @@ static int aemif_probe(struct platform_device *pdev)
 	}
 
 	/*
-	 * Create a child devices explicitly from here to
-	 * guarantee that the child will be probed after the AEMIF timing
-	 * parameters are set.
+	 * Create a child devices explicitly from here to guarantee that the
+	 * child will be probed after the AEMIF timing parameters are set.
 	 */
-	for_each_available_child_of_node(np, child_np) {
-		ret = of_platform_populate(child_np, NULL, dev_lookup, dev);
-		if (ret < 0)
-			goto error;

drivers/memory/ti-aemif.c static int aemif_probe(struct platform_device *pdev) · line 416

Quoted 10 lines
drivers/memory/ti-aemif.c +10 -0
+	if (np) {
+		for_each_available_child_of_node(np, child_np) {
+			ret = of_platform_populate(child_np, NULL,
+						   dev_lookup, dev);
+			if (ret < 0)
+				goto error;
+		}
+	} else {
+		for (i = 0; i < pdata->num_sub_devices; i++) {
+			ret = platform_device_register(&pdata->sub_devices[i]);

Before doing this can we make aemif device the parent of the sub_device?

Quoted 17 lines
drivers/memory/ti-aemif.c +5 -0
+			if (ret) {
+				dev_warn(dev, "Error register sub device %s\n",
+					 pdata->sub_devices[i].name);
+			}
+		}
 	}
 
 	return 0;
include/linux/platform_data/ti-aemif.h +1 -0
index ac72e115093c..dfe8901128c9 100644
@@ -16,8 +16,17 @@
 
 #include <linux/of_platform.h>
 
+struct aemif_abus_data {

include/linux/platform_data/ti-aemif.h line 29

Quoted 10 lines
include/linux/platform_data/ti-aemif.h +8 -0
+	u32 cs;
+};
+
 struct aemif_platform_data {
 	struct of_dev_auxdata *dev_lookup;
+	u32 cs_offset;
+	struct aemif_abus_data *abus_data;
+	size_t num_abus_data;
+	struct platform_device *sub_devices;
+	size_t num_sub_devices;

It will be nice to add documentation for these members.

Thanks,
Sekhar

#4 lore raw

PATCH RESEND v2 3/4 ARM: davinci: add aemif & nand support to da850-lcdk in legacy mode

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now have support for aemif & nand from board files. As an example add support for nand to da850-lcdk in legacy mode.

---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
 1 file changed, 132 insertions(+)
arch/arm/mach-davinci/board-omapl138-hawk.c +132 -0
index 6c997c59a3cd..9c3de56b54e4 100644
@@ -16,6 +16,11 @@
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
+#include <linux/mtd/rawnand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
 	gpiod_remove_lookup_table(&mmc_gpios_table);
 }
 
+static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
+	{
+		.name		= "u-boot env",
+		.offset		= 0,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	 },
+	{
+		.name		= "u-boot",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	},
+	{
+		.name		= "free space",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+		.mask_flags	= 0,
+	},
+};
+
+static struct davinci_aemif_timing omapl138_hawk_nandflash_timing = {
+	.wsetup		= 24,
+	.wstrobe	= 21,
+	.whold		= 14,
+	.rsetup		= 19,
+	.rstrobe	= 50,
+	.rhold		= 0,
+	.ta		= 20,
+};
+
+static struct davinci_nand_pdata omapl138_hawk_nandflash_data = {
+	.parts		= omapl138_hawk_nandflash_partition,
+	.nr_parts	= ARRAY_SIZE(omapl138_hawk_nandflash_partition),
+	.ecc_mode	= NAND_ECC_HW,
+	.ecc_bits	= 4,
+	.bbt_options	= NAND_BBT_USE_FLASH,
+	.options	= NAND_BUSWIDTH_16,
+	.timing		= &omapl138_hawk_nandflash_timing,
+	.mask_chipsel	= 0,
+	.mask_ale	= 0,
+	.mask_cle	= 0,
+};
+
+static struct resource omapl138_hawk_nandflash_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CS3_BASE,
+		.end	= DA8XX_AEMIF_CS3_BASE + SZ_32M,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct resource omapl138_hawk_aemif_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K,
+		.flags	= IORESOURCE_MEM,
+	}
+};
+
+static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
+	{
+		.cs	= 3,
+	}
+};
+
+static struct platform_device omapl138_hawk_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,
+		.dev		= {
+			.platform_data	= &omapl138_hawk_nandflash_data,
+		},
+		.resource	= omapl138_hawk_nandflash_resource,
+		.num_resources	= ARRAY_SIZE(omapl138_hawk_nandflash_resource),
+		.id		= 0,
+	}
+};
+
+static struct aemif_platform_data omapl138_hawk_aemif_pdata = {
+	.cs_offset = 2,
+	.abus_data = omapl138_hawk_aemif_abus_data,
+	.num_abus_data = ARRAY_SIZE(omapl138_hawk_aemif_abus_data),
+	.sub_devices = omapl138_hawk_aemif_devices,
+	.num_sub_devices = ARRAY_SIZE(omapl138_hawk_aemif_devices),
+};
+
+static struct platform_device omapl138_hawk_aemif_device = {
+	.name		= "ti-aemif",
+	.dev = {
+		.platform_data	= &omapl138_hawk_aemif_pdata,
+	},
+	.resource	= omapl138_hawk_aemif_resource,
+	.num_resources	= ARRAY_SIZE(omapl138_hawk_aemif_resource),
+	.id		= -1,
+};
+
+static const short omapl138_hawk_nand_pins[] = {
+	DA850_EMA_WAIT_1, DA850_NEMA_OE, DA850_NEMA_WE, DA850_NEMA_CS_3,
+	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
+	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
+	DA850_EMA_D_8, DA850_EMA_D_9, DA850_EMA_D_10, DA850_EMA_D_11,
+	DA850_EMA_D_12, DA850_EMA_D_13, DA850_EMA_D_14, DA850_EMA_D_15,
+	DA850_EMA_A_1, DA850_EMA_A_2,
+	-1
+};
+
+static int omapl138_hawk_register_aemif(void)
+{
+	int ret;
+
+	ret = davinci_cfg_reg_list(omapl138_hawk_nand_pins);
+	if (ret)
+		pr_warn("%s: NAND mux setup failed: %d\n", __func__, ret);
+
+	return platform_device_register(&omapl138_hawk_aemif_device);
+}
+
 static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);
 static da8xx_ocic_handler_t hawk_usb_ocic_handler;
 
@@ -294,6 +422,10 @@ static __init void omapl138_hawk_init(void)
 
 	omapl138_hawk_usb_init();
 
+	ret = omapl138_hawk_register_aemif();
+	if (ret)
+		pr_warn("%s: aemif registration failed: %d\n", __func__, ret);
+
 	ret = da8xx_register_watchdog();
 	if (ret)
 		pr_warn("%s: watchdog registration failed: %d\n",
Signature · 1 line
2.17.0
#5 lore raw

Re: [RESEND PATCH v2 3/4] ARM: davinci: add aemif & nand support to da850-lcdk in legacy mode

Quoted 4 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now have support for aemif & nand from board files. As an example add support for nand to da850-lcdk in legacy mode.

Hawkboard is a separate board of its own, although closely related to LCDK. Lets refer to it as hawkboard itself, instead of "LCDK in legacy mode". So:

ARM: davinci: omapl138-hawk: ...

Quoted 27 lines
---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
 1 file changed, 132 insertions(+)
arch/arm/mach-davinci/board-omapl138-hawk.c +6 -0
index 6c997c59a3cd..9c3de56b54e4 100644
@@ -16,6 +16,11 @@
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
+#include <linux/mtd/rawnand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
 	gpiod_remove_lookup_table(&mmc_gpios_table);
 }
 
+static struct mtd_partition omapl138_hawk_nandflash_partition[] = {

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 180

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +10 -0
+	{
+		.name		= "u-boot env",
+		.offset		= 0,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,
+	 },
+	{
+		.name		= "u-boot",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_128K,

Can you make it 512K as it is in da850-lcdk.dts ?

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +9 -0
+		.mask_flags	= MTD_WRITEABLE,
+	},
+	{
+		.name		= "free space",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+		.mask_flags	= 0,
+	},
+};
 

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 244

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +10 -0
+static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
+	{
+		.cs	= 3,
+	}
+};
+
+static struct platform_device omapl138_hawk_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,

Is there a reason for .id to be set to 1 here? Ideally it should be -1, I think since there is a single NAND on the board.

Note that I sent a patch dropping AEMIF clock acquisition from DaVinci NAND driver.

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 250

Quoted 6 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +6 -0
+		.dev		= {
+			.platform_data	= &omapl138_hawk_nandflash_data,
+		},
+		.resource	= omapl138_hawk_nandflash_resource,
+		.num_resources	= ARRAY_SIZE(omapl138_hawk_nandflash_resource),
+		.id		= 0,

This should have resulted in a double init warning?

Thanks,
Sekhar

#6 lore raw

Re: [RESEND PATCH v2 3/4] ARM: davinci: add aemif & nand support to da850-lcdk in legacy mode

2018-04-17 16:09 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 62 lines · Bartosz Golaszewski
Quoted 4 lines

From: Bartosz Golaszewski <[email protected]>

We now have support for aemif & nand from board files. As an example add support for nand to da850-lcdk in legacy mode.

Hawkboard is a separate board of its own, although closely related to LCDK. Lets refer to it as hawkboard itself, instead of "LCDK in legacy mode". So:

ARM: davinci: omapl138-hawk: ...

Quoted 27 lines
---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
 1 file changed, 132 insertions(+)
arch/arm/mach-davinci/board-omapl138-hawk.c +6 -0
index 6c997c59a3cd..9c3de56b54e4 100644
@@ -16,6 +16,11 @@
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
+#include <linux/mtd/rawnand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
      gpiod_remove_lookup_table(&mmc_gpios_table);
 }
 
+static struct mtd_partition omapl138_hawk_nandflash_partition[] = {

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 180

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +10 -0
+     {
+             .name           = "u-boot env",
+             .offset         = 0,
+             .size           = SZ_128K,
+             .mask_flags     = MTD_WRITEABLE,
+      },
+     {
+             .name           = "u-boot",
+             .offset         = MTDPART_OFS_APPEND,
+             .size           = SZ_128K,

Can you make it 512K as it is in da850-lcdk.dts ?

Quoted 9 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +9 -0
+             .mask_flags     = MTD_WRITEABLE,
+     },
+     {
+             .name           = "free space",
+             .offset         = MTDPART_OFS_APPEND,
+             .size           = MTDPART_SIZ_FULL,
+             .mask_flags     = 0,
+     },
+};
Quoted 14 lines

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 244

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +10 -0
+static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
+     {
+             .cs     = 3,
+     }
+};
+
+static struct platform_device omapl138_hawk_aemif_devices[] = {
+     {
+             .name           = "davinci_nand",
+             .id             = 1,

Is there a reason for .id to be set to 1 here? Ideally it should be -1, I think since there is a single NAND on the board.

The davinci nand driver uses pdev->id as the chipselect number. I guess this should be in the platform data. I'll send a patch for that.

Quoted 12 lines

Note that I sent a patch dropping AEMIF clock acquisition from DaVinci NAND driver.

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 250

Quoted 6 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +6 -0
+             .dev            = {
+                     .platform_data  = &omapl138_hawk_nandflash_data,
+             },
+             .resource       = omapl138_hawk_nandflash_resource,
+             .num_resources  = ARRAY_SIZE(omapl138_hawk_nandflash_resource),
+             .id             = 0,

This should have resulted in a double init warning?

It should, strange it didn't - at least for me.

Thanks,
Bart

#7 lore raw

Re: [RESEND PATCH v2 3/4] ARM: davinci: add aemif & nand support to da850-lcdk in legacy mode

Quoted 78 lines · Bartosz Golaszewski

2018-04-17 16:09 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 62 lines · Bartosz Golaszewski
Quoted 4 lines

From: Bartosz Golaszewski <[email protected]>

We now have support for aemif & nand from board files. As an example add support for nand to da850-lcdk in legacy mode.

Hawkboard is a separate board of its own, although closely related to LCDK. Lets refer to it as hawkboard itself, instead of "LCDK in legacy mode". So:

ARM: davinci: omapl138-hawk: ...

Quoted 27 lines
---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 132 ++++++++++++++++++++
 1 file changed, 132 insertions(+)
arch/arm/mach-davinci/board-omapl138-hawk.c +6 -0
index 6c997c59a3cd..9c3de56b54e4 100644
@@ -16,6 +16,11 @@
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/gpio-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
+#include <linux/mtd/rawnand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/platform_data/mtd-davinci.h>
+#include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -162,6 +167,129 @@ static __init void omapl138_hawk_mmc_init(void)
      gpiod_remove_lookup_table(&mmc_gpios_table);
 }
 
+static struct mtd_partition omapl138_hawk_nandflash_partition[] = {

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 180

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +10 -0
+     {
+             .name           = "u-boot env",
+             .offset         = 0,
+             .size           = SZ_128K,
+             .mask_flags     = MTD_WRITEABLE,
+      },
+     {
+             .name           = "u-boot",
+             .offset         = MTDPART_OFS_APPEND,
+             .size           = SZ_128K,

Can you make it 512K as it is in da850-lcdk.dts ?

Quoted 9 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +9 -0
+             .mask_flags     = MTD_WRITEABLE,
+     },
+     {
+             .name           = "free space",
+             .offset         = MTDPART_OFS_APPEND,
+             .size           = MTDPART_SIZ_FULL,
+             .mask_flags     = 0,
+     },
+};
Quoted 14 lines

arch/arm/mach-davinci/board-omapl138-hawk.c static __init void omapl138_hawk_mmc_init(void) · line 244

Quoted 10 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +10 -0
+static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
+     {
+             .cs     = 3,
+     }
+};
+
+static struct platform_device omapl138_hawk_aemif_devices[] = {
+     {
+             .name           = "davinci_nand",
+             .id             = 1,

Is there a reason for .id to be set to 1 here? Ideally it should be -1, I think since there is a single NAND on the board.

Quoted 2 lines

The davinci nand driver uses pdev->id as the chipselect number. I guess this should be in the platform data. I'll send a patch for that.

I remember that now. No need to change that, I think. Just a comment here would suffice.

Thanks,
Sekhar

#8 lore raw

PATCH RESEND v2 4/4 ARM: davinci: use aemif platform driver in legacy mode for da850-evm

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in aemif. Use the platform driver instead of the handcrafted API in da850-evm.

Note: the id of davinci_nand is changed to 0 in order to make it work with the new common-clock framework based psc driver.

---
 arch/arm/mach-davinci/board-da850-evm.c | 93 ++++++++++++++-----------
 1 file changed, 51 insertions(+), 42 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +51 -42
index 78a670aafea0..f1c2c8c8c4af 100644
@@ -33,6 +33,7 @@
 #include <linux/platform_data/gpio-davinci.h>
 #include <linux/platform_data/mtd-davinci.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/ti-aemif.h>
 #include <linux/platform_data/spi-davinci.h>
 #include <linux/platform_data/uio_pruss.h>
 #include <linux/regulator/machine.h>
@@ -185,16 +186,6 @@ static struct resource da850_evm_norflash_resource[] = {
 	},
 };
 
-static struct platform_device da850_evm_norflash_device = {
-	.name		= "physmap-flash",
-	.id		= 0,
-	.dev		= {
-		.platform_data  = &da850_evm_norflash_data,
-	},
-	.num_resources	= 1,
-	.resource	= da850_evm_norflash_resource,
-};
-
 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  * (128K blocks). It may be used instead of the (default) SPI flash
  * to boot, using TI's tools to install the secondary boot loader
@@ -265,37 +256,58 @@ static struct resource da850_evm_nandflash_resource[] = {
 	},
 };
 
-static struct platform_device da850_evm_nandflash_device = {
-	.name		= "davinci_nand",
-	.id		= 1,
-	.dev		= {
-		.platform_data	= &da850_evm_nandflash_data,
-	},
-	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
-	.resource	= da850_evm_nandflash_resource,
+static struct resource da850_evm_aemif_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K,
+		.flags	= IORESOURCE_MEM,
+	}
 };
 
-static struct platform_device *da850_evm_devices[] = {
-	&da850_evm_nandflash_device,
-	&da850_evm_norflash_device,
+static struct aemif_abus_data da850_evm_aemif_abus_data[] = {
+	{
+		.cs	= 3,
+	}
 };
 
-#define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
-#define DA8XX_AEMIF_ASIZE_16BIT		0x1
-
-static void __init da850_evm_init_nor(void)
-{
-	void __iomem *aemif_addr;
-
-	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
+static struct platform_device da850_evm_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 0,
+		.dev		= {
+			.platform_data	= &da850_evm_nandflash_data,
+		},
+		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
+		.resource	= da850_evm_nandflash_resource,
+	},
+	{
+		.name		= "physmap-flash",
+		.id		= 0,
+		.dev		= {
+			.platform_data  = &da850_evm_norflash_data,
+		},
+		.num_resources	= 1,
+		.resource	= da850_evm_norflash_resource,
+	}
+};
 
-	/* Configure data bus width of CS2 to 16 bit */
-	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
-		DA8XX_AEMIF_ASIZE_16BIT,
-		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
+static struct aemif_platform_data da850_evm_aemif_pdata = {
+	.cs_offset = 2,
+	.abus_data = da850_evm_aemif_abus_data,
+	.num_abus_data = ARRAY_SIZE(da850_evm_aemif_abus_data),
+	.sub_devices = da850_evm_aemif_devices,
+	.num_sub_devices = ARRAY_SIZE(da850_evm_aemif_devices),
+};
 
-	iounmap(aemif_addr);
-}
+static struct platform_device da850_evm_aemif_device = {
+	.name		= "ti-aemif",
+	.dev = {
+		.platform_data	= &da850_evm_aemif_pdata,
+	},
+	.resource	= da850_evm_aemif_resource,
+	.num_resources	= ARRAY_SIZE(da850_evm_aemif_resource),
+	.id		= -1,
+};
 
 static const short da850_evm_nand_pins[] = {
 	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
@@ -338,13 +350,10 @@ static inline void da850_evm_setup_nor_nand(void)
 			pr_warn("%s: NOR mux setup failed: %d\n",
 				__func__, ret);
 
-		da850_evm_init_nor();
-
-		platform_add_devices(da850_evm_devices,
-					ARRAY_SIZE(da850_evm_devices));
-
-		if (davinci_aemif_setup(&da850_evm_nandflash_device))
-			pr_warn("%s: Cannot configure AEMIF.\n", __func__);
+		ret = platform_device_register(&da850_evm_aemif_device);
+		if (ret)
+			pr_warn("%s: registering aemif failed: %d\n",
+				__func__, ret);
 	}
 }
 
Signature · 1 line
2.17.0
#9 lore raw

Re: [RESEND PATCH v2 4/4] ARM: davinci: use aemif platform driver in legacy mode for da850-evm

Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in aemif. Use the platform driver instead of the handcrafted API in da850-evm.

Note: the id of davinci_nand is changed to 0 in order to make it work with the new common-clock framework based psc driver.

Is this now needed after applying my patch dropping clock acquisition from DaVinci NAND driver?

Quoted 2 lines

Thanks,
Sekhar

#10 lore raw

Re: [RESEND PATCH v2 4/4] ARM: davinci: use aemif platform driver in legacy mode for da850-evm

2018-04-17 16:12 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 12 lines · Bartosz Golaszewski
Quoted 7 lines

From: Bartosz Golaszewski <[email protected]>

We now support board files in aemif. Use the platform driver instead of the handcrafted API in da850-evm.

Note: the id of davinci_nand is changed to 0 in order to make it work with the new common-clock framework based psc driver.

Is this now needed after applying my patch dropping clock acquisition from DaVinci NAND driver?

Now that I realized that pdev->id matters for the driver as well, I'm thinking this may have broken the support. Unfortunately we don't have the nand extension for da850-evm to test it. I'll revert it to the previous value.

Bart

#11 lore raw
In reply to Bartosz Golaszewski

Hi Bartosz,

Quoted 13 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

This is the first part of changes required to remove duplicate aemif support from mach-davinci.

I actually noticed that one of my previous changes from 2017 broke nand in legacy mode - the clock lookup no longer works. This series addresses it as well.

First patch just uses a static string for the ti-aemif driver name.

The second adds support for board files to the aemif driver.

Quoted 7 lines

Last two add nand support to da850-lcdk in legacy mode and make da850-evm use the platform driver instead of the mach-specific one.

If these patches get accepted, I'll prepere a follow-up moving all other boards to the new platform driver.

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Thanks,
Sekhar

#12 lore raw

2018-04-17 12:53 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 22 lines

Hi Bartosz,

Quoted 19 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

This is the first part of changes required to remove duplicate aemif support from mach-davinci.

I actually noticed that one of my previous changes from 2017 broke nand in legacy mode - the clock lookup no longer works. This series addresses it as well.

First patch just uses a static string for the ti-aemif driver name.

The second adds support for board files to the aemif driver.

Last two add nand support to da850-lcdk in legacy mode and make da850-evm use the platform driver instead of the mach-specific one.

If these patches get accepted, I'll prepere a follow-up moving all other boards to the new platform driver.

Quoted 6 lines
Quoted 1 line

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Thanks,
Sekhar

Hi Sekhar,

yes, all of them. They're not linked to David's work in any way.

Bart

#13 lore raw

2018-04-17 14:36 GMT+02:00 Bartosz Golaszewski <[email protected]>:

Quoted 27 lines

2018-04-17 12:53 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 26 lines

Hi Bartosz,

Quoted 13 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

This is the first part of changes required to remove duplicate aemif support from mach-davinci.

I actually noticed that one of my previous changes from 2017 broke nand in legacy mode - the clock lookup no longer works. This series addresses it as well.

First patch just uses a static string for the ti-aemif driver name.

The second adds support for board files to the aemif driver.

Quoted 7 lines

Last two add nand support to da850-lcdk in legacy mode and make da850-evm use the platform driver instead of the mach-specific one.

If these patches get accepted, I'll prepere a follow-up moving all other boards to the new platform driver.

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Quoted 8 lines
Quoted 2 lines

Thanks,
Sekhar

Hi Sekhar,

yes, all of them. They're not linked to David's work in any way.

Bart

Oops, -ETOOFAST, I rebased it on top of David's v9, let me check how it works with mainline - it should be mostly fine.

Bart

#14 lore raw

2018-04-17 14:41 GMT+02:00 Bartosz Golaszewski <[email protected]>:

Quoted 33 lines

2018-04-17 14:36 GMT+02:00 Bartosz Golaszewski <[email protected]>:

Quoted 32 lines

2018-04-17 12:53 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 22 lines

Hi Bartosz,

Quoted 19 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

This is the first part of changes required to remove duplicate aemif support from mach-davinci.

I actually noticed that one of my previous changes from 2017 broke nand in legacy mode - the clock lookup no longer works. This series addresses it as well.

First patch just uses a static string for the ti-aemif driver name.

The second adds support for board files to the aemif driver.

Last two add nand support to da850-lcdk in legacy mode and make da850-evm use the platform driver instead of the mach-specific one.

If these patches get accepted, I'll prepere a follow-up moving all other boards to the new platform driver.

Quoted 6 lines
Quoted 1 line

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Thanks,
Sekhar

Hi Sekhar,

Quoted 8 lines
Quoted 3 lines

yes, all of them. They're not linked to David's work in any way.

Bart

Oops, -ETOOFAST, I rebased it on top of David's v9, let me check how it works with mainline - it should be mostly fine.

Bart

Ok, so the patches apply and build nicely on top of v4.17-rc1, but they only actually work with David's v9 branch. On the other hand nand doesn't work with mainline now anyway so I assume it's safe to apply them and wait for David's patches to be merged.

Thanks,
Bartosz

#15 lore raw
In reply to Bartosz Golaszewski
Quoted 2 lines · Bartosz Golaszewski

2018-04-17 12:53 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 1 line

Hi Bartosz,

[...]

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Hi Sekhar,

yes, all of them. They're not linked to David's work in any way.

Please separate the driver/emif/* patches from the series. These are not fixes so they are not rcx candidates. But will queue them up for next merge window. Thanks !!

#16 lore raw
Quoted 12 lines · Santosh Shilimkar
Quoted 2 lines · Bartosz Golaszewski

2018-04-17 12:53 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 1 line

Hi Bartosz,

[...]

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Quoted 7 lines
Quoted 4 lines

Hi Sekhar,

yes, all of them. They're not linked to David's work in any way.

Please separate the driver/emif/* patches from the series. These are not fixes so they are not rcx candidates. But will queue them up for next merge window. Thanks !!

Thanks Santosh! Can you please queue the drivers/emif/ patches on an immutable branch based off v4.17-rc1 which I can then merge to queue the platform patches?

Thanks,
Sekhar

#17 lore raw
Quoted 17 lines · Sekhar Nori
Quoted 16 lines · Santosh Shilimkar
Quoted 2 lines · Bartosz Golaszewski

2018-04-17 12:53 GMT+02:00 Sekhar Nori <[email protected]>:

Quoted 1 line

Hi Bartosz,

[...]

Quoted 10 lines
Quoted 4 lines
Quoted 1 line

This series applies on top of v8 of David Lechner's CCF series.

Are there any patches in the series that can safely be applied to v4.17-rc1?

Hi Sekhar,

yes, all of them. They're not linked to David's work in any way.

Quoted 8 lines
Quoted 3 lines

Please separate the driver/emif/* patches from the series. These are not fixes so they are not rcx candidates. But will queue them up for next merge window. Thanks !!

Thanks Santosh! Can you please queue the drivers/emif/ patches on an immutable branch based off v4.17-rc1 which I can then merge to queue the platform patches?

Sure. Will send a note once I get to it.

Regards,
Santosh