All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width
@ 2016-09-14 17:05 Wolfram Sang
  2016-09-14 17:05 ` [PATCH 1/4] mmc: add define for R1 response without CRC Wolfram Sang
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-09-14 17:05 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Simon Horman, Dirk Behme, Wolfram Sang

From: Wolfram Sang <wsa@the-dreams.de>

This series enables SDHI instances on R-Car Gen3 to access eMMC with 8 bit bus
width. I think the patch descriptions speak for themselves.

I decided to not protect this new feature with a flag because it needs
specifically to be enabled by setting the bus width to 8. No legacy platform
does that.

The DTS changes for R-Car Gen3 will come via a seperate series. Note that
'non-removable' is not supported yet because of Runtime PM issues. It seems we
need to overhaul Runtime PM handling for other reasons as well, so I suggest
the basic support goes in like this and DTS do not use 'non-removable' for now.

These patches are based on top of Simon's sdr104-v7 patches but they apply to
current mmc/next as well. A branch can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/topic/sdhi-8bit-emmc-driver

Please review, comment, apply...

   Wolfram


Wolfram Sang (4):
  mmc: add define for R1 response without CRC
  mmc: rtsx_pci: use new macro for R1 without CRC
  mmc: rtsx_usb: use new macro for R1 without CRC
  mmc: tmio: add eMMC support

 drivers/mmc/host/rtsx_pci_sdmmc.c |  2 +-
 drivers/mmc/host/rtsx_usb_sdmmc.c |  2 +-
 drivers/mmc/host/tmio_mmc.h       |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c   | 29 +++++++++++++++++------------
 include/linux/mmc/core.h          |  3 +++
 5 files changed, 25 insertions(+), 14 deletions(-)

-- 
2.9.3

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

* [PATCH 1/4] mmc: add define for R1 response without CRC
  2016-09-14 17:05 [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Wolfram Sang
@ 2016-09-14 17:05 ` Wolfram Sang
  2016-09-14 17:05 ` [PATCH 2/4] mmc: rtsx_pci: use new macro for R1 " Wolfram Sang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-09-14 17:05 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Simon Horman, Dirk Behme, Wolfram Sang

The core uses it for polling. Give drivers a proper define to handle
this case like all other response types.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 include/linux/mmc/core.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index b01e77de1a74de..4caee099b63a28 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -55,6 +55,9 @@ struct mmc_command {
 #define MMC_RSP_R6	(MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 #define MMC_RSP_R7	(MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 
+/* Can be used by core to poll after switch to MMC HS mode */
+#define MMC_RSP_R1_NO_CRC	(MMC_RSP_PRESENT|MMC_RSP_OPCODE)
+
 #define mmc_resp_type(cmd)	((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
 
 /*
-- 
2.9.3

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

* [PATCH 2/4] mmc: rtsx_pci: use new macro for R1 without CRC
  2016-09-14 17:05 [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Wolfram Sang
  2016-09-14 17:05 ` [PATCH 1/4] mmc: add define for R1 response without CRC Wolfram Sang
@ 2016-09-14 17:05 ` Wolfram Sang
  2016-09-14 17:05 ` [PATCH 3/4] mmc: rtsx_usb: " Wolfram Sang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-09-14 17:05 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Simon Horman, Dirk Behme, Wolfram Sang

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 396c9b7e4121b0..3ccaa1415f33b2 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -126,7 +126,7 @@ static int sd_response_type(struct mmc_command *cmd)
 		return SD_RSP_TYPE_R0;
 	case MMC_RSP_R1:
 		return SD_RSP_TYPE_R1;
-	case MMC_RSP_R1 & ~MMC_RSP_CRC:
+	case MMC_RSP_R1_NO_CRC:
 		return SD_RSP_TYPE_R1 | SD_NO_CHECK_CRC7;
 	case MMC_RSP_R1B:
 		return SD_RSP_TYPE_R1b;
-- 
2.9.3

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

* [PATCH 3/4] mmc: rtsx_usb: use new macro for R1 without CRC
  2016-09-14 17:05 [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Wolfram Sang
  2016-09-14 17:05 ` [PATCH 1/4] mmc: add define for R1 response without CRC Wolfram Sang
  2016-09-14 17:05 ` [PATCH 2/4] mmc: rtsx_pci: use new macro for R1 " Wolfram Sang
@ 2016-09-14 17:05 ` Wolfram Sang
  2016-09-14 17:05 ` [PATCH 4/4] mmc: tmio: add eMMC support Wolfram Sang
  2016-09-15 11:52 ` [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Geert Uytterhoeven
  4 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-09-14 17:05 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Simon Horman, Dirk Behme, Wolfram Sang

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 6c71fc9f76c7ec..4106295527b9d0 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -324,7 +324,7 @@ static void sd_send_cmd_get_rsp(struct rtsx_usb_sdmmc *host,
 	case MMC_RSP_R1:
 		rsp_type = SD_RSP_TYPE_R1;
 		break;
-	case MMC_RSP_R1 & ~MMC_RSP_CRC:
+	case MMC_RSP_R1_NO_CRC:
 		rsp_type = SD_RSP_TYPE_R1 | SD_NO_CHECK_CRC7;
 		break;
 	case MMC_RSP_R1B:
-- 
2.9.3

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

* [PATCH 4/4] mmc: tmio: add eMMC support
  2016-09-14 17:05 [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Wolfram Sang
                   ` (2 preceding siblings ...)
  2016-09-14 17:05 ` [PATCH 3/4] mmc: rtsx_usb: " Wolfram Sang
@ 2016-09-14 17:05 ` Wolfram Sang
  2016-09-15 11:52 ` [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Geert Uytterhoeven
  4 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2016-09-14 17:05 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Simon Horman, Dirk Behme, Wolfram Sang

We need to add R1 without CRC support, refactor the bus width routine a
little and extend a quirk check.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/tmio_mmc.h     |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c | 29 +++++++++++++++++------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 4b501f2d529f6e..637581faf756b1 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -79,6 +79,9 @@
 #define	CLK_CTL_DIV_MASK	0xff
 #define	CLK_CTL_SCLKEN		BIT(8)
 
+#define CARD_OPT_WIDTH8		BIT(13)
+#define CARD_OPT_WIDTH		BIT(15)
+
 #define TMIO_BBS		512		/* Boot block size */
 
 /* Definitions for values the CTRL_SDIO_STATUS register can take. */
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 46b5a456243b84..f21c92ec7121cc 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -340,7 +340,9 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
 
 	switch (mmc_resp_type(cmd)) {
 	case MMC_RSP_NONE: c |= RESP_NONE; break;
-	case MMC_RSP_R1:   c |= RESP_R1;   break;
+	case MMC_RSP_R1:
+	case MMC_RSP_R1_NO_CRC:
+			   c |= RESP_R1;   break;
 	case MMC_RSP_R1B:  c |= RESP_R1B;  break;
 	case MMC_RSP_R2:   c |= RESP_R2;   break;
 	case MMC_RSP_R3:   c |= RESP_R3;   break;
@@ -737,12 +739,13 @@ static int tmio_mmc_start_data(struct tmio_mmc_host *host,
 	pr_debug("setup data transfer: blocksize %08x  nr_blocks %d\n",
 		 data->blksz, data->blocks);
 
-	/* Some hardware cannot perform 2 byte requests in 4 bit mode */
-	if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) {
+	/* Some hardware cannot perform 2 byte requests in 4/8 bit mode */
+	if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4 ||
+	    host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) {
 		int blksz_2bytes = pdata->flags & TMIO_MMC_BLKSZ_2BYTES;
 
 		if (data->blksz < 2 || (data->blksz < 4 && !blksz_2bytes)) {
-			pr_err("%s: %d byte block unsupported in 4 bit mode\n",
+			pr_err("%s: %d byte block unsupported in 4/8 bit mode\n",
 			       mmc_hostname(host->mmc), data->blksz);
 			return -EINVAL;
 		}
@@ -922,14 +925,16 @@ static void tmio_mmc_power_off(struct tmio_mmc_host *host)
 static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,
 				unsigned char bus_width)
 {
-	switch (bus_width) {
-	case MMC_BUS_WIDTH_1:
-		sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
-		break;
-	case MMC_BUS_WIDTH_4:
-		sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
-		break;
-	}
+	u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT)
+				& ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8);
+
+	/* reg now applies to MMC_BUS_WIDTH_4 */
+	if (bus_width == MMC_BUS_WIDTH_1)
+		reg |= CARD_OPT_WIDTH;
+	else if (bus_width == MMC_BUS_WIDTH_8)
+		reg |= CARD_OPT_WIDTH8;
+
+	sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg);
 }
 
 /* Set MMC clock / power.
-- 
2.9.3

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

* Re: [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width
  2016-09-14 17:05 [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Wolfram Sang
                   ` (3 preceding siblings ...)
  2016-09-14 17:05 ` [PATCH 4/4] mmc: tmio: add eMMC support Wolfram Sang
@ 2016-09-15 11:52 ` Geert Uytterhoeven
  2016-09-19  8:00   ` Wolfram Sang
  4 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2016-09-15 11:52 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Linux MMC List, Linux-Renesas, Simon Horman, Dirk Behme, Wolfram Sang

Hi Wolfram,

On Wed, Sep 14, 2016 at 7:05 PM, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> The DTS changes for R-Car Gen3 will come via a seperate series. Note that
> 'non-removable' is not supported yet because of Runtime PM issues. It seems we
> need to overhaul Runtime PM handling for other reasons as well, so I suggest
> the basic support goes in like this and DTS do not use 'non-removable' for now.

DT describes the hardware, not current limitations of the software.
Hence IMHO you should add the "non-removable" property to the DTS, and
work around its non-functioning in software.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width
  2016-09-15 11:52 ` [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Geert Uytterhoeven
@ 2016-09-19  8:00   ` Wolfram Sang
  2016-09-19 10:00     ` Ulf Hansson
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2016-09-19  8:00 UTC (permalink / raw)
  To: Geert Uytterhoeven, Ulf Hansson
  Cc: Wolfram Sang, Linux MMC List, Linux-Renesas, Simon Horman, Dirk Behme

[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]

On Thu, Sep 15, 2016 at 01:52:26PM +0200, Geert Uytterhoeven wrote:
> Hi Wolfram,
> 
> On Wed, Sep 14, 2016 at 7:05 PM, Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> > The DTS changes for R-Car Gen3 will come via a seperate series. Note that
> > 'non-removable' is not supported yet because of Runtime PM issues. It seems we
> > need to overhaul Runtime PM handling for other reasons as well, so I suggest
> > the basic support goes in like this and DTS do not use 'non-removable' for now.
> 
> DT describes the hardware, not current limitations of the software.
> Hence IMHO you should add the "non-removable" property to the DTS, and
> work around its non-functioning in software.

@Ulf: Would you accept such a workaround for a while?

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index f21c92ec7121cc..5ab8af294f7c40 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1154,6 +1154,10 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 				  !mmc_card_is_removable(mmc) ||
 				  mmc->slot.cd_irq >= 0);
 
+	/* Workaround for NONREMOVABLE until we fix RuntimePM handling */
+	if (pdata->flags & TMIO_MMC_MIN_RCAR2)
+		_host->native_hotplug = true;
+
 	if (tmio_mmc_clk_enable(_host) < 0) {
 		mmc->f_max = pdata->hclk;
 		mmc->f_min = mmc->f_max / 512;


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width
  2016-09-19  8:00   ` Wolfram Sang
@ 2016-09-19 10:00     ` Ulf Hansson
  0 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2016-09-19 10:00 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Geert Uytterhoeven, Wolfram Sang, Linux MMC List, Linux-Renesas,
	Simon Horman, Dirk Behme

On 19 September 2016 at 10:00, Wolfram Sang <wsa@the-dreams.de> wrote:
> On Thu, Sep 15, 2016 at 01:52:26PM +0200, Geert Uytterhoeven wrote:
>> Hi Wolfram,
>>
>> On Wed, Sep 14, 2016 at 7:05 PM, Wolfram Sang
>> <wsa+renesas@sang-engineering.com> wrote:
>> > The DTS changes for R-Car Gen3 will come via a seperate series. Note that
>> > 'non-removable' is not supported yet because of Runtime PM issues. It seems we
>> > need to overhaul Runtime PM handling for other reasons as well, so I suggest
>> > the basic support goes in like this and DTS do not use 'non-removable' for now.
>>
>> DT describes the hardware, not current limitations of the software.
>> Hence IMHO you should add the "non-removable" property to the DTS, and
>> work around its non-functioning in software.
>
> @Ulf: Would you accept such a workaround for a while?

With some comments about why, yes!

Br
Uffe

>
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index f21c92ec7121cc..5ab8af294f7c40 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -1154,6 +1154,10 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
>                                   !mmc_card_is_removable(mmc) ||
>                                   mmc->slot.cd_irq >= 0);
>
> +       /* Workaround for NONREMOVABLE until we fix RuntimePM handling */
> +       if (pdata->flags & TMIO_MMC_MIN_RCAR2)
> +               _host->native_hotplug = true;
> +
>         if (tmio_mmc_clk_enable(_host) < 0) {
>                 mmc->f_max = pdata->hclk;
>                 mmc->f_min = mmc->f_max / 512;
>

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

end of thread, other threads:[~2016-09-19 10:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-14 17:05 [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Wolfram Sang
2016-09-14 17:05 ` [PATCH 1/4] mmc: add define for R1 response without CRC Wolfram Sang
2016-09-14 17:05 ` [PATCH 2/4] mmc: rtsx_pci: use new macro for R1 " Wolfram Sang
2016-09-14 17:05 ` [PATCH 3/4] mmc: rtsx_usb: " Wolfram Sang
2016-09-14 17:05 ` [PATCH 4/4] mmc: tmio: add eMMC support Wolfram Sang
2016-09-15 11:52 ` [PATCH 0/4] tmio: add support for eMMC with 8 bit bus width Geert Uytterhoeven
2016-09-19  8:00   ` Wolfram Sang
2016-09-19 10:00     ` Ulf Hansson

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.