public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: Do not poll using CMD13 when changing timing
Date: Mon, 11 Feb 2019 07:56:09 +0100	[thread overview]
Message-ID: <20190211075609.2f449d8d@jawa> (raw)
In-Reply-To: <20190206131123.24384-1-marek.vasut+renesas@gmail.com>

Hi Marek,

> When using CMD6 to switch eMMC card timing from HS200/HS400 to
> HS/legacy, do not poll for the completion status using CMD13, but
> rather wait 50mS.

Nit: mS -> ms

> 
> Once the card receives the CMD6 and starts executing it, the bus is in
> undefined state until both the card finishes executing the command and
> until the controller switches the bus to matching timing
> configuration. During this time, it is not possible to transport any
> commands or data across the bus, which includes the CMD13.

Just out of curiosity - is this 50ms time written in some spec? Or is
it only specific to Renesas HS200/HS400 ?

> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> ---
> NOTE: Linux does the same thing.
> ---
>  drivers/mmc/mmc.c | 28 ++++++++++++++++++++--------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index c7730c9233..ababacf65a 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -720,7 +720,8 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8
> *ext_csd) return err;
>  }
>  
> -int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
> +static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
> +			bool send_status)
>  {
>  	struct mmc_cmd cmd;
>  	int timeout = 1000;
> @@ -736,19 +737,29 @@ int mmc_switch(struct mmc *mmc, u8 set, u8
> index, u8 value) while (retries > 0) {
>  		ret = mmc_send_cmd(mmc, &cmd, NULL);
>  
> -		/* Waiting for the ready status */
> -		if (!ret) {
> -			ret = mmc_send_status(mmc, timeout);
> -			return ret;
> +		if (ret) {
> +			retries--;
> +			continue;
> +		}
> +
> +		if (!send_status) {
> +			mdelay(50);
> +			return 0;
>  		}
>  
> -		retries--;
> +		/* Waiting for the ready status */
> +		return mmc_send_status(mmc, timeout);
>  	}
>  
>  	return ret;
>  
>  }
>  
> +int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
> +{
> +	return __mmc_switch(mmc, set, index, value, true);
> +}
> +
>  #if !CONFIG_IS_ENABLED(MMC_TINY)
>  static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,
>  			      bool hsdowngrade)
> @@ -780,8 +791,9 @@ static int mmc_set_card_speed(struct mmc *mmc,
> enum bus_mode mode, default:
>  		return -EINVAL;
>  	}
> -	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
> EXT_CSD_HS_TIMING,
> -			 speed_bits);
> +
> +	err = __mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
> EXT_CSD_HS_TIMING,
> +			   speed_bits, !hsdowngrade);
>  	if (err)
>  		return err;
>  




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190211/46c2b9f6/attachment.sig>

  parent reply	other threads:[~2019-02-11  6:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06 13:11 [U-Boot] [PATCH] mmc: Do not poll using CMD13 when changing timing Marek Vasut
2019-02-06 13:14 ` Jean-Jacques Hiblot
2019-02-11  6:56 ` Lukasz Majewski [this message]
2019-06-25 14:13 ` Jean-Jacques Hiblot
2019-06-25 15:53   ` Marek Vasut
2019-06-25 19:07     ` Jean-Jacques Hiblot
2019-06-25 19:47       ` Marek Vasut
2019-06-26  9:22         ` Jean-Jacques Hiblot
2019-06-26  9:50           ` Marek Vasut
2019-06-26 12:21             ` Jean-Jacques Hiblot
2019-06-26 13:09               ` Marek Vasut

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=20190211075609.2f449d8d@jawa \
    --to=lukma@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox