mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(wifi): allow to disable wifi modem clocks if wifi is not inited
This commit is contained in:
@@ -74,6 +74,15 @@ void modem_clock_module_disable(periph_module_t module);
|
||||
*/
|
||||
uint32_t modem_clock_module_bits_get(periph_module_t module);
|
||||
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
/**
|
||||
* @brief Set Wi-Fi initialization status.
|
||||
*
|
||||
* @param inited Wi-Fi initialization status.
|
||||
*/
|
||||
void modem_clock_configure_wifi_status(bool inited);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reset the mac of modem module
|
||||
*
|
||||
|
||||
@@ -47,6 +47,8 @@ typedef enum {
|
||||
MODEM_CLOCK_DEVICE_MAX
|
||||
} modem_clock_device_t;
|
||||
|
||||
#define MODEM_STATUS_IDLE (0)
|
||||
#define MODEM_STATUS_WIFI_INITED (0x1UL)
|
||||
|
||||
typedef struct modem_clock_context {
|
||||
modem_clock_hal_context_t *hal;
|
||||
@@ -59,13 +61,16 @@ typedef struct modem_clock_context {
|
||||
} dev[MODEM_CLOCK_DEVICE_MAX];
|
||||
/* the low-power clock source for each module */
|
||||
modem_clock_lpclk_src_t lpclk_src[PERIPH_MODEM_MODULE_NUM];
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
uint32_t modem_status;
|
||||
#endif
|
||||
} modem_clock_context_t;
|
||||
|
||||
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
static void IRAM_ATTR modem_clock_wifi_mac_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (enable || !(ctx->modem_status & MODEM_STATUS_WIFI_INITED)) {
|
||||
modem_syscon_ll_enable_wifi_apb_clock(ctx->hal->syscon_dev, enable);
|
||||
modem_syscon_ll_enable_wifi_mac_clock(ctx->hal->syscon_dev, enable);
|
||||
}
|
||||
@@ -73,7 +78,7 @@ static void IRAM_ATTR modem_clock_wifi_mac_configure(modem_clock_context_t *ctx,
|
||||
|
||||
static void IRAM_ATTR modem_clock_wifi_bb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (enable || !(ctx->modem_status & MODEM_STATUS_WIFI_INITED)) {
|
||||
modem_syscon_ll_clk_wifibb_configure(ctx->hal->syscon_dev, enable);
|
||||
}
|
||||
}
|
||||
@@ -164,6 +169,10 @@ modem_clock_context_t * __attribute__((weak)) IRAM_ATTR MODEM_CLOCK_instance(voi
|
||||
[MODEM_CLOCK_DATADUMP] = { .refs = 0, .with_refcnt = true, .configure = modem_clock_data_dump_configure }
|
||||
},
|
||||
.lpclk_src = { [0 ... PERIPH_MODEM_MODULE_NUM - 1] = MODEM_CLOCK_LPCLK_SRC_INVALID }
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
,
|
||||
.modem_status = MODEM_STATUS_IDLE
|
||||
#endif
|
||||
};
|
||||
return &modem_clock_context;
|
||||
}
|
||||
@@ -389,6 +398,18 @@ uint32_t IRAM_ATTR modem_clock_module_bits_get(periph_module_t module)
|
||||
return val;
|
||||
}
|
||||
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
void modem_clock_configure_wifi_status(bool inited)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&MODEM_CLOCK_instance()->lock);
|
||||
if (inited)
|
||||
MODEM_CLOCK_instance()->modem_status |= MODEM_STATUS_WIFI_INITED;
|
||||
else
|
||||
MODEM_CLOCK_instance()->modem_status &= ~MODEM_STATUS_WIFI_INITED;
|
||||
portEXIT_CRITICAL_SAFE(&MODEM_CLOCK_instance()->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
void modem_clock_deselect_all_module_lp_clock_source(void)
|
||||
{
|
||||
#if SOC_WIFI_SUPPORTED
|
||||
|
||||
Reference in New Issue
Block a user