* [PATCH 3/3] mmc: Add ESDHC weird register workaround
@ 2010-07-28 5:54 Roy Zang
2010-07-28 8:03 ` Anton Vorontsov
0 siblings, 1 reply; 4+ messages in thread
From: Roy Zang @ 2010-07-28 5:54 UTC (permalink / raw)
To: linux-mmc-approval; +Cc: linuxppc-dev
P4080 ESDHC controller induces weird register setting.
This patch adds the workaround to correct the weird register setting.
Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
---
drivers/mmc/host/sdhci-of-core.c | 5 +++++
drivers/mmc/host/sdhci.c | 13 +++++++++++++
drivers/mmc/host/sdhci.h | 2 ++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/host/sdhci-of-core.c b/drivers/mmc/host/sdhci-of-core.c
index 0c30242..1b6945a 100644
--- a/drivers/mmc/host/sdhci-of-core.c
+++ b/drivers/mmc/host/sdhci-of-core.c
@@ -164,6 +164,11 @@ static int __devinit sdhci_of_probe(struct of_device *ofdev,
if (sdhci_of_wp_inverted(np))
host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
+ if (of_device_is_compatible(np, "fsl,p4080-esdhc")) {
+ host->quirks |= SDHCI_QUIRK_QORIQ_REG_WEIRD;
+ host->quirks &= ~SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
+ }
+
clk = of_get_property(np, "clock-frequency", &size);
if (clk && size == sizeof(*clk) && *clk)
of_host->clock = *clk;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 1424d08..b5b3627 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -788,6 +788,15 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
}
+ /* The default value of DMAS bits of Protocol Control Register is not
+ * correct. clear these two bits to use simple DMA */
+#define ESDHCI_CTRL_DMAS_MASK 0xFFFFFCFF
+ if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD) {
+ ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
+ ctrl = ctrl & ESDHCI_CTRL_DMAS_MASK;
+ sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
+ }
+
if (!(host->flags & SDHCI_REQ_USE_DMA)) {
int flags;
@@ -1699,6 +1708,10 @@ int sdhci_add_host(struct sdhci_host *host)
caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+ /* Workaround for P4080 host controller capabilities */
+ if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD)
+ caps &= ~(SDHCI_CAN_VDD_180 | SDHCI_CAN_VDD_330);
+
if (host->quirks & SDHCI_QUIRK_FORCE_DMA)
host->flags |= SDHCI_USE_SDMA;
else if (!(caps & SDHCI_CAN_DO_SDMA))
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index aa112aa..33d5613 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -243,6 +243,8 @@ struct sdhci_host {
#define SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC (1<<26)
/* Controller uses Auto CMD12 command to stop the transfer */
#define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<27)
+/* Controller has weird bit setting for some registers due to errata */
+#define SDHCI_QUIRK_QORIQ_REG_WEIRD (1<<28)
int irq; /* Device IRQ */
void __iomem * ioaddr; /* Mapped address */
--
1.5.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] mmc: Add ESDHC weird register workaround
2010-07-28 5:54 [PATCH 3/3] mmc: Add ESDHC weird register workaround Roy Zang
@ 2010-07-28 8:03 ` Anton Vorontsov
2010-07-28 9:43 ` Zang Roy-R61911
0 siblings, 1 reply; 4+ messages in thread
From: Anton Vorontsov @ 2010-07-28 8:03 UTC (permalink / raw)
To: Roy Zang; +Cc: linuxppc-dev, linux-mmc-approval
On Wed, Jul 28, 2010 at 01:54:21PM +0800, Roy Zang wrote:
> P4080 ESDHC controller induces weird register setting.
> This patch adds the workaround to correct the weird register setting.
>
> Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
> ---
> drivers/mmc/host/sdhci-of-core.c | 5 +++++
> drivers/mmc/host/sdhci.c | 13 +++++++++++++
> drivers/mmc/host/sdhci.h | 2 ++
> 3 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-core.c b/drivers/mmc/host/sdhci-of-core.c
> index 0c30242..1b6945a 100644
> --- a/drivers/mmc/host/sdhci-of-core.c
> +++ b/drivers/mmc/host/sdhci-of-core.c
> @@ -164,6 +164,11 @@ static int __devinit sdhci_of_probe(struct of_device *ofdev,
> if (sdhci_of_wp_inverted(np))
> host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
>
> + if (of_device_is_compatible(np, "fsl,p4080-esdhc")) {
> + host->quirks |= SDHCI_QUIRK_QORIQ_REG_WEIRD;
> + host->quirks &= ~SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
You do not mention this change in the patch description, why?
> + }
> +
> clk = of_get_property(np, "clock-frequency", &size);
> if (clk && size == sizeof(*clk) && *clk)
> of_host->clock = *clk;
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 1424d08..b5b3627 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -788,6 +788,15 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
> sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> }
>
> + /* The default value of DMAS bits of Protocol Control Register is not
> + * correct. clear these two bits to use simple DMA */
> +#define ESDHCI_CTRL_DMAS_MASK 0xFFFFFCFF
> + if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD) {
> + ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
> + ctrl = ctrl & ESDHCI_CTRL_DMAS_MASK;
> + sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
> + }
You should implement register quirks via SDHCI IO accessors.
See esdhc_writew() for example.
> if (!(host->flags & SDHCI_REQ_USE_DMA)) {
> int flags;
>
> @@ -1699,6 +1708,10 @@ int sdhci_add_host(struct sdhci_host *host)
>
> caps = sdhci_readl(host, SDHCI_CAPABILITIES);
>
> + /* Workaround for P4080 host controller capabilities */
> + if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD)
> + caps &= ~(SDHCI_CAN_VDD_180 | SDHCI_CAN_VDD_330);
Ditto. Make a quirk for cap register. Or implement
SDHCI_QUIRK_NO_VDD_180 and SDHCI_QUIRK_NO_VDD_300 quirks
instead.
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 3/3] mmc: Add ESDHC weird register workaround
2010-07-28 8:03 ` Anton Vorontsov
@ 2010-07-28 9:43 ` Zang Roy-R61911
2010-07-30 7:37 ` Anton Vorontsov
0 siblings, 1 reply; 4+ messages in thread
From: Zang Roy-R61911 @ 2010-07-28 9:43 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: linuxppc-dev, linux-mmc
=20
> -----Original Message-----
> From: Anton Vorontsov [mailto:cbouatmailru@gmail.com]=20
> Sent: Wednesday, July 28, 2010 16:03 PM
> To: Zang Roy-R61911
> Cc: linux-mmc-approval@vger.kernel.org; linuxppc-dev@ozlabs.org
> Subject: Re: [PATCH 3/3] mmc: Add ESDHC weird register workaround
>=20
> On Wed, Jul 28, 2010 at 01:54:21PM +0800, Roy Zang wrote:
> > P4080 ESDHC controller induces weird register setting.
> > This patch adds the workaround to correct the weird=20
> register setting.
> >=20
> > Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
> > ---
> > drivers/mmc/host/sdhci-of-core.c | 5 +++++
> > drivers/mmc/host/sdhci.c | 13 +++++++++++++
> > drivers/mmc/host/sdhci.h | 2 ++
> > 3 files changed, 20 insertions(+), 0 deletions(-)
> >=20
> > diff --git a/drivers/mmc/host/sdhci-of-core.c=20
> b/drivers/mmc/host/sdhci-of-core.c
> > index 0c30242..1b6945a 100644
> > --- a/drivers/mmc/host/sdhci-of-core.c
> > +++ b/drivers/mmc/host/sdhci-of-core.c
> > @@ -164,6 +164,11 @@ static int __devinit=20
> sdhci_of_probe(struct of_device *ofdev,
> > if (sdhci_of_wp_inverted(np))
> > host->quirks |=3D SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
> > =20
> > + if (of_device_is_compatible(np, "fsl,p4080-esdhc")) {
> > + host->quirks |=3D SDHCI_QUIRK_QORIQ_REG_WEIRD;
> > + host->quirks &=3D ~SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
>=20
> You do not mention this change in the patch description, why?
This is not needed any more. Will be removed.
>=20
> > + }
> > +
> > clk =3D of_get_property(np, "clock-frequency", &size);
> > if (clk && size =3D=3D sizeof(*clk) && *clk)
> > of_host->clock =3D *clk;
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > index 1424d08..b5b3627 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -788,6 +788,15 @@ static void sdhci_prepare_data(struct=20
> sdhci_host *host, struct mmc_data *data)
> > sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> > }
> > =20
> > + /* The default value of DMAS bits of Protocol Control=20
> Register is not
> > + * correct. clear these two bits to use simple DMA */
> > +#define ESDHCI_CTRL_DMAS_MASK 0xFFFFFCFF
> > + if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD) {
> > + ctrl =3D sdhci_readl(host, SDHCI_HOST_CONTROL);
> > + ctrl =3D ctrl & ESDHCI_CTRL_DMAS_MASK;
> > + sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
> > + }
>=20
> You should implement register quirks via SDHCI IO accessors.
What does you mean "SDHCI IO accessors?
It makes more sense to define something like:
SDHCI_QUIRK_QORIQ_PROCTL_WEIRD.
Any comment?
>=20
> See esdhc_writew() for example.
>=20
> > if (!(host->flags & SDHCI_REQ_USE_DMA)) {
> > int flags;
> > =20
> > @@ -1699,6 +1708,10 @@ int sdhci_add_host(struct sdhci_host *host)
> > =20
> > caps =3D sdhci_readl(host, SDHCI_CAPABILITIES);
> > =20
> > + /* Workaround for P4080 host controller capabilities */
> > + if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD)
> > + caps &=3D ~(SDHCI_CAN_VDD_180 | SDHCI_CAN_VDD_330);
>=20
> Ditto. Make a quirk for cap register. Or implement
> SDHCI_QUIRK_NO_VDD_180 and SDHCI_QUIRK_NO_VDD_300 quirks
> instead.
Second proposal more makes sense to me.
Thanks.
Roy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] mmc: Add ESDHC weird register workaround
2010-07-28 9:43 ` Zang Roy-R61911
@ 2010-07-30 7:37 ` Anton Vorontsov
0 siblings, 0 replies; 4+ messages in thread
From: Anton Vorontsov @ 2010-07-30 7:37 UTC (permalink / raw)
To: Zang Roy-R61911; +Cc: linuxppc-dev, linux-mmc
On Wed, Jul 28, 2010 at 05:43:00PM +0800, Zang Roy-R61911 wrote:
[...]
> > > + /* The default value of DMAS bits of Protocol Control
> > Register is not
> > > + * correct. clear these two bits to use simple DMA */
> > > +#define ESDHCI_CTRL_DMAS_MASK 0xFFFFFCFF
> > > + if (host->quirks & SDHCI_QUIRK_QORIQ_REG_WEIRD) {
> > > + ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
> > > + ctrl = ctrl & ESDHCI_CTRL_DMAS_MASK;
> > > + sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
> > > + }
> >
> > You should implement register quirks via SDHCI IO accessors.
> What does you mean "SDHCI IO accessors?
See drivers/mmc/host/sdhci-of-esdhc.c
struct sdhci_of_data sdhci_esdhc = {
...
.ops = {
...
.write_l = sdhci_be32bs_writel,
...
},
};
You can implement your own write_l and put the quirk in
there, as we do for esdhc_readw, esdhc_writew, etc.
OTOH, as you say it has wrong default value, not behaviour,
so I think you can just initialize the HOST_CONTROL register
just once somewhere in sdhci-of-esdhc, e.g. ->enable_dma
callback?
> It makes more sense to define something like:
> SDHCI_QUIRK_QORIQ_PROCTL_WEIRD.
I don't think so.
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-30 7:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-28 5:54 [PATCH 3/3] mmc: Add ESDHC weird register workaround Roy Zang
2010-07-28 8:03 ` Anton Vorontsov
2010-07-28 9:43 ` Zang Roy-R61911
2010-07-30 7:37 ` Anton Vorontsov
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).