public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: Implement SD/MMC versioning properly
Date: Fri, 23 Jan 2015 22:40:37 +0900	[thread overview]
Message-ID: <54C24F55.8020300@samsung.com> (raw)
In-Reply-To: <1422007921-11736-1-git-send-email-pantelis.antoniou@konsulko.com>

Tested-by: Jaehoon Chung <jh80.chung@samsung.com>

(with eMMC4.5,eMMC5.0,SD2.0,SD3.0 cards)

Best Regards,
Jaehoon Chung

On 01/23/2015 07:12 PM, Pantelis Antoniou wrote:
> The SD/MMC version scheme was buggy when dealing with standard
> major.minor.change cases. Fix it my using something similar to
> linux's kernel versioning method.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/cmd_mmc.c |  8 ++++++--
>  include/mmc.h    | 56 +++++++++++++++++++++++++++++++++++++-------------------
>  2 files changed, 43 insertions(+), 21 deletions(-)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 4e28c9d..1335e3d 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -85,8 +85,12 @@ static void print_mmcinfo(struct mmc *mmc)
>  	printf("Tran Speed: %d\n", mmc->tran_speed);
>  	printf("Rd Block Len: %d\n", mmc->read_bl_len);
>  
> -	printf("%s version %d.%d\n", IS_SD(mmc) ? "SD" : "MMC",
> -			(mmc->version >> 8) & 0xf, mmc->version & 0xff);
> +	printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC",
> +			EXTRACT_SDMMC_MAJOR_VERSION(mmc->version),
> +			EXTRACT_SDMMC_MINOR_VERSION(mmc->version));
> +	if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0)
> +		printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version));
> +	printf("\n");
>  
>  	printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No");
>  	puts("Capacity: ");
> diff --git a/include/mmc.h b/include/mmc.h
> index 09101e2..0fd7517 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -14,24 +14,41 @@
>  #include <linux/compiler.h>
>  #include <part.h>
>  
> -#define SD_VERSION_SD	0x20000
> -#define SD_VERSION_3	(SD_VERSION_SD | 0x300)
> -#define SD_VERSION_2	(SD_VERSION_SD | 0x200)
> -#define SD_VERSION_1_0	(SD_VERSION_SD | 0x100)
> -#define SD_VERSION_1_10	(SD_VERSION_SD | 0x10a)
> -#define MMC_VERSION_MMC		0x10000
> -#define MMC_VERSION_UNKNOWN	(MMC_VERSION_MMC)
> -#define MMC_VERSION_1_2		(MMC_VERSION_MMC | 0x102)
> -#define MMC_VERSION_1_4		(MMC_VERSION_MMC | 0x104)
> -#define MMC_VERSION_2_2		(MMC_VERSION_MMC | 0x202)
> -#define MMC_VERSION_3		(MMC_VERSION_MMC | 0x300)
> -#define MMC_VERSION_4		(MMC_VERSION_MMC | 0x400)
> -#define MMC_VERSION_4_1		(MMC_VERSION_MMC | 0x401)
> -#define MMC_VERSION_4_2		(MMC_VERSION_MMC | 0x402)
> -#define MMC_VERSION_4_3		(MMC_VERSION_MMC | 0x403)
> -#define MMC_VERSION_4_41	(MMC_VERSION_MMC | 0x429)
> -#define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
> -#define MMC_VERSION_5_0		(MMC_VERSION_MMC | 0x500)
> +/* SD/MMC version bits; 8 flags, 8 major, 8 minor, 8 change */
> +#define SD_VERSION_SD	(1U << 31)
> +#define MMC_VERSION_MMC	(1U << 30)
> +
> +#define MAKE_SDMMC_VERSION(a, b, c)	\
> +	((((u32)(a)) << 16) | ((u32)(b) << 8) | (u32)(c))
> +#define MAKE_SD_VERSION(a, b, c)	\
> +	(SD_VERSION_SD | MAKE_SDMMC_VERSION(a, b, c))
> +#define MAKE_MMC_VERSION(a, b, c)	\
> +	(MMC_VERSION_MMC | MAKE_SDMMC_VERSION(a, b, c))
> +
> +#define EXTRACT_SDMMC_MAJOR_VERSION(x)	\
> +	(((u32)(x) >> 16) & 0xff)
> +#define EXTRACT_SDMMC_MINOR_VERSION(x)	\
> +	(((u32)(x) >> 8) & 0xff)
> +#define EXTRACT_SDMMC_CHANGE_VERSION(x)	\
> +	((u32)(x) & 0xff)
> +
> +#define SD_VERSION_3		MAKE_SD_VERSION(3, 0, 0)
> +#define SD_VERSION_2		MAKE_SD_VERSION(2, 0, 0)
> +#define SD_VERSION_1_0		MAKE_SD_VERSION(1, 0, 0)
> +#define SD_VERSION_1_10		MAKE_SD_VERSION(1, 10, 0)
> +
> +#define MMC_VERSION_UNKNOWN	MAKE_MMC_VERSION(0, 0, 0)
> +#define MMC_VERSION_1_2		MAKE_MMC_VERSION(1, 2, 0)
> +#define MMC_VERSION_1_4		MAKE_MMC_VERSION(1, 4, 0)
> +#define MMC_VERSION_2_2		MAKE_MMC_VERSION(2, 2, 0)
> +#define MMC_VERSION_3		MAKE_MMC_VERSION(3, 0, 0)
> +#define MMC_VERSION_4		MAKE_MMC_VERSION(4, 0, 0)
> +#define MMC_VERSION_4_1		MAKE_MMC_VERSION(4, 1, 0)
> +#define MMC_VERSION_4_2		MAKE_MMC_VERSION(4, 2, 0)
> +#define MMC_VERSION_4_3		MAKE_MMC_VERSION(4, 3, 0)
> +#define MMC_VERSION_4_41	MAKE_MMC_VERSION(4, 4, 1)
> +#define MMC_VERSION_4_5		MAKE_MMC_VERSION(4, 5, 0)
> +#define MMC_VERSION_5_0		MAKE_MMC_VERSION(5, 0, 0)
>  
>  #define MMC_MODE_HS		(1 << 0)
>  #define MMC_MODE_HS_52MHz	(1 << 1)
> @@ -43,7 +60,8 @@
>  
>  #define SD_DATA_4BIT	0x00040000
>  
> -#define IS_SD(x) (x->version & SD_VERSION_SD)
> +#define IS_SD(x)	((x)->version & SD_VERSION_SD)
> +#define IS_MMC(x)	((x)->version & SD_VERSION_MMC)
>  
>  #define MMC_DATA_READ		1
>  #define MMC_DATA_WRITE		2
> 

  reply	other threads:[~2015-01-23 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 10:12 [U-Boot] [PATCH] mmc: Implement SD/MMC versioning properly Pantelis Antoniou
2015-01-23 13:40 ` Jaehoon Chung [this message]
2015-01-23 17:09 ` Stephen Warren

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=54C24F55.8020300@samsung.com \
    --to=jh80.chung@samsung.com \
    --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