*** Introduce get_boot_device() for K3 platform ***
Subsystems (2)
v2 cover *** Introduce get_boot_device() for K3 platform ***
It is handy to have some u-boot environment variables set based on the current booting device.
Provide a way to obtain the boot device for non SPLs by factoring out spl_boot_device() into an own function get_boot_device().
v2:
- Relocate bootindex to OCRAM, drop misleading comments and remove not needed changes
- Make get_boot_device() read bootindex out of OCRAM
- Add user for get_boot_device(), patch 3
v1: https://lists.denx.de/pipermail/u-boot/2024-February/546770.html
Wadim Egorov (3):
arm: mach-k3: am625: copy bootindex to OCRAM for main domain SPL
arm: mach-k3: am625: Provide a way to obtain boot device for non SPLs
board: phycore-am62x: Extend for better environment handling
arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am625_init.c | 103 ++---------------- arch/arm/mach-k3/am62x/Makefile | 2 + arch/arm/mach-k3/am62x/boot.c | 103 ++++++++++++++++++ arch/arm/mach-k3/include/mach/am62_hardware.h | 1 + arch/arm/mach-k3/include/mach/hardware.h | 1 + board/phytec/phycore_am62x/phycore-am62x.c | 64 +++++++++++ configs/phycore_am62x_a53_defconfig | 1 + 8 files changed, 182 insertions(+), 94 deletions(-) create mode 100644 arch/arm/mach-k3/am62x/Makefile create mode 100644 arch/arm/mach-k3/am62x/boot.c
Signature · 1 line
2.34.1
PATCH v2 1/3 arm: mach-k3: am625: copy bootindex to OCRAM for main domain SPL
Relocate booindex to OCRAM region after it gets opened by TIFS so the main domain bootloaders can have access to this data.
---
v2:
- Relocate bootindex to OCRAM, drop misleading comments and remove not needed changes
--- arch/arm/mach-k3/am625_init.c | 8 ++++++++ arch/arm/mach-k3/include/mach/am62_hardware.h | 1 + 2 files changed, 9 insertions(+)
arch/arm/mach-k3/am625_init.c +8 -0
@@ -175,6 +175,14 @@ void board_init_f(ulong dummy)k3_sysfw_loader (true,NULL ,NULL ); } +/* +* Relocate boot information to OCRAM (after TIFS has opend this +* region for us) so the next bootloader stages can keep access to +* primary vs backup bootmodes. +*/ +if (IS_ENABLED (CONFIG_CPU_V7R )) +writel (bootindex,K3_BOOT_PARAM_TABLE_INDEX_OCRAM ); +/* * Force probe of clk_k3 driver here to ensure basic default clock * configuration is always done.
arch/arm/mach-k3/include/mach/am62_hardware.h +1 -0
@@ -76,6 +76,7 @@#define CTRLMMR_MCU_RST_CTRL (MCU_CTRL_MMR0_BASE + 0x18170)#define ROM_EXTENDED_BOOT_DATA_INFO 0x43c3f1e0 +#define K3_BOOT_PARAM_TABLE_INDEX_OCRAM 0x7000F290#define TI_SRAM_SCRATCH_BOARD_EEPROM_START 0x43c30000
Signature · 1 line
2.34.1
PATCH v2 2/3 arm: mach-k3: am625: Provide a way to obtain boot device for non SPLs
In reply to Wadim EgorovIntroduce get_boot_device() to obtain the booting device. Make it also available for non SPL builds so u-boot can also know the device it is booting from.
---
v2:
- Make get_boot_device() read bootindex out of OCRAM
--- arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am625_init.c | 95 +-------------------- arch/arm/mach-k3/am62x/Makefile | 2 + arch/arm/mach-k3/am62x/boot.c | 103 +++++++++++++++++++++++ arch/arm/mach-k3/include/mach/hardware.h | 1 + 5 files changed, 108 insertions(+), 94 deletions(-) create mode 100644 arch/arm/mach-k3/am62x/Makefile create mode 100644 arch/arm/mach-k3/am62x/boot.c
arch/arm/mach-k3/Makefile +1 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_SOC_K3_AM625) += am625_init.o obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_init.o endif obj-y += common.o security.o +obj-$(CONFIG_SOC_K3_AM625) += am62x/
arch/arm/mach-k3/am625_init.c +1 -94
101 lines not on this page · raw message
arch/arm/mach-k3/am62x/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0+ +obj-y += boot.o
arch/arm/mach-k3/am62x/boot.c new file +103 -0
103 lines not on this page · raw message
arch/arm/mach-k3/include/mach/hardware.h +1 -0
@@ -96,4 +96,5 @@ struct rom_extended_boot_data { u32 num_components; }; +u32 get_boot_device (void );#endif /* _ASM_ARCH_HARDWARE_H_ */
Signature · 1 line
2.34.1
PATCH v2 3/3 board: phycore-am62x: Extend for better environment handling
In reply to Wadim EgorovSelect environment location based on the device we boot from. Also, introduce a "boot" variable that represents the current boot device and can be used by scripts.
--- board/phytec/phycore_am62x/phycore-am62x.c | 64 ++++++++++++++++++++++ configs/phycore_am62x_a53_defconfig | 1 + 2 files changed, 65 insertions(+)
board/phytec/phycore_am62x/phycore-am62x.c +64 -0
@@ -57,3 +57,67 @@ void spl_board_init(void) MCU_CTRL_DEVICE_CLKOUT_32K_CTRL); }#endif + +#if IS_ENABLED (CONFIG_ENV_IS_IN_FAT ) ||IS_ENABLED (CONFIG_ENV_IS_IN_MMC ) +int mmc_get_env_dev (void ) +{ +u32 boot_device =get_boot_device (); + +switch (boot_device) { +case BOOT_DEVICE_MMC1 : +return 0 ; +case BOOT_DEVICE_MMC2 : +return 1 ; + }; + +return CONFIG_SYS_MMC_ENV_DEV ; +} +#endif + +enum env_location env_get_location (enum env_operation op,int prio) +{ +u32 boot_device =get_boot_device (); + +if (prio) +return ENVL_UNKNOWN ; + +switch (boot_device) { +case BOOT_DEVICE_MMC1 : +case BOOT_DEVICE_MMC2 : +if (CONFIG_IS_ENABLED (ENV_IS_IN_FAT )) +return ENVL_FAT ; +if (CONFIG_IS_ENABLED (ENV_IS_IN_MMC )) +return ENVL_MMC ; +case BOOT_DEVICE_SPI : +if (CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH )) +return ENVL_SPI_FLASH ; +default : +return ENVL_NOWHERE ; + }; +} + +#if IS_ENABLED (CONFIG_BOARD_LATE_INIT ) +int board_late_init (void ) +{ +u32 boot_device =get_boot_device (); + +switch (boot_device) { +case BOOT_DEVICE_MMC1 : +env_set_ulong ("mmcdev" ,0 ); +env_set ("boot" ,"mmc" ); +break ; +case BOOT_DEVICE_MMC2 : +env_set_ulong ("mmcdev" ,1 ); +env_set ("boot" ,"mmc" ); +break ; +case BOOT_DEVICE_SPI : +env_set ("boot" ,"spi" ); +break ; +case BOOT_DEVICE_ETHERNET : +env_set ("boot" ,"net" ); +break ; + }; + +return 0 ; +} +#endif
configs/phycore_am62x_a53_defconfig +1 -0
@@ -34,6 +34,7 @@ CONFIG_BOOTSTD_FULL=y CONFIG_SYS_BOOTM_LEN=0x800000 CONFIG_BOOTCOMMAND="run mmcboot; bootflow scan -lb" CONFIG_DEFAULT_FDT_FILE="oftree" +CONFIG_BOARD_LATE_INIT=y CONFIG_SPL_MAX_SIZE=0x58000 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y CONFIG_SPL_BSS_START_ADDR=0x80c80000
Signature · 1 line
2.34.1
Quoted 4 lines · Wadim Egorov
It is handy to have some u-boot environment variables set based on the current booting device.
Provide a way to obtain the boot device for non SPLs by factoring outspl_boot_device()into an own functionget_boot_device().
Applied to u-boot/master now (but I seem to have missed this in b4 ty), thanks.
Signature · 1 line
Tom