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/irqs.h>
35 #include <mach/sh73a0.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
39 static struct plat_sci_port scif0_platform_data = {
40 .mapbase = 0xe6c40000,
41 .flags = UPF_BOOT_AUTOCONF,
42 .scscr = SCSCR_RE | SCSCR_TE,
43 .scbrr_algo_id = SCBRR_ALGO_4,
45 .irqs = { gic_spi(72), gic_spi(72),
46 gic_spi(72), gic_spi(72) },
49 static struct platform_device scif0_device = {
53 .platform_data = &scif0_platform_data,
57 static struct plat_sci_port scif1_platform_data = {
58 .mapbase = 0xe6c50000,
59 .flags = UPF_BOOT_AUTOCONF,
60 .scscr = SCSCR_RE | SCSCR_TE,
61 .scbrr_algo_id = SCBRR_ALGO_4,
63 .irqs = { gic_spi(73), gic_spi(73),
64 gic_spi(73), gic_spi(73) },
67 static struct platform_device scif1_device = {
71 .platform_data = &scif1_platform_data,
75 static struct plat_sci_port scif2_platform_data = {
76 .mapbase = 0xe6c60000,
77 .flags = UPF_BOOT_AUTOCONF,
78 .scscr = SCSCR_RE | SCSCR_TE,
79 .scbrr_algo_id = SCBRR_ALGO_4,
81 .irqs = { gic_spi(74), gic_spi(74),
82 gic_spi(74), gic_spi(74) },
85 static struct platform_device scif2_device = {
89 .platform_data = &scif2_platform_data,
93 static struct plat_sci_port scif3_platform_data = {
94 .mapbase = 0xe6c70000,
95 .flags = UPF_BOOT_AUTOCONF,
96 .scscr = SCSCR_RE | SCSCR_TE,
97 .scbrr_algo_id = SCBRR_ALGO_4,
99 .irqs = { gic_spi(75), gic_spi(75),
100 gic_spi(75), gic_spi(75) },
103 static struct platform_device scif3_device = {
107 .platform_data = &scif3_platform_data,
111 static struct plat_sci_port scif4_platform_data = {
112 .mapbase = 0xe6c80000,
113 .flags = UPF_BOOT_AUTOCONF,
114 .scscr = SCSCR_RE | SCSCR_TE,
115 .scbrr_algo_id = SCBRR_ALGO_4,
117 .irqs = { gic_spi(78), gic_spi(78),
118 gic_spi(78), gic_spi(78) },
121 static struct platform_device scif4_device = {
125 .platform_data = &scif4_platform_data,
129 static struct plat_sci_port scif5_platform_data = {
130 .mapbase = 0xe6cb0000,
131 .flags = UPF_BOOT_AUTOCONF,
132 .scscr = SCSCR_RE | SCSCR_TE,
133 .scbrr_algo_id = SCBRR_ALGO_4,
135 .irqs = { gic_spi(79), gic_spi(79),
136 gic_spi(79), gic_spi(79) },
139 static struct platform_device scif5_device = {
143 .platform_data = &scif5_platform_data,
147 static struct plat_sci_port scif6_platform_data = {
148 .mapbase = 0xe6cc0000,
149 .flags = UPF_BOOT_AUTOCONF,
150 .scscr = SCSCR_RE | SCSCR_TE,
151 .scbrr_algo_id = SCBRR_ALGO_4,
153 .irqs = { gic_spi(156), gic_spi(156),
154 gic_spi(156), gic_spi(156) },
157 static struct platform_device scif6_device = {
161 .platform_data = &scif6_platform_data,
165 static struct plat_sci_port scif7_platform_data = {
166 .mapbase = 0xe6cd0000,
167 .flags = UPF_BOOT_AUTOCONF,
168 .scscr = SCSCR_RE | SCSCR_TE,
169 .scbrr_algo_id = SCBRR_ALGO_4,
171 .irqs = { gic_spi(143), gic_spi(143),
172 gic_spi(143), gic_spi(143) },
175 static struct platform_device scif7_device = {
179 .platform_data = &scif7_platform_data,
183 static struct plat_sci_port scif8_platform_data = {
184 .mapbase = 0xe6c30000,
185 .flags = UPF_BOOT_AUTOCONF,
186 .scscr = SCSCR_RE | SCSCR_TE,
187 .scbrr_algo_id = SCBRR_ALGO_4,
189 .irqs = { gic_spi(80), gic_spi(80),
190 gic_spi(80), gic_spi(80) },
193 static struct platform_device scif8_device = {
197 .platform_data = &scif8_platform_data,
201 static struct sh_timer_config cmt10_platform_data = {
203 .channel_offset = 0x10,
205 .clockevent_rating = 125,
206 .clocksource_rating = 125,
209 static struct resource cmt10_resources[] = {
214 .flags = IORESOURCE_MEM,
217 .start = gic_spi(65),
218 .flags = IORESOURCE_IRQ,
222 static struct platform_device cmt10_device = {
226 .platform_data = &cmt10_platform_data,
228 .resource = cmt10_resources,
229 .num_resources = ARRAY_SIZE(cmt10_resources),
233 static struct sh_timer_config tmu00_platform_data = {
235 .channel_offset = 0x4,
237 .clockevent_rating = 200,
240 static struct resource tmu00_resources[] = {
245 .flags = IORESOURCE_MEM,
248 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
249 .flags = IORESOURCE_IRQ,
253 static struct platform_device tmu00_device = {
257 .platform_data = &tmu00_platform_data,
259 .resource = tmu00_resources,
260 .num_resources = ARRAY_SIZE(tmu00_resources),
263 static struct sh_timer_config tmu01_platform_data = {
265 .channel_offset = 0x10,
267 .clocksource_rating = 200,
270 static struct resource tmu01_resources[] = {
275 .flags = IORESOURCE_MEM,
278 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
279 .flags = IORESOURCE_IRQ,
283 static struct platform_device tmu01_device = {
287 .platform_data = &tmu01_platform_data,
289 .resource = tmu01_resources,
290 .num_resources = ARRAY_SIZE(tmu01_resources),
293 static struct resource i2c0_resources[] = {
297 .end = 0xe6820425 - 1,
298 .flags = IORESOURCE_MEM,
301 .start = gic_spi(167),
303 .flags = IORESOURCE_IRQ,
307 static struct resource i2c1_resources[] = {
311 .end = 0xe6822425 - 1,
312 .flags = IORESOURCE_MEM,
315 .start = gic_spi(51),
317 .flags = IORESOURCE_IRQ,
321 static struct resource i2c2_resources[] = {
325 .end = 0xe6824425 - 1,
326 .flags = IORESOURCE_MEM,
329 .start = gic_spi(171),
331 .flags = IORESOURCE_IRQ,
335 static struct resource i2c3_resources[] = {
339 .end = 0xe6826425 - 1,
340 .flags = IORESOURCE_MEM,
343 .start = gic_spi(183),
345 .flags = IORESOURCE_IRQ,
349 static struct resource i2c4_resources[] = {
353 .end = 0xe6828425 - 1,
354 .flags = IORESOURCE_MEM,
357 .start = gic_spi(187),
359 .flags = IORESOURCE_IRQ,
363 static struct platform_device i2c0_device = {
364 .name = "i2c-sh_mobile",
366 .resource = i2c0_resources,
367 .num_resources = ARRAY_SIZE(i2c0_resources),
370 static struct platform_device i2c1_device = {
371 .name = "i2c-sh_mobile",
373 .resource = i2c1_resources,
374 .num_resources = ARRAY_SIZE(i2c1_resources),
377 static struct platform_device i2c2_device = {
378 .name = "i2c-sh_mobile",
380 .resource = i2c2_resources,
381 .num_resources = ARRAY_SIZE(i2c2_resources),
384 static struct platform_device i2c3_device = {
385 .name = "i2c-sh_mobile",
387 .resource = i2c3_resources,
388 .num_resources = ARRAY_SIZE(i2c3_resources),
391 static struct platform_device i2c4_device = {
392 .name = "i2c-sh_mobile",
394 .resource = i2c4_resources,
395 .num_resources = ARRAY_SIZE(i2c4_resources),
398 /* Transmit sizes and respective CHCR register values */
409 /* log2(size / 8) - used to calculate number of transfers */
411 [XMIT_SZ_8BIT] = 0, \
412 [XMIT_SZ_16BIT] = 1, \
413 [XMIT_SZ_32BIT] = 2, \
414 [XMIT_SZ_64BIT] = 3, \
415 [XMIT_SZ_128BIT] = 4, \
416 [XMIT_SZ_256BIT] = 5, \
417 [XMIT_SZ_512BIT] = 6, \
420 #define TS_INDEX2VAL(i) ((((i) & 3) << 3) | (((i) & 0xc) << (20 - 2)))
421 #define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
422 #define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
424 static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
426 .slave_id = SHDMA_SLAVE_SCIF0_TX,
428 .chcr = CHCR_TX(XMIT_SZ_8BIT),
431 .slave_id = SHDMA_SLAVE_SCIF0_RX,
433 .chcr = CHCR_RX(XMIT_SZ_8BIT),
436 .slave_id = SHDMA_SLAVE_SCIF1_TX,
438 .chcr = CHCR_TX(XMIT_SZ_8BIT),
441 .slave_id = SHDMA_SLAVE_SCIF1_RX,
443 .chcr = CHCR_RX(XMIT_SZ_8BIT),
446 .slave_id = SHDMA_SLAVE_SCIF2_TX,
448 .chcr = CHCR_TX(XMIT_SZ_8BIT),
451 .slave_id = SHDMA_SLAVE_SCIF2_RX,
453 .chcr = CHCR_RX(XMIT_SZ_8BIT),
456 .slave_id = SHDMA_SLAVE_SCIF3_TX,
458 .chcr = CHCR_TX(XMIT_SZ_8BIT),
461 .slave_id = SHDMA_SLAVE_SCIF3_RX,
463 .chcr = CHCR_RX(XMIT_SZ_8BIT),
466 .slave_id = SHDMA_SLAVE_SCIF4_TX,
468 .chcr = CHCR_TX(XMIT_SZ_8BIT),
471 .slave_id = SHDMA_SLAVE_SCIF4_RX,
473 .chcr = CHCR_RX(XMIT_SZ_8BIT),
476 .slave_id = SHDMA_SLAVE_SCIF5_TX,
478 .chcr = CHCR_TX(XMIT_SZ_8BIT),
481 .slave_id = SHDMA_SLAVE_SCIF5_RX,
483 .chcr = CHCR_RX(XMIT_SZ_8BIT),
486 .slave_id = SHDMA_SLAVE_SCIF6_TX,
488 .chcr = CHCR_TX(XMIT_SZ_8BIT),
491 .slave_id = SHDMA_SLAVE_SCIF6_RX,
493 .chcr = CHCR_RX(XMIT_SZ_8BIT),
496 .slave_id = SHDMA_SLAVE_SCIF7_TX,
498 .chcr = CHCR_TX(XMIT_SZ_8BIT),
501 .slave_id = SHDMA_SLAVE_SCIF7_RX,
503 .chcr = CHCR_RX(XMIT_SZ_8BIT),
506 .slave_id = SHDMA_SLAVE_SCIF8_TX,
508 .chcr = CHCR_TX(XMIT_SZ_8BIT),
511 .slave_id = SHDMA_SLAVE_SCIF8_RX,
513 .chcr = CHCR_RX(XMIT_SZ_8BIT),
516 .slave_id = SHDMA_SLAVE_SDHI0_TX,
518 .chcr = CHCR_TX(XMIT_SZ_16BIT),
521 .slave_id = SHDMA_SLAVE_SDHI0_RX,
523 .chcr = CHCR_RX(XMIT_SZ_16BIT),
526 .slave_id = SHDMA_SLAVE_SDHI1_TX,
528 .chcr = CHCR_TX(XMIT_SZ_16BIT),
531 .slave_id = SHDMA_SLAVE_SDHI1_RX,
533 .chcr = CHCR_RX(XMIT_SZ_16BIT),
536 .slave_id = SHDMA_SLAVE_SDHI2_TX,
538 .chcr = CHCR_TX(XMIT_SZ_16BIT),
541 .slave_id = SHDMA_SLAVE_SDHI2_RX,
543 .chcr = CHCR_RX(XMIT_SZ_16BIT),
546 .slave_id = SHDMA_SLAVE_MMCIF_TX,
548 .chcr = CHCR_TX(XMIT_SZ_32BIT),
551 .slave_id = SHDMA_SLAVE_MMCIF_RX,
553 .chcr = CHCR_RX(XMIT_SZ_32BIT),
558 #define DMAE_CHANNEL(_offset) \
560 .offset = _offset - 0x20, \
561 .dmars = _offset - 0x20 + 0x40, \
564 static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
565 DMAE_CHANNEL(0x8000),
566 DMAE_CHANNEL(0x8080),
567 DMAE_CHANNEL(0x8100),
568 DMAE_CHANNEL(0x8180),
569 DMAE_CHANNEL(0x8200),
570 DMAE_CHANNEL(0x8280),
571 DMAE_CHANNEL(0x8300),
572 DMAE_CHANNEL(0x8380),
573 DMAE_CHANNEL(0x8400),
574 DMAE_CHANNEL(0x8480),
575 DMAE_CHANNEL(0x8500),
576 DMAE_CHANNEL(0x8580),
577 DMAE_CHANNEL(0x8600),
578 DMAE_CHANNEL(0x8680),
579 DMAE_CHANNEL(0x8700),
580 DMAE_CHANNEL(0x8780),
581 DMAE_CHANNEL(0x8800),
582 DMAE_CHANNEL(0x8880),
583 DMAE_CHANNEL(0x8900),
584 DMAE_CHANNEL(0x8980),
587 static const unsigned int ts_shift[] = TS_SHIFT;
589 static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
590 .slave = sh73a0_dmae_slaves,
591 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
592 .channel = sh73a0_dmae_channels,
593 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
596 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
597 .ts_high_mask = 0x00300000,
598 .ts_shift = ts_shift,
599 .ts_shift_num = ARRAY_SIZE(ts_shift),
600 .dmaor_init = DMAOR_DME,
603 static struct resource sh73a0_dmae_resources[] = {
605 /* Registers including DMAOR and channels including DMARSx */
607 .end = 0xfe008a00 - 1,
608 .flags = IORESOURCE_MEM,
612 .start = gic_spi(129),
614 .flags = IORESOURCE_IRQ,
617 /* IRQ for channels 0-19 */
618 .start = gic_spi(109),
620 .flags = IORESOURCE_IRQ,
624 static struct platform_device dma0_device = {
625 .name = "sh-dma-engine",
627 .resource = sh73a0_dmae_resources,
628 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
630 .platform_data = &sh73a0_dmae_platform_data,
634 static struct platform_device *sh73a0_early_devices[] __initdata = {
649 static struct platform_device *sh73a0_late_devices[] __initdata = {
658 #define SRCR2 0xe61580b0
660 void __init sh73a0_add_standard_devices(void)
662 /* Clear software reset bit on SY-DMAC module */
663 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
665 platform_add_devices(sh73a0_early_devices,
666 ARRAY_SIZE(sh73a0_early_devices));
667 platform_add_devices(sh73a0_late_devices,
668 ARRAY_SIZE(sh73a0_late_devices));
671 void __init sh73a0_add_early_devices(void)
673 early_platform_add_devices(sh73a0_early_devices,
674 ARRAY_SIZE(sh73a0_early_devices));