Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88af5655 authored by Ivan T. Ivanov's avatar Ivan T. Ivanov Committed by Ulf Hansson
Browse files

mmc: sdhci: let GPIO based card detection have higher precedence



Controller could have BROKEN_CARD_DETECTION quirk set, but drivers
could use GPIO to detect card present state. Let, when defined, GPIO
take precedence, so drivers could properly detect card state and not
use polling.

Signed-off-by: default avatarIvan T. Ivanov <ivan.ivanov@linaro.org>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 951b8c87
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1604,15 +1604,21 @@ static int sdhci_do_get_cd(struct sdhci_host *host)
	if (host->flags & SDHCI_DEVICE_DEAD)
		return 0;

	/* If polling/nonremovable, assume that the card is always present. */
	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
	    (host->mmc->caps & MMC_CAP_NONREMOVABLE))
	/* If nonremovable, assume that the card is always present. */
	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
		return 1;

	/* Try slot gpio detect */
	/*
	 * Try slot gpio detect, if defined it take precedence
	 * over build in controller functionality
	 */
	if (!IS_ERR_VALUE(gpio_cd))
		return !!gpio_cd;

	/* If polling, assume that the card is always present. */
	if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
		return 1;

	/* Host native card detect */
	return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
}