mxc_nand.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. /*
  2. * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #include <linux/delay.h>
  20. #include <linux/slab.h>
  21. #include <linux/init.h>
  22. #include <linux/module.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/nand.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/device.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/clk.h>
  30. #include <linux/err.h>
  31. #include <linux/io.h>
  32. #include <asm/mach/flash.h>
  33. #include <mach/mxc_nand.h>
  34. #include <mach/hardware.h>
  35. #define DRIVER_NAME "mxc_nand"
  36. #define nfc_is_v21() (cpu_is_mx25() || cpu_is_mx35())
  37. #define nfc_is_v1() (cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21())
  38. #define nfc_is_v3_2() cpu_is_mx51()
  39. #define nfc_is_v3() nfc_is_v3_2()
  40. /* Addresses for NFC registers */
  41. #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00)
  42. #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04)
  43. #define NFC_V1_V2_FLASH_ADDR (host->regs + 0x06)
  44. #define NFC_V1_V2_FLASH_CMD (host->regs + 0x08)
  45. #define NFC_V1_V2_CONFIG (host->regs + 0x0a)
  46. #define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c)
  47. #define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e)
  48. #define NFC_V1_V2_RSLTSPARE_AREA (host->regs + 0x10)
  49. #define NFC_V1_V2_WRPROT (host->regs + 0x12)
  50. #define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14)
  51. #define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16)
  52. #define NFC_V21_UNLOCKSTART_BLKADDR (host->regs + 0x20)
  53. #define NFC_V21_UNLOCKEND_BLKADDR (host->regs + 0x22)
  54. #define NFC_V1_V2_NF_WRPRST (host->regs + 0x18)
  55. #define NFC_V1_V2_CONFIG1 (host->regs + 0x1a)
  56. #define NFC_V1_V2_CONFIG2 (host->regs + 0x1c)
  57. #define NFC_V2_CONFIG1_ECC_MODE_4 (1 << 0)
  58. #define NFC_V1_V2_CONFIG1_SP_EN (1 << 2)
  59. #define NFC_V1_V2_CONFIG1_ECC_EN (1 << 3)
  60. #define NFC_V1_V2_CONFIG1_INT_MSK (1 << 4)
  61. #define NFC_V1_V2_CONFIG1_BIG (1 << 5)
  62. #define NFC_V1_V2_CONFIG1_RST (1 << 6)
  63. #define NFC_V1_V2_CONFIG1_CE (1 << 7)
  64. #define NFC_V2_CONFIG1_ONE_CYCLE (1 << 8)
  65. #define NFC_V2_CONFIG1_PPB(x) (((x) & 0x3) << 9)
  66. #define NFC_V2_CONFIG1_FP_INT (1 << 11)
  67. #define NFC_V1_V2_CONFIG2_INT (1 << 15)
  68. /*
  69. * Operation modes for the NFC. Valid for v1, v2 and v3
  70. * type controllers.
  71. */
  72. #define NFC_CMD (1 << 0)
  73. #define NFC_ADDR (1 << 1)
  74. #define NFC_INPUT (1 << 2)
  75. #define NFC_OUTPUT (1 << 3)
  76. #define NFC_ID (1 << 4)
  77. #define NFC_STATUS (1 << 5)
  78. #define NFC_V3_FLASH_CMD (host->regs_axi + 0x00)
  79. #define NFC_V3_FLASH_ADDR0 (host->regs_axi + 0x04)
  80. #define NFC_V3_CONFIG1 (host->regs_axi + 0x34)
  81. #define NFC_V3_CONFIG1_SP_EN (1 << 0)
  82. #define NFC_V3_CONFIG1_RBA(x) (((x) & 0x7 ) << 4)
  83. #define NFC_V3_ECC_STATUS_RESULT (host->regs_axi + 0x38)
  84. #define NFC_V3_LAUNCH (host->regs_axi + 0x40)
  85. #define NFC_V3_WRPROT (host->regs_ip + 0x0)
  86. #define NFC_V3_WRPROT_LOCK_TIGHT (1 << 0)
  87. #define NFC_V3_WRPROT_LOCK (1 << 1)
  88. #define NFC_V3_WRPROT_UNLOCK (1 << 2)
  89. #define NFC_V3_WRPROT_BLS_UNLOCK (2 << 6)
  90. #define NFC_V3_WRPROT_UNLOCK_BLK_ADD0 (host->regs_ip + 0x04)
  91. #define NFC_V3_CONFIG2 (host->regs_ip + 0x24)
  92. #define NFC_V3_CONFIG2_PS_512 (0 << 0)
  93. #define NFC_V3_CONFIG2_PS_2048 (1 << 0)
  94. #define NFC_V3_CONFIG2_PS_4096 (2 << 0)
  95. #define NFC_V3_CONFIG2_ONE_CYCLE (1 << 2)
  96. #define NFC_V3_CONFIG2_ECC_EN (1 << 3)
  97. #define NFC_V3_CONFIG2_2CMD_PHASES (1 << 4)
  98. #define NFC_V3_CONFIG2_NUM_ADDR_PHASE0 (1 << 5)
  99. #define NFC_V3_CONFIG2_ECC_MODE_8 (1 << 6)
  100. #define NFC_V3_CONFIG2_PPB(x) (((x) & 0x3) << 7)
  101. #define NFC_V3_CONFIG2_NUM_ADDR_PHASE1(x) (((x) & 0x3) << 12)
  102. #define NFC_V3_CONFIG2_INT_MSK (1 << 15)
  103. #define NFC_V3_CONFIG2_ST_CMD(x) (((x) & 0xff) << 24)
  104. #define NFC_V3_CONFIG2_SPAS(x) (((x) & 0xff) << 16)
  105. #define NFC_V3_CONFIG3 (host->regs_ip + 0x28)
  106. #define NFC_V3_CONFIG3_ADD_OP(x) (((x) & 0x3) << 0)
  107. #define NFC_V3_CONFIG3_FW8 (1 << 3)
  108. #define NFC_V3_CONFIG3_SBB(x) (((x) & 0x7) << 8)
  109. #define NFC_V3_CONFIG3_NUM_OF_DEVICES(x) (((x) & 0x7) << 12)
  110. #define NFC_V3_CONFIG3_RBB_MODE (1 << 15)
  111. #define NFC_V3_CONFIG3_NO_SDMA (1 << 20)
  112. #define NFC_V3_IPC (host->regs_ip + 0x2C)
  113. #define NFC_V3_IPC_CREQ (1 << 0)
  114. #define NFC_V3_IPC_INT (1 << 31)
  115. #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
  116. struct mxc_nand_host {
  117. struct mtd_info mtd;
  118. struct nand_chip nand;
  119. struct mtd_partition *parts;
  120. struct device *dev;
  121. void *spare0;
  122. void *main_area0;
  123. void __iomem *base;
  124. void __iomem *regs;
  125. void __iomem *regs_axi;
  126. void __iomem *regs_ip;
  127. int status_request;
  128. struct clk *clk;
  129. int clk_act;
  130. int irq;
  131. int eccsize;
  132. wait_queue_head_t irq_waitq;
  133. uint8_t *data_buf;
  134. unsigned int buf_start;
  135. int spare_len;
  136. void (*preset)(struct mtd_info *);
  137. void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
  138. void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
  139. void (*send_page)(struct mtd_info *, unsigned int);
  140. void (*send_read_id)(struct mxc_nand_host *);
  141. uint16_t (*get_dev_status)(struct mxc_nand_host *);
  142. int (*check_int)(struct mxc_nand_host *);
  143. };
  144. /* OOB placement block for use with hardware ecc generation */
  145. static struct nand_ecclayout nandv1_hw_eccoob_smallpage = {
  146. .eccbytes = 5,
  147. .eccpos = {6, 7, 8, 9, 10},
  148. .oobfree = {{0, 5}, {12, 4}, }
  149. };
  150. static struct nand_ecclayout nandv1_hw_eccoob_largepage = {
  151. .eccbytes = 20,
  152. .eccpos = {6, 7, 8, 9, 10, 22, 23, 24, 25, 26,
  153. 38, 39, 40, 41, 42, 54, 55, 56, 57, 58},
  154. .oobfree = {{2, 4}, {11, 10}, {27, 10}, {43, 10}, {59, 5}, }
  155. };
  156. /* OOB description for 512 byte pages with 16 byte OOB */
  157. static struct nand_ecclayout nandv2_hw_eccoob_smallpage = {
  158. .eccbytes = 1 * 9,
  159. .eccpos = {
  160. 7, 8, 9, 10, 11, 12, 13, 14, 15
  161. },
  162. .oobfree = {
  163. {.offset = 0, .length = 5}
  164. }
  165. };
  166. /* OOB description for 2048 byte pages with 64 byte OOB */
  167. static struct nand_ecclayout nandv2_hw_eccoob_largepage = {
  168. .eccbytes = 4 * 9,
  169. .eccpos = {
  170. 7, 8, 9, 10, 11, 12, 13, 14, 15,
  171. 23, 24, 25, 26, 27, 28, 29, 30, 31,
  172. 39, 40, 41, 42, 43, 44, 45, 46, 47,
  173. 55, 56, 57, 58, 59, 60, 61, 62, 63
  174. },
  175. .oobfree = {
  176. {.offset = 2, .length = 4},
  177. {.offset = 16, .length = 7},
  178. {.offset = 32, .length = 7},
  179. {.offset = 48, .length = 7}
  180. }
  181. };
  182. #ifdef CONFIG_MTD_PARTITIONS
  183. static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
  184. #endif
  185. static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
  186. {
  187. struct mxc_nand_host *host = dev_id;
  188. disable_irq_nosync(irq);
  189. wake_up(&host->irq_waitq);
  190. return IRQ_HANDLED;
  191. }
  192. static int check_int_v3(struct mxc_nand_host *host)
  193. {
  194. uint32_t tmp;
  195. tmp = readl(NFC_V3_IPC);
  196. if (!(tmp & NFC_V3_IPC_INT))
  197. return 0;
  198. tmp &= ~NFC_V3_IPC_INT;
  199. writel(tmp, NFC_V3_IPC);
  200. return 1;
  201. }
  202. static int check_int_v1_v2(struct mxc_nand_host *host)
  203. {
  204. uint32_t tmp;
  205. tmp = readw(NFC_V1_V2_CONFIG2);
  206. if (!(tmp & NFC_V1_V2_CONFIG2_INT))
  207. return 0;
  208. writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
  209. return 1;
  210. }
  211. /* This function polls the NANDFC to wait for the basic operation to
  212. * complete by checking the INT bit of config2 register.
  213. */
  214. static void wait_op_done(struct mxc_nand_host *host, int useirq)
  215. {
  216. int max_retries = 8000;
  217. if (useirq) {
  218. if (!host->check_int(host)) {
  219. enable_irq(host->irq);
  220. wait_event(host->irq_waitq, host->check_int(host));
  221. }
  222. } else {
  223. while (max_retries-- > 0) {
  224. if (host->check_int(host))
  225. break;
  226. udelay(1);
  227. }
  228. if (max_retries < 0)
  229. DEBUG(MTD_DEBUG_LEVEL0, "%s: INT not set\n",
  230. __func__);
  231. }
  232. }
  233. static void send_cmd_v3(struct mxc_nand_host *host, uint16_t cmd, int useirq)
  234. {
  235. /* fill command */
  236. writel(cmd, NFC_V3_FLASH_CMD);
  237. /* send out command */
  238. writel(NFC_CMD, NFC_V3_LAUNCH);
  239. /* Wait for operation to complete */
  240. wait_op_done(host, useirq);
  241. }
  242. /* This function issues the specified command to the NAND device and
  243. * waits for completion. */
  244. static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
  245. {
  246. DEBUG(MTD_DEBUG_LEVEL3, "send_cmd(host, 0x%x, %d)\n", cmd, useirq);
  247. writew(cmd, NFC_V1_V2_FLASH_CMD);
  248. writew(NFC_CMD, NFC_V1_V2_CONFIG2);
  249. if (cpu_is_mx21() && (cmd == NAND_CMD_RESET)) {
  250. int max_retries = 100;
  251. /* Reset completion is indicated by NFC_CONFIG2 */
  252. /* being set to 0 */
  253. while (max_retries-- > 0) {
  254. if (readw(NFC_V1_V2_CONFIG2) == 0) {
  255. break;
  256. }
  257. udelay(1);
  258. }
  259. if (max_retries < 0)
  260. DEBUG(MTD_DEBUG_LEVEL0, "%s: RESET failed\n",
  261. __func__);
  262. } else {
  263. /* Wait for operation to complete */
  264. wait_op_done(host, useirq);
  265. }
  266. }
  267. static void send_addr_v3(struct mxc_nand_host *host, uint16_t addr, int islast)
  268. {
  269. /* fill address */
  270. writel(addr, NFC_V3_FLASH_ADDR0);
  271. /* send out address */
  272. writel(NFC_ADDR, NFC_V3_LAUNCH);
  273. wait_op_done(host, 0);
  274. }
  275. /* This function sends an address (or partial address) to the
  276. * NAND device. The address is used to select the source/destination for
  277. * a NAND command. */
  278. static void send_addr_v1_v2(struct mxc_nand_host *host, uint16_t addr, int islast)
  279. {
  280. DEBUG(MTD_DEBUG_LEVEL3, "send_addr(host, 0x%x %d)\n", addr, islast);
  281. writew(addr, NFC_V1_V2_FLASH_ADDR);
  282. writew(NFC_ADDR, NFC_V1_V2_CONFIG2);
  283. /* Wait for operation to complete */
  284. wait_op_done(host, islast);
  285. }
  286. static void send_page_v3(struct mtd_info *mtd, unsigned int ops)
  287. {
  288. struct nand_chip *nand_chip = mtd->priv;
  289. struct mxc_nand_host *host = nand_chip->priv;
  290. uint32_t tmp;
  291. tmp = readl(NFC_V3_CONFIG1);
  292. tmp &= ~(7 << 4);
  293. writel(tmp, NFC_V3_CONFIG1);
  294. /* transfer data from NFC ram to nand */
  295. writel(ops, NFC_V3_LAUNCH);
  296. wait_op_done(host, false);
  297. }
  298. static void send_page_v1_v2(struct mtd_info *mtd, unsigned int ops)
  299. {
  300. struct nand_chip *nand_chip = mtd->priv;
  301. struct mxc_nand_host *host = nand_chip->priv;
  302. int bufs, i;
  303. if (nfc_is_v1() && mtd->writesize > 512)
  304. bufs = 4;
  305. else
  306. bufs = 1;
  307. for (i = 0; i < bufs; i++) {
  308. /* NANDFC buffer 0 is used for page read/write */
  309. writew(i, NFC_V1_V2_BUF_ADDR);
  310. writew(ops, NFC_V1_V2_CONFIG2);
  311. /* Wait for operation to complete */
  312. wait_op_done(host, true);
  313. }
  314. }
  315. static void send_read_id_v3(struct mxc_nand_host *host)
  316. {
  317. /* Read ID into main buffer */
  318. writel(NFC_ID, NFC_V3_LAUNCH);
  319. wait_op_done(host, true);
  320. memcpy(host->data_buf, host->main_area0, 16);
  321. }
  322. /* Request the NANDFC to perform a read of the NAND device ID. */
  323. static void send_read_id_v1_v2(struct mxc_nand_host *host)
  324. {
  325. struct nand_chip *this = &host->nand;
  326. /* NANDFC buffer 0 is used for device ID output */
  327. writew(0x0, NFC_V1_V2_BUF_ADDR);
  328. writew(NFC_ID, NFC_V1_V2_CONFIG2);
  329. /* Wait for operation to complete */
  330. wait_op_done(host, true);
  331. memcpy(host->data_buf, host->main_area0, 16);
  332. if (this->options & NAND_BUSWIDTH_16) {
  333. /* compress the ID info */
  334. host->data_buf[1] = host->data_buf[2];
  335. host->data_buf[2] = host->data_buf[4];
  336. host->data_buf[3] = host->data_buf[6];
  337. host->data_buf[4] = host->data_buf[8];
  338. host->data_buf[5] = host->data_buf[10];
  339. }
  340. }
  341. static uint16_t get_dev_status_v3(struct mxc_nand_host *host)
  342. {
  343. writew(NFC_STATUS, NFC_V3_LAUNCH);
  344. wait_op_done(host, true);
  345. return readl(NFC_V3_CONFIG1) >> 16;
  346. }
  347. /* This function requests the NANDFC to perform a read of the
  348. * NAND device status and returns the current status. */
  349. static uint16_t get_dev_status_v1_v2(struct mxc_nand_host *host)
  350. {
  351. void __iomem *main_buf = host->main_area0;
  352. uint32_t store;
  353. uint16_t ret;
  354. writew(0x0, NFC_V1_V2_BUF_ADDR);
  355. /*
  356. * The device status is stored in main_area0. To
  357. * prevent corruption of the buffer save the value
  358. * and restore it afterwards.
  359. */
  360. store = readl(main_buf);
  361. writew(NFC_STATUS, NFC_V1_V2_CONFIG2);
  362. wait_op_done(host, true);
  363. ret = readw(main_buf);
  364. writel(store, main_buf);
  365. return ret;
  366. }
  367. /* This functions is used by upper layer to checks if device is ready */
  368. static int mxc_nand_dev_ready(struct mtd_info *mtd)
  369. {
  370. /*
  371. * NFC handles R/B internally. Therefore, this function
  372. * always returns status as ready.
  373. */
  374. return 1;
  375. }
  376. static void mxc_nand_enable_hwecc(struct mtd_info *mtd, int mode)
  377. {
  378. /*
  379. * If HW ECC is enabled, we turn it on during init. There is
  380. * no need to enable again here.
  381. */
  382. }
  383. static int mxc_nand_correct_data_v1(struct mtd_info *mtd, u_char *dat,
  384. u_char *read_ecc, u_char *calc_ecc)
  385. {
  386. struct nand_chip *nand_chip = mtd->priv;
  387. struct mxc_nand_host *host = nand_chip->priv;
  388. /*
  389. * 1-Bit errors are automatically corrected in HW. No need for
  390. * additional correction. 2-Bit errors cannot be corrected by
  391. * HW ECC, so we need to return failure
  392. */
  393. uint16_t ecc_status = readw(NFC_V1_V2_ECC_STATUS_RESULT);
  394. if (((ecc_status & 0x3) == 2) || ((ecc_status >> 2) == 2)) {
  395. DEBUG(MTD_DEBUG_LEVEL0,
  396. "MXC_NAND: HWECC uncorrectable 2-bit ECC error\n");
  397. return -1;
  398. }
  399. return 0;
  400. }
  401. static int mxc_nand_correct_data_v2_v3(struct mtd_info *mtd, u_char *dat,
  402. u_char *read_ecc, u_char *calc_ecc)
  403. {
  404. struct nand_chip *nand_chip = mtd->priv;
  405. struct mxc_nand_host *host = nand_chip->priv;
  406. u32 ecc_stat, err;
  407. int no_subpages = 1;
  408. int ret = 0;
  409. u8 ecc_bit_mask, err_limit;
  410. ecc_bit_mask = (host->eccsize == 4) ? 0x7 : 0xf;
  411. err_limit = (host->eccsize == 4) ? 0x4 : 0x8;
  412. no_subpages = mtd->writesize >> 9;
  413. if (nfc_is_v21())
  414. ecc_stat = readl(NFC_V1_V2_ECC_STATUS_RESULT);
  415. else
  416. ecc_stat = readl(NFC_V3_ECC_STATUS_RESULT);
  417. do {
  418. err = ecc_stat & ecc_bit_mask;
  419. if (err > err_limit) {
  420. printk(KERN_WARNING "UnCorrectable RS-ECC Error\n");
  421. return -1;
  422. } else {
  423. ret += err;
  424. }
  425. ecc_stat >>= 4;
  426. } while (--no_subpages);
  427. mtd->ecc_stats.corrected += ret;
  428. pr_debug("%d Symbol Correctable RS-ECC Error\n", ret);
  429. return ret;
  430. }
  431. static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
  432. u_char *ecc_code)
  433. {
  434. return 0;
  435. }
  436. static u_char mxc_nand_read_byte(struct mtd_info *mtd)
  437. {
  438. struct nand_chip *nand_chip = mtd->priv;
  439. struct mxc_nand_host *host = nand_chip->priv;
  440. uint8_t ret;
  441. /* Check for status request */
  442. if (host->status_request)
  443. return host->get_dev_status(host) & 0xFF;
  444. ret = *(uint8_t *)(host->data_buf + host->buf_start);
  445. host->buf_start++;
  446. return ret;
  447. }
  448. static uint16_t mxc_nand_read_word(struct mtd_info *mtd)
  449. {
  450. struct nand_chip *nand_chip = mtd->priv;
  451. struct mxc_nand_host *host = nand_chip->priv;
  452. uint16_t ret;
  453. ret = *(uint16_t *)(host->data_buf + host->buf_start);
  454. host->buf_start += 2;
  455. return ret;
  456. }
  457. /* Write data of length len to buffer buf. The data to be
  458. * written on NAND Flash is first copied to RAMbuffer. After the Data Input
  459. * Operation by the NFC, the data is written to NAND Flash */
  460. static void mxc_nand_write_buf(struct mtd_info *mtd,
  461. const u_char *buf, int len)
  462. {
  463. struct nand_chip *nand_chip = mtd->priv;
  464. struct mxc_nand_host *host = nand_chip->priv;
  465. u16 col = host->buf_start;
  466. int n = mtd->oobsize + mtd->writesize - col;
  467. n = min(n, len);
  468. memcpy(host->data_buf + col, buf, n);
  469. host->buf_start += n;
  470. }
  471. /* Read the data buffer from the NAND Flash. To read the data from NAND
  472. * Flash first the data output cycle is initiated by the NFC, which copies
  473. * the data to RAMbuffer. This data of length len is then copied to buffer buf.
  474. */
  475. static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
  476. {
  477. struct nand_chip *nand_chip = mtd->priv;
  478. struct mxc_nand_host *host = nand_chip->priv;
  479. u16 col = host->buf_start;
  480. int n = mtd->oobsize + mtd->writesize - col;
  481. n = min(n, len);
  482. memcpy(buf, host->data_buf + col, len);
  483. host->buf_start += len;
  484. }
  485. /* Used by the upper layer to verify the data in NAND Flash
  486. * with the data in the buf. */
  487. static int mxc_nand_verify_buf(struct mtd_info *mtd,
  488. const u_char *buf, int len)
  489. {
  490. return -EFAULT;
  491. }
  492. /* This function is used by upper layer for select and
  493. * deselect of the NAND chip */
  494. static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
  495. {
  496. struct nand_chip *nand_chip = mtd->priv;
  497. struct mxc_nand_host *host = nand_chip->priv;
  498. switch (chip) {
  499. case -1:
  500. /* Disable the NFC clock */
  501. if (host->clk_act) {
  502. clk_disable(host->clk);
  503. host->clk_act = 0;
  504. }
  505. break;
  506. case 0:
  507. /* Enable the NFC clock */
  508. if (!host->clk_act) {
  509. clk_enable(host->clk);
  510. host->clk_act = 1;
  511. }
  512. break;
  513. default:
  514. break;
  515. }
  516. }
  517. /*
  518. * Function to transfer data to/from spare area.
  519. */
  520. static void copy_spare(struct mtd_info *mtd, bool bfrom)
  521. {
  522. struct nand_chip *this = mtd->priv;
  523. struct mxc_nand_host *host = this->priv;
  524. u16 i, j;
  525. u16 n = mtd->writesize >> 9;
  526. u8 *d = host->data_buf + mtd->writesize;
  527. u8 *s = host->spare0;
  528. u16 t = host->spare_len;
  529. j = (mtd->oobsize / n >> 1) << 1;
  530. if (bfrom) {
  531. for (i = 0; i < n - 1; i++)
  532. memcpy(d + i * j, s + i * t, j);
  533. /* the last section */
  534. memcpy(d + i * j, s + i * t, mtd->oobsize - i * j);
  535. } else {
  536. for (i = 0; i < n - 1; i++)
  537. memcpy(&s[i * t], &d[i * j], j);
  538. /* the last section */
  539. memcpy(&s[i * t], &d[i * j], mtd->oobsize - i * j);
  540. }
  541. }
  542. static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
  543. {
  544. struct nand_chip *nand_chip = mtd->priv;
  545. struct mxc_nand_host *host = nand_chip->priv;
  546. /* Write out column address, if necessary */
  547. if (column != -1) {
  548. /*
  549. * MXC NANDFC can only perform full page+spare or
  550. * spare-only read/write. When the upper layers
  551. * layers perform a read/write buf operation,
  552. * we will used the saved column address to index into
  553. * the full page.
  554. */
  555. host->send_addr(host, 0, page_addr == -1);
  556. if (mtd->writesize > 512)
  557. /* another col addr cycle for 2k page */
  558. host->send_addr(host, 0, false);
  559. }
  560. /* Write out page address, if necessary */
  561. if (page_addr != -1) {
  562. /* paddr_0 - p_addr_7 */
  563. host->send_addr(host, (page_addr & 0xff), false);
  564. if (mtd->writesize > 512) {
  565. if (mtd->size >= 0x10000000) {
  566. /* paddr_8 - paddr_15 */
  567. host->send_addr(host, (page_addr >> 8) & 0xff, false);
  568. host->send_addr(host, (page_addr >> 16) & 0xff, true);
  569. } else
  570. /* paddr_8 - paddr_15 */
  571. host->send_addr(host, (page_addr >> 8) & 0xff, true);
  572. } else {
  573. /* One more address cycle for higher density devices */
  574. if (mtd->size >= 0x4000000) {
  575. /* paddr_8 - paddr_15 */
  576. host->send_addr(host, (page_addr >> 8) & 0xff, false);
  577. host->send_addr(host, (page_addr >> 16) & 0xff, true);
  578. } else
  579. /* paddr_8 - paddr_15 */
  580. host->send_addr(host, (page_addr >> 8) & 0xff, true);
  581. }
  582. }
  583. }
  584. /*
  585. * v2 and v3 type controllers can do 4bit or 8bit ecc depending
  586. * on how much oob the nand chip has. For 8bit ecc we need at least
  587. * 26 bytes of oob data per 512 byte block.
  588. */
  589. static int get_eccsize(struct mtd_info *mtd)
  590. {
  591. int oobbytes_per_512 = 0;
  592. oobbytes_per_512 = mtd->oobsize * 512 / mtd->writesize;
  593. if (oobbytes_per_512 < 26)
  594. return 4;
  595. else
  596. return 8;
  597. }
  598. static void preset_v1_v2(struct mtd_info *mtd)
  599. {
  600. struct nand_chip *nand_chip = mtd->priv;
  601. struct mxc_nand_host *host = nand_chip->priv;
  602. uint16_t config1 = 0;
  603. if (nand_chip->ecc.mode == NAND_ECC_HW)
  604. config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
  605. if (nfc_is_v21())
  606. config1 |= NFC_V2_CONFIG1_FP_INT;
  607. if (!cpu_is_mx21())
  608. config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
  609. if (nfc_is_v21() && mtd->writesize) {
  610. uint16_t pages_per_block = mtd->erasesize / mtd->writesize;
  611. host->eccsize = get_eccsize(mtd);
  612. if (host->eccsize == 4)
  613. config1 |= NFC_V2_CONFIG1_ECC_MODE_4;
  614. config1 |= NFC_V2_CONFIG1_PPB(ffs(pages_per_block) - 6);
  615. } else {
  616. host->eccsize = 1;
  617. }
  618. writew(config1, NFC_V1_V2_CONFIG1);
  619. /* preset operation */
  620. /* Unlock the internal RAM Buffer */
  621. writew(0x2, NFC_V1_V2_CONFIG);
  622. /* Blocks to be unlocked */
  623. if (nfc_is_v21()) {
  624. writew(0x0, NFC_V21_UNLOCKSTART_BLKADDR);
  625. writew(0xffff, NFC_V21_UNLOCKEND_BLKADDR);
  626. } else if (nfc_is_v1()) {
  627. writew(0x0, NFC_V1_UNLOCKSTART_BLKADDR);
  628. writew(0x4000, NFC_V1_UNLOCKEND_BLKADDR);
  629. } else
  630. BUG();
  631. /* Unlock Block Command for given address range */
  632. writew(0x4, NFC_V1_V2_WRPROT);
  633. }
  634. static void preset_v3(struct mtd_info *mtd)
  635. {
  636. struct nand_chip *chip = mtd->priv;
  637. struct mxc_nand_host *host = chip->priv;
  638. uint32_t config2, config3;
  639. int i, addr_phases;
  640. writel(NFC_V3_CONFIG1_RBA(0), NFC_V3_CONFIG1);
  641. writel(NFC_V3_IPC_CREQ, NFC_V3_IPC);
  642. /* Unlock the internal RAM Buffer */
  643. writel(NFC_V3_WRPROT_BLS_UNLOCK | NFC_V3_WRPROT_UNLOCK,
  644. NFC_V3_WRPROT);
  645. /* Blocks to be unlocked */
  646. for (i = 0; i < NAND_MAX_CHIPS; i++)
  647. writel(0x0 | (0xffff << 16),
  648. NFC_V3_WRPROT_UNLOCK_BLK_ADD0 + (i << 2));
  649. writel(0, NFC_V3_IPC);
  650. config2 = NFC_V3_CONFIG2_ONE_CYCLE |
  651. NFC_V3_CONFIG2_2CMD_PHASES |
  652. NFC_V3_CONFIG2_SPAS(mtd->oobsize >> 1) |
  653. NFC_V3_CONFIG2_ST_CMD(0x70) |
  654. NFC_V3_CONFIG2_NUM_ADDR_PHASE0;
  655. if (chip->ecc.mode == NAND_ECC_HW)
  656. config2 |= NFC_V3_CONFIG2_ECC_EN;
  657. addr_phases = fls(chip->pagemask) >> 3;
  658. if (mtd->writesize == 2048) {
  659. config2 |= NFC_V3_CONFIG2_PS_2048;
  660. config2 |= NFC_V3_CONFIG2_NUM_ADDR_PHASE1(addr_phases);
  661. } else if (mtd->writesize == 4096) {
  662. config2 |= NFC_V3_CONFIG2_PS_4096;
  663. config2 |= NFC_V3_CONFIG2_NUM_ADDR_PHASE1(addr_phases);
  664. } else {
  665. config2 |= NFC_V3_CONFIG2_PS_512;
  666. config2 |= NFC_V3_CONFIG2_NUM_ADDR_PHASE1(addr_phases - 1);
  667. }
  668. if (mtd->writesize) {
  669. config2 |= NFC_V3_CONFIG2_PPB(ffs(mtd->erasesize / mtd->writesize) - 6);
  670. host->eccsize = get_eccsize(mtd);
  671. if (host->eccsize == 8)
  672. config2 |= NFC_V3_CONFIG2_ECC_MODE_8;
  673. }
  674. writel(config2, NFC_V3_CONFIG2);
  675. config3 = NFC_V3_CONFIG3_NUM_OF_DEVICES(0) |
  676. NFC_V3_CONFIG3_NO_SDMA |
  677. NFC_V3_CONFIG3_RBB_MODE |
  678. NFC_V3_CONFIG3_SBB(6) | /* Reset default */
  679. NFC_V3_CONFIG3_ADD_OP(0);
  680. if (!(chip->options & NAND_BUSWIDTH_16))
  681. config3 |= NFC_V3_CONFIG3_FW8;
  682. writel(config3, NFC_V3_CONFIG3);
  683. writel(0, NFC_V3_DELAY_LINE);
  684. }
  685. /* Used by the upper layer to write command to NAND Flash for
  686. * different operations to be carried out on NAND Flash */
  687. static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
  688. int column, int page_addr)
  689. {
  690. struct nand_chip *nand_chip = mtd->priv;
  691. struct mxc_nand_host *host = nand_chip->priv;
  692. DEBUG(MTD_DEBUG_LEVEL3,
  693. "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
  694. command, column, page_addr);
  695. /* Reset command state information */
  696. host->status_request = false;
  697. /* Command pre-processing step */
  698. switch (command) {
  699. case NAND_CMD_RESET:
  700. host->preset(mtd);
  701. host->send_cmd(host, command, false);
  702. break;
  703. case NAND_CMD_STATUS:
  704. host->buf_start = 0;
  705. host->status_request = true;
  706. host->send_cmd(host, command, true);
  707. mxc_do_addr_cycle(mtd, column, page_addr);
  708. break;
  709. case NAND_CMD_READ0:
  710. case NAND_CMD_READOOB:
  711. if (command == NAND_CMD_READ0)
  712. host->buf_start = column;
  713. else
  714. host->buf_start = column + mtd->writesize;
  715. command = NAND_CMD_READ0; /* only READ0 is valid */
  716. host->send_cmd(host, command, false);
  717. mxc_do_addr_cycle(mtd, column, page_addr);
  718. if (mtd->writesize > 512)
  719. host->send_cmd(host, NAND_CMD_READSTART, true);
  720. host->send_page(mtd, NFC_OUTPUT);
  721. memcpy(host->data_buf, host->main_area0, mtd->writesize);
  722. copy_spare(mtd, true);
  723. break;
  724. case NAND_CMD_SEQIN:
  725. if (column >= mtd->writesize)
  726. /* call ourself to read a page */
  727. mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr);
  728. host->buf_start = column;
  729. host->send_cmd(host, command, false);
  730. mxc_do_addr_cycle(mtd, column, page_addr);
  731. break;
  732. case NAND_CMD_PAGEPROG:
  733. memcpy(host->main_area0, host->data_buf, mtd->writesize);
  734. copy_spare(mtd, false);
  735. host->send_page(mtd, NFC_INPUT);
  736. host->send_cmd(host, command, true);
  737. mxc_do_addr_cycle(mtd, column, page_addr);
  738. break;
  739. case NAND_CMD_READID:
  740. host->send_cmd(host, command, true);
  741. mxc_do_addr_cycle(mtd, column, page_addr);
  742. host->send_read_id(host);
  743. host->buf_start = column;
  744. break;
  745. case NAND_CMD_ERASE1:
  746. case NAND_CMD_ERASE2:
  747. host->send_cmd(host, command, false);
  748. mxc_do_addr_cycle(mtd, column, page_addr);
  749. break;
  750. }
  751. }
  752. /*
  753. * The generic flash bbt decriptors overlap with our ecc
  754. * hardware, so define some i.MX specific ones.
  755. */
  756. static uint8_t bbt_pattern[] = { 'B', 'b', 't', '0' };
  757. static uint8_t mirror_pattern[] = { '1', 't', 'b', 'B' };
  758. static struct nand_bbt_descr bbt_main_descr = {
  759. .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
  760. | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
  761. .offs = 0,
  762. .len = 4,
  763. .veroffs = 4,
  764. .maxblocks = 4,
  765. .pattern = bbt_pattern,
  766. };
  767. static struct nand_bbt_descr bbt_mirror_descr = {
  768. .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
  769. | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
  770. .offs = 0,
  771. .len = 4,
  772. .veroffs = 4,
  773. .maxblocks = 4,
  774. .pattern = mirror_pattern,
  775. };
  776. static int __init mxcnd_probe(struct platform_device *pdev)
  777. {
  778. struct nand_chip *this;
  779. struct mtd_info *mtd;
  780. struct mxc_nand_platform_data *pdata = pdev->dev.platform_data;
  781. struct mxc_nand_host *host;
  782. struct resource *res;
  783. int err = 0, nr_parts = 0;
  784. struct nand_ecclayout *oob_smallpage, *oob_largepage;
  785. /* Allocate memory for MTD device structure and private data */
  786. host = kzalloc(sizeof(struct mxc_nand_host) + NAND_MAX_PAGESIZE +
  787. NAND_MAX_OOBSIZE, GFP_KERNEL);
  788. if (!host)
  789. return -ENOMEM;
  790. host->data_buf = (uint8_t *)(host + 1);
  791. host->dev = &pdev->dev;
  792. /* structures must be linked */
  793. this = &host->nand;
  794. mtd = &host->mtd;
  795. mtd->priv = this;
  796. mtd->owner = THIS_MODULE;
  797. mtd->dev.parent = &pdev->dev;
  798. mtd->name = DRIVER_NAME;
  799. /* 50 us command delay time */
  800. this->chip_delay = 5;
  801. this->priv = host;
  802. this->dev_ready = mxc_nand_dev_ready;
  803. this->cmdfunc = mxc_nand_command;
  804. this->select_chip = mxc_nand_select_chip;
  805. this->read_byte = mxc_nand_read_byte;
  806. this->read_word = mxc_nand_read_word;
  807. this->write_buf = mxc_nand_write_buf;
  808. this->read_buf = mxc_nand_read_buf;
  809. this->verify_buf = mxc_nand_verify_buf;
  810. host->clk = clk_get(&pdev->dev, "nfc");
  811. if (IS_ERR(host->clk)) {
  812. err = PTR_ERR(host->clk);
  813. goto eclk;
  814. }
  815. clk_enable(host->clk);
  816. host->clk_act = 1;
  817. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  818. if (!res) {
  819. err = -ENODEV;
  820. goto eres;
  821. }
  822. host->base = ioremap(res->start, resource_size(res));
  823. if (!host->base) {
  824. err = -ENOMEM;
  825. goto eres;
  826. }
  827. host->main_area0 = host->base;
  828. if (nfc_is_v1() || nfc_is_v21()) {
  829. host->preset = preset_v1_v2;
  830. host->send_cmd = send_cmd_v1_v2;
  831. host->send_addr = send_addr_v1_v2;
  832. host->send_page = send_page_v1_v2;
  833. host->send_read_id = send_read_id_v1_v2;
  834. host->get_dev_status = get_dev_status_v1_v2;
  835. host->check_int = check_int_v1_v2;
  836. }
  837. if (nfc_is_v21()) {
  838. host->regs = host->base + 0x1e00;
  839. host->spare0 = host->base + 0x1000;
  840. host->spare_len = 64;
  841. oob_smallpage = &nandv2_hw_eccoob_smallpage;
  842. oob_largepage = &nandv2_hw_eccoob_largepage;
  843. this->ecc.bytes = 9;
  844. } else if (nfc_is_v1()) {
  845. host->regs = host->base + 0xe00;
  846. host->spare0 = host->base + 0x800;
  847. host->spare_len = 16;
  848. oob_smallpage = &nandv1_hw_eccoob_smallpage;
  849. oob_largepage = &nandv1_hw_eccoob_largepage;
  850. this->ecc.bytes = 3;
  851. host->eccsize = 1;
  852. } else if (nfc_is_v3_2()) {
  853. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  854. if (!res) {
  855. err = -ENODEV;
  856. goto eirq;
  857. }
  858. host->regs_ip = ioremap(res->start, resource_size(res));
  859. if (!host->regs_ip) {
  860. err = -ENOMEM;
  861. goto eirq;
  862. }
  863. host->regs_axi = host->base + 0x1e00;
  864. host->spare0 = host->base + 0x1000;
  865. host->spare_len = 64;
  866. host->preset = preset_v3;
  867. host->send_cmd = send_cmd_v3;
  868. host->send_addr = send_addr_v3;
  869. host->send_page = send_page_v3;
  870. host->send_read_id = send_read_id_v3;
  871. host->check_int = check_int_v3;
  872. host->get_dev_status = get_dev_status_v3;
  873. oob_smallpage = &nandv2_hw_eccoob_smallpage;
  874. oob_largepage = &nandv2_hw_eccoob_largepage;
  875. } else
  876. BUG();
  877. this->ecc.size = 512;
  878. this->ecc.layout = oob_smallpage;
  879. if (pdata->hw_ecc) {
  880. this->ecc.calculate = mxc_nand_calculate_ecc;
  881. this->ecc.hwctl = mxc_nand_enable_hwecc;
  882. if (nfc_is_v1())
  883. this->ecc.correct = mxc_nand_correct_data_v1;
  884. else
  885. this->ecc.correct = mxc_nand_correct_data_v2_v3;
  886. this->ecc.mode = NAND_ECC_HW;
  887. } else {
  888. this->ecc.mode = NAND_ECC_SOFT;
  889. }
  890. /* NAND bus width determines access funtions used by upper layer */
  891. if (pdata->width == 2)
  892. this->options |= NAND_BUSWIDTH_16;
  893. if (pdata->flash_bbt) {
  894. this->bbt_td = &bbt_main_descr;
  895. this->bbt_md = &bbt_mirror_descr;
  896. /* update flash based bbt */
  897. this->options |= NAND_USE_FLASH_BBT;
  898. }
  899. init_waitqueue_head(&host->irq_waitq);
  900. host->irq = platform_get_irq(pdev, 0);
  901. err = request_irq(host->irq, mxc_nfc_irq, IRQF_DISABLED, DRIVER_NAME, host);
  902. if (err)
  903. goto eirq;
  904. /* first scan to find the device and get the page size */
  905. if (nand_scan_ident(mtd, 1, NULL)) {
  906. err = -ENXIO;
  907. goto escan;
  908. }
  909. /* Call preset again, with correct writesize this time */
  910. host->preset(mtd);
  911. if (mtd->writesize == 2048)
  912. this->ecc.layout = oob_largepage;
  913. /* second phase scan */
  914. if (nand_scan_tail(mtd)) {
  915. err = -ENXIO;
  916. goto escan;
  917. }
  918. /* Register the partitions */
  919. #ifdef CONFIG_MTD_PARTITIONS
  920. nr_parts =
  921. parse_mtd_partitions(mtd, part_probes, &host->parts, 0);
  922. if (nr_parts > 0)
  923. add_mtd_partitions(mtd, host->parts, nr_parts);
  924. else if (pdata->parts)
  925. add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts);
  926. else
  927. #endif
  928. {
  929. pr_info("Registering %s as whole device\n", mtd->name);
  930. add_mtd_device(mtd);
  931. }
  932. platform_set_drvdata(pdev, host);
  933. return 0;
  934. escan:
  935. free_irq(host->irq, host);
  936. eirq:
  937. if (host->regs_ip)
  938. iounmap(host->regs_ip);
  939. iounmap(host->base);
  940. eres:
  941. clk_put(host->clk);
  942. eclk:
  943. kfree(host);
  944. return err;
  945. }
  946. static int __devexit mxcnd_remove(struct platform_device *pdev)
  947. {
  948. struct mxc_nand_host *host = platform_get_drvdata(pdev);
  949. clk_put(host->clk);
  950. platform_set_drvdata(pdev, NULL);
  951. nand_release(&host->mtd);
  952. free_irq(host->irq, host);
  953. if (host->regs_ip)
  954. iounmap(host->regs_ip);
  955. iounmap(host->base);
  956. kfree(host);
  957. return 0;
  958. }
  959. static struct platform_driver mxcnd_driver = {
  960. .driver = {
  961. .name = DRIVER_NAME,
  962. },
  963. .remove = __devexit_p(mxcnd_remove),
  964. };
  965. static int __init mxc_nd_init(void)
  966. {
  967. return platform_driver_probe(&mxcnd_driver, mxcnd_probe);
  968. }
  969. static void __exit mxc_nd_cleanup(void)
  970. {
  971. /* Unregister the device structure */
  972. platform_driver_unregister(&mxcnd_driver);
  973. }
  974. module_init(mxc_nd_init);
  975. module_exit(mxc_nd_cleanup);
  976. MODULE_AUTHOR("Freescale Semiconductor, Inc.");
  977. MODULE_DESCRIPTION("MXC NAND MTD driver");
  978. MODULE_LICENSE("GPL");