The Linux kernel uses several power management strategies:

  • Suspend to memory allows for the system to sleep while waiting for an event. On suspend, most system devices, including CPU and memory, enter low power mode. On resume, the system will continue from the same state it was in before it suspended.

  • Power off, which brings the system to a halt until an event wakes the system. On power off the system power remains enabled and the system is placed on its lowest consumption mode. On wakeup, the bootloader starts up again and the system is initialized.

Suspend to memory

The Linux kernel can perform a suspend-to-memory or suspend-to-RAM operation. When entering this low-power mode, the system state is kept in self-refreshing RAM while the system enters a low-power-consumption mode. The system resumes when a previously selected interrupt is received, restores the previous state, and continues running from where it left off. There is often a trade-off between the depth of the low-power mode and the speed at which the system can resume.

The ConnectCore MP15 can reach different power levels during suspend. The suspend level depends on the enabled wake-up sources. For a certain peripheral to be able to wake the system, this peripheral must be powered. As a consequence, the more different wake-up sources you enable, the more power your device will consume during suspend.

For details on the different suspend levels and the associated wake-up sources, refer to https://wiki.st.com/stm32mpu/wiki/Power_overview.

For example, to wake the system from the lowest power consumption mode, there are only a few wake-up sources available:

  • The reset line

  • STM32MP15 RTC alarm

  • A tamper event

  • One of the six special wake-up pins (WKUP1..WKUP6)

If you want your device to wake up on signal from a different interface, such as a UART, or Ethernet, you’ll need to configure those devices as wake-up sources thus keeping them enabled during suspend.

Enter suspend mode

To enter suspend mode:

  • Run /bin/standby from the command line, or

  • Briefly press the power key

The default device tree of the ConnectCore MP15 Development Kit has the following wakeup-capable interfaces enabled:

  • ON/OFF button (WKUP1 pin)

  • STM32MP15 RTC alarm

  • I2C2 bus

  • I2C6 bus

    • External RV3028 RTC alarm

To allow the system to go to the deepest standby mode, you need to disable the non-essential wakeup sources, and leave only the ON/OFF button and internal RTC alarm:

# echo disabled > /sys/devices/platform/soc/40013000.i2c/power/wakeup
# echo disabled > /sys/devices/platform/soc/5c009000.i2c/power/wakeup
# echo disabled > /sys/devices/platform/soc/5c009000.i2c/i2c-6/6-0052/power/wakeup

Power off

The Linux kernel can perform a power-off operation that places the Power Management IC (PMIC) in power off mode, disabling all power sources that are not needed for wake up.

During power off, the only available power rail is VBAT, if supplied by a coin cell or supercap via VCC_LICELL.

Enter power off

To enter power off mode you can do one of the following:

  • Run the command poweroff from the command line to perform a controlled software power off sequence.

  • Press the power key for five seconds, to perform a controlled software power off sequence.

Configure wake-up sources

CPU GPIOs

CPU GPIOs can only act as wake-up sources if they have been configured to send an input key event to the system via a driver such as gpio-keys. To do so, add an entry like this to your device tree (the example configures the User Button 1 (GPIOA 13) on the ConnectCore MP15 Development Kit):

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
	...

	gpio-keys {
		compatible = "gpio-keys";
		button {
			label = "User Button 1";
			gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WAKEUP>;
			gpio-key,wakeup;
		};
	};

	...
};

Triggering the GPIO (pressing User Button 1) wakes the system up from suspend. Regular GPIOs cannot wake the system from power-off.

Wake-up pins

There are six special WAKE UP functions associated with six pads of the STM32MP15 CPU. These pads are able to wake the system from the deepest standby mode, if configured as wake-up sources.

The following table shows the pads of the ConnectCore MP15 that have the special wake-up capability:

Wakeup pin SoC pad SOM pad EXTI interrupt Default use on the ConnectCore MP15 Development Kit

WKUP1

PA0

E2

55

PMIC interrupt, linked to ON/OFF button on the ConnectCore MP15 Development Kit

WKUP2

PA2

AA20

56

ETH1_MDIO (Ethernet)

WKUP3

PC13

not available

57

-

WKUP4

PI8

C16

58

Low power oscillator (LPO) 32kHz signal (Wi-Fi)

WKUP5

PI11

V7

59

LCD_G6 data line (LCD) if enabled via a device tree overlay

WKUP6

PC1

AA19

60

ETH_MDC (Ethernet)

These pads multiplex different functionality and may be in use by a peripheral on the ConnectCore MP15 device tree, as denoted by the last column.

To use one of these pads as wake-up source:

  1. Check your device tree for any interface that may use the pad for an alternate function (AF) different than GPIO. If you find one, disable that interface to free the pad to be used as a regular GPIO.

  2. On the Linux device tree, configure a gpio-keys entry to produce its associated exti interrupt, and add the property wakeup-source. For instance, for WKUP5:

    Linux device tree
    	gpio-keys {
    		compatible = "gpio-keys";
    		button {
    			label = "wakeup GPIO";
    			interrupts-extended = <&exti 59 IRQ_TYPE_EDGE_FALLING>;
    			linux,code = <KEY_WAKEUP>;
    			wakeup-source;
    		};
    	};
The WKUP pads detect falling edges, so you must connect an external pull-up resistor on the line to a power rail that is enabled during suspend.

RTC alarm

To enable the RTC wake alarm to trigger in 60 seconds:

  • Enable the RTC device as a wake-up source:

    # echo enabled > /sys/class/rtc/rtc0/device/power/wakeup
  • Program the time when the alarm should trigger an interrupt (format is seconds since the epoch or, if there’s a leading +, seconds in the future or, if there’s a leading +=, seconds ahead of the current alarm):

    # echo +60 > /sys/class/rtc/rtc0/wakealarm

The internal RTC can wake the system from standby and also from power off if VBAT is supplied by a coin cell or supercap via VCC_LICELL.

The external RTC can wake the system from standby only.

Ethernet Wake-On-LAN (WOL)

To enable the Ethernet as a wake-up source:

# ethtool -s eth0 wol g

Verify the Wake-On-LAN is enabled with:

# cat /sys/class/net/eth0/power/wakeup
enabled

Suspend the system:

# standby

To wake the system up, send a WOL packet from your host computer to the MAC address of the device (you may need root permissions):

$ etherwake XX:XX:XX:XX:XX:XX

where XX:XX:XX:XX:XX:XX is the MAC address of the device.