mxc_nand.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730
  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 <linux/irq.h>
  33. #include <linux/completion.h>
  34. #include <linux/of.h>
  35. #include <linux/of_device.h>
  36. #include <linux/of_mtd.h>
  37. #include <asm/mach/flash.h>
  38. #include <linux/platform_data/mtd-mxc_nand.h>
  39. #define DRIVER_NAME "mxc_nand"
  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_V21_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_BLKADDR0 (host->regs + 0x20)
  53. #define NFC_V21_UNLOCKSTART_BLKADDR1 (host->regs + 0x24)
  54. #define NFC_V21_UNLOCKSTART_BLKADDR2 (host->regs + 0x28)
  55. #define NFC_V21_UNLOCKSTART_BLKADDR3 (host->regs + 0x2c)
  56. #define NFC_V21_UNLOCKEND_BLKADDR0 (host->regs + 0x22)
  57. #define NFC_V21_UNLOCKEND_BLKADDR1 (host->regs + 0x26)
  58. #define NFC_V21_UNLOCKEND_BLKADDR2 (host->regs + 0x2a)
  59. #define NFC_V21_UNLOCKEND_BLKADDR3 (host->regs + 0x2e)
  60. #define NFC_V1_V2_NF_WRPRST (host->regs + 0x18)
  61. #define NFC_V1_V2_CONFIG1 (host->regs + 0x1a)
  62. #define NFC_V1_V2_CONFIG2 (host->regs + 0x1c)
  63. #define NFC_V2_CONFIG1_ECC_MODE_4 (1 << 0)
  64. #define NFC_V1_V2_CONFIG1_SP_EN (1 << 2)
  65. #define NFC_V1_V2_CONFIG1_ECC_EN (1 << 3)
  66. #define NFC_V1_V2_CONFIG1_INT_MSK (1 << 4)
  67. #define NFC_V1_V2_CONFIG1_BIG (1 << 5)
  68. #define NFC_V1_V2_CONFIG1_RST (1 << 6)
  69. #define NFC_V1_V2_CONFIG1_CE (1 << 7)
  70. #define NFC_V2_CONFIG1_ONE_CYCLE (1 << 8)
  71. #define NFC_V2_CONFIG1_PPB(x) (((x) & 0x3) << 9)
  72. #define NFC_V2_CONFIG1_FP_INT (1 << 11)
  73. #define NFC_V1_V2_CONFIG2_INT (1 << 15)
  74. /*
  75. * Operation modes for the NFC. Valid for v1, v2 and v3
  76. * type controllers.
  77. */
  78. #define NFC_CMD (1 << 0)
  79. #define NFC_ADDR (1 << 1)
  80. #define NFC_INPUT (1 << 2)
  81. #define NFC_OUTPUT (1 << 3)
  82. #define NFC_ID (1 << 4)
  83. #define NFC_STATUS (1 << 5)
  84. #define NFC_V3_FLASH_CMD (host->regs_axi + 0x00)
  85. #define NFC_V3_FLASH_ADDR0 (host->regs_axi + 0x04)
  86. #define NFC_V3_CONFIG1 (host->regs_axi + 0x34)
  87. #define NFC_V3_CONFIG1_SP_EN (1 << 0)
  88. #define NFC_V3_CONFIG1_RBA(x) (((x) & 0x7 ) << 4)
  89. #define NFC_V3_ECC_STATUS_RESULT (host->regs_axi + 0x38)
  90. #define NFC_V3_LAUNCH (host->regs_axi + 0x40)
  91. #define NFC_V3_WRPROT (host->regs_ip + 0x0)
  92. #define NFC_V3_WRPROT_LOCK_TIGHT (1 << 0)
  93. #define NFC_V3_WRPROT_LOCK (1 << 1)
  94. #define NFC_V3_WRPROT_UNLOCK (1 << 2)
  95. #define NFC_V3_WRPROT_BLS_UNLOCK (2 << 6)
  96. #define NFC_V3_WRPROT_UNLOCK_BLK_ADD0 (host->regs_ip + 0x04)
  97. #define NFC_V3_CONFIG2 (host->regs_ip + 0x24)
  98. #define NFC_V3_CONFIG2_PS_512 (0 << 0)
  99. #define NFC_V3_CONFIG2_PS_2048 (1 << 0)
  100. #define NFC_V3_CONFIG2_PS_4096 (2 << 0)
  101. #define NFC_V3_CONFIG2_ONE_CYCLE (1 << 2)
  102. #define NFC_V3_CONFIG2_ECC_EN (1 << 3)
  103. #define NFC_V3_CONFIG2_2CMD_PHASES (1 << 4)
  104. #define NFC_V3_CONFIG2_NUM_ADDR_PHASE0 (1 << 5)
  105. #define NFC_V3_CONFIG2_ECC_MODE_8 (1 << 6)
  106. #define NFC_V3_CONFIG2_PPB(x, shift) (((x) & 0x3) << shift)
  107. #define NFC_V3_CONFIG2_NUM_ADDR_PHASE1(x) (((x) & 0x3) << 12)
  108. #define NFC_V3_CONFIG2_INT_MSK (1 << 15)
  109. #define NFC_V3_CONFIG2_ST_CMD(x) (((x) & 0xff) << 24)
  110. #define NFC_V3_CONFIG2_SPAS(x) (((x) & 0xff) << 16)
  111. #define NFC_V3_CONFIG3 (host->regs_ip + 0x28)
  112. #define NFC_V3_CONFIG3_ADD_OP(x) (((x) & 0x3) << 0)
  113. #define NFC_V3_CONFIG3_FW8 (1 << 3)
  114. #define NFC_V3_CONFIG3_SBB(x) (((x) & 0x7) << 8)
  115. #define NFC_V3_CONFIG3_NUM_OF_DEVICES(x) (((x) & 0x7) << 12)
  116. #define NFC_V3_CONFIG3_RBB_MODE (1 << 15)
  117. #define NFC_V3_CONFIG3_NO_SDMA (1 << 20)
  118. #define NFC_V3_IPC (host->regs_ip + 0x2C)
  119. #define NFC_V3_IPC_CREQ (1 << 0)
  120. #define NFC_V3_IPC_INT (1 << 31)
  121. #define NFC_V3_DELAY_LINE (host->regs_ip + 0x34)
  122. struct mxc_nand_host;
  123. struct mxc_nand_devtype_data {
  124. void (*preset)(struct mtd_info *);
  125. void (*send_cmd)(struct mxc_nand_host *, uint16_t, int);
  126. void (*send_addr)(struct mxc_nand_host *, uint16_t, int);
  127. void (*send_page)(struct mtd_info *, unsigned int);
  128. void (*send_read_id)(struct mxc_nand_host *);
  129. uint16_t (*get_dev_status)(struct mxc_nand_host *);
  130. int (*check_int)(struct mxc_nand_host *);
  131. void (*irq_control)(struct mxc_nand_host *, int);
  132. u32 (*get_ecc_status)(struct mxc_nand_host *);
  133. struct nand_ecclayout *ecclayout_512, *ecclayout_2k, *ecclayout_4k;
  134. void (*select_chip)(struct mtd_info *mtd, int chip);
  135. int (*correct_data)(struct mtd_info *mtd, u_char *dat,
  136. u_char *read_ecc, u_char *calc_ecc);
  137. /*
  138. * On i.MX21 the CONFIG2:INT bit cannot be read if interrupts are masked
  139. * (CONFIG1:INT_MSK is set). To handle this the driver uses
  140. * enable_irq/disable_irq_nosync instead of CONFIG1:INT_MSK
  141. */
  142. int irqpending_quirk;
  143. int needs_ip;
  144. size_t regs_offset;
  145. size_t spare0_offset;
  146. size_t axi_offset;
  147. int spare_len;
  148. int eccbytes;
  149. int eccsize;
  150. int ppb_shift;
  151. };
  152. struct mxc_nand_host {
  153. struct mtd_info mtd;
  154. struct nand_chip nand;
  155. struct device *dev;
  156. void __iomem *spare0;
  157. void __iomem *main_area0;
  158. void __iomem *base;
  159. void __iomem *regs;
  160. void __iomem *regs_axi;
  161. void __iomem *regs_ip;
  162. int status_request;
  163. struct clk *clk;
  164. int clk_act;
  165. int irq;
  166. int eccsize;
  167. int used_oobsize;
  168. int active_cs;
  169. struct completion op_completion;
  170. uint8_t *data_buf;
  171. unsigned int buf_start;
  172. const struct mxc_nand_devtype_data *devtype_data;
  173. struct mxc_nand_platform_data pdata;
  174. };
  175. /* OOB placement block for use with hardware ecc generation */
  176. static struct nand_ecclayout nandv1_hw_eccoob_smallpage = {
  177. .eccbytes = 5,
  178. .eccpos = {6, 7, 8, 9, 10},
  179. .oobfree = {{0, 5}, {12, 4}, }
  180. };
  181. static struct nand_ecclayout nandv1_hw_eccoob_largepage = {
  182. .eccbytes = 20,
  183. .eccpos = {6, 7, 8, 9, 10, 22, 23, 24, 25, 26,
  184. 38, 39, 40, 41, 42, 54, 55, 56, 57, 58},
  185. .oobfree = {{2, 4}, {11, 10}, {27, 10}, {43, 10}, {59, 5}, }
  186. };
  187. /* OOB description for 512 byte pages with 16 byte OOB */
  188. static struct nand_ecclayout nandv2_hw_eccoob_smallpage = {
  189. .eccbytes = 1 * 9,
  190. .eccpos = {
  191. 7, 8, 9, 10, 11, 12, 13, 14, 15
  192. },
  193. .oobfree = {
  194. {.offset = 0, .length = 5}
  195. }
  196. };
  197. /* OOB description for 2048 byte pages with 64 byte OOB */
  198. static struct nand_ecclayout nandv2_hw_eccoob_largepage = {
  199. .eccbytes = 4 * 9,
  200. .eccpos = {
  201. 7, 8, 9, 10, 11, 12, 13, 14, 15,
  202. 23, 24, 25, 26, 27, 28, 29, 30, 31,
  203. 39, 40, 41, 42, 43, 44, 45, 46, 47,
  204. 55, 56, 57, 58, 59, 60, 61, 62, 63
  205. },
  206. .oobfree = {
  207. {.offset = 2, .length = 4},
  208. {.offset = 16, .length = 7},
  209. {.offset = 32, .length = 7},
  210. {.offset = 48, .length = 7}
  211. }
  212. };
  213. /* OOB description for 4096 byte pages with 128 byte OOB */
  214. static struct nand_ecclayout nandv2_hw_eccoob_4k = {
  215. .eccbytes = 8 * 9,
  216. .eccpos = {
  217. 7, 8, 9, 10, 11, 12, 13, 14, 15,
  218. 23, 24, 25, 26, 27, 28, 29, 30, 31,
  219. 39, 40, 41, 42, 43, 44, 45, 46, 47,
  220. 55, 56, 57, 58, 59, 60, 61, 62, 63,
  221. 71, 72, 73, 74, 75, 76, 77, 78, 79,
  222. 87, 88, 89, 90, 91, 92, 93, 94, 95,
  223. 103, 104, 105, 106, 107, 108, 109, 110, 111,
  224. 119, 120, 121, 122, 123, 124, 125, 126, 127,
  225. },
  226. .oobfree = {
  227. {.offset = 2, .length = 4},
  228. {.offset = 16, .length = 7},
  229. {.offset = 32, .length = 7},
  230. {.offset = 48, .length = 7},
  231. {.offset = 64, .length = 7},
  232. {.offset = 80, .length = 7},
  233. {.offset = 96, .length = 7},
  234. {.offset = 112, .length = 7},
  235. }
  236. };
  237. static const char * const part_probes[] = {
  238. "cmdlinepart", "RedBoot", "ofpart", NULL };
  239. static void memcpy32_fromio(void *trg, const void __iomem *src, size_t size)
  240. {
  241. int i;
  242. u32 *t = trg;
  243. const __iomem u32 *s = src;
  244. for (i = 0; i < (size >> 2); i++)
  245. *t++ = __raw_readl(s++);
  246. }
  247. static void memcpy16_fromio(void *trg, const void __iomem *src, size_t size)
  248. {
  249. int i;
  250. u16 *t = trg;
  251. const __iomem u16 *s = src;
  252. /* We assume that src (IO) is always 32bit aligned */
  253. if (PTR_ALIGN(trg, 4) == trg && IS_ALIGNED(size, 4)) {
  254. memcpy32_fromio(trg, src, size);
  255. return;
  256. }
  257. for (i = 0; i < (size >> 1); i++)
  258. *t++ = __raw_readw(s++);
  259. }
  260. static inline void memcpy32_toio(void __iomem *trg, const void *src, int size)
  261. {
  262. /* __iowrite32_copy use 32bit size values so divide by 4 */
  263. __iowrite32_copy(trg, src, size / 4);
  264. }
  265. static void memcpy16_toio(void __iomem *trg, const void *src, int size)
  266. {
  267. int i;
  268. __iomem u16 *t = trg;
  269. const u16 *s = src;
  270. /* We assume that trg (IO) is always 32bit aligned */
  271. if (PTR_ALIGN(src, 4) == src && IS_ALIGNED(size, 4)) {
  272. memcpy32_toio(trg, src, size);
  273. return;
  274. }
  275. for (i = 0; i < (size >> 1); i++)
  276. __raw_writew(*s++, t++);
  277. }
  278. static int check_int_v3(struct mxc_nand_host *host)
  279. {
  280. uint32_t tmp;
  281. tmp = readl(NFC_V3_IPC);
  282. if (!(tmp & NFC_V3_IPC_INT))
  283. return 0;
  284. tmp &= ~NFC_V3_IPC_INT;
  285. writel(tmp, NFC_V3_IPC);
  286. return 1;
  287. }
  288. static int check_int_v1_v2(struct mxc_nand_host *host)
  289. {
  290. uint32_t tmp;
  291. tmp = readw(NFC_V1_V2_CONFIG2);
  292. if (!(tmp & NFC_V1_V2_CONFIG2_INT))
  293. return 0;
  294. if (!host->devtype_data->irqpending_quirk)
  295. writew(tmp & ~NFC_V1_V2_CONFIG2_INT, NFC_V1_V2_CONFIG2);
  296. return 1;
  297. }
  298. static void irq_control_v1_v2(struct mxc_nand_host *host, int activate)
  299. {
  300. uint16_t tmp;
  301. tmp = readw(NFC_V1_V2_CONFIG1);
  302. if (activate)
  303. tmp &= ~NFC_V1_V2_CONFIG1_INT_MSK;
  304. else
  305. tmp |= NFC_V1_V2_CONFIG1_INT_MSK;
  306. writew(tmp, NFC_V1_V2_CONFIG1);
  307. }
  308. static void irq_control_v3(struct mxc_nand_host *host, int activate)
  309. {
  310. uint32_t tmp;
  311. tmp = readl(NFC_V3_CONFIG2);
  312. if (activate)
  313. tmp &= ~NFC_V3_CONFIG2_INT_MSK;
  314. else
  315. tmp |= NFC_V3_CONFIG2_INT_MSK;
  316. writel(tmp, NFC_V3_CONFIG2);
  317. }
  318. static void irq_control(struct mxc_nand_host *host, int activate)
  319. {
  320. if (host->devtype_data->irqpending_quirk) {
  321. if (activate)
  322. enable_irq(host->irq);
  323. else
  324. disable_irq_nosync(host->irq);
  325. } else {
  326. host->devtype_data->irq_control(host, activate);
  327. }
  328. }
  329. static u32 get_ecc_status_v1(struct mxc_nand_host *host)
  330. {
  331. return readw(NFC_V1_V2_ECC_STATUS_RESULT);
  332. }
  333. static u32 get_ecc_status_v2(struct mxc_nand_host *host)
  334. {
  335. return readl(NFC_V1_V2_ECC_STATUS_RESULT);
  336. }
  337. static u32 get_ecc_status_v3(struct mxc_nand_host *host)
  338. {
  339. return readl(NFC_V3_ECC_STATUS_RESULT);
  340. }
  341. static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
  342. {
  343. struct mxc_nand_host *host = dev_id;
  344. if (!host->devtype_data->check_int(host))
  345. return IRQ_NONE;
  346. irq_control(host, 0);
  347. complete(&host->op_completion);
  348. return IRQ_HANDLED;
  349. }
  350. /* This function polls the NANDFC to wait for the basic operation to
  351. * complete by checking the INT bit of config2 register.
  352. */
  353. static int wait_op_done(struct mxc_nand_host *host, int useirq)
  354. {
  355. int ret = 0;
  356. /*
  357. * If operation is already complete, don't bother to setup an irq or a
  358. * loop.
  359. */
  360. if (host->devtype_data->check_int(host))
  361. return 0;
  362. if (useirq) {
  363. unsigned long timeout;
  364. reinit_completion(&host->op_completion);
  365. irq_control(host, 1);
  366. timeout = wait_for_completion_timeout(&host->op_completion, HZ);
  367. if (!timeout && !host->devtype_data->check_int(host)) {
  368. dev_dbg(host->dev, "timeout waiting for irq\n");
  369. ret = -ETIMEDOUT;
  370. }
  371. } else {
  372. int max_retries = 8000;
  373. int done;
  374. do {
  375. udelay(1);
  376. done = host->devtype_data->check_int(host);
  377. if (done)
  378. break;
  379. } while (--max_retries);
  380. if (!done) {
  381. dev_dbg(host->dev, "timeout polling for completion\n");
  382. ret = -ETIMEDOUT;
  383. }
  384. }
  385. WARN_ONCE(ret < 0, "timeout! useirq=%d\n", useirq);
  386. return ret;
  387. }
  388. static void send_cmd_v3(struct mxc_nand_host *host, uint16_t cmd, int useirq)
  389. {
  390. /* fill command */
  391. writel(cmd, NFC_V3_FLASH_CMD);
  392. /* send out command */
  393. writel(NFC_CMD, NFC_V3_LAUNCH);
  394. /* Wait for operation to complete */
  395. wait_op_done(host, useirq);
  396. }
  397. /* This function issues the specified command to the NAND device and
  398. * waits for completion. */
  399. static void send_cmd_v1_v2(struct mxc_nand_host *host, uint16_t cmd, int useirq)
  400. {
  401. pr_debug("send_cmd(host, 0x%x, %d)\n", cmd, useirq);
  402. writew(cmd, NFC_V1_V2_FLASH_CMD);
  403. writew(NFC_CMD, NFC_V1_V2_CONFIG2);
  404. if (host->devtype_data->irqpending_quirk && (cmd == NAND_CMD_RESET)) {
  405. int max_retries = 100;
  406. /* Reset completion is indicated by NFC_CONFIG2 */
  407. /* being set to 0 */
  408. while (max_retries-- > 0) {
  409. if (readw(NFC_V1_V2_CONFIG2) == 0) {
  410. break;
  411. }
  412. udelay(1);
  413. }
  414. if (max_retries < 0)
  415. pr_debug("%s: RESET failed\n", __func__);
  416. } else {
  417. /* Wait for operation to complete */
  418. wait_op_done(host, useirq);
  419. }
  420. }
  421. static void send_addr_v3(struct mxc_nand_host *host, uint16_t addr, int islast)
  422. {
  423. /* fill address */
  424. writel(addr, NFC_V3_FLASH_ADDR0);
  425. /* send out address */
  426. writel(NFC_ADDR, NFC_V3_LAUNCH);
  427. wait_op_done(host, 0);
  428. }
  429. /* This function sends an address (or partial address) to the
  430. * NAND device. The address is used to select the source/destination for
  431. * a NAND command. */
  432. static void send_addr_v1_v2(struct mxc_nand_host *host, uint16_t addr, int islast)
  433. {
  434. pr_debug("send_addr(host, 0x%x %d)\n", addr, islast);
  435. writew(addr, NFC_V1_V2_FLASH_ADDR);
  436. writew(NFC_ADDR, NFC_V1_V2_CONFIG2);
  437. /* Wait for operation to complete */
  438. wait_op_done(host, islast);
  439. }
  440. static void send_page_v3(struct mtd_info *mtd, unsigned int ops)
  441. {
  442. struct nand_chip *nand_chip = mtd->priv;
  443. struct mxc_nand_host *host = nand_chip->priv;
  444. uint32_t tmp;
  445. tmp = readl(NFC_V3_CONFIG1);
  446. tmp &= ~(7 << 4);
  447. writel(tmp, NFC_V3_CONFIG1);
  448. /* transfer data from NFC ram to nand */
  449. writel(ops, NFC_V3_LAUNCH);
  450. wait_op_done(host, false);
  451. }
  452. static void send_page_v2(struct mtd_info *mtd, unsigned int ops)
  453. {
  454. struct nand_chip *nand_chip = mtd->priv;
  455. struct mxc_nand_host *host = nand_chip->priv;
  456. /* NANDFC buffer 0 is used for page read/write */
  457. writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
  458. writew(ops, NFC_V1_V2_CONFIG2);
  459. /* Wait for operation to complete */
  460. wait_op_done(host, true);
  461. }
  462. static void send_page_v1(struct mtd_info *mtd, unsigned int ops)
  463. {
  464. struct nand_chip *nand_chip = mtd->priv;
  465. struct mxc_nand_host *host = nand_chip->priv;
  466. int bufs, i;
  467. if (mtd->writesize > 512)
  468. bufs = 4;
  469. else
  470. bufs = 1;
  471. for (i = 0; i < bufs; i++) {
  472. /* NANDFC buffer 0 is used for page read/write */
  473. writew((host->active_cs << 4) | i, NFC_V1_V2_BUF_ADDR);
  474. writew(ops, NFC_V1_V2_CONFIG2);
  475. /* Wait for operation to complete */
  476. wait_op_done(host, true);
  477. }
  478. }
  479. static void send_read_id_v3(struct mxc_nand_host *host)
  480. {
  481. /* Read ID into main buffer */
  482. writel(NFC_ID, NFC_V3_LAUNCH);
  483. wait_op_done(host, true);
  484. memcpy32_fromio(host->data_buf, host->main_area0, 16);
  485. }
  486. /* Request the NANDFC to perform a read of the NAND device ID. */
  487. static void send_read_id_v1_v2(struct mxc_nand_host *host)
  488. {
  489. /* NANDFC buffer 0 is used for device ID output */
  490. writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
  491. writew(NFC_ID, NFC_V1_V2_CONFIG2);
  492. /* Wait for operation to complete */
  493. wait_op_done(host, true);
  494. memcpy32_fromio(host->data_buf, host->main_area0, 16);
  495. }
  496. static uint16_t get_dev_status_v3(struct mxc_nand_host *host)
  497. {
  498. writew(NFC_STATUS, NFC_V3_LAUNCH);
  499. wait_op_done(host, true);
  500. return readl(NFC_V3_CONFIG1) >> 16;
  501. }
  502. /* This function requests the NANDFC to perform a read of the
  503. * NAND device status and returns the current status. */
  504. static uint16_t get_dev_status_v1_v2(struct mxc_nand_host *host)
  505. {
  506. void __iomem *main_buf = host->main_area0;
  507. uint32_t store;
  508. uint16_t ret;
  509. writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
  510. /*
  511. * The device status is stored in main_area0. To
  512. * prevent corruption of the buffer save the value
  513. * and restore it afterwards.
  514. */
  515. store = readl(main_buf);
  516. writew(NFC_STATUS, NFC_V1_V2_CONFIG2);
  517. wait_op_done(host, true);
  518. ret = readw(main_buf);
  519. writel(store, main_buf);
  520. return ret;
  521. }
  522. /* This functions is used by upper layer to checks if device is ready */
  523. static int mxc_nand_dev_ready(struct mtd_info *mtd)
  524. {
  525. /*
  526. * NFC handles R/B internally. Therefore, this function
  527. * always returns status as ready.
  528. */
  529. return 1;
  530. }
  531. static void mxc_nand_enable_hwecc(struct mtd_info *mtd, int mode)
  532. {
  533. /*
  534. * If HW ECC is enabled, we turn it on during init. There is
  535. * no need to enable again here.
  536. */
  537. }
  538. static int mxc_nand_correct_data_v1(struct mtd_info *mtd, u_char *dat,
  539. u_char *read_ecc, u_char *calc_ecc)
  540. {
  541. struct nand_chip *nand_chip = mtd->priv;
  542. struct mxc_nand_host *host = nand_chip->priv;
  543. /*
  544. * 1-Bit errors are automatically corrected in HW. No need for
  545. * additional correction. 2-Bit errors cannot be corrected by
  546. * HW ECC, so we need to return failure
  547. */
  548. uint16_t ecc_status = get_ecc_status_v1(host);
  549. if (((ecc_status & 0x3) == 2) || ((ecc_status >> 2) == 2)) {
  550. pr_debug("MXC_NAND: HWECC uncorrectable 2-bit ECC error\n");
  551. return -1;
  552. }
  553. return 0;
  554. }
  555. static int mxc_nand_correct_data_v2_v3(struct mtd_info *mtd, u_char *dat,
  556. u_char *read_ecc, u_char *calc_ecc)
  557. {
  558. struct nand_chip *nand_chip = mtd->priv;
  559. struct mxc_nand_host *host = nand_chip->priv;
  560. u32 ecc_stat, err;
  561. int no_subpages = 1;
  562. int ret = 0;
  563. u8 ecc_bit_mask, err_limit;
  564. ecc_bit_mask = (host->eccsize == 4) ? 0x7 : 0xf;
  565. err_limit = (host->eccsize == 4) ? 0x4 : 0x8;
  566. no_subpages = mtd->writesize >> 9;
  567. ecc_stat = host->devtype_data->get_ecc_status(host);
  568. do {
  569. err = ecc_stat & ecc_bit_mask;
  570. if (err > err_limit) {
  571. printk(KERN_WARNING "UnCorrectable RS-ECC Error\n");
  572. return -1;
  573. } else {
  574. ret += err;
  575. }
  576. ecc_stat >>= 4;
  577. } while (--no_subpages);
  578. pr_debug("%d Symbol Correctable RS-ECC Error\n", ret);
  579. return ret;
  580. }
  581. static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
  582. u_char *ecc_code)
  583. {
  584. return 0;
  585. }
  586. static u_char mxc_nand_read_byte(struct mtd_info *mtd)
  587. {
  588. struct nand_chip *nand_chip = mtd->priv;
  589. struct mxc_nand_host *host = nand_chip->priv;
  590. uint8_t ret;
  591. /* Check for status request */
  592. if (host->status_request)
  593. return host->devtype_data->get_dev_status(host) & 0xFF;
  594. if (nand_chip->options & NAND_BUSWIDTH_16) {
  595. /* only take the lower byte of each word */
  596. ret = *(uint16_t *)(host->data_buf + host->buf_start);
  597. host->buf_start += 2;
  598. } else {
  599. ret = *(uint8_t *)(host->data_buf + host->buf_start);
  600. host->buf_start++;
  601. }
  602. pr_debug("%s: ret=0x%hhx (start=%u)\n", __func__, ret, host->buf_start);
  603. return ret;
  604. }
  605. static uint16_t mxc_nand_read_word(struct mtd_info *mtd)
  606. {
  607. struct nand_chip *nand_chip = mtd->priv;
  608. struct mxc_nand_host *host = nand_chip->priv;
  609. uint16_t ret;
  610. ret = *(uint16_t *)(host->data_buf + host->buf_start);
  611. host->buf_start += 2;
  612. return ret;
  613. }
  614. /* Write data of length len to buffer buf. The data to be
  615. * written on NAND Flash is first copied to RAMbuffer. After the Data Input
  616. * Operation by the NFC, the data is written to NAND Flash */
  617. static void mxc_nand_write_buf(struct mtd_info *mtd,
  618. const u_char *buf, int len)
  619. {
  620. struct nand_chip *nand_chip = mtd->priv;
  621. struct mxc_nand_host *host = nand_chip->priv;
  622. u16 col = host->buf_start;
  623. int n = mtd->oobsize + mtd->writesize - col;
  624. n = min(n, len);
  625. memcpy(host->data_buf + col, buf, n);
  626. host->buf_start += n;
  627. }
  628. /* Read the data buffer from the NAND Flash. To read the data from NAND
  629. * Flash first the data output cycle is initiated by the NFC, which copies
  630. * the data to RAMbuffer. This data of length len is then copied to buffer buf.
  631. */
  632. static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
  633. {
  634. struct nand_chip *nand_chip = mtd->priv;
  635. struct mxc_nand_host *host = nand_chip->priv;
  636. u16 col = host->buf_start;
  637. int n = mtd->oobsize + mtd->writesize - col;
  638. n = min(n, len);
  639. memcpy(buf, host->data_buf + col, n);
  640. host->buf_start += n;
  641. }
  642. /* This function is used by upper layer for select and
  643. * deselect of the NAND chip */
  644. static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip)
  645. {
  646. struct nand_chip *nand_chip = mtd->priv;
  647. struct mxc_nand_host *host = nand_chip->priv;
  648. if (chip == -1) {
  649. /* Disable the NFC clock */
  650. if (host->clk_act) {
  651. clk_disable_unprepare(host->clk);
  652. host->clk_act = 0;
  653. }
  654. return;
  655. }
  656. if (!host->clk_act) {
  657. /* Enable the NFC clock */
  658. clk_prepare_enable(host->clk);
  659. host->clk_act = 1;
  660. }
  661. }
  662. static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
  663. {
  664. struct nand_chip *nand_chip = mtd->priv;
  665. struct mxc_nand_host *host = nand_chip->priv;
  666. if (chip == -1) {
  667. /* Disable the NFC clock */
  668. if (host->clk_act) {
  669. clk_disable_unprepare(host->clk);
  670. host->clk_act = 0;
  671. }
  672. return;
  673. }
  674. if (!host->clk_act) {
  675. /* Enable the NFC clock */
  676. clk_prepare_enable(host->clk);
  677. host->clk_act = 1;
  678. }
  679. host->active_cs = chip;
  680. writew(host->active_cs << 4, NFC_V1_V2_BUF_ADDR);
  681. }
  682. /*
  683. * The controller splits a page into data chunks of 512 bytes + partial oob.
  684. * There are writesize / 512 such chunks, the size of the partial oob parts is
  685. * oobsize / #chunks rounded down to a multiple of 2. The last oob chunk then
  686. * contains additionally the byte lost by rounding (if any).
  687. * This function handles the needed shuffling between host->data_buf (which
  688. * holds a page in natural order, i.e. writesize bytes data + oobsize bytes
  689. * spare) and the NFC buffer.
  690. */
  691. static void copy_spare(struct mtd_info *mtd, bool bfrom)
  692. {
  693. struct nand_chip *this = mtd->priv;
  694. struct mxc_nand_host *host = this->priv;
  695. u16 i, oob_chunk_size;
  696. u16 num_chunks = mtd->writesize / 512;
  697. u8 *d = host->data_buf + mtd->writesize;
  698. u8 __iomem *s = host->spare0;
  699. u16 sparebuf_size = host->devtype_data->spare_len;
  700. /* size of oob chunk for all but possibly the last one */
  701. oob_chunk_size = (host->used_oobsize / num_chunks) & ~1;
  702. if (bfrom) {
  703. for (i = 0; i < num_chunks - 1; i++)
  704. memcpy16_fromio(d + i * oob_chunk_size,
  705. s + i * sparebuf_size,
  706. oob_chunk_size);
  707. /* the last chunk */
  708. memcpy16_fromio(d + i * oob_chunk_size,
  709. s + i * sparebuf_size,
  710. host->used_oobsize - i * oob_chunk_size);
  711. } else {
  712. for (i = 0; i < num_chunks - 1; i++)
  713. memcpy16_toio(&s[i * sparebuf_size],
  714. &d[i * oob_chunk_size],
  715. oob_chunk_size);
  716. /* the last chunk */
  717. memcpy16_toio(&s[i * sparebuf_size],
  718. &d[i * oob_chunk_size],
  719. host->used_oobsize - i * oob_chunk_size);
  720. }
  721. }
  722. /*
  723. * MXC NANDFC can only perform full page+spare or spare-only read/write. When
  724. * the upper layers perform a read/write buf operation, the saved column address
  725. * is used to index into the full page. So usually this function is called with
  726. * column == 0 (unless no column cycle is needed indicated by column == -1)
  727. */
  728. static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
  729. {
  730. struct nand_chip *nand_chip = mtd->priv;
  731. struct mxc_nand_host *host = nand_chip->priv;
  732. /* Write out column address, if necessary */
  733. if (column != -1) {
  734. host->devtype_data->send_addr(host, column & 0xff,
  735. page_addr == -1);
  736. if (mtd->writesize > 512)
  737. /* another col addr cycle for 2k page */
  738. host->devtype_data->send_addr(host,
  739. (column >> 8) & 0xff,
  740. false);
  741. }
  742. /* Write out page address, if necessary */
  743. if (page_addr != -1) {
  744. /* paddr_0 - p_addr_7 */
  745. host->devtype_data->send_addr(host, (page_addr & 0xff), false);
  746. if (mtd->writesize > 512) {
  747. if (mtd->size >= 0x10000000) {
  748. /* paddr_8 - paddr_15 */
  749. host->devtype_data->send_addr(host,
  750. (page_addr >> 8) & 0xff,
  751. false);
  752. host->devtype_data->send_addr(host,
  753. (page_addr >> 16) & 0xff,
  754. true);
  755. } else
  756. /* paddr_8 - paddr_15 */
  757. host->devtype_data->send_addr(host,
  758. (page_addr >> 8) & 0xff, true);
  759. } else {
  760. /* One more address cycle for higher density devices */
  761. if (mtd->size >= 0x4000000) {
  762. /* paddr_8 - paddr_15 */
  763. host->devtype_data->send_addr(host,
  764. (page_addr >> 8) & 0xff,
  765. false);
  766. host->devtype_data->send_addr(host,
  767. (page_addr >> 16) & 0xff,
  768. true);
  769. } else
  770. /* paddr_8 - paddr_15 */
  771. host->devtype_data->send_addr(host,
  772. (page_addr >> 8) & 0xff, true);
  773. }
  774. }
  775. }
  776. /*
  777. * v2 and v3 type controllers can do 4bit or 8bit ecc depending
  778. * on how much oob the nand chip has. For 8bit ecc we need at least
  779. * 26 bytes of oob data per 512 byte block.
  780. */
  781. static int get_eccsize(struct mtd_info *mtd)
  782. {
  783. int oobbytes_per_512 = 0;
  784. oobbytes_per_512 = mtd->oobsize * 512 / mtd->writesize;
  785. if (oobbytes_per_512 < 26)
  786. return 4;
  787. else
  788. return 8;
  789. }
  790. static void ecc_8bit_layout_4k(struct nand_ecclayout *layout)
  791. {
  792. int i, j;
  793. layout->eccbytes = 8*18;
  794. for (i = 0; i < 8; i++)
  795. for (j = 0; j < 18; j++)
  796. layout->eccpos[i*18 + j] = i*26 + j + 7;
  797. layout->oobfree[0].offset = 2;
  798. layout->oobfree[0].length = 4;
  799. for (i = 1; i < 8; i++) {
  800. layout->oobfree[i].offset = i*26;
  801. layout->oobfree[i].length = 7;
  802. }
  803. }
  804. static void preset_v1(struct mtd_info *mtd)
  805. {
  806. struct nand_chip *nand_chip = mtd->priv;
  807. struct mxc_nand_host *host = nand_chip->priv;
  808. uint16_t config1 = 0;
  809. if (nand_chip->ecc.mode == NAND_ECC_HW && mtd->writesize)
  810. config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
  811. if (!host->devtype_data->irqpending_quirk)
  812. config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
  813. host->eccsize = 1;
  814. writew(config1, NFC_V1_V2_CONFIG1);
  815. /* preset operation */
  816. /* Unlock the internal RAM Buffer */
  817. writew(0x2, NFC_V1_V2_CONFIG);
  818. /* Blocks to be unlocked */
  819. writew(0x0, NFC_V1_UNLOCKSTART_BLKADDR);
  820. writew(0xffff, NFC_V1_UNLOCKEND_BLKADDR);
  821. /* Unlock Block Command for given address range */
  822. writew(0x4, NFC_V1_V2_WRPROT);
  823. }
  824. static void preset_v2(struct mtd_info *mtd)
  825. {
  826. struct nand_chip *nand_chip = mtd->priv;
  827. struct mxc_nand_host *host = nand_chip->priv;
  828. uint16_t config1 = 0;
  829. config1 |= NFC_V2_CONFIG1_FP_INT;
  830. if (!host->devtype_data->irqpending_quirk)
  831. config1 |= NFC_V1_V2_CONFIG1_INT_MSK;
  832. if (mtd->writesize) {
  833. uint16_t pages_per_block = mtd->erasesize / mtd->writesize;
  834. if (nand_chip->ecc.mode == NAND_ECC_HW)
  835. config1 |= NFC_V1_V2_CONFIG1_ECC_EN;
  836. host->eccsize = get_eccsize(mtd);
  837. if (host->eccsize == 4)
  838. config1 |= NFC_V2_CONFIG1_ECC_MODE_4;
  839. config1 |= NFC_V2_CONFIG1_PPB(ffs(pages_per_block) - 6);
  840. } else {
  841. host->eccsize = 1;
  842. }
  843. writew(config1, NFC_V1_V2_CONFIG1);
  844. /* preset operation */
  845. /* spare area size in 16-bit half-words */
  846. writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
  847. /* Unlock the internal RAM Buffer */
  848. writew(0x2, NFC_V1_V2_CONFIG);
  849. /* Blocks to be unlocked */
  850. writew(0x0, NFC_V21_UNLOCKSTART_BLKADDR0);
  851. writew(0x0, NFC_V21_UNLOCKSTART_BLKADDR1);
  852. writew(0x0, NFC_V21_UNLOCKSTART_BLKADDR2);
  853. writew(0x0, NFC_V21_UNLOCKSTART_BLKADDR3);
  854. writew(0xffff, NFC_V21_UNLOCKEND_BLKADDR0);
  855. writew(0xffff, NFC_V21_UNLOCKEND_BLKADDR1);
  856. writew(0xffff, NFC_V21_UNLOCKEND_BLKADDR2);
  857. writew(0xffff, NFC_V21_UNLOCKEND_BLKADDR3);
  858. /* Unlock Block Command for given address range */
  859. writew(0x4, NFC_V1_V2_WRPROT);
  860. }
  861. static void preset_v3(struct mtd_info *mtd)
  862. {
  863. struct nand_chip *chip = mtd->priv;
  864. struct mxc_nand_host *host = chip->priv;
  865. uint32_t config2, config3;
  866. int i, addr_phases;
  867. writel(NFC_V3_CONFIG1_RBA(0), NFC_V3_CONFIG1);
  868. writel(NFC_V3_IPC_CREQ, NFC_V3_IPC);
  869. /* Unlock the internal RAM Buffer */
  870. writel(NFC_V3_WRPROT_BLS_UNLOCK | NFC_V3_WRPROT_UNLOCK,
  871. NFC_V3_WRPROT);
  872. /* Blocks to be unlocked */
  873. for (i = 0; i < NAND_MAX_CHIPS; i++)
  874. writel(0x0 | (0xffff << 16),
  875. NFC_V3_WRPROT_UNLOCK_BLK_ADD0 + (i << 2));
  876. writel(0, NFC_V3_IPC);
  877. config2 = NFC_V3_CONFIG2_ONE_CYCLE |
  878. NFC_V3_CONFIG2_2CMD_PHASES |
  879. NFC_V3_CONFIG2_SPAS(mtd->oobsize >> 1) |
  880. NFC_V3_CONFIG2_ST_CMD(0x70) |
  881. NFC_V3_CONFIG2_INT_MSK |
  882. NFC_V3_CONFIG2_NUM_ADDR_PHASE0;
  883. addr_phases = fls(chip->pagemask) >> 3;
  884. if (mtd->writesize == 2048) {
  885. config2 |= NFC_V3_CONFIG2_PS_2048;
  886. config2 |= NFC_V3_CONFIG2_NUM_ADDR_PHASE1(addr_phases);
  887. } else if (mtd->writesize == 4096) {
  888. config2 |= NFC_V3_CONFIG2_PS_4096;
  889. config2 |= NFC_V3_CONFIG2_NUM_ADDR_PHASE1(addr_phases);
  890. } else {
  891. config2 |= NFC_V3_CONFIG2_PS_512;
  892. config2 |= NFC_V3_CONFIG2_NUM_ADDR_PHASE1(addr_phases - 1);
  893. }
  894. if (mtd->writesize) {
  895. if (chip->ecc.mode == NAND_ECC_HW)
  896. config2 |= NFC_V3_CONFIG2_ECC_EN;
  897. config2 |= NFC_V3_CONFIG2_PPB(
  898. ffs(mtd->erasesize / mtd->writesize) - 6,
  899. host->devtype_data->ppb_shift);
  900. host->eccsize = get_eccsize(mtd);
  901. if (host->eccsize == 8)
  902. config2 |= NFC_V3_CONFIG2_ECC_MODE_8;
  903. }
  904. writel(config2, NFC_V3_CONFIG2);
  905. config3 = NFC_V3_CONFIG3_NUM_OF_DEVICES(0) |
  906. NFC_V3_CONFIG3_NO_SDMA |
  907. NFC_V3_CONFIG3_RBB_MODE |
  908. NFC_V3_CONFIG3_SBB(6) | /* Reset default */
  909. NFC_V3_CONFIG3_ADD_OP(0);
  910. if (!(chip->options & NAND_BUSWIDTH_16))
  911. config3 |= NFC_V3_CONFIG3_FW8;
  912. writel(config3, NFC_V3_CONFIG3);
  913. writel(0, NFC_V3_DELAY_LINE);
  914. }
  915. /* Used by the upper layer to write command to NAND Flash for
  916. * different operations to be carried out on NAND Flash */
  917. static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
  918. int column, int page_addr)
  919. {
  920. struct nand_chip *nand_chip = mtd->priv;
  921. struct mxc_nand_host *host = nand_chip->priv;
  922. pr_debug("mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
  923. command, column, page_addr);
  924. /* Reset command state information */
  925. host->status_request = false;
  926. /* Command pre-processing step */
  927. switch (command) {
  928. case NAND_CMD_RESET:
  929. host->devtype_data->preset(mtd);
  930. host->devtype_data->send_cmd(host, command, false);
  931. break;
  932. case NAND_CMD_STATUS:
  933. host->buf_start = 0;
  934. host->status_request = true;
  935. host->devtype_data->send_cmd(host, command, true);
  936. WARN_ONCE(column != -1 || page_addr != -1,
  937. "Unexpected column/row value (cmd=%u, col=%d, row=%d)\n",
  938. command, column, page_addr);
  939. mxc_do_addr_cycle(mtd, column, page_addr);
  940. break;
  941. case NAND_CMD_READ0:
  942. case NAND_CMD_READOOB:
  943. if (command == NAND_CMD_READ0)
  944. host->buf_start = column;
  945. else
  946. host->buf_start = column + mtd->writesize;
  947. command = NAND_CMD_READ0; /* only READ0 is valid */
  948. host->devtype_data->send_cmd(host, command, false);
  949. WARN_ONCE(column < 0,
  950. "Unexpected column/row value (cmd=%u, col=%d, row=%d)\n",
  951. command, column, page_addr);
  952. mxc_do_addr_cycle(mtd, 0, page_addr);
  953. if (mtd->writesize > 512)
  954. host->devtype_data->send_cmd(host,
  955. NAND_CMD_READSTART, true);
  956. host->devtype_data->send_page(mtd, NFC_OUTPUT);
  957. memcpy32_fromio(host->data_buf, host->main_area0,
  958. mtd->writesize);
  959. copy_spare(mtd, true);
  960. break;
  961. case NAND_CMD_SEQIN:
  962. if (column >= mtd->writesize)
  963. /* call ourself to read a page */
  964. mxc_nand_command(mtd, NAND_CMD_READ0, 0, page_addr);
  965. host->buf_start = column;
  966. host->devtype_data->send_cmd(host, command, false);
  967. WARN_ONCE(column < -1,
  968. "Unexpected column/row value (cmd=%u, col=%d, row=%d)\n",
  969. command, column, page_addr);
  970. mxc_do_addr_cycle(mtd, 0, page_addr);
  971. break;
  972. case NAND_CMD_PAGEPROG:
  973. memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize);
  974. copy_spare(mtd, false);
  975. host->devtype_data->send_page(mtd, NFC_INPUT);
  976. host->devtype_data->send_cmd(host, command, true);
  977. WARN_ONCE(column != -1 || page_addr != -1,
  978. "Unexpected column/row value (cmd=%u, col=%d, row=%d)\n",
  979. command, column, page_addr);
  980. mxc_do_addr_cycle(mtd, column, page_addr);
  981. break;
  982. case NAND_CMD_READID:
  983. host->devtype_data->send_cmd(host, command, true);
  984. mxc_do_addr_cycle(mtd, column, page_addr);
  985. host->devtype_data->send_read_id(host);
  986. host->buf_start = 0;
  987. break;
  988. case NAND_CMD_ERASE1:
  989. case NAND_CMD_ERASE2:
  990. host->devtype_data->send_cmd(host, command, false);
  991. WARN_ONCE(column != -1,
  992. "Unexpected column value (cmd=%u, col=%d)\n",
  993. command, column);
  994. mxc_do_addr_cycle(mtd, column, page_addr);
  995. break;
  996. case NAND_CMD_PARAM:
  997. host->devtype_data->send_cmd(host, command, false);
  998. mxc_do_addr_cycle(mtd, column, page_addr);
  999. host->devtype_data->send_page(mtd, NFC_OUTPUT);
  1000. memcpy32_fromio(host->data_buf, host->main_area0, 512);
  1001. host->buf_start = 0;
  1002. break;
  1003. default:
  1004. WARN_ONCE(1, "Unimplemented command (cmd=%u)\n",
  1005. command);
  1006. break;
  1007. }
  1008. }
  1009. /*
  1010. * The generic flash bbt decriptors overlap with our ecc
  1011. * hardware, so define some i.MX specific ones.
  1012. */
  1013. static uint8_t bbt_pattern[] = { 'B', 'b', 't', '0' };
  1014. static uint8_t mirror_pattern[] = { '1', 't', 'b', 'B' };
  1015. static struct nand_bbt_descr bbt_main_descr = {
  1016. .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
  1017. | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
  1018. .offs = 0,
  1019. .len = 4,
  1020. .veroffs = 4,
  1021. .maxblocks = 4,
  1022. .pattern = bbt_pattern,
  1023. };
  1024. static struct nand_bbt_descr bbt_mirror_descr = {
  1025. .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
  1026. | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
  1027. .offs = 0,
  1028. .len = 4,
  1029. .veroffs = 4,
  1030. .maxblocks = 4,
  1031. .pattern = mirror_pattern,
  1032. };
  1033. /* v1 + irqpending_quirk: i.MX21 */
  1034. static const struct mxc_nand_devtype_data imx21_nand_devtype_data = {
  1035. .preset = preset_v1,
  1036. .send_cmd = send_cmd_v1_v2,
  1037. .send_addr = send_addr_v1_v2,
  1038. .send_page = send_page_v1,
  1039. .send_read_id = send_read_id_v1_v2,
  1040. .get_dev_status = get_dev_status_v1_v2,
  1041. .check_int = check_int_v1_v2,
  1042. .irq_control = irq_control_v1_v2,
  1043. .get_ecc_status = get_ecc_status_v1,
  1044. .ecclayout_512 = &nandv1_hw_eccoob_smallpage,
  1045. .ecclayout_2k = &nandv1_hw_eccoob_largepage,
  1046. .ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
  1047. .select_chip = mxc_nand_select_chip_v1_v3,
  1048. .correct_data = mxc_nand_correct_data_v1,
  1049. .irqpending_quirk = 1,
  1050. .needs_ip = 0,
  1051. .regs_offset = 0xe00,
  1052. .spare0_offset = 0x800,
  1053. .spare_len = 16,
  1054. .eccbytes = 3,
  1055. .eccsize = 1,
  1056. };
  1057. /* v1 + !irqpending_quirk: i.MX27, i.MX31 */
  1058. static const struct mxc_nand_devtype_data imx27_nand_devtype_data = {
  1059. .preset = preset_v1,
  1060. .send_cmd = send_cmd_v1_v2,
  1061. .send_addr = send_addr_v1_v2,
  1062. .send_page = send_page_v1,
  1063. .send_read_id = send_read_id_v1_v2,
  1064. .get_dev_status = get_dev_status_v1_v2,
  1065. .check_int = check_int_v1_v2,
  1066. .irq_control = irq_control_v1_v2,
  1067. .get_ecc_status = get_ecc_status_v1,
  1068. .ecclayout_512 = &nandv1_hw_eccoob_smallpage,
  1069. .ecclayout_2k = &nandv1_hw_eccoob_largepage,
  1070. .ecclayout_4k = &nandv1_hw_eccoob_smallpage, /* XXX: needs fix */
  1071. .select_chip = mxc_nand_select_chip_v1_v3,
  1072. .correct_data = mxc_nand_correct_data_v1,
  1073. .irqpending_quirk = 0,
  1074. .needs_ip = 0,
  1075. .regs_offset = 0xe00,
  1076. .spare0_offset = 0x800,
  1077. .axi_offset = 0,
  1078. .spare_len = 16,
  1079. .eccbytes = 3,
  1080. .eccsize = 1,
  1081. };
  1082. /* v21: i.MX25, i.MX35 */
  1083. static const struct mxc_nand_devtype_data imx25_nand_devtype_data = {
  1084. .preset = preset_v2,
  1085. .send_cmd = send_cmd_v1_v2,
  1086. .send_addr = send_addr_v1_v2,
  1087. .send_page = send_page_v2,
  1088. .send_read_id = send_read_id_v1_v2,
  1089. .get_dev_status = get_dev_status_v1_v2,
  1090. .check_int = check_int_v1_v2,
  1091. .irq_control = irq_control_v1_v2,
  1092. .get_ecc_status = get_ecc_status_v2,
  1093. .ecclayout_512 = &nandv2_hw_eccoob_smallpage,
  1094. .ecclayout_2k = &nandv2_hw_eccoob_largepage,
  1095. .ecclayout_4k = &nandv2_hw_eccoob_4k,
  1096. .select_chip = mxc_nand_select_chip_v2,
  1097. .correct_data = mxc_nand_correct_data_v2_v3,
  1098. .irqpending_quirk = 0,
  1099. .needs_ip = 0,
  1100. .regs_offset = 0x1e00,
  1101. .spare0_offset = 0x1000,
  1102. .axi_offset = 0,
  1103. .spare_len = 64,
  1104. .eccbytes = 9,
  1105. .eccsize = 0,
  1106. };
  1107. /* v3.2a: i.MX51 */
  1108. static const struct mxc_nand_devtype_data imx51_nand_devtype_data = {
  1109. .preset = preset_v3,
  1110. .send_cmd = send_cmd_v3,
  1111. .send_addr = send_addr_v3,
  1112. .send_page = send_page_v3,
  1113. .send_read_id = send_read_id_v3,
  1114. .get_dev_status = get_dev_status_v3,
  1115. .check_int = check_int_v3,
  1116. .irq_control = irq_control_v3,
  1117. .get_ecc_status = get_ecc_status_v3,
  1118. .ecclayout_512 = &nandv2_hw_eccoob_smallpage,
  1119. .ecclayout_2k = &nandv2_hw_eccoob_largepage,
  1120. .ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
  1121. .select_chip = mxc_nand_select_chip_v1_v3,
  1122. .correct_data = mxc_nand_correct_data_v2_v3,
  1123. .irqpending_quirk = 0,
  1124. .needs_ip = 1,
  1125. .regs_offset = 0,
  1126. .spare0_offset = 0x1000,
  1127. .axi_offset = 0x1e00,
  1128. .spare_len = 64,
  1129. .eccbytes = 0,
  1130. .eccsize = 0,
  1131. .ppb_shift = 7,
  1132. };
  1133. /* v3.2b: i.MX53 */
  1134. static const struct mxc_nand_devtype_data imx53_nand_devtype_data = {
  1135. .preset = preset_v3,
  1136. .send_cmd = send_cmd_v3,
  1137. .send_addr = send_addr_v3,
  1138. .send_page = send_page_v3,
  1139. .send_read_id = send_read_id_v3,
  1140. .get_dev_status = get_dev_status_v3,
  1141. .check_int = check_int_v3,
  1142. .irq_control = irq_control_v3,
  1143. .get_ecc_status = get_ecc_status_v3,
  1144. .ecclayout_512 = &nandv2_hw_eccoob_smallpage,
  1145. .ecclayout_2k = &nandv2_hw_eccoob_largepage,
  1146. .ecclayout_4k = &nandv2_hw_eccoob_smallpage, /* XXX: needs fix */
  1147. .select_chip = mxc_nand_select_chip_v1_v3,
  1148. .correct_data = mxc_nand_correct_data_v2_v3,
  1149. .irqpending_quirk = 0,
  1150. .needs_ip = 1,
  1151. .regs_offset = 0,
  1152. .spare0_offset = 0x1000,
  1153. .axi_offset = 0x1e00,
  1154. .spare_len = 64,
  1155. .eccbytes = 0,
  1156. .eccsize = 0,
  1157. .ppb_shift = 8,
  1158. };
  1159. static inline int is_imx21_nfc(struct mxc_nand_host *host)
  1160. {
  1161. return host->devtype_data == &imx21_nand_devtype_data;
  1162. }
  1163. static inline int is_imx27_nfc(struct mxc_nand_host *host)
  1164. {
  1165. return host->devtype_data == &imx27_nand_devtype_data;
  1166. }
  1167. static inline int is_imx25_nfc(struct mxc_nand_host *host)
  1168. {
  1169. return host->devtype_data == &imx25_nand_devtype_data;
  1170. }
  1171. static inline int is_imx51_nfc(struct mxc_nand_host *host)
  1172. {
  1173. return host->devtype_data == &imx51_nand_devtype_data;
  1174. }
  1175. static inline int is_imx53_nfc(struct mxc_nand_host *host)
  1176. {
  1177. return host->devtype_data == &imx53_nand_devtype_data;
  1178. }
  1179. static const struct platform_device_id mxcnd_devtype[] = {
  1180. {
  1181. .name = "imx21-nand",
  1182. .driver_data = (kernel_ulong_t) &imx21_nand_devtype_data,
  1183. }, {
  1184. .name = "imx27-nand",
  1185. .driver_data = (kernel_ulong_t) &imx27_nand_devtype_data,
  1186. }, {
  1187. .name = "imx25-nand",
  1188. .driver_data = (kernel_ulong_t) &imx25_nand_devtype_data,
  1189. }, {
  1190. .name = "imx51-nand",
  1191. .driver_data = (kernel_ulong_t) &imx51_nand_devtype_data,
  1192. }, {
  1193. .name = "imx53-nand",
  1194. .driver_data = (kernel_ulong_t) &imx53_nand_devtype_data,
  1195. }, {
  1196. /* sentinel */
  1197. }
  1198. };
  1199. MODULE_DEVICE_TABLE(platform, mxcnd_devtype);
  1200. #ifdef CONFIG_OF_MTD
  1201. static const struct of_device_id mxcnd_dt_ids[] = {
  1202. {
  1203. .compatible = "fsl,imx21-nand",
  1204. .data = &imx21_nand_devtype_data,
  1205. }, {
  1206. .compatible = "fsl,imx27-nand",
  1207. .data = &imx27_nand_devtype_data,
  1208. }, {
  1209. .compatible = "fsl,imx25-nand",
  1210. .data = &imx25_nand_devtype_data,
  1211. }, {
  1212. .compatible = "fsl,imx51-nand",
  1213. .data = &imx51_nand_devtype_data,
  1214. }, {
  1215. .compatible = "fsl,imx53-nand",
  1216. .data = &imx53_nand_devtype_data,
  1217. },
  1218. { /* sentinel */ }
  1219. };
  1220. MODULE_DEVICE_TABLE(of, mxcnd_dt_ids);
  1221. static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
  1222. {
  1223. struct device_node *np = host->dev->of_node;
  1224. struct mxc_nand_platform_data *pdata = &host->pdata;
  1225. const struct of_device_id *of_id =
  1226. of_match_device(mxcnd_dt_ids, host->dev);
  1227. int buswidth;
  1228. if (!np)
  1229. return 1;
  1230. if (of_get_nand_ecc_mode(np) >= 0)
  1231. pdata->hw_ecc = 1;
  1232. pdata->flash_bbt = of_get_nand_on_flash_bbt(np);
  1233. buswidth = of_get_nand_bus_width(np);
  1234. if (buswidth < 0)
  1235. return buswidth;
  1236. pdata->width = buswidth / 8;
  1237. host->devtype_data = of_id->data;
  1238. return 0;
  1239. }
  1240. #else
  1241. static int __init mxcnd_probe_dt(struct mxc_nand_host *host)
  1242. {
  1243. return 1;
  1244. }
  1245. #endif
  1246. static int mxcnd_probe(struct platform_device *pdev)
  1247. {
  1248. struct nand_chip *this;
  1249. struct mtd_info *mtd;
  1250. struct mxc_nand_host *host;
  1251. struct resource *res;
  1252. int err = 0;
  1253. /* Allocate memory for MTD device structure and private data */
  1254. host = devm_kzalloc(&pdev->dev, sizeof(struct mxc_nand_host),
  1255. GFP_KERNEL);
  1256. if (!host)
  1257. return -ENOMEM;
  1258. /* allocate a temporary buffer for the nand_scan_ident() */
  1259. host->data_buf = devm_kzalloc(&pdev->dev, PAGE_SIZE, GFP_KERNEL);
  1260. if (!host->data_buf)
  1261. return -ENOMEM;
  1262. host->dev = &pdev->dev;
  1263. /* structures must be linked */
  1264. this = &host->nand;
  1265. mtd = &host->mtd;
  1266. mtd->priv = this;
  1267. mtd->dev.parent = &pdev->dev;
  1268. mtd->name = DRIVER_NAME;
  1269. /* 50 us command delay time */
  1270. this->chip_delay = 5;
  1271. this->priv = host;
  1272. this->dev_ready = mxc_nand_dev_ready;
  1273. this->cmdfunc = mxc_nand_command;
  1274. this->read_byte = mxc_nand_read_byte;
  1275. this->read_word = mxc_nand_read_word;
  1276. this->write_buf = mxc_nand_write_buf;
  1277. this->read_buf = mxc_nand_read_buf;
  1278. host->clk = devm_clk_get(&pdev->dev, NULL);
  1279. if (IS_ERR(host->clk))
  1280. return PTR_ERR(host->clk);
  1281. err = mxcnd_probe_dt(host);
  1282. if (err > 0) {
  1283. struct mxc_nand_platform_data *pdata =
  1284. dev_get_platdata(&pdev->dev);
  1285. if (pdata) {
  1286. host->pdata = *pdata;
  1287. host->devtype_data = (struct mxc_nand_devtype_data *)
  1288. pdev->id_entry->driver_data;
  1289. } else {
  1290. err = -ENODEV;
  1291. }
  1292. }
  1293. if (err < 0)
  1294. return err;
  1295. if (host->devtype_data->needs_ip) {
  1296. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1297. host->regs_ip = devm_ioremap_resource(&pdev->dev, res);
  1298. if (IS_ERR(host->regs_ip))
  1299. return PTR_ERR(host->regs_ip);
  1300. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  1301. } else {
  1302. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1303. }
  1304. host->base = devm_ioremap_resource(&pdev->dev, res);
  1305. if (IS_ERR(host->base))
  1306. return PTR_ERR(host->base);
  1307. host->main_area0 = host->base;
  1308. if (host->devtype_data->regs_offset)
  1309. host->regs = host->base + host->devtype_data->regs_offset;
  1310. host->spare0 = host->base + host->devtype_data->spare0_offset;
  1311. if (host->devtype_data->axi_offset)
  1312. host->regs_axi = host->base + host->devtype_data->axi_offset;
  1313. this->ecc.bytes = host->devtype_data->eccbytes;
  1314. host->eccsize = host->devtype_data->eccsize;
  1315. this->select_chip = host->devtype_data->select_chip;
  1316. this->ecc.size = 512;
  1317. this->ecc.layout = host->devtype_data->ecclayout_512;
  1318. if (host->pdata.hw_ecc) {
  1319. this->ecc.calculate = mxc_nand_calculate_ecc;
  1320. this->ecc.hwctl = mxc_nand_enable_hwecc;
  1321. this->ecc.correct = host->devtype_data->correct_data;
  1322. this->ecc.mode = NAND_ECC_HW;
  1323. } else {
  1324. this->ecc.mode = NAND_ECC_SOFT;
  1325. }
  1326. /* NAND bus width determines access functions used by upper layer */
  1327. if (host->pdata.width == 2)
  1328. this->options |= NAND_BUSWIDTH_16;
  1329. if (host->pdata.flash_bbt) {
  1330. this->bbt_td = &bbt_main_descr;
  1331. this->bbt_md = &bbt_mirror_descr;
  1332. /* update flash based bbt */
  1333. this->bbt_options |= NAND_BBT_USE_FLASH;
  1334. }
  1335. init_completion(&host->op_completion);
  1336. host->irq = platform_get_irq(pdev, 0);
  1337. if (host->irq < 0)
  1338. return host->irq;
  1339. /*
  1340. * Use host->devtype_data->irq_control() here instead of irq_control()
  1341. * because we must not disable_irq_nosync without having requested the
  1342. * irq.
  1343. */
  1344. host->devtype_data->irq_control(host, 0);
  1345. err = devm_request_irq(&pdev->dev, host->irq, mxc_nfc_irq,
  1346. 0, DRIVER_NAME, host);
  1347. if (err)
  1348. return err;
  1349. err = clk_prepare_enable(host->clk);
  1350. if (err)
  1351. return err;
  1352. host->clk_act = 1;
  1353. /*
  1354. * Now that we "own" the interrupt make sure the interrupt mask bit is
  1355. * cleared on i.MX21. Otherwise we can't read the interrupt status bit
  1356. * on this machine.
  1357. */
  1358. if (host->devtype_data->irqpending_quirk) {
  1359. disable_irq_nosync(host->irq);
  1360. host->devtype_data->irq_control(host, 1);
  1361. }
  1362. /* first scan to find the device and get the page size */
  1363. if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) {
  1364. err = -ENXIO;
  1365. goto escan;
  1366. }
  1367. /* allocate the right size buffer now */
  1368. devm_kfree(&pdev->dev, (void *)host->data_buf);
  1369. host->data_buf = devm_kzalloc(&pdev->dev, mtd->writesize + mtd->oobsize,
  1370. GFP_KERNEL);
  1371. if (!host->data_buf) {
  1372. err = -ENOMEM;
  1373. goto escan;
  1374. }
  1375. /* Call preset again, with correct writesize this time */
  1376. host->devtype_data->preset(mtd);
  1377. if (mtd->writesize == 2048)
  1378. this->ecc.layout = host->devtype_data->ecclayout_2k;
  1379. else if (mtd->writesize == 4096) {
  1380. this->ecc.layout = host->devtype_data->ecclayout_4k;
  1381. if (get_eccsize(mtd) == 8)
  1382. ecc_8bit_layout_4k(this->ecc.layout);
  1383. }
  1384. /*
  1385. * Experimentation shows that i.MX NFC can only handle up to 218 oob
  1386. * bytes. Limit used_oobsize to 218 so as to not confuse copy_spare()
  1387. * into copying invalid data to/from the spare IO buffer, as this
  1388. * might cause ECC data corruption when doing sub-page write to a
  1389. * partially written page.
  1390. */
  1391. host->used_oobsize = min(mtd->oobsize, 218U);
  1392. if (this->ecc.mode == NAND_ECC_HW) {
  1393. if (is_imx21_nfc(host) || is_imx27_nfc(host))
  1394. this->ecc.strength = 1;
  1395. else
  1396. this->ecc.strength = (host->eccsize == 4) ? 4 : 8;
  1397. }
  1398. /* second phase scan */
  1399. if (nand_scan_tail(mtd)) {
  1400. err = -ENXIO;
  1401. goto escan;
  1402. }
  1403. /* Register the partitions */
  1404. mtd_device_parse_register(mtd, part_probes,
  1405. &(struct mtd_part_parser_data){
  1406. .of_node = pdev->dev.of_node,
  1407. },
  1408. host->pdata.parts,
  1409. host->pdata.nr_parts);
  1410. platform_set_drvdata(pdev, host);
  1411. return 0;
  1412. escan:
  1413. if (host->clk_act)
  1414. clk_disable_unprepare(host->clk);
  1415. return err;
  1416. }
  1417. static int mxcnd_remove(struct platform_device *pdev)
  1418. {
  1419. struct mxc_nand_host *host = platform_get_drvdata(pdev);
  1420. nand_release(&host->mtd);
  1421. if (host->clk_act)
  1422. clk_disable_unprepare(host->clk);
  1423. return 0;
  1424. }
  1425. static struct platform_driver mxcnd_driver = {
  1426. .driver = {
  1427. .name = DRIVER_NAME,
  1428. .of_match_table = of_match_ptr(mxcnd_dt_ids),
  1429. },
  1430. .id_table = mxcnd_devtype,
  1431. .probe = mxcnd_probe,
  1432. .remove = mxcnd_remove,
  1433. };
  1434. module_platform_driver(mxcnd_driver);
  1435. MODULE_AUTHOR("Freescale Semiconductor, Inc.");
  1436. MODULE_DESCRIPTION("MXC NAND MTD driver");
  1437. MODULE_LICENSE("GPL");