Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 27850
b: refs/heads/master
c: 6dfc6d2
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Gleixner committed May 23, 2006
1 parent a862843 commit c92867f
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 167 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7aa65bfd6793a56cc3bbce8436abbfea3a7bdd1f
refs/heads/master: 6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd
2 changes: 1 addition & 1 deletion trunk/drivers/mtd/nand/ams-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static int __init ams_delta_init(void)
}
/* 25 us command delay time */
this->chip_delay = 30;
this->eccmode = NAND_ECC_SOFT;
this->ecc.mode = NAND_ECC_SOFT;

/* Set chip enabled, but */
ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE |
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mtd/nand/au1550nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ static int __init au1xxx_nand_init(void)

/* 30 us command delay time */
this->chip_delay = 30;
this->eccmode = NAND_ECC_SOFT;
this->ecc.mode = NAND_ECC_SOFT;

this->options = NAND_NO_AUTOINCR;

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mtd/nand/autcpu12.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int __init autcpu12_init(void)
this->dev_ready = autcpu12_device_ready;
/* 20 us command delay time */
this->chip_delay = 20;
this->eccmode = NAND_ECC_SOFT;
this->ecc.mode = NAND_ECC_SOFT;

/* Enable the following for a flash based bad block table */
/*
Expand Down
12 changes: 7 additions & 5 deletions trunk/drivers/mtd/nand/cs553x_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,13 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)

this->chip_delay = 0;

this->eccmode = NAND_ECC_HW3_256;
this->enable_hwecc = cs_enable_hwecc;
this->calculate_ecc = cs_calculate_ecc;
this->correct_data = nand_correct_data;

this->ecc.mode = NAND_ECC_HW;
this->ecc.size = 256;
this->ecc.bytes = 3;
this->ecc.hwctl = cs_enable_hwecc;
this->ecc.calculate = cs_calculate_ecc;
this->ecc.correct = nand_correct_data;

/* Enable the following for a flash based bad block table */
this->options = NAND_USE_FLASH_BBT | NAND_NO_AUTOINCR;

Expand Down
10 changes: 6 additions & 4 deletions trunk/drivers/mtd/nand/diskonchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,12 +1674,14 @@ static int __init doc_probe(unsigned long physadr)
nand->dev_ready = doc200x_dev_ready;
nand->waitfunc = doc200x_wait;
nand->block_bad = doc200x_block_bad;
nand->enable_hwecc = doc200x_enable_hwecc;
nand->calculate_ecc = doc200x_calculate_ecc;
nand->correct_data = doc200x_correct_data;
nand->ecc.hwctl = doc200x_enable_hwecc;
nand->ecc.calculate = doc200x_calculate_ecc;
nand->ecc.correct = doc200x_correct_data;

nand->autooob = &doc200x_oobinfo;
nand->eccmode = NAND_ECC_HW6_512;
nand->ecc.mode = NAND_ECC_HW_SYNDROME;
nand->ecc.size = 512;
nand->ecc.bytes = 6;
nand->options = NAND_USE_FLASH_BBT | NAND_HWECC_SYNDROME;

doc->physadr = physadr;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mtd/nand/h1910.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static int __init h1910_init(void)
this->dev_ready = NULL; /* unknown whether that was correct or not so we will just do it like this */
/* 15 us command delay time */
this->chip_delay = 50;
this->eccmode = NAND_ECC_SOFT;
this->ecc.mode = NAND_ECC_SOFT;
this->options = NAND_NO_AUTOINCR;

/* Scan to find existence of the device */
Expand Down
146 changes: 48 additions & 98 deletions trunk/drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,9 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
{
int i, status;
uint8_t ecc_code[32];
int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
int eccmode = oobsel->useecc ? this->ecc.mode : NAND_ECC_NONE;
int *oob_config = oobsel->eccpos;
int datidx = 0, eccidx = 0, eccsteps = this->eccsteps;
int datidx = 0, eccidx = 0, eccsteps = this->ecc.steps;
int eccbytes = 0;

/* FIXME: Enable cached programming */
Expand All @@ -901,28 +901,28 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
/* Software ecc 3/256, write all */
case NAND_ECC_SOFT:
for (; eccsteps; eccsteps--) {
this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code);
this->ecc.calculate(mtd, &this->data_poi[datidx], ecc_code);
for (i = 0; i < 3; i++, eccidx++)
oob_buf[oob_config[eccidx]] = ecc_code[i];
datidx += this->eccsize;
datidx += this->ecc.size;
}
this->write_buf(mtd, this->data_poi, mtd->oobblock);
break;
default:
eccbytes = this->eccbytes;
eccbytes = this->ecc.bytes;
for (; eccsteps; eccsteps--) {
/* enable hardware ecc logic for write */
this->enable_hwecc(mtd, NAND_ECC_WRITE);
this->write_buf(mtd, &this->data_poi[datidx], this->eccsize);
this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code);
this->ecc.hwctl(mtd, NAND_ECC_WRITE);
this->write_buf(mtd, &this->data_poi[datidx], this->ecc.size);
this->ecc.calculate(mtd, &this->data_poi[datidx], ecc_code);
for (i = 0; i < eccbytes; i++, eccidx++)
oob_buf[oob_config[eccidx]] = ecc_code[i];
/* If the hardware ecc provides syndromes then
* the ecc code must be written immidiately after
* the data bytes (words) */
if (this->options & NAND_HWECC_SYNDROME)
this->write_buf(mtd, ecc_code, eccbytes);
datidx += this->eccsize;
datidx += this->ecc.size;
}
break;
}
Expand Down Expand Up @@ -1155,7 +1155,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
if (oobsel->useecc == MTD_NANDECC_AUTOPLACE)
oobsel = this->autooob;

eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
eccmode = oobsel->useecc ? this->ecc.mode : NAND_ECC_NONE;
oob_config = oobsel->eccpos;

/* Select the NAND device */
Expand All @@ -1170,8 +1170,8 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
col = from & (mtd->oobblock - 1);

end = mtd->oobblock;
ecc = this->eccsize;
eccbytes = this->eccbytes;
ecc = this->ecc.size;
eccbytes = this->ecc.bytes;

if ((eccmode == NAND_ECC_NONE) || (this->options & NAND_HWECC_SYNDROME))
compareecc = 0;
Expand Down Expand Up @@ -1216,7 +1216,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
oobsel->useecc == MTD_NANDECC_AUTOPL_USR)
oob_data = &this->data_buf[end];

eccsteps = this->eccsteps;
eccsteps = this->ecc.steps;

switch (eccmode) {
case NAND_ECC_NONE:{
Expand All @@ -1234,32 +1234,32 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */
this->read_buf(mtd, data_poi, end);
for (i = 0, datidx = 0; eccsteps; eccsteps--, i += 3, datidx += ecc)
this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
this->ecc.calculate(mtd, &data_poi[datidx], &ecc_calc[i]);
break;

default:
for (i = 0, datidx = 0; eccsteps; eccsteps--, i += eccbytes, datidx += ecc) {
this->enable_hwecc(mtd, NAND_ECC_READ);
this->ecc.hwctl(mtd, NAND_ECC_READ);
this->read_buf(mtd, &data_poi[datidx], ecc);

/* HW ecc with syndrome calculation must read the
* syndrome from flash immidiately after the data */
if (!compareecc) {
/* Some hw ecc generators need to know when the
* syndrome is read from flash */
this->enable_hwecc(mtd, NAND_ECC_READSYN);
this->ecc.hwctl(mtd, NAND_ECC_READSYN);
this->read_buf(mtd, &oob_data[i], eccbytes);
/* We calc error correction directly, it checks the hw
* generator for an error, reads back the syndrome and
* does the error correction on the fly */
ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]);
ecc_status = this->ecc.correct(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]);
if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) {
DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: "
"Failed ECC read, page 0x%08x on chip %d\n", page, chipnr);
ecc_failed++;
}
} else {
this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
this->ecc.calculate(mtd, &data_poi[datidx], &ecc_calc[i]);
}
}
break;
Expand All @@ -1277,8 +1277,8 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
ecc_code[j] = oob_data[oob_config[j]];

/* correct data, if necessary */
for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) {
ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]);
for (i = 0, j = 0, datidx = 0; i < this->ecc.steps; i++, datidx += ecc) {
ecc_status = this->ecc.correct(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]);

/* Get next chunk of ecc bytes */
j += eccbytes;
Expand Down Expand Up @@ -1315,7 +1315,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
break;
case MTD_NANDECC_PLACE:
/* YAFFS1 legacy mode */
oob_data += this->eccsteps * sizeof(int);
oob_data += this->ecc.steps * sizeof(int);
default:
oob_data += mtd->oobsize;
}
Expand Down Expand Up @@ -2648,99 +2648,49 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
* check ECC mode, default to software if 3byte/512byte hardware ECC is
* selected and we have 256 byte pagesize fallback to software ECC
*/
this->eccsize = 256;
this->eccbytes = 3;

