hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/cpufreq/loongson2_cpufreq.c
....@@ -20,10 +20,9 @@
2020 #include <linux/delay.h>
2121 #include <linux/platform_device.h>
2222
23
-#include <asm/clock.h>
2423 #include <asm/idle.h>
2524
26
-#include <asm/mach-loongson64/loongson.h>
25
+#include <asm/mach-loongson2ef/loongson.h>
2726
2827 static uint nowait;
2928
....@@ -58,29 +57,20 @@
5857 loongson2_clockmod_table[index].driver_data) / 8;
5958
6059 /* setting the cpu frequency */
61
- clk_set_rate(policy->clk, freq * 1000);
60
+ loongson2_cpu_set_rate(freq);
6261
6362 return 0;
6463 }
6564
6665 static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
6766 {
68
- struct clk *cpuclk;
6967 int i;
7068 unsigned long rate;
7169 int ret;
7270
73
- cpuclk = clk_get(NULL, "cpu_clk");
74
- if (IS_ERR(cpuclk)) {
75
- pr_err("couldn't get CPU clk\n");
76
- return PTR_ERR(cpuclk);
77
- }
78
-
7971 rate = cpu_clock_freq / 1000;
80
- if (!rate) {
81
- clk_put(cpuclk);
72
+ if (!rate)
8273 return -EINVAL;
83
- }
8474
8575 /* clock table init */
8676 for (i = 2;
....@@ -88,19 +78,16 @@
8878 i++)
8979 loongson2_clockmod_table[i].frequency = (rate * i) / 8;
9080
91
- ret = clk_set_rate(cpuclk, rate * 1000);
92
- if (ret) {
93
- clk_put(cpuclk);
81
+ ret = loongson2_cpu_set_rate(rate);
82
+ if (ret)
9483 return ret;
95
- }
9684
97
- policy->clk = cpuclk;
98
- return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0);
85
+ cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0);
86
+ return 0;
9987 }
10088
10189 static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
10290 {
103
- clk_put(policy->clk);
10491 return 0;
10592 }
10693
....@@ -143,9 +130,11 @@
143130 u32 cpu_freq;
144131
145132 spin_lock_irqsave(&loongson2_wait_lock, flags);
146
- cpu_freq = LOONGSON_CHIPCFG(0);
147
- LOONGSON_CHIPCFG(0) &= ~0x7; /* Put CPU into wait mode */
148
- LOONGSON_CHIPCFG(0) = cpu_freq; /* Restore CPU state */
133
+ cpu_freq = readl(LOONGSON_CHIPCFG);
134
+ /* Put CPU into wait mode */
135
+ writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG);
136
+ /* Restore CPU state */
137
+ writel(cpu_freq, LOONGSON_CHIPCFG);
149138 spin_unlock_irqrestore(&loongson2_wait_lock, flags);
150139 local_irq_enable();
151140 }