mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal
@ 2025-04-09 13:19 Ahmad Fatoum
  2025-04-09 13:19 ` [PATCH 2/2] ARM: stm32mp: init: expand bootsource logic to STM32MP13{1,3} Ahmad Fatoum
  2025-04-10  6:37 ` [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-04-09 13:19 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

stm32mp_code() is used internally in SoC support code to record the
information what SoC we are running on per device tree.

By changing the information to hexadecimal, we can more easily apply
bitmasks to check if we are on STM32MP15 or STM32MP13.

Do that and while at it, rename the function as not to confuse any
out-of-tree users.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-stm32mp/init.c       | 14 +++++++-------
 arch/arm/mach-stm32mp/stm32image.c |  2 +-
 include/mach/stm32mp/stm32.h       |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-stm32mp/init.c b/arch/arm/mach-stm32mp/init.c
index 2eb8b6beec2a..b24649e86658 100644
--- a/arch/arm/mach-stm32mp/init.c
+++ b/arch/arm/mach-stm32mp/init.c
@@ -229,9 +229,9 @@ static int stm32mp15_setup_cpu_type(void)
 	return 0;
 }
 
-static int __st32mp_soc;
+static unsigned __st32mp_soc;
 
-int stm32mp_soc(void)
+unsigned stm32mp_soc_code(void)
 {
 	return __st32mp_soc;
 }
@@ -241,17 +241,17 @@ static int stm32mp_init(void)
 	u32 boot_ctx;
 
 	if (of_machine_is_compatible("st,stm32mp135"))
-		__st32mp_soc = 32135;
+		__st32mp_soc = 0x32135;
 	else if (of_machine_is_compatible("st,stm32mp151"))
-		__st32mp_soc = 32151;
+		__st32mp_soc = 0x32151;
 	else if (of_machine_is_compatible("st,stm32mp153"))
-		__st32mp_soc = 32153;
+		__st32mp_soc = 0x32153;
 	else if (of_machine_is_compatible("st,stm32mp157"))
-		__st32mp_soc = 32157;
+		__st32mp_soc = 0x32157;
 	else
 		return 0;
 
-	if (__st32mp_soc == 32135) {
+	if (__st32mp_soc == 0x32135) {
 		boot_ctx = readl(STM32MP13_TAMP_BOOT_CONTEXT);
 	} else {
 		stm32mp15_setup_cpu_type();
diff --git a/arch/arm/mach-stm32mp/stm32image.c b/arch/arm/mach-stm32mp/stm32image.c
index 37d7c731209e..1b2e8c618c85 100644
--- a/arch/arm/mach-stm32mp/stm32image.c
+++ b/arch/arm/mach-stm32mp/stm32image.c
@@ -46,7 +46,7 @@ static struct image_handler image_handler_stm32_image_v1_handler = {
 
 static int stm32mp_register_stm32image_image_handler(void)
 {
-	if (!stm32mp_soc())
+	if (!stm32mp_soc_code())
 		return 0;
 
 	return register_image_handler(&image_handler_stm32_image_v1_handler);
diff --git a/include/mach/stm32mp/stm32.h b/include/mach/stm32mp/stm32.h
index f698ebfaf4f1..a37d62cdaedb 100644
--- a/include/mach/stm32mp/stm32.h
+++ b/include/mach/stm32mp/stm32.h
@@ -28,6 +28,6 @@
 #define STM32_DDR_BASE			0xC0000000
 #define STM32_DDR_SIZE			SZ_1G
 
-int stm32mp_soc(void);
+unsigned stm32mp_soc_code(void);
 
 #endif /* _MACH_STM32_H_ */
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ARM: stm32mp: init: expand bootsource logic to STM32MP13{1,3}
  2025-04-09 13:19 [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal Ahmad Fatoum
@ 2025-04-09 13:19 ` Ahmad Fatoum
  2025-04-10  6:37 ` [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-04-09 13:19 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We currently run through the bootsource logic only for STM32MP135, but
the code is equally applicable to the cheaper variants that only differ
in available peripherals.

Change the check to account for current STM32MP13 variants.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-stm32mp/init.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/init.c b/arch/arm/mach-stm32mp/init.c
index b24649e86658..1c7f62dbb033 100644
--- a/arch/arm/mach-stm32mp/init.c
+++ b/arch/arm/mach-stm32mp/init.c
@@ -240,7 +240,11 @@ static int stm32mp_init(void)
 {
 	u32 boot_ctx;
 
-	if (of_machine_is_compatible("st,stm32mp135"))
+	if (of_machine_is_compatible("st,stm32mp131"))
+		__st32mp_soc = 0x32131;
+	else if (of_machine_is_compatible("st,stm32mp133"))
+		__st32mp_soc = 0x32133;
+	else if (of_machine_is_compatible("st,stm32mp135"))
 		__st32mp_soc = 0x32135;
 	else if (of_machine_is_compatible("st,stm32mp151"))
 		__st32mp_soc = 0x32151;
@@ -251,7 +255,7 @@ static int stm32mp_init(void)
 	else
 		return 0;
 
-	if (__st32mp_soc == 0x32135) {
+	if ((__st32mp_soc & 0xFF0) == 0x130) {
 		boot_ctx = readl(STM32MP13_TAMP_BOOT_CONTEXT);
 	} else {
 		stm32mp15_setup_cpu_type();
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal
  2025-04-09 13:19 [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal Ahmad Fatoum
  2025-04-09 13:19 ` [PATCH 2/2] ARM: stm32mp: init: expand bootsource logic to STM32MP13{1,3} Ahmad Fatoum
@ 2025-04-10  6:37 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-04-10  6:37 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Wed, 09 Apr 2025 15:19:19 +0200, Ahmad Fatoum wrote:
> stm32mp_code() is used internally in SoC support code to record the
> information what SoC we are running on per device tree.
> 
> By changing the information to hexadecimal, we can more easily apply
> bitmasks to check if we are on STM32MP15 or STM32MP13.
> 
> Do that and while at it, rename the function as not to confuse any
> out-of-tree users.
> 
> [...]

Applied, thanks!

[1/2] ARM: stm32mp: switch internal SoC code to hexadecimal
      https://git.pengutronix.de/cgit/barebox/commit/?id=32c05dcac56c (link may not be stable)
[2/2] ARM: stm32mp: init: expand bootsource logic to STM32MP13{1,3}
      https://git.pengutronix.de/cgit/barebox/commit/?id=2ac7fd27ec75 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-10  6:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-09 13:19 [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal Ahmad Fatoum
2025-04-09 13:19 ` [PATCH 2/2] ARM: stm32mp: init: expand bootsource logic to STM32MP13{1,3} Ahmad Fatoum
2025-04-10  6:37 ` [PATCH 1/2] ARM: stm32mp: switch internal SoC code to hexadecimal Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox