All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ibai Erkiaga Elorza <IBAIE@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: implement SDHCI card detect
Date: Fri, 31 May 2019 13:27:24 +0000	[thread overview]
Message-ID: <CH2PR02MB63753322CF9CA9FE3DC5F6C7D1190@CH2PR02MB6375.namprd02.prod.outlook.com> (raw)
In-Reply-To: <15d9c03a-51c7-64aa-8f19-5914a08d372f@xilinx.com>

Hi Michal,

> -----Original Message-----
> From: Michal Simek <michal.simek@xilinx.com>
> Sent: 27 May 2019 06:53
> To: Ibai Erkiaga Elorza <IBAIE@xilinx.com>; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH] mmc: implement SDHCI card detect
> 
> On 23. 05. 19 15:54, Ibai Erkiaga wrote:
> > Card detect function implemented for SDHCI framework.
> >
> > Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@xilinx.com>
> > ---
> >
> >  drivers/mmc/sdhci.c | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index
> > e2bb90a..cb4db8d 100644
> > --- a/drivers/mmc/sdhci.c
> > +++ b/drivers/mmc/sdhci.c
> > @@ -390,6 +390,21 @@ static int sdhci_send_command(struct mmc *mmc,
> struct mmc_cmd *cmd,
> >  		return -ECOMM;
> >  }
> >
> > +#if IS_ENABLED(CONFIG_DM_MMC)
> > +static int sdhci_get_cd(struct udevice *dev) {
> > +	struct mmc *mmc = mmc_get_mmc_dev(dev); #else static int
> > +sdhci_get_cd(struct mmc *mmc) { #endif
> > +	u32 state;
> > +	struct sdhci_host *host = mmc->priv;
> > +
> > +	state = sdhci_readl(host, SDHCI_PRESENT_STATE);
> > +	return (state & SDHCI_CARD_PRESENT);
> 
> This should be much more robust. It should at least handle cases where you
> have broken-cd, cd-gpios, cd-inverted cases.
> This code will likely work with boards which have CD connected properly but
> it is enabled for all which will cause a lot of issues.
> 
You are right, this implementation is quite basic and the idea was just to get rid-off the polling message for the golden use case (properly connected CD).

> If you want to add this functionality one by one then new Kconfig should be
> used but I am not big fan of that.
> 
The broken-cd Kconfig is already in the MMC framework so I would say that you can use this implementation if your CD is properly connected and just stay as current implementation using CONFIG_MMC_BROKEN_CD.

> > +}
> > +
> >  #if defined(CONFIG_DM_MMC) && defined(MMC_SUPPORTS_TUNING)
> static
> > int sdhci_execute_tuning(struct udevice *dev, uint opcode)  { @@
> > -627,6 +642,7 @@ int sdhci_probe(struct udevice *dev)  const struct
> > dm_mmc_ops sdhci_ops = {
> >  	.send_cmd	= sdhci_send_command,
> >  	.set_ios	= sdhci_set_ios,
> > +	.get_cd		= sdhci_get_cd,
> >  #ifdef MMC_SUPPORTS_TUNING
> >  	.execute_tuning	= sdhci_execute_tuning,
> >  #endif
> > @@ -635,6 +651,7 @@ const struct dm_mmc_ops sdhci_ops = {  static
> > const struct mmc_ops sdhci_ops = {
> >  	.send_cmd	= sdhci_send_command,
> >  	.set_ios	= sdhci_set_ios,
> > +	.get_cd		= sdhci_get_cd,
> >  	.init		= sdhci_init,
> >  };
> >  #endif
> >
> 
> Thanks,
> Michal

Thanks,
Ibai

  reply	other threads:[~2019-05-31 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 13:54 [U-Boot] [PATCH] mmc: implement SDHCI card detect Ibai Erkiaga
2019-05-27  5:52 ` Michal Simek
2019-05-31 13:27   ` Ibai Erkiaga Elorza [this message]
2019-06-03  7:32     ` Michal Simek

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=CH2PR02MB63753322CF9CA9FE3DC5F6C7D1190@CH2PR02MB6375.namprd02.prod.outlook.com \
    --to=ibaie@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.