diff options
author | Steve French <sfrench@us.ibm.com> | 2006-01-17 22:49:59 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-01-17 22:49:59 -0500 |
commit | d65177c1ae7f085723154105c5dc8d9e16ae8265 (patch) | |
tree | 14408129d880d89cc5e937f2810f243ed1e6fcde /arch/sh/kernel/cpu | |
parent | d41f084a74de860fe879403fbbad13abdf7aea8e (diff) | |
parent | 15578eeb6cd4b74492f26e60624aa1a9a52ddd7b (diff) |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'arch/sh/kernel/cpu')
20 files changed, 1719 insertions, 432 deletions
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile index cd43714df61a..5bfc33bec5d0 100644 --- a/arch/sh/kernel/cpu/Makefile +++ b/arch/sh/kernel/cpu/Makefile | |||
@@ -2,15 +2,12 @@ | |||
2 | # Makefile for the Linux/SuperH CPU-specifc backends. | 2 | # Makefile for the Linux/SuperH CPU-specifc backends. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := irq_ipr.o irq_imask.o init.o bus.o | 5 | obj-y += irq/ init.o bus.o clock.o |
6 | 6 | ||
7 | obj-$(CONFIG_CPU_SH2) += sh2/ | 7 | obj-$(CONFIG_CPU_SH2) += sh2/ |
8 | obj-$(CONFIG_CPU_SH3) += sh3/ | 8 | obj-$(CONFIG_CPU_SH3) += sh3/ |
9 | obj-$(CONFIG_CPU_SH4) += sh4/ | 9 | obj-$(CONFIG_CPU_SH4) += sh4/ |
10 | 10 | ||
11 | obj-$(CONFIG_SH_RTC) += rtc.o | 11 | obj-$(CONFIG_SH_RTC) += rtc.o |
12 | obj-$(CONFIG_UBC_WAKEUP) += ubc.o | 12 | obj-$(CONFIG_UBC_WAKEUP) += ubc.o |
13 | obj-$(CONFIG_SH_ADC) += adc.o | 13 | obj-$(CONFIG_SH_ADC) += adc.o |
14 | |||
15 | USE_STANDARD_AS_RULE := true | ||
16 | |||
diff --git a/arch/sh/kernel/cpu/bus.c b/arch/sh/kernel/cpu/bus.c index d4fee2a79373..fc6c4bd40c65 100644 --- a/arch/sh/kernel/cpu/bus.c +++ b/arch/sh/kernel/cpu/bus.c | |||
@@ -53,21 +53,6 @@ static int sh_bus_resume(struct device *dev) | |||
53 | return 0; | 53 | return 0; |
54 | } | 54 | } |
55 | 55 | ||
56 | static struct device sh_bus_devices[SH_NR_BUSES] = { | ||
57 | { | ||
58 | .bus_id = SH_BUS_NAME_VIRT, | ||
59 | }, | ||
60 | }; | ||
61 | |||
62 | struct bus_type sh_bus_types[SH_NR_BUSES] = { | ||
63 | { | ||
64 | .name = SH_BUS_NAME_VIRT, | ||
65 | .match = sh_bus_match, | ||
66 | .suspend = sh_bus_suspend, | ||
67 | .resume = sh_bus_resume, | ||
68 | }, | ||
69 | }; | ||
70 | |||
71 | static int sh_device_probe(struct device *dev) | 56 | static int sh_device_probe(struct device *dev) |
72 | { | 57 | { |
73 | struct sh_dev *shdev = to_sh_dev(dev); | 58 | struct sh_dev *shdev = to_sh_dev(dev); |
@@ -90,6 +75,23 @@ static int sh_device_remove(struct device *dev) | |||
90 | return 0; | 75 | return 0; |
91 | } | 76 | } |
92 | 77 | ||
78 | static struct device sh_bus_devices[SH_NR_BUSES] = { | ||
79 | { | ||
80 | .bus_id = SH_BUS_NAME_VIRT, | ||
81 | }, | ||
82 | }; | ||
83 | |||
84 | struct bus_type sh_bus_types[SH_NR_BUSES] = { | ||
85 | { | ||
86 | .name = SH_BUS_NAME_VIRT, | ||
87 | .match = sh_bus_match, | ||
88 | .probe = sh_bus_probe, | ||
89 | .remove = sh_bus_remove, | ||
90 | .suspend = sh_bus_suspend, | ||
91 | .resume = sh_bus_resume, | ||
92 | }, | ||
93 | }; | ||
94 | |||
93 | int sh_device_register(struct sh_dev *dev) | 95 | int sh_device_register(struct sh_dev *dev) |
94 | { | 96 | { |
95 | if (!dev) | 97 | if (!dev) |
@@ -107,6 +109,8 @@ int sh_device_register(struct sh_dev *dev) | |||
107 | /* This is needed for USB OHCI to work */ | 109 | /* This is needed for USB OHCI to work */ |
108 | if (dev->dma_mask) | 110 | if (dev->dma_mask) |
109 | dev->dev.dma_mask = dev->dma_mask; | 111 | dev->dev.dma_mask = dev->dma_mask; |
112 | if (dev->coherent_dma_mask) | ||
113 | dev->dev.coherent_dma_mask = dev->coherent_dma_mask; | ||
110 | 114 | ||
111 | snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%s%u", | 115 | snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%s%u", |
112 | dev->name, dev->dev_id); | 116 | dev->name, dev->dev_id); |
@@ -133,8 +137,6 @@ int sh_driver_register(struct sh_driver *drv) | |||
133 | return -EINVAL; | 137 | return -EINVAL; |
134 | } | 138 | } |
135 | 139 | ||
136 | drv->drv.probe = sh_device_probe; | ||
137 | drv->drv.remove = sh_device_remove; | ||
138 | drv->drv.bus = &sh_bus_types[drv->bus_id]; | 140 | drv->drv.bus = &sh_bus_types[drv->bus_id]; |
139 | 141 | ||
140 | return driver_register(&drv->drv); | 142 | return driver_register(&drv->drv); |
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c new file mode 100644 index 000000000000..989e7fdd524d --- /dev/null +++ b/arch/sh/kernel/cpu/clock.c | |||
@@ -0,0 +1,287 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/clock.c - SuperH clock framework | ||
3 | * | ||
4 | * Copyright (C) 2005 Paul Mundt | ||
5 | * | ||
6 | * This clock framework is derived from the OMAP version by: | ||
7 | * | ||
8 | * Copyright (C) 2004 Nokia Corporation | ||
9 | * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> | ||
10 | * | ||
11 | * 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 | ||
13 | * for more details. | ||
14 | */ | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/list.h> | ||
19 | #include <linux/kref.h> | ||
20 | #include <linux/seq_file.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <asm/clock.h> | ||
23 | #include <asm/timer.h> | ||
24 | |||
25 | static LIST_HEAD(clock_list); | ||
26 | static DEFINE_SPINLOCK(clock_lock); | ||
27 | static DECLARE_MUTEX(clock_list_sem); | ||
28 | |||
29 | /* | ||
30 | * Each subtype is expected to define the init routines for these clocks, | ||
31 | * as each subtype (or processor family) will have these clocks at the | ||
32 | * very least. These are all provided through the CPG, which even some of | ||
33 | * the more quirky parts (such as ST40, SH4-202, etc.) still have. | ||
34 | * | ||
35 | * The processor-specific code is expected to register any additional | ||
36 | * clock sources that are of interest. | ||
37 | */ | ||
38 | static struct clk master_clk = { | ||
39 | .name = "master_clk", | ||
40 | .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, | ||
41 | #ifdef CONFIG_SH_PCLK_FREQ_BOOL | ||
42 | .rate = CONFIG_SH_PCLK_FREQ, | ||
43 | #endif | ||
44 | }; | ||
45 | |||
46 | static struct clk module_clk = { | ||
47 | .name = "module_clk", | ||
48 | .parent = &master_clk, | ||
49 | .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, | ||
50 | }; | ||
51 | |||
52 | static struct clk bus_clk = { | ||
53 | .name = "bus_clk", | ||
54 | .parent = &master_clk, | ||
55 | .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, | ||
56 | }; | ||
57 | |||
58 | static struct clk cpu_clk = { | ||
59 | .name = "cpu_clk", | ||
60 | .parent = &master_clk, | ||
61 | .flags = CLK_ALWAYS_ENABLED, | ||
62 | }; | ||
63 | |||
64 | /* | ||
65 | * The ordering of these clocks matters, do not change it. | ||
66 | */ | ||
67 | static struct clk *onchip_clocks[] = { | ||
68 | &master_clk, | ||
69 | &module_clk, | ||
70 | &bus_clk, | ||
71 | &cpu_clk, | ||
72 | }; | ||
73 | |||
74 | static void propagate_rate(struct clk *clk) | ||
75 | { | ||
76 | struct clk *clkp; | ||
77 | |||
78 | list_for_each_entry(clkp, &clock_list, node) { | ||
79 | if (likely(clkp->parent != clk)) | ||
80 | continue; | ||
81 | if (likely(clkp->ops && clkp->ops->recalc)) | ||
82 | clkp->ops->recalc(clkp); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | int __clk_enable(struct clk *clk) | ||
87 | { | ||
88 | /* | ||
89 | * See if this is the first time we're enabling the clock, some | ||
90 | * clocks that are always enabled still require "special" | ||
91 | * initialization. This is especially true if the clock mode | ||
92 | * changes and the clock needs to hunt for the proper set of | ||
93 | * divisors to use before it can effectively recalc. | ||
94 | */ | ||
95 | if (unlikely(atomic_read(&clk->kref.refcount) == 1)) | ||
96 | if (clk->ops && clk->ops->init) | ||
97 | clk->ops->init(clk); | ||
98 | |||
99 | if (clk->flags & CLK_ALWAYS_ENABLED) | ||
100 | return 0; | ||
101 | |||
102 | if (likely(clk->ops && clk->ops->enable)) | ||
103 | clk->ops->enable(clk); | ||
104 | |||
105 | kref_get(&clk->kref); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | int clk_enable(struct clk *clk) | ||
110 | { | ||
111 | unsigned long flags; | ||
112 | int ret; | ||
113 | |||
114 | spin_lock_irqsave(&clock_lock, flags); | ||
115 | ret = __clk_enable(clk); | ||
116 | spin_unlock_irqrestore(&clock_lock, flags); | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | static void clk_kref_release(struct kref *kref) | ||
122 | { | ||
123 | /* Nothing to do */ | ||
124 | } | ||
125 | |||
126 | void __clk_disable(struct clk *clk) | ||
127 | { | ||
128 | if (clk->flags & CLK_ALWAYS_ENABLED) | ||
129 | return; | ||
130 | |||
131 | kref_put(&clk->kref, clk_kref_release); | ||
132 | } | ||
133 | |||
134 | void clk_disable(struct clk *clk) | ||
135 | { | ||
136 | unsigned long flags; | ||
137 | |||
138 | spin_lock_irqsave(&clock_lock, flags); | ||
139 | __clk_disable(clk); | ||
140 | spin_unlock_irqrestore(&clock_lock, flags); | ||
141 | } | ||
142 | |||
143 | int clk_register(struct clk *clk) | ||
144 | { | ||
145 | down(&clock_list_sem); | ||
146 | |||
147 | list_add(&clk->node, &clock_list); | ||
148 | kref_init(&clk->kref); | ||
149 | |||
150 | up(&clock_list_sem); | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | void clk_unregister(struct clk *clk) | ||
156 | { | ||
157 | down(&clock_list_sem); | ||
158 | list_del(&clk->node); | ||
159 | up(&clock_list_sem); | ||
160 | } | ||
161 | |||
162 | inline unsigned long clk_get_rate(struct clk *clk) | ||
163 | { | ||
164 | return clk->rate; | ||
165 | } | ||
166 | |||
167 | int clk_set_rate(struct clk *clk, unsigned long rate) | ||
168 | { | ||
169 | int ret = -EOPNOTSUPP; | ||
170 | |||
171 | if (likely(clk->ops && clk->ops->set_rate)) { | ||
172 | unsigned long flags; | ||
173 | |||
174 | spin_lock_irqsave(&clock_lock, flags); | ||
175 | ret = clk->ops->set_rate(clk, rate); | ||
176 | spin_unlock_irqrestore(&clock_lock, flags); | ||
177 | } | ||
178 | |||
179 | if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) | ||
180 | propagate_rate(clk); | ||
181 | |||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | void clk_recalc_rate(struct clk *clk) | ||
186 | { | ||
187 | if (likely(clk->ops && clk->ops->recalc)) { | ||
188 | unsigned long flags; | ||
189 | |||
190 | spin_lock_irqsave(&clock_lock, flags); | ||
191 | clk->ops->recalc(clk); | ||
192 | spin_unlock_irqrestore(&clock_lock, flags); | ||
193 | } | ||
194 | |||
195 | if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) | ||
196 | propagate_rate(clk); | ||
197 | } | ||
198 | |||
199 | struct clk *clk_get(const char *id) | ||
200 | { | ||
201 | struct clk *p, *clk = ERR_PTR(-ENOENT); | ||
202 | |||
203 | down(&clock_list_sem); | ||
204 | list_for_each_entry(p, &clock_list, node) { | ||
205 | if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { | ||
206 | clk = p; | ||
207 | break; | ||
208 | } | ||
209 | } | ||
210 | up(&clock_list_sem); | ||
211 | |||
212 | return clk; | ||
213 | } | ||
214 | |||
215 | void clk_put(struct clk *clk) | ||
216 | { | ||
217 | if (clk && !IS_ERR(clk)) | ||
218 | module_put(clk->owner); | ||
219 | } | ||
220 | |||
221 | void __init __attribute__ ((weak)) | ||
222 | arch_init_clk_ops(struct clk_ops **ops, int type) | ||
223 | { | ||
224 | } | ||
225 | |||
226 | int __init clk_init(void) | ||
227 | { | ||
228 | int i, ret = 0; | ||
229 | |||
230 | if (unlikely(!master_clk.rate)) | ||
231 | /* | ||
232 | * NOTE: This will break if the default divisor has been | ||
233 | * changed. | ||
234 | * | ||
235 | * No one should be changing the default on us however, | ||
236 | * expect that a sane value for CONFIG_SH_PCLK_FREQ will | ||
237 | * be defined in the event of a different divisor. | ||
238 | */ | ||
239 | master_clk.rate = get_timer_frequency() * 4; | ||
240 | |||
241 | for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) { | ||
242 | struct clk *clk = onchip_clocks[i]; | ||
243 | |||
244 | arch_init_clk_ops(&clk->ops, i); | ||
245 | ret |= clk_register(clk); | ||
246 | clk_enable(clk); | ||
247 | } | ||
248 | |||
249 | /* Kick the child clocks.. */ | ||
250 | propagate_rate(&master_clk); | ||
251 | propagate_rate(&bus_clk); | ||
252 | |||
253 | return ret; | ||
254 | } | ||
255 | |||
256 | int show_clocks(struct seq_file *m) | ||
257 | { | ||
258 | struct clk *clk; | ||
259 | |||
260 | list_for_each_entry_reverse(clk, &clock_list, node) { | ||
261 | unsigned long rate = clk_get_rate(clk); | ||
262 | |||
263 | /* | ||
264 | * Don't bother listing dummy clocks with no ancestry | ||
265 | * that only support enable and disable ops. | ||
266 | */ | ||
267 | if (unlikely(!rate && !clk->parent)) | ||
268 | continue; | ||
269 | |||
270 | seq_printf(m, "%-12s\t: %ld.%02ldMHz\n", clk->name, | ||
271 | rate / 1000000, (rate % 1000000) / 10000); | ||
272 | } | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | |||
277 | EXPORT_SYMBOL_GPL(clk_register); | ||
278 | EXPORT_SYMBOL_GPL(clk_unregister); | ||
279 | EXPORT_SYMBOL_GPL(clk_get); | ||
280 | EXPORT_SYMBOL_GPL(clk_put); | ||
281 | EXPORT_SYMBOL_GPL(clk_enable); | ||
282 | EXPORT_SYMBOL_GPL(clk_disable); | ||
283 | EXPORT_SYMBOL_GPL(__clk_enable); | ||
284 | EXPORT_SYMBOL_GPL(__clk_disable); | ||
285 | EXPORT_SYMBOL_GPL(clk_get_rate); | ||
286 | EXPORT_SYMBOL_GPL(clk_set_rate); | ||
287 | EXPORT_SYMBOL_GPL(clk_recalc_rate); | ||
diff --git a/arch/sh/kernel/cpu/irq/Makefile b/arch/sh/kernel/cpu/irq/Makefile new file mode 100644 index 000000000000..e3cccea15e1d --- /dev/null +++ b/arch/sh/kernel/cpu/irq/Makefile | |||
@@ -0,0 +1,7 @@ | |||
1 | # | ||
2 | # Makefile for the Linux/SuperH CPU-specifc IRQ handlers. | ||
3 | # | ||
4 | obj-y += ipr.o imask.o | ||
5 | |||
6 | obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o | ||
7 | obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o | ||
diff --git a/arch/sh/kernel/cpu/irq_imask.c b/arch/sh/kernel/cpu/irq/imask.c index a963d00a971e..baed9a550d39 100644 --- a/arch/sh/kernel/cpu/irq_imask.c +++ b/arch/sh/kernel/cpu/irq/imask.c | |||
@@ -1,16 +1,12 @@ | |||
1 | /* $Id: irq_imask.c,v 1.1.2.1 2002/11/17 10:53:43 mrbrown Exp $ | 1 | /* |
2 | * | 2 | * arch/sh/kernel/cpu/irq/imask.c |
3 | * linux/arch/sh/kernel/irq_imask.c | ||
4 | * | 3 | * |
5 | * Copyright (C) 1999, 2000 Niibe Yutaka | 4 | * Copyright (C) 1999, 2000 Niibe Yutaka |
6 | * | 5 | * |
7 | * Simple interrupt handling using IMASK of SR register. | 6 | * Simple interrupt handling using IMASK of SR register. |
8 | * | 7 | * |
9 | */ | 8 | */ |
10 | |||
11 | /* NOTE: Will not work on level 15 */ | 9 | /* NOTE: Will not work on level 15 */ |
12 | |||
13 | |||
14 | #include <linux/ptrace.h> | 10 | #include <linux/ptrace.h> |
15 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
16 | #include <linux/kernel_stat.h> | 12 | #include <linux/kernel_stat.h> |
@@ -19,13 +15,11 @@ | |||
19 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
20 | #include <linux/init.h> | 16 | #include <linux/init.h> |
21 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
22 | |||
23 | #include <asm/system.h> | ||
24 | #include <asm/irq.h> | ||
25 | |||
26 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
27 | #include <linux/cache.h> | 19 | #include <linux/cache.h> |
28 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
21 | #include <asm/system.h> | ||
22 | #include <asm/irq.h> | ||
29 | 23 | ||
30 | /* Bitmap of IRQ masked */ | 24 | /* Bitmap of IRQ masked */ |
31 | static unsigned long imask_mask = 0x7fff; | 25 | static unsigned long imask_mask = 0x7fff; |
@@ -40,7 +34,7 @@ static void end_imask_irq(unsigned int irq); | |||
40 | #define IMASK_PRIORITY 15 | 34 | #define IMASK_PRIORITY 15 |
41 | 35 | ||
42 | static unsigned int startup_imask_irq(unsigned int irq) | 36 | static unsigned int startup_imask_irq(unsigned int irq) |
43 | { | 37 | { |
44 | /* Nothing to do */ | 38 | /* Nothing to do */ |
45 | return 0; /* never anything pending */ | 39 | return 0; /* never anything pending */ |
46 | } | 40 | } |
diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c new file mode 100644 index 000000000000..06e8afab32e4 --- /dev/null +++ b/arch/sh/kernel/cpu/irq/intc2.c | |||
@@ -0,0 +1,284 @@ | |||
1 | /* | ||
2 | * Interrupt handling for INTC2-based IRQ. | ||
3 | * | ||
4 | * Copyright (C) 2001 David J. Mckay (david.mckay@st.com) | ||
5 | * Copyright (C) 2005, 2006 Paul Mundt (lethal@linux-sh.org) | ||
6 | * | ||
7 | * May be copied or modified under the terms of the GNU General Public | ||
8 | * License. See linux/COPYING for more information. | ||
9 | * | ||
10 | * These are the "new Hitachi style" interrupts, as present on the | ||
11 | * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/irq.h> | ||
17 | #include <asm/system.h> | ||
18 | #include <asm/io.h> | ||
19 | #include <asm/machvec.h> | ||
20 | |||
21 | struct intc2_data { | ||
22 | unsigned char msk_offset; | ||
23 | unsigned char msk_shift; | ||
24 | |||
25 | int (*clear_irq) (int); | ||
26 | }; | ||
27 | |||
28 | static struct intc2_data intc2_data[NR_INTC2_IRQS]; | ||
29 | |||
30 | static void enable_intc2_irq(unsigned int irq); | ||
31 | static void disable_intc2_irq(unsigned int irq); | ||
32 | |||
33 | /* shutdown is same as "disable" */ | ||
34 | #define shutdown_intc2_irq disable_intc2_irq | ||
35 | |||
36 | static void mask_and_ack_intc2(unsigned int); | ||
37 | static void end_intc2_irq(unsigned int irq); | ||
38 | |||
39 | static unsigned int startup_intc2_irq(unsigned int irq) | ||
40 | { | ||
41 | enable_intc2_irq(irq); | ||
42 | return 0; /* never anything pending */ | ||
43 | } | ||
44 | |||
45 | static struct hw_interrupt_type intc2_irq_type = { | ||
46 | .typename = "INTC2-IRQ", | ||
47 | .startup = startup_intc2_irq, | ||
48 | .shutdown = shutdown_intc2_irq, | ||
49 | .enable = enable_intc2_irq, | ||
50 | .disable = disable_intc2_irq, | ||
51 | .ack = mask_and_ack_intc2, | ||
52 | .end = end_intc2_irq | ||
53 | }; | ||
54 | |||
55 | static void disable_intc2_irq(unsigned int irq) | ||
56 | { | ||
57 | int irq_offset = irq - INTC2_FIRST_IRQ; | ||
58 | int msk_shift, msk_offset; | ||
59 | |||
60 | /* Sanity check */ | ||
61 | if (unlikely(irq_offset < 0 || irq_offset >= NR_INTC2_IRQS)) | ||
62 | return; | ||
63 | |||
64 | msk_shift = intc2_data[irq_offset].msk_shift; | ||
65 | msk_offset = intc2_data[irq_offset].msk_offset; | ||
66 | |||
67 | ctrl_outl(1 << msk_shift, | ||
68 | INTC2_BASE + INTC2_INTMSK_OFFSET + msk_offset); | ||
69 | } | ||
70 | |||
71 | static void enable_intc2_irq(unsigned int irq) | ||
72 | { | ||
73 | int irq_offset = irq - INTC2_FIRST_IRQ; | ||
74 | int msk_shift, msk_offset; | ||
75 | |||
76 | /* Sanity check */ | ||
77 | if (unlikely(irq_offset < 0 || irq_offset >= NR_INTC2_IRQS)) | ||
78 | return; | ||
79 | |||
80 | msk_shift = intc2_data[irq_offset].msk_shift; | ||
81 | msk_offset = intc2_data[irq_offset].msk_offset; | ||
82 | |||
83 | ctrl_outl(1 << msk_shift, | ||
84 | INTC2_BASE + INTC2_INTMSKCLR_OFFSET + msk_offset); | ||
85 | } | ||
86 | |||
87 | static void mask_and_ack_intc2(unsigned int irq) | ||
88 | { | ||
89 | disable_intc2_irq(irq); | ||
90 | } | ||
91 | |||
92 | static void end_intc2_irq(unsigned int irq) | ||
93 | { | ||
94 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | ||
95 | enable_intc2_irq(irq); | ||
96 | |||
97 | if (unlikely(intc2_data[irq - INTC2_FIRST_IRQ].clear_irq)) | ||
98 | intc2_data[irq - INTC2_FIRST_IRQ].clear_irq(irq); | ||
99 | } | ||
100 | |||
101 | /* | ||
102 | * Setup an INTC2 style interrupt. | ||
103 | * NOTE: Unlike IPR interrupts, parameters are not shifted by this code, | ||
104 | * allowing the use of the numbers straight out of the datasheet. | ||
105 | * For example: | ||
106 | * PIO1 which is INTPRI00[19,16] and INTMSK00[13] | ||
107 | * would be: ^ ^ ^ ^ | ||
108 | * | | | | | ||
109 | * make_intc2_irq(84, 0, 16, 0, 13); | ||
110 | */ | ||
111 | void make_intc2_irq(unsigned int irq, | ||
112 | unsigned int ipr_offset, unsigned int ipr_shift, | ||
113 | unsigned int msk_offset, unsigned int msk_shift, | ||
114 | unsigned int priority) | ||
115 | { | ||
116 | int irq_offset = irq - INTC2_FIRST_IRQ; | ||
117 | unsigned int flags; | ||
118 | unsigned long ipr; | ||
119 | |||
120 | if (unlikely(irq_offset < 0 || irq_offset >= NR_INTC2_IRQS)) | ||
121 | return; | ||
122 | |||
123 | disable_irq_nosync(irq); | ||
124 | |||
125 | /* Fill the data we need */ | ||
126 | intc2_data[irq_offset].msk_offset = msk_offset; | ||
127 | intc2_data[irq_offset].msk_shift = msk_shift; | ||
128 | intc2_data[irq_offset].clear_irq = NULL; | ||
129 | |||
130 | /* Set the priority level */ | ||
131 | local_irq_save(flags); | ||
132 | |||
133 | ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET + ipr_offset); | ||
134 | ipr &= ~(0xf << ipr_shift); | ||
135 | ipr |= priority << ipr_shift; | ||
136 | ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET + ipr_offset); | ||
137 | |||
138 | local_irq_restore(flags); | ||
139 | |||
140 | irq_desc[irq].handler = &intc2_irq_type; | ||
141 | |||
142 | disable_intc2_irq(irq); | ||
143 | } | ||
144 | |||
145 | static struct intc2_init { | ||
146 | unsigned short irq; | ||
147 | unsigned char ipr_offset, ipr_shift; | ||
148 | unsigned char msk_offset, msk_shift; | ||
149 | unsigned char priority; | ||
150 | } intc2_init_data[] __initdata = { | ||
151 | #if defined(CONFIG_CPU_SUBTYPE_ST40) | ||
152 | {64, 0, 0, 0, 0, 13}, /* PCI serr */ | ||
153 | {65, 0, 4, 0, 1, 13}, /* PCI err */ | ||
154 | {66, 0, 4, 0, 2, 13}, /* PCI ad */ | ||
155 | {67, 0, 4, 0, 3, 13}, /* PCI pwd down */ | ||
156 | {72, 0, 8, 0, 5, 13}, /* DMAC INT0 */ | ||
157 | {73, 0, 8, 0, 6, 13}, /* DMAC INT1 */ | ||
158 | {74, 0, 8, 0, 7, 13}, /* DMAC INT2 */ | ||
159 | {75, 0, 8, 0, 8, 13}, /* DMAC INT3 */ | ||
160 | {76, 0, 8, 0, 9, 13}, /* DMAC INT4 */ | ||
161 | {78, 0, 8, 0, 11, 13}, /* DMAC ERR */ | ||
162 | {80, 0, 12, 0, 12, 13}, /* PIO0 */ | ||
163 | {84, 0, 16, 0, 13, 13}, /* PIO1 */ | ||
164 | {88, 0, 20, 0, 14, 13}, /* PIO2 */ | ||
165 | {112, 4, 0, 4, 0, 13}, /* Mailbox */ | ||
166 | #ifdef CONFIG_CPU_SUBTYPE_ST40GX1 | ||
167 | {116, 4, 4, 4, 4, 13}, /* SSC0 */ | ||
168 | {120, 4, 8, 4, 8, 13}, /* IR Blaster */ | ||
169 | {124, 4, 12, 4, 12, 13}, /* USB host */ | ||
170 | {128, 4, 16, 4, 16, 13}, /* Video processor BLITTER */ | ||
171 | {132, 4, 20, 4, 20, 13}, /* UART0 */ | ||
172 | {134, 4, 20, 4, 22, 13}, /* UART2 */ | ||
173 | {136, 4, 24, 4, 24, 13}, /* IO_PIO0 */ | ||
174 | {140, 4, 28, 4, 28, 13}, /* EMPI */ | ||
175 | {144, 8, 0, 8, 0, 13}, /* MAFE */ | ||
176 | {148, 8, 4, 8, 4, 13}, /* PWM */ | ||
177 | {152, 8, 8, 8, 8, 13}, /* SSC1 */ | ||
178 | {156, 8, 12, 8, 12, 13}, /* IO_PIO1 */ | ||
179 | {160, 8, 16, 8, 16, 13}, /* USB target */ | ||
180 | {164, 8, 20, 8, 20, 13}, /* UART1 */ | ||
181 | {168, 8, 24, 8, 24, 13}, /* Teletext */ | ||
182 | {172, 8, 28, 8, 28, 13}, /* VideoSync VTG */ | ||
183 | {173, 8, 28, 8, 29, 13}, /* VideoSync DVP0 */ | ||
184 | {174, 8, 28, 8, 30, 13}, /* VideoSync DVP1 */ | ||
185 | #endif | ||
186 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) | ||
187 | /* | ||
188 | * SH7760 INTC2-Style interrupts, vectors IRQ48-111 INTEVT 0x800-0xFE0 | ||
189 | */ | ||
190 | /* INTPRIO0 | INTMSK0 */ | ||
191 | {48, 0, 28, 0, 31, 3}, /* IRQ 4 */ | ||
192 | {49, 0, 24, 0, 30, 3}, /* IRQ 3 */ | ||
193 | {50, 0, 20, 0, 29, 3}, /* IRQ 2 */ | ||
194 | {51, 0, 16, 0, 28, 3}, /* IRQ 1 */ | ||
195 | /* 52-55 (INTEVT 0x880-0x8E0) unused/reserved */ | ||
196 | /* INTPRIO4 | INTMSK0 */ | ||
197 | {56, 4, 28, 0, 25, 3}, /* HCAN2_CHAN0 */ | ||
198 | {57, 4, 24, 0, 24, 3}, /* HCAN2_CHAN1 */ | ||
199 | {58, 4, 20, 0, 23, 3}, /* I2S_CHAN0 */ | ||
200 | {59, 4, 16, 0, 22, 3}, /* I2S_CHAN1 */ | ||
201 | {60, 4, 12, 0, 21, 3}, /* AC97_CHAN0 */ | ||
202 | {61, 4, 8, 0, 20, 3}, /* AC97_CHAN1 */ | ||
203 | {62, 4, 4, 0, 19, 3}, /* I2C_CHAN0 */ | ||
204 | {63, 4, 0, 0, 18, 3}, /* I2C_CHAN1 */ | ||
205 | /* INTPRIO8 | INTMSK0 */ | ||
206 | {52, 8, 16, 0, 11, 3}, /* SCIF0_ERI_IRQ */ | ||
207 | {53, 8, 16, 0, 10, 3}, /* SCIF0_RXI_IRQ */ | ||
208 | {54, 8, 16, 0, 9, 3}, /* SCIF0_BRI_IRQ */ | ||
209 | {55, 8, 16, 0, 8, 3}, /* SCIF0_TXI_IRQ */ | ||
210 | {64, 8, 28, 0, 17, 3}, /* USBHI_IRQ */ | ||
211 | {65, 8, 24, 0, 16, 3}, /* LCDC */ | ||
212 | /* 66, 67 unused */ | ||
213 | {68, 8, 20, 0, 14, 13}, /* DMABRGI0_IRQ */ | ||
214 | {69, 8, 20, 0, 13, 13}, /* DMABRGI1_IRQ */ | ||
215 | {70, 8, 20, 0, 12, 13}, /* DMABRGI2_IRQ */ | ||
216 | /* 71 unused */ | ||
217 | {72, 8, 12, 0, 7, 3}, /* SCIF1_ERI_IRQ */ | ||
218 | {73, 8, 12, 0, 6, 3}, /* SCIF1_RXI_IRQ */ | ||
219 | {74, 8, 12, 0, 5, 3}, /* SCIF1_BRI_IRQ */ | ||
220 | {75, 8, 12, 0, 4, 3}, /* SCIF1_TXI_IRQ */ | ||
221 | {76, 8, 8, 0, 3, 3}, /* SCIF2_ERI_IRQ */ | ||
222 | {77, 8, 8, 0, 2, 3}, /* SCIF2_RXI_IRQ */ | ||
223 | {78, 8, 8, 0, 1, 3}, /* SCIF2_BRI_IRQ */ | ||
224 | {79, 8, 8, 0, 0, 3}, /* SCIF2_TXI_IRQ */ | ||
225 | /* | INTMSK4 */ | ||
226 | {80, 8, 4, 4, 23, 3}, /* SIM_ERI */ | ||
227 | {81, 8, 4, 4, 22, 3}, /* SIM_RXI */ | ||
228 | {82, 8, 4, 4, 21, 3}, /* SIM_TXI */ | ||
229 | {83, 8, 4, 4, 20, 3}, /* SIM_TEI */ | ||
230 | {84, 8, 0, 4, 19, 3}, /* HSPII */ | ||
231 | /* INTPRIOC | INTMSK4 */ | ||
232 | /* 85-87 unused/reserved */ | ||
233 | {88, 12, 20, 4, 18, 3}, /* MMCI0 */ | ||
234 | {89, 12, 20, 4, 17, 3}, /* MMCI1 */ | ||
235 | {90, 12, 20, 4, 16, 3}, /* MMCI2 */ | ||
236 | {91, 12, 20, 4, 15, 3}, /* MMCI3 */ | ||
237 | {92, 12, 12, 4, 6, 3}, /* MFI (unsure, bug? in my 7760 manual*/ | ||
238 | /* 93-107 reserved/undocumented */ | ||
239 | {108,12, 4, 4, 1, 3}, /* ADC */ | ||
240 | {109,12, 0, 4, 0, 3}, /* CMTI */ | ||
241 | /* 110-111 reserved/unused */ | ||
242 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
243 | { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2}, | ||
244 | #ifdef CONFIG_SH_RTC | ||
245 | { RTC_IRQ, 4, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY }, | ||
246 | #endif | ||
247 | { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, | ||
248 | { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, | ||
249 | { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, | ||
250 | { SCIF0_TXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, | ||
251 | |||
252 | { SCIF1_ERI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, | ||
253 | { SCIF1_RXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, | ||
254 | { SCIF1_BRI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, | ||
255 | { SCIF1_TXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, | ||
256 | |||
257 | { PCIC0_IRQ, 0x10, 8, 0, INTC_PCIC0_MSK, PCIC0_PRIORITY }, | ||
258 | { PCIC1_IRQ, 0x10, 0, 0, INTC_PCIC1_MSK, PCIC1_PRIORITY }, | ||
259 | { PCIC2_IRQ, 0x14, 24, 0, INTC_PCIC2_MSK, PCIC2_PRIORITY }, | ||
260 | { PCIC3_IRQ, 0x14, 16, 0, INTC_PCIC3_MSK, PCIC3_PRIORITY }, | ||
261 | { PCIC4_IRQ, 0x14, 8, 0, INTC_PCIC4_MSK, PCIC4_PRIORITY }, | ||
262 | #endif | ||
263 | }; | ||
264 | |||
265 | void __init init_IRQ_intc2(void) | ||
266 | { | ||
267 | int i; | ||
268 | |||
269 | for (i = 0; i < ARRAY_SIZE(intc2_init_data); i++) { | ||
270 | struct intc2_init *p = intc2_init_data + i; | ||
271 | make_intc2_irq(p->irq, p->ipr_offset, p->ipr_shift, | ||
272 | p-> msk_offset, p->msk_shift, p->priority); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | /* Adds a termination callback to the interrupt */ | ||
277 | void intc2_add_clear_irq(int irq, int (*fn)(int)) | ||
278 | { | ||
279 | if (unlikely(irq < INTC2_FIRST_IRQ)) | ||
280 | return; | ||
281 | |||
282 | intc2_data[irq - INTC2_FIRST_IRQ].clear_irq = fn; | ||
283 | } | ||
284 | |||
diff --git a/arch/sh/kernel/cpu/irq_ipr.c b/arch/sh/kernel/cpu/irq/ipr.c index 71f92096132b..fdbd718ae5c6 100644 --- a/arch/sh/kernel/cpu/irq_ipr.c +++ b/arch/sh/kernel/cpu/irq/ipr.c | |||
@@ -1,6 +1,5 @@ | |||
1 | /* $Id: irq_ipr.c,v 1.1.2.1 2002/11/17 10:53:43 mrbrown Exp $ | 1 | /* |
2 | * | 2 | * arch/sh/kernel/cpu/irq/ipr.c |
3 | * linux/arch/sh/kernel/irq_ipr.c | ||
4 | * | 3 | * |
5 | * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi | 4 | * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi |
6 | * Copyright (C) 2000 Kazumoto Kojima | 5 | * Copyright (C) 2000 Kazumoto Kojima |
@@ -109,7 +108,8 @@ static void end_ipr_irq(unsigned int irq) | |||
109 | enable_ipr_irq(irq); | 108 | enable_ipr_irq(irq); |
110 | } | 109 | } |
111 | 110 | ||
112 | void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority) | 111 | void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, |
112 | int priority, int maskpos) | ||
113 | { | 113 | { |
114 | disable_irq_nosync(irq); | 114 | disable_irq_nosync(irq); |
115 | ipr_data[irq].addr = addr; | 115 | ipr_data[irq].addr = addr; |
@@ -120,126 +120,47 @@ void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority) | |||
120 | disable_ipr_irq(irq); | 120 | disable_ipr_irq(irq); |
121 | } | 121 | } |
122 | 122 | ||
123 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | ||
124 | defined(CONFIG_CPU_SUBTYPE_SH7707) || \ | ||
125 | defined(CONFIG_CPU_SUBTYPE_SH7709) | ||
126 | static unsigned char pint_map[256]; | ||
127 | static unsigned long portcr_mask = 0; | ||
128 | |||
129 | static void enable_pint_irq(unsigned int irq); | ||
130 | static void disable_pint_irq(unsigned int irq); | ||
131 | |||
132 | /* shutdown is same as "disable" */ | ||
133 | #define shutdown_pint_irq disable_pint_irq | ||
134 | |||
135 | static void mask_and_ack_pint(unsigned int); | ||
136 | static void end_pint_irq(unsigned int irq); | ||
137 | |||
138 | static unsigned int startup_pint_irq(unsigned int irq) | ||
139 | { | ||
140 | enable_pint_irq(irq); | ||
141 | return 0; /* never anything pending */ | ||
142 | } | ||
143 | |||
144 | static struct hw_interrupt_type pint_irq_type = { | ||
145 | .typename = "PINT-IRQ", | ||
146 | .startup = startup_pint_irq, | ||
147 | .shutdown = shutdown_pint_irq, | ||
148 | .enable = enable_pint_irq, | ||
149 | .disable = disable_pint_irq, | ||
150 | .ack = mask_and_ack_pint, | ||
151 | .end = end_pint_irq | ||
152 | }; | ||
153 | |||
154 | static void disable_pint_irq(unsigned int irq) | ||
155 | { | ||
156 | unsigned long val, flags; | ||
157 | |||
158 | local_irq_save(flags); | ||
159 | val = ctrl_inw(INTC_INTER); | ||
160 | val &= ~(1 << (irq - PINT_IRQ_BASE)); | ||
161 | ctrl_outw(val, INTC_INTER); /* disable PINTn */ | ||
162 | portcr_mask &= ~(3 << (irq - PINT_IRQ_BASE)*2); | ||
163 | local_irq_restore(flags); | ||
164 | } | ||
165 | |||
166 | static void enable_pint_irq(unsigned int irq) | ||
167 | { | ||
168 | unsigned long val, flags; | ||
169 | |||
170 | local_irq_save(flags); | ||
171 | val = ctrl_inw(INTC_INTER); | ||
172 | val |= 1 << (irq - PINT_IRQ_BASE); | ||
173 | ctrl_outw(val, INTC_INTER); /* enable PINTn */ | ||
174 | portcr_mask |= 3 << (irq - PINT_IRQ_BASE)*2; | ||
175 | local_irq_restore(flags); | ||
176 | } | ||
177 | |||
178 | static void mask_and_ack_pint(unsigned int irq) | ||
179 | { | ||
180 | disable_pint_irq(irq); | ||
181 | } | ||
182 | |||
183 | static void end_pint_irq(unsigned int irq) | ||
184 | { | ||
185 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | ||
186 | enable_pint_irq(irq); | ||
187 | } | ||
188 | |||
189 | void make_pint_irq(unsigned int irq) | ||
190 | { | ||
191 | disable_irq_nosync(irq); | ||
192 | irq_desc[irq].handler = &pint_irq_type; | ||
193 | disable_pint_irq(irq); | ||
194 | } | ||
195 | #endif | ||
196 | |||
197 | void __init init_IRQ(void) | 123 | void __init init_IRQ(void) |
198 | { | 124 | { |
199 | #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ | 125 | #ifndef CONFIG_CPU_SUBTYPE_SH7780 |
200 | defined(CONFIG_CPU_SUBTYPE_SH7707) || \ | 126 | make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY, 0); |
201 | defined(CONFIG_CPU_SUBTYPE_SH7709) | 127 | make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY, 0); |
202 | int i; | ||
203 | #endif | ||
204 | |||
205 | make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY); | ||
206 | make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY); | ||
207 | #if defined(CONFIG_SH_RTC) | 128 | #if defined(CONFIG_SH_RTC) |
208 | make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY); | 129 | make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY, 0); |
209 | #endif | 130 | #endif |
210 | 131 | ||
211 | #ifdef SCI_ERI_IRQ | 132 | #ifdef SCI_ERI_IRQ |
212 | make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); | 133 | make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY, 0); |
213 | make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); | 134 | make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY, 0); |
214 | make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); | 135 | make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY, 0); |
215 | #endif | 136 | #endif |
216 | 137 | ||
217 | #ifdef SCIF1_ERI_IRQ | 138 | #ifdef SCIF1_ERI_IRQ |
218 | make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); | 139 | make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); |
219 | make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); | 140 | make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); |
220 | make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); | 141 | make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); |
221 | make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); | 142 | make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); |
222 | #endif | 143 | #endif |
223 | 144 | ||
224 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) | 145 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) |
225 | make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY); | 146 | make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY, 0); |
226 | make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); | 147 | make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY, 0); |
227 | make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); | 148 | make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY, 0); |
228 | make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY); | 149 | make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY, 0); |
229 | #endif | 150 | #endif |
230 | 151 | ||
231 | #ifdef SCIF_ERI_IRQ | 152 | #ifdef SCIF_ERI_IRQ |
232 | make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); | 153 | make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); |
233 | make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); | 154 | make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); |
234 | make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); | 155 | make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); |
235 | make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); | 156 | make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); |
236 | #endif | 157 | #endif |
237 | 158 | ||
238 | #ifdef IRDA_ERI_IRQ | 159 | #ifdef IRDA_ERI_IRQ |
239 | make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); | 160 | make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); |
240 | make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); | 161 | make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); |
241 | make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); | 162 | make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); |
242 | make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); | 163 | make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); |
243 | #endif | 164 | #endif |
244 | 165 | ||
245 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ | 166 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ |
@@ -254,86 +175,32 @@ void __init init_IRQ(void) | |||
254 | * You should set corresponding bits of PFC to "00" | 175 | * You should set corresponding bits of PFC to "00" |
255 | * to enable these interrupts. | 176 | * to enable these interrupts. |
256 | */ | 177 | */ |
257 | make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY); | 178 | make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY, 0); |
258 | make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY); | 179 | make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY, 0); |
259 | make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY); | 180 | make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY, 0); |
260 | make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY); | 181 | make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY, 0); |
261 | make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY); | 182 | make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY, 0); |
262 | make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY); | 183 | make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY, 0); |
263 | #if !defined(CONFIG_CPU_SUBTYPE_SH7300) | 184 | #endif |
264 | make_ipr_irq(PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY); | 185 | #endif |
265 | make_ipr_irq(PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY); | ||
266 | enable_ipr_irq(PINT0_IRQ); | ||
267 | enable_ipr_irq(PINT8_IRQ); | ||
268 | 186 | ||
269 | for(i = 0; i < 16; i++) | 187 | #ifdef CONFIG_CPU_HAS_PINT_IRQ |
270 | make_pint_irq(PINT_IRQ_BASE + i); | 188 | init_IRQ_pint(); |
271 | for(i = 0; i < 256; i++) | 189 | #endif |
272 | { | ||
273 | if(i & 1) pint_map[i] = 0; | ||
274 | else if(i & 2) pint_map[i] = 1; | ||
275 | else if(i & 4) pint_map[i] = 2; | ||
276 | else if(i & 8) pint_map[i] = 3; | ||
277 | else if(i & 0x10) pint_map[i] = 4; | ||
278 | else if(i & 0x20) pint_map[i] = 5; | ||
279 | else if(i & 0x40) pint_map[i] = 6; | ||
280 | else if(i & 0x80) pint_map[i] = 7; | ||
281 | } | ||
282 | #endif /* !CONFIG_CPU_SUBTYPE_SH7300 */ | ||
283 | #endif /* CONFIG_CPU_SUBTYPE_SH7707 || CONFIG_CPU_SUBTYPE_SH7709 || CONFIG_CPU_SUBTYPE_SH7300*/ | ||
284 | 190 | ||
285 | #ifdef CONFIG_CPU_SUBTYPE_ST40 | 191 | #ifdef CONFIG_CPU_HAS_INTC2_IRQ |
286 | init_IRQ_intc2(); | 192 | init_IRQ_intc2(); |
287 | #endif | 193 | #endif |
288 | |||
289 | /* Perform the machine specific initialisation */ | 194 | /* Perform the machine specific initialisation */ |
290 | if (sh_mv.mv_init_irq != NULL) { | 195 | if (sh_mv.mv_init_irq != NULL) |
291 | sh_mv.mv_init_irq(); | 196 | sh_mv.mv_init_irq(); |
292 | } | ||
293 | } | 197 | } |
294 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ | 198 | |
295 | defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) | 199 | #if !defined(CONFIG_CPU_HAS_PINT_IRQ) |
296 | int ipr_irq_demux(int irq) | 200 | int ipr_irq_demux(int irq) |
297 | { | 201 | { |
298 | #if !defined(CONFIG_CPU_SUBTYPE_SH7300) | ||
299 | unsigned long creg, dreg, d, sav; | ||
300 | |||
301 | if(irq == PINT0_IRQ) | ||
302 | { | ||
303 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) | ||
304 | creg = PORT_PACR; | ||
305 | dreg = PORT_PADR; | ||
306 | #else | ||
307 | creg = PORT_PCCR; | ||
308 | dreg = PORT_PCDR; | ||
309 | #endif | ||
310 | sav = ctrl_inw(creg); | ||
311 | ctrl_outw(sav | portcr_mask, creg); | ||
312 | d = (~ctrl_inb(dreg) ^ ctrl_inw(INTC_ICR2)) & ctrl_inw(INTC_INTER) & 0xff; | ||
313 | ctrl_outw(sav, creg); | ||
314 | if(d == 0) return irq; | ||
315 | return PINT_IRQ_BASE + pint_map[d]; | ||
316 | } | ||
317 | else if(irq == PINT8_IRQ) | ||
318 | { | ||
319 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) | ||
320 | creg = PORT_PBCR; | ||
321 | dreg = PORT_PBDR; | ||
322 | #else | ||
323 | creg = PORT_PFCR; | ||
324 | dreg = PORT_PFDR; | ||
325 | #endif | ||
326 | sav = ctrl_inw(creg); | ||
327 | ctrl_outw(sav | (portcr_mask >> 16), creg); | ||
328 | d = (~ctrl_inb(dreg) ^ (ctrl_inw(INTC_ICR2) >> 8)) & (ctrl_inw(INTC_INTER) >> 8) & 0xff; | ||
329 | ctrl_outw(sav, creg); | ||
330 | if(d == 0) return irq; | ||
331 | return PINT_IRQ_BASE + 8 + pint_map[d]; | ||
332 | } | ||
333 | #endif | ||
334 | return irq; | 202 | return irq; |
335 | } | 203 | } |
336 | #endif | 204 | #endif |
337 | 205 | ||
338 | EXPORT_SYMBOL(make_ipr_irq); | 206 | EXPORT_SYMBOL(make_ipr_irq); |
339 | |||
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c new file mode 100644 index 000000000000..95d6024fe1ae --- /dev/null +++ b/arch/sh/kernel/cpu/irq/pint.c | |||
@@ -0,0 +1,169 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/irq/pint.c - Interrupt handling for PINT-based IRQs. | ||
3 | * | ||
4 | * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi | ||
5 | * Copyright (C) 2000 Kazumoto Kojima | ||
6 | * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp> | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/irq.h> | ||
16 | #include <linux/module.h> | ||
17 | |||
18 | #include <asm/system.h> | ||
19 | #include <asm/io.h> | ||
20 | #include <asm/machvec.h> | ||
21 | |||
22 | static unsigned char pint_map[256]; | ||
23 | static unsigned long portcr_mask; | ||
24 | |||
25 | static void enable_pint_irq(unsigned int irq); | ||
26 | static void disable_pint_irq(unsigned int irq); | ||
27 | |||
28 | /* shutdown is same as "disable" */ | ||
29 | #define shutdown_pint_irq disable_pint_irq | ||
30 | |||
31 | static void mask_and_ack_pint(unsigned int); | ||
32 | static void end_pint_irq(unsigned int irq); | ||
33 | |||
34 | static unsigned int startup_pint_irq(unsigned int irq) | ||
35 | { | ||
36 | enable_pint_irq(irq); | ||
37 | return 0; /* never anything pending */ | ||
38 | } | ||
39 | |||
40 | static struct hw_interrupt_type pint_irq_type = { | ||
41 | .typename = "PINT-IRQ", | ||
42 | .startup = startup_pint_irq, | ||
43 | .shutdown = shutdown_pint_irq, | ||
44 | .enable = enable_pint_irq, | ||
45 | .disable = disable_pint_irq, | ||
46 | .ack = mask_and_ack_pint, | ||
47 | .end = end_pint_irq | ||
48 | }; | ||
49 | |||
50 | static void disable_pint_irq(unsigned int irq) | ||
51 | { | ||
52 | unsigned long val, flags; | ||
53 | |||
54 | local_irq_save(flags); | ||
55 | val = ctrl_inw(INTC_INTER); | ||
56 | val &= ~(1 << (irq - PINT_IRQ_BASE)); | ||
57 | ctrl_outw(val, INTC_INTER); /* disable PINTn */ | ||
58 | portcr_mask &= ~(3 << (irq - PINT_IRQ_BASE)*2); | ||
59 | local_irq_restore(flags); | ||
60 | } | ||
61 | |||
62 | static void enable_pint_irq(unsigned int irq) | ||
63 | { | ||
64 | unsigned long val, flags; | ||
65 | |||
66 | local_irq_save(flags); | ||
67 | val = ctrl_inw(INTC_INTER); | ||
68 | val |= 1 << (irq - PINT_IRQ_BASE); | ||
69 | ctrl_outw(val, INTC_INTER); /* enable PINTn */ | ||
70 | portcr_mask |= 3 << (irq - PINT_IRQ_BASE)*2; | ||
71 | local_irq_restore(flags); | ||
72 | } | ||
73 | |||
74 | static void mask_and_ack_pint(unsigned int irq) | ||
75 | { | ||
76 | disable_pint_irq(irq); | ||
77 | } | ||
78 | |||
79 | static void end_pint_irq(unsigned int irq) | ||
80 | { | ||
81 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | ||
82 | enable_pint_irq(irq); | ||
83 | } | ||
84 | |||
85 | void make_pint_irq(unsigned int irq) | ||
86 | { | ||
87 | disable_irq_nosync(irq); | ||
88 | irq_desc[irq].handler = &pint_irq_type; | ||
89 | disable_pint_irq(irq); | ||
90 | } | ||
91 | |||
92 | void __init init_IRQ_pint(void) | ||
93 | { | ||
94 | int i; | ||
95 | |||
96 | make_ipr_irq(PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY); | ||
97 | make_ipr_irq(PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY); | ||
98 | |||
99 | enable_irq(PINT0_IRQ); | ||
100 | enable_irq(PINT8_IRQ); | ||
101 | |||
102 | for(i = 0; i < 16; i++) | ||
103 | make_pint_irq(PINT_IRQ_BASE + i); | ||
104 | |||
105 | for(i = 0; i < 256; i++) { | ||
106 | if (i & 1) | ||
107 | pint_map[i] = 0; | ||
108 | else if (i & 2) | ||
109 | pint_map[i] = 1; | ||
110 | else if (i & 4) | ||
111 | pint_map[i] = 2; | ||
112 | else if (i & 8) | ||
113 | pint_map[i] = 3; | ||
114 | else if (i & 0x10) | ||
115 | pint_map[i] = 4; | ||
116 | else if (i & 0x20) | ||
117 | pint_map[i] = 5; | ||
118 | else if (i & 0x40) | ||
119 | pint_map[i] = 6; | ||
120 | else if (i & 0x80) | ||
121 | pint_map[i] = 7; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | int ipr_irq_demux(int irq) | ||
126 | { | ||
127 | unsigned long creg, dreg, d, sav; | ||
128 | |||
129 | if (irq == PINT0_IRQ) { | ||
130 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) | ||
131 | creg = PORT_PACR; | ||
132 | dreg = PORT_PADR; | ||
133 | #else | ||
134 | creg = PORT_PCCR; | ||
135 | dreg = PORT_PCDR; | ||
136 | #endif | ||
137 | sav = ctrl_inw(creg); | ||
138 | ctrl_outw(sav | portcr_mask, creg); | ||
139 | d = (~ctrl_inb(dreg) ^ ctrl_inw(INTC_ICR2)) & | ||
140 | ctrl_inw(INTC_INTER) & 0xff; | ||
141 | ctrl_outw(sav, creg); | ||
142 | |||
143 | if (d == 0) | ||
144 | return irq; | ||
145 | |||
146 | return PINT_IRQ_BASE + pint_map[d]; | ||
147 | } else if (irq == PINT8_IRQ) { | ||
148 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) | ||
149 | creg = PORT_PBCR; | ||
150 | dreg = PORT_PBDR; | ||
151 | #else | ||
152 | creg = PORT_PFCR; | ||
153 | dreg = PORT_PFDR; | ||
154 | #endif | ||
155 | sav = ctrl_inw(creg); | ||
156 | ctrl_outw(sav | (portcr_mask >> 16), creg); | ||
157 | d = (~ctrl_inb(dreg) ^ (ctrl_inw(INTC_ICR2) >> 8)) & | ||
158 | (ctrl_inw(INTC_INTER) >> 8) & 0xff; | ||
159 | ctrl_outw(sav, creg); | ||
160 | |||
161 | if (d == 0) | ||
162 | return irq; | ||
163 | |||
164 | return PINT_IRQ_BASE + 8 + pint_map[d]; | ||
165 | } | ||
166 | |||
167 | return irq; | ||
168 | } | ||
169 | |||
diff --git a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile index a64532e4dc63..b54dbb9a0c86 100644 --- a/arch/sh/kernel/cpu/sh3/Makefile +++ b/arch/sh/kernel/cpu/sh3/Makefile | |||
@@ -4,3 +4,10 @@ | |||
4 | 4 | ||
5 | obj-y := ex.o probe.o | 5 | obj-y := ex.o probe.o |
6 | 6 | ||
7 | clock-$(CONFIG_CPU_SH3) := clock-sh3.o | ||
8 | clock-$(CONFIG_CPU_SUBTYPE_SH7300) := clock-sh7300.o | ||
9 | clock-$(CONFIG_CPU_SUBTYPE_SH7705) := clock-sh7705.o | ||
10 | clock-$(CONFIG_CPU_SUBTYPE_SH7709) := clock-sh7709.o | ||
11 | |||
12 | obj-y += $(clock-y) | ||
13 | |||
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh3.c b/arch/sh/kernel/cpu/sh3/clock-sh3.c new file mode 100644 index 000000000000..c3c945958baf --- /dev/null +++ b/arch/sh/kernel/cpu/sh3/clock-sh3.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh3/clock-sh3.c | ||
3 | * | ||
4 | * Generic SH-3 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * FRQCR parsing hacked out of arch/sh/kernel/time.c | ||
9 | * | ||
10 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | ||
11 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | ||
12 | * Copyright (C) 2002, 2003, 2004 Paul Mundt | ||
13 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> | ||
14 | * | ||
15 | * This file is subject to the terms and conditions of the GNU General Public | ||
16 | * License. See the file "COPYING" in the main directory of this archive | ||
17 | * for more details. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <asm/clock.h> | ||
22 | #include <asm/freq.h> | ||
23 | #include <asm/io.h> | ||
24 | |||
25 | static int stc_multipliers[] = { 1, 2, 3, 4, 6, 1, 1, 1 }; | ||
26 | static int ifc_divisors[] = { 1, 2, 3, 4, 1, 1, 1, 1 }; | ||
27 | static int pfc_divisors[] = { 1, 2, 3, 4, 6, 1, 1, 1 }; | ||
28 | |||
29 | static void master_clk_init(struct clk *clk) | ||
30 | { | ||
31 | int frqcr = ctrl_inw(FRQCR); | ||
32 | int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); | ||
33 | |||
34 | clk->rate *= pfc_divisors[idx]; | ||
35 | } | ||
36 | |||
37 | static struct clk_ops sh3_master_clk_ops = { | ||
38 | .init = master_clk_init, | ||
39 | }; | ||
40 | |||
41 | static void module_clk_recalc(struct clk *clk) | ||
42 | { | ||
43 | int frqcr = ctrl_inw(FRQCR); | ||
44 | int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); | ||
45 | |||
46 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | ||
47 | } | ||
48 | |||
49 | static struct clk_ops sh3_module_clk_ops = { | ||
50 | .recalc = module_clk_recalc, | ||
51 | }; | ||
52 | |||
53 | static void bus_clk_recalc(struct clk *clk) | ||
54 | { | ||
55 | int frqcr = ctrl_inw(FRQCR); | ||
56 | int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4); | ||
57 | |||
58 | clk->rate = clk->parent->rate / stc_multipliers[idx]; | ||
59 | } | ||
60 | |||
61 | static struct clk_ops sh3_bus_clk_ops = { | ||
62 | .recalc = bus_clk_recalc, | ||
63 | }; | ||
64 | |||
65 | static void cpu_clk_recalc(struct clk *clk) | ||
66 | { | ||
67 | int frqcr = ctrl_inw(FRQCR); | ||
68 | int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2); | ||
69 | |||
70 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | ||
71 | } | ||
72 | |||
73 | static struct clk_ops sh3_cpu_clk_ops = { | ||
74 | .recalc = cpu_clk_recalc, | ||
75 | }; | ||
76 | |||
77 | static struct clk_ops *sh3_clk_ops[] = { | ||
78 | &sh3_master_clk_ops, | ||
79 | &sh3_module_clk_ops, | ||
80 | &sh3_bus_clk_ops, | ||
81 | &sh3_cpu_clk_ops, | ||
82 | }; | ||
83 | |||
84 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
85 | { | ||
86 | if (idx < ARRAY_SIZE(sh3_clk_ops)) | ||
87 | *ops = sh3_clk_ops[idx]; | ||
88 | } | ||
89 | |||
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7300.c b/arch/sh/kernel/cpu/sh3/clock-sh7300.c new file mode 100644 index 000000000000..e804174b9625 --- /dev/null +++ b/arch/sh/kernel/cpu/sh3/clock-sh7300.c | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh3/clock-sh7300.c | ||
3 | * | ||
4 | * SH7300 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * FRQCR parsing hacked out of arch/sh/kernel/time.c | ||
9 | * | ||
10 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | ||
11 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | ||
12 | * Copyright (C) 2002, 2003, 2004 Paul Mundt | ||
13 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> | ||
14 | * | ||
15 | * This file is subject to the terms and conditions of the GNU General Public | ||
16 | * License. See the file "COPYING" in the main directory of this archive | ||
17 | * for more details. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <asm/clock.h> | ||
22 | #include <asm/freq.h> | ||
23 | #include <asm/io.h> | ||
24 | |||
25 | static int md_table[] = { 1, 2, 3, 4, 6, 8, 12 }; | ||
26 | |||
27 | static void master_clk_init(struct clk *clk) | ||
28 | { | ||
29 | clk->rate *= md_table[ctrl_inw(FRQCR) & 0x0007]; | ||
30 | } | ||
31 | |||
32 | static struct clk_ops sh7300_master_clk_ops = { | ||
33 | .init = master_clk_init, | ||
34 | }; | ||
35 | |||
36 | static void module_clk_recalc(struct clk *clk) | ||
37 | { | ||
38 | int idx = (ctrl_inw(FRQCR) & 0x0007); | ||
39 | clk->rate = clk->parent->rate / md_table[idx]; | ||
40 | } | ||
41 | |||
42 | static struct clk_ops sh7300_module_clk_ops = { | ||
43 | .recalc = module_clk_recalc, | ||
44 | }; | ||
45 | |||
46 | static void bus_clk_recalc(struct clk *clk) | ||
47 | { | ||
48 | int idx = (ctrl_inw(FRQCR) & 0x0700) >> 8; | ||
49 | clk->rate = clk->parent->rate / md_table[idx]; | ||
50 | } | ||
51 | |||
52 | static struct clk_ops sh7300_bus_clk_ops = { | ||
53 | .recalc = bus_clk_recalc, | ||
54 | }; | ||
55 | |||
56 | static void cpu_clk_recalc(struct clk *clk) | ||
57 | { | ||
58 | int idx = (ctrl_inw(FRQCR) & 0x0070) >> 4; | ||
59 | clk->rate = clk->parent->rate / md_table[idx]; | ||
60 | } | ||
61 | |||
62 | static struct clk_ops sh7300_cpu_clk_ops = { | ||
63 | .recalc = cpu_clk_recalc, | ||
64 | }; | ||
65 | |||
66 | static struct clk_ops *sh7300_clk_ops[] = { | ||
67 | &sh7300_master_clk_ops, | ||
68 | &sh7300_module_clk_ops, | ||
69 | &sh7300_bus_clk_ops, | ||
70 | &sh7300_cpu_clk_ops, | ||
71 | }; | ||
72 | |||
73 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
74 | { | ||
75 | if (idx < ARRAY_SIZE(sh7300_clk_ops)) | ||
76 | *ops = sh7300_clk_ops[idx]; | ||
77 | } | ||
78 | |||
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7705.c b/arch/sh/kernel/cpu/sh3/clock-sh7705.c new file mode 100644 index 000000000000..dfdbf3277fd7 --- /dev/null +++ b/arch/sh/kernel/cpu/sh3/clock-sh7705.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh3/clock-sh7705.c | ||
3 | * | ||
4 | * SH7705 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * FRQCR parsing hacked out of arch/sh/kernel/time.c | ||
9 | * | ||
10 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | ||
11 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | ||
12 | * Copyright (C) 2002, 2003, 2004 Paul Mundt | ||
13 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> | ||
14 | * | ||
15 | * This file is subject to the terms and conditions of the GNU General Public | ||
16 | * License. See the file "COPYING" in the main directory of this archive | ||
17 | * for more details. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <asm/clock.h> | ||
22 | #include <asm/freq.h> | ||
23 | #include <asm/io.h> | ||
24 | |||
25 | /* | ||
26 | * SH7705 uses the same divisors as the generic SH-3 case, it's just the | ||
27 | * FRQCR layout that is a bit different.. | ||
28 | */ | ||
29 | static int stc_multipliers[] = { 1, 2, 3, 4, 6, 1, 1, 1 }; | ||
30 | static int ifc_divisors[] = { 1, 2, 3, 4, 1, 1, 1, 1 }; | ||
31 | static int pfc_divisors[] = { 1, 2, 3, 4, 6, 1, 1, 1 }; | ||
32 | |||
33 | static void master_clk_init(struct clk *clk) | ||
34 | { | ||
35 | clk->rate *= pfc_divisors[ctrl_inw(FRQCR) & 0x0003]; | ||
36 | } | ||
37 | |||
38 | static struct clk_ops sh7705_master_clk_ops = { | ||
39 | .init = master_clk_init, | ||
40 | }; | ||
41 | |||
42 | static void module_clk_recalc(struct clk *clk) | ||
43 | { | ||
44 | int idx = ctrl_inw(FRQCR) & 0x0003; | ||
45 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | ||
46 | } | ||
47 | |||
48 | static struct clk_ops sh7705_module_clk_ops = { | ||
49 | .recalc = module_clk_recalc, | ||
50 | }; | ||
51 | |||
52 | static void bus_clk_recalc(struct clk *clk) | ||
53 | { | ||
54 | int idx = (ctrl_inw(FRQCR) & 0x0300) >> 8; | ||
55 | clk->rate = clk->parent->rate / stc_multipliers[idx]; | ||
56 | } | ||
57 | |||
58 | static struct clk_ops sh7705_bus_clk_ops = { | ||
59 | .recalc = bus_clk_recalc, | ||
60 | }; | ||
61 | |||
62 | static void cpu_clk_recalc(struct clk *clk) | ||
63 | { | ||
64 | int idx = (ctrl_inw(FRQCR) & 0x0030) >> 4; | ||
65 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | ||
66 | } | ||
67 | |||
68 | static struct clk_ops sh7705_cpu_clk_ops = { | ||
69 | .recalc = cpu_clk_recalc, | ||
70 | }; | ||
71 | |||
72 | static struct clk_ops *sh7705_clk_ops[] = { | ||
73 | &sh7705_master_clk_ops, | ||
74 | &sh7705_module_clk_ops, | ||
75 | &sh7705_bus_clk_ops, | ||
76 | &sh7705_cpu_clk_ops, | ||
77 | }; | ||
78 | |||
79 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
80 | { | ||
81 | if (idx < ARRAY_SIZE(sh7705_clk_ops)) | ||
82 | *ops = sh7705_clk_ops[idx]; | ||
83 | } | ||
84 | |||
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7709.c b/arch/sh/kernel/cpu/sh3/clock-sh7709.c new file mode 100644 index 000000000000..10461a745e5f --- /dev/null +++ b/arch/sh/kernel/cpu/sh3/clock-sh7709.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh3/clock-sh7709.c | ||
3 | * | ||
4 | * SH7709 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Andriy Skulysh | ||
7 | * | ||
8 | * Based on arch/sh/kernel/cpu/sh3/clock-sh7705.c | ||
9 | * Copyright (C) 2005 Paul Mundt | ||
10 | * | ||
11 | * 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 | ||
13 | * for more details. | ||
14 | */ | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <asm/clock.h> | ||
18 | #include <asm/freq.h> | ||
19 | #include <asm/io.h> | ||
20 | |||
21 | static int stc_multipliers[] = { 1, 2, 4, 8, 3, 6, 1, 1 }; | ||
22 | static int ifc_divisors[] = { 1, 2, 4, 1, 3, 1, 1, 1 }; | ||
23 | static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 }; | ||
24 | |||
25 | static void set_bus_parent(struct clk *clk) | ||
26 | { | ||
27 | struct clk *bus_clk = clk_get("bus_clk"); | ||
28 | clk->parent = bus_clk; | ||
29 | clk_put(bus_clk); | ||
30 | } | ||
31 | |||
32 | static void master_clk_init(struct clk *clk) | ||
33 | { | ||
34 | int frqcr = ctrl_inw(FRQCR); | ||
35 | int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); | ||
36 | |||
37 | clk->rate *= pfc_divisors[idx]; | ||
38 | } | ||
39 | |||
40 | static struct clk_ops sh7709_master_clk_ops = { | ||
41 | .init = master_clk_init, | ||
42 | }; | ||
43 | |||
44 | static void module_clk_recalc(struct clk *clk) | ||
45 | { | ||
46 | int frqcr = ctrl_inw(FRQCR); | ||
47 | int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003); | ||
48 | |||
49 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | ||
50 | } | ||
51 | |||
52 | static struct clk_ops sh7709_module_clk_ops = { | ||
53 | #ifdef CLOCK_MODE_0_1_2_7 | ||
54 | .init = set_bus_parent, | ||
55 | #endif | ||
56 | .recalc = module_clk_recalc, | ||
57 | }; | ||
58 | |||
59 | static void bus_clk_recalc(struct clk *clk) | ||
60 | { | ||
61 | int frqcr = ctrl_inw(FRQCR); | ||
62 | int idx = (frqcr & 0x0080) ? | ||
63 | ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4) : 1; | ||
64 | |||
65 | clk->rate = clk->parent->rate * stc_multipliers[idx]; | ||
66 | } | ||
67 | |||
68 | static struct clk_ops sh7709_bus_clk_ops = { | ||
69 | .recalc = bus_clk_recalc, | ||
70 | }; | ||
71 | |||
72 | static void cpu_clk_recalc(struct clk *clk) | ||
73 | { | ||
74 | int frqcr = ctrl_inw(FRQCR); | ||
75 | int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2); | ||
76 | |||
77 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | ||
78 | } | ||
79 | |||
80 | static struct clk_ops sh7709_cpu_clk_ops = { | ||
81 | .init = set_bus_parent, | ||
82 | .recalc = cpu_clk_recalc, | ||
83 | }; | ||
84 | |||
85 | static struct clk_ops *sh7709_clk_ops[] = { | ||
86 | &sh7709_master_clk_ops, | ||
87 | &sh7709_module_clk_ops, | ||
88 | &sh7709_bus_clk_ops, | ||
89 | &sh7709_cpu_clk_ops, | ||
90 | }; | ||
91 | |||
92 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
93 | { | ||
94 | if (idx < ARRAY_SIZE(sh7709_clk_ops)) | ||
95 | *ops = sh7709_clk_ops[idx]; | ||
96 | } | ||
diff --git a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile index ead1071eac73..3d5cafc71ae3 100644 --- a/arch/sh/kernel/cpu/sh4/Makefile +++ b/arch/sh/kernel/cpu/sh4/Makefile | |||
@@ -5,6 +5,15 @@ | |||
5 | obj-y := ex.o probe.o | 5 | obj-y := ex.o probe.o |
6 | 6 | ||
7 | obj-$(CONFIG_SH_FPU) += fpu.o | 7 | obj-$(CONFIG_SH_FPU) += fpu.o |
8 | obj-$(CONFIG_CPU_SUBTYPE_ST40STB1) += irq_intc2.o | ||
9 | obj-$(CONFIG_SH_STORE_QUEUES) += sq.o | 8 | obj-$(CONFIG_SH_STORE_QUEUES) += sq.o |
10 | 9 | ||
10 | # Primary on-chip clocks (common) | ||
11 | clock-$(CONFIG_CPU_SH4) := clock-sh4.o | ||
12 | clock-$(CONFIG_CPU_SUBTYPE_SH73180) := clock-sh73180.o | ||
13 | clock-$(CONFIG_CPU_SUBTYPE_SH7770) := clock-sh7770.o | ||
14 | clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o | ||
15 | |||
16 | # Additional clocks by subtype | ||
17 | clock-$(CONFIG_CPU_SUBTYPE_SH4_202) += clock-sh4-202.o | ||
18 | |||
19 | obj-y += $(clock-y) | ||
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c new file mode 100644 index 000000000000..bfdf5fe8d948 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4/clock-sh4-202.c | ||
3 | * | ||
4 | * Additional SH4-202 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/err.h> | ||
15 | #include <asm/clock.h> | ||
16 | #include <asm/freq.h> | ||
17 | #include <asm/io.h> | ||
18 | |||
19 | #define CPG2_FRQCR3 0xfe0a0018 | ||
20 | |||
21 | static int frqcr3_divisors[] = { 1, 2, 3, 4, 6, 8, 16 }; | ||
22 | static int frqcr3_values[] = { 0, 1, 2, 3, 4, 5, 6 }; | ||
23 | |||
24 | static void emi_clk_recalc(struct clk *clk) | ||
25 | { | ||
26 | int idx = ctrl_inl(CPG2_FRQCR3) & 0x0007; | ||
27 | clk->rate = clk->parent->rate / frqcr3_divisors[idx]; | ||
28 | } | ||
29 | |||
30 | static inline int frqcr3_lookup(struct clk *clk, unsigned long rate) | ||
31 | { | ||
32 | int divisor = clk->parent->rate / rate; | ||
33 | int i; | ||
34 | |||
35 | for (i = 0; i < ARRAY_SIZE(frqcr3_divisors); i++) | ||
36 | if (frqcr3_divisors[i] == divisor) | ||
37 | return frqcr3_values[i]; | ||
38 | |||
39 | /* Safe fallback */ | ||
40 | return 5; | ||
41 | } | ||
42 | |||
43 | static struct clk_ops sh4202_emi_clk_ops = { | ||
44 | .recalc = emi_clk_recalc, | ||
45 | }; | ||
46 | |||
47 | static struct clk sh4202_emi_clk = { | ||
48 | .name = "emi_clk", | ||
49 | .flags = CLK_ALWAYS_ENABLED, | ||
50 | .ops = &sh4202_emi_clk_ops, | ||
51 | }; | ||
52 | |||
53 | static void femi_clk_recalc(struct clk *clk) | ||
54 | { | ||
55 | int idx = (ctrl_inl(CPG2_FRQCR3) >> 3) & 0x0007; | ||
56 | clk->rate = clk->parent->rate / frqcr3_divisors[idx]; | ||
57 | } | ||
58 | |||
59 | static struct clk_ops sh4202_femi_clk_ops = { | ||
60 | .recalc = femi_clk_recalc, | ||
61 | }; | ||
62 | |||
63 | static struct clk sh4202_femi_clk = { | ||
64 | .name = "femi_clk", | ||
65 | .flags = CLK_ALWAYS_ENABLED, | ||
66 | .ops = &sh4202_femi_clk_ops, | ||
67 | }; | ||
68 | |||
69 | static void shoc_clk_init(struct clk *clk) | ||
70 | { | ||
71 | int i; | ||
72 | |||
73 | /* | ||
74 | * For some reason, the shoc_clk seems to be set to some really | ||
75 | * insane value at boot (values outside of the allowable frequency | ||
76 | * range for instance). We deal with this by scaling it back down | ||
77 | * to something sensible just in case. | ||
78 | * | ||
79 | * Start scaling from the high end down until we find something | ||
80 | * that passes rate verification.. | ||
81 | */ | ||
82 | for (i = 0; i < ARRAY_SIZE(frqcr3_divisors); i++) { | ||
83 | int divisor = frqcr3_divisors[i]; | ||
84 | |||
85 | if (clk->ops->set_rate(clk, clk->parent->rate / divisor) == 0) | ||
86 | break; | ||
87 | } | ||
88 | |||
89 | WARN_ON(i == ARRAY_SIZE(frqcr3_divisors)); /* Undefined clock */ | ||
90 | } | ||
91 | |||
92 | static void shoc_clk_recalc(struct clk *clk) | ||
93 | { | ||
94 | int idx = (ctrl_inl(CPG2_FRQCR3) >> 6) & 0x0007; | ||
95 | clk->rate = clk->parent->rate / frqcr3_divisors[idx]; | ||
96 | } | ||
97 | |||
98 | static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) | ||
99 | { | ||
100 | struct clk *bclk = clk_get("bus_clk"); | ||
101 | unsigned long bclk_rate = clk_get_rate(bclk); | ||
102 | |||
103 | clk_put(bclk); | ||
104 | |||
105 | if (rate > bclk_rate) | ||
106 | return 1; | ||
107 | if (rate > 66000000) | ||
108 | return 1; | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static int shoc_clk_set_rate(struct clk *clk, unsigned long rate) | ||
114 | { | ||
115 | unsigned long frqcr3; | ||
116 | unsigned int tmp; | ||
117 | |||
118 | /* Make sure we have something sensible to switch to */ | ||
119 | if (shoc_clk_verify_rate(clk, rate) != 0) | ||
120 | return -EINVAL; | ||
121 | |||
122 | tmp = frqcr3_lookup(clk, rate); | ||
123 | |||
124 | frqcr3 = ctrl_inl(CPG2_FRQCR3); | ||
125 | frqcr3 &= ~(0x0007 << 6); | ||
126 | frqcr3 |= tmp << 6; | ||
127 | ctrl_outl(frqcr3, CPG2_FRQCR3); | ||
128 | |||
129 | clk->rate = clk->parent->rate / frqcr3_divisors[tmp]; | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static struct clk_ops sh4202_shoc_clk_ops = { | ||
135 | .init = shoc_clk_init, | ||
136 | .recalc = shoc_clk_recalc, | ||
137 | .set_rate = shoc_clk_set_rate, | ||
138 | }; | ||
139 | |||
140 | static struct clk sh4202_shoc_clk = { | ||
141 | .name = "shoc_clk", | ||
142 | .flags = CLK_ALWAYS_ENABLED, | ||
143 | .ops = &sh4202_shoc_clk_ops, | ||
144 | }; | ||
145 | |||
146 | static struct clk *sh4202_onchip_clocks[] = { | ||
147 | &sh4202_emi_clk, | ||
148 | &sh4202_femi_clk, | ||
149 | &sh4202_shoc_clk, | ||
150 | }; | ||
151 | |||
152 | static int __init sh4202_clk_init(void) | ||
153 | { | ||
154 | struct clk *clk = clk_get("master_clk"); | ||
155 | int i; | ||
156 | |||
157 | for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { | ||
158 | struct clk *clkp = sh4202_onchip_clocks[i]; | ||
159 | |||
160 | clkp->parent = clk; | ||
161 | clk_register(clkp); | ||
162 | clk_enable(clkp); | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Now that we have the rest of the clocks registered, we need to | ||
167 | * force the parent clock to propagate so that these clocks will | ||
168 | * automatically figure out their rate. We cheat by handing the | ||
169 | * parent clock its current rate and forcing child propagation. | ||
170 | */ | ||
171 | clk_set_rate(clk, clk_get_rate(clk)); | ||
172 | |||
173 | clk_put(clk); | ||
174 | |||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | arch_initcall(sh4202_clk_init); | ||
179 | |||
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4.c b/arch/sh/kernel/cpu/sh4/clock-sh4.c new file mode 100644 index 000000000000..dca9f87a12d6 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4/clock-sh4.c | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4/clock-sh4.c | ||
3 | * | ||
4 | * Generic SH-4 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * FRQCR parsing hacked out of arch/sh/kernel/time.c | ||
9 | * | ||
10 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | ||
11 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | ||
12 | * Copyright (C) 2002, 2003, 2004 Paul Mundt | ||
13 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> | ||
14 | * | ||
15 | * This file is subject to the terms and conditions of the GNU General Public | ||
16 | * License. See the file "COPYING" in the main directory of this archive | ||
17 | * for more details. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <asm/clock.h> | ||
22 | #include <asm/freq.h> | ||
23 | #include <asm/io.h> | ||
24 | |||
25 | static int ifc_divisors[] = { 1, 2, 3, 4, 6, 8, 1, 1 }; | ||
26 | #define bfc_divisors ifc_divisors /* Same */ | ||
27 | static int pfc_divisors[] = { 2, 3, 4, 6, 8, 2, 2, 2 }; | ||
28 | |||
29 | static void master_clk_init(struct clk *clk) | ||
30 | { | ||
31 | clk->rate *= pfc_divisors[ctrl_inw(FRQCR) & 0x0007]; | ||
32 | } | ||
33 | |||
34 | static struct clk_ops sh4_master_clk_ops = { | ||
35 | .init = master_clk_init, | ||
36 | }; | ||
37 | |||
38 | static void module_clk_recalc(struct clk *clk) | ||
39 | { | ||
40 | int idx = (ctrl_inw(FRQCR) & 0x0007); | ||
41 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | ||
42 | } | ||
43 | |||
44 | static struct clk_ops sh4_module_clk_ops = { | ||
45 | .recalc = module_clk_recalc, | ||
46 | }; | ||
47 | |||
48 | static void bus_clk_recalc(struct clk *clk) | ||
49 | { | ||
50 | int idx = (ctrl_inw(FRQCR) >> 3) & 0x0007; | ||
51 | clk->rate = clk->parent->rate / bfc_divisors[idx]; | ||
52 | } | ||
53 | |||
54 | static struct clk_ops sh4_bus_clk_ops = { | ||
55 | .recalc = bus_clk_recalc, | ||
56 | }; | ||
57 | |||
58 | static void cpu_clk_recalc(struct clk *clk) | ||
59 | { | ||
60 | int idx = (ctrl_inw(FRQCR) >> 6) & 0x0007; | ||
61 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | ||
62 | } | ||
63 | |||
64 | static struct clk_ops sh4_cpu_clk_ops = { | ||
65 | .recalc = cpu_clk_recalc, | ||
66 | }; | ||
67 | |||
68 | static struct clk_ops *sh4_clk_ops[] = { | ||
69 | &sh4_master_clk_ops, | ||
70 | &sh4_module_clk_ops, | ||
71 | &sh4_bus_clk_ops, | ||
72 | &sh4_cpu_clk_ops, | ||
73 | }; | ||
74 | |||
75 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
76 | { | ||
77 | if (idx < ARRAY_SIZE(sh4_clk_ops)) | ||
78 | *ops = sh4_clk_ops[idx]; | ||
79 | } | ||
80 | |||
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh73180.c b/arch/sh/kernel/cpu/sh4/clock-sh73180.c new file mode 100644 index 000000000000..2fa5cb2ae68d --- /dev/null +++ b/arch/sh/kernel/cpu/sh4/clock-sh73180.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4/clock-sh73180.c | ||
3 | * | ||
4 | * SH73180 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * FRQCR parsing hacked out of arch/sh/kernel/time.c | ||
9 | * | ||
10 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | ||
11 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | ||
12 | * Copyright (C) 2002, 2003, 2004 Paul Mundt | ||
13 | * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> | ||
14 | * | ||
15 | * This file is subject to the terms and conditions of the GNU General Public | ||
16 | * License. See the file "COPYING" in the main directory of this archive | ||
17 | * for more details. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <asm/clock.h> | ||
22 | #include <asm/freq.h> | ||
23 | #include <asm/io.h> | ||
24 | |||
25 | /* | ||
26 | * SH73180 uses a common set of divisors, so this is quite simple.. | ||
27 | */ | ||
28 | static int divisors[] = { 1, 2, 3, 4, 6, 8, 12, 16 }; | ||
29 | |||
30 | static void master_clk_init(struct clk *clk) | ||
31 | { | ||
32 | clk->rate *= divisors[ctrl_inl(FRQCR) & 0x0007]; | ||
33 | } | ||
34 | |||
35 | static struct clk_ops sh73180_master_clk_ops = { | ||
36 | .init = master_clk_init, | ||
37 | }; | ||
38 | |||
39 | static void module_clk_recalc(struct clk *clk) | ||
40 | { | ||
41 | int idx = (ctrl_inl(FRQCR) & 0x0007); | ||
42 | clk->rate = clk->parent->rate / divisors[idx]; | ||
43 | } | ||
44 | |||
45 | static struct clk_ops sh73180_module_clk_ops = { | ||
46 | .recalc = module_clk_recalc, | ||
47 | }; | ||
48 | |||
49 | static void bus_clk_recalc(struct clk *clk) | ||
50 | { | ||
51 | int idx = (ctrl_inl(FRQCR) >> 12) & 0x0007; | ||
52 | clk->rate = clk->parent->rate / divisors[idx]; | ||
53 | } | ||
54 | |||
55 | static struct clk_ops sh73180_bus_clk_ops = { | ||
56 | .recalc = bus_clk_recalc, | ||
57 | }; | ||
58 | |||
59 | static void cpu_clk_recalc(struct clk *clk) | ||
60 | { | ||
61 | int idx = (ctrl_inl(FRQCR) >> 20) & 0x0007; | ||
62 | clk->rate = clk->parent->rate / divisors[idx]; | ||
63 | } | ||
64 | |||
65 | static struct clk_ops sh73180_cpu_clk_ops = { | ||
66 | .recalc = cpu_clk_recalc, | ||
67 | }; | ||
68 | |||
69 | static struct clk_ops *sh73180_clk_ops[] = { | ||
70 | &sh73180_master_clk_ops, | ||
71 | &sh73180_module_clk_ops, | ||
72 | &sh73180_bus_clk_ops, | ||
73 | &sh73180_cpu_clk_ops, | ||
74 | }; | ||
75 | |||
76 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
77 | { | ||
78 | if (idx < ARRAY_SIZE(sh73180_clk_ops)) | ||
79 | *ops = sh73180_clk_ops[idx]; | ||
80 | } | ||
81 | |||
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh7770.c b/arch/sh/kernel/cpu/sh4/clock-sh7770.c new file mode 100644 index 000000000000..c8694bac6477 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4/clock-sh7770.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4/clock-sh7770.c | ||
3 | * | ||
4 | * SH7770 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <asm/clock.h> | ||
15 | #include <asm/freq.h> | ||
16 | #include <asm/io.h> | ||
17 | |||
18 | static int ifc_divisors[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; | ||
19 | static int bfc_divisors[] = { 1, 1, 1, 1, 1, 8,12, 1 }; | ||
20 | static int pfc_divisors[] = { 1, 8, 1,10,12,16, 1, 1 }; | ||
21 | |||
22 | static void master_clk_init(struct clk *clk) | ||
23 | { | ||
24 | clk->rate *= pfc_divisors[(ctrl_inl(FRQCR) >> 28) & 0x000f]; | ||
25 | } | ||
26 | |||
27 | static struct clk_ops sh7770_master_clk_ops = { | ||
28 | .init = master_clk_init, | ||
29 | }; | ||
30 | |||
31 | static void module_clk_recalc(struct clk *clk) | ||
32 | { | ||
33 | int idx = ((ctrl_inl(FRQCR) >> 28) & 0x000f); | ||
34 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | ||
35 | } | ||
36 | |||
37 | static struct clk_ops sh7770_module_clk_ops = { | ||
38 | .recalc = module_clk_recalc, | ||
39 | }; | ||
40 | |||
41 | static void bus_clk_recalc(struct clk *clk) | ||
42 | { | ||
43 | int idx = (ctrl_inl(FRQCR) & 0x000f); | ||
44 | clk->rate = clk->parent->rate / bfc_divisors[idx]; | ||
45 | } | ||
46 | |||
47 | static struct clk_ops sh7770_bus_clk_ops = { | ||
48 | .recalc = bus_clk_recalc, | ||
49 | }; | ||
50 | |||
51 | static void cpu_clk_recalc(struct clk *clk) | ||
52 | { | ||
53 | int idx = ((ctrl_inl(FRQCR) >> 24) & 0x000f); | ||
54 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | ||
55 | } | ||
56 | |||
57 | static struct clk_ops sh7770_cpu_clk_ops = { | ||
58 | .recalc = cpu_clk_recalc, | ||
59 | }; | ||
60 | |||
61 | static struct clk_ops *sh7770_clk_ops[] = { | ||
62 | &sh7770_master_clk_ops, | ||
63 | &sh7770_module_clk_ops, | ||
64 | &sh7770_bus_clk_ops, | ||
65 | &sh7770_cpu_clk_ops, | ||
66 | }; | ||
67 | |||
68 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
69 | { | ||
70 | if (idx < ARRAY_SIZE(sh7770_clk_ops)) | ||
71 | *ops = sh7770_clk_ops[idx]; | ||
72 | } | ||
73 | |||
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh7780.c b/arch/sh/kernel/cpu/sh4/clock-sh7780.c new file mode 100644 index 000000000000..93ad367342c9 --- /dev/null +++ b/arch/sh/kernel/cpu/sh4/clock-sh7780.c | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh4/clock-sh7780.c | ||
3 | * | ||
4 | * SH7780 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2005 Paul Mundt | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <asm/clock.h> | ||
15 | #include <asm/freq.h> | ||
16 | #include <asm/io.h> | ||
17 | |||
18 | static int ifc_divisors[] = { 2, 4 }; | ||
19 | static int bfc_divisors[] = { 1, 1, 1, 8, 12, 16, 24, 1 }; | ||
20 | static int pfc_divisors[] = { 1, 24, 24, 1 }; | ||
21 | static int cfc_divisors[] = { 1, 1, 4, 1, 6, 1, 1, 1 }; | ||
22 | |||
23 | static void master_clk_init(struct clk *clk) | ||
24 | { | ||
25 | clk->rate *= pfc_divisors[ctrl_inl(FRQCR) & 0x0003]; | ||
26 | } | ||
27 | |||
28 | static struct clk_ops sh7780_master_clk_ops = { | ||
29 | .init = master_clk_init, | ||
30 | }; | ||
31 | |||
32 | static void module_clk_recalc(struct clk *clk) | ||
33 | { | ||
34 | int idx = (ctrl_inl(FRQCR) & 0x0003); | ||
35 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | ||
36 | } | ||
37 | |||
38 | static struct clk_ops sh7780_module_clk_ops = { | ||
39 | .recalc = module_clk_recalc, | ||
40 | }; | ||
41 | |||
42 | static void bus_clk_recalc(struct clk *clk) | ||
43 | { | ||
44 | int idx = ((ctrl_inl(FRQCR) >> 16) & 0x0007); | ||
45 | clk->rate = clk->parent->rate / bfc_divisors[idx]; | ||
46 | } | ||
47 | |||
48 | static struct clk_ops sh7780_bus_clk_ops = { | ||
49 | .recalc = bus_clk_recalc, | ||
50 | }; | ||
51 | |||
52 | static void cpu_clk_recalc(struct clk *clk) | ||
53 | { | ||
54 | int idx = ((ctrl_inl(FRQCR) >> 24) & 0x0001); | ||
55 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | ||
56 | } | ||
57 | |||
58 | static struct clk_ops sh7780_cpu_clk_ops = { | ||
59 | .recalc = cpu_clk_recalc, | ||
60 | }; | ||
61 | |||
62 | static struct clk_ops *sh7780_clk_ops[] = { | ||
63 | &sh7780_master_clk_ops, | ||
64 | &sh7780_module_clk_ops, | ||
65 | &sh7780_bus_clk_ops, | ||
66 | &sh7780_cpu_clk_ops, | ||
67 | }; | ||
68 | |||
69 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
70 | { | ||
71 | if (idx < ARRAY_SIZE(sh7780_clk_ops)) | ||
72 | *ops = sh7780_clk_ops[idx]; | ||
73 | } | ||
74 | |||
75 | static void shyway_clk_recalc(struct clk *clk) | ||
76 | { | ||
77 | int idx = ((ctrl_inl(FRQCR) >> 20) & 0x0007); | ||
78 | clk->rate = clk->parent->rate / cfc_divisors[idx]; | ||
79 | } | ||
80 | |||
81 | static struct clk_ops sh7780_shyway_clk_ops = { | ||
82 | .recalc = shyway_clk_recalc, | ||
83 | }; | ||
84 | |||
85 | static struct clk sh7780_shyway_clk = { | ||
86 | .name = "shyway_clk", | ||
87 | .flags = CLK_ALWAYS_ENABLED, | ||
88 | .ops = &sh7780_shyway_clk_ops, | ||
89 | }; | ||
90 | |||
91 | /* | ||
92 | * Additional SH7780-specific on-chip clocks that aren't already part of the | ||
93 | * clock framework | ||
94 | */ | ||
95 | static struct clk *sh7780_onchip_clocks[] = { | ||
96 | &sh7780_shyway_clk, | ||
97 | }; | ||
98 | |||
99 | static int __init sh7780_clk_init(void) | ||
100 | { | ||
101 | struct clk *clk = clk_get("master_clk"); | ||
102 | int i; | ||
103 | |||
104 | for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { | ||
105 | struct clk *clkp = sh7780_onchip_clocks[i]; | ||
106 | |||
107 | clkp->parent = clk; | ||
108 | clk_register(clkp); | ||
109 | clk_enable(clkp); | ||
110 | } | ||
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 | |||
120 | clk_put(clk); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | arch_initcall(sh7780_clk_init); | ||
126 | |||
diff --git a/arch/sh/kernel/cpu/sh4/irq_intc2.c b/arch/sh/kernel/cpu/sh4/irq_intc2.c deleted file mode 100644 index f6b16ba01932..000000000000 --- a/arch/sh/kernel/cpu/sh4/irq_intc2.c +++ /dev/null | |||
@@ -1,222 +0,0 @@ | |||
1 | /* | ||
2 | * linux/arch/sh/kernel/irq_intc2.c | ||
3 | * | ||
4 | * Copyright (C) 2001 David J. Mckay (david.mckay@st.com) | ||
5 | * | ||
6 | * May be copied or modified under the terms of the GNU General Public | ||
7 | * License. See linux/COPYING for more information. | ||
8 | * | ||
9 | * Interrupt handling for INTC2-based IRQ. | ||
10 | * | ||
11 | * These are the "new Hitachi style" interrupts, as present on the | ||
12 | * Hitachi 7751 and the STM ST40 STB1. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/irq.h> | ||
18 | |||
19 | #include <asm/system.h> | ||
20 | #include <asm/io.h> | ||
21 | #include <asm/machvec.h> | ||
22 | |||
23 | |||
24 | struct intc2_data { | ||
25 | unsigned char msk_offset; | ||
26 | unsigned char msk_shift; | ||
27 | #ifdef CONFIG_CPU_SUBTYPE_ST40 | ||
28 | int (*clear_irq) (int); | ||
29 | #endif | ||
30 | }; | ||
31 | |||
32 | |||
33 | static struct intc2_data intc2_data[NR_INTC2_IRQS]; | ||
34 | |||
35 | static void enable_intc2_irq(unsigned int irq); | ||
36 | static void disable_intc2_irq(unsigned int irq); | ||
37 | |||
38 | /* shutdown is same as "disable" */ | ||
39 | #define shutdown_intc2_irq disable_intc2_irq | ||
40 | |||
41 | static void mask_and_ack_intc2(unsigned int); | ||
42 | static void end_intc2_irq(unsigned int irq); | ||
43 | |||
44 | static unsigned int startup_intc2_irq(unsigned int irq) | ||
45 | { | ||
46 | enable_intc2_irq(irq); | ||
47 | return 0; /* never anything pending */ | ||
48 | } | ||
49 | |||
50 | static struct hw_interrupt_type intc2_irq_type = { | ||
51 | .typename = "INTC2-IRQ", | ||
52 | .startup = startup_intc2_irq, | ||
53 | .shutdown = shutdown_intc2_irq, | ||
54 | .enable = enable_intc2_irq, | ||
55 | .disable = disable_intc2_irq, | ||
56 | .ack = mask_and_ack_intc2, | ||
57 | .end = end_intc2_irq | ||
58 | }; | ||
59 | |||
60 | static void disable_intc2_irq(unsigned int irq) | ||
61 | { | ||
62 | int irq_offset = irq - INTC2_FIRST_IRQ; | ||
63 | int msk_shift, msk_offset; | ||
64 | |||
65 | // Sanity check | ||
66 | if((irq_offset<0) || (irq_offset>=NR_INTC2_IRQS)) | ||
67 | return; | ||
68 | |||
69 | msk_shift = intc2_data[irq_offset].msk_shift; | ||
70 | msk_offset = intc2_data[irq_offset].msk_offset; | ||
71 | |||
72 | ctrl_outl(1<<msk_shift, | ||
73 | INTC2_BASE+INTC2_INTMSK_OFFSET+msk_offset); | ||
74 | } | ||
75 | |||
76 | static void enable_intc2_irq(unsigned int irq) | ||
77 | { | ||
78 | int irq_offset = irq - INTC2_FIRST_IRQ; | ||
79 | int msk_shift, msk_offset; | ||
80 | |||
81 | /* Sanity check */ | ||
82 | if((irq_offset<0) || (irq_offset>=NR_INTC2_IRQS)) | ||
83 | return; | ||
84 | |||
85 | msk_shift = intc2_data[irq_offset].msk_shift; | ||
86 | msk_offset = intc2_data[irq_offset].msk_offset; | ||
87 | |||
88 | ctrl_outl(1<<msk_shift, | ||
89 | INTC2_BASE+INTC2_INTMSKCLR_OFFSET+msk_offset); | ||
90 | } | ||
91 | |||
92 | static void mask_and_ack_intc2(unsigned int irq) | ||
93 | { | ||
94 | disable_intc2_irq(irq); | ||
95 | } | ||
96 | |||
97 | static void end_intc2_irq(unsigned int irq) | ||
98 | { | ||
99 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | ||
100 | enable_intc2_irq(irq); | ||
101 | |||
102 | #ifdef CONFIG_CPU_SUBTYPE_ST40 | ||
103 | if (intc2_data[irq - INTC2_FIRST_IRQ].clear_irq) | ||
104 | intc2_data[irq - INTC2_FIRST_IRQ].clear_irq (irq); | ||
105 | #endif | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * Setup an INTC2 style interrupt. | ||
110 | * NOTE: Unlike IPR interrupts, parameters are not shifted by this code, | ||
111 | * allowing the use of the numbers straight out of the datasheet. | ||
112 | * For example: | ||
113 | * PIO1 which is INTPRI00[19,16] and INTMSK00[13] | ||
114 | * would be: ^ ^ ^ ^ | ||
115 | * | | | | | ||
116 | * make_intc2_irq(84, 0, 16, 0, 13); | ||
117 | */ | ||
118 | void make_intc2_irq(unsigned int irq, | ||
119 | unsigned int ipr_offset, unsigned int ipr_shift, | ||
120 | unsigned int msk_offset, unsigned int msk_shift, | ||
121 | unsigned int priority) | ||
122 | { | ||
123 | int irq_offset = irq - INTC2_FIRST_IRQ; | ||
124 | unsigned int flags; | ||
125 | unsigned long ipr; | ||
126 | |||
127 | if((irq_offset<0) || (irq_offset>=NR_INTC2_IRQS)) | ||
128 | return; | ||
129 | |||
130 | disable_irq_nosync(irq); | ||
131 | |||
132 | /* Fill the data we need */ | ||
133 | intc2_data[irq_offset].msk_offset = msk_offset; | ||
134 | intc2_data[irq_offset].msk_shift = msk_shift; | ||
135 | #ifdef CONFIG_CPU_SUBTYPE_ST40 | ||
136 | intc2_data[irq_offset].clear_irq = NULL; | ||
137 | #endif | ||
138 | |||
139 | /* Set the priority level */ | ||
140 | local_irq_save(flags); | ||
141 | |||
142 | ipr=ctrl_inl(INTC2_BASE+INTC2_INTPRI_OFFSET+ipr_offset); | ||
143 | ipr&=~(0xf<<ipr_shift); | ||
144 | ipr|=(priority)<<ipr_shift; | ||
145 | ctrl_outl(ipr, INTC2_BASE+INTC2_INTPRI_OFFSET+ipr_offset); | ||
146 | |||
147 | local_irq_restore(flags); | ||
148 | |||
149 | irq_desc[irq].handler=&intc2_irq_type; | ||
150 | |||
151 | disable_intc2_irq(irq); | ||
152 | } | ||
153 | |||
154 | #ifdef CONFIG_CPU_SUBTYPE_ST40 | ||
155 | |||
156 | struct intc2_init { | ||
157 | unsigned short irq; | ||
158 | unsigned char ipr_offset, ipr_shift; | ||
159 | unsigned char msk_offset, msk_shift; | ||
160 | }; | ||
161 | |||
162 | static struct intc2_init intc2_init_data[] __initdata = { | ||
163 | {64, 0, 0, 0, 0}, /* PCI serr */ | ||
164 | {65, 0, 4, 0, 1}, /* PCI err */ | ||
165 | {66, 0, 4, 0, 2}, /* PCI ad */ | ||
166 | {67, 0, 4, 0, 3}, /* PCI pwd down */ | ||
167 | {72, 0, 8, 0, 5}, /* DMAC INT0 */ | ||
168 | {73, 0, 8, 0, 6}, /* DMAC INT1 */ | ||
169 | {74, 0, 8, 0, 7}, /* DMAC INT2 */ | ||
170 | {75, 0, 8, 0, 8}, /* DMAC INT3 */ | ||
171 | {76, 0, 8, 0, 9}, /* DMAC INT4 */ | ||
172 | {78, 0, 8, 0, 11}, /* DMAC ERR */ | ||
173 | {80, 0, 12, 0, 12}, /* PIO0 */ | ||
174 | {84, 0, 16, 0, 13}, /* PIO1 */ | ||
175 | {88, 0, 20, 0, 14}, /* PIO2 */ | ||
176 | {112, 4, 0, 4, 0}, /* Mailbox */ | ||
177 | #ifdef CONFIG_CPU_SUBTYPE_ST40GX1 | ||
178 | {116, 4, 4, 4, 4}, /* SSC0 */ | ||
179 | {120, 4, 8, 4, 8}, /* IR Blaster */ | ||
180 | {124, 4, 12, 4, 12}, /* USB host */ | ||
181 | {128, 4, 16, 4, 16}, /* Video processor BLITTER */ | ||
182 | {132, 4, 20, 4, 20}, /* UART0 */ | ||
183 | {134, 4, 20, 4, 22}, /* UART2 */ | ||
184 | {136, 4, 24, 4, 24}, /* IO_PIO0 */ | ||
185 | {140, 4, 28, 4, 28}, /* EMPI */ | ||
186 | {144, 8, 0, 8, 0}, /* MAFE */ | ||
187 | {148, 8, 4, 8, 4}, /* PWM */ | ||
188 | {152, 8, 8, 8, 8}, /* SSC1 */ | ||
189 | {156, 8, 12, 8, 12}, /* IO_PIO1 */ | ||
190 | {160, 8, 16, 8, 16}, /* USB target */ | ||
191 | {164, 8, 20, 8, 20}, /* UART1 */ | ||
192 | {168, 8, 24, 8, 24}, /* Teletext */ | ||
193 | {172, 8, 28, 8, 28}, /* VideoSync VTG */ | ||
194 | {173, 8, 28, 8, 29}, /* VideoSync DVP0 */ | ||
195 | {174, 8, 28, 8, 30}, /* VideoSync DVP1 */ | ||
196 | #endif | ||
197 | }; | ||
198 | |||
199 | void __init init_IRQ_intc2(void) | ||
200 | { | ||
201 | struct intc2_init *p; | ||
202 | |||
203 | printk(KERN_ALERT "init_IRQ_intc2\n"); | ||
204 | |||
205 | for (p = intc2_init_data; | ||
206 | p<intc2_init_data+ARRAY_SIZE(intc2_init_data); | ||
207 | p++) { | ||
208 | make_intc2_irq(p->irq, p->ipr_offset, p->ipr_shift, | ||
209 | p-> msk_offset, p->msk_shift, 13); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | /* Adds a termination callback to the interrupt */ | ||
214 | void intc2_add_clear_irq(int irq, int (*fn)(int)) | ||
215 | { | ||
216 | if (irq < INTC2_FIRST_IRQ) | ||
217 | return; | ||
218 | |||
219 | intc2_data[irq - INTC2_FIRST_IRQ].clear_irq = fn; | ||
220 | } | ||
221 | |||
222 | #endif /* CONFIG_CPU_SUBTYPE_ST40 */ | ||