From 6aa4f8b63ec3dc333574aa7449c48d5ea9c97b8a Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Thu, 21 Nov 2024 11:55:24 +0800 Subject: [PATCH] feat(mcpwm): support mcpwm sleep retention on p4 --- .../esp_driver_mcpwm/test_apps/mcpwm/main/CMakeLists.txt | 3 +-- .../test_apps/pulse_cnt/main/CMakeLists.txt | 3 +-- components/soc/esp32p4/include/soc/Kconfig.soc_caps.in | 8 ++++++++ .../soc/esp32p4/include/soc/retention_periph_defs.h | 6 ++++++ components/soc/esp32p4/include/soc/soc_caps.h | 4 ++-- components/soc/esp32p4/mcpwm_periph.c | 1 + 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/components/esp_driver_mcpwm/test_apps/mcpwm/main/CMakeLists.txt b/components/esp_driver_mcpwm/test_apps/mcpwm/main/CMakeLists.txt index 42208fabf3..6a88a89350 100644 --- a/components/esp_driver_mcpwm/test_apps/mcpwm/main/CMakeLists.txt +++ b/components/esp_driver_mcpwm/test_apps/mcpwm/main/CMakeLists.txt @@ -17,8 +17,7 @@ if(CONFIG_SOC_ETM_SUPPORTED AND CONFIG_SOC_MCPWM_SUPPORT_ETM) list(APPEND srcs "test_mcpwm_etm.c") endif() -# TODO: IDF-9928 support ESP32P4 -if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED AND CONFIG_PM_ENABLE AND NOT CONFIG_IDF_TARGET_ESP32P4) +if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED AND CONFIG_PM_ENABLE) list(APPEND srcs "test_mcpwm_sleep.c") endif() diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt index 1fc04aa4b8..043307bcb3 100644 --- a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt @@ -6,8 +6,7 @@ if(CONFIG_PCNT_ISR_IRAM_SAFE) list(APPEND srcs "test_pulse_cnt_iram.c") endif() -# TODO: IDF-9907 support ESP32P4 -if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED AND CONFIG_PM_ENABLE AND NOT CONFIG_IDF_TARGET_ESP32P4) +if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED AND CONFIG_PM_ENABLE) list(APPEND srcs "test_pulse_cnt_sleep.c") endif() diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index f626fecd21..378147443c 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -1123,6 +1123,10 @@ config SOC_PCNT_SUPPORT_CLEAR_SIGNAL bool default y +config SOC_PCNT_SUPPORT_SLEEP_RETENTION + bool + default y + config SOC_RMT_GROUPS int default 1 @@ -1275,6 +1279,10 @@ config SOC_MCPWM_CAPTURE_CLK_FROM_GROUP bool default y +config SOC_MCPWM_SUPPORT_SLEEP_RETENTION + bool + default y + config SOC_USB_OTG_PERIPH_NUM int default 2 diff --git a/components/soc/esp32p4/include/soc/retention_periph_defs.h b/components/soc/esp32p4/include/soc/retention_periph_defs.h index 84d52d48c1..17cf61998f 100644 --- a/components/soc/esp32p4/include/soc/retention_periph_defs.h +++ b/components/soc/esp32p4/include/soc/retention_periph_defs.h @@ -57,6 +57,9 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_GPSPI2 = 31, SLEEP_RETENTION_MODULE_GPSPI3 = 32, SLEEP_RETENTION_MODULE_LEDC = 33, + SLEEP_RETENTION_MODULE_MCPWM0 = 34, + SLEEP_RETENTION_MODULE_MCPWM1 = 35, + SLEEP_RETENTION_MODULE_PCNT0 = 36, SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1 } periph_retention_module_t; @@ -96,6 +99,9 @@ typedef enum periph_retention_module { : ((m) == SLEEP_RETENTION_MODULE_GPSPI2) ? true \ : ((m) == SLEEP_RETENTION_MODULE_GPSPI3) ? true \ : ((m) == SLEEP_RETENTION_MODULE_LEDC) ? true \ + : ((m) == SLEEP_RETENTION_MODULE_MCPWM0) ? true \ + : ((m) == SLEEP_RETENTION_MODULE_MCPWM1) ? true \ + : ((m) == SLEEP_RETENTION_MODULE_PCNT0) ? true \ : false) #ifdef __cplusplus diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index ced013a17a..4c7f8eb92f 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -409,7 +409,7 @@ #define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1 /*!< Support clear signal input */ -// #define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 // TODO: IDF-9907 Waiting for expansion of module ID /*!< The sleep retention feature can help back up PCNT registers before sleep */ +#define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up PCNT registers before sleep */ /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ @@ -455,7 +455,7 @@ #define SOC_MCPWM_SUPPORT_ETM (1) ///< Support ETM (Event Task Matrix) #define SOC_MCPWM_SUPPORT_EVENT_COMPARATOR (1) ///< Support event comparator (based on ETM) #define SOC_MCPWM_CAPTURE_CLK_FROM_GROUP (1) ///< Capture timer shares clock with other PWM timers -// #define SOC_MCPWM_SUPPORT_SLEEP_RETENTION (1) // TODO: IDF-9928 Waiting for expansion of module ID ///< Support back up registers before sleep +#define SOC_MCPWM_SUPPORT_SLEEP_RETENTION (1) ///< Support back up registers before sleep /*-------------------------- USB CAPS ----------------------------------------*/ // USB Serial JTAG Caps diff --git a/components/soc/esp32p4/mcpwm_periph.c b/components/soc/esp32p4/mcpwm_periph.c index 8c0cb3e444..60cf13f103 100644 --- a/components/soc/esp32p4/mcpwm_periph.c +++ b/components/soc/esp32p4/mcpwm_periph.c @@ -6,6 +6,7 @@ #include "soc/soc.h" #include "soc/mcpwm_periph.h" +#include "soc/mcpwm_reg.h" #include "soc/gpio_sig_map.h" const mcpwm_signal_conn_t mcpwm_periph_signals = {