diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 2356a09e43..4a63e23fd9 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -449,6 +449,18 @@ static void btdm_slp_tmr_callback(void *arg); #endif /* #ifdef CONFIG_PM_ENABLE */ +static inline void esp_bt_power_domain_on(void) +{ + // Bluetooth module power up + esp_wifi_bt_power_domain_on(); +} + +static inline void esp_bt_power_domain_off(void) +{ + // Bluetooth module power down + esp_wifi_bt_power_domain_off(); +} + static inline void btdm_check_and_init_bb(void) { /* init BT-BB if PHY/RF has been switched off since last BT-BB init */ @@ -1393,6 +1405,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) goto error; } + esp_bt_power_domain_on(); + btdm_controller_mem_init(); periph_module_enable(PERIPH_BT_MODULE); @@ -1554,6 +1568,8 @@ esp_err_t esp_bt_controller_deinit(void) btdm_lpcycle_us = 0; btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE); + esp_bt_power_domain_off(); + return ESP_OK; } diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 04c35768e4..fd99974073 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -409,7 +409,7 @@ static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock; void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void) { #if CONFIG_MAC_BB_PD - // le module power down + // Bluetooth module power down SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO); SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD); @@ -420,7 +420,7 @@ void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void) void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void) { #if CONFIG_MAC_BB_PD - // le module power up + // Bluetooth module power up CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD); CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO); @@ -428,6 +428,22 @@ void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void) #endif } +static inline void esp_bt_power_domain_on(void) +{ + // Bluetooth module power up + CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD); + CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO); + esp_wifi_bt_power_domain_on(); +} + +static inline void esp_bt_power_domain_off(void) +{ + // Bluetooth module power down + SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO); + SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD); + esp_wifi_bt_power_domain_off(); +} + void IRAM_ATTR btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem) { #if CONFIG_MAC_BB_PD @@ -953,6 +969,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) // overwrite some parameters cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL; + esp_bt_power_domain_on(); + sdk_config_extend_set_pll_track(false); #if CONFIG_MAC_BB_PD @@ -1231,6 +1249,9 @@ esp_err_t esp_bt_controller_deinit(void) esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); #endif + + esp_bt_power_domain_off(); + free(osi_funcs_p); osi_funcs_p = NULL; diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index 51b23aa8fd..5679a02543 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -494,6 +494,16 @@ esp_err_t esp_bt_sleep_disable(void); */ esp_err_t esp_ble_scan_dupilcate_list_flush(void); +/** + * @brief bt Wi-Fi power domain power on + */ +void esp_wifi_bt_power_domain_on(void); + +/** + * @brief bt Wi-Fi power domain power off + */ +void esp_wifi_bt_power_domain_off(void); + #ifdef __cplusplus } #endif diff --git a/components/bt/include/esp32c3/include/esp_bt.h b/components/bt/include/esp32c3/include/esp_bt.h index a1f2551e2c..d62b7a4a94 100644 --- a/components/bt/include/esp32c3/include/esp_bt.h +++ b/components/bt/include/esp32c3/include/esp_bt.h @@ -523,6 +523,16 @@ void esp_bt_controller_wakeup_request(void); */ int esp_bt_h4tl_eif_io_event_notify(int event); +/** + * @brief bt Wi-Fi power domain power on + */ +void esp_wifi_bt_power_domain_on(void); + +/** + * @brief bt Wi-Fi power domain power off + */ +void esp_wifi_bt_power_domain_off(void); + #ifdef __cplusplus } #endif