aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/cpu/sh3/setup-sh770x.c
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2007-07-25 04:50:01 -0400
committerPaul Mundt <lethal@linux-sh.org>2007-09-20 22:57:46 -0400
commitec58f1f32de0b6f9e83aada94c857a8fa9b00070 (patch)
tree612397e5bc717d630b177aa799d8e4e2f30cb824 /arch/sh/kernel/cpu/sh3/setup-sh770x.c
parent28b146c84ed571043f473d2ac2f2a27e48fda7d1 (diff)
sh: intc - add support for SH7706, SH7707, SH7708, SH7709
This patch unifies the cpu specific interrupt setup code for sh7706, sh7707, sh7708 and sh7709 and moves the code into a new file called setup-sh770x.c. It makes sense to share the setup code between these processors because most hardware blocks are identical from a software point of view. With this patch the sh770x processors now have a complete set of vectors that match with the information provided by the data sheets. This is a big improvement for sh7708. Vectors for IRQ4 and IRQ5 are enabled by default. Use plat_irq_setup_pins() if pins IRQ0-3 should be used in IRQ mode. This patch also unifies the platform device setup code which means that the rtc driver now has platform data for all sh770x processors. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/cpu/sh3/setup-sh770x.c')
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh770x.c212
1 files changed, 212 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
new file mode 100644
index 000000000000..68fc037a6b5c
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
@@ -0,0 +1,212 @@
1/*
2 * SH3 Setup code for SH7706, SH7707, SH7708, SH7709
3 *
4 * Copyright (C) 2007 Magnus Damm
5 *
6 * Based on setup-sh7709.c
7 *
8 * Copyright (C) 2006 Paul Mundt
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <linux/init.h>
15#include <linux/io.h>
16#include <linux/irq.h>
17#include <linux/platform_device.h>
18#include <linux/serial.h>
19#include <asm/sci.h>
20
21enum {
22 UNUSED = 0,
23
24 /* interrupt sources */
25 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
26 PINT07, PINT815,
27 DMAC_DEI0, DMAC_DEI1, DMAC_DEI2, DMAC_DEI3,
28 SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI,
29 SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI,
30 SCI_ERI, SCI_RXI, SCI_TXI, SCI_TEI,
31 ADC_ADI,
32 TMU0, TMU1, TMU2_TUNI, TMU2_TICPI,
33 RTC_ATI, RTC_PRI, RTC_CUI,
34 WDT,
35 REF_RCMI, REF_ROVI,
36
37 /* interrupt groups */
38 RTC, REF, TMU2, DMAC, SCI, SCIF2, SCIF0,
39};
40
41static struct intc_vect vectors[] = {
42 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
43 INTC_VECT(TMU2_TUNI, 0x440), INTC_VECT(TMU2_TICPI, 0x460),
44 INTC_VECT(RTC_ATI, 0x480), INTC_VECT(RTC_PRI, 0x4a0),
45 INTC_VECT(RTC_CUI, 0x4c0),
46 INTC_VECT(SCI_ERI, 0x4e0), INTC_VECT(SCI_RXI, 0x500),
47 INTC_VECT(SCI_TXI, 0x520), INTC_VECT(SCI_TEI, 0x540),
48 INTC_VECT(WDT, 0x560),
49 INTC_VECT(REF_RCMI, 0x580),
50 INTC_VECT(REF_ROVI, 0x5a0),
51#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
52 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
53 defined(CONFIG_CPU_SUBTYPE_SH7709)
54 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
55 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820),
56 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860),
57 INTC_VECT(ADC_ADI, 0x980),
58 INTC_VECT(SCIF2_ERI, 0x900), INTC_VECT(SCIF2_RXI, 0x920),
59 INTC_VECT(SCIF2_BRI, 0x940), INTC_VECT(SCIF2_TXI, 0x960),
60#endif
61#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
62 defined(CONFIG_CPU_SUBTYPE_SH7709)
63 INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
64 INTC_VECT(SCIF0_ERI, 0x880), INTC_VECT(SCIF0_RXI, 0x8a0),
65 INTC_VECT(SCIF0_BRI, 0x8c0), INTC_VECT(SCIF0_TXI, 0x8e0),
66#endif
67};
68
69static struct intc_group groups[] = {
70 INTC_GROUP(RTC, RTC_ATI, RTC_PRI, RTC_CUI),
71 INTC_GROUP(TMU2, TMU2_TUNI, TMU2_TICPI),
72 INTC_GROUP(REF, REF_RCMI, REF_ROVI),
73 INTC_GROUP(DMAC, DMAC_DEI0, DMAC_DEI1, DMAC_DEI2, DMAC_DEI3),
74 INTC_GROUP(SCI, SCI_ERI, SCI_RXI, SCI_TXI, SCI_TEI),
75 INTC_GROUP(SCIF0, SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI),
76 INTC_GROUP(SCIF2, SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI),
77};
78
79static struct intc_prio priorities[] = {
80 INTC_PRIO(DMAC, 7),
81 INTC_PRIO(SCI, 3),
82 INTC_PRIO(SCIF2, 3),
83 INTC_PRIO(SCIF0, 3),
84};
85
86static struct intc_prio_reg prio_registers[] = {
87 { 0xfffffee2, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
88 { 0xfffffee4, 16, 4, /* IPRB */ { WDT, REF, SCI, 0 } },
89#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
90 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
91 defined(CONFIG_CPU_SUBTYPE_SH7709)
92 { 0xa4000016, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
93 { 0xa4000018, 16, 4, /* IPRD */ { 0, 0, IRQ4, IRQ5 } },
94 { 0xa400001a, 16, 4, /* IPRE */ { DMAC, 0, SCIF2, ADC_ADI } },
95#endif
96#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
97 defined(CONFIG_CPU_SUBTYPE_SH7709)
98 { 0xa4000018, 16, 4, /* IPRD */ { PINT07, PINT815, } },
99 { 0xa400001a, 16, 4, /* IPRE */ { 0, SCIF0 } },
100#endif
101};
102
103static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, groups,
104 priorities, NULL, prio_registers, NULL);
105
106#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
107 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
108 defined(CONFIG_CPU_SUBTYPE_SH7709)
109static struct intc_vect vectors_irq[] = {
110 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
111 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
112};
113
114static DECLARE_INTC_DESC(intc_desc_irq, "sh770x-irq", vectors_irq, NULL,
115 priorities, NULL, prio_registers, NULL);
116#endif
117
118static struct resource rtc_resources[] = {
119 [0] = {
120 .start = 0xfffffec0,
121 .end = 0xfffffec0 + 0x1e,
122 .flags = IORESOURCE_IO,
123 },
124 [1] = {
125 .start = 20,
126 .flags = IORESOURCE_IRQ,
127 },
128 [2] = {
129 .start = 21,
130 .flags = IORESOURCE_IRQ,
131 },
132 [3] = {
133 .start = 22,
134 .flags = IORESOURCE_IRQ,
135 },
136};
137
138static struct platform_device rtc_device = {
139 .name = "sh-rtc",
140 .id = -1,
141 .num_resources = ARRAY_SIZE(rtc_resources),
142 .resource = rtc_resources,
143};
144
145static struct plat_sci_port sci_platform_data[] = {
146 {
147 .mapbase = 0xfffffe80,
148 .flags = UPF_BOOT_AUTOCONF,
149 .type = PORT_SCI,
150 .irqs = { 23, 24, 25, 0 },
151 },
152#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
153 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
154 defined(CONFIG_CPU_SUBTYPE_SH7709)
155 {
156 .mapbase = 0xa4000150,
157 .flags = UPF_BOOT_AUTOCONF,
158 .type = PORT_SCIF,
159 .irqs = { 56, 57, 59, 58 },
160 },
161#endif
162#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
163 defined(CONFIG_CPU_SUBTYPE_SH7709)
164 {
165 .mapbase = 0xa4000140,
166 .flags = UPF_BOOT_AUTOCONF,
167 .type = PORT_IRDA,
168 .irqs = { 52, 53, 55, 54 },
169 },
170#endif
171 {
172 .flags = 0,
173 }
174};
175
176static struct platform_device sci_device = {
177 .name = "sh-sci",
178 .id = -1,
179 .dev = {
180 .platform_data = sci_platform_data,
181 },
182};
183
184static struct platform_device *sh770x_devices[] __initdata = {
185 &sci_device,
186 &rtc_device,
187};
188
189static int __init sh770x_devices_setup(void)
190{
191 return platform_add_devices(sh770x_devices,
192 ARRAY_SIZE(sh770x_devices));
193}
194__initcall(sh770x_devices_setup);
195
196void __init plat_irq_setup_pins(int mode)
197{
198 if (mode == IRQ_MODE_IRQ) {
199#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
200 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
201 defined(CONFIG_CPU_SUBTYPE_SH7709)
202 register_intc_controller(&intc_desc_irq);
203 return;
204#endif
205 }
206 BUG();
207}
208
209void __init plat_irq_setup(void)
210{
211 register_intc_controller(&intc_desc);
212}