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

mips: loongsoon2ef: remove private clk api

As platforms are moving to COMMON_CLK in general, loongson2ef
stuck out as something that has a private implementation but
does not actually use it except for setting the frequency of
the CPU itself from the loongson2_cpufreq driver.

Change that driver to call the register setting function directly
and remove the rest of the stub implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Arnd Bergmann and committed by
Thomas Bogendoerfer
c02e9630 5ceb89f8

+8 -164
-49
arch/mips/include/asm/clock.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef __ASM_MIPS_CLOCK_H 3 - #define __ASM_MIPS_CLOCK_H 4 - 5 - #include <linux/kref.h> 6 - #include <linux/list.h> 7 - #include <linux/seq_file.h> 8 - #include <linux/clk.h> 9 - 10 - struct clk; 11 - 12 - struct clk_ops { 13 - void (*init) (struct clk *clk); 14 - void (*enable) (struct clk *clk); 15 - void (*disable) (struct clk *clk); 16 - void (*recalc) (struct clk *clk); 17 - int (*set_rate) (struct clk *clk, unsigned long rate, int algo_id); 18 - long (*round_rate) (struct clk *clk, unsigned long rate); 19 - }; 20 - 21 - struct clk { 22 - struct list_head node; 23 - const char *name; 24 - int id; 25 - struct module *owner; 26 - 27 - struct clk *parent; 28 - struct clk_ops *ops; 29 - 30 - struct kref kref; 31 - 32 - unsigned long rate; 33 - unsigned long flags; 34 - }; 35 - 36 - #define CLK_ALWAYS_ENABLED (1 << 0) 37 - #define CLK_RATE_PROPAGATES (1 << 1) 38 - 39 - int clk_init(void); 40 - 41 - int __clk_enable(struct clk *); 42 - void __clk_disable(struct clk *); 43 - 44 - void clk_recalc_rate(struct clk *); 45 - 46 - int clk_register(struct clk *); 47 - void clk_unregister(struct clk *); 48 - 49 - #endif /* __ASM_MIPS_CLOCK_H */
+1
arch/mips/include/asm/mach-loongson2ef/loongson.h
··· 244 244 #ifdef CONFIG_CPU_SUPPORTS_CPUFREQ 245 245 #include <linux/cpufreq.h> 246 246 extern struct cpufreq_frequency_table loongson2_clockmod_table[]; 247 + extern int loongson2_cpu_set_rate(unsigned long rate_khz); 247 248 #endif 248 249 249 250 /*
-1
arch/mips/loongson2ef/Kconfig
··· 46 46 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER 47 47 select DMA_NONCOHERENT 48 48 select GENERIC_ISA_DMA_SUPPORT_BROKEN 49 - select HAVE_CLK 50 49 select FORCE_PCI 51 50 select I8259 52 51 select IRQ_MIPS_CPU
+3 -95
arch/mips/loongson2ef/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 - #include <linux/clk.h> 10 9 #include <linux/cpufreq.h> 11 10 #include <linux/errno.h> 12 11 #include <linux/export.h> 13 - #include <linux/list.h> 14 - #include <linux/mutex.h> 15 - #include <linux/spinlock.h> 16 12 17 - #include <asm/clock.h> 18 13 #include <asm/mach-loongson2ef/loongson.h> 19 14 20 - static LIST_HEAD(clock_list); 21 - static DEFINE_SPINLOCK(clock_lock); 22 - static DEFINE_MUTEX(clock_list_sem); 23 - 24 - /* Minimum CLK support */ 25 15 enum { 26 16 DC_ZERO, DC_25PT = 2, DC_37PT, DC_50PT, DC_62PT, DC_75PT, 27 17 DC_87PT, DC_DISABLE, DC_RESV ··· 31 41 }; 32 42 EXPORT_SYMBOL_GPL(loongson2_clockmod_table); 33 43 34 - static struct clk cpu_clk = { 35 - .name = "cpu_clk", 36 - .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, 37 - .rate = 800000000, 38 - }; 39 - 40 - struct clk *clk_get(struct device *dev, const char *id) 44 + int loongson2_cpu_set_rate(unsigned long rate_khz) 41 45 { 42 - return &cpu_clk; 43 - } 44 - EXPORT_SYMBOL(clk_get); 45 - 46 - static void propagate_rate(struct clk *clk) 47 - { 48 - struct clk *clkp; 49 - 50 - list_for_each_entry(clkp, &clock_list, node) { 51 - if (likely(clkp->parent != clk)) 52 - continue; 53 - if (likely(clkp->ops && clkp->ops->recalc)) 54 - clkp->ops->recalc(clkp); 55 - if (unlikely(clkp->flags & CLK_RATE_PROPAGATES)) 56 - propagate_rate(clkp); 57 - } 58 - } 59 - 60 - int clk_enable(struct clk *clk) 61 - { 62 - return 0; 63 - } 64 - EXPORT_SYMBOL(clk_enable); 65 - 66 - void clk_disable(struct clk *clk) 67 - { 68 - } 69 - EXPORT_SYMBOL(clk_disable); 70 - 71 - unsigned long clk_get_rate(struct clk *clk) 72 - { 73 - if (!clk) 74 - return 0; 75 - 76 - return (unsigned long)clk->rate; 77 - } 78 - EXPORT_SYMBOL(clk_get_rate); 79 - 80 - void clk_put(struct clk *clk) 81 - { 82 - } 83 - EXPORT_SYMBOL(clk_put); 84 - 85 - int clk_set_rate(struct clk *clk, unsigned long rate) 86 - { 87 - unsigned int rate_khz = rate / 1000; 88 46 struct cpufreq_frequency_table *pos; 89 - int ret = 0; 90 47 int regval; 91 - 92 - if (likely(clk->ops && clk->ops->set_rate)) { 93 - unsigned long flags; 94 - 95 - spin_lock_irqsave(&clock_lock, flags); 96 - ret = clk->ops->set_rate(clk, rate, 0); 97 - spin_unlock_irqrestore(&clock_lock, flags); 98 - } 99 - 100 - if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) 101 - propagate_rate(clk); 102 48 103 49 cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table) 104 50 if (rate_khz == pos->frequency) ··· 42 116 if (rate_khz != pos->frequency) 43 117 return -ENOTSUPP; 44 118 45 - clk->rate = rate; 46 - 47 119 regval = readl(LOONGSON_CHIPCFG); 48 120 regval = (regval & ~0x7) | (pos->driver_data - 1); 49 121 writel(regval, LOONGSON_CHIPCFG); 50 122 51 - return ret; 123 + return 0; 52 124 } 53 - EXPORT_SYMBOL_GPL(clk_set_rate); 54 - 55 - long clk_round_rate(struct clk *clk, unsigned long rate) 56 - { 57 - if (likely(clk->ops && clk->ops->round_rate)) { 58 - unsigned long flags, rounded; 59 - 60 - spin_lock_irqsave(&clock_lock, flags); 61 - rounded = clk->ops->round_rate(clk, rate); 62 - spin_unlock_irqrestore(&clock_lock, flags); 63 - 64 - return rounded; 65 - } 66 - 67 - return rate; 68 - } 69 - EXPORT_SYMBOL_GPL(clk_round_rate); 125 + EXPORT_SYMBOL_GPL(loongson2_cpu_set_rate);
-1
arch/mips/loongson64/smp.c
··· 15 15 #include <linux/kexec.h> 16 16 #include <asm/processor.h> 17 17 #include <asm/time.h> 18 - #include <asm/clock.h> 19 18 #include <asm/tlbflush.h> 20 19 #include <asm/cacheflush.h> 21 20 #include <loongson.h>
+4 -18
drivers/cpufreq/loongson2_cpufreq.c
··· 20 20 #include <linux/delay.h> 21 21 #include <linux/platform_device.h> 22 22 23 - #include <asm/clock.h> 24 23 #include <asm/idle.h> 25 24 26 25 #include <asm/mach-loongson2ef/loongson.h> ··· 57 58 loongson2_clockmod_table[index].driver_data) / 8; 58 59 59 60 /* setting the cpu frequency */ 60 - clk_set_rate(policy->clk, freq * 1000); 61 + loongson2_cpu_set_rate(freq); 61 62 62 63 return 0; 63 64 } 64 65 65 66 static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) 66 67 { 67 - struct clk *cpuclk; 68 68 int i; 69 69 unsigned long rate; 70 70 int ret; 71 71 72 - cpuclk = clk_get(NULL, "cpu_clk"); 73 - if (IS_ERR(cpuclk)) { 74 - pr_err("couldn't get CPU clk\n"); 75 - return PTR_ERR(cpuclk); 76 - } 77 - 78 72 rate = cpu_clock_freq / 1000; 79 - if (!rate) { 80 - clk_put(cpuclk); 73 + if (!rate) 81 74 return -EINVAL; 82 - } 83 75 84 76 /* clock table init */ 85 77 for (i = 2; ··· 78 88 i++) 79 89 loongson2_clockmod_table[i].frequency = (rate * i) / 8; 80 90 81 - ret = clk_set_rate(cpuclk, rate * 1000); 82 - if (ret) { 83 - clk_put(cpuclk); 91 + ret = loongson2_cpu_set_rate(rate); 92 + if (ret) 84 93 return ret; 85 - } 86 94 87 - policy->clk = cpuclk; 88 95 cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0); 89 96 return 0; 90 97 } 91 98 92 99 static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) 93 100 { 94 - clk_put(policy->clk); 95 101 return 0; 96 102 } 97 103