2 * sh7377 processor support
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
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.
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.
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
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>
25 #include <linux/of_platform.h>
26 #include <linux/uio_driver.h>
27 #include <linux/delay.h>
28 #include <linux/input.h>
30 #include <linux/serial_sci.h>
31 #include <linux/sh_intc.h>
32 #include <linux/sh_timer.h>
33 #include <mach/hardware.h>
34 #include <mach/common.h>
35 #include <asm/mach/map.h>
36 #include <mach/irqs.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/time.h>
41 static struct map_desc sh7377_io_desc
[] __initdata
= {
42 /* create a 1:1 entity map for 0xe6xxxxxx
43 * used by CPGA, INTC and PFC.
46 .virtual = 0xe6000000,
47 .pfn
= __phys_to_pfn(0xe6000000),
49 .type
= MT_DEVICE_NONSHARED
53 void __init
sh7377_map_io(void)
55 iotable_init(sh7377_io_desc
, ARRAY_SIZE(sh7377_io_desc
));
59 static struct plat_sci_port scif0_platform_data
= {
60 .mapbase
= 0xe6c40000,
61 .flags
= UPF_BOOT_AUTOCONF
,
62 .scscr
= SCSCR_RE
| SCSCR_TE
,
63 .scbrr_algo_id
= SCBRR_ALGO_4
,
65 .irqs
= { evt2irq(0xc00), evt2irq(0xc00),
66 evt2irq(0xc00), evt2irq(0xc00) },
69 static struct platform_device scif0_device
= {
73 .platform_data
= &scif0_platform_data
,
78 static struct plat_sci_port scif1_platform_data
= {
79 .mapbase
= 0xe6c50000,
80 .flags
= UPF_BOOT_AUTOCONF
,
81 .scscr
= SCSCR_RE
| SCSCR_TE
,
82 .scbrr_algo_id
= SCBRR_ALGO_4
,
84 .irqs
= { evt2irq(0xc20), evt2irq(0xc20),
85 evt2irq(0xc20), evt2irq(0xc20) },
88 static struct platform_device scif1_device
= {
92 .platform_data
= &scif1_platform_data
,
97 static struct plat_sci_port scif2_platform_data
= {
98 .mapbase
= 0xe6c60000,
99 .flags
= UPF_BOOT_AUTOCONF
,
100 .scscr
= SCSCR_RE
| SCSCR_TE
,
101 .scbrr_algo_id
= SCBRR_ALGO_4
,
103 .irqs
= { evt2irq(0xc40), evt2irq(0xc40),
104 evt2irq(0xc40), evt2irq(0xc40) },
107 static struct platform_device scif2_device
= {
111 .platform_data
= &scif2_platform_data
,
116 static struct plat_sci_port scif3_platform_data
= {
117 .mapbase
= 0xe6c70000,
118 .flags
= UPF_BOOT_AUTOCONF
,
119 .scscr
= SCSCR_RE
| SCSCR_TE
,
120 .scbrr_algo_id
= SCBRR_ALGO_4
,
122 .irqs
= { evt2irq(0xc60), evt2irq(0xc60),
123 evt2irq(0xc60), evt2irq(0xc60) },
126 static struct platform_device scif3_device
= {
130 .platform_data
= &scif3_platform_data
,
135 static struct plat_sci_port scif4_platform_data
= {
136 .mapbase
= 0xe6c80000,
137 .flags
= UPF_BOOT_AUTOCONF
,
138 .scscr
= SCSCR_RE
| SCSCR_TE
,
139 .scbrr_algo_id
= SCBRR_ALGO_4
,
141 .irqs
= { evt2irq(0xd20), evt2irq(0xd20),
142 evt2irq(0xd20), evt2irq(0xd20) },
145 static struct platform_device scif4_device
= {
149 .platform_data
= &scif4_platform_data
,
154 static struct plat_sci_port scif5_platform_data
= {
155 .mapbase
= 0xe6cb0000,
156 .flags
= UPF_BOOT_AUTOCONF
,
157 .scscr
= SCSCR_RE
| SCSCR_TE
,
158 .scbrr_algo_id
= SCBRR_ALGO_4
,
160 .irqs
= { evt2irq(0xd40), evt2irq(0xd40),
161 evt2irq(0xd40), evt2irq(0xd40) },
164 static struct platform_device scif5_device
= {
168 .platform_data
= &scif5_platform_data
,
173 static struct plat_sci_port scif6_platform_data
= {
174 .mapbase
= 0xe6cc0000,
175 .flags
= UPF_BOOT_AUTOCONF
,
176 .scscr
= SCSCR_RE
| SCSCR_TE
,
177 .scbrr_algo_id
= SCBRR_ALGO_4
,
179 .irqs
= { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
180 intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
183 static struct platform_device scif6_device
= {
187 .platform_data
= &scif6_platform_data
,
192 static struct plat_sci_port scif7_platform_data
= {
193 .mapbase
= 0xe6c30000,
194 .flags
= UPF_BOOT_AUTOCONF
,
195 .scscr
= SCSCR_RE
| SCSCR_TE
,
196 .scbrr_algo_id
= SCBRR_ALGO_4
,
198 .irqs
= { evt2irq(0xd60), evt2irq(0xd60),
199 evt2irq(0xd60), evt2irq(0xd60) },
202 static struct platform_device scif7_device
= {
206 .platform_data
= &scif7_platform_data
,
210 static struct sh_timer_config cmt10_platform_data
= {
212 .channel_offset
= 0x10,
214 .clockevent_rating
= 125,
215 .clocksource_rating
= 125,
218 static struct resource cmt10_resources
[] = {
223 .flags
= IORESOURCE_MEM
,
226 .start
= evt2irq(0xb00), /* CMT1_CMT10 */
227 .flags
= IORESOURCE_IRQ
,
231 static struct platform_device cmt10_device
= {
235 .platform_data
= &cmt10_platform_data
,
237 .resource
= cmt10_resources
,
238 .num_resources
= ARRAY_SIZE(cmt10_resources
),
242 static struct uio_info vpu_platform_data
= {
245 .irq
= intcs_evt2irq(0x980),
248 static struct resource vpu_resources
[] = {
253 .flags
= IORESOURCE_MEM
,
257 static struct platform_device vpu_device
= {
258 .name
= "uio_pdrv_genirq",
261 .platform_data
= &vpu_platform_data
,
263 .resource
= vpu_resources
,
264 .num_resources
= ARRAY_SIZE(vpu_resources
),
268 static struct uio_info veu0_platform_data
= {
271 .irq
= intcs_evt2irq(0x700),
274 static struct resource veu0_resources
[] = {
279 .flags
= IORESOURCE_MEM
,
283 static struct platform_device veu0_device
= {
284 .name
= "uio_pdrv_genirq",
287 .platform_data
= &veu0_platform_data
,
289 .resource
= veu0_resources
,
290 .num_resources
= ARRAY_SIZE(veu0_resources
),
294 static struct uio_info veu1_platform_data
= {
297 .irq
= intcs_evt2irq(0x720),
300 static struct resource veu1_resources
[] = {
305 .flags
= IORESOURCE_MEM
,
309 static struct platform_device veu1_device
= {
310 .name
= "uio_pdrv_genirq",
313 .platform_data
= &veu1_platform_data
,
315 .resource
= veu1_resources
,
316 .num_resources
= ARRAY_SIZE(veu1_resources
),
320 static struct uio_info veu2_platform_data
= {
323 .irq
= intcs_evt2irq(0x740),
326 static struct resource veu2_resources
[] = {
331 .flags
= IORESOURCE_MEM
,
335 static struct platform_device veu2_device
= {
336 .name
= "uio_pdrv_genirq",
339 .platform_data
= &veu2_platform_data
,
341 .resource
= veu2_resources
,
342 .num_resources
= ARRAY_SIZE(veu2_resources
),
346 static struct uio_info veu3_platform_data
= {
349 .irq
= intcs_evt2irq(0x760),
352 static struct resource veu3_resources
[] = {
357 .flags
= IORESOURCE_MEM
,
361 static struct platform_device veu3_device
= {
362 .name
= "uio_pdrv_genirq",
365 .platform_data
= &veu3_platform_data
,
367 .resource
= veu3_resources
,
368 .num_resources
= ARRAY_SIZE(veu3_resources
),
372 static struct uio_info jpu_platform_data
= {
375 .irq
= intcs_evt2irq(0x560),
378 static struct resource jpu_resources
[] = {
383 .flags
= IORESOURCE_MEM
,
387 static struct platform_device jpu_device
= {
388 .name
= "uio_pdrv_genirq",
391 .platform_data
= &jpu_platform_data
,
393 .resource
= jpu_resources
,
394 .num_resources
= ARRAY_SIZE(jpu_resources
),
398 static struct uio_info spu0_platform_data
= {
401 .irq
= evt2irq(0x1800),
404 static struct resource spu0_resources
[] = {
409 .flags
= IORESOURCE_MEM
,
413 static struct platform_device spu0_device
= {
414 .name
= "uio_pdrv_genirq",
417 .platform_data
= &spu0_platform_data
,
419 .resource
= spu0_resources
,
420 .num_resources
= ARRAY_SIZE(spu0_resources
),
424 static struct uio_info spu1_platform_data
= {
427 .irq
= evt2irq(0x1820),
430 static struct resource spu1_resources
[] = {
435 .flags
= IORESOURCE_MEM
,
439 static struct platform_device spu1_device
= {
440 .name
= "uio_pdrv_genirq",
443 .platform_data
= &spu1_platform_data
,
445 .resource
= spu1_resources
,
446 .num_resources
= ARRAY_SIZE(spu1_resources
),
449 static struct platform_device
*sh7377_early_devices
[] __initdata
= {
461 static struct platform_device
*sh7377_devices
[] __initdata
= {
472 void __init
sh7377_add_standard_devices(void)
474 platform_add_devices(sh7377_early_devices
,
475 ARRAY_SIZE(sh7377_early_devices
));
477 platform_add_devices(sh7377_devices
,
478 ARRAY_SIZE(sh7377_devices
));
481 static void __init
sh7377_earlytimer_init(void)
484 shmobile_earlytimer_init();
487 #define SMSTPCR3 0xe615013c
488 #define SMSTPCR3_CMT1 (1 << 29)
490 void __init
sh7377_add_early_devices(void)
492 /* enable clock to CMT1 */
493 __raw_writel(__raw_readl(SMSTPCR3
) & ~SMSTPCR3_CMT1
, SMSTPCR3
);
495 early_platform_add_devices(sh7377_early_devices
,
496 ARRAY_SIZE(sh7377_early_devices
));
498 /* setup early console here as well */
499 shmobile_setup_console();
501 /* override timer setup with soc-specific code */
502 shmobile_timer
.init
= sh7377_earlytimer_init
;
507 void __init
sh7377_add_early_devices_dt(void)
509 shmobile_setup_delay(600, 1, 3); /* Cortex-A8 @ 600MHz */
511 early_platform_add_devices(sh7377_early_devices
,
512 ARRAY_SIZE(sh7377_early_devices
));
514 /* setup early console here as well */
515 shmobile_setup_console();
518 static const struct of_dev_auxdata sh7377_auxdata_lookup
[] __initconst
= {
522 void __init
sh7377_add_standard_devices_dt(void)
524 /* clocks are setup late during boot in the case of DT */
527 platform_add_devices(sh7377_early_devices
,
528 ARRAY_SIZE(sh7377_early_devices
));
530 of_platform_populate(NULL
, of_default_bus_match_table
,
531 sh7377_auxdata_lookup
, NULL
);
534 static const char *sh7377_boards_compat_dt
[] __initdata
= {
539 DT_MACHINE_START(SH7377_DT
, "Generic SH7377 (Flattened Device Tree)")
540 .map_io
= sh7377_map_io
,
541 .init_early
= sh7377_add_early_devices_dt
,
542 .init_irq
= sh7377_init_irq
,
543 .handle_irq
= shmobile_handle_irq_intc
,
544 .init_machine
= sh7377_add_standard_devices_dt
,
545 .timer
= &shmobile_timer
,
546 .dt_compat
= sh7377_boards_compat_dt
,
549 #endif /* CONFIG_USE_OF */