aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2005-08-18 17:35:38 -0400
committerDavid S. Miller <davem@davemloft.net>2005-08-18 17:35:38 -0400
commit2cab224d1f6557e7014601f251d6a41982963e6b (patch)
tree24a234e496ba3425c5513adc377cdd77261fe609 /arch/sparc64
parent6be382ea0c767a81be0e7980400b9b18167b3261 (diff)
[SPARC64]: Fix 2 bugs in cpufreq drivers.
1) cpufreq wants frequenceis in KHZ not MHZ 2) provide ->get() method so curfreq node is created Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/us2e_cpufreq.c36
-rw-r--r--arch/sparc64/kernel/us3_cpufreq.c29
2 files changed, 52 insertions, 13 deletions
diff --git a/arch/sparc64/kernel/us2e_cpufreq.c b/arch/sparc64/kernel/us2e_cpufreq.c
index 7aae0a18aabe..686e526bec04 100644
--- a/arch/sparc64/kernel/us2e_cpufreq.c
+++ b/arch/sparc64/kernel/us2e_cpufreq.c
@@ -88,7 +88,6 @@ static void frob_mem_refresh(int cpu_slowing_down,
88{ 88{
89 unsigned long old_refr_count, refr_count, mctrl; 89 unsigned long old_refr_count, refr_count, mctrl;
90 90
91
92 refr_count = (clock_tick * MCTRL0_REFR_INTERVAL); 91 refr_count = (clock_tick * MCTRL0_REFR_INTERVAL);
93 refr_count /= (MCTRL0_REFR_CLKS_P_CNT * divisor * 1000000000UL); 92 refr_count /= (MCTRL0_REFR_CLKS_P_CNT * divisor * 1000000000UL);
94 93
@@ -230,6 +229,25 @@ static unsigned long estar_to_divisor(unsigned long estar)
230 return ret; 229 return ret;
231} 230}
232 231
232static unsigned int us2e_freq_get(unsigned int cpu)
233{
234 cpumask_t cpus_allowed;
235 unsigned long clock_tick, estar;
236
237 if (!cpu_online(cpu))
238 return 0;
239
240 cpus_allowed = current->cpus_allowed;
241 set_cpus_allowed(current, cpumask_of_cpu(cpu));
242
243 clock_tick = sparc64_get_clock_tick(cpu) / 1000;
244 estar = read_hbreg(HBIRD_ESTAR_MODE_ADDR);
245
246 set_cpus_allowed(current, cpus_allowed);
247
248 return clock_tick / estar_to_divisor(estar);
249}
250
233static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index) 251static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index)
234{ 252{
235 unsigned long new_bits, new_freq; 253 unsigned long new_bits, new_freq;
@@ -243,7 +261,7 @@ static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index)
243 cpus_allowed = current->cpus_allowed; 261 cpus_allowed = current->cpus_allowed;
244 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 262 set_cpus_allowed(current, cpumask_of_cpu(cpu));
245 263
246 new_freq = clock_tick = sparc64_get_clock_tick(cpu); 264 new_freq = clock_tick = sparc64_get_clock_tick(cpu) / 1000;
247 new_bits = index_to_estar_mode(index); 265 new_bits = index_to_estar_mode(index);
248 divisor = index_to_divisor(index); 266 divisor = index_to_divisor(index);
249 new_freq /= divisor; 267 new_freq /= divisor;
@@ -258,7 +276,8 @@ static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index)
258 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 276 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
259 277
260 if (old_divisor != divisor) 278 if (old_divisor != divisor)
261 us2e_transition(estar, new_bits, clock_tick, old_divisor, divisor); 279 us2e_transition(estar, new_bits, clock_tick * 1000,
280 old_divisor, divisor);
262 281
263 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 282 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
264 283
@@ -272,10 +291,8 @@ static int us2e_freq_target(struct cpufreq_policy *policy,
272 unsigned int new_index = 0; 291 unsigned int new_index = 0;
273 292
274 if (cpufreq_frequency_table_target(policy, 293 if (cpufreq_frequency_table_target(policy,
275 &us2e_freq_table[policy->cpu].table[0], 294 &us2e_freq_table[policy->cpu].table[0],
276 target_freq, 295 target_freq, relation, &new_index))
277 relation,
278 &new_index))
279 return -EINVAL; 296 return -EINVAL;
280 297
281 us2e_set_cpu_divider_index(policy->cpu, new_index); 298 us2e_set_cpu_divider_index(policy->cpu, new_index);
@@ -292,7 +309,7 @@ static int us2e_freq_verify(struct cpufreq_policy *policy)
292static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) 309static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
293{ 310{
294 unsigned int cpu = policy->cpu; 311 unsigned int cpu = policy->cpu;
295 unsigned long clock_tick = sparc64_get_clock_tick(cpu); 312 unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
296 struct cpufreq_frequency_table *table = 313 struct cpufreq_frequency_table *table =
297 &us2e_freq_table[cpu].table[0]; 314 &us2e_freq_table[cpu].table[0];
298 315
@@ -351,9 +368,10 @@ static int __init us2e_freq_init(void)
351 memset(us2e_freq_table, 0, 368 memset(us2e_freq_table, 0,
352 (NR_CPUS * sizeof(struct us2e_freq_percpu_info))); 369 (NR_CPUS * sizeof(struct us2e_freq_percpu_info)));
353 370
371 driver->init = us2e_freq_cpu_init;
354 driver->verify = us2e_freq_verify; 372 driver->verify = us2e_freq_verify;
355 driver->target = us2e_freq_target; 373 driver->target = us2e_freq_target;
356 driver->init = us2e_freq_cpu_init; 374 driver->get = us2e_freq_get;
357 driver->exit = us2e_freq_cpu_exit; 375 driver->exit = us2e_freq_cpu_exit;
358 driver->owner = THIS_MODULE, 376 driver->owner = THIS_MODULE,
359 strcpy(driver->name, "UltraSPARC-IIe"); 377 strcpy(driver->name, "UltraSPARC-IIe");
diff --git a/arch/sparc64/kernel/us3_cpufreq.c b/arch/sparc64/kernel/us3_cpufreq.c
index 18fe54b8aa55..9080e7cd4bb0 100644
--- a/arch/sparc64/kernel/us3_cpufreq.c
+++ b/arch/sparc64/kernel/us3_cpufreq.c
@@ -56,7 +56,7 @@ static void write_safari_cfg(unsigned long val)
56 56
57static unsigned long get_current_freq(unsigned int cpu, unsigned long safari_cfg) 57static unsigned long get_current_freq(unsigned int cpu, unsigned long safari_cfg)
58{ 58{
59 unsigned long clock_tick = sparc64_get_clock_tick(cpu); 59 unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
60 unsigned long ret; 60 unsigned long ret;
61 61
62 switch (safari_cfg & SAFARI_CFG_DIV_MASK) { 62 switch (safari_cfg & SAFARI_CFG_DIV_MASK) {
@@ -76,6 +76,26 @@ static unsigned long get_current_freq(unsigned int cpu, unsigned long safari_cfg
76 return ret; 76 return ret;
77} 77}
78 78
79static unsigned int us3_freq_get(unsigned int cpu)
80{
81 cpumask_t cpus_allowed;
82 unsigned long reg;
83 unsigned int ret;
84
85 if (!cpu_online(cpu))
86 return 0;
87
88 cpus_allowed = current->cpus_allowed;
89 set_cpus_allowed(current, cpumask_of_cpu(cpu));
90
91 reg = read_safari_cfg();
92 ret = get_current_freq(cpu, reg);
93
94 set_cpus_allowed(current, cpus_allowed);
95
96 return ret;
97}
98
79static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index) 99static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index)
80{ 100{
81 unsigned long new_bits, new_freq, reg; 101 unsigned long new_bits, new_freq, reg;
@@ -88,7 +108,7 @@ static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index)
88 cpus_allowed = current->cpus_allowed; 108 cpus_allowed = current->cpus_allowed;
89 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 109 set_cpus_allowed(current, cpumask_of_cpu(cpu));
90 110
91 new_freq = sparc64_get_clock_tick(cpu); 111 new_freq = sparc64_get_clock_tick(cpu) / 1000;
92 switch (index) { 112 switch (index) {
93 case 0: 113 case 0:
94 new_bits = SAFARI_CFG_DIV_1; 114 new_bits = SAFARI_CFG_DIV_1;
@@ -150,7 +170,7 @@ static int us3_freq_verify(struct cpufreq_policy *policy)
150static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) 170static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
151{ 171{
152 unsigned int cpu = policy->cpu; 172 unsigned int cpu = policy->cpu;
153 unsigned long clock_tick = sparc64_get_clock_tick(cpu); 173 unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
154 struct cpufreq_frequency_table *table = 174 struct cpufreq_frequency_table *table =
155 &us3_freq_table[cpu].table[0]; 175 &us3_freq_table[cpu].table[0];
156 176
@@ -206,9 +226,10 @@ static int __init us3_freq_init(void)
206 memset(us3_freq_table, 0, 226 memset(us3_freq_table, 0,
207 (NR_CPUS * sizeof(struct us3_freq_percpu_info))); 227 (NR_CPUS * sizeof(struct us3_freq_percpu_info)));
208 228
229 driver->init = us3_freq_cpu_init;
209 driver->verify = us3_freq_verify; 230 driver->verify = us3_freq_verify;
210 driver->target = us3_freq_target; 231 driver->target = us3_freq_target;
211 driver->init = us3_freq_cpu_init; 232 driver->get = us3_freq_get;
212 driver->exit = us3_freq_cpu_exit; 233 driver->exit = us3_freq_cpu_exit;
213 driver->owner = THIS_MODULE, 234 driver->owner = THIS_MODULE,
214 strcpy(driver->name, "UltraSPARC-III"); 235 strcpy(driver->name, "UltraSPARC-III");