fsmc_nand.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. /*
  2. * drivers/mtd/nand/fsmc_nand.c
  3. *
  4. * ST Microelectronics
  5. * Flexible Static Memory Controller (FSMC)
  6. * Driver for NAND portions
  7. *
  8. * Copyright © 2010 ST Microelectronics
  9. * Vipin Kumar <vipin.kumar@st.com>
  10. * Ashish Priyadarshi
  11. *
  12. * Based on drivers/mtd/nand/nomadik_nand.c
  13. *
  14. * This file is licensed under the terms of the GNU General Public
  15. * License version 2. This program is licensed "as is" without any
  16. * warranty of any kind, whether express or implied.
  17. */
  18. #include <linux/clk.h>
  19. #include <linux/completion.h>
  20. #include <linux/dmaengine.h>
  21. #include <linux/dma-direction.h>
  22. #include <linux/dma-mapping.h>
  23. #include <linux/err.h>
  24. #include <linux/init.h>
  25. #include <linux/module.h>
  26. #include <linux/resource.h>
  27. #include <linux/sched.h>
  28. #include <linux/types.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/rawnand.h>
  31. #include <linux/mtd/nand_ecc.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/of.h>
  34. #include <linux/mtd/partitions.h>
  35. #include <linux/io.h>
  36. #include <linux/slab.h>
  37. #include <linux/amba/bus.h>
  38. #include <mtd/mtd-abi.h>
  39. /* fsmc controller registers for NOR flash */
  40. #define CTRL 0x0
  41. /* ctrl register definitions */
  42. #define BANK_ENABLE (1 << 0)
  43. #define MUXED (1 << 1)
  44. #define NOR_DEV (2 << 2)
  45. #define WIDTH_8 (0 << 4)
  46. #define WIDTH_16 (1 << 4)
  47. #define RSTPWRDWN (1 << 6)
  48. #define WPROT (1 << 7)
  49. #define WRT_ENABLE (1 << 12)
  50. #define WAIT_ENB (1 << 13)
  51. #define CTRL_TIM 0x4
  52. /* ctrl_tim register definitions */
  53. #define FSMC_NOR_BANK_SZ 0x8
  54. #define FSMC_NOR_REG_SIZE 0x40
  55. #define FSMC_NOR_REG(base, bank, reg) (base + \
  56. FSMC_NOR_BANK_SZ * (bank) + \
  57. reg)
  58. /* fsmc controller registers for NAND flash */
  59. #define PC 0x00
  60. /* pc register definitions */
  61. #define FSMC_RESET (1 << 0)
  62. #define FSMC_WAITON (1 << 1)
  63. #define FSMC_ENABLE (1 << 2)
  64. #define FSMC_DEVTYPE_NAND (1 << 3)
  65. #define FSMC_DEVWID_8 (0 << 4)
  66. #define FSMC_DEVWID_16 (1 << 4)
  67. #define FSMC_ECCEN (1 << 6)
  68. #define FSMC_ECCPLEN_512 (0 << 7)
  69. #define FSMC_ECCPLEN_256 (1 << 7)
  70. #define FSMC_TCLR_1 (1)
  71. #define FSMC_TCLR_SHIFT (9)
  72. #define FSMC_TCLR_MASK (0xF)
  73. #define FSMC_TAR_1 (1)
  74. #define FSMC_TAR_SHIFT (13)
  75. #define FSMC_TAR_MASK (0xF)
  76. #define STS 0x04
  77. /* sts register definitions */
  78. #define FSMC_CODE_RDY (1 << 15)
  79. #define COMM 0x08
  80. /* comm register definitions */
  81. #define FSMC_TSET_0 0
  82. #define FSMC_TSET_SHIFT 0
  83. #define FSMC_TSET_MASK 0xFF
  84. #define FSMC_TWAIT_6 6
  85. #define FSMC_TWAIT_SHIFT 8
  86. #define FSMC_TWAIT_MASK 0xFF
  87. #define FSMC_THOLD_4 4
  88. #define FSMC_THOLD_SHIFT 16
  89. #define FSMC_THOLD_MASK 0xFF
  90. #define FSMC_THIZ_1 1
  91. #define FSMC_THIZ_SHIFT 24
  92. #define FSMC_THIZ_MASK 0xFF
  93. #define ATTRIB 0x0C
  94. #define IOATA 0x10
  95. #define ECC1 0x14
  96. #define ECC2 0x18
  97. #define ECC3 0x1C
  98. #define FSMC_NAND_BANK_SZ 0x20
  99. #define FSMC_NAND_REG(base, bank, reg) (base + FSMC_NOR_REG_SIZE + \
  100. (FSMC_NAND_BANK_SZ * (bank)) + \
  101. reg)
  102. #define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ)
  103. struct fsmc_nand_timings {
  104. uint8_t tclr;
  105. uint8_t tar;
  106. uint8_t thiz;
  107. uint8_t thold;
  108. uint8_t twait;
  109. uint8_t tset;
  110. };
  111. enum access_mode {
  112. USE_DMA_ACCESS = 1,
  113. USE_WORD_ACCESS,
  114. };
  115. /**
  116. * struct fsmc_nand_data - structure for FSMC NAND device state
  117. *
  118. * @pid: Part ID on the AMBA PrimeCell format
  119. * @mtd: MTD info for a NAND flash.
  120. * @nand: Chip related info for a NAND flash.
  121. * @partitions: Partition info for a NAND Flash.
  122. * @nr_partitions: Total number of partition of a NAND flash.
  123. *
  124. * @bank: Bank number for probed device.
  125. * @clk: Clock structure for FSMC.
  126. *
  127. * @read_dma_chan: DMA channel for read access
  128. * @write_dma_chan: DMA channel for write access to NAND
  129. * @dma_access_complete: Completion structure
  130. *
  131. * @data_pa: NAND Physical port for Data.
  132. * @data_va: NAND port for Data.
  133. * @cmd_va: NAND port for Command.
  134. * @addr_va: NAND port for Address.
  135. * @regs_va: FSMC regs base address.
  136. */
  137. struct fsmc_nand_data {
  138. u32 pid;
  139. struct nand_chip nand;
  140. unsigned int bank;
  141. struct device *dev;
  142. enum access_mode mode;
  143. struct clk *clk;
  144. /* DMA related objects */
  145. struct dma_chan *read_dma_chan;
  146. struct dma_chan *write_dma_chan;
  147. struct completion dma_access_complete;
  148. struct fsmc_nand_timings *dev_timings;
  149. dma_addr_t data_pa;
  150. void __iomem *data_va;
  151. void __iomem *cmd_va;
  152. void __iomem *addr_va;
  153. void __iomem *regs_va;
  154. };
  155. static int fsmc_ecc1_ooblayout_ecc(struct mtd_info *mtd, int section,
  156. struct mtd_oob_region *oobregion)
  157. {
  158. struct nand_chip *chip = mtd_to_nand(mtd);
  159. if (section >= chip->ecc.steps)
  160. return -ERANGE;
  161. oobregion->offset = (section * 16) + 2;
  162. oobregion->length = 3;
  163. return 0;
  164. }
  165. static int fsmc_ecc1_ooblayout_free(struct mtd_info *mtd, int section,
  166. struct mtd_oob_region *oobregion)
  167. {
  168. struct nand_chip *chip = mtd_to_nand(mtd);
  169. if (section >= chip->ecc.steps)
  170. return -ERANGE;
  171. oobregion->offset = (section * 16) + 8;
  172. if (section < chip->ecc.steps - 1)
  173. oobregion->length = 8;
  174. else
  175. oobregion->length = mtd->oobsize - oobregion->offset;
  176. return 0;
  177. }
  178. static const struct mtd_ooblayout_ops fsmc_ecc1_ooblayout_ops = {
  179. .ecc = fsmc_ecc1_ooblayout_ecc,
  180. .free = fsmc_ecc1_ooblayout_free,
  181. };
  182. /*
  183. * ECC placement definitions in oobfree type format.
  184. * There are 13 bytes of ecc for every 512 byte block and it has to be read
  185. * consecutively and immediately after the 512 byte data block for hardware to
  186. * generate the error bit offsets in 512 byte data.
  187. */
  188. static int fsmc_ecc4_ooblayout_ecc(struct mtd_info *mtd, int section,
  189. struct mtd_oob_region *oobregion)
  190. {
  191. struct nand_chip *chip = mtd_to_nand(mtd);
  192. if (section >= chip->ecc.steps)
  193. return -ERANGE;
  194. oobregion->length = chip->ecc.bytes;
  195. if (!section && mtd->writesize <= 512)
  196. oobregion->offset = 0;
  197. else
  198. oobregion->offset = (section * 16) + 2;
  199. return 0;
  200. }
  201. static int fsmc_ecc4_ooblayout_free(struct mtd_info *mtd, int section,
  202. struct mtd_oob_region *oobregion)
  203. {
  204. struct nand_chip *chip = mtd_to_nand(mtd);
  205. if (section >= chip->ecc.steps)
  206. return -ERANGE;
  207. oobregion->offset = (section * 16) + 15;
  208. if (section < chip->ecc.steps - 1)
  209. oobregion->length = 3;
  210. else
  211. oobregion->length = mtd->oobsize - oobregion->offset;
  212. return 0;
  213. }
  214. static const struct mtd_ooblayout_ops fsmc_ecc4_ooblayout_ops = {
  215. .ecc = fsmc_ecc4_ooblayout_ecc,
  216. .free = fsmc_ecc4_ooblayout_free,
  217. };
  218. static inline struct fsmc_nand_data *mtd_to_fsmc(struct mtd_info *mtd)
  219. {
  220. return container_of(mtd_to_nand(mtd), struct fsmc_nand_data, nand);
  221. }
  222. /*
  223. * fsmc_cmd_ctrl - For facilitaing Hardware access
  224. * This routine allows hardware specific access to control-lines(ALE,CLE)
  225. */
  226. static void fsmc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  227. {
  228. struct nand_chip *this = mtd_to_nand(mtd);
  229. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  230. void __iomem *regs = host->regs_va;
  231. unsigned int bank = host->bank;
  232. if (ctrl & NAND_CTRL_CHANGE) {
  233. u32 pc;
  234. if (ctrl & NAND_CLE) {
  235. this->IO_ADDR_R = host->cmd_va;
  236. this->IO_ADDR_W = host->cmd_va;
  237. } else if (ctrl & NAND_ALE) {
  238. this->IO_ADDR_R = host->addr_va;
  239. this->IO_ADDR_W = host->addr_va;
  240. } else {
  241. this->IO_ADDR_R = host->data_va;
  242. this->IO_ADDR_W = host->data_va;
  243. }
  244. pc = readl(FSMC_NAND_REG(regs, bank, PC));
  245. if (ctrl & NAND_NCE)
  246. pc |= FSMC_ENABLE;
  247. else
  248. pc &= ~FSMC_ENABLE;
  249. writel_relaxed(pc, FSMC_NAND_REG(regs, bank, PC));
  250. }
  251. mb();
  252. if (cmd != NAND_CMD_NONE)
  253. writeb_relaxed(cmd, this->IO_ADDR_W);
  254. }
  255. /*
  256. * fsmc_nand_setup - FSMC (Flexible Static Memory Controller) init routine
  257. *
  258. * This routine initializes timing parameters related to NAND memory access in
  259. * FSMC registers
  260. */
  261. static void fsmc_nand_setup(struct fsmc_nand_data *host,
  262. struct fsmc_nand_timings *tims)
  263. {
  264. uint32_t value = FSMC_DEVTYPE_NAND | FSMC_ENABLE | FSMC_WAITON;
  265. uint32_t tclr, tar, thiz, thold, twait, tset;
  266. unsigned int bank = host->bank;
  267. void __iomem *regs = host->regs_va;
  268. tclr = (tims->tclr & FSMC_TCLR_MASK) << FSMC_TCLR_SHIFT;
  269. tar = (tims->tar & FSMC_TAR_MASK) << FSMC_TAR_SHIFT;
  270. thiz = (tims->thiz & FSMC_THIZ_MASK) << FSMC_THIZ_SHIFT;
  271. thold = (tims->thold & FSMC_THOLD_MASK) << FSMC_THOLD_SHIFT;
  272. twait = (tims->twait & FSMC_TWAIT_MASK) << FSMC_TWAIT_SHIFT;
  273. tset = (tims->tset & FSMC_TSET_MASK) << FSMC_TSET_SHIFT;
  274. if (host->nand.options & NAND_BUSWIDTH_16)
  275. writel_relaxed(value | FSMC_DEVWID_16,
  276. FSMC_NAND_REG(regs, bank, PC));
  277. else
  278. writel_relaxed(value | FSMC_DEVWID_8,
  279. FSMC_NAND_REG(regs, bank, PC));
  280. writel_relaxed(readl(FSMC_NAND_REG(regs, bank, PC)) | tclr | tar,
  281. FSMC_NAND_REG(regs, bank, PC));
  282. writel_relaxed(thiz | thold | twait | tset,
  283. FSMC_NAND_REG(regs, bank, COMM));
  284. writel_relaxed(thiz | thold | twait | tset,
  285. FSMC_NAND_REG(regs, bank, ATTRIB));
  286. }
  287. static int fsmc_calc_timings(struct fsmc_nand_data *host,
  288. const struct nand_sdr_timings *sdrt,
  289. struct fsmc_nand_timings *tims)
  290. {
  291. unsigned long hclk = clk_get_rate(host->clk);
  292. unsigned long hclkn = NSEC_PER_SEC / hclk;
  293. uint32_t thiz, thold, twait, tset;
  294. if (sdrt->tRC_min < 30000)
  295. return -EOPNOTSUPP;
  296. tims->tar = DIV_ROUND_UP(sdrt->tAR_min / 1000, hclkn) - 1;
  297. if (tims->tar > FSMC_TAR_MASK)
  298. tims->tar = FSMC_TAR_MASK;
  299. tims->tclr = DIV_ROUND_UP(sdrt->tCLR_min / 1000, hclkn) - 1;
  300. if (tims->tclr > FSMC_TCLR_MASK)
  301. tims->tclr = FSMC_TCLR_MASK;
  302. thiz = sdrt->tCS_min - sdrt->tWP_min;
  303. tims->thiz = DIV_ROUND_UP(thiz / 1000, hclkn);
  304. thold = sdrt->tDH_min;
  305. if (thold < sdrt->tCH_min)
  306. thold = sdrt->tCH_min;
  307. if (thold < sdrt->tCLH_min)
  308. thold = sdrt->tCLH_min;
  309. if (thold < sdrt->tWH_min)
  310. thold = sdrt->tWH_min;
  311. if (thold < sdrt->tALH_min)
  312. thold = sdrt->tALH_min;
  313. if (thold < sdrt->tREH_min)
  314. thold = sdrt->tREH_min;
  315. tims->thold = DIV_ROUND_UP(thold / 1000, hclkn);
  316. if (tims->thold == 0)
  317. tims->thold = 1;
  318. else if (tims->thold > FSMC_THOLD_MASK)
  319. tims->thold = FSMC_THOLD_MASK;
  320. twait = max(sdrt->tRP_min, sdrt->tWP_min);
  321. tims->twait = DIV_ROUND_UP(twait / 1000, hclkn) - 1;
  322. if (tims->twait == 0)
  323. tims->twait = 1;
  324. else if (tims->twait > FSMC_TWAIT_MASK)
  325. tims->twait = FSMC_TWAIT_MASK;
  326. tset = max(sdrt->tCS_min - sdrt->tWP_min,
  327. sdrt->tCEA_max - sdrt->tREA_max);
  328. tims->tset = DIV_ROUND_UP(tset / 1000, hclkn) - 1;
  329. if (tims->tset == 0)
  330. tims->tset = 1;
  331. else if (tims->tset > FSMC_TSET_MASK)
  332. tims->tset = FSMC_TSET_MASK;
  333. return 0;
  334. }
  335. static int fsmc_setup_data_interface(struct mtd_info *mtd, int csline,
  336. const struct nand_data_interface *conf)
  337. {
  338. struct nand_chip *nand = mtd_to_nand(mtd);
  339. struct fsmc_nand_data *host = nand_get_controller_data(nand);
  340. struct fsmc_nand_timings tims;
  341. const struct nand_sdr_timings *sdrt;
  342. int ret;
  343. sdrt = nand_get_sdr_timings(conf);
  344. if (IS_ERR(sdrt))
  345. return PTR_ERR(sdrt);
  346. ret = fsmc_calc_timings(host, sdrt, &tims);
  347. if (ret)
  348. return ret;
  349. if (csline == NAND_DATA_IFACE_CHECK_ONLY)
  350. return 0;
  351. fsmc_nand_setup(host, &tims);
  352. return 0;
  353. }
  354. /*
  355. * fsmc_enable_hwecc - Enables Hardware ECC through FSMC registers
  356. */
  357. static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode)
  358. {
  359. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  360. void __iomem *regs = host->regs_va;
  361. uint32_t bank = host->bank;
  362. writel_relaxed(readl(FSMC_NAND_REG(regs, bank, PC)) & ~FSMC_ECCPLEN_256,
  363. FSMC_NAND_REG(regs, bank, PC));
  364. writel_relaxed(readl(FSMC_NAND_REG(regs, bank, PC)) & ~FSMC_ECCEN,
  365. FSMC_NAND_REG(regs, bank, PC));
  366. writel_relaxed(readl(FSMC_NAND_REG(regs, bank, PC)) | FSMC_ECCEN,
  367. FSMC_NAND_REG(regs, bank, PC));
  368. }
  369. /*
  370. * fsmc_read_hwecc_ecc4 - Hardware ECC calculator for ecc4 option supported by
  371. * FSMC. ECC is 13 bytes for 512 bytes of data (supports error correction up to
  372. * max of 8-bits)
  373. */
  374. static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data,
  375. uint8_t *ecc)
  376. {
  377. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  378. void __iomem *regs = host->regs_va;
  379. uint32_t bank = host->bank;
  380. uint32_t ecc_tmp;
  381. unsigned long deadline = jiffies + FSMC_BUSY_WAIT_TIMEOUT;
  382. do {
  383. if (readl_relaxed(FSMC_NAND_REG(regs, bank, STS)) & FSMC_CODE_RDY)
  384. break;
  385. else
  386. cond_resched();
  387. } while (!time_after_eq(jiffies, deadline));
  388. if (time_after_eq(jiffies, deadline)) {
  389. dev_err(host->dev, "calculate ecc timed out\n");
  390. return -ETIMEDOUT;
  391. }
  392. ecc_tmp = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC1));
  393. ecc[0] = (uint8_t) (ecc_tmp >> 0);
  394. ecc[1] = (uint8_t) (ecc_tmp >> 8);
  395. ecc[2] = (uint8_t) (ecc_tmp >> 16);
  396. ecc[3] = (uint8_t) (ecc_tmp >> 24);
  397. ecc_tmp = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC2));
  398. ecc[4] = (uint8_t) (ecc_tmp >> 0);
  399. ecc[5] = (uint8_t) (ecc_tmp >> 8);
  400. ecc[6] = (uint8_t) (ecc_tmp >> 16);
  401. ecc[7] = (uint8_t) (ecc_tmp >> 24);
  402. ecc_tmp = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC3));
  403. ecc[8] = (uint8_t) (ecc_tmp >> 0);
  404. ecc[9] = (uint8_t) (ecc_tmp >> 8);
  405. ecc[10] = (uint8_t) (ecc_tmp >> 16);
  406. ecc[11] = (uint8_t) (ecc_tmp >> 24);
  407. ecc_tmp = readl_relaxed(FSMC_NAND_REG(regs, bank, STS));
  408. ecc[12] = (uint8_t) (ecc_tmp >> 16);
  409. return 0;
  410. }
  411. /*
  412. * fsmc_read_hwecc_ecc1 - Hardware ECC calculator for ecc1 option supported by
  413. * FSMC. ECC is 3 bytes for 512 bytes of data (supports error correction up to
  414. * max of 1-bit)
  415. */
  416. static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data,
  417. uint8_t *ecc)
  418. {
  419. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  420. void __iomem *regs = host->regs_va;
  421. uint32_t bank = host->bank;
  422. uint32_t ecc_tmp;
  423. ecc_tmp = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC1));
  424. ecc[0] = (uint8_t) (ecc_tmp >> 0);
  425. ecc[1] = (uint8_t) (ecc_tmp >> 8);
  426. ecc[2] = (uint8_t) (ecc_tmp >> 16);
  427. return 0;
  428. }
  429. /* Count the number of 0's in buff upto a max of max_bits */
  430. static int count_written_bits(uint8_t *buff, int size, int max_bits)
  431. {
  432. int k, written_bits = 0;
  433. for (k = 0; k < size; k++) {
  434. written_bits += hweight8(~buff[k]);
  435. if (written_bits > max_bits)
  436. break;
  437. }
  438. return written_bits;
  439. }
  440. static void dma_complete(void *param)
  441. {
  442. struct fsmc_nand_data *host = param;
  443. complete(&host->dma_access_complete);
  444. }
  445. static int dma_xfer(struct fsmc_nand_data *host, void *buffer, int len,
  446. enum dma_data_direction direction)
  447. {
  448. struct dma_chan *chan;
  449. struct dma_device *dma_dev;
  450. struct dma_async_tx_descriptor *tx;
  451. dma_addr_t dma_dst, dma_src, dma_addr;
  452. dma_cookie_t cookie;
  453. unsigned long flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
  454. int ret;
  455. unsigned long time_left;
  456. if (direction == DMA_TO_DEVICE)
  457. chan = host->write_dma_chan;
  458. else if (direction == DMA_FROM_DEVICE)
  459. chan = host->read_dma_chan;
  460. else
  461. return -EINVAL;
  462. dma_dev = chan->device;
  463. dma_addr = dma_map_single(dma_dev->dev, buffer, len, direction);
  464. if (direction == DMA_TO_DEVICE) {
  465. dma_src = dma_addr;
  466. dma_dst = host->data_pa;
  467. } else {
  468. dma_src = host->data_pa;
  469. dma_dst = dma_addr;
  470. }
  471. tx = dma_dev->device_prep_dma_memcpy(chan, dma_dst, dma_src,
  472. len, flags);
  473. if (!tx) {
  474. dev_err(host->dev, "device_prep_dma_memcpy error\n");
  475. ret = -EIO;
  476. goto unmap_dma;
  477. }
  478. tx->callback = dma_complete;
  479. tx->callback_param = host;
  480. cookie = tx->tx_submit(tx);
  481. ret = dma_submit_error(cookie);
  482. if (ret) {
  483. dev_err(host->dev, "dma_submit_error %d\n", cookie);
  484. goto unmap_dma;
  485. }
  486. dma_async_issue_pending(chan);
  487. time_left =
  488. wait_for_completion_timeout(&host->dma_access_complete,
  489. msecs_to_jiffies(3000));
  490. if (time_left == 0) {
  491. dmaengine_terminate_all(chan);
  492. dev_err(host->dev, "wait_for_completion_timeout\n");
  493. ret = -ETIMEDOUT;
  494. goto unmap_dma;
  495. }
  496. ret = 0;
  497. unmap_dma:
  498. dma_unmap_single(dma_dev->dev, dma_addr, len, direction);
  499. return ret;
  500. }
  501. /*
  502. * fsmc_write_buf - write buffer to chip
  503. * @mtd: MTD device structure
  504. * @buf: data buffer
  505. * @len: number of bytes to write
  506. */
  507. static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
  508. {
  509. int i;
  510. struct nand_chip *chip = mtd_to_nand(mtd);
  511. if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
  512. IS_ALIGNED(len, sizeof(uint32_t))) {
  513. uint32_t *p = (uint32_t *)buf;
  514. len = len >> 2;
  515. for (i = 0; i < len; i++)
  516. writel_relaxed(p[i], chip->IO_ADDR_W);
  517. } else {
  518. for (i = 0; i < len; i++)
  519. writeb_relaxed(buf[i], chip->IO_ADDR_W);
  520. }
  521. }
  522. /*
  523. * fsmc_read_buf - read chip data into buffer
  524. * @mtd: MTD device structure
  525. * @buf: buffer to store date
  526. * @len: number of bytes to read
  527. */
  528. static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
  529. {
  530. int i;
  531. struct nand_chip *chip = mtd_to_nand(mtd);
  532. if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
  533. IS_ALIGNED(len, sizeof(uint32_t))) {
  534. uint32_t *p = (uint32_t *)buf;
  535. len = len >> 2;
  536. for (i = 0; i < len; i++)
  537. p[i] = readl_relaxed(chip->IO_ADDR_R);
  538. } else {
  539. for (i = 0; i < len; i++)
  540. buf[i] = readb_relaxed(chip->IO_ADDR_R);
  541. }
  542. }
  543. /*
  544. * fsmc_read_buf_dma - read chip data into buffer
  545. * @mtd: MTD device structure
  546. * @buf: buffer to store date
  547. * @len: number of bytes to read
  548. */
  549. static void fsmc_read_buf_dma(struct mtd_info *mtd, uint8_t *buf, int len)
  550. {
  551. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  552. dma_xfer(host, buf, len, DMA_FROM_DEVICE);
  553. }
  554. /*
  555. * fsmc_write_buf_dma - write buffer to chip
  556. * @mtd: MTD device structure
  557. * @buf: data buffer
  558. * @len: number of bytes to write
  559. */
  560. static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf,
  561. int len)
  562. {
  563. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  564. dma_xfer(host, (void *)buf, len, DMA_TO_DEVICE);
  565. }
  566. /*
  567. * fsmc_read_page_hwecc
  568. * @mtd: mtd info structure
  569. * @chip: nand chip info structure
  570. * @buf: buffer to store read data
  571. * @oob_required: caller expects OOB data read to chip->oob_poi
  572. * @page: page number to read
  573. *
  574. * This routine is needed for fsmc version 8 as reading from NAND chip has to be
  575. * performed in a strict sequence as follows:
  576. * data(512 byte) -> ecc(13 byte)
  577. * After this read, fsmc hardware generates and reports error data bits(up to a
  578. * max of 8 bits)
  579. */
  580. static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
  581. uint8_t *buf, int oob_required, int page)
  582. {
  583. int i, j, s, stat, eccsize = chip->ecc.size;
  584. int eccbytes = chip->ecc.bytes;
  585. int eccsteps = chip->ecc.steps;
  586. uint8_t *p = buf;
  587. uint8_t *ecc_calc = chip->buffers->ecccalc;
  588. uint8_t *ecc_code = chip->buffers->ecccode;
  589. int off, len, group = 0;
  590. /*
  591. * ecc_oob is intentionally taken as uint16_t. In 16bit devices, we
  592. * end up reading 14 bytes (7 words) from oob. The local array is
  593. * to maintain word alignment
  594. */
  595. uint16_t ecc_oob[7];
  596. uint8_t *oob = (uint8_t *)&ecc_oob[0];
  597. unsigned int max_bitflips = 0;
  598. for (i = 0, s = 0; s < eccsteps; s++, i += eccbytes, p += eccsize) {
  599. chip->cmdfunc(mtd, NAND_CMD_READ0, s * eccsize, page);
  600. chip->ecc.hwctl(mtd, NAND_ECC_READ);
  601. chip->read_buf(mtd, p, eccsize);
  602. for (j = 0; j < eccbytes;) {
  603. struct mtd_oob_region oobregion;
  604. int ret;
  605. ret = mtd_ooblayout_ecc(mtd, group++, &oobregion);
  606. if (ret)
  607. return ret;
  608. off = oobregion.offset;
  609. len = oobregion.length;
  610. /*
  611. * length is intentionally kept a higher multiple of 2
  612. * to read at least 13 bytes even in case of 16 bit NAND
  613. * devices
  614. */
  615. if (chip->options & NAND_BUSWIDTH_16)
  616. len = roundup(len, 2);
  617. chip->cmdfunc(mtd, NAND_CMD_READOOB, off, page);
  618. chip->read_buf(mtd, oob + j, len);
  619. j += len;
  620. }
  621. memcpy(&ecc_code[i], oob, chip->ecc.bytes);
  622. chip->ecc.calculate(mtd, p, &ecc_calc[i]);
  623. stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
  624. if (stat < 0) {
  625. mtd->ecc_stats.failed++;
  626. } else {
  627. mtd->ecc_stats.corrected += stat;
  628. max_bitflips = max_t(unsigned int, max_bitflips, stat);
  629. }
  630. }
  631. return max_bitflips;
  632. }
  633. /*
  634. * fsmc_bch8_correct_data
  635. * @mtd: mtd info structure
  636. * @dat: buffer of read data
  637. * @read_ecc: ecc read from device spare area
  638. * @calc_ecc: ecc calculated from read data
  639. *
  640. * calc_ecc is a 104 bit information containing maximum of 8 error
  641. * offset informations of 13 bits each in 512 bytes of read data.
  642. */
  643. static int fsmc_bch8_correct_data(struct mtd_info *mtd, uint8_t *dat,
  644. uint8_t *read_ecc, uint8_t *calc_ecc)
  645. {
  646. struct nand_chip *chip = mtd_to_nand(mtd);
  647. struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
  648. void __iomem *regs = host->regs_va;
  649. unsigned int bank = host->bank;
  650. uint32_t err_idx[8];
  651. uint32_t num_err, i;
  652. uint32_t ecc1, ecc2, ecc3, ecc4;
  653. num_err = (readl_relaxed(FSMC_NAND_REG(regs, bank, STS)) >> 10) & 0xF;
  654. /* no bit flipping */
  655. if (likely(num_err == 0))
  656. return 0;
  657. /* too many errors */
  658. if (unlikely(num_err > 8)) {
  659. /*
  660. * This is a temporary erase check. A newly erased page read
  661. * would result in an ecc error because the oob data is also
  662. * erased to FF and the calculated ecc for an FF data is not
  663. * FF..FF.
  664. * This is a workaround to skip performing correction in case
  665. * data is FF..FF
  666. *
  667. * Logic:
  668. * For every page, each bit written as 0 is counted until these
  669. * number of bits are greater than 8 (the maximum correction
  670. * capability of FSMC for each 512 + 13 bytes)
  671. */
  672. int bits_ecc = count_written_bits(read_ecc, chip->ecc.bytes, 8);
  673. int bits_data = count_written_bits(dat, chip->ecc.size, 8);
  674. if ((bits_ecc + bits_data) <= 8) {
  675. if (bits_data)
  676. memset(dat, 0xff, chip->ecc.size);
  677. return bits_data;
  678. }
  679. return -EBADMSG;
  680. }
  681. /*
  682. * ------------------- calc_ecc[] bit wise -----------|--13 bits--|
  683. * |---idx[7]--|--.....-----|---idx[2]--||---idx[1]--||---idx[0]--|
  684. *
  685. * calc_ecc is a 104 bit information containing maximum of 8 error
  686. * offset informations of 13 bits each. calc_ecc is copied into a
  687. * uint64_t array and error offset indexes are populated in err_idx
  688. * array
  689. */
  690. ecc1 = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC1));
  691. ecc2 = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC2));
  692. ecc3 = readl_relaxed(FSMC_NAND_REG(regs, bank, ECC3));
  693. ecc4 = readl_relaxed(FSMC_NAND_REG(regs, bank, STS));
  694. err_idx[0] = (ecc1 >> 0) & 0x1FFF;
  695. err_idx[1] = (ecc1 >> 13) & 0x1FFF;
  696. err_idx[2] = (((ecc2 >> 0) & 0x7F) << 6) | ((ecc1 >> 26) & 0x3F);
  697. err_idx[3] = (ecc2 >> 7) & 0x1FFF;
  698. err_idx[4] = (((ecc3 >> 0) & 0x1) << 12) | ((ecc2 >> 20) & 0xFFF);
  699. err_idx[5] = (ecc3 >> 1) & 0x1FFF;
  700. err_idx[6] = (ecc3 >> 14) & 0x1FFF;
  701. err_idx[7] = (((ecc4 >> 16) & 0xFF) << 5) | ((ecc3 >> 27) & 0x1F);
  702. i = 0;
  703. while (num_err--) {
  704. change_bit(0, (unsigned long *)&err_idx[i]);
  705. change_bit(1, (unsigned long *)&err_idx[i]);
  706. if (err_idx[i] < chip->ecc.size * 8) {
  707. change_bit(err_idx[i], (unsigned long *)dat);
  708. i++;
  709. }
  710. }
  711. return i;
  712. }
  713. static bool filter(struct dma_chan *chan, void *slave)
  714. {
  715. chan->private = slave;
  716. return true;
  717. }
  718. static int fsmc_nand_probe_config_dt(struct platform_device *pdev,
  719. struct fsmc_nand_data *host,
  720. struct nand_chip *nand)
  721. {
  722. struct device_node *np = pdev->dev.of_node;
  723. u32 val;
  724. int ret;
  725. nand->options = 0;
  726. if (!of_property_read_u32(np, "bank-width", &val)) {
  727. if (val == 2) {
  728. nand->options |= NAND_BUSWIDTH_16;
  729. } else if (val != 1) {
  730. dev_err(&pdev->dev, "invalid bank-width %u\n", val);
  731. return -EINVAL;
  732. }
  733. }
  734. if (of_get_property(np, "nand-skip-bbtscan", NULL))
  735. nand->options |= NAND_SKIP_BBTSCAN;
  736. host->dev_timings = devm_kzalloc(&pdev->dev,
  737. sizeof(*host->dev_timings), GFP_KERNEL);
  738. if (!host->dev_timings)
  739. return -ENOMEM;
  740. ret = of_property_read_u8_array(np, "timings", (u8 *)host->dev_timings,
  741. sizeof(*host->dev_timings));
  742. if (ret)
  743. host->dev_timings = NULL;
  744. /* Set default NAND bank to 0 */
  745. host->bank = 0;
  746. if (!of_property_read_u32(np, "bank", &val)) {
  747. if (val > 3) {
  748. dev_err(&pdev->dev, "invalid bank %u\n", val);
  749. return -EINVAL;
  750. }
  751. host->bank = val;
  752. }
  753. return 0;
  754. }
  755. /*
  756. * fsmc_nand_probe - Probe function
  757. * @pdev: platform device structure
  758. */
  759. static int __init fsmc_nand_probe(struct platform_device *pdev)
  760. {
  761. struct fsmc_nand_data *host;
  762. struct mtd_info *mtd;
  763. struct nand_chip *nand;
  764. struct resource *res;
  765. dma_cap_mask_t mask;
  766. int ret = 0;
  767. u32 pid;
  768. int i;
  769. /* Allocate memory for the device structure (and zero it) */
  770. host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
  771. if (!host)
  772. return -ENOMEM;
  773. nand = &host->nand;
  774. ret = fsmc_nand_probe_config_dt(pdev, host, nand);
  775. if (ret)
  776. return ret;
  777. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_data");
  778. host->data_va = devm_ioremap_resource(&pdev->dev, res);
  779. if (IS_ERR(host->data_va))
  780. return PTR_ERR(host->data_va);
  781. host->data_pa = (dma_addr_t)res->start;
  782. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
  783. host->addr_va = devm_ioremap_resource(&pdev->dev, res);
  784. if (IS_ERR(host->addr_va))
  785. return PTR_ERR(host->addr_va);
  786. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
  787. host->cmd_va = devm_ioremap_resource(&pdev->dev, res);
  788. if (IS_ERR(host->cmd_va))
  789. return PTR_ERR(host->cmd_va);
  790. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs");
  791. host->regs_va = devm_ioremap_resource(&pdev->dev, res);
  792. if (IS_ERR(host->regs_va))
  793. return PTR_ERR(host->regs_va);
  794. host->clk = devm_clk_get(&pdev->dev, NULL);
  795. if (IS_ERR(host->clk)) {
  796. dev_err(&pdev->dev, "failed to fetch block clock\n");
  797. return PTR_ERR(host->clk);
  798. }
  799. ret = clk_prepare_enable(host->clk);
  800. if (ret)
  801. return ret;
  802. /*
  803. * This device ID is actually a common AMBA ID as used on the
  804. * AMBA PrimeCell bus. However it is not a PrimeCell.
  805. */
  806. for (pid = 0, i = 0; i < 4; i++)
  807. pid |= (readl(host->regs_va + resource_size(res) - 0x20 + 4 * i) & 255) << (i * 8);
  808. host->pid = pid;
  809. dev_info(&pdev->dev, "FSMC device partno %03x, manufacturer %02x, "
  810. "revision %02x, config %02x\n",
  811. AMBA_PART_BITS(pid), AMBA_MANF_BITS(pid),
  812. AMBA_REV_BITS(pid), AMBA_CONFIG_BITS(pid));
  813. host->dev = &pdev->dev;
  814. if (host->mode == USE_DMA_ACCESS)
  815. init_completion(&host->dma_access_complete);
  816. /* Link all private pointers */
  817. mtd = nand_to_mtd(&host->nand);
  818. nand_set_controller_data(nand, host);
  819. nand_set_flash_node(nand, pdev->dev.of_node);
  820. mtd->dev.parent = &pdev->dev;
  821. nand->IO_ADDR_R = host->data_va;
  822. nand->IO_ADDR_W = host->data_va;
  823. nand->cmd_ctrl = fsmc_cmd_ctrl;
  824. nand->chip_delay = 30;
  825. /*
  826. * Setup default ECC mode. nand_dt_init() called from nand_scan_ident()
  827. * can overwrite this value if the DT provides a different value.
  828. */
  829. nand->ecc.mode = NAND_ECC_HW;
  830. nand->ecc.hwctl = fsmc_enable_hwecc;
  831. nand->ecc.size = 512;
  832. nand->badblockbits = 7;
  833. switch (host->mode) {
  834. case USE_DMA_ACCESS:
  835. dma_cap_zero(mask);
  836. dma_cap_set(DMA_MEMCPY, mask);
  837. host->read_dma_chan = dma_request_channel(mask, filter, NULL);
  838. if (!host->read_dma_chan) {
  839. dev_err(&pdev->dev, "Unable to get read dma channel\n");
  840. goto err_req_read_chnl;
  841. }
  842. host->write_dma_chan = dma_request_channel(mask, filter, NULL);
  843. if (!host->write_dma_chan) {
  844. dev_err(&pdev->dev, "Unable to get write dma channel\n");
  845. goto err_req_write_chnl;
  846. }
  847. nand->read_buf = fsmc_read_buf_dma;
  848. nand->write_buf = fsmc_write_buf_dma;
  849. break;
  850. default:
  851. case USE_WORD_ACCESS:
  852. nand->read_buf = fsmc_read_buf;
  853. nand->write_buf = fsmc_write_buf;
  854. break;
  855. }
  856. if (host->dev_timings)
  857. fsmc_nand_setup(host, host->dev_timings);
  858. else
  859. nand->setup_data_interface = fsmc_setup_data_interface;
  860. if (AMBA_REV_BITS(host->pid) >= 8) {
  861. nand->ecc.read_page = fsmc_read_page_hwecc;
  862. nand->ecc.calculate = fsmc_read_hwecc_ecc4;
  863. nand->ecc.correct = fsmc_bch8_correct_data;
  864. nand->ecc.bytes = 13;
  865. nand->ecc.strength = 8;
  866. }
  867. /*
  868. * Scan to find existence of the device
  869. */
  870. ret = nand_scan_ident(mtd, 1, NULL);
  871. if (ret) {
  872. dev_err(&pdev->dev, "No NAND Device found!\n");
  873. goto err_scan_ident;
  874. }
  875. if (AMBA_REV_BITS(host->pid) >= 8) {
  876. switch (mtd->oobsize) {
  877. case 16:
  878. case 64:
  879. case 128:
  880. case 224:
  881. case 256:
  882. break;
  883. default:
  884. dev_warn(&pdev->dev, "No oob scheme defined for oobsize %d\n",
  885. mtd->oobsize);
  886. ret = -EINVAL;
  887. goto err_probe;
  888. }
  889. mtd_set_ooblayout(mtd, &fsmc_ecc4_ooblayout_ops);
  890. } else {
  891. switch (nand->ecc.mode) {
  892. case NAND_ECC_HW:
  893. dev_info(&pdev->dev, "Using 1-bit HW ECC scheme\n");
  894. nand->ecc.calculate = fsmc_read_hwecc_ecc1;
  895. nand->ecc.correct = nand_correct_data;
  896. nand->ecc.bytes = 3;
  897. nand->ecc.strength = 1;
  898. break;
  899. case NAND_ECC_SOFT:
  900. if (nand->ecc.algo == NAND_ECC_BCH) {
  901. dev_info(&pdev->dev, "Using 4-bit SW BCH ECC scheme\n");
  902. break;
  903. }
  904. case NAND_ECC_ON_DIE:
  905. break;
  906. default:
  907. dev_err(&pdev->dev, "Unsupported ECC mode!\n");
  908. goto err_probe;
  909. }
  910. /*
  911. * Don't set layout for BCH4 SW ECC. This will be
  912. * generated later in nand_bch_init() later.
  913. */
  914. if (nand->ecc.mode == NAND_ECC_HW) {
  915. switch (mtd->oobsize) {
  916. case 16:
  917. case 64:
  918. case 128:
  919. mtd_set_ooblayout(mtd,
  920. &fsmc_ecc1_ooblayout_ops);
  921. break;
  922. default:
  923. dev_warn(&pdev->dev,
  924. "No oob scheme defined for oobsize %d\n",
  925. mtd->oobsize);
  926. ret = -EINVAL;
  927. goto err_probe;
  928. }
  929. }
  930. }
  931. /* Second stage of scan to fill MTD data-structures */
  932. ret = nand_scan_tail(mtd);
  933. if (ret)
  934. goto err_probe;
  935. mtd->name = "nand";
  936. ret = mtd_device_register(mtd, NULL, 0);
  937. if (ret)
  938. goto err_probe;
  939. platform_set_drvdata(pdev, host);
  940. dev_info(&pdev->dev, "FSMC NAND driver registration successful\n");
  941. return 0;
  942. err_probe:
  943. err_scan_ident:
  944. if (host->mode == USE_DMA_ACCESS)
  945. dma_release_channel(host->write_dma_chan);
  946. err_req_write_chnl:
  947. if (host->mode == USE_DMA_ACCESS)
  948. dma_release_channel(host->read_dma_chan);
  949. err_req_read_chnl:
  950. clk_disable_unprepare(host->clk);
  951. return ret;
  952. }
  953. /*
  954. * Clean up routine
  955. */
  956. static int fsmc_nand_remove(struct platform_device *pdev)
  957. {
  958. struct fsmc_nand_data *host = platform_get_drvdata(pdev);
  959. if (host) {
  960. nand_release(&host->nand);
  961. if (host->mode == USE_DMA_ACCESS) {
  962. dma_release_channel(host->write_dma_chan);
  963. dma_release_channel(host->read_dma_chan);
  964. }
  965. clk_disable_unprepare(host->clk);
  966. }
  967. return 0;
  968. }
  969. #ifdef CONFIG_PM_SLEEP
  970. static int fsmc_nand_suspend(struct device *dev)
  971. {
  972. struct fsmc_nand_data *host = dev_get_drvdata(dev);
  973. if (host)
  974. clk_disable_unprepare(host->clk);
  975. return 0;
  976. }
  977. static int fsmc_nand_resume(struct device *dev)
  978. {
  979. struct fsmc_nand_data *host = dev_get_drvdata(dev);
  980. if (host) {
  981. clk_prepare_enable(host->clk);
  982. if (host->dev_timings)
  983. fsmc_nand_setup(host, host->dev_timings);
  984. }
  985. return 0;
  986. }
  987. #endif
  988. static SIMPLE_DEV_PM_OPS(fsmc_nand_pm_ops, fsmc_nand_suspend, fsmc_nand_resume);
  989. static const struct of_device_id fsmc_nand_id_table[] = {
  990. { .compatible = "st,spear600-fsmc-nand" },
  991. { .compatible = "stericsson,fsmc-nand" },
  992. {}
  993. };
  994. MODULE_DEVICE_TABLE(of, fsmc_nand_id_table);
  995. static struct platform_driver fsmc_nand_driver = {
  996. .remove = fsmc_nand_remove,
  997. .driver = {
  998. .name = "fsmc-nand",
  999. .of_match_table = fsmc_nand_id_table,
  1000. .pm = &fsmc_nand_pm_ops,
  1001. },
  1002. };
  1003. module_platform_driver_probe(fsmc_nand_driver, fsmc_nand_probe);
  1004. MODULE_LICENSE("GPL");
  1005. MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>, Ashish Priyadarshi");
  1006. MODULE_DESCRIPTION("NAND driver for SPEAr Platforms");