[Galaxy S II Android Development] fenomeno83:
I will explain you how undervolt speedmod kernel (but you can use to undervolt others kernels)

Note that it is at your risk!!

You must have a linux OS (like Ubuntu; you can install it also using a virtual machine)

First download:

samsung update 3 i9100 kernel source from https://opensource.samsung.com (search "i9100")

speedmod kernel source from http://xdaforums.com/showpost.php?p=15923387&postcount=2

build package from http://www.mediafire.com/?s9vaekv96d6qdfc (thanks to gokhanmoral)

Uncompress samsung update 3 (and uncompress also kernel; you can delete platform package)

Uncompress speedmod source and uncompress also initrafms

Uncompress build package

Move all necessary files on the build package:

copy samsung kernel in "MyKernel" folder (when you enter in "MyKernel" folder must have arch, block, crypto...... subfolders..check this!)

copy speedmod initramfs files in "initramfs-modified" folder (when you enter in "initramfs-modified" must have data, dev, lib.... subfolders...check this!!)

copy speedmod patch in "MyKernel" folder

check my source code to see FOLDERS structure

http://www.zshare.net/download/9625790645c1ef85

Now, undervolt samsung kernel:

to do this we must edit 3 files:

MyKernel\arch\arm\march-s5pv310\cpufreq.c

MyKernel\drivers\media\video\samsung\mali\platform\orion-m400\mali_platform.c (maybe it is not necessary edit this file)

MyKernel\drivers\media\video\samsung\mali\platform\orion-m400\mali_platform_dvfs.c

In cpufreq.c you can undervolt: cpu, internal, bus

Open cpufreq.c and search this:

static struct busfreq_table s5pv310_busfreq_table[] = {

{LV_0, 400000, 1100000},

{LV_1, 267000, 1000000},

#if !defined(CONFIG_MACH_Q1_REV00) && !defined(CONFIG_MACH_Q1_REV02)

{LV_2, 133000, 1000000},

#endif

{0, 0, 0},

};

#endif

That is to manage bus voltages..if you see LV_0; LV_1 and LV_2 in you have frequency and voltage..for example {LV_0, 400000, 1100000} means that for 400mhz in the bus you use 1100mv; in my kernel I reduce all bus voltage -50mv (for example {LV_0, 400000, 1050000})

You can find the same method in busfreq.c file, but i think that it is not used (but if you want, you can edit in the same manner)

After search this:

{

.index	= L0,

.arm_volt	= 1300000,

.int_volt	= 1100000,

}, {

.index	= L1,

.arm_volt	= 1200000,

.int_volt	= 1100000,

}, {

.index	= L2,

.arm_volt	= 1100000,

.int_volt	= 1100000,

}, {

.index	= L3,

.arm_volt	= 1000000,

.int_volt	= 1000000,

}, {

.index	= L4,

.arm_volt	= 975000,

.int_volt	= 1000000,

},

};

This is to manage cpu and internal voltages..you can find several similar methods: EDIT ALL THAT HAVE INDEX FROM L0(1200MHZ) TO L4(200MHZ)!!!

arm_volt are voltages that we know (voltages that in many kernels you can set by setcpu)..

for L4 voltage (refer to 200mhz) chooose your favourite value (for example, in my kernel I use 875mv)... for L0 to L3 remember that after code will be reduce them by 50mv; this means that if armvolt for L0(1200mhz) is set to 1300000, it will be 1250mv...in my kernel I

reduced voltages from L0 to L3 -50mv (this means for example that for L0 i wrote 1250000, that means 1250 - 50 = 1200mv)

For internal voltages, edit from L0 to L4 int_volt (I reduced them -50mv)

In code search this:

/* Minimum Voltage */

if (s5pv310_volt_table.arm_volt < 925000)

s5pv310_volt_table.arm_volt = 925000;

and edit with

/* Minimum Voltage */

if (s5pv310_volt_table.arm_volt < 800000)

s5pv310_volt_table.arm_volt = 800000;

SAVE!

open mali_platform.c (this is to manage gpu voltages; but maybe you don't need to edit this file; there is also mali_platform_dvfs.c to manage gpu voltages)

Search this:

#ifdef CONFIG_S5PV310_ASV

int mali_gpu_vol = 1000000; /* 1.00V for ASV */

#else

int mali_gpu_vol = 950000; /* 0.95V */

#endif

#else

int mali_gpu_vol = 1050000; /* 1.05V */

#endif

and edit your voltages (I reduced them -50 mv)...but repeat, maybe this is not necessary to undervolt gpu

SAVE!

Open mali_platform_dvfs.c

Search this:

mali_dvfs_table mali_dvfs[MALI_DVFS_STEPS]={

#ifdef CONFIG_CPU_S5PV310_EVT1

#ifdef CONFIG_S5PV310_ASV

/*step 0*/{160 ,1000000 ,1000000},

/*step 1*/{267 ,1000000 ,1100000} };

#else

/*step 0*/{160 ,1000000 , 950000},

/*step 1*/{267 ,1000000 ,1050000} };

