3 * 2N Telekomunikace, a.s. <www.2n.cz>
4 * Ladislav Michl <michl@2n.cz>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #ifndef CONFIG_SYS_NAND_BASE_LIST
28 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
31 DECLARE_GLOBAL_DATA_PTR
;
33 int nand_curr_device
= -1;
34 nand_info_t nand_info
[CONFIG_SYS_MAX_NAND_DEVICE
];
36 static struct nand_chip nand_chip
[CONFIG_SYS_MAX_NAND_DEVICE
];
37 static ulong base_address
[CONFIG_SYS_MAX_NAND_DEVICE
] = CONFIG_SYS_NAND_BASE_LIST
;
39 static const char default_nand_name
[] = "nand";
40 static __attribute__((unused
)) char dev_name
[CONFIG_SYS_MAX_NAND_DEVICE
][8];
42 static void nand_init_chip(struct mtd_info
*mtd
, struct nand_chip
*nand
,
45 int maxchips
= CONFIG_SYS_NAND_MAX_CHIPS
;
46 static int __attribute__((unused
)) i
= 0;
52 nand
->IO_ADDR_R
= nand
->IO_ADDR_W
= (void __iomem
*)base_addr
;
53 if (board_nand_init(nand
) == 0) {
54 if (nand_scan(mtd
, maxchips
) == 0) {
56 mtd
->name
= (char *)default_nand_name
;
57 #ifdef CONFIG_NEEDS_MANUAL_RELOC
59 mtd
->name
+= gd
->reloc_off
;
62 #ifdef CONFIG_MTD_DEVICE
64 * Add MTD device so that we can reference it later
65 * via the mtdcore infrastructure (e.g. ubi).
67 sprintf(dev_name
[i
], "nand%d", i
);
68 mtd
->name
= dev_name
[i
++];
83 unsigned int size
= 0;
84 for (i
= 0; i
< CONFIG_SYS_MAX_NAND_DEVICE
; i
++) {
85 nand_init_chip(&nand_info
[i
], &nand_chip
[i
], base_address
[i
]);
86 size
+= nand_info
[i
].size
/ 1024;
87 if (nand_curr_device
== -1)
90 printf("%u MiB\n", size
/ 1024);
92 #ifdef CONFIG_SYS_NAND_SELECT_DEVICE
94 * Select the chip in the board/cpu specific driver
96 board_nand_select_device(nand_info
[nand_curr_device
].priv
, nand_curr_device
);