blob: 79a6040774a4d88a3bb694b0201a180dd51174a0 [file] [log] [blame]
Magnus Damm6d9598e2010-11-17 10:59:31 +00001/*
2 * sh73a0 processor support
3 *
4 * Copyright (C) 2010 Takashi Yoshii
5 * Copyright (C) 2010 Magnus Damm
6 * Copyright (C) 2008 Yoshihiro Shimoda
7 *
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.
11 *
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.
16 *
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
20 */
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/irq.h>
Simon Horman4eca1342013-02-15 21:38:20 +090025#include <linux/irqchip.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000026#include <linux/platform_device.h>
Simon Horman48609532012-11-21 22:00:15 +090027#include <linux/of_platform.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000028#include <linux/delay.h>
29#include <linux/input.h>
30#include <linux/io.h>
31#include <linux/serial_sci.h>
Magnus Damm681e1b32011-05-24 10:37:16 +000032#include <linux/sh_dma.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000033#include <linux/sh_intc.h>
34#include <linux/sh_timer.h>
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +090035#include <linux/platform_data/sh_ipmmu.h>
Magnus Damm341eb542013-02-26 12:01:09 +090036#include <linux/platform_data/irq-renesas-intc-irqpin.h>
Kuninori Morimoto6088b422012-06-25 03:43:28 -070037#include <mach/dma-register.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000038#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060039#include <mach/irqs.h>
Magnus Damm681e1b32011-05-24 10:37:16 +000040#include <mach/sh73a0.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090041#include <mach/common.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000042#include <asm/mach-types.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090043#include <asm/mach/map.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000044#include <asm/mach/arch.h>
Magnus Damm3be26fd2012-03-06 17:36:45 +090045#include <asm/mach/time.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000046
Magnus Damm50e15c32012-02-29 21:37:27 +090047static struct map_desc sh73a0_io_desc[] __initdata = {
48 /* create a 1:1 entity map for 0xe6xxxxxx
49 * used by CPGA, INTC and PFC.
50 */
51 {
52 .virtual = 0xe6000000,
53 .pfn = __phys_to_pfn(0xe6000000),
54 .length = 256 << 20,
55 .type = MT_DEVICE_NONSHARED
56 },
57};
58
59void __init sh73a0_map_io(void)
60{
61 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
62}
63
Magnus Damm474f6752013-06-27 17:09:01 +090064/* PFC */
65static struct resource pfc_resources[] __initdata = {
66 DEFINE_RES_MEM(0xe6050000, 0x8000),
67 DEFINE_RES_MEM(0xe605801c, 0x000c),
Laurent Pinchart994d66a2012-12-15 23:51:28 +010068};
69
70void __init sh73a0_pinmux_init(void)
71{
Magnus Damm474f6752013-06-27 17:09:01 +090072 platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
73 ARRAY_SIZE(pfc_resources));
Laurent Pinchart994d66a2012-12-15 23:51:28 +010074}
75
Magnus Damm6d9598e2010-11-17 10:59:31 +000076static struct plat_sci_port scif0_platform_data = {
77 .mapbase = 0xe6c40000,
78 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090079 .scscr = SCSCR_RE | SCSCR_TE,
80 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +000081 .type = PORT_SCIFA,
82 .irqs = { gic_spi(72), gic_spi(72),
83 gic_spi(72), gic_spi(72) },
84};
85
86static struct platform_device scif0_device = {
87 .name = "sh-sci",
88 .id = 0,
89 .dev = {
90 .platform_data = &scif0_platform_data,
91 },
92};
93
94static struct plat_sci_port scif1_platform_data = {
95 .mapbase = 0xe6c50000,
96 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090097 .scscr = SCSCR_RE | SCSCR_TE,
98 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +000099 .type = PORT_SCIFA,
100 .irqs = { gic_spi(73), gic_spi(73),
101 gic_spi(73), gic_spi(73) },
102};
103
104static struct platform_device scif1_device = {
105 .name = "sh-sci",
106 .id = 1,
107 .dev = {
108 .platform_data = &scif1_platform_data,
109 },
110};
111
112static struct plat_sci_port scif2_platform_data = {
113 .mapbase = 0xe6c60000,
114 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900115 .scscr = SCSCR_RE | SCSCR_TE,
116 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000117 .type = PORT_SCIFA,
118 .irqs = { gic_spi(74), gic_spi(74),
119 gic_spi(74), gic_spi(74) },
120};
121
122static struct platform_device scif2_device = {
123 .name = "sh-sci",
124 .id = 2,
125 .dev = {
126 .platform_data = &scif2_platform_data,
127 },
128};
129
130static struct plat_sci_port scif3_platform_data = {
131 .mapbase = 0xe6c70000,
132 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900133 .scscr = SCSCR_RE | SCSCR_TE,
134 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000135 .type = PORT_SCIFA,
136 .irqs = { gic_spi(75), gic_spi(75),
137 gic_spi(75), gic_spi(75) },
138};
139
140static struct platform_device scif3_device = {
141 .name = "sh-sci",
142 .id = 3,
143 .dev = {
144 .platform_data = &scif3_platform_data,
145 },
146};
147
148static struct plat_sci_port scif4_platform_data = {
149 .mapbase = 0xe6c80000,
150 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900151 .scscr = SCSCR_RE | SCSCR_TE,
152 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000153 .type = PORT_SCIFA,
154 .irqs = { gic_spi(78), gic_spi(78),
155 gic_spi(78), gic_spi(78) },
156};
157
158static struct platform_device scif4_device = {
159 .name = "sh-sci",
160 .id = 4,
161 .dev = {
162 .platform_data = &scif4_platform_data,
163 },
164};
165
166static struct plat_sci_port scif5_platform_data = {
167 .mapbase = 0xe6cb0000,
168 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900169 .scscr = SCSCR_RE | SCSCR_TE,
170 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000171 .type = PORT_SCIFA,
172 .irqs = { gic_spi(79), gic_spi(79),
173 gic_spi(79), gic_spi(79) },
174};
175
176static struct platform_device scif5_device = {
177 .name = "sh-sci",
178 .id = 5,
179 .dev = {
180 .platform_data = &scif5_platform_data,
181 },
182};
183
184static struct plat_sci_port scif6_platform_data = {
185 .mapbase = 0xe6cc0000,
186 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900187 .scscr = SCSCR_RE | SCSCR_TE,
188 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000189 .type = PORT_SCIFA,
190 .irqs = { gic_spi(156), gic_spi(156),
191 gic_spi(156), gic_spi(156) },
192};
193
194static struct platform_device scif6_device = {
195 .name = "sh-sci",
196 .id = 6,
197 .dev = {
198 .platform_data = &scif6_platform_data,
199 },
200};
201
202static struct plat_sci_port scif7_platform_data = {
203 .mapbase = 0xe6cd0000,
204 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900205 .scscr = SCSCR_RE | SCSCR_TE,
206 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000207 .type = PORT_SCIFA,
208 .irqs = { gic_spi(143), gic_spi(143),
209 gic_spi(143), gic_spi(143) },
210};
211
212static struct platform_device scif7_device = {
213 .name = "sh-sci",
214 .id = 7,
215 .dev = {
216 .platform_data = &scif7_platform_data,
217 },
218};
219
220static struct plat_sci_port scif8_platform_data = {
221 .mapbase = 0xe6c30000,
222 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900223 .scscr = SCSCR_RE | SCSCR_TE,
224 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000225 .type = PORT_SCIFB,
226 .irqs = { gic_spi(80), gic_spi(80),
227 gic_spi(80), gic_spi(80) },
228};
229
230static struct platform_device scif8_device = {
231 .name = "sh-sci",
232 .id = 8,
233 .dev = {
234 .platform_data = &scif8_platform_data,
235 },
236};
237
238static struct sh_timer_config cmt10_platform_data = {
239 .name = "CMT10",
240 .channel_offset = 0x10,
241 .timer_bit = 0,
Simon Horman5600a842013-05-22 19:47:05 +0900242 .clockevent_rating = 80,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000243 .clocksource_rating = 125,
244};
245
246static struct resource cmt10_resources[] = {
247 [0] = {
248 .name = "CMT10",
249 .start = 0xe6138010,
250 .end = 0xe613801b,
251 .flags = IORESOURCE_MEM,
252 },
253 [1] = {
254 .start = gic_spi(65),
255 .flags = IORESOURCE_IRQ,
256 },
257};
258
259static struct platform_device cmt10_device = {
260 .name = "sh_cmt",
261 .id = 10,
262 .dev = {
263 .platform_data = &cmt10_platform_data,
264 },
265 .resource = cmt10_resources,
266 .num_resources = ARRAY_SIZE(cmt10_resources),
267};
268
Magnus Damm5010f3d2010-12-21 08:40:59 +0000269/* TMU */
270static struct sh_timer_config tmu00_platform_data = {
271 .name = "TMU00",
272 .channel_offset = 0x4,
273 .timer_bit = 0,
274 .clockevent_rating = 200,
275};
276
277static struct resource tmu00_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000278 [0] = DEFINE_RES_MEM_NAMED(0xfff60008, 0xc, "TMU00"),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000279 [1] = {
280 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
281 .flags = IORESOURCE_IRQ,
282 },
283};
284
285static struct platform_device tmu00_device = {
286 .name = "sh_tmu",
287 .id = 0,
288 .dev = {
289 .platform_data = &tmu00_platform_data,
290 },
291 .resource = tmu00_resources,
292 .num_resources = ARRAY_SIZE(tmu00_resources),
293};
294
295static struct sh_timer_config tmu01_platform_data = {
296 .name = "TMU01",
297 .channel_offset = 0x10,
298 .timer_bit = 1,
299 .clocksource_rating = 200,
300};
301
302static struct resource tmu01_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000303 [0] = DEFINE_RES_MEM_NAMED(0xfff60014, 0xc, "TMU00"),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000304 [1] = {
305 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
306 .flags = IORESOURCE_IRQ,
307 },
308};
309
310static struct platform_device tmu01_device = {
311 .name = "sh_tmu",
312 .id = 1,
313 .dev = {
314 .platform_data = &tmu01_platform_data,
315 },
316 .resource = tmu01_resources,
317 .num_resources = ARRAY_SIZE(tmu01_resources),
318};
319
Yoshii Takashib028f942010-11-19 13:20:45 +0000320static struct resource i2c0_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000321 [0] = DEFINE_RES_MEM_NAMED(0xe6820000, 0x426, "IIC0"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000322 [1] = {
323 .start = gic_spi(167),
324 .end = gic_spi(170),
325 .flags = IORESOURCE_IRQ,
326 },
327};
328
329static struct resource i2c1_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000330 [0] = DEFINE_RES_MEM_NAMED(0xe6822000, 0x426, "IIC1"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000331 [1] = {
332 .start = gic_spi(51),
333 .end = gic_spi(54),
334 .flags = IORESOURCE_IRQ,
335 },
336};
337
338static struct resource i2c2_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000339 [0] = DEFINE_RES_MEM_NAMED(0xe6824000, 0x426, "IIC2"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000340 [1] = {
341 .start = gic_spi(171),
342 .end = gic_spi(174),
343 .flags = IORESOURCE_IRQ,
344 },
345};
346
347static struct resource i2c3_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000348 [0] = DEFINE_RES_MEM_NAMED(0xe6826000, 0x426, "IIC3"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000349 [1] = {
350 .start = gic_spi(183),
351 .end = gic_spi(186),
352 .flags = IORESOURCE_IRQ,
353 },
354};
355
356static struct resource i2c4_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000357 [0] = DEFINE_RES_MEM_NAMED(0xe6828000, 0x426, "IIC4"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000358 [1] = {
359 .start = gic_spi(187),
360 .end = gic_spi(190),
361 .flags = IORESOURCE_IRQ,
362 },
363};
364
365static struct platform_device i2c0_device = {
366 .name = "i2c-sh_mobile",
367 .id = 0,
368 .resource = i2c0_resources,
369 .num_resources = ARRAY_SIZE(i2c0_resources),
370};
371
372static struct platform_device i2c1_device = {
373 .name = "i2c-sh_mobile",
374 .id = 1,
375 .resource = i2c1_resources,
376 .num_resources = ARRAY_SIZE(i2c1_resources),
377};
378
379static struct platform_device i2c2_device = {
380 .name = "i2c-sh_mobile",
381 .id = 2,
382 .resource = i2c2_resources,
383 .num_resources = ARRAY_SIZE(i2c2_resources),
384};
385
386static struct platform_device i2c3_device = {
387 .name = "i2c-sh_mobile",
388 .id = 3,
389 .resource = i2c3_resources,
390 .num_resources = ARRAY_SIZE(i2c3_resources),
391};
392
393static struct platform_device i2c4_device = {
394 .name = "i2c-sh_mobile",
395 .id = 4,
396 .resource = i2c4_resources,
397 .num_resources = ARRAY_SIZE(i2c4_resources),
398};
399
Magnus Damm681e1b32011-05-24 10:37:16 +0000400static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
401 {
402 .slave_id = SHDMA_SLAVE_SCIF0_TX,
403 .addr = 0xe6c40020,
404 .chcr = CHCR_TX(XMIT_SZ_8BIT),
405 .mid_rid = 0x21,
406 }, {
407 .slave_id = SHDMA_SLAVE_SCIF0_RX,
408 .addr = 0xe6c40024,
409 .chcr = CHCR_RX(XMIT_SZ_8BIT),
410 .mid_rid = 0x22,
411 }, {
412 .slave_id = SHDMA_SLAVE_SCIF1_TX,
413 .addr = 0xe6c50020,
414 .chcr = CHCR_TX(XMIT_SZ_8BIT),
415 .mid_rid = 0x25,
416 }, {
417 .slave_id = SHDMA_SLAVE_SCIF1_RX,
418 .addr = 0xe6c50024,
419 .chcr = CHCR_RX(XMIT_SZ_8BIT),
420 .mid_rid = 0x26,
421 }, {
422 .slave_id = SHDMA_SLAVE_SCIF2_TX,
423 .addr = 0xe6c60020,
424 .chcr = CHCR_TX(XMIT_SZ_8BIT),
425 .mid_rid = 0x29,
426 }, {
427 .slave_id = SHDMA_SLAVE_SCIF2_RX,
428 .addr = 0xe6c60024,
429 .chcr = CHCR_RX(XMIT_SZ_8BIT),
430 .mid_rid = 0x2a,
431 }, {
432 .slave_id = SHDMA_SLAVE_SCIF3_TX,
433 .addr = 0xe6c70020,
434 .chcr = CHCR_TX(XMIT_SZ_8BIT),
435 .mid_rid = 0x2d,
436 }, {
437 .slave_id = SHDMA_SLAVE_SCIF3_RX,
438 .addr = 0xe6c70024,
439 .chcr = CHCR_RX(XMIT_SZ_8BIT),
440 .mid_rid = 0x2e,
441 }, {
442 .slave_id = SHDMA_SLAVE_SCIF4_TX,
443 .addr = 0xe6c80020,
444 .chcr = CHCR_TX(XMIT_SZ_8BIT),
445 .mid_rid = 0x39,
446 }, {
447 .slave_id = SHDMA_SLAVE_SCIF4_RX,
448 .addr = 0xe6c80024,
449 .chcr = CHCR_RX(XMIT_SZ_8BIT),
450 .mid_rid = 0x3a,
451 }, {
452 .slave_id = SHDMA_SLAVE_SCIF5_TX,
453 .addr = 0xe6cb0020,
454 .chcr = CHCR_TX(XMIT_SZ_8BIT),
455 .mid_rid = 0x35,
456 }, {
457 .slave_id = SHDMA_SLAVE_SCIF5_RX,
458 .addr = 0xe6cb0024,
459 .chcr = CHCR_RX(XMIT_SZ_8BIT),
460 .mid_rid = 0x36,
461 }, {
462 .slave_id = SHDMA_SLAVE_SCIF6_TX,
463 .addr = 0xe6cc0020,
464 .chcr = CHCR_TX(XMIT_SZ_8BIT),
465 .mid_rid = 0x1d,
466 }, {
467 .slave_id = SHDMA_SLAVE_SCIF6_RX,
468 .addr = 0xe6cc0024,
469 .chcr = CHCR_RX(XMIT_SZ_8BIT),
470 .mid_rid = 0x1e,
471 }, {
472 .slave_id = SHDMA_SLAVE_SCIF7_TX,
473 .addr = 0xe6cd0020,
474 .chcr = CHCR_TX(XMIT_SZ_8BIT),
475 .mid_rid = 0x19,
476 }, {
477 .slave_id = SHDMA_SLAVE_SCIF7_RX,
478 .addr = 0xe6cd0024,
479 .chcr = CHCR_RX(XMIT_SZ_8BIT),
480 .mid_rid = 0x1a,
481 }, {
482 .slave_id = SHDMA_SLAVE_SCIF8_TX,
483 .addr = 0xe6c30040,
484 .chcr = CHCR_TX(XMIT_SZ_8BIT),
485 .mid_rid = 0x3d,
486 }, {
487 .slave_id = SHDMA_SLAVE_SCIF8_RX,
488 .addr = 0xe6c30060,
489 .chcr = CHCR_RX(XMIT_SZ_8BIT),
490 .mid_rid = 0x3e,
491 }, {
492 .slave_id = SHDMA_SLAVE_SDHI0_TX,
493 .addr = 0xee100030,
494 .chcr = CHCR_TX(XMIT_SZ_16BIT),
495 .mid_rid = 0xc1,
496 }, {
497 .slave_id = SHDMA_SLAVE_SDHI0_RX,
498 .addr = 0xee100030,
499 .chcr = CHCR_RX(XMIT_SZ_16BIT),
500 .mid_rid = 0xc2,
501 }, {
502 .slave_id = SHDMA_SLAVE_SDHI1_TX,
503 .addr = 0xee120030,
504 .chcr = CHCR_TX(XMIT_SZ_16BIT),
505 .mid_rid = 0xc9,
506 }, {
507 .slave_id = SHDMA_SLAVE_SDHI1_RX,
508 .addr = 0xee120030,
509 .chcr = CHCR_RX(XMIT_SZ_16BIT),
510 .mid_rid = 0xca,
511 }, {
512 .slave_id = SHDMA_SLAVE_SDHI2_TX,
513 .addr = 0xee140030,
514 .chcr = CHCR_TX(XMIT_SZ_16BIT),
515 .mid_rid = 0xcd,
516 }, {
517 .slave_id = SHDMA_SLAVE_SDHI2_RX,
518 .addr = 0xee140030,
519 .chcr = CHCR_RX(XMIT_SZ_16BIT),
520 .mid_rid = 0xce,
521 }, {
522 .slave_id = SHDMA_SLAVE_MMCIF_TX,
523 .addr = 0xe6bd0034,
524 .chcr = CHCR_TX(XMIT_SZ_32BIT),
525 .mid_rid = 0xd1,
526 }, {
527 .slave_id = SHDMA_SLAVE_MMCIF_RX,
528 .addr = 0xe6bd0034,
529 .chcr = CHCR_RX(XMIT_SZ_32BIT),
530 .mid_rid = 0xd2,
531 },
532};
533
534#define DMAE_CHANNEL(_offset) \
535 { \
536 .offset = _offset - 0x20, \
537 .dmars = _offset - 0x20 + 0x40, \
538 }
539
540static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
541 DMAE_CHANNEL(0x8000),
542 DMAE_CHANNEL(0x8080),
543 DMAE_CHANNEL(0x8100),
544 DMAE_CHANNEL(0x8180),
545 DMAE_CHANNEL(0x8200),
546 DMAE_CHANNEL(0x8280),
547 DMAE_CHANNEL(0x8300),
548 DMAE_CHANNEL(0x8380),
549 DMAE_CHANNEL(0x8400),
550 DMAE_CHANNEL(0x8480),
551 DMAE_CHANNEL(0x8500),
552 DMAE_CHANNEL(0x8580),
553 DMAE_CHANNEL(0x8600),
554 DMAE_CHANNEL(0x8680),
555 DMAE_CHANNEL(0x8700),
556 DMAE_CHANNEL(0x8780),
557 DMAE_CHANNEL(0x8800),
558 DMAE_CHANNEL(0x8880),
559 DMAE_CHANNEL(0x8900),
560 DMAE_CHANNEL(0x8980),
561};
562
Magnus Damm681e1b32011-05-24 10:37:16 +0000563static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
564 .slave = sh73a0_dmae_slaves,
565 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
566 .channel = sh73a0_dmae_channels,
567 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700568 .ts_low_shift = TS_LOW_SHIFT,
569 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
570 .ts_high_shift = TS_HI_SHIFT,
571 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
572 .ts_shift = dma_ts_shift,
573 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Magnus Damm681e1b32011-05-24 10:37:16 +0000574 .dmaor_init = DMAOR_DME,
575};
576
577static struct resource sh73a0_dmae_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000578 DEFINE_RES_MEM(0xfe000020, 0x89e0),
Magnus Damm681e1b32011-05-24 10:37:16 +0000579 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900580 .name = "error_irq",
Magnus Damm681e1b32011-05-24 10:37:16 +0000581 .start = gic_spi(129),
582 .end = gic_spi(129),
583 .flags = IORESOURCE_IRQ,
584 },
585 {
586 /* IRQ for channels 0-19 */
587 .start = gic_spi(109),
588 .end = gic_spi(128),
589 .flags = IORESOURCE_IRQ,
590 },
591};
592
593static struct platform_device dma0_device = {
594 .name = "sh-dma-engine",
595 .id = 0,
596 .resource = sh73a0_dmae_resources,
597 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
598 .dev = {
599 .platform_data = &sh73a0_dmae_platform_data,
600 },
601};
602
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700603/* MPDMAC */
604static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
605 {
606 .slave_id = SHDMA_SLAVE_FSI2A_RX,
607 .addr = 0xec230020,
608 .chcr = CHCR_RX(XMIT_SZ_32BIT),
609 .mid_rid = 0xd6, /* CHECK ME */
610 }, {
611 .slave_id = SHDMA_SLAVE_FSI2A_TX,
612 .addr = 0xec230024,
613 .chcr = CHCR_TX(XMIT_SZ_32BIT),
614 .mid_rid = 0xd5, /* CHECK ME */
615 }, {
616 .slave_id = SHDMA_SLAVE_FSI2C_RX,
617 .addr = 0xec230060,
618 .chcr = CHCR_RX(XMIT_SZ_32BIT),
619 .mid_rid = 0xda, /* CHECK ME */
620 }, {
621 .slave_id = SHDMA_SLAVE_FSI2C_TX,
622 .addr = 0xec230064,
623 .chcr = CHCR_TX(XMIT_SZ_32BIT),
624 .mid_rid = 0xd9, /* CHECK ME */
625 }, {
626 .slave_id = SHDMA_SLAVE_FSI2B_RX,
627 .addr = 0xec240020,
628 .chcr = CHCR_RX(XMIT_SZ_32BIT),
629 .mid_rid = 0x8e, /* CHECK ME */
630 }, {
631 .slave_id = SHDMA_SLAVE_FSI2B_TX,
632 .addr = 0xec240024,
633 .chcr = CHCR_RX(XMIT_SZ_32BIT),
634 .mid_rid = 0x8d, /* CHECK ME */
635 }, {
636 .slave_id = SHDMA_SLAVE_FSI2D_RX,
637 .addr = 0xec240060,
638 .chcr = CHCR_RX(XMIT_SZ_32BIT),
639 .mid_rid = 0x9a, /* CHECK ME */
640 },
641};
642
643#define MPDMA_CHANNEL(a, b, c) \
644{ \
645 .offset = a, \
646 .dmars = b, \
647 .dmars_bit = c, \
648 .chclr_offset = (0x220 - 0x20) + a \
649}
650
651static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
652 MPDMA_CHANNEL(0x00, 0, 0),
653 MPDMA_CHANNEL(0x10, 0, 8),
654 MPDMA_CHANNEL(0x20, 4, 0),
655 MPDMA_CHANNEL(0x30, 4, 8),
656 MPDMA_CHANNEL(0x50, 8, 0),
657 MPDMA_CHANNEL(0x70, 8, 8),
658};
659
660static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
661 .slave = sh73a0_mpdma_slaves,
662 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
663 .channel = sh73a0_mpdma_channels,
664 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700665 .ts_low_shift = TS_LOW_SHIFT,
666 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
667 .ts_high_shift = TS_HI_SHIFT,
668 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
669 .ts_shift = dma_ts_shift,
670 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700671 .dmaor_init = DMAOR_DME,
672 .chclr_present = 1,
673};
674
675/* Resource order important! */
676static struct resource sh73a0_mpdma_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000677 /* Channel registers and DMAOR */
678 DEFINE_RES_MEM(0xec618020, 0x270),
679 /* DMARSx */
680 DEFINE_RES_MEM(0xec619000, 0xc),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700681 {
682 .name = "error_irq",
683 .start = gic_spi(181),
684 .end = gic_spi(181),
685 .flags = IORESOURCE_IRQ,
686 },
687 {
688 /* IRQ for channels 0-5 */
689 .start = gic_spi(175),
690 .end = gic_spi(180),
691 .flags = IORESOURCE_IRQ,
692 },
693};
694
695static struct platform_device mpdma0_device = {
696 .name = "sh-dma-engine",
697 .id = 1,
698 .resource = sh73a0_mpdma_resources,
699 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
700 .dev = {
701 .platform_data = &sh73a0_mpdma_platform_data,
702 },
703};
704
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900705static struct resource pmu_resources[] = {
706 [0] = {
707 .start = gic_spi(55),
708 .end = gic_spi(55),
709 .flags = IORESOURCE_IRQ,
710 },
711 [1] = {
712 .start = gic_spi(56),
713 .end = gic_spi(56),
714 .flags = IORESOURCE_IRQ,
715 },
716};
717
718static struct platform_device pmu_device = {
719 .name = "arm-pmu",
720 .id = -1,
721 .num_resources = ARRAY_SIZE(pmu_resources),
722 .resource = pmu_resources,
723};
724
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900725/* an IPMMU module for ICB */
726static struct resource ipmmu_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000727 DEFINE_RES_MEM_NAMED(0xfe951000, 0x100, "IPMMU"),
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900728};
729
730static const char * const ipmmu_dev_names[] = {
731 "sh_mobile_lcdc_fb.0",
732};
733
734static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
735 .dev_names = ipmmu_dev_names,
736 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
737};
738
739static struct platform_device ipmmu_device = {
740 .name = "ipmmu",
741 .id = -1,
742 .dev = {
743 .platform_data = &ipmmu_platform_data,
744 },
745 .resource = ipmmu_resources,
746 .num_resources = ARRAY_SIZE(ipmmu_resources),
747};
748
Magnus Damm1461f8b2013-03-06 15:08:31 +0900749static struct renesas_intc_irqpin_config irqpin0_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900750 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
751};
752
753static struct resource irqpin0_resources[] = {
754 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
755 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
756 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
757 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
758 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
759 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
760 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
761 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
762 DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
763 DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
764 DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
765 DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
766 DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
767};
768
769static struct platform_device irqpin0_device = {
770 .name = "renesas_intc_irqpin",
771 .id = 0,
772 .resource = irqpin0_resources,
773 .num_resources = ARRAY_SIZE(irqpin0_resources),
774 .dev = {
775 .platform_data = &irqpin0_platform_data,
776 },
777};
778
Magnus Damm1461f8b2013-03-06 15:08:31 +0900779static struct renesas_intc_irqpin_config irqpin1_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900780 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
781 .control_parent = true, /* Disable spurious IRQ10 */
782};
783
784static struct resource irqpin1_resources[] = {
785 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
786 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
787 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
788 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
789 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
790 DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
791 DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
792 DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
793 DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
794 DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
795 DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
796 DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
797 DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
798};
799
800static struct platform_device irqpin1_device = {
801 .name = "renesas_intc_irqpin",
802 .id = 1,
803 .resource = irqpin1_resources,
804 .num_resources = ARRAY_SIZE(irqpin1_resources),
805 .dev = {
806 .platform_data = &irqpin1_platform_data,
807 },
808};
809
Magnus Damm1461f8b2013-03-06 15:08:31 +0900810static struct renesas_intc_irqpin_config irqpin2_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900811 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
812};
813
814static struct resource irqpin2_resources[] = {
815 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
816 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
817 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
818 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
819 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
820 DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
821 DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
822 DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
823 DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
824 DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
825 DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
826 DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
827 DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
828};
829
830static struct platform_device irqpin2_device = {
831 .name = "renesas_intc_irqpin",
832 .id = 2,
833 .resource = irqpin2_resources,
834 .num_resources = ARRAY_SIZE(irqpin2_resources),
835 .dev = {
836 .platform_data = &irqpin2_platform_data,
837 },
838};
839
Magnus Damm1461f8b2013-03-06 15:08:31 +0900840static struct renesas_intc_irqpin_config irqpin3_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900841 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
842};
843
844static struct resource irqpin3_resources[] = {
845 DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
846 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
847 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
848 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
849 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
850 DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
851 DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
852 DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
853 DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
854 DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
855 DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
856 DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
857 DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
858};
859
860static struct platform_device irqpin3_device = {
861 .name = "renesas_intc_irqpin",
862 .id = 3,
863 .resource = irqpin3_resources,
864 .num_resources = ARRAY_SIZE(irqpin3_resources),
865 .dev = {
866 .platform_data = &irqpin3_platform_data,
867 },
868};
869
Simon Horman3b00f932013-02-19 10:53:05 +0900870static struct platform_device *sh73a0_devices_dt[] __initdata = {
Magnus Damm6d9598e2010-11-17 10:59:31 +0000871 &scif0_device,
872 &scif1_device,
873 &scif2_device,
874 &scif3_device,
875 &scif4_device,
876 &scif5_device,
877 &scif6_device,
878 &scif7_device,
879 &scif8_device,
880 &cmt10_device,
Simon Horman48609532012-11-21 22:00:15 +0900881};
882
883static struct platform_device *sh73a0_early_devices[] __initdata = {
Magnus Damm5010f3d2010-12-21 08:40:59 +0000884 &tmu00_device,
885 &tmu01_device,
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900886 &ipmmu_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000887};
888
Yoshii Takashib028f942010-11-19 13:20:45 +0000889static struct platform_device *sh73a0_late_devices[] __initdata = {
890 &i2c0_device,
891 &i2c1_device,
892 &i2c2_device,
893 &i2c3_device,
894 &i2c4_device,
Magnus Damm681e1b32011-05-24 10:37:16 +0000895 &dma0_device,
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700896 &mpdma0_device,
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900897 &pmu_device,
Magnus Damm341eb542013-02-26 12:01:09 +0900898 &irqpin0_device,
899 &irqpin1_device,
900 &irqpin2_device,
901 &irqpin3_device,
Yoshii Takashib028f942010-11-19 13:20:45 +0000902};
903
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000904#define SRCR2 IOMEM(0xe61580b0)
Magnus Damm681e1b32011-05-24 10:37:16 +0000905
Magnus Damm6d9598e2010-11-17 10:59:31 +0000906void __init sh73a0_add_standard_devices(void)
907{
Magnus Damm681e1b32011-05-24 10:37:16 +0000908 /* Clear software reset bit on SY-DMAC module */
909 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
910
Simon Horman3b00f932013-02-19 10:53:05 +0900911 platform_add_devices(sh73a0_devices_dt,
912 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000913 platform_add_devices(sh73a0_early_devices,
914 ARRAY_SIZE(sh73a0_early_devices));
Yoshii Takashib028f942010-11-19 13:20:45 +0000915 platform_add_devices(sh73a0_late_devices,
916 ARRAY_SIZE(sh73a0_late_devices));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000917}
918
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900919void __init sh73a0_init_delay(void)
920{
921 shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
922}
923
Kuninori Morimotod6720002012-05-10 00:26:58 -0700924/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
925void __init __weak sh73a0_register_twd(void) { }
926
Stephen Warren6bb27d72012-11-08 12:40:59 -0700927void __init sh73a0_earlytimer_init(void)
Magnus Damm3be26fd2012-03-06 17:36:45 +0900928{
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900929 sh73a0_init_delay();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900930 sh73a0_clock_init();
931 shmobile_earlytimer_init();
Kuninori Morimotod6720002012-05-10 00:26:58 -0700932 sh73a0_register_twd();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900933}
934
Magnus Damm6d9598e2010-11-17 10:59:31 +0000935void __init sh73a0_add_early_devices(void)
936{
Simon Horman3b00f932013-02-19 10:53:05 +0900937 early_platform_add_devices(sh73a0_devices_dt,
938 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000939 early_platform_add_devices(sh73a0_early_devices,
940 ARRAY_SIZE(sh73a0_early_devices));
Magnus Damm50e15c32012-02-29 21:37:27 +0900941
942 /* setup early console here as well */
943 shmobile_setup_console();
Magnus Damm6d9598e2010-11-17 10:59:31 +0000944}
Simon Horman48609532012-11-21 22:00:15 +0900945
946#ifdef CONFIG_USE_OF
947
Simon Horman48609532012-11-21 22:00:15 +0900948static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
949 {},
950};
951
952void __init sh73a0_add_standard_devices_dt(void)
953{
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200954 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
955
Simon Horman48609532012-11-21 22:00:15 +0900956 /* clocks are setup late during boot in the case of DT */
957 sh73a0_clock_init();
958
Simon Horman3b00f932013-02-19 10:53:05 +0900959 platform_add_devices(sh73a0_devices_dt,
960 ARRAY_SIZE(sh73a0_devices_dt));
Simon Horman48609532012-11-21 22:00:15 +0900961 of_platform_populate(NULL, of_default_bus_match_table,
962 sh73a0_auxdata_lookup, NULL);
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200963
964 /* Instantiate cpufreq-cpu0 */
965 platform_device_register_full(&devinfo);
Simon Horman48609532012-11-21 22:00:15 +0900966}
967
968static const char *sh73a0_boards_compat_dt[] __initdata = {
969 "renesas,sh73a0",
970 NULL,
971};
972
973DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
Simon Hormanf9989502013-02-15 21:38:20 +0900974 .smp = smp_ops(sh73a0_smp_ops),
Simon Horman48609532012-11-21 22:00:15 +0900975 .map_io = sh73a0_map_io,
Simon Horman3b00f932013-02-19 10:53:05 +0900976 .init_early = sh73a0_init_delay,
Simon Horman48609532012-11-21 22:00:15 +0900977 .nr_irqs = NR_IRQS_LEGACY,
Simon Horman4eca1342013-02-15 21:38:20 +0900978 .init_irq = irqchip_init,
Simon Horman48609532012-11-21 22:00:15 +0900979 .init_machine = sh73a0_add_standard_devices_dt,
Simon Horman48609532012-11-21 22:00:15 +0900980 .dt_compat = sh73a0_boards_compat_dt,
981MACHINE_END
982#endif /* CONFIG_USE_OF */