diff options
Diffstat (limited to 'arch/arm/mach-pxa/cpu-pxa.c')
-rw-r--r-- | arch/arm/mach-pxa/cpu-pxa.c | 310 |
1 files changed, 210 insertions, 100 deletions
diff --git a/arch/arm/mach-pxa/cpu-pxa.c b/arch/arm/mach-pxa/cpu-pxa.c index 4b21479332ae..fb9ba1ab2826 100644 --- a/arch/arm/mach-pxa/cpu-pxa.c +++ b/arch/arm/mach-pxa/cpu-pxa.c | |||
@@ -49,125 +49,216 @@ MODULE_PARM_DESC(freq_debug, "Set the debug messages to on=1/off=0"); | |||
49 | #define freq_debug 0 | 49 | #define freq_debug 0 |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | static unsigned int pxa27x_maxfreq; | ||
53 | module_param(pxa27x_maxfreq, uint, 0); | ||
54 | MODULE_PARM_DESC(pxa27x_maxfreq, "Set the pxa27x maxfreq in MHz" | ||
55 | "(typically 624=>pxa270, 416=>pxa271, 520=>pxa272)"); | ||
56 | |||
52 | typedef struct { | 57 | typedef struct { |
53 | unsigned int khz; | 58 | unsigned int khz; |
54 | unsigned int membus; | 59 | unsigned int membus; |
55 | unsigned int cccr; | 60 | unsigned int cccr; |
56 | unsigned int div2; | 61 | unsigned int div2; |
62 | unsigned int cclkcfg; | ||
57 | } pxa_freqs_t; | 63 | } pxa_freqs_t; |
58 | 64 | ||
59 | /* Define the refresh period in mSec for the SDRAM and the number of rows */ | 65 | /* Define the refresh period in mSec for the SDRAM and the number of rows */ |
60 | #define SDRAM_TREF 64 /* standard 64ms SDRAM */ | 66 | #define SDRAM_TREF 64 /* standard 64ms SDRAM */ |
61 | #define SDRAM_ROWS 4096 /* 64MB=8192 32MB=4096 */ | 67 | #define SDRAM_ROWS 4096 /* 64MB=8192 32MB=4096 */ |
62 | #define MDREFR_DRI(x) (((x) * SDRAM_TREF) / (SDRAM_ROWS * 32)) | ||
63 | |||
64 | #define CCLKCFG_TURBO 0x1 | ||
65 | #define CCLKCFG_FCS 0x2 | ||
66 | #define PXA25x_MIN_FREQ 99500 | ||
67 | #define PXA25x_MAX_FREQ 398100 | ||
68 | #define MDREFR_DB2_MASK (MDREFR_K2DB2 | MDREFR_K1DB2) | ||
69 | #define MDREFR_DRI_MASK 0xFFF | ||
70 | 68 | ||
69 | #define CCLKCFG_TURBO 0x1 | ||
70 | #define CCLKCFG_FCS 0x2 | ||
71 | #define CCLKCFG_HALFTURBO 0x4 | ||
72 | #define CCLKCFG_FASTBUS 0x8 | ||
73 | #define MDREFR_DB2_MASK (MDREFR_K2DB2 | MDREFR_K1DB2) | ||
74 | #define MDREFR_DRI_MASK 0xFFF | ||
71 | 75 | ||
76 | /* | ||
77 | * PXA255 definitions | ||
78 | */ | ||
72 | /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */ | 79 | /* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */ |
80 | #define CCLKCFG CCLKCFG_TURBO | CCLKCFG_FCS | ||
81 | |||
73 | static pxa_freqs_t pxa255_run_freqs[] = | 82 | static pxa_freqs_t pxa255_run_freqs[] = |
74 | { | 83 | { |
75 | /* CPU MEMBUS CCCR DIV2*/ | 84 | /* CPU MEMBUS CCCR DIV2 CCLKCFG run turbo PXbus SDRAM */ |
76 | { 99500, 99500, 0x121, 1}, /* run= 99, turbo= 99, PXbus=50, SDRAM=50 */ | 85 | { 99500, 99500, 0x121, 1, CCLKCFG}, /* 99, 99, 50, 50 */ |
77 | {132700, 132700, 0x123, 1}, /* run=133, turbo=133, PXbus=66, SDRAM=66 */ | 86 | {132700, 132700, 0x123, 1, CCLKCFG}, /* 133, 133, 66, 66 */ |
78 | {199100, 99500, 0x141, 0}, /* run=199, turbo=199, PXbus=99, SDRAM=99 */ | 87 | {199100, 99500, 0x141, 0, CCLKCFG}, /* 199, 199, 99, 99 */ |
79 | {265400, 132700, 0x143, 1}, /* run=265, turbo=265, PXbus=133, SDRAM=66 */ | 88 | {265400, 132700, 0x143, 1, CCLKCFG}, /* 265, 265, 133, 66 */ |
80 | {331800, 165900, 0x145, 1}, /* run=331, turbo=331, PXbus=166, SDRAM=83 */ | 89 | {331800, 165900, 0x145, 1, CCLKCFG}, /* 331, 331, 166, 83 */ |
81 | {398100, 99500, 0x161, 0}, /* run=398, turbo=398, PXbus=196, SDRAM=99 */ | 90 | {398100, 99500, 0x161, 0, CCLKCFG}, /* 398, 398, 196, 99 */ |
82 | {0,} | ||
83 | }; | 91 | }; |
84 | #define NUM_RUN_FREQS ARRAY_SIZE(pxa255_run_freqs) | ||
85 | |||
86 | static struct cpufreq_frequency_table pxa255_run_freq_table[NUM_RUN_FREQS+1]; | ||
87 | 92 | ||
88 | /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */ | 93 | /* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */ |
89 | static pxa_freqs_t pxa255_turbo_freqs[] = | 94 | static pxa_freqs_t pxa255_turbo_freqs[] = |
90 | { | 95 | { |
91 | /* CPU MEMBUS CCCR DIV2*/ | 96 | /* CPU MEMBUS CCCR DIV2 CCLKCFG run turbo PXbus SDRAM */ |
92 | { 99500, 99500, 0x121, 1}, /* run=99, turbo= 99, PXbus=50, SDRAM=50 */ | 97 | { 99500, 99500, 0x121, 1, CCLKCFG}, /* 99, 99, 50, 50 */ |
93 | {199100, 99500, 0x221, 0}, /* run=99, turbo=199, PXbus=50, SDRAM=99 */ | 98 | {199100, 99500, 0x221, 0, CCLKCFG}, /* 99, 199, 50, 99 */ |
94 | {298500, 99500, 0x321, 0}, /* run=99, turbo=287, PXbus=50, SDRAM=99 */ | 99 | {298500, 99500, 0x321, 0, CCLKCFG}, /* 99, 287, 50, 99 */ |
95 | {298600, 99500, 0x1c1, 0}, /* run=199, turbo=287, PXbus=99, SDRAM=99 */ | 100 | {298600, 99500, 0x1c1, 0, CCLKCFG}, /* 199, 287, 99, 99 */ |
96 | {398100, 99500, 0x241, 0}, /* run=199, turbo=398, PXbus=99, SDRAM=99 */ | 101 | {398100, 99500, 0x241, 0, CCLKCFG}, /* 199, 398, 99, 99 */ |
97 | {0,} | 102 | }; |
103 | |||
104 | #define NUM_PXA25x_RUN_FREQS ARRAY_SIZE(pxa255_run_freqs) | ||
105 | #define NUM_PXA25x_TURBO_FREQS ARRAY_SIZE(pxa255_turbo_freqs) | ||
106 | |||
107 | static struct cpufreq_frequency_table | ||
108 | pxa255_run_freq_table[NUM_PXA25x_RUN_FREQS+1]; | ||
109 | static struct cpufreq_frequency_table | ||
110 | pxa255_turbo_freq_table[NUM_PXA25x_TURBO_FREQS+1]; | ||
111 | |||
112 | /* | ||
113 | * PXA270 definitions | ||
114 | * | ||
115 | * For the PXA27x: | ||
116 | * Control variables are A, L, 2N for CCCR; B, HT, T for CLKCFG. | ||
117 | * | ||
118 | * A = 0 => memory controller clock from table 3-7, | ||
119 | * A = 1 => memory controller clock = system bus clock | ||
120 | * Run mode frequency = 13 MHz * L | ||
121 | * Turbo mode frequency = 13 MHz * L * N | ||
122 | * System bus frequency = 13 MHz * L / (B + 1) | ||
123 | * | ||
124 | * In CCCR: | ||
125 | * A = 1 | ||
126 | * L = 16 oscillator to run mode ratio | ||
127 | * 2N = 6 2 * (turbo mode to run mode ratio) | ||
128 | * | ||
129 | * In CCLKCFG: | ||
130 | * B = 1 Fast bus mode | ||
131 | * HT = 0 Half-Turbo mode | ||
132 | * T = 1 Turbo mode | ||
133 | * | ||
134 | * For now, just support some of the combinations in table 3-7 of | ||
135 | * PXA27x Processor Family Developer's Manual to simplify frequency | ||
136 | * change sequences. | ||
137 | */ | ||
138 | #define PXA27x_CCCR(A, L, N2) (A << 25 | N2 << 7 | L) | ||
139 | #define CCLKCFG2(B, HT, T) \ | ||
140 | (CCLKCFG_FCS | \ | ||
141 | ((B) ? CCLKCFG_FASTBUS : 0) | \ | ||
142 | ((HT) ? CCLKCFG_HALFTURBO : 0) | \ | ||
143 | ((T) ? CCLKCFG_TURBO : 0)) | ||
144 | |||
145 | static pxa_freqs_t pxa27x_freqs[] = { | ||
146 | {104000, 104000, PXA27x_CCCR(1, 8, 2), 0, CCLKCFG2(1, 0, 1)}, | ||
147 | {156000, 104000, PXA27x_CCCR(1, 8, 6), 0, CCLKCFG2(1, 1, 1)}, | ||
148 | {208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1)}, | ||
149 | {312000, 208000, PXA27x_CCCR(1, 16, 3), 1, CCLKCFG2(1, 0, 1)}, | ||
150 | {416000, 208000, PXA27x_CCCR(1, 16, 4), 1, CCLKCFG2(1, 0, 1)}, | ||
151 | {520000, 208000, PXA27x_CCCR(1, 16, 5), 1, CCLKCFG2(1, 0, 1)}, | ||
152 | {624000, 208000, PXA27x_CCCR(1, 16, 6), 1, CCLKCFG2(1, 0, 1)} | ||
98 | }; | 153 | }; |
99 | #define NUM_TURBO_FREQS ARRAY_SIZE(pxa255_turbo_freqs) | ||
100 | 154 | ||
101 | static struct cpufreq_frequency_table pxa255_turbo_freq_table[NUM_TURBO_FREQS+1]; | 155 | #define NUM_PXA27x_FREQS ARRAY_SIZE(pxa27x_freqs) |
156 | static struct cpufreq_frequency_table | ||
157 | pxa27x_freq_table[NUM_PXA27x_FREQS+1]; | ||
102 | 158 | ||
103 | extern unsigned get_clk_frequency_khz(int info); | 159 | extern unsigned get_clk_frequency_khz(int info); |
104 | 160 | ||
161 | static void find_freq_tables(struct cpufreq_policy *policy, | ||
162 | struct cpufreq_frequency_table **freq_table, | ||
163 | pxa_freqs_t **pxa_freqs) | ||
164 | { | ||
165 | if (cpu_is_pxa25x()) { | ||
166 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | ||
167 | *pxa_freqs = pxa255_run_freqs; | ||
168 | *freq_table = pxa255_run_freq_table; | ||
169 | } else if (policy->policy == CPUFREQ_POLICY_POWERSAVE) { | ||
170 | *pxa_freqs = pxa255_turbo_freqs; | ||
171 | *freq_table = pxa255_turbo_freq_table; | ||
172 | } else { | ||
173 | printk("CPU PXA: Unknown policy found. " | ||
174 | "Using CPUFREQ_POLICY_PERFORMANCE\n"); | ||
175 | *pxa_freqs = pxa255_run_freqs; | ||
176 | *freq_table = pxa255_run_freq_table; | ||
177 | } | ||
178 | } | ||
179 | if (cpu_is_pxa27x()) { | ||
180 | *pxa_freqs = pxa27x_freqs; | ||
181 | *freq_table = pxa27x_freq_table; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | static void pxa27x_guess_max_freq(void) | ||
186 | { | ||
187 | if (!pxa27x_maxfreq) { | ||
188 | pxa27x_maxfreq = 416000; | ||
189 | printk(KERN_INFO "PXA CPU 27x max frequency not defined " | ||
190 | "(pxa27x_maxfreq), assuming pxa271 with %dkHz maxfreq\n", | ||
191 | pxa27x_maxfreq); | ||
192 | } else { | ||
193 | pxa27x_maxfreq *= 1000; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | static u32 mdrefr_dri(unsigned int freq) | ||
198 | { | ||
199 | u32 dri = 0; | ||
200 | |||
201 | if (cpu_is_pxa25x()) | ||
202 | dri = ((freq * SDRAM_TREF) / (SDRAM_ROWS * 32)); | ||
203 | if (cpu_is_pxa27x()) | ||
204 | dri = ((freq * SDRAM_TREF) / (SDRAM_ROWS - 31)) / 32; | ||
205 | return dri; | ||
206 | } | ||
207 | |||
105 | /* find a valid frequency point */ | 208 | /* find a valid frequency point */ |
106 | static int pxa_verify_policy(struct cpufreq_policy *policy) | 209 | static int pxa_verify_policy(struct cpufreq_policy *policy) |
107 | { | 210 | { |
108 | struct cpufreq_frequency_table *pxa_freqs_table; | 211 | struct cpufreq_frequency_table *pxa_freqs_table; |
212 | pxa_freqs_t *pxa_freqs; | ||
109 | int ret; | 213 | int ret; |
110 | 214 | ||
111 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | 215 | find_freq_tables(policy, &pxa_freqs_table, &pxa_freqs); |
112 | pxa_freqs_table = pxa255_run_freq_table; | ||
113 | } else if (policy->policy == CPUFREQ_POLICY_POWERSAVE) { | ||
114 | pxa_freqs_table = pxa255_turbo_freq_table; | ||
115 | } else { | ||
116 | printk("CPU PXA: Unknown policy found. " | ||
117 | "Using CPUFREQ_POLICY_PERFORMANCE\n"); | ||
118 | pxa_freqs_table = pxa255_run_freq_table; | ||
119 | } | ||
120 | |||
121 | ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table); | 216 | ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table); |
122 | 217 | ||
123 | if (freq_debug) | 218 | if (freq_debug) |
124 | pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n", | 219 | pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n", |
125 | policy->min, policy->max); | 220 | policy->min, policy->max); |
126 | 221 | ||
127 | return ret; | 222 | return ret; |
128 | } | 223 | } |
129 | 224 | ||
225 | static unsigned int pxa_cpufreq_get(unsigned int cpu) | ||
226 | { | ||
227 | return get_clk_frequency_khz(0); | ||
228 | } | ||
229 | |||
130 | static int pxa_set_target(struct cpufreq_policy *policy, | 230 | static int pxa_set_target(struct cpufreq_policy *policy, |
131 | unsigned int target_freq, | 231 | unsigned int target_freq, |
132 | unsigned int relation) | 232 | unsigned int relation) |
133 | { | 233 | { |
134 | struct cpufreq_frequency_table *pxa_freqs_table; | 234 | struct cpufreq_frequency_table *pxa_freqs_table; |
135 | pxa_freqs_t *pxa_freq_settings; | 235 | pxa_freqs_t *pxa_freq_settings; |
136 | struct cpufreq_freqs freqs; | 236 | struct cpufreq_freqs freqs; |
137 | unsigned int idx; | 237 | unsigned int idx; |
138 | unsigned long flags; | 238 | unsigned long flags; |
139 | unsigned int unused, preset_mdrefr, postset_mdrefr; | 239 | unsigned int new_freq_cpu, new_freq_mem; |
140 | void *ramstart = phys_to_virt(0xa0000000); | 240 | unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg; |
141 | 241 | ||
142 | /* Get the current policy */ | 242 | /* Get the current policy */ |
143 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | 243 | find_freq_tables(policy, &pxa_freqs_table, &pxa_freq_settings); |
144 | pxa_freq_settings = pxa255_run_freqs; | ||
145 | pxa_freqs_table = pxa255_run_freq_table; | ||
146 | } else if (policy->policy == CPUFREQ_POLICY_POWERSAVE) { | ||
147 | pxa_freq_settings = pxa255_turbo_freqs; | ||
148 | pxa_freqs_table = pxa255_turbo_freq_table; | ||
149 | } else { | ||
150 | printk("CPU PXA: Unknown policy found. " | ||
151 | "Using CPUFREQ_POLICY_PERFORMANCE\n"); | ||
152 | pxa_freq_settings = pxa255_run_freqs; | ||
153 | pxa_freqs_table = pxa255_run_freq_table; | ||
154 | } | ||
155 | 244 | ||
156 | /* Lookup the next frequency */ | 245 | /* Lookup the next frequency */ |
157 | if (cpufreq_frequency_table_target(policy, pxa_freqs_table, | 246 | if (cpufreq_frequency_table_target(policy, pxa_freqs_table, |
158 | target_freq, relation, &idx)) { | 247 | target_freq, relation, &idx)) { |
159 | return -EINVAL; | 248 | return -EINVAL; |
160 | } | 249 | } |
161 | 250 | ||
251 | new_freq_cpu = pxa_freq_settings[idx].khz; | ||
252 | new_freq_mem = pxa_freq_settings[idx].membus; | ||
162 | freqs.old = policy->cur; | 253 | freqs.old = policy->cur; |
163 | freqs.new = pxa_freq_settings[idx].khz; | 254 | freqs.new = new_freq_cpu; |
164 | freqs.cpu = policy->cpu; | 255 | freqs.cpu = policy->cpu; |
165 | 256 | ||
166 | if (freq_debug) | 257 | if (freq_debug) |
167 | pr_debug(KERN_INFO "Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n", | 258 | pr_debug(KERN_INFO "Changing CPU frequency to %d Mhz, " |
168 | freqs.new / 1000, (pxa_freq_settings[idx].div2) ? | 259 | "(SDRAM %d Mhz)\n", |
169 | (pxa_freq_settings[idx].membus / 2000) : | 260 | freqs.new / 1000, (pxa_freq_settings[idx].div2) ? |
170 | (pxa_freq_settings[idx].membus / 1000)); | 261 | (new_freq_mem / 2000) : (new_freq_mem / 1000)); |
171 | 262 | ||
172 | /* | 263 | /* |
173 | * Tell everyone what we're about to do... | 264 | * Tell everyone what we're about to do... |
@@ -177,16 +268,16 @@ static int pxa_set_target(struct cpufreq_policy *policy, | |||
177 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 268 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
178 | 269 | ||
179 | /* Calculate the next MDREFR. If we're slowing down the SDRAM clock | 270 | /* Calculate the next MDREFR. If we're slowing down the SDRAM clock |
180 | * we need to preset the smaller DRI before the change. If we're speeding | 271 | * we need to preset the smaller DRI before the change. If we're |
181 | * up we need to set the larger DRI value after the change. | 272 | * speeding up we need to set the larger DRI value after the change. |
182 | */ | 273 | */ |
183 | preset_mdrefr = postset_mdrefr = MDREFR; | 274 | preset_mdrefr = postset_mdrefr = MDREFR; |
184 | if ((MDREFR & MDREFR_DRI_MASK) > MDREFR_DRI(pxa_freq_settings[idx].membus)) { | 275 | if ((MDREFR & MDREFR_DRI_MASK) > mdrefr_dri(new_freq_mem)) { |
185 | preset_mdrefr = (preset_mdrefr & ~MDREFR_DRI_MASK) | | 276 | preset_mdrefr = (preset_mdrefr & ~MDREFR_DRI_MASK); |
186 | MDREFR_DRI(pxa_freq_settings[idx].membus); | 277 | preset_mdrefr |= mdrefr_dri(new_freq_mem); |
187 | } | 278 | } |
188 | postset_mdrefr = (postset_mdrefr & ~MDREFR_DRI_MASK) | | 279 | postset_mdrefr = |
189 | MDREFR_DRI(pxa_freq_settings[idx].membus); | 280 | (postset_mdrefr & ~MDREFR_DRI_MASK) | mdrefr_dri(new_freq_mem); |
190 | 281 | ||
191 | /* If we're dividing the memory clock by two for the SDRAM clock, this | 282 | /* If we're dividing the memory clock by two for the SDRAM clock, this |
192 | * must be set prior to the change. Clearing the divide must be done | 283 | * must be set prior to the change. Clearing the divide must be done |
@@ -201,26 +292,27 @@ static int pxa_set_target(struct cpufreq_policy *policy, | |||
201 | 292 | ||
202 | local_irq_save(flags); | 293 | local_irq_save(flags); |
203 | 294 | ||
204 | /* Set new the CCCR */ | 295 | /* Set new the CCCR and prepare CCLKCFG */ |
205 | CCCR = pxa_freq_settings[idx].cccr; | 296 | CCCR = pxa_freq_settings[idx].cccr; |
297 | cclkcfg = pxa_freq_settings[idx].cclkcfg; | ||
206 | 298 | ||
207 | asm volatile(" \n\ | 299 | asm volatile(" \n\ |
208 | ldr r4, [%1] /* load MDREFR */ \n\ | 300 | ldr r4, [%1] /* load MDREFR */ \n\ |
209 | b 2f \n\ | 301 | b 2f \n\ |
210 | .align 5 \n\ | 302 | .align 5 \n\ |
211 | 1: \n\ | 303 | 1: \n\ |
212 | str %4, [%1] /* preset the MDREFR */ \n\ | 304 | str %3, [%1] /* preset the MDREFR */ \n\ |
213 | mcr p14, 0, %2, c6, c0, 0 /* set CCLKCFG[FCS] */ \n\ | 305 | mcr p14, 0, %2, c6, c0, 0 /* set CCLKCFG[FCS] */ \n\ |
214 | str %5, [%1] /* postset the MDREFR */ \n\ | 306 | str %4, [%1] /* postset the MDREFR */ \n\ |
215 | \n\ | 307 | \n\ |
216 | b 3f \n\ | 308 | b 3f \n\ |
217 | 2: b 1b \n\ | 309 | 2: b 1b \n\ |
218 | 3: nop \n\ | 310 | 3: nop \n\ |
219 | " | 311 | " |
220 | : "=&r" (unused) | 312 | : "=&r" (unused) |
221 | : "r" (&MDREFR), "r" (CCLKCFG_TURBO|CCLKCFG_FCS), "r" (ramstart), | 313 | : "r" (&MDREFR), "r" (cclkcfg), |
222 | "r" (preset_mdrefr), "r" (postset_mdrefr) | 314 | "r" (preset_mdrefr), "r" (postset_mdrefr) |
223 | : "r4", "r5"); | 315 | : "r4", "r5"); |
224 | local_irq_restore(flags); | 316 | local_irq_restore(flags); |
225 | 317 | ||
226 | /* | 318 | /* |
@@ -233,38 +325,57 @@ static int pxa_set_target(struct cpufreq_policy *policy, | |||
233 | return 0; | 325 | return 0; |
234 | } | 326 | } |
235 | 327 | ||
236 | static unsigned int pxa_cpufreq_get(unsigned int cpu) | 328 | static __init int pxa_cpufreq_init(struct cpufreq_policy *policy) |
237 | { | ||
238 | return get_clk_frequency_khz(0); | ||
239 | } | ||
240 | |||
241 | static int pxa_cpufreq_init(struct cpufreq_policy *policy) | ||
242 | { | 329 | { |
243 | int i; | 330 | int i; |
331 | unsigned int freq; | ||
332 | |||
333 | /* try to guess pxa27x cpu */ | ||
334 | if (cpu_is_pxa27x()) | ||
335 | pxa27x_guess_max_freq(); | ||
244 | 336 | ||
245 | /* set default policy and cpuinfo */ | 337 | /* set default policy and cpuinfo */ |
246 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | 338 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; |
247 | policy->policy = CPUFREQ_POLICY_PERFORMANCE; | 339 | if (cpu_is_pxa25x()) |
248 | policy->cpuinfo.max_freq = PXA25x_MAX_FREQ; | 340 | policy->policy = CPUFREQ_POLICY_PERFORMANCE; |
249 | policy->cpuinfo.min_freq = PXA25x_MIN_FREQ; | ||
250 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ | 341 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ |
251 | policy->cur = get_clk_frequency_khz(0); /* current freq */ | 342 | policy->cur = get_clk_frequency_khz(0); /* current freq */ |
252 | policy->min = policy->max = policy->cur; | 343 | policy->min = policy->max = policy->cur; |
253 | 344 | ||
254 | /* Generate the run cpufreq_frequency_table struct */ | 345 | /* Generate pxa25x the run cpufreq_frequency_table struct */ |
255 | for (i = 0; i < NUM_RUN_FREQS; i++) { | 346 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { |
256 | pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; | 347 | pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; |
257 | pxa255_run_freq_table[i].index = i; | 348 | pxa255_run_freq_table[i].index = i; |
258 | } | 349 | } |
259 | |||
260 | pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; | 350 | pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; |
261 | /* Generate the turbo cpufreq_frequency_table struct */ | 351 | |
262 | for (i = 0; i < NUM_TURBO_FREQS; i++) { | 352 | /* Generate pxa25x the turbo cpufreq_frequency_table struct */ |
263 | pxa255_turbo_freq_table[i].frequency = pxa255_turbo_freqs[i].khz; | 353 | for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) { |
354 | pxa255_turbo_freq_table[i].frequency = | ||
355 | pxa255_turbo_freqs[i].khz; | ||
264 | pxa255_turbo_freq_table[i].index = i; | 356 | pxa255_turbo_freq_table[i].index = i; |
265 | } | 357 | } |
266 | pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; | 358 | pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; |
267 | 359 | ||
360 | /* Generate the pxa27x cpufreq_frequency_table struct */ | ||
361 | for (i = 0; i < NUM_PXA27x_FREQS; i++) { | ||
362 | freq = pxa27x_freqs[i].khz; | ||
363 | if (freq > pxa27x_maxfreq) | ||
364 | break; | ||
365 | pxa27x_freq_table[i].frequency = freq; | ||
366 | pxa27x_freq_table[i].index = i; | ||
367 | } | ||
368 | pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END; | ||
369 | |||
370 | /* | ||
371 | * Set the policy's minimum and maximum frequencies from the tables | ||
372 | * just constructed. This sets cpuinfo.mxx_freq, min and max. | ||
373 | */ | ||
374 | if (cpu_is_pxa25x()) | ||
375 | cpufreq_frequency_table_cpuinfo(policy, pxa255_run_freq_table); | ||
376 | else if (cpu_is_pxa27x()) | ||
377 | cpufreq_frequency_table_cpuinfo(policy, pxa27x_freq_table); | ||
378 | |||
268 | printk(KERN_INFO "PXA CPU frequency change support initialized\n"); | 379 | printk(KERN_INFO "PXA CPU frequency change support initialized\n"); |
269 | 380 | ||
270 | return 0; | 381 | return 0; |
@@ -275,26 +386,25 @@ static struct cpufreq_driver pxa_cpufreq_driver = { | |||
275 | .target = pxa_set_target, | 386 | .target = pxa_set_target, |
276 | .init = pxa_cpufreq_init, | 387 | .init = pxa_cpufreq_init, |
277 | .get = pxa_cpufreq_get, | 388 | .get = pxa_cpufreq_get, |
278 | .name = "PXA25x", | 389 | .name = "PXA2xx", |
279 | }; | 390 | }; |
280 | 391 | ||
281 | static int __init pxa_cpu_init(void) | 392 | static int __init pxa_cpu_init(void) |
282 | { | 393 | { |
283 | int ret = -ENODEV; | 394 | int ret = -ENODEV; |
284 | if (cpu_is_pxa25x()) | 395 | if (cpu_is_pxa25x() || cpu_is_pxa27x()) |
285 | ret = cpufreq_register_driver(&pxa_cpufreq_driver); | 396 | ret = cpufreq_register_driver(&pxa_cpufreq_driver); |
286 | return ret; | 397 | return ret; |
287 | } | 398 | } |
288 | 399 | ||
289 | static void __exit pxa_cpu_exit(void) | 400 | static void __exit pxa_cpu_exit(void) |
290 | { | 401 | { |
291 | if (cpu_is_pxa25x()) | 402 | cpufreq_unregister_driver(&pxa_cpufreq_driver); |
292 | cpufreq_unregister_driver(&pxa_cpufreq_driver); | ||
293 | } | 403 | } |
294 | 404 | ||
295 | 405 | ||
296 | MODULE_AUTHOR ("Intrinsyc Software Inc."); | 406 | MODULE_AUTHOR("Intrinsyc Software Inc."); |
297 | MODULE_DESCRIPTION ("CPU frequency changing driver for the PXA architecture"); | 407 | MODULE_DESCRIPTION("CPU frequency changing driver for the PXA architecture"); |
298 | MODULE_LICENSE("GPL"); | 408 | MODULE_LICENSE("GPL"); |
299 | module_init(pxa_cpu_init); | 409 | module_init(pxa_cpu_init); |
300 | module_exit(pxa_cpu_exit); | 410 | module_exit(pxa_cpu_exit); |