blob: b30bbee6dc65b64ee1b5cf2ec126f54c308eee4c [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>
Magnus Damm681e1b32011-05-24 10:37:16 +000035#include <mach/sh73a0.h>
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>
Magnus Dammfd44aa52014-06-17 16:47:37 +090040#include "common.h"
Magnus Damm74ac0de2014-06-17 16:47:13 +090041#include "dma-register.h"
Magnus Dammb6bab122014-06-17 16:47:29 +090042#include "irqs.h"
Magnus Damm6d9598e2010-11-17 10:59:31 +000043
Magnus Damm50e15c32012-02-29 21:37:27 +090044static struct map_desc sh73a0_io_desc[] __initdata = {
45 /* create a 1:1 entity map for 0xe6xxxxxx
46 * used by CPGA, INTC and PFC.
47 */
48 {
49 .virtual = 0xe6000000,
50 .pfn = __phys_to_pfn(0xe6000000),
51 .length = 256 << 20,
52 .type = MT_DEVICE_NONSHARED
53 },
54};
55
56void __init sh73a0_map_io(void)
57{
58 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
59}
60
Magnus Damm474f6752013-06-27 17:09:01 +090061/* PFC */
62static struct resource pfc_resources[] __initdata = {
63 DEFINE_RES_MEM(0xe6050000, 0x8000),
64 DEFINE_RES_MEM(0xe605801c, 0x000c),
Laurent Pinchart994d66a2012-12-15 23:51:28 +010065};
66
67void __init sh73a0_pinmux_init(void)
68{
Magnus Damm474f6752013-06-27 17:09:01 +090069 platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
70 ARRAY_SIZE(pfc_resources));
Laurent Pinchart994d66a2012-12-15 23:51:28 +010071}
72
Laurent Pinchartd000fff2013-12-06 10:59:22 +010073/* SCIF */
74#define SH73A0_SCIF(scif_type, index, baseaddr, irq) \
75static struct plat_sci_port scif##index##_platform_data = { \
76 .type = scif_type, \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010077 .flags = UPF_BOOT_AUTOCONF, \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010078 .scscr = SCSCR_RE | SCSCR_TE, \
79}; \
80 \
Laurent Pinchart31e1ee82013-12-06 10:59:31 +010081static struct resource scif##index##_resources[] = { \
82 DEFINE_RES_MEM(baseaddr, 0x100), \
83 DEFINE_RES_IRQ(irq), \
84}; \
85 \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010086static struct platform_device scif##index##_device = { \
87 .name = "sh-sci", \
88 .id = index, \
Laurent Pinchart31e1ee82013-12-06 10:59:31 +010089 .resource = scif##index##_resources, \
90 .num_resources = ARRAY_SIZE(scif##index##_resources), \
Laurent Pinchartd000fff2013-12-06 10:59:22 +010091 .dev = { \
92 .platform_data = &scif##index##_platform_data, \
93 }, \
94}
Magnus Damm6d9598e2010-11-17 10:59:31 +000095
Laurent Pinchartd000fff2013-12-06 10:59:22 +010096SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
97SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
98SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
99SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
100SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
101SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
102SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
103SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
104SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000105
Laurent Pinchart652256f2014-04-23 13:15:10 +0200106static struct sh_timer_config cmt1_platform_data = {
107 .channels_mask = 0x3f,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000108};
109
Laurent Pinchart652256f2014-04-23 13:15:10 +0200110static struct resource cmt1_resources[] = {
111 DEFINE_RES_MEM(0xe6138000, 0x200),
112 DEFINE_RES_IRQ(gic_spi(65)),
Magnus Damm6d9598e2010-11-17 10:59:31 +0000113};
114
Laurent Pinchart652256f2014-04-23 13:15:10 +0200115static struct platform_device cmt1_device = {
116 .name = "sh-cmt-48",
117 .id = 1,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000118 .dev = {
Laurent Pinchart652256f2014-04-23 13:15:10 +0200119 .platform_data = &cmt1_platform_data,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000120 },
Laurent Pinchart652256f2014-04-23 13:15:10 +0200121 .resource = cmt1_resources,
122 .num_resources = ARRAY_SIZE(cmt1_resources),
Magnus Damm6d9598e2010-11-17 10:59:31 +0000123};
124
Magnus Damm5010f3d2010-12-21 08:40:59 +0000125/* TMU */
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200126static struct sh_timer_config tmu0_platform_data = {
127 .channels_mask = 7,
Magnus Damm5010f3d2010-12-21 08:40:59 +0000128};
129
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200130static struct resource tmu0_resources[] = {
131 DEFINE_RES_MEM(0xfff60000, 0x2c),
132 DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
133 DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
134 DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000135};
136
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200137static struct platform_device tmu0_device = {
138 .name = "sh-tmu",
Magnus Damm5010f3d2010-12-21 08:40:59 +0000139 .id = 0,
140 .dev = {
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200141 .platform_data = &tmu0_platform_data,
Magnus Damm5010f3d2010-12-21 08:40:59 +0000142 },
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200143 .resource = tmu0_resources,
144 .num_resources = ARRAY_SIZE(tmu0_resources),
Magnus Damm5010f3d2010-12-21 08:40:59 +0000145};
146
Yoshii Takashib028f942010-11-19 13:20:45 +0000147static struct resource i2c0_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700148 [0] = DEFINE_RES_MEM(0xe6820000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000149 [1] = {
150 .start = gic_spi(167),
151 .end = gic_spi(170),
152 .flags = IORESOURCE_IRQ,
153 },
154};
155
156static struct resource i2c1_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700157 [0] = DEFINE_RES_MEM(0xe6822000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000158 [1] = {
159 .start = gic_spi(51),
160 .end = gic_spi(54),
161 .flags = IORESOURCE_IRQ,
162 },
163};
164
165static struct resource i2c2_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700166 [0] = DEFINE_RES_MEM(0xe6824000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000167 [1] = {
168 .start = gic_spi(171),
169 .end = gic_spi(174),
170 .flags = IORESOURCE_IRQ,
171 },
172};
173
174static struct resource i2c3_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700175 [0] = DEFINE_RES_MEM(0xe6826000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000176 [1] = {
177 .start = gic_spi(183),
178 .end = gic_spi(186),
179 .flags = IORESOURCE_IRQ,
180 },
181};
182
183static struct resource i2c4_resources[] = {
Kuninori Morimoto8e855242013-10-07 22:58:55 -0700184 [0] = DEFINE_RES_MEM(0xe6828000, 0x426),
Yoshii Takashib028f942010-11-19 13:20:45 +0000185 [1] = {
186 .start = gic_spi(187),
187 .end = gic_spi(190),
188 .flags = IORESOURCE_IRQ,
189 },
190};
191
192static struct platform_device i2c0_device = {
193 .name = "i2c-sh_mobile",
194 .id = 0,
195 .resource = i2c0_resources,
196 .num_resources = ARRAY_SIZE(i2c0_resources),
197};
198
199static struct platform_device i2c1_device = {
200 .name = "i2c-sh_mobile",
201 .id = 1,
202 .resource = i2c1_resources,
203 .num_resources = ARRAY_SIZE(i2c1_resources),
204};
205
206static struct platform_device i2c2_device = {
207 .name = "i2c-sh_mobile",
208 .id = 2,
209 .resource = i2c2_resources,
210 .num_resources = ARRAY_SIZE(i2c2_resources),
211};
212
213static struct platform_device i2c3_device = {
214 .name = "i2c-sh_mobile",
215 .id = 3,
216 .resource = i2c3_resources,
217 .num_resources = ARRAY_SIZE(i2c3_resources),
218};
219
220static struct platform_device i2c4_device = {
221 .name = "i2c-sh_mobile",
222 .id = 4,
223 .resource = i2c4_resources,
224 .num_resources = ARRAY_SIZE(i2c4_resources),
225};
226
Magnus Damm681e1b32011-05-24 10:37:16 +0000227static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
228 {
229 .slave_id = SHDMA_SLAVE_SCIF0_TX,
230 .addr = 0xe6c40020,
231 .chcr = CHCR_TX(XMIT_SZ_8BIT),
232 .mid_rid = 0x21,
233 }, {
234 .slave_id = SHDMA_SLAVE_SCIF0_RX,
235 .addr = 0xe6c40024,
236 .chcr = CHCR_RX(XMIT_SZ_8BIT),
237 .mid_rid = 0x22,
238 }, {
239 .slave_id = SHDMA_SLAVE_SCIF1_TX,
240 .addr = 0xe6c50020,
241 .chcr = CHCR_TX(XMIT_SZ_8BIT),
242 .mid_rid = 0x25,
243 }, {
244 .slave_id = SHDMA_SLAVE_SCIF1_RX,
245 .addr = 0xe6c50024,
246 .chcr = CHCR_RX(XMIT_SZ_8BIT),
247 .mid_rid = 0x26,
248 }, {
249 .slave_id = SHDMA_SLAVE_SCIF2_TX,
250 .addr = 0xe6c60020,
251 .chcr = CHCR_TX(XMIT_SZ_8BIT),
252 .mid_rid = 0x29,
253 }, {
254 .slave_id = SHDMA_SLAVE_SCIF2_RX,
255 .addr = 0xe6c60024,
256 .chcr = CHCR_RX(XMIT_SZ_8BIT),
257 .mid_rid = 0x2a,
258 }, {
259 .slave_id = SHDMA_SLAVE_SCIF3_TX,
260 .addr = 0xe6c70020,
261 .chcr = CHCR_TX(XMIT_SZ_8BIT),
262 .mid_rid = 0x2d,
263 }, {
264 .slave_id = SHDMA_SLAVE_SCIF3_RX,
265 .addr = 0xe6c70024,
266 .chcr = CHCR_RX(XMIT_SZ_8BIT),
267 .mid_rid = 0x2e,
268 }, {
269 .slave_id = SHDMA_SLAVE_SCIF4_TX,
270 .addr = 0xe6c80020,
271 .chcr = CHCR_TX(XMIT_SZ_8BIT),
272 .mid_rid = 0x39,
273 }, {
274 .slave_id = SHDMA_SLAVE_SCIF4_RX,
275 .addr = 0xe6c80024,
276 .chcr = CHCR_RX(XMIT_SZ_8BIT),
277 .mid_rid = 0x3a,
278 }, {
279 .slave_id = SHDMA_SLAVE_SCIF5_TX,
280 .addr = 0xe6cb0020,
281 .chcr = CHCR_TX(XMIT_SZ_8BIT),
282 .mid_rid = 0x35,
283 }, {
284 .slave_id = SHDMA_SLAVE_SCIF5_RX,
285 .addr = 0xe6cb0024,
286 .chcr = CHCR_RX(XMIT_SZ_8BIT),
287 .mid_rid = 0x36,
288 }, {
289 .slave_id = SHDMA_SLAVE_SCIF6_TX,
290 .addr = 0xe6cc0020,
291 .chcr = CHCR_TX(XMIT_SZ_8BIT),
292 .mid_rid = 0x1d,
293 }, {
294 .slave_id = SHDMA_SLAVE_SCIF6_RX,
295 .addr = 0xe6cc0024,
296 .chcr = CHCR_RX(XMIT_SZ_8BIT),
297 .mid_rid = 0x1e,
298 }, {
299 .slave_id = SHDMA_SLAVE_SCIF7_TX,
300 .addr = 0xe6cd0020,
301 .chcr = CHCR_TX(XMIT_SZ_8BIT),
302 .mid_rid = 0x19,
303 }, {
304 .slave_id = SHDMA_SLAVE_SCIF7_RX,
305 .addr = 0xe6cd0024,
306 .chcr = CHCR_RX(XMIT_SZ_8BIT),
307 .mid_rid = 0x1a,
308 }, {
309 .slave_id = SHDMA_SLAVE_SCIF8_TX,
310 .addr = 0xe6c30040,
311 .chcr = CHCR_TX(XMIT_SZ_8BIT),
312 .mid_rid = 0x3d,
313 }, {
314 .slave_id = SHDMA_SLAVE_SCIF8_RX,
315 .addr = 0xe6c30060,
316 .chcr = CHCR_RX(XMIT_SZ_8BIT),
317 .mid_rid = 0x3e,
318 }, {
319 .slave_id = SHDMA_SLAVE_SDHI0_TX,
320 .addr = 0xee100030,
321 .chcr = CHCR_TX(XMIT_SZ_16BIT),
322 .mid_rid = 0xc1,
323 }, {
324 .slave_id = SHDMA_SLAVE_SDHI0_RX,
325 .addr = 0xee100030,
326 .chcr = CHCR_RX(XMIT_SZ_16BIT),
327 .mid_rid = 0xc2,
328 }, {
329 .slave_id = SHDMA_SLAVE_SDHI1_TX,
330 .addr = 0xee120030,
331 .chcr = CHCR_TX(XMIT_SZ_16BIT),
332 .mid_rid = 0xc9,
333 }, {
334 .slave_id = SHDMA_SLAVE_SDHI1_RX,
335 .addr = 0xee120030,
336 .chcr = CHCR_RX(XMIT_SZ_16BIT),
337 .mid_rid = 0xca,
338 }, {
339 .slave_id = SHDMA_SLAVE_SDHI2_TX,
340 .addr = 0xee140030,
341 .chcr = CHCR_TX(XMIT_SZ_16BIT),
342 .mid_rid = 0xcd,
343 }, {
344 .slave_id = SHDMA_SLAVE_SDHI2_RX,
345 .addr = 0xee140030,
346 .chcr = CHCR_RX(XMIT_SZ_16BIT),
347 .mid_rid = 0xce,
348 }, {
349 .slave_id = SHDMA_SLAVE_MMCIF_TX,
350 .addr = 0xe6bd0034,
351 .chcr = CHCR_TX(XMIT_SZ_32BIT),
352 .mid_rid = 0xd1,
353 }, {
354 .slave_id = SHDMA_SLAVE_MMCIF_RX,
355 .addr = 0xe6bd0034,
356 .chcr = CHCR_RX(XMIT_SZ_32BIT),
357 .mid_rid = 0xd2,
358 },
359};
360
361#define DMAE_CHANNEL(_offset) \
362 { \
363 .offset = _offset - 0x20, \
364 .dmars = _offset - 0x20 + 0x40, \
365 }
366
367static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
368 DMAE_CHANNEL(0x8000),
369 DMAE_CHANNEL(0x8080),
370 DMAE_CHANNEL(0x8100),
371 DMAE_CHANNEL(0x8180),
372 DMAE_CHANNEL(0x8200),
373 DMAE_CHANNEL(0x8280),
374 DMAE_CHANNEL(0x8300),
375 DMAE_CHANNEL(0x8380),
376 DMAE_CHANNEL(0x8400),
377 DMAE_CHANNEL(0x8480),
378 DMAE_CHANNEL(0x8500),
379 DMAE_CHANNEL(0x8580),
380 DMAE_CHANNEL(0x8600),
381 DMAE_CHANNEL(0x8680),
382 DMAE_CHANNEL(0x8700),
383 DMAE_CHANNEL(0x8780),
384 DMAE_CHANNEL(0x8800),
385 DMAE_CHANNEL(0x8880),
386 DMAE_CHANNEL(0x8900),
387 DMAE_CHANNEL(0x8980),
388};
389
Magnus Damm681e1b32011-05-24 10:37:16 +0000390static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
391 .slave = sh73a0_dmae_slaves,
392 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
393 .channel = sh73a0_dmae_channels,
394 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700395 .ts_low_shift = TS_LOW_SHIFT,
396 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
397 .ts_high_shift = TS_HI_SHIFT,
398 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
399 .ts_shift = dma_ts_shift,
400 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Magnus Damm681e1b32011-05-24 10:37:16 +0000401 .dmaor_init = DMAOR_DME,
402};
403
404static struct resource sh73a0_dmae_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000405 DEFINE_RES_MEM(0xfe000020, 0x89e0),
Magnus Damm681e1b32011-05-24 10:37:16 +0000406 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900407 .name = "error_irq",
Magnus Damm681e1b32011-05-24 10:37:16 +0000408 .start = gic_spi(129),
409 .end = gic_spi(129),
410 .flags = IORESOURCE_IRQ,
411 },
412 {
413 /* IRQ for channels 0-19 */
414 .start = gic_spi(109),
415 .end = gic_spi(128),
416 .flags = IORESOURCE_IRQ,
417 },
418};
419
420static struct platform_device dma0_device = {
421 .name = "sh-dma-engine",
422 .id = 0,
423 .resource = sh73a0_dmae_resources,
424 .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
425 .dev = {
426 .platform_data = &sh73a0_dmae_platform_data,
427 },
428};
429
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700430/* MPDMAC */
431static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
432 {
433 .slave_id = SHDMA_SLAVE_FSI2A_RX,
434 .addr = 0xec230020,
435 .chcr = CHCR_RX(XMIT_SZ_32BIT),
436 .mid_rid = 0xd6, /* CHECK ME */
437 }, {
438 .slave_id = SHDMA_SLAVE_FSI2A_TX,
439 .addr = 0xec230024,
440 .chcr = CHCR_TX(XMIT_SZ_32BIT),
441 .mid_rid = 0xd5, /* CHECK ME */
442 }, {
443 .slave_id = SHDMA_SLAVE_FSI2C_RX,
444 .addr = 0xec230060,
445 .chcr = CHCR_RX(XMIT_SZ_32BIT),
446 .mid_rid = 0xda, /* CHECK ME */
447 }, {
448 .slave_id = SHDMA_SLAVE_FSI2C_TX,
449 .addr = 0xec230064,
450 .chcr = CHCR_TX(XMIT_SZ_32BIT),
451 .mid_rid = 0xd9, /* CHECK ME */
452 }, {
453 .slave_id = SHDMA_SLAVE_FSI2B_RX,
454 .addr = 0xec240020,
455 .chcr = CHCR_RX(XMIT_SZ_32BIT),
456 .mid_rid = 0x8e, /* CHECK ME */
457 }, {
458 .slave_id = SHDMA_SLAVE_FSI2B_TX,
459 .addr = 0xec240024,
460 .chcr = CHCR_RX(XMIT_SZ_32BIT),
461 .mid_rid = 0x8d, /* CHECK ME */
462 }, {
463 .slave_id = SHDMA_SLAVE_FSI2D_RX,
464 .addr = 0xec240060,
465 .chcr = CHCR_RX(XMIT_SZ_32BIT),
466 .mid_rid = 0x9a, /* CHECK ME */
467 },
468};
469
470#define MPDMA_CHANNEL(a, b, c) \
471{ \
472 .offset = a, \
473 .dmars = b, \
474 .dmars_bit = c, \
475 .chclr_offset = (0x220 - 0x20) + a \
476}
477
478static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
479 MPDMA_CHANNEL(0x00, 0, 0),
480 MPDMA_CHANNEL(0x10, 0, 8),
481 MPDMA_CHANNEL(0x20, 4, 0),
482 MPDMA_CHANNEL(0x30, 4, 8),
483 MPDMA_CHANNEL(0x50, 8, 0),
484 MPDMA_CHANNEL(0x70, 8, 8),
485};
486
487static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
488 .slave = sh73a0_mpdma_slaves,
489 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
490 .channel = sh73a0_mpdma_channels,
491 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
Kuninori Morimoto6088b422012-06-25 03:43:28 -0700492 .ts_low_shift = TS_LOW_SHIFT,
493 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
494 .ts_high_shift = TS_HI_SHIFT,
495 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
496 .ts_shift = dma_ts_shift,
497 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700498 .dmaor_init = DMAOR_DME,
499 .chclr_present = 1,
500};
501
502/* Resource order important! */
503static struct resource sh73a0_mpdma_resources[] = {
Simon Hormanabbec5f2013-04-23 02:27:15 +0000504 /* Channel registers and DMAOR */
505 DEFINE_RES_MEM(0xec618020, 0x270),
506 /* DMARSx */
507 DEFINE_RES_MEM(0xec619000, 0xc),
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700508 {
509 .name = "error_irq",
510 .start = gic_spi(181),
511 .end = gic_spi(181),
512 .flags = IORESOURCE_IRQ,
513 },
514 {
515 /* IRQ for channels 0-5 */
516 .start = gic_spi(175),
517 .end = gic_spi(180),
518 .flags = IORESOURCE_IRQ,
519 },
520};
521
522static struct platform_device mpdma0_device = {
523 .name = "sh-dma-engine",
524 .id = 1,
525 .resource = sh73a0_mpdma_resources,
526 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
527 .dev = {
528 .platform_data = &sh73a0_mpdma_platform_data,
529 },
530};
531
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900532static struct resource pmu_resources[] = {
533 [0] = {
534 .start = gic_spi(55),
535 .end = gic_spi(55),
536 .flags = IORESOURCE_IRQ,
537 },
538 [1] = {
539 .start = gic_spi(56),
540 .end = gic_spi(56),
541 .flags = IORESOURCE_IRQ,
542 },
543};
544
545static struct platform_device pmu_device = {
546 .name = "arm-pmu",
547 .id = -1,
548 .num_resources = ARRAY_SIZE(pmu_resources),
549 .resource = pmu_resources,
550};
551
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900552/* an IPMMU module for ICB */
553static struct resource ipmmu_resources[] = {
Kuninori Morimoto6244cd72013-10-07 22:59:06 -0700554 DEFINE_RES_MEM(0xfe951000, 0x100),
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900555};
556
557static const char * const ipmmu_dev_names[] = {
558 "sh_mobile_lcdc_fb.0",
559};
560
561static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
562 .dev_names = ipmmu_dev_names,
563 .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
564};
565
566static struct platform_device ipmmu_device = {
567 .name = "ipmmu",
568 .id = -1,
569 .dev = {
570 .platform_data = &ipmmu_platform_data,
571 },
572 .resource = ipmmu_resources,
573 .num_resources = ARRAY_SIZE(ipmmu_resources),
574};
575
Magnus Damm1461f8b2013-03-06 15:08:31 +0900576static struct renesas_intc_irqpin_config irqpin0_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900577 .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
578};
579
580static struct resource irqpin0_resources[] = {
581 DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
582 DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
583 DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
584 DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
585 DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
586 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
587 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
588 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
589 DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
590 DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
591 DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
592 DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
593 DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
594};
595
596static struct platform_device irqpin0_device = {
597 .name = "renesas_intc_irqpin",
598 .id = 0,
599 .resource = irqpin0_resources,
600 .num_resources = ARRAY_SIZE(irqpin0_resources),
601 .dev = {
602 .platform_data = &irqpin0_platform_data,
603 },
604};
605
Magnus Damm1461f8b2013-03-06 15:08:31 +0900606static struct renesas_intc_irqpin_config irqpin1_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900607 .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
608 .control_parent = true, /* Disable spurious IRQ10 */
609};
610
611static struct resource irqpin1_resources[] = {
612 DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
613 DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
614 DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
615 DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
616 DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
617 DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
618 DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
619 DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
620 DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
621 DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
622 DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
623 DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
624 DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
625};
626
627static struct platform_device irqpin1_device = {
628 .name = "renesas_intc_irqpin",
629 .id = 1,
630 .resource = irqpin1_resources,
631 .num_resources = ARRAY_SIZE(irqpin1_resources),
632 .dev = {
633 .platform_data = &irqpin1_platform_data,
634 },
635};
636
Magnus Damm1461f8b2013-03-06 15:08:31 +0900637static struct renesas_intc_irqpin_config irqpin2_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900638 .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
639};
640
641static struct resource irqpin2_resources[] = {
642 DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
643 DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
644 DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
645 DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
646 DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
647 DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
648 DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
649 DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
650 DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
651 DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
652 DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
653 DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
654 DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
655};
656
657static struct platform_device irqpin2_device = {
658 .name = "renesas_intc_irqpin",
659 .id = 2,
660 .resource = irqpin2_resources,
661 .num_resources = ARRAY_SIZE(irqpin2_resources),
662 .dev = {
663 .platform_data = &irqpin2_platform_data,
664 },
665};
666
Magnus Damm1461f8b2013-03-06 15:08:31 +0900667static struct renesas_intc_irqpin_config irqpin3_platform_data = {
Magnus Damm341eb542013-02-26 12:01:09 +0900668 .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
669};
670
671static struct resource irqpin3_resources[] = {
672 DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
673 DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
674 DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
675 DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
676 DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
677 DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
678 DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
679 DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
680 DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
681 DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
682 DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
683 DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
684 DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
685};
686
687static struct platform_device irqpin3_device = {
688 .name = "renesas_intc_irqpin",
689 .id = 3,
690 .resource = irqpin3_resources,
691 .num_resources = ARRAY_SIZE(irqpin3_resources),
692 .dev = {
693 .platform_data = &irqpin3_platform_data,
694 },
695};
696
Simon Horman3b00f932013-02-19 10:53:05 +0900697static struct platform_device *sh73a0_devices_dt[] __initdata = {
Magnus Damm6d9598e2010-11-17 10:59:31 +0000698 &scif0_device,
699 &scif1_device,
700 &scif2_device,
701 &scif3_device,
702 &scif4_device,
703 &scif5_device,
704 &scif6_device,
705 &scif7_device,
706 &scif8_device,
Laurent Pinchart652256f2014-04-23 13:15:10 +0200707 &cmt1_device,
Simon Horman48609532012-11-21 22:00:15 +0900708};
709
710static struct platform_device *sh73a0_early_devices[] __initdata = {
Laurent Pinchart3df592b2014-04-23 13:15:17 +0200711 &tmu0_device,
Hideki EIRAKU9a27dee2013-01-21 19:54:28 +0900712 &ipmmu_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000713};
714
Yoshii Takashib028f942010-11-19 13:20:45 +0000715static struct platform_device *sh73a0_late_devices[] __initdata = {
716 &i2c0_device,
717 &i2c1_device,
718 &i2c2_device,
719 &i2c3_device,
720 &i2c4_device,
Magnus Damm681e1b32011-05-24 10:37:16 +0000721 &dma0_device,
Kuninori Morimoto832290b2012-06-25 03:39:20 -0700722 &mpdma0_device,
Tetsuyuki Kobayashif23f5be2012-09-06 20:14:06 +0900723 &pmu_device,
Magnus Damm341eb542013-02-26 12:01:09 +0900724 &irqpin0_device,
725 &irqpin1_device,
726 &irqpin2_device,
727 &irqpin3_device,
Yoshii Takashib028f942010-11-19 13:20:45 +0000728};
729
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000730#define SRCR2 IOMEM(0xe61580b0)
Magnus Damm681e1b32011-05-24 10:37:16 +0000731
Magnus Damm6d9598e2010-11-17 10:59:31 +0000732void __init sh73a0_add_standard_devices(void)
733{
Magnus Damm681e1b32011-05-24 10:37:16 +0000734 /* Clear software reset bit on SY-DMAC module */
735 __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
736
Simon Horman3b00f932013-02-19 10:53:05 +0900737 platform_add_devices(sh73a0_devices_dt,
738 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000739 platform_add_devices(sh73a0_early_devices,
740 ARRAY_SIZE(sh73a0_early_devices));
Yoshii Takashib028f942010-11-19 13:20:45 +0000741 platform_add_devices(sh73a0_late_devices,
742 ARRAY_SIZE(sh73a0_late_devices));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000743}
744
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900745void __init sh73a0_init_delay(void)
746{
747 shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
748}
749
Kuninori Morimotod6720002012-05-10 00:26:58 -0700750/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
751void __init __weak sh73a0_register_twd(void) { }
752
Stephen Warren6bb27d72012-11-08 12:40:59 -0700753void __init sh73a0_earlytimer_init(void)
Magnus Damm3be26fd2012-03-06 17:36:45 +0900754{
Magnus Damm43cb8cb2013-05-22 15:04:14 +0900755 sh73a0_init_delay();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900756 sh73a0_clock_init();
757 shmobile_earlytimer_init();
Kuninori Morimotod6720002012-05-10 00:26:58 -0700758 sh73a0_register_twd();
Magnus Damm3be26fd2012-03-06 17:36:45 +0900759}
760
Magnus Damm6d9598e2010-11-17 10:59:31 +0000761void __init sh73a0_add_early_devices(void)
762{
Simon Horman3b00f932013-02-19 10:53:05 +0900763 early_platform_add_devices(sh73a0_devices_dt,
764 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Damm6d9598e2010-11-17 10:59:31 +0000765 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{
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200776 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
777
Simon Horman48609532012-11-21 22:00:15 +0900778 /* clocks are setup late during boot in the case of DT */
779 sh73a0_clock_init();
780
Simon Horman3b00f932013-02-19 10:53:05 +0900781 platform_add_devices(sh73a0_devices_dt,
782 ARRAY_SIZE(sh73a0_devices_dt));
Magnus Dammea315972013-07-01 14:42:04 +0900783 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Guennadi Liakhovetskid2347382013-04-05 12:00:38 +0200784
785 /* Instantiate cpufreq-cpu0 */
786 platform_device_register_full(&devinfo);
Simon Horman48609532012-11-21 22:00:15 +0900787}
788
789static 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 .nr_irqs = NR_IRQS_LEGACY,
Simon Horman48609532012-11-21 22:00:15 +0900799 .init_machine = sh73a0_add_standard_devices_dt,
Simon Horman48609532012-11-21 22:00:15 +0900800 .dt_compat = sh73a0_boards_compat_dt,
801MACHINE_END
802#endif /* CONFIG_USE_OF */