Last edited 5 days ago

STM32MP1 power overview

Applicable for STM32MP13x lines, STM32MP15x lines

This article gives information about the support power management in OpenSTlinux for STM32MP1 series.

1. Framework purpose[edit | edit source]

The purpose of this article is to explain how OpenSTlinux components handle the STM32MP1 series power management:

  • Software overview
  • Peripheral power support
  • Low-power modes available on the device

See also the page How to define your low-power strategy.

2. Software overview[edit | edit source]

In OpenSTLinux,the device power requests associated to each system resources (clock, regulator, operation point) are provided by the secure world through SCMI requests.

The device request are consolidated by the Linux frameworks before to use SCMI framework.

The Linux system power request is handled with the PSCI support and OP-TEE.

2.1. Component description[edit | edit source]

The OpenSTLinux components for low-power modes are:

Nonsecure world (Linux):

  • Power management frameworks: See Power overview for details
  • PSCI library: this is a set of standardized functions to request a low-power service to the secure monitor.
  • SCMI drivers: driver for system resources (clock, regulators, power domain,...), exposed by OP-TEE with SCMI protocol.
  • Device driver: any peripheral driver which needs to control power.
    • RCC driver for clock and reset managed by nonsecure world.
    • STPMIC1 driver: this driver handles STPMIC1 for STM32MP15 when I2C is not secured (not recommended and it is no more the STMicroelectronics boards configuration since ecosystem release v7.0.0 )

Secure monitor and secure world components (OP-TEE): (see next chapter for details)

  • SCMI protocol: see SCMI overview for details.
  • PSCI library: generic PSCI stack.
  • Low-power driver: the role of this driver is to choose the low-power mode according to the programmed wake-up source(s).
  • PM framework: call the low-power callback of each device on the call of Low-power driver.
  • OP-TEE drivers: driver of device for system resources
    • PWR driver: this driver is responsible for configuring the low-power mode.
    • RCC driver: this driver handles the circuit secure clocks.
    • STPMIC driver: this driver handles STPMIC (STPMIC1 or STPMIC1L present in hardware design), including configuration for the low-power mode
    • DDR driver: this driver is responsible to set DDR in self refresh mode

STM32 peripherals (hardware):

2.2. API description[edit | edit source]

The OpenSTLinux power management support is based on Arm® interface specifications:

  • Power state coordination interface (PSCI) [1] defines many messages (see identifiers in OP-TEE core/arch/arm/include/sm/psci.h or in Linux include/kvm/arm_psci.h ), for examples:
    • CPU_ON/CPU_OFF : used for hotplug feature.
    • SYSTEM_OFF : used for power off.
    • SYSTEM_RESET : used for system reset.
    • SYSTEM_SUSPEND : used to system suspend (deep).
    • PSCI_VERSION : return the supported version of the PSCI specication, v1.1 is supported by TF-A.
  • System Control and Management Interface (SCMI)[2], see SCMI overview for details.

3. Configuration[edit | edit source]

The objective of this chapter is to explain how to configure OpenSTLinux for low-power modes.

See the page power overview for kernel configuration details.


3.1. Low-power mode in OP-TEE[edit | edit source]

Low-power management on the STM32MP1 platform is handled by OpenSTLinux through:

Power management for STM32MP1 in OP-TEE is configured with:

Low-power management in OP-TEE, including any required helper code in TF-A, is also impacted by the STM32MPU_OP-TEE_profiles (CFG_STM32MP_PROFILE):

On STMicroelectronics boards, the flags are configured through flavors selected according to the device-tree name.
For example: flavorlist-MP1-PWR-OSTL in core/arch/arm/plat-stm32mp1/conf.mk

It is important to synchronize the configurations of all software components and device trees for the configuration of the services used (SCMI, PSCI, SMC) and for the protection of system resources.

3.2. Supported power modes in OP-TEE[edit | edit source]

This system low-power mode mapping can be modified through the PWR node in the secure OS device tree, as described in OP-TEE documentation/devicetree/bindings/regulator/st,stm32mp1-pwr-reg.yaml :

  • reduce the list of supported modes in system_suspend_supported_soc_modes
  • request a STPMIC1/STPMIC1L software switch-off to turn off all the STM32MPU supply rails by setting the system-power-controller property in the pmic node
    By default, the system low power mode for PSCI power-off request is "Standby mode with DDR off" to keep the backup-domain supply on (STM32_PM_CSTANDBY_ALLOW_STANDBY_DDR_OFF).

For example, the OP-TEE device-tree core/arch/arm/dts/stm32mp135f-dk.dts does not support STM32_PM_CSTOP_ALLOW_STOP and support system-power-controller:

 &i2c4 {
 ...
   stpmic1: pmic@33 {
 ...
     system-power-controller;
 ...
  };
 };
 &pwr_regulators {
 	system_suspend_supported_soc_modes = <
 		STM32_PM_CSLEEP_RUN
 		STM32_PM_CSTOP_ALLOW_LP_STOP
 		STM32_PM_CSTOP_ALLOW_LPLV_STOP
 		STM32_PM_CSTANDBY_ALLOW_LPLV_STOP2
 		STM32_PM_CSTANDBY_ALLOW_STANDBY_DDR_SR
 	>;
 };

3.3. Supported power modes in Linux[edit | edit source]

In Linux, the SoC device tree (arch/arm/boot/dts/st/stm32mp131.dtsi or arch/arm/boot/dts/st/stm32mp151-scmi.dtsi ) defines low-power states under cpus/domain-idle-states and CPU idle states under cpus/idle-states, with the associated PSCI_CPU_SUSPEND parameter in arm,psci-suspend-param values. It also defines the PSCI topology under psci; its power-domain nodes reference low-power states through their domain-idle-states properties (see OSI and S2Idle for modes supported by PSCI_CPU_SUSPEND).

	cpus {
...
		domain-idle-states {
			stop1: domain-stop1 {
				compatible = "domain-idle-state";
				arm,psci-suspend-param = <0x00000012>;
...
			};
			lp_stop1: domain-lp-stop1 {
				compatible = "domain-idle-state";
				arm,psci-suspend-param = <0x00000022>;
...
			};
			lplv_stop1: domain-lplv-stop1 {
				compatible = "domain-idle-state";
				arm,psci-suspend-param = <0x00000222>;
...
			};
		};
		idle-states {
			entry-method = "psci";
			cpu_pwrdn: cpu-power-down {
				compatible = "arm,idle-state";
				arm,psci-suspend-param = <0x00000002>;
...
			};
		};
	};
	psci: psci {
		compatible = "arm,psci-1.0";
		method = "smc";

		cpu0_pd: power-domain-cpu0 {
			#power-domain-cells = <0>;
			domain-idle-states = <&cpu_pwrdn>;
			power-domains = <&pd_core>;
		};

		pd_core: power-domain-cluster {
			#power-domain-cells = <0>;
			domain-idle-states = <&stop1>, <&lp_stop1>;
			power-domains = <&pd_core_ret>;
		};

		pd_core_ret: power-domain-retention {
			#power-domain-cells = <0>;
			domain-idle-states = <&lplv_stop1>;
		};
	};

References to low-power modes that are not supported in system_suspend_supported_soc_modes must be removed from the Linux board device tree to avoid issues with CpuIdle and S2Idle.

For example, on a board without STPMIC1 and if the modes LP-Stop and LPLV-Stop are not supported, the OP-TEE device tree is:

&pwr_regulators {
	system_suspend_supported_soc_modes = <
		STM32_PM_CSLEEP_RUN
		STM32_PM_CSTOP_ALLOW_STOP
		STM32_PM_CSTANDBY_ALLOW_STANDBY_DDR_SR
	>;
	vdd-supply = <&vdd>;
	vdd_3v3_usbfs-supply = <&vdd_usb>;
};

The associated reference modes in the Linux device tree must be removed from the domain-idle-states properties:

&pd_core {
			domain-idle-states = <&stop1>;
};

