diff mbox series

[03/10] board: stm32mp1: Implement board_fit_config_name_match() for SPL

Message ID 20210826214209.254461-4-mr.nuke.me@gmail.com
State Superseded
Delegated to: Patrice Chotard
Headers show
Series stm32mp1: Support falcon mode with OP-TEE payloads | expand

Commit Message

Alexandru Gagniuc Aug. 26, 2021, 9:42 p.m. UTC
This function is needed when loading a FIT image from SPL. It selects
the correct configuration node for the current board. Implement it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
 board/st/stm32mp1/spl.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Patrick Delaunay Aug. 31, 2021, 4:39 p.m. UTC | #1
Hi

Add in CC the MAINTAINERS.

On 8/26/21 11:42 PM, Alexandru Gagniuc wrote:
> This function is needed when loading a FIT image from SPL. It selects
> the correct configuration node for the current board. Implement it.
>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> ---
>   board/st/stm32mp1/spl.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c
> index bb210d7727..543c037ad8 100644
> --- a/board/st/stm32mp1/spl.c
> +++ b/board/st/stm32mp1/spl.c
> @@ -5,6 +5,7 @@
>   
>   #include <config.h>
>   #include <common.h>
> +#include <dm/device.h>
>   #include <init.h>
>   #include <asm/io.h>
>   #include <asm/arch/sys_proto.h>
> @@ -92,3 +93,12 @@ void board_debug_uart_init(void)
>   #endif
>   }
>   #endif
> +
> +int board_fit_config_name_match(const char *name)
> +{
> +	if (of_machine_is_compatible("st,stm32mp157c-dk2"))
> +		return !strstr(name, "stm32mp157c-dk2");
> +
> +	/* Okay, it's most likely an EV board */
> +	return !strstr(name, "stm32mp157") + !strstr(name, "-ev");
> +}

It is not working for all STMicroelectronics boards....

=> st,stm32mp157a-dk1 for example

based on board_late_init => I propose board_name extraction from compatible :

#ifdef CONFIG_SPL_LOAD_FIT
int board_fit_config_name_match(const char *name)
{
	const void *fdt_compat;
	int fdt_compat_len;

	fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible", &fdt_compat_len);

	/* only STMicrolectronics board are supported */
	if (strncmp(fdt_compat, "st,", 3) != 0)
		return 1;
	
	return !strstr(name, fdt_compat + 3);
}
#endif
diff mbox series

Patch

diff --git a/board/st/stm32mp1/spl.c b/board/st/stm32mp1/spl.c
index bb210d7727..543c037ad8 100644
--- a/board/st/stm32mp1/spl.c
+++ b/board/st/stm32mp1/spl.c
@@ -5,6 +5,7 @@ 
 
 #include <config.h>
 #include <common.h>
+#include <dm/device.h>
 #include <init.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
@@ -92,3 +93,12 @@  void board_debug_uart_init(void)
 #endif
 }
 #endif
+
+int board_fit_config_name_match(const char *name)
+{
+	if (of_machine_is_compatible("st,stm32mp157c-dk2"))
+		return !strstr(name, "stm32mp157c-dk2");
+
+	/* Okay, it's most likely an EV board */
+	return !strstr(name, "stm32mp157") + !strstr(name, "-ev");
+}