From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ivan Mikhaylov Subject: Re: [PATCH v2 2/2] mmc: sdhci-of-aspeed: add inversion sighttps://elixir.bootlin.com/linux/v4.6/ident/sdhci_opsnal presence Date: Thu, 14 Nov 2019 20:19:31 +0300 Message-ID: References: <20191114125435.27756-1-i.mikhaylov@yadro.com> <20191114125435.27756-3-i.mikhaylov@yadro.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Adrian Hunter Cc: Joel Stanley , Andrew Jeffery , Rob Herring , Mark Rutland , Ulf Hansson , 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 List-Id: linux-mmc@vger.kernel.org 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 > > > > 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; return res; Something like this? > > > + host->mmc_host_ops.get_cd = aspeed_get_cd; > > + if (of_property_read_bool(pdev->dev.of_node, "cd-inverted")) > > + dev_info(&pdev->dev, "aspeed: sdhci: presence signal inversion > > enabled\n"); > > Is this print really needed? > I can remove it if you think it's redundant. Thanks.