blob: c7630aaaa26078a05628301512151c93b779c3b0 [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>
Kuninori Morimoto6088b422012-06-25 03:43:28 -070036#include <mach/dma-register.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000037#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060038#include <mach/irqs.h>
Magnus Damm681e1b32011-05-24 10:37:16 +000039#include <mach/sh73a0.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090040#include <mach/common.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000041#include <asm/mach-types.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090042#include <asm/mach/map.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000043#include <asm/mach/arch.h>
Magnus Damm3be26fd2012-03-06 17:36:45 +090044#include <asm/mach/time.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000045
Magnus Damm50e15c32012-02-29 21:37:27 +090046static struct map_desc sh73a0_io_desc[] __initdata = {
47 /* create a 1:1 entity map for 0xe6xxxxxx
48 * used by CPGA, INTC and PFC.
49 */
50 {
51 .virtual = 0xe6000000,
52 .pfn = __phys_to_pfn(0xe6000000),
53 .length = 256 << 20,
54 .type = MT_DEVICE_NONSHARED
55 },
56};
57
58void __init sh73a0_map_io(void)
59{
60 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
61}
62
Laurent Pinchart994d66a2012-12-15 23:51:28 +010063static struct resource sh73a0_pfc_resources[] = {
64 [0] = {
65 .start = 0xe6050000,
66 .end = 0xe6057fff,
67 .flags = IORESOURCE_MEM,
68 },
69 [1] = {
70 .start = 0xe605801c,
71 .end = 0xe6058027,
72 .flags = IORESOURCE_MEM,
73 }
74};
75
76static struct platform_device sh73a0_pfc_device = {
77 .name = "pfc-sh73a0",
78 .id = -1,
79 .resource = sh73a0_pfc_resources,
80 .num_resources = ARRAY_SIZE(sh73a0_pfc_resources),
81};
82
83void __init sh73a0_pinmux_init(void)
84{
85 platform_device_register(&sh73a0_pfc_device);
86}
87
Magnus Damm6d9598e2010-11-17 10:59:31 +000088static struct plat_sci_port scif0_platform_data = {
89 .mapbase = 0xe6c40000,
90 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090091 .scscr = SCSCR_RE | SCSCR_TE,
92 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +000093 .type = PORT_SCIFA,
94 .irqs = { gic_spi(72), gic_spi(72),
95 gic_spi(72), gic_spi(72) },
96};
97
98static struct platform_device scif0_device = {
99 .name = "sh-sci",
100 .id = 0,
101 .dev = {
102 .platform_data = &scif0_platform_data,
103 },
104};
105
106static struct plat_sci_port scif1_platform_data = {
107 .mapbase = 0xe6c50000,
108 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900109 .scscr = SCSCR_RE | SCSCR_TE,
110 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000111 .type = PORT_SCIFA,
112 .irqs = { gic_spi(73), gic_spi(73),
113 gic_spi(73), gic_spi(73) },
114};
115
116static struct platform_device scif1_device = {
117 .name = "sh-sci",
118 .id = 1,
119 .dev = {
120 .platform_data = &scif1_platform_data,
121 },
122};
123
124static struct plat_sci_port scif2_platform_data = {
125 .mapbase = 0xe6c60000,
126 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900127 .scscr = SCSCR_RE | SCSCR_TE,
128 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000129 .type = PORT_SCIFA,
130 .irqs = { gic_spi(74), gic_spi(74),
131 gic_spi(74), gic_spi(74) },
132};
133
134static struct platform_device scif2_device = {
135 .name = "sh-sci",
136 .id = 2,
137 .dev = {
138 .platform_data = &scif2_platform_data,
139 },
140};
141
142static struct plat_sci_port scif3_platform_data = {
143 .mapbase = 0xe6c70000,
144 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900145 .scscr = SCSCR_RE | SCSCR_TE,
146 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000147 .type = PORT_SCIFA,
148 .irqs = { gic_spi(75), gic_spi(75),
149 gic_spi(75), gic_spi(75) },
150};
151
152static struct platform_device scif3_device = {
153 .name = "sh-sci",
154 .id = 3,
155 .dev = {
156 .platform_data = &scif3_platform_data,
157 },
158};
159
160static struct plat_sci_port scif4_platform_data = {
161 .mapbase = 0xe6c80000,
162 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900163 .scscr = SCSCR_RE | SCSCR_TE,
164 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000165 .type = PORT_SCIFA,
166 .irqs = { gic_spi(78), gic_spi(78),
167 gic_spi(78), gic_spi(78) },
168};
169
170static struct platform_device scif4_device = {
171 .name = "sh-sci",
172 .id = 4,
173 .dev = {
174 .platform_data = &scif4_platform_data,
175 },
176};
177
178static struct plat_sci_port scif5_platform_data = {
179 .mapbase = 0xe6cb0000,
180 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900181 .scscr = SCSCR_RE | SCSCR_TE,
182 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000183 .type = PORT_SCIFA,
184 .irqs = { gic_spi(79), gic_spi(79),
185 gic_spi(79), gic_spi(79) },
186};
187
188static struct platform_device scif5_device = {
189 .name = "sh-sci",
190 .id = 5,
191 .dev = {
192 .platform_data = &scif5_platform_data,
193 },
194};
195
196static struct plat_sci_port scif6_platform_data = {
197 .mapbase = 0xe6cc0000,
198 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900199 .scscr = SCSCR_RE | SCSCR_TE,
200 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000201 .type = PORT_SCIFA,
202 .irqs = { gic_spi(156), gic_spi(156),
203 gic_spi(156), gic_spi(156) },
204};
205
206static struct platform_device scif6_device = {
207 .name = "sh-sci",
208 .id = 6,
209 .dev = {
210 .platform_data = &scif6_platform_data,
211 },
212};
213
214static struct plat_sci_port scif7_platform_data = {
215 .mapbase = 0xe6cd0000,
216 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900217 .scscr = SCSCR_RE | SCSCR_TE,
218 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000219 .type = PORT_SCIFA,
220 .irqs = { gic_spi(143), gic_spi(143),
221 gic_spi(143), gic_spi(143) },
222};
223
224static struct platform_device scif7_device = {
225 .name = "sh-sci",
226 .id = 7,
227 .dev = {
228 .platform_data = &scif7_platform_data,
229 },
230};
231
232static struct plat_sci_port scif8_platform_data = {
233 .mapbase = 0xe6c30000,
234 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900235 .scscr = SCSCR_RE | SCSCR_TE,
236 .scbrr_algo_id = SCBRR_ALGO_4,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000237 .type = PORT_SCIFB,
238 .irqs = { gic_spi(80), gic_spi(80),
239 gic_spi(80), gic_spi(80) },
240};
241
242static struct platform_device scif8_device = {
243 .name = "sh-sci",
244 .id = 8,
245 .dev = {
246 .platform_data = &scif8_platform_data,
247 },
248};
249
250static struct sh_timer_config cmt10_platform_data = {
251 .name = "CMT10",
252 .channel_offset = 0x10,
253 .timer_bit = 0,
254 .clockevent_rating = 125,
255 .clocksource_rating = 125,
256};
257
258static struct resource cmt10_resources[] = {
259 [0] = {
260 .name = "CMT10",
261 .start = 0xe6138010,
262 .end = 0xe613801b,
263 .flags = IORESOURCE_MEM,
264 },
265 [1] = {
266 .start = gic_spi(65),
267 .flags = IORESOURCE_IRQ,
268 },
269};
270
271static struct platform_device cmt10_device = {
272 .name = "sh_cmt",
273 .id = 10,
274 .dev = {
275 .platform_data = &cmt10_platform_data,
276 },
277 .resource = cmt10_resources,
278 .num_resources = ARRAY_SIZE(cmt10_resources),
279};
280
Magnus Damm5010f3d2010-12-21 08:40:59 +0000281/* TMU */
282static struct sh_timer_config tmu00_platform_data = {
283 .name = "TMU00",
284 .channel_offset = 0x4,
285 .timer_bit = 0,
286 .clockevent_rating = 200,
287};
288
289static struct resource tmu00_resources[] = {
290 [0] = {
291 .name = "TMU00",
292 .start = 0xfff60008,
293 .end = 0xfff60013,
294 .flags = IORESOURCE_MEM,
295 },
296 [1] = {
297 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
298 .flags = IORESOURCE_IRQ,
299 },
300};
301
302static struct platform_device tmu00_device = {
303 .name = "sh_tmu",
304 .id = 0,
305 .dev = {
306 .platform_data = &tmu00_platform_data,
307 },
308 .resource = tmu00_resources,
309 .num_resources = ARRAY_SIZE(tmu00_resources),
310};
311
312static struct sh_timer_config tmu01_platform_data = {
313 .name = "TMU01",
314 .channel_offset = 0x10,
315 .timer_bit = 1,
316 .clocksource_rating = 200,
317};
318
319static struct resource tmu01_resources[] = {
320 [0] = {
321 .name = "TMU01",
322 .start = 0xfff60014,
323 .end = 0xfff6001f,
324 .flags = IORESOURCE_MEM,
325 },
326 [1] = {
327 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
328 .flags = IORESOURCE_IRQ,
329 },
330};
331
332static struct platform_device tmu01_device = {
333 .name = "sh_tmu",
334 .id = 1,
335 .dev = {
336 .platform_data = &tmu01_platform_data,
337 },
338 .resource = tmu01_resources,
339 .num_resources = ARRAY_SIZE(tmu01_resources),
340};
341
Yoshii Takashib028f942010-11-19 13:20:45 +0000342static struct resource i2c0_resources[] = {
343 [0] = {
344 .name = "IIC0",
345 .start = 0xe6820000,
346 .end = 0xe6820425 - 1,
347 .flags = IORESOURCE_MEM,
348 },
349 [1] = {
350 .start = gic_spi(167),
351 .end = gic_spi(170),
352 .flags = IORESOURCE_IRQ,
353 },
354};
355
356static struct resource i2c1_resources[] = {
357 [0] = {
358 .name = "IIC1",
359 .start = 0xe6822000,
360 .end = 0xe6822425 - 1,
361 .flags = IORESOURCE_MEM,
362 },
363 [1] = {
364 .start = gic_spi(51),
365 .end = gic_spi(54),
366 .flags = IORESOURCE_IRQ,
367 },
368};
369
370static struct resource i2c2_resources[] = {
371 [0] = {
372 .name = "IIC2",
373 .start = 0xe6824000,
374 .end = 0xe6824425 - 1,
375 .flags = IORESOURCE_MEM,
376 },
377 [1] = {
378 .start = gic_spi(171),
379 .end = gic_spi(174),
380 .flags = IORESOURCE_IRQ,
381 },
382};
383
384static struct resource i2c3_resources[] = {
385 [0] = {
386 .name = "IIC3",
387 .start = 0xe6826000,
388 .end = 0xe6826425 - 1,
389 .flags = IORESOURCE_MEM,
390 },
391 [1] = {
392 .start = gic_spi(183),
393 .end = gic_spi(186),
394 .flags = IORESOURCE_IRQ,
395 },
396};
397
398static struct resource i2c4_resources[] = {
399 [0] = {
400 .name = "IIC4",
401 .start = 0xe6828000,
402 .end = 0xe6828425 - 1,
403 .flags = IORESOURCE_MEM,
404 },
405 [1] = {
406 .start = gic_spi(187),
407 .end = gic_spi(190),
408 .flags = IORESOURCE_IRQ,
409 },
410};
411
412static struct platform_device i2c0_device = {
413 .name = "i2c-sh_mobile",
414 .id = 0,
415 .resource = i2c0_resources,
416 .num_resources = ARRAY_SIZE(i2c0_resources),
417};
418
419static struct platform_device i2c1_device = {
420 .name = "i2c-sh_mobile",
421 .id = 1,
422 .resource = i2c1_resources,
423 .num_resources = ARRAY_SIZE(i2c1_resources),
424};
425
426static struct platform_device i2c2_device = {
427 .name = "i2c-sh_mobile",
428 .id = 2,
429 .resource = i2c2_resources,
430 .num_resources = ARRAY_SIZE(i2c2_resources),
431};
432
433static struct platform_device i2c3_device = {
434 .name = "i2c-sh_mobile",
435 .id = 3,
436 .resource = i2c3_resources,
437 .num_resources = ARRAY_SIZE(i2c3_resources),
438};
439
440static struct platform_device i2c4_device = {
441 .name = "i2c-sh_mobile",
442 .id = 4,
443 .resource = i2c4_resources,
444 .num_resources = ARRAY_SIZE(i2c4_resources),
445};
446
Magnus Damm681e1b32011-05-24 10:37:16 +0000447static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
448 {
449 .slave_id = SHDMA_SLAVE_SCIF0_TX,
450 .addr = 0xe6c40020,
451 .chcr = CHCR_TX(XMIT_SZ_8BIT),
452 .mid_rid = 0x21,
453 }, {
454 .slave_id = SHDMA_SLAVE_SCIF0_RX,
455 .addr = 0xe6c40024,
456 .chcr = CHCR_RX(XMIT_SZ_8BIT),
457 .mid_rid = 0x22,
458 }, {
459 .slave_id = SHDMA_SLAVE_SCIF1_TX,
460 .addr = 0xe6c50020,
461 .chcr = CHCR_TX(XMIT_SZ_8BIT),
462 .mid_rid = 0x25,
463 }, {
464 .slave_id = SHDMA_SLAVE_SCIF1_RX,
465 .addr = 0xe6c50024,
466 .chcr = CHCR_RX(XMIT_SZ_8BIT),
467 .mid_rid = 0x26,
468 }, {
469 .slave_id = SHDMA_SLAVE_SCIF2_TX,
470 .addr = 0xe6c60020,
471 .chcr = CHCR_TX(XMIT_SZ_8BIT),
472 .mid_rid = 0x29,
473 }, {
474 .slave_id = SHDMA_SLAVE_SCIF2_RX,
475 .addr = 0xe6c60024,
476 .chcr = CHCR_RX(XMIT_SZ_8BIT),
477 .mid_rid = 0x2a,
478 }, {
479 .slave_id = SHDMA_SLAVE_SCIF3_TX,
480 .addr = 0xe6c70020,
481 .chcr = CHCR_TX(XMIT_SZ_8BIT),
482 .mid_rid = 0x2d,
483 }, {
484 .slave_id = SHDMA_SLAVE_SCIF3_RX,
485 .addr = 0xe6c70024,
486 .chcr = CHCR_RX(XMIT_SZ_8BIT),
487 .mid_rid = 0x2e,
488 }, {
489 .slave_id = SHDMA_SLAVE_SCIF4_TX,
490 .addr = 0xe6c80020,
491 .chcr = CHCR_TX(XMIT_SZ_8BIT),
492 .mid_rid = 0x39,
493 }, {
494 .slave_id = SHDMA_SLAVE_SCIF4_RX,
495 .addr = 0xe6c80024,
496 .chcr = CHCR_RX(XMIT_SZ_8BIT),
497 .mid_rid = 0x3a,
498 }, {
499 .slave_id = SHDMA_SLAVE_SCIF5_TX,
500 .addr = 0xe6cb0020,
501 .chcr = CHCR_TX(XMIT_SZ_8BIT),
502 .mid_rid = 0x35,
503 }, {
504 .slave_id = SHDMA_SLAVE_SCIF5_RX,
505 .addr = 0xe6cb0024,
506 .chcr = CHCR_RX(XMIT_SZ_8BIT),
507 .mid_rid = 0x36,
508 }, {
509 .slave_id = SHDMA_SLAVE_SCIF6_TX,
510 .addr = 0xe6cc0020,
511 .chcr = CHCR_TX(XMIT_SZ_8BIT),
512 .mid_rid = 0x1d,
513 }, {
514 .slave_id = SHDMA_SLAVE_SCIF6_RX,
515 .addr = 0xe6cc0024,
516 .chcr = CHCR_RX(XMIT_SZ_8BIT),
517 .mid_rid = 0x1e,
518 }, {
519 .slave_id = SHDMA_SLAVE_SCIF7_TX,
520 .addr = 0xe6cd0020,
521 .chcr = CHCR_TX(XMIT_SZ_8BIT),
522 .mid_rid = 0x19,
523 }, {
524 .slave_id = SHDMA_SLAVE_SCIF7_RX,
525 .addr = 0xe6cd0024,
526 .chcr = CHCR_RX(XMIT_SZ_8BIT),
527 .mid_rid = 0x1a,
528 }, {
529 .slave_id = SHDMA_SLAVE_SCIF8_TX,
530 .addr = 0xe6c30040,
531 .chcr = CHCR_TX(XMIT_SZ_8BIT),
532 .mid_rid = 0x3d,
533 }, {
534 .slave_id = SHDMA_SLAVE_SCIF8_RX,
535 .addr = 0xe6c30060,
536 .chcr = CHCR_RX(XMIT_SZ_8BIT),
537 .mid_rid = 0x3e,
538 }, {
539 .slave_id = SHDMA_SLAVE_SDHI0_TX,
540 .addr = 0xee100030,
541 .chcr = CHCR_TX(XMIT_SZ_16BIT),
542 .mid_rid = 0xc1,
543 }, {
544 .slave_id = SHDMA_SLAVE_SDHI0_RX,
545 .addr = 0xee100030,
546 .chcr = CHCR_RX(XMIT_SZ_16BIT),
547 .mid_rid = 0xc2,
548 }, {
549 .slave_id = SHDMA_SLAVE_SDHI1_TX,
550 .addr = 0xee120030,
551 .chcr = CHCR_TX(XMIT_SZ_16BIT),
552 .mid_rid = 0xc9,
553 }, {
554 .slave_id = SHDMA_SLAVE_SDHI1_RX,
555 .addr = 0xee120030,
556 .chcr = CHCR_RX(XMIT_SZ_16BIT),
557 .mid_rid = 0xca,
558 }, {
559 .slave_id = SHDMA_SLAVE_SDHI2_TX,
560 .addr = 0xee140030,
561 .chcr = CHCR_TX(XMIT_SZ_16BIT),
562 .mid_rid = 0xcd,
563 }, {
564 .slave_id = SHDMA_SLAVE_SDHI2_RX,
565 .addr = 0xee140030,
566 .chcr = CHCR_RX(XMIT_SZ_16BIT),
567 .mid_rid = 0xce,
568 }, {
569 .slave_id = SHDMA_SLAVE_MMCIF_TX,
570 .addr = 0xe6bd0034,
571 .chcr = CHCR_TX(XMIT_SZ_32BIT),
572 .mid_rid = 0xd1,
573 }, {
574 .slave_id = SHDMA_SLAVE_MMCIF_RX,
575 .addr = 0xe6bd0034,
576 .chcr = CHCR_RX(XMIT_SZ_32BIT),
577 .mid_rid = 0xd2,
578 },
579};
580
581#define DMAE_CHANNEL(_offset) \
582 { \
583 .offset = _offset - 0x20, \
584 .dmars = _offset - 0x20 + 0x40, \
585 }
586
587static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
588 DMAE_CHANNEL(0x8000),
589 DMAE_CHANNEL(0x8080),
590 DMAE_CHANNEL(0x8100),
591 DMAE_CHANNEL(0x8180),
592 DMAE_CHANNEL(0x8200),
593 DMAE_CHANNEL(0x8280),
594 DMAE_CHANNEL(0x8300),
595 DMAE_CHANNEL(0x8380),
596 DMAE_CHANNEL(0x8400),
597 DMAE_CHANNEL(0x8480),
598 DMAE_CHANNEL(0x8500),
599 DMAE_CHANNEL(0x8580),
600 DMAE_CHANNEL(0x8600),
601 DMAE_CHANNEL(0x8680),
602 DMAE_CHANNEL(0x8700),
603 DMAE_CHANNEL(0x8780),
604 DMAE_CHANNEL(0x8800),
605 DMAE_CHANNEL(0x8880),
606 DMAE_CHANNEL(0x8900),
607 DMAE_CHANNEL(0x8980),
608};
609
Magnus Damm681e1b32011-05-24 10:37:16 +0000610static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
611 .slave = sh73a0_dmae_slaves,
612 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
613 .channel = sh73a0_dmae_channels,
614 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700615 .ts_low_shift = TS_LOW_SHIFT,
616 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
617 .ts_high_shift = TS_HI_SHIFT,
618 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
619 .ts_shift = dma_ts_shift,
620 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Magnus Damm681e1b32011-05-24 10:37:16 +0000621 .dmaor_init = DMAOR_DME,
622};
623
624static struct resource sh73a0_dmae_resources[] = {
625 {
626 /* Registers including DMAOR and channels including DMARSx */
627 .start = 0xfe000020,
628 .end = 0xfe008a00 - 1,
629 .flags = IORESOURCE_MEM,
630 },
631 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900632 .name = "error_irq",
Magnus Damm681e1b32011-05-24 10:37:16 +0000633 .start = gic_spi(129),
634 .end = gic_spi(129),
635 .flags = IORESOURCE_IRQ,
636 },
637 {
638 /* IRQ for channels 0-19 */
639 .start = gic_spi(109),
640 .end = gic_spi(128),
641 .flags = IORESOURCE_IRQ,
642 },
643};
644
645static struct platform_device dma0_device = {
646 .name = "sh-dma-engine",
647 .id = 0,
648 .resource = sh73a0_dmae_resources,
649 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
650 .dev = {
651 .platform_data = &sh73a0_dmae_platform_data,
652 },
653};
654
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700655/* MPDMAC */
656static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
657 {
658 .slave_id = SHDMA_SLAVE_FSI2A_RX,
659 .addr = 0xec230020,
660 .chcr = CHCR_RX(XMIT_SZ_32BIT),
661 .mid_rid = 0xd6, /* CHECK ME */
662 }, {
663 .slave_id = SHDMA_SLAVE_FSI2A_TX,
664 .addr = 0xec230024,
665 .chcr = CHCR_TX(XMIT_SZ_32BIT),
666 .mid_rid = 0xd5, /* CHECK ME */
667 }, {
668 .slave_id = SHDMA_SLAVE_FSI2C_RX,
669 .addr = 0xec230060,
670 .chcr = CHCR_RX(XMIT_SZ_32BIT),
671 .mid_rid = 0xda, /* CHECK ME */
672 }, {
673 .slave_id = SHDMA_SLAVE_FSI2C_TX,
674 .addr = 0xec230064,
675 .chcr = CHCR_TX(XMIT_SZ_32BIT),
676 .mid_rid = 0xd9, /* CHECK ME */
677 }, {
678 .slave_id = SHDMA_SLAVE_FSI2B_RX,
679 .addr = 0xec240020,
680 .chcr = CHCR_RX(XMIT_SZ_32BIT),
681 .mid_rid = 0x8e, /* CHECK ME */
682 }, {
683 .slave_id = SHDMA_SLAVE_FSI2B_TX,
684 .addr = 0xec240024,
685 .chcr = CHCR_RX(XMIT_SZ_32BIT),
686 .mid_rid = 0x8d, /* CHECK ME */
687 }, {
688 .slave_id = SHDMA_SLAVE_FSI2D_RX,
689 .addr = 0xec240060,
690 .chcr = CHCR_RX(XMIT_SZ_32BIT),
691 .mid_rid = 0x9a, /* CHECK ME */
692 },
693};
694
695#define MPDMA_CHANNEL(a, b, c) \
696{ \
697 .offset = a, \
698 .dmars = b, \
699 .dmars_bit = c, \
700 .chclr_offset = (0x220 - 0x20) + a \
701}
702
703static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
704 MPDMA_CHANNEL(0x00, 0, 0),
705 MPDMA_CHANNEL(0x10, 0, 8),
706 MPDMA_CHANNEL(0x20, 4, 0),
707 MPDMA_CHANNEL(0x30, 4, 8),
708 MPDMA_CHANNEL(0x50, 8, 0),
709 MPDMA_CHANNEL(0x70, 8, 8),
710};
711
712static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
713 .slave = sh73a0_mpdma_slaves,
714 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
715 .channel = sh73a0_mpdma_channels,
716 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700717 .ts_low_shift = TS_LOW_SHIFT,
718 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
719 .ts_high_shift = TS_HI_SHIFT,
720 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
721 .ts_shift = dma_ts_shift,
722 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700723 .dmaor_init = DMAOR_DME,
724 .chclr_present = 1,
725};
726
727/* Resource order important! */
728static struct resource sh73a0_mpdma_resources[] = {
729 {
730 /* Channel registers and DMAOR */
731 .start = 0xec618020,
732 .end = 0xec61828f,
733 .flags = IORESOURCE_MEM,
734 },
735 {
736 /* DMARSx */
737 .start = 0xec619000,
738 .end = 0xec61900b,
739 .flags = IORESOURCE_MEM,
740 },
741 {
742 .name = "error_irq",
743 .start = gic_spi(181),
744 .end = gic_spi(181),
745 .flags = IORESOURCE_IRQ,
746 },
747 {
748 /* IRQ for channels 0-5 */
749 .start = gic_spi(175),
750 .end = gic_spi(180),
751 .flags = IORESOURCE_IRQ,
752 },
753};
754
755static struct platform_device mpdma0_device = {
756 .name = "sh-dma-engine",
757 .id = 1,
758 .resource = sh73a0_mpdma_resources,
759 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
760 .dev = {
761 .platform_data = &sh73a0_mpdma_platform_data,
762 },
763};
764
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900765static struct resource pmu_resources[] = {
766 [0] = {
767 .start = gic_spi(55),
768 .end = gic_spi(55),
769 .flags = IORESOURCE_IRQ,
770 },
771 [1] = {
772 .start = gic_spi(56),
773 .end = gic_spi(56),
774 .flags = IORESOURCE_IRQ,
775 },
776};
777
778static struct platform_device pmu_device = {
779 .name = "arm-pmu",
780 .id = -1,
781 .num_resources = ARRAY_SIZE(pmu_resources),
782 .resource = pmu_resources,
783};
784
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900785/* an IPMMU module for ICB */
786static struct resource ipmmu_resources[] = {
787 [0] = {
788 .name = "IPMMU",
789 .start = 0xfe951000,
790 .end = 0xfe9510ff,
791 .flags = IORESOURCE_MEM,
792 },
793};
794
795static const char * const ipmmu_dev_names[] = {
796 "sh_mobile_lcdc_fb.0",
797};
798
799static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
800 .dev_names = ipmmu_dev_names,
801 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
802};
803
804static struct platform_device ipmmu_device = {
805 .name = "ipmmu",
806 .id = -1,
807 .dev = {
808 .platform_data = &ipmmu_platform_data,
809 },
810 .resource = ipmmu_resources,
811 .num_resources = ARRAY_SIZE(ipmmu_resources),
812};
813
Simon Horman48609532012-11-21 22:00:15 +0900814static struct platform_device *sh73a0_early_devices_dt[] __initdata = {
Magnus Damm6d9598e2010-11-17 10:59:31 +0000815 &scif0_device,
816 &scif1_device,
817 &scif2_device,
818 &scif3_device,
819 &scif4_device,
820 &scif5_device,
821 &scif6_device,
822 &scif7_device,
823 &scif8_device,
824 &cmt10_device,
Simon Horman48609532012-11-21 22:00:15 +0900825};
826
827static struct platform_device *sh73a0_early_devices[] __initdata = {
Magnus Damm5010f3d2010-12-21 08:40:59 +0000828 &tmu00_device,
829 &tmu01_device,
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900830 &ipmmu_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000831};
832
Yoshii Takashib028f942010-11-19 13:20:45 +0000833static struct platform_device *sh73a0_late_devices[] __initdata = {
834 &i2c0_device,
835 &i2c1_device,
836 &i2c2_device,
837 &i2c3_device,
838 &i2c4_device,
Magnus Damm681e1b32011-05-24 10:37:16 +0000839 &dma0_device,
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700840 &mpdma0_device,
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900841 &pmu_device,
Yoshii Takashib028f942010-11-19 13:20:45 +0000842};
843
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000844#define SRCR2 IOMEM(0xe61580b0)
Magnus Damm681e1b32011-05-24 10:37:16 +0000845
Magnus Damm6d9598e2010-11-17 10:59:31 +0000846void __init sh73a0_add_standard_devices(void)
847{
Magnus Damm681e1b32011-05-24 10:37:16 +0000848 /* Clear software reset bit on SY-DMAC module */
849 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
850
Simon Horman48609532012-11-21 22:00:15 +0900851 platform_add_devices(sh73a0_early_devices_dt,
852 ARRAY_SIZE(sh73a0_early_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000853 platform_add_devices(sh73a0_early_devices,
854 ARRAY_SIZE(sh73a0_early_devices));
Yoshii Takashib028f942010-11-19 13:20:45 +0000855 platform_add_devices(sh73a0_late_devices,
856 ARRAY_SIZE(sh73a0_late_devices));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000857}
858
Kuninori Morimotod6720002012-05-10 00:26:58 -0700859/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
860void __init __weak sh73a0_register_twd(void) { }
861
Stephen Warren6bb27d72012-11-08 12:40:59 -0700862void __init sh73a0_earlytimer_init(void)
Magnus Damm3be26fd2012-03-06 17:36:45 +0900863{
864 sh73a0_clock_init();
865 shmobile_earlytimer_init();
Kuninori Morimotod6720002012-05-10 00:26:58 -0700866 sh73a0_register_twd();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900867}
868
Magnus Damm6d9598e2010-11-17 10:59:31 +0000869void __init sh73a0_add_early_devices(void)
870{
Simon Horman48609532012-11-21 22:00:15 +0900871 early_platform_add_devices(sh73a0_early_devices_dt,
872 ARRAY_SIZE(sh73a0_early_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000873 early_platform_add_devices(sh73a0_early_devices,
874 ARRAY_SIZE(sh73a0_early_devices));
Magnus Damm50e15c32012-02-29 21:37:27 +0900875
876 /* setup early console here as well */
877 shmobile_setup_console();
Magnus Damm6d9598e2010-11-17 10:59:31 +0000878}
Simon Horman48609532012-11-21 22:00:15 +0900879
880#ifdef CONFIG_USE_OF
881
882/* Please note that the clock initialisation shcheme used in
883 * sh73a0_add_early_devices_dt() and sh73a0_add_standard_devices_dt()
884 * does not work with SMP as there is a yet to be resolved lock-up in
885 * workqueue initialisation.
886 *
887 * CONFIG_SMP should be disabled when using this code.
888 */
889
890void __init sh73a0_add_early_devices_dt(void)
891{
892 shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
893
894 early_platform_add_devices(sh73a0_early_devices_dt,
895 ARRAY_SIZE(sh73a0_early_devices_dt));
896
897 /* setup early console here as well */
898 shmobile_setup_console();
899}
900
901static const struct of_dev_auxdata sh73a0_auxdata_lookup[] __initconst = {
902 {},
903};
904
905void __init sh73a0_add_standard_devices_dt(void)
906{
907 /* clocks are setup late during boot in the case of DT */
908 sh73a0_clock_init();
909
910 platform_add_devices(sh73a0_early_devices_dt,
911 ARRAY_SIZE(sh73a0_early_devices_dt));
912 of_platform_populate(NULL, of_default_bus_match_table,
913 sh73a0_auxdata_lookup, NULL);
914}
915
916static const char *sh73a0_boards_compat_dt[] __initdata = {
917 "renesas,sh73a0",
918 NULL,
919};
920
921DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
Simon Hormanf9989502013-02-15 21:38:20 +0900922 .smp = smp_ops(sh73a0_smp_ops),
Simon Horman48609532012-11-21 22:00:15 +0900923 .map_io = sh73a0_map_io,
924 .init_early = sh73a0_add_early_devices_dt,
925 .nr_irqs = NR_IRQS_LEGACY,
Simon Horman4eca1342013-02-15 21:38:20 +0900926 .init_irq = irqchip_init,
Simon Horman48609532012-11-21 22:00:15 +0900927 .init_machine = sh73a0_add_standard_devices_dt,
928 .init_time = shmobile_timer_init,
929 .dt_compat = sh73a0_boards_compat_dt,
930MACHINE_END
931#endif /* CONFIG_USE_OF */