xref: /openbmc/linux/arch/sh/kernel/cpu/sh3/setup-sh770x.c (revision a09d2831)
1 /*
2  * SH3 Setup code for SH7706, SH7707, SH7708, SH7709
3  *
4  *  Copyright (C) 2007  Magnus Damm
5  *  Copyright (C) 2009  Paul Mundt
6  *
7  * Based on setup-sh7709.c
8  *
9  *  Copyright (C) 2006  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/io.h>
17 #include <linux/irq.h>
18 #include <linux/platform_device.h>
19 #include <linux/serial.h>
20 #include <linux/serial_sci.h>
21 #include <linux/sh_timer.h>
22 
23 enum {
24 	UNUSED = 0,
25 
26 	/* interrupt sources */
27 	IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
28 	PINT07, PINT815,
29 	DMAC, SCIF0, SCIF2, SCI, ADC_ADI,
30 	LCDC, PCC0, PCC1,
31 	TMU0, TMU1, TMU2,
32 	RTC, WDT, REF,
33 };
34 
35 static struct intc_vect vectors[] __initdata = {
36 	INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
37 	INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
38 	INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
39 	INTC_VECT(RTC, 0x4c0),
40 	INTC_VECT(SCI, 0x4e0), INTC_VECT(SCI, 0x500),
41 	INTC_VECT(SCI, 0x520), INTC_VECT(SCI, 0x540),
42 	INTC_VECT(WDT, 0x560),
43 	INTC_VECT(REF, 0x580),
44 	INTC_VECT(REF, 0x5a0),
45 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
46     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
47     defined(CONFIG_CPU_SUBTYPE_SH7709)
48 	/* IRQ0->5 are handled in setup-sh3.c */
49 	INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
50 	INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
51 	INTC_VECT(ADC_ADI, 0x980),
52 	INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
53 	INTC_VECT(SCIF2, 0x940), INTC_VECT(SCIF2, 0x960),
54 #endif
55 #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
56     defined(CONFIG_CPU_SUBTYPE_SH7709)
57 	INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
58 	INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
59 	INTC_VECT(SCIF0, 0x8c0), INTC_VECT(SCIF0, 0x8e0),
60 #endif
61 #if defined(CONFIG_CPU_SUBTYPE_SH7707)
62 	INTC_VECT(LCDC, 0x9a0),
63 	INTC_VECT(PCC0, 0x9c0), INTC_VECT(PCC1, 0x9e0),
64 #endif
65 };
66 
67 static struct intc_prio_reg prio_registers[] __initdata = {
68 	{ 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
69 	{ 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF, SCI, 0 } },
70 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
71     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
72     defined(CONFIG_CPU_SUBTYPE_SH7709)
73 	{ 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
74 	{ 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
75 	{ 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, 0, SCIF2, ADC_ADI } },
76 #endif
77 #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
78     defined(CONFIG_CPU_SUBTYPE_SH7709)
79 	{ 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, } },
80 	{ 0xa400001a, 0, 16, 4, /* IPRE */ { 0, SCIF0 } },
81 #endif
82 #if defined(CONFIG_CPU_SUBTYPE_SH7707)
83 	{ 0xa400001c, 0, 16, 4, /* IPRF */ { 0, LCDC, PCC0, PCC1, } },
84 #endif
85 };
86 
87 static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, NULL,
88 			 NULL, prio_registers, NULL);
89 
90 static struct resource rtc_resources[] = {
91 	[0] =	{
92 		.start	= 0xfffffec0,
93 		.end	= 0xfffffec0 + 0x1e,
94 		.flags  = IORESOURCE_IO,
95 	},
96 	[1] =	{
97 		.start	= 20,
98 		.flags  = IORESOURCE_IRQ,
99 	},
100 };
101 
102 static struct platform_device rtc_device = {
103 	.name		= "sh-rtc",
104 	.id		= -1,
105 	.num_resources	= ARRAY_SIZE(rtc_resources),
106 	.resource	= rtc_resources,
107 };
108 
109 static struct plat_sci_port scif0_platform_data = {
110 	.mapbase	= 0xfffffe80,
111 	.flags		= UPF_BOOT_AUTOCONF,
112 	.type		= PORT_SCI,
113 	.irqs		= { 23, 23, 23, 0 },
114 };
115 
116 static struct platform_device scif0_device = {
117 	.name		= "sh-sci",
118 	.id		= 0,
119 	.dev		= {
120 		.platform_data	= &scif0_platform_data,
121 	},
122 };
123 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
124     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
125     defined(CONFIG_CPU_SUBTYPE_SH7709)
126 static struct plat_sci_port scif1_platform_data = {
127 	.mapbase	= 0xa4000150,
128 	.flags		= UPF_BOOT_AUTOCONF,
129 	.type		= PORT_SCIF,
130 	.irqs		= { 56, 56, 56, 56 },
131 };
132 
133 static struct platform_device scif1_device = {
134 	.name		= "sh-sci",
135 	.id		= 1,
136 	.dev		= {
137 		.platform_data	= &scif1_platform_data,
138 	},
139 };
140 #endif
141 #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
142     defined(CONFIG_CPU_SUBTYPE_SH7709)
143 static struct plat_sci_port scif2_platform_data = {
144 	.mapbase	= 0xa4000140,
145 	.flags		= UPF_BOOT_AUTOCONF,
146 	.type		= PORT_IRDA,
147 	.irqs		= { 52, 52, 52, 52 },
148 };
149 
150 static struct platform_device scif2_device = {
151 	.name		= "sh-sci",
152 	.id		= 2,
153 	.dev		= {
154 		.platform_data	= &scif2_platform_data,
155 	},
156 };
157 #endif
158 
159 static struct sh_timer_config tmu0_platform_data = {
160 	.name = "TMU0",
161 	.channel_offset = 0x02,
162 	.timer_bit = 0,
163 	.clk = "peripheral_clk",
164 	.clockevent_rating = 200,
165 };
166 
167 static struct resource tmu0_resources[] = {
168 	[0] = {
169 		.name	= "TMU0",
170 		.start	= 0xfffffe94,
171 		.end	= 0xfffffe9f,
172 		.flags	= IORESOURCE_MEM,
173 	},
174 	[1] = {
175 		.start	= 16,
176 		.flags	= IORESOURCE_IRQ,
177 	},
178 };
179 
180 static struct platform_device tmu0_device = {
181 	.name		= "sh_tmu",
182 	.id		= 0,
183 	.dev = {
184 		.platform_data	= &tmu0_platform_data,
185 	},
186 	.resource	= tmu0_resources,
187 	.num_resources	= ARRAY_SIZE(tmu0_resources),
188 };
189 
190 static struct sh_timer_config tmu1_platform_data = {
191 	.name = "TMU1",
192 	.channel_offset = 0xe,
193 	.timer_bit = 1,
194 	.clk = "peripheral_clk",
195 	.clocksource_rating = 200,
196 };
197 
198 static struct resource tmu1_resources[] = {
199 	[0] = {
200 		.name	= "TMU1",
201 		.start	= 0xfffffea0,
202 		.end	= 0xfffffeab,
203 		.flags	= IORESOURCE_MEM,
204 	},
205 	[1] = {
206 		.start	= 17,
207 		.flags	= IORESOURCE_IRQ,
208 	},
209 };
210 
211 static struct platform_device tmu1_device = {
212 	.name		= "sh_tmu",
213 	.id		= 1,
214 	.dev = {
215 		.platform_data	= &tmu1_platform_data,
216 	},
217 	.resource	= tmu1_resources,
218 	.num_resources	= ARRAY_SIZE(tmu1_resources),
219 };
220 
221 static struct sh_timer_config tmu2_platform_data = {
222 	.name = "TMU2",
223 	.channel_offset = 0x1a,
224 	.timer_bit = 2,
225 	.clk = "peripheral_clk",
226 };
227 
228 static struct resource tmu2_resources[] = {
229 	[0] = {
230 		.name	= "TMU2",
231 		.start	= 0xfffffeac,
232 		.end	= 0xfffffebb,
233 		.flags	= IORESOURCE_MEM,
234 	},
235 	[1] = {
236 		.start	= 18,
237 		.flags	= IORESOURCE_IRQ,
238 	},
239 };
240 
241 static struct platform_device tmu2_device = {
242 	.name		= "sh_tmu",
243 	.id		= 2,
244 	.dev = {
245 		.platform_data	= &tmu2_platform_data,
246 	},
247 	.resource	= tmu2_resources,
248 	.num_resources	= ARRAY_SIZE(tmu2_resources),
249 };
250 
251 static struct platform_device *sh770x_devices[] __initdata = {
252 	&scif0_device,
253 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
254     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
255     defined(CONFIG_CPU_SUBTYPE_SH7709)
256 	&scif1_device,
257 #endif
258 #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
259     defined(CONFIG_CPU_SUBTYPE_SH7709)
260 	&scif2_device,
261 #endif
262 	&tmu0_device,
263 	&tmu1_device,
264 	&tmu2_device,
265 	&rtc_device,
266 };
267 
268 static int __init sh770x_devices_setup(void)
269 {
270 	return platform_add_devices(sh770x_devices,
271 		ARRAY_SIZE(sh770x_devices));
272 }
273 arch_initcall(sh770x_devices_setup);
274 
275 static struct platform_device *sh770x_early_devices[] __initdata = {
276 	&scif0_device,
277 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
278     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
279     defined(CONFIG_CPU_SUBTYPE_SH7709)
280 	&scif1_device,
281 #endif
282 #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
283     defined(CONFIG_CPU_SUBTYPE_SH7709)
284 	&scif2_device,
285 #endif
286 	&tmu0_device,
287 	&tmu1_device,
288 	&tmu2_device,
289 };
290 
291 void __init plat_early_device_setup(void)
292 {
293 	early_platform_add_devices(sh770x_early_devices,
294 				   ARRAY_SIZE(sh770x_early_devices));
295 }
296 
297 void __init plat_irq_setup(void)
298 {
299 	register_intc_controller(&intc_desc);
300 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
301     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
302     defined(CONFIG_CPU_SUBTYPE_SH7709)
303 	plat_irq_setup_sh3();
304 #endif
305 }
306