On Mon, 11 Nov 2019 at 12:01, Lars Pedersen <lapeddk@xxxxxxxxx> wrote: > > 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@xxxxxxxxx> Applied to git.kernel.org/pub/scm/utils/mmc/mmc-utils.git master, thanks! Kind regards Uffe > --- > v3: > - Simplified setting of auto and manual BKOPS into old > bkops_en function. > > v2: > - Added signed-off-by for patches > - Dropped patch for BKOPS start support, since its already > controlled in the host controller. (mmc_run_bkops) > > mmc.c | 9 ++++++--- > mmc.h | 5 +++-- > mmc_cmds.c | 23 ++++++++++++++++------- > 3 files changed, 25 insertions(+), 12 deletions(-) > > diff --git a/mmc.c b/mmc.c > index 50c9c9e..513fb78 100644 > --- a/mmc.c > +++ b/mmc.c > @@ -120,9 +120,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, > diff --git a/mmc.h b/mmc.h > index 648fb26..027cf57 100644 > --- a/mmc.h > +++ b/mmc.h > @@ -126,9 +126,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 > diff --git a/mmc_cmds.c b/mmc_cmds.c > index fb37189..f433f6f 100644 > --- a/mmc_cmds.c > +++ b/mmc_cmds.c > @@ -734,13 +734,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) { > @@ -754,12 +756,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); > -- > 2.23.0 >