nand.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /*
  2. * (C) Copyright 2006 DENX Software Engineering
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #if defined(CONFIG_CMD_NAND)
  24. #if !defined(CFG_NAND_LEGACY)
  25. #include <nand.h>
  26. #include <asm/arch/pxa-regs.h>
  27. #ifdef CFG_DFC_DEBUG1
  28. # define DFC_DEBUG1(fmt, args...) printf(fmt, ##args)
  29. #else
  30. # define DFC_DEBUG1(fmt, args...)
  31. #endif
  32. #ifdef CFG_DFC_DEBUG2
  33. # define DFC_DEBUG2(fmt, args...) printf(fmt, ##args)
  34. #else
  35. # define DFC_DEBUG2(fmt, args...)
  36. #endif
  37. #ifdef CFG_DFC_DEBUG3
  38. # define DFC_DEBUG3(fmt, args...) printf(fmt, ##args)
  39. #else
  40. # define DFC_DEBUG3(fmt, args...)
  41. #endif
  42. #define MIN(x, y) ((x < y) ? x : y)
  43. /* These really don't belong here, as they are specific to the NAND Model */
  44. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  45. static struct nand_bbt_descr delta_bbt_descr = {
  46. .options = 0,
  47. .offs = 0,
  48. .len = 2,
  49. .pattern = scan_ff_pattern
  50. };
  51. static struct nand_oobinfo delta_oob = {
  52. .useecc = MTD_NANDECC_AUTOPL_USR, /* MTD_NANDECC_PLACEONLY, */
  53. .eccbytes = 6,
  54. .eccpos = {2, 3, 4, 5, 6, 7},
  55. .oobfree = { {8, 2}, {12, 4} }
  56. };
  57. /*
  58. * not required for Monahans DFC
  59. */
  60. static void dfc_hwcontrol(struct mtd_info *mtdinfo, int cmd)
  61. {
  62. return;
  63. }
  64. #if 0
  65. /* read device ready pin */
  66. static int dfc_device_ready(struct mtd_info *mtdinfo)
  67. {
  68. if(NDSR & NDSR_RDY)
  69. return 1;
  70. else
  71. return 0;
  72. return 0;
  73. }
  74. #endif
  75. /*
  76. * Write buf to the DFC Controller Data Buffer
  77. */
  78. static void dfc_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
  79. {
  80. unsigned long bytes_multi = len & 0xfffffffc;
  81. unsigned long rest = len & 0x3;
  82. unsigned long *long_buf;
  83. int i;
  84. DFC_DEBUG2("dfc_write_buf: writing %d bytes starting with 0x%x.\n", len, *((unsigned long*) buf));
  85. if(bytes_multi) {
  86. for(i=0; i<bytes_multi; i+=4) {
  87. long_buf = (unsigned long*) &buf[i];
  88. NDDB = *long_buf;
  89. }
  90. }
  91. if(rest) {
  92. printf("dfc_write_buf: ERROR, writing non 4-byte aligned data.\n");
  93. }
  94. return;
  95. }
  96. /*
  97. * These functions are quite problematic for the DFC. Luckily they are
  98. * not used in the current nand code, except for nand_command, which
  99. * we've defined our own anyway. The problem is, that we always need
  100. * to write 4 bytes to the DFC Data Buffer, but in these functions we
  101. * don't know if to buffer the bytes/half words until we've gathered 4
  102. * bytes or if to send them straight away.
  103. *
  104. * Solution: Don't use these with Mona's DFC and complain loudly.
  105. */
  106. static void dfc_write_word(struct mtd_info *mtd, u16 word)
  107. {
  108. printf("dfc_write_word: WARNING, this function does not work with the Monahans DFC!\n");
  109. }
  110. static void dfc_write_byte(struct mtd_info *mtd, u_char byte)
  111. {
  112. printf("dfc_write_byte: WARNING, this function does not work with the Monahans DFC!\n");
  113. }
  114. /* The original:
  115. * static void dfc_read_buf(struct mtd_info *mtd, const u_char *buf, int len)
  116. *
  117. * Shouldn't this be "u_char * const buf" ?
  118. */
  119. static void dfc_read_buf(struct mtd_info *mtd, u_char* const buf, int len)
  120. {
  121. int i=0, j;
  122. /* we have to be carefull not to overflow the buffer if len is
  123. * not a multiple of 4 */
  124. unsigned long bytes_multi = len & 0xfffffffc;
  125. unsigned long rest = len & 0x3;
  126. unsigned long *long_buf;
  127. DFC_DEBUG3("dfc_read_buf: reading %d bytes.\n", len);
  128. /* if there are any, first copy multiple of 4 bytes */
  129. if(bytes_multi) {
  130. for(i=0; i<bytes_multi; i+=4) {
  131. long_buf = (unsigned long*) &buf[i];
  132. *long_buf = NDDB;
  133. }
  134. }
  135. /* ...then the rest */
  136. if(rest) {
  137. unsigned long rest_data = NDDB;
  138. for(j=0;j<rest; j++)
  139. buf[i+j] = (u_char) ((rest_data>>j) & 0xff);
  140. }
  141. return;
  142. }
  143. /*
  144. * read a word. Not implemented as not used in NAND code.
  145. */
  146. static u16 dfc_read_word(struct mtd_info *mtd)
  147. {
  148. printf("dfc_write_byte: UNIMPLEMENTED.\n");
  149. return 0;
  150. }
  151. /* global var, too bad: mk@tbd: move to ->priv pointer */
  152. static unsigned long read_buf = 0;
  153. static int bytes_read = -1;
  154. /*
  155. * read a byte from NDDB Because we can only read 4 bytes from NDDB at
  156. * a time, we buffer the remaining bytes. The buffer is reset when a
  157. * new command is sent to the chip.
  158. *
  159. * WARNING:
  160. * This function is currently only used to read status and id
  161. * bytes. For these commands always 8 bytes need to be read from
  162. * NDDB. So we read and discard these bytes right now. In case this
  163. * function is used for anything else in the future, we must check
  164. * what was the last command issued and read the appropriate amount of
  165. * bytes respectively.
  166. */
  167. static u_char dfc_read_byte(struct mtd_info *mtd)
  168. {
  169. unsigned char byte;
  170. unsigned long dummy;
  171. if(bytes_read < 0) {
  172. read_buf = NDDB;
  173. dummy = NDDB;
  174. bytes_read = 0;
  175. }
  176. byte = (unsigned char) (read_buf>>(8 * bytes_read++));
  177. if(bytes_read >= 4)
  178. bytes_read = -1;
  179. DFC_DEBUG2("dfc_read_byte: byte %u: 0x%x of (0x%x).\n", bytes_read - 1, byte, read_buf);
  180. return byte;
  181. }
  182. /* calculate delta between OSCR values start and now */
  183. static unsigned long get_delta(unsigned long start)
  184. {
  185. unsigned long cur = OSCR;
  186. if(cur < start) /* OSCR overflowed */
  187. return (cur + (start^0xffffffff));
  188. else
  189. return (cur - start);
  190. }
  191. /* delay function, this doesn't belong here */
  192. static void wait_us(unsigned long us)
  193. {
  194. unsigned long start = OSCR;
  195. us *= OSCR_CLK_FREQ;
  196. while (get_delta(start) < us) {
  197. /* do nothing */
  198. }
  199. }
  200. static void dfc_clear_nddb(void)
  201. {
  202. NDCR &= ~NDCR_ND_RUN;
  203. wait_us(CFG_NAND_OTHER_TO);
  204. }
  205. /* wait_event with timeout */
  206. static unsigned long dfc_wait_event(unsigned long event)
  207. {
  208. unsigned long ndsr, timeout, start = OSCR;
  209. if(!event)
  210. return 0xff000000;
  211. else if(event & (NDSR_CS0_CMDD | NDSR_CS0_BBD))
  212. timeout = CFG_NAND_PROG_ERASE_TO * OSCR_CLK_FREQ;
  213. else
  214. timeout = CFG_NAND_OTHER_TO * OSCR_CLK_FREQ;
  215. while(1) {
  216. ndsr = NDSR;
  217. if(ndsr & event) {
  218. NDSR |= event;
  219. break;
  220. }
  221. if(get_delta(start) > timeout) {
  222. DFC_DEBUG1("dfc_wait_event: TIMEOUT waiting for event: 0x%x.\n", event);
  223. return 0xff000000;
  224. }
  225. }
  226. return ndsr;
  227. }
  228. /* we don't always wan't to do this */
  229. static void dfc_new_cmd(void)
  230. {
  231. int retry = 0;
  232. unsigned long status;
  233. while(retry++ <= CFG_NAND_SENDCMD_RETRY) {
  234. /* Clear NDSR */
  235. NDSR = 0xFFF;
  236. /* set NDCR[NDRUN] */
  237. if(!(NDCR & NDCR_ND_RUN))
  238. NDCR |= NDCR_ND_RUN;
  239. status = dfc_wait_event(NDSR_WRCMDREQ);
  240. if(status & NDSR_WRCMDREQ)
  241. return;
  242. DFC_DEBUG2("dfc_new_cmd: FAILED to get WRITECMDREQ, retry: %d.\n", retry);
  243. dfc_clear_nddb();
  244. }
  245. DFC_DEBUG1("dfc_new_cmd: giving up after %d retries.\n", retry);
  246. }
  247. /* this function is called after Programm and Erase Operations to
  248. * check for success or failure */
  249. static int dfc_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
  250. {
  251. unsigned long ndsr=0, event=0;
  252. if(state == FL_WRITING) {
  253. event = NDSR_CS0_CMDD | NDSR_CS0_BBD;
  254. } else if(state == FL_ERASING) {
  255. event = NDSR_CS0_CMDD | NDSR_CS0_BBD;
  256. }
  257. ndsr = dfc_wait_event(event);
  258. if((ndsr & NDSR_CS0_BBD) || (ndsr & 0xff000000))
  259. return(0x1); /* Status Read error */
  260. return 0;
  261. }
  262. /* cmdfunc send commands to the DFC */
  263. static void dfc_cmdfunc(struct mtd_info *mtd, unsigned command,
  264. int column, int page_addr)
  265. {
  266. /* register struct nand_chip *this = mtd->priv; */
  267. unsigned long ndcb0=0, ndcb1=0, ndcb2=0, event=0;
  268. /* clear the ugly byte read buffer */
  269. bytes_read = -1;
  270. read_buf = 0;
  271. switch (command) {
  272. case NAND_CMD_READ0:
  273. DFC_DEBUG3("dfc_cmdfunc: NAND_CMD_READ0, page_addr: 0x%x, column: 0x%x.\n", page_addr, (column>>1));
  274. dfc_new_cmd();
  275. ndcb0 = (NAND_CMD_READ0 | (4<<16));
  276. column >>= 1; /* adjust for 16 bit bus */
  277. ndcb1 = (((column>>1) & 0xff) |
  278. ((page_addr<<8) & 0xff00) |
  279. ((page_addr<<8) & 0xff0000) |
  280. ((page_addr<<8) & 0xff000000)); /* make this 0x01000000 ? */
  281. event = NDSR_RDDREQ;
  282. goto write_cmd;
  283. case NAND_CMD_READ1:
  284. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_READ1 unimplemented!\n");
  285. goto end;
  286. case NAND_CMD_READOOB:
  287. DFC_DEBUG1("dfc_cmdfunc: NAND_CMD_READOOB unimplemented!\n");
  288. goto end;
  289. case NAND_CMD_READID:
  290. dfc_new_cmd();
  291. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_READID.\n");
  292. ndcb0 = (NAND_CMD_READID | (3 << 21) | (1 << 16)); /* addr cycles*/
  293. event = NDSR_RDDREQ;
  294. goto write_cmd;
  295. case NAND_CMD_PAGEPROG:
  296. /* sent as a multicommand in NAND_CMD_SEQIN */
  297. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_PAGEPROG empty due to multicmd.\n");
  298. goto end;
  299. case NAND_CMD_ERASE1:
  300. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_ERASE1, page_addr: 0x%x, column: 0x%x.\n", page_addr, (column>>1));
  301. dfc_new_cmd();
  302. ndcb0 = (0xd060 | (1<<25) | (2<<21) | (1<<19) | (3<<16));
  303. ndcb1 = (page_addr & 0x00ffffff);
  304. goto write_cmd;
  305. case NAND_CMD_ERASE2:
  306. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_ERASE2 empty due to multicmd.\n");
  307. goto end;
  308. case NAND_CMD_SEQIN:
  309. /* send PAGE_PROG command(0x1080) */
  310. dfc_new_cmd();
  311. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_SEQIN/PAGE_PROG, page_addr: 0x%x, column: 0x%x.\n", page_addr, (column>>1));
  312. ndcb0 = (0x1080 | (1<<25) | (1<<21) | (1<<19) | (4<<16));
  313. column >>= 1; /* adjust for 16 bit bus */
  314. ndcb1 = (((column>>1) & 0xff) |
  315. ((page_addr<<8) & 0xff00) |
  316. ((page_addr<<8) & 0xff0000) |
  317. ((page_addr<<8) & 0xff000000)); /* make this 0x01000000 ? */
  318. event = NDSR_WRDREQ;
  319. goto write_cmd;
  320. case NAND_CMD_STATUS:
  321. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_STATUS.\n");
  322. dfc_new_cmd();
  323. ndcb0 = NAND_CMD_STATUS | (4<<21);
  324. event = NDSR_RDDREQ;
  325. goto write_cmd;
  326. case NAND_CMD_RESET:
  327. DFC_DEBUG2("dfc_cmdfunc: NAND_CMD_RESET.\n");
  328. ndcb0 = NAND_CMD_RESET | (5<<21);
  329. event = NDSR_CS0_CMDD;
  330. goto write_cmd;
  331. default:
  332. printk("dfc_cmdfunc: error, unsupported command.\n");
  333. goto end;
  334. }
  335. write_cmd:
  336. NDCB0 = ndcb0;
  337. NDCB0 = ndcb1;
  338. NDCB0 = ndcb2;
  339. /* wait_event: */
  340. dfc_wait_event(event);
  341. end:
  342. return;
  343. }
  344. static void dfc_gpio_init(void)
  345. {
  346. DFC_DEBUG2("Setting up DFC GPIO's.\n");
  347. /* no idea what is done here, see zylonite.c */
  348. GPIO4 = 0x1;
  349. DF_ALE_WE1 = 0x00000001;
  350. DF_ALE_WE2 = 0x00000001;
  351. DF_nCS0 = 0x00000001;
  352. DF_nCS1 = 0x00000001;
  353. DF_nWE = 0x00000001;
  354. DF_nRE = 0x00000001;
  355. DF_IO0 = 0x00000001;
  356. DF_IO8 = 0x00000001;
  357. DF_IO1 = 0x00000001;
  358. DF_IO9 = 0x00000001;
  359. DF_IO2 = 0x00000001;
  360. DF_IO10 = 0x00000001;
  361. DF_IO3 = 0x00000001;
  362. DF_IO11 = 0x00000001;
  363. DF_IO4 = 0x00000001;
  364. DF_IO12 = 0x00000001;
  365. DF_IO5 = 0x00000001;
  366. DF_IO13 = 0x00000001;
  367. DF_IO6 = 0x00000001;
  368. DF_IO14 = 0x00000001;
  369. DF_IO7 = 0x00000001;
  370. DF_IO15 = 0x00000001;
  371. DF_nWE = 0x1901;
  372. DF_nRE = 0x1901;
  373. DF_CLE_NOE = 0x1900;
  374. DF_ALE_WE1 = 0x1901;
  375. DF_INT_RnB = 0x1900;
  376. }
  377. /*
  378. * Board-specific NAND initialization. The following members of the
  379. * argument are board-specific (per include/linux/mtd/nand_new.h):
  380. * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
  381. * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
  382. * - hwcontrol: hardwarespecific function for accesing control-lines
  383. * - dev_ready: hardwarespecific function for accesing device ready/busy line
  384. * - enable_hwecc?: function to enable (reset) hardware ecc generator. Must
  385. * only be provided if a hardware ECC is available
  386. * - eccmode: mode of ecc, see defines
  387. * - chip_delay: chip dependent delay for transfering data from array to
  388. * read regs (tR)
  389. * - options: various chip options. They can partly be set to inform
  390. * nand_scan about special functionality. See the defines for further
  391. * explanation
  392. * Members with a "?" were not set in the merged testing-NAND branch,
  393. * so they are not set here either.
  394. */
  395. int board_nand_init(struct nand_chip *nand)
  396. {
  397. unsigned long tCH, tCS, tWH, tWP, tRH, tRP, tRP_high, tR, tWHR, tAR;
  398. /* set up GPIO Control Registers */
  399. dfc_gpio_init();
  400. /* turn on the NAND Controller Clock (104 MHz @ D0) */
  401. CKENA |= (CKENA_4_NAND | CKENA_9_SMC);
  402. #undef CFG_TIMING_TIGHT
  403. #ifndef CFG_TIMING_TIGHT
  404. tCH = MIN(((unsigned long) (NAND_TIMING_tCH * DFC_CLK_PER_US) + 1),
  405. DFC_MAX_tCH);
  406. tCS = MIN(((unsigned long) (NAND_TIMING_tCS * DFC_CLK_PER_US) + 1),
  407. DFC_MAX_tCS);
  408. tWH = MIN(((unsigned long) (NAND_TIMING_tWH * DFC_CLK_PER_US) + 1),
  409. DFC_MAX_tWH);
  410. tWP = MIN(((unsigned long) (NAND_TIMING_tWP * DFC_CLK_PER_US) + 1),
  411. DFC_MAX_tWP);
  412. tRH = MIN(((unsigned long) (NAND_TIMING_tRH * DFC_CLK_PER_US) + 1),
  413. DFC_MAX_tRH);
  414. tRP = MIN(((unsigned long) (NAND_TIMING_tRP * DFC_CLK_PER_US) + 1),
  415. DFC_MAX_tRP);
  416. tR = MIN(((unsigned long) (NAND_TIMING_tR * DFC_CLK_PER_US) + 1),
  417. DFC_MAX_tR);
  418. tWHR = MIN(((unsigned long) (NAND_TIMING_tWHR * DFC_CLK_PER_US) + 1),
  419. DFC_MAX_tWHR);
  420. tAR = MIN(((unsigned long) (NAND_TIMING_tAR * DFC_CLK_PER_US) + 1),
  421. DFC_MAX_tAR);
  422. #else /* this is the tight timing */
  423. tCH = MIN(((unsigned long) (NAND_TIMING_tCH * DFC_CLK_PER_US)),
  424. DFC_MAX_tCH);
  425. tCS = MIN(((unsigned long) (NAND_TIMING_tCS * DFC_CLK_PER_US)),
  426. DFC_MAX_tCS);
  427. tWH = MIN(((unsigned long) (NAND_TIMING_tWH * DFC_CLK_PER_US)),
  428. DFC_MAX_tWH);
  429. tWP = MIN(((unsigned long) (NAND_TIMING_tWP * DFC_CLK_PER_US)),
  430. DFC_MAX_tWP);
  431. tRH = MIN(((unsigned long) (NAND_TIMING_tRH * DFC_CLK_PER_US)),
  432. DFC_MAX_tRH);
  433. tRP = MIN(((unsigned long) (NAND_TIMING_tRP * DFC_CLK_PER_US)),
  434. DFC_MAX_tRP);
  435. tR = MIN(((unsigned long) (NAND_TIMING_tR * DFC_CLK_PER_US) - tCH - 2),
  436. DFC_MAX_tR);
  437. tWHR = MIN(((unsigned long) (NAND_TIMING_tWHR * DFC_CLK_PER_US) - tCH - 2),
  438. DFC_MAX_tWHR);
  439. tAR = MIN(((unsigned long) (NAND_TIMING_tAR * DFC_CLK_PER_US) - 2),
  440. DFC_MAX_tAR);
  441. #endif /* CFG_TIMING_TIGHT */
  442. DFC_DEBUG2("tCH=%u, tCS=%u, tWH=%u, tWP=%u, tRH=%u, tRP=%u, tR=%u, tWHR=%u, tAR=%u.\n", tCH, tCS, tWH, tWP, tRH, tRP, tR, tWHR, tAR);
  443. /* tRP value is split in the register */
  444. if(tRP & (1 << 4)) {
  445. tRP_high = 1;
  446. tRP &= ~(1 << 4);
  447. } else {
  448. tRP_high = 0;
  449. }
  450. NDTR0CS0 = (tCH << 19) |
  451. (tCS << 16) |
  452. (tWH << 11) |
  453. (tWP << 8) |
  454. (tRP_high << 6) |
  455. (tRH << 3) |
  456. (tRP << 0);
  457. NDTR1CS0 = (tR << 16) |
  458. (tWHR << 4) |
  459. (tAR << 0);
  460. /* If it doesn't work (unlikely) think about:
  461. * - ecc enable
  462. * - chip select don't care
  463. * - read id byte count
  464. *
  465. * Intentionally enabled by not setting bits:
  466. * - dma (DMA_EN)
  467. * - page size = 512
  468. * - cs don't care, see if we can enable later!
  469. * - row address start position (after second cycle)
  470. * - pages per block = 32
  471. * - ND_RDY : clears command buffer
  472. */
  473. /* NDCR_NCSX | /\* Chip select busy don't care *\/ */
  474. NDCR = (NDCR_SPARE_EN | /* use the spare area */
  475. NDCR_DWIDTH_C | /* 16bit DFC data bus width */
  476. NDCR_DWIDTH_M | /* 16 bit Flash device data bus width */
  477. (2 << 16) | /* read id count = 7 ???? mk@tbd */
  478. NDCR_ND_ARB_EN | /* enable bus arbiter */
  479. NDCR_RDYM | /* flash device ready ir masked */
  480. NDCR_CS0_PAGEDM | /* ND_nCSx page done ir masked */
  481. NDCR_CS1_PAGEDM |
  482. NDCR_CS0_CMDDM | /* ND_CSx command done ir masked */
  483. NDCR_CS1_CMDDM |
  484. NDCR_CS0_BBDM | /* ND_CSx bad block detect ir masked */
  485. NDCR_CS1_BBDM |
  486. NDCR_DBERRM | /* double bit error ir masked */
  487. NDCR_SBERRM | /* single bit error ir masked */
  488. NDCR_WRDREQM | /* write data request ir masked */
  489. NDCR_RDDREQM | /* read data request ir masked */
  490. NDCR_WRCMDREQM); /* write command request ir masked */
  491. /* wait 10 us due to cmd buffer clear reset */
  492. /* wait(10); */
  493. nand->hwcontrol = dfc_hwcontrol;
  494. /* nand->dev_ready = dfc_device_ready; */
  495. nand->eccmode = NAND_ECC_SOFT;
  496. nand->options = NAND_BUSWIDTH_16;
  497. nand->waitfunc = dfc_wait;
  498. nand->read_byte = dfc_read_byte;
  499. nand->write_byte = dfc_write_byte;
  500. nand->read_word = dfc_read_word;
  501. nand->write_word = dfc_write_word;
  502. nand->read_buf = dfc_read_buf;
  503. nand->write_buf = dfc_write_buf;
  504. nand->cmdfunc = dfc_cmdfunc;
  505. nand->autooob = &delta_oob;
  506. nand->badblock_pattern = &delta_bbt_descr;
  507. return 0;
  508. }
  509. #else
  510. #error "U-Boot legacy NAND support not available for Monahans DFC."
  511. #endif
  512. #endif