Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / arm / mach-shmobile / setup-r8a7740.c
blob35dec233301e9711e7a612e537c8a85aa260307c
1 /*
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>
24 #include <linux/io.h>
25 #include <linux/irqchip.h>
26 #include <linux/irqchip/arm-gic.h>
27 #include <linux/platform_data/irq-renesas-intc-irqpin.h>
28 #include <linux/platform_device.h>
29 #include <linux/of_platform.h>
30 #include <linux/serial_sci.h>
31 #include <linux/sh_dma.h>
32 #include <linux/sh_timer.h>
33 #include <linux/platform_data/sh_ipmmu.h>
34 #include <mach/dma-register.h>
35 #include <mach/r8a7740.h>
36 #include <mach/pm-rmobile.h>
37 #include <mach/common.h>
38 #include <mach/irqs.h>
39 #include <asm/mach-types.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/time.h>
44 static struct map_desc r8a7740_io_desc[] __initdata = {
46 * for CPGA/INTC/PFC
47 * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
50 .virtual = 0xe6000000,
51 .pfn = __phys_to_pfn(0xe6000000),
52 .length = 160 << 20,
53 .type = MT_DEVICE_NONSHARED
55 #ifdef CONFIG_CACHE_L2X0
57 * for l2x0_init()
58 * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
61 .virtual = 0xf0002000,
62 .pfn = __phys_to_pfn(0xf0100000),
63 .length = PAGE_SIZE,
64 .type = MT_DEVICE_NONSHARED
66 #endif
69 void __init r8a7740_map_io(void)
71 iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc));
74 /* PFC */
75 static const struct resource pfc_resources[] = {
76 DEFINE_RES_MEM(0xe6050000, 0x8000),
77 DEFINE_RES_MEM(0xe605800c, 0x0020),
80 void __init r8a7740_pinmux_init(void)
82 platform_device_register_simple("pfc-r8a7740", -1, pfc_resources,
83 ARRAY_SIZE(pfc_resources));
86 static struct renesas_intc_irqpin_config irqpin0_platform_data = {
87 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
90 static struct resource irqpin0_resources[] = {
91 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
92 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
93 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
94 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
95 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
96 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ0 */
97 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ1 */
98 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ2 */
99 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ3 */
100 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ4 */
101 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ5 */
102 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ6 */
103 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ7 */
106 static struct platform_device irqpin0_device = {
107 .name = "renesas_intc_irqpin",
108 .id = 0,
109 .resource = irqpin0_resources,
110 .num_resources = ARRAY_SIZE(irqpin0_resources),
111 .dev = {
112 .platform_data = &irqpin0_platform_data,
116 static struct renesas_intc_irqpin_config irqpin1_platform_data = {
117 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
120 static struct resource irqpin1_resources[] = {
121 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
122 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
123 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
124 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
125 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
126 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ8 */
127 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ9 */
128 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ10 */
129 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ11 */
130 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ12 */
131 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ13 */
132 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ14 */
133 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ15 */
136 static struct platform_device irqpin1_device = {
137 .name = "renesas_intc_irqpin",
138 .id = 1,
139 .resource = irqpin1_resources,
140 .num_resources = ARRAY_SIZE(irqpin1_resources),
141 .dev = {
142 .platform_data = &irqpin1_platform_data,
146 static struct renesas_intc_irqpin_config irqpin2_platform_data = {
147 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
150 static struct resource irqpin2_resources[] = {
151 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
152 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI30A */
153 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ30A */
154 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK30A */
155 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR30A */
156 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ16 */
157 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ17 */
158 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ18 */
159 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ19 */
160 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ20 */
161 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ21 */
162 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ22 */
163 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ23 */
166 static struct platform_device irqpin2_device = {
167 .name = "renesas_intc_irqpin",
168 .id = 2,
169 .resource = irqpin2_resources,
170 .num_resources = ARRAY_SIZE(irqpin2_resources),
171 .dev = {
172 .platform_data = &irqpin2_platform_data,
176 static struct renesas_intc_irqpin_config irqpin3_platform_data = {
177 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
180 static struct resource irqpin3_resources[] = {
181 DEFINE_RES_MEM(0xe690000c, 4), /* ICR3A */
182 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
183 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
184 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
185 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
186 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ24 */
187 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ25 */
188 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ26 */
189 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ27 */
190 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ28 */
191 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ29 */
192 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ30 */
193 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ31 */
196 static struct platform_device irqpin3_device = {
197 .name = "renesas_intc_irqpin",
198 .id = 3,
199 .resource = irqpin3_resources,
200 .num_resources = ARRAY_SIZE(irqpin3_resources),
201 .dev = {
202 .platform_data = &irqpin3_platform_data,
206 /* SCIF */
207 #define R8A7740_SCIF(scif_type, index, baseaddr, irq) \
208 static struct plat_sci_port scif##index##_platform_data = { \
209 .type = scif_type, \
210 .flags = UPF_BOOT_AUTOCONF, \
211 .scscr = SCSCR_RE | SCSCR_TE, \
212 }; \
214 static struct resource scif##index##_resources[] = { \
215 DEFINE_RES_MEM(baseaddr, 0x100), \
216 DEFINE_RES_IRQ(irq), \
217 }; \
219 static struct platform_device scif##index##_device = { \
220 .name = "sh-sci", \
221 .id = index, \
222 .resource = scif##index##_resources, \
223 .num_resources = ARRAY_SIZE(scif##index##_resources), \
224 .dev = { \
225 .platform_data = &scif##index##_platform_data, \
226 }, \
229 R8A7740_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(100));
230 R8A7740_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(101));
231 R8A7740_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(102));
232 R8A7740_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(103));
233 R8A7740_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(104));
234 R8A7740_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(105));
235 R8A7740_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(106));
236 R8A7740_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(107));
237 R8A7740_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(108));
239 /* CMT */
240 static struct sh_timer_config cmt1_platform_data = {
241 .channels_mask = 0x3f,
244 static struct resource cmt1_resources[] = {
245 DEFINE_RES_MEM(0xe6138000, 0x170),
246 DEFINE_RES_IRQ(gic_spi(58)),
249 static struct platform_device cmt1_device = {
250 .name = "sh-cmt-48",
251 .id = 1,
252 .dev = {
253 .platform_data = &cmt1_platform_data,
255 .resource = cmt1_resources,
256 .num_resources = ARRAY_SIZE(cmt1_resources),
259 /* TMU */
260 static struct sh_timer_config tmu0_platform_data = {
261 .channels_mask = 7,
264 static struct resource tmu0_resources[] = {
265 DEFINE_RES_MEM(0xfff80000, 0x2c),
266 DEFINE_RES_IRQ(gic_spi(198)),
267 DEFINE_RES_IRQ(gic_spi(199)),
268 DEFINE_RES_IRQ(gic_spi(200)),
271 static struct platform_device tmu0_device = {
272 .name = "sh-tmu",
273 .id = 0,
274 .dev = {
275 .platform_data = &tmu0_platform_data,
277 .resource = tmu0_resources,
278 .num_resources = ARRAY_SIZE(tmu0_resources),
281 /* IPMMUI (an IPMMU module for ICB/LMB) */
282 static struct resource ipmmu_resources[] = {
283 [0] = {
284 .name = "IPMMUI",
285 .start = 0xfe951000,
286 .end = 0xfe9510ff,
287 .flags = IORESOURCE_MEM,
291 static const char * const ipmmu_dev_names[] = {
292 "sh_mobile_lcdc_fb.0",
293 "sh_mobile_lcdc_fb.1",
294 "sh_mobile_ceu.0",
297 static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
298 .dev_names = ipmmu_dev_names,
299 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
302 static struct platform_device ipmmu_device = {
303 .name = "ipmmu",
304 .id = -1,
305 .dev = {
306 .platform_data = &ipmmu_platform_data,
308 .resource = ipmmu_resources,
309 .num_resources = ARRAY_SIZE(ipmmu_resources),
312 static struct platform_device *r8a7740_devices_dt[] __initdata = {
313 &scif0_device,
314 &scif1_device,
315 &scif2_device,
316 &scif3_device,
317 &scif4_device,
318 &scif5_device,
319 &scif6_device,
320 &scif7_device,
321 &scif8_device,
322 &cmt1_device,
325 static struct platform_device *r8a7740_early_devices[] __initdata = {
326 &irqpin0_device,
327 &irqpin1_device,
328 &irqpin2_device,
329 &irqpin3_device,
330 &tmu0_device,
331 &ipmmu_device,
334 /* DMA */
335 static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
337 .slave_id = SHDMA_SLAVE_SDHI0_TX,
338 .addr = 0xe6850030,
339 .chcr = CHCR_TX(XMIT_SZ_16BIT),
340 .mid_rid = 0xc1,
341 }, {
342 .slave_id = SHDMA_SLAVE_SDHI0_RX,
343 .addr = 0xe6850030,
344 .chcr = CHCR_RX(XMIT_SZ_16BIT),
345 .mid_rid = 0xc2,
346 }, {
347 .slave_id = SHDMA_SLAVE_SDHI1_TX,
348 .addr = 0xe6860030,
349 .chcr = CHCR_TX(XMIT_SZ_16BIT),
350 .mid_rid = 0xc9,
351 }, {
352 .slave_id = SHDMA_SLAVE_SDHI1_RX,
353 .addr = 0xe6860030,
354 .chcr = CHCR_RX(XMIT_SZ_16BIT),
355 .mid_rid = 0xca,
356 }, {
357 .slave_id = SHDMA_SLAVE_SDHI2_TX,
358 .addr = 0xe6870030,
359 .chcr = CHCR_TX(XMIT_SZ_16BIT),
360 .mid_rid = 0xcd,
361 }, {
362 .slave_id = SHDMA_SLAVE_SDHI2_RX,
363 .addr = 0xe6870030,
364 .chcr = CHCR_RX(XMIT_SZ_16BIT),
365 .mid_rid = 0xce,
366 }, {
367 .slave_id = SHDMA_SLAVE_FSIA_TX,
368 .addr = 0xfe1f0024,
369 .chcr = CHCR_TX(XMIT_SZ_32BIT),
370 .mid_rid = 0xb1,
371 }, {
372 .slave_id = SHDMA_SLAVE_FSIA_RX,
373 .addr = 0xfe1f0020,
374 .chcr = CHCR_RX(XMIT_SZ_32BIT),
375 .mid_rid = 0xb2,
376 }, {
377 .slave_id = SHDMA_SLAVE_FSIB_TX,
378 .addr = 0xfe1f0064,
379 .chcr = CHCR_TX(XMIT_SZ_32BIT),
380 .mid_rid = 0xb5,
381 }, {
382 .slave_id = SHDMA_SLAVE_MMCIF_TX,
383 .addr = 0xe6bd0034,
384 .chcr = CHCR_TX(XMIT_SZ_32BIT),
385 .mid_rid = 0xd1,
386 }, {
387 .slave_id = SHDMA_SLAVE_MMCIF_RX,
388 .addr = 0xe6bd0034,
389 .chcr = CHCR_RX(XMIT_SZ_32BIT),
390 .mid_rid = 0xd2,
394 #define DMA_CHANNEL(a, b, c) \
396 .offset = a, \
397 .dmars = b, \
398 .dmars_bit = c, \
399 .chclr_offset = (0x220 - 0x20) + a \
402 static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
403 DMA_CHANNEL(0x00, 0, 0),
404 DMA_CHANNEL(0x10, 0, 8),
405 DMA_CHANNEL(0x20, 4, 0),
406 DMA_CHANNEL(0x30, 4, 8),
407 DMA_CHANNEL(0x50, 8, 0),
408 DMA_CHANNEL(0x60, 8, 8),
411 static struct sh_dmae_pdata dma_platform_data = {
412 .slave = r8a7740_dmae_slaves,
413 .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
414 .channel = r8a7740_dmae_channels,
415 .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
416 .ts_low_shift = TS_LOW_SHIFT,
417 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
418 .ts_high_shift = TS_HI_SHIFT,
419 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
420 .ts_shift = dma_ts_shift,
421 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
422 .dmaor_init = DMAOR_DME,
423 .chclr_present = 1,
426 /* Resource order important! */
427 static struct resource r8a7740_dmae0_resources[] = {
429 /* Channel registers and DMAOR */
430 .start = 0xfe008020,
431 .end = 0xfe00828f,
432 .flags = IORESOURCE_MEM,
435 /* DMARSx */
436 .start = 0xfe009000,
437 .end = 0xfe00900b,
438 .flags = IORESOURCE_MEM,
441 .name = "error_irq",
442 .start = gic_spi(34),
443 .end = gic_spi(34),
444 .flags = IORESOURCE_IRQ,
447 /* IRQ for channels 0-5 */
448 .start = gic_spi(28),
449 .end = gic_spi(33),
450 .flags = IORESOURCE_IRQ,
454 /* Resource order important! */
455 static struct resource r8a7740_dmae1_resources[] = {
457 /* Channel registers and DMAOR */
458 .start = 0xfe018020,
459 .end = 0xfe01828f,
460 .flags = IORESOURCE_MEM,
463 /* DMARSx */
464 .start = 0xfe019000,
465 .end = 0xfe01900b,
466 .flags = IORESOURCE_MEM,
469 .name = "error_irq",
470 .start = gic_spi(41),
471 .end = gic_spi(41),
472 .flags = IORESOURCE_IRQ,
475 /* IRQ for channels 0-5 */
476 .start = gic_spi(35),
477 .end = gic_spi(40),
478 .flags = IORESOURCE_IRQ,
482 /* Resource order important! */
483 static struct resource r8a7740_dmae2_resources[] = {
485 /* Channel registers and DMAOR */
486 .start = 0xfe028020,
487 .end = 0xfe02828f,
488 .flags = IORESOURCE_MEM,
491 /* DMARSx */
492 .start = 0xfe029000,
493 .end = 0xfe02900b,
494 .flags = IORESOURCE_MEM,
497 .name = "error_irq",
498 .start = gic_spi(48),
499 .end = gic_spi(48),
500 .flags = IORESOURCE_IRQ,
503 /* IRQ for channels 0-5 */
504 .start = gic_spi(42),
505 .end = gic_spi(47),
506 .flags = IORESOURCE_IRQ,
510 static struct platform_device dma0_device = {
511 .name = "sh-dma-engine",
512 .id = 0,
513 .resource = r8a7740_dmae0_resources,
514 .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
515 .dev = {
516 .platform_data = &dma_platform_data,
520 static struct platform_device dma1_device = {
521 .name = "sh-dma-engine",
522 .id = 1,
523 .resource = r8a7740_dmae1_resources,
524 .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
525 .dev = {
526 .platform_data = &dma_platform_data,
530 static struct platform_device dma2_device = {
531 .name = "sh-dma-engine",
532 .id = 2,
533 .resource = r8a7740_dmae2_resources,
534 .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
535 .dev = {
536 .platform_data = &dma_platform_data,
540 /* USB-DMAC */
541 static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
543 .offset = 0,
544 }, {
545 .offset = 0x20,
549 static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
551 .slave_id = SHDMA_SLAVE_USBHS_TX,
552 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
553 }, {
554 .slave_id = SHDMA_SLAVE_USBHS_RX,
555 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
559 static struct sh_dmae_pdata usb_dma_platform_data = {
560 .slave = r8a7740_usb_dma_slaves,
561 .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
562 .channel = r8a7740_usb_dma_channels,
563 .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
564 .ts_low_shift = USBTS_LOW_SHIFT,
565 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
566 .ts_high_shift = USBTS_HI_SHIFT,
567 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
568 .ts_shift = dma_usbts_shift,
569 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
570 .dmaor_init = DMAOR_DME,
571 .chcr_offset = 0x14,
572 .chcr_ie_bit = 1 << 5,
573 .dmaor_is_32bit = 1,
574 .needs_tend_set = 1,
575 .no_dmars = 1,
576 .slave_only = 1,
579 static struct resource r8a7740_usb_dma_resources[] = {
581 /* Channel registers and DMAOR */
582 .start = 0xe68a0020,
583 .end = 0xe68a0064 - 1,
584 .flags = IORESOURCE_MEM,
587 /* VCR/SWR/DMICR */
588 .start = 0xe68a0000,
589 .end = 0xe68a0014 - 1,
590 .flags = IORESOURCE_MEM,
593 /* IRQ for channels */
594 .start = gic_spi(49),
595 .end = gic_spi(49),
596 .flags = IORESOURCE_IRQ,
600 static struct platform_device usb_dma_device = {
601 .name = "sh-dma-engine",
602 .id = 3,
603 .resource = r8a7740_usb_dma_resources,
604 .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
605 .dev = {
606 .platform_data = &usb_dma_platform_data,
610 /* I2C */
611 static struct resource i2c0_resources[] = {
612 [0] = {
613 .name = "IIC0",
614 .start = 0xfff20000,
615 .end = 0xfff20425 - 1,
616 .flags = IORESOURCE_MEM,
618 [1] = {
619 .start = gic_spi(201),
620 .end = gic_spi(204),
621 .flags = IORESOURCE_IRQ,
625 static struct resource i2c1_resources[] = {
626 [0] = {
627 .name = "IIC1",
628 .start = 0xe6c20000,
629 .end = 0xe6c20425 - 1,
630 .flags = IORESOURCE_MEM,
632 [1] = {
633 .start = gic_spi(70), /* IIC1_ALI1 */
634 .end = gic_spi(73), /* IIC1_DTEI1 */
635 .flags = IORESOURCE_IRQ,
639 static struct platform_device i2c0_device = {
640 .name = "i2c-sh_mobile",
641 .id = 0,
642 .resource = i2c0_resources,
643 .num_resources = ARRAY_SIZE(i2c0_resources),
646 static struct platform_device i2c1_device = {
647 .name = "i2c-sh_mobile",
648 .id = 1,
649 .resource = i2c1_resources,
650 .num_resources = ARRAY_SIZE(i2c1_resources),
653 static struct resource pmu_resources[] = {
654 [0] = {
655 .start = gic_spi(83),
656 .end = gic_spi(83),
657 .flags = IORESOURCE_IRQ,
661 static struct platform_device pmu_device = {
662 .name = "arm-pmu",
663 .id = -1,
664 .num_resources = ARRAY_SIZE(pmu_resources),
665 .resource = pmu_resources,
668 static struct platform_device *r8a7740_late_devices[] __initdata = {
669 &i2c0_device,
670 &i2c1_device,
671 &dma0_device,
672 &dma1_device,
673 &dma2_device,
674 &usb_dma_device,
675 &pmu_device,
679 * r8a7740 chip has lasting errata on MERAM buffer.
680 * this is work-around for it.
681 * see
682 * "Media RAM (MERAM)" on r8a7740 documentation
684 #define MEBUFCNTR 0xFE950098
685 void __init r8a7740_meram_workaround(void)
687 void __iomem *reg;
689 reg = ioremap_nocache(MEBUFCNTR, 4);
690 if (reg) {
691 iowrite32(0x01600164, reg);
692 iounmap(reg);
696 #define ICCR 0x0004
697 #define ICSTART 0x0070
699 #define i2c_read(reg, offset) ioread8(reg + offset)
700 #define i2c_write(reg, offset, data) iowrite8(data, reg + offset)
703 * r8a7740 chip has lasting errata on I2C I/O pad reset.
704 * this is work-around for it.
706 static void r8a7740_i2c_workaround(struct platform_device *pdev)
708 struct resource *res;
709 void __iomem *reg;
711 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
712 if (unlikely(!res)) {
713 pr_err("r8a7740 i2c workaround fail (cannot find resource)\n");
714 return;
717 reg = ioremap(res->start, resource_size(res));
718 if (unlikely(!reg)) {
719 pr_err("r8a7740 i2c workaround fail (cannot map IO)\n");
720 return;
723 i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80);
724 i2c_read(reg, ICCR); /* dummy read */
726 i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10);
727 i2c_read(reg, ICSTART); /* dummy read */
729 udelay(10);
731 i2c_write(reg, ICCR, 0x01);
732 i2c_write(reg, ICSTART, 0x00);
734 udelay(10);
736 i2c_write(reg, ICCR, 0x10);
737 udelay(10);
738 i2c_write(reg, ICCR, 0x00);
739 udelay(10);
740 i2c_write(reg, ICCR, 0x10);
741 udelay(10);
743 iounmap(reg);
746 void __init r8a7740_add_standard_devices(void)
748 /* I2C work-around */
749 r8a7740_i2c_workaround(&i2c0_device);
750 r8a7740_i2c_workaround(&i2c1_device);
752 r8a7740_init_pm_domains();
754 /* add devices */
755 platform_add_devices(r8a7740_early_devices,
756 ARRAY_SIZE(r8a7740_early_devices));
757 platform_add_devices(r8a7740_devices_dt,
758 ARRAY_SIZE(r8a7740_devices_dt));
759 platform_add_devices(r8a7740_late_devices,
760 ARRAY_SIZE(r8a7740_late_devices));
762 /* add devices to PM domain */
764 rmobile_add_device_to_domain("A3SP", &scif0_device);
765 rmobile_add_device_to_domain("A3SP", &scif1_device);
766 rmobile_add_device_to_domain("A3SP", &scif2_device);
767 rmobile_add_device_to_domain("A3SP", &scif3_device);
768 rmobile_add_device_to_domain("A3SP", &scif4_device);
769 rmobile_add_device_to_domain("A3SP", &scif5_device);
770 rmobile_add_device_to_domain("A3SP", &scif6_device);
771 rmobile_add_device_to_domain("A3SP", &scif7_device);
772 rmobile_add_device_to_domain("A3SP", &scif8_device);
773 rmobile_add_device_to_domain("A3SP", &i2c1_device);
776 void __init r8a7740_add_early_devices(void)
778 early_platform_add_devices(r8a7740_early_devices,
779 ARRAY_SIZE(r8a7740_early_devices));
780 early_platform_add_devices(r8a7740_devices_dt,
781 ARRAY_SIZE(r8a7740_devices_dt));
783 /* setup early console here as well */
784 shmobile_setup_console();
787 #ifdef CONFIG_USE_OF
789 void __init r8a7740_add_standard_devices_dt(void)
791 platform_add_devices(r8a7740_devices_dt,
792 ARRAY_SIZE(r8a7740_devices_dt));
793 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
796 void __init r8a7740_init_irq_of(void)
798 void __iomem *intc_prio_base = ioremap_nocache(0xe6900010, 0x10);
799 void __iomem *intc_msk_base = ioremap_nocache(0xe6900040, 0x10);
800 void __iomem *pfc_inta_ctrl = ioremap_nocache(0xe605807c, 0x4);
802 irqchip_init();
804 /* route signals to GIC */
805 iowrite32(0x0, pfc_inta_ctrl);
808 * To mask the shared interrupt to SPI 149 we must ensure to set
809 * PRIO *and* MASK. Else we run into IRQ floods when registering
810 * the intc_irqpin devices
812 iowrite32(0x0, intc_prio_base + 0x0);
813 iowrite32(0x0, intc_prio_base + 0x4);
814 iowrite32(0x0, intc_prio_base + 0x8);
815 iowrite32(0x0, intc_prio_base + 0xc);
816 iowrite8(0xff, intc_msk_base + 0x0);
817 iowrite8(0xff, intc_msk_base + 0x4);
818 iowrite8(0xff, intc_msk_base + 0x8);
819 iowrite8(0xff, intc_msk_base + 0xc);
821 iounmap(intc_prio_base);
822 iounmap(intc_msk_base);
823 iounmap(pfc_inta_ctrl);
826 static void __init r8a7740_generic_init(void)
828 r8a7740_clock_init(0);
829 r8a7740_add_standard_devices_dt();
832 static const char *r8a7740_boards_compat_dt[] __initdata = {
833 "renesas,r8a7740",
834 NULL,
837 DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
838 .map_io = r8a7740_map_io,
839 .init_early = shmobile_init_delay,
840 .init_irq = r8a7740_init_irq_of,
841 .init_machine = r8a7740_generic_init,
842 .init_late = shmobile_init_late,
843 .dt_compat = r8a7740_boards_compat_dt,
844 MACHINE_END
846 #endif /* CONFIG_USE_OF */