@@ -1373,7 +1373,7 @@ static int denali_set_max_ecc_strength(struct denali_nand_info *denali)
int oobsize = mtd->oobsize;
int ecc_size = chip->ecc.size;
int ecc_steps = mtd->writesize / chip->ecc.size;
- const int *ecc_strength = denali_default_ecc_strength;
+ const int *ecc_strength = denali->ecc_strength_avail;
int ecc_bytes;
/* carve out the BBM area */
@@ -1625,6 +1625,9 @@ int denali_init(struct denali_nand_info *denali)
chip->ecc.size = denali->caps & DENALI_CAPS_ECC_SIZE_1024 ?
1024 : 512;
+ if (!denali->ecc_strength_avail)
+ denali->ecc_strength_avail = denali_default_ecc_strength;
+
ret = denali_set_max_ecc_strength(denali);
if (ret)
goto failed_req_irq;
@@ -428,6 +428,7 @@ struct denali_nand_info {
u32 devnum; /* represent how many nands connected */
u32 bbtskipbytes;
u32 max_banks;
+ const int *ecc_strength_avail;
unsigned int caps;
#define DENALI_CAPS_HW_ECC_FIXUP BIT(0)
#define DENALI_CAPS_DMA_64BIT BIT(1)
@@ -30,6 +30,7 @@ struct denali_dt {
};
struct denali_dt_data {
+ const int *ecc_strength_avail;
unsigned int caps;
};
@@ -54,8 +55,10 @@ static int denali_dt_probe(struct platform_device *pdev)
denali = &dt->denali;
data = of_device_get_match_data(&pdev->dev);
- if (data)
+ if (data) {
+ denali->ecc_strength_avail = data->ecc_strength_avail;
denali->caps = data->caps;
+ }
denali->caps |= DENALI_CAPS_HW_ECC_FIXUP;
The ecc.strength of this IP is a platform-dependent parameter. I chose {15, 8} as the default to respect the historical reason of this driver, but it should be overridable to use this driver for other SoCs. If necessary, SoCs can provide their own ecc_strength_avail. This must be an array of supported ecc.strength in descending order, terminated by zero. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> --- drivers/mtd/nand/denali.c | 5 ++++- drivers/mtd/nand/denali.h | 1 + drivers/mtd/nand/denali_dt.c | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) -- 2.7.4