fsl_ifc_nand.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  1. /*
  2. * Freescale Integrated Flash Controller NAND driver
  3. *
  4. * Copyright 2011-2012 Freescale Semiconductor, Inc
  5. *
  6. * Author: Dipen Dudhat <Dipen.Dudhat@freescale.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/module.h>
  23. #include <linux/types.h>
  24. #include <linux/init.h>
  25. #include <linux/kernel.h>
  26. #include <linux/slab.h>
  27. #include <linux/mtd/mtd.h>
  28. #include <linux/mtd/nand.h>
  29. #include <linux/mtd/partitions.h>
  30. #include <linux/mtd/nand_ecc.h>
  31. #include <asm/fsl_ifc.h>
  32. #define ERR_BYTE 0xFF /* Value returned for read
  33. bytes when read failed */
  34. #define IFC_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait
  35. for IFC NAND Machine */
  36. struct fsl_ifc_ctrl;
  37. /* mtd information per set */
  38. struct fsl_ifc_mtd {
  39. struct mtd_info mtd;
  40. struct nand_chip chip;
  41. struct fsl_ifc_ctrl *ctrl;
  42. struct device *dev;
  43. int bank; /* Chip select bank number */
  44. unsigned int bufnum_mask; /* bufnum = page & bufnum_mask */
  45. u8 __iomem *vbase; /* Chip select base virtual address */
  46. };
  47. /* overview of the fsl ifc controller */
  48. struct fsl_ifc_nand_ctrl {
  49. struct nand_hw_control controller;
  50. struct fsl_ifc_mtd *chips[FSL_IFC_BANK_COUNT];
  51. u8 __iomem *addr; /* Address of assigned IFC buffer */
  52. unsigned int page; /* Last page written to / read from */
  53. unsigned int read_bytes;/* Number of bytes read during command */
  54. unsigned int column; /* Saved column from SEQIN */
  55. unsigned int index; /* Pointer to next byte to 'read' */
  56. unsigned int oob; /* Non zero if operating on OOB data */
  57. unsigned int eccread; /* Non zero for a full-page ECC read */
  58. unsigned int counter; /* counter for the initializations */
  59. unsigned int max_bitflips; /* Saved during READ0 cmd */
  60. };
  61. static struct fsl_ifc_nand_ctrl *ifc_nand_ctrl;
  62. /* 512-byte page with 4-bit ECC, 8-bit */
  63. static struct nand_ecclayout oob_512_8bit_ecc4 = {
  64. .eccbytes = 8,
  65. .eccpos = {8, 9, 10, 11, 12, 13, 14, 15},
  66. .oobfree = { {0, 5}, {6, 2} },
  67. };
  68. /* 512-byte page with 4-bit ECC, 16-bit */
  69. static struct nand_ecclayout oob_512_16bit_ecc4 = {
  70. .eccbytes = 8,
  71. .eccpos = {8, 9, 10, 11, 12, 13, 14, 15},
  72. .oobfree = { {2, 6}, },
  73. };
  74. /* 2048-byte page size with 4-bit ECC */
  75. static struct nand_ecclayout oob_2048_ecc4 = {
  76. .eccbytes = 32,
  77. .eccpos = {
  78. 8, 9, 10, 11, 12, 13, 14, 15,
  79. 16, 17, 18, 19, 20, 21, 22, 23,
  80. 24, 25, 26, 27, 28, 29, 30, 31,
  81. 32, 33, 34, 35, 36, 37, 38, 39,
  82. },
  83. .oobfree = { {2, 6}, {40, 24} },
  84. };
  85. /* 4096-byte page size with 4-bit ECC */
  86. static struct nand_ecclayout oob_4096_ecc4 = {
  87. .eccbytes = 64,
  88. .eccpos = {
  89. 8, 9, 10, 11, 12, 13, 14, 15,
  90. 16, 17, 18, 19, 20, 21, 22, 23,
  91. 24, 25, 26, 27, 28, 29, 30, 31,
  92. 32, 33, 34, 35, 36, 37, 38, 39,
  93. 40, 41, 42, 43, 44, 45, 46, 47,
  94. 48, 49, 50, 51, 52, 53, 54, 55,
  95. 56, 57, 58, 59, 60, 61, 62, 63,
  96. 64, 65, 66, 67, 68, 69, 70, 71,
  97. },
  98. .oobfree = { {2, 6}, {72, 56} },
  99. };
  100. /* 4096-byte page size with 8-bit ECC -- requires 218-byte OOB */
  101. static struct nand_ecclayout oob_4096_ecc8 = {
  102. .eccbytes = 128,
  103. .eccpos = {
  104. 8, 9, 10, 11, 12, 13, 14, 15,
  105. 16, 17, 18, 19, 20, 21, 22, 23,
  106. 24, 25, 26, 27, 28, 29, 30, 31,
  107. 32, 33, 34, 35, 36, 37, 38, 39,
  108. 40, 41, 42, 43, 44, 45, 46, 47,
  109. 48, 49, 50, 51, 52, 53, 54, 55,
  110. 56, 57, 58, 59, 60, 61, 62, 63,
  111. 64, 65, 66, 67, 68, 69, 70, 71,
  112. 72, 73, 74, 75, 76, 77, 78, 79,
  113. 80, 81, 82, 83, 84, 85, 86, 87,
  114. 88, 89, 90, 91, 92, 93, 94, 95,
  115. 96, 97, 98, 99, 100, 101, 102, 103,
  116. 104, 105, 106, 107, 108, 109, 110, 111,
  117. 112, 113, 114, 115, 116, 117, 118, 119,
  118. 120, 121, 122, 123, 124, 125, 126, 127,
  119. 128, 129, 130, 131, 132, 133, 134, 135,
  120. },
  121. .oobfree = { {2, 6}, {136, 82} },
  122. };
  123. /*
  124. * Generic flash bbt descriptors
  125. */
  126. static u8 bbt_pattern[] = {'B', 'b', 't', '0' };
  127. static u8 mirror_pattern[] = {'1', 't', 'b', 'B' };
  128. static struct nand_bbt_descr bbt_main_descr = {
  129. .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
  130. NAND_BBT_2BIT | NAND_BBT_VERSION,
  131. .offs = 2, /* 0 on 8-bit small page */
  132. .len = 4,
  133. .veroffs = 6,
  134. .maxblocks = 4,
  135. .pattern = bbt_pattern,
  136. };
  137. static struct nand_bbt_descr bbt_mirror_descr = {
  138. .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
  139. NAND_BBT_2BIT | NAND_BBT_VERSION,
  140. .offs = 2, /* 0 on 8-bit small page */
  141. .len = 4,
  142. .veroffs = 6,
  143. .maxblocks = 4,
  144. .pattern = mirror_pattern,
  145. };
  146. /*
  147. * Set up the IFC hardware block and page address fields, and the ifc nand
  148. * structure addr field to point to the correct IFC buffer in memory
  149. */
  150. static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
  151. {
  152. struct nand_chip *chip = mtd->priv;
  153. struct fsl_ifc_mtd *priv = chip->priv;
  154. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  155. struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  156. int buf_num;
  157. ifc_nand_ctrl->page = page_addr;
  158. /* Program ROW0/COL0 */
  159. out_be32(&ifc->ifc_nand.row0, page_addr);
  160. out_be32(&ifc->ifc_nand.col0, (oob ? IFC_NAND_COL_MS : 0) | column);
  161. buf_num = page_addr & priv->bufnum_mask;
  162. ifc_nand_ctrl->addr = priv->vbase + buf_num * (mtd->writesize * 2);
  163. ifc_nand_ctrl->index = column;
  164. /* for OOB data point to the second half of the buffer */
  165. if (oob)
  166. ifc_nand_ctrl->index += mtd->writesize;
  167. }
  168. static int is_blank(struct mtd_info *mtd, unsigned int bufnum)
  169. {
  170. struct nand_chip *chip = mtd->priv;
  171. struct fsl_ifc_mtd *priv = chip->priv;
  172. u8 __iomem *addr = priv->vbase + bufnum * (mtd->writesize * 2);
  173. u32 __iomem *mainarea = (u32 *)addr;
  174. u8 __iomem *oob = addr + mtd->writesize;
  175. int i;
  176. for (i = 0; i < mtd->writesize / 4; i++) {
  177. if (__raw_readl(&mainarea[i]) != 0xffffffff)
  178. return 0;
  179. }
  180. for (i = 0; i < chip->ecc.layout->eccbytes; i++) {
  181. int pos = chip->ecc.layout->eccpos[i];
  182. if (__raw_readb(&oob[pos]) != 0xff)
  183. return 0;
  184. }
  185. return 1;
  186. }
  187. /* returns nonzero if entire page is blank */
  188. static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl,
  189. u32 *eccstat, unsigned int bufnum)
  190. {
  191. u32 reg = eccstat[bufnum / 4];
  192. int errors;
  193. errors = (reg >> ((3 - bufnum % 4) * 8)) & 15;
  194. return errors;
  195. }
  196. /*
  197. * execute IFC NAND command and wait for it to complete
  198. */
  199. static void fsl_ifc_run_command(struct mtd_info *mtd)
  200. {
  201. struct nand_chip *chip = mtd->priv;
  202. struct fsl_ifc_mtd *priv = chip->priv;
  203. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  204. struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
  205. struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  206. u32 eccstat[4];
  207. int i;
  208. /* set the chip select for NAND Transaction */
  209. out_be32(&ifc->ifc_nand.nand_csel, priv->bank << IFC_NAND_CSEL_SHIFT);
  210. dev_vdbg(priv->dev,
  211. "%s: fir0=%08x fcr0=%08x\n",
  212. __func__,
  213. in_be32(&ifc->ifc_nand.nand_fir0),
  214. in_be32(&ifc->ifc_nand.nand_fcr0));
  215. ctrl->nand_stat = 0;
  216. /* start read/write seq */
  217. out_be32(&ifc->ifc_nand.nandseq_strt, IFC_NAND_SEQ_STRT_FIR_STRT);
  218. /* wait for command complete flag or timeout */
  219. wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat,
  220. IFC_TIMEOUT_MSECS * HZ/1000);
  221. /* ctrl->nand_stat will be updated from IRQ context */
  222. if (!ctrl->nand_stat)
  223. dev_err(priv->dev, "Controller is not responding\n");
  224. if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_FTOER)
  225. dev_err(priv->dev, "NAND Flash Timeout Error\n");
  226. if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_WPER)
  227. dev_err(priv->dev, "NAND Flash Write Protect Error\n");
  228. nctrl->max_bitflips = 0;
  229. if (nctrl->eccread) {
  230. int errors;
  231. int bufnum = nctrl->page & priv->bufnum_mask;
  232. int sector = bufnum * chip->ecc.steps;
  233. int sector_end = sector + chip->ecc.steps - 1;
  234. for (i = sector / 4; i <= sector_end / 4; i++)
  235. eccstat[i] = in_be32(&ifc->ifc_nand.nand_eccstat[i]);
  236. for (i = sector; i <= sector_end; i++) {
  237. errors = check_read_ecc(mtd, ctrl, eccstat, i);
  238. if (errors == 15) {
  239. /*
  240. * Uncorrectable error.
  241. * OK only if the whole page is blank.
  242. *
  243. * We disable ECCER reporting due to...
  244. * erratum IFC-A002770 -- so report it now if we
  245. * see an uncorrectable error in ECCSTAT.
  246. */
  247. if (!is_blank(mtd, bufnum))
  248. ctrl->nand_stat |=
  249. IFC_NAND_EVTER_STAT_ECCER;
  250. break;
  251. }
  252. mtd->ecc_stats.corrected += errors;
  253. nctrl->max_bitflips = max_t(unsigned int,
  254. nctrl->max_bitflips,
  255. errors);
  256. }
  257. nctrl->eccread = 0;
  258. }
  259. }
  260. static void fsl_ifc_do_read(struct nand_chip *chip,
  261. int oob,
  262. struct mtd_info *mtd)
  263. {
  264. struct fsl_ifc_mtd *priv = chip->priv;
  265. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  266. struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  267. /* Program FIR/IFC_NAND_FCR0 for Small/Large page */
  268. if (mtd->writesize > 512) {
  269. out_be32(&ifc->ifc_nand.nand_fir0,
  270. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  271. (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) |
  272. (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) |
  273. (IFC_FIR_OP_CMD1 << IFC_NAND_FIR0_OP3_SHIFT) |
  274. (IFC_FIR_OP_RBCD << IFC_NAND_FIR0_OP4_SHIFT));
  275. out_be32(&ifc->ifc_nand.nand_fir1, 0x0);
  276. out_be32(&ifc->ifc_nand.nand_fcr0,
  277. (NAND_CMD_READ0 << IFC_NAND_FCR0_CMD0_SHIFT) |
  278. (NAND_CMD_READSTART << IFC_NAND_FCR0_CMD1_SHIFT));
  279. } else {
  280. out_be32(&ifc->ifc_nand.nand_fir0,
  281. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  282. (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) |
  283. (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) |
  284. (IFC_FIR_OP_RBCD << IFC_NAND_FIR0_OP3_SHIFT));
  285. out_be32(&ifc->ifc_nand.nand_fir1, 0x0);
  286. if (oob)
  287. out_be32(&ifc->ifc_nand.nand_fcr0,
  288. NAND_CMD_READOOB << IFC_NAND_FCR0_CMD0_SHIFT);
  289. else
  290. out_be32(&ifc->ifc_nand.nand_fcr0,
  291. NAND_CMD_READ0 << IFC_NAND_FCR0_CMD0_SHIFT);
  292. }
  293. }
  294. /* cmdfunc send commands to the IFC NAND Machine */
  295. static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
  296. int column, int page_addr) {
  297. struct nand_chip *chip = mtd->priv;
  298. struct fsl_ifc_mtd *priv = chip->priv;
  299. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  300. struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  301. /* clear the read buffer */
  302. ifc_nand_ctrl->read_bytes = 0;
  303. if (command != NAND_CMD_PAGEPROG)
  304. ifc_nand_ctrl->index = 0;
  305. switch (command) {
  306. /* READ0 read the entire buffer to use hardware ECC. */
  307. case NAND_CMD_READ0:
  308. out_be32(&ifc->ifc_nand.nand_fbcr, 0);
  309. set_addr(mtd, 0, page_addr, 0);
  310. ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize;
  311. ifc_nand_ctrl->index += column;
  312. if (chip->ecc.mode == NAND_ECC_HW)
  313. ifc_nand_ctrl->eccread = 1;
  314. fsl_ifc_do_read(chip, 0, mtd);
  315. fsl_ifc_run_command(mtd);
  316. return;
  317. /* READOOB reads only the OOB because no ECC is performed. */
  318. case NAND_CMD_READOOB:
  319. out_be32(&ifc->ifc_nand.nand_fbcr, mtd->oobsize - column);
  320. set_addr(mtd, column, page_addr, 1);
  321. ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize;
  322. fsl_ifc_do_read(chip, 1, mtd);
  323. fsl_ifc_run_command(mtd);
  324. return;
  325. case NAND_CMD_READID:
  326. case NAND_CMD_PARAM: {
  327. int timing = IFC_FIR_OP_RB;
  328. if (command == NAND_CMD_PARAM)
  329. timing = IFC_FIR_OP_RBCD;
  330. out_be32(&ifc->ifc_nand.nand_fir0,
  331. (IFC_FIR_OP_CMD0 << IFC_NAND_FIR0_OP0_SHIFT) |
  332. (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) |
  333. (timing << IFC_NAND_FIR0_OP2_SHIFT));
  334. out_be32(&ifc->ifc_nand.nand_fcr0,
  335. command << IFC_NAND_FCR0_CMD0_SHIFT);
  336. out_be32(&ifc->ifc_nand.row3, column);
  337. /*
  338. * although currently it's 8 bytes for READID, we always read
  339. * the maximum 256 bytes(for PARAM)
  340. */
  341. out_be32(&ifc->ifc_nand.nand_fbcr, 256);
  342. ifc_nand_ctrl->read_bytes = 256;
  343. set_addr(mtd, 0, 0, 0);
  344. fsl_ifc_run_command(mtd);
  345. return;
  346. }
  347. /* ERASE1 stores the block and page address */
  348. case NAND_CMD_ERASE1:
  349. set_addr(mtd, 0, page_addr, 0);
  350. return;
  351. /* ERASE2 uses the block and page address from ERASE1 */
  352. case NAND_CMD_ERASE2:
  353. out_be32(&ifc->ifc_nand.nand_fir0,
  354. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  355. (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP1_SHIFT) |
  356. (IFC_FIR_OP_CMD1 << IFC_NAND_FIR0_OP2_SHIFT));
  357. out_be32(&ifc->ifc_nand.nand_fcr0,
  358. (NAND_CMD_ERASE1 << IFC_NAND_FCR0_CMD0_SHIFT) |
  359. (NAND_CMD_ERASE2 << IFC_NAND_FCR0_CMD1_SHIFT));
  360. out_be32(&ifc->ifc_nand.nand_fbcr, 0);
  361. ifc_nand_ctrl->read_bytes = 0;
  362. fsl_ifc_run_command(mtd);
  363. return;
  364. /* SEQIN sets up the addr buffer and all registers except the length */
  365. case NAND_CMD_SEQIN: {
  366. u32 nand_fcr0;
  367. ifc_nand_ctrl->column = column;
  368. ifc_nand_ctrl->oob = 0;
  369. if (mtd->writesize > 512) {
  370. nand_fcr0 =
  371. (NAND_CMD_SEQIN << IFC_NAND_FCR0_CMD0_SHIFT) |
  372. (NAND_CMD_PAGEPROG << IFC_NAND_FCR0_CMD1_SHIFT);
  373. out_be32(&ifc->ifc_nand.nand_fir0,
  374. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  375. (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) |
  376. (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) |
  377. (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP3_SHIFT) |
  378. (IFC_FIR_OP_CW1 << IFC_NAND_FIR0_OP4_SHIFT));
  379. } else {
  380. nand_fcr0 = ((NAND_CMD_PAGEPROG <<
  381. IFC_NAND_FCR0_CMD1_SHIFT) |
  382. (NAND_CMD_SEQIN <<
  383. IFC_NAND_FCR0_CMD2_SHIFT));
  384. out_be32(&ifc->ifc_nand.nand_fir0,
  385. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  386. (IFC_FIR_OP_CMD2 << IFC_NAND_FIR0_OP1_SHIFT) |
  387. (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP2_SHIFT) |
  388. (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP3_SHIFT) |
  389. (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP4_SHIFT));
  390. out_be32(&ifc->ifc_nand.nand_fir1,
  391. (IFC_FIR_OP_CW1 << IFC_NAND_FIR1_OP5_SHIFT));
  392. if (column >= mtd->writesize)
  393. nand_fcr0 |=
  394. NAND_CMD_READOOB << IFC_NAND_FCR0_CMD0_SHIFT;
  395. else
  396. nand_fcr0 |=
  397. NAND_CMD_READ0 << IFC_NAND_FCR0_CMD0_SHIFT;
  398. }
  399. if (column >= mtd->writesize) {
  400. /* OOB area --> READOOB */
  401. column -= mtd->writesize;
  402. ifc_nand_ctrl->oob = 1;
  403. }
  404. out_be32(&ifc->ifc_nand.nand_fcr0, nand_fcr0);
  405. set_addr(mtd, column, page_addr, ifc_nand_ctrl->oob);
  406. return;
  407. }
  408. /* PAGEPROG reuses all of the setup from SEQIN and adds the length */
  409. case NAND_CMD_PAGEPROG: {
  410. if (ifc_nand_ctrl->oob) {
  411. out_be32(&ifc->ifc_nand.nand_fbcr,
  412. ifc_nand_ctrl->index - ifc_nand_ctrl->column);
  413. } else {
  414. out_be32(&ifc->ifc_nand.nand_fbcr, 0);
  415. }
  416. fsl_ifc_run_command(mtd);
  417. return;
  418. }
  419. case NAND_CMD_STATUS:
  420. out_be32(&ifc->ifc_nand.nand_fir0,
  421. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  422. (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP1_SHIFT));
  423. out_be32(&ifc->ifc_nand.nand_fcr0,
  424. NAND_CMD_STATUS << IFC_NAND_FCR0_CMD0_SHIFT);
  425. out_be32(&ifc->ifc_nand.nand_fbcr, 1);
  426. set_addr(mtd, 0, 0, 0);
  427. ifc_nand_ctrl->read_bytes = 1;
  428. fsl_ifc_run_command(mtd);
  429. /*
  430. * The chip always seems to report that it is
  431. * write-protected, even when it is not.
  432. */
  433. setbits8(ifc_nand_ctrl->addr, NAND_STATUS_WP);
  434. return;
  435. case NAND_CMD_RESET:
  436. out_be32(&ifc->ifc_nand.nand_fir0,
  437. IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT);
  438. out_be32(&ifc->ifc_nand.nand_fcr0,
  439. NAND_CMD_RESET << IFC_NAND_FCR0_CMD0_SHIFT);
  440. fsl_ifc_run_command(mtd);
  441. return;
  442. default:
  443. dev_err(priv->dev, "%s: error, unsupported command 0x%x.\n",
  444. __func__, command);
  445. }
  446. }
  447. static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip)
  448. {
  449. /* The hardware does not seem to support multiple
  450. * chips per bank.
  451. */
  452. }
  453. /*
  454. * Write buf to the IFC NAND Controller Data Buffer
  455. */
  456. static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
  457. {
  458. struct nand_chip *chip = mtd->priv;
  459. struct fsl_ifc_mtd *priv = chip->priv;
  460. unsigned int bufsize = mtd->writesize + mtd->oobsize;
  461. if (len <= 0) {
  462. dev_err(priv->dev, "%s: len %d bytes", __func__, len);
  463. return;
  464. }
  465. if ((unsigned int)len > bufsize - ifc_nand_ctrl->index) {
  466. dev_err(priv->dev,
  467. "%s: beyond end of buffer (%d requested, %u available)\n",
  468. __func__, len, bufsize - ifc_nand_ctrl->index);
  469. len = bufsize - ifc_nand_ctrl->index;
  470. }
  471. memcpy_toio(&ifc_nand_ctrl->addr[ifc_nand_ctrl->index], buf, len);
  472. ifc_nand_ctrl->index += len;
  473. }
  474. /*
  475. * Read a byte from either the IFC hardware buffer
  476. * read function for 8-bit buswidth
  477. */
  478. static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)
  479. {
  480. struct nand_chip *chip = mtd->priv;
  481. struct fsl_ifc_mtd *priv = chip->priv;
  482. /*
  483. * If there are still bytes in the IFC buffer, then use the
  484. * next byte.
  485. */
  486. if (ifc_nand_ctrl->index < ifc_nand_ctrl->read_bytes)
  487. return in_8(&ifc_nand_ctrl->addr[ifc_nand_ctrl->index++]);
  488. dev_err(priv->dev, "%s: beyond end of buffer\n", __func__);
  489. return ERR_BYTE;
  490. }
  491. /*
  492. * Read two bytes from the IFC hardware buffer
  493. * read function for 16-bit buswith
  494. */
  495. static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
  496. {
  497. struct nand_chip *chip = mtd->priv;
  498. struct fsl_ifc_mtd *priv = chip->priv;
  499. uint16_t data;
  500. /*
  501. * If there are still bytes in the IFC buffer, then use the
  502. * next byte.
  503. */
  504. if (ifc_nand_ctrl->index < ifc_nand_ctrl->read_bytes) {
  505. data = in_be16((uint16_t *)&ifc_nand_ctrl->
  506. addr[ifc_nand_ctrl->index]);
  507. ifc_nand_ctrl->index += 2;
  508. return (uint8_t) data;
  509. }
  510. dev_err(priv->dev, "%s: beyond end of buffer\n", __func__);
  511. return ERR_BYTE;
  512. }
  513. /*
  514. * Read from the IFC Controller Data Buffer
  515. */
  516. static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
  517. {
  518. struct nand_chip *chip = mtd->priv;
  519. struct fsl_ifc_mtd *priv = chip->priv;
  520. int avail;
  521. if (len < 0) {
  522. dev_err(priv->dev, "%s: len %d bytes", __func__, len);
  523. return;
  524. }
  525. avail = min((unsigned int)len,
  526. ifc_nand_ctrl->read_bytes - ifc_nand_ctrl->index);
  527. memcpy_fromio(buf, &ifc_nand_ctrl->addr[ifc_nand_ctrl->index], avail);
  528. ifc_nand_ctrl->index += avail;
  529. if (len > avail)
  530. dev_err(priv->dev,
  531. "%s: beyond end of buffer (%d requested, %d available)\n",
  532. __func__, len, avail);
  533. }
  534. /*
  535. * Verify buffer against the IFC Controller Data Buffer
  536. */
  537. static int fsl_ifc_verify_buf(struct mtd_info *mtd,
  538. const u_char *buf, int len)
  539. {
  540. struct nand_chip *chip = mtd->priv;
  541. struct fsl_ifc_mtd *priv = chip->priv;
  542. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  543. struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
  544. int i;
  545. if (len < 0) {
  546. dev_err(priv->dev, "%s: write_buf of %d bytes", __func__, len);
  547. return -EINVAL;
  548. }
  549. if ((unsigned int)len > nctrl->read_bytes - nctrl->index) {
  550. dev_err(priv->dev,
  551. "%s: beyond end of buffer (%d requested, %u available)\n",
  552. __func__, len, nctrl->read_bytes - nctrl->index);
  553. nctrl->index = nctrl->read_bytes;
  554. return -EINVAL;
  555. }
  556. for (i = 0; i < len; i++)
  557. if (in_8(&nctrl->addr[nctrl->index + i]) != buf[i])
  558. break;
  559. nctrl->index += len;
  560. if (i != len)
  561. return -EIO;
  562. if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC)
  563. return -EIO;
  564. return 0;
  565. }
  566. /*
  567. * This function is called after Program and Erase Operations to
  568. * check for success or failure.
  569. */
  570. static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip)
  571. {
  572. struct fsl_ifc_mtd *priv = chip->priv;
  573. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  574. struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  575. u32 nand_fsr;
  576. /* Use READ_STATUS command, but wait for the device to be ready */
  577. out_be32(&ifc->ifc_nand.nand_fir0,
  578. (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  579. (IFC_FIR_OP_RDSTAT << IFC_NAND_FIR0_OP1_SHIFT));
  580. out_be32(&ifc->ifc_nand.nand_fcr0, NAND_CMD_STATUS <<
  581. IFC_NAND_FCR0_CMD0_SHIFT);
  582. out_be32(&ifc->ifc_nand.nand_fbcr, 1);
  583. set_addr(mtd, 0, 0, 0);
  584. ifc_nand_ctrl->read_bytes = 1;
  585. fsl_ifc_run_command(mtd);
  586. nand_fsr = in_be32(&ifc->ifc_nand.nand_fsr);
  587. /*
  588. * The chip always seems to report that it is
  589. * write-protected, even when it is not.
  590. */
  591. return nand_fsr | NAND_STATUS_WP;
  592. }
  593. static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  594. uint8_t *buf, int oob_required, int page)
  595. {
  596. struct fsl_ifc_mtd *priv = chip->priv;
  597. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  598. struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
  599. fsl_ifc_read_buf(mtd, buf, mtd->writesize);
  600. if (oob_required)
  601. fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
  602. if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_ECCER)
  603. dev_err(priv->dev, "NAND Flash ECC Uncorrectable Error\n");
  604. if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC)
  605. mtd->ecc_stats.failed++;
  606. return nctrl->max_bitflips;
  607. }
  608. /* ECC will be calculated automatically, and errors will be detected in
  609. * waitfunc.
  610. */
  611. static void fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
  612. const uint8_t *buf, int oob_required)
  613. {
  614. fsl_ifc_write_buf(mtd, buf, mtd->writesize);
  615. fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
  616. }
  617. static int fsl_ifc_chip_init_tail(struct mtd_info *mtd)
  618. {
  619. struct nand_chip *chip = mtd->priv;
  620. struct fsl_ifc_mtd *priv = chip->priv;
  621. dev_dbg(priv->dev, "%s: nand->numchips = %d\n", __func__,
  622. chip->numchips);
  623. dev_dbg(priv->dev, "%s: nand->chipsize = %lld\n", __func__,
  624. chip->chipsize);
  625. dev_dbg(priv->dev, "%s: nand->pagemask = %8x\n", __func__,
  626. chip->pagemask);
  627. dev_dbg(priv->dev, "%s: nand->chip_delay = %d\n", __func__,
  628. chip->chip_delay);
  629. dev_dbg(priv->dev, "%s: nand->badblockpos = %d\n", __func__,
  630. chip->badblockpos);
  631. dev_dbg(priv->dev, "%s: nand->chip_shift = %d\n", __func__,
  632. chip->chip_shift);
  633. dev_dbg(priv->dev, "%s: nand->page_shift = %d\n", __func__,
  634. chip->page_shift);
  635. dev_dbg(priv->dev, "%s: nand->phys_erase_shift = %d\n", __func__,
  636. chip->phys_erase_shift);
  637. dev_dbg(priv->dev, "%s: nand->ecclayout = %p\n", __func__,
  638. chip->ecclayout);
  639. dev_dbg(priv->dev, "%s: nand->ecc.mode = %d\n", __func__,
  640. chip->ecc.mode);
  641. dev_dbg(priv->dev, "%s: nand->ecc.steps = %d\n", __func__,
  642. chip->ecc.steps);
  643. dev_dbg(priv->dev, "%s: nand->ecc.bytes = %d\n", __func__,
  644. chip->ecc.bytes);
  645. dev_dbg(priv->dev, "%s: nand->ecc.total = %d\n", __func__,
  646. chip->ecc.total);
  647. dev_dbg(priv->dev, "%s: nand->ecc.layout = %p\n", __func__,
  648. chip->ecc.layout);
  649. dev_dbg(priv->dev, "%s: mtd->flags = %08x\n", __func__, mtd->flags);
  650. dev_dbg(priv->dev, "%s: mtd->size = %lld\n", __func__, mtd->size);
  651. dev_dbg(priv->dev, "%s: mtd->erasesize = %d\n", __func__,
  652. mtd->erasesize);
  653. dev_dbg(priv->dev, "%s: mtd->writesize = %d\n", __func__,
  654. mtd->writesize);
  655. dev_dbg(priv->dev, "%s: mtd->oobsize = %d\n", __func__,
  656. mtd->oobsize);
  657. return 0;
  658. }
  659. static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
  660. {
  661. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  662. struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  663. struct nand_chip *chip = &priv->chip;
  664. struct nand_ecclayout *layout;
  665. u32 csor;
  666. /* Fill in fsl_ifc_mtd structure */
  667. priv->mtd.priv = chip;
  668. priv->mtd.owner = THIS_MODULE;
  669. /* fill in nand_chip structure */
  670. /* set up function call table */
  671. if ((in_be32(&ifc->cspr_cs[priv->bank].cspr)) & CSPR_PORT_SIZE_16)
  672. chip->read_byte = fsl_ifc_read_byte16;
  673. else
  674. chip->read_byte = fsl_ifc_read_byte;
  675. chip->write_buf = fsl_ifc_write_buf;
  676. chip->read_buf = fsl_ifc_read_buf;
  677. chip->verify_buf = fsl_ifc_verify_buf;
  678. chip->select_chip = fsl_ifc_select_chip;
  679. chip->cmdfunc = fsl_ifc_cmdfunc;
  680. chip->waitfunc = fsl_ifc_wait;
  681. chip->bbt_td = &bbt_main_descr;
  682. chip->bbt_md = &bbt_mirror_descr;
  683. out_be32(&ifc->ifc_nand.ncfgr, 0x0);
  684. /* set up nand options */
  685. chip->options = NAND_NO_READRDY;
  686. chip->bbt_options = NAND_BBT_USE_FLASH;
  687. if (in_be32(&ifc->cspr_cs[priv->bank].cspr) & CSPR_PORT_SIZE_16) {
  688. chip->read_byte = fsl_ifc_read_byte16;
  689. chip->options |= NAND_BUSWIDTH_16;
  690. } else {
  691. chip->read_byte = fsl_ifc_read_byte;
  692. }
  693. chip->controller = &ifc_nand_ctrl->controller;
  694. chip->priv = priv;
  695. chip->ecc.read_page = fsl_ifc_read_page;
  696. chip->ecc.write_page = fsl_ifc_write_page;
  697. csor = in_be32(&ifc->csor_cs[priv->bank].csor);
  698. /* Hardware generates ECC per 512 Bytes */
  699. chip->ecc.size = 512;
  700. chip->ecc.bytes = 8;
  701. chip->ecc.strength = 4;
  702. switch (csor & CSOR_NAND_PGS_MASK) {
  703. case CSOR_NAND_PGS_512:
  704. if (chip->options & NAND_BUSWIDTH_16) {
  705. layout = &oob_512_16bit_ecc4;
  706. } else {
  707. layout = &oob_512_8bit_ecc4;
  708. /* Avoid conflict with bad block marker */
  709. bbt_main_descr.offs = 0;
  710. bbt_mirror_descr.offs = 0;
  711. }
  712. priv->bufnum_mask = 15;
  713. break;
  714. case CSOR_NAND_PGS_2K:
  715. layout = &oob_2048_ecc4;
  716. priv->bufnum_mask = 3;
  717. break;
  718. case CSOR_NAND_PGS_4K:
  719. if ((csor & CSOR_NAND_ECC_MODE_MASK) ==
  720. CSOR_NAND_ECC_MODE_4) {
  721. layout = &oob_4096_ecc4;
  722. } else {
  723. layout = &oob_4096_ecc8;
  724. chip->ecc.bytes = 16;
  725. }
  726. priv->bufnum_mask = 1;
  727. break;
  728. default:
  729. dev_err(priv->dev, "bad csor %#x: bad page size\n", csor);
  730. return -ENODEV;
  731. }
  732. /* Must also set CSOR_NAND_ECC_ENC_EN if DEC_EN set */
  733. if (csor & CSOR_NAND_ECC_DEC_EN) {
  734. chip->ecc.mode = NAND_ECC_HW;
  735. chip->ecc.layout = layout;
  736. } else {
  737. chip->ecc.mode = NAND_ECC_SOFT;
  738. }
  739. return 0;
  740. }
  741. static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
  742. {
  743. nand_release(&priv->mtd);
  744. kfree(priv->mtd.name);
  745. if (priv->vbase)
  746. iounmap(priv->vbase);
  747. ifc_nand_ctrl->chips[priv->bank] = NULL;
  748. dev_set_drvdata(priv->dev, NULL);
  749. kfree(priv);
  750. return 0;
  751. }
  752. static int match_bank(struct fsl_ifc_regs __iomem *ifc, int bank,
  753. phys_addr_t addr)
  754. {
  755. u32 cspr = in_be32(&ifc->cspr_cs[bank].cspr);
  756. if (!(cspr & CSPR_V))
  757. return 0;
  758. if ((cspr & CSPR_MSEL) != CSPR_MSEL_NAND)
  759. return 0;
  760. return (cspr & CSPR_BA) == convert_ifc_address(addr);
  761. }
  762. static DEFINE_MUTEX(fsl_ifc_nand_mutex);
  763. static int __devinit fsl_ifc_nand_probe(struct platform_device *dev)
  764. {
  765. struct fsl_ifc_regs __iomem *ifc;
  766. struct fsl_ifc_mtd *priv;
  767. struct resource res;
  768. static const char *part_probe_types[]
  769. = { "cmdlinepart", "RedBoot", "ofpart", NULL };
  770. int ret;
  771. int bank;
  772. struct device_node *node = dev->dev.of_node;
  773. struct mtd_part_parser_data ppdata;
  774. ppdata.of_node = dev->dev.of_node;
  775. if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs)
  776. return -ENODEV;
  777. ifc = fsl_ifc_ctrl_dev->regs;
  778. /* get, allocate and map the memory resource */
  779. ret = of_address_to_resource(node, 0, &res);
  780. if (ret) {
  781. dev_err(&dev->dev, "%s: failed to get resource\n", __func__);
  782. return ret;
  783. }
  784. /* find which chip select it is connected to */
  785. for (bank = 0; bank < FSL_IFC_BANK_COUNT; bank++) {
  786. if (match_bank(ifc, bank, res.start))
  787. break;
  788. }
  789. if (bank >= FSL_IFC_BANK_COUNT) {
  790. dev_err(&dev->dev, "%s: address did not match any chip selects\n",
  791. __func__);
  792. return -ENODEV;
  793. }
  794. priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
  795. if (!priv)
  796. return -ENOMEM;
  797. mutex_lock(&fsl_ifc_nand_mutex);
  798. if (!fsl_ifc_ctrl_dev->nand) {
  799. ifc_nand_ctrl = kzalloc(sizeof(*ifc_nand_ctrl), GFP_KERNEL);
  800. if (!ifc_nand_ctrl) {
  801. dev_err(&dev->dev, "failed to allocate memory\n");
  802. mutex_unlock(&fsl_ifc_nand_mutex);
  803. return -ENOMEM;
  804. }
  805. ifc_nand_ctrl->read_bytes = 0;
  806. ifc_nand_ctrl->index = 0;
  807. ifc_nand_ctrl->addr = NULL;
  808. fsl_ifc_ctrl_dev->nand = ifc_nand_ctrl;
  809. spin_lock_init(&ifc_nand_ctrl->controller.lock);
  810. init_waitqueue_head(&ifc_nand_ctrl->controller.wq);
  811. } else {
  812. ifc_nand_ctrl = fsl_ifc_ctrl_dev->nand;
  813. }
  814. mutex_unlock(&fsl_ifc_nand_mutex);
  815. ifc_nand_ctrl->chips[bank] = priv;
  816. priv->bank = bank;
  817. priv->ctrl = fsl_ifc_ctrl_dev;
  818. priv->dev = &dev->dev;
  819. priv->vbase = ioremap(res.start, resource_size(&res));
  820. if (!priv->vbase) {
  821. dev_err(priv->dev, "%s: failed to map chip region\n", __func__);
  822. ret = -ENOMEM;
  823. goto err;
  824. }
  825. dev_set_drvdata(priv->dev, priv);
  826. out_be32(&ifc->ifc_nand.nand_evter_en,
  827. IFC_NAND_EVTER_EN_OPC_EN |
  828. IFC_NAND_EVTER_EN_FTOER_EN |
  829. IFC_NAND_EVTER_EN_WPER_EN);
  830. /* enable NAND Machine Interrupts */
  831. out_be32(&ifc->ifc_nand.nand_evter_intr_en,
  832. IFC_NAND_EVTER_INTR_OPCIR_EN |
  833. IFC_NAND_EVTER_INTR_FTOERIR_EN |
  834. IFC_NAND_EVTER_INTR_WPERIR_EN);
  835. priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", (unsigned)res.start);
  836. if (!priv->mtd.name) {
  837. ret = -ENOMEM;
  838. goto err;
  839. }
  840. ret = fsl_ifc_chip_init(priv);
  841. if (ret)
  842. goto err;
  843. ret = nand_scan_ident(&priv->mtd, 1, NULL);
  844. if (ret)
  845. goto err;
  846. ret = fsl_ifc_chip_init_tail(&priv->mtd);
  847. if (ret)
  848. goto err;
  849. ret = nand_scan_tail(&priv->mtd);
  850. if (ret)
  851. goto err;
  852. /* First look for RedBoot table or partitions on the command
  853. * line, these take precedence over device tree information */
  854. mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata,
  855. NULL, 0);
  856. dev_info(priv->dev, "IFC NAND device at 0x%llx, bank %d\n",
  857. (unsigned long long)res.start, priv->bank);
  858. return 0;
  859. err:
  860. fsl_ifc_chip_remove(priv);
  861. return ret;
  862. }
  863. static int fsl_ifc_nand_remove(struct platform_device *dev)
  864. {
  865. struct fsl_ifc_mtd *priv = dev_get_drvdata(&dev->dev);
  866. fsl_ifc_chip_remove(priv);
  867. mutex_lock(&fsl_ifc_nand_mutex);
  868. ifc_nand_ctrl->counter--;
  869. if (!ifc_nand_ctrl->counter) {
  870. fsl_ifc_ctrl_dev->nand = NULL;
  871. kfree(ifc_nand_ctrl);
  872. }
  873. mutex_unlock(&fsl_ifc_nand_mutex);
  874. return 0;
  875. }
  876. static const struct of_device_id fsl_ifc_nand_match[] = {
  877. {
  878. .compatible = "fsl,ifc-nand",
  879. },
  880. {}
  881. };
  882. static struct platform_driver fsl_ifc_nand_driver = {
  883. .driver = {
  884. .name = "fsl,ifc-nand",
  885. .owner = THIS_MODULE,
  886. .of_match_table = fsl_ifc_nand_match,
  887. },
  888. .probe = fsl_ifc_nand_probe,
  889. .remove = fsl_ifc_nand_remove,
  890. };
  891. static int __init fsl_ifc_nand_init(void)
  892. {
  893. int ret;
  894. ret = platform_driver_register(&fsl_ifc_nand_driver);
  895. if (ret)
  896. printk(KERN_ERR "fsl-ifc: Failed to register platform"
  897. "driver\n");
  898. return ret;
  899. }
  900. static void __exit fsl_ifc_nand_exit(void)
  901. {
  902. platform_driver_unregister(&fsl_ifc_nand_driver);
  903. }
  904. module_init(fsl_ifc_nand_init);
  905. module_exit(fsl_ifc_nand_exit);
  906. MODULE_LICENSE("GPL");
  907. MODULE_AUTHOR("Freescale");
  908. MODULE_DESCRIPTION("Freescale Integrated Flash Controller MTD NAND driver");