diff --git a/components/esp_pm/include/esp32c6/pm.h b/components/esp_pm/include/esp32c6/pm.h new file mode 100644 index 0000000000..6255cccad1 --- /dev/null +++ b/components/esp_pm/include/esp32c6/pm.h @@ -0,0 +1,32 @@ +/* + * 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 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 diff --git a/components/esp_pm/include/esp_pm.h b/components/esp_pm/include/esp_pm.h index 64ef7b36ff..32f711e520 100644 --- a/components/esp_pm/include/esp_pm.h +++ b/components/esp_pm/include/esp_pm.h @@ -21,6 +21,8 @@ #include "esp32h2/pm.h" #elif CONFIG_IDF_TARGET_ESP32C2 #include "esp32c2/pm.h" +#elif CONFIG_IDF_TARGET_ESP32C6 +#include "esp32c6/pm.h" #endif #ifdef __cplusplus diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index 36ece69223..0d4094aceb 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -56,6 +56,9 @@ #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" #endif #define MHZ (1000000) @@ -85,13 +88,15 @@ #define REF_CLK_DIV_MIN 2 #elif CONFIG_IDF_TARGET_ESP32S3 /* Minimal divider at which REF_CLK_FREQ can be obtained */ -#define REF_CLK_DIV_MIN 2 +#define REF_CLK_DIV_MIN 2 // TODO: IDF-5660 #elif CONFIG_IDF_TARGET_ESP32C3 #define REF_CLK_DIV_MIN 2 #elif CONFIG_IDF_TARGET_ESP32H2 #define REF_CLK_DIV_MIN 2 #elif CONFIG_IDF_TARGET_ESP32C2 #define REF_CLK_DIV_MIN 2 +#elif CONFIG_IDF_TARGET_ESP32C6 +#define REF_CLK_DIV_MIN 2 #endif #ifdef CONFIG_PM_PROFILING @@ -228,6 +233,8 @@ esp_err_t esp_pm_configure(const void* vconfig) const esp_pm_config_esp32h2_t* config = (const esp_pm_config_esp32h2_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; #endif #ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE @@ -338,6 +345,8 @@ esp_err_t esp_pm_get_configuration(void* vconfig) esp_pm_config_esp32h2_t* config = (esp_pm_config_esp32h2_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; #endif portENTER_CRITICAL(&s_switch_lock); @@ -782,6 +791,8 @@ void esp_pm_impl_init(void) esp_pm_config_esp32h2_t cfg = { #elif CONFIG_IDF_TARGET_ESP32C2 esp_pm_config_esp32c2_t cfg = { +#elif CONFIG_IDF_TARGET_ESP32C6 + esp_pm_config_esp32c6_t cfg = { #endif .max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, .min_freq_mhz = xtal_freq_mhz, diff --git a/components/esp_pm/test/test_pm.c b/components/esp_pm/test/test_pm.c index ca4b913f99..83f4d8bcd8 100644 --- a/components/esp_pm/test/test_pm.c +++ b/components/esp_pm/test/test_pm.c @@ -54,6 +54,8 @@ static void switch_freq(int mhz) esp_pm_config_esp32c3_t pm_config = { #elif CONFIG_IDF_TARGET_ESP32H2 esp_pm_config_esp32h2_t pm_config = { +#elif CONFIG_IDF_TARGET_ESP32C6 + esp_pm_config_esp32c6_t pm_config = { #endif .max_freq_mhz = mhz, .min_freq_mhz = MIN(mhz, xtal_freq_mhz), @@ -109,6 +111,8 @@ static void light_sleep_enable(void) esp_pm_config_esp32c3_t pm_config = { #elif CONFIG_IDF_TARGET_ESP32H2 esp_pm_config_esp32h2_t pm_config = { +#elif CONFIG_IDF_TARGET_ESP32C6 + esp_pm_config_esp32c6_t pm_config = { #endif .max_freq_mhz = cur_freq_mhz, .min_freq_mhz = xtal_freq, @@ -133,6 +137,8 @@ static void light_sleep_disable(void) esp_pm_config_esp32c3_t pm_config = { #elif CONFIG_IDF_TARGET_ESP32H2 esp_pm_config_esp32h2_t pm_config = { +#elif CONFIG_IDF_TARGET_ESP32C6 + esp_pm_config_esp32c6_t pm_config = { #endif .max_freq_mhz = cur_freq_mhz, .min_freq_mhz = cur_freq_mhz,