diff mbox series

[U-Boot,v2,07/11] mmc: use the generic timeout for cmd6 (SWITCH) provided in the ext_csd

Message ID 20190702085358.27368-8-jjhiblot@ti.com
State Accepted
Commit 39320c537def08bafa07ef3dd0f519465e56d57d
Delegated to: Peng Fan
Headers show
Series Improvements on the MMC switch | expand

Commit Message

Jean-Jacques Hiblot July 2, 2019, 8:53 a.m. UTC
Starting with rev 4.5, the eMMC can define a generic timeout for the
SWITCH command.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

Changes in v2: None

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

Comments

Peng Fan July 10, 2019, 5:51 a.m. UTC | #1
Hi Jean,

> -----Original Message-----
> From: Jean-Jacques Hiblot [mailto:jjhiblot@ti.com]
> Sent: 2019年7月2日 16:54
> To: marek.vasut@gmail.com
> Cc: Jean-Jacques Hiblot <jjhiblot@ti.com>; Jon Nettleton
> <jon@solid-run.com>; Peng Fan <peng.fan@nxp.com>; Marek Vasut
> <marek.vasut+renesas@gmail.com>; u-boot@lists.denx.de; Baruch Siach
> <baruch@tkos.co.il>; Jens Wiklander <jens.wiklander@linaro.org>; Rajesh
> Bhagat <rajesh.bhagat@nxp.com>
> Subject: [PATCH v2 07/11] mmc: use the generic timeout for cmd6 (SWITCH)
> provided in the ext_csd
> 
> Starting with rev 4.5, the eMMC can define a generic timeout for the SWITCH
> command.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
> 
> Changes in v2: None
> 
>  drivers/mmc/mmc.c | 10 +++++++++-
>  include/mmc.h     |  2 ++
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index
> a61e311cca..ff56c3dd67 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -21,6 +21,8 @@
>  #include <div64.h>
>  #include "mmc_private.h"
> 
> +#define DEFAULT_CMD6_TIMEOUT_MS  500
> +
>  static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
> static int mmc_power_cycle(struct mmc *mmc);
> #if !CONFIG_IS_ENABLED(MMC_TINY) @@ -745,10 +747,13 @@ static int
> __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
>  			bool send_status)
>  {
>  	struct mmc_cmd cmd;
> -	int timeout = 1000;
> +	int timeout = DEFAULT_CMD6_TIMEOUT_MS;

Is this expected to change 1000->500?

Regards,
Peng.

>  	int retries = 3;
>  	int ret;
> 
> +	if (mmc->gen_cmd6_time)
> +		timeout = mmc->gen_cmd6_time * 10;
> +
>  	cmd.cmdidx = MMC_CMD_SWITCH;
>  	cmd.resp_type = MMC_RSP_R1b;
>  	cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | @@
> -2135,6 +2140,9 @@ static int mmc_startup_v4(struct mmc *mmc)
>  			mmc->capacity_user = capacity;
>  	}
> 
> +	if (mmc->version >= MMC_VERSION_4_5)
> +		mmc->gen_cmd6_time =
> ext_csd[EXT_CSD_GENERIC_CMD6_TIME];
> +
>  	/* The partition data may be non-zero but it is only
>  	 * effective if PARTITION_SETTING_COMPLETED is set in
>  	 * EXT_CSD, so ignore any data if this bit is not set, diff --git
> a/include/mmc.h b/include/mmc.h index 854778deed..8159ef1448 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -226,6 +226,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
>  #define EXT_CSD_HC_WP_GRP_SIZE		221	/* RO */
>  #define EXT_CSD_HC_ERASE_GRP_SIZE	224	/* RO */
>  #define EXT_CSD_BOOT_MULT		226	/* RO */
> +#define EXT_CSD_GENERIC_CMD6_TIME       248     /* RO */
>  #define EXT_CSD_BKOPS_SUPPORT		502	/* RO */
> 
>  /*
> @@ -581,6 +582,7 @@ struct mmc {
>  	u8 part_attr;
>  	u8 wr_rel_set;
>  	u8 part_config;
> +	u8 gen_cmd6_time;
>  	uint tran_speed;
>  	uint legacy_speed; /* speed for the legacy mode provided by the card */
>  	uint read_bl_len;
> --
> 2.17.1
Jean-Jacques Hiblot July 10, 2019, 8 a.m. UTC | #2
Hi Peng,

