From 8f415a7f448d0438091f2456c173b5e32a829dd1 Mon Sep 17 00:00:00 2001 From: jingli Date: Wed, 22 Feb 2023 14:03:39 +0800 Subject: [PATCH 1/4] refactor: power management component use unified esp_pm_config_t --- components/esp_pm/include/esp32/pm.h | 23 +----- components/esp_pm/include/esp32c2/pm.h | 25 +----- components/esp_pm/include/esp32c3/pm.h | 25 +----- components/esp_pm/include/esp32c6/pm.h | 27 +------ components/esp_pm/include/esp32h2/pm.h | 30 ------- components/esp_pm/include/esp32h4/pm.h | 25 +----- components/esp_pm/include/esp32s2/pm.h | 25 +----- components/esp_pm/include/esp32s3/pm.h | 25 +----- components/esp_pm/include/esp_pm.h | 38 +++++---- components/esp_pm/pm_impl.c | 80 +------------------ .../esp_pm/test_apps/esp_pm/main/test_pm.c | 49 +----------- docs/doxygen/Doxyfile | 1 - .../api-reference/system/power_management.rst | 3 +- .../api-reference/system/power_management.rst | 3 +- examples/wifi/itwt/main/itwt.c | 2 +- examples/wifi/power_save/main/power_save.c | 14 +--- 16 files changed, 57 insertions(+), 338 deletions(-) delete mode 100644 components/esp_pm/include/esp32h2/pm.h diff --git a/components/esp_pm/include/esp32/pm.h b/components/esp_pm/include/esp32/pm.h index 4933345f099..d5d6022fb3b 100644 --- a/components/esp_pm/include/esp32/pm.h +++ b/components/esp_pm/include/esp32/pm.h @@ -6,25 +6,8 @@ #pragma once -#include -#include -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" -/** - * @brief Power management config for ESP32 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32c2/pm.h b/components/esp_pm/include/esp32c2/pm.h index 78ad319646c..4488ff895a8 100644 --- a/components/esp_pm/include/esp32c2/pm.h +++ b/components/esp_pm/include/esp32c2/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32c2_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32-C2 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32c2_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32c3/pm.h b/components/esp_pm/include/esp32c3/pm.h index e2d125d89ae..aeb83322cc9 100644 --- a/components/esp_pm/include/esp32c3/pm.h +++ b/components/esp_pm/include/esp32c3/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32c3_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32C3 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32c3_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32c6/pm.h b/components/esp_pm/include/esp32c6/pm.h index 6255cccad10..b6b0487861c 100644 --- a/components/esp_pm/include/esp32c6/pm.h +++ b/components/esp_pm/include/esp32c6/pm.h @@ -1,32 +1,13 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32c6_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32C6 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32c6_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32h2/pm.h b/components/esp_pm/include/esp32h2/pm.h deleted file mode 100644 index 45c89d71c6d..00000000000 --- a/components/esp_pm/include/esp32h2/pm.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - - -#pragma once -#include -#include -#include "esp_err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Power management config for ESP32H2 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32h2_t; - -#ifdef __cplusplus -} -#endif diff --git a/components/esp_pm/include/esp32h4/pm.h b/components/esp_pm/include/esp32h4/pm.h index 9a1c9c9c428..1078f778123 100644 --- a/components/esp_pm/include/esp32h4/pm.h +++ b/components/esp_pm/include/esp32h4/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32h4_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32H4 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32h4_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32s2/pm.h b/components/esp_pm/include/esp32s2/pm.h index 8036326ff91..8c6bc5bb843 100644 --- a/components/esp_pm/include/esp32s2/pm.h +++ b/components/esp_pm/include/esp32s2/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32s2_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32s2_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32s3/pm.h b/components/esp_pm/include/esp32s3/pm.h index 51ec7aafb2d..b51c7df326e 100644 --- a/components/esp_pm/include/esp32s3/pm.h +++ b/components/esp_pm/include/esp32s3/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32s3_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32s3_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp_pm.h b/components/esp_pm/include/esp_pm.h index 4b8a3b05ca4..f64bdd93cfd 100644 --- a/components/esp_pm/include/esp_pm.h +++ b/components/esp_pm/include/esp_pm.h @@ -9,26 +9,34 @@ #include #include "esp_err.h" #include "sdkconfig.h" -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/pm.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/pm.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/pm.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/pm.h" -#endif #ifdef __cplusplus extern "C" { #endif +/** + * @brief Power management config + * + * Pass a pointer to this structure as an argument to esp_pm_configure function. + */ +typedef struct { + int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ + int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ + bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ +} esp_pm_config_t; + +/** + * backward compatibility + * newer chips no longer require this typedef + */ +typedef esp_pm_config_t esp_pm_config_esp32_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32s2_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32s3_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32c3_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32h4_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32c2_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32c6_t __attribute__((deprecated("please use esp_pm_config_t instead"))); + /** * @brief Power management constraints */ diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index a14bcc3d2fe..b56346ba81e 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -22,6 +22,7 @@ #include "hal/uart_ll.h" #include "hal/uart_types.h" #include "driver/uart.h" +#include "driver/gpio.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -39,31 +40,6 @@ #include "sdkconfig.h" -// [refactor-todo] opportunity for further refactor -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/pm.h" -#include "driver/gpio.h" -#endif #define MHZ (1000000) @@ -227,23 +203,7 @@ esp_err_t esp_pm_configure(const void* vconfig) return ESP_ERR_NOT_SUPPORTED; #endif -#if CONFIG_IDF_TARGET_ESP32 - const esp_pm_config_esp32_t* config = (const esp_pm_config_esp32_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S2 - const esp_pm_config_esp32s2_t* config = (const esp_pm_config_esp32s2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S3 - const esp_pm_config_esp32s3_t* config = (const esp_pm_config_esp32s3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C3 - const esp_pm_config_esp32c3_t* config = (const esp_pm_config_esp32c3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H4 - const esp_pm_config_esp32h4_t* config = (const esp_pm_config_esp32h4_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C2 - const esp_pm_config_esp32c2_t* config = (const esp_pm_config_esp32c2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C6 - const esp_pm_config_esp32c6_t* config = (const esp_pm_config_esp32c6_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H2 - const esp_pm_config_esp32h2_t* config = (const esp_pm_config_esp32h2_t*) vconfig; -#endif + const esp_pm_config_t* config = (const esp_pm_config_t*) vconfig; #ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE if (config->light_sleep_enable) { @@ -347,23 +307,7 @@ esp_err_t esp_pm_get_configuration(void* vconfig) return ESP_ERR_INVALID_ARG; } -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t* config = (esp_pm_config_esp32_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t* config = (esp_pm_config_esp32s2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t* config = (esp_pm_config_esp32s3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t* config = (esp_pm_config_esp32c3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t* config = (esp_pm_config_esp32h4_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t* config = (esp_pm_config_esp32c2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t* config = (esp_pm_config_esp32c6_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H2 - esp_pm_config_esp32h2_t* config = (esp_pm_config_esp32h2_t*) vconfig; -#endif + esp_pm_config_t* config = (esp_pm_config_t*) vconfig; portENTER_CRITICAL(&s_switch_lock); config->light_sleep_enable = s_light_sleep_en; @@ -792,23 +736,7 @@ void esp_pm_impl_init(void) #ifdef CONFIG_PM_DFS_INIT_AUTO int xtal_freq_mhz = esp_clk_xtal_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32H2 - esp_pm_config_esp32h2_t cfg = { -#endif + esp_pm_config_t cfg = { .max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, .min_freq_mhz = xtal_freq_mhz, }; diff --git a/components/esp_pm/test_apps/esp_pm/main/test_pm.c b/components/esp_pm/test_apps/esp_pm/main/test_pm.c index 09e90edce78..af98d2c54a0 100644 --- a/components/esp_pm/test_apps/esp_pm/main/test_pm.c +++ b/components/esp_pm/test_apps/esp_pm/main/test_pm.c @@ -48,21 +48,8 @@ TEST_CASE("Can dump power management lock stats", "[pm]") static void switch_freq(int mhz) { int xtal_freq_mhz = esp_clk_xtal_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + + esp_pm_config_t pm_config = { .max_freq_mhz = mhz, .min_freq_mhz = MIN(mhz, xtal_freq_mhz), }; @@ -105,21 +92,7 @@ static void light_sleep_enable(void) int cur_freq_mhz = esp_clk_cpu_freq() / MHZ; int xtal_freq = esp_clk_xtal_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + esp_pm_config_t pm_config = { .max_freq_mhz = cur_freq_mhz, .min_freq_mhz = xtal_freq, .light_sleep_enable = true @@ -131,21 +104,7 @@ static void light_sleep_disable(void) { int cur_freq_mhz = esp_clk_cpu_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + esp_pm_config_t pm_config = { .max_freq_mhz = cur_freq_mhz, .min_freq_mhz = cur_freq_mhz, }; diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index d48a77d466b..05a845a494d 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -159,7 +159,6 @@ INPUT = \ $(PROJECT_PATH)/components/esp_netif/include/esp_netif_sntp.h \ $(PROJECT_PATH)/components/esp_partition/include/esp_partition.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \ - $(PROJECT_PATH)/components/esp_pm/include/$(IDF_TARGET)/pm.h \ $(PROJECT_PATH)/components/esp_pm/include/esp_pm.h \ $(PROJECT_PATH)/components/esp_ringbuf/include/freertos/ringbuf.h \ $(PROJECT_PATH)/components/esp_rom/include/esp_rom_sys.h \ diff --git a/docs/en/api-reference/system/power_management.rst b/docs/en/api-reference/system/power_management.rst index 0c830d50f04..b43e721b077 100644 --- a/docs/en/api-reference/system/power_management.rst +++ b/docs/en/api-reference/system/power_management.rst @@ -25,7 +25,7 @@ Power management can be enabled at compile time, using the option :ref:`CONFIG_P Enabling power management features comes at the cost of increased interrupt latency. Extra latency depends on a number of factors, such as the CPU frequency, single/dual core mode, whether or not frequency switch needs to be done. Minimum extra latency is 0.2 us (when the CPU frequency is 240 MHz and frequency scaling is not enabled). Maximum extra latency is 40 us (when frequency scaling is enabled, and a switch from 40 MHz to 80 MHz is performed on interrupt entry). -Dynamic frequency scaling (DFS) and automatic light sleep can be enabled in an application by calling the function :cpp:func:`esp_pm_configure`. Its argument is a structure defining the frequency scaling settings, :cpp:class:`esp_pm_config_{IDF_TARGET_PATH_NAME}_t`. In this structure, three fields need to be initialized: +Dynamic frequency scaling (DFS) and automatic light sleep can be enabled in an application by calling the function :cpp:func:`esp_pm_configure`. Its argument is a structure defining the frequency scaling settings, :cpp:class:`esp_pm_config_t`. In this structure, three fields need to be initialized: - ``max_freq_mhz``: Maximum CPU frequency in MHz, i.e., the frequency used when the ``ESP_PM_CPU_FREQ_MAX`` lock is acquired. This field will usually be set to the default CPU frequency. - ``min_freq_mhz``: Minimum CPU frequency in MHz, i.e., the frequency used when only the ``ESP_PM_APB_FREQ_MAX`` lock is acquired. This field can be set to the XTAL frequency value, or the XTAL frequency divided by an integer. Note that 10 MHz is the lowest frequency at which the default REF_TICK clock of 1 MHz can be generated. @@ -137,5 +137,4 @@ API Reference ------------- .. include-build-file:: inc/esp_pm.inc -.. include-build-file:: inc/pm.inc diff --git a/docs/zh_CN/api-reference/system/power_management.rst b/docs/zh_CN/api-reference/system/power_management.rst index e199d07c243..106fa9efbb8 100644 --- a/docs/zh_CN/api-reference/system/power_management.rst +++ b/docs/zh_CN/api-reference/system/power_management.rst @@ -25,7 +25,7 @@ ESP-IDF 中集成的电源管理算法可以根据应用程序组件的需求, 启用电源管理功能将会增加中断延迟。额外延迟与多个因素有关,例如:CPU 频率、单/双核模式、是否需要进行频率切换等。CPU 频率为 240 MHz 且未启用频率调节时,最小额外延迟为 0.2 us;如果启用频率调节,且在中断入口将频率由 40 MHz 调节至 80 MHz,则最大额外延迟为 40 us。 -通过调用 :cpp:func:`esp_pm_configure` 函数可以在应用程序中启用动态调频 (DFS) 功能和自动 Light-sleep 模式。此函数的参数 :cpp:class:`esp_pm_config_{IDF_TARGET_PATH_NAME}_t` 定义了频率调节的相关设置。在此参数结构中,需要初始化以下三个字段: +通过调用 :cpp:func:`esp_pm_configure` 函数可以在应用程序中启用动态调频 (DFS) 功能和自动 Light-sleep 模式。此函数的参数 :cpp:class:`esp_pm_config_t` 定义了频率调节的相关设置。在此参数结构中,需要初始化以下三个字段: - ``max_freq_mhz``:最大 CPU 频率 (MHz),即获取 ``ESP_PM_CPU_FREQ_MAX`` 锁后所使用的频率。该字段通常设置为 :ref:`CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ`。 - ``min_freq_mhz``:最小 CPU 频率 (MHz),即仅获取 ``ESP_PM_APB_FREQ_MAX`` 锁后所使用的频率。该字段可设置为晶振 (XTAL) 频率值,或者 XTAL 频率值除以整数。注意,10 MHz 是生成 1 MHz 的 REF_TICK 默认时钟所需的最小频率。 @@ -137,5 +137,4 @@ API 参考 ------------- .. include-build-file:: inc/esp_pm.inc -.. include-build-file:: inc/pm.inc diff --git a/examples/wifi/itwt/main/itwt.c b/examples/wifi/itwt/main/itwt.c index 8ce6db7e26d..23a60a3128a 100644 --- a/examples/wifi/itwt/main/itwt.c +++ b/examples/wifi/itwt/main/itwt.c @@ -254,7 +254,7 @@ void app_main(void) // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. - esp_pm_config_esp32c6_t pm_config = { + esp_pm_config_t pm_config = { .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, #if CONFIG_FREERTOS_USE_TICKLESS_IDLE diff --git a/examples/wifi/power_save/main/power_save.c b/examples/wifi/power_save/main/power_save.c index bd39b47d767..780a902eadf 100644 --- a/examples/wifi/power_save/main/power_save.c +++ b/examples/wifi/power_save/main/power_save.c @@ -95,19 +95,7 @@ void app_main(void) // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + esp_pm_config_t pm_config = { .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, #if CONFIG_FREERTOS_USE_TICKLESS_IDLE From 4c3d1e24d71ac18aea6dd10bc69320ad7e0dc007 Mon Sep 17 00:00:00 2001 From: jingli Date: Wed, 8 Feb 2023 11:32:57 +0800 Subject: [PATCH 2/4] codeclean: remove unused sleep related functions --- components/esp_hw_support/linker.lf | 1 - .../esp_hw_support/port/esp32/CMakeLists.txt | 1 - components/esp_hw_support/port/esp32/rtc_pm.c | 58 ------------ .../esp_hw_support/port/esp32/rtc_sleep.c | 5 - .../port/esp32c2/CMakeLists.txt | 1 - .../esp_hw_support/port/esp32c2/rtc_pm.c | 57 ----------- .../esp_hw_support/port/esp32c2/rtc_sleep.c | 6 -- .../esp_hw_support/port/esp32c2/rtc_time.c | 17 ---- .../port/esp32c3/CMakeLists.txt | 1 - .../esp_hw_support/port/esp32c3/rtc_pm.c | 59 ------------ .../esp_hw_support/port/esp32c3/rtc_sleep.c | 6 -- .../esp_hw_support/port/esp32c3/rtc_time.c | 17 ---- .../esp_hw_support/port/esp32c6/rtc_pm.c | 7 -- .../esp_hw_support/port/esp32c6/rtc_time.c | 15 --- .../esp_hw_support/port/esp32h2/rtc_time.c | 15 --- .../port/esp32h4/CMakeLists.txt | 1 - .../esp_hw_support/port/esp32h4/rtc_pm.c | 59 ------------ .../esp_hw_support/port/esp32h4/rtc_sleep.c | 6 -- .../esp_hw_support/port/esp32h4/rtc_time.c | 17 ---- .../port/esp32s2/CMakeLists.txt | 1 - .../esp_hw_support/port/esp32s2/rtc_pm.c | 59 ------------ .../esp_hw_support/port/esp32s2/rtc_sleep.c | 5 - .../esp_hw_support/port/esp32s2/rtc_time.c | 17 ---- .../port/esp32s3/CMakeLists.txt | 1 - .../esp_hw_support/port/esp32s3/rtc_pm.c | 57 ----------- .../esp_hw_support/port/esp32s3/rtc_sleep.c | 6 -- .../esp_hw_support/port/esp32s3/rtc_time.c | 17 ---- .../hal/esp32h2/include/hal/rtc_cntl_ll.h | 94 ------------------- components/soc/esp32/include/soc/rtc.h | 8 -- components/soc/esp32c2/include/soc/rtc.h | 34 ------- components/soc/esp32c3/include/soc/rtc.h | 11 --- components/soc/esp32c6/include/soc/rtc.h | 4 - components/soc/esp32h2/include/soc/rtc.h | 7 +- components/soc/esp32h4/include/soc/rtc.h | 11 --- components/soc/esp32s2/include/soc/rtc.h | 4 - components/soc/esp32s3/include/soc/rtc.h | 12 --- 36 files changed, 1 insertion(+), 696 deletions(-) delete mode 100644 components/esp_hw_support/port/esp32/rtc_pm.c delete mode 100644 components/esp_hw_support/port/esp32c2/rtc_pm.c delete mode 100644 components/esp_hw_support/port/esp32c3/rtc_pm.c delete mode 100644 components/esp_hw_support/port/esp32c6/rtc_pm.c delete mode 100644 components/esp_hw_support/port/esp32h4/rtc_pm.c delete mode 100644 components/esp_hw_support/port/esp32s2/rtc_pm.c delete mode 100644 components/esp_hw_support/port/esp32s3/rtc_pm.c delete mode 100644 components/hal/esp32h2/include/hal/rtc_cntl_ll.h diff --git a/components/esp_hw_support/linker.lf b/components/esp_hw_support/linker.lf index 3e85123b98a..2a06811a951 100644 --- a/components/esp_hw_support/linker.lf +++ b/components/esp_hw_support/linker.lf @@ -16,7 +16,6 @@ entries: if SOC_CONFIGURABLE_VDDSDIO_SUPPORTED: rtc_init:rtc_vddsdio_set_config (noflash) if IDF_TARGET_ESP32C6 = n && IDF_TARGET_ESP32H2 = n: # TODO: IDF-5645 - rtc_pm (noflash_text) rtc_sleep (noflash_text) rtc_time (noflash_text) if SOC_PMU_SUPPORTED = y: diff --git a/components/esp_hw_support/port/esp32/CMakeLists.txt b/components/esp_hw_support/port/esp32/CMakeLists.txt index 40ac8b93672..81d32061763 100644 --- a/components/esp_hw_support/port/esp32/CMakeLists.txt +++ b/components/esp_hw_support/port/esp32/CMakeLists.txt @@ -5,7 +5,6 @@ set(srcs "rtc_clk.c" "rtc_clk_init.c" "rtc_init.c" - "rtc_pm.c" "rtc_sleep.c" "rtc_time.c" "chip_info.c") diff --git a/components/esp_hw_support/port/esp32/rtc_pm.c b/components/esp_hw_support/port/esp32/rtc_pm.c deleted file mode 100644 index 43ca6cdd922..00000000000 --- a/components/esp_hw_support/port/esp32/rtc_pm.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "soc/rtc.h" - -typedef enum { - PM_LIGHT_SLEEP = BIT(2), /*!< WiFi PD, memory in light sleep */ -} pm_sleep_mode_t; - -typedef enum{ - PM_SW_NOREJECT = 0, - PM_SW_REJECT = 1 -} pm_sw_reject_t; - - -/* These MAC-related functions are defined in the closed source part of - * RTC library - */ -extern void pm_mac_init(void); -extern int pm_check_mac_idle(void); -extern void pm_mac_deinit(void); - -/* This sleep-related function is called from the closed source part of RTC - * library. - */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) -{ - (void) pmac_save_params; /* unused */ - - pm_mac_deinit(); - if (pm_check_mac_idle()) { - pm_mac_init(); - return PM_SW_REJECT; - } - - rtc_sleep_config_t cfg = { 0 }; - - switch (sleep_mode) { - case PM_LIGHT_SLEEP: - cfg.wifi_pd_en = 1; - cfg.dig_dbias_wak = 4; - cfg.dig_dbias_slp = 0; - cfg.rtc_dbias_wak = 0; - cfg.rtc_dbias_slp = 0; - cfg.lslp_meminf_pd = 1; - rtc_sleep_init(cfg); - break; - - default: - assert(0 && "unsupported sleep mode"); - } - return PM_SW_NOREJECT; -} diff --git a/components/esp_hw_support/port/esp32/rtc_sleep.c b/components/esp_hw_support/port/esp32/rtc_sleep.c index 98bfa9644a7..a4d4ed9ec9d 100644 --- a/components/esp_hw_support/port/esp32/rtc_sleep.c +++ b/components/esp_hw_support/port/esp32/rtc_sleep.c @@ -241,11 +241,6 @@ void rtc_sleep_low_init(uint32_t slowclk_period) REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CNTL_CK8M_WAIT_SLP_CYCLES); } -void rtc_sleep_set_wakeup_time(uint64_t t) -{ - rtc_cntl_ll_set_wakeup_timer(t); -} - /* Read back 'reject' status when waking from light or deep sleep */ static uint32_t rtc_sleep_finish(void); diff --git a/components/esp_hw_support/port/esp32c2/CMakeLists.txt b/components/esp_hw_support/port/esp32c2/CMakeLists.txt index df1877dec34..d0774a50297 100644 --- a/components/esp_hw_support/port/esp32c2/CMakeLists.txt +++ b/components/esp_hw_support/port/esp32c2/CMakeLists.txt @@ -1,7 +1,6 @@ set(srcs "rtc_clk_init.c" "rtc_clk.c" "rtc_init.c" - "rtc_pm.c" "rtc_sleep.c" "rtc_time.c" "chip_info.c") diff --git a/components/esp_hw_support/port/esp32c2/rtc_pm.c b/components/esp_hw_support/port/esp32c2/rtc_pm.c deleted file mode 100644 index cba8213e1d2..00000000000 --- a/components/esp_hw_support/port/esp32c2/rtc_pm.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "soc/rtc.h" -#include "soc/rtc_cntl_reg.h" - -typedef enum { - PM_LIGHT_SLEEP = BIT(2), /*!< WiFi PD, memory in light sleep */ -} pm_sleep_mode_t; - -typedef enum { - PM_SW_NOREJECT = 0, - PM_SW_REJECT = 1 -} pm_sw_reject_t; - - -/* These MAC-related functions are defined in the closed source part of - * RTC library - */ -extern void pm_mac_init(void); -extern int pm_check_mac_idle(void); -extern void pm_mac_deinit(void); - -/* This sleep-related function is called from the closed source part of RTC - * library. - */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) -{ - (void) pmac_save_params; /* unused */ - - pm_mac_deinit(); - if (pm_check_mac_idle()) { - pm_mac_init(); - return PM_SW_REJECT; - } - - rtc_sleep_config_t cfg = { 0 }; - - switch (sleep_mode) { - case PM_LIGHT_SLEEP: - cfg.dig_dbias_wak = 4; - cfg.dig_dbias_slp = 0; - cfg.rtc_dbias_wak = 0; - cfg.rtc_dbias_slp = 0; - rtc_sleep_init(cfg); - break; - - default: - assert(0 && "unsupported sleep mode"); - } - return PM_SW_NOREJECT; -} diff --git a/components/esp_hw_support/port/esp32c2/rtc_sleep.c b/components/esp_hw_support/port/esp32c2/rtc_sleep.c index 884301d1535..1cb648cf372 100644 --- a/components/esp_hw_support/port/esp32c2/rtc_sleep.c +++ b/components/esp_hw_support/port/esp32c2/rtc_sleep.c @@ -149,12 +149,6 @@ void rtc_sleep_low_init(uint32_t slowclk_period) REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CNTL_CK8M_WAIT_SLP_CYCLES); } -void rtc_sleep_set_wakeup_time(uint64_t t) -{ - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER0_REG, t & UINT32_MAX); - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER1_REG, t >> 32); -} - static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu); uint32_t rtc_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu) diff --git a/components/esp_hw_support/port/esp32c2/rtc_time.c b/components/esp_hw_support/port/esp32c2/rtc_time.c index b2a6f77a4c7..180c51b8bcb 100644 --- a/components/esp_hw_support/port/esp32c2/rtc_time.c +++ b/components/esp_hw_support/port/esp32c2/rtc_time.c @@ -170,23 +170,6 @@ uint64_t rtc_time_get(void) return rtc_cntl_ll_get_rtc_time(); } -uint64_t rtc_light_slp_time_get(void) -{ - uint64_t t_wake = READ_PERI_REG(RTC_CNTL_TIME_LOW0_REG); - t_wake |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH0_REG)) << 32; - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - return (t_wake - t_slp); -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { SET_PERI_REG_MASK(RTC_CNTL_SLOW_CLK_CONF_REG, RTC_CNTL_SLOW_CLK_NEXT_EDGE); diff --git a/components/esp_hw_support/port/esp32c3/CMakeLists.txt b/components/esp_hw_support/port/esp32c3/CMakeLists.txt index 6f5037848fe..b383b815a6a 100644 --- a/components/esp_hw_support/port/esp32c3/CMakeLists.txt +++ b/components/esp_hw_support/port/esp32c3/CMakeLists.txt @@ -1,7 +1,6 @@ set(srcs "rtc_clk_init.c" "rtc_clk.c" "rtc_init.c" - "rtc_pm.c" "rtc_sleep.c" "rtc_time.c" "chip_info.c" diff --git a/components/esp_hw_support/port/esp32c3/rtc_pm.c b/components/esp_hw_support/port/esp32c3/rtc_pm.c deleted file mode 100644 index 93174cd5190..00000000000 --- a/components/esp_hw_support/port/esp32c3/rtc_pm.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "soc/rtc.h" -#include "soc/rtc_cntl_reg.h" -#include "soc/syscon_reg.h" - -typedef enum { - PM_LIGHT_SLEEP = BIT(2), /*!< WiFi PD, memory in light sleep */ -} pm_sleep_mode_t; - -typedef enum { - PM_SW_NOREJECT = 0, - PM_SW_REJECT = 1 -} pm_sw_reject_t; - - -/* These MAC-related functions are defined in the closed source part of - * RTC library - */ -extern void pm_mac_init(void); -extern int pm_check_mac_idle(void); -extern void pm_mac_deinit(void); - -/* This sleep-related function is called from the closed source part of RTC - * library. - */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) -{ - (void) pmac_save_params; /* unused */ - - pm_mac_deinit(); - if (pm_check_mac_idle()) { - pm_mac_init(); - return PM_SW_REJECT; - } - - rtc_sleep_config_t cfg = { 0 }; - - switch (sleep_mode) { - case PM_LIGHT_SLEEP: - cfg.wifi_pd_en = 1; - cfg.dig_dbias_wak = 4; - cfg.dig_dbias_slp = 0; - cfg.rtc_dbias_wak = 0; - cfg.rtc_dbias_slp = 0; - rtc_sleep_init(cfg); - break; - - default: - assert(0 && "unsupported sleep mode"); - } - return PM_SW_NOREJECT; -} diff --git a/components/esp_hw_support/port/esp32c3/rtc_sleep.c b/components/esp_hw_support/port/esp32c3/rtc_sleep.c index 179f6e93dd7..df473914082 100644 --- a/components/esp_hw_support/port/esp32c3/rtc_sleep.c +++ b/components/esp_hw_support/port/esp32c3/rtc_sleep.c @@ -190,12 +190,6 @@ void rtc_sleep_low_init(uint32_t slowclk_period) REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CNTL_CK8M_WAIT_SLP_CYCLES); } -void rtc_sleep_set_wakeup_time(uint64_t t) -{ - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER0_REG, t & UINT32_MAX); - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER1_REG, t >> 32); -} - static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu); uint32_t rtc_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu) diff --git a/components/esp_hw_support/port/esp32c3/rtc_time.c b/components/esp_hw_support/port/esp32c3/rtc_time.c index 26327e58d39..aa277ba66c2 100644 --- a/components/esp_hw_support/port/esp32c3/rtc_time.c +++ b/components/esp_hw_support/port/esp32c3/rtc_time.c @@ -173,23 +173,6 @@ uint64_t rtc_time_get(void) return rtc_cntl_ll_get_rtc_time(); } -uint64_t rtc_light_slp_time_get(void) -{ - uint64_t t_wake = READ_PERI_REG(RTC_CNTL_TIME_LOW0_REG); - t_wake |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH0_REG)) << 32; - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - return (t_wake - t_slp); -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { SET_PERI_REG_MASK(RTC_CNTL_SLOW_CLK_CONF_REG, RTC_CNTL_SLOW_CLK_NEXT_EDGE); diff --git a/components/esp_hw_support/port/esp32c6/rtc_pm.c b/components/esp_hw_support/port/esp32c6/rtc_pm.c deleted file mode 100644 index 8a5daa45174..00000000000 --- a/components/esp_hw_support/port/esp32c6/rtc_pm.c +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -// TODO: IDF-5645 diff --git a/components/esp_hw_support/port/esp32c6/rtc_time.c b/components/esp_hw_support/port/esp32c6/rtc_time.c index 483b9fc0bca..184455b2605 100644 --- a/components/esp_hw_support/port/esp32c6/rtc_time.c +++ b/components/esp_hw_support/port/esp32c6/rtc_time.c @@ -210,21 +210,6 @@ uint64_t rtc_time_get(void) return lp_timer_hal_get_cycle_count(0); } -uint64_t rtc_light_slp_time_get(void) -{ - // TODO: IDF-5645 - ESP_EARLY_LOGW(TAG, "rtc_light_slp_time_get() has not been implemented yet"); - return 0; -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(LP_TIMER_MAIN_BUF1_LOW_REG); - t_slp |= ((uint64_t) READ_PERI_REG(LP_TIMER_MAIN_BUF1_HIGH_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { // TODO: IDF-5781 diff --git a/components/esp_hw_support/port/esp32h2/rtc_time.c b/components/esp_hw_support/port/esp32h2/rtc_time.c index 37ad5985846..b68488d7e3d 100644 --- a/components/esp_hw_support/port/esp32h2/rtc_time.c +++ b/components/esp_hw_support/port/esp32h2/rtc_time.c @@ -212,21 +212,6 @@ uint64_t rtc_time_get(void) return t; } -uint64_t rtc_light_slp_time_get(void) -{ - // TODO: IDF-6267 - ESP_EARLY_LOGW(TAG, "rtc_light_slp_time_get() has not been implemented yet"); - return 0; -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(LP_TIMER_MAIN_BUF1_LOW_REG); - t_slp |= ((uint64_t) READ_PERI_REG(LP_TIMER_MAIN_BUF1_HIGH_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { // TODO: IDF-6254 diff --git a/components/esp_hw_support/port/esp32h4/CMakeLists.txt b/components/esp_hw_support/port/esp32h4/CMakeLists.txt index 640f39022df..af789acfd65 100644 --- a/components/esp_hw_support/port/esp32h4/CMakeLists.txt +++ b/components/esp_hw_support/port/esp32h4/CMakeLists.txt @@ -1,7 +1,6 @@ set(srcs "rtc_clk_init.c" "rtc_clk.c" "rtc_init.c" - "rtc_pm.c" "rtc_sleep.c" "rtc_time.c" "chip_info.c" diff --git a/components/esp_hw_support/port/esp32h4/rtc_pm.c b/components/esp_hw_support/port/esp32h4/rtc_pm.c deleted file mode 100644 index 486f7617913..00000000000 --- a/components/esp_hw_support/port/esp32h4/rtc_pm.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "soc/rtc.h" -#include "soc/rtc_cntl_reg.h" -#include "soc/syscon_reg.h" - -typedef enum { - PM_LIGHT_SLEEP = BIT(2), /*!< WiFi PD, memory in light sleep */ -} pm_sleep_mode_t; - -typedef enum { - PM_SW_NOREJECT = 0, - PM_SW_REJECT = 1 -} pm_sw_reject_t; - - -/* These MAC-related functions are defined in the closed source part of - * RTC library - */ -extern void pm_mac_init(void); -extern int pm_check_mac_idle(void); -extern void pm_mac_deinit(void); - -/* This sleep-related function is called from the closed source part of RTC - * library. - */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) -{ - (void) pmac_save_params; /* unused */ - - pm_mac_deinit(); - if (pm_check_mac_idle()) { - pm_mac_init(); - return PM_SW_REJECT; - } - - rtc_sleep_config_t cfg = { 0 }; - - switch (sleep_mode) { - case PM_LIGHT_SLEEP: - // cfg.wifi_pd_en = 1; // ESP32-H4 TO-DO: IDF-3693 - cfg.dig_dbias_wak = 4; - cfg.dig_dbias_slp = 0; - cfg.rtc_dbias_wak = 0; - cfg.rtc_dbias_slp = 0; - rtc_sleep_init(cfg); - break; - - default: - assert(0 && "unsupported sleep mode"); - } - return PM_SW_NOREJECT; -} diff --git a/components/esp_hw_support/port/esp32h4/rtc_sleep.c b/components/esp_hw_support/port/esp32h4/rtc_sleep.c index 4ea3a706fc9..d1ffa8f2a99 100644 --- a/components/esp_hw_support/port/esp32h4/rtc_sleep.c +++ b/components/esp_hw_support/port/esp32h4/rtc_sleep.c @@ -288,12 +288,6 @@ void rtc_sleep_low_init(uint32_t slowclk_period) REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CNTL_CK8M_WAIT_SLP_CYCLES); } -void rtc_sleep_set_wakeup_time(uint64_t t) -{ - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER0_REG, t & UINT32_MAX); - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER1_REG, t >> 32); -} - static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu); uint32_t rtc_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu) diff --git a/components/esp_hw_support/port/esp32h4/rtc_time.c b/components/esp_hw_support/port/esp32h4/rtc_time.c index 743473a96ab..21b23649f82 100644 --- a/components/esp_hw_support/port/esp32h4/rtc_time.c +++ b/components/esp_hw_support/port/esp32h4/rtc_time.c @@ -167,23 +167,6 @@ uint64_t rtc_time_get(void) return rtc_cntl_ll_get_rtc_time(); } -uint64_t rtc_light_slp_time_get(void) -{ - uint64_t t_wake = READ_PERI_REG(RTC_CNTL_TIME_LOW0_REG); - t_wake |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH0_REG)) << 32; - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - return (t_wake - t_slp); -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { SET_PERI_REG_MASK(RTC_CNTL_SLOW_CLK_CONF_REG, RTC_CNTL_SLOW_CLK_NEXT_EDGE); diff --git a/components/esp_hw_support/port/esp32s2/CMakeLists.txt b/components/esp_hw_support/port/esp32s2/CMakeLists.txt index 15079598f99..a2a386d9d09 100644 --- a/components/esp_hw_support/port/esp32s2/CMakeLists.txt +++ b/components/esp_hw_support/port/esp32s2/CMakeLists.txt @@ -5,7 +5,6 @@ set(srcs "rtc_clk.c" "rtc_clk_init.c" "rtc_init.c" - "rtc_pm.c" "rtc_sleep.c" "rtc_time.c" "chip_info.c") diff --git a/components/esp_hw_support/port/esp32s2/rtc_pm.c b/components/esp_hw_support/port/esp32s2/rtc_pm.c deleted file mode 100644 index d1fb320830a..00000000000 --- a/components/esp_hw_support/port/esp32s2/rtc_pm.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "soc/rtc.h" -#include "soc/rtc_cntl_reg.h" -#include "soc/syscon_reg.h" - -typedef enum { - PM_LIGHT_SLEEP = BIT(2), /*!< WiFi PD, memory in light sleep */ -} pm_sleep_mode_t; - -typedef enum{ - PM_SW_NOREJECT = 0, - PM_SW_REJECT = 1 -} pm_sw_reject_t; - - -/* These MAC-related functions are defined in the closed source part of - * RTC library - */ -extern void pm_mac_init(void); -extern int pm_check_mac_idle(void); -extern void pm_mac_deinit(void); - -/* This sleep-related function is called from the closed source part of RTC - * library. - */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) -{ - (void) pmac_save_params; /* unused */ - - pm_mac_deinit(); - if (pm_check_mac_idle()) { - pm_mac_init(); - return PM_SW_REJECT; - } - - rtc_sleep_config_t cfg = { 0 }; - - switch (sleep_mode) { - case PM_LIGHT_SLEEP: - cfg.wifi_pd_en = 1; - cfg.dig_dbias_wak = 4; - cfg.dig_dbias_slp = 0; - cfg.rtc_dbias_wak = 0; - cfg.rtc_dbias_slp = 0; - rtc_sleep_init(cfg); - break; - - default: - assert(0 && "unsupported sleep mode"); - } - return PM_SW_NOREJECT; -} diff --git a/components/esp_hw_support/port/esp32s2/rtc_sleep.c b/components/esp_hw_support/port/esp32s2/rtc_sleep.c index c1382399345..578a6a5c628 100644 --- a/components/esp_hw_support/port/esp32s2/rtc_sleep.c +++ b/components/esp_hw_support/port/esp32s2/rtc_sleep.c @@ -185,11 +185,6 @@ void rtc_sleep_low_init(uint32_t slowclk_period) REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_XTL_BUF_WAIT, rtc_time_us_to_slowclk(RTC_CNTL_XTL_BUF_WAIT_SLP_US, slowclk_period)); } -void rtc_sleep_set_wakeup_time(uint64_t t) -{ - rtc_cntl_ll_set_wakeup_timer(t); -} - /* Read back 'reject' status when waking from light or deep sleep */ static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu); diff --git a/components/esp_hw_support/port/esp32s2/rtc_time.c b/components/esp_hw_support/port/esp32s2/rtc_time.c index 57e248e9f19..aae694037e4 100644 --- a/components/esp_hw_support/port/esp32s2/rtc_time.c +++ b/components/esp_hw_support/port/esp32s2/rtc_time.c @@ -238,23 +238,6 @@ uint64_t rtc_time_get(void) return rtc_cntl_ll_get_rtc_time(); } -uint64_t rtc_light_slp_time_get(void) -{ - uint64_t t_wake = READ_PERI_REG(RTC_CNTL_TIME_LOW0_REG); - t_wake |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH0_REG)) << 32; - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - return (t_wake - t_slp); -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { SET_PERI_REG_MASK(RTC_CNTL_SLOW_CLK_CONF_REG, RTC_CNTL_SLOW_CLK_NEXT_EDGE); diff --git a/components/esp_hw_support/port/esp32s3/CMakeLists.txt b/components/esp_hw_support/port/esp32s3/CMakeLists.txt index b41200f13e9..bb4a29c5af0 100644 --- a/components/esp_hw_support/port/esp32s3/CMakeLists.txt +++ b/components/esp_hw_support/port/esp32s3/CMakeLists.txt @@ -5,7 +5,6 @@ set(srcs "rtc_clk.c" "rtc_clk_init.c" "rtc_init.c" - "rtc_pm.c" "rtc_sleep.c" "rtc_time.c" "chip_info.c" diff --git a/components/esp_hw_support/port/esp32s3/rtc_pm.c b/components/esp_hw_support/port/esp32s3/rtc_pm.c deleted file mode 100644 index 4bf523eb203..00000000000 --- a/components/esp_hw_support/port/esp32s3/rtc_pm.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "soc/rtc.h" -#include "soc/rtc_cntl_reg.h" -#include "soc/syscon_reg.h" - -typedef enum { - PM_LIGHT_SLEEP = BIT(2), /*!< WiFi PD, memory in light sleep */ -} pm_sleep_mode_t; - -typedef enum { - PM_SW_NOREJECT = 0, - PM_SW_REJECT = 1 -} pm_sw_reject_t; - - -/* These MAC-related functions are defined in the closed source part of - * RTC library - */ -extern void pm_mac_init(void); -extern int pm_check_mac_idle(void); -extern void pm_mac_deinit(void); - -/* This sleep-related function is called from the closed source part of RTC - * library. - */ -pm_sw_reject_t pm_set_sleep_mode(pm_sleep_mode_t sleep_mode, void(*pmac_save_params)(void)) -{ - (void) pmac_save_params; /* unused */ - - pm_mac_deinit(); - if (pm_check_mac_idle()) { - pm_mac_init(); - return PM_SW_REJECT; - } - - rtc_sleep_config_t cfg = { 0 }; - - switch (sleep_mode) { - case PM_LIGHT_SLEEP: - cfg.wifi_pd_en = 1; - cfg.dig_dbias_slp = 0; - cfg.rtc_dbias_slp = 0; - rtc_sleep_init(cfg); - break; - - default: - assert(0 && "unsupported sleep mode"); - } - return PM_SW_NOREJECT; -} diff --git a/components/esp_hw_support/port/esp32s3/rtc_sleep.c b/components/esp_hw_support/port/esp32s3/rtc_sleep.c index 14d3cf3876d..cc9d24fa2bb 100644 --- a/components/esp_hw_support/port/esp32s3/rtc_sleep.c +++ b/components/esp_hw_support/port/esp32s3/rtc_sleep.c @@ -245,12 +245,6 @@ void rtc_sleep_low_init(uint32_t slowclk_period) REG_SET_FIELD(RTC_CNTL_TIMER1_REG, RTC_CNTL_CK8M_WAIT, RTC_CNTL_CK8M_WAIT_SLP_CYCLES); } -void rtc_sleep_set_wakeup_time(uint64_t t) -{ - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER0_REG, t & UINT32_MAX); - WRITE_PERI_REG(RTC_CNTL_SLP_TIMER1_REG, t >> 32); -} - static uint32_t rtc_sleep_finish(uint32_t lslp_mem_inf_fpu); __attribute__((weak)) uint32_t rtc_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu) diff --git a/components/esp_hw_support/port/esp32s3/rtc_time.c b/components/esp_hw_support/port/esp32s3/rtc_time.c index 6333b68a19c..ff58ed4d71d 100644 --- a/components/esp_hw_support/port/esp32s3/rtc_time.c +++ b/components/esp_hw_support/port/esp32s3/rtc_time.c @@ -172,23 +172,6 @@ uint64_t rtc_time_get(void) return rtc_cntl_ll_get_rtc_time(); } -uint64_t rtc_light_slp_time_get(void) -{ - uint64_t t_wake = READ_PERI_REG(RTC_CNTL_TIME_LOW0_REG); - t_wake |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH0_REG)) << 32; - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - return (t_wake - t_slp); -} - -uint64_t rtc_deep_slp_time_get(void) -{ - uint64_t t_slp = READ_PERI_REG(RTC_CNTL_TIME_LOW1_REG); - t_slp |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME_HIGH1_REG)) << 32; - uint64_t t_wake = rtc_time_get(); - return (t_wake - t_slp); -} - void rtc_clk_wait_for_slow_cycle(void) //This function may not by useful any more { SET_PERI_REG_MASK(RTC_CNTL_SLOW_CLK_CONF_REG, RTC_CNTL_SLOW_CLK_NEXT_EDGE); diff --git a/components/hal/esp32h2/include/hal/rtc_cntl_ll.h b/components/hal/esp32h2/include/hal/rtc_cntl_ll.h deleted file mode 100644 index 2df27b8dcff..00000000000 --- a/components/hal/esp32h2/include/hal/rtc_cntl_ll.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "soc/soc.h" -#include "soc/rtc.h" -#include "esp_attr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -FORCE_INLINE_ATTR void rtc_cntl_ll_set_wakeup_timer(uint64_t t) -{ - // ESP32H2-TODO: IDF-6401 -} - -FORCE_INLINE_ATTR uint32_t rtc_cntl_ll_gpio_get_wakeup_pins(void) -{ - return 0; - // ESP32H2-TODO: IDF-6401 -} - -FORCE_INLINE_ATTR uint32_t rtc_cntl_ll_gpio_get_wakeup_status(void) -{ - // ESP32H2-TODO: IDF-6401 - return 0; -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_gpio_clear_wakeup_status(void) -{ - // ESP32H2-TODO: IDF-6401 -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_gpio_set_wakeup_pins(void) -{ - // ESP32H2-TODO: IDF-5718 -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_gpio_clear_wakeup_pins(void) -{ - // ESP32H2-TODO: IDF-5718 -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_set_cpu_retention_link_addr(uint32_t addr) -{ - // ESP32H2-TODO: IDF-5718 has removed the retention feature -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_enable_cpu_retention_clock(void) -{ - // ESP32H2-TODO: IDF-5718 has removed the retention feature -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_enable_cpu_retention(void) -{ - // ESP32H2-TODO: IDF-5718 has removed the retention feature -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_disable_cpu_retention(void) -{ - // ESP32H2-TODO: IDF-5718 has removed the retention feature -} - -FORCE_INLINE_ATTR void rtc_cntl_ll_sleep_enable(void) -{ - // TODO: IDF-6572 -} - -FORCE_INLINE_ATTR uint64_t rtc_cntl_ll_get_rtc_time(void) -{ - // TODO: IDF-6572 - return 0; -} - -FORCE_INLINE_ATTR uint64_t rtc_cntl_ll_time_to_count(uint64_t time_in_us) -{ - // TODO: IDF-6572 - return 0; -} - -FORCE_INLINE_ATTR uint32_t rtc_cntl_ll_get_wakeup_cause(void) -{ - // TODO: IDF-6572 - return 0; -} - -#ifdef __cplusplus -} -#endif diff --git a/components/soc/esp32/include/soc/rtc.h b/components/soc/esp32/include/soc/rtc.h index cfc583ad491..4881a174a2a 100644 --- a/components/soc/esp32/include/soc/rtc.h +++ b/components/soc/esp32/include/soc/rtc.h @@ -573,14 +573,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg); */ void rtc_sleep_low_init(uint32_t slowclk_period); -/** - * @brief Set target value of RTC counter for RTC_TIMER_TRIG_EN wakeup source - * @param t value of RTC counter at which wakeup from sleep will happen; - * only the lower 48 bits are used - */ -void rtc_sleep_set_wakeup_time(uint64_t t); - - #define RTC_EXT0_TRIG_EN BIT(0) //!< EXT0 GPIO wakeup #define RTC_EXT1_TRIG_EN BIT(1) //!< EXT1 GPIO wakeup #define RTC_GPIO_TRIG_EN BIT(2) //!< GPIO wakeup (light sleep only) diff --git a/components/soc/esp32c2/include/soc/rtc.h b/components/soc/esp32c2/include/soc/rtc.h index b838418bed5..4f86b869435 100644 --- a/components/soc/esp32c2/include/soc/rtc.h +++ b/components/soc/esp32c2/include/soc/rtc.h @@ -460,10 +460,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * @@ -602,13 +598,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg); */ void rtc_sleep_low_init(uint32_t slowclk_period); -/** - * @brief Set target value of RTC counter for RTC_TIMER_TRIG_EN wakeup source - * @param t value of RTC counter at which wakeup from sleep will happen; - * only the lower 48 bits are used - */ -void rtc_sleep_set_wakeup_time(uint64_t t); - #define RTC_GPIO_TRIG_EN BIT(2) //!< GPIO wakeup #define RTC_TIMER_TRIG_EN BIT(3) //!< Timer wakeup #define RTC_WIFI_TRIG_EN BIT(5) //!< WIFI wakeup (light sleep only) @@ -659,29 +648,6 @@ void rtc_sleep_set_wakeup_time(uint64_t t); */ uint32_t rtc_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu); -/** - * @brief Enter deep sleep mode - * - * Similar to rtc_sleep_start(), but additionally uses hardware to calculate the CRC value - * of RTC FAST memory. On wake, this CRC is used to determine if a deep sleep wake - * stub is valid to execute (if a wake address is set). - * - * No RAM is accessed while calculating the CRC and going into deep sleep, which makes - * this function safe to use even if the caller's stack is in RTC FAST memory. - * - * @note If no deep sleep wake stub address is set then calling rtc_sleep_start() will - * have the same effect and takes less time as CRC calculation is skipped. - * - * @note This function should only be called after rtc_sleep_init() has been called to - * configure the system for deep sleep. - * - * @param wakeup_opt - same as for rtc_sleep_start - * @param reject_opt - same as for rtc_sleep_start - * - * @return non-zero if sleep was rejected by hardware - */ -uint32_t rtc_deep_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt); - /** * RTC power and clock control initialization settings */ diff --git a/components/soc/esp32c3/include/soc/rtc.h b/components/soc/esp32c3/include/soc/rtc.h index 8b569200827..59b1dcdd21a 100644 --- a/components/soc/esp32c3/include/soc/rtc.h +++ b/components/soc/esp32c3/include/soc/rtc.h @@ -483,10 +483,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * @@ -643,13 +639,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg); */ void rtc_sleep_low_init(uint32_t slowclk_period); -/** - * @brief Set target value of RTC counter for RTC_TIMER_TRIG_EN wakeup source - * @param t value of RTC counter at which wakeup from sleep will happen; - * only the lower 48 bits are used - */ -void rtc_sleep_set_wakeup_time(uint64_t t); - #define RTC_GPIO_TRIG_EN BIT(2) //!< GPIO wakeup #define RTC_TIMER_TRIG_EN BIT(3) //!< Timer wakeup #define RTC_WIFI_TRIG_EN BIT(5) //!< WIFI wakeup (light sleep only) diff --git a/components/soc/esp32c6/include/soc/rtc.h b/components/soc/esp32c6/include/soc/rtc.h index 734f4f24f65..f0c6c2fc13e 100644 --- a/components/soc/esp32c6/include/soc/rtc.h +++ b/components/soc/esp32c6/include/soc/rtc.h @@ -446,10 +446,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * diff --git a/components/soc/esp32h2/include/soc/rtc.h b/components/soc/esp32h2/include/soc/rtc.h index 38e25292f2a..ed752215448 100644 --- a/components/soc/esp32h2/include/soc/rtc.h +++ b/components/soc/esp32h2/include/soc/rtc.h @@ -17,7 +17,7 @@ extern "C" { /** * @file rtc.h - * @brief Low-level RTC power, clock, and sleep functions. + * @brief Low-level RTC power, clock functions. * * Functions in this file facilitate configuration of ESP32's RTC_CNTL peripheral. * RTC_CNTL peripheral handles many functions: @@ -456,10 +456,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * @@ -497,7 +493,6 @@ bool rtc_dig_8m_enabled(void); */ uint32_t rtc_clk_freq_cal(uint32_t cal_val); - // -------------------------- CLOCK TREE DEFS ALIAS ---------------------------- // **WARNING**: The following are only for backwards compatibility. // Please use the declarations in soc/clk_tree_defs.h instead. diff --git a/components/soc/esp32h4/include/soc/rtc.h b/components/soc/esp32h4/include/soc/rtc.h index bbdd6397b8f..338252d5f03 100644 --- a/components/soc/esp32h4/include/soc/rtc.h +++ b/components/soc/esp32h4/include/soc/rtc.h @@ -499,10 +499,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * @@ -657,13 +653,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg); */ void rtc_sleep_low_init(uint32_t slowclk_period); -/** - * @brief Set target value of RTC counter for RTC_TIMER_TRIG_EN wakeup source - * @param t value of RTC counter at which wakeup from sleep will happen; - * only the lower 48 bits are used - */ -void rtc_sleep_set_wakeup_time(uint64_t t); - #define RTC_GPIO_TRIG_EN BIT(2) //!< GPIO wakeup #define RTC_TIMER_TRIG_EN BIT(3) //!< Timer wakeup #define RTC_WIFI_TRIG_EN BIT(5) //!< WIFI wakeup (light sleep only) diff --git a/components/soc/esp32s2/include/soc/rtc.h b/components/soc/esp32s2/include/soc/rtc.h index b3321905b83..0436e5b86fb 100644 --- a/components/soc/esp32s2/include/soc/rtc.h +++ b/components/soc/esp32s2/include/soc/rtc.h @@ -508,10 +508,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * diff --git a/components/soc/esp32s3/include/soc/rtc.h b/components/soc/esp32s3/include/soc/rtc.h index 82518b83d7f..2a45f36a7e3 100644 --- a/components/soc/esp32s3/include/soc/rtc.h +++ b/components/soc/esp32s3/include/soc/rtc.h @@ -508,10 +508,6 @@ uint64_t rtc_time_slowclk_to_us(uint64_t rtc_cycles, uint32_t period); */ uint64_t rtc_time_get(void); -uint64_t rtc_light_slp_time_get(void); - -uint64_t rtc_deep_slp_time_get(void); - /** * @brief Busy loop until next RTC_SLOW_CLK cycle * @@ -667,14 +663,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg); */ void rtc_sleep_low_init(uint32_t slowclk_period); -/** - * @brief Set target value of RTC counter for RTC_TIMER_TRIG_EN wakeup source - * @param t value of RTC counter at which wakeup from sleep will happen; - * only the lower 48 bits are used - */ -void rtc_sleep_set_wakeup_time(uint64_t t); - - #define RTC_EXT0_TRIG_EN BIT(0) //!< EXT0 GPIO wakeup #define RTC_EXT1_TRIG_EN BIT(1) //!< EXT1 GPIO wakeup #define RTC_GPIO_TRIG_EN BIT(2) //!< GPIO wakeup (light sleep only) From eede7295d14b159b84e5ebdbf850727299a74672 Mon Sep 17 00:00:00 2001 From: jingli Date: Wed, 22 Feb 2023 21:40:21 +0800 Subject: [PATCH 3/4] docs: upate migration guides for deprecated type and header file in power management component --- docs/en/migration-guides/release-5.x/5.1/index.rst | 1 + docs/en/migration-guides/release-5.x/5.1/system.rst | 10 ++++++++++ docs/zh_CN/migration-guides/release-5.x/5.1/index.rst | 1 + docs/zh_CN/migration-guides/release-5.x/5.1/system.rst | 10 ++++++++++ 4 files changed, 22 insertions(+) create mode 100644 docs/en/migration-guides/release-5.x/5.1/system.rst create mode 100644 docs/zh_CN/migration-guides/release-5.x/5.1/system.rst diff --git a/docs/en/migration-guides/release-5.x/5.1/index.rst b/docs/en/migration-guides/release-5.x/5.1/index.rst index 35a89aca69f..4a3c4b65d7b 100644 --- a/docs/en/migration-guides/release-5.x/5.1/index.rst +++ b/docs/en/migration-guides/release-5.x/5.1/index.rst @@ -10,3 +10,4 @@ Migration from 5.0 to 5.1 peripherals storage networking + system diff --git a/docs/en/migration-guides/release-5.x/5.1/system.rst b/docs/en/migration-guides/release-5.x/5.1/system.rst new file mode 100644 index 00000000000..e6fe37009fa --- /dev/null +++ b/docs/en/migration-guides/release-5.x/5.1/system.rst @@ -0,0 +1,10 @@ +System +====== + +:link_to_translation:`zh_CN:[中文]` + +Power Management +----------------------- + +* ``esp_pm_config_esp32xx_t`` is deprecated, use ``esp_pm_config_t`` instead. +* ``esp32xx/pm.h`` is deprecated, use ``esp_pm.h`` instead. diff --git a/docs/zh_CN/migration-guides/release-5.x/5.1/index.rst b/docs/zh_CN/migration-guides/release-5.x/5.1/index.rst index 03c107bdac1..c95cac366cc 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.1/index.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.1/index.rst @@ -10,3 +10,4 @@ peripherals storage networking + system diff --git a/docs/zh_CN/migration-guides/release-5.x/5.1/system.rst b/docs/zh_CN/migration-guides/release-5.x/5.1/system.rst new file mode 100644 index 00000000000..d6da2d7bba6 --- /dev/null +++ b/docs/zh_CN/migration-guides/release-5.x/5.1/system.rst @@ -0,0 +1,10 @@ +系统 +====== + +:link_to_translation:`en:[英文]` + +电源管理 +---------- + +* ``esp_pm_config_esp32xx_t`` 已被弃用,应使用 ``esp_pm_config_t`` 替代。 +* ``esp32xx/pm.h`` 已被弃用,应使用 ``esp_pm.h`` 替代。 From 3a648e8ed60eb1db3b1f154b3edb4c63b5930e34 Mon Sep 17 00:00:00 2001 From: jingli Date: Thu, 23 Feb 2023 10:06:22 +0800 Subject: [PATCH 4/4] ci: h2 does not support deep sleep currently, comment some codes to avoid ci error --- components/esp_hw_support/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index f20e393137e..d43e0332e2f 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -107,6 +107,7 @@ if(NOT BOOTLOADER_BUILD) "adc_share_hw_ctrl.c" # TODO: IDF-6215 "sleep_cpu.c" # TODO: IDF-6267 "sleep_modes.c" # TODO: IDF-6267 + "sleep_wake_stub.c" # TODO: IDF-6267 ) endif() else()