doc2000.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /*
  2. * Linux driver for Disk-On-Chip 2000 and Millennium
  3. * (c) 1999 Machine Vision Holdings, Inc.
  4. * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
  5. *
  6. * $Id: doc2000.c,v 1.67 2005/11/07 11:14:24 gleixner Exp $
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/module.h>
  10. #include <asm/errno.h>
  11. #include <asm/io.h>
  12. #include <asm/uaccess.h>
  13. #include <linux/miscdevice.h>
  14. #include <linux/delay.h>
  15. #include <linux/slab.h>
  16. #include <linux/sched.h>
  17. #include <linux/init.h>
  18. #include <linux/types.h>
  19. #include <linux/bitops.h>
  20. #include <linux/mutex.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/nand.h>
  23. #include <linux/mtd/doc2000.h>
  24. #define DOC_SUPPORT_2000
  25. #define DOC_SUPPORT_2000TSOP
  26. #define DOC_SUPPORT_MILLENNIUM
  27. #ifdef DOC_SUPPORT_2000
  28. #define DoC_is_2000(doc) (doc->ChipID == DOC_ChipID_Doc2k)
  29. #else
  30. #define DoC_is_2000(doc) (0)
  31. #endif
  32. #if defined(DOC_SUPPORT_2000TSOP) || defined(DOC_SUPPORT_MILLENNIUM)
  33. #define DoC_is_Millennium(doc) (doc->ChipID == DOC_ChipID_DocMil)
  34. #else
  35. #define DoC_is_Millennium(doc) (0)
  36. #endif
  37. /* #define ECC_DEBUG */
  38. /* I have no idea why some DoC chips can not use memcpy_from|to_io().
  39. * This may be due to the different revisions of the ASIC controller built-in or
  40. * simplily a QA/Bug issue. Who knows ?? If you have trouble, please uncomment
  41. * this:
  42. #undef USE_MEMCPY
  43. */
  44. static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
  45. size_t *retlen, u_char *buf);
  46. static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
  47. size_t *retlen, const u_char *buf);
  48. static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
  49. struct mtd_oob_ops *ops);
  50. static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
  51. struct mtd_oob_ops *ops);
  52. static int doc_write_oob_nolock(struct mtd_info *mtd, loff_t ofs, size_t len,
  53. size_t *retlen, const u_char *buf);
  54. static int doc_erase (struct mtd_info *mtd, struct erase_info *instr);
  55. static struct mtd_info *doc2klist = NULL;
  56. /* Perform the required delay cycles by reading from the appropriate register */
  57. static void DoC_Delay(struct DiskOnChip *doc, unsigned short cycles)
  58. {
  59. volatile char dummy;
  60. int i;
  61. for (i = 0; i < cycles; i++) {
  62. if (DoC_is_Millennium(doc))
  63. dummy = ReadDOC(doc->virtadr, NOP);
  64. else
  65. dummy = ReadDOC(doc->virtadr, DOCStatus);
  66. }
  67. }
  68. /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
  69. static int _DoC_WaitReady(struct DiskOnChip *doc)
  70. {
  71. void __iomem *docptr = doc->virtadr;
  72. unsigned long timeo = jiffies + (HZ * 10);
  73. DEBUG(MTD_DEBUG_LEVEL3,
  74. "_DoC_WaitReady called for out-of-line wait\n");
  75. /* Out-of-line routine to wait for chip response */
  76. while (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) {
  77. /* issue 2 read from NOP register after reading from CDSNControl register
  78. see Software Requirement 11.4 item 2. */
  79. DoC_Delay(doc, 2);
  80. if (time_after(jiffies, timeo)) {
  81. DEBUG(MTD_DEBUG_LEVEL2, "_DoC_WaitReady timed out.\n");
  82. return -EIO;
  83. }
  84. udelay(1);
  85. cond_resched();
  86. }
  87. return 0;
  88. }
  89. static inline int DoC_WaitReady(struct DiskOnChip *doc)
  90. {
  91. void __iomem *docptr = doc->virtadr;
  92. /* This is inline, to optimise the common case, where it's ready instantly */
  93. int ret = 0;
  94. /* 4 read form NOP register should be issued in prior to the read from CDSNControl
  95. see Software Requirement 11.4 item 2. */
  96. DoC_Delay(doc, 4);
  97. if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B))
  98. /* Call the out-of-line routine to wait */
  99. ret = _DoC_WaitReady(doc);
  100. /* issue 2 read from NOP register after reading from CDSNControl register
  101. see Software Requirement 11.4 item 2. */
  102. DoC_Delay(doc, 2);
  103. return ret;
  104. }
  105. /* DoC_Command: Send a flash command to the flash chip through the CDSN Slow IO register to
  106. bypass the internal pipeline. Each of 4 delay cycles (read from the NOP register) is
  107. required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */
  108. static int DoC_Command(struct DiskOnChip *doc, unsigned char command,
  109. unsigned char xtraflags)
  110. {
  111. void __iomem *docptr = doc->virtadr;
  112. if (DoC_is_2000(doc))
  113. xtraflags |= CDSN_CTRL_FLASH_IO;
  114. /* Assert the CLE (Command Latch Enable) line to the flash chip */
  115. WriteDOC(xtraflags | CDSN_CTRL_CLE | CDSN_CTRL_CE, docptr, CDSNControl);
  116. DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */
  117. if (DoC_is_Millennium(doc))
  118. WriteDOC(command, docptr, CDSNSlowIO);
  119. /* Send the command */
  120. WriteDOC_(command, docptr, doc->ioreg);
  121. if (DoC_is_Millennium(doc))
  122. WriteDOC(command, docptr, WritePipeTerm);
  123. /* Lower the CLE line */
  124. WriteDOC(xtraflags | CDSN_CTRL_CE, docptr, CDSNControl);
  125. DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */
  126. /* Wait for the chip to respond - Software requirement 11.4.1 (extended for any command) */
  127. return DoC_WaitReady(doc);
  128. }
  129. /* DoC_Address: Set the current address for the flash chip through the CDSN Slow IO register to
  130. bypass the internal pipeline. Each of 4 delay cycles (read from the NOP register) is
  131. required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */
  132. static int DoC_Address(struct DiskOnChip *doc, int numbytes, unsigned long ofs,
  133. unsigned char xtraflags1, unsigned char xtraflags2)
  134. {
  135. int i;
  136. void __iomem *docptr = doc->virtadr;
  137. if (DoC_is_2000(doc))
  138. xtraflags1 |= CDSN_CTRL_FLASH_IO;
  139. /* Assert the ALE (Address Latch Enable) line to the flash chip */
  140. WriteDOC(xtraflags1 | CDSN_CTRL_ALE | CDSN_CTRL_CE, docptr, CDSNControl);
  141. DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */
  142. /* Send the address */
  143. /* Devices with 256-byte page are addressed as:
  144. Column (bits 0-7), Page (bits 8-15, 16-23, 24-31)
  145. * there is no device on the market with page256
  146. and more than 24 bits.
  147. Devices with 512-byte page are addressed as:
  148. Column (bits 0-7), Page (bits 9-16, 17-24, 25-31)
  149. * 25-31 is sent only if the chip support it.
  150. * bit 8 changes the read command to be sent
  151. (NAND_CMD_READ0 or NAND_CMD_READ1).
  152. */
  153. if (numbytes == ADDR_COLUMN || numbytes == ADDR_COLUMN_PAGE) {
  154. if (DoC_is_Millennium(doc))
  155. WriteDOC(ofs & 0xff, docptr, CDSNSlowIO);
  156. WriteDOC_(ofs & 0xff, docptr, doc->ioreg);
  157. }
  158. if (doc->page256) {
  159. ofs = ofs >> 8;
  160. } else {
  161. ofs = ofs >> 9;
  162. }
  163. if (numbytes == ADDR_PAGE || numbytes == ADDR_COLUMN_PAGE) {
  164. for (i = 0; i < doc->pageadrlen; i++, ofs = ofs >> 8) {
  165. if (DoC_is_Millennium(doc))
  166. WriteDOC(ofs & 0xff, docptr, CDSNSlowIO);
  167. WriteDOC_(ofs & 0xff, docptr, doc->ioreg);
  168. }
  169. }
  170. if (DoC_is_Millennium(doc))
  171. WriteDOC(ofs & 0xff, docptr, WritePipeTerm);
  172. DoC_Delay(doc, 2); /* Needed for some slow flash chips. mf. */
  173. /* FIXME: The SlowIO's for millennium could be replaced by
  174. a single WritePipeTerm here. mf. */
  175. /* Lower the ALE line */
  176. WriteDOC(xtraflags1 | xtraflags2 | CDSN_CTRL_CE, docptr,
  177. CDSNControl);
  178. DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */
  179. /* Wait for the chip to respond - Software requirement 11.4.1 */
  180. return DoC_WaitReady(doc);
  181. }
  182. /* Read a buffer from DoC, taking care of Millennium odditys */
  183. static void DoC_ReadBuf(struct DiskOnChip *doc, u_char * buf, int len)
  184. {
  185. volatile int dummy;
  186. int modulus = 0xffff;
  187. void __iomem *docptr = doc->virtadr;
  188. int i;
  189. if (len <= 0)
  190. return;
  191. if (DoC_is_Millennium(doc)) {
  192. /* Read the data via the internal pipeline through CDSN IO register,
  193. see Pipelined Read Operations 11.3 */
  194. dummy = ReadDOC(docptr, ReadPipeInit);
  195. /* Millennium should use the LastDataRead register - Pipeline Reads */
  196. len--;
  197. /* This is needed for correctly ECC calculation */
  198. modulus = 0xff;
  199. }
  200. for (i = 0; i < len; i++)
  201. buf[i] = ReadDOC_(docptr, doc->ioreg + (i & modulus));
  202. if (DoC_is_Millennium(doc)) {
  203. buf[i] = ReadDOC(docptr, LastDataRead);
  204. }
  205. }
  206. /* Write a buffer to DoC, taking care of Millennium odditys */
  207. static void DoC_WriteBuf(struct DiskOnChip *doc, const u_char * buf, int len)
  208. {
  209. void __iomem *docptr = doc->virtadr;
  210. int i;
  211. if (len <= 0)
  212. return;
  213. for (i = 0; i < len; i++)
  214. WriteDOC_(buf[i], docptr, doc->ioreg + i);
  215. if (DoC_is_Millennium(doc)) {
  216. WriteDOC(0x00, docptr, WritePipeTerm);
  217. }
  218. }
  219. /* DoC_SelectChip: Select a given flash chip within the current floor */
  220. static inline int DoC_SelectChip(struct DiskOnChip *doc, int chip)
  221. {
  222. void __iomem *docptr = doc->virtadr;
  223. /* Software requirement 11.4.4 before writing DeviceSelect */
  224. /* Deassert the CE line to eliminate glitches on the FCE# outputs */
  225. WriteDOC(CDSN_CTRL_WP, docptr, CDSNControl);
  226. DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */
  227. /* Select the individual flash chip requested */
  228. WriteDOC(chip, docptr, CDSNDeviceSelect);
  229. DoC_Delay(doc, 4);
  230. /* Reassert the CE line */
  231. WriteDOC(CDSN_CTRL_CE | CDSN_CTRL_FLASH_IO | CDSN_CTRL_WP, docptr,
  232. CDSNControl);
  233. DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */
  234. /* Wait for it to be ready */
  235. return DoC_WaitReady(doc);
  236. }
  237. /* DoC_SelectFloor: Select a given floor (bank of flash chips) */
  238. static inline int DoC_SelectFloor(struct DiskOnChip *doc, int floor)
  239. {
  240. void __iomem *docptr = doc->virtadr;
  241. /* Select the floor (bank) of chips required */
  242. WriteDOC(floor, docptr, FloorSelect);
  243. /* Wait for the chip to be ready */
  244. return DoC_WaitReady(doc);
  245. }
  246. /* DoC_IdentChip: Identify a given NAND chip given {floor,chip} */
  247. static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
  248. {
  249. int mfr, id, i, j;
  250. volatile char dummy;
  251. /* Page in the required floor/chip */
  252. DoC_SelectFloor(doc, floor);
  253. DoC_SelectChip(doc, chip);
  254. /* Reset the chip */
  255. if (DoC_Command(doc, NAND_CMD_RESET, CDSN_CTRL_WP)) {
  256. DEBUG(MTD_DEBUG_LEVEL2,
  257. "DoC_Command (reset) for %d,%d returned true\n",
  258. floor, chip);
  259. return 0;
  260. }
  261. /* Read the NAND chip ID: 1. Send ReadID command */
  262. if (DoC_Command(doc, NAND_CMD_READID, CDSN_CTRL_WP)) {
  263. DEBUG(MTD_DEBUG_LEVEL2,
  264. "DoC_Command (ReadID) for %d,%d returned true\n",
  265. floor, chip);
  266. return 0;
  267. }
  268. /* Read the NAND chip ID: 2. Send address byte zero */
  269. DoC_Address(doc, ADDR_COLUMN, 0, CDSN_CTRL_WP, 0);
  270. /* Read the manufacturer and device id codes from the device */
  271. if (DoC_is_Millennium(doc)) {
  272. DoC_Delay(doc, 2);
  273. dummy = ReadDOC(doc->virtadr, ReadPipeInit);
  274. mfr = ReadDOC(doc->virtadr, LastDataRead);
  275. DoC_Delay(doc, 2);
  276. dummy = ReadDOC(doc->virtadr, ReadPipeInit);
  277. id = ReadDOC(doc->virtadr, LastDataRead);
  278. } else {
  279. /* CDSN Slow IO register see Software Req 11.4 item 5. */
  280. dummy = ReadDOC(doc->virtadr, CDSNSlowIO);
  281. DoC_Delay(doc, 2);
  282. mfr = ReadDOC_(doc->virtadr, doc->ioreg);
  283. /* CDSN Slow IO register see Software Req 11.4 item 5. */
  284. dummy = ReadDOC(doc->virtadr, CDSNSlowIO);
  285. DoC_Delay(doc, 2);
  286. id = ReadDOC_(doc->virtadr, doc->ioreg);
  287. }
  288. /* No response - return failure */
  289. if (mfr == 0xff || mfr == 0)
  290. return 0;
  291. /* Check it's the same as the first chip we identified.
  292. * M-Systems say that any given DiskOnChip device should only
  293. * contain _one_ type of flash part, although that's not a
  294. * hardware restriction. */
  295. if (doc->mfr) {
  296. if (doc->mfr == mfr && doc->id == id)
  297. return 1; /* This is another the same the first */
  298. else
  299. printk(KERN_WARNING
  300. "Flash chip at floor %d, chip %d is different:\n",
  301. floor, chip);
  302. }
  303. /* Print and store the manufacturer and ID codes. */
  304. for (i = 0; nand_flash_ids[i].name != NULL; i++) {
  305. if (id == nand_flash_ids[i].id) {
  306. /* Try to identify manufacturer */
  307. for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {
  308. if (nand_manuf_ids[j].id == mfr)
  309. break;
  310. }
  311. printk(KERN_INFO
  312. "Flash chip found: Manufacturer ID: %2.2X, "
  313. "Chip ID: %2.2X (%s:%s)\n", mfr, id,
  314. nand_manuf_ids[j].name, nand_flash_ids[i].name);
  315. if (!doc->mfr) {
  316. doc->mfr = mfr;
  317. doc->id = id;
  318. doc->chipshift =
  319. ffs((nand_flash_ids[i].chipsize << 20)) - 1;
  320. doc->page256 = (nand_flash_ids[i].pagesize == 256) ? 1 : 0;
  321. doc->pageadrlen = doc->chipshift > 25 ? 3 : 2;
  322. doc->erasesize =
  323. nand_flash_ids[i].erasesize;
  324. return 1;
  325. }
  326. return 0;
  327. }
  328. }
  329. /* We haven't fully identified the chip. Print as much as we know. */
  330. printk(KERN_WARNING "Unknown flash chip found: %2.2X %2.2X\n",
  331. id, mfr);
  332. printk(KERN_WARNING "Please report to dwmw2@infradead.org\n");
  333. return 0;
  334. }
  335. /* DoC_ScanChips: Find all NAND chips present in a DiskOnChip, and identify them */
  336. static void DoC_ScanChips(struct DiskOnChip *this, int maxchips)
  337. {
  338. int floor, chip;
  339. int numchips[MAX_FLOORS];
  340. int ret = 1;
  341. this->numchips = 0;
  342. this->mfr = 0;
  343. this->id = 0;
  344. /* For each floor, find the number of valid chips it contains */
  345. for (floor = 0; floor < MAX_FLOORS; floor++) {
  346. ret = 1;
  347. numchips[floor] = 0;
  348. for (chip = 0; chip < maxchips && ret != 0; chip++) {
  349. ret = DoC_IdentChip(this, floor, chip);
  350. if (ret) {
  351. numchips[floor]++;
  352. this->numchips++;
  353. }
  354. }
  355. }
  356. /* If there are none at all that we recognise, bail */
  357. if (!this->numchips) {
  358. printk(KERN_NOTICE "No flash chips recognised.\n");
  359. return;
  360. }
  361. /* Allocate an array to hold the information for each chip */
  362. this->chips = kmalloc(sizeof(struct Nand) * this->numchips, GFP_KERNEL);
  363. if (!this->chips) {
  364. printk(KERN_NOTICE "No memory for allocating chip info structures\n");
  365. return;
  366. }
  367. ret = 0;
  368. /* Fill out the chip array with {floor, chipno} for each
  369. * detected chip in the device. */
  370. for (floor = 0; floor < MAX_FLOORS; floor++) {
  371. for (chip = 0; chip < numchips[floor]; chip++) {
  372. this->chips[ret].floor = floor;
  373. this->chips[ret].chip = chip;
  374. this->chips[ret].curadr = 0;
  375. this->chips[ret].curmode = 0x50;
  376. ret++;
  377. }
  378. }
  379. /* Calculate and print the total size of the device */
  380. this->totlen = this->numchips * (1 << this->chipshift);
  381. printk(KERN_INFO "%d flash chips found. Total DiskOnChip size: %ld MiB\n",
  382. this->numchips, this->totlen >> 20);
  383. }
  384. static int DoC2k_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
  385. {
  386. int tmp1, tmp2, retval;
  387. if (doc1->physadr == doc2->physadr)
  388. return 1;
  389. /* Use the alias resolution register which was set aside for this
  390. * purpose. If it's value is the same on both chips, they might
  391. * be the same chip, and we write to one and check for a change in
  392. * the other. It's unclear if this register is usuable in the
  393. * DoC 2000 (it's in the Millennium docs), but it seems to work. */
  394. tmp1 = ReadDOC(doc1->virtadr, AliasResolution);
  395. tmp2 = ReadDOC(doc2->virtadr, AliasResolution);
  396. if (tmp1 != tmp2)
  397. return 0;
  398. WriteDOC((tmp1 + 1) % 0xff, doc1->virtadr, AliasResolution);
  399. tmp2 = ReadDOC(doc2->virtadr, AliasResolution);
  400. if (tmp2 == (tmp1 + 1) % 0xff)
  401. retval = 1;
  402. else
  403. retval = 0;
  404. /* Restore register contents. May not be necessary, but do it just to
  405. * be safe. */
  406. WriteDOC(tmp1, doc1->virtadr, AliasResolution);
  407. return retval;
  408. }
  409. /* This routine is found from the docprobe code by symbol_get(),
  410. * which will bump the use count of this module. */
  411. void DoC2k_init(struct mtd_info *mtd)
  412. {
  413. struct DiskOnChip *this = mtd->priv;
  414. struct DiskOnChip *old = NULL;
  415. int maxchips;
  416. /* We must avoid being called twice for the same device. */
  417. if (doc2klist)
  418. old = doc2klist->priv;
  419. while (old) {
  420. if (DoC2k_is_alias(old, this)) {
  421. printk(KERN_NOTICE
  422. "Ignoring DiskOnChip 2000 at 0x%lX - already configured\n",
  423. this->physadr);
  424. iounmap(this->virtadr);
  425. kfree(mtd);
  426. return;
  427. }
  428. if (old->nextdoc)
  429. old = old->nextdoc->priv;
  430. else
  431. old = NULL;
  432. }
  433. switch (this->ChipID) {
  434. case DOC_ChipID_Doc2kTSOP:
  435. mtd->name = "DiskOnChip 2000 TSOP";
  436. this->ioreg = DoC_Mil_CDSN_IO;
  437. /* Pretend it's a Millennium */
  438. this->ChipID = DOC_ChipID_DocMil;
  439. maxchips = MAX_CHIPS;
  440. break;
  441. case DOC_ChipID_Doc2k:
  442. mtd->name = "DiskOnChip 2000";
  443. this->ioreg = DoC_2k_CDSN_IO;
  444. maxchips = MAX_CHIPS;
  445. break;
  446. case DOC_ChipID_DocMil:
  447. mtd->name = "DiskOnChip Millennium";
  448. this->ioreg = DoC_Mil_CDSN_IO;
  449. maxchips = MAX_CHIPS_MIL;
  450. break;
  451. default:
  452. printk("Unknown ChipID 0x%02x\n", this->ChipID);
  453. kfree(mtd);
  454. iounmap(this->virtadr);
  455. return;
  456. }
  457. printk(KERN_NOTICE "%s found at address 0x%lX\n", mtd->name,
  458. this->physadr);
  459. mtd->type = MTD_NANDFLASH;
  460. mtd->flags = MTD_CAP_NANDFLASH;
  461. mtd->size = 0;
  462. mtd->erasesize = 0;
  463. mtd->writesize = 512;
  464. mtd->oobsize = 16;
  465. mtd->owner = THIS_MODULE;
  466. mtd->erase = doc_erase;
  467. mtd->point = NULL;
  468. mtd->unpoint = NULL;
  469. mtd->read = doc_read;
  470. mtd->write = doc_write;
  471. mtd->read_oob = doc_read_oob;
  472. mtd->write_oob = doc_write_oob;
  473. mtd->sync = NULL;
  474. this->totlen = 0;
  475. this->numchips = 0;
  476. this->curfloor = -1;
  477. this->curchip = -1;
  478. mutex_init(&this->lock);
  479. /* Ident all the chips present. */
  480. DoC_ScanChips(this, maxchips);
  481. if (!this->totlen) {
  482. kfree(mtd);
  483. iounmap(this->virtadr);
  484. } else {
  485. this->nextdoc = doc2klist;
  486. doc2klist = mtd;
  487. mtd->size = this->totlen;
  488. mtd->erasesize = this->erasesize;
  489. add_mtd_device(mtd);
  490. return;
  491. }
  492. }
  493. EXPORT_SYMBOL_GPL(DoC2k_init);
  494. static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
  495. size_t * retlen, u_char * buf)
  496. {
  497. struct DiskOnChip *this = mtd->priv;
  498. void __iomem *docptr = this->virtadr;
  499. struct Nand *mychip;
  500. unsigned char syndrome[6], eccbuf[6];
  501. volatile char dummy;
  502. int i, len256 = 0, ret=0;
  503. size_t left = len;
  504. /* Don't allow read past end of device */
  505. if (from >= this->totlen)
  506. return -EINVAL;
  507. mutex_lock(&this->lock);
  508. *retlen = 0;
  509. while (left) {
  510. len = left;
  511. /* Don't allow a single read to cross a 512-byte block boundary */
  512. if (from + len > ((from | 0x1ff) + 1))
  513. len = ((from | 0x1ff) + 1) - from;
  514. /* The ECC will not be calculated correctly if less than 512 is read */
  515. if (len != 0x200 && eccbuf)
  516. printk(KERN_WARNING
  517. "ECC needs a full sector read (adr: %lx size %lx)\n",
  518. (long) from, (long) len);
  519. /* printk("DoC_Read (adr: %lx size %lx)\n", (long) from, (long) len); */
  520. /* Find the chip which is to be used and select it */
  521. mychip = &this->chips[from >> (this->chipshift)];
  522. if (this->curfloor != mychip->floor) {
  523. DoC_SelectFloor(this, mychip->floor);
  524. DoC_SelectChip(this, mychip->chip);
  525. } else if (this->curchip != mychip->chip) {
  526. DoC_SelectChip(this, mychip->chip);
  527. }
  528. this->curfloor = mychip->floor;
  529. this->curchip = mychip->chip;
  530. DoC_Command(this,
  531. (!this->page256
  532. && (from & 0x100)) ? NAND_CMD_READ1 : NAND_CMD_READ0,
  533. CDSN_CTRL_WP);
  534. DoC_Address(this, ADDR_COLUMN_PAGE, from, CDSN_CTRL_WP,
  535. CDSN_CTRL_ECC_IO);
  536. /* Prime the ECC engine */
  537. WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
  538. WriteDOC(DOC_ECC_EN, docptr, ECCConf);
  539. /* treat crossing 256-byte sector for 2M x 8bits devices */
  540. if (this->page256 && from + len > (from | 0xff) + 1) {
  541. len256 = (from | 0xff) + 1 - from;
  542. DoC_ReadBuf(this, buf, len256);
  543. DoC_Command(this, NAND_CMD_READ0, CDSN_CTRL_WP);
  544. DoC_Address(this, ADDR_COLUMN_PAGE, from + len256,
  545. CDSN_CTRL_WP, CDSN_CTRL_ECC_IO);
  546. }
  547. DoC_ReadBuf(this, &buf[len256], len - len256);
  548. /* Let the caller know we completed it */
  549. *retlen += len;
  550. /* Read the ECC data through the DiskOnChip ECC logic */
  551. /* Note: this will work even with 2M x 8bit devices as */
  552. /* they have 8 bytes of OOB per 256 page. mf. */
  553. DoC_ReadBuf(this, eccbuf, 6);
  554. /* Flush the pipeline */
  555. if (DoC_is_Millennium(this)) {
  556. dummy = ReadDOC(docptr, ECCConf);
  557. dummy = ReadDOC(docptr, ECCConf);
  558. i = ReadDOC(docptr, ECCConf);
  559. } else {
  560. dummy = ReadDOC(docptr, 2k_ECCStatus);
  561. dummy = ReadDOC(docptr, 2k_ECCStatus);
  562. i = ReadDOC(docptr, 2k_ECCStatus);
  563. }
  564. /* Check the ECC Status */
  565. if (i & 0x80) {
  566. int nb_errors;
  567. /* There was an ECC error */
  568. #ifdef ECC_DEBUG
  569. printk(KERN_ERR "DiskOnChip ECC Error: Read at %lx\n", (long)from);
  570. #endif
  571. /* Read the ECC syndrom through the DiskOnChip ECC
  572. logic. These syndrome will be all ZERO when there
  573. is no error */
  574. for (i = 0; i < 6; i++) {
  575. syndrome[i] =
  576. ReadDOC(docptr, ECCSyndrome0 + i);
  577. }
  578. nb_errors = doc_decode_ecc(buf, syndrome);
  579. #ifdef ECC_DEBUG
  580. printk(KERN_ERR "Errors corrected: %x\n", nb_errors);
  581. #endif
  582. if (nb_errors < 0) {
  583. /* We return error, but have actually done the
  584. read. Not that this can be told to
  585. user-space, via sys_read(), but at least
  586. MTD-aware stuff can know about it by
  587. checking *retlen */
  588. ret = -EIO;
  589. }
  590. }
  591. #ifdef PSYCHO_DEBUG
  592. printk(KERN_DEBUG "ECC DATA at %lxB: %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
  593. (long)from, eccbuf[0], eccbuf[1], eccbuf[2],
  594. eccbuf[3], eccbuf[4], eccbuf[5]);
  595. #endif
  596. /* disable the ECC engine */
  597. WriteDOC(DOC_ECC_DIS, docptr , ECCConf);
  598. /* according to 11.4.1, we need to wait for the busy line
  599. * drop if we read to the end of the page. */
  600. if(0 == ((from + len) & 0x1ff))
  601. {
  602. DoC_WaitReady(this);
  603. }
  604. from += len;
  605. left -= len;
  606. buf += len;
  607. }
  608. mutex_unlock(&this->lock);
  609. return ret;
  610. }
  611. static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
  612. size_t * retlen, const u_char * buf)
  613. {
  614. struct DiskOnChip *this = mtd->priv;
  615. int di; /* Yes, DI is a hangover from when I was disassembling the binary driver */
  616. void __iomem *docptr = this->virtadr;
  617. unsigned char eccbuf[6];
  618. volatile char dummy;
  619. int len256 = 0;
  620. struct Nand *mychip;
  621. size_t left = len;
  622. int status;
  623. /* Don't allow write past end of device */
  624. if (to >= this->totlen)
  625. return -EINVAL;
  626. mutex_lock(&this->lock);
  627. *retlen = 0;
  628. while (left) {
  629. len = left;
  630. /* Don't allow a single write to cross a 512-byte block boundary */
  631. if (to + len > ((to | 0x1ff) + 1))
  632. len = ((to | 0x1ff) + 1) - to;
  633. /* The ECC will not be calculated correctly if less than 512 is written */
  634. /* DBB-
  635. if (len != 0x200 && eccbuf)
  636. printk(KERN_WARNING
  637. "ECC needs a full sector write (adr: %lx size %lx)\n",
  638. (long) to, (long) len);
  639. -DBB */
  640. /* printk("DoC_Write (adr: %lx size %lx)\n", (long) to, (long) len); */
  641. /* Find the chip which is to be used and select it */
  642. mychip = &this->chips[to >> (this->chipshift)];
  643. if (this->curfloor != mychip->floor) {
  644. DoC_SelectFloor(this, mychip->floor);
  645. DoC_SelectChip(this, mychip->chip);
  646. } else if (this->curchip != mychip->chip) {
  647. DoC_SelectChip(this, mychip->chip);
  648. }
  649. this->curfloor = mychip->floor;
  650. this->curchip = mychip->chip;
  651. /* Set device to main plane of flash */
  652. DoC_Command(this, NAND_CMD_RESET, CDSN_CTRL_WP);
  653. DoC_Command(this,
  654. (!this->page256
  655. && (to & 0x100)) ? NAND_CMD_READ1 : NAND_CMD_READ0,
  656. CDSN_CTRL_WP);
  657. DoC_Command(this, NAND_CMD_SEQIN, 0);
  658. DoC_Address(this, ADDR_COLUMN_PAGE, to, 0, CDSN_CTRL_ECC_IO);
  659. /* Prime the ECC engine */
  660. WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
  661. WriteDOC(DOC_ECC_EN | DOC_ECC_RW, docptr, ECCConf);
  662. /* treat crossing 256-byte sector for 2M x 8bits devices */
  663. if (this->page256 && to + len > (to | 0xff) + 1) {
  664. len256 = (to | 0xff) + 1 - to;
  665. DoC_WriteBuf(this, buf, len256);
  666. DoC_Command(this, NAND_CMD_PAGEPROG, 0);
  667. DoC_Command(this, NAND_CMD_STATUS, CDSN_CTRL_WP);
  668. /* There's an implicit DoC_WaitReady() in DoC_Command */
  669. dummy = ReadDOC(docptr, CDSNSlowIO);
  670. DoC_Delay(this, 2);
  671. if (ReadDOC_(docptr, this->ioreg) & 1) {
  672. printk(KERN_ERR "Error programming flash\n");
  673. /* Error in programming */
  674. *retlen = 0;
  675. mutex_unlock(&this->lock);
  676. return -EIO;
  677. }
  678. DoC_Command(this, NAND_CMD_SEQIN, 0);
  679. DoC_Address(this, ADDR_COLUMN_PAGE, to + len256, 0,
  680. CDSN_CTRL_ECC_IO);
  681. }
  682. DoC_WriteBuf(this, &buf[len256], len - len256);
  683. WriteDOC(CDSN_CTRL_ECC_IO | CDSN_CTRL_CE, docptr, CDSNControl);
  684. if (DoC_is_Millennium(this)) {
  685. WriteDOC(0, docptr, NOP);
  686. WriteDOC(0, docptr, NOP);
  687. WriteDOC(0, docptr, NOP);
  688. } else {
  689. WriteDOC_(0, docptr, this->ioreg);
  690. WriteDOC_(0, docptr, this->ioreg);
  691. WriteDOC_(0, docptr, this->ioreg);
  692. }
  693. WriteDOC(CDSN_CTRL_ECC_IO | CDSN_CTRL_FLASH_IO | CDSN_CTRL_CE, docptr,
  694. CDSNControl);
  695. /* Read the ECC data through the DiskOnChip ECC logic */
  696. for (di = 0; di < 6; di++) {
  697. eccbuf[di] = ReadDOC(docptr, ECCSyndrome0 + di);
  698. }
  699. /* Reset the ECC engine */
  700. WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
  701. #ifdef PSYCHO_DEBUG
  702. printk
  703. ("OOB data at %lx is %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
  704. (long) to, eccbuf[0], eccbuf[1], eccbuf[2], eccbuf[3],
  705. eccbuf[4], eccbuf[5]);
  706. #endif
  707. DoC_Command(this, NAND_CMD_PAGEPROG, 0);
  708. DoC_Command(this, NAND_CMD_STATUS, CDSN_CTRL_WP);
  709. /* There's an implicit DoC_WaitReady() in DoC_Command */
  710. if (DoC_is_Millennium(this)) {
  711. ReadDOC(docptr, ReadPipeInit);
  712. status = ReadDOC(docptr, LastDataRead);
  713. } else {
  714. dummy = ReadDOC(docptr, CDSNSlowIO);
  715. DoC_Delay(this, 2);
  716. status = ReadDOC_(docptr, this->ioreg);
  717. }
  718. if (status & 1) {
  719. printk(KERN_ERR "Error programming flash\n");
  720. /* Error in programming */
  721. *retlen = 0;
  722. mutex_unlock(&this->lock);
  723. return -EIO;
  724. }
  725. /* Let the caller know we completed it */
  726. *retlen += len;
  727. if (eccbuf) {
  728. unsigned char x[8];
  729. size_t dummy;
  730. int ret;
  731. /* Write the ECC data to flash */
  732. for (di=0; di<6; di++)
  733. x[di] = eccbuf[di];
  734. x[6]=0x55;
  735. x[7]=0x55;
  736. ret = doc_write_oob_nolock(mtd, to, 8, &dummy, x);
  737. if (ret) {
  738. mutex_unlock(&this->lock);
  739. return ret;
  740. }
  741. }
  742. to += len;
  743. left -= len;
  744. buf += len;
  745. }
  746. mutex_unlock(&this->lock);
  747. return 0;
  748. }
  749. static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
  750. struct mtd_oob_ops *ops)
  751. {
  752. struct DiskOnChip *this = mtd->priv;
  753. int len256 = 0, ret;
  754. struct Nand *mychip;
  755. uint8_t *buf = ops->oobbuf;
  756. size_t len = ops->len;
  757. BUG_ON(ops->mode != MTD_OOB_PLACE);
  758. ofs += ops->ooboffs;
  759. mutex_lock(&this->lock);
  760. mychip = &this->chips[ofs >> this->chipshift];
  761. if (this->curfloor != mychip->floor) {
  762. DoC_SelectFloor(this, mychip->floor);
  763. DoC_SelectChip(this, mychip->chip);
  764. } else if (this->curchip != mychip->chip) {
  765. DoC_SelectChip(this, mychip->chip);
  766. }
  767. this->curfloor = mychip->floor;
  768. this->curchip = mychip->chip;
  769. /* update address for 2M x 8bit devices. OOB starts on the second */
  770. /* page to maintain compatibility with doc_read_ecc. */
  771. if (this->page256) {
  772. if (!(ofs & 0x8))
  773. ofs += 0x100;
  774. else
  775. ofs -= 0x8;
  776. }
  777. DoC_Command(this, NAND_CMD_READOOB, CDSN_CTRL_WP);
  778. DoC_Address(this, ADDR_COLUMN_PAGE, ofs, CDSN_CTRL_WP, 0);
  779. /* treat crossing 8-byte OOB data for 2M x 8bit devices */
  780. /* Note: datasheet says it should automaticaly wrap to the */
  781. /* next OOB block, but it didn't work here. mf. */
  782. if (this->page256 && ofs + len > (ofs | 0x7) + 1) {
  783. len256 = (ofs | 0x7) + 1 - ofs;
  784. DoC_ReadBuf(this, buf, len256);
  785. DoC_Command(this, NAND_CMD_READOOB, CDSN_CTRL_WP);
  786. DoC_Address(this, ADDR_COLUMN_PAGE, ofs & (~0x1ff),
  787. CDSN_CTRL_WP, 0);
  788. }
  789. DoC_ReadBuf(this, &buf[len256], len - len256);
  790. ops->retlen = len;
  791. /* Reading the full OOB data drops us off of the end of the page,
  792. * causing the flash device to go into busy mode, so we need
  793. * to wait until ready 11.4.1 and Toshiba TC58256FT docs */
  794. ret = DoC_WaitReady(this);
  795. mutex_unlock(&this->lock);
  796. return ret;
  797. }
  798. static int doc_write_oob_nolock(struct mtd_info *mtd, loff_t ofs, size_t len,
  799. size_t * retlen, const u_char * buf)
  800. {
  801. struct DiskOnChip *this = mtd->priv;
  802. int len256 = 0;
  803. void __iomem *docptr = this->virtadr;
  804. struct Nand *mychip = &this->chips[ofs >> this->chipshift];
  805. volatile int dummy;
  806. int status;
  807. // printk("doc_write_oob(%lx, %d): %2.2X %2.2X %2.2X %2.2X ... %2.2X %2.2X .. %2.2X %2.2X\n",(long)ofs, len,
  808. // buf[0], buf[1], buf[2], buf[3], buf[8], buf[9], buf[14],buf[15]);
  809. /* Find the chip which is to be used and select it */
  810. if (this->curfloor != mychip->floor) {
  811. DoC_SelectFloor(this, mychip->floor);
  812. DoC_SelectChip(this, mychip->chip);
  813. } else if (this->curchip != mychip->chip) {
  814. DoC_SelectChip(this, mychip->chip);
  815. }
  816. this->curfloor = mychip->floor;
  817. this->curchip = mychip->chip;
  818. /* disable the ECC engine */
  819. WriteDOC (DOC_ECC_RESET, docptr, ECCConf);
  820. WriteDOC (DOC_ECC_DIS, docptr, ECCConf);
  821. /* Reset the chip, see Software Requirement 11.4 item 1. */
  822. DoC_Command(this, NAND_CMD_RESET, CDSN_CTRL_WP);
  823. /* issue the Read2 command to set the pointer to the Spare Data Area. */
  824. DoC_Command(this, NAND_CMD_READOOB, CDSN_CTRL_WP);
  825. /* update address for 2M x 8bit devices. OOB starts on the second */
  826. /* page to maintain compatibility with doc_read_ecc. */
  827. if (this->page256) {
  828. if (!(ofs & 0x8))
  829. ofs += 0x100;
  830. else
  831. ofs -= 0x8;
  832. }
  833. /* issue the Serial Data In command to initial the Page Program process */
  834. DoC_Command(this, NAND_CMD_SEQIN, 0);
  835. DoC_Address(this, ADDR_COLUMN_PAGE, ofs, 0, 0);
  836. /* treat crossing 8-byte OOB data for 2M x 8bit devices */
  837. /* Note: datasheet says it should automaticaly wrap to the */
  838. /* next OOB block, but it didn't work here. mf. */
  839. if (this->page256 && ofs + len > (ofs | 0x7) + 1) {
  840. len256 = (ofs | 0x7) + 1 - ofs;
  841. DoC_WriteBuf(this, buf, len256);
  842. DoC_Command(this, NAND_CMD_PAGEPROG, 0);
  843. DoC_Command(this, NAND_CMD_STATUS, 0);
  844. /* DoC_WaitReady() is implicit in DoC_Command */
  845. if (DoC_is_Millennium(this)) {
  846. ReadDOC(docptr, ReadPipeInit);
  847. status = ReadDOC(docptr, LastDataRead);
  848. } else {
  849. dummy = ReadDOC(docptr, CDSNSlowIO);
  850. DoC_Delay(this, 2);
  851. status = ReadDOC_(docptr, this->ioreg);
  852. }
  853. if (status & 1) {
  854. printk(KERN_ERR "Error programming oob data\n");
  855. /* There was an error */
  856. *retlen = 0;
  857. return -EIO;
  858. }
  859. DoC_Command(this, NAND_CMD_SEQIN, 0);
  860. DoC_Address(this, ADDR_COLUMN_PAGE, ofs & (~0x1ff), 0, 0);
  861. }
  862. DoC_WriteBuf(this, &buf[len256], len - len256);
  863. DoC_Command(this, NAND_CMD_PAGEPROG, 0);
  864. DoC_Command(this, NAND_CMD_STATUS, 0);
  865. /* DoC_WaitReady() is implicit in DoC_Command */
  866. if (DoC_is_Millennium(this)) {
  867. ReadDOC(docptr, ReadPipeInit);
  868. status = ReadDOC(docptr, LastDataRead);
  869. } else {
  870. dummy = ReadDOC(docptr, CDSNSlowIO);
  871. DoC_Delay(this, 2);
  872. status = ReadDOC_(docptr, this->ioreg);
  873. }
  874. if (status & 1) {
  875. printk(KERN_ERR "Error programming oob data\n");
  876. /* There was an error */
  877. *retlen = 0;
  878. return -EIO;
  879. }
  880. *retlen = len;
  881. return 0;
  882. }
  883. static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
  884. struct mtd_oob_ops *ops)
  885. {
  886. struct DiskOnChip *this = mtd->priv;
  887. int ret;
  888. BUG_ON(ops->mode != MTD_OOB_PLACE);
  889. mutex_lock(&this->lock);
  890. ret = doc_write_oob_nolock(mtd, ofs + ops->ooboffs, ops->len,
  891. &ops->retlen, ops->oobbuf);
  892. mutex_unlock(&this->lock);
  893. return ret;
  894. }
  895. static int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
  896. {
  897. struct DiskOnChip *this = mtd->priv;
  898. __u32 ofs = instr->addr;
  899. __u32 len = instr->len;
  900. volatile int dummy;
  901. void __iomem *docptr = this->virtadr;
  902. struct Nand *mychip;
  903. int status;
  904. mutex_lock(&this->lock);
  905. if (ofs & (mtd->erasesize-1) || len & (mtd->erasesize-1)) {
  906. mutex_unlock(&this->lock);
  907. return -EINVAL;
  908. }
  909. instr->state = MTD_ERASING;
  910. /* FIXME: Do this in the background. Use timers or schedule_task() */
  911. while(len) {
  912. mychip = &this->chips[ofs >> this->chipshift];
  913. if (this->curfloor != mychip->floor) {
  914. DoC_SelectFloor(this, mychip->floor);
  915. DoC_SelectChip(this, mychip->chip);
  916. } else if (this->curchip != mychip->chip) {
  917. DoC_SelectChip(this, mychip->chip);
  918. }
  919. this->curfloor = mychip->floor;
  920. this->curchip = mychip->chip;
  921. DoC_Command(this, NAND_CMD_ERASE1, 0);
  922. DoC_Address(this, ADDR_PAGE, ofs, 0, 0);
  923. DoC_Command(this, NAND_CMD_ERASE2, 0);
  924. DoC_Command(this, NAND_CMD_STATUS, CDSN_CTRL_WP);
  925. if (DoC_is_Millennium(this)) {
  926. ReadDOC(docptr, ReadPipeInit);
  927. status = ReadDOC(docptr, LastDataRead);
  928. } else {
  929. dummy = ReadDOC(docptr, CDSNSlowIO);
  930. DoC_Delay(this, 2);
  931. status = ReadDOC_(docptr, this->ioreg);
  932. }
  933. if (status & 1) {
  934. printk(KERN_ERR "Error erasing at 0x%x\n", ofs);
  935. /* There was an error */
  936. instr->state = MTD_ERASE_FAILED;
  937. goto callback;
  938. }
  939. ofs += mtd->erasesize;
  940. len -= mtd->erasesize;
  941. }
  942. instr->state = MTD_ERASE_DONE;
  943. callback:
  944. mtd_erase_callback(instr);
  945. mutex_unlock(&this->lock);
  946. return 0;
  947. }
  948. /****************************************************************************
  949. *
  950. * Module stuff
  951. *
  952. ****************************************************************************/
  953. static void __exit cleanup_doc2000(void)
  954. {
  955. struct mtd_info *mtd;
  956. struct DiskOnChip *this;
  957. while ((mtd = doc2klist)) {
  958. this = mtd->priv;
  959. doc2klist = this->nextdoc;
  960. del_mtd_device(mtd);
  961. iounmap(this->virtadr);
  962. kfree(this->chips);
  963. kfree(mtd);
  964. }
  965. }
  966. module_exit(cleanup_doc2000);
  967. MODULE_LICENSE("GPL");
  968. MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org> et al.");
  969. MODULE_DESCRIPTION("MTD driver for DiskOnChip 2000 and Millennium");