mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 11:17:20 +02:00
fix(sdmmc): Fix SDMMC slot switch timing related issue on ESP32-P4
This commit is contained in:
@@ -103,6 +103,7 @@ DRAM_DMA_ALIGNED_ATTR static sdmmc_desc_t s_dma_desc[SDMMC_DMA_DESC_CNT];
|
|||||||
static void sdmmc_isr(void *arg);
|
static void sdmmc_isr(void *arg);
|
||||||
static void sdmmc_host_dma_init(void);
|
static void sdmmc_host_dma_init(void);
|
||||||
static esp_err_t sdmmc_host_pullup_en_internal(int slot, int width);
|
static esp_err_t sdmmc_host_pullup_en_internal(int slot, int width);
|
||||||
|
static bool sdmmc_host_slot_initialized(int slot);
|
||||||
#if SOC_SDMMC_NUM_SLOTS >= 2
|
#if SOC_SDMMC_NUM_SLOTS >= 2
|
||||||
static void sdmmc_host_change_to_slot(int slot);
|
static void sdmmc_host_change_to_slot(int slot);
|
||||||
#endif
|
#endif
|
||||||
@@ -392,8 +393,16 @@ esp_err_t sdmmc_host_start_command(int slot, sdmmc_hw_cmd_t cmd, uint32_t arg)
|
|||||||
SLOT_CHECK(slot);
|
SLOT_CHECK(slot);
|
||||||
|
|
||||||
#if SOC_SDMMC_NUM_SLOTS >= 2
|
#if SOC_SDMMC_NUM_SLOTS >= 2
|
||||||
// change the host settings to the appropriate slot before starting the transaction
|
// Change the host settings to the appropriate slot before starting the transaction
|
||||||
sdmmc_host_change_to_slot(slot);
|
// If the slot is not initialized (slot_host_div not set) or already active, do nothing
|
||||||
|
if (s_host_ctx.active_slot_num != slot) {
|
||||||
|
s_host_ctx.active_slot_num = slot;
|
||||||
|
if (sdmmc_host_slot_initialized(slot)) {
|
||||||
|
sdmmc_host_change_to_slot(slot);
|
||||||
|
} else {
|
||||||
|
ESP_LOGD(TAG, "Slot %d is not initialized yet, skipping sdmmc_host_change_to_slot", slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if this isn't a clock update command, check the card detect status
|
// if this isn't a clock update command, check the card detect status
|
||||||
@@ -830,12 +839,6 @@ static bool sdmmc_host_slot_initialized(int slot)
|
|||||||
#if SOC_SDMMC_NUM_SLOTS >= 2
|
#if SOC_SDMMC_NUM_SLOTS >= 2
|
||||||
static void sdmmc_host_change_to_slot(int slot)
|
static void sdmmc_host_change_to_slot(int slot)
|
||||||
{
|
{
|
||||||
// If the slot is not initialized (slot_host_div not set) or already active, do nothing
|
|
||||||
if (s_host_ctx.active_slot_num == slot || sdmmc_host_slot_initialized(slot) == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
s_host_ctx.active_slot_num = slot;
|
|
||||||
|
|
||||||
// Apply the appropriate saved host settings for the new slot before starting the transaction
|
// Apply the appropriate saved host settings for the new slot before starting the transaction
|
||||||
SDMMC_CLK_SRC_ATOMIC() {
|
SDMMC_CLK_SRC_ATOMIC() {
|
||||||
sdmmc_ll_set_clock_div(s_host_ctx.hal.dev, s_host_ctx.slot_ctx[slot].slot_host_div);
|
sdmmc_ll_set_clock_div(s_host_ctx.hal.dev, s_host_ctx.slot_ctx[slot].slot_host_div);
|
||||||
|
Reference in New Issue
Block a user