* [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence
@ 2025-04-10 9:00 Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 1/2] mmc: Add a new callback function to perform the 74 clocks cycle sequence Mathieu Othacehe
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mathieu Othacehe @ 2025-04-10 9:00 UTC (permalink / raw)
To: Peng Fan
Cc: Jaehoon Chung, Tom Rini, Marek Vasut, Jonas Karlman, Simon Glass,
Tim Harvey, Jean-Jacques Hiblot, u-boot, regis.ray, pascal.dupuis,
Mathieu Othacehe
Hello,
Back in 2019, the init_stream sequence was disabled with db52e19ced because:
This is not required. The MMC core sends CMD0 right after the
initialization and it serves the same purpose.
That is wrong. It does not serve the same purpose at all. The init_stream
function role is to keep the CMD line high for 74 clock cycles which is
required by the SD specification[1]:
A device shall be ready to accept the first command within 1ms from detecting VDD min.
Device may use up to 74 clocks for preparation before receiving the first command.
It turns out that one of the devices I am speaking to is requiring those 74
clocks sequence before the send of the CMD0 as described in the specification.
It was then broken since 2019.
I guess that most of the other devices out there are able to cope with those
74 clocks sequence missing and can respond directly to CMD0, which is why that
went unnoticed with the omap_hsmmc driver users.
I am proposing to restore that sequence, which is also used on the Linux side.
Thanks,
Mathieu
[1]: https://academy.cba.mit.edu/classes/networking_communications/SD/SD.pdf
Jean-Jacques Hiblot (1):
mmc: Add a new callback function to perform the 74 clocks cycle
sequence
Mathieu Othacehe (1):
mmc: omap_hsmmc: implement send_init_stream callback
drivers/mmc/mmc-uclass.c | 13 +++++++++++++
drivers/mmc/mmc.c | 6 ++++++
drivers/mmc/omap_hsmmc.c | 13 +++++++++++--
include/mmc.h | 9 +++++++++
4 files changed, 39 insertions(+), 2 deletions(-)
--
2.47.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] mmc: Add a new callback function to perform the 74 clocks cycle sequence
2025-04-10 9:00 [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Mathieu Othacehe
@ 2025-04-10 9:00 ` Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 2/2] mmc: omap_hsmmc: implement send_init_stream callback Mathieu Othacehe
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mathieu Othacehe @ 2025-04-10 9:00 UTC (permalink / raw)
To: Peng Fan
Cc: Jaehoon Chung, Tom Rini, Marek Vasut, Jonas Karlman, Simon Glass,
Tim Harvey, Jean-Jacques Hiblot, u-boot, regis.ray, pascal.dupuis
From: Jean-Jacques Hiblot <jjhiblot@ti.com>
Add a new callback function *send_init_stream* which start a sequence of
at least 74 clock cycles.
The mmc core uses *mmc_send_init_stream* in order to invoke the callback
function. This will be used during power cycle where the specification
requires such a sequence after power up.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
drivers/mmc/mmc-uclass.c | 13 +++++++++++++
drivers/mmc/mmc.c | 6 ++++++
include/mmc.h | 9 +++++++++
3 files changed, 28 insertions(+)
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index c8db4f811c2..ca5bf1d11e6 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -83,6 +83,19 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us)
return dm_mmc_wait_dat0(mmc->dev, state, timeout_us);
}
+void dm_mmc_send_init_stream(struct udevice *dev)
+{
+ struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+ if (ops->send_init_stream)
+ ops->send_init_stream(dev);
+}
+
+void mmc_send_init_stream(struct mmc *mmc)
+{
+ dm_mmc_send_init_stream(mmc->dev);
+}
+
static int dm_mmc_get_wp(struct udevice *dev)
{
struct dm_mmc_ops *ops = mmc_get_ops(dev);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 31a72366206..086826c668c 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1663,6 +1663,10 @@ static int mmc_execute_tuning(struct mmc *mmc, uint opcode)
}
#endif
+static void mmc_send_init_stream(struct mmc *mmc)
+{
+}
+
static int mmc_set_ios(struct mmc *mmc)
{
int ret = 0;
@@ -2929,6 +2933,8 @@ int mmc_get_op_cond(struct mmc *mmc, bool quiet)
retry:
mmc_set_initial_state(mmc);
+ mmc_send_init_stream(mmc);
+
/* Reset the Card */
err = mmc_go_idle(mmc);
diff --git a/include/mmc.h b/include/mmc.h
index 81bccb4cf12..c2d275cdc3e 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -487,6 +487,14 @@ struct dm_mmc_ops {
*/
int (*set_ios)(struct udevice *dev);
+ /**
+ * send_init_stream() - send the initialization stream: 74 clock cycles
+ * This is used after power up before sending the first command
+ *
+ * @dev: Device to update
+ */
+ void (*send_init_stream)(struct udevice *dev);
+
/**
* get_cd() - See whether a card is present
*
@@ -566,6 +574,7 @@ struct dm_mmc_ops {
/* Transition functions for compatibility */
int mmc_set_ios(struct mmc *mmc);
+void mmc_send_init_stream(struct mmc *mmc);
int mmc_getcd(struct mmc *mmc);
int mmc_getwp(struct mmc *mmc);
int mmc_execute_tuning(struct mmc *mmc, uint opcode);
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] mmc: omap_hsmmc: implement send_init_stream callback
2025-04-10 9:00 [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 1/2] mmc: Add a new callback function to perform the 74 clocks cycle sequence Mathieu Othacehe
@ 2025-04-10 9:00 ` Mathieu Othacehe
2025-04-18 2:43 ` [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Peng Fan
2025-04-23 16:05 ` Peng Fan (OSS)
3 siblings, 0 replies; 5+ messages in thread
From: Mathieu Othacehe @ 2025-04-10 9:00 UTC (permalink / raw)
To: Peng Fan
Cc: Jaehoon Chung, Tom Rini, Marek Vasut, Jonas Karlman, Simon Glass,
Tim Harvey, Jean-Jacques Hiblot, u-boot, regis.ray, pascal.dupuis,
Mathieu Othacehe
This callback is used to send the 74 clock cycles after power up.
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
drivers/mmc/omap_hsmmc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index e66ab25d02a..92bc72b267c 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -780,6 +780,14 @@ tuning_error:
return ret;
}
#endif
+
+static void omap_hsmmc_send_init_stream(struct udevice *dev)
+{
+ struct omap_hsmmc_data *priv = dev_get_priv(dev);
+ struct hsmmc *mmc_base = priv->base_addr;
+
+ mmc_init_stream(mmc_base);
+}
#endif
static void mmc_enable_irq(struct mmc *mmc, struct mmc_cmd *cmd)
@@ -1515,9 +1523,10 @@ static const struct dm_mmc_ops omap_hsmmc_ops = {
.get_wp = omap_hsmmc_getwp,
#endif
#if CONFIG_IS_ENABLED(MMC_SUPPORTS_TUNING)
- .execute_tuning = omap_hsmmc_execute_tuning,
+ .execute_tuning = omap_hsmmc_execute_tuning,
#endif
- .wait_dat0 = omap_hsmmc_wait_dat0,
+ .send_init_stream = omap_hsmmc_send_init_stream,
+ .wait_dat0 = omap_hsmmc_wait_dat0,
};
#else
static const struct mmc_ops omap_hsmmc_ops = {
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence
2025-04-10 9:00 [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 1/2] mmc: Add a new callback function to perform the 74 clocks cycle sequence Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 2/2] mmc: omap_hsmmc: implement send_init_stream callback Mathieu Othacehe
@ 2025-04-18 2:43 ` Peng Fan
2025-04-23 16:05 ` Peng Fan (OSS)
3 siblings, 0 replies; 5+ messages in thread
From: Peng Fan @ 2025-04-18 2:43 UTC (permalink / raw)
To: Mathieu Othacehe
Cc: Peng Fan, Jaehoon Chung, Tom Rini, Marek Vasut, Jonas Karlman,
Simon Glass, Tim Harvey, Jean-Jacques Hiblot, u-boot, regis.ray,
pascal.dupuis
Hi Mathieu,
On Thu, Apr 10, 2025 at 11:00:19AM +0200, Mathieu Othacehe wrote:
>Hello,
>
>Back in 2019, the init_stream sequence was disabled with db52e19ced because:
>
> This is not required. The MMC core sends CMD0 right after the
> initialization and it serves the same purpose.
>
>That is wrong. It does not serve the same purpose at all. The init_stream
>function role is to keep the CMD line high for 74 clock cycles which is
>required by the SD specification[1]:
>
> A device shall be ready to accept the first command within 1ms from detecting VDD min.
> Device may use up to 74 clocks for preparation before receiving the first command.
>
>It turns out that one of the devices I am speaking to is requiring those 74
>clocks sequence before the send of the CMD0 as described in the specification.
>
>It was then broken since 2019.
>
>I guess that most of the other devices out there are able to cope with those
>74 clocks sequence missing and can respond directly to CMD0, which is why that
>went unnoticed with the omap_hsmmc driver users.
This patchset looks good to me.
Reviewd-by: Peng Fan <peng.fan@nxp.com>
But before apply the patchset. I would like see whether Jean has any
comments.
Thanks,
Peng
>
>I am proposing to restore that sequence, which is also used on the Linux side.
>
>Thanks,
>
>Mathieu
>
>[1]: https://academy.cba.mit.edu/classes/networking_communications/SD/SD.pdf
>
>Jean-Jacques Hiblot (1):
> mmc: Add a new callback function to perform the 74 clocks cycle
> sequence
>
>Mathieu Othacehe (1):
> mmc: omap_hsmmc: implement send_init_stream callback
>
> drivers/mmc/mmc-uclass.c | 13 +++++++++++++
> drivers/mmc/mmc.c | 6 ++++++
> drivers/mmc/omap_hsmmc.c | 13 +++++++++++--
> include/mmc.h | 9 +++++++++
> 4 files changed, 39 insertions(+), 2 deletions(-)
>
>--
>2.47.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence
2025-04-10 9:00 [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Mathieu Othacehe
` (2 preceding siblings ...)
2025-04-18 2:43 ` [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Peng Fan
@ 2025-04-23 16:05 ` Peng Fan (OSS)
3 siblings, 0 replies; 5+ messages in thread
From: Peng Fan (OSS) @ 2025-04-23 16:05 UTC (permalink / raw)
To: u-boot, Mathieu Othacehe
Cc: Peng Fan, Jaehoon Chung, Tom Rini, Marek Vasut, Jonas Karlman,
Simon Glass, Tim Harvey, Jean-Jacques Hiblot, regis.ray,
pascal.dupuis
From: Peng Fan <peng.fan@nxp.com>
On Thu, 10 Apr 2025 11:00:19 +0200, Mathieu Othacehe wrote:
> Back in 2019, the init_stream sequence was disabled with db52e19ced because:
>
> This is not required. The MMC core sends CMD0 right after the
> initialization and it serves the same purpose.
>
> That is wrong. It does not serve the same purpose at all. The init_stream
> function role is to keep the CMD line high for 74 clock cycles which is
> required by the SD specification[1]:
>
> [...]
Applied, thanks!
[1/2] mmc: Add a new callback function to perform the 74 clocks cycle sequence
commit: d770e325e9d2fd3ba94481fc6ee41c25e799b325
[2/2] mmc: omap_hsmmc: implement send_init_stream callback
commit: 991c9530fc0d52229e6196f6be2dd6e1ef17857c
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-23 14:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 9:00 [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 1/2] mmc: Add a new callback function to perform the 74 clocks cycle sequence Mathieu Othacehe
2025-04-10 9:00 ` [PATCH 2/2] mmc: omap_hsmmc: implement send_init_stream callback Mathieu Othacehe
2025-04-18 2:43 ` [PATCH 0/2] mmc: omap_hsmmc: Restore the init_stream sequence Peng Fan
2025-04-23 16:05 ` Peng Fan (OSS)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox