Skip to contentSkip to conversation

tmio: add support for eMMC with 8 bit bus width

PATCH Applied Wolfram Sang 4 participants 15 messages Sep 19, 2016 – Sep 22, 2016

Subsystems (4)
lore
Share & tools
lore

Wolfram Sang

author maintainer
#0 lore raw

v3 cover tmio: add support for eMMC with 8 bit bus width

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.

Note that I decided to use the pattern that pinctrl-0 is 3.3v and pinctrl-1 is 1.8v, although the eMMC is fixed at 1.8v. I tried a few ways to only use pinctrl-0 being 1.8v here, but they all ended up to be confusing for users IMO, so I sticked to the most consistent solution after all.

Changes since V2:

* correct node name for sd2_uhs in both devicetrees

Changes since V1:

* merged the two distinct series (drivers + DTS) into one: patches 1-4 are for Ulf, I will ping Simon for patches 5+6 when the time is ready.

* DTS now contains 'non-removable' and we have a software workaround 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

Please review, comment, apply...

Wolfram

Wolfram Sang (6):
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
arm64: dts: r8a7795: salvator: enable on-board eMMC
arm64: dts: r8a7796: salvator: enable on board eMMC

 arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts | 43 +++++++++++++++++++++
 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts | 44 +++++++++++++++++++++-
 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                    | 38 +++++++++++++------
 include/linux/mmc/core.h                           |  3 ++
 7 files changed, 120 insertions(+), 15 deletions(-)
Signature · 1 line
2.9.3
author maintainer
#1 lore raw

PATCH v3 1/6 mmc: add define for R1 response without CRC

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

---
 include/linux/mmc/core.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/mmc/core.h +3 -0
index b01e77de1a74de..4caee099b63a28 100644
@@ -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))
 
 /*
Signature · 1 line
2.9.3
#2 lore raw

Re: [PATCH v3 1/6] mmc: add define for R1 response without CRC

Hi Wolfram,

Quoted 13 lines · Wolfram Sang

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

---
 include/linux/mmc/core.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/mmc/core.h +0 -0
index b01e77de1a74de..4caee099b63a28 100644

include/linux/mmc/core.h struct mmc_command { · line 59

Quoted 5 lines
include/linux/mmc/core.h +2 -0
@@ -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)

MMC_RSP_RQ_NO_CRC is described at Specification?

Best Regards,
Jaehoon Chung

Quoted 5 lines
include/linux/mmc/core.h +1 -0
+
 #define mmc_resp_type(cmd)	((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
 
 /*
#3 lore raw

Re: [PATCH v3 1/6] mmc: add define for R1 response without CRC

Quoted 19 lines · Jaehoon Chung

Hi Wolfram,

Quoted 16 lines · Wolfram Sang

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

---
 include/linux/mmc/core.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/mmc/core.h +0 -0
index b01e77de1a74de..4caee099b63a28 100644
@@ -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)
 
Quoted 4 lines

include/linux/mmc/core.h struct mmc_command { · line 59

Quoted 2 lines
include/linux/mmc/core.h +2 -0
+/* 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)

MMC_RSP_RQ_NO_CRC is described at Specification?

Yes. JEDEC eMMC Spec v5.1, chapter 6.6.2, in the note:

"NOTE While the actual timing change is done, the behavior of any command sent (like CMD13) cannot be guaranteed due to the asynchronous operation. Therefore it is not recommended to use CMD13 to check the busy completion of the timing change indication. In case CMD13 is used the host must ignore CRC errors, if appear."

And the MMC core does that. In mmc_ops.c:

70 if (ignore_crc)
71 cmd.flags &= ~MMC_RSP_CRC;

And ignore_crc is used in mmc.c (last 'true' parameter):

1023 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,

1024                            EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
1025                            card->ext_csd.generic_cmd6_time,
1026                            true, false, true);

This is why I put the comment above the define.

#4 lore raw

Re: [PATCH v3 1/6] mmc: add define for R1 response without CRC

Quoted 25 lines · Wolfram Sang
Quoted 19 lines · Jaehoon Chung

Hi Wolfram,

Quoted 16 lines · Wolfram Sang

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

---
 include/linux/mmc/core.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/mmc/core.h +0 -0
index b01e77de1a74de..4caee099b63a28 100644
@@ -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)
 
Quoted 4 lines

include/linux/mmc/core.h struct mmc_command { · line 59

Quoted 2 lines
include/linux/mmc/core.h +2 -0
+/* 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)

MMC_RSP_RQ_NO_CRC is described at Specification?

Quoted 7 lines

Yes. JEDEC eMMC Spec v5.1, chapter 6.6.2, in the note:

"NOTE While the actual timing change is done, the behavior of any command sent (like CMD13) cannot be guaranteed due to the asynchronous operation. Therefore it is not recommended to use CMD13 to check the busy completion of the timing change indication. In case CMD13 is used the host must ignore CRC errors, if appear."

Thanks for noticing this. I read the spec again.

Best Regards,
Jaehoon Chung

Quoted 15 lines

And the MMC core does that. In mmc_ops.c:

70 if (ignore_crc)
71 cmd.flags &= ~MMC_RSP_CRC;

And ignore_crc is used in mmc.c (last 'true' parameter):

1023 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,

1024                            EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
1025                            card->ext_csd.generic_cmd6_time,
1026                            true, false, true);

This is why I put the comment above the define.

author maintainer
#5 lore raw

PATCH v3 2/6 mmc: rtsx_pci: use new macro for R1 without CRC

In reply to Wolfram Sang
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
index 396c9b7e4121b0..3ccaa1415f33b2 100644
@@ -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;
Signature · 1 line
2.9.3
#6 lore raw

Re: [PATCH v3 2/6] mmc: rtsx_pci: use new macro for R1 without CRC

Hi Wolfram,

Add the commit message.

Quoted 19 lines · Wolfram Sang
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
index 396c9b7e4121b0..3ccaa1415f33b2 100644
@@ -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;
#7 lore raw

Re: [PATCH v3 2/6] mmc: rtsx_pci: use new macro for R1 without CRC

Quoted 3 lines · Jaehoon Chung

Hi Wolfram,

Add the commit message.

Can do, but would be highly redundant with the subject. Ulf, you want one, too?

Quoted 22 lines · Wolfram Sang
Quoted 19 lines
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
index 396c9b7e4121b0..3ccaa1415f33b2 100644
@@ -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;
author maintainer
#8 lore raw

PATCH v3 3/6 mmc: rtsx_usb: use new macro for R1 without CRC

In reply to Wolfram Sang
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_usb_sdmmc.c +1 -1
index 6c71fc9f76c7ec..4106295527b9d0 100644
@@ -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:
Signature · 1 line
2.9.3
author maintainer
#9 lore raw

PATCH v3 4/6 mmc: tmio: add eMMC support

In reply to Wolfram Sang

We need to add R1 without CRC support, refactor the bus width routine a little and extend a quirk check. To support "non-removable;" we need a workaround which will be hopefully removed when reworking PM soon.

---
 drivers/mmc/host/tmio_mmc.h     |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c | 38 ++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
drivers/mmc/host/tmio_mmc.h +3 -0
index 4b501f2d529f6e..637581faf756b1 100644
@@ -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. */
drivers/mmc/host/tmio_mmc_pio.c +26 -12
index 46b5a456243b84..a0f05eb4f34490 100644
@@ -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.
@@ -1149,6 +1154,15 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 				  !mmc_card_is_removable(mmc) ||
 				  mmc->slot.cd_irq >= 0);
 
+	/*
+	 * On Gen2+, eMMC with NONREMOVABLE currently fails because native
+	 * hotplug gets disabled. It seems RuntimePM related yet we need further
+	 * research. Since we are planning a PM overhaul anyway, let's enforce
+	 * for now the device being active by enabling native hotplug always.
+	 */
+	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;
Signature · 1 line
2.9.3
#10 lore raw

Re: [PATCH v3 4/6] mmc: tmio: add eMMC support

Quoted 15 lines · Wolfram Sang

We need to add R1 without CRC support, refactor the bus width routine a little and extend a quirk check. To support "non-removable;" we need a workaround which will be hopefully removed when reworking PM soon.

---
 drivers/mmc/host/tmio_mmc.h     |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c | 38 ++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
drivers/mmc/host/tmio_mmc.h +0 -0
index 4b501f2d529f6e..637581faf756b1 100644

drivers/mmc/host/tmio_mmc.h line 83

