Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion drivers/gpio/gpio_mspm0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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:
Expand All @@ -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:
Expand Down
35 changes: 35 additions & 0 deletions dts/arm/ti/mspm0/g/mspm0g.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
40 changes: 40 additions & 0 deletions dts/arm/ti/mspm0/l/mspm0l.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
53 changes: 53 additions & 0 deletions dts/arm/ti/mspm0/mspm0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
};
};

Expand Down
4 changes: 4 additions & 0 deletions soc/ti/mspm0/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ config MSPM0_PERIPH_STARTUP_DELAY
int
default 8

config HWINFO
bool
default y if POWEROFF

endif # SOC_FAMILY_TI_MSPM0
3 changes: 3 additions & 0 deletions soc/ti/mspm0/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

zephyr_sources(soc.c)
zephyr_include_directories(.)

zephyr_sources_ifdef(CONFIG_PM power.c)
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
83 changes: 83 additions & 0 deletions soc/ti/mspm0/common/power.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2025 Linumiz GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <soc.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
#include <zephyr/logging/log.h>

#include <ti/driverlib/driverlib.h>

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);
}
40 changes: 40 additions & 0 deletions soc/ti/mspm0/common/poweroff.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate commit for poweroff

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2025 Linumiz GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <soc.h>
#include <zephyr/drivers/hwinfo.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>

#include <ti/driverlib/driverlib.h>

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depends on HWINFO driver

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);
2 changes: 2 additions & 0 deletions soc/ti/mspm0/mspm0g/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ config SOC_SERIES_MSPM0G
select BUILD_OUTPUT_BIN
select BUILD_OUTPUT_HEX
select HAS_MSPM0_SDK
select HAS_PM
select HAS_POWEROFF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this as well to poweroff commit

select CLOCK_CONTROL
select SOC_EARLY_INIT_HOOK
2 changes: 2 additions & 0 deletions soc/ti/mspm0/mspm0l/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ config SOC_SERIES_MSPM0L
select BUILD_OUTPUT_BIN
select BUILD_OUTPUT_HEX
select HAS_MSPM0_SDK
select HAS_PM
select HAS_POWEROFF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

select CLOCK_CONTROL
select SOC_EARLY_INIT_HOOK

Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ manifest:
groups:
- hal
- name: hal_ti
revision: 391f7cb740b59c077ddd49411f043161597b10aa
revision: d0628446c830c25522bd1999234a77b4841016fa
path: modules/hal/ti
groups:
- hal
Expand Down
Loading