Skip to content

Commit 6d5cd06

Browse files
tpetazzonistorulf
authored andcommitted
mmc: sdhci: use WP GPIO in sdhci_check_ro()
Even though SDHCI controllers may have a dedicated WP pin that can be queried using the SDHCI_PRESENT_STATE register, some platforms may chose to use a separate regular GPIO to route the WP signal. Such a GPIO is typically represented using the wp-gpios property in the Device Tree. Unfortunately, the current sdhci_check_ro() function does not make use of such GPIO when available: it either uses a host controller specific ->get_ro() operation, or uses the SDHCI_PRESENT_STATE. Several host controller specific ->get_ro() functions are implemented just to check a WP GPIO state. Instead of pushing this to more controller-specific implementations, let's handle this in the core SDHCI code, just like it is already done for the CD GPIO in sdhci_get_cd(). The below patch simply changes sdhci_check_ro() to use the value of the WP GPIO if available. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 70bcc9e commit 6d5cd06

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,8 @@ static int sdhci_check_ro(struct sdhci_host *host)
20532053
is_readonly = 0;
20542054
else if (host->ops->get_ro)
20552055
is_readonly = host->ops->get_ro(host);
2056+
else if (mmc_can_gpio_ro(host->mmc))
2057+
is_readonly = mmc_gpio_get_ro(host->mmc);
20562058
else
20572059
is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE)
20582060
& SDHCI_WRITE_PROTECT);

0 commit comments

Comments
 (0)