mtd/drivers/mtd/nand diskonchip.c,1.11,1.12
dbrown at infradead.org
dbrown at infradead.org
Wed Jun 16 22:41:21 EDT 2004
Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv7523/drivers/mtd/nand
Modified Files:
diskonchip.c
Log Message:
Fix ECC support for DOC 2000. Fix some C usage that bothers older GCC versions.
Index: diskonchip.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/diskonchip.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- diskonchip.c 16 Jun 2004 21:10:36 -0000 1.11
+++ diskonchip.c 17 Jun 2004 02:41:19 -0000 1.12
@@ -120,10 +120,11 @@
struct nand_chip *this = mtd->priv;
struct doc_priv *doc = (void *)this->priv;
unsigned long docptr = doc->virtadr;
+ u_char ret;
ReadDOC(docptr, CDSNSlowIO);
DoC_Delay(doc, 2);
- u_char ret = ReadDOC(docptr, 2k_CDSN_IO);
+ ret = ReadDOC(docptr, 2k_CDSN_IO);
if (debug) printk("read_byte returns %02x\n", ret);
return ret;
}
@@ -460,60 +461,28 @@
return 0;
}
-static int doc2000_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
+/* This code is only called on write */
+static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
unsigned char *ecc_code)
{
struct nand_chip *this = mtd->priv;
struct doc_priv *doc = (void *)this->priv;
unsigned long docptr = doc->virtadr;
- volatile char dummy;
- int stat;
int i;
- // DBB : check for NULL ecc_code here?
- // DBB note: I'm using the presence of dat as a read/write indicator. FIX ME!
- if (dat) {
- // DBB: this is assumed to be a read
- // flush the pipeline:
- dummy = ReadDOC(docptr, 2k_ECCStatus);
- dummy = ReadDOC(docptr, 2k_ECCStatus);
- dummy = ReadDOC(docptr, 2k_ECCStatus);
- stat = dummy & 0x80;
- } else {
- // DBB: this is assumed to be a write
+ /* flush the pipeline */
+ if (DoC_is_2000(doc)) {
WriteDOC(doc->CDSNControl & ~CDSN_CTRL_FLASH_IO, docptr, CDSNControl);
WriteDOC(0, docptr, 2k_CDSN_IO);
WriteDOC(0, docptr, 2k_CDSN_IO);
WriteDOC(0, docptr, 2k_CDSN_IO);
WriteDOC(doc->CDSNControl, docptr, CDSNControl);
- stat = 1;
- }
- if (stat) {
- for (i = 0; i < 6; i++)
- ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
} else {
- /* On read, if there were no ECC errors, the syndrome is by
- definition zero. We can skip actually reading it. */
- memset(ecc_code, 0, 6);
+ WriteDOC(0, docptr, NOP);
+ WriteDOC(0, docptr, NOP);
+ WriteDOC(0, docptr, NOP);
}
- WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
- return stat;
-}
-
-
-/* This code is only called on write */
-static int doc2001_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
- unsigned char *ecc_code)
-{
- struct nand_chip *this = mtd->priv;
- struct doc_priv *doc = (void *)this->priv;
- unsigned long docptr = doc->virtadr;
- int i;
- /* flush the pipeline */
- WriteDOC(0, docptr, NOP);
- WriteDOC(0, docptr, NOP);
- WriteDOC(0, docptr, NOP);
for (i = 0; i < 6; i++)
ecc_code[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
@@ -529,9 +498,15 @@
volatile char dummy;
/* flush the pipeline */
- dummy = ReadDOC(docptr, ECCConf);
- dummy = ReadDOC(docptr, ECCConf);
- dummy = ReadDOC(docptr, ECCConf);
+ if (DoC_is_2000(doc)) {
+ dummy = ReadDOC(docptr, 2k_ECCStatus);
+ dummy = ReadDOC(docptr, 2k_ECCStatus);
+ dummy = ReadDOC(docptr, 2k_ECCStatus);
+ } else {
+ dummy = ReadDOC(docptr, ECCConf);
+ dummy = ReadDOC(docptr, ECCConf);
+ dummy = ReadDOC(docptr, ECCConf);
+ }
/* Error occured ? */
if (dummy & 0x80) {
@@ -572,7 +547,8 @@
.options = NAND_USE_FLASH_BBT | NAND_HWECC_SYNDROME,
.autooob = &doc200x_oobinfo,
.correct_data = doc200x_correct_data,
- .enable_hwecc = doc200x_enable_hwecc
+ .enable_hwecc = doc200x_enable_hwecc,
+ .calculate_ecc = doc200x_calculate_ecc
};
static struct mtd_info mymtd = {
@@ -585,7 +561,13 @@
{
u_char buf[SECTORSIZE];
struct INFTLMediaHeader *mh = (struct INFTLMediaHeader *) &buf;
+ struct mtd_partition parts[6];
+ struct INFTLPartition *ip;
+ int numparts = 0;
+ int lastblock = 0;
+ int i;
int offs;
+
for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
int ret, retlen;
if ((ret = MTD_READ(mtd, offs, SECTORSIZE, &retlen, buf)))
@@ -630,14 +612,9 @@
return 0;
}
- struct mtd_partition parts[6];
memset((char *) parts, 0, sizeof(parts));
- int numparts = 0;
- int lastblock = 0;
/* Scan the partitions */
- int i;
- struct INFTLPartition *ip;
for (i = 0; (i < 4); i++) {
ip = &(mh->Partitions[i]);
ip->virtualUnits = le32_to_cpu(ip->virtualUnits);
@@ -691,9 +668,9 @@
int __init init_nanddoc(void)
{
- mydoc.virtadr = (unsigned long)ioremap(mydoc.physadr, DOC_IOREMAP_LEN);
int nrchips = 1;
char *name;
+ mydoc.virtadr = (unsigned long)ioremap(mydoc.physadr, DOC_IOREMAP_LEN);
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
mydoc.virtadr, DOCControl);
@@ -715,7 +692,6 @@
mynand.read_buf = doc2001_readbuf;
mynand.verify_buf = doc2001_verifybuf;
mynand.bbt_td = &inftl_bbt_descr;
- mynand.calculate_ecc = doc2001_calculate_ecc;
//mynand.scan_bbt = nftl_scan_bbt;
ReadDOC(mydoc.virtadr, ChipID);
@@ -742,7 +718,6 @@
mynand.write_buf = doc2000_writebuf;
mynand.read_buf = doc2000_readbuf;
mynand.verify_buf = doc2000_verifybuf;
- mynand.calculate_ecc = doc2000_calculate_ecc;
doc2000_count_chips(&mymtd);
nrchips = 4 * mydoc.chips_per_floor;
More information about the linux-mtd-cvs
mailing list