doc2000.c 32 KB

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