I share my codes on Gist:
This is a simple script and service setup that allows your Debian OS can monitor the temperature of the SoC regularly and then control it to be high or low speed automatically through the GPIO.
I have not encountered any problems so far
https://gist.github.com/FrankWu100/9b7dee45ce40729221cb277bce1102d9