Quoted 5 lines
drivers/mmc/host/tmio_mmc.h +2 -0
@@ -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)

Just confusing whether CARD_OPT_WIDTH is 4bit or 1bit?

Quoted 9 lines
drivers/mmc/host/tmio_mmc.h +1 -0
+
 #define TMIO_BBS		512		/* Boot block size */
 
 /* Definitions for values the CTRL_SDIO_STATUS register can take. */
drivers/mmc/host/tmio_mmc_pio.c +0 -0
index 46b5a456243b84..a0f05eb4f34490 100644

drivers/mmc/host/tmio_mmc_pio.c static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command · line 345

Quoted 7 lines
drivers/mmc/host/tmio_mmc_pio.c +3 -1
@@ -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;

Just wonder..It there case that hit "case MMC_RSP_R1_NO_CRC" ?

Quoted 62 lines
drivers/mmc/host/tmio_mmc_pio.c +23 -11
 	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.
@@ -1149,6 +1154,15 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 				  !mmc_card_is_removable(mmc) ||
 				  mmc->slot.cd_irq >= 0);
 
+	/*
+	 * On Gen2+, eMMC with NONREMOVABLE currently fails because native
+	 * hotplug gets disabled. It seems RuntimePM related yet we need further
+	 * research. Since we are planning a PM overhaul anyway, let's enforce
+	 * for now the device being active by enabling native hotplug always.
+	 */
+	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;
#11 lore raw

Re: [PATCH v3 4/6] mmc: tmio: add eMMC support

Quoted 19 lines · Jaehoon Chung
Quoted 18 lines · Wolfram Sang

We need to add R1 without CRC support, refactor the bus width routine a little and extend a quirk check. To support "non-removable;" we need a workaround which will be hopefully removed when reworking PM soon.

---
 drivers/mmc/host/tmio_mmc.h     |  3 +++
 drivers/mmc/host/tmio_mmc_pio.c | 38 ++++++++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
drivers/mmc/host/tmio_mmc.h +0 -0
index 4b501f2d529f6e..637581faf756b1 100644
@@ -79,6 +79,9 @@
 #define	CLK_CTL_DIV_MASK	0xff
 #define	CLK_CTL_SCLKEN		BIT(8)
 
Quoted 4 lines

drivers/mmc/host/tmio_mmc.h line 83

Quoted 2 lines
drivers/mmc/host/tmio_mmc.h +2 -0
+#define CARD_OPT_WIDTH8		BIT(13)
+#define CARD_OPT_WIDTH		BIT(15)

Just confusing whether CARD_OPT_WIDTH is 4bit or 1bit?

The HW is confusing. Setting the bit sets 1-bit mode. This is why I put the comment below in the code:

Quoted 4 lines

drivers/mmc/host/tmio_mmc.h line 87

Quoted 4 lines
drivers/mmc/host/tmio_mmc.h +4 -0
+	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 */

This comment I meant ^^^

Quoted 2 lines
Quoted 2 lines
drivers/mmc/host/tmio_mmc.h +2 -0
+	if (bus_width == MMC_BUS_WIDTH_1)
+		reg |= CARD_OPT_WIDTH;

...

Quoted 8 lines

drivers/mmc/host/tmio_mmc.h

Quoted 6 lines
drivers/mmc/host/tmio_mmc.h +3 -1
 	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;

Just wonder..It there case that hit "case MMC_RSP_R1_NO_CRC" ?

Yes, as described in my response to patch 1. It doesn't work without.

author maintainer
#12 lore raw

PATCH v3 5/6 arm64: dts: r8a7795: salvator: enable on-board eMMC

In reply to Wolfram Sang
---
 arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)
arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts +43 -0
index 8964b1ea3cea69..8e98aeae54c066 100644
@@ -62,6 +62,24 @@
 		clock-frequency = <24576000>;
 	};
 
