aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2010-05-04 10:07:15 -0400
committerPaul Mundt <lethal@linux-sh.org>2010-05-31 00:18:51 -0400
commit69bf6f451febe8dd07ccedf0ba3279c0f3f7fc3a (patch)
treeb3ff66a5903c7ebc7a281d2870693aef8ec952fb /arch/arm
parentd5b732b17ca2fc74f370bdba5aae6c804fac8c35 (diff)
ARM: add DMA support to sh7372, enable DMA for SDHI
This adds DMA support for the sh7372 sh-mobile ARM core, using the shdma dmaengine driver, and uses DMA for the SDHI SD-card controller on this SoC. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c9
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh7372.h10
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c223
3 files changed, 242 insertions, 0 deletions
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 353ff8d120b1..5c41b958e022 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -24,6 +24,7 @@
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/mfd/sh_mobile_sdhi.h>
27#include <linux/mtd/mtd.h> 28#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
29#include <linux/mtd/physmap.h> 30#include <linux/mtd/physmap.h>
@@ -231,6 +232,11 @@ static struct platform_device keysc_device = {
231}; 232};
232 233
233/* SDHI0 */ 234/* SDHI0 */
235static struct sh_mobile_sdhi_info sdhi0_info = {
236 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
237 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
238};
239
234static struct resource sdhi0_resources[] = { 240static struct resource sdhi0_resources[] = {
235 [0] = { 241 [0] = {
236 .name = "SDHI0", 242 .name = "SDHI0",
@@ -249,6 +255,9 @@ static struct platform_device sdhi0_device = {
249 .num_resources = ARRAY_SIZE(sdhi0_resources), 255 .num_resources = ARRAY_SIZE(sdhi0_resources),
250 .resource = sdhi0_resources, 256 .resource = sdhi0_resources,
251 .id = 0, 257 .id = 0,
258 .dev = {
259 .platform_data = &sdhi0_info,
260 },
252}; 261};
253 262
254/* USB1 */ 263/* USB1 */
diff --git a/arch/arm/mach-shmobile/include/mach/sh7372.h b/arch/arm/mach-shmobile/include/mach/sh7372.h
index dc34f00c56b8..57e033a1e529 100644
--- a/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ b/arch/arm/mach-shmobile/include/mach/sh7372.h
@@ -431,4 +431,14 @@ enum {
431 GPIO_FN_SDENC_DV_CLKI, 431 GPIO_FN_SDENC_DV_CLKI,
432}; 432};
433 433
434/* DMA slave IDs */
435enum {
436 SHDMA_SLAVE_SDHI0_RX,
437 SHDMA_SLAVE_SDHI0_TX,
438 SHDMA_SLAVE_SDHI1_RX,
439 SHDMA_SLAVE_SDHI1_TX,
440 SHDMA_SLAVE_SDHI2_RX,
441 SHDMA_SLAVE_SDHI2_TX,
442};
443
434#endif /* __ASM_SH7372_H__ */ 444#endif /* __ASM_SH7372_H__ */
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index d1a8095a19eb..bf6974b4afd0 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -26,9 +26,11 @@
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/serial_sci.h> 28#include <linux/serial_sci.h>
29#include <linux/sh_dma.h>
29#include <linux/sh_intc.h> 30#include <linux/sh_intc.h>
30#include <linux/sh_timer.h> 31#include <linux/sh_timer.h>
31#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/sh7372.h>
32#include <asm/mach-types.h> 34#include <asm/mach-types.h>
33#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
34 36
@@ -227,6 +229,224 @@ static struct platform_device iic1_device = {
227 .resource = iic1_resources, 229 .resource = iic1_resources,
228}; 230};
229 231
232/* DMA */
233/* Transmit sizes and respective CHCR register values */
234enum {
235 XMIT_SZ_8BIT = 0,
236 XMIT_SZ_16BIT = 1,
237 XMIT_SZ_32BIT = 2,
238 XMIT_SZ_64BIT = 7,
239 XMIT_SZ_128BIT = 3,
240 XMIT_SZ_256BIT = 4,
241 XMIT_SZ_512BIT = 5,
242};
243
244/* log2(size / 8) - used to calculate number of transfers */
245#define TS_SHIFT { \
246 [XMIT_SZ_8BIT] = 0, \
247 [XMIT_SZ_16BIT] = 1, \
248 [XMIT_SZ_32BIT] = 2, \
249 [XMIT_SZ_64BIT] = 3, \
250 [XMIT_SZ_128BIT] = 4, \
251 [XMIT_SZ_256BIT] = 5, \
252 [XMIT_SZ_512BIT] = 6, \
253}
254
255#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
256 (((i) & 0xc) << (20 - 2)))
257
258static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
259 {
260 .slave_id = SHDMA_SLAVE_SDHI0_TX,
261 .addr = 0xe6850030,
262 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
263 .mid_rid = 0xc1,
264 }, {
265 .slave_id = SHDMA_SLAVE_SDHI0_RX,
266 .addr = 0xe6850030,
267 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
268 .mid_rid = 0xc2,
269 }, {
270 .slave_id = SHDMA_SLAVE_SDHI1_TX,
271 .addr = 0xe6860030,
272 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
273 .mid_rid = 0xc9,
274 }, {
275 .slave_id = SHDMA_SLAVE_SDHI1_RX,
276 .addr = 0xe6860030,
277 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
278 .mid_rid = 0xca,
279 }, {
280 .slave_id = SHDMA_SLAVE_SDHI2_TX,
281 .addr = 0xe6870030,
282 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
283 .mid_rid = 0xcd,
284 }, {
285 .slave_id = SHDMA_SLAVE_SDHI2_RX,
286 .addr = 0xe6870030,
287 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
288 .mid_rid = 0xce,
289 },
290};
291
292static const struct sh_dmae_channel sh7372_dmae_channels[] = {
293 {
294 .offset = 0,
295 .dmars = 0,
296 .dmars_bit = 0,
297 }, {
298 .offset = 0x10,
299 .dmars = 0,
300 .dmars_bit = 8,
301 }, {
302 .offset = 0x20,
303 .dmars = 4,
304 .dmars_bit = 0,
305 }, {
306 .offset = 0x30,
307 .dmars = 4,
308 .dmars_bit = 8,
309 }, {
310 .offset = 0x50,
311 .dmars = 8,
312 .dmars_bit = 0,
313 }, {
314 .offset = 0x60,
315 .dmars = 8,
316 .dmars_bit = 8,
317 }
318};
319
320static const unsigned int ts_shift[] = TS_SHIFT;
321
322static struct sh_dmae_pdata dma_platform_data = {
323 .slave = sh7372_dmae_slaves,
324 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
325 .channel = sh7372_dmae_channels,
326 .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
327 .ts_low_shift = 3,
328 .ts_low_mask = 0x18,
329 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */
330 .ts_high_mask = 0x00300000,
331 .ts_shift = ts_shift,
332 .ts_shift_num = ARRAY_SIZE(ts_shift),
333 .dmaor_init = DMAOR_DME,
334};
335
336/* Resource order important! */
337static struct resource sh7372_dmae0_resources[] = {
338 {
339 /* Channel registers and DMAOR */
340 .start = 0xfe008020,
341 .end = 0xfe00808f,
342 .flags = IORESOURCE_MEM,
343 },
344 {
345 /* DMARSx */
346 .start = 0xfe009000,
347 .end = 0xfe00900b,
348 .flags = IORESOURCE_MEM,
349 },
350 {
351 /* DMA error IRQ */
352 .start = 246,
353 .end = 246,
354 .flags = IORESOURCE_IRQ,
355 },
356 {
357 /* IRQ for channels 0-5 */
358 .start = 240,
359 .end = 245,
360 .flags = IORESOURCE_IRQ,
361 },
362};
363
364/* Resource order important! */
365static struct resource sh7372_dmae1_resources[] = {
366 {
367 /* Channel registers and DMAOR */
368 .start = 0xfe018020,
369 .end = 0xfe01808f,
370 .flags = IORESOURCE_MEM,
371 },
372 {
373 /* DMARSx */
374 .start = 0xfe019000,
375 .end = 0xfe01900b,
376 .flags = IORESOURCE_MEM,
377 },
378 {
379 /* DMA error IRQ */
380 .start = 254,
381 .end = 254,
382 .flags = IORESOURCE_IRQ,
383 },
384 {
385 /* IRQ for channels 0-5 */
386 .start = 248,
387 .end = 253,
388 .flags = IORESOURCE_IRQ,
389 },
390};
391
392/* Resource order important! */
393static struct resource sh7372_dmae2_resources[] = {
394 {
395 /* Channel registers and DMAOR */
396 .start = 0xfe028020,
397 .end = 0xfe02808f,
398 .flags = IORESOURCE_MEM,
399 },
400 {
401 /* DMARSx */
402 .start = 0xfe029000,
403 .end = 0xfe02900b,
404 .flags = IORESOURCE_MEM,
405 },
406 {
407 /* DMA error IRQ */
408 .start = 262,
409 .end = 262,
410 .flags = IORESOURCE_IRQ,
411 },
412 {
413 /* IRQ for channels 0-5 */
414 .start = 256,
415 .end = 261,
416 .flags = IORESOURCE_IRQ,
417 },
418};
419
420static struct platform_device dma0_device = {
421 .name = "sh-dma-engine",
422 .id = 0,
423 .resource = sh7372_dmae0_resources,
424 .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
425 .dev = {
426 .platform_data = &dma_platform_data,
427 },
428};
429
430static struct platform_device dma1_device = {
431 .name = "sh-dma-engine",
432 .id = 1,
433 .resource = sh7372_dmae1_resources,
434 .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
435 .dev = {
436 .platform_data = &dma_platform_data,
437 },
438};
439
440static struct platform_device dma2_device = {
441 .name = "sh-dma-engine",
442 .id = 2,
443 .resource = sh7372_dmae2_resources,
444 .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
445 .dev = {
446 .platform_data = &dma_platform_data,
447 },
448};
449
230static struct platform_device *sh7372_early_devices[] __initdata = { 450static struct platform_device *sh7372_early_devices[] __initdata = {
231 &scif0_device, 451 &scif0_device,
232 &scif1_device, 452 &scif1_device,
@@ -238,6 +458,9 @@ static struct platform_device *sh7372_early_devices[] __initdata = {
238 &cmt10_device, 458 &cmt10_device,
239 &iic0_device, 459 &iic0_device,
240 &iic1_device, 460 &iic1_device,
461 &dma0_device,
462 &dma1_device,
463 &dma2_device,
241}; 464};
242 465
243void __init sh7372_add_standard_devices(void) 466void __init sh7372_add_standard_devices(void)