summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Serban <mihai.serban@intel.com>2016-02-24 16:31:37 +0200
committerSerban, Mihai <mihai.serban@intel.com>2016-02-25 14:19:01 +0000
commit34c98a40d132dd09a0cf2c79086683cf2de30f5e (patch)
tree89e625e8a6bf1906b8dd0cbf8f10becf35256a82
parente056248ed458b2e41f64a14f14f08ff71423b7bb (diff)
downloadedison-u-boot-34c98a40d132dd09a0cf2c79086683cf2de30f5e.tar.gz
mmc: Fix user area power on write protection
The mmc_switch command fails if the new value is incompatible with the existing EXT_CSD[USER_WP] register configuration. For example the R/W US_PERM_WP_DISABLE bit cannot be clear once set so we need to keep the old register configuration when setting the US_PWR_WP_EN bit. Change-Id: I72eacc18c594ecbffcc4d204ad3a065a9db284c2 Signed-off-by: Mihai Serban <mihai.serban@intel.com> Reviewed-on: https://android.intel.com/472350
-rw-r--r--drivers/mmc/mmc.c5
-rw-r--r--include/mmc.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 81938a7062..0ecdf2546c 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1877,8 +1877,9 @@ int mmc_usr_power_on_wp(struct mmc *mmc, lbaint_t addr, unsigned int size)
return -EINVAL;
}
- err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
- EXT_CSD_USER_WP, EXT_CSD_USER_PWR_WP_EN);
+ err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_USER_WP,
+ (ext_csd[EXT_CSD_USER_WP] & EXT_CSD_USER_WRITE_ONCE_MASK) |
+ EXT_CSD_USER_PWR_WP_EN);
if (err)
return err;
diff --git a/include/mmc.h b/include/mmc.h
index dd9e803616..b2ead11e37 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -237,6 +237,7 @@
#define EXT_CSD_USER_PWR_WP_DIS (1 << 3) /* disable power-on write protect*/
#define EXT_CSD_USER_PERM_WP_EN (1 << 2) /* enable permanent write protect */
#define EXT_CSD_USER_PWR_WP_EN (1 << 0) /* enable power-on write protect */
+#define EXT_CSD_USER_WRITE_ONCE_MASK (0xd0) /* mask the bits that can be written only once */
#define R1_ILLEGAL_COMMAND (1 << 22)
#define R1_APP_CMD (1 << 5)