From 4704a99af32d3fd3d4cc0d0e4b6d13a75efe3ff8 Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 2 Jul 2026 12:19:00 +0800 Subject: [PATCH] refactor(sdm): move sleep retention config into driver layer Move SDM regdma retention descriptors out of esp_hal_gpio and into per-target esp_driver_sdm sources so the driver owns its backup scope and restore flow. --- components/esp_driver_sdm/CMakeLists.txt | 4 ++ .../src/esp32c5/sdm_retention.c | 37 +++++++++++++++++++ .../src/esp32c6/sdm_retention.c | 37 +++++++++++++++++++ .../src/esp32h2/sdm_retention.c | 37 +++++++++++++++++++ .../src/esp32h21/sdm_retention.c | 37 +++++++++++++++++++ .../src/esp32h4/sdm_retention.c | 37 +++++++++++++++++++ .../src/esp32p4/sdm_retention.c | 37 +++++++++++++++++++ .../src/esp32s31/sdm_retention.c | 37 +++++++++++++++++++ components/esp_driver_sdm/src/sdm.c | 13 ++++--- components/esp_driver_sdm/src/sdm_priv.h | 35 ++++++++++++++++++ components/esp_hal_gpio/esp32c5/sdm_periph.c | 30 --------------- components/esp_hal_gpio/esp32c6/sdm_periph.c | 30 --------------- components/esp_hal_gpio/esp32h2/sdm_periph.c | 30 --------------- components/esp_hal_gpio/esp32h21/sdm_periph.c | 30 --------------- components/esp_hal_gpio/esp32h4/sdm_periph.c | 30 --------------- components/esp_hal_gpio/esp32p4/sdm_periph.c | 30 --------------- components/esp_hal_gpio/esp32s31/sdm_periph.c | 32 ---------------- .../esp_hal_gpio/include/hal/sdm_periph.h | 17 --------- 18 files changed, 305 insertions(+), 235 deletions(-) create mode 100644 components/esp_driver_sdm/src/esp32c5/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/esp32c6/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/esp32h2/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/esp32h21/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/esp32h4/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/esp32p4/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/esp32s31/sdm_retention.c create mode 100644 components/esp_driver_sdm/src/sdm_priv.h diff --git a/components/esp_driver_sdm/CMakeLists.txt b/components/esp_driver_sdm/CMakeLists.txt index f1778957293..7358f3477ed 100644 --- a/components/esp_driver_sdm/CMakeLists.txt +++ b/components/esp_driver_sdm/CMakeLists.txt @@ -10,10 +10,14 @@ set(priv_requires esp_pm esp_driver_gpio) set(requires esp_hal_gpio) if(CONFIG_SOC_SDM_SUPPORTED) list(APPEND srcs "src/sdm.c") + if(CONFIG_SOC_PAU_SUPPORTED) + list(APPEND srcs "src/${target}/sdm_retention.c") + endif() endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} + PRIV_INCLUDE_DIRS "src" PRIV_REQUIRES "${priv_requires}" REQUIRES "${requires}" LDFRAGMENTS "linker.lf" diff --git a/components/esp_driver_sdm/src/esp32c5/sdm_retention.c b/components/esp_driver_sdm/src/esp32c5/sdm_retention.c new file mode 100644 index 00000000000..5c8e4e5371a --- /dev/null +++ b/components/esp_driver_sdm/src/esp32c5/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA[x]_REG + * GPIO_EXT_SIGMADELTA_MISC_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 5 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) +static const uint32_t gpio_ext_regs_map[4] = {0x1f, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0) | ENTRY(2), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/esp32c6/sdm_retention.c b/components/esp_driver_sdm/src/esp32c6/sdm_retention.c new file mode 100644 index 00000000000..d04a88798df --- /dev/null +++ b/components/esp_driver_sdm/src/esp32c6/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA[x]_REG + * GPIO_EXT_SIGMADELTA_MISC_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 5 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x0) +static const uint32_t gpio_ext_regs_map[4] = {0x20f, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0) | ENTRY(2), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/esp32h2/sdm_retention.c b/components/esp_driver_sdm/src/esp32h2/sdm_retention.c new file mode 100644 index 00000000000..d04a88798df --- /dev/null +++ b/components/esp_driver_sdm/src/esp32h2/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA[x]_REG + * GPIO_EXT_SIGMADELTA_MISC_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 5 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x0) +static const uint32_t gpio_ext_regs_map[4] = {0x20f, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0) | ENTRY(2), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/esp32h21/sdm_retention.c b/components/esp_driver_sdm/src/esp32h21/sdm_retention.c new file mode 100644 index 00000000000..0fdc034420b --- /dev/null +++ b/components/esp_driver_sdm/src/esp32h21/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA_MISC_REG + * GPIO_EXT_SIGMADELTA[x]_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 5 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) +static const uint32_t gpio_ext_regs_map[4] = {0x1f, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/esp32h4/sdm_retention.c b/components/esp_driver_sdm/src/esp32h4/sdm_retention.c new file mode 100644 index 00000000000..c4f6b31a067 --- /dev/null +++ b/components/esp_driver_sdm/src/esp32h4/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA[x]_REG + * GPIO_EXT_SIGMADELTA_MISC_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 5 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) +static const uint32_t gpio_ext_regs_map[4] = {0x1f, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0) | ENTRY(2), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/esp32p4/sdm_retention.c b/components/esp_driver_sdm/src/esp32p4/sdm_retention.c new file mode 100644 index 00000000000..2437d9d7494 --- /dev/null +++ b/components/esp_driver_sdm/src/esp32p4/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA[x]_REG + * GPIO_EXT_SIGMADELTA_MISC_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 9 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x0) +static const uint32_t gpio_ext_regs_map[4] = {0x2ff, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/esp32s31/sdm_retention.c b/components/esp_driver_sdm/src/esp32s31/sdm_retention.c new file mode 100644 index 00000000000..6ea8131dcef --- /dev/null +++ b/components/esp_driver_sdm/src/esp32s31/sdm_retention.c @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdm_priv.h" +#include "soc/gpio_ext_reg.h" + +/** + * @brief Registers in retention context: + * GPIO_EXT_SIGMADELTA[x]_REG + * GPIO_EXT_SIGMADELTA_MISC_REG + */ +#define GPIO_EXT_RETENTION_REGS_CNT 9 +#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) +static const uint32_t gpio_ext_regs_map[4] = {0x1ff, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t gpio_ext_regdma_entries[] = { + // backup stage: save configuration and status registers + // restore stage: restore the configuration and status registers + [0] = { + .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), + GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, + GPIO_EXT_RETENTION_REGS_CNT, 0, 0, + gpio_ext_regs_map[0], gpio_ext_regs_map[1], + gpio_ext_regs_map[2], gpio_ext_regs_map[3]), + .owner = ENTRY(0) | ENTRY(2), + }, +}; + +const sdm_reg_retention_info_t sdm_reg_retention_infos[1] = { + [0] = { + .module = SLEEP_RETENTION_MODULE_SDM0, + .regdma_entry_array = gpio_ext_regdma_entries, + .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) + } +}; diff --git a/components/esp_driver_sdm/src/sdm.c b/components/esp_driver_sdm/src/sdm.c index 6eee4030a5b..7dc60c22068 100644 --- a/components/esp_driver_sdm/src/sdm.c +++ b/components/esp_driver_sdm/src/sdm.c @@ -35,6 +35,7 @@ #include "esp_private/gpio.h" #include "esp_private/sleep_retention.h" #include "esp_private/esp_gpio_reserve.h" +#include "sdm_priv.h" #if CONFIG_SDM_OBJ_CACHE_SAFE #define SDM_MEM_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) @@ -92,16 +93,16 @@ static sdm_platform_t s_platform; static esp_err_t sdm_create_sleep_retention_link_cb(void *group) { int group_id = ((sdm_group_t *)group)->group_id; - esp_err_t err = sleep_retention_entries_create(soc_sdm_retention_infos[group_id].regdma_entry_array, - soc_sdm_retention_infos[group_id].array_size, - REGDMA_LINK_PRI_SDM, soc_sdm_retention_infos[group_id].module); + esp_err_t err = sleep_retention_entries_create(sdm_reg_retention_infos[group_id].regdma_entry_array, + sdm_reg_retention_infos[group_id].array_size, + REGDMA_LINK_PRI_SDM, sdm_reg_retention_infos[group_id].module); return err; } static void sdm_create_retention_module(sdm_group_t *group) { int group_id = group->group_id; - sleep_retention_module_t module = soc_sdm_retention_infos[group_id].module; + sleep_retention_module_t module = sdm_reg_retention_infos[group_id].module; _lock_acquire(&s_platform.mutex); if (sleep_retention_is_module_inited(module) && !sleep_retention_is_module_created(module)) { if (sleep_retention_module_allocate(module) != ESP_OK) { @@ -154,7 +155,7 @@ static esp_err_t sdm_group_install(sdm_group_t *group, soc_module_clk_t clk_src) } #if SDM_USE_RETENTION_LINK - sleep_retention_module_t module = soc_sdm_retention_infos[group_id].module; + sleep_retention_module_t module = sdm_reg_retention_infos[group_id].module; sleep_retention_module_init_param_t init_param = { .cbs = { .create = { @@ -235,7 +236,7 @@ static void sdm_group_uninstall(sdm_group_t *group) } #if SDM_USE_RETENTION_LINK - sleep_retention_module_t module = soc_sdm_retention_infos[group->group_id].module; + sleep_retention_module_t module = sdm_reg_retention_infos[group->group_id].module; sleep_retention_module_detach(module); if (sleep_retention_is_module_created(module)) { sleep_retention_module_free(module); diff --git a/components/esp_driver_sdm/src/sdm_priv.h b/components/esp_driver_sdm/src/sdm_priv.h new file mode 100644 index 00000000000..7f00c7be1f2 --- /dev/null +++ b/components/esp_driver_sdm/src/sdm_priv.h @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "soc/soc_caps.h" +#include "hal/sdm_caps.h" +#if SOC_PAU_SUPPORTED +#include "soc/regdma.h" +#include "soc/retention_periph_defs.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if SOC_PAU_SUPPORTED + +typedef struct { + const periph_retention_module_t module; + const regdma_entries_config_t *regdma_entry_array; + const size_t array_size; +} sdm_reg_retention_info_t; + +extern const sdm_reg_retention_info_t sdm_reg_retention_infos[SDM_CAPS_GET(INST_NUM)]; + +#endif // SOC_PAU_SUPPORTED + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_hal_gpio/esp32c5/sdm_periph.c b/components/esp_hal_gpio/esp32c5/sdm_periph.c index 315a4c5d79f..a6e8213b6e5 100644 --- a/components/esp_hal_gpio/esp32c5/sdm_periph.c +++ b/components/esp_hal_gpio/esp32c5/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -27,32 +26,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA[x]_REG - * GPIO_EXT_SIGMADELTA_MISC_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 5 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) -static const uint32_t gpio_ext_regs_map[4] = {0x1f, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0) | ENTRY(2), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; diff --git a/components/esp_hal_gpio/esp32c6/sdm_periph.c b/components/esp_hal_gpio/esp32c6/sdm_periph.c index 9356660742a..a6e8213b6e5 100644 --- a/components/esp_hal_gpio/esp32c6/sdm_periph.c +++ b/components/esp_hal_gpio/esp32c6/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -27,32 +26,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA[x]_REG - * GPIO_EXT_SIGMADELTA_MISC_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 5 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x0) -static const uint32_t gpio_ext_regs_map[4] = {0x20f, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0) | ENTRY(2), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; diff --git a/components/esp_hal_gpio/esp32h2/sdm_periph.c b/components/esp_hal_gpio/esp32h2/sdm_periph.c index 9356660742a..a6e8213b6e5 100644 --- a/components/esp_hal_gpio/esp32h2/sdm_periph.c +++ b/components/esp_hal_gpio/esp32h2/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -27,32 +26,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA[x]_REG - * GPIO_EXT_SIGMADELTA_MISC_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 5 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x0) -static const uint32_t gpio_ext_regs_map[4] = {0x20f, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0) | ENTRY(2), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; diff --git a/components/esp_hal_gpio/esp32h21/sdm_periph.c b/components/esp_hal_gpio/esp32h21/sdm_periph.c index 8b6bb9bdcad..b892278f291 100644 --- a/components/esp_hal_gpio/esp32h21/sdm_periph.c +++ b/components/esp_hal_gpio/esp32h21/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -27,32 +26,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA_MISC_REG - * GPIO_EXT_SIGMADELTA[x]_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 5 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) -static const uint32_t gpio_ext_regs_map[4] = {0x1f, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0) | ENTRY(2), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; diff --git a/components/esp_hal_gpio/esp32h4/sdm_periph.c b/components/esp_hal_gpio/esp32h4/sdm_periph.c index e2a876388f4..b892278f291 100644 --- a/components/esp_hal_gpio/esp32h4/sdm_periph.c +++ b/components/esp_hal_gpio/esp32h4/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -27,32 +26,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA[x]_REG - * GPIO_EXT_SIGMADELTA_MISC_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 5 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) -static const uint32_t gpio_ext_regs_map[4] = {0x1f, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0) | ENTRY(2), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; diff --git a/components/esp_hal_gpio/esp32p4/sdm_periph.c b/components/esp_hal_gpio/esp32p4/sdm_periph.c index b1225194963..cda8bb611b1 100644 --- a/components/esp_hal_gpio/esp32p4/sdm_periph.c +++ b/components/esp_hal_gpio/esp32p4/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -39,32 +38,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA[x]_REG - * GPIO_EXT_SIGMADELTA_MISC_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 9 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x0) -static const uint32_t gpio_ext_regs_map[4] = {0x2ff, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; diff --git a/components/esp_hal_gpio/esp32s31/sdm_periph.c b/components/esp_hal_gpio/esp32s31/sdm_periph.c index 9bab401cebd..bb638ca7d52 100644 --- a/components/esp_hal_gpio/esp32s31/sdm_periph.c +++ b/components/esp_hal_gpio/esp32s31/sdm_periph.c @@ -6,7 +6,6 @@ #include "hal/sdm_periph.h" #include "soc/gpio_sig_map.h" -#include "soc/gpio_ext_reg.h" const soc_sdm_signal_desc_t soc_sdm_signals[1] = { [0] = { @@ -39,34 +38,3 @@ const soc_sdm_signal_desc_t soc_sdm_signals[1] = { } } }; - -#if SOC_PAU_SUPPORTED -/** - * @brief Registers in retention context: - * GPIO_EXT_SIGMADELTA[x]_REG - * GPIO_EXT_SIGMADELTA_MISC_REG - */ -#define GPIO_EXT_RETENTION_REGS_CNT 9 -#define GPIO_EXT_RETENTION_REGS_BASE (DR_REG_GPIO_EXT_BASE + 0x4) -static const uint32_t gpio_ext_regs_map[4] = {0x1ff, 0x0, 0x0, 0x0}; -static const regdma_entries_config_t gpio_ext_regdma_entries[] = { - // backup stage: save configuration and status registers - // restore stage: restore the configuration and status registers - [0] = { - .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_SDM_LINK(0x00), - GPIO_EXT_RETENTION_REGS_BASE, GPIO_EXT_RETENTION_REGS_BASE, - GPIO_EXT_RETENTION_REGS_CNT, 0, 0, - gpio_ext_regs_map[0], gpio_ext_regs_map[1], - gpio_ext_regs_map[2], gpio_ext_regs_map[3]), - .owner = ENTRY(0) | ENTRY(2), - }, -}; - -const soc_sdm_retention_desc_t soc_sdm_retention_infos[1] = { - [0] = { - .module = SLEEP_RETENTION_MODULE_SDM0, - .regdma_entry_array = gpio_ext_regdma_entries, - .array_size = ARRAY_SIZE(gpio_ext_regdma_entries) - } -}; -#endif // SOC_PAU_SUPPORTED diff --git a/components/esp_hal_gpio/include/hal/sdm_periph.h b/components/esp_hal_gpio/include/hal/sdm_periph.h index 6349c0bad9c..3fd3d8864dc 100644 --- a/components/esp_hal_gpio/include/hal/sdm_periph.h +++ b/components/esp_hal_gpio/include/hal/sdm_periph.h @@ -10,11 +10,6 @@ #include #include "soc/soc_caps.h" #include "soc/periph_defs.h" -#include "soc/regdma.h" - -#if SOC_HAS(PAU) -#include "soc/retention_periph_defs.h" -#endif // SOC_HAS(PAU) #ifdef __cplusplus extern "C" { @@ -32,18 +27,6 @@ typedef struct { extern const soc_sdm_signal_desc_t soc_sdm_signals[SDM_CAPS_GET(INST_NUM)]; -#if SOC_HAS(PAU) - -typedef struct { - const periph_retention_module_t module; // ID of the SDM as a retention module - const regdma_entries_config_t *regdma_entry_array; // Array of regdma entries for retention - const size_t array_size; // Size of the regdma_entry_array -} soc_sdm_retention_desc_t; - -extern const soc_sdm_retention_desc_t soc_sdm_retention_infos[SDM_CAPS_GET(INST_NUM)]; - -#endif // SOC_HAS(PAU) - #endif // SOC_HAS(SDM) #ifdef __cplusplus