Merge branch 'bugfix/spi_flash_compatible_with_rom_c3_and_s3_v4.3' into 'release/v4.3'

spi_flash: make spiflash compatible with ESP32C3 and ESP32S3 ROM (backport v4.3)

See merge request espressif/esp-idf!12784
This commit is contained in:
Jiang Jiang Jian 2021-03-22 12:47:05 +00:00
commit 651a939643
4 changed files with 22 additions and 1 deletions

View File

@ -189,6 +189,11 @@ struct spi_flash_host_driver_s {
*/
esp_err_t (*flush_cache)(spi_flash_host_inst_t* host, uint32_t addr, uint32_t size);
/**
* Suspend check erase/program operation, reserved for ESP32-C3 and ESP32-S3 spi flash ROM IMPL.
*/
void (*check_suspend)(spi_flash_host_inst_t *host);
/**
* Resume flash from suspend manually
*/

View File

@ -20,10 +20,11 @@ void spi_flash_hal_disable_auto_resume_mode(spi_flash_host_inst_t *host);
void spi_flash_hal_disable_auto_suspend_mode(spi_flash_host_inst_t *host);
void spi_flash_hal_setup_auto_resume_mode(spi_flash_host_inst_t *host);
#endif //SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND
#include "spi_flash_hal_common.inc"
#ifndef CONFIG_SPI_FLASH_ROM_IMPL
#include "spi_flash_hal_common.inc"
// HAL for
// - MEMSPI
// - SPI1~3 on ESP32/S2/S3/C3
@ -93,6 +94,19 @@ esp_err_t spi_flash_hal_set_write_protect(spi_flash_host_inst_t *host, bool wp)
return ESP_OK;
}
#else // defined CONFIG_SPI_FLASH_ROM_IMPL
static inline spi_dev_t *get_spi_dev(spi_flash_host_inst_t *host)
{
return ((spi_flash_hal_context_t*)host)->spi;
}
static inline int get_host_id(spi_flash_host_inst_t* host)
{
spi_dev_t *dev = get_spi_dev(host);
return spi_flash_ll_hw_get_id(dev);
}
#endif // !CONFIG_SPI_FLASH_ROM_IMPL
uint32_t spi_flash_hal_check_status(spi_flash_host_inst_t *host)

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 = NULL, \
.resume = spi_flash_hal_resume, \
.suspend = spi_flash_hal_suspend,\
.sus_setup = spi_flash_hal_setup_read_suspend,\

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 = NULL,
.resume = spi_flash_hal_resume,
.suspend = spi_flash_hal_suspend,
};