Skip to contentSkip to conversation

R8A7778/BOCK-W: HPB-DMAC support for SDHI0

PATCH Superseded Sergei Shtylyov 3 participants 9 messages Jul 22, 2013 – Jul 30, 2013

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover R8A7778/BOCK-W: HPB-DMAC support for SDHI0

Hello.

Here's the set of 3 patches against the Simon Horman's 'renesas.git' repo,
'renesas-next-20130722' tag. Here we add the HPB-DMAC platform code working on the R8A7778 and enable DMA for SDHI0 on BOCK-W. The patchset depends on the R-Car HPB-DMAC driver patch posted earlier.

[1/2] ARM: shmobile: r8a7778: add HPB-DMAC support [2/2] ARM: shmobile: BOCK-W: enable DMA for SDHI0

The former patch #1 has been merged to the next patch moving the data from
the now removed <mach/dma.h> to <mach/r8a7778.h>.

WBR, Sergei

#1 lore raw

PATCH v2 1/2 ARM: shmobile: r8a7778: add HPB-DMAC support

From: Max Filippov <[email protected]>

Add HPB-DMAC platform device on R8A7778 SoC along with its slave and channel configurations.

[Sergei: moved *enum* declaring HPB-DMAC slave IDs from now removed <mach/dma.h> to <mach/r8a7778.h>, removed #include <mach/dma.h> from setup-r8a7778.c, removed SSI-related *enum* values and SSI-related data from hpb_dmae_slaves[] and hpb_dmae_channels[].]

---
Changes in version 2:
- moved *enum* declaring HPB-DMAC slave IDs from the separate header file to <mach/r8a7778.h>, removed #include <mach/dma.h> from setup-r8a7778.c;
- removed SSI-related *enum* values and SSI-related data from hpb_dmae_slaves[] and hpb_dmae_channels[].

 arch/arm/mach-shmobile/include/mach/r8a7778.h |    8 ++
 arch/arm/mach-shmobile/setup-r8a7778.c        |   80 ++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
arch/arm/mach-shmobile/include/mach/r8a7778.h +8 -0
Index: renesas/arch/arm/mach-shmobile/include/mach/r8a7778.h
===================================================================
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2013  Renesas Solutions Corp.
  * Copyright (C) 2013  Kuninori Morimoto <[email protected]>
+ * Copyright (C) 2013  Cogent Embedded, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +24,13 @@
 #include <linux/sh_eth.h>
 #include <linux/platform_data/usb-rcar-phy.h>
 
+/* HPB-DMA slave IDs */
+enum {
+	HPBDMA_SLAVE_DUMMY,
+	HPBDMA_SLAVE_SDHI0_TX,
+	HPBDMA_SLAVE_SDHI0_RX,
+};
+
 extern void r8a7778_add_standard_devices(void);
 extern void r8a7778_add_standard_devices_dt(void);
 extern void r8a7778_add_ether_device(struct sh_eth_plat_data *pdata);
arch/arm/mach-shmobile/setup-r8a7778.c +80 -0

98 lines not on this page · raw message

#2 lore raw

PATCH v2 1/2 ARM: shmobile: r8a7778: add HPB-DMAC support

[ Cc Morimoto-san ]

Quoted 19 lines · Sergei Shtylyov

From: Max Filippov <[email protected]>

Add HPB-DMAC platform device on R8A7778 SoC along with its slave and channel configurations.

[Sergei: moved *enum* declaring HPB-DMAC slave IDs from now removed <mach/dma.h> to <mach/r8a7778.h>, removed #include <mach/dma.h> from setup-r8a7778.c, removed SSI-related *enum* values and SSI-related data from hpb_dmae_slaves[] and hpb_dmae_channels[].]

---
Changes in version 2:
- moved *enum* declaring HPB-DMAC slave IDs from the separate header file to <mach/r8a7778.h>, removed #include <mach/dma.h> from setup-r8a7778.c;
- removed SSI-related *enum* values and SSI-related data from hpb_dmae_slaves[] and hpb_dmae_channels[].

Quoted 3 lines
 arch/arm/mach-shmobile/include/mach/r8a7778.h |    8 ++
 arch/arm/mach-shmobile/setup-r8a7778.c        |   80 ++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)

Morimoto-san, Magnus,

could you please review this?

Quoted 133 lines

Index: renesas/arch/arm/mach-shmobile/include/mach/r8a7778.h
===================================================================

arch/arm/mach-shmobile/include/mach/r8a7778.h +8 -0
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2013  Renesas Solutions Corp.
  * Copyright (C) 2013  Kuninori Morimoto <[email protected]>
+ * Copyright (C) 2013  Cogent Embedded, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +24,13 @@
 #include <linux/sh_eth.h>
 #include <linux/platform_data/usb-rcar-phy.h>
 
+/* HPB-DMA slave IDs */
+enum {
+	HPBDMA_SLAVE_DUMMY,
+	HPBDMA_SLAVE_SDHI0_TX,
+	HPBDMA_SLAVE_SDHI0_RX,
+};
+
 extern void r8a7778_add_standard_devices(void);
 extern void r8a7778_add_standard_devices_dt(void);
 extern void r8a7778_add_ether_device(struct sh_eth_plat_data *pdata);

Index: renesas/arch/arm/mach-shmobile/setup-r8a7778.c
===================================================================

arch/arm/mach-shmobile/setup-r8a7778.c +80 -0
@@ -24,6 +24,7 @@
 #include <linux/irqchip/arm-gic.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/platform_data/dma-rcar-hpbdma.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_data/irq-renesas-intc-irqpin.h>
 #include <linux/platform_device.h>
@@ -333,6 +334,84 @@ void __init r8a7778_add_mmc_device(struc
 		info, sizeof(*info));
 }
 
+/* HPB-DMA */
+
+/* Asynchronous mode register (ASYNCMDR) bits */
+#define	ASYNCMDR_ASMD22_MASK	BIT(2)	/* SDHI0 */
+#define	ASYNCMDR_ASMD22_SINGLE	BIT(2)	/* SDHI0 */
+#define	ASYNCMDR_ASMD22_MULTI	0	/* SDHI0 */
+#define	ASYNCMDR_ASMD21_MASK	BIT(1)	/* SDHI0 */
+#define	ASYNCMDR_ASMD21_SINGLE	BIT(1)	/* SDHI0 */
+#define	ASYNCMDR_ASMD21_MULTI	0	/* SDHI0 */
+
+static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = {
+	{
+		.id	= HPBDMA_SLAVE_SDHI0_TX,
+		.addr	= 0xffe4c000 + 0x30,
+		.dcr	= DCR_SPDS_16BIT | DCR_DMDL | DCR_DPDS_16BIT,
+		.rstr	= ASYNCRSTR_ASRST21 | ASYNCRSTR_ASRST22 |
+			  ASYNCRSTR_ASRST23,
+		.mdr	= ASYNCMDR_ASMD21_SINGLE,
+		.mdm	= ASYNCMDR_ASMD21_MASK,
+		.port	= 0x0D0C,
+		.flags	= HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
+		.dma_ch	= 21,
+	}, {
+		.id	= HPBDMA_SLAVE_SDHI0_RX,
+		.addr	= 0xffe4c000 + 0x30,
+		.dcr	= DCR_SMDL | DCR_SPDS_16BIT | DCR_DPDS_16BIT,
+		.rstr	= ASYNCRSTR_ASRST21 | ASYNCRSTR_ASRST22 |
+			  ASYNCRSTR_ASRST23,
+		.mdr	= ASYNCMDR_ASMD22_SINGLE,
+		.mdm	= ASYNCMDR_ASMD22_MASK,
+		.port	= 0x0D0C,
+		.flags	= HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
+		.dma_ch	= 22,
+	},
+};
+
+static const struct hpb_dmae_channel hpb_dmae_channels[] = {
+	/* ch. 21 SD0 */
+	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX),
+	/* ch. 22 SD0 */
+	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX),
+};
+
+static struct hpb_dmae_pdata dma_platform_data __initdata = {
+	.slaves			= hpb_dmae_slaves,
+	.num_slaves		= ARRAY_SIZE(hpb_dmae_slaves),
+	.channels		= hpb_dmae_channels,
+	.num_channels		= ARRAY_SIZE(hpb_dmae_channels),
+	.ts_shift		= {
+		[XMIT_SZ_8BIT]	= 0,
+		[XMIT_SZ_16BIT]	= 1,
+		[XMIT_SZ_32BIT]	= 2,
+	},
+	.num_hw_channels	= 39,
+};
+
+static struct resource hpb_dmae_resources[] __initdata = {
+	/* Channel registers */
+	DEFINE_RES_MEM(0xffc08000, 0x1000),
+	/* Common registers */
+	DEFINE_RES_MEM(0xffc09000, 0x170),
+	/* Asynchronous reset registers */
+	DEFINE_RES_MEM(0xffc00300, 4),
+	/* Asynchronous mode registers */
+	DEFINE_RES_MEM(0xffc00400, 4),
+	/* IRQ for DMA channels */
+	DEFINE_RES_NAMED(gic_iid(0x7b), 5, NULL, IORESOURCE_IRQ),
+};
+
+static void __init r8a7778_register_hpb_dmae(void)
+{
+	platform_device_register_resndata(&platform_bus, "hpb-dma-engine", -1,
+					  hpb_dmae_resources,
+					  ARRAY_SIZE(hpb_dmae_resources),
+					  &dma_platform_data,
+					  sizeof(dma_platform_data));
+}
+
 void __init r8a7778_add_standard_devices(void)
 {
 	int i;
@@ -355,6 +434,7 @@ void __init r8a7778_add_standard_devices
 
 	r8a7778_register_tmu(0);
 	r8a7778_register_tmu(1);
+	r8a7778_register_hpb_dmae();
 }
 
 void __init r8a7778_init_late(void)
#3 lore raw

PATCH v2 1/2 ARM: shmobile: r8a7778: add HPB-DMAC support

Hi

Quoted 16 lines
Quoted 16 lines
arch/arm/mach-shmobile/setup-r8a7778.c +16 -0
+static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = {
+	{
+		.id	= HPBDMA_SLAVE_SDHI0_TX,
+		.addr	= 0xffe4c000 + 0x30,
+		.dcr	= DCR_SPDS_16BIT | DCR_DMDL | DCR_DPDS_16BIT,
+		.rstr	= ASYNCRSTR_ASRST21 | ASYNCRSTR_ASRST22 |
+			  ASYNCRSTR_ASRST23,
+		.mdr	= ASYNCMDR_ASMD21_SINGLE,
+		.mdm	= ASYNCMDR_ASMD21_MASK,
+		.port	= 0x0D0C,
+		.flags	= HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
+		.dma_ch	= 21,
+	}, {
+		.id	= HPBDMA_SLAVE_SDHI0_RX,
+		.addr	= 0xffe4c000 + 0x30,
+		.dcr	= DCR_SMDL | DCR_SPDS_16BIT | DCR_DPDS_16BIT,
Quoted 8 lines

arch/arm/mach-shmobile/setup-r8a7778.c void __init r8a7778_add_mmc_device(struc · line 370

Quoted 8 lines
arch/arm/mach-shmobile/setup-r8a7778.c +8 -0
+		.rstr	= ASYNCRSTR_ASRST21 | ASYNCRSTR_ASRST22 |
+			  ASYNCRSTR_ASRST23,
+		.mdr	= ASYNCMDR_ASMD22_SINGLE,
+		.mdm	= ASYNCMDR_ASMD22_MASK,
+		.port	= 0x0D0C,
+		.flags	= HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
+		.dma_ch	= 22,
+	},

I'm not sure detail of SDHI, but TX and RX are using same .port = 0x0D0C. Is this correct ?
And what is 0x0C port ?
My datasheet doens't have it on Ch21 - Ch23

Quoted 11 lines
Quoted 11 lines
arch/arm/mach-shmobile/setup-r8a7778.c +11 -0
+static const struct hpb_dmae_channel hpb_dmae_channels[] = {
+	/* ch. 21 SD0 */
+	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX),
+	/* ch. 22 SD0 */
+	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX),
+};
+
+static struct hpb_dmae_pdata dma_platform_data __initdata = {
+	.slaves			= hpb_dmae_slaves,
+	.num_slaves		= ARRAY_SIZE(hpb_dmae_slaves),
+	.channels		= hpb_dmae_channels,
Quoted 8 lines

arch/arm/mach-shmobile/setup-r8a7778.c void __init r8a7778_add_mmc_device(struc · line 391

Quoted 8 lines
arch/arm/mach-shmobile/setup-r8a7778.c +8 -0
+	.num_channels		= ARRAY_SIZE(hpb_dmae_channels),
+	.ts_shift		= {
+		[XMIT_SZ_8BIT]	= 0,
+		[XMIT_SZ_16BIT]	= 1,
+		[XMIT_SZ_32BIT]	= 2,
+	},
+	.num_hw_channels	= 39,
+};

This is not a big deal, but according to .num_hw_channels, we will have max 39 channels (or more over).

I want 1 line for 1 channels on hpb_dmae_channels. like this

static const struct hpb_dmae_channel hpb_dmae_channels[] = {
	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX), /* ch21 */
	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX), /* ch22 */
}

Best regards
---
Kuninori Morimoto

#4 lore raw

PATCH v2 1/2 ARM: shmobile: r8a7778: add HPB-DMAC support

Hello.

Quoted 18 lines · Kuninori Morimoto
Quoted 18 lines
Quoted 18 lines
arch/arm/mach-shmobile/setup-r8a7778.c +18 -0
+static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = {
+	{
+		.id	= HPBDMA_SLAVE_SDHI0_TX,
+		.addr	= 0xffe4c000 + 0x30,
+		.dcr	= DCR_SPDS_16BIT | DCR_DMDL | DCR_DPDS_16BIT,
+		.rstr	= ASYNCRSTR_ASRST21 | ASYNCRSTR_ASRST22 |
+			  ASYNCRSTR_ASRST23,
+		.mdr	= ASYNCMDR_ASMD21_SINGLE,
+		.mdm	= ASYNCMDR_ASMD21_MASK,
+		.port	= 0x0D0C,
+		.flags	= HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
+		.dma_ch	= 21,
+	}, {
+		.id	= HPBDMA_SLAVE_SDHI0_RX,
+		.addr	= 0xffe4c000 + 0x30,
+		.dcr	= DCR_SMDL | DCR_SPDS_16BIT | DCR_DPDS_16BIT,
+		.rstr	= ASYNCRSTR_ASRST21 | ASYNCRSTR_ASRST22 |
+			  ASYNCRSTR_ASRST23,
Quoted 8 lines
Quoted 6 lines

arch/arm/mach-shmobile/setup-r8a7778.c void __init r8a7778_add_mmc_device(struc · line 370

Quoted 6 lines
arch/arm/mach-shmobile/setup-r8a7778.c +6 -0
+		.mdr	= ASYNCMDR_ASMD22_SINGLE,
+		.mdm	= ASYNCMDR_ASMD22_MASK,
+		.port	= 0x0D0C,
+		.flags	= HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
+		.dma_ch	= 22,
+	},

I'm not sure detail of SDHI, but TX and RX are using same .port = 0x0D0C.

It's not one port, it's a pair of ports, source and destination.

Quoted 2 lines

Is this correct ?
And what is 0x0C port ?

SDHI0 if you look into the table 16.7 of the R-Car M1A manual 1.00 for the
channels 21 thru 23.

Quoted 1 line

My datasheet doens't have it on Ch21 - Ch23

Maybe you're looking at the wrong table or an obsolete manual?

Quoted 23 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/mach-shmobile/setup-r8a7778.c +11 -0
+static const struct hpb_dmae_channel hpb_dmae_channels[] = {
+	/* ch. 21 SD0 */
+	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX),
+	/* ch. 22 SD0 */
+	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX),
+};
+
+static struct hpb_dmae_pdata dma_platform_data __initdata = {
+	.slaves			= hpb_dmae_slaves,
+	.num_slaves		= ARRAY_SIZE(hpb_dmae_slaves),
+	.channels		= hpb_dmae_channels,
Quoted 8 lines

arch/arm/mach-shmobile/setup-r8a7778.c void __init r8a7778_add_mmc_device(struc · line 391

Quoted 8 lines
arch/arm/mach-shmobile/setup-r8a7778.c +8 -0
+	.num_channels		= ARRAY_SIZE(hpb_dmae_channels),
+	.ts_shift		= {
+		[XMIT_SZ_8BIT]	= 0,
+		[XMIT_SZ_16BIT]	= 1,
+		[XMIT_SZ_32BIT]	= 2,
+	},
+	.num_hw_channels	= 39,
+};

This is not a big deal, but according to .num_hw_channels, we will have max 39 channels (or more over).

Quoted 7 lines

I want 1 line for 1 channels on hpb_dmae_channels. like this

static const struct hpb_dmae_channel hpb_dmae_channels[] = {
	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX), /* ch21 */
	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX), /* ch22 */
}

OK, done.

Quoted 3 lines

Best regards
---
Kuninori Morimoto

WBR, Sergei

#5 lore raw

PATCH v2 1/2 ARM: shmobile: r8a7778: add HPB-DMAC support

Hi Sergei

Quoted 5 lines
Quoted 2 lines

Is this correct ?
And what is 0x0C port ?

SDHI0 if you look into the table 16.7 of the R-Car M1A manual 1.00 for the
channels 21 thru 23.

Ahh... yes, indeed
sorry for my noise

Quoted 9 lines
Quoted 7 lines

I want 1 line for 1 channels on hpb_dmae_channels. like this

static const struct hpb_dmae_channel hpb_dmae_channels[] = {
	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX), /* ch21 */
	HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX), /* ch22 */
}

OK, done.

Thank you

#6 lore raw

PATCH v2 2/2 ARM: shmobile: BOCK-W: enable DMA for SDHI0

In reply to Sergei Shtylyov

From: Max Filippov <[email protected]>

Pass HPB-DMA slave IDs in the SDHI0 platform data to enable DMA in the SDHI driver.

[Sergei: removed #include <mach/dma.h>]

---
Changes in version 2:
- removed #include <mach/dma.h>;
- refreshed the patch.

 arch/arm/mach-shmobile/board-bockw.c |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-shmobile/board-bockw.c +2 -0
Index: renesas/arch/arm/mach-shmobile/board-bockw.c
===================================================================
@@ -81,6 +81,8 @@ static struct rcar_phy_platform_data usb
 
 /* SDHI */
 static struct sh_mobile_sdhi_info sdhi0_info = {
+	.dma_slave_tx	= HPBDMA_SLAVE_SDHI0_TX,
+	.dma_slave_rx	= HPBDMA_SLAVE_SDHI0_RX,
 	.tmio_caps	= MMC_CAP_SD_HIGHSPEED,
 	.tmio_ocr_mask	= MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT,
#7 lore raw

PATCH v2 2/2 ARM: shmobile: BOCK-W: enable DMA for SDHI0

Quoted 8 lines · Sergei Shtylyov

From: Max Filippov <[email protected]>

Pass HPB-DMA slave IDs in the SDHI0 platform data to enable DMA in the SDHI driver.

[Sergei: removed #include <mach/dma.h>]

I don't see HPBDMA_SLAVE_SDHI0_TX in v3.11-rc2.
Please repost this patch when it is available in
a branch I can used as a base.

Quoted 23 lines

---
Changes in version 2:
- removed #include <mach/dma.h>;
- refreshed the patch.

 arch/arm/mach-shmobile/board-bockw.c |    2 ++
 1 file changed, 2 insertions(+)

Index: renesas/arch/arm/mach-shmobile/board-bockw.c
===================================================================

arch/arm/mach-shmobile/board-bockw.c +2 -0
@@ -81,6 +81,8 @@ static struct rcar_phy_platform_data usb
 
 /* SDHI */
 static struct sh_mobile_sdhi_info sdhi0_info = {
+	.dma_slave_tx	= HPBDMA_SLAVE_SDHI0_TX,
+	.dma_slave_rx	= HPBDMA_SLAVE_SDHI0_RX,
 	.tmio_caps	= MMC_CAP_SD_HIGHSPEED,
 	.tmio_ocr_mask	= MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT,
#8 lore raw

PATCH v2 2/2 ARM: shmobile: BOCK-W: enable DMA for SDHI0

Quoted 6 lines · Simon Horman
Quoted 5 lines · Sergei Shtylyov

From: Max Filippov <[email protected]>

Pass HPB-DMA slave IDs in the SDHI0 platform data to enable DMA in the SDHI driver.

Quoted 7 lines
Quoted 3 lines
[Sergei: removed #include <mach/dma.h>]

I don't see HPBDMA_SLAVE_SDHI0_TX in v3.11-rc2.
Please repost this patch when it is available in
a branch I can used as a base.

Sorry, I now see it in patch 1/2.
Somehow I missed that :(