blob: f74ab530c71df767a8d6f9f1dcc0ea018f328298 [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, \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010078 .flags = UPF_BOOT_AUTOCONF, \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010079 .scscr = SCSCR_RE | SCSCR_TE, \
80}; \
81 \
Laurent Pinchart31e1ee82013-12-06 10:59:31 +010082static struct resource scif##index##_resources[] = { \
83 DEFINE_RES_MEM(baseaddr, 0x100), \
84 DEFINE_RES_IRQ(irq), \
85}; \
86 \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010087static struct platform_device scif##index##_device = { \
88 .name = "sh-sci", \
89 .id = index, \
Laurent Pinchart31e1ee82013-12-06 10:59:31 +010090 .resource = scif##index##_resources, \
91 .num_resources = ARRAY_SIZE(scif##index##_resources), \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010092 .dev = { \
93 .platform_data = &scif##index##_platform_data, \
94 }, \
95}
Magnus Damm6d9598e2010-11-17 10:59:31 +000096
Laurent Pinchartd000fff2013-12-06 10:59:22 +010097SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
98SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
99SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
100SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
101SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
102SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
103SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
104SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
105SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000106
107static struct sh_timer_config cmt10_platform_data = {
108 .name = "CMT10",
109 .channel_offset = 0x10,
110 .timer_bit = 0,
Simon Horman5600a842013-05-22 19:47:05 +0900111 .clockevent_rating = 80,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000112 .clocksource_rating = 125,
113};
114
115static struct resource cmt10_resources[] = {
116 [0] = {
117 .name = "CMT10",
118 .start = 0xe6138010,
119 .end = 0xe613801b,
120 .flags = IORESOURCE_MEM,
121 },
122 [1] = {
123 .start = gic_spi(65),
124 .flags = IORESOURCE_IRQ,
125 },
126};
127
128static struct platform_device cmt10_device = {
129 .name = "sh_cmt",
130 .id = 10,
131 .dev = {
132 .platform_data = &cmt10_platform_data,
133 },
134 .resource = cmt10_resources,
135 .num_resources = ARRAY_SIZE(cmt10_resources),
136};
137
Magnus Damm5010f3d2010-12-21 08:40:59 +0000138/* TMU */
139static struct sh_timer_config tmu00_platform_data = {
140 .name = "TMU00",
141 .channel_offset = 0x4,
142 .timer_bit = 0,
143 .clockevent_rating = 200,
144};
145
146static struct resource tmu00_resources[] = {
Kuninori Morimotobd6dfe52013-10-07 22:58:42 -0700147 [0] = DEFINE_RES_MEM(0xfff60008, 0xc),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000148 [1] = {
149 .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
150 .flags = IORESOURCE_IRQ,
151 },
152};
153
154static struct platform_device tmu00_device = {
155 .name = "sh_tmu",
156 .id = 0,
157 .dev = {
158 .platform_data = &tmu00_platform_data,
159 },
160 .resource = tmu00_resources,
161 .num_resources = ARRAY_SIZE(tmu00_resources),
162};
163
164static struct sh_timer_config tmu01_platform_data = {
165 .name = "TMU01",
166 .channel_offset = 0x10,
167 .timer_bit = 1,
168 .clocksource_rating = 200,
169};
170
171static struct resource tmu01_resources[] = {
Kuninori Morimotobd6dfe52013-10-07 22:58:42 -0700172 [0] = DEFINE_RES_MEM(0xfff60014, 0xc),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000173 [1] = {
174 .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
175 .flags = IORESOURCE_IRQ,
176 },
177};
178
179static struct platform_device tmu01_device = {
180 .name = "sh_tmu",
181 .id = 1,
182 .dev = {
183 .platform_data = &tmu01_platform_data,
184 },
185 .resource = tmu01_resources,
186 .num_resources = ARRAY_SIZE(tmu01_resources),
187};
188
Yoshii Takashib028f942010-11-19 13:20:45 +0000189static struct resource i2c0_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700190 [0] = DEFINE_RES_MEM(0xe6820000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000191 [1] = {
192 .start = gic_spi(167),
193 .end = gic_spi(170),
194 .flags = IORESOURCE_IRQ,
195 },
196};
197
198static struct resource i2c1_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700199 [0] = DEFINE_RES_MEM(0xe6822000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000200 [1] = {
201 .start = gic_spi(51),
202 .end = gic_spi(54),
203 .flags = IORESOURCE_IRQ,
204 },
205};
206
207static struct resource i2c2_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700208 [0] = DEFINE_RES_MEM(0xe6824000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000209 [1] = {
210 .start = gic_spi(171),
211 .end = gic_spi(174),
212 .flags = IORESOURCE_IRQ,
213 },
214};
215
216static struct resource i2c3_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700217 [0] = DEFINE_RES_MEM(0xe6826000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000218 [1] = {
219 .start = gic_spi(183),
220 .end = gic_spi(186),
221 .flags = IORESOURCE_IRQ,
222 },
223};
224
225static struct resource i2c4_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700226 [0] = DEFINE_RES_MEM(0xe6828000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000227 [1] = {
228 .start = gic_spi(187),
229 .end = gic_spi(190),
230 .flags = IORESOURCE_IRQ,
231 },
232};
233
234static struct platform_device i2c0_device = {
235 .name = "i2c-sh_mobile",
236 .id = 0,
237 .resource = i2c0_resources,
238 .num_resources = ARRAY_SIZE(i2c0_resources),
239};
240
241static struct platform_device i2c1_device = {
242 .name = "i2c-sh_mobile",
243 .id = 1,
244 .resource = i2c1_resources,
245 .num_resources = ARRAY_SIZE(i2c1_resources),
246};
247
248static struct platform_device i2c2_device = {
249 .name = "i2c-sh_mobile",
250 .id = 2,
251 .resource = i2c2_resources,
252 .num_resources = ARRAY_SIZE(i2c2_resources),
253};
254
255static struct platform_device i2c3_device = {
256 .name = "i2c-sh_mobile",
257 .id = 3,
258 .resource = i2c3_resources,
259 .num_resources = ARRAY_SIZE(i2c3_resources),
260};
261
262static struct platform_device i2c4_device = {
263 .name = "i2c-sh_mobile",
264 .id = 4,
265 .resource = i2c4_resources,
266 .num_resources = ARRAY_SIZE(i2c4_resources),
267};
268
Magnus Damm681e1b32011-05-24 10:37:16 +0000269static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
270 {
271 .slave_id = SHDMA_SLAVE_SCIF0_TX,
272 .addr = 0xe6c40020,
273 .chcr = CHCR_TX(XMIT_SZ_8BIT),
274 .mid_rid = 0x21,
275 }, {
276 .slave_id = SHDMA_SLAVE_SCIF0_RX,
277 .addr = 0xe6c40024,
278 .chcr = CHCR_RX(XMIT_SZ_8BIT),
279 .mid_rid = 0x22,
280 }, {
281 .slave_id = SHDMA_SLAVE_SCIF1_TX,
282 .addr = 0xe6c50020,
283 .chcr = CHCR_TX(XMIT_SZ_8BIT),
284 .mid_rid = 0x25,
285 }, {
286 .slave_id = SHDMA_SLAVE_SCIF1_RX,
287 .addr = 0xe6c50024,
288 .chcr = CHCR_RX(XMIT_SZ_8BIT),
289 .mid_rid = 0x26,
290 }, {
291 .slave_id = SHDMA_SLAVE_SCIF2_TX,
292 .addr = 0xe6c60020,
293 .chcr = CHCR_TX(XMIT_SZ_8BIT),
294 .mid_rid = 0x29,
295 }, {
296 .slave_id = SHDMA_SLAVE_SCIF2_RX,
297 .addr = 0xe6c60024,
298 .chcr = CHCR_RX(XMIT_SZ_8BIT),
299 .mid_rid = 0x2a,
300 }, {
301 .slave_id = SHDMA_SLAVE_SCIF3_TX,
302 .addr = 0xe6c70020,
303 .chcr = CHCR_TX(XMIT_SZ_8BIT),
304 .mid_rid = 0x2d,
305 }, {
306 .slave_id = SHDMA_SLAVE_SCIF3_RX,
307 .addr = 0xe6c70024,
308 .chcr = CHCR_RX(XMIT_SZ_8BIT),
309 .mid_rid = 0x2e,
310 }, {
311 .slave_id = SHDMA_SLAVE_SCIF4_TX,
312 .addr = 0xe6c80020,
313 .chcr = CHCR_TX(XMIT_SZ_8BIT),
314 .mid_rid = 0x39,
315 }, {
316 .slave_id = SHDMA_SLAVE_SCIF4_RX,
317 .addr = 0xe6c80024,
318 .chcr = CHCR_RX(XMIT_SZ_8BIT),
319 .mid_rid = 0x3a,
320 }, {
321 .slave_id = SHDMA_SLAVE_SCIF5_TX,
322 .addr = 0xe6cb0020,
323 .chcr = CHCR_TX(XMIT_SZ_8BIT),
324 .mid_rid = 0x35,
325 }, {
326 .slave_id = SHDMA_SLAVE_SCIF5_RX,
327 .addr = 0xe6cb0024,
328 .chcr = CHCR_RX(XMIT_SZ_8BIT),
329 .mid_rid = 0x36,
330 }, {
331 .slave_id = SHDMA_SLAVE_SCIF6_TX,
332 .addr = 0xe6cc0020,
333 .chcr = CHCR_TX(XMIT_SZ_8BIT),
334 .mid_rid = 0x1d,
335 }, {
336 .slave_id = SHDMA_SLAVE_SCIF6_RX,
337 .addr = 0xe6cc0024,
338 .chcr = CHCR_RX(XMIT_SZ_8BIT),
339 .mid_rid = 0x1e,
340 }, {
341 .slave_id = SHDMA_SLAVE_SCIF7_TX,
342 .addr = 0xe6cd0020,
343 .chcr = CHCR_TX(XMIT_SZ_8BIT),
344 .mid_rid = 0x19,
345 }, {
346 .slave_id = SHDMA_SLAVE_SCIF7_RX,
347 .addr = 0xe6cd0024,
348 .chcr = CHCR_RX(XMIT_SZ_8BIT),
349 .mid_rid = 0x1a,
350 }, {
351 .slave_id = SHDMA_SLAVE_SCIF8_TX,
352 .addr = 0xe6c30040,
353 .chcr = CHCR_TX(XMIT_SZ_8BIT),
354 .mid_rid = 0x3d,
355 }, {
356 .slave_id = SHDMA_SLAVE_SCIF8_RX,
357 .addr = 0xe6c30060,
358 .chcr = CHCR_RX(XMIT_SZ_8BIT),
359 .mid_rid = 0x3e,
360 }, {
361 .slave_id = SHDMA_SLAVE_SDHI0_TX,
362 .addr = 0xee100030,
363 .chcr = CHCR_TX(XMIT_SZ_16BIT),
364 .mid_rid = 0xc1,
365 }, {
366 .slave_id = SHDMA_SLAVE_SDHI0_RX,
367 .addr = 0xee100030,
368 .chcr = CHCR_RX(XMIT_SZ_16BIT),
369 .mid_rid = 0xc2,
370 }, {
371 .slave_id = SHDMA_SLAVE_SDHI1_TX,
372 .addr = 0xee120030,
373 .chcr = CHCR_TX(XMIT_SZ_16BIT),
374 .mid_rid = 0xc9,
375 }, {
376 .slave_id = SHDMA_SLAVE_SDHI1_RX,
377 .addr = 0xee120030,
378 .chcr = CHCR_RX(XMIT_SZ_16BIT),
379 .mid_rid = 0xca,
380 }, {
381 .slave_id = SHDMA_SLAVE_SDHI2_TX,
382 .addr = 0xee140030,
383 .chcr = CHCR_TX(XMIT_SZ_16BIT),
384 .mid_rid = 0xcd,
385 }, {
386 .slave_id = SHDMA_SLAVE_SDHI2_RX,
387 .addr = 0xee140030,
388 .chcr = CHCR_RX(XMIT_SZ_16BIT),
389 .mid_rid = 0xce,
390 }, {
391 .slave_id = SHDMA_SLAVE_MMCIF_TX,
392 .addr = 0xe6bd0034,
393 .chcr = CHCR_TX(XMIT_SZ_32BIT),
394 .mid_rid = 0xd1,
395 }, {
396 .slave_id = SHDMA_SLAVE_MMCIF_RX,
397 .addr = 0xe6bd0034,
398 .chcr = CHCR_RX(XMIT_SZ_32BIT),
399 .mid_rid = 0xd2,
400 },
401};
402
403#define DMAE_CHANNEL(_offset) \
404 { \
405 .offset = _offset - 0x20, \
406 .dmars = _offset - 0x20 + 0x40, \
407 }
408
409static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
410 DMAE_CHANNEL(0x8000),
411 DMAE_CHANNEL(0x8080),
412 DMAE_CHANNEL(0x8100),
413 DMAE_CHANNEL(0x8180),
414 DMAE_CHANNEL(0x8200),
415 DMAE_CHANNEL(0x8280),
416 DMAE_CHANNEL(0x8300),
417 DMAE_CHANNEL(0x8380),
418 DMAE_CHANNEL(0x8400),
419 DMAE_CHANNEL(0x8480),
420 DMAE_CHANNEL(0x8500),
421 DMAE_CHANNEL(0x8580),
422 DMAE_CHANNEL(0x8600),
423 DMAE_CHANNEL(0x8680),
424 DMAE_CHANNEL(0x8700),
425 DMAE_CHANNEL(0x8780),
426 DMAE_CHANNEL(0x8800),
427 DMAE_CHANNEL(0x8880),
428 DMAE_CHANNEL(0x8900),
429 DMAE_CHANNEL(0x8980),
430};
431
Magnus Damm681e1b32011-05-24 10:37:16 +0000432static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
433 .slave = sh73a0_dmae_slaves,
434 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
435 .channel = sh73a0_dmae_channels,
436 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700437 .ts_low_shift = TS_LOW_SHIFT,
438 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
439 .ts_high_shift = TS_HI_SHIFT,
440 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
441 .ts_shift = dma_ts_shift,
442 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Magnus Damm681e1b32011-05-24 10:37:16 +0000443 .dmaor_init = DMAOR_DME,
444};
445
446static struct resource sh73a0_dmae_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000447 DEFINE_RES_MEM(0xfe000020, 0x89e0),
Magnus Damm681e1b32011-05-24 10:37:16 +0000448 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900449 .name = "error_irq",
Magnus Damm681e1b32011-05-24 10:37:16 +0000450 .start = gic_spi(129),
451 .end = gic_spi(129),
452 .flags = IORESOURCE_IRQ,
453 },
454 {
455 /* IRQ for channels 0-19 */
456 .start = gic_spi(109),
457 .end = gic_spi(128),
458 .flags = IORESOURCE_IRQ,
459 },
460};
461
462static struct platform_device dma0_device = {
463 .name = "sh-dma-engine",
464 .id = 0,
465 .resource = sh73a0_dmae_resources,
466 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
467 .dev = {
468 .platform_data = &sh73a0_dmae_platform_data,
469 },
470};
471
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700472/* MPDMAC */
473static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
474 {
475 .slave_id = SHDMA_SLAVE_FSI2A_RX,
476 .addr = 0xec230020,
477 .chcr = CHCR_RX(XMIT_SZ_32BIT),
478 .mid_rid = 0xd6, /* CHECK ME */
479 }, {
480 .slave_id = SHDMA_SLAVE_FSI2A_TX,
481 .addr = 0xec230024,
482 .chcr = CHCR_TX(XMIT_SZ_32BIT),
483 .mid_rid = 0xd5, /* CHECK ME */
484 }, {
485 .slave_id = SHDMA_SLAVE_FSI2C_RX,
486 .addr = 0xec230060,
487 .chcr = CHCR_RX(XMIT_SZ_32BIT),
488 .mid_rid = 0xda, /* CHECK ME */
489 }, {
490 .slave_id = SHDMA_SLAVE_FSI2C_TX,
491 .addr = 0xec230064,
492 .chcr = CHCR_TX(XMIT_SZ_32BIT),
493 .mid_rid = 0xd9, /* CHECK ME */
494 }, {
495 .slave_id = SHDMA_SLAVE_FSI2B_RX,
496 .addr = 0xec240020,
497 .chcr = CHCR_RX(XMIT_SZ_32BIT),
498 .mid_rid = 0x8e, /* CHECK ME */
499 }, {
500 .slave_id = SHDMA_SLAVE_FSI2B_TX,
501 .addr = 0xec240024,
502 .chcr = CHCR_RX(XMIT_SZ_32BIT),
503 .mid_rid = 0x8d, /* CHECK ME */
504 }, {
505 .slave_id = SHDMA_SLAVE_FSI2D_RX,
506 .addr = 0xec240060,
507 .chcr = CHCR_RX(XMIT_SZ_32BIT),
508 .mid_rid = 0x9a, /* CHECK ME */
509 },
510};
511
512#define MPDMA_CHANNEL(a, b, c) \
513{ \
514 .offset = a, \
515 .dmars = b, \
516 .dmars_bit = c, \
517 .chclr_offset = (0x220 - 0x20) + a \
518}
519
520static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
521 MPDMA_CHANNEL(0x00, 0, 0),
522 MPDMA_CHANNEL(0x10, 0, 8),
523 MPDMA_CHANNEL(0x20, 4, 0),
524 MPDMA_CHANNEL(0x30, 4, 8),
525 MPDMA_CHANNEL(0x50, 8, 0),
526 MPDMA_CHANNEL(0x70, 8, 8),
527};
528
529static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
530 .slave = sh73a0_mpdma_slaves,
531 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
532 .channel = sh73a0_mpdma_channels,
533 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700534 .ts_low_shift = TS_LOW_SHIFT,
535 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
536 .ts_high_shift = TS_HI_SHIFT,
537 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
538 .ts_shift = dma_ts_shift,
539 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700540 .dmaor_init = DMAOR_DME,
541 .chclr_present = 1,
542};
543
544/* Resource order important! */
545static struct resource sh73a0_mpdma_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000546 /* Channel registers and DMAOR */
547 DEFINE_RES_MEM(0xec618020, 0x270),
548 /* DMARSx */
549 DEFINE_RES_MEM(0xec619000, 0xc),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700550 {
551 .name = "error_irq",
552 .start = gic_spi(181),
553 .end = gic_spi(181),
554 .flags = IORESOURCE_IRQ,
555 },
556 {
557 /* IRQ for channels 0-5 */
558 .start = gic_spi(175),
559 .end = gic_spi(180),
560 .flags = IORESOURCE_IRQ,
561 },
562};
563
564static struct platform_device mpdma0_device = {
565 .name = "sh-dma-engine",
566 .id = 1,
567 .resource = sh73a0_mpdma_resources,
568 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
569 .dev = {
570 .platform_data = &sh73a0_mpdma_platform_data,
571 },
572};
573
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900574static struct resource pmu_resources[] = {
575 [0] = {
576 .start = gic_spi(55),
577 .end = gic_spi(55),
578 .flags = IORESOURCE_IRQ,
579 },
580 [1] = {
581 .start = gic_spi(56),
582 .end = gic_spi(56),
583 .flags = IORESOURCE_IRQ,
584 },
585};
586
587static struct platform_device pmu_device = {
588 .name = "arm-pmu",
589 .id = -1,
590 .num_resources = ARRAY_SIZE(pmu_resources),
591 .resource = pmu_resources,
592};
593
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900594/* an IPMMU module for ICB */
595static struct resource ipmmu_resources[] = {
Kuninori Morimoto6244cd72013-10-07 22:59:06 -0700596 DEFINE_RES_MEM(0xfe951000, 0x100),
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900597};
598
599static const char * const ipmmu_dev_names[] = {
600 "sh_mobile_lcdc_fb.0",
601};
602
603static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
604 .dev_names = ipmmu_dev_names,
605 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
606};
607
608static struct platform_device ipmmu_device = {
609 .name = "ipmmu",
610 .id = -1,
611 .dev = {
612 .platform_data = &ipmmu_platform_data,
613 },
614 .resource = ipmmu_resources,
615 .num_resources = ARRAY_SIZE(ipmmu_resources),
616};
617
Magnus Damm1461f8b2013-03-06 15:08:31 +0900618static struct renesas_intc_irqpin_config irqpin0_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900619 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
620};
621
622static struct resource irqpin0_resources[] = {
623 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
624 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
625 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
626 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
627 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
628 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
629 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
630 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
631 DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
632 DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
633 DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
634 DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
635 DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
636};
637
638static struct platform_device irqpin0_device = {
639 .name = "renesas_intc_irqpin",
640 .id = 0,
641 .resource = irqpin0_resources,
642 .num_resources = ARRAY_SIZE(irqpin0_resources),
643 .dev = {
644 .platform_data = &irqpin0_platform_data,
645 },
646};
647
Magnus Damm1461f8b2013-03-06 15:08:31 +0900648static struct renesas_intc_irqpin_config irqpin1_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900649 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
650 .control_parent = true, /* Disable spurious IRQ10 */
651};
652
653static struct resource irqpin1_resources[] = {
654 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
655 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
656 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
657 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
658 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
659 DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
660 DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
661 DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
662 DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
663 DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
664 DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
665 DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
666 DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
667};
668
669static struct platform_device irqpin1_device = {
670 .name = "renesas_intc_irqpin",
671 .id = 1,
672 .resource = irqpin1_resources,
673 .num_resources = ARRAY_SIZE(irqpin1_resources),
674 .dev = {
675 .platform_data = &irqpin1_platform_data,
676 },
677};
678
Magnus Damm1461f8b2013-03-06 15:08:31 +0900679static struct renesas_intc_irqpin_config irqpin2_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900680 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
681};
682
683static struct resource irqpin2_resources[] = {
684 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
685 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
686 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
687 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
688 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
689 DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
690 DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
691 DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
692 DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
693 DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
694 DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
695 DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
696 DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
697};
698
699static struct platform_device irqpin2_device = {
700 .name = "renesas_intc_irqpin",
701 .id = 2,
702 .resource = irqpin2_resources,
703 .num_resources = ARRAY_SIZE(irqpin2_resources),
704 .dev = {
705 .platform_data = &irqpin2_platform_data,
706 },
707};
708
Magnus Damm1461f8b2013-03-06 15:08:31 +0900709static struct renesas_intc_irqpin_config irqpin3_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900710 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
711};
712
713static struct resource irqpin3_resources[] = {
714 DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
715 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
716 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
717 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
718 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
719 DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
720 DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
721 DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
722 DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
723 DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
724 DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
725 DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
726 DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
727};
728
729static struct platform_device irqpin3_device = {
730 .name = "renesas_intc_irqpin",
731 .id = 3,
732 .resource = irqpin3_resources,
733 .num_resources = ARRAY_SIZE(irqpin3_resources),
734 .dev = {
735 .platform_data = &irqpin3_platform_data,
736 },
737};
738
Simon Horman3b00f932013-02-19 10:53:05 +0900739static struct platform_device *sh73a0_devices_dt[] __initdata = {
Magnus Damm6d9598e2010-11-17 10:59:31 +0000740 &scif0_device,
741 &scif1_device,
742 &scif2_device,
743 &scif3_device,
744 &scif4_device,
745 &scif5_device,
746 &scif6_device,
747 &scif7_device,
748 &scif8_device,
749 &cmt10_device,
Simon Horman48609532012-11-21 22:00:15 +0900750};
751
752static struct platform_device *sh73a0_early_devices[] __initdata = {
Magnus Damm5010f3d2010-12-21 08:40:59 +0000753 &tmu00_device,
754 &tmu01_device,
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900755 &ipmmu_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000756};
757
Yoshii Takashib028f942010-11-19 13:20:45 +0000758static struct platform_device *sh73a0_late_devices[] __initdata = {
759 &i2c0_device,
760 &i2c1_device,
761 &i2c2_device,
762 &i2c3_device,
763 &i2c4_device,
Magnus Damm681e1b32011-05-24 10:37:16 +0000764 &dma0_device,
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700765 &mpdma0_device,
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900766 &pmu_device,
Magnus Damm341eb542013-02-26 12:01:09 +0900767 &irqpin0_device,
768 &irqpin1_device,
769 &irqpin2_device,
770 &irqpin3_device,
Yoshii Takashib028f942010-11-19 13:20:45 +0000771};
772
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000773#define SRCR2 IOMEM(0xe61580b0)
Magnus Damm681e1b32011-05-24 10:37:16 +0000774
Magnus Damm6d9598e2010-11-17 10:59:31 +0000775void __init sh73a0_add_standard_devices(void)
776{
Magnus Damm681e1b32011-05-24 10:37:16 +0000777 /* Clear software reset bit on SY-DMAC module */
778 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
779
Simon Horman3b00f932013-02-19 10:53:05 +0900780 platform_add_devices(sh73a0_devices_dt,
781 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000782 platform_add_devices(sh73a0_early_devices,
783 ARRAY_SIZE(sh73a0_early_devices));
Yoshii Takashib028f942010-11-19 13:20:45 +0000784 platform_add_devices(sh73a0_late_devices,
785 ARRAY_SIZE(sh73a0_late_devices));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000786}
787
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900788void __init sh73a0_init_delay(void)
789{
790 shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
791}
792
Kuninori Morimotod6720002012-05-10 00:26:58 -0700793/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
794void __init __weak sh73a0_register_twd(void) { }
795
Stephen Warren6bb27d72012-11-08 12:40:59 -0700796void __init sh73a0_earlytimer_init(void)
Magnus Damm3be26fd2012-03-06 17:36:45 +0900797{
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900798 sh73a0_init_delay();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900799 sh73a0_clock_init();
800 shmobile_earlytimer_init();
Kuninori Morimotod6720002012-05-10 00:26:58 -0700801 sh73a0_register_twd();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900802}
803
Magnus Damm6d9598e2010-11-17 10:59:31 +0000804void __init sh73a0_add_early_devices(void)
805{
Simon Horman3b00f932013-02-19 10:53:05 +0900806 early_platform_add_devices(sh73a0_devices_dt,
807 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000808 early_platform_add_devices(sh73a0_early_devices,
809 ARRAY_SIZE(sh73a0_early_devices));
Magnus Damm50e15c32012-02-29 21:37:27 +0900810
811 /* setup early console here as well */
812 shmobile_setup_console();
Magnus Damm6d9598e2010-11-17 10:59:31 +0000813}
Simon Horman48609532012-11-21 22:00:15 +0900814
815#ifdef CONFIG_USE_OF
816
Simon Horman48609532012-11-21 22:00:15 +0900817void __init sh73a0_add_standard_devices_dt(void)
818{
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200819 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
820
Simon Horman48609532012-11-21 22:00:15 +0900821 /* clocks are setup late during boot in the case of DT */
822 sh73a0_clock_init();
823
Simon Horman3b00f932013-02-19 10:53:05 +0900824 platform_add_devices(sh73a0_devices_dt,
825 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Dammea315972013-07-01 14:42:04 +0900826 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200827
828 /* Instantiate cpufreq-cpu0 */
829 platform_device_register_full(&devinfo);
Simon Horman48609532012-11-21 22:00:15 +0900830}
831
832static const char *sh73a0_boards_compat_dt[] __initdata = {
833 "renesas,sh73a0",
834 NULL,
835};
836
837DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
Simon Hormanf9989502013-02-15 21:38:20 +0900838 .smp = smp_ops(sh73a0_smp_ops),
Simon Horman48609532012-11-21 22:00:15 +0900839 .map_io = sh73a0_map_io,
Simon Horman3b00f932013-02-19 10:53:05 +0900840 .init_early = sh73a0_init_delay,
Simon Horman48609532012-11-21 22:00:15 +0900841 .nr_irqs = NR_IRQS_LEGACY,
Simon Horman48609532012-11-21 22:00:15 +0900842 .init_machine = sh73a0_add_standard_devices_dt,
Simon Horman48609532012-11-21 22:00:15 +0900843 .dt_compat = sh73a0_boards_compat_dt,
844MACHINE_END
845#endif /* CONFIG_USE_OF */