summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorPeng Fan <Peng.Fan@freescale.com>2015-04-11 16:35:22 +0800
committerMax Krummenacher <max.krummenacher@toradex.com>2016-03-09 14:42:03 +0100
commit086916ae8f867c9269512725443cbb1bdcc753d4 (patch)
tree5b346b1f1dea1b0ffcb1fce2d7f5bbd827fda22c /common
parent90c52f1a91f194320f217876806b3a46bc84062c (diff)
MLK-10774-8 env_mmc: add the dynamtic mmc dev support
This patch add the support to load/save env to the slot which was used as the boot media by dynamic detection. Signed-off-by: Jason Liu <r64343@freescale.com> Signed-off-by: Ye.Li <B37916@freescale.com> Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Diffstat (limited to 'common')
-rw-r--r--common/env_mmc.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 14648e37bd..fb006bd09c 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -53,6 +53,11 @@ __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
return 0;
}
+__weak int mmc_get_env_devno(void)
+{
+ return CONFIG_SYS_MMC_ENV_DEV;
+}
+
int env_init(void)
{
/* use default */
@@ -71,7 +76,7 @@ __weak uint mmc_get_env_part(struct mmc *mmc)
static int mmc_set_env_part(struct mmc *mmc)
{
uint part = mmc_get_env_part(mmc);
- int dev = CONFIG_SYS_MMC_ENV_DEV;
+ int dev = mmc_get_env_devno();
int ret = 0;
#ifdef CONFIG_SPL_BUILD
@@ -108,7 +113,7 @@ static int init_mmc_for_env(struct mmc *mmc)
static void fini_mmc_for_env(struct mmc *mmc)
{
#ifdef CONFIG_SYS_MMC_ENV_PART
- int dev = CONFIG_SYS_MMC_ENV_DEV;
+ int dev = mmc_get_env_devno();
#ifdef CONFIG_SPL_BUILD
dev = 0;
@@ -127,7 +132,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size,
blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
- n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start,
+ n = mmc->block_dev.block_write(mmc_get_env_devno(), blk_start,
blk_cnt, (u_char *)buffer);
return (n == blk_cnt) ? 0 : -1;
@@ -140,7 +145,8 @@ static unsigned char env_flags;
int saveenv(void)
{
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
- struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+ int mmc_env_devno = mmc_get_env_devno();
+ struct mmc *mmc = find_mmc_device(mmc_env_devno);
u32 offset;
int ret, copy = 0;
@@ -164,7 +170,7 @@ int saveenv(void)
}
printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "",
- CONFIG_SYS_MMC_ENV_DEV);
+ mmc_env_devno);
if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
puts("failed\n");
ret = 1;
@@ -188,7 +194,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
unsigned long offset, const void *buffer)
{
uint blk_start, blk_cnt, n;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
+ int dev = mmc_get_env_devno();
#ifdef CONFIG_SPL_BUILD
dev = 0;
@@ -212,7 +218,7 @@ void env_relocate_spec(void)
int crc1_ok = 0, crc2_ok = 0;
env_t *ep;
int ret;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
+ int dev = mmc_get_env_devno();
ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1);
@@ -296,7 +302,7 @@ void env_relocate_spec(void)
struct mmc *mmc;
u32 offset;
int ret;
- int dev = CONFIG_SYS_MMC_ENV_DEV;
+ int dev = mmc_get_env_devno();
#ifdef CONFIG_SPL_BUILD
dev = 0;