mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH 2/4] at91: Use the ddramc driver for all boards whose architecture uses it
Date: Wed,  5 Mar 2025 09:20:59 +0300	[thread overview]
Message-ID: <20250305062101.25588-2-eagle.alexander923@gmail.com> (raw)
In-Reply-To: <20250305062101.25588-1-eagle.alexander923@gmail.com>

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

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 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(-)

diff --git a/arch/arm/boards/sama5d4_xplained/lowlevel.c b/arch/arm/boards/sama5d4_xplained/lowlevel.c
index 183bd9c5a9..5763333f39 100644
--- a/arch/arm/boards/sama5d4_xplained/lowlevel.c
+++ b/arch/arm/boards/sama5d4_xplained/lowlevel.c
@@ -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);
 }
diff --git a/arch/arm/mach-at91/ddramc.c b/arch/arm/mach-at91/ddramc.c
index 4d0637b487..ca77889ecc 100644
--- a/arch/arm/mach-at91/ddramc.c
+++ b/arch/arm/mach-at91/ddramc.c
@@ -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);
 }
 
diff --git a/arch/arm/mach-at91/sama5d3_devices.c b/arch/arm/mach-at91/sama5d3_devices.c
index f6d5617e5f..4871c2bd69 100644
--- a/arch/arm/mach-at91/sama5d3_devices.c
+++ b/arch/arm/mach-at91/sama5d3_devices.c
@@ -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);
 }
diff --git a/arch/arm/mach-at91/sama5d4_devices.c b/arch/arm/mach-at91/sama5d4_devices.c
index e438bd0d10..4a81e7cd40 100644
--- a/arch/arm/mach-at91/sama5d4_devices.c
+++ b/arch/arm/mach-at91/sama5d4_devices.c
@@ -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);
 }
diff --git a/include/mach/at91/at91_ddrsdrc.h b/include/mach/at91/at91_ddrsdrc.h
index b9b0eb20b3..d511e157b2 100644
--- a/include/mach/at91/at91_ddrsdrc.h
+++ b/include/mach/at91/at91_ddrsdrc.h
@@ -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__ */
-- 
2.39.1




  reply	other threads:[~2025-03-05  6:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05  6:20 [PATCH 1/4] at91:: Remove dead definition of atmel_nand_load_image() Alexander Shiyan
2025-03-05  6:20 ` Alexander Shiyan [this message]
2025-03-07  8:18   ` [PATCH 2/4] at91: Use the ddramc driver for all boards whose architecture uses it Sascha Hauer
2025-03-07  8:24     ` Alexander Shiyan
2025-03-05  6:21 ` [PATCH 3/4] at91: ddramc: Trivial code cleanup Alexander Shiyan
2025-03-05  6:21 ` [PATCH 4/4] at91: Use proper values of stashed SAMA5D2/3/4 bootsource Alexander Shiyan
2025-03-07  8:20 ` (subset) [PATCH 1/4] at91:: Remove dead definition of atmel_nand_load_image() Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250305062101.25588-2-eagle.alexander923@gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox