2 * SH7091/SH7750/SH7750S/SH7750R/SH7751/SH7751R Setup
4 * Copyright (C) 2006 Paul Mundt
5 * Copyright (C) 2006 Jamie Lenehan
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/platform_device.h>
12 #include <linux/init.h>
13 #include <linux/serial.h>
15 #include <linux/sh_timer.h>
16 #include <linux/sh_intc.h>
17 #include <linux/serial_sci.h>
18 #include <generated/machtypes.h>
20 static struct resource rtc_resources
[] = {
23 .end
= 0xffc80000 + 0x58 - 1,
24 .flags
= IORESOURCE_IO
,
27 /* Shared Period/Carry/Alarm IRQ */
28 .start
= evt2irq(0x480),
29 .flags
= IORESOURCE_IRQ
,
33 static struct platform_device rtc_device
= {
36 .num_resources
= ARRAY_SIZE(rtc_resources
),
37 .resource
= rtc_resources
,
40 static struct plat_sci_port sci_platform_data
= {
44 static struct resource sci_resources
[] = {
45 DEFINE_RES_MEM(0xffe00000, 0x20),
46 DEFINE_RES_IRQ(evt2irq(0x4e0)),
49 static struct platform_device sci_device
= {
52 .resource
= sci_resources
,
53 .num_resources
= ARRAY_SIZE(sci_resources
),
55 .platform_data
= &sci_platform_data
,
59 static struct plat_sci_port scif_platform_data
= {
64 static struct resource scif_resources
[] = {
65 DEFINE_RES_MEM(0xffe80000, 0x100),
66 DEFINE_RES_IRQ(evt2irq(0x700)),
69 static struct platform_device scif_device
= {
72 .resource
= scif_resources
,
73 .num_resources
= ARRAY_SIZE(scif_resources
),
75 .platform_data
= &scif_platform_data
,
79 static struct sh_timer_config tmu0_platform_data
= {
83 static struct resource tmu0_resources
[] = {
84 DEFINE_RES_MEM(0xffd80000, 0x30),
85 DEFINE_RES_IRQ(evt2irq(0x400)),
86 DEFINE_RES_IRQ(evt2irq(0x420)),
87 DEFINE_RES_IRQ(evt2irq(0x440)),
90 static struct platform_device tmu0_device
= {
94 .platform_data
= &tmu0_platform_data
,
96 .resource
= tmu0_resources
,
97 .num_resources
= ARRAY_SIZE(tmu0_resources
),
100 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
101 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
102 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
103 defined(CONFIG_CPU_SUBTYPE_SH7751R)
105 static struct sh_timer_config tmu1_platform_data
= {
109 static struct resource tmu1_resources
[] = {
110 DEFINE_RES_MEM(0xfe100000, 0x20),
111 DEFINE_RES_IRQ(evt2irq(0xb00)),
112 DEFINE_RES_IRQ(evt2irq(0xb80)),
115 static struct platform_device tmu1_device
= {
119 .platform_data
= &tmu1_platform_data
,
121 .resource
= tmu1_resources
,
122 .num_resources
= ARRAY_SIZE(tmu1_resources
),
127 static struct platform_device
*sh7750_devices
[] __initdata
= {
130 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
131 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
132 defined(CONFIG_CPU_SUBTYPE_SH7751R)
137 static int __init
sh7750_devices_setup(void)
139 if (mach_is_rts7751r2d()) {
140 platform_device_register(&scif_device
);
142 platform_device_register(&sci_device
);
143 platform_device_register(&scif_device
);
146 return platform_add_devices(sh7750_devices
,
147 ARRAY_SIZE(sh7750_devices
));
149 arch_initcall(sh7750_devices_setup
);
151 static struct platform_device
*sh7750_early_devices
[] __initdata
= {
153 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
154 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
155 defined(CONFIG_CPU_SUBTYPE_SH7751R)
160 void __init
plat_early_device_setup(void)
162 struct platform_device
*dev
[1];
164 if (mach_is_rts7751r2d()) {
165 scif_platform_data
.scscr
|= SCSCR_CKE1
;
166 dev
[0] = &scif_device
;
167 early_platform_add_devices(dev
, 1);
169 dev
[0] = &sci_device
;
170 early_platform_add_devices(dev
, 1);
171 dev
[0] = &scif_device
;
172 early_platform_add_devices(dev
, 1);
175 early_platform_add_devices(sh7750_early_devices
,
176 ARRAY_SIZE(sh7750_early_devices
));
182 /* interrupt sources */
183 IRL0
, IRL1
, IRL2
, IRL3
, /* only IRLM mode supported */
185 PCIC0_PCISERR
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
186 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
,
187 TMU3
, TMU4
, TMU0
, TMU1
, TMU2
, RTC
, SCI1
, SCIF
, WDT
, REF
,
189 /* interrupt groups */
193 static struct intc_vect vectors
[] __initdata
= {
194 INTC_VECT(HUDI
, 0x600), INTC_VECT(GPIOI
, 0x620),
195 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
196 INTC_VECT(TMU2
, 0x440), INTC_VECT(TMU2
, 0x460),
197 INTC_VECT(RTC
, 0x480), INTC_VECT(RTC
, 0x4a0),
198 INTC_VECT(RTC
, 0x4c0),
199 INTC_VECT(SCI1
, 0x4e0), INTC_VECT(SCI1
, 0x500),
200 INTC_VECT(SCI1
, 0x520), INTC_VECT(SCI1
, 0x540),
201 INTC_VECT(SCIF
, 0x700), INTC_VECT(SCIF
, 0x720),
202 INTC_VECT(SCIF
, 0x740), INTC_VECT(SCIF
, 0x760),
203 INTC_VECT(WDT
, 0x560),
204 INTC_VECT(REF
, 0x580), INTC_VECT(REF
, 0x5a0),
207 static struct intc_prio_reg prio_registers
[] __initdata
= {
208 { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0
, TMU1
, TMU2
, RTC
} },
209 { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT
, REF
, SCI1
, 0 } },
210 { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI
, DMAC
, SCIF
, HUDI
} },
211 { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0
, IRL1
, IRL2
, IRL3
} },
212 { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
214 PCIC1
, PCIC0_PCISERR
} },
217 static DECLARE_INTC_DESC(intc_desc
, "sh7750", vectors
, NULL
,
218 NULL
, prio_registers
, NULL
);
220 /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
221 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
222 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
223 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
224 defined(CONFIG_CPU_SUBTYPE_SH7091)
225 static struct intc_vect vectors_dma4
[] __initdata
= {
226 INTC_VECT(DMAC
, 0x640), INTC_VECT(DMAC
, 0x660),
227 INTC_VECT(DMAC
, 0x680), INTC_VECT(DMAC
, 0x6a0),
228 INTC_VECT(DMAC
, 0x6c0),
231 static DECLARE_INTC_DESC(intc_desc_dma4
, "sh7750_dma4",
233 NULL
, prio_registers
, NULL
);
236 /* SH7750R and SH7751R both have 8-channel DMA controllers */
237 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
238 static struct intc_vect vectors_dma8
[] __initdata
= {
239 INTC_VECT(DMAC
, 0x640), INTC_VECT(DMAC
, 0x660),
240 INTC_VECT(DMAC
, 0x680), INTC_VECT(DMAC
, 0x6a0),
241 INTC_VECT(DMAC
, 0x780), INTC_VECT(DMAC
, 0x7a0),
242 INTC_VECT(DMAC
, 0x7c0), INTC_VECT(DMAC
, 0x7e0),
243 INTC_VECT(DMAC
, 0x6c0),
246 static DECLARE_INTC_DESC(intc_desc_dma8
, "sh7750_dma8",
248 NULL
, prio_registers
, NULL
);
251 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
252 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
253 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
254 defined(CONFIG_CPU_SUBTYPE_SH7751R)
255 static struct intc_vect vectors_tmu34
[] __initdata
= {
256 INTC_VECT(TMU3
, 0xb00), INTC_VECT(TMU4
, 0xb80),
259 static struct intc_mask_reg mask_registers
[] __initdata
= {
260 { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
261 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
262 0, 0, 0, 0, 0, 0, TMU4
, TMU3
,
263 PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
264 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
,
265 PCIC1_PCIDMA3
, PCIC0_PCISERR
} },
268 static DECLARE_INTC_DESC(intc_desc_tmu34
, "sh7750_tmu34",
270 mask_registers
, prio_registers
, NULL
);
273 /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
274 static struct intc_vect vectors_irlm
[] __initdata
= {
275 INTC_VECT(IRL0
, 0x240), INTC_VECT(IRL1
, 0x2a0),
276 INTC_VECT(IRL2
, 0x300), INTC_VECT(IRL3
, 0x360),
279 static DECLARE_INTC_DESC(intc_desc_irlm
, "sh7750_irlm", vectors_irlm
, NULL
,
280 NULL
, prio_registers
, NULL
);
282 /* SH7751 and SH7751R both have PCI */
283 #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
284 static struct intc_vect vectors_pci
[] __initdata
= {
285 INTC_VECT(PCIC0_PCISERR
, 0xa00), INTC_VECT(PCIC1_PCIERR
, 0xae0),
286 INTC_VECT(PCIC1_PCIPWDWN
, 0xac0), INTC_VECT(PCIC1_PCIPWON
, 0xaa0),
287 INTC_VECT(PCIC1_PCIDMA0
, 0xa80), INTC_VECT(PCIC1_PCIDMA1
, 0xa60),
288 INTC_VECT(PCIC1_PCIDMA2
, 0xa40), INTC_VECT(PCIC1_PCIDMA3
, 0xa20),
291 static struct intc_group groups_pci
[] __initdata
= {
292 INTC_GROUP(PCIC1
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
293 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
),
296 static DECLARE_INTC_DESC(intc_desc_pci
, "sh7750_pci", vectors_pci
, groups_pci
,
297 mask_registers
, prio_registers
, NULL
);
300 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
301 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
302 defined(CONFIG_CPU_SUBTYPE_SH7091)
303 void __init
plat_irq_setup(void)
306 * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
309 register_intc_controller(&intc_desc
);
310 register_intc_controller(&intc_desc_dma4
);
314 #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
315 void __init
plat_irq_setup(void)
317 register_intc_controller(&intc_desc
);
318 register_intc_controller(&intc_desc_dma8
);
319 register_intc_controller(&intc_desc_tmu34
);
323 #if defined(CONFIG_CPU_SUBTYPE_SH7751)
324 void __init
plat_irq_setup(void)
326 register_intc_controller(&intc_desc
);
327 register_intc_controller(&intc_desc_dma4
);
328 register_intc_controller(&intc_desc_tmu34
);
329 register_intc_controller(&intc_desc_pci
);
333 #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
334 void __init
plat_irq_setup(void)
336 register_intc_controller(&intc_desc
);
337 register_intc_controller(&intc_desc_dma8
);
338 register_intc_controller(&intc_desc_tmu34
);
339 register_intc_controller(&intc_desc_pci
);
343 #define INTC_ICR 0xffd00000UL
344 #define INTC_ICR_IRLM (1<<7)
346 void __init
plat_irq_setup_pins(int mode
)
348 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
349 BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
354 case IRQ_MODE_IRQ
: /* individual interrupt mode for IRL3-0 */
355 __raw_writew(__raw_readw(INTC_ICR
) | INTC_ICR_IRLM
, INTC_ICR
);
356 register_intc_controller(&intc_desc_irlm
);