blob: ba9b74198b723fa93d6050ef66238d2867c8a2b5 [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>
25#include <linux/platform_device.h>
Simon Horman48609532012-11-21 22:00:15 +090026#include <linux/of_platform.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000027#include <linux/delay.h>
28#include <linux/input.h>
29#include <linux/io.h>
30#include <linux/serial_sci.h>
Magnus Damm681e1b32011-05-24 10:37:16 +000031#include <linux/sh_dma.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000032#include <linux/sh_intc.h>
33#include <linux/sh_timer.h>
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +090034#include <linux/platform_data/sh_ipmmu.h>
Magnus Damm341eb542013-02-26 12:01:09 +090035#include <linux/platform_data/irq-renesas-intc-irqpin.h>
Kuninori Morimoto6088b422012-06-25 03:43:28 -070036#include <mach/dma-register.h>
Rob Herring250a2722012-01-03 16:57:33 -060037#include <mach/irqs.h>
Magnus Damm681e1b32011-05-24 10:37:16 +000038#include <mach/sh73a0.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090039#include <mach/common.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000040#include <asm/mach-types.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090041#include <asm/mach/map.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000042#include <asm/mach/arch.h>
Magnus Damm3be26fd2012-03-06 17:36:45 +090043#include <asm/mach/time.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000044
Magnus Damm50e15c32012-02-29 21:37:27 +090045static struct map_desc sh73a0_io_desc[] __initdata = {
46 /* create a 1:1 entity map for 0xe6xxxxxx
47 * used by CPGA, INTC and PFC.
48 */
49 {
50 .virtual = 0xe6000000,
51 .pfn = __phys_to_pfn(0xe6000000),
52 .length = 256 << 20,
53 .type = MT_DEVICE_NONSHARED
54 },
55};
56
57void __init sh73a0_map_io(void)
58{
59 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
60}
61
Magnus Damm474f6752013-06-27 17:09:01 +090062/* PFC */
63static struct resource pfc_resources[] __initdata = {
64 DEFINE_RES_MEM(0xe6050000, 0x8000),
65 DEFINE_RES_MEM(0xe605801c, 0x000c),
Laurent Pinchart994d66a2012-12-15 23:51:28 +010066};
67
68void __init sh73a0_pinmux_init(void)
69{
Magnus Damm474f6752013-06-27 17:09:01 +090070 platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
71 ARRAY_SIZE(pfc_resources));
Laurent Pinchart994d66a2012-12-15 23:51:28 +010072}
73
Laurent Pinchartd000fff2013-12-06 10:59:22 +010074/* SCIF */
75#define SH73A0_SCIF(scif_type, index, baseaddr, irq) \
76static struct plat_sci_port scif##index##_platform_data = { \
77 .type = scif_type, \
78 .mapbase = baseaddr, \
79 .flags = UPF_BOOT_AUTOCONF, \
80 .irqs = SCIx_IRQ_MUXED(irq), \
81 .scbrr_algo_id = SCBRR_ALGO_4, \
82 .scscr = SCSCR_RE | SCSCR_TE, \
83}; \
84 \
85static struct platform_device scif##index##_device = { \
86 .name = "sh-sci", \
87 .id = index, \
88 .dev = { \
89 .platform_data = &scif##index##_platform_data, \
90 }, \
91}
Magnus Damm6d9598e2010-11-17 10:59:31 +000092
Laurent Pinchartd000fff2013-12-06 10:59:22 +010093SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
94SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
95SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
96SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
97SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
98SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
99SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
100SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
101SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000102
103static struct sh_timer_config cmt10_platform_data = {
104 .name = "CMT10",
105 .channel_offset = 0x10,
106 .timer_bit = 0,
Simon Horman5600a842013-05-22 19:47:05 +0900107 .clockevent_rating = 80,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000108 .clocksource_rating = 125,
109};
110
111static struct resource cmt10_resources[] = {
112 [0] = {
113 .name = "CMT10",
114 .start = 0xe6138010,
115 .end = 0xe613801b,
116 .flags = IORESOURCE_MEM,
117 },
118 [1] = {
119 .start = gic_spi(65),
120 .flags = IORESOURCE_IRQ,
121 },
122};
123
124static struct platform_device cmt10_device = {
125 .name = "sh_cmt",
126 .id = 10,
127 .dev = {
128 .platform_data = &cmt10_platform_data,
129 },
130 .resource = cmt10_resources,
131 .num_resources = ARRAY_SIZE(cmt10_resources),
132};
133
Magnus Damm5010f3d2010-12-21 08:40:59 +0000134/* TMU */
135static struct sh_timer_config tmu00_platform_data = {
136 .name = "TMU00",
137 .channel_offset = 0x4,
138 .timer_bit = 0,
139 .clockevent_rating = 200,
140};
141
142static struct resource tmu00_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000143 [0] = DEFINE_RES_MEM_NAMED(0xfff60008, 0xc, "TMU00"),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000144 [1] = {
145 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
146 .flags = IORESOURCE_IRQ,
147 },
148};
149
150static struct platform_device tmu00_device = {
151 .name = "sh_tmu",
152 .id = 0,
153 .dev = {
154 .platform_data = &tmu00_platform_data,
155 },
156 .resource = tmu00_resources,
157 .num_resources = ARRAY_SIZE(tmu00_resources),
158};
159
160static struct sh_timer_config tmu01_platform_data = {
161 .name = "TMU01",
162 .channel_offset = 0x10,
163 .timer_bit = 1,
164 .clocksource_rating = 200,
165};
166
167static struct resource tmu01_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000168 [0] = DEFINE_RES_MEM_NAMED(0xfff60014, 0xc, "TMU00"),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000169 [1] = {
170 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
171 .flags = IORESOURCE_IRQ,
172 },
173};
174
175static struct platform_device tmu01_device = {
176 .name = "sh_tmu",
177 .id = 1,
178 .dev = {
179 .platform_data = &tmu01_platform_data,
180 },
181 .resource = tmu01_resources,
182 .num_resources = ARRAY_SIZE(tmu01_resources),
183};
184
Yoshii Takashib028f942010-11-19 13:20:45 +0000185static struct resource i2c0_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000186 [0] = DEFINE_RES_MEM_NAMED(0xe6820000, 0x426, "IIC0"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000187 [1] = {
188 .start = gic_spi(167),
189 .end = gic_spi(170),
190 .flags = IORESOURCE_IRQ,
191 },
192};
193
194static struct resource i2c1_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000195 [0] = DEFINE_RES_MEM_NAMED(0xe6822000, 0x426, "IIC1"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000196 [1] = {
197 .start = gic_spi(51),
198 .end = gic_spi(54),
199 .flags = IORESOURCE_IRQ,
200 },
201};
202
203static struct resource i2c2_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000204 [0] = DEFINE_RES_MEM_NAMED(0xe6824000, 0x426, "IIC2"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000205 [1] = {
206 .start = gic_spi(171),
207 .end = gic_spi(174),
208 .flags = IORESOURCE_IRQ,
209 },
210};
211
212static struct resource i2c3_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000213 [0] = DEFINE_RES_MEM_NAMED(0xe6826000, 0x426, "IIC3"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000214 [1] = {
215 .start = gic_spi(183),
216 .end = gic_spi(186),
217 .flags = IORESOURCE_IRQ,
218 },
219};
220
221static struct resource i2c4_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000222 [0] = DEFINE_RES_MEM_NAMED(0xe6828000, 0x426, "IIC4"),
Yoshii Takashib028f942010-11-19 13:20:45 +0000223 [1] = {
224 .start = gic_spi(187),
225 .end = gic_spi(190),
226 .flags = IORESOURCE_IRQ,
227 },
228};
229
230static struct platform_device i2c0_device = {
231 .name = "i2c-sh_mobile",
232 .id = 0,
233 .resource = i2c0_resources,
234 .num_resources = ARRAY_SIZE(i2c0_resources),
235};
236
237static struct platform_device i2c1_device = {
238 .name = "i2c-sh_mobile",
239 .id = 1,
240 .resource = i2c1_resources,
241 .num_resources = ARRAY_SIZE(i2c1_resources),
242};
243
244static struct platform_device i2c2_device = {
245 .name = "i2c-sh_mobile",
246 .id = 2,
247 .resource = i2c2_resources,
248 .num_resources = ARRAY_SIZE(i2c2_resources),
249};
250
251static struct platform_device i2c3_device = {
252 .name = "i2c-sh_mobile",
253 .id = 3,
254 .resource = i2c3_resources,
255 .num_resources = ARRAY_SIZE(i2c3_resources),
256};
257
258static struct platform_device i2c4_device = {
259 .name = "i2c-sh_mobile",
260 .id = 4,
261 .resource = i2c4_resources,
262 .num_resources = ARRAY_SIZE(i2c4_resources),
263};
264
Magnus Damm681e1b32011-05-24 10:37:16 +0000265static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
266 {
267 .slave_id = SHDMA_SLAVE_SCIF0_TX,
268 .addr = 0xe6c40020,
269 .chcr = CHCR_TX(XMIT_SZ_8BIT),
270 .mid_rid = 0x21,
271 }, {
272 .slave_id = SHDMA_SLAVE_SCIF0_RX,
273 .addr = 0xe6c40024,
274 .chcr = CHCR_RX(XMIT_SZ_8BIT),
275 .mid_rid = 0x22,
276 }, {
277 .slave_id = SHDMA_SLAVE_SCIF1_TX,
278 .addr = 0xe6c50020,
279 .chcr = CHCR_TX(XMIT_SZ_8BIT),
280 .mid_rid = 0x25,
281 }, {
282 .slave_id = SHDMA_SLAVE_SCIF1_RX,
283 .addr = 0xe6c50024,
284 .chcr = CHCR_RX(XMIT_SZ_8BIT),
285 .mid_rid = 0x26,
286 }, {
287 .slave_id = SHDMA_SLAVE_SCIF2_TX,
288 .addr = 0xe6c60020,
289 .chcr = CHCR_TX(XMIT_SZ_8BIT),
290 .mid_rid = 0x29,
291 }, {
292 .slave_id = SHDMA_SLAVE_SCIF2_RX,
293 .addr = 0xe6c60024,
294 .chcr = CHCR_RX(XMIT_SZ_8BIT),
295 .mid_rid = 0x2a,
296 }, {
297 .slave_id = SHDMA_SLAVE_SCIF3_TX,
298 .addr = 0xe6c70020,
299 .chcr = CHCR_TX(XMIT_SZ_8BIT),
300 .mid_rid = 0x2d,
301 }, {
302 .slave_id = SHDMA_SLAVE_SCIF3_RX,
303 .addr = 0xe6c70024,
304 .chcr = CHCR_RX(XMIT_SZ_8BIT),
305 .mid_rid = 0x2e,
306 }, {
307 .slave_id = SHDMA_SLAVE_SCIF4_TX,
308 .addr = 0xe6c80020,
309 .chcr = CHCR_TX(XMIT_SZ_8BIT),
310 .mid_rid = 0x39,
311 }, {
312 .slave_id = SHDMA_SLAVE_SCIF4_RX,
313 .addr = 0xe6c80024,
314 .chcr = CHCR_RX(XMIT_SZ_8BIT),
315 .mid_rid = 0x3a,
316 }, {
317 .slave_id = SHDMA_SLAVE_SCIF5_TX,
318 .addr = 0xe6cb0020,
319 .chcr = CHCR_TX(XMIT_SZ_8BIT),
320 .mid_rid = 0x35,
321 }, {
322 .slave_id = SHDMA_SLAVE_SCIF5_RX,
323 .addr = 0xe6cb0024,
324 .chcr = CHCR_RX(XMIT_SZ_8BIT),
325 .mid_rid = 0x36,
326 }, {
327 .slave_id = SHDMA_SLAVE_SCIF6_TX,
328 .addr = 0xe6cc0020,
329 .chcr = CHCR_TX(XMIT_SZ_8BIT),
330 .mid_rid = 0x1d,
331 }, {
332 .slave_id = SHDMA_SLAVE_SCIF6_RX,
333 .addr = 0xe6cc0024,
334 .chcr = CHCR_RX(XMIT_SZ_8BIT),
335 .mid_rid = 0x1e,
336 }, {
337 .slave_id = SHDMA_SLAVE_SCIF7_TX,
338 .addr = 0xe6cd0020,
339 .chcr = CHCR_TX(XMIT_SZ_8BIT),
340 .mid_rid = 0x19,
341 }, {
342 .slave_id = SHDMA_SLAVE_SCIF7_RX,
343 .addr = 0xe6cd0024,
344 .chcr = CHCR_RX(XMIT_SZ_8BIT),
345 .mid_rid = 0x1a,
346 }, {
347 .slave_id = SHDMA_SLAVE_SCIF8_TX,
348 .addr = 0xe6c30040,
349 .chcr = CHCR_TX(XMIT_SZ_8BIT),
350 .mid_rid = 0x3d,
351 }, {
352 .slave_id = SHDMA_SLAVE_SCIF8_RX,
353 .addr = 0xe6c30060,
354 .chcr = CHCR_RX(XMIT_SZ_8BIT),
355 .mid_rid = 0x3e,
356 }, {
357 .slave_id = SHDMA_SLAVE_SDHI0_TX,
358 .addr = 0xee100030,
359 .chcr = CHCR_TX(XMIT_SZ_16BIT),
360 .mid_rid = 0xc1,
361 }, {
362 .slave_id = SHDMA_SLAVE_SDHI0_RX,
363 .addr = 0xee100030,
364 .chcr = CHCR_RX(XMIT_SZ_16BIT),
365 .mid_rid = 0xc2,
366 }, {
367 .slave_id = SHDMA_SLAVE_SDHI1_TX,
368 .addr = 0xee120030,
369 .chcr = CHCR_TX(XMIT_SZ_16BIT),
370 .mid_rid = 0xc9,
371 }, {
372 .slave_id = SHDMA_SLAVE_SDHI1_RX,
373 .addr = 0xee120030,
374 .chcr = CHCR_RX(XMIT_SZ_16BIT),
375 .mid_rid = 0xca,
376 }, {
377 .slave_id = SHDMA_SLAVE_SDHI2_TX,
378 .addr = 0xee140030,
379 .chcr = CHCR_TX(XMIT_SZ_16BIT),
380 .mid_rid = 0xcd,
381 }, {
382 .slave_id = SHDMA_SLAVE_SDHI2_RX,
383 .addr = 0xee140030,
384 .chcr = CHCR_RX(XMIT_SZ_16BIT),
385 .mid_rid = 0xce,
386 }, {
387 .slave_id = SHDMA_SLAVE_MMCIF_TX,
388 .addr = 0xe6bd0034,
389 .chcr = CHCR_TX(XMIT_SZ_32BIT),
390 .mid_rid = 0xd1,
391 }, {
392 .slave_id = SHDMA_SLAVE_MMCIF_RX,
393 .addr = 0xe6bd0034,
394 .chcr = CHCR_RX(XMIT_SZ_32BIT),
395 .mid_rid = 0xd2,
396 },
397};
398
399#define DMAE_CHANNEL(_offset) \
400 { \
401 .offset = _offset - 0x20, \
402 .dmars = _offset - 0x20 + 0x40, \
403 }
404
405static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
406 DMAE_CHANNEL(0x8000),
407 DMAE_CHANNEL(0x8080),
408 DMAE_CHANNEL(0x8100),
409 DMAE_CHANNEL(0x8180),
410 DMAE_CHANNEL(0x8200),
411 DMAE_CHANNEL(0x8280),
412 DMAE_CHANNEL(0x8300),
413 DMAE_CHANNEL(0x8380),
414 DMAE_CHANNEL(0x8400),
415 DMAE_CHANNEL(0x8480),
416 DMAE_CHANNEL(0x8500),
417 DMAE_CHANNEL(0x8580),
418 DMAE_CHANNEL(0x8600),
419 DMAE_CHANNEL(0x8680),
420 DMAE_CHANNEL(0x8700),
421 DMAE_CHANNEL(0x8780),
422 DMAE_CHANNEL(0x8800),
423 DMAE_CHANNEL(0x8880),
424 DMAE_CHANNEL(0x8900),
425 DMAE_CHANNEL(0x8980),
426};
427
Magnus Damm681e1b32011-05-24 10:37:16 +0000428static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
429 .slave = sh73a0_dmae_slaves,
430 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
431 .channel = sh73a0_dmae_channels,
432 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700433 .ts_low_shift = TS_LOW_SHIFT,
434 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
435 .ts_high_shift = TS_HI_SHIFT,
436 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
437 .ts_shift = dma_ts_shift,
438 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Magnus Damm681e1b32011-05-24 10:37:16 +0000439 .dmaor_init = DMAOR_DME,
440};
441
442static struct resource sh73a0_dmae_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000443 DEFINE_RES_MEM(0xfe000020, 0x89e0),
Magnus Damm681e1b32011-05-24 10:37:16 +0000444 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900445 .name = "error_irq",
Magnus Damm681e1b32011-05-24 10:37:16 +0000446 .start = gic_spi(129),
447 .end = gic_spi(129),
448 .flags = IORESOURCE_IRQ,
449 },
450 {
451 /* IRQ for channels 0-19 */
452 .start = gic_spi(109),
453 .end = gic_spi(128),
454 .flags = IORESOURCE_IRQ,
455 },
456};
457
458static struct platform_device dma0_device = {
459 .name = "sh-dma-engine",
460 .id = 0,
461 .resource = sh73a0_dmae_resources,
462 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
463 .dev = {
464 .platform_data = &sh73a0_dmae_platform_data,
465 },
466};
467
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700468/* MPDMAC */
469static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
470 {
471 .slave_id = SHDMA_SLAVE_FSI2A_RX,
472 .addr = 0xec230020,
473 .chcr = CHCR_RX(XMIT_SZ_32BIT),
474 .mid_rid = 0xd6, /* CHECK ME */
475 }, {
476 .slave_id = SHDMA_SLAVE_FSI2A_TX,
477 .addr = 0xec230024,
478 .chcr = CHCR_TX(XMIT_SZ_32BIT),
479 .mid_rid = 0xd5, /* CHECK ME */
480 }, {
481 .slave_id = SHDMA_SLAVE_FSI2C_RX,
482 .addr = 0xec230060,
483 .chcr = CHCR_RX(XMIT_SZ_32BIT),
484 .mid_rid = 0xda, /* CHECK ME */
485 }, {
486 .slave_id = SHDMA_SLAVE_FSI2C_TX,
487 .addr = 0xec230064,
488 .chcr = CHCR_TX(XMIT_SZ_32BIT),
489 .mid_rid = 0xd9, /* CHECK ME */
490 }, {
491 .slave_id = SHDMA_SLAVE_FSI2B_RX,
492 .addr = 0xec240020,
493 .chcr = CHCR_RX(XMIT_SZ_32BIT),
494 .mid_rid = 0x8e, /* CHECK ME */
495 }, {
496 .slave_id = SHDMA_SLAVE_FSI2B_TX,
497 .addr = 0xec240024,
498 .chcr = CHCR_RX(XMIT_SZ_32BIT),
499 .mid_rid = 0x8d, /* CHECK ME */
500 }, {
501 .slave_id = SHDMA_SLAVE_FSI2D_RX,
502 .addr = 0xec240060,
503 .chcr = CHCR_RX(XMIT_SZ_32BIT),
504 .mid_rid = 0x9a, /* CHECK ME */
505 },
506};
507
508#define MPDMA_CHANNEL(a, b, c) \
509{ \
510 .offset = a, \
511 .dmars = b, \
512 .dmars_bit = c, \
513 .chclr_offset = (0x220 - 0x20) + a \
514}
515
516static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
517 MPDMA_CHANNEL(0x00, 0, 0),
518 MPDMA_CHANNEL(0x10, 0, 8),
519 MPDMA_CHANNEL(0x20, 4, 0),
520 MPDMA_CHANNEL(0x30, 4, 8),
521 MPDMA_CHANNEL(0x50, 8, 0),
522 MPDMA_CHANNEL(0x70, 8, 8),
523};
524
525static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
526 .slave = sh73a0_mpdma_slaves,
527 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
528 .channel = sh73a0_mpdma_channels,
529 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700530 .ts_low_shift = TS_LOW_SHIFT,
531 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
532 .ts_high_shift = TS_HI_SHIFT,
533 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
534 .ts_shift = dma_ts_shift,
535 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700536 .dmaor_init = DMAOR_DME,
537 .chclr_present = 1,
538};
539
540/* Resource order important! */
541static struct resource sh73a0_mpdma_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000542 /* Channel registers and DMAOR */
543 DEFINE_RES_MEM(0xec618020, 0x270),
544 /* DMARSx */
545 DEFINE_RES_MEM(0xec619000, 0xc),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700546 {
547 .name = "error_irq",
548 .start = gic_spi(181),
549 .end = gic_spi(181),
550 .flags = IORESOURCE_IRQ,
551 },
552 {
553 /* IRQ for channels 0-5 */
554 .start = gic_spi(175),
555 .end = gic_spi(180),
556 .flags = IORESOURCE_IRQ,
557 },
558};
559
560static struct platform_device mpdma0_device = {
561 .name = "sh-dma-engine",
562 .id = 1,
563 .resource = sh73a0_mpdma_resources,
564 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
565 .dev = {
566 .platform_data = &sh73a0_mpdma_platform_data,
567 },
568};
569
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900570static struct resource pmu_resources[] = {
571 [0] = {
572 .start = gic_spi(55),
573 .end = gic_spi(55),
574 .flags = IORESOURCE_IRQ,
575 },
576 [1] = {
577 .start = gic_spi(56),
578 .end = gic_spi(56),
579 .flags = IORESOURCE_IRQ,
580 },
581};
582
583static struct platform_device pmu_device = {
584 .name = "arm-pmu",
585 .id = -1,
586 .num_resources = ARRAY_SIZE(pmu_resources),
587 .resource = pmu_resources,
588};
589
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900590/* an IPMMU module for ICB */
591static struct resource ipmmu_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000592 DEFINE_RES_MEM_NAMED(0xfe951000, 0x100, "IPMMU"),
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900593};
594
595static const char * const ipmmu_dev_names[] = {
596 "sh_mobile_lcdc_fb.0",
597};
598
599static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
600 .dev_names = ipmmu_dev_names,
601 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
602};
603
604static struct platform_device ipmmu_device = {
605 .name = "ipmmu",
606 .id = -1,
607 .dev = {
608 .platform_data = &ipmmu_platform_data,
609 },
610 .resource = ipmmu_resources,
611 .num_resources = ARRAY_SIZE(ipmmu_resources),
612};
613
Magnus Damm1461f8b2013-03-06 15:08:31 +0900614static struct renesas_intc_irqpin_config irqpin0_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900615 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
616};
617
618static struct resource irqpin0_resources[] = {
619 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
620 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
621 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
622 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
623 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
624 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
625 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
626 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
627 DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
628 DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
629 DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
630 DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
631 DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
632};
633
634static struct platform_device irqpin0_device = {
635 .name = "renesas_intc_irqpin",
636 .id = 0,
637 .resource = irqpin0_resources,
638 .num_resources = ARRAY_SIZE(irqpin0_resources),
639 .dev = {
640 .platform_data = &irqpin0_platform_data,
641 },
642};
643
Magnus Damm1461f8b2013-03-06 15:08:31 +0900644static struct renesas_intc_irqpin_config irqpin1_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900645 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
646 .control_parent = true, /* Disable spurious IRQ10 */
647};
648
649static struct resource irqpin1_resources[] = {
650 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
651 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
652 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
653 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
654 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
655 DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
656 DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
657 DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
658 DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
659 DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
660 DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
661 DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
662 DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
663};
664
665static struct platform_device irqpin1_device = {
666 .name = "renesas_intc_irqpin",
667 .id = 1,
668 .resource = irqpin1_resources,
669 .num_resources = ARRAY_SIZE(irqpin1_resources),
670 .dev = {
671 .platform_data = &irqpin1_platform_data,
672 },
673};
674
Magnus Damm1461f8b2013-03-06 15:08:31 +0900675static struct renesas_intc_irqpin_config irqpin2_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900676 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
677};
678
679static struct resource irqpin2_resources[] = {
680 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
681 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
682 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
683 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
684 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
685 DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
686 DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
687 DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
688 DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
689 DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
690 DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
691 DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
692 DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
693};
694
695static struct platform_device irqpin2_device = {
696 .name = "renesas_intc_irqpin",
697 .id = 2,
698 .resource = irqpin2_resources,
699 .num_resources = ARRAY_SIZE(irqpin2_resources),
700 .dev = {
701 .platform_data = &irqpin2_platform_data,
702 },
703};
704
Magnus Damm1461f8b2013-03-06 15:08:31 +0900705static struct renesas_intc_irqpin_config irqpin3_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900706 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
707};
708
709static struct resource irqpin3_resources[] = {
710 DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
711 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
712 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
713 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
714 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
715 DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
716 DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
717 DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
718 DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
719 DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
720 DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
721 DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
722 DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
723};
724
725static struct platform_device irqpin3_device = {
726 .name = "renesas_intc_irqpin",
727 .id = 3,
728 .resource = irqpin3_resources,
729 .num_resources = ARRAY_SIZE(irqpin3_resources),
730 .dev = {
731 .platform_data = &irqpin3_platform_data,
732 },
733};
734
Simon Horman3b00f932013-02-19 10:53:05 +0900735static struct platform_device *sh73a0_devices_dt[] __initdata = {
Magnus Damm6d9598e2010-11-17 10:59:31 +0000736 &scif0_device,
737 &scif1_device,
738 &scif2_device,
739 &scif3_device,
740 &scif4_device,
741 &scif5_device,
742 &scif6_device,
743 &scif7_device,
744 &scif8_device,
745 &cmt10_device,
Simon Horman48609532012-11-21 22:00:15 +0900746};
747
748static struct platform_device *sh73a0_early_devices[] __initdata = {
Magnus Damm5010f3d2010-12-21 08:40:59 +0000749 &tmu00_device,
750 &tmu01_device,
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900751 &ipmmu_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000752};
753
Yoshii Takashib028f942010-11-19 13:20:45 +0000754static struct platform_device *sh73a0_late_devices[] __initdata = {
755 &i2c0_device,
756 &i2c1_device,
757 &i2c2_device,
758 &i2c3_device,
759 &i2c4_device,
Magnus Damm681e1b32011-05-24 10:37:16 +0000760 &dma0_device,
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700761 &mpdma0_device,
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900762 &pmu_device,
Magnus Damm341eb542013-02-26 12:01:09 +0900763 &irqpin0_device,
764 &irqpin1_device,
765 &irqpin2_device,
766 &irqpin3_device,
Yoshii Takashib028f942010-11-19 13:20:45 +0000767};
768
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000769#define SRCR2 IOMEM(0xe61580b0)
Magnus Damm681e1b32011-05-24 10:37:16 +0000770
Magnus Damm6d9598e2010-11-17 10:59:31 +0000771void __init sh73a0_add_standard_devices(void)
772{
Magnus Damm681e1b32011-05-24 10:37:16 +0000773 /* Clear software reset bit on SY-DMAC module */
774 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
775
Simon Horman3b00f932013-02-19 10:53:05 +0900776 platform_add_devices(sh73a0_devices_dt,
777 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000778 platform_add_devices(sh73a0_early_devices,
779 ARRAY_SIZE(sh73a0_early_devices));
Yoshii Takashib028f942010-11-19 13:20:45 +0000780 platform_add_devices(sh73a0_late_devices,
781 ARRAY_SIZE(sh73a0_late_devices));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000782}
783
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900784void __init sh73a0_init_delay(void)
785{
786 shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
787}
788
Kuninori Morimotod6720002012-05-10 00:26:58 -0700789/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
790void __init __weak sh73a0_register_twd(void) { }
791
Stephen Warren6bb27d72012-11-08 12:40:59 -0700792void __init sh73a0_earlytimer_init(void)
Magnus Damm3be26fd2012-03-06 17:36:45 +0900793{
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900794 sh73a0_init_delay();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900795 sh73a0_clock_init();
796 shmobile_earlytimer_init();
Kuninori Morimotod6720002012-05-10 00:26:58 -0700797 sh73a0_register_twd();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900798}
799
Magnus Damm6d9598e2010-11-17 10:59:31 +0000800void __init sh73a0_add_early_devices(void)
801{
Simon Horman3b00f932013-02-19 10:53:05 +0900802 early_platform_add_devices(sh73a0_devices_dt,
803 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000804 early_platform_add_devices(sh73a0_early_devices,
805 ARRAY_SIZE(sh73a0_early_devices));
Magnus Damm50e15c32012-02-29 21:37:27 +0900806
807 /* setup early console here as well */
808 shmobile_setup_console();
Magnus Damm6d9598e2010-11-17 10:59:31 +0000809}
Simon Horman48609532012-11-21 22:00:15 +0900810
811#ifdef CONFIG_USE_OF
812
Simon Horman48609532012-11-21 22:00:15 +0900813void __init sh73a0_add_standard_devices_dt(void)
814{
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200815 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
816
Simon Horman48609532012-11-21 22:00:15 +0900817 /* clocks are setup late during boot in the case of DT */
818 sh73a0_clock_init();
819
Simon Horman3b00f932013-02-19 10:53:05 +0900820 platform_add_devices(sh73a0_devices_dt,
821 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Dammea315972013-07-01 14:42:04 +0900822 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200823
824 /* Instantiate cpufreq-cpu0 */
825 platform_device_register_full(&devinfo);
Simon Horman48609532012-11-21 22:00:15 +0900826}
827
828static const char *sh73a0_boards_compat_dt[] __initdata = {
829 "renesas,sh73a0",
830 NULL,
831};
832
833DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
Simon Hormanf9989502013-02-15 21:38:20 +0900834 .smp = smp_ops(sh73a0_smp_ops),
Simon Horman48609532012-11-21 22:00:15 +0900835 .map_io = sh73a0_map_io,
Simon Horman3b00f932013-02-19 10:53:05 +0900836 .init_early = sh73a0_init_delay,
Simon Horman48609532012-11-21 22:00:15 +0900837 .nr_irqs = NR_IRQS_LEGACY,
Simon Horman48609532012-11-21 22:00:15 +0900838 .init_machine = sh73a0_add_standard_devices_dt,
Simon Horman48609532012-11-21 22:00:15 +0900839 .dt_compat = sh73a0_boards_compat_dt,
840MACHINE_END
841#endif /* CONFIG_USE_OF */