Skip to contentSkip to conversation

am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

PATCH New Pekon Gupta 3 participants 8 messages Sep 25, 2013 – Oct 2, 2013 4 messages not in the archive

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

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

NAND driver needs to know bus-width of the connected NAND device, in order to perform proper I/O and initialize itself. Currently there is no CONFIG option to provide this information to NAND driver.
- SPL NAND driver does not have framework to parse ONFI parameter page.
- NAND drivers which cannot self initialize !defined(CONFIG_SYS_NAND_SELF_INIT) do not have any information about device bus-width during board_nand_init(), So, any device-width specific configurations are not possible there.
- There should be some mechanism to pass device bus-width information for non-ONFI compliant devices.

This patch
(1) adds CONFIG_SYS_NAND_DEVICE_WIDTH which can take following value 16: NAND device with x16 bus-width
8: NAND device with x8 bus-width
(2) removes GPMC_NAND_ECC_LP_x16_LAYOUT, as NAND layout is determined based on ecc-scheme and oobsize during initialization in board_nand_init(). Thus this config is redundant.

---
 doc/README.nand                        |  9 +++++++++
 drivers/mtd/nand/omap_gpmc.c           | 18 +++++++++++-------
 include/configs/am335x_evm.h           |  2 +-
 include/configs/am3517_crane.h         |  2 +-
 include/configs/am3517_evm.h           |  2 +-
 include/configs/cm_t35.h               |  2 --
 include/configs/devkit8000.h           |  3 +--
 include/configs/dig297.h               |  2 --
 include/configs/igep0033.h             |  8 ++++----
 include/configs/igep00x0.h             |  2 +-
 include/configs/mcx.h                  |  2 +-
 include/configs/omap3_beagle.h         |  3 +--
 include/configs/omap3_evm_common.h     |  1 -
 include/configs/omap3_logic.h          |  1 -
 include/configs/omap3_overo.h          |  3 +--
 include/configs/omap3_pandora.h        |  2 --
 include/configs/omap3_zoom1.h          |  2 --
 include/configs/omap3_zoom2.h          |  1 -
 include/configs/siemens-am33x-common.h |  8 ++++----
 include/configs/tam3517-common.h       |  2 +-
 include/configs/tricorder.h            |  3 +--
 21 files changed, 38 insertions(+), 40 deletions(-)
doc/README.nand +9 -0
index f9c921e..5726ff2 100644
@@ -179,6 +179,15 @@ Configuration Options:
 	This is used by SoC platforms which do not have built-in ELM
 	hardware engine required for BCH ECC correction.
 
+   CONFIG_SYS_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: NAND devices has bus-width=x8
+	- 16: NAND device has bus-width=x16
+
 Platform specific options
 =========================
 
drivers/mtd/nand/omap_gpmc.c +11 -7
index 68786f9..584e33e 100644
@@ -214,11 +214,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)
 	unsigned int eccsize1 = 0x00, eccsize0 = 0x00, bch_wrapmode = 0x00;
 	u32 ecc_size_config_val = 0;
 	u32 ecc_config_val = 0;
-	u32 cs_config1_val;
 
-	/* reconfigure GPMC device-width */
-	cs_config1_val = readl(&gpmc_cfg->cs[cs].config1);
-	writel((cs_config1_val | dev_width << 12), &gpmc_cfg->cs[cs].config1);
 	/* configure GPMC for specific ecc-scheme */
 	switch (bch->ecc_scheme) {
 	case OMAP_ECC_HAM1_CODE_SW:
@@ -772,10 +768,10 @@ 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)
+	if (CONFIG_SYS_NAND_DEVICE_WIDTH == 16)
 		nand->options |= NAND_BUSWIDTH_16;
-
+	else
+		nand->options &= ~NAND_BUSWIDTH_16;
 	nand->chip_delay = 100;
 	nand->ecc.layout = &omap_ecclayout;
 
@@ -795,5 +791,13 @@ int board_nand_init(struct nand_chip *nand)
 	nand->dev_ready = omap_spl_dev_ready;
 #endif
 