switch (this->eccmode) {
case NAND_ECC_HW12_2048:
if (mtd->oobblock < 2048) {
printk(KERN_WARNING "2048 byte HW ECC not possible on "
"%d byte page size, fallback to SW ECC\n",
mtd->oobblock);
this->eccmode = NAND_ECC_SOFT;
this->calculate_ecc = nand_calculate_ecc;
this->correct_data = nand_correct_data;
} else
this->eccsize = 2048;
break;

case NAND_ECC_HW3_512:
case NAND_ECC_HW6_512:
case NAND_ECC_HW8_512:
if (mtd->oobblock == 256) {
printk(KERN_WARNING "512 byte HW ECC not possible on "
"256 Byte pagesize, fallback to SW ECC \n");
this->eccmode = NAND_ECC_SOFT;
this->calculate_ecc = nand_calculate_ecc;
this->correct_data = nand_correct_data;
} else
this->eccsize = 512; /* set eccsize to 512 */
break;
switch (this->ecc.mode) {
case NAND_ECC_HW:
case NAND_ECC_HW_SYNDROME:
if (!this->ecc.calculate || !this->ecc.correct ||
!this->ecc.hwctl) {
printk(KERN_WARNING "No ECC functions supplied, "
"Hardware ECC not possible\n");
BUG();
}
if (mtd->oobblock >= this->ecc.size)
break;
printk(KERN_WARNING "%d byte HW ECC not possible on "
"%d byte page size, fallback to SW ECC\n",
this->ecc.size, mtd->oobblock);
this->ecc.mode = NAND_ECC_SOFT;

case NAND_ECC_HW3_256:
case NAND_ECC_SOFT:
this->ecc.calculate = nand_calculate_ecc;
this->ecc.correct = nand_correct_data;
this->ecc.size = 256;
this->ecc.bytes = 3;
break;

case NAND_ECC_NONE:
printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. "
"This is not recommended !!\n");
this->eccmode = NAND_ECC_NONE;
this->ecc.size = mtd->oobblock;
this->ecc.bytes = 0;
break;

case NAND_ECC_SOFT:
this->calculate_ecc = nand_calculate_ecc;
this->correct_data = nand_correct_data;
break;

default:
printk(KERN_WARNING "Invalid NAND_ECC_MODE %d\n",
this->eccmode);
BUG();
}

/*
* Check hardware ecc function availability and adjust number of ecc
* bytes per calculation step
*/
switch (this->eccmode) {
case NAND_ECC_HW12_2048:
this->eccbytes += 4;
case NAND_ECC_HW8_512:
this->eccbytes += 2;
case NAND_ECC_HW6_512:
this->eccbytes += 3;
case NAND_ECC_HW3_512:
case NAND_ECC_HW3_256:
if (this->calculate_ecc && this->correct_data &&
this->enable_hwecc)
break;
printk(KERN_WARNING "No ECC functions supplied, "
"Hardware ECC not possible\n");
this->ecc.mode);
BUG();
}

mtd->eccsize = this->eccsize;

/*
* Set the number of read / write steps for one page depending on ECC
* mode
*/
switch (this->eccmode) {
case NAND_ECC_HW12_2048:
this->eccsteps = mtd->oobblock / 2048;
break;
case NAND_ECC_HW3_512:
case NAND_ECC_HW6_512:
case NAND_ECC_HW8_512:
this->eccsteps = mtd->oobblock / 512;
break;
case NAND_ECC_HW3_256:
case NAND_ECC_SOFT:
this->eccsteps = mtd->oobblock / 256;
break;

case NAND_ECC_NONE:
this->eccsteps = 1;
break;
this->ecc.steps = mtd->oobblock / this->ecc.size;
if(this->ecc.steps * this->ecc.size != mtd->oobblock) {
printk(KERN_WARNING "Invalid ecc parameters\n");
BUG();
}

/* Initialize state, waitqueue and spinlock */
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mtd/nand/nandsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ static int __init ns_init_module(void)
chip->verify_buf = ns_nand_verify_buf;
chip->write_word = ns_nand_write_word;
chip->read_word = ns_nand_read_word;
chip->eccmode = NAND_ECC_SOFT;
chip->ecc.mode = NAND_ECC_SOFT;
chip->options |= NAND_SKIP_BBTSCAN;

/*
Expand Down
10 changes: 6 additions & 4 deletions trunk/drivers/mtd/nand/ndfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ static void ndfc_chip_init(struct ndfc_nand_mtd *mtd)
chip->read_buf = ndfc_read_buf;
chip->write_buf = ndfc_write_buf;
chip->verify_buf = ndfc_verify_buf;
chip->correct_data = nand_correct_data;
chip->enable_hwecc = ndfc_enable_hwecc;
chip->calculate_ecc = ndfc_calculate_ecc;
chip->eccmode = NAND_ECC_HW3_256;
chip->ecc.correct = nand_correct_data;
chip->ecc.hwctl = ndfc_enable_hwecc;
chip->ecc.calculate = ndfc_calculate_ecc;
chip->ecc.mode = NAND_ECC_HW;
chip->ecc.size = 256;
chip->ecc.bytes = 3;
chip->autooob = mtd->pl_chip->autooob;
mtd->mtd.priv = chip;
mtd->mtd.owner = THIS_MODULE;
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/mtd/nand/ppchameleonevb.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static int __init ppchameleonevb_init(void)
#endif
this->chip_delay = NAND_BIG_DELAY_US;
/* ECC mode */
this->eccmode = NAND_ECC_SOFT;
this->ecc.mode = NAND_ECC_SOFT;

/* Scan to find existence of the device (it could not be mounted) */
if (nand_scan(ppchameleon_mtd, 1)) {
Expand Down Expand Up @@ -358,7 +358,7 @@ static int __init ppchameleonevb_init(void)
this->chip_delay = NAND_SMALL_DELAY_US;

/* ECC mode */
this->eccmode = NAND_ECC_SOFT;
this->ecc.mode = NAND_ECC_SOFT;

/* Scan to find existence of the device */
if (nand_scan(ppchameleonevb_mtd, 1)) {
Expand Down
Loading

0 comments on commit c92867f

Please sign in to comment.