mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Power Management: power up/down BT power domain when BT init/deinit
This commit is contained in:
parent
a66b5bbda2
commit
1e7bc626ee
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user