Skip to contentSkip to conversation

at91:: Remove dead definition of atmel_nand_load_image()

PATCH Applied Alexander Shiyan 2 participants 7 messages Mar 5, 2025 – Mar 7, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 at91:: Remove dead definition of atmel_nand_load_image()

atmel_nand_load_image() is not defined anywhere.

---
 include/mach/at91/board.h | 2 --
 1 file changed, 2 deletions(-)
include/mach/at91/board.h +0 -2
index 5f04f9c849..7edadeafba 100644
@@ -31,8 +31,6 @@ struct at91_usbh_data {
 extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
 extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data);
 
-void atmel_nand_load_image(void *dest, int size, int pagesize, int blocksize);
-
  /* USB Device */
 struct at91_udc_data {
 	int	vbus_pin;		/* high == host powering us */
Signature · 1 line
2.39.1
#1 lore raw

PATCH 2/4 at91: Use the ddramc driver for all boards whose architecture uses it

Reuse ddramc driver for all SAMA5D2/3/4 boards.

---
 arch/arm/boards/sama5d4_xplained/lowlevel.c |  4 ++--
 arch/arm/mach-at91/ddramc.c                 |  4 ++--
 arch/arm/mach-at91/sama5d3_devices.c        |  7 +++----
 arch/arm/mach-at91/sama5d4_devices.c        |  7 +++----
 include/mach/at91/at91_ddrsdrc.h            | 11 -----------
 5 files changed, 10 insertions(+), 23 deletions(-)
arch/arm/boards/sama5d4_xplained/lowlevel.c +2 -2
index 183bd9c5a9..5763333f39 100644
@@ -10,7 +10,7 @@
 #include <asm/barebox-arm-head.h>
 #include <asm/barebox-arm.h>
 
-#include <mach/at91/at91_ddrsdrc.h>
+#include <mach/at91/ddramc.h>
 #include <mach/at91/hardware.h>
 
 void __naked __bare_init barebox_arm_reset_vector(uint32_t r0, uint32_t r1, uint32_t r2)
@@ -19,5 +19,5 @@ void __naked __bare_init barebox_arm_reset_vector(uint32_t r0, uint32_t r1, uint
 
 	arm_setup_stack(SAMA5D4_SRAM_BASE + SAMA5D4_SRAM_SIZE);
 
-	barebox_arm_entry(SAMA5_DDRCS, at91sama5d4_get_ddram_size(), NULL);
+	sama5d4_barebox_entry(0, NULL);
 }
arch/arm/mach-at91/ddramc.c +2 -2
index 4d0637b487..ca77889ecc 100644
@@ -30,14 +30,14 @@ void __noreturn sama5d3_barebox_entry(unsigned int r4, void *boarddata)
 {
 	__sama5d3_stashed_bootrom_r4 = r4;
 
-	barebox_arm_entry(SAMA5_DDRCS, at91sama5d3_get_ddram_size(),
+	barebox_arm_entry(SAMA5_DDRCS, sama5_ramsize(IOMEM(SAMA5D3_BASE_MPDDRC)),
 			  boarddata);
 }
 void __noreturn sama5d4_barebox_entry(unsigned int r4, void *boarddata)
 {
 	__sama5d4_stashed_bootrom_r4 = r4;
 
-	barebox_arm_entry(SAMA5_DDRCS, at91sama5d4_get_ddram_size(),
+	barebox_arm_entry(SAMA5_DDRCS, sama5_ramsize(IOMEM(SAMA5D4_BASE_MPDDRC)),
 			  boarddata);
 }
 
arch/arm/mach-at91/sama5d3_devices.c +3 -4
index f6d5617e5f..4871c2bd69 100644
@@ -21,10 +21,9 @@
 
 void at91_add_device_sdram(u32 size)
 {
-	if (!size)
-		size = at91sama5d3_get_ddram_size();
-
-	arm_add_mem_device("ram0", SAMA5_DDRCS, size);
+	add_generic_device("sama5-ddramc", DEVICE_ID_SINGLE, NULL,
+			   SAMA5D3_BASE_MPDDRC, SZ_512,
+			   IORESOURCE_MEM, NULL);
 	add_mem_device("sram0", SAMA5D3_SRAM_BASE,
 			SAMA5D3_SRAM_SIZE, IORESOURCE_MEM_WRITEABLE);
 }
arch/arm/mach-at91/sama5d4_devices.c +3 -4
index e438bd0d10..4a81e7cd40 100644
@@ -21,10 +21,9 @@
 
 void at91_add_device_sdram(u32 size)
 {
-	if (!size)
-		size = at91sama5d4_get_ddram_size();
-
-	arm_add_mem_device("ram0", SAMA5_DDRCS, size);
+	add_generic_device("sama5-ddramc", DEVICE_ID_SINGLE, NULL,
+			   SAMA5D4_BASE_MPDDRC, SZ_512,
+			   IORESOURCE_MEM, NULL);
 	add_mem_device("sram0", SAMA5D4_SRAM_BASE,
 		       SAMA5D4_SRAM_SIZE, IORESOURCE_MEM_WRITEABLE);
 }
include/mach/at91/at91_ddrsdrc.h +0 -11
index b9b0eb20b3..d511e157b2 100644
@@ -357,17 +357,6 @@ static inline u32 at91sam9n12_get_ddram_size(void)
 	return at91_get_ddram_size(IOMEM(AT91SAM9N12_BASE_DDRSDRC0), true);
 }
 
-static inline u32 at91sama5d3_get_ddram_size(void)
-{
-	return at91_get_ddram_size(IOMEM(SAMA5D3_BASE_MPDDRC), true);
-}
-
-static inline u32 at91sama5d4_get_ddram_size(void)
-{
-	return at91_get_ddram_size(IOMEM(SAMA5D4_BASE_MPDDRC), true);
-}
-
-
 #endif /* __ASSEMBLY__ */
 
 #endif	/* #ifndef __AT91_DDRSDRC_H__ */
Signature · 1 line
2.39.1
#2 lore raw

Re: [PATCH 2/4] at91: Use the ddramc driver for all boards whose architecture uses it

Quoted 36 lines · Alexander Shiyan

Reuse ddramc driver for all SAMA5D2/3/4 boards.

---
 arch/arm/boards/sama5d4_xplained/lowlevel.c |  4 ++--
 arch/arm/mach-at91/ddramc.c                 |  4 ++--
 arch/arm/mach-at91/sama5d3_devices.c        |  7 +++----
 arch/arm/mach-at91/sama5d4_devices.c        |  7 +++----
 include/mach/at91/at91_ddrsdrc.h            | 11 -----------
 5 files changed, 10 insertions(+), 23 deletions(-)
arch/arm/boards/sama5d4_xplained/lowlevel.c +2 -2
index 183bd9c5a9..5763333f39 100644
@@ -10,7 +10,7 @@
 #include <asm/barebox-arm-head.h>
 #include <asm/barebox-arm.h>
 
-#include <mach/at91/at91_ddrsdrc.h>
+#include <mach/at91/ddramc.h>
 #include <mach/at91/hardware.h>
 
 void __naked __bare_init barebox_arm_reset_vector(uint32_t r0, uint32_t r1, uint32_t r2)
@@ -19,5 +19,5 @@ void __naked __bare_init barebox_arm_reset_vector(uint32_t r0, uint32_t r1, uint
 
 	arm_setup_stack(SAMA5D4_SRAM_BASE + SAMA5D4_SRAM_SIZE);
 
-	barebox_arm_entry(SAMA5_DDRCS, at91sama5d4_get_ddram_size(), NULL);
+	sama5d4_barebox_entry(0, NULL);
 }
arch/arm/mach-at91/ddramc.c +0 -0
index 4d0637b487..ca77889ecc 100644

arch/arm/mach-at91/ddramc.c void __noreturn sama5d3_barebox_entry(unsigned int r4, void *boarddata) · line 34

Quoted 6 lines
arch/arm/mach-at91/ddramc.c +1 -1
@@ -30,14 +30,14 @@ void __noreturn sama5d3_barebox_entry(unsigned int r4, void *boarddata)
 {
 	__sama5d3_stashed_bootrom_r4 = r4;
 
-	barebox_arm_entry(SAMA5_DDRCS, at91sama5d3_get_ddram_size(),
+	barebox_arm_entry(SAMA5_DDRCS, sama5_ramsize(IOMEM(SAMA5D3_BASE_MPDDRC)),
 			  boarddata);

I like it better to have a at91sama5d3_get_ddram_size() because with that you don't have to worry about the base address, but only need to call for the correct SoC.

Quoted 15 lines
arch/arm/mach-at91/ddramc.c +1 -1
 }
 void __noreturn sama5d4_barebox_entry(unsigned int r4, void *boarddata)
 {
 	__sama5d4_stashed_bootrom_r4 = r4;
 
-	barebox_arm_entry(SAMA5_DDRCS, at91sama5d4_get_ddram_size(),
+	barebox_arm_entry(SAMA5_DDRCS, sama5_ramsize(IOMEM(SAMA5D4_BASE_MPDDRC)),
 			  boarddata);
 }
 
arch/arm/mach-at91/sama5d3_devices.c +0 -0
index f6d5617e5f..4871c2bd69 100644

arch/arm/mach-at91/sama5d3_devices.c line 26

Quoted 10 lines
arch/arm/mach-at91/sama5d3_devices.c +3 -4
@@ -21,10 +21,9 @@
 
 void at91_add_device_sdram(u32 size)
 {
-	if (!size)
-		size = at91sama5d3_get_ddram_size();
-
-	arm_add_mem_device("ram0", SAMA5_DDRCS, size);
+	add_generic_device("sama5-ddramc", DEVICE_ID_SINGLE, NULL,
+			   SAMA5D3_BASE_MPDDRC, SZ_512,
+			   IORESOURCE_MEM, NULL);

Is this necessary? I just merged your patch that says that all SAMA5D3 boards are merged to device tree. The device tree already has a "atmel,sama5d3-ddramc" node, so there shouldn't be a need to create the device here again.

Sascha

Quoted 48 lines
arch/arm/mach-at91/sama5d3_devices.c +0 -0
 	add_mem_device("sram0", SAMA5D3_SRAM_BASE,
 			SAMA5D3_SRAM_SIZE, IORESOURCE_MEM_WRITEABLE);
 }
arch/arm/mach-at91/sama5d4_devices.c +3 -4
index e438bd0d10..4a81e7cd40 100644
@@ -21,10 +21,9 @@
 
 void at91_add_device_sdram(u32 size)
 {
-	if (!size)
-		size = at91sama5d4_get_ddram_size();
-
-	arm_add_mem_device("ram0", SAMA5_DDRCS, size);
+	add_generic_device("sama5-ddramc", DEVICE_ID_SINGLE, NULL,
+			   SAMA5D4_BASE_MPDDRC, SZ_512,
+			   IORESOURCE_MEM, NULL);
 	add_mem_device("sram0", SAMA5D4_SRAM_BASE,
 		       SAMA5D4_SRAM_SIZE, IORESOURCE_MEM_WRITEABLE);
 }
include/mach/at91/at91_ddrsdrc.h +0 -11
index b9b0eb20b3..d511e157b2 100644
@@ -357,17 +357,6 @@ static inline u32 at91sam9n12_get_ddram_size(void)
 	return at91_get_ddram_size(IOMEM(AT91SAM9N12_BASE_DDRSDRC0), true);
 }
 
-static inline u32 at91sama5d3_get_ddram_size(void)
-{
-	return at91_get_ddram_size(IOMEM(SAMA5D3_BASE_MPDDRC), true);
-}
-
-static inline u32 at91sama5d4_get_ddram_size(void)
-{
-	return at91_get_ddram_size(IOMEM(SAMA5D4_BASE_MPDDRC), true);
-}
-
-
 #endif /* __ASSEMBLY__ */
 
 #endif	/* #ifndef __AT91_DDRSDRC_H__ */
Signature · 1 line
2.39.1
Signature · 4 lines
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 |
#3 lore raw

Re: [PATCH 2/4] at91: Use the ddramc driver for all boards whose architecture uses it

Hello.

Quoted 6 lines
Quoted 6 lines
arch/arm/mach-at91/sama5d3_devices.c +0 -0
index f6d5617e5f..4871c2bd69 100644
@@ -21,10 +21,9 @@
 
Quoted 14 lines

arch/arm/mach-at91/sama5d3_devices.c line 26

Quoted 9 lines
arch/arm/mach-at91/sama5d3_devices.c +3 -4
 void at91_add_device_sdram(u32 size)
 {
-     if (!size)
-             size = at91sama5d3_get_ddram_size();
-
-     arm_add_mem_device("ram0", SAMA5_DDRCS, size);
+     add_generic_device("sama5-ddramc", DEVICE_ID_SINGLE, NULL,
+                        SAMA5D3_BASE_MPDDRC, SZ_512,
+                        IORESOURCE_MEM, NULL);

Is this necessary? I just merged your patch that says that all SAMA5D3 boards are merged to device tree. The device tree already has a "atmel,sama5d3-ddramc" node, so there shouldn't be a need to create the device here again.

This series was created before I realized that board files for SAMA5D3 can be deleted completely. In general, in this case it is a patch race :)

Thanks!

#4 lore raw

PATCH 3/4 at91: ddramc: Trivial code cleanup

In reply to Alexander Shiyan

Trivial code cleanup, which includes:
- Adding/removing blank lines for better code readability.
- Wrapping the of_compatible driver property in DRV_OF_COMPAT().

---
 arch/arm/mach-at91/ddramc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm/mach-at91/ddramc.c +4 -3
index ca77889ecc..ffedd39d6b 100644
@@ -22,6 +22,7 @@ static unsigned sama5_ramsize(void __iomem *base)
 void __noreturn sama5d2_barebox_entry(unsigned int r4, void *boarddata)
 {
 	__sama5d2_stashed_bootrom_r4 = r4;
+
 	barebox_arm_entry(SAMA5_DDRCS, sama5_ramsize(SAMA5D2_BASE_MPDDRC),
 			  boarddata);
 }
@@ -33,6 +34,7 @@ void __noreturn sama5d3_barebox_entry(unsigned int r4, void *boarddata)
 	barebox_arm_entry(SAMA5_DDRCS, sama5_ramsize(IOMEM(SAMA5D3_BASE_MPDDRC)),
 			  boarddata);
 }
+
 void __noreturn sama5d4_barebox_entry(unsigned int r4, void *boarddata)
 {
 	__sama5d4_stashed_bootrom_r4 = r4;
@@ -54,7 +56,7 @@ static int sama5_ddr_probe(struct device *dev)
 	return arm_add_mem_device("ram0", SAMA5_DDRCS, sama5_ramsize(base));
 }
 
-static struct of_device_id sama5_ddr_dt_ids[] = {
+static __maybe_unused struct of_device_id sama5_ddr_dt_ids[] = {
 	{ .compatible = "atmel,sama5d3-ddramc" },
 	{ /* sentinel */ }
 };
@@ -63,7 +65,6 @@ MODULE_DEVICE_TABLE(of, sama5_ddr_dt_ids);
 static struct driver sama5_ddr_driver = {
 	.name   = "sama5-ddramc",
 	.probe  = sama5_ddr_probe,
-	.of_compatible = sama5_ddr_dt_ids,
+	.of_compatible = DRV_OF_COMPAT(sama5_ddr_dt_ids),
 };
-
 mem_platform_driver(sama5_ddr_driver);
Signature · 1 line
2.39.1
#5 lore raw

PATCH 4/4 at91: Use proper values of stashed SAMA5D2/3/4 bootsource

In reply to Alexander Shiyan

Since the SRAM area varies across different processor variants, let's make a distinction for stashed bootsource recovery.

---
 arch/arm/mach-at91/sama5_bootsource.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm/mach-at91/sama5_bootsource.c +7 -3
index 4ede256e8f..0d91f5fb5a 100644
@@ -19,11 +19,15 @@
  */
 static int sama5_bootsource_init(void)
 {
-	if (!of_machine_is_compatible("atmel,sama5"))
+	if (of_machine_is_compatible("atmel,sama5d2"))
+		at91_bootsource = __sama5d2_stashed_bootrom_r4;
+	else if (of_machine_is_compatible("atmel,sama5d3"))
+		at91_bootsource = __sama5d3_stashed_bootrom_r4;
+	else if (of_machine_is_compatible("atmel,sama5d4"))
+		at91_bootsource = __sama5d4_stashed_bootrom_r4;
+	else
 		return 0;
 
-	at91_bootsource = __sama5d2_stashed_bootrom_r4;
-
 	if (at91_bootsource)
 		bootsource_set_raw(sama5_bootsource(at91_bootsource),
 				   sama5_bootsource_instance(at91_bootsource));
Signature · 1 line
2.39.1
Applied
#6 lore raw

Re: (subset) [PATCH 1/4] at91:: Remove dead definition of atmel_nand_load_image()

In reply to Alexander Shiyan
Quoted 3 lines · Alexander Shiyan

atmel_nand_load_image() is not defined anywhere.

Applied, thanks!

[1/4] at91:: Remove dead definition of atmel_nand_load_image()
https://git.pengutronix.de/cgit/barebox/commit/?id=b4f53ca046e0 (link may not be stable)
[3/4] at91: ddramc: Trivial code cleanup
https://git.pengutronix.de/cgit/barebox/commit/?id=94bb3615d786 (link may not be stable)
[4/4] at91: Use proper values of stashed SAMA5D2/3/4 bootsource
https://git.pengutronix.de/cgit/barebox/commit/?id=b70ae92dda7a (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>