* [PATCH 0/3] mmc: sdhci: Card detection fixes
@ 2015-06-26 10:00 Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence Ivan T. Ivanov
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 10:00 UTC (permalink / raw)
To: Ulf Hansson
Cc: Adrian Hunter, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
Following changes aimed to fix some aspects of card detection, when
BROKEN_CARD_DETECTION quirk is set.
Ivan T. Ivanov (3):
mmc: sdhci: let GPIO based card detection have higher precedence
mmc: sdhci: don't use card state polling when CD GPIO is defined
mmc: sdhci: properly check card present state when quirk
NO_CARD_NO_RESET is set
drivers/mmc/host/sdhci.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence
2015-06-26 10:00 [PATCH 0/3] mmc: sdhci: Card detection fixes Ivan T. Ivanov
@ 2015-06-26 10:00 ` Ivan T. Ivanov
2015-06-26 10:19 ` Adrian Hunter
2015-06-26 10:00 ` [PATCH 2/3] mmc: sdhci: don't use card state polling when CD GPIO is defined Ivan T. Ivanov
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 10:00 UTC (permalink / raw)
To: Ulf Hansson
Cc: Adrian Hunter, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
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: Ivan T. Ivanov <ivan.ivanov@linaro.org>
---
drivers/mmc/host/sdhci.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index bc14452..8bafb9f 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1601,15 +1601,18 @@ static int sdhci_do_get_cd(struct sdhci_host *host)
if (host->flags & SDHCI_DEVICE_DEAD)
return 0;
+ /*
+ * 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/nonremovable, assume that the card is always present. */
if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
(host->mmc->caps & MMC_CAP_NONREMOVABLE))
return 1;
- /* Try slot gpio detect */
- if (!IS_ERR_VALUE(gpio_cd))
- return !!gpio_cd;
-
/* Host native card detect */
return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] mmc: sdhci: don't use card state polling when CD GPIO is defined
2015-06-26 10:00 [PATCH 0/3] mmc: sdhci: Card detection fixes Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence Ivan T. Ivanov
@ 2015-06-26 10:00 ` Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 3/3] mmc: sdhci: properly check card present state when quirk NO_CARD_NO_RESET is set Ivan T. Ivanov
2015-06-26 10:31 ` [PATCH 0/3] mmc: sdhci: Card detection fixes Jaehoon Chung
3 siblings, 0 replies; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 10:00 UTC (permalink / raw)
To: Ulf Hansson
Cc: Adrian Hunter, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
There is no reason to use polling for card detection state change when
drivers are using dedicated GPIO for this. Don't poll in this case.
Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
---
drivers/mmc/host/sdhci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8bafb9f..0b65752 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3121,7 +3121,8 @@ int sdhci_add_host(struct sdhci_host *host)
mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
- !(mmc->caps & MMC_CAP_NONREMOVABLE))
+ !(mmc->caps & MMC_CAP_NONREMOVABLE) &&
+ IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc)))
mmc->caps |= MMC_CAP_NEEDS_POLL;
/* If there are external regulators, get them */
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] mmc: sdhci: properly check card present state when quirk NO_CARD_NO_RESET is set
2015-06-26 10:00 [PATCH 0/3] mmc: sdhci: Card detection fixes Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 2/3] mmc: sdhci: don't use card state polling when CD GPIO is defined Ivan T. Ivanov
@ 2015-06-26 10:00 ` Ivan T. Ivanov
2015-06-26 10:31 ` [PATCH 0/3] mmc: sdhci: Card detection fixes Jaehoon Chung
3 siblings, 0 replies; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 10:00 UTC (permalink / raw)
To: Ulf Hansson
Cc: Adrian Hunter, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
Controller could have both NO_CARD_NO_RESET and BROKEN_CARD_DETECTION
quirks set. Use sdhci_do_get_cd() when applying NO_CARD_NO_RESET, which
properly check for BROKEN_CARD_DETECTION quirk.
Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
---
drivers/mmc/host/sdhci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 0b65752..912a3bb 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -207,8 +207,7 @@ EXPORT_SYMBOL_GPL(sdhci_reset);
static void sdhci_do_reset(struct sdhci_host *host, u8 mask)
{
if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
- if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
- SDHCI_CARD_PRESENT))
+ if (!sdhci_do_get_cd(host))
return;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence
2015-06-26 10:00 ` [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence Ivan T. Ivanov
@ 2015-06-26 10:19 ` Adrian Hunter
2015-06-26 11:00 ` Ivan T. Ivanov
0 siblings, 1 reply; 10+ messages in thread
From: Adrian Hunter @ 2015-06-26 10:19 UTC (permalink / raw)
To: Ivan T. Ivanov, Ulf Hansson
Cc: Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel, linux-arm-msm
On 26/06/15 13:00, Ivan T. Ivanov wrote:
> 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: Ivan T. Ivanov <ivan.ivanov@linaro.org>
> ---
> drivers/mmc/host/sdhci.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index bc14452..8bafb9f 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1601,15 +1601,18 @@ static int sdhci_do_get_cd(struct sdhci_host *host)
> if (host->flags & SDHCI_DEVICE_DEAD)
> return 0;
>
> + /*
> + * Try slot gpio detect, if defined it take precedence
> + * over build in controller functionality
> + */
> + if (!IS_ERR_VALUE(gpio_cd))
> + return !!gpio_cd;
> +
You've also put it above the MMC_CAP_NONREMOVABLE check which doesn't seem
right.
> /* If polling/nonremovable, assume that the card is always present. */
> if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
> (host->mmc->caps & MMC_CAP_NONREMOVABLE))
> return 1;
>
> - /* Try slot gpio detect */
> - if (!IS_ERR_VALUE(gpio_cd))
> - return !!gpio_cd;
> -
> /* Host native card detect */
> return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
> }
> --
> 1.9.1
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] mmc: sdhci: Card detection fixes
2015-06-26 10:00 [PATCH 0/3] mmc: sdhci: Card detection fixes Ivan T. Ivanov
` (2 preceding siblings ...)
2015-06-26 10:00 ` [PATCH 3/3] mmc: sdhci: properly check card present state when quirk NO_CARD_NO_RESET is set Ivan T. Ivanov
@ 2015-06-26 10:31 ` Jaehoon Chung
2015-06-26 11:05 ` Ivan T. Ivanov
3 siblings, 1 reply; 10+ messages in thread
From: Jaehoon Chung @ 2015-06-26 10:31 UTC (permalink / raw)
To: Ivan T. Ivanov, Ulf Hansson
Cc: Adrian Hunter, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
Hi, Ivan.
On 06/26/2015 07:00 PM, Ivan T. Ivanov wrote:
> Following changes aimed to fix some aspects of card detection, when
> BROKEN_CARD_DETECTION quirk is set.
As i know, when there is no card detection scheme, BROKEN_CARD_DETECTION quirks is set.
If it can use CD_GPIO, doesn't it need to set BROKEN_CARD_DETECTION?
Just wondering..
Best Regards,
Jaehoon Chung
>
> Ivan T. Ivanov (3):
> mmc: sdhci: let GPIO based card detection have higher precedence
> mmc: sdhci: don't use card state polling when CD GPIO is defined
> mmc: sdhci: properly check card present state when quirk
> NO_CARD_NO_RESET is set
>
> drivers/mmc/host/sdhci.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence
2015-06-26 10:19 ` Adrian Hunter
@ 2015-06-26 11:00 ` Ivan T. Ivanov
2015-06-26 11:09 ` Adrian Hunter
0 siblings, 1 reply; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 11:00 UTC (permalink / raw)
To: Adrian Hunter
Cc: Ulf Hansson, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
On Fri, 2015-06-26 at 13:19 +0300, Adrian Hunter wrote:
> On 26/06/15 13:00, Ivan T. Ivanov wrote:
> > 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: Ivan T. Ivanov ivanov@linaro.org>
> > ---
> > drivers/mmc/host/sdhci.c | 11 +++++++----
> > 1 file changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index bc14452..8bafb9f 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -1601,15 +1601,18 @@ static int sdhci_do_get_cd(struct sdhci_host *host)
> > if (host->flags & SDHCI_DEVICE_DEAD)
> > return 0;
> >
> > + /*
> > + * Try slot gpio detect, if defined it take precedence
> > + * over build in controller functionality
> > + */
> > + if (!IS_ERR_VALUE(gpio_cd))
> > + return !!gpio_cd;
> > +
>
> You've also put it above the MMC_CAP_NONREMOVABLE check which doesn't seem
> right.
>
Probably, but what are the chances that this is valid GIO for non-removable cards.
I could rework it if you insist.
Thank you,
Ivan
> > /* If polling/nonremovable, assume that the card is always present. */
> > if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
> > (host->mmc->caps & MMC_CAP_NONREMOVABLE))
> > return 1;
> >
> > - /* Try slot gpio detect */
> > - if (!IS_ERR_VALUE(gpio_cd))
> > - return !!gpio_cd;
> > -
> > /* Host native card detect */
> > return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
> > }
> > --
> > 1.9.1
> >
> >
> >
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/3] mmc: sdhci: Card detection fixes
2015-06-26 10:31 ` [PATCH 0/3] mmc: sdhci: Card detection fixes Jaehoon Chung
@ 2015-06-26 11:05 ` Ivan T. Ivanov
0 siblings, 0 replies; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 11:05 UTC (permalink / raw)
To: Jaehoon Chung
Cc: Ulf Hansson, Adrian Hunter, Tim Kryger, Aisheng Dong, linux-mmc,
linux-kernel, linux-arm-msm
On Fri, 2015-06-26 at 19:31 +0900, Jaehoon Chung wrote:
> Hi, Ivan.
>
> On 06/26/2015 07:00 PM, Ivan T. Ivanov wrote:
> > Following changes aimed to fix some aspects of card detection, when
> > BROKEN_CARD_DETECTION quirk is set.
>
> As i know, when there is no card detection scheme, BROKEN_CARD_DETECTION quirks is set.
> If it can use CD_GPIO, doesn't it need to set BROKEN_CARD_DETECTION?
> Just wondering..
>
I am not sure that I get this. My understanding is that if controller have
issues reporting card present state, users could use GPIO for card state sensing.
Probably this don't sound reasonable, but someone could just want to ignore
controller capabilities and use GPIO explicitly.
Regards,
Ivan
> Best Regards,
> Jaehoon Chung
>
> > Ivan T. Ivanov (3):
> > mmc: sdhci: let GPIO based card detection have higher precedence
> > mmc: sdhci: don't use card state polling when CD GPIO is defined
> > mmc: sdhci: properly check card present state when quirk
> > NO_CARD_NO_RESET is set
> >
> > drivers/mmc/host/sdhci.c | 17 ++++++++++-------
> > 1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > --
> > 1.9.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence
2015-06-26 11:00 ` Ivan T. Ivanov
@ 2015-06-26 11:09 ` Adrian Hunter
2015-06-26 11:12 ` Ivan T. Ivanov
0 siblings, 1 reply; 10+ messages in thread
From: Adrian Hunter @ 2015-06-26 11:09 UTC (permalink / raw)
To: Ivan T. Ivanov
Cc: Ulf Hansson, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
On 26/06/15 14:00, Ivan T. Ivanov wrote:
>
> On Fri, 2015-06-26 at 13:19 +0300, Adrian Hunter wrote:
>> On 26/06/15 13:00, Ivan T. Ivanov wrote:
>>> 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: Ivan T. Ivanov ivanov@linaro.org>
>>> ---
>>> drivers/mmc/host/sdhci.c | 11 +++++++----
>>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>>> index bc14452..8bafb9f 100644
>>> --- a/drivers/mmc/host/sdhci.c
>>> +++ b/drivers/mmc/host/sdhci.c
>>> @@ -1601,15 +1601,18 @@ static int sdhci_do_get_cd(struct sdhci_host *host)
>>> if (host->flags & SDHCI_DEVICE_DEAD)
>>> return 0;
>>>
>>> + /*
>>> + * Try slot gpio detect, if defined it take precedence
>>> + * over build in controller functionality
>>> + */
>>> + if (!IS_ERR_VALUE(gpio_cd))
>>> + return !!gpio_cd;
>>> +
>>
>> You've also put it above the MMC_CAP_NONREMOVABLE check which doesn't seem
>> right.
>>
>
> Probably, but what are the chances that this is valid GIO for non-removable cards.
> I could rework it if you insist.
It is nicer not to have to think "what are the chances", and nicer that the
logic is strictly correct, so yes please.
>
> Thank you,
> Ivan
>
>>> /* If polling/nonremovable, assume that the card is always present. */
>>> if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
>>> (host->mmc->caps & MMC_CAP_NONREMOVABLE))
>>> return 1;
>>>
>>> - /* Try slot gpio detect */
>>> - if (!IS_ERR_VALUE(gpio_cd))
>>> - return !!gpio_cd;
>>> -
>>> /* Host native card detect */
>>> return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
>>> }
>>> --
>>> 1.9.1
>>>
>>>
>>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence
2015-06-26 11:09 ` Adrian Hunter
@ 2015-06-26 11:12 ` Ivan T. Ivanov
0 siblings, 0 replies; 10+ messages in thread
From: Ivan T. Ivanov @ 2015-06-26 11:12 UTC (permalink / raw)
To: Adrian Hunter
Cc: Ulf Hansson, Tim Kryger, Aisheng Dong, linux-mmc, linux-kernel,
linux-arm-msm
On Fri, 2015-06-26 at 14:09 +0300, Adrian Hunter wrote:
> On 26/06/15 14:00, Ivan T. Ivanov wrote:
> > On Fri, 2015-06-26 at 13:19 +0300, Adrian Hunter wrote:
> > > On 26/06/15 13:00, Ivan T. Ivanov wrote:
> > > > 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: Ivan T. Ivanov ivanov@linaro.org>
> > > > ---
> > > > drivers/mmc/host/sdhci.c | 11 +++++++----
> > > > 1 file changed, 7 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > > > index bc14452..8bafb9f 100644
> > > > --- a/drivers/mmc/host/sdhci.c
> > > > +++ b/drivers/mmc/host/sdhci.c
> > > > @@ -1601,15 +1601,18 @@ static int sdhci_do_get_cd(struct sdhci_host *host)
> > > > if (host->flags & SDHCI_DEVICE_DEAD)
> > > > return 0;
> > > >
> > > > + /*
> > > > + * Try slot gpio detect, if defined it take precedence
> > > > + * over build in controller functionality
> > > > + */
> > > > + if (!IS_ERR_VALUE(gpio_cd))
> > > > + return !!gpio_cd;
> > > > +
> > >
> > > You've also put it above the MMC_CAP_NONREMOVABLE check which doesn't seem
> > > right.
> > >
> >
> > Probably, but what are the chances that this is valid GIO for non-removable cards.
> > I could rework it if you insist.
>
> It is nicer not to have to think "what are the chances", and nicer that the
> logic is strictly correct, so yes please.
>
Sure, will do.
Thanks,
Ivan
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-06-26 11:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26 10:00 [PATCH 0/3] mmc: sdhci: Card detection fixes Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 1/3] mmc: sdhci: let GPIO based card detection have higher precedence Ivan T. Ivanov
2015-06-26 10:19 ` Adrian Hunter
2015-06-26 11:00 ` Ivan T. Ivanov
2015-06-26 11:09 ` Adrian Hunter
2015-06-26 11:12 ` Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 2/3] mmc: sdhci: don't use card state polling when CD GPIO is defined Ivan T. Ivanov
2015-06-26 10:00 ` [PATCH 3/3] mmc: sdhci: properly check card present state when quirk NO_CARD_NO_RESET is set Ivan T. Ivanov
2015-06-26 10:31 ` [PATCH 0/3] mmc: sdhci: Card detection fixes Jaehoon Chung
2015-06-26 11:05 ` Ivan T. Ivanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).