summaryrefslogtreecommitdiffstats
path: root/common/env_mmc.c
diff options
context:
space:
mode:
authorDmitry Lifshitz <lifshitz@compulab.co.il>2014-07-30 13:19:06 +0300
committerPantelis Antoniou <panto@antoniou-consulting.com>2014-08-01 20:12:15 +0300
commit6e7b7df4df435742fcfde5f384760ae1bda2e39c (patch)
tree64f0cc9f8d1d07ca8f19d66cf2a9f0ba17eead23 /common/env_mmc.c
parentac77f42d0939f05b39335277b678859b47edb997 (diff)
downloadtalos-obmc-uboot-6e7b7df4df435742fcfde5f384760ae1bda2e39c.tar.gz
talos-obmc-uboot-6e7b7df4df435742fcfde5f384760ae1bda2e39c.zip
env_mmc: support env partition setup in runtime
Add callback with __weak annotation to allow setup of environment partition number in runtime from a board file. Propagate mmc_switch_part() return value into init_mmc_for_env() instead of -1 in case of failure. Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Diffstat (limited to 'common/env_mmc.c')
-rw-r--r--common/env_mmc.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 7da10e61af..a7621a897c 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -62,16 +62,36 @@ int env_init(void)
return 0;
}
-static int init_mmc_for_env(struct mmc *mmc)
-{
#ifdef CONFIG_SYS_MMC_ENV_PART
+__weak uint mmc_get_env_part(struct mmc *mmc)
+{
+ return CONFIG_SYS_MMC_ENV_PART;
+}
+
+static int mmc_set_env_part(struct mmc *mmc)
+{
+ uint part = mmc_get_env_part(mmc);
int dev = CONFIG_SYS_MMC_ENV_DEV;
+ int ret = 0;
#ifdef CONFIG_SPL_BUILD
dev = 0;
#endif
+
+ if (part != mmc->part_num) {
+ ret = mmc_switch_part(dev, part);
+ if (ret)
+ puts("MMC partition switch failed\n");
+ }
+
+ return ret;
+}
+#else
+static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
#endif
+static int init_mmc_for_env(struct mmc *mmc)
+{
if (!mmc) {
puts("No MMC card found\n");
return -1;
@@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc)
return -1;
}
-#ifdef CONFIG_SYS_MMC_ENV_PART
- if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) {
- if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) {
- puts("MMC partition switch failed\n");
- return -1;
- }
- }
-#endif
-
- return 0;
+ return mmc_set_env_part(mmc);
}
static void fini_mmc_for_env(struct mmc *mmc)
OpenPOWER on IntegriCloud