mmc: sdhci: query card presence from cd-gpio before asking SDHCI
PATCH 1/1 mmc: sdhci: query card presence from cd-gpio before asking SDHCI
Call mmc_gpio_get_cd() to query card presence from cd-gpio before asking SDHCI. The rationale behind this change is that flag SDHCI_QUIRK_BROKEN_CARD_DETECTION is designed for SDHCI controller to tell that SDHCI_PRESENT_STATE is broken, and it should be used for this case only. So when cd-gpio is being used, the controller should set the flag to tell that SDHCI_PRESENT_STATE is not available.
However, the existing code will skip checking cd-gpio as long as flag SDHCI_QUIRK_BROKEN_CARD_DETECTION is set. Change the querying order between cd-gpio and SDHCI to support the rationale above.
--- drivers/mmc/host/sdhci.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci.c +16 -13
@@ -1258,7 +1258,7 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power)static void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) {struct sdhci_host *host; -bool present; +int present;unsigned long flags;u32 tuning_opcode;
@@ -1287,18 +1287,21 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq = mrq; -/* If polling, assume that the card is always present. */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) - present = true; -else - present =sdhci_readl (host,SDHCI_PRESENT_STATE ) & -SDHCI_CARD_PRESENT ; - -/* If we're using a cd-gpio, testing the presence bit might fail. */ -if (!present) { -int ret =mmc_gpio_get_cd (host->mmc); -if (ret >0 ) - present = true; +/* +* Firstly check card presence from cd-gpio. The return could +* be one of the following possibilities: +* negative: cd-gpio is not available +* zero: cd-gpio is used, and card is removed +* one: cd-gpio is used, and card is present +*/ + present =mmc_gpio_get_cd (host->mmc); +if (present <0 ) { +/* If polling, assume that the card is always present. */ +if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) + present =1 ; +else + present =sdhci_readl (host,SDHCI_PRESENT_STATE ) & +SDHCI_CARD_PRESENT ; }if (!present || host->flags &SDHCI_DEVICE_DEAD ) {
Signature · 1 line
1.7.9.5
PATCH 1/1 mmc: sdhci: query card presence from cd-gpio before asking SDHCI
Hi Shawn,
Quoted 7 lines · Shawn Guo
Call
mmc_gpio_get_cd()to query card presence from cd-gpio before asking SDHCI. The rationale behind this change is that flagSDHCI_QUIRK_BROKEN_CARD_DETECTIONis designed for SDHCI controller to tell thatSDHCI_PRESENT_STATEis broken, and it should be used for this case only. So when cd-gpio is being used, the controller should set the flag to tell thatSDHCI_PRESENT_STATEis not available.
Quoted 5 lines
However, the existing code will skip checking cd-gpio as long as flag
SDHCI_QUIRK_BROKEN_CARD_DETECTIONis set. Change the querying order between cd-gpio and SDHCI to support the rationale above.Signed-off-by Shawn Guo <[email protected]>
Thanks, pushed to mmc-next for 3.9.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child