public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Eric Biggers <ebiggers@google.com>,
	Raul E Rangel <rrangel@chromium.org>,
	linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org
Subject: Re: [PATCH v1 1/6] mmc: sdhci: Introduce couple of quirks to ignore particular state of CD GPIO
Date: Fri, 8 Oct 2021 12:38:26 +0300	[thread overview]
Message-ID: <2bed40e1-9601-7aae-a246-9939cb744526@intel.com> (raw)
In-Reply-To: <20211005102430.63716-2-andriy.shevchenko@linux.intel.com>

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@linux.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.
> 


  reply	other threads:[~2021-10-08  9:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 10:24 [PATCH v1 0/6] mmc: sdhci-pci: Add some CD GPIO related quirks Andy Shevchenko
2021-10-05 10:24 ` [PATCH v1 1/6] mmc: sdhci: Introduce couple of quirks to ignore particular state of CD GPIO Andy Shevchenko
2021-10-08  9:38   ` Adrian Hunter [this message]
2021-10-05 10:24 ` [PATCH v1 2/6] mmc: sdhci-pci: Read card detect from ACPI for Intel Merrifield Andy Shevchenko
2021-10-05 10:24 ` [PATCH v1 3/6] mmc: sdhci: Replace bxt_get_cd() with SDHCI_QUIRK_CARD_DETECTION_IF_GPIO_HIGH Andy Shevchenko
2021-10-05 10:24 ` [PATCH v1 4/6] mmc: sdhci-pci: Remove dead code (struct sdhci_pci_data et al) Andy Shevchenko
2021-10-08  9:42   ` Adrian Hunter
2021-10-05 10:24 ` [PATCH v1 5/6] mmc: sdhci-pci: Remove dead code (cd_gpio, cd_irq " Andy Shevchenko
2021-10-08  9:45   ` Adrian Hunter
2021-10-05 10:24 ` [PATCH v1 6/6] mmc: sdhci-pci: Remove dead code (rst_n_gpio " Andy Shevchenko
2021-10-08  9:45   ` Adrian Hunter
2021-10-07 16:42 ` [PATCH v1 0/6] mmc: sdhci-pci: Add some CD GPIO related quirks Andy Shevchenko
2021-10-07 18:03   ` Adrian Hunter
2021-10-12 20:37     ` Andy Shevchenko
2021-10-07 21:39   ` Raul Rangel
2021-10-12 20:41     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bed40e1-9601-7aae-a246-9939cb744526@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ebiggers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=rrangel@chromium.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox