rockchip: drivers: mtd: nand: modify the bad block detection process
Change-Id: I97c99e91516f34a270684cbb77820b4078f1cf03 Signed-off-by: Yifeng Zhao <zyf@rock-chips.com>
This commit is contained in:
parent
0bc1964007
commit
d6d708d1a3
|
|
@ -539,7 +539,7 @@ static int rockchip_nand_ecc_init(struct mtd_info *mtd,
|
||||||
|
|
||||||
static int rockchip_nand_block_bad(struct mtd_info *mtd, loff_t ofs)
|
static int rockchip_nand_block_bad(struct mtd_info *mtd, loff_t ofs)
|
||||||
{
|
{
|
||||||
int page, res = 0, i;
|
int page, res = 0;
|
||||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||||
u16 bad = 0xff;
|
u16 bad = 0xff;
|
||||||
int chipnr = (int)(ofs >> chip->chip_shift);
|
int chipnr = (int)(ofs >> chip->chip_shift);
|
||||||
|
|
@ -549,13 +549,23 @@ static int rockchip_nand_block_bad(struct mtd_info *mtd, loff_t ofs)
|
||||||
chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
|
chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
|
||||||
if(rockchip_nand_hw_syndrome_pio_read_page(mtd,
|
if(rockchip_nand_hw_syndrome_pio_read_page(mtd,
|
||||||
chip, chip->buffers->databuf, 0, page) == -1) {
|
chip, chip->buffers->databuf, 0, page) == -1) {
|
||||||
|
/* first page of the block*/
|
||||||
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page);
|
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page);
|
||||||
for (i = 0; i < 8; i++) {
|
bad = chip->read_byte(mtd);
|
||||||
bad = chip->read_byte(mtd);
|
if (bad != 0xFF)
|
||||||
if (bad)
|
res = 1;
|
||||||
break;
|
/* second page of the block*/
|
||||||
}
|
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos,
|
||||||
if (i >= 8)
|
page + 1);
|
||||||
|
bad = chip->read_byte(mtd);
|
||||||
|
if (bad != 0xFF)
|
||||||
|
res = 1;
|
||||||
|
/* last page of the block */
|
||||||
|
page += ((mtd->erasesize - mtd->writesize) >> chip->chip_shift);
|
||||||
|
page--;
|
||||||
|
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page);
|
||||||
|
bad = chip->read_byte(mtd);
|
||||||
|
if (bad != 0xFF)
|
||||||
res = 1;
|
res = 1;
|
||||||
}
|
}
|
||||||
chip->select_chip(mtd, -1);
|
chip->select_chip(mtd, -1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue