diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2010-10-15 06:21:01 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2010-10-23 09:11:21 -0400 |
commit | 2dfb579c7da171f6153cd58e8fbf7dcfe684778d (patch) | |
tree | e54663068118de6dcd2d48fe6894d37c0a02bdbc /drivers/mmc/host | |
parent | d3b993dcc11cd291e6908ed02b9db99970220952 (diff) |
mmc: sdhci: introduce get_ro private write-protect hook
Some controllers handle their write-protection differently. Introduce a
callback to be able to handle it, ensuring the same locking takes place
for it. Rename the status variable to make it more obvious why the read
from the registers needs to be inverted.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: Eric BĂ©nard <eric@eukrea.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r-- | drivers/mmc/host/sdhci.c | 15 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.h | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9cb60bac1950..782c0ee3c925 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1223,22 +1223,25 @@ static int sdhci_get_ro(struct mmc_host *mmc) | |||
1223 | { | 1223 | { |
1224 | struct sdhci_host *host; | 1224 | struct sdhci_host *host; |
1225 | unsigned long flags; | 1225 | unsigned long flags; |
1226 | int present; | 1226 | int is_readonly; |
1227 | 1227 | ||
1228 | host = mmc_priv(mmc); | 1228 | host = mmc_priv(mmc); |
1229 | 1229 | ||
1230 | spin_lock_irqsave(&host->lock, flags); | 1230 | spin_lock_irqsave(&host->lock, flags); |
1231 | 1231 | ||
1232 | if (host->flags & SDHCI_DEVICE_DEAD) | 1232 | if (host->flags & SDHCI_DEVICE_DEAD) |
1233 | present = 0; | 1233 | is_readonly = 0; |
1234 | else if (host->ops->get_ro) | ||
1235 | is_readonly = host->ops->get_ro(host); | ||
1234 | else | 1236 | else |
1235 | present = sdhci_readl(host, SDHCI_PRESENT_STATE); | 1237 | is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE) |
1238 | & SDHCI_WRITE_PROTECT); | ||
1236 | 1239 | ||
1237 | spin_unlock_irqrestore(&host->lock, flags); | 1240 | spin_unlock_irqrestore(&host->lock, flags); |
1238 | 1241 | ||
1239 | if (host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT) | 1242 | /* This quirk needs to be replaced by a callback-function later */ |
1240 | return !!(present & SDHCI_WRITE_PROTECT); | 1243 | return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ? |
1241 | return !(present & SDHCI_WRITE_PROTECT); | 1244 | !is_readonly : is_readonly; |
1242 | } | 1245 | } |
1243 | 1246 | ||
1244 | static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) | 1247 | static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) |
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index bfcd611d7b77..b7b8a3b28b01 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -214,6 +214,7 @@ struct sdhci_ops { | |||
214 | unsigned int (*get_timeout_clock)(struct sdhci_host *host); | 214 | unsigned int (*get_timeout_clock)(struct sdhci_host *host); |
215 | void (*platform_send_init_74_clocks)(struct sdhci_host *host, | 215 | void (*platform_send_init_74_clocks)(struct sdhci_host *host, |
216 | u8 power_mode); | 216 | u8 power_mode); |
217 | unsigned int (*get_ro)(struct sdhci_host *host); | ||
217 | }; | 218 | }; |
218 | 219 | ||
219 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | 220 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS |