From 9e6155b923e71cba8e684b2f0c79352330e4370e Mon Sep 17 00:00:00 2001 From: Pekon Gupta Date: Thu, 5 Dec 2013 02:11:03 +0530 Subject: [PATCH] mtd: nand: omap: add CONFIG_SPL_NAND_DEVICE_WIDTH to determine NAND device bus-width This patch adds CONFIG_SPL_NAND_DEVICE_WIDTH to specify bus-width of NAND device CONFIG_SPL_NAND_DEVICE_WIDTH == 16: NAND device with x16 bus-width CONFIG_SPL_NAND_DEVICE_WIDTH == 8: NAND device with x8 bus-width Need for a separate CONFIG_xx arise from following situations. (1) SPL NAND drivers does not have framework to parse ONFI parameter page. (2) if !defined(CONFIG_SYS_NAND_SELF_INIT) |- board_nand_init() |- nand_scan() |- nand_scan_ident() |- nand_scan_tail() This means board_nand_init() is called before nand_scan_ident(). So NAND controller is initialized before the actual probing of NAND device. However some controller (like GPMC) need to be specifically configured for bus-width of NAND device. In such cases, bus-width of the NAND device should be known in advance of actual device probing. Hence, CONFIG_SPL_NAND_DEVICE_WIDTH is useful. (3) Non-ONFI compliant devices need some mechanism to specify device bus-width to driver. Signed-off-by: Pekon Gupta --- doc/README.nand | 9 +++++++++ drivers/mtd/nand/omap_gpmc.c | 14 ++++++++++---- include/configs/am335x_evm.h | 1 + include/configs/am3517_crane.h | 1 + include/configs/am3517_evm.h | 1 + include/configs/am43xx_evm.h | 1 + include/configs/cm_t35.h | 1 + include/configs/devkit8000.h | 1 + include/configs/dig297.h | 1 + include/configs/dra7xx_evm.h | 1 + include/configs/igep0033.h | 1 + include/configs/igep00x0.h | 1 + include/configs/mcx.h | 1 + include/configs/omap3_beagle.h | 1 + include/configs/omap3_evm_common.h | 2 +- include/configs/omap3_logic.h | 1 + include/configs/omap3_overo.h | 1 + include/configs/omap3_pandora.h | 2 +- include/configs/omap3_zoom1.h | 1 + include/configs/omap3_zoom2.h | 1 + include/configs/siemens-am33x-common.h | 1 + include/configs/tam3517-common.h | 1 + include/configs/tricorder.h | 1 + 23 files changed, 40 insertions(+), 6 deletions(-) diff --git a/doc/README.nand b/doc/README.nand index d69abaae12..ab3ca34251 100644 --- a/doc/README.nand +++ b/doc/README.nand @@ -180,6 +180,15 @@ Configuration Options: This is used by SoC platforms which do not have built-in ELM hardware engine required for BCH ECC correction. + CONFIG_SPL_NAND_DEVICE_WIDTH + Specifies bus-width of the default NAND device connected to SoC. + This config is useful for driver which cannot self initialize or + parse ONFI parameter (like SPL drivers), or for supporting non-ONFI + compliant devices. + This config can take following values: + - 8: x8 NAND devices is connected + - 16: x16 NAND device is connected + Platform specific options ========================= diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c index 04ecca6061..bf43520d96 100644 --- a/drivers/mtd/nand/omap_gpmc.c +++ b/drivers/mtd/nand/omap_gpmc.c @@ -856,13 +856,19 @@ int board_nand_init(struct nand_chip *nand) nand->priv = &bch_priv; nand->cmd_ctrl = omap_nand_hwcontrol; nand->options |= NAND_NO_PADDING | NAND_CACHEPRG; - /* If we are 16 bit dev, our gpmc config tells us that */ - if ((readl(&gpmc_cfg->cs[cs].config1) & 0x3000) == 0x1000) - nand->options |= NAND_BUSWIDTH_16; - nand->chip_delay = 100; nand->ecc.layout = &omap_ecclayout; + /* configure driver and controller based on NAND device bus-width */ + gpmc_config = readl(&gpmc_cfg->cs[cs].config1); + if (CONFIG_SPL_NAND_DEVICE_WIDTH == 16) { + nand->options |= NAND_BUSWIDTH_16; + writel(gpmc_config | (0x1 << 12), &gpmc_cfg->cs[cs].config1); + } else { + nand->options &= ~NAND_BUSWIDTH_16; + writel(gpmc_config & ~(0x1 << 12), &gpmc_cfg->cs[cs].config1); + } + /* select ECC scheme */ #if defined(CONFIG_NAND_OMAP_ECCSCHEME) err = omap_select_ecc_scheme(nand, CONFIG_NAND_OMAP_ECCSCHEME, diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index b76d7b0cd1..6823370fd1 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -206,6 +206,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ CONFIG_SYS_NAND_PAGE_SIZE) diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index 3bd344db19..b6469778ab 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -335,6 +335,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ 10, 11, 12, 13} diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index 5f1de46846..35054afb0a 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -329,6 +329,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ 10, 11, 12, 13} diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h index 977013f37e..8afb8d77a6 100644 --- a/include/configs/am43xx_evm.h +++ b/include/configs/am43xx_evm.h @@ -211,6 +211,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 4096 #define CONFIG_SYS_NAND_OOBSIZE 224 #define CONFIG_SYS_NAND_BLOCK_SIZE (256 * 1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ CONFIG_SYS_NAND_PAGE_SIZE) diff --git a/include/configs/cm_t35.h b/include/configs/cm_t35.h index 1e3dd0dc08..c337925941 100644 --- a/include/configs/cm_t35.h +++ b/include/configs/cm_t35.h @@ -166,6 +166,7 @@ /* CS0 */ #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ /* devices */ +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 /* Environment information */ #define CONFIG_BOOTDELAY 10 #define CONFIG_ZERO_BOOTDELAY_CHECK diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h index 7d75b8a074..b722970ff0 100644 --- a/include/configs/devkit8000.h +++ b/include/configs/devkit8000.h @@ -320,6 +320,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0 #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ 10, 11, 12, 13} diff --git a/include/configs/dig297.h b/include/configs/dig297.h index 75c67206f2..fa0fd40f5d 100644 --- a/include/configs/dig297.h +++ b/include/configs/dig297.h @@ -143,6 +143,7 @@ #define CONFIG_SYS_NAND_BASE NAND_BASE /* physical address */ /* to access nand at */ /* CS0 */ +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ #if defined(CONFIG_CMD_NET) diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index 05eeedd9f4..413fe4be4c 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -103,6 +103,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 /* NAND: driver related configs */ #define CONFIG_NAND_OMAP_GPMC #define CONFIG_NAND_OMAP_ELM diff --git a/include/configs/igep0033.h b/include/configs/igep0033.h index b08929e2b3..5875e77947 100644 --- a/include/configs/igep0033.h +++ b/include/configs/igep0033.h @@ -253,6 +253,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS #define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \ 10, 11, 12, 13, 14, 15, 16, 17, \ diff --git a/include/configs/igep00x0.h b/include/configs/igep00x0.h index 52b509adc6..9ca6a97dd6 100644 --- a/include/configs/igep00x0.h +++ b/include/configs/igep00x0.h @@ -357,6 +357,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0 #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ 10, 11, 12, 13} diff --git a/include/configs/mcx.h b/include/configs/mcx.h index 3a06d54e52..8cbf9ef29f 100644 --- a/include/configs/mcx.h +++ b/include/configs/mcx.h @@ -387,6 +387,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0 #define CONFIG_SYS_NAND_ECCPOS {40, 41, 42, 43, 44, 45, 46, 47,\ diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index 60aadb2b61..680abe5721 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -426,6 +426,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0 #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ 10, 11, 12, 13} diff --git a/include/configs/omap3_evm_common.h b/include/configs/omap3_evm_common.h index 564af9a094..162c69a849 100644 --- a/include/configs/omap3_evm_common.h +++ b/include/configs/omap3_evm_common.h @@ -122,7 +122,7 @@ /* Max number of NAND devices */ #define CONFIG_SYS_MAX_NAND_DEVICE 1 - +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 /* Timeout values (in ticks) */ #define CONFIG_SYS_FLASH_ERASE_TOUT (100 * CONFIG_SYS_HZ) #define CONFIG_SYS_FLASH_WRITE_TOUT (100 * CONFIG_SYS_HZ) diff --git a/include/configs/omap3_logic.h b/include/configs/omap3_logic.h index 00f43315c4..72315f14db 100644 --- a/include/configs/omap3_logic.h +++ b/include/configs/omap3_logic.h @@ -298,6 +298,7 @@ #if defined(CONFIG_CMD_NAND) #define CONFIG_NAND_OMAP_GPMC +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_ENV_IS_IN_NAND #define CONFIG_ENV_OFFSET SMNAND_ENV_OFFSET #endif diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h index fd9300abf1..6af8ea6316 100644 --- a/include/configs/omap3_overo.h +++ b/include/configs/omap3_overo.h @@ -319,6 +319,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS #define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ 10, 11, 12, 13} diff --git a/include/configs/omap3_pandora.h b/include/configs/omap3_pandora.h index e764d0fed6..84805a1794 100644 --- a/include/configs/omap3_pandora.h +++ b/include/configs/omap3_pandora.h @@ -133,7 +133,7 @@ /* at CS0 */ #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ /* devices */ - +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #ifdef CONFIG_CMD_NAND #define CONFIG_CMD_MTDPARTS #define CONFIG_MTD_PARTITIONS diff --git a/include/configs/omap3_zoom1.h b/include/configs/omap3_zoom1.h index b3eec6d67d..a9e78b2446 100644 --- a/include/configs/omap3_zoom1.h +++ b/include/configs/omap3_zoom1.h @@ -140,6 +140,7 @@ /* CS0 */ #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ /* devices */ +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_JFFS2_NAND /* nand device jffs2 lives on */ #define CONFIG_JFFS2_DEV "nand0" diff --git a/include/configs/omap3_zoom2.h b/include/configs/omap3_zoom2.h index 9ca7fbe2b6..926c6b1fc2 100644 --- a/include/configs/omap3_zoom2.h +++ b/include/configs/omap3_zoom2.h @@ -159,6 +159,7 @@ /* to access nand at */ /* CS0 */ #define CONFIG_SYS_MAX_NAND_DEVICE 1 +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 /* Environment information */ #define CONFIG_BOOTDELAY 10 diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h index 784f9a40cf..9f3d4b6e24 100644 --- a/include/configs/siemens-am33x-common.h +++ b/include/configs/siemens-am33x-common.h @@ -187,6 +187,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS #define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \ 10, 11, 12, 13, 14, 15, 16, 17, \ diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h index d32b6584c1..e007442f20 100644 --- a/include/configs/tam3517-common.h +++ b/include/configs/tam3517-common.h @@ -254,6 +254,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 16 #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0 #define CONFIG_SYS_NAND_ECCPOS {40, 41, 42, 43, 44, 45, 46, 47,\ diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h index 21edd11ac0..306cf6404e 100644 --- a/include/configs/tricorder.h +++ b/include/configs/tricorder.h @@ -286,6 +286,7 @@ #define CONFIG_SYS_NAND_PAGE_SIZE 2048 #define CONFIG_SYS_NAND_OOBSIZE 64 #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SPL_NAND_DEVICE_WIDTH 8 #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS #define CONFIG_SYS_NAND_ECCPOS {12, 13, 14, 15, 16, 17, 18, 19, 20,\ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\