mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 04:34:31 +02:00
deinit BB MAC back memory when they are not used
This commit is contained in:
@@ -1243,6 +1243,9 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
phy_init_flag();
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_mac_bb_pd_mem_deinit();
|
||||
#endif
|
||||
|
||||
free(osi_funcs_p);
|
||||
osi_funcs_p = NULL;
|
||||
|
@@ -176,6 +176,11 @@ void esp_phy_load_cal_and_init(void);
|
||||
*/
|
||||
void esp_mac_bb_pd_mem_init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize backup memory for MAC and Baseband power up/down
|
||||
*/
|
||||
void esp_mac_bb_pd_mem_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Power up MAC and Baseband
|
||||
*/
|
||||
|
@@ -73,6 +73,8 @@ static uint32_t* s_phy_digital_regs_mem = NULL;
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
uint32_t* s_mac_bb_pd_mem = NULL;
|
||||
/* Reference count of MAC BB backup memory */
|
||||
static uint8_t s_backup_mem_ref = 0;
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
|
||||
@@ -307,6 +309,7 @@ void esp_mac_bb_pd_mem_init(void)
|
||||
{
|
||||
_lock_acquire(&s_phy_access_lock);
|
||||
|
||||
s_backup_mem_ref++;
|
||||
if (s_mac_bb_pd_mem == NULL) {
|
||||
s_mac_bb_pd_mem = (uint32_t *)heap_caps_malloc(SOC_MAC_BB_PD_MEM_SIZE, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||
}
|
||||
@@ -314,6 +317,19 @@ void esp_mac_bb_pd_mem_init(void)
|
||||
_lock_release(&s_phy_access_lock);
|
||||
}
|
||||
|
||||
void esp_mac_bb_pd_mem_deinit(void)
|
||||
{
|
||||
_lock_acquire(&s_phy_access_lock);
|
||||
|
||||
s_backup_mem_ref--;
|
||||
if (s_backup_mem_ref == 0) {
|
||||
free(s_mac_bb_pd_mem);
|
||||
s_mac_bb_pd_mem = NULL;
|
||||
}
|
||||
|
||||
_lock_release(&s_phy_access_lock);
|
||||
}
|
||||
|
||||
IRAM_ATTR void esp_mac_bb_power_up(void)
|
||||
{
|
||||
if (s_mac_bb_pd_mem == NULL) {
|
||||
|
@@ -133,6 +133,9 @@ esp_err_t esp_wifi_deinit(void)
|
||||
phy_init_flag();
|
||||
#endif
|
||||
esp_wifi_power_domain_off();
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_mac_bb_pd_mem_deinit();
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user