+	reg_1p8v: regulator0 {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	reg_3p3v: regulator1 {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
 	vcc_sdhi0: regulator-vcc-sdhi0 {
 		compatible = "regulator-fixed";
 
@@ -246,6 +264,18 @@
 		power-source = <1800>;
 	};
 
+	sdhi2_pins: sd2 {
+		groups = "sdhi2_data8", "sdhi2_ctrl";
+		function = "sdhi2";
+		power-source = <3300>;
+	};
+
+	sdhi2_pins_uhs: sd2_uhs {
+		groups = "sdhi2_data8", "sdhi2_ctrl";
+		function = "sdhi2";
+		power-source = <1800>;
+	};
+
 	sdhi3_pins: sd3 {
 		groups = "sdhi3_data4", "sdhi3_ctrl";
 		function = "sdhi3";
@@ -398,6 +428,19 @@
 	status = "okay";
 };
 
+&sdhi2 {
+	/* used for on-board 8bit eMMC */
+	pinctrl-0 = <&sdhi2_pins>;
+	pinctrl-1 = <&sdhi2_pins_uhs>;
+	pinctrl-names = "default", "state_uhs";
+
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	bus-width = <8>;
+	non-removable;
+	status = "okay";
+};
+
 &sdhi3 {
 	pinctrl-0 = <&sdhi3_pins>;
 	pinctrl-1 = <&sdhi3_pins_uhs>;
Signature · 1 line
2.9.3
author maintainer
#13 lore raw

PATCH v3 6/6 arm64: dts: r8a7796: salvator: enable on board eMMC

In reply to Wolfram Sang
---
 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts | 44 +++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts +43 -1
index 91440eb2237e72..8cda70db2745ae 100644
@@ -31,6 +31,24 @@
 		reg = <0x0 0x48000000 0x0 0x78000000>;
 	};
 
+	reg_1p8v: regulator0 {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	reg_3p3v: regulator1 {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
 	vcc_sdhi0: regulator-vcc-sdhi0 {
 		compatible = "regulator-fixed";
 
@@ -78,7 +96,6 @@
 		states = <3300000 1
 			  1800000 0>;
 	};
-
 };
 
 &pfc {
@@ -106,6 +123,18 @@
 		power-source = <1800>;
 	};
 
+	sdhi2_pins: sd2 {
+		groups = "sdhi2_data8", "sdhi2_ctrl";
+		function = "sdhi2";
+		power-source = <3300>;
+	};
+
+	sdhi2_pins_uhs: sd2_uhs {
+		groups = "sdhi2_data8", "sdhi2_ctrl";
+		function = "sdhi2";
+		power-source = <1800>;
+	};
+
 	sdhi3_pins: sd3 {
 		groups = "sdhi3_data4", "sdhi3_ctrl";
 		function = "sdhi3";
@@ -138,6 +167,19 @@
 	status = "okay";
 };
 
+&sdhi2 {
+	/* used for on-board 8bit eMMC */
+	pinctrl-0 = <&sdhi2_pins>;
+	pinctrl-1 = <&sdhi2_pins_uhs>;
+	pinctrl-names = "default", "state_uhs";
+
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	bus-width = <8>;
+	non-removable;
+	status = "okay";
+};
+
 &sdhi3 {
 	pinctrl-0 = <&sdhi3_pins>;
 	pinctrl-1 = <&sdhi3_pins_uhs>;
Signature · 1 line
2.9.3
Applied
#14 lore raw
In reply to Wolfram Sang
Quoted 40 lines · Wolfram Sang

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.

Note that I decided to use the pattern that pinctrl-0 is 3.3v and pinctrl-1 is 1.8v, although the eMMC is fixed at 1.8v. I tried a few ways to only use pinctrl-0 being 1.8v here, but they all ended up to be confusing for users IMO, so I sticked to the most consistent solution after all.

Changes since V2:

* correct node name for sd2_uhs in both devicetrees

Changes since V1:

* merged the two distinct series (drivers + DTS) into one: patches 1-4 are for Ulf, I will ping Simon for patches 5+6 when the time is ready.

* DTS now contains 'non-removable' and we have a software workaround 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

Please review, comment, apply...

Wolfram

Wolfram Sang (6):
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
arm64: dts: r8a7795: salvator: enable on-board eMMC
arm64: dts: r8a7796: salvator: enable on board eMMC

Quoted 9 lines
 arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts | 43 +++++++++++++++++++++
 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts | 44 +++++++++++++++++++++-
 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                    | 38 +++++++++++++------
 include/linux/mmc/core.h                           |  3 ++
 7 files changed, 120 insertions(+), 15 deletions(-)

Thanks, applied patch 1->4 for next. I assume Simon will pick up the DT changes, sooner or later.

Kind regards
Uffe