Re: [PATCH V3 08/12] board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM
On Wed, Jan 4, 2023 at 12:53 PM Neha Malcom Francis wrote: > > Hi Sinthu > > On 27/12/22 17:45, Sinthu Raja wrote: > > From: Sinthu Raja > > > > 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 > > --- > > > > Changes in V3: > > = > > Address review comments: > > - Rework on DTB selection API clarity about mini-U-Boot vs EVM and family > > support as suggested. > > > > v2: > > https://patchwork.ozlabs.org/project/uboot/cover/20221221135219.24702-9-sinthu.r...@ti.com/ > > > > board/ti/j721s2/evm.c | 64 +++ > > 1 file changed, 64 insertions(+) > > > > diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c > > index a7c4082a7a..a670332fc0 100644 > > --- a/board/ti/j721s2/evm.c > > +++ b/board/ti/j721s2/evm.c > > @@ -23,6 +23,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "../common/board_detect.h" > > > > @@ -202,3 +203,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(); > > +#ifdef CONFIG_SPL_OF_LIST > > This may just be a case of formality but we'd need "if > defined(CONFIG_TI_I2C_BOARD_DETECT)" here as well right? Thanks for pointing, I have updated and pushed the new series. > > > + do_dt_magic(); > > +#endif > > + k3_mem_init(); > > +} > > +#endif > > -- > Thanking You > Neha Malcom Francis -- With Regards Sinthu Raja
Re: [PATCH V3 08/12] board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM
Hi Sinthu On 27/12/22 17:45, Sinthu Raja wrote: From: Sinthu Raja 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 --- Changes in V3: = Address review comments: - Rework on DTB selection API clarity about mini-U-Boot vs EVM and family support as suggested. v2: https://patchwork.ozlabs.org/project/uboot/cover/20221221135219.24702-9-sinthu.r...@ti.com/ board/ti/j721s2/evm.c | 64 +++ 1 file changed, 64 insertions(+) diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index a7c4082a7a..a670332fc0 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "../common/board_detect.h" @@ -202,3 +203,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(); +#ifdef CONFIG_SPL_OF_LIST This may just be a case of formality but we'd need "if defined(CONFIG_TI_I2C_BOARD_DETECT)" here as well right? + do_dt_magic(); +#endif + k3_mem_init(); +} +#endif -- Thanking You Neha Malcom Francis
[PATCH V3 08/12] board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM
From: Sinthu Raja 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 --- Changes in V3: = Address review comments: - Rework on DTB selection API clarity about mini-U-Boot vs EVM and family support as suggested. v2: https://patchwork.ozlabs.org/project/uboot/cover/20221221135219.24702-9-sinthu.r...@ti.com/ board/ti/j721s2/evm.c | 64 +++ 1 file changed, 64 insertions(+) diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index a7c4082a7a..a670332fc0 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "../common/board_detect.h" @@ -202,3 +203,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(); +#ifdef CONFIG_SPL_OF_LIST + do_dt_magic(); +#endif + k3_mem_init(); +} +#endif -- 2.36.1