From: Ivan Mikhaylov <i.mikhaylov@yadro.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-mmc@vger.kernel.org, openbmc@lists.ozlabs.org
Subject: Re: [PATCH v2 2/2] mmc: sdhci-of-aspeed: add inversion signal presence
Date: Fri, 15 Nov 2019 15:56:54 +0300 [thread overview]
Message-ID: <221381ebad0236625775bda5655fcd7c78455e6f.camel@yadro.com> (raw)
In-Reply-To: <d177ef37-643e-442d-d536-750e0bb5e86d@intel.com>
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@yadro.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.
next prev parent reply other threads:[~2019-11-15 12:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 12:54 [PATCH v2 0/2] add inversion signal presence support Ivan Mikhaylov
2019-11-14 12:54 ` [PATCH v2 1/2] aspeed: dts: add sd card for vesnin Ivan Mikhaylov
2019-11-14 12:54 ` [PATCH v2 2/2] mmc: sdhci-of-aspeed: add inversion signal presence Ivan Mikhaylov
2019-11-14 13:10 ` Adrian Hunter
2019-11-14 17:19 ` [PATCH v2 2/2] mmc: sdhci-of-aspeed: add inversion sighttps://elixir.bootlin.com/linux/v4.6/ident/sdhci_opsnal presence Ivan Mikhaylov
2019-11-15 7:20 ` Adrian Hunter
2019-11-15 12:56 ` Ivan Mikhaylov [this message]
2019-11-15 13:17 ` [PATCH v2 2/2] mmc: sdhci-of-aspeed: add inversion signal presence Adrian Hunter
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=221381ebad0236625775bda5655fcd7c78455e6f.camel@yadro.com \
--to=i.mikhaylov@yadro.com \
--cc=adrian.hunter@intel.com \
--cc=andrew@aj.id.au \
--cc=devicetree@vger.kernel.org \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=openbmc@lists.ozlabs.org \
--cc=robh+dt@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).