summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-10-14 14:19:01 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-10-14 15:28:35 +0200
commit8bfb1852cf6ad9b2193bc7d0dbdae67e0553361a (patch)
treedcf5fc5818ad20e5d1b55cf9ed8a43576949949e /arch/arm/boards
parent0b149ef38a54b5a6ce007e9146dea384cf32c8a7 (diff)
downloadbarebox-8bfb1852cf6ad9b2193bc7d0dbdae67e0553361a.tar.gz
barebox-8bfb1852cf6ad9b2193bc7d0dbdae67e0553361a.tar.xz
ARM: at91: add basic sama5d2-som1-ek1 support
The ATSAMA5D27-SOM1-EK1 is Microchip's evaluation kit for the SAMA5D2 System in Packages (SiPs). The ATSAMA5D27C-D1G-CU SIP embeds 128 MB of DDR2 DRAM and the SoM has a PMIC, QSPI flash and a 100Mbps PHY. barebox already supports the sama5d2 clocks, GPIO/Pinctrl, QSPI controller and Ethernet MAC. Most notable omission is the sama5d2 variant of the SDHCI, which differs from the MCI used by previous AT91 boards, but we kernel boot over the network works, so lets add the board now and have the SDHCI follow later. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/boards')
-rw-r--r--arch/arm/boards/Makefile1
-rw-r--r--arch/arm/boards/sama5d27-som1/Makefile1
-rw-r--r--arch/arm/boards/sama5d27-som1/lowlevel.c81
3 files changed, 83 insertions, 0 deletions
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index a814ab8239..7d2023624f 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -112,6 +112,7 @@ obj-$(CONFIG_MACH_RPI_COMMON) += raspberry-pi/
obj-$(CONFIG_MACH_SABRELITE) += freescale-mx6-sabrelite/
obj-$(CONFIG_MACH_SABRESD) += freescale-mx6-sabresd/
obj-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += freescale-mx6sx-sabresdb/
+obj-$(CONFIG_MACH_SAMA5D27_SOM1) += sama5d27-som1/
obj-$(CONFIG_MACH_SAMA5D3XEK) += sama5d3xek/
obj-$(CONFIG_MACH_SAMA5D3_XPLAINED) += sama5d3_xplained/
obj-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += microchip-ksz9477-evb/
diff --git a/arch/arm/boards/sama5d27-som1/Makefile b/arch/arm/boards/sama5d27-som1/Makefile
new file mode 100644
index 0000000000..b08c4a93ca
--- /dev/null
+++ b/arch/arm/boards/sama5d27-som1/Makefile
@@ -0,0 +1 @@
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/sama5d27-som1/lowlevel.c b/arch/arm/boards/sama5d27-som1/lowlevel.c
new file mode 100644
index 0000000000..7df5a4772d
--- /dev/null
+++ b/arch/arm/boards/sama5d27-som1/lowlevel.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Ahmad Fatoum, Pengutronix
+ */
+
+#include <common.h>
+#include <init.h>
+
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+#include <mach/at91_pmc_ll.h>
+
+#include <mach/hardware.h>
+#include <mach/iomux.h>
+#include <debug_ll.h>
+#include <mach/at91_dbgu.h>
+
+#define RGB_LED_GREEN (1 << 0)
+#define RGB_LED_RED (1 << 1)
+#define RGB_LED_BLUE (1 << 2)
+
+/* PCK = 492MHz, MCK = 164MHz */
+#define MASTER_CLOCK 164000000
+
+#define sama5d2_pmc_enable_periph_clock(clk) \
+ at91_pmc_sam9x5_enable_periph_clock(IOMEM(SAMA5D2_BASE_PMC), clk)
+
+static void ek_turn_led(unsigned color)
+{
+ struct {
+ unsigned long pio;
+ unsigned bit;
+ unsigned color;
+ } *led, leds[] = {
+ { .pio = SAMA5D2_BASE_PIOA, .bit = 10, .color = color & RGB_LED_RED },
+ { .pio = SAMA5D2_BASE_PIOB, .bit = 1, .color = color & RGB_LED_GREEN },
+ { .pio = SAMA5D2_BASE_PIOA, .bit = 31, .color = color & RGB_LED_BLUE },
+ { /* sentinel */ },
+ };
+
+ for (led = leds; led->pio; led++) {
+ at91_mux_gpio4_enable(IOMEM(led->pio), BIT(led->bit));
+ at91_mux_gpio4_input(IOMEM(led->pio), BIT(led->bit), false);
+ at91_mux_gpio4_set(IOMEM(led->pio), BIT(led->bit), led->color);
+ }
+}
+
+static void ek_dbgu_init(void)
+{
+ unsigned mck = MASTER_CLOCK / 2;
+
+ sama5d2_pmc_enable_periph_clock(SAMA5D2_ID_PIOD);
+
+ at91_mux_pio4_set_A_periph(IOMEM(SAMA5D2_BASE_PIOD),
+ pin_to_mask(AT91_PIN_PD3)); /* DBGU TXD */
+
+ sama5d2_pmc_enable_periph_clock(SAMA5D2_ID_UART1);
+
+ at91_dbgu_setup_ll(IOMEM(SAMA5D2_BASE_UART1), mck, 115200);
+
+ putc_ll('>');
+}
+
+extern char __dtb_z_at91_sama5d27_som1_ek_start[];
+
+ENTRY_FUNCTION(start_sama5d27_som1_ek, r0, r1, r2)
+{
+ void *fdt;
+
+ arm_cpu_lowlevel_init();
+
+ arm_setup_stack(SAMA5D2_SRAM_BASE + SAMA5D2_SRAM_SIZE - 16);
+
+ if (IS_ENABLED(CONFIG_DEBUG_LL))
+ ek_dbgu_init();
+
+ fdt = __dtb_z_at91_sama5d27_som1_ek_start + get_runtime_offset();
+
+ ek_turn_led(RGB_LED_GREEN);
+ barebox_arm_entry(SAMA5_DDRCS, SZ_128M, fdt);
+}