diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index a814ab8..7d20236 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -112,6 +112,7 @@ 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 0000000..b08c4a9 --- /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 0000000..7df5a47 --- /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 +#include + +#include +#include +#include + +#include +#include +#include +#include + +#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); +} diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index f33e6a4..097ea2a 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -135,6 +135,7 @@ vf610-zii-ssmb-dtu.dtb.o pbl-dtb-$(CONFIG_MACH_AT91SAM9263EK_DT) += at91sam9263ek.dtb.o pbl-dtb-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += at91-microchip-ksz9477-evb.dtb.o +pbl-dtb-$(CONFIG_MACH_SAMA5D27_SOM1) += at91-sama5d27_som1_ek.dtb.o pbl-dtb-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek.dtb.o pbl-dtb-$(CONFIG_MACH_XILINX_ZCU104) += zynqmp-zcu104-revA.dtb.o diff --git a/arch/arm/dts/at91-sama5d27_som1_ek.dts b/arch/arm/dts/at91-sama5d27_som1_ek.dts new file mode 100644 index 0000000..936f07e --- /dev/null +++ b/arch/arm/dts/at91-sama5d27_som1_ek.dts @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 OR X11 +/* + * Copyright (C) 2019 Oleksij Rempel - Pengutronix + */ + +#include + +/ { + chosen { + environment { + compatible = "barebox,environment"; + device-path = &barebox_env; + }; + }; + + memory { + reg = <0x20000000 0x8000000>; + }; +}; + +&qspi1 { + flash@0 { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "barebox"; + reg = <0x0 0x80000>; + }; + + barebox_env: partition@80000 { + label = "barebox-environment"; + reg = <0x80000 0x80000>; + }; + }; +}; diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 6be9bf6..ef00e32 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -573,6 +573,14 @@ help Select this if you are using Microchip's EVB-KSZ9477 Evaluation Kit. +config MACH_SAMA5D27_SOM1 + bool "Microchip SAMA5D27 SoM-1 Evaluation Kit" + select SOC_SAMA5D2 + select OFDEVICE + select COMMON_CLK_OF_PROVIDER + help + Select this if you are using Microchip's sama5d27 SoM evaluation kit + endif comment "AT91 Board Options" diff --git a/images/Makefile.at91 b/images/Makefile.at91 index acdb591..f321bde 100644 --- a/images/Makefile.at91 +++ b/images/Makefile.at91 @@ -13,3 +13,7 @@ pblb-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += start_sama5d3_xplained_ung8071 FILE_barebox-microchip-ksz9477-evb.img = start_sama5d3_xplained_ung8071.pblb image-$(CONFIG_MACH_MICROCHIP_KSZ9477_EVB) += barebox-microchip-ksz9477-evb.img + +pblb-$(CONFIG_MACH_SAMA5D27_SOM1) += start_sama5d27_som1_ek +FILE_barebox-sama5d27-som1-ek.img = start_sama5d27_som1_ek.pblb +image-$(CONFIG_MACH_SAMA5D27_SOM1) += barebox-sama5d27-som1-ek.img