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,
28 #ifndef CONFIG_SYS_NAND_BASE_LIST
29 #define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
32 DECLARE_GLOBAL_DATA_PTR
;
34 int nand_curr_device
= -1;
37 nand_info_t nand_info
[CONFIG_SYS_MAX_NAND_DEVICE
];
39 #ifndef CONFIG_SYS_NAND_SELF_INIT
40 static struct nand_chip nand_chip
[CONFIG_SYS_MAX_NAND_DEVICE
];
41 static ulong base_address
[CONFIG_SYS_MAX_NAND_DEVICE
] = CONFIG_SYS_NAND_BASE_LIST
;
44 static char dev_name
[CONFIG_SYS_MAX_NAND_DEVICE
][8];
46 static unsigned long total_nand_size
; /* in kiB */
48 /* Register an initialized NAND mtd device with the U-Boot NAND command. */
49 int nand_register(int devnum
)
53 if (devnum
>= CONFIG_SYS_MAX_NAND_DEVICE
)
56 mtd
= &nand_info
[devnum
];
58 sprintf(dev_name
[devnum
], "nand%d", devnum
);
59 mtd
->name
= dev_name
[devnum
];
61 #ifdef CONFIG_MTD_DEVICE
63 * Add MTD device so that we can reference it later
64 * via the mtdcore infrastructure (e.g. ubi).
69 total_nand_size
+= mtd
->size
/ 1024;
71 if (nand_curr_device
== -1)
72 nand_curr_device
= devnum
;
77 #ifndef CONFIG_SYS_NAND_SELF_INIT
78 static void nand_init_chip(int i
)
80 struct mtd_info
*mtd
= &nand_info
[i
];
81 struct nand_chip
*nand
= &nand_chip
[i
];
82 ulong base_addr
= base_address
[i
];
83 int maxchips
= CONFIG_SYS_NAND_MAX_CHIPS
;
89 nand
->IO_ADDR_R
= nand
->IO_ADDR_W
= (void __iomem
*)base_addr
;
91 if (board_nand_init(nand
))
94 if (nand_scan(mtd
, maxchips
))
103 #ifdef CONFIG_SYS_NAND_SELF_INIT
108 for (i
= 0; i
< CONFIG_SYS_MAX_NAND_DEVICE
; i
++)
112 printf("%lu MiB\n", total_nand_size
/ 1024);
114 #ifdef CONFIG_SYS_NAND_SELECT_DEVICE
116 * Select the chip in the board/cpu specific driver
118 board_nand_select_device(nand_info
[nand_curr_device
].priv
, nand_curr_device
);