This is very much a draft still as I go along. Everything in here is subhect to change heavily, could be wrong and your mileage may vary greatly.
Everything here assumes native build on Arch POWER riscv64.
This is probably broken in some way but works for me.
#!/bin/bash
MAXTEMP=70000 # 70C
MEDTEMP=65000 # 65C
while [ true ]; do
TEMP1=$(cat /sys/class/hwmon/hwmon0/temp1_input)
TEMP2=$(cat /sys/class/hwmon/hwmon0/temp2_input)
echo "${TEMP1} ${TEMP2}"
if [ ${TEMP1} -lt ${MAXTEMP} -o ${TEMP2} -lt ${MAXTEMP} ]; then
if [ ${TEMP1} -lt ${MEDTEMP} -o ${TEMP2} -lt ${MEDTEMP} ]; then
echo ":: limit to 20%"
echo 180 > /sys/class/hwmon/hwmon2/pwm1
else
echo ":: limit to 40%"
echo 120 > /sys/class/hwmon/hwmon2/pwm1
fi
fi
sleep 1
done
This was mostly correct for mine; the two references to hwmon2 were incorrect, but easily modified to hwmon1 and then it worked as expected