+	/* reconfigure GPMC.CONFIG1 register with correct device-width */
+	gpmc_config = readl(&gpmc_cfg->cs[cs].config1);
+	if (nand->options & NAND_BUSWIDTH_16)
+		gpmc_config |= (0x1 << 12);
+	else
+		gpmc_config &= ~(0x1 << 12);
+	writel(gpmc_config, &gpmc_cfg->cs[cs].config1);
+
 	return 0;
 }
include/configs/am335x_evm.h +1 -1
index 978bca7..c92cb2f 100644
@@ -216,6 +216,7 @@
 
 #ifdef CONFIG_NAND
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_BLOCK_SIZE	131072
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
@@ -366,7 +367,6 @@
 /* NAND support */
 #ifdef CONFIG_NAND
 #define CONFIG_CMD_NAND
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #if !defined(CONFIG_SPI_BOOT) && !defined(CONFIG_NOR_BOOT)
 #define MTDIDS_DEFAULT			"nand0=omap2-nand.0"
 #define MTDPARTS_DEFAULT		"mtdparts=omap2-nand.0:128k(SPL)," \
include/configs/am3517_crane.h +1 -1
index 1fd2508..0985221 100644
@@ -269,7 +269,6 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_ENV_IS_IN_NAND		1
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
 
@@ -332,6 +331,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/am3517_evm.h +1 -1
index 6500878..8593d44 100644
@@ -263,7 +263,6 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_ENV_IS_IN_NAND		1
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
 
@@ -326,6 +325,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/cm_t35.h +0 -2
index bc5b66c..1e3dd0d 100644
@@ -164,8 +164,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand at */
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x8_LAYOUT
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of NAND */
 							/* devices */
 /* Environment information */
include/configs/devkit8000.h +1 -2
index cb79b4e..d6c64a3 100644
@@ -116,8 +116,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand at */
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of NAND */
 							/* devices */
 #define CONFIG_JFFS2_NAND
@@ -318,6 +316,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/dig297.h +0 -2
index 30e3908..f69bcec 100644
@@ -143,8 +143,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand at */
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of NAND */
 
 #if defined(CONFIG_CMD_NET)
include/configs/igep0033.h +4 -4
index 3e18a65..ce6b9be 100644
@@ -188,7 +188,6 @@
 /* NAND support */
 #define CONFIG_NAND
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_SYS_NAND_BASE		(0x08000000)	/* phys address CS0 */
 #define CONFIG_SYS_MAX_NAND_DEVICE	1
 #define CONFIG_SYS_NAND_ONFI_DETECTION	1
@@ -248,11 +247,12 @@
 #define CONFIG_SPL_NAND_DRIVERS
 #define CONFIG_SPL_NAND_ECC
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
-#define CONFIG_SYS_NAND_PAGE_COUNT	(CONFIG_SYS_NAND_BLOCK_SIZE / \
-					 CONFIG_SYS_NAND_PAGE_SIZE)
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
+#define CONFIG_SYS_NAND_BLOCK_SIZE	(128*1024)
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
-#define CONFIG_SYS_NAND_BLOCK_SIZE	(128*1024)
+#define CONFIG_SYS_NAND_PAGE_COUNT	(CONFIG_SYS_NAND_BLOCK_SIZE / \
+					 CONFIG_SYS_NAND_PAGE_SIZE)
 #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/igep00x0.h +1 -1
index 9982cf6..7e5bc9b 100644
@@ -268,7 +268,6 @@
 #define PISMO1_NAND_SIZE		GPMC_SIZE_128M /* Configure the PISMO */
 #define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_SYS_NAND_BASE		NAND_BASE
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_ENV_OFFSET		0x260000 /* environment starts here */
 #define CONFIG_ENV_IS_IN_NAND	        1
 #define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
@@ -354,6 +353,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/mcx.h +1 -1
index 5e27ab2..d508978 100644
@@ -322,7 +322,6 @@
 #define PISMO1_NAND_SIZE		GPMC_SIZE_128M
 
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT
 #define CONFIG_ENV_IS_IN_NAND
 #define SMNAND_ENV_OFFSET		0x180000 /* environment starts here */
 
