All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mmc: sh_mobile_sdhi: Add r7s72100 support
@ 2016-09-11 21:03 Chris Brandt
  2016-09-11 21:03 ` [PATCH v2 1/3] mmc: sh_mobile_sdhi: add ocr_mask option Chris Brandt
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chris Brandt @ 2016-09-11 21:03 UTC (permalink / raw)
  To: Ulf Hansson, Wolfram Sang, Sergei Shtylyov, Geert Uytterhoeven
  Cc: Simon Horman, linux-mmc, linux-renesas-soc, Chris Brandt

For the most part, the SDHI controller in the RZ/A1 (r7s72100)
is the same as other Renesas SoC...except for the fact that the 
data port register was widened to 32-bits and the 16-bit accesses
in the current tmio driver aren't going to cut it.

Also, the tmio driver allows you to pass in what voltages you
support via the ocr_mask. For the RZ/A1, it's just simple 3.3v.
So, I added the ability to pass that when using DT.

Chris Brandt (3):
  mmc: sh_mobile_sdhi: add ocr_mask option
  mmc: tmio-mmc: add support for 32bit data port
  mmc: sh_mobile_sdhi: Add r7s72100 support

 Documentation/devicetree/bindings/mmc/tmio_mmc.txt |  1 +
 drivers/mmc/host/sh_mobile_sdhi.c                  |  9 ++++++
 drivers/mmc/host/tmio_mmc.h                        | 12 ++++++++
 drivers/mmc/host/tmio_mmc_pio.c                    | 35 ++++++++++++++++++++++
 include/linux/mfd/tmio.h                           |  5 ++++
 5 files changed, 62 insertions(+)

-- 
2.9.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] mmc: sh_mobile_sdhi: add ocr_mask option
  2016-09-11 21:03 [PATCH v2 0/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt
@ 2016-09-11 21:03 ` Chris Brandt
  2016-09-11 21:03 ` [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port Chris Brandt
  2016-09-11 21:03 ` [PATCH v2 3/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt
  2 siblings, 0 replies; 6+ messages in thread
From: Chris Brandt @ 2016-09-11 21:03 UTC (permalink / raw)
  To: Ulf Hansson, Wolfram Sang, Sergei Shtylyov, Geert Uytterhoeven
  Cc: Simon Horman, linux-mmc, linux-renesas-soc, Chris Brandt

In moving platforms from board files to DT, there still needs to be a way
to set the ocr_mask setting for the tmio driver during probe. Without this
setting, the probe will fail because the supported voltages are not known.

This patch will also traditional platform registration platforms to
migrate to DT.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 5334f24..b033500 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -59,6 +59,7 @@ enum tmio_mmc_dmac_type {
 
 struct sh_mobile_sdhi_of_data {
 	unsigned long tmio_flags;
+	u32	      tmio_ocr_mask;
 	unsigned long capabilities;
 	unsigned long capabilities2;
 	enum dma_slave_buswidth dma_buswidth;
@@ -630,6 +631,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 		const struct sh_mobile_sdhi_of_data *of_data = of_id->data;
 
 		mmc_data->flags |= of_data->tmio_flags;
+		mmc_data->ocr_mask = of_data->tmio_ocr_mask;
 		mmc_data->capabilities |= of_data->capabilities;
 		mmc_data->capabilities2 |= of_data->capabilities2;
 		mmc_data->dma_rx_offset = of_data->dma_rx_offset;
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port
  2016-09-11 21:03 [PATCH v2 0/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt
  2016-09-11 21:03 ` [PATCH v2 1/3] mmc: sh_mobile_sdhi: add ocr_mask option Chris Brandt
@ 2016-09-11 21:03 ` Chris Brandt
  2016-09-12 10:59   ` Sergei Shtylyov
  2016-09-11 21:03 ` [PATCH v2 3/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt
  2 siblings, 1 reply; 6+ messages in thread
From: Chris Brandt @ 2016-09-11 21:03 UTC (permalink / raw)
  To: Ulf Hansson, Wolfram Sang, Sergei Shtylyov, Geert Uytterhoeven
  Cc: Simon Horman, linux-mmc, linux-renesas-soc, Chris Brandt

For the r7s72100 SOC, the DATA_PORT register was changed to be 32-bits wide.
Therefore a new flag has been created that will allow 32-bit reads/writes
to the DATA_PORT register instead of 16-bit (because 16-bits accesses are
not supported).

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
v2:
* changed 'data * 0xFF' to 'data & 0xFF'
* added 'const' for sd_ctrl_write32_rep
---
 drivers/mmc/host/tmio_mmc.h     | 12 ++++++++++++
 drivers/mmc/host/tmio_mmc_pio.c | 35 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/tmio.h        |  5 +++++
 3 files changed, 52 insertions(+)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index ecb99fc..a99e634 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -237,6 +237,12 @@ static inline u32 sd_ctrl_read16_and_16_as_32(struct tmio_mmc_host *host, int ad
 	       readw(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
 }
 
+static inline void sd_ctrl_read32_rep(struct tmio_mmc_host *host, int addr,
+		u32 *buf, int count)
+{
+	readsl(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
 static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, u16 val)
 {
 	/* If there is a hook and it returns non-zero then there
@@ -259,4 +265,10 @@ static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, int
 	writew(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
 }
 
+static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
+		const u32 *buf, int count)
+{
+	writesl(host->ctl + (addr << host->bus_shift), buf, count);
+}
+
 #endif
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 017a4dc..66a25ec 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -439,10 +439,45 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
 {
 	int is_read = host->data->flags & MMC_DATA_READ;
 	u8  *buf8;
+	u32 data;
 
 	/*
 	 * Transfer the data
 	 */
+	if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) {
+		if (is_read)
+			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
+					   count >> 2);
+		else
+			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
+					    count >> 2);
+
+		/* if count was multiple of 4 */
+		if (!(count & 0x3))
+			return;
+
+		buf8 = (u8 *)(buf + (count >> 2));
+		count %= 4;
+
+		if (is_read) {
+			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1);
+			while (count--) {
+				*buf8 = data & 0xFF;
+				data = data >> 8;
+				buf8++;
+			}
+		} else {
+			data = *buf8++;
+			if (count > 1)
+				data |= (*buf8++ << 8);
+			if (count > 2)
+				data |= (*buf8++ << 16);
+			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, &data, 1);
+		}
+
+		return;
+	}
+
 	if (is_read)
 		sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
 	else
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 3b95dc7..0dbcb7e 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -100,6 +100,11 @@
 #define TMIO_MMC_SDIO_STATUS_QUIRK	(1 << 8)
 
 /*
+ * Some controllers have a 32-bit wide data port register
+ */
+#define TMIO_MMC_32BIT_DATA_PORT	(1 << 9)
+
+/*
  * Some controllers allows to set SDx actual clock
  */
 #define TMIO_MMC_CLK_ACTUAL		(1 << 10)
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] mmc: sh_mobile_sdhi: Add r7s72100 support
  2016-09-11 21:03 [PATCH v2 0/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt
  2016-09-11 21:03 ` [PATCH v2 1/3] mmc: sh_mobile_sdhi: add ocr_mask option Chris Brandt
  2016-09-11 21:03 ` [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port Chris Brandt
@ 2016-09-11 21:03 ` Chris Brandt
  2 siblings, 0 replies; 6+ messages in thread
From: Chris Brandt @ 2016-09-11 21:03 UTC (permalink / raw)
  To: Ulf Hansson, Wolfram Sang, Sergei Shtylyov, Geert Uytterhoeven
  Cc: Simon Horman, linux-mmc, linux-renesas-soc, Chris Brandt

Add support for r7s72100 SoC.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
 Documentation/devicetree/bindings/mmc/tmio_mmc.txt | 1 +
 drivers/mmc/host/sh_mobile_sdhi.c                  | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/tmio_mmc.txt b/Documentation/devicetree/bindings/mmc/tmio_mmc.txt
index 13df9c2..08b3a30 100644
--- a/Documentation/devicetree/bindings/mmc/tmio_mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/tmio_mmc.txt
@@ -13,6 +13,7 @@ Required properties:
 - compatible:	"renesas,sdhi-shmobile" - a generic sh-mobile SDHI unit
 		"renesas,sdhi-sh7372" - SDHI IP on SH7372 SoC
 		"renesas,sdhi-sh73a0" - SDHI IP on SH73A0 SoC
+		"renesas,sdhi-r7s72100" - SDHI IP on R7S72100 SoC
 		"renesas,sdhi-r8a73a4" - SDHI IP on R8A73A4 SoC
 		"renesas,sdhi-r8a7740" - SDHI IP on R8A7740 SoC
 		"renesas,sdhi-r8a7778" - SDHI IP on R8A7778 SoC
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index b033500..fe9cc41 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -77,6 +77,12 @@ static const struct sh_mobile_sdhi_of_data of_default_cfg = {
 	.tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
 };
 
+static const struct sh_mobile_sdhi_of_data of_rz_compatible = {
+	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT,
+	.tmio_ocr_mask	= MMC_VDD_32_33,
+	.capabilities	= MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
+};
+
 static const struct sh_mobile_sdhi_of_data of_rcar_gen1_compatible = {
 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE |
 			  TMIO_MMC_CLK_ACTUAL,
@@ -133,6 +139,7 @@ static const struct of_device_id sh_mobile_sdhi_of_match[] = {
 	{ .compatible = "renesas,sdhi-sh73a0", .data = &of_default_cfg, },
 	{ .compatible = "renesas,sdhi-r8a73a4", .data = &of_default_cfg, },
 	{ .compatible = "renesas,sdhi-r8a7740", .data = &of_default_cfg, },
+	{ .compatible = "renesas,sdhi-r7s72100", .data = &of_rz_compatible, },
 	{ .compatible = "renesas,sdhi-r8a7778", .data = &of_rcar_gen1_compatible, },
 	{ .compatible = "renesas,sdhi-r8a7779", .data = &of_rcar_gen1_compatible, },
 	{ .compatible = "renesas,sdhi-r8a7790", .data = &of_rcar_gen2_compatible, },
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port
  2016-09-11 21:03 ` [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port Chris Brandt
@ 2016-09-12 10:59   ` Sergei Shtylyov
  2016-09-12 13:06     ` Chris Brandt
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2016-09-12 10:59 UTC (permalink / raw)
  To: Chris Brandt, Ulf Hansson, Wolfram Sang, Geert Uytterhoeven
  Cc: Simon Horman, linux-mmc, linux-renesas-soc

Hello.

On 9/12/2016 12:03 AM, Chris Brandt wrote:

> For the r7s72100 SOC, the DATA_PORT register was changed to be 32-bits wide.
> Therefore a new flag has been created that will allow 32-bit reads/writes
> to the DATA_PORT register instead of 16-bit (because 16-bits accesses are
> not supported).
>
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> ---
> v2:
> * changed 'data * 0xFF' to 'data & 0xFF'
> * added 'const' for sd_ctrl_write32_rep

[...]

> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index 017a4dc..66a25ec 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -439,10 +439,45 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
>  {
>  	int is_read = host->data->flags & MMC_DATA_READ;
>  	u8  *buf8;
> +	u32 data;
>
>  	/*
>  	 * Transfer the data
>  	 */
> +	if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) {
> +		if (is_read)
> +			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
> +					   count >> 2);
> +		else
> +			sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, (u32 *)buf,
> +					    count >> 2);
> +
> +		/* if count was multiple of 4 */
> +		if (!(count & 0x3))
> +			return;
> +
> +		buf8 = (u8 *)(buf + (count >> 2));
> +		count %= 4;
> +
> +		if (is_read) {
> +			sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1);
> +			while (count--) {
> +				*buf8 = data & 0xFF;
> +				data = data >> 8;

				data >>= 8;

> +				buf8++;
> +			}
> +		} else {
> +			data = *buf8++;
> +			if (count > 1)
> +				data |= (*buf8++ << 8);

    Parens not needed.

> +			if (count > 2)
> +				data |= (*buf8++ << 16);

    Here as well.
    Dunno how I missed it in the previous review...

    BTW, you could use memcpy() and thus avoid all the loops and shifts, see 
ata_sff_data_xfer32() in drivers/ata/libata-sff.c.

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port
  2016-09-12 10:59   ` Sergei Shtylyov
@ 2016-09-12 13:06     ` Chris Brandt
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Brandt @ 2016-09-12 13:06 UTC (permalink / raw)
  To: Sergei Shtylyov, Ulf Hansson, Wolfram Sang, Geert Uytterhoeven
  Cc: Simon Horman, linux-mmc, linux-renesas-soc

Hello Sergei

>     BTW, you could use memcpy() and thus avoid all the loops and shifts,
> see
> ata_sff_data_xfer32() in drivers/ata/libata-sff.c.
> 
> [...]
> 
> MBR, Sergei

That's a good idea. Thank you.
I just tried it and it works good, so I'll get rid of the loops.



Chris


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-12 13:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-11 21:03 [PATCH v2 0/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt
2016-09-11 21:03 ` [PATCH v2 1/3] mmc: sh_mobile_sdhi: add ocr_mask option Chris Brandt
2016-09-11 21:03 ` [PATCH v2 2/3] mmc: tmio-mmc: add support for 32bit data port Chris Brandt
2016-09-12 10:59   ` Sergei Shtylyov
2016-09-12 13:06     ` Chris Brandt
2016-09-11 21:03 ` [PATCH v2 3/3] mmc: sh_mobile_sdhi: Add r7s72100 support Chris Brandt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.