@@ -50,6 +50,31 @@ int of_get_nand_ecc_mode(struct device_node *np)
EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
/**
+ * of_get_nand_ecc_level - Get nand ecc level for the given device_node
+ * @np: Pointer to the given device_node
+ * @strengh: ECC strength
+ * @blk_size: ECC block size
+ *
+ * The function gets ecc level requirements from property 'nand-ecc-level'.
+ * Return 0 on success, -errno otherwise.
+ */
+int of_get_nand_ecc_level(struct device_node *np, u32 *strengh, u32 *blk_size)
+{
+ int err;
+
+ err = of_property_read_u32_index(np, "nand-ecc-level", 0, strengh);
+ if (err < 0)
+ return err;
+
+ err = of_property_read_u32_index(np, "nand-ecc-level", 1, blk_size);
+ if (err < 0)
+ return err;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(of_get_nand_ecc_level);
+
+/**
* of_get_nand_bus_width - Get nand bus witdh for given device_node
* @np: Pointer to the given device_node
*
@@ -13,6 +13,7 @@
#include <linux/of.h>
int of_get_nand_ecc_mode(struct device_node *np);
+int of_get_nand_ecc_level(struct device_node *np, u32 *strengh, u32 *blk_size);
int of_get_nand_bus_width(struct device_node *np);
bool of_get_nand_on_flash_bbt(struct device_node *np);
@@ -23,6 +24,12 @@ static inline int of_get_nand_ecc_mode(struct device_node *np)
return -ENOSYS;
}
+static inline int of_get_nand_ecc_level(struct device_node *np, u32 *strengh,
+ u32 *blk_size)
+{
+ return -ENOSYS;
+}
+
static inline int of_get_nand_bus_width(struct device_node *np)
{
return -ENOSYS;
Some chip do not support automatic retrieval of ECC level requirements. Provide an helper function to retrieve these requirements from DT. Signed-off-by: Boris BREZILLON <b.brezillon.dev@gmail.com> --- drivers/of/of_mtd.c | 25 +++++++++++++++++++++++++ include/linux/of_mtd.h | 7 +++++++ 2 files changed, 32 insertions(+)