On 10/07/2019 07:51, Peng Fan wrote:
> Hi Jean,
>
>> -----Original Message-----
>> From: Jean-Jacques Hiblot [mailto:jjhiblot@ti.com]
>> Sent: 2019年7月2日 16:54
>> To: marek.vasut@gmail.com
>> Cc: Jean-Jacques Hiblot <jjhiblot@ti.com>; Jon Nettleton
>> <jon@solid-run.com>; Peng Fan <peng.fan@nxp.com>; Marek Vasut
>> <marek.vasut+renesas@gmail.com>; u-boot@lists.denx.de; Baruch Siach
>> <baruch@tkos.co.il>; Jens Wiklander <jens.wiklander@linaro.org>; Rajesh
>> Bhagat <rajesh.bhagat@nxp.com>
>> Subject: [PATCH v2 07/11] mmc: use the generic timeout for cmd6 (SWITCH)
>> provided in the ext_csd
>>
>> Starting with rev 4.5, the eMMC can define a generic timeout for the SWITCH
>> command.
>>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> ---
>>
>> Changes in v2: None
>>
>>   drivers/mmc/mmc.c | 10 +++++++++-
>>   include/mmc.h     |  2 ++
>>   2 files changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index
>> a61e311cca..ff56c3dd67 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -21,6 +21,8 @@
>>   #include <div64.h>
>>   #include "mmc_private.h"
>>
>> +#define DEFAULT_CMD6_TIMEOUT_MS  500
>> +
>>   static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
>> static int mmc_power_cycle(struct mmc *mmc);
>> #if !CONFIG_IS_ENABLED(MMC_TINY) @@ -745,10 +747,13 @@ static int
>> __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
>>   			bool send_status)
>>   {
>>   	struct mmc_cmd cmd;
>> -	int timeout = 1000;
>> +	int timeout = DEFAULT_CMD6_TIMEOUT_MS;
> Is this expected to change 1000->500?

Yes. The 500ms timeout value directly comes from the linux driver.

>
> Regards,
> Peng.
>
>>   	int retries = 3;
>>   	int ret;
>
Peng Fan July 10, 2019, 8:07 a.m. UTC | #3
> Subject: Re: [PATCH v2 07/11] mmc: use the generic timeout for cmd6
> (SWITCH) provided in the ext_csd
> 
> Hi Peng,
> 
> On 10/07/2019 07:51, Peng Fan wrote:
> > Hi Jean,
> >
> >> -----Original Message-----
> >> From: Jean-Jacques Hiblot [mailto:jjhiblot@ti.com]
> >> Sent: 2019年7月2日 16:54
> >> To: marek.vasut@gmail.com
> >> Cc: Jean-Jacques Hiblot <jjhiblot@ti.com>; Jon Nettleton
> >> <jon@solid-run.com>; Peng Fan <peng.fan@nxp.com>; Marek Vasut
> >> <marek.vasut+renesas@gmail.com>; u-boot@lists.denx.de; Baruch Siach
> >> <baruch@tkos.co.il>; Jens Wiklander <jens.wiklander@linaro.org>;
> >> Rajesh Bhagat <rajesh.bhagat@nxp.com>
> >> Subject: [PATCH v2 07/11] mmc: use the generic timeout for cmd6
> >> (SWITCH) provided in the ext_csd
> >>
> >> Starting with rev 4.5, the eMMC can define a generic timeout for the
> >> SWITCH command.
> >>
> >> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> >> ---
> >>
> >> Changes in v2: None
> >>
> >>   drivers/mmc/mmc.c | 10 +++++++++-
> >>   include/mmc.h     |  2 ++
> >>   2 files changed, 11 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index
> >> a61e311cca..ff56c3dd67 100644
> >> --- a/drivers/mmc/mmc.c
> >> +++ b/drivers/mmc/mmc.c
> >> @@ -21,6 +21,8 @@
> >>   #include <div64.h>
> >>   #include "mmc_private.h"
> >>
> >> +#define DEFAULT_CMD6_TIMEOUT_MS  500
> >> +
> >>   static int mmc_set_signal_voltage(struct mmc *mmc, uint
> >> signal_voltage); static int mmc_power_cycle(struct mmc *mmc); #if
> >> !CONFIG_IS_ENABLED(MMC_TINY) @@ -745,10 +747,13 @@ static int
> >> __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
> >>   			bool send_status)
> >>   {
> >>   	struct mmc_cmd cmd;
> >> -	int timeout = 1000;
> >> +	int timeout = DEFAULT_CMD6_TIMEOUT_MS;
> > Is this expected to change 1000->500?
> 
> Yes. The 500ms timeout value directly comes from the linux driver.

ok. If no objections to your patchset, I'll add such info to this patch later.

Regards,
Peng.

> 
> >
> > Regards,
> > Peng.
> >
> >>   	int retries = 3;
> >>   	int ret;
> >
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index a61e311cca..ff56c3dd67 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -21,6 +21,8 @@ 
 #include <div64.h>
 #include "mmc_private.h"
 
+#define DEFAULT_CMD6_TIMEOUT_MS  500
+
 static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
 static int mmc_power_cycle(struct mmc *mmc);
 #if !CONFIG_IS_ENABLED(MMC_TINY)
@@ -745,10 +747,13 @@  static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
 			bool send_status)
 {
 	struct mmc_cmd cmd;
-	int timeout = 1000;
+	int timeout = DEFAULT_CMD6_TIMEOUT_MS;
 	int retries = 3;
 	int ret;
 
+	if (mmc->gen_cmd6_time)
+		timeout = mmc->gen_cmd6_time * 10;
+
 	cmd.cmdidx = MMC_CMD_SWITCH;
 	cmd.resp_type = MMC_RSP_R1b;
 	cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
@@ -2135,6 +2140,9 @@  static int mmc_startup_v4(struct mmc *mmc)
 			mmc->capacity_user = capacity;
 	}
 
