mtd: nand: omap: optimize and clean-up of OMAP NAND driver
Subsystems (3)
v9 cover mtd: nand: omap: optimize and clean-up of OMAP NAND driver
*changes in v9*
(Important) As this patch series was becoming bulky and had many un-related patches, so it has been split into two parts.
Part-1: Current patch series focuses on cleaning up GPMC and ELM drivers
maintaining existing functionality. And update ecc-scheme selection mechanism across all platforms.
Part-2: Next patch series will focus on optimizing data-paths of GPMC and ELM
drivers for better performance and scalability.
This Part-1 series has following patches, maintaining earlier feedbacks. [PATCH 1/4] [NEW] mtd: nand: omap: make am33xx/elm.c as common driver
- move ELM driver source to drivers/mtd/nand/ to reuse driver on all platforms
[PATCH 2/4] [SPLIT] mtd: nand: omap: enable BCH ECC scheme using ELM for ...
v8 version of this patch is split into follwing part maintaining earlier feedbacks.
- [PATCH 2/4] handles ecc-scheme selection clean-up
- [PATCH 3/4] add CONFIG_NAND_OMAP_ECCSCHEME
[PATCH 3/4] [NEW] mtd: nand: omap: add CONFIG_NAND_OMAP_ECCSCHEME ...
- split from previous patch to introduce new CONFIG_xx for having common method of ecc-scheme selection across all platforms.
- updated include/configs/ for SoC platforms (like OMAP3) which use omap_gpmc.c
[PATCH 4/4] [NEW] am335x: fix GPMC config for NAND and NOR SPL boot
- clean separation of NOR Boot and NAND Boot configurations
- configuration of GPMC registers moved to arch/am33xx from board/ti/am335x/board.c, so that its re-usable for other boards also.
This patch is tested on beagle-bone (white) with NAND cape, using following
(a) Patch to add beaglebone pin-mux support
http://lists.denx.de/pipermail/u-boot/2013-September/163881.html
(b) Hack in board-file to configure GPMC for x16 device
--------------
arch/arm/cpu/armv7/am33xx/mem.c +1 -1
@@ -64,7 +64,7 @@ void gpmc_init(void)u32 base =CONFIG_SYS_FLASH_BASE ;#elif defined(CONFIG_NAND )/* configure GPMC for NAND */ -const u32 gpmc_regs[GPMC_MAX_REG ] = {M_NAND_GPMC_CONFIG1 , +const u32 gpmc_regs[GPMC_MAX_REG ] = {M_NAND_GPMC_CONFIG1 |0x1000 ,M_NAND_GPMC_CONFIG2 ,M_NAND_GPMC_CONFIG3 , M_NAND_GPMC_CONFIG4,
--------------
*changes in v8*
[PATCH] mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
- incorporated following feedbacks from Scott Wood <[email protected]>
- using symbolic names (enums) as values of CONFIG_NAND_OMAP_ECCSCHEME
- updated omap_select_ecc_scheme(): perform ecc-scheme compatibility checks before updating nand_chip.ecc fields. This avoids corrupting of existing ecc-scheme in case of switching failures.
- code clean-up (removed fall-back on omap_select_ecc_scheme() failures)
*changes in v7*
[PATCH] mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
- omap_gpmc.c: fix: free bytes in OOB (ecclayout->oobfree[0].length)
- omap_gpmc.c: cleanup: redundant code added in previous patch versions
- am335x_evm.h: cleanup: redundant code added in previous patch versions
- tricorder.h: fix: CONFIG_NAND_OMAP_ECCSCHEME
*changes in v6*
[PATCH] mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
- incorporated feedbacks from Scott Wood <[email protected]>
- renamed CONFIG_SYS_NAND_ECCSCHEME to CONFIG_NAND_OMAP_ECCSCHEME
- updated omap_select_ecc_scheme() to handle error conditions without depending on caller.
- renamed OMAP_ECC_HAM1_CODE_HW_ROMCODE to OMAP_ECC_HAM1_CODE_HW to keep it naming compatible to linux kernel
- updated doc/README.nand and doc/README.omap3
- moved CONFIG_NAND_OMAP_ECCSCHEME description to README.nand
*changes in v5*
This version of patch is tested on am335x-evm with x8 NAND device, and boots SPL and u-boot from NAND
[PATCH] mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
- re-added omap_read_page_bch(): needed proper sequence of while reading DATA and ECC from NAND page, so that calc_ecc generated from GPMC is understood by ELM.
- added check to see if NAND OOB can accomodate ECC for entire page
*changes in v4*
[PATCH] mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
- removed omap_read_page_bch(): chip->ecc.read_page uses default API nand_read_page_hwecc() in nand_base.c
- updated tricorder.h: added new CONFIGS for ECCSCHEME & ONFI_DETECTION
- converted printf("ECC-SCHEME") to debug("ECC-SCHEME")
*changes in v3*
[PATCH] mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform (complete re-work)
- ecc-scheme is selection is controller by s/w, not CONFIG_NAND_xx
- added omap_select_ecc_scheme(), as common function to handle all ecc-scheme related configurations for both board_nand_init() & omap_nand_switch_ecc().
- removed un-used defines from asm/arch-am33xx/omap_gpmc.h
- updated doc/REAME.nand
- removed un-used defines from asm/omap_gpmc.h
*changes in v2*
- added documentation for CONFIG_NAND_OMAP_xx in doc/README.nand
- added CONFIG_BCH along with CONFIG_NAND_OMAP_ECC_BCH8_CODE_HW_DETECTION_SW to include software library lib/bch.c
- fixed board_nand_init() and omap_enable_hwecc()
*original v1*
This patch series updates BCH8_ECC schemes in mtd/nand/omap_gpmc.c driver
- adds scalability for higher ECC schemes in future.
- removes CONFIG_AM335x and it makes it generic for all platforms.
- optimizes read_data paths
Pekon Gupta (4):
mtd: nand: omap: make am33xx/elm.c as common driver for all OMAPx and
AMxxxx platforms
mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
mtd: nand: omap: add CONFIG_NAND_OMAP_ECCSCHEME for selection of
ecc-scheme
am335x: fix GPMC config for NAND and NOR SPL boot
arch/arm/cpu/armv7/am33xx/Makefile | 1 - arch/arm/cpu/armv7/am33xx/elm.c | 196 -------------------- arch/arm/cpu/armv7/am33xx/mem.c | 52 +++--- arch/arm/include/asm/arch-am33xx/elm.h | 77 -------- arch/arm/include/asm/arch-am33xx/mem.h | 5 - arch/arm/include/asm/omap_elm.h | 77 ++++++++ arch/arm/include/asm/omap_gpmc.h | 16 ++ board/ti/am335x/board.c | 14 +- doc/README.nand | 53 ++++++ doc/README.omap3 | 3 +- drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/omap_elm.c | 196 ++++++++++++++++++++ drivers/mtd/nand/omap_gpmc.c | 323 ++++++++++++++++++++------------- include/configs/am335x_evm.h | 5 +- include/configs/am335x_igep0033.h | 2 + include/configs/am3517_crane.h | 1 + include/configs/am3517_evm.h | 1 + include/configs/devkit8000.h | 1 + include/configs/mcx.h | 2 +- include/configs/omap3_beagle.h | 1 + include/configs/omap3_evm.h | 1 + include/configs/omap3_evm_quick_nand.h | 1 + include/configs/omap3_igep00x0.h | 1 + include/configs/omap3_overo.h | 1 + include/configs/siemens-am33x-common.h | 2 + include/configs/tam3517-common.h | 2 +- include/configs/tricorder.h | 2 +- 27 files changed, 592 insertions(+), 445 deletions(-) delete mode 100644 arch/arm/cpu/armv7/am33xx/elm.c delete mode 100644 arch/arm/include/asm/arch-am33xx/elm.h create mode 100644 arch/arm/include/asm/omap_elm.h create mode 100644 drivers/mtd/nand/omap_elm.c
Signature · 1 line
1.8.1
PATCH v9 1/4 mtd: nand: omap: make am33xx/elm.c as common driver for all OMAPx and AMxxxx platforms
ELM hardware engine which is used for ECC error detection, is present on all latest OMAP SoC (like OMAP4xxx, OMAP5xxx, DRA7xxx, AM33xx, AM43xx). Thus ELM driver should be moved to common drivers/mtd/nand/ folder so that all SoC having on-chip ELM hardware engine can re-use it.
This patch has following changes:
- mv arch/arm/include/asm/arch-am33xx/elm.h arch/arm/include/asm/omap_elm.h
- mv arch/arm/cpu/armv7/am33xx/elm.c drivers/mtd/nand/omap_elm.c
- update Makefiles
- update #include <asm/elm.h>
- add CONFIG_NAND_OMAP_ELM to compile driver/mtd/nand/omap_elm.c and include in all board configs using AM33xx SoC platform.
--- arch/arm/cpu/armv7/am33xx/Makefile | 1 - arch/arm/cpu/armv7/am33xx/elm.c | 196 --------------------------------- arch/arm/include/asm/arch-am33xx/elm.h | 77 ------------- arch/arm/include/asm/omap_elm.h | 77 +++++++++++++ doc/README.nand | 19 ++++ drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/omap_elm.c | 196 +++++++++++++++++++++++++++++++++ drivers/mtd/nand/omap_gpmc.c | 2 +- include/configs/am335x_evm.h | 2 + include/configs/am335x_igep0033.h | 1 + include/configs/siemens-am33x-common.h | 1 + 11 files changed, 298 insertions(+), 275 deletions(-) delete mode 100644 arch/arm/cpu/armv7/am33xx/elm.c delete mode 100644 arch/arm/include/asm/arch-am33xx/elm.h create mode 100644 arch/arm/include/asm/omap_elm.h create mode 100644 drivers/mtd/nand/omap_elm.c
arch/arm/cpu/armv7/am33xx/Makefile +0 -1
@@ -19,4 +19,3 @@ obj-y += ddr.o obj-y += emif4.o obj-y += board.o obj-y += mux.o -obj-$(CONFIG_NAND_OMAP_GPMC) += elm.o
arch/arm/cpu/armv7/am33xx/elm.c deleted +0 -196
196 lines not on this page · raw message
arch/arm/include/asm/arch-am33xx/elm.h deleted +0 -77
77 lines not on this page · raw message
arch/arm/include/asm/omap_elm.h new file +77 -0
77 lines not on this page · raw message
doc/README.nand +19 -0
@@ -169,6 +169,25 @@ Configuration Options: Please convert your driver even if you don't need the extra flexibility, so that one day we can eliminate the old mechanism. + +Platform specific options +========================= + CONFIG_NAND_OMAP_GPMC + Enables omap_gpmc.c driver for OMAPx and AMxxxx platforms. + GPMC controller is used for parallel NAND flash devices, and can + do ECC calculation (not ECC error detection) for HAM1, BCH4, BCH8 + and BCH16 ECC algorithms. + + CONFIG_NAND_OMAP_ELM + Enables omap_elm.c driver for OMAPx and AMxxxx platforms. + ELM controller is used for ECC error detection (not ECC calculation) + of BCH4, BCH8 and BCH16 ECC algorithms. + Some legacy platforms like OMAP3xx do not have in-built ELM h/w engine, + thus such SoC platforms need to depend on software library for ECC error + detection. However ECC calculation on such plaforms would still be + done by GPMC controller. + + NOTE: =====
drivers/mtd/nand/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o obj-$(CONFIG_NAND_SPEAR) += spr_nand.o obj-$(CONFIG_TEGRA_NAND) += tegra_nand.o obj-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o +obj-$(CONFIG_NAND_OMAP_ELM) += omap_elm.o obj-$(CONFIG_NAND_PLAT) += nand_plat.o obj-$(CONFIG_NAND_DOCG4) += docg4.o
drivers/mtd/nand/omap_elm.c new file +196 -0
196 lines not on this page · raw message
drivers/mtd/nand/omap_gpmc.c +1 -1
@@ -16,7 +16,7 @@#include <linux/compiler.h> #include <nand.h> #ifdef CONFIG_AM33XX -#include <asm/arch/elm.h> +#include <asm/omap_elm.h> #endif static uint8_t cs;
include/configs/am335x_evm.h +2 -0
@@ -221,6 +221,8 @@#define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/am33xx/u-boot-spl.lds"#ifdef CONFIG_NAND +#define CONFIG_NAND_OMAP_GPMC +#define CONFIG_NAND_OMAP_ELM #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ CONFIG_SYS_NAND_PAGE_SIZE)
include/configs/am335x_igep0033.h +1 -0
@@ -187,6 +187,7 @@/* NAND support */ #define CONFIG_NAND #define CONFIG_NAND_OMAP_GPMC +#define CONFIG_NAND_OMAP_ELM #define GPMC_NAND_ECC_LP_x16_LAYOUT 1#define CONFIG_SYS_NAND_BASE (0x08000000)/* phys address CS0 */ #define CONFIG_SYS_MAX_NAND_DEVICE 1
include/configs/siemens-am33x-common.h +1 -0
@@ -431,6 +431,7 @@ "\0"#define CONFIG_NAND_OMAP_GPMC +#define CONFIG_NAND_OMAP_ELM #define GPMC_NAND_ECC_LP_x16_LAYOUT 1#define CONFIG_SYS_NAND_BASE (0x08000000)/* physical address */ /* to access nand at */
Signature · 1 line
1.8.1
PATCH v9 1/4 mtd: nand: omap: make am33xx/elm.c as common driver for all OMAPx and AMxxxx platforms
Quoted 22 lines · Pekon Gupta
ELM hardware engine which is used for ECC error detection, is present on all latest OMAP SoC (like OMAP4xxx, OMAP5xxx, DRA7xxx, AM33xx, AM43xx). Thus ELM driver should be moved to common
drivers/mtd/nand/folder so that all SoC having on-chip ELM hardware engine can re-use it.
This patch has following changes:
- mvarch/arm/include/asm/arch-am33xx/elm.harch/arm/include/asm/omap_elm.h
- mvarch/arm/cpu/armv7/am33xx/elm.cdrivers/mtd/nand/omap_elm.c
- update Makefiles
- update #include <asm/elm.h>
- addCONFIG_NAND_OMAP_ELMto compiledriver/mtd/nand/omap_elm.cand include in all board configs using AM33xx SoC platform.Signed-off-by Pekon Gupta <[email protected]>--- arch/arm/cpu/armv7/am33xx/Makefile | 1 - arch/arm/cpu/armv7/am33xx/elm.c | 196 --------------------------------- arch/arm/include/asm/arch-am33xx/elm.h | 77 ------------- arch/arm/include/asm/omap_elm.h | 77 +++++++++++++ doc/README.nand | 19 ++++ drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/omap_elm.c | 196 +++++++++++++++++++++++++++++++++ drivers/mtd/nand/omap_gpmc.c | 2 +-
Quoted 8 lines
include/configs/am335x_evm.h | 2 + include/configs/am335x_igep0033.h | 1 + include/configs/siemens-am33x-common.h | 1 + 11 files changed, 298 insertions(+), 275 deletions(-) delete mode 100644 arch/arm/cpu/armv7/am33xx/elm.c delete mode 100644 arch/arm/include/asm/arch-am33xx/elm.h create mode 100644 arch/arm/include/asm/omap_elm.h create mode 100644 drivers/mtd/nand/omap_elm.c
Please pass "-M -C" to git format-patch so that renames will be identified.
-Scott
PATCH v9 2/4 mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
In reply to Pekon GuptaBCH8_ECC scheme implemented in omap_gpmc.c driver has following favours
+-----------------------------------+-----------------+-----------------+ |ECC Scheme | ECC Calculation | Error Detection | +-----------------------------------+-----------------+-----------------+ |OMAP_ECC_BCH8_CODE_HW |GPMC |ELM H/W engine | |OMAP_ECC_BCH8_CODE_HW_DETECTION_SW |GPMC |S/W BCH library | +-----------------------------------+-----------------+-----------------+
Current implementation limits the BCH8_CODE_HW only for AM33xx device family. (using CONFIG_AM33XX). However, other SoC families (like TI81xx) also have ELM hardware module, and can support ECC error detection using ELM.
This patch
- removes CONFIG_AM33xx
Thus this driver can be reused by all devices having ELM h/w engine.
- adds omap_select_ecc_scheme()
A common function to handle ecc-scheme related configurations. This can be used both during device-probe and via user-space u-boot commads to change ecc-scheme. During device probe ecc-scheme is selected based on CONFIG_NAND_OMAP_ELM or CONFIG_NAND_OMAP_BCH8
- enables CONFIG_BCH
S/W library (lib/bch.c) required by OMAP_ECC_BCHx_CODE_HW_DETECTION_SW is enabled by CONFIG_BCH.
- enables CONFIG_SYS_NAND_ONFI_DETECTION
for auto-detection of ONFI compliant NAND devices
- updates following README doc
doc/README.nand board/ti/am335x/README doc/README.omap3
--- arch/arm/include/asm/omap_gpmc.h | 16 ++ doc/README.nand | 11 ++ drivers/mtd/nand/omap_gpmc.c | 328 ++++++++++++++++++++++++--------------- 3 files changed, 231 insertions(+), 124 deletions(-)
arch/arm/include/asm/omap_gpmc.h +16 -0
@@ -68,4 +68,20 @@ }#endif +enum omap_ecc { +/* 1-bit ECC calculation by Software, Error detection by Software */ +OMAP_ECC_HAM1_CODE_SW =1 ,/* avoid un-initialized int can be 0x0 */ +/* 1-bit ECC calculation by GPMC, Error detection by Software */ +/* ECC layout compatible to legacy ROMCODE. */ +OMAP_ECC_HAM1_CODE_HW , +/* 4-bit ECC calculation by GPMC, Error detection by Software */ +OMAP_ECC_BCH4_CODE_HW_DETECTION_SW , +/* 4-bit ECC calculation by GPMC, Error detection by ELM */ +OMAP_ECC_BCH4_CODE_HW , +/* 8-bit ECC calculation by GPMC, Error detection by Software */ +OMAP_ECC_BCH8_CODE_HW_DETECTION_SW , +/* 8-bit ECC calculation by GPMC, Error detection by ELM */ +OMAP_ECC_BCH8_CODE_HW , +}; +#endif /* __ASM_OMAP_GPMC_H */
doc/README.nand +11 -0
@@ -170,6 +170,17 @@ Configuration Options: flexibility, so that one day we can eliminate the old mechanism. + CONFIG_SYS_NAND_ONFI_DETECTION + Enables detection of ONFI compliant devices during probe. + And fetching device parameters flashed on device, by parsing + ONFI parameter page. + + CONFIG_BCH + Enables software based BCH ECC algorithm present in lib/bch.c + This is used by SoC platforms which do not have built-in ELM + hardware engine required for BCH ECC correction. + + Platform specific options ========================= CONFIG_NAND_OMAP_GPMC
drivers/mtd/nand/omap_gpmc.c +204 -124
460 lines not on this page · raw message
Signature · 1 line
1.8.1
PATCH v9 2/4 mtd: nand: omap: enable BCH ECC scheme using ELM for generic platform
drivers/mtd/nand/omap_gpmc.c line 20
Quoted 12 lines · Pekon Gupta
drivers/mtd/nand/omap_gpmc.c +1
-1@@ -15,15 +15,15 @@#include <linux/bch.h> #include <linux/compiler.h> #include <nand.h> -#ifdef CONFIG_AM33XX +#ifdef CONFIG_NAND_OMAP_ELM #include <asm/omap_elm.h> #endif
Substitutions like this should probably have been part of patch 1/4. Why do you need to ifdef the include at all?
-Scott
PATCH v9 3/4 mtd: nand: omap: add CONFIG_NAND_OMAP_ECCSCHEME for selection of ecc-scheme
In reply to Pekon GuptaThis patch adds new CONFIG_NAND_OMAP_ECCSCHEME, replacing other distributed CONFIG_xx used for selecting NAND ecc-schemes.
This patch aims at solving following issues.
1) Currently ecc-scheme is tied to SoC platform, which prevents user to select other ecc-schemes also supported in hardware. like;
- most of OMAP3 SoC platforms use only 1-bit Hamming ecc-scheme, inspite the fact that they can use higher ecc-schemes like 8-bit ecc-schemes with software based error detection (OMAP_ECC_BCH4_CODE_HW_DETECTION_SW).
- most of AM33xx SoC plaforms use 8-bit BCH ecc-scheme for now, but hardware supports BCH16 ecc-scheme also.
2) Different platforms use different CONFIG_xx to select ecc-schemes, which adds confusion for user while migrating platforms.
- *CONFIG_NAND_OMAP_ELM* which enables ELM hardware engine, selects only 8-bit BCH ecc-scheme with h/w based error-correction (OMAP_ECC_BCH8_CODE_HW) whereas ELM hardware engine supports other ecc-schemes also like; BCH4, and BCH16 (in future).
- *CONFIG_NAND_OMAP_BCH8* selects 8-bit BCH ecc-scheme with s/w based error correction (OMAP_ECC_BCH8_CODE_HW_DETECTION_SW).
- *CONFIG_SPL_NAND_SOFTECC* selects 1-bit Hamming ecc-scheme using s/w library
Thus adding new *CONFIG_NAND_OMAP_ECCSCHEME* de-couples ecc-scheme dependency on SoC platform and NAND driver. And user can select ecc-scheme independently foreach board.
However, selection some hardware based ecc-schemes (OMAP_ECC_BCHx_CODE_HW) still depends on presence of ELM hardware engine on SoC. (Refer doc/README.nand)
--- doc/README.nand | 23 +++++++++++++++++++++++ doc/README.omap3 | 3 +-- drivers/mtd/nand/omap_gpmc.c | 13 ++++--------- include/configs/am335x_evm.h | 3 ++- include/configs/am335x_igep0033.h | 1 + include/configs/am3517_crane.h | 1 + include/configs/am3517_evm.h | 1 + include/configs/devkit8000.h | 1 + include/configs/mcx.h | 2 +- include/configs/omap3_beagle.h | 1 + include/configs/omap3_evm.h | 1 + include/configs/omap3_evm_quick_nand.h | 1 + include/configs/omap3_igep00x0.h | 1 + include/configs/omap3_overo.h | 1 + include/configs/siemens-am33x-common.h | 1 + include/configs/tam3517-common.h | 2 +- include/configs/tricorder.h | 2 +- 17 files changed, 43 insertions(+), 15 deletions(-)
doc/README.nand +23 -0
@@ -198,6 +198,29 @@ Platform specific options detection. However ECC calculation on such plaforms would still be done by GPMC controller. + CONFIG_NAND_OMAP_ECCSCHEME + On OMAP platforms, this CONFIG specifies NAND ECC scheme. + It can take following values: + OMAP_ECC_HAM1_CODE_SW + 1-bit Hamming code using software lib. + (for legacy devices only) + OMAP_ECC_HAM1_CODE_HW + 1-bit Hamming code using GPMC hardware. + (for legacy devices only) + OMAP_ECC_BCH4_CODE_HW_DETECTION_SW + 4-bit BCH code (unsupported) + OMAP_ECC_BCH4_CODE_HW + 4-bit BCH code (unsupported) + OMAP_ECC_BCH8_CODE_HW_DETECTION_SW + 8-bit BCH code with + - ecc calculation using GPMC hardware engine, + - error detection using software library. + - requires CONFIG_BCH to enable software BCH library + (For legacy device which do not have ELM h/w engine) + OMAP_ECC_BCH8_CODE_HW + 8-bit BCH code with + - ecc calculation using GPMC hardware engine, + - error detection using ELM hardware engine. NOTE: =====
doc/README.omap3 +1 -2
@@ -161,8 +161,7 @@ BCH8 To enable hardware assisted BCH8 (8-bit BCH [Bose, Chaudhuri, Hocquenghem]) on OMAP3 devices we can use the BCH library in lib/bch.c. To do so add CONFIG_BCH -to enable the library and CONFIG_NAND_OMAP_BCH8 to to enable hardware assisted -syndrom generation to your board config. +and set CONFIG_NAND_OMAP_ECCSCHEME=5 (refer README.nand) for selecting BCH8_SW. The NAND OOB layout is the same as in linux kernel, if the linux kernel BCH8 implementation for OMAP3 works for you so the u-boot version should also. When you require the SPL to read with BCH8 there are two more configs to
drivers/mtd/nand/omap_gpmc.c +4 -9
@@ -1008,18 +1008,13 @@ int board_nand_init(struct nand_chip *nand) nand->ecc.layout = &omap_ecclayout;/* select ECC scheme */ -#if defined(CONFIG_NAND_OMAP_ELM ) - err =omap_select_ecc_scheme (nand,OMAP_ECC_BCH8_CODE_HW , +#if defined(CONFIG_NAND_OMAP_ECCSCHEME ) + err =omap_select_ecc_scheme (nand,CONFIG_NAND_OMAP_ECCSCHEME ,CONFIG_SYS_NAND_PAGE_SIZE ,CONFIG_SYS_NAND_OOBSIZE ); -#elif defined(CONFIG_NAND_OMAP_BCH8 ) - err =omap_select_ecc_scheme (nand,OMAP_ECC_BCH8_CODE_HW_DETECTION_SW , -CONFIG_SYS_NAND_PAGE_SIZE ,CONFIG_SYS_NAND_OOBSIZE ); -#elif !defined(CONFIG_SPL_BUILD ) || defined(CONFIG_SPL_NAND_SOFTECC ) +#else +/* pagesize and oobsize are not required to configure sw ecc-scheme */ err =omap_select_ecc_scheme (nand,OMAP_ECC_HAM1_CODE_SW ,0 ,0 ); -#else - err =omap_select_ecc_scheme (nand,OMAP_ECC_HAM1_CODE_HW , -CONFIG_SYS_NAND_PAGE_SIZE ,CONFIG_SYS_NAND_OOBSIZE );#endif if (err)return err;
include/configs/am335x_evm.h +2 -1
@@ -240,7 +240,8 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 14 - +#define CONFIG_SYS_NAND_ONFI_DETECTION +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000#endif
include/configs/am335x_igep0033.h +1 -0
@@ -264,6 +264,7 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 14 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
include/configs/am3517_crane.h +1 -0
@@ -340,6 +340,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/am3517_evm.h +1 -0
@@ -334,6 +334,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/devkit8000.h +1 -0
@@ -327,6 +327,7 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
include/configs/mcx.h +1 -1
@@ -353,7 +353,6 @@#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE -#define CONFIG_SPL_NAND_SOFTECC #define CONFIG_SPL_LIBCOMMON_SUPPORT #define CONFIG_SPL_LIBDISK_SUPPORT
@@ -395,6 +394,7 @@ 56, 57, 58, 59, 60, 61, 62, 63}#define CONFIG_SYS_NAND_ECCSIZE 256#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_SW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
include/configs/omap3_beagle.h +1 -0
@@ -432,6 +432,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm.h +1 -0
@@ -107,6 +107,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_evm_quick_nand.h +1 -0
@@ -86,6 +86,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/omap3_igep00x0.h +1 -0
@@ -362,6 +362,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000#endif
include/configs/omap3_overo.h +1 -0
@@ -325,6 +325,7 @@ 10, 11, 12, 13}#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
include/configs/siemens-am33x-common.h +1 -0
@@ -196,6 +196,7 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 14 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW#define CONFIG_SYS_NAND_ECCSTEPS 4#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \
include/configs/tam3517-common.h +1 -1
@@ -225,7 +225,6 @@#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_CONSOLE #define CONFIG_SPL_NAND_SIMPLE -#define CONFIG_SPL_NAND_SOFTECC #define CONFIG_SPL_NAND_WORKSPACE 0x8f07f000/* below BSS */ #define CONFIG_SPL_LIBCOMMON_SUPPORT
@@ -262,6 +261,7 @@ 56, 57, 58, 59, 60, 61, 62, 63}#define CONFIG_SYS_NAND_ECCSIZE 256#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_SW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
include/configs/tricorder.h +1 -1
@@ -138,7 +138,6 @@#define CONFIG_SYS_MAX_NAND_DEVICE 1/* Max number of NAND */ /* devices */ -#define CONFIG_NAND_OMAP_BCH8 #define CONFIG_BCH /* commands to include */
@@ -374,6 +373,7 @@#define CONFIG_SYS_NAND_ECCSIZE 512#define CONFIG_SYS_NAND_ECCBYTES 13 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW_DETECTION_SW#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
Signature · 1 line
1.8.1
PATCH v9 4/4 am335x: fix GPMC config for NAND and NOR SPL boot
In reply to Pekon GuptaGPMC controller is common IP to interface with both NAND and NOR flash devices. Also, it supports max 8 chip-selects, which can be independently connected to any of the devices.
But ROM code expects the boot-device to be connected to only chip-select[0]. Thus to resolve conflict between NOR and NAND boot. This patch:
- combines NOR and NAND configs spread in board files to common gpmc_init()
- configures GPMC based on boot-mode selected for SPL boot.
--- arch/arm/cpu/armv7/am33xx/mem.c | 52 +++++++++++++++++++--------------- arch/arm/include/asm/arch-am33xx/mem.h | 5 ---- board/ti/am335x/board.c | 14 +-------- 3 files changed, 30 insertions(+), 41 deletions(-)
arch/arm/cpu/armv7/am33xx/mem.c +29 -23
@@ -22,17 +22,6 @@struct gpmc *gpmc_cfg; -#if defined(CONFIG_CMD_NAND ) -static const u32 gpmc_m_nand[GPMC_MAX_REG ] = { -M_NAND_GPMC_CONFIG1 , -M_NAND_GPMC_CONFIG2 , -M_NAND_GPMC_CONFIG3 , -M_NAND_GPMC_CONFIG4 , -M_NAND_GPMC_CONFIG5 , -M_NAND_GPMC_CONFIG6 ,0 -}; -#endif -void enable_gpmc_cs_config (const u32 *gpmc_config,struct gpmc_cs *cs,u32 base,u32 size)
@@ -61,11 +50,34 @@ void gpmc_init(void) {/* putting a blanket check on GPMC based on ZeBu for now */ gpmc_cfg = (struct gpmc *)GPMC_BASE ; - -#ifdef CONFIG_CMD_NAND -const u32 *gpmc_config =NULL ; -u32 base =0 ; +#if defined(CONFIG_NOR ) +/* configure GPMC for NOR */ +const u32 gpmc_regs[GPMC_MAX_REG ] = {STNOR_GPMC_CONFIG1 , +STNOR_GPMC_CONFIG2 , +STNOR_GPMC_CONFIG3 , +STNOR_GPMC_CONFIG4 , +STNOR_GPMC_CONFIG5 , +STNOR_GPMC_CONFIG6 , +STNOR_GPMC_CONFIG7 + }; +u32 size =GPMC_SIZE_16M ; +u32 base =CONFIG_SYS_FLASH_BASE ; +#elif defined(CONFIG_NAND ) +/* configure GPMC for NAND */ +const u32 gpmc_regs[GPMC_MAX_REG ] = {M_NAND_GPMC_CONFIG1 , +M_NAND_GPMC_CONFIG2 , +M_NAND_GPMC_CONFIG3 , +M_NAND_GPMC_CONFIG4 , +M_NAND_GPMC_CONFIG5 , +M_NAND_GPMC_CONFIG6 , +0 + }; +u32 size =GPMC_SIZE_256M ; +u32 base =CONFIG_SYS_NAND_BASE ; +#else +const u32 gpmc_regs[GPMC_MAX_REG ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 };u32 size =0 ; +u32 base =0 ;#endif /* global settings */ writel (0x00000008 , &gpmc_cfg->sysconfig);
@@ -81,12 +93,6 @@ void gpmc_init(void)*/ writel (0 , &gpmc_cfg->cs[0 ].config7);sdelay (1000 ); - -#ifdef CONFIG_CMD_NAND - gpmc_config = gpmc_m_nand; - - base =PISMO1_NAND_BASE ; - size =PISMO1_NAND_SIZE ; -enable_gpmc_cs_config (gpmc_config, &gpmc_cfg->cs[0 ], base, size); -#endif +/* enable chip-select specific configurations */ +enable_gpmc_cs_config (gpmc_regs, &gpmc_cfg->cs[0 ], base, size); }
arch/arm/include/asm/arch-am33xx/mem.h +0 -5
@@ -68,9 +68,4 @@#define PISMO2_NAND_CS0 7#define PISMO2_NAND_CS1 8 -/* make it readable for the gpmc_init */ -#define PISMO1_NOR_BASE FLASH_BASE -#define PISMO1_NAND_BASE CONFIG_SYS_NAND_BASE -#define PISMO1_NAND_SIZE GPMC_SIZE_256M -#endif /* endif _MEM_H_ */
board/ti/am335x/board.c +1 -13
@@ -481,26 +481,14 @@ void sdram_init(void)*/ int board_init (void ) { -#ifdef CONFIG_NOR -const u32 gpmc_nor[GPMC_MAX_REG ] = {STNOR_GPMC_CONFIG1 , -STNOR_GPMC_CONFIG2 ,STNOR_GPMC_CONFIG3 ,STNOR_GPMC_CONFIG4 , -STNOR_GPMC_CONFIG5 ,STNOR_GPMC_CONFIG6 ,STNOR_GPMC_CONFIG7 }; -#endif -#if defined(CONFIG_HW_WATCHDOG )hw_watchdog_init ();#endif gd->bd->bi_boot_params =CONFIG_SYS_SDRAM_BASE +0x100 ; - +#if defined(CONFIG_NOR ) || defined(CONFIG_NAND )gpmc_init (); - -#ifdef CONFIG_NOR -/* Reconfigure CS0 for NOR instead of NAND. */ -enable_gpmc_cs_config (gpmc_nor, &gpmc_cfg->cs[0 ], -CONFIG_SYS_FLASH_BASE ,GPMC_SIZE_16M );#endif -return 0 ; }
Signature · 1 line
1.8.1