diff --git a/components/esp_hw_support/modem_clock.c b/components/esp_hw_support/modem_clock.c index 443b7c78bb..715a8ac211 100644 --- a/components/esp_hw_support/modem_clock.c +++ b/components/esp_hw_support/modem_clock.c @@ -16,6 +16,7 @@ #include "esp_private/esp_modem_clock.h" #include "esp_private/esp_pmu.h" #include "esp_sleep.h" +#include "hal/efuse_hal.h" // Please define the frequently called modules in the low bit, // which will improve the execution efficiency @@ -334,9 +335,15 @@ void modem_clock_select_lp_clock_source(periph_module_t module, modem_clock_lpcl modem_clock_hal_select_ble_rtc_timer_lpclk_source(MODEM_CLOCK_instance()->hal, src); modem_clock_hal_set_ble_rtc_timer_divisor_value(MODEM_CLOCK_instance()->hal, divider); modem_clock_hal_enable_ble_rtc_timer_clock(MODEM_CLOCK_instance()->hal, true); - if (src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { - pmu_sleep_enable_hp_sleep_sysclk(true); +#if SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND + if (efuse_hal_chip_revision() != 0) { + if (src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { + pmu_sleep_enable_hp_sleep_sysclk(true); + } + modem_clock_hal_enable_wifipwr_clock(MODEM_CLOCK_instance()->hal, true); + modem_clock_domain_clk_gate_disable(MODEM_CLOCK_DOMAIN_WIFIPWR, PMU_HP_ICG_MODEM_CODE_SLEEP); } +#endif break; #endif // SOC_BT_SUPPORTED @@ -390,9 +397,15 @@ void modem_clock_deselect_lp_clock_source(periph_module_t module) case PERIPH_BT_MODULE: modem_clock_hal_deselect_all_ble_rtc_timer_lpclk_source(MODEM_CLOCK_instance()->hal); modem_clock_hal_enable_ble_rtc_timer_clock(MODEM_CLOCK_instance()->hal, false); - if (last_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { - pmu_sleep_enable_hp_sleep_sysclk(false); +#if SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND + if (efuse_hal_chip_revision() != 0) { + if (last_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { + pmu_sleep_enable_hp_sleep_sysclk(false); + } + modem_clock_hal_enable_wifipwr_clock(MODEM_CLOCK_instance()->hal, false); + modem_clock_domain_clk_gate_enable(MODEM_CLOCK_DOMAIN_WIFI, PMU_HP_ICG_MODEM_CODE_SLEEP); } +#endif break; #endif // SOC_BT_SUPPORTED case PERIPH_COEX_MODULE: diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index bbf30c4705..b1ace25e8c 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -1270,3 +1270,7 @@ config SOC_BLE_POWER_CONTROL_SUPPORTED config SOC_BLUFI_SUPPORTED bool default y + +config SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND + bool + default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 676709dae2..e5208eeaf0 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -520,3 +520,5 @@ #define SOC_BLE_DEVICE_PRIVACY_SUPPORTED (1) /*!< Support BLE device privacy mode */ #define SOC_BLE_POWER_CONTROL_SUPPORTED (1) /*!< Support Bluetooth Power Control */ #define SOC_BLUFI_SUPPORTED (1) /*!< Support BLUFI */ + +#define SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND (1)