The Linux kernel uses several power management strategies:

  • Dynamic voltage frequency scaling (DVFS) adjusts the CPU frequency and the different voltages depending on the system’s load. The combination of a CPU frequency and a set of voltages for that frequency is called an operating point.

  • Suspend to memory allows for the system to sleep waiting for an event. On suspend, all 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 wake up, the bootloader starts up again and the system is initialized.

Dynamic Voltage Frequency Scaling

Dynamic Voltage Frequency Scaling is enabled by default, so the CPU frequency and voltages of a running system will adapt to the system’s load. The DVFS subsystem is controlled through the /sys/devices/system/cpu/cpuN/cpufreq/ sysfs path, where N corresponds to the core number:

Sysfs attributes of CPU frequency scaling
# ls /sys/devices/system/cpu/cpu0/cpufreq/
affected_cpus                  related_cpus                   scaling_governor
cpuinfo_cur_freq               scaling_available_frequencies  scaling_max_freq
cpuinfo_max_freq               scaling_available_governors    scaling_min_freq
cpuinfo_min_freq               scaling_cur_freq               scaling_setspeed
cpuinfo_transition_latency     scaling_driver                 stats

The scaling_cur_freq file shows the current frequency of the core:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

The available frequencies are shown in scaling_available_frequencies.

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

The DVFS subsystem can be configured with different governors that control its behavior. The available governors are listed in scaling_available_governors.

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative userspace powersave ondemand performance schedutil
Actual output may differ depending on kernel version/configuration.

The current governor is shown in scaling_governor, and by default is set to the ondemand governor.

  • ondemand: This governor does a periodic polling to adjust the operating mode to the system load.

  • conservative: Similar to the ondemand governor, the conservative governor performs graceful frequency and voltage changes that are better suited to battery powered devices.

  • powersave: This governor uses the lowest available frequency without dynamic adaptation.

  • userspace: This governor allows for user space to select the operating frequencies.

  • performance: This governor uses the highest available frequency without dynamic adaptation.

  • schedutil: This governor uses an scheduler-driven CPU frequency selection.

Manually select a working CPU frequency
# echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
900000 1200000
# echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
900000

Suspend to memory

The Linux kernel can also 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 press (less than two seconds) the power key

Resume events

The system can resume from any interrupt generating event, including:

  • MCA GPIOs

  • MCA RTC alarm

  • Power key event

  • Wake on LAN (if supported by the driver)

By default, the power key event will always be registered to resume a system from suspend. 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 two seconds, but less than nine seconds, to perform a controlled software power off sequence.

  • Press the power key for nine seconds or longer to perform an unconditional hardware power off (not controlled by software).

  • Run poweroff_safe [-t <timeout>] from the command line. It instructs the MCA to force a system power-off after a timeout (in seconds). The default timeout value is 30 seconds if the <timeout> parameter is not defined.

Press time values are configurable on the MCA power key device tree.

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

  • MCA GPIOs

  • MCA RTC alarm

The power key will always wake up the system.

Configuring wake-up sources

GPIO resume from suspend

MCA GPIOs as wake-up source

MCA GPIOs are configured as wake-up sources. To program an MCA GPIO to generate a wake-up interrupt when it changes status:

  • Run gpiomon waiting for one event on a given MCA GPIO (either rising or falling edge) with an ampersand at the end to send the task to the background:

    # gpiomon --num-events 1 --rising-edge mca-gpio 11 &
  • Suspend:

    # standby
  • Set the MCA GPIO high (or low if you configured it falling edge) to wake the system up.

CPU GPIOs as wake-up source

CPU GPIOs can only act as wake-up sources if they have been configured as such in the GPIO port. On the default device tree, no GPIO is configured as wake-up source. To configure a GPIO as wake-up source, add the the following properties to the GPIO port device tree node:

  • pad-wakeup-num: Number of pads configured in the port as wake-up sources.

  • pad-wakeup: List of pad configurations on the port. Every pad configuration consists of:

For example, to configure GPIO4_20 and GPIO4_21 as falling edge wake-up sources, add the following entry to the device tree:

&lsio_gpio4 {
	pad-wakeup-num = <2>;
	pad-wakeup = <IMX8QXP_USDHC1_VSELECT 5 20>,
		     <IMX8QXP_USDHC1_WP 5 21>;
};

Make sure the power domain of the selected pads is enabled during suspend or the pads will not be able to wake up the system. For that:

  1. Locate the power domain of a given GPIO on the ConnectCore 8X SBC Pro schematics. See the GPIO pad power domain section.

  2. Identify the regulator on the device tree (in the example reg_1v8) and configure it to stay on even during suspend:

    &reg_1v8 {
    	regulator-always-on;
    };

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

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.

Coin cell charger

If using a rechargeable coin cell, you can enable the coin cell charger, which is disabled by default.

To enable it, add the following lines to your custom device tree file:

&pf8x00_sc {
	vcoin_reg: VCOIN {
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3600000>;
		regulator-always-on;
	};
};

The coin cell charger provides 60 uA current in run mode and 10 uA in suspend. You can configure multiple voltage values between 1800000 and 3600000 uV depending on the requirements of the connected battery.

The ConnectCore 8X SBC Pro has a circuit that implements the coin cell charger.