1 /* 2 * Copyright (c) 2023 Renesas Electronics Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/init.h> 8 #include <zephyr/pm/pm.h> 9 #include <zephyr/logging/log.h> 10 #include <DA1469xAB.h> 11 #include <da1469x_clock.h> 12 #include <da1469x_sleep.h> 13 14 LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL); 15 pm_state_set(enum pm_state state,uint8_t substate_id)16void pm_state_set(enum pm_state state, uint8_t substate_id) 17 { 18 ARG_UNUSED(substate_id); 19 20 switch (state) { 21 case PM_STATE_STANDBY: 22 /* We enter here with interrupts disabled by BASEPRI which prevents wfi from 23 * waking up on interrupts. Need to disable interrupts by PRIMASK instead and 24 * reset BASEPRI to 0. 25 */ 26 __disable_irq(); 27 arch_irq_unlock(0); 28 29 da1469x_sleep(); 30 31 break; 32 default: 33 LOG_DBG("Unsupported power state %u", state); 34 break; 35 } 36 } 37 pm_state_exit_post_ops(enum pm_state state,uint8_t substate_id)38void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) 39 { 40 ARG_UNUSED(state); 41 ARG_UNUSED(substate_id); 42 43 if (state == PM_STATE_STANDBY) { 44 __enable_irq(); 45 } 46 } 47 renesas_da1469x_pm_init(void)48int renesas_da1469x_pm_init(void) 49 { 50 static const struct da1469x_sleep_config sleep_cfg = { 51 .enable_xtal_on_wakeup = DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(xtal32m)), 52 }; 53 54 da1469x_sleep_config(&sleep_cfg); 55 56 return 0; 57 } 58