@@ -385,6 +384,7 @@
 #define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
 
 /* NAND boot config */
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/omap3_beagle.h +1 -2
index c1245e7..9050f55 100644
@@ -184,8 +184,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand at */
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of NAND */
 							/* devices */
 
@@ -424,6 +422,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/omap3_evm_common.h +0 -1
index edf6543..564af9a 100644
@@ -210,7 +210,6 @@
 #define CONFIG_SYS_FLASH_BASE		PISMO1_NAND_BASE
 
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT
 #define CONFIG_ENV_OFFSET		SMNAND_ENV_OFFSET
 #elif defined(CONFIG_CMD_ONENAND)
 #define CONFIG_SYS_FLASH_BASE		PISMO1_ONEN_BASE
include/configs/omap3_logic.h +0 -1
index ee6db51..e198c4c 100644
@@ -298,7 +298,6 @@
 
 #if defined(CONFIG_CMD_NAND)
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_ENV_IS_IN_NAND
 #define CONFIG_ENV_OFFSET		SMNAND_ENV_OFFSET
 #endif
include/configs/omap3_overo.h +1 -2
index 88380a4..de06e20 100644
@@ -120,8 +120,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand */
 							/* at CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1	/* Max number of NAND */
 						/* devices */
 #define CONFIG_JFFS2_NAND
@@ -317,6 +315,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/omap3_pandora.h +0 -2
index 91a2568..6ea106d 100644
@@ -131,8 +131,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand */
 							/* at CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1	/* Max number of NAND */
 						/* devices */
 
include/configs/omap3_zoom1.h +0 -2
index c747d52..1dd7b9c 100644
@@ -138,8 +138,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand at */
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of NAND */
 							/* devices */
 #define CONFIG_JFFS2_NAND
include/configs/omap3_zoom2.h +0 -1
index cb8c7ec..9ca7fbe 100644
@@ -158,7 +158,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand at */
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_SYS_MAX_NAND_DEVICE	1
 
 /* Environment information */
include/configs/siemens-am33x-common.h +4 -4
index 5426ee8..197accc 100644
@@ -182,11 +182,12 @@
 #define CONFIG_SPL_NAND_DRIVERS
 #define CONFIG_SPL_NAND_ECC
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
-#define CONFIG_SYS_NAND_PAGE_COUNT	(CONFIG_SYS_NAND_BLOCK_SIZE / \
-					 CONFIG_SYS_NAND_PAGE_SIZE)
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
+#define CONFIG_SYS_NAND_BLOCK_SIZE	(128*1024)
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
-#define CONFIG_SYS_NAND_BLOCK_SIZE	(128*1024)
+#define CONFIG_SYS_NAND_PAGE_COUNT	(CONFIG_SYS_NAND_BLOCK_SIZE / \
+					 CONFIG_SYS_NAND_PAGE_SIZE)
 #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, \
@@ -433,7 +434,6 @@
 		"\0"
 
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
 #define CONFIG_SYS_NAND_BASE		(0x08000000)	/* physical address */
 							/* to access nand at */
 							/* CS0 */
include/configs/tam3517-common.h +1 -1
index 60dd8ff..1f31a87 100644
@@ -188,7 +188,6 @@
 #define PISMO1_NAND_SIZE		GPMC_SIZE_128M
 
 #define CONFIG_NAND_OMAP_GPMC
-#define GPMC_NAND_ECC_LP_x16_LAYOUT
 #define CONFIG_ENV_IS_IN_NAND
 #define SMNAND_ENV_OFFSET		0x180000 /* environment starts here */
 
@@ -252,6 +251,7 @@
 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000
 
 /* NAND boot config */
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
include/configs/tricorder.h +1 -2
index 6daea50..95bbbaa 100644
@@ -106,8 +106,6 @@
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access nand@*/
 							/* CS0 */
-#define GPMC_NAND_ECC_LP_x16_LAYOUT	1
-
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of NAND */
 							/* devices */
 #define CONFIG_BCH
@@ -284,6 +282,7 @@
 
 /* NAND boot config */
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_DEVICE_WIDTH	8
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
 #define CONFIG_SYS_NAND_OOBSIZE		64
Signature · 1 line
1.8.1
#1 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Short comment. Apologies for top posting:

The first incarnations of SPL and loader mainly cared about the boot flash device.

OMAPs require a resistor strap to specify the width of the boot device. The values is latched for SW to read.

As such always a run time check of width was sufficient for boot device.

On dev board we would have many devices and use DIP switch to select which one was in use. A run time not compile time was way to support this.

If information is dynamically available it is better to use this if focus is boot device management.

Other tricks writing patterns and reading results is also possible but simplicity of compile vs. that is debatable.

Regards,
Richard W.

-----Original Message-----
From: Gupta, Pekon
Sent: Wednesday, September 25, 2013 12:18 AM
To: scottwood at freescale.com; Rini, Tom
Cc: u-boot at lists.denx.de; Balbi, Felipe; Kipisz, Steven; sbabic at denx.de; notasas at gmail.com; luca.ceresoli at comelit.it; Woodruff, Richard; weber at corscience.de; peter.barada at logicpd.com; frederik at kriewitz.eu; Tom.Rix at windriver.com; Menon, Nishanth; srinath at mistralsolutions.com; Hiremath, Vaibhav; Gupta, Pekon
Subject: [PATCH 1/1] am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

NAND driver needs to know bus-width of the connected NAND device, in order to perform proper I/O and initialize itself. Currently there is no CONFIG option to provide this information to NAND driver.
- SPL NAND driver does not have framework to parse ONFI parameter page.
- NAND drivers which cannot self initialize !defined(CONFIG_SYS_NAND_SELF_INIT)
do not have any information about device bus-width during board_nand_init(),
So, any device-width specific configurations are not possible there.
- There should be some mechanism to pass device bus-width information for
non-ONFI compliant devices.

@@ -772,10 +768,10 @@ 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)

#2 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Quoted 3 lines · Richard

Short comment. Apologies for top posting:

The first incarnations of SPL and loader mainly cared about the boot flash device.

Is there an SPL that cares about something other than the boot device now?

Quoted 4 lines

OMAPs require a resistor strap to specify the width of the boot device. The values is latched for SW to read.

As such always a run time check of width was sufficient for boot device.

Quoted 8 lines

On dev board we would have many devices and use DIP switch to select which one was in use. A run time not compile time was way to support this.

If information is dynamically available it is better to use this if focus is boot device management.

Other tricks writing patterns and reading results is also possible but simplicity of compile vs. that is debatable.

Regards,
Richard W.

I agree. Outside of SPL (where hardcoding can be useful due to size constraints, and you only care about the boot device), it's best to let drivers determine the best way to learn about such configuration.

Quoted 9 lines

-----Original Message-----
From: Gupta, Pekon
Sent: Wednesday, September 25, 2013 12:18 AM
To: scottwood at freescale.com; Rini, Tom
Cc: u-boot at lists.denx.de; Balbi, Felipe; Kipisz, Steven; sbabic at denx.de; notasas at gmail.com; luca.ceresoli at comelit.it; Woodruff, Richard; weber at corscience.de; peter.barada at logicpd.com; frederik at kriewitz.eu; Tom.Rix at windriver.com; Menon, Nishanth; srinath at mistralsolutions.com; Hiremath, Vaibhav; Gupta, Pekon
Subject: [PATCH 1/1] am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

NAND driver needs to know bus-width of the connected NAND device, in order to perform proper I/O and initialize itself. Currently there is no CONFIG option to provide this information to NAND driver.
- SPL NAND driver does not have framework to parse ONFI parameter page.

Is this about SPL? It looks like a more general change.

Quoted 3 lines

- NAND drivers which cannot self initialize !defined(CONFIG_SYS_NAND_SELF_INIT) do not have any information about device bus-width during board_nand_init(), So, any device-width specific configurations are not possible there.

Convert to self-init. That's what it's for.

-Scott

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Quoted 11 lines · Pekon
Quoted 10 lines
Quoted 3 lines

From: Gupta, Pekon <[email protected]>

NAND driver needs to know bus-width of the connected NAND device, in

order to perform proper I/O and initialize itself. Currently there is no CONFIG option to provide this information to NAND driver.

Quoted 1 line

- SPL NAND driver does not have framework to parse ONFI parameter

page.

Is this about SPL? It looks like a more general change.

Yes, actually I would have loved to see a generic SPL driver for all platforms,

How could that possibly work?

Quoted 4 lines

because SPL is mostly statically configured, and it just does plain NAND read (it doesn?t even support NAND write, etc).
But I do not know the hardware configurations tweaks of other SoC, So at-least have common CONFIG_SYS_NAND_xx which all SPL drivers can use.

Again, are you introducing this symbol for use only in SPL? It looked like you were removing the code that does dynamic detection, which would also affect non-SPL.

-Scott

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Quoted 26 lines · Pekon
Quoted 10 lines

From: Scott Wood [mailto:scottwood at freescale.com]

Quoted 3 lines · Pekon
Quoted 3 lines
Quoted 3 lines

From: Gupta, Pekon <[email protected]>

NAND driver needs to know bus-width of the connected NAND device,

in

Quoted 1 line
Quoted 1 line

order to perform proper I/O and initialize itself. Currently there is no

CONFIG

Quoted 1 line
Quoted 1 line

option to provide this information to NAND driver.

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

- SPL NAND driver does not have framework to parse ONFI parameter

page.

Is this about SPL? It looks like a more general change.

Yes, actually I would have loved to see a generic SPL driver for all platforms,

How could that possibly work?

NAND SPL (as in drivers/mtd/nand/am335x_spl_bch.c) had following limitation
(a) depends on CONFIG_SYS_NAND_xx (for NAND device parameters like erasesize, pagesize, oobsize, etc).
(b) can only do NAND read access.
(c) calls nand_chip->ecc.hwctl() for doing controller specific configurations, which is populated while doing board_nand_init().

Quoted 2 lines

Above (a), (b), and (c) do not have any SoC specific dependency. And can be put into a generic framework which can be used for all SPL drivers.

Not all NAND controllers expose a low-level interface that matches hwctl() (e.g. fsl_ifc and fsl_elbc). For those that do, we do have a common nand_spl_simple.c that works for many drivers, without needing to hardcode the bus width (though perhaps a few bytes could be shaved off by hardcoding it).

BTW, referring to "driver" in NAND context is ambiguous... I prefer to use it to refer to the controller drivers when not qualified as "high level driver" or similar.

Quoted 8 lines

All SoC specific configurations are done in either:
- board_nand_init(): initializations based on device.
- nand_chip->ecc.hwctl(): configurations for ECC scheme.
which is *shared* code between SPL & u-boot driver, and is present in u-boot driver file (like drivers/mtd/nand/omap_gpmc.c), not in SPL driver file.

The missing piece was device bus-width detection which I addresses in this patch by adding CONFIG_SYS_NAND_DEVICE_WIDTH.

The changelog that introduced am335x_spl_bch.c says that "custom read_page implementation is required for proper syndrome generation." Other than that ECC mode, AFAICT you're already using nand_spl_simple.c.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

because SPL is mostly statically configured, and it just does plain NAND read (it doesn?t even support NAND write, etc).
But I do not know the hardware configurations tweaks of other SoC, So at-least have common CONFIG_SYS_NAND_xx which all SPL drivers can

use.

Again, are you introducing this symbol for use only in SPL?

Apart from SPL, CONFIG_SYS_NAND_DEVICE_WIDTH also be useful for
(1) drivers which do not use CONFIG_SYS_NAND_ONFI_DETECTION, where code for reading on-chip ONFI parameters is not enabled in nand_base.c
(2) non ONFI compatible NAND devices.

Unlikely, given that they've all managed to work without this so far. E.g. eLBC and IFC hardcode this information on a per-chip basis in the #defines that hold values for config registers, and prior to this patch omap_gpmc had code to read a config register (regardless of where it originally got set).

Quoted 7 lines
Quoted 6 lines

It looked
like you were removing the code that does dynamic detection, which would also affect non-SPL.

Review

Quoted 2 lines
(quoted diff) +0 -1
-	/* If we are 16 bit dev, our gpmc config tells us that */
 -	if ((readl(&gpmc_cfg->cs[cs].config1) & 0x3000) == 0x1000)
Quoted 8 lines

omap_gpmc.c never had dynamic detection support. Above gpmc_config bit which is used to tell whether device is x16 or x8, gets actually hard-coded in gpmc_init(). Thus it was actually a mechanism to pass hard-coded bus-width information to nand driver.
Refer: arch/arm/cpu/armv7/am33xx/mem.c : gpmc_init()

So, instead of hacking the gpmc_init() everytime for different devices, this patch introduces a generic CONFIG which can be used everywhere.

It looks like you do more NAND config in gpmc_init() than just setting this one bit, so I don't think you save anything here.

BTW, do you not need to set this bit in the config register for the hardware to work in the SPL case?

-Scott

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Quoted 14 lines · Pekon
Quoted 8 lines

From: Scott Wood [mailto:scottwood at freescale.com]

Quoted 4 lines · Pekon

Apart from SPL, CONFIG_SYS_NAND_DEVICE_WIDTH also be useful for
(1) drivers which do not use CONFIG_SYS_NAND_ONFI_DETECTION, where code for reading on-chip ONFI parameters is not enabled in nand_base.c
(2) non ONFI compatible NAND devices.

Quoted 6 lines

Unlikely, given that they've all managed to work without this so far. E.g. eLBC and IFC hardcode this information on a per-chip basis in the #defines that hold values for config registers, and prior to this patch omap_gpmc had code to read a config register (regardless of where it originally got set).

Quoted 4 lines

(1) drivers/mtd/nand/fsl_ifc_spl.c
They are doing same way as OMAP used to. They are also using controller configurations to tell driver about the]NAND bus-width "port_size = (cspr & CSPR_PORT_SIZE_16) ? 16 : 8;"

Yes. Note that CSPR is set per-chip.

Quoted 2 lines

(2) drivers/mtd/nand/fsl_elbc_spl.c
They are doing incomplete check. Rather they are not caring for x16 device

Right, I forgot that eLBC doesn't support 16-bit NAND (hardware limitation).

Quoted 1 line

So CONFIG_SYS_NAND_DEVICE_WIDTH should help them also. right ?

How would it help?

Quoted 1 line

So can this new CONFIG_xx be accepted ?

Only for SPL usage.

Quoted 22 lines
Quoted 22 lines
Quoted 2 lines
Quoted 2 lines

It looked
like you were removing the code that does dynamic detection, which

would

Quoted 6 lines
Quoted 4 lines

also affect non-SPL.

Review

Quoted 2 lines
(quoted diff) +0 -1
-	/* If we are 16 bit dev, our gpmc config tells us that */
 -	if ((readl(&gpmc_cfg->cs[cs].config1) & 0x3000) == 0x1000)

omap_gpmc.c never had dynamic detection support. Above gpmc_config

bit

Quoted 2 lines

which is used to tell whether device is x16 or x8, gets actually hard-coded in gpmc_init(). Thus it was actually a mechanism to pass hard-coded bus-

width

Quoted 5 lines

information to nand driver.
Refer: arch/arm/cpu/armv7/am33xx/mem.c : gpmc_init()

So, instead of hacking the gpmc_init() everytime for different devices, this patch introduces a generic CONFIG which can be used everywhere.

It looks like you do more NAND config in gpmc_init() than just setting this one bit, so I don't think you save anything here.

Quoted 6 lines
Quoted 3 lines

BTW, do you not need to set this bit in the config register for the hardware to work in the SPL case?

Yes, I'm not changing the default configs for GPMC in gpmc_init(), because they are ok for x8 device. I'm just overriding them again during board_nand_init() if CONFIG_SYS_NAND_DEVICE_WIDTH == x16 device.

Is this due to wanting to do identification as x8?

-Scott

#9 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Hi,

Please see last set of queries inline..

Quoted 4 lines

From: Scott Wood [mailto:scottwood at freescale.com]

