aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/exynos4210-cpufreq.c
diff options
context:
space:
mode:
authorJonghwan Choi <jhbird.choi@samsung.com>2012-12-23 18:57:42 -0500
committerKukjin Kim <kgene.kim@samsung.com>2012-12-23 18:57:42 -0500
commit9d0554fff9a21d846adcfbd14cfb02e82773162c (patch)
tree98926538dc47a6e4025c70a65c5493f60ec19a97 /drivers/cpufreq/exynos4210-cpufreq.c
parent857d90f7014f4fe0acc49947ad5309174111a4e8 (diff)
cpufreq: exynos: Use APLL_FREQ macro for cpu divider value
Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'drivers/cpufreq/exynos4210-cpufreq.c')
-rw-r--r--drivers/cpufreq/exynos4210-cpufreq.c135
1 files changed, 25 insertions, 110 deletions
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 5ae5c529fca7..250dcf0c0b22 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -20,94 +20,37 @@
20#include <mach/regs-clock.h> 20#include <mach/regs-clock.h>
21#include <mach/cpufreq.h> 21#include <mach/cpufreq.h>
22 22
23#define CPUFREQ_LEVEL_END L5
24
25static struct clk *cpu_clk; 23static struct clk *cpu_clk;
26static struct clk *moutcore; 24static struct clk *moutcore;
27static struct clk *mout_mpll; 25static struct clk *mout_mpll;
28static struct clk *mout_apll; 26static struct clk *mout_apll;
29 27
30struct cpufreq_clkdiv { 28static unsigned int exynos4210_volt_table[] = {
31 unsigned int index;
32 unsigned int clkdiv;
33};
34
35static unsigned int exynos4210_volt_table[CPUFREQ_LEVEL_END] = {
36 1250000, 1150000, 1050000, 975000, 950000, 29 1250000, 1150000, 1050000, 975000, 950000,
37}; 30};
38 31
39
40static struct cpufreq_clkdiv exynos4210_clkdiv_table[CPUFREQ_LEVEL_END];
41
42static struct cpufreq_frequency_table exynos4210_freq_table[] = { 32static struct cpufreq_frequency_table exynos4210_freq_table[] = {
43 {L0, 1200*1000}, 33 {L0, 1200 * 1000},
44 {L1, 1000*1000}, 34 {L1, 1000 * 1000},
45 {L2, 800*1000}, 35 {L2, 800 * 1000},
46 {L3, 500*1000}, 36 {L3, 500 * 1000},
47 {L4, 200*1000}, 37 {L4, 200 * 1000},
48 {0, CPUFREQ_TABLE_END}, 38 {0, CPUFREQ_TABLE_END},
49}; 39};
50 40
51static unsigned int clkdiv_cpu0[CPUFREQ_LEVEL_END][7] = { 41static struct apll_freq apll_freq_4210[] = {
52 /* 42 /*
53 * Clock divider value for following 43 * values:
54 * { DIVCORE, DIVCOREM0, DIVCOREM1, DIVPERIPH, 44 * freq
55 * DIVATB, DIVPCLK_DBG, DIVAPLL } 45 * clock divider for CORE, COREM0, COREM1, PERIPH, ATB, PCLK_DBG, APLL, RESERVED
46 * clock divider for COPY, HPM, RESERVED
47 * PLL M, P, S
56 */ 48 */
57 49 APLL_FREQ(1200, 0, 3, 7, 3, 4, 1, 7, 0, 5, 0, 0, 150, 3, 1),
58 /* ARM L0: 1200MHz */ 50 APLL_FREQ(1000, 0, 3, 7, 3, 4, 1, 7, 0, 4, 0, 0, 250, 6, 1),
59 { 0, 3, 7, 3, 4, 1, 7 }, 51 APLL_FREQ(800, 0, 3, 7, 3, 3, 1, 7, 0, 3, 0, 0, 200, 6, 1),
60 52 APLL_FREQ(500, 0, 3, 7, 3, 3, 1, 7, 0, 3, 0, 0, 250, 6, 2),
61 /* ARM L1: 1000MHz */ 53 APLL_FREQ(200, 0, 1, 3, 1, 3, 1, 0, 0, 3, 0, 0, 200, 6, 3),
62 { 0, 3, 7, 3, 4, 1, 7 },
63
64 /* ARM L2: 800MHz */
65 { 0, 3, 7, 3, 3, 1, 7 },
66
67 /* ARM L3: 500MHz */
68 { 0, 3, 7, 3, 3, 1, 7 },
69
70 /* ARM L4: 200MHz */
71 { 0, 1, 3, 1, 3, 1, 0 },
72};
73
74static unsigned int clkdiv_cpu1[CPUFREQ_LEVEL_END][2] = {
75 /*
76 * Clock divider value for following
77 * { DIVCOPY, DIVHPM }
78 */
79
80 /* ARM L0: 1200MHz */
81 { 5, 0 },
82
83 /* ARM L1: 1000MHz */
84 { 4, 0 },
85
86 /* ARM L2: 800MHz */
87 { 3, 0 },
88
89 /* ARM L3: 500MHz */
90 { 3, 0 },
91
92 /* ARM L4: 200MHz */
93 { 3, 0 },
94};
95
96static unsigned int exynos4210_apll_pms_table[CPUFREQ_LEVEL_END] = {
97 /* APLL FOUT L0: 1200MHz */
98 ((150 << 16) | (3 << 8) | 1),
99
100 /* APLL FOUT L1: 1000MHz */
101 ((250 << 16) | (6 << 8) | 1),
102
103 /* APLL FOUT L2: 800MHz */
104 ((200 << 16) | (6 << 8) | 1),
105
106 /* APLL FOUT L3: 500MHz */
107 ((250 << 16) | (6 << 8) | 2),
108
109 /* APLL FOUT L4: 200MHz */
110 ((200 << 16) | (6 << 8) | 3),
111}; 54};
112 55
113static void exynos4210_set_clkdiv(unsigned int div_index) 56static void exynos4210_set_clkdiv(unsigned int div_index)
@@ -116,7 +59,7 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
116 59
117 /* Change Divider - CPU0 */ 60 /* Change Divider - CPU0 */
118 61
119 tmp = exynos4210_clkdiv_table[div_index].clkdiv; 62 tmp = apll_freq_4210[div_index].clk_div_cpu0;
120 63
121 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU); 64 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU);
122 65
@@ -126,12 +69,7 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
126 69
127 /* Change Divider - CPU1 */ 70 /* Change Divider - CPU1 */
128 71
129 tmp = __raw_readl(EXYNOS4_CLKDIV_CPU1); 72 tmp = apll_freq_4210[div_index].clk_div_cpu1;
130
131 tmp &= ~((0x7 << 4) | 0x7);
132
133 tmp |= ((clkdiv_cpu1[div_index][0] << 4) |
134 (clkdiv_cpu1[div_index][1] << 0));
135 73
136 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU1); 74 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU1);
137 75
@@ -159,7 +97,7 @@ static void exynos4210_set_apll(unsigned int index)
159 /* 3. Change PLL PMS values */ 97 /* 3. Change PLL PMS values */
160 tmp = __raw_readl(EXYNOS4_APLL_CON0); 98 tmp = __raw_readl(EXYNOS4_APLL_CON0);
161 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0)); 99 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0));
162 tmp |= exynos4210_apll_pms_table[index]; 100 tmp |= apll_freq_4210[index].mps;
163 __raw_writel(tmp, EXYNOS4_APLL_CON0); 101 __raw_writel(tmp, EXYNOS4_APLL_CON0);
164 102
165 /* 4. wait_lock_time */ 103 /* 4. wait_lock_time */
@@ -178,8 +116,8 @@ static void exynos4210_set_apll(unsigned int index)
178 116
179bool exynos4210_pms_change(unsigned int old_index, unsigned int new_index) 117bool exynos4210_pms_change(unsigned int old_index, unsigned int new_index)
180{ 118{
181 unsigned int old_pm = (exynos4210_apll_pms_table[old_index] >> 8); 119 unsigned int old_pm = apll_freq_4210[old_index].mps >> 8;
182 unsigned int new_pm = (exynos4210_apll_pms_table[new_index] >> 8); 120 unsigned int new_pm = apll_freq_4210[new_index].mps >> 8;
183 121
184 return (old_pm == new_pm) ? 0 : 1; 122 return (old_pm == new_pm) ? 0 : 1;
185} 123}
@@ -197,7 +135,7 @@ static void exynos4210_set_frequency(unsigned int old_index,
197 /* 2. Change just s value in apll m,p,s value */ 135 /* 2. Change just s value in apll m,p,s value */
198 tmp = __raw_readl(EXYNOS4_APLL_CON0); 136 tmp = __raw_readl(EXYNOS4_APLL_CON0);
199 tmp &= ~(0x7 << 0); 137 tmp &= ~(0x7 << 0);
200 tmp |= (exynos4210_apll_pms_table[new_index] & 0x7); 138 tmp |= apll_freq_4210[new_index].mps & 0x7;
201 __raw_writel(tmp, EXYNOS4_APLL_CON0); 139 __raw_writel(tmp, EXYNOS4_APLL_CON0);
202 } else { 140 } else {
203 /* Clock Configuration Procedure */ 141 /* Clock Configuration Procedure */
@@ -211,7 +149,7 @@ static void exynos4210_set_frequency(unsigned int old_index,
211 /* 1. Change just s value in apll m,p,s value */ 149 /* 1. Change just s value in apll m,p,s value */
212 tmp = __raw_readl(EXYNOS4_APLL_CON0); 150 tmp = __raw_readl(EXYNOS4_APLL_CON0);
213 tmp &= ~(0x7 << 0); 151 tmp &= ~(0x7 << 0);
214 tmp |= (exynos4210_apll_pms_table[new_index] & 0x7); 152 tmp |= apll_freq_4210[new_index].mps & 0x7;
215 __raw_writel(tmp, EXYNOS4_APLL_CON0); 153 __raw_writel(tmp, EXYNOS4_APLL_CON0);
216 154
217 /* 2. Change the system clock divider values */ 155 /* 2. Change the system clock divider values */
@@ -228,8 +166,6 @@ static void exynos4210_set_frequency(unsigned int old_index,
228 166
229int exynos4210_cpufreq_init(struct exynos_dvfs_info *info) 167int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
230{ 168{
231 int i;
232 unsigned int tmp;
233 unsigned long rate; 169 unsigned long rate;
234 170
235 cpu_clk = clk_get(NULL, "armclk"); 171 cpu_clk = clk_get(NULL, "armclk");
@@ -250,29 +186,8 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
250 if (IS_ERR(mout_apll)) 186 if (IS_ERR(mout_apll))
251 goto err_mout_apll; 187 goto err_mout_apll;
252 188
253 tmp = __raw_readl(EXYNOS4_CLKDIV_CPU);
254
255 for (i = L0; i < CPUFREQ_LEVEL_END; i++) {
256 tmp &= ~(EXYNOS4_CLKDIV_CPU0_CORE_MASK |
257 EXYNOS4_CLKDIV_CPU0_COREM0_MASK |
258 EXYNOS4_CLKDIV_CPU0_COREM1_MASK |
259 EXYNOS4_CLKDIV_CPU0_PERIPH_MASK |
260 EXYNOS4_CLKDIV_CPU0_ATB_MASK |
261 EXYNOS4_CLKDIV_CPU0_PCLKDBG_MASK |
262 EXYNOS4_CLKDIV_CPU0_APLL_MASK);
263
264 tmp |= ((clkdiv_cpu0[i][0] << EXYNOS4_CLKDIV_CPU0_CORE_SHIFT) |
265 (clkdiv_cpu0[i][1] << EXYNOS4_CLKDIV_CPU0_COREM0_SHIFT) |
266 (clkdiv_cpu0[i][2] << EXYNOS4_CLKDIV_CPU0_COREM1_SHIFT) |
267 (clkdiv_cpu0[i][3] << EXYNOS4_CLKDIV_CPU0_PERIPH_SHIFT) |
268 (clkdiv_cpu0[i][4] << EXYNOS4_CLKDIV_CPU0_ATB_SHIFT) |
269 (clkdiv_cpu0[i][5] << EXYNOS4_CLKDIV_CPU0_PCLKDBG_SHIFT) |
270 (clkdiv_cpu0[i][6] << EXYNOS4_CLKDIV_CPU0_APLL_SHIFT));
271
272 exynos4210_clkdiv_table[i].clkdiv = tmp;
273 }
274
275 info->mpll_freq_khz = rate; 189 info->mpll_freq_khz = rate;
190 /* 800Mhz */
276 info->pll_safe_idx = L2; 191 info->pll_safe_idx = L2;
277 info->cpu_clk = cpu_clk; 192 info->cpu_clk = cpu_clk;
278 info->volt_table = exynos4210_volt_table; 193 info->volt_table = exynos4210_volt_table;