Skip to content
Snippets Groups Projects
Commit 6e7b7df4 authored by Dmitry Lifshitz's avatar Dmitry Lifshitz Committed by Pantelis Antoniou
Browse files

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: default avatarDmitry Lifshitz <lifshitz@compulab.co.il>
Signed-off-by: default avatarIgor Grinberg <grinberg@compulab.co.il>
Acked-by: default avatarPantelis Antoniou <panto@antoniou-consulting.com>
parent ac77f42d
No related branches found
No related tags found
No related merge requests found
...@@ -62,16 +62,36 @@ int env_init(void) ...@@ -62,16 +62,36 @@ int env_init(void)
return 0; return 0;
} }
static int init_mmc_for_env(struct mmc *mmc)
{
#ifdef CONFIG_SYS_MMC_ENV_PART #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 dev = CONFIG_SYS_MMC_ENV_DEV;
int ret = 0;
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_BUILD
dev = 0; dev = 0;
#endif #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 #endif
static int init_mmc_for_env(struct mmc *mmc)
{
if (!mmc) { if (!mmc) {
puts("No MMC card found\n"); puts("No MMC card found\n");
return -1; return -1;
...@@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc) ...@@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc)
return -1; return -1;
} }
#ifdef CONFIG_SYS_MMC_ENV_PART return mmc_set_env_part(mmc);
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;
} }
static void fini_mmc_for_env(struct mmc *mmc) static void fini_mmc_for_env(struct mmc *mmc)
......
...@@ -184,6 +184,9 @@ extern void env_reloc(void); ...@@ -184,6 +184,9 @@ extern void env_reloc(void);
#include <mmc.h> #include <mmc.h>
extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr); extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
# ifdef CONFIG_SYS_MMC_ENV_PART
extern uint mmc_get_env_part(struct mmc *mmc);
# endif
#endif #endif
#ifndef DO_DEPS_ONLY #ifndef DO_DEPS_ONLY
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment