static int DoC_Command(struct DiskOnChip *doc, unsigned char command, unsigned char xtraflags) { void __iomem *docptr = doc->virtadr; if (DoC_is_2000(doc)) xtraflags |= CDSN_CTRL_FLASH_IO; /* Assert the CLE (Command Latch Enable) line to the flash chip */ WriteDOC(xtraflags | CDSN_CTRL_CLE | CDSN_CTRL_CE, docptr, CDSNControl); DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */ if (DoC_is_Millennium(doc)) WriteDOC(command, docptr, CDSNSlowIO); /* Send the command */ WriteDOC_(command, docptr, doc->ioreg); if (DoC_is_Millennium(doc)) WriteDOC(command, docptr, WritePipeTerm); /* Lower the CLE line */ WriteDOC(xtraflags | CDSN_CTRL_CE, docptr, CDSNControl); DoC_Delay(doc, 4); /* Software requirement 11.4.3 for Millennium */ /* Wait for the chip to respond - Software requirement 11.4.1 (extended for any command) */ return DoC_WaitReady(doc); }
/* DoC_SelectFloor: Select a given floor (bank of flash chips) */ static int DoC_SelectFloor(void __iomem * docptr, int floor) { /* Select the floor (bank) of chips required */ WriteDOC(floor, docptr, FloorSelect); /* Wait for the chip to be ready */ return DoC_WaitReady(docptr); }
static int DoC_SelectFloor(void __iomem * docptr, int floor) { WriteDOC(floor, docptr, FloorSelect); return DoC_WaitReady(docptr); }
/* DoC_IdentChip: Identify a given NAND chip given {floor,chip} */ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip) { int mfr, id, i, j; volatile char dummy; /* Page in the required floor/chip FIXME: is this supported by Millennium ?? */ DoC_SelectFloor(doc->virtadr, floor); DoC_SelectChip(doc->virtadr, chip); /* Reset the chip, see Software Requirement 11.4 item 1. */ DoC_Command(doc->virtadr, NAND_CMD_RESET, CDSN_CTRL_WP); DoC_WaitReady(doc->virtadr); /* Read the NAND chip ID: 1. Send ReadID command */ DoC_Command(doc->virtadr, NAND_CMD_READID, CDSN_CTRL_WP); /* Read the NAND chip ID: 2. Send address byte zero */ DoC_Address(doc->virtadr, 1, 0x00, CDSN_CTRL_WP, 0x00); /* Read the manufacturer and device id codes of the flash device through CDSN IO register see Software Requirement 11.4 item 5.*/ dummy = ReadDOC(doc->virtadr, ReadPipeInit); DoC_Delay(doc->virtadr, 2); mfr = ReadDOC(doc->virtadr, Mil_CDSN_IO); DoC_Delay(doc->virtadr, 2); id = ReadDOC(doc->virtadr, Mil_CDSN_IO); dummy = ReadDOC(doc->virtadr, LastDataRead); /* No response - return failure */ if (mfr == 0xff || mfr == 0) return 0; /* FIXME: to deal with multi-flash on multi-Millennium case more carefully */ for (i = 0; nand_flash_ids[i].name != NULL; i++) { if ( id == nand_flash_ids[i].id) { /* Try to identify manufacturer */ for (j = 0; nand_manuf_ids[j].id != 0x0; j++) { if (nand_manuf_ids[j].id == mfr) break; } printk(KERN_INFO "Flash chip found: Manufacturer ID: %2.2X, " "Chip ID: %2.2X (%s:%s)\n", mfr, id, nand_manuf_ids[j].name, nand_flash_ids[i].name); doc->mfr = mfr; doc->id = id; doc->chipshift = ffs((nand_flash_ids[i].chipsize << 20)) - 1; break; } } if (nand_flash_ids[i].name == NULL) return 0; else return 1; }
/* DoC_SelectChip: Select a given flash chip within the current floor */ static int DoC_SelectChip(void __iomem * docptr, int chip) { /* Select the individual flash chip requested */ WriteDOC(chip, docptr, CDSNDeviceSelect); DoC_Delay(docptr, 4); /* Wait for it to be ready */ return DoC_WaitReady(docptr); }
static int DoC_SelectChip(void __iomem * docptr, int chip) { WriteDOC(chip, docptr, CDSNDeviceSelect); DoC_Delay(docptr, 4); return DoC_WaitReady(docptr); }
static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip) { int mfr, id, i, j; volatile char dummy; DoC_SelectFloor(doc->virtadr, floor); DoC_SelectChip(doc->virtadr, chip); DoC_Command(doc->virtadr, NAND_CMD_RESET, CDSN_CTRL_WP); DoC_WaitReady(doc->virtadr); DoC_Command(doc->virtadr, NAND_CMD_READID, CDSN_CTRL_WP); DoC_Address(doc->virtadr, 1, 0x00, CDSN_CTRL_WP, 0x00); dummy = ReadDOC(doc->virtadr, ReadPipeInit); DoC_Delay(doc->virtadr, 2); mfr = ReadDOC(doc->virtadr, Mil_CDSN_IO); DoC_Delay(doc->virtadr, 2); id = ReadDOC(doc->virtadr, Mil_CDSN_IO); dummy = ReadDOC(doc->virtadr, LastDataRead); if (mfr == 0xff || mfr == 0) return 0; for (i = 0; nand_flash_ids[i].name != NULL; i++) { if ( id == nand_flash_ids[i].id) { for (j = 0; nand_manuf_ids[j].id != 0x0; j++) { if (nand_manuf_ids[j].id == mfr) break; } printk(KERN_INFO "Flash chip found: Manufacturer ID: %2.2X, " "Chip ID: %2.2X (%s:%s)\n", mfr, id, nand_manuf_ids[j].name, nand_flash_ids[i].name); doc->mfr = mfr; doc->id = id; doc->chipshift = ffs((nand_flash_ids[i].chipsize << 20)) - 1; break; } } if (nand_flash_ids[i].name == NULL) return 0; else return 1; }
/* DoC_IdentChip: Identify a given NAND chip given {floor,chip} */ static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip) { int mfr, id, i, j; volatile char dummy; void __iomem * docptr = doc->virtadr; /* Page in the required floor/chip */ DoC_SelectFloor(docptr, floor); DoC_SelectChip(docptr, chip); /* Millennium Plus bus cycle sequence as per figure 2, section 2.4 */ WriteDOC((DOC_FLASH_CE | DOC_FLASH_WP), docptr, Mplus_FlashSelect); /* Reset the chip, see Software Requirement 11.4 item 1. */ DoC_Command(docptr, NAND_CMD_RESET, 0); DoC_WaitReady(docptr); /* Read the NAND chip ID: 1. Send ReadID command */ DoC_Command(docptr, NAND_CMD_READID, 0); /* Read the NAND chip ID: 2. Send address byte zero */ DoC_Address(doc, 1, 0x00, 0, 0x00); WriteDOC(0, docptr, Mplus_FlashControl); DoC_WaitReady(docptr); /* Read the manufacturer and device id codes of the flash device through CDSN IO register see Software Requirement 11.4 item 5.*/ dummy = ReadDOC(docptr, Mplus_ReadPipeInit); dummy = ReadDOC(docptr, Mplus_ReadPipeInit); mfr = ReadDOC(docptr, Mil_CDSN_IO); if (doc->interleave) dummy = ReadDOC(docptr, Mil_CDSN_IO); /* 2 way interleave */ id = ReadDOC(docptr, Mil_CDSN_IO); if (doc->interleave) dummy = ReadDOC(docptr, Mil_CDSN_IO); /* 2 way interleave */ dummy = ReadDOC(docptr, Mplus_LastDataRead); dummy = ReadDOC(docptr, Mplus_LastDataRead); /* Disable flash internally */ WriteDOC(0, docptr, Mplus_FlashSelect); /* No response - return failure */ if (mfr == 0xff || mfr == 0) return 0; for (i = 0; nand_flash_ids[i].name != NULL; i++) { if (id == nand_flash_ids[i].id) { /* Try to identify manufacturer */ for (j = 0; nand_manuf_ids[j].id != 0x0; j++) { if (nand_manuf_ids[j].id == mfr) break; } printk(KERN_INFO "Flash chip found: Manufacturer ID: %2.2X, " "Chip ID: %2.2X (%s:%s)\n", mfr, id, nand_manuf_ids[j].name, nand_flash_ids[i].name); doc->mfr = mfr; doc->id = id; doc->chipshift = ffs((nand_flash_ids[i].chipsize << 20)) - 1; doc->erasesize = nand_flash_ids[i].erasesize << doc->interleave; break; } } if (nand_flash_ids[i].name == NULL) return 0; return 1; }