mtd: nand: omap: clean up of omap_elm and omap_gpmc driver
Subsystems (2)
v2 cover mtd: nand: omap: clean up of omap_elm and omap_gpmc driver
*changes v1->v2*
[PATCH 2/7] fix for BCH4 and BCH16 ECC scheme
[PATCH 7/7] <new patch>
- white space-clean up
*original v1*
This patch series
- removes un-wanted & redundant code in omap_elm and omap_gpmc drivers
- refactors some private struct in omap_gpmc to make them generic across ecc-schemes
- minor code fixes and clean-ups
This series can be as-it-is applied on u-boot 'v2014.04-rc3'.
*Testing Procedure*
Boot tested on am335x_evm (MLO -> U-boot -> kernel with filesystem flashed from U-boot) using OMAP_ECC_BCH8_CODE_HW and OMAP_ECC_BCH8_CODE_HW_DETECTION_SW ecc-schemes
Pekon Gupta (7):
mtd: nand: omap_elm: remove #include omap_gpmc.h
mtd: nand: omap_elm: use bch_type instead of nibble count to
differentiate between BCH4/BCH8/BCH16
mtd: nand: omap_elm: use macros for register definitions
mtd: nand: omap_gpmc: remove unused members of 'struct nand_bch_priv'
mtd: nand: omap_gpmc: rename struct nand_bch_priv to struct
omap_nand_info
mtd: nand: omap_gpmc: minor cleanup of omap_correct_data_bch
mtd: nand: omap: fix error-codes returned from omap-elm driver
drivers/mtd/nand/omap_elm.c | 28 ++++++------ drivers/mtd/nand/omap_gpmc.c | 101 +++++++++++++++++-------------------------- include/linux/mtd/omap_elm.h | 11 +++-- 3 files changed, 59 insertions(+), 81 deletions(-)
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 1/7 mtd: nand: omap_elm: remove #include omap_gpmc.h
There is no dependency of omap_elm.c on omap_gpmc.h
--- drivers/mtd/nand/omap_elm.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/nand/omap_elm.c +0 -1
@@ -16,7 +16,6 @@#include <common.h> #include <asm/io.h> #include <asm/errno.h> -#include <linux/mtd/omap_gpmc.h> #include <linux/mtd/omap_elm.h> #include <asm/arch/hardware.h>
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 1/7 mtd: nand: omap_elm: remove #include omap_gpmc.h
Quoted 4 lines · pekon gupta
There is no dependency of
omap_elm.conomap_gpmc.hSigned-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/e8672694/attachment.pgp>
PATCH v2 2/7 mtd: nand: omap_elm: use bch_type instead of nibble count to differentiate between BCH4/BCH8/BCH16
In reply to Pekon GuptaELM hardware engine support ECC error detection for multiple ECC strengths like
+------+------------------------+ |Type | ECC syndrome length | +------+------------------------+ |BCH4 | 6.5 bytes = 13 nibbles | |BCH8 | 13 byte = 26 nibbles | |BCH16 | 26 bytes = 52 nibbles | +------+------------------------+
Current implementation of omap_elm driver uses ECC syndrom length (in 'nibbles') to differentiate between BCH4/BCH8/BCH16. This patch replaces it with 'bch_type'
--- drivers/mtd/nand/omap_elm.c | 20 ++++++++------------ drivers/mtd/nand/omap_gpmc.c | 10 ++-------- include/linux/mtd/omap_elm.h | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-)
drivers/mtd/nand/omap_elm.c +8 -12
@@ -24,14 +24,12 @@struct elm *elm_cfg;/** -* elm_load_syndromes - Load BCH syndromes based on nibble selection +* elm_load_syndromes - Load BCH syndromes based on bch_type selection * @syndrome: BCH syndrome -* @nibbles: +* @bch_type: BCH4/BCH8/BCH16 * @poly: Syndrome Polynomial set to use -* -* Load BCH syndromes based on nibble selection */ -static void elm_load_syndromes (u8 *syndrome,u32 nibbles,u8 poly) +static void elm_load_syndromes (u8 *syndrome,enum bch_level bch_type,u8 poly) {u32 *ptr;u32 val;
@@ -47,8 +45,7 @@ static void elm_load_syndromes(u8 *syndrome, u32 nibbles, u8 poly) (syndrome[7 ] <<24 );writel (val, ptr); -/* BCH 8-bit with 26 nibbles (4*8=32) */ -if (nibbles >13 ) { +if (bch_type ==BCH_8_BIT || bch_type ==BCH_16_BIT ) {/* reg 2 */ ptr = &elm_cfg->syndrome_fragments[poly].syndrome_fragment_x[2 ]; val = syndrome[8] | (syndrome[9] << 8) | (syndrome[10] << 16) |
@@ -61,8 +58,7 @@ static void elm_load_syndromes(u8 *syndrome, u32 nibbles, u8 poly)writel (val, ptr); } -/* BCH 16-bit with 52 nibbles (7*8=56) */ -if (nibbles >26 ) { +if (bch_type ==BCH_16_BIT ) {/* reg 4 */ ptr = &elm_cfg->syndrome_fragments[poly].syndrome_fragment_x[4 ]; val = syndrome[16] | (syndrome[17] << 8) |
@@ -86,7 +82,7 @@ static void elm_load_syndromes(u8 *syndrome, u32 nibbles, u8 poly)/** * elm_check_errors - Check for BCH errors and return error locations * @syndrome: BCH syndrome -* @nibbles: +* @bch_type: BCH4/BCH8/BCH16 * @error_count: Returns number of errrors in the syndrome * @error_locations: Returns error locations (in decimal) in this array *
@@ -94,14 +90,14 @@ static void elm_load_syndromes(u8 *syndrome, u32 nibbles, u8 poly)* and locations in the array passed. Returns -1 if error is not correctable, * else returns 0 */ -int elm_check_error (u8 *syndrome,u32 nibbles,u32 *error_count, +int elm_check_error (u8 *syndrome,enum bch_level bch_type,u32 *error_count,u32 *error_locations) {u8 poly =ELM_DEFAULT_POLY ;s8 i;u32 location_status; -elm_load_syndromes (syndrome, nibbles, poly); +elm_load_syndromes (syndrome, bch_type, poly);/* start processing */ writel((readl(&elm_cfg->syndrome_fragments[poly].syndrome_fragment_x[6])
drivers/mtd/nand/omap_gpmc.c +2 -8
@@ -153,7 +153,6 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,struct nand_bch_priv {uint8_t mode;uint8_t type; -uint8_t nibbles;struct bch_control *control;enum omap_ecc ecc_scheme; };
@@ -163,11 +162,6 @@ struct nand_bch_priv {#define ECC_BCH8 1#define ECC_BCH16 2 -/* BCH nibbles for diff bch levels */ -#define ECC_BCH4_NIBBLES 13 -#define ECC_BCH8_NIBBLES 26 -#define ECC_BCH16_NIBBLES 52 -/* * This can be a single instance cause all current users have only one NAND * with nearly the same setup (BCH8, some with ELM and others with sw BCH
@@ -176,7 +170,6 @@ struct nand_bch_priv {*/ static __maybe_unused struct nand_bch_priv bch_priv = { .type =ECC_BCH8 , - .nibbles =ECC_BCH8_NIBBLES , .control =NULL };
@@ -383,7 +376,8 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat, }/* use elm module to check for errors */ elm_config ((enum bch_level )(bch->type)); -if (elm_check_error (calc_ecc, bch->nibbles, &error_count, error_loc)) { +if (elm_check_error (calc_ecc, (enum bch_level )bch->type, + &error_count, error_loc)) {printf ("nand: error: uncorrectable ECC errors\n" );return -EINVAL ; }
include/linux/mtd/omap_elm.h +1 -1
@@ -68,7 +68,7 @@ struct elm {struct location error_location[8 ];/* 0x800 */ }; -int elm_check_error (u8 *syndrome,u32 nibbles,u32 *error_count, +int elm_check_error (u8 *syndrome,enum bch_level bch_type,u32 *error_count,u32 *error_locations);int elm_config (enum bch_level level);void elm_reset (void );
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 2/7 mtd: nand: omap_elm: use bch_type instead of nibble count to differentiate between BCH4/BCH8/BCH16
Quoted 9 lines · pekon gupta
ELM hardware engine support ECC error detection for multiple ECC strengths like
+------+------------------------+ |Type | ECC syndrome length | +------+------------------------+ |BCH4 | 6.5 bytes = 13 nibbles | |BCH8 | 13 byte = 26 nibbles | |BCH16 | 26 bytes = 52 nibbles | +------+------------------------+
Quoted 5 lines
Current implementation of
omap_elmdriver uses ECC syndrom length (in 'nibbles') to differentiate between BCH4/BCH8/BCH16. This patch replaces it with 'bch_type'Signed-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/5bfe8939/attachment.pgp>
PATCH v2 3/7 mtd: nand: omap_elm: use macros for register definitions
In reply to Pekon GuptaThis patch adds macros for following parameters of ELM Hardware engine
- ELM_MAX_CHANNELS: ELM can process 8 data streams simultaneously
- ELM_MAX_ERRORS: ELM can detect upto 16 ECC error when using BCH16 scheme
--- include/linux/mtd/omap_elm.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
include/linux/mtd/omap_elm.h +6 -3
@@ -24,6 +24,9 @@#define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100)#define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F) +#define ELM_MAX_CHANNELS 8 +#define ELM_MAX_ERROR_COUNT 16 +#ifndef __ASSEMBLY__ enum bch_level {
@@ -43,7 +46,7 @@ struct syndrome {struct location {u32 location_status;/* 0x800 */ u8 res1[124 ];/* 0x804 */ -u32 error_location_x[16 ];/* 0x880.... */ +u32 error_location_x[ELM_MAX_ERROR_COUNT ];/* 0x880, 0x980, .. */ u8 res2[64 ];/* 0x8c0 */ };
@@ -63,9 +66,9 @@ struct elm {u8 res2[92 ];/* 0x024 */ u32 page_ctrl;/* 0x080 */ u8 res3[892 ];/* 0x084 */ -struct syndrome syndrome_fragments[8 ];/* 0x400 */ +struct syndrome syndrome_fragments[ELM_MAX_CHANNELS ];/* 0x400,0x420 */ u8 res4[512 ];/* 0x600 */ -struct location error_location[8 ];/* 0x800 */ +struct location error_location[ELM_MAX_CHANNELS ];/* 0x800,0x900 ... */ }; int elm_check_error(u8 *syndrome, enum bch_level bch_type, u32 *error_count,
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 3/7 mtd: nand: omap_elm: use macros for register definitions
Quoted 6 lines · pekon gupta
This patch adds macros for following parameters of ELM Hardware engine
-ELM_MAX_CHANNELS: ELM can process 8 data streams simultaneously
-ELM_MAX_ERRORS: ELM can detect upto 16 ECC error when using BCH16 schemeSigned-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/0b182290/attachment.pgp>
PATCH v2 4/7 mtd: nand: omap_gpmc: remove unused members of 'struct nand_bch_priv'
In reply to Pekon GuptaThis patch prepares to refactor 'struct nand_bch_priv' -> 'struct omap_nand_info' And thus performs following clean-ups:
- remove nand_bch_priv.type: use nand_bch_priv.ecc_scheme instead
- remove nand_bch_priv.mode: <unused>
--- drivers/mtd/nand/omap_gpmc.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
drivers/mtd/nand/omap_gpmc.c +6 -17
@@ -151,17 +151,10 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,* Generic BCH interface */ struct nand_bch_priv { -uint8_t mode; -uint8_t type;struct bch_control *control;enum omap_ecc ecc_scheme; }; -/* bch types */ -#define ECC_BCH4 0 -#define ECC_BCH8 1 -#define ECC_BCH16 2 -/* * This can be a single instance cause all current users have only one NAND * with nearly the same setup (BCH8, some with ELM and others with sw BCH
@@ -169,7 +162,6 @@ struct nand_bch_priv {* When some users with other BCH strength will exists this have to change! */ static __maybe_unused struct nand_bch_priv bch_priv = { - .type =ECC_BCH8 , .control =NULL };
@@ -342,6 +334,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,uint32_t eccbytes = chip->ecc.bytes;uint32_t error_count =0 , error_max;uint32_t error_loc[8 ]; +enum bch_level bch_type;uint32_t i, ecc_flag =0 ;uint8_t count, err =0 ;uint32_t byte_pos, bit_pos;
@@ -369,22 +362,22 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,*/ switch (bch->ecc_scheme) {case OMAP_ECC_BCH8_CODE_HW : + bch_type =BCH_8_BIT ;omap_reverse_list (calc_ecc, eccbytes -1 );break ;default :return -EINVAL ; }/* use elm module to check for errors */ -elm_config ((enum bch_level )(bch->type)); -if (elm_check_error (calc_ecc, (enum bch_level )bch->type, - &error_count, error_loc)) { +elm_config (bch_type); +if (elm_check_error (calc_ecc, bch_type, &error_count, error_loc)) {printf ("nand: error: uncorrectable ECC errors\n" );return -EINVAL ; }/* correct bch error */ for (count =0 ; count < error_count; count++) { -switch (bch->type) { -case ECC_BCH8 : +switch (bch->ecc_scheme) { +case OMAP_ECC_BCH8_CODE_HW :/* 14th byte in ECC is reserved to match ROM layout */ error_max =SECTOR_BYTES + (eccbytes -1 );break ;
@@ -562,7 +555,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,/* For this ecc-scheme, ecc.bytes, ecc.layout, ... are * initialized in nand_scan_tail(), so just set ecc.mode */ bch_priv.control =NULL ; - bch_priv.type =0 ; nand->ecc.mode =NAND_ECC_SOFT ; nand->ecc.layout =NULL ; nand->ecc.size =0 ;
@@ -578,7 +570,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,return -EINVAL ; } bch_priv.control =NULL ; - bch_priv.type =0 ;/* populate ecc specific fields */ memset (&nand->ecc,0 ,sizeof (struct nand_ecc_ctrl )); nand->ecc.mode =NAND_ECC_HW ;
@@ -617,7 +608,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,printf ("nand: error: could not init_bch()\n" );return -ENODEV ; } - bch_priv.type =ECC_BCH8 ;/* populate ecc specific fields */ memset (&nand->ecc,0 ,sizeof (struct nand_ecc_ctrl )); nand->ecc.mode =NAND_ECC_HW ;
@@ -659,7 +649,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, }/* intialize ELM for ECC error detection */ elm_init (); - bch_priv.type =ECC_BCH8 ;/* populate ecc specific fields */ memset (&nand->ecc,0 ,sizeof (struct nand_ecc_ctrl )); nand->ecc.mode =NAND_ECC_HW ;
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 4/7 mtd: nand: omap_gpmc: remove unused members of 'struct nand_bch_priv'
Quoted 6 lines · Pekon Gupta
This patch prepares to refactor 'struct
nand_bch_priv' -> 'structomap_nand_info' And thus performs following clean-ups:
- remove nand_bch_priv.type: use nand_bch_priv.ecc_scheme instead
- remove nand_bch_priv.mode: <unused>Signed-off-by Pekon Gupta <[email protected]>
Thanks,
Stefan
PATCH v2 4/7 mtd: nand: omap_gpmc: remove unused members of 'struct nand_bch_priv'
In reply to Pekon GuptaQuoted 6 lines · Pekon Gupta
This patch prepares to refactor 'struct
nand_bch_priv' -> 'structomap_nand_info' And thus performs following clean-ups:
- remove nand_bch_priv.type: use nand_bch_priv.ecc_scheme instead
- remove nand_bch_priv.mode: <unused>Signed-off-by Pekon Gupta <[email protected]>
Thanks,
Stefan
PATCH v2 4/7 mtd: nand: omap_gpmc: remove unused members of 'struct nand_bch_priv'
In reply to Pekon GuptaQuoted 9 lines · pekon gupta
This patch prepares to refactor 'struct
nand_bch_priv' -> 'structomap_nand_info' And thus performs following clean-ups:
- remove nand_bch_priv.type: use nand_bch_priv.ecc_scheme instead
- remove nand_bch_priv.mode: <unused>Signed-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/f5a78877/attachment.pgp>
PATCH v2 5/7 mtd: nand: omap_gpmc: rename struct nand_bch_priv to struct omap_nand_info
In reply to Pekon GuptaThis patch renames 'struct nand_bch_priv' which currently holds private data only for BCH ECC schemes, into 'struct omap_nand_info' so that same can be used for all ECC schemes
--- drivers/mtd/nand/omap_gpmc.c | 58 ++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 32 deletions(-)
drivers/mtd/nand/omap_gpmc.c +26 -32
@@ -148,9 +148,9 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat, }/* -* Generic BCH interface +* Driver configurations */ -struct nand_bch_priv { +struct omap_nand_info {struct bch_control *control;enum omap_ecc ecc_scheme; };
@@ -161,7 +161,7 @@ struct nand_bch_priv {* library). * When some users with other BCH strength will exists this have to change! */ -static __maybe_unused struct nand_bch_priv bch_priv = { +static __maybe_unused struct omap_nand_info omap_nand_info = { .control =NULL };
@@ -191,7 +191,7 @@ __maybe_unusedstatic void omap_enable_hwecc (struct mtd_info *mtd,int32_t mode) {struct nand_chip *nand = mtd->priv; -struct nand_bch_priv *bch = nand->priv; +struct omap_nand_info *info = nand->priv;unsigned int dev_width = (nand->options &NAND_BUSWIDTH_16 ) ?1 :0 ;unsigned int ecc_algo =0 ;unsigned int bch_type =0 ;
@@ -200,7 +200,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)u32 ecc_config_val =0 ;/* configure GPMC for specific ecc-scheme */ -switch (bch->ecc_scheme) { +switch (info->ecc_scheme) {case OMAP_ECC_HAM1_CODE_SW :return ;case OMAP_ECC_HAM1_CODE_HW :
@@ -262,11 +262,11 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat, uint8_t *ecc_code) {struct nand_chip *chip = mtd->priv; -struct nand_bch_priv *bch = chip->priv; +struct omap_nand_info *info = chip->priv;uint32_t *ptr, val =0 ;int8_t i =0 , j; -switch (bch->ecc_scheme) { +switch (info->ecc_scheme) {case OMAP_ECC_HAM1_CODE_HW : val =readl (&gpmc_cfg->ecc1_result); ecc_code[0 ] = val &0xFF ;
@@ -294,7 +294,7 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,return -EINVAL ; }/* ECC scheme specific syndrome customizations */ -switch (bch->ecc_scheme) { +switch (info->ecc_scheme) {case OMAP_ECC_HAM1_CODE_HW :break ;#ifdef CONFIG_BCH
@@ -330,7 +330,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc) { struct nand_chip *chip = mtd->priv; -struct nand_bch_priv *bch = chip->priv; +struct omap_nand_info *info = chip->priv;uint32_t eccbytes = chip->ecc.bytes;uint32_t error_count =0 , error_max;uint32_t error_loc[8 ];
@@ -360,7 +360,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,* while reading ECC result we read it in big endian. * Hence while loading to ELM we have rotate to get the right endian. */ -switch (bch->ecc_scheme) { +switch (info->ecc_scheme) {case OMAP_ECC_BCH8_CODE_HW : bch_type =BCH_8_BIT ;omap_reverse_list (calc_ecc, eccbytes -1 );
@@ -376,7 +376,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat, }/* correct bch error */ for (count =0 ; count < error_count; count++) { -switch (bch->ecc_scheme) { +switch (info->ecc_scheme) {case OMAP_ECC_BCH8_CODE_HW :/* 14th byte in ECC is reserved to match ROM layout */ error_max =SECTOR_BYTES + (eccbytes -1 );
@@ -483,10 +483,10 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,/* cannot correct more than 8 errors */ unsigned int errloc[8 ];struct nand_chip *chip = mtd->priv; -struct nand_bch_priv *chip_priv = chip->priv; -struct bch_control *bch = chip_priv->control; +struct omap_nand_info *info = chip->priv; - count =decode_bch (bch,NULL ,512 , read_ecc, calc_ecc,NULL , errloc); + count =decode_bch (info->control,NULL ,512 , read_ecc, calc_ecc, +NULL , errloc);if (count >0 ) {/* correct errors */ for (i =0 ; i < count; i++) {
@@ -522,15 +522,11 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,static void __maybe_unused omap_free_bch (struct mtd_info *mtd) {struct nand_chip *chip = mtd->priv; -struct nand_bch_priv *chip_priv = chip->priv; -struct bch_control *bch =NULL ; +struct omap_nand_info *info = chip->priv; -if (chip_priv) - bch = chip_priv->control; - -if (bch) { -free_bch (bch); - chip_priv->control =NULL ; +if (info->control) { +free_bch (info->control); + info->control =NULL ; } }#endif /* CONFIG_BCH */
@@ -544,7 +540,7 @@ static void __maybe_unused omap_free_bch(struct mtd_info *mtd)*/ static int omap_select_ecc_scheme (struct nand_chip *nand,enum omap_ecc ecc_scheme,unsigned int pagesize,unsigned int oobsize) { -struct nand_bch_priv *bch = nand->priv; +struct omap_nand_info *info = nand->priv;struct nand_ecclayout *ecclayout = &omap_ecclayout;int eccsteps = pagesize /SECTOR_BYTES ;int i;
@@ -554,11 +550,10 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,debug ("nand: selected OMAP_ECC_HAM1_CODE_SW\n" );/* For this ecc-scheme, ecc.bytes, ecc.layout, ... are * initialized in nand_scan_tail(), so just set ecc.mode */ - bch_priv.control =NULL ; + info->control =NULL ; nand->ecc.mode =NAND_ECC_SOFT ; nand->ecc.layout =NULL ; nand->ecc.size =0 ; - bch->ecc_scheme =OMAP_ECC_HAM1_CODE_SW ;break ;case OMAP_ECC_HAM1_CODE_HW :
@@ -569,7 +564,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, (3 * eccsteps) + BADBLOCK_MARKER_LENGTH));return -EINVAL ; } - bch_priv.control =NULL ; + info->control =NULL ;/* populate ecc specific fields */ memset (&nand->ecc,0 ,sizeof (struct nand_ecc_ctrl )); nand->ecc.mode =NAND_ECC_HW ;
@@ -590,7 +585,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, ecclayout->oobfree[0 ].offset = i +BADBLOCK_MARKER_LENGTH ; ecclayout->oobfree[0 ].length = oobsize - ecclayout->eccbytes -BADBLOCK_MARKER_LENGTH ; - bch->ecc_scheme =OMAP_ECC_HAM1_CODE_HW ;break ;case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW :
@@ -603,8 +597,8 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,return -EINVAL ; }/* check if BCH S/W library can be used for error detection */ - bch_priv.control =init_bch (13 ,8 ,0x201b ); -if (!bch_priv.control) { + info->control =init_bch (13 ,8 ,0x201b ); +if (!info->control) {printf ("nand: error: could not init_bch()\n" );return -ENODEV ; }
@@ -631,7 +625,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, ecclayout->oobfree[0 ].offset = i +BADBLOCK_MARKER_LENGTH ; ecclayout->oobfree[0 ].length = oobsize - ecclayout->eccbytes -BADBLOCK_MARKER_LENGTH ; - bch->ecc_scheme =OMAP_ECC_BCH8_CODE_HW_DETECTION_SW ;break ;#else printf ("nand: error: CONFIG_BCH required for ECC\n" );
@@ -649,6 +642,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, }/* intialize ELM for ECC error detection */ elm_init (); + info->control =NULL ;/* populate ecc specific fields */ memset (&nand->ecc,0 ,sizeof (struct nand_ecc_ctrl )); nand->ecc.mode =NAND_ECC_HW ;
@@ -666,7 +660,6 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, ecclayout->oobfree[0 ].offset = i +BADBLOCK_MARKER_LENGTH ; ecclayout->oobfree[0 ].length = oobsize - ecclayout->eccbytes -BADBLOCK_MARKER_LENGTH ; - bch->ecc_scheme =OMAP_ECC_BCH8_CODE_HW ;break ;#else printf ("nand: error: CONFIG_NAND_OMAP_ELM required for ECC\n" );
@@ -682,6 +675,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,if (ecc_scheme !=OMAP_ECC_HAM1_CODE_SW ) nand->ecc.layout = ecclayout; + info->ecc_scheme = ecc_scheme;return 0 ; }
@@ -785,7 +779,7 @@ int board_nand_init(struct nand_chip *nand) nand->IO_ADDR_R = (void __iomem *)&gpmc_cfg->cs[cs].nand_dat; nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd; - nand->priv = &bch_priv; + nand->priv = &omap_nand_info; 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 */
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 5/7 mtd: nand: omap_gpmc: rename struct nand_bch_priv to struct omap_nand_info
Quoted 6 lines · pekon gupta
This patch renames 'struct
nand_bch_priv' which currently holds private data only for BCH ECC schemes, into 'structomap_nand_info' so that same can be used for all ECC schemesSigned-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/3e26f51c/attachment.pgp>
PATCH v2 6/7 mtd: nand: omap_gpmc: minor cleanup of omap_correct_data_bch
In reply to Pekon GuptaThis patch tries to avoid some local pointer dereferences, by using common local variables in omap_correct_data_bch()
--- drivers/mtd/nand/omap_gpmc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/nand/omap_gpmc.c +5 -5
@@ -331,7 +331,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat, {struct nand_chip *chip = mtd->priv;struct omap_nand_info *info = chip->priv; -uint32_t eccbytes = chip->ecc.bytes; +struct nand_ecc_ctrl *ecc = &chip->ecc;uint32_t error_count =0 , error_max;uint32_t error_loc[8 ];enum bch_level bch_type;
@@ -340,7 +340,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,uint32_t byte_pos, bit_pos;/* check calculated ecc */ -for (i =0 ; i < chip->ecc.bytes && !ecc_flag; i++) { +for (i =0 ; i < ecc->bytes && !ecc_flag; i++) {if (calc_ecc[i] !=0x00 ) ecc_flag =1 ; }
@@ -349,7 +349,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,/* check for whether its a erased-page */ ecc_flag =0 ; -for (i =0 ; i < chip->ecc.bytes && !ecc_flag; i++) { +for (i =0 ; i < ecc->bytes && !ecc_flag; i++) {if (read_ecc[i] !=0xff ) ecc_flag =1 ; }
@@ -363,7 +363,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,switch (info->ecc_scheme) {case OMAP_ECC_BCH8_CODE_HW : bch_type =BCH_8_BIT ; -omap_reverse_list (calc_ecc, eccbytes -1 ); +omap_reverse_list (calc_ecc, ecc->bytes -1 );break ;default :return -EINVAL ;
@@ -379,7 +379,7 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,switch (info->ecc_scheme) {case OMAP_ECC_BCH8_CODE_HW :/* 14th byte in ECC is reserved to match ROM layout */ - error_max =SECTOR_BYTES + (eccbytes -1 ); + error_max =SECTOR_BYTES + (ecc->bytes -1 );break ;default :return -EINVAL ;
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 6/7 mtd: nand: omap_gpmc: minor cleanup of omap_correct_data_bch
Quoted 4 lines · Pekon Gupta
This patch tries to avoid some local pointer dereferences, by using common local variables in
omap_correct_data_bch()Signed-off-by Pekon Gupta <[email protected]>
Thanks,
Stefan
PATCH v2 6/7 mtd: nand: omap_gpmc: minor cleanup of omap_correct_data_bch
In reply to Pekon GuptaQuoted 4 lines · Pekon Gupta
This patch tries to avoid some local pointer dereferences, by using common local variables in
omap_correct_data_bch()Signed-off-by Pekon Gupta <[email protected]>
Thanks,
Stefan
PATCH v2 6/7 mtd: nand: omap_gpmc: minor cleanup of omap_correct_data_bch
In reply to Pekon GuptaQuoted 6 lines · pekon gupta
This patch tries to avoid some local pointer dereferences, by using common local variables in
omap_correct_data_bch()Signed-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/433e9851/attachment.pgp>
PATCH v2 7/7 mtd: nand: omap: fix error-codes returned from omap-elm driver
In reply to Pekon GuptaThis patch
omap-elm.c: replaces -ve integer value returned during errorneous condition,
with proper error-codes.
omap-gpmc.c: updates omap-gpmc driver to pass error-codes returned from
omap-elm driver to upper layers
--- drivers/mtd/nand/omap_elm.c | 7 +++++-- drivers/mtd/nand/omap_gpmc.c | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/mtd/nand/omap_elm.c +5 -2
@@ -19,6 +19,7 @@#include <linux/mtd/omap_elm.h> #include <asm/arch/hardware.h> +#define DRIVER_NAME "omap-elm"#define ELM_DEFAULT_POLY (0)struct elm *elm_cfg;
@@ -113,8 +114,10 @@ int elm_check_error(u8 *syndrome, enum bch_level bch_type, u32 *error_count,/* check if correctable */ location_status =readl (&elm_cfg->error_location[poly].location_status); -if (!(location_status &ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK )) -return -1 ; +if (!(location_status &ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK )) { +printf ("%s: uncorrectable ECC errors\n" ,DRIVER_NAME ); +return -EBADMSG ; + }/* get error count */ *error_count = readl(&elm_cfg->error_location[poly].location_status) &
drivers/mtd/nand/omap_gpmc.c +4 -4
@@ -370,10 +370,10 @@ static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat, }/* use elm module to check for errors */ elm_config (bch_type); -if (elm_check_error (calc_ecc, bch_type, &error_count, error_loc)) { -printf ("nand: error: uncorrectable ECC errors\n" ); -return -EINVAL ; - } + err =elm_check_error (calc_ecc, bch_type, &error_count, error_loc); +if (err) +return err; +/* correct bch error */ for (count =0 ; count < error_count; count++) {switch (info->ecc_scheme) {
Signature · 1 line
1.8.5.1.163.gd7aced9
PATCH v2 7/7 mtd: nand: omap: fix error-codes returned from omap-elm driver
Quoted 7 lines · Pekon Gupta
This patch
omap-elm.c: replaces -ve integer value returned during errorneous condition,
with proper error-codes.
omap-gpmc.c: updates omap-gpmc driver to pass error-codes returned from
omap-elm driver to upper layersSigned-off-by Pekon Gupta <[email protected]>
Thanks,
Stefan
PATCH v2 7/7 mtd: nand: omap: fix error-codes returned from omap-elm driver
In reply to Pekon GuptaQuoted 7 lines · Pekon Gupta
This patch
omap-elm.c: replaces -ve integer value returned during errorneous condition,
with proper error-codes.
omap-gpmc.c: updates omap-gpmc driver to pass error-codes returned from
omap-elm driver to upper layersSigned-off-by Pekon Gupta <[email protected]>
Thanks,
Stefan
PATCH v2 7/7 mtd: nand: omap: fix error-codes returned from omap-elm driver
In reply to Pekon GuptaQuoted 9 lines · pekon gupta
This patch
omap-elm.c: replaces -ve integer value returned during errorneous condition,
with proper error-codes.
omap-gpmc.c: updates omap-gpmc driver to pass error-codes returned from
omap-elm driver to upper layersSigned-off-by Pekon Gupta <[email protected]>Reviewed-by Stefan Roese <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140606/92a8e35c/attachment.pgp>
Gupta
v2 cover mtd: nand: omap: clean up of omap_elm and omap_gpmc driver
In reply to Pekon GuptaQuoted 15 lines
From: Gupta, Pekon
*changes v1->v2*
[PATCH 2/7] fix for BCH4 and BCH16 ECC scheme
[PATCH 7/7] <new patch>
- white space-clean up*original v1*
This patch series
- removes un-wanted & redundant code inomap_elmandomap_gpmcdrivers
- refactors some private struct inomap_gpmcto make them generic across ecc-schemes
- minor code fixes and clean-ups
This series can be as-it-is applied on u-boot 'v2014.04-rc3'.
Quoted 4 lines
*Testing Procedure*
Boot tested onam335x_evm(MLO -> U-boot -> kernel with filesystem flashed from U-boot) usingOMAP_ECC_BCH8_CODE_HWandOMAP_ECC_BCH8_CODE_HW_DETECTION_SWecc-schemes
Ping ..
Please review and accept this. These are simple driver clean-ups.
with regards, pekon