Commit 3f719069c884284b2457448a7afe32b02bd4f782

Authored by pekon gupta
Committed by Scott Wood
1 parent d016dc42ce

mtd: nand: omap: add CONFIG_NAND_OMAP_ECCSCHEME for selection of ecc-scheme

This 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)

Signed-off-by: Pekon Gupta <pekon@ti.com>

Showing 17 changed files with 43 additions and 15 deletions Side-by-side Diff

... ... @@ -208,6 +208,29 @@
208 208 detection. However ECC calculation on such plaforms would still be
209 209 done by GPMC controller.
210 210  
  211 + CONFIG_NAND_OMAP_ECCSCHEME
  212 + On OMAP platforms, this CONFIG specifies NAND ECC scheme.
  213 + It can take following values:
  214 + OMAP_ECC_HAM1_CODE_SW
  215 + 1-bit Hamming code using software lib.
  216 + (for legacy devices only)
  217 + OMAP_ECC_HAM1_CODE_HW
  218 + 1-bit Hamming code using GPMC hardware.
  219 + (for legacy devices only)
  220 + OMAP_ECC_BCH4_CODE_HW_DETECTION_SW
  221 + 4-bit BCH code (unsupported)
  222 + OMAP_ECC_BCH4_CODE_HW
  223 + 4-bit BCH code (unsupported)
  224 + OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
  225 + 8-bit BCH code with
  226 + - ecc calculation using GPMC hardware engine,
  227 + - error detection using software library.
  228 + - requires CONFIG_BCH to enable software BCH library
  229 + (For legacy device which do not have ELM h/w engine)
  230 + OMAP_ECC_BCH8_CODE_HW
  231 + 8-bit BCH code with
  232 + - ecc calculation using GPMC hardware engine,
  233 + - error detection using ELM hardware engine.
211 234  
212 235 NOTE:
213 236 =====
... ... @@ -161,8 +161,7 @@
161 161  
162 162 To enable hardware assisted BCH8 (8-bit BCH [Bose, Chaudhuri, Hocquenghem]) on
163 163 OMAP3 devices we can use the BCH library in lib/bch.c. To do so add CONFIG_BCH
164   -to enable the library and CONFIG_NAND_OMAP_BCH8 to to enable hardware assisted
165   -syndrom generation to your board config.
  164 +and set CONFIG_NAND_OMAP_ECCSCHEME=5 (refer README.nand) for selecting BCH8_SW.
166 165 The NAND OOB layout is the same as in linux kernel, if the linux kernel BCH8
167 166 implementation for OMAP3 works for you so the u-boot version should also.
168 167 When you require the SPL to read with BCH8 there are two more configs to
drivers/mtd/nand/omap_gpmc.c
... ... @@ -1004,18 +1004,13 @@
1004 1004 nand->ecc.layout = &omap_ecclayout;
1005 1005  
1006 1006 /* select ECC scheme */
1007   -#if defined(CONFIG_NAND_OMAP_ELM)
1008   - err = omap_select_ecc_scheme(nand, OMAP_ECC_BCH8_CODE_HW,
  1007 +#if defined(CONFIG_NAND_OMAP_ECCSCHEME)
  1008 + err = omap_select_ecc_scheme(nand, CONFIG_NAND_OMAP_ECCSCHEME,
1009 1009 CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE);
1010   -#elif defined(CONFIG_NAND_OMAP_BCH8)
1011   - err = omap_select_ecc_scheme(nand, OMAP_ECC_BCH8_CODE_HW_DETECTION_SW,
1012   - CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE);
1013   -#elif !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_NAND_SOFTECC)
  1010 +#else
  1011 + /* pagesize and oobsize are not required to configure sw ecc-scheme */
1014 1012 err = omap_select_ecc_scheme(nand, OMAP_ECC_HAM1_CODE_SW,
1015 1013 0, 0);
1016   -#else
1017   - err = omap_select_ecc_scheme(nand, OMAP_ECC_HAM1_CODE_HW,
1018   - CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE);
1019 1014 #endif
1020 1015 if (err)
1021 1016 return err;
include/configs/am335x_evm.h
... ... @@ -240,7 +240,8 @@
240 240  
241 241 #define CONFIG_SYS_NAND_ECCSIZE 512
242 242 #define CONFIG_SYS_NAND_ECCBYTES 14
243   -
  243 +#define CONFIG_SYS_NAND_ONFI_DETECTION
  244 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW
244 245 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
245 246 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
246 247 #endif
include/configs/am335x_igep0033.h
... ... @@ -264,6 +264,7 @@
264 264  
265 265 #define CONFIG_SYS_NAND_ECCSIZE 512
266 266 #define CONFIG_SYS_NAND_ECCBYTES 14
  267 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW
267 268  
268 269 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
269 270  
include/configs/am3517_crane.h
... ... @@ -340,6 +340,7 @@
340 340 10, 11, 12, 13}
341 341 #define CONFIG_SYS_NAND_ECCSIZE 512
342 342 #define CONFIG_SYS_NAND_ECCBYTES 3
  343 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
