mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software/liblitespi/spiflash: fix clk_freq tuning with L2 cache
Correct CRC was always calculated, regardless of divisor, as the test flash block was in the L2 cache. This resulted in the minimum divisor being used and incorrect flash reads with 200MHz sys_clock.
This commit is contained in:
parent
e0416639f7
commit
3a890a077b
1 changed files with 4 additions and 0 deletions
|
@ -25,6 +25,8 @@ int spiflash_freq_init(void)
|
|||
unsigned int lowest_div, crc, crc_test;
|
||||
|
||||
lowest_div = spiflash_phy_clk_divisor_read();
|
||||
flush_cpu_dcache();
|
||||
flush_l2_cache();
|
||||
crc = crc32((unsigned char *)SPIFLASH_BASE, SPI_FLASH_BLOCK_SIZE);
|
||||
crc_test = crc;
|
||||
|
||||
|
@ -40,6 +42,8 @@ int spiflash_freq_init(void)
|
|||
|
||||
while((crc == crc_test) && (lowest_div-- > 0)) {
|
||||
spiflash_phy_clk_divisor_write((uint32_t)lowest_div);
|
||||
flush_cpu_dcache();
|
||||
flush_l2_cache();
|
||||
crc_test = crc32((unsigned char *)SPIFLASH_BASE, SPI_FLASH_BLOCK_SIZE);
|
||||
#ifdef SPIFLASH_DEBUG
|
||||
printf("[DIV: %d] %08x\n\r", lowest_div, crc_test);
|
||||
|
|
Loading…
Reference in a new issue