]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: fix response timeout after switch command
authorStefan Bosch <stefan_b@posteo.net>
Sat, 23 Jan 2021 12:37:41 +0000 (13:37 +0100)
committerPeng Fan <peng.fan@nxp.com>
Fri, 19 Feb 2021 07:04:15 +0000 (15:04 +0800)
After issuing the switch command: Wait until 'current state' of the card
status becomes 'tran'. This prevents from response timeout at the next
command because of 'current state' = 'data'.

Signed-off-by: Stefan Bosch <stefan_b@posteo.net>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/mmc.c
include/mmc.h

index d67af80c0110cdae3d2ab106277b44815c4e5268..b4c8e7f293bde2e30d6d9f453815c26c8c3e596a 100644 (file)
@@ -841,7 +841,8 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
                                 value);
                        return -EIO;
                }
-               if (!ret && (status & MMC_STATUS_RDY_FOR_DATA))
+               if (!ret && (status & MMC_STATUS_RDY_FOR_DATA) &&
+                   (status & MMC_STATUS_CURR_STATE) == MMC_STATE_TRANS)
                        return 0;
                udelay(100);
        } while (get_timer(start) < timeout_ms);
index c12c7a0b5cfa559aa81ed3d65d4191813a088b3f..effccaaca086fb35bcd0e680c68112a345ba59d1 100644 (file)
@@ -178,6 +178,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
 #define MMC_STATUS_ERROR       (1 << 19)
 
 #define MMC_STATE_PRG          (7 << 9)
+#define MMC_STATE_TRANS                (4 << 9)
 
 #define MMC_VDD_165_195                0x00000080      /* VDD voltage 1.65 - 1.95 */
 #define MMC_VDD_20_21          0x00000100      /* VDD voltage 2.0 ~ 2.1 */