From patchwork Wed Sep 15 09:43:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1528289 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=Iwu5fiLZ; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=vpLyvhK1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H8ZzL3z5Jz9sRK for ; Wed, 15 Sep 2021 19:43:42 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 482C582C2B; Wed, 15 Sep 2021 11:43:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1631699015; bh=3IS3Yyft86J1U//PzxGf2npbNSrs0bOmTxZ6IXUpoD8=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Iwu5fiLZgc5FmTa+L6NpCOWpcGC25vcpIpYP1qLFLGCQuIZ1/zxXlG3rSgVZo+ghQ +FZyrrsCJJtxjSpfnageHNbL2zd6S+3O31/+GPZdLqCb86di9HIb7uu55QknckqW/3 hjRjHxkLcmaE2kzjOmbPq4izYb0aUidHJinCzAGq+v2kfQOhZwEMNqaRbMKce2g+Bu z4a3mrZnAMszH3za6yE0pM3mpeIlLxHLclEAVnCT9GEDA220aUUp45ZaN0Bduiuv/t Kw43R2jbQIXnMPZPd4BcEtVo6GAJsvQD3q+HU0QiubLRcfOV1qT1lb855aV9xtITkN 6ZN8D7BzVua5Q== Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6D46480098; Wed, 15 Sep 2021 11:43:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1631699013; bh=3IS3Yyft86J1U//PzxGf2npbNSrs0bOmTxZ6IXUpoD8=; h=From:To:Cc:Subject:Date:From; b=vpLyvhK1rsjomlUsidnrBsbXwuD6tKAy+hifkQUHBSyqDtlg7CJaM7g8ahJH61CQe bUaRnRhN5r5e9+BPYnw1MQTeR7IVFQDrtGSPTZsUkLM4dHuo89ektIGf8mp/J14Qq1 ZjxO70VQC9BgbHNpOJhzKyuh6bXKpVAEoYjlNgg71HrffUGbPtZkRVhFlksRYgwoiy +o2RwpKrn6msaJxfLnku46sqbJWg3BmSxIiLkZTcVEQ13286tHsGuITm4a33KqhOul ZMLwSHEiGn6rDZg2BmuVjr1BqrbCkt1JtXup7XApqD8rQV5e1ujNZ26w+q4kcPdSW0 hS5/JmS0TbBYw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Jaehoon Chung , Peng Fan , Stefano Babic Subject: [PATCH v2] cmd: mmc: Support mmc hwpartition user enh start - Date: Wed, 15 Sep 2021 11:43:13 +0200 Message-Id: <20210915094313.85659-1-marex@denx.de> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Add option to extend the hardware partition to the maximum size by using the '-' dash sign instead of $cnt parameter. This is useful in case we want to switch the entire eMMC user area into pSLC mode, especially in case the device may be populated with different size eMMCs. With this change, we do not have to calculate the number of blocks of the user area manually. To switch the pSLC mode for user area, use e.g. the following. WARNING: This is a one-time irreversible change. => mmc hwpartition user enh 0 - wrrel on complete Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Jaehoon Chung Cc: Peng Fan Cc: Stefano Babic --- V2: - Add comment about block units - Fix spacing --- cmd/mmc.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index f1e30d0cf64..64e6be72803 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -593,7 +593,33 @@ static int do_mmc_list(struct cmd_tbl *cmdtp, int flag, } #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) -static int parse_hwpart_user(struct mmc_hwpart_conf *pconf, +static void parse_hwpart_user_enh_size(struct mmc *mmc, + struct mmc_hwpart_conf *pconf, + char *argv) +{ + int ret; + + pconf->user.enh_size = 0; + + if (!strcmp(argv, "-")) { /* The rest of eMMC */ + ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN); + ret = mmc_send_ext_csd(mmc, ext_csd); + if (ret) + return; + /* This value is in 512B block units */ + pconf->user.enh_size = + ((ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT + 2] << 16) + + (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT + 1] << 8) + + ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT]) * 1024 * + ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * + ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; + pconf->user.enh_size -= pconf->user.enh_start; + } else { + pconf->user.enh_size = dectoul(argv, NULL); + } +} + +static int parse_hwpart_user(struct mmc *mmc, struct mmc_hwpart_conf *pconf, int argc, char *const argv[]) { int i = 0; @@ -606,8 +632,7 @@ static int parse_hwpart_user(struct mmc_hwpart_conf *pconf, return -1; pconf->user.enh_start = dectoul(argv[i + 1], NULL); - pconf->user.enh_size = - dectoul(argv[i + 2], NULL); + parse_hwpart_user_enh_size(mmc, pconf, argv[i + 2]); i += 3; } else if (!strcmp(argv[i], "wrrel")) { if (i + 1 >= argc) @@ -679,7 +704,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag, while (i < argc) { if (!strcmp(argv[i], "user")) { i++; - r = parse_hwpart_user(&pconf, argc-i, &argv[i]); + r = parse_hwpart_user(mmc, &pconf, argc - i, &argv[i]); if (r < 0) return CMD_RET_USAGE; i += r;