X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fenv_mmc.c;h=45d95a1e23ed95cf6563a26dda50cc71e9ad1b1d;hb=0e689a61929bdf15423e868bc242c1268bda7db9;hp=a5d14d448c8f56fff3afcc64d405ab4486fbe031;hpb=089795090a627f4216c5f21eaf436ba1672cf02e;p=u-boot 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 #include +#include #include #include #include @@ -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;