diff --git a/components/esp_hw_support/modem_clock.c b/components/esp_hw_support/modem_clock.c index 6d027bd86f..66e4b504c0 100644 --- a/components/esp_hw_support/modem_clock.c +++ b/components/esp_hw_support/modem_clock.c @@ -28,6 +28,10 @@ typedef enum { MODEM_CLOCK_MODEM_PRIVATE_FE, MODEM_CLOCK_COEXIST, MODEM_CLOCK_I2C_MASTER, +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + MODEM_CLOCK_WIFI_APB, + MODEM_CLOCK_WIFI_BB_44M, +#endif #if SOC_WIFI_SUPPORTED MODEM_CLOCK_WIFI_MAC, MODEM_CLOCK_WIFI_BB, @@ -64,7 +68,9 @@ typedef struct modem_clock_context { static void IRAM_ATTR modem_clock_wifi_mac_configure(modem_clock_context_t *ctx, bool enable) { if (enable) { +#if !SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT modem_syscon_ll_enable_wifi_apb_clock(ctx->hal->syscon_dev, enable); +#endif modem_syscon_ll_enable_wifi_mac_clock(ctx->hal->syscon_dev, enable); } } @@ -86,6 +92,22 @@ static void IRAM_ATTR modem_clock_ble_mac_configure(modem_clock_context_t *ctx, } #endif // SOC_BT_SUPPORTED +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT +static void IRAM_ATTR modem_clock_wifi_apb_configure(modem_clock_context_t *ctx, bool enable) +{ + if (enable) { + modem_syscon_ll_enable_wifi_apb_clock(ctx->hal->syscon_dev, enable); + } +} + +static void IRAM_ATTR modem_clock_wifi_bb_44m_configure(modem_clock_context_t *ctx, bool enable) +{ + if (enable) { + modem_syscon_ll_enable_wifibb_44m_clock(ctx->hal->syscon_dev, enable); + } +} +#endif + #if SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED static void IRAM_ATTR modem_clock_ble_i154_bb_configure(modem_clock_context_t *ctx, bool enable) { @@ -149,6 +171,10 @@ modem_clock_context_t * __attribute__((weak)) IRAM_ATTR MODEM_CLOCK_instance(voi [MODEM_CLOCK_MODEM_PRIVATE_FE] = { .refs = 0, .configure = modem_clock_modem_private_fe_configure }, [MODEM_CLOCK_COEXIST] = { .refs = 0, .configure = modem_clock_coex_configure }, [MODEM_CLOCK_I2C_MASTER] = { .refs = 0, .configure = modem_clock_i2c_master_configure }, +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + [MODEM_CLOCK_WIFI_APB] = { .refs = 0, .configure = modem_clock_wifi_apb_configure }, + [MODEM_CLOCK_WIFI_BB_44M] = { .refs = 0, .configure = modem_clock_wifi_bb_44m_configure }, +#endif #if SOC_WIFI_SUPPORTED [MODEM_CLOCK_WIFI_MAC] = { .refs = 0, .configure = modem_clock_wifi_mac_configure }, [MODEM_CLOCK_WIFI_BB] = { .refs = 0, .configure = modem_clock_wifi_bb_configure }, @@ -273,8 +299,11 @@ void IRAM_ATTR modem_clock_module_mac_reset(periph_module_t module) } portEXIT_CRITICAL_SAFE(&ctx->lock); } - +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT +#define WIFI_CLOCK_DEPS (BIT(MODEM_CLOCK_WIFI_MAC) | BIT(MODEM_CLOCK_WIFI_APB) | BIT(MODEM_CLOCK_WIFI_BB) | BIT(MODEM_CLOCK_WIFI_BB_44M) | BIT(MODEM_CLOCK_COEXIST)) +#else #define WIFI_CLOCK_DEPS (BIT(MODEM_CLOCK_WIFI_MAC) | BIT(MODEM_CLOCK_WIFI_BB) | BIT(MODEM_CLOCK_COEXIST)) +#endif #define BLE_CLOCK_DEPS (BIT(MODEM_CLOCK_BLE_MAC) | BIT(MODEM_CLOCK_BT_I154_COMMON_BB) | BIT(MODEM_CLOCK_ETM) | BIT(MODEM_CLOCK_COEXIST)) #define IEEE802154_CLOCK_DEPS (BIT(MODEM_CLOCK_802154_MAC) | BIT(MODEM_CLOCK_BT_I154_COMMON_BB) | BIT(MODEM_CLOCK_ETM) | BIT(MODEM_CLOCK_COEXIST)) #define COEXIST_CLOCK_DEPS (BIT(MODEM_CLOCK_COEXIST)) @@ -282,6 +311,9 @@ void IRAM_ATTR modem_clock_module_mac_reset(periph_module_t module) #define I2C_ANA_MST_CLOCK_DEPS (BIT(MODEM_CLOCK_I2C_MASTER)) #define MODEM_ETM_CLOCK_DEPS (BIT(MODEM_CLOCK_ETM)) #define MODEM_ADC_COMMON_FE_CLOCK_DEPS (BIT(MODEM_CLOCK_MODEM_ADC_COMMON_FE)) +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT +#define PHY_CALIBRATION_CLOCK_DEPS (BIT(MODEM_CLOCK_WIFI_APB) | BIT(MODEM_CLOCK_WIFI_BB_44M)) +#endif static IRAM_ATTR uint32_t modem_clock_get_module_deps(periph_module_t module) { @@ -299,6 +331,9 @@ static IRAM_ATTR uint32_t modem_clock_get_module_deps(periph_module_t module) #if SOC_BT_SUPPORTED case PERIPH_BT_MODULE: deps = BLE_CLOCK_DEPS; break; #endif +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + case PERIPH_PHY_CALIBRATION_MODULE: deps = PHY_CALIBRATION_CLOCK_DEPS; break; +#endif #if SOC_IEEE802154_SUPPORTED case PERIPH_IEEE802154_MODULE: deps = IEEE802154_CLOCK_DEPS; break; #endif diff --git a/components/esp_phy/lib b/components/esp_phy/lib index b942b97a65..9c0ed868fe 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit b942b97a65e92b5899636f2dc40e8336d43ee107 +Subproject commit 9c0ed868fe5eb6f321c4fb478136bccbfba5a670 diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 16ca899e31..5a3858ebe6 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -49,6 +49,10 @@ #include "esp_private/sleep_modem.h" #endif #include "hal/efuse_hal.h" +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT +#include "esp_private/esp_modem_clock.h" +#include "soc/periph_defs.h" +#endif #if CONFIG_IDF_TARGET_ESP32 extern wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb; @@ -268,6 +272,22 @@ IRAM_ATTR void esp_phy_common_clock_disable(void) wifi_bt_common_module_disable(); } +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT +IRAM_ATTR void esp_phy_calibration_clock_enable(esp_phy_modem_t modem) +{ + if (modem == PHY_MODEM_BT || modem == PHY_MODEM_IEEE802154) { + modem_clock_module_enable(PERIPH_PHY_CALIBRATION_MODULE); + } +} + +IRAM_ATTR void esp_phy_calibration_clock_disable(esp_phy_modem_t modem) +{ + if (modem == PHY_MODEM_BT || modem == PHY_MODEM_IEEE802154) { + modem_clock_module_disable(PERIPH_PHY_CALIBRATION_MODULE); + } +} +#endif + #if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA static inline void phy_digital_regs_store(void) { @@ -296,6 +316,9 @@ void esp_phy_enable(esp_phy_modem_t modem) phy_update_wifi_mac_time(false, s_phy_rf_en_ts); #endif esp_phy_common_clock_enable(); +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + esp_phy_calibration_clock_enable(modem); +#endif if (s_is_phy_calibrated == false) { esp_phy_load_cal_and_init(); s_is_phy_calibrated = true; @@ -337,7 +360,9 @@ void esp_phy_enable(esp_phy_modem_t modem) phy_ant_update(); phy_ant_clr_update_flag(); } - +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + esp_phy_calibration_clock_disable(modem); +#endif } phy_set_modem_flag(modem); #if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_ESP_PHY_DISABLE_PLL_TRACK diff --git a/components/hal/esp32c5/include/hal/modem_syscon_ll.h b/components/hal/esp32c5/include/hal/modem_syscon_ll.h index b8281dd4c5..79a28fd082 100644 --- a/components/hal/esp32c5/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32c5/include/hal/modem_syscon_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -327,12 +327,23 @@ static inline void modem_syscon_ll_clk_conf1_configure(modem_syscon_dev_t *hw, b __attribute__((always_inline)) static inline void modem_syscon_ll_clk_wifibb_configure(modem_syscon_dev_t *hw, bool en) { +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + /* Configure + clk_wifibb_22m / clk_wifibb_40m / clk_wifibb_80m + clk_wifibb_40x / clk_wifibb_80x / clk_wifibb_40x1 / clk_wifibb_80x1 + clk_wifibb_160x1 + + clk_wifibb_44m is configured in modem_syscon_ll_enable_wifibb_44m_clock + */ + modem_syscon_ll_clk_conf1_configure(hw, en, 0x1fb); +#else /* Configure clk_wifibb_22m / clk_wifibb_40m / clk_wifibb_44m / clk_wifibb_80m clk_wifibb_40x / clk_wifibb_80x / clk_wifibb_40x1 / clk_wifibb_80x1 clk_wifibb_160x1 */ modem_syscon_ll_clk_conf1_configure(hw, en, 0x1ff); +#endif } __attribute__((always_inline)) diff --git a/components/hal/esp32c61/include/hal/modem_syscon_ll.h b/components/hal/esp32c61/include/hal/modem_syscon_ll.h index bdf7371804..72c7f7eb18 100644 --- a/components/hal/esp32c61/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32c61/include/hal/modem_syscon_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -327,12 +327,23 @@ static inline void modem_syscon_ll_clk_conf1_configure(modem_syscon_dev_t *hw, b __attribute__((always_inline)) static inline void modem_syscon_ll_clk_wifibb_configure(modem_syscon_dev_t *hw, bool en) { +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + /* Configure + clk_wifibb_22m / clk_wifibb_40m / clk_wifibb_80m + clk_wifibb_40x / clk_wifibb_80x / clk_wifibb_40x1 / clk_wifibb_80x1 + clk_wifibb_160x1 + + clk_wifibb_44m is configured in modem_syscon_ll_enable_wifibb_44m_clock + */ + modem_syscon_ll_clk_conf1_configure(hw, en, 0x1fb); +#else /* Configure clk_wifibb_22m / clk_wifibb_40m / clk_wifibb_44m / clk_wifibb_80m clk_wifibb_40x / clk_wifibb_80x / clk_wifibb_40x1 / clk_wifibb_80x1 clk_wifibb_160x1 */ modem_syscon_ll_clk_conf1_configure(hw, en, 0x1ff); +#endif } __attribute__((always_inline)) diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 1dea626a85..15409dceb5 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -1859,6 +1859,10 @@ config SOC_BLE_CTE_SUPPORTED bool default y +config SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + bool + default y + config SOC_LP_CORE_SINGLE_INTERRUPT_VECTOR bool default y diff --git a/components/soc/esp32c5/include/soc/periph_defs.h b/components/soc/esp32c5/include/soc/periph_defs.h index f1d0108342..c84c73b7e6 100644 --- a/components/soc/esp32c5/include/soc/periph_defs.h +++ b/components/soc/esp32c5/include/soc/periph_defs.h @@ -73,12 +73,13 @@ typedef enum { PERIPH_ANA_I2C_MASTER_MODULE, PERIPH_MODEM_ETM_MODULE, PERIPH_MODEM_ADC_COMMON_FE_MODULE, + PERIPH_PHY_CALIBRATION_MODULE, PERIPH_MODULE_MAX /* !!! Don't append soc modules here !!! */ } periph_module_t; #define PERIPH_MODEM_MODULE_MIN PERIPH_WIFI_MODULE -#define PERIPH_MODEM_MODULE_MAX PERIPH_MODEM_ADC_COMMON_FE_MODULE +#define PERIPH_MODEM_MODULE_MAX PERIPH_PHY_CALIBRATION_MODULE #define PERIPH_MODEM_MODULE_NUM (PERIPH_MODEM_MODULE_MAX - PERIPH_MODEM_MODULE_MIN + 1) #define IS_MODEM_MODULE(periph) ((periph>=PERIPH_MODEM_MODULE_MIN) && (periph<=PERIPH_MODEM_MODULE_MAX)) diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 1a65246f20..eb47380731 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -717,6 +717,7 @@ /*------------------------------------- PHY CAPS -------------------------------------*/ // #define SOC_PHY_COMBO_MODULE (1) /*!< Support Wi-Fi, BLE and 15.4*/ +#define SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT (1) /*------------------------------------- ULP CAPS -------------------------------------*/ #define SOC_LP_CORE_SINGLE_INTERRUPT_VECTOR (1) /*!< LP Core interrupts all map to a single entry in vector table */ diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index e66ff2cf94..094942fa5d 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -1346,3 +1346,7 @@ config SOC_BLE_CTE_SUPPORTED config SOC_PHY_COMBO_MODULE bool default y + +config SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + bool + default y diff --git a/components/soc/esp32c61/include/soc/periph_defs.h b/components/soc/esp32c61/include/soc/periph_defs.h index 9885bb2f38..f4c771a385 100644 --- a/components/soc/esp32c61/include/soc/periph_defs.h +++ b/components/soc/esp32c61/include/soc/periph_defs.h @@ -42,12 +42,13 @@ typedef enum { PERIPH_ANA_I2C_MASTER_MODULE, PERIPH_MODEM_ETM_MODULE, PERIPH_MODEM_ADC_COMMON_FE_MODULE, + PERIPH_PHY_CALIBRATION_MODULE, PERIPH_MODULE_MAX /* !!! Don't append soc modules here !!! */ } periph_module_t; #define PERIPH_MODEM_MODULE_MIN PERIPH_WIFI_MODULE -#define PERIPH_MODEM_MODULE_MAX PERIPH_MODEM_ADC_COMMON_FE_MODULE +#define PERIPH_MODEM_MODULE_MAX PERIPH_PHY_CALIBRATION_MODULE #define PERIPH_MODEM_MODULE_NUM (PERIPH_MODEM_MODULE_MAX - PERIPH_MODEM_MODULE_MIN + 1) #define IS_MODEM_MODULE(periph) ((periph>=PERIPH_MODEM_MODULE_MIN) && (periph<=PERIPH_MODEM_MODULE_MAX)) diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 8eeebc16cf..0eecccecb5 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -537,6 +537,7 @@ /*------------------------------------- PHY CAPS -------------------------------------*/ #define SOC_PHY_COMBO_MODULE (1) /*!< Support Wi-Fi, BLE and 15.4*/ +#define SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT (1) /*------------------------------------- No Reset CAPS -------------------------------------*/ // \#define SOC_CAPS_NO_RESET_BY_ANA_BOD (1) //TODO: [ESP32C61] IDF-9254