Skip to content

Commit 914a481

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/idf-11064_v5.4' into 'release/v5.4'
backport v5.4: fix some issues on esp32c5 eco1 See merge request espressif/esp-idf!34790
2 parents 48ed77c + 52bcb74 commit 914a481

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

components/esp_hw_support/lowpower/port/esp32c5/sleep_clock.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "modem/modem_syscon_reg.h"
1111
#include "modem/modem_lpcon_reg.h"
1212
#include "soc/i2c_ana_mst_reg.h"
13+
#include "soc/chip_revision.h"
14+
#include "hal/efuse_hal.h"
1315

1416
static const char *TAG = "sleep_clock";
1517

@@ -35,7 +37,6 @@ esp_err_t sleep_clock_system_retention_init(void *arg)
3537
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP && CONFIG_XTAL_FREQ_AUTO
3638
uint32_t xtal_freq_mhz = (uint32_t)rtc_clk_xtal_freq_get();
3739
if (xtal_freq_mhz == SOC_XTAL_FREQ_48M) {
38-
3940
/* For the 48 MHz main XTAL, we need regdma to configured BBPLL by exec
4041
* the PHY_I2C_MST_CMD_TYPE_BBPLL_CFG command from PHY i2c master
4142
* command memory */
@@ -52,6 +53,21 @@ esp_err_t sleep_clock_system_retention_init(void *arg)
5253
}
5354
#endif
5455

56+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
57+
/* On ESP32-C5 ECO1, clearing BIT(31) of PCR_FPGA_DEBUG_REG (it's located
58+
* in TOP domain) is used to fix the issue where the modem module fails
59+
* to transmit and receive packets due to the loss of The modem root clock
60+
* caused by automatic clock gating during soc root clock source switching.
61+
* For detailed information, refer to IDF-11064 */
62+
if (ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 1)) {
63+
const static sleep_retention_entries_config_t rootclk_workaround[] = {
64+
[0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_PCR_LINK(9), PCR_FPGA_DEBUG_REG, PCR_FPGA_DEBUG_REG, 1, 0, 0), .owner = ENTRY(0) | ENTRY(1) }
65+
};
66+
err = sleep_retention_entries_create(rootclk_workaround, ARRAY_SIZE(rootclk_workaround), 1, SLEEP_RETENTION_MODULE_CLOCK_SYSTEM);
67+
ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem root clock workaround, 1 level priority");
68+
}
69+
#endif
70+
5571
ESP_LOGI(TAG, "System Power, Clock and Reset sleep retention initialization");
5672
return ESP_OK;
5773
}

components/esp_hw_support/port/esp32c5/rtc_clk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ bool rtc_clk_cpu_freq_mhz_to_config(uint32_t freq_mhz, rtc_cpu_freq_config_t *ou
268268
} else if (freq_mhz == 80) {
269269
real_freq_mhz = freq_mhz;
270270
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 1)) {
271-
// ESP32C5 has a root clock ICG issue when switching SOC_CPU_CLK_SRC from PLL_F160M to PLL_F240M
271+
/* ESP32C5 has a root clock ICG issue when switching SOC_CPU_CLK_SRC from PLL_F160M to PLL_F240M
272+
* For detailed information, refer to IDF-11064 */
272273
source = SOC_CPU_CLK_SRC_PLL_F240M;
273274
source_freq_mhz = CLK_LL_PLL_240M_FREQ_MHZ;
274275
divider = 3;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
#include "soc/rtc.h"
2020
#include "soc/rtc_periph.h"
2121
#include "soc/i2s_reg.h"
22+
#include "soc/chip_revision.h"
2223
#include "esp_cpu.h"
24+
#include "hal/efuse_hal.h"
2325
#include "hal/wdt_hal.h"
2426
#if SOC_MODEM_CLOCK_SUPPORTED
2527
#include "hal/modem_lpcon_ll.h"
@@ -215,6 +217,15 @@ __attribute__((weak)) void esp_perip_clk_init(void)
215217
modem_clock_select_lp_clock_source(PERIPH_WIFI_MODULE, modem_lpclk_src, 0);
216218
#endif
217219

220+
if (ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 1)) {
221+
/* On ESP32-C5 ECO1, clearing BIT(31) of PCR_FPGA_DEBUG_REG is used to fix
222+
* the issue where the modem module fails to transmit and receive packets
223+
* due to the loss of the modem root clock caused by automatic clock gating
224+
* during soc root clock source switching. For detailed information, refer
225+
* to IDF-11064. */
226+
REG_CLR_BIT(PCR_FPGA_DEBUG_REG, BIT(31));
227+
}
228+
218229
ESP_EARLY_LOGW(TAG, "esp_perip_clk_init() has not been implemented yet");
219230
#if 0 // TODO: [ESP32C5] IDF-8844
220231
uint32_t common_perip_clk, hwcrypto_perip_clk, wifi_bt_sdio_clk = 0;

components/soc/esp32c5/include/soc/Kconfig.soc_caps.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,10 +1379,6 @@ config SOC_PM_MODEM_RETENTION_BY_REGDMA
13791379
bool
13801380
default y
13811381

1382-
config SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD
1383-
bool
1384-
default y
1385-
13861382
config SOC_EXT_MEM_CACHE_TAG_IN_CPU_DOMAIN
13871383
bool
13881384
default y

components/soc/esp32c5/include/soc/soc_caps.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@
578578

579579
#define SOC_PM_CPU_RETENTION_BY_SW (1)
580580
#define SOC_PM_MODEM_RETENTION_BY_REGDMA (1)
581-
#define SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD (1)
582581
#define SOC_EXT_MEM_CACHE_TAG_IN_CPU_DOMAIN (1)
583582

584583
#define SOC_PM_PAU_LINK_NUM (5)

0 commit comments

Comments
 (0)