[PATCH RFC 02/20] mtd: Allow building nand_spl_simple w/o SPL_NAND_ECC

Lubomir Rintel lkundrak at v3.sk
Tue Nov 17 22:00:00 CET 2020


The Skytone Alpha 400 boards don't use ECC.

It's probably and oversignt and certainly a bad idea, nevertheless
enforcing ECC on existing boards would break boot. Sigh.

Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
---
 drivers/mtd/nand/raw/nand_spl_simple.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_spl_simple.c b/drivers/mtd/nand/raw/nand_spl_simple.c
index 09e053541a9..ea5bcaf3982 100644
--- a/drivers/mtd/nand/raw/nand_spl_simple.c
+++ b/drivers/mtd/nand/raw/nand_spl_simple.c
@@ -9,14 +9,16 @@
 #include <asm/io.h>
 #include <linux/mtd/nand_ecc.h>
 
-static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
 static struct mtd_info *mtd;
 static struct nand_chip nand_chip;
 
+#if IS_ENABLED(CONFIG_SPL_NAND_ECC)
+static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
+
 #define ECCSTEPS	(CONFIG_SYS_NAND_PAGE_SIZE / \
 					CONFIG_SYS_NAND_ECCSIZE)
 #define ECCTOTAL	(ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES)
-
+#endif
 
 #if (CONFIG_SYS_NAND_PAGE_SIZE <= 512)
 /*
@@ -166,7 +168,7 @@ static int nand_read_page(int block, int page, uchar *dst)
 
 	return 0;
 }
-#else
+#elif IS_ENABLED(CONFIG_SPL_NAND_ECC)
 static int nand_read_page(int block, int page, void *dst)
 {
 	struct nand_chip *this = mtd_to_nand(mtd);
@@ -206,6 +208,16 @@ static int nand_read_page(int block, int page, void *dst)
 
 	return 0;
 }
+#else
+static int nand_read_page(int block, int page, void *dst)
+{
+	struct nand_chip *this = mtd_to_nand(mtd);
+
+	nand_command(block, page, 0, NAND_CMD_READ0);
+	this->read_buf(mtd, dst, CONFIG_SYS_NAND_PAGE_SIZE);
+
+	return 0;
+}
 #endif
 
 /* nand_init() - initialize data to make nand usable by SPL */
-- 
2.28.0



More information about the U-Boot mailing list