fix(esp_hw_support): fix MODEM_ADC_COMMON_FE destroyed by modem powerdown lightsleep

This commit is contained in:
wuzhenghui
2025-08-08 11:53:30 +08:00
parent da5b2a4dae
commit 40ba25aecd
5 changed files with 23 additions and 1 deletions
+20
View File
@@ -21,6 +21,7 @@
#include "driver/rtc_io.h"
#include "esp_adc/adc_oneshot.h"
#include "esp_clk_tree.h"
#include "esp_sleep.h"
#include "esp_private/adc_private.h"
#include "esp_private/adc_share_hw_ctrl.h"
#include "esp_private/sar_periph_ctrl.h"
@@ -163,6 +164,16 @@ esp_err_t adc_oneshot_new_unit(const adc_oneshot_unit_init_cfg_t *init_config, a
ESP_LOGD(TAG, "new adc unit%"PRId32" is created", unit->unit_id);
*ret_unit = unit;
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
//TODO: IDF-8475: Depends to SLEEP_RETENTION_MODULE_CLOCK_MODEM retention module after ADC retention supported.
#if SOC_PM_SUPPORT_MODEM_PD
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_MODEM, ESP_PD_OPTION_ON));
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON));
#endif
#elif ADC_LL_ADC_FE_ON_MODEM_DOMAIN
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_MODEM, ESP_PD_OPTION_ON));
#endif
return ESP_OK;
err:
@@ -288,6 +299,15 @@ esp_err_t adc_oneshot_del_unit(adc_oneshot_unit_handle_t handle)
_lock_release(&s_ctx.mutex);
#endif
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
//TODO: IDF-8475: Depends to SLEEP_RETENTION_MODULE_CLOCK_MODEM retention module after ADC retention supported.
#if SOC_PM_SUPPORT_MODEM_PD
esp_sleep_pd_config(ESP_PD_DOMAIN_MODEM, ESP_PD_OPTION_OFF);
esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_OFF);
#endif
#elif ADC_LL_ADC_FE_ON_MODEM_DOMAIN
esp_sleep_pd_config(ESP_PD_DOMAIN_MODEM, ESP_PD_OPTION_OFF);
#endif
return ESP_OK;
}