pxa3xx_nand.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228
  1. /*
  2. * drivers/mtd/nand/pxa3xx_nand.c
  3. *
  4. * Copyright © 2005 Intel Corporation
  5. * Copyright © 2006 Marvell International Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/delay.h>
  16. #include <linux/clk.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/nand.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/io.h>
  21. #include <linux/irq.h>
  22. #include <asm/dma.h>
  23. #include <mach/pxa-regs.h>
  24. #include <mach/pxa3xx_nand.h>
  25. #define CHIP_DELAY_TIMEOUT (2 * HZ/10)
  26. /* registers and bit definitions */
  27. #define NDCR (0x00) /* Control register */
  28. #define NDTR0CS0 (0x04) /* Timing Parameter 0 for CS0 */
  29. #define NDTR1CS0 (0x0C) /* Timing Parameter 1 for CS0 */
  30. #define NDSR (0x14) /* Status Register */
  31. #define NDPCR (0x18) /* Page Count Register */
  32. #define NDBDR0 (0x1C) /* Bad Block Register 0 */
  33. #define NDBDR1 (0x20) /* Bad Block Register 1 */
  34. #define NDDB (0x40) /* Data Buffer */
  35. #define NDCB0 (0x48) /* Command Buffer0 */
  36. #define NDCB1 (0x4C) /* Command Buffer1 */
  37. #define NDCB2 (0x50) /* Command Buffer2 */
  38. #define NDCR_SPARE_EN (0x1 << 31)
  39. #define NDCR_ECC_EN (0x1 << 30)
  40. #define NDCR_DMA_EN (0x1 << 29)
  41. #define NDCR_ND_RUN (0x1 << 28)
  42. #define NDCR_DWIDTH_C (0x1 << 27)
  43. #define NDCR_DWIDTH_M (0x1 << 26)
  44. #define NDCR_PAGE_SZ (0x1 << 24)
  45. #define NDCR_NCSX (0x1 << 23)
  46. #define NDCR_ND_MODE (0x3 << 21)
  47. #define NDCR_NAND_MODE (0x0)
  48. #define NDCR_CLR_PG_CNT (0x1 << 20)
  49. #define NDCR_CLR_ECC (0x1 << 19)
  50. #define NDCR_RD_ID_CNT_MASK (0x7 << 16)
  51. #define NDCR_RD_ID_CNT(x) (((x) << 16) & NDCR_RD_ID_CNT_MASK)
  52. #define NDCR_RA_START (0x1 << 15)
  53. #define NDCR_PG_PER_BLK (0x1 << 14)
  54. #define NDCR_ND_ARB_EN (0x1 << 12)
  55. #define NDSR_MASK (0xfff)
  56. #define NDSR_RDY (0x1 << 11)
  57. #define NDSR_CS0_PAGED (0x1 << 10)
  58. #define NDSR_CS1_PAGED (0x1 << 9)
  59. #define NDSR_CS0_CMDD (0x1 << 8)
  60. #define NDSR_CS1_CMDD (0x1 << 7)
  61. #define NDSR_CS0_BBD (0x1 << 6)
  62. #define NDSR_CS1_BBD (0x1 << 5)
  63. #define NDSR_DBERR (0x1 << 4)
  64. #define NDSR_SBERR (0x1 << 3)
  65. #define NDSR_WRDREQ (0x1 << 2)
  66. #define NDSR_RDDREQ (0x1 << 1)
  67. #define NDSR_WRCMDREQ (0x1)
  68. #define NDCB0_AUTO_RS (0x1 << 25)
  69. #define NDCB0_CSEL (0x1 << 24)
  70. #define NDCB0_CMD_TYPE_MASK (0x7 << 21)
  71. #define NDCB0_CMD_TYPE(x) (((x) << 21) & NDCB0_CMD_TYPE_MASK)
  72. #define NDCB0_NC (0x1 << 20)
  73. #define NDCB0_DBC (0x1 << 19)
  74. #define NDCB0_ADDR_CYC_MASK (0x7 << 16)
  75. #define NDCB0_ADDR_CYC(x) (((x) << 16) & NDCB0_ADDR_CYC_MASK)
  76. #define NDCB0_CMD2_MASK (0xff << 8)
  77. #define NDCB0_CMD1_MASK (0xff)
  78. #define NDCB0_ADDR_CYC_SHIFT (16)
  79. /* dma-able I/O address for the NAND data and commands */
  80. #define NDCB0_DMA_ADDR (0x43100048)
  81. #define NDDB_DMA_ADDR (0x43100040)
  82. /* macros for registers read/write */
  83. #define nand_writel(info, off, val) \
  84. __raw_writel((val), (info)->mmio_base + (off))
  85. #define nand_readl(info, off) \
  86. __raw_readl((info)->mmio_base + (off))
  87. /* error code and state */
  88. enum {
  89. ERR_NONE = 0,
  90. ERR_DMABUSERR = -1,
  91. ERR_SENDCMD = -2,
  92. ERR_DBERR = -3,
  93. ERR_BBERR = -4,
  94. };
  95. enum {
  96. STATE_READY = 0,
  97. STATE_CMD_HANDLE,
  98. STATE_DMA_READING,
  99. STATE_DMA_WRITING,
  100. STATE_DMA_DONE,
  101. STATE_PIO_READING,
  102. STATE_PIO_WRITING,
  103. };
  104. struct pxa3xx_nand_info {
  105. struct nand_chip nand_chip;
  106. struct platform_device *pdev;
  107. struct pxa3xx_nand_flash *flash_info;
  108. struct clk *clk;
  109. void __iomem *mmio_base;
  110. unsigned int buf_start;
  111. unsigned int buf_count;
  112. /* DMA information */
  113. int drcmr_dat;
  114. int drcmr_cmd;
  115. unsigned char *data_buff;
  116. dma_addr_t data_buff_phys;
  117. size_t data_buff_size;
  118. int data_dma_ch;
  119. struct pxa_dma_desc *data_desc;
  120. dma_addr_t data_desc_addr;
  121. uint32_t reg_ndcr;
  122. /* saved column/page_addr during CMD_SEQIN */
  123. int seqin_column;
  124. int seqin_page_addr;
  125. /* relate to the command */
  126. unsigned int state;
  127. int use_ecc; /* use HW ECC ? */
  128. int use_dma; /* use DMA ? */
  129. size_t data_size; /* data size in FIFO */
  130. int retcode;
  131. struct completion cmd_complete;
  132. /* generated NDCBx register values */
  133. uint32_t ndcb0;
  134. uint32_t ndcb1;
  135. uint32_t ndcb2;
  136. };
  137. static int use_dma = 1;
  138. module_param(use_dma, bool, 0444);
  139. MODULE_PARM_DESC(use_dma, "enable DMA for data transfering to/from NAND HW");
  140. static struct pxa3xx_nand_cmdset smallpage_cmdset = {
  141. .read1 = 0x0000,
  142. .read2 = 0x0050,
  143. .program = 0x1080,
  144. .read_status = 0x0070,
  145. .read_id = 0x0090,
  146. .erase = 0xD060,
  147. .reset = 0x00FF,
  148. .lock = 0x002A,
  149. .unlock = 0x2423,
  150. .lock_status = 0x007A,
  151. };
  152. static struct pxa3xx_nand_cmdset largepage_cmdset = {
  153. .read1 = 0x3000,
  154. .read2 = 0x0050,
  155. .program = 0x1080,
  156. .read_status = 0x0070,
  157. .read_id = 0x0090,
  158. .erase = 0xD060,
  159. .reset = 0x00FF,
  160. .lock = 0x002A,
  161. .unlock = 0x2423,
  162. .lock_status = 0x007A,
  163. };
  164. static struct pxa3xx_nand_timing samsung512MbX16_timing = {
  165. .tCH = 10,
  166. .tCS = 0,
  167. .tWH = 20,
  168. .tWP = 40,
  169. .tRH = 30,
  170. .tRP = 40,
  171. .tR = 11123,
  172. .tWHR = 110,
  173. .tAR = 10,
  174. };
  175. static struct pxa3xx_nand_flash samsung512MbX16 = {
  176. .timing = &samsung512MbX16_timing,
  177. .cmdset = &smallpage_cmdset,
  178. .page_per_block = 32,
  179. .page_size = 512,
  180. .flash_width = 16,
  181. .dfc_width = 16,
  182. .num_blocks = 4096,
  183. .chip_id = 0x46ec,
  184. };
  185. static struct pxa3xx_nand_timing micron_timing = {
  186. .tCH = 10,
  187. .tCS = 25,
  188. .tWH = 15,
  189. .tWP = 25,
  190. .tRH = 15,
  191. .tRP = 25,
  192. .tR = 25000,
  193. .tWHR = 60,
  194. .tAR = 10,
  195. };
  196. static struct pxa3xx_nand_flash micron1GbX8 = {
  197. .timing = &micron_timing,
  198. .cmdset = &largepage_cmdset,
  199. .page_per_block = 64,
  200. .page_size = 2048,
  201. .flash_width = 8,
  202. .dfc_width = 8,
  203. .num_blocks = 1024,
  204. .chip_id = 0xa12c,
  205. };
  206. static struct pxa3xx_nand_flash micron1GbX16 = {
  207. .timing = &micron_timing,
  208. .cmdset = &largepage_cmdset,
  209. .page_per_block = 64,
  210. .page_size = 2048,
  211. .flash_width = 16,
  212. .dfc_width = 16,
  213. .num_blocks = 1024,
  214. .chip_id = 0xb12c,
  215. };
  216. static struct pxa3xx_nand_timing stm2GbX16_timing = {
  217. .tCH = 10,
  218. .tCS = 35,
  219. .tWH = 15,
  220. .tWP = 25,
  221. .tRH = 15,
  222. .tRP = 25,
  223. .tR = 25000,
  224. .tWHR = 60,
  225. .tAR = 10,
  226. };
  227. static struct pxa3xx_nand_flash stm2GbX16 = {
  228. .timing = &stm2GbX16_timing,
  229. .page_per_block = 64,
  230. .page_size = 2048,
  231. .flash_width = 16,
  232. .dfc_width = 16,
  233. .num_blocks = 2048,
  234. .chip_id = 0xba20,
  235. };
  236. static struct pxa3xx_nand_flash *builtin_flash_types[] = {
  237. &samsung512MbX16,
  238. &micron1GbX8,
  239. &micron1GbX16,
  240. &stm2GbX16,
  241. };
  242. #define NDTR0_tCH(c) (min((c), 7) << 19)
  243. #define NDTR0_tCS(c) (min((c), 7) << 16)
  244. #define NDTR0_tWH(c) (min((c), 7) << 11)
  245. #define NDTR0_tWP(c) (min((c), 7) << 8)
  246. #define NDTR0_tRH(c) (min((c), 7) << 3)
  247. #define NDTR0_tRP(c) (min((c), 7) << 0)
  248. #define NDTR1_tR(c) (min((c), 65535) << 16)
  249. #define NDTR1_tWHR(c) (min((c), 15) << 4)
  250. #define NDTR1_tAR(c) (min((c), 15) << 0)
  251. /* convert nano-seconds to nand flash controller clock cycles */
  252. #define ns2cycle(ns, clk) (int)(((ns) * (clk / 1000000) / 1000) + 1)
  253. static void pxa3xx_nand_set_timing(struct pxa3xx_nand_info *info,
  254. struct pxa3xx_nand_timing *t)
  255. {
  256. unsigned long nand_clk = clk_get_rate(info->clk);
  257. uint32_t ndtr0, ndtr1;
  258. ndtr0 = NDTR0_tCH(ns2cycle(t->tCH, nand_clk)) |
  259. NDTR0_tCS(ns2cycle(t->tCS, nand_clk)) |
  260. NDTR0_tWH(ns2cycle(t->tWH, nand_clk)) |
  261. NDTR0_tWP(ns2cycle(t->tWP, nand_clk)) |
  262. NDTR0_tRH(ns2cycle(t->tRH, nand_clk)) |
  263. NDTR0_tRP(ns2cycle(t->tRP, nand_clk));
  264. ndtr1 = NDTR1_tR(ns2cycle(t->tR, nand_clk)) |
  265. NDTR1_tWHR(ns2cycle(t->tWHR, nand_clk)) |
  266. NDTR1_tAR(ns2cycle(t->tAR, nand_clk));
  267. nand_writel(info, NDTR0CS0, ndtr0);
  268. nand_writel(info, NDTR1CS0, ndtr1);
  269. }
  270. #define WAIT_EVENT_TIMEOUT 10
  271. static int wait_for_event(struct pxa3xx_nand_info *info, uint32_t event)
  272. {
  273. int timeout = WAIT_EVENT_TIMEOUT;
  274. uint32_t ndsr;
  275. while (timeout--) {
  276. ndsr = nand_readl(info, NDSR) & NDSR_MASK;
  277. if (ndsr & event) {
  278. nand_writel(info, NDSR, ndsr);
  279. return 0;
  280. }
  281. udelay(10);
  282. }
  283. return -ETIMEDOUT;
  284. }
  285. static int prepare_read_prog_cmd(struct pxa3xx_nand_info *info,
  286. uint16_t cmd, int column, int page_addr)
  287. {
  288. struct pxa3xx_nand_flash *f = info->flash_info;
  289. struct pxa3xx_nand_cmdset *cmdset = f->cmdset;
  290. /* calculate data size */
  291. switch (f->page_size) {
  292. case 2048:
  293. info->data_size = (info->use_ecc) ? 2088 : 2112;
  294. break;
  295. case 512:
  296. info->data_size = (info->use_ecc) ? 520 : 528;
  297. break;
  298. default:
  299. return -EINVAL;
  300. }
  301. /* generate values for NDCBx registers */
  302. info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0);
  303. info->ndcb1 = 0;
  304. info->ndcb2 = 0;
  305. info->ndcb0 |= NDCB0_ADDR_CYC(f->row_addr_cycles + f->col_addr_cycles);
  306. if (f->col_addr_cycles == 2) {
  307. /* large block, 2 cycles for column address
  308. * row address starts from 3rd cycle
  309. */
  310. info->ndcb1 |= (page_addr << 16) | (column & 0xffff);
  311. if (f->row_addr_cycles == 3)
  312. info->ndcb2 = (page_addr >> 16) & 0xff;
  313. } else
  314. /* small block, 1 cycles for column address
  315. * row address starts from 2nd cycle
  316. */
  317. info->ndcb1 = (page_addr << 8) | (column & 0xff);
  318. if (cmd == cmdset->program)
  319. info->ndcb0 |= NDCB0_CMD_TYPE(1) | NDCB0_AUTO_RS;
  320. return 0;
  321. }
  322. static int prepare_erase_cmd(struct pxa3xx_nand_info *info,
  323. uint16_t cmd, int page_addr)
  324. {
  325. info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0);
  326. info->ndcb0 |= NDCB0_CMD_TYPE(2) | NDCB0_AUTO_RS | NDCB0_ADDR_CYC(3);
  327. info->ndcb1 = page_addr;
  328. info->ndcb2 = 0;
  329. return 0;
  330. }
  331. static int prepare_other_cmd(struct pxa3xx_nand_info *info, uint16_t cmd)
  332. {
  333. struct pxa3xx_nand_cmdset *cmdset = info->flash_info->cmdset;
  334. info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0);
  335. info->ndcb1 = 0;
  336. info->ndcb2 = 0;
  337. if (cmd == cmdset->read_id) {
  338. info->ndcb0 |= NDCB0_CMD_TYPE(3);
  339. info->data_size = 8;
  340. } else if (cmd == cmdset->read_status) {
  341. info->ndcb0 |= NDCB0_CMD_TYPE(4);
  342. info->data_size = 8;
  343. } else if (cmd == cmdset->reset || cmd == cmdset->lock ||
  344. cmd == cmdset->unlock) {
  345. info->ndcb0 |= NDCB0_CMD_TYPE(5);
  346. } else
  347. return -EINVAL;
  348. return 0;
  349. }
  350. static void enable_int(struct pxa3xx_nand_info *info, uint32_t int_mask)
  351. {
  352. uint32_t ndcr;
  353. ndcr = nand_readl(info, NDCR);
  354. nand_writel(info, NDCR, ndcr & ~int_mask);
  355. }
  356. static void disable_int(struct pxa3xx_nand_info *info, uint32_t int_mask)
  357. {
  358. uint32_t ndcr;
  359. ndcr = nand_readl(info, NDCR);
  360. nand_writel(info, NDCR, ndcr | int_mask);
  361. }
  362. /* NOTE: it is a must to set ND_RUN firstly, then write command buffer
  363. * otherwise, it does not work
  364. */
  365. static int write_cmd(struct pxa3xx_nand_info *info)
  366. {
  367. uint32_t ndcr;
  368. /* clear status bits and run */
  369. nand_writel(info, NDSR, NDSR_MASK);
  370. ndcr = info->reg_ndcr;
  371. ndcr |= info->use_ecc ? NDCR_ECC_EN : 0;
  372. ndcr |= info->use_dma ? NDCR_DMA_EN : 0;
  373. ndcr |= NDCR_ND_RUN;
  374. nand_writel(info, NDCR, ndcr);
  375. if (wait_for_event(info, NDSR_WRCMDREQ)) {
  376. printk(KERN_ERR "timed out writing command\n");
  377. return -ETIMEDOUT;
  378. }
  379. nand_writel(info, NDCB0, info->ndcb0);
  380. nand_writel(info, NDCB0, info->ndcb1);
  381. nand_writel(info, NDCB0, info->ndcb2);
  382. return 0;
  383. }
  384. static int handle_data_pio(struct pxa3xx_nand_info *info)
  385. {
  386. int ret, timeout = CHIP_DELAY_TIMEOUT;
  387. switch (info->state) {
  388. case STATE_PIO_WRITING:
  389. __raw_writesl(info->mmio_base + NDDB, info->data_buff,
  390. info->data_size << 2);
  391. enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD);
  392. ret = wait_for_completion_timeout(&info->cmd_complete, timeout);
  393. if (!ret) {
  394. printk(KERN_ERR "program command time out\n");
  395. return -1;
  396. }
  397. break;
  398. case STATE_PIO_READING:
  399. __raw_readsl(info->mmio_base + NDDB, info->data_buff,
  400. info->data_size << 2);
  401. break;
  402. default:
  403. printk(KERN_ERR "%s: invalid state %d\n", __func__,
  404. info->state);
  405. return -EINVAL;
  406. }
  407. info->state = STATE_READY;
  408. return 0;
  409. }
  410. static void start_data_dma(struct pxa3xx_nand_info *info, int dir_out)
  411. {
  412. struct pxa_dma_desc *desc = info->data_desc;
  413. int dma_len = ALIGN(info->data_size, 32);
  414. desc->ddadr = DDADR_STOP;
  415. desc->dcmd = DCMD_ENDIRQEN | DCMD_WIDTH4 | DCMD_BURST32 | dma_len;
  416. if (dir_out) {
  417. desc->dsadr = info->data_buff_phys;
  418. desc->dtadr = NDDB_DMA_ADDR;
  419. desc->dcmd |= DCMD_INCSRCADDR | DCMD_FLOWTRG;
  420. } else {
  421. desc->dtadr = info->data_buff_phys;
  422. desc->dsadr = NDDB_DMA_ADDR;
  423. desc->dcmd |= DCMD_INCTRGADDR | DCMD_FLOWSRC;
  424. }
  425. DRCMR(info->drcmr_dat) = DRCMR_MAPVLD | info->data_dma_ch;
  426. DDADR(info->data_dma_ch) = info->data_desc_addr;
  427. DCSR(info->data_dma_ch) |= DCSR_RUN;
  428. }
  429. static void pxa3xx_nand_data_dma_irq(int channel, void *data)
  430. {
  431. struct pxa3xx_nand_info *info = data;
  432. uint32_t dcsr;
  433. dcsr = DCSR(channel);
  434. DCSR(channel) = dcsr;
  435. if (dcsr & DCSR_BUSERR) {
  436. info->retcode = ERR_DMABUSERR;
  437. complete(&info->cmd_complete);
  438. }
  439. if (info->state == STATE_DMA_WRITING) {
  440. info->state = STATE_DMA_DONE;
  441. enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD);
  442. } else {
  443. info->state = STATE_READY;
  444. complete(&info->cmd_complete);
  445. }
  446. }
  447. static irqreturn_t pxa3xx_nand_irq(int irq, void *devid)
  448. {
  449. struct pxa3xx_nand_info *info = devid;
  450. unsigned int status;
  451. status = nand_readl(info, NDSR);
  452. if (status & (NDSR_RDDREQ | NDSR_DBERR)) {
  453. if (status & NDSR_DBERR)
  454. info->retcode = ERR_DBERR;
  455. disable_int(info, NDSR_RDDREQ | NDSR_DBERR);
  456. if (info->use_dma) {
  457. info->state = STATE_DMA_READING;
  458. start_data_dma(info, 0);
  459. } else {
  460. info->state = STATE_PIO_READING;
  461. complete(&info->cmd_complete);
  462. }
  463. } else if (status & NDSR_WRDREQ) {
  464. disable_int(info, NDSR_WRDREQ);
  465. if (info->use_dma) {
  466. info->state = STATE_DMA_WRITING;
  467. start_data_dma(info, 1);
  468. } else {
  469. info->state = STATE_PIO_WRITING;
  470. complete(&info->cmd_complete);
  471. }
  472. } else if (status & (NDSR_CS0_BBD | NDSR_CS0_CMDD)) {
  473. if (status & NDSR_CS0_BBD)
  474. info->retcode = ERR_BBERR;
  475. disable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD);
  476. info->state = STATE_READY;
  477. complete(&info->cmd_complete);
  478. }
  479. nand_writel(info, NDSR, status);
  480. return IRQ_HANDLED;
  481. }
  482. static int pxa3xx_nand_do_cmd(struct pxa3xx_nand_info *info, uint32_t event)
  483. {
  484. uint32_t ndcr;
  485. int ret, timeout = CHIP_DELAY_TIMEOUT;
  486. if (write_cmd(info)) {
  487. info->retcode = ERR_SENDCMD;
  488. goto fail_stop;
  489. }
  490. info->state = STATE_CMD_HANDLE;
  491. enable_int(info, event);
  492. ret = wait_for_completion_timeout(&info->cmd_complete, timeout);
  493. if (!ret) {
  494. printk(KERN_ERR "command execution timed out\n");
  495. info->retcode = ERR_SENDCMD;
  496. goto fail_stop;
  497. }
  498. if (info->use_dma == 0 && info->data_size > 0)
  499. if (handle_data_pio(info))
  500. goto fail_stop;
  501. return 0;
  502. fail_stop:
  503. ndcr = nand_readl(info, NDCR);
  504. nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN);
  505. udelay(10);
  506. return -ETIMEDOUT;
  507. }
  508. static int pxa3xx_nand_dev_ready(struct mtd_info *mtd)
  509. {
  510. struct pxa3xx_nand_info *info = mtd->priv;
  511. return (nand_readl(info, NDSR) & NDSR_RDY) ? 1 : 0;
  512. }
  513. static inline int is_buf_blank(uint8_t *buf, size_t len)
  514. {
  515. for (; len > 0; len--)
  516. if (*buf++ != 0xff)
  517. return 0;
  518. return 1;
  519. }
  520. static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
  521. int column, int page_addr)
  522. {
  523. struct pxa3xx_nand_info *info = mtd->priv;
  524. struct pxa3xx_nand_flash *flash_info = info->flash_info;
  525. struct pxa3xx_nand_cmdset *cmdset = flash_info->cmdset;
  526. int ret;
  527. info->use_dma = (use_dma) ? 1 : 0;
  528. info->use_ecc = 0;
  529. info->data_size = 0;
  530. info->state = STATE_READY;
  531. init_completion(&info->cmd_complete);
  532. switch (command) {
  533. case NAND_CMD_READOOB:
  534. /* disable HW ECC to get all the OOB data */
  535. info->buf_count = mtd->writesize + mtd->oobsize;
  536. info->buf_start = mtd->writesize + column;
  537. if (prepare_read_prog_cmd(info, cmdset->read1, column, page_addr))
  538. break;
  539. pxa3xx_nand_do_cmd(info, NDSR_RDDREQ | NDSR_DBERR);
  540. /* We only are OOB, so if the data has error, does not matter */
  541. if (info->retcode == ERR_DBERR)
  542. info->retcode = ERR_NONE;
  543. break;
  544. case NAND_CMD_READ0:
  545. info->use_ecc = 1;
  546. info->retcode = ERR_NONE;
  547. info->buf_start = column;
  548. info->buf_count = mtd->writesize + mtd->oobsize;
  549. memset(info->data_buff, 0xFF, info->buf_count);
  550. if (prepare_read_prog_cmd(info, cmdset->read1, column, page_addr))
  551. break;
  552. pxa3xx_nand_do_cmd(info, NDSR_RDDREQ | NDSR_DBERR);
  553. if (info->retcode == ERR_DBERR) {
  554. /* for blank page (all 0xff), HW will calculate its ECC as
  555. * 0, which is different from the ECC information within
  556. * OOB, ignore such double bit errors
  557. */
  558. if (is_buf_blank(info->data_buff, mtd->writesize))
  559. info->retcode = ERR_NONE;
  560. }
  561. break;
  562. case NAND_CMD_SEQIN:
  563. info->buf_start = column;
  564. info->buf_count = mtd->writesize + mtd->oobsize;
  565. memset(info->data_buff, 0xff, info->buf_count);
  566. /* save column/page_addr for next CMD_PAGEPROG */
  567. info->seqin_column = column;
  568. info->seqin_page_addr = page_addr;
  569. break;
  570. case NAND_CMD_PAGEPROG:
  571. info->use_ecc = (info->seqin_column >= mtd->writesize) ? 0 : 1;
  572. if (prepare_read_prog_cmd(info, cmdset->program,
  573. info->seqin_column, info->seqin_page_addr))
  574. break;
  575. pxa3xx_nand_do_cmd(info, NDSR_WRDREQ);
  576. break;
  577. case NAND_CMD_ERASE1:
  578. if (prepare_erase_cmd(info, cmdset->erase, page_addr))
  579. break;
  580. pxa3xx_nand_do_cmd(info, NDSR_CS0_BBD | NDSR_CS0_CMDD);
  581. break;
  582. case NAND_CMD_ERASE2:
  583. break;
  584. case NAND_CMD_READID:
  585. case NAND_CMD_STATUS:
  586. info->use_dma = 0; /* force PIO read */
  587. info->buf_start = 0;
  588. info->buf_count = (command == NAND_CMD_READID) ?
  589. flash_info->read_id_bytes : 1;
  590. if (prepare_other_cmd(info, (command == NAND_CMD_READID) ?
  591. cmdset->read_id : cmdset->read_status))
  592. break;
  593. pxa3xx_nand_do_cmd(info, NDSR_RDDREQ);
  594. break;
  595. case NAND_CMD_RESET:
  596. if (prepare_other_cmd(info, cmdset->reset))
  597. break;
  598. ret = pxa3xx_nand_do_cmd(info, NDSR_CS0_CMDD);
  599. if (ret == 0) {
  600. int timeout = 2;
  601. uint32_t ndcr;
  602. while (timeout--) {
  603. if (nand_readl(info, NDSR) & NDSR_RDY)
  604. break;
  605. msleep(10);
  606. }
  607. ndcr = nand_readl(info, NDCR);
  608. nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN);
  609. }
  610. break;
  611. default:
  612. printk(KERN_ERR "non-supported command.\n");
  613. break;
  614. }
  615. if (info->retcode == ERR_DBERR) {
  616. printk(KERN_ERR "double bit error @ page %08x\n", page_addr);
  617. info->retcode = ERR_NONE;
  618. }
  619. }
  620. static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd)
  621. {
  622. struct pxa3xx_nand_info *info = mtd->priv;
  623. char retval = 0xFF;
  624. if (info->buf_start < info->buf_count)
  625. /* Has just send a new command? */
  626. retval = info->data_buff[info->buf_start++];
  627. return retval;
  628. }
  629. static u16 pxa3xx_nand_read_word(struct mtd_info *mtd)
  630. {
  631. struct pxa3xx_nand_info *info = mtd->priv;
  632. u16 retval = 0xFFFF;
  633. if (!(info->buf_start & 0x01) && info->buf_start < info->buf_count) {
  634. retval = *((u16 *)(info->data_buff+info->buf_start));
  635. info->buf_start += 2;
  636. }
  637. return retval;
  638. }
  639. static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
  640. {
  641. struct pxa3xx_nand_info *info = mtd->priv;
  642. int real_len = min_t(size_t, len, info->buf_count - info->buf_start);
  643. memcpy(buf, info->data_buff + info->buf_start, real_len);
  644. info->buf_start += real_len;
  645. }
  646. static void pxa3xx_nand_write_buf(struct mtd_info *mtd,
  647. const uint8_t *buf, int len)
  648. {
  649. struct pxa3xx_nand_info *info = mtd->priv;
  650. int real_len = min_t(size_t, len, info->buf_count - info->buf_start);
  651. memcpy(info->data_buff + info->buf_start, buf, real_len);
  652. info->buf_start += real_len;
  653. }
  654. static int pxa3xx_nand_verify_buf(struct mtd_info *mtd,
  655. const uint8_t *buf, int len)
  656. {
  657. return 0;
  658. }
  659. static void pxa3xx_nand_select_chip(struct mtd_info *mtd, int chip)
  660. {
  661. return;
  662. }
  663. static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this)
  664. {
  665. struct pxa3xx_nand_info *info = mtd->priv;
  666. /* pxa3xx_nand_send_command has waited for command complete */
  667. if (this->state == FL_WRITING || this->state == FL_ERASING) {
  668. if (info->retcode == ERR_NONE)
  669. return 0;
  670. else {
  671. /*
  672. * any error make it return 0x01 which will tell
  673. * the caller the erase and write fail
  674. */
  675. return 0x01;
  676. }
  677. }
  678. return 0;
  679. }
  680. static void pxa3xx_nand_ecc_hwctl(struct mtd_info *mtd, int mode)
  681. {
  682. return;
  683. }
  684. static int pxa3xx_nand_ecc_calculate(struct mtd_info *mtd,
  685. const uint8_t *dat, uint8_t *ecc_code)
  686. {
  687. return 0;
  688. }
  689. static int pxa3xx_nand_ecc_correct(struct mtd_info *mtd,
  690. uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc)
  691. {
  692. struct pxa3xx_nand_info *info = mtd->priv;
  693. /*
  694. * Any error include ERR_SEND_CMD, ERR_DBERR, ERR_BUSERR, we
  695. * consider it as a ecc error which will tell the caller the
  696. * read fail We have distinguish all the errors, but the
  697. * nand_read_ecc only check this function return value
  698. */
  699. if (info->retcode != ERR_NONE)
  700. return -1;
  701. return 0;
  702. }
  703. static int __readid(struct pxa3xx_nand_info *info, uint32_t *id)
  704. {
  705. struct pxa3xx_nand_flash *f = info->flash_info;
  706. struct pxa3xx_nand_cmdset *cmdset = f->cmdset;
  707. uint32_t ndcr;
  708. uint8_t id_buff[8];
  709. if (prepare_other_cmd(info, cmdset->read_id)) {
  710. printk(KERN_ERR "failed to prepare command\n");
  711. return -EINVAL;
  712. }
  713. /* Send command */
  714. if (write_cmd(info))
  715. goto fail_timeout;
  716. /* Wait for CMDDM(command done successfully) */
  717. if (wait_for_event(info, NDSR_RDDREQ))
  718. goto fail_timeout;
  719. __raw_readsl(info->mmio_base + NDDB, id_buff, 2);
  720. *id = id_buff[0] | (id_buff[1] << 8);
  721. return 0;
  722. fail_timeout:
  723. ndcr = nand_readl(info, NDCR);
  724. nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN);
  725. udelay(10);
  726. return -ETIMEDOUT;
  727. }
  728. static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info,
  729. struct pxa3xx_nand_flash *f)
  730. {
  731. struct platform_device *pdev = info->pdev;
  732. struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data;
  733. uint32_t ndcr = 0x00000FFF; /* disable all interrupts */
  734. if (f->page_size != 2048 && f->page_size != 512)
  735. return -EINVAL;
  736. if (f->flash_width != 16 && f->flash_width != 8)
  737. return -EINVAL;
  738. /* calculate flash information */
  739. f->oob_size = (f->page_size == 2048) ? 64 : 16;
  740. f->read_id_bytes = (f->page_size == 2048) ? 4 : 2;
  741. /* calculate addressing information */
  742. f->col_addr_cycles = (f->page_size == 2048) ? 2 : 1;
  743. if (f->num_blocks * f->page_per_block > 65536)
  744. f->row_addr_cycles = 3;
  745. else
  746. f->row_addr_cycles = 2;
  747. ndcr |= (pdata->enable_arbiter) ? NDCR_ND_ARB_EN : 0;
  748. ndcr |= (f->col_addr_cycles == 2) ? NDCR_RA_START : 0;
  749. ndcr |= (f->page_per_block == 64) ? NDCR_PG_PER_BLK : 0;
  750. ndcr |= (f->page_size == 2048) ? NDCR_PAGE_SZ : 0;
  751. ndcr |= (f->flash_width == 16) ? NDCR_DWIDTH_M : 0;
  752. ndcr |= (f->dfc_width == 16) ? NDCR_DWIDTH_C : 0;
  753. ndcr |= NDCR_RD_ID_CNT(f->read_id_bytes);
  754. ndcr |= NDCR_SPARE_EN; /* enable spare by default */
  755. info->reg_ndcr = ndcr;
  756. pxa3xx_nand_set_timing(info, f->timing);
  757. info->flash_info = f;
  758. return 0;
  759. }
  760. static int pxa3xx_nand_detect_flash(struct pxa3xx_nand_info *info)
  761. {
  762. struct pxa3xx_nand_flash *f;
  763. uint32_t id;
  764. int i;
  765. for (i = 0; i < ARRAY_SIZE(builtin_flash_types); i++) {
  766. f = builtin_flash_types[i];
  767. if (pxa3xx_nand_config_flash(info, f))
  768. continue;
  769. if (__readid(info, &id))
  770. continue;
  771. if (id == f->chip_id)
  772. return 0;
  773. }
  774. return -ENODEV;
  775. }
  776. /* the maximum possible buffer size for large page with OOB data
  777. * is: 2048 + 64 = 2112 bytes, allocate a page here for both the
  778. * data buffer and the DMA descriptor
  779. */
  780. #define MAX_BUFF_SIZE PAGE_SIZE
  781. static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
  782. {
  783. struct platform_device *pdev = info->pdev;
  784. int data_desc_offset = MAX_BUFF_SIZE - sizeof(struct pxa_dma_desc);
  785. if (use_dma == 0) {
  786. info->data_buff = kmalloc(MAX_BUFF_SIZE, GFP_KERNEL);
  787. if (info->data_buff == NULL)
  788. return -ENOMEM;
  789. return 0;
  790. }
  791. info->data_buff = dma_alloc_coherent(&pdev->dev, MAX_BUFF_SIZE,
  792. &info->data_buff_phys, GFP_KERNEL);
  793. if (info->data_buff == NULL) {
  794. dev_err(&pdev->dev, "failed to allocate dma buffer\n");
  795. return -ENOMEM;
  796. }
  797. info->data_buff_size = MAX_BUFF_SIZE;
  798. info->data_desc = (void *)info->data_buff + data_desc_offset;
  799. info->data_desc_addr = info->data_buff_phys + data_desc_offset;
  800. info->data_dma_ch = pxa_request_dma("nand-data", DMA_PRIO_LOW,
  801. pxa3xx_nand_data_dma_irq, info);
  802. if (info->data_dma_ch < 0) {
  803. dev_err(&pdev->dev, "failed to request data dma\n");
  804. dma_free_coherent(&pdev->dev, info->data_buff_size,
  805. info->data_buff, info->data_buff_phys);
  806. return info->data_dma_ch;
  807. }
  808. return 0;
  809. }
  810. static struct nand_ecclayout hw_smallpage_ecclayout = {
  811. .eccbytes = 6,
  812. .eccpos = {8, 9, 10, 11, 12, 13 },
  813. .oobfree = { {2, 6} }
  814. };
  815. static struct nand_ecclayout hw_largepage_ecclayout = {
  816. .eccbytes = 24,
  817. .eccpos = {
  818. 40, 41, 42, 43, 44, 45, 46, 47,
  819. 48, 49, 50, 51, 52, 53, 54, 55,
  820. 56, 57, 58, 59, 60, 61, 62, 63},
  821. .oobfree = { {2, 38} }
  822. };
  823. static void pxa3xx_nand_init_mtd(struct mtd_info *mtd,
  824. struct pxa3xx_nand_info *info)
  825. {
  826. struct pxa3xx_nand_flash *f = info->flash_info;
  827. struct nand_chip *this = &info->nand_chip;
  828. this->options = (f->flash_width == 16) ? NAND_BUSWIDTH_16: 0;
  829. this->waitfunc = pxa3xx_nand_waitfunc;
  830. this->select_chip = pxa3xx_nand_select_chip;
  831. this->dev_ready = pxa3xx_nand_dev_ready;
  832. this->cmdfunc = pxa3xx_nand_cmdfunc;
  833. this->read_word = pxa3xx_nand_read_word;
  834. this->read_byte = pxa3xx_nand_read_byte;
  835. this->read_buf = pxa3xx_nand_read_buf;
  836. this->write_buf = pxa3xx_nand_write_buf;
  837. this->verify_buf = pxa3xx_nand_verify_buf;
  838. this->ecc.mode = NAND_ECC_HW;
  839. this->ecc.hwctl = pxa3xx_nand_ecc_hwctl;
  840. this->ecc.calculate = pxa3xx_nand_ecc_calculate;
  841. this->ecc.correct = pxa3xx_nand_ecc_correct;
  842. this->ecc.size = f->page_size;
  843. if (f->page_size == 2048)
  844. this->ecc.layout = &hw_largepage_ecclayout;
  845. else
  846. this->ecc.layout = &hw_smallpage_ecclayout;
  847. this->chip_delay = 25;
  848. }
  849. static int pxa3xx_nand_probe(struct platform_device *pdev)
  850. {
  851. struct pxa3xx_nand_platform_data *pdata;
  852. struct pxa3xx_nand_info *info;
  853. struct nand_chip *this;
  854. struct mtd_info *mtd;
  855. struct resource *r;
  856. int ret = 0, irq;
  857. pdata = pdev->dev.platform_data;
  858. if (!pdata) {
  859. dev_err(&pdev->dev, "no platform data defined\n");
  860. return -ENODEV;
  861. }
  862. mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct pxa3xx_nand_info),
  863. GFP_KERNEL);
  864. if (!mtd) {
  865. dev_err(&pdev->dev, "failed to allocate memory\n");
  866. return -ENOMEM;
  867. }
  868. info = (struct pxa3xx_nand_info *)(&mtd[1]);
  869. info->pdev = pdev;
  870. this = &info->nand_chip;
  871. mtd->priv = info;
  872. info->clk = clk_get(&pdev->dev, "NANDCLK");
  873. if (IS_ERR(info->clk)) {
  874. dev_err(&pdev->dev, "failed to get nand clock\n");
  875. ret = PTR_ERR(info->clk);
  876. goto fail_free_mtd;
  877. }
  878. clk_enable(info->clk);
  879. r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
  880. if (r == NULL) {
  881. dev_err(&pdev->dev, "no resource defined for data DMA\n");
  882. ret = -ENXIO;
  883. goto fail_put_clk;
  884. }
  885. info->drcmr_dat = r->start;
  886. r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
  887. if (r == NULL) {
  888. dev_err(&pdev->dev, "no resource defined for command DMA\n");
  889. ret = -ENXIO;
  890. goto fail_put_clk;
  891. }
  892. info->drcmr_cmd = r->start;
  893. irq = platform_get_irq(pdev, 0);
  894. if (irq < 0) {
  895. dev_err(&pdev->dev, "no IRQ resource defined\n");
  896. ret = -ENXIO;
  897. goto fail_put_clk;
  898. }
  899. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  900. if (r == NULL) {
  901. dev_err(&pdev->dev, "no IO memory resource defined\n");
  902. ret = -ENODEV;
  903. goto fail_put_clk;
  904. }
  905. r = request_mem_region(r->start, r->end - r->start + 1, pdev->name);
  906. if (r == NULL) {
  907. dev_err(&pdev->dev, "failed to request memory resource\n");
  908. ret = -EBUSY;
  909. goto fail_put_clk;
  910. }
  911. info->mmio_base = ioremap(r->start, r->end - r->start + 1);
  912. if (info->mmio_base == NULL) {
  913. dev_err(&pdev->dev, "ioremap() failed\n");
  914. ret = -ENODEV;
  915. goto fail_free_res;
  916. }
  917. ret = pxa3xx_nand_init_buff(info);
  918. if (ret)
  919. goto fail_free_io;
  920. ret = request_irq(IRQ_NAND, pxa3xx_nand_irq, IRQF_DISABLED,
  921. pdev->name, info);
  922. if (ret < 0) {
  923. dev_err(&pdev->dev, "failed to request IRQ\n");
  924. goto fail_free_buf;
  925. }
  926. ret = pxa3xx_nand_detect_flash(info);
  927. if (ret) {
  928. dev_err(&pdev->dev, "failed to detect flash\n");
  929. ret = -ENODEV;
  930. goto fail_free_irq;
  931. }
  932. pxa3xx_nand_init_mtd(mtd, info);
  933. platform_set_drvdata(pdev, mtd);
  934. if (nand_scan(mtd, 1)) {
  935. dev_err(&pdev->dev, "failed to scan nand\n");
  936. ret = -ENXIO;
  937. goto fail_free_irq;
  938. }
  939. return add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts);
  940. fail_free_irq:
  941. free_irq(IRQ_NAND, info);
  942. fail_free_buf:
  943. if (use_dma) {
  944. pxa_free_dma(info->data_dma_ch);
  945. dma_free_coherent(&pdev->dev, info->data_buff_size,
  946. info->data_buff, info->data_buff_phys);
  947. } else
  948. kfree(info->data_buff);
  949. fail_free_io:
  950. iounmap(info->mmio_base);
  951. fail_free_res:
  952. release_mem_region(r->start, r->end - r->start + 1);
  953. fail_put_clk:
  954. clk_disable(info->clk);
  955. clk_put(info->clk);
  956. fail_free_mtd:
  957. kfree(mtd);
  958. return ret;
  959. }
  960. static int pxa3xx_nand_remove(struct platform_device *pdev)
  961. {
  962. struct mtd_info *mtd = platform_get_drvdata(pdev);
  963. struct pxa3xx_nand_info *info = mtd->priv;
  964. platform_set_drvdata(pdev, NULL);
  965. del_mtd_device(mtd);
  966. del_mtd_partitions(mtd);
  967. free_irq(IRQ_NAND, info);
  968. if (use_dma) {
  969. pxa_free_dma(info->data_dma_ch);
  970. dma_free_writecombine(&pdev->dev, info->data_buff_size,
  971. info->data_buff, info->data_buff_phys);
  972. } else
  973. kfree(info->data_buff);
  974. kfree(mtd);
  975. return 0;
  976. }
  977. #ifdef CONFIG_PM
  978. static int pxa3xx_nand_suspend(struct platform_device *pdev, pm_message_t state)
  979. {
  980. struct mtd_info *mtd = (struct mtd_info *)platform_get_drvdata(pdev);
  981. struct pxa3xx_nand_info *info = mtd->priv;
  982. if (info->state != STATE_READY) {
  983. dev_err(&pdev->dev, "driver busy, state = %d\n", info->state);
  984. return -EAGAIN;
  985. }
  986. return 0;
  987. }
  988. static int pxa3xx_nand_resume(struct platform_device *pdev)
  989. {
  990. struct mtd_info *mtd = (struct mtd_info *)platform_get_drvdata(pdev);
  991. struct pxa3xx_nand_info *info = mtd->priv;
  992. clk_enable(info->clk);
  993. return pxa3xx_nand_config_flash(info, info->flash_info);
  994. }
  995. #else
  996. #define pxa3xx_nand_suspend NULL
  997. #define pxa3xx_nand_resume NULL
  998. #endif
  999. static struct platform_driver pxa3xx_nand_driver = {
  1000. .driver = {
  1001. .name = "pxa3xx-nand",
  1002. },
  1003. .probe = pxa3xx_nand_probe,
  1004. .remove = pxa3xx_nand_remove,
  1005. .suspend = pxa3xx_nand_suspend,
  1006. .resume = pxa3xx_nand_resume,
  1007. };
  1008. static int __init pxa3xx_nand_init(void)
  1009. {
  1010. return platform_driver_register(&pxa3xx_nand_driver);
  1011. }
  1012. module_init(pxa3xx_nand_init);
  1013. static void __exit pxa3xx_nand_exit(void)
  1014. {
  1015. platform_driver_unregister(&pxa3xx_nand_driver);
  1016. }
  1017. module_exit(pxa3xx_nand_exit);
  1018. MODULE_LICENSE("GPL");
  1019. MODULE_DESCRIPTION("PXA3xx NAND controller driver");