]> git.sur5r.net Git - u-boot/blob - drivers/mtd/nand/davinci_nand.c
Merge branch 'master' of git://git.denx.de/u-boot-nand-flash
[u-boot] / drivers / mtd / nand / davinci_nand.c
1 /*
2  * NAND driver for TI DaVinci based boards.
3  *
4  * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
5  *
6  * Based on Linux DaVinci NAND driver by TI. Original copyright follows:
7  */
8
9 /*
10  *
11  * linux/drivers/mtd/nand/nand_davinci.c
12  *
13  * NAND Flash Driver
14  *
15  * Copyright (C) 2006 Texas Instruments.
16  *
17  * ----------------------------------------------------------------------------
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 2 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  *  You should have received a copy of the GNU General Public License
30  *  along with this program; if not, write to the Free Software
31  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32  * ----------------------------------------------------------------------------
33  *
34  *  Overview:
35  *   This is a device driver for the NAND flash device found on the
36  *   DaVinci board which utilizes the Samsung k9k2g08 part.
37  *
38  Modifications:
39  ver. 1.0: Feb 2005, Vinod/Sudhakar
40  -
41  *
42  */
43
44 #include <common.h>
45 #include <asm/io.h>
46 #include <nand.h>
47 #include <asm/arch/nand_defs.h>
48 #include <asm/arch/emif_defs.h>
49
50 /* Definitions for 4-bit hardware ECC */
51 #define NAND_TIMEOUT                    10240
52 #define NAND_ECC_BUSY                   0xC
53 #define NAND_4BITECC_MASK               0x03FF03FF
54 #define EMIF_NANDFSR_ECC_STATE_MASK     0x00000F00
55 #define ECC_STATE_NO_ERR                0x0
56 #define ECC_STATE_TOO_MANY_ERRS         0x1
57 #define ECC_STATE_ERR_CORR_COMP_P       0x2
58 #define ECC_STATE_ERR_CORR_COMP_N       0x3
59
60 static emif_registers *const emif_regs = (void *) DAVINCI_ASYNC_EMIF_CNTRL_BASE;
61
62 /*
63  * Exploit the little endianness of the ARM to do multi-byte transfers
64  * per device read. This can perform over twice as quickly as individual
65  * byte transfers when buffer alignment is conducive.
66  *
67  * NOTE: This only works if the NAND is not connected to the 2 LSBs of
68  * the address bus. On Davinci EVM platforms this has always been true.
69  */
70 static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
71 {
72         struct nand_chip *chip = mtd->priv;
73         const u32 *nand = chip->IO_ADDR_R;
74
75         /* Make sure that buf is 32 bit aligned */
76         if (((int)buf & 0x3) != 0) {
77                 if (((int)buf & 0x1) != 0) {
78                         if (len) {
79                                 *buf = readb(nand);
80                                 buf += 1;
81                                 len--;
82                         }
83                 }
84
85                 if (((int)buf & 0x3) != 0) {
86                         if (len >= 2) {
87                                 *(u16 *)buf = readw(nand);
88                                 buf += 2;
89                                 len -= 2;
90                         }
91                 }
92         }
93
94         /* copy aligned data */
95         while (len >= 4) {
96                 *(u32 *)buf = readl(nand);
97                 buf += 4;
98                 len -= 4;
99         }
100
101         /* mop up any remaining bytes */
102         if (len) {
103                 if (len >= 2) {
104                         *(u16 *)buf = readw(nand);
105                         buf += 2;
106                         len -= 2;
107                 }
108
109                 if (len)
110                         *buf = readb(nand);
111         }
112 }
113
114 static void nand_davinci_write_buf(struct mtd_info *mtd, const uint8_t *buf,
115                                    int len)
116 {
117         struct nand_chip *chip = mtd->priv;
118         const u32 *nand = chip->IO_ADDR_W;
119
120         /* Make sure that buf is 32 bit aligned */
121         if (((int)buf & 0x3) != 0) {
122                 if (((int)buf & 0x1) != 0) {
123                         if (len) {
124                                 writeb(*buf, nand);
125                                 buf += 1;
126                                 len--;
127                         }
128                 }
129
130                 if (((int)buf & 0x3) != 0) {
131                         if (len >= 2) {
132                                 writew(*(u16 *)buf, nand);
133                                 buf += 2;
134                                 len -= 2;
135                         }
136                 }
137         }
138
139         /* copy aligned data */
140         while (len >= 4) {
141                 writel(*(u32 *)buf, nand);
142                 buf += 4;
143                 len -= 4;
144         }
145
146         /* mop up any remaining bytes */
147         if (len) {
148                 if (len >= 2) {
149                         writew(*(u16 *)buf, nand);
150                         buf += 2;
151                         len -= 2;
152                 }
153
154                 if (len)
155                         writeb(*buf, nand);
156         }
157 }
158
159 static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
160 {
161         struct          nand_chip *this = mtd->priv;
162         u_int32_t       IO_ADDR_W = (u_int32_t)this->IO_ADDR_W;
163
164         if (ctrl & NAND_CTRL_CHANGE) {
165                 IO_ADDR_W &= ~(MASK_ALE|MASK_CLE);
166
167                 if ( ctrl & NAND_CLE )
168                         IO_ADDR_W |= MASK_CLE;
169                 if ( ctrl & NAND_ALE )
170                         IO_ADDR_W |= MASK_ALE;
171                 this->IO_ADDR_W = (void __iomem *) IO_ADDR_W;
172         }
173
174         if (cmd != NAND_CMD_NONE)
175                 writeb(cmd, IO_ADDR_W);
176 }
177
178 #ifdef CONFIG_SYS_NAND_HW_ECC
179
180 static void nand_davinci_enable_hwecc(struct mtd_info *mtd, int mode)
181 {
182         int             dummy;
183
184         dummy = emif_regs->NANDF1ECC;
185
186         /* FIXME:  only chipselect 0 is supported for now */
187         emif_regs->NANDFCR |= 1 << 8;
188 }
189
190 static u_int32_t nand_davinci_readecc(struct mtd_info *mtd, u_int32_t region)
191 {
192         u_int32_t       ecc = 0;
193
194         if (region == 1)
195                 ecc = emif_regs->NANDF1ECC;
196         else if (region == 2)
197                 ecc = emif_regs->NANDF2ECC;
198         else if (region == 3)
199                 ecc = emif_regs->NANDF3ECC;
200         else if (region == 4)
201                 ecc = emif_regs->NANDF4ECC;
202
203         return(ecc);
204 }
205
206 static int nand_davinci_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
207 {
208         u_int32_t               tmp;
209         const int region = 1;
210
211         tmp = nand_davinci_readecc(mtd, region);
212
213         /* Squeeze 4 bytes ECC into 3 bytes by removing RESERVED bits
214          * and shifting. RESERVED bits are 31 to 28 and 15 to 12. */
215         tmp = (tmp & 0x00000fff) | ((tmp & 0x0fff0000) >> 4);
216
217         /* Invert so that erased block ECC is correct */
218         tmp = ~tmp;
219
220         *ecc_code++ = tmp;
221         *ecc_code++ = tmp >>  8;
222         *ecc_code++ = tmp >> 16;
223
224         /* NOTE:  the above code matches mainline Linux:
225          *      .PQR.stu ==> ~PQRstu
226          *
227          * MontaVista/TI kernels encode those bytes differently, use
228          * complicated (and allegedly sometimes-wrong) correction code,
229          * and usually shipped with U-Boot that uses software ECC:
230          *      .PQR.stu ==> PsQRtu
231          *
232          * If you need MV/TI compatible NAND I/O in U-Boot, it should
233          * be possible to (a) change the mangling above, (b) reverse
234          * that mangling in nand_davinci_correct_data() below.
235          */
236
237         return 0;
238 }
239
240 static int nand_davinci_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
241 {
242         struct nand_chip *this = mtd->priv;
243         u_int32_t ecc_nand = read_ecc[0] | (read_ecc[1] << 8) |
244                                           (read_ecc[2] << 16);
245         u_int32_t ecc_calc = calc_ecc[0] | (calc_ecc[1] << 8) |
246                                           (calc_ecc[2] << 16);
247         u_int32_t diff = ecc_calc ^ ecc_nand;
248
249         if (diff) {
250                 if ((((diff >> 12) ^ diff) & 0xfff) == 0xfff) {
251                         /* Correctable error */
252                         if ((diff >> (12 + 3)) < this->ecc.size) {
253                                 uint8_t find_bit = 1 << ((diff >> 12) & 7);
254                                 uint32_t find_byte = diff >> (12 + 3);
255
256                                 dat[find_byte] ^= find_bit;
257                                 MTDDEBUG(MTD_DEBUG_LEVEL0, "Correcting single "
258                                          "bit ECC error at offset: %d, bit: "
259                                          "%d\n", find_byte, find_bit);
260                                 return 1;
261                         } else {
262                                 return -1;
263                         }
264                 } else if (!(diff & (diff - 1))) {
265                         /* Single bit ECC error in the ECC itself,
266                            nothing to fix */
267                         MTDDEBUG(MTD_DEBUG_LEVEL0, "Single bit ECC error in "
268                                  "ECC.\n");
269                         return 1;
270                 } else {
271                         /* Uncorrectable error */
272                         MTDDEBUG(MTD_DEBUG_LEVEL0, "ECC UNCORRECTED_ERROR 1\n");
273                         return -1;
274                 }
275         }
276         return(0);
277 }
278 #endif /* CONFIG_SYS_NAND_HW_ECC */
279
280 #ifdef CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST
281 static struct nand_ecclayout nand_davinci_4bit_layout_oobfirst = {
282 #if defined(CONFIG_SYS_NAND_PAGE_2K)
283         .eccbytes = 40,
284         .eccpos = {
285                 24, 25, 26, 27, 28,
286                 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
287                 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
288                 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
289                 59, 60, 61, 62, 63,
290                 },
291         .oobfree = {
292                 {.offset = 2, .length = 22, },
293         },
294 #elif defined(CONFIG_SYS_NAND_PAGE_4K)
295         .eccbytes = 80,
296         .eccpos = {
297                 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
298                 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
299                 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
300                 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
301                 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
302                 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
303                 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
304                 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
305                 },
306         .oobfree = {
307                 {.offset = 2, .length = 46, },
308         },
309 #endif
310 };
311
312 static void nand_davinci_4bit_enable_hwecc(struct mtd_info *mtd, int mode)
313 {
314         u32 val;
315
316         switch (mode) {
317         case NAND_ECC_WRITE:
318         case NAND_ECC_READ:
319                 /*
320                  * Start a new ECC calculation for reading or writing 512 bytes
321                  * of data.
322                  */
323                 val = (emif_regs->NANDFCR & ~(3 << 4)) | (1 << 12);
324                 emif_regs->NANDFCR = val;
325                 break;
326         case NAND_ECC_READSYN:
327                 val = emif_regs->NAND4BITECC1;
328                 break;
329         default:
330                 break;
331         }
332 }
333
334 static u32 nand_davinci_4bit_readecc(struct mtd_info *mtd, unsigned int ecc[4])
335 {
336         ecc[0] = emif_regs->NAND4BITECC1 & NAND_4BITECC_MASK;
337         ecc[1] = emif_regs->NAND4BITECC2 & NAND_4BITECC_MASK;
338         ecc[2] = emif_regs->NAND4BITECC3 & NAND_4BITECC_MASK;
339         ecc[3] = emif_regs->NAND4BITECC4 & NAND_4BITECC_MASK;
340
341         return 0;
342 }
343
344 static int nand_davinci_4bit_calculate_ecc(struct mtd_info *mtd,
345                                            const uint8_t *dat,
346                                            uint8_t *ecc_code)
347 {
348         unsigned int hw_4ecc[4];
349         unsigned int i;
350
351         nand_davinci_4bit_readecc(mtd, hw_4ecc);
352
353         /*Convert 10 bit ecc value to 8 bit */
354         for (i = 0; i < 2; i++) {
355                 unsigned int hw_ecc_low = hw_4ecc[i * 2];
356                 unsigned int hw_ecc_hi = hw_4ecc[(i * 2) + 1];
357
358                 /* Take first 8 bits from val1 (count1=0) or val5 (count1=1) */
359                 *ecc_code++ = hw_ecc_low & 0xFF;
360
361                 /*
362                  * Take 2 bits as LSB bits from val1 (count1=0) or val5
363                  * (count1=1) and 6 bits from val2 (count1=0) or
364                  * val5 (count1=1)
365                  */
366                 *ecc_code++ =
367                     ((hw_ecc_low >> 8) & 0x3) | ((hw_ecc_low >> 14) & 0xFC);
368
369                 /*
370                  * Take 4 bits from val2 (count1=0) or val5 (count1=1) and
371                  * 4 bits from val3 (count1=0) or val6 (count1=1)
372                  */
373                 *ecc_code++ =
374                     ((hw_ecc_low >> 22) & 0xF) | ((hw_ecc_hi << 4) & 0xF0);
375
376                 /*
377                  * Take 6 bits from val3(count1=0) or val6 (count1=1) and
378                  * 2 bits from val4 (count1=0) or  val7 (count1=1)
379                  */
380                 *ecc_code++ =
381                     ((hw_ecc_hi >> 4) & 0x3F) | ((hw_ecc_hi >> 10) & 0xC0);
382
383                 /* Take 8 bits from val4 (count1=0) or val7 (count1=1) */
384                 *ecc_code++ = (hw_ecc_hi >> 18) & 0xFF;
385         }
386
387         return 0;
388 }
389
390 static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat,
391                                           uint8_t *read_ecc, uint8_t *calc_ecc)
392 {
393         int i;
394         unsigned int hw_4ecc[4];
395         unsigned int iserror;
396         unsigned short *ecc16;
397         unsigned int numerrors, erroraddress, errorvalue;
398         u32 val;
399
400         /*
401          * Check for an ECC where all bytes are 0xFF.  If this is the case, we
402          * will assume we are looking at an erased page and we should ignore
403          * the ECC.
404          */
405         for (i = 0; i < 10; i++) {
406                 if (read_ecc[i] != 0xFF)
407                         break;
408         }
409         if (i == 10)
410                 return 0;
411
412         /* Convert 8 bit in to 10 bit */
413         ecc16 = (unsigned short *)&read_ecc[0];
414
415         /*
416          * Write the parity values in the NAND Flash 4-bit ECC Load register.
417          * Write each parity value one at a time starting from 4bit_ecc_val8
418          * to 4bit_ecc_val1.
419          */
420
421         /*Take 2 bits from 8th byte and 8 bits from 9th byte */
422         writel(((ecc16[4]) >> 6) & 0x3FF, &emif_regs->NAND4BITECCLOAD);
423
424         /* Take 4 bits from 7th byte and 6 bits from 8th byte */
425         writel((((ecc16[3]) >> 12) & 0xF) | ((((ecc16[4])) << 4) & 0x3F0),
426                &emif_regs->NAND4BITECCLOAD);
427
428         /* Take 6 bits from 6th byte and 4 bits from 7th byte */
429         writel((ecc16[3] >> 2) & 0x3FF, &emif_regs->NAND4BITECCLOAD);
430
431         /* Take 8 bits from 5th byte and 2 bits from 6th byte */
432         writel(((ecc16[2]) >> 8) | ((((ecc16[3])) << 8) & 0x300),
433                &emif_regs->NAND4BITECCLOAD);
434
435         /*Take 2 bits from 3rd byte and 8 bits from 4th byte */
436         writel((((ecc16[1]) >> 14) & 0x3) | ((((ecc16[2])) << 2) & 0x3FC),
437                &emif_regs->NAND4BITECCLOAD);
438
439         /* Take 4 bits form 2nd bytes and 6 bits from 3rd bytes */
440         writel(((ecc16[1]) >> 4) & 0x3FF, &emif_regs->NAND4BITECCLOAD);
441
442         /* Take 6 bits from 1st byte and 4 bits from 2nd byte */
443         writel((((ecc16[0]) >> 10) & 0x3F) | (((ecc16[1]) << 6) & 0x3C0),
444                &emif_regs->NAND4BITECCLOAD);
445
446         /* Take 10 bits from 0th and 1st bytes */
447         writel((ecc16[0]) & 0x3FF, &emif_regs->NAND4BITECCLOAD);
448
449         /*
450          * Perform a dummy read to the EMIF Revision Code and Status register.
451          * This is required to ensure time for syndrome calculation after
452          * writing the ECC values in previous step.
453          */
454
455         val = emif_regs->NANDFSR;
456
457         /*
458          * Read the syndrome from the NAND Flash 4-Bit ECC 1-4 registers.
459          * A syndrome value of 0 means no bit errors. If the syndrome is
460          * non-zero then go further otherwise return.
461          */
462         nand_davinci_4bit_readecc(mtd, hw_4ecc);
463
464         if (!(hw_4ecc[0] | hw_4ecc[1] | hw_4ecc[2] | hw_4ecc[3]))
465                 return 0;
466
467         /*
468          * Clear any previous address calculation by doing a dummy read of an
469          * error address register.
470          */
471         val = emif_regs->NANDERRADD1;
472
473         /*
474          * Set the addr_calc_st bit(bit no 13) in the NAND Flash Control
475          * register to 1.
476          */
477         emif_regs->NANDFCR |= 1 << 13;
478
479         /*
480          * Wait for the corr_state field (bits 8 to 11)in the
481          * NAND Flash Status register to be equal to 0x0, 0x1, 0x2, or 0x3.
482          */
483         i = NAND_TIMEOUT;
484         do {
485                 val = emif_regs->NANDFSR;
486                 val &= 0xc00;
487                 i--;
488         } while ((i > 0) && val);
489
490         iserror = emif_regs->NANDFSR;
491         iserror &= EMIF_NANDFSR_ECC_STATE_MASK;
492         iserror = iserror >> 8;
493
494         /*
495          * ECC_STATE_TOO_MANY_ERRS (0x1) means errors cannot be
496          * corrected (five or more errors).  The number of errors
497          * calculated (err_num field) differs from the number of errors
498          * searched.  ECC_STATE_ERR_CORR_COMP_P (0x2) means error
499          * correction complete (errors on bit 8 or 9).
500          * ECC_STATE_ERR_CORR_COMP_N (0x3) means error correction
501          * complete (error exists).
502          */
503
504         if (iserror == ECC_STATE_NO_ERR) {
505                 val = emif_regs->NANDERRVAL1;
506                 return 0;
507         } else if (iserror == ECC_STATE_TOO_MANY_ERRS) {
508                 val = emif_regs->NANDERRVAL1;
509                 return -1;
510         }
511
512         numerrors = ((emif_regs->NANDFSR >> 16) & 0x3) + 1;
513
514         /* Read the error address, error value and correct */
515         for (i = 0; i < numerrors; i++) {
516                 if (i > 1) {
517                         erroraddress =
518                             ((emif_regs->NANDERRADD2 >>
519                               (16 * (i & 1))) & 0x3FF);
520                         erroraddress = ((512 + 7) - erroraddress);
521                         errorvalue =
522                             ((emif_regs->NANDERRVAL2 >>
523                               (16 * (i & 1))) & 0xFF);
524                 } else {
525                         erroraddress =
526                             ((emif_regs->NANDERRADD1 >>
527                               (16 * (i & 1))) & 0x3FF);
528                         erroraddress = ((512 + 7) - erroraddress);
529                         errorvalue =
530                             ((emif_regs->NANDERRVAL1 >>
531                               (16 * (i & 1))) & 0xFF);
532                 }
533                 /* xor the corrupt data with error value */
534                 if (erroraddress < 512)
535                         dat[erroraddress] ^= errorvalue;
536         }
537
538         return numerrors;
539 }
540 #endif /* CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST */
541
542 static int nand_davinci_dev_ready(struct mtd_info *mtd)
543 {
544         return emif_regs->NANDFSR & 0x1;
545 }
546
547 static void nand_flash_init(void)
548 {
549         /* This is for DM6446 EVM and *very* similar.  DO NOT GROW THIS!
550          * Instead, have your board_init() set EMIF timings, based on its
551          * knowledge of the clocks and what devices are hooked up ... and
552          * don't even do that unless no UBL handled it.
553          */
554 #ifdef CONFIG_SOC_DM644X
555         u_int32_t       acfg1 = 0x3ffffffc;
556
557         /*------------------------------------------------------------------*
558          *  NAND FLASH CHIP TIMEOUT @ 459 MHz                               *
559          *                                                                  *
560          *  AEMIF.CLK freq   = PLL1/6 = 459/6 = 76.5 MHz                    *
561          *  AEMIF.CLK period = 1/76.5 MHz = 13.1 ns                         *
562          *                                                                  *
563          *------------------------------------------------------------------*/
564          acfg1 = 0
565                 | (0 << 31 )    /* selectStrobe */
566                 | (0 << 30 )    /* extWait */
567                 | (1 << 26 )    /* writeSetup   10 ns */
568                 | (3 << 20 )    /* writeStrobe  40 ns */
569                 | (1 << 17 )    /* writeHold    10 ns */
570                 | (1 << 13 )    /* readSetup    10 ns */
571                 | (5 << 7 )     /* readStrobe   60 ns */
572                 | (1 << 4 )     /* readHold     10 ns */
573                 | (3 << 2 )     /* turnAround   ?? ns */
574                 | (0 << 0 )     /* asyncSize    8-bit bus */
575                 ;
576
577         emif_regs->AB1CR = acfg1; /* CS2 */
578
579         emif_regs->NANDFCR = 0x00000101; /* NAND flash on CS2 */
580 #endif
581 }
582
583 void davinci_nand_init(struct nand_chip *nand)
584 {
585         nand->chip_delay  = 0;
586 #ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
587         nand->options     |= NAND_USE_FLASH_BBT;
588 #endif
589 #ifdef CONFIG_SYS_NAND_HW_ECC
590         nand->ecc.mode = NAND_ECC_HW;
591         nand->ecc.size = 512;
592         nand->ecc.bytes = 3;
593         nand->ecc.calculate = nand_davinci_calculate_ecc;
594         nand->ecc.correct  = nand_davinci_correct_data;
595         nand->ecc.hwctl  = nand_davinci_enable_hwecc;
596 #else
597         nand->ecc.mode = NAND_ECC_SOFT;
598 #endif /* CONFIG_SYS_NAND_HW_ECC */
599 #ifdef CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST
600         nand->ecc.mode = NAND_ECC_HW_OOB_FIRST;
601         nand->ecc.size = 512;
602         nand->ecc.bytes = 10;
603         nand->ecc.calculate = nand_davinci_4bit_calculate_ecc;
604         nand->ecc.correct = nand_davinci_4bit_correct_data;
605         nand->ecc.hwctl = nand_davinci_4bit_enable_hwecc;
606         nand->ecc.layout = &nand_davinci_4bit_layout_oobfirst;
607 #endif
608         /* Set address of hardware control function */
609         nand->cmd_ctrl = nand_davinci_hwcontrol;
610
611         nand->read_buf = nand_davinci_read_buf;
612         nand->write_buf = nand_davinci_write_buf;
613
614         nand->dev_ready = nand_davinci_dev_ready;
615
616         nand_flash_init();
617 }
618
619 int board_nand_init(struct nand_chip *chip) __attribute__((weak));
620
621 int board_nand_init(struct nand_chip *chip)
622 {
623         davinci_nand_init(chip);
624         return 0;
625 }