diff options
author | Sinthu Raja <sinthu.raja@ti.com> | 2023-01-10 21:17:54 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-27 12:51:27 -0500 |
commit | 554f8e84b63e90f92d59a91820c81ff0635340dd (patch) | |
tree | fdfcbed79a7c620b26c5539d6393045d2f516bb9 /board/ti/j721s2 | |
parent | fca27ee8b993bd1a5752fc2156b1e86358fa8041 (diff) | |
download | u-boot-554f8e84b63e90f92d59a91820c81ff0635340dd.tar.gz u-boot-554f8e84b63e90f92d59a91820c81ff0635340dd.tar.bz2 u-boot-554f8e84b63e90f92d59a91820c81ff0635340dd.zip |
board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM
Add the board_init_f API for SPL and run the platform-required SoC
initialization.
Add the functionality for board name-based DTB selection from FIT
within SPL. This will make it easier to utilise one defconfig for
both the EVM and the SK.
Signed-off-by: Sinthu Raja <sinthu.raja@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'board/ti/j721s2')
-rw-r--r-- | board/ti/j721s2/evm.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index 9b159e3d5c..c86715fa21 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -23,6 +23,7 @@ #include <asm/arch/sys_proto.h> #include <dm.h> #include <dm/uclass-internal.h> +#include <dm/root.h> #include "../common/board_detect.h" @@ -207,3 +208,66 @@ int board_late_init(void) void spl_board_init(void) { } + +/* Support for the various EVM / SK families */ +#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT) +void do_dt_magic(void) +{ + int ret, rescan, mmc_dev = -1; + static struct mmc *mmc; + + do_board_detect(); + + /* + * Board detection has been done. + * Let us see if another dtb wouldn't be a better match + * for our board + */ + if (IS_ENABLED(CONFIG_CPU_V7R)) { + ret = fdtdec_resetup(&rescan); + if (!ret && rescan) { + dm_uninit(); + dm_init_and_scan(true); + } + } + + /* + * Because of multi DTB configuration, the MMC device has + * to be re-initialized after reconfiguring FDT inorder to + * boot from MMC. Do this when boot mode is MMC and ROM has + * not loaded SYSFW. + */ + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC1: + mmc_dev = 0; + break; + case BOOT_DEVICE_MMC2: + case BOOT_DEVICE_MMC2_2: + mmc_dev = 1; + break; + } + + if (mmc_dev > 0 && !check_rom_loaded_sysfw()) { + ret = mmc_init_device(mmc_dev); + if (!ret) { + mmc = find_mmc_device(mmc_dev); + if (mmc) { + ret = mmc_init(mmc); + if (ret) + printf("mmc init failed with error: %d\n", ret); + } + } + } +} +#endif + +#ifdef CONFIG_SPL_BUILD +void board_init_f(ulong dummy) +{ + k3_spl_init(); +#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT) + do_dt_magic(); +#endif + k3_mem_init(); +} +#endif |