I am trying to find wakeup source on VF61 for standby mode. /sys/kernel/debug/wakeup_sources
records some information. For gpio wakeup, last_change
can will show the time when entering standby mode. But for ttyLP0, last_change
only record the time when initiating command # echo enabled > /sys/class/tty/ttyLP0/power/wakeup
and it doesn’t change no matter how many times system is waken up by ttyLP0. It will be difficult to tell which source wakes up system. Is there other way to find wakeup source?
root@colibri-vf:~# cat /sys/kernel/debug/wakeup_sources
name active_count event_count wakeup_count expire_count active_since total_time max_time last_change prevent_suspend_time
ttyLP0 0 0 0 0 0 0 0 57190 0
gpio-keys 4 4 0 0 0 26 16 367017 0
usbc_det 0 0 0 0 0 0 0 1548 0
400a7000.snvs:snvs-rtc-lp 0 0 0 0 0 0 0 1292 0
alarmtimer 0 0 0 0 0 0 0 163 0
deleted 0 0 0 0 0 0 0 0 0
This counters are provided by the system wakeup event framework, which is a relatively new framework and needs “opt-in” by drivers to actually make use of it. This means the driver needs to detect whether there has been a wake-up interrupt, and needs to call the framework to increase counters. Clearly not all drivers implement this functionality, including the Vybrid UART driver (lpuart). With this change the UART driver notifies the framework about wakeup events:
http://git.toradex.com/cgit/linux-toradex.git/commit/?h=toradex_vf_4.4-next&id=849412836858ae27893c8bcfd0ceef0df88d9409
Note that you should not use files under /sys/kernel/debug/
for application development, since their interface might change or they might disappear completely in future kernel version. The wake-up counters are also available in the stable sysfs ABI in the power folder of every device, e.g. /sys/class/tty/ttyLP0/power/wakeup_count
or /sys/devices/platform/gpio-keys/power/wakeup_count
. See also:
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-power