[U-Boot] [RFC/PATCH 1/4] Enable multi chip support in the NAND layer

Wolfgang Grandegger
2009-01-07T18:53:45Z

This patch adds support for NAND_MAX_CHIPS to the MTD NAND layer.
Multi-chip devices are then displayed as shown:

Device 0: 2x NAND 512MiB 3,3V 8-bit, sector size 128 KiB

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
common/cmd_nand.c | 10 +++++++++-
drivers/mtd/nand/nand.c | 10 +++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)

Index: u-boot/common/cmd_nand.c
===================================================================
--- u-boot.orig/common/cmd_nand.c
+++ u-boot/common/cmd_nand.c
@@ -191,10 +191,18 @@ int do_nand(cmd_tbl_t * cmdtp, int flag,

putc('\n');
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
- if (nand_info[i].name)
+ if (nand_info[i].name) {
+#if NAND_MAX_CHIPS > 1
+ struct nand_chip *chip = nand_info[i].priv;
+ printf("Device %d: %dx %s, sector size %u KiB\n",
+ i, chip->numchips, nand_info[i].name,
+ nand_info[i].erasesize >> 10);
+#else
printf("Device %d: %s, sector size %u KiB\n",
i, nand_info[i].name,
nand_info[i].erasesize >> 10);
+#endif
+ }
}
return 0;
}
Index: u-boot/drivers/mtd/nand/nand.c
===================================================================
--- u-boot.orig/drivers/mtd/nand/nand.c
+++ u-boot/drivers/mtd/nand/nand.c
@@ -28,6 +28,10 @@
#define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
#endif

+#ifndef NAND_MAX_CHIPS
+#define NAND_MAX_CHIPS 1
+#endif
+
int nand_curr_device = -1;
nand_info_t nand_info[CONFIG_SYS_MAX_NAND_DEVICE];

@@ -41,11 +45,15 @@ extern int board_nand_init(struct nand_c
static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
ulong base_addr)
{
+ int maxchips = NAND_MAX_CHIPS;
+
+ if (maxchips < 1)
+ maxchips = 1;
mtd->priv = nand;

nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;
if (board_nand_init(nand) == 0) {
- if (nand_scan(mtd, 1) == 0) {
+ if (nand_scan(mtd, maxchips) == 0) {
if (!mtd->name)
mtd->name = (char *)default_nand_name;
} else