blob: 979cf815c2988c4bce6958c954ad78c4b85b7356 [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>
37
Magnus Dammbfc46f32012-02-29 21:37:12 +090038static struct map_desc sh7377_io_desc[] __initdata = {
39 /* create a 1:1 entity map for 0xe6xxxxxx
40 * used by CPGA, INTC and PFC.
41 */
42 {
43 .virtual = 0xe6000000,
44 .pfn = __phys_to_pfn(0xe6000000),
45 .length = 256 << 20,
46 .type = MT_DEVICE_NONSHARED
47 },
48};
49
50void __init sh7377_map_io(void)
51{
52 iotable_init(sh7377_io_desc, ARRAY_SIZE(sh7377_io_desc));
53}
54
Magnus Damm043296d2010-05-20 14:39:21 +000055/* SCIFA0 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000056static struct plat_sci_port scif0_platform_data = {
57 .mapbase = 0xe6c40000,
58 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090059 .scscr = SCSCR_RE | SCSCR_TE,
60 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +000061 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +000062 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
63 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000064};
65
66static struct platform_device scif0_device = {
67 .name = "sh-sci",
68 .id = 0,
69 .dev = {
70 .platform_data = &scif0_platform_data,
71 },
72};
73
Magnus Damm043296d2010-05-20 14:39:21 +000074/* SCIFA1 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000075static struct plat_sci_port scif1_platform_data = {
76 .mapbase = 0xe6c50000,
77 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090078 .scscr = SCSCR_RE | SCSCR_TE,
79 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +000080 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +000081 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
82 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +000083};
84
85static struct platform_device scif1_device = {
86 .name = "sh-sci",
87 .id = 1,
88 .dev = {
89 .platform_data = &scif1_platform_data,
90 },
91};
92
Magnus Damm043296d2010-05-20 14:39:21 +000093/* SCIFA2 */
Magnus Dammf2aaf662010-02-05 11:15:07 +000094static struct plat_sci_port scif2_platform_data = {
95 .mapbase = 0xe6c60000,
96 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090097 .scscr = SCSCR_RE | SCSCR_TE,
98 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +000099 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000100 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
101 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000102};
103
104static struct platform_device scif2_device = {
105 .name = "sh-sci",
106 .id = 2,
107 .dev = {
108 .platform_data = &scif2_platform_data,
109 },
110};
111
Magnus Damm043296d2010-05-20 14:39:21 +0000112/* SCIFA3 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000113static struct plat_sci_port scif3_platform_data = {
114 .mapbase = 0xe6c70000,
115 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900116 .scscr = SCSCR_RE | SCSCR_TE,
117 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000118 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000119 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
120 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000121};
122
123static struct platform_device scif3_device = {
124 .name = "sh-sci",
125 .id = 3,
126 .dev = {
127 .platform_data = &scif3_platform_data,
128 },
129};
130
Magnus Damm043296d2010-05-20 14:39:21 +0000131/* SCIFA4 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000132static struct plat_sci_port scif4_platform_data = {
133 .mapbase = 0xe6c80000,
134 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900135 .scscr = SCSCR_RE | SCSCR_TE,
136 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000137 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000138 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
139 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000140};
141
142static struct platform_device scif4_device = {
143 .name = "sh-sci",
144 .id = 4,
145 .dev = {
146 .platform_data = &scif4_platform_data,
147 },
148};
149
Magnus Damm043296d2010-05-20 14:39:21 +0000150/* SCIFA5 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000151static struct plat_sci_port scif5_platform_data = {
152 .mapbase = 0xe6cb0000,
153 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900154 .scscr = SCSCR_RE | SCSCR_TE,
155 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000156 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000157 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
158 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000159};
160
161static struct platform_device scif5_device = {
162 .name = "sh-sci",
163 .id = 5,
164 .dev = {
165 .platform_data = &scif5_platform_data,
166 },
167};
168
Magnus Damm043296d2010-05-20 14:39:21 +0000169/* SCIFA6 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000170static struct plat_sci_port scif6_platform_data = {
171 .mapbase = 0xe6cc0000,
172 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900173 .scscr = SCSCR_RE | SCSCR_TE,
174 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000175 .type = PORT_SCIFA,
Magnus Damm043296d2010-05-20 14:39:21 +0000176 .irqs = { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
177 intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000178};
179
180static struct platform_device scif6_device = {
181 .name = "sh-sci",
182 .id = 6,
183 .dev = {
184 .platform_data = &scif6_platform_data,
185 },
186};
187
Magnus Damm043296d2010-05-20 14:39:21 +0000188/* SCIFB */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000189static struct plat_sci_port scif7_platform_data = {
190 .mapbase = 0xe6c30000,
191 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900192 .scscr = SCSCR_RE | SCSCR_TE,
193 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm1d0738e2011-04-28 03:02:40 +0000194 .type = PORT_SCIFB,
Magnus Damm043296d2010-05-20 14:39:21 +0000195 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
196 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammf2aaf662010-02-05 11:15:07 +0000197};
198
199static struct platform_device scif7_device = {
200 .name = "sh-sci",
201 .id = 7,
202 .dev = {
203 .platform_data = &scif7_platform_data,
204 },
205};
206
207static struct sh_timer_config cmt10_platform_data = {
208 .name = "CMT10",
209 .channel_offset = 0x10,
210 .timer_bit = 0,
Magnus Dammf2aaf662010-02-05 11:15:07 +0000211 .clockevent_rating = 125,
212 .clocksource_rating = 125,
213};
214
215static struct resource cmt10_resources[] = {
216 [0] = {
217 .name = "CMT10",
218 .start = 0xe6138010,
219 .end = 0xe613801b,
220 .flags = IORESOURCE_MEM,
221 },
222 [1] = {
Magnus Damm043296d2010-05-20 14:39:21 +0000223 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000224 .flags = IORESOURCE_IRQ,
225 },
226};
227
228static struct platform_device cmt10_device = {
229 .name = "sh_cmt",
230 .id = 10,
231 .dev = {
232 .platform_data = &cmt10_platform_data,
233 },
234 .resource = cmt10_resources,
235 .num_resources = ARRAY_SIZE(cmt10_resources),
236};
237
Magnus Dammc9fcf002011-04-28 03:19:05 +0000238/* VPU */
239static struct uio_info vpu_platform_data = {
240 .name = "VPU5HG",
241 .version = "0",
242 .irq = intcs_evt2irq(0x980),
243};
244
245static struct resource vpu_resources[] = {
246 [0] = {
247 .name = "VPU",
248 .start = 0xfe900000,
249 .end = 0xfe900157,
250 .flags = IORESOURCE_MEM,
251 },
252};
253
254static struct platform_device vpu_device = {
255 .name = "uio_pdrv_genirq",
256 .id = 0,
257 .dev = {
258 .platform_data = &vpu_platform_data,
259 },
260 .resource = vpu_resources,
261 .num_resources = ARRAY_SIZE(vpu_resources),
262};
263
264/* VEU0 */
265static struct uio_info veu0_platform_data = {
266 .name = "VEU0",
267 .version = "0",
268 .irq = intcs_evt2irq(0x700),
269};
270
271static struct resource veu0_resources[] = {
272 [0] = {
273 .name = "VEU0",
274 .start = 0xfe920000,
275 .end = 0xfe9200cb,
276 .flags = IORESOURCE_MEM,
277 },
278};
279
280static struct platform_device veu0_device = {
281 .name = "uio_pdrv_genirq",
282 .id = 1,
283 .dev = {
284 .platform_data = &veu0_platform_data,
285 },
286 .resource = veu0_resources,
287 .num_resources = ARRAY_SIZE(veu0_resources),
288};
289
290/* VEU1 */
291static struct uio_info veu1_platform_data = {
292 .name = "VEU1",
293 .version = "0",
294 .irq = intcs_evt2irq(0x720),
295};
296
297static struct resource veu1_resources[] = {
298 [0] = {
299 .name = "VEU1",
300 .start = 0xfe924000,
301 .end = 0xfe9240cb,
302 .flags = IORESOURCE_MEM,
303 },
304};
305
306static struct platform_device veu1_device = {
307 .name = "uio_pdrv_genirq",
308 .id = 2,
309 .dev = {
310 .platform_data = &veu1_platform_data,
311 },
312 .resource = veu1_resources,
313 .num_resources = ARRAY_SIZE(veu1_resources),
314};
315
316/* VEU2 */
317static struct uio_info veu2_platform_data = {
318 .name = "VEU2",
319 .version = "0",
320 .irq = intcs_evt2irq(0x740),
321};
322
323static struct resource veu2_resources[] = {
324 [0] = {
325 .name = "VEU2",
326 .start = 0xfe928000,
327 .end = 0xfe928307,
328 .flags = IORESOURCE_MEM,
329 },
330};
331
332static struct platform_device veu2_device = {
333 .name = "uio_pdrv_genirq",
334 .id = 3,
335 .dev = {
336 .platform_data = &veu2_platform_data,
337 },
338 .resource = veu2_resources,
339 .num_resources = ARRAY_SIZE(veu2_resources),
340};
341
342/* VEU3 */
343static struct uio_info veu3_platform_data = {
344 .name = "VEU3",
345 .version = "0",
346 .irq = intcs_evt2irq(0x760),
347};
348
349static struct resource veu3_resources[] = {
350 [0] = {
351 .name = "VEU3",
352 .start = 0xfe92c000,
353 .end = 0xfe92c307,
354 .flags = IORESOURCE_MEM,
355 },
356};
357
358static struct platform_device veu3_device = {
359 .name = "uio_pdrv_genirq",
360 .id = 4,
361 .dev = {
362 .platform_data = &veu3_platform_data,
363 },
364 .resource = veu3_resources,
365 .num_resources = ARRAY_SIZE(veu3_resources),
366};
367
368/* JPU */
369static struct uio_info jpu_platform_data = {
370 .name = "JPU",
371 .version = "0",
372 .irq = intcs_evt2irq(0x560),
373};
374
375static struct resource jpu_resources[] = {
376 [0] = {
377 .name = "JPU",
378 .start = 0xfe980000,
379 .end = 0xfe9902d3,
380 .flags = IORESOURCE_MEM,
381 },
382};
383
384static struct platform_device jpu_device = {
385 .name = "uio_pdrv_genirq",
386 .id = 5,
387 .dev = {
388 .platform_data = &jpu_platform_data,
389 },
390 .resource = jpu_resources,
391 .num_resources = ARRAY_SIZE(jpu_resources),
392};
393
394/* SPU2DSP0 */
395static struct uio_info spu0_platform_data = {
396 .name = "SPU2DSP0",
397 .version = "0",
398 .irq = evt2irq(0x1800),
399};
400
401static struct resource spu0_resources[] = {
402 [0] = {
403 .name = "SPU2DSP0",
404 .start = 0xfe200000,
405 .end = 0xfe2fffff,
406 .flags = IORESOURCE_MEM,
407 },
408};
409
410static struct platform_device spu0_device = {
411 .name = "uio_pdrv_genirq",
412 .id = 6,
413 .dev = {
414 .platform_data = &spu0_platform_data,
415 },
416 .resource = spu0_resources,
417 .num_resources = ARRAY_SIZE(spu0_resources),
418};
419
420/* SPU2DSP1 */
421static struct uio_info spu1_platform_data = {
422 .name = "SPU2DSP1",
423 .version = "0",
424 .irq = evt2irq(0x1820),
425};
426
427static struct resource spu1_resources[] = {
428 [0] = {
429 .name = "SPU2DSP1",
430 .start = 0xfe300000,
431 .end = 0xfe3fffff,
432 .flags = IORESOURCE_MEM,
433 },
434};
435
436static struct platform_device spu1_device = {
437 .name = "uio_pdrv_genirq",
438 .id = 7,
439 .dev = {
440 .platform_data = &spu1_platform_data,
441 },
442 .resource = spu1_resources,
443 .num_resources = ARRAY_SIZE(spu1_resources),
444};
445
Magnus Dammf2aaf662010-02-05 11:15:07 +0000446static struct platform_device *sh7377_early_devices[] __initdata = {
447 &scif0_device,
448 &scif1_device,
449 &scif2_device,
450 &scif3_device,
451 &scif4_device,
452 &scif5_device,
453 &scif6_device,
454 &scif7_device,
455 &cmt10_device,
456};
457
Magnus Dammc9fcf002011-04-28 03:19:05 +0000458static struct platform_device *sh7377_devices[] __initdata = {
459 &vpu_device,
460 &veu0_device,
461 &veu1_device,
462 &veu2_device,
463 &veu3_device,
464 &jpu_device,
465 &spu0_device,
466 &spu1_device,
467};
468
Magnus Dammf2aaf662010-02-05 11:15:07 +0000469void __init sh7377_add_standard_devices(void)
470{
471 platform_add_devices(sh7377_early_devices,
472 ARRAY_SIZE(sh7377_early_devices));
Magnus Dammc9fcf002011-04-28 03:19:05 +0000473
474 platform_add_devices(sh7377_devices,
475 ARRAY_SIZE(sh7377_devices));
Magnus Dammf2aaf662010-02-05 11:15:07 +0000476}
477
478#define SMSTPCR3 0xe615013c
479#define SMSTPCR3_CMT1 (1 << 29)
480
481void __init sh7377_add_early_devices(void)
482{
483 /* enable clock to CMT1 */
484 __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3);
485
486 early_platform_add_devices(sh7377_early_devices,
487 ARRAY_SIZE(sh7377_early_devices));
Magnus Dammbfc46f32012-02-29 21:37:12 +0900488
489 /* setup early console here as well */
490 shmobile_setup_console();
Magnus Dammf2aaf662010-02-05 11:15:07 +0000491}