1 /* 2 * Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/pm/pm.h> 8 #include <zephyr/irq.h> 9 #include <esp_sleep.h> 10 11 #include <zephyr/logging/log.h> 12 LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL); 13 14 /* Invoke Low Power/System Off specific Tasks */ pm_state_set(enum pm_state state,uint8_t substate_id)15void pm_state_set(enum pm_state state, uint8_t substate_id) 16 { 17 ARG_UNUSED(substate_id); 18 19 switch (state) { 20 case PM_STATE_STANDBY: 21 /* Nothing to do. */ 22 break; 23 default: 24 LOG_DBG("Unsupported power state %u", state); 25 break; 26 } 27 } 28 29 /* Handle SOC specific activity after Low Power Mode Exit */ pm_state_exit_post_ops(enum pm_state state,uint8_t substate_id)30void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) 31 { 32 ARG_UNUSED(substate_id); 33 34 switch (state) { 35 case PM_STATE_STANDBY: 36 irq_unlock(MSTATUS_IEN); 37 __asm__ volatile("wfi"); 38 esp_light_sleep_start(); 39 break; 40 default: 41 LOG_DBG("Unsupported power state %u", state); 42 break; 43 } 44 } 45