altera_qspi: skip erase if the sector is blank

Skip erase if the sector is blank. The sector erase is slow, and
may take 0.7 sec typically or up to 3 sec worst-case.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
This commit is contained in:
Thomas Chou 2015-12-23 10:33:52 +08:00
parent a1b1d7eceb
commit f81a673ec4
1 changed files with 25 additions and 14 deletions

View File

@ -131,10 +131,20 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr)
size_t end = addr + len;
u32 sect;
u32 stat;
u32 *flash, *last;
instr->state = MTD_ERASING;
addr &= ~(mtd->erasesize - 1); /* get lower aligned address */
while (addr < end) {
flash = pdata->base + addr;
last = pdata->base + addr + mtd->erasesize;
/* skip erase if sector is blank */
while (flash < last) {
if (readl(flash) != 0xffffffff)
break;
flash++;
}
if (flash < last) {
sect = addr / mtd->erasesize;
sect <<= 8;
sect |= QUADSPI_MEM_OP_SECTOR_ERASE;
@ -150,6 +160,7 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr)
mtd_erase_callback(instr);
return -EIO;
}
}
addr += mtd->erasesize;
}
instr->state = MTD_ERASE_DONE;