mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use
@ 2023-01-11 17:22 Ahmad Fatoum
  2023-01-11 17:22 ` [PATCH v3 2/2] ARM: at91: make bootsource code generic to all SAMA5 Ahmad Fatoum
  2023-01-12 14:53 ` [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-01-11 17:22 UTC (permalink / raw)
  To: barebox; +Cc: Sam Ravnborg, Ahmad Fatoum

The sama5d4[devices].c files are for non-OF instantiation of platform
devices. We don't need anything out of these two files, so don't build
them when compiling for CONFIG_AT91_MULTI_BOARDS. We use that instead of
CONFIG_OFDEVICE, as sama5d4_xplained_defconfig and sama5d4ek_defconfig
enable CONFIG_OFDEVICE, but probe no device at all from DT.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - use CONFIG_AT91_MULTI_BOARDS instead of CONFIG_OFDEVICE to fix
    sama5d4 non-DT defconfigs build failure

Sascha, please replace commit with same name in next with this.
---
 arch/arm/mach-at91/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 390d49d03dee..f70e67bddebf 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -27,9 +27,10 @@ obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o at91rm9200_device
 obj-$(CONFIG_SOC_AT91SAM9260) += at91sam9260.o at91sam9260_devices.o
 obj-$(CONFIG_SOC_AT91SAM9261) += at91sam9261.o at91sam9261_devices.o
 obj-$(CONFIG_SOC_AT91SAM9G10) += at91sam9261.o at91sam9261_devices.o
-ifeq ($(CONFIG_OFDEVICE),)
+ifeq ($(CONFIG_AT91_MULTI_BOARDS),)
 obj-$(CONFIG_SOC_AT91SAM9263) += at91sam9263.o at91sam9263_devices.o
 obj-$(CONFIG_SOC_SAMA5D3)	+= sama5d3.o sama5d3_devices.o
+obj-$(CONFIG_SOC_SAMA5D4)	+= sama5d4.o sama5d4_devices.o
 endif
 lwl-$(CONFIG_SOC_AT91SAM9263)	+= sam9263_ll.o
 lwl-$(CONFIG_SOC_SAMA5D2)	+= sama5d2_ll.o
@@ -39,4 +40,3 @@ obj-$(CONFIG_SOC_AT91SAM9G20) += at91sam9260.o at91sam9260_devices.o
 obj-$(CONFIG_SOC_AT91SAM9G45) += at91sam9g45.o at91sam9g45_devices.o
 obj-$(CONFIG_SOC_AT91SAM9X5)	+= at91sam9x5.o at91sam9x5_devices.o
 obj-$(CONFIG_SOC_AT91SAM9N12)	+= at91sam9n12.o at91sam9n12_devices.o
-obj-$(CONFIG_SOC_SAMA5D4)	+= sama5d4.o sama5d4_devices.o
-- 
2.30.2




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

* [PATCH v3 2/2] ARM: at91: make bootsource code generic to all SAMA5
  2023-01-11 17:22 [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use Ahmad Fatoum
@ 2023-01-11 17:22 ` Ahmad Fatoum
  2023-01-12 14:53 ` [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-01-11 17:22 UTC (permalink / raw)
  To: barebox; +Cc: Sam Ravnborg, Ahmad Fatoum

While I couldn't find documentation, the BootROM of all of SAMA5D2, D3
and D4 populates R4 when calling next stage bootloader with information
about the booutsource. barebox PBL will pass along this information to
barebox proper, so add a generic initcall that sets the bootsource.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - define at91_bootsource() in bootm-barebox.c instead as sama5_bootsource.c
    is only for DT-enabled multi-image-capable barebox builds.

Sascha, please replace commit with same name in next with this.
---
 arch/arm/mach-at91/Kconfig                    |  3 ++
 arch/arm/mach-at91/Makefile                   |  1 +
 arch/arm/mach-at91/bootm-barebox.c            |  6 ++--
 arch/arm/mach-at91/include/mach/cpu.h         |  1 -
 .../mach-at91/include/mach/sama5_bootsource.h |  2 ++
 arch/arm/mach-at91/sama5_bootsource.c         | 33 +++++++++++++++++++
 arch/arm/mach-at91/sama5d2.c                  | 15 ---------
 arch/arm/mach-at91/setup.c                    |  3 --
 8 files changed, 43 insertions(+), 21 deletions(-)
 create mode 100644 arch/arm/mach-at91/sama5_bootsource.c

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index bc55b1c4e76e..529512b6c0db 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -75,6 +75,9 @@ config SOC_SAMA5
 	select HAVE_AT91SAM9_RST
 	select CPU_V7
 
+config SOC_SAMA5_MULTI
+	def_bool SOC_SAMA5 && AT91_MULTI_BOARDS
+
 config SOC_SAMA5D2
 	bool
 	select SOC_SAMA5
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index f70e67bddebf..301e0b761b26 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -40,3 +40,4 @@ obj-$(CONFIG_SOC_AT91SAM9G20) += at91sam9260.o at91sam9260_devices.o
 obj-$(CONFIG_SOC_AT91SAM9G45) += at91sam9g45.o at91sam9g45_devices.o
 obj-$(CONFIG_SOC_AT91SAM9X5)	+= at91sam9x5.o at91sam9x5_devices.o
 obj-$(CONFIG_SOC_AT91SAM9N12)	+= at91sam9n12.o at91sam9n12_devices.o
+obj-$(CONFIG_SOC_SAMA5_MULTI)	+= sama5_bootsource.o
diff --git a/arch/arm/mach-at91/bootm-barebox.c b/arch/arm/mach-at91/bootm-barebox.c
index 3c99d5813b53..77aa4577c6c7 100644
--- a/arch/arm/mach-at91/bootm-barebox.c
+++ b/arch/arm/mach-at91/bootm-barebox.c
@@ -6,9 +6,11 @@
 #include <common.h>
 #include <init.h>
 #include <memory.h>
-#include <mach/cpu.h>
 #include <mach/sama5_bootsource.h>
 
+unsigned long at91_bootsource;
+EXPORT_SYMBOL(at91_bootsource);
+
 static int do_bootm_at91_barebox_image(struct image_data *data)
 {
 	resource_size_t start, end;
@@ -40,7 +42,7 @@ static struct image_handler image_handler_at91_barebox_image = {
 
 static int at91_register_barebox_image_handler(void)
 {
-	if (!of_machine_is_compatible("atmel,sama5d2"))
+	if (!of_machine_is_compatible("atmel,sama5"))
 	    return 0;
 
 	return register_image_handler(&image_handler_at91_barebox_image);
diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h
index 37e516947b57..ca85e8be6e24 100644
--- a/arch/arm/mach-at91/include/mach/cpu.h
+++ b/arch/arm/mach-at91/include/mach/cpu.h
@@ -160,7 +160,6 @@ struct at91_socinfo {
 extern struct at91_socinfo at91_soc_initdata;
 const char *at91_get_soc_type(struct at91_socinfo *c);
 const char *at91_get_soc_subtype(struct at91_socinfo *c);
-extern unsigned long at91_bootsource;
 
 static inline int at91_soc_is_detected(void)
 {
diff --git a/arch/arm/mach-at91/include/mach/sama5_bootsource.h b/arch/arm/mach-at91/include/mach/sama5_bootsource.h
index b31d20bc7c34..8072e7c25154 100644
--- a/arch/arm/mach-at91/include/mach/sama5_bootsource.h
+++ b/arch/arm/mach-at91/include/mach/sama5_bootsource.h
@@ -52,6 +52,8 @@ static inline int sama5_bootsource_instance(u32 reg)
 #define __sama5d4_stashed_bootrom_r4 \
 	(*(volatile u32 *)(SAMA5D4_SRAM_BASE + SAMA5D4_SRAM_SIZE - 0x4))
 
+extern unsigned long at91_bootsource;
+
 static inline void __noreturn sama5_boot_xload(void __noreturn (*bb)(void), u32 r4)
 {
 	asm volatile("mov r4, %0" : : "r"(r4) : );
diff --git a/arch/arm/mach-at91/sama5_bootsource.c b/arch/arm/mach-at91/sama5_bootsource.c
new file mode 100644
index 000000000000..1cbfb4da7d95
--- /dev/null
+++ b/arch/arm/mach-at91/sama5_bootsource.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <mach/sama5_bootsource.h>
+#include <linux/export.h>
+#include <bootsource.h>
+#include <init.h>
+#include <of.h>
+
+/*
+ * sama5_bootsource_init - initialize bootsource
+ *
+ * BootROM will populate r4 when loading first stage bootloader
+ * with information about boot source. The entry points for
+ * multi-image capable SAMA5 boards will pass this information
+ * along. If you use a bootloader before barebox, you need to
+ * ensure that r4 is initialized for $bootsource to be correct
+ * in barebox. Example implementing it for AT91Bootstrap:
+ * https://github.com/linux4sam/at91bootstrap/pull/159
+ */
+static int sama5_bootsource_init(void)
+{
+	if (!of_machine_is_compatible("atmel,sama5"))
+		return 0;
+
+	at91_bootsource = __sama5d2_stashed_bootrom_r4;
+
+	if (at91_bootsource)
+		bootsource_set_raw(sama5_bootsource(at91_bootsource),
+				   sama5_bootsource_instance(at91_bootsource));
+
+	return 0;
+}
+postcore_initcall(sama5_bootsource_init);
diff --git a/arch/arm/mach-at91/sama5d2.c b/arch/arm/mach-at91/sama5d2.c
index b05d6a56bdd8..b0a04beb639e 100644
--- a/arch/arm/mach-at91/sama5d2.c
+++ b/arch/arm/mach-at91/sama5d2.c
@@ -6,7 +6,6 @@
 #include <mach/aic.h>
 #include <mach/sama5d2.h>
 #include <asm/cache-l2x0.h>
-#include <mach/sama5_bootsource.h>
 #include <asm/mmu.h>
 #include <mach/cpu.h>
 
@@ -54,17 +53,3 @@ static int sama5d2_init(void)
 	return 0;
 }
 postmmu_initcall(sama5d2_init);
-
-static int sama5d2_bootsource_init(void)
-{
-	if (!of_machine_is_compatible("atmel,sama5d2"))
-		return 0;
-
-	at91_bootsource = __sama5d2_stashed_bootrom_r4;
-
-	bootsource_set_raw(sama5_bootsource(at91_bootsource),
-			   sama5_bootsource_instance(at91_bootsource));
-
-	return 0;
-}
-postcore_initcall(sama5d2_bootsource_init);
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 8a21d8debcd5..3d49624cd5c1 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -403,6 +403,3 @@ void at91sam_phy_reset(void __iomem *rstc_base)
 	/* Restore NRST value */
 	writel(AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN, rstc_base + AT91_RSTC_MR);
 }
-
-unsigned long at91_bootsource;
-EXPORT_SYMBOL(at91_bootsource);
-- 
2.30.2




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

* Re: [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use
  2023-01-11 17:22 [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use Ahmad Fatoum
  2023-01-11 17:22 ` [PATCH v3 2/2] ARM: at91: make bootsource code generic to all SAMA5 Ahmad Fatoum
@ 2023-01-12 14:53 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-01-12 14:53 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Sam Ravnborg

On Wed, Jan 11, 2023 at 06:22:18PM +0100, Ahmad Fatoum wrote:
> The sama5d4[devices].c files are for non-OF instantiation of platform
> devices. We don't need anything out of these two files, so don't build
> them when compiling for CONFIG_AT91_MULTI_BOARDS. We use that instead of
> CONFIG_OFDEVICE, as sama5d4_xplained_defconfig and sama5d4ek_defconfig
> enable CONFIG_OFDEVICE, but probe no device at all from DT.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
>   - use CONFIG_AT91_MULTI_BOARDS instead of CONFIG_OFDEVICE to fix
>     sama5d4 non-DT defconfigs build failure
> 
> Sascha, please replace commit with same name in next with this.
> ---
>  arch/arm/mach-at91/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> index 390d49d03dee..f70e67bddebf 100644
> --- a/arch/arm/mach-at91/Makefile
> +++ b/arch/arm/mach-at91/Makefile
> @@ -27,9 +27,10 @@ obj-$(CONFIG_SOC_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o at91rm9200_device
>  obj-$(CONFIG_SOC_AT91SAM9260) += at91sam9260.o at91sam9260_devices.o
>  obj-$(CONFIG_SOC_AT91SAM9261) += at91sam9261.o at91sam9261_devices.o
>  obj-$(CONFIG_SOC_AT91SAM9G10) += at91sam9261.o at91sam9261_devices.o
> -ifeq ($(CONFIG_OFDEVICE),)
> +ifeq ($(CONFIG_AT91_MULTI_BOARDS),)
>  obj-$(CONFIG_SOC_AT91SAM9263) += at91sam9263.o at91sam9263_devices.o
>  obj-$(CONFIG_SOC_SAMA5D3)	+= sama5d3.o sama5d3_devices.o
> +obj-$(CONFIG_SOC_SAMA5D4)	+= sama5d4.o sama5d4_devices.o
>  endif
>  lwl-$(CONFIG_SOC_AT91SAM9263)	+= sam9263_ll.o
>  lwl-$(CONFIG_SOC_SAMA5D2)	+= sama5d2_ll.o
> @@ -39,4 +40,3 @@ obj-$(CONFIG_SOC_AT91SAM9G20) += at91sam9260.o at91sam9260_devices.o
>  obj-$(CONFIG_SOC_AT91SAM9G45) += at91sam9g45.o at91sam9g45_devices.o
>  obj-$(CONFIG_SOC_AT91SAM9X5)	+= at91sam9x5.o at91sam9x5_devices.o
>  obj-$(CONFIG_SOC_AT91SAM9N12)	+= at91sam9n12.o at91sam9n12_devices.o
> -obj-$(CONFIG_SOC_SAMA5D4)	+= sama5d4.o sama5d4_devices.o
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-01-12 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 17:22 [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use Ahmad Fatoum
2023-01-11 17:22 ` [PATCH v3 2/2] ARM: at91: make bootsource code generic to all SAMA5 Ahmad Fatoum
2023-01-12 14:53 ` [PATCH v3 1/2] ARM: at91: sama5d4: enable for DT use Sascha Hauer

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