blob: 9284e6fdb0c85e890ad35aea7783308cbc450a3e [file] [log] [blame]
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -08001/*
2 * R8A7740 processor support
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
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.
10 *
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.
15 *
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
19 */
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -080020#include <linux/delay.h>
Kuninori Morimoto3841e6f2012-04-24 02:10:05 -070021#include <linux/dma-mapping.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080022#include <linux/kernel.h>
23#include <linux/init.h>
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -080024#include <linux/io.h>
Bastian Hecht0b7d7822013-03-27 14:54:04 +010025#include <linux/platform_data/irq-renesas-intc-irqpin.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080026#include <linux/platform_device.h>
Magnus Damm755d57b2012-07-06 17:08:07 +090027#include <linux/of_platform.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080028#include <linux/serial_sci.h>
Kuninori Morimoto643c3302012-06-25 03:36:49 -070029#include <linux/sh_dma.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080030#include <linux/sh_timer.h>
Hideki EIRAKUf671e022013-01-21 19:54:29 +090031#include <linux/platform_data/sh_ipmmu.h>
Kuninori Morimotod7de9382012-06-25 03:43:10 -070032#include <mach/dma-register.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080033#include <mach/r8a7740.h>
Kuninori Morimoto84592932012-07-05 01:25:58 -070034#include <mach/pm-rmobile.h>
Magnus Dammd3ab7222012-02-29 21:37:35 +090035#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060036#include <mach/irqs.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080037#include <asm/mach-types.h>
Magnus Dammd3ab7222012-02-29 21:37:35 +090038#include <asm/mach/map.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080039#include <asm/mach/arch.h>
Magnus Damm23e5bc02012-03-06 17:36:53 +090040#include <asm/mach/time.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080041
Magnus Dammd3ab7222012-02-29 21:37:35 +090042static struct map_desc r8a7740_io_desc[] __initdata = {
43 /*
44 * for CPGA/INTC/PFC
45 * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
46 */
47 {
48 .virtual = 0xe6000000,
49 .pfn = __phys_to_pfn(0xe6000000),
50 .length = 160 << 20,
51 .type = MT_DEVICE_NONSHARED
52 },
53#ifdef CONFIG_CACHE_L2X0
54 /*
55 * for l2x0_init()
56 * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
57 */
58 {
59 .virtual = 0xf0002000,
60 .pfn = __phys_to_pfn(0xf0100000),
61 .length = PAGE_SIZE,
62 .type = MT_DEVICE_NONSHARED
63 },
64#endif
65};
66
67void __init r8a7740_map_io(void)
68{
69 iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc));
70}
71
Laurent Pinchart02b01ad2012-12-15 23:51:25 +010072/* PFC */
73static struct resource r8a7740_pfc_resources[] = {
74 [0] = {
75 .start = 0xe6050000,
76 .end = 0xe6057fff,
77 .flags = IORESOURCE_MEM,
78 },
79 [1] = {
80 .start = 0xe605800c,
81 .end = 0xe605802b,
82 .flags = IORESOURCE_MEM,
83 }
84};
85
86static struct platform_device r8a7740_pfc_device = {
87 .name = "pfc-r8a7740",
88 .id = -1,
89 .resource = r8a7740_pfc_resources,
90 .num_resources = ARRAY_SIZE(r8a7740_pfc_resources),
91};
92
93void __init r8a7740_pinmux_init(void)
94{
95 platform_device_register(&r8a7740_pfc_device);
96}
97
Bastian Hecht0b7d7822013-03-27 14:54:04 +010098static struct renesas_intc_irqpin_config irqpin0_platform_data = {
99 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
100};
101
102static struct resource irqpin0_resources[] = {
103 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
104 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
105 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
106 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
107 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
108 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ0 */
109 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ1 */
110 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ2 */
111 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ3 */
112 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ4 */
113 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ5 */
114 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ6 */
115 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ7 */
116};
117
118static struct platform_device irqpin0_device = {
119 .name = "renesas_intc_irqpin",
120 .id = 0,
121 .resource = irqpin0_resources,
122 .num_resources = ARRAY_SIZE(irqpin0_resources),
123 .dev = {
124 .platform_data = &irqpin0_platform_data,
125 },
126};
127
128static struct renesas_intc_irqpin_config irqpin1_platform_data = {
129 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
130};
131
132static struct resource irqpin1_resources[] = {
133 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
134 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
135 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
136 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
137 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
138 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ8 */
139 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ9 */
140 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ10 */
141 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ11 */
142 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ12 */
143 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ13 */
144 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ14 */
145 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ15 */
146};
147
148static struct platform_device irqpin1_device = {
149 .name = "renesas_intc_irqpin",
150 .id = 1,
151 .resource = irqpin1_resources,
152 .num_resources = ARRAY_SIZE(irqpin1_resources),
153 .dev = {
154 .platform_data = &irqpin1_platform_data,
155 },
156};
157
158static struct renesas_intc_irqpin_config irqpin2_platform_data = {
159 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
160};
161
162static struct resource irqpin2_resources[] = {
163 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
164 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI30A */
165 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ30A */
166 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK30A */
167 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR30A */
168 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ16 */
169 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ17 */
170 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ18 */
171 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ19 */
172 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ20 */
173 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ21 */
174 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ22 */
175 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ23 */
176};
177
178static struct platform_device irqpin2_device = {
179 .name = "renesas_intc_irqpin",
180 .id = 2,
181 .resource = irqpin2_resources,
182 .num_resources = ARRAY_SIZE(irqpin2_resources),
183 .dev = {
184 .platform_data = &irqpin2_platform_data,
185 },
186};
187
188static struct renesas_intc_irqpin_config irqpin3_platform_data = {
189 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
190};
191
192static struct resource irqpin3_resources[] = {
193 DEFINE_RES_MEM(0xe690000c, 4), /* ICR3A */
194 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
195 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
196 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
197 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
198 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ24 */
199 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ25 */
200 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ26 */
201 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ27 */
202 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ28 */
203 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ29 */
204 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ30 */
205 DEFINE_RES_IRQ(gic_spi(149)), /* IRQ31 */
206};
207
208static struct platform_device irqpin3_device = {
209 .name = "renesas_intc_irqpin",
210 .id = 3,
211 .resource = irqpin3_resources,
212 .num_resources = ARRAY_SIZE(irqpin3_resources),
213 .dev = {
214 .platform_data = &irqpin3_platform_data,
215 },
216};
217
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800218/* SCIFA0 */
219static struct plat_sci_port scif0_platform_data = {
220 .mapbase = 0xe6c40000,
221 .flags = UPF_BOOT_AUTOCONF,
222 .scscr = SCSCR_RE | SCSCR_TE,
223 .scbrr_algo_id = SCBRR_ALGO_4,
224 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100225 .irqs = SCIx_IRQ_MUXED(gic_spi(100)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800226};
227
228static struct platform_device scif0_device = {
229 .name = "sh-sci",
230 .id = 0,
231 .dev = {
232 .platform_data = &scif0_platform_data,
233 },
234};
235
236/* SCIFA1 */
237static struct plat_sci_port scif1_platform_data = {
238 .mapbase = 0xe6c50000,
239 .flags = UPF_BOOT_AUTOCONF,
240 .scscr = SCSCR_RE | SCSCR_TE,
241 .scbrr_algo_id = SCBRR_ALGO_4,
242 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100243 .irqs = SCIx_IRQ_MUXED(gic_spi(101)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800244};
245
246static struct platform_device scif1_device = {
247 .name = "sh-sci",
248 .id = 1,
249 .dev = {
250 .platform_data = &scif1_platform_data,
251 },
252};
253
254/* SCIFA2 */
255static struct plat_sci_port scif2_platform_data = {
256 .mapbase = 0xe6c60000,
257 .flags = UPF_BOOT_AUTOCONF,
258 .scscr = SCSCR_RE | SCSCR_TE,
259 .scbrr_algo_id = SCBRR_ALGO_4,
260 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100261 .irqs = SCIx_IRQ_MUXED(gic_spi(102)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800262};
263
264static struct platform_device scif2_device = {
265 .name = "sh-sci",
266 .id = 2,
267 .dev = {
268 .platform_data = &scif2_platform_data,
269 },
270};
271
272/* SCIFA3 */
273static struct plat_sci_port scif3_platform_data = {
274 .mapbase = 0xe6c70000,
275 .flags = UPF_BOOT_AUTOCONF,
276 .scscr = SCSCR_RE | SCSCR_TE,
277 .scbrr_algo_id = SCBRR_ALGO_4,
278 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100279 .irqs = SCIx_IRQ_MUXED(gic_spi(103)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800280};
281
282static struct platform_device scif3_device = {
283 .name = "sh-sci",
284 .id = 3,
285 .dev = {
286 .platform_data = &scif3_platform_data,
287 },
288};
289
290/* SCIFA4 */
291static struct plat_sci_port scif4_platform_data = {
292 .mapbase = 0xe6c80000,
293 .flags = UPF_BOOT_AUTOCONF,
294 .scscr = SCSCR_RE | SCSCR_TE,
295 .scbrr_algo_id = SCBRR_ALGO_4,
296 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100297 .irqs = SCIx_IRQ_MUXED(gic_spi(104)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800298};
299
300static struct platform_device scif4_device = {
301 .name = "sh-sci",
302 .id = 4,
303 .dev = {
304 .platform_data = &scif4_platform_data,
305 },
306};
307
308/* SCIFA5 */
309static struct plat_sci_port scif5_platform_data = {
310 .mapbase = 0xe6cb0000,
311 .flags = UPF_BOOT_AUTOCONF,
312 .scscr = SCSCR_RE | SCSCR_TE,
313 .scbrr_algo_id = SCBRR_ALGO_4,
314 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100315 .irqs = SCIx_IRQ_MUXED(gic_spi(105)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800316};
317
318static struct platform_device scif5_device = {
319 .name = "sh-sci",
320 .id = 5,
321 .dev = {
322 .platform_data = &scif5_platform_data,
323 },
324};
325
326/* SCIFA6 */
327static struct plat_sci_port scif6_platform_data = {
328 .mapbase = 0xe6cc0000,
329 .flags = UPF_BOOT_AUTOCONF,
330 .scscr = SCSCR_RE | SCSCR_TE,
331 .scbrr_algo_id = SCBRR_ALGO_4,
332 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100333 .irqs = SCIx_IRQ_MUXED(gic_spi(106)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800334};
335
336static struct platform_device scif6_device = {
337 .name = "sh-sci",
338 .id = 6,
339 .dev = {
340 .platform_data = &scif6_platform_data,
341 },
342};
343
344/* SCIFA7 */
345static struct plat_sci_port scif7_platform_data = {
346 .mapbase = 0xe6cd0000,
347 .flags = UPF_BOOT_AUTOCONF,
348 .scscr = SCSCR_RE | SCSCR_TE,
349 .scbrr_algo_id = SCBRR_ALGO_4,
350 .type = PORT_SCIFA,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100351 .irqs = SCIx_IRQ_MUXED(gic_spi(107)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800352};
353
354static struct platform_device scif7_device = {
355 .name = "sh-sci",
356 .id = 7,
357 .dev = {
358 .platform_data = &scif7_platform_data,
359 },
360};
361
362/* SCIFB */
363static struct plat_sci_port scifb_platform_data = {
364 .mapbase = 0xe6c30000,
365 .flags = UPF_BOOT_AUTOCONF,
366 .scscr = SCSCR_RE | SCSCR_TE,
367 .scbrr_algo_id = SCBRR_ALGO_4,
368 .type = PORT_SCIFB,
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100369 .irqs = SCIx_IRQ_MUXED(gic_spi(108)),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800370};
371
372static struct platform_device scifb_device = {
373 .name = "sh-sci",
374 .id = 8,
375 .dev = {
376 .platform_data = &scifb_platform_data,
377 },
378};
379
380/* CMT */
381static struct sh_timer_config cmt10_platform_data = {
382 .name = "CMT10",
383 .channel_offset = 0x10,
384 .timer_bit = 0,
385 .clockevent_rating = 125,
386 .clocksource_rating = 125,
387};
388
389static struct resource cmt10_resources[] = {
390 [0] = {
391 .name = "CMT10",
392 .start = 0xe6138010,
393 .end = 0xe613801b,
394 .flags = IORESOURCE_MEM,
395 },
396 [1] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100397 .start = gic_spi(58),
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800398 .flags = IORESOURCE_IRQ,
399 },
400};
401
402static struct platform_device cmt10_device = {
403 .name = "sh_cmt",
404 .id = 10,
405 .dev = {
406 .platform_data = &cmt10_platform_data,
407 },
408 .resource = cmt10_resources,
409 .num_resources = ARRAY_SIZE(cmt10_resources),
410};
411
Kuninori Morimotoe67d7af2012-12-12 02:08:09 -0800412/* TMU */
413static struct sh_timer_config tmu00_platform_data = {
414 .name = "TMU00",
415 .channel_offset = 0x4,
416 .timer_bit = 0,
417 .clockevent_rating = 200,
418};
419
420static struct resource tmu00_resources[] = {
421 [0] = {
422 .name = "TMU00",
423 .start = 0xfff80008,
424 .end = 0xfff80014 - 1,
425 .flags = IORESOURCE_MEM,
426 },
427 [1] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100428 .start = gic_spi(198),
Kuninori Morimotoe67d7af2012-12-12 02:08:09 -0800429 .flags = IORESOURCE_IRQ,
430 },
431};
432
433static struct platform_device tmu00_device = {
434 .name = "sh_tmu",
435 .id = 0,
436 .dev = {
437 .platform_data = &tmu00_platform_data,
438 },
439 .resource = tmu00_resources,
440 .num_resources = ARRAY_SIZE(tmu00_resources),
441};
442
443static struct sh_timer_config tmu01_platform_data = {
444 .name = "TMU01",
445 .channel_offset = 0x10,
446 .timer_bit = 1,
447 .clocksource_rating = 200,
448};
449
450static struct resource tmu01_resources[] = {
451 [0] = {
452 .name = "TMU01",
453 .start = 0xfff80014,
454 .end = 0xfff80020 - 1,
455 .flags = IORESOURCE_MEM,
456 },
457 [1] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100458 .start = gic_spi(199),
Kuninori Morimotoe67d7af2012-12-12 02:08:09 -0800459 .flags = IORESOURCE_IRQ,
460 },
461};
462
463static struct platform_device tmu01_device = {
464 .name = "sh_tmu",
465 .id = 1,
466 .dev = {
467 .platform_data = &tmu01_platform_data,
468 },
469 .resource = tmu01_resources,
470 .num_resources = ARRAY_SIZE(tmu01_resources),
471};
472
473static struct sh_timer_config tmu02_platform_data = {
474 .name = "TMU02",
475 .channel_offset = 0x1C,
476 .timer_bit = 2,
477 .clocksource_rating = 200,
478};
479
480static struct resource tmu02_resources[] = {
481 [0] = {
482 .name = "TMU02",
483 .start = 0xfff80020,
484 .end = 0xfff8002C - 1,
485 .flags = IORESOURCE_MEM,
486 },
487 [1] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100488 .start = gic_spi(200),
Kuninori Morimotoe67d7af2012-12-12 02:08:09 -0800489 .flags = IORESOURCE_IRQ,
490 },
491};
492
493static struct platform_device tmu02_device = {
494 .name = "sh_tmu",
495 .id = 2,
496 .dev = {
497 .platform_data = &tmu02_platform_data,
498 },
499 .resource = tmu02_resources,
500 .num_resources = ARRAY_SIZE(tmu02_resources),
501};
502
Hideki EIRAKUf671e022013-01-21 19:54:29 +0900503/* IPMMUI (an IPMMU module for ICB/LMB) */
504static struct resource ipmmu_resources[] = {
505 [0] = {
506 .name = "IPMMUI",
507 .start = 0xfe951000,
508 .end = 0xfe9510ff,
509 .flags = IORESOURCE_MEM,
510 },
511};
512
513static const char * const ipmmu_dev_names[] = {
514 "sh_mobile_lcdc_fb.0",
515 "sh_mobile_lcdc_fb.1",
516 "sh_mobile_ceu.0",
517};
518
519static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
520 .dev_names = ipmmu_dev_names,
521 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
522};
523
524static struct platform_device ipmmu_device = {
525 .name = "ipmmu",
526 .id = -1,
527 .dev = {
528 .platform_data = &ipmmu_platform_data,
529 },
530 .resource = ipmmu_resources,
531 .num_resources = ARRAY_SIZE(ipmmu_resources),
532};
533
Bastian Hecht744fdc82013-04-17 12:34:05 +0200534static struct platform_device *r8a7740_devices_dt[] __initdata = {
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800535 &scif0_device,
536 &scif1_device,
537 &scif2_device,
538 &scif3_device,
539 &scif4_device,
540 &scif5_device,
541 &scif6_device,
542 &scif7_device,
543 &scifb_device,
544 &cmt10_device,
Bastian Hecht744fdc82013-04-17 12:34:05 +0200545};
546
547static struct platform_device *r8a7740_early_devices[] __initdata = {
548 &irqpin0_device,
549 &irqpin1_device,
550 &irqpin2_device,
551 &irqpin3_device,
Kuninori Morimotoe67d7af2012-12-12 02:08:09 -0800552 &tmu00_device,
553 &tmu01_device,
554 &tmu02_device,
Hideki EIRAKUf671e022013-01-21 19:54:29 +0900555 &ipmmu_device,
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800556};
557
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700558/* DMA */
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700559static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
560 {
Kuninori Morimotocb76eb82012-06-25 03:37:00 -0700561 .slave_id = SHDMA_SLAVE_SDHI0_TX,
562 .addr = 0xe6850030,
563 .chcr = CHCR_TX(XMIT_SZ_16BIT),
564 .mid_rid = 0xc1,
565 }, {
566 .slave_id = SHDMA_SLAVE_SDHI0_RX,
567 .addr = 0xe6850030,
568 .chcr = CHCR_RX(XMIT_SZ_16BIT),
569 .mid_rid = 0xc2,
570 }, {
571 .slave_id = SHDMA_SLAVE_SDHI1_TX,
572 .addr = 0xe6860030,
573 .chcr = CHCR_TX(XMIT_SZ_16BIT),
574 .mid_rid = 0xc9,
575 }, {
576 .slave_id = SHDMA_SLAVE_SDHI1_RX,
577 .addr = 0xe6860030,
578 .chcr = CHCR_RX(XMIT_SZ_16BIT),
579 .mid_rid = 0xca,
580 }, {
581 .slave_id = SHDMA_SLAVE_SDHI2_TX,
582 .addr = 0xe6870030,
583 .chcr = CHCR_TX(XMIT_SZ_16BIT),
584 .mid_rid = 0xcd,
585 }, {
586 .slave_id = SHDMA_SLAVE_SDHI2_RX,
587 .addr = 0xe6870030,
588 .chcr = CHCR_RX(XMIT_SZ_16BIT),
589 .mid_rid = 0xce,
590 }, {
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700591 .slave_id = SHDMA_SLAVE_FSIA_TX,
592 .addr = 0xfe1f0024,
593 .chcr = CHCR_TX(XMIT_SZ_32BIT),
594 .mid_rid = 0xb1,
595 }, {
596 .slave_id = SHDMA_SLAVE_FSIA_RX,
597 .addr = 0xfe1f0020,
598 .chcr = CHCR_RX(XMIT_SZ_32BIT),
599 .mid_rid = 0xb2,
600 }, {
601 .slave_id = SHDMA_SLAVE_FSIB_TX,
602 .addr = 0xfe1f0064,
603 .chcr = CHCR_TX(XMIT_SZ_32BIT),
604 .mid_rid = 0xb5,
605 },
606};
607
608#define DMA_CHANNEL(a, b, c) \
609{ \
610 .offset = a, \
611 .dmars = b, \
612 .dmars_bit = c, \
613 .chclr_offset = (0x220 - 0x20) + a \
614}
615
616static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
617 DMA_CHANNEL(0x00, 0, 0),
618 DMA_CHANNEL(0x10, 0, 8),
619 DMA_CHANNEL(0x20, 4, 0),
620 DMA_CHANNEL(0x30, 4, 8),
621 DMA_CHANNEL(0x50, 8, 0),
622 DMA_CHANNEL(0x60, 8, 8),
623};
624
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700625static struct sh_dmae_pdata dma_platform_data = {
626 .slave = r8a7740_dmae_slaves,
627 .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
628 .channel = r8a7740_dmae_channels,
629 .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
Kuninori Morimotod7de9382012-06-25 03:43:10 -0700630 .ts_low_shift = TS_LOW_SHIFT,
631 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
632 .ts_high_shift = TS_HI_SHIFT,
633 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
634 .ts_shift = dma_ts_shift,
635 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700636 .dmaor_init = DMAOR_DME,
637 .chclr_present = 1,
638};
639
640/* Resource order important! */
641static struct resource r8a7740_dmae0_resources[] = {
642 {
643 /* Channel registers and DMAOR */
644 .start = 0xfe008020,
645 .end = 0xfe00828f,
646 .flags = IORESOURCE_MEM,
647 },
648 {
649 /* DMARSx */
650 .start = 0xfe009000,
651 .end = 0xfe00900b,
652 .flags = IORESOURCE_MEM,
653 },
654 {
655 .name = "error_irq",
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100656 .start = gic_spi(34),
657 .end = gic_spi(34),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700658 .flags = IORESOURCE_IRQ,
659 },
660 {
661 /* IRQ for channels 0-5 */
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100662 .start = gic_spi(28),
663 .end = gic_spi(33),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700664 .flags = IORESOURCE_IRQ,
665 },
666};
667
668/* Resource order important! */
669static struct resource r8a7740_dmae1_resources[] = {
670 {
671 /* Channel registers and DMAOR */
672 .start = 0xfe018020,
673 .end = 0xfe01828f,
674 .flags = IORESOURCE_MEM,
675 },
676 {
677 /* DMARSx */
678 .start = 0xfe019000,
679 .end = 0xfe01900b,
680 .flags = IORESOURCE_MEM,
681 },
682 {
683 .name = "error_irq",
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100684 .start = gic_spi(41),
685 .end = gic_spi(41),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700686 .flags = IORESOURCE_IRQ,
687 },
688 {
689 /* IRQ for channels 0-5 */
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100690 .start = gic_spi(35),
691 .end = gic_spi(40),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700692 .flags = IORESOURCE_IRQ,
693 },
694};
695
696/* Resource order important! */
697static struct resource r8a7740_dmae2_resources[] = {
698 {
699 /* Channel registers and DMAOR */
700 .start = 0xfe028020,
701 .end = 0xfe02828f,
702 .flags = IORESOURCE_MEM,
703 },
704 {
705 /* DMARSx */
706 .start = 0xfe029000,
707 .end = 0xfe02900b,
708 .flags = IORESOURCE_MEM,
709 },
710 {
711 .name = "error_irq",
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100712 .start = gic_spi(48),
713 .end = gic_spi(48),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700714 .flags = IORESOURCE_IRQ,
715 },
716 {
717 /* IRQ for channels 0-5 */
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100718 .start = gic_spi(42),
719 .end = gic_spi(47),
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700720 .flags = IORESOURCE_IRQ,
721 },
722};
723
724static struct platform_device dma0_device = {
725 .name = "sh-dma-engine",
726 .id = 0,
727 .resource = r8a7740_dmae0_resources,
728 .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
729 .dev = {
730 .platform_data = &dma_platform_data,
731 },
732};
733
734static struct platform_device dma1_device = {
735 .name = "sh-dma-engine",
736 .id = 1,
737 .resource = r8a7740_dmae1_resources,
738 .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
739 .dev = {
740 .platform_data = &dma_platform_data,
741 },
742};
743
744static struct platform_device dma2_device = {
745 .name = "sh-dma-engine",
746 .id = 2,
747 .resource = r8a7740_dmae2_resources,
748 .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
749 .dev = {
750 .platform_data = &dma_platform_data,
751 },
752};
753
Kuninori Morimotodbf382e2012-06-25 03:37:10 -0700754/* USB-DMAC */
Kuninori Morimotodbf382e2012-06-25 03:37:10 -0700755static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
756 {
757 .offset = 0,
758 }, {
759 .offset = 0x20,
760 },
761};
762
Kuninori Morimotodbf382e2012-06-25 03:37:10 -0700763static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
764 {
765 .slave_id = SHDMA_SLAVE_USBHS_TX,
766 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
767 }, {
768 .slave_id = SHDMA_SLAVE_USBHS_RX,
769 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
770 },
771};
772
773static struct sh_dmae_pdata usb_dma_platform_data = {
774 .slave = r8a7740_usb_dma_slaves,
775 .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
776 .channel = r8a7740_usb_dma_channels,
777 .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
Kuninori Morimotod7de9382012-06-25 03:43:10 -0700778 .ts_low_shift = USBTS_LOW_SHIFT,
779 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
780 .ts_high_shift = USBTS_HI_SHIFT,
781 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
Kuninori Morimotodbf382e2012-06-25 03:37:10 -0700782 .ts_shift = dma_usbts_shift,
783 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
784 .dmaor_init = DMAOR_DME,
785 .chcr_offset = 0x14,
786 .chcr_ie_bit = 1 << 5,
787 .dmaor_is_32bit = 1,
788 .needs_tend_set = 1,
789 .no_dmars = 1,
790 .slave_only = 1,
791};
792
793static struct resource r8a7740_usb_dma_resources[] = {
794 {
795 /* Channel registers and DMAOR */
796 .start = 0xe68a0020,
797 .end = 0xe68a0064 - 1,
798 .flags = IORESOURCE_MEM,
799 },
800 {
801 /* VCR/SWR/DMICR */
802 .start = 0xe68a0000,
803 .end = 0xe68a0014 - 1,
804 .flags = IORESOURCE_MEM,
805 },
806 {
807 /* IRQ for channels */
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100808 .start = gic_spi(49),
809 .end = gic_spi(49),
Kuninori Morimotodbf382e2012-06-25 03:37:10 -0700810 .flags = IORESOURCE_IRQ,
811 },
812};
813
814static struct platform_device usb_dma_device = {
815 .name = "sh-dma-engine",
816 .id = 3,
817 .resource = r8a7740_usb_dma_resources,
818 .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
819 .dev = {
820 .platform_data = &usb_dma_platform_data,
821 },
822};
823
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800824/* I2C */
825static struct resource i2c0_resources[] = {
826 [0] = {
827 .name = "IIC0",
828 .start = 0xfff20000,
829 .end = 0xfff20425 - 1,
830 .flags = IORESOURCE_MEM,
831 },
832 [1] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100833 .start = gic_spi(201),
834 .end = gic_spi(204),
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800835 .flags = IORESOURCE_IRQ,
836 },
837};
838
839static struct resource i2c1_resources[] = {
840 [0] = {
841 .name = "IIC1",
842 .start = 0xe6c20000,
843 .end = 0xe6c20425 - 1,
844 .flags = IORESOURCE_MEM,
845 },
846 [1] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100847 .start = gic_spi(70), /* IIC1_ALI1 */
848 .end = gic_spi(73), /* IIC1_DTEI1 */
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800849 .flags = IORESOURCE_IRQ,
850 },
851};
852
853static struct platform_device i2c0_device = {
854 .name = "i2c-sh_mobile",
855 .id = 0,
856 .resource = i2c0_resources,
857 .num_resources = ARRAY_SIZE(i2c0_resources),
858};
859
860static struct platform_device i2c1_device = {
861 .name = "i2c-sh_mobile",
862 .id = 1,
863 .resource = i2c1_resources,
864 .num_resources = ARRAY_SIZE(i2c1_resources),
865};
866
Nobuhiro Iwamatsu86bc52e2012-09-14 13:27:13 +0900867static struct resource pmu_resources[] = {
868 [0] = {
Bastian Hecht0b7d7822013-03-27 14:54:04 +0100869 .start = gic_spi(83),
870 .end = gic_spi(83),
Nobuhiro Iwamatsu86bc52e2012-09-14 13:27:13 +0900871 .flags = IORESOURCE_IRQ,
872 },
873};
874
875static struct platform_device pmu_device = {
876 .name = "arm-pmu",
877 .id = -1,
878 .num_resources = ARRAY_SIZE(pmu_resources),
879 .resource = pmu_resources,
880};
881
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800882static struct platform_device *r8a7740_late_devices[] __initdata = {
883 &i2c0_device,
884 &i2c1_device,
Kuninori Morimoto643c3302012-06-25 03:36:49 -0700885 &dma0_device,
886 &dma1_device,
887 &dma2_device,
Kuninori Morimotodbf382e2012-06-25 03:37:10 -0700888 &usb_dma_device,
Nobuhiro Iwamatsu86bc52e2012-09-14 13:27:13 +0900889 &pmu_device,
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800890};
891
Kuninori Morimotod49679e2012-06-12 02:36:21 -0700892/*
893 * r8a7740 chip has lasting errata on MERAM buffer.
894 * this is work-around for it.
895 * see
896 * "Media RAM (MERAM)" on r8a7740 documentation
897 */
898#define MEBUFCNTR 0xFE950098
899void r8a7740_meram_workaround(void)
900{
901 void __iomem *reg;
902
903 reg = ioremap_nocache(MEBUFCNTR, 4);
904 if (reg) {
905 iowrite32(0x01600164, reg);
906 iounmap(reg);
907 }
908}
909
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800910#define ICCR 0x0004
911#define ICSTART 0x0070
912
913#define i2c_read(reg, offset) ioread8(reg + offset)
914#define i2c_write(reg, offset, data) iowrite8(data, reg + offset)
915
916/*
917 * r8a7740 chip has lasting errata on I2C I/O pad reset.
918 * this is work-around for it.
919 */
920static void r8a7740_i2c_workaround(struct platform_device *pdev)
921{
922 struct resource *res;
923 void __iomem *reg;
924
925 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
926 if (unlikely(!res)) {
927 pr_err("r8a7740 i2c workaround fail (cannot find resource)\n");
928 return;
929 }
930
931 reg = ioremap(res->start, resource_size(res));
932 if (unlikely(!reg)) {
933 pr_err("r8a7740 i2c workaround fail (cannot map IO)\n");
934 return;
935 }
936
937 i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80);
938 i2c_read(reg, ICCR); /* dummy read */
939
940 i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10);
941 i2c_read(reg, ICSTART); /* dummy read */
942
Kuninori Morimoto42287162012-04-13 02:41:06 -0700943 udelay(10);
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800944
945 i2c_write(reg, ICCR, 0x01);
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800946 i2c_write(reg, ICSTART, 0x00);
Kuninori Morimoto42287162012-04-13 02:41:06 -0700947
948 udelay(10);
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800949
950 i2c_write(reg, ICCR, 0x10);
Kuninori Morimoto42287162012-04-13 02:41:06 -0700951 udelay(10);
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800952 i2c_write(reg, ICCR, 0x00);
Kuninori Morimoto42287162012-04-13 02:41:06 -0700953 udelay(10);
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800954 i2c_write(reg, ICCR, 0x10);
Kuninori Morimoto42287162012-04-13 02:41:06 -0700955 udelay(10);
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800956
957 iounmap(reg);
958}
959
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800960void __init r8a7740_add_standard_devices(void)
961{
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800962 /* I2C work-around */
963 r8a7740_i2c_workaround(&i2c0_device);
964 r8a7740_i2c_workaround(&i2c1_device);
965
Rafael J. Wysocki7b567402012-08-07 01:13:37 +0200966 r8a7740_init_pm_domains();
Kuninori Morimoto84592932012-07-05 01:25:58 -0700967
968 /* add devices */
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800969 platform_add_devices(r8a7740_early_devices,
970 ARRAY_SIZE(r8a7740_early_devices));
Bastian Hecht744fdc82013-04-17 12:34:05 +0200971 platform_add_devices(r8a7740_devices_dt,
972 ARRAY_SIZE(r8a7740_devices_dt));
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -0800973 platform_add_devices(r8a7740_late_devices,
974 ARRAY_SIZE(r8a7740_late_devices));
Kuninori Morimoto802a5632012-07-05 01:26:31 -0700975
976 /* add devices to PM domain */
977
Rafael J. Wysocki8bdd9462012-08-07 01:07:01 +0200978 rmobile_add_device_to_domain("A3SP", &scif0_device);
979 rmobile_add_device_to_domain("A3SP", &scif1_device);
980 rmobile_add_device_to_domain("A3SP", &scif2_device);
981 rmobile_add_device_to_domain("A3SP", &scif3_device);
982 rmobile_add_device_to_domain("A3SP", &scif4_device);
983 rmobile_add_device_to_domain("A3SP", &scif5_device);
984 rmobile_add_device_to_domain("A3SP", &scif6_device);
985 rmobile_add_device_to_domain("A3SP", &scif7_device);
986 rmobile_add_device_to_domain("A3SP", &scifb_device);
987 rmobile_add_device_to_domain("A3SP", &i2c1_device);
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800988}
989
990void __init r8a7740_add_early_devices(void)
991{
992 early_platform_add_devices(r8a7740_early_devices,
993 ARRAY_SIZE(r8a7740_early_devices));
Bastian Hecht744fdc82013-04-17 12:34:05 +0200994 early_platform_add_devices(r8a7740_devices_dt,
995 ARRAY_SIZE(r8a7740_devices_dt));
Magnus Dammd3ab7222012-02-29 21:37:35 +0900996
997 /* setup early console here as well */
998 shmobile_setup_console();
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -0800999}
Magnus Damm755d57b2012-07-06 17:08:07 +09001000
1001#ifdef CONFIG_USE_OF
1002
Magnus Damm755d57b2012-07-06 17:08:07 +09001003static const struct of_dev_auxdata r8a7740_auxdata_lookup[] __initconst = {
1004 { }
1005};
1006
1007void __init r8a7740_add_standard_devices_dt(void)
1008{
Bastian Hecht744fdc82013-04-17 12:34:05 +02001009 platform_add_devices(r8a7740_devices_dt,
1010 ARRAY_SIZE(r8a7740_devices_dt));
Magnus Damm755d57b2012-07-06 17:08:07 +09001011 of_platform_populate(NULL, of_default_bus_match_table,
1012 r8a7740_auxdata_lookup, NULL);
1013}
1014
Bastian Hecht744fdc82013-04-17 12:34:05 +02001015void __init r8a7740_init_delay(void)
1016{
1017 shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
1018};
1019
1020static void __init r8a7740_generic_init(void)
1021{
1022 r8a7740_clock_init(0);
1023 r8a7740_add_standard_devices_dt();
1024}
1025
Magnus Damm755d57b2012-07-06 17:08:07 +09001026static const char *r8a7740_boards_compat_dt[] __initdata = {
1027 "renesas,r8a7740",
1028 NULL,
1029};
1030
Kuninori Morimotoa41acc42012-10-21 22:15:13 -07001031DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
Magnus Damm755d57b2012-07-06 17:08:07 +09001032 .map_io = r8a7740_map_io,
Bastian Hecht744fdc82013-04-17 12:34:05 +02001033 .init_early = r8a7740_init_delay,
1034 .init_irq = r8a7740_init_irq_of,
1035 .init_machine = r8a7740_generic_init,
1036 .init_time = shmobile_timer_init,
Magnus Damm755d57b2012-07-06 17:08:07 +09001037 .dt_compat = r8a7740_boards_compat_dt,
1038MACHINE_END
1039
1040#endif /* CONFIG_USE_OF */