spi_flash: Add auto-suspend mode for ESP32-S2

Uses HW auto_wait_idle, HW auto_suspend and SW resume
This commit is contained in:
KonstantinKondrashov 2020-05-10 17:32:07 +08:00 committed by Cao Sen Miao
parent afef16c2e9
commit 60e58eaddb
5 changed files with 21 additions and 0 deletions

View File

@ -173,6 +173,9 @@ bool esp_flash_chip_driver_initialized(const esp_flash_t *chip)
return true;
}
#ifdef CONFIG_SPI_FLASH_AUTO_SUSPEND
spi_flash_ll_auto_suspend_init(spi_flash_ll_get_hw(SPI_HOST), val);
#endif
esp_err_t IRAM_ATTR esp_flash_init(esp_flash_t *chip)
{
// Chip init flow

View File

@ -255,6 +255,10 @@ esp_err_t esp_flash_init_default_chip(void)
return err;
}
#ifdef CONFIG_SPI_FLASH_AUTO_SUSPEND
spi_flash_hal_setup_auto_suspend_mode(default_chip.host);
#endif
// ROM TODO: account for non-standard default pins in efuse
// ROM TODO: to account for chips which are slow to power on, maybe keep probing in a loop here
err = esp_flash_init(&default_chip);

View File

@ -35,6 +35,7 @@
.configure_host_io_mode = spi_flash_hal_configure_host_io_mode, \
.poll_cmd_done = spi_flash_hal_poll_cmd_done, \
.flush_cache = memspi_host_flush_cache, \
.check_suspend = memspi_host_cb_check_suspend, \
}
/// configuration for the memspi host
@ -176,3 +177,11 @@ int memspi_host_read_data_slicer(spi_flash_host_inst_t *host, uint32_t address,
* @return Length that can actually be written in one `program_page` call in `spi_flash_host_driver_t`.
*/
int memspi_host_write_data_slicer(spi_flash_host_inst_t *host, uint32_t address, uint32_t len, uint32_t *align_address, uint32_t page_size);
/**
* @brief Check the suspend status and resume a suspended operation.
*
* @param host The driver context.
*
*/
void memspi_host_cb_check_suspend(spi_flash_host_inst_t *host);

View File

@ -61,6 +61,7 @@ static const spi_flash_host_driver_t esp_flash_gpspi_host = {
.configure_host_io_mode = spi_flash_hal_gpspi_configure_host_io_mode,
.poll_cmd_done = spi_flash_hal_gpspi_poll_cmd_done,
.flush_cache = NULL,
.check_suspend = memspi_host_cb_check_suspend,
};
#endif

View File

@ -67,12 +67,16 @@ static inline IRAM_ATTR bool on_spi1_check_yield(spi1_app_func_arg_t* ctx);
IRAM_ATTR static void cache_enable(void* arg)
{
#ifndef CONFIG_SPI_FLASH_AUTO_SUSPEND
g_flash_guard_default_ops.end();
#endif
}
IRAM_ATTR static void cache_disable(void* arg)
{
#ifndef CONFIG_SPI_FLASH_AUTO_SUSPEND
g_flash_guard_default_ops.start();
#endif
}
static IRAM_ATTR esp_err_t spi_start(void *arg)