Outp32(rERASE_ADDRESS, targetAddr);
Outp8(rSE, QSPI_DUMMY_DATA);
+
+ arch_invalidate_dcache(targetAddr + CONFIG_S5J_FLASH_BASE, (targetAddr + CONFIG_S5J_FLASH_BASE + QSPI_SIZE_4KB));
}
void QSPI_Block_Erase(u32 targetAddr, eQSPI_BLOCK_SIZE unit)
{
+ u32 blockEraseSize = 0;
+
if (unit == BLOCK_64KB) {
SetBits(rCOMMAND2, 16, 0xFF, COMMAND_ERASE_64KB);
+ blockEraseSize = QSPI_SIZE_64KB;
} else {
SetBits(rCOMMAND2, 16, 0xFF, COMMAND_ERASE_32KB);
+ blockEraseSize = QSPI_SIZE_32KB;
}
Outp32(rERASE_ADDRESS, targetAddr);
Outp8(rBE, QSPI_DUMMY_DATA);
+
+ arch_invalidate_dcache(targetAddr + CONFIG_S5J_FLASH_BASE, (targetAddr + CONFIG_S5J_FLASH_BASE + blockEraseSize));
}
void QSPI_Chip_Erase(void)
{
int ret;
uint32_t val;
+ int size = 0;
#ifdef S5J_SFLASH_USE_DIRECT_RW
/* debug code */
case SFLASH_SECTOR_ERASE:
Outp32(rERASE_ADDRESS, addr);
Outp8(rSE, QSPI_DUMMY_DATA);
+ size = 4096; /* Sub-sector size */
break;
case SFLASH_BLOCK_ERASE_LARGE:
+ size = 65536; /* block size */
SetBits(rCOMMAND2, 16, 0xFF, COMMAND_ERASE_64KB);
/* SetBits(rCOMMAND2, 16, 0xFF, COMMAND_ERASE_32KB); */
break;
}
- while (getreg32(rRDSR) & 0x1) {
- usleep(10);
+ while (getreg8(rRDSR) & 0x1) ;
+
+ if (cmd != SFLASH_CHIP_ERASE1) {
+ arch_invalidate_dcache(addr + S5J_SFLASH_MAPPED_ADDR, (addr + S5J_SFLASH_MAPPED_ADDR + size));
}
return OK;
addr += readsize;
i += readsize;
size -= readsize;
+
+ /* check write in progress */
+ while (getreg8(rRDSR) & 0x1) ;
}
return OK;