Power Management

One important part of a laptop is the ability to use it ``on the road''. In Linux 2.4, you have the choice between using APM or ACPI. Using APM should mean you'll be able to suspend the thing, but then you'll be running without SpeedStep, so for continued work, your battery will be empty fairly fast. Using ACPI means you won't be able to suspend the machine (at least not in 2.4; 2.6 has support for that), but if you apply the patches from the ACPI4Linux Project at http://acpi.sourceforge.net/, you'll be able to switch between P (SpeedStep) and T (throttling) modes; that means you'll be able to run a lot longer on a single battery for continued work.

Of course, if you're running 2.6, you won't have to worry about this as much, since ACPI support in 2.6 is a lot better; plus, in 2.6, you don't even need ACPI support for SpeedStep.

In any case, switching to a slower mode using ACPI is done by echoing two numbers to /proc/acpi/processor/CPU0/limit. I'm doing this for battery mode:

echo '1:5' > /proc/acpi/processor/CPU0/limit

and this for AC adapter mode:

echo '0:0' > /proc/acpi/processor/CPU0/limit

which means 'run at full processor power when the AC adapter is connected, and at reduced SpeedStep mode, with 31% throttling when it is not'.

You'll want to install acpid for complete ACPI support; however, it seems that the battery does not issue an event. I've fixed this by checking whether we're on AC power at boot time, and switching the system accordingly. That Works For Me, but YMMV.

OTOH, if you're running 2.6, there's a neat new feature in the kernel, called the ``CPU Frequency Scaling'', which will do the switching of processor speed fully automatic, in kernel space, with no need to configure anything. You want CONFIG_CPU_FREQ, CONFIG_CPU_FREQ_GOV_PERFORMANCE, CONFIG_CPU_FREQ_GOV_POWERSAVE, and CONFIG_X86_P4_CLOCKMOD. Additionally, you may be interested in setting frequencies manually, for which you need the userspace governor.

Now, if you run on battery power, the kernel will automatically select the ``powersave'' governor, and when you connect the system to a power source of some kind, the ``performance'' governor will be selected. If you compile governors as modules (I don't recommend that), make sure to load the additional module before you (dis)connect your system to/from a power outlet.

You can view the current processor speed in /proc/cpuinfo, and configure the driver through files in /sys/devices/system/cpu/cpu0/cpufreq

The buttons (lid and power) do work, OTOH. Create a file in /etc/acpi/events with a contents such as

event=button[ /]lid
action=/etc/acpi/powerbtn.sh
and a file called /etc/acpi/powerbtn.sh with a contents like
echo '1' > /proc/acpi/sleep
to make your system suspend to RAM when you close the lid. Or, if you're using 2.6, make the contents of the latter file look like this:
echo '4' > /proc/acpi/sleep
to have it hibernate. Which, by the way, is pretty cool :-)
Wouter Verhelst 2004-01-09