All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/4] Update stm32_sdmmc2 driver and DT bindings
@ 2019-02-13 10:58 Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 1/4] ARM: dts: stm32: Update sdmmc binding for stm32h743i-eval Patrice Chotard
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Patrice Chotard @ 2019-02-13 10:58 UTC (permalink / raw)
  To: u-boot


This series:
 - Update stm32_sdmmc2 driver to be synced with v4.19 kernel DT bindings.
 - Fix r1b timeout issue for stm32_sdmmc2 driver.
 - Update stm32h743i-eval and stm32mp157c-ed1 DT to be synced with new
   sdmmc DT bindings.

Changes in v2:
     - Remove a "Reviewed-by: CITOOLS ..."

Christophe Kerello (1):
  mmc: stm32_sdmmc2: Fix r1b timeout issue

Patrice Chotard (1):
  ARM: dts: stm32: Update sdmmc binding for stm32mp157c-ed1

Patrick Delaunay (2):
  ARM: dts: stm32: Update sdmmc binding for stm32h743i-eval
  mmc: stm32_sdmmc2: Update DT properties with v4.19 bindings

 arch/arm/dts/stm32h743i-eval.dts |  2 +-
 arch/arm/dts/stm32mp157c-ed1.dts | 10 +++---
 drivers/mmc/stm32_sdmmc2.c       | 67 ++++++++++++++++++++++++++++++++++------
 3 files changed, 64 insertions(+), 15 deletions(-)

-- 
1.9.1

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

* [U-Boot] [PATCH v2 1/4] ARM: dts: stm32: Update sdmmc binding for stm32h743i-eval
  2019-02-13 10:58 [U-Boot] [PATCH v2 0/4] Update stm32_sdmmc2 driver and DT bindings Patrice Chotard
@ 2019-02-13 10:58 ` Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 2/4] ARM: dts: stm32: Update sdmmc binding for stm32mp157c-ed1 Patrice Chotard
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Patrice Chotard @ 2019-02-13 10:58 UTC (permalink / raw)
  To: u-boot

From: Patrick Delaunay <patrick.delaunay@st.com>

Update some sdmmc properties which have been updated with
v4.19 DT bindings:
      - st,dirpol becomes st,sig-dir
      - st,negedge becomes st,neg-edge
      - st,pin-ckin becomes st,use-ckin

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

Changes in v2: None

 arch/arm/dts/stm32h743i-eval.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/stm32h743i-eval.dts b/arch/arm/dts/stm32h743i-eval.dts
index 28c876be27fc..368432f13c9b 100644
--- a/arch/arm/dts/stm32h743i-eval.dts
+++ b/arch/arm/dts/stm32h743i-eval.dts
@@ -105,5 +105,5 @@
 		    <&pinctrl_sdmmc1_level_shifter>;
 	pinctrl-names = "default";
 	bus-width = <4>;
-	st,dirpol;
+	st,sig-dir;
 };
-- 
1.9.1

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

* [U-Boot] [PATCH v2 2/4] ARM: dts: stm32: Update sdmmc binding for stm32mp157c-ed1
  2019-02-13 10:58 [U-Boot] [PATCH v2 0/4] Update stm32_sdmmc2 driver and DT bindings Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 1/4] ARM: dts: stm32: Update sdmmc binding for stm32h743i-eval Patrice Chotard
@ 2019-02-13 10:58 ` Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 3/4] mmc: stm32_sdmmc2: Update DT properties with v4.19 bindings Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 4/4] mmc: stm32_sdmmc2: Fix r1b timeout issue Patrice Chotard
  3 siblings, 0 replies; 5+ messages in thread
From: Patrice Chotard @ 2019-02-13 10:58 UTC (permalink / raw)
  To: u-boot

Update some sdmmc properties which have been updated with
v4.19 DT bindings:
      - st,dirpol becomes st,sig-dir
      - st,negedge becomes st,neg-edge
      - st,pin-ckin becomes st,use-ckin

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

Changes in v2: None

 arch/arm/dts/stm32mp157c-ed1.dts | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/stm32mp157c-ed1.dts b/arch/arm/dts/stm32mp157c-ed1.dts
index 2664c9ce904d..8c0ff3c6ff00 100644
--- a/arch/arm/dts/stm32mp157c-ed1.dts
+++ b/arch/arm/dts/stm32mp157c-ed1.dts
@@ -342,9 +342,9 @@
 &sdmmc1 {
 	pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_dir_pins_a>;
 	broken-cd;
-	st,dirpol;
-	st,negedge;
-	st,pin-ckin;
+	st,sig-dir;
+	st,neg-edge;
+	st,use-ckin;
 	bus-width = <4>;
 	vmmc-supply = <&vdd_sd>;
 	vqmmc-supply = <&sd_switch>;
@@ -361,8 +361,8 @@
 	non-removable;
 	no-sd;
 	no-sdio;
-	st,dirpol;
-	st,negedge;
+	st,sig-dir;
+	st,neg-edge;
 	bus-width = <8>;
 	vmmc-supply = <&v3v3>;
 	vqmmc-supply = <&vdd>;
-- 
1.9.1

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

* [U-Boot] [PATCH v2 3/4] mmc: stm32_sdmmc2: Update DT properties with v4.19 bindings
  2019-02-13 10:58 [U-Boot] [PATCH v2 0/4] Update stm32_sdmmc2 driver and DT bindings Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 1/4] ARM: dts: stm32: Update sdmmc binding for stm32h743i-eval Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 2/4] ARM: dts: stm32: Update sdmmc binding for stm32mp157c-ed1 Patrice Chotard
@ 2019-02-13 10:58 ` Patrice Chotard
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 4/4] mmc: stm32_sdmmc2: Fix r1b timeout issue Patrice Chotard
  3 siblings, 0 replies; 5+ messages in thread
From: Patrice Chotard @ 2019-02-13 10:58 UTC (permalink / raw)
  To: u-boot

From: Patrick Delaunay <patrick.delaunay@st.com>

Some properties name has been updated:
  - st,dirpol becomes st,sig-dir
  - st,negedge becomes st,neg-edge
  - st,pin-ckin becomes st,use-ckin

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

Changes in v2:
     - Remove a "Reviewed-by: CITOOLS ..."

 drivers/mmc/stm32_sdmmc2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
index a36612dd937e..bab7efe754aa 100644
--- a/drivers/mmc/stm32_sdmmc2.c
+++ b/drivers/mmc/stm32_sdmmc2.c
@@ -585,11 +585,11 @@ static int stm32_sdmmc2_probe(struct udevice *dev)
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
-	if (dev_read_bool(dev, "st,negedge"))
+	if (dev_read_bool(dev, "st,neg-edge"))
 		priv->clk_reg_msk |= SDMMC_CLKCR_NEGEDGE;
-	if (dev_read_bool(dev, "st,dirpol"))
+	if (dev_read_bool(dev, "st,sig-dir"))
 		priv->pwr_reg_msk |= SDMMC_POWER_DIRPOL;
-	if (dev_read_bool(dev, "st,pin-ckin"))
+	if (dev_read_bool(dev, "st,use-ckin"))
 		priv->clk_reg_msk |= SDMMC_CLKCR_SELCLKRX_CKIN;
 
 	ret = clk_get_by_index(dev, 0, &priv->clk);
-- 
1.9.1

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

* [U-Boot] [PATCH v2 4/4] mmc: stm32_sdmmc2: Fix r1b timeout issue
  2019-02-13 10:58 [U-Boot] [PATCH v2 0/4] Update stm32_sdmmc2 driver and DT bindings Patrice Chotard
                   ` (2 preceding siblings ...)
  2019-02-13 10:58 ` [U-Boot] [PATCH v2 3/4] mmc: stm32_sdmmc2: Update DT properties with v4.19 bindings Patrice Chotard
@ 2019-02-13 10:58 ` Patrice Chotard
  3 siblings, 0 replies; 5+ messages in thread
From: Patrice Chotard @ 2019-02-13 10:58 UTC (permalink / raw)
  To: u-boot

From: Christophe Kerello <christophe.kerello@st.com>

On response type r1b, if DTIME is not defined or too short,
the Datatimeout and DPSM flag occurs. Like the DPSM is
activated all next data transfer will be frozen.
To avoid this freeze:
    -The driver must define a DTIME on all r1b response type.
    -DTIME of SDMMC must be defined for alls stop transmission
     (for read and write request) even if MMC_RSP_BUSY is not set.
    -If busy timeout occur, an abort request must be sent to
     reinitialize the DPSM.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Tested-by: Patrick DELAUNAY <patrick.delaunay@st.com>
---

Changes in v2: None

 drivers/mmc/stm32_sdmmc2.c | 61 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 55 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c
index bab7efe754aa..ed31ca126e93 100644
--- a/drivers/mmc/stm32_sdmmc2.c
+++ b/drivers/mmc/stm32_sdmmc2.c
@@ -190,6 +190,7 @@ struct stm32_sdmmc2_ctx {
 #define SDMMC_IDMACTRL_IDMAEN		BIT(0)
 
 #define SDMMC_CMD_TIMEOUT		0xFFFFFFFF
+#define SDMMC_BUSYD0END_TIMEOUT_US	1000000
 
 static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
 				    struct mmc_data *data,
@@ -209,9 +210,6 @@ static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
 		idmabase0 = (u32)data->src;
 	}
 
-	/* Set the SDMMC Data TimeOut value */
-	writel(SDMMC_CMD_TIMEOUT, priv->base + SDMMC_DTIMER);
-
 	/* Set the SDMMC DataLength value */
 	writel(ctx->data_length, priv->base + SDMMC_DLEN);
 
