fsmc_nand.c 30 KB

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