diff mbox

[2/2] davinci: Add NAND support for DA830/OMAP-L137 EVM platform

Message ID 20090918211518.GB12907@mag.az.mvista.com (mailing list archive)
State Accepted
Headers show

Commit Message

Mark A. Greer Sept. 18, 2009, 9:15 p.m. UTC
From: David A. Griego <dgriego@mvista.com>

Add support for NAND flash parts on the DA830/OMAP-L137 EVM
User Interface board.  This includes overriding the default
bad block tables used by the davinci_nand driver.

Signed-off-by: David A. Griego <dgriego@mvista.com>
Signed-off-by: Mark A. Greer <mgreer@mvista.com>
---
Sergei, if you had a hand in this patch, please add your sign off now
(or your comments).

 arch/arm/mach-davinci/Kconfig           |    5 +
 arch/arm/mach-davinci/board-da830-evm.c |  132 +++++++++++++++++++++++++++++++
 2 files changed, 137 insertions(+), 0 deletions(-)

Comments

Sergei Shtylyov Sept. 19, 2009, 4:53 p.m. UTC | #1
Hello.

Mark A. Greer wrote:

> From: David A. Griego <dgriego@mvista.com>
>
> Add support for NAND flash parts on the DA830/OMAP-L137 EVM
> User Interface board.  This includes overriding the default
> bad block tables used by the davinci_nand driver.
>
> Signed-off-by: David A. Griego <dgriego@mvista.com>
> Signed-off-by: Mark A. Greer <mgreer@mvista.com>
>   

> ---
> Sergei, if you had a hand in this patch, please add your sign off now
> (or your comments).
>   

   Yes, I had.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

> diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
> index fb76721..14ea437 100644
> --- a/arch/arm/mach-davinci/board-da830-evm.c
> +++ b/arch/arm/mach-davinci/board-da830-evm.c
> @@ -14,9 +14,13 @@
>  #include <linux/init.h>
>  #include <linux/console.h>
>  #include <linux/gpio.h>
> +#include <linux/platform_device.h>
>  #include <linux/i2c.h>
>  #include <linux/i2c/pcf857x.h>
>  #include <linux/i2c/at24.h>
> +#include <linux/mtd/mtd.h>
> +#include <linux/mtd/physmap.h>
>   

   ??? It should not be needed for NAND.

WBR, Sergei
Sergei Shtylyov Oct. 1, 2009, 9:54 a.m. UTC | #2
Hello.

Kevin Hilman wrote:

>>> From: David A. Griego <dgriego@mvista.com>
>>>
>>> Add support for NAND flash parts on the DA830/OMAP-L137 EVM
>>> User Interface board.  This includes overriding the default
>>> bad block tables used by the davinci_nand driver.
>>>
>>> Signed-off-by: David A. Griego <dgriego@mvista.com>
>>> Signed-off-by: Mark A. Greer <mgreer@mvista.com>
>>>   
>>>       
>>> ---
>>> Sergei, if you had a hand in this patch, please add your sign off now
>>> (or your comments).
>>>   
>>>       
>>   Yes, I had.
>>
>> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
>>     
>
> Thanks, pushing today.
>   

   What about wrongly including <linux/mtd/physmap.h>?

> Kevin
>   

WBR, Sergei
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 7b6dddf..b0fc043 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -120,6 +120,11 @@  config DA830_UI_LCD
 	  Say Y here to use the LCD as a framebuffer or simple character
 	  display.
 
+config DA830_UI_NAND
+	bool "NAND flash"
+	help
+	  Say Y here to use the NAND flash.  Do not forget to setup
+	  the switch correctly.
 endchoice
 
 config MACH_DAVINCI_DA850_EVM
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index fb76721..14ea437 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -14,9 +14,13 @@ 
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/gpio.h>
+#include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pcf857x.h>
 #include <linux/i2c/at24.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/partitions.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -26,12 +30,16 @@ 
 #include <mach/cp_intc.h>
 #include <mach/mux.h>
 #include <mach/gpio.h>
+#include <mach/nand.h>
 #include <mach/da8xx.h>
 #include <mach/asp.h>
 
 #define DA830_EVM_PHY_MASK		0x0
 #define DA830_EVM_MDIO_FREQUENCY	2200000	/* PHY bus frequency */
 
+#define DA830_EMIF25_ASYNC_DATA_CE3_BASE	0x62000000
+#define DA830_EMIF25_CONTROL_BASE		0x68000000
+
 static struct at24_platform_data da830_evm_i2c_eeprom_info = {
 	.byte_len	= SZ_256K / 8,
 	.page_size	= 64,
@@ -147,6 +155,118 @@  static struct davinci_mmc_config da830_evm_mmc_config = {
 	.version		= MMC_CTLR_VERSION_2,
 };
 
+#ifdef CONFIG_DA830_UI_NAND
+static struct mtd_partition da830_evm_nand_partitions[] = {
+	/* bootloader (U-Boot, etc) in first sector */
+	[0] = {
+		.name		= "bootloader",
+		.offset		= 0,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,	/* force read-only */
+	},
+	/* bootloader params in the next sector */
+	[1] = {
+		.name		= "params",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_128K,
+		.mask_flags	= MTD_WRITEABLE,	/* force read-only */
+	},
+	/* kernel */
+	[2] = {
+		.name		= "kernel",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_2M,
+		.mask_flags	= 0,
+	},
+	/* file system */
+	[3] = {
+		.name		= "filesystem",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+		.mask_flags	= 0,
+	}
+};
+
+/* flash bbt decriptors */
+static uint8_t da830_evm_nand_bbt_pattern[] = { 'B', 'b', 't', '0' };
+static uint8_t da830_evm_nand_mirror_pattern[] = { '1', 't', 'b', 'B' };
+
+static struct nand_bbt_descr da830_evm_nand_bbt_main_descr = {
+	.options	= NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
+			  NAND_BBT_WRITE | NAND_BBT_2BIT |
+			  NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs		= 2,
+	.len		= 4,
+	.veroffs	= 16,
+	.maxblocks	= 4,
+	.pattern	= da830_evm_nand_bbt_pattern
+};
+
+static struct nand_bbt_descr da830_evm_nand_bbt_mirror_descr = {
+	.options	= NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
+			  NAND_BBT_WRITE | NAND_BBT_2BIT |
+			  NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+	.offs		= 2,
+	.len		= 4,
+	.veroffs	= 16,
+	.maxblocks	= 4,
+	.pattern	= da830_evm_nand_mirror_pattern
+};
+
+static struct davinci_nand_pdata da830_evm_nand_pdata = {
+	.parts		= da830_evm_nand_partitions,
+	.nr_parts	= ARRAY_SIZE(da830_evm_nand_partitions),
+	.ecc_mode	= NAND_ECC_HW,
+	.ecc_bits	= 4,
+	.options	= NAND_USE_FLASH_BBT,
+	.bbt_td		= &da830_evm_nand_bbt_main_descr,
+	.bbt_md		= &da830_evm_nand_bbt_mirror_descr,
+};
+
+static struct resource da830_evm_nand_resources[] = {
+	[0] = {		/* First memory resource is NAND I/O window */
+		.start	= DA830_EMIF25_ASYNC_DATA_CE3_BASE,
+		.end	= DA830_EMIF25_ASYNC_DATA_CE3_BASE + PAGE_SIZE - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {		/* Second memory resource is AEMIF control registers */
+		.start	= DA830_EMIF25_CONTROL_BASE,
+		.end	= DA830_EMIF25_CONTROL_BASE + SZ_32K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device da830_evm_nand_device = {
+	.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,
+};
+#endif
+
+static struct platform_device *da830_evm_devices[] __initdata = {
+#ifdef CONFIG_DA830_UI_NAND
+	&da830_evm_nand_device,
+#endif
+};
+
+/*
+ * UI board NAND/NOR flashes only use 8-bit data bus.
+ */
+static const short da830_evm_emif25_pins[] = {
+	DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,
+	DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,
+	DA830_EMA_A_0, DA830_EMA_A_1, DA830_EMA_A_2, DA830_EMA_A_3,
+	DA830_EMA_A_4, DA830_EMA_A_5, DA830_EMA_A_6, DA830_EMA_A_7,
+	DA830_EMA_A_8, DA830_EMA_A_9, DA830_EMA_A_10, DA830_EMA_A_11,
+	DA830_EMA_A_12, DA830_EMA_BA_0, DA830_EMA_BA_1, DA830_NEMA_WE,
+	DA830_NEMA_CS_2, DA830_NEMA_CS_3, DA830_NEMA_OE, DA830_EMA_WAIT_0,
+	-1
+};
+
 static __init void da830_evm_init(void)
 {
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
@@ -207,6 +327,7 @@  static __init void da830_evm_init(void)
 		pr_warning("da830_evm_init: mmc/sd registration failed: %d\n",
 				ret);
 
+#ifdef CONFIG_DA830_UI
 #ifdef CONFIG_DA830_UI_LCD
 	ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
 	if (ret)
@@ -216,6 +337,17 @@  static __init void da830_evm_init(void)
 	ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
 	if (ret)
 		pr_warning("da830_evm_init: lcd setup failed: %d\n", ret);
+#else /* Must be NAND or NOR */
+	ret = da8xx_pinmux_setup(da830_evm_emif25_pins);
+	if (ret)
+		pr_warning("da830_evm_init: emif25 mux setup failed: %d\n",
+				ret);
+
+	ret = platform_add_devices(da830_evm_devices,
+			ARRAY_SIZE(da830_evm_devices));
+	if (ret)
+		pr_warning("da830_evm_init: EVM devices not added\n");
+#endif
 #endif
 
 	ret = da8xx_register_rtc();