@@ -236,8 +234,11 @@ static void stm32_sdmmc2_start_data(struct stm32_sdmmc2_priv *priv,
 }
 
 static void stm32_sdmmc2_start_cmd(struct stm32_sdmmc2_priv *priv,
-				   struct mmc_cmd *cmd, u32 cmd_param)
+				   struct mmc_cmd *cmd, u32 cmd_param,
+				   struct stm32_sdmmc2_ctx *ctx)
 {
+	u32 timeout = 0;
+
 	if (readl(priv->base + SDMMC_CMD) & SDMMC_CMD_CPSMEN)
 		writel(0, priv->base + SDMMC_CMD);
 
@@ -251,6 +252,26 @@ static void stm32_sdmmc2_start_cmd(struct stm32_sdmmc2_priv *priv,
 			cmd_param |= SDMMC_CMD_WAITRESP_1;
 	}
 
+	/*
+	 * SDMMC_DTIME must be set in two case:
+	 * - on data transfert.
+	 * - on busy request.
+	 * If not done or too short, the dtimeout flag occurs and DPSM stays
+	 * enabled/busy and waits for abort (stop transmission cmd).
+	 * Next data command is not possible whereas DPSM is activated.
+	 */
+	if (ctx->data_length) {
+		timeout = SDMMC_CMD_TIMEOUT;
+	} else {
+		writel(0, priv->base + SDMMC_DCTRL);
+
+		if (cmd->resp_type & MMC_RSP_BUSY)
+			timeout = SDMMC_CMD_TIMEOUT;
+	}
+
+	/* Set the SDMMC Data TimeOut value */
+	writel(timeout, priv->base + SDMMC_DTIMER);
+
 	/* Clear flags */
 	writel(SDMMC_ICR_STATIC_FLAGS, priv->base + SDMMC_ICR);
 
@@ -309,6 +330,31 @@ static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv *priv,
 			cmd->response[2] = readl(priv->base + SDMMC_RESP3);
 			cmd->response[3] = readl(priv->base + SDMMC_RESP4);
 		}
+
+		/* Wait for BUSYD0END flag if busy status is detected */
+		if (cmd->resp_type & MMC_RSP_BUSY &&
+		    status & SDMMC_STA_BUSYD0) {
+			mask = SDMMC_STA_DTIMEOUT | SDMMC_STA_BUSYD0END;
+
+			/* Polling status register */
+			ret = readl_poll_timeout(priv->base + SDMMC_STA,
+						 status, status & mask,
+						 SDMMC_BUSYD0END_TIMEOUT_US);
+
+			if (ret < 0) {
+				debug("%s: timeout reading SDMMC_STA\n",
+				      __func__);
+				ctx->dpsm_abort = true;
+				return ret;
+			}
+
+			if (status & SDMMC_STA_DTIMEOUT) {
+				debug("%s: error SDMMC_STA_DTIMEOUT (0x%x)\n",
+				      __func__, status);
+				ctx->dpsm_abort = true;
+				return -ETIMEDOUT;
+			}
+		}
 	}
 
 	return 0;
@@ -395,7 +441,7 @@ retry_cmd:
 		stm32_sdmmc2_start_data(priv, data, &ctx);
 	}
 
-	stm32_sdmmc2_start_cmd(priv, cmd, cmdat);
+	stm32_sdmmc2_start_cmd(priv, cmd, cmdat, &ctx);
 
 	debug("%s: send cmd %d data: 0x%x @ 0x%x\n",
 	      __func__, cmd->cmdidx,
@@ -425,7 +471,10 @@ retry_cmd:
 		debug("%s: send STOP command to abort dpsm treatments\n",
 		      __func__);
 
-		stm32_sdmmc2_start_cmd(priv, &stop_cmd, SDMMC_CMD_CMDSTOP);
+		ctx.data_length = 0;
+
+		stm32_sdmmc2_start_cmd(priv, &stop_cmd,
+				       SDMMC_CMD_CMDSTOP, &ctx);
 		stm32_sdmmc2_end_cmd(priv, &stop_cmd, &ctx);
 
 		writel(SDMMC_ICR_STATIC_FLAGS, priv->base + SDMMC_ICR);
-- 
1.9.1

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

end of thread, other threads:[~2019-02-13 10:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-13 10:58 [U-Boot] [PATCH v2 0/4] Update stm32_sdmmc2 driver and DT bindings Patrice Chotard
2019-02-13 10:58 ` [U-Boot] [PATCH v2 1/4] ARM: dts: stm32: Update sdmmc binding for stm32h743i-eval Patrice Chotard
2019-02-13 10:58 ` [U-Boot] [PATCH v2 2/4] ARM: dts: stm32: Update sdmmc binding for stm32mp157c-ed1 Patrice Chotard
2019-02-13 10:58 ` [U-Boot] [PATCH v2 3/4] mmc: stm32_sdmmc2: Update DT properties with v4.19 bindings Patrice Chotard
2019-02-13 10:58 ` [U-Boot] [PATCH v2 4/4] mmc: stm32_sdmmc2: Fix r1b timeout issue Patrice Chotard

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.