blob: 79b1b4ec8e3c65f5302c3180215ba6b2152d93cb [file] [log] [blame]
Kukjin Kimf7d77072011-06-01 14:18:22 -07001/*
Jaecheol Lee83efc742010-10-12 09:19:38 +09002 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * CPU frequency scaling for S5PC110/S5PV210
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/types.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/clk.h>
17#include <linux/io.h>
18#include <linux/cpufreq.h>
Jonghwan Choie8b4c192011-06-24 16:04:14 +090019#include <linux/regulator/consumer.h>
Huisung Kang405e6d62011-06-24 16:04:15 +090020#include <linux/suspend.h>
Jaecheol Lee83efc742010-10-12 09:19:38 +090021
22#include <mach/map.h>
23#include <mach/regs-clock.h>
24
25static struct clk *cpu_clk;
26static struct clk *dmc0_clk;
27static struct clk *dmc1_clk;
28static struct cpufreq_freqs freqs;
29
30/* APLL M,P,S values for 1G/800Mhz */
31#define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1)
32#define APLL_VAL_800 ((1 << 31) | (100 << 16) | (3 << 8) | 1)
33
Huisung Kang405e6d62011-06-24 16:04:15 +090034/* Use 800MHz when entering sleep mode */
35#define SLEEP_FREQ (800 * 1000)
36
Jaecheol Lee83efc742010-10-12 09:19:38 +090037/*
Huisung Kang90d5d0a2011-06-24 16:04:13 +090038 * relation has an additional symantics other than the standard of cpufreq
39 * DISALBE_FURTHER_CPUFREQ: disable further access to target
40 * ENABLE_FURTUER_CPUFREQ: enable access to target
41 */
42enum cpufreq_access {
43 DISABLE_FURTHER_CPUFREQ = 0x10,
44 ENABLE_FURTHER_CPUFREQ = 0x20,
45};
46
47static bool no_cpufreq_access;
48
49/*
Jaecheol Lee83efc742010-10-12 09:19:38 +090050 * DRAM configurations to calculate refresh counter for changing
51 * frequency of memory.
52 */
53struct dram_conf {
54 unsigned long freq; /* HZ */
55 unsigned long refresh; /* DRAM refresh counter * 1000 */
56};
57
58/* DRAM configuration (DMC0 and DMC1) */
59static struct dram_conf s5pv210_dram_conf[2];
60
61enum perf_level {
62 L0, L1, L2, L3, L4,
63};
64
65enum s5pv210_mem_type {
66 LPDDR = 0x1,
67 LPDDR2 = 0x2,
68 DDR2 = 0x4,
69};
70
71enum s5pv210_dmc_port {
72 DMC0 = 0,
73 DMC1,
74};
75
76static struct cpufreq_frequency_table s5pv210_freq_table[] = {
77 {L0, 1000*1000},
78 {L1, 800*1000},
79 {L2, 400*1000},
80 {L3, 200*1000},
81 {L4, 100*1000},
82 {0, CPUFREQ_TABLE_END},
83};
84
Jonghwan Choie8b4c192011-06-24 16:04:14 +090085static struct regulator *arm_regulator;
86static struct regulator *int_regulator;
87
88struct s5pv210_dvs_conf {
89 int arm_volt; /* uV */
90 int int_volt; /* uV */
91};
92
93static const int arm_volt_max = 1350000;
94static const int int_volt_max = 1250000;
95
96static struct s5pv210_dvs_conf dvs_conf[] = {
97 [L0] = {
98 .arm_volt = 1250000,
99 .int_volt = 1100000,
100 },
101 [L1] = {
102 .arm_volt = 1200000,
103 .int_volt = 1100000,
104 },
105 [L2] = {
106 .arm_volt = 1050000,
107 .int_volt = 1100000,
108 },
109 [L3] = {
110 .arm_volt = 950000,
111 .int_volt = 1100000,
112 },
113 [L4] = {
114 .arm_volt = 950000,
115 .int_volt = 1000000,
116 },
117};
118
Jaecheol Lee83efc742010-10-12 09:19:38 +0900119static u32 clkdiv_val[5][11] = {
120 /*
121 * Clock divider value for following
122 * { APLL, A2M, HCLK_MSYS, PCLK_MSYS,
123 * HCLK_DSYS, PCLK_DSYS, HCLK_PSYS, PCLK_PSYS,
124 * ONEDRAM, MFC, G3D }
125 */
126
127 /* L0 : [1000/200/100][166/83][133/66][200/200] */
128 {0, 4, 4, 1, 3, 1, 4, 1, 3, 0, 0},
129
130 /* L1 : [800/200/100][166/83][133/66][200/200] */
131 {0, 3, 3, 1, 3, 1, 4, 1, 3, 0, 0},
132
133 /* L2 : [400/200/100][166/83][133/66][200/200] */
134 {1, 3, 1, 1, 3, 1, 4, 1, 3, 0, 0},
135
136 /* L3 : [200/200/100][166/83][133/66][200/200] */
137 {3, 3, 1, 1, 3, 1, 4, 1, 3, 0, 0},
138
139 /* L4 : [100/100/100][83/83][66/66][100/100] */
140 {7, 7, 0, 0, 7, 0, 9, 0, 7, 0, 0},
141};
142
143/*
144 * This function set DRAM refresh counter
145 * accoriding to operating frequency of DRAM
146 * ch: DMC port number 0 or 1
147 * freq: Operating frequency of DRAM(KHz)
148 */
149static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq)
150{
151 unsigned long tmp, tmp1;
152 void __iomem *reg = NULL;
153
Jonghwan Choid62fa312011-05-12 18:31:20 +0900154 if (ch == DMC0) {
Jaecheol Lee83efc742010-10-12 09:19:38 +0900155 reg = (S5P_VA_DMC0 + 0x30);
Jonghwan Choid62fa312011-05-12 18:31:20 +0900156 } else if (ch == DMC1) {
Jaecheol Lee83efc742010-10-12 09:19:38 +0900157 reg = (S5P_VA_DMC1 + 0x30);
Jonghwan Choid62fa312011-05-12 18:31:20 +0900158 } else {
Jaecheol Lee83efc742010-10-12 09:19:38 +0900159 printk(KERN_ERR "Cannot find DMC port\n");
Jonghwan Choid62fa312011-05-12 18:31:20 +0900160 return;
161 }
Jaecheol Lee83efc742010-10-12 09:19:38 +0900162
163 /* Find current DRAM frequency */
164 tmp = s5pv210_dram_conf[ch].freq;
165
166 do_div(tmp, freq);
167
168 tmp1 = s5pv210_dram_conf[ch].refresh;
169
170 do_div(tmp1, tmp);
171
172 __raw_writel(tmp1, reg);
173}
174
175int s5pv210_verify_speed(struct cpufreq_policy *policy)
176{
177 if (policy->cpu)
178 return -EINVAL;
179
180 return cpufreq_frequency_table_verify(policy, s5pv210_freq_table);
181}
182
183unsigned int s5pv210_getspeed(unsigned int cpu)
184{
185 if (cpu)
186 return 0;
187
188 return clk_get_rate(cpu_clk) / 1000;
189}
190
191static int s5pv210_target(struct cpufreq_policy *policy,
192 unsigned int target_freq,
193 unsigned int relation)
194{
195 unsigned long reg;
196 unsigned int index, priv_index;
197 unsigned int pll_changing = 0;
198 unsigned int bus_speed_changing = 0;
Jonghwan Choie8b4c192011-06-24 16:04:14 +0900199 int arm_volt, int_volt;
200 int ret = 0;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900201
Huisung Kang90d5d0a2011-06-24 16:04:13 +0900202 if (relation & ENABLE_FURTHER_CPUFREQ)
203 no_cpufreq_access = false;
204
205 if (no_cpufreq_access) {
206#ifdef CONFIG_PM_VERBOSE
207 pr_err("%s:%d denied access to %s as it is disabled"
208 "temporarily\n", __FILE__, __LINE__, __func__);
209#endif
210 return -EINVAL;
211 }
212
213 if (relation & DISABLE_FURTHER_CPUFREQ)
214 no_cpufreq_access = true;
215
216 relation &= ~(ENABLE_FURTHER_CPUFREQ | DISABLE_FURTHER_CPUFREQ);
217
Jaecheol Lee83efc742010-10-12 09:19:38 +0900218 freqs.old = s5pv210_getspeed(0);
219
220 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
221 target_freq, relation, &index))
222 return -EINVAL;
223
224 freqs.new = s5pv210_freq_table[index].frequency;
225 freqs.cpu = 0;
226
227 if (freqs.new == freqs.old)
228 return 0;
229
230 /* Finding current running level index */
231 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
232 freqs.old, relation, &priv_index))
233 return -EINVAL;
234
Jonghwan Choie8b4c192011-06-24 16:04:14 +0900235 arm_volt = dvs_conf[index].arm_volt;
236 int_volt = dvs_conf[index].int_volt;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900237
238 if (freqs.new > freqs.old) {
Jonghwan Choie8b4c192011-06-24 16:04:14 +0900239 ret = regulator_set_voltage(arm_regulator,
240 arm_volt, arm_volt_max);
241 if (ret)
242 return ret;
243
244 ret = regulator_set_voltage(int_regulator,
245 int_volt, int_volt_max);
246 if (ret)
247 return ret;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900248 }
249
Jonghwan Choie8b4c192011-06-24 16:04:14 +0900250 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
251
Jaecheol Lee83efc742010-10-12 09:19:38 +0900252 /* Check if there need to change PLL */
253 if ((index == L0) || (priv_index == L0))
254 pll_changing = 1;
255
256 /* Check if there need to change System bus clock */
257 if ((index == L4) || (priv_index == L4))
258 bus_speed_changing = 1;
259
260 if (bus_speed_changing) {
261 /*
262 * Reconfigure DRAM refresh counter value for minimum
263 * temporary clock while changing divider.
264 * expected clock is 83Mhz : 7.8usec/(1/83Mhz) = 0x287
265 */
266 if (pll_changing)
267 s5pv210_set_refresh(DMC1, 83000);
268 else
269 s5pv210_set_refresh(DMC1, 100000);
270
271 s5pv210_set_refresh(DMC0, 83000);
272 }
273
274 /*
275 * APLL should be changed in this level
276 * APLL -> MPLL(for stable transition) -> APLL
277 * Some clock source's clock API are not prepared.
278 * Do not use clock API in below code.
279 */
280 if (pll_changing) {
281 /*
282 * 1. Temporary Change divider for MFC and G3D
283 * SCLKA2M(200/1=200)->(200/4=50)Mhz
284 */
285 reg = __raw_readl(S5P_CLK_DIV2);
286 reg &= ~(S5P_CLKDIV2_G3D_MASK | S5P_CLKDIV2_MFC_MASK);
287 reg |= (3 << S5P_CLKDIV2_G3D_SHIFT) |
288 (3 << S5P_CLKDIV2_MFC_SHIFT);
289 __raw_writel(reg, S5P_CLK_DIV2);
290
291 /* For MFC, G3D dividing */
292 do {
293 reg = __raw_readl(S5P_CLKDIV_STAT0);
294 } while (reg & ((1 << 16) | (1 << 17)));
295
296 /*
297 * 2. Change SCLKA2M(200Mhz)to SCLKMPLL in MFC_MUX, G3D MUX
298 * (200/4=50)->(667/4=166)Mhz
299 */
300 reg = __raw_readl(S5P_CLK_SRC2);
301 reg &= ~(S5P_CLKSRC2_G3D_MASK | S5P_CLKSRC2_MFC_MASK);
302 reg |= (1 << S5P_CLKSRC2_G3D_SHIFT) |
303 (1 << S5P_CLKSRC2_MFC_SHIFT);
304 __raw_writel(reg, S5P_CLK_SRC2);
305
306 do {
307 reg = __raw_readl(S5P_CLKMUX_STAT1);
308 } while (reg & ((1 << 7) | (1 << 3)));
309
310 /*
311 * 3. DMC1 refresh count for 133Mhz if (index == L4) is
312 * true refresh counter is already programed in upper
313 * code. 0x287@83Mhz
314 */
315 if (!bus_speed_changing)
316 s5pv210_set_refresh(DMC1, 133000);
317
318 /* 4. SCLKAPLL -> SCLKMPLL */
319 reg = __raw_readl(S5P_CLK_SRC0);
320 reg &= ~(S5P_CLKSRC0_MUX200_MASK);
321 reg |= (0x1 << S5P_CLKSRC0_MUX200_SHIFT);
322 __raw_writel(reg, S5P_CLK_SRC0);
323
324 do {
325 reg = __raw_readl(S5P_CLKMUX_STAT0);
326 } while (reg & (0x1 << 18));
327
328 }
329
330 /* Change divider */
331 reg = __raw_readl(S5P_CLK_DIV0);
332
333 reg &= ~(S5P_CLKDIV0_APLL_MASK | S5P_CLKDIV0_A2M_MASK |
334 S5P_CLKDIV0_HCLK200_MASK | S5P_CLKDIV0_PCLK100_MASK |
335 S5P_CLKDIV0_HCLK166_MASK | S5P_CLKDIV0_PCLK83_MASK |
336 S5P_CLKDIV0_HCLK133_MASK | S5P_CLKDIV0_PCLK66_MASK);
337
338 reg |= ((clkdiv_val[index][0] << S5P_CLKDIV0_APLL_SHIFT) |
339 (clkdiv_val[index][1] << S5P_CLKDIV0_A2M_SHIFT) |
340 (clkdiv_val[index][2] << S5P_CLKDIV0_HCLK200_SHIFT) |
341 (clkdiv_val[index][3] << S5P_CLKDIV0_PCLK100_SHIFT) |
342 (clkdiv_val[index][4] << S5P_CLKDIV0_HCLK166_SHIFT) |
343 (clkdiv_val[index][5] << S5P_CLKDIV0_PCLK83_SHIFT) |
344 (clkdiv_val[index][6] << S5P_CLKDIV0_HCLK133_SHIFT) |
345 (clkdiv_val[index][7] << S5P_CLKDIV0_PCLK66_SHIFT));
346
347 __raw_writel(reg, S5P_CLK_DIV0);
348
349 do {
350 reg = __raw_readl(S5P_CLKDIV_STAT0);
351 } while (reg & 0xff);
352
353 /* ARM MCS value changed */
354 reg = __raw_readl(S5P_ARM_MCS_CON);
355 reg &= ~0x3;
356 if (index >= L3)
357 reg |= 0x3;
358 else
359 reg |= 0x1;
360
361 __raw_writel(reg, S5P_ARM_MCS_CON);
362
363 if (pll_changing) {
364 /* 5. Set Lock time = 30us*24Mhz = 0x2cf */
365 __raw_writel(0x2cf, S5P_APLL_LOCK);
366
367 /*
368 * 6. Turn on APLL
369 * 6-1. Set PMS values
370 * 6-2. Wait untile the PLL is locked
371 */
372 if (index == L0)
373 __raw_writel(APLL_VAL_1000, S5P_APLL_CON);
374 else
375 __raw_writel(APLL_VAL_800, S5P_APLL_CON);
376
377 do {
378 reg = __raw_readl(S5P_APLL_CON);
379 } while (!(reg & (0x1 << 29)));
380
381 /*
382 * 7. Change souce clock from SCLKMPLL(667Mhz)
383 * to SCLKA2M(200Mhz) in MFC_MUX and G3D MUX
384 * (667/4=166)->(200/4=50)Mhz
385 */
386 reg = __raw_readl(S5P_CLK_SRC2);
387 reg &= ~(S5P_CLKSRC2_G3D_MASK | S5P_CLKSRC2_MFC_MASK);
388 reg |= (0 << S5P_CLKSRC2_G3D_SHIFT) |
389 (0 << S5P_CLKSRC2_MFC_SHIFT);
390 __raw_writel(reg, S5P_CLK_SRC2);
391
392 do {
393 reg = __raw_readl(S5P_CLKMUX_STAT1);
394 } while (reg & ((1 << 7) | (1 << 3)));
395
396 /*
397 * 8. Change divider for MFC and G3D
398 * (200/4=50)->(200/1=200)Mhz
399 */
400 reg = __raw_readl(S5P_CLK_DIV2);
401 reg &= ~(S5P_CLKDIV2_G3D_MASK | S5P_CLKDIV2_MFC_MASK);
402 reg |= (clkdiv_val[index][10] << S5P_CLKDIV2_G3D_SHIFT) |
403 (clkdiv_val[index][9] << S5P_CLKDIV2_MFC_SHIFT);
404 __raw_writel(reg, S5P_CLK_DIV2);
405
406 /* For MFC, G3D dividing */
407 do {
408 reg = __raw_readl(S5P_CLKDIV_STAT0);
409 } while (reg & ((1 << 16) | (1 << 17)));
410
411 /* 9. Change MPLL to APLL in MSYS_MUX */
412 reg = __raw_readl(S5P_CLK_SRC0);
413 reg &= ~(S5P_CLKSRC0_MUX200_MASK);
414 reg |= (0x0 << S5P_CLKSRC0_MUX200_SHIFT);
415 __raw_writel(reg, S5P_CLK_SRC0);
416
417 do {
418 reg = __raw_readl(S5P_CLKMUX_STAT0);
419 } while (reg & (0x1 << 18));
420
421 /*
422 * 10. DMC1 refresh counter
423 * L4 : DMC1 = 100Mhz 7.8us/(1/100) = 0x30c
424 * Others : DMC1 = 200Mhz 7.8us/(1/200) = 0x618
425 */
426 if (!bus_speed_changing)
427 s5pv210_set_refresh(DMC1, 200000);
428 }
429
430 /*
431 * L4 level need to change memory bus speed, hence onedram clock divier
432 * and memory refresh parameter should be changed
433 */
434 if (bus_speed_changing) {
435 reg = __raw_readl(S5P_CLK_DIV6);
436 reg &= ~S5P_CLKDIV6_ONEDRAM_MASK;
437 reg |= (clkdiv_val[index][8] << S5P_CLKDIV6_ONEDRAM_SHIFT);
438 __raw_writel(reg, S5P_CLK_DIV6);
439
440 do {
441 reg = __raw_readl(S5P_CLKDIV_STAT1);
442 } while (reg & (1 << 15));
443
444 /* Reconfigure DRAM refresh counter value */
445 if (index != L4) {
446 /*
447 * DMC0 : 166Mhz
448 * DMC1 : 200Mhz
449 */
450 s5pv210_set_refresh(DMC0, 166000);
451 s5pv210_set_refresh(DMC1, 200000);
452 } else {
453 /*
454 * DMC0 : 83Mhz
455 * DMC1 : 100Mhz
456 */
457 s5pv210_set_refresh(DMC0, 83000);
458 s5pv210_set_refresh(DMC1, 100000);
459 }
460 }
461
462 if (freqs.new < freqs.old) {
Jonghwan Choie8b4c192011-06-24 16:04:14 +0900463 regulator_set_voltage(int_regulator,
464 int_volt, int_volt_max);
465
466 regulator_set_voltage(arm_regulator,
467 arm_volt, arm_volt_max);
Jaecheol Lee83efc742010-10-12 09:19:38 +0900468 }
469
470 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
471
472 printk(KERN_DEBUG "Perf changed[L%d]\n", index);
473
474 return 0;
475}
476
477#ifdef CONFIG_PM
Rafael J. Wysocki7ca64e22011-03-10 21:13:05 +0100478static int s5pv210_cpufreq_suspend(struct cpufreq_policy *policy)
Jaecheol Lee83efc742010-10-12 09:19:38 +0900479{
480 return 0;
481}
482
483static int s5pv210_cpufreq_resume(struct cpufreq_policy *policy)
484{
485 return 0;
486}
487#endif
488
489static int check_mem_type(void __iomem *dmc_reg)
490{
491 unsigned long val;
492
493 val = __raw_readl(dmc_reg + 0x4);
494 val = (val & (0xf << 8));
495
496 return val >> 8;
497}
498
499static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
500{
501 unsigned long mem_type;
Julia Lawall4911ca12011-06-06 18:59:02 -0700502 int ret;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900503
504 cpu_clk = clk_get(NULL, "armclk");
505 if (IS_ERR(cpu_clk))
506 return PTR_ERR(cpu_clk);
507
508 dmc0_clk = clk_get(NULL, "sclk_dmc0");
509 if (IS_ERR(dmc0_clk)) {
Julia Lawall4911ca12011-06-06 18:59:02 -0700510 ret = PTR_ERR(dmc0_clk);
511 goto out_dmc0;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900512 }
513
514 dmc1_clk = clk_get(NULL, "hclk_msys");
515 if (IS_ERR(dmc1_clk)) {
Julia Lawall4911ca12011-06-06 18:59:02 -0700516 ret = PTR_ERR(dmc1_clk);
517 goto out_dmc1;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900518 }
519
Julia Lawall4911ca12011-06-06 18:59:02 -0700520 if (policy->cpu != 0) {
521 ret = -EINVAL;
522 goto out_dmc1;
523 }
Jaecheol Lee83efc742010-10-12 09:19:38 +0900524
525 /*
526 * check_mem_type : This driver only support LPDDR & LPDDR2.
527 * other memory type is not supported.
528 */
529 mem_type = check_mem_type(S5P_VA_DMC0);
530
531 if ((mem_type != LPDDR) && (mem_type != LPDDR2)) {
532 printk(KERN_ERR "CPUFreq doesn't support this memory type\n");
Julia Lawall4911ca12011-06-06 18:59:02 -0700533 ret = -EINVAL;
534 goto out_dmc1;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900535 }
536
537 /* Find current refresh counter and frequency each DMC */
538 s5pv210_dram_conf[0].refresh = (__raw_readl(S5P_VA_DMC0 + 0x30) * 1000);
539 s5pv210_dram_conf[0].freq = clk_get_rate(dmc0_clk);
540
541 s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000);
542 s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk);
543
544 policy->cur = policy->min = policy->max = s5pv210_getspeed(0);
545
546 cpufreq_frequency_table_get_attr(s5pv210_freq_table, policy->cpu);
547
548 policy->cpuinfo.transition_latency = 40000;
549
550 return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table);
Julia Lawall4911ca12011-06-06 18:59:02 -0700551
552out_dmc1:
553 clk_put(dmc0_clk);
554out_dmc0:
555 clk_put(cpu_clk);
556 return ret;
Jaecheol Lee83efc742010-10-12 09:19:38 +0900557}
558
Huisung Kang405e6d62011-06-24 16:04:15 +0900559static int s5pv210_cpufreq_notifier_event(struct notifier_block *this,
560 unsigned long event, void *ptr)
561{
562 int ret;
563
564 switch (event) {
565 case PM_SUSPEND_PREPARE:
566 ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
567 DISABLE_FURTHER_CPUFREQ);
568 if (ret < 0)
569 return NOTIFY_BAD;
570
571 return NOTIFY_OK;
572 case PM_POST_RESTORE:
573 case PM_POST_SUSPEND:
574 cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ,
575 ENABLE_FURTHER_CPUFREQ);
576
577 return NOTIFY_OK;
578 }
579
580 return NOTIFY_DONE;
581}
582
Jaecheol Lee83efc742010-10-12 09:19:38 +0900583static struct cpufreq_driver s5pv210_driver = {
584 .flags = CPUFREQ_STICKY,
585 .verify = s5pv210_verify_speed,
586 .target = s5pv210_target,
587 .get = s5pv210_getspeed,
588 .init = s5pv210_cpu_init,
589 .name = "s5pv210",
590#ifdef CONFIG_PM
591 .suspend = s5pv210_cpufreq_suspend,
592 .resume = s5pv210_cpufreq_resume,
593#endif
594};
595
Huisung Kang405e6d62011-06-24 16:04:15 +0900596static struct notifier_block s5pv210_cpufreq_notifier = {
597 .notifier_call = s5pv210_cpufreq_notifier_event,
598};
599
Jaecheol Lee83efc742010-10-12 09:19:38 +0900600static int __init s5pv210_cpufreq_init(void)
601{
Jonghwan Choie8b4c192011-06-24 16:04:14 +0900602 arm_regulator = regulator_get(NULL, "vddarm");
603 if (IS_ERR(arm_regulator)) {
604 pr_err("failed to get regulator vddarm");
605 return PTR_ERR(arm_regulator);
606 }
607
608 int_regulator = regulator_get(NULL, "vddint");
609 if (IS_ERR(int_regulator)) {
610 pr_err("failed to get regulator vddint");
611 regulator_put(arm_regulator);
612 return PTR_ERR(int_regulator);
613 }
614
Huisung Kang405e6d62011-06-24 16:04:15 +0900615 register_pm_notifier(&s5pv210_cpufreq_notifier);
616
Jaecheol Lee83efc742010-10-12 09:19:38 +0900617 return cpufreq_register_driver(&s5pv210_driver);
618}
619
620late_initcall(s5pv210_cpufreq_init);