]> git.sur5r.net Git - u-boot/commitdiff
Enable multi chip support in the NAND layer
authorWolfgang Grandegger <wg@grandegger.com>
Wed, 11 Feb 2009 17:38:20 +0000 (18:38 +0100)
committerScott Wood <scottwood@freescale.com>
Mon, 23 Mar 2009 20:53:37 +0000 (15:53 -0500)
This patch adds support for NAND_MAX_CHIPS to the MTD NAND layer.
Multi-chips devices are displayed as shown:

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

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
common/cmd_nand.c
drivers/mtd/nand/nand.c
drivers/mtd/nand/nand_base.c

index 04b3200e57dd4790f4af1c27981af00aae3cf8fe..e142d7666151718e98162b4c19179b5f6704a8bc 100644 (file)
@@ -205,6 +205,17 @@ static void do_nand_status(nand_info_t *nand)
 }
 #endif
 
+static void nand_print_info(int idx)
+{
+       nand_info_t *nand = &nand_info[idx];
+       struct nand_chip *chip = nand->priv;
+       printf("Device %d: ", idx);
+       if (chip->numchips > 1)
+               printf("%dx ", chip->numchips);
+       printf("%s, sector size %u KiB\n",
+              nand->name, nand->erasesize >> 10);
+}
+
 int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
        int i, dev, ret = 0;
@@ -233,9 +244,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
                putc('\n');
                for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
                        if (nand_info[i].name)
-                               printf("Device %d: %s, sector size %u KiB\n",
-                                      i, nand_info[i].name,
-                                      nand_info[i].erasesize >> 10);
+                               nand_print_info(i);
                }
                return 0;
        }
@@ -243,12 +252,12 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
        if (strcmp(cmd, "device") == 0) {
 
                if (argc < 3) {
+                       putc('\n');
                        if ((nand_curr_device < 0) ||
                            (nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE))
-                               puts("\nno devices available\n");
+                               puts("no devices available\n");
                        else
-                               printf("\nDevice %d: %s\n", nand_curr_device,
-                                      nand_info[nand_curr_device].name);
+                               nand_print_info(nand_curr_device);
                        return 0;
                }
                dev = (int)simple_strtoul(argv[2], NULL, 10);
index 70b605f9d2816365bad1be4079268db6ef5d2e8e..9d8379497431ba19eeb626c1174b7d40384ed177 100644 (file)
@@ -41,11 +41,15 @@ static const char default_nand_name[] = "nand";
 static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
                           ulong base_addr)
 {
+       int maxchips = CONFIG_SYS_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
index d33fee242f0ad68e15840401a56dc4d864a3c6b4..e6ac859e1a52d336767eb06e9d8822cd6f822bd6 100644 (file)
@@ -2652,8 +2652,10 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
                    type->id != chip->read_byte(mtd))
                        break;
        }
+#ifdef DEBUG
        if (i > 1)
                printk(KERN_INFO "%d NAND chips detected\n", i);
+#endif
 
        /* Store the number of chips and calc total size for mtd */
        chip->numchips = i;