feat(esp_hw_support): support entry 2 xtalx2 power pu in esp32h4

This commit is contained in:
hebinglin
2026-05-21 19:55:37 +08:00
parent 2c91b280f4
commit 5710783a89
8 changed files with 101 additions and 1 deletions
@@ -40,6 +40,12 @@ if((CONFIG_SOC_PM_SUPPORT_MODEM_PD OR CONFIG_SOC_PM_SUPPORT_TOP_PD) AND CONFIG_S
list(APPEND srcs "port/${target}/sleep_clock.c")
endif()
if(CONFIG_SOC_PM_SUPPORT_PMU_MODEM_STATE AND CONFIG_BT_CTRL_SLEEP_ENABLE AND CONFIG_SOC_PM_XTALX2_PD_IN_MODEM_STATES)
list(APPEND srcs "port/${target}/sleep_power.c")
set_property(TARGET ${COMPONENT_LIB}
APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-u sleep_power_system_retention_init")
endif()
if(CONFIG_SOC_PM_SUPPORT_PMU_MODEM_STATE)
list(APPEND srcs "port/${target}/sleep_modem_state.c")
endif()
@@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_private/sleep_power.h"
#include "soc/pmu_reg.h"
ESP_LOG_ATTR_TAG(TAG, "sleep_power");
#if CONFIG_BT_CTRL_SLEEP_ENABLE
esp_err_t sleep_power_system_retention_init(void *arg)
{
const static sleep_retention_entries_config_t power_regs_retention[] = {
/* During the modem-to-active transition, the MODEM lock keeps the xtalx2 xpd status unchanged.
* Therefore, if xtalx2 is disabled in modem state, we need to set xtalx2 tie-high to enable it in active state. */
[0] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_POWER_LINK(0), PMU_IMM_HP_CK_POWER_REG, PMU_TIE_HIGH_XTALX2 | PMU_TIE_HIGH_GLOBAL_XTALX2_ICG, PMU_TIE_HIGH_XTALX2_M | PMU_TIE_HIGH_GLOBAL_XTALX2_ICG_M, 1, 0), .owner = ENTRY(2) },
};
esp_err_t err = sleep_retention_entries_create(power_regs_retention, ARRAY_SIZE(power_regs_retention), REGDMA_LINK_PRI_POWER, SLEEP_RETENTION_MODULE_POWER);
ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for system power retention");
ESP_LOGI(TAG, "System power sleep retention initialization");
return ESP_OK;
}
ESP_SYSTEM_INIT_FN(sleep_power_startup_init, SECONDARY, BIT(0), 108)
{
sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_power_system_retention_init, .arg = NULL } },
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE
};
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_POWER, &init_param);
if (err != ESP_OK) {
ESP_LOGW(TAG, "failed to init power retention module, err=%d", err);
}
return ESP_OK;
}
#endif