Skip to contentSkip to conversation

mtd: nand: omap: add CONFIG_SPL_NAND_DEVICE_WIDTH to determine NAND device bus-width

PATCH New Pekon Gupta 3 participants 3 messages Dec 5, 2013 – Dec 7, 2013

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

PATCH 1/1 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.

---
 doc/README.nand                        |  9 +++++++++
 drivers/mtd/nand/omap_gpmc.c           | 14 ++++++++++----
 include/configs/am335x_evm.h           |  1 +
 include/configs/am335x_igep0033.h      |  1 +
 include/configs/am3517_crane.h         |  1 +
 include/configs/am3517_evm.h           |  1 +
 include/configs/cm_t35.h               |  1 +
 include/configs/devkit8000.h           |  1 +
 include/configs/dig297.h               |  1 +
 include/configs/mcx.h                  |  1 +
 include/configs/omap3_beagle.h         |  1 +
 include/configs/omap3_evm_common.h     |  2 +-
 include/configs/omap3_igep00x0.h       |  1 +
 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 +
 21 files changed, 38 insertions(+), 6 deletions(-)
doc/README.nand +9 -0
index b91f198..a07863a 100644
@@ -190,6 +190,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
 =========================
drivers/mtd/nand/omap_gpmc.c +10 -4
index fae00be..1870152 100644
@@ -861,13 +861,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,
include/configs/am335x_evm.h +1 -0
index 9ccbc20..5f5804e 100644
@@ -228,6 +228,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, \
include/configs/am335x_igep0033.h +1 -0
index c00d54f..a776707 100644
@@ -252,6 +252,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, \
include/configs/am3517_crane.h +1 -0
index 4407b45..9537bc5 100644
@@ -334,6 +334,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}
include/configs/am3517_evm.h +1 -0
index 7f52ce4..47e0f0f 100644
@@ -328,6 +328,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}
include/configs/cm_t35.h +1 -0
index 52a1f05..0789bad 100644
@@ -167,6 +167,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		3
 #define CONFIG_ZERO_BOOTDELAY_CHECK
include/configs/devkit8000.h +1 -0
index 16a00eb..9379d39 100644
@@ -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	0
 #define CONFIG_SYS_NAND_ECCPOS		{2, 3, 4, 5, 6, 7, 8, 9,\
 						10, 11, 12, 13}
include/configs/dig297.h +1 -0
index af6f56b..3333460 100644
@@ -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)
include/configs/mcx.h +1 -0
index dd4afb8..8074008 100644
@@ -386,6 +386,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,\
include/configs/omap3_beagle.h +1 -0
index 8127f87..0d36105 100644
@@ -424,6 +424,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}
include/configs/omap3_evm_common.h +1 -1
index 7f3424b..8a16d09 100644
@@ -120,7 +120,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)
include/configs/omap3_igep00x0.h +1 -0
index 172c3a3..474c1c8 100644
@@ -356,6 +356,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}
include/configs/omap3_logic.h +1 -0
index 0d03c75..9f9035e 100644
@@ -295,6 +295,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
include/configs/omap3_overo.h +1 -0
index 007e27f..e131d23 100644
@@ -317,6 +317,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}
include/configs/omap3_pandora.h +1 -1
index da67787..de03a7e 100644
@@ -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
include/configs/omap3_zoom1.h +1 -0
index f0fa96e..82f16fb 100644
@@ -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"
include/configs/omap3_zoom2.h +1 -0
index 8b0ac3d..f145daa 100644
@@ -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
include/configs/siemens-am33x-common.h +1 -0
index 018e22b..5200a5f 100644
@@ -184,6 +184,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, \
include/configs/tam3517-common.h +1 -0
index d3f9a4e..7e2ce8f 100644
@@ -252,6 +252,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,\
include/configs/tricorder.h +1 -0
index 62f97d2..d9a6215 100644
@@ -364,6 +364,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,\
Signature · 1 line
1.8.1
#1 lore raw

PATCH 1/1 mtd: nand: omap: add CONFIG_SPL_NAND_DEVICE_WIDTH to determine NAND device bus-width

Hi Pekon,

Just a comment for OMAP3-based IGEP boards, see below ...

2013/12/5 Pekon Gupta <[email protected]>:

Quoted 221 lines

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.

---
 doc/README.nand                        |  9 +++++++++
 drivers/mtd/nand/omap_gpmc.c           | 14 ++++++++++----
 include/configs/am335x_evm.h           |  1 +
 include/configs/am335x_igep0033.h      |  1 +
 include/configs/am3517_crane.h         |  1 +
 include/configs/am3517_evm.h           |  1 +
 include/configs/cm_t35.h               |  1 +
 include/configs/devkit8000.h           |  1 +
 include/configs/dig297.h               |  1 +
 include/configs/mcx.h                  |  1 +
 include/configs/omap3_beagle.h         |  1 +
 include/configs/omap3_evm_common.h     |  2 +-
 include/configs/omap3_igep00x0.h       |  1 +
 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 +
 21 files changed, 38 insertions(+), 6 deletions(-)
doc/README.nand +9 -0
index b91f198..a07863a 100644
@@ -190,6 +190,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
 =========================
drivers/mtd/nand/omap_gpmc.c +10 -4
index fae00be..1870152 100644
@@ -861,13 +861,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,
include/configs/am335x_evm.h +1 -0
index 9ccbc20..5f5804e 100644
@@ -228,6 +228,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, \
include/configs/am335x_igep0033.h +1 -0
index c00d54f..a776707 100644
@@ -252,6 +252,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, \
include/configs/am3517_crane.h +1 -0
index 4407b45..9537bc5 100644
@@ -334,6 +334,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}
include/configs/am3517_evm.h +1 -0
index 7f52ce4..47e0f0f 100644
@@ -328,6 +328,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}
include/configs/cm_t35.h +1 -0
index 52a1f05..0789bad 100644
@@ -167,6 +167,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               3
 #define CONFIG_ZERO_BOOTDELAY_CHECK
include/configs/devkit8000.h +1 -0
index 16a00eb..9379d39 100644
@@ -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  0
 #define CONFIG_SYS_NAND_ECCPOS         {2, 3, 4, 5, 6, 7, 8, 9,\
                                                10, 11, 12, 13}
include/configs/dig297.h +1 -0
index af6f56b..3333460 100644
@@ -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)
include/configs/mcx.h +1 -0
index dd4afb8..8074008 100644
@@ -386,6 +386,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,\
include/configs/omap3_beagle.h +1 -0
index 8127f87..0d36105 100644
@@ -424,6 +424,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}
include/configs/omap3_evm_common.h +1 -1
index 7f3424b..8a16d09 100644
@@ -120,7 +120,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)
include/configs/omap3_igep00x0.h +0 -0
index 172c3a3..474c1c8 100644

include/configs/omap3_igep00x0.h line 359

Quoted 4 lines
include/configs/omap3_igep00x0.h +1 -0
@@ -356,6 +356,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

The device width for OMAP3-based IGEP boards is 16 not 8

Quoted 103 lines
include/configs/omap3_igep00x0.h +0 -0
 #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}
include/configs/omap3_logic.h +1 -0
index 0d03c75..9f9035e 100644
@@ -295,6 +295,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
include/configs/omap3_overo.h +1 -0
index 007e27f..e131d23 100644
@@ -317,6 +317,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}
include/configs/omap3_pandora.h +1 -1
index da67787..de03a7e 100644
@@ -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
include/configs/omap3_zoom1.h +1 -0
index f0fa96e..82f16fb 100644
@@ -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"
include/configs/omap3_zoom2.h +1 -0
index 8b0ac3d..f145daa 100644
@@ -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
include/configs/siemens-am33x-common.h +1 -0
index 018e22b..5200a5f 100644
@@ -184,6 +184,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, \
include/configs/tam3517-common.h +1 -0
index d3f9a4e..7e2ce8f 100644
@@ -252,6 +252,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,\
include/configs/tricorder.h +1 -1
index 62f97d2..d9a6215 100644
@@ -364,6 +364,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,\
--

1.8.1

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Best regards,
Enric

#2 lore raw

PATCH 1/1 mtd: nand: omap: add CONFIG_SPL_NAND_DEVICE_WIDTH to determine NAND device bus-width

In reply to Pekon Gupta
Quoted 6 lines · Pekon Gupta

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.

Yes, at least for smaller SPLs.

Quoted 11 lines

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

See below.

Quoted 2 lines

(3) Non-ONFI compliant devices need some mechanism to specify device bus-width to driver.

Does an x8 "READ ID" work with non-ONFI devices? If not, you need something, and I suppose you need to hardcode whether an ONFI device is present -- but for non-SPL it's better to do it in a way that is per-device, such as having board code initialize certain registers. If you really want to do it this way, though, there's already a variable for this: CONFIG_SYS_NAND_BUSWIDTH_16BIT

Just be sure to update the documentation to add to the list of drivers that care about that symbol.

Quoted 31 lines
---
 doc/README.nand                        |  9 +++++++++
 drivers/mtd/nand/omap_gpmc.c           | 14 ++++++++++----
 include/configs/am335x_evm.h           |  1 +
 include/configs/am335x_igep0033.h      |  1 +
 include/configs/am3517_crane.h         |  1 +
 include/configs/am3517_evm.h           |  1 +
 include/configs/cm_t35.h               |  1 +
 include/configs/devkit8000.h           |  1 +
 include/configs/dig297.h               |  1 +
 include/configs/mcx.h                  |  1 +
 include/configs/omap3_beagle.h         |  1 +
  include/configs/omap3_evm_common.h     |  2 +-
 include/configs/omap3_igep00x0.h       |  1 +
 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 +
 21 files changed, 38 insertions(+), 6 deletions(-)
doc/README.nand +0 -0
index b91f198..a07863a 100644
@@ -190,6 +190,15 @@ Configuration Options:
 	This is used by SoC platforms which do not have built-in ELM

doc/README.nand Configuration Options: · line 200

Quoted 10 lines
doc/README.nand +8 -0
 	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

I don't understand "cannot self initialize". I understand "doesn't currently self initialize", but if that's causing a problem then why not convert the driver to use self-init?

SPL is a different situation as it typically doesn't have dynamic ID code at all (as opposed to the question of whether driver code can be inserted between nand_scan_ident and nand_scan_tail).

Quoted 16 lines
doc/README.nand +0 -0
 Platform specific options
 =========================
drivers/mtd/nand/omap_gpmc.c +0 -4
index fae00be..1870152 100644
@@ -861,13 +861,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;

drivers/mtd/nand/omap_gpmc.c int board_nand_init(struct nand_chip *nand) · line 875

Quoted 10 lines
drivers/mtd/nand/omap_gpmc.c +9 -0
 
+	/* 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);
+	}

This doesn't appear to be limited to SPL, or even to (SPL || non-ONFI).

-Scott