[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <221381ebad0236625775bda5655fcd7c78455e6f.camel@yadro.com>
Date: Fri, 15 Nov 2019 15:56:54 +0300
From: Ivan Mikhaylov <i.mikhaylov@...ro.com>
To: Adrian Hunter <adrian.hunter@...el.com>
CC: Joel Stanley <joel@....id.au>, Andrew Jeffery <andrew@...id.au>,
"Rob Herring" <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
"Ulf Hansson" <ulf.hansson@...aro.org>,
<devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-aspeed@...ts.ozlabs.org>, <linux-kernel@...r.kernel.org>,
<linux-mmc@...r.kernel.org>, <openbmc@...ts.ozlabs.org>
Subject: Re: [PATCH v2 2/2] mmc: sdhci-of-aspeed: add inversion signal
presence
On Fri, 2019-11-15 at 09:20 +0200, Adrian Hunter wrote:
> On 14/11/19 7:19 PM, Ivan Mikhaylov wrote:
> > On Thu, 2019-11-14 at 15:10 +0200, Adrian Hunter wrote:
> > On 14/11/19 2:54 PM, Ivan Mikhaylov wrote:
> > > > Change the default .get_cd callback. Add inverted signal card detection
> > > > check.
> > > >
> > > > Signed-off-by: Ivan Mikhaylov <i.mikhaylov@...ro.com>
> > > >
> > > > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c
> > > > b/drivers/mmc/host/sdhci-of-
> > > > aspeed.c
> > > > index 8962f6664381..186559ee8fcc 100644
> > > > --- a/drivers/mmc/host/sdhci-of-aspeed.c
> > > > +++ b/drivers/mmc/host/sdhci-of-aspeed.c
> > > > @@ -143,6 +143,19 @@ static inline int
> > > > aspeed_sdhci_calculate_slot(struct
> > > > aspeed_sdhci *dev,
> > > > return (delta / 0x100) - 1;
> > > > }
> > > >
> > > > +static int aspeed_get_cd(struct mmc_host *mmc)
> > > > +{
> > > > + struct sdhci_host *host = mmc_priv(mmc);
> > > > +
> > > > + int present = !!(sdhci_readl(host, SDHCI_PRESENT_STATE)
> > > > + & SDHCI_CARD_PRESENT);
> > > > +
> > > > + if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
> > > > + present = !present;
> > >
> > > Perhaps safer to flip the bit using CONFIG_MMC_SDHCI_IO_ACCESSORS and
> > > ->readl() callback
>
>
> > Sorry, don't quite understand what you're saying. You want to instantiate
> > '.read_l' callback instead of '.get_cd' in sdhci_ops and substitute the real
> > value?
> >
> > res = readl(base, reg);
> > if (reg == SDHCI_PRESENT_STATE)
> > if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
> > return !res;
>
> Presumably just flip the SDHCI_CARD_PRESENT bit i.e.
>
> return res ^ SDHCI_CARD_PRESENT;
>
> > return res;
> >
> > Something like this?
>
> Yes
>
Don't you think it will bring a little overhead on any sdhci_readl plus
sdhci_readl will not get the real value in case of inverted signal which seems
is not right from communication fairness between hw and sw? I took that approach
with .get_cd from variety of drivers in host/mmc but if you think it will be
better and safer with .read_l - I'll do that way.
Sorry for the link in subject, didn't notice that I put it in previous message
somehow.
Thanks.
Powered by blists - more mailing lists