diff options
author | Paul Mundt <lethal@linux-sh.org> | 2006-11-30 23:15:14 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-12-05 20:45:40 -0500 |
commit | 1d118562c2067a42d0e8f70671a4ce27d7c6ffee (patch) | |
tree | fa59028397143d7fa94d86785bee8443efe30798 | |
parent | e74b56800e78a10bc09b56a87831876a1d9d09ae (diff) |
sh: Clock framework tidying.
This syncs up the SH clock framework with the linux/clk.h API,
for which there were only some minor changes required, namely
the clk_get() dev_id and subsequent callsites.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/kernel/cpu/clock.c | 27 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh3/clock-sh7709.c | 2 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4/clock-sh4-202.c | 4 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh4/clock-sh7780.c | 2 | ||||
-rw-r--r-- | arch/sh/kernel/timers/timer-cmt.c | 4 | ||||
-rw-r--r-- | arch/sh/kernel/timers/timer-mtu2.c | 2 | ||||
-rw-r--r-- | arch/sh/kernel/timers/timer-tmu.c | 2 | ||||
-rw-r--r-- | drivers/serial/sh-sci.c | 6 | ||||
-rw-r--r-- | include/asm-sh/clock.h | 12 |
9 files changed, 38 insertions, 23 deletions
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c index 51ec64cdf348..abb586b12565 100644 --- a/arch/sh/kernel/cpu/clock.c +++ b/arch/sh/kernel/cpu/clock.c | |||
@@ -5,9 +5,11 @@ | |||
5 | * | 5 | * |
6 | * This clock framework is derived from the OMAP version by: | 6 | * This clock framework is derived from the OMAP version by: |
7 | * | 7 | * |
8 | * Copyright (C) 2004 Nokia Corporation | 8 | * Copyright (C) 2004 - 2005 Nokia Corporation |
9 | * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> | 9 | * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> |
10 | * | 10 | * |
11 | * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com> | ||
12 | * | ||
11 | * This file is subject to the terms and conditions of the GNU General Public | 13 | * This file is subject to the terms and conditions of the GNU General Public |
12 | * License. See the file "COPYING" in the main directory of this archive | 14 | * License. See the file "COPYING" in the main directory of this archive |
13 | * for more details. | 15 | * for more details. |
@@ -20,6 +22,7 @@ | |||
20 | #include <linux/kref.h> | 22 | #include <linux/kref.h> |
21 | #include <linux/seq_file.h> | 23 | #include <linux/seq_file.h> |
22 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/platform_device.h> | ||
23 | #include <asm/clock.h> | 26 | #include <asm/clock.h> |
24 | #include <asm/timer.h> | 27 | #include <asm/timer.h> |
25 | 28 | ||
@@ -195,17 +198,37 @@ void clk_recalc_rate(struct clk *clk) | |||
195 | propagate_rate(clk); | 198 | propagate_rate(clk); |
196 | } | 199 | } |
197 | 200 | ||
198 | struct clk *clk_get(const char *id) | 201 | /* |
202 | * Returns a clock. Note that we first try to use device id on the bus | ||
203 | * and clock name. If this fails, we try to use clock name only. | ||
204 | */ | ||
205 | struct clk *clk_get(struct device *dev, const char *id) | ||
199 | { | 206 | { |
200 | struct clk *p, *clk = ERR_PTR(-ENOENT); | 207 | struct clk *p, *clk = ERR_PTR(-ENOENT); |
208 | int idno; | ||
209 | |||
210 | if (dev == NULL || dev->bus != &platform_bus_type) | ||
211 | idno = -1; | ||
212 | else | ||
213 | idno = to_platform_device(dev)->id; | ||
201 | 214 | ||
202 | mutex_lock(&clock_list_sem); | 215 | mutex_lock(&clock_list_sem); |
203 | list_for_each_entry(p, &clock_list, node) { | 216 | list_for_each_entry(p, &clock_list, node) { |
217 | if (p->id == idno && | ||
218 | strcmp(id, p->name) == 0 && try_module_get(p->owner)) { | ||
219 | clk = p; | ||
220 | goto found; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | list_for_each_entry(p, &clock_list, node) { | ||
204 | if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { | 225 | if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { |
205 | clk = p; | 226 | clk = p; |
206 | break; | 227 | break; |
207 | } | 228 | } |
208 | } | 229 | } |
230 | |||
231 | found: | ||
209 | mutex_unlock(&clock_list_sem); | 232 | mutex_unlock(&clock_list_sem); |
210 | 233 | ||
211 | return clk; | 234 | return clk; |
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7709.c b/arch/sh/kernel/cpu/sh3/clock-sh7709.c index 10461a745e5f..b791a29fdb62 100644 --- a/arch/sh/kernel/cpu/sh3/clock-sh7709.c +++ b/arch/sh/kernel/cpu/sh3/clock-sh7709.c | |||
@@ -24,7 +24,7 @@ static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 }; | |||
24 | 24 | ||
25 | static void set_bus_parent(struct clk *clk) | 25 | static void set_bus_parent(struct clk *clk) |
26 | { | 26 | { |
27 | struct clk *bus_clk = clk_get("bus_clk"); | 27 | struct clk *bus_clk = clk_get(NULL, "bus_clk"); |
28 | clk->parent = bus_clk; | 28 | clk->parent = bus_clk; |
29 | clk_put(bus_clk); | 29 | clk_put(bus_clk); |
30 | } | 30 | } |
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c index bfdf5fe8d948..fa2019aabd74 100644 --- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c +++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c | |||
@@ -97,7 +97,7 @@ static void shoc_clk_recalc(struct clk *clk) | |||
97 | 97 | ||
98 | static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) | 98 | static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) |
99 | { | 99 | { |
100 | struct clk *bclk = clk_get("bus_clk"); | 100 | struct clk *bclk = clk_get(NULL, "bus_clk"); |
101 | unsigned long bclk_rate = clk_get_rate(bclk); | 101 | unsigned long bclk_rate = clk_get_rate(bclk); |
102 | 102 | ||
103 | clk_put(bclk); | 103 | clk_put(bclk); |
@@ -151,7 +151,7 @@ static struct clk *sh4202_onchip_clocks[] = { | |||
151 | 151 | ||
152 | static int __init sh4202_clk_init(void) | 152 | static int __init sh4202_clk_init(void) |
153 | { | 153 | { |
154 | struct clk *clk = clk_get("master_clk"); | 154 | struct clk *clk = clk_get(NULL, "master_clk"); |
155 | int i; | 155 | int i; |
156 | 156 | ||
157 | for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { | 157 | for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { |
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh7780.c b/arch/sh/kernel/cpu/sh4/clock-sh7780.c index 93ad367342c9..9e6a216750c8 100644 --- a/arch/sh/kernel/cpu/sh4/clock-sh7780.c +++ b/arch/sh/kernel/cpu/sh4/clock-sh7780.c | |||
@@ -98,7 +98,7 @@ static struct clk *sh7780_onchip_clocks[] = { | |||
98 | 98 | ||
99 | static int __init sh7780_clk_init(void) | 99 | static int __init sh7780_clk_init(void) |
100 | { | 100 | { |
101 | struct clk *clk = clk_get("master_clk"); | 101 | struct clk *clk = clk_get(NULL, "master_clk"); |
102 | int i; | 102 | int i; |
103 | 103 | ||
104 | for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { | 104 | for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { |
diff --git a/arch/sh/kernel/timers/timer-cmt.c b/arch/sh/kernel/timers/timer-cmt.c index 95581dccbbfd..a574b93a4e7b 100644 --- a/arch/sh/kernel/timers/timer-cmt.c +++ b/arch/sh/kernel/timers/timer-cmt.c | |||
@@ -124,7 +124,7 @@ static void cmt_clk_init(struct clk *clk) | |||
124 | u8 divisor = CMT_CMCSR_INIT & 0x3; | 124 | u8 divisor = CMT_CMCSR_INIT & 0x3; |
125 | ctrl_inw(CMT_CMCSR_0); | 125 | ctrl_inw(CMT_CMCSR_0); |
126 | ctrl_outw(CMT_CMCSR_INIT, CMT_CMCSR_0); | 126 | ctrl_outw(CMT_CMCSR_INIT, CMT_CMCSR_0); |
127 | clk->parent = clk_get("module_clk"); | 127 | clk->parent = clk_get(NULL, "module_clk"); |
128 | clk->rate = clk->parent->rate / (8 << (divisor << 1)); | 128 | clk->rate = clk->parent->rate / (8 << (divisor << 1)); |
129 | } | 129 | } |
130 | 130 | ||
@@ -164,7 +164,7 @@ static int cmt_timer_init(void) | |||
164 | 164 | ||
165 | setup_irq(CONFIG_SH_TIMER_IRQ, &cmt_irq); | 165 | setup_irq(CONFIG_SH_TIMER_IRQ, &cmt_irq); |
166 | 166 | ||
167 | cmt0_clk.parent = clk_get("module_clk"); | 167 | cmt0_clk.parent = clk_get(NULL, "module_clk"); |
168 | 168 | ||
169 | cmt_timer_stop(); | 169 | cmt_timer_stop(); |
170 | 170 | ||
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c index 201f0a62132f..fffcd1c09873 100644 --- a/arch/sh/kernel/timers/timer-mtu2.c +++ b/arch/sh/kernel/timers/timer-mtu2.c | |||
@@ -161,7 +161,7 @@ static int mtu2_timer_init(void) | |||
161 | 161 | ||
162 | setup_irq(CONFIG_SH_TIMER_IRQ, &mtu2_irq); | 162 | setup_irq(CONFIG_SH_TIMER_IRQ, &mtu2_irq); |
163 | 163 | ||
164 | mtu2_clk1.parent = clk_get("module_clk"); | 164 | mtu2_clk1.parent = clk_get(NULL, "module_clk"); |
165 | 165 | ||
166 | ctrl_outb(ctrl_inb(STBCR3) & (~0x20), STBCR3); | 166 | ctrl_outb(ctrl_inb(STBCR3) & (~0x20), STBCR3); |
167 | 167 | ||
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c index b9ed8a387555..e060e71d0785 100644 --- a/arch/sh/kernel/timers/timer-tmu.c +++ b/arch/sh/kernel/timers/timer-tmu.c | |||
@@ -144,7 +144,7 @@ static int tmu_timer_init(void) | |||
144 | 144 | ||
145 | setup_irq(CONFIG_SH_TIMER_IRQ, &tmu_irq); | 145 | setup_irq(CONFIG_SH_TIMER_IRQ, &tmu_irq); |
146 | 146 | ||
147 | tmu0_clk.parent = clk_get("module_clk"); | 147 | tmu0_clk.parent = clk_get(NULL, "module_clk"); |
148 | 148 | ||
149 | /* Start TMU0 */ | 149 | /* Start TMU0 */ |
150 | tmu_timer_stop(); | 150 | tmu_timer_stop(); |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index cfcc3caf49d8..3b5f19ec2126 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -775,7 +775,7 @@ static int sci_notifier(struct notifier_block *self, | |||
775 | * | 775 | * |
776 | * Clean this up later.. | 776 | * Clean this up later.. |
777 | */ | 777 | */ |
778 | clk = clk_get("module_clk"); | 778 | clk = clk_get(NULL, "module_clk"); |
779 | port->uartclk = clk_get_rate(clk) * 16; | 779 | port->uartclk = clk_get_rate(clk) * 16; |
780 | clk_put(clk); | 780 | clk_put(clk); |
781 | } | 781 | } |
@@ -960,7 +960,7 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios, | |||
960 | default: | 960 | default: |
961 | { | 961 | { |
962 | #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) | 962 | #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) |
963 | struct clk *clk = clk_get("module_clk"); | 963 | struct clk *clk = clk_get(NULL, "module_clk"); |
964 | t = SCBRR_VALUE(baud, clk_get_rate(clk)); | 964 | t = SCBRR_VALUE(baud, clk_get_rate(clk)); |
965 | clk_put(clk); | 965 | clk_put(clk); |
966 | #else | 966 | #else |
@@ -1128,7 +1128,7 @@ static void __init sci_init_ports(void) | |||
1128 | * XXX: We should use a proper SCI/SCIF clock | 1128 | * XXX: We should use a proper SCI/SCIF clock |
1129 | */ | 1129 | */ |
1130 | { | 1130 | { |
1131 | struct clk *clk = clk_get("module_clk"); | 1131 | struct clk *clk = clk_get(NULL, "module_clk"); |
1132 | sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; | 1132 | sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; |
1133 | clk_put(clk); | 1133 | clk_put(clk); |
1134 | } | 1134 | } |
diff --git a/include/asm-sh/clock.h b/include/asm-sh/clock.h index fdfb75b30f0d..1df92807f8c5 100644 --- a/include/asm-sh/clock.h +++ b/include/asm-sh/clock.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/kref.h> | 4 | #include <linux/kref.h> |
5 | #include <linux/list.h> | 5 | #include <linux/list.h> |
6 | #include <linux/seq_file.h> | 6 | #include <linux/seq_file.h> |
7 | #include <linux/clk.h> | ||
7 | 8 | ||
8 | struct clk; | 9 | struct clk; |
9 | 10 | ||
@@ -18,7 +19,7 @@ struct clk_ops { | |||
18 | struct clk { | 19 | struct clk { |
19 | struct list_head node; | 20 | struct list_head node; |
20 | const char *name; | 21 | const char *name; |
21 | 22 | int id; | |
22 | struct module *owner; | 23 | struct module *owner; |
23 | 24 | ||
24 | struct clk *parent; | 25 | struct clk *parent; |
@@ -40,22 +41,13 @@ void arch_init_clk_ops(struct clk_ops **, int type); | |||
40 | int clk_init(void); | 41 | int clk_init(void); |
41 | 42 | ||
42 | int __clk_enable(struct clk *); | 43 | int __clk_enable(struct clk *); |
43 | int clk_enable(struct clk *); | ||
44 | |||
45 | void __clk_disable(struct clk *); | 44 | void __clk_disable(struct clk *); |
46 | void clk_disable(struct clk *); | ||
47 | 45 | ||
48 | int clk_set_rate(struct clk *, unsigned long rate); | ||
49 | unsigned long clk_get_rate(struct clk *); | ||
50 | void clk_recalc_rate(struct clk *); | 46 | void clk_recalc_rate(struct clk *); |
51 | 47 | ||
52 | struct clk *clk_get(const char *id); | ||
53 | void clk_put(struct clk *); | ||
54 | |||
55 | int clk_register(struct clk *); | 48 | int clk_register(struct clk *); |
56 | void clk_unregister(struct clk *); | 49 | void clk_unregister(struct clk *); |
57 | 50 | ||
58 | int show_clocks(struct seq_file *m); | 51 | int show_clocks(struct seq_file *m); |
59 | 52 | ||
60 | #endif /* __ASM_SH_CLOCK_H */ | 53 | #endif /* __ASM_SH_CLOCK_H */ |
61 | |||