mmc: Add a new callback function to perform the 74 clocks cycle sequence
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Thu, 10 Apr 2025 09:00:20 +0000 (11:00 +0200)
committerPeng Fan <peng.fan@nxp.com>
Wed, 23 Apr 2025 02:41:11 +0000 (10:41 +0800)
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>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/mmc/mmc-uclass.c
drivers/mmc/mmc.c
include/mmc.h

index 9af84da..2f4dc5b 100644 (file)
@@ -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);
index 13e887e..cdcf2e0 100644 (file)
@@ -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);
 
index 52cacfd..eead666 100644 (file)
@@ -493,6 +493,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
         *
@@ -572,6 +580,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);