From patchwork Fri Sep 18 21:15:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mark A. Greer" X-Patchwork-Id: 48662 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8ILHHO9014830 for ; Fri, 18 Sep 2009 21:17:17 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n8ILFU3U018153; Fri, 18 Sep 2009 16:15:30 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n8ILFUqD023053; Fri, 18 Sep 2009 16:15:30 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id E327E80627; Fri, 18 Sep 2009 16:15:29 -0500 (CDT) X-Original-To: Davinci-linux-open-source@linux.davincidsp.com Delivered-To: Davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 44B0C80626 for ; Fri, 18 Sep 2009 16:15:26 -0500 (CDT) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp52.itg.ti.com (8.13.7/8.13.7) with ESMTP id n8ILFQm7024890 for ; Fri, 18 Sep 2009 16:15:26 -0500 (CDT) Received: from mail159-tx2-R.bigfish.com (mail-tx2.bigfish.com [65.55.88.114]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id n8ILFP7d016382 for ; Fri, 18 Sep 2009 16:15:26 -0500 Received: from mail159-tx2 (localhost.localdomain [127.0.0.1]) by mail159-tx2-R.bigfish.com (Postfix) with ESMTP id A6A15728231 for ; Fri, 18 Sep 2009 21:15:25 +0000 (UTC) X-SpamScore: 7 X-BigFish: vps7(zza4b1ozz1202hzzz2dh6bh35h61h) X-Spam-TCS-SCL: 0:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 63.81.120.158; Service: EHS Received: by mail159-tx2 (MessageSwitch) id 1253308520698809_31485; Fri, 18 Sep 2009 21:15:20 +0000 (UCT) Received: from TX2EHSMHS043.bigfish.com (unknown [10.9.14.243]) by mail159-tx2.bigfish.com (Postfix) with ESMTP id 9E8E31C68050 for ; Fri, 18 Sep 2009 21:15:20 +0000 (UTC) Received: from gateway-1237.mvista.com (63.81.120.158) by TX2EHSMHS043.bigfish.com (10.9.99.143) with Microsoft SMTP Server id 14.0.482.32; Fri, 18 Sep 2009 21:15:19 +0000 Received: from mag.az.mvista.com (mag.az.mvista.com [10.50.1.99]) by hermes.mvista.com (Postfix) with ESMTP id 51A841B7E9; Fri, 18 Sep 2009 14:15:18 -0700 (PDT) Received: from mgreer by mag.az.mvista.com with local (Exim 4.69) (envelope-from ) id 1MoknW-0003O2-6Y; Fri, 18 Sep 2009 14:15:18 -0700 Date: Fri, 18 Sep 2009 14:15:18 -0700 From: "Mark A. Greer" To: "Mark A. Greer" Message-ID: <20090918211518.GB12907@mag.az.mvista.com> References: <20090918211004.GA12907@mag.az.mvista.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090918211004.GA12907@mag.az.mvista.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Reverse-DNS: unknown Cc: Davinci List , dgriego@mvista.com Subject: [PATCH 2/2] davinci: Add NAND support for DA830/OMAP-L137 EVM platform X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: David A. Griego 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 Signed-off-by: Mark A. Greer Signed-off-by: Sergei Shtylyov --- 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(-) 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 #include #include +#include #include #include #include +#include +#include +#include #include #include @@ -26,12 +30,16 @@ #include #include #include +#include #include #include #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();