Power Management: support DFS

This commit is contained in:
Li Shuai
2022-11-07 22:10:22 +08:00
committed by wuzhenghui
parent 2b5618606b
commit 0f6cda1dd3
6 changed files with 19 additions and 11 deletions

View File

@@ -470,7 +470,7 @@ esp_err_t twai_driver_install(const twai_general_config_t *g_config, const twai_
p_twai_obj_dummy->module = twai_controller_periph_signals.controllers[controller_id].module; p_twai_obj_dummy->module = twai_controller_periph_signals.controllers[controller_id].module;
#ifdef CONFIG_PM_ENABLE #if CONFIG_PM_ENABLE && SOC_TWAI_CLK_SUPPORT_APB
if (clk_src == TWAI_CLK_SRC_APB) { if (clk_src == TWAI_CLK_SRC_APB) {
// TODO: pm_lock name should also reflect the controller ID // TODO: pm_lock name should also reflect the controller ID
ret = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "twai", &(p_twai_obj_dummy->pm_lock)); ret = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "twai", &(p_twai_obj_dummy->pm_lock));
@@ -478,7 +478,7 @@ esp_err_t twai_driver_install(const twai_general_config_t *g_config, const twai_
goto err; goto err;
} }
} }
#endif //CONFIG_PM_ENABLE #endif //CONFIG_PM_ENABLE && SOC_TWAI_CLK_SUPPORT_APB
//Initialize TWAI peripheral registers, and allocate interrupt //Initialize TWAI peripheral registers, and allocate interrupt
TWAI_ENTER_CRITICAL(); TWAI_ENTER_CRITICAL();

View File

@@ -2,10 +2,10 @@ menu "Power Management"
config PM_ENABLE config PM_ENABLE
bool "Support for power management" bool "Support for power management"
# SMP FreeRTOS currently does not support power management IDF-4997 # SMP FreeRTOS currently does not support power management IDF-4997
# ESP32C6 currently does not support power management IDF-5347 IDF-6270 # ESP32H2 currently does not support power management IDF-6270
# Note. Disabling this option for C6 will also cause all sdkconfig.release test cases run without pm enabled # Note. Disabling this option for H2 will also cause all sdkconfig.release test cases run without pm enabled
# ORed with __DOXYGEN__ to pass C6 docs build, need to remove when pm is supported on C6 # ORed with __DOXYGEN__ to pass H2 docs build, need to remove when pm is supported on H2
depends on (!FREERTOS_SMP && !IDF_TARGET_ESP32C6 && !IDF_TARGET_ESP32H2) || __DOXYGEN__ depends on (!FREERTOS_SMP && !IDF_TARGET_ESP32H2) || __DOXYGEN__
default n default n
help help
If enabled, application is compiled with support for power management. If enabled, application is compiled with support for power management.

View File

@@ -288,6 +288,13 @@ esp_err_t esp_pm_configure(const void* vconfig)
*/ */
apb_max_freq = 80; apb_max_freq = 80;
} }
#elif CONFIG_IDF_TARGET_ESP32C6
/* Maximum SOC APB clock frequency is 40 MHz, maximum Modem (WiFi,
* Bluetooth, etc..) APB clock frequency is 80 MHz */
const int soc_apb_clk_freq = esp_clk_apb_freq() / MHZ;
const int modem_apb_clk_freq = MODEM_APB_CLK_FREQ / MHZ;
const int apb_clk_freq = MAX(soc_apb_clk_freq, modem_apb_clk_freq);
int apb_max_freq = MIN(max_freq_mhz, apb_clk_freq); /* CPU frequency in APB_MAX mode */
#else #else
int apb_max_freq = MIN(max_freq_mhz, 80); /* CPU frequency in APB_MAX mode */ int apb_max_freq = MIN(max_freq_mhz, 80); /* CPU frequency in APB_MAX mode */
#endif #endif

View File

@@ -141,6 +141,7 @@
#define EFUSE_CLK_FREQ_ROM ( 20*1000000) #define EFUSE_CLK_FREQ_ROM ( 20*1000000)
#define CPU_CLK_FREQ APB_CLK_FREQ #define CPU_CLK_FREQ APB_CLK_FREQ
#define APB_CLK_FREQ ( 40*1000000 ) #define APB_CLK_FREQ ( 40*1000000 )
#define MODEM_APB_CLK_FREQ ( 80*1000000 )
#define REF_CLK_FREQ ( 1000000 ) #define REF_CLK_FREQ ( 1000000 )
#define RTC_CLK_FREQ (20*1000000) #define RTC_CLK_FREQ (20*1000000)
#define XTAL_CLK_FREQ (40*1000000) #define XTAL_CLK_FREQ (40*1000000)

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -27,6 +27,7 @@
#include "cmd_system.h" #include "cmd_system.h"
#include "wifi_cmd.h" #include "wifi_cmd.h"
#include "esp_wifi_he.h" #include "esp_wifi_he.h"
#include "esp_pm.h"
/******************************************************* /*******************************************************
* Constants * Constants
@@ -244,10 +245,7 @@ void app_main(void)
} }
// TODO: WIFI-5150 // TODO: WIFI-5150
#if CONFIG_PM_ENABLE #if CONFIG_PM_ENABLE && 0
io_toggle_pmu_internal_signal_map_to_io_init();
io_toggle_gpio_init();
sleep_clock_system_retention_init(); sleep_clock_system_retention_init();
sleep_clock_modem_retention_init(); sleep_clock_modem_retention_init();
sleep_peripheral_retention_init(); sleep_peripheral_retention_init();

View File

@@ -105,6 +105,8 @@ void app_main(void)
esp_pm_config_esp32s3_t pm_config = { esp_pm_config_esp32s3_t pm_config = {
#elif CONFIG_IDF_TARGET_ESP32C2 #elif CONFIG_IDF_TARGET_ESP32C2
esp_pm_config_esp32c2_t pm_config = { esp_pm_config_esp32c2_t pm_config = {
#elif CONFIG_IDF_TARGET_ESP32C6
esp_pm_config_esp32c6_t pm_config = {
#endif #endif
.max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ,
.min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ,