mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp32c6: add esp_pm support
This commit is contained in:
parent
62f9ddcb82
commit
a7b549acca
32
components/esp_pm/include/esp32c6/pm.h
Normal file
32
components/esp_pm/include/esp32c6/pm.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#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
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user