[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2bed40e1-9601-7aae-a246-9939cb744526@intel.com>
Date: Fri, 8 Oct 2021 12:38:26 +0300
From: Adrian Hunter <adrian.hunter@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Eric Biggers <ebiggers@...gle.com>,
Raul E Rangel <rrangel@...omium.org>,
linux-kernel@...r.kernel.org, linux-mmc@...r.kernel.org
Subject: Re: [PATCH v1 1/6] mmc: sdhci: Introduce couple of quirks to ignore
particular state of CD GPIO
On 05/10/2021 13:24, Andy Shevchenko wrote:
> Some platforms may provide contradictory info in some states of CD GPIO line,
> and hence that state or states should be ignored. Introduce couple of quirks
> for that.
OK, I have looked closer now :-)
Hooking ->get_cd() should work, and that is preferred to new quirks.
Please try that.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> drivers/mmc/host/sdhci.c | 13 ++++++++-----
> drivers/mmc/host/sdhci.h | 4 ++++
> 2 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 357b365bf0ec..a7960ee3ef4f 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2395,7 +2395,7 @@ EXPORT_SYMBOL_GPL(sdhci_set_ios);
> static int sdhci_get_cd(struct mmc_host *mmc)
> {
> struct sdhci_host *host = mmc_priv(mmc);
> - int gpio_cd = mmc_gpio_get_cd(mmc);
> + int gpio_cd;
>
> if (host->flags & SDHCI_DEVICE_DEAD)
> return 0;
> @@ -2405,11 +2405,14 @@ static int sdhci_get_cd(struct mmc_host *mmc)
> return 1;
>
> /*
> - * Try slot gpio detect, if defined it take precedence
> - * over build in controller functionality
> + * Try slot GPIO detect, if defined it take precedence
> + * over build in controller functionality.
> */
> - if (gpio_cd >= 0)
> - return !!gpio_cd;
> + gpio_cd = mmc_gpio_get_cd(mmc);
> + if (gpio_cd == 0 && !(host->quirks2 & SDHCI_QUIRK_CARD_DETECTION_IF_GPIO_LOW))
> + return 0;
> + if (gpio_cd > 0 && !(host->quirks2 & SDHCI_QUIRK_CARD_DETECTION_IF_GPIO_HIGH))
> + return 1;
>
> /* If polling, assume that the card is always present. */
> if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index e8d04e42a5af..fb7910d22b18 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -464,6 +464,10 @@ struct sdhci_host {
> #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15)
> /* Controller has CRC in 136 bit Command Response */
> #define SDHCI_QUIRK2_RSP_136_HAS_CRC (1<<16)
> +/* Controller requires additional card detection test on GPIO low */
> +#define SDHCI_QUIRK_CARD_DETECTION_IF_GPIO_LOW (1<<17)
> +/* Controller requires additional card detection test on GPIO high */
> +#define SDHCI_QUIRK_CARD_DETECTION_IF_GPIO_HIGH (1<<18)
> /*
> * Disable HW timeout if the requested timeout is more than the maximum
> * obtainable timeout.
>
Powered by blists - more mailing lists