summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaniv Gardi <ygardi@codeaurora.org>2013-05-26 13:25:33 -0400
committerChris Ball <cjb@laptop.org>2013-05-26 13:27:05 -0400
commit21bb473fc58366b872efe31e1da7831cad4b92fa (patch)
tree5d575be4f30a76874c8f572d322aafff3c698646
parent1fc81f3a417c0810fe7b81e860e760452f2eb52f (diff)
downloadmmc-utils-21bb473fc58366b872efe31e1da7831cad4b92fa.tar.gz
Add method for triggering Sanitize command
This patch adds a method to trigger Sanitize command to MMC. The Sanitize command is used for deleting the unmapped memory region of the MMC device. Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org> Acked-by: Subhash Jadavani <subhashj@codeaurora.org> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--mmc.c5
-rw-r--r--mmc.h1
-rw-r--r--mmc_cmds.c28
-rw-r--r--mmc_cmds.h1
4 files changed, 35 insertions, 0 deletions
diff --git a/mmc.c b/mmc.c
index a2de863..a757c8f 100644
--- a/mmc.c
+++ b/mmc.c
@@ -90,6 +90,11 @@ static struct Command commands[] = {
"Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.",
NULL
},
+ { do_sanitize, -1,
+ "sanitize", "<device>\n"
+ "Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device.",
+ NULL
+ },
{ 0, 0, 0, 0 }
};
diff --git a/mmc.h b/mmc.h
index c863751..5173d34 100644
--- a/mmc.h
+++ b/mmc.h
@@ -38,6 +38,7 @@
#define EXT_CSD_PART_CONFIG 179
#define EXT_CSD_BOOT_WP 173
#define EXT_CSD_WR_REL_PARAM 166
+#define EXT_CSD_SANITIZE_START 165
#define EXT_CSD_BKOPS_EN 163 /* R/W */
#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
#define EXT_CSD_NATIVE_SECTOR_SIZE 63 /* R */
diff --git a/mmc_cmds.c b/mmc_cmds.c
index b407f65..5473a20 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv)
out_free:
return ret;
}
+
+int do_sanitize(int nargs, char **argv)
+{
+ int fd, ret;
+ char *device;
+
+ CHECK(nargs != 2, "Usage: mmc sanitize </path/to/mmcblkX>\n",
+ exit(1));
+
+ device = argv[1];
+
+ fd = open(device, O_RDWR);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+
+ ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1);
+ if (ret) {
+ fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
+ 1, EXT_CSD_SANITIZE_START, device);
+ exit(1);
+ }
+
+ return ret;
+
+}
+
diff --git a/mmc_cmds.h b/mmc_cmds.h
index e52d622..ec22eee 100644
--- a/mmc_cmds.h
+++ b/mmc_cmds.h
@@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv);
int do_write_bkops_en(int nargs, char **argv);
int do_hwreset_en(int nargs, char **argv);
int do_hwreset_dis(int nargs, char **argv);
+int do_sanitize(int nargs, char **argv);