#!/system/bin/sh
# Key/PON diagnostics for the Poco F1 mainline recovery. Run: sh diag-keys.sh
mount -t debugfs none /sys/kernel/debug 2>/dev/null
echo "=== kernel (build time tells you which image you booted)"
uname -a
echo "=== platform drivers (pon / pwrkey / resin / gpio-keys)"
ls /sys/bus/platform/drivers 2>/dev/null | grep -i -E "pon|pwrkey|resin|gpio-keys|pm8941"
echo "=== devices that exist for them"
find /sys/devices -maxdepth 7 \( -name '*pon*' -o -name '*pwrkey*' -o -name '*resin*' -o -name 'gpio-keys*' \) 2>/dev/null | head -20
echo "=== input devices (look for pm8941_pwrkey and pm8941_resin)"
grep -E "^N: Name|^H: Handlers" /proc/bus/input/devices
echo "=== /dev/input"
ls -l /dev/input 2>&1 | head -12
echo "=== log"
dmesg | grep -i -E "pwrkey|resin|qcom.pon|qcom_pon|pm8941|reboot.mode|input: " | head -30
echo "=== deferred devices"
cat /sys/kernel/debug/devices_deferred
echo "=== done"
