mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'feat/optimize_for_esp32h4_light_sleep_ble_current_v6.1_new_chip_only' into 'release/v6.1'
Feat/optimize for esp32h4 light sleep ble current v6.1 new chip only See merge request espressif/esp-idf!51302
This commit is contained in:
Submodule components/bt/controller/lib_esp32h4/esp32h4-bt-lib updated: 2b03d4afe9...f4ce5d581a
Submodule components/bt/controller/lib_esp32s31/esp32s31-bt-lib updated: 4c572fb783...f4f26856d7
@@ -10,6 +10,24 @@ entries:
|
||||
entries:
|
||||
.adv_fast_execute_code_iram1+
|
||||
|
||||
[sections:sleep_text]
|
||||
entries:
|
||||
.iram_sleep+
|
||||
.iram_btslp+
|
||||
|
||||
[sections:sleep_text_adv]
|
||||
entries:
|
||||
.iram_sleep_adv+
|
||||
|
||||
[sections:sleep_text_conn]
|
||||
entries:
|
||||
.iram_sleep_conn+
|
||||
|
||||
[sections:sleep_single_sleep]
|
||||
entries:
|
||||
.iram_single_sleep+
|
||||
|
||||
|
||||
[scheme:bt_default]
|
||||
entries:
|
||||
bt_bss -> dram0_bss
|
||||
@@ -27,6 +45,26 @@ entries:
|
||||
else:
|
||||
adv_fast_execute_code_iram_text -> flash_text
|
||||
|
||||
if BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM = y:
|
||||
sleep_text -> iram0_text
|
||||
else:
|
||||
sleep_text -> flash_text
|
||||
|
||||
if BT_CTRL_LE_ADV_SLEEP_CODE_IN_IRAM = y:
|
||||
sleep_text_adv->iram0_text
|
||||
else:
|
||||
sleep_text_adv->flash_text
|
||||
|
||||
if BT_CTRL_LE_CONN_SLEEP_CODE_IN_IRAM = y:
|
||||
sleep_text_conn->iram0_text
|
||||
else:
|
||||
sleep_text_conn->flash_text
|
||||
|
||||
if BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM = y || BT_CTRL_RUN_IN_FLASH_ONLY = n:
|
||||
sleep_single_sleep->iram0_text
|
||||
else:
|
||||
sleep_single_sleep->flash_text
|
||||
|
||||
# For the following fragments, order matters for
|
||||
# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates:
|
||||
#
|
||||
|
||||
@@ -10,6 +10,23 @@ entries:
|
||||
entries:
|
||||
.adv_fast_execute_code_iram1+
|
||||
|
||||
[sections:sleep_text]
|
||||
entries:
|
||||
.iram_sleep+
|
||||
.iram_btslp+
|
||||
|
||||
[sections:sleep_text_adv]
|
||||
entries:
|
||||
.iram_sleep_adv+
|
||||
|
||||
[sections:sleep_text_conn]
|
||||
entries:
|
||||
.iram_sleep_conn+
|
||||
|
||||
[sections:sleep_single_sleep]
|
||||
entries:
|
||||
.iram_single_sleep+
|
||||
|
||||
[scheme:bt_default]
|
||||
entries:
|
||||
bt_bss -> dram0_bss
|
||||
@@ -27,6 +44,26 @@ entries:
|
||||
else:
|
||||
adv_fast_execute_code_iram_text -> flash_text
|
||||
|
||||
if BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM = y:
|
||||
sleep_text -> iram0_text
|
||||
else:
|
||||
sleep_text -> flash_text
|
||||
|
||||
if BT_CTRL_LE_ADV_SLEEP_CODE_IN_IRAM = y:
|
||||
sleep_text_adv->iram0_text
|
||||
else:
|
||||
sleep_text_adv->flash_text
|
||||
|
||||
if BT_CTRL_LE_CONN_SLEEP_CODE_IN_IRAM = y:
|
||||
sleep_text_conn->iram0_text
|
||||
else:
|
||||
sleep_text_conn->flash_text
|
||||
|
||||
if BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM = y || BT_CTRL_RUN_IN_FLASH_ONLY = n:
|
||||
sleep_single_sleep->iram0_text
|
||||
else:
|
||||
sleep_single_sleep->flash_text
|
||||
|
||||
# For the following fragments, order matters for
|
||||
# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates:
|
||||
#
|
||||
|
||||
@@ -27,7 +27,7 @@ config BT_CTRL_TASK_STACK_SIZE
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
config BT_CTRL_SLEEP_ENABLE
|
||||
menuconfig BT_CTRL_SLEEP_ENABLE
|
||||
bool "Enable Bluetooth Controller sleep"
|
||||
default n
|
||||
help
|
||||
@@ -55,6 +55,30 @@ choice BT_CTRL_LP_CLK_SRC
|
||||
|
||||
endchoice
|
||||
|
||||
config BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM
|
||||
bool "Put sleep related code into IRAM to optimize power consumption"
|
||||
default n
|
||||
depends on BT_CTRL_SLEEP_ENABLE
|
||||
help
|
||||
Put frequently-executed sleep functions into IRAM for faster execution
|
||||
and lower power consumption. Occupies extra 3 KB RAM.
|
||||
|
||||
config BT_CTRL_LE_ADV_SLEEP_CODE_IN_IRAM
|
||||
bool "Put BLE advertising sleep code into IRAM"
|
||||
default y
|
||||
depends on BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM && BT_CTRL_BLE_ENABLE
|
||||
help
|
||||
Put frequently-executed advertising functions into IRAM.
|
||||
Occupies extra 8 KB RAM.
|
||||
|
||||
config BT_CTRL_LE_CONN_SLEEP_CODE_IN_IRAM
|
||||
bool "Put BLE connection sleep code into IRAM"
|
||||
default y
|
||||
depends on BT_CTRL_SLEEP_RELATED_CODE_IN_IRAM && BT_CTRL_BLE_ENABLE
|
||||
help
|
||||
Put frequently-executed connection functions into IRAM.
|
||||
Occupies extra 8 KB RAM.
|
||||
|
||||
config BT_DUAL_MODE_ARCH
|
||||
bool
|
||||
default y
|
||||
|
||||
@@ -37,15 +37,26 @@
|
||||
*/
|
||||
#define BTDM_LOG_TAG "BTDM_SLEEP"
|
||||
|
||||
#define BTDM_RTC_DELAY_US_LIGHT_SLEEP (2000)
|
||||
#define BTDM_RTC_DELAY_US_LIGHT_SLEEP (1800)
|
||||
#define BTDM_RTC_DELAY_US_MODEM_SLEEP (1500)
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t rsv:31;
|
||||
uint32_t bt_wakeup:1;
|
||||
};
|
||||
uint32_t val;
|
||||
} btdm_lp_wakeup_params_t;
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* External Functions
|
||||
***************************************************************************************************
|
||||
*/
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#if UC_BT_CTRL_SLEEP_ENABLE
|
||||
static bool btdm_lp_check_wakeup_by_bt(void);
|
||||
#endif // UC_BT_CTRL_SLEEP_ENABLE
|
||||
extern bool r_btdm_sleep_should_skip_light_sleep_check(void);
|
||||
extern const sleep_retention_entries_config_t *r_btdm_mac_retention_link_get(uint8_t *size);
|
||||
extern void r_btdm_sleep_wake_up_overhead_set(uint32_t overhead);
|
||||
@@ -73,6 +84,7 @@ static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
static uint32_t s_bt_xtal_lpclk_freq = 100000;
|
||||
static uint32_t s_bt_lpclk_freq = 0;
|
||||
static uint8_t s_btdm_lp_modem_clk_en = 0;
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
@@ -197,6 +209,21 @@ btdm_lp_timer_clk_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
}
|
||||
|
||||
void IRAM_ATTR e_btdm_lp_modem_clock_set(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (!s_btdm_lp_modem_clk_en) {
|
||||
modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
s_btdm_lp_modem_clk_en = 1;
|
||||
}
|
||||
} else {
|
||||
if (!s_bt_active && s_btdm_lp_modem_clk_en) {
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
s_btdm_lp_modem_clk_en = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
btdm_lp_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
@@ -213,17 +240,33 @@ btdm_lp_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
void
|
||||
btdm_lp_wake_up_cb(void *arg)
|
||||
{
|
||||
btdm_lp_wakeup_params_t *params;
|
||||
|
||||
if (s_bt_active) {
|
||||
return;
|
||||
}
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
params = (btdm_lp_wakeup_params_t *)arg;
|
||||
if (params) {
|
||||
params->bt_wakeup = 0;
|
||||
}
|
||||
esp_phy_enable(PHY_MODEM_BT);
|
||||
#if UC_BT_CTRL_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
if (params) {
|
||||
params->bt_wakeup = btdm_lp_check_wakeup_by_bt();
|
||||
}
|
||||
#endif // UC_BT_CTRL_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
s_bt_active = true;
|
||||
}
|
||||
|
||||
#if UC_BT_CTRL_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static bool btdm_lp_check_wakeup_by_bt(void)
|
||||
{
|
||||
return (esp_sleep_get_wakeup_causes() & BIT(ESP_SLEEP_WAKEUP_BT));
|
||||
}
|
||||
|
||||
static esp_err_t
|
||||
btdm_lp_modem_retention_create(void)
|
||||
{
|
||||
@@ -307,7 +350,11 @@ btdm_lp_modem_state_deinit(void)
|
||||
void
|
||||
btdm_lp_enable_clock(esp_btdm_controller_config_t *cfg)
|
||||
{
|
||||
modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
if (!s_btdm_lp_modem_clk_en) {
|
||||
modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
s_btdm_lp_modem_clk_en = 1;
|
||||
}
|
||||
modem_clock_module_enable(PERIPH_BT_APB_MODULE);
|
||||
modem_clock_module_mac_reset(PERIPH_BT_MODULE);
|
||||
btdm_lp_timer_clk_init(cfg);
|
||||
}
|
||||
@@ -316,7 +363,11 @@ void
|
||||
btdm_lp_disable_clock(void)
|
||||
{
|
||||
btdm_lp_timer_clk_deinit();
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_APB_MODULE);
|
||||
if (s_btdm_lp_modem_clk_en) {
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
s_btdm_lp_modem_clk_en = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -69,6 +69,8 @@ typedef enum {
|
||||
MODEM_CLOCK_ETM,
|
||||
#if SOC_BT_SUPPORTED
|
||||
MODEM_CLOCK_BLE_MAC,
|
||||
MODEM_CLOCK_BT_PERIPHERAL,
|
||||
MODEM_CLOCK_BT_APB,
|
||||
#endif
|
||||
#if SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED
|
||||
MODEM_CLOCK_BT_I154_COMMON_BB,
|
||||
|
||||
@@ -11,14 +11,15 @@
|
||||
#include "esp_private/regi2c_ctrl.h"
|
||||
|
||||
/* Clock dependency definitions */
|
||||
#define BLE_CLOCK_DEPS ( MODEM_CLOCKS( BLE_MAC, BT_I154_COMMON_BB, ETM, COEXIST ) )
|
||||
#define IEEE802154_CLOCK_DEPS ( MODEM_CLOCKS( 802154_MAC, BT_I154_COMMON_BB, ETM, COEXIST ) )
|
||||
#define BT_APB_CLOCK_DEPS ( MODEM_CLOCKS( BT_APB, ETM ) )
|
||||
#define BLE_CLOCK_DEPS ( MODEM_CLOCKS( BLE_MAC, BT_I154_COMMON_BB, ETM, COEXIST, BT_APB, BT_PERIPHERAL ) )
|
||||
#define IEEE802154_CLOCK_DEPS ( MODEM_CLOCKS( 802154_MAC, BT_I154_COMMON_BB, ETM, COEXIST, BT_APB ) )
|
||||
#define COEXIST_CLOCK_DEPS ( MODEM_CLOCKS( COEXIST ) )
|
||||
#define I2C_ANA_MST_CLOCK_DEPS ( MODEM_CLOCKS( I2C_MASTER ) )
|
||||
#define PHY_CLOCK_DEPS ( MODEM_CLOCKS( MODEM_ADC_COMMON_FE, MODEM_PRIVATE_FE ) | I2C_ANA_MST_CLOCK_DEPS )
|
||||
#define MODEM_ETM_CLOCK_DEPS ( MODEM_CLOCKS( ETM ) )
|
||||
#define MODEM_ADC_COMMON_FE_CLOCK_DEPS ( MODEM_CLOCKS( MODEM_ADC_COMMON_FE ) )
|
||||
#define PHY_CALIBRATION_BT_I154_CLOCK_DEPS ( MODEM_CLOCKS( BT_I154_COMMON_BB ) )
|
||||
#define PHY_CALIBRATION_BT_I154_CLOCK_DEPS ( MODEM_CLOCKS( BT_I154_COMMON_BB, BT_APB ) )
|
||||
#define PHY_CALIBRATION_WIFI_CLOCK_DEPS ( 0 )
|
||||
#if !defined(SOC_BT_SUPPORTED) && !defined(SOC_IEEE802154_SUPPORTED)
|
||||
#undef PHY_CALIBRATION_BT_I154_CLOCK_DEPS
|
||||
@@ -38,6 +39,7 @@ uint32_t IRAM_ATTR modem_clock_get_module_deps(shared_periph_module_t module)
|
||||
case PERIPH_PHY_CALIBRATION_MODULE: deps = PHY_CALIBRATION_CLOCK_DEPS; break;
|
||||
case PERIPH_IEEE802154_MODULE: deps = IEEE802154_CLOCK_DEPS; break;
|
||||
case PERIPH_MODEM_ETM_MODULE: deps = MODEM_ETM_CLOCK_DEPS; break;
|
||||
case PERIPH_BT_APB_MODULE: deps = BT_APB_CLOCK_DEPS; break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -47,34 +49,56 @@ uint32_t IRAM_ATTR modem_clock_get_module_deps(shared_periph_module_t module)
|
||||
static void IRAM_ATTR modem_clock_ble_mac_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
modem_syscon_ll_enable_bt_mac_clock(ctx->hal->syscon_dev, enable);
|
||||
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)
|
||||
{
|
||||
return modem_syscon_ll_bt_mac_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void IRAM_ATTR modem_clock_bt_peripheral_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
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_bt_peripheral_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
|
||||
|
||||
static void IRAM_ATTR modem_clock_ble_i154_bb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
static void IRAM_ATTR modem_clock_bt_apb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
modem_syscon_ll_enable_bt_apb_clock(ctx->hal->syscon_dev, enable);
|
||||
modem_syscon_ll_enable_bt_clock(ctx->hal->syscon_dev, enable);
|
||||
modem_syscon_ll_enable_modem_sec_apb_clock(ctx->hal->syscon_dev, enable);
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING
|
||||
static esp_err_t IRAM_ATTR modem_clock_bt_apb_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_modem_sec_apb_clock_is_enabled(ctx->hal->syscon_dev);
|
||||
return all_clock_enabled ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void IRAM_ATTR modem_clock_ble_i154_bb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
modem_syscon_ll_enable_bt_bb_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;
|
||||
return modem_syscon_ll_bt_bb_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -177,6 +201,8 @@ static void IRAM_ATTR modem_clock_configure_impl(modem_clock_context_t *ctx, int
|
||||
: (dev_id == MODEM_CLOCK_I2C_MASTER) ? modem_clock_i2c_master_configure
|
||||
: (dev_id == MODEM_CLOCK_ETM) ? modem_clock_etm_configure
|
||||
: (dev_id == MODEM_CLOCK_BLE_MAC) ? modem_clock_ble_mac_configure
|
||||
: (dev_id == MODEM_CLOCK_BT_PERIPHERAL) ? modem_clock_bt_peripheral_configure
|
||||
: (dev_id == MODEM_CLOCK_BT_APB) ? modem_clock_bt_apb_configure
|
||||
: (dev_id == MODEM_CLOCK_BT_I154_COMMON_BB) ? modem_clock_ble_i154_bb_configure
|
||||
: (dev_id == MODEM_CLOCK_802154_MAC) ? modem_clock_ieee802154_mac_configure
|
||||
: (dev_id == MODEM_CLOCK_DATADUMP) ? modem_clock_data_dump_configure
|
||||
@@ -197,6 +223,8 @@ static esp_err_t IRAM_ATTR modem_clock_check_impl(modem_clock_context_t *ctx, in
|
||||
: (dev_id == MODEM_CLOCK_I2C_MASTER) ? modem_clock_i2c_master_check_enable
|
||||
: (dev_id == MODEM_CLOCK_ETM) ? modem_clock_etm_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BLE_MAC) ? modem_clock_ble_mac_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BT_PERIPHERAL) ? modem_clock_bt_peripheral_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BT_APB) ? modem_clock_bt_apb_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BT_I154_COMMON_BB) ? modem_clock_ble_i154_bb_check_enable
|
||||
: (dev_id == MODEM_CLOCK_802154_MAC) ? modem_clock_ieee802154_mac_check_enable
|
||||
: (dev_id == MODEM_CLOCK_DATADUMP) ? modem_clock_data_dump_check_enable
|
||||
|
||||
@@ -12,15 +12,16 @@
|
||||
|
||||
/* Clock dependency definitions */
|
||||
#define WIFI_CLOCK_DEPS ( MODEM_CLOCKS( WIFI_MAC, WIFI_APB, WIFI_BB, WIFI_BB_44M, COEXIST, WIFI_BB_80X1, SOC_PLL_SOURCE_CG ) )
|
||||
#define BLE_CLOCK_DEPS ( MODEM_CLOCKS( BLE_MAC, BT_I154_COMMON_BB, ETM, COEXIST, WIFI_BB_80X1, SOC_PLL_SOURCE_CG ) )
|
||||
#define IEEE802154_CLOCK_DEPS ( MODEM_CLOCKS( 802154_MAC, BT_I154_COMMON_BB, ETM, COEXIST, WIFI_BB_80X1, SOC_PLL_SOURCE_CG ) )
|
||||
#define BLE_CLOCK_DEPS ( MODEM_CLOCKS( BLE_MAC, BT_I154_COMMON_BB, ETM, COEXIST, WIFI_BB_80X1, SOC_PLL_SOURCE_CG, BT_APB, BT_PERIPHERAL ) )
|
||||
#define BT_APB_CLOCK_DEPS ( MODEM_CLOCKS( BT_APB, ETM, SOC_PLL_SOURCE_CG, BLE_MAC ) )
|
||||
#define IEEE802154_CLOCK_DEPS ( MODEM_CLOCKS( 802154_MAC, BT_I154_COMMON_BB, ETM, COEXIST, WIFI_BB_80X1, SOC_PLL_SOURCE_CG, BT_APB ) )
|
||||
#define COEXIST_CLOCK_DEPS ( MODEM_CLOCKS( COEXIST, SOC_PLL_SOURCE_CG ) )
|
||||
#define I2C_ANA_MST_CLOCK_DEPS ( MODEM_CLOCKS( I2C_MASTER ) )
|
||||
#define PHY_CLOCK_DEPS ( MODEM_CLOCKS( MODEM_ADC_COMMON_FE, MODEM_PRIVATE_FE, SOC_PLL_SOURCE_CG ) | I2C_ANA_MST_CLOCK_DEPS )
|
||||
#define MODEM_ETM_CLOCK_DEPS ( MODEM_CLOCKS( ETM ) )
|
||||
#define MODEM_ADC_COMMON_FE_CLOCK_DEPS ( MODEM_CLOCKS( MODEM_ADC_COMMON_FE, SOC_PLL_SOURCE_CG ) )
|
||||
#define PHY_CALIBRATION_WIFI_CLOCK_DEPS ( MODEM_CLOCKS( WIFI_APB, WIFI_BB, WIFI_BB_44M, WIFI_BB_80X1, SOC_PLL_SOURCE_CG ) )
|
||||
#define PHY_CALIBRATION_BT_I154_CLOCK_DEPS ( MODEM_CLOCKS( WIFI_APB, WIFI_BB_44M, BT_I154_COMMON_BB, SOC_PLL_SOURCE_CG ) )
|
||||
#define PHY_CALIBRATION_BT_I154_CLOCK_DEPS ( MODEM_CLOCKS( WIFI_APB, WIFI_BB_44M, BT_I154_COMMON_BB, SOC_PLL_SOURCE_CG, BT_APB ) )
|
||||
#define PHY_CALIBRATION_CLOCK_DEPS ( PHY_CALIBRATION_WIFI_CLOCK_DEPS | PHY_CALIBRATION_BT_I154_CLOCK_DEPS )
|
||||
|
||||
|
||||
@@ -45,6 +46,7 @@ uint32_t IRAM_ATTR modem_clock_get_module_deps(shared_periph_module_t module)
|
||||
case PERIPH_IEEE802154_MODULE: deps = IEEE802154_CLOCK_DEPS; break;
|
||||
#endif
|
||||
case PERIPH_MODEM_ETM_MODULE: deps = MODEM_ETM_CLOCK_DEPS; break;
|
||||
case PERIPH_BT_APB_MODULE: deps = BT_APB_CLOCK_DEPS; break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -100,15 +102,25 @@ static esp_err_t IRAM_ATTR modem_clock_wifi_bb_80x1_check_enable(modem_clock_con
|
||||
static void IRAM_ATTR modem_clock_ble_mac_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
modem_syscon_ll_enable_bt_mac_clock(ctx->hal->syscon_dev, enable);
|
||||
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)
|
||||
{
|
||||
return modem_syscon_ll_bt_mac_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void IRAM_ATTR modem_clock_bt_peripheral_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
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_bt_peripheral_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;
|
||||
@@ -116,6 +128,22 @@ static esp_err_t IRAM_ATTR modem_clock_ble_mac_check_enable(modem_clock_context_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void IRAM_ATTR modem_clock_bt_apb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
modem_syscon_ll_enable_bt_apb_clock(ctx->hal->syscon_dev, enable);
|
||||
modem_syscon_ll_enable_modem_sec_apb_clock(ctx->hal->syscon_dev, enable);
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING
|
||||
static esp_err_t IRAM_ATTR modem_clock_bt_apb_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_modem_sec_apb_clock_is_enabled(ctx->hal->syscon_dev);
|
||||
return all_clock_enabled ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SOC_PHY_CALIBRATION_CLOCK_IS_INDEPENDENT
|
||||
static void IRAM_ATTR modem_clock_wifi_apb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
@@ -147,17 +175,13 @@ static esp_err_t IRAM_ATTR modem_clock_wifi_bb_44m_check_enable(modem_clock_cont
|
||||
#if SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED
|
||||
static void IRAM_ATTR modem_clock_ble_i154_bb_configure(modem_clock_context_t *ctx, bool enable)
|
||||
{
|
||||
modem_syscon_ll_enable_bt_apb_clock(ctx->hal->syscon_dev, enable);
|
||||
modem_syscon_ll_enable_bt_clock(ctx->hal->syscon_dev, enable);
|
||||
modem_syscon_ll_enable_bt_bb_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;
|
||||
return modem_syscon_ll_bt_bb_clock_is_enabled(ctx->hal->syscon_dev) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -286,6 +310,8 @@ static void IRAM_ATTR modem_clock_configure_impl(modem_clock_context_t *ctx, int
|
||||
: (dev_id == MODEM_CLOCK_ETM) ? modem_clock_etm_configure
|
||||
#if SOC_BT_SUPPORTED
|
||||
: (dev_id == MODEM_CLOCK_BLE_MAC) ? modem_clock_ble_mac_configure
|
||||
: (dev_id == MODEM_CLOCK_BT_PERIPHERAL) ? modem_clock_bt_peripheral_configure
|
||||
: (dev_id == MODEM_CLOCK_BT_APB) ? modem_clock_bt_apb_configure
|
||||
#endif
|
||||
#if SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED
|
||||
: (dev_id == MODEM_CLOCK_BT_I154_COMMON_BB) ? modem_clock_ble_i154_bb_configure
|
||||
@@ -317,6 +343,8 @@ static esp_err_t IRAM_ATTR modem_clock_check_impl(modem_clock_context_t *ctx, in
|
||||
: (dev_id == MODEM_CLOCK_WIFI_BB_80X1) ? modem_clock_wifi_bb_80x1_check_enable
|
||||
: (dev_id == MODEM_CLOCK_ETM) ? modem_clock_etm_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BLE_MAC) ? modem_clock_ble_mac_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BT_PERIPHERAL) ? modem_clock_bt_peripheral_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BT_APB) ? modem_clock_bt_apb_check_enable
|
||||
: (dev_id == MODEM_CLOCK_BT_I154_COMMON_BB) ? modem_clock_ble_i154_bb_check_enable
|
||||
: (dev_id == MODEM_CLOCK_802154_MAC) ? modem_clock_ieee802154_mac_check_enable
|
||||
: (dev_id == MODEM_CLOCK_DATADUMP) ? modem_clock_data_dump_check_enable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -122,7 +122,6 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw
|
||||
hw->clk_conf.clk_modem_sec_ecb_en = en;
|
||||
hw->clk_conf.clk_modem_sec_ccm_en = en;
|
||||
hw->clk_conf.clk_modem_sec_bah_en = en;
|
||||
hw->clk_conf.clk_modem_sec_apb_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
@@ -131,8 +130,19 @@ static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t
|
||||
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;
|
||||
hw->clk_conf.clk_modem_sec_bah_en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void modem_syscon_ll_enable_modem_sec_apb_clock(modem_syscon_dev_t *hw, bool en)
|
||||
{
|
||||
hw->clk_conf.clk_modem_sec_apb_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline bool modem_syscon_ll_modem_sec_apb_clock_is_enabled(modem_syscon_dev_t *hw)
|
||||
{
|
||||
return hw->clk_conf.clk_modem_sec_apb_en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
@@ -345,11 +355,10 @@ static inline void modem_syscon_ll_reset_all(modem_syscon_dev_t *hw)
|
||||
hw->modem_rst_conf.val = 0;
|
||||
}
|
||||
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void modem_syscon_ll_clk_conf1_configure(modem_syscon_dev_t *hw, bool en, uint32_t mask)
|
||||
{
|
||||
if(en){
|
||||
if (en) {
|
||||
hw->clk_conf1.val = hw->clk_conf1.val | mask;
|
||||
} else {
|
||||
hw->clk_conf1.val = hw->clk_conf1.val & ~mask;
|
||||
@@ -398,7 +407,6 @@ static inline bool modem_syscon_ll_fe_32m_clock_is_enabled(modem_syscon_dev_t *h
|
||||
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)
|
||||
{
|
||||
@@ -453,6 +461,12 @@ static inline void modem_syscon_ll_enable_bt_bb_clock(modem_syscon_dev_t *hw, bo
|
||||
hw->clk_conf1.clk_btbb_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline bool modem_syscon_ll_bt_bb_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_bt_mac_clock(modem_syscon_dev_t *hw, bool en)
|
||||
{
|
||||
@@ -465,22 +479,6 @@ static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *h
|
||||
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_bt_apb_en = en;
|
||||
hw->clk_conf1.clk_btbb_en = en;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -122,7 +122,6 @@ static inline void modem_syscon_ll_enable_modem_sec_clock(modem_syscon_dev_t *hw
|
||||
hw->clk_conf.clk_modem_sec_ecb_en = en;
|
||||
hw->clk_conf.clk_modem_sec_ccm_en = en;
|
||||
hw->clk_conf.clk_modem_sec_bah_en = en;
|
||||
hw->clk_conf.clk_modem_sec_apb_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
@@ -131,8 +130,19 @@ static inline bool modem_syscon_ll_modem_sec_clock_is_enabled(modem_syscon_dev_t
|
||||
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;
|
||||
hw->clk_conf.clk_modem_sec_bah_en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void modem_syscon_ll_enable_modem_sec_apb_clock(modem_syscon_dev_t *hw, bool en)
|
||||
{
|
||||
hw->clk_conf.clk_modem_sec_apb_en = en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline bool modem_syscon_ll_modem_sec_apb_clock_is_enabled(modem_syscon_dev_t *hw)
|
||||
{
|
||||
return hw->clk_conf.clk_modem_sec_apb_en;
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
@@ -610,13 +620,13 @@ static inline bool modem_syscon_ll_bt_mac_clock_is_enabled(modem_syscon_dev_t *h
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static inline void modem_syscon_ll_enable_bt_clock(modem_syscon_dev_t *hw, bool en)
|
||||
static inline void modem_syscon_ll_enable_bt_bb_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)
|
||||
static inline bool modem_syscon_ll_bt_bb_clock_is_enabled(modem_syscon_dev_t *hw)
|
||||
{
|
||||
return hw->clk_conf1.clk_btbb_en;
|
||||
}
|
||||
|
||||
@@ -27,12 +27,13 @@ typedef enum {
|
||||
PERIPH_MODEM_ETM_MODULE,
|
||||
PERIPH_MODEM_ADC_COMMON_FE_MODULE,
|
||||
PERIPH_PHY_CALIBRATION_MODULE,
|
||||
PERIPH_BT_APB_MODULE,
|
||||
PERIPH_MODULE_MAX
|
||||
/* !!! Don't append soc modules here !!! */
|
||||
} shared_periph_module_t;
|
||||
|
||||
#define PERIPH_MODEM_MODULE_MIN PERIPH_BT_MODULE
|
||||
#define PERIPH_MODEM_MODULE_MAX PERIPH_PHY_CALIBRATION_MODULE
|
||||
#define PERIPH_MODEM_MODULE_MAX PERIPH_BT_APB_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))
|
||||
|
||||
|
||||
@@ -29,11 +29,12 @@ typedef enum {
|
||||
PERIPH_MODEM_ETM_MODULE,
|
||||
PERIPH_MODEM_ADC_COMMON_FE_MODULE,
|
||||
PERIPH_PHY_CALIBRATION_MODULE,
|
||||
PERIPH_BT_APB_MODULE,
|
||||
PERIPH_MODULE_MAX
|
||||
} shared_periph_module_t;
|
||||
|
||||
#define PERIPH_MODEM_MODULE_MIN PERIPH_WIFI_MODULE
|
||||
#define PERIPH_MODEM_MODULE_MAX PERIPH_PHY_CALIBRATION_MODULE
|
||||
#define PERIPH_MODEM_MODULE_MAX PERIPH_BT_APB_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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user