]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm: k3: select tifsstub via board_fit_config_name_match
authorAristo Chen <aristo.chen@canonical.com>
Tue, 23 Jun 2026 14:15:15 +0000 (14:15 +0000)
committerTom Rini <trini@konsulko.com>
Thu, 16 Jul 2026 18:03:40 +0000 (12:03 -0600)
TI K3 AM62x/AM62Ax/AM62Px boards carry two or three mutually-exclusive
tifsstub variants in their tispl.bin FIT images, all at the same load
address. The existing approach loads every variant and then discards
the wrong ones at runtime via a *p_size = 0 hack in
board_fit_image_post_process(). Switch to selecting the appropriate
FIT configuration up front via board_fit_config_name_match() so only
the correct tifsstub is loaded in the first place.

board_fit_config_name_match() is invoked by the R5 SPL during FIT
config selection. get_device_type() is a simple register read that is
available at that point, so the security state can be determined
early. The matching logic is factored into
k3_fit_config_match_security_state() in arch/arm/mach-k3/common.c so
it can be shared by any K3 board that wants this scheme. It matches
configurations by a suffix appended to the description string:

  -hs-se  ->  HS-SE  (K3_DEVICE_TYPE_HS_SE)
  -hs-fs  ->  HS-FS  (K3_DEVICE_TYPE_HS_FS)
  -gp     ->  GP     (K3_DEVICE_TYPE_GP)

Configurations without a security-state suffix (e.g. u-boot.img) do
not match and fall through to the DTS-specified default config
naturally.

Each TI EVM board defines its board_fit_config_name_match() as a thin
wrapper around the shared helper:
- board/ti/am62x/evm.c   (AM625 SK: hs-se, hs-fs, gp)
- board/ti/am62ax/evm.c  (AM62A SK: hs-se, hs-fs, gp)
- board/ti/am62px/evm.c  (AM62P SK: hs-se, hs-fs, gp)

FIT configurations are split per security state in:
- arch/arm/dts/k3-am625-sk-binman.dtsi
  (ti-falcon, ti-spl, ti-spl_unsigned: conf-hs-se/conf-hs-fs/conf-gp)
- arch/arm/dts/k3-am62a-sk-binman.dtsi
  (ti-falcon, ti-spl: conf-hs-se/conf-hs-fs; no GP variant on AM62A)
- arch/arm/dts/k3-am62p-sk-binman.dtsi
  (ti-falcon, ti-spl: conf-hs-se/conf-hs-fs; no GP variant on AM62P)

The runtime filter in board_fit_image_post_process() is intentionally
left in place. It becomes redundant once every board using the AM62x
family dtsi files migrates to per-state configurations. The dtsi for
phytec phycore and toradex verdin boards is updated by separate
patches in this series, and the now-redundant runtime filter is
removed by the final patch in the series.

Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Reviewed-by: Anshul Dalal <anshuld@ti.com>
arch/arm/dts/k3-am625-sk-binman.dtsi
arch/arm/dts/k3-am62a-sk-binman.dtsi
arch/arm/dts/k3-am62p-sk-binman.dtsi
arch/arm/mach-k3/common.c
arch/arm/mach-k3/common.h
arch/arm/mach-k3/include/mach/hardware.h
board/ti/am62ax/evm.c
board/ti/am62px/evm.c
board/ti/am62x/evm.c

