From patchwork Fri Apr 26 00:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 1927980 X-Patchwork-Delegate: festevam@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VQYBT3MZYz1ybC for ; Fri, 26 Apr 2024 10:14:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F0974890AA; Fri, 26 Apr 2024 02:14:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 4ECC38909F; Fri, 26 Apr 2024 02:14:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from finn.localdomain (finn.gateworks.com [108.161.129.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5522A890AD for ; Fri, 26 Apr 2024 02:14:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gateworks.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tharvey@gateworks.com Received: from [68.189.91.139] (helo=tharvey.pdc.gateworks.com) by finn.localdomain with esmtp (Exim 4.95) (envelope-from ) id 1s09EM-005zBS-DX; Fri, 26 Apr 2024 00:14:22 +0000 From: Tim Harvey To: Tom Rini , Tim Harvey , Simon Glass , Marek Vasut , Fabio Estevam , Jaehoon Chung , u-boot@lists.denx.de Subject: [PATCH] cmd: mmc: allow use of hardware parittion names for mmc partconf Date: Thu, 25 Apr 2024 17:14:19 -0700 Message-Id: <20240426001419.1210364-1-tharvey@gateworks.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean eMMC devices have hardware partitions such as user, boot0, and boot1. Allow these names to be displayed when reading the mmc PARTITION_CONFIG field via 'mmc partconf'. Additionally allow a name to be specified when setting the PARTITION_CONFIG. Before: u-boot=> mmc partconf 2 1 1 0 && mmc partconf 2 EXT_CSD[179], PARTITION_CONFIG: BOOT_ACK: 0x1 BOOT_PARTITION_ENABLE: 0x2 PARTITION_ACCESS: 0x0 After: u-boot=> mmc partconf 2 1 1 0 && mmc partconf 2 EXT_CSD[179], PARTITION_CONFIG: BOOT_ACK: 0x1 BOOT_PARTITION_ENABLE: 0x1 (boot0) PARTITION_ACCESS: 0x0 u-boot=> mmc partconf 2 1 boot1 0 && mmc partconf 2 EXT_CSD[179], PARTITION_CONFIG: BOOT_ACK: 0x1 BOOT_PARTITION_ENABLE: 0x2 (boot1) PARTITION_ACCESS: 0x0 Signed-off-by: Tim Harvey Reviewed-by: Fabio Estevam --- cmd/mmc.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index 2d5430a53079..26692a8e349b 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -14,6 +14,18 @@ #include #include #include +#include + +static const char *mmc_partnames[] = { + "user", + "boot0", + "boot1", + "", + "", + "", + "", + "user", +}; static int curr_device = -1; @@ -918,8 +930,8 @@ static int mmc_partconf_print(struct mmc *mmc, const char *varname) printf("EXT_CSD[179], PARTITION_CONFIG:\n" "BOOT_ACK: 0x%x\n" - "BOOT_PARTITION_ENABLE: 0x%x\n" - "PARTITION_ACCESS: 0x%x\n", ack, part, access); + "BOOT_PARTITION_ENABLE: 0x%x (%s)\n" + "PARTITION_ACCESS: 0x%x\n", ack, part, mmc_partnames[part], access); return CMD_RET_SUCCESS; } @@ -949,7 +961,14 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag, return mmc_partconf_print(mmc, cmd_arg2(argc, argv)); ack = dectoul(argv[2], NULL); - part_num = dectoul(argv[3], NULL); + if (!isdigit(*argv[3])) { + for (part_num = 0; part_num < ARRAY_SIZE(mmc_partnames); part_num++) { + if (!strcmp(argv[3], mmc_partnames[part_num])) + break; + } + } else { + part_num = dectoul(argv[3], NULL); + } access = dectoul(argv[4], NULL); /* acknowledge to be sent during boot operation */