mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/7] ARM: at91: xload: Unify loader functions to use a single xload_instance structure
@ 2025-03-20  9:14 Alexander Shiyan
  2025-03-20  9:14 ` [PATCH 2/7] ARM: at91: xload: Replace magic values with definitions Alexander Shiyan
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Alexander Shiyan @ 2025-03-20  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

The loader function structures use the same members,
so they can be rewritten to use a single xload_instance structure.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 arch/arm/mach-at91/xload.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-at91/xload.c b/arch/arm/mach-at91/xload.c
index 9c03d2119c..4e7e80379f 100644
--- a/arch/arm/mach-at91/xload.c
+++ b/arch/arm/mach-at91/xload.c
@@ -11,6 +11,13 @@
 #include <asm/cache.h>
 #include <pbl/bio.h>
 
+struct xload_instance {
+	void __iomem *base;
+	unsigned id;
+	u8 periph;
+	s8 pins[15];
+};
+
 static void at91_fat_start_image(struct pbl_bio *bio,
 				 void *buf, unsigned int len,
 				 u32 r4)
@@ -31,12 +38,7 @@ static void at91_fat_start_image(struct pbl_bio *bio,
 	sama5_boot_xload(bb, r4);
 }
 
-static const struct sdhci_instance {
-	void __iomem *base;
-	unsigned id;
-	u8 periph;
-	s8 pins[15];
-} sdhci_instances[] = {
+static const struct xload_instance sama5d2_mci_instances[] = {
 	[0] = {
 		.base = SAMA5D2_BASE_SDHC0, .id = SAMA5D2_ID_SDMMC0, .periph = AT91_MUX_PERIPH_A,
 		.pins = { 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 13, 10, 11, 12, -1 }
@@ -54,16 +56,16 @@ static const struct sdhci_instance {
 void __noreturn sama5d2_sdhci_start_image(u32 r4)
 {
 	void *buf = (void *)SAMA5_DDRCS;
-	const struct sdhci_instance *instance;
+	const struct xload_instance *instance;
 	struct pbl_bio bio;
 	const s8 *pin;
 	int ret;
 
 	ret = sama5_bootsource_instance(r4);
-	if (ret > 1)
+	if (ret > ARRAY_SIZE(sama5d2_mci_instances) - 1)
 		panic("Couldn't determine boot MCI instance\n");
 
-	instance = &sdhci_instances[ret];
+	instance = &sama5d2_mci_instances[ret];
 
 	sama5d2_pmc_enable_periph_clock(SAMA5D2_ID_PIOA);
 	for (pin = instance->pins; *pin >= 0; pin++) {
@@ -86,12 +88,7 @@ void __noreturn sama5d2_sdhci_start_image(u32 r4)
 	panic("FAT chainloading failed\n");
 }
 
-static const struct atmci_instance {
-	void __iomem *base;
-	unsigned id;
-	u8 periph;
-	s8 pins[15];
-} sama5d3_atmci_instances[] = {
+static const struct xload_instance sama5d3_mci_instances[] = {
 	[0] = {
 		.base = IOMEM(SAMA5D3_BASE_HSMCI0),
 		.id = SAMA5D3_ID_HSMCI0,
@@ -107,16 +104,16 @@ void __noreturn sama5d3_atmci_start_image(u32 boot_src, unsigned int clock,
 					  unsigned int slot)
 {
 	void *buf = (void *)SAMA5_DDRCS;
-	const struct atmci_instance *instance;
+	const struct xload_instance *instance;
 	struct pbl_bio bio;
 	const s8 *pin;
 	int ret;
 
 	ret = sama5_bootsource_instance(boot_src);
-	if (ret > ARRAY_SIZE(sama5d3_atmci_instances) - 1)
+	if (ret > ARRAY_SIZE(sama5d3_mci_instances) - 1)
 		panic("Couldn't determine boot MCI instance\n");
 
-	instance = &sama5d3_atmci_instances[boot_src];
+	instance = &sama5d3_mci_instances[boot_src];
 
 	sama5d3_pmc_enable_periph_clock(SAMA5D3_ID_PIOD);
 	for (pin = instance->pins; *pin >= 0; pin++) {
-- 
2.39.1




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

end of thread, other threads:[~2025-03-20 12:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-20  9:14 [PATCH 1/7] ARM: at91: xload: Unify loader functions to use a single xload_instance structure Alexander Shiyan
2025-03-20  9:14 ` [PATCH 2/7] ARM: at91: xload: Replace magic values with definitions Alexander Shiyan
2025-03-20  9:14 ` [PATCH 3/7] ARM: at91: xload: Remove len argument from at91_fat_start_image() Alexander Shiyan
2025-03-20  9:14 ` [PATCH 4/7] ARM: at91: xload: Use the variable name as described in include/mach/at91/xload.h Alexander Shiyan
2025-03-20  9:14 ` [PATCH 5/7] ARM: at91: xload: Remove intermediate variable Alexander Shiyan
2025-03-20  9:14 ` [PATCH 6/7] ARM: at91: xload: Rename the sama5d2 output image names Alexander Shiyan
2025-03-20  9:14 ` [PATCH 7/7] ARM: at91: xload: Add QSPI boot support for SAMA5D2 Alexander Shiyan
2025-03-20 11:45 ` [PATCH 1/7] ARM: at91: xload: Unify loader functions to use a single xload_instance structure Sascha Hauer

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