Skip to content

Commit 0291269

Browse files
esp-wzhespressif-bot
authored andcommitted
fix(esp_hw_support): wait eFuse controller idle after sleep wakeup
1 parent 6e1d598 commit 0291269

File tree

6 files changed

+55
-1
lines changed

6 files changed

+55
-1
lines changed

components/esp_hw_support/port/esp32c5/pmu_sleep.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "soc/soc.h"
1515
#include "soc/rtc.h"
1616
#include "soc/pmu_struct.h"
17+
#include "hal/efuse_hal.h"
1718
#include "hal/lp_aon_hal.h"
1819
#include "esp_private/esp_pmu.h"
1920
#include "pmu_param.h"
@@ -280,6 +281,10 @@ uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp
280281
bool pmu_sleep_finish(bool dslp)
281282
{
282283
(void)dslp;
284+
285+
// Wait eFuse memory update done.
286+
while(efuse_ll_get_controller_state() != EFUSE_CONTROLLER_STATE_IDLE);
287+
283288
return pmu_ll_hp_is_sleep_reject(PMU_instance()->hal->dev);
284289
}
285290

components/esp_hw_support/port/esp32c6/pmu_sleep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp
347347
bool pmu_sleep_finish(bool dslp)
348348
{
349349
(void)dslp;
350+
351+
// Wait eFuse memory update done.
352+
while(efuse_ll_get_controller_state() != EFUSE_CONTROLLER_STATE_IDLE);
353+
350354
return pmu_ll_hp_is_sleep_reject(PMU_instance()->hal->dev);
351355
}
352356

components/esp_hw_support/port/esp32p4/pmu_sleep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ TCM_IRAM_ATTR bool pmu_sleep_finish(bool dslp)
333333
pmu_sleep_shutdown_ldo();
334334
}
335335

336+
// Wait eFuse memory update done.
337+
while(efuse_ll_get_controller_state() != EFUSE_CONTROLLER_STATE_IDLE);
338+
336339
unsigned chip_version = efuse_hal_chip_revision();
337340
if (!ESP_CHIP_REV_ABOVE(chip_version, 1)) {
338341
REGI2C_WRITE_MASK(I2C_CPLL, I2C_CPLL_OC_DIV_7_0, 6); // lower default cpu_pll freq to 400M

components/hal/esp32c5/include/hal/efuse_ll.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
extern "C" {
1919
#endif
2020

21+
typedef enum {
22+
EFUSE_CONTROLLER_STATE_RESET = 0, ///< efuse_controllerid is on reset state.
23+
EFUSE_CONTROLLER_STATE_IDLE = 1, ///< efuse_controllerid is on idle state.
24+
EFUSE_CONTROLLER_STATE_READ_INIT = 2, ///< efuse_controllerid is on read init state.
25+
EFUSE_CONTROLLER_STATE_READ_BLK0 = 3, ///< efuse_controllerid is on reading block0 state.
26+
EFUSE_CONTROLLER_STATE_BLK0_CRC_CHECK = 4, ///< efuse_controllerid is on checking block0 crc state.
27+
EFUSE_CONTROLLER_STATE_READ_RS_BLK = 5, ///< efuse_controllerid is on reading RS block state.
28+
} efuse_controller_state_t;
29+
2130
// Always inline these functions even no gcc optimization is applied.
2231

2332
/******************* eFuse fields *************************/
@@ -134,6 +143,11 @@ __attribute__((always_inline)) static inline void efuse_ll_rs_bypass_update(void
134143

135144
/******************* eFuse control functions *************************/
136145

146+
__attribute__((always_inline)) static inline uint32_t efuse_ll_get_controller_state(void)
147+
{
148+
return EFUSE.status.state;
149+
}
150+
137151
#ifdef __cplusplus
138152
}
139153
#endif

components/hal/esp32c6/include/hal/efuse_ll.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -16,6 +16,15 @@
1616
extern "C" {
1717
#endif
1818

19+
typedef enum {
20+
EFUSE_CONTROLLER_STATE_RESET = 0, ///< efuse_controllerid is on reset state.
21+
EFUSE_CONTROLLER_STATE_IDLE = 1, ///< efuse_controllerid is on idle state.
22+
EFUSE_CONTROLLER_STATE_READ_INIT = 2, ///< efuse_controllerid is on read init state.
23+
EFUSE_CONTROLLER_STATE_READ_BLK0 = 3, ///< efuse_controllerid is on reading block0 state.
24+
EFUSE_CONTROLLER_STATE_BLK0_CRC_CHECK = 4, ///< efuse_controllerid is on checking block0 crc state.
25+
EFUSE_CONTROLLER_STATE_READ_RS_BLK = 5, ///< efuse_controllerid is on reading RS block state.
26+
} efuse_controller_state_t;
27+
1928
// Always inline these functions even no gcc optimization is applied.
2029

2130
/******************* eFuse fields *************************/
@@ -175,6 +184,11 @@ __attribute__((always_inline)) static inline void efuse_ll_set_pwr_off_num(uint1
175184
EFUSE.wr_tim_conf2.pwr_off_num = value;
176185
}
177186

187+
__attribute__((always_inline)) static inline uint32_t efuse_ll_get_controller_state(void)
188+
{
189+
return EFUSE.status.state;
190+
}
191+
178192
/******************* eFuse control functions *************************/
179193

180194
#ifdef __cplusplus

components/hal/esp32p4/include/hal/efuse_ll.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
extern "C" {
1717
#endif
1818

19+
typedef enum {
20+
EFUSE_CONTROLLER_STATE_RESET = 0, ///< efuse_controllerid is on reset state.
21+
EFUSE_CONTROLLER_STATE_IDLE = 1, ///< efuse_controllerid is on idle state.
22+
EFUSE_CONTROLLER_STATE_READ_INIT = 2, ///< efuse_controllerid is on read init state.
23+
EFUSE_CONTROLLER_STATE_READ_BLK0 = 3, ///< efuse_controllerid is on reading block0 state.
24+
EFUSE_CONTROLLER_STATE_BLK0_CRC_CHECK = 4, ///< efuse_controllerid is on checking block0 crc state.
25+
EFUSE_CONTROLLER_STATE_READ_RS_BLK = 5, ///< efuse_controllerid is on reading RS block state.
26+
} efuse_controller_state_t;
27+
1928
// Always inline these functions even no gcc optimization is applied.
2029

2130
/******************* eFuse fields *************************/
@@ -130,6 +139,11 @@ __attribute__((always_inline)) static inline void efuse_ll_rs_bypass_update(void
130139
EFUSE.wr_tim_conf0_rs_bypass.update = 1;
131140
}
132141

142+
__attribute__((always_inline)) static inline uint32_t efuse_ll_get_controller_state(void)
143+
{
144+
return EFUSE.status.state;
145+
}
146+
133147
/******************* eFuse control functions *************************/
134148

135149
#ifdef __cplusplus

0 commit comments

Comments
 (0)