mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
esp_wifi: store PHY digital registers before disabling PHY and load
them after enabling PHY
This commit is contained in:
committed by
zhangyanjiao
parent
436c3c289e
commit
e5e47ebae6
@@ -21,10 +21,6 @@ extern "C" {
|
|||||||
|
|
||||||
#define ESP_CAL_DATA_CHECK_FAIL 1
|
#define ESP_CAL_DATA_CHECK_FAIL 1
|
||||||
|
|
||||||
#if CONFIG_MAC_BB_PD
|
|
||||||
#define MAC_BB_PD_MEM_SIZE (192*4)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file phy.h
|
* @file phy.h
|
||||||
* @brief Declarations for functions provided by libphy.a
|
* @brief Declarations for functions provided by libphy.a
|
||||||
@@ -80,6 +76,16 @@ void phy_close_rf(void);
|
|||||||
void phy_xpd_tsens(void);
|
void phy_xpd_tsens(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Store and load PHY digital registers.
|
||||||
|
*
|
||||||
|
* @param backup_en if backup_en is true, store PHY digital registers to memory. Otherwise load PHY digital registers from memory
|
||||||
|
* @param mem_addr Memory address to store and load PHY digital registers
|
||||||
|
*
|
||||||
|
* @return memory size
|
||||||
|
*/
|
||||||
|
uint8_t phy_dig_reg_backup(bool backup_en, uint32_t *mem_addr);
|
||||||
|
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
/**
|
/**
|
||||||
* @brief Store and load baseband registers.
|
* @brief Store and load baseband registers.
|
||||||
|
@@ -74,6 +74,9 @@ static int64_t s_phy_rf_en_ts = 0;
|
|||||||
/* PHY spinlock for libphy.a */
|
/* PHY spinlock for libphy.a */
|
||||||
static DRAM_ATTR portMUX_TYPE s_phy_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
static DRAM_ATTR portMUX_TYPE s_phy_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
|
||||||
|
/* Memory to store PHY digital registers */
|
||||||
|
static uint32_t* s_phy_digital_regs_mem = NULL;
|
||||||
|
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
uint32_t* s_mac_bb_pd_mem = NULL;
|
uint32_t* s_mac_bb_pd_mem = NULL;
|
||||||
#endif
|
#endif
|
||||||
@@ -198,6 +201,24 @@ IRAM_ATTR void esp_phy_common_clock_disable(void)
|
|||||||
wifi_bt_common_module_disable();
|
wifi_bt_common_module_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void phy_digital_regs_store(void)
|
||||||
|
{
|
||||||
|
if (s_phy_digital_regs_mem == NULL) {
|
||||||
|
s_phy_digital_regs_mem = (uint32_t *)malloc(SOC_PHY_DIG_REGS_MEM_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_phy_digital_regs_mem != NULL) {
|
||||||
|
phy_dig_reg_backup(true, s_phy_digital_regs_mem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void phy_digital_regs_load(void)
|
||||||
|
{
|
||||||
|
if (s_phy_digital_regs_mem != NULL) {
|
||||||
|
phy_dig_reg_backup(false, s_phy_digital_regs_mem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void esp_phy_enable(void)
|
void esp_phy_enable(void)
|
||||||
{
|
{
|
||||||
_lock_acquire(&s_phy_access_lock);
|
_lock_acquire(&s_phy_access_lock);
|
||||||
@@ -217,6 +238,7 @@ void esp_phy_enable(void)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
phy_wakeup_init();
|
phy_wakeup_init();
|
||||||
|
phy_digital_regs_load();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
@@ -240,6 +262,7 @@ void esp_phy_disable(void)
|
|||||||
|
|
||||||
s_phy_access_ref--;
|
s_phy_access_ref--;
|
||||||
if (s_phy_access_ref == 0) {
|
if (s_phy_access_ref == 0) {
|
||||||
|
phy_digital_regs_store();
|
||||||
// Disable PHY and RF.
|
// Disable PHY and RF.
|
||||||
phy_close_rf();
|
phy_close_rf();
|
||||||
#if CONFIG_IDF_TARGET_ESP32C3
|
#if CONFIG_IDF_TARGET_ESP32C3
|
||||||
@@ -263,7 +286,7 @@ void esp_mac_bb_pd_mem_init(void)
|
|||||||
_lock_acquire(&s_phy_access_lock);
|
_lock_acquire(&s_phy_access_lock);
|
||||||
|
|
||||||
if (s_mac_bb_pd_mem == NULL) {
|
if (s_mac_bb_pd_mem == NULL) {
|
||||||
s_mac_bb_pd_mem = (uint32_t *)heap_caps_malloc(MAC_BB_PD_MEM_SIZE, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
s_mac_bb_pd_mem = (uint32_t *)heap_caps_malloc(SOC_MAC_BB_PD_MEM_SIZE, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
_lock_release(&s_phy_access_lock);
|
_lock_release(&s_phy_access_lock);
|
||||||
|
@@ -271,6 +271,9 @@
|
|||||||
#define SOC_AES_SUPPORT_AES_192 (1)
|
#define SOC_AES_SUPPORT_AES_192 (1)
|
||||||
#define SOC_AES_SUPPORT_AES_256 (1)
|
#define SOC_AES_SUPPORT_AES_256 (1)
|
||||||
|
|
||||||
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
|
|
||||||
/*-------------------------- Power Management CAPS ---------------------------*/
|
/*-------------------------- Power Management CAPS ---------------------------*/
|
||||||
#define SOC_PM_SUPPORT_EXT_WAKEUP (1)
|
#define SOC_PM_SUPPORT_EXT_WAKEUP (1)
|
||||||
|
|
||||||
|
@@ -118,6 +118,10 @@
|
|||||||
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
||||||
#define SOC_COEX_HW_PTI (1)
|
#define SOC_COEX_HW_PTI (1)
|
||||||
|
|
||||||
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
|
#define SOC_MAC_BB_PD_MEM_SIZE (192*4)
|
||||||
|
|
||||||
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
|
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
|
||||||
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)
|
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)
|
||||||
#define SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND (1)
|
#define SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND (1)
|
||||||
|
@@ -299,6 +299,9 @@
|
|||||||
/*-------------------------- WI-FI HARDWARE TSF CAPS -------------------------------*/
|
/*-------------------------- WI-FI HARDWARE TSF CAPS -------------------------------*/
|
||||||
#define SOC_WIFI_HW_TSF (1)
|
#define SOC_WIFI_HW_TSF (1)
|
||||||
|
|
||||||
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
|
|
||||||
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
|
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
|
||||||
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)
|
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)
|
||||||
#define SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND (1)
|
#define SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND (1)
|
||||||
|
@@ -165,6 +165,9 @@
|
|||||||
/*-------------------------- WI-FI HARDWARE TSF CAPS -------------------------------*/
|
/*-------------------------- WI-FI HARDWARE TSF CAPS -------------------------------*/
|
||||||
#define SOC_WIFI_HW_TSF (1)
|
#define SOC_WIFI_HW_TSF (1)
|
||||||
|
|
||||||
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
|
#define SOC_MAC_BB_PD_MEM_SIZE (192*4)
|
||||||
|
|
||||||
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
|
/*-------------------------- SPI MEM CAPS ---------------------------------------*/
|
||||||
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)
|
#define SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE (1)
|
||||||
|
Reference in New Issue
Block a user