fsmc_nand.c 31 KB

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