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