+	if (mmc->version >= MMC_VERSION_4_5)
+		mmc->gen_cmd6_time = ext_csd[EXT_CSD_GENERIC_CMD6_TIME];
+
 	/* The partition data may be non-zero but it is only
 	 * effective if PARTITION_SETTING_COMPLETED is set in
 	 * EXT_CSD, so ignore any data if this bit is not set,
diff --git a/include/mmc.h b/include/mmc.h
index 854778deed..8159ef1448 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -226,6 +226,7 @@  static inline bool mmc_is_tuning_cmd(uint cmdidx)
 #define EXT_CSD_HC_WP_GRP_SIZE		221	/* RO */
 #define EXT_CSD_HC_ERASE_GRP_SIZE	224	/* RO */
 #define EXT_CSD_BOOT_MULT		226	/* RO */
+#define EXT_CSD_GENERIC_CMD6_TIME       248     /* RO */
 #define EXT_CSD_BKOPS_SUPPORT		502	/* RO */
 
 /*
@@ -581,6 +582,7 @@  struct mmc {
 	u8 part_attr;
 	u8 wr_rel_set;
 	u8 part_config;
+	u8 gen_cmd6_time;
 	uint tran_speed;
 	uint legacy_speed; /* speed for the legacy mode provided by the card */
 	uint read_bl_len;