All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Harvey <tharvey@gateworks.com>
To: Tom Rini <trini@konsulko.com>, Tim Harvey <tharvey@gateworks.com>,
	Simon Glass <sjg@chromium.org>, Marek Vasut <marex@denx.de>,
	Fabio Estevam <festevam@gmail.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	u-boot@lists.denx.de, Dragan Simic <dsimic@manjaro.org>
Subject: [PATCH v3] mmc: allow use of hardware partition names for mmc partconf
Date: Fri, 26 Apr 2024 17:11:57 -0700	[thread overview]
Message-ID: <20240427001157.1460302-1-tharvey@gateworks.com> (raw)

eMMC devices have hardware partitions such as user, boot0, and boot1.

Add an enumerated type defining the hardware partition values and an
array of names describing them by name that can be used throughout
U-Boot.

Allow these names to be displayed when reading and used when setting
the mmc PARTITION_CONFIG field via 'mmc partconf'.

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 <tharvey@gateworks.com>
---
v3:
 - define partition names and values in mmc.h/mmc.c for others to use

v2:
 - fix typo in subject
 - add names for gp1..gp4
---
 cmd/mmc.c         | 14 +++++++++++---
 drivers/mmc/mmc.c | 11 +++++++++++
 include/mmc.h     | 15 +++++++++++++++
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/cmd/mmc.c b/cmd/mmc.c
index 2d5430a53079..26ab4450816b 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -14,6 +14,7 @@
 #include <part.h>
 #include <sparse_format.h>
 #include <image-sparse.h>
+#include <linux/ctype.h>
 
 static int curr_device = -1;
 
@@ -918,8 +919,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, emmc_hwpart_names[part], access);
 
 	return CMD_RET_SUCCESS;
 }
@@ -949,7 +950,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 <= EMMC_HWPART_USER; part_num++) {
+			if (!strcmp(argv[3], emmc_hwpart_names[part_num]))
+				break;
+		}
+	} else {
+		part_num = dectoul(argv[3], NULL);
+	}
 	access = dectoul(argv[4], NULL);
 
 	/* acknowledge to be sent during boot operation */
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 7b068c71ff37..132afe1b8a29 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -29,6 +29,17 @@
 
 #define DEFAULT_CMD6_TIMEOUT_MS  500
 
+const char *emmc_hwpart_names[] = {
+	"user",
+	"boot0",
+	"boot1",
+	"gp1",
+	"gp2",
+	"gp3",
+	"gp4",
+	"user",
+};
+
 static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
 
 #if !CONFIG_IS_ENABLED(DM_MMC)
diff --git a/include/mmc.h b/include/mmc.h
index 4b8327f1f93b..7243bd761202 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -381,6 +381,21 @@ enum mmc_voltage {
 #define MMC_TIMING_MMC_HS200	9
 #define MMC_TIMING_MMC_HS400	10
 
+/* emmc hardware partition values */
+enum emmc_hwpart {
+	EMMC_HWPART_DEFAULT = 0,
+	EMMC_HWPART_BOOT0 = 1,
+	EMMC_HWPART_BOOT1 = 2,
+	EMMC_HWPART_GP1 = 3,
+	EMMC_HWPART_GP2 = 4,
+	EMMC_HWPART_GP3 = 5,
+	EMMC_HWPART_GP4 = 6,
+	EMMC_HWPART_USER = 7,
+};
+
+/* emmc hardware partition names */
+extern const char *emmc_hwpart_names[];
+
 /* Driver model support */
 
 /**
-- 
2.25.1


             reply	other threads:[~2024-04-27  0:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-27  0:11 Tim Harvey [this message]
2024-04-27  0:48 ` [PATCH v3] mmc: allow use of hardware partition names for mmc partconf Marek Vasut
2024-04-27  1:29   ` E Shattow
2024-04-27 10:22     ` Marek Vasut
2024-04-27 12:06       ` E Shattow
2024-04-27 23:19         ` Marek Vasut
2024-04-27 23:20 ` Marek Vasut
2024-04-29 16:48   ` Tim Harvey
2024-04-29 20:15     ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240427001157.1460302-1-tharvey@gateworks.com \
    --to=tharvey@gateworks.com \
    --cc=dsimic@manjaro.org \
    --cc=festevam@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=marex@denx.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.