mmc-utils: Add blockprotect command set

This patch adds a group of commands that allow controlling an eMMC's
user partition write-protect features, which allow temporary, permanent
or until-next-power-on write-protection of a write-protect block (which
is a device-dependent multiple of an erase block).

BUG=None
TEST=Manual enabling, disabling and writing of a bunch of blocks on my
Minnie.

Change-Id: I75ff069f7f9cf94cdb3adfa0a5f4574f912cad9f
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340252
Reviewed-by: Gwendal Grignou <gwendal@google.com>
diff --git a/mmc.c b/mmc.c
index fa872d5..019f5c3 100644
--- a/mmc.c
+++ b/mmc.c
@@ -204,6 +204,31 @@
 		  "The device path should specify the scr file directory.",
 	  NULL
 	},
+	{ do_blockprotect_enable, -2, "blockprotect enable",
+		"[-p|-r] <device> <sector>\n"
+		"Enable block protection for a given sector. Will write protect all\n"
+		"sectors within the target sector's write protect block. Write protect\n"
+		"block size is a multiple of erase block size and device dependent.\n"
+		"Run mmc blockprotect info to query write protect block size.\n"
+		"  -p  Protect block permanently. WARNING: THIS IS IRREVERSIBLE!\n"
+		"  -r  Protect block until next power-on.",
+	  NULL
+	},
+	{ do_blockprotect_disable, -2, "blockprotect disable",
+		"<device> <sector>\n"
+		"Disable block protection for a given sector. Will disable protection\n"
+		"for all sectors within the target sector's write protect block.\n"
+		"Cannot disable permanent or power-on write protection.",
+	  NULL
+	},
+	{ do_blockprotect_read, -2, "blockprotect read", "<device> <sector>\n"
+		"Query the current block protection status of a given sector.",
+	  NULL
+	},
+	{ do_blockprotect_info, -1, "blockprotect info", "<device>\n"
+		"Query information about device's block protect capabilities.",
+	  NULL
+	},
 	{ 0, 0, 0, 0 }
 };