mmc_spi: allow higher timeouts for SPI mode
authorWolfgang Muees <wolfgang.mues@auerswald.de>
Wed, 11 Mar 2009 13:28:39 +0000 (14:28 +0100)
committerPierre Ossman <drzeus@drzeus.cx>
Tue, 24 Mar 2009 20:30:02 +0000 (21:30 +0100)
Some SD cards have very high timeouts in SPI mode.
So adjust the timeouts from theory to practice.

Signed-off-by: Wolfgang Muees <wolfgang.mues@auerswald.de>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/mmc/core/core.c

index 4a18d90556d9563a2e311e87649d73ee2325e3b1..5c83c67b186cece78738e1e985f5dc01a3e87c68 100644 (file)
@@ -297,6 +297,21 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
                        data->timeout_clks = 0;
                }
        }
+       /*
+        * Some cards need very high timeouts if driven in SPI mode.
+        * The worst observed timeout was 900ms after writing a
+        * continuous stream of data until the internal logic
+        * overflowed.
+        */
+       if (mmc_host_is_spi(card->host)) {
+               if (data->flags & MMC_DATA_WRITE) {
+                       if (data->timeout_ns < 1000000000)
+                               data->timeout_ns = 1000000000;  /* 1s */
+               } else {
+                       if (data->timeout_ns < 100000000)
+                               data->timeout_ns =  100000000;  /* 100ms */
+               }
+       }
 }
 EXPORT_SYMBOL(mmc_set_data_timeout);