mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-23 09:20:30 +00:00
auto beacon: support esp32c6 autobeacon (advanced DTIM sleep feature)
modem retention: Support esp32c6 wifi MAC and baseband sleep retention sleep_modem: wifi MAC modem wakeup protect in modem state before PMU trigger sleep enable request sleep modem: provide a interface to get whether the Modem power domain is allowed to power off during sleep add i2c_ana master header file to project auto beacon: release PMU's lock on root clock source (it is locked in the PLL) wifi receiving beacon frame in PMU modem state strongly depends on the BBPLL clock, PMU will forcibly lock the root clock source as PLL, when the root clock source of the software system is selected as PLL, we need to release the root clock source locking. When it is judged that the PLL is locked by PMU after wakeing up from the PMU modem state, switch the root clock source to the PLL in the sleep process (a critical section). auto beacon: fix the failure to receive broadcast/multicast frames in modem state When the multicast field in the beacon frame received in the PMU modem state is True, the PMU switches to the PMU active state (the PMU waits for the HP LDO to stabilize and then restores the MAC context) and starts to receive broadcast/multicast frames (Broadcast/Multicast frames will be sent after a minimum delay of 48 us after the beacon frame), because the PMU waits for the HP LDO to stabilize too long (~154 us), which will cause broadcast/multicast frame reception to be missed. auto beacon: select the PLL clock source as the REGDMA backup clock source when the PMU switches to ACTIVE from MODEM state update Digital Peripheral (M2A switch) REGDMA restore time parameter auto beacon: fix the issue that only channel 1 can connect to AP in modem state
This commit is contained in:
@@ -38,9 +38,16 @@
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||
#include "esp_private/sleep_modem.h"
|
||||
#include "esp_private/esp_pau.h"
|
||||
#endif
|
||||
#include "hal/efuse_hal.h"
|
||||
|
||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
||||
#include "esp_private/sleep_retention.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
extern wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb;
|
||||
#endif
|
||||
@@ -56,19 +63,9 @@ static DRAM_ATTR struct {
|
||||
} s_wifi_bt_pd_controller = { .count = 0 };
|
||||
#endif
|
||||
|
||||
/* Indicate PHY is calibrated or not */
|
||||
static bool s_is_phy_calibrated = false;
|
||||
|
||||
static bool s_is_phy_reg_stored = false;
|
||||
|
||||
/* Reference count of enabling PHY */
|
||||
static uint8_t s_phy_access_ref = 0;
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
/* Reference of powering down MAC and BB */
|
||||
static bool s_mac_bb_pu = true;
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
/* time stamp updated when the PHY/RF is turned on */
|
||||
static int64_t s_phy_rf_en_ts = 0;
|
||||
@@ -77,15 +74,17 @@ static int64_t s_phy_rf_en_ts = 0;
|
||||
/* PHY spinlock for libphy.a */
|
||||
static DRAM_ATTR portMUX_TYPE s_phy_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
/* Indicate PHY is calibrated or not */
|
||||
static bool s_is_phy_calibrated = false;
|
||||
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
/* Indicate PHY regs is stored or not */
|
||||
static bool s_is_phy_reg_stored = false;
|
||||
/* Memory to store PHY digital registers */
|
||||
static uint32_t* s_phy_digital_regs_mem = NULL;
|
||||
static uint8_t s_phy_modem_init_ref = 0;
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
uint32_t* s_mac_bb_pd_mem = NULL;
|
||||
/* Reference count of MAC BB backup memory */
|
||||
static uint8_t s_macbb_backup_mem_ref = 0;
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
|
||||
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED
|
||||
@@ -212,6 +211,7 @@ IRAM_ATTR void esp_phy_common_clock_disable(void)
|
||||
wifi_bt_common_module_disable();
|
||||
}
|
||||
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
static inline void phy_digital_regs_store(void)
|
||||
{
|
||||
if (s_phy_digital_regs_mem != NULL) {
|
||||
@@ -226,6 +226,7 @@ static inline void phy_digital_regs_load(void)
|
||||
phy_dig_reg_backup(false, s_phy_digital_regs_mem);
|
||||
}
|
||||
}
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
|
||||
void esp_phy_enable(void)
|
||||
{
|
||||
@@ -245,8 +246,22 @@ void esp_phy_enable(void)
|
||||
s_is_phy_calibrated = true;
|
||||
}
|
||||
else {
|
||||
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
|
||||
extern bool pm_mac_modem_rf_already_enabled(void);
|
||||
if (!pm_mac_modem_rf_already_enabled()) {
|
||||
if (sleep_modem_wifi_modem_state_enabled()) {
|
||||
pau_regdma_trigger_modem_link_restore();
|
||||
} else {
|
||||
phy_wakeup_init();
|
||||
}
|
||||
}
|
||||
#else
|
||||
phy_wakeup_init();
|
||||
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP */
|
||||
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
phy_digital_regs_load();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@@ -264,13 +279,22 @@ void esp_phy_disable(void)
|
||||
|
||||
s_phy_access_ref--;
|
||||
if (s_phy_access_ref == 0) {
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
phy_digital_regs_store();
|
||||
// Disable PHY and RF.
|
||||
phy_close_rf();
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
// Disable PHY temperature sensor
|
||||
phy_xpd_tsens();
|
||||
#endif
|
||||
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
|
||||
if (sleep_modem_wifi_modem_state_enabled()) {
|
||||
pau_regdma_trigger_modem_link_backup();
|
||||
} else
|
||||
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP */
|
||||
{
|
||||
// Disable PHY and RF.
|
||||
phy_close_rf();
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
// Disable PHY temperature sensor
|
||||
phy_xpd_tsens();
|
||||
#endif
|
||||
}
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
// Update WiFi MAC time before disalbe WiFi/BT common peripheral clock
|
||||
phy_update_wifi_mac_time(true, esp_timer_get_time());
|
||||
@@ -312,19 +336,19 @@ void esp_wifi_bt_power_domain_off(void)
|
||||
|
||||
void esp_phy_modem_init(void)
|
||||
{
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
_lock_acquire(&s_phy_access_lock);
|
||||
|
||||
s_phy_modem_init_ref++;
|
||||
if (s_phy_digital_regs_mem == NULL) {
|
||||
s_phy_digital_regs_mem = (uint32_t *)heap_caps_malloc(SOC_PHY_DIG_REGS_MEM_SIZE, MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||
}
|
||||
|
||||
_lock_release(&s_phy_access_lock);
|
||||
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
}
|
||||
|
||||
void esp_phy_modem_deinit(void)
|
||||
{
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
_lock_acquire(&s_phy_access_lock);
|
||||
|
||||
s_phy_modem_init_ref--;
|
||||
@@ -341,50 +365,76 @@ void esp_phy_modem_deinit(void)
|
||||
}
|
||||
|
||||
_lock_release(&s_phy_access_lock);
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
}
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
static uint32_t* s_mac_bb_pd_mem = NULL;
|
||||
/* Reference count of MAC BB backup memory */
|
||||
static uint8_t s_macbb_backup_mem_ref = 0;
|
||||
/* Reference of powering down MAC and BB */
|
||||
static bool s_mac_bb_pu = true;
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
|
||||
void esp_mac_bb_pd_mem_init(void)
|
||||
{
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
_lock_acquire(&s_phy_access_lock);
|
||||
|
||||
s_macbb_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);
|
||||
}
|
||||
|
||||
_lock_release(&s_phy_access_lock);
|
||||
#elif SOC_PM_MODEM_RETENTION_BY_REGDMA
|
||||
const static sleep_retention_entries_config_t bb_regs_retention[] = {
|
||||
[0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b00, 0x600a7000, 0x600a7000, 121, 0, 0), .owner = BIT(0) | BIT(1) }, /* AGC */
|
||||
[1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b01, 0x600a7400, 0x600a7400, 14, 0, 0), .owner = BIT(0) | BIT(1) }, /* TX */
|
||||
[2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b02, 0x600a7800, 0x600a7800, 136, 0, 0), .owner = BIT(0) | BIT(1) }, /* NRX */
|
||||
[3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b03, 0x600a7c00, 0x600a7c00, 53, 0, 0), .owner = BIT(0) | BIT(1) }, /* BB */
|
||||
[4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b05, 0x600a0000, 0x600a0000, 58, 0, 0), .owner = BIT(0) | BIT(1) } /* FE COEX */
|
||||
};
|
||||
esp_err_t err = sleep_retention_entries_create(bb_regs_retention, ARRAY_SIZE(bb_regs_retention), 3, SLEEP_RETENTION_MODULE_WIFI_BB);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "failed to allocate memory for WiFi baseband retention");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void esp_mac_bb_pd_mem_deinit(void)
|
||||
{
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
_lock_acquire(&s_phy_access_lock);
|
||||
|
||||
s_macbb_backup_mem_ref--;
|
||||
if (s_macbb_backup_mem_ref == 0) {
|
||||
free(s_mac_bb_pd_mem);
|
||||
s_mac_bb_pd_mem = NULL;
|
||||
}
|
||||
|
||||
_lock_release(&s_phy_access_lock);
|
||||
#elif SOC_PM_MODEM_RETENTION_BY_REGDMA
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_WIFI_BB);
|
||||
#endif
|
||||
}
|
||||
|
||||
IRAM_ATTR void esp_mac_bb_power_up(void)
|
||||
{
|
||||
esp_wifi_bt_power_domain_on();
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
if (s_mac_bb_pd_mem == NULL) {
|
||||
return;
|
||||
}
|
||||
esp_wifi_bt_power_domain_on();
|
||||
if (!s_mac_bb_pu) {
|
||||
esp_phy_common_clock_enable();
|
||||
phy_freq_mem_backup(false, s_mac_bb_pd_mem);
|
||||
esp_phy_common_clock_disable();
|
||||
s_mac_bb_pu = true;
|
||||
}
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
}
|
||||
|
||||
IRAM_ATTR void esp_mac_bb_power_down(void)
|
||||
{
|
||||
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
if (s_mac_bb_pd_mem == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -394,9 +444,10 @@ IRAM_ATTR void esp_mac_bb_power_down(void)
|
||||
esp_phy_common_clock_disable();
|
||||
s_mac_bb_pu = false;
|
||||
}
|
||||
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
|
||||
esp_wifi_bt_power_domain_off();
|
||||
}
|
||||
#endif
|
||||
#endif // CONFIG_MAC_BB_PD
|
||||
|
||||
// PHY init data handling functions
|
||||
#if CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION
|
||||
|
Reference in New Issue
Block a user