mmc-utils: Add AUTO_EN support in the BKOPS_EN

This patch adds support to enable auto(AUTO_EN) and
manual(MANUAL_EN) in BKOPS_EN register. Auto bkops
can only be used on eMMC 5.0 or newer.

Signed-off-by: Lars Pedersen <lapeddk@gmail.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20191111110051.16490-1-lapeddk@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Lars Pedersen authored and Ulf Hansson committed 2021-03-30 15:12:23 +02:00
1 parent be4cac34ea
commit ad6890a2dd
3 files changed
+25 -12

No files matched your search

+6 -3
View File
@@ -131,9 +131,12 @@ static struct Command commands[] = {
"<boot_bus_width> must be \"x1|x4|x8\"",
NULL
},
{ do_write_bkops_en, -1,
"bkops enable", "<device>\n"
"Enable the eMMC BKOPS feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.",
{ do_write_bkops_en, -2,
"bkops_en", "<auto|manual> <device>\n"
"Enable the eMMC BKOPS feature on <device>.\n"
"The auto (AUTO_EN) setting is only supported on eMMC 5.0 or newer.\n"
"Setting auto won't have any effect if manual is set.\n"
"NOTE! Setting manual (MANUAL_EN) is one-time programmable (unreversible) change.",
NULL
},
{ do_hwreset_en, -1,
+3 -2
View File
@@ -128,9 +128,10 @@
#define EN_REL_WR (1<<2)
/*
* BKOPS_EN field definition
* BKOPS_EN field definitions
*/
#define BKOPS_ENABLE (1<<0)
#define BKOPS_MAN_ENABLE (1<<0)
#define BKOPS_AUTO_ENABLE (1<<1)
/*
* EXT_CSD field definitions
+16 -7
View File
@@ -792,13 +792,15 @@ int do_write_bkops_en(int nargs, char **argv)
__u8 ext_csd[512], value = 0;
int fd, ret;
char *device;
char *en_type;
if (nargs != 2) {
fprintf(stderr, "Usage: mmc bkops enable </path/to/mmcblkX>\n");
exit(1);
if (nargs != 3) {
fprintf(stderr, "Usage: mmc bkops_en <auto|manual> </path/to/mmcblkX>\n");
exit(1);
}
device = argv[1];
en_type = argv[1];
device = argv[2];
fd = open(device, O_RDWR);
if (fd < 0) {
@@ -812,12 +814,19 @@ int do_write_bkops_en(int nargs, char **argv)
exit(1);
}
if (!(ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1)) {
fprintf(stderr, "%s doesn't support BKOPS\n", device);
if (strcmp(en_type, "auto") == 0) {
if (ext_csd[EXT_CSD_REV] < EXT_CSD_REV_V5_0) {
fprintf(stderr, "%s doesn't support AUTO_EN in the BKOPS_EN register\n", device);
exit(1);
}
ret = write_extcsd_value(fd, EXT_CSD_BKOPS_EN, BKOPS_AUTO_ENABLE);
} else if (strcmp(en_type, "manual") == 0) {
ret = write_extcsd_value(fd, EXT_CSD_BKOPS_EN, BKOPS_MAN_ENABLE);
} else {
fprintf(stderr, "%s invalid mode for BKOPS_EN requested: %s. Valid options: auto or manual\n", en_type, device);
exit(1);
}
ret = write_extcsd_value(fd, EXT_CSD_BKOPS_EN, BKOPS_ENABLE);
if (ret) {
fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
value, EXT_CSD_BKOPS_EN, device);