summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2013-06-11 15:14:02 -0600
committerAndy Fleming <afleming@freescale.com>2013-06-13 16:52:20 -0500
commit5c088ee841f9c660a3e62887e7b8623fc15dcd68 (patch)
treef2cf7e6bb7e0a66b7b3959ec3fd792c85b8dd2b7 /common
parentf866a46d6ee86335f60c542e294ec2c01d689eba (diff)
downloadu-boot-imx-5c088ee841f9c660a3e62887e7b8623fc15dcd68.zip
u-boot-imx-5c088ee841f9c660a3e62887e7b8623fc15dcd68.tar.gz
u-boot-imx-5c088ee841f9c660a3e62887e7b8623fc15dcd68.tar.bz2
env_mmc: allow negative CONFIG_ENV_OFFSET
A negative value of CONFIG_ENV_OFFSET is treated as a backwards offset from the end of the eMMC device/partition, rather than a forwards offset from the start. This is useful when a single board may be stuffed with different eMMC devices, each of which has a different capacity, and you always want the environment to be stored at the very end of the device (or eMMC boot partition for example). One example of this case is NVIDIA's Ventana reference board. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Andy Fleming <afleming@freescale.com>
Diffstat (limited to 'common')
-rw-r--r--common/env_mmc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 9ca098f..5d3a769 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -53,11 +53,19 @@ DECLARE_GLOBAL_DATA_PTR;
__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
{
- *env_addr = CONFIG_ENV_OFFSET;
+ s64 offset;
+
+ offset = CONFIG_ENV_OFFSET;
#ifdef CONFIG_ENV_OFFSET_REDUND
if (copy)
- *env_addr = CONFIG_ENV_OFFSET_REDUND;
+ offset = CONFIG_ENV_OFFSET_REDUND;
#endif
+
+ if (offset < 0)
+ offset += mmc->capacity;
+
+ *env_addr = offset;
+
return 0;
}