All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add a commande extcsd write <offset> <value> <device>
@ 2017-03-03 17:57 Philippe Reynes
  0 siblings, 0 replies; only message in thread
From: Philippe Reynes @ 2017-03-03 17:57 UTC (permalink / raw)
  To: linux-mmc; +Cc: chris, Philippe Reynes

There was a command to read the extcsd and some command
to enable or configure feature, but not generic write in
the extcsd. Such generic write may be usefull for the
manufacturer registers.

Signed-off-by: Philippe Reynes <philippe.reynes@sagemcom.com>
---
 mmc.c      |    5 +++++
 mmc_cmds.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/mmc.c b/mmc.c
index 50c9c9e..de820eb 100644
--- a/mmc.c
+++ b/mmc.c
@@ -58,6 +58,11 @@ static struct Command commands[] = {
 		"Print extcsd data from <device>.",
 	  NULL
 	},
+	{ do_write_extcsd, -1,
+	  "extcsd write", "<offset> " "<value> " "<device>\n"
+		"Write <value> at offset <offset> to <device> extcsd.",
+	  NULL
+	},
 	{ do_writeprotect_boot_get, -1,
 	  "writeprotect boot get", "<device>\n"
 		"Print the boot partitions write protect status for <device>.",
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 6b86115..ba79ffe 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1750,6 +1750,36 @@ out_free:
 	return ret;
 }
 
+int do_write_extcsd(int nargs, char **argv)
+{
+	int fd, ret;
+	int offset, value;
+	char *device;
+
+	CHECK(nargs != 4, "Usage: mmc extcsd write <offset> <value> </path/to/mmcblkX>\n",
+			  exit(1));
+
+	offset = strtol(argv[1], NULL, 0);
+	value  = strtol(argv[2], NULL, 0);
+	device = argv[3];
+
+	fd = open(device, O_RDWR);
+	if (fd < 0) {
+		perror("open");
+		exit(1);
+	}
+
+	ret = write_extcsd_value(fd, offset, value);
+	if (ret) {
+		fprintf(stderr,
+			"Could not write 0x%02x to EXT_CSD[%d] in %s\n",
+			value, offset, device);
+		exit(1);
+	}
+
+	return ret;
+}
+
 int do_sanitize(int nargs, char **argv)
 {
 	int fd, ret;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-03 18:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 17:57 [PATCH] Add a commande extcsd write <offset> <value> <device> Philippe Reynes

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.