Quoted 3 lines · Pekon
Quoted 2 lines

From: Scott Wood [mailto:scottwood at freescale.com]

Quoted 1 line · Pekon

[snip]

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

(1) drivers/mtd/nand/fsl_ifc_spl.c
(2) drivers/mtd/nand/fsl_elbc_spl.c
So CONFIG_SYS_NAND_DEVICE_WIDTH should help them also. right ?

How would it help?

I meant, instead of requiring the modification in board file, CONFIG_SPL_DEVICE_WIDTH can be put in include/configs/*.h

Quoted 4 lines
Quoted 1 line

So can this new CONFIG_xx be accepted ?

Only for SPL usage.

Ok. so should I rename to CONFIG_SPL_NAND_DEVICE_WIDTH ?

I have recently sent another version of this patch (as PATCH 2/4) of series below. This series also adds checks for reading ONFI params. Request you to review that also, so that I can include all feedbacks in next patch version.
http://lists.denx.de/pipermail/u-boot/2013-September/163878.html

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

It looked
like you were removing the code that does dynamic detection, which

would

Quoted 2 lines
Quoted 2 lines

also affect non-SPL.

Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +0 -1
-	/* If we are 16 bit dev, our gpmc config tells us that */
 -	if ((readl(&gpmc_cfg->cs[cs].config1) & 0x3000) == 0x1000)

omap_gpmc.c never had dynamic detection support. Above

gpmc_config

Quoted 2 lines
Quoted 2 lines

bit

Quoted 1 line

which is used to tell whether device is x16 or x8, gets actually hard-

coded in

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

gpmc_init(). Thus it was actually a mechanism to pass hard-coded bus-

width

Quoted 5 lines

information to nand driver.
Refer: arch/arm/cpu/armv7/am33xx/mem.c : gpmc_init()

So, instead of hacking the gpmc_init() everytime for different devices, this patch introduces a generic CONFIG which can be used everywhere.

Re-added dynamic detection for u-boot (second stage) in above series. CONFIG_SPL_NAND_DEVICE_WIDTH would be used only for SPL boot.
http://lists.denx.de/pipermail/u-boot/2013-September/163879.html

Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

It looks like you do more NAND config in gpmc_init() than just setting this one bit, so I don't think you save anything here.

BTW, do you not need to set this bit in the config register for the hardware to work in the SPL case?

Yes, I'm not changing the default configs for GPMC in gpmc_init(), because they are ok for x8 device. I'm just overriding them again during board_nand_init() if CONFIG_SYS_NAND_DEVICE_WIDTH == x16 device.

Is this due to wanting to do identification as x8?

Yes, reading of on-chip ONFI params should happen only in x8 mode. [PATCH 1/4] of above series should explain this.
http://lists.denx.de/pipermail/u-boot/2013-September/163882.html

(dropping few emails from CC list as they are bouncing, and u-boot mailman rejects email saying too many recipients).

with regards, pekon

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

PATCH 1/1 am33xx: add CONFIG_SYS_NAND_DEVICE_WIDTH to determine NAND device bus-width

Quoted 10 lines · Pekon

Hi,

Please see last set of queries inline..

Quoted 4 lines

From: Scott Wood [mailto:scottwood at freescale.com]

Quoted 3 lines · Pekon
Quoted 2 lines

From: Scott Wood [mailto:scottwood at freescale.com]

Quoted 1 line · Pekon

[snip]

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

(1) drivers/mtd/nand/fsl_ifc_spl.c
(2) drivers/mtd/nand/fsl_elbc_spl.c
So CONFIG_SYS_NAND_DEVICE_WIDTH should help them also. right ?

How would it help?

I meant, instead of requiring the modification in board file, CONFIG_SPL_DEVICE_WIDTH can be put in include/configs/*.h

Those registers are already specified in include/configs/*.h for eLBC/IFC.

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

So can this new CONFIG_xx be accepted ?

Only for SPL usage.

Ok. so should I rename to CONFIG_SPL_NAND_DEVICE_WIDTH ?

In theory yes, though the other similar SPL NAND parameters use CONFIG_SYS.

-Scott