Skip to content

Commit 377914d

Browse files
committed
change(esp_hw_support): fix wifi mac rx buffer link exception caused by pll clock
1 parent 2fce894 commit 377914d

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

components/esp_hw_support/sleep_modes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,9 @@ FORCE_INLINE_ATTR void misc_modules_sleep_prepare(uint32_t pd_flags, bool deep_s
674674
}
675675
#endif
676676
#if CONFIG_MAC_BB_PD
677+
# if CONFIG_IDF_TARGET_ESP32C5
678+
clk_ll_soc_root_clk_auto_gating_bypass(false);
679+
# endif
677680
mac_bb_power_down_cb_execute();
678681
#endif
679682
#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL
@@ -736,6 +739,9 @@ FORCE_INLINE_ATTR void misc_modules_wake_prepare(uint32_t pd_flags)
736739
#endif
737740
#if CONFIG_MAC_BB_PD
738741
mac_bb_power_up_cb_execute();
742+
# if CONFIG_IDF_TARGET_ESP32C5
743+
clk_ll_soc_root_clk_auto_gating_bypass(true);
744+
# endif
739745
#endif
740746
#if REGI2C_ANA_CALI_PD_WORKAROUND
741747
regi2c_analog_cali_reg_write();

components/esp_system/port/soc/esp32c5/clk.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "esp_cpu.h"
2424
#include "hal/efuse_hal.h"
2525
#include "hal/wdt_hal.h"
26+
#include "hal/clk_tree_ll.h"
2627
#if SOC_MODEM_CLOCK_SUPPORTED
2728
#include "hal/modem_lpcon_ll.h"
2829
#endif
@@ -222,14 +223,12 @@ __attribute__((weak)) void esp_perip_clk_init(void)
222223
modem_clock_select_lp_clock_source(PERIPH_WIFI_MODULE, modem_lpclk_src, 0);
223224
#endif
224225

225-
if (ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 1)) {
226-
/* On ESP32-C5 ECO1, clearing BIT(31) of PCR_FPGA_DEBUG_REG is used to fix
227-
* the issue where the modem module fails to transmit and receive packets
228-
* due to the loss of the modem root clock caused by automatic clock gating
229-
* during soc root clock source switching. For detailed information, refer
230-
* to IDF-11064. */
231-
REG_CLR_BIT(PCR_FPGA_DEBUG_REG, BIT(31));
232-
}
226+
/* On ESP32-C5 ECO1, clearing BIT(31) of PCR_FPGA_DEBUG_REG is used to fix
227+
* the issue where the modem module fails to transmit and receive packets
228+
* due to the loss of the modem root clock caused by automatic clock gating
229+
* during soc root clock source switching. For detailed information, refer
230+
* to IDF-11064. */
231+
clk_ll_soc_root_clk_auto_gating_bypass(true);
233232

234233
ESP_EARLY_LOGW(TAG, "esp_perip_clk_init() has not been implemented yet");
235234
#if 0 // TODO: [ESP32C5] IDF-8844

components/hal/esp32c5/include/hal/clk_tree_ll.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
#include <stdint.h>
1010
#include "soc/soc.h"
1111
#include "soc/clk_tree_defs.h"
12+
#include "soc/pcr_reg.h"
1213
#include "soc/pcr_struct.h"
1314
#include "soc/lp_clkrst_struct.h"
1415
#include "soc/pmu_reg.h"
1516
#include "soc/pmu_struct.h"
17+
#include "soc/chip_revision.h"
1618
#include "hal/regi2c_ctrl.h"
1719
#include "soc/regi2c_bbpll.h"
1820
#include "hal/assert.h"
1921
#include "hal/log.h"
2022
#include "esp32c5/rom/rtc.h"
2123
#include "hal/misc.h"
24+
#include "hal/efuse_hal.h"
2225

2326
#ifdef __cplusplus
2427
extern "C" {
@@ -420,6 +423,22 @@ static inline __attribute__((always_inline)) uint32_t clk_ll_apb_get_divider(voi
420423
return HAL_FORCE_READ_U32_REG_FIELD(PCR.apb_freq_conf, apb_div_num) + 1;
421424
}
422425

426+
/**
427+
* @brief Enable or disable the soc root clock auto gating logic
428+
*
429+
* @param ena true to enable, false to disable
430+
*/
431+
static inline __attribute__((always_inline)) void clk_ll_soc_root_clk_auto_gating_bypass(bool ena)
432+
{
433+
if (ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 1)) {
434+
if (ena) {
435+
REG_CLR_BIT(PCR_FPGA_DEBUG_REG, BIT(31));
436+
} else {
437+
REG_SET_BIT(PCR_FPGA_DEBUG_REG, BIT(31));
438+
}
439+
}
440+
}
441+
423442
/**
424443
* @brief Select the clock source for RTC_SLOW_CLK
425444
*

0 commit comments

Comments
 (0)