[U-Boot] [PATCH 2/4] Support run-time disabling of NAND and OneNAND memories.
Josh Karabin
gkarabin at vocollect.com
Tue May 26 22:14:14 CEST 2009
Add "disable" functions that will prevent the initialization
function of nand and onenand interfaces from completing.
These functions are intended to be called on boards that can
be populated with one of multiple persistent memory types.
Board initialization code must ensure that only the correct
memory type is used by called the disable function(s) of
memory types that are supported at run time, but aren't
present on the board.
Signed-off-by: Josh Karabin <gkarabin at vocollect.com>
---
drivers/mtd/nand/nand.c | 10 ++++++++++
drivers/mtd/onenand/onenand_uboot.c | 9 +++++++++
include/nand.h | 1 +
include/onenand_uboot.h | 1 +
4 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index d369115..59ba140 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -38,6 +38,7 @@ static ulong base_address[CONFIG_SYS_MAX_NAND_DEVICE] = CONFIG_SYS_NAND_BASE_LIS
static const char default_nand_name[] = "nand";
static __attribute__((unused)) char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
+static int nand_disabled = 0;
static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
ulong base_addr)
@@ -75,10 +76,19 @@ static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
}
+void nand_disable_init(void)
+{
+ nand_disabled = 1;
+}
+
void nand_init(void)
{
int i;
unsigned int size = 0;
+
+ if (nand_disabled)
+ return;
+
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
nand_init_chip(&nand_info[i], &nand_chip[i], base_address[i]);
size += nand_info[i].size / 1024;
diff --git a/drivers/mtd/onenand/onenand_uboot.c b/drivers/mtd/onenand/onenand_uboot.c
index a95b922..17bcd51 100644
--- a/drivers/mtd/onenand/onenand_uboot.c
+++ b/drivers/mtd/onenand/onenand_uboot.c
@@ -21,9 +21,18 @@
struct mtd_info onenand_mtd;
struct onenand_chip onenand_chip;
static __attribute__((unused)) char dev_name[] = "onenand0";
+static int onenand_disabled = 0;
+
+void onenand_disable_init(void)
+{
+ onenand_disabled = 1;
+}
void onenand_init(void)
{
+ if (onenand_disabled)
+ return;
+
memset(&onenand_mtd, 0, sizeof(struct mtd_info));
memset(&onenand_chip, 0, sizeof(struct onenand_chip));
diff --git a/include/nand.h b/include/nand.h
index 065a42c..e8e21ef 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -24,6 +24,7 @@
#ifndef _NAND_H_
#define _NAND_H_
+extern void nand_disable_init(void);
extern void nand_init(void);
#ifndef CONFIG_NAND_LEGACY
diff --git a/include/onenand_uboot.h b/include/onenand_uboot.h
index 49da9d0..a82213d 100644
--- a/include/onenand_uboot.h
+++ b/include/onenand_uboot.h
@@ -28,6 +28,7 @@ extern struct mtd_info onenand_mtd;
extern void onenand_board_init(struct mtd_info *);
/* Functions */
+extern void onenand_disable_init(void);
extern void onenand_init(void);
extern int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t * retlen, u_char * buf);
--
1.6.0.6
More information about the U-Boot
mailing list