Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
447 changes: 447 additions & 0 deletions device/husky/MODEM-PLAN.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions device/husky/bringup/s5b.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes.
L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5b.log
: > $O
snap() { echo "$(date +%T.%N | cut -c1-12) $1 $(awk '{printf "%s=%s ",$1,$2}' $L/lines) ufs=$(grep -vc ': 0$' $U) errh=$(dmesg | grep -c 'ufshcd_err_handler started') bat=$(cat /sys/class/power_supply/*battery*/capacity)% bt=$(cat /sys/class/power_supply/*battery*/temp)" >> $O; }
snap pre
echo 1 > $L/gpio_on; echo "gpio_on rc=$?" >> $O
i=0
while [ $i -lt 55 ]; do
sleep 1; i=$((i+1)); snap "on+$i"
if [ "$(grep -vc ': 0$' $U)" != 0 ]; then echo "STOP-UFS-COUNTER" >> $O; break; fi
done
echo 1 > $L/gpio_off; echo "gpio_off rc=$?" >> $O
for t in 1 5 10 30 60; do
sleep $([ $t = 1 ] && echo 1 || echo 5); snap "off+$t"
done
echo DONE >> $O
14 changes: 14 additions & 0 deletions device/husky/bringup/s5c-control.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes.
# CONTROL for S5c: the same 30 s + 55 s + 30 s sampling, NO writes to any modem line. Log: /root/s5c-control.log
L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5c-control.log
B=/sys/class/power_supply/max170xx_battery
: > $O
snap() { echo "$(date +%T.%N | cut -c1-12) $1 cur=$(cat $B/current_now) avg=$(cat $B/current_avg) v=$(cat $B/voltage_now) bat=$(cat $B/capacity)% bt=$(cat $B/temp) ufs=$(grep -vc ': 0$' $U) lines=$(awk '{s+=$2} END {print s+0}' $L/lines)" >> $O; }
i=0; while [ $i -lt 30 ]; do snap "base-$i"; sleep 1; i=$((i+1)); done
snap "pda1(none)"
i=0; while [ $i -lt 55 ]; do sleep 1; i=$((i+1)); snap "on+$i(none)"; done
sleep 2; snap "off+2(none)"
for t in 3 8 13 18 23 28; do sleep 5; snap "post+$t(none)"; done
echo DONE >> $O
37 changes: 37 additions & 0 deletions device/husky/bringup/s5c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes.
# S5c (TEST ONLY): pda_active=1, then gpio_on once, 55 s of 1 s samples, gpio_off, pda_active=0 only if the CP side is quiet.
# Runs ON the phone so the power-off happens even if ssh drops. Log: /root/s5c.log
L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5c.log
B=$(ls -d /sys/class/power_supply/*battery* | head -1)
: > $O
cp2ap() { awk '/^CP2AP_/ {s+=$2} END {print s+0}' $L/lines; }
ufsbad() { [ "$(grep -vc ': 0$' $U)" != 0 ] || [ "$(dmesg | grep -c 'ufshcd_err_handler started')" != 0 ]; }
snap() { echo "$(date +%T.%N | cut -c1-12) $1 $(awk '{printf "%s=%s ",$1,$2}' $L/lines | sed 's/AP2CP_//g;s/CP2AP_/c2a_/g') ufs=$(grep -vc ': 0$' $U) cur=$(cat $B/current_now) avg=$(cat $B/current_avg 2>/dev/null) v=$(cat $B/voltage_now) bat=$(cat $B/capacity)% bt=$(cat $B/temp)" >> $O; }
# 30 s baseline at the same cadence
i=0; while [ $i -lt 30 ]; do snap "base-$i"; sleep 1; i=$((i+1)); done
BASE=$(awk '/ base-/ {for(i=1;i<=NF;i++) if ($i ~ /^cur=/) {sub("cur=","",$i); s+=$i; n++}} END {printf "%d", s/n}' $O)
echo "baseline cur=$BASE uA" >> $O
echo 1 > $L/pda_active; echo "pda_active=1 rc=$?" >> $O; snap "pda1"
echo 1 > $L/gpio_on; RC=$?; echo "gpio_on rc=$RC" >> $O
STOP=""
if [ $RC = 0 ]; then
i=0
while [ $i -lt 55 ]; do
sleep 1; i=$((i+1)); snap "on+$i"
ufsbad && { STOP="UFS"; break; }
BT=$(cat $B/temp); [ "$BT" -gt 450 ] && { STOP="BATTEMP"; break; }
CUR=$(cat $B/current_now); [ $((BASE - CUR)) -gt 300000 ] && { STOP="CURRENT"; break; }
done
fi
echo "STOPREASON=${STOP:-none-at-55s}" >> $O
echo 1 > $L/gpio_off; echo "gpio_off rc=$?" >> $O
sleep 2; snap "off+2"
if [ "$(cp2ap)" = 0 ]; then
echo 0 > $L/pda_active; echo "pda_active=0 rc=$?" >> $O
else
echo "CP2AP STILL HIGH after gpio_off: pda_active NOT lowered, do not reboot" >> $O
fi
for t in 3 8 13 18 23 28; do sleep 5; snap "post+$t"; done
echo DONE >> $O
35 changes: 35 additions & 0 deletions device/husky/bringup/s5d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes.
# S5d (TEST ONLY): battery-only current measurement around the modem power-on. Runs ON the phone; log /root/s5d.log.
# Phases: A baseline 150 s (no writes) -> B pda_active=1 + gpio_on, 60 s (median-of-5 abort) -> gpio_off, pda_active=0 if CP2AP quiet
# -> C post 120 s -> D control 120 s (no writes). 1 s samples of current_now/current_avg/voltage.
L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5d.log; B=/sys/class/power_supply/max170xx_battery
: > $O
cp2ap() { awk '/^CP2AP_/ {s+=$2} END {print s+0}' $L/lines; }
ufsbad() { [ "$(grep -vc ': 0$' $U)" != 0 ] || [ "$(dmesg | grep -c 'ufshcd_err_handler started')" != 0 ]; }
snap() { echo "$(date +%T) $1 cur=$(cat $B/current_now) avg=$(cat $B/current_avg) v=$(cat $B/voltage_now) bt=$(cat $B/temp) c2a=$(cp2ap) ufs=$(grep -vc ': 0$' $U)" >> $O; }
med5() { tail -5 $O | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | sed -n 3p; }
phase() { n=$1; tag=$2; i=0; while [ $i -lt $n ]; do snap "$tag-$i"; sleep 1; i=$((i+1)); done; }
phase 150 A
BASEMED=$(sed -n '/ A-/p' $O | tail -60 | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | awk '{a[NR]=$1} END {print a[int((NR+1)/2)]}')
echo "BASELINE_MEDIAN_cur=$BASEMED uA" >> $O
echo 1 > $L/pda_active; echo "pda_active=1 rc=$?" >> $O
echo 1 > $L/gpio_on; RC=$?; echo "gpio_on rc=$RC" >> $O
STOP=""
if [ $RC = 0 ]; then
i=0
while [ $i -lt 60 ]; do
sleep 1; i=$((i+1)); snap "B-$i"
ufsbad && { STOP="UFS"; break; }
[ "$(cat $B/temp)" -gt 450 ] && { STOP="BATTEMP"; break; }
if [ $i -ge 5 ]; then M=$(med5); [ $((BASEMED - M)) -gt 300000 ] && { STOP="CURRENT_MEDIAN"; break; }; fi
done
fi
echo "STOPREASON=${STOP:-none-at-60s}" >> $O
echo 1 > $L/gpio_off; echo "gpio_off rc=$?" >> $O
sleep 2; snap "off+2"
if [ "$(cp2ap)" = 0 ]; then echo 0 > $L/pda_active; echo "pda_active=0 rc=$?" >> $O; else echo "CP2AP STILL HIGH: pda_active NOT lowered, do not reboot" >> $O; fi
phase 120 C
phase 120 D
echo DONE >> $O
71 changes: 71 additions & 0 deletions device/husky/bringup/s5e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes.
# S5e v2 (TEST ONLY): battery-only current, isolating pda_active from gpio_on. Run as: nohup setsid sh /root/s5e.sh & Log: /root/s5e.log
# A 90 s base | E1 pda_active ALONE 30 s | B 60 s | E2 gpio_on, pda LOW 60 s | C 60 s | E3 pda=1 then gpio_on 60 s | D 60 s | E1b (replicate) 30 s | E 60 s
# Fixes after review: trap (safe_off on INT/TERM/HUP), abort ends the run, CP2AP-high stops, pda verified low before powered steps,
# UFS error count compared to the count at start, tighter E1 rule (150 mA), screen state in every sample, per-phase medians at the end.
L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5e.log; B=/sys/class/power_supply/max170xx_battery
: > $O
N0=$(dmesg | grep -c 'ufshcd_err_handler started')
ABORT=""
hw() { echo "$2" > $L/$1; }
cp2ap() { awk '/^CP2AP_/ {s+=$2} END {print s+0}' $L/lines; }
ap2cp() { awk '/^AP2CP_/ {s+=$2} END {print s+0}' $L/lines; }
pda() { awk '/^AP2CP_AP_ACTIVE/ {print $2}' $L/lines; }
ufsbad() { [ "$(grep -vc ': 0$' $U)" != 0 ] || [ "$(dmesg | grep -c 'ufshcd_err_handler started')" != "$N0" ]; }
snap() { echo "$(date +%T) $1 cur=$(cat $B/current_now) avg=$(cat $B/current_avg) v=$(cat $B/voltage_now) bt=$(cat $B/temp) c2a=$(cp2ap) a2c=$(ap2cp) pda=$(pda) ufs=$(grep -vc ': 0$' $U) bl=$(cat /sys/class/backlight/*/bl_power | head -1)" >> $O; }
med5() { tail -5 $O | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | sed -n 3p; }
phase() { n=$1; tag=$2; i=0; while [ $i -lt $n ]; do snap "$tag-$i"; sleep 1; i=$((i+1)); done; }
safe_off() {
hw gpio_off 1; echo "gpio_off rc=$?" >> $O; sleep 2; snap "off+2"
if [ "$(cp2ap)" = 0 ]; then hw pda_active 0; echo "pda_active=0 rc=$?" >> $O
else echo "CP2AP STILL HIGH: pda_active NOT lowered, do not reboot" >> $O; ABORT="CP2AP_HIGH"; fi
[ "$(pda)" = 0 ] || [ "$ABORT" = "CP2AP_HIGH" ] || ABORT="PDA_NOT_LOW"
}
trap 'echo TRAP >> $O; safe_off; echo ABORTED-BY-SIGNAL >> $O; exit 1' INT TERM HUP
# powered TAG SECONDS THRESHOLD_uA : the enabling write(s) were done by the caller
powered() { tag=$1; n=$2; th=$3; STOP=""; i=0
while [ $i -lt $n ]; do sleep 1; i=$((i+1)); snap "$tag-$i"
ufsbad && { STOP=UFS; break; }
[ "$(cat $B/temp)" -gt 450 ] && { STOP=BATTEMP; break; }
if [ $i -ge 5 ]; then M=$(med5); [ $((BASEMED - M)) -gt $th ] && { STOP=CURRENT_MEDIAN; break; }; fi
done
echo "STOPREASON($tag)=${STOP:-none-at-${n}s}" >> $O; [ -n "$STOP" ] && ABORT="$tag:$STOP"; }
finish() { phase 30 Z; echo "ABORTED=$ABORT" >> $O; summary; echo DONE >> $O; exit 1; }
summary() { echo "--- per-phase median cur (uA) and n" >> $O
for ph in A E1 B E2 C E3 D E1b E; do grep -E "^[0-9:]+ $ph-[0-9]+ " $O | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | awk -v ph=$ph '{a[NR]=$1} END { if (NR) printf "%s median=%d n=%d\n", ph, a[int((NR+1)/2)], NR }' >> $O; done; }
echo "start: bl=$(cat /sys/class/backlight/*/bl_power | head -1) N0=$N0 status=$(cat $B/status)" >> $O
[ "$(cat $B/status)" = "Discharging" ] || { echo "NOT DISCHARGING: refusing" >> $O; ABORT=START_STATUS; finish; }
[ "$(cat $B/temp)" -le 450 ] || { echo "BATTERY HOT: refusing" >> $O; ABORT=START_TEMP; finish; }
[ "$(ap2cp)$(cp2ap)" = "00" ] || { echo "LINES NOT ALL 0: refusing" >> $O; ABORT=START_LINES; finish; }
ufsbad && { echo "UFS NOT CLEAN: refusing" >> $O; ABORT=START_UFS; finish; }
phase 90 A
BASEMED=$(sed -n '/ A-/p' $O | tail -60 | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | awk '{a[NR]=$1} END {print a[int((NR+1)/2)]}')
echo "BASELINE_MEDIAN_cur=$BASEMED uA" >> $O
[ "$(pda)" = 0 ] || { echo "pda not low at start" >> $O; ABORT=START; finish; }
# E1: pda_active alone (tight rule 150 mA)
hw pda_active 1; echo "E1 pda_active=1 rc=$?" >> $O
if [ "$(pda)" = 1 ] && [ "$(ap2cp)" = 1 ]; then powered E1 30 150000; else echo "E1 READBACK MISMATCH" >> $O; ABORT="E1:READBACK"; fi
hw pda_active 0; echo "E1 pda_active=0 rc=$?" >> $O; [ -z "$ABORT" ] || finish
[ "$(pda)" = 0 ] || { ABORT="PDA_NOT_LOW_AFTER_E1"; finish; }
phase 60 B
# E2: gpio_on with pda low
[ "$(pda)" = 0 ] || { ABORT="PDA_NOT_LOW_BEFORE_E2"; finish; }
hw gpio_on 1; RC=$?; echo "E2 gpio_on(pda low) rc=$RC" >> $O
if [ "$(ap2cp)" = 4 ] && [ "$(pda)" = 0 ]; then powered E2 60 400000; else echo "E2 READBACK MISMATCH (ap2cp=$(ap2cp) pda=$(pda))" >> $O; ABORT="E2:READBACK"; fi
safe_off; [ -z "$ABORT" ] || finish
phase 60 C
# E3: pda_active then gpio_on (the S5d order)
hw pda_active 1; echo "E3 pda_active=1 rc=$?" >> $O
hw gpio_on 1; RC=$?; echo "E3 gpio_on rc=$RC" >> $O
if [ "$(ap2cp)" = 5 ] && [ "$(pda)" = 1 ]; then powered E3 60 400000; else echo "E3 READBACK MISMATCH (ap2cp=$(ap2cp) pda=$(pda))" >> $O; ABORT="E3:READBACK"; fi
safe_off; [ -z "$ABORT" ] || finish
phase 60 D
# E1b: replicate of E1
hw pda_active 1; echo "E1b pda_active=1 rc=$?" >> $O
if [ "$(pda)" = 1 ] && [ "$(ap2cp)" = 1 ]; then powered E1b 30 150000; else echo "E1b READBACK MISMATCH" >> $O; ABORT="E1b:READBACK"; fi
hw pda_active 0; echo "E1b pda_active=0 rc=$?" >> $O; [ -z "$ABORT" ] || finish
phase 60 E
summary
echo DONE >> $O
21 changes: 21 additions & 0 deletions device/husky/overlays/modem-s1-link.dtso
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Modem link bring-up, stage S1, never default (device/husky/
* MODEM-PLAN.md): turns on the modem PCIe controller node
* (pcie_0, ch0) and its PHY (pcie_0_phy) and nothing else. The `modem`
* child stays disabled, so the controller driver takes no modem line, and
* the pins are not touched (pcie_0 has only an "active" pinctrl state, which
* only link_up selects). Both drivers only map their registers at probe.
* The controller module is blacklisted and loaded by hand after the boot.
* The modem power lines are not described as enabled anywhere in this file.
*/
/dts-v1/;
/plugin/;

&pcie_0_phy {
status = "okay";
};

&pcie_0 {
status = "okay";
};
24 changes: 24 additions & 0 deletions device/husky/overlays/modem-s2-lines.dtso
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Modem link bring-up, stage S2, never default (device/husky/
* MODEM-PLAN.md): S1 (pcie_0 and pcie_0_phy) plus the `modem`
* child of pcie_0, so the controller driver requests the eleven modem lines
* as the bootloader left them (GPIOD_ASIS: no direction or level change at
* probe). Only the debugfs `status` file reads them. There is no cpif node
* (samsung,exynos-cp) in the tree, so cpif and shm_ipc cannot bind and must
* not be loaded. No pin state is selected and no line is driven by hand.
*/
/dts-v1/;
/plugin/;

&pcie_0_phy {
status = "okay";
};

&pcie_0 {
status = "okay";

modem {
status = "okay";
};
};
31 changes: 31 additions & 0 deletions device/husky/overlays/modem-s4-cpif.dtso
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Modem link test, stage S4, never default (device/husky/
* MODEM-PLAN.md): the controller (pcie_0_phy, pcie_0)
* is on, but its `modem` child is OFF so the lines are free for CPIF, and
* /cp-shmem and /cpif (disabled in the base dtb, kernel branch
* husky-e1-modem-cpif) are switched on. cpif probe forces the seven AP2CP
* outputs low; nothing powers the modem or starts PCIe.
*/
/dts-v1/;
/plugin/;

&pcie_0_phy {
status = "okay";
};

&pcie_0 {
status = "okay";

modem {
status = "disabled";
};
};

&{/cp-shmem} {
status = "okay";
};

&{/cpif} {
status = "okay";
};