aboutsummaryrefslogtreecommitdiff
path: root/cmd/mmc.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-03-30 07:24:19 +0200
committerPeng Fan <peng.fan@nxp.com>2020-04-22 20:41:55 +0800
commit0469d846364ae54fc380a813cc4c3e9e19bdc99a (patch)
treed93f62a4625b8d53415ea44ced16b04e214674f2 /cmd/mmc.c
parentd5210e4589294b4c356e7c2ac598cda8d738aec8 (diff)
downloadu-boot-0469d846364ae54fc380a813cc4c3e9e19bdc99a.zip
u-boot-0469d846364ae54fc380a813cc4c3e9e19bdc99a.tar.gz
u-boot-0469d846364ae54fc380a813cc4c3e9e19bdc99a.tar.bz2
cmd: mmc: provide boot area protection command
Provide command 'mmc wp' to power on write protect boot areas on eMMC devices. The B_PWR_WP_EN bit in the extended CSD register BOOT_WP is set. The boot area are write protected until the next power cycle occurs. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd/mmc.c')
-rw-r--r--cmd/mmc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 6d71208..6142ec8 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -896,9 +896,30 @@ static int do_mmc_bkops_enable(cmd_tbl_t *cmdtp, int flag,
}
#endif
+static int do_mmc_boot_wp(cmd_tbl_t *cmdtp, int flag,
+ int argc, char * const argv[])
+{
+ int err;
+ struct mmc *mmc;
+
+ mmc = init_mmc_device(curr_device, false);
+ if (!mmc)
+ return CMD_RET_FAILURE;
+ if (IS_SD(mmc)) {
+ printf("It is not an eMMC device\n");
+ return CMD_RET_FAILURE;
+ }
+ err = mmc_boot_wp(mmc);
+ if (err)
+ return CMD_RET_FAILURE;
+ printf("boot areas protected\n");
+ return CMD_RET_SUCCESS;
+}
+
static cmd_tbl_t cmd_mmc[] = {
U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""),
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
+ U_BOOT_CMD_MKENT(wp, 1, 0, do_mmc_boot_wp, "", ""),
#if CONFIG_IS_ENABLED(MMC_WRITE)
U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
@@ -968,6 +989,7 @@ U_BOOT_CMD(
"mmc part - lists available partition on current mmc device\n"
"mmc dev [dev] [part] - show or set current mmc device [partition]\n"
"mmc list - lists available devices\n"
+ "mmc wp - power on write protect booot partitions\n"
#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
"mmc hwpartition [args...] - does hardware partitioning\n"
" arguments (sizes in 512-byte blocks):\n"