aboutsummaryrefslogtreecommitdiff
path: root/common/env_mmc.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2017-05-30 14:07:23 -0400
committerTom Rini <trini@konsulko.com>2017-05-30 14:07:23 -0400
commitccbbada0a59fead35495409d0c2c7bcb22a40278 (patch)
tree04acadf027384a90ec4fb2ff19f5b4a0849ae6bc /common/env_mmc.c
parent380e86f361e4e2aef83295972863654fde157560 (diff)
parentde59d10cd0a4e79c85e4f791fb8f023164d0890e (diff)
Merge branch 'master' of git://git.denx.de/u-boot-mmc
Diffstat (limited to 'common/env_mmc.c')
-rw-r--r--common/env_mmc.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/common/env_mmc.c b/common/env_mmc.c
index a5d14d448c..45d95a1e23 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -10,6 +10,7 @@
#include <command.h>
#include <environment.h>
+#include <fdtdec.h>
#include <linux/stddef.h>
#include <malloc.h>
#include <memalign.h>
@@ -36,15 +37,37 @@ DECLARE_GLOBAL_DATA_PTR;
#define CONFIG_ENV_OFFSET 0
#endif
-__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static inline s64 mmc_offset(int copy)
{
- s64 offset;
+ const char *propname = "u-boot,mmc-env-offset";
+ s64 defvalue = CONFIG_ENV_OFFSET;
- offset = CONFIG_ENV_OFFSET;
-#ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_OFFSET_REDUND)
+ if (copy) {
+ propname = "u-boot,mmc-env-offset-redundant";
+ defvalue = CONFIG_ENV_OFFSET_REDUND;
+ }
+#endif
+
+ return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue);
+}
+#else
+static inline s64 mmc_offset(int copy)
+{
+ s64 offset = CONFIG_ENV_OFFSET;
+
+#if defined(CONFIG_ENV_OFFSET_REDUND)
if (copy)
offset = CONFIG_ENV_OFFSET_REDUND;
#endif
+ return offset;
+}
+#endif
+
+__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
+{
+ s64 offset = mmc_offset(copy);
if (offset < 0)
offset += mmc->capacity;