108 lines
2.9 KiB
Plaintext
Executable File
108 lines
2.9 KiB
Plaintext
Executable File
#!/sbin/openrc-run
|
|
description="Platina Hexagon DSP, RMTFS, and WCN3990 Wi-Fi bringup"
|
|
|
|
depend() {
|
|
after udev modules
|
|
before networkmanager
|
|
}
|
|
|
|
ipa_bringup_mode() {
|
|
case " $(cat "${1:-/proc/cmdline}" 2>/dev/null) " in
|
|
*" platina.ipa_bringup=1 "*) return 0 ;;
|
|
esac
|
|
return 1
|
|
}
|
|
|
|
start_remoteprocs() {
|
|
local root="$1" hold_modem="$2" rproc
|
|
for rproc in "$root"/remoteproc*; do
|
|
if [ -d "$rproc" ] && [ -f "$rproc/state" ]; then
|
|
if [ "$hold_modem" = 1 ] &&
|
|
[ "$(cat "$rproc/name" 2>/dev/null)" = "4080000.remoteproc" ]; then
|
|
continue
|
|
fi
|
|
if [ "$(cat "$rproc/state" 2>/dev/null)" = "offline" ]; then
|
|
echo start > "$rproc/state" 2>/dev/null || true
|
|
fi
|
|
fi
|
|
done
|
|
}
|
|
|
|
start() {
|
|
local hold_modem=0
|
|
if ipa_bringup_mode; then
|
|
hold_modem=1
|
|
fi
|
|
ebegin "Initializing Platina DSP and WCN3990 Wi-Fi"
|
|
# 1. Manage initramfs modem/IPA blacklists for normal vs early bringup mode
|
|
sed -i "/qcom_q6v5_mss/d" /etc/modprobe.d/modem-blacklist.conf 2>/dev/null || true
|
|
if [ "$hold_modem" = 1 ]; then
|
|
if ! grep -q "blacklist ipa" /etc/modprobe.d/modem-blacklist.conf 2>/dev/null; then
|
|
printf "install ipa /bin/true\nblacklist ipa\n" > /etc/modprobe.d/modem-blacklist.conf
|
|
fi
|
|
else
|
|
sed -i "/ipa/d" /etc/modprobe.d/modem-blacklist.conf 2>/dev/null || true
|
|
if [ -f /etc/modprobe.d/modem-blacklist.conf ] &&
|
|
[ ! -s /etc/modprobe.d/modem-blacklist.conf ]; then
|
|
rm -f /etc/modprobe.d/modem-blacklist.conf
|
|
fi
|
|
fi
|
|
|
|
# 2. Ensure kernel modules are loaded
|
|
modprobe qcom_rmtfs_mem 2>/dev/null || true
|
|
modprobe qcom_q6v5_pas 2>/dev/null || true
|
|
modprobe qcom_q6v5_mss 2>/dev/null || true
|
|
if [ "$hold_modem" = 0 ]; then
|
|
modprobe ipa 2>/dev/null || true
|
|
fi
|
|
|
|
# 3. Ensure tqftpserv and rmtfs daemons are running
|
|
if ! pidof tqftpserv >/dev/null 2>&1; then
|
|
rc-service tqftpserv restart 2>/dev/null || /usr/bin/tqftpserv &
|
|
fi
|
|
if ! pidof rmtfs >/dev/null 2>&1; then
|
|
if [ "$hold_modem" = 1 ]; then
|
|
rc-service rmtfs restart 2>/dev/null || /usr/bin/rmtfs -P -r -v &
|
|
else
|
|
rc-service rmtfs restart 2>/dev/null || /usr/bin/rmtfs -s -P -r -v &
|
|
fi
|
|
fi
|
|
|
|
# Wait up to 3s for remoteproc nodes to register
|
|
for i in 1 2 3; do
|
|
if [ -d /sys/class/remoteproc ]; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
# 4. Start any offline remoteproc instance (modem/ADSP/CDSP)
|
|
start_remoteprocs /sys/class/remoteproc "$hold_modem"
|
|
|
|
# 5. Ensure pd-mapper is running
|
|
if ! pidof pd-mapper >/dev/null 2>&1; then
|
|
rc-service pd-mapper restart 2>/dev/null || /usr/bin/pd-mapper &
|
|
fi
|
|
|
|
# Wait for modem remoteproc to be running before probing ath10k
|
|
if [ "$hold_modem" = 0 ]; then
|
|
for i in 1 2 3 4 5; do
|
|
for rproc in /sys/class/remoteproc/remoteproc*; do
|
|
if [ -f "$rproc/name" ] && grep -q "4080000" "$rproc/name" 2>/dev/null; then
|
|
if [ "$(cat "$rproc/state" 2>/dev/null)" = "running" ]; then
|
|
break 2
|
|
fi
|
|
fi
|
|
done
|
|
sleep 1
|
|
done
|
|
fi
|
|
|
|
# 6. Load ath10k_snoc Wi-Fi driver cleanly
|
|
if ! lsmod | grep -q ath10k_snoc; then
|
|
modprobe ath10k_snoc 2>/dev/null || true
|
|
fi
|
|
|
|
eend 0
|
|
}
|