mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask
@ 2023-11-14 13:30 Marco Felsch
  2023-11-14 13:30 ` [PATCH 2/8] mci: core: check switch error for switch command Marco Felsch
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>

Extended CSD register PARTITIONING_SUPPORT ENH_ATTRIBUTE_EN is bit 1
instead of 0

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 include/mci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/mci.h b/include/mci.h
index 3e93f378e4a3..616c7c3cae5c 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -305,7 +305,7 @@
 #define EXT_CSD_ENH_USR_MASK		(1 << 0)
 
 /* register PARTITIONING_SUPPORT [160] */
-#define EXT_CSD_ENH_ATTRIBUTE_EN_MASK	(1 << 0)
+#define EXT_CSD_ENH_ATTRIBUTE_EN_MASK	(1 << 1)
 
 /* register BUS_WIDTH [183], field Bus Mode Selection [4:0] */
 #define EXT_CSD_BUS_WIDTH_1	0	/* Card is in 1 bit mode */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/8] mci: core: check switch error for switch command
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-14 13:30 ` [PATCH 3/8] commands: mmc: add write_reliability subcommand Marco Felsch
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>

check whether SWITCH_ERROR is set, if set the device did not switch to
the expected mode as requested by the SWITCH command.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
[m.felsch@pengutronix.de: align commit message and minor cleanups]
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/mci/mci-core.c | 15 ++++++++++++++-
 include/mci.h          |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index bc049c80298b..1276920e1604 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -494,7 +494,9 @@ int mci_send_ext_csd(struct mci *mci, char *ext_csd)
  */
 int mci_switch(struct mci *mci, unsigned index, unsigned value)
 {
+	unsigned int status;
 	struct mci_cmd cmd;
+	int ret;
 
 	mci_setup_cmd(&cmd, MMC_CMD_SWITCH,
 		(MMC_SWITCH_MODE_WRITE_BYTE << 24) |
@@ -502,7 +504,18 @@ int mci_switch(struct mci *mci, unsigned index, unsigned value)
 		(value << 8),
 		 MMC_RSP_R1b);
 
-	return mci_send_cmd(mci, &cmd, NULL);
+	ret = mci_send_cmd(mci, &cmd, NULL);
+	if (ret)
+		return ret;
+
+	ret = mci_send_status(mci, &status);
+	if (ret)
+		return ret;
+
+	if (status & R1_SWITCH_ERROR)
+		return -EIO;
+
+	return 0;
 }
 
 static blkcnt_t mci_calc_blk_cnt(blkcnt_t cap, unsigned shift)
diff --git a/include/mci.h b/include/mci.h
index 616c7c3cae5c..f38384613728 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -319,6 +319,7 @@
 #define R1_STATUS(x)			(x & 0xFFF9A000)
 #define R1_CURRENT_STATE(x)		((x & 0x00001E00) >> 9)	/* sx, b (4 bits) */
 #define R1_READY_FOR_DATA 		(1 << 8)		/* sx, a */
+#define R1_SWITCH_ERROR			(1 << 7)
 #define R1_APP_CMD			(1 << 5)
 
 #define R1_STATUS_MASK			(~0x0206BF7F)
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/8] commands: mmc: add write_reliability subcommand
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
  2023-11-14 13:30 ` [PATCH 2/8] mci: core: check switch error for switch command Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-14 13:30 ` [PATCH 4/8] commands: mmc: add partition_complete subcommand Marco Felsch
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>

Add new sub-command to enable the write reliability.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
[m.felsch@pengutronix.de: minor cleanups]
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 commands/mmc.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++-
 include/mci.h  |  4 +++
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/commands/mmc.c b/commands/mmc.c
index 1e62b71850e0..1009b16bfdf7 100644
--- a/commands/mmc.c
+++ b/commands/mmc.c
@@ -147,6 +147,67 @@ static int do_mmc_enh_area(int argc, char *argv[])
 	return COMMAND_ERROR;
 }
 
+static int do_mmc_write_reliability(int argc, char *argv[])
+{
+	const char *devpath;
+	struct mci *mci;
+	u8 *ext_csd;
+
+	if (argc - optind != 1) {
+		printf("Usage: mmc write_reliability /dev/mmcX\n");
+		return COMMAND_ERROR_USAGE;
+	}
+
+	devpath = argv[optind];
+
+	mci = mci_get_device_by_devpath(devpath);
+	if (!mci) {
+		printf("Failure to open %s as mci device\n", devpath);
+		return COMMAND_ERROR;
+	}
+
+	ext_csd = mci_get_ext_csd(mci);
+	if (IS_ERR(ext_csd))
+		return COMMAND_ERROR;
+
+	if (ext_csd[EXT_CSD_PARTITION_SETTING_COMPLETED]) {
+		printf("Partitioning already finalized\n");
+		goto error;
+	}
+
+	if (!(ext_csd[EXT_CSD_WR_REL_PARAM] & EXT_CSD_EN_REL_WR)) {
+		printf("Device doesn't support the enhanced definition of reliable write\n");
+		goto error;
+	}
+
+	if (!(ext_csd[EXT_CSD_WR_REL_PARAM] & EXT_CSD_HS_CTRL_REL)) {
+		printf("Device doesn't support WR_REL_SET writes\n");
+		goto error;
+	}
+
+	/*
+	 * Host has one opportunity to write all of the bits. Separate writes to
+	 * individual bits are not permitted so set all bits for now.
+	 */
+	if ((ext_csd[EXT_CSD_WR_REL_SET] & 0x1f) != 0x1f) {
+		int ret;
+
+		ret = mci_switch(mci, EXT_CSD_WR_REL_SET, 0x1f);
+		if (ret) {
+			printf("Failure to write to EXT_CSD_WR_REL_SET\n");
+			goto error;
+		}
+	}
+
+	free(ext_csd);
+
+	return COMMAND_SUCCESS;
+
+error:
+	free(ext_csd);
+	return COMMAND_ERROR;
+}
+
 static struct {
 	const char *cmd;
 	int (*func)(int argc, char *argv[]);
@@ -154,6 +215,9 @@ static struct {
 	{
 		.cmd = "enh_area",
 		.func = do_mmc_enh_area,
+	}, {
+		.cmd = "write_reliability",
+		.func = do_mmc_write_reliability,
 	}
 };
 
@@ -189,11 +253,13 @@ BAREBOX_CMD_HELP_TEXT("The subcommand enh_area creates an enhanced area of")
 BAREBOX_CMD_HELP_TEXT("maximal size.")
 BAREBOX_CMD_HELP_TEXT("Note, with -c this is an irreversible action.")
 BAREBOX_CMD_HELP_OPT("-c", "complete partitioning")
+BAREBOX_CMD_HELP_TEXT("")
+BAREBOX_CMD_HELP_TEXT("The subcommand write_reliability enable write reliability")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(mmc)
 	.cmd = do_mmc,
-	BAREBOX_CMD_OPTS("enh_area [-c] /dev/mmcX")
+	BAREBOX_CMD_OPTS("write_reliability|enh_area [-c] /dev/mmcX")
 	BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
 	BAREBOX_CMD_HELP(cmd_mmc_help)
 BAREBOX_CMD_END
diff --git a/include/mci.h b/include/mci.h
index f38384613728..4fed8d739284 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -307,6 +307,10 @@
 /* register PARTITIONING_SUPPORT [160] */
 #define EXT_CSD_ENH_ATTRIBUTE_EN_MASK	(1 << 1)
 
+/* register EXT_CSD_WR_REL_PARAM [166] */
+#define EXT_CSD_HS_CTRL_REL		(1 << 0)
+#define EXT_CSD_EN_REL_WR		(1 << 2)
+
 /* register BUS_WIDTH [183], field Bus Mode Selection [4:0] */
 #define EXT_CSD_BUS_WIDTH_1	0	/* Card is in 1 bit mode */
 #define EXT_CSD_BUS_WIDTH_4	1	/* Card is in 4 bit mode */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/8] commands: mmc: add partition_complete subcommand
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
  2023-11-14 13:30 ` [PATCH 2/8] mci: core: check switch error for switch command Marco Felsch
  2023-11-14 13:30 ` [PATCH 3/8] commands: mmc: add write_reliability subcommand Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-14 13:30 ` [PATCH 5/8] commands: mmc: deprecate -c option Marco Felsch
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>

A separate command is less error prone in case both the "write
reliability" and the "enhanced area" feature should be set.

Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 commands/mmc.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/commands/mmc.c b/commands/mmc.c
index 1009b16bfdf7..4e7d03231023 100644
--- a/commands/mmc.c
+++ b/commands/mmc.c
@@ -208,6 +208,34 @@ static int do_mmc_write_reliability(int argc, char *argv[])
 	return COMMAND_ERROR;
 }
 
+static int do_mmc_partition_complete(int argc, char *argv[])
+{
+	const char *devpath;
+	struct mci *mci;
+	int ret;
+
+	if (argc - optind != 1) {
+		printf("Usage: mmc partition_complete /dev/mmcX\n");
+		return COMMAND_ERROR_USAGE;
+	}
+
+	devpath = argv[optind];
+
+	mci = mci_get_device_by_devpath(devpath);
+	if (!mci) {
+		printf("Failure to open %s as mci device\n", devpath);
+		return COMMAND_ERROR_USAGE;
+	}
+
+	ret = mmc_partitioning_complete(mci);
+	if (ret)
+		return COMMAND_ERROR;
+
+	printf("Now power cycle the device to let it reconfigure itself.\n");
+
+	return COMMAND_SUCCESS;
+}
+
 static struct {
 	const char *cmd;
 	int (*func)(int argc, char *argv[]);
@@ -218,6 +246,9 @@ static struct {
 	}, {
 		.cmd = "write_reliability",
 		.func = do_mmc_write_reliability,
+	}, {
+		.cmd = "partition_complete",
+		.func = do_mmc_partition_complete,
 	}
 };
 
@@ -255,11 +286,13 @@ BAREBOX_CMD_HELP_TEXT("Note, with -c this is an irreversible action.")
 BAREBOX_CMD_HELP_OPT("-c", "complete partitioning")
 BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("The subcommand write_reliability enable write reliability")
+BAREBOX_CMD_HELP_TEXT("")
+BAREBOX_CMD_HELP_TEXT("The subcommand partition_complete set PARTITION_SETTING_COMPLETED (irreversible action)")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(mmc)
 	.cmd = do_mmc,
-	BAREBOX_CMD_OPTS("write_reliability|enh_area [-c] /dev/mmcX")
+	BAREBOX_CMD_OPTS("partition_complete|write_reliability|enh_area [-c] /dev/mmcX")
 	BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
 	BAREBOX_CMD_HELP(cmd_mmc_help)
 BAREBOX_CMD_END
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/8] commands: mmc: deprecate -c option
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
                   ` (2 preceding siblings ...)
  2023-11-14 13:30 ` [PATCH 4/8] commands: mmc: add partition_complete subcommand Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-14 13:30 ` [PATCH 6/8] mci: export mci_get_ext_csd as helper Marco Felsch
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

Deprecate the -c options since it's now more error prone in case both
the "enhanced area" and the "write reliability" feature should be
enabled. Instead users should use the separate "partition_complete"
command to make it more clear.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 commands/mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/commands/mmc.c b/commands/mmc.c
index 4e7d03231023..4259dbb763d1 100644
--- a/commands/mmc.c
+++ b/commands/mmc.c
@@ -95,6 +95,7 @@ static int do_mmc_enh_area(int argc, char *argv[])
 	while ((opt = getopt(argc, argv, "c")) > 0) {
 		switch (opt) {
 		case 'c':
+			printf("Use -c to complete the partitioning is deprecated, use separate partition_complete command instead\n");
 			set_completed = 1;
 			break;
 		}
@@ -283,7 +284,7 @@ BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("The subcommand enh_area creates an enhanced area of")
 BAREBOX_CMD_HELP_TEXT("maximal size.")
 BAREBOX_CMD_HELP_TEXT("Note, with -c this is an irreversible action.")
-BAREBOX_CMD_HELP_OPT("-c", "complete partitioning")
+BAREBOX_CMD_HELP_OPT("-c", "complete partitioning (deprecated)")
 BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("The subcommand write_reliability enable write reliability")
 BAREBOX_CMD_HELP_TEXT("")
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/8] mci: export mci_get_ext_csd as helper
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
                   ` (3 preceding siblings ...)
  2023-11-14 13:30 ` [PATCH 5/8] commands: mmc: deprecate -c option Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-14 13:30 ` [PATCH 7/8] mci: core: cosmetic cleanup mci_register Marco Felsch
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

Make the mci_get_ext_csd() function a helper to make it usable for
others.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 commands/mmc.c         | 17 -----------------
 drivers/mci/mci-core.c | 17 +++++++++++++++++
 include/mci.h          |  1 +
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/commands/mmc.c b/commands/mmc.c
index 4259dbb763d1..fa01b89cdf42 100644
--- a/commands/mmc.c
+++ b/commands/mmc.c
@@ -65,23 +65,6 @@ static int mmc_partitioning_complete(struct mci *mci)
 	return ret;
 }
 
-static u8 *mci_get_ext_csd(struct mci *mci)
-{
-	u8 *ext_csd;
-	int ret;
-
-	ext_csd = xmalloc(512);
-
-	ret = mci_send_ext_csd(mci, ext_csd);
-	if (ret) {
-		printf("Failure to read EXT_CSD register\n");
-		free(ext_csd);
-		return ERR_PTR(-EIO);
-	}
-
-	return ext_csd;
-}
-
 /* enh_area [-c] /dev/mmcX */
 static int do_mmc_enh_area(int argc, char *argv[])
 {
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 1276920e1604..8ce97b5d5cdd 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -518,6 +518,23 @@ int mci_switch(struct mci *mci, unsigned index, unsigned value)
 	return 0;
 }
 
+u8 *mci_get_ext_csd(struct mci *mci)
+{
+	u8 *ext_csd;
+	int ret;
+
+	ext_csd = xmalloc(512);
+
+	ret = mci_send_ext_csd(mci, ext_csd);
+	if (ret) {
+		printf("Failure to read EXT_CSD register\n");
+		free(ext_csd);
+		return ERR_PTR(-EIO);
+	}
+
+	return ext_csd;
+}
+
 static blkcnt_t mci_calc_blk_cnt(blkcnt_t cap, unsigned shift)
 {
 	blkcnt_t ret = cap >> shift;
diff --git a/include/mci.h b/include/mci.h
index 4fed8d739284..1ef44a3a76b0 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -545,6 +545,7 @@ void mci_of_parse_node(struct mci_host *host, struct device_node *np);
 int mci_detect_card(struct mci_host *);
 int mci_send_ext_csd(struct mci *mci, char *ext_csd);
 int mci_switch(struct mci *mci, unsigned index, unsigned value);
+u8 *mci_get_ext_csd(struct mci *mci);
 
 static inline int mmc_host_is_spi(struct mci_host *host)
 {
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/8] mci: core: cosmetic cleanup mci_register
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
                   ` (4 preceding siblings ...)
  2023-11-14 13:30 ` [PATCH 6/8] mci: export mci_get_ext_csd as helper Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-14 13:30 ` [PATCH 8/8] mci: core: add partitioning_completed device parameter Marco Felsch
  2023-11-15 13:05 ` [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Sascha Hauer
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

Just use one generic 'struct param_d' variable instead of having two.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/mci/mci-core.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 8ce97b5d5cdd..70e367997763 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2158,7 +2158,7 @@ int mci_register(struct mci_host *host)
 {
 	struct mci *mci;
 	struct device *hw_dev;
-	struct param_d *param_probe, *param_broken_cd;
+	struct param_d *param;
 	int ret;
 
 	mci = xzalloc(sizeof(*mci));
@@ -2203,20 +2203,20 @@ int mci_register(struct mci_host *host)
 
 	dev_info(hw_dev, "registered as %s\n", dev_name(&mci->dev));
 
-	param_probe = dev_add_param_bool(&mci->dev, "probe",
-			mci_set_probe, NULL, &mci->probe, mci);
+	param = dev_add_param_bool(&mci->dev, "probe", mci_set_probe, NULL,
+				   &mci->probe, mci);
 
-	if (IS_ERR(param_probe) && PTR_ERR(param_probe) != -ENOSYS) {
-		ret = PTR_ERR(param_probe);
+	if (IS_ERR(param) && PTR_ERR(param) != -ENOSYS) {
+		ret = PTR_ERR(param);
 		dev_dbg(&mci->dev, "Failed to add 'probe' parameter to the MCI device\n");
 		goto err_unregister;
 	}
 
-	param_broken_cd = dev_add_param_bool(&mci->dev, "broken_cd",
-					     NULL, NULL, &host->broken_cd, mci);
+	param = dev_add_param_bool(&mci->dev, "broken_cd", NULL, NULL,
+				   &host->broken_cd, mci);
 
-	if (IS_ERR(param_broken_cd) && PTR_ERR(param_broken_cd) != -ENOSYS) {
-		ret = PTR_ERR(param_broken_cd);
+	if (IS_ERR(param) && PTR_ERR(param) != -ENOSYS) {
+		ret = PTR_ERR(param);
 		dev_dbg(&mci->dev, "Failed to add 'broken_cd' parameter to the MCI device\n");
 		goto err_unregister;
 	}
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 8/8] mci: core: add partitioning_completed device parameter
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
                   ` (5 preceding siblings ...)
  2023-11-14 13:30 ` [PATCH 7/8] mci: core: cosmetic cleanup mci_register Marco Felsch
@ 2023-11-14 13:30 ` Marco Felsch
  2023-11-15 13:05 ` [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Sascha Hauer
  7 siblings, 0 replies; 9+ messages in thread
From: Marco Felsch @ 2023-11-14 13:30 UTC (permalink / raw)
  To: barebox

Add mmcX.partitioning_completed parameter so it can be queried by
scripts and board code.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/mci/mci-core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 70e367997763..d20db925876e 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1968,6 +1968,22 @@ static int of_broken_cd_fixup(struct device_node *root, void *ctx)
 	return 0;
 }
 
+static int mci_get_partition_setting_completed(struct mci *mci)
+{
+	u8 *ext_csd;
+	int ret;
+
+	ext_csd = mci_get_ext_csd(mci);
+	if (IS_ERR(ext_csd))
+		return PTR_ERR(ext_csd);
+
+	ret = ext_csd[EXT_CSD_PARTITION_SETTING_COMPLETED];
+
+	free(ext_csd);
+
+	return ret;
+}
+
 /**
  * Probe an MCI card at the given host interface
  * @param mci MCI device instance
@@ -2079,6 +2095,13 @@ static int mci_card_probe(struct mci *mci)
 			dev_add_param_bool(&mci->dev, "boot_ack",
 					   mci_set_boot_ack, NULL,
 					   &mci->boot_ack_enable, mci);
+
+		ret = mci_get_partition_setting_completed(mci);
+		if (ret < 0)
+			dev_dbg(&mci->dev,
+				"Failed to determine EXT_CSD_PARTITION_SETTING_COMPLETED\n");
+		else
+			dev_add_param_bool_fixed(&mci->dev, "partitioning_completed", ret);
 	}
 
 	dev_dbg(&mci->dev, "SD Card successfully added\n");
-- 
2.39.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask
  2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
                   ` (6 preceding siblings ...)
  2023-11-14 13:30 ` [PATCH 8/8] mci: core: add partitioning_completed device parameter Marco Felsch
@ 2023-11-15 13:05 ` Sascha Hauer
  7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2023-11-15 13:05 UTC (permalink / raw)
  To: Marco Felsch; +Cc: barebox

On Tue, Nov 14, 2023 at 02:30:00PM +0100, Marco Felsch wrote:
> From: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
> 
> Extended CSD register PARTITIONING_SUPPORT ENH_ATTRIBUTE_EN is bit 1
> instead of 0
> 
> Signed-off-by: LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  include/mci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/include/mci.h b/include/mci.h
> index 3e93f378e4a3..616c7c3cae5c 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -305,7 +305,7 @@
>  #define EXT_CSD_ENH_USR_MASK		(1 << 0)
>  
>  /* register PARTITIONING_SUPPORT [160] */
> -#define EXT_CSD_ENH_ATTRIBUTE_EN_MASK	(1 << 0)
> +#define EXT_CSD_ENH_ATTRIBUTE_EN_MASK	(1 << 1)
>  
>  /* register BUS_WIDTH [183], field Bus Mode Selection [4:0] */
>  #define EXT_CSD_BUS_WIDTH_1	0	/* Card is in 1 bit mode */
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-11-15 13:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14 13:30 [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Marco Felsch
2023-11-14 13:30 ` [PATCH 2/8] mci: core: check switch error for switch command Marco Felsch
2023-11-14 13:30 ` [PATCH 3/8] commands: mmc: add write_reliability subcommand Marco Felsch
2023-11-14 13:30 ` [PATCH 4/8] commands: mmc: add partition_complete subcommand Marco Felsch
2023-11-14 13:30 ` [PATCH 5/8] commands: mmc: deprecate -c option Marco Felsch
2023-11-14 13:30 ` [PATCH 6/8] mci: export mci_get_ext_csd as helper Marco Felsch
2023-11-14 13:30 ` [PATCH 7/8] mci: core: cosmetic cleanup mci_register Marco Felsch
2023-11-14 13:30 ` [PATCH 8/8] mci: core: add partitioning_completed device parameter Marco Felsch
2023-11-15 13:05 ` [PATCH 1/8] mci: correct ENH_ATTRIBUTE_EN_MASK bit mask Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox