The STM32MP157A-EV1 and STM32MP157C-EV1 Evaluation boards are the full-feature demonstration and development platforms for STMicroelectronics Arm®-based dual Cortex®-A7 32 bits and Cortex®-M4 32 bits MPUs in the STM32MP1 Series. Add support for running barebox as SSBL on either of them. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- Documentation/boards/stm32mp.rst | 35 ++++++++++++++++++-- arch/arm/boards/Makefile | 1 + arch/arm/boards/stm32mp15x-ev1/Makefile | 2 ++ arch/arm/boards/stm32mp15x-ev1/board.c | 39 +++++++++++++++++++++++ arch/arm/boards/stm32mp15x-ev1/lowlevel.c | 26 +++++++++++++++ arch/arm/configs/stm32mp_defconfig | 1 + arch/arm/dts/Makefile | 1 + arch/arm/dts/stm32mp157c-ev1.dts | 20 ++++++++++++ arch/arm/mach-stm32mp/Kconfig | 8 +++++ images/Makefile.stm32mp | 5 +++ 10 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 arch/arm/boards/stm32mp15x-ev1/Makefile create mode 100644 arch/arm/boards/stm32mp15x-ev1/board.c create mode 100644 arch/arm/boards/stm32mp15x-ev1/lowlevel.c create mode 100644 arch/arm/dts/stm32mp157c-ev1.dts diff --git a/Documentation/boards/stm32mp.rst b/Documentation/boards/stm32mp.rst index 87fff7d1259b..24b7a19ceb96 100644 --- a/Documentation/boards/stm32mp.rst +++ b/Documentation/boards/stm32mp.rst @@ -32,6 +32,7 @@ The resulting images will be placed under ``images/``: barebox-stm32mp15xx-dkx.img # both DK1 and DK2 barebox-stm32mp157c-lxa-mc1.img barebox-stm32mp157c-seeed-odyssey.img + barebox-stm32mp15x-ev1.img # stm32mp157c-ev1 and friends Flashing barebox @@ -94,8 +95,38 @@ acknowledge. Boot source selection --------------------- -The STM32MP BootROM samples three boot pins at reset. Usually BOOT1 is -pulled down and BOOT0 and BOOT2 are connected to a 2P DIP switch:: +The STM32MP BootROM samples three boot pins at reset. On official +eval kit, they are either connected to a 3P DIP switch or 2P (with +BOOT1 pulled down). + +EV-1 +^^^^ +SW1 on the DK boards sets boot mode as follows:: + + +-------+ + | --- | + BOOT2 | O-- | + BOOT1 | O --O | + BOOT0 | N O-- | <---- SD-Card + +-------+ + + +-------+ + | --- | + BOOT2 | --O | + BOOT1 | O O-- | + BOOT0 | N --O | <---- eMMC + +-------+ + + +-------+ + | --- | + BOOT2 | --O | + BOOT1 | O --O | + BOOT0 | N --O | <---- DFU on UART and USB OTG + +-------+ + +DK-1/DK-2 +^^^^^^^^^ +Boot mode on the DK board is set as follows:: +-------+ BOOT2 | O O-- | diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index f8cdd90ed6e6..732936bad63e 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -134,6 +134,7 @@ obj-$(CONFIG_MACH_SOLIDRUN_CUBOX) += solidrun-cubox/ obj-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += solidrun-microsom/ obj-$(CONFIG_MACH_STM32MP15XX_DKX) += stm32mp15xx-dkx/ obj-$(CONFIG_MACH_LXA_MC1) += lxa-mc1/ +obj-$(CONFIG_MACH_STM32MP15X_EV1) += stm32mp15x-ev1/ obj-$(CONFIG_MACH_TECHNEXION_PICO_HOBBIT) += technexion-pico-hobbit/ obj-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += technexion-wandboard/ obj-$(CONFIG_MACH_TNY_A9260) += tny-a926x/ diff --git a/arch/arm/boards/stm32mp15x-ev1/Makefile b/arch/arm/boards/stm32mp15x-ev1/Makefile new file mode 100644 index 000000000000..092c31d6b28d --- /dev/null +++ b/arch/arm/boards/stm32mp15x-ev1/Makefile @@ -0,0 +1,2 @@ +lwl-y += lowlevel.o +obj-y += board.o diff --git a/arch/arm/boards/stm32mp15x-ev1/board.c b/arch/arm/boards/stm32mp15x-ev1/board.c new file mode 100644 index 000000000000..b8e26cd37b3d --- /dev/null +++ b/arch/arm/boards/stm32mp15x-ev1/board.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <bootsource.h> +#include <common.h> +#include <init.h> +#include <mach/bbu.h> + +static int ed1_probe(struct device_d *dev) +{ + int flags; + + flags = bootsource_get_instance() == 0 ? BBU_HANDLER_FLAG_DEFAULT : 0; + stm32mp_bbu_mmc_register_handler("sd", "/dev/mmc0.ssbl", flags); + + flags = bootsource_get_instance() == 1 ? BBU_HANDLER_FLAG_DEFAULT : 0; + stm32mp_bbu_mmc_register_handler("emmc", "/dev/mmc1.ssbl", flags); + + if (bootsource_get_instance() == 0) + of_device_enable_path("/chosen/environment-sd"); + else + of_device_enable_path("/chosen/environment-emmc"); + + barebox_set_model("STM32MP157C-ED1"); + + return 0; +} + +/* ED1 is the SoM on top of the EV1 */ +static const struct of_device_id ed1_of_match[] = { + { .compatible = "st,stm32mp157c-ed1" }, + { /* sentinel */ }, +}; + +static struct driver_d ed1_board_driver = { + .name = "board-stm32mp15x-ed1", + .probe = ed1_probe, + .of_compatible = ed1_of_match, +}; +postcore_platform_driver(ed1_board_driver); diff --git a/arch/arm/boards/stm32mp15x-ev1/lowlevel.c b/arch/arm/boards/stm32mp15x-ev1/lowlevel.c new file mode 100644 index 000000000000..06ff6291b8b4 --- /dev/null +++ b/arch/arm/boards/stm32mp15x-ev1/lowlevel.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <common.h> +#include <mach/entry.h> +#include <debug_ll.h> + +extern char __dtb_z_stm32mp157c_ev1_start[]; + +static void setup_uart(void) +{ + /* first stage has set up the UART, so nothing to do here */ + putc_ll('>'); +} + +ENTRY_FUNCTION(start_stm32mp15x_ev1, r0, r1, r2) +{ + void *fdt; + + stm32mp_cpu_lowlevel_init(); + + if (IS_ENABLED(CONFIG_DEBUG_LL)) + setup_uart(); + + fdt = __dtb_z_stm32mp157c_ev1_start + get_runtime_offset(); + + stm32mp1_barebox_entry(fdt); +} diff --git a/arch/arm/configs/stm32mp_defconfig b/arch/arm/configs/stm32mp_defconfig index e1ee4ec08205..7b90002f8796 100644 --- a/arch/arm/configs/stm32mp_defconfig +++ b/arch/arm/configs/stm32mp_defconfig @@ -2,6 +2,7 @@ CONFIG_ARCH_STM32MP=y CONFIG_MACH_STM32MP15XX_DKX=y CONFIG_MACH_LXA_MC1=y CONFIG_MACH_SEEED_ODYSSEY=y +CONFIG_MACH_STM32MP15X_EV1=y CONFIG_THUMB2_BAREBOX=y CONFIG_ARM_BOARD_APPEND_ATAG=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 63bd73dfaa5d..d5f61768a5b5 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -113,6 +113,7 @@ lwl-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += imx6dl-hummingboard.dtb.o imx6q-hummingb lwl-$(CONFIG_MACH_SEEED_ODYSSEY) += stm32mp157c-odyssey.dtb.o lwl-$(CONFIG_MACH_STM32MP15XX_DKX) += stm32mp157c-dk2.dtb.o stm32mp157a-dk1.dtb.o lwl-$(CONFIG_MACH_LXA_MC1) += stm32mp157c-lxa-mc1.dtb.o +lwl-$(CONFIG_MACH_STM32MP15X_EV1) += stm32mp157c-ev1.dtb.o lwl-$(CONFIG_MACH_SCB9328) += imx1-scb9328.dtb.o lwl-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += imx6q-wandboard.dtb.o imx6dl-wandboard.dtb.o lwl-$(CONFIG_MACH_TECHNEXION_PICO_HOBBIT) += imx6ul-pico-hobbit.dtb.o diff --git a/arch/arm/dts/stm32mp157c-ev1.dts b/arch/arm/dts/stm32mp157c-ev1.dts new file mode 100644 index 000000000000..742eca7a33c9 --- /dev/null +++ b/arch/arm/dts/stm32mp157c-ev1.dts @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR X11) + +#include <arm/stm32mp157c-ev1.dts> +#include "stm32mp151.dtsi" + +/ { + chosen { + environment-sd { + compatible = "barebox,environment"; + device-path = &sdmmc1, "partname:barebox-environment"; + status = "disabled"; + }; + + environment-emmc { + compatible = "barebox,environment"; + device-path = &sdmmc2, "partname:barebox-environment"; + status = "disabled"; + }; + }; +}; diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig index b8ccbaab6702..95d3dc510d12 100644 --- a/arch/arm/mach-stm32mp/Kconfig +++ b/arch/arm/mach-stm32mp/Kconfig @@ -23,4 +23,12 @@ config MACH_SEEED_ODYSSEY select ARCH_STM32MP157 bool "Seeed Studio Odyssey" +config MACH_STM32MP15X_EV1 + select ARCH_STM32MP157 + bool "STM32MP15X-EV1 board" + help + builds a single barebox-stm32mp15x-ev1.img that can be deployed + as SSBL on any STM32MP15X-EVAL platform, like the + STM32MP157C-EV1 + endif diff --git a/images/Makefile.stm32mp b/images/Makefile.stm32mp index eafe84a72185..3384f5014bb1 100644 --- a/images/Makefile.stm32mp +++ b/images/Makefile.stm32mp @@ -27,3 +27,8 @@ pblb-$(CONFIG_MACH_SEEED_ODYSSEY) += start_stm32mp157c_seeed_odyssey FILE_barebox-stm32mp157c-seeed-odyssey.img = start_stm32mp157c_seeed_odyssey.pblb.stm32 OPTS_start_stm32mp157c_seeed_odyssey.pblb.stm32 = $(STM32MP1_OPTS) image-$(CONFIG_MACH_SEEED_ODYSSEY) += barebox-stm32mp157c-seeed-odyssey.img + +pblb-$(CONFIG_MACH_STM32MP15X_EV1) += start_stm32mp15x_ev1 +FILE_barebox-stm32mp15x-ev1.img = start_stm32mp15x_ev1.pblb.stm32 +OPTS_start_stm32mp15x_ev1.pblb.stm32 = $(STM32MP1_OPTS) +image-$(CONFIG_MACH_STM32MP15X_EV1) += barebox-stm32mp15x-ev1.img -- 2.29.2 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox