fix(sdmmc): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled

This commit is contained in:
Chen Jichang
2025-05-16 18:27:28 +08:00
parent 4bfd180a94
commit a21f7c78f9
2 changed files with 6 additions and 0 deletions

View File

@ -373,9 +373,11 @@ static esp_err_t sd_host_del_sdmmc_controller(sd_host_ctlr_handle_t ctlr)
if (ctlr_ctx->io_intr_sem) { if (ctlr_ctx->io_intr_sem) {
vSemaphoreDeleteWithCaps(ctlr_ctx->io_intr_sem); vSemaphoreDeleteWithCaps(ctlr_ctx->io_intr_sem);
} }
#if CONFIG_PM_ENABLE
if (ctlr_ctx->pm_lock) { if (ctlr_ctx->pm_lock) {
esp_pm_lock_delete(ctlr_ctx->pm_lock); esp_pm_lock_delete(ctlr_ctx->pm_lock);
} }
#endif
free(ctlr_ctx->dma_desc); free(ctlr_ctx->dma_desc);
ctlr_ctx->dma_desc = NULL; ctlr_ctx->dma_desc = NULL;

View File

@ -482,9 +482,11 @@ esp_err_t sd_host_slot_sdmmc_do_transaction(sd_host_slot_handle_t slot, sdmmc_co
sd_host_sdmmc_slot_t *slot_ctx = __containerof(slot, sd_host_sdmmc_slot_t, drv); sd_host_sdmmc_slot_t *slot_ctx = __containerof(slot, sd_host_sdmmc_slot_t, drv);
xSemaphoreTake(slot_ctx->ctlr->mutex, portMAX_DELAY); xSemaphoreTake(slot_ctx->ctlr->mutex, portMAX_DELAY);
#if CONFIG_PM_ENABLE
if (slot_ctx->ctlr->pm_lock) { if (slot_ctx->ctlr->pm_lock) {
ESP_GOTO_ON_ERROR(esp_pm_lock_acquire(slot_ctx->ctlr->pm_lock), out, TAG, "acquire pm_lock failed"); ESP_GOTO_ON_ERROR(esp_pm_lock_acquire(slot_ctx->ctlr->pm_lock), out, TAG, "acquire pm_lock failed");
} }
#endif
slot_ctx->ctlr->cur_slot_id = slot_ctx->slot_id; slot_ctx->ctlr->cur_slot_id = slot_ctx->slot_id;
// By default, set probing frequency (400kHz) and 1-bit bus // By default, set probing frequency (400kHz) and 1-bit bus
@ -579,9 +581,11 @@ esp_err_t sd_host_slot_sdmmc_do_transaction(sd_host_slot_handle_t slot, sdmmc_co
#endif #endif
out: out:
#if CONFIG_PM_ENABLE
if (slot_ctx->ctlr->pm_lock) { if (slot_ctx->ctlr->pm_lock) {
ESP_RETURN_ON_ERROR(esp_pm_lock_release(slot_ctx->ctlr->pm_lock), TAG, "release pm_lock failed"); ESP_RETURN_ON_ERROR(esp_pm_lock_release(slot_ctx->ctlr->pm_lock), TAG, "release pm_lock failed");
} }
#endif
xSemaphoreGive(slot_ctx->ctlr->mutex); xSemaphoreGive(slot_ctx->ctlr->mutex);
return ret; return ret;