blob: 9f146095098b258766bebe319b47adc225ec00ce [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>
Magnus Dammbfc46f32012-02-29 21:37:12 +090033#include <mach/common.h>
34#include <asm/mach/map.h>
Magnus Dammf2aaf662010-02-05 11:15:07 +000035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
Magnus Damm03f7bee2012-03-06 17:36:29 +090037#include <asm/mach/time.h>
Magnus Dammf2aaf662010-02-05 11:15:07 +000038
Magnus Dammbfc46f32012-02-29 21:37:12 +090039static struct map_desc sh7377_io_desc[] __initdata = {
40 /* create a 1:1 entity map for 0xe6xxxxxx
41 * used by CPGA, INTC and PFC.
42 */
43 {
44 .virtual = 0xe6000000,
45 .pfn = __phys_to_pfn(0xe6000000),
46 .length = 256 << 20,
47 .type = MT_DEVICE_NONSHARED
48 },
49};
50
51void __init sh7377_map_io(void)
52{
53 iotable_init(sh7377_io_desc, ARRAY_SIZE(sh7377_io_desc));
54}
55
Magnus Damm043296d2010-05-20 14:39:21 +000056/* SCIFA0 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000057static struct plat_sci_port scif0_platform_data = {
58 .mapbase = 0xe6c40000,
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(0xc00), evt2irq(0xc00),
64 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000065};
66
67static struct platform_device scif0_device = {
68 .name = "sh-sci",
69 .id = 0,
70 .dev = {
71 .platform_data = &scif0_platform_data,
72 },
73};
74
Magnus Damm043296d2010-05-20 14:39:21 +000075/* SCIFA1 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000076static struct plat_sci_port scif1_platform_data = {
77 .mapbase = 0xe6c50000,
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(0xc20), evt2irq(0xc20),
83 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000084};
85
86static struct platform_device scif1_device = {
87 .name = "sh-sci",
88 .id = 1,
89 .dev = {
90 .platform_data = &scif1_platform_data,
91 },
92};
93
Magnus Damm043296d2010-05-20 14:39:21 +000094/* SCIFA2 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000095static struct plat_sci_port scif2_platform_data = {
96 .mapbase = 0xe6c60000,
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(0xc40), evt2irq(0xc40),
102 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000103};
104
105static struct platform_device scif2_device = {
106 .name = "sh-sci",
107 .id = 2,
108 .dev = {
109 .platform_data = &scif2_platform_data,
110 },
111};
112
Magnus Damm043296d2010-05-20 14:39:21 +0000113/* SCIFA3 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000114static struct plat_sci_port scif3_platform_data = {
115 .mapbase = 0xe6c70000,
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(0xc60), evt2irq(0xc60),
121 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000122};
123
124static struct platform_device scif3_device = {
125 .name = "sh-sci",
126 .id = 3,
127 .dev = {
128 .platform_data = &scif3_platform_data,
129 },
130};
131
Magnus Damm043296d2010-05-20 14:39:21 +0000132/* SCIFA4 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000133static struct plat_sci_port scif4_platform_data = {
134 .mapbase = 0xe6c80000,
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(0xd20), evt2irq(0xd20),
140 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000141};
142
143static struct platform_device scif4_device = {
144 .name = "sh-sci",
145 .id = 4,
146 .dev = {
147 .platform_data = &scif4_platform_data,
148 },
149};
150
Magnus Damm043296d2010-05-20 14:39:21 +0000151/* SCIFA5 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000152static struct plat_sci_port scif5_platform_data = {
153 .mapbase = 0xe6cb0000,
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 = { evt2irq(0xd40), evt2irq(0xd40),
159 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000160};
161
162static struct platform_device scif5_device = {
163 .name = "sh-sci",
164 .id = 5,
165 .dev = {
166 .platform_data = &scif5_platform_data,
167 },
168};
169
Magnus Damm043296d2010-05-20 14:39:21 +0000170/* SCIFA6 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000171static struct plat_sci_port scif6_platform_data = {
172 .mapbase = 0xe6cc0000,
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_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000177 .irqs = { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
178 intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000179};
180
181static struct platform_device scif6_device = {
182 .name = "sh-sci",
183 .id = 6,
184 .dev = {
185 .platform_data = &scif6_platform_data,
186 },
187};
188
Magnus Damm043296d2010-05-20 14:39:21 +0000189/* SCIFB */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000190static struct plat_sci_port scif7_platform_data = {
191 .mapbase = 0xe6c30000,
192 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900193 .scscr = SCSCR_RE | SCSCR_TE,
194 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000195 .type = PORT_SCIFB,
Magnus Damm043296d2010-05-20 14:39:21 +0000196 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
197 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000198};
199
200static struct platform_device scif7_device = {
201 .name = "sh-sci",
202 .id = 7,
203 .dev = {
204 .platform_data = &scif7_platform_data,
205 },
206};
207
208static struct sh_timer_config cmt10_platform_data = {
209 .name = "CMT10",
210 .channel_offset = 0x10,
211 .timer_bit = 0,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000212 .clockevent_rating = 125,
213 .clocksource_rating = 125,
214};
215
216static struct resource cmt10_resources[] = {
217 [0] = {
218 .name = "CMT10",
219 .start = 0xe6138010,
220 .end = 0xe613801b,
221 .flags = IORESOURCE_MEM,
222 },
223 [1] = {
Magnus Damm043296d2010-05-20 14:39:21 +0000224 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000225 .flags = IORESOURCE_IRQ,
226 },
227};
228
229static struct platform_device cmt10_device = {
230 .name = "sh_cmt",
231 .id = 10,
232 .dev = {
233 .platform_data = &cmt10_platform_data,
234 },
235 .resource = cmt10_resources,
236 .num_resources = ARRAY_SIZE(cmt10_resources),
237};
238
Magnus Dammc9fcf002011-04-28 03:19:05 +0000239/* VPU */
240static struct uio_info vpu_platform_data = {
241 .name = "VPU5HG",
242 .version = "0",
243 .irq = intcs_evt2irq(0x980),
244};
245
246static struct resource vpu_resources[] = {
247 [0] = {
248 .name = "VPU",
249 .start = 0xfe900000,
250 .end = 0xfe900157,
251 .flags = IORESOURCE_MEM,
252 },
253};
254
255static struct platform_device vpu_device = {
256 .name = "uio_pdrv_genirq",
257 .id = 0,
258 .dev = {
259 .platform_data = &vpu_platform_data,
260 },
261 .resource = vpu_resources,
262 .num_resources = ARRAY_SIZE(vpu_resources),
263};
264
265/* VEU0 */
266static struct uio_info veu0_platform_data = {
267 .name = "VEU0",
268 .version = "0",
269 .irq = intcs_evt2irq(0x700),
270};
271
272static struct resource veu0_resources[] = {
273 [0] = {
274 .name = "VEU0",
275 .start = 0xfe920000,
276 .end = 0xfe9200cb,
277 .flags = IORESOURCE_MEM,
278 },
279};
280
281static struct platform_device veu0_device = {
282 .name = "uio_pdrv_genirq",
283 .id = 1,
284 .dev = {
285 .platform_data = &veu0_platform_data,
286 },
287 .resource = veu0_resources,
288 .num_resources = ARRAY_SIZE(veu0_resources),
289};
290
291/* VEU1 */
292static struct uio_info veu1_platform_data = {
293 .name = "VEU1",
294 .version = "0",
295 .irq = intcs_evt2irq(0x720),
296};
297
298static struct resource veu1_resources[] = {
299 [0] = {
300 .name = "VEU1",
301 .start = 0xfe924000,
302 .end = 0xfe9240cb,
303 .flags = IORESOURCE_MEM,
304 },
305};
306
307static struct platform_device veu1_device = {
308 .name = "uio_pdrv_genirq",
309 .id = 2,
310 .dev = {
311 .platform_data = &veu1_platform_data,
312 },
313 .resource = veu1_resources,
314 .num_resources = ARRAY_SIZE(veu1_resources),
315};
316
317/* VEU2 */
318static struct uio_info veu2_platform_data = {
319 .name = "VEU2",
320 .version = "0",
321 .irq = intcs_evt2irq(0x740),
322};
323
324static struct resource veu2_resources[] = {
325 [0] = {
326 .name = "VEU2",
327 .start = 0xfe928000,
328 .end = 0xfe928307,
329 .flags = IORESOURCE_MEM,
330 },
331};
332
333static struct platform_device veu2_device = {
334 .name = "uio_pdrv_genirq",
335 .id = 3,
336 .dev = {
337 .platform_data = &veu2_platform_data,
338 },
339 .resource = veu2_resources,
340 .num_resources = ARRAY_SIZE(veu2_resources),
341};
342
343/* VEU3 */
344static struct uio_info veu3_platform_data = {
345 .name = "VEU3",
346 .version = "0",
347 .irq = intcs_evt2irq(0x760),
348};
349
350static struct resource veu3_resources[] = {
351 [0] = {
352 .name = "VEU3",
353 .start = 0xfe92c000,
354 .end = 0xfe92c307,
355 .flags = IORESOURCE_MEM,
356 },
357};
358
359static struct platform_device veu3_device = {
360 .name = "uio_pdrv_genirq",
361 .id = 4,
362 .dev = {
363 .platform_data = &veu3_platform_data,
364 },
365 .resource = veu3_resources,
366 .num_resources = ARRAY_SIZE(veu3_resources),
367};
368
369/* JPU */
370static struct uio_info jpu_platform_data = {
371 .name = "JPU",
372 .version = "0",
373 .irq = intcs_evt2irq(0x560),
374};
375
376static struct resource jpu_resources[] = {
377 [0] = {
378 .name = "JPU",
379 .start = 0xfe980000,
380 .end = 0xfe9902d3,
381 .flags = IORESOURCE_MEM,
382 },
383};
384
385static struct platform_device jpu_device = {
386 .name = "uio_pdrv_genirq",
387 .id = 5,
388 .dev = {
389 .platform_data = &jpu_platform_data,
390 },
391 .resource = jpu_resources,
392 .num_resources = ARRAY_SIZE(jpu_resources),
393};
394
395/* SPU2DSP0 */
396static struct uio_info spu0_platform_data = {
397 .name = "SPU2DSP0",
398 .version = "0",
399 .irq = evt2irq(0x1800),
400};
401
402static struct resource spu0_resources[] = {
403 [0] = {
404 .name = "SPU2DSP0",
405 .start = 0xfe200000,
406 .end = 0xfe2fffff,
407 .flags = IORESOURCE_MEM,
408 },
409};
410
411static struct platform_device spu0_device = {
412 .name = "uio_pdrv_genirq",
413 .id = 6,
414 .dev = {
415 .platform_data = &spu0_platform_data,
416 },
417 .resource = spu0_resources,
418 .num_resources = ARRAY_SIZE(spu0_resources),
419};
420
421/* SPU2DSP1 */
422static struct uio_info spu1_platform_data = {
423 .name = "SPU2DSP1",
424 .version = "0",
425 .irq = evt2irq(0x1820),
426};
427
428static struct resource spu1_resources[] = {
429 [0] = {
430 .name = "SPU2DSP1",
431 .start = 0xfe300000,
432 .end = 0xfe3fffff,
433 .flags = IORESOURCE_MEM,
434 },
435};
436
437static struct platform_device spu1_device = {
438 .name = "uio_pdrv_genirq",
439 .id = 7,
440 .dev = {
441 .platform_data = &spu1_platform_data,
442 },
443 .resource = spu1_resources,
444 .num_resources = ARRAY_SIZE(spu1_resources),
445};
446
Magnus Dammf2aaf662010-02-05 11:15:07 +0000447static struct platform_device *sh7377_early_devices[] __initdata = {
448 &scif0_device,
449 &scif1_device,
450 &scif2_device,
451 &scif3_device,
452 &scif4_device,
453 &scif5_device,
454 &scif6_device,
455 &scif7_device,
456 &cmt10_device,
457};
458
Magnus Dammc9fcf002011-04-28 03:19:05 +0000459static struct platform_device *sh7377_devices[] __initdata = {
460 &vpu_device,
461 &veu0_device,
462 &veu1_device,
463 &veu2_device,
464 &veu3_device,
465 &jpu_device,
466 &spu0_device,
467 &spu1_device,
468};
469
Magnus Dammf2aaf662010-02-05 11:15:07 +0000470void __init sh7377_add_standard_devices(void)
471{
472 platform_add_devices(sh7377_early_devices,
473 ARRAY_SIZE(sh7377_early_devices));
Magnus Dammc9fcf002011-04-28 03:19:05 +0000474
475 platform_add_devices(sh7377_devices,
476 ARRAY_SIZE(sh7377_devices));
Magnus Dammf2aaf662010-02-05 11:15:07 +0000477}
478
Magnus Damm03f7bee2012-03-06 17:36:29 +0900479static void __init sh7377_earlytimer_init(void)
480{
481 sh7377_clock_init();
482 shmobile_earlytimer_init();
483}
484
Magnus Dammf2aaf662010-02-05 11:15:07 +0000485#define SMSTPCR3 0xe615013c
486#define SMSTPCR3_CMT1 (1 << 29)
487
488void __init sh7377_add_early_devices(void)
489{
490 /* enable clock to CMT1 */
491 __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3);
492
493 early_platform_add_devices(sh7377_early_devices,
494 ARRAY_SIZE(sh7377_early_devices));
Magnus Dammbfc46f32012-02-29 21:37:12 +0900495
496 /* setup early console here as well */
497 shmobile_setup_console();
Magnus Damm03f7bee2012-03-06 17:36:29 +0900498
499 /* override timer setup with soc-specific code */
500 shmobile_timer.init = sh7377_earlytimer_init;
Magnus Dammf2aaf662010-02-05 11:15:07 +0000501}