ccimx93: standby: customize script support for systemd

We need to take in account if the IW612 chip (WiFi/Bt) is going to be powered
off on suspend state. In such a case, we need to unload the driver modules and
restore the expected tty speed for Bluetooth, so that functionality is restored
back on resume.

https://onedigi.atlassian.net/browse/DEL-8489

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2023-04-24 09:07:53 +02:00 committed by Javier Viguera
parent b980c2f1ff
commit fd5ee3a5e3
1 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,60 @@
#!/bin/sh
#===============================================================================
#
# standby-actions
#
# Copyright (C) 2023 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: manage interfaces before suspending and after resuming from
# suspend
#
#===============================================================================
SUSPEND_WLAN_IFACES="/tmp/suspend_wlan_ifaces"
actions_needed() {
[ -d "/proc/device-tree/wireless" ] && [ ! -e "/sys/firmware/devicetree/base/soc@0/bus@42800000/mmc@428b0000/keep-power-in-suspend" ]
}
if [ "${1}" = "pre" ]; then
# Stop NetworkManager before suspend
systemctl stop NetworkManager
if actions_needed; then
rm -f "${SUSPEND_WLAN_IFACES}"
for iface in mlan0 uap0 wfd0; do
if grep -qs ${iface} /var/run/ifstate; then
ifdown ${iface} && echo ${iface} >> "${SUSPEND_WLAN_IFACES}"
fi
done
rmmod moal
rmmod mlan
systemctl stop bluetooth
systemctl stop bluetooth-init
stty -F /dev/ttyBt 115200
fi
elif [ "${1}" = "post" ]; then
if actions_needed; then
/etc/udev/scripts/load_iw612.sh
sleep 0.5
while read -r iface; do
ifup "${iface}"
done < "${SUSPEND_WLAN_IFACES}"
rm -f "${SUSPEND_WLAN_IFACES}"
systemctl start bluetooth-init
systemctl start bluetooth
fi
# Resume NetworkManager after suspend
systemctl start NetworkManager
fi