From c315c9b97cad1223a6f9214d78beeffb125c895c Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Tue, 8 Aug 2023 12:09:33 +0200 Subject: [PATCH] soc: arm: ti_simplelink: cc13x2_cc26x2: add support for sys_poweroff Implement sys_poweroff() hooks, based on previous SOFT_OFF implementation. Signed-off-by: Gerard Marull-Paretas --- .../ti_simplelink/cc13x2_cc26x2/CMakeLists.txt | 6 ++++-- .../ti_simplelink/cc13x2_cc26x2/Kconfig.series | 1 + soc/arm/ti_simplelink/cc13x2_cc26x2/power.c | 8 -------- soc/arm/ti_simplelink/cc13x2_cc26x2/poweroff.c | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 soc/arm/ti_simplelink/cc13x2_cc26x2/poweroff.c diff --git a/soc/arm/ti_simplelink/cc13x2_cc26x2/CMakeLists.txt b/soc/arm/ti_simplelink/cc13x2_cc26x2/CMakeLists.txt index f17a0ffe815..085aa4d474b 100644 --- a/soc/arm/ti_simplelink/cc13x2_cc26x2/CMakeLists.txt +++ b/soc/arm/ti_simplelink/cc13x2_cc26x2/CMakeLists.txt @@ -5,7 +5,9 @@ zephyr_sources(soc.c) zephyr_sources(ccfg.c) -zephyr_library_sources_ifdef(CONFIG_PM power.c) -zephyr_library_sources_ifdef(CONFIG_PM_DEVICE power.c) +if(CONFIG_PM OR CONFIG_POWEROFF) + zephyr_library_sources(power.c) +endif() +zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c) zephyr_linker_sources_ifdef(CONFIG_HAS_TI_CCFG SECTIONS ccfg.ld) diff --git a/soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.series b/soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.series index 9332a4c0672..d5defae07b0 100644 --- a/soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.series +++ b/soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.series @@ -16,5 +16,6 @@ config SOC_SERIES_CC13X2_CC26X2 select HAS_TI_CCFG select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE select HAS_PM + select HAS_POWEROFF help Enable support for TI SimpleLink CC13x2 / CC26x2 SoCs diff --git a/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c b/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c index 88a51933665..09c381b3d50 100644 --- a/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c +++ b/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c @@ -54,7 +54,6 @@ extern PowerCC26X2_ModuleState PowerCC26X2_module; * Power state mapping: * PM_STATE_SUSPEND_TO_IDLE: Idle * PM_STATE_STANDBY: Standby - * PM_STATE_SUSPEND_TO_RAM | PM_STATE_SUSPEND_TO_DISK: Shutdown */ /* Invoke Low Power/System Off specific Tasks */ @@ -106,13 +105,6 @@ void pm_state_set(enum pm_state state, uint8_t substate_id) /* go to standby mode */ Power_sleep(PowerCC26XX_STANDBY); break; - case PM_STATE_SUSPEND_TO_RAM: - __fallthrough; - case PM_STATE_SUSPEND_TO_DISK: - __fallthrough; - case PM_STATE_SOFT_OFF: - Power_shutdown(0, 0); - break; default: LOG_DBG("Unsupported power state %u", state); break; diff --git a/soc/arm/ti_simplelink/cc13x2_cc26x2/poweroff.c b/soc/arm/ti_simplelink/cc13x2_cc26x2/poweroff.c new file mode 100644 index 00000000000..348a652e441 --- /dev/null +++ b/soc/arm/ti_simplelink/cc13x2_cc26x2/poweroff.c @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#include + +void z_sys_poweroff(void) +{ + Power_shutdown(0, 0); + + CODE_UNREACHABLE; +}