* [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card
@ 2014-11-18 14:11 Markus Niebel
2014-11-21 10:50 ` Jaehoon Chung
2014-12-12 18:33 ` Pantelis Antoniou
0 siblings, 2 replies; 5+ messages in thread
From: Markus Niebel @ 2014-11-18 14:11 UTC (permalink / raw)
To: u-boot
From: Markus Niebel <Markus.Niebel@tq-group.com>
if the card claims to be high capacity and the card
is partitioned the capacity shall still be read from
ext_csd SEC_COUNT even if the resulting capacity is
smaller than 2 GiB
Signed-off-by: Markus Niebel <Markus.Niebel@tq-group.com>
---
drivers/mmc/mmc.c | 15 +++++++++++++++
include/mmc.h | 3 +++
2 files changed, 18 insertions(+)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 44a4feb..24b0989 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1022,6 +1022,21 @@ static int mmc_startup(struct mmc *mmc)
mmc->erase_grp_size =
ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
MMC_MAX_BLOCK_LEN * 1024;
+ /*
+ * if high capacity and partition setting completed
+ * SEC_COUNT is valid even if it is smaller than 2 GiB
+ * JEDEC Standard JESD84-B45, 6.2.4
+ */
+ if (mmc->high_capacity &&
+ (ext_csd[EXT_CSD_PARTITION_SETTING] &
+ EXT_CSD_PARTITION_SETTING_COMPLETED)) {
+ capacity = (ext_csd[EXT_CSD_SEC_CNT]) |
+ (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) |
+ (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) |
+ (ext_csd[EXT_CSD_SEC_CNT + 3] << 24);
+ capacity *= MMC_MAX_BLOCK_LEN;
+ mmc->capacity_user = capacity;
+ }
} else {
/* Calculate the group size from the csd value. */
int erase_gsz, erase_gmul;
diff --git a/include/mmc.h b/include/mmc.h
index d74a190..cb91565 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -147,6 +147,7 @@
* EXT_CSD fields
*/
#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
+#define EXT_CSD_PARTITION_SETTING 155 /* R/W */
#define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */
#define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
@@ -197,6 +198,8 @@
#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2)
#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x)
+#define EXT_CSD_PARTITION_SETTING_COMPLETED (1 << 0)
+
#define R1_ILLEGAL_COMMAND (1 << 22)
#define R1_APP_CMD (1 << 5)
--
2.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card
2014-11-18 14:11 [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card Markus Niebel
@ 2014-11-21 10:50 ` Jaehoon Chung
2014-11-21 11:51 ` Markus Niebel
2014-11-21 12:36 ` Jaehoon Chung
2014-12-12 18:33 ` Pantelis Antoniou
1 sibling, 2 replies; 5+ messages in thread
From: Jaehoon Chung @ 2014-11-21 10:50 UTC (permalink / raw)
To: u-boot
Hi, Markus.
On 11/18/2014 11:11 PM, Markus Niebel wrote:
> From: Markus Niebel <Markus.Niebel@tq-group.com>
>
> if the card claims to be high capacity and the card
> is partitioned the capacity shall still be read from
> ext_csd SEC_COUNT even if the resulting capacity is
> smaller than 2 GiB
I have one question.
"smaller than 2GiB" means the size after completed partition?
Best Regards,
Jaehoon Chung
>
> Signed-off-by: Markus Niebel <Markus.Niebel@tq-group.com>
> ---
> drivers/mmc/mmc.c | 15 +++++++++++++++
> include/mmc.h | 3 +++
> 2 files changed, 18 insertions(+)
>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 44a4feb..24b0989 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1022,6 +1022,21 @@ static int mmc_startup(struct mmc *mmc)
> mmc->erase_grp_size =
> ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
> MMC_MAX_BLOCK_LEN * 1024;
> + /*
> + * if high capacity and partition setting completed
> + * SEC_COUNT is valid even if it is smaller than 2 GiB
> + * JEDEC Standard JESD84-B45, 6.2.4
> + */
> + if (mmc->high_capacity &&
> + (ext_csd[EXT_CSD_PARTITION_SETTING] &
> + EXT_CSD_PARTITION_SETTING_COMPLETED)) {
> + capacity = (ext_csd[EXT_CSD_SEC_CNT]) |
> + (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) |
> + (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) |
> + (ext_csd[EXT_CSD_SEC_CNT + 3] << 24);
> + capacity *= MMC_MAX_BLOCK_LEN;
> + mmc->capacity_user = capacity;
> + }
> } else {
> /* Calculate the group size from the csd value. */
> int erase_gsz, erase_gmul;
> diff --git a/include/mmc.h b/include/mmc.h
> index d74a190..cb91565 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -147,6 +147,7 @@
> * EXT_CSD fields
> */
> #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
> +#define EXT_CSD_PARTITION_SETTING 155 /* R/W */
> #define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */
> #define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
> #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
> @@ -197,6 +198,8 @@
> #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2)
> #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x)
>
> +#define EXT_CSD_PARTITION_SETTING_COMPLETED (1 << 0)
> +
> #define R1_ILLEGAL_COMMAND (1 << 22)
> #define R1_APP_CMD (1 << 5)
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card
2014-11-21 10:50 ` Jaehoon Chung
@ 2014-11-21 11:51 ` Markus Niebel
2014-11-21 12:36 ` Jaehoon Chung
1 sibling, 0 replies; 5+ messages in thread
From: Markus Niebel @ 2014-11-21 11:51 UTC (permalink / raw)
To: u-boot
Hello Jaehoon Chung
Am 21.11.2014 um 11:50 schrieb Jaehoon Chung:
> Hi, Markus.
>
> On 11/18/2014 11:11 PM, Markus Niebel wrote:
>> From: Markus Niebel <Markus.Niebel@tq-group.com>
>>
>> if the card claims to be high capacity and the card
>> is partitioned the capacity shall still be read from
>> ext_csd SEC_COUNT even if the resulting capacity is
>> smaller than 2 GiB
>
> I have one question.
> "smaller than 2GiB" means the size after completed partition?
Yes. Some cards enable a pseudo SLC mode using the enhanced partition attribute.
This results in reduced sizes after completion.
Tested with a 4 GB Micron eMMC (resulting size is around 1.8 GiB)
>
> Best Regards,
> Jaehoon Chung
>
Best Regards
Markus Niebel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card
2014-11-21 10:50 ` Jaehoon Chung
2014-11-21 11:51 ` Markus Niebel
@ 2014-11-21 12:36 ` Jaehoon Chung
1 sibling, 0 replies; 5+ messages in thread
From: Jaehoon Chung @ 2014-11-21 12:36 UTC (permalink / raw)
To: u-boot
Hi, Markus.
It's reasonable, looks good to me.
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
On 11/21/2014 07:50 PM, Jaehoon Chung wrote:
> Hi, Markus.
>
> On 11/18/2014 11:11 PM, Markus Niebel wrote:
>> From: Markus Niebel <Markus.Niebel@tq-group.com>
>>
>> if the card claims to be high capacity and the card
>> is partitioned the capacity shall still be read from
>> ext_csd SEC_COUNT even if the resulting capacity is
>> smaller than 2 GiB
>
> I have one question.
> "smaller than 2GiB" means the size after completed partition?
>
> Best Regards,
> Jaehoon Chung
>
>>
>> Signed-off-by: Markus Niebel <Markus.Niebel@tq-group.com>
>> ---
>> drivers/mmc/mmc.c | 15 +++++++++++++++
>> include/mmc.h | 3 +++
>> 2 files changed, 18 insertions(+)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 44a4feb..24b0989 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -1022,6 +1022,21 @@ static int mmc_startup(struct mmc *mmc)
>> mmc->erase_grp_size =
>> ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
>> MMC_MAX_BLOCK_LEN * 1024;
>> + /*
>> + * if high capacity and partition setting completed
>> + * SEC_COUNT is valid even if it is smaller than 2 GiB
>> + * JEDEC Standard JESD84-B45, 6.2.4
>> + */
>> + if (mmc->high_capacity &&
>> + (ext_csd[EXT_CSD_PARTITION_SETTING] &
>> + EXT_CSD_PARTITION_SETTING_COMPLETED)) {
>> + capacity = (ext_csd[EXT_CSD_SEC_CNT]) |
>> + (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) |
>> + (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) |
>> + (ext_csd[EXT_CSD_SEC_CNT + 3] << 24);
>> + capacity *= MMC_MAX_BLOCK_LEN;
>> + mmc->capacity_user = capacity;
>> + }
>> } else {
>> /* Calculate the group size from the csd value. */
>> int erase_gsz, erase_gmul;
>> diff --git a/include/mmc.h b/include/mmc.h
>> index d74a190..cb91565 100644
>> --- a/include/mmc.h
>> +++ b/include/mmc.h
>> @@ -147,6 +147,7 @@
>> * EXT_CSD fields
>> */
>> #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
>> +#define EXT_CSD_PARTITION_SETTING 155 /* R/W */
>> #define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */
>> #define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
>> #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
>> @@ -197,6 +198,8 @@
>> #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2)
>> #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x)
>>
>> +#define EXT_CSD_PARTITION_SETTING_COMPLETED (1 << 0)
>> +
>> #define R1_ILLEGAL_COMMAND (1 << 22)
>> #define R1_APP_CMD (1 << 5)
>>
>>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card
2014-11-18 14:11 [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card Markus Niebel
2014-11-21 10:50 ` Jaehoon Chung
@ 2014-12-12 18:33 ` Pantelis Antoniou
1 sibling, 0 replies; 5+ messages in thread
From: Pantelis Antoniou @ 2014-12-12 18:33 UTC (permalink / raw)
To: u-boot
Hi Markus,
Looks good to me.
> On Nov 18, 2014, at 16:11 , Markus Niebel <list-09_u-boot@tqsc.de> wrote:
>
> From: Markus Niebel <Markus.Niebel@tq-group.com>
>
> if the card claims to be high capacity and the card
> is partitioned the capacity shall still be read from
> ext_csd SEC_COUNT even if the resulting capacity is
> smaller than 2 GiB
>
> Signed-off-by: Markus Niebel <Markus.Niebel@tq-group.com>
> ---
> drivers/mmc/mmc.c | 15 +++++++++++++++
> include/mmc.h | 3 +++
> 2 files changed, 18 insertions(+)
>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 44a4feb..24b0989 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1022,6 +1022,21 @@ static int mmc_startup(struct mmc *mmc)
> mmc->erase_grp_size =
> ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
> MMC_MAX_BLOCK_LEN * 1024;
> + /*
> + * if high capacity and partition setting completed
> + * SEC_COUNT is valid even if it is smaller than 2 GiB
> + * JEDEC Standard JESD84-B45, 6.2.4
> + */
> + if (mmc->high_capacity &&
> + (ext_csd[EXT_CSD_PARTITION_SETTING] &
> + EXT_CSD_PARTITION_SETTING_COMPLETED)) {
> + capacity = (ext_csd[EXT_CSD_SEC_CNT]) |
> + (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) |
> + (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) |
> + (ext_csd[EXT_CSD_SEC_CNT + 3] << 24);
> + capacity *= MMC_MAX_BLOCK_LEN;
> + mmc->capacity_user = capacity;
> + }
> } else {
> /* Calculate the group size from the csd value. */
> int erase_gsz, erase_gmul;
> diff --git a/include/mmc.h b/include/mmc.h
> index d74a190..cb91565 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -147,6 +147,7 @@
> * EXT_CSD fields
> */
> #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
> +#define EXT_CSD_PARTITION_SETTING 155 /* R/W */
> #define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */
> #define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
> #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
> @@ -197,6 +198,8 @@
> #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2)
> #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x)
>
> +#define EXT_CSD_PARTITION_SETTING_COMPLETED (1 << 0)
> +
> #define R1_ILLEGAL_COMMAND (1 << 22)
> #define R1_APP_CMD (1 << 5)
>
> --
> 2.1.1
>
Thanks, applied.
? Pantelis
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-12 18:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-18 14:11 [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card Markus Niebel
2014-11-21 10:50 ` Jaehoon Chung
2014-11-21 11:51 ` Markus Niebel
2014-11-21 12:36 ` Jaehoon Chung
2014-12-12 18:33 ` Pantelis Antoniou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox