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

Merge branch 'sh/clkfwk'

+1234 -914
+7
arch/sh/Kconfig
··· 513 513 This is necessary for determining the reference clock value on 514 514 platforms lacking an RTC. 515 515 516 + config SH_CLK_CPG 517 + def_bool y 518 + 519 + config SH_CLK_CPG_LEGACY 520 + depends on SH_CLK_CPG 521 + def_bool y if !CPU_SUBTYPE_SH7785 522 + 516 523 config SH_CLK_MD 517 524 int "CPU Mode Pin Setting" 518 525 depends on CPU_SH2
+20 -2
arch/sh/boards/board-sh7785lcr.c
··· 2 2 * Renesas Technology Corp. R0P7785LC0011RL Support. 3 3 * 4 4 * Copyright (C) 2008 Yoshihiro Shimoda 5 + * Copyright (C) 2009 Paul Mundt 5 6 * 6 7 * This file is subject to the terms and conditions of the GNU General Public 7 8 * License. See the file "COPYING" in the main directory of this archive 8 9 * for more details. 9 10 */ 10 - 11 11 #include <linux/init.h> 12 12 #include <linux/platform_device.h> 13 13 #include <linux/sm501.h> ··· 19 19 #include <linux/i2c-pca-platform.h> 20 20 #include <linux/i2c-algo-pca.h> 21 21 #include <linux/irq.h> 22 - #include <asm/heartbeat.h> 22 + #include <linux/clk.h> 23 + #include <linux/errno.h> 23 24 #include <mach/sh7785lcr.h> 25 + #include <asm/heartbeat.h> 26 + #include <asm/clock.h> 24 27 25 28 /* 26 29 * NOTE: This board has 2 physical memory maps. ··· 276 273 plat_irq_setup_pins(IRQ_MODE_IRQ3210); 277 274 } 278 275 276 + static int sh7785lcr_clk_init(void) 277 + { 278 + struct clk *clk; 279 + int ret; 280 + 281 + clk = clk_get(NULL, "extal"); 282 + if (!clk || IS_ERR(clk)) 283 + return PTR_ERR(clk); 284 + ret = clk_set_rate(clk, 33333333); 285 + clk_put(clk); 286 + 287 + return ret; 288 + } 289 + 279 290 static void sh7785lcr_power_off(void) 280 291 { 281 292 unsigned char *p; ··· 326 309 static struct sh_machine_vector mv_sh7785lcr __initmv = { 327 310 .mv_name = "SH7785LCR", 328 311 .mv_setup = sh7785lcr_setup, 312 + .mv_clk_init = sh7785lcr_clk_init, 329 313 .mv_init_irq = init_sh7785lcr_IRQ, 330 314 }; 331 315
+45 -24
arch/sh/include/asm/clock.h
··· 10 10 11 11 struct clk_ops { 12 12 void (*init)(struct clk *clk); 13 - void (*enable)(struct clk *clk); 13 + int (*enable)(struct clk *clk); 14 14 void (*disable)(struct clk *clk); 15 - void (*recalc)(struct clk *clk); 15 + unsigned long (*recalc)(struct clk *clk); 16 16 int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); 17 17 int (*set_parent)(struct clk *clk, struct clk *parent); 18 18 long (*round_rate)(struct clk *clk, unsigned long rate); ··· 27 27 struct clk *parent; 28 28 struct clk_ops *ops; 29 29 30 + struct list_head children; 31 + struct list_head sibling; /* node for children */ 32 + 30 33 int usecount; 31 34 32 35 unsigned long rate; 33 36 unsigned long flags; 37 + 38 + void __iomem *enable_reg; 39 + unsigned int enable_bit; 40 + 34 41 unsigned long arch_flags; 42 + void *priv; 43 + struct dentry *dentry; 35 44 }; 36 45 37 - #define CLK_ALWAYS_ENABLED (1 << 0) 38 - #define CLK_RATE_PROPAGATES (1 << 1) 39 - #define CLK_NEEDS_INIT (1 << 2) 46 + struct clk_lookup { 47 + struct list_head node; 48 + const char *dev_id; 49 + const char *con_id; 50 + struct clk *clk; 51 + }; 52 + 53 + #define CLK_ENABLE_ON_INIT (1 << 0) 40 54 41 55 /* Should be defined by processor-specific code */ 42 - void arch_init_clk_ops(struct clk_ops **, int type); 56 + void __deprecated arch_init_clk_ops(struct clk_ops **, int type); 43 57 int __init arch_clk_init(void); 44 58 45 59 /* arch/sh/kernel/cpu/clock.c */ 46 60 int clk_init(void); 47 - 48 - void clk_recalc_rate(struct clk *); 49 - 61 + unsigned long followparent_recalc(struct clk *); 62 + void recalculate_root_clocks(void); 63 + void propagate_rate(struct clk *); 64 + int clk_reparent(struct clk *child, struct clk *parent); 50 65 int clk_register(struct clk *); 51 66 void clk_unregister(struct clk *); 52 67 53 - static inline int clk_always_enable(const char *id) 54 - { 55 - struct clk *clk; 56 - int ret; 57 - 58 - clk = clk_get(NULL, id); 59 - if (IS_ERR(clk)) 60 - return PTR_ERR(clk); 61 - 62 - ret = clk_enable(clk); 63 - if (ret) 64 - clk_put(clk); 65 - 66 - return ret; 67 - } 68 + /* arch/sh/kernel/cpu/clock-cpg.c */ 69 + int __init __deprecated cpg_clk_init(void); 68 70 69 71 /* the exported API, in addition to clk_set_rate */ 70 72 /** ··· 98 96 99 97 IP_N1, 100 98 }; 99 + 100 + struct clk_div_mult_table { 101 + unsigned int *divisors; 102 + unsigned int nr_divisors; 103 + unsigned int *multipliers; 104 + unsigned int nr_multipliers; 105 + }; 106 + 107 + struct cpufreq_frequency_table; 108 + void clk_rate_table_build(struct clk *clk, 109 + struct cpufreq_frequency_table *freq_table, 110 + int nr_freqs, 111 + struct clk_div_mult_table *src_table, 112 + unsigned long *bitmap); 113 + 114 + long clk_rate_table_round(struct clk *clk, 115 + struct cpufreq_frequency_table *freq_table, 116 + unsigned long rate); 117 + 101 118 #endif /* __ASM_SH_CLOCK_H */
+2
arch/sh/include/asm/machvec.h
··· 46 46 47 47 void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size); 48 48 void (*mv_ioport_unmap)(void __iomem *); 49 + 50 + int (*mv_clk_init)(void); 49 51 }; 50 52 51 53 extern struct sh_machine_vector sh_mv;
+1
arch/sh/kernel/cpu/Makefile
··· 17 17 18 18 obj-$(CONFIG_UBC_WAKEUP) += ubc.o 19 19 obj-$(CONFIG_SH_ADC) += adc.o 20 + obj-$(CONFIG_SH_CLK_CPG) += clock-cpg.o 20 21 21 22 obj-y += irq/ init.o clock.o
+62
arch/sh/kernel/cpu/clock-cpg.c
··· 1 + #include <linux/clk.h> 2 + #include <linux/compiler.h> 3 + #include <asm/clock.h> 4 + 5 + #ifdef CONFIG_SH_CLK_CPG_LEGACY 6 + static struct clk master_clk = { 7 + .name = "master_clk", 8 + .flags = CLK_ENABLE_ON_INIT, 9 + .rate = CONFIG_SH_PCLK_FREQ, 10 + }; 11 + 12 + static struct clk peripheral_clk = { 13 + .name = "peripheral_clk", 14 + .parent = &master_clk, 15 + .flags = CLK_ENABLE_ON_INIT, 16 + }; 17 + 18 + static struct clk bus_clk = { 19 + .name = "bus_clk", 20 + .parent = &master_clk, 21 + .flags = CLK_ENABLE_ON_INIT, 22 + }; 23 + 24 + static struct clk cpu_clk = { 25 + .name = "cpu_clk", 26 + .parent = &master_clk, 27 + .flags = CLK_ENABLE_ON_INIT, 28 + }; 29 + 30 + /* 31 + * The ordering of these clocks matters, do not change it. 32 + */ 33 + static struct clk *onchip_clocks[] = { 34 + &master_clk, 35 + &peripheral_clk, 36 + &bus_clk, 37 + &cpu_clk, 38 + }; 39 + 40 + int __init __deprecated cpg_clk_init(void) 41 + { 42 + int i, ret = 0; 43 + 44 + for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) { 45 + struct clk *clk = onchip_clocks[i]; 46 + arch_init_clk_ops(&clk->ops, i); 47 + if (clk->ops) 48 + ret |= clk_register(clk); 49 + } 50 + 51 + return ret; 52 + } 53 + 54 + /* 55 + * Placeholder for compatability, until the lazy CPUs do this 56 + * on their own. 57 + */ 58 + int __init __weak arch_clk_init(void) 59 + { 60 + return cpg_clk_init(); 61 + } 62 + #endif /* CONFIG_SH_CPG_CLK_LEGACY */
+400 -206
arch/sh/kernel/cpu/clock.c
··· 1 1 /* 2 2 * arch/sh/kernel/cpu/clock.c - SuperH clock framework 3 3 * 4 - * Copyright (C) 2005, 2006, 2007 Paul Mundt 4 + * Copyright (C) 2005 - 2009 Paul Mundt 5 5 * 6 6 * This clock framework is derived from the OMAP version by: 7 7 * 8 - * Copyright (C) 2004 - 2005 Nokia Corporation 8 + * Copyright (C) 2004 - 2008 Nokia Corporation 9 9 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> 10 10 * 11 11 * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com> 12 + * 13 + * With clkdev bits: 14 + * 15 + * Copyright (C) 2008 Russell King. 12 16 * 13 17 * This file is subject to the terms and conditions of the GNU General Public 14 18 * License. See the file "COPYING" in the main directory of this archive ··· 28 24 #include <linux/seq_file.h> 29 25 #include <linux/err.h> 30 26 #include <linux/platform_device.h> 31 - #include <linux/proc_fs.h> 27 + #include <linux/debugfs.h> 28 + #include <linux/cpufreq.h> 32 29 #include <asm/clock.h> 30 + #include <asm/machvec.h> 33 31 34 32 static LIST_HEAD(clock_list); 35 33 static DEFINE_SPINLOCK(clock_lock); 36 34 static DEFINE_MUTEX(clock_list_sem); 37 35 38 - /* 39 - * Each subtype is expected to define the init routines for these clocks, 40 - * as each subtype (or processor family) will have these clocks at the 41 - * very least. These are all provided through the CPG, which even some of 42 - * the more quirky parts (such as ST40, SH4-202, etc.) still have. 43 - * 44 - * The processor-specific code is expected to register any additional 45 - * clock sources that are of interest. 46 - */ 47 - static struct clk master_clk = { 48 - .name = "master_clk", 49 - .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, 50 - .rate = CONFIG_SH_PCLK_FREQ, 51 - }; 36 + void clk_rate_table_build(struct clk *clk, 37 + struct cpufreq_frequency_table *freq_table, 38 + int nr_freqs, 39 + struct clk_div_mult_table *src_table, 40 + unsigned long *bitmap) 41 + { 42 + unsigned long mult, div; 43 + unsigned long freq; 44 + int i; 52 45 53 - static struct clk module_clk = { 54 - .name = "module_clk", 55 - .parent = &master_clk, 56 - .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, 57 - }; 46 + for (i = 0; i < nr_freqs; i++) { 47 + div = 1; 48 + mult = 1; 58 49 59 - static struct clk bus_clk = { 60 - .name = "bus_clk", 61 - .parent = &master_clk, 62 - .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, 63 - }; 50 + if (src_table->divisors && i < src_table->nr_divisors) 51 + div = src_table->divisors[i]; 64 52 65 - static struct clk cpu_clk = { 66 - .name = "cpu_clk", 67 - .parent = &master_clk, 68 - .flags = CLK_ALWAYS_ENABLED, 69 - }; 53 + if (src_table->multipliers && i < src_table->nr_multipliers) 54 + mult = src_table->multipliers[i]; 70 55 71 - /* 72 - * The ordering of these clocks matters, do not change it. 73 - */ 74 - static struct clk *onchip_clocks[] = { 75 - &master_clk, 76 - &module_clk, 77 - &bus_clk, 78 - &cpu_clk, 79 - }; 56 + if (!div || !mult || (bitmap && !test_bit(i, bitmap))) 57 + freq = CPUFREQ_ENTRY_INVALID; 58 + else 59 + freq = clk->parent->rate * mult / div; 80 60 81 - static void propagate_rate(struct clk *clk) 61 + freq_table[i].index = i; 62 + freq_table[i].frequency = freq; 63 + } 64 + 65 + /* Termination entry */ 66 + freq_table[i].index = i; 67 + freq_table[i].frequency = CPUFREQ_TABLE_END; 68 + } 69 + 70 + long clk_rate_table_round(struct clk *clk, 71 + struct cpufreq_frequency_table *freq_table, 72 + unsigned long rate) 73 + { 74 + unsigned long rate_error, rate_error_prev = ~0UL; 75 + unsigned long rate_best_fit = rate; 76 + unsigned long highest, lowest; 77 + int i; 78 + 79 + highest = lowest = 0; 80 + 81 + for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { 82 + unsigned long freq = freq_table[i].frequency; 83 + 84 + if (freq == CPUFREQ_ENTRY_INVALID) 85 + continue; 86 + 87 + if (freq > highest) 88 + highest = freq; 89 + if (freq < lowest) 90 + lowest = freq; 91 + 92 + rate_error = abs(freq - rate); 93 + if (rate_error < rate_error_prev) { 94 + rate_best_fit = freq; 95 + rate_error_prev = rate_error; 96 + } 97 + 98 + if (rate_error == 0) 99 + break; 100 + } 101 + 102 + if (rate >= highest) 103 + rate_best_fit = highest; 104 + if (rate <= lowest) 105 + rate_best_fit = lowest; 106 + 107 + return rate_best_fit; 108 + } 109 + 110 + /* Used for clocks that always have same value as the parent clock */ 111 + unsigned long followparent_recalc(struct clk *clk) 112 + { 113 + return clk->parent ? clk->parent->rate : 0; 114 + } 115 + 116 + int clk_reparent(struct clk *child, struct clk *parent) 117 + { 118 + list_del_init(&child->sibling); 119 + if (parent) 120 + list_add(&child->sibling, &parent->children); 121 + child->parent = parent; 122 + 123 + /* now do the debugfs renaming to reattach the child 124 + to the proper parent */ 125 + 126 + return 0; 127 + } 128 + 129 + /* Propagate rate to children */ 130 + void propagate_rate(struct clk *tclk) 82 131 { 83 132 struct clk *clkp; 84 133 85 - list_for_each_entry(clkp, &clock_list, node) { 86 - if (likely(clkp->parent != clk)) 87 - continue; 88 - if (likely(clkp->ops && clkp->ops->recalc)) 89 - clkp->ops->recalc(clkp); 90 - if (unlikely(clkp->flags & CLK_RATE_PROPAGATES)) 91 - propagate_rate(clkp); 134 + list_for_each_entry(clkp, &tclk->children, sibling) { 135 + if (clkp->ops && clkp->ops->recalc) 136 + clkp->rate = clkp->ops->recalc(clkp); 137 + 138 + propagate_rate(clkp); 92 139 } 93 140 } 94 141 95 - static void __clk_init(struct clk *clk) 142 + static void __clk_disable(struct clk *clk) 96 143 { 97 - /* 98 - * See if this is the first time we're enabling the clock, some 99 - * clocks that are always enabled still require "special" 100 - * initialization. This is especially true if the clock mode 101 - * changes and the clock needs to hunt for the proper set of 102 - * divisors to use before it can effectively recalc. 103 - */ 144 + if (clk->usecount == 0) { 145 + printk(KERN_ERR "Trying disable clock %s with 0 usecount\n", 146 + clk->name); 147 + WARN_ON(1); 148 + return; 149 + } 104 150 105 - if (clk->flags & CLK_NEEDS_INIT) { 106 - if (clk->ops && clk->ops->init) 107 - clk->ops->init(clk); 108 - 109 - clk->flags &= ~CLK_NEEDS_INIT; 151 + if (!(--clk->usecount)) { 152 + if (likely(clk->ops && clk->ops->disable)) 153 + clk->ops->disable(clk); 154 + if (likely(clk->parent)) 155 + __clk_disable(clk->parent); 110 156 } 111 157 } 158 + 159 + void clk_disable(struct clk *clk) 160 + { 161 + unsigned long flags; 162 + 163 + if (!clk) 164 + return; 165 + 166 + spin_lock_irqsave(&clock_lock, flags); 167 + __clk_disable(clk); 168 + spin_unlock_irqrestore(&clock_lock, flags); 169 + } 170 + EXPORT_SYMBOL_GPL(clk_disable); 112 171 113 172 static int __clk_enable(struct clk *clk) 114 173 { 115 - if (!clk) 116 - return -EINVAL; 174 + int ret = 0; 117 175 118 - clk->usecount++; 176 + if (clk->usecount++ == 0) { 177 + if (clk->parent) { 178 + ret = __clk_enable(clk->parent); 179 + if (unlikely(ret)) 180 + goto err; 181 + } 119 182 120 - /* nothing to do if always enabled */ 121 - if (clk->flags & CLK_ALWAYS_ENABLED) 122 - return 0; 123 - 124 - if (clk->usecount == 1) { 125 - __clk_init(clk); 126 - 127 - __clk_enable(clk->parent); 128 - 129 - if (clk->ops && clk->ops->enable) 130 - clk->ops->enable(clk); 183 + if (clk->ops && clk->ops->enable) { 184 + ret = clk->ops->enable(clk); 185 + if (ret) { 186 + if (clk->parent) 187 + __clk_disable(clk->parent); 188 + goto err; 189 + } 190 + } 131 191 } 132 192 133 - return 0; 193 + return ret; 194 + err: 195 + clk->usecount--; 196 + return ret; 134 197 } 135 198 136 199 int clk_enable(struct clk *clk) 137 200 { 138 201 unsigned long flags; 139 202 int ret; 203 + 204 + if (!clk) 205 + return -EINVAL; 140 206 141 207 spin_lock_irqsave(&clock_lock, flags); 142 208 ret = __clk_enable(clk); ··· 216 142 } 217 143 EXPORT_SYMBOL_GPL(clk_enable); 218 144 219 - static void __clk_disable(struct clk *clk) 145 + static LIST_HEAD(root_clks); 146 + 147 + /** 148 + * recalculate_root_clocks - recalculate and propagate all root clocks 149 + * 150 + * Recalculates all root clocks (clocks with no parent), which if the 151 + * clock's .recalc is set correctly, should also propagate their rates. 152 + * Called at init. 153 + */ 154 + void recalculate_root_clocks(void) 220 155 { 221 - if (!clk) 222 - return; 156 + struct clk *clkp; 223 157 224 - clk->usecount--; 225 - 226 - WARN_ON(clk->usecount < 0); 227 - 228 - if (clk->flags & CLK_ALWAYS_ENABLED) 229 - return; 230 - 231 - if (clk->usecount == 0) { 232 - if (likely(clk->ops && clk->ops->disable)) 233 - clk->ops->disable(clk); 234 - 235 - __clk_disable(clk->parent); 158 + list_for_each_entry(clkp, &root_clks, sibling) { 159 + if (clkp->ops && clkp->ops->recalc) 160 + clkp->rate = clkp->ops->recalc(clkp); 161 + propagate_rate(clkp); 236 162 } 237 163 } 238 - 239 - void clk_disable(struct clk *clk) 240 - { 241 - unsigned long flags; 242 - 243 - spin_lock_irqsave(&clock_lock, flags); 244 - __clk_disable(clk); 245 - spin_unlock_irqrestore(&clock_lock, flags); 246 - } 247 - EXPORT_SYMBOL_GPL(clk_disable); 248 164 249 165 int clk_register(struct clk *clk) 250 166 { 167 + if (clk == NULL || IS_ERR(clk)) 168 + return -EINVAL; 169 + 170 + /* 171 + * trap out already registered clocks 172 + */ 173 + if (clk->node.next || clk->node.prev) 174 + return 0; 175 + 251 176 mutex_lock(&clock_list_sem); 252 177 253 - list_add(&clk->node, &clock_list); 178 + INIT_LIST_HEAD(&clk->children); 254 179 clk->usecount = 0; 255 - clk->flags |= CLK_NEEDS_INIT; 256 180 181 + if (clk->parent) 182 + list_add(&clk->sibling, &clk->parent->children); 183 + else 184 + list_add(&clk->sibling, &root_clks); 185 + 186 + list_add(&clk->node, &clock_list); 187 + if (clk->ops && clk->ops->init) 188 + clk->ops->init(clk); 257 189 mutex_unlock(&clock_list_sem); 258 - 259 - if (clk->flags & CLK_ALWAYS_ENABLED) { 260 - __clk_init(clk); 261 - pr_debug( "Clock '%s' is ALWAYS_ENABLED\n", clk->name); 262 - if (clk->ops && clk->ops->enable) 263 - clk->ops->enable(clk); 264 - pr_debug( "Enabled."); 265 - } 266 190 267 191 return 0; 268 192 } ··· 269 197 void clk_unregister(struct clk *clk) 270 198 { 271 199 mutex_lock(&clock_list_sem); 200 + list_del(&clk->sibling); 272 201 list_del(&clk->node); 273 202 mutex_unlock(&clock_list_sem); 274 203 } 275 204 EXPORT_SYMBOL_GPL(clk_unregister); 205 + 206 + static void clk_enable_init_clocks(void) 207 + { 208 + struct clk *clkp; 209 + 210 + list_for_each_entry(clkp, &clock_list, node) 211 + if (clkp->flags & CLK_ENABLE_ON_INIT) 212 + clk_enable(clkp); 213 + } 276 214 277 215 unsigned long clk_get_rate(struct clk *clk) 278 216 { ··· 299 217 int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id) 300 218 { 301 219 int ret = -EOPNOTSUPP; 220 + unsigned long flags; 221 + 222 + spin_lock_irqsave(&clock_lock, flags); 302 223 303 224 if (likely(clk->ops && clk->ops->set_rate)) { 304 - unsigned long flags; 305 - 306 - spin_lock_irqsave(&clock_lock, flags); 307 225 ret = clk->ops->set_rate(clk, rate, algo_id); 308 - spin_unlock_irqrestore(&clock_lock, flags); 226 + if (ret != 0) 227 + goto out_unlock; 228 + } else { 229 + clk->rate = rate; 230 + ret = 0; 309 231 } 310 232 311 - if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) 312 - propagate_rate(clk); 233 + if (clk->ops && clk->ops->recalc) 234 + clk->rate = clk->ops->recalc(clk); 235 + 236 + propagate_rate(clk); 237 + 238 + out_unlock: 239 + spin_unlock_irqrestore(&clock_lock, flags); 313 240 314 241 return ret; 315 242 } 316 243 EXPORT_SYMBOL_GPL(clk_set_rate_ex); 317 244 318 - void clk_recalc_rate(struct clk *clk) 319 - { 320 - if (likely(clk->ops && clk->ops->recalc)) { 321 - unsigned long flags; 322 - 323 - spin_lock_irqsave(&clock_lock, flags); 324 - clk->ops->recalc(clk); 325 - spin_unlock_irqrestore(&clock_lock, flags); 326 - } 327 - 328 - if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) 329 - propagate_rate(clk); 330 - } 331 - EXPORT_SYMBOL_GPL(clk_recalc_rate); 332 - 333 245 int clk_set_parent(struct clk *clk, struct clk *parent) 334 246 { 247 + unsigned long flags; 335 248 int ret = -EINVAL; 336 - struct clk *old; 337 249 338 250 if (!parent || !clk) 339 251 return ret; 252 + if (clk->parent == parent) 253 + return 0; 340 254 341 - old = clk->parent; 342 - if (likely(clk->ops && clk->ops->set_parent)) { 343 - unsigned long flags; 344 - spin_lock_irqsave(&clock_lock, flags); 345 - ret = clk->ops->set_parent(clk, parent); 346 - spin_unlock_irqrestore(&clock_lock, flags); 347 - clk->parent = (ret ? old : parent); 348 - } 255 + spin_lock_irqsave(&clock_lock, flags); 256 + if (clk->usecount == 0) { 257 + if (clk->ops->set_parent) 258 + ret = clk->ops->set_parent(clk, parent); 259 + else 260 + ret = clk_reparent(clk, parent); 349 261 350 - if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) 351 - propagate_rate(clk); 262 + if (ret == 0) { 263 + pr_debug("clock: set parent of %s to %s (new rate %ld)\n", 264 + clk->name, clk->parent->name, clk->rate); 265 + if (clk->ops->recalc) 266 + clk->rate = clk->ops->recalc(clk); 267 + propagate_rate(clk); 268 + } 269 + } else 270 + ret = -EBUSY; 271 + spin_unlock_irqrestore(&clock_lock, flags); 272 + 352 273 return ret; 353 274 } 354 275 EXPORT_SYMBOL_GPL(clk_set_parent); ··· 379 294 EXPORT_SYMBOL_GPL(clk_round_rate); 380 295 381 296 /* 297 + * Find the correct struct clk for the device and connection ID. 298 + * We do slightly fuzzy matching here: 299 + * An entry with a NULL ID is assumed to be a wildcard. 300 + * If an entry has a device ID, it must match 301 + * If an entry has a connection ID, it must match 302 + * Then we take the most specific entry - with the following 303 + * order of precidence: dev+con > dev only > con only. 304 + */ 305 + static struct clk *clk_find(const char *dev_id, const char *con_id) 306 + { 307 + struct clk_lookup *p; 308 + struct clk *clk = NULL; 309 + int match, best = 0; 310 + 311 + list_for_each_entry(p, &clock_list, node) { 312 + match = 0; 313 + if (p->dev_id) { 314 + if (!dev_id || strcmp(p->dev_id, dev_id)) 315 + continue; 316 + match += 2; 317 + } 318 + if (p->con_id) { 319 + if (!con_id || strcmp(p->con_id, con_id)) 320 + continue; 321 + match += 1; 322 + } 323 + if (match == 0) 324 + continue; 325 + 326 + if (match > best) { 327 + clk = p->clk; 328 + best = match; 329 + } 330 + } 331 + return clk; 332 + } 333 + 334 + struct clk *clk_get_sys(const char *dev_id, const char *con_id) 335 + { 336 + struct clk *clk; 337 + 338 + mutex_lock(&clock_list_sem); 339 + clk = clk_find(dev_id, con_id); 340 + mutex_unlock(&clock_list_sem); 341 + 342 + return clk ? clk : ERR_PTR(-ENOENT); 343 + } 344 + EXPORT_SYMBOL_GPL(clk_get_sys); 345 + 346 + /* 382 347 * Returns a clock. Note that we first try to use device id on the bus 383 348 * and clock name. If this fails, we try to use clock name only. 384 349 */ 385 350 struct clk *clk_get(struct device *dev, const char *id) 386 351 { 352 + const char *dev_id = dev ? dev_name(dev) : NULL; 387 353 struct clk *p, *clk = ERR_PTR(-ENOENT); 388 354 int idno; 355 + 356 + clk = clk_get_sys(dev_id, id); 357 + if (clk && !IS_ERR(clk)) 358 + return clk; 389 359 390 360 if (dev == NULL || dev->bus != &platform_bus_type) 391 361 idno = -1; ··· 477 337 } 478 338 EXPORT_SYMBOL_GPL(clk_put); 479 339 480 - void __init __attribute__ ((weak)) 481 - arch_init_clk_ops(struct clk_ops **ops, int type) 482 - { 483 - } 484 - 485 - int __init __attribute__ ((weak)) 486 - arch_clk_init(void) 487 - { 488 - return 0; 489 - } 490 - 491 - static int show_clocks(char *buf, char **start, off_t off, 492 - int len, int *eof, void *data) 493 - { 494 - struct clk *clk; 495 - char *p = buf; 496 - 497 - list_for_each_entry_reverse(clk, &clock_list, node) { 498 - unsigned long rate = clk_get_rate(clk); 499 - 500 - p += sprintf(p, "%-12s\t: %ld.%02ldMHz\t%s\n", clk->name, 501 - rate / 1000000, (rate % 1000000) / 10000, 502 - ((clk->flags & CLK_ALWAYS_ENABLED) || 503 - clk->usecount > 0) ? 504 - "enabled" : "disabled"); 505 - } 506 - 507 - return p - buf; 508 - } 509 - 510 340 #ifdef CONFIG_PM 511 341 static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state) 512 342 { ··· 486 376 switch (state.event) { 487 377 case PM_EVENT_ON: 488 378 /* Resumeing from hibernation */ 489 - if (prev_state.event == PM_EVENT_FREEZE) { 490 - list_for_each_entry(clkp, &clock_list, node) 491 - if (likely(clkp->ops)) { 492 - unsigned long rate = clkp->rate; 379 + if (prev_state.event != PM_EVENT_FREEZE) 380 + break; 493 381 494 - if (likely(clkp->ops->set_parent)) 495 - clkp->ops->set_parent(clkp, 496 - clkp->parent); 497 - if (likely(clkp->ops->set_rate)) 498 - clkp->ops->set_rate(clkp, 499 - rate, NO_CHANGE); 500 - else if (likely(clkp->ops->recalc)) 501 - clkp->ops->recalc(clkp); 502 - } 382 + list_for_each_entry(clkp, &clock_list, node) { 383 + if (likely(clkp->ops)) { 384 + unsigned long rate = clkp->rate; 385 + 386 + if (likely(clkp->ops->set_parent)) 387 + clkp->ops->set_parent(clkp, 388 + clkp->parent); 389 + if (likely(clkp->ops->set_rate)) 390 + clkp->ops->set_rate(clkp, 391 + rate, NO_CHANGE); 392 + else if (likely(clkp->ops->recalc)) 393 + clkp->rate = clkp->ops->recalc(clkp); 394 + } 503 395 } 504 396 break; 505 397 case PM_EVENT_FREEZE: ··· 545 433 546 434 int __init clk_init(void) 547 435 { 548 - int i, ret = 0; 436 + int ret; 549 437 550 - BUG_ON(!master_clk.rate); 551 - 552 - for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) { 553 - struct clk *clk = onchip_clocks[i]; 554 - 555 - arch_init_clk_ops(&clk->ops, i); 556 - ret |= clk_register(clk); 438 + ret = arch_clk_init(); 439 + if (unlikely(ret)) { 440 + pr_err("%s: CPU clock registration failed.\n", __func__); 441 + return ret; 557 442 } 558 443 559 - ret |= arch_clk_init(); 444 + if (sh_mv.mv_clk_init) { 445 + ret = sh_mv.mv_clk_init(); 446 + if (unlikely(ret)) { 447 + pr_err("%s: machvec clock initialization failed.\n", 448 + __func__); 449 + return ret; 450 + } 451 + } 560 452 561 453 /* Kick the child clocks.. */ 562 - propagate_rate(&master_clk); 563 - propagate_rate(&bus_clk); 454 + recalculate_root_clocks(); 455 + 456 + /* Enable the necessary init clocks */ 457 + clk_enable_init_clocks(); 564 458 565 459 return ret; 566 460 } 567 461 568 - static int __init clk_proc_init(void) 569 - { 570 - struct proc_dir_entry *p; 571 - p = create_proc_read_entry("clocks", S_IRUSR, NULL, 572 - show_clocks, NULL); 573 - if (unlikely(!p)) 574 - return -EINVAL; 462 + /* 463 + * debugfs support to trace clock tree hierarchy and attributes 464 + */ 465 + static struct dentry *clk_debugfs_root; 575 466 467 + static int clk_debugfs_register_one(struct clk *c) 468 + { 469 + int err; 470 + struct dentry *d, *child; 471 + struct clk *pa = c->parent; 472 + char s[255]; 473 + char *p = s; 474 + 475 + p += sprintf(p, "%s", c->name); 476 + if (c->id >= 0) 477 + sprintf(p, ":%d", c->id); 478 + d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root); 479 + if (!d) 480 + return -ENOMEM; 481 + c->dentry = d; 482 + 483 + d = debugfs_create_u8("usecount", S_IRUGO, c->dentry, (u8 *)&c->usecount); 484 + if (!d) { 485 + err = -ENOMEM; 486 + goto err_out; 487 + } 488 + d = debugfs_create_u32("rate", S_IRUGO, c->dentry, (u32 *)&c->rate); 489 + if (!d) { 490 + err = -ENOMEM; 491 + goto err_out; 492 + } 493 + d = debugfs_create_x32("flags", S_IRUGO, c->dentry, (u32 *)&c->flags); 494 + if (!d) { 495 + err = -ENOMEM; 496 + goto err_out; 497 + } 498 + return 0; 499 + 500 + err_out: 501 + d = c->dentry; 502 + list_for_each_entry(child, &d->d_subdirs, d_u.d_child) 503 + debugfs_remove(child); 504 + debugfs_remove(c->dentry); 505 + return err; 506 + } 507 + 508 + static int clk_debugfs_register(struct clk *c) 509 + { 510 + int err; 511 + struct clk *pa = c->parent; 512 + 513 + if (pa && !pa->dentry) { 514 + err = clk_debugfs_register(pa); 515 + if (err) 516 + return err; 517 + } 518 + 519 + if (!c->dentry) { 520 + err = clk_debugfs_register_one(c); 521 + if (err) 522 + return err; 523 + } 576 524 return 0; 577 525 } 578 - subsys_initcall(clk_proc_init); 526 + 527 + static int __init clk_debugfs_init(void) 528 + { 529 + struct clk *c; 530 + struct dentry *d; 531 + int err; 532 + 533 + d = debugfs_create_dir("clock", NULL); 534 + if (!d) 535 + return -ENOMEM; 536 + clk_debugfs_root = d; 537 + 538 + list_for_each_entry(c, &clock_list, node) { 539 + err = clk_debugfs_register(c); 540 + if (err) 541 + goto err_out; 542 + } 543 + return 0; 544 + err_out: 545 + debugfs_remove(clk_debugfs_root); /* REVISIT: Cleanup correctly */ 546 + return err; 547 + } 548 + late_initcall(clk_debugfs_init);
+5 -11
arch/sh/kernel/cpu/sh2/clock-sh7619.c
··· 38 38 .init = master_clk_init, 39 39 }; 40 40 41 - static void module_clk_recalc(struct clk *clk) 41 + static unsigned long module_clk_recalc(struct clk *clk) 42 42 { 43 43 int idx = (ctrl_inw(FREQCR) & 0x0007); 44 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 44 + return clk->parent->rate / pfc_divisors[idx]; 45 45 } 46 46 47 47 static struct clk_ops sh7619_module_clk_ops = { 48 48 .recalc = module_clk_recalc, 49 49 }; 50 50 51 - static void bus_clk_recalc(struct clk *clk) 51 + static unsigned long bus_clk_recalc(struct clk *clk) 52 52 { 53 - clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7]; 53 + return clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7]; 54 54 } 55 55 56 56 static struct clk_ops sh7619_bus_clk_ops = { 57 57 .recalc = bus_clk_recalc, 58 58 }; 59 59 60 - static void cpu_clk_recalc(struct clk *clk) 61 - { 62 - clk->rate = clk->parent->rate; 63 - } 64 - 65 60 static struct clk_ops sh7619_cpu_clk_ops = { 66 - .recalc = cpu_clk_recalc, 61 + .recalc = followparent_recalc, 67 62 }; 68 63 69 64 static struct clk_ops *sh7619_clk_ops[] = { ··· 73 78 if (idx < ARRAY_SIZE(sh7619_clk_ops)) 74 79 *ops = sh7619_clk_ops[idx]; 75 80 } 76 -
+2 -2
arch/sh/kernel/cpu/sh2/setup-sh7619.c
··· 115 115 .name = "CMT0", 116 116 .channel_offset = 0x02, 117 117 .timer_bit = 0, 118 - .clk = "module_clk", 118 + .clk = "peripheral_clk", 119 119 .clockevent_rating = 125, 120 120 .clocksource_rating = 0, /* disabled due to code generation issues */ 121 121 }; ··· 147 147 .name = "CMT1", 148 148 .channel_offset = 0x08, 149 149 .timer_bit = 1, 150 - .clk = "module_clk", 150 + .clk = "peripheral_clk", 151 151 .clockevent_rating = 125, 152 152 .clocksource_rating = 0, /* disabled due to code generation issues */ 153 153 };
+7 -7
arch/sh/kernel/cpu/sh2a/clock-sh7201.c
··· 34 34 35 35 static void master_clk_init(struct clk *clk) 36 36 { 37 - clk->rate = 10000000 * PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007]; 37 + return 10000000 * PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007]; 38 38 } 39 39 40 40 static struct clk_ops sh7201_master_clk_ops = { 41 41 .init = master_clk_init, 42 42 }; 43 43 44 - static void module_clk_recalc(struct clk *clk) 44 + static unsigned long module_clk_recalc(struct clk *clk) 45 45 { 46 46 int idx = (ctrl_inw(FREQCR) & 0x0007); 47 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 47 + return clk->parent->rate / pfc_divisors[idx]; 48 48 } 49 49 50 50 static struct clk_ops sh7201_module_clk_ops = { 51 51 .recalc = module_clk_recalc, 52 52 }; 53 53 54 - static void bus_clk_recalc(struct clk *clk) 54 + static unsigned long bus_clk_recalc(struct clk *clk) 55 55 { 56 56 int idx = (ctrl_inw(FREQCR) & 0x0007); 57 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 57 + return clk->parent->rate / pfc_divisors[idx]; 58 58 } 59 59 60 60 static struct clk_ops sh7201_bus_clk_ops = { 61 61 .recalc = bus_clk_recalc, 62 62 }; 63 63 64 - static void cpu_clk_recalc(struct clk *clk) 64 + static unsigned long cpu_clk_recalc(struct clk *clk) 65 65 { 66 66 int idx = ((ctrl_inw(FREQCR) >> 4) & 0x0007); 67 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 67 + return clk->parent->rate / ifc_divisors[idx]; 68 68 } 69 69 70 70 static struct clk_ops sh7201_cpu_clk_ops = {
+5 -10
arch/sh/kernel/cpu/sh2a/clock-sh7203.c
··· 46 46 .init = master_clk_init, 47 47 }; 48 48 49 - static void module_clk_recalc(struct clk *clk) 49 + static unsigned long module_clk_recalc(struct clk *clk) 50 50 { 51 51 int idx = (ctrl_inw(FREQCR) & 0x0007); 52 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 52 + return clk->parent->rate / pfc_divisors[idx]; 53 53 } 54 54 55 55 static struct clk_ops sh7203_module_clk_ops = { 56 56 .recalc = module_clk_recalc, 57 57 }; 58 58 59 - static void bus_clk_recalc(struct clk *clk) 59 + static unsigned long bus_clk_recalc(struct clk *clk) 60 60 { 61 61 int idx = (ctrl_inw(FREQCR) & 0x0007); 62 - clk->rate = clk->parent->rate / pfc_divisors[idx-2]; 62 + return clk->parent->rate / pfc_divisors[idx-2]; 63 63 } 64 64 65 65 static struct clk_ops sh7203_bus_clk_ops = { 66 66 .recalc = bus_clk_recalc, 67 67 }; 68 68 69 - static void cpu_clk_recalc(struct clk *clk) 70 - { 71 - clk->rate = clk->parent->rate; 72 - } 73 - 74 69 static struct clk_ops sh7203_cpu_clk_ops = { 75 - .recalc = cpu_clk_recalc, 70 + .recalc = followparent_recalc, 76 71 }; 77 72 78 73 static struct clk_ops *sh7203_clk_ops[] = {
+6 -6
arch/sh/kernel/cpu/sh2a/clock-sh7206.c
··· 41 41 .init = master_clk_init, 42 42 }; 43 43 44 - static void module_clk_recalc(struct clk *clk) 44 + static unsigned long module_clk_recalc(struct clk *clk) 45 45 { 46 46 int idx = (ctrl_inw(FREQCR) & 0x0007); 47 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 47 + return clk->parent->rate / pfc_divisors[idx]; 48 48 } 49 49 50 50 static struct clk_ops sh7206_module_clk_ops = { 51 51 .recalc = module_clk_recalc, 52 52 }; 53 53 54 - static void bus_clk_recalc(struct clk *clk) 54 + static unsigned long bus_clk_recalc(struct clk *clk) 55 55 { 56 - clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007]; 56 + return clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007]; 57 57 } 58 58 59 59 static struct clk_ops sh7206_bus_clk_ops = { 60 60 .recalc = bus_clk_recalc, 61 61 }; 62 62 63 - static void cpu_clk_recalc(struct clk *clk) 63 + static unsigned long cpu_clk_recalc(struct clk *clk) 64 64 { 65 65 int idx = (ctrl_inw(FREQCR) & 0x0007); 66 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 66 + return clk->parent->rate / ifc_divisors[idx]; 67 67 } 68 68 69 69 static struct clk_ops sh7206_cpu_clk_ops = {
+3 -3
arch/sh/kernel/cpu/sh2a/setup-mxg.c
··· 118 118 .name = "MTU2_0", 119 119 .channel_offset = -0x80, 120 120 .timer_bit = 0, 121 - .clk = "module_clk", 121 + .clk = "peripheral_clk", 122 122 .clockevent_rating = 200, 123 123 }; 124 124 ··· 149 149 .name = "MTU2_1", 150 150 .channel_offset = -0x100, 151 151 .timer_bit = 1, 152 - .clk = "module_clk", 152 + .clk = "peripheral_clk", 153 153 .clockevent_rating = 200, 154 154 }; 155 155 ··· 180 180 .name = "MTU2_2", 181 181 .channel_offset = 0x80, 182 182 .timer_bit = 2, 183 - .clk = "module_clk", 183 + .clk = "peripheral_clk", 184 184 .clockevent_rating = 200, 185 185 }; 186 186
+3 -3
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
··· 255 255 .name = "MTU2_0", 256 256 .channel_offset = -0x80, 257 257 .timer_bit = 0, 258 - .clk = "module_clk", 258 + .clk = "peripheral_clk", 259 259 .clockevent_rating = 200, 260 260 }; 261 261 ··· 286 286 .name = "MTU2_1", 287 287 .channel_offset = -0x100, 288 288 .timer_bit = 1, 289 - .clk = "module_clk", 289 + .clk = "peripheral_clk", 290 290 .clockevent_rating = 200, 291 291 }; 292 292 ··· 317 317 .name = "MTU2_2", 318 318 .channel_offset = 0x80, 319 319 .timer_bit = 2, 320 - .clk = "module_clk", 320 + .clk = "peripheral_clk", 321 321 .clockevent_rating = 200, 322 322 }; 323 323
+4 -4
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
··· 211 211 .name = "CMT0", 212 212 .channel_offset = 0x02, 213 213 .timer_bit = 0, 214 - .clk = "module_clk", 214 + .clk = "peripheral_clk", 215 215 .clockevent_rating = 125, 216 216 .clocksource_rating = 0, /* disabled due to code generation issues */ 217 217 }; ··· 243 243 .name = "CMT1", 244 244 .channel_offset = 0x08, 245 245 .timer_bit = 1, 246 - .clk = "module_clk", 246 + .clk = "peripheral_clk", 247 247 .clockevent_rating = 125, 248 248 .clocksource_rating = 0, /* disabled due to code generation issues */ 249 249 }; ··· 275 275 .name = "MTU2_0", 276 276 .channel_offset = -0x80, 277 277 .timer_bit = 0, 278 - .clk = "module_clk", 278 + .clk = "peripheral_clk", 279 279 .clockevent_rating = 200, 280 280 }; 281 281 ··· 306 306 .name = "MTU2_1", 307 307 .channel_offset = -0x100, 308 308 .timer_bit = 1, 309 - .clk = "module_clk", 309 + .clk = "peripheral_clk", 310 310 .clockevent_rating = 200, 311 311 }; 312 312
+5 -5
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
··· 171 171 .name = "CMT0", 172 172 .channel_offset = 0x02, 173 173 .timer_bit = 0, 174 - .clk = "module_clk", 174 + .clk = "peripheral_clk", 175 175 .clockevent_rating = 125, 176 176 .clocksource_rating = 0, /* disabled due to code generation issues */ 177 177 }; ··· 203 203 .name = "CMT1", 204 204 .channel_offset = 0x08, 205 205 .timer_bit = 1, 206 - .clk = "module_clk", 206 + .clk = "peripheral_clk", 207 207 .clockevent_rating = 125, 208 208 .clocksource_rating = 0, /* disabled due to code generation issues */ 209 209 }; ··· 235 235 .name = "MTU2_0", 236 236 .channel_offset = -0x80, 237 237 .timer_bit = 0, 238 - .clk = "module_clk", 238 + .clk = "peripheral_clk", 239 239 .clockevent_rating = 200, 240 240 }; 241 241 ··· 266 266 .name = "MTU2_1", 267 267 .channel_offset = -0x100, 268 268 .timer_bit = 1, 269 - .clk = "module_clk", 269 + .clk = "peripheral_clk", 270 270 .clockevent_rating = 200, 271 271 }; 272 272 ··· 297 297 .name = "MTU2_2", 298 298 .channel_offset = 0x80, 299 299 .timer_bit = 2, 300 - .clk = "module_clk", 300 + .clk = "peripheral_clk", 301 301 .clockevent_rating = 200, 302 302 }; 303 303
+6 -6
arch/sh/kernel/cpu/sh3/clock-sh3.c
··· 38 38 .init = master_clk_init, 39 39 }; 40 40 41 - static void module_clk_recalc(struct clk *clk) 41 + static unsigned long module_clk_recalc(struct clk *clk) 42 42 { 43 43 int frqcr = ctrl_inw(FRQCR); 44 44 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); 45 45 46 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 46 + return clk->parent->rate / pfc_divisors[idx]; 47 47 } 48 48 49 49 static struct clk_ops sh3_module_clk_ops = { 50 50 .recalc = module_clk_recalc, 51 51 }; 52 52 53 - static void bus_clk_recalc(struct clk *clk) 53 + static unsigned long bus_clk_recalc(struct clk *clk) 54 54 { 55 55 int frqcr = ctrl_inw(FRQCR); 56 56 int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4); 57 57 58 - clk->rate = clk->parent->rate / stc_multipliers[idx]; 58 + return clk->parent->rate / stc_multipliers[idx]; 59 59 } 60 60 61 61 static struct clk_ops sh3_bus_clk_ops = { 62 62 .recalc = bus_clk_recalc, 63 63 }; 64 64 65 - static void cpu_clk_recalc(struct clk *clk) 65 + static unsigned long cpu_clk_recalc(struct clk *clk) 66 66 { 67 67 int frqcr = ctrl_inw(FRQCR); 68 68 int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2); 69 69 70 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 70 + return clk->parent->rate / ifc_divisors[idx]; 71 71 } 72 72 73 73 static struct clk_ops sh3_cpu_clk_ops = {
+6 -6
arch/sh/kernel/cpu/sh3/clock-sh7705.c
··· 39 39 .init = master_clk_init, 40 40 }; 41 41 42 - static void module_clk_recalc(struct clk *clk) 42 + static unsigned long module_clk_recalc(struct clk *clk) 43 43 { 44 44 int idx = ctrl_inw(FRQCR) & 0x0003; 45 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 45 + return clk->parent->rate / pfc_divisors[idx]; 46 46 } 47 47 48 48 static struct clk_ops sh7705_module_clk_ops = { 49 49 .recalc = module_clk_recalc, 50 50 }; 51 51 52 - static void bus_clk_recalc(struct clk *clk) 52 + static unsigned long bus_clk_recalc(struct clk *clk) 53 53 { 54 54 int idx = (ctrl_inw(FRQCR) & 0x0300) >> 8; 55 - clk->rate = clk->parent->rate / stc_multipliers[idx]; 55 + return clk->parent->rate / stc_multipliers[idx]; 56 56 } 57 57 58 58 static struct clk_ops sh7705_bus_clk_ops = { 59 59 .recalc = bus_clk_recalc, 60 60 }; 61 61 62 - static void cpu_clk_recalc(struct clk *clk) 62 + static unsigned long cpu_clk_recalc(struct clk *clk) 63 63 { 64 64 int idx = (ctrl_inw(FRQCR) & 0x0030) >> 4; 65 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 65 + return clk->parent->rate / ifc_divisors[idx]; 66 66 } 67 67 68 68 static struct clk_ops sh7705_cpu_clk_ops = {
+6 -6
arch/sh/kernel/cpu/sh3/clock-sh7706.c
··· 34 34 .init = master_clk_init, 35 35 }; 36 36 37 - static void module_clk_recalc(struct clk *clk) 37 + static unsigned long module_clk_recalc(struct clk *clk) 38 38 { 39 39 int frqcr = ctrl_inw(FRQCR); 40 40 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); 41 41 42 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 42 + return clk->parent->rate / pfc_divisors[idx]; 43 43 } 44 44 45 45 static struct clk_ops sh7706_module_clk_ops = { 46 46 .recalc = module_clk_recalc, 47 47 }; 48 48 49 - static void bus_clk_recalc(struct clk *clk) 49 + static unsigned long bus_clk_recalc(struct clk *clk) 50 50 { 51 51 int frqcr = ctrl_inw(FRQCR); 52 52 int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4); 53 53 54 - clk->rate = clk->parent->rate / stc_multipliers[idx]; 54 + return clk->parent->rate / stc_multipliers[idx]; 55 55 } 56 56 57 57 static struct clk_ops sh7706_bus_clk_ops = { 58 58 .recalc = bus_clk_recalc, 59 59 }; 60 60 61 - static void cpu_clk_recalc(struct clk *clk) 61 + static unsigned long cpu_clk_recalc(struct clk *clk) 62 62 { 63 63 int frqcr = ctrl_inw(FRQCR); 64 64 int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2); 65 65 66 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 66 + return clk->parent->rate / ifc_divisors[idx]; 67 67 } 68 68 69 69 static struct clk_ops sh7706_cpu_clk_ops = {
+6 -6
arch/sh/kernel/cpu/sh3/clock-sh7709.c
··· 41 41 .init = master_clk_init, 42 42 }; 43 43 44 - static void module_clk_recalc(struct clk *clk) 44 + static unsigned long module_clk_recalc(struct clk *clk) 45 45 { 46 46 int frqcr = ctrl_inw(FRQCR); 47 47 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); 48 48 49 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 49 + return clk->parent->rate / pfc_divisors[idx]; 50 50 } 51 51 52 52 static struct clk_ops sh7709_module_clk_ops = { ··· 56 56 .recalc = module_clk_recalc, 57 57 }; 58 58 59 - static void bus_clk_recalc(struct clk *clk) 59 + static unsigned long bus_clk_recalc(struct clk *clk) 60 60 { 61 61 int frqcr = ctrl_inw(FRQCR); 62 62 int idx = (frqcr & 0x0080) ? 63 63 ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4) : 1; 64 64 65 - clk->rate = clk->parent->rate * stc_multipliers[idx]; 65 + return clk->parent->rate * stc_multipliers[idx]; 66 66 } 67 67 68 68 static struct clk_ops sh7709_bus_clk_ops = { 69 69 .recalc = bus_clk_recalc, 70 70 }; 71 71 72 - static void cpu_clk_recalc(struct clk *clk) 72 + static unsigned long cpu_clk_recalc(struct clk *clk) 73 73 { 74 74 int frqcr = ctrl_inw(FRQCR); 75 75 int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2); 76 76 77 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 77 + return clk->parent->rate / ifc_divisors[idx]; 78 78 } 79 79 80 80 static struct clk_ops sh7709_cpu_clk_ops = {
+6 -6
arch/sh/kernel/cpu/sh3/clock-sh7710.c
··· 33 33 .init = master_clk_init, 34 34 }; 35 35 36 - static void module_clk_recalc(struct clk *clk) 36 + static unsigned long module_clk_recalc(struct clk *clk) 37 37 { 38 38 int idx = (ctrl_inw(FRQCR) & 0x0007); 39 - clk->rate = clk->parent->rate / md_table[idx]; 39 + return clk->parent->rate / md_table[idx]; 40 40 } 41 41 42 42 static struct clk_ops sh7710_module_clk_ops = { 43 43 .recalc = module_clk_recalc, 44 44 }; 45 45 46 - static void bus_clk_recalc(struct clk *clk) 46 + static unsigned long bus_clk_recalc(struct clk *clk) 47 47 { 48 48 int idx = (ctrl_inw(FRQCR) & 0x0700) >> 8; 49 - clk->rate = clk->parent->rate / md_table[idx]; 49 + return clk->parent->rate / md_table[idx]; 50 50 } 51 51 52 52 static struct clk_ops sh7710_bus_clk_ops = { 53 53 .recalc = bus_clk_recalc, 54 54 }; 55 55 56 - static void cpu_clk_recalc(struct clk *clk) 56 + static unsigned long cpu_clk_recalc(struct clk *clk) 57 57 { 58 58 int idx = (ctrl_inw(FRQCR) & 0x0070) >> 4; 59 - clk->rate = clk->parent->rate / md_table[idx]; 59 + return clk->parent->rate / md_table[idx]; 60 60 } 61 61 62 62 static struct clk_ops sh7710_cpu_clk_ops = {
+4 -4
arch/sh/kernel/cpu/sh3/clock-sh7712.c
··· 33 33 .init = master_clk_init, 34 34 }; 35 35 36 - static void module_clk_recalc(struct clk *clk) 36 + static unsigned long module_clk_recalc(struct clk *clk) 37 37 { 38 38 int frqcr = ctrl_inw(FRQCR); 39 39 int idx = frqcr & 0x0007; 40 40 41 - clk->rate = clk->parent->rate / divisors[idx]; 41 + return clk->parent->rate / divisors[idx]; 42 42 } 43 43 44 44 static struct clk_ops sh7712_module_clk_ops = { 45 45 .recalc = module_clk_recalc, 46 46 }; 47 47 48 - static void cpu_clk_recalc(struct clk *clk) 48 + static unsigned long cpu_clk_recalc(struct clk *clk) 49 49 { 50 50 int frqcr = ctrl_inw(FRQCR); 51 51 int idx = (frqcr & 0x0030) >> 4; 52 52 53 - clk->rate = clk->parent->rate / divisors[idx]; 53 + return clk->parent->rate / divisors[idx]; 54 54 } 55 55 56 56 static struct clk_ops sh7712_cpu_clk_ops = {
+3 -3
arch/sh/kernel/cpu/sh3/setup-sh7705.c
··· 121 121 .name = "TMU0", 122 122 .channel_offset = 0x02, 123 123 .timer_bit = 0, 124 - .clk = "module_clk", 124 + .clk = "peripheral_clk", 125 125 .clockevent_rating = 200, 126 126 }; 127 127 ··· 152 152 .name = "TMU1", 153 153 .channel_offset = 0xe, 154 154 .timer_bit = 1, 155 - .clk = "module_clk", 155 + .clk = "peripheral_clk", 156 156 .clocksource_rating = 200, 157 157 }; 158 158 ··· 183 183 .name = "TMU2", 184 184 .channel_offset = 0x1a, 185 185 .timer_bit = 2, 186 - .clk = "module_clk", 186 + .clk = "peripheral_clk", 187 187 }; 188 188 189 189 static struct resource tmu2_resources[] = {
+3 -3
arch/sh/kernel/cpu/sh3/setup-sh770x.c
··· 149 149 .name = "TMU0", 150 150 .channel_offset = 0x02, 151 151 .timer_bit = 0, 152 - .clk = "module_clk", 152 + .clk = "peripheral_clk", 153 153 .clockevent_rating = 200, 154 154 }; 155 155 ··· 180 180 .name = "TMU1", 181 181 .channel_offset = 0xe, 182 182 .timer_bit = 1, 183 - .clk = "module_clk", 183 + .clk = "peripheral_clk", 184 184 .clocksource_rating = 200, 185 185 }; 186 186 ··· 211 211 .name = "TMU2", 212 212 .channel_offset = 0x1a, 213 213 .timer_bit = 2, 214 - .clk = "module_clk", 214 + .clk = "peripheral_clk", 215 215 }; 216 216 217 217 static struct resource tmu2_resources[] = {
+3 -3
arch/sh/kernel/cpu/sh3/setup-sh7710.c
··· 125 125 .name = "TMU0", 126 126 .channel_offset = 0x02, 127 127 .timer_bit = 0, 128 - .clk = "module_clk", 128 + .clk = "peripheral_clk", 129 129 .clockevent_rating = 200, 130 130 }; 131 131 ··· 156 156 .name = "TMU1", 157 157 .channel_offset = 0xe, 158 158 .timer_bit = 1, 159 - .clk = "module_clk", 159 + .clk = "peripheral_clk", 160 160 .clocksource_rating = 200, 161 161 }; 162 162 ··· 187 187 .name = "TMU2", 188 188 .channel_offset = 0x1a, 189 189 .timer_bit = 2, 190 - .clk = "module_clk", 190 + .clk = "peripheral_clk", 191 191 }; 192 192 193 193 static struct resource tmu2_resources[] = {
+8 -8
arch/sh/kernel/cpu/sh3/setup-sh7720.c
··· 128 128 .name = "CMT0", 129 129 .channel_offset = 0x10, 130 130 .timer_bit = 0, 131 - .clk = "module_clk", 131 + .clk = "peripheral_clk", 132 132 .clockevent_rating = 125, 133 133 .clocksource_rating = 125, 134 134 }; ··· 160 160 .name = "CMT1", 161 161 .channel_offset = 0x20, 162 162 .timer_bit = 1, 163 - .clk = "module_clk", 163 + .clk = "peripheral_clk", 164 164 }; 165 165 166 166 static struct resource cmt1_resources[] = { ··· 190 190 .name = "CMT2", 191 191 .channel_offset = 0x30, 192 192 .timer_bit = 2, 193 - .clk = "module_clk", 193 + .clk = "peripheral_clk", 194 194 }; 195 195 196 196 static struct resource cmt2_resources[] = { ··· 220 220 .name = "CMT3", 221 221 .channel_offset = 0x40, 222 222 .timer_bit = 3, 223 - .clk = "module_clk", 223 + .clk = "peripheral_clk", 224 224 }; 225 225 226 226 static struct resource cmt3_resources[] = { ··· 250 250 .name = "CMT4", 251 251 .channel_offset = 0x50, 252 252 .timer_bit = 4, 253 - .clk = "module_clk", 253 + .clk = "peripheral_clk", 254 254 }; 255 255 256 256 static struct resource cmt4_resources[] = { ··· 280 280 .name = "TMU0", 281 281 .channel_offset = 0x02, 282 282 .timer_bit = 0, 283 - .clk = "module_clk", 283 + .clk = "peripheral_clk", 284 284 .clockevent_rating = 200, 285 285 }; 286 286 ··· 311 311 .name = "TMU1", 312 312 .channel_offset = 0xe, 313 313 .timer_bit = 1, 314 - .clk = "module_clk", 314 + .clk = "peripheral_clk", 315 315 .clocksource_rating = 200, 316 316 }; 317 317 ··· 342 342 .name = "TMU2", 343 343 .channel_offset = 0x1a, 344 344 .timer_bit = 2, 345 - .clk = "module_clk", 345 + .clk = "peripheral_clk", 346 346 }; 347 347 348 348 static struct resource tmu2_resources[] = {
+17 -26
arch/sh/kernel/cpu/sh4/clock-sh4-202.c
··· 21 21 static int frqcr3_divisors[] = { 1, 2, 3, 4, 6, 8, 16 }; 22 22 static int frqcr3_values[] = { 0, 1, 2, 3, 4, 5, 6 }; 23 23 24 - static void emi_clk_recalc(struct clk *clk) 24 + static unsigned long emi_clk_recalc(struct clk *clk) 25 25 { 26 26 int idx = ctrl_inl(CPG2_FRQCR3) & 0x0007; 27 - clk->rate = clk->parent->rate / frqcr3_divisors[idx]; 27 + return clk->parent->rate / frqcr3_divisors[idx]; 28 28 } 29 29 30 30 static inline int frqcr3_lookup(struct clk *clk, unsigned long rate) ··· 46 46 47 47 static struct clk sh4202_emi_clk = { 48 48 .name = "emi_clk", 49 - .flags = CLK_ALWAYS_ENABLED, 49 + .flags = CLK_ENABLE_ON_INIT, 50 50 .ops = &sh4202_emi_clk_ops, 51 51 }; 52 52 53 - static void femi_clk_recalc(struct clk *clk) 53 + static unsigned long femi_clk_recalc(struct clk *clk) 54 54 { 55 55 int idx = (ctrl_inl(CPG2_FRQCR3) >> 3) & 0x0007; 56 - clk->rate = clk->parent->rate / frqcr3_divisors[idx]; 56 + return clk->parent->rate / frqcr3_divisors[idx]; 57 57 } 58 58 59 59 static struct clk_ops sh4202_femi_clk_ops = { ··· 62 62 63 63 static struct clk sh4202_femi_clk = { 64 64 .name = "femi_clk", 65 - .flags = CLK_ALWAYS_ENABLED, 65 + .flags = CLK_ENABLE_ON_INIT, 66 66 .ops = &sh4202_femi_clk_ops, 67 67 }; 68 68 ··· 90 90 WARN_ON(i == ARRAY_SIZE(frqcr3_divisors)); /* Undefined clock */ 91 91 } 92 92 93 - static void shoc_clk_recalc(struct clk *clk) 93 + static unsigned long shoc_clk_recalc(struct clk *clk) 94 94 { 95 95 int idx = (ctrl_inl(CPG2_FRQCR3) >> 6) & 0x0007; 96 - clk->rate = clk->parent->rate / frqcr3_divisors[idx]; 96 + return clk->parent->rate / frqcr3_divisors[idx]; 97 97 } 98 98 99 99 static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) ··· 140 140 141 141 static struct clk sh4202_shoc_clk = { 142 142 .name = "shoc_clk", 143 - .flags = CLK_ALWAYS_ENABLED, 143 + .flags = CLK_ENABLE_ON_INIT, 144 144 .ops = &sh4202_shoc_clk_ops, 145 145 }; 146 146 ··· 150 150 &sh4202_shoc_clk, 151 151 }; 152 152 153 - static int __init sh4202_clk_init(void) 153 + int __init arch_clk_init(void) 154 154 { 155 - struct clk *clk = clk_get(NULL, "master_clk"); 156 - int i; 155 + struct clk *clk; 156 + int i, ret = 0; 157 157 158 + cpg_clk_init(); 159 + 160 + clk = clk_get(NULL, "master_clk"); 158 161 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { 159 162 struct clk *clkp = sh4202_onchip_clocks[i]; 160 163 161 164 clkp->parent = clk; 162 - clk_register(clkp); 163 - clk_enable(clkp); 165 + ret |= clk_register(clkp); 164 166 } 165 - 166 - /* 167 - * Now that we have the rest of the clocks registered, we need to 168 - * force the parent clock to propagate so that these clocks will 169 - * automatically figure out their rate. We cheat by handing the 170 - * parent clock its current rate and forcing child propagation. 171 - */ 172 - clk_set_rate(clk, clk_get_rate(clk)); 173 167 174 168 clk_put(clk); 175 169 176 - return 0; 170 + return ret; 177 171 } 178 - 179 - arch_initcall(sh4202_clk_init); 180 -
+6 -6
arch/sh/kernel/cpu/sh4/clock-sh4.c
··· 35 35 .init = master_clk_init, 36 36 }; 37 37 38 - static void module_clk_recalc(struct clk *clk) 38 + static unsigned long module_clk_recalc(struct clk *clk) 39 39 { 40 40 int idx = (ctrl_inw(FRQCR) & 0x0007); 41 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 41 + return clk->parent->rate / pfc_divisors[idx]; 42 42 } 43 43 44 44 static struct clk_ops sh4_module_clk_ops = { 45 45 .recalc = module_clk_recalc, 46 46 }; 47 47 48 - static void bus_clk_recalc(struct clk *clk) 48 + static unsigned long bus_clk_recalc(struct clk *clk) 49 49 { 50 50 int idx = (ctrl_inw(FRQCR) >> 3) & 0x0007; 51 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 51 + return clk->parent->rate / bfc_divisors[idx]; 52 52 } 53 53 54 54 static struct clk_ops sh4_bus_clk_ops = { 55 55 .recalc = bus_clk_recalc, 56 56 }; 57 57 58 - static void cpu_clk_recalc(struct clk *clk) 58 + static unsigned long cpu_clk_recalc(struct clk *clk) 59 59 { 60 60 int idx = (ctrl_inw(FRQCR) >> 6) & 0x0007; 61 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 61 + return clk->parent->rate / ifc_divisors[idx]; 62 62 } 63 63 64 64 static struct clk_ops sh4_cpu_clk_ops = {
+3 -3
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
··· 38 38 .name = "TMU0", 39 39 .channel_offset = 0x04, 40 40 .timer_bit = 0, 41 - .clk = "module_clk", 41 + .clk = "peripheral_clk", 42 42 .clockevent_rating = 200, 43 43 }; 44 44 ··· 69 69 .name = "TMU1", 70 70 .channel_offset = 0x10, 71 71 .timer_bit = 1, 72 - .clk = "module_clk", 72 + .clk = "peripheral_clk", 73 73 .clocksource_rating = 200, 74 74 }; 75 75 ··· 100 100 .name = "TMU2", 101 101 .channel_offset = 0x1c, 102 102 .timer_bit = 2, 103 - .clk = "module_clk", 103 + .clk = "peripheral_clk", 104 104 }; 105 105 106 106 static struct resource tmu2_resources[] = {
+5 -5
arch/sh/kernel/cpu/sh4/setup-sh7750.c
··· 65 65 .name = "TMU0", 66 66 .channel_offset = 0x04, 67 67 .timer_bit = 0, 68 - .clk = "module_clk", 68 + .clk = "peripheral_clk", 69 69 .clockevent_rating = 200, 70 70 }; 71 71 ··· 96 96 .name = "TMU1", 97 97 .channel_offset = 0x10, 98 98 .timer_bit = 1, 99 - .clk = "module_clk", 99 + .clk = "peripheral_clk", 100 100 .clocksource_rating = 200, 101 101 }; 102 102 ··· 127 127 .name = "TMU2", 128 128 .channel_offset = 0x1c, 129 129 .timer_bit = 2, 130 - .clk = "module_clk", 130 + .clk = "peripheral_clk", 131 131 }; 132 132 133 133 static struct resource tmu2_resources[] = { ··· 162 162 .name = "TMU3", 163 163 .channel_offset = 0x04, 164 164 .timer_bit = 0, 165 - .clk = "module_clk", 165 + .clk = "peripheral_clk", 166 166 }; 167 167 168 168 static struct resource tmu3_resources[] = { ··· 192 192 .name = "TMU4", 193 193 .channel_offset = 0x10, 194 194 .timer_bit = 1, 195 - .clk = "module_clk", 195 + .clk = "peripheral_clk", 196 196 }; 197 197 198 198 static struct resource tmu4_resources[] = {
+3 -3
arch/sh/kernel/cpu/sh4/setup-sh7760.c
··· 164 164 .name = "TMU0", 165 165 .channel_offset = 0x04, 166 166 .timer_bit = 0, 167 - .clk = "module_clk", 167 + .clk = "peripheral_clk", 168 168 .clockevent_rating = 200, 169 169 }; 170 170 ··· 195 195 .name = "TMU1", 196 196 .channel_offset = 0x10, 197 197 .timer_bit = 1, 198 - .clk = "module_clk", 198 + .clk = "peripheral_clk", 199 199 .clocksource_rating = 200, 200 200 }; 201 201 ··· 226 226 .name = "TMU2", 227 227 .channel_offset = 0x1c, 228 228 .timer_bit = 2, 229 - .clk = "module_clk", 229 + .clk = "peripheral_clk", 230 230 }; 231 231 232 232 static struct resource tmu2_resources[] = {
+206 -218
arch/sh/kernel/cpu/sh4a/clock-sh7722.c
··· 151 151 static int divisors2[] = { 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40 }; 152 152 #endif 153 153 154 - static void master_clk_recalc(struct clk *clk) 154 + static unsigned long master_clk_recalc(struct clk *clk) 155 155 { 156 156 unsigned frqcr = ctrl_inl(FRQCR); 157 157 158 - clk->rate = CONFIG_SH_PCLK_FREQ * STCPLL(frqcr); 158 + return CONFIG_SH_PCLK_FREQ * STCPLL(frqcr); 159 159 } 160 160 161 161 static void master_clk_init(struct clk *clk) 162 162 { 163 163 clk->parent = NULL; 164 - clk->flags |= CLK_RATE_PROPAGATES; 165 - clk->rate = CONFIG_SH_PCLK_FREQ; 166 - master_clk_recalc(clk); 164 + clk->rate = master_clk_recalc(clk); 167 165 } 168 166 169 - 170 - static void module_clk_recalc(struct clk *clk) 167 + static unsigned long module_clk_recalc(struct clk *clk) 171 168 { 172 169 unsigned long frqcr = ctrl_inl(FRQCR); 173 170 174 - clk->rate = clk->parent->rate / STCPLL(frqcr); 171 + return clk->parent->rate / STCPLL(frqcr); 175 172 } 176 173 177 174 #if defined(CONFIG_CPU_SUBTYPE_SH7724) ··· 280 283 return index; 281 284 } 282 285 283 - static void sh7722_frqcr_recalc(struct clk *clk) 286 + static unsigned long sh7722_frqcr_recalc(struct clk *clk) 284 287 { 285 288 struct frqcr_context ctx = sh7722_get_clk_context(clk->name); 286 289 unsigned long frqcr = ctrl_inl(FRQCR); 287 290 int index; 288 291 289 292 index = (frqcr >> ctx.shift) & ctx.mask; 290 - clk->rate = clk->parent->rate * 2 / divisors2[index]; 293 + return clk->parent->rate * 2 / divisors2[index]; 291 294 } 292 295 293 296 static int sh7722_frqcr_set_rate(struct clk *clk, unsigned long rate, ··· 436 439 437 440 /* 438 441 * clock ops methods for SIU A/B and IrDA clock 439 - * 440 442 */ 441 - 442 443 #ifndef CONFIG_CPU_SUBTYPE_SH7343 443 - 444 444 static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id) 445 445 { 446 446 unsigned long r; ··· 452 458 return 0; 453 459 } 454 460 455 - static void sh7722_siu_recalc(struct clk *clk) 461 + static unsigned long sh7722_siu_recalc(struct clk *clk) 456 462 { 457 463 unsigned long r; 458 464 459 465 r = ctrl_inl(clk->arch_flags); 460 - clk->rate = clk->parent->rate * 2 / divisors2[r & 0xF]; 466 + return clk->parent->rate * 2 / divisors2[r & 0xF]; 461 467 } 462 468 463 469 static int sh7722_siu_start_stop(struct clk *clk, int enable) ··· 472 478 return 0; 473 479 } 474 480 475 - static void sh7722_siu_enable(struct clk *clk) 481 + static int sh7722_siu_enable(struct clk *clk) 476 482 { 477 - sh7722_siu_start_stop(clk, 1); 483 + return sh7722_siu_start_stop(clk, 1); 478 484 } 479 485 480 486 static void sh7722_siu_disable(struct clk *clk) ··· 491 497 492 498 #endif /* CONFIG_CPU_SUBTYPE_SH7343 */ 493 499 494 - static void sh7722_video_enable(struct clk *clk) 500 + static int sh7722_video_enable(struct clk *clk) 495 501 { 496 502 unsigned long r; 497 503 498 504 r = ctrl_inl(VCLKCR); 499 505 ctrl_outl( r & ~(1<<8), VCLKCR); 506 + return 0; 500 507 } 501 508 502 509 static void sh7722_video_disable(struct clk *clk) ··· 520 525 return 0; 521 526 } 522 527 523 - static void sh7722_video_recalc(struct clk *clk) 528 + static unsigned long sh7722_video_recalc(struct clk *clk) 524 529 { 525 530 unsigned long r; 526 531 527 532 r = ctrl_inl(VCLKCR); 528 - clk->rate = clk->parent->rate / ((r & 0x3F) + 1); 533 + return clk->parent->rate / ((r & 0x3F) + 1); 529 534 } 530 535 531 536 static struct clk_ops sh7722_video_clk_ops = { ··· 540 545 static struct clk sh7722_umem_clock = { 541 546 .name = "umem_clk", 542 547 .ops = &sh7722_frqcr_clk_ops, 543 - .flags = CLK_RATE_PROPAGATES, 544 548 }; 545 549 546 550 static struct clk sh7722_sh_clock = { 547 551 .name = "sh_clk", 548 552 .ops = &sh7722_frqcr_clk_ops, 549 - .flags = CLK_RATE_PROPAGATES, 550 553 }; 551 554 552 555 static struct clk sh7722_peripheral_clock = { 553 556 .name = "peripheral_clk", 554 557 .ops = &sh7722_frqcr_clk_ops, 555 - .flags = CLK_RATE_PROPAGATES, 556 558 }; 557 559 558 560 static struct clk sh7722_sdram_clock = { ··· 560 568 static struct clk sh7722_r_clock = { 561 569 .name = "r_clk", 562 570 .rate = 32768, 563 - .flags = CLK_RATE_PROPAGATES, 564 571 }; 565 572 566 573 #if !defined(CONFIG_CPU_SUBTYPE_SH7343) &&\ ··· 618 627 break; 619 628 default: 620 629 return -EINVAL; 621 - } 630 + } 622 631 623 632 r = ctrl_inl(reg); 624 633 ··· 631 640 return 0; 632 641 } 633 642 634 - static void sh7722_mstpcr_enable(struct clk *clk) 643 + static int sh7722_mstpcr_enable(struct clk *clk) 635 644 { 636 - sh7722_mstpcr_start_stop(clk, 1); 645 + return sh7722_mstpcr_start_stop(clk, 1); 637 646 } 638 647 639 648 static void sh7722_mstpcr_disable(struct clk *clk) ··· 641 650 sh7722_mstpcr_start_stop(clk, 0); 642 651 } 643 652 644 - static void sh7722_mstpcr_recalc(struct clk *clk) 645 - { 646 - if (clk->parent) 647 - clk->rate = clk->parent->rate; 648 - } 649 - 650 653 static struct clk_ops sh7722_mstpcr_clk_ops = { 651 654 .enable = sh7722_mstpcr_enable, 652 655 .disable = sh7722_mstpcr_disable, 653 - .recalc = sh7722_mstpcr_recalc, 656 + .recalc = followparent_recalc, 654 657 }; 655 658 656 - #define MSTPCR(_name, _parent, regnr, bitnr) \ 659 + #define MSTPCR(_name, _parent, regnr, bitnr, _flags) \ 657 660 { \ 658 661 .name = _name, \ 662 + .flags = _flags, \ 659 663 .arch_flags = MSTPCR_ARCH_FLAGS(regnr, bitnr), \ 660 664 .ops = (void *)_parent, \ 661 665 } 662 666 663 667 static struct clk sh7722_mstpcr_clocks[] = { 664 668 #if defined(CONFIG_CPU_SUBTYPE_SH7722) 665 - MSTPCR("uram0", "umem_clk", 0, 28), 666 - MSTPCR("xymem0", "bus_clk", 0, 26), 667 - MSTPCR("tmu0", "peripheral_clk", 0, 15), 668 - MSTPCR("cmt0", "r_clk", 0, 14), 669 - MSTPCR("rwdt0", "r_clk", 0, 13), 670 - MSTPCR("flctl0", "peripheral_clk", 0, 10), 671 - MSTPCR("scif0", "peripheral_clk", 0, 7), 672 - MSTPCR("scif1", "peripheral_clk", 0, 6), 673 - MSTPCR("scif2", "peripheral_clk", 0, 5), 674 - MSTPCR("i2c0", "peripheral_clk", 1, 9), 675 - MSTPCR("rtc0", "r_clk", 1, 8), 676 - MSTPCR("sdhi0", "peripheral_clk", 2, 18), 677 - MSTPCR("keysc0", "r_clk", 2, 14), 678 - MSTPCR("usbf0", "peripheral_clk", 2, 11), 679 - MSTPCR("2dg0", "bus_clk", 2, 9), 680 - MSTPCR("siu0", "bus_clk", 2, 8), 681 - MSTPCR("vou0", "bus_clk", 2, 5), 682 - MSTPCR("jpu0", "bus_clk", 2, 6), 683 - MSTPCR("beu0", "bus_clk", 2, 4), 684 - MSTPCR("ceu0", "bus_clk", 2, 3), 685 - MSTPCR("veu0", "bus_clk", 2, 2), 686 - MSTPCR("vpu0", "bus_clk", 2, 1), 687 - MSTPCR("lcdc0", "bus_clk", 2, 0), 669 + MSTPCR("uram0", "umem_clk", 0, 28, CLK_ENABLE_ON_INIT), 670 + MSTPCR("xymem0", "bus_clk", 0, 26, CLK_ENABLE_ON_INIT), 671 + MSTPCR("tmu0", "peripheral_clk", 0, 15, 0), 672 + MSTPCR("cmt0", "r_clk", 0, 14, 0), 673 + MSTPCR("rwdt0", "r_clk", 0, 13, 0), 674 + MSTPCR("flctl0", "peripheral_clk", 0, 10, 0), 675 + MSTPCR("scif0", "peripheral_clk", 0, 7, 0), 676 + MSTPCR("scif1", "peripheral_clk", 0, 6, 0), 677 + MSTPCR("scif2", "peripheral_clk", 0, 5, 0), 678 + MSTPCR("i2c0", "peripheral_clk", 1, 9, 0), 679 + MSTPCR("rtc0", "r_clk", 1, 8, 0), 680 + MSTPCR("sdhi0", "peripheral_clk", 2, 18, 0), 681 + MSTPCR("keysc0", "r_clk", 2, 14, 0), 682 + MSTPCR("usbf0", "peripheral_clk", 2, 11, 0), 683 + MSTPCR("2dg0", "bus_clk", 2, 9, 0), 684 + MSTPCR("siu0", "bus_clk", 2, 8, 0), 685 + MSTPCR("vou0", "bus_clk", 2, 5, 0), 686 + MSTPCR("jpu0", "bus_clk", 2, 6, CLK_ENABLE_ON_INIT), 687 + MSTPCR("beu0", "bus_clk", 2, 4, 0), 688 + MSTPCR("ceu0", "bus_clk", 2, 3, 0), 689 + MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT), 690 + MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT), 691 + MSTPCR("lcdc0", "bus_clk", 2, 0, 0), 688 692 #endif 689 693 #if defined(CONFIG_CPU_SUBTYPE_SH7723) 690 694 /* See page 60 of Datasheet V1.0: Overview -> Block Diagram */ 691 - MSTPCR("tlb0", "cpu_clk", 0, 31), 692 - MSTPCR("ic0", "cpu_clk", 0, 30), 693 - MSTPCR("oc0", "cpu_clk", 0, 29), 694 - MSTPCR("l2c0", "sh_clk", 0, 28), 695 - MSTPCR("ilmem0", "cpu_clk", 0, 27), 696 - MSTPCR("fpu0", "cpu_clk", 0, 24), 697 - MSTPCR("intc0", "cpu_clk", 0, 22), 698 - MSTPCR("dmac0", "bus_clk", 0, 21), 699 - MSTPCR("sh0", "sh_clk", 0, 20), 700 - MSTPCR("hudi0", "peripheral_clk", 0, 19), 701 - MSTPCR("ubc0", "cpu_clk", 0, 17), 702 - MSTPCR("tmu0", "peripheral_clk", 0, 15), 703 - MSTPCR("cmt0", "r_clk", 0, 14), 704 - MSTPCR("rwdt0", "r_clk", 0, 13), 705 - MSTPCR("dmac1", "bus_clk", 0, 12), 706 - MSTPCR("tmu1", "peripheral_clk", 0, 11), 707 - MSTPCR("flctl0", "peripheral_clk", 0, 10), 708 - MSTPCR("scif0", "peripheral_clk", 0, 9), 709 - MSTPCR("scif1", "peripheral_clk", 0, 8), 710 - MSTPCR("scif2", "peripheral_clk", 0, 7), 711 - MSTPCR("scif3", "bus_clk", 0, 6), 712 - MSTPCR("scif4", "bus_clk", 0, 5), 713 - MSTPCR("scif5", "bus_clk", 0, 4), 714 - MSTPCR("msiof0", "bus_clk", 0, 2), 715 - MSTPCR("msiof1", "bus_clk", 0, 1), 716 - MSTPCR("meram0", "sh_clk", 0, 0), 717 - MSTPCR("i2c0", "peripheral_clk", 1, 9), 718 - MSTPCR("rtc0", "r_clk", 1, 8), 719 - MSTPCR("atapi0", "sh_clk", 2, 28), 720 - MSTPCR("adc0", "peripheral_clk", 2, 28), 721 - MSTPCR("tpu0", "bus_clk", 2, 25), 722 - MSTPCR("irda0", "peripheral_clk", 2, 24), 723 - MSTPCR("tsif0", "bus_clk", 2, 22), 724 - MSTPCR("icb0", "bus_clk", 2, 21), 725 - MSTPCR("sdhi0", "bus_clk", 2, 18), 726 - MSTPCR("sdhi1", "bus_clk", 2, 17), 727 - MSTPCR("keysc0", "r_clk", 2, 14), 728 - MSTPCR("usb0", "bus_clk", 2, 11), 729 - MSTPCR("2dg0", "bus_clk", 2, 10), 730 - MSTPCR("siu0", "bus_clk", 2, 8), 731 - MSTPCR("veu1", "bus_clk", 2, 6), 732 - MSTPCR("vou0", "bus_clk", 2, 5), 733 - MSTPCR("beu0", "bus_clk", 2, 4), 734 - MSTPCR("ceu0", "bus_clk", 2, 3), 735 - MSTPCR("veu0", "bus_clk", 2, 2), 736 - MSTPCR("vpu0", "bus_clk", 2, 1), 737 - MSTPCR("lcdc0", "bus_clk", 2, 0), 695 + MSTPCR("tlb0", "cpu_clk", 0, 31, 0), 696 + MSTPCR("ic0", "cpu_clk", 0, 30, 0), 697 + MSTPCR("oc0", "cpu_clk", 0, 29, 0), 698 + MSTPCR("l2c0", "sh_clk", 0, 28, 0), 699 + MSTPCR("ilmem0", "cpu_clk", 0, 27, 0), 700 + MSTPCR("fpu0", "cpu_clk", 0, 24, 0), 701 + MSTPCR("intc0", "cpu_clk", 0, 22, 0), 702 + MSTPCR("dmac0", "bus_clk", 0, 21, 0), 703 + MSTPCR("sh0", "sh_clk", 0, 20, 0), 704 + MSTPCR("hudi0", "peripheral_clk", 0, 19, 0), 705 + MSTPCR("ubc0", "cpu_clk", 0, 17, 0), 706 + MSTPCR("tmu0", "peripheral_clk", 0, 15, 0), 707 + MSTPCR("cmt0", "r_clk", 0, 14, 0), 708 + MSTPCR("rwdt0", "r_clk", 0, 13, 0), 709 + MSTPCR("dmac1", "bus_clk", 0, 12, 0), 710 + MSTPCR("tmu1", "peripheral_clk", 0, 11, 0), 711 + MSTPCR("flctl0", "peripheral_clk", 0, 10, 0), 712 + MSTPCR("scif0", "peripheral_clk", 0, 9, 0), 713 + MSTPCR("scif1", "peripheral_clk", 0, 8, 0), 714 + MSTPCR("scif2", "peripheral_clk", 0, 7, 0), 715 + MSTPCR("scif3", "bus_clk", 0, 6, 0), 716 + MSTPCR("scif4", "bus_clk", 0, 5, 0), 717 + MSTPCR("scif5", "bus_clk", 0, 4, 0), 718 + MSTPCR("msiof0", "bus_clk", 0, 2, 0), 719 + MSTPCR("msiof1", "bus_clk", 0, 1, 0), 720 + MSTPCR("meram0", "sh_clk", 0, 0, CLK_ENABLE_ON_INIT), 721 + MSTPCR("i2c0", "peripheral_clk", 1, 9, 0), 722 + MSTPCR("rtc0", "r_clk", 1, 8, 0), 723 + MSTPCR("atapi0", "sh_clk", 2, 28, 0), 724 + MSTPCR("adc0", "peripheral_clk", 2, 28, 0), 725 + MSTPCR("tpu0", "bus_clk", 2, 25, 0), 726 + MSTPCR("irda0", "peripheral_clk", 2, 24, 0), 727 + MSTPCR("tsif0", "bus_clk", 2, 22, 0), 728 + MSTPCR("icb0", "bus_clk", 2, 21, 0), 729 + MSTPCR("sdhi0", "bus_clk", 2, 18, 0), 730 + MSTPCR("sdhi1", "bus_clk", 2, 17, 0), 731 + MSTPCR("keysc0", "r_clk", 2, 14, 0), 732 + MSTPCR("usb0", "bus_clk", 2, 11, 0), 733 + MSTPCR("2dg0", "bus_clk", 2, 10, 0), 734 + MSTPCR("siu0", "bus_clk", 2, 8, 0), 735 + MSTPCR("veu1", "bus_clk", 2, 6, CLK_ENABLE_ON_INIT), 736 + MSTPCR("vou0", "bus_clk", 2, 5, 0), 737 + MSTPCR("beu0", "bus_clk", 2, 4, 0), 738 + MSTPCR("ceu0", "bus_clk", 2, 3, 0), 739 + MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT), 740 + MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT), 741 + MSTPCR("lcdc0", "bus_clk", 2, 0, 0), 738 742 #endif 739 743 #if defined(CONFIG_CPU_SUBTYPE_SH7724) 740 744 /* See Datasheet : Overview -> Block Diagram */ 741 - MSTPCR("tlb0", "cpu_clk", 0, 31), 742 - MSTPCR("ic0", "cpu_clk", 0, 30), 743 - MSTPCR("oc0", "cpu_clk", 0, 29), 744 - MSTPCR("rs0", "bus_clk", 0, 28), 745 - MSTPCR("ilmem0", "cpu_clk", 0, 27), 746 - MSTPCR("l2c0", "sh_clk", 0, 26), 747 - MSTPCR("fpu0", "cpu_clk", 0, 24), 748 - MSTPCR("intc0", "peripheral_clk", 0, 22), 749 - MSTPCR("dmac0", "bus_clk", 0, 21), 750 - MSTPCR("sh0", "sh_clk", 0, 20), 751 - MSTPCR("hudi0", "peripheral_clk", 0, 19), 752 - MSTPCR("ubc0", "cpu_clk", 0, 17), 753 - MSTPCR("tmu0", "peripheral_clk", 0, 15), 754 - MSTPCR("cmt0", "r_clk", 0, 14), 755 - MSTPCR("rwdt0", "r_clk", 0, 13), 756 - MSTPCR("dmac1", "bus_clk", 0, 12), 757 - MSTPCR("tmu1", "peripheral_clk", 0, 10), 758 - MSTPCR("scif0", "peripheral_clk", 0, 9), 759 - MSTPCR("scif1", "peripheral_clk", 0, 8), 760 - MSTPCR("scif2", "peripheral_clk", 0, 7), 761 - MSTPCR("scif3", "bus_clk", 0, 6), 762 - MSTPCR("scif4", "bus_clk", 0, 5), 763 - MSTPCR("scif5", "bus_clk", 0, 4), 764 - MSTPCR("msiof0", "bus_clk", 0, 2), 765 - MSTPCR("msiof1", "bus_clk", 0, 1), 766 - MSTPCR("keysc0", "r_clk", 1, 12), 767 - MSTPCR("rtc0", "r_clk", 1, 11), 768 - MSTPCR("i2c0", "peripheral_clk", 1, 9), 769 - MSTPCR("i2c1", "peripheral_clk", 1, 8), 770 - MSTPCR("mmc0", "bus_clk", 2, 29), 771 - MSTPCR("eth0", "bus_clk", 2, 28), 772 - MSTPCR("atapi0", "bus_clk", 2, 26), 773 - MSTPCR("tpu0", "bus_clk", 2, 25), 774 - MSTPCR("irda0", "peripheral_clk", 2, 24), 775 - MSTPCR("tsif0", "bus_clk", 2, 22), 776 - MSTPCR("usb1", "bus_clk", 2, 21), 777 - MSTPCR("usb0", "bus_clk", 2, 20), 778 - MSTPCR("2dg0", "bus_clk", 2, 19), 779 - MSTPCR("sdhi0", "bus_clk", 2, 18), 780 - MSTPCR("sdhi1", "bus_clk", 2, 17), 781 - MSTPCR("veu1", "bus_clk", 2, 15), 782 - MSTPCR("ceu1", "bus_clk", 2, 13), 783 - MSTPCR("beu1", "bus_clk", 2, 12), 784 - MSTPCR("2ddmac0", "sh_clk", 2, 10), 785 - MSTPCR("spu0", "bus_clk", 2, 9), 786 - MSTPCR("jpu0", "bus_clk", 2, 6), 787 - MSTPCR("vou0", "bus_clk", 2, 5), 788 - MSTPCR("beu0", "bus_clk", 2, 4), 789 - MSTPCR("ceu0", "bus_clk", 2, 3), 790 - MSTPCR("veu0", "bus_clk", 2, 2), 791 - MSTPCR("vpu0", "bus_clk", 2, 1), 792 - MSTPCR("lcdc0", "bus_clk", 2, 0), 745 + MSTPCR("tlb0", "cpu_clk", 0, 31, 0), 746 + MSTPCR("ic0", "cpu_clk", 0, 30, 0), 747 + MSTPCR("oc0", "cpu_clk", 0, 29, 0), 748 + MSTPCR("rs0", "bus_clk", 0, 28, 0), 749 + MSTPCR("ilmem0", "cpu_clk", 0, 27, 0), 750 + MSTPCR("l2c0", "sh_clk", 0, 26, 0), 751 + MSTPCR("fpu0", "cpu_clk", 0, 24, 0), 752 + MSTPCR("intc0", "peripheral_clk", 0, 22, 0), 753 + MSTPCR("dmac0", "bus_clk", 0, 21, 0), 754 + MSTPCR("sh0", "sh_clk", 0, 20, 0), 755 + MSTPCR("hudi0", "peripheral_clk", 0, 19, 0), 756 + MSTPCR("ubc0", "cpu_clk", 0, 17, 0), 757 + MSTPCR("tmu0", "peripheral_clk", 0, 15, 0), 758 + MSTPCR("cmt0", "r_clk", 0, 14, 0), 759 + MSTPCR("rwdt0", "r_clk", 0, 13, 0), 760 + MSTPCR("dmac1", "bus_clk", 0, 12, 0), 761 + MSTPCR("tmu1", "peripheral_clk", 0, 10, 0), 762 + MSTPCR("scif0", "peripheral_clk", 0, 9, 0), 763 + MSTPCR("scif1", "peripheral_clk", 0, 8, 0), 764 + MSTPCR("scif2", "peripheral_clk", 0, 7, 0), 765 + MSTPCR("scif3", "bus_clk", 0, 6, 0), 766 + MSTPCR("scif4", "bus_clk", 0, 5, 0), 767 + MSTPCR("scif5", "bus_clk", 0, 4, 0), 768 + MSTPCR("msiof0", "bus_clk", 0, 2, 0), 769 + MSTPCR("msiof1", "bus_clk", 0, 1, 0), 770 + MSTPCR("keysc0", "r_clk", 1, 12, 0), 771 + MSTPCR("rtc0", "r_clk", 1, 11, 0), 772 + MSTPCR("i2c0", "peripheral_clk", 1, 9, 0), 773 + MSTPCR("i2c1", "peripheral_clk", 1, 8, 0), 774 + MSTPCR("mmc0", "bus_clk", 2, 29, 0), 775 + MSTPCR("eth0", "bus_clk", 2, 28, 0), 776 + MSTPCR("atapi0", "bus_clk", 2, 26, 0), 777 + MSTPCR("tpu0", "bus_clk", 2, 25, 0), 778 + MSTPCR("irda0", "peripheral_clk", 2, 24, 0), 779 + MSTPCR("tsif0", "bus_clk", 2, 22, 0), 780 + MSTPCR("usb1", "bus_clk", 2, 21, 0), 781 + MSTPCR("usb0", "bus_clk", 2, 20, 0), 782 + MSTPCR("2dg0", "bus_clk", 2, 19, 0), 783 + MSTPCR("sdhi0", "bus_clk", 2, 18, 0), 784 + MSTPCR("sdhi1", "bus_clk", 2, 17, 0), 785 + MSTPCR("veu1", "bus_clk", 2, 15, CLK_ENABLE_ON_INIT), 786 + MSTPCR("ceu1", "bus_clk", 2, 13, 0), 787 + MSTPCR("beu1", "bus_clk", 2, 12, 0), 788 + MSTPCR("2ddmac0", "sh_clk", 2, 10, 0), 789 + MSTPCR("spu0", "bus_clk", 2, 9, 0), 790 + MSTPCR("jpu0", "bus_clk", 2, 6, 0), 791 + MSTPCR("vou0", "bus_clk", 2, 5, 0), 792 + MSTPCR("beu0", "bus_clk", 2, 4, 0), 793 + MSTPCR("ceu0", "bus_clk", 2, 3, 0), 794 + MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT), 795 + MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT), 796 + MSTPCR("lcdc0", "bus_clk", 2, 0, 0), 793 797 #endif 794 798 #if defined(CONFIG_CPU_SUBTYPE_SH7343) 795 - MSTPCR("uram0", "umem_clk", 0, 28), 796 - MSTPCR("xymem0", "bus_clk", 0, 26), 797 - MSTPCR("tmu0", "peripheral_clk", 0, 15), 798 - MSTPCR("cmt0", "r_clk", 0, 14), 799 - MSTPCR("rwdt0", "r_clk", 0, 13), 800 - MSTPCR("scif0", "peripheral_clk", 0, 7), 801 - MSTPCR("scif1", "peripheral_clk", 0, 6), 802 - MSTPCR("scif2", "peripheral_clk", 0, 5), 803 - MSTPCR("scif3", "peripheral_clk", 0, 4), 804 - MSTPCR("i2c0", "peripheral_clk", 1, 9), 805 - MSTPCR("i2c1", "peripheral_clk", 1, 8), 806 - MSTPCR("sdhi0", "peripheral_clk", 2, 18), 807 - MSTPCR("keysc0", "r_clk", 2, 14), 808 - MSTPCR("usbf0", "peripheral_clk", 2, 11), 809 - MSTPCR("siu0", "bus_clk", 2, 8), 810 - MSTPCR("jpu0", "bus_clk", 2, 6), 811 - MSTPCR("vou0", "bus_clk", 2, 5), 812 - MSTPCR("beu0", "bus_clk", 2, 4), 813 - MSTPCR("ceu0", "bus_clk", 2, 3), 814 - MSTPCR("veu0", "bus_clk", 2, 2), 815 - MSTPCR("vpu0", "bus_clk", 2, 1), 816 - MSTPCR("lcdc0", "bus_clk", 2, 0), 799 + MSTPCR("uram0", "umem_clk", 0, 28, CLK_ENABLE_ON_INIT), 800 + MSTPCR("xymem0", "bus_clk", 0, 26, CLK_ENABLE_ON_INIT), 801 + MSTPCR("tmu0", "peripheral_clk", 0, 15, 0), 802 + MSTPCR("cmt0", "r_clk", 0, 14, 0), 803 + MSTPCR("rwdt0", "r_clk", 0, 13, 0), 804 + MSTPCR("scif0", "peripheral_clk", 0, 7, 0), 805 + MSTPCR("scif1", "peripheral_clk", 0, 6, 0), 806 + MSTPCR("scif2", "peripheral_clk", 0, 5, 0), 807 + MSTPCR("scif3", "peripheral_clk", 0, 4, 0), 808 + MSTPCR("i2c0", "peripheral_clk", 1, 9, 0), 809 + MSTPCR("i2c1", "peripheral_clk", 1, 8, 0), 810 + MSTPCR("sdhi0", "peripheral_clk", 2, 18, 0), 811 + MSTPCR("keysc0", "r_clk", 2, 14, 0), 812 + MSTPCR("usbf0", "peripheral_clk", 2, 11, 0), 813 + MSTPCR("siu0", "bus_clk", 2, 8, 0), 814 + MSTPCR("jpu0", "bus_clk", 2, 6, CLK_ENABLE_ON_INIT), 815 + MSTPCR("vou0", "bus_clk", 2, 5, 0), 816 + MSTPCR("beu0", "bus_clk", 2, 4, 0), 817 + MSTPCR("ceu0", "bus_clk", 2, 3, 0), 818 + MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT), 819 + MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT), 820 + MSTPCR("lcdc0", "bus_clk", 2, 0, 0), 817 821 #endif 818 822 #if defined(CONFIG_CPU_SUBTYPE_SH7366) 819 823 /* See page 52 of Datasheet V0.40: Overview -> Block Diagram */ 820 - MSTPCR("tlb0", "cpu_clk", 0, 31), 821 - MSTPCR("ic0", "cpu_clk", 0, 30), 822 - MSTPCR("oc0", "cpu_clk", 0, 29), 823 - MSTPCR("rsmem0", "sh_clk", 0, 28), 824 - MSTPCR("xymem0", "cpu_clk", 0, 26), 825 - MSTPCR("intc30", "peripheral_clk", 0, 23), 826 - MSTPCR("intc0", "peripheral_clk", 0, 22), 827 - MSTPCR("dmac0", "bus_clk", 0, 21), 828 - MSTPCR("sh0", "sh_clk", 0, 20), 829 - MSTPCR("hudi0", "peripheral_clk", 0, 19), 830 - MSTPCR("ubc0", "cpu_clk", 0, 17), 831 - MSTPCR("tmu0", "peripheral_clk", 0, 15), 832 - MSTPCR("cmt0", "r_clk", 0, 14), 833 - MSTPCR("rwdt0", "r_clk", 0, 13), 834 - MSTPCR("flctl0", "peripheral_clk", 0, 10), 835 - MSTPCR("scif0", "peripheral_clk", 0, 7), 836 - MSTPCR("scif1", "bus_clk", 0, 6), 837 - MSTPCR("scif2", "bus_clk", 0, 5), 838 - MSTPCR("msiof0", "peripheral_clk", 0, 2), 839 - MSTPCR("sbr0", "peripheral_clk", 0, 1), 840 - MSTPCR("i2c0", "peripheral_clk", 1, 9), 841 - MSTPCR("icb0", "bus_clk", 2, 27), 842 - MSTPCR("meram0", "sh_clk", 2, 26), 843 - MSTPCR("dacc0", "peripheral_clk", 2, 24), 844 - MSTPCR("dacy0", "peripheral_clk", 2, 23), 845 - MSTPCR("tsif0", "bus_clk", 2, 22), 846 - MSTPCR("sdhi0", "bus_clk", 2, 18), 847 - MSTPCR("mmcif0", "bus_clk", 2, 17), 848 - MSTPCR("usb0", "bus_clk", 2, 11), 849 - MSTPCR("siu0", "bus_clk", 2, 8), 850 - MSTPCR("veu1", "bus_clk", 2, 7), 851 - MSTPCR("vou0", "bus_clk", 2, 5), 852 - MSTPCR("beu0", "bus_clk", 2, 4), 853 - MSTPCR("ceu0", "bus_clk", 2, 3), 854 - MSTPCR("veu0", "bus_clk", 2, 2), 855 - MSTPCR("vpu0", "bus_clk", 2, 1), 856 - MSTPCR("lcdc0", "bus_clk", 2, 0), 824 + MSTPCR("tlb0", "cpu_clk", 0, 31, 0), 825 + MSTPCR("ic0", "cpu_clk", 0, 30, 0), 826 + MSTPCR("oc0", "cpu_clk", 0, 29, 0), 827 + MSTPCR("rsmem0", "sh_clk", 0, 28, CLK_ENABLE_ON_INIT), 828 + MSTPCR("xymem0", "cpu_clk", 0, 26, CLK_ENABLE_ON_INIT), 829 + MSTPCR("intc30", "peripheral_clk", 0, 23, 0), 830 + MSTPCR("intc0", "peripheral_clk", 0, 22, 0), 831 + MSTPCR("dmac0", "bus_clk", 0, 21, 0), 832 + MSTPCR("sh0", "sh_clk", 0, 20, 0), 833 + MSTPCR("hudi0", "peripheral_clk", 0, 19, 0), 834 + MSTPCR("ubc0", "cpu_clk", 0, 17, 0), 835 + MSTPCR("tmu0", "peripheral_clk", 0, 15, 0), 836 + MSTPCR("cmt0", "r_clk", 0, 14, 0), 837 + MSTPCR("rwdt0", "r_clk", 0, 13, 0), 838 + MSTPCR("flctl0", "peripheral_clk", 0, 10, 0), 839 + MSTPCR("scif0", "peripheral_clk", 0, 7, 0), 840 + MSTPCR("scif1", "bus_clk", 0, 6, 0), 841 + MSTPCR("scif2", "bus_clk", 0, 5, 0), 842 + MSTPCR("msiof0", "peripheral_clk", 0, 2, 0), 843 + MSTPCR("sbr0", "peripheral_clk", 0, 1, 0), 844 + MSTPCR("i2c0", "peripheral_clk", 1, 9, 0), 845 + MSTPCR("icb0", "bus_clk", 2, 27, 0), 846 + MSTPCR("meram0", "sh_clk", 2, 26, 0), 847 + MSTPCR("dacc0", "peripheral_clk", 2, 24, 0), 848 + MSTPCR("dacy0", "peripheral_clk", 2, 23, 0), 849 + MSTPCR("tsif0", "bus_clk", 2, 22, 0), 850 + MSTPCR("sdhi0", "bus_clk", 2, 18, 0), 851 + MSTPCR("mmcif0", "bus_clk", 2, 17, 0), 852 + MSTPCR("usb0", "bus_clk", 2, 11, 0), 853 + MSTPCR("siu0", "bus_clk", 2, 8, 0), 854 + MSTPCR("veu1", "bus_clk", 2, 7, CLK_ENABLE_ON_INIT), 855 + MSTPCR("vou0", "bus_clk", 2, 5, 0), 856 + MSTPCR("beu0", "bus_clk", 2, 4, 0), 857 + MSTPCR("ceu0", "bus_clk", 2, 3, 0), 858 + MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT), 859 + MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT), 860 + MSTPCR("lcdc0", "bus_clk", 2, 0, 0), 857 861 #endif 858 862 }; 859 863 ··· 883 897 void __init 884 898 arch_init_clk_ops(struct clk_ops **ops, int type) 885 899 { 886 - BUG_ON(type < 0 || type > ARRAY_SIZE(onchip_ops)); 900 + BUG_ON(type < 0 || type >= ARRAY_SIZE(onchip_ops)); 887 901 *ops = onchip_ops[type]; 888 902 } 889 903 ··· 891 905 { 892 906 struct clk *clk; 893 907 int i; 908 + 909 + cpg_clk_init(); 894 910 895 911 clk = clk_get(NULL, "master_clk"); 896 912 for (i = 0; i < ARRAY_SIZE(sh7722_clocks); i++) { ··· 914 926 clk_put(clk); 915 927 } 916 928 917 - clk_recalc_rate(&sh7722_r_clock); /* make sure rate gets propagated */ 929 + propagate_rate(&sh7722_r_clock); /* make sure rate gets propagated */ 918 930 919 931 return 0; 920 932 }
+16 -30
arch/sh/kernel/cpu/sh4a/clock-sh7763.c
··· 29 29 .init = master_clk_init, 30 30 }; 31 31 32 - static void module_clk_recalc(struct clk *clk) 32 + static unsigned long module_clk_recalc(struct clk *clk) 33 33 { 34 34 int idx = ((ctrl_inl(FRQCR) >> 4) & 0x07); 35 - clk->rate = clk->parent->rate / p0fc_divisors[idx]; 35 + return clk->parent->rate / p0fc_divisors[idx]; 36 36 } 37 37 38 38 static struct clk_ops sh7763_module_clk_ops = { 39 39 .recalc = module_clk_recalc, 40 40 }; 41 41 42 - static void bus_clk_recalc(struct clk *clk) 42 + static unsigned long bus_clk_recalc(struct clk *clk) 43 43 { 44 44 int idx = ((ctrl_inl(FRQCR) >> 16) & 0x07); 45 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 45 + return clk->parent->rate / bfc_divisors[idx]; 46 46 } 47 47 48 48 static struct clk_ops sh7763_bus_clk_ops = { 49 49 .recalc = bus_clk_recalc, 50 50 }; 51 51 52 - static void cpu_clk_recalc(struct clk *clk) 53 - { 54 - clk->rate = clk->parent->rate; 55 - } 56 - 57 52 static struct clk_ops sh7763_cpu_clk_ops = { 58 - .recalc = cpu_clk_recalc, 53 + .recalc = followparent_recalc, 59 54 }; 60 55 61 56 static struct clk_ops *sh7763_clk_ops[] = { ··· 66 71 *ops = sh7763_clk_ops[idx]; 67 72 } 68 73 69 - static void shyway_clk_recalc(struct clk *clk) 74 + static unsigned long shyway_clk_recalc(struct clk *clk) 70 75 { 71 76 int idx = ((ctrl_inl(FRQCR) >> 20) & 0x07); 72 - clk->rate = clk->parent->rate / cfc_divisors[idx]; 77 + return clk->parent->rate / cfc_divisors[idx]; 73 78 } 74 79 75 80 static struct clk_ops sh7763_shyway_clk_ops = { ··· 78 83 79 84 static struct clk sh7763_shyway_clk = { 80 85 .name = "shyway_clk", 81 - .flags = CLK_ALWAYS_ENABLED, 86 + .flags = CLK_ENABLE_ON_INIT, 82 87 .ops = &sh7763_shyway_clk_ops, 83 88 }; 84 89 ··· 90 95 &sh7763_shyway_clk, 91 96 }; 92 97 93 - static int __init sh7763_clk_init(void) 98 + int __init arch_clk_init(void) 94 99 { 95 - struct clk *clk = clk_get(NULL, "master_clk"); 96 - int i; 100 + struct clk *clk; 101 + int i, ret = 0; 97 102 103 + cpg_clk_init(); 104 + 105 + clk = clk_get(NULL, "master_clk"); 98 106 for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) { 99 107 struct clk *clkp = sh7763_onchip_clocks[i]; 100 108 101 109 clkp->parent = clk; 102 - clk_register(clkp); 103 - clk_enable(clkp); 110 + ret |= clk_register(clkp); 104 111 } 105 - 106 - /* 107 - * Now that we have the rest of the clocks registered, we need to 108 - * force the parent clock to propagate so that these clocks will 109 - * automatically figure out their rate. We cheat by handing the 110 - * parent clock its current rate and forcing child propagation. 111 - */ 112 - clk_set_rate(clk, clk_get_rate(clk)); 113 112 114 113 clk_put(clk); 115 114 116 - return 0; 115 + return ret; 117 116 } 118 - 119 - arch_initcall(sh7763_clk_init); 120 -
+6 -6
arch/sh/kernel/cpu/sh4a/clock-sh7770.c
··· 28 28 .init = master_clk_init, 29 29 }; 30 30 31 - static void module_clk_recalc(struct clk *clk) 31 + static unsigned long module_clk_recalc(struct clk *clk) 32 32 { 33 33 int idx = ((ctrl_inl(FRQCR) >> 28) & 0x000f); 34 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 34 + return clk->parent->rate / pfc_divisors[idx]; 35 35 } 36 36 37 37 static struct clk_ops sh7770_module_clk_ops = { 38 38 .recalc = module_clk_recalc, 39 39 }; 40 40 41 - static void bus_clk_recalc(struct clk *clk) 41 + static unsigned long bus_clk_recalc(struct clk *clk) 42 42 { 43 43 int idx = (ctrl_inl(FRQCR) & 0x000f); 44 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 44 + return clk->parent->rate / bfc_divisors[idx]; 45 45 } 46 46 47 47 static struct clk_ops sh7770_bus_clk_ops = { 48 48 .recalc = bus_clk_recalc, 49 49 }; 50 50 51 - static void cpu_clk_recalc(struct clk *clk) 51 + static unsigned long cpu_clk_recalc(struct clk *clk) 52 52 { 53 53 int idx = ((ctrl_inl(FRQCR) >> 24) & 0x000f); 54 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 54 + return clk->parent->rate / ifc_divisors[idx]; 55 55 } 56 56 57 57 static struct clk_ops sh7770_cpu_clk_ops = {
+17 -26
arch/sh/kernel/cpu/sh4a/clock-sh7780.c
··· 29 29 .init = master_clk_init, 30 30 }; 31 31 32 - static void module_clk_recalc(struct clk *clk) 32 + static unsigned long module_clk_recalc(struct clk *clk) 33 33 { 34 34 int idx = (ctrl_inl(FRQCR) & 0x0003); 35 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 35 + return clk->parent->rate / pfc_divisors[idx]; 36 36 } 37 37 38 38 static struct clk_ops sh7780_module_clk_ops = { 39 39 .recalc = module_clk_recalc, 40 40 }; 41 41 42 - static void bus_clk_recalc(struct clk *clk) 42 + static unsigned long bus_clk_recalc(struct clk *clk) 43 43 { 44 44 int idx = ((ctrl_inl(FRQCR) >> 16) & 0x0007); 45 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 45 + return clk->parent->rate / bfc_divisors[idx]; 46 46 } 47 47 48 48 static struct clk_ops sh7780_bus_clk_ops = { 49 49 .recalc = bus_clk_recalc, 50 50 }; 51 51 52 - static void cpu_clk_recalc(struct clk *clk) 52 + static unsigned long cpu_clk_recalc(struct clk *clk) 53 53 { 54 54 int idx = ((ctrl_inl(FRQCR) >> 24) & 0x0001); 55 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 55 + return clk->parent->rate / ifc_divisors[idx]; 56 56 } 57 57 58 58 static struct clk_ops sh7780_cpu_clk_ops = { ··· 72 72 *ops = sh7780_clk_ops[idx]; 73 73 } 74 74 75 - static void shyway_clk_recalc(struct clk *clk) 75 + static unsigned long shyway_clk_recalc(struct clk *clk) 76 76 { 77 77 int idx = ((ctrl_inl(FRQCR) >> 20) & 0x0007); 78 - clk->rate = clk->parent->rate / cfc_divisors[idx]; 78 + return clk->parent->rate / cfc_divisors[idx]; 79 79 } 80 80 81 81 static struct clk_ops sh7780_shyway_clk_ops = { ··· 84 84 85 85 static struct clk sh7780_shyway_clk = { 86 86 .name = "shyway_clk", 87 - .flags = CLK_ALWAYS_ENABLED, 87 + .flags = CLK_ENABLE_ON_INIT, 88 88 .ops = &sh7780_shyway_clk_ops, 89 89 }; 90 90 ··· 96 96 &sh7780_shyway_clk, 97 97 }; 98 98 99 - static int __init sh7780_clk_init(void) 99 + int __init arch_clk_init(void) 100 100 { 101 - struct clk *clk = clk_get(NULL, "master_clk"); 102 - int i; 101 + struct clk *clk; 102 + int i, ret = 0; 103 103 104 + cpg_clk_init(); 105 + 106 + clk = clk_get(NULL, "master_clk"); 104 107 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { 105 108 struct clk *clkp = sh7780_onchip_clocks[i]; 106 109 107 110 clkp->parent = clk; 108 - clk_register(clkp); 109 - clk_enable(clkp); 111 + ret |= clk_register(clkp); 110 112 } 111 - 112 - /* 113 - * Now that we have the rest of the clocks registered, we need to 114 - * force the parent clock to propagate so that these clocks will 115 - * automatically figure out their rate. We cheat by handing the 116 - * parent clock its current rate and forcing child propagation. 117 - */ 118 - clk_set_rate(clk, clk_get_rate(clk)); 119 113 120 114 clk_put(clk); 121 115 122 - return 0; 116 + return ret; 123 117 } 124 - 125 - arch_initcall(sh7780_clk_init); 126 -
+228 -123
arch/sh/kernel/cpu/sh4a/clock-sh7785.c
··· 3 3 * 4 4 * SH7785 support for the clock framework 5 5 * 6 - * Copyright (C) 2007 Paul Mundt 6 + * Copyright (C) 2007 - 2009 Paul Mundt 7 7 * 8 8 * This file is subject to the terms and conditions of the GNU General Public 9 9 * License. See the file "COPYING" in the main directory of this archive ··· 11 11 */ 12 12 #include <linux/init.h> 13 13 #include <linux/kernel.h> 14 + #include <linux/clk.h> 15 + #include <linux/io.h> 16 + #include <linux/cpufreq.h> 14 17 #include <asm/clock.h> 15 18 #include <asm/freq.h> 16 - #include <asm/io.h> 17 19 18 - static int ifc_divisors[] = { 1, 2, 4, 6 }; 19 - static int ufc_divisors[] = { 1, 1, 4, 6 }; 20 - static int sfc_divisors[] = { 1, 1, 4, 6 }; 21 - static int bfc_divisors[] = { 1, 1, 1, 1, 1, 12, 16, 18, 22 - 24, 32, 36, 48, 1, 1, 1, 1 }; 23 - static int mfc_divisors[] = { 1, 1, 4, 6 }; 24 - static int pfc_divisors[] = { 1, 1, 1, 1, 1, 1, 1, 18, 25 - 24, 32, 36, 48, 1, 1, 1, 1 }; 20 + static unsigned int div2[] = { 1, 2, 4, 6, 8, 12, 16, 18, 21 + 24, 32, 36, 48 }; 26 22 27 - static void master_clk_init(struct clk *clk) 28 - { 29 - clk->rate *= pfc_divisors[ctrl_inl(FRQMR1) & 0x000f]; 23 + static struct clk_div_mult_table cpg_div = { 24 + .divisors = div2, 25 + .nr_divisors = ARRAY_SIZE(div2), 26 + }; 27 + 28 + struct clk_priv { 29 + unsigned int shift; 30 + 31 + /* allowable divisor bitmap */ 32 + unsigned long div_bitmap; 33 + 34 + /* Supportable frequencies + termination entry */ 35 + struct cpufreq_frequency_table freq_table[ARRAY_SIZE(div2)+1]; 36 + }; 37 + 38 + #define FRQMR_CLK_DATA(_name, _shift, _div_bitmap) \ 39 + static struct clk_priv _name##_data = { \ 40 + .shift = _shift, \ 41 + .div_bitmap = _div_bitmap, \ 42 + \ 43 + .freq_table[0] = { \ 44 + .index = 0, \ 45 + .frequency = CPUFREQ_TABLE_END, \ 46 + }, \ 30 47 } 31 48 32 - static struct clk_ops sh7785_master_clk_ops = { 33 - .init = master_clk_init, 34 - }; 49 + FRQMR_CLK_DATA(pfc, 0, 0x0f80); 50 + FRQMR_CLK_DATA(s3fc, 4, 0x0ff0); 51 + FRQMR_CLK_DATA(s2fc, 8, 0x0030); 52 + FRQMR_CLK_DATA(mfc, 12, 0x000c); 53 + FRQMR_CLK_DATA(bfc, 16, 0x0fe0); 54 + FRQMR_CLK_DATA(sfc, 20, 0x000c); 55 + FRQMR_CLK_DATA(ufc, 24, 0x000c); 56 + FRQMR_CLK_DATA(ifc, 28, 0x000e); 35 57 36 - static void module_clk_recalc(struct clk *clk) 58 + static unsigned long frqmr_recalc(struct clk *clk) 37 59 { 38 - int idx = (ctrl_inl(FRQMR1) & 0x000f); 39 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 60 + struct clk_priv *data = clk->priv; 61 + unsigned int idx = (__raw_readl(FRQMR1) >> data->shift) & 0x000f; 62 + 63 + clk_rate_table_build(clk, data->freq_table, ARRAY_SIZE(div2), 64 + &cpg_div, &data->div_bitmap); 65 + 66 + return data->freq_table[idx].frequency; 40 67 } 41 68 42 - static struct clk_ops sh7785_module_clk_ops = { 43 - .recalc = module_clk_recalc, 44 - }; 45 - 46 - static void bus_clk_recalc(struct clk *clk) 69 + static long frqmr_round_rate(struct clk *clk, unsigned long rate) 47 70 { 48 - int idx = ((ctrl_inl(FRQMR1) >> 16) & 0x000f); 49 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 71 + struct clk_priv *data = clk->priv; 72 + 73 + return clk_rate_table_round(clk, data->freq_table, rate); 50 74 } 51 75 52 - static struct clk_ops sh7785_bus_clk_ops = { 53 - .recalc = bus_clk_recalc, 76 + static struct clk_ops frqmr_clk_ops = { 77 + .recalc = frqmr_recalc, 78 + .round_rate = frqmr_round_rate, 54 79 }; 55 80 56 - static void cpu_clk_recalc(struct clk *clk) 81 + static unsigned long pll_recalc(struct clk *clk) 57 82 { 58 - int idx = ((ctrl_inl(FRQMR1) >> 28) & 0x0003); 59 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 83 + /* 84 + * XXX: PLL1 multiplier is locked for the default clock mode, 85 + * when mode pin detection and configuration support is added, 86 + * select the multiplier dynamically. 87 + */ 88 + return clk->parent->rate * 36; 60 89 } 61 90 62 - static struct clk_ops sh7785_cpu_clk_ops = { 63 - .recalc = cpu_clk_recalc, 64 - }; 65 - 66 - static struct clk_ops *sh7785_clk_ops[] = { 67 - &sh7785_master_clk_ops, 68 - &sh7785_module_clk_ops, 69 - &sh7785_bus_clk_ops, 70 - &sh7785_cpu_clk_ops, 71 - }; 72 - 73 - void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 74 - { 75 - if (idx < ARRAY_SIZE(sh7785_clk_ops)) 76 - *ops = sh7785_clk_ops[idx]; 77 - } 78 - 79 - static void shyway_clk_recalc(struct clk *clk) 80 - { 81 - int idx = ((ctrl_inl(FRQMR1) >> 20) & 0x0003); 82 - clk->rate = clk->parent->rate / sfc_divisors[idx]; 83 - } 84 - 85 - static struct clk_ops sh7785_shyway_clk_ops = { 86 - .recalc = shyway_clk_recalc, 87 - }; 88 - 89 - static struct clk sh7785_shyway_clk = { 90 - .name = "shyway_clk", 91 - .flags = CLK_ALWAYS_ENABLED, 92 - .ops = &sh7785_shyway_clk_ops, 93 - }; 94 - 95 - static void ddr_clk_recalc(struct clk *clk) 96 - { 97 - int idx = ((ctrl_inl(FRQMR1) >> 12) & 0x0003); 98 - clk->rate = clk->parent->rate / mfc_divisors[idx]; 99 - } 100 - 101 - static struct clk_ops sh7785_ddr_clk_ops = { 102 - .recalc = ddr_clk_recalc, 103 - }; 104 - 105 - static struct clk sh7785_ddr_clk = { 106 - .name = "ddr_clk", 107 - .flags = CLK_ALWAYS_ENABLED, 108 - .ops = &sh7785_ddr_clk_ops, 109 - }; 110 - 111 - static void ram_clk_recalc(struct clk *clk) 112 - { 113 - int idx = ((ctrl_inl(FRQMR1) >> 24) & 0x0003); 114 - clk->rate = clk->parent->rate / ufc_divisors[idx]; 115 - } 116 - 117 - static struct clk_ops sh7785_ram_clk_ops = { 118 - .recalc = ram_clk_recalc, 119 - }; 120 - 121 - static struct clk sh7785_ram_clk = { 122 - .name = "ram_clk", 123 - .flags = CLK_ALWAYS_ENABLED, 124 - .ops = &sh7785_ram_clk_ops, 91 + static struct clk_ops pll_clk_ops = { 92 + .recalc = pll_recalc, 125 93 }; 126 94 127 95 /* 128 - * Additional SH7785-specific on-chip clocks that aren't already part of the 129 - * clock framework 96 + * Default rate for the root input clock, reset this with clk_set_rate() 97 + * from the platform code. 130 98 */ 131 - static struct clk *sh7785_onchip_clocks[] = { 132 - &sh7785_shyway_clk, 133 - &sh7785_ddr_clk, 134 - &sh7785_ram_clk, 99 + static struct clk extal_clk = { 100 + .name = "extal", 101 + .id = -1, 102 + .rate = 33333333, 135 103 }; 136 104 137 - static int __init sh7785_clk_init(void) 105 + static struct clk pll_clk = { 106 + .name = "pll_clk", 107 + .id = -1, 108 + .ops = &pll_clk_ops, 109 + .parent = &extal_clk, 110 + .flags = CLK_ENABLE_ON_INIT, 111 + }; 112 + 113 + static struct clk cpu_clk = { 114 + .name = "cpu_clk", /* Ick */ 115 + .id = -1, 116 + .ops = &frqmr_clk_ops, 117 + .parent = &pll_clk, 118 + .flags = CLK_ENABLE_ON_INIT, 119 + .priv = &ifc_data, 120 + }; 121 + 122 + static struct clk shyway_clk = { 123 + .name = "shyway_clk", /* SHck */ 124 + .id = -1, 125 + .ops = &frqmr_clk_ops, 126 + .parent = &pll_clk, 127 + .flags = CLK_ENABLE_ON_INIT, 128 + .priv = &sfc_data, 129 + }; 130 + 131 + static struct clk peripheral_clk = { 132 + .name = "peripheral_clk", /* Pck */ 133 + .id = -1, 134 + .ops = &frqmr_clk_ops, 135 + .parent = &pll_clk, 136 + .flags = CLK_ENABLE_ON_INIT, 137 + .priv = &pfc_data, 138 + }; 139 + 140 + static struct clk ddr_clk = { 141 + .name = "ddr_clk", /* DDRck */ 142 + .id = -1, 143 + .ops = &frqmr_clk_ops, 144 + .parent = &pll_clk, 145 + .flags = CLK_ENABLE_ON_INIT, 146 + .priv = &mfc_data, 147 + }; 148 + 149 + static struct clk bus_clk = { 150 + .name = "bus_clk", /* Bck */ 151 + .id = -1, 152 + .ops = &frqmr_clk_ops, 153 + .parent = &pll_clk, 154 + .flags = CLK_ENABLE_ON_INIT, 155 + .priv = &bfc_data, 156 + }; 157 + 158 + static struct clk ga_clk = { 159 + .name = "ga_clk", /* GAck */ 160 + .id = -1, 161 + .ops = &frqmr_clk_ops, 162 + .parent = &pll_clk, 163 + .priv = &s2fc_data, 164 + }; 165 + 166 + static struct clk du_clk = { 167 + .name = "du_clk", /* DUck */ 168 + .id = -1, 169 + .ops = &frqmr_clk_ops, 170 + .parent = &pll_clk, 171 + .priv = &s3fc_data, 172 + }; 173 + 174 + static struct clk umem_clk = { 175 + .name = "umem_clk", /* uck */ 176 + .id = -1, 177 + .ops = &frqmr_clk_ops, 178 + .parent = &pll_clk, 179 + .flags = CLK_ENABLE_ON_INIT, 180 + .priv = &ufc_data, 181 + }; 182 + 183 + static struct clk *clks[] = { 184 + &extal_clk, 185 + &pll_clk, 186 + &cpu_clk, 187 + &shyway_clk, 188 + &peripheral_clk, 189 + &ddr_clk, 190 + &bus_clk, 191 + &ga_clk, 192 + &du_clk, 193 + &umem_clk, 194 + }; 195 + 196 + static int mstpcr_clk_enable(struct clk *clk) 138 197 { 139 - struct clk *clk = clk_get(NULL, "master_clk"); 140 - int i; 141 - 142 - for (i = 0; i < ARRAY_SIZE(sh7785_onchip_clocks); i++) { 143 - struct clk *clkp = sh7785_onchip_clocks[i]; 144 - 145 - clkp->parent = clk; 146 - clk_register(clkp); 147 - clk_enable(clkp); 148 - } 149 - 150 - /* 151 - * Now that we have the rest of the clocks registered, we need to 152 - * force the parent clock to propagate so that these clocks will 153 - * automatically figure out their rate. We cheat by handing the 154 - * parent clock its current rate and forcing child propagation. 155 - */ 156 - clk_set_rate(clk, clk_get_rate(clk)); 157 - 158 - clk_put(clk); 159 - 198 + __raw_writel(__raw_readl(clk->enable_reg) & ~(1 << clk->enable_bit), 199 + clk->enable_reg); 160 200 return 0; 161 201 } 162 - arch_initcall(sh7785_clk_init); 202 + 203 + static void mstpcr_clk_disable(struct clk *clk) 204 + { 205 + __raw_writel(__raw_readl(clk->enable_reg) | (1 << clk->enable_bit), 206 + clk->enable_reg); 207 + } 208 + 209 + static struct clk_ops mstpcr_clk_ops = { 210 + .enable = mstpcr_clk_enable, 211 + .disable = mstpcr_clk_disable, 212 + .recalc = followparent_recalc, 213 + }; 214 + 215 + #define MSTPCR0 0xffc80030 216 + #define MSTPCR1 0xffc80034 217 + 218 + #define CLK(_name, _id, _parent, _enable_reg, \ 219 + _enable_bit, _flags) \ 220 + { \ 221 + .name = _name, \ 222 + .id = _id, \ 223 + .parent = _parent, \ 224 + .enable_reg = (void __iomem *)_enable_reg, \ 225 + .enable_bit = _enable_bit, \ 226 + .flags = _flags, \ 227 + .ops = &mstpcr_clk_ops, \ 228 + } 229 + 230 + static struct clk mstpcr_clks[] = { 231 + /* MSTPCR0 */ 232 + CLK("scif_fck", 5, &peripheral_clk, MSTPCR0, 29, 0), 233 + CLK("scif_fck", 4, &peripheral_clk, MSTPCR0, 28, 0), 234 + CLK("scif_fck", 3, &peripheral_clk, MSTPCR0, 27, 0), 235 + CLK("scif_fck", 2, &peripheral_clk, MSTPCR0, 26, 0), 236 + CLK("scif_fck", 1, &peripheral_clk, MSTPCR0, 25, 0), 237 + CLK("scif_fck", 0, &peripheral_clk, MSTPCR0, 24, 0), 238 + CLK("ssi_fck", 1, &peripheral_clk, MSTPCR0, 21, 0), 239 + CLK("ssi_fck", 0, &peripheral_clk, MSTPCR0, 20, 0), 240 + CLK("hac_fck", 1, &peripheral_clk, MSTPCR0, 17, 0), 241 + CLK("hac_fck", 0, &peripheral_clk, MSTPCR0, 16, 0), 242 + CLK("mmcif_fck", -1, &peripheral_clk, MSTPCR0, 13, 0), 243 + CLK("flctl_fck", -1, &peripheral_clk, MSTPCR0, 12, 0), 244 + CLK("tmu345_fck", -1, &peripheral_clk, MSTPCR0, 9, 0), 245 + CLK("tmu012_fck", -1, &peripheral_clk, MSTPCR0, 8, 0), 246 + CLK("siof_fck", -1, &peripheral_clk, MSTPCR0, 3, 0), 247 + CLK("hspi_fck", -1, &peripheral_clk, MSTPCR0, 2, 0), 248 + 249 + /* MSTPCR1 */ 250 + CLK("hudi_fck", -1, NULL, MSTPCR1, 19, 0), 251 + CLK("ubc_fck", -1, NULL, MSTPCR1, 17, 0), 252 + CLK("dmac_11_6_fck", -1, NULL, MSTPCR1, 5, 0), 253 + CLK("dmac_5_0_fck", -1, NULL, MSTPCR1, 4, 0), 254 + CLK("gdta_fck", -1, NULL, MSTPCR1, 0, 0), 255 + }; 256 + 257 + int __init arch_clk_init(void) 258 + { 259 + int i, ret = 0; 260 + 261 + for (i = 0; i < ARRAY_SIZE(clks); i++) 262 + ret |= clk_register(clks[i]); 263 + for (i = 0; i < ARRAY_SIZE(mstpcr_clks); i++) 264 + ret |= clk_register(&mstpcr_clks[i]); 265 + 266 + return ret; 267 + }
+20 -27
arch/sh/kernel/cpu/sh4a/clock-sh7786.c
··· 36 36 .init = master_clk_init, 37 37 }; 38 38 39 - static void module_clk_recalc(struct clk *clk) 39 + static unsigned long module_clk_recalc(struct clk *clk) 40 40 { 41 41 int idx = (ctrl_inl(FRQMR1) & 0x000f); 42 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 42 + return clk->parent->rate / pfc_divisors[idx]; 43 43 } 44 44 45 45 static struct clk_ops sh7786_module_clk_ops = { 46 46 .recalc = module_clk_recalc, 47 47 }; 48 48 49 - static void bus_clk_recalc(struct clk *clk) 49 + static unsigned long bus_clk_recalc(struct clk *clk) 50 50 { 51 51 int idx = ((ctrl_inl(FRQMR1) >> 16) & 0x000f); 52 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 52 + return clk->parent->rate / bfc_divisors[idx]; 53 53 } 54 54 55 55 static struct clk_ops sh7786_bus_clk_ops = { 56 56 .recalc = bus_clk_recalc, 57 57 }; 58 58 59 - static void cpu_clk_recalc(struct clk *clk) 59 + static unsigned long cpu_clk_recalc(struct clk *clk) 60 60 { 61 61 int idx = ((ctrl_inl(FRQMR1) >> 28) & 0x0003); 62 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 62 + return clk->parent->rate / ifc_divisors[idx]; 63 63 } 64 64 65 65 static struct clk_ops sh7786_cpu_clk_ops = { ··· 79 79 *ops = sh7786_clk_ops[idx]; 80 80 } 81 81 82 - static void shyway_clk_recalc(struct clk *clk) 82 + static unsigned long shyway_clk_recalc(struct clk *clk) 83 83 { 84 84 int idx = ((ctrl_inl(FRQMR1) >> 20) & 0x0003); 85 - clk->rate = clk->parent->rate / sfc_divisors[idx]; 85 + return clk->parent->rate / sfc_divisors[idx]; 86 86 } 87 87 88 88 static struct clk_ops sh7786_shyway_clk_ops = { ··· 91 91 92 92 static struct clk sh7786_shyway_clk = { 93 93 .name = "shyway_clk", 94 - .flags = CLK_ALWAYS_ENABLED, 94 + .flags = CLK_ENABLE_ON_INIT, 95 95 .ops = &sh7786_shyway_clk_ops, 96 96 }; 97 97 98 - static void ddr_clk_recalc(struct clk *clk) 98 + static unsigned long ddr_clk_recalc(struct clk *clk) 99 99 { 100 100 int idx = ((ctrl_inl(FRQMR1) >> 12) & 0x0003); 101 - clk->rate = clk->parent->rate / mfc_divisors[idx]; 101 + return clk->parent->rate / mfc_divisors[idx]; 102 102 } 103 103 104 104 static struct clk_ops sh7786_ddr_clk_ops = { ··· 107 107 108 108 static struct clk sh7786_ddr_clk = { 109 109 .name = "ddr_clk", 110 - .flags = CLK_ALWAYS_ENABLED, 110 + .flags = CLK_ENABLE_ON_INIT, 111 111 .ops = &sh7786_ddr_clk_ops, 112 112 }; 113 113 ··· 120 120 &sh7786_ddr_clk, 121 121 }; 122 122 123 - static int __init sh7786_clk_init(void) 123 + int __init arch_clk_init(void) 124 124 { 125 - struct clk *clk = clk_get(NULL, "master_clk"); 126 - int i; 125 + struct clk *clk; 126 + int i, ret = 0; 127 127 128 + cpg_clk_init(); 129 + 130 + clk = clk_get(NULL, "master_clk"); 128 131 for (i = 0; i < ARRAY_SIZE(sh7786_onchip_clocks); i++) { 129 132 struct clk *clkp = sh7786_onchip_clocks[i]; 130 133 131 134 clkp->parent = clk; 132 - clk_register(clkp); 133 - clk_enable(clkp); 135 + ret |= clk_register(clkp); 134 136 } 135 - 136 - /* 137 - * Now that we have the rest of the clocks registered, we need to 138 - * force the parent clock to propagate so that these clocks will 139 - * automatically figure out their rate. We cheat by handing the 140 - * parent clock its current rate and forcing child propagation. 141 - */ 142 - clk_set_rate(clk, clk_get_rate(clk)); 143 137 144 138 clk_put(clk); 145 139 146 - return 0; 140 + return ret; 147 141 } 148 - arch_initcall(sh7786_clk_init);
+17 -24
arch/sh/kernel/cpu/sh4a/clock-shx3.c
··· 40 40 .init = master_clk_init, 41 41 }; 42 42 43 - static void module_clk_recalc(struct clk *clk) 43 + static unsigned long module_clk_recalc(struct clk *clk) 44 44 { 45 45 int idx = ((ctrl_inl(FRQCR) >> PFC_POS) & PFC_MSK); 46 - clk->rate = clk->parent->rate / pfc_divisors[idx]; 46 + return clk->parent->rate / pfc_divisors[idx]; 47 47 } 48 48 49 49 static struct clk_ops shx3_module_clk_ops = { 50 50 .recalc = module_clk_recalc, 51 51 }; 52 52 53 - static void bus_clk_recalc(struct clk *clk) 53 + static unsigned long bus_clk_recalc(struct clk *clk) 54 54 { 55 55 int idx = ((ctrl_inl(FRQCR) >> BFC_POS) & BFC_MSK); 56 - clk->rate = clk->parent->rate / bfc_divisors[idx]; 56 + return clk->parent->rate / bfc_divisors[idx]; 57 57 } 58 58 59 59 static struct clk_ops shx3_bus_clk_ops = { 60 60 .recalc = bus_clk_recalc, 61 61 }; 62 62 63 - static void cpu_clk_recalc(struct clk *clk) 63 + static unsigned long cpu_clk_recalc(struct clk *clk) 64 64 { 65 65 int idx = ((ctrl_inl(FRQCR) >> IFC_POS) & IFC_MSK); 66 - clk->rate = clk->parent->rate / ifc_divisors[idx]; 66 + return clk->parent->rate / ifc_divisors[idx]; 67 67 } 68 68 69 69 static struct clk_ops shx3_cpu_clk_ops = { ··· 83 83 *ops = shx3_clk_ops[idx]; 84 84 } 85 85 86 - static void shyway_clk_recalc(struct clk *clk) 86 + static unsigned long shyway_clk_recalc(struct clk *clk) 87 87 { 88 88 int idx = ((ctrl_inl(FRQCR) >> CFC_POS) & CFC_MSK); 89 - clk->rate = clk->parent->rate / cfc_divisors[idx]; 89 + return clk->parent->rate / cfc_divisors[idx]; 90 90 } 91 91 92 92 static struct clk_ops shx3_shyway_clk_ops = { ··· 95 95 96 96 static struct clk shx3_shyway_clk = { 97 97 .name = "shyway_clk", 98 - .flags = CLK_ALWAYS_ENABLED, 98 + .flags = CLK_ENABLE_ON_INIT, 99 99 .ops = &shx3_shyway_clk_ops, 100 100 }; 101 101 ··· 107 107 &shx3_shyway_clk, 108 108 }; 109 109 110 - static int __init shx3_clk_init(void) 110 + int __init arch_clk_init(void) 111 111 { 112 - struct clk *clk = clk_get(NULL, "master_clk"); 113 - int i; 112 + struct clk *clk; 113 + int i, ret = 0; 114 114 115 + cpg_clk_init(); 116 + 117 + clk = clk_get(NULL, "master_clk"); 115 118 for (i = 0; i < ARRAY_SIZE(shx3_onchip_clocks); i++) { 116 119 struct clk *clkp = shx3_onchip_clocks[i]; 117 120 118 121 clkp->parent = clk; 119 - clk_register(clkp); 120 - clk_enable(clkp); 122 + ret |= clk_register(clkp); 121 123 } 122 - 123 - /* 124 - * Now that we have the rest of the clocks registered, we need to 125 - * force the parent clock to propagate so that these clocks will 126 - * automatically figure out their rate. We cheat by handing the 127 - * parent clock its current rate and forcing child propagation. 128 - */ 129 - clk_set_rate(clk, clk_get_rate(clk)); 130 124 131 125 clk_put(clk); 132 126 133 - return 0; 127 + return ret; 134 128 } 135 - arch_initcall(shx3_clk_init);
-6
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
··· 318 318 319 319 static int __init sh7343_devices_setup(void) 320 320 { 321 - clk_always_enable("uram0"); /* URAM */ 322 - clk_always_enable("xymem0"); /* XYMEM */ 323 - clk_always_enable("veu0"); /* VEU */ 324 - clk_always_enable("vpu0"); /* VPU */ 325 - clk_always_enable("jpu0"); /* JPU */ 326 - 327 321 platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20); 328 322 platform_resource_setup_memory(&veu_device, "veu", 2 << 20); 329 323 platform_resource_setup_memory(&jpu_device, "jpu", 2 << 20);
-6
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
··· 307 307 308 308 static int __init sh7366_devices_setup(void) 309 309 { 310 - clk_always_enable("rsmem0"); /* RSMEM */ 311 - clk_always_enable("xymem0"); /* XYMEM */ 312 - clk_always_enable("veu1"); /* VEU-2 */ 313 - clk_always_enable("veu0"); /* VEU-1 */ 314 - clk_always_enable("vpu0"); /* VPU */ 315 - 316 310 platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20); 317 311 platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20); 318 312 platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
-6
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
··· 352 352 353 353 static int __init sh7722_devices_setup(void) 354 354 { 355 - clk_always_enable("uram0"); /* URAM */ 356 - clk_always_enable("xymem0"); /* XYMEM */ 357 - clk_always_enable("veu0"); /* VEU */ 358 - clk_always_enable("vpu0"); /* VPU */ 359 - clk_always_enable("jpu0"); /* JPU */ 360 - 361 355 platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20); 362 356 platform_resource_setup_memory(&veu_device, "veu", 2 << 20); 363 357 platform_resource_setup_memory(&jpu_device, "jpu", 2 << 20);
-5
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
··· 460 460 461 461 static int __init sh7723_devices_setup(void) 462 462 { 463 - clk_always_enable("meram0"); /* MERAM */ 464 - clk_always_enable("veu1"); /* VEU2H1 */ 465 - clk_always_enable("veu0"); /* VEU2H0 */ 466 - clk_always_enable("vpu0"); /* VPU */ 467 - 468 463 platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20); 469 464 platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20); 470 465 platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
-4
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
··· 470 470 471 471 static int __init sh7724_devices_setup(void) 472 472 { 473 - clk_always_enable("vpu0"); /* VPU */ 474 - clk_always_enable("veu1"); /* VEU3F1 */ 475 - clk_always_enable("veu0"); /* VEU3F0 */ 476 - 477 473 platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20); 478 474 platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20); 479 475 platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
+6 -6
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
··· 118 118 .name = "TMU0", 119 119 .channel_offset = 0x04, 120 120 .timer_bit = 0, 121 - .clk = "module_clk", 121 + .clk = "peripheral_clk", 122 122 .clockevent_rating = 200, 123 123 }; 124 124 ··· 149 149 .name = "TMU1", 150 150 .channel_offset = 0x10, 151 151 .timer_bit = 1, 152 - .clk = "module_clk", 152 + .clk = "peripheral_clk", 153 153 .clocksource_rating = 200, 154 154 }; 155 155 ··· 180 180 .name = "TMU2", 181 181 .channel_offset = 0x1c, 182 182 .timer_bit = 2, 183 - .clk = "module_clk", 183 + .clk = "peripheral_clk", 184 184 }; 185 185 186 186 static struct resource tmu2_resources[] = { ··· 210 210 .name = "TMU3", 211 211 .channel_offset = 0x04, 212 212 .timer_bit = 0, 213 - .clk = "module_clk", 213 + .clk = "peripheral_clk", 214 214 }; 215 215 216 216 static struct resource tmu3_resources[] = { ··· 240 240 .name = "TMU4", 241 241 .channel_offset = 0x10, 242 242 .timer_bit = 1, 243 - .clk = "module_clk", 243 + .clk = "peripheral_clk", 244 244 }; 245 245 246 246 static struct resource tmu4_resources[] = { ··· 270 270 .name = "TMU5", 271 271 .channel_offset = 0x1c, 272 272 .timer_bit = 2, 273 - .clk = "module_clk", 273 + .clk = "peripheral_clk", 274 274 }; 275 275 276 276 static struct resource tmu5_resources[] = {
+9 -9
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
··· 82 82 .name = "TMU0", 83 83 .channel_offset = 0x04, 84 84 .timer_bit = 0, 85 - .clk = "module_clk", 85 + .clk = "peripheral_clk", 86 86 .clockevent_rating = 200, 87 87 }; 88 88 ··· 113 113 .name = "TMU1", 114 114 .channel_offset = 0x10, 115 115 .timer_bit = 1, 116 - .clk = "module_clk", 116 + .clk = "peripheral_clk", 117 117 .clocksource_rating = 200, 118 118 }; 119 119 ··· 144 144 .name = "TMU2", 145 145 .channel_offset = 0x1c, 146 146 .timer_bit = 2, 147 - .clk = "module_clk", 147 + .clk = "peripheral_clk", 148 148 }; 149 149 150 150 static struct resource tmu2_resources[] = { ··· 174 174 .name = "TMU3", 175 175 .channel_offset = 0x04, 176 176 .timer_bit = 0, 177 - .clk = "module_clk", 177 + .clk = "peripheral_clk", 178 178 }; 179 179 180 180 static struct resource tmu3_resources[] = { ··· 204 204 .name = "TMU4", 205 205 .channel_offset = 0x10, 206 206 .timer_bit = 1, 207 - .clk = "module_clk", 207 + .clk = "peripheral_clk", 208 208 }; 209 209 210 210 static struct resource tmu4_resources[] = { ··· 234 234 .name = "TMU5", 235 235 .channel_offset = 0x1c, 236 236 .timer_bit = 2, 237 - .clk = "module_clk", 237 + .clk = "peripheral_clk", 238 238 }; 239 239 240 240 static struct resource tmu5_resources[] = { ··· 264 264 .name = "TMU6", 265 265 .channel_offset = 0x04, 266 266 .timer_bit = 0, 267 - .clk = "module_clk", 267 + .clk = "peripheral_clk", 268 268 }; 269 269 270 270 static struct resource tmu6_resources[] = { ··· 294 294 .name = "TMU7", 295 295 .channel_offset = 0x10, 296 296 .timer_bit = 1, 297 - .clk = "module_clk", 297 + .clk = "peripheral_clk", 298 298 }; 299 299 300 300 static struct resource tmu7_resources[] = { ··· 324 324 .name = "TMU8", 325 325 .channel_offset = 0x1c, 326 326 .timer_bit = 2, 327 - .clk = "module_clk", 327 + .clk = "peripheral_clk", 328 328 }; 329 329 330 330 static struct resource tmu8_resources[] = {
+6 -6
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
··· 18 18 .name = "TMU0", 19 19 .channel_offset = 0x04, 20 20 .timer_bit = 0, 21 - .clk = "module_clk", 21 + .clk = "peripheral_clk", 22 22 .clockevent_rating = 200, 23 23 }; 24 24 ··· 49 49 .name = "TMU1", 50 50 .channel_offset = 0x10, 51 51 .timer_bit = 1, 52 - .clk = "module_clk", 52 + .clk = "peripheral_clk", 53 53 .clocksource_rating = 200, 54 54 }; 55 55 ··· 80 80 .name = "TMU2", 81 81 .channel_offset = 0x1c, 82 82 .timer_bit = 2, 83 - .clk = "module_clk", 83 + .clk = "peripheral_clk", 84 84 }; 85 85 86 86 static struct resource tmu2_resources[] = { ··· 110 110 .name = "TMU3", 111 111 .channel_offset = 0x04, 112 112 .timer_bit = 0, 113 - .clk = "module_clk", 113 + .clk = "peripheral_clk", 114 114 }; 115 115 116 116 static struct resource tmu3_resources[] = { ··· 140 140 .name = "TMU4", 141 141 .channel_offset = 0x10, 142 142 .timer_bit = 1, 143 - .clk = "module_clk", 143 + .clk = "peripheral_clk", 144 144 }; 145 145 146 146 static struct resource tmu4_resources[] = { ··· 170 170 .name = "TMU5", 171 171 .channel_offset = 0x1c, 172 172 .timer_bit = 2, 173 - .clk = "module_clk", 173 + .clk = "peripheral_clk", 174 174 }; 175 175 176 176 static struct resource tmu5_resources[] = {
+12 -6
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
··· 20 20 .name = "TMU0", 21 21 .channel_offset = 0x04, 22 22 .timer_bit = 0, 23 - .clk = "module_clk", 23 + .clk = "tmu012_fck", 24 24 .clockevent_rating = 200, 25 25 }; 26 26 ··· 51 51 .name = "TMU1", 52 52 .channel_offset = 0x10, 53 53 .timer_bit = 1, 54 - .clk = "module_clk", 54 + .clk = "tmu012_fck", 55 55 .clocksource_rating = 200, 56 56 }; 57 57 ··· 82 82 .name = "TMU2", 83 83 .channel_offset = 0x1c, 84 84 .timer_bit = 2, 85 - .clk = "module_clk", 85 + .clk = "tmu012_fck", 86 86 }; 87 87 88 88 static struct resource tmu2_resources[] = { ··· 112 112 .name = "TMU3", 113 113 .channel_offset = 0x04, 114 114 .timer_bit = 0, 115 - .clk = "module_clk", 115 + .clk = "tmu345_fck", 116 116 }; 117 117 118 118 static struct resource tmu3_resources[] = { ··· 142 142 .name = "TMU4", 143 143 .channel_offset = 0x10, 144 144 .timer_bit = 1, 145 - .clk = "module_clk", 145 + .clk = "tmu345_fck", 146 146 }; 147 147 148 148 static struct resource tmu4_resources[] = { ··· 172 172 .name = "TMU5", 173 173 .channel_offset = 0x1c, 174 174 .timer_bit = 2, 175 - .clk = "module_clk", 175 + .clk = "tmu345_fck", 176 176 }; 177 177 178 178 static struct resource tmu5_resources[] = { ··· 204 204 .flags = UPF_BOOT_AUTOCONF, 205 205 .type = PORT_SCIF, 206 206 .irqs = { 40, 40, 40, 40 }, 207 + .clk = "scif_fck", 207 208 }, { 208 209 .mapbase = 0xffeb0000, 209 210 .flags = UPF_BOOT_AUTOCONF, 210 211 .type = PORT_SCIF, 211 212 .irqs = { 44, 44, 44, 44 }, 213 + .clk = "scif_fck", 212 214 }, { 213 215 .mapbase = 0xffec0000, 214 216 .flags = UPF_BOOT_AUTOCONF, 215 217 .type = PORT_SCIF, 216 218 .irqs = { 60, 60, 60, 60 }, 219 + .clk = "scif_fck", 217 220 }, { 218 221 .mapbase = 0xffed0000, 219 222 .flags = UPF_BOOT_AUTOCONF, 220 223 .type = PORT_SCIF, 221 224 .irqs = { 61, 61, 61, 61 }, 225 + .clk = "scif_fck", 222 226 }, { 223 227 .mapbase = 0xffee0000, 224 228 .flags = UPF_BOOT_AUTOCONF, 225 229 .type = PORT_SCIF, 226 230 .irqs = { 62, 62, 62, 62 }, 231 + .clk = "scif_fck", 227 232 }, { 228 233 .mapbase = 0xffef0000, 229 234 .flags = UPF_BOOT_AUTOCONF, 230 235 .type = PORT_SCIF, 231 236 .irqs = { 63, 63, 63, 63 }, 237 + .clk = "scif_fck", 232 238 }, { 233 239 .flags = 0, 234 240 }
+12 -12
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
··· 75 75 .name = "TMU0", 76 76 .channel_offset = 0x04, 77 77 .timer_bit = 0, 78 - .clk = "module_clk", 78 + .clk = "peripheral_clk", 79 79 .clockevent_rating = 200, 80 80 }; 81 81 ··· 106 106 .name = "TMU1", 107 107 .channel_offset = 0x10, 108 108 .timer_bit = 1, 109 - .clk = "module_clk", 109 + .clk = "peripheral_clk", 110 110 .clocksource_rating = 200, 111 111 }; 112 112 ··· 137 137 .name = "TMU2", 138 138 .channel_offset = 0x1c, 139 139 .timer_bit = 2, 140 - .clk = "module_clk", 140 + .clk = "peripheral_clk", 141 141 }; 142 142 143 143 static struct resource tmu2_resources[] = { ··· 167 167 .name = "TMU3", 168 168 .channel_offset = 0x04, 169 169 .timer_bit = 0, 170 - .clk = "module_clk", 170 + .clk = "peripheral_clk", 171 171 }; 172 172 173 173 static struct resource tmu3_resources[] = { ··· 197 197 .name = "TMU4", 198 198 .channel_offset = 0x10, 199 199 .timer_bit = 1, 200 - .clk = "module_clk", 200 + .clk = "peripheral_clk", 201 201 }; 202 202 203 203 static struct resource tmu4_resources[] = { ··· 227 227 .name = "TMU5", 228 228 .channel_offset = 0x1c, 229 229 .timer_bit = 2, 230 - .clk = "module_clk", 230 + .clk = "peripheral_clk", 231 231 }; 232 232 233 233 static struct resource tmu5_resources[] = { ··· 257 257 .name = "TMU6", 258 258 .channel_offset = 0x04, 259 259 .timer_bit = 0, 260 - .clk = "module_clk", 260 + .clk = "peripheral_clk", 261 261 }; 262 262 263 263 static struct resource tmu6_resources[] = { ··· 287 287 .name = "TMU7", 288 288 .channel_offset = 0x10, 289 289 .timer_bit = 1, 290 - .clk = "module_clk", 290 + .clk = "peripheral_clk", 291 291 }; 292 292 293 293 static struct resource tmu7_resources[] = { ··· 317 317 .name = "TMU8", 318 318 .channel_offset = 0x1c, 319 319 .timer_bit = 2, 320 - .clk = "module_clk", 320 + .clk = "peripheral_clk", 321 321 }; 322 322 323 323 static struct resource tmu8_resources[] = { ··· 347 347 .name = "TMU9", 348 348 .channel_offset = 0x04, 349 349 .timer_bit = 0, 350 - .clk = "module_clk", 350 + .clk = "peripheral_clk", 351 351 }; 352 352 353 353 static struct resource tmu9_resources[] = { ··· 377 377 .name = "TMU10", 378 378 .channel_offset = 0x10, 379 379 .timer_bit = 1, 380 - .clk = "module_clk", 380 + .clk = "peripheral_clk", 381 381 }; 382 382 383 383 static struct resource tmu10_resources[] = { ··· 407 407 .name = "TMU11", 408 408 .channel_offset = 0x1c, 409 409 .timer_bit = 2, 410 - .clk = "module_clk", 410 + .clk = "peripheral_clk", 411 411 }; 412 412 413 413 static struct resource tmu11_resources[] = {
+6 -6
arch/sh/kernel/cpu/sh4a/setup-shx3.c
··· 53 53 .name = "TMU0", 54 54 .channel_offset = 0x04, 55 55 .timer_bit = 0, 56 - .clk = "module_clk", 56 + .clk = "peripheral_clk", 57 57 .clockevent_rating = 200, 58 58 }; 59 59 ··· 84 84 .name = "TMU1", 85 85 .channel_offset = 0x10, 86 86 .timer_bit = 1, 87 - .clk = "module_clk", 87 + .clk = "peripheral_clk", 88 88 .clocksource_rating = 200, 89 89 }; 90 90 ··· 115 115 .name = "TMU2", 116 116 .channel_offset = 0x1c, 117 117 .timer_bit = 2, 118 - .clk = "module_clk", 118 + .clk = "peripheral_clk", 119 119 }; 120 120 121 121 static struct resource tmu2_resources[] = { ··· 145 145 .name = "TMU3", 146 146 .channel_offset = 0x04, 147 147 .timer_bit = 0, 148 - .clk = "module_clk", 148 + .clk = "peripheral_clk", 149 149 }; 150 150 151 151 static struct resource tmu3_resources[] = { ··· 175 175 .name = "TMU4", 176 176 .channel_offset = 0x10, 177 177 .timer_bit = 1, 178 - .clk = "module_clk", 178 + .clk = "peripheral_clk", 179 179 }; 180 180 181 181 static struct resource tmu4_resources[] = { ··· 205 205 .name = "TMU5", 206 206 .channel_offset = 0x1c, 207 207 .timer_bit = 2, 208 - .clk = "module_clk", 208 + .clk = "peripheral_clk", 209 209 }; 210 210 211 211 static struct resource tmu5_resources[] = {
+6 -6
arch/sh/kernel/cpu/sh5/clock-sh5.c
··· 32 32 .init = master_clk_init, 33 33 }; 34 34 35 - static void module_clk_recalc(struct clk *clk) 35 + static unsigned long module_clk_recalc(struct clk *clk) 36 36 { 37 37 int idx = (ctrl_inw(cprc_base) >> 12) & 0x0007; 38 - clk->rate = clk->parent->rate / ifc_table[idx]; 38 + return clk->parent->rate / ifc_table[idx]; 39 39 } 40 40 41 41 static struct clk_ops sh5_module_clk_ops = { 42 42 .recalc = module_clk_recalc, 43 43 }; 44 44 45 - static void bus_clk_recalc(struct clk *clk) 45 + static unsigned long bus_clk_recalc(struct clk *clk) 46 46 { 47 47 int idx = (ctrl_inw(cprc_base) >> 3) & 0x0007; 48 - clk->rate = clk->parent->rate / ifc_table[idx]; 48 + return clk->parent->rate / ifc_table[idx]; 49 49 } 50 50 51 51 static struct clk_ops sh5_bus_clk_ops = { 52 52 .recalc = bus_clk_recalc, 53 53 }; 54 54 55 - static void cpu_clk_recalc(struct clk *clk) 55 + static unsigned long cpu_clk_recalc(struct clk *clk) 56 56 { 57 57 int idx = (ctrl_inw(cprc_base) & 0x0007); 58 - clk->rate = clk->parent->rate / ifc_table[idx]; 58 + return clk->parent->rate / ifc_table[idx]; 59 59 } 60 60 61 61 static struct clk_ops sh5_cpu_clk_ops = {
+3 -3
arch/sh/kernel/cpu/sh5/setup-sh5.c
··· 75 75 .name = "TMU0", 76 76 .channel_offset = 0x04, 77 77 .timer_bit = 0, 78 - .clk = "module_clk", 78 + .clk = "peripheral_clk", 79 79 .clockevent_rating = 200, 80 80 }; 81 81 ··· 106 106 .name = "TMU1", 107 107 .channel_offset = 0x10, 108 108 .timer_bit = 1, 109 - .clk = "module_clk", 109 + .clk = "peripheral_clk", 110 110 .clocksource_rating = 200, 111 111 }; 112 112 ··· 137 137 .name = "TMU2", 138 138 .channel_offset = 0x1c, 139 139 .timer_bit = 2, 140 - .clk = "module_clk", 140 + .clk = "peripheral_clk", 141 141 }; 142 142 143 143 static struct resource tmu2_resources[] = {
+1 -1
drivers/i2c/busses/i2c-sh7760.c
··· 396 396 signed char cdf, cdfm; 397 397 int scgd, scgdm, scgds; 398 398 399 - mclk = clk_get(NULL, "module_clk"); 399 + mclk = clk_get(NULL, "peripheral_clk"); 400 400 if (IS_ERR(mclk)) { 401 401 return PTR_ERR(mclk); 402 402 } else {
+1 -1
drivers/serial/sh-sci.c
··· 1084 1084 sci_port->port.uartclk = CONFIG_CPU_CLOCK; 1085 1085 #elif defined(CONFIG_HAVE_CLK) 1086 1086 sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; 1087 - sci_port->dclk = clk_get(&dev->dev, "module_clk"); 1087 + sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); 1088 1088 sci_port->enable = sci_clk_enable; 1089 1089 sci_port->disable = sci_clk_disable; 1090 1090 #else