2 * sh73a0 processor support
4 * Copyright (C) 2010 Takashi Yoshii
5 * Copyright (C) 2010 Magnus Damm
6 * Copyright (C) 2008 Yoshihiro Shimoda
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/irq.h>
25 #include <linux/irqchip.h>
26 #include <linux/platform_device.h>
27 #include <linux/of_platform.h>
28 #include <linux/delay.h>
29 #include <linux/input.h>
31 #include <linux/serial_sci.h>
32 #include <linux/sh_dma.h>
33 #include <linux/sh_intc.h>
34 #include <linux/sh_timer.h>
35 #include <linux/platform_data/sh_ipmmu.h>
36 #include <mach/dma-register.h>
37 #include <mach/hardware.h>
38 #include <mach/irqs.h>
39 #include <mach/sh73a0.h>
40 #include <mach/common.h>
41 #include <asm/mach-types.h>
42 #include <asm/mach/map.h>
43 #include <asm/mach/arch.h>
44 #include <asm/mach/time.h>
46 static struct map_desc sh73a0_io_desc[] __initdata = {
47 /* create a 1:1 entity map for 0xe6xxxxxx
48 * used by CPGA, INTC and PFC.
51 .virtual = 0xe6000000,
52 .pfn = __phys_to_pfn(0xe6000000),
54 .type = MT_DEVICE_NONSHARED
58 void __init sh73a0_map_io(void)
60 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
63 static struct resource sh73a0_pfc_resources[] = {
67 .flags = IORESOURCE_MEM,
72 .flags = IORESOURCE_MEM,
76 static struct platform_device sh73a0_pfc_device = {
79 .resource = sh73a0_pfc_resources,
80 .num_resources = ARRAY_SIZE(sh73a0_pfc_resources),
83 void __init sh73a0_pinmux_init(void)
85 platform_device_register(&sh73a0_pfc_device);
88 static struct plat_sci_port scif0_platform_data = {
89 .mapbase = 0xe6c40000,
90 .flags = UPF_BOOT_AUTOCONF,
91 .scscr = SCSCR_RE | SCSCR_TE,
92 .scbrr_algo_id = SCBRR_ALGO_4,
94 .irqs = { gic_spi(72), gic_spi(72),
95 gic_spi(72), gic_spi(72) },
98 static struct platform_device scif0_device = {
102 .platform_data = &scif0_platform_data,
106 static struct plat_sci_port scif1_platform_data = {
107 .mapbase = 0xe6c50000,
108 .flags = UPF_BOOT_AUTOCONF,
109 .scscr = SCSCR_RE | SCSCR_TE,
110 .scbrr_algo_id = SCBRR_ALGO_4,
112 .irqs = { gic_spi(73), gic_spi(73),
113 gic_spi(73), gic_spi(73) },
116 static struct platform_device scif1_device = {
120 .platform_data = &scif1_platform_data,
124 static struct plat_sci_port scif2_platform_data = {
125 .mapbase = 0xe6c60000,
126 .flags = UPF_BOOT_AUTOCONF,
127 .scscr = SCSCR_RE | SCSCR_TE,
128 .scbrr_algo_id = SCBRR_ALGO_4,
130 .irqs = { gic_spi(74), gic_spi(74),
131 gic_spi(74), gic_spi(74) },
134 static struct platform_device scif2_device = {
138 .platform_data = &scif2_platform_data,
142 static struct plat_sci_port scif3_platform_data = {
143 .mapbase = 0xe6c70000,
144 .flags = UPF_BOOT_AUTOCONF,
145 .scscr = SCSCR_RE | SCSCR_TE,
146 .scbrr_algo_id = SCBRR_ALGO_4,
148 .irqs = { gic_spi(75), gic_spi(75),
149 gic_spi(75), gic_spi(75) },
152 static struct platform_device scif3_device = {
156 .platform_data = &scif3_platform_data,
160 static struct plat_sci_port scif4_platform_data = {
161 .mapbase = 0xe6c80000,
162 .flags = UPF_BOOT_AUTOCONF,
163 .scscr = SCSCR_RE | SCSCR_TE,
164 .scbrr_algo_id = SCBRR_ALGO_4,
166 .irqs = { gic_spi(78), gic_spi(78),
167 gic_spi(78), gic_spi(78) },
170 static struct platform_device scif4_device = {
174 .platform_data = &scif4_platform_data,
178 static struct plat_sci_port scif5_platform_data = {
179 .mapbase = 0xe6cb0000,
180 .flags = UPF_BOOT_AUTOCONF,
181 .scscr = SCSCR_RE | SCSCR_TE,
182 .scbrr_algo_id = SCBRR_ALGO_4,
184 .irqs = { gic_spi(79), gic_spi(79),
185 gic_spi(79), gic_spi(79) },
188 static struct platform_device scif5_device = {
192 .platform_data = &scif5_platform_data,
196 static struct plat_sci_port scif6_platform_data = {
197 .mapbase = 0xe6cc0000,
198 .flags = UPF_BOOT_AUTOCONF,
199 .scscr = SCSCR_RE | SCSCR_TE,
200 .scbrr_algo_id = SCBRR_ALGO_4,
202 .irqs = { gic_spi(156), gic_spi(156),
203 gic_spi(156), gic_spi(156) },
206 static struct platform_device scif6_device = {
210 .platform_data = &scif6_platform_data,
214 static struct plat_sci_port scif7_platform_data = {
215 .mapbase = 0xe6cd0000,
216 .flags = UPF_BOOT_AUTOCONF,
217 .scscr = SCSCR_RE | SCSCR_TE,
218 .scbrr_algo_id = SCBRR_ALGO_4,
220 .irqs = { gic_spi(143), gic_spi(143),
221 gic_spi(143), gic_spi(143) },
224 static struct platform_device scif7_device = {
228 .platform_data = &scif7_platform_data,
232 static struct plat_sci_port scif8_platform_data = {
233 .mapbase = 0xe6c30000,
234 .flags = UPF_BOOT_AUTOCONF,
235 .scscr = SCSCR_RE | SCSCR_TE,
236 .scbrr_algo_id = SCBRR_ALGO_4,
238 .irqs = { gic_spi(80), gic_spi(80),
239 gic_spi(80), gic_spi(80) },
242 static struct platform_device scif8_device = {
246 .platform_data = &scif8_platform_data,
250 static struct sh_timer_config cmt10_platform_data = {
252 .channel_offset = 0x10,
254 .clockevent_rating = 125,
255 .clocksource_rating = 125,
258 static struct resource cmt10_resources[] = {
263 .flags = IORESOURCE_MEM,
266 .start = gic_spi(65),
267 .flags = IORESOURCE_IRQ,
271 static struct platform_device cmt10_device = {
275 .platform_data = &cmt10_platform_data,
277 .resource = cmt10_resources,
278 .num_resources = ARRAY_SIZE(cmt10_resources),
282 static struct sh_timer_config tmu00_platform_data = {
284 .channel_offset = 0x4,
286 .clockevent_rating = 200,
289 static struct resource tmu00_resources[] = {
294 .flags = IORESOURCE_MEM,
297 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
298 .flags = IORESOURCE_IRQ,
302 static struct platform_device tmu00_device = {
306 .platform_data = &tmu00_platform_data,
308 .resource = tmu00_resources,
309 .num_resources = ARRAY_SIZE(tmu00_resources),
312 static struct sh_timer_config tmu01_platform_data = {
314 .channel_offset = 0x10,
316 .clocksource_rating = 200,
319 static struct resource tmu01_resources[] = {
324 .flags = IORESOURCE_MEM,
327 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
328 .flags = IORESOURCE_IRQ,
332 static struct platform_device tmu01_device = {
336 .platform_data = &tmu01_platform_data,
338 .resource = tmu01_resources,
339 .num_resources = ARRAY_SIZE(tmu01_resources),
342 static struct resource i2c0_resources[] = {
346 .end = 0xe6820425 - 1,
347 .flags = IORESOURCE_MEM,
350 .start = gic_spi(167),
352 .flags = IORESOURCE_IRQ,
356 static struct resource i2c1_resources[] = {
360 .end = 0xe6822425 - 1,
361 .flags = IORESOURCE_MEM,
364 .start = gic_spi(51),
366 .flags = IORESOURCE_IRQ,
370 static struct resource i2c2_resources[] = {
374 .end = 0xe6824425 - 1,
375 .flags = IORESOURCE_MEM,
378 .start = gic_spi(171),
380 .flags = IORESOURCE_IRQ,
384 static struct resource i2c3_resources[] = {
388 .end = 0xe6826425 - 1,
389 .flags = IORESOURCE_MEM,
392 .start = gic_spi(183),
394 .flags = IORESOURCE_IRQ,
398 static struct resource i2c4_resources[] = {
402 .end = 0xe6828425 - 1,
403 .flags = IORESOURCE_MEM,
406 .start = gic_spi(187),
408 .flags = IORESOURCE_IRQ,
412 static struct platform_device i2c0_device = {
413 .name = "i2c-sh_mobile",
415 .resource = i2c0_resources,
416 .num_resources = ARRAY_SIZE(i2c0_resources),
419 static struct platform_device i2c1_device = {
420 .name = "i2c-sh_mobile",
422 .resource = i2c1_resources,
423 .num_resources = ARRAY_SIZE(i2c1_resources),
426 static struct platform_device i2c2_device = {
427 .name = "i2c-sh_mobile",
429 .resource = i2c2_resources,
430 .num_resources = ARRAY_SIZE(i2c2_resources),
433 static struct platform_device i2c3_device = {
434 .name = "i2c-sh_mobile",
436 .resource = i2c3_resources,
437 .num_resources = ARRAY_SIZE(i2c3_resources),
440 static struct platform_device i2c4_device = {
441 .name = "i2c-sh_mobile",
443 .resource = i2c4_resources,
444 .num_resources = ARRAY_SIZE(i2c4_resources),
447 static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
449 .slave_id = SHDMA_SLAVE_SCIF0_TX,
451 .chcr = CHCR_TX(XMIT_SZ_8BIT),
454 .slave_id = SHDMA_SLAVE_SCIF0_RX,
456 .chcr = CHCR_RX(XMIT_SZ_8BIT),
459 .slave_id = SHDMA_SLAVE_SCIF1_TX,
461 .chcr = CHCR_TX(XMIT_SZ_8BIT),
464 .slave_id = SHDMA_SLAVE_SCIF1_RX,
466 .chcr = CHCR_RX(XMIT_SZ_8BIT),
469 .slave_id = SHDMA_SLAVE_SCIF2_TX,
471 .chcr = CHCR_TX(XMIT_SZ_8BIT),
474 .slave_id = SHDMA_SLAVE_SCIF2_RX,
476 .chcr = CHCR_RX(XMIT_SZ_8BIT),
479 .slave_id = SHDMA_SLAVE_SCIF3_TX,
481 .chcr = CHCR_TX(XMIT_SZ_8BIT),
484 .slave_id = SHDMA_SLAVE_SCIF3_RX,
486 .chcr = CHCR_RX(XMIT_SZ_8BIT),
489 .slave_id = SHDMA_SLAVE_SCIF4_TX,
491 .chcr = CHCR_TX(XMIT_SZ_8BIT),
494 .slave_id = SHDMA_SLAVE_SCIF4_RX,
496 .chcr = CHCR_RX(XMIT_SZ_8BIT),
499 .slave_id = SHDMA_SLAVE_SCIF5_TX,
501 .chcr = CHCR_TX(XMIT_SZ_8BIT),
504 .slave_id = SHDMA_SLAVE_SCIF5_RX,
506 .chcr = CHCR_RX(XMIT_SZ_8BIT),
509 .slave_id = SHDMA_SLAVE_SCIF6_TX,
511 .chcr = CHCR_TX(XMIT_SZ_8BIT),
514 .slave_id = SHDMA_SLAVE_SCIF6_RX,
516 .chcr = CHCR_RX(XMIT_SZ_8BIT),
519 .slave_id = SHDMA_SLAVE_SCIF7_TX,
521 .chcr = CHCR_TX(XMIT_SZ_8BIT),
524 .slave_id = SHDMA_SLAVE_SCIF7_RX,
526 .chcr = CHCR_RX(XMIT_SZ_8BIT),
529 .slave_id = SHDMA_SLAVE_SCIF8_TX,
531 .chcr = CHCR_TX(XMIT_SZ_8BIT),
534 .slave_id = SHDMA_SLAVE_SCIF8_RX,
536 .chcr = CHCR_RX(XMIT_SZ_8BIT),
539 .slave_id = SHDMA_SLAVE_SDHI0_TX,
541 .chcr = CHCR_TX(XMIT_SZ_16BIT),
544 .slave_id = SHDMA_SLAVE_SDHI0_RX,
546 .chcr = CHCR_RX(XMIT_SZ_16BIT),
549 .slave_id = SHDMA_SLAVE_SDHI1_TX,
551 .chcr = CHCR_TX(XMIT_SZ_16BIT),
554 .slave_id = SHDMA_SLAVE_SDHI1_RX,
556 .chcr = CHCR_RX(XMIT_SZ_16BIT),
559 .slave_id = SHDMA_SLAVE_SDHI2_TX,
561 .chcr = CHCR_TX(XMIT_SZ_16BIT),
564 .slave_id = SHDMA_SLAVE_SDHI2_RX,
566 .chcr = CHCR_RX(XMIT_SZ_16BIT),
569 .slave_id = SHDMA_SLAVE_MMCIF_TX,
571 .chcr = CHCR_TX(XMIT_SZ_32BIT),
574 .slave_id = SHDMA_SLAVE_MMCIF_RX,
576 .chcr = CHCR_RX(XMIT_SZ_32BIT),
581 #define DMAE_CHANNEL(_offset) \
583 .offset = _offset - 0x20, \
584 .dmars = _offset - 0x20 + 0x40, \
587 static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
588 DMAE_CHANNEL(0x8000),
589 DMAE_CHANNEL(0x8080),
590 DMAE_CHANNEL(0x8100),
591 DMAE_CHANNEL(0x8180),
592 DMAE_CHANNEL(0x8200),
593 DMAE_CHANNEL(0x8280),
594 DMAE_CHANNEL(0x8300),
595 DMAE_CHANNEL(0x8380),
596 DMAE_CHANNEL(0x8400),
597 DMAE_CHANNEL(0x8480),
598 DMAE_CHANNEL(0x8500),
599 DMAE_CHANNEL(0x8580),
600 DMAE_CHANNEL(0x8600),
601 DMAE_CHANNEL(0x8680),
602 DMAE_CHANNEL(0x8700),
603 DMAE_CHANNEL(0x8780),
604 DMAE_CHANNEL(0x8800),
605 DMAE_CHANNEL(0x8880),
606 DMAE_CHANNEL(0x8900),
607 DMAE_CHANNEL(0x8980),
610 static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
611 .slave = sh73a0_dmae_slaves,
612 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
613 .channel = sh73a0_dmae_channels,
614 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
615 .ts_low_shift = TS_LOW_SHIFT,
616 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
617 .ts_high_shift = TS_HI_SHIFT,
618 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
619 .ts_shift = dma_ts_shift,
620 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
621 .dmaor_init = DMAOR_DME,
624 static struct resource sh73a0_dmae_resources[] = {
626 /* Registers including DMAOR and channels including DMARSx */
628 .end = 0xfe008a00 - 1,
629 .flags = IORESOURCE_MEM,
633 .start = gic_spi(129),
635 .flags = IORESOURCE_IRQ,
638 /* IRQ for channels 0-19 */
639 .start = gic_spi(109),
641 .flags = IORESOURCE_IRQ,
645 static struct platform_device dma0_device = {
646 .name = "sh-dma-engine",
648 .resource = sh73a0_dmae_resources,
649 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
651 .platform_data = &sh73a0_dmae_platform_data,
656 static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
658 .slave_id = SHDMA_SLAVE_FSI2A_RX,
660 .chcr = CHCR_RX(XMIT_SZ_32BIT),
661 .mid_rid = 0xd6, /* CHECK ME */
663 .slave_id = SHDMA_SLAVE_FSI2A_TX,
665 .chcr = CHCR_TX(XMIT_SZ_32BIT),
666 .mid_rid = 0xd5, /* CHECK ME */
668 .slave_id = SHDMA_SLAVE_FSI2C_RX,
670 .chcr = CHCR_RX(XMIT_SZ_32BIT),
671 .mid_rid = 0xda, /* CHECK ME */
673 .slave_id = SHDMA_SLAVE_FSI2C_TX,
675 .chcr = CHCR_TX(XMIT_SZ_32BIT),
676 .mid_rid = 0xd9, /* CHECK ME */
678 .slave_id = SHDMA_SLAVE_FSI2B_RX,
680 .chcr = CHCR_RX(XMIT_SZ_32BIT),
681 .mid_rid = 0x8e, /* CHECK ME */
683 .slave_id = SHDMA_SLAVE_FSI2B_TX,
685 .chcr = CHCR_RX(XMIT_SZ_32BIT),
686 .mid_rid = 0x8d, /* CHECK ME */
688 .slave_id = SHDMA_SLAVE_FSI2D_RX,
690 .chcr = CHCR_RX(XMIT_SZ_32BIT),
691 .mid_rid = 0x9a, /* CHECK ME */
695 #define MPDMA_CHANNEL(a, b, c) \
700 .chclr_offset = (0x220 - 0x20) + a \
703 static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
704 MPDMA_CHANNEL(0x00, 0, 0),
705 MPDMA_CHANNEL(0x10, 0, 8),
706 MPDMA_CHANNEL(0x20, 4, 0),
707 MPDMA_CHANNEL(0x30, 4, 8),
708 MPDMA_CHANNEL(0x50, 8, 0),
709 MPDMA_CHANNEL(0x70, 8, 8),
712 static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
713 .slave = sh73a0_mpdma_slaves,
714 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
715 .channel = sh73a0_mpdma_channels,
716 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
717 .ts_low_shift = TS_LOW_SHIFT,
718 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
719 .ts_high_shift = TS_HI_SHIFT,
720 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
721 .ts_shift = dma_ts_shift,
722 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
723 .dmaor_init = DMAOR_DME,
727 /* Resource order important! */
728 static struct resource sh73a0_mpdma_resources[] = {
730 /* Channel registers and DMAOR */
733 .flags = IORESOURCE_MEM,
739 .flags = IORESOURCE_MEM,
743 .start = gic_spi(181),
745 .flags = IORESOURCE_IRQ,
748 /* IRQ for channels 0-5 */
749 .start = gic_spi(175),
751 .flags = IORESOURCE_IRQ,
755 static struct platform_device mpdma0_device = {
756 .name = "sh-dma-engine",
758 .resource = sh73a0_mpdma_resources,
759 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
761 .platform_data = &sh73a0_mpdma_platform_data,
765 static struct resource pmu_resources[] = {
767 .start = gic_spi(55),
769 .flags = IORESOURCE_IRQ,
772 .start = gic_spi(56),
774 .flags = IORESOURCE_IRQ,
778 static struct platform_device pmu_device = {
781 .num_resources = ARRAY_SIZE(pmu_resources),
782 .resource = pmu_resources,
785 /* an IPMMU module for ICB */
786 static struct resource ipmmu_resources[] = {
791 .flags = IORESOURCE_MEM,
795 static const char * const ipmmu_dev_names[] = {
796 "sh_mobile_lcdc_fb.0",
799 static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
800 .dev_names = ipmmu_dev_names,
801 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
804 static struct platform_device ipmmu_device = {
808 .platform_data = &ipmmu_platform_data,
810 .resource = ipmmu_resources,
811 .num_resources = ARRAY_SIZE(ipmmu_resources),
814 static struct platform_device *sh73a0_devices_dt[] __initdata = {
827 static struct platform_device *sh73a0_early_devices[] __initdata = {
833 static struct platform_device *sh73a0_late_devices[] __initdata = {
844 #define SRCR2 IOMEM(0xe61580b0)
846 void __init sh73a0_add_standard_devices(void)
848 /* Clear software reset bit on SY-DMAC module */
849 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
851 platform_add_devices(sh73a0_devices_dt,
852 ARRAY_SIZE(sh73a0_devices_dt));
853 platform_add_devices(sh73a0_early_devices,
854 ARRAY_SIZE(sh73a0_early_devices));
855 platform_add_devices(sh73a0_late_devices,
856 ARRAY_SIZE(sh73a0_late_devices));
859 /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
860 void __init __weak sh73a0_register_twd(void) { }
862 void __init sh73a0_earlytimer_init(void)
865 shmobile_earlytimer_init();
866 sh73a0_register_twd();
869 void __init sh73a0_add_early_devices(void)
871 early_platform_add_devices(sh73a0_devices_dt,
872 ARRAY_SIZE(sh73a0_devices_dt));
873 early_platform_add_devices(sh73a0_early_devices,
874 ARRAY_SIZE(sh73a0_early_devices));
876 /* setup early console here as well */
877 shmobile_setup_console();
882 void __init sh73a0_init_delay(void)
884 shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
887 static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
891 void __init sh73a0_add_standard_devices_dt(void)
893 /* clocks are setup late during boot in the case of DT */
896 platform_add_devices(sh73a0_devices_dt,
897 ARRAY_SIZE(sh73a0_devices_dt));
898 of_platform_populate(NULL, of_default_bus_match_table,
899 sh73a0_auxdata_lookup, NULL);
902 static const char *sh73a0_boards_compat_dt[] __initdata = {
907 DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
908 .smp = smp_ops(sh73a0_smp_ops),
909 .map_io = sh73a0_map_io,
910 .init_early = sh73a0_init_delay,
911 .nr_irqs = NR_IRQS_LEGACY,
912 .init_irq = irqchip_init,
913 .init_machine = sh73a0_add_standard_devices_dt,
914 .init_time = shmobile_timer_init,
915 .dt_compat = sh73a0_boards_compat_dt,
917 #endif /* CONFIG_USE_OF */