mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
Power Management: power up/down BT power domain when BT init/deinit
This commit is contained in:
@@ -488,6 +488,18 @@ static void btdm_slp_tmr_callback(void *arg);
|
|||||||
#endif /* #ifdef CONFIG_PM_ENABLE */
|
#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)
|
static inline void btdm_check_and_init_bb(void)
|
||||||
{
|
{
|
||||||
/* init BT-BB if PHY/RF has been switched off since last BT-BB init */
|
/* init BT-BB if PHY/RF has been switched off since last BT-BB init */
|
||||||
@@ -1621,6 +1633,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_bt_power_domain_on();
|
||||||
|
|
||||||
btdm_controller_mem_init();
|
btdm_controller_mem_init();
|
||||||
|
|
||||||
periph_module_enable(PERIPH_BT_MODULE);
|
periph_module_enable(PERIPH_BT_MODULE);
|
||||||
@@ -1774,6 +1788,8 @@ esp_err_t esp_bt_controller_deinit(void)
|
|||||||
btdm_lpcycle_us = 0;
|
btdm_lpcycle_us = 0;
|
||||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||||
|
|
||||||
|
esp_bt_power_domain_off();
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -408,7 +408,7 @@ static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
|
|||||||
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_MAC_BB_PD
|
#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_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
|||||||
void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_MAC_BB_PD
|
#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_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||||
|
|
||||||
@@ -427,6 +427,22 @@ void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
|||||||
#endif
|
#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)
|
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
|
#if CONFIG_MAC_BB_PD
|
||||||
@@ -956,6 +972,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
// overwrite some parameters
|
// overwrite some parameters
|
||||||
cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL;
|
cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL;
|
||||||
|
|
||||||
|
esp_bt_power_domain_on();
|
||||||
|
|
||||||
btdm_controller_mem_init();
|
btdm_controller_mem_init();
|
||||||
|
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
@@ -1223,6 +1241,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_pd_callback(btdm_mac_bb_power_down_cb);
|
||||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
esp_bt_power_domain_off();
|
||||||
|
|
||||||
free(osi_funcs_p);
|
free(osi_funcs_p);
|
||||||
osi_funcs_p = NULL;
|
osi_funcs_p = NULL;
|
||||||
|
|
||||||
|
@@ -407,10 +407,6 @@ static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
|
|||||||
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
// le 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_mac_bb_power_down();
|
esp_mac_bb_power_down();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -418,10 +414,6 @@ void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
|||||||
void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
// le 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_mac_bb_power_up();
|
esp_mac_bb_power_up();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -433,6 +425,18 @@ void IRAM_ATTR btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uin
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 void interrupt_set_wrapper(int32_t cpu_no, int32_t intr_source, int32_t intr_num, int32_t intr_prio)
|
static void interrupt_set_wrapper(int32_t cpu_no, int32_t intr_source, int32_t intr_num, int32_t intr_prio)
|
||||||
{
|
{
|
||||||
intr_matrix_set(cpu_no, intr_source, intr_num);
|
intr_matrix_set(cpu_no, intr_source, intr_num);
|
||||||
@@ -936,6 +940,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
// overwrite some parameters
|
// overwrite some parameters
|
||||||
cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL;
|
cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL;
|
||||||
|
|
||||||
|
esp_bt_power_domain_on();
|
||||||
|
|
||||||
btdm_controller_mem_init();
|
btdm_controller_mem_init();
|
||||||
|
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
@@ -1143,6 +1149,8 @@ error:
|
|||||||
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
esp_bt_power_domain_off();
|
||||||
|
|
||||||
if (osi_funcs_p != NULL) {
|
if (osi_funcs_p != NULL) {
|
||||||
free(osi_funcs_p);
|
free(osi_funcs_p);
|
||||||
osi_funcs_p = NULL;
|
osi_funcs_p = NULL;
|
||||||
|
@@ -530,6 +530,16 @@ esp_err_t esp_bt_sleep_disable(void);
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_ble_scan_dupilcate_list_flush(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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -527,6 +527,16 @@ void esp_bt_controller_wakeup_request(void);
|
|||||||
*/
|
*/
|
||||||
int esp_bt_h4tl_eif_io_event_notify(int event);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -526,6 +526,16 @@ void esp_bt_controller_wakeup_request(void);
|
|||||||
*/
|
*/
|
||||||
int esp_bt_h4tl_eif_io_event_notify(int event);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user