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
= {
41 .mapbase
= 0xffe00000,
42 .port_reg
= 0xffe0001C,
43 .flags
= UPF_BOOT_AUTOCONF
,
44 .scscr
= SCSCR_TE
| SCSCR_RE
,
45 .scbrr_algo_id
= SCBRR_ALGO_2
,
47 .irqs
= SCIx_IRQ_MUXED(evt2irq(0x4e0)),
51 static struct platform_device sci_device
= {
55 .platform_data
= &sci_platform_data
,
59 static struct plat_sci_port scif_platform_data
= {
60 .mapbase
= 0xffe80000,
61 .flags
= UPF_BOOT_AUTOCONF
,
62 .scscr
= SCSCR_TE
| SCSCR_RE
| SCSCR_REIE
,
63 .scbrr_algo_id
= SCBRR_ALGO_2
,
65 .irqs
= SCIx_IRQ_MUXED(evt2irq(0x700)),
68 static struct platform_device scif_device
= {
72 .platform_data
= &scif_platform_data
,
76 static struct sh_timer_config tmu0_platform_data
= {
77 .channel_offset
= 0x04,
79 .clockevent_rating
= 200,
82 static struct resource tmu0_resources
[] = {
86 .flags
= IORESOURCE_MEM
,
89 .start
= evt2irq(0x400),
90 .flags
= IORESOURCE_IRQ
,
94 static struct platform_device tmu0_device
= {
98 .platform_data
= &tmu0_platform_data
,
100 .resource
= tmu0_resources
,
101 .num_resources
= ARRAY_SIZE(tmu0_resources
),
104 static struct sh_timer_config tmu1_platform_data
= {
105 .channel_offset
= 0x10,
107 .clocksource_rating
= 200,
110 static struct resource tmu1_resources
[] = {
114 .flags
= IORESOURCE_MEM
,
117 .start
= evt2irq(0x420),
118 .flags
= IORESOURCE_IRQ
,
122 static struct platform_device tmu1_device
= {
126 .platform_data
= &tmu1_platform_data
,
128 .resource
= tmu1_resources
,
129 .num_resources
= ARRAY_SIZE(tmu1_resources
),
132 static struct sh_timer_config tmu2_platform_data
= {
133 .channel_offset
= 0x1c,
137 static struct resource tmu2_resources
[] = {
141 .flags
= IORESOURCE_MEM
,
144 .start
= evt2irq(0x440),
145 .flags
= IORESOURCE_IRQ
,
149 static struct platform_device tmu2_device
= {
153 .platform_data
= &tmu2_platform_data
,
155 .resource
= tmu2_resources
,
156 .num_resources
= ARRAY_SIZE(tmu2_resources
),
159 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
160 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
161 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
162 defined(CONFIG_CPU_SUBTYPE_SH7751R)
164 static struct sh_timer_config tmu3_platform_data
= {
165 .channel_offset
= 0x04,
169 static struct resource tmu3_resources
[] = {
173 .flags
= IORESOURCE_MEM
,
176 .start
= evt2irq(0xb00),
177 .flags
= IORESOURCE_IRQ
,
181 static struct platform_device tmu3_device
= {
185 .platform_data
= &tmu3_platform_data
,
187 .resource
= tmu3_resources
,
188 .num_resources
= ARRAY_SIZE(tmu3_resources
),
191 static struct sh_timer_config tmu4_platform_data
= {
192 .channel_offset
= 0x10,
196 static struct resource tmu4_resources
[] = {
200 .flags
= IORESOURCE_MEM
,
203 .start
= evt2irq(0xb80),
204 .flags
= IORESOURCE_IRQ
,
208 static struct platform_device tmu4_device
= {
212 .platform_data
= &tmu4_platform_data
,
214 .resource
= tmu4_resources
,
215 .num_resources
= ARRAY_SIZE(tmu4_resources
),
220 static struct platform_device
*sh7750_devices
[] __initdata
= {
225 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
226 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
227 defined(CONFIG_CPU_SUBTYPE_SH7751R)
233 static int __init
sh7750_devices_setup(void)
235 if (mach_is_rts7751r2d()) {
236 platform_device_register(&scif_device
);
238 platform_device_register(&sci_device
);
239 platform_device_register(&scif_device
);
242 return platform_add_devices(sh7750_devices
,
243 ARRAY_SIZE(sh7750_devices
));
245 arch_initcall(sh7750_devices_setup
);
247 static struct platform_device
*sh7750_early_devices
[] __initdata
= {
251 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
252 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
253 defined(CONFIG_CPU_SUBTYPE_SH7751R)
259 void __init
plat_early_device_setup(void)
261 struct platform_device
*dev
[1];
263 if (mach_is_rts7751r2d()) {
264 scif_platform_data
.scscr
|= SCSCR_CKE1
;
265 dev
[0] = &scif_device
;
266 early_platform_add_devices(dev
, 1);
268 dev
[0] = &sci_device
;
269 early_platform_add_devices(dev
, 1);
270 dev
[0] = &scif_device
;
271 early_platform_add_devices(dev
, 1);
274 early_platform_add_devices(sh7750_early_devices
,
275 ARRAY_SIZE(sh7750_early_devices
));
281 /* interrupt sources */
282 IRL0
, IRL1
, IRL2
, IRL3
, /* only IRLM mode supported */
284 PCIC0_PCISERR
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
285 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
,
286 TMU3
, TMU4
, TMU0
, TMU1
, TMU2
, RTC
, SCI1
, SCIF
, WDT
, REF
,
288 /* interrupt groups */
292 static struct intc_vect vectors
[] __initdata
= {
293 INTC_VECT(HUDI
, 0x600), INTC_VECT(GPIOI
, 0x620),
294 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
295 INTC_VECT(TMU2
, 0x440), INTC_VECT(TMU2
, 0x460),
296 INTC_VECT(RTC
, 0x480), INTC_VECT(RTC
, 0x4a0),
297 INTC_VECT(RTC
, 0x4c0),
298 INTC_VECT(SCI1
, 0x4e0), INTC_VECT(SCI1
, 0x500),
299 INTC_VECT(SCI1
, 0x520), INTC_VECT(SCI1
, 0x540),
300 INTC_VECT(SCIF
, 0x700), INTC_VECT(SCIF
, 0x720),
301 INTC_VECT(SCIF
, 0x740), INTC_VECT(SCIF
, 0x760),
302 INTC_VECT(WDT
, 0x560),
303 INTC_VECT(REF
, 0x580), INTC_VECT(REF
, 0x5a0),
306 static struct intc_prio_reg prio_registers
[] __initdata
= {
307 { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0
, TMU1
, TMU2
, RTC
} },
308 { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT
, REF
, SCI1
, 0 } },
309 { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI
, DMAC
, SCIF
, HUDI
} },
310 { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0
, IRL1
, IRL2
, IRL3
} },
311 { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
313 PCIC1
, PCIC0_PCISERR
} },
316 static DECLARE_INTC_DESC(intc_desc
, "sh7750", vectors
, NULL
,
317 NULL
, prio_registers
, NULL
);
319 /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
320 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
321 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
322 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
323 defined(CONFIG_CPU_SUBTYPE_SH7091)
324 static struct intc_vect vectors_dma4
[] __initdata
= {
325 INTC_VECT(DMAC
, 0x640), INTC_VECT(DMAC
, 0x660),
326 INTC_VECT(DMAC
, 0x680), INTC_VECT(DMAC
, 0x6a0),
327 INTC_VECT(DMAC
, 0x6c0),
330 static DECLARE_INTC_DESC(intc_desc_dma4
, "sh7750_dma4",
332 NULL
, prio_registers
, NULL
);
335 /* SH7750R and SH7751R both have 8-channel DMA controllers */
336 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
337 static struct intc_vect vectors_dma8
[] __initdata
= {
338 INTC_VECT(DMAC
, 0x640), INTC_VECT(DMAC
, 0x660),
339 INTC_VECT(DMAC
, 0x680), INTC_VECT(DMAC
, 0x6a0),
340 INTC_VECT(DMAC
, 0x780), INTC_VECT(DMAC
, 0x7a0),
341 INTC_VECT(DMAC
, 0x7c0), INTC_VECT(DMAC
, 0x7e0),
342 INTC_VECT(DMAC
, 0x6c0),
345 static DECLARE_INTC_DESC(intc_desc_dma8
, "sh7750_dma8",
347 NULL
, prio_registers
, NULL
);
350 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
351 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
352 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
353 defined(CONFIG_CPU_SUBTYPE_SH7751R)
354 static struct intc_vect vectors_tmu34
[] __initdata
= {
355 INTC_VECT(TMU3
, 0xb00), INTC_VECT(TMU4
, 0xb80),
358 static struct intc_mask_reg mask_registers
[] __initdata
= {
359 { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
360 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
361 0, 0, 0, 0, 0, 0, TMU4
, TMU3
,
362 PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
363 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
,
364 PCIC1_PCIDMA3
, PCIC0_PCISERR
} },
367 static DECLARE_INTC_DESC(intc_desc_tmu34
, "sh7750_tmu34",
369 mask_registers
, prio_registers
, NULL
);
372 /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
373 static struct intc_vect vectors_irlm
[] __initdata
= {
374 INTC_VECT(IRL0
, 0x240), INTC_VECT(IRL1
, 0x2a0),
375 INTC_VECT(IRL2
, 0x300), INTC_VECT(IRL3
, 0x360),
378 static DECLARE_INTC_DESC(intc_desc_irlm
, "sh7750_irlm", vectors_irlm
, NULL
,
379 NULL
, prio_registers
, NULL
);
381 /* SH7751 and SH7751R both have PCI */
382 #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
383 static struct intc_vect vectors_pci
[] __initdata
= {
384 INTC_VECT(PCIC0_PCISERR
, 0xa00), INTC_VECT(PCIC1_PCIERR
, 0xae0),
385 INTC_VECT(PCIC1_PCIPWDWN
, 0xac0), INTC_VECT(PCIC1_PCIPWON
, 0xaa0),
386 INTC_VECT(PCIC1_PCIDMA0
, 0xa80), INTC_VECT(PCIC1_PCIDMA1
, 0xa60),
387 INTC_VECT(PCIC1_PCIDMA2
, 0xa40), INTC_VECT(PCIC1_PCIDMA3
, 0xa20),
390 static struct intc_group groups_pci
[] __initdata
= {
391 INTC_GROUP(PCIC1
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
392 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
),
395 static DECLARE_INTC_DESC(intc_desc_pci
, "sh7750_pci", vectors_pci
, groups_pci
,
396 mask_registers
, prio_registers
, NULL
);
399 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
400 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
401 defined(CONFIG_CPU_SUBTYPE_SH7091)
402 void __init
plat_irq_setup(void)
405 * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
408 register_intc_controller(&intc_desc
);
409 register_intc_controller(&intc_desc_dma4
);
413 #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
414 void __init
plat_irq_setup(void)
416 register_intc_controller(&intc_desc
);
417 register_intc_controller(&intc_desc_dma8
);
418 register_intc_controller(&intc_desc_tmu34
);
422 #if defined(CONFIG_CPU_SUBTYPE_SH7751)
423 void __init
plat_irq_setup(void)
425 register_intc_controller(&intc_desc
);
426 register_intc_controller(&intc_desc_dma4
);
427 register_intc_controller(&intc_desc_tmu34
);
428 register_intc_controller(&intc_desc_pci
);
432 #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
433 void __init
plat_irq_setup(void)
435 register_intc_controller(&intc_desc
);
436 register_intc_controller(&intc_desc_dma8
);
437 register_intc_controller(&intc_desc_tmu34
);
438 register_intc_controller(&intc_desc_pci
);
442 #define INTC_ICR 0xffd00000UL
443 #define INTC_ICR_IRLM (1<<7)
445 void __init
plat_irq_setup_pins(int mode
)
447 #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
448 BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
453 case IRQ_MODE_IRQ
: /* individual interrupt mode for IRL3-0 */
454 __raw_writew(__raw_readw(INTC_ICR
) | INTC_ICR_IRLM
, INTC_ICR
);
455 register_intc_controller(&intc_desc_irlm
);