summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2021-04-23 16:28:25 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-05-12 07:56:30 +0200
commite30fb46597d308e62af561d91524a5d8b4a46e5a (patch)
tree4d882fd2556ddddfc7691a94d78daf2497c30bb7 /arch/arm/mach-at91
parent931dbaf438b6afc4359b16f79a0b837738702560 (diff)
downloadbarebox-e30fb46597d308e62af561d91524a5d8b4a46e5a.tar.gz
barebox-e30fb46597d308e62af561d91524a5d8b4a46e5a.tar.xz
ARM: at91: xload-mmc: add sama5d3_atmci_start_image() helper
This helper should be called from the xloader Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20210423142829.29468-3-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r--arch/arm/mach-at91/Kconfig2
-rw-r--r--arch/arm/mach-at91/include/mach/xload.h2
-rw-r--r--arch/arm/mach-at91/xload-mmc.c51
3 files changed, 55 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 810c00d495..28a82c1a93 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -45,6 +45,7 @@ config HAVE_AT91_DDRAMC
config AT91_MCI_PBL
bool
+ depends on MCI_ATMEL_PBL
depends on MCI_ATMEL_SDHCI_PBL
default y
@@ -610,6 +611,7 @@ config MACH_MICROCHIP_KSZ9477_EVB
bool "Microchip EVB-KSZ9477 Evaluation Kit"
select SOC_SAMA5D3
select OFDEVICE
+ select MCI_ATMEL_PBL
select COMMON_CLK_OF_PROVIDER
help
Select this if you are using Microchip's EVB-KSZ9477 Evaluation Kit.
diff --git a/arch/arm/mach-at91/include/mach/xload.h b/arch/arm/mach-at91/include/mach/xload.h
index 9201e7d0b7..bbc70af210 100644
--- a/arch/arm/mach-at91/include/mach/xload.h
+++ b/arch/arm/mach-at91/include/mach/xload.h
@@ -5,6 +5,8 @@
#include <pbl.h>
void __noreturn sama5d2_sdhci_start_image(u32 r4);
+void __noreturn sama5d3_atmci_start_image(u32 r4, unsigned int clock,
+ unsigned int slot);
int at91_sdhci_bio_init(struct pbl_bio *bio, void __iomem *base);
int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
diff --git a/arch/arm/mach-at91/xload-mmc.c b/arch/arm/mach-at91/xload-mmc.c
index e9edeccb7f..8d4f653d1e 100644
--- a/arch/arm/mach-at91/xload-mmc.c
+++ b/arch/arm/mach-at91/xload-mmc.c
@@ -3,6 +3,7 @@
#include <mach/sama5_bootsource.h>
#include <mach/hardware.h>
#include <mach/sama5d2_ll.h>
+#include <mach/sama5d3_ll.h>
#include <mach/gpio.h>
#include <linux/sizes.h>
#include <asm/cache.h>
@@ -82,3 +83,53 @@ void __noreturn sama5d2_sdhci_start_image(u32 r4)
out_panic:
panic("FAT chainloading failed\n");
}
+
+static const struct atmci_instance {
+ void __iomem *base;
+ unsigned id;
+ u8 periph;
+ s8 pins[15];
+} sama5d3_atmci_instances[] = {
+ [0] = {
+ .base = IOMEM(SAMA5D3_BASE_HSMCI0),
+ .id = SAMA5D3_ID_HSMCI0,
+ .periph = AT91_MUX_PERIPH_A,
+ .pins = {
+ AT91_PIN_PD0, AT91_PIN_PD1, AT91_PIN_PD2, AT91_PIN_PD3,
+ AT91_PIN_PD4, AT91_PIN_PD5, AT91_PIN_PD6, AT91_PIN_PD7,
+ AT91_PIN_PD8, AT91_PIN_PD9, -1 }
+ },
+};
+
+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;
+ struct pbl_bio bio;
+ const s8 *pin;
+ int ret;
+
+ ret = sama5_bootsource_instance(boot_src);
+ if (ret > ARRAY_SIZE(sama5d3_atmci_instances) - 1)
+ panic("Couldn't determine boot MCI instance\n");
+
+ instance = &sama5d3_atmci_instances[boot_src];
+
+ sama5d3_pmc_enable_periph_clock(SAMA5D2_ID_PIOD);
+ for (pin = instance->pins; *pin >= 0; pin++) {
+ at91_mux_pio3_pin(IOMEM(SAMA5D3_BASE_PIOD),
+ pin_to_mask(*pin), instance->periph, 0);
+ }
+
+ sama5d3_pmc_enable_periph_clock(instance->id);
+
+ ret = at91_mci_bio_init(&bio, instance->base, clock, slot);
+ if (ret)
+ goto out_panic;
+
+ at91_fat_start_image(&bio, buf, SZ_16M, boot_src);
+
+out_panic:
+ panic("FAT chainloading failed\n");
+}