Skip to content

Commit 12191f2

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/fix_softap_tx_bcn_failed_v5.5' into 'release/v5.5'
fix(pm): fix c5 tx pkt failed v5.5 See merge request espressif/esp-idf!40350
2 parents 7a329d5 + b7887b0 commit 12191f2

File tree

1 file changed

+38
-6
lines changed
  • components/esp_hw_support/port/esp32c5

1 file changed

+38
-6
lines changed

components/esp_hw_support/port/esp32c5/rtc_clk.c

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,21 @@ bool rtc_clk_cpu_freq_mhz_to_config(uint32_t freq_mhz, rtc_cpu_freq_config_t *ou
233233
// 40MHz with PLL_F160M or PLL_F240M clock source. This is a special case, has to handle separately.
234234
if (xtal_freq == SOC_XTAL_FREQ_48M && freq_mhz == 40) {
235235
real_freq_mhz = freq_mhz;
236-
source = SOC_CPU_CLK_SRC_PLL_F160M;
237-
source_freq_mhz = CLK_LL_PLL_160M_FREQ_MHZ;
238-
divider = 4;
236+
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 101)) {
237+
#if CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240
238+
source = SOC_CPU_CLK_SRC_PLL_F240M;
239+
source_freq_mhz = CLK_LL_PLL_240M_FREQ_MHZ;
240+
divider = 6;
241+
#else
242+
source = SOC_CPU_CLK_SRC_PLL_F160M;
243+
source_freq_mhz = CLK_LL_PLL_160M_FREQ_MHZ;
244+
divider = 4;
245+
#endif
246+
} else {
247+
source = SOC_CPU_CLK_SRC_PLL_F160M;
248+
source_freq_mhz = CLK_LL_PLL_160M_FREQ_MHZ;
249+
divider = 4;
250+
}
239251
} else if (freq_mhz <= xtal_freq && freq_mhz != 0) {
240252
divider = xtal_freq / freq_mhz;
241253
real_freq_mhz = (xtal_freq + divider / 2) / divider; /* round */
@@ -258,12 +270,18 @@ bool rtc_clk_cpu_freq_mhz_to_config(uint32_t freq_mhz, rtc_cpu_freq_config_t *ou
258270
divider = 1;
259271
} else if (freq_mhz == 80) {
260272
real_freq_mhz = freq_mhz;
261-
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 1)) {
273+
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 101)) {
262274
/* ESP32C5 has a root clock ICG issue when switching SOC_CPU_CLK_SRC from PLL_F160M to PLL_F240M
263275
* For detailed information, refer to IDF-11064 */
276+
#if CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240
264277
source = SOC_CPU_CLK_SRC_PLL_F240M;
265278
source_freq_mhz = CLK_LL_PLL_240M_FREQ_MHZ;
266279
divider = 3;
280+
#else
281+
source = SOC_CPU_CLK_SRC_PLL_F160M;
282+
source_freq_mhz = CLK_LL_PLL_160M_FREQ_MHZ;
283+
divider = 2;
284+
#endif
267285
} else {
268286
source = SOC_CPU_CLK_SRC_PLL_F160M;
269287
source_freq_mhz = CLK_LL_PLL_160M_FREQ_MHZ;
@@ -393,8 +411,22 @@ void rtc_clk_cpu_freq_set_xtal_for_sleep(void)
393411

394412
void rtc_clk_cpu_freq_to_pll_and_pll_lock_release(int cpu_freq_mhz)
395413
{
396-
// TODO: IDF-8641 CPU_MAX_FREQ don't know what to do... pll_240 or pll_160...
397-
rtc_clk_cpu_freq_to_pll_240_mhz(cpu_freq_mhz);
414+
// IDF-11064
415+
if (cpu_freq_mhz == 240) {
416+
rtc_clk_cpu_freq_to_pll_240_mhz(cpu_freq_mhz);
417+
} else if (cpu_freq_mhz == 160) {
418+
rtc_clk_cpu_freq_to_pll_160_mhz(cpu_freq_mhz);
419+
} else {// cpu_freq_mhz is 80
420+
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 101)) {// (use 240mhz pll if max cpu freq is 240MHz)
421+
#if CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240
422+
rtc_clk_cpu_freq_to_pll_240_mhz(cpu_freq_mhz);
423+
#else
424+
rtc_clk_cpu_freq_to_pll_160_mhz(cpu_freq_mhz);
425+
#endif
426+
} else {// (fixed for chip rev. >= ECO3)
427+
rtc_clk_cpu_freq_to_pll_160_mhz(cpu_freq_mhz);
428+
}
429+
}
398430
clk_ll_cpu_clk_src_lock_release();
399431
}
400432

0 commit comments

Comments
 (0)