#endif

#else

/*step 0*/{134 ,1000000 ,1050000},

/*step 1*/{267 ,1000000 ,1150000} };

#endif

for example, {267 ,1000000 ,1050000} }; means that for 267mhz are associated 1000mv and 1050mv voltages (i don't know if are minumum and maximum voltages and I don't know if are used)

After search this:

#ifdef CONFIG_S5PV310_HI_ARMCLK_THAN_1_2GHZ

MALI_DEBUG_PRINT(3, ("> max arm clock is higher than 1.2GHz.\n"));

switch(asv_info.asv_num) {

/* ASB table for 1.4GHz */

case 0:

case 1:

/* SS & A group */

mali_dvfs[MALI_DVFS_L2].vol = 1100000; // 266Mhz

mali_dvfs[MALI_DVFS_L3].vol = 1000000; // 160Mhz

break;

case 2:

case 3:

/* B & C group */

mali_dvfs[MALI_DVFS_L2].vol = 1000000; // 266Mhz

mali_dvfs[MALI_DVFS_L3].vol = 950000; // 160Mhz

break;

case 4:

/* D group */

mali_dvfs[MALI_DVFS_L2].vol = 950000; // 266Mhz

mali_dvfs[MALI_DVFS_L3].vol = 950000; // 160Mhz

break;

default :

MALI_PRINT(("mali asv level is invalid %d", asv_info.asv_num));

return MALI_FALSE;

}

#else

switch(asv_info.asv_num) {

case 0:

case 1:

case 2:

mali_dvfs[MALI_DVFS_L3].vol = 1000000; // 160Mhz

mali_dvfs[MALI_DVFS_L2].vol = 1100000; // 266Mhz

break;

case 3:

case 4:

mali_dvfs[MALI_DVFS_L3].vol = 950000; // 160Mhz

mali_dvfs[MALI_DVFS_L2].vol = 1000000; // 266Mhz

break;

case 5:

case 6:

mali_dvfs[MALI_DVFS_L3].vol = 950000; // 160Mhz

mali_dvfs[MALI_DVFS_L2].vol = 1000000; // 266Mhz

break;

case 7:

case 8:

mali_dvfs[MALI_DVFS_L3].vol = 950000; // 160Mhz

mali_dvfs[MALI_DVFS_L2].vol = 950000; // 266Mhz

break;

default :

MALI_PRINT(("mali asv level is invalid %d", asv_info.asv_num));

return MALI_FALSE;

}

#endif

return MALI_TRUE;

}

and edit values (edit all; samsung stock valued for gs2 are 950-1000mv, but better that edit all because I don't know what is correct "case"; I reduced them -50mv)

SAVE!

So, check my source code to see what values I used

http://www.zshare.net/download/9625790645c1ef85

Now, we have original samsung kernel undervolted.

How to apply speedmod changes?

First all, apply patch.

With terminal, go in Mykernel folder (with command cd "foldername") and write: patch -p1 < PatchFileName.patch (use correct patchFileName)

If kernel is patched, you can delete patchFile and go to MyKernel arch arm configs and edit c1_rev02_speedmod_deconfing

Search

CONFIG_CROSS_COMPILE=""

CONFIG_LOCALVERSION=""

CONFIG_LOCALVERSION AUTO=y

and modify in this manner:

CONFIG_CROSS_COMPILE='*'

CONFIG_LOCALVERSION="-yourKernelName"

#CONFIG_LOCALVERSION AUTO is not set

in local version you can set name that will appear in device info (put "-" before name)

After search:

CONFIG_INITRAMFS_SOURCE="/home/kernel/initramfs/out"

and edit with:

CONFIG_INITRAMFS_SOURCE='*'

SAVE!

In my source, you can see phenomenal_deconfing file to verify what I changed

Now edit build.sh file

Where you see /home/fenomeno83/Desktop, edit with your path where you want save after building cwm zip version and odin tar version

SAVE!

Al last, with cd command go to folder where is build.sh and digit: sh build.sh

Wait that tar and zip files will be generated!!