doc2000.c 32 KB

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