39deab23c78b885d8c8cced0df293d20611f1d6f
[kernel-bfs] / kernel-power-2.6.28 / debian / patches / overclock.diff
1 --- kernel-maemo-2.6.28.orig/arch/arm/mach-omap2/omap3-opp.h
2 +++ kernel-maemo-2.6.28/arch/arm/mach-omap2/omap3-opp.h
3 @@ -4,13 +4,23 @@
4  #include <mach/omap-pm.h>
5  
6  /* MPU speeds */
7 +#define S1150M  1150000000
8 +#define S1100M  1100000000
9 +#define S1000M  1000000000
10 +#define S950M   950000000
11 +#define S900M   900000000
12 +#define S850M   850000000
13 +#define S805M   805000000
14 +#define S750M   750000000
15 +#define S700M   700000000
16  #define S600M   600000000
17  #define S550M   550000000
18  #define S500M   500000000
19  #define S250M   250000000
20 -#define S125M   125000000
21 +#define S125M   124999000
22  
23  /* DSP speeds */
24 +#define S520M   520000000
25  #define S430M   430000000
26  #define S400M   400000000
27  #define S360M   360000000
28 @@ -21,42 +31,8 @@
29  #define S83M    83000000
30  #define S166M   166000000
31  
32 -static struct omap_opp omap3_mpu_rate_table[] = {
33 -       {0, 0, 0},
34 -       /*OPP1*/
35 -       {0, VDD1_OPP1, 0x1E},
36 -       /*OPP2*/
37 -       {S250M, VDD1_OPP2, 0x26},
38 -       /*OPP3*/
39 -       {S500M, VDD1_OPP3, 0x30},
40 -       /*OPP4*/
41 -       {S550M, VDD1_OPP4, 0x36},
42 -       /*OPP5*/
43 -       {S600M, VDD1_OPP5, 0x3C},
44 -};
45 -
46 -static struct omap_opp omap3_l3_rate_table[] = {
47 -       {0, 0, 0},
48 -       /*OPP1*/
49 -       {0, VDD2_OPP1, 0x1E},
50 -       /*OPP2*/
51 -       {S83M, VDD2_OPP2, 0x24},
52 -       /*OPP3*/
53 -       {S166M, VDD2_OPP3, 0x2C},
54 -};
55 -
56 -static struct omap_opp omap3_dsp_rate_table[] = {
57 -       {0, 0, 0},
58 -       /*OPP1*/
59 -       {S90M, VDD1_OPP1, 0x1E},
60 -       /*OPP2*/
61 -       {S180M, VDD1_OPP2, 0x26},
62 -       /*OPP3*/
63 -       {S360M, VDD1_OPP3, 0x30},
64 -       /*OPP4*/
65 -       {S400M, VDD1_OPP4, 0x36},
66 -       /*OPP5*/
67 -       {S430M, VDD1_OPP5, 0x3C},
68 -};
69 +extern struct omap_opp omap3_mpu_rate_table[];
70 +extern struct omap_opp omap3_dsp_rate_table[];
71 +extern struct omap_opp omap3_l3_rate_table[];
72  
73  #endif
74 --- kernel-maemo-2.6.28.orig/arch/arm/plat-omap/include/mach/omap34xx.h
75 +++ kernel-maemo-2.6.28/arch/arm/plat-omap/include/mach/omap34xx.h
76 @@ -114,7 +114,8 @@
77  #define VDD2_OPP3      0x3
78  
79  #define MIN_VDD1_OPP   VDD1_OPP1
80 -#define MAX_VDD1_OPP   VDD1_OPP5
81 +/*#define MAX_VDD1_OPP VDD1_OPP5*/
82 +#define MAX_VDD1_OPP   15
83  #define MIN_VDD2_OPP   VDD2_OPP1
84  #define MAX_VDD2_OPP   VDD2_OPP3
85  
86 --- kernel-maemo-2.6.28.orig/arch/arm/mach-omap2/smartreflex.c
87 +++ kernel-maemo-2.6.28/arch/arm/mach-omap2/smartreflex.c
88 @@ -513,7 +513,7 @@
89         sr->req_opp_no = target_opp_no;
90  
91         if (sr->srid == SR1) {
92 -               switch (target_opp_no) {
93 +               switch (min(target_opp_no-1,5)) {
94                 case 5:
95                         nvalue_reciprocal = sr->opp5_nvalue;
96                         break;
97 @@ -527,6 +527,7 @@
98                         nvalue_reciprocal = sr->opp2_nvalue;
99                         break;
100                 case 1:
101 +               case 0:
102                         nvalue_reciprocal = sr->opp1_nvalue;
103                         break;
104                 default:
105 @@ -564,6 +565,8 @@
106                         (ERRCONFIG_VPBOUNDINTEN | ERRCONFIG_VPBOUNDINTST));
107  
108         if (sr->srid == SR1) {
109 +               /*printk(KERN_NOTICE "OPP%d setting voltage %d\n",
110 +                                                               target_opp_no,mpu_opps[target_opp_no].vsel);*/
111                 errminlimit = (target_opp_no > SR_MAX_LOW_OPP) ?
112                         SR1_ERRMINLIMIT_HIGHOPP : SR1_ERRMINLIMIT_LOWOPP;
113  
114 @@ -866,6 +869,8 @@
115         current_opp_no = get_opp_no(current_opp);
116  
117         if (vdd == PRCM_VDD1) {
118 +               /*printk(KERN_DEBUG "OPP%d bypass setting voltage %d\n",
119 +                                                               target_opp_no,target_vsel);*/
120                 t2_smps_steps = abs(target_vsel - current_vsel);
121                 errorgain = (target_opp_no > SR_MAX_LOW_OPP) ?
122                         PRM_VP1_CONFIG_ERRORGAIN_HIGHOPP :
123 --- kernel-maemo-2.6.28.orig/arch/arm/plat-omap/cpu-omap.c
124 +++ kernel-maemo-2.6.28/arch/arm/plat-omap/cpu-omap.c
125 @@ -148,10 +148,13 @@
126                                                         VERY_HI_RATE) / 1000;
127         }
128  
129 -       clk_set_rate(mpu_clk, policy->cpuinfo.max_freq * 1000);
130 +       /*clk_set_rate(mpu_clk, policy->cpuinfo.max_freq * 1000);*/
131 +       clk_set_rate(mpu_clk, 600000 * 1000); /*N900 hack: set default max to 600MHz */
132  
133 -       policy->min = policy->cpuinfo.min_freq;
134 -       policy->max = policy->cpuinfo.max_freq;
135 +       /*policy->min = policy->cpuinfo.min_freq;*/
136 +       /*policy->max = policy->cpuinfo.max_freq;*/
137 +       policy->min = 250000;
138 +       policy->max = 600000; /*N900 hack: set default to 250-600MHz */
139         policy->cur = omap_getspeed(0);
140  
141         policy->cpuinfo.transition_latency = 300 * 1000;
142 --- kernel-maemo-2.6.28.orig/arch/arm/mach-omap2/smartreflex.h
143 +++ kernel-maemo-2.6.28/arch/arm/mach-omap2/smartreflex.h
144 @@ -254,7 +254,7 @@
145  /* XXX: end remove/move */
146  
147  /* SR_MAX_LOW_OPP: the highest of the "low OPPs", 1 and 2. */
148 -#define SR_MAX_LOW_OPP         2
149 +#define SR_MAX_LOW_OPP         3
150  
151  /* XXX: find more appropriate place for these once DVFS is in place */
152  extern u32 current_vdd1_opp;
153 --- kernel-maemo-2.6.28.orig/drivers/cpufreq/cpufreq.c
154 +++ kernel-maemo-2.6.28/drivers/cpufreq/cpufreq.c
155 @@ -465,7 +465,7 @@
156  /**
157   * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
158   */
159 -#define store_one(file_name, object)                   \
160 +#define store_one(file_name, object,ignore)                    \
161  static ssize_t store_##file_name                                       \
162  (struct cpufreq_policy *policy, const char *buf, size_t count)         \
163  {                                                                      \
164 @@ -479,15 +479,16 @@
165         ret = sscanf (buf, "%u", &new_policy.object);                   \
166         if (ret != 1)                                                   \
167                 return -EINVAL;                                         \
168 -                                                                       \
169 -       ret = __cpufreq_set_policy(policy, &new_policy);                \
170 +       printk(KERN_DEBUG "cpufreq: request %u -> %u\n",policy->object,new_policy.object);      \
171 +       if (new_policy.object != ignore && new_policy.object >= 100000) \
172 +           ret = __cpufreq_set_policy(policy, &new_policy);            \
173         policy->user_policy.object = policy->object;                    \
174                                                                         \
175         return ret ? ret : count;                                       \
176  }
177  
178 -store_one(scaling_min_freq,min);
179 -store_one(scaling_max_freq,max);
180 +store_one(scaling_min_freq,min,0);
181 +store_one(scaling_max_freq,max,600000);
182  
183  /**
184   * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware
185 --- kernel-maemo-2.6.28.orig/arch/arm/mach-omap2/pm.c
186 +++ kernel-maemo-2.6.28/arch/arm/mach-omap2/pm.c
187 @@ -39,6 +39,62 @@
188  #include "prm-regbits-34xx.h"
189  #include "pm.h"
190  #include "smartreflex.h"
191 +#include "resource34xx_mutex.h"
192 +#include "omap3-opp.h"
193 +
194 +struct omap_opp omap3_mpu_rate_table[] = {
195 +       {0, 0, 0},
196 +       {0, 1, 0x1E},
197 +       /*underclocking*/
198 +       {S125M, 2, 0x1E},
199 +       /*default*/
200 +       {S250M, 3, 0x26},
201 +       {S500M, 4, 0x30},
202 +       {S550M, 5, 0x36},
203 +       {S600M, 6, 0x3C},
204 +       /*overclocking*/
205 +       {S700M, 7, 0x3C},
206 +       {S750M, 8, 0x3C},
207 +       {S805M, 9, 0x3C},
208 +       {S850M, 10, 0x3C},
209 +       {S900M, 11, 0x3C},
210 +       {S950M, 12, 0x3C},
211 +       {S1000M, 13, 0x3C},
212 +       {S1100M, 14, 0x48},
213 +       {S1150M, 15, 0x48},
214 +};
215 +
216 +struct omap_opp omap3_l3_rate_table[] = {
217 +       {0, 0, 0},
218 +       /*OPP1*/
219 +       {0, VDD2_OPP1, 0x1E},
220 +       /*OPP2*/
221 +       {S83M, VDD2_OPP2, 0x24},
222 +       /*OPP3*/
223 +       {S166M, VDD2_OPP3, 0x2C},
224 +};
225 +
226 +struct omap_opp omap3_dsp_rate_table[] = {
227 +       {0, 0, 0},
228 +       /*underclocking*/
229 +       {S90M,  1, 0x1E},
230 +       /*default*/
231 +       {S90M,  2, 0x1E},
232 +       {S180M, 3, 0x26},
233 +       {S360M, 4, 0x30},
234 +       {S400M, 5, 0x36},
235 +       {S430M, 6, 0x3C},
236 +       /*overclocking*/
237 +       {S430M, 7, 0x3C},
238 +       {S430M, 8, 0x3C},
239 +       {S430M, 9, 0x3C},/*800MHz*/
240 +       {S500M, 10, 0x3C},
241 +       {S500M, 11, 0x3C},
242 +       {S500M, 12, 0x3C},
243 +       {S500M, 13, 0x3C},
244 +       {S520M, 14, 0x48},
245 +       {S520M, 15, 0x48},
246 +};
247  
248  unsigned short enable_dyn_sleep;
249  unsigned short clocks_off_while_idle;
250 @@ -81,6 +137,108 @@
251  
252  #endif
253  
254 +static ssize_t omap_vdd1_opps_vsel_show(struct kobject *kobj,
255 +                                       struct kobj_attribute *attr, char *buf)
256 +{
257 +       int i;
258 +       char *b=buf;
259 +       for(i=1;i<=MAX_VDD1_OPP;i++)
260 +               b+=sprintf(b, "%hu ", mpu_opps[i].vsel);
261 +       b+=sprintf(b, "\n");
262 +       return b-buf;
263 +}
264 +
265 +static ssize_t omap_vdd1_opps_vsel_store(struct kobject *kobj,
266 +                                       struct kobj_attribute *attr,
267 +                                       const char *buf, size_t n)
268 +{
269 +       u16 value[16];
270 +       int i;
271 +
272 +       if (sscanf(buf, "%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu",
273 +                               &value[0], &value[1], &value[2], &value[3],
274 +                               &value[4], &value[5], &value[6], &value[7],
275 +                               &value[8], &value[9], &value[10], &value[11],
276 +                               &value[12], &value[13], &value[14], &value[15]
277 +                               ) != MAX_VDD1_OPP) {
278 +               printk(KERN_ERR "vdd1_opps_vsel: Invalid value\n");
279 +               return -EINVAL;
280 +       }
281 +
282 +       mutex_lock(&dvfs_mutex);
283 +
284 +       for(i=1;i<=MAX_VDD1_OPP;i++) {
285 +               if(value[i-1]<0x49) {
286 +                       mpu_opps[i].vsel = value[i-1];
287 +               }
288 +       }
289 +
290 +       mutex_unlock(&dvfs_mutex);
291 +
292 +       return n;
293 +}
294 +
295 +static struct kobj_attribute vdd1_opps_vsel = {
296 +       .attr = {
297 +       .name = __stringify(vdd1_opps_vsel),
298 +       .mode = 0644,
299 +       },
300 +       .show = omap_vdd1_opps_vsel_show,
301 +       .store = omap_vdd1_opps_vsel_store,
302 +};
303 +
304 +static ssize_t omap_dsp_opps_rate_show(struct kobject *kobj,
305 +                                       struct kobj_attribute *attr, char *buf)
306 +{
307 +       int i;
308 +       char *b=buf;
309 +       for(i=1;i<=MAX_VDD1_OPP;i++)
310 +               b+=sprintf(b, "%lu ", dsp_opps[i].rate);
311 +       b+=sprintf(b, "\n");
312 +       return b-buf;
313 +}
314 +
315 +static ssize_t omap_dsp_opps_rate_store(struct kobject *kobj,
316 +                                       struct kobj_attribute *attr,
317 +                                       const char *buf, size_t n)
318 +{
319 +       unsigned long value[16];
320 +       int i;
321 +
322 +       if (sscanf(buf, "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
323 +                               &value[0], &value[1], &value[2], &value[3],
324 +                               &value[4], &value[5], &value[6], &value[7],
325 +                               &value[8], &value[9], &value[10], &value[11],
326 +                               &value[12], &value[13], &value[14], &value[15]
327 +                               ) != MAX_VDD1_OPP) {
328 +               printk(KERN_ERR "dsp_opps_rate: Invalid value\n");
329 +               return -EINVAL;
330 +       }
331 +
332 +       mutex_lock(&dvfs_mutex);
333 +
334 +       for(i=1;i<=MAX_VDD1_OPP;i++) {
335 +               if(value[i-1]<=600000) {
336 +                       dsp_opps[i].rate = value[i-1];
337 +               }
338 +       }
339 +
340 +       mutex_unlock(&dvfs_mutex);
341 +
342 +       return n;
343 +}
344 +
345 +static struct kobj_attribute dsp_opps_rate = {
346 +       .attr = {
347 +       .name = __stringify(dsp_opps_rate),
348 +       .mode = 0644,
349 +       },
350 +       .show = omap_dsp_opps_rate_show,
351 +       .store = omap_dsp_opps_rate_store,
352 +};
353 +
354 +
355 +
356  static ssize_t idle_show(struct kobject *kobj, struct kobj_attribute *attr,
357                          char *buf)
358  {
359 @@ -258,6 +416,17 @@
360                 printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
361                 return error;
362         }
363 +       error = sysfs_create_file(power_kobj, &vdd1_opps_vsel.attr);
364 +       if (error) {
365 +               printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
366 +               return error;
367 +       }
368 +       error = sysfs_create_file(power_kobj, &dsp_opps_rate.attr);
369 +       if (error) {
370 +               printk(KERN_ERR "sysfs_create_file failed: %d\n", error);
371 +               return error;
372 +       }
373 +
374  #ifdef CONFIG_OMAP_PM_SRF
375         error = sysfs_create_file(power_kobj,
376                                   &vdd1_opp_attr.attr);