1*a430fa06SMiquel Raynal // SPDX-License-Identifier: GPL-2.0+
2*a430fa06SMiquel Raynal /*
3*a430fa06SMiquel Raynal * (C) Copyright 2009
4*a430fa06SMiquel Raynal * Magnus Lilja <lilja.magnus@gmail.com>
5*a430fa06SMiquel Raynal *
6*a430fa06SMiquel Raynal * (C) Copyright 2008
7*a430fa06SMiquel Raynal * Maxim Artamonov, <scn1874 at yandex.ru>
8*a430fa06SMiquel Raynal *
9*a430fa06SMiquel Raynal * (C) Copyright 2006-2008
10*a430fa06SMiquel Raynal * Stefan Roese, DENX Software Engineering, sr at denx.de.
11*a430fa06SMiquel Raynal */
12*a430fa06SMiquel Raynal
13*a430fa06SMiquel Raynal #include <common.h>
14*a430fa06SMiquel Raynal #include <nand.h>
15*a430fa06SMiquel Raynal #include <asm/arch/imx-regs.h>
16*a430fa06SMiquel Raynal #include <asm/io.h>
17*a430fa06SMiquel Raynal #include "mxc_nand.h"
18*a430fa06SMiquel Raynal
19*a430fa06SMiquel Raynal #if defined(MXC_NFC_V1) || defined(MXC_NFC_V2_1)
20*a430fa06SMiquel Raynal static struct mxc_nand_regs *const nfc = (void *)NFC_BASE_ADDR;
21*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V3_2)
22*a430fa06SMiquel Raynal static struct mxc_nand_regs *const nfc = (void *)NFC_BASE_ADDR_AXI;
23*a430fa06SMiquel Raynal static struct mxc_nand_ip_regs *const nfc_ip = (void *)NFC_BASE_ADDR;
24*a430fa06SMiquel Raynal #endif
25*a430fa06SMiquel Raynal
nfc_wait_ready(void)26*a430fa06SMiquel Raynal static void nfc_wait_ready(void)
27*a430fa06SMiquel Raynal {
28*a430fa06SMiquel Raynal uint32_t tmp;
29*a430fa06SMiquel Raynal
30*a430fa06SMiquel Raynal #if defined(MXC_NFC_V1) || defined(MXC_NFC_V2_1)
31*a430fa06SMiquel Raynal while (!(readnfc(&nfc->config2) & NFC_V1_V2_CONFIG2_INT))
32*a430fa06SMiquel Raynal ;
33*a430fa06SMiquel Raynal
34*a430fa06SMiquel Raynal /* Reset interrupt flag */
35*a430fa06SMiquel Raynal tmp = readnfc(&nfc->config2);
36*a430fa06SMiquel Raynal tmp &= ~NFC_V1_V2_CONFIG2_INT;
37*a430fa06SMiquel Raynal writenfc(tmp, &nfc->config2);
38*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V3_2)
39*a430fa06SMiquel Raynal while (!(readnfc(&nfc_ip->ipc) & NFC_V3_IPC_INT))
40*a430fa06SMiquel Raynal ;
41*a430fa06SMiquel Raynal
42*a430fa06SMiquel Raynal /* Reset interrupt flag */
43*a430fa06SMiquel Raynal tmp = readnfc(&nfc_ip->ipc);
44*a430fa06SMiquel Raynal tmp &= ~NFC_V3_IPC_INT;
45*a430fa06SMiquel Raynal writenfc(tmp, &nfc_ip->ipc);
46*a430fa06SMiquel Raynal #endif
47*a430fa06SMiquel Raynal }
48*a430fa06SMiquel Raynal
nfc_nand_init(void)49*a430fa06SMiquel Raynal static void nfc_nand_init(void)
50*a430fa06SMiquel Raynal {
51*a430fa06SMiquel Raynal #if defined(MXC_NFC_V3_2)
52*a430fa06SMiquel Raynal int ecc_per_page = CONFIG_SYS_NAND_PAGE_SIZE / 512;
53*a430fa06SMiquel Raynal int tmp;
54*a430fa06SMiquel Raynal
55*a430fa06SMiquel Raynal tmp = (readnfc(&nfc_ip->config2) & ~(NFC_V3_CONFIG2_SPAS_MASK |
56*a430fa06SMiquel Raynal NFC_V3_CONFIG2_EDC_MASK | NFC_V3_CONFIG2_PS_MASK)) |
57*a430fa06SMiquel Raynal NFC_V3_CONFIG2_SPAS(CONFIG_SYS_NAND_OOBSIZE / 2) |
58*a430fa06SMiquel Raynal NFC_V3_CONFIG2_INT_MSK | NFC_V3_CONFIG2_ECC_EN |
59*a430fa06SMiquel Raynal NFC_V3_CONFIG2_ONE_CYCLE;
60*a430fa06SMiquel Raynal if (CONFIG_SYS_NAND_PAGE_SIZE == 4096)
61*a430fa06SMiquel Raynal tmp |= NFC_V3_CONFIG2_PS_4096;
62*a430fa06SMiquel Raynal else if (CONFIG_SYS_NAND_PAGE_SIZE == 2048)
63*a430fa06SMiquel Raynal tmp |= NFC_V3_CONFIG2_PS_2048;
64*a430fa06SMiquel Raynal else if (CONFIG_SYS_NAND_PAGE_SIZE == 512)
65*a430fa06SMiquel Raynal tmp |= NFC_V3_CONFIG2_PS_512;
66*a430fa06SMiquel Raynal /*
67*a430fa06SMiquel Raynal * if spare size is larger that 16 bytes per 512 byte hunk
68*a430fa06SMiquel Raynal * then use 8 symbol correction instead of 4
69*a430fa06SMiquel Raynal */
70*a430fa06SMiquel Raynal if (CONFIG_SYS_NAND_OOBSIZE / ecc_per_page > 16)
71*a430fa06SMiquel Raynal tmp |= NFC_V3_CONFIG2_ECC_MODE_8;
72*a430fa06SMiquel Raynal else
73*a430fa06SMiquel Raynal tmp &= ~NFC_V3_CONFIG2_ECC_MODE_8;
74*a430fa06SMiquel Raynal writenfc(tmp, &nfc_ip->config2);
75*a430fa06SMiquel Raynal
76*a430fa06SMiquel Raynal tmp = NFC_V3_CONFIG3_NUM_OF_DEVS(0) |
77*a430fa06SMiquel Raynal NFC_V3_CONFIG3_NO_SDMA |
78*a430fa06SMiquel Raynal NFC_V3_CONFIG3_RBB_MODE |
79*a430fa06SMiquel Raynal NFC_V3_CONFIG3_SBB(6) | /* Reset default */
80*a430fa06SMiquel Raynal NFC_V3_CONFIG3_ADD_OP(0);
81*a430fa06SMiquel Raynal #ifndef CONFIG_SYS_NAND_BUSWIDTH_16
82*a430fa06SMiquel Raynal tmp |= NFC_V3_CONFIG3_FW8;
83*a430fa06SMiquel Raynal #endif
84*a430fa06SMiquel Raynal writenfc(tmp, &nfc_ip->config3);
85*a430fa06SMiquel Raynal
86*a430fa06SMiquel Raynal writenfc(0, &nfc_ip->delay_line);
87*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V2_1)
88*a430fa06SMiquel Raynal int ecc_per_page = CONFIG_SYS_NAND_PAGE_SIZE / 512;
89*a430fa06SMiquel Raynal int config1;
90*a430fa06SMiquel Raynal
91*a430fa06SMiquel Raynal writenfc(CONFIG_SYS_NAND_OOBSIZE / 2, &nfc->spare_area_size);
92*a430fa06SMiquel Raynal
93*a430fa06SMiquel Raynal /* unlocking RAM Buff */
94*a430fa06SMiquel Raynal writenfc(0x2, &nfc->config);
95*a430fa06SMiquel Raynal
96*a430fa06SMiquel Raynal /* hardware ECC checking and correct */
97*a430fa06SMiquel Raynal config1 = readnfc(&nfc->config1) | NFC_V1_V2_CONFIG1_ECC_EN |
98*a430fa06SMiquel Raynal NFC_V1_V2_CONFIG1_INT_MSK | NFC_V2_CONFIG1_ONE_CYCLE |
99*a430fa06SMiquel Raynal NFC_V2_CONFIG1_FP_INT;
100*a430fa06SMiquel Raynal /*
101*a430fa06SMiquel Raynal * if spare size is larger that 16 bytes per 512 byte hunk
102*a430fa06SMiquel Raynal * then use 8 symbol correction instead of 4
103*a430fa06SMiquel Raynal */
104*a430fa06SMiquel Raynal if (CONFIG_SYS_NAND_OOBSIZE / ecc_per_page > 16)
105*a430fa06SMiquel Raynal config1 &= ~NFC_V2_CONFIG1_ECC_MODE_4;
106*a430fa06SMiquel Raynal else
107*a430fa06SMiquel Raynal config1 |= NFC_V2_CONFIG1_ECC_MODE_4;
108*a430fa06SMiquel Raynal writenfc(config1, &nfc->config1);
109*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V1)
110*a430fa06SMiquel Raynal /* unlocking RAM Buff */
111*a430fa06SMiquel Raynal writenfc(0x2, &nfc->config);
112*a430fa06SMiquel Raynal
113*a430fa06SMiquel Raynal /* hardware ECC checking and correct */
114*a430fa06SMiquel Raynal writenfc(NFC_V1_V2_CONFIG1_ECC_EN | NFC_V1_V2_CONFIG1_INT_MSK,
115*a430fa06SMiquel Raynal &nfc->config1);
116*a430fa06SMiquel Raynal #endif
117*a430fa06SMiquel Raynal }
118*a430fa06SMiquel Raynal
nfc_nand_command(unsigned short command)119*a430fa06SMiquel Raynal static void nfc_nand_command(unsigned short command)
120*a430fa06SMiquel Raynal {
121*a430fa06SMiquel Raynal writenfc(command, &nfc->flash_cmd);
122*a430fa06SMiquel Raynal writenfc(NFC_CMD, &nfc->operation);
123*a430fa06SMiquel Raynal nfc_wait_ready();
124*a430fa06SMiquel Raynal }
125*a430fa06SMiquel Raynal
nfc_nand_address(unsigned short address)126*a430fa06SMiquel Raynal static void nfc_nand_address(unsigned short address)
127*a430fa06SMiquel Raynal {
128*a430fa06SMiquel Raynal writenfc(address, &nfc->flash_addr);
129*a430fa06SMiquel Raynal writenfc(NFC_ADDR, &nfc->operation);
130*a430fa06SMiquel Raynal nfc_wait_ready();
131*a430fa06SMiquel Raynal }
132*a430fa06SMiquel Raynal
nfc_nand_page_address(unsigned int page_address)133*a430fa06SMiquel Raynal static void nfc_nand_page_address(unsigned int page_address)
134*a430fa06SMiquel Raynal {
135*a430fa06SMiquel Raynal unsigned int page_count;
136*a430fa06SMiquel Raynal
137*a430fa06SMiquel Raynal nfc_nand_address(0x00);
138*a430fa06SMiquel Raynal
139*a430fa06SMiquel Raynal /* code only for large page flash */
140*a430fa06SMiquel Raynal if (CONFIG_SYS_NAND_PAGE_SIZE > 512)
141*a430fa06SMiquel Raynal nfc_nand_address(0x00);
142*a430fa06SMiquel Raynal
143*a430fa06SMiquel Raynal page_count = CONFIG_SYS_NAND_SIZE / CONFIG_SYS_NAND_PAGE_SIZE;
144*a430fa06SMiquel Raynal
145*a430fa06SMiquel Raynal if (page_address <= page_count) {
146*a430fa06SMiquel Raynal page_count--; /* transform 0x01000000 to 0x00ffffff */
147*a430fa06SMiquel Raynal do {
148*a430fa06SMiquel Raynal nfc_nand_address(page_address & 0xff);
149*a430fa06SMiquel Raynal page_address = page_address >> 8;
150*a430fa06SMiquel Raynal page_count = page_count >> 8;
151*a430fa06SMiquel Raynal } while (page_count);
152*a430fa06SMiquel Raynal }
153*a430fa06SMiquel Raynal
154*a430fa06SMiquel Raynal nfc_nand_address(0x00);
155*a430fa06SMiquel Raynal }
156*a430fa06SMiquel Raynal
nfc_nand_data_output(void)157*a430fa06SMiquel Raynal static void nfc_nand_data_output(void)
158*a430fa06SMiquel Raynal {
159*a430fa06SMiquel Raynal #ifdef NAND_MXC_2K_MULTI_CYCLE
160*a430fa06SMiquel Raynal int i;
161*a430fa06SMiquel Raynal #endif
162*a430fa06SMiquel Raynal
163*a430fa06SMiquel Raynal #if defined(MXC_NFC_V1) || defined(MXC_NFC_V2_1)
164*a430fa06SMiquel Raynal writenfc(0, &nfc->buf_addr);
165*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V3_2)
166*a430fa06SMiquel Raynal int config1 = readnfc(&nfc->config1);
167*a430fa06SMiquel Raynal config1 &= ~NFC_V3_CONFIG1_RBA_MASK;
168*a430fa06SMiquel Raynal writenfc(config1, &nfc->config1);
169*a430fa06SMiquel Raynal #endif
170*a430fa06SMiquel Raynal writenfc(NFC_OUTPUT, &nfc->operation);
171*a430fa06SMiquel Raynal nfc_wait_ready();
172*a430fa06SMiquel Raynal #ifdef NAND_MXC_2K_MULTI_CYCLE
173*a430fa06SMiquel Raynal /*
174*a430fa06SMiquel Raynal * This NAND controller requires multiple input commands
175*a430fa06SMiquel Raynal * for pages larger than 512 bytes.
176*a430fa06SMiquel Raynal */
177*a430fa06SMiquel Raynal for (i = 1; i < CONFIG_SYS_NAND_PAGE_SIZE / 512; i++) {
178*a430fa06SMiquel Raynal writenfc(i, &nfc->buf_addr);
179*a430fa06SMiquel Raynal writenfc(NFC_OUTPUT, &nfc->operation);
180*a430fa06SMiquel Raynal nfc_wait_ready();
181*a430fa06SMiquel Raynal }
182*a430fa06SMiquel Raynal #endif
183*a430fa06SMiquel Raynal }
184*a430fa06SMiquel Raynal
nfc_nand_check_ecc(void)185*a430fa06SMiquel Raynal static int nfc_nand_check_ecc(void)
186*a430fa06SMiquel Raynal {
187*a430fa06SMiquel Raynal #if defined(MXC_NFC_V1)
188*a430fa06SMiquel Raynal u16 ecc_status = readw(&nfc->ecc_status_result);
189*a430fa06SMiquel Raynal return (ecc_status & 0x3) == 2 || (ecc_status >> 2) == 2;
190*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V2_1) || defined(MXC_NFC_V3_2)
191*a430fa06SMiquel Raynal u32 ecc_status = readl(&nfc->ecc_status_result);
192*a430fa06SMiquel Raynal int ecc_per_page = CONFIG_SYS_NAND_PAGE_SIZE / 512;
193*a430fa06SMiquel Raynal int err_limit = CONFIG_SYS_NAND_OOBSIZE / ecc_per_page > 16 ? 8 : 4;
194*a430fa06SMiquel Raynal int subpages = CONFIG_SYS_NAND_PAGE_SIZE / 512;
195*a430fa06SMiquel Raynal
196*a430fa06SMiquel Raynal do {
197*a430fa06SMiquel Raynal if ((ecc_status & 0xf) > err_limit)
198*a430fa06SMiquel Raynal return 1;
199*a430fa06SMiquel Raynal ecc_status >>= 4;
200*a430fa06SMiquel Raynal } while (--subpages);
201*a430fa06SMiquel Raynal
202*a430fa06SMiquel Raynal return 0;
203*a430fa06SMiquel Raynal #endif
204*a430fa06SMiquel Raynal }
205*a430fa06SMiquel Raynal
nfc_nand_read_page(unsigned int page_address)206*a430fa06SMiquel Raynal static void nfc_nand_read_page(unsigned int page_address)
207*a430fa06SMiquel Raynal {
208*a430fa06SMiquel Raynal /* read in first 0 buffer */
209*a430fa06SMiquel Raynal #if defined(MXC_NFC_V1) || defined(MXC_NFC_V2_1)
210*a430fa06SMiquel Raynal writenfc(0, &nfc->buf_addr);
211*a430fa06SMiquel Raynal #elif defined(MXC_NFC_V3_2)
212*a430fa06SMiquel Raynal int config1 = readnfc(&nfc->config1);
213*a430fa06SMiquel Raynal config1 &= ~NFC_V3_CONFIG1_RBA_MASK;
214*a430fa06SMiquel Raynal writenfc(config1, &nfc->config1);
215*a430fa06SMiquel Raynal #endif
216*a430fa06SMiquel Raynal nfc_nand_command(NAND_CMD_READ0);
217*a430fa06SMiquel Raynal nfc_nand_page_address(page_address);
218*a430fa06SMiquel Raynal
219*a430fa06SMiquel Raynal if (CONFIG_SYS_NAND_PAGE_SIZE > 512)
220*a430fa06SMiquel Raynal nfc_nand_command(NAND_CMD_READSTART);
221*a430fa06SMiquel Raynal
222*a430fa06SMiquel Raynal nfc_nand_data_output(); /* fill the main buffer 0 */
223*a430fa06SMiquel Raynal }
224*a430fa06SMiquel Raynal
nfc_read_page(unsigned int page_address,unsigned char * buf)225*a430fa06SMiquel Raynal static int nfc_read_page(unsigned int page_address, unsigned char *buf)
226*a430fa06SMiquel Raynal {
227*a430fa06SMiquel Raynal int i;
228*a430fa06SMiquel Raynal u32 *src;
229*a430fa06SMiquel Raynal u32 *dst;
230*a430fa06SMiquel Raynal
231*a430fa06SMiquel Raynal nfc_nand_read_page(page_address);
232*a430fa06SMiquel Raynal
233*a430fa06SMiquel Raynal if (nfc_nand_check_ecc())
234*a430fa06SMiquel Raynal return -EBADMSG;
235*a430fa06SMiquel Raynal
236*a430fa06SMiquel Raynal src = (u32 *)&nfc->main_area[0][0];
237*a430fa06SMiquel Raynal dst = (u32 *)buf;
238*a430fa06SMiquel Raynal
239*a430fa06SMiquel Raynal /* main copy loop from NAND-buffer to SDRAM memory */
240*a430fa06SMiquel Raynal for (i = 0; i < CONFIG_SYS_NAND_PAGE_SIZE / 4; i++) {
241*a430fa06SMiquel Raynal writel(readl(src), dst);
242*a430fa06SMiquel Raynal src++;
243*a430fa06SMiquel Raynal dst++;
244*a430fa06SMiquel Raynal }
245*a430fa06SMiquel Raynal
246*a430fa06SMiquel Raynal return 0;
247*a430fa06SMiquel Raynal }
248*a430fa06SMiquel Raynal
is_badblock(int pagenumber)249*a430fa06SMiquel Raynal static int is_badblock(int pagenumber)
250*a430fa06SMiquel Raynal {
251*a430fa06SMiquel Raynal int page = pagenumber;
252*a430fa06SMiquel Raynal u32 badblock;
253*a430fa06SMiquel Raynal u32 *src;
254*a430fa06SMiquel Raynal
255*a430fa06SMiquel Raynal /* Check the first two pages for bad block markers */
256*a430fa06SMiquel Raynal for (page = pagenumber; page < pagenumber + 2; page++) {
257*a430fa06SMiquel Raynal nfc_nand_read_page(page);
258*a430fa06SMiquel Raynal
259*a430fa06SMiquel Raynal src = (u32 *)&nfc->spare_area[0][0];
260*a430fa06SMiquel Raynal
261*a430fa06SMiquel Raynal /*
262*a430fa06SMiquel Raynal * IMPORTANT NOTE: The nand flash controller uses a non-
263*a430fa06SMiquel Raynal * standard layout for large page devices. This can
264*a430fa06SMiquel Raynal * affect the position of the bad block marker.
265*a430fa06SMiquel Raynal */
266*a430fa06SMiquel Raynal /* Get the bad block marker */
267*a430fa06SMiquel Raynal badblock = readl(&src[CONFIG_SYS_NAND_BAD_BLOCK_POS / 4]);
268*a430fa06SMiquel Raynal badblock >>= 8 * (CONFIG_SYS_NAND_BAD_BLOCK_POS % 4);
269*a430fa06SMiquel Raynal badblock &= 0xff;
270*a430fa06SMiquel Raynal
271*a430fa06SMiquel Raynal /* bad block marker verify */
272*a430fa06SMiquel Raynal if (badblock != 0xff)
273*a430fa06SMiquel Raynal return 1; /* potential bad block */
274*a430fa06SMiquel Raynal }
275*a430fa06SMiquel Raynal
276*a430fa06SMiquel Raynal return 0;
277*a430fa06SMiquel Raynal }
278*a430fa06SMiquel Raynal
nand_spl_load_image(uint32_t from,unsigned int size,void * buf)279*a430fa06SMiquel Raynal int nand_spl_load_image(uint32_t from, unsigned int size, void *buf)
280*a430fa06SMiquel Raynal {
281*a430fa06SMiquel Raynal int i;
282*a430fa06SMiquel Raynal unsigned int page;
283*a430fa06SMiquel Raynal unsigned int maxpages = CONFIG_SYS_NAND_SIZE /
284*a430fa06SMiquel Raynal CONFIG_SYS_NAND_PAGE_SIZE;
285*a430fa06SMiquel Raynal
286*a430fa06SMiquel Raynal nfc_nand_init();
287*a430fa06SMiquel Raynal
288*a430fa06SMiquel Raynal /* Convert to page number */
289*a430fa06SMiquel Raynal page = from / CONFIG_SYS_NAND_PAGE_SIZE;
290*a430fa06SMiquel Raynal i = 0;
291*a430fa06SMiquel Raynal
292*a430fa06SMiquel Raynal size = roundup(size, CONFIG_SYS_NAND_PAGE_SIZE);
293*a430fa06SMiquel Raynal while (i < size / CONFIG_SYS_NAND_PAGE_SIZE) {
294*a430fa06SMiquel Raynal if (nfc_read_page(page, buf) < 0)
295*a430fa06SMiquel Raynal return -1;
296*a430fa06SMiquel Raynal
297*a430fa06SMiquel Raynal page++;
298*a430fa06SMiquel Raynal i++;
299*a430fa06SMiquel Raynal buf = buf + CONFIG_SYS_NAND_PAGE_SIZE;
300*a430fa06SMiquel Raynal
301*a430fa06SMiquel Raynal /*
302*a430fa06SMiquel Raynal * Check if we have crossed a block boundary, and if so
303*a430fa06SMiquel Raynal * check for bad block.
304*a430fa06SMiquel Raynal */
305*a430fa06SMiquel Raynal if (!(page % CONFIG_SYS_NAND_PAGE_COUNT)) {
306*a430fa06SMiquel Raynal /*
307*a430fa06SMiquel Raynal * Yes, new block. See if this block is good. If not,
308*a430fa06SMiquel Raynal * loop until we find a good block.
309*a430fa06SMiquel Raynal */
310*a430fa06SMiquel Raynal while (is_badblock(page)) {
311*a430fa06SMiquel Raynal page = page + CONFIG_SYS_NAND_PAGE_COUNT;
312*a430fa06SMiquel Raynal /* Check i we've reached the end of flash. */
313*a430fa06SMiquel Raynal if (page >= maxpages)
314*a430fa06SMiquel Raynal return -1;
315*a430fa06SMiquel Raynal }
316*a430fa06SMiquel Raynal }
317*a430fa06SMiquel Raynal }
318*a430fa06SMiquel Raynal
319*a430fa06SMiquel Raynal return 0;
320*a430fa06SMiquel Raynal }
321*a430fa06SMiquel Raynal
322*a430fa06SMiquel Raynal #ifndef CONFIG_SPL_FRAMEWORK
323*a430fa06SMiquel Raynal /*
324*a430fa06SMiquel Raynal * The main entry for NAND booting. It's necessary that SDRAM is already
325*a430fa06SMiquel Raynal * configured and available since this code loads the main U-Boot image
326*a430fa06SMiquel Raynal * from NAND into SDRAM and starts it from there.
327*a430fa06SMiquel Raynal */
nand_boot(void)328*a430fa06SMiquel Raynal void nand_boot(void)
329*a430fa06SMiquel Raynal {
330*a430fa06SMiquel Raynal __attribute__((noreturn)) void (*uboot)(void);
331*a430fa06SMiquel Raynal
332*a430fa06SMiquel Raynal /*
333*a430fa06SMiquel Raynal * CONFIG_SYS_NAND_U_BOOT_OFFS and CONFIG_SYS_NAND_U_BOOT_SIZE must
334*a430fa06SMiquel Raynal * be aligned to full pages
335*a430fa06SMiquel Raynal */
336*a430fa06SMiquel Raynal if (!nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
337*a430fa06SMiquel Raynal CONFIG_SYS_NAND_U_BOOT_SIZE,
338*a430fa06SMiquel Raynal (uchar *)CONFIG_SYS_NAND_U_BOOT_DST)) {
339*a430fa06SMiquel Raynal /* Copy from NAND successful, start U-Boot */
340*a430fa06SMiquel Raynal uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START;
341*a430fa06SMiquel Raynal uboot();
342*a430fa06SMiquel Raynal } else {
343*a430fa06SMiquel Raynal /* Unrecoverable error when copying from NAND */
344*a430fa06SMiquel Raynal hang();
345*a430fa06SMiquel Raynal }
346*a430fa06SMiquel Raynal }
347*a430fa06SMiquel Raynal #endif
348*a430fa06SMiquel Raynal
nand_init(void)349*a430fa06SMiquel Raynal void nand_init(void) {}
nand_deselect(void)350*a430fa06SMiquel Raynal void nand_deselect(void) {}
351