4 * Copyright (C) 2006 Paul Mundt
5 * Copyright (C) 2009 Magnus Damm
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>
14 #include <linux/serial_sci.h>
15 #include <linux/sh_timer.h>
16 #include <linux/sh_intc.h>
19 static struct plat_sci_port scif0_platform_data = {
20 .flags = UPF_BOOT_AUTOCONF,
21 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
25 static struct resource scif0_resources[] = {
26 DEFINE_RES_MEM(0xffe80000, 0x100),
27 DEFINE_RES_IRQ(evt2irq(0x700)),
28 DEFINE_RES_IRQ(evt2irq(0x720)),
29 DEFINE_RES_IRQ(evt2irq(0x760)),
30 DEFINE_RES_IRQ(evt2irq(0x740)),
33 static struct platform_device scif0_device = {
36 .resource = scif0_resources,
37 .num_resources = ARRAY_SIZE(scif0_resources),
39 .platform_data = &scif0_platform_data,
43 static struct sh_timer_config tmu0_platform_data = {
44 .channel_offset = 0x04,
46 .clockevent_rating = 200,
49 static struct resource tmu0_resources[] = {
53 .flags = IORESOURCE_MEM,
56 .start = evt2irq(0x400),
57 .flags = IORESOURCE_IRQ,
61 static struct platform_device tmu0_device = {
65 .platform_data = &tmu0_platform_data,
67 .resource = tmu0_resources,
68 .num_resources = ARRAY_SIZE(tmu0_resources),
71 static struct sh_timer_config tmu1_platform_data = {
72 .channel_offset = 0x10,
74 .clocksource_rating = 200,
77 static struct resource tmu1_resources[] = {
81 .flags = IORESOURCE_MEM,
84 .start = evt2irq(0x420),
85 .flags = IORESOURCE_IRQ,
89 static struct platform_device tmu1_device = {
93 .platform_data = &tmu1_platform_data,
95 .resource = tmu1_resources,
96 .num_resources = ARRAY_SIZE(tmu1_resources),
99 static struct sh_timer_config tmu2_platform_data = {
100 .channel_offset = 0x1c,
104 static struct resource tmu2_resources[] = {
108 .flags = IORESOURCE_MEM,
111 .start = evt2irq(0x440),
112 .flags = IORESOURCE_IRQ,
116 static struct platform_device tmu2_device = {
120 .platform_data = &tmu2_platform_data,
122 .resource = tmu2_resources,
123 .num_resources = ARRAY_SIZE(tmu2_resources),
126 static struct platform_device *sh4202_devices[] __initdata = {
133 static int __init sh4202_devices_setup(void)
135 return platform_add_devices(sh4202_devices,
136 ARRAY_SIZE(sh4202_devices));
138 arch_initcall(sh4202_devices_setup);
140 static struct platform_device *sh4202_early_devices[] __initdata = {
147 void __init plat_early_device_setup(void)
149 early_platform_add_devices(sh4202_early_devices,
150 ARRAY_SIZE(sh4202_early_devices));
156 /* interrupt sources */
157 IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
158 HUDI, TMU0, TMU1, TMU2, RTC, SCIF, WDT,
161 static struct intc_vect vectors[] __initdata = {
162 INTC_VECT(HUDI, 0x600),
163 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
164 INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
165 INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
166 INTC_VECT(RTC, 0x4c0),
167 INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
168 INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
169 INTC_VECT(WDT, 0x560),
172 static struct intc_prio_reg prio_registers[] __initdata = {
173 { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
174 { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, 0, 0, 0 } },
175 { 0xffd0000c, 0, 16, 4, /* IPRC */ { 0, 0, SCIF, HUDI } },
176 { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
179 static DECLARE_INTC_DESC(intc_desc, "sh4-202", vectors, NULL,
180 NULL, prio_registers, NULL);
182 static struct intc_vect vectors_irlm[] __initdata = {
183 INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
184 INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
187 static DECLARE_INTC_DESC(intc_desc_irlm, "sh4-202_irlm", vectors_irlm, NULL,
188 NULL, prio_registers, NULL);
190 void __init plat_irq_setup(void)
192 register_intc_controller(&intc_desc);
195 #define INTC_ICR 0xffd00000UL
196 #define INTC_ICR_IRLM (1<<7)
198 void __init plat_irq_setup_pins(int mode)
201 case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
202 __raw_writew(__raw_readw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
203 register_intc_controller(&intc_desc_irlm);