blob: 420d25c0d742fe0f38d9e245acd5fb0a1204ff92 [file] [log] [blame]
Magnus Damm2b7eda62010-02-05 11:14:58 +00001/*
2 * sh7372 processor support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
Magnus Damm68224712011-04-28 03:21:00 +000025#include <linux/uio_driver.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000026#include <linux/delay.h>
27#include <linux/input.h>
28#include <linux/io.h>
29#include <linux/serial_sci.h>
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +000030#include <linux/sh_dma.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000031#include <linux/sh_intc.h>
32#include <linux/sh_timer.h>
Rafael J. Wysocki111058c2011-08-14 13:35:39 +020033#include <linux/pm_domain.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000034#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060035#include <mach/irqs.h>
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +000036#include <mach/sh7372.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000037#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
39
Magnus Damm33c96072010-05-20 14:41:00 +000040/* SCIFA0 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000041static struct plat_sci_port scif0_platform_data = {
42 .mapbase = 0xe6c40000,
43 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090044 .scscr = SCSCR_RE | SCSCR_TE,
45 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +000046 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +000047 .irqs = { evt2irq(0x0c00), evt2irq(0x0c00),
48 evt2irq(0x0c00), evt2irq(0x0c00) },
Magnus Damm2b7eda62010-02-05 11:14:58 +000049};
50
51static struct platform_device scif0_device = {
52 .name = "sh-sci",
53 .id = 0,
54 .dev = {
55 .platform_data = &scif0_platform_data,
56 },
57};
58
Magnus Damm33c96072010-05-20 14:41:00 +000059/* SCIFA1 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000060static struct plat_sci_port scif1_platform_data = {
61 .mapbase = 0xe6c50000,
62 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090063 .scscr = SCSCR_RE | SCSCR_TE,
64 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +000065 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +000066 .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
67 evt2irq(0x0c20), evt2irq(0x0c20) },
Magnus Damm2b7eda62010-02-05 11:14:58 +000068};
69
70static struct platform_device scif1_device = {
71 .name = "sh-sci",
72 .id = 1,
73 .dev = {
74 .platform_data = &scif1_platform_data,
75 },
76};
77
Magnus Damm33c96072010-05-20 14:41:00 +000078/* SCIFA2 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000079static struct plat_sci_port scif2_platform_data = {
80 .mapbase = 0xe6c60000,
81 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090082 .scscr = SCSCR_RE | SCSCR_TE,
83 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +000084 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +000085 .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
86 evt2irq(0x0c40), evt2irq(0x0c40) },
Magnus Damm2b7eda62010-02-05 11:14:58 +000087};
88
89static struct platform_device scif2_device = {
90 .name = "sh-sci",
91 .id = 2,
92 .dev = {
93 .platform_data = &scif2_platform_data,
94 },
95};
96
Magnus Damm33c96072010-05-20 14:41:00 +000097/* SCIFA3 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000098static struct plat_sci_port scif3_platform_data = {
99 .mapbase = 0xe6c70000,
100 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900101 .scscr = SCSCR_RE | SCSCR_TE,
102 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000103 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +0000104 .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
105 evt2irq(0x0c60), evt2irq(0x0c60) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000106};
107
108static struct platform_device scif3_device = {
109 .name = "sh-sci",
110 .id = 3,
111 .dev = {
112 .platform_data = &scif3_platform_data,
113 },
114};
115
Magnus Damm33c96072010-05-20 14:41:00 +0000116/* SCIFA4 */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000117static struct plat_sci_port scif4_platform_data = {
118 .mapbase = 0xe6c80000,
119 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900120 .scscr = SCSCR_RE | SCSCR_TE,
121 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000122 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +0000123 .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
124 evt2irq(0x0d20), evt2irq(0x0d20) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000125};
126
127static struct platform_device scif4_device = {
128 .name = "sh-sci",
129 .id = 4,
130 .dev = {
131 .platform_data = &scif4_platform_data,
132 },
133};
134
Magnus Damm33c96072010-05-20 14:41:00 +0000135/* SCIFA5 */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000136static struct plat_sci_port scif5_platform_data = {
137 .mapbase = 0xe6cb0000,
138 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900139 .scscr = SCSCR_RE | SCSCR_TE,
140 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000141 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +0000142 .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
143 evt2irq(0x0d40), evt2irq(0x0d40) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000144};
145
146static struct platform_device scif5_device = {
147 .name = "sh-sci",
148 .id = 5,
149 .dev = {
150 .platform_data = &scif5_platform_data,
151 },
152};
153
Magnus Damm33c96072010-05-20 14:41:00 +0000154/* SCIFB */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000155static struct plat_sci_port scif6_platform_data = {
156 .mapbase = 0xe6c30000,
157 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900158 .scscr = SCSCR_RE | SCSCR_TE,
159 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000160 .type = PORT_SCIFB,
Magnus Damm33c96072010-05-20 14:41:00 +0000161 .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
162 evt2irq(0x0d60), evt2irq(0x0d60) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000163};
164
165static struct platform_device scif6_device = {
166 .name = "sh-sci",
167 .id = 6,
168 .dev = {
169 .platform_data = &scif6_platform_data,
170 },
171};
172
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000173/* CMT */
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000174static struct sh_timer_config cmt2_platform_data = {
175 .name = "CMT2",
176 .channel_offset = 0x40,
177 .timer_bit = 5,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000178 .clockevent_rating = 125,
179 .clocksource_rating = 125,
180};
181
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000182static struct resource cmt2_resources[] = {
Magnus Damm2b7eda62010-02-05 11:14:58 +0000183 [0] = {
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000184 .name = "CMT2",
185 .start = 0xe6130040,
186 .end = 0xe613004b,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000187 .flags = IORESOURCE_MEM,
188 },
189 [1] = {
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000190 .start = evt2irq(0x0b80), /* CMT2 */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000191 .flags = IORESOURCE_IRQ,
192 },
193};
194
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000195static struct platform_device cmt2_device = {
Magnus Damm2b7eda62010-02-05 11:14:58 +0000196 .name = "sh_cmt",
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000197 .id = 2,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000198 .dev = {
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000199 .platform_data = &cmt2_platform_data,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000200 },
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000201 .resource = cmt2_resources,
202 .num_resources = ARRAY_SIZE(cmt2_resources),
Magnus Damm2b7eda62010-02-05 11:14:58 +0000203};
204
Magnus Dammc6c049e2010-10-14 06:57:25 +0000205/* TMU */
206static struct sh_timer_config tmu00_platform_data = {
207 .name = "TMU00",
208 .channel_offset = 0x4,
209 .timer_bit = 0,
210 .clockevent_rating = 200,
211};
212
213static struct resource tmu00_resources[] = {
214 [0] = {
215 .name = "TMU00",
216 .start = 0xfff60008,
217 .end = 0xfff60013,
218 .flags = IORESOURCE_MEM,
219 },
220 [1] = {
221 .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
222 .flags = IORESOURCE_IRQ,
223 },
224};
225
226static struct platform_device tmu00_device = {
227 .name = "sh_tmu",
228 .id = 0,
229 .dev = {
230 .platform_data = &tmu00_platform_data,
231 },
232 .resource = tmu00_resources,
233 .num_resources = ARRAY_SIZE(tmu00_resources),
234};
235
236static struct sh_timer_config tmu01_platform_data = {
237 .name = "TMU01",
238 .channel_offset = 0x10,
239 .timer_bit = 1,
240 .clocksource_rating = 200,
241};
242
243static struct resource tmu01_resources[] = {
244 [0] = {
245 .name = "TMU01",
246 .start = 0xfff60014,
247 .end = 0xfff6001f,
248 .flags = IORESOURCE_MEM,
249 },
250 [1] = {
251 .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
252 .flags = IORESOURCE_IRQ,
253 },
254};
255
256static struct platform_device tmu01_device = {
257 .name = "sh_tmu",
258 .id = 1,
259 .dev = {
260 .platform_data = &tmu01_platform_data,
261 },
262 .resource = tmu01_resources,
263 .num_resources = ARRAY_SIZE(tmu01_resources),
264};
265
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000266/* I2C */
267static struct resource iic0_resources[] = {
268 [0] = {
269 .name = "IIC0",
270 .start = 0xFFF20000,
271 .end = 0xFFF20425 - 1,
272 .flags = IORESOURCE_MEM,
273 },
274 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000275 .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
276 .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000277 .flags = IORESOURCE_IRQ,
278 },
279};
280
281static struct platform_device iic0_device = {
282 .name = "i2c-sh_mobile",
283 .id = 0, /* "i2c0" clock */
284 .num_resources = ARRAY_SIZE(iic0_resources),
285 .resource = iic0_resources,
286};
287
288static struct resource iic1_resources[] = {
289 [0] = {
290 .name = "IIC1",
291 .start = 0xE6C20000,
292 .end = 0xE6C20425 - 1,
293 .flags = IORESOURCE_MEM,
294 },
295 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000296 .start = evt2irq(0x780), /* IIC1_ALI1 */
297 .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000298 .flags = IORESOURCE_IRQ,
299 },
300};
301
302static struct platform_device iic1_device = {
303 .name = "i2c-sh_mobile",
304 .id = 1, /* "i2c1" clock */
305 .num_resources = ARRAY_SIZE(iic1_resources),
306 .resource = iic1_resources,
307};
308
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000309/* DMA */
310/* Transmit sizes and respective CHCR register values */
311enum {
312 XMIT_SZ_8BIT = 0,
313 XMIT_SZ_16BIT = 1,
314 XMIT_SZ_32BIT = 2,
315 XMIT_SZ_64BIT = 7,
316 XMIT_SZ_128BIT = 3,
317 XMIT_SZ_256BIT = 4,
318 XMIT_SZ_512BIT = 5,
319};
320
321/* log2(size / 8) - used to calculate number of transfers */
322#define TS_SHIFT { \
323 [XMIT_SZ_8BIT] = 0, \
324 [XMIT_SZ_16BIT] = 1, \
325 [XMIT_SZ_32BIT] = 2, \
326 [XMIT_SZ_64BIT] = 3, \
327 [XMIT_SZ_128BIT] = 4, \
328 [XMIT_SZ_256BIT] = 5, \
329 [XMIT_SZ_512BIT] = 6, \
330}
331
332#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
333 (((i) & 0xc) << (20 - 2)))
334
335static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
336 {
Guennadi Liakhovetski8d3e17b2010-05-23 16:39:24 +0000337 .slave_id = SHDMA_SLAVE_SCIF0_TX,
338 .addr = 0xe6c40020,
339 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
340 .mid_rid = 0x21,
341 }, {
342 .slave_id = SHDMA_SLAVE_SCIF0_RX,
343 .addr = 0xe6c40024,
344 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
345 .mid_rid = 0x22,
346 }, {
347 .slave_id = SHDMA_SLAVE_SCIF1_TX,
348 .addr = 0xe6c50020,
349 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
350 .mid_rid = 0x25,
351 }, {
352 .slave_id = SHDMA_SLAVE_SCIF1_RX,
353 .addr = 0xe6c50024,
354 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
355 .mid_rid = 0x26,
356 }, {
357 .slave_id = SHDMA_SLAVE_SCIF2_TX,
358 .addr = 0xe6c60020,
359 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
360 .mid_rid = 0x29,
361 }, {
362 .slave_id = SHDMA_SLAVE_SCIF2_RX,
363 .addr = 0xe6c60024,
364 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
365 .mid_rid = 0x2a,
366 }, {
367 .slave_id = SHDMA_SLAVE_SCIF3_TX,
368 .addr = 0xe6c70020,
369 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
370 .mid_rid = 0x2d,
371 }, {
372 .slave_id = SHDMA_SLAVE_SCIF3_RX,
373 .addr = 0xe6c70024,
374 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
375 .mid_rid = 0x2e,
376 }, {
377 .slave_id = SHDMA_SLAVE_SCIF4_TX,
378 .addr = 0xe6c80020,
379 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
380 .mid_rid = 0x39,
381 }, {
382 .slave_id = SHDMA_SLAVE_SCIF4_RX,
383 .addr = 0xe6c80024,
384 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
385 .mid_rid = 0x3a,
386 }, {
387 .slave_id = SHDMA_SLAVE_SCIF5_TX,
388 .addr = 0xe6cb0020,
389 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
390 .mid_rid = 0x35,
391 }, {
392 .slave_id = SHDMA_SLAVE_SCIF5_RX,
393 .addr = 0xe6cb0024,
394 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
395 .mid_rid = 0x36,
396 }, {
397 .slave_id = SHDMA_SLAVE_SCIF6_TX,
398 .addr = 0xe6c30040,
399 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
400 .mid_rid = 0x3d,
401 }, {
402 .slave_id = SHDMA_SLAVE_SCIF6_RX,
403 .addr = 0xe6c30060,
404 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
405 .mid_rid = 0x3e,
406 }, {
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000407 .slave_id = SHDMA_SLAVE_SDHI0_TX,
408 .addr = 0xe6850030,
409 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
410 .mid_rid = 0xc1,
411 }, {
412 .slave_id = SHDMA_SLAVE_SDHI0_RX,
413 .addr = 0xe6850030,
414 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
415 .mid_rid = 0xc2,
416 }, {
417 .slave_id = SHDMA_SLAVE_SDHI1_TX,
418 .addr = 0xe6860030,
419 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
420 .mid_rid = 0xc9,
421 }, {
422 .slave_id = SHDMA_SLAVE_SDHI1_RX,
423 .addr = 0xe6860030,
424 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
425 .mid_rid = 0xca,
426 }, {
427 .slave_id = SHDMA_SLAVE_SDHI2_TX,
428 .addr = 0xe6870030,
429 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
430 .mid_rid = 0xcd,
431 }, {
432 .slave_id = SHDMA_SLAVE_SDHI2_RX,
433 .addr = 0xe6870030,
434 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
435 .mid_rid = 0xce,
Guennadi Liakhovetski6d11dc12010-11-24 10:05:15 +0000436 }, {
437 .slave_id = SHDMA_SLAVE_MMCIF_TX,
438 .addr = 0xe6bd0034,
439 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
440 .mid_rid = 0xd1,
441 }, {
442 .slave_id = SHDMA_SLAVE_MMCIF_RX,
443 .addr = 0xe6bd0034,
444 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
445 .mid_rid = 0xd2,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000446 },
447};
448
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100449#define SH7372_CHCLR 0x220
450
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000451static const struct sh_dmae_channel sh7372_dmae_channels[] = {
452 {
453 .offset = 0,
454 .dmars = 0,
455 .dmars_bit = 0,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100456 .chclr_offset = SH7372_CHCLR + 0,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000457 }, {
458 .offset = 0x10,
459 .dmars = 0,
460 .dmars_bit = 8,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100461 .chclr_offset = SH7372_CHCLR + 0x10,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000462 }, {
463 .offset = 0x20,
464 .dmars = 4,
465 .dmars_bit = 0,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100466 .chclr_offset = SH7372_CHCLR + 0x20,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000467 }, {
468 .offset = 0x30,
469 .dmars = 4,
470 .dmars_bit = 8,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100471 .chclr_offset = SH7372_CHCLR + 0x30,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000472 }, {
473 .offset = 0x50,
474 .dmars = 8,
475 .dmars_bit = 0,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100476 .chclr_offset = SH7372_CHCLR + 0x50,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000477 }, {
478 .offset = 0x60,
479 .dmars = 8,
480 .dmars_bit = 8,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100481 .chclr_offset = SH7372_CHCLR + 0x60,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000482 }
483};
484
485static const unsigned int ts_shift[] = TS_SHIFT;
486
487static struct sh_dmae_pdata dma_platform_data = {
488 .slave = sh7372_dmae_slaves,
489 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
490 .channel = sh7372_dmae_channels,
491 .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
492 .ts_low_shift = 3,
493 .ts_low_mask = 0x18,
494 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
495 .ts_high_mask = 0x00300000,
496 .ts_shift = ts_shift,
497 .ts_shift_num = ARRAY_SIZE(ts_shift),
498 .dmaor_init = DMAOR_DME,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100499 .chclr_present = 1,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000500};
501
502/* Resource order important! */
503static struct resource sh7372_dmae0_resources[] = {
504 {
505 /* Channel registers and DMAOR */
506 .start = 0xfe008020,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100507 .end = 0xfe00828f,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000508 .flags = IORESOURCE_MEM,
509 },
510 {
511 /* DMARSx */
512 .start = 0xfe009000,
513 .end = 0xfe00900b,
514 .flags = IORESOURCE_MEM,
515 },
516 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900517 .name = "error_irq",
Magnus Dammf989ae52010-08-31 09:27:53 +0000518 .start = evt2irq(0x20c0),
519 .end = evt2irq(0x20c0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000520 .flags = IORESOURCE_IRQ,
521 },
522 {
523 /* IRQ for channels 0-5 */
Magnus Dammf989ae52010-08-31 09:27:53 +0000524 .start = evt2irq(0x2000),
525 .end = evt2irq(0x20a0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000526 .flags = IORESOURCE_IRQ,
527 },
528};
529
530/* Resource order important! */
531static struct resource sh7372_dmae1_resources[] = {
532 {
533 /* Channel registers and DMAOR */
534 .start = 0xfe018020,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100535 .end = 0xfe01828f,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000536 .flags = IORESOURCE_MEM,
537 },
538 {
539 /* DMARSx */
540 .start = 0xfe019000,
541 .end = 0xfe01900b,
542 .flags = IORESOURCE_MEM,
543 },
544 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900545 .name = "error_irq",
Magnus Dammf989ae52010-08-31 09:27:53 +0000546 .start = evt2irq(0x21c0),
547 .end = evt2irq(0x21c0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000548 .flags = IORESOURCE_IRQ,
549 },
550 {
551 /* IRQ for channels 0-5 */
Magnus Dammf989ae52010-08-31 09:27:53 +0000552 .start = evt2irq(0x2100),
553 .end = evt2irq(0x21a0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000554 .flags = IORESOURCE_IRQ,
555 },
556};
557
558/* Resource order important! */
559static struct resource sh7372_dmae2_resources[] = {
560 {
561 /* Channel registers and DMAOR */
562 .start = 0xfe028020,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100563 .end = 0xfe02828f,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000564 .flags = IORESOURCE_MEM,
565 },
566 {
567 /* DMARSx */
568 .start = 0xfe029000,
569 .end = 0xfe02900b,
570 .flags = IORESOURCE_MEM,
571 },
572 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900573 .name = "error_irq",
Magnus Dammf989ae52010-08-31 09:27:53 +0000574 .start = evt2irq(0x22c0),
575 .end = evt2irq(0x22c0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000576 .flags = IORESOURCE_IRQ,
577 },
578 {
579 /* IRQ for channels 0-5 */
Magnus Dammf989ae52010-08-31 09:27:53 +0000580 .start = evt2irq(0x2200),
581 .end = evt2irq(0x22a0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000582 .flags = IORESOURCE_IRQ,
583 },
584};
585
586static struct platform_device dma0_device = {
587 .name = "sh-dma-engine",
588 .id = 0,
589 .resource = sh7372_dmae0_resources,
590 .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
591 .dev = {
592 .platform_data = &dma_platform_data,
593 },
594};
595
596static struct platform_device dma1_device = {
597 .name = "sh-dma-engine",
598 .id = 1,
599 .resource = sh7372_dmae1_resources,
600 .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
601 .dev = {
602 .platform_data = &dma_platform_data,
603 },
604};
605
606static struct platform_device dma2_device = {
607 .name = "sh-dma-engine",
608 .id = 2,
609 .resource = sh7372_dmae2_resources,
610 .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
611 .dev = {
612 .platform_data = &dma_platform_data,
613 },
614};
615
Kuninori Morimotoafe48042011-06-17 08:21:10 +0000616/*
617 * USB-DMAC
618 */
619
620unsigned int usbts_shift[] = {3, 4, 5};
621
622enum {
623 XMIT_SZ_8BYTE = 0,
624 XMIT_SZ_16BYTE = 1,
625 XMIT_SZ_32BYTE = 2,
626};
627
628#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
629
630static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
631 {
632 .offset = 0,
633 }, {
634 .offset = 0x20,
635 },
636};
637
638/* USB DMAC0 */
639static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
640 {
641 .slave_id = SHDMA_SLAVE_USB0_TX,
642 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
643 }, {
644 .slave_id = SHDMA_SLAVE_USB0_RX,
645 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
646 },
647};
648
649static struct sh_dmae_pdata usb_dma0_platform_data = {
650 .slave = sh7372_usb_dmae0_slaves,
651 .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
652 .channel = sh7372_usb_dmae_channels,
653 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
654 .ts_low_shift = 6,
655 .ts_low_mask = 0xc0,
656 .ts_high_shift = 0,
657 .ts_high_mask = 0,
658 .ts_shift = usbts_shift,
659 .ts_shift_num = ARRAY_SIZE(usbts_shift),
660 .dmaor_init = DMAOR_DME,
661 .chcr_offset = 0x14,
662 .chcr_ie_bit = 1 << 5,
663 .dmaor_is_32bit = 1,
664 .needs_tend_set = 1,
665 .no_dmars = 1,
666};
667
668static struct resource sh7372_usb_dmae0_resources[] = {
669 {
670 /* Channel registers and DMAOR */
671 .start = 0xe68a0020,
672 .end = 0xe68a0064 - 1,
673 .flags = IORESOURCE_MEM,
674 },
675 {
676 /* VCR/SWR/DMICR */
677 .start = 0xe68a0000,
678 .end = 0xe68a0014 - 1,
679 .flags = IORESOURCE_MEM,
680 },
681 {
682 /* IRQ for channels */
683 .start = evt2irq(0x0a00),
684 .end = evt2irq(0x0a00),
685 .flags = IORESOURCE_IRQ,
686 },
687};
688
689static struct platform_device usb_dma0_device = {
690 .name = "sh-dma-engine",
691 .id = 3,
692 .resource = sh7372_usb_dmae0_resources,
693 .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
694 .dev = {
695 .platform_data = &usb_dma0_platform_data,
696 },
697};
698
699/* USB DMAC1 */
700static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
701 {
702 .slave_id = SHDMA_SLAVE_USB1_TX,
703 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
704 }, {
705 .slave_id = SHDMA_SLAVE_USB1_RX,
706 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
707 },
708};
709
710static struct sh_dmae_pdata usb_dma1_platform_data = {
711 .slave = sh7372_usb_dmae1_slaves,
712 .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
713 .channel = sh7372_usb_dmae_channels,
714 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
715 .ts_low_shift = 6,
716 .ts_low_mask = 0xc0,
717 .ts_high_shift = 0,
718 .ts_high_mask = 0,
719 .ts_shift = usbts_shift,
720 .ts_shift_num = ARRAY_SIZE(usbts_shift),
721 .dmaor_init = DMAOR_DME,
722 .chcr_offset = 0x14,
723 .chcr_ie_bit = 1 << 5,
724 .dmaor_is_32bit = 1,
725 .needs_tend_set = 1,
726 .no_dmars = 1,
727};
728
729static struct resource sh7372_usb_dmae1_resources[] = {
730 {
731 /* Channel registers and DMAOR */
732 .start = 0xe68c0020,
733 .end = 0xe68c0064 - 1,
734 .flags = IORESOURCE_MEM,
735 },
736 {
737 /* VCR/SWR/DMICR */
738 .start = 0xe68c0000,
739 .end = 0xe68c0014 - 1,
740 .flags = IORESOURCE_MEM,
741 },
742 {
743 /* IRQ for channels */
744 .start = evt2irq(0x1d00),
745 .end = evt2irq(0x1d00),
746 .flags = IORESOURCE_IRQ,
747 },
748};
749
750static struct platform_device usb_dma1_device = {
751 .name = "sh-dma-engine",
752 .id = 4,
753 .resource = sh7372_usb_dmae1_resources,
754 .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
755 .dev = {
756 .platform_data = &usb_dma1_platform_data,
757 },
758};
759
Magnus Damm68224712011-04-28 03:21:00 +0000760/* VPU */
761static struct uio_info vpu_platform_data = {
762 .name = "VPU5HG",
763 .version = "0",
764 .irq = intcs_evt2irq(0x980),
765};
766
767static struct resource vpu_resources[] = {
768 [0] = {
769 .name = "VPU",
770 .start = 0xfe900000,
771 .end = 0xfe900157,
772 .flags = IORESOURCE_MEM,
773 },
774};
775
776static struct platform_device vpu_device = {
777 .name = "uio_pdrv_genirq",
778 .id = 0,
779 .dev = {
780 .platform_data = &vpu_platform_data,
781 },
782 .resource = vpu_resources,
783 .num_resources = ARRAY_SIZE(vpu_resources),
784};
785
786/* VEU0 */
787static struct uio_info veu0_platform_data = {
788 .name = "VEU0",
789 .version = "0",
790 .irq = intcs_evt2irq(0x700),
791};
792
793static struct resource veu0_resources[] = {
794 [0] = {
795 .name = "VEU0",
796 .start = 0xfe920000,
797 .end = 0xfe9200cb,
798 .flags = IORESOURCE_MEM,
799 },
800};
801
802static struct platform_device veu0_device = {
803 .name = "uio_pdrv_genirq",
804 .id = 1,
805 .dev = {
806 .platform_data = &veu0_platform_data,
807 },
808 .resource = veu0_resources,
809 .num_resources = ARRAY_SIZE(veu0_resources),
810};
811
812/* VEU1 */
813static struct uio_info veu1_platform_data = {
814 .name = "VEU1",
815 .version = "0",
816 .irq = intcs_evt2irq(0x720),
817};
818
819static struct resource veu1_resources[] = {
820 [0] = {
821 .name = "VEU1",
822 .start = 0xfe924000,
823 .end = 0xfe9240cb,
824 .flags = IORESOURCE_MEM,
825 },
826};
827
828static struct platform_device veu1_device = {
829 .name = "uio_pdrv_genirq",
830 .id = 2,
831 .dev = {
832 .platform_data = &veu1_platform_data,
833 },
834 .resource = veu1_resources,
835 .num_resources = ARRAY_SIZE(veu1_resources),
836};
837
838/* VEU2 */
839static struct uio_info veu2_platform_data = {
840 .name = "VEU2",
841 .version = "0",
842 .irq = intcs_evt2irq(0x740),
843};
844
845static struct resource veu2_resources[] = {
846 [0] = {
847 .name = "VEU2",
848 .start = 0xfe928000,
849 .end = 0xfe928307,
850 .flags = IORESOURCE_MEM,
851 },
852};
853
854static struct platform_device veu2_device = {
855 .name = "uio_pdrv_genirq",
856 .id = 3,
857 .dev = {
858 .platform_data = &veu2_platform_data,
859 },
860 .resource = veu2_resources,
861 .num_resources = ARRAY_SIZE(veu2_resources),
862};
863
864/* VEU3 */
865static struct uio_info veu3_platform_data = {
866 .name = "VEU3",
867 .version = "0",
868 .irq = intcs_evt2irq(0x760),
869};
870
871static struct resource veu3_resources[] = {
872 [0] = {
873 .name = "VEU3",
874 .start = 0xfe92c000,
875 .end = 0xfe92c307,
876 .flags = IORESOURCE_MEM,
877 },
878};
879
880static struct platform_device veu3_device = {
881 .name = "uio_pdrv_genirq",
882 .id = 4,
883 .dev = {
884 .platform_data = &veu3_platform_data,
885 },
886 .resource = veu3_resources,
887 .num_resources = ARRAY_SIZE(veu3_resources),
888};
889
890/* JPU */
891static struct uio_info jpu_platform_data = {
892 .name = "JPU",
893 .version = "0",
894 .irq = intcs_evt2irq(0x560),
895};
896
897static struct resource jpu_resources[] = {
898 [0] = {
899 .name = "JPU",
900 .start = 0xfe980000,
901 .end = 0xfe9902d3,
902 .flags = IORESOURCE_MEM,
903 },
904};
905
906static struct platform_device jpu_device = {
907 .name = "uio_pdrv_genirq",
908 .id = 5,
909 .dev = {
910 .platform_data = &jpu_platform_data,
911 },
912 .resource = jpu_resources,
913 .num_resources = ARRAY_SIZE(jpu_resources),
914};
915
916/* SPU2DSP0 */
917static struct uio_info spu0_platform_data = {
918 .name = "SPU2DSP0",
919 .version = "0",
920 .irq = evt2irq(0x1800),
921};
922
923static struct resource spu0_resources[] = {
924 [0] = {
925 .name = "SPU2DSP0",
926 .start = 0xfe200000,
927 .end = 0xfe2fffff,
928 .flags = IORESOURCE_MEM,
929 },
930};
931
932static struct platform_device spu0_device = {
933 .name = "uio_pdrv_genirq",
934 .id = 6,
935 .dev = {
936 .platform_data = &spu0_platform_data,
937 },
938 .resource = spu0_resources,
939 .num_resources = ARRAY_SIZE(spu0_resources),
940};
941
942/* SPU2DSP1 */
943static struct uio_info spu1_platform_data = {
944 .name = "SPU2DSP1",
945 .version = "0",
946 .irq = evt2irq(0x1820),
947};
948
949static struct resource spu1_resources[] = {
950 [0] = {
951 .name = "SPU2DSP1",
952 .start = 0xfe300000,
953 .end = 0xfe3fffff,
954 .flags = IORESOURCE_MEM,
955 },
956};
957
958static struct platform_device spu1_device = {
959 .name = "uio_pdrv_genirq",
960 .id = 7,
961 .dev = {
962 .platform_data = &spu1_platform_data,
963 },
964 .resource = spu1_resources,
965 .num_resources = ARRAY_SIZE(spu1_resources),
966};
967
Magnus Damm2b7eda62010-02-05 11:14:58 +0000968static struct platform_device *sh7372_early_devices[] __initdata = {
969 &scif0_device,
970 &scif1_device,
971 &scif2_device,
972 &scif3_device,
973 &scif4_device,
974 &scif5_device,
975 &scif6_device,
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000976 &cmt2_device,
Magnus Dammc6c049e2010-10-14 06:57:25 +0000977 &tmu00_device,
978 &tmu01_device,
Magnus Damm934e4072010-10-13 07:22:11 +0000979};
980
981static struct platform_device *sh7372_late_devices[] __initdata = {
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000982 &iic0_device,
983 &iic1_device,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000984 &dma0_device,
985 &dma1_device,
986 &dma2_device,
Kuninori Morimotoafe48042011-06-17 08:21:10 +0000987 &usb_dma0_device,
988 &usb_dma1_device,
Magnus Damm68224712011-04-28 03:21:00 +0000989 &vpu_device,
990 &veu0_device,
991 &veu1_device,
992 &veu2_device,
993 &veu3_device,
994 &jpu_device,
995 &spu0_device,
996 &spu1_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000997};
998
999void __init sh7372_add_standard_devices(void)
1000{
Magnus Damm96f79342011-07-01 22:14:34 +02001001 sh7372_init_pm_domain(&sh7372_a4lc);
Kuninori Morimotoc1ba5bb2011-07-10 10:12:08 +02001002 sh7372_init_pm_domain(&sh7372_a4mp);
Magnus Dammd24771d2011-07-10 10:38:22 +02001003 sh7372_init_pm_domain(&sh7372_d4);
Magnus Damm382414b2011-10-19 23:52:50 +02001004 sh7372_init_pm_domain(&sh7372_a4r);
Magnus Damm33afebf2011-07-01 22:14:45 +02001005 sh7372_init_pm_domain(&sh7372_a3rv);
Magnus Damm082517a2011-07-01 22:14:53 +02001006 sh7372_init_pm_domain(&sh7372_a3ri);
Magnus Dammf7dadb32011-12-23 01:23:07 +01001007 sh7372_init_pm_domain(&sh7372_a4s);
Magnus Dammd93f5cd2011-10-19 23:52:41 +02001008 sh7372_init_pm_domain(&sh7372_a3sp);
Magnus Dammf7dadb32011-12-23 01:23:07 +01001009 sh7372_init_pm_domain(&sh7372_a3sg);
Magnus Damm96f79342011-07-01 22:14:34 +02001010
Rafael J. Wysocki111058c2011-08-14 13:35:39 +02001011 sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
Magnus Damm382414b2011-10-19 23:52:50 +02001012 sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc);
Rafael J. Wysocki111058c2011-08-14 13:35:39 +02001013
Magnus Dammf7dadb32011-12-23 01:23:07 +01001014 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sg);
1015 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sp);
1016
Magnus Damm2b7eda62010-02-05 11:14:58 +00001017 platform_add_devices(sh7372_early_devices,
1018 ARRAY_SIZE(sh7372_early_devices));
Magnus Damm934e4072010-10-13 07:22:11 +00001019
1020 platform_add_devices(sh7372_late_devices,
1021 ARRAY_SIZE(sh7372_late_devices));
Magnus Damm33afebf2011-07-01 22:14:45 +02001022
1023 sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
Kuninori Morimotoc1ba5bb2011-07-10 10:12:08 +02001024 sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
1025 sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
Magnus Dammd93f5cd2011-10-19 23:52:41 +02001026 sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
1027 sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
1028 sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
1029 sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
1030 sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
1031 sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
1032 sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
1033 sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
1034 sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
1035 sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
1036 sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
1037 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device);
1038 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device);
Magnus Damm382414b2011-10-19 23:52:50 +02001039 sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device);
1040 sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device);
1041 sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device);
1042 sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device);
1043 sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device);
1044 sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device);
Magnus Damm2b7eda62010-02-05 11:14:58 +00001045}
1046
Magnus Damm2b7eda62010-02-05 11:14:58 +00001047void __init sh7372_add_early_devices(void)
1048{
Magnus Damm2b7eda62010-02-05 11:14:58 +00001049 early_platform_add_devices(sh7372_early_devices,
1050 ARRAY_SIZE(sh7372_early_devices));
1051}