Skip to content

Commit 2461b0c

Browse files
committed
Merge branch 'fix/reinit_c5_clk_tree_after_app_changed' into 'master'
feat(esp_hw_support): manage clock tree hw/sw coherence during CPU reset lazily See merge request espressif/esp-idf!39677
2 parents 52e8876 + 6124c8e commit 2461b0c

File tree

5 files changed

+88
-58
lines changed

5 files changed

+88
-58
lines changed

components/esp_hw_support/port/esp32c5/esp_clk_tree.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ uint32_t *freq_value)
7171
}
7272

7373
#define ENUM2ARRAY(clk_src) (clk_src - SOC_MOD_CLK_PLL_F12M)
74-
static __NOINIT_ATTR int16_t s_pll_src_cg_ref_cnt[9] = { 0 };
74+
static int16_t s_pll_src_cg_ref_cnt[9] = { 0 };
7575
static bool esp_clk_tree_initialized = false;
7676

7777
void esp_clk_tree_initialize(void)
@@ -82,8 +82,6 @@ void esp_clk_tree_initialize(void)
8282
|| (rst_reason == RESET_REASON_CPU0_JTAG) || (rst_reason == RESET_REASON_CPU0_LOCKUP)) {
8383
esp_clk_tree_initialized = true;
8484
return;
85-
} else {
86-
bzero(s_pll_src_cg_ref_cnt, sizeof(s_pll_src_cg_ref_cnt));
8785
}
8886

8987
soc_cpu_clk_src_t current_cpu_clk_src = clk_ll_cpu_get_src();
@@ -146,7 +144,10 @@ esp_err_t esp_clk_tree_enable_src(soc_module_clk_t clk_src, bool enable)
146144
if (!enable) {
147145
s_pll_src_cg_ref_cnt[ENUM2ARRAY(clk_src)]--;
148146
}
149-
assert(s_pll_src_cg_ref_cnt[ENUM2ARRAY(clk_src)] >= 0);
147+
if (s_pll_src_cg_ref_cnt[ENUM2ARRAY(clk_src)] < 0) {
148+
ESP_EARLY_LOGW(TAG, "soc_module_clk_t %d disabled multiple times!!", clk_src);
149+
s_pll_src_cg_ref_cnt[ENUM2ARRAY(clk_src)] = 0;
150+
}
150151
}
151152
return ESP_OK;
152153
}

components/esp_hw_support/port/esp32c5/include/soc/rtc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ void rtc_clk_cpu_freq_get_config(rtc_cpu_freq_config_t *out_config);
318318
*/
319319
void rtc_clk_cpu_freq_set_xtal(void);
320320

321+
#ifndef BOOTLOADER_BUILD
321322
/**
322323
* @brief Switch root clock source to PLL (only used by sleep) release root clock source locked by PMU
323324
*
@@ -330,6 +331,7 @@ void rtc_clk_cpu_freq_set_xtal(void);
330331
* @param[in] Maximum CPU frequency, in MHz
331332
*/
332333
void rtc_clk_cpu_freq_to_pll_and_pll_lock_release(int cpu_freq_mhz);
334+
#endif
333335

334336
/**
335337
* @brief Get the current APB frequency.

components/esp_hw_support/port/esp32c5/pmu_param.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#include "hal/efuse_hal.h"
1818
#include "esp_hw_log.h"
1919

20+
#define PMU_CLK_SRC_VAL(src) \
21+
(((uint32_t)src == (uint32_t)SOC_MOD_CLK_XTAL) ? 0 : \
22+
((uint32_t)src == (uint32_t)SOC_MOD_CLK_RC_FAST) ? 1 : \
23+
((uint32_t)src == (uint32_t)SOC_MOD_CLK_PLL_F160M) ? 2 : \
24+
((uint32_t)src == (uint32_t)SOC_MOD_CLK_PLL_F240M) ? 3 : 0)
25+
2026
static __attribute__((unused)) const char *TAG = "pmu_param";
2127

2228
#ifndef ARRAY_SIZE
@@ -111,7 +117,7 @@ const pmu_hp_system_power_param_t * pmu_hp_system_power_param_default(pmu_hp_mod
111117
.icg_sysclk_en = 1, \
112118
.sysclk_slp_sel = 0, \
113119
.icg_slp_sel = 0, \
114-
.dig_sysclk_sel = SOC_CPU_CLK_SRC_XTAL \
120+
.dig_sysclk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_XTAL) \
115121
} \
116122
}
117123

@@ -127,7 +133,7 @@ const pmu_hp_system_power_param_t * pmu_hp_system_power_param_default(pmu_hp_mod
127133
.icg_sysclk_en = 1, \
128134
.sysclk_slp_sel = 1, \
129135
.icg_slp_sel = 1, \
130-
.dig_sysclk_sel = SOC_CPU_CLK_SRC_PLL_F160M \
136+
.dig_sysclk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_PLL_F160M) \
131137
} \
132138
}
133139

@@ -142,7 +148,7 @@ const pmu_hp_system_power_param_t * pmu_hp_system_power_param_default(pmu_hp_mod
142148
.icg_sysclk_en = 0, \
143149
.sysclk_slp_sel = 1, \
144150
.icg_slp_sel = 1, \
145-
.dig_sysclk_sel = SOC_CPU_CLK_SRC_XTAL \
151+
.dig_sysclk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_XTAL) \
146152
} \
147153
}
148154

@@ -289,8 +295,8 @@ const pmu_hp_system_analog_param_t * pmu_hp_system_analog_param_default(pmu_hp_m
289295
.hp_active_retention_mode = 0, \
290296
.hp_sleep2active_retention_en = 0, \
291297
.hp_modem2active_retention_en = 0, \
292-
.hp_sleep2active_backup_clk_sel = SOC_CPU_CLK_SRC_XTAL, \
293-
.hp_modem2active_backup_clk_sel = SOC_CPU_CLK_SRC_PLL_F160M, \
298+
.hp_sleep2active_backup_clk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_XTAL), \
299+
.hp_modem2active_backup_clk_sel = PMU_CLK_SRC_VAL(SOC_CPU_CLK_SRC_PLL_F160M), \
294300
.hp_sleep2active_backup_mode = PMU_HP_RETENTION_REGDMA_CONFIG(0, 0), \
295301
.hp_modem2active_backup_mode = PMU_HP_RETENTION_REGDMA_CONFIG(0, 2), \
296302
.hp_sleep2active_backup_en = 0, \
@@ -304,7 +310,7 @@ const pmu_hp_system_analog_param_t * pmu_hp_system_analog_param_default(pmu_hp_m
304310
.hp_sleep2modem_backup_modem_clk_code = 1, \
305311
.hp_modem_retention_mode = 0, \
306312
.hp_sleep2modem_retention_en = 0, \
307-
.hp_sleep2modem_backup_clk_sel = SOC_CPU_CLK_SRC_XTAL, \
313+
.hp_sleep2modem_backup_clk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_XTAL), \
308314
.hp_sleep2modem_backup_mode = PMU_HP_RETENTION_REGDMA_CONFIG(0, 1), \
309315
.hp_sleep2modem_backup_en = 0, \
310316
}, \
@@ -318,8 +324,8 @@ const pmu_hp_system_analog_param_t * pmu_hp_system_analog_param_default(pmu_hp_m
318324
.hp_sleep_retention_mode = 0, \
319325
.hp_modem2sleep_retention_en = 0, \
320326
.hp_active2sleep_retention_en = 0, \
321-
.hp_modem2sleep_backup_clk_sel = SOC_CPU_CLK_SRC_XTAL, \
322-
.hp_active2sleep_backup_clk_sel = SOC_CPU_CLK_SRC_XTAL, \
327+
.hp_modem2sleep_backup_clk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_XTAL), \
328+
.hp_active2sleep_backup_clk_sel = PMU_CLK_SRC_VAL(SOC_MOD_CLK_XTAL), \
323329
.hp_modem2sleep_backup_mode = PMU_HP_RETENTION_REGDMA_CONFIG(1, 1), \
324330
.hp_active2sleep_backup_mode = PMU_HP_RETENTION_REGDMA_CONFIG(1, 0), \
325331
.hp_modem2sleep_backup_en = 0, \

components/esp_hw_support/port/esp32c5/rtc_clk.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ __attribute__((weak)) void rtc_clk_set_cpu_switch_to_pll(int event_id)
303303
{
304304
}
305305

306-
static void rtc_clk_update_pll_state_on_cpu_src_switching_start(soc_cpu_clk_src_t old_src, soc_cpu_clk_src_t new_src)
306+
static void rtc_clk_update_pll_state_on_cpu_src_switching_start(soc_cpu_clk_src_t old_src, soc_cpu_clk_src_t new_src, bool fast_switching)
307307
{
308308
if ((new_src == SOC_CPU_CLK_SRC_PLL_F160M) || (new_src == SOC_CPU_CLK_SRC_PLL_F240M)) {
309-
if (s_cur_pll_freq != CLK_LL_PLL_480M_FREQ_MHZ) {
309+
if ((s_cur_pll_freq != CLK_LL_PLL_480M_FREQ_MHZ) && !fast_switching) {
310310
rtc_clk_bbpll_enable();
311311
rtc_clk_bbpll_configure(rtc_clk_xtal_freq_get(), CLK_LL_PLL_480M_FREQ_MHZ);
312312
}
@@ -316,13 +316,13 @@ static void rtc_clk_update_pll_state_on_cpu_src_switching_start(soc_cpu_clk_src_
316316
}
317317
}
318318

319-
static void rtc_clk_update_pll_state_on_cpu_switching_end(soc_cpu_clk_src_t old_src, soc_cpu_clk_src_t new_src)
319+
static void rtc_clk_update_pll_state_on_cpu_src_switching_end(soc_cpu_clk_src_t old_src, soc_cpu_clk_src_t new_src, bool fast_switching)
320320
{
321321
if ((old_src == SOC_CPU_CLK_SRC_PLL_F160M) || (old_src == SOC_CPU_CLK_SRC_PLL_F240M)) {
322322
#ifndef BOOTLOADER_BUILD
323323
esp_clk_tree_enable_src((old_src == SOC_CPU_CLK_SRC_PLL_F240M) ? SOC_MOD_CLK_PLL_F240M : SOC_MOD_CLK_PLL_F160M, false);
324324
#endif
325-
if ((new_src != SOC_CPU_CLK_SRC_PLL_F160M) && (new_src != SOC_CPU_CLK_SRC_PLL_F240M) && !s_bbpll_digi_consumers_ref_count) {
325+
if ((new_src != SOC_CPU_CLK_SRC_PLL_F160M) && (new_src != SOC_CPU_CLK_SRC_PLL_F240M) && !s_bbpll_digi_consumers_ref_count && !fast_switching) {
326326
// We don't turn off the bbpll if some consumers depend on bbpll
327327
rtc_clk_bbpll_disable();
328328
}
@@ -333,7 +333,7 @@ void rtc_clk_cpu_freq_set_config(const rtc_cpu_freq_config_t *config)
333333
{
334334
soc_cpu_clk_src_t old_cpu_clk_src = clk_ll_cpu_get_src();
335335
if (old_cpu_clk_src != config->source) {
336-
rtc_clk_update_pll_state_on_cpu_src_switching_start(old_cpu_clk_src, config->source);
336+
rtc_clk_update_pll_state_on_cpu_src_switching_start(old_cpu_clk_src, config->source, false);
337337
}
338338
if (config->source == SOC_CPU_CLK_SRC_XTAL) {
339339
rtc_clk_cpu_freq_to_xtal(config->freq_mhz, config->div);
@@ -349,7 +349,7 @@ void rtc_clk_cpu_freq_set_config(const rtc_cpu_freq_config_t *config)
349349
rtc_clk_cpu_freq_to_rc_fast();
350350
}
351351
if (old_cpu_clk_src != config->source) {
352-
rtc_clk_update_pll_state_on_cpu_switching_end(old_cpu_clk_src, config->source);
352+
rtc_clk_update_pll_state_on_cpu_src_switching_end(old_cpu_clk_src, config->source, false);
353353
}
354354
}
355355

@@ -389,16 +389,25 @@ void rtc_clk_cpu_freq_get_config(rtc_cpu_freq_config_t *out_config)
389389

390390
void rtc_clk_cpu_freq_set_config_fast(const rtc_cpu_freq_config_t *config)
391391
{
392+
soc_cpu_clk_src_t old_cpu_clk_src = clk_ll_cpu_get_src();
392393
if (config->source == SOC_CPU_CLK_SRC_XTAL) {
394+
rtc_clk_update_pll_state_on_cpu_src_switching_start(old_cpu_clk_src, config->source, true);
393395
rtc_clk_cpu_freq_to_xtal(config->freq_mhz, config->div);
396+
rtc_clk_update_pll_state_on_cpu_src_switching_end(old_cpu_clk_src, config->source, true);
394397
} else if (config->source == SOC_CPU_CLK_SRC_PLL_F160M &&
395398
s_cur_pll_freq == CLK_LL_PLL_480M_FREQ_MHZ) {
399+
rtc_clk_update_pll_state_on_cpu_src_switching_start(old_cpu_clk_src, config->source, true);
396400
rtc_clk_cpu_freq_to_pll_160_mhz(config->freq_mhz);
401+
rtc_clk_update_pll_state_on_cpu_src_switching_end(old_cpu_clk_src, config->source, true);
397402
} else if (config->source == SOC_CPU_CLK_SRC_PLL_F240M &&
398403
s_cur_pll_freq == CLK_LL_PLL_480M_FREQ_MHZ) {
404+
rtc_clk_update_pll_state_on_cpu_src_switching_start(old_cpu_clk_src, config->source, true);
399405
rtc_clk_cpu_freq_to_pll_240_mhz(config->freq_mhz);
406+
rtc_clk_update_pll_state_on_cpu_src_switching_end(old_cpu_clk_src, config->source, true);
400407
} else if (config->source == SOC_CPU_CLK_SRC_RC_FAST) {
408+
rtc_clk_update_pll_state_on_cpu_src_switching_start(old_cpu_clk_src, config->source, true);
401409
rtc_clk_cpu_freq_to_rc_fast();
410+
rtc_clk_update_pll_state_on_cpu_src_switching_end(old_cpu_clk_src, config->source, true);
402411
} else {
403412
/* fallback */
404413
rtc_clk_cpu_freq_set_config(config);
@@ -414,8 +423,13 @@ void rtc_clk_cpu_freq_set_xtal(void)
414423
void rtc_clk_cpu_set_to_default_config(void)
415424
{
416425
int freq_mhz = (int)rtc_clk_xtal_freq_get();
417-
426+
#ifndef BOOTLOADER_BUILD
427+
soc_module_clk_t old_cpu_clk_src = (soc_module_clk_t)clk_ll_cpu_get_src();
428+
#endif
418429
rtc_clk_cpu_freq_to_xtal(freq_mhz, 1);
430+
#ifndef BOOTLOADER_BUILD
431+
esp_clk_tree_enable_src(old_cpu_clk_src, false);
432+
#endif
419433
s_cur_pll_freq = 0; // no disable PLL, but set freq to 0 to trigger a PLL calibration after wake-up from sleep
420434
}
421435

@@ -424,26 +438,33 @@ void rtc_clk_cpu_freq_set_xtal_for_sleep(void)
424438
rtc_clk_cpu_set_to_default_config();
425439
}
426440

441+
#ifndef BOOTLOADER_BUILD
427442
void rtc_clk_cpu_freq_to_pll_and_pll_lock_release(int cpu_freq_mhz)
428443
{
429444
// IDF-11064
430445
if (cpu_freq_mhz == 240) {
446+
esp_clk_tree_enable_src(SOC_MOD_CLK_PLL_F240M, true);
431447
rtc_clk_cpu_freq_to_pll_240_mhz(cpu_freq_mhz);
432448
} else if (cpu_freq_mhz == 160) {
449+
esp_clk_tree_enable_src(SOC_MOD_CLK_PLL_F160M, true);
433450
rtc_clk_cpu_freq_to_pll_160_mhz(cpu_freq_mhz);
434451
} else {// cpu_freq_mhz is 80
435452
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 101)) {// (use 240mhz pll if max cpu freq is 240MHz)
436453
#if CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240
454+
esp_clk_tree_enable_src(SOC_MOD_CLK_PLL_F240M, true);
437455
rtc_clk_cpu_freq_to_pll_240_mhz(cpu_freq_mhz);
438456
#else
457+
esp_clk_tree_enable_src(SOC_MOD_CLK_PLL_F160M, true);
439458
rtc_clk_cpu_freq_to_pll_160_mhz(cpu_freq_mhz);
440459
#endif
441460
} else {// (fixed for chip rev. >= ECO3)
461+
esp_clk_tree_enable_src(SOC_MOD_CLK_PLL_F160M, true);
442462
rtc_clk_cpu_freq_to_pll_160_mhz(cpu_freq_mhz);
443463
}
444464
}
445465
clk_ll_cpu_clk_src_lock_release();
446466
}
467+
#endif
447468

448469
soc_xtal_freq_t rtc_clk_xtal_freq_get(void)
449470
{

components/soc/esp32c5/include/soc/clk_tree_defs.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,50 @@ typedef enum {
7272
SOC_ROOT_CIRCUIT_CLK_BBPLL, /*!< BBPLL_CLK is the output of the PLL generator circuit */
7373
} soc_root_clk_circuit_t;
7474

75+
// Naming convention: SOC_MOD_CLK_{[upstream]clock_name}_[attr]
76+
// {[upstream]clock_name}: XTAL, (BB)PLL, etc.
77+
// [attr] - optional: FAST, SLOW, D<divider>, F<freq>
78+
/**
79+
* @brief Supported clock sources for modules (CPU, peripherals, RTC, etc.)
80+
*
81+
* @note enum starts from 1, to save 0 for special purpose
82+
*/
83+
typedef enum {
84+
// For CPU domain
85+
SOC_MOD_CLK_CPU = 1, /*!< CPU_CLK can be sourced from XTAL, PLL, or RC_FAST by configuring soc_cpu_clk_src_t */
86+
// For RTC domain
87+
SOC_MOD_CLK_RTC_FAST, /*!< RTC_FAST_CLK can be sourced from XTAL_D2 or RC_FAST by configuring soc_rtc_fast_clk_src_t */
88+
SOC_MOD_CLK_RTC_SLOW, /*!< RTC_SLOW_CLK can be sourced from RC_SLOW, XTAL32K, or OSC_SLOW by configuring soc_rtc_slow_clk_src_t */
89+
// For digital domain: peripherals, WIFI, BLE
90+
SOC_MOD_CLK_PLL_F12M, /*!< PLL_F12M_CLK is derived from SPLL (clock gating + fixed divider of 40), it has a fixed frequency of 12MHz */
91+
SOC_MOD_CLK_PLL_F20M, /*!< PLL_F20M_CLK is derived from SPLL (clock gating + fixed divider of 24), it has a fixed frequency of 20MHz */
92+
SOC_MOD_CLK_PLL_F40M, /*!< PLL_F40M_CLK is derived from SPLL (clock gating + fixed divider of 12), it has a fixed frequency of 40MHz */
93+
SOC_MOD_CLK_PLL_F48M, /*!< PLL_F48M_CLK is derived from SPLL (clock gating + fixed divider of 10), it has a fixed frequency of 48MHz */
94+
SOC_MOD_CLK_PLL_F60M, /*!< PLL_F60M_CLK is derived from SPLL (clock gating + fixed divider of 8), it has a fixed frequency of 60MHz */
95+
SOC_MOD_CLK_PLL_F80M, /*!< PLL_F80M_CLK is derived from SPLL (clock gating + fixed divider of 6), it has a fixed frequency of 80MHz */
96+
SOC_MOD_CLK_PLL_F120M, /*!< PLL_F120M_CLK is derived from SPLL (clock gating + fixed divider of 4), it has a fixed frequency of 120MHz */
97+
SOC_MOD_CLK_PLL_F160M, /*!< PLL_F160M_CLK is derived from SPLL (clock gating + fixed divider of 3), it has a fixed frequency of 160MHz */
98+
SOC_MOD_CLK_MODEM_APB = SOC_MOD_CLK_PLL_F160M, /*!< Modem APB clock comes from the CLK_160M_REF */
99+
SOC_MOD_CLK_PLL_F240M, /*!< PLL_F240M_CLK is derived from SPLL (clock gating + fixed divider of 2), it has a fixed frequency of 240MHz */
100+
SOC_MOD_CLK_SPLL, /*!< SPLL is from the main XTAL oscillator frequency multipliers, it has a "fixed" frequency of 480MHz */
101+
SOC_MOD_CLK_XTAL32K, /*!< XTAL32K_CLK comes from the external 32kHz crystal, passing a clock gating to the peripherals */
102+
SOC_MOD_CLK_RC_FAST, /*!< RC_FAST_CLK comes from the internal 20MHz rc oscillator, passing a clock gating to the peripherals */
103+
SOC_MOD_CLK_XTAL, /*!< XTAL_CLK comes from the external 48MHz crystal */
104+
// For LP peripherals
105+
SOC_MOD_CLK_XTAL_D2, /*!< XTAL_D2_CLK comes from the external 48MHz crystal, passing a div of 2 to the LP peripherals */
106+
SOC_MOD_CLK_INVALID, /*!< Indication of the end of the available module clock sources */
107+
} soc_module_clk_t;
108+
75109
/**
76110
* @brief CPU_CLK mux inputs, which are the supported clock sources for the CPU_CLK
77111
* @note Enum values are matched with the register field values on purpose
78112
*/
79113
typedef enum {
80-
SOC_CPU_CLK_SRC_XTAL = 0, /*!< Select XTAL_CLK as CPU_CLK source */
81-
SOC_CPU_CLK_SRC_RC_FAST = 1, /*!< Select RC_FAST_CLK as CPU_CLK source */
82-
SOC_CPU_CLK_SRC_PLL_F160M = 2, /*!< Select PLL_F160M_CLK as CPU_CLK source (PLL_F160M_CLK is derived from SPLL (480MHz), which is the output of the main crystal oscillator frequency multiplier) */
83-
SOC_CPU_CLK_SRC_PLL_F240M = 3, /*!< Select PLL_F240M_CLK as CPU_CLK source (PLL_F240M_CLK is derived from SPLL (480MHz), which is the output of the main crystal oscillator frequency multiplier) */
84-
SOC_CPU_CLK_SRC_INVALID, /*!< Invalid CPU_CLK source */
114+
SOC_CPU_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL, /*!< Select XTAL_CLK as CPU_CLK source */
115+
SOC_CPU_CLK_SRC_RC_FAST = SOC_MOD_CLK_RC_FAST, /*!< Select RC_FAST_CLK as CPU_CLK source */
116+
SOC_CPU_CLK_SRC_PLL_F160M = SOC_MOD_CLK_PLL_F160M, /*!< Select PLL_F160M_CLK as CPU_CLK source (PLL_F160M_CLK is derived from SPLL (480MHz), which is the output of the main crystal oscillator frequency multiplier) */
117+
SOC_CPU_CLK_SRC_PLL_F240M = SOC_MOD_CLK_PLL_F240M, /*!< Select PLL_F240M_CLK as CPU_CLK source (PLL_F240M_CLK is derived from SPLL (480MHz), which is the output of the main crystal oscillator frequency multiplier) */
118+
SOC_CPU_CLK_SRC_INVALID = SOC_MOD_CLK_INVALID, /*!< Invalid CPU_CLK source */
85119
} soc_cpu_clk_src_t;
86120

87121
/**
@@ -119,40 +153,6 @@ typedef enum {
119153
SOC_XTAL_FREQ_48M = 48, /*!< 48MHz XTAL */
120154
} soc_xtal_freq_t;
121155

122-
// Naming convention: SOC_MOD_CLK_{[upstream]clock_name}_[attr]
123-
// {[upstream]clock_name}: XTAL, (BB)PLL, etc.
124-
// [attr] - optional: FAST, SLOW, D<divider>, F<freq>
125-
/**
126-
* @brief Supported clock sources for modules (CPU, peripherals, RTC, etc.)
127-
*
128-
* @note enum starts from 1, to save 0 for special purpose
129-
*/
130-
typedef enum {
131-
// For CPU domain
132-
SOC_MOD_CLK_CPU = 1, /*!< CPU_CLK can be sourced from XTAL, PLL, or RC_FAST by configuring soc_cpu_clk_src_t */
133-
// For RTC domain
134-
SOC_MOD_CLK_RTC_FAST, /*!< RTC_FAST_CLK can be sourced from XTAL_D2 or RC_FAST by configuring soc_rtc_fast_clk_src_t */
135-
SOC_MOD_CLK_RTC_SLOW, /*!< RTC_SLOW_CLK can be sourced from RC_SLOW, XTAL32K, or OSC_SLOW by configuring soc_rtc_slow_clk_src_t */
136-
// For digital domain: peripherals, WIFI, BLE
137-
SOC_MOD_CLK_PLL_F12M, /*!< PLL_F12M_CLK is derived from SPLL (clock gating + fixed divider of 40), it has a fixed frequency of 12MHz */
138-
SOC_MOD_CLK_PLL_F20M, /*!< PLL_F20M_CLK is derived from SPLL (clock gating + fixed divider of 24), it has a fixed frequency of 20MHz */
139-
SOC_MOD_CLK_PLL_F40M, /*!< PLL_F40M_CLK is derived from SPLL (clock gating + fixed divider of 12), it has a fixed frequency of 40MHz */
140-
SOC_MOD_CLK_PLL_F48M, /*!< PLL_F48M_CLK is derived from SPLL (clock gating + fixed divider of 10), it has a fixed frequency of 48MHz */
141-
SOC_MOD_CLK_PLL_F60M, /*!< PLL_F60M_CLK is derived from SPLL (clock gating + fixed divider of 8), it has a fixed frequency of 60MHz */
142-
SOC_MOD_CLK_PLL_F80M, /*!< PLL_F80M_CLK is derived from SPLL (clock gating + fixed divider of 6), it has a fixed frequency of 80MHz */
143-
SOC_MOD_CLK_PLL_F120M, /*!< PLL_F120M_CLK is derived from SPLL (clock gating + fixed divider of 4), it has a fixed frequency of 120MHz */
144-
SOC_MOD_CLK_PLL_F160M, /*!< PLL_F160M_CLK is derived from SPLL (clock gating + fixed divider of 3), it has a fixed frequency of 160MHz */
145-
SOC_MOD_CLK_MODEM_APB = SOC_MOD_CLK_PLL_F160M, /*!< Modem APB clock comes from the CLK_160M_REF */
146-
SOC_MOD_CLK_PLL_F240M, /*!< PLL_F240M_CLK is derived from SPLL (clock gating + fixed divider of 2), it has a fixed frequency of 240MHz */
147-
SOC_MOD_CLK_SPLL, /*!< SPLL is from the main XTAL oscillator frequency multipliers, it has a "fixed" frequency of 480MHz */
148-
SOC_MOD_CLK_XTAL32K, /*!< XTAL32K_CLK comes from the external 32kHz crystal, passing a clock gating to the peripherals */
149-
SOC_MOD_CLK_RC_FAST, /*!< RC_FAST_CLK comes from the internal 20MHz rc oscillator, passing a clock gating to the peripherals */
150-
SOC_MOD_CLK_XTAL, /*!< XTAL_CLK comes from the external 48MHz crystal */
151-
// For LP peripherals
152-
SOC_MOD_CLK_XTAL_D2, /*!< XTAL_D2_CLK comes from the external 48MHz crystal, passing a div of 2 to the LP peripherals */
153-
SOC_MOD_CLK_INVALID, /*!< Indication of the end of the available module clock sources */
154-
} soc_module_clk_t;
155-
156156
//////////////////////////////////////////////////SYSTIMER//////////////////////////////////////////////////////////////
157157

158158
/**

0 commit comments

Comments
 (0)