blob: 7b747aba204649a65d850305fa0194c2218106fb [file] [log] [blame]
Magnus Dammc793c1b2010-02-05 11:14:49 +00001/*
2 * sh7367 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 Dammde328352011-04-28 03:16:32 +000025#include <linux/uio_driver.h>
Magnus Dammc793c1b2010-02-05 11:14:49 +000026#include <linux/delay.h>
27#include <linux/input.h>
28#include <linux/io.h>
29#include <linux/serial_sci.h>
Magnus Dammc793c1b2010-02-05 11:14:49 +000030#include <linux/sh_timer.h>
31#include <mach/hardware.h>
Magnus Damm237caf92012-02-29 21:37:04 +090032#include <mach/common.h>
Magnus Dammc793c1b2010-02-05 11:14:49 +000033#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
Magnus Damm237caf92012-02-29 21:37:04 +090035#include <asm/mach/map.h>
36
37static struct map_desc sh7367_io_desc[] __initdata = {
38 /* create a 1:1 entity map for 0xe6xxxxxx
39 * used by CPGA, INTC and PFC.
40 */
41 {
42 .virtual = 0xe6000000,
43 .pfn = __phys_to_pfn(0xe6000000),
44 .length = 256 << 20,
45 .type = MT_DEVICE_NONSHARED
46 },
47};
48
49void __init sh7367_map_io(void)
50{
51 iotable_init(sh7367_io_desc, ARRAY_SIZE(sh7367_io_desc));
52}
Magnus Dammc793c1b2010-02-05 11:14:49 +000053
Magnus Damm74905092010-05-20 14:35:30 +000054/* SCIFA0 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000055static struct plat_sci_port scif0_platform_data = {
56 .mapbase = 0xe6c40000,
57 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090058 .scscr = SCSCR_RE | SCSCR_TE,
59 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090060 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000061 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
62 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000063};
64
65static struct platform_device scif0_device = {
66 .name = "sh-sci",
67 .id = 0,
68 .dev = {
69 .platform_data = &scif0_platform_data,
70 },
71};
72
Magnus Damm74905092010-05-20 14:35:30 +000073/* SCIFA1 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000074static struct plat_sci_port scif1_platform_data = {
75 .mapbase = 0xe6c50000,
76 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090077 .scscr = SCSCR_RE | SCSCR_TE,
78 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090079 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000080 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
81 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +000082};
83
84static struct platform_device scif1_device = {
85 .name = "sh-sci",
86 .id = 1,
87 .dev = {
88 .platform_data = &scif1_platform_data,
89 },
90};
91
Magnus Damm74905092010-05-20 14:35:30 +000092/* SCIFA2 */
Magnus Dammc793c1b2010-02-05 11:14:49 +000093static struct plat_sci_port scif2_platform_data = {
94 .mapbase = 0xe6c60000,
95 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090096 .scscr = SCSCR_RE | SCSCR_TE,
97 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +090098 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000099 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
100 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000101};
102
103static struct platform_device scif2_device = {
104 .name = "sh-sci",
105 .id = 2,
106 .dev = {
107 .platform_data = &scif2_platform_data,
108 },
109};
110
Magnus Damm74905092010-05-20 14:35:30 +0000111/* SCIFA3 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000112static struct plat_sci_port scif3_platform_data = {
113 .mapbase = 0xe6c70000,
114 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900115 .scscr = SCSCR_RE | SCSCR_TE,
116 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900117 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000118 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
119 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000120};
121
122static struct platform_device scif3_device = {
123 .name = "sh-sci",
124 .id = 3,
125 .dev = {
126 .platform_data = &scif3_platform_data,
127 },
128};
129
Magnus Damm74905092010-05-20 14:35:30 +0000130/* SCIFA4 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000131static struct plat_sci_port scif4_platform_data = {
132 .mapbase = 0xe6c80000,
133 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900134 .scscr = SCSCR_RE | SCSCR_TE,
135 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900136 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000137 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
138 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000139};
140
141static struct platform_device scif4_device = {
142 .name = "sh-sci",
143 .id = 4,
144 .dev = {
145 .platform_data = &scif4_platform_data,
146 },
147};
148
Magnus Damm74905092010-05-20 14:35:30 +0000149/* SCIFA5 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000150static struct plat_sci_port scif5_platform_data = {
151 .mapbase = 0xe6cb0000,
152 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900153 .scscr = SCSCR_RE | SCSCR_TE,
154 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900155 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000156 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
157 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000158};
159
160static struct platform_device scif5_device = {
161 .name = "sh-sci",
162 .id = 5,
163 .dev = {
164 .platform_data = &scif5_platform_data,
165 },
166};
167
Magnus Damm74905092010-05-20 14:35:30 +0000168/* SCIFB */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000169static struct plat_sci_port scif6_platform_data = {
170 .mapbase = 0xe6c30000,
171 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900172 .scscr = SCSCR_RE | SCSCR_TE,
173 .scbrr_algo_id = SCBRR_ALGO_4,
Paul Mundt31105722011-06-14 15:07:06 +0900174 .type = PORT_SCIFB,
Magnus Damm74905092010-05-20 14:35:30 +0000175 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
176 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +0000177};
178
179static struct platform_device scif6_device = {
180 .name = "sh-sci",
181 .id = 6,
182 .dev = {
183 .platform_data = &scif6_platform_data,
184 },
185};
186
187static struct sh_timer_config cmt10_platform_data = {
188 .name = "CMT10",
189 .channel_offset = 0x10,
190 .timer_bit = 0,
Magnus Dammc793c1b2010-02-05 11:14:49 +0000191 .clockevent_rating = 125,
192 .clocksource_rating = 125,
193};
194
195static struct resource cmt10_resources[] = {
196 [0] = {
197 .name = "CMT10",
198 .start = 0xe6138010,
199 .end = 0xe613801b,
200 .flags = IORESOURCE_MEM,
201 },
202 [1] = {
Magnus Damm74905092010-05-20 14:35:30 +0000203 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000204 .flags = IORESOURCE_IRQ,
205 },
206};
207
208static struct platform_device cmt10_device = {
209 .name = "sh_cmt",
210 .id = 10,
211 .dev = {
212 .platform_data = &cmt10_platform_data,
213 },
214 .resource = cmt10_resources,
215 .num_resources = ARRAY_SIZE(cmt10_resources),
216};
217
Magnus Dammde328352011-04-28 03:16:32 +0000218/* VPU */
219static struct uio_info vpu_platform_data = {
220 .name = "VPU5",
221 .version = "0",
222 .irq = intcs_evt2irq(0x980),
223};
224
225static struct resource vpu_resources[] = {
226 [0] = {
227 .name = "VPU",
228 .start = 0xfe900000,
229 .end = 0xfe902807,
230 .flags = IORESOURCE_MEM,
231 },
232};
233
234static struct platform_device vpu_device = {
235 .name = "uio_pdrv_genirq",
236 .id = 0,
237 .dev = {
238 .platform_data = &vpu_platform_data,
239 },
240 .resource = vpu_resources,
241 .num_resources = ARRAY_SIZE(vpu_resources),
242};
243
244/* VEU0 */
245static struct uio_info veu0_platform_data = {
246 .name = "VEU0",
247 .version = "0",
248 .irq = intcs_evt2irq(0x700),
249};
250
251static struct resource veu0_resources[] = {
252 [0] = {
253 .name = "VEU0",
254 .start = 0xfe920000,
255 .end = 0xfe9200b7,
256 .flags = IORESOURCE_MEM,
257 },
258};
259
260static struct platform_device veu0_device = {
261 .name = "uio_pdrv_genirq",
262 .id = 1,
263 .dev = {
264 .platform_data = &veu0_platform_data,
265 },
266 .resource = veu0_resources,
267 .num_resources = ARRAY_SIZE(veu0_resources),
268};
269
270/* VEU1 */
271static struct uio_info veu1_platform_data = {
272 .name = "VEU1",
273 .version = "0",
274 .irq = intcs_evt2irq(0x720),
275};
276
277static struct resource veu1_resources[] = {
278 [0] = {
279 .name = "VEU1",
280 .start = 0xfe924000,
281 .end = 0xfe9240b7,
282 .flags = IORESOURCE_MEM,
283 },
284};
285
286static struct platform_device veu1_device = {
287 .name = "uio_pdrv_genirq",
288 .id = 2,
289 .dev = {
290 .platform_data = &veu1_platform_data,
291 },
292 .resource = veu1_resources,
293 .num_resources = ARRAY_SIZE(veu1_resources),
294};
295
296/* VEU2 */
297static struct uio_info veu2_platform_data = {
298 .name = "VEU2",
299 .version = "0",
300 .irq = intcs_evt2irq(0x740),
301};
302
303static struct resource veu2_resources[] = {
304 [0] = {
305 .name = "VEU2",
306 .start = 0xfe928000,
307 .end = 0xfe9280b7,
308 .flags = IORESOURCE_MEM,
309 },
310};
311
312static struct platform_device veu2_device = {
313 .name = "uio_pdrv_genirq",
314 .id = 3,
315 .dev = {
316 .platform_data = &veu2_platform_data,
317 },
318 .resource = veu2_resources,
319 .num_resources = ARRAY_SIZE(veu2_resources),
320};
321
322/* VEU3 */
323static struct uio_info veu3_platform_data = {
324 .name = "VEU3",
325 .version = "0",
326 .irq = intcs_evt2irq(0x760),
327};
328
329static struct resource veu3_resources[] = {
330 [0] = {
331 .name = "VEU3",
332 .start = 0xfe92c000,
333 .end = 0xfe92c0b7,
334 .flags = IORESOURCE_MEM,
335 },
336};
337
338static struct platform_device veu3_device = {
339 .name = "uio_pdrv_genirq",
340 .id = 4,
341 .dev = {
342 .platform_data = &veu3_platform_data,
343 },
344 .resource = veu3_resources,
345 .num_resources = ARRAY_SIZE(veu3_resources),
346};
347
348/* VEU2H */
349static struct uio_info veu2h_platform_data = {
350 .name = "VEU2H",
351 .version = "0",
352 .irq = intcs_evt2irq(0x520),
353};
354
355static struct resource veu2h_resources[] = {
356 [0] = {
357 .name = "VEU2H",
358 .start = 0xfe93c000,
359 .end = 0xfe93c27b,
360 .flags = IORESOURCE_MEM,
361 },
362};
363
364static struct platform_device veu2h_device = {
365 .name = "uio_pdrv_genirq",
366 .id = 5,
367 .dev = {
368 .platform_data = &veu2h_platform_data,
369 },
370 .resource = veu2h_resources,
371 .num_resources = ARRAY_SIZE(veu2h_resources),
372};
373
374/* JPU */
375static struct uio_info jpu_platform_data = {
376 .name = "JPU",
377 .version = "0",
378 .irq = intcs_evt2irq(0x560),
379};
380
381static struct resource jpu_resources[] = {
382 [0] = {
383 .name = "JPU",
384 .start = 0xfe980000,
385 .end = 0xfe9902d3,
386 .flags = IORESOURCE_MEM,
387 },
388};
389
390static struct platform_device jpu_device = {
391 .name = "uio_pdrv_genirq",
392 .id = 6,
393 .dev = {
394 .platform_data = &jpu_platform_data,
395 },
396 .resource = jpu_resources,
397 .num_resources = ARRAY_SIZE(jpu_resources),
398};
399
400/* SPU1 */
401static struct uio_info spu1_platform_data = {
402 .name = "SPU1",
403 .version = "0",
404 .irq = evt2irq(0xfc0),
405};
406
407static struct resource spu1_resources[] = {
408 [0] = {
409 .name = "SPU1",
410 .start = 0xfe300000,
411 .end = 0xfe3fffff,
412 .flags = IORESOURCE_MEM,
413 },
414};
415
416static struct platform_device spu1_device = {
417 .name = "uio_pdrv_genirq",
418 .id = 7,
419 .dev = {
420 .platform_data = &spu1_platform_data,
421 },
422 .resource = spu1_resources,
423 .num_resources = ARRAY_SIZE(spu1_resources),
424};
425
Magnus Dammc793c1b2010-02-05 11:14:49 +0000426static struct platform_device *sh7367_early_devices[] __initdata = {
427 &scif0_device,
428 &scif1_device,
429 &scif2_device,
430 &scif3_device,
431 &scif4_device,
432 &scif5_device,
433 &scif6_device,
434 &cmt10_device,
435};
436
Magnus Dammde328352011-04-28 03:16:32 +0000437static struct platform_device *sh7367_devices[] __initdata = {
438 &vpu_device,
439 &veu0_device,
440 &veu1_device,
441 &veu2_device,
442 &veu3_device,
443 &veu2h_device,
444 &jpu_device,
445 &spu1_device,
446};
447
Magnus Dammc793c1b2010-02-05 11:14:49 +0000448void __init sh7367_add_standard_devices(void)
449{
450 platform_add_devices(sh7367_early_devices,
451 ARRAY_SIZE(sh7367_early_devices));
Magnus Dammde328352011-04-28 03:16:32 +0000452
453 platform_add_devices(sh7367_devices,
454 ARRAY_SIZE(sh7367_devices));
Magnus Dammc793c1b2010-02-05 11:14:49 +0000455}
456
457#define SYMSTPCR2 0xe6158048
458#define SYMSTPCR2_CMT1 (1 << 29)
459
460void __init sh7367_add_early_devices(void)
461{
462 /* enable clock to CMT1 */
463 __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2);
464
465 early_platform_add_devices(sh7367_early_devices,
466 ARRAY_SIZE(sh7367_early_devices));
Magnus Damm237caf92012-02-29 21:37:04 +0900467
468 /* setup early console here as well */
469 shmobile_setup_console();
Magnus Dammc793c1b2010-02-05 11:14:49 +0000470}