Skip to contentSkip to conversation

ARM: davinci: deduplicate aemif support

PATCH In review Bartosz Golaszewski 3 participants 22 messages Jun 25, 2018 – Jun 26, 2018

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

cover ARM: davinci: deduplicate aemif support

From: Bartosz Golaszewski <[email protected]>

This series moves all aemif/nand users to using the ti-aemif platform driver located in drivers/memory instead of the older API located in mach-davinci.

The first patch adds a necessary clock lookup and the last patch removes the duplicate aemif code.

Bartosz Golaszewski (9):
clk: davinci: psc-dm365: use two lookup entries for the aemif clock
ARM: davinci: omapl138-hawk: add aemif & nand support
ARM: davinci: da850-evm: use aemif platform driver in legacy mode
ARM: davinci: dm365-evm: use the ti-aemif soc driver
ARM: davinci: dm644x-evm: use aemif platform driver
ARM: davinci: da830-evm: use aemif platform driver
ARM: davinci: dm646x-evm: use aemif platform driver
ARM: davinci: mityomapl138: use aemif platform driver
ARM: davinci: kill davinci_aemif_setup()

 arch/arm/mach-davinci/Makefile                |   2 +-
 arch/arm/mach-davinci/aemif.c                 | 218 ------------------
 arch/arm/mach-davinci/board-da830-evm.c       |  56 ++++-
 arch/arm/mach-davinci/board-da850-evm.c       |  93 ++++----
 arch/arm/mach-davinci/board-dm365-evm.c       |  59 +++--
 arch/arm/mach-davinci/board-dm644x-evm.c      |  55 +++--
 arch/arm/mach-davinci/board-dm646x-evm.c      |  52 ++++-
 arch/arm/mach-davinci/board-mityomapl138.c    |  55 +++--
 arch/arm/mach-davinci/board-omapl138-hawk.c   | 132 +++++++++++
 drivers/clk/davinci/psc-dm365.c               |   3 +-
 .../linux/platform_data/mtd-davinci-aemif.h   |   1 -
 11 files changed, 400 insertions(+), 326 deletions(-)
 delete mode 100644 arch/arm/mach-davinci/aemif.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/9 clk: davinci: psc-dm365: use two lookup entries for the aemif clock

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its con_id and from the aemif driver by dev_id.

---
 drivers/clk/davinci/psc-dm365.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/davinci/psc-dm365.c +2 -1
index 8c73086cc676..c75424f4ea3b 100644
@@ -21,7 +21,8 @@ LPSC_CLKDEV1(mmcsd1_clkdev,		NULL,		"da830-mmc.1");
 LPSC_CLKDEV1(asp0_clkdev,		NULL,		"davinci-mcbsp");
 LPSC_CLKDEV1(usb_clkdev,		"usb",		NULL);
 LPSC_CLKDEV1(spi2_clkdev,		NULL,		"spi_davinci.2");
-LPSC_CLKDEV1(aemif_clkdev,		"aemif",	NULL);
+LPSC_CLKDEV2(aemif_clkdev,		"aemif",	NULL,
+					NULL,		"ti-aemif");
 LPSC_CLKDEV1(mmcsd0_clkdev,		NULL,		"da830-mmc.0");
 LPSC_CLKDEV1(i2c_clkdev,		NULL,		"i2c_davinci.1");
 LPSC_CLKDEV1(uart0_clkdev,		NULL,		"serial8250.0");
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

Quoted 4 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its con_id and from the aemif driver by dev_id.

What about the other SoCs? Don't they need this change as well?

Quoted 21 lines
---
  drivers/clk/davinci/psc-dm365.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/davinci/psc-dm365.c +2 -1
index 8c73086cc676..c75424f4ea3b 100644
@@ -21,7 +21,8 @@ LPSC_CLKDEV1(mmcsd1_clkdev,		NULL,		"da830-mmc.1");
  LPSC_CLKDEV1(asp0_clkdev,		NULL,		"davinci-mcbsp");
  LPSC_CLKDEV1(usb_clkdev,		"usb",		NULL);
  LPSC_CLKDEV1(spi2_clkdev,		NULL,		"spi_davinci.2");
-LPSC_CLKDEV1(aemif_clkdev,		"aemif",	NULL);
+LPSC_CLKDEV2(aemif_clkdev,		"aemif",	NULL,
+					NULL,		"ti-aemif");
  LPSC_CLKDEV1(mmcsd0_clkdev,		NULL,		"da830-mmc.0");
  LPSC_CLKDEV1(i2c_clkdev,		NULL,		"i2c_davinci.1");
  LPSC_CLKDEV1(uart0_clkdev,		NULL,		"serial8250.0");
#3 lore raw

Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:

Quoted 10 lines · Bartosz Golaszewski
Quoted 5 lines

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its con_id and from the aemif driver by dev_id.

What about the other SoCs? Don't they need this change as well?

So I double checked and turns out I missed one other board that's affected by this series and calls clk_get() from machine code:
dm644x-evm.

I'll fix it in v2.

Thanks,
Bart

Quoted 25 lines
Quoted 24 lines
---
  drivers/clk/davinci/psc-dm365.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/davinci/psc-dm365.c +2 -1
index 8c73086cc676..c75424f4ea3b 100644
@@ -21,7 +21,8 @@ LPSC_CLKDEV1(mmcsd1_clkdev,           NULL,
 "da830-mmc.1");
  LPSC_CLKDEV1(asp0_clkdev,             NULL,           "davinci-mcbsp");
  LPSC_CLKDEV1(usb_clkdev,              "usb",          NULL);
  LPSC_CLKDEV1(spi2_clkdev,             NULL,           "spi_davinci.2");
-LPSC_CLKDEV1(aemif_clkdev,             "aemif",        NULL);
+LPSC_CLKDEV2(aemif_clkdev,             "aemif",        NULL,
+                                       NULL,           "ti-aemif");
  LPSC_CLKDEV1(mmcsd0_clkdev,           NULL,           "da830-mmc.0");
  LPSC_CLKDEV1(i2c_clkdev,              NULL,           "i2c_davinci.1");
  LPSC_CLKDEV1(uart0_clkdev,            NULL,           "serial8250.0");
maintainer
#4 lore raw

Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

Quoted 9 lines · Bartosz Golaszewski

2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:

Quoted 8 lines · Bartosz Golaszewski
Quoted 5 lines

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its con_id and from the aemif driver by dev_id.

Quoted 8 lines
Quoted 2 lines

What about the other SoCs? Don't they need this change as well?

So I double checked and turns out I missed one other board that's affected by this series and calls clk_get() from machine code:
dm644x-evm.

I'll fix it in v2.

The ti-aemif platform driver also does clk_get(). Don't you need lookups to make that work as well? For example, DA830 doesn't have a clock lookup for aemif at all.

#5 lore raw

Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

2018-06-25 18:06 GMT+02:00 David Lechner <[email protected]>:

Quoted 21 lines · Bartosz Golaszewski
Quoted 20 lines

2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:

Quoted 13 lines · Bartosz Golaszewski
Quoted 6 lines

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its con_id and from the aemif driver by dev_id.

What about the other SoCs? Don't they need this change as well?

So I double checked and turns out I missed one other board that's affected by this series and calls clk_get() from machine code:
dm644x-evm.

Quoted 7 lines
Quoted 1 line

I'll fix it in v2.

The ti-aemif platform driver also does clk_get(). Don't you need lookups to make that work as well? For example, DA830 doesn't have a clock lookup for aemif at all.

Right, I'll check that too.

Thanks,
Bart

#6 lore raw

Re: [PATCH 1/9] clk: davinci: psc-dm365: use two lookup entries for the aemif clock

In reply to David Lechner

2018-06-25 18:06 GMT+02:00 David Lechner <[email protected]>:

Quoted 21 lines · Bartosz Golaszewski
Quoted 20 lines

2018-06-25 17:53 GMT+02:00 David Lechner <[email protected]>:

Quoted 13 lines · Bartosz Golaszewski
Quoted 6 lines

From: Bartosz Golaszewski <[email protected]>

We want to be able to get the clock both from the board file by its con_id and from the aemif driver by dev_id.

What about the other SoCs? Don't they need this change as well?

So I double checked and turns out I missed one other board that's affected by this series and calls clk_get() from machine code:
dm644x-evm.

Quoted 7 lines
Quoted 1 line

I'll fix it in v2.

The ti-aemif platform driver also does clk_get(). Don't you need lookups to make that work as well? For example, DA830 doesn't have a clock lookup for aemif at all.

This seems like a bug: in arch/arm/mach-davinci/aemif.c in current mainline we do call clk_get() for 'aemif' and it's called indirectly from board-da830-evm.c via davinci_aemif_setup().

I'll address this too in v2.

Bart

#7 lore raw

PATCH 2/9 ARM: davinci: omapl138-hawk: add aemif & nand support

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

---
 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 466e87b24e9a..02c0f36633e9 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>
