summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-07-18 12:56:33 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-08-06 13:55:03 +0200
commit2f1cfea510284f1ab6aa9b7268a4dba28748ee0e (patch)
treea1020484cf71c58e154d1839a2f3662fbf7dec71 /drivers/mtd
parentfaf766e2b21661ad8e247d1d83f571bfa9d55d8f (diff)
downloadbarebox-2f1cfea510284f1ab6aa9b7268a4dba28748ee0e.tar.gz
barebox-2f1cfea510284f1ab6aa9b7268a4dba28748ee0e.tar.xz
mtd: nand: Add function to parse device tree properties
This adds nand_of_parse_node() which can be used to parse generic NAND device properties. Not very complete yet, but it's a start. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand_base.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index bf15e6ccee..e103eac596 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -43,6 +43,7 @@
#include <io.h>
#include <malloc.h>
#include <module.h>
+#include <of_mtd.h>
/* Define default oob placement schemes for large and small page devices */
static struct nand_ecclayout nand_oob_8 = {
@@ -3507,6 +3508,32 @@ ident_done:
}
/**
+ * nand_of_parse_node - parse generic NAND properties
+ * @mtd: MTD device structure
+ * @np: Device node to read information from
+ *
+ * This parses device tree properties generic to NAND controllers and fills in
+ * the various fields in struct nand_chip.
+ */
+void nand_of_parse_node(struct mtd_info *mtd, struct device_node *np)
+{
+ struct nand_chip *chip = mtd->priv;
+ int ecc_strength, ecc_size;
+
+ if (!IS_ENABLED(CONFIG_OFDEVICE))
+ return;
+
+ ecc_strength = of_get_nand_ecc_strength(np);
+ ecc_size = of_get_nand_ecc_step_size(np);
+
+ if (ecc_strength >= 0)
+ chip->ecc.strength = ecc_strength;
+
+ if (ecc_size >= 0)
+ chip->ecc.size = ecc_size;
+}
+
+/**
* nand_scan_ident - [NAND Interface] Scan for the NAND device
* @mtd: MTD device structure
* @maxchips: number of chips to scan for