blob: b5d0cf579c6196d023266e81840d7800184c9999 [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_timer.h>
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +090033#include <linux/platform_data/sh_ipmmu.h>
Magnus Damm341eb542013-02-26 12:01:09 +090034#include <linux/platform_data/irq-renesas-intc-irqpin.h>
Geert Uytterhoevended59d62014-06-20 18:53:09 +020035
Magnus Damm6d9598e2010-11-17 10:59:31 +000036#include <asm/mach-types.h>
Magnus Damm50e15c32012-02-29 21:37:27 +090037#include <asm/mach/map.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000038#include <asm/mach/arch.h>
Magnus Damm3be26fd2012-03-06 17:36:45 +090039#include <asm/mach/time.h>
Geert Uytterhoevended59d62014-06-20 18:53:09 +020040
Magnus Dammfd44aa52014-06-17 16:47:37 +090041#include "common.h"
Magnus Damm74ac0de2014-06-17 16:47:13 +090042#include "dma-register.h"
Geert Uytterhoeven86155b32014-08-20 15:39:23 +020043#include "intc.h"
Magnus Dammb6bab122014-06-17 16:47:29 +090044#include "irqs.h"
Geert Uytterhoevended59d62014-06-20 18:53:09 +020045#include "sh73a0.h"
Magnus Damm6d9598e2010-11-17 10:59:31 +000046
Magnus Damm50e15c32012-02-29 21:37:27 +090047static struct map_desc sh73a0_io_desc[] __initdata = {
48 /* create a 1:1 entity map for 0xe6xxxxxx
49 * used by CPGA, INTC and PFC.
50 */
51 {
52 .virtual = 0xe6000000,
53 .pfn = __phys_to_pfn(0xe6000000),
54 .length = 256 << 20,
55 .type = MT_DEVICE_NONSHARED
56 },
57};
58
59void __init sh73a0_map_io(void)
60{
Geert Uytterhoeven7a2071c2014-11-14 16:49:47 +010061 debug_ll_io_init();
Magnus Damm50e15c32012-02-29 21:37:27 +090062 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
63}
64
Magnus Damm474f6752013-06-27 17:09:01 +090065/* PFC */
66static struct resource pfc_resources[] __initdata = {
67 DEFINE_RES_MEM(0xe6050000, 0x8000),
68 DEFINE_RES_MEM(0xe605801c, 0x000c),
Laurent Pinchart994d66a2012-12-15 23:51:28 +010069};
70
71void __init sh73a0_pinmux_init(void)
72{
Magnus Damm474f6752013-06-27 17:09:01 +090073 platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
74 ARRAY_SIZE(pfc_resources));
Laurent Pinchart994d66a2012-12-15 23:51:28 +010075}
76
Laurent Pinchartd000fff2013-12-06 10:59:22 +010077/* SCIF */
78#define SH73A0_SCIF(scif_type, index, baseaddr, irq) \
79static struct plat_sci_port scif##index##_platform_data = { \
80 .type = scif_type, \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010081 .flags = UPF_BOOT_AUTOCONF, \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010082 .scscr = SCSCR_RE | SCSCR_TE, \
83}; \
84 \
Laurent Pinchart31e1ee82013-12-06 10:59:31 +010085static struct resource scif##index##_resources[] = { \
86 DEFINE_RES_MEM(baseaddr, 0x100), \
87 DEFINE_RES_IRQ(irq), \
88}; \
89 \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010090static struct platform_device scif##index##_device = { \
91 .name = "sh-sci", \
92 .id = index, \
Laurent Pinchart31e1ee82013-12-06 10:59:31 +010093 .resource = scif##index##_resources, \
94 .num_resources = ARRAY_SIZE(scif##index##_resources), \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010095 .dev = { \
96 .platform_data = &scif##index##_platform_data, \
97 }, \
98}
Magnus Damm6d9598e2010-11-17 10:59:31 +000099
Laurent Pinchartd000fff2013-12-06 10:59:22 +0100100SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
101SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
102SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
103SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
104SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
105SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
106SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
107SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
108SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000109
Laurent Pinchart652256f2014-04-23 13:15:10 +0200110static struct sh_timer_config cmt1_platform_data = {
111 .channels_mask = 0x3f,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000112};
113
Laurent Pinchart652256f2014-04-23 13:15:10 +0200114static struct resource cmt1_resources[] = {
115 DEFINE_RES_MEM(0xe6138000, 0x200),
116 DEFINE_RES_IRQ(gic_spi(65)),
Magnus Damm6d9598e2010-11-17 10:59:31 +0000117};
118
Laurent Pinchart652256f2014-04-23 13:15:10 +0200119static struct platform_device cmt1_device = {
120 .name = "sh-cmt-48",
121 .id = 1,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000122 .dev = {
Laurent Pinchart652256f2014-04-23 13:15:10 +0200123 .platform_data = &cmt1_platform_data,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000124 },
Laurent Pinchart652256f2014-04-23 13:15:10 +0200125 .resource = cmt1_resources,
126 .num_resources = ARRAY_SIZE(cmt1_resources),
Magnus Damm6d9598e2010-11-17 10:59:31 +0000127};
128
Magnus Damm5010f3d2010-12-21 08:40:59 +0000129/* TMU */
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200130static struct sh_timer_config tmu0_platform_data = {
131 .channels_mask = 7,
Magnus Damm5010f3d2010-12-21 08:40:59 +0000132};
133
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200134static struct resource tmu0_resources[] = {
135 DEFINE_RES_MEM(0xfff60000, 0x2c),
136 DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
137 DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
138 DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000139};
140
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200141static struct platform_device tmu0_device = {
142 .name = "sh-tmu",
Magnus Damm5010f3d2010-12-21 08:40:59 +0000143 .id = 0,
144 .dev = {
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200145 .platform_data = &tmu0_platform_data,
Magnus Damm5010f3d2010-12-21 08:40:59 +0000146 },
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200147 .resource = tmu0_resources,
148 .num_resources = ARRAY_SIZE(tmu0_resources),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000149};
150
Yoshii Takashib028f942010-11-19 13:20:45 +0000151static struct resource i2c0_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700152 [0] = DEFINE_RES_MEM(0xe6820000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000153 [1] = {
154 .start = gic_spi(167),
155 .end = gic_spi(170),
156 .flags = IORESOURCE_IRQ,
157 },
158};
159
160static struct resource i2c1_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700161 [0] = DEFINE_RES_MEM(0xe6822000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000162 [1] = {
163 .start = gic_spi(51),
164 .end = gic_spi(54),
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
169static struct resource i2c2_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700170 [0] = DEFINE_RES_MEM(0xe6824000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000171 [1] = {
172 .start = gic_spi(171),
173 .end = gic_spi(174),
174 .flags = IORESOURCE_IRQ,
175 },
176};
177
178static struct resource i2c3_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700179 [0] = DEFINE_RES_MEM(0xe6826000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000180 [1] = {
181 .start = gic_spi(183),
182 .end = gic_spi(186),
183 .flags = IORESOURCE_IRQ,
184 },
185};
186
187static struct resource i2c4_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700188 [0] = DEFINE_RES_MEM(0xe6828000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000189 [1] = {
190 .start = gic_spi(187),
191 .end = gic_spi(190),
192 .flags = IORESOURCE_IRQ,
193 },
194};
195
196static struct platform_device i2c0_device = {
197 .name = "i2c-sh_mobile",
198 .id = 0,
199 .resource = i2c0_resources,
200 .num_resources = ARRAY_SIZE(i2c0_resources),
201};
202
203static struct platform_device i2c1_device = {
204 .name = "i2c-sh_mobile",
205 .id = 1,
206 .resource = i2c1_resources,
207 .num_resources = ARRAY_SIZE(i2c1_resources),
208};
209
210static struct platform_device i2c2_device = {
211 .name = "i2c-sh_mobile",
212 .id = 2,
213 .resource = i2c2_resources,
214 .num_resources = ARRAY_SIZE(i2c2_resources),
215};
216
217static struct platform_device i2c3_device = {
218 .name = "i2c-sh_mobile",
219 .id = 3,
220 .resource = i2c3_resources,
221 .num_resources = ARRAY_SIZE(i2c3_resources),
222};
223
224static struct platform_device i2c4_device = {
225 .name = "i2c-sh_mobile",
226 .id = 4,
227 .resource = i2c4_resources,
228 .num_resources = ARRAY_SIZE(i2c4_resources),
229};
230
Magnus Damm681e1b32011-05-24 10:37:16 +0000231static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
232 {
233 .slave_id = SHDMA_SLAVE_SCIF0_TX,
234 .addr = 0xe6c40020,
235 .chcr = CHCR_TX(XMIT_SZ_8BIT),
236 .mid_rid = 0x21,
237 }, {
238 .slave_id = SHDMA_SLAVE_SCIF0_RX,
239 .addr = 0xe6c40024,
240 .chcr = CHCR_RX(XMIT_SZ_8BIT),
241 .mid_rid = 0x22,
242 }, {
243 .slave_id = SHDMA_SLAVE_SCIF1_TX,
244 .addr = 0xe6c50020,
245 .chcr = CHCR_TX(XMIT_SZ_8BIT),
246 .mid_rid = 0x25,
247 }, {
248 .slave_id = SHDMA_SLAVE_SCIF1_RX,
249 .addr = 0xe6c50024,
250 .chcr = CHCR_RX(XMIT_SZ_8BIT),
251 .mid_rid = 0x26,
252 }, {
253 .slave_id = SHDMA_SLAVE_SCIF2_TX,
254 .addr = 0xe6c60020,
255 .chcr = CHCR_TX(XMIT_SZ_8BIT),
256 .mid_rid = 0x29,
257 }, {
258 .slave_id = SHDMA_SLAVE_SCIF2_RX,
259 .addr = 0xe6c60024,
260 .chcr = CHCR_RX(XMIT_SZ_8BIT),
261 .mid_rid = 0x2a,
262 }, {
263 .slave_id = SHDMA_SLAVE_SCIF3_TX,
264 .addr = 0xe6c70020,
265 .chcr = CHCR_TX(XMIT_SZ_8BIT),
266 .mid_rid = 0x2d,
267 }, {
268 .slave_id = SHDMA_SLAVE_SCIF3_RX,
269 .addr = 0xe6c70024,
270 .chcr = CHCR_RX(XMIT_SZ_8BIT),
271 .mid_rid = 0x2e,
272 }, {
273 .slave_id = SHDMA_SLAVE_SCIF4_TX,
274 .addr = 0xe6c80020,
275 .chcr = CHCR_TX(XMIT_SZ_8BIT),
276 .mid_rid = 0x39,
277 }, {
278 .slave_id = SHDMA_SLAVE_SCIF4_RX,
279 .addr = 0xe6c80024,
280 .chcr = CHCR_RX(XMIT_SZ_8BIT),
281 .mid_rid = 0x3a,
282 }, {
283 .slave_id = SHDMA_SLAVE_SCIF5_TX,
284 .addr = 0xe6cb0020,
285 .chcr = CHCR_TX(XMIT_SZ_8BIT),
286 .mid_rid = 0x35,
287 }, {
288 .slave_id = SHDMA_SLAVE_SCIF5_RX,
289 .addr = 0xe6cb0024,
290 .chcr = CHCR_RX(XMIT_SZ_8BIT),
291 .mid_rid = 0x36,
292 }, {
293 .slave_id = SHDMA_SLAVE_SCIF6_TX,
294 .addr = 0xe6cc0020,
295 .chcr = CHCR_TX(XMIT_SZ_8BIT),
296 .mid_rid = 0x1d,
297 }, {
298 .slave_id = SHDMA_SLAVE_SCIF6_RX,
299 .addr = 0xe6cc0024,
300 .chcr = CHCR_RX(XMIT_SZ_8BIT),
301 .mid_rid = 0x1e,
302 }, {
303 .slave_id = SHDMA_SLAVE_SCIF7_TX,
304 .addr = 0xe6cd0020,
305 .chcr = CHCR_TX(XMIT_SZ_8BIT),
306 .mid_rid = 0x19,
307 }, {
308 .slave_id = SHDMA_SLAVE_SCIF7_RX,
309 .addr = 0xe6cd0024,
310 .chcr = CHCR_RX(XMIT_SZ_8BIT),
311 .mid_rid = 0x1a,
312 }, {
313 .slave_id = SHDMA_SLAVE_SCIF8_TX,
314 .addr = 0xe6c30040,
315 .chcr = CHCR_TX(XMIT_SZ_8BIT),
316 .mid_rid = 0x3d,
317 }, {
318 .slave_id = SHDMA_SLAVE_SCIF8_RX,
319 .addr = 0xe6c30060,
320 .chcr = CHCR_RX(XMIT_SZ_8BIT),
321 .mid_rid = 0x3e,
322 }, {
323 .slave_id = SHDMA_SLAVE_SDHI0_TX,
324 .addr = 0xee100030,
325 .chcr = CHCR_TX(XMIT_SZ_16BIT),
326 .mid_rid = 0xc1,
327 }, {
328 .slave_id = SHDMA_SLAVE_SDHI0_RX,
329 .addr = 0xee100030,
330 .chcr = CHCR_RX(XMIT_SZ_16BIT),
331 .mid_rid = 0xc2,
332 }, {
333 .slave_id = SHDMA_SLAVE_SDHI1_TX,
334 .addr = 0xee120030,
335 .chcr = CHCR_TX(XMIT_SZ_16BIT),
336 .mid_rid = 0xc9,
337 }, {
338 .slave_id = SHDMA_SLAVE_SDHI1_RX,
339 .addr = 0xee120030,
340 .chcr = CHCR_RX(XMIT_SZ_16BIT),
341 .mid_rid = 0xca,
342 }, {
343 .slave_id = SHDMA_SLAVE_SDHI2_TX,
344 .addr = 0xee140030,
345 .chcr = CHCR_TX(XMIT_SZ_16BIT),
346 .mid_rid = 0xcd,
347 }, {
348 .slave_id = SHDMA_SLAVE_SDHI2_RX,
349 .addr = 0xee140030,
350 .chcr = CHCR_RX(XMIT_SZ_16BIT),
351 .mid_rid = 0xce,
352 }, {
353 .slave_id = SHDMA_SLAVE_MMCIF_TX,
354 .addr = 0xe6bd0034,
355 .chcr = CHCR_TX(XMIT_SZ_32BIT),
356 .mid_rid = 0xd1,
357 }, {
358 .slave_id = SHDMA_SLAVE_MMCIF_RX,
359 .addr = 0xe6bd0034,
360 .chcr = CHCR_RX(XMIT_SZ_32BIT),
361 .mid_rid = 0xd2,
362 },
363};
364
365#define DMAE_CHANNEL(_offset) \
366 { \
367 .offset = _offset - 0x20, \
368 .dmars = _offset - 0x20 + 0x40, \
369 }
370
371static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
372 DMAE_CHANNEL(0x8000),
373 DMAE_CHANNEL(0x8080),
374 DMAE_CHANNEL(0x8100),
375 DMAE_CHANNEL(0x8180),
376 DMAE_CHANNEL(0x8200),
377 DMAE_CHANNEL(0x8280),
378 DMAE_CHANNEL(0x8300),
379 DMAE_CHANNEL(0x8380),
380 DMAE_CHANNEL(0x8400),
381 DMAE_CHANNEL(0x8480),
382 DMAE_CHANNEL(0x8500),
383 DMAE_CHANNEL(0x8580),
384 DMAE_CHANNEL(0x8600),
385 DMAE_CHANNEL(0x8680),
386 DMAE_CHANNEL(0x8700),
387 DMAE_CHANNEL(0x8780),
388 DMAE_CHANNEL(0x8800),
389 DMAE_CHANNEL(0x8880),
390 DMAE_CHANNEL(0x8900),
391 DMAE_CHANNEL(0x8980),
392};
393
Magnus Damm681e1b32011-05-24 10:37:16 +0000394static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
395 .slave = sh73a0_dmae_slaves,
396 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
397 .channel = sh73a0_dmae_channels,
398 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700399 .ts_low_shift = TS_LOW_SHIFT,
400 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
401 .ts_high_shift = TS_HI_SHIFT,
402 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
403 .ts_shift = dma_ts_shift,
404 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Magnus Damm681e1b32011-05-24 10:37:16 +0000405 .dmaor_init = DMAOR_DME,
406};
407
408static struct resource sh73a0_dmae_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000409 DEFINE_RES_MEM(0xfe000020, 0x89e0),
Magnus Damm681e1b32011-05-24 10:37:16 +0000410 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900411 .name = "error_irq",
Magnus Damm681e1b32011-05-24 10:37:16 +0000412 .start = gic_spi(129),
413 .end = gic_spi(129),
414 .flags = IORESOURCE_IRQ,
415 },
416 {
417 /* IRQ for channels 0-19 */
418 .start = gic_spi(109),
419 .end = gic_spi(128),
420 .flags = IORESOURCE_IRQ,
421 },
422};
423
424static struct platform_device dma0_device = {
425 .name = "sh-dma-engine",
426 .id = 0,
427 .resource = sh73a0_dmae_resources,
428 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
429 .dev = {
430 .platform_data = &sh73a0_dmae_platform_data,
431 },
432};
433
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700434/* MPDMAC */
435static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
436 {
437 .slave_id = SHDMA_SLAVE_FSI2A_RX,
438 .addr = 0xec230020,
439 .chcr = CHCR_RX(XMIT_SZ_32BIT),
440 .mid_rid = 0xd6, /* CHECK ME */
441 }, {
442 .slave_id = SHDMA_SLAVE_FSI2A_TX,
443 .addr = 0xec230024,
444 .chcr = CHCR_TX(XMIT_SZ_32BIT),
445 .mid_rid = 0xd5, /* CHECK ME */
446 }, {
447 .slave_id = SHDMA_SLAVE_FSI2C_RX,
448 .addr = 0xec230060,
449 .chcr = CHCR_RX(XMIT_SZ_32BIT),
450 .mid_rid = 0xda, /* CHECK ME */
451 }, {
452 .slave_id = SHDMA_SLAVE_FSI2C_TX,
453 .addr = 0xec230064,
454 .chcr = CHCR_TX(XMIT_SZ_32BIT),
455 .mid_rid = 0xd9, /* CHECK ME */
456 }, {
457 .slave_id = SHDMA_SLAVE_FSI2B_RX,
458 .addr = 0xec240020,
459 .chcr = CHCR_RX(XMIT_SZ_32BIT),
460 .mid_rid = 0x8e, /* CHECK ME */
461 }, {
462 .slave_id = SHDMA_SLAVE_FSI2B_TX,
463 .addr = 0xec240024,
464 .chcr = CHCR_RX(XMIT_SZ_32BIT),
465 .mid_rid = 0x8d, /* CHECK ME */
466 }, {
467 .slave_id = SHDMA_SLAVE_FSI2D_RX,
468 .addr = 0xec240060,
469 .chcr = CHCR_RX(XMIT_SZ_32BIT),
470 .mid_rid = 0x9a, /* CHECK ME */
471 },
472};
473
474#define MPDMA_CHANNEL(a, b, c) \
475{ \
476 .offset = a, \
477 .dmars = b, \
478 .dmars_bit = c, \
479 .chclr_offset = (0x220 - 0x20) + a \
480}
481
482static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
483 MPDMA_CHANNEL(0x00, 0, 0),
484 MPDMA_CHANNEL(0x10, 0, 8),
485 MPDMA_CHANNEL(0x20, 4, 0),
486 MPDMA_CHANNEL(0x30, 4, 8),
487 MPDMA_CHANNEL(0x50, 8, 0),
488 MPDMA_CHANNEL(0x70, 8, 8),
489};
490
491static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
492 .slave = sh73a0_mpdma_slaves,
493 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
494 .channel = sh73a0_mpdma_channels,
495 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700496 .ts_low_shift = TS_LOW_SHIFT,
497 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
498 .ts_high_shift = TS_HI_SHIFT,
499 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
500 .ts_shift = dma_ts_shift,
501 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700502 .dmaor_init = DMAOR_DME,
503 .chclr_present = 1,
504};
505
506/* Resource order important! */
507static struct resource sh73a0_mpdma_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000508 /* Channel registers and DMAOR */
509 DEFINE_RES_MEM(0xec618020, 0x270),
510 /* DMARSx */
511 DEFINE_RES_MEM(0xec619000, 0xc),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700512 {
513 .name = "error_irq",
514 .start = gic_spi(181),
515 .end = gic_spi(181),
516 .flags = IORESOURCE_IRQ,
517 },
518 {
519 /* IRQ for channels 0-5 */
520 .start = gic_spi(175),
521 .end = gic_spi(180),
522 .flags = IORESOURCE_IRQ,
523 },
524};
525
526static struct platform_device mpdma0_device = {
527 .name = "sh-dma-engine",
528 .id = 1,
529 .resource = sh73a0_mpdma_resources,
530 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
531 .dev = {
532 .platform_data = &sh73a0_mpdma_platform_data,
533 },
534};
535
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900536static struct resource pmu_resources[] = {
537 [0] = {
538 .start = gic_spi(55),
539 .end = gic_spi(55),
540 .flags = IORESOURCE_IRQ,
541 },
542 [1] = {
543 .start = gic_spi(56),
544 .end = gic_spi(56),
545 .flags = IORESOURCE_IRQ,
546 },
547};
548
549static struct platform_device pmu_device = {
550 .name = "arm-pmu",
551 .id = -1,
552 .num_resources = ARRAY_SIZE(pmu_resources),
553 .resource = pmu_resources,
554};
555
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900556/* an IPMMU module for ICB */
557static struct resource ipmmu_resources[] = {
Kuninori Morimoto6244cd72013-10-07 22:59:06 -0700558 DEFINE_RES_MEM(0xfe951000, 0x100),
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900559};
560
561static const char * const ipmmu_dev_names[] = {
562 "sh_mobile_lcdc_fb.0",
563};
564
565static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
566 .dev_names = ipmmu_dev_names,
567 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
568};
569
570static struct platform_device ipmmu_device = {
571 .name = "ipmmu",
572 .id = -1,
573 .dev = {
574 .platform_data = &ipmmu_platform_data,
575 },
576 .resource = ipmmu_resources,
577 .num_resources = ARRAY_SIZE(ipmmu_resources),
578};
579
Magnus Damm1461f8b2013-03-06 15:08:31 +0900580static struct renesas_intc_irqpin_config irqpin0_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900581 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
Geert Uytterhoevenb0ddb312015-01-06 14:39:10 +0100582 .control_parent = true,
Magnus Damm341eb542013-02-26 12:01:09 +0900583};
584
585static struct resource irqpin0_resources[] = {
586 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
587 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
588 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
589 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
590 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
591 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
592 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
593 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
594 DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
595 DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
596 DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
597 DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
598 DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
599};
600
601static struct platform_device irqpin0_device = {
602 .name = "renesas_intc_irqpin",
603 .id = 0,
604 .resource = irqpin0_resources,
605 .num_resources = ARRAY_SIZE(irqpin0_resources),
606 .dev = {
607 .platform_data = &irqpin0_platform_data,
608 },
609};
610
Magnus Damm1461f8b2013-03-06 15:08:31 +0900611static struct renesas_intc_irqpin_config irqpin1_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900612 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
613 .control_parent = true, /* Disable spurious IRQ10 */
614};
615
616static struct resource irqpin1_resources[] = {
617 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
618 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
619 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
620 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
621 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
622 DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
623 DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
624 DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
625 DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
626 DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
627 DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
628 DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
629 DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
630};
631
632static struct platform_device irqpin1_device = {
633 .name = "renesas_intc_irqpin",
634 .id = 1,
635 .resource = irqpin1_resources,
636 .num_resources = ARRAY_SIZE(irqpin1_resources),
637 .dev = {
638 .platform_data = &irqpin1_platform_data,
639 },
640};
641
Magnus Damm1461f8b2013-03-06 15:08:31 +0900642static struct renesas_intc_irqpin_config irqpin2_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900643 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
Geert Uytterhoevenb0ddb312015-01-06 14:39:10 +0100644 .control_parent = true,
Magnus Damm341eb542013-02-26 12:01:09 +0900645};
646
647static struct resource irqpin2_resources[] = {
648 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
649 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
650 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
651 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
652 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
653 DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
654 DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
655 DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
656 DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
657 DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
658 DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
659 DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
660 DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
661};
662
663static struct platform_device irqpin2_device = {
664 .name = "renesas_intc_irqpin",
665 .id = 2,
666 .resource = irqpin2_resources,
667 .num_resources = ARRAY_SIZE(irqpin2_resources),
668 .dev = {
669 .platform_data = &irqpin2_platform_data,
670 },
671};
672
Magnus Damm1461f8b2013-03-06 15:08:31 +0900673static struct renesas_intc_irqpin_config irqpin3_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900674 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
Geert Uytterhoevenb0ddb312015-01-06 14:39:10 +0100675 .control_parent = true,
Magnus Damm341eb542013-02-26 12:01:09 +0900676};
677
678static struct resource irqpin3_resources[] = {
679 DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
680 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
681 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
682 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
683 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
684 DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
685 DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
686 DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
687 DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
688 DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
689 DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
690 DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
691 DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
692};
693
694static struct platform_device irqpin3_device = {
695 .name = "renesas_intc_irqpin",
696 .id = 3,
697 .resource = irqpin3_resources,
698 .num_resources = ARRAY_SIZE(irqpin3_resources),
699 .dev = {
700 .platform_data = &irqpin3_platform_data,
701 },
702};
703
Simon Horman700ce7c22014-07-07 09:54:52 +0200704static struct platform_device *sh73a0_early_devices[] __initdata = {
Magnus Damm6d9598e2010-11-17 10:59:31 +0000705 &scif0_device,
706 &scif1_device,
707 &scif2_device,
708 &scif3_device,
709 &scif4_device,
710 &scif5_device,
711 &scif6_device,
712 &scif7_device,
713 &scif8_device,
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200714 &tmu0_device,
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900715 &ipmmu_device,
Ulrich Hecht48a0d1e2014-09-08 09:57:08 +0900716 &cmt1_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000717};
718
Yoshii Takashib028f942010-11-19 13:20:45 +0000719static struct platform_device *sh73a0_late_devices[] __initdata = {
720 &i2c0_device,
721 &i2c1_device,
722 &i2c2_device,
723 &i2c3_device,
724 &i2c4_device,
Magnus Damm681e1b32011-05-24 10:37:16 +0000725 &dma0_device,
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700726 &mpdma0_device,
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900727 &pmu_device,
Magnus Damm341eb542013-02-26 12:01:09 +0900728 &irqpin0_device,
729 &irqpin1_device,
730 &irqpin2_device,
731 &irqpin3_device,
Yoshii Takashib028f942010-11-19 13:20:45 +0000732};
733
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000734#define SRCR2 IOMEM(0xe61580b0)
Magnus Damm681e1b32011-05-24 10:37:16 +0000735
Magnus Damm6d9598e2010-11-17 10:59:31 +0000736void __init sh73a0_add_standard_devices(void)
737{
Magnus Damm681e1b32011-05-24 10:37:16 +0000738 /* Clear software reset bit on SY-DMAC module */
739 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
740
Magnus Damm6d9598e2010-11-17 10:59:31 +0000741 platform_add_devices(sh73a0_early_devices,
742 ARRAY_SIZE(sh73a0_early_devices));
Yoshii Takashib028f942010-11-19 13:20:45 +0000743 platform_add_devices(sh73a0_late_devices,
744 ARRAY_SIZE(sh73a0_late_devices));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000745}
746
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900747void __init sh73a0_init_delay(void)
748{
Magnus Damm5df622a2014-08-20 22:02:45 +0900749 shmobile_init_delay();
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900750}
751
Kuninori Morimotod6720002012-05-10 00:26:58 -0700752/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
753void __init __weak sh73a0_register_twd(void) { }
754
Stephen Warren6bb27d72012-11-08 12:40:59 -0700755void __init sh73a0_earlytimer_init(void)
Magnus Damm3be26fd2012-03-06 17:36:45 +0900756{
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900757 sh73a0_init_delay();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900758 sh73a0_clock_init();
759 shmobile_earlytimer_init();
Kuninori Morimotod6720002012-05-10 00:26:58 -0700760 sh73a0_register_twd();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900761}
762
Magnus Damm6d9598e2010-11-17 10:59:31 +0000763void __init sh73a0_add_early_devices(void)
764{
765 early_platform_add_devices(sh73a0_early_devices,
766 ARRAY_SIZE(sh73a0_early_devices));
Magnus Damm50e15c32012-02-29 21:37:27 +0900767
768 /* setup early console here as well */
769 shmobile_setup_console();
Magnus Damm6d9598e2010-11-17 10:59:31 +0000770}
Simon Horman48609532012-11-21 22:00:15 +0900771
772#ifdef CONFIG_USE_OF
773
Simon Horman48609532012-11-21 22:00:15 +0900774void __init sh73a0_add_standard_devices_dt(void)
775{
776 /* clocks are setup late during boot in the case of DT */
777 sh73a0_clock_init();
778
Magnus Dammea315972013-07-01 14:42:04 +0900779 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Simon Horman48609532012-11-21 22:00:15 +0900780}
781
Geert Uytterhoevencad900812014-11-07 14:46:33 +0100782#define RESCNT2 IOMEM(0xe6188020)
783static void sh73a0_restart(enum reboot_mode mode, const char *cmd)
784{
785 /* Do soft power on reset */
786 writel((1 << 31), RESCNT2);
787}
788
Simon Horman48609532012-11-21 22:00:15 +0900789static const char *sh73a0_boards_compat_dt[] __initdata = {
790 "renesas,sh73a0",
791 NULL,
792};
793
794DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
Simon Hormanf9989502013-02-15 21:38:20 +0900795 .smp = smp_ops(sh73a0_smp_ops),
Simon Horman48609532012-11-21 22:00:15 +0900796 .map_io = sh73a0_map_io,
Simon Horman3b00f932013-02-19 10:53:05 +0900797 .init_early = sh73a0_init_delay,
Simon Horman48609532012-11-21 22:00:15 +0900798 .init_machine = sh73a0_add_standard_devices_dt,
Magnus Damme604d802014-07-31 08:32:15 +0900799 .init_late = shmobile_init_late,
Geert Uytterhoevencad900812014-11-07 14:46:33 +0100800 .restart = sh73a0_restart,
Simon Horman48609532012-11-21 22:00:15 +0900801 .dt_compat = sh73a0_boards_compat_dt,
802MACHINE_END
803#endif /* CONFIG_USE_OF */