Re: [PATCH v6 3/4] mtd:nand:omap2: updated support for BCH4 ECC scheme
On Thu, Sep 12, 2013 at 05:20:18PM +0530, Pekon Gupta wrote: This patch adds following two flavours of BCH4 ECC scheme in omap2-nand driver - OMAP_ECC_BCH4_CODE_HW_DETECTION_SW - uses GPMC H/W engine for calculating ECC. - uses software library (lib/bch.h nand_bch.h) for error correction. - OMAP_ECC_BCH4_CODE_HW - uses GPMC H/W engine for calculating ECC. - uses ELM H/W engine for error correction. With this patch omap2-nand driver supports following ECC schemes: +---+---+---+ | ECC scheme|ECC calculation|Error detection| +---+---+---+ |OMAP_ECC_HAMMING_CODE_DEFAULT |S/W|S/W| |OMAP_ECC_HAMMING_CODE_HW |H/W (GPMC) |S/W| |OMAP_ECC_HAMMING_CODE_HW_ROMCODE |H/W (GPMC) |S/W| +---+---+---+ |OMAP_ECC_BCH4_CODE_HW_DETECTION_SW |H/W (GPMC) |S/W (lib/bch.h)| |OMAP_ECC_BCH4_CODE_HW |H/W (GPMC) |H/W (ELM) | +---+---+---+ |OMAP_ECC_BCH8_CODE_HW_DETECTION_SW |H/W (GPMC) |S/W (lib/bch.h)| |OMAP_ECC_BCH8_CODE_HW |H/W (GPMC) |H/W (ELM) | +---+---+---+ Important: - Selection of OMAP_ECC_BCHx_CODE_HW_DETECTION_SW requires, Kconfig: CONFIG_MTD_NAND_ECC_BCH: enables S/W based BCH ECC algorithm. - Selection of OMAP_ECC_BCHx_CODE_HW requires, Kconfig: CONFIG_MTD_NAND_OMAP_BCH: enables ELM H/W module. Signed-off-by: Pekon Gupta pe...@ti.com --- drivers/mtd/nand/Kconfig | 30 ++- drivers/mtd/nand/omap2.c | 136 ++- 2 files changed, 68 insertions(+), 98 deletions(-) diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index d885298..5836039 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -96,35 +96,13 @@ config MTD_NAND_OMAP2 config MTD_NAND_OMAP_BCH depends on MTD_NAND MTD_NAND_OMAP2 ARCH_OMAP3 - tristate Enable support for hardware BCH error correction + tristate Support hardware based BCH error correction default n select BCH - select BCH_CONST_PARAMS help - Support for hardware BCH error correction. - -choice - prompt BCH error correction capability - depends on MTD_NAND_OMAP_BCH - -config MTD_NAND_OMAP_BCH8 - bool 8 bits / 512 bytes (recommended) - help - Support correcting up to 8 bitflips per 512-byte block. - This will use 13 bytes of spare area per 512 bytes of page data. - This is the recommended mode, as 4-bit mode does not work - on some OMAP3 revisions, due to a hardware bug. - -config MTD_NAND_OMAP_BCH4 - bool 4 bits / 512 bytes - help - Support correcting up to 4 bitflips per 512-byte block. - This will use 7 bytes of spare area per 512 bytes of page data. - Note that this mode does not work on some OMAP3 revisions, due to a - hardware bug. Please check your OMAP datasheet before selecting this - mode. - -endchoice + Some devices have built-in ELM hardware engine, which can be used to + locate and correct errors when using BCH ECC scheme. This enables the + driver support for same. if MTD_NAND_OMAP_BCH config BCH_CONST_M diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 420078f..6f4596c 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -27,6 +27,7 @@ #ifdef CONFIG_MTD_NAND_ECC_BCH #include linux/bch.h +#include linux/mtd/nand_bch.h #endif #ifdef CONFIG_MTD_NAND_OMAP_BCH #include linux/platform_data/elm.h @@ -144,7 +145,6 @@ #define BCH_ECC_SIZE10x20/* ecc_size1 = 32 */ #define BADBLOCK_MARKER_LENGTH 0x2 -#define OMAP_ECC_BCH8_POLYNOMIAL 0x201b #ifdef CONFIG_MTD_NAND_OMAP_BCH static u_char bch8_vector[] = {0xf3, 0xdb, 0x14, 0x16, 0x8b, 0xd2, 0xbe, 0xcc, @@ -185,10 +185,9 @@ struct omap_nand_info { OMAP_NAND_IO_WRITE, /* write */ } iomode; u_char *buf; - int buf_len; + int buf_len; Please do not make unrelated, arbitrary changes to whitespace as part of a patch that solves other problems. struct gpmc_nand_regs reg; /* fields specific for BCHx_HW ECC scheme */ - struct bch_control *bch; boolis_elm_used; struct device *elm_dev; struct device_node *of_node; ... @@ -1725,16 +1672,17 @@ static int omap_nand_probe(struct platform_device
[PATCH v6 3/4] mtd:nand:omap2: updated support for BCH4 ECC scheme
This patch adds following two flavours of BCH4 ECC scheme in omap2-nand driver - OMAP_ECC_BCH4_CODE_HW_DETECTION_SW - uses GPMC H/W engine for calculating ECC. - uses software library (lib/bch.h nand_bch.h) for error correction. - OMAP_ECC_BCH4_CODE_HW - uses GPMC H/W engine for calculating ECC. - uses ELM H/W engine for error correction. With this patch omap2-nand driver supports following ECC schemes: +---+---+---+ | ECC scheme|ECC calculation|Error detection| +---+---+---+ |OMAP_ECC_HAMMING_CODE_DEFAULT |S/W|S/W| |OMAP_ECC_HAMMING_CODE_HW |H/W (GPMC) |S/W| |OMAP_ECC_HAMMING_CODE_HW_ROMCODE |H/W (GPMC) |S/W| +---+---+---+ |OMAP_ECC_BCH4_CODE_HW_DETECTION_SW |H/W (GPMC) |S/W (lib/bch.h)| |OMAP_ECC_BCH4_CODE_HW |H/W (GPMC) |H/W (ELM) | +---+---+---+ |OMAP_ECC_BCH8_CODE_HW_DETECTION_SW |H/W (GPMC) |S/W (lib/bch.h)| |OMAP_ECC_BCH8_CODE_HW |H/W (GPMC) |H/W (ELM) | +---+---+---+ Important: - Selection of OMAP_ECC_BCHx_CODE_HW_DETECTION_SW requires, Kconfig: CONFIG_MTD_NAND_ECC_BCH: enables S/W based BCH ECC algorithm. - Selection of OMAP_ECC_BCHx_CODE_HW requires, Kconfig: CONFIG_MTD_NAND_OMAP_BCH: enables ELM H/W module. Signed-off-by: Pekon Gupta pe...@ti.com --- drivers/mtd/nand/Kconfig | 30 ++- drivers/mtd/nand/omap2.c | 136 ++- 2 files changed, 68 insertions(+), 98 deletions(-) diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index d885298..5836039 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -96,35 +96,13 @@ config MTD_NAND_OMAP2 config MTD_NAND_OMAP_BCH depends on MTD_NAND MTD_NAND_OMAP2 ARCH_OMAP3 - tristate Enable support for hardware BCH error correction + tristate Support hardware based BCH error correction default n select BCH - select BCH_CONST_PARAMS help -Support for hardware BCH error correction. - -choice - prompt BCH error correction capability - depends on MTD_NAND_OMAP_BCH - -config MTD_NAND_OMAP_BCH8 - bool 8 bits / 512 bytes (recommended) - help -Support correcting up to 8 bitflips per 512-byte block. -This will use 13 bytes of spare area per 512 bytes of page data. -This is the recommended mode, as 4-bit mode does not work -on some OMAP3 revisions, due to a hardware bug. - -config MTD_NAND_OMAP_BCH4 - bool 4 bits / 512 bytes - help -Support correcting up to 4 bitflips per 512-byte block. -This will use 7 bytes of spare area per 512 bytes of page data. -Note that this mode does not work on some OMAP3 revisions, due to a -hardware bug. Please check your OMAP datasheet before selecting this -mode. - -endchoice + Some devices have built-in ELM hardware engine, which can be used to + locate and correct errors when using BCH ECC scheme. This enables the + driver support for same. if MTD_NAND_OMAP_BCH config BCH_CONST_M diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 420078f..6f4596c 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -27,6 +27,7 @@ #ifdef CONFIG_MTD_NAND_ECC_BCH #include linux/bch.h +#include linux/mtd/nand_bch.h #endif #ifdef CONFIG_MTD_NAND_OMAP_BCH #include linux/platform_data/elm.h @@ -144,7 +145,6 @@ #define BCH_ECC_SIZE1 0x20/* ecc_size1 = 32 */ #define BADBLOCK_MARKER_LENGTH 0x2 -#define OMAP_ECC_BCH8_POLYNOMIAL 0x201b #ifdef CONFIG_MTD_NAND_OMAP_BCH static u_char bch8_vector[] = {0xf3, 0xdb, 0x14, 0x16, 0x8b, 0xd2, 0xbe, 0xcc, @@ -185,10 +185,9 @@ struct omap_nand_info { OMAP_NAND_IO_WRITE, /* write */ } iomode; u_char *buf; - int buf_len; + int buf_len; struct gpmc_nand_regs reg; /* fields specific for BCHx_HW ECC scheme */ - struct bch_control *bch; boolis_elm_used; struct device *elm_dev; struct device_node *of_node; @@ -1227,58 +1226,6 @@ static int omap3_calculate_ecc_bch8(struct mtd_info *mtd, const u_char *dat, return 0; } -/** - * omap3_correct_data_bch - Decode received data and correct errors - * @mtd: MTD device structure - * @data: page data - * @read_ecc: ecc read from nand flash - *