blob: a83cf51fc09906a13018472b4f563baebaf7bcb5 [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>
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +000035#include <mach/sh7372.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000036#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
38
Magnus Damm33c96072010-05-20 14:41:00 +000039/* SCIFA0 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000040static struct plat_sci_port scif0_platform_data = {
41 .mapbase = 0xe6c40000,
42 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090043 .scscr = SCSCR_RE | SCSCR_TE,
44 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +000045 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +000046 .irqs = { evt2irq(0x0c00), evt2irq(0x0c00),
47 evt2irq(0x0c00), evt2irq(0x0c00) },
Magnus Damm2b7eda62010-02-05 11:14:58 +000048};
49
50static struct platform_device scif0_device = {
51 .name = "sh-sci",
52 .id = 0,
53 .dev = {
54 .platform_data = &scif0_platform_data,
55 },
56};
57
Magnus Damm33c96072010-05-20 14:41:00 +000058/* SCIFA1 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000059static struct plat_sci_port scif1_platform_data = {
60 .mapbase = 0xe6c50000,
61 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090062 .scscr = SCSCR_RE | SCSCR_TE,
63 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +000064 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +000065 .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
66 evt2irq(0x0c20), evt2irq(0x0c20) },
Magnus Damm2b7eda62010-02-05 11:14:58 +000067};
68
69static struct platform_device scif1_device = {
70 .name = "sh-sci",
71 .id = 1,
72 .dev = {
73 .platform_data = &scif1_platform_data,
74 },
75};
76
Magnus Damm33c96072010-05-20 14:41:00 +000077/* SCIFA2 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000078static struct plat_sci_port scif2_platform_data = {
79 .mapbase = 0xe6c60000,
80 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +090081 .scscr = SCSCR_RE | SCSCR_TE,
82 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +000083 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +000084 .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
85 evt2irq(0x0c40), evt2irq(0x0c40) },
Magnus Damm2b7eda62010-02-05 11:14:58 +000086};
87
88static struct platform_device scif2_device = {
89 .name = "sh-sci",
90 .id = 2,
91 .dev = {
92 .platform_data = &scif2_platform_data,
93 },
94};
95
Magnus Damm33c96072010-05-20 14:41:00 +000096/* SCIFA3 */
Magnus Damm2b7eda62010-02-05 11:14:58 +000097static struct plat_sci_port scif3_platform_data = {
98 .mapbase = 0xe6c70000,
99 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900100 .scscr = SCSCR_RE | SCSCR_TE,
101 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000102 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +0000103 .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
104 evt2irq(0x0c60), evt2irq(0x0c60) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000105};
106
107static struct platform_device scif3_device = {
108 .name = "sh-sci",
109 .id = 3,
110 .dev = {
111 .platform_data = &scif3_platform_data,
112 },
113};
114
Magnus Damm33c96072010-05-20 14:41:00 +0000115/* SCIFA4 */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000116static struct plat_sci_port scif4_platform_data = {
117 .mapbase = 0xe6c80000,
118 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900119 .scscr = SCSCR_RE | SCSCR_TE,
120 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000121 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +0000122 .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
123 evt2irq(0x0d20), evt2irq(0x0d20) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000124};
125
126static struct platform_device scif4_device = {
127 .name = "sh-sci",
128 .id = 4,
129 .dev = {
130 .platform_data = &scif4_platform_data,
131 },
132};
133
Magnus Damm33c96072010-05-20 14:41:00 +0000134/* SCIFA5 */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000135static struct plat_sci_port scif5_platform_data = {
136 .mapbase = 0xe6cb0000,
137 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900138 .scscr = SCSCR_RE | SCSCR_TE,
139 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000140 .type = PORT_SCIFA,
Magnus Damm33c96072010-05-20 14:41:00 +0000141 .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
142 evt2irq(0x0d40), evt2irq(0x0d40) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000143};
144
145static struct platform_device scif5_device = {
146 .name = "sh-sci",
147 .id = 5,
148 .dev = {
149 .platform_data = &scif5_platform_data,
150 },
151};
152
Magnus Damm33c96072010-05-20 14:41:00 +0000153/* SCIFB */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000154static struct plat_sci_port scif6_platform_data = {
155 .mapbase = 0xe6c30000,
156 .flags = UPF_BOOT_AUTOCONF,
Paul Mundtf43dc232011-01-13 15:06:28 +0900157 .scscr = SCSCR_RE | SCSCR_TE,
158 .scbrr_algo_id = SCBRR_ALGO_4,
Guennadi Liakhovetskieb6e8605e2010-05-23 16:39:17 +0000159 .type = PORT_SCIFB,
Magnus Damm33c96072010-05-20 14:41:00 +0000160 .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
161 evt2irq(0x0d60), evt2irq(0x0d60) },
Magnus Damm2b7eda62010-02-05 11:14:58 +0000162};
163
164static struct platform_device scif6_device = {
165 .name = "sh-sci",
166 .id = 6,
167 .dev = {
168 .platform_data = &scif6_platform_data,
169 },
170};
171
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000172/* CMT */
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000173static struct sh_timer_config cmt2_platform_data = {
174 .name = "CMT2",
175 .channel_offset = 0x40,
176 .timer_bit = 5,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000177 .clockevent_rating = 125,
178 .clocksource_rating = 125,
179};
180
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000181static struct resource cmt2_resources[] = {
Magnus Damm2b7eda62010-02-05 11:14:58 +0000182 [0] = {
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000183 .name = "CMT2",
184 .start = 0xe6130040,
185 .end = 0xe613004b,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000186 .flags = IORESOURCE_MEM,
187 },
188 [1] = {
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000189 .start = evt2irq(0x0b80), /* CMT2 */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000190 .flags = IORESOURCE_IRQ,
191 },
192};
193
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000194static struct platform_device cmt2_device = {
Magnus Damm2b7eda62010-02-05 11:14:58 +0000195 .name = "sh_cmt",
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000196 .id = 2,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000197 .dev = {
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000198 .platform_data = &cmt2_platform_data,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000199 },
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000200 .resource = cmt2_resources,
201 .num_resources = ARRAY_SIZE(cmt2_resources),
Magnus Damm2b7eda62010-02-05 11:14:58 +0000202};
203
Magnus Dammc6c049e2010-10-14 06:57:25 +0000204/* TMU */
205static struct sh_timer_config tmu00_platform_data = {
206 .name = "TMU00",
207 .channel_offset = 0x4,
208 .timer_bit = 0,
209 .clockevent_rating = 200,
210};
211
212static struct resource tmu00_resources[] = {
213 [0] = {
214 .name = "TMU00",
215 .start = 0xfff60008,
216 .end = 0xfff60013,
217 .flags = IORESOURCE_MEM,
218 },
219 [1] = {
220 .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
221 .flags = IORESOURCE_IRQ,
222 },
223};
224
225static struct platform_device tmu00_device = {
226 .name = "sh_tmu",
227 .id = 0,
228 .dev = {
229 .platform_data = &tmu00_platform_data,
230 },
231 .resource = tmu00_resources,
232 .num_resources = ARRAY_SIZE(tmu00_resources),
233};
234
235static struct sh_timer_config tmu01_platform_data = {
236 .name = "TMU01",
237 .channel_offset = 0x10,
238 .timer_bit = 1,
239 .clocksource_rating = 200,
240};
241
242static struct resource tmu01_resources[] = {
243 [0] = {
244 .name = "TMU01",
245 .start = 0xfff60014,
246 .end = 0xfff6001f,
247 .flags = IORESOURCE_MEM,
248 },
249 [1] = {
250 .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
251 .flags = IORESOURCE_IRQ,
252 },
253};
254
255static struct platform_device tmu01_device = {
256 .name = "sh_tmu",
257 .id = 1,
258 .dev = {
259 .platform_data = &tmu01_platform_data,
260 },
261 .resource = tmu01_resources,
262 .num_resources = ARRAY_SIZE(tmu01_resources),
263};
264
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000265/* I2C */
266static struct resource iic0_resources[] = {
267 [0] = {
268 .name = "IIC0",
269 .start = 0xFFF20000,
270 .end = 0xFFF20425 - 1,
271 .flags = IORESOURCE_MEM,
272 },
273 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000274 .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
275 .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000276 .flags = IORESOURCE_IRQ,
277 },
278};
279
280static struct platform_device iic0_device = {
281 .name = "i2c-sh_mobile",
282 .id = 0, /* "i2c0" clock */
283 .num_resources = ARRAY_SIZE(iic0_resources),
284 .resource = iic0_resources,
285};
286
287static struct resource iic1_resources[] = {
288 [0] = {
289 .name = "IIC1",
290 .start = 0xE6C20000,
291 .end = 0xE6C20425 - 1,
292 .flags = IORESOURCE_MEM,
293 },
294 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000295 .start = evt2irq(0x780), /* IIC1_ALI1 */
296 .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000297 .flags = IORESOURCE_IRQ,
298 },
299};
300
301static struct platform_device iic1_device = {
302 .name = "i2c-sh_mobile",
303 .id = 1, /* "i2c1" clock */
304 .num_resources = ARRAY_SIZE(iic1_resources),
305 .resource = iic1_resources,
306};
307
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000308/* DMA */
309/* Transmit sizes and respective CHCR register values */
310enum {
311 XMIT_SZ_8BIT = 0,
312 XMIT_SZ_16BIT = 1,
313 XMIT_SZ_32BIT = 2,
314 XMIT_SZ_64BIT = 7,
315 XMIT_SZ_128BIT = 3,
316 XMIT_SZ_256BIT = 4,
317 XMIT_SZ_512BIT = 5,
318};
319
320/* log2(size / 8) - used to calculate number of transfers */
321#define TS_SHIFT { \
322 [XMIT_SZ_8BIT] = 0, \
323 [XMIT_SZ_16BIT] = 1, \
324 [XMIT_SZ_32BIT] = 2, \
325 [XMIT_SZ_64BIT] = 3, \
326 [XMIT_SZ_128BIT] = 4, \
327 [XMIT_SZ_256BIT] = 5, \
328 [XMIT_SZ_512BIT] = 6, \
329}
330
331#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
332 (((i) & 0xc) << (20 - 2)))
333
334static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
335 {
Guennadi Liakhovetski8d3e17b2010-05-23 16:39:24 +0000336 .slave_id = SHDMA_SLAVE_SCIF0_TX,
337 .addr = 0xe6c40020,
338 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
339 .mid_rid = 0x21,
340 }, {
341 .slave_id = SHDMA_SLAVE_SCIF0_RX,
342 .addr = 0xe6c40024,
343 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
344 .mid_rid = 0x22,
345 }, {
346 .slave_id = SHDMA_SLAVE_SCIF1_TX,
347 .addr = 0xe6c50020,
348 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
349 .mid_rid = 0x25,
350 }, {
351 .slave_id = SHDMA_SLAVE_SCIF1_RX,
352 .addr = 0xe6c50024,
353 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
354 .mid_rid = 0x26,
355 }, {
356 .slave_id = SHDMA_SLAVE_SCIF2_TX,
357 .addr = 0xe6c60020,
358 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
359 .mid_rid = 0x29,
360 }, {
361 .slave_id = SHDMA_SLAVE_SCIF2_RX,
362 .addr = 0xe6c60024,
363 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
364 .mid_rid = 0x2a,
365 }, {
366 .slave_id = SHDMA_SLAVE_SCIF3_TX,
367 .addr = 0xe6c70020,
368 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
369 .mid_rid = 0x2d,
370 }, {
371 .slave_id = SHDMA_SLAVE_SCIF3_RX,
372 .addr = 0xe6c70024,
373 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
374 .mid_rid = 0x2e,
375 }, {
376 .slave_id = SHDMA_SLAVE_SCIF4_TX,
377 .addr = 0xe6c80020,
378 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
379 .mid_rid = 0x39,
380 }, {
381 .slave_id = SHDMA_SLAVE_SCIF4_RX,
382 .addr = 0xe6c80024,
383 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
384 .mid_rid = 0x3a,
385 }, {
386 .slave_id = SHDMA_SLAVE_SCIF5_TX,
387 .addr = 0xe6cb0020,
388 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
389 .mid_rid = 0x35,
390 }, {
391 .slave_id = SHDMA_SLAVE_SCIF5_RX,
392 .addr = 0xe6cb0024,
393 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
394 .mid_rid = 0x36,
395 }, {
396 .slave_id = SHDMA_SLAVE_SCIF6_TX,
397 .addr = 0xe6c30040,
398 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
399 .mid_rid = 0x3d,
400 }, {
401 .slave_id = SHDMA_SLAVE_SCIF6_RX,
402 .addr = 0xe6c30060,
403 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
404 .mid_rid = 0x3e,
405 }, {
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000406 .slave_id = SHDMA_SLAVE_SDHI0_TX,
407 .addr = 0xe6850030,
408 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
409 .mid_rid = 0xc1,
410 }, {
411 .slave_id = SHDMA_SLAVE_SDHI0_RX,
412 .addr = 0xe6850030,
413 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
414 .mid_rid = 0xc2,
415 }, {
416 .slave_id = SHDMA_SLAVE_SDHI1_TX,
417 .addr = 0xe6860030,
418 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
419 .mid_rid = 0xc9,
420 }, {
421 .slave_id = SHDMA_SLAVE_SDHI1_RX,
422 .addr = 0xe6860030,
423 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
424 .mid_rid = 0xca,
425 }, {
426 .slave_id = SHDMA_SLAVE_SDHI2_TX,
427 .addr = 0xe6870030,
428 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
429 .mid_rid = 0xcd,
430 }, {
431 .slave_id = SHDMA_SLAVE_SDHI2_RX,
432 .addr = 0xe6870030,
433 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
434 .mid_rid = 0xce,
Guennadi Liakhovetski6d11dc12010-11-24 10:05:15 +0000435 }, {
436 .slave_id = SHDMA_SLAVE_MMCIF_TX,
437 .addr = 0xe6bd0034,
438 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
439 .mid_rid = 0xd1,
440 }, {
441 .slave_id = SHDMA_SLAVE_MMCIF_RX,
442 .addr = 0xe6bd0034,
443 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
444 .mid_rid = 0xd2,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000445 },
446};
447
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100448#define SH7372_CHCLR 0x220
449
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000450static const struct sh_dmae_channel sh7372_dmae_channels[] = {
451 {
452 .offset = 0,
453 .dmars = 0,
454 .dmars_bit = 0,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100455 .chclr_offset = SH7372_CHCLR + 0,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000456 }, {
457 .offset = 0x10,
458 .dmars = 0,
459 .dmars_bit = 8,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100460 .chclr_offset = SH7372_CHCLR + 0x10,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000461 }, {
462 .offset = 0x20,
463 .dmars = 4,
464 .dmars_bit = 0,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100465 .chclr_offset = SH7372_CHCLR + 0x20,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000466 }, {
467 .offset = 0x30,
468 .dmars = 4,
469 .dmars_bit = 8,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100470 .chclr_offset = SH7372_CHCLR + 0x30,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000471 }, {
472 .offset = 0x50,
473 .dmars = 8,
474 .dmars_bit = 0,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100475 .chclr_offset = SH7372_CHCLR + 0x50,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000476 }, {
477 .offset = 0x60,
478 .dmars = 8,
479 .dmars_bit = 8,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100480 .chclr_offset = SH7372_CHCLR + 0x60,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000481 }
482};
483
484static const unsigned int ts_shift[] = TS_SHIFT;
485
486static struct sh_dmae_pdata dma_platform_data = {
487 .slave = sh7372_dmae_slaves,
488 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
489 .channel = sh7372_dmae_channels,
490 .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
491 .ts_low_shift = 3,
492 .ts_low_mask = 0x18,
493 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
494 .ts_high_mask = 0x00300000,
495 .ts_shift = ts_shift,
496 .ts_shift_num = ARRAY_SIZE(ts_shift),
497 .dmaor_init = DMAOR_DME,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100498 .chclr_present = 1,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000499};
500
501/* Resource order important! */
502static struct resource sh7372_dmae0_resources[] = {
503 {
504 /* Channel registers and DMAOR */
505 .start = 0xfe008020,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100506 .end = 0xfe00828f,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000507 .flags = IORESOURCE_MEM,
508 },
509 {
510 /* DMARSx */
511 .start = 0xfe009000,
512 .end = 0xfe00900b,
513 .flags = IORESOURCE_MEM,
514 },
515 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900516 .name = "error_irq",
Magnus Dammf989ae52010-08-31 09:27:53 +0000517 .start = evt2irq(0x20c0),
518 .end = evt2irq(0x20c0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000519 .flags = IORESOURCE_IRQ,
520 },
521 {
522 /* IRQ for channels 0-5 */
Magnus Dammf989ae52010-08-31 09:27:53 +0000523 .start = evt2irq(0x2000),
524 .end = evt2irq(0x20a0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000525 .flags = IORESOURCE_IRQ,
526 },
527};
528
529/* Resource order important! */
530static struct resource sh7372_dmae1_resources[] = {
531 {
532 /* Channel registers and DMAOR */
533 .start = 0xfe018020,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100534 .end = 0xfe01828f,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000535 .flags = IORESOURCE_MEM,
536 },
537 {
538 /* DMARSx */
539 .start = 0xfe019000,
540 .end = 0xfe01900b,
541 .flags = IORESOURCE_MEM,
542 },
543 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900544 .name = "error_irq",
Magnus Dammf989ae52010-08-31 09:27:53 +0000545 .start = evt2irq(0x21c0),
546 .end = evt2irq(0x21c0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000547 .flags = IORESOURCE_IRQ,
548 },
549 {
550 /* IRQ for channels 0-5 */
Magnus Dammf989ae52010-08-31 09:27:53 +0000551 .start = evt2irq(0x2100),
552 .end = evt2irq(0x21a0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000553 .flags = IORESOURCE_IRQ,
554 },
555};
556
557/* Resource order important! */
558static struct resource sh7372_dmae2_resources[] = {
559 {
560 /* Channel registers and DMAOR */
561 .start = 0xfe028020,
Guennadi Liakhovetskie08b8812012-01-04 15:34:21 +0100562 .end = 0xfe02828f,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000563 .flags = IORESOURCE_MEM,
564 },
565 {
566 /* DMARSx */
567 .start = 0xfe029000,
568 .end = 0xfe02900b,
569 .flags = IORESOURCE_MEM,
570 },
571 {
Shimoda, Yoshihiro20052462012-01-10 14:21:31 +0900572 .name = "error_irq",
Magnus Dammf989ae52010-08-31 09:27:53 +0000573 .start = evt2irq(0x22c0),
574 .end = evt2irq(0x22c0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000575 .flags = IORESOURCE_IRQ,
576 },
577 {
578 /* IRQ for channels 0-5 */
Magnus Dammf989ae52010-08-31 09:27:53 +0000579 .start = evt2irq(0x2200),
580 .end = evt2irq(0x22a0),
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000581 .flags = IORESOURCE_IRQ,
582 },
583};
584
585static struct platform_device dma0_device = {
586 .name = "sh-dma-engine",
587 .id = 0,
588 .resource = sh7372_dmae0_resources,
589 .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
590 .dev = {
591 .platform_data = &dma_platform_data,
592 },
593};
594
595static struct platform_device dma1_device = {
596 .name = "sh-dma-engine",
597 .id = 1,
598 .resource = sh7372_dmae1_resources,
599 .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
600 .dev = {
601 .platform_data = &dma_platform_data,
602 },
603};
604
605static struct platform_device dma2_device = {
606 .name = "sh-dma-engine",
607 .id = 2,
608 .resource = sh7372_dmae2_resources,
609 .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
610 .dev = {
611 .platform_data = &dma_platform_data,
612 },
613};
614
Kuninori Morimotoafe48042011-06-17 08:21:10 +0000615/*
616 * USB-DMAC
617 */
618
619unsigned int usbts_shift[] = {3, 4, 5};
620
621enum {
622 XMIT_SZ_8BYTE = 0,
623 XMIT_SZ_16BYTE = 1,
624 XMIT_SZ_32BYTE = 2,
625};
626
627#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
628
629static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
630 {
631 .offset = 0,
632 }, {
633 .offset = 0x20,
634 },
635};
636
637/* USB DMAC0 */
638static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
639 {
640 .slave_id = SHDMA_SLAVE_USB0_TX,
641 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
642 }, {
643 .slave_id = SHDMA_SLAVE_USB0_RX,
644 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
645 },
646};
647
648static struct sh_dmae_pdata usb_dma0_platform_data = {
649 .slave = sh7372_usb_dmae0_slaves,
650 .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
651 .channel = sh7372_usb_dmae_channels,
652 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
653 .ts_low_shift = 6,
654 .ts_low_mask = 0xc0,
655 .ts_high_shift = 0,
656 .ts_high_mask = 0,
657 .ts_shift = usbts_shift,
658 .ts_shift_num = ARRAY_SIZE(usbts_shift),
659 .dmaor_init = DMAOR_DME,
660 .chcr_offset = 0x14,
661 .chcr_ie_bit = 1 << 5,
662 .dmaor_is_32bit = 1,
663 .needs_tend_set = 1,
664 .no_dmars = 1,
Guennadi Liakhovetskic8ddf032012-01-18 10:14:29 +0100665 .slave_only = 1,
Kuninori Morimotoafe48042011-06-17 08:21:10 +0000666};
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,
Guennadi Liakhovetskic8ddf032012-01-18 10:14:29 +0100727 .slave_only = 1,
Kuninori Morimotoafe48042011-06-17 08:21:10 +0000728};
729
730static struct resource sh7372_usb_dmae1_resources[] = {
731 {
732 /* Channel registers and DMAOR */
733 .start = 0xe68c0020,
734 .end = 0xe68c0064 - 1,
735 .flags = IORESOURCE_MEM,
736 },
737 {
738 /* VCR/SWR/DMICR */
739 .start = 0xe68c0000,
740 .end = 0xe68c0014 - 1,
741 .flags = IORESOURCE_MEM,
742 },
743 {
744 /* IRQ for channels */
745 .start = evt2irq(0x1d00),
746 .end = evt2irq(0x1d00),
747 .flags = IORESOURCE_IRQ,
748 },
749};
750
751static struct platform_device usb_dma1_device = {
752 .name = "sh-dma-engine",
753 .id = 4,
754 .resource = sh7372_usb_dmae1_resources,
755 .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
756 .dev = {
757 .platform_data = &usb_dma1_platform_data,
758 },
759};
760
Magnus Damm68224712011-04-28 03:21:00 +0000761/* VPU */
762static struct uio_info vpu_platform_data = {
763 .name = "VPU5HG",
764 .version = "0",
765 .irq = intcs_evt2irq(0x980),
766};
767
768static struct resource vpu_resources[] = {
769 [0] = {
770 .name = "VPU",
771 .start = 0xfe900000,
772 .end = 0xfe900157,
773 .flags = IORESOURCE_MEM,
774 },
775};
776
777static struct platform_device vpu_device = {
778 .name = "uio_pdrv_genirq",
779 .id = 0,
780 .dev = {
781 .platform_data = &vpu_platform_data,
782 },
783 .resource = vpu_resources,
784 .num_resources = ARRAY_SIZE(vpu_resources),
785};
786
787/* VEU0 */
788static struct uio_info veu0_platform_data = {
789 .name = "VEU0",
790 .version = "0",
791 .irq = intcs_evt2irq(0x700),
792};
793
794static struct resource veu0_resources[] = {
795 [0] = {
796 .name = "VEU0",
797 .start = 0xfe920000,
798 .end = 0xfe9200cb,
799 .flags = IORESOURCE_MEM,
800 },
801};
802
803static struct platform_device veu0_device = {
804 .name = "uio_pdrv_genirq",
805 .id = 1,
806 .dev = {
807 .platform_data = &veu0_platform_data,
808 },
809 .resource = veu0_resources,
810 .num_resources = ARRAY_SIZE(veu0_resources),
811};
812
813/* VEU1 */
814static struct uio_info veu1_platform_data = {
815 .name = "VEU1",
816 .version = "0",
817 .irq = intcs_evt2irq(0x720),
818};
819
820static struct resource veu1_resources[] = {
821 [0] = {
822 .name = "VEU1",
823 .start = 0xfe924000,
824 .end = 0xfe9240cb,
825 .flags = IORESOURCE_MEM,
826 },
827};
828
829static struct platform_device veu1_device = {
830 .name = "uio_pdrv_genirq",
831 .id = 2,
832 .dev = {
833 .platform_data = &veu1_platform_data,
834 },
835 .resource = veu1_resources,
836 .num_resources = ARRAY_SIZE(veu1_resources),
837};
838
839/* VEU2 */
840static struct uio_info veu2_platform_data = {
841 .name = "VEU2",
842 .version = "0",
843 .irq = intcs_evt2irq(0x740),
844};
845
846static struct resource veu2_resources[] = {
847 [0] = {
848 .name = "VEU2",
849 .start = 0xfe928000,
850 .end = 0xfe928307,
851 .flags = IORESOURCE_MEM,
852 },
853};
854
855static struct platform_device veu2_device = {
856 .name = "uio_pdrv_genirq",
857 .id = 3,
858 .dev = {
859 .platform_data = &veu2_platform_data,
860 },
861 .resource = veu2_resources,
862 .num_resources = ARRAY_SIZE(veu2_resources),
863};
864
865/* VEU3 */
866static struct uio_info veu3_platform_data = {
867 .name = "VEU3",
868 .version = "0",
869 .irq = intcs_evt2irq(0x760),
870};
871
872static struct resource veu3_resources[] = {
873 [0] = {
874 .name = "VEU3",
875 .start = 0xfe92c000,
876 .end = 0xfe92c307,
877 .flags = IORESOURCE_MEM,
878 },
879};
880
881static struct platform_device veu3_device = {
882 .name = "uio_pdrv_genirq",
883 .id = 4,
884 .dev = {
885 .platform_data = &veu3_platform_data,
886 },
887 .resource = veu3_resources,
888 .num_resources = ARRAY_SIZE(veu3_resources),
889};
890
891/* JPU */
892static struct uio_info jpu_platform_data = {
893 .name = "JPU",
894 .version = "0",
895 .irq = intcs_evt2irq(0x560),
896};
897
898static struct resource jpu_resources[] = {
899 [0] = {
900 .name = "JPU",
901 .start = 0xfe980000,
902 .end = 0xfe9902d3,
903 .flags = IORESOURCE_MEM,
904 },
905};
906
907static struct platform_device jpu_device = {
908 .name = "uio_pdrv_genirq",
909 .id = 5,
910 .dev = {
911 .platform_data = &jpu_platform_data,
912 },
913 .resource = jpu_resources,
914 .num_resources = ARRAY_SIZE(jpu_resources),
915};
916
917/* SPU2DSP0 */
918static struct uio_info spu0_platform_data = {
919 .name = "SPU2DSP0",
920 .version = "0",
921 .irq = evt2irq(0x1800),
922};
923
924static struct resource spu0_resources[] = {
925 [0] = {
926 .name = "SPU2DSP0",
927 .start = 0xfe200000,
928 .end = 0xfe2fffff,
929 .flags = IORESOURCE_MEM,
930 },
931};
932
933static struct platform_device spu0_device = {
934 .name = "uio_pdrv_genirq",
935 .id = 6,
936 .dev = {
937 .platform_data = &spu0_platform_data,
938 },
939 .resource = spu0_resources,
940 .num_resources = ARRAY_SIZE(spu0_resources),
941};
942
943/* SPU2DSP1 */
944static struct uio_info spu1_platform_data = {
945 .name = "SPU2DSP1",
946 .version = "0",
947 .irq = evt2irq(0x1820),
948};
949
950static struct resource spu1_resources[] = {
951 [0] = {
952 .name = "SPU2DSP1",
953 .start = 0xfe300000,
954 .end = 0xfe3fffff,
955 .flags = IORESOURCE_MEM,
956 },
957};
958
959static struct platform_device spu1_device = {
960 .name = "uio_pdrv_genirq",
961 .id = 7,
962 .dev = {
963 .platform_data = &spu1_platform_data,
964 },
965 .resource = spu1_resources,
966 .num_resources = ARRAY_SIZE(spu1_resources),
967};
968
Magnus Damm2b7eda62010-02-05 11:14:58 +0000969static struct platform_device *sh7372_early_devices[] __initdata = {
970 &scif0_device,
971 &scif1_device,
972 &scif2_device,
973 &scif3_device,
974 &scif4_device,
975 &scif5_device,
976 &scif6_device,
Magnus Damm0ed61fc2011-06-30 09:22:50 +0000977 &cmt2_device,
Magnus Dammc6c049e2010-10-14 06:57:25 +0000978 &tmu00_device,
979 &tmu01_device,
Magnus Damm934e4072010-10-13 07:22:11 +0000980};
981
982static struct platform_device *sh7372_late_devices[] __initdata = {
Kuninori Morimotoc1909cc2010-03-11 10:42:47 +0000983 &iic0_device,
984 &iic1_device,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000985 &dma0_device,
986 &dma1_device,
987 &dma2_device,
Kuninori Morimotoafe48042011-06-17 08:21:10 +0000988 &usb_dma0_device,
989 &usb_dma1_device,
Magnus Damm68224712011-04-28 03:21:00 +0000990 &vpu_device,
991 &veu0_device,
992 &veu1_device,
993 &veu2_device,
994 &veu3_device,
995 &jpu_device,
996 &spu0_device,
997 &spu1_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000998};
999
1000void __init sh7372_add_standard_devices(void)
1001{
Magnus Damm96f79342011-07-01 22:14:34 +02001002 sh7372_init_pm_domain(&sh7372_a4lc);
Kuninori Morimotoc1ba5bb2011-07-10 10:12:08 +02001003 sh7372_init_pm_domain(&sh7372_a4mp);
Magnus Dammd24771d2011-07-10 10:38:22 +02001004 sh7372_init_pm_domain(&sh7372_d4);
Magnus Damm382414b2011-10-19 23:52:50 +02001005 sh7372_init_pm_domain(&sh7372_a4r);
Magnus Damm33afebf2011-07-01 22:14:45 +02001006 sh7372_init_pm_domain(&sh7372_a3rv);
Magnus Damm082517a2011-07-01 22:14:53 +02001007 sh7372_init_pm_domain(&sh7372_a3ri);
Magnus Dammf7dadb32011-12-23 01:23:07 +01001008 sh7372_init_pm_domain(&sh7372_a4s);
Magnus Dammd93f5cd2011-10-19 23:52:41 +02001009 sh7372_init_pm_domain(&sh7372_a3sp);
Magnus Dammf7dadb32011-12-23 01:23:07 +01001010 sh7372_init_pm_domain(&sh7372_a3sg);
Magnus Damm96f79342011-07-01 22:14:34 +02001011
Rafael J. Wysocki111058c2011-08-14 13:35:39 +02001012 sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
Magnus Damm382414b2011-10-19 23:52:50 +02001013 sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc);
Rafael J. Wysocki111058c2011-08-14 13:35:39 +02001014
Magnus Dammf7dadb32011-12-23 01:23:07 +01001015 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sg);
1016 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sp);
1017
Magnus Damm2b7eda62010-02-05 11:14:58 +00001018 platform_add_devices(sh7372_early_devices,
1019 ARRAY_SIZE(sh7372_early_devices));
Magnus Damm934e4072010-10-13 07:22:11 +00001020
1021 platform_add_devices(sh7372_late_devices,
1022 ARRAY_SIZE(sh7372_late_devices));
Magnus Damm33afebf2011-07-01 22:14:45 +02001023
1024 sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
Kuninori Morimotoc1ba5bb2011-07-10 10:12:08 +02001025 sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
1026 sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
Magnus Dammd93f5cd2011-10-19 23:52:41 +02001027 sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
1028 sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
1029 sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
1030 sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
1031 sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
1032 sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
1033 sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
1034 sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
1035 sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
1036 sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
1037 sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
1038 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device);
1039 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device);
Magnus Damm382414b2011-10-19 23:52:50 +02001040 sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device);
1041 sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device);
1042 sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device);
1043 sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device);
1044 sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device);
1045 sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device);
Magnus Damm2b7eda62010-02-05 11:14:58 +00001046}
1047
Magnus Damm2b7eda62010-02-05 11:14:58 +00001048void __init sh7372_add_early_devices(void)
1049{
Magnus Damm2b7eda62010-02-05 11:14:58 +00001050 early_platform_add_devices(sh7372_early_devices,
1051 ARRAY_SIZE(sh7372_early_devices));
1052}