Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+33 -51
-11
arch/mips/include/asm/clock.h
··· 50 50 int clk_register(struct clk *); 51 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 53 #endif /* __ASM_MIPS_CLOCK_H */
-1
arch/mips/include/asm/mach-loongson/loongson.h
··· 245 245 246 246 #ifdef CONFIG_CPU_SUPPORTS_CPUFREQ 247 247 #include <linux/cpufreq.h> 248 - extern void loongson2_cpu_wait(void); 249 248 extern struct cpufreq_frequency_table loongson2_clockmod_table[]; 250 249 251 250 /* Chip Config */
+1 -1
arch/mips/kernel/cpufreq/Makefile
··· 2 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
+10 -36
arch/mips/kernel/cpufreq/loongson2_clock.c arch/mips/loongson/lemote-2f/clock.c
··· 6 6 * License. See the file "COPYING" in the main directory of this archive 7 7 * for more details. 8 8 */ 9 - 10 - #include <linux/module.h> 9 + #include <linux/clk.h> 11 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 18 #include <asm/clock.h> 15 - 16 - #include <loongson.h> 19 + #include <asm/mach-loongson/loongson.h> 17 20 18 21 static LIST_HEAD(clock_list); 19 22 static DEFINE_SPINLOCK(clock_lock); ··· 92 89 93 90 int clk_set_rate(struct clk *clk, unsigned long rate) 94 91 { 95 - return clk_set_rate_ex(clk, rate, 0); 96 - } 97 - EXPORT_SYMBOL_GPL(clk_set_rate); 98 - 99 - int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id) 100 - { 101 92 int ret = 0; 102 93 int regval; 103 94 int i; ··· 100 103 unsigned long flags; 101 104 102 105 spin_lock_irqsave(&clock_lock, flags); 103 - ret = clk->ops->set_rate(clk, rate, algo_id); 106 + ret = clk->ops->set_rate(clk, rate, 0); 104 107 spin_unlock_irqrestore(&clock_lock, flags); 105 108 } 106 109 ··· 126 129 127 130 return ret; 128 131 } 129 - EXPORT_SYMBOL_GPL(clk_set_rate_ex); 132 + EXPORT_SYMBOL_GPL(clk_set_rate); 130 133 131 134 long clk_round_rate(struct clk *clk, unsigned long rate) 132 135 { ··· 143 146 return rate; 144 147 } 145 148 EXPORT_SYMBOL_GPL(clk_round_rate); 146 - 147 - /* 148 - * This is the simple version of Loongson-2 wait, Maybe we need do this in 149 - * interrupt disabled content 150 - */ 151 - 152 - DEFINE_SPINLOCK(loongson2_wait_lock); 153 - void loongson2_cpu_wait(void) 154 - { 155 - u32 cpu_freq; 156 - unsigned long flags; 157 - 158 - spin_lock_irqsave(&loongson2_wait_lock, flags); 159 - cpu_freq = LOONGSON_CHIPCFG0; 160 - LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */ 161 - LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */ 162 - spin_unlock_irqrestore(&loongson2_wait_lock, flags); 163 - } 164 - EXPORT_SYMBOL_GPL(loongson2_cpu_wait); 165 - 166 - MODULE_AUTHOR("Yanhua <yanh@lemote.com>"); 167 - MODULE_DESCRIPTION("cpufreq driver for Loongson 2F"); 168 - MODULE_LICENSE("GPL");
+20 -1
arch/mips/kernel/cpufreq/loongson2_cpufreq.c
··· 19 19 20 20 #include <asm/clock.h> 21 21 22 - #include <loongson.h> 22 + #include <asm/mach-loongson/loongson.h> 23 23 24 24 static uint nowait; 25 25 ··· 180 180 }, 181 181 .id_table = platform_device_ids, 182 182 }; 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 + } 183 202 184 203 static int __init cpufreq_init(void) 185 204 {
+1
arch/mips/loongson/Kconfig
··· 41 41 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER 42 42 select DMA_NONCOHERENT 43 43 select GENERIC_ISA_DMA_SUPPORT_BROKEN 44 + select HAVE_CLK 44 45 select HW_HAS_PCI 45 46 select I8259 46 47 select IRQ_CPU
+1 -1
arch/mips/loongson/lemote-2f/Makefile
··· 2 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 8 # Suspend Support