Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 312ABC433EF for ; Sat, 11 Sep 2021 21:14:39 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D558960FE3 for ; Sat, 11 Sep 2021 21:14:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D558960FE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 49AD082C7D; Sat, 11 Sep 2021 23:14: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=1631394876; bh=hp2v/qFvVKovjhnmJLDy2wbv4DQABUJhlQ4WE9GPZ1Y=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=M9o0YTOPOdIcp8Be8WpZ84yBnnvTo0V/1njfD25TZHRh+g53ST2wF3I4KsH1QBkDx 0JxRLiAl8wNpWZrDYz738DMahyba/5cCu0HQpvur6rdDMZy80egX01VUmrb/Hhs7fm Up2TXIYvqhWy47HmZh4yv1PE1fwFDtaTR75ITIiLygj8a8AsCsiZzeIvARv0RrFr8t GnSYLCmpuPjqk40mxpoyBULzwkGrsUbYCTWsPXCQo55tUUuMktLQJU314gMq1FG3Qk Q+mk350ujgiH6IdBhYOyc8E8WkbC5UFTY6G44lqNDVORRtg7DVaCzyXwjkZS1l3xMp vGp7RzK0kSCCw== 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 C737682999; Sat, 11 Sep 2021 23:14:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1631394873; bh=hp2v/qFvVKovjhnmJLDy2wbv4DQABUJhlQ4WE9GPZ1Y=; h=From:To:Cc:Subject:Date:From; b=LlyOnzNRsweMG8S4lqdY2AHx7Bn5MMB2vQ/V9cRSk+q+YTiKcFSXJnNO2eSJjvGqN trLN+mY4VBCtzWAw0GMzKE5tYM3LJcdnkmq4F0RNGbiFtINahGdKsUsrp7d4mynrC/ hkghCh+qzccdbAFF+BfHhJ3XFCbHF+oRAal7f2Srtn1gV0SnMKBR+CFo334usgwX0u wYEDpsQbMigXHgoRHzbpjn1rprp5hNHBcKd7fyP63j4goLflZ5vAhu1TYFi9v2S89h ZhjtRvoGYjApZ0aRZJdVVgNxwolp6IDxdPkQN9sDXQ/z7gLt+eCyJry/96xy3CyBjS wTwDU9FmMxajw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Jaehoon Chung , Peng Fan , Stefano Babic Subject: [PATCH] cmd: mmc: Support mmc hwpartition user enh start - Date: Sat, 11 Sep 2021 23:14:16 +0200 Message-Id: <20210911211416.32390-1-marex@denx.de> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- cmd/mmc.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index c67ad762422..b6bb951347d 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -560,7 +560,32 @@ 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; + 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; @@ -573,8 +598,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) @@ -646,7 +670,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; -- 2.33.0