aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2012-06-25 06:37:10 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-06-30 09:07:31 -0400
commitdbf382e556931aa75b2d7970d64661544d6c327c (patch)
tree1a200fda74b220a7cc37b8620f017355605d3970 /arch/arm
parentcb76eb812ee03187da3b46e190895b55019d2133 (diff)
ARM: shmobile: r8a7740: add DMAEngine support for USB
Current shdmac can support USB DMAC on r8a7740. This support reduce CPU duty when USB access. 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')
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7740.c4
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7740.h2
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7740.c87
3 files changed, 92 insertions, 1 deletions
diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c
index 39b131101167..daf3eace5dcf 100644
--- a/arch/arm/mach-shmobile/clock-r8a7740.c
+++ b/arch/arm/mach-shmobile/clock-r8a7740.c
@@ -463,7 +463,7 @@ enum {
463 463
464 MSTP230, 464 MSTP230,
465 MSTP222, 465 MSTP222,
466 MSTP218, MSTP217, MSTP216, 466 MSTP218, MSTP217, MSTP216, MSTP214,
467 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 467 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
468 468
469 MSTP329, MSTP328, MSTP323, MSTP320, 469 MSTP329, MSTP328, MSTP323, MSTP320,
@@ -489,6 +489,7 @@ static struct clk mstp_clks[MSTP_NR] = {
489 [MSTP218] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */ 489 [MSTP218] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */
490 [MSTP217] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */ 490 [MSTP217] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */
491 [MSTP216] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 16, 0), /* DMAC3 */ 491 [MSTP216] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 16, 0), /* DMAC3 */
492 [MSTP214] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 14, 0), /* USBDMAC */
492 [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 493 [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
493 [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 494 [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
494 [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */ 495 [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */
@@ -567,6 +568,7 @@ static struct clk_lookup lookups[] = {
567 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), 568 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
568 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), 569 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]),
569 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), 570 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]),
571 CLKDEV_DEV_ID("sh-dma-engine.3", &mstp_clks[MSTP214]),
570 CLKDEV_DEV_ID("sh-dma-engine.2", &mstp_clks[MSTP216]), 572 CLKDEV_DEV_ID("sh-dma-engine.2", &mstp_clks[MSTP216]),
571 CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]), 573 CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]),
572 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), 574 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]),
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7740.h b/arch/arm/mach-shmobile/include/mach/r8a7740.h
index 0f14ce8d9f01..8bd7b9c136a1 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7740.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7740.h
@@ -600,6 +600,8 @@ enum {
600 SHDMA_SLAVE_FSIA_RX, 600 SHDMA_SLAVE_FSIA_RX,
601 SHDMA_SLAVE_FSIA_TX, 601 SHDMA_SLAVE_FSIA_TX,
602 SHDMA_SLAVE_FSIB_TX, 602 SHDMA_SLAVE_FSIB_TX,
603 SHDMA_SLAVE_USBHS_TX,
604 SHDMA_SLAVE_USBHS_RX,
603}; 605};
604 606
605#endif /* __ASM_R8A7740_H__ */ 607#endif /* __ASM_R8A7740_H__ */
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index 320c43af8614..5e84609e82d2 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -501,6 +501,92 @@ static struct platform_device dma2_device = {
501 }, 501 },
502}; 502};
503 503
504/* USB-DMAC */
505/* Transmit sizes and respective CHCR register values */
506enum {
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 */
513static 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
519static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
520 {
521 .offset = 0,
522 }, {
523 .offset = 0x20,
524 },
525};
526
527#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
528
529static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
530 {
531 .slave_id = SHDMA_SLAVE_USBHS_TX,
532 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
533 }, {
534 .slave_id = SHDMA_SLAVE_USBHS_RX,
535 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
536 },
537};
538
539static struct sh_dmae_pdata usb_dma_platform_data = {
540 .slave = r8a7740_usb_dma_slaves,
541 .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
542 .channel = r8a7740_usb_dma_channels,
543 .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
544 .ts_low_shift = 6,
545 .ts_low_mask = 0xc0,
546 .ts_high_shift = 0,
547 .ts_high_mask = 0,
548 .ts_shift = dma_usbts_shift,
549 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
550 .dmaor_init = DMAOR_DME,
551 .chcr_offset = 0x14,
552 .chcr_ie_bit = 1 << 5,
553 .dmaor_is_32bit = 1,
554 .needs_tend_set = 1,
555 .no_dmars = 1,
556 .slave_only = 1,
557};
558
559static struct resource r8a7740_usb_dma_resources[] = {
560 {
561 /* Channel registers and DMAOR */
562 .start = 0xe68a0020,
563 .end = 0xe68a0064 - 1,
564 .flags = IORESOURCE_MEM,
565 },
566 {
567 /* VCR/SWR/DMICR */
568 .start = 0xe68a0000,
569 .end = 0xe68a0014 - 1,
570 .flags = IORESOURCE_MEM,
571 },
572 {
573 /* IRQ for channels */
574 .start = evt2irq(0x0a00),
575 .end = evt2irq(0x0a00),
576 .flags = IORESOURCE_IRQ,
577 },
578};
579
580static struct platform_device usb_dma_device = {
581 .name = "sh-dma-engine",
582 .id = 3,
583 .resource = r8a7740_usb_dma_resources,
584 .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
585 .dev = {
586 .platform_data = &usb_dma_platform_data,
587 },
588};
589
504/* I2C */ 590/* I2C */
505static struct resource i2c0_resources[] = { 591static struct resource i2c0_resources[] = {
506 [0] = { 592 [0] = {
@@ -550,6 +636,7 @@ static struct platform_device *r8a7740_late_devices[] __initdata = {
550 &dma0_device, 636 &dma0_device,
551 &dma1_device, 637 &dma1_device,
552 &dma2_device, 638 &dma2_device,
639 &usb_dma_device,
553}; 640};
554 641
555/* 642/*