public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: richard clark <richard.xnu.clark@gmail.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jon Hunter <jonathanh@nvidia.com>
Cc: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] sdhci: Fix SD card detection issue
Date: Mon, 15 Apr 2024 12:35:14 +0300	[thread overview]
Message-ID: <ba32a2ca-e482-45c2-b381-f8371b8da4be@intel.com> (raw)
In-Reply-To: <CAJNi4rOyuXdHOifib6kX0Wdb5O5LXPEm9nsvEMe-jbCz9GyQww@mail.gmail.com>

+Nvidia guys

On 15/04/24 11:11, richard clark wrote:
> On Mon, Apr 15, 2024 at 3:18 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 15/04/24 10:06, Richard Clark wrote:
>>> The mmc_gpio_get_cd(...) will return 0 called from sdhci_get_cd(...), which means
>>> the card is not present. Actually, the card detection pin is active low by default
>>> according to the SDHCI psec, thus the card detection result is not correct, more
>>
>> SDHCI spec covers the SDHCI lines.  GPIO is separate.
>>
>>> specificly below if condition is true in mmc_rescan(...):
>>>       ...
>>>       if (mmc_card_is_removable(host) && host->ops->get_cd &&
>>>               host->ops->get_cd(host) == 0) {
>>>               ...
>>>               goto out;
>>>       }
>>> The SD card device will have no chance to be created.
>>>
>>> This commit fixes this detection issue via the MMC_CAP2_CD_ACTIVE_HIGH cap2 flag,
>>> parsed from the 'cd-inverted' property of DT.
>>
>> What hardware / driver is it?
> sdhci-tegra on Orin.
>>>
>>> Signed-off-by: Richard Clark <richard.xnu.clark@gmail.com>
>>> ---
>>>  drivers/mmc/host/sdhci.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>>> index c79f73459915..79f33a161ca8 100644
>>> --- a/drivers/mmc/host/sdhci.c
>>> +++ b/drivers/mmc/host/sdhci.c
>>> @@ -2483,6 +2483,9 @@ static int sdhci_get_cd(struct mmc_host *mmc)
>>>        * Try slot gpio detect, if defined it take precedence
>>>        * over build in controller functionality
>>>        */
>>> +     if (!(mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH))
>>> +             gpio_cd = !gpio_cd;
>>
>> MMC_CAP2_CD_ACTIVE_HIGH is already handled in
>> mmc_gpiod_request_cd(), and this turns an error (gpio_cd < 0)
>> into 0, which is not right.
> 
> But in case of 'cd-inverted' is not specified, the gpio CD pin return
> 0 which will be explained as card is not present.
>>
>>> +
>>>       if (gpio_cd >= 0)
>>>               return !!gpio_cd;
>>>
>>


      reply	other threads:[~2024-04-15  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  7:06 [PATCH] sdhci: Fix SD card detection issue Richard Clark
2024-04-15  7:18 ` Adrian Hunter
2024-04-15  7:22   ` Russell King (Oracle)
2024-04-15  8:17     ` richard clark
2024-04-15  8:23       ` Russell King (Oracle)
2024-04-16  2:15         ` richard clark
2024-04-15  8:11   ` richard clark
2024-04-15  9:35     ` Adrian Hunter [this message]

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=ba32a2ca-e482-45c2-b381-f8371b8da4be@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=richard.xnu.clark@gmail.com \
    --cc=thierry.reding@gmail.com \
    --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