I’m now testing modified suspend script which I plan to make a suspend target unit (to utilize systemd based suspend).
The script is below, I have tested it successfully during the day, and left overnight - which also woke up ok. It draws suspiciously big power during sleep though - 240mA in active state and 100mA in suspend (so about 2.5W). I’d expect it to be lower.
If I try to poweroff aux (mpcie, by PWR3 command) it does not affect power draw (actually makes it slightly bigger?!) but it also makes system a bit unstable - eg. system lockup when doing lspci.
Either way, there could be some win by suspending nvme perhaps (which could be done via sysfs nodes) but major win should be by clocking down various clocks (eg memory, bus, maybe shutting off some spi/i2c perephery?). Any quick hints?
The modified script:
$ cat standby
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "reform-standby has to be run as root / using sudo."
exit
fi
set_wakes() {
# configure UARTs as wakeup sources
echo enabled > /sys/devices/platform/soc@0/30800000.bus/30860000.serial/tty/ttymxc0/power/wakeup
echo enabled > /sys/devices/platform/soc@0/30800000.bus/30890000.serial/tty/ttymxc1/power/wakeup
echo enabled > /sys/devices/platform/soc@0/30800000.bus/30880000.serial/tty/ttymxc2/power/wakeup
}
radio_off() {
# remove PCI device
echo 1 > /sys/class/pci_bus/0000:01/device/remove
# turn off the power on the mpcie
#echo -en "\0PWR3" > /dev/hidraw0
#sleep 1
}
radio_on() {
# turn on the power on the mpcie
#echo -en "\0PWR4" > /dev/hidraw0
#sleep 1
echo 1 > /sys/class/pci_bus/0000:00/rescan
sleep 1
}
bklite_off() {
echo -en "\0LITE0" > /dev/hidraw0
}
bklite_on() {
echo -en "\0LITE6" > /dev/hidraw0
}
# Countdown for manual run
if [[ -z "$1" ]]; then
echo Entering standby in 3...
sleep 1
echo 2...
sleep 1
echo 1...
sleep 1
fi
# Either manual or suspending
if [[ -z "$1" || $1 = "suspend" ]]; then
set_wakes
radio_off
bklite_off
fi
# Go sleeping for manual run
if [[ -z "$1" ]]; then
sync
echo mem >/sys/power/state
sleep 1
fi
# Either manual or resuming
if [[ -z "$1" || $1 = "resume" ]]; then
bklite_on
radio_on
fi