Skip to content

Commit e0991fa

Browse files
committed
Merge branch 'bugfix/fix_esp32p4_deepsleep_gpio_wakeup_support_v5.3' into 'release/v5.3'
feat(esp_hw_support): support esp32p4 gpio/ext1 wakeup deepsleep (v5.3) See merge request espressif/esp-idf!32164
2 parents c2cf3d7 + 51a102a commit e0991fa

File tree

13 files changed

+53
-9
lines changed

13 files changed

+53
-9
lines changed

components/esp_hw_support/include/esp_private/esp_pmu.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ typedef enum {
6262
#define RTC_EXT1_TRIG_EN 0
6363
#endif
6464

65-
#define RTC_GPIO_TRIG_EN PMU_GPIO_WAKEUP_EN //!< GPIO wakeup
65+
#if SOC_LP_IO_HAS_INDEPENDENT_WAKEUP_SOURCE
66+
#define RTC_GPIO_TRIG_EN (PMU_GPIO_WAKEUP_EN | PMU_LP_GPIO_WAKEUP_EN) //!< GPIO & LP_GPIO wakeup
67+
#else
68+
#define RTC_GPIO_TRIG_EN (PMU_GPIO_WAKEUP_EN)
69+
#endif
6670

6771
#if SOC_LP_TIMER_SUPPORTED
6872
#define RTC_TIMER_TRIG_EN PMU_LP_TIMER_WAKEUP_EN //!< Timer wakeup

components/esp_hw_support/port/esp32p4/pmu_sleep.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ const pmu_sleep_config_t* pmu_sleep_config_default(
154154

155155
if (dslp) {
156156
config->param.lp_sys.analog_wait_target_cycle = rtc_time_us_to_slowclk(PMU_LP_ANALOG_WAIT_TARGET_TIME_DSLP_US, slowclk_period);
157+
158+
pmu_sleep_digital_config_t digital_default = PMU_SLEEP_DIGITAL_DSLP_CONFIG_DEFAULT(pd_flags);
159+
config->digital = digital_default;
160+
157161
pmu_sleep_analog_config_t analog_default = PMU_SLEEP_ANALOG_DSLP_CONFIG_DEFAULT(pd_flags);
158162
config->analog = analog_default;
159163
} else {
@@ -200,6 +204,7 @@ static void pmu_sleep_power_init(pmu_context_t *ctx, const pmu_sleep_power_confi
200204
static void pmu_sleep_digital_init(pmu_context_t *ctx, const pmu_sleep_digital_config_t *dig)
201205
{
202206
pmu_ll_hp_set_dig_pad_slp_sel (ctx->hal->dev, HP(SLEEP), dig->syscntl.dig_pad_slp_sel);
207+
pmu_ll_hp_set_hold_all_lp_pad (ctx->hal->dev, HP(SLEEP), dig->syscntl.lp_pad_hold_all);
203208
}
204209

205210
static void pmu_sleep_analog_init(pmu_context_t *ctx, const pmu_sleep_analog_config_t *analog, bool dslp)
@@ -255,9 +260,7 @@ void pmu_sleep_init(const pmu_sleep_config_t *config, bool dslp)
255260
{
256261
assert(PMU_instance());
257262
pmu_sleep_power_init(PMU_instance(), &config->power, dslp);
258-
if(!dslp){
259-
pmu_sleep_digital_init(PMU_instance(), &config->digital);
260-
}
263+
pmu_sleep_digital_init(PMU_instance(), &config->digital);
261264
pmu_sleep_analog_init(PMU_instance(), &config->analog, dslp);
262265
pmu_sleep_param_init(PMU_instance(), &config->param, dslp);
263266
}

components/esp_hw_support/port/esp32p4/private_include/pmu_param.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,18 @@ typedef struct {
314314
pmu_hp_sys_cntl_reg_t syscntl;
315315
} pmu_sleep_digital_config_t;
316316

317+
318+
#define PMU_SLEEP_DIGITAL_DSLP_CONFIG_DEFAULT(pd_flags) { \
319+
.syscntl = { \
320+
.dig_pad_slp_sel = 0, \
321+
.lp_pad_hold_all = (pd_flags & PMU_SLEEP_PD_LP_PERIPH) ? 1 : 0, \
322+
} \
323+
}
324+
317325
#define PMU_SLEEP_DIGITAL_LSLP_CONFIG_DEFAULT(pd_flags) { \
318326
.syscntl = { \
319-
.dig_pad_slp_sel = ((pd_flags) & PMU_SLEEP_PD_TOP) ? 0 : 1, \
327+
.dig_pad_slp_sel = (pd_flags & PMU_SLEEP_PD_TOP) ? 0 : 1, \
328+
.lp_pad_hold_all = (pd_flags & PMU_SLEEP_PD_LP_PERIPH) ? 1 : 0, \
320329
} \
321330
}
322331

components/esp_hw_support/sleep_modes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ typedef struct {
217217
uint32_t ext0_rtc_gpio_num : 5;
218218
#endif
219219
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
220-
uint32_t gpio_wakeup_mask : 8; // 8 is the maximum RTCIO number in all chips that support GPIO wakeup
221-
uint32_t gpio_trigger_mode : 8;
220+
uint32_t gpio_wakeup_mask : SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT; // Only RTC_GPIO supports wakeup deepsleep
221+
uint32_t gpio_trigger_mode : SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT;
222222
#endif
223223
uint32_t sleep_time_adjustment;
224224
uint32_t ccount_ticks_record;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK
311311
int
312312
default 0
313313

314+
config SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT
315+
int
316+
default 6
317+
314318
config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK
315319
hex
316320
default 0x00000000001FFFC0

components/soc/esp32c2/include/soc/soc_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
#define SOC_GPIO_OUT_RANGE_MAX 20
136136

137137
#define SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK (0ULL | BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5)
138+
#define SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT (6)
138139

139140
// digital I/O pad powered by VDD3P3_CPU or VDD_SPI(GPIO_NUM_6~GPIO_NUM_20)
140141
#define SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK 0x00000000001FFFC0ULL

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK
403403
int
404404
default 0
405405

406+
config SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT
407+
int
408+
default 6
409+
406410
config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK
407411
hex
408412
default 0x00000000003FFFC0

components/soc/esp32c3/include/soc/soc_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
#define SOC_GPIO_OUT_RANGE_MAX 21
174174

175175
#define SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK (0ULL | BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5)
176+
#define SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT (6)
176177

177178
// digital I/O pad powered by VDD3P3_CPU or VDD_SPI(GPIO_NUM_6~GPIO_NUM_21)
178179
#define SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK 0x00000000003FFFC0ULL

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK
499499
int
500500
default 0
501501

502+
config SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT
503+
int
504+
default 8
505+
502506
config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK
503507
hex
504508
default 0x000000007FFFFF00

components/soc/esp32c6/include/soc/soc_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
#define SOC_GPIO_OUT_RANGE_MAX 30
204204

205205
#define SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK (0ULL | BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7)
206+
#define SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT (8)
206207

207208
// digital I/O pad powered by VDD3P3_CPU or VDD_SPI(GPIO_NUM_8~GPIO_NUM_30)
208209
#define SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK 0x000000007FFFFF00ULL

0 commit comments

Comments
 (0)