diff mbox series

[08/11] mmc: core: Parse the SD SCR register for support of CMD48/49 and CMD58/59

Message ID 20210504161222.101536-9-ulf.hansson@linaro.org
State New
Headers show
Series Initital support for new power/perf features for SD cards | expand

Commit Message

Ulf Hansson May 4, 2021, 4:12 p.m. UTC
In SD spec v4.x the support for CMD48/49 and CMD58/59 were introduced as
optional features. To let the card announce whether it supports the
commands, the SCR register has been extended with corresponding support
bits. Let's parse and store this information for later use.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/mmc/core/sd.c    | 4 +++-
 include/linux/mmc/card.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.25.1

Comments

Linus Walleij May 6, 2021, 1:01 p.m. UTC | #1
On Tue, May 4, 2021 at 6:12 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:

> In SD spec v4.x the support for CMD48/49 and CMD58/59 were introduced as

> optional features. To let the card announce whether it supports the

> commands, the SCR register has been extended with corresponding support

> bits. Let's parse and store this information for later use.

>

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
Shawn Lin May 7, 2021, 1:58 a.m. UTC | #2
On 2021/5/5 0:12, Ulf Hansson wrote:
> In SD spec v4.x the support for CMD48/49 and CMD58/59 were introduced as

> optional features. To let the card announce whether it supports the

> commands, the SCR register has been extended with corresponding support

> bits. Let's parse and store this information for later use.

> 


Just check v4.0 spec, and it says

"Table 4-32 is added in Version 4.00. These commands are reserved for
future extenstion". So,

Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>


> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---

>   drivers/mmc/core/sd.c    | 4 +++-

>   include/linux/mmc/card.h | 2 ++

>   2 files changed, 5 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c

> index 2c48d6504101..de7b5f8df550 100644

> --- a/drivers/mmc/core/sd.c

> +++ b/drivers/mmc/core/sd.c

> @@ -222,7 +222,9 @@ static int mmc_decode_scr(struct mmc_card *card)

>   	else

>   		card->erased_byte = 0x0;

>   

> -	if (scr->sda_spec3)

> +	if (scr->sda_spec4)

> +		scr->cmds = UNSTUFF_BITS(resp, 32, 4);

> +	else if (scr->sda_spec3)

>   		scr->cmds = UNSTUFF_BITS(resp, 32, 2);

>   

>   	/* SD Spec says: any SD Card shall set at least bits 0 and 2 */

> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h

> index f9ad35dd6012..858fc4d11240 100644

> --- a/include/linux/mmc/card.h

> +++ b/include/linux/mmc/card.h

> @@ -139,6 +139,8 @@ struct sd_scr {

>   	unsigned char		cmds;

>   #define SD_SCR_CMD20_SUPPORT   (1<<0)

>   #define SD_SCR_CMD23_SUPPORT   (1<<1)

> +#define SD_SCR_CMD48_SUPPORT   (1<<2)

> +#define SD_SCR_CMD58_SUPPORT   (1<<3)

>   };

>   

>   struct sd_ssr {

>
diff mbox series

Patch

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 2c48d6504101..de7b5f8df550 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -222,7 +222,9 @@  static int mmc_decode_scr(struct mmc_card *card)
 	else
 		card->erased_byte = 0x0;
 
-	if (scr->sda_spec3)
+	if (scr->sda_spec4)
+		scr->cmds = UNSTUFF_BITS(resp, 32, 4);
+	else if (scr->sda_spec3)
 		scr->cmds = UNSTUFF_BITS(resp, 32, 2);
 
 	/* SD Spec says: any SD Card shall set at least bits 0 and 2 */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index f9ad35dd6012..858fc4d11240 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -139,6 +139,8 @@  struct sd_scr {
 	unsigned char		cmds;
 #define SD_SCR_CMD20_SUPPORT   (1<<0)
 #define SD_SCR_CMD23_SUPPORT   (1<<1)
+#define SD_SCR_CMD48_SUPPORT   (1<<2)
+#define SD_SCR_CMD58_SUPPORT   (1<<3)
 };
 
 struct sd_ssr {