# Manipulating cpu voltage [SOLVED]

## khendon

I would like the ability to manipulate the CPU voltage of my AMD Turion64 laptop. There is software available in Windows (Rightmark CPU Clock) that allows me to easily do that, but I have yet to find a way to do it in Linux. I've searched various forums, and google. Let me stress that I have no desire at all to change the CPU frequency. The default frequency of 1.6GHz is fine, the default voltage of 1450mV is not. In Windows I've changed that to 1250mV, lowering my CPU temperature by over 10 degrees celcius on load, which leads to a much cooler system and thus less need for the noisy fan to work. In the thread https://forums.gentoo.org/viewtopic-t-341298-highlight-voltage.html a way to do this on a Pentium-M is described. Now I would like to find some way (any way) to do the same on my AMD cpu.

Most (maybe all) Linux methods of altering CPU voltage (cpufreq for example) only do so automatically when adjusting frequency. They have nice lil daemons running that measure load and adjust frequency and voltage based on need. This does not help me. What I need is a way to alter the values these applications use. I'm not quite sure where these values are stored.

Any help would be greatly appreciated.Last edited by khendon on Thu Nov 24, 2005 1:20 pm; edited 1 time in total

----------

## Fran

I opened a thread about this some time ago:

https://forums.gentoo.org/viewtopic-t-245197-highlight-undervolting.html

You only have to add 2 or 3 lines to powernow-k8.c. But you must know which values in the voltage table you want to change. In that thread, I only changed data->powernow_table[0].index because I only wanted to lower the voltage for 2.2Ghz (with my bios this is the first position in the table, with other bioses this can be different).

----------

## khendon

 *Fran wrote:*   

> I opened a thread about this some time ago:
> 
> https://forums.gentoo.org/viewtopic-t-245197-highlight-undervolting.html
> 
> You only have to add 2 or 3 lines to powernow-k8.c. But you must know which values in the voltage table you want to change. In that thread, I only changed data->powernow_table[0].index because I only wanted to lower the voltage for 2.2Ghz (with my bios this is the first position in the table, with other bioses this can be different).

 

Hi

That sounds like exactly like what I need. I'm not sure I understand your post in that thread however. I would like a voltage at default speed, 1.6GHz, of 1250mV. I'm hoping I have it right here:

Default value read from bios in your example is 2 << 8 = 512. Now, I'm assuming that the default value in my case would be the value that translates into the default voltage of 1450mV, which would be 4 << 8 = 1024, giving me a voltage of 1550-(1024 >> 8)*25=1450mV. To get my desired voltage of 1250mV, I would then need to add 8 << 8. 4 << 8 + 8 << 8 = 3072. 1550(3072 >> 8)*25=1250mV. Am I doing this right?

You mentioned that you're altering the first position in the table because that's where the voltage for maximum speed is located in your bios. How did you find this information? I would guess that mine's the same, but it would be nice to be able to verify this somehow.

----------

## Fran

 *khendon wrote:*   

> Default value read from bios in your example is 2 << 8 = 512. Now, I'm assuming that the default value in my case would be the value that translates into the default voltage of 1450mV, which would be 4 << 8 = 1024, giving me a voltage of 1550-(1024 >> 8)*25=1450mV. To get my desired voltage of 1250mV, I would then need to add 8 << 8. 4 << 8 + 8 << 8 = 3072. 1550(3072 >> 8)*25=1250mV. Am I doing this right?

 

Yep, that's right. For a processor using powernow-k8, adding (8 << 8) to a voltage in that table is equivalent to reducing 0.2V. If your cpu is at 1.45V at default speed, the default value in that table will probably be (4 << 8).

 *khendon wrote:*   

> You mentioned that you're altering the first position in the table because that's where the voltage for maximum speed is located in your bios. How did you find this information? I would guess that mine's the same, but it would be nice to be able to verify this somehow.

 

Don't be so sure ;). In fact, it was in the first position in a previous version of my M/B bios. In my current bios, it is in the last position of the table.

To be sure, just look at dmesg:

```
$ dmesg | grep powernow

powernow-k8: Found 1 AMD Athlon 64 / Opteron processors (version 1.50.4)

powernow-k8:    0 : fid 0x2 (1000 MHz), vid 0x12 (1100 mV)

powernow-k8:    1 : fid 0xa (1800 MHz), vid 0xa (1300 mV)

powernow-k8:    2 : fid 0xc (2000 MHz), vid 0x6 (1400 mV)

powernow-k8:    3 : fid 0xe (2200 MHz), vid 0x6 (1400 mV)
```

That shows that the max speed is in the 4th position of the table (position [3] in the array). It also shows the vid in hex. The default voltage would be 1500mV (0x2), but by adding (4 << 8) to that position (0x2+0x4==(2<<8)+(4<<8)=0x6) I lowered 100mV. Only to that frequency; I don't care about lower frequencies and left them as they are read from the bios.

For my current kernel (2.6.14.2) these are the lines that I added (I put it at the beginning of the function print_basics, that shows the info in dmesg)

```
if (data->numps >= 3)

                data->powernow_table[3].index += (4 << 8); 
```

The "if" is there to be sure that I don't cause a segfault in the kernel (maybe in future bioses the table will only have 3 freqs).

HTH :).

----------

## khendon

It works like a charm!  :Very Happy: 

And, indeed, I needed to change the first position in the array, not the third, to modify the voltage. Dmesg now reports 1.250V at 1.6GHz  :Smile:  Thank you very much!

----------

## nlindblad

Add [SOLVED] to topic please...

----------

## morfic

please try the following patch if you would like the ability to change the voltage at boot time or whenever inserting powernow-k8 module

patch kernel 2.6.16-rc2 (only tested on vanilla) with this patch: http://dev.gentoo.org/~morfic/powernow-k8-vcore_list-2.6.16-rc2.diff

add powernow-k8.vcore_list=value1,value2,value3 to the kernel command line in grub or lilo

or build powernow-k8 as module and do 'modprobe powernow-k8 vcore_list=value1,value2,value3

please only specify any new voltages for each powernow-k8 step you have

dmesg | grep powernow   will show current values/number of states you have

value is in millivolt, so to change from 1.3 to 1.1 you would specify 1100

i will now paste my dmesg to illustrate how this works on a turion64 with 2 states

morfic@localhost64 ~ $ dmesg | grep powernow

Bootdata ok (command line is root=/dev/hda7 vga=792 powernow-k8.vcore_list=1100,900)

Kernel command line: root=/dev/hda7 vga=792 powernow-k8.vcore_list=1100,900

powernow-k8: Found 1 AMD Athlon 64 / Opteron processors (version 1.60.0)

powernow-k8: Request Voltage for id0 is 1100 mV default voltage is 1450

powernow-k8: Performing required adjustment of 350 mV  or 14 25mV steps

powernow-k8: Request Voltage for id1 is 900 mV default voltage is 1000

powernow-k8: Performing required adjustment of 100 mV  or 4 25mV steps

powernow-k8:    0 : fid 0x8 (1600 MHz), vid 0x12 (1100 mV)

powernow-k8:    1 : fid 0x0 (800 MHz), vid 0x1a (900 mV)

powernow-k8: ph2 null fid transition 0x8

morfic@localhost64 ~ $ 

the ph2 line means we trigger a transition where the frequency has not changed

i have made the patch because calculating it was too cumbersome fr me and friends, aside my default voltage is 1.45V in linux while i used the spec of 1.5V so i was always off by .05V, the patch will adjust the voltage by the difference of currently read from bios from requested voltage, much more failsafe i think

as usual, neither i nor gentoo grant no guarantees and warrantees, use fhis patch is entirely at your own risk, improper use of this patch can lead to system instabilities and damage your hardware, by downloading the and applying the patch you acknowledge this.

i would appreciate user feedback, especially from people with 3 or more power states

note: the power usage in /proc/acpi/processor/cpu*/power is hardcoded and will not change when you lower your vcore

note: if you build powernow-k8 as module you will not automatically use your usual scaling governor, modprobe powernow-k8 and set your usual scaling governor

----------

## morfic

forgot to add, 1.45V@1600Mhz means 90C compiles

while 1.1V@1600MHz mean 60C compiles

hot little turion, i know

----------

