mmc: sd: UHS-I bus speed should be set last in UHS initialization
Subsystems (2)
PATCH 1/1 mmc: sd: UHS-I bus speed should be set last in UHS initialization
mmc_sd_init_uhs_card function sets the driver type, current limit and bus speed mode on card as well as on host controller side.
Currently bus speed mode is set by sending CMD6 to card and immediately setting the timing mode in host controller. But then before initiating tuning sequence, it also tries to set current limit by sending CMD6 to card which results in data timeout errors in controller if bus speed mode is SDR50/SDR104 mode.
So basically bus speed mode should be set only after current limit is set in the card and immediately after setting the bus speed mode, tuning sequence should be initiated.
--- drivers/mmc/core/sd.c | 57 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 38 insertions(+), 19 deletions(-)
drivers/mmc/core/sd.c +38 -19
@@ -459,10 +459,9 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)return 0 ; } -static int sd_set_bus_speed_mode (struct mmc_card *card,u8 *status) +static int sd_get_bus_speed_mode (struct mmc_card *card) { -unsigned int bus_speed =0 , timing =0 ; -int err; +int bus_speed =0 ;/* * If the host doesn't support any of the UHS-I modes, fallback on
@@ -470,37 +469,56 @@ static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)*/ if (!(card->host->caps & (MMC_CAP_UHS_SDR12 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_DDR50 ))) -return 0 ; +return -EINVAL ;if ((card->host->caps &MMC_CAP_UHS_SDR104 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 )) { bus_speed =UHS_SDR104_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR104 ; - card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; }else if ((card->host->caps &MMC_CAP_UHS_DDR50 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_DDR50 )) { bus_speed =UHS_DDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_DDR50 ; - card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR50 )) { bus_speed =UHS_SDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR50 ; - card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR25 )) { bus_speed =UHS_SDR25_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR25 ; - card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR12 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR12 )) { bus_speed =UHS_SDR12_BUS_SPEED ; + } + +return bus_speed; +} + +static int sd_set_bus_speed_mode (struct mmc_card *card,u8 *status) +{ +int err, bus_speed; +unsigned int timing =0 ; + + bus_speed =sd_get_bus_speed_mode (card); + +if (bus_speed ==UHS_SDR104_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR104 ; + card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; + }else if (bus_speed ==UHS_DDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_DDR50 ; + card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR50 ; + card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR25_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR25 ; + card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; + }else if (bus_speed ==UHS_SDR12_BUS_SPEED ) { timing =MMC_TIMING_UHS_SDR12 ; card->sw_caps.uhs_max_dtr =UHS_SDR12_MAX_DTR ; + }else { +return -EINVAL ; } card->sd_bus_speed = bus_speed;
@@ -522,6 +540,7 @@ static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)static int sd_set_current_limit (struct mmc_card *card,u8 *status) {int current_limit =0 ; +unsigned int bus_speed =sd_get_bus_speed_mode (card);int err;/*
@@ -529,9 +548,9 @@ static int sd_set_current_limit(struct mmc_card *card, u8 *status)* bus speed modes. For other bus speed modes, we set the default * current limit of 200mA. */ -if ((card->sd_bus_speed ==UHS_SDR50_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_SDR104_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_DDR50_BUS_SPEED )) { +if ((bus_speed ==UHS_SDR50_BUS_SPEED ) || + (bus_speed ==UHS_SDR104_BUS_SPEED ) || + (bus_speed ==UHS_DDR50_BUS_SPEED )) {if (card->host->caps &MMC_CAP_MAX_CURRENT_800 ) {if (card->sw_caps.sd3_curr_limit &SD_MAX_CURRENT_800 ) current_limit =SD_SET_CURRENT_LIMIT_800 ;
@@ -613,13 +632,13 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)if (err) goto out; -/* Set bus speed mode of the card */ - err =sd_set_bus_speed_mode (card, status); +/* Set current limit for the card */ + err =sd_set_current_limit (card, status);if (err) goto out; -/* Set current limit for the card */ - err =sd_set_current_limit (card, status); +/* Set bus speed mode of the card */ + err =sd_set_bus_speed_mode (card, status);if (err) goto out;
Signature · 5 lines
1.7.1.1 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Hi Subhash, adding Arindam for review,
Quoted 89 lines · Subhash Jadavani
mmc_sd_init_uhs_cardfunction sets the driver type, current limit and bus speed mode on card as well as on host controller side.Currently bus speed mode is set by sending CMD6 to card and immediately setting the timing mode in host controller. But then before initiating tuning sequence, it also tries to set current limit by sending CMD6 to card which results in data timeout errors in controller if bus speed mode is SDR50/SDR104 mode.
So basically bus speed mode should be set only after current limit is set in the card and immediately after setting the bus speed mode, tuning sequence should be initiated.
Signed-off-by Subhash Jadavani <[email protected]>--- drivers/mmc/core/sd.c | 57 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 38 insertions(+), 19 deletions(-)drivers/mmc/core/sd.c +23
-12@@ -459,10 +459,9 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)return 0 ; } -static int sd_set_bus_speed_mode (struct mmc_card *card,u8 *status) +static int sd_get_bus_speed_mode (struct mmc_card *card) { -unsigned int bus_speed =0 , timing =0 ; -int err; +int bus_speed =0 ;/* * If the host doesn't support any of the UHS-I modes, fallback on @@ -470,37 +469,56 @@ static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)*/ if (!(card->host->caps & (MMC_CAP_UHS_SDR12 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_DDR50 ))) -return 0 ; +return -EINVAL ;if ((card->host->caps &MMC_CAP_UHS_SDR104 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 )) { bus_speed =UHS_SDR104_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR104 ; - card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; }else if ((card->host->caps &MMC_CAP_UHS_DDR50 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_DDR50 )) { bus_speed =UHS_DDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_DDR50 ; - card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR50 )) { bus_speed =UHS_SDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR50 ; - card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR25 )) { bus_speed =UHS_SDR25_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR25 ; - card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR12 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR12 )) { bus_speed =UHS_SDR12_BUS_SPEED ; + } + +return bus_speed; +} + +static int sd_set_bus_speed_mode (struct mmc_card *card,u8 *status) +{ +int err, bus_speed; +unsigned int timing =0 ; + + bus_speed =sd_get_bus_speed_mode (card); + +if (bus_speed ==UHS_SDR104_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR104 ; + card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; + }else if (bus_speed ==UHS_DDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_DDR50 ; + card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR50 ;
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 522
Quoted 10 lines
drivers/mmc/core/sd.c +7
-0+ card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR25_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR25 ; + card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; + }else if (bus_speed ==UHS_SDR12_BUS_SPEED ) { timing =MMC_TIMING_UHS_SDR12 ; card->sw_caps.uhs_max_dtr =UHS_SDR12_MAX_DTR ; + }else { +return -EINVAL ; }
Minor change: I think "switch (sd_get_bus_speed_mode(card))" would be cleaner.
Quoted 31 lines
drivers/mmc/core/sd.c +6
-5card->sd_bus_speed = bus_speed;@@ -522,6 +540,7 @@ static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)static int sd_set_current_limit (struct mmc_card *card,u8 *status) {int current_limit =0 ; +unsigned int bus_speed =sd_get_bus_speed_mode (card);int err;/* @@ -529,9 +548,9 @@ static int sd_set_current_limit(struct mmc_card *card, u8 *status)* bus speed modes. For other bus speed modes, we set the default * current limit of 200mA. */ -if ((card->sd_bus_speed ==UHS_SDR50_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_SDR104_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_DDR50_BUS_SPEED )) { +if ((bus_speed ==UHS_SDR50_BUS_SPEED ) || + (bus_speed ==UHS_SDR104_BUS_SPEED ) || + (bus_speed ==UHS_DDR50_BUS_SPEED )) {if (card->host->caps &MMC_CAP_MAX_CURRENT_800 ) {if (card->sw_caps.sd3_curr_limit &SD_MAX_CURRENT_800 ) current_limit =SD_SET_CURRENT_LIMIT_800 ;@@ -613,13 +632,13 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)if (err) goto out; -/* Set bus speed mode of the card */ - err =sd_set_bus_speed_mode (card, status); +/* Set current limit for the card */ + err =sd_set_current_limit (card, status);
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 644
Quoted 10 lines
drivers/mmc/core/sd.c +2
-2if (err) goto out; -/* Set current limit for the card */ - err =sd_set_current_limit (card, status); +/* Set bus speed mode of the card */ + err =sd_set_bus_speed_mode (card, status);if (err) goto out;
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Hi Subhash,
Quoted 50 lines
-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 1:40 AM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; Nath, Arindam
Subject: Re: [PATCH] mmc: sd: UHS-I bus speed should be set last in UHS initializationHi Subhash, adding Arindam for review,
Quoted 9 lines · Subhash Jadavani
mmc_sd_init_uhs_cardfunction sets the driver type, current limit and bus speed mode on card as well as on host controller side.Currently bus speed mode is set by sending CMD6 to card and immediately setting the timing mode in host controller. But then before initiating tuning sequence, it also tries to set current limit by sending CMD6 to card which results in data timeout errors in controller if bus speed mode is SDR50/SDR104 mode.
Quoted 7 lines
So basically bus speed mode should be set only after current limit is set in the card and immediately after setting the bus speed mode, tuning sequence should be initiated.
Signed-off-by Subhash Jadavani <[email protected]>--- drivers/mmc/core/sd.c | 57 ++++++++++++++++++++++++++++++++----------------
drivers/mmc/core/sd.c static int sd_select_driver_type(struct mmc_card
Quoted 7 lines
1 files changed, 38 insertions(+), 19 deletions(-)drivers/mmc/core/sd.c +0
-0@@ -459,10 +459,9 @@ static int sd_select_driver_type(struct mmc_card*card, u8 *status)
drivers/mmc/core/sd.c static int sd_select_driver_type(struct mmc_card *card, u8 *status)
Quoted 12 lines
drivers/mmc/core/sd.c +2
-3return 0 ; } -static int sd_set_bus_speed_mode (struct mmc_card *card,u8 *status) +static int sd_get_bus_speed_mode (struct mmc_card *card) { -unsigned int bus_speed =0 , timing =0 ; -int err; +int bus_speed =0 ;/* * If the host doesn't support any of the UHS-I modes, fallback on
Quoted 7 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 1 line
drivers/mmc/core/sd.c +0
-0@@ -470,37 +469,56 @@ static int sd_set_bus_speed_mode(struct
mmc_card*card, u8 *status)drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 472
Quoted 5 lines
drivers/mmc/core/sd.c +1
-1*/ if (!(card->host->caps & (MMC_CAP_UHS_SDR12 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_DDR50 ))) -return 0 ; +return -EINVAL ;
We should not return -EINVAL here, because this is not an error condition. This would simply mean that the card and host controller will fall back to using the default bus speed, and should still be operable. Check the comment below too.
Quoted 100 lines
Quoted 48 lines
drivers/mmc/core/sd.c +20
-8if ((card->host->caps &MMC_CAP_UHS_SDR104 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 )) { bus_speed =UHS_SDR104_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR104 ; - card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; }else if ((card->host->caps &MMC_CAP_UHS_DDR50 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_DDR50 )) { bus_speed =UHS_DDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_DDR50 ; - card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR50 )) { bus_speed =UHS_SDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR50 ; - card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR25 )) { bus_speed =UHS_SDR25_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR25 ; - card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR12 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR12 )) { bus_speed =UHS_SDR12_BUS_SPEED ; + } + +return bus_speed; +} + +static int sd_set_bus_speed_mode (struct mmc_card *card,u8 *status) +{ +int err, bus_speed; +unsigned int timing =0 ; + + bus_speed =sd_get_bus_speed_mode (card); + +if (bus_speed ==UHS_SDR104_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR104 ; + card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; + }else if (bus_speed ==UHS_DDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_DDR50 ; + card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR50 ;drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 522
Quoted 10 lines
drivers/mmc/core/sd.c +7
-0+ card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR25_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR25 ; + card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; + }else if (bus_speed ==UHS_SDR12_BUS_SPEED ) { timing =MMC_TIMING_UHS_SDR12 ; card->sw_caps.uhs_max_dtr =UHS_SDR12_MAX_DTR ; + }else { +return -EINVAL ; }Minor change: I think "switch (
sd_get_bus_speed_mode(card))" would be cleaner.drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0card->sd_bus_speed = bus_speed;@@ -522,6 +540,7 @@ static int sd_set_bus_speed_mode(struct mmc_card*card, u8 *status)
drivers/mmc/core/sd.c static int sd_set_current_limit(struct mmc_card
Quoted 8 lines
drivers/mmc/core/sd.c +1
-0static int sd_set_current_limit (struct mmc_card *card,u8 *status) {int current_limit =0 ; +unsigned int bus_speed =sd_get_bus_speed_mode (card);int err;/* @@ -529,9 +548,9 @@ static int sd_set_current_limit(struct mmc_card*card, u8 *status)
drivers/mmc/core/sd.c static int sd_set_current_limit(struct mmc_card *card, u8 *status)
Quoted 11 lines
drivers/mmc/core/sd.c +3
-3* bus speed modes. For other bus speed modes, we set the default * current limit of 200mA. */ -if ((card->sd_bus_speed ==UHS_SDR50_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_SDR104_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_DDR50_BUS_SPEED )) { +if ((bus_speed ==UHS_SDR50_BUS_SPEED ) || + (bus_speed ==UHS_SDR104_BUS_SPEED ) || + (bus_speed ==UHS_DDR50_BUS_SPEED )) {if (card->host->caps &MMC_CAP_MAX_CURRENT_800 ) { if (card->sw_caps.sd3_curr_limit &
SD_MAX_CURRENT_800)drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card
Quoted 2 lines
drivers/mmc/core/sd.c +0
-0current_limit =SD_SET_CURRENT_LIMIT_800 ;@@ -613,13 +632,13 @@ static int mmc_sd_init_uhs_card(struct mmc_card*card)
Quoted 10 lines
drivers/mmc/core/sd.c +2
-2if (err) goto out; -/* Set bus speed mode of the card */ - err =sd_set_bus_speed_mode (card, status); +/* Set current limit for the card */ + err =sd_set_current_limit (card, status);if (err) goto out;
Quoted 4 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 641
Quoted 4 lines
drivers/mmc/core/sd.c +2
-2-/* Set current limit for the card */ - err =sd_set_current_limit (card, status); +/* Set bus speed mode of the card */ + err =sd_set_bus_speed_mode (card, status);
Now supposing that we return -EINVAL here, then that would imply that mmc_sd_init_uhs_card() failed, but that should not be the case. Like I mentioned before, the card should still be operable using default speed mode.
Thanks,
Arindam
Quoted 10 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 634
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0if (err) goto out;Thanks,
- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child
Hi Arindam,
Thank you for the review. Please find few comments inline.
Quoted 70 lines
-----Original Message-----
From: Nath, Arindam [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 12:38 PM
To: Chris Ball; Subhash Jadavani
Cc: [email protected]; [email protected]; Philip Rakity; zhangfei gao
Subject: RE: [PATCH] mmc: sd: UHS-I bus speed should be set last in UHS initializationHi Subhash,
Quoted 7 lines
-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 1:40 AM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; Nath, Arindam
Subject: Re: [PATCH] mmc: sd: UHS-I bus speed should be set last inUHS
Quoted 13 lines
initialization
Hi Subhash, adding Arindam for review,
Quoted 8 lines · Subhash Jadavani
mmc_sd_init_uhs_cardfunction sets the driver type, current limit and bus speed mode on card as well as on host controller side.Currently bus speed mode is set by sending CMD6 to card and immediately setting the timing mode in host controller. But then before initiating tuning sequence, it also tries to set current limit by sending CMD6 to card which results in data timeout errors in controller if bus speed mode is SDR50/SDR104
mode.
Quoted 3 lines
Quoted 3 lines
So basically bus speed mode should be set only after current limit is set in the card and immediately after setting the bus speed
mode,
Quoted 5 lines
Quoted 5 lines
tuning sequence should be initiated.
Signed-off-by Subhash Jadavani <[email protected]>--- drivers/mmc/core/sd.c | 57 ++++++++++++++++++++++++++++++++-------
Quoted 8 lines
---------
drivers/mmc/core/sd.c static int sd_select_driver_type(struct
Quoted 7 lines
1 files changed, 38 insertions(+), 19 deletions(-)drivers/mmc/core/sd.c +0
-0@@ -459,10 +459,9 @@ static int sd_select_driver_type(struct
mmc_cardQuoted 5 lines
*card, u8 *status)
Quoted 4 lines
drivers/mmc/core/sd.c +0
-1return 0 ; } -static int sd_set_bus_speed_mode(struct mmc_card *card, u8*status)
Quoted 11 lines
drivers/mmc/core/sd.c static int sd_select_driver_type(struct mmc_card *card, u8 *status)
Quoted 8 lines
drivers/mmc/core/sd.c +2
-2+static int sd_get_bus_speed_mode (struct mmc_card *card) { -unsigned int bus_speed =0 , timing =0 ; -int err; +int bus_speed =0 ;/* * If the host doesn't support any of the UHS-I modes, fallback on
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 1 line
drivers/mmc/core/sd.c +0
-0@@ -470,37 +469,56 @@ static int sd_set_bus_speed_mode(struct
mmc_card*card, u8 *status)
Quoted 10 lines
Quoted 5 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 472
Quoted 5 lines
drivers/mmc/core/sd.c +1
-1*/ if (!(card->host->caps & (MMC_CAP_UHS_SDR12 |MMC_CAP_UHS_SDR25 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_DDR50 ))) -return 0 ; +return -EINVAL ;We should not return
-EINVALhere, because this is not an error condition. This would simply mean that the card and host controller will fall back to using the default bus speed, and should still be operable. Check the comment below too.
Return value of this function gets used in sd_set_bus_speed_mode() function and compared against all the valid bus speed modes. If we choose to return 0 from here then '0' corresponds to valid bus speed mode 'UHS_SDR12_BUS_SPEED'.
#define UHS_SDR12_BUS_SPEED 0 #define UHS_SDR25_BUS_SPEED 1 #define UHS_SDR50_BUS_SPEED 2 #define UHS_SDR104_BUS_SPEED 3 #define UHS_DDR50_BUS_SPEED 4
If we don't want to return the error value from this function then we can basically remove following check from this *get* function and move it to each *set* function before calling *get*. Please see more comments inline in *set* functions below.
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return -EINVAL;
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
drivers/mmc/core/sd.c +0
-8if ((card->host->caps &MMC_CAP_UHS_SDR104 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 )) { bus_speed =UHS_SDR104_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR104 ; - card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; }else if ((card->host->caps &MMC_CAP_UHS_DDR50 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_DDR50 )) { bus_speed =UHS_DDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_DDR50 ; - card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR50 )) { bus_speed =UHS_SDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR50 ; - card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; }else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR25 )) { bus_speed =UHS_SDR25_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR25 ; - card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR12)) && (card->sw_caps.sd3_bus_mode &Quoted 8 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 8 lines
drivers/mmc/core/sd.c +6
-0SD_MODE_UHS_SDR12)) { bus_speed =UHS_SDR12_BUS_SPEED ; + } + +return bus_speed; +} + +static int sd_set_bus_speed_mode(struct mmc_card *card, u8*status)
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 502
Quoted 4 lines
drivers/mmc/core/sd.c +4
-0+{ +int err, bus_speed; +unsigned int timing =0 ; +
We need add this check here.
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return 0;
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/mmc/core/sd.c +15
-0+ bus_speed =sd_get_bus_speed_mode (card); + +if (bus_speed ==UHS_SDR104_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR104 ; + card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; + }else if (bus_speed ==UHS_DDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_DDR50 ; + card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR50 ; + card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR25_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR25 ; + card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; + }else if (bus_speed ==UHS_SDR12_BUS_SPEED ) {
Quoted 8 lines
Quoted 8 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 522
Quoted 5 lines
drivers/mmc/core/sd.c +2
-0timing =MMC_TIMING_UHS_SDR12 ; card->sw_caps.uhs_max_dtr =UHS_SDR12_MAX_DTR ; + }else { +return -EINVAL ; }Minor change: I think "switch (
sd_get_bus_speed_mode(card))" would be cleaner.
Yes, we can replace it with switch. I will do it next patch rev.
Quoted 11 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 4 lines
drivers/mmc/core/sd.c +0
-0card->sd_bus_speed = bus_speed;@@ -522,6 +540,7 @@ static int sd_set_bus_speed_mode(struct
mmc_cardQuoted 6 lines
*card, u8 *status)
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 544
Quoted 5 lines
drivers/mmc/core/sd.c +1
-0static int sd_set_current_limit (struct mmc_card *card,u8 *status) {int current_limit =0 ; +unsigned int bus_speed =sd_get_bus_speed_mode (card);int err;
We need add this check here.
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return 0;
Quoted 30 lines
Quoted 16 lines
drivers/mmc/core/sd.c static int sd_set_current_limit(struct mmc_card
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0/* @@ -529,9 +548,9 @@ static int sd_set_current_limit(struct mmc_card*card, u8 *status)
drivers/mmc/core/sd.c static int sd_set_current_limit(struct mmc_card *card, u8 *status)
Quoted 11 lines
drivers/mmc/core/sd.c +3
-3* bus speed modes. For other bus speed modes, we set the default * current limit of 200mA. */ -if ((card->sd_bus_speed ==UHS_SDR50_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_SDR104_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_DDR50_BUS_SPEED )) { +if ((bus_speed ==UHS_SDR50_BUS_SPEED ) || + (bus_speed ==UHS_SDR104_BUS_SPEED ) || + (bus_speed ==UHS_DDR50_BUS_SPEED )) {if (card->host->caps &MMC_CAP_MAX_CURRENT_800 ) { if (card->sw_caps.sd3_curr_limit &
SD_MAX_CURRENT_800)Quoted 2 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct
Quoted 2 lines
drivers/mmc/core/sd.c +0
-0current_limit =SD_SET_CURRENT_LIMIT_800 ;@@ -613,13 +632,13 @@ static int mmc_sd_init_uhs_card(struct
mmc_cardQuoted 11 lines
*card)
Quoted 10 lines
drivers/mmc/core/sd.c +2
-2if (err) goto out; -/* Set bus speed mode of the card */ - err =sd_set_bus_speed_mode (card, status); +/* Set current limit for the card */ + err =sd_set_current_limit (card, status);if (err) goto out;
Quoted 9 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 641
Quoted 4 lines
drivers/mmc/core/sd.c +2
-2-/* Set current limit for the card */ - err =sd_set_current_limit (card, status); +/* Set bus speed mode of the card */ + err =sd_set_bus_speed_mode (card, status);Now supposing that we return
-EINVALhere, then that would imply thatmmc_sd_init_uhs_card()failed, but that should not be the case. Like I mentioned before, the card should still be operable using default speed mode.
When you say Default speed mode, does it mean SDR12 mode?
Thanks,
Subhash
Quoted 15 lines
Thanks,
ArindamQuoted 10 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 634
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0if (err) goto out;Thanks,
- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child
Quoted 123 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 2:43 PM
To: Nath, Arindam; 'Chris Ball'
Cc: [email protected]; [email protected]; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: [PATCH] mmc: sd: UHS-I bus speed should be set last in UHS initializationHi Arindam,
Thank you for the review. Please find few comments inline.
Quoted 7 lines
-----Original Message-----
From: Nath, Arindam [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 12:38 PM
To: Chris Ball; Subhash Jadavani
Cc: [email protected]; [email protected]; Philip Rakity; zhangfei gao
Subject: RE: [PATCH] mmc: sd: UHS-I bus speed should be set last inUHS
Quoted 21 lines
initialization
Hi Subhash,
Quoted 7 lines
-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 1:40 AM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; Nath, Arindam
Subject: Re: [PATCH] mmc: sd: UHS-I bus speed should be set last inUHS
Quoted 8 lines
initialization
Hi Subhash, adding Arindam for review,
Quoted 3 lines · Subhash Jadavani
mmc_sd_init_uhs_cardfunction sets the driver type, current limit and bus speed mode on card as well as on host controller side.Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Currently bus speed mode is set by sending CMD6 to card and immediately setting the timing mode in host controller. But then before initiating tuning sequence, it also tries to set current limit by sending CMD6 to card which results in data timeout errors in controller if bus speed mode is SDR50/SDR104
mode.
Quoted 2 lines
Quoted 2 lines
So basically bus speed mode should be set only after current
limit
Quoted 7 lines
Quoted 1 line
Quoted 1 line
is set in the card and immediately after setting the bus speed
mode,
Quoted 5 lines
Quoted 5 lines
tuning sequence should be initiated.
Signed-off-by Subhash Jadavani <[email protected]>--- drivers/mmc/core/sd.c | 57 ++++++++++++++++++++++++++++++++-----
Quoted 16 lines
--
Quoted 8 lines
---------
drivers/mmc/core/sd.c static int sd_select_driver_type(struct
Quoted 7 lines
1 files changed, 38 insertions(+), 19 deletions(-)drivers/mmc/core/sd.c +0
-0@@ -459,10 +459,9 @@ static int sd_select_driver_type(struct
mmc_cardQuoted 5 lines
*card, u8 *status)
Quoted 4 lines
drivers/mmc/core/sd.c +0
-1return 0 ; } -static int sd_set_bus_speed_mode(struct mmc_card *card, u8*status)
Quoted 8 lines
Quoted 8 lines
drivers/mmc/core/sd.c static int sd_select_driver_type(struct mmc_card *card, u8 *status)
Quoted 8 lines
drivers/mmc/core/sd.c +2
-2+static int sd_get_bus_speed_mode (struct mmc_card *card) { -unsigned int bus_speed =0 , timing =0 ; -int err; +int bus_speed =0 ;/* * If the host doesn't support any of the UHS-I modes, fallback
Quoted 5 lines
Quoted 5 lines
on
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 1 line
drivers/mmc/core/sd.c +0
-0@@ -470,37 +469,56 @@ static int sd_set_bus_speed_mode(struct
mmc_card*card, u8 *status)Quoted 2 lines
drivers/mmc/core/sd.c +0
-0*/ if (!(card->host->caps & (MMC_CAP_UHS_SDR12 |
MMC_CAP_UHS_SDR25|Quoted 1 line
Quoted 1 line
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct · line 471
Quoted 1 line
drivers/mmc/core/sd.c +0
-0MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
MMC_CAP_UHS_DDR50)))Quoted 7 lines
Quoted 2 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct · line 472
Quoted 2 lines
drivers/mmc/core/sd.c +1
-1-return 0 ; +return -EINVAL ;We should not return
-EINVALhere, because this is not an error condition. This would simply mean that the card and host controller will fall back to using the default bus speed, and should still be operable. Check the comment below too.Return value of this function gets used in
sd_set_bus_speed_mode()function
and compared against all the valid bus speed modes. If we choose to return 0
from here then '0' corresponds to valid bus speed mode 'UHS_SDR12_BUS_SPEED'.#define UHS_SDR12_BUS_SPEED 0 #define UHS_SDR25_BUS_SPEED 1 #define UHS_SDR50_BUS_SPEED 2 #define UHS_SDR104_BUS_SPEED 3 #define UHS_DDR50_BUS_SPEED 4If we don't want to return the error value from this function then we can
basically remove following check from this *get* function and move it to
each *set* function before calling *get*. Please see more comments inline in
*set* functions below.
Quoted 3 lines
if (!(card->host->caps & (
MMC_CAP_UHS_SDR12|MMC_CAP_UHS_SDR25|MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return -EINVAL;
By *Default Bus Speed*, I meant speed corresponding to SDR12. So if we return 0 from sd_get_bus_speed_mode(), that would make sure that your modified sd_set_bus_speed_mode() correctly executes the last *else if* condition, and we set the default speed. So I don't think we will need to return -EINVAL.
Quoted 48 lines
Quoted 10 lines
Quoted 10 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 10 lines
drivers/mmc/core/sd.c +0
-2if ((card->host->caps &MMC_CAP_UHS_SDR104 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 )) { bus_speed =UHS_SDR104_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR104 ; - card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; }else if ((card->host->caps &MMC_CAP_UHS_DDR50 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_DDR50 )){
Quoted 6 lines
Quoted 5 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 5 lines
drivers/mmc/core/sd.c +0
-2bus_speed =UHS_DDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_DDR50 ; - card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50)) && (card-sw_caps.sd3_bus_mode &
Quoted 7 lines
Quoted 7 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 7 lines
drivers/mmc/core/sd.c +0
-2SD_MODE_UHS_SDR50)) { bus_speed =UHS_SDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR50 ; - card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25)) && (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR25)){
Quoted 16 lines
Quoted 6 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 6 lines
drivers/mmc/core/sd.c +0
-2bus_speed =UHS_SDR25_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR25 ; - card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ; } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR12)) && (card-sw_caps.sd3_bus_mode &
Quoted 8 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 8 lines
drivers/mmc/core/sd.c +6
-0SD_MODE_UHS_SDR12)) { bus_speed =UHS_SDR12_BUS_SPEED ; + } + +return bus_speed; +} + +static int sd_set_bus_speed_mode(struct mmc_card *card, u8*status)
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 502
Quoted 4 lines
drivers/mmc/core/sd.c +4
-0+{ +int err, bus_speed; +unsigned int timing =0 ; +We need add this check here.
Quoted 4 lines
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return 0;
Actually my very first patches returned directly from this function for the above condition. But if I remember correctly, Philip suggested that we should set the default speed too, so the *else if* clause below would take care of that.
Quoted 44 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/mmc/core/sd.c +14
-0+ bus_speed =sd_get_bus_speed_mode (card); + +if (bus_speed ==UHS_SDR104_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR104 ; + card->sw_caps.uhs_max_dtr =UHS_SDR104_MAX_DTR ; + }else if (bus_speed ==UHS_DDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_DDR50 ; + card->sw_caps.uhs_max_dtr =UHS_DDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR50 ; + card->sw_caps.uhs_max_dtr =UHS_SDR50_MAX_DTR ; + }else if (bus_speed ==UHS_SDR25_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR25 ; + card->sw_caps.uhs_max_dtr =UHS_SDR25_MAX_DTR ;Quoted 8 lines
Quoted 8 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 522
Quoted 6 lines
drivers/mmc/core/sd.c +3
-0+ }else if (bus_speed ==UHS_SDR12_BUS_SPEED ) { timing =MMC_TIMING_UHS_SDR12 ; card->sw_caps.uhs_max_dtr =UHS_SDR12_MAX_DTR ; + }else { +return -EINVAL ; }Minor change: I think "switch (
sd_get_bus_speed_mode(card))" wouldbe
Quoted 1 line
Quoted 1 line
cleaner.
Yes, we can replace it with switch. I will do it next patch rev.
Quoted 7 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 4 lines
drivers/mmc/core/sd.c +0
-0card->sd_bus_speed = bus_speed;@@ -522,6 +540,7 @@ static int sd_set_bus_speed_mode(struct
mmc_cardQuoted 2 lines
*card, u8 *status)
Quoted 1 line
drivers/mmc/core/sd.c +0
-0static int sd_set_current_limit(struct mmc_card *card, u8*status)
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 544
Quoted 4 lines
drivers/mmc/core/sd.c +1
-0{int current_limit =0 ; +unsigned int bus_speed =sd_get_bus_speed_mode (card);int err;We need add this check here.
Quoted 4 lines
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return 0;
Setting current limit is little different. As per section 4.3.10.3 of the Physical Layer Spec v3.01, Current Limit is only set for SDR50, SDR104, and DDR50 modes. For SDR12 and SDR25, we need to set the current limit of 200mA. So I don't think we should directly return from here.
Quoted 40 lines
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_current_limit(struct
Quoted 4 lines
drivers/mmc/core/sd.c +0
-0/* @@ -529,9 +548,9 @@ static int sd_set_current_limit(struct
mmc_cardQuoted 2 lines
Quoted 2 lines
*card, u8 *status)
Quoted 1 line
drivers/mmc/core/sd.c +0
-0* bus speed modes. For other bus speed modes, we set the default
Quoted 25 lines
Quoted 11 lines
drivers/mmc/core/sd.c static int sd_set_current_limit(struct mmc_card *card, u8 *status)
Quoted 10 lines
drivers/mmc/core/sd.c +3
-3* current limit of 200mA. */ -if ((card->sd_bus_speed ==UHS_SDR50_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_SDR104_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_DDR50_BUS_SPEED )) { +if ((bus_speed ==UHS_SDR50_BUS_SPEED ) || + (bus_speed ==UHS_SDR104_BUS_SPEED ) || + (bus_speed ==UHS_DDR50_BUS_SPEED )) {if (card->host->caps &MMC_CAP_MAX_CURRENT_800 ) { if (card->sw_caps.sd3_curr_limit &
SD_MAX_CURRENT_800)Quoted 2 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct
Quoted 2 lines
drivers/mmc/core/sd.c +0
-0current_limit =SD_SET_CURRENT_LIMIT_800 ;@@ -613,13 +632,13 @@ static int mmc_sd_init_uhs_card(struct
mmc_cardQuoted 11 lines
*card)
Quoted 10 lines
drivers/mmc/core/sd.c +2
-2if (err) goto out; -/* Set bus speed mode of the card */ - err =sd_set_bus_speed_mode (card, status); +/* Set current limit for the card */ + err =sd_set_current_limit (card, status);if (err) goto out;Quoted 7 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 641
Quoted 4 lines
drivers/mmc/core/sd.c +2
-2-/* Set current limit for the card */ - err =sd_set_current_limit (card, status); +/* Set bus speed mode of the card */ + err =sd_set_bus_speed_mode (card, status);Now supposing that we return
-EINVALhere, then that would imply thatmmc_sd_init_uhs_card()failed, but that should not be the case. Like
Quoted 6 lines
I
Quoted 1 line
mentioned before, the card should still be operable using default
speed
Quoted 1 line
mode.
When you say Default speed mode, does it mean SDR12 mode?
Yes.
Quoted 21 lines
Thanks,
SubhashQuoted 15 lines
Thanks,
ArindamQuoted 10 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 634
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0if (err) goto out;Thanks,
- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child
Quoted 144 lines
-----Original Message-----
From: [email protected] [mailto:linux-arm-msm- [email protected]] On Behalf Of Nath, Arindam
Sent: Tuesday, August 02, 2011 3:21 PM
To: Subhash Jadavani; 'Chris Ball'
Cc: [email protected]; [email protected]; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: [PATCH] mmc: sd: UHS-I bus speed should be set last in UHS initializationQuoted 7 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 2:43 PM
To: Nath, Arindam; 'Chris Ball'
Cc: [email protected]; [email protected]; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: [PATCH] mmc: sd: UHS-I bus speed should be set last inUHS
Quoted 11 lines
initialization
Hi Arindam,
Thank you for the review. Please find few comments inline.
Quoted 5 lines
-----Original Message-----
From: Nath, Arindam [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 12:38 PM
To: Chris Ball; Subhash Jadavani
Cc: [email protected]; [email protected];Philip
Quoted 13 lines
Quoted 2 lines
Rakity; zhangfei gao
Subject: RE: [PATCH] mmc: sd: UHS-I bus speed should be set last inUHS
Quoted 10 lines
initialization
Hi Subhash,
Quoted 5 lines
-----Original Message-----
From: Chris Ball [mailto:[email protected]]
Sent: Tuesday, August 02, 2011 1:40 AM
To: Subhash Jadavani
Cc: [email protected]; [email protected];Nath,
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Arindam
Subject: Re: [PATCH] mmc: sd: UHS-I bus speed should be set lastin
Quoted 7 lines
Quoted 7 lines
UHS
Quoted 6 lines
initialization
Hi Subhash, adding Arindam for review,
Quoted 1 line · Subhash Jadavani
mmc_sd_init_uhs_cardfunction sets the driver type, currentlimit
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
and bus speed mode on card as well as on host controller side.
Currently bus speed mode is set by sending CMD6 to card and immediately setting the timing mode in host controller. But then before initiating tuning sequence, it also tries to set current limit by sending CMD6 to card which results in data timeout errors in controller if bus speed mode is SDR50/SDR104
Quoted 11 lines
Quoted 3 lines
mode.
Quoted 2 lines
Quoted 2 lines
So basically bus speed mode should be set only after current
limit
Quoted 7 lines
Quoted 1 line
Quoted 1 line
is set in the card and immediately after setting the bus speed
mode,
Quoted 5 lines
Quoted 5 lines
tuning sequence should be initiated.
Signed-off-by Subhash Jadavani <[email protected]>--- drivers/mmc/core/sd.c | 57 ++++++++++++++++++++++++++++++++---
Quoted 63 lines
--
Quoted 16 lines
--
Quoted 8 lines
---------
drivers/mmc/core/sd.c static int sd_select_driver_type(struct
Quoted 7 lines
1 files changed, 38 insertions(+), 19 deletions(-)drivers/mmc/core/sd.c +0
-0@@ -459,10 +459,9 @@ static int sd_select_driver_type(struct
mmc_cardQuoted 5 lines
*card, u8 *status)
Quoted 4 lines
drivers/mmc/core/sd.c +0
-1return 0 ; } -static int sd_set_bus_speed_mode(struct mmc_card *card, u8*status)
Quoted 8 lines
Quoted 8 lines
drivers/mmc/core/sd.c static int sd_select_driver_type(struct mmc_card *card, u8 *status)
Quoted 8 lines
drivers/mmc/core/sd.c +2
-2+static int sd_get_bus_speed_mode (struct mmc_card *card) { -unsigned int bus_speed =0 , timing =0 ; -int err; +int bus_speed =0 ;/* * If the host doesn't support any of the UHS-I modes, fallback
Quoted 5 lines
Quoted 5 lines
on
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 1 line
drivers/mmc/core/sd.c +0
-0@@ -470,37 +469,56 @@ static int sd_set_bus_speed_mode(struct
mmc_card*card, u8 *status)Quoted 2 lines
drivers/mmc/core/sd.c +0
-0*/ if (!(card->host->caps & (MMC_CAP_UHS_SDR12 |
MMC_CAP_UHS_SDR25|Quoted 1 line
Quoted 1 line
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct · line 471
Quoted 1 line
drivers/mmc/core/sd.c +0
-0MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
MMC_CAP_UHS_DDR50)))Quoted 7 lines
Quoted 2 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct · line 472
Quoted 2 lines
drivers/mmc/core/sd.c +1
-1-return 0 ; +return -EINVAL ;We should not return
-EINVALhere, because this is not an error condition. This would simply mean that the card and host controller will fall back to using the default bus speed, and should still be operable. Check the comment below too.Return value of this function gets used in
sd_set_bus_speed_mode()function
and compared against all the valid bus speed modes. If we choose to return 0
from here then '0' corresponds to valid bus speed mode 'UHS_SDR12_BUS_SPEED'.#define UHS_SDR12_BUS_SPEED 0 #define UHS_SDR25_BUS_SPEED 1 #define UHS_SDR50_BUS_SPEED 2 #define UHS_SDR104_BUS_SPEED 3 #define UHS_DDR50_BUS_SPEED 4If we don't want to return the error value from this function then we can
basically remove following check from this *get* function and move it to
each *set* function before calling *get*. Please see more comments inline in
*set* functions below.Quoted 3 lines
if (!(card->host->caps & (
MMC_CAP_UHS_SDR12|MMC_CAP_UHS_SDR25|MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return -EINVAL;
Quoted 5 lines
By *Default Bus Speed*, I meant speed corresponding to SDR12. So if we return 0 from
sd_get_bus_speed_mode(), that would make sure that your modifiedsd_set_bus_speed_mode()correctly executes the last *else if* condition, and we set the default speed. So I don't think we will need to return-EINVAL.
Ok. Got your points. Will address this in next rev. for this patch.
Thanks,
Subhash
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 9 lines
drivers/mmc/core/sd.c +0
-2if ((card->host->caps &MMC_CAP_UHS_SDR104 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 )) { bus_speed =UHS_SDR104_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR104 ; - card->sw_caps.uhs_max_dtr =
UHS_SDR104_MAX_DTR;
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct · line 477
Quoted 2 lines
drivers/mmc/core/sd.c +0
-0}else if ((card->host->caps &MMC_CAP_UHS_DDR50 ) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_DDR50 )){
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +0
-2bus_speed =UHS_DDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_DDR50 ; - card->sw_caps.uhs_max_dtr =
UHS_DDR50_MAX_DTR;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct · line 480
Quoted 2 lines
drivers/mmc/core/sd.c +0
-0} else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50)) && (card-sw_caps.sd3_bus_mode &
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 4 lines
drivers/mmc/core/sd.c +0
-2SD_MODE_UHS_SDR50)) { bus_speed =UHS_SDR50_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR50 ; - card->sw_caps.uhs_max_dtr =
UHS_SDR50_MAX_DTR;
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0}else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |MMC_CAP_UHS_SDR50 |MMC_CAP_UHS_SDR25 )) && (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR25 )){
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +0
-2bus_speed =UHS_SDR25_BUS_SPEED ; - timing =MMC_TIMING_UHS_SDR25 ; - card->sw_caps.uhs_max_dtr =
UHS_SDR25_MAX_DTR;
Quoted 32 lines
Quoted 20 lines
Quoted 13 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0} else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR12)) && (card-sw_caps.sd3_bus_mode &
Quoted 8 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 8 lines
drivers/mmc/core/sd.c +6
-0SD_MODE_UHS_SDR12)) { bus_speed =UHS_SDR12_BUS_SPEED ; + } + +return bus_speed; +} + +static int sd_set_bus_speed_mode(struct mmc_card *card, u8*status)
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 502
Quoted 4 lines
drivers/mmc/core/sd.c +4
-0+{ +int err, bus_speed; +unsigned int timing =0 ; +We need add this check here.
Quoted 4 lines
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return 0;Actually my very first patches returned directly from this function for the above condition. But if I remember correctly, Philip suggested that we should set the default speed too, so the *else if* clause below would take care of that.
Quoted 2 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 5 lines
drivers/mmc/core/sd.c +5
-0+ bus_speed =sd_get_bus_speed_mode (card); + +if (bus_speed ==UHS_SDR104_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR104 ; + card->sw_caps.uhs_max_dtr =
UHS_SDR104_MAX_DTR;
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +3
-0+ }else if (bus_speed ==UHS_DDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_DDR50 ; + card->sw_caps.uhs_max_dtr =
UHS_DDR50_MAX_DTR;
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +3
-0+ }else if (bus_speed ==UHS_SDR50_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR50 ; + card->sw_caps.uhs_max_dtr =
UHS_SDR50_MAX_DTR;
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +3
-0+ }else if (bus_speed ==UHS_SDR25_BUS_SPEED ) { + timing =MMC_TIMING_UHS_SDR25 ; + card->sw_caps.uhs_max_dtr =
UHS_SDR25_MAX_DTR;
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
Quoted 3 lines
drivers/mmc/core/sd.c +1
-0+ }else if (bus_speed ==UHS_SDR12_BUS_SPEED ) { timing =MMC_TIMING_UHS_SDR12 ; card->sw_caps.uhs_max_dtr =
UHS_SDR12_MAX_DTR;
Quoted 31 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 522
Quoted 3 lines
drivers/mmc/core/sd.c +2
-0+ }else { +return -EINVAL ; }Minor change: I think "switch (
sd_get_bus_speed_mode(card))"would
Quoted 20 lines
be
Quoted 1 line
Quoted 1 line
cleaner.
Yes, we can replace it with switch. I will do it next patch rev.
Quoted 7 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct
Quoted 4 lines
drivers/mmc/core/sd.c +0
-0card->sd_bus_speed = bus_speed;@@ -522,6 +540,7 @@ static int sd_set_bus_speed_mode(struct
mmc_cardQuoted 2 lines
*card, u8 *status)
Quoted 1 line
drivers/mmc/core/sd.c +0
-0static int sd_set_current_limit(struct mmc_card *card, u8*status)
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) · line 544
Quoted 4 lines
drivers/mmc/core/sd.c +1
-0{int current_limit =0 ; +unsigned int bus_speed =sd_get_bus_speed_mode (card);int err;We need add this check here.
Quoted 4 lines
if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) return 0;
Quoted 26 lines
Setting current limit is little different. As per section 4.3.10.3 of the Physical Layer Spec v3.01, Current Limit is only set for SDR50, SDR104, and DDR50 modes. For SDR12 and SDR25, we need to set the current limit of 200mA. So I don't think we should directly return from here.
Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int sd_set_current_limit(struct
Quoted 4 lines
drivers/mmc/core/sd.c +0
-0/* @@ -529,9 +548,9 @@ static int sd_set_current_limit(struct
mmc_cardQuoted 2 lines
Quoted 2 lines
*card, u8 *status)
Quoted 1 line
drivers/mmc/core/sd.c +0
-0* bus speed modes. For other bus speed modes, we set the default
Quoted 12 lines
Quoted 12 lines
drivers/mmc/core/sd.c static int sd_set_current_limit(struct mmc_card *card, u8 *status)
Quoted 10 lines
drivers/mmc/core/sd.c +3
-3* current limit of 200mA. */ -if ((card->sd_bus_speed ==UHS_SDR50_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_SDR104_BUS_SPEED ) || - (card->sd_bus_speed ==UHS_DDR50_BUS_SPEED )) { +if ((bus_speed ==UHS_SDR50_BUS_SPEED ) || + (bus_speed ==UHS_SDR104_BUS_SPEED ) || + (bus_speed ==UHS_DDR50_BUS_SPEED )) {if (card->host->caps &MMC_CAP_MAX_CURRENT_800 ) { if (card->sw_caps.sd3_curr_limit &
SD_MAX_CURRENT_800)Quoted 1 line
drivers/mmc/core/sd.c +0
-0current_limit =
SD_SET_CURRENT_LIMIT_800;
Quoted 59 lines
Quoted 13 lines
Quoted 13 lines
Quoted 1 line
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct
Quoted 1 line
drivers/mmc/core/sd.c +0
-0@@ -613,13 +632,13 @@ static int mmc_sd_init_uhs_card(struct
mmc_cardQuoted 11 lines
*card)
Quoted 10 lines
drivers/mmc/core/sd.c +2
-2if (err) goto out; -/* Set bus speed mode of the card */ - err =sd_set_bus_speed_mode (card, status); +/* Set current limit for the card */ + err =sd_set_current_limit (card, status);if (err) goto out;Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 641
Quoted 4 lines
drivers/mmc/core/sd.c +2
-2-/* Set current limit for the card */ - err =sd_set_current_limit (card, status); +/* Set bus speed mode of the card */ + err =sd_set_bus_speed_mode (card, status);Now supposing that we return
-EINVALhere, then that would implythat
Quoted 1 line
Quoted 1 line
mmc_sd_init_uhs_card()failed, but that should not be the case.Like
Quoted 6 lines
I
Quoted 1 line
mentioned before, the card should still be operable using default
speed
Quoted 1 line
mode.
When you say Default speed mode, does it mean SDR12 mode?
Yes.
Quoted 21 lines
Thanks,
SubhashQuoted 15 lines
Thanks,
ArindamQuoted 10 lines
drivers/mmc/core/sd.c static int mmc_sd_init_uhs_card(struct mmc_card *card) · line 634
Quoted 3 lines
drivers/mmc/core/sd.c +0
-0if (err) goto out;Thanks,
- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child--
To unsubscribe from this list: send the line "unsubscribe linux-arm- msm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Issue with non-UHS-I SD3.0 cards
Hi,
I am seeing the issue where "SanDisk Extreme SDHC 8GB Class 10 card" is running in "Default Speed" mode even though it supports "High Speed" mode. After analysis, I found that this card is advertising itself as SD3.0 card (with SD_SPEC=2 and SD_SPEC3=1 in SCR). But current mmc core later initialization sequence for SD3.0 cards is such that these non-UHS-I SD3.0 cards runs in Default Speed mode @25MHz.
Here is Essential conditions to indicate Version 3.00 Card (from SD3.01 spec)
(SD_SPEC=2 and SD_SPEC3=1) :
(1) The card shall support CMD6
(2) The card shall support CMD8
(3) The card shall support CMD42
(4) User area capacity shall be up to 2GB (SDSC) or 32GB (SDHC) User area capacity shall be more than or equal to 32GB and up to 2TB (SDXC)
(5) Speed Class shall be supported (SDHC or SDXC)
So even if SD card doesn't support any of the newly defined UHS-I bus speed mode, it can advertise itself as SD3.0 cards as long as it supports all the essential conditions of SD3.0 cards. Given this, these type of cards should at least run in High Speed mode @50MHZ if it supports HS.
Here are the changes you have to do to make non-UHS-I SD3.0 cards run in High Speed Mode @50MHz. Do let me know if looks fine or not, so I can post the formal patch.
--- drivers/mmc/core/sd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/core/sd.c +3 -3
@@ -305,6 +305,9 @@ static int mmc_read_switch(struct mmc_card *card) goto out; } +if (status[13 ] &0x02 ) + card->sw_caps.hs_max_dtr =50000000 ; +if (card->scr.sda_spec3) { card->sw_caps.sd3_bus_mode = status[13 ];
@@ -347,9 +350,6 @@ static int mmc_read_switch(struct mmc_card *card) } card->sw_caps.sd3_curr_limit = status[7 ]; - }else { -if (status[13 ] &0x02 ) - card->sw_caps.hs_max_dtr =50000000 ; } out:
--
Regards,
Subhash
RE: Issue with non-UHS-I SD3.0 cards
Hi Subhash,
Quoted 19 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Friday, August 05, 2011 7:01 PM
To: [email protected]
Cc: Nath, Arindam; 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: Issue with non-UHS-I SD3.0 cardsHi,
I am seeing the issue where "SanDisk Extreme SDHC 8GB Class 10 card" is running in "Default Speed" mode even though it supports "High Speed" mode.
After analysis, I found that this card is advertising itself as SD3.0 card
(with SD_SPEC=2 and SD_SPEC3=1 in SCR). But current mmc core later initialization sequence for SD3.0 cards is such that these non-UHS-I SD3.0
cards runs in Default Speed mode @25MHz.
Quoted 10 lines
Here is Essential conditions to indicate Version 3.00 Card (from SD3.01 spec)
(SD_SPEC=2 and SD_SPEC3=1) :
(1) The card shall support CMD6
(2) The card shall support CMD8
(3) The card shall support CMD42
(4) User area capacity shall be up to 2GB (SDSC) or 32GB (SDHC) User area capacity shall be more than or equal to 32GB and up to 2TB (SDXC)
(5) Speed Class shall be supported (SDHC or SDXC)
I went through the particular section of the spec again, and IMO, the essential conditions are for the manufacturer of the card to advertise his card as SD3.0 card or otherwise. From software point of view, the SD_SPEC=2 _and_ SD_SPEC3=1 will indicate a SD3.0 card.
Thanks,
Arindam
Quoted 51 lines
So even if SD card doesn't support any of the newly defined UHS-I bus speed
mode, it can advertise itself as SD3.0 cards as long as it supports all the
essential conditions of SD3.0 cards. Given this, these type of cards should
at least run in High Speed mode @50MHZ if it supports HS.Here are the changes you have to do to make non-UHS-I SD3.0 cards run in
High Speed Mode @50MHz. Do let me know if looks fine or not, so I can post
the formal patch.--- drivers/mmc/core/sd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)drivers/mmc/core/sd.c +3
-4@@ -305,6 +305,9 @@ static int mmc_read_switch(struct mmc_card *card) goto out; } +if (status[13 ] &0x02 ) + card->sw_caps.hs_max_dtr =50000000 ; +if (card->scr.sda_spec3) { card->sw_caps.sd3_bus_mode = status[13 ];@@ -347,9 +350,6 @@ static int mmc_read_switch(struct mmc_card *card) } card->sw_caps.sd3_curr_limit = status[7 ]; - }else { -if (status[13 ] &0x02 ) - card->sw_caps.hs_max_dtr =50000000 ; } out: --Regards,
Subhash
RE: Issue with non-UHS-I SD3.0 cards
In reply to Subhash JadavaniQuoted 44 lines
-----Original Message-----
From: Nath, Arindam
Sent: Saturday, August 06, 2011 12:15 AM
To: 'Subhash Jadavani'; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsHi Subhash,
Quoted 10 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Friday, August 05, 2011 7:01 PM
To: [email protected]
Cc: Nath, Arindam; 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: Issue with non-UHS-I SD3.0 cardsHi,
I am seeing the issue where "SanDisk Extreme SDHC 8GB Class 10 card"
is
Quoted 10 lines
running in "Default Speed" mode even though it supports "High Speed" mode.
After analysis, I found that this card is advertising itself as SD3.0 card
(with SD_SPEC=2 and SD_SPEC3=1 in SCR). But current mmc core later initialization sequence for SD3.0 cards is such that these non-UHS-I SD3.0
cards runs in Default Speed mode @25MHz.Here is Essential conditions to indicate Version 3.00 Card (from
SD3.01
Quoted 9 lines
spec)
(SD_SPEC=2 and SD_SPEC3=1) :
(1) The card shall support CMD6
(2) The card shall support CMD8
(3) The card shall support CMD42
(4) User area capacity shall be up to 2GB (SDSC) or 32GB (SDHC) User area capacity shall be more than or equal to 32GB and up to 2TB (SDXC)
(5) Speed Class shall be supported (SDHC or SDXC)
Quoted 4 lines
I went through the particular section of the spec again, and IMO, the essential conditions are for the manufacturer of the card to advertise his card as SD3.0 card or otherwise. From software point of view, the SD_SPEC=2 _and_ SD_SPEC3=1 will indicate a SD3.0 card.
I misread your comment, so please ignore what you mentioned above. So if I understand correctly, in your case *sd_spec3* is set for the card, even though it is a non UHS-I card. In that case, what you tried in your patch looks fine, except that I would suggest to move it inside the
if (card->scr.sda_spec3) {
...
}condition.
Quoted 56 lines
Thanks,
ArindamQuoted 5 lines
So even if SD card doesn't support any of the newly defined UHS-I bus speed
mode, it can advertise itself as SD3.0 cards as long as it supportsall
Quoted 46 lines
the
essential conditions of SD3.0 cards. Given this, these type of cards should
at least run in High Speed mode @50MHZ if it supports HS.Here are the changes you have to do to make non-UHS-I SD3.0 cards run in
High Speed Mode @50MHz. Do let me know if looks fine or not, so I can post
the formal patch.--- drivers/mmc/core/sd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)drivers/mmc/core/sd.c +3
-4@@ -305,6 +305,9 @@ static int mmc_read_switch(struct mmc_card *card) goto out; } +if (status[13 ] &0x02 ) + card->sw_caps.hs_max_dtr =50000000 ; +if (card->scr.sda_spec3) { card->sw_caps.sd3_bus_mode = status[13 ];@@ -347,9 +350,6 @@ static int mmc_read_switch(struct mmc_card *card) } card->sw_caps.sd3_curr_limit = status[7 ]; - }else { -if (status[13 ] &0x02 ) - card->sw_caps.hs_max_dtr =50000000 ; } out: --Regards,
Subhash
RE: Issue with non-UHS-I SD3.0 cards
In reply to Subhash JadavaniQuoted 57 lines
-----Original Message-----
From: Nath, Arindam
Sent: Saturday, August 06, 2011 12:27 AM
To: 'Subhash Jadavani'; '[email protected]'
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsQuoted 7 lines
-----Original Message-----
From: Nath, Arindam
Sent: Saturday, August 06, 2011 12:15 AM
To: 'Subhash Jadavani'; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsQuoted 13 lines
Hi Subhash,
Quoted 10 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Friday, August 05, 2011 7:01 PM
To: [email protected]
Cc: Nath, Arindam; 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: Issue with non-UHS-I SD3.0 cardsHi,
I am seeing the issue where "SanDisk Extreme SDHC 8GB Class 10
card"
Quoted 2 lines
is
Quoted 1 line
running in "Default Speed" mode even though it supports "High
Speed"
Quoted 2 lines
Quoted 2 lines
mode.
After analysis, I found that this card is advertising itself asSD3.0
Quoted 3 lines
Quoted 3 lines
card
(with SD_SPEC=2 and SD_SPEC3=1 in SCR). But current mmc core later initialization sequence for SD3.0 cards is such that these non-UHS-I
Quoted 15 lines
Quoted 4 lines
SD3.0
cards runs in Default Speed mode @25MHz.Here is Essential conditions to indicate Version 3.00 Card (from
SD3.01
Quoted 9 lines
spec)
(SD_SPEC=2 and SD_SPEC3=1) :
(1) The card shall support CMD6
(2) The card shall support CMD8
(3) The card shall support CMD42
(4) User area capacity shall be up to 2GB (SDSC) or 32GB (SDHC) User area capacity shall be more than or equal to 32GB and up to 2TB (SDXC)
(5) Speed Class shall be supported (SDHC or SDXC)
Quoted 7 lines
Quoted 2 lines
I went through the particular section of the spec again, and IMO, the essential conditions are for the manufacturer of the card to
advertise
Quoted 2 lines
his card as SD3.0 card or otherwise. From software point of view, the SD_SPEC=2 _and_ SD_SPEC3=1 will indicate a SD3.0 card.
I misread your comment, so please ignore what you mentioned above. So
*so please ignore what I mentioned above*
Sorry for the typo.
Quoted 73 lines
if I understand correctly, in your case *sd_spec3* is set for the card, even though it is a non UHS-I card. In that case, what you tried in your patch looks fine, except that I would suggest to move it inside the
if (card->scr.sda_spec3) { ... }condition.
Quoted 7 lines
Thanks,
ArindamQuoted 3 lines
So even if SD card doesn't support any of the newly defined UHS-I
bus
Quoted 5 lines
Quoted 2 lines
speed
mode, it can advertise itself as SD3.0 cards as long as it supportsall
Quoted 2 lines
the
essential conditions of SD3.0 cards. Given this, these type ofcards
Quoted 4 lines
Quoted 4 lines
should
at least run in High Speed mode @50MHZ if it supports HS.Here are the changes you have to do to make non-UHS-I SD3.0 cards
run
Quoted 2 lines
Quoted 2 lines
in
High Speed Mode @50MHz. Do let me know if looks fine or not, so Ican
Quoted 7 lines
Quoted 7 lines
post
the formal patch.--- drivers/mmc/core/sd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)Quoted 5 lines
drivers/mmc/core/sd.c static int mmc_read_switch(struct mmc_card
Quoted 5 lines
drivers/mmc/core/sd.c +0
-0@@ -305,6 +305,9 @@ static int mmc_read_switch(struct mmc_card*card)
Quoted 10 lines
drivers/mmc/core/sd.c static int mmc_read_switch(struct mmc_card
Quoted 10 lines
drivers/mmc/core/sd.c +3
-0goto out; } +if (status[13 ] &0x02 ) + card->sw_caps.hs_max_dtr =50000000 ; +if (card->scr.sda_spec3) { card->sw_caps.sd3_bus_mode = status[13 ];@@ -347,9 +350,6 @@ static int mmc_read_switch(struct mmc_card*card)
Quoted 16 lines
Quoted 16 lines
drivers/mmc/core/sd.c +0
-4} card->sw_caps.sd3_curr_limit = status[7 ]; - }else { -if (status[13 ] &0x02 ) - card->sw_caps.hs_max_dtr =50000000 ; } out: --Regards,
Subhash
RE: Issue with non-UHS-I SD3.0 cards
In reply to Nath, ArindamHi Arindam,
Quoted 68 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Nath, Arindam
Sent: Saturday, August 06, 2011 12:27 AM
To: Subhash Jadavani; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsQuoted 7 lines
-----Original Message-----
From: Nath, Arindam
Sent: Saturday, August 06, 2011 12:15 AM
To: 'Subhash Jadavani'; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsQuoted 13 lines
Hi Subhash,
Quoted 10 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Friday, August 05, 2011 7:01 PM
To: [email protected]
Cc: Nath, Arindam; 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: Issue with non-UHS-I SD3.0 cardsHi,
I am seeing the issue where "SanDisk Extreme SDHC 8GB Class 10
card"
Quoted 2 lines
is
Quoted 1 line
running in "Default Speed" mode even though it supports "High
Speed"
Quoted 2 lines
Quoted 2 lines
mode.
After analysis, I found that this card is advertising itself asSD3.0
Quoted 3 lines
Quoted 3 lines
card
(with SD_SPEC=2 and SD_SPEC3=1 in SCR). But current mmc core later initialization sequence for SD3.0 cards is such that these non-UHS-I
Quoted 15 lines
Quoted 4 lines
SD3.0
cards runs in Default Speed mode @25MHz.Here is Essential conditions to indicate Version 3.00 Card (from
SD3.01
Quoted 9 lines
spec)
(SD_SPEC=2 and SD_SPEC3=1) :
(1) The card shall support CMD6
(2) The card shall support CMD8
(3) The card shall support CMD42
(4) User area capacity shall be up to 2GB (SDSC) or 32GB (SDHC) User area capacity shall be more than or equal to 32GB and up to 2TB (SDXC)
(5) Speed Class shall be supported (SDHC or SDXC)Quoted 2 lines
I went through the particular section of the spec again, and IMO, the essential conditions are for the manufacturer of the card to
advertise
Quoted 2 lines
his card as SD3.0 card or otherwise. From software point of view, the SD_SPEC=2 _and_ SD_SPEC3=1 will indicate a SD3.0 card.
I misread your comment, so please ignore what you mentioned above. So if I understand correctly, in your case *sd_spec3* is set for the card, even though it is a non UHS-I card. In that case, what you tried in your patch looks fine, except that I would suggest to move it inside the
Quoted 6 lines
if (card->scr.sda_spec3) { ... }condition.
You mean moving the " card->sw_caps.hs_max_dtr = 50000000;" under if (card->scr.sda_spec3) condition and still retaining the else condition for " if (card->scr.sda_spec3) ".
Something like this:
if (card->scr.sda_spec3) {
if (status[13] & 0x02)
card->sw_caps.hs_max_dtr = 50000000;
...
...} else {
if (status[13] & 0x02)
card->sw_caps.hs_max_dtr = 50000000;
}I thought it's duplication of code as both if & else condition is executing the same code so thought of putting it outside of if, else.
I am even ok with putting it inside "if (card->scr.sda_spec3)", if you think it's better.
Regards,
Subhash
Quoted 68 lines
Quoted 7 lines
Thanks,
ArindamQuoted 3 lines
So even if SD card doesn't support any of the newly defined UHS-I
bus
Quoted 5 lines
Quoted 2 lines
speed
mode, it can advertise itself as SD3.0 cards as long as it supportsall
Quoted 2 lines
the
essential conditions of SD3.0 cards. Given this, these type ofcards
Quoted 4 lines
Quoted 4 lines
should
at least run in High Speed mode @50MHZ if it supports HS.Here are the changes you have to do to make non-UHS-I SD3.0 cards
run
Quoted 2 lines
Quoted 2 lines
in
High Speed Mode @50MHz. Do let me know if looks fine or not, so Ican
Quoted 7 lines
Quoted 7 lines
post
the formal patch.--- drivers/mmc/core/sd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)Quoted 5 lines
drivers/mmc/core/sd.c static int mmc_read_switch(struct mmc_card
Quoted 5 lines
drivers/mmc/core/sd.c +0
-0@@ -305,6 +305,9 @@ static int mmc_read_switch(struct mmc_card*card)
Quoted 10 lines
drivers/mmc/core/sd.c static int mmc_read_switch(struct mmc_card
Quoted 10 lines
drivers/mmc/core/sd.c +3
-0goto out; } +if (status[13 ] &0x02 ) + card->sw_caps.hs_max_dtr =50000000 ; +if (card->scr.sda_spec3) { card->sw_caps.sd3_bus_mode = status[13 ];@@ -347,9 +350,6 @@ static int mmc_read_switch(struct mmc_card*card)
Quoted 8 lines
Quoted 8 lines
drivers/mmc/core/sd.c +0
-3} card->sw_caps.sd3_curr_limit = status[7 ]; - }else { -if (status[13 ] &0x02 ) - card->sw_caps.hs_max_dtr =50000000 ; }Quoted 8 lines
Quoted 8 lines
drivers/mmc/core/sd.c +0
-1out: --Regards,
Subhash--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Nath, Arindam
Reviewed-byRE: Issue with non-UHS-I SD3.0 cards
Hi Subhash,
Quoted 109 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Monday, August 08, 2011 11:51 AM
To: Nath, Arindam; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsHi Arindam,
Quoted 29 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Nath, Arindam
Sent: Saturday, August 06, 2011 12:27 AM
To: Subhash Jadavani; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsQuoted 19 lines
-----Original Message-----
From: Nath, Arindam
Sent: Saturday, August 06, 2011 12:15 AM
To: 'Subhash Jadavani'; [email protected]
Cc: 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: RE: Issue with non-UHS-I SD3.0 cardsHi Subhash,
Quoted 9 lines
-----Original Message-----
From: Subhash Jadavani [mailto:[email protected]]
Sent: Friday, August 05, 2011 7:01 PM
To: [email protected]
Cc: Nath, Arindam; 'Chris Ball'; 'Philip Rakity'; 'zhangfei gao'
Subject: Issue with non-UHS-I SD3.0 cardsHi,
Quoted 10 lines
Quoted 1 line
Quoted 1 line
I am seeing the issue where "SanDisk Extreme SDHC 8GB Class 10
card"
Quoted 2 lines
is
Quoted 1 line
running in "Default Speed" mode even though it supports "High
Speed"
Quoted 2 lines
Quoted 2 lines
mode.
After analysis, I found that this card is advertising itself asSD3.0
Quoted 2 lines
Quoted 2 lines
card
(with SD_SPEC=2 and SD_SPEC3=1 in SCR). But current mmc corelater
Quoted 1 line
Quoted 1 line
Quoted 1 line
initialization sequence for SD3.0 cards is such that these non-
UHS-
Quoted 12 lines
I
Quoted 11 lines
Quoted 4 lines
SD3.0
cards runs in Default Speed mode @25MHz.Here is Essential conditions to indicate Version 3.00 Card (from
SD3.01
Quoted 6 lines
spec)
(SD_SPEC=2 and SD_SPEC3=1) :
(1) The card shall support CMD6
(2) The card shall support CMD8
(3) The card shall support CMD42
(4) User area capacity shall be up to 2GB (SDSC) or 32GB(SDHC)
Quoted 1 line
Quoted 1 line
Quoted 1 line
User area capacity shall be more than or equal to 32GB
and
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
up to 2TB (SDXC)
(5) Speed Class shall be supported (SDHC or SDXC)I went through the particular section of the spec again, and IMO,
the
Quoted 3 lines
Quoted 1 line
essential conditions are for the manufacturer of the card to
advertise
Quoted 1 line
his card as SD3.0 card or otherwise. From software point of view,
the
Quoted 4 lines
Quoted 1 line
SD_SPEC=2 _and_ SD_SPEC3=1 will indicate a SD3.0 card.
I misread your comment, so please ignore what you mentioned above. So if I understand correctly, in your case *sd_spec3* is set for the
card,
Quoted 10 lines
even though it is a non UHS-I card. In that case, what you tried in your patch looks fine, except that I would suggest to move it inside the
if (card->scr.sda_spec3) { ... }condition.
You mean moving the "
card->sw_caps.hs_max_dtr= 50000000;" under if (card->scr.sda_spec3) condition and still retaining the else condition for "
if (card->scr.sda_spec3) ".Something like this:
if (card->scr.sda_spec3) { if (status[13] & 0x02) card->sw_caps.hs_max_dtr = 50000000; ... ...} else { if (status[13] & 0x02) card->sw_caps.hs_max_dtr = 50000000; }
Quoted 6 lines
I thought it's duplication of code as both if & else condition is executing
the same code so thought of putting it outside of if, else. I am even ok with putting it inside "if (card->scr.sda_spec3)", if you think
it's better.
Your argument makes sense. I am OK with your original patch.
Quoted 76 lines
Regards,
SubhashQuoted 10 lines
Quoted 7 lines
Thanks,
ArindamQuoted 3 lines
So even if SD card doesn't support any of the newly defined UHS-I
bus
Quoted 2 lines
Quoted 2 lines
speed
mode, it can advertise itself as SD3.0 cards as long as itsupports
Quoted 48 lines
Quoted 3 lines
all
Quoted 2 lines
the
essential conditions of SD3.0 cards. Given this, these type ofcards
Quoted 4 lines
Quoted 4 lines
should
at least run in High Speed mode @50MHZ if it supports HS.Here are the changes you have to do to make non-UHS-I SD3.0 cards
run
Quoted 2 lines
Quoted 2 lines
in
High Speed Mode @50MHz. Do let me know if looks fine or not, so Ican
Quoted 7 lines
Quoted 7 lines
post
the formal patch.--- drivers/mmc/core/sd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)Quoted 5 lines
drivers/mmc/core/sd.c static int mmc_read_switch(struct mmc_card
Quoted 5 lines
drivers/mmc/core/sd.c +0
-0@@ -305,6 +305,9 @@ static int mmc_read_switch(struct mmc_card*card)
Quoted 10 lines
drivers/mmc/core/sd.c static int mmc_read_switch(struct mmc_card
Quoted 10 lines
drivers/mmc/core/sd.c +3
-0goto out; } +if (status[13 ] &0x02 ) + card->sw_caps.hs_max_dtr =50000000 ; +if (card->scr.sda_spec3) { card->sw_caps.sd3_bus_mode = status[13 ];@@ -347,9 +350,6 @@ static int mmc_read_switch(struct mmc_card*card)
Quoted 12 lines
Quoted 12 lines
drivers/mmc/core/sd.c +0
-4} card->sw_caps.sd3_curr_limit = status[7 ]; - }else { -if (status[13 ] &0x02 ) - card->sw_caps.hs_max_dtr =50000000 ; } out: --Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Regards,
Subhash--
To unsubscribe from this list: send the line "unsubscribe linux-mmc"in
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html