From 394df648b11ca722aefe47e1384eb54a1e803155 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Mon, 22 Dec 2025 18:19:59 +0800 Subject: [PATCH] feat(esp_hw_support): implement CHECK_ENABLE operations for modem clock control functions --- .../include/esp_private/regi2c_ctrl.h | 3 + components/esp_hw_support/modem_clock.c | 147 +++++++++++++++++- .../hal/esp32c5/include/hal/modem_lpcon_ll.h | 12 ++ .../hal/esp32c5/include/hal/modem_syscon_ll.h | 142 +++++++++++++++++ components/hal/esp32c5/modem_clock_hal.c | 14 ++ .../hal/esp32c6/include/hal/modem_lpcon_ll.h | 18 +++ .../hal/esp32c6/include/hal/modem_syscon_ll.h | 115 +++++++++++++- components/hal/esp32c6/modem_clock_hal.c | 12 ++ .../hal/esp32c61/include/hal/modem_lpcon_ll.h | 12 ++ .../esp32c61/include/hal/modem_syscon_ll.h | 141 +++++++++++++++++ components/hal/esp32c61/modem_clock_hal.c | 14 ++ .../hal/esp32h2/include/hal/modem_lpcon_ll.h | 18 +++ .../hal/esp32h2/include/hal/modem_syscon_ll.h | 101 ++++++++++++ components/hal/esp32h2/modem_clock_hal.c | 14 ++ .../hal/esp32h21/include/hal/modem_lpcon_ll.h | 18 +++ .../esp32h21/include/hal/modem_syscon_ll.h | 107 +++++++++++++ components/hal/esp32h21/modem_clock_hal.c | 15 ++ .../hal/esp32h4/include/hal/modem_lpcon_ll.h | 18 +++ .../hal/esp32h4/include/hal/modem_syscon_ll.h | 114 ++++++++++++++ components/hal/esp32h4/modem_clock_hal.c | 14 ++ components/hal/include/hal/modem_clock_hal.h | 2 + 21 files changed, 1049 insertions(+), 2 deletions(-) diff --git a/components/esp_hw_support/include/esp_private/regi2c_ctrl.h b/components/esp_hw_support/include/esp_private/regi2c_ctrl.h index b35d356b599..ad7458501b9 100644 --- a/components/esp_hw_support/include/esp_private/regi2c_ctrl.h +++ b/components/esp_hw_support/include/esp_private/regi2c_ctrl.h @@ -27,6 +27,7 @@ extern "C" { // For bootloader, the strategy is to keep the analog i2c master clock always enabled if ANA_I2C_MST_CLK_HAS_ROOT_GATING (in bootloader_hardware_init()) #define ANALOG_CLOCK_ENABLE() #define ANALOG_CLOCK_DISABLE() +#define ANALOG_CLOCK_IS_ENABLED() #else // !BOOTLOADER_BUILD @@ -57,9 +58,11 @@ static inline __attribute__((always_inline)) void ANA_I2C_SRC_CLOCK_ENABLE(bool ANA_I2C_SRC_CLOCK_ENABLE(false); \ } +#define ANALOG_CLOCK_IS_ENABLED() regi2c_ctrl_ll_master_is_clock_enabled() #else #define ANALOG_CLOCK_ENABLE() #define ANALOG_CLOCK_DISABLE() +#define ANALOG_CLOCK_IS_ENABLED() #endif #endif // BOOTLOADER_BUILD diff --git a/components/esp_hw_support/modem_clock.c b/components/esp_hw_support/modem_clock.c index ae4d0de1f14..05b7fbc1576 100644 --- a/components/esp_hw_support/modem_clock.c +++ b/components/esp_hw_support/modem_clock.c @@ -31,7 +31,9 @@ typedef enum { MODEM_CLOCK_MODEM_ADC_COMMON_FE, MODEM_CLOCK_MODEM_PRIVATE_FE, MODEM_CLOCK_COEXIST, +#if ANA_I2C_MST_CLK_HAS_ROOT_GATING MODEM_CLOCK_I2C_MASTER, +#endif #if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT MODEM_CLOCK_WIFI_APB, MODEM_CLOCK_WIFI_BB_44M, @@ -63,6 +65,9 @@ typedef struct modem_clock_context { uint16_t with_refcnt : 1; /* Enable reference count management (true=use refs, false=ignore refs) */ uint16_t reserved : 15; /* reserved for 15 bits aligned */ void (*configure)(struct modem_clock_context *, bool); +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING + esp_err_t (*check_enable)(struct modem_clock_context *); +#endif } dev[MODEM_CLOCK_DEVICE_MAX]; /* the low-power clock source for each module */ modem_clock_lpclk_src_t lpclk_src[PERIPH_MODEM_MODULE_NUM]; @@ -86,6 +91,23 @@ static void IRAM_ATTR modem_clock_wifi_bb_configure(modem_clock_context_t *ctx, modem_syscon_ll_clk_wifibb_configure(ctx->hal->syscon_dev, enable); } } + +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING +static esp_err_t IRAM_ATTR modem_clock_wifi_mac_check_enable(modem_clock_context_t *ctx) +{ + bool all_clock_enabled = true; +#if !SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + all_clock_enabled &= modem_syscon_ll_wifi_apb_clock_is_enabled(ctx->hal->syscon_dev); +#endif + all_clock_enabled &= modem_syscon_ll_wifi_mac_clock_is_enabled(ctx->hal->syscon_dev); + return all_clock_enabled ? ESP_OK : ESP_FAIL; +} + +static esp_err_t IRAM_ATTR modem_clock_wifi_bb_check_enable(modem_clock_context_t *ctx) +{ + return modem_syscon_ll_wifibb_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL; +} +#endif #endif // SOC_WIFI_SUPPORTED #if SOC_BT_SUPPORTED @@ -95,6 +117,17 @@ static void IRAM_ATTR modem_clock_ble_mac_configure(modem_clock_context_t *ctx, modem_syscon_ll_enable_modem_sec_clock(ctx->hal->syscon_dev, enable); modem_syscon_ll_enable_ble_timer_clock(ctx->hal->syscon_dev, enable); } + +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING +static esp_err_t IRAM_ATTR modem_clock_ble_mac_check_enable(modem_clock_context_t *ctx) +{ + bool all_clock_enabled = true; + all_clock_enabled &= modem_syscon_ll_bt_mac_clock_is_enabled(ctx->hal->syscon_dev); + all_clock_enabled &= modem_syscon_ll_modem_sec_clock_is_enabled(ctx->hal->syscon_dev); + all_clock_enabled &= modem_syscon_ll_ble_timer_clock_is_enabled(ctx->hal->syscon_dev); + return all_clock_enabled ? ESP_OK : ESP_FAIL; +} +#endif #endif // SOC_BT_SUPPORTED #if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT @@ -111,6 +144,18 @@ static void IRAM_ATTR modem_clock_wifi_bb_44m_configure(modem_clock_context_t *c modem_syscon_ll_enable_wifibb_44m_clock(ctx->hal->syscon_dev, enable); } } + +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING +static esp_err_t IRAM_ATTR modem_clock_wifi_apb_check_enable(modem_clock_context_t *ctx) +{ + return modem_syscon_ll_wifi_apb_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL; +} + +static esp_err_t IRAM_ATTR modem_clock_wifi_bb_44m_check_enable(modem_clock_context_t *ctx) +{ + return modem_syscon_ll_wifibb_44m_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL; +} +#endif #endif #if SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED @@ -120,6 +165,15 @@ static void IRAM_ATTR modem_clock_ble_i154_bb_configure(modem_clock_context_t *c modem_syscon_ll_enable_bt_clock(ctx->hal->syscon_dev, enable); } +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING +static esp_err_t IRAM_ATTR modem_clock_ble_i154_bb_check_enable(modem_clock_context_t *ctx) +{ + bool all_clock_enabled = true; + all_clock_enabled &= modem_syscon_ll_bt_apb_clock_is_enabled(ctx->hal->syscon_dev); + all_clock_enabled &= modem_syscon_ll_bt_clock_is_enabled(ctx->hal->syscon_dev); + return all_clock_enabled ? ESP_OK : ESP_FAIL; +} +#endif #endif // SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED #if SOC_IEEE802154_SUPPORTED @@ -128,6 +182,16 @@ static void IRAM_ATTR modem_clock_ieee802154_mac_configure(modem_clock_context_t modem_syscon_ll_enable_ieee802154_apb_clock(ctx->hal->syscon_dev, enable); modem_syscon_ll_enable_ieee802154_mac_clock(ctx->hal->syscon_dev, enable); } + +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING +static esp_err_t IRAM_ATTR modem_clock_ieee802154_mac_check_enable(modem_clock_context_t *ctx) +{ + bool all_clock_enabled = true; + all_clock_enabled &= modem_syscon_ll_ieee802154_apb_clock_is_enabled(ctx->hal->syscon_dev); + all_clock_enabled &= modem_syscon_ll_ieee802154_mac_clock_is_enabled(ctx->hal->syscon_dev); + return all_clock_enabled ? ESP_OK : ESP_FAIL; +} +#endif #endif // SOC_IEEE802154_SUPPORTED static void IRAM_ATTR modem_clock_coex_configure(modem_clock_context_t *ctx, bool enable) @@ -145,6 +209,7 @@ static void IRAM_ATTR modem_clock_modem_private_fe_configure(modem_clock_context modem_clock_hal_enable_modem_private_fe_clock(ctx->hal, enable); } +#if ANA_I2C_MST_CLK_HAS_ROOT_GATING static void IRAM_ATTR modem_clock_i2c_master_configure(modem_clock_context_t *ctx, bool enable) { if (enable) { @@ -153,6 +218,7 @@ static void IRAM_ATTR modem_clock_i2c_master_configure(modem_clock_context_t *ct ANALOG_CLOCK_DISABLE(); } } +#endif static void IRAM_ATTR modem_clock_etm_configure(modem_clock_context_t *ctx, bool enable) { @@ -165,6 +231,43 @@ static void IRAM_ATTR modem_clock_data_dump_configure(modem_clock_context_t *ctx modem_syscon_ll_enable_data_dump_mux_clock(ctx->hal->syscon_dev, enable); } +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING +static esp_err_t IRAM_ATTR modem_clock_coex_check_enable(modem_clock_context_t *ctx) +{ + return modem_lpcon_ll_coex_clock_is_enabled(ctx->hal->lpcon_dev) ? ESP_OK : ESP_FAIL; +} + +static esp_err_t IRAM_ATTR modem_clock_modem_adc_common_fe_check_enable(modem_clock_context_t *ctx) +{ + return modem_clock_hal_modem_common_fe_clock_is_enabled(ctx->hal) ? ESP_OK : ESP_FAIL; +} + +static esp_err_t IRAM_ATTR modem_clock_modem_private_fe_check_enable(modem_clock_context_t *ctx) +{ + return modem_clock_hal_modem_private_fe_clock_is_enabled(ctx->hal) ? ESP_OK : ESP_FAIL; +} + +#if ANA_I2C_MST_CLK_HAS_ROOT_GATING +static esp_err_t IRAM_ATTR modem_clock_i2c_master_check_enable(modem_clock_context_t *ctx) +{ + return ANALOG_CLOCK_IS_ENABLED() ? ESP_OK : ESP_FAIL; +} +#endif + +static esp_err_t IRAM_ATTR modem_clock_etm_check_enable(modem_clock_context_t *ctx) +{ + return modem_syscon_ll_etm_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL; +} + +static esp_err_t IRAM_ATTR modem_clock_data_dump_check_enable(modem_clock_context_t *ctx) +{ + bool all_clock_enabled = true; + all_clock_enabled &= modem_syscon_ll_data_dump_clock_is_enabled(ctx->hal->syscon_dev); + all_clock_enabled &= modem_syscon_ll_data_dump_mux_clock_is_enabled(ctx->hal->syscon_dev); + return all_clock_enabled ? ESP_OK : ESP_FAIL; +} +#endif + modem_clock_context_t * __attribute__((weak)) IRAM_ATTR MODEM_CLOCK_instance(void) { /* It should be explicitly defined in the internal RAM */ @@ -175,8 +278,10 @@ modem_clock_context_t * __attribute__((weak)) IRAM_ATTR MODEM_CLOCK_instance(voi [MODEM_CLOCK_MODEM_ADC_COMMON_FE] = { .refs = 0, .with_refcnt = true, .configure = modem_clock_modem_adc_common_fe_configure }, [MODEM_CLOCK_MODEM_PRIVATE_FE] = { .refs = 0, .with_refcnt = true, .configure = modem_clock_modem_private_fe_configure }, [MODEM_CLOCK_COEXIST] = { .refs = 0, .with_refcnt = true, .configure = modem_clock_coex_configure }, +#if ANA_I2C_MST_CLK_HAS_ROOT_GATING // ANALOG_CLOCK_ENABLE/DISABLE has its own ref_cnt management. [MODEM_CLOCK_I2C_MASTER] = { .refs = 0, .with_refcnt = false, .configure = modem_clock_i2c_master_configure }, +#endif #if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT [MODEM_CLOCK_WIFI_APB] = { .refs = 0, .with_refcnt = true, .configure = modem_clock_wifi_apb_configure }, [MODEM_CLOCK_WIFI_BB_44M] = { .refs = 0, .with_refcnt = true, .configure = modem_clock_wifi_bb_44m_configure }, @@ -199,12 +304,40 @@ modem_clock_context_t * __attribute__((weak)) IRAM_ATTR MODEM_CLOCK_instance(voi }, .lpclk_src = { [0 ... PERIPH_MODEM_MODULE_NUM - 1] = MODEM_CLOCK_LPCLK_SRC_INVALID } }; + if (modem_clock_hal.syscon_dev == NULL || modem_clock_hal.lpcon_dev == NULL) { modem_clock_hal.syscon_dev = &MODEM_SYSCON; modem_clock_hal.lpcon_dev = &MODEM_LPCON; #if SOC_CLOCK_TREE_MANAGEMENT_SUPPORTED ESP_ERROR_CHECK(esp_clk_tree_enable_src(SOC_MOD_CLK_MODEM_APB, true)); #endif +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING + modem_clock_context.dev[MODEM_CLOCK_MODEM_ADC_COMMON_FE].check_enable = modem_clock_modem_adc_common_fe_check_enable; + modem_clock_context.dev[MODEM_CLOCK_MODEM_PRIVATE_FE].check_enable = modem_clock_modem_private_fe_check_enable; + modem_clock_context.dev[MODEM_CLOCK_COEXIST].check_enable = modem_clock_coex_check_enable; + #if ANA_I2C_MST_CLK_HAS_ROOT_GATING + modem_clock_context.dev[MODEM_CLOCK_I2C_MASTER].check_enable = modem_clock_i2c_master_check_enable; + #endif + #if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + modem_clock_context.dev[MODEM_CLOCK_WIFI_APB].check_enable = modem_clock_wifi_apb_check_enable; + modem_clock_context.dev[MODEM_CLOCK_WIFI_BB_44M].check_enable = modem_clock_wifi_bb_44m_check_enable; + #endif + #if SOC_WIFI_SUPPORTED + modem_clock_context.dev[MODEM_CLOCK_WIFI_MAC].check_enable = modem_clock_wifi_mac_check_enable; + modem_clock_context.dev[MODEM_CLOCK_WIFI_BB].check_enable = modem_clock_wifi_bb_check_enable; + #endif + modem_clock_context.dev[MODEM_CLOCK_ETM].check_enable = modem_clock_etm_check_enable; + #if SOC_BT_SUPPORTED + modem_clock_context.dev[MODEM_CLOCK_BLE_MAC].check_enable = modem_clock_ble_mac_check_enable; + #endif + #if SOC_IEEE802154_SUPPORTED || SOC_BT_SUPPORTED + modem_clock_context.dev[MODEM_CLOCK_BT_I154_COMMON_BB].check_enable = modem_clock_ble_i154_bb_check_enable; + #endif + #if SOC_IEEE802154_SUPPORTED + modem_clock_context.dev[MODEM_CLOCK_802154_MAC].check_enable = modem_clock_ieee802154_mac_check_enable; + #endif + modem_clock_context.dev[MODEM_CLOCK_DATADUMP].check_enable = modem_clock_data_dump_check_enable; +#endif // CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING } return &modem_clock_context; } @@ -253,6 +386,11 @@ static void IRAM_ATTR modem_clock_device_enable(modem_clock_context_t *ctx, uint if (refs == 0 || !ctx->dev[i].with_refcnt) { (*ctx->dev[i].configure)(ctx, true); } +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING + if (ctx->dev[i].check_enable) { + ESP_ERROR_CHECK((*ctx->dev[i].check_enable)(ctx)); + } +#endif } } esp_os_exit_critical_safe(&ctx->lock); @@ -314,8 +452,12 @@ void IRAM_ATTR modem_clock_module_mac_reset(shared_periph_module_t module) #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)) -#define PHY_CLOCK_DEPS (BIT(MODEM_CLOCK_I2C_MASTER) | BIT(MODEM_CLOCK_MODEM_ADC_COMMON_FE) | BIT(MODEM_CLOCK_MODEM_PRIVATE_FE)) +#if ANA_I2C_MST_CLK_HAS_ROOT_GATING #define I2C_ANA_MST_CLOCK_DEPS (BIT(MODEM_CLOCK_I2C_MASTER)) +#else +#define I2C_ANA_MST_CLOCK_DEPS (0) +#endif +#define PHY_CLOCK_DEPS (I2C_ANA_MST_CLOCK_DEPS | BIT(MODEM_CLOCK_MODEM_ADC_COMMON_FE) | BIT(MODEM_CLOCK_MODEM_PRIVATE_FE)) #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 @@ -381,6 +523,9 @@ static IRAM_ATTR void modem_clock_module_icg_map_init_all(void) for (int domain = 0; domain < MODEM_CLOCK_DOMAIN_MAX; domain++) { uint32_t code = modem_clock_hal_get_clock_domain_icg_bitmap(MODEM_CLOCK_instance()->hal, domain); modem_clock_hal_set_clock_domain_icg_bitmap(MODEM_CLOCK_instance()->hal, domain, initial_gating_mode[domain] | code); +#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING + assert((modem_clock_hal_get_clock_domain_icg_bitmap(MODEM_CLOCK_instance()->hal, domain) & code) == code); +#endif } esp_os_exit_critical_safe(&MODEM_CLOCK_instance()->lock); } diff --git a/components/hal/esp32c5/include/hal/modem_lpcon_ll.h b/components/hal/esp32c5/include/hal/modem_lpcon_ll.h index fd62ed3b2fb..72da6a3bc7c 100644 --- a/components/hal/esp32c5/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32c5/include/hal/modem_lpcon_ll.h @@ -25,6 +25,12 @@ static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_test_clk_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_ble_rtc_timer_slow_osc(modem_lpcon_dev_t *hw, bool en) { @@ -163,6 +169,12 @@ static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool hw->clk_conf.clk_coex_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_coex_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_coex_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_ble_rtc_timer_clock(modem_lpcon_dev_t *hw, bool en) { diff --git a/components/hal/esp32c5/include/hal/modem_syscon_ll.h b/components/hal/esp32c5/include/hal/modem_syscon_ll.h index fca99ead9f7..82dedd7a0fc 100644 --- a/components/hal/esp32c5/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32c5/include/hal/modem_syscon_ll.h @@ -11,6 +11,7 @@ #include #include #include "soc/soc.h" +#include "soc/soc_caps.h" #include "hal/assert.h" #include "modem/modem_syscon_struct.h" #include "hal/modem_clock_types.h" @@ -25,12 +26,24 @@ static inline void modem_syscon_ll_enable_test_clk(modem_syscon_dev_t *hw, bool hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_test_clk_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_pwdet_sar_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.pwdet_sar_clock_ena = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_pwdet_sar_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.pwdet_sar_clock_ena; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_set_pwdet_clk_div_num(modem_syscon_dev_t *hw, uint32_t div) { @@ -61,24 +74,48 @@ static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t hw->clk_conf.clk_data_dump_mux = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_mux_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_mux; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_etm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_etm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_etm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zbmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zbmac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw, bool en) { @@ -89,18 +126,40 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_modem_sec_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_modem_sec_en && + hw->clk_conf.clk_modem_sec_ecb_en && + hw->clk_conf.clk_modem_sec_ccm_en && + hw->clk_conf.clk_modem_sec_bah_en && + hw->clk_conf.clk_modem_sec_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_ble_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ble_timer_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_ble_timer_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_data_dump_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_force_clock(modem_syscon_dev_t *hw) { @@ -346,6 +405,17 @@ static inline void modem_syscon_ll_clk_wifibb_configure(modem_syscon_dev_t *hw, #endif } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifibb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + // Check if any of the wifibb clocks are enabled +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + return (hw->clk_conf1.val & 0x1fb) == 0x1fb; +#else + return (hw->clk_conf1.val & 0x1ff) == 0x1ff; +#endif +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifibb_22m_clock(modem_syscon_dev_t *hw, bool en) { @@ -364,6 +434,12 @@ static inline void modem_syscon_ll_enable_wifibb_44m_clock(modem_syscon_dev_t *h hw->clk_conf1.clk_wifibb_44m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifibb_44m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifibb_44m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifibb_80m_clock(modem_syscon_dev_t *hw, bool en) { @@ -413,12 +489,24 @@ static inline void modem_syscon_ll_enable_wifi_mac_clock(modem_syscon_dev_t *hw, hw->clk_conf1.clk_wifimac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifi_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifimac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifi_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_wifi_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifi_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifi_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_20m_clock(modem_syscon_dev_t *hw, bool en) { @@ -437,18 +525,36 @@ static inline void modem_syscon_ll_enable_fe_80m_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_80m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_80m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_80m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_160m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_160m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_160m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_160m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_apb_en; +} + // The modem_syscon of esp32c5 adds the enablement of the adc clock on the analog front end compared to esp32h2 and esp32c6. __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, bool en) @@ -456,6 +562,12 @@ static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_adc_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_adc_en; +} + // The modem_syscon of esp32c5 adds the enablement of the dac clock on the analog front end compared to esp32h2 and esp32c6. __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_dac_clock(modem_syscon_dev_t *hw, bool en) @@ -463,6 +575,12 @@ static inline void modem_syscon_ll_enable_fe_dac_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_dac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_dac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_dac_en; +} + // The modem_syscon of esp32c5 adds the enablement of the analog power detect clock on the analog front end compared to esp32h2 and esp32c6. __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_pwdet_clock(modem_syscon_dev_t *hw, bool en) @@ -470,24 +588,48 @@ static inline void modem_syscon_ll_enable_fe_pwdet_clock(modem_syscon_dev_t *hw, hw->clk_conf1.clk_fe_pwdet_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_pwdet_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_pwdet_adc_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_btmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_btmac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_btbb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_btbb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_480m_clock(modem_syscon_dev_t *hw, bool en) { diff --git a/components/hal/esp32c5/modem_clock_hal.c b/components/hal/esp32c5/modem_clock_hal.c index a1c8aa087e1..776bd50e1ea 100644 --- a/components/hal/esp32c5/modem_clock_hal.c +++ b/components/hal/esp32c5/modem_clock_hal.c @@ -103,6 +103,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_cont } } +bool IRAM_ATTR modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_apb_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_80m_clock_is_enabled(hal->syscon_dev); +} + void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable) { if (enable) { @@ -113,6 +119,14 @@ void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_con } } +bool IRAM_ATTR modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_160m_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_dac_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_pwdet_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_adc_clock_is_enabled(hal->syscon_dev); +} + void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider) { modem_lpcon_ll_set_ble_rtc_timer_divisor_value(hal->lpcon_dev, divider); diff --git a/components/hal/esp32c6/include/hal/modem_lpcon_ll.h b/components/hal/esp32c6/include/hal/modem_lpcon_ll.h index bd31a44cb20..197eee2b01d 100644 --- a/components/hal/esp32c6/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32c6/include/hal/modem_lpcon_ll.h @@ -145,18 +145,36 @@ static inline void modem_lpcon_ll_enable_wifipwr_clock(modem_lpcon_dev_t *hw, bo hw->clk_conf.clk_wifipwr_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_wifipwr_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_wifipwr_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool en) { hw->clk_conf.clk_coex_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_coex_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_coex_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_ble_rtc_timer_clock(modem_lpcon_dev_t *hw, bool en) { hw->clk_conf.clk_lp_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_ble_rtc_timer_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_lp_timer_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_wifipwr_force_clock(modem_lpcon_dev_t *hw, bool en) { diff --git a/components/hal/esp32c6/include/hal/modem_syscon_ll.h b/components/hal/esp32c6/include/hal/modem_syscon_ll.h index 2ade23179e0..65f46d58e1d 100644 --- a/components/hal/esp32c6/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32c6/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 */ @@ -31,24 +31,48 @@ static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t hw->clk_conf.clk_data_dump_mux = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_mux_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_mux; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_etm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_etm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_etm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_mac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_mac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw, bool en) { @@ -59,18 +83,40 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_modem_sec_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_modem_sec_en && + hw->clk_conf.clk_modem_sec_ecb_en && + hw->clk_conf.clk_modem_sec_ccm_en && + hw->clk_conf.clk_modem_sec_bah_en && + hw->clk_conf.clk_modem_sec_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_ble_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ble_timer_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_ble_timer_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_data_dump_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_force_clock(modem_syscon_dev_t *hw) { @@ -304,6 +350,13 @@ static inline void modem_syscon_ll_clk_wifibb_configure(modem_syscon_dev_t *hw, modem_syscon_ll_clk_conf1_configure(hw, en, 0x1ff); } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifibb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + // Check if any of the wifibb clocks are enabled + return (hw->clk_conf1.val & 0x1ff) == 0x1ff; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifibb_22m_clock(modem_syscon_dev_t *hw, bool en) { @@ -322,6 +375,12 @@ static inline void modem_syscon_ll_enable_wifibb_44m_clock(modem_syscon_dev_t *h hw->clk_conf1.clk_wifibb_44m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifibb_44m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifibb_44m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifibb_80m_clock(modem_syscon_dev_t *hw, bool en) { @@ -370,12 +429,24 @@ static inline void modem_syscon_ll_enable_wifi_mac_clock(modem_syscon_dev_t *hw, hw->clk_conf1.clk_wifimac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifi_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifimac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifi_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_wifi_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifi_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifi_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_20m_clock(modem_syscon_dev_t *hw, bool en) { @@ -394,41 +465,83 @@ static inline void modem_syscon_ll_enable_fe_80m_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_80m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_80m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_80m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_160m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_160m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_160m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_160m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_cal_160m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_cal_160m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_cal_160m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_cal_160m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_mac_clock(modem_syscon_dev_t *hw, bool en) { } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return true; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_480m_clock(modem_syscon_dev_t *hw, bool en) { diff --git a/components/hal/esp32c6/modem_clock_hal.c b/components/hal/esp32c6/modem_clock_hal.c index 42d8f973c09..a1b5f589cdc 100644 --- a/components/hal/esp32c6/modem_clock_hal.c +++ b/components/hal/esp32c6/modem_clock_hal.c @@ -103,6 +103,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_cont } } +bool IRAM_ATTR modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_apb_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_80m_clock_is_enabled(hal->syscon_dev); +} + void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable) { if (enable) { @@ -111,6 +117,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_con } } +bool IRAM_ATTR modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_cal_160m_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_160m_clock_is_enabled(hal->syscon_dev); +} + void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider) { modem_lpcon_ll_set_ble_rtc_timer_divisor_value(hal->lpcon_dev, divider); diff --git a/components/hal/esp32c61/include/hal/modem_lpcon_ll.h b/components/hal/esp32c61/include/hal/modem_lpcon_ll.h index 0383f03382c..28b0775e596 100644 --- a/components/hal/esp32c61/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32c61/include/hal/modem_lpcon_ll.h @@ -25,6 +25,12 @@ static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_test_clk_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_ble_rtc_timer_slow_osc(modem_lpcon_dev_t *hw, bool en) { @@ -163,6 +169,12 @@ static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool hw->clk_conf.clk_coex_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_coex_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_coex_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_ble_rtc_timer_clock(modem_lpcon_dev_t *hw, bool en) { diff --git a/components/hal/esp32c61/include/hal/modem_syscon_ll.h b/components/hal/esp32c61/include/hal/modem_syscon_ll.h index 6568b887ee5..753e4dbe27b 100644 --- a/components/hal/esp32c61/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32c61/include/hal/modem_syscon_ll.h @@ -11,6 +11,7 @@ #include #include #include "soc/soc.h" +#include "soc/soc_caps.h" #include "hal/assert.h" #include "modem/modem_syscon_struct.h" #include "hal/modem_clock_types.h" @@ -25,12 +26,24 @@ static inline void modem_syscon_ll_enable_test_clk(modem_syscon_dev_t *hw, bool hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_test_clk_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_pwdet_sar_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.pwdet_sar_clock_ena = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_pwdet_sar_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.pwdet_sar_clock_ena; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_set_pwdet_clk_div_num(modem_syscon_dev_t *hw, uint32_t div) { @@ -61,24 +74,48 @@ static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t hw->clk_conf.clk_data_dump_mux = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_mux_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_mux; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_etm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_etm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_etm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zbmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zbmac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw, bool en) { @@ -89,18 +126,40 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_modem_sec_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_modem_sec_en && + hw->clk_conf.clk_modem_sec_ecb_en && + hw->clk_conf.clk_modem_sec_ccm_en && + hw->clk_conf.clk_modem_sec_bah_en && + hw->clk_conf.clk_modem_sec_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_ble_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ble_timer_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_ble_timer_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_data_dump_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_force_clock(modem_syscon_dev_t *hw) { @@ -346,6 +405,16 @@ static inline void modem_syscon_ll_clk_wifibb_configure(modem_syscon_dev_t *hw, #endif } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifibb_clock_is_enabled(modem_syscon_dev_t *hw) +{ +#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT + return (hw->clk_conf1.val & 0x1fb) == 0x1fb; +#else + return (hw->clk_conf1.val & 0x1ff) == 0x1ff; +#endif +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifibb_22m_clock(modem_syscon_dev_t *hw, bool en) { @@ -364,6 +433,12 @@ static inline void modem_syscon_ll_enable_wifibb_44m_clock(modem_syscon_dev_t *h hw->clk_conf1.clk_wifibb_44m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifibb_44m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifibb_44m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifibb_80m_clock(modem_syscon_dev_t *hw, bool en) { @@ -413,12 +488,24 @@ static inline void modem_syscon_ll_enable_wifi_mac_clock(modem_syscon_dev_t *hw, hw->clk_conf1.clk_wifimac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifi_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifimac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_wifi_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_wifi_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_wifi_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_wifi_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_20m_clock(modem_syscon_dev_t *hw, bool en) { @@ -437,18 +524,36 @@ static inline void modem_syscon_ll_enable_fe_80m_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_80m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_80m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_80m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_160m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_160m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_160m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_160m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_apb_en; +} + // The modem_syscon of esp32c5 adds the enablement of the adc clock on the analog front end compared to esp32h2 and esp32c6. __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, bool en) @@ -456,6 +561,12 @@ static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_adc_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_adc_en; +} + // The modem_syscon of esp32c5 adds the enablement of the dac clock on the analog front end compared to esp32h2 and esp32c6. __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_dac_clock(modem_syscon_dev_t *hw, bool en) @@ -463,6 +574,12 @@ static inline void modem_syscon_ll_enable_fe_dac_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_dac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_dac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_dac_en; +} + // The modem_syscon of esp32c5 adds the enablement of the analog power detect clock on the analog front end compared to esp32h2 and esp32c6. __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_pwdet_clock(modem_syscon_dev_t *hw, bool en) @@ -470,24 +587,48 @@ static inline void modem_syscon_ll_enable_fe_pwdet_clock(modem_syscon_dev_t *hw, hw->clk_conf1.clk_fe_pwdet_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_pwdet_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_pwdet_adc_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_btmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_btmac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_btbb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_btbb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_480m_clock(modem_syscon_dev_t *hw, bool en) { diff --git a/components/hal/esp32c61/modem_clock_hal.c b/components/hal/esp32c61/modem_clock_hal.c index 9ff15d06af2..6e49bab4b84 100644 --- a/components/hal/esp32c61/modem_clock_hal.c +++ b/components/hal/esp32c61/modem_clock_hal.c @@ -103,6 +103,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_cont } } +bool IRAM_ATTR modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_apb_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_80m_clock_is_enabled(hal->syscon_dev); +} + void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable) { if (enable) { @@ -113,6 +119,14 @@ void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_con } } +bool IRAM_ATTR modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_160m_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_adc_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_dac_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_pwdet_clock_is_enabled(hal->syscon_dev); +} + void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider) { modem_lpcon_ll_set_ble_rtc_timer_divisor_value(hal->lpcon_dev, divider); diff --git a/components/hal/esp32h2/include/hal/modem_lpcon_ll.h b/components/hal/esp32h2/include/hal/modem_lpcon_ll.h index f678bd84d04..91baf45a3f5 100644 --- a/components/hal/esp32h2/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32h2/include/hal/modem_lpcon_ll.h @@ -25,6 +25,12 @@ static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_test_clk_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_lpclk_slow_osc(modem_lpcon_dev_t *hw, bool en) { @@ -67,12 +73,24 @@ static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool hw->clk_conf.clk_coex_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_coex_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_coex_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_fe_mem_clock(modem_lpcon_dev_t *hw, bool en) { hw->clk_conf.clk_fe_mem_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_fe_mem_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_fe_mem_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_force_clock(modem_lpcon_dev_t *hw, bool en) { diff --git a/components/hal/esp32h2/include/hal/modem_syscon_ll.h b/components/hal/esp32h2/include/hal/modem_syscon_ll.h index 1a29054dac2..3c5606d0057 100644 --- a/components/hal/esp32h2/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32h2/include/hal/modem_syscon_ll.h @@ -25,6 +25,12 @@ static inline void modem_syscon_ll_enable_test_clk(modem_syscon_dev_t *hw, bool hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_test_clk_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t *hw, bool en) @@ -32,24 +38,48 @@ static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t // ESP32H2 Not Support } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_mux_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return true; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_etm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_etm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_etm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_mac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_mac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw, bool en) { @@ -60,6 +90,16 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_modem_sec_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_modem_sec_en && + hw->clk_conf.clk_modem_sec_ecb_en && + hw->clk_conf.clk_modem_sec_ccm_en && + hw->clk_conf.clk_modem_sec_bah_en && + hw->clk_conf.clk_modem_sec_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw, bool en) { @@ -67,12 +107,25 @@ static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_ble_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ble_timer_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_ble_timer_apb_en && + hw->clk_conf.clk_ble_timer_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_data_dump_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_force_clock(modem_syscon_dev_t *hw) { @@ -203,12 +256,23 @@ static inline void modem_syscon_ll_enable_fe_16m_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_16m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_16m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_16m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_32m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_32m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_32m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_32m_en; +} __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_sdm_clock(modem_syscon_dev_t *hw, bool en) @@ -216,27 +280,58 @@ static inline void modem_syscon_ll_enable_fe_sdm_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_sdm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_sdm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_sdm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_adc_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_adc_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_mac_clock(modem_syscon_dev_t *hw, bool en) { + // ESP32H2 Not Support +} + +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return true; } __attribute__((always_inline)) @@ -245,6 +340,12 @@ static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool hw->clk_conf1.clk_bt_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_force_clock(modem_syscon_dev_t *hw, bool en) { diff --git a/components/hal/esp32h2/modem_clock_hal.c b/components/hal/esp32h2/modem_clock_hal.c index 2ae3b62352f..ac32fb798d0 100644 --- a/components/hal/esp32h2/modem_clock_hal.c +++ b/components/hal/esp32h2/modem_clock_hal.c @@ -19,6 +19,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_cont modem_syscon_ll_enable_fe_32m_clock(hal->syscon_dev, enable); } +bool IRAM_ATTR modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_apb_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_32m_clock_is_enabled(hal->syscon_dev); +} + void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable) { modem_lpcon_ll_enable_fe_mem_clock(hal->lpcon_dev, enable); @@ -27,6 +33,14 @@ void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_con modem_syscon_ll_enable_fe_16m_clock(hal->syscon_dev, enable); } +bool IRAM_ATTR modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_lpcon_ll_fe_mem_clock_is_enabled(hal->lpcon_dev) && + modem_syscon_ll_fe_sdm_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_adc_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_16m_clock_is_enabled(hal->syscon_dev); +} + void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider) { lp_clkrst_ll_set_ble_rtc_timer_divisor_value(&LP_CLKRST, divider); diff --git a/components/hal/esp32h21/include/hal/modem_lpcon_ll.h b/components/hal/esp32h21/include/hal/modem_lpcon_ll.h index 6d428d39a3b..0d501c99b75 100644 --- a/components/hal/esp32h21/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32h21/include/hal/modem_lpcon_ll.h @@ -25,6 +25,12 @@ static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_test_clk_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_lpclk_slow_osc(modem_lpcon_dev_t *hw, bool en) { @@ -67,12 +73,24 @@ static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool hw->clk_conf.clk_coex_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_coex_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_coex_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_fe_mem_clock(modem_lpcon_dev_t *hw, bool en) { hw->clk_conf.clk_fe_mem_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_fe_mem_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_fe_mem_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_force_clock(modem_lpcon_dev_t *hw, bool en) { diff --git a/components/hal/esp32h21/include/hal/modem_syscon_ll.h b/components/hal/esp32h21/include/hal/modem_syscon_ll.h index c322c2018a4..1d15f3d1cc5 100644 --- a/components/hal/esp32h21/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32h21/include/hal/modem_syscon_ll.h @@ -25,6 +25,12 @@ static inline void modem_syscon_ll_enable_test_clk(modem_syscon_dev_t *hw, bool hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_test_clk_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t *hw, bool en) @@ -32,24 +38,49 @@ static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t // ESP32-H21 Not Support } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_mux_clock_is_enabled(modem_syscon_dev_t *hw) +{ + // ESP32-H21 Not Support + return true; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_etm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_etm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_etm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_mac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_mac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw, bool en) { @@ -60,6 +91,16 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_modem_sec_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_modem_sec_en && + hw->clk_conf.clk_modem_sec_ecb_en && + hw->clk_conf.clk_modem_sec_ccm_en && + hw->clk_conf.clk_modem_sec_bah_en && + hw->clk_conf.clk_modem_sec_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw, bool en) { @@ -67,12 +108,25 @@ static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_ble_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ble_timer_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_ble_timer_apb_en && + hw->clk_conf.clk_ble_timer_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_data_dump_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_force_clock(modem_syscon_dev_t *hw) { @@ -204,18 +258,35 @@ static inline void modem_syscon_ll_enable_fe_txlogain_clock(modem_syscon_dev_t * hw->clk_conf1.clk_fe_txlogain_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_txlogain_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_txlogain_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_16m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_16m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_16m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_16m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_32m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_32m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_32m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_32m_en; +} __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_sdm_clock(modem_syscon_dev_t *hw, bool en) @@ -223,35 +294,71 @@ static inline void modem_syscon_ll_enable_fe_sdm_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_sdm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_sdm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_sdm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_adc_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_adc_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_mac_clock(modem_syscon_dev_t *hw, bool en) { } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return true; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_force_clock(modem_syscon_dev_t *hw, bool en) { diff --git a/components/hal/esp32h21/modem_clock_hal.c b/components/hal/esp32h21/modem_clock_hal.c index bd8e750646d..1d276031852 100644 --- a/components/hal/esp32h21/modem_clock_hal.c +++ b/components/hal/esp32h21/modem_clock_hal.c @@ -19,6 +19,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_cont modem_syscon_ll_enable_fe_32m_clock(hal->syscon_dev, enable); } +bool IRAM_ATTR modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_apb_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_32m_clock_is_enabled(hal->syscon_dev); +} + void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable) { modem_lpcon_ll_enable_fe_mem_clock(hal->lpcon_dev, enable); @@ -28,6 +34,15 @@ void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_con modem_syscon_ll_enable_fe_16m_clock(hal->syscon_dev, enable); } +bool IRAM_ATTR modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_lpcon_ll_fe_mem_clock_is_enabled(hal->lpcon_dev) && + modem_syscon_ll_fe_sdm_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_adc_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_txlogain_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_16m_clock_is_enabled(hal->syscon_dev); +} + void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider) { lp_clkrst_ll_set_ble_rtc_timer_divisor_value(&LP_CLKRST, divider); diff --git a/components/hal/esp32h4/include/hal/modem_lpcon_ll.h b/components/hal/esp32h4/include/hal/modem_lpcon_ll.h index 0a09a3c241c..adbf14e1245 100644 --- a/components/hal/esp32h4/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32h4/include/hal/modem_lpcon_ll.h @@ -25,6 +25,12 @@ static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_test_clk_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_lpclk_slow_osc(modem_lpcon_dev_t *hw, bool en) { @@ -67,11 +73,23 @@ static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool hw->clk_conf.clk_coex_en = en; } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_coex_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return hw->clk_conf.clk_coex_en; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_fe_mem_clock(modem_lpcon_dev_t *hw, bool en) { } +__attribute__((always_inline)) +static inline bool modem_lpcon_ll_fe_mem_clock_is_enabled(modem_lpcon_dev_t *hw) +{ + return true; +} + __attribute__((always_inline)) static inline void modem_lpcon_ll_enable_coex_force_clock(modem_lpcon_dev_t *hw, bool en) { diff --git a/components/hal/esp32h4/include/hal/modem_syscon_ll.h b/components/hal/esp32h4/include/hal/modem_syscon_ll.h index a6083dc0de3..68bd9f97045 100644 --- a/components/hal/esp32h4/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32h4/include/hal/modem_syscon_ll.h @@ -25,12 +25,24 @@ static inline void modem_syscon_ll_enable_test_clk(modem_syscon_dev_t *hw, bool hw->test_conf.clk_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_test_clk_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->test_conf.clk_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_pwdet_sar_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.pwdet_sar_clock_ena = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_pwdet_sar_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.pwdet_sar_clock_ena; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_set_pwdet_clk_div_num(modem_syscon_dev_t *hw, uint32_t div) { @@ -61,24 +73,48 @@ static inline void modem_syscon_ll_enable_data_dump_mux_clock(modem_syscon_dev_t hw->clk_conf.clk_data_dump_mux = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_mux_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_mux; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_etm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_etm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_etm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zb_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zb_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ieee802154_mac_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_zbmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ieee802154_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_zbmac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw, bool en) { @@ -89,18 +125,40 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw hw->clk_conf.clk_modem_sec_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_modem_sec_en && + hw->clk_conf.clk_modem_sec_ecb_en && + hw->clk_conf.clk_modem_sec_ccm_en && + hw->clk_conf.clk_modem_sec_bah_en && + hw->clk_conf.clk_modem_sec_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_ble_timer_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_ble_timer_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_ble_timer_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_ble_timer_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_data_dump_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf.clk_data_dump_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_data_dump_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf.clk_data_dump_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_etm_force_clock(modem_syscon_dev_t *hw) { @@ -304,18 +362,36 @@ static inline void modem_syscon_ll_enable_fe_txlogain_clock(modem_syscon_dev_t * hw->clk_conf1.clk_fe_txlogain_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_txlogain_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_txlogain_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_16m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_16m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_16m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_16m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_32m_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_32m_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_32m_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_32m_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_sdm_clock(modem_syscon_dev_t *hw, bool en) @@ -323,24 +399,48 @@ static inline void modem_syscon_ll_enable_fe_sdm_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_fe_sdm_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_sdm_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_sdm_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_adc_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_adc_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_adc_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_adc_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_fe_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_fe_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_fe_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_fe_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_apb_clock(modem_syscon_dev_t *hw, bool en) { hw->clk_conf1.clk_bt_apb_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_apb_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_bb_clock(modem_syscon_dev_t *hw, bool en) { @@ -353,6 +453,12 @@ static inline void modem_syscon_ll_enable_bt_mac_clock(modem_syscon_dev_t *hw, b hw->clk_conf1.clk_btmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_btmac_en; +} + __attribute__((always_inline)) static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool en) { @@ -361,6 +467,14 @@ static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool hw->clk_conf1.clk_btmac_en = en; } +__attribute__((always_inline)) +static inline bool modem_syscon_ll_bt_clock_is_enabled(modem_syscon_dev_t *hw) +{ + return hw->clk_conf1.clk_bt_apb_en && + hw->clk_conf1.clk_btbb_en && + hw->clk_conf1.clk_btmac_en; +} + __attribute__((always_inline)) static inline uint32_t modem_syscon_ll_get_date(modem_syscon_dev_t *hw) { diff --git a/components/hal/esp32h4/modem_clock_hal.c b/components/hal/esp32h4/modem_clock_hal.c index bc1a70861ce..37932652e81 100644 --- a/components/hal/esp32h4/modem_clock_hal.c +++ b/components/hal/esp32h4/modem_clock_hal.c @@ -95,6 +95,12 @@ void IRAM_ATTR modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_cont modem_syscon_ll_enable_fe_32m_clock(hal->syscon_dev, enable); } +bool IRAM_ATTR modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_syscon_ll_fe_apb_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_32m_clock_is_enabled(hal->syscon_dev); +} + void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable) { modem_lpcon_ll_enable_fe_mem_clock(hal->lpcon_dev, enable); @@ -103,6 +109,14 @@ void IRAM_ATTR modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_con modem_syscon_ll_enable_fe_16m_clock(hal->syscon_dev, enable); } +bool IRAM_ATTR modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal) +{ + return modem_lpcon_ll_fe_mem_clock_is_enabled(hal->lpcon_dev) && + modem_syscon_ll_fe_sdm_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_adc_clock_is_enabled(hal->syscon_dev) && + modem_syscon_ll_fe_16m_clock_is_enabled(hal->syscon_dev); +} + void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider) { lp_clkrst_ll_set_ble_rtc_timer_divisor_value(&LP_CLKRST, divider); diff --git a/components/hal/include/hal/modem_clock_hal.h b/components/hal/include/hal/modem_clock_hal.h index e5dfd7dcf56..1e17817e9f3 100644 --- a/components/hal/include/hal/modem_clock_hal.h +++ b/components/hal/include/hal/modem_clock_hal.h @@ -30,7 +30,9 @@ uint32_t modem_clock_hal_get_clock_domain_icg_bitmap(modem_clock_hal_context_t * #endif void modem_clock_hal_enable_modem_common_fe_clock(modem_clock_hal_context_t *hal, bool enable); +bool modem_clock_hal_modem_common_fe_clock_is_enabled(modem_clock_hal_context_t *hal); void modem_clock_hal_enable_modem_private_fe_clock(modem_clock_hal_context_t *hal, bool enable); +bool modem_clock_hal_modem_private_fe_clock_is_enabled(modem_clock_hal_context_t *hal); #if SOC_BT_SUPPORTED void modem_clock_hal_set_ble_rtc_timer_divisor_value(modem_clock_hal_context_t *hal, uint32_t divider);