start_cpu_freq 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. #BK got this from http://murga-linux.com/puppy/viewtopic.php?t=55417&start=15
  3. # but added test for /proc/acpi, bios-date, processor-manufacturer.
  4. # added extra code provided by pakt.
  5. #100603 gamble, any CPU >=2007 can handle acpi-cpufreq, or it will fail to load.
  6. #101014 improve test for older computers, and fix menu --well no probably not the latter.
  7. #101114 rerwin: refine usage of dmidecode.
  8. #disable freq scaling for older computers...
  9. #[ ! -d /proc/acpi ] && FLAGEXIT='yes'
  10. if [ ! -d /proc/acpi ];then #101114
  11. FLAGEXIT='yes'
  12. else
  13. [ `dmidecode -s "bios-release-date" | cut -f 3 -d '/' | rev | cut -c 1,2 | rev` -lt 7 ] && FLAGEXIT='yes' #<2006 100603: <2007 101014
  14. fi
  15. if [ "$FLAGEXIT" = "yes" ];then #101014
  16. # if [ -f /usr/share/applications/cpu_freq.desktop ];then
  17. # rm -f /usr/share/applications/cpu_freq.desktop
  18. # fixmenus
  19. # #[ "`pidof jwm`" != "" ] && jwm -restart #ideally should do this, but with any luck user will look at this item after next boot.
  20. # fi
  21. exit
  22. fi
  23. #INTEL='p4-clockmod speedstep-centrino speedstep-ich'
  24. #VIA='longhaul e_powersaver'
  25. #CYRIX='gx-suspmod'
  26. FREQMODS="acpi-cpufreq"
  27. case "$1" in
  28. start)
  29. #CPUMAN="`dmidecode -s 'processor-manufacturer' | tr '[A-Z]' '[a-z]' | cut -f 1 -d ' '`"
  30. #case $CPUMAN in
  31. # intel) FREQMODS="${INTEL} acpi-cpufreq" ;;
  32. # via) FREQMODS="${VIA} acpi-cpufreq" ;;
  33. # cyrix) FREQMODS="${CYRIX} acpi-cpufreq" ;;
  34. #esac
  35. for ONEMOD in $FREQMODS
  36. do
  37. modprobe $ONEMOD
  38. if [ $? -eq 0 ];then
  39. modprobe cpufreq_ondemand
  40. if [ $? -eq 0 ];then
  41. for CPUNUM in `ls -1 /sys/devices/system/cpu/ | grep 'cpu[0-9]' | tr '\n' ' '`
  42. do
  43. echo ondemand >/sys/devices/system/cpu/$CPUNUM/cpufreq/scaling_governor
  44. done
  45. #echo > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
  46. #echo > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  47. #echo > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
  48. #echo > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
  49. break
  50. else
  51. rmmod $ONEMOD
  52. fi
  53. fi
  54. done
  55. ;;
  56. esac