board_r: env: support storage env when kernel dtb is enabled
if we would like to use kernel dtb, it must depends on nowhere env to detect boot media and initialize it. After storage is initialized, we switch env from nowhere to CONFIG_ENV_IS_IN_xxx=y, nowhere env info will append or override to storage env. Change-Id: Id1cf44d4b25dcaba3c142b283ed093bed0decafe Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
2e02c4e25b
commit
6ba4112660
|
|
@ -32,6 +32,7 @@
|
|||
#endif
|
||||
#include <malloc.h>
|
||||
#include <mapmem.h>
|
||||
#include <memalign.h>
|
||||
#ifdef CONFIG_BITBANGMII
|
||||
#include <miiphy.h>
|
||||
#endif
|
||||
|
|
@ -435,6 +436,7 @@ static int initr_mmc(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_USING_KERNEL_DTB) || !defined(CONFIG_ENV_IS_NOWHERE)
|
||||
/*
|
||||
* Tell if it's OK to load the environment early in boot.
|
||||
*
|
||||
|
|
@ -473,6 +475,44 @@ static int initr_env(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USING_KERNEL_DTB
|
||||
static int initr_env_nowhere(void)
|
||||
{
|
||||
#if defined(CONFIG_NEEDS_MANUAL_RELOC)
|
||||
env_reloc();
|
||||
env_htab.change_ok += gd->reloc_off;
|
||||
#endif
|
||||
set_default_env(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_ENV_IS_NOWHERE)
|
||||
static int initr_env_switch(void)
|
||||
{
|
||||
ALLOC_CACHE_ALIGN_BUFFER(env_t, env_nowhere, 1);
|
||||
int ret;
|
||||
|
||||
/* Export nowhere env for late use */
|
||||
ret = env_export(env_nowhere);
|
||||
if (ret) {
|
||||
printf("%s: export nowhere env fail, ret=%d\n", __func__, ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Destroy nowhere env and import storage env */
|
||||
initr_env();
|
||||
|
||||
/* Append/override nowhere env to storage env */
|
||||
himport_r(&env_htab, (char *)env_nowhere->data, ENV_SIZE, '\0',
|
||||
H_NOCLEAR, 0, 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_ENV_IS_NOWHERE */
|
||||
#endif /* CONFIG_USING_KERNEL_DTB */
|
||||
|
||||
#ifdef CONFIG_SYS_BOOTPARAMS_LEN
|
||||
static int initr_malloc_bootparams(void)
|
||||
|
|
@ -738,12 +778,27 @@ static init_fnc_t init_sequence_r[] = {
|
|||
#ifdef CONFIG_DM
|
||||
initr_dm,
|
||||
#endif
|
||||
|
||||
/*
|
||||
* kernel dtb must depends on nowhere to detect boot storage media
|
||||
* and initialize it.
|
||||
*/
|
||||
#ifdef CONFIG_USING_KERNEL_DTB
|
||||
initr_env,
|
||||
initr_env_nowhere,
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_NDS32)
|
||||
board_init, /* Setup chipselects */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Now that storage has been initialized in board_init(), we could switch env
|
||||
* from nowhere to storage, i.e. CONFIG_ENV_IS_IN_xxx=y.
|
||||
*/
|
||||
#if defined(CONFIG_USING_KERNEL_DTB) && !defined(CONFIG_ENV_IS_NOWHERE)
|
||||
initr_env_switch,
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TODO: printing of the clock inforamtion of the board is now
|
||||
* implemented as part of bdinfo command. Currently only support for
|
||||
|
|
|
|||
Loading…
Reference in New Issue