The Linux kernel can support up to four system sleep states depending on the capabilities of the platform it runs on. In this article, we will explore platform-specific implementations for Toradex SoMs.
When the CPU is not running, the processor can enter the low power mode. The chip supports a very flexible set of power mode configurations in low power mode:
System Idle: The CPU can enter this mode automatically if there is no thread running anymore. All peripherals can be kept working. The CPU state is retained, so the interrupt response can be very short.
Low Power Idle: Some of the peripherals are kept still alive while others are shut off. The interrupt response in this state is longer than in the System Idle, but the power consumption is much lower.
Suspend: All clocks, unused peripherals and PHYs are off. The DDR3L RAM stays in SelfRefresh mode. The exit time from this mode is much longer. All power rails are still available on the module.
The low power mode can be activated through the following command:
# echo standby > /sys/power/state
The suspend mode can be activated through the following command:
# echo mem > /sys/power/state
In order to wake the system up again, the MXM3 PIN 37 need to be pulled up or down (depending on the previous state).
The NVIDIA Tegra T30 support Low Power modes (LP). Currently, LP1 is supported which means CPU is put into a sleep mode and RAM is in self-refresh mode
# echo mem > /sys/power/state
In order to wake the system up again, the MXM3 PIN 37 need to be pulled up or down (depending on the previous state).
The suspend mode can be selected using /sys/power/suspend/mode
. But currently, only LP1 is supported.
The NVIDIA Tegra TK1 support Low Power modes (LP). Currently, LP1 is supported which means CPU is put into a sleep mode and RAM is in self-refresh mode
# echo mem > /sys/power/state
In order to wake the system up again, the MXM3 PIN 37 need to be pulled up or down (depending on the previous state).
The suspend mode can be selected using /sys/power/suspend/mode
. But currently, only LP1 is supported.
By default SODIMM PIN 45 is used as wake-up GPIO on Colibri modules and MXM3 PIN 37 is used as wake-up GPIO on Apalis modules.
The below example sets the timeout (in Sec) to wakeup from standby/suspend.
# echo +10 > /sys/class/rtc/rtc1/wakealarm
The below example enables ttyLP0 as wake-up source.
# echo enabled > /sys/class/tty/ttyLP0/power/wakeup
Note: UART wake-up is only supported for standby mode.
When the CPU is not running, the processor can enter the low power mode. The chip supports a very flexible set of power mode configurations in low power mode:
System Idle: The CPU can enter this mode automatically if there is no thread running anymore. All peripherals can be kept working. The CPU state is retained, so the interrupt response can be very short.
Low Power Idle: Some of the peripherals are kept still alive while others are shut off. The interrupt response in this state is longer than in the System Idle, but the power consumption is much lower.
Suspend: All clocks, unused peripherals and PHYs are off. The DDR3L RAM stays in SelfRefresh mode. The exit time from this mode is much longer. All power rails are still available on the module.
The low power mode can be activated through the following command:
# echo standby > /sys/power/state
The suspend mode can be activated through the following command:
# echo mem > /sys/power/state
In order to wake the system up again, you can use the SODIMM PIN 45 need to be pulled up or down (depending on the previous state), or use the RTC.
The below example sets the timeout (in Sec) to wakeup from standby/suspend.
# echo +10 > /sys/class/rtc/rtc1/wakealarm
The NVIDIA Tegra T20 and T30 support Low Power modes (LP). Currently, LP1 is supported which means CPU is put into a sleep mode and RAM is in self-refresh mode. LP1 mode draws around 180mW on a Colibri T20 512 MB on the Iris Carrier Board)
# echo mem > /sys/power/state
In order to wake the system up again, the SODIMM PIN 45 need to be pulled up or down (depending on the previous state).
The suspend mode can be selected using /sys/power/suspend/mode
. But currently, only LP1 is supported.
Note: Check the release notes for possible limitations.
The Ethernet PHY used on our Vybrid based modules has an errata which does not allow the PHY to power down and wake-up reliable. Therefore, suspend mode for the Ethernet PHY has been disabled by default (by this commit).
For low-power applications not using Ethernet, it is recommended to set the PHY to power-down mode in U-Boot and disable the PHY driver in Linux. To disable PHY control from Linux either disable the Ethernet and PHY driver in the kernel configuration or remove the corresponding device tree node (e.g. set the status
property of the fec node to disabled
see Device Tree Customization).
Use the following U-Boot command to disable the Ethernet PHY:
> mii write 0 0 0x3800
Extend the bootcmd to disable the Ethernet PHY by default:
> setenv bootcmd "mii write 0 0 0x3800 && ${bootcmd}"
> saveenv
The standby sleep state puts the Vybrid SoC in STOP mode. The SoC can be woken from standby through any peripheral interrupt. However, currently, wake-up capabilities have been implemented and tested only for some peripheral drivers, namely GPIO, SNVS RTC and UART driver.
Entering standby mode:
# echo standby > /sys/power/state
The mem sleep state (Suspend-to-RAM) uses Vybrid's LPSTOP2 mode. This mode powergates most parts of the SoC expect some peripherals such as Wake-Up controller (WKPU) or LP RTC. The main memory (DDR3) is put into self-refresh mode. The SoC can be woken from mem sleep state through wake-up GPIOs or internal SNVS RTC.
Entering in suspend to mem mode:
# echo mem > /sys/power/state
Or
# systemctl suspend
Note:
systemctl suspend
to initiate suspend to mem.The Wi-Fi subsystem currently does not support suspend. Thus the related kernel module needs to be unloaded.
# modprobe -r mwifiex_sdio
Two sleep states are supported by the Linux kernel on Verdin iMX8M Mini: Suspend-to-RAM and Suspend-to-Idle.
To enter on Suspend-to-RAM state:
# echo enabled > /sys/class/tty/ttymxc0/power/wakeup; echo deep > /sys/power/mem_sleep; echo mem > /sys/power/state
The system will wake up with WAKE1_MICO#
(SODIMM_252, X7-24) pin or with a console keypress.
You can also set the system to wake up with RTC alarm in 5 secs from now:
# echo +5 > /sys/class/rtc/rtc1/wakealarm; echo deep > /sys/power/mem_sleep; echo mem > /sys/power/state
To enter on S2Idle state:
# echo enabled > /sys/class/tty/ttymxc0/power/wakeup; echo s2idle > /sys/power/mem_sleep; echo mem > /sys/power/state
If there is the need to make an application aware of the Suspend/Resume events, one can use Systemd to accomplish it.
Systemd has in place the systemd-suspend.service
(Reference: https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#SuspendMode=), which can be used by the developer to create other services the are nedded to be executed before entering suspend mode (before the systend-suspend.service
) and/or after resuming ( after the systend-suspend.service
).
The sample service below will send the signal USR1 (SIGUSR1
) to an application right before the system entering in suspend mode.
It can be saved as /etc/systemd/system/signal_before_suspend.service
.
[Unit]
Description=Sends signal USR1 to application signal_test before system entering in suspend mode.
Before=sleep.target
[Service]
Type=oneshot
ExecStart=killall -s SIGUSR1 signal_test
User=root
[Install]
RequiredBy=sleep.target
Activating the service:
$ systemctl enable signal_before_suspend.service
Starting the service:
$ systemctl start signal_before_suspend.service
The sample service below will send the signal USR2 (SIGUSR2
) to an application right after the system resuming.
It can be saved as /etc/systemd/system/signal_after_resume.service
.
[Unit]
Description=Sends signal USR2 to application signal_test before system resumes.
After=sleep.target
[Service]
Type=oneshot
ExecStart=killall -s SIGUSR2 signal_test
User=root
[Install]
RequiredBy=sleep.target
Activating the service:
$ systemctl enable signal_after_resume.service
Starting the service:
$ systemctl start signal_after_resume.service
The package pm-utils
has some ready-to-use hooks and also allows you to create your own hooks.
Important links: