Commit 470dcc7511431db4210a79ea4e6b14cf109a24dc

Authored by Joe Hershberger
Committed by Andy Fleming
1 parent 073cfd1c04

mmc: Add a SDHCI quirk for boards that have no CD

Some boards have no Card Detect wired.  In that case, set the CD test
bits in the standard interface.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>

Showing 2 changed files with 21 additions and 3 deletions Side-by-side Diff

... ... @@ -381,11 +381,24 @@
381 381 }
382 382 }
383 383  
  384 + sdhci_set_power(host, fls(mmc->voltages) - 1);
  385 +
  386 + if (host->quirks & SDHCI_QUIRK_NO_CD) {
  387 + unsigned int status;
  388 +
  389 + sdhci_writel(host, SDHCI_CTRL_CD_TEST_INS | SDHCI_CTRL_CD_TEST,
  390 + SDHCI_HOST_CONTROL);
  391 +
  392 + status = sdhci_readl(host, SDHCI_PRESENT_STATE);
  393 + while ((!(status & SDHCI_CARD_PRESENT)) ||
  394 + (!(status & SDHCI_CARD_STATE_STABLE)) ||
  395 + (!(status & SDHCI_CARD_DETECT_PIN_LEVEL)))
  396 + status = sdhci_readl(host, SDHCI_PRESENT_STATE);
  397 + }
  398 +
384 399 /* Eable all state */
385 400 sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_ENABLE);
386 401 sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_SIGNAL_ENABLE);
387   -
388   - sdhci_set_power(host, fls(mmc->voltages) - 1);
389 402  
390 403 return 0;
391 404 }
... ... @@ -76,6 +76,8 @@
76 76 #define SDHCI_SPACE_AVAILABLE 0x00000400
77 77 #define SDHCI_DATA_AVAILABLE 0x00000800
78 78 #define SDHCI_CARD_PRESENT 0x00010000
  79 +#define SDHCI_CARD_STATE_STABLE 0x00020000
  80 +#define SDHCI_CARD_DETECT_PIN_LEVEL 0x00040000
79 81 #define SDHCI_WRITE_PROTECT 0x00080000
80 82  
81 83 #define SDHCI_HOST_CONTROL 0x28
... ... @@ -87,7 +89,9 @@
87 89 #define SDHCI_CTRL_ADMA1 0x08
88 90 #define SDHCI_CTRL_ADMA32 0x10
89 91 #define SDHCI_CTRL_ADMA64 0x18
90   -#define SDHCI_CTRL_8BITBUS 0x20
  92 +#define SDHCI_CTRL_8BITBUS 0x20
  93 +#define SDHCI_CTRL_CD_TEST_INS 0x40
  94 +#define SDHCI_CTRL_CD_TEST 0x80
91 95  
92 96 #define SDHCI_POWER_CONTROL 0x29
93 97 #define SDHCI_POWER_ON 0x01
... ... @@ -219,6 +223,7 @@
219 223 #define SDHCI_QUIRK_BROKEN_R1B (1 << 2)
220 224 #define SDHCI_QUIRK_NO_HISPD_BIT (1 << 3)
221 225 #define SDHCI_QUIRK_BROKEN_VOLTAGE (1 << 4)
  226 +#define SDHCI_QUIRK_NO_CD (1 << 5)
222 227  
223 228 /* to make gcc happy */
224 229 struct sdhci_host;