[Desire Android Development] iscaela:
This kernel module allows you to run any official Froyo kernel image from HTC with reduced CPU voltages at each frequency. Reducing voltage decreases the power consumed by the CPU (dissipated as heat).

INSTALL:

You need root or an unrestricted recovery image (e.g ClockworkMod) to install this. The default settings decrease voltage by 75-100 mV which seems stable on my device. Just download the attached file and select it from recovery or ROM Manager.

I've built "update.zip" files for the Desire with Linux kernel versions 2.6.32.15-gf9c0527, 2.6.32.15-gd96f2c0, and 2.6.32.15-g6a358a9. You can check your kernel version in Settings->About phone->Software information.

Other HTC devices running Froyo are supported. If you have a different device, please give me the full version number and I can add an update.zip for it.

Undervolt driver for the EVO 4G

Added undervolt-2.6.32.15-gd96f2c0-20100907.zip.

Added undervolt-2.6.32.15-g6a358a9-20100907.zip.

Added undervolt-2.6.32.15-gf5a401c-20100907.zip.

USAGE:

Read the instructions above first. If you are happy with the default settings, you don't need to read this unless you're curious

To load the driver, use an init script like this one (included):

#!/system/bin/sh
#
# Load undervolt for htc-kernel
addr=`awk '$3 == "acpuclk_set_rate" { print "0x"$1; }' /proc/kallsyms`
if [ -n "$addr" ]; then
insmod /system/lib/modules/undervolt.ko "acpuclk_set_rate_addr=$addr"
if [ $? -eq 0 ]; then
echo '-75' > /proc/undervolt
echo '1225 1125' > /proc/undervolt
echo '1250 1150' > /proc/undervolt
echo '1275 1175' > /proc/undervolt
echo '1300 1200' > /proc/undervolt
echo '1' > /proc/undervolt
echo "+++ undervolt enabled"
exit 0
fi
fi
echo "+++ undervolt could not be enabled

The driver adds a "/proc/undervolt" knob to make voltage changes, reading from it prints the current default and adjusted voltages in mV for every CPU frequency, e.g.:

cat /proc/undervolt
1050 975 19200
1050 975 128000
...
1300 1200 960000
1300 1200 998400

Write a space-separated pair of default and adjusted voltages in mV to change the values in the table, e.g. to undervolt stock freqs using 1500 mV to 1000mV):

echo '1050 1000' > /proc/undervolt

.

Write '+' or '-' followed by a single number to adjust *all* voltages by that amount in mV:

echo '-25' > /proc/undervolt

The changes are NOT applied until you write the number 1:

echo '1' > /proc/undervolt

Writing the number 0 reverts all voltages to the default. This also happens when you unload the module with rmmod.

BACKGROUND:

I figured it would be possible to locate and modify acpu_freq_tbl on the stock HTC kernel with a LKM (since /dev/kmem isn't available), and I was right, although it involved peeking at the ARM opcodes. The method should also work for other HTC kernel images on recent devices (anything with a "Scorpion" CPU): Nexus One, Droid Incredible, EVO 4G. Overclocking will be possible with a bit more work.

This also disables the voltage constraints set by the board-specific configuration (e.g. in board-bravo.c or board-incrediblec.c). This was done by y patching the regulator_set_voltage function to simply ignore the constraints. The remaining limits are imposed by the driver for the regulator IC. The TPS65023 driver defines these for VDCDC1: min_uV = 800000, max_uV = 1600000.

KNOWN BUGS:

There is a vdd_undervolt parameter to set the default undervolt, but it is ignored (by insmod?), use +/- instead.