Skip to contentSkip to conversation

SPL:Defines function required to env read for IFC & env_nand

PATCH Superseded Prabhakar Kushwaha 2 participants 2 messages Oct 25, 2013 – Nov 6, 2013

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 5/6 SPL:Defines function required to env read for IFC & env_nand

fsl_ifs_spl.c reads data from NAND and store at a memory location in raw mode. It does not used MTD layer.
To read env variable from NAND MTD layer read/write required.

Hence, add mtd_block_isbad & nand_read_skip_bad function required during env variable read.

Also, avoid nand_info during env read for SPL

---
Based upon git://git.denx.de/u-boot-mpc85xx.git branch next

Changes for v2: Sending as it is

 common/env_nand.c              |    4 ++++
 drivers/mtd/nand/fsl_ifc_spl.c |   22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
common/env_nand.c +4 -0
index 695a9ee..77ba003 100644
@@ -245,7 +245,11 @@ int readenv(size_t offset, u_char *buf)
 	size_t blocksize, len;
 	u_char *char_ptr;
 
+#ifdef CONFIG_SPL_BUILD
+	blocksize = CONFIG_ENV_SIZE;;
+#else
 	blocksize = nand_info[0].erasesize;
+#endif
 	if (!blocksize)
 		return 1;
 
drivers/mtd/nand/fsl_ifc_spl.c +22 -0
index d462265..0db7142 100644
@@ -11,6 +11,28 @@
 #include <asm/io.h>
 #include <asm/fsl_ifc.h>
 #include <linux/mtd/nand.h>
+#ifndef CONFIG_SPL_INIT_MINIMAL
+#include <linux/mtd/mtd.h>
+#endif
+
+static void nand_load(unsigned int offs, int uboot_size, uchar *dst);
+
+#ifdef CONFIG_ENV_IS_IN_NAND
+struct mtd_info nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
+
+int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
+{
+	return 0;
+}
+
+int nand_read_skip_bad(struct mtd_info *nand, loff_t offset, size_t *length,
+		size_t *actual, loff_t lim, u_char *buffer)
+{
+	nand_load(offset, *length, buffer);
+	return 0;
+}
+#endif
+
 
 static inline int is_blank(uchar *addr, int page_size)
 {
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 5/6 SPL:Defines function required to env read for IFC & env_nand

Quoted 24 lines · Prabhakar Kushwaha

fsl_ifs_spl.c reads data from NAND and store at a memory location in raw mode. It does not used MTD layer.
To read env variable from NAND MTD layer read/write required.

Hence, add mtd_block_isbad & nand_read_skip_bad function required during env variable read.

Also, avoid nand_info during env read for SPL

---
Based upon git://git.denx.de/u-boot-mpc85xx.git branch next

Changes for v2: Sending as it is

 common/env_nand.c              |    4 ++++
 drivers/mtd/nand/fsl_ifc_spl.c |   22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
common/env_nand.c +0 -0
index 695a9ee..77ba003 100644

common/env_nand.c int readenv(size_t offset, u_char *buf) · line 252

Quoted 8 lines
common/env_nand.c +4 -0
@@ -245,7 +245,11 @@ int readenv(size_t offset, u_char *buf)
 	size_t blocksize, len;
 	u_char *char_ptr;
 
+#ifdef CONFIG_SPL_BUILD
+	blocksize = CONFIG_ENV_SIZE;;
+#else
 	blocksize = nand_info[0].erasesize;
+#endif

Extra semicolon

As discussed earlier, use CONFIG_SYS_NAND_BLOCK_SIZE.

Quoted 8 lines
common/env_nand.c +0 -0
 	if (!blocksize)
 		return 1;
 
drivers/mtd/nand/fsl_ifc_spl.c +0 -0
index d462265..0db7142 100644

drivers/mtd/nand/fsl_ifc_spl.c line 16

Quoted 6 lines
drivers/mtd/nand/fsl_ifc_spl.c +3 -0
@@ -11,6 +11,28 @@
 #include <asm/io.h>
 #include <asm/fsl_ifc.h>
 #include <linux/mtd/nand.h>
+#ifndef CONFIG_SPL_INIT_MINIMAL
+#include <linux/mtd/mtd.h>
+#endif

I think you mean "#ifdef CONFIG_ENV_IS_IN_NAND", but in any case you usually shouldn't need to ifdef headers.

-Scott