343 344 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
344 345 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
345 346  
include/configs/am3517_evm.h
... ... @@ -334,6 +334,7 @@
334 334 10, 11, 12, 13}
335 335 #define CONFIG_SYS_NAND_ECCSIZE 512
336 336 #define CONFIG_SYS_NAND_ECCBYTES 3
  337 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
337 338 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
338 339 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
339 340  
include/configs/devkit8000.h
... ... @@ -327,6 +327,7 @@
327 327  
328 328 #define CONFIG_SYS_NAND_ECCSIZE 512
329 329 #define CONFIG_SYS_NAND_ECCBYTES 3
  330 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
330 331  
331 332 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
332 333  
include/configs/mcx.h
... ... @@ -353,7 +353,6 @@
353 353 #define CONFIG_SPL_FRAMEWORK
354 354 #define CONFIG_SPL_BOARD_INIT
355 355 #define CONFIG_SPL_NAND_SIMPLE
356   -#define CONFIG_SPL_NAND_SOFTECC
357 356  
358 357 #define CONFIG_SPL_LIBCOMMON_SUPPORT
359 358 #define CONFIG_SPL_LIBDISK_SUPPORT
... ... @@ -395,6 +394,7 @@
395 394 56, 57, 58, 59, 60, 61, 62, 63}
396 395 #define CONFIG_SYS_NAND_ECCSIZE 256
397 396 #define CONFIG_SYS_NAND_ECCBYTES 3
  397 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_SW
398 398  
399 399 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
400 400  
include/configs/omap3_beagle.h
... ... @@ -432,6 +432,7 @@
432 432 10, 11, 12, 13}
433 433 #define CONFIG_SYS_NAND_ECCSIZE 512
434 434 #define CONFIG_SYS_NAND_ECCBYTES 3
  435 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
435 436 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
436 437 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
437 438  
include/configs/omap3_evm.h
... ... @@ -107,6 +107,7 @@
107 107 10, 11, 12, 13}
108 108 #define CONFIG_SYS_NAND_ECCSIZE 512
109 109 #define CONFIG_SYS_NAND_ECCBYTES 3
  110 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
110 111 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
111 112 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
112 113  
include/configs/omap3_evm_quick_nand.h
... ... @@ -86,6 +86,7 @@
86 86 10, 11, 12, 13}
87 87 #define CONFIG_SYS_NAND_ECCSIZE 512
88 88 #define CONFIG_SYS_NAND_ECCBYTES 3
  89 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
89 90 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
90 91 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
91 92  
include/configs/omap3_igep00x0.h
... ... @@ -362,6 +362,7 @@
362 362 10, 11, 12, 13}
363 363 #define CONFIG_SYS_NAND_ECCSIZE 512
364 364 #define CONFIG_SYS_NAND_ECCBYTES 3
  365 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
365 366 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
366 367 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
367 368 #endif
include/configs/omap3_overo.h
... ... @@ -325,6 +325,7 @@
325 325 10, 11, 12, 13}
326 326 #define CONFIG_SYS_NAND_ECCSIZE 512
327 327 #define CONFIG_SYS_NAND_ECCBYTES 3
  328 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_HW
328 329 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
329 330 #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
330 331  
include/configs/siemens-am33x-common.h
... ... @@ -196,6 +196,7 @@
196 196  
197 197 #define CONFIG_SYS_NAND_ECCSIZE 512
198 198 #define CONFIG_SYS_NAND_ECCBYTES 14
  199 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW
199 200  
200 201 #define CONFIG_SYS_NAND_ECCSTEPS 4
201 202 #define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \
include/configs/tam3517-common.h
... ... @@ -225,7 +225,6 @@
225 225 #define CONFIG_SPL_BOARD_INIT
226 226 #define CONFIG_SPL_CONSOLE
227 227 #define CONFIG_SPL_NAND_SIMPLE
228   -#define CONFIG_SPL_NAND_SOFTECC
229 228 #define CONFIG_SPL_NAND_WORKSPACE 0x8f07f000 /* below BSS */
230 229  
231 230 #define CONFIG_SPL_LIBCOMMON_SUPPORT
... ... @@ -262,6 +261,7 @@
262 261 56, 57, 58, 59, 60, 61, 62, 63}
263 262 #define CONFIG_SYS_NAND_ECCSIZE 256
264 263 #define CONFIG_SYS_NAND_ECCBYTES 3
  264 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_HAM1_CODE_SW
265 265  
266 266 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
267 267  
include/configs/tricorder.h
... ... @@ -138,7 +138,6 @@
138 138  
139 139 #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */
140 140 /* devices */
141   -#define CONFIG_NAND_OMAP_BCH8
142 141 #define CONFIG_BCH
143 142 #define CONFIG_SYS_NAND_MAX_OOBFREE 2
144 143 #define CONFIG_SYS_NAND_MAX_ECCPOS 56
... ... @@ -376,6 +375,7 @@
376 375  
377 376 #define CONFIG_SYS_NAND_ECCSIZE 512
378 377 #define CONFIG_SYS_NAND_ECCBYTES 13
  378 +#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
379 379  
380 380 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE
381 381