aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/host/sdhci-pci.c5
-rw-r--r--drivers/mmc/host/sdhci.c28
-rw-r--r--include/linux/mmc/sdhci.h2
3 files changed, 31 insertions, 4 deletions
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 82c5dc412679..936bbca19c0a 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -327,6 +327,11 @@ static int jmicron_probe(struct sdhci_pci_chip *chip)
327 return ret; 327 return ret;
328 } 328 }
329 329
330 /* quirk for unsable RO-detection on JM388 chips */
331 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD ||
332 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD)
333 chip->quirks |= SDHCI_QUIRK_UNSTABLE_RO_DETECT;
334
330 return 0; 335 return 0;
331} 336}
332 337
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a70a3d1ef35a..e5cfe70dc23b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1256,14 +1256,11 @@ out:
1256 spin_unlock_irqrestore(&host->lock, flags); 1256 spin_unlock_irqrestore(&host->lock, flags);
1257} 1257}
1258 1258
1259static int sdhci_get_ro(struct mmc_host *mmc) 1259static int check_ro(struct sdhci_host *host)
1260{ 1260{
1261 struct sdhci_host *host;
1262 unsigned long flags; 1261 unsigned long flags;
1263 int is_readonly; 1262 int is_readonly;
1264 1263
1265 host = mmc_priv(mmc);
1266
1267 spin_lock_irqsave(&host->lock, flags); 1264 spin_lock_irqsave(&host->lock, flags);
1268 1265
1269 if (host->flags & SDHCI_DEVICE_DEAD) 1266 if (host->flags & SDHCI_DEVICE_DEAD)
@@ -1281,6 +1278,29 @@ static int sdhci_get_ro(struct mmc_host *mmc)
1281 !is_readonly : is_readonly; 1278 !is_readonly : is_readonly;
1282} 1279}
1283 1280
1281#define SAMPLE_COUNT 5
1282
1283static int sdhci_get_ro(struct mmc_host *mmc)
1284{
1285 struct sdhci_host *host;
1286 int i, ro_count;
1287
1288 host = mmc_priv(mmc);
1289
1290 if (!(host->quirks & SDHCI_QUIRK_UNSTABLE_RO_DETECT))
1291 return check_ro(host);
1292
1293 ro_count = 0;
1294 for (i = 0; i < SAMPLE_COUNT; i++) {
1295 if (check_ro(host)) {
1296 if (++ro_count > SAMPLE_COUNT / 2)
1297 return 1;
1298 }
1299 msleep(30);
1300 }
1301 return 0;
1302}
1303
1284static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) 1304static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
1285{ 1305{
1286 struct sdhci_host *host; 1306 struct sdhci_host *host;
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 83bd9f76709a..92e1c9ad126c 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -85,6 +85,8 @@ struct sdhci_host {
85#define SDHCI_QUIRK_NO_HISPD_BIT (1<<29) 85#define SDHCI_QUIRK_NO_HISPD_BIT (1<<29)
86/* Controller treats ADMA descriptors with length 0000h incorrectly */ 86/* Controller treats ADMA descriptors with length 0000h incorrectly */
87#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30) 87#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30)
88/* The read-only detection via SDHCI_PRESENT_STATE register is unstable */
89#define SDHCI_QUIRK_UNSTABLE_RO_DETECT (1<<31)
88 90
89 int irq; /* Device IRQ */ 91 int irq; /* Device IRQ */
90 void __iomem *ioaddr; /* Mapped address */ 92 void __iomem *ioaddr; /* Mapped address */