mmc: omap_hsmmc: Restore the init_stream sequence
PATCH 1/2 mmc: Add a new callback function to perform the 74 clocks cycle sequence
In reply to Mathieu OthaceheFrom: Jean-Jacques Hiblot <[email protected]>
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.
--- drivers/mmc/mmc-uclass.c | 13 +++++++++++++ drivers/mmc/mmc.c | 6 ++++++ include/mmc.h | 9 +++++++++ 3 files changed, 28 insertions(+)
drivers/mmc/mmc-uclass.c +13 -0
@@ -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);
drivers/mmc/mmc.c +6 -0
@@ -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);
include/mmc.h +9 -0
@@ -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);
Signature · 1 line
2.47.1
PATCH 2/2 mmc: omap_hsmmc: implement send_init_stream callback
In reply to Mathieu OthaceheThis callback is used to send the 74 clock cycles after power up.
--- drivers/mmc/omap_hsmmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/mmc/omap_hsmmc.c +11 -2
@@ -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 = {
Signature · 1 line
2.47.1
cover mmc: omap_hsmmc: Restore the init_stream sequence
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(-)
Signature · 1 line
2.47.1
Hi Mathieu,
Quoted 14 lines · Mathieu Othacehe
Hello,
Back in 2019, the
init_streamsequence was disabled withdb52e19cedbecause: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_streamfunction 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.
Quoted 8 lines
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_hsmmcdriver users.
This patchset looks good to me.
But before apply the patchset. I would like see whether Jean has any comments.
Thanks,
Peng
Quoted 25 lines
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
sequenceMathieu Othacehe (1):
mmc:omap_hsmmc: implementsend_init_streamcallbackdrivers/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(-)Signature · 1 line
2.47.1
Peng Fan (OSS)
AppliedFrom: Peng Fan <[email protected]>
Quoted 10 lines · Mathieu Othacehe
Back in 2019, the
init_streamsequence was disabled withdb52e19cedbecause: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_streamfunction 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: 991c9530fc0d52229e6196f6be2dd6e1ef17857cBest regards,
Signature · 1 line
Peng Fan <[email protected]>