aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/devices/elm.c13
-rw-r--r--drivers/mtd/nand/omap2.c9
-rw-r--r--include/linux/platform_data/elm.h3
3 files changed, 20 insertions, 5 deletions
diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c
index f160d2c6cd59..c51752ad072e 100644
--- a/drivers/mtd/devices/elm.c
+++ b/drivers/mtd/devices/elm.c
@@ -103,7 +103,8 @@ static u32 elm_read_reg(struct elm_info *info, int offset)
103 * @dev: ELM device 103 * @dev: ELM device
104 * @bch_type: Type of BCH ecc 104 * @bch_type: Type of BCH ecc
105 */ 105 */
106int elm_config(struct device *dev, enum bch_ecc bch_type) 106int elm_config(struct device *dev, enum bch_ecc bch_type,
107 int ecc_steps, int ecc_step_size, int ecc_syndrome_size)
107{ 108{
108 u32 reg_val; 109 u32 reg_val;
109 struct elm_info *info = dev_get_drvdata(dev); 110 struct elm_info *info = dev_get_drvdata(dev);
@@ -112,6 +113,16 @@ int elm_config(struct device *dev, enum bch_ecc bch_type)
112 dev_err(dev, "Unable to configure elm - device not probed?\n"); 113 dev_err(dev, "Unable to configure elm - device not probed?\n");
113 return -ENODEV; 114 return -ENODEV;
114 } 115 }
116 /* ELM cannot detect ECC errors for chunks > 1KB */
117 if (ecc_step_size > ((ELM_ECC_SIZE + 1) / 2)) {
118 dev_err(dev, "unsupported config ecc-size=%d\n", ecc_step_size);
119 return -EINVAL;
120 }
121 /* ELM support 8 error syndrome process */
122 if (ecc_steps > ERROR_VECTOR_MAX) {
123 dev_err(dev, "unsupported config ecc-step=%d\n", ecc_steps);
124 return -EINVAL;
125 }
115 126
116 reg_val = (bch_type & ECC_BCH_LEVEL_MASK) | (ELM_ECC_SIZE << 16); 127 reg_val = (bch_type & ECC_BCH_LEVEL_MASK) | (ELM_ECC_SIZE << 16);
117 elm_write_reg(info, ELM_LOCATION_CONFIG, reg_val); 128 elm_write_reg(info, ELM_LOCATION_CONFIG, reg_val);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index ab9c472456d9..6f9b339aed74 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1540,6 +1540,8 @@ static int is_elm_present(struct omap_nand_info *info,
1540 struct device_node *elm_node, enum bch_ecc bch_type) 1540 struct device_node *elm_node, enum bch_ecc bch_type)
1541{ 1541{
1542 struct platform_device *pdev; 1542 struct platform_device *pdev;
1543 struct nand_ecc_ctrl *ecc = &info->nand.ecc;
1544 int err;
1543 /* check whether elm-id is passed via DT */ 1545 /* check whether elm-id is passed via DT */
1544 if (!elm_node) { 1546 if (!elm_node) {
1545 pr_err("nand: error: ELM DT node not found\n"); 1547 pr_err("nand: error: ELM DT node not found\n");
@@ -1553,9 +1555,10 @@ static int is_elm_present(struct omap_nand_info *info,
1553 } 1555 }
1554 /* ELM module available, now configure it */ 1556 /* ELM module available, now configure it */
1555 info->elm_dev = &pdev->dev; 1557 info->elm_dev = &pdev->dev;
1556 if (elm_config(info->elm_dev, bch_type)) 1558 err = elm_config(info->elm_dev, bch_type,
1557 return -ENODEV; 1559 (info->mtd.writesize / ecc->size), ecc->size, ecc->bytes);
1558 return 0; 1560
1561 return err;
1559} 1562}
1560#endif /* CONFIG_MTD_NAND_ECC_BCH */ 1563#endif /* CONFIG_MTD_NAND_ECC_BCH */
1561 1564
diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h
index bf0a83b7ed9d..6e37156b0902 100644
--- a/include/linux/platform_data/elm.h
+++ b/include/linux/platform_data/elm.h
@@ -50,5 +50,6 @@ struct elm_errorvec {
50 50
51void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc, 51void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
52 struct elm_errorvec *err_vec); 52 struct elm_errorvec *err_vec);
53int elm_config(struct device *dev, enum bch_ecc bch_type); 53int elm_config(struct device *dev, enum bch_ecc bch_type,
54 int ecc_steps, int ecc_step_size, int ecc_syndrome_size);
54#endif /* __ELM_H */ 55#endif /* __ELM_H */