Files
NANOKVM-LicheeRV-Nano-Build…/buildroot/board/cvitek/SG200X/overlay/etc/init.d/S00pmu
2025-07-28 18:55:41 +08:00

49 lines
997 B
Bash
Executable File

#!/bin/sh
start() {
if ! command -v i2cget &> /dev/null
then
echo "i2cdetect not find, please install i2c-tools"
exit 1
fi
pmu_version=$(i2cget -y 4 0x34 0x03)
pmu_version=$((pmu_version & 0xCF))
chip_id_1=$(printf "%d" 0x47)
chip_id_2=$(printf "%d" 0x4a)
if [ "$pmu_version" -eq "$chip_id_1" ] || [ "$pmu_version" -eq "$chip_id_2" ]; then
exec /usr/bin/axp2101
echo "Starting PMU: OK\n"
fi
}
stop() {
runlevel=$(cat /run/runlevel | awk '{ print $1 }')
if [ "$runlevel" = "0" ]; then
printf "Stopping PMU\n"
value=$(i2cget -y 4 0x34 0x10)
value=$((value | 0x01))
i2cset -y 4 0x34 0x10 $value
fi
}
case "$1" in
start)
if grep -q "pmu=axp2101" /boot/board 2>/dev/null; then
start
fi
;;
stop)
if grep -q "pmu=axp2101" /boot/board 2>/dev/null; then
stop
fi
;;
*)
echo "Usage: /etc/init.d/S00pmu {start}"
exit 1
;;
esac