blob: 747ed8ef84ef04866e1b745c6654e5a11f5a7055 [file] [log] [blame]
Magnus Dammf2aaf662010-02-05 11:15:07 +00001/*
2 * sh7377 processor support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
Magnus Dammc9fcf002011-04-28 03:19:05 +000025#include <linux/uio_driver.h>
Magnus Dammf2aaf662010-02-05 11:15:07 +000026#include <linux/delay.h>
27#include <linux/input.h>
28#include <linux/io.h>
29#include <linux/serial_sci.h>
30#include <linux/sh_intc.h>
31#include <linux/sh_timer.h>
32#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060033#include <mach/irqs.h>
Magnus Dammf2aaf662010-02-05 11:15:07 +000034#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36
Magnus Damm043296d2010-05-20 14:39:21 +000037/* SCIFA0 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000038static struct plat_sci_port scif0_platform_data = {
39 .mapbase = 0xe6c40000,
40 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090041 .scscr = SCSCR_RE | SCSCR_TE,
42 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +000043 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +000044 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
45 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000046};
47
48static struct platform_device scif0_device = {
49 .name = "sh-sci",
50 .id = 0,
51 .dev = {
52 .platform_data = &scif0_platform_data,
53 },
54};
55
Magnus Damm043296d2010-05-20 14:39:21 +000056/* SCIFA1 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000057static struct plat_sci_port scif1_platform_data = {
58 .mapbase = 0xe6c50000,
59 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090060 .scscr = SCSCR_RE | SCSCR_TE,
61 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +000062 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +000063 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
64 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000065};
66
67static struct platform_device scif1_device = {
68 .name = "sh-sci",
69 .id = 1,
70 .dev = {
71 .platform_data = &scif1_platform_data,
72 },
73};
74
Magnus Damm043296d2010-05-20 14:39:21 +000075/* SCIFA2 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000076static struct plat_sci_port scif2_platform_data = {
77 .mapbase = 0xe6c60000,
78 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090079 .scscr = SCSCR_RE | SCSCR_TE,
80 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +000081 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +000082 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
83 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000084};
85
86static struct platform_device scif2_device = {
87 .name = "sh-sci",
88 .id = 2,
89 .dev = {
90 .platform_data = &scif2_platform_data,
91 },
92};
93
Magnus Damm043296d2010-05-20 14:39:21 +000094/* SCIFA3 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000095static struct plat_sci_port scif3_platform_data = {
96 .mapbase = 0xe6c70000,
97 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090098 .scscr = SCSCR_RE | SCSCR_TE,
99 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000100 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000101 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
102 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000103};
104
105static struct platform_device scif3_device = {
106 .name = "sh-sci",
107 .id = 3,
108 .dev = {
109 .platform_data = &scif3_platform_data,
110 },
111};
112
Magnus Damm043296d2010-05-20 14:39:21 +0000113/* SCIFA4 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000114static struct plat_sci_port scif4_platform_data = {
115 .mapbase = 0xe6c80000,
116 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900117 .scscr = SCSCR_RE | SCSCR_TE,
118 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000119 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000120 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
121 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000122};
123
124static struct platform_device scif4_device = {
125 .name = "sh-sci",
126 .id = 4,
127 .dev = {
128 .platform_data = &scif4_platform_data,
129 },
130};
131
Magnus Damm043296d2010-05-20 14:39:21 +0000132/* SCIFA5 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000133static struct plat_sci_port scif5_platform_data = {
134 .mapbase = 0xe6cb0000,
135 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900136 .scscr = SCSCR_RE | SCSCR_TE,
137 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000138 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000139 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
140 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000141};
142
143static struct platform_device scif5_device = {
144 .name = "sh-sci",
145 .id = 5,
146 .dev = {
147 .platform_data = &scif5_platform_data,
148 },
149};
150
Magnus Damm043296d2010-05-20 14:39:21 +0000151/* SCIFA6 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000152static struct plat_sci_port scif6_platform_data = {
153 .mapbase = 0xe6cc0000,
154 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900155 .scscr = SCSCR_RE | SCSCR_TE,
156 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000157 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000158 .irqs = { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
159 intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000160};
161
162static struct platform_device scif6_device = {
163 .name = "sh-sci",
164 .id = 6,
165 .dev = {
166 .platform_data = &scif6_platform_data,
167 },
168};
169
Magnus Damm043296d2010-05-20 14:39:21 +0000170/* SCIFB */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000171static struct plat_sci_port scif7_platform_data = {
172 .mapbase = 0xe6c30000,
173 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900174 .scscr = SCSCR_RE | SCSCR_TE,
175 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000176 .type = PORT_SCIFB,
Magnus Damm043296d2010-05-20 14:39:21 +0000177 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
178 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000179};
180
181static struct platform_device scif7_device = {
182 .name = "sh-sci",
183 .id = 7,
184 .dev = {
185 .platform_data = &scif7_platform_data,
186 },
187};
188
189static struct sh_timer_config cmt10_platform_data = {
190 .name = "CMT10",
191 .channel_offset = 0x10,
192 .timer_bit = 0,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000193 .clockevent_rating = 125,
194 .clocksource_rating = 125,
195};
196
197static struct resource cmt10_resources[] = {
198 [0] = {
199 .name = "CMT10",
200 .start = 0xe6138010,
201 .end = 0xe613801b,
202 .flags = IORESOURCE_MEM,
203 },
204 [1] = {
Magnus Damm043296d2010-05-20 14:39:21 +0000205 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000206 .flags = IORESOURCE_IRQ,
207 },
208};
209
210static struct platform_device cmt10_device = {
211 .name = "sh_cmt",
212 .id = 10,
213 .dev = {
214 .platform_data = &cmt10_platform_data,
215 },
216 .resource = cmt10_resources,
217 .num_resources = ARRAY_SIZE(cmt10_resources),
218};
219
Magnus Dammc9fcf002011-04-28 03:19:05 +0000220/* VPU */
221static struct uio_info vpu_platform_data = {
222 .name = "VPU5HG",
223 .version = "0",
224 .irq = intcs_evt2irq(0x980),
225};
226
227static struct resource vpu_resources[] = {
228 [0] = {
229 .name = "VPU",
230 .start = 0xfe900000,
231 .end = 0xfe900157,
232 .flags = IORESOURCE_MEM,
233 },
234};
235
236static struct platform_device vpu_device = {
237 .name = "uio_pdrv_genirq",
238 .id = 0,
239 .dev = {
240 .platform_data = &vpu_platform_data,
241 },
242 .resource = vpu_resources,
243 .num_resources = ARRAY_SIZE(vpu_resources),
244};
245
246/* VEU0 */
247static struct uio_info veu0_platform_data = {
248 .name = "VEU0",
249 .version = "0",
250 .irq = intcs_evt2irq(0x700),
251};
252
253static struct resource veu0_resources[] = {
254 [0] = {
255 .name = "VEU0",
256 .start = 0xfe920000,
257 .end = 0xfe9200cb,
258 .flags = IORESOURCE_MEM,
259 },
260};
261
262static struct platform_device veu0_device = {
263 .name = "uio_pdrv_genirq",
264 .id = 1,
265 .dev = {
266 .platform_data = &veu0_platform_data,
267 },
268 .resource = veu0_resources,
269 .num_resources = ARRAY_SIZE(veu0_resources),
270};
271
272/* VEU1 */
273static struct uio_info veu1_platform_data = {
274 .name = "VEU1",
275 .version = "0",
276 .irq = intcs_evt2irq(0x720),
277};
278
279static struct resource veu1_resources[] = {
280 [0] = {
281 .name = "VEU1",
282 .start = 0xfe924000,
283 .end = 0xfe9240cb,
284 .flags = IORESOURCE_MEM,
285 },
286};
287
288static struct platform_device veu1_device = {
289 .name = "uio_pdrv_genirq",
290 .id = 2,
291 .dev = {
292 .platform_data = &veu1_platform_data,
293 },
294 .resource = veu1_resources,
295 .num_resources = ARRAY_SIZE(veu1_resources),
296};
297
298/* VEU2 */
299static struct uio_info veu2_platform_data = {
300 .name = "VEU2",
301 .version = "0",
302 .irq = intcs_evt2irq(0x740),
303};
304
305static struct resource veu2_resources[] = {
306 [0] = {
307 .name = "VEU2",
308 .start = 0xfe928000,
309 .end = 0xfe928307,
310 .flags = IORESOURCE_MEM,
311 },
312};
313
314static struct platform_device veu2_device = {
315 .name = "uio_pdrv_genirq",
316 .id = 3,
317 .dev = {
318 .platform_data = &veu2_platform_data,
319 },
320 .resource = veu2_resources,
321 .num_resources = ARRAY_SIZE(veu2_resources),
322};
323
324/* VEU3 */
325static struct uio_info veu3_platform_data = {
326 .name = "VEU3",
327 .version = "0",
328 .irq = intcs_evt2irq(0x760),
329};
330
331static struct resource veu3_resources[] = {
332 [0] = {
333 .name = "VEU3",
334 .start = 0xfe92c000,
335 .end = 0xfe92c307,
336 .flags = IORESOURCE_MEM,
337 },
338};
339
340static struct platform_device veu3_device = {
341 .name = "uio_pdrv_genirq",
342 .id = 4,
343 .dev = {
344 .platform_data = &veu3_platform_data,
345 },
346 .resource = veu3_resources,
347 .num_resources = ARRAY_SIZE(veu3_resources),
348};
349
350/* JPU */
351static struct uio_info jpu_platform_data = {
352 .name = "JPU",
353 .version = "0",
354 .irq = intcs_evt2irq(0x560),
355};
356
357static struct resource jpu_resources[] = {
358 [0] = {
359 .name = "JPU",
360 .start = 0xfe980000,
361 .end = 0xfe9902d3,
362 .flags = IORESOURCE_MEM,
363 },
364};
365
366static struct platform_device jpu_device = {
367 .name = "uio_pdrv_genirq",
368 .id = 5,
369 .dev = {
370 .platform_data = &jpu_platform_data,
371 },
372 .resource = jpu_resources,
373 .num_resources = ARRAY_SIZE(jpu_resources),
374};
375
376/* SPU2DSP0 */
377static struct uio_info spu0_platform_data = {
378 .name = "SPU2DSP0",
379 .version = "0",
380 .irq = evt2irq(0x1800),
381};
382
383static struct resource spu0_resources[] = {
384 [0] = {
385 .name = "SPU2DSP0",
386 .start = 0xfe200000,
387 .end = 0xfe2fffff,
388 .flags = IORESOURCE_MEM,
389 },
390};
391
392static struct platform_device spu0_device = {
393 .name = "uio_pdrv_genirq",
394 .id = 6,
395 .dev = {
396 .platform_data = &spu0_platform_data,
397 },
398 .resource = spu0_resources,
399 .num_resources = ARRAY_SIZE(spu0_resources),
400};
401
402/* SPU2DSP1 */
403static struct uio_info spu1_platform_data = {
404 .name = "SPU2DSP1",
405 .version = "0",
406 .irq = evt2irq(0x1820),
407};
408
409static struct resource spu1_resources[] = {
410 [0] = {
411 .name = "SPU2DSP1",
412 .start = 0xfe300000,
413 .end = 0xfe3fffff,
414 .flags = IORESOURCE_MEM,
415 },
416};
417
418static struct platform_device spu1_device = {
419 .name = "uio_pdrv_genirq",
420 .id = 7,
421 .dev = {
422 .platform_data = &spu1_platform_data,
423 },
424 .resource = spu1_resources,
425 .num_resources = ARRAY_SIZE(spu1_resources),
426};
427
Magnus Dammf2aaf662010-02-05 11:15:07 +0000428static struct platform_device *sh7377_early_devices[] __initdata = {
429 &scif0_device,
430 &scif1_device,
431 &scif2_device,
432 &scif3_device,
433 &scif4_device,
434 &scif5_device,
435 &scif6_device,
436 &scif7_device,
437 &cmt10_device,
438};
439
Magnus Dammc9fcf002011-04-28 03:19:05 +0000440static struct platform_device *sh7377_devices[] __initdata = {
441 &vpu_device,
442 &veu0_device,
443 &veu1_device,
444 &veu2_device,
445 &veu3_device,
446 &jpu_device,
447 &spu0_device,
448 &spu1_device,
449};
450
Magnus Dammf2aaf662010-02-05 11:15:07 +0000451void __init sh7377_add_standard_devices(void)
452{
453 platform_add_devices(sh7377_early_devices,
454 ARRAY_SIZE(sh7377_early_devices));
Magnus Dammc9fcf002011-04-28 03:19:05 +0000455
456 platform_add_devices(sh7377_devices,
457 ARRAY_SIZE(sh7377_devices));
Magnus Dammf2aaf662010-02-05 11:15:07 +0000458}
459
460#define SMSTPCR3 0xe615013c
461#define SMSTPCR3_CMT1 (1 << 29)
462
463void __init sh7377_add_early_devices(void)
464{
465 /* enable clock to CMT1 */
466 __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3);
467
468 early_platform_add_devices(sh7377_early_devices,
469 ARRAY_SIZE(sh7377_early_devices));
470}