From c7902201851cc025dd1a8e8f9f5e22ba95e191de Mon Sep 17 00:00:00 2001 From: Sanjay Vallimanalan Date: Mon, 1 Sep 2025 17:47:29 +0530 Subject: [PATCH 1/5] west.yml: Update hal_ti revision Update hal_ti to include input-enable property for all UART RX pins. Without the input-enable property, UART reception does not function correctly when the SoC enters low-power mode. Adding this property ensures reliable UART operation in all power states. Signed-off-by: Sanjay Vallimanalan --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index a564256794447..6275936279012 100644 --- a/west.yml +++ b/west.yml @@ -260,7 +260,7 @@ manifest: groups: - hal - name: hal_ti - revision: 391f7cb740b59c077ddd49411f043161597b10aa + revision: d0628446c830c25522bd1999234a77b4841016fa path: modules/hal/ti groups: - hal From 0ac0e6931f64b820c6ac6c343d454e334283d5e2 Mon Sep 17 00:00:00 2001 From: Sanjay Vallimanalan Date: Tue, 12 Aug 2025 12:55:49 +0530 Subject: [PATCH 2/5] soc: mspm0: add power management support TI MSPM0 series supports range of power modes (RUN/SLEEP, STOP, STANDBY) supporting low power operations. Provides automatic restoration to RUN mode on wakeup from any low power state. Signed-off-by: Sanjay Vallimanalan Signed-off-by: Parthiban Nallathambi --- soc/ti/mspm0/common/CMakeLists.txt | 2 + soc/ti/mspm0/common/power.c | 83 ++++++++++++++++++++++++++++++ soc/ti/mspm0/mspm0g/Kconfig | 1 + soc/ti/mspm0/mspm0l/Kconfig | 1 + 4 files changed, 87 insertions(+) create mode 100644 soc/ti/mspm0/common/power.c diff --git a/soc/ti/mspm0/common/CMakeLists.txt b/soc/ti/mspm0/common/CMakeLists.txt index 956e8a013950c..6b484e9a297d4 100644 --- a/soc/ti/mspm0/common/CMakeLists.txt +++ b/soc/ti/mspm0/common/CMakeLists.txt @@ -2,3 +2,5 @@ zephyr_sources(soc.c) zephyr_include_directories(.) + +zephyr_sources_ifdef(CONFIG_PM power.c) diff --git a/soc/ti/mspm0/common/power.c b/soc/ti/mspm0/common/power.c new file mode 100644 index 0000000000000..46332db67ec34 --- /dev/null +++ b/soc/ti/mspm0/common/power.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 Linumiz GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#include + +LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL); + +static void set_mode_run(uint8_t state) +{ + switch (state) { + case DL_SYSCTL_POWER_POLICY_RUN_SLEEP0: + DL_SYSCTL_setPowerPolicyRUN0SLEEP0(); + break; + case DL_SYSCTL_POWER_POLICY_RUN_SLEEP1: + DL_SYSCTL_setPowerPolicyRUN1SLEEP1(); + break; + case DL_SYSCTL_POWER_POLICY_RUN_SLEEP2: + DL_SYSCTL_setPowerPolicyRUN2SLEEP2(); + break; + } +} + +static void set_mode_stop(uint8_t state) +{ + switch (state) { + case DL_SYSCTL_POWER_POLICY_STOP0: + DL_SYSCTL_setPowerPolicySTOP0(); + break; + case DL_SYSCTL_POWER_POLICY_STOP1: + DL_SYSCTL_setPowerPolicySTOP1(); + break; + case DL_SYSCTL_POWER_POLICY_STOP2: + DL_SYSCTL_setPowerPolicySTOP2(); + break; + } +} + +static void set_mode_standby(uint8_t state) +{ + switch (state) { + case DL_SYSCTL_POWER_POLICY_STANDBY0: + DL_SYSCTL_setPowerPolicySTANDBY0(); + break; + case DL_SYSCTL_POWER_POLICY_STANDBY1: + DL_SYSCTL_setPowerPolicySTANDBY1(); + break; + } +} + +void pm_state_set(enum pm_state state, uint8_t substate_id) +{ + switch (state) { + case PM_STATE_RUNTIME_IDLE: + set_mode_run(substate_id); + break; + case PM_STATE_SUSPEND_TO_IDLE: + set_mode_stop(substate_id); + break; + case PM_STATE_STANDBY: + set_mode_standby(substate_id); + break; + default: + LOG_DBG("Unsupported power state %u", state); + return; + } + + __WFI(); +} + +void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) +{ + DL_SYSCTL_setPowerPolicyRUN0SLEEP0(); + irq_unlock(0); +} diff --git a/soc/ti/mspm0/mspm0g/Kconfig b/soc/ti/mspm0/mspm0g/Kconfig index 8a0241246d41c..5a727b26b28e3 100644 --- a/soc/ti/mspm0/mspm0g/Kconfig +++ b/soc/ti/mspm0/mspm0g/Kconfig @@ -13,5 +13,6 @@ config SOC_SERIES_MSPM0G select BUILD_OUTPUT_BIN select BUILD_OUTPUT_HEX select HAS_MSPM0_SDK + select HAS_PM select CLOCK_CONTROL select SOC_EARLY_INIT_HOOK diff --git a/soc/ti/mspm0/mspm0l/Kconfig b/soc/ti/mspm0/mspm0l/Kconfig index 9693c0d5186d2..f77aa0250bdfc 100644 --- a/soc/ti/mspm0/mspm0l/Kconfig +++ b/soc/ti/mspm0/mspm0l/Kconfig @@ -12,6 +12,7 @@ config SOC_SERIES_MSPM0L select BUILD_OUTPUT_BIN select BUILD_OUTPUT_HEX select HAS_MSPM0_SDK + select HAS_PM select CLOCK_CONTROL select SOC_EARLY_INIT_HOOK From 27d9843a18c23201330b8f90e47d83019068e7db Mon Sep 17 00:00:00 2001 From: Sanjay Vallimanalan Date: Tue, 12 Aug 2025 12:57:04 +0530 Subject: [PATCH 3/5] soc: mspm0: add poweroff support add support for SHUTDOWN operating mode in TI MSPM0 series for power-off operation. Uses HWINFO for reset cause detection to handle shutdown IO release on low power wakeup. Signed-off-by: Sanjay Vallimanalan Signed-off-by: Parthiban Nallathambi --- soc/ti/mspm0/Kconfig | 4 +++ soc/ti/mspm0/common/CMakeLists.txt | 1 + soc/ti/mspm0/common/poweroff.c | 40 ++++++++++++++++++++++++++++++ soc/ti/mspm0/mspm0g/Kconfig | 1 + soc/ti/mspm0/mspm0l/Kconfig | 1 + 5 files changed, 47 insertions(+) create mode 100644 soc/ti/mspm0/common/poweroff.c diff --git a/soc/ti/mspm0/Kconfig b/soc/ti/mspm0/Kconfig index 3c1293fb9eb0f..13e17cdbdfd7e 100644 --- a/soc/ti/mspm0/Kconfig +++ b/soc/ti/mspm0/Kconfig @@ -15,4 +15,8 @@ config MSPM0_PERIPH_STARTUP_DELAY int default 8 +config HWINFO + bool + default y if POWEROFF + endif # SOC_FAMILY_TI_MSPM0 diff --git a/soc/ti/mspm0/common/CMakeLists.txt b/soc/ti/mspm0/common/CMakeLists.txt index 6b484e9a297d4..b2dccf18da16b 100644 --- a/soc/ti/mspm0/common/CMakeLists.txt +++ b/soc/ti/mspm0/common/CMakeLists.txt @@ -4,3 +4,4 @@ zephyr_sources(soc.c) zephyr_include_directories(.) zephyr_sources_ifdef(CONFIG_PM power.c) +zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c) diff --git a/soc/ti/mspm0/common/poweroff.c b/soc/ti/mspm0/common/poweroff.c new file mode 100644 index 0000000000000..c98676f3f54c5 --- /dev/null +++ b/soc/ti/mspm0/common/poweroff.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Linumiz GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#include + +void z_sys_poweroff(void) +{ + DL_SYSCTL_setPowerPolicySHUTDOWN(); + __WFI(); + + CODE_UNREACHABLE; +} + +static int ti_mspm0_poweroff_init(void) +{ + int ret; + uint32_t rst_cause; + + ret = hwinfo_get_reset_cause(&rst_cause); + if (ret != 0) { + return ret; + } + + if (RESET_LOW_POWER_WAKE == rst_cause) { + DL_SYSCTL_releaseShutdownIO(); + } + + return 0; +} + +SYS_INIT(ti_mspm0_poweroff_init, POST_KERNEL, 0); diff --git a/soc/ti/mspm0/mspm0g/Kconfig b/soc/ti/mspm0/mspm0g/Kconfig index 5a727b26b28e3..49148c8f34a6a 100644 --- a/soc/ti/mspm0/mspm0g/Kconfig +++ b/soc/ti/mspm0/mspm0g/Kconfig @@ -14,5 +14,6 @@ config SOC_SERIES_MSPM0G select BUILD_OUTPUT_HEX select HAS_MSPM0_SDK select HAS_PM + select HAS_POWEROFF select CLOCK_CONTROL select SOC_EARLY_INIT_HOOK diff --git a/soc/ti/mspm0/mspm0l/Kconfig b/soc/ti/mspm0/mspm0l/Kconfig index f77aa0250bdfc..7a566a530e55f 100644 --- a/soc/ti/mspm0/mspm0l/Kconfig +++ b/soc/ti/mspm0/mspm0l/Kconfig @@ -13,6 +13,7 @@ config SOC_SERIES_MSPM0L select BUILD_OUTPUT_HEX select HAS_MSPM0_SDK select HAS_PM + select HAS_POWEROFF select CLOCK_CONTROL select SOC_EARLY_INIT_HOOK From 9db609a17930e9dbb2dcf85cba9b4480c3165df6 Mon Sep 17 00:00:00 2001 From: Sanjay Vallimanalan Date: Tue, 26 Aug 2025 15:17:49 +0530 Subject: [PATCH 4/5] drivers: gpio: Add GPIO Fast Wake support The fast wake feature in the MSPM0 GPIO peripheral allows the GPIO module to stay in a low-power state and detect interrupt events on the device pins without requiring a high-speed clock. This allows the device to support fast wakeup from low-power modes, such as STOP and STANDBY, on any GPIO pin. Signed-off-by: Sanjay Vallimanalan Signed-off-by: Parthiban Nallathambi --- drivers/gpio/gpio_mspm0.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio_mspm0.c b/drivers/gpio/gpio_mspm0.c index bc95845865f06..7ac165aaf73fe 100644 --- a/drivers/gpio/gpio_mspm0.c +++ b/drivers/gpio/gpio_mspm0.c @@ -158,6 +158,8 @@ static int gpio_mspm0_pin_configure(const struct device *port, gpio_flags_t flags) { const struct gpio_mspm0_config *config = port->config; + DL_GPIO_WAKEUP wakeup = DL_GPIO_WAKEUP_DISABLE; + /* determine pull up resistor value based on flags */ DL_GPIO_RESISTOR pull_res; @@ -169,14 +171,25 @@ static int gpio_mspm0_pin_configure(const struct device *port, pull_res = DL_GPIO_RESISTOR_NONE; } + if (flags & GPIO_INT_WAKEUP) { + if (flags & GPIO_ACTIVE_LOW) { + wakeup = DL_GPIO_WAKEUP_ON_0; + } else { + wakeup = DL_GPIO_WAKEUP_ON_1; + } + } + /* Config pin based on flags */ switch (flags & (GPIO_INPUT | GPIO_OUTPUT)) { case GPIO_INPUT: + if (wakeup != DL_GPIO_WAKEUP_DISABLE) { + DL_GPIO_enableFastWakePins(config->base, BIT(pin)); + } DL_GPIO_initDigitalInputFeatures(config->pincm_lut[pin], DL_GPIO_INVERSION_DISABLE, pull_res, DL_GPIO_HYSTERESIS_DISABLE, - DL_GPIO_WAKEUP_DISABLE); + wakeup); DL_GPIO_disableOutput(config->base, BIT(pin)); break; case GPIO_OUTPUT: @@ -198,6 +211,9 @@ static int gpio_mspm0_pin_configure(const struct device *port, DL_GPIO_enableOutput(config->base, BIT(pin)); break; case GPIO_DISCONNECTED: + if (wakeup != DL_GPIO_WAKEUP_DISABLE) { + DL_GPIO_disableWakeUp(config->pincm_lut[pin]); + } DL_GPIO_disableOutput(config->base, BIT(pin)); break; default: From aaa58b1d3780501e307eba7d1d1189928ed65837 Mon Sep 17 00:00:00 2001 From: Sanjay Vallimanalan Date: Tue, 12 Aug 2025 11:55:05 +0530 Subject: [PATCH 5/5] dts: arm/ti/mspm0: add cpu power states for MSPM0 series MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add range of cpu power states (run/sleep, stop and standby) for MSPM0 series. add exit latencies ranging from 1.5-15.7µs and minimum residency times of 5-10ms for optimal power management transitions. Signed-off-by: Sanjay Vallimanalan Signed-off-by: Parthiban Nallathambi --- dts/arm/ti/mspm0/g/mspm0g.dtsi | 35 ++++++++++++++++++++++ dts/arm/ti/mspm0/l/mspm0l.dtsi | 40 +++++++++++++++++++++++++ dts/arm/ti/mspm0/mspm0.dtsi | 53 ++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) diff --git a/dts/arm/ti/mspm0/g/mspm0g.dtsi b/dts/arm/ti/mspm0/g/mspm0g.dtsi index d599264866148..d7951ffa9edcd 100644 --- a/dts/arm/ti/mspm0/g/mspm0g.dtsi +++ b/dts/arm/ti/mspm0/g/mspm0g.dtsi @@ -106,3 +106,38 @@ }; }; }; + +&run1 { + exit-latency-us = <2>; /* 1.5us */ + min-residency-us = <5000>; +}; + +&run2 { + exit-latency-us = <3>; /* 2.1us */ + min-residency-us = <5000>; +}; + +&stop0 { + exit-latency-us = <13>; /* 12.1us */ + min-residency-us = <7500>; +}; + +&stop1 { + exit-latency-us = <14>; /* 13.5us */ + min-residency-us = <7500>; +}; + +&stop2 { + exit-latency-us = <13>; /* 12.9us */ + min-residency-us = <7500>; +}; + +&stdby0 { + exit-latency-us = <16>; /* 15.2us */ + min-residency-us = <10000>; +}; + +&stdby1 { + exit-latency-us = <16>; /* 15.2us */ + min-residency-us = <10000>; +}; diff --git a/dts/arm/ti/mspm0/l/mspm0l.dtsi b/dts/arm/ti/mspm0/l/mspm0l.dtsi index 9cf266adc8023..33c2e0ea626b6 100644 --- a/dts/arm/ti/mspm0/l/mspm0l.dtsi +++ b/dts/arm/ti/mspm0/l/mspm0l.dtsi @@ -17,3 +17,43 @@ #gpio-cells = <2>; }; }; + +&run0 { + exit-latency-us = <2>; /* 1.5us */ + min-residency-us = <5000>; +}; + +&run1 { + exit-latency-us = <3>; /* 2.1us */ + min-residency-us = <5000>; +}; + +&run2 { + exit-latency-us = <3>; /* 2.5us */ + min-residency-us = <5000>; +}; + +&stop0 { + exit-latency-us = <13>; /* 12.5us */ + min-residency-us = <7500>; +}; + +&stop1 { + exit-latency-us = <15>; /* 14.6us */ + min-residency-us = <7500>; +}; + +&stop2 { + exit-latency-us = <14>; /* 13.5us */ + min-residency-us = <7500>; +}; + +&stdby0 { + exit-latency-us = <16>; /* 15.7us */ + min-residency-us = <10000>; +}; + +&stdby1 { + exit-latency-us = <16>; /* 15.7us */ + min-residency-us = <10000>; +}; diff --git a/dts/arm/ti/mspm0/mspm0.dtsi b/dts/arm/ti/mspm0/mspm0.dtsi index 3cb4047b210e4..c74dda4d6257f 100644 --- a/dts/arm/ti/mspm0/mspm0.dtsi +++ b/dts/arm/ti/mspm0/mspm0.dtsi @@ -20,6 +20,59 @@ reg = <0>; #address-cells = <1>; #size-cells = <1>; + cpu-power-states = <&run0 &run1 &run2 + &stop0 &stop1 &stop2 + &stdby0 &stdby1>; + }; + + power-states { + run0: runsleep0 { + compatible = "zephyr,power-state"; + power-state-name = "runtime-idle"; + substate-id = <1>; + }; + + run1: runsleep1 { + compatible = "zephyr,power-state"; + power-state-name = "runtime-idle"; + substate-id = <2>; + }; + + run2: runsleep2 { + compatible = "zephyr,power-state"; + power-state-name = "runtime-idle"; + substate-id = <3>; + }; + + stop0: stop0 { + compatible = "zephyr,power-state"; + power-state-name = "suspend-to-idle"; + substate-id = <1>; + }; + + stop1: stop1 { + compatible = "zephyr,power-state"; + power-state-name = "suspend-to-idle"; + substate-id = <2>; + }; + + stop2: stop2 { + compatible = "zephyr,power-state"; + power-state-name = "suspend-to-idle"; + substate-id = <3>; + }; + + stdby0: standby0 { + compatible = "zephyr,power-state"; + power-state-name = "standby"; + substate-id = <1>; + }; + + stdby1: standby1 { + compatible = "zephyr,power-state"; + power-state-name = "standby"; + substate-id = <2>; + }; }; };