index ba29a047406879dd71a96a30bb360a332c631908..1717621a8500a503c1fc19de4919324ab67bc7a1 100644 (file)
                        };
 
                        configurations {
-                               default = "conf-0";
-                               conf-0 {
-                                       description = "k3-am625-sk-falcon";
+                               default = "conf-hs-fs";
+                               conf-hs-fs {
+                                       description = "k3-am625-sk-falcon-hs-fs";
+                                       firmware = "atf";
+                                       loadables = "tee", "tifsstub-fs", "dm";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am625-sk-falcon-hs-se";
+                                       firmware = "atf";
+                                       loadables = "tee", "tifsstub-hs", "dm";
+                               };
+                               conf-gp {
+                                       description = "k3-am625-sk-falcon-gp";
                                        firmware = "atf";
-                                       loadables = "tee", "tifsstub-hs", "tifsstub-fs",
-                                       "tifsstub-gp", "dm";
+                                       loadables = "tee", "tifsstub-gp", "dm";
                                };
                        };
                };
                        };
 
                        configurations {
-                               default = "conf-0";
+                               default = "conf-hs-fs";
 
-                               conf-0 {
-                                       description = "k3-am625-sk";
+                               conf-hs-fs {
+                                       description = "k3-am625-sk-hs-fs";
+                                       firmware = "atf";
+                                       loadables = "tee", "tifsstub-fs", "dm", "spl";
+                                       fdt = "fdt-0";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am625-sk-hs-se";
                                        firmware = "atf";
-                                       loadables = "tee", "tifsstub-hs", "tifsstub-fs",
-                                       "tifsstub-gp", "dm", "spl";
+                                       loadables = "tee", "tifsstub-hs", "dm", "spl";
+                                       fdt = "fdt-0";
+                               };
+                               conf-gp {
+                                       description = "k3-am625-sk-gp";
+                                       firmware = "atf";
+                                       loadables = "tee", "tifsstub-gp", "dm", "spl";
                                        fdt = "fdt-0";
                                };
                        };
                        };
 
                        configurations {
-                               default = "conf-0";
+                               default = "conf-hs-fs";
 
-                               conf-0 {
-                                       description = "k3-am625-sk";
+                               conf-hs-fs {
+                                       description = "k3-am625-sk-hs-fs";
+                                       firmware = "atf";
+                                       loadables = "tee", "tifsstub-fs", "dm", "spl";
+                                       fdt = "fdt-0";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am625-sk-hs-se";
+                                       firmware = "atf";
+                                       loadables = "tee", "tifsstub-hs", "dm", "spl";
+                                       fdt = "fdt-0";
+                               };
+                               conf-gp {
+                                       description = "k3-am625-sk-gp";
                                        firmware = "atf";
-                                       loadables = "tee", "tifsstub-hs", "tifsstub-fs",
-                                                 "tifsstub-gp", "dm", "spl";
+                                       loadables = "tee", "tifsstub-gp", "dm", "spl";
                                        fdt = "fdt-0";
                                };
                        };
index 49c90f5855cf4021976ba8889ef733df0583a709..6e7deb218e97f2eb105a8dec903cd23419c8a620 100644 (file)
                        };
 
                        configurations {
-                               default = "conf-0";
-                               conf-0 {
-                                       description = "k3-am62a7-sk-falcon";
+                               default = "conf-hs-fs";
+                               conf-hs-fs {
+                                       description = "k3-am62a7-sk-falcon-hs-fs";
+                                       firmware = "atf";
+                                       loadables = "tee", "dm", "tifsstub-fs";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am62a7-sk-falcon-hs-se";
                                        firmware = "atf";
-                                       loadables = "tee", "dm", "tifsstub-hs", "tifsstub-fs";
+                                       loadables = "tee", "dm", "tifsstub-hs";
                                };
                        };
                };
                        };
 
                        configurations {
-                               default = "conf-0";
+                               default = "conf-hs-fs";
 
-                               ti_spl_conf_0: conf-0 {
-                                       description = "k3-am62a7-sk";
+                               ti_spl_conf_0: conf-hs-fs {
+                                       description = "k3-am62a7-sk-hs-fs";
+                                       firmware = "atf";
+                                       loadables = "tee", "dm", "spl", "tifsstub-fs";
+                                       fdt = "fdt-0";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am62a7-sk-hs-se";
                                        firmware = "atf";
-                                       loadables = "tee", "dm", "spl",
-                                       "tifsstub-hs", "tifsstub-fs";
+                                       loadables = "tee", "dm", "spl", "tifsstub-hs";
                                        fdt = "fdt-0";
                                };
                        };
index cca56b76d6914b3350148243be689349b5f51774..c56ecad85a6a50d710770aa0145a02fb94cb2498 100644 (file)
                        };
 
                        configurations {
-                               default = "conf-0";
-                               conf-0 {
-                                       description = "k3-am62p5-sk-falcon";
+                               default = "conf-hs-fs";
+                               conf-hs-fs {
+                                       description = "k3-am62p5-sk-falcon-hs-fs";
                                        firmware = "atf";
-                                       loadables = "tee", "dm", "tifsstub-hs", "tifsstub-fs";
+                                       loadables = "tee", "dm", "tifsstub-fs";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am62p5-sk-falcon-hs-se";
+                                       firmware = "atf";
+                                       loadables = "tee", "dm", "tifsstub-hs";
                                };
                        };
                };
                        };
 
                        configurations {
-                               default = "conf-0";
+                               default = "conf-hs-fs";
 
-                               conf-0 {
-                                       description = "k3-am62px-sk";
+                               conf-hs-fs {
+                                       description = "k3-am62px-sk-hs-fs";
+                                       firmware = "atf";
+                                       loadables = "tee", "dm", "spl", "tifsstub-fs";
+                                       fdt = "fdt-0";
+                               };
+                               conf-hs-se {
+                                       description = "k3-am62px-sk-hs-se";
                                        firmware = "atf";
-                                       loadables = "tee", "dm", "spl",
-                                       "tifsstub-hs", "tifsstub-fs";
+                                       loadables = "tee", "dm", "spl", "tifsstub-hs";
                                        fdt = "fdt-0";
                                };
                        };
index 19a6e24f38b206a4f288043f696cd687868c376e..6e382efdb3be34fcb3ddbf90cd9b884e5330d16f 100644 (file)
@@ -191,6 +191,33 @@ enum k3_device_type get_device_type(void)
        }
 }
 
+int k3_fit_config_match_security_state(const char *name)
+{
+       const char *suffix;
+       size_t name_len, suffix_len;
+
+       switch (get_device_type()) {
+       case K3_DEVICE_TYPE_HS_SE:
+               suffix = "-hs-se";
+               break;
+       case K3_DEVICE_TYPE_HS_FS:
+               suffix = "-hs-fs";
+               break;
+       case K3_DEVICE_TYPE_GP:
+               suffix = "-gp";
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       name_len = strlen(name);
+       suffix_len = strlen(suffix);
+       if (name_len < suffix_len)
+               return -EINVAL;
+
+       return strncmp(name + name_len - suffix_len, suffix, suffix_len);
+}
+
 #if defined(CONFIG_DISPLAY_CPUINFO)
 static const char *get_device_type_name(void)
 {
index 466ad22f895de3b4952507ae70f127bf0cfc2128..37ff98d89924207781baeb0fdcd25be6ebf3d025 100644 (file)
@@ -32,15 +32,6 @@ enum k3_firewall_region_type {
        K3_FIREWALL_REGION_BACKGROUND
 };
 
-enum k3_device_type {
-       K3_DEVICE_TYPE_BAD,
-       K3_DEVICE_TYPE_GP,
-       K3_DEVICE_TYPE_TEST,
-       K3_DEVICE_TYPE_EMU,
-       K3_DEVICE_TYPE_HS_FS,
-       K3_DEVICE_TYPE_HS_SE,
-};
-
 void setup_k3_mpu_regions(void);
 int early_console_init(void);
 void disable_linefill_optimization(void);
@@ -55,7 +46,6 @@ const struct k3_speed_grade_map *k3_get_speed_grade_map(void);
 void k3_fix_rproc_clock(const char *path);
 void mmr_unlock(uintptr_t base, u32 partition);
 bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data);
-enum k3_device_type get_device_type(void);
 struct ti_sci_handle *get_ti_sci_handle(void);
 void do_board_detect(void);
 void ti_secure_image_check_binary(void **p_image, size_t *p_size);
index b337a71956fb9846632e40582fe6a555eed94ae1..2c771a1195f566145d05c45773286a07d1c62c29 100644 (file)
@@ -124,8 +124,19 @@ struct rom_extended_boot_data {
        u32 num_components;
 };
 
+enum k3_device_type {
+       K3_DEVICE_TYPE_BAD,
+       K3_DEVICE_TYPE_GP,
+       K3_DEVICE_TYPE_TEST,
+       K3_DEVICE_TYPE_EMU,
+       K3_DEVICE_TYPE_HS_FS,
+       K3_DEVICE_TYPE_HS_SE,
+};
+
 u32 get_boot_device(void);
 const char *get_reset_reason(void);
+enum k3_device_type get_device_type(void);
+int k3_fit_config_match_security_state(const char *name);
 
 #define writel_verify(val, addr) \
 do { \
index 4916eec3b2b2122886300a65d443db87242bf1dd..adb784e69a87e4222d507ae581646a702da1f3ab 100644 (file)
@@ -6,6 +6,7 @@
  *
  */
 
+#include <image.h>
 #include <asm/arch/hardware.h>
 #include <asm/io.h>
 #include <dm/uclass.h>
 #include "../common/fdt_ops.h"
 #include "../common/k3_32k_lfosc.h"
 
+int board_fit_config_name_match(const char *name)
+{
+       return k3_fit_config_match_security_state(name);
+}
+
 #if defined(CONFIG_XPL_BUILD)
 void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
index 8fde47fb1be433fba9856cfad4bd26e64ea8eb35..9fa0a1c9f7279ce940be23363c5e44b42f4d8f57 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <efi_loader.h>
+#include <image.h>
 #include <asm/arch/hardware.h>
 #include <asm/io.h>
 #include <cpu_func.h>
@@ -43,6 +44,11 @@ struct efi_capsule_update_info update_info = {
        .images = fw_images,
 };
 
+int board_fit_config_name_match(const char *name)
+{
+       return k3_fit_config_match_security_state(name);
+}
+
 #if IS_ENABLED(CONFIG_SPL_BUILD)
 void spl_board_init(void)
 {
index 49e58ad6d6c88d1e4cd41c3a273be6f7441ab609..90beed341b68880cfed6fe09d461e38f49b03482 100644 (file)
@@ -18,6 +18,7 @@
 #include <fdt_support.h>
 #include <fdt_simplefb.h>
 #include <asm/io.h>
+#include <image.h>
 #include <asm/arch/hardware.h>
 #include <dm/uclass.h>
 #include <asm/arch/k3-ddr.h>
@@ -135,6 +136,11 @@ int board_late_init(void)
 }
 #endif
 
+int board_fit_config_name_match(const char *name)
+{
+       return k3_fit_config_match_security_state(name);
+}
+
 #if defined(CONFIG_XPL_BUILD)
 void spl_board_init(void)
 {