]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mtd: nand: omap_elm: use bch_type instead of nibble count to differentiate between...
authorpekon gupta <pekon@ti.com>
Fri, 11 Apr 2014 07:25:30 +0000 (12:55 +0530)
committerTom Rini <trini@ti.com>
Fri, 6 Jun 2014 21:45:48 +0000 (17:45 -0400)
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  |
 +------+------------------------+

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'

Signed-off-by: Pekon Gupta <pekon@ti.com>
Reviewed-by: Stefan Roese <sr@denx.de>
drivers/mtd/nand/omap_elm.c
drivers/mtd/nand/omap_gpmc.c
include/linux/mtd/omap_elm.h

index 4c65f3b6f5f6a0f7f56c0367c1bc915f44089088..afa629a8135475f01991a28787d4613b85682c2a 100644 (file)
 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])
index bf99b8e6759c1b0c6ad2c126fc75c322c9364322..e84bc7b060c1d5cdc15ea94e89af26a3103614f7 100644 (file)
@@ -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;
        }
index 45454eaf0f18ffd15566c2969cf64df94da26c1c..a6e9591d3798f2ed7b3b1d203ec015fccbd6c7da 100644 (file)
@@ -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);