All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: usdhi6rol0: Implement card_busy function
@ 2021-08-16 12:52 Mårten Lindahl
  2021-08-16 13:57 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Mårten Lindahl @ 2021-08-16 12:52 UTC (permalink / raw)
  To: Jesper Nilsson, Lars Persson, Ulf Hansson
  Cc: kernel, linux-arm-kernel, linux-mmc, Mårten Lindahl

When switching card voltage to UHS voltage the mmc framework tries to
check the card busy signal, meaning the card pulling DAT0 line low,
before the switch is made. Drivers that does not implement the card_busy
function will manage to do the switch anyway, but the framework will
print a warning about not being able to verify the voltage signal.

Implement card_busy function.

Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
---

v2:
 - Update commit message, since interface limitation for checking DAT
   lines is not valid for this fix.
 - Skip check of SCLKDIVEN bit, and skip check of DAT3 line since SD
   specification only points out checking DAT0 for busy signal.
 - Update comment about card_busy callback.

 drivers/mmc/host/usdhi6rol0.c | 10 ++++++++++
 include/linux/mmc/host.h      |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index b9b79b1089a0..b5ab133e9add 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -1186,6 +1186,15 @@ static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 	return ret;
 }
 
+static int usdhi6_card_busy(struct mmc_host *mmc)
+{
+	struct usdhi6_host *host = mmc_priv(mmc);
+	u32 tmp = usdhi6_read(host, USDHI6_SD_INFO2);
+
+	/* Card is busy if it is pulling dat[0] low */
+	return !(tmp & USDHI6_SD_INFO2_SDDAT0);
+}
+
 static const struct mmc_host_ops usdhi6_ops = {
 	.request	= usdhi6_request,
 	.set_ios	= usdhi6_set_ios,
@@ -1193,6 +1202,7 @@ static const struct mmc_host_ops usdhi6_ops = {
 	.get_ro		= usdhi6_get_ro,
 	.enable_sdio_irq = usdhi6_enable_sdio_irq,
 	.start_signal_voltage_switch = usdhi6_sig_volt_switch,
+	.card_busy = usdhi6_card_busy,
 };
 
 /*			State machine handlers				*/
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 0abd47e9ef9b..ff1a251bb0bc 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -153,7 +153,7 @@ struct mmc_host_ops {
 
 	int	(*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
 
-	/* Check if the card is pulling dat[0:3] low */
+	/* Check if the card is pulling dat[0] low */
 	int	(*card_busy)(struct mmc_host *host);
 
 	/* The tuning command opcode value is different for SD and eMMC cards */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mmc: usdhi6rol0: Implement card_busy function
  2021-08-16 12:52 [PATCH v2] mmc: usdhi6rol0: Implement card_busy function Mårten Lindahl
@ 2021-08-16 13:57 ` Ulf Hansson
  2021-08-16 14:08   ` Marten Lindahl
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2021-08-16 13:57 UTC (permalink / raw)
  To: Mårten Lindahl
  Cc: Jesper Nilsson, Lars Persson, kernel, linux-arm-kernel, linux-mmc

On Mon, 16 Aug 2021 at 14:53, Mårten Lindahl <marten.lindahl@axis.com> wrote:
>
> When switching card voltage to UHS voltage the mmc framework tries to
> check the card busy signal, meaning the card pulling DAT0 line low,
> before the switch is made. Drivers that does not implement the card_busy
> function will manage to do the switch anyway, but the framework will
> print a warning about not being able to verify the voltage signal.
>
> Implement card_busy function.
>
> Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
> ---
>
> v2:
>  - Update commit message, since interface limitation for checking DAT
>    lines is not valid for this fix.
>  - Skip check of SCLKDIVEN bit, and skip check of DAT3 line since SD
>    specification only points out checking DAT0 for busy signal.
>  - Update comment about card_busy callback.
>
>  drivers/mmc/host/usdhi6rol0.c | 10 ++++++++++
>  include/linux/mmc/host.h      |  2 +-

The change looks good to me, but I would be even happier if you could
split this into two patches. Would you mind?

Kind regards
Uffe

>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> index b9b79b1089a0..b5ab133e9add 100644
> --- a/drivers/mmc/host/usdhi6rol0.c
> +++ b/drivers/mmc/host/usdhi6rol0.c
> @@ -1186,6 +1186,15 @@ static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>         return ret;
>  }
>
> +static int usdhi6_card_busy(struct mmc_host *mmc)
> +{
> +       struct usdhi6_host *host = mmc_priv(mmc);
> +       u32 tmp = usdhi6_read(host, USDHI6_SD_INFO2);
> +
> +       /* Card is busy if it is pulling dat[0] low */
> +       return !(tmp & USDHI6_SD_INFO2_SDDAT0);
> +}
> +
>  static const struct mmc_host_ops usdhi6_ops = {
>         .request        = usdhi6_request,
>         .set_ios        = usdhi6_set_ios,
> @@ -1193,6 +1202,7 @@ static const struct mmc_host_ops usdhi6_ops = {
>         .get_ro         = usdhi6_get_ro,
>         .enable_sdio_irq = usdhi6_enable_sdio_irq,
>         .start_signal_voltage_switch = usdhi6_sig_volt_switch,
> +       .card_busy = usdhi6_card_busy,
>  };
>
>  /*                     State machine handlers                          */
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 0abd47e9ef9b..ff1a251bb0bc 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -153,7 +153,7 @@ struct mmc_host_ops {
>
>         int     (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
>
> -       /* Check if the card is pulling dat[0:3] low */
> +       /* Check if the card is pulling dat[0] low */
>         int     (*card_busy)(struct mmc_host *host);
>
>         /* The tuning command opcode value is different for SD and eMMC cards */
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mmc: usdhi6rol0: Implement card_busy function
  2021-08-16 13:57 ` Ulf Hansson
@ 2021-08-16 14:08   ` Marten Lindahl
  0 siblings, 0 replies; 3+ messages in thread
From: Marten Lindahl @ 2021-08-16 14:08 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Mårten Lindahl, Jesper Nilsson, Lars Persson, kernel,
	linux-arm-kernel, linux-mmc

On Mon, Aug 16, 2021 at 03:57:18PM +0200, Ulf Hansson wrote:
> On Mon, 16 Aug 2021 at 14:53, Mårten Lindahl <marten.lindahl@axis.com> wrote:
> >
> > When switching card voltage to UHS voltage the mmc framework tries to
> > check the card busy signal, meaning the card pulling DAT0 line low,
> > before the switch is made. Drivers that does not implement the card_busy
> > function will manage to do the switch anyway, but the framework will
> > print a warning about not being able to verify the voltage signal.
> >
> > Implement card_busy function.
> >
> > Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
> > ---
> >
> > v2:
> >  - Update commit message, since interface limitation for checking DAT
> >    lines is not valid for this fix.
> >  - Skip check of SCLKDIVEN bit, and skip check of DAT3 line since SD
> >    specification only points out checking DAT0 for busy signal.
> >  - Update comment about card_busy callback.
> >
> >  drivers/mmc/host/usdhi6rol0.c | 10 ++++++++++
> >  include/linux/mmc/host.h      |  2 +-
> 
> The change looks good to me, but I would be even happier if you could
> split this into two patches. Would you mind?
> 
> Kind regards
> Uffe

Ok, yes I can do that. I will send a separate patch for updating the
header file.

Kind regards
Mårten

> 
> >  2 files changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> > index b9b79b1089a0..b5ab133e9add 100644
> > --- a/drivers/mmc/host/usdhi6rol0.c
> > +++ b/drivers/mmc/host/usdhi6rol0.c
> > @@ -1186,6 +1186,15 @@ static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> >         return ret;
> >  }
> >
> > +static int usdhi6_card_busy(struct mmc_host *mmc)
> > +{
> > +       struct usdhi6_host *host = mmc_priv(mmc);
> > +       u32 tmp = usdhi6_read(host, USDHI6_SD_INFO2);
> > +
> > +       /* Card is busy if it is pulling dat[0] low */
> > +       return !(tmp & USDHI6_SD_INFO2_SDDAT0);
> > +}
> > +
> >  static const struct mmc_host_ops usdhi6_ops = {
> >         .request        = usdhi6_request,
> >         .set_ios        = usdhi6_set_ios,
> > @@ -1193,6 +1202,7 @@ static const struct mmc_host_ops usdhi6_ops = {
> >         .get_ro         = usdhi6_get_ro,
> >         .enable_sdio_irq = usdhi6_enable_sdio_irq,
> >         .start_signal_voltage_switch = usdhi6_sig_volt_switch,
> > +       .card_busy = usdhi6_card_busy,
> >  };
> >
> >  /*                     State machine handlers                          */
> > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> > index 0abd47e9ef9b..ff1a251bb0bc 100644
> > --- a/include/linux/mmc/host.h
> > +++ b/include/linux/mmc/host.h
> > @@ -153,7 +153,7 @@ struct mmc_host_ops {
> >
> >         int     (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
> >
> > -       /* Check if the card is pulling dat[0:3] low */
> > +       /* Check if the card is pulling dat[0] low */
> >         int     (*card_busy)(struct mmc_host *host);
> >
> >         /* The tuning command opcode value is different for SD and eMMC cards */
> > --
> > 2.20.1
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-16 14:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 12:52 [PATCH v2] mmc: usdhi6rol0: Implement card_busy function Mårten Lindahl
2021-08-16 13:57 ` Ulf Hansson
2021-08-16 14:08   ` Marten Lindahl

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.