@@ -166,6 +171,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_512K,
+		.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 = {
+	.core_chipsel	= 1,
+	.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),
+	}
+};
+
+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;
 
@@ -298,6 +426,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.1
maintainer
#8 lore raw

Re: [PATCH 2/9] ARM: davinci: omapl138-hawk: add aemif & nand support

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

Quoted 12 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-hawk.

---

arch/arm/mach-davinci/board-omapl138-hawk.c +4 -0
+static struct platform_device omapl138_hawk_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,

same comment as on da850-evm...

this might need id = 0 now.

Quoted 7 lines
arch/arm/mach-davinci/board-omapl138-hawk.c +7 -0
+		.dev		= {
+			.platform_data	= &omapl138_hawk_nandflash_data,
+		},
+		.resource	= omapl138_hawk_nandflash_resource,
+		.num_resources	= ARRAY_SIZE(omapl138_hawk_nandflash_resource),
+	}
+};
#9 lore raw

PATCH 3/9 ARM: davinci: da850-evm: use aemif platform driver in legacy mode

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da850-evm.

---
 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 442c16773f09..0ae7c47ed2b0 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
@@ -266,37 +257,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		= 1,
+		.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,
@@ -339,13 +351,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.1
maintainer
#10 lore raw

Re: [PATCH 3/9] ARM: davinci: da850-evm: use aemif platform driver in legacy mode

Quoted 10 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da850-evm.

---

arch/arm/mach-davinci/board-da850-evm.c +0 -1
-	iounmap(aemif_addr);

arch/arm/mach-davinci/board-da850-evm.c static struct resource da850_evm_nandflash_resource[] = { · line 311

Quoted 10 lines
arch/arm/mach-davinci/board-da850-evm.c +9 -1
-}
+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,
+};

Not essential, but it is nice to have the id right after name since they are closely related (as you did in several other instances in this same patch). For a second, I thought you forgot id = -1 here before I saw it.

maintainer
#11 lore raw

Re: [PATCH 3/9] ARM: davinci: da850-evm: use aemif platform driver in legacy mode

In reply to Bartosz Golaszewski
Quoted 15 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da850-evm.

---
  arch/arm/mach-davinci/board-da850-evm.c | 93 ++++++++++++++-----------
  1 file changed, 51 insertions(+), 42 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +0 -0
index 442c16773f09..0ae7c47ed2b0 100644

arch/arm/mach-davinci/board-da850-evm.c line 36

Quoted 4 lines
arch/arm/mach-davinci/board-da850-evm.c +1 -0
@@ -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>

alphabetical order would be after spi-davinci.h

Quoted 36 lines
arch/arm/mach-davinci/board-da850-evm.c +10 -13
  #include <linux/platform_data/spi-davinci.h>
  #include <linux/platform_data/uio_pruss.h>
  #include <linux/regulator/machine.h>
@@ -266,37 +257,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

arch/arm/mach-davinci/board-da850-evm.c static struct resource da850_evm_nandflash_resource[] = { · line 277

Quoted 10 lines
arch/arm/mach-davinci/board-da850-evm.c +4 -6
-
-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		= 1,

The existing clock lookup is for "davinci_nand.0". Might need to change id here.

Quoted 43 lines
arch/arm/mach-davinci/board-da850-evm.c +32 -6
+		.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,
#12 lore raw

PATCH 4/9 ARM: davinci: dm365-evm: use the ti-aemif soc driver

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in dm365-evm.

---
 arch/arm/mach-davinci/board-dm365-evm.c | 59 +++++++++++++++++++------
 1 file changed, 46 insertions(+), 13 deletions(-)
arch/arm/mach-davinci/board-dm365-evm.c +46 -13
index 307e88d99dd3..12b8d7b8c6b8 100644
@@ -28,6 +28,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/eeprom.h>
 #include <linux/v4l2-dv-timings.h>
+#include <linux/platform_data/ti-aemif.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -159,14 +160,47 @@ static struct resource davinci_nand_resources[] = {
 	},
 };
 
-static struct platform_device davinci_nand_device = {
-	.name			= "davinci_nand",
-	.id			= 0,
-	.num_resources		= ARRAY_SIZE(davinci_nand_resources),
-	.resource		= davinci_nand_resources,
-	.dev			= {
-		.platform_data	= &davinci_nand_data,
+static struct platform_device davinci_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 0,
+		.num_resources	= ARRAY_SIZE(davinci_nand_resources),
+		.resource	= davinci_nand_resources,
+		.dev		= {
+			.platform_data	= &davinci_nand_data,
+		},
+	}
+};
+
+static struct resource davinci_aemif_resources[] = {
+	{
+		.start		= DM365_ASYNC_EMIF_CONTROL_BASE,
+		.end		= DM365_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
+		.flags		= IORESOURCE_MEM,
+	},
+};
+
+static struct aemif_abus_data da850_evm_aemif_abus_data[] = {
+	{
+		.cs		= 1,
+	},
+};
+
+static struct aemif_platform_data davinci_aemif_pdata = {
+	.abus_data		= da850_evm_aemif_abus_data,
+	.num_abus_data		= ARRAY_SIZE(da850_evm_aemif_abus_data),
+	.sub_devices		= davinci_aemif_devices,
+	.num_sub_devices	= ARRAY_SIZE(davinci_aemif_devices),
+};
+
+static struct platform_device davinci_aemif_device = {
+	.name			= "ti-aemif",
+	.dev = {
+		.platform_data	= &davinci_aemif_pdata,
 	},
+	.resource		= davinci_aemif_resources,
+	.num_resources		= ARRAY_SIZE(davinci_aemif_resources),
+	.id			= -1,
 };
 
 static struct at24_platform_data eeprom_info = {
@@ -537,10 +571,6 @@ static void __init evm_init_i2c(void)
 	i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
 }
 
-static struct platform_device *dm365_evm_nand_devices[] __initdata = {
-	&davinci_nand_device,
-};
-
 static inline int have_leds(void)
 {
 #ifdef CONFIG_LEDS_CLASS
@@ -628,6 +658,7 @@ static void __init evm_init_cpld(void)
 	u8 mux, resets;
 	const char *label;
 	struct clk *aemif_clk;
+	int rc;
 
 	/* Make sure we can configure the CPLD through CS1.  Then
 	 * leave it on for later access to MMC and LED registers.
@@ -660,8 +691,10 @@ static void __init evm_init_cpld(void)
 		/* external keypad mux */
 		mux |= BIT(7);
 
-		platform_add_devices(dm365_evm_nand_devices,
-				ARRAY_SIZE(dm365_evm_nand_devices));
+		rc = platform_device_register(&davinci_aemif_device);
+		if (rc)
+			pr_warn("%s(): error registering the aemif device: %d\n",
+				__func__, rc);
 	} else {
 		/* no OneNAND support yet */
 	}
Signature · 1 line
2.17.1
#13 lore raw

PATCH 5/9 ARM: davinci: dm644x-evm: use aemif platform driver

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in dm644x-evm.

---
 arch/arm/mach-davinci/board-dm644x-evm.c | 55 ++++++++++++++++++------
 1 file changed, 42 insertions(+), 13 deletions(-)
arch/arm/mach-davinci/board-dm644x-evm.c +42 -13
index 738e443ab15f..e3556708c71b 100644
@@ -42,6 +42,7 @@
 #include <linux/platform_data/mmc-davinci.h>
 #include <linux/platform_data/usb-davinci.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/ti-aemif.h>
 
 #include "davinci.h"
 
@@ -174,14 +175,47 @@ static struct resource davinci_evm_nandflash_resource[] = {
 	},
 };
 
-static struct platform_device davinci_evm_nandflash_device = {
-	.name		= "davinci_nand",
-	.id		= 0,
-	.dev		= {
-		.platform_data	= &davinci_evm_nandflash_data,
+static struct resource davinci_evm_aemif_resource[] = {
+	{
+		.start		= DM644X_ASYNC_EMIF_CONTROL_BASE,
+		.end		= DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
+		.flags		= IORESOURCE_MEM,
 	},
-	.num_resources	= ARRAY_SIZE(davinci_evm_nandflash_resource),
-	.resource	= davinci_evm_nandflash_resource,
+};
+
+static struct aemif_abus_data davinci_evm_aemif_abus_data[] = {
+	{
+		.cs		= 1,
+	},
+};
+
+static struct platform_device davinci_evm_nandflash_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 0,
+		.dev		= {
+			.platform_data	= &davinci_evm_nandflash_data,
+		},
+		.num_resources	= ARRAY_SIZE(davinci_evm_nandflash_resource),
+		.resource	= davinci_evm_nandflash_resource,
+	},
+};
+
+static struct aemif_platform_data davinci_evm_aemif_pdata = {
+	.abus_data = davinci_evm_aemif_abus_data,
+	.num_abus_data = ARRAY_SIZE(davinci_evm_aemif_abus_data),
+	.sub_devices = davinci_evm_nandflash_devices,
+	.num_sub_devices = ARRAY_SIZE(davinci_evm_nandflash_devices),
+};
+
+static struct platform_device davinci_evm_aemif_device = {
+	.name			= "ti-aemif",
+	.dev = {
+		.platform_data = &davinci_evm_aemif_pdata,
+	},
+	.resource = davinci_evm_aemif_resource,
+	.num_resources = ARRAY_SIZE(davinci_evm_aemif_resource),
+	.id = -1,
 };
 
 static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
@@ -795,12 +829,7 @@ static __init void davinci_evm_init(void)
 
 		/* only one device will be jumpered and detected */
 		if (HAS_NAND) {
-			platform_device_register(&davinci_evm_nandflash_device);
-
-			if (davinci_aemif_setup(&davinci_evm_nandflash_device))
-				pr_warn("%s: Cannot configure AEMIF\n",
-					__func__);
-
+			platform_device_register(&davinci_evm_aemif_device);
 #ifdef CONFIG_I2C
 			evm_leds[7].default_trigger = "nand-disk";
 #endif
Signature · 1 line
2.17.1
#14 lore raw

PATCH 6/9 ARM: davinci: da830-evm: use aemif platform driver

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da830-evm.

---
 arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
 1 file changed, 44 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +44 -12
index b2470141dba3..666db3cee08a 100644
@@ -28,6 +28,7 @@
 #include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/platform_data/spi-davinci.h>
 #include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
@@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] = {
 	},
 };
 
-static struct platform_device da830_evm_nand_device = {
-	.name		= "davinci_nand",
-	.id		= 1,
-	.dev		= {
-		.platform_data	= &da830_evm_nand_pdata,
+static struct platform_device da830_evm_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,
+		.dev		= {
+			.platform_data	= &da830_evm_nand_pdata,
+		},
+		.num_resources	= ARRAY_SIZE(da830_evm_nand_resources),
+		.resource	= da830_evm_nand_resources,
+	},
+};
+
+static struct resource da830_evm_aemif_resource[] = {
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct aemif_abus_data da830_evm_aemif_abus_data[] = {
+	{
+		.cs	= 3,
 	},
-	.num_resources	= ARRAY_SIZE(da830_evm_nand_resources),
-	.resource	= da830_evm_nand_resources,
+};
+
+static struct aemif_platform_data da830_evm_aemif_pdata = {
+	.abus_data		= da830_evm_aemif_abus_data,
+	.num_abus_data		= ARRAY_SIZE(da830_evm_aemif_abus_data),
+	.sub_devices		= da830_evm_aemif_devices,
+	.num_sub_devices	= ARRAY_SIZE(da830_evm_aemif_devices),
+	.cs_offset		= 2,
+};
+
+static struct platform_device da830_evm_aemif_device = {
+	.name		= "ti-aemif",
+	.dev = {
+		.platform_data = &da830_evm_aemif_pdata,
+	},
+	.resource	= da830_evm_aemif_resource,
+	.num_resources	= ARRAY_SIZE(da830_evm_aemif_resource),
+	.id		= -1,
 };
 
 /*
@@ -371,12 +406,9 @@ static inline void da830_evm_init_nand(int mux_mode)
 	if (ret)
 		pr_warn("%s: emif25 mux setup failed: %d\n", __func__, ret);
 
-	ret = platform_device_register(&da830_evm_nand_device);
+	ret = platform_device_register(&da830_evm_aemif_device);
 	if (ret)
-		pr_warn("%s: NAND device not registered\n", __func__);
-
-	if (davinci_aemif_setup(&da830_evm_nand_device))
-		pr_warn("%s: Cannot configure AEMIF\n", __func__);
+		pr_warn("%s: AEMIF device not registered\n", __func__);
 
 	gpio_direction_output(mux_mode, 1);
 }
Signature · 1 line
2.17.1
maintainer
#15 lore raw

Re: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

Quoted 25 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da830-evm.

---
  arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
  1 file changed, 44 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +1 -0
index b2470141dba3..666db3cee08a 100644
@@ -28,6 +28,7 @@
  #include <linux/platform_data/mtd-davinci-aemif.h>
  #include <linux/platform_data/spi-davinci.h>
  #include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
  #include <linux/regulator/machine.h>
 
  #include <asm/mach-types.h>
@@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] = {
  	},
  };

arch/arm/mach-davinci/board-da830-evm.c static struct resource da830_evm_nand_resources[] = { · line 340

Quoted 10 lines
arch/arm/mach-davinci/board-da830-evm.c +4 -5
 
-static struct platform_device da830_evm_nand_device = {
-	.name		= "davinci_nand",
-	.id		= 1,
-	.dev		= {
-		.platform_data	= &da830_evm_nand_pdata,
+static struct platform_device da830_evm_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,

Actually, now that I've thought about it some more. It probably makes more sense to make all of the "davinci_nand" devices in this series use id = -1 since there is only one per board. It looks like da850 is the only one that has a lookup for "davinic_nand.0" already.

I think that we are going to have to add clock lookups for the "davinci_nand" devices as well. Although the driver doesn't do clk_get() explicitly, I think some function it calls does get a clock. I remember that we had to add a clock-ranges property to device tree to get the davinci_nand driver working, which is why I think we are going to need a clock lookup for these devices as well.

Quoted 8 lines
arch/arm/mach-davinci/board-da830-evm.c +8 -0
+		.dev		= {
+			.platform_data	= &da830_evm_nand_pdata,
+		},
+		.num_resources	= ARRAY_SIZE(da830_evm_nand_resources),
+		.resource	= da830_evm_nand_resources,
+	},
+};
+
#16 lore raw

Re: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

2018-06-25 18:20 GMT+02:00 David Lechner <[email protected]>:

Quoted 44 lines · Bartosz Golaszewski
Quoted 26 lines

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da830-evm.

---
  arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
  1 file changed, 44 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +1 -0
index b2470141dba3..666db3cee08a 100644
@@ -28,6 +28,7 @@
  #include <linux/platform_data/mtd-davinci-aemif.h>
  #include <linux/platform_data/spi-davinci.h>
  #include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
  #include <linux/regulator/machine.h>
    #include <asm/mach-types.h>
@@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] =
 {
        },

arch/arm/mach-davinci/board-da830-evm.c static struct resource da830_evm_nand_resources[] = · line 341

Quoted 10 lines
arch/arm/mach-davinci/board-da830-evm.c +4 -4
  };
  -static struct platform_device da830_evm_nand_device = {
-       .name           = "davinci_nand",
-       .id             = 1,
-       .dev            = {
-               .platform_data  = &da830_evm_nand_pdata,
+static struct platform_device da830_evm_aemif_devices[] = {
+       {
+               .name           = "davinci_nand",
+               .id             = 1,

Actually, now that I've thought about it some more. It probably makes more sense to make all of the "davinci_nand" devices in this series use id = -1 since there is only one per board. It looks like da850 is the only one that has a lookup for "davinic_nand.0" already.

Quoted 8 lines

I think that we are going to have to add clock lookups for the "davinci_nand" devices as well. Although the driver doesn't do clk_get() explicitly, I think some function it calls does get a clock. I remember that we had to add a clock-ranges property to device tree to get the davinci_nand driver working, which is why I think we are going to need a clock lookup for these devices as well.

Seems like ever since commit a8e3923ab571 ("mtd: rawnand: davinci:
don't acquire and enable clock") we no longer need to worry about the clock entries for nand.

Thanks,
Bart

maintainer
#17 lore raw

Re: [PATCH 6/9] ARM: davinci: da830-evm: use aemif platform driver

Quoted 54 lines · Bartosz Golaszewski

2018-06-25 18:20 GMT+02:00 David Lechner <[email protected]>:

Quoted 44 lines · Bartosz Golaszewski
Quoted 26 lines

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in da830-evm.

---
   arch/arm/mach-davinci/board-da830-evm.c | 56 +++++++++++++++++++------
   1 file changed, 44 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +1 -0
index b2470141dba3..666db3cee08a 100644
@@ -28,6 +28,7 @@
   #include <linux/platform_data/mtd-davinci-aemif.h>
   #include <linux/platform_data/spi-davinci.h>
   #include <linux/platform_data/usb-davinci.h>
+#include <linux/platform_data/ti-aemif.h>
   #include <linux/regulator/machine.h>
     #include <asm/mach-types.h>
@@ -333,14 +334,48 @@ static struct resource da830_evm_nand_resources[] =
 {
         },

arch/arm/mach-davinci/board-da830-evm.c static struct resource da830_evm_nand_resources[] = · line 341

Quoted 10 lines
arch/arm/mach-davinci/board-da830-evm.c +4 -4
   };
   -static struct platform_device da830_evm_nand_device = {
-       .name           = "davinci_nand",
-       .id             = 1,
-       .dev            = {
-               .platform_data  = &da830_evm_nand_pdata,
+static struct platform_device da830_evm_aemif_devices[] = {
+       {
+               .name           = "davinci_nand",
+               .id             = 1,

Actually, now that I've thought about it some more. It probably makes more sense to make all of the "davinci_nand" devices in this series use id = -1 since there is only one per board. It looks like da850 is the only one that has a lookup for "davinic_nand.0" already.

Quoted 8 lines

I think that we are going to have to add clock lookups for the "davinci_nand" devices as well. Although the driver doesn't do clk_get() explicitly, I think some function it calls does get a clock. I remember that we had to add a clock-ranges property to device tree to get the davinci_nand driver working, which is why I think we are going to need a clock lookup for these devices as well.

Quoted 7 lines

Seems like ever since commit a8e3923ab571 ("mtd: rawnand: davinci:
don't acquire and enable clock") we no longer need to worry about the clock entries for nand.

Thanks,
Bart

Sounds good. If you end up touching the da850 clock lookups, you can probably drop the "davinci_nand.0" entry there.

#18 lore raw

PATCH 7/9 ARM: davinci: dm646x-evm: use aemif platform driver

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in dm646x-evm.

---
 arch/arm/mach-davinci/board-dm646x-evm.c | 52 +++++++++++++++++++-----
 1 file changed, 41 insertions(+), 11 deletions(-)
arch/arm/mach-davinci/board-dm646x-evm.c +41 -11
index 867ab2fa6cfd..99297e0612ba 100644
@@ -24,6 +24,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_data/at24.h>
 #include <linux/platform_data/pcf857x.h>
+#include <linux/platform_data/ti-aemif.h>
 
 #include <media/i2c/tvp514x.h>
 #include <media/i2c/adv7343.h>
@@ -106,16 +107,47 @@ static struct resource davinci_nand_resources[] = {
 	},
 };
 
-static struct platform_device davinci_nand_device = {
-	.name			= "davinci_nand",
-	.id			= 0,
+static struct platform_device davinci_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 0,
+		.num_resources	= ARRAY_SIZE(davinci_nand_resources),
+		.resource	= davinci_nand_resources,
+		.dev		= {
+			.platform_data	= &davinci_nand_data,
+		},
+	},
+};
+
+static struct resource davinci_aemif_resources[] = {
+	{
+		.start	= DM646X_ASYNC_EMIF_CONTROL_BASE,
+		.end	= DM646X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
 
-	.num_resources		= ARRAY_SIZE(davinci_nand_resources),
-	.resource		= davinci_nand_resources,
+static struct aemif_abus_data davinci_aemif_abus_data[] = {
+	{
+		.cs	= 1,
+	},
+};
 
-	.dev			= {
-		.platform_data	= &davinci_nand_data,
+static struct aemif_platform_data davinci_aemif_pdata = {
+	.abus_data		= davinci_aemif_abus_data,
+	.num_abus_data		= ARRAY_SIZE(davinci_aemif_abus_data),
+	.sub_devices		= davinci_aemif_devices,
+	.num_sub_devices	= ARRAY_SIZE(davinci_aemif_devices),
+};
+
+static struct platform_device davinci_aemif_device = {
+	.name		= "ti-aemif",
+	.dev = {
+		.platform_data	= &davinci_aemif_pdata,
 	},
+	.resource	= davinci_aemif_resources,
+	.num_resources	= ARRAY_SIZE(davinci_aemif_resources),
+	.id		= -1,
 };
 
 #define HAS_ATA		(IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
@@ -793,10 +825,8 @@ static __init void evm_init(void)
 	if (machine_is_davinci_dm6467tevm())
 		davinci_nand_data.timing = &dm6467tevm_nandflash_timing;
 
-	platform_device_register(&davinci_nand_device);
-
-	if (davinci_aemif_setup(&davinci_nand_device))
-		pr_warn("%s: Cannot configure AEMIF.\n", __func__);
+	if (platform_device_register(&davinci_aemif_device))
+		pr_warn("%s: Cannot register AEMIF device.\n", __func__);
 
 	dm646x_init_edma(dm646x_edma_rsv);
 
Signature · 1 line
2.17.1
#19 lore raw

PATCH 8/9 ARM: davinci: mityomapl138: use aemif platform driver

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We now support board files in the aemif driver. Register a platform device instead of using the handcrafted API in mityomapl138.

---
 arch/arm/mach-davinci/board-mityomapl138.c | 55 ++++++++++++++++------
 1 file changed, 41 insertions(+), 14 deletions(-)
arch/arm/mach-davinci/board-mityomapl138.c +41 -14
index 2cce0d7d2f2a..b0fdea355d96 100644
@@ -30,6 +30,7 @@
 #include <mach/da8xx.h>
 #include <linux/platform_data/mtd-davinci.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
+#include <linux/platform_data/ti-aemif.h>
 #include <mach/mux.h>
 #include <linux/platform_data/spi-davinci.h>
 
@@ -422,27 +423,53 @@ static struct resource mityomapl138_nandflash_resource[] = {
 	},
 };
 
-static struct platform_device mityomapl138_nandflash_device = {
-	.name		= "davinci_nand",
-	.id		= 1,
-	.dev		= {
-		.platform_data	= &mityomapl138_nandflash_data,
+static struct platform_device mityomapl138_aemif_devices[] = {
+	{
+		.name		= "davinci_nand",
+		.id		= 1,
+		.dev		= {
+			.platform_data	= &mityomapl138_nandflash_data,
+		},
+		.num_resources	= ARRAY_SIZE(mityomapl138_nandflash_resource),
+		.resource	= mityomapl138_nandflash_resource,
 	},
-	.num_resources	= ARRAY_SIZE(mityomapl138_nandflash_resource),
-	.resource	= mityomapl138_nandflash_resource,
 };
 
-static struct platform_device *mityomapl138_devices[] __initdata = {
-	&mityomapl138_nandflash_device,
+static struct resource mityomapl138_aemif_resources[] = {
+	{
+		.start	= DA8XX_AEMIF_CTL_BASE,
+		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct aemif_abus_data mityomapl138_aemif_abus_data[] = {
+	{
+		.cs	= 1,
+	},
+};
+
+static struct aemif_platform_data mityomapl138_aemif_pdata = {
+	.abus_data		= mityomapl138_aemif_abus_data,
+	.num_abus_data		= ARRAY_SIZE(mityomapl138_aemif_abus_data),
+	.sub_devices		= mityomapl138_aemif_devices,
+	.num_sub_devices	= ARRAY_SIZE(mityomapl138_aemif_devices),
+};
+
+static struct platform_device mityomapl138_aemif_device = {
+	.name		= "ti-aemif",
+	.dev = {
+		.platform_data	= &mityomapl138_aemif_pdata,
+	},
+	.resource	= mityomapl138_aemif_resources,
+	.num_resources	= ARRAY_SIZE(mityomapl138_aemif_resources),
+	.id		= -1,
 };
 
 static void __init mityomapl138_setup_nand(void)
 {
-	platform_add_devices(mityomapl138_devices,
-				 ARRAY_SIZE(mityomapl138_devices));
-
-	if (davinci_aemif_setup(&mityomapl138_nandflash_device))
-		pr_warn("%s: Cannot configure AEMIF\n", __func__);
+	if (platform_device_register(&mityomapl138_aemif_device))
+		pr_warn("%s: Cannot register AEMIF device\n", __func__);
 }
 
 static const short mityomap_mii_pins[] = {
Signature · 1 line
2.17.1
#20 lore raw

PATCH 9/9 ARM: davinci: kill davinci_aemif_setup()

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

All users now register platform devices using the ti-aemif driver. Remove the handcrafted aemif API.

---
 arch/arm/mach-davinci/Makefile                |   2 +-
 arch/arm/mach-davinci/aemif.c                 | 218 ------------------
 .../linux/platform_data/mtd-davinci-aemif.h   |   1 -
 3 files changed, 1 insertion(+), 220 deletions(-)
 delete mode 100644 arch/arm/mach-davinci/aemif.c
arch/arm/mach-davinci/Makefile +1 -1
index 8725d8bea567..93d271b4d84b 100644
@@ -6,7 +6,7 @@
 
 # Common objects
 obj-y 					:= time.o serial.o usb.o \
-					   common.o sram.o aemif.o
+					   common.o sram.o
 
 obj-$(CONFIG_DAVINCI_MUX)		+= mux.o
 
arch/arm/mach-davinci/aemif.c deleted +0 -218

218 lines not on this page · raw message

include/linux/platform_data/mtd-davinci-aemif.h +0 -1
index 97948ac2bb9b..a403dd51dacc 100644
@@ -33,5 +33,4 @@ struct davinci_aemif_timing {
 	u8	ta;
 };
 
-int davinci_aemif_setup(struct platform_device *pdev);
 #endif
Signature · 1 line
2.17.1
maintainer
#21 lore raw

Re: [PATCH 9/9] ARM: davinci: kill davinci_aemif_setup()

Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

All users now register platform devices using the ti-aemif driver. Remove the handcrafted aemif API.

---

I found the subject line to be a bit misleading since this patch removes an entire file, not just the one function mentioned.