diff mbox series

[U-Boot] mmc: get mmc_spi working again

Message ID bbb03bdc-9d59-bd33-112e-929eeaebad22@hsu-hh.de
State Deferred
Delegated to: Peng Fan
Headers show
Series [U-Boot] mmc: get mmc_spi working again | expand

Commit Message

Marcel Eckert Oct. 16, 2018, 12:02 p.m. UTC
Trying to migrate to the latest U-Boot version (my old version was 
u-boot-2016.09.y), mmc_spi command fails with "unable to select a mode". 
I hunted this down to a rewrite in mmc.c regarding MMC/SD mode handling 
(d0c221fe7336fc7d9ada57d96f4a8911a3aac041).
Current mmc.c tries to perform SD commands (like sd_set_card_speed or 
sd_select_bus_width) that produce a "illegal command" response from 
different of my SD-Cards when used in SPI-Mode.
Attached patch just skips these illegal command sequences, when mmc_host 
uses SPI-mode. The patch is a straightforward solution, maybe SPI-mode 
needs to be added in "enum bus_mode" (see mmc.h) and handled properly in 
mmc.c.

Signed-off-by: Marcel Eckert <eckert@hsu-hh.de>
---
  drivers/mmc/mmc.c | 9 +++++++++
  1 file changed, 9 insertions(+)


@@ -1332,6 +1335,9 @@ static int sd_select_bus_width(struct mmc *mmc, int w)
         int err;
         struct mmc_cmd cmd;

+       if (mmc_host_is_spi(mmc))
+               return 0;
+
         if ((w != 4) && (w != 1))
                 return -EINVAL;

@@ -1375,6 +1381,9 @@ static int sd_read_ssr(struct mmc *mmc)
         int timeout = 3;
         unsigned int au, eo, et, es;

+       if (mmc_host_is_spi(mmc))
+               return 0;
+
         cmd.cmdidx = MMC_CMD_APP_CMD;
         cmd.resp_type = MMC_RSP_R1;
         cmd.cmdarg = mmc->rca << 16;
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 585951cd78..d78b58ac77 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1286,6 +1286,9 @@  static int sd_set_card_speed(struct mmc *mmc, enum 
bus_mode mode)
  {
         int err;

+       if (mmc_host_is_spi(mmc))
+               return 0;
+
         ALLOC_CACHE_ALIGN_BUFFER(uint, switch_status, 16);
         int speed;