summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorChristoph Fritz <chf.fritz@googlemail.com>2018-06-18 12:03:58 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-06-20 09:06:09 +0200
commitbe940f1a513b5167963174eca1d9509aaddda2fe (patch)
treed73b285be5a2703cff38bab9b7a7039d55279521 /commands
parent51c0c6454944d53b63de7b1f42484ed5dc64d703 (diff)
downloadbarebox-be940f1a513b5167963174eca1d9509aaddda2fe.tar.gz
mmc_extcsd command: Add cmd option to set bkops-enable
This patch is for convenience to set bkops-enable (EXT_CSD_BKOPS_EN[163]) on devices which have it not yet activated. Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/mmc_extcsd.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c
index 82e0600..3a418ea 100644
--- a/commands/mmc_extcsd.c
+++ b/commands/mmc_extcsd.c
@@ -1482,7 +1482,7 @@ static int print_field(u8 *reg, int index)
str = "may";
else
str = "shall not";
- printf("\t[1] AUTO_EN: Device %s perform background ops while"
+ printf("\t[1] AUTO_EN: Device %s perform background ops while\n"
"\t not servicing the host\n", str);
return 1;
@@ -2371,11 +2371,12 @@ static int do_mmc_extcsd(int argc, char *argv[])
int write_operation = 0;
int always_write = 0;
int print_as_raw = 0;
+ int set_bkops_en = 0;
if (argc < 2)
return COMMAND_ERROR_USAGE;
- while ((opt = getopt(argc, argv, "i:v:yr")) > 0)
+ while ((opt = getopt(argc, argv, "i:v:yrb")) > 0)
switch (opt) {
case 'i':
index = simple_strtoul(optarg, NULL, 0);
@@ -2390,6 +2391,13 @@ static int do_mmc_extcsd(int argc, char *argv[])
case 'r':
print_as_raw = 1;
break;
+ case 'b':
+ set_bkops_en = 1;
+ index = EXT_CSD_BKOPS_EN;
+ value = BIT(0);
+ write_operation = 1;
+ always_write = 1;
+ break;
}
if (optind == argc)
@@ -2421,6 +2429,16 @@ static int do_mmc_extcsd(int argc, char *argv[])
goto error_with_mem;
}
+ if (set_bkops_en) {
+ if (dst[index]) {
+ printf("Abort: EXT_CSD [%u] already set to %#02x!\n",
+ index, dst[index]);
+ goto error_with_mem;
+ }
+ if (dst[EXT_CSD_REV] >= 7)
+ value |= BIT(1); /* set AUTO_EN bit too */
+ }
+
if (write_operation)
if (!print_field(dst, index)) {
printf("No field with this index found. Abort write operation!\n");
@@ -2466,12 +2484,14 @@ BAREBOX_CMD_HELP_OPT("-r", "print the register as raw data")
BAREBOX_CMD_HELP_OPT("-v", "value which will be written")
BAREBOX_CMD_HELP_OPT("-y", "don't request when writing to one time programmable fields")
BAREBOX_CMD_HELP_OPT("", "__CAUTION__: this could damage the device!")
+BAREBOX_CMD_HELP_OPT("-b", "set bkops-enable (EXT_CSD_BKOPS_EN[163])")
+BAREBOX_CMD_HELP_OPT("", "__WARNING__: this is a write-once setting!")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(mmc_extcsd)
.cmd = do_mmc_extcsd,
BAREBOX_CMD_DESC("Read/write the extended CSD register.")
- BAREBOX_CMD_OPTS("dev [-r | -i index [-r | -v value [-y]]]")
+ BAREBOX_CMD_OPTS("dev [-r | -b | -i index [-r | -v value [-y]]]")
BAREBOX_CMD_GROUP(CMD_GRP_CONSOLE)
BAREBOX_CMD_HELP(cmd_mmc_extcsd_help)
BAREBOX_CMD_END