mtd: nand: fsmc: Add BCH4 SW ECC support for SPEAr600
Subsystems (3)
PATCH 1/4 mtd: nand: fsmc: Add BCH4 SW ECC support for SPEAr600
This patch adds support for 4-bit ECC BCH4 for the SPEAr600 SoC. This can be used by boards equipped with a NAND chip that requires 4-bit ECC strength. The SPEAr600 HW ECC only supports 1-bit ECC strength.
To enable SW BCH4, you need to specify this in your config header:
And use the command "nandecc bch4" to select this ECC scheme upon runtime.
Tested on SPEAr600 x600 board.
--- drivers/mtd/nand/fsmc_nand.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/mtd/nand/fsmc_nand.c +40 -0
@@ -13,6 +13,7 @@#include <asm/io.h> #include <linux/bitops.h> #include <linux/err.h> +#include <linux/mtd/nand_bch.h> #include <linux/mtd/nand_ecc.h> #include <linux/mtd/fsmc_nand.h> #include <asm/arch/hardware.h>
@@ -390,6 +391,45 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,return 0 ; } +#ifndef CONFIG_SPL_BUILD +/* +* fsmc_nand_switch_ecc - switch the ECC operation between different engines +* +* @eccstrength - the number of bits that could be corrected +* (1 - HW, 4 - SW BCH4) +*/ +int __maybe_unused fsmc_nand_switch_ecc (uint32_t eccstrength) +{ +struct nand_chip *nand; +struct mtd_info *mtd; +int err =0 ; + + mtd = &nand_info[nand_curr_device]; + nand = mtd->priv; + +/* Setup the ecc configurations again */ +if (eccstrength ==1 ) { + nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.bytes =3 ; + nand->ecc.strength =1 ; + nand->ecc.layout = &fsmc_ecc1_layout; + nand->ecc.correct = nand_correct_data; + }else { + nand->ecc.mode =NAND_ECC_SOFT_BCH ; + nand->ecc.calculate = nand_bch_calculate_ecc; + nand->ecc.correct = nand_bch_correct_data; + nand->ecc.bytes =7 ; + nand->ecc.strength =4 ; + nand->ecc.layout =NULL ; + } + +/* Update NAND handling after ECC mode switch */ + err =nand_scan_tail (mtd); + +return err; +} +#endif /* CONFIG_SPL_BUILD */ +int fsmc_nand_init (struct nand_chip *nand) {static int chip_nr;
Signature · 1 line
2.5.1
PATCH 2/4 arm: spear: Add command to switch between 1-bit HW ECC and SW BCH4
This patch adds the "nandecc" command to switch between the SPEAr600 internal 1-bit HW ECC and the 4-bit SW BCH4 ECC. This can be needed to support NAND chips with a stronger ECC than 1-bit, as on the x600. And to dynamically switch between both ECC schemes for backwards compatibility.
--- arch/arm/cpu/arm926ejs/spear/cpu.c | 34 ++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-spear/spr_misc.h | 1 + 2 files changed, 35 insertions(+)
arch/arm/cpu/arm926ejs/spear/cpu.c +34 -0
@@ -83,3 +83,37 @@ int print_cpuinfo(void)return 0 ; }#endif + +#if !defined(CONFIG_SPL_BUILD ) && defined(CONFIG_NAND_ECC_BCH ) +static int do_switch_ecc (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +if (argc !=2 ) + goto usage; + +if (strncmp (argv[1 ],"hw" ,2 ) ==0 ) { +/* 1-bit HW ECC */ +printf ("Switching to 1-bit HW ECC\n" ); +fsmc_nand_switch_ecc (1 ); + }else if (strncmp (argv[1 ],"bch4" ,2 ) ==0 ) { +/* 4-bit SW ECC BCH4 */ +printf ("Switching to 4-bit SW ECC (BCH4)\n" ); +fsmc_nand_switch_ecc (4 ); + }else { + goto usage; + } + +return 0 ; + +usage: +printf ("Usage: nandecc %s\n" , cmdtp->usage); +return 1 ; +} + +U_BOOT_CMD ( + nandecc,2 ,0 , do_switch_ecc, +"switch NAND ECC calculation algorithm" , +"hw|bch4 - Switch between NAND hardware 1-bit HW and" +" 4-bit SW BCH\n" +); +#endif
arch/arm/include/asm/arch-spear/spr_misc.h +1 -0
@@ -253,5 +253,6 @@ struct misc_regs {#define SOC_SPEAR320 203extern int get_socrev (void ); +int fsmc_nand_switch_ecc (uint32_t eccstrength);#endif
Signature · 1 line
2.5.1
PATCH 2/4 arm: spear: Add command to switch between 1-bit HW ECC and SW BCH4
Quoted 11 lines · Stefan Roese
This patch adds the "nandecc" command to switch between the SPEAr600 internal 1-bit HW ECC and the 4-bit SW BCH4 ECC. This can be needed to support NAND chips with a stronger ECC than 1-bit, as on the x600. And to dynamically switch between both ECC schemes for backwards compatibility.
Signed-off-by Stefan Roese <[email protected]>Cc Viresh Kumar <[email protected]>--- arch/arm/cpu/arm926ejs/spear/cpu.c | 34 ++++++++++++++++++++++++++++++ arch/arm/include/asm/arch-spear/spr_misc.h | 1 + 2 files changed, 35 insertions(+)
For [2-4]/4:
Signature · 1 line
viresh
PATCH 2/4 arm: spear: Add command to switch between 1-bit HW ECC and SW BCH4
In reply to Stefan RoeseQuoted 8 lines · Stefan Roese
This patch adds the "nandecc" command to switch between the SPEAr600 internal 1-bit HW ECC and the 4-bit SW BCH4 ECC. This can be needed to support NAND chips with a stronger ECC than 1-bit, as on the x600. And to dynamically switch between both ECC schemes for backwards compatibility.
Signed-off-by Stefan Roese <[email protected]>Cc Viresh Kumar <[email protected]>Acked-by Viresh Kumar <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/c994b4b7/attachment.sig>
PATCH 3/4 arm: spear: Add BCH4 SW support to SPEAr600 x600 board
In reply to Stefan RoeseThis board is equipped with a Micron NAND chip (MT29F1G08ABADAH4) that needs 4-bit ECC. But the SPEAr600 only supports 1-bit HW ECC internally. This patch enables the SW 4-bit BCH support for this board.
--- include/configs/x600.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/x600.h +2 -0
@@ -67,6 +67,8 @@#define CONFIG_MTD_ECC_SOFT #define CONFIG_SYS_FSMC_NAND_8BIT #define CONFIG_SYS_NAND_ONFI_DETECTION +#define CONFIG_NAND_ECC_BCH +#define CONFIG_BCH /* UBI/UBI config options */ #define CONFIG_MTD_DEVICE
Signature · 1 line
2.5.1
PATCH 3/4 arm: spear: Add BCH4 SW support to SPEAr600 x600 board
Quoted 6 lines · Stefan Roese
This board is equipped with a Micron NAND chip (MT29F1G08ABADAH4) that needs 4-bit ECC. But the SPEAr600 only supports 1-bit HW ECC internally. This patch enables the SW 4-bit BCH support for this board.
Signed-off-by Stefan Roese <[email protected]>Cc Viresh Kumar <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/c9b8f7e4/attachment.sig>
PATCH 4/4 arm: spear: Enable THUMB mode on x600 board
In reply to Stefan RoeseTo reduce the size of the U-Boot image on the x600 board, lets enable the THUMB mode. This reduces the overall size to less than 0x6000 bytes. Fitting it again in the onboard NOR flash.
--- include/configs/x600.h | 1 + 1 file changed, 1 insertion(+)
include/configs/x600.h +1 -0
@@ -17,6 +17,7 @@#define CONFIG_SPEAR600 /* SPEAr600 SoC */ #define CONFIG_X600 /* on X600 board */ #define CONFIG_SYS_GENERIC_BOARD +#define CONFIG_SYS_THUMB_BUILD #include <asm/arch/hardware.h>
Signature · 1 line
2.5.1
PATCH 4/4 arm: spear: Enable THUMB mode on x600 board
Quoted 6 lines · Stefan Roese
To reduce the size of the U-Boot image on the x600 board, lets enable the THUMB mode. This reduces the overall size to less than
0x6000bytes. Fitting it again in the onboard NOR flash.Signed-off-by Stefan Roese <[email protected]>Cc Viresh Kumar <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150912/b250a4a6/attachment.sig>
PATCH 1/4 mtd: nand: fsmc: Add BCH4 SW ECC support for SPEAr600
In reply to Stefan RoeseQuoted 35 lines · Stefan Roese
This patch adds support for 4-bit ECC BCH4 for the SPEAr600 SoC. This can be used by boards equipped with a NAND chip that requires 4-bit ECC strength. The SPEAr600 HW ECC only supports 1-bit ECC strength.
To enable SW BCH4, you need to specify this in your config header:
And use the command "nandecc bch4" to select this ECC scheme upon runtime.
Tested on SPEAr600 x600 board.
Signed-off-by Stefan Roese <[email protected]>Cc Scott Wood <[email protected]>Cc Viresh Kumar <[email protected]>--- drivers/mtd/nand/fsmc_nand.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)drivers/mtd/nand/fsmc_nand.c +3
-0@@ -13,6 +13,7 @@#include <asm/io.h> #include <linux/bitops.h> #include <linux/err.h> +#include <linux/mtd/nand_bch.h> #include <linux/mtd/nand_ecc.h> #include <linux/mtd/fsmc_nand.h> #include <asm/arch/hardware.h> @@ -390,6 +391,45 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,return 0 ; } +#ifndef CONFIG_SPL_BUILD +/*
drivers/mtd/nand/fsmc_nand.c static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, · line 405
Quoted 10 lines
drivers/mtd/nand/fsmc_nand.c +10
-0+* fsmc_nand_switch_ecc - switch the ECC operation between different engines +* +* @eccstrength - the number of bits that could be corrected +* (1 - HW, 4 - SW BCH4) +*/ +int __maybe_unused fsmc_nand_switch_ecc (uint32_t eccstrength) +{ +struct nand_chip *nand; +struct mtd_info *mtd; +int err =0 ;
You don't have to initialize it.
Quoted 20 lines
drivers/mtd/nand/fsmc_nand.c +20
-0+ + mtd = &nand_info[nand_curr_device]; + nand = mtd->priv; + +/* Setup the ecc configurations again */ +if (eccstrength ==1 ) { + nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.bytes =3 ; + nand->ecc.strength =1 ; + nand->ecc.layout = &fsmc_ecc1_layout; + nand->ecc.correct = nand_correct_data; + }else { + nand->ecc.mode =NAND_ECC_SOFT_BCH ; + nand->ecc.calculate = nand_bch_calculate_ecc; + nand->ecc.correct = nand_bch_correct_data; + nand->ecc.bytes =7 ; + nand->ecc.strength =4 ; + nand->ecc.layout =NULL ; + } +
drivers/mtd/nand/fsmc_nand.c static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, · line 435
Quoted 10 lines
drivers/mtd/nand/fsmc_nand.c +7
-0+/* Update NAND handling after ECC mode switch */ + err =nand_scan_tail (mtd); + + return err; +} +#endif /* CONFIG_SPL_BUILD */ +int fsmc_nand_init (struct nand_chip *nand) {static int chip_nr;
Other than that:
Signature · 1 line
viresh