diff mbox

[U-Boot] mmc: support the correct card version for eMMC

Message ID 5108B024.2040606@samsung.com
State Accepted
Delegated to: Andy Fleming
Headers show

Commit Message

Jaehoon Chung Jan. 30, 2013, 5:31 a.m. UTC
eMMC vesrion is supported up to v4.5.
But bootloader isn't saw the exact eMMC version.
After applied this patch,
if use the mmcinfo command, then can see the exactly mmc version.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 common/cmd_mmc.c  |    2 +-
 drivers/mmc/mmc.c |   18 ++++++++++++++++++
 include/mmc.h     |   21 +++++++++++++--------
 3 files changed, 32 insertions(+), 9 deletions(-)

Comments

Jaehoon Chung Jan. 31, 2013, 11:55 a.m. UTC | #1
Hi Rommel,

Could you review or test for this?

Best Regards,
Jaehoon Chung

On 01/30/2013 02:31 PM, Jaehoon Chung wrote:
> eMMC vesrion is supported up to v4.5.
> But bootloader isn't saw the exact eMMC version.
> After applied this patch,
> if use the mmcinfo command, then can see the exactly mmc version.
> 
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  common/cmd_mmc.c  |    2 +-
>  drivers/mmc/mmc.c |   18 ++++++++++++++++++
>  include/mmc.h     |   21 +++++++++++++--------
>  3 files changed, 32 insertions(+), 9 deletions(-)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 7dacd51..9e8d293 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -106,7 +106,7 @@ static void print_mmcinfo(struct mmc *mmc)
>  	printf("Rd Block Len: %d\n", mmc->read_bl_len);
>  
>  	printf("%s version %d.%d\n", IS_SD(mmc) ? "SD" : "MMC",
> -			(mmc->version >> 4) & 0xf, mmc->version & 0xf);
> +			(mmc->version >> 8) & 0xf, mmc->version & 0xff);
>  
>  	printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No");
>  	puts("Capacity: ");
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 72e8ce6..3b3317e 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1029,6 +1029,24 @@ static int mmc_startup(struct mmc *mmc)
>  				mmc->capacity = capacity;
>  		}
>  
> +		switch (ext_csd[EXT_CSD_REV]) {
> +		case 1:
> +			mmc->version = MMC_VERSION_4_1;
> +			break;
> +		case 2:
> +			mmc->version = MMC_VERSION_4_2;
> +			break;
> +		case 3:
> +			mmc->version = MMC_VERSION_4_3;
> +			break;
> +		case 5:
> +			mmc->version = MMC_VERSION_4_41;
> +			break;
> +		case 6:
> +			mmc->version = MMC_VERSION_4_5;
> +			break;
> +		}
> +
>  		/*
>  		 * Check whether GROUP_DEF is set, if yes, read out
>  		 * group size from ext_csd directly, or calculate
> diff --git a/include/mmc.h b/include/mmc.h
> index a13e2bd..d0ec744 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -30,16 +30,21 @@
>  #include <linux/compiler.h>
>  
>  #define SD_VERSION_SD	0x20000
> -#define SD_VERSION_2	(SD_VERSION_SD | 0x20)
> -#define SD_VERSION_1_0	(SD_VERSION_SD | 0x10)
> -#define SD_VERSION_1_10	(SD_VERSION_SD | 0x1a)
> +#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 | 0x12)
> -#define MMC_VERSION_1_4		(MMC_VERSION_MMC | 0x14)
> -#define MMC_VERSION_2_2		(MMC_VERSION_MMC | 0x22)
> -#define MMC_VERSION_3		(MMC_VERSION_MMC | 0x30)
> -#define MMC_VERSION_4		(MMC_VERSION_MMC | 0x40)
> +#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_MODE_HS		0x001
>  #define MMC_MODE_HS_52MHz	0x010
>
Mela Custodio Feb. 1, 2013, 10:03 p.m. UTC | #2
Dear Jaehoon,

On 2013.01/31, Jaehoon Chung wrote:
> Hi Rommel,
> 
> Could you review or test for this?

> > eMMC vesrion is supported up to v4.5.
> > But bootloader isn't saw the exact eMMC version.
> > After applied this patch,
> > if use the mmcinfo command, then can see the exactly mmc version.
> > 
> > Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > ---
> >  common/cmd_mmc.c  |    2 +-
> >  drivers/mmc/mmc.c |   18 ++++++++++++++++++
> >  include/mmc.h     |   21 +++++++++++++--------
> >  3 files changed, 32 insertions(+), 9 deletions(-)

Doesn't git am cleanly when "mmc: check the revision for sd3.0" is
applied first. And "mmc: check the revision for sd3.0" doesn't git am
cleanly if this patch is applied first. Maybe merging the two patches is
better to avoid this chicken and egg problem.

Builds OK all by itself.

Acked-by: Rommel Custodio <sessyargc@gmail.com>

All the best,
Rommel
Tom Rini April 17, 2013, 3:37 p.m. UTC | #3
On Tue, Jan 29, 2013 at 07:31:16PM -0000, Jaehoon Chung wrote:

> eMMC vesrion is supported up to v4.5.
> But bootloader isn't saw the exact eMMC version.
> After applied this patch,
> if use the mmcinfo command, then can see the exactly mmc version.
> 
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Acked-by: Rommel Custodio <sessyargc@gmail.com>

Applied to u-boot/master and tested on omap5_uevm (eMMC 4.45) and
next gen beaglebone (am335x_evm, eMMC 4.41).  Thanks!
diff mbox

Patch

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 7dacd51..9e8d293 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -106,7 +106,7 @@  static void print_mmcinfo(struct mmc *mmc)
 	printf("Rd Block Len: %d\n", mmc->read_bl_len);
 
 	printf("%s version %d.%d\n", IS_SD(mmc) ? "SD" : "MMC",
-			(mmc->version >> 4) & 0xf, mmc->version & 0xf);
+			(mmc->version >> 8) & 0xf, mmc->version & 0xff);
 
 	printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No");
 	puts("Capacity: ");
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 72e8ce6..3b3317e 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1029,6 +1029,24 @@  static int mmc_startup(struct mmc *mmc)
 				mmc->capacity = capacity;
 		}
 
+		switch (ext_csd[EXT_CSD_REV]) {
+		case 1:
+			mmc->version = MMC_VERSION_4_1;
+			break;
+		case 2:
+			mmc->version = MMC_VERSION_4_2;
+			break;
+		case 3:
+			mmc->version = MMC_VERSION_4_3;
+			break;
+		case 5:
+			mmc->version = MMC_VERSION_4_41;
+			break;
+		case 6:
+			mmc->version = MMC_VERSION_4_5;
+			break;
+		}
+
 		/*
 		 * Check whether GROUP_DEF is set, if yes, read out
 		 * group size from ext_csd directly, or calculate
diff --git a/include/mmc.h b/include/mmc.h
index a13e2bd..d0ec744 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -30,16 +30,21 @@ 
 #include <linux/compiler.h>
 
 #define SD_VERSION_SD	0x20000
-#define SD_VERSION_2	(SD_VERSION_SD | 0x20)
-#define SD_VERSION_1_0	(SD_VERSION_SD | 0x10)
-#define SD_VERSION_1_10	(SD_VERSION_SD | 0x1a)
+#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 | 0x12)
-#define MMC_VERSION_1_4		(MMC_VERSION_MMC | 0x14)
-#define MMC_VERSION_2_2		(MMC_VERSION_MMC | 0x22)
-#define MMC_VERSION_3		(MMC_VERSION_MMC | 0x30)
-#define MMC_VERSION_4		(MMC_VERSION_MMC | 0x40)
+#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_MODE_HS		0x001
 #define MMC_MODE_HS_52MHz	0x010