pm: esp32c6: Power management support
Power management support (light/deep sleep) for ESP32C6 Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
This commit is contained in:
parent
f74592dcde
commit
3ee2a62a55
5 changed files with 95 additions and 9 deletions
|
@ -14,6 +14,8 @@ config SOC_SERIES_ESP32C6
|
|||
select RISCV_ISA_EXT_ZICSR
|
||||
select HAS_ESPRESSIF_HAL
|
||||
select XIP if !MCUBOOT
|
||||
select HAS_PM
|
||||
select HAS_POWEROFF
|
||||
|
||||
if SOC_SERIES_ESP32C6
|
||||
|
||||
|
|
44
soc/espressif/esp32c6/power.c
Normal file
44
soc/espressif/esp32c6/power.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/pm/pm.h>
|
||||
#include <zephyr/irq.h>
|
||||
#include <esp_sleep.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
|
||||
|
||||
/* Invoke Low Power/System Off specific Tasks */
|
||||
void pm_state_set(enum pm_state state, uint8_t substate_id)
|
||||
{
|
||||
ARG_UNUSED(substate_id);
|
||||
|
||||
switch (state) {
|
||||
case PM_STATE_STANDBY:
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
default:
|
||||
LOG_DBG("Unsupported power state %u", state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle SOC specific activity after Low Power Mode Exit */
|
||||
void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
|
||||
{
|
||||
ARG_UNUSED(substate_id);
|
||||
|
||||
switch (state) {
|
||||
case PM_STATE_STANDBY:
|
||||
irq_unlock(MSTATUS_IEN);
|
||||
__asm__ volatile("wfi");
|
||||
esp_light_sleep_start();
|
||||
break;
|
||||
default:
|
||||
LOG_DBG("Unsupported power state %u", state);
|
||||
break;
|
||||
}
|
||||
}
|
15
soc/espressif/esp32c6/poweroff.c
Normal file
15
soc/espressif/esp32c6/poweroff.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/sys/poweroff.h>
|
||||
|
||||
#include <esp_sleep.h>
|
||||
|
||||
void z_sys_poweroff(void)
|
||||
{
|
||||
/* Forces RTC domain to be always on */
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
esp_deep_sleep_start();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue