3.3.6. Wakeup Sources
This section talks about the multiple ways in which we can wakeup the AM62Lx SoC from various low power modes. The AM62Lx SoC support various wakeup sources like GP Timers, RTC Timer, UART, I2C, WKUP GPIO, and I/O Daisy Chain.
The table below lists the wakeup sources supported in this SDK release and whether that source is valid for given low power modes:
Wakeup Source |
Deep Sleep |
RTC Only + DDR |
RTC Only |
|---|---|---|---|
Real-Time Clock (RTC) |
Yes |
Yes |
Yes |
WKUP GPIO |
Yes |
No |
No |
Main I/O Daisy Chain (Main GPIO and Main UART) |
Yes |
No |
No |
WKUP UART |
Yes |
No |
No |
USB Wakeup |
Yes |
No |
No |
RTC Ext Pin |
Yes |
Yes |
Yes |
3.3.6.1. Real-Time Clock (RTC)
It’s possible to use the SoC’s internal RTC to wakeup the system using the command rtcwake:
rtcwake
- Show whether an alarm is set or not:
rtcwake -m show -v
- Suspend to RAM and wakeup after 10 seconds:
rtcwake -m mem -s {{10}}
- Disable a previously set alarm:
rtcwake -m disable
- Perform a dry run to wakeup the computer at a given time. (Press Ctrl + C to abort):
rtcwake -m on --date {{hh:ss}}
For example, to wakeup from Deep Sleep in 10 seconds, use the command like this:
root@am62lxx-evm:~# rtcwake -m mem -s 10
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Thu Jan 1 00:00:46 1970
[ 28.138624] PM: suspend entry (deep)
[ 28.142400] Filesystems sync: 0.000 seconds
[ 28.159141] Freezing user space processes
[ 28.169800] Freezing user space processes completed (elapsed 0.002 seconds)
[ 28.176909] OOM killer disabled.
[ 28.180168] Freezing remaining freezable tasks
[ 28.186015] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[ 28.193484] printk: Suspending console(s) (use no_console_suspend to debug)
ERROR: Wake up src 0x10000
[ 28.229712] Disabling non-boot CPUs ...
[ 28.232172] psci: CPU1 killed (polled 0 ms)
[ 28.233437] Enabling non-boot CPUs ...
[ 28.233757] Detected VIPT I-cache on CPU1
[ 28.233811] GICv3: CPU1: found redistributor 1 region 0:0x0000000001860000
[ 28.233875] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 28.235241] CPU1 is up
[ 28.257825] am65-cpsw-nuss 8000000.ethernet: set new flow-id-base 96
[ 28.271845] am65-cpsw-nuss 8000000.ethernet eth0: PHY [8000f00.mdio:00] driver [TI DP83867] (irq=POLL)
[ 28.271880] am65-cpsw-nuss 8000000.ethernet eth0: configuring for phy/rgmii-rxid link mode
[ 28.285658] am65-cpsw-nuss 8000000.ethernet eth1: PHY [8000f00.mdio:01] driver [TI DP83867] (irq=POLL)
[ 28.285678] am65-cpsw-nuss 8000000.ethernet eth1: configuring for phy/rgmii-rxid link mode
[ 28.364033] OOM killer enabled.
[ 28.367181] Restarting tasks ... done.
[ 28.378392] random: crng reseeded on system resumption
[ 28.384269] PM: suspend exit
3.3.6.2. MCU GPIO
MCU GPIO wakeup is not supported on AM62LX.
3.3.6.3. WKUP GPIO
One of the most common ways to wakeup a system is by using some I/O activity.
I/O activity on the WKUP GPIOs can wakeup the system when the WKUP GPIO
controller is configured as a wakeup source. Refer to the wkup_gpio_key node
in
k3-am62l3-evm-lpm-wkup-sources.dtso
to use as a template to configure the desired WKUP GPIO as a wakeup capable
GPIO.
A brief guide to configuring an WKUP GPIO as wakeup:
Add “gpio-keys” as a compatible string, refer to gpio_keys kernel documentation for details.
compatible = "gpio-keys";
Set the desired pinctrl.
pinctrl-names = "default"; pinctrl-0 = <&wake_wkupgpio0_pins_default>;
Setup the interrupt parent as WKUP GPIO, then setup the interrupt.
interrupt-parent = <&wkup_gpio0>; interrupts = <0 IRQ_TYPE_EDGE_RISING>;
Create following child node as a
switchnode:switch { label = "WKUPGPIO"; linux,code = <143>; gpios = <&wkup_gpio0 0 GPIO_ACTIVE_LOW>; wakeup-source; };
label: Descriptive name of the switch node. If the WKUP GPIO node is setup correctly, the label will appear under
/proc/interrupts.linux,code: Keycode to emit.
gpios: the GPIO required to be used as the gpio-key.
wakeup-source: wakeup-source property describes devices which have wakeup capability.
To confirm that gpio_keys can wakeup the system from Deep Sleep, check
/proc/interruptsfor the label:root@<machine>:~# cat /proc/interrupts | grep "WKUPGPIO" 23: 0 0 GPIO 0 Edge -davinci_gpio WKUPGPIO
The WKUP GPIOs can be used to wakeup the system from Deep Sleep because WKUP GPIOs are in a power domain that stays ON when the SoC is in Deep Sleep. Hence, the GPIO controller is able to act as a wakeup source and send a wakeup interrupt to the system.
WKUP GPIO wakeup can only be tested when k3-am62l3-evm-lpm-wkup-sources.dtso overlay is loaded. Refer to How to enable DT overlays for more details. The WKUP GPIO in the overlay is routed from the WKUP UART. With this configuration the WKUP UART is not available as a wakeup source.
Once the system has entered Deep Sleep as shown in the LPM section, wakeup from WKUP_UART0_RXD can be triggered by entering a keypress on the WKUP UART (/dev/ttyUSB2).
3.3.6.4. Main I/O Daisy Chain
The system powers off the main domain when the SoC enters a low power mode. The main domain includes controllers such as Main UART, GPIO, I2C, etc. I/O daisy chaining is used in order to wakeup the SoC from peripherals that are connected to powered-off controllers. At the hardware level, all the pads in an SoC are pinmuxed to dedicated controllers like UART or GPIO.
For example, to wakeup the system from Deep Sleep via a key press on Main UART (used for Linux console logs), then simply configuring the Main UART controller as a wakeup source wouldn’t work. This is because the UART controller is powered off and wouldn’t be able to register any key press as a wakeup event. However, the UART is still connected at the “pad” level and the pads can be configured as wakeup sources by setting a specific bit in the pad register.
For detailed information and sequence please refer to I/O Power Management and Daisy Chaining section in the TRM.
Note
AM62Lx supports the ability to wakeup using pad based wake event ONLY in Deep Sleep. During active system usage, even if the wake_enable bit is set the system will be unresponsive to any wakeup activity on that pad.
To demonstrate I/O daisy chain wakeup as part of AM62Lx offering, two reference examples are provided:
main_uart0 is used where a key press on the Linux console can wakeup the system.
main_gpio is used where activity on configured GPIO pin can wakeup the system.
3.3.6.4.1. Main UART
To configure UART as an I/O daisy chain wakeup, refer to the main_uart0 node in k3-am62l3-evm.dts
&pmx0 {
uart0_pins_default: uart0-default-pins {
pinctrl-single,pins = <
AM62LX_IOPAD(0x01b4, PIN_INPUT, 0) /* (D13) UART0_RXD */
AM62LX_IOPAD(0x01b8, PIN_OUTPUT, 0) /* (C13) UART0_TXD */
>;
bootph-all;
};
uart0_pins_wakeup: uart0-wakeup-pins {
pinctrl-single,pins = <
AM62LX_IOPAD(0x01b4, PIN_INPUT | PIN_WKUP_EN, 0) /* (D13) UART0_RXD */
AM62LX_IOPAD(0x01b8, PIN_OUTPUT, 0) /* (C13) UART0_TXD */
>;
};
};
&uart0 {
pinctrl-0 = <&uart0_pins_default>;
pinctrl-1 = <&uart0_pins_wakeup>;
pinctrl-names = "default", "wakeup";
wakeup-source;
status = "okay";
bootph-all;
};
In the above code, a “wakeup” pinctrl state is defined for main_uart0. The “wakeup” pinctrl state sets the WKUP_EN flag on the desired padconfig register, which allows the pad to act as a wakeup source. During suspend, the Linux 8250_omap serial driver switches from the “default” pinctrl state to the “wakeup” pinctrl state.
This configures UART to act as a wakeup source, and a key press on same terminal should trigger a wakeup from LPM.
Any UART can be chosen according to application requirements.
3.3.6.4.2. Main GPIO
Configuring Main GPIO as an I/O daisy chain wakeup source requires a combination of gpio-keys with a chained IRQ in the pinctrl driver. Setting the 29th bit in the desired padconfig register, allows the pad to act as a wakeup source by triggering a wake IRQ in Deep Sleep states.
The reference configuration for Main GPIO wakeup can be found under gpio_key node in k3-am62l3-evm.dts
gpio_key { compatible = "gpio-keys"; autorepeat; pinctrl-names = "default"; pinctrl-0 = <&usr_button_pins_default>; switch { label = "User Key"; linux,code = <BTN_0>; interrupts-extended = <&main_gpio0 90 IRQ_TYPE_EDGE_RISING>, <&main_pmx0 0x1ac>; interrupt-names = "irq", "wakeup"; }; };
The IRQ is chained to the pinctrl driver using the second interrupts-extended entry. The wake IRQ framework in Linux works so that the second entry gets marked as a wakeup source, and then the pinctrl driver is informed that the pad, 0x1ac in this case, is to be configured as a wakeup pad when system enters Deep Sleep.
To use main_gpio as a wakeup source, ensure gpio is a wake-irq in
/proc/interrupts:
root@<machine>:~# grep wakeup /proc/interrupts
299: 0 0 pinctrl 428 Edge User Key:wakeup
Once the system has entered Deep Sleep as shown in the LPM section, wakeup from MAIN GPIO0_90 can be triggered by pressing button SW5.
3.3.6.5. WKUP UART
The UART in WKUP domain is capable of waking up the system.
In order to use WKUP UART as a wakeup source, it needs to be configured in a generic way using the ti-sysc interconnect target module driver. The reference configuration can be found under target-module in k3-am62-wakeup.dtsi
WKUP UART is generally available on the third serial port (/dev/ttyUSB2).
Once the system has entered the specified low power mode as shown in the LPM section, wakeup from WKUP UART can be triggered by doing any key press on the WKUP UART terminal. No output will be visible on the WKUP UART terminal, but Linux resume messages will be printed on the MAIN UART terminal.
3.3.6.6. USB Wakeup methods
System wakeup is possible through the USB events in both Host and Device mode.
3.3.6.6.1. Host Mode Wakeup Events
The USB wakeup events in Host mode are described below:
3.3.6.6.1.1. Wakeup via a device connect event
Follow the steps described in LPM section to enter desired low power mode.
Now plug in a USB device to one of the port on the board and the system should wakeup. Post wakeup, the device would show up enumerated. This can be checked by below command before and after suspending and waking up the system.
# lsusb -t
3.3.6.6.1.2. Wakeup via a device disconnect event
Plug in a USB device to one of the port on the board and check that the device is enumerated by executing the below command.
# lsusb -t
Follow the steps described in LPM section to enter desired low power mode.
Once the system is suspended, disconnect the USB device from the board and this should wakeup the system. The device will not show up in list of USB enumerated devices. This can be verified by executing
# lsusb -t
3.3.6.6.1.3. Via Remote wakeup event
Use a device that supports USB suspend/resume and ensure that the USB device can suspend and resume correctly. For a example a Logitech USB keyboard that supports suspend/resume. Follow below steps to check whether the keyboard is capable to trigger a remote wakeup event to system.
Assuming the USB keyboard device is at /sys/bus/usb/devices/1-1/, enable USB autosuspend and wakeup
# echo auto > /sys/bus/usb/devices/1-1/power/control
# echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
Allow for two seconds of inactivity and check the runtime power status of the keyboard. It should show “suspended”, indicating that the keyboard has entered into suspend state.
# cat /sys/bus/usb/devices/1-1/power/runtime_status
Now press a key on the keyboard and check the runtime power status and it would come back to “active”.
# cat /sys/bus/usb/devices/1-1/power/runtime_status
Follow the steps described in LPM section to enter desired low power mode.
And once in suspended state, trigger system wakeup via remote wakeup event by typing keys on the keyboard. The system would wakeup. And USB keyboard would still be present in the system’s list of USB enumerated devices and this can be verified by executing
# lsusb -t
3.3.6.6.2. Device Mode Wakeup Events
3.3.6.6.2.1. Wakeup via connect event
Load a USB gadget driver such as g_zero
# modprobe g_zero
Follow the steps described in LPM section to put the system enter desired low power mode.
Once the system has entered the suspend state, plug a cable from a different Host system to the board’s USB DRP port. This should wakeup the system and gadget will be enumerated on the Host. Enumeration of the gadget on the Host system can be verified by executing the below command on the Host system
# lsusb -t
3.3.6.7. MCU IPC based Wakeup
MCU IPC wakeup is not supported on AM62LX.
3.3.6.8. CAN I/O Daisy Chain
CAN wakeup is not supported on AM62LX.
3.3.6.9. RTC Ext Pin
To resume using RTC Ext pin wakeup, press the following button on the EVM:
3.3.6.10. Confirming the Wakeup event type
This is not applicable for AM62LX.