&pd_core_ret {
			/delete-property/ domain-idle-states;
};

3.4. STPMIC configuration for low-power mode in OP-TEE[edit | edit source]

Refer to PMIC OP-TEE page for details of PMIC configuration in OP-TEE for each power mode, and to application note AN5260 and AN5587 for configuration examples.

In OpenSTLinux, when using a PMIC on a board, it is recommended to use a secure I²C (for example I2C4 or I2C6 on STM32MP15x lines ) protected by ETPZC and the PMIC is handle only in OP-TEE, exported with SCMI.

It is the default configuration of all STMicroelectronic STM32MP1 series boards to support PSCI OSI.

STPMIC1 on unsecure I²C is the configuration used in -rcc-scmi external device tree of STMicroelectronic STM32MP15x lines  boards; in this mode the STPMIC is managed in non-secure world but the low power mode of STPMIC is configured by OP-TEE, so the unsecure I²C and STPMIC are shared between secure and secure world and access PWR regulators are exported by SMC to Linux regulator driver (CFG_STM32_PWR_SIP).

The pm_hint parameter of pmic_regu_pm() is used by the STPMIC (STPMIC1 or STPMIC1L) driver in OP-TEE to configure each regulators according to the selected low-power mode as described in device tree by subnodes.

See OP-TEE device tree in core/arch/arm/dts/stm32mp135f-dk.dts for configuration example:

			vddcpu: buck1 {
				regulator-name = "vddcpu";
				regulator-min-microvolt = <1250000>;
				regulator-max-microvolt = <1350000>;
				regulator-always-on;
				regulator-over-current-protection;

				lp-stop {
					regulator-suspend-microvolt = <1250000>;
				};
				lplv-stop {
					regulator-suspend-microvolt = <900000>;
				};
				lplv-stop2 {
					regulator-off-in-suspend;
				};
				standby-ddr-sr {
					regulator-off-in-suspend;
				};
				standby-ddr-off {
					regulator-off-in-suspend;
				};
			};
Information
STPMIC1L is only supported in OP-TEE and TF-A with driver for STPMIC2 family (STPMIC1L, STPMIC2L, STPMIC25)
OpenSTLinux don't support of STPMIC1L in Linux.
So hardware design with STPMIC1L for STM32MP15x lines  must use secure I²C and STPMIC1L device must be managed in OP-TEE.
See example STPMIC managed in OP-TEE with configuration of STMicroelectronics STM32MP1 series boards since ecosystem release v7.0.0 and the page How to configure device tree for board with STPMIC1L.

4. How to use the framework[edit | edit source]

4.1. Low-power modes[edit | edit source]

Refer to STM32MP13 reference manuals or STM32MP15 reference manuals for the full description of low-power modes.

The modes are handled by the RCC and the PWR peripherals.

On lower mode requests , Linux stops the whole system activity and a low-power mode is entered with PSCI request. The OP-TEE PSCI stack selects the deepest mode according to the activated wake-up source(s).

STM32MP1 series STMicroelectronic deliveries propose a default mapping of the low-power modes for each type of board and for each PSCI request, this default mapping can be changed thanks to the device tree as explain in a paragraph above

System mode Linux Command PSCI request DDR state
Stop freeze
(s2idle)
PSCI_CPU_SUSPEND SR, VTT on
LP-Stop SR, VTT off
LPLV-Stop
Stop mem
(deep)
PSCI_SYSTEM_SUSPEND SR, VTT on
LP-Stop SR, VTT off
LPLV-Stop
LPLV-Stop2STM32MP13
Standby
Standby shutdown PSCI_SYSTEM_OFF OFF
VBAT
STPMIC1 switch OFF

Since ecosystem release ≤ v7.0.0 and with the default configuration used in device tree of STMicroelectronic boards present in each software component,
PSCI_CPU_SUSPEND for freeze command and s2idle mode is supported.

The previous OpenSTLinux configuration (CFG_STM32_PSCI_OSI=n, CFG_STM32_LOWPOWER_SIP=y, CFG_STM32_PWR_SIP=y), with STPMIC managed by Linux and without s2idle support, are provided for some STMicroelectronic boards in External device tree in directory stm32mp1/ with -rcc-scmi device tree for each software component:

4.1.1. On STM32MP13x lines [edit | edit source]

The AN5565 STM32MP13 lines using low-power modes gives more information on these modes and on associated the wake-up sources.

The table below summarizes the device hardware states corresponding to each low-power mode.

MPU mode Platform mode VDDCORE state VDDCPU state Clocks state
CRun/CSleeep Run On On On
CStop Stop On On Off
LP-Stop On On
LPLV-Stop Retention Retention
CStandby LPLV-Stop2 Retention Off
Standby Off Off

The following tables give the list of wake-up sources available in each mode.

Platform mode Available wake-up sources
Stop/LP-Stop Group1 : Group2 + HSE CSS USBH, OTG, ETH
LPLV-Stop
LPLV-Stop2
Group2 : Group3 + PVD, AVD, USART, I2C, SPI, DTS, LPTIM, GPIO
Standby Group3 : BOR, Vbat mon, Temp mon, LSE CSS, RTC, TAMP, Wakeup pins (from PWR)

4.1.2. On STM32MP15x lines [edit | edit source]

The AN5109 low-power application note also gives more information on these modes, including:

  • the detailed description of the operating modes
  • the low-power mode entry and exit sequences
  • the low-power mode control registers
  • the wake-up sources and the software mechanism that ensures the consistency between the low-power mode and the activated wake-up source

The table below summarizes the device hardware states corresponding to each low-power mode.

The term "subsystem" either refers to Arm® Cortex®-A7 (also called MPU) or to Arm® Cortex®-M4 (also called MCU). A mode prefixed by 'C' corresponds to a subsystem mode.

Level Mode VDDCORE state Subsystem Clocks state
MPU Subsystem MPU CRun On On
MPU CStop On Off
MPU CStandby On Off + MPU reset on wakeup
MCU Subsystem MCU CRun On On
MCU CStop On Off

A platform mode is the combination of MPU and MCU modes, only the some MPU mode are used in OpenSTLinux for each platform mode

MPU mode MCU mode Platform mode VDDCORE state Clocks state
CRun/CSleep
CStop/CStandby
CRun Run On On
CStop/CStandby CStop Stop
(LPDS = 0)
Retention Off
CStop/CStandby CStop LP-Stop
(LPDS = 1)
Retention
Low-power mode
Off
CStop/CStandby CStop LPLV-Stop
(LPDS and LVDS = 1)
Retention
Low-power Low-voltage mode
Off
CStandby CStop
MCU PDDS = 1
Standby Off Off

See config_power[] in core/arch/arm/plat-stm32mp1/pm/low_power.c for mapping in OP-TEE.

The following tables give the list of wake-up sources available in each mode.

Plaform mode Available wake-up sources
Stop
LP-Stop
Group1 : Group2 + USB, CEC, ETH, USART, I²C, SPI, LPTIM
LPLV-Stop Group2 : Group3 + PVD, AVD, GPIO
Standby Group3: BOR, Vbat mon, Temp mon, LSE CSS, RTC, TAMP, Wakeup pins (from PWR)

This list of Wake-up capability peripheral for each mode is defined in the Table 35. Functionalities depending on system operating mode of the STM32MP15 reference manuals.

4.2. PSCI topology[edit | edit source]

The PSCI specification defines the concept of the power domain topology tree and in OpenSTLinux, each STM32MP1 series low power mode is associated to a PSCI State-id, which uses the ARM Recommended StateID Encoding with OS initiated support.

For PSCI suspend requests, STM32MP1 series supports 4 power levels in the PSCI topology to handle PSCU_CPU_SUSPEND request define in core/arch/arm/plat-stm32mp1/pm/psci.c with values aligned on STM32MP2 PSCI topology.

#define STM32_STATE_ID_CPU_PWRDN        U(0x2)
#define STM32_STATE_ID_STOP1            U(0x12)
#define STM32_STATE_ID_LP_STOP1         U(0x22)
#define STM32_STATE_ID_LPLV_STOP1       U(0x222)

4.3. PSCI_CPU_SUSPEND support[edit | edit source]

PSCI_CPU_SUSPEND is supported when CFG_STM32_PSCI_OSI is activated in OP-TEE and when the PSCI power domains are defined in Linux device tree, see -ostl device trees for examples on STMicroelectronic board.

Linux kernel sent the PSCI_CPU_SUSPEND to OP-TEE after a S2IDLE/FREEZE system request and for PSCI CPUIdle OS initiated mode (PSCI OSI). They are described in the SoC device tree using the hierarchical model with nodes idle-states and domain-idle-states as described in Documentation/devicetree/bindings/arm/psci.yaml (see Power overview for detail).

The targeted arm,psci-suspend-param, based on this topology, is provided to PCSI stack in PSCI_CPU_SUSPEND requested (see Power overview).

4.4. PSCI_SYSTEM_SUSPEND support[edit | edit source]

Linux kernel sent the PSCI_SYSTEM_SUSPEND to OP-TEE after "DEEP"/"S2RAM" request (see Power overview for details). The activated wake-up are checked in OP-TEE to select the lowest supported mode in core/arch/arm/plat-stm32mp1/pm/power_config.c according the OpenSTLinux configuration and based:

  1. either on value of EXTI IMR register, i.e. the PSCI platform-coordinated mode, it is default configuration since ecosystem release v7.0.0 )
  2. either on proprietary SMC (CFG_STM32_LOWPOWER_SIP) used by Linux STM32 power domain driver, for -rcc-scmi configuration (it was the default configuration before ecosystem release v7.0.0 )

If a low-power mode is not supported by a board design, it must be removed in OP-TEE device tree.

4.5. PSCI stack in OP-TEE[edit | edit source]

The OP-TEE PSCI stack calls the STM32MP1 platform hooks (see core/arch/arm/plat-stm32mp1/pm/psci.c )

For PSCI_SYSTEM_SYSTEM request the targeted low power mode is selected in core/arch/arm/plat-stm32mp1/pm/power_config.c according the OpenSTLinux configuration (CFG_STM32_LOWPOWER_SIP).

In OP-TEE PM framework, the targeted power level is indicated with pm_hint parameter of API pm_change_state() (called in core/arch/arm/plat-stm32mp1/pm/context.c ) and transmit to each OP-TEE drivers to save/restore the device configuration (see core/include/kernel/pm.h and core/arch/arm/plat-stm32mp1/stm32mp_pm.h for details).

When it is done, the last sequence of entry in low power mode, the DDR is set in self-refresh mode and the DDR (means no more accessible), so this part must be executed in SYSRAM:

A shared context in BKPSRAM (see details in STM32MP13 and STM32MP15 RAM mapping) is used to transmit the information between TF-A BL2 and OP-TEE.
This context is used for standby mode exit and, if needed, by the TF-A BL2 resident code in SYSRAM; it is defined by:

This context save values needed to restore the system when system exit of low power, including DDR access.
As the FIP with the OP-TEE firmware can be updated independently from TF-A BL2, the context format must be backward compatible and the context CRC and version is checked before any access to its content.

5. Source code location[edit | edit source]

Below are listed the software frameworks and drivers managing the OpenSTLinux power management.

  • And drivers for each internal peripheral or external component are described in the associated pages:

6. How to trace and debug[edit | edit source]

See How to debug TF-A BL2 and How_to_debug_OP-TEE to activate the traces.

7. To go further[edit | edit source]

Refer to reference manual for a detailed description of low-power modes and peripheral wake-up sources:

The following application notes gives additional information on the hardware settings used for low-power management:

8. References[edit | edit source]

  1. ↑ Arm Power State Coordination Interface (PSCI):
    https://developer.arm.com/documentation/den0022
  2. ↑ Arm System Control and Management Interface Platform Design Document (SCMI) specification:
    https://developer.arm.com/documentation/den0056