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.
Entering suspend mode
To enter suspend mode:
-
Run
/bin/standby
from the command line, or -
Briefly (less than two seconds) press the power key
Resume events
The system can resume from any interrupt-generating event, including:
-
Internal RTC alarm
-
External RTC alarm
-
Power key event
-
Wake on LAN (if supported by the driver)
-
Wake on wireless LAN (if supported by the driver)
The following wake-up sources are enabled by default:
-
Power key
-
Internal RTC alarm
See Configuring wake-up sources for additional details.
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.
Entering 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 longer than six seconds to perform a controlled software power-off sequence.
Wake up events
You can wake up the target from power-off mode with an interrupt event to the PMIC, but not to the CPU as it will not be powered. These include:
-
Power key event
-
Internal RTC alarm
-
External RTC alarm
Press the power key for one second or longer to wake the system from power-off. |
Configuring wake-up sources
GPIO resume from suspend
CPU GPIOs as wake-up source
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 the device tree:
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
...
gpio-keys {
compatible = "gpio-keys";
power {
label = "Power Button";
gpios = <&gpio2 20 GPIO_ACTIVE_LOW>;
linux,code = <KEY_POWER>;
gpio-key,wakeup;
};
};
...
};
Triggering the GPIO during suspend wakes the system up. Triggering the GPIO when the system is running also sends the KEY_POWER event, which powers the system off. |
RTC alarm resume
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
Wake On Wireless LAN (WoWLAN)
The Murata LBEE5PL2DL Wi-Fi chip can wake the ConnectCore 93 from standby through Wake on Wireless LAN standard. This functionality requires that the Wi-Fi chip remains enabled during suspend. To configure your device to wake on Wireless LAN:
-
Adjust the device tree to keep the chip powered on during suspend, as follows.
ccimx9_wifi.dtso device tree... fragment@1 { target = <&usdhc3>; __overlay__ { status = "okay"; + keep-power-in-suspend; }; }; ... + /* Keep regulator ON in suspend */ + fragment@3 { + target = <&buck4>; + __overlay__ { + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + };
-
Generate a file called
dut_mgc.conf
as shown below:mefcfg={ Criteria=2 NumEntries=1 mef_entry_0={ mode=1 action=1 filter_num=1 RPN=Filter_0 Filter_0={ type=0x46 repeat=16 byte=XX:XX:XX:XX:XX:XX offset=28 } } }
where
XX:XX:XX:XX:XX:XX
is the MAC address of the Wi-Fi interface. -
Enable wireless as a wake-up source:
# iw phy mwiphy0 wowlan enable magic-packet # echo enabled > /sys/bus/platform/devices/428b0000.mmc/power/wakeup # mlanutl wlan0 mefcfg dut_mgc.conf # mlanutl wlan0 auto_arp 0 # mlanutl wlan0 hscfg 0 0xff
Test system wake-up
Once you have enabled Ethernet or wireless as a wake-up source for your ConnectCore 93, you can test the functionality to make sure it behaves as you want it to. To test your system’s wake function:
-
Connect to an Access Point. See Connect for instructions.
-
Suspend the system:
# standby
-
Wake the system by sending a WOL packet from your host computer (you may need root permissions):
$ etherwake -i <host_iface> XX:XX:XX:XX:XX:XX
where:
-
host_iface
is the host interface to use to send the magic packet, which must be able to reach the Wi-Fi network to which the device is connected. -
XX:XX:XX:XX:XX:XX
is the MAC address of the network interface.
-
For more complex setups or information about other wakeup options, visit https://www.nxp.com/docs/en/application-note/AN14465.pdf. |