* [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
@ 2012-10-23 7:01 r66093
2012-10-23 8:26 ` Anton Vorontsov
0 siblings, 1 reply; 8+ messages in thread
From: r66093 @ 2012-10-23 7:01 UTC (permalink / raw)
To: linux-mmc; +Cc: Jerry Huang, Anton Vorontsov, Chris Ball
From: Jerry Huang <Chang-Ming.Huang@freescale.com>
The current eSDHC driver use the poll mode to detect
if the SD/MMC card is inserted or removed, which will generate
many interrupts and impact the performance.
Therefore, change the default card detect to interrupt mode,
if the board can't support this mode, we still use the poll mode.
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Anton Vorontsov <cbouatmailru@gmail.com>
CC: Chris Ball <cjb@laptop.org>
---
drivers/mmc/host/sdhci-of-esdhc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index ffc1226..5dc362f 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -196,6 +196,11 @@ static void esdhc_of_detect_limitation(struct platform_device *pdev,
if (vvn == VENDOR_V_22)
pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+ /* P4080DS and MPC837XMDS board don't support interrupt mode */
+ if (of_machine_is_compatible("fsl,mpc837xmds") ||
+ of_machine_is_compatible("fsl,P4080DS"))
+ pdata->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
iounmap(ioaddr);
end:
return;
@@ -223,7 +228,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
* card detection could be handled via GPIO
* eSDHC cannot support End Attribute in NOP ADMA descriptor
*/
- .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION
+ .quirks = ESDHC_DEFAULT_QUIRKS
| SDHCI_QUIRK_NO_CARD_NO_RESET
| SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
.ops = &sdhci_esdhc_ops,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-23 7:01 [PATCH] powerpc/esdhc: enable the card insert/remove interrupt r66093
@ 2012-10-23 8:26 ` Anton Vorontsov
2012-10-23 8:39 ` Huang Changming-R66093
0 siblings, 1 reply; 8+ messages in thread
From: Anton Vorontsov @ 2012-10-23 8:26 UTC (permalink / raw)
To: r66093; +Cc: linux-mmc, Jerry Huang, Chris Ball, Kumar Gala, linuxppc-dev
On Tue, Oct 23, 2012 at 03:01:17PM +0800, r66093@freescale.com wrote:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> The current eSDHC driver use the poll mode to detect
> if the SD/MMC card is inserted or removed, which will generate
> many interrupts and impact the performance.
> Therefore, change the default card detect to interrupt mode,
> if the board can't support this mode, we still use the poll mode.
>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
IIRC, the card detection is broken SOC-revision-wise, not board-wise. So
the change seems wrong.
Also, take a look at this:
http://lkml.org/lkml/2010/7/14/127
I started the work but never finished, unfortunately it caused some
regressions for non-FSL hardware...
> drivers/mmc/host/sdhci-of-esdhc.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index ffc1226..5dc362f 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -196,6 +196,11 @@ static void esdhc_of_detect_limitation(struct platform_device *pdev,
> if (vvn == VENDOR_V_22)
> pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
>
> + /* P4080DS and MPC837XMDS board don't support interrupt mode */
> + if (of_machine_is_compatible("fsl,mpc837xmds") ||
> + of_machine_is_compatible("fsl,P4080DS"))
> + pdata->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> +
> iounmap(ioaddr);
> end:
> return;
> @@ -223,7 +228,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
> * card detection could be handled via GPIO
> * eSDHC cannot support End Attribute in NOP ADMA descriptor
> */
> - .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION
> + .quirks = ESDHC_DEFAULT_QUIRKS
> | SDHCI_QUIRK_NO_CARD_NO_RESET
> | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
> .ops = &sdhci_esdhc_ops,
> --
> 1.7.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-23 8:26 ` Anton Vorontsov
@ 2012-10-23 8:39 ` Huang Changming-R66093
2012-10-25 10:05 ` Huang Changming-R66093
0 siblings, 1 reply; 8+ messages in thread
From: Huang Changming-R66093 @ 2012-10-23 8:39 UTC (permalink / raw)
To: Anton Vorontsov
Cc: linux-mmc@vger.kernel.org, Chris Ball, Kumar Gala,
linuxppc-dev@lists.ozlabs.org
Hi, Anton
For FSL SOCs, the interrupt mode is support for card detect.
For some reasons, some board can't support this feature, such as mpc837xmds board,
but mpc837xrdb board support it.
I see your links, it is about the DMA (the first version of p2020 don't support DMA, need to enable the PIO mode, but the later version has fixed this issue).
Best Regards
Jerry Huang
> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Anton Vorontsov
> Sent: Tuesday, October 23, 2012 4:27 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Chris Ball; Kumar
> Gala; linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH] powerpc/esdhc: enable the card insert/remove
> interrupt
>
> On Tue, Oct 23, 2012 at 03:01:17PM +0800, r66093@freescale.com wrote:
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >
> > The current eSDHC driver use the poll mode to detect if the SD/MMC
> > card is inserted or removed, which will generate many interrupts and
> > impact the performance.
> > Therefore, change the default card detect to interrupt mode, if the
> > board can't support this mode, we still use the poll mode.
> >
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Anton Vorontsov <cbouatmailru@gmail.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
>
> IIRC, the card detection is broken SOC-revision-wise, not board-wise. So
> the change seems wrong.
>
> Also, take a look at this:
>
> http://lkml.org/lkml/2010/7/14/127
>
> I started the work but never finished, unfortunately it caused some
> regressions for non-FSL hardware...
>
> > drivers/mmc/host/sdhci-of-esdhc.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-of-esdhc.c
> > b/drivers/mmc/host/sdhci-of-esdhc.c
> > index ffc1226..5dc362f 100644
> > --- a/drivers/mmc/host/sdhci-of-esdhc.c
> > +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> > @@ -196,6 +196,11 @@ static void esdhc_of_detect_limitation(struct
> platform_device *pdev,
> > if (vvn == VENDOR_V_22)
> > pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
> >
> > + /* P4080DS and MPC837XMDS board don't support interrupt mode */
> > + if (of_machine_is_compatible("fsl,mpc837xmds") ||
> > + of_machine_is_compatible("fsl,P4080DS"))
> > + pdata->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> > +
> > iounmap(ioaddr);
> > end:
> > return;
> > @@ -223,7 +228,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata =
> {
> > * card detection could be handled via GPIO
> > * eSDHC cannot support End Attribute in NOP ADMA descriptor
> > */
> > - .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION
> > + .quirks = ESDHC_DEFAULT_QUIRKS
> > | SDHCI_QUIRK_NO_CARD_NO_RESET
> > | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
> > .ops = &sdhci_esdhc_ops,
> > --
> > 1.7.9.5
> --
> 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] 8+ messages in thread
* RE: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-23 8:39 ` Huang Changming-R66093
@ 2012-10-25 10:05 ` Huang Changming-R66093
2012-10-25 10:30 ` Anton Vorontsov
0 siblings, 1 reply; 8+ messages in thread
From: Huang Changming-R66093 @ 2012-10-25 10:05 UTC (permalink / raw)
To: Anton Vorontsov
Cc: linux-mmc@vger.kernel.org, Chris Ball, Kumar Gala,
linuxppc-dev@lists.ozlabs.org
Hi, Anton.
Could you have any comment about it?
If not, I will resend this patch with v2.
Best Regards
Jerry Huang
> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Huang Changming-R66093
> Sent: Tuesday, October 23, 2012 4:40 PM
> To: Anton Vorontsov
> Cc: linux-mmc@vger.kernel.org; Chris Ball; Kumar Gala; linuxppc-
> dev@lists.ozlabs.org
> Subject: RE: [PATCH] powerpc/esdhc: enable the card insert/remove
> interrupt
>
> Hi, Anton
> For FSL SOCs, the interrupt mode is support for card detect.
> For some reasons, some board can't support this feature, such as
> mpc837xmds board, but mpc837xrdb board support it.
>
> I see your links, it is about the DMA (the first version of p2020 don't
> support DMA, need to enable the PIO mode, but the later version has fixed
> this issue).
>
> Best Regards
> Jerry Huang
>
>
> > -----Original Message-----
> > From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> > owner@vger.kernel.org] On Behalf Of Anton Vorontsov
> > Sent: Tuesday, October 23, 2012 4:27 PM
> > To: Huang Changming-R66093
> > Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Chris Ball;
> > Kumar Gala; linuxppc-dev@lists.ozlabs.org
> > Subject: Re: [PATCH] powerpc/esdhc: enable the card insert/remove
> > interrupt
> >
> > On Tue, Oct 23, 2012 at 03:01:17PM +0800, r66093@freescale.com wrote:
> > > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > >
> > > The current eSDHC driver use the poll mode to detect if the SD/MMC
> > > card is inserted or removed, which will generate many interrupts and
> > > impact the performance.
> > > Therefore, change the default card detect to interrupt mode, if the
> > > board can't support this mode, we still use the poll mode.
> > >
> > > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > > CC: Anton Vorontsov <cbouatmailru@gmail.com>
> > > CC: Chris Ball <cjb@laptop.org>
> > > ---
> >
> > IIRC, the card detection is broken SOC-revision-wise, not board-wise.
> > So the change seems wrong.
> >
> > Also, take a look at this:
> >
> > http://lkml.org/lkml/2010/7/14/127
> >
> > I started the work but never finished, unfortunately it caused some
> > regressions for non-FSL hardware...
> >
> > > drivers/mmc/host/sdhci-of-esdhc.c | 7 ++++++-
> > > 1 file changed, 6 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-of-esdhc.c
> > > b/drivers/mmc/host/sdhci-of-esdhc.c
> > > index ffc1226..5dc362f 100644
> > > --- a/drivers/mmc/host/sdhci-of-esdhc.c
> > > +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> > > @@ -196,6 +196,11 @@ static void esdhc_of_detect_limitation(struct
> > platform_device *pdev,
> > > if (vvn == VENDOR_V_22)
> > > pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
> > >
> > > + /* P4080DS and MPC837XMDS board don't support interrupt mode */
> > > + if (of_machine_is_compatible("fsl,mpc837xmds") ||
> > > + of_machine_is_compatible("fsl,P4080DS"))
> > > + pdata->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> > > +
> > > iounmap(ioaddr);
> > > end:
> > > return;
> > > @@ -223,7 +228,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata
> > > =
> > {
> > > * card detection could be handled via GPIO
> > > * eSDHC cannot support End Attribute in NOP ADMA descriptor
> > > */
> > > - .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION
> > > + .quirks = ESDHC_DEFAULT_QUIRKS
> > > | SDHCI_QUIRK_NO_CARD_NO_RESET
> > > | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
> > > .ops = &sdhci_esdhc_ops,
> > > --
> > > 1.7.9.5
> > --
> > 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
>
> N r y b X ǧv ^ ){.n + { g" ^n r z \x1a h & \x1e G h
> \x03( 階 ݢj" \x1a ^[m z ޖ f h ~ m
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-25 10:05 ` Huang Changming-R66093
@ 2012-10-25 10:30 ` Anton Vorontsov
2012-10-26 2:42 ` Huang Changming-R66093
0 siblings, 1 reply; 8+ messages in thread
From: Anton Vorontsov @ 2012-10-25 10:30 UTC (permalink / raw)
To: Huang Changming-R66093
Cc: linux-mmc@vger.kernel.org, Chris Ball, Kumar Gala,
linuxppc-dev@lists.ozlabs.org
On Thu, Oct 25, 2012 at 10:05:44AM +0000, Huang Changming-R66093 wrote:
> Hi, Anton.
> Could you have any comment about it?
> If not, I will resend this patch with v2.
Technically, the patch looks fine.
But again, as far as I recall, the card detection logic was broken on the
SOC level (it's actually very hard to break it on the board level -- it
would either work or not, but in the eSDHC case it was just unreliable,
again, if I recall everything correctly -- I might be wrong).
Of course you know the hardware much better, so your words weight more, so
you don't need my ack on the patch. :)
Although there's a second issue: for P4080DS and mpc837x boards you still
have the same problem with polling method, right? It is causing
performance drops/freezes every like 100 ms, and that's why you want to
avoid the polling.
So, you've "fixed" some boards, but left others to suffer. Ideally, the
best fix would be to also make the card polling cheap.
Anyways, using (d) clause of the "Reviewer's statement of oversight", I
can easily give this:
Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>
:)
Thanks!
[...]
> > > IIRC, the card detection is broken SOC-revision-wise, not board-wise.
> > > So the change seems wrong.
> > >
> > > Also, take a look at this:
> > >
> > > http://lkml.org/lkml/2010/7/14/127
> > >
> > > I started the work but never finished, unfortunately it caused some
> > > regressions for non-FSL hardware...
> > >
> > > > drivers/mmc/host/sdhci-of-esdhc.c | 7 ++++++-
> > > > 1 file changed, 6 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/mmc/host/sdhci-of-esdhc.c
> > > > b/drivers/mmc/host/sdhci-of-esdhc.c
> > > > index ffc1226..5dc362f 100644
> > > > --- a/drivers/mmc/host/sdhci-of-esdhc.c
> > > > +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> > > > @@ -196,6 +196,11 @@ static void esdhc_of_detect_limitation(struct
> > > platform_device *pdev,
> > > > if (vvn == VENDOR_V_22)
> > > > pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
> > > >
> > > > + /* P4080DS and MPC837XMDS board don't support interrupt mode */
> > > > + if (of_machine_is_compatible("fsl,mpc837xmds") ||
> > > > + of_machine_is_compatible("fsl,P4080DS"))
> > > > + pdata->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> > > > +
> > > > iounmap(ioaddr);
> > > > end:
> > > > return;
> > > > @@ -223,7 +228,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata
> > > > =
> > > {
> > > > * card detection could be handled via GPIO
> > > > * eSDHC cannot support End Attribute in NOP ADMA descriptor
> > > > */
> > > > - .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION
> > > > + .quirks = ESDHC_DEFAULT_QUIRKS
> > > > | SDHCI_QUIRK_NO_CARD_NO_RESET
> > > > | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
> > > > .ops = &sdhci_esdhc_ops,
> > > > --
> > > > 1.7.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-25 10:30 ` Anton Vorontsov
@ 2012-10-26 2:42 ` Huang Changming-R66093
2012-10-27 1:12 ` Anton Vorontsov
0 siblings, 1 reply; 8+ messages in thread
From: Huang Changming-R66093 @ 2012-10-26 2:42 UTC (permalink / raw)
To: Anton Vorontsov
Cc: linux-mmc@vger.kernel.org, Chris Ball, Kumar Gala,
linuxppc-dev@lists.ozlabs.org
[-- Attachment #1: Type: text/plain, Size: 4836 bytes --]
Hi, Anton,
For the current polling mode, driver will send CMD13 to poll the card status periodically , which will cause too many interrupts.
Once I sent patches to detect the card when using polling mode last year: read the state register, instead of send CMD13. But, these patches were not accepted. Now I attach them for you.
Because these patches are not accepted, I think about the interrupt mode to detect card.
Of course, you are right, the p4080ds and mpc837xmds are still using polling mode, which just fix some boards.
The best way is for all.
Then, I will back to my previous patches, for FSL eSDHC, don't send CMD13, and just read state register to check it.
For all FSL silicones, the state bit is updated when card inserting or removing.
Now I have two ways to resolve this issue, I prefer to the polling mode (unfortunately, they are not accepted).
I will be greatly appreciated if you review these attachment patches again and give your comment.
If you think the attachment patches are OK, I will resend them to mail list.
If you don't, I will continue to work on the interrupt mode for FSL eSDHC.
Thanks.
> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Anton Vorontsov
> Sent: Thursday, October 25, 2012 6:31 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Chris Ball; Kumar Gala; linuxppc-
> dev@lists.ozlabs.org
> Subject: Re: [PATCH] powerpc/esdhc: enable the card insert/remove
> interrupt
>
> On Thu, Oct 25, 2012 at 10:05:44AM +0000, Huang Changming-R66093 wrote:
> > Hi, Anton.
> > Could you have any comment about it?
> > If not, I will resend this patch with v2.
>
> Technically, the patch looks fine.
>
> But again, as far as I recall, the card detection logic was broken on the
> SOC level (it's actually very hard to break it on the board level -- it
> would either work or not, but in the eSDHC case it was just unreliable,
> again, if I recall everything correctly -- I might be wrong).
>
> Of course you know the hardware much better, so your words weight more,
> so you don't need my ack on the patch. :)
>
> Although there's a second issue: for P4080DS and mpc837x boards you still
> have the same problem with polling method, right? It is causing
> performance drops/freezes every like 100 ms, and that's why you want to
> avoid the polling.
>
> So, you've "fixed" some boards, but left others to suffer. Ideally, the
> best fix would be to also make the card polling cheap.
>
> Anyways, using (d) clause of the "Reviewer's statement of oversight", I
> can easily give this:
>
> Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>
>
> :)
>
> Thanks!
>
> [...]
> > > > IIRC, the card detection is broken SOC-revision-wise, not board-
> wise.
> > > > So the change seems wrong.
> > > >
> > > > Also, take a look at this:
> > > >
> > > > http://lkml.org/lkml/2010/7/14/127
> > > >
> > > > I started the work but never finished, unfortunately it caused
> > > > some regressions for non-FSL hardware...
> > > >
> > > > > drivers/mmc/host/sdhci-of-esdhc.c | 7 ++++++-
> > > > > 1 file changed, 6 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/mmc/host/sdhci-of-esdhc.c
> > > > > b/drivers/mmc/host/sdhci-of-esdhc.c
> > > > > index ffc1226..5dc362f 100644
> > > > > --- a/drivers/mmc/host/sdhci-of-esdhc.c
> > > > > +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> > > > > @@ -196,6 +196,11 @@ static void
> > > > > esdhc_of_detect_limitation(struct
> > > > platform_device *pdev,
> > > > > if (vvn == VENDOR_V_22)
> > > > > pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
> > > > >
> > > > > + /* P4080DS and MPC837XMDS board don't support interrupt mode
> */
> > > > > + if (of_machine_is_compatible("fsl,mpc837xmds") ||
> > > > > + of_machine_is_compatible("fsl,P4080DS"))
> > > > > + pdata->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> > > > > +
> > > > > iounmap(ioaddr);
> > > > > end:
> > > > > return;
> > > > > @@ -223,7 +228,7 @@ static struct sdhci_pltfm_data
> > > > > sdhci_esdhc_pdata =
> > > > {
> > > > > * card detection could be handled via GPIO
> > > > > * eSDHC cannot support End Attribute in NOP ADMA descriptor
> > > > > */
> > > > > - .quirks = ESDHC_DEFAULT_QUIRKS |
> SDHCI_QUIRK_BROKEN_CARD_DETECTION
> > > > > + .quirks = ESDHC_DEFAULT_QUIRKS
> > > > > | SDHCI_QUIRK_NO_CARD_NO_RESET
> > > > > | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
> > > > > .ops = &sdhci_esdhc_ops,
> > > > > --
> > > > > 1.7.9.5
> --
> 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
[-- Attachment #2: 0002-MMC-SD-Add-callback-function-to-detect-card.patch --]
[-- Type: application/octet-stream, Size: 2094 bytes --]
From bd9be632c2ebf77ba067dbb52a8c4bd73be1697b Mon Sep 17 00:00:00 2001
From: Jerry Huang <Chang-Ming.Huang@freescale.com>
Date: Tue, 6 Dec 2011 17:22:27 +0800
Subject: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
In order to check whether the card has been removed, the function
mmc_send_status() will send command CMD13 to card and ask the card
to send its status register to sdhc driver, which will generate
many interrupts repeatedly and make the system performance bad.
Therefore, add callback function get_cd() to check whether
the card has been removed when the driver has this callback function.
If the card is present, 1 will return, if the card is absent, 0 will return.
If the controller will not support this feature, -ENOSYS will return.
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
- when controller don't support get_cd, return -ENOSYS
- add the CC
changes for v3:
- enalbe the controller clock in platform, instead of core
changes for v4:
- move the detect code to core.c according to the new structure
drivers/mmc/core/core.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 6db6621..d570c72 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
int _mmc_detect_card_removed(struct mmc_host *host)
{
- int ret;
+ int ret = -ENOSYS;
if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
return 0;
@@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
if (!host->card || mmc_card_removed(host->card))
return 1;
- ret = host->bus_ops->alive(host);
+ if (host->ops->get_cd) {
+ ret = host->ops->get_cd(host);
+ if (ret >= 0)
+ ret = !ret;
+ }
+ if (ret < 0)
+ ret = host->bus_ops->alive(host);
if (ret) {
mmc_card_set_removed(host->card);
pr_debug("%s: card remove detected\n", mmc_hostname(host));
--
1.7.5.4
[-- Attachment #3: 0003-SDHCI-add-sdhci_get_cd-callback-to-detect-the-card.patch --]
[-- Type: application/octet-stream, Size: 3102 bytes --]
From c029b98325733ea0225389612eb7b9f0f0b722cd Mon Sep 17 00:00:00 2001
From: Jerry Huang <Chang-Ming.Huang@freescale.com>
Date: Wed, 7 Dec 2011 10:41:49 +0800
Subject: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
Add callback function sdhci_get_cd to detect the card.
And one new callback added to implement the card detect in sdhci struncture.
If special platform has the card detect callback, it will return the card
state, the value zero is for absent cardi and one is for present card.
If the controller don't support card detect, sdhci_get_cd will return -ENOSYS.
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
- when controller don't support get_cd, return -ENOSYS
- add new callback for sdhci to detect the card
- add the CC
changes for v3:
- use pin_lock only when get_cd defined
changes for v4:
- enalbe the controller clock in platform, instead of core
changes for v5:
- remove the copyright
drivers/mmc/host/sdhci.c | 21 ++++++++++++++++++++++
drivers/mmc/host/sdhci.h | 2 ++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6d8eea3..fbe2f46 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1518,6 +1519,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
return ret;
}
+/* Return values for the sdjco_get_cd callback:
+ * 0 for a absent card
+ * 1 for a present card
+ * -ENOSYS when not supported (equal to NULL callback)
+ */
+static int sdhci_get_cd(struct mmc_host *mmc)
+{
+ struct sdhci_host *host = mmc_priv(mmc);
+ unsigned long flags;
+ int present = -ENOSYS;
+
+ if (host->ops->get_cd) {
+ spin_lock_irqsave(&host->lock, flags);
+ present = host->ops->get_cd(host);
+ spin_unlock_irqrestore(&host->lock, flags);
+ }
+
+ return present;
+}
+
static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable)
{
if (host->flags & SDHCI_DEVICE_DEAD)
@@ -1884,6 +1905,7 @@ static const struct mmc_host_ops sdhci_ops = {
.request = sdhci_request,
.set_ios = sdhci_set_ios,
.get_ro = sdhci_get_ro,
+ .get_cd = sdhci_get_cd,
.hw_reset = sdhci_hw_reset,
.enable_sdio_irq = sdhci_enable_sdio_irq,
.start_signal_voltage_switch = sdhci_start_signal_voltage_switch,
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0a5b654..82f4d27 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -69,6 +69,7 @@
#define SDHCI_SPACE_AVAILABLE 0x00000400
#define SDHCI_DATA_AVAILABLE 0x00000800
#define SDHCI_CARD_PRESENT 0x00010000
+#define SDHCI_CARD_CDPL 0x00040000
#define SDHCI_WRITE_PROTECT 0x00080000
#define SDHCI_DATA_LVL_MASK 0x00F00000
#define SDHCI_DATA_LVL_SHIFT 20
@@ -261,6 +262,7 @@ struct sdhci_ops {
void (*set_clock)(struct sdhci_host *host, unsigned int clock);
+ int (*get_cd)(struct sdhci_host *host);
int (*enable_dma)(struct sdhci_host *host);
unsigned int (*get_max_clock)(struct sdhci_host *host);
unsigned int (*get_min_clock)(struct sdhci_host *host);
--
1.7.5.4
[-- Attachment #4: 0004-ESDHC-add-callback-esdhc_of_get_cd-to-detect-card.patch --]
[-- Type: application/octet-stream, Size: 2480 bytes --]
From 99e41c1bacbad5e9a3418bcac2b5f778516efe6d Mon Sep 17 00:00:00 2001
From: Jerry Huang <Chang-Ming.Huang@freescale.com>
Date: Fri, 9 Dec 2011 11:06:58 +0800
Subject: [PATCH 4/4 v3] ESDHC: add callback esdhc_of_get_cd to detect card
In order to check if the card is present, we will read the PRESENT STATE
register and check the bit13(Card detect pin level) and bit15(CINS).
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
- add new callback for esdhc to detect the card state
- add the CC
changes for v3:
- enable the controller clock when detect the card state, not core
drivers/mmc/host/sdhci-of-esdhc.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 59e9d00..40da8f4 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -1,7 +1,7 @@
/*
* Freescale eSDHC controller driver.
*
- * Copyright (c) 2007, 2010 Freescale Semiconductor, Inc.
+ * Copyright (c) 2007, 2010-2011 Freescale Semiconductor, Inc.
* Copyright (c) 2009 MontaVista Software, Inc.
*
* Authors: Xiaobo Xie <X.Xie@freescale.com>
@@ -82,6 +82,28 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host)
return pltfm_host->clock / 256 / 16;
}
+/* Return: none zero - the card is presetn; 0 - card is absent */
+static int esdhc_of_get_cd(struct sdhci_host *host)
+{
+ int present;
+
+ if (host->flags & SDHCI_DEVICE_DEAD)
+ present = 0;
+ else {
+ int sysctl = sdhci_be32bs_readl(host, SDHCI_CLOCK_CONTROL);
+ /* Enable the controller clock to update the present state */
+ sdhci_be32bs_writel(host, sysctl | SDHCI_CLOCK_INT_EN,
+ SDHCI_CLOCK_CONTROL);
+ /* Detect the card present or absent */
+ present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE);
+ present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL);
+ /* Resve the previous to System control register */
+ sdhci_be32bs_writel(host, sysctl, SDHCI_CLOCK_CONTROL);
+ }
+
+ return present;
+}
+
static struct sdhci_ops sdhci_esdhc_ops = {
.read_l = sdhci_be32bs_readl,
.read_w = esdhc_readw,
@@ -93,6 +115,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
.enable_dma = esdhc_of_enable_dma,
.get_max_clock = esdhc_of_get_max_clock,
.get_min_clock = esdhc_of_get_min_clock,
+ .get_cd = esdhc_of_get_cd,
};
static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
--
1.7.5.4
[-- Attachment #5: 0001-MMC-core-Add-f_min-to-mmc_power_on.patch --]
[-- Type: application/octet-stream, Size: 1072 bytes --]
From 5abfc594fd26198df957a5710c026d8be6de4f5e Mon Sep 17 00:00:00 2001
From: Jerry Huang <Chang-Ming.Huang@freescale.com>
Date: Mon, 5 Dec 2011 14:28:31 +0800
Subject: [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on()
When f_init is zero, the SDHC can't work correctly. So f_min will replace
f_init, when f_init is zero.
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
- add the CC
changes for v3:
- enalbe the controller clock in platform, instead of core
drivers/mmc/core/core.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index a08e6b1..2d40c04 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1253,7 +1253,10 @@ static void mmc_power_up(struct mmc_host *host)
*/
mmc_delay(10);
- host->ios.clock = host->f_init;
+ if (host->f_init)
+ host->ios.clock = host->f_init;
+ else
+ host->ios.clock = host->f_min;
host->ios.power_mode = MMC_POWER_ON;
mmc_set_ios(host);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-26 2:42 ` Huang Changming-R66093
@ 2012-10-27 1:12 ` Anton Vorontsov
2012-10-29 1:40 ` Huang Changming-R66093
0 siblings, 1 reply; 8+ messages in thread
From: Anton Vorontsov @ 2012-10-27 1:12 UTC (permalink / raw)
To: Huang Changming-R66093
Cc: linux-mmc@vger.kernel.org, Chris Ball, Kumar Gala,
linuxppc-dev@lists.ozlabs.org
Hello Huang,
On Fri, Oct 26, 2012 at 02:42:36AM +0000, Huang Changming-R66093 wrote:
> For the current polling mode, driver will send CMD13 to poll the card status periodically , which will cause too many interrupts.
> Once I sent patches to detect the card when using polling mode last year: read the state register, instead of send CMD13. But, these patches were not accepted. Now I attach them for you.
Was there any specific reason why the patches didn't get accepted?
I very briefly looked at them, and they seem to be OK (there are a few
cosmetic details I'd comment on, tho -- but please send them in a normal
way (i.e. not as attachments).
Thanks,
Anton.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] powerpc/esdhc: enable the card insert/remove interrupt
2012-10-27 1:12 ` Anton Vorontsov
@ 2012-10-29 1:40 ` Huang Changming-R66093
0 siblings, 0 replies; 8+ messages in thread
From: Huang Changming-R66093 @ 2012-10-29 1:40 UTC (permalink / raw)
To: Anton Vorontsov
Cc: linux-mmc@vger.kernel.org, Chris Ball, Kumar Gala,
linuxppc-dev@lists.ozlabs.org
> Hello Huang,
>
> On Fri, Oct 26, 2012 at 02:42:36AM +0000, Huang Changming-R66093 wrote:
> > For the current polling mode, driver will send CMD13 to poll the card
> status periodically , which will cause too many interrupts.
> > Once I sent patches to detect the card when using polling mode last
> year: read the state register, instead of send CMD13. But, these patches
> were not accepted. Now I attach them for you.
>
> Was there any specific reason why the patches didn't get accepted?
>
> I very briefly looked at them, and they seem to be OK (there are a few
> cosmetic details I'd comment on, tho -- but please send them in a normal
> way (i.e. not as attachments).
>
Thanks, Anton.
I don't know why.
I will resend these patches based on latest kernel.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-10-29 1:40 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-23 7:01 [PATCH] powerpc/esdhc: enable the card insert/remove interrupt r66093
2012-10-23 8:26 ` Anton Vorontsov
2012-10-23 8:39 ` Huang Changming-R66093
2012-10-25 10:05 ` Huang Changming-R66093
2012-10-25 10:30 ` Anton Vorontsov
2012-10-26 2:42 ` Huang Changming-R66093
2012-10-27 1:12 ` Anton Vorontsov
2012-10-29 1:40 ` Huang Changming-R66093
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).