mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/add_modem_module_rst_api_v5.1' into 'release/v5.1'
modem_clock: add modem module mac reset api (backport v5.1) See merge request espressif/esp-idf!24441
This commit is contained in:
commit
159e80246b
@ -29,6 +29,16 @@ extern "C" {
|
|||||||
* module depends on the wifi mac, wifi baseband and FE, when wifi module
|
* module depends on the wifi mac, wifi baseband and FE, when wifi module
|
||||||
* clock is enabled, the wifi MAC, baseband and FE clocks will be enabled
|
* clock is enabled, the wifi MAC, baseband and FE clocks will be enabled
|
||||||
*
|
*
|
||||||
|
* This interface and modem_clock_module_disable will jointly maintain the
|
||||||
|
* ref_cnt of each device clock source. The ref_cnt indicates how many modules
|
||||||
|
* are relying on the clock source. Each enable ops will add 1 to the ref_cnt of
|
||||||
|
* the clock source that the module depends on, and only when the ref_cnt of
|
||||||
|
* the module is from 0 to 1 will the clock enable be actually configured.
|
||||||
|
*
|
||||||
|
* !!! Do not use the hal/ll layer interface to configure the clock for the
|
||||||
|
* consistency of the hardware state maintained in the driver and the hardware
|
||||||
|
* actual state.
|
||||||
|
*
|
||||||
* @param module modem module
|
* @param module modem module
|
||||||
*/
|
*/
|
||||||
void modem_clock_module_enable(periph_module_t module);
|
void modem_clock_module_enable(periph_module_t module);
|
||||||
@ -36,10 +46,28 @@ void modem_clock_module_enable(periph_module_t module);
|
|||||||
/**
|
/**
|
||||||
* @brief Disable the clock of modem module
|
* @brief Disable the clock of modem module
|
||||||
*
|
*
|
||||||
|
* This interface and modem_clock_module_enable will jointly maintain the ref_cnt
|
||||||
|
* of each device clock source. The ref_cnt indicates how many modules are relying
|
||||||
|
* on the clock source. Each disable ops will minus 1 to the ref_cnt of the clock
|
||||||
|
* source that the module depends on, and only when the ref_cnt of the module is
|
||||||
|
* from 1 to 0 will the clock disable be actually configured.
|
||||||
|
*
|
||||||
|
* !!! Do not use the hal/ll layer interface to configure the clock for the
|
||||||
|
* consistency of the hardware state maintained in the driver and the hardware
|
||||||
|
* actual state.
|
||||||
|
*
|
||||||
* @param module modem module
|
* @param module modem module
|
||||||
*/
|
*/
|
||||||
void modem_clock_module_disable(periph_module_t module);
|
void modem_clock_module_disable(periph_module_t module);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the mac of modem module
|
||||||
|
*
|
||||||
|
* @param module modem module, must be one of
|
||||||
|
* PERIPH_WIFI_MODULE / PERIPH_BT_MODULE /PERIPH_IEEE802154_MODULE
|
||||||
|
*/
|
||||||
|
void modem_clock_module_mac_reset(periph_module_t module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the clock gating control signal of each clock domain of the modem
|
* @brief Initialize the clock gating control signal of each clock domain of the modem
|
||||||
*
|
*
|
||||||
|
@ -214,15 +214,34 @@ static void IRAM_ATTR modem_clock_device_disable(modem_clock_context_t *ctx, uin
|
|||||||
assert(refs >= 0);
|
assert(refs >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR modem_clock_wifi_mac_reset(void)
|
void IRAM_ATTR modem_clock_module_mac_reset(periph_module_t module)
|
||||||
{
|
{
|
||||||
#if SOC_WIFI_SUPPORTED
|
|
||||||
modem_clock_context_t *ctx = MODEM_CLOCK_instance();
|
modem_clock_context_t *ctx = MODEM_CLOCK_instance();
|
||||||
portENTER_CRITICAL_SAFE(&ctx->lock);
|
portENTER_CRITICAL_SAFE(&ctx->lock);
|
||||||
//TODO: IDF-5713
|
switch (module)
|
||||||
modem_syscon_ll_reset_wifimac(ctx->hal->syscon_dev);
|
{
|
||||||
portEXIT_CRITICAL_SAFE(&ctx->lock);
|
#if SOC_WIFI_SUPPORTED
|
||||||
|
case PERIPH_WIFI_MODULE:
|
||||||
|
modem_syscon_ll_reset_wifimac(ctx->hal->syscon_dev);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#if SOC_BT_SUPPORTED
|
||||||
|
case PERIPH_BT_MODULE:
|
||||||
|
modem_syscon_ll_reset_btmac(ctx->hal->syscon_dev);
|
||||||
|
modem_syscon_ll_reset_btmac_apb(ctx->hal->syscon_dev);
|
||||||
|
modem_syscon_ll_reset_ble_timer(ctx->hal->syscon_dev);
|
||||||
|
modem_syscon_ll_reset_modem_sec(ctx->hal->syscon_dev);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if SOC_IEEE802154_SUPPORTED
|
||||||
|
case PERIPH_IEEE802154_MODULE:
|
||||||
|
modem_syscon_ll_reset_zbmac(ctx->hal->syscon_dev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
#endif
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
portEXIT_CRITICAL_SAFE(&ctx->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WIFI_CLOCK_DEPS (BIT(MODEM_CLOCK_WIFI_MAC) | BIT(MODEM_CLOCK_FE) | BIT(MODEM_CLOCK_WIFI_BB) | BIT(MODEM_CLOCK_COEXIST))
|
#define WIFI_CLOCK_DEPS (BIT(MODEM_CLOCK_WIFI_MAC) | BIT(MODEM_CLOCK_FE) | BIT(MODEM_CLOCK_WIFI_BB) | BIT(MODEM_CLOCK_COEXIST))
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "esp_event.h"
|
#include "esp_event.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_timer.h"
|
#include "esp_timer.h"
|
||||||
|
#include "esp_private/esp_modem_clock.h"
|
||||||
#include "esp_private/wifi_os_adapter.h"
|
#include "esp_private/wifi_os_adapter.h"
|
||||||
#include "esp_private/wifi.h"
|
#include "esp_private/wifi.h"
|
||||||
#include "esp_phy_init.h"
|
#include "esp_phy_init.h"
|
||||||
@ -297,9 +298,7 @@ static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat
|
|||||||
|
|
||||||
static void wifi_reset_mac_wrapper(void)
|
static void wifi_reset_mac_wrapper(void)
|
||||||
{
|
{
|
||||||
// TODO: IDF-5713
|
modem_clock_module_mac_reset(PERIPH_WIFI_MODULE);
|
||||||
modem_clock_wifi_mac_reset();
|
|
||||||
ESP_LOGW(TAG, "wifi_reset_mac_wrapper() has not been implemented yet");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wifi_clock_enable_wrapper(void)
|
static void wifi_clock_enable_wrapper(void)
|
||||||
|
@ -19,7 +19,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
||||||
{ // TODO: IDF-5713
|
{
|
||||||
switch (periph) {
|
switch (periph) {
|
||||||
case PERIPH_SARADC_MODULE:
|
case PERIPH_SARADC_MODULE:
|
||||||
return PCR_SARADC_CLK_EN;
|
return PCR_SARADC_CLK_EN;
|
||||||
@ -82,25 +82,13 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
|||||||
//TODO: LP_PERIPH modules are added temporarily and will be moved to a separate API (IDF-7374).
|
//TODO: LP_PERIPH modules are added temporarily and will be moved to a separate API (IDF-7374).
|
||||||
case PERIPH_LP_I2C0_MODULE:
|
case PERIPH_LP_I2C0_MODULE:
|
||||||
return LPPERI_LP_EXT_I2C_CK_EN;
|
return LPPERI_LP_EXT_I2C_CK_EN;
|
||||||
// case PERIPH_RNG_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_RNG_EN;
|
|
||||||
// case PERIPH_WIFI_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_WIFI_EN_M;
|
|
||||||
// case PERIPH_BT_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_BT_EN_M;
|
|
||||||
// case PERIPH_WIFI_BT_COMMON_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_WIFI_BT_COMMON_M;
|
|
||||||
// case PERIPH_BT_BASEBAND_MODULE:
|
|
||||||
// return PCR_BT_BASEBAND_EN;
|
|
||||||
// case PERIPH_BT_LC_MODULE:
|
|
||||||
// return PCR_BT_LC_EN;
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool enable)
|
static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool enable)
|
||||||
{ // TODO: IDF-5713
|
{
|
||||||
(void)enable; // unused
|
(void)enable; // unused
|
||||||
|
|
||||||
switch (periph) {
|
switch (periph) {
|
||||||
@ -178,34 +166,14 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
|
|||||||
//TODO: LP_PERIPH modules are added temporarily and will be moved to a separate API (IDF-7374).
|
//TODO: LP_PERIPH modules are added temporarily and will be moved to a separate API (IDF-7374).
|
||||||
case PERIPH_LP_I2C0_MODULE:
|
case PERIPH_LP_I2C0_MODULE:
|
||||||
return LPPERI_LP_EXT_I2C_RESET_EN;
|
return LPPERI_LP_EXT_I2C_RESET_EN;
|
||||||
// case PERIPH_RNG_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_RNG_EN;
|
|
||||||
// case PERIPH_WIFI_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_WIFI_EN_M;
|
|
||||||
// case PERIPH_BT_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_BT_EN_M;
|
|
||||||
// case PERIPH_WIFI_BT_COMMON_MODULE:
|
|
||||||
// return PCR_WIFI_CLK_WIFI_BT_COMMON_M;
|
|
||||||
// case PERIPH_BT_BASEBAND_MODULE:
|
|
||||||
// return PCR_BT_BASEBAND_EN;
|
|
||||||
// case PERIPH_BT_LC_MODULE:
|
|
||||||
// return PCR_BT_LC_EN;
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
||||||
{ // TODO: IDF-5713
|
{
|
||||||
switch (periph) {
|
switch (periph) {
|
||||||
// case PERIPH_RNG_MODULE:
|
|
||||||
// case PERIPH_WIFI_MODULE:
|
|
||||||
// case PERIPH_BT_MODULE:
|
|
||||||
// case PERIPH_WIFI_BT_COMMON_MODULE:
|
|
||||||
// case PERIPH_BT_BASEBAND_MODULE:
|
|
||||||
// case PERIPH_BT_LC_MODULE:
|
|
||||||
// return SYSTEM_WIFI_CLK_EN_REG;
|
|
||||||
|
|
||||||
case PERIPH_SARADC_MODULE:
|
case PERIPH_SARADC_MODULE:
|
||||||
return PCR_SARADC_CONF_REG;
|
return PCR_SARADC_CONF_REG;
|
||||||
case PERIPH_RMT_MODULE:
|
case PERIPH_RMT_MODULE:
|
||||||
@ -273,7 +241,7 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
|
static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
|
||||||
{ // TODO: IDF-5713
|
{
|
||||||
switch (periph) {
|
switch (periph) {
|
||||||
case PERIPH_SARADC_MODULE:
|
case PERIPH_SARADC_MODULE:
|
||||||
return PCR_SARADC_CONF_REG;
|
return PCR_SARADC_CONF_REG;
|
||||||
|
@ -216,6 +216,34 @@ static inline void modem_lpcon_ll_set_lp_apb_icg_bitmap(modem_lpcon_dev_t *hw, u
|
|||||||
hw->clk_conf_power_st.clk_lp_apb_st_map = bitmap;
|
hw->clk_conf_power_st.clk_lp_apb_st_map = bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
static inline void modem_lpcon_ll_reset_wifipwr(modem_lpcon_dev_t *hw)
|
||||||
|
{
|
||||||
|
hw->rst_conf.rst_wifipwr = 1;
|
||||||
|
hw->rst_conf.rst_wifipwr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
static inline void modem_lpcon_ll_reset_coex(modem_lpcon_dev_t *hw)
|
||||||
|
{
|
||||||
|
hw->rst_conf.rst_coex = 1;
|
||||||
|
hw->rst_conf.rst_coex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
static inline void modem_lpcon_ll_reset_i2c_master(modem_lpcon_dev_t *hw)
|
||||||
|
{
|
||||||
|
hw->rst_conf.rst_i2c_mst = 1;
|
||||||
|
hw->rst_conf.rst_i2c_mst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
static inline void modem_lpcon_ll_reset_ble_rtc_timer(modem_lpcon_dev_t *hw)
|
||||||
|
{
|
||||||
|
hw->rst_conf.rst_lp_timer = 1;
|
||||||
|
hw->rst_conf.rst_lp_timer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
static inline void modem_lpcon_ll_reset_all(modem_lpcon_dev_t *hw)
|
static inline void modem_lpcon_ll_reset_all(modem_lpcon_dev_t *hw)
|
||||||
{
|
{
|
||||||
|
@ -204,31 +204,16 @@ static inline void modem_syscon_ll_reset_zbmac(modem_syscon_dev_t *hw)
|
|||||||
hw->modem_rst_conf.rst_zbmac = 0;
|
hw->modem_rst_conf.rst_zbmac = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((always_inline))
|
|
||||||
static inline void modem_syscon_ll_reset_modem_ecb(modem_syscon_dev_t *hw)
|
|
||||||
{
|
|
||||||
hw->modem_rst_conf.rst_modem_ecb = 1;
|
|
||||||
hw->modem_rst_conf.rst_modem_ecb = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
|
||||||
static inline void modem_syscon_ll_reset_modem_ccm(modem_syscon_dev_t *hw)
|
|
||||||
{
|
|
||||||
hw->modem_rst_conf.rst_modem_ccm = 1;
|
|
||||||
hw->modem_rst_conf.rst_modem_ccm = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
|
||||||
static inline void modem_syscon_ll_reset_modem_bah(modem_syscon_dev_t *hw)
|
|
||||||
{
|
|
||||||
hw->modem_rst_conf.rst_modem_bah = 1;
|
|
||||||
hw->modem_rst_conf.rst_modem_bah = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
static inline void modem_syscon_ll_reset_modem_sec(modem_syscon_dev_t *hw)
|
static inline void modem_syscon_ll_reset_modem_sec(modem_syscon_dev_t *hw)
|
||||||
{
|
{
|
||||||
|
hw->modem_rst_conf.rst_modem_ecb = 1;
|
||||||
|
hw->modem_rst_conf.rst_modem_ccm = 1;
|
||||||
|
hw->modem_rst_conf.rst_modem_bah = 1;
|
||||||
hw->modem_rst_conf.rst_modem_sec = 1;
|
hw->modem_rst_conf.rst_modem_sec = 1;
|
||||||
|
hw->modem_rst_conf.rst_modem_ecb = 0;
|
||||||
|
hw->modem_rst_conf.rst_modem_ccm = 0;
|
||||||
|
hw->modem_rst_conf.rst_modem_bah = 0;
|
||||||
hw->modem_rst_conf.rst_modem_sec = 0;
|
hw->modem_rst_conf.rst_modem_sec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,20 @@ static inline void modem_lpcon_ll_enable_fe_mem_force_clock(modem_lpcon_dev_t *h
|
|||||||
hw->clk_conf_force_on.clk_fe_mem_fo = en;
|
hw->clk_conf_force_on.clk_fe_mem_fo = en;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
static inline void modem_lpcon_ll_reset_coex(modem_lpcon_dev_t *hw)
|
||||||
|
{
|
||||||
|
hw->rst_conf.rst_coex = 1;
|
||||||
|
hw->rst_conf.rst_coex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
static inline void modem_lpcon_ll_reset_i2c_master(modem_lpcon_dev_t *hw)
|
||||||
|
{
|
||||||
|
hw->rst_conf.rst_i2c_mst = 1;
|
||||||
|
hw->rst_conf.rst_i2c_mst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
static inline void modem_lpcon_ll_reset_all(modem_lpcon_dev_t *hw)
|
static inline void modem_lpcon_ll_reset_all(modem_lpcon_dev_t *hw)
|
||||||
{
|
{
|
||||||
|
@ -150,31 +150,16 @@ static inline void modem_syscon_ll_reset_zbmac(modem_syscon_dev_t *hw)
|
|||||||
hw->modem_rst_conf.rst_zbmac = 0;
|
hw->modem_rst_conf.rst_zbmac = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((always_inline))
|
|
||||||
static inline void modem_syscon_ll_reset_modem_ecb(modem_syscon_dev_t *hw)
|
|
||||||
{
|
|
||||||
hw->modem_rst_conf.rst_modem_ecb = 1;
|
|
||||||
hw->modem_rst_conf.rst_modem_ecb = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
|
||||||
static inline void modem_syscon_ll_reset_modem_ccm(modem_syscon_dev_t *hw)
|
|
||||||
{
|
|
||||||
hw->modem_rst_conf.rst_modem_ccm = 1;
|
|
||||||
hw->modem_rst_conf.rst_modem_ccm = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
|
||||||
static inline void modem_syscon_ll_reset_modem_bah(modem_syscon_dev_t *hw)
|
|
||||||
{
|
|
||||||
hw->modem_rst_conf.rst_modem_bah = 1;
|
|
||||||
hw->modem_rst_conf.rst_modem_bah = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
static inline void modem_syscon_ll_reset_modem_sec(modem_syscon_dev_t *hw)
|
static inline void modem_syscon_ll_reset_modem_sec(modem_syscon_dev_t *hw)
|
||||||
{
|
{
|
||||||
|
hw->modem_rst_conf.rst_modem_ecb = 1;
|
||||||
|
hw->modem_rst_conf.rst_modem_ccm = 1;
|
||||||
|
hw->modem_rst_conf.rst_modem_bah = 1;
|
||||||
hw->modem_rst_conf.rst_modem_sec = 1;
|
hw->modem_rst_conf.rst_modem_sec = 1;
|
||||||
|
hw->modem_rst_conf.rst_modem_ecb = 0;
|
||||||
|
hw->modem_rst_conf.rst_modem_ccm = 0;
|
||||||
|
hw->modem_rst_conf.rst_modem_bah = 0;
|
||||||
hw->modem_rst_conf.rst_modem_sec = 0;
|
hw->modem_rst_conf.rst_modem_sec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user