projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mtd: nand: Wait for PAGEPROG to finish in drivers setting NAND_ECC_CUSTOM_PAGE_ACCESS
[oweals/u-boot.git]
/
drivers
/
mtd
/
nand
/
nand.c
diff --git
a/drivers/mtd/nand/nand.c
b/drivers/mtd/nand/nand.c
index 05512412b9404a886f5c4457ea43527c16d909aa..6aa909fdd9751b3b5a853d7b70c8d5e977fe28ea 100644
(file)
--- a/
drivers/mtd/nand/nand.c
+++ b/
drivers/mtd/nand/nand.c
@@
-19,8
+19,7
@@
DECLARE_GLOBAL_DATA_PTR;
int nand_curr_device = -1;
int nand_curr_device = -1;
-
-struct mtd_info *nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
+static struct mtd_info *nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
#ifndef CONFIG_SYS_NAND_SELF_INIT
static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
#ifndef CONFIG_SYS_NAND_SELF_INIT
static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
@@
-31,12
+30,21
@@
static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
static unsigned long total_nand_size; /* in kiB */
static unsigned long total_nand_size; /* in kiB */
+struct mtd_info *get_nand_dev_by_index(int dev)
+{
+ if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[dev] ||
+ !nand_info[dev]->name)
+ return NULL;
+
+ return nand_info[dev];
+}
+
int nand_mtd_to_devnum(struct mtd_info *mtd)
{
int i;
int nand_mtd_to_devnum(struct mtd_info *mtd)
{
int i;
- for (i = 0; i <
ARRAY_SIZE(nand_info)
; i++) {
- if (mtd &&
nand_info[i]
== mtd)
+ for (i = 0; i <
CONFIG_SYS_MAX_NAND_DEVICE
; i++) {
+ if (mtd &&
get_nand_dev_by_index(i)
== mtd)
return i;
}
return i;
}
@@
-101,8
+109,9
@@
static void create_mtd_concat(void)
int i;
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
int i;
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
- if (nand_info[i] != NULL) {
- nand_info_list[nand_devices_found] = nand_info[i];
+ struct mtd_info *mtd = get_nand_dev_by_index(i);
+ if (mtd != NULL) {
+ nand_info_list[nand_devices_found] = mtd;
nand_devices_found++;
}
}
nand_devices_found++;
}
}
@@
-131,8
+140,23
@@
static void create_mtd_concat(void)
}
#endif
}
#endif
+unsigned long nand_size(void)
+{
+ return total_nand_size;
+}
+
void nand_init(void)
{
void nand_init(void)
{
+ static int initialized;
+
+ /*
+ * Avoid initializing NAND Flash multiple times,
+ * otherwise it will calculate a wrong total size.
+ */
+ if (initialized)
+ return;
+ initialized = 1;
+
#ifdef CONFIG_SYS_NAND_SELF_INIT
board_nand_init();
#else
#ifdef CONFIG_SYS_NAND_SELF_INIT
board_nand_init();
#else
@@
-142,13
+166,11
@@
void nand_init(void)
nand_init_chip(i);
#endif
nand_init_chip(i);
#endif
- printf("%lu MiB\n", total_nand_size / 1024);
-
#ifdef CONFIG_SYS_NAND_SELECT_DEVICE
/*
* Select the chip in the board/cpu specific driver
*/
#ifdef CONFIG_SYS_NAND_SELECT_DEVICE
/*
* Select the chip in the board/cpu specific driver
*/
- board_nand_select_device(mtd_to_nand(
nand_info[nand_curr_device]
),
+ board_nand_select_device(mtd_to_nand(
get_nand_dev_by_index(nand_curr_device)
),
nand_curr_device);
#endif
nand_curr_device);
#endif