mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-19 21:51:25 +02:00
board: st: stm32mp2: add mmc_get_env_dev()
Use the boot instance to select the correct mmc device identifier, this patch only to save the environment on eMMC = MMC(1) on STMicroelectronics boards. Set the CONFIG_SYS_MMC_ENV_DEV to -1 to select the mmc boot instance by default. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
This commit is contained in:
parent
1b343e2603
commit
a3be0ccc47
@ -10,6 +10,7 @@
|
|||||||
#include <fdt_support.h>
|
#include <fdt_support.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <misc.h>
|
#include <misc.h>
|
||||||
|
#include <mmc.h>
|
||||||
#include <asm/global_data.h>
|
#include <asm/global_data.h>
|
||||||
#include <asm/arch/sys_proto.h>
|
#include <asm/arch/sys_proto.h>
|
||||||
#include <dm/device.h>
|
#include <dm/device.h>
|
||||||
@ -78,6 +79,42 @@ enum env_location env_get_location(enum env_operation op, int prio)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mmc_get_boot(void)
|
||||||
|
{
|
||||||
|
struct udevice *dev;
|
||||||
|
u32 boot_mode = get_bootmode();
|
||||||
|
unsigned int instance = (boot_mode & TAMP_BOOT_INSTANCE_MASK) - 1;
|
||||||
|
char cmd[20];
|
||||||
|
const u32 sdmmc_addr[] = {
|
||||||
|
STM32_SDMMC1_BASE,
|
||||||
|
STM32_SDMMC2_BASE,
|
||||||
|
STM32_SDMMC3_BASE
|
||||||
|
};
|
||||||
|
|
||||||
|
if (instance > ARRAY_SIZE(sdmmc_addr))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* search associated sdmmc node in devicetree */
|
||||||
|
snprintf(cmd, sizeof(cmd), "mmc@%x", sdmmc_addr[instance]);
|
||||||
|
if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
|
||||||
|
log_err("mmc%d = %s not found in device tree!\n", instance, cmd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dev_seq(dev);
|
||||||
|
};
|
||||||
|
|
||||||
|
int mmc_get_env_dev(void)
|
||||||
|
{
|
||||||
|
const int mmc_env_dev = CONFIG_IS_ENABLED(ENV_IS_IN_MMC, (CONFIG_SYS_MMC_ENV_DEV), (-1));
|
||||||
|
|
||||||
|
if (mmc_env_dev >= 0)
|
||||||
|
return mmc_env_dev;
|
||||||
|
|
||||||
|
/* use boot instance to select the correct mmc device identifier */
|
||||||
|
return mmc_get_boot();
|
||||||
|
}
|
||||||
|
|
||||||
int board_late_init(void)
|
int board_late_init(void)
|
||||||
{
|
{
|
||||||
const void *fdt_compat;
|
const void *fdt_compat;
|
||||||
|
@ -36,7 +36,7 @@ CONFIG_CMD_LOG=y
|
|||||||
CONFIG_OF_LIVE=y
|
CONFIG_OF_LIVE=y
|
||||||
CONFIG_ENV_IS_NOWHERE=y
|
CONFIG_ENV_IS_NOWHERE=y
|
||||||
CONFIG_ENV_IS_IN_MMC=y
|
CONFIG_ENV_IS_IN_MMC=y
|
||||||
CONFIG_SYS_MMC_ENV_DEV=1
|
CONFIG_SYS_MMC_ENV_DEV=-1
|
||||||
CONFIG_NO_NET=y
|
CONFIG_NO_NET=y
|
||||||
CONFIG_SYS_64BIT_LBA=y
|
CONFIG_SYS_64BIT_LBA=y
|
||||||
CONFIG_GPIO_HOG=y
|
CONFIG_GPIO_HOG=y
|
||||||
|
Loading…
x
Reference in New Issue
Block a user