blob: a51e1a1e6996ddf7a3bd097a23fdbc3071261ae0 [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>
Magnus Damm9e8de442012-03-06 17:36:22 +090036#include <asm/mach/time.h>
Magnus Damm237caf92012-02-29 21:37:04 +090037
38static struct map_desc sh7367_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 sh7367_map_io(void)
51{
52 iotable_init(sh7367_io_desc, ARRAY_SIZE(sh7367_io_desc));
53}
Magnus Dammc793c1b2010-02-05 11:14:49 +000054
Magnus Damm74905092010-05-20 14:35:30 +000055/* SCIFA0 */
Magnus Dammc793c1b2010-02-05 11:14:49 +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,
Paul Mundt31105722011-06-14 15:07:06 +090061 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000062 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
63 evt2irq(0xc00), evt2irq(0xc00) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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 Damm74905092010-05-20 14:35:30 +000074/* SCIFA1 */
Magnus Dammc793c1b2010-02-05 11:14:49 +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,
Paul Mundt31105722011-06-14 15:07:06 +090080 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +000081 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
82 evt2irq(0xc20), evt2irq(0xc20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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 Damm74905092010-05-20 14:35:30 +000093/* SCIFA2 */
Magnus Dammc793c1b2010-02-05 11:14:49 +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,
Paul Mundt31105722011-06-14 15:07:06 +090099 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000100 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
101 evt2irq(0xc40), evt2irq(0xc40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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 Damm74905092010-05-20 14:35:30 +0000112/* SCIFA3 */
Magnus Dammc793c1b2010-02-05 11:14:49 +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,
Paul Mundt31105722011-06-14 15:07:06 +0900118 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000119 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
120 evt2irq(0xc60), evt2irq(0xc60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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 Damm74905092010-05-20 14:35:30 +0000131/* SCIFA4 */
Magnus Dammc793c1b2010-02-05 11:14:49 +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,
Paul Mundt31105722011-06-14 15:07:06 +0900137 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000138 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
139 evt2irq(0xd20), evt2irq(0xd20) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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 Damm74905092010-05-20 14:35:30 +0000150/* SCIFA5 */
Magnus Dammc793c1b2010-02-05 11:14:49 +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,
Paul Mundt31105722011-06-14 15:07:06 +0900156 .type = PORT_SCIFA,
Magnus Damm74905092010-05-20 14:35:30 +0000157 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
158 evt2irq(0xd40), evt2irq(0xd40) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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 Damm74905092010-05-20 14:35:30 +0000169/* SCIFB */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000170static struct plat_sci_port scif6_platform_data = {
171 .mapbase = 0xe6c30000,
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,
Paul Mundt31105722011-06-14 15:07:06 +0900175 .type = PORT_SCIFB,
Magnus Damm74905092010-05-20 14:35:30 +0000176 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
177 evt2irq(0xd60), evt2irq(0xd60) },
Magnus Dammc793c1b2010-02-05 11:14:49 +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
188static struct sh_timer_config cmt10_platform_data = {
189 .name = "CMT10",
190 .channel_offset = 0x10,
191 .timer_bit = 0,
Magnus Dammc793c1b2010-02-05 11:14:49 +0000192 .clockevent_rating = 125,
193 .clocksource_rating = 125,
194};
195
196static struct resource cmt10_resources[] = {
197 [0] = {
198 .name = "CMT10",
199 .start = 0xe6138010,
200 .end = 0xe613801b,
201 .flags = IORESOURCE_MEM,
202 },
203 [1] = {
Magnus Damm74905092010-05-20 14:35:30 +0000204 .start = evt2irq(0xb00), /* CMT1_CMT10 */
Magnus Dammc793c1b2010-02-05 11:14:49 +0000205 .flags = IORESOURCE_IRQ,
206 },
207};
208
209static struct platform_device cmt10_device = {
210 .name = "sh_cmt",
211 .id = 10,
212 .dev = {
213 .platform_data = &cmt10_platform_data,
214 },
215 .resource = cmt10_resources,
216 .num_resources = ARRAY_SIZE(cmt10_resources),
217};
218
Magnus Dammde328352011-04-28 03:16:32 +0000219/* VPU */
220static struct uio_info vpu_platform_data = {
221 .name = "VPU5",
222 .version = "0",
223 .irq = intcs_evt2irq(0x980),
224};
225
226static struct resource vpu_resources[] = {
227 [0] = {
228 .name = "VPU",
229 .start = 0xfe900000,
230 .end = 0xfe902807,
231 .flags = IORESOURCE_MEM,
232 },
233};
234
235static struct platform_device vpu_device = {
236 .name = "uio_pdrv_genirq",
237 .id = 0,
238 .dev = {
239 .platform_data = &vpu_platform_data,
240 },
241 .resource = vpu_resources,
242 .num_resources = ARRAY_SIZE(vpu_resources),
243};
244
245/* VEU0 */
246static struct uio_info veu0_platform_data = {
247 .name = "VEU0",
248 .version = "0",
249 .irq = intcs_evt2irq(0x700),
250};
251
252static struct resource veu0_resources[] = {
253 [0] = {
254 .name = "VEU0",
255 .start = 0xfe920000,
256 .end = 0xfe9200b7,
257 .flags = IORESOURCE_MEM,
258 },
259};
260
261static struct platform_device veu0_device = {
262 .name = "uio_pdrv_genirq",
263 .id = 1,
264 .dev = {
265 .platform_data = &veu0_platform_data,
266 },
267 .resource = veu0_resources,
268 .num_resources = ARRAY_SIZE(veu0_resources),
269};
270
271/* VEU1 */
272static struct uio_info veu1_platform_data = {
273 .name = "VEU1",
274 .version = "0",
275 .irq = intcs_evt2irq(0x720),
276};
277
278static struct resource veu1_resources[] = {
279 [0] = {
280 .name = "VEU1",
281 .start = 0xfe924000,
282 .end = 0xfe9240b7,
283 .flags = IORESOURCE_MEM,
284 },
285};
286
287static struct platform_device veu1_device = {
288 .name = "uio_pdrv_genirq",
289 .id = 2,
290 .dev = {
291 .platform_data = &veu1_platform_data,
292 },
293 .resource = veu1_resources,
294 .num_resources = ARRAY_SIZE(veu1_resources),
295};
296
297/* VEU2 */
298static struct uio_info veu2_platform_data = {
299 .name = "VEU2",
300 .version = "0",
301 .irq = intcs_evt2irq(0x740),
302};
303
304static struct resource veu2_resources[] = {
305 [0] = {
306 .name = "VEU2",
307 .start = 0xfe928000,
308 .end = 0xfe9280b7,
309 .flags = IORESOURCE_MEM,
310 },
311};
312
313static struct platform_device veu2_device = {
314 .name = "uio_pdrv_genirq",
315 .id = 3,
316 .dev = {
317 .platform_data = &veu2_platform_data,
318 },
319 .resource = veu2_resources,
320 .num_resources = ARRAY_SIZE(veu2_resources),
321};
322
323/* VEU3 */
324static struct uio_info veu3_platform_data = {
325 .name = "VEU3",
326 .version = "0",
327 .irq = intcs_evt2irq(0x760),
328};
329
330static struct resource veu3_resources[] = {
331 [0] = {
332 .name = "VEU3",
333 .start = 0xfe92c000,
334 .end = 0xfe92c0b7,
335 .flags = IORESOURCE_MEM,
336 },
337};
338
339static struct platform_device veu3_device = {
340 .name = "uio_pdrv_genirq",
341 .id = 4,
342 .dev = {
343 .platform_data = &veu3_platform_data,
344 },
345 .resource = veu3_resources,
346 .num_resources = ARRAY_SIZE(veu3_resources),
347};
348
349/* VEU2H */
350static struct uio_info veu2h_platform_data = {
351 .name = "VEU2H",
352 .version = "0",
353 .irq = intcs_evt2irq(0x520),
354};
355
356static struct resource veu2h_resources[] = {
357 [0] = {
358 .name = "VEU2H",
359 .start = 0xfe93c000,
360 .end = 0xfe93c27b,
361 .flags = IORESOURCE_MEM,
362 },
363};
364
365static struct platform_device veu2h_device = {
366 .name = "uio_pdrv_genirq",
367 .id = 5,
368 .dev = {
369 .platform_data = &veu2h_platform_data,
370 },
371 .resource = veu2h_resources,
372 .num_resources = ARRAY_SIZE(veu2h_resources),
373};
374
375/* JPU */
376static struct uio_info jpu_platform_data = {
377 .name = "JPU",
378 .version = "0",
379 .irq = intcs_evt2irq(0x560),
380};
381
382static struct resource jpu_resources[] = {
383 [0] = {
384 .name = "JPU",
385 .start = 0xfe980000,
386 .end = 0xfe9902d3,
387 .flags = IORESOURCE_MEM,
388 },
389};
390
391static struct platform_device jpu_device = {
392 .name = "uio_pdrv_genirq",
393 .id = 6,
394 .dev = {
395 .platform_data = &jpu_platform_data,
396 },
397 .resource = jpu_resources,
398 .num_resources = ARRAY_SIZE(jpu_resources),
399};
400
401/* SPU1 */
402static struct uio_info spu1_platform_data = {
403 .name = "SPU1",
404 .version = "0",
405 .irq = evt2irq(0xfc0),
406};
407
408static struct resource spu1_resources[] = {
409 [0] = {
410 .name = "SPU1",
411 .start = 0xfe300000,
412 .end = 0xfe3fffff,
413 .flags = IORESOURCE_MEM,
414 },
415};
416
417static struct platform_device spu1_device = {
418 .name = "uio_pdrv_genirq",
419 .id = 7,
420 .dev = {
421 .platform_data = &spu1_platform_data,
422 },
423 .resource = spu1_resources,
424 .num_resources = ARRAY_SIZE(spu1_resources),
425};
426
Magnus Dammc793c1b2010-02-05 11:14:49 +0000427static struct platform_device *sh7367_early_devices[] __initdata = {
428 &scif0_device,
429 &scif1_device,
430 &scif2_device,
431 &scif3_device,
432 &scif4_device,
433 &scif5_device,
434 &scif6_device,
435 &cmt10_device,
436};
437
Magnus Dammde328352011-04-28 03:16:32 +0000438static struct platform_device *sh7367_devices[] __initdata = {
439 &vpu_device,
440 &veu0_device,
441 &veu1_device,
442 &veu2_device,
443 &veu3_device,
444 &veu2h_device,
445 &jpu_device,
446 &spu1_device,
447};
448
Magnus Dammc793c1b2010-02-05 11:14:49 +0000449void __init sh7367_add_standard_devices(void)
450{
451 platform_add_devices(sh7367_early_devices,
452 ARRAY_SIZE(sh7367_early_devices));
Magnus Dammde328352011-04-28 03:16:32 +0000453
454 platform_add_devices(sh7367_devices,
455 ARRAY_SIZE(sh7367_devices));
Magnus Dammc793c1b2010-02-05 11:14:49 +0000456}
457
Magnus Damm9e8de442012-03-06 17:36:22 +0900458static void __init sh7367_earlytimer_init(void)
459{
460 sh7367_clock_init();
461 shmobile_earlytimer_init();
462}
463
Magnus Dammc793c1b2010-02-05 11:14:49 +0000464#define SYMSTPCR2 0xe6158048
465#define SYMSTPCR2_CMT1 (1 << 29)
466
467void __init sh7367_add_early_devices(void)
468{
469 /* enable clock to CMT1 */
470 __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2);
471
472 early_platform_add_devices(sh7367_early_devices,
473 ARRAY_SIZE(sh7367_early_devices));
Magnus Damm237caf92012-02-29 21:37:04 +0900474
475 /* setup early console here as well */
476 shmobile_setup_console();
Magnus Damm9e8de442012-03-06 17:36:22 +0900477
478 /* override timer setup with soc-specific code */
479 shmobile_timer.init = sh7367_earlytimer_init;
Magnus Dammc793c1b2010-02-05 11:14:49 +0000480}