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/platform_device.h>
26 #include <linux/delay.h>
27 #include <linux/input.h>
29 #include <linux/serial_sci.h>
30 #include <linux/sh_dma.h>
31 #include <linux/sh_intc.h>
32 #include <linux/sh_timer.h>
33 #include <mach/hardware.h>
34 #include <mach/sh73a0.h>
35 #include <mach/common.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/map.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/time.h>
41 static struct map_desc sh73a0_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 sh73a0_map_io(void)
55 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
58 static struct plat_sci_port scif0_platform_data = {
59 .mapbase = 0xe6c40000,
60 .flags = UPF_BOOT_AUTOCONF,
61 .scscr = SCSCR_RE | SCSCR_TE,
62 .scbrr_algo_id = SCBRR_ALGO_4,
64 .irqs = { gic_spi(72), gic_spi(72),
65 gic_spi(72), gic_spi(72) },
68 static struct platform_device scif0_device = {
72 .platform_data = &scif0_platform_data,
76 static struct plat_sci_port scif1_platform_data = {
77 .mapbase = 0xe6c50000,
78 .flags = UPF_BOOT_AUTOCONF,
79 .scscr = SCSCR_RE | SCSCR_TE,
80 .scbrr_algo_id = SCBRR_ALGO_4,
82 .irqs = { gic_spi(73), gic_spi(73),
83 gic_spi(73), gic_spi(73) },
86 static struct platform_device scif1_device = {
90 .platform_data = &scif1_platform_data,
94 static struct plat_sci_port scif2_platform_data = {
95 .mapbase = 0xe6c60000,
96 .flags = UPF_BOOT_AUTOCONF,
97 .scscr = SCSCR_RE | SCSCR_TE,
98 .scbrr_algo_id = SCBRR_ALGO_4,
100 .irqs = { gic_spi(74), gic_spi(74),
101 gic_spi(74), gic_spi(74) },
104 static struct platform_device scif2_device = {
108 .platform_data = &scif2_platform_data,
112 static struct plat_sci_port scif3_platform_data = {
113 .mapbase = 0xe6c70000,
114 .flags = UPF_BOOT_AUTOCONF,
115 .scscr = SCSCR_RE | SCSCR_TE,
116 .scbrr_algo_id = SCBRR_ALGO_4,
118 .irqs = { gic_spi(75), gic_spi(75),
119 gic_spi(75), gic_spi(75) },
122 static struct platform_device scif3_device = {
126 .platform_data = &scif3_platform_data,
130 static struct plat_sci_port scif4_platform_data = {
131 .mapbase = 0xe6c80000,
132 .flags = UPF_BOOT_AUTOCONF,
133 .scscr = SCSCR_RE | SCSCR_TE,
134 .scbrr_algo_id = SCBRR_ALGO_4,
136 .irqs = { gic_spi(78), gic_spi(78),
137 gic_spi(78), gic_spi(78) },
140 static struct platform_device scif4_device = {
144 .platform_data = &scif4_platform_data,
148 static struct plat_sci_port scif5_platform_data = {
149 .mapbase = 0xe6cb0000,
150 .flags = UPF_BOOT_AUTOCONF,
151 .scscr = SCSCR_RE | SCSCR_TE,
152 .scbrr_algo_id = SCBRR_ALGO_4,
154 .irqs = { gic_spi(79), gic_spi(79),
155 gic_spi(79), gic_spi(79) },
158 static struct platform_device scif5_device = {
162 .platform_data = &scif5_platform_data,
166 static struct plat_sci_port scif6_platform_data = {
167 .mapbase = 0xe6cc0000,
168 .flags = UPF_BOOT_AUTOCONF,
169 .scscr = SCSCR_RE | SCSCR_TE,
170 .scbrr_algo_id = SCBRR_ALGO_4,
172 .irqs = { gic_spi(156), gic_spi(156),
173 gic_spi(156), gic_spi(156) },
176 static struct platform_device scif6_device = {
180 .platform_data = &scif6_platform_data,
184 static struct plat_sci_port scif7_platform_data = {
185 .mapbase = 0xe6cd0000,
186 .flags = UPF_BOOT_AUTOCONF,
187 .scscr = SCSCR_RE | SCSCR_TE,
188 .scbrr_algo_id = SCBRR_ALGO_4,
190 .irqs = { gic_spi(143), gic_spi(143),
191 gic_spi(143), gic_spi(143) },
194 static struct platform_device scif7_device = {
198 .platform_data = &scif7_platform_data,
202 static struct plat_sci_port scif8_platform_data = {
203 .mapbase = 0xe6c30000,
204 .flags = UPF_BOOT_AUTOCONF,
205 .scscr = SCSCR_RE | SCSCR_TE,
206 .scbrr_algo_id = SCBRR_ALGO_4,
208 .irqs = { gic_spi(80), gic_spi(80),
209 gic_spi(80), gic_spi(80) },
212 static struct platform_device scif8_device = {
216 .platform_data = &scif8_platform_data,
220 static struct sh_timer_config cmt10_platform_data = {
222 .channel_offset = 0x10,
224 .clockevent_rating = 125,
225 .clocksource_rating = 125,
228 static struct resource cmt10_resources[] = {
233 .flags = IORESOURCE_MEM,
236 .start = gic_spi(65),
237 .flags = IORESOURCE_IRQ,
241 static struct platform_device cmt10_device = {
245 .platform_data = &cmt10_platform_data,
247 .resource = cmt10_resources,
248 .num_resources = ARRAY_SIZE(cmt10_resources),
252 static struct sh_timer_config tmu00_platform_data = {
254 .channel_offset = 0x4,
256 .clockevent_rating = 200,
259 static struct resource tmu00_resources[] = {
264 .flags = IORESOURCE_MEM,
267 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
268 .flags = IORESOURCE_IRQ,
272 static struct platform_device tmu00_device = {
276 .platform_data = &tmu00_platform_data,
278 .resource = tmu00_resources,
279 .num_resources = ARRAY_SIZE(tmu00_resources),
282 static struct sh_timer_config tmu01_platform_data = {
284 .channel_offset = 0x10,
286 .clocksource_rating = 200,
289 static struct resource tmu01_resources[] = {
294 .flags = IORESOURCE_MEM,
297 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
298 .flags = IORESOURCE_IRQ,
302 static struct platform_device tmu01_device = {
306 .platform_data = &tmu01_platform_data,
308 .resource = tmu01_resources,
309 .num_resources = ARRAY_SIZE(tmu01_resources),
312 static struct resource i2c0_resources[] = {
316 .end = 0xe6820425 - 1,
317 .flags = IORESOURCE_MEM,
320 .start = gic_spi(167),
322 .flags = IORESOURCE_IRQ,
326 static struct resource i2c1_resources[] = {
330 .end = 0xe6822425 - 1,
331 .flags = IORESOURCE_MEM,
334 .start = gic_spi(51),
336 .flags = IORESOURCE_IRQ,
340 static struct resource i2c2_resources[] = {
344 .end = 0xe6824425 - 1,
345 .flags = IORESOURCE_MEM,
348 .start = gic_spi(171),
350 .flags = IORESOURCE_IRQ,
354 static struct resource i2c3_resources[] = {
358 .end = 0xe6826425 - 1,
359 .flags = IORESOURCE_MEM,
362 .start = gic_spi(183),
364 .flags = IORESOURCE_IRQ,
368 static struct resource i2c4_resources[] = {
372 .end = 0xe6828425 - 1,
373 .flags = IORESOURCE_MEM,
376 .start = gic_spi(187),
378 .flags = IORESOURCE_IRQ,
382 static struct platform_device i2c0_device = {
383 .name = "i2c-sh_mobile",
385 .resource = i2c0_resources,
386 .num_resources = ARRAY_SIZE(i2c0_resources),
389 static struct platform_device i2c1_device = {
390 .name = "i2c-sh_mobile",
392 .resource = i2c1_resources,
393 .num_resources = ARRAY_SIZE(i2c1_resources),
396 static struct platform_device i2c2_device = {
397 .name = "i2c-sh_mobile",
399 .resource = i2c2_resources,
400 .num_resources = ARRAY_SIZE(i2c2_resources),
403 static struct platform_device i2c3_device = {
404 .name = "i2c-sh_mobile",
406 .resource = i2c3_resources,
407 .num_resources = ARRAY_SIZE(i2c3_resources),
410 static struct platform_device i2c4_device = {
411 .name = "i2c-sh_mobile",
413 .resource = i2c4_resources,
414 .num_resources = ARRAY_SIZE(i2c4_resources),
417 /* Transmit sizes and respective CHCR register values */
428 /* log2(size / 8) - used to calculate number of transfers */
430 [XMIT_SZ_8BIT] = 0, \
431 [XMIT_SZ_16BIT] = 1, \
432 [XMIT_SZ_32BIT] = 2, \
433 [XMIT_SZ_64BIT] = 3, \
434 [XMIT_SZ_128BIT] = 4, \
435 [XMIT_SZ_256BIT] = 5, \
436 [XMIT_SZ_512BIT] = 6, \
439 #define TS_INDEX2VAL(i) ((((i) & 3) << 3) | (((i) & 0xc) << (20 - 2)))
440 #define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
441 #define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
443 static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
445 .slave_id = SHDMA_SLAVE_SCIF0_TX,
447 .chcr = CHCR_TX(XMIT_SZ_8BIT),
450 .slave_id = SHDMA_SLAVE_SCIF0_RX,
452 .chcr = CHCR_RX(XMIT_SZ_8BIT),
455 .slave_id = SHDMA_SLAVE_SCIF1_TX,
457 .chcr = CHCR_TX(XMIT_SZ_8BIT),
460 .slave_id = SHDMA_SLAVE_SCIF1_RX,
462 .chcr = CHCR_RX(XMIT_SZ_8BIT),
465 .slave_id = SHDMA_SLAVE_SCIF2_TX,
467 .chcr = CHCR_TX(XMIT_SZ_8BIT),
470 .slave_id = SHDMA_SLAVE_SCIF2_RX,
472 .chcr = CHCR_RX(XMIT_SZ_8BIT),
475 .slave_id = SHDMA_SLAVE_SCIF3_TX,
477 .chcr = CHCR_TX(XMIT_SZ_8BIT),
480 .slave_id = SHDMA_SLAVE_SCIF3_RX,
482 .chcr = CHCR_RX(XMIT_SZ_8BIT),
485 .slave_id = SHDMA_SLAVE_SCIF4_TX,
487 .chcr = CHCR_TX(XMIT_SZ_8BIT),
490 .slave_id = SHDMA_SLAVE_SCIF4_RX,
492 .chcr = CHCR_RX(XMIT_SZ_8BIT),
495 .slave_id = SHDMA_SLAVE_SCIF5_TX,
497 .chcr = CHCR_TX(XMIT_SZ_8BIT),
500 .slave_id = SHDMA_SLAVE_SCIF5_RX,
502 .chcr = CHCR_RX(XMIT_SZ_8BIT),
505 .slave_id = SHDMA_SLAVE_SCIF6_TX,
507 .chcr = CHCR_TX(XMIT_SZ_8BIT),
510 .slave_id = SHDMA_SLAVE_SCIF6_RX,
512 .chcr = CHCR_RX(XMIT_SZ_8BIT),
515 .slave_id = SHDMA_SLAVE_SCIF7_TX,
517 .chcr = CHCR_TX(XMIT_SZ_8BIT),
520 .slave_id = SHDMA_SLAVE_SCIF7_RX,
522 .chcr = CHCR_RX(XMIT_SZ_8BIT),
525 .slave_id = SHDMA_SLAVE_SCIF8_TX,
527 .chcr = CHCR_TX(XMIT_SZ_8BIT),
530 .slave_id = SHDMA_SLAVE_SCIF8_RX,
532 .chcr = CHCR_RX(XMIT_SZ_8BIT),
535 .slave_id = SHDMA_SLAVE_SDHI0_TX,
537 .chcr = CHCR_TX(XMIT_SZ_16BIT),
540 .slave_id = SHDMA_SLAVE_SDHI0_RX,
542 .chcr = CHCR_RX(XMIT_SZ_16BIT),
545 .slave_id = SHDMA_SLAVE_SDHI1_TX,
547 .chcr = CHCR_TX(XMIT_SZ_16BIT),
550 .slave_id = SHDMA_SLAVE_SDHI1_RX,
552 .chcr = CHCR_RX(XMIT_SZ_16BIT),
555 .slave_id = SHDMA_SLAVE_SDHI2_TX,
557 .chcr = CHCR_TX(XMIT_SZ_16BIT),
560 .slave_id = SHDMA_SLAVE_SDHI2_RX,
562 .chcr = CHCR_RX(XMIT_SZ_16BIT),
565 .slave_id = SHDMA_SLAVE_MMCIF_TX,
567 .chcr = CHCR_TX(XMIT_SZ_32BIT),
570 .slave_id = SHDMA_SLAVE_MMCIF_RX,
572 .chcr = CHCR_RX(XMIT_SZ_32BIT),
577 #define DMAE_CHANNEL(_offset) \
579 .offset = _offset - 0x20, \
580 .dmars = _offset - 0x20 + 0x40, \
583 static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
584 DMAE_CHANNEL(0x8000),
585 DMAE_CHANNEL(0x8080),
586 DMAE_CHANNEL(0x8100),
587 DMAE_CHANNEL(0x8180),
588 DMAE_CHANNEL(0x8200),
589 DMAE_CHANNEL(0x8280),
590 DMAE_CHANNEL(0x8300),
591 DMAE_CHANNEL(0x8380),
592 DMAE_CHANNEL(0x8400),
593 DMAE_CHANNEL(0x8480),
594 DMAE_CHANNEL(0x8500),
595 DMAE_CHANNEL(0x8580),
596 DMAE_CHANNEL(0x8600),
597 DMAE_CHANNEL(0x8680),
598 DMAE_CHANNEL(0x8700),
599 DMAE_CHANNEL(0x8780),
600 DMAE_CHANNEL(0x8800),
601 DMAE_CHANNEL(0x8880),
602 DMAE_CHANNEL(0x8900),
603 DMAE_CHANNEL(0x8980),
606 static const unsigned int ts_shift[] = TS_SHIFT;
608 static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
609 .slave = sh73a0_dmae_slaves,
610 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
611 .channel = sh73a0_dmae_channels,
612 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
615 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
616 .ts_high_mask = 0x00300000,
617 .ts_shift = ts_shift,
618 .ts_shift_num = ARRAY_SIZE(ts_shift),
619 .dmaor_init = DMAOR_DME,
622 static struct resource sh73a0_dmae_resources[] = {
624 /* Registers including DMAOR and channels including DMARSx */
626 .end = 0xfe008a00 - 1,
627 .flags = IORESOURCE_MEM,
631 .start = gic_spi(129),
633 .flags = IORESOURCE_IRQ,
636 /* IRQ for channels 0-19 */
637 .start = gic_spi(109),
639 .flags = IORESOURCE_IRQ,
643 static struct platform_device dma0_device = {
644 .name = "sh-dma-engine",
646 .resource = sh73a0_dmae_resources,
647 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
649 .platform_data = &sh73a0_dmae_platform_data,
653 static struct platform_device *sh73a0_early_devices[] __initdata = {
668 static struct platform_device *sh73a0_late_devices[] __initdata = {
677 #define SRCR2 0xe61580b0
679 void __init sh73a0_add_standard_devices(void)
681 /* Clear software reset bit on SY-DMAC module */
682 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
684 platform_add_devices(sh73a0_early_devices,
685 ARRAY_SIZE(sh73a0_early_devices));
686 platform_add_devices(sh73a0_late_devices,
687 ARRAY_SIZE(sh73a0_late_devices));
690 static void __init sh73a0_earlytimer_init(void)
693 shmobile_earlytimer_init();
696 void __init sh73a0_add_early_devices(void)
698 early_platform_add_devices(sh73a0_early_devices,
699 ARRAY_SIZE(sh73a0_early_devices));
701 /* setup early console here as well */
702 shmobile_setup_console();
704 /* override timer setup with soc-specific code */
705 shmobile_timer.init = sh73a0_earlytimer_init;