From patchwork Wed Jan 8 03:02:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weijie Gao X-Patchwork-Id: 239243 List-Id: U-Boot discussion From: weijie.gao at mediatek.com (Weijie Gao) Date: Wed, 8 Jan 2020 11:02:29 +0800 Subject: [PATCH 14/16] mips: mtmips: add SPL support Message-ID: <1578452549-7156-1-git-send-email-weijie.gao@mediatek.com> This patch adds SPL support for mtmips platform. The lowlevel architecture is split into SPL and the rest parts are built into a memory loadable u-boot image. The increment of size is very small (< 10 KiB) and the memory bootable u-boot (u-boot.img) is generated automatically so there is not need to add a separate config for it. Signed-off-by: Weijie Gao Reviewed-by: Stefan Roese --- Makefile | 9 +++++++++ arch/mips/Kconfig | 2 ++ arch/mips/dts/mt7628-u-boot.dtsi | 25 +++++++++++++++++++++++++ arch/mips/mach-mtmips/Kconfig | 4 ++++ arch/mips/mach-mtmips/Makefile | 1 + arch/mips/mach-mtmips/spl.c | 23 +++++++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 arch/mips/dts/mt7628-u-boot.dtsi create mode 100644 arch/mips/mach-mtmips/spl.c diff --git a/Makefile b/Makefile index 37bfc0e711..8f429eac54 100644 --- a/Makefile +++ b/Makefile @@ -894,6 +894,7 @@ ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb-tegra.bin endif ALL-$(CONFIG_ARCH_MEDIATEK) += u-boot-mtk.bin +ALL-$(CONFIG_ARCH_MTMIPS) += u-boot-mtmips.bin # Add optional build target if defined in board/cpu/soc headers ifneq ($(CONFIG_BUILD_TARGET),) @@ -1662,6 +1663,14 @@ u-boot-mtk.bin: u-boot.bin FORCE $(call if_changed,mkimage) endif +ifeq ($(CONFIG_SPL),y) +u-boot-mtmips.bin: u-boot.dtb u-boot-lzma.img spl/u-boot-spl.bin FORCE + $(call if_changed,binman) +else +u-boot-mtmips.bin: u-boot.bin FORCE + $(call if_changed,copy) +endif + ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) # Rule to link u-boot diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 015a7f6358..20bd422b4f 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -98,6 +98,8 @@ config ARCH_MTMIPS select SUPPORTS_CPU_MIPS32_R2 select SUPPORTS_LITTLE_ENDIAN select SYSRESET + select SUPPORT_SPL + select BINMAN config ARCH_JZ47XX bool "Support Ingenic JZ47xx" diff --git a/arch/mips/dts/mt7628-u-boot.dtsi b/arch/mips/dts/mt7628-u-boot.dtsi new file mode 100644 index 0000000000..e9abe6eb9f --- /dev/null +++ b/arch/mips/dts/mt7628-u-boot.dtsi @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 MediaTek Inc. + * + * Author: Weijie Gao + */ + +/ { + binman { + filename = "u-boot-mtmips.bin"; + pad-byte = <0xff>; + +#ifdef CONFIG_SPL + u-boot-spl { + align-end = <0x4000>; + }; + + u-boot-img { + }; +#else + u-boot { + }; +#endif + }; +}; diff --git a/arch/mips/mach-mtmips/Kconfig b/arch/mips/mach-mtmips/Kconfig index e0076b613f..4556e7f4f6 100644 --- a/arch/mips/mach-mtmips/Kconfig +++ b/arch/mips/mach-mtmips/Kconfig @@ -20,6 +20,10 @@ config SYS_ICACHE_LINE_SIZE default 32 config SYS_TEXT_BASE + default 0x9c000000 if !SPL + default 0x80200000 if SPL + +config SPL_TEXT_BASE default 0x9c000000 choice diff --git a/arch/mips/mach-mtmips/Makefile b/arch/mips/mach-mtmips/Makefile index 72f0369030..a7e6a66304 100644 --- a/arch/mips/mach-mtmips/Makefile +++ b/arch/mips/mach-mtmips/Makefile @@ -3,5 +3,6 @@ obj-y += cpu.o obj-y += ddr_init.o obj-y += ddr_cal.o +obj-$(CONFIG_SPL_BUILD) += spl.o obj-$(CONFIG_SOC_MT7628) += mt7628/ diff --git a/arch/mips/mach-mtmips/spl.c b/arch/mips/mach-mtmips/spl.c new file mode 100644 index 0000000000..37172abadf --- /dev/null +++ b/arch/mips/mach-mtmips/spl.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2020 MediaTek Inc. All Rights Reserved. + * + * Author: Weijie Gao + */ + +#include +#include + +void __noreturn board_init_f(ulong dummy) +{ +#ifdef CONFIG_SPL_SERIAL_SUPPORT + preloader_console_init(); +#endif + + board_init_r(NULL, 0); +} + +void board_boot_order(u32 *spl_boot_list) +{ + spl_boot_list[0] = BOOT_DEVICE_NOR; +}