diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2012-06-25 06:43:10 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-06-30 09:07:31 -0400 |
commit | d7de938f3da618b1592427f625e150c0a68b9ecb (patch) | |
tree | 91993154c7fcb463ee9f8779eaa31232c6db8ba7 /arch/arm/mach-shmobile/setup-r8a7740.c | |
parent | dbf382e556931aa75b2d7970d64661544d6c327c (diff) |
ARM: shmobile: use common DMAEngine definitions on r8a7740
This patch switch over to use common DMAEngine definitions,
and reduced a waste of code.
It is easy to understand if sh_dmae_pdata / sh_dmae_slave_config
settings are used defined value instead of direct value.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'arch/arm/mach-shmobile/setup-r8a7740.c')
-rw-r--r-- | arch/arm/mach-shmobile/setup-r8a7740.c | 64 |
1 files changed, 11 insertions, 53 deletions
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c index 5e84609e82d2..48d7bbf0d2e2 100644 --- a/arch/arm/mach-shmobile/setup-r8a7740.c +++ b/arch/arm/mach-shmobile/setup-r8a7740.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/sh_dma.h> | 27 | #include <linux/sh_dma.h> |
28 | #include <linux/sh_timer.h> | 28 | #include <linux/sh_timer.h> |
29 | #include <linux/dma-mapping.h> | 29 | #include <linux/dma-mapping.h> |
30 | #include <mach/dma-register.h> | ||
30 | #include <mach/r8a7740.h> | 31 | #include <mach/r8a7740.h> |
31 | #include <mach/common.h> | 32 | #include <mach/common.h> |
32 | #include <mach/irqs.h> | 33 | #include <mach/irqs.h> |
@@ -279,31 +280,6 @@ static struct platform_device *r8a7740_early_devices[] __initdata = { | |||
279 | }; | 280 | }; |
280 | 281 | ||
281 | /* DMA */ | 282 | /* DMA */ |
282 | enum { | ||
283 | XMIT_SZ_8BIT = 0, | ||
284 | XMIT_SZ_16BIT = 1, | ||
285 | XMIT_SZ_32BIT = 2, | ||
286 | XMIT_SZ_64BIT = 7, | ||
287 | XMIT_SZ_128BIT = 3, | ||
288 | XMIT_SZ_256BIT = 4, | ||
289 | XMIT_SZ_512BIT = 5, | ||
290 | }; | ||
291 | |||
292 | /* log2(size / 8) - used to calculate number of transfers */ | ||
293 | #define TS_SHIFT { \ | ||
294 | [XMIT_SZ_8BIT] = 0, \ | ||
295 | [XMIT_SZ_16BIT] = 1, \ | ||
296 | [XMIT_SZ_32BIT] = 2, \ | ||
297 | [XMIT_SZ_64BIT] = 3, \ | ||
298 | [XMIT_SZ_128BIT] = 4, \ | ||
299 | [XMIT_SZ_256BIT] = 5, \ | ||
300 | [XMIT_SZ_512BIT] = 6, \ | ||
301 | } | ||
302 | |||
303 | #define TS_INDEX2VAL(i) ((((i) & 0x3) << 3) | (((i) & 0xc) << (20 - 2))) | ||
304 | #define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz))) | ||
305 | #define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz))) | ||
306 | |||
307 | static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = { | 283 | static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = { |
308 | { | 284 | { |
309 | .slave_id = SHDMA_SLAVE_SDHI0_TX, | 285 | .slave_id = SHDMA_SLAVE_SDHI0_TX, |
@@ -370,19 +346,17 @@ static const struct sh_dmae_channel r8a7740_dmae_channels[] = { | |||
370 | DMA_CHANNEL(0x60, 8, 8), | 346 | DMA_CHANNEL(0x60, 8, 8), |
371 | }; | 347 | }; |
372 | 348 | ||
373 | static const unsigned int ts_shift[] = TS_SHIFT; | ||
374 | |||
375 | static struct sh_dmae_pdata dma_platform_data = { | 349 | static struct sh_dmae_pdata dma_platform_data = { |
376 | .slave = r8a7740_dmae_slaves, | 350 | .slave = r8a7740_dmae_slaves, |
377 | .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves), | 351 | .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves), |
378 | .channel = r8a7740_dmae_channels, | 352 | .channel = r8a7740_dmae_channels, |
379 | .channel_num = ARRAY_SIZE(r8a7740_dmae_channels), | 353 | .channel_num = ARRAY_SIZE(r8a7740_dmae_channels), |
380 | .ts_low_shift = 3, | 354 | .ts_low_shift = TS_LOW_SHIFT, |
381 | .ts_low_mask = 0x18, | 355 | .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT, |
382 | .ts_high_shift = (20 - 2), | 356 | .ts_high_shift = TS_HI_SHIFT, |
383 | .ts_high_mask = 0x00300000, | 357 | .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT, |
384 | .ts_shift = ts_shift, | 358 | .ts_shift = dma_ts_shift, |
385 | .ts_shift_num = ARRAY_SIZE(ts_shift), | 359 | .ts_shift_num = ARRAY_SIZE(dma_ts_shift), |
386 | .dmaor_init = DMAOR_DME, | 360 | .dmaor_init = DMAOR_DME, |
387 | .chclr_present = 1, | 361 | .chclr_present = 1, |
388 | }; | 362 | }; |
@@ -502,20 +476,6 @@ static struct platform_device dma2_device = { | |||
502 | }; | 476 | }; |
503 | 477 | ||
504 | /* USB-DMAC */ | 478 | /* USB-DMAC */ |
505 | /* Transmit sizes and respective CHCR register values */ | ||
506 | enum { | ||
507 | USBTS_XMIT_SZ_8BYTE = 0, | ||
508 | USBTS_XMIT_SZ_16BYTE = 1, | ||
509 | USBTS_XMIT_SZ_32BYTE = 2, | ||
510 | }; | ||
511 | |||
512 | /* log2(size / 8) - used to calculate number of transfers */ | ||
513 | static const unsigned int dma_usbts_shift[] = { | ||
514 | [USBTS_XMIT_SZ_8BYTE] = 3, | ||
515 | [USBTS_XMIT_SZ_16BYTE] = 4, | ||
516 | [USBTS_XMIT_SZ_32BYTE] = 5, | ||
517 | }; | ||
518 | |||
519 | static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = { | 479 | static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = { |
520 | { | 480 | { |
521 | .offset = 0, | 481 | .offset = 0, |
@@ -524,8 +484,6 @@ static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = { | |||
524 | }, | 484 | }, |
525 | }; | 485 | }; |
526 | 486 | ||
527 | #define USBTS_INDEX2VAL(i) (((i) & 3) << 6) | ||
528 | |||
529 | static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = { | 487 | static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = { |
530 | { | 488 | { |
531 | .slave_id = SHDMA_SLAVE_USBHS_TX, | 489 | .slave_id = SHDMA_SLAVE_USBHS_TX, |
@@ -541,10 +499,10 @@ static struct sh_dmae_pdata usb_dma_platform_data = { | |||
541 | .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves), | 499 | .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves), |
542 | .channel = r8a7740_usb_dma_channels, | 500 | .channel = r8a7740_usb_dma_channels, |
543 | .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels), | 501 | .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels), |
544 | .ts_low_shift = 6, | 502 | .ts_low_shift = USBTS_LOW_SHIFT, |
545 | .ts_low_mask = 0xc0, | 503 | .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT, |
546 | .ts_high_shift = 0, | 504 | .ts_high_shift = USBTS_HI_SHIFT, |
547 | .ts_high_mask = 0, | 505 | .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT, |
548 | .ts_shift = dma_usbts_shift, | 506 | .ts_shift = dma_usbts_shift, |
549 | .ts_shift_num = ARRAY_SIZE(dma_usbts_shift), | 507 | .ts_shift_num = ARRAY_SIZE(dma_usbts_shift), |
550 | .dmaor_init = DMAOR_DME, | 508 | .dmaor_init = DMAOR_DME, |