Commit 21bb473f authored by Yaniv Gardi's avatar Yaniv Gardi Committed by Chris Ball
Browse files

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: default avatarYaniv Gardi <ygardi@codeaurora.org>
Acked-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 1fc81f3a
...@@ -90,6 +90,11 @@ static struct Command commands[] = { ...@@ -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.", "Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.",
NULL 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 } { 0, 0, 0, 0 }
}; };
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#define EXT_CSD_PART_CONFIG 179 #define EXT_CSD_PART_CONFIG 179
#define EXT_CSD_BOOT_WP 173 #define EXT_CSD_BOOT_WP 173
#define EXT_CSD_WR_REL_PARAM 166 #define EXT_CSD_WR_REL_PARAM 166
#define EXT_CSD_SANITIZE_START 165
#define EXT_CSD_BKOPS_EN 163 /* R/W */ #define EXT_CSD_BKOPS_EN 163 /* R/W */
#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
#define EXT_CSD_NATIVE_SECTOR_SIZE 63 /* R */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63 /* R */
......
...@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv) ...@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv)
out_free: out_free:
return ret; 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;
}
...@@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv); ...@@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv);
int do_write_bkops_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_en(int nargs, char **argv);
int do_hwreset_dis(int nargs, char **argv); int do_hwreset_dis(int nargs, char **argv);
int do_sanitize(int nargs, char **argv);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment