#!/bin/sh
#BK got this from http://murga-linux.com/puppy/viewtopic.php?t=55417&start=15
# but added test for /proc/acpi, bios-date, processor-manufacturer.
# added extra code provided by pakt.
#100603 gamble, any CPU >=2007 can handle acpi-cpufreq, or it will fail to load.
#101014 improve test for older computers, and fix menu --well no probably not the latter.
#101114 rerwin: refine usage of dmidecode.

#disable freq scaling for older computers...
#[ ! -d /proc/acpi ] && FLAGEXIT='yes'
if [ ! -d /proc/acpi ];then #101114
 FLAGEXIT='yes'
else
 [ `dmidecode -s "bios-release-date" | cut -f 3 -d '/' | rev | cut -c 1,2 | rev` -lt 7 ] && FLAGEXIT='yes' #<2006 100603: <2007 101014
fi
if [ "$FLAGEXIT" = "yes" ];then #101014
 exit
fi

FREQMODS="acpi-cpufreq"

case "$1" in
 start)
  for ONEMOD in $FREQMODS
  do
   modprobe $ONEMOD
   if [ $? -eq 0 ];then
    modprobe cpufreq_ondemand
    if [ $? -eq 0 ];then
     for CPUNUM in `ls -1 /sys/devices/system/cpu/ | grep 'cpu[0-9]' | tr '\n' ' '`
     do
      echo ondemand >/sys/devices/system/cpu/$CPUNUM/cpufreq/scaling_governor
     done
     break
    else
     rmmod $ONEMOD
    fi
   fi
  done
 ;;
esac

