2 * R8A7740 processor support
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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/delay.h>
21 #include <linux/dma-mapping.h>
22 #include <linux/kernel.h>
23 #include <linux/init.h>
25 #include <linux/platform_data/irq-renesas-intc-irqpin.h>
26 #include <linux/platform_device.h>
27 #include <linux/of_platform.h>
28 #include <linux/serial_sci.h>
29 #include <linux/sh_dma.h>
30 #include <linux/sh_timer.h>
31 #include <linux/platform_data/sh_ipmmu.h>
32 #include <mach/dma-register.h>
33 #include <mach/r8a7740.h>
34 #include <mach/pm-rmobile.h>
35 #include <mach/common.h>
36 #include <mach/irqs.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/map.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/time.h>
42 static struct map_desc r8a7740_io_desc[] __initdata = {
45 * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
48 .virtual = 0xe6000000,
49 .pfn = __phys_to_pfn(0xe6000000),
51 .type = MT_DEVICE_NONSHARED
53 #ifdef CONFIG_CACHE_L2X0
56 * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
59 .virtual = 0xf0002000,
60 .pfn = __phys_to_pfn(0xf0100000),
62 .type = MT_DEVICE_NONSHARED
67 void __init r8a7740_map_io(void)
69 iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc));
73 static const struct resource pfc_resources[] = {
74 DEFINE_RES_MEM(0xe6050000, 0x8000),
75 DEFINE_RES_MEM(0xe605800c, 0x0020),
78 void __init r8a7740_pinmux_init(void)
80 platform_device_register_simple("pfc-r8a7740", -1, pfc_resources,
81 ARRAY_SIZE(pfc_resources));
84 static struct renesas_intc_irqpin_config irqpin0_platform_data = {
85 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
88 static struct resource irqpin0_resources[] = {
89 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
90 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
91 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
92 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
93 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
94 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ0 */
95 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ1 */
96 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ2 */
97 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ3 */
98 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ4 */
99 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ5 */
100 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ6 */
101 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ7 */
104 static struct platform_device irqpin0_device = {
105 .name = "renesas_intc_irqpin",
107 .resource = irqpin0_resources,
108 .num_resources = ARRAY_SIZE(irqpin0_resources),
110 .platform_data = &irqpin0_platform_data,
114 static struct renesas_intc_irqpin_config irqpin1_platform_data = {
115 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
118 static struct resource irqpin1_resources[] = {
119 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
120 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
121 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
122 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
123 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
124 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ8 */
125 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ9 */
126 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ10 */
127 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ11 */
128 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ12 */
129 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ13 */
130 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ14 */
131 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ15 */
134 static struct platform_device irqpin1_device = {
135 .name = "renesas_intc_irqpin",
137 .resource = irqpin1_resources,
138 .num_resources = ARRAY_SIZE(irqpin1_resources),
140 .platform_data = &irqpin1_platform_data,
144 static struct renesas_intc_irqpin_config irqpin2_platform_data = {
145 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
148 static struct resource irqpin2_resources[] = {
149 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
150 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI30A */
151 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ30A */
152 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK30A */
153 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR30A */
154 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ16 */
155 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ17 */
156 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ18 */
157 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ19 */
158 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ20 */
159 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ21 */
160 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ22 */
161 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ23 */
164 static struct platform_device irqpin2_device = {
165 .name = "renesas_intc_irqpin",
167 .resource = irqpin2_resources,
168 .num_resources = ARRAY_SIZE(irqpin2_resources),
170 .platform_data = &irqpin2_platform_data,
174 static struct renesas_intc_irqpin_config irqpin3_platform_data = {
175 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
178 static struct resource irqpin3_resources[] = {
179 DEFINE_RES_MEM(0xe690000c, 4), /* ICR3A */
180 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
181 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
182 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
183 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
184 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ24 */
185 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ25 */
186 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ26 */
187 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ27 */
188 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ28 */
189 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ29 */
190 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ30 */
191 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ31 */
194 static struct platform_device irqpin3_device = {
195 .name = "renesas_intc_irqpin",
197 .resource = irqpin3_resources,
198 .num_resources = ARRAY_SIZE(irqpin3_resources),
200 .platform_data = &irqpin3_platform_data,
205 static struct plat_sci_port scif0_platform_data = {
206 .mapbase = 0xe6c40000,
207 .flags = UPF_BOOT_AUTOCONF,
208 .scscr = SCSCR_RE | SCSCR_TE,
209 .scbrr_algo_id = SCBRR_ALGO_4,
211 .irqs = SCIx_IRQ_MUXED(gic_spi(100)),
214 static struct platform_device scif0_device = {
218 .platform_data = &scif0_platform_data,
223 static struct plat_sci_port scif1_platform_data = {
224 .mapbase = 0xe6c50000,
225 .flags = UPF_BOOT_AUTOCONF,
226 .scscr = SCSCR_RE | SCSCR_TE,
227 .scbrr_algo_id = SCBRR_ALGO_4,
229 .irqs = SCIx_IRQ_MUXED(gic_spi(101)),
232 static struct platform_device scif1_device = {
236 .platform_data = &scif1_platform_data,
241 static struct plat_sci_port scif2_platform_data = {
242 .mapbase = 0xe6c60000,
243 .flags = UPF_BOOT_AUTOCONF,
244 .scscr = SCSCR_RE | SCSCR_TE,
245 .scbrr_algo_id = SCBRR_ALGO_4,
247 .irqs = SCIx_IRQ_MUXED(gic_spi(102)),
250 static struct platform_device scif2_device = {
254 .platform_data = &scif2_platform_data,
259 static struct plat_sci_port scif3_platform_data = {
260 .mapbase = 0xe6c70000,
261 .flags = UPF_BOOT_AUTOCONF,
262 .scscr = SCSCR_RE | SCSCR_TE,
263 .scbrr_algo_id = SCBRR_ALGO_4,
265 .irqs = SCIx_IRQ_MUXED(gic_spi(103)),
268 static struct platform_device scif3_device = {
272 .platform_data = &scif3_platform_data,
277 static struct plat_sci_port scif4_platform_data = {
278 .mapbase = 0xe6c80000,
279 .flags = UPF_BOOT_AUTOCONF,
280 .scscr = SCSCR_RE | SCSCR_TE,
281 .scbrr_algo_id = SCBRR_ALGO_4,
283 .irqs = SCIx_IRQ_MUXED(gic_spi(104)),
286 static struct platform_device scif4_device = {
290 .platform_data = &scif4_platform_data,
295 static struct plat_sci_port scif5_platform_data = {
296 .mapbase = 0xe6cb0000,
297 .flags = UPF_BOOT_AUTOCONF,
298 .scscr = SCSCR_RE | SCSCR_TE,
299 .scbrr_algo_id = SCBRR_ALGO_4,
301 .irqs = SCIx_IRQ_MUXED(gic_spi(105)),
304 static struct platform_device scif5_device = {
308 .platform_data = &scif5_platform_data,
313 static struct plat_sci_port scif6_platform_data = {
314 .mapbase = 0xe6cc0000,
315 .flags = UPF_BOOT_AUTOCONF,
316 .scscr = SCSCR_RE | SCSCR_TE,
317 .scbrr_algo_id = SCBRR_ALGO_4,
319 .irqs = SCIx_IRQ_MUXED(gic_spi(106)),
322 static struct platform_device scif6_device = {
326 .platform_data = &scif6_platform_data,
331 static struct plat_sci_port scif7_platform_data = {
332 .mapbase = 0xe6cd0000,
333 .flags = UPF_BOOT_AUTOCONF,
334 .scscr = SCSCR_RE | SCSCR_TE,
335 .scbrr_algo_id = SCBRR_ALGO_4,
337 .irqs = SCIx_IRQ_MUXED(gic_spi(107)),
340 static struct platform_device scif7_device = {
344 .platform_data = &scif7_platform_data,
349 static struct plat_sci_port scifb_platform_data = {
350 .mapbase = 0xe6c30000,
351 .flags = UPF_BOOT_AUTOCONF,
352 .scscr = SCSCR_RE | SCSCR_TE,
353 .scbrr_algo_id = SCBRR_ALGO_4,
355 .irqs = SCIx_IRQ_MUXED(gic_spi(108)),
358 static struct platform_device scifb_device = {
362 .platform_data = &scifb_platform_data,
367 static struct sh_timer_config cmt10_platform_data = {
369 .channel_offset = 0x10,
371 .clockevent_rating = 125,
372 .clocksource_rating = 125,
375 static struct resource cmt10_resources[] = {
380 .flags = IORESOURCE_MEM,
383 .start = gic_spi(58),
384 .flags = IORESOURCE_IRQ,
388 static struct platform_device cmt10_device = {
392 .platform_data = &cmt10_platform_data,
394 .resource = cmt10_resources,
395 .num_resources = ARRAY_SIZE(cmt10_resources),
399 static struct sh_timer_config tmu00_platform_data = {
401 .channel_offset = 0x4,
403 .clockevent_rating = 200,
406 static struct resource tmu00_resources[] = {
410 .end = 0xfff80014 - 1,
411 .flags = IORESOURCE_MEM,
414 .start = gic_spi(198),
415 .flags = IORESOURCE_IRQ,
419 static struct platform_device tmu00_device = {
423 .platform_data = &tmu00_platform_data,
425 .resource = tmu00_resources,
426 .num_resources = ARRAY_SIZE(tmu00_resources),
429 static struct sh_timer_config tmu01_platform_data = {
431 .channel_offset = 0x10,
433 .clocksource_rating = 200,
436 static struct resource tmu01_resources[] = {
440 .end = 0xfff80020 - 1,
441 .flags = IORESOURCE_MEM,
444 .start = gic_spi(199),
445 .flags = IORESOURCE_IRQ,
449 static struct platform_device tmu01_device = {
453 .platform_data = &tmu01_platform_data,
455 .resource = tmu01_resources,
456 .num_resources = ARRAY_SIZE(tmu01_resources),
459 static struct sh_timer_config tmu02_platform_data = {
461 .channel_offset = 0x1C,
463 .clocksource_rating = 200,
466 static struct resource tmu02_resources[] = {
470 .end = 0xfff8002C - 1,
471 .flags = IORESOURCE_MEM,
474 .start = gic_spi(200),
475 .flags = IORESOURCE_IRQ,
479 static struct platform_device tmu02_device = {
483 .platform_data = &tmu02_platform_data,
485 .resource = tmu02_resources,
486 .num_resources = ARRAY_SIZE(tmu02_resources),
489 /* IPMMUI (an IPMMU module for ICB/LMB) */
490 static struct resource ipmmu_resources[] = {
495 .flags = IORESOURCE_MEM,
499 static const char * const ipmmu_dev_names[] = {
500 "sh_mobile_lcdc_fb.0",
501 "sh_mobile_lcdc_fb.1",
505 static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
506 .dev_names = ipmmu_dev_names,
507 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
510 static struct platform_device ipmmu_device = {
514 .platform_data = &ipmmu_platform_data,
516 .resource = ipmmu_resources,
517 .num_resources = ARRAY_SIZE(ipmmu_resources),
520 static struct platform_device *r8a7740_devices_dt[] __initdata = {
533 static struct platform_device *r8a7740_early_devices[] __initdata = {
545 static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
547 .slave_id = SHDMA_SLAVE_SDHI0_TX,
549 .chcr = CHCR_TX(XMIT_SZ_16BIT),
552 .slave_id = SHDMA_SLAVE_SDHI0_RX,
554 .chcr = CHCR_RX(XMIT_SZ_16BIT),
557 .slave_id = SHDMA_SLAVE_SDHI1_TX,
559 .chcr = CHCR_TX(XMIT_SZ_16BIT),
562 .slave_id = SHDMA_SLAVE_SDHI1_RX,
564 .chcr = CHCR_RX(XMIT_SZ_16BIT),
567 .slave_id = SHDMA_SLAVE_SDHI2_TX,
569 .chcr = CHCR_TX(XMIT_SZ_16BIT),
572 .slave_id = SHDMA_SLAVE_SDHI2_RX,
574 .chcr = CHCR_RX(XMIT_SZ_16BIT),
577 .slave_id = SHDMA_SLAVE_FSIA_TX,
579 .chcr = CHCR_TX(XMIT_SZ_32BIT),
582 .slave_id = SHDMA_SLAVE_FSIA_RX,
584 .chcr = CHCR_RX(XMIT_SZ_32BIT),
587 .slave_id = SHDMA_SLAVE_FSIB_TX,
589 .chcr = CHCR_TX(XMIT_SZ_32BIT),
594 #define DMA_CHANNEL(a, b, c) \
599 .chclr_offset = (0x220 - 0x20) + a \
602 static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
603 DMA_CHANNEL(0x00, 0, 0),
604 DMA_CHANNEL(0x10, 0, 8),
605 DMA_CHANNEL(0x20, 4, 0),
606 DMA_CHANNEL(0x30, 4, 8),
607 DMA_CHANNEL(0x50, 8, 0),
608 DMA_CHANNEL(0x60, 8, 8),
611 static struct sh_dmae_pdata dma_platform_data = {
612 .slave = r8a7740_dmae_slaves,
613 .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
614 .channel = r8a7740_dmae_channels,
615 .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
616 .ts_low_shift = TS_LOW_SHIFT,
617 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
618 .ts_high_shift = TS_HI_SHIFT,
619 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
620 .ts_shift = dma_ts_shift,
621 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
622 .dmaor_init = DMAOR_DME,
626 /* Resource order important! */
627 static struct resource r8a7740_dmae0_resources[] = {
629 /* Channel registers and DMAOR */
632 .flags = IORESOURCE_MEM,
638 .flags = IORESOURCE_MEM,
642 .start = gic_spi(34),
644 .flags = IORESOURCE_IRQ,
647 /* IRQ for channels 0-5 */
648 .start = gic_spi(28),
650 .flags = IORESOURCE_IRQ,
654 /* Resource order important! */
655 static struct resource r8a7740_dmae1_resources[] = {
657 /* Channel registers and DMAOR */
660 .flags = IORESOURCE_MEM,
666 .flags = IORESOURCE_MEM,
670 .start = gic_spi(41),
672 .flags = IORESOURCE_IRQ,
675 /* IRQ for channels 0-5 */
676 .start = gic_spi(35),
678 .flags = IORESOURCE_IRQ,
682 /* Resource order important! */
683 static struct resource r8a7740_dmae2_resources[] = {
685 /* Channel registers and DMAOR */
688 .flags = IORESOURCE_MEM,
694 .flags = IORESOURCE_MEM,
698 .start = gic_spi(48),
700 .flags = IORESOURCE_IRQ,
703 /* IRQ for channels 0-5 */
704 .start = gic_spi(42),
706 .flags = IORESOURCE_IRQ,
710 static struct platform_device dma0_device = {
711 .name = "sh-dma-engine",
713 .resource = r8a7740_dmae0_resources,
714 .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
716 .platform_data = &dma_platform_data,
720 static struct platform_device dma1_device = {
721 .name = "sh-dma-engine",
723 .resource = r8a7740_dmae1_resources,
724 .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
726 .platform_data = &dma_platform_data,
730 static struct platform_device dma2_device = {
731 .name = "sh-dma-engine",
733 .resource = r8a7740_dmae2_resources,
734 .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
736 .platform_data = &dma_platform_data,
741 static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
749 static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
751 .slave_id = SHDMA_SLAVE_USBHS_TX,
752 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
754 .slave_id = SHDMA_SLAVE_USBHS_RX,
755 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
759 static struct sh_dmae_pdata usb_dma_platform_data = {
760 .slave = r8a7740_usb_dma_slaves,
761 .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
762 .channel = r8a7740_usb_dma_channels,
763 .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
764 .ts_low_shift = USBTS_LOW_SHIFT,
765 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
766 .ts_high_shift = USBTS_HI_SHIFT,
767 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
768 .ts_shift = dma_usbts_shift,
769 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
770 .dmaor_init = DMAOR_DME,
772 .chcr_ie_bit = 1 << 5,
779 static struct resource r8a7740_usb_dma_resources[] = {
781 /* Channel registers and DMAOR */
783 .end = 0xe68a0064 - 1,
784 .flags = IORESOURCE_MEM,
789 .end = 0xe68a0014 - 1,
790 .flags = IORESOURCE_MEM,
793 /* IRQ for channels */
794 .start = gic_spi(49),
796 .flags = IORESOURCE_IRQ,
800 static struct platform_device usb_dma_device = {
801 .name = "sh-dma-engine",
803 .resource = r8a7740_usb_dma_resources,
804 .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
806 .platform_data = &usb_dma_platform_data,
811 static struct resource i2c0_resources[] = {
815 .end = 0xfff20425 - 1,
816 .flags = IORESOURCE_MEM,
819 .start = gic_spi(201),
821 .flags = IORESOURCE_IRQ,
825 static struct resource i2c1_resources[] = {
829 .end = 0xe6c20425 - 1,
830 .flags = IORESOURCE_MEM,
833 .start = gic_spi(70), /* IIC1_ALI1 */
834 .end = gic_spi(73), /* IIC1_DTEI1 */
835 .flags = IORESOURCE_IRQ,
839 static struct platform_device i2c0_device = {
840 .name = "i2c-sh_mobile",
842 .resource = i2c0_resources,
843 .num_resources = ARRAY_SIZE(i2c0_resources),
846 static struct platform_device i2c1_device = {
847 .name = "i2c-sh_mobile",
849 .resource = i2c1_resources,
850 .num_resources = ARRAY_SIZE(i2c1_resources),
853 static struct resource pmu_resources[] = {
855 .start = gic_spi(83),
857 .flags = IORESOURCE_IRQ,
861 static struct platform_device pmu_device = {
864 .num_resources = ARRAY_SIZE(pmu_resources),
865 .resource = pmu_resources,
868 static struct platform_device *r8a7740_late_devices[] __initdata = {
879 * r8a7740 chip has lasting errata on MERAM buffer.
880 * this is work-around for it.
882 * "Media RAM (MERAM)" on r8a7740 documentation
884 #define MEBUFCNTR 0xFE950098
885 void r8a7740_meram_workaround(void)
889 reg = ioremap_nocache(MEBUFCNTR, 4);
891 iowrite32(0x01600164, reg);
897 #define ICSTART 0x0070
899 #define i2c_read(reg, offset) ioread8(reg + offset)
900 #define i2c_write(reg, offset, data) iowrite8(data, reg + offset)
903 * r8a7740 chip has lasting errata on I2C I/O pad reset.
904 * this is work-around for it.
906 static void r8a7740_i2c_workaround(struct platform_device *pdev)
908 struct resource *res;
911 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
912 if (unlikely(!res)) {
913 pr_err("r8a7740 i2c workaround fail (cannot find resource)\n");
917 reg = ioremap(res->start, resource_size(res));
918 if (unlikely(!reg)) {
919 pr_err("r8a7740 i2c workaround fail (cannot map IO)\n");
923 i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80);
924 i2c_read(reg, ICCR); /* dummy read */
926 i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10);
927 i2c_read(reg, ICSTART); /* dummy read */
931 i2c_write(reg, ICCR, 0x01);
932 i2c_write(reg, ICSTART, 0x00);
936 i2c_write(reg, ICCR, 0x10);
938 i2c_write(reg, ICCR, 0x00);
940 i2c_write(reg, ICCR, 0x10);
946 void __init r8a7740_add_standard_devices(void)
948 /* I2C work-around */
949 r8a7740_i2c_workaround(&i2c0_device);
950 r8a7740_i2c_workaround(&i2c1_device);
952 r8a7740_init_pm_domains();
955 platform_add_devices(r8a7740_early_devices,
956 ARRAY_SIZE(r8a7740_early_devices));
957 platform_add_devices(r8a7740_devices_dt,
958 ARRAY_SIZE(r8a7740_devices_dt));
959 platform_add_devices(r8a7740_late_devices,
960 ARRAY_SIZE(r8a7740_late_devices));
962 /* add devices to PM domain */
964 rmobile_add_device_to_domain("A3SP", &scif0_device);
965 rmobile_add_device_to_domain("A3SP", &scif1_device);
966 rmobile_add_device_to_domain("A3SP", &scif2_device);
967 rmobile_add_device_to_domain("A3SP", &scif3_device);
968 rmobile_add_device_to_domain("A3SP", &scif4_device);
969 rmobile_add_device_to_domain("A3SP", &scif5_device);
970 rmobile_add_device_to_domain("A3SP", &scif6_device);
971 rmobile_add_device_to_domain("A3SP", &scif7_device);
972 rmobile_add_device_to_domain("A3SP", &scifb_device);
973 rmobile_add_device_to_domain("A3SP", &i2c1_device);
976 void __init r8a7740_add_early_devices(void)
978 early_platform_add_devices(r8a7740_early_devices,
979 ARRAY_SIZE(r8a7740_early_devices));
980 early_platform_add_devices(r8a7740_devices_dt,
981 ARRAY_SIZE(r8a7740_devices_dt));
983 /* setup early console here as well */
984 shmobile_setup_console();
989 void __init r8a7740_add_early_devices_dt(void)
991 shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
993 early_platform_add_devices(r8a7740_early_devices,
994 ARRAY_SIZE(r8a7740_early_devices));
996 /* setup early console here as well */
997 shmobile_setup_console();
1000 void __init r8a7740_add_standard_devices_dt(void)
1002 platform_add_devices(r8a7740_devices_dt,
1003 ARRAY_SIZE(r8a7740_devices_dt));
1004 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
1007 void __init r8a7740_init_delay(void)
1009 shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
1012 static void __init r8a7740_generic_init(void)
1014 r8a7740_clock_init(0);
1015 r8a7740_add_standard_devices_dt();
1018 static const char *r8a7740_boards_compat_dt[] __initdata = {
1023 DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
1024 .map_io = r8a7740_map_io,
1025 .init_early = r8a7740_init_delay,
1026 .init_irq = r8a7740_init_irq_of,
1027 .init_machine = r8a7740_generic_init,
1028 .init_time = shmobile_timer_init,
1029 .dt_compat = r8a7740_boards_compat_dt,
1032 #endif /* CONFIG_USE_OF */