MLK-10471: mtd: nand: use maximum ecc strength controller can support
authorHan Xu <b45815@freescale.com>
Wed, 15 Apr 2015 19:54:46 +0000 (14:54 -0500)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:47:31 +0000 (14:47 -0500)
when the maximum ecc NAND oob can afford exceed the ecc strength
controller can provide, use the maximum ecc strength controller can
support instead of the minimum ecc NAND spec required.

kobs-ng will also use the same ecc strength to align with kernel to make
sure all NAND chips can boot.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 958a2c5b07524f3502cfdefe66724a9a1f8ad608)

drivers/mtd/nand/gpmi-nand/gpmi-nand.c

index 4e2e642..4be7790 100644 (file)
@@ -208,6 +208,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
        geo->ecc_strength = round_up(chip->ecc_strength_ds, 2);
        if (!gpmi_check_ecc(this))
                return -EINVAL;
+       /* set the ecc strength to the maximum ecc controller can support */
+       geo->ecc_strength = this->devdata->bch_max_ecc_strength;
 
        /* Keep the C >= O */
        if (geo->ecc_chunk_size < mtd->oobsize) {
@@ -324,7 +326,7 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
        if (!gpmi_check_ecc(this)) {
                dev_err(this->dev,
                        "ecc strength: %d cannot be supported by the controller (%d)\n"
-                       "try to use minimum ecc strength that NAND chip required\n",
+                       "try to use maximum ecc strength that NAND chip required\n",
                        geo->ecc_strength,
                        this->devdata->bch_max_ecc_strength);
                return -EINVAL;
@@ -408,6 +410,9 @@ int common_nfc_set_geometry(struct gpmi_nand_data *this)
 {
        if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
                                || legacy_set_geometry(this))
+               /* To align with the kobs-ng, use the maximum ecc strength */
+               /* controller can support, rather than the minimum ecc nand */
+               /* spec required. */
                return set_geometry_by_ecc_info(this);
 
        return 0;