Commit ba4f46b2 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Boris Brezillon

mtd: nand: add support for "nand-ecc-algo" DT property

So far it was only possible to specify ECC algorithm using "soft" and
"soft_bch" values of nand-ecc-mode prop. There wasn't a way to specify
it for a hardware ECC mode.

Now that we have independent field in NAND subsystem for storing info
about ECC algorithm we may also add support for this new DT property.
Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent e4225ae8
...@@ -22,6 +22,8 @@ Optional NAND chip properties: ...@@ -22,6 +22,8 @@ Optional NAND chip properties:
- nand-ecc-mode : String, operation mode of the NAND ecc mode. - nand-ecc-mode : String, operation mode of the NAND ecc mode.
Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
"soft_bch". "soft_bch".
- nand-ecc-algo: string, algorithm of NAND ECC.
Supported values are: "hamming", "bch".
- nand-bus-width : 8 or 16 bus width if not present 8 - nand-bus-width : 8 or 16 bus width if not present 8
- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false - nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
......
...@@ -4003,17 +4003,23 @@ static int of_get_nand_ecc_mode(struct device_node *np) ...@@ -4003,17 +4003,23 @@ static int of_get_nand_ecc_mode(struct device_node *np)
return -ENODEV; return -ENODEV;
} }
static const char * const nand_ecc_algos[] = {
[NAND_ECC_HAMMING] = "hamming",
[NAND_ECC_BCH] = "bch",
};
static int of_get_nand_ecc_algo(struct device_node *np) static int of_get_nand_ecc_algo(struct device_node *np)
{ {
const char *pm; const char *pm;
int err; int err, i;
/* err = of_property_read_string(np, "nand-ecc-algo", &pm);
* TODO: Read ECC algo OF property and map it to enum nand_ecc_algo. if (!err) {
* It's not implemented yet as currently NAND subsystem ignores for (i = NAND_ECC_HAMMING; i < ARRAY_SIZE(nand_ecc_algos); i++)
* algorithm explicitly set this way. Once it's handled we should if (!strcasecmp(pm, nand_ecc_algos[i]))
* document & support new property. return i;
*/ return -ENODEV;
}
/* /*
* For backward compatibility we also read "nand-ecc-mode" checking * For backward compatibility we also read "nand-ecc-mode" checking
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment