diff --git a/components/esp_hal_pmu/include/hal/pmu_types.h b/components/esp_hal_pmu/include/hal/pmu_types.h index 77767dd8f54..8b8ace4e051 100644 --- a/components/esp_hal_pmu/include/hal/pmu_types.h +++ b/components/esp_hal_pmu/include/hal/pmu_types.h @@ -7,6 +7,7 @@ #pragma once #include +#include "soc/soc.h" #include "soc/soc_caps.h" #include "hal/config.h" @@ -24,6 +25,17 @@ typedef enum { PMU_MODE_HP_MAX, } pmu_hp_mode_t; +/** + * @brief PMU ICG modem code of HP system + * + * Each code maps to one bit in modem_lpcon `clk_*_st_map` bitmap fields. + */ +typedef enum { + PMU_HP_ICG_MODEM_CODE_SLEEP = 0, /*!< ICG bitmap bit for HP_SLEEP mode */ + PMU_HP_ICG_MODEM_CODE_MODEM = 1, /*!< ICG bitmap bit for HP_MODEM mode */ + PMU_HP_ICG_MODEM_CODE_ACTIVE = 2, /*!< ICG bitmap bit for HP_ACTIVE mode */ +} pmu_hp_icg_modem_mode_t; + /** * @brief PMU modes of LP system */ diff --git a/components/esp_hal_regi2c/esp32h4/include/hal/regi2c_ctrl_ll.h b/components/esp_hal_regi2c/esp32h4/include/hal/regi2c_ctrl_ll.h index ff476dabb4b..d0941de6d81 100644 --- a/components/esp_hal_regi2c/esp32h4/include/hal/regi2c_ctrl_ll.h +++ b/components/esp_hal_regi2c/esp32h4/include/hal/regi2c_ctrl_ll.h @@ -12,6 +12,10 @@ #include "soc/pmu_reg.h" #include "modem/modem_lpcon_struct.h" #include "modem/modem_syscon_struct.h" +#include "hal/modem_lpcon_ll.h" +#if SOC_PM_SUPPORT_MODEM_CLOCK_DOMAIN_ICG +#include "hal/pmu_types.h" +#endif #ifdef __cplusplus extern "C" { @@ -24,6 +28,10 @@ extern "C" { */ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_enable_clock(bool en) { + /* In ESP32H4, modem_lpcon_reg will lose power after sleep with top pd, so we need to set i2c master and lp_apb clock active and modem st map */ + const uint32_t icg_bitmap = BIT(PMU_HP_ICG_MODEM_CODE_ACTIVE) | BIT(PMU_HP_ICG_MODEM_CODE_MODEM); + modem_lpcon_ll_set_i2c_master_icg_bitmap(&MODEM_LPCON, icg_bitmap); + modem_lpcon_ll_set_lp_apb_icg_bitmap(&MODEM_LPCON, icg_bitmap); MODEM_LPCON.clk_conf.clk_i2c_mst_en = en; } diff --git a/components/esp_hw_support/include/esp_private/esp_pmu.h b/components/esp_hw_support/include/esp_private/esp_pmu.h index 2846bc34390..928f1a4ea90 100644 --- a/components/esp_hw_support/include/esp_private/esp_pmu.h +++ b/components/esp_hw_support/include/esp_private/esp_pmu.h @@ -13,6 +13,7 @@ #include "soc/soc_caps.h" #include "soc/clk_tree_defs.h" +#include "hal/pmu_types.h" #if SOC_PMU_SUPPORTED #include "hal/pmu_hal.h" @@ -24,16 +25,6 @@ extern "C" { #endif -/** - * @brief PMU ICG modem code of HP system - * @note This type is required in rtc_clk_init.c when PMU not fully supported - */ -typedef enum { - PMU_HP_ICG_MODEM_CODE_SLEEP = 0, - PMU_HP_ICG_MODEM_CODE_MODEM = 1, - PMU_HP_ICG_MODEM_CODE_ACTIVE = 2, -} pmu_hp_icg_modem_mode_t; - #if SOC_PMU_SUPPORTED #define RTC_SLEEP_PD_DIG PMU_SLEEP_PD_TOP //!< Deep sleep (power down digital domain, includes all power domains diff --git a/components/esp_hw_support/include/esp_private/sleep_clock.h b/components/esp_hw_support/include/esp_private/sleep_clock.h index 60b5a715027..cdaf844a1eb 100644 --- a/components/esp_hw_support/include/esp_private/sleep_clock.h +++ b/components/esp_hw_support/include/esp_private/sleep_clock.h @@ -51,7 +51,7 @@ bool clock_domain_pd_allowed(void); */ esp_err_t sleep_clock_system_retention_init(void *arg); -#if CONFIG_MAC_BB_PD || CONFIG_BT_LE_SLEEP_ENABLE || CONFIG_BT_CTRL_SLEEP_ENABLE || CONFIG_IEEE802154_SLEEP_ENABLE || SOC_PM_MODEM_CLK_CONF_RETENTION +#if CONFIG_MAC_BB_PD || CONFIG_BT_LE_SLEEP_ENABLE || CONFIG_BT_CTRL_SLEEP_ENABLE || CONFIG_IEEE802154_SLEEP_ENABLE /** * @brief Modem system clock retention initialize. *