public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC 4/5] SPL:Defines function required to env read for IFC & env_nand
@ 2013-09-16 16:05 Prabhakar Kushwaha
  2013-09-16 23:53 ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Prabhakar Kushwaha @ 2013-09-16 16:05 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
---
 common/env_nand.c              |    7 ++++---
 drivers/mtd/nand/Makefile      |    2 +-
 drivers/mtd/nand/fsl_ifc_spl.c |   22 ++++++++++++++++++++++
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/common/env_nand.c b/common/env_nand.c
index 7530962..7a7107f 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -246,11 +246,13 @@ int readenv(size_t offset, u_char *buf)
 	u_char *char_ptr;
 
 	blocksize = nand_info[0].erasesize;
+#ifndef CONFIG_SPL_BUILD
 	if (!blocksize)
 		return 1;
-
 	len = min(blocksize, CONFIG_ENV_SIZE);
-
+#else
+	len = CONFIG_ENV_SIZE;
+#endif
 	while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {
 		if (nand_block_isbad(&nand_info[0], offset)) {
 			offset += blocksize;
@@ -396,7 +398,6 @@ void env_relocate_spec(void)
 		return;
 	}
 #endif
-
 	ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);
 	if (ret) {
 		set_default_env("!readenv() failed");
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 366dee6..06d5d14 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -24,6 +24,7 @@ COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
 COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o
 COBJS-$(CONFIG_SPL_NAND_INIT) += nand.o
+COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_spl.o
 
 else # not spl
 
@@ -68,7 +69,6 @@ COBJS-$(CONFIG_NAND_DOCG4) += docg4.o
 else  # minimal SPL drivers
 
 COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_spl.o
-COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_spl.o
 COBJS-$(CONFIG_NAND_MXC) += mxc_nand_spl.o
 
 endif # drivers
diff --git a/drivers/mtd/nand/fsl_ifc_spl.c b/drivers/mtd/nand/fsl_ifc_spl.c
index d462265..e7edacf 100644
--- a/drivers/mtd/nand/fsl_ifc_spl.c
+++ b/drivers/mtd/nand/fsl_ifc_spl.c
@@ -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);
+
+#ifndef CONFIG_SPL_INIT_MINIMAL
+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)
 {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-25 17:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-16 16:05 [U-Boot] [RFC 4/5] SPL:Defines function required to env read for IFC & env_nand Prabhakar Kushwaha
2013-09-16 23:53 ` Scott Wood
2013-09-18 11:10   ` Prabhakar Kushwaha
2013-09-23 18:19     ` Scott Wood
2013-09-25  4:17       ` Prabhakar Kushwaha
2013-09-25 17:20         ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox