diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2012-08-01 11:15:32 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-08-01 12:10:06 -0400 |
commit | 95cf1468f712df516cc471adcd1c861df4e3d371 (patch) | |
tree | 36aa730653e3fe6b114d57e9b00374393d472533 | |
parent | 4b00951f6f2fd335f063e553b474fe4648b3307d (diff) |
MIPS: Loongson 2: Sort out clock managment.
For unexplainable reasons the Loongson 2 clock API was implemented in a
module so fixing this involved shifting large amounts of code around.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/clock.h | 11 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-loongson/loongson.h | 1 | ||||
-rw-r--r-- | arch/mips/kernel/cpufreq/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/kernel/cpufreq/loongson2_cpufreq.c | 21 | ||||
-rw-r--r-- | arch/mips/loongson/Kconfig | 1 | ||||
-rw-r--r-- | arch/mips/loongson/lemote-2f/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/loongson/lemote-2f/clock.c (renamed from arch/mips/kernel/cpufreq/loongson2_clock.c) | 46 |
7 files changed, 33 insertions, 51 deletions
diff --git a/arch/mips/include/asm/clock.h b/arch/mips/include/asm/clock.h index 83894aa7932c..c9456e7a7283 100644 --- a/arch/mips/include/asm/clock.h +++ b/arch/mips/include/asm/clock.h | |||
@@ -50,15 +50,4 @@ void clk_recalc_rate(struct clk *); | |||
50 | int clk_register(struct clk *); | 50 | int clk_register(struct clk *); |
51 | void clk_unregister(struct clk *); | 51 | void clk_unregister(struct clk *); |
52 | 52 | ||
53 | /* the exported API, in addition to clk_set_rate */ | ||
54 | /** | ||
55 | * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter | ||
56 | * @clk: clock source | ||
57 | * @rate: desired clock rate in Hz | ||
58 | * @algo_id: algorithm id to be passed down to ops->set_rate | ||
59 | * | ||
60 | * Returns success (0) or negative errno. | ||
61 | */ | ||
62 | int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id); | ||
63 | |||
64 | #endif /* __ASM_MIPS_CLOCK_H */ | 53 | #endif /* __ASM_MIPS_CLOCK_H */ |
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h index 06367c37e1b2..5222a007bc21 100644 --- a/arch/mips/include/asm/mach-loongson/loongson.h +++ b/arch/mips/include/asm/mach-loongson/loongson.h | |||
@@ -245,7 +245,6 @@ static inline void do_perfcnt_IRQ(void) | |||
245 | 245 | ||
246 | #ifdef CONFIG_CPU_SUPPORTS_CPUFREQ | 246 | #ifdef CONFIG_CPU_SUPPORTS_CPUFREQ |
247 | #include <linux/cpufreq.h> | 247 | #include <linux/cpufreq.h> |
248 | extern void loongson2_cpu_wait(void); | ||
249 | extern struct cpufreq_frequency_table loongson2_clockmod_table[]; | 248 | extern struct cpufreq_frequency_table loongson2_clockmod_table[]; |
250 | 249 | ||
251 | /* Chip Config */ | 250 | /* Chip Config */ |
diff --git a/arch/mips/kernel/cpufreq/Makefile b/arch/mips/kernel/cpufreq/Makefile index c3479a432efe..05a5715ee38c 100644 --- a/arch/mips/kernel/cpufreq/Makefile +++ b/arch/mips/kernel/cpufreq/Makefile | |||
@@ -2,4 +2,4 @@ | |||
2 | # Makefile for the Linux/MIPS cpufreq. | 2 | # Makefile for the Linux/MIPS cpufreq. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o loongson2_clock.o | 5 | obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o |
diff --git a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c index ae5db206347c..e7c98e2b78b6 100644 --- a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c +++ b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include <asm/clock.h> | 20 | #include <asm/clock.h> |
21 | 21 | ||
22 | #include <loongson.h> | 22 | #include <asm/mach-loongson/loongson.h> |
23 | 23 | ||
24 | static uint nowait; | 24 | static uint nowait; |
25 | 25 | ||
@@ -181,6 +181,25 @@ static struct platform_driver platform_driver = { | |||
181 | .id_table = platform_device_ids, | 181 | .id_table = platform_device_ids, |
182 | }; | 182 | }; |
183 | 183 | ||
184 | /* | ||
185 | * This is the simple version of Loongson-2 wait, Maybe we need do this in | ||
186 | * interrupt disabled context. | ||
187 | */ | ||
188 | |||
189 | static DEFINE_SPINLOCK(loongson2_wait_lock); | ||
190 | |||
191 | static void loongson2_cpu_wait(void) | ||
192 | { | ||
193 | unsigned long flags; | ||
194 | u32 cpu_freq; | ||
195 | |||
196 | spin_lock_irqsave(&loongson2_wait_lock, flags); | ||
197 | cpu_freq = LOONGSON_CHIPCFG0; | ||
198 | LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */ | ||
199 | LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */ | ||
200 | spin_unlock_irqrestore(&loongson2_wait_lock, flags); | ||
201 | } | ||
202 | |||
184 | static int __init cpufreq_init(void) | 203 | static int __init cpufreq_init(void) |
185 | { | 204 | { |
186 | int ret; | 205 | int ret; |
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig index aca93eed8779..263beb9322a8 100644 --- a/arch/mips/loongson/Kconfig +++ b/arch/mips/loongson/Kconfig | |||
@@ -41,6 +41,7 @@ config LEMOTE_MACH2F | |||
41 | select CSRC_R4K if ! MIPS_EXTERNAL_TIMER | 41 | select CSRC_R4K if ! MIPS_EXTERNAL_TIMER |
42 | select DMA_NONCOHERENT | 42 | select DMA_NONCOHERENT |
43 | select GENERIC_ISA_DMA_SUPPORT_BROKEN | 43 | select GENERIC_ISA_DMA_SUPPORT_BROKEN |
44 | select HAVE_CLK | ||
44 | select HW_HAS_PCI | 45 | select HW_HAS_PCI |
45 | select I8259 | 46 | select I8259 |
46 | select IRQ_CPU | 47 | select IRQ_CPU |
diff --git a/arch/mips/loongson/lemote-2f/Makefile b/arch/mips/loongson/lemote-2f/Makefile index 8699a53f0477..4f9eaa328a16 100644 --- a/arch/mips/loongson/lemote-2f/Makefile +++ b/arch/mips/loongson/lemote-2f/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for lemote loongson2f family machines | 2 | # Makefile for lemote loongson2f family machines |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += machtype.o irq.o reset.o ec_kb3310b.o | 5 | obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o |
6 | 6 | ||
7 | # | 7 | # |
8 | # Suspend Support | 8 | # Suspend Support |
diff --git a/arch/mips/kernel/cpufreq/loongson2_clock.c b/arch/mips/loongson/lemote-2f/clock.c index 5426779d9fdb..bc739d4bab2e 100644 --- a/arch/mips/kernel/cpufreq/loongson2_clock.c +++ b/arch/mips/loongson/lemote-2f/clock.c | |||
@@ -6,14 +6,17 @@ | |||
6 | * License. See the file "COPYING" in the main directory of this archive | 6 | * License. See the file "COPYING" in the main directory of this archive |
7 | * for more details. | 7 | * for more details. |
8 | */ | 8 | */ |
9 | 9 | #include <linux/clk.h> | |
10 | #include <linux/module.h> | ||
11 | #include <linux/cpufreq.h> | 10 | #include <linux/cpufreq.h> |
12 | #include <linux/platform_device.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/export.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/list.h> | ||
15 | #include <linux/mutex.h> | ||
16 | #include <linux/spinlock.h> | ||
13 | 17 | ||
14 | #include <asm/clock.h> | 18 | #include <asm/clock.h> |
15 | 19 | #include <asm/mach-loongson/loongson.h> | |
16 | #include <loongson.h> | ||
17 | 20 | ||
18 | static LIST_HEAD(clock_list); | 21 | static LIST_HEAD(clock_list); |
19 | static DEFINE_SPINLOCK(clock_lock); | 22 | static DEFINE_SPINLOCK(clock_lock); |
@@ -89,12 +92,6 @@ EXPORT_SYMBOL(clk_put); | |||
89 | 92 | ||
90 | int clk_set_rate(struct clk *clk, unsigned long rate) | 93 | int clk_set_rate(struct clk *clk, unsigned long rate) |
91 | { | 94 | { |
92 | return clk_set_rate_ex(clk, rate, 0); | ||
93 | } | ||
94 | EXPORT_SYMBOL_GPL(clk_set_rate); | ||
95 | |||
96 | int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id) | ||
97 | { | ||
98 | int ret = 0; | 95 | int ret = 0; |
99 | int regval; | 96 | int regval; |
100 | int i; | 97 | int i; |
@@ -103,7 +100,7 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id) | |||
103 | unsigned long flags; | 100 | unsigned long flags; |
104 | 101 | ||
105 | spin_lock_irqsave(&clock_lock, flags); | 102 | spin_lock_irqsave(&clock_lock, flags); |
106 | ret = clk->ops->set_rate(clk, rate, algo_id); | 103 | ret = clk->ops->set_rate(clk, rate, 0); |
107 | spin_unlock_irqrestore(&clock_lock, flags); | 104 | spin_unlock_irqrestore(&clock_lock, flags); |
108 | } | 105 | } |
109 | 106 | ||
@@ -129,7 +126,7 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id) | |||
129 | 126 | ||
130 | return ret; | 127 | return ret; |
131 | } | 128 | } |
132 | EXPORT_SYMBOL_GPL(clk_set_rate_ex); | 129 | EXPORT_SYMBOL_GPL(clk_set_rate); |
133 | 130 | ||
134 | long clk_round_rate(struct clk *clk, unsigned long rate) | 131 | long clk_round_rate(struct clk *clk, unsigned long rate) |
135 | { | 132 | { |
@@ -146,26 +143,3 @@ long clk_round_rate(struct clk *clk, unsigned long rate) | |||
146 | return rate; | 143 | return rate; |
147 | } | 144 | } |
148 | EXPORT_SYMBOL_GPL(clk_round_rate); | 145 | EXPORT_SYMBOL_GPL(clk_round_rate); |
149 | |||
150 | /* | ||
151 | * This is the simple version of Loongson-2 wait, Maybe we need do this in | ||
152 | * interrupt disabled content | ||
153 | */ | ||
154 | |||
155 | DEFINE_SPINLOCK(loongson2_wait_lock); | ||
156 | void loongson2_cpu_wait(void) | ||
157 | { | ||
158 | u32 cpu_freq; | ||
159 | unsigned long flags; | ||
160 | |||
161 | spin_lock_irqsave(&loongson2_wait_lock, flags); | ||
162 | cpu_freq = LOONGSON_CHIPCFG0; | ||
163 | LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */ | ||
164 | LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */ | ||
165 | spin_unlock_irqrestore(&loongson2_wait_lock, flags); | ||
166 | } | ||
167 | EXPORT_SYMBOL_GPL(loongson2_cpu_wait); | ||
168 | |||
169 | MODULE_AUTHOR("Yanhua <yanh@lemote.com>"); | ||
170 | MODULE_DESCRIPTION("cpufreq driver for Loongson 2F"); | ||
171 | MODULE_LICENSE("GPL"); | ||