From patchwork Tue Nov 18 14:11:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Niebel X-Patchwork-Id: 412045 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id CE47B14010F for ; Wed, 19 Nov 2014 00:57:49 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 293F04B653; Tue, 18 Nov 2014 14:57:47 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zS0lyvHGP43S; Tue, 18 Nov 2014 14:57:46 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 905294B639; Tue, 18 Nov 2014 14:57:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9535C4B639 for ; Tue, 18 Nov 2014 14:57:42 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HEMCCbNk-rXO for ; Tue, 18 Nov 2014 14:57:42 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by theia.denx.de (Postfix) with ESMTPS id 778454B635 for ; Tue, 18 Nov 2014 14:57:38 +0100 (CET) Received: from [89.246.71.91] (helo=mail7.tqsc.de) by smtprelay01.ispgateway.de with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.84) (envelope-from ) id 1XqjHm-0008B7-7E; Tue, 18 Nov 2014 14:57:38 +0100 Received: from sc1006092vm.tqsc.de ([192.168.169.50] helo=ubuntu.tqsc.de) by mail7.tqsc.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XqjHl-0002xP-JR; Tue, 18 Nov 2014 14:57:37 +0100 From: Markus Niebel To: u-boot@lists.denx.de Date: Tue, 18 Nov 2014 15:11:42 +0100 Message-Id: <1416319902-22915-1-git-send-email-list-09_u-boot@tqsc.de> X-Mailer: git-send-email 2.1.1 X-Df-Sender: MTQ1NzgzNQ== Cc: panto@antoniou-consulting.com, Markus Niebel Subject: [U-Boot] [PATCH ] MMC: fix user capacity for partitioned eMMC card X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Markus Niebel 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 Acked-by: Jaehoon Chung --- 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)