env: sf: Add support for env init for QSPI-NOR
ENV variables can now be used before relocation. Signed-off-by: Ashish Kumar <Ashish.Kumar@nxp.com> Reviewed-by: York Sun <york.sun@nxp.com>
This commit is contained in:
parent
134200a5ef
commit
b500c92b70
21
env/sf.c
vendored
21
env/sf.c
vendored
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#ifndef CONFIG_SPL_BUILD
|
#ifndef CONFIG_SPL_BUILD
|
||||||
#define CMD_SAVEENV
|
#define CMD_SAVEENV
|
||||||
|
#define INITENV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ENV_OFFSET_REDUND
|
#ifdef CONFIG_ENV_OFFSET_REDUND
|
||||||
@ -348,6 +349,23 @@ out:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
|
||||||
|
static int env_sf_init(void)
|
||||||
|
{
|
||||||
|
env_t *env_ptr = (env_t *)(CONFIG_ENV_ADDR);
|
||||||
|
|
||||||
|
if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
|
||||||
|
gd->env_addr = (ulong)&(env_ptr->data);
|
||||||
|
gd->env_valid = 1;
|
||||||
|
} else {
|
||||||
|
gd->env_addr = (ulong)&default_environment[0];
|
||||||
|
gd->env_valid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
U_BOOT_ENV_LOCATION(sf) = {
|
U_BOOT_ENV_LOCATION(sf) = {
|
||||||
.location = ENVL_SPI_FLASH,
|
.location = ENVL_SPI_FLASH,
|
||||||
ENV_NAME("SPI Flash")
|
ENV_NAME("SPI Flash")
|
||||||
@ -355,4 +373,7 @@ U_BOOT_ENV_LOCATION(sf) = {
|
|||||||
#ifdef CMD_SAVEENV
|
#ifdef CMD_SAVEENV
|
||||||
.save = env_save_ptr(env_sf_save),
|
.save = env_save_ptr(env_sf_save),
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
|
||||||
|
.init = env_sf_init,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user