diff mbox series

[14/16] mips: mtmips: add SPL support

Message ID 1578452549-7156-1-git-send-email-weijie.gao@mediatek.com
State New
Headers show
Series [01/16] configs: mtmips: add missing board selection for gardena-smart-gateway-mt7688 | expand

Commit Message

Weijie Gao Jan. 8, 2020, 3:02 a.m. UTC
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 <weijie.gao at mediatek.com>
---
 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

Comments

Stefan Roese Jan. 10, 2020, 2:17 p.m. UTC | #1
On 08.01.20 04:02, Weijie Gao wrote:
> 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 <weijie.gao at mediatek.com>
> ---
>   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 <weijie.gao at mediatek.com>
> + */
> +
> +/ {
> +	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 <weijie.gao at mediatek.com>
> + */
> +
> +#include <common.h>
> +#include <spl.h>
> +
> +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;
> +}
> 

Please add the UART2 pin mux code here as suggested in my previous mail
(or a similar, preferred version).

Other than that:

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan
diff mbox series

Patch

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 <weijie.gao at mediatek.com>
+ */
+
+/ {
+	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 <weijie.gao at mediatek.com>
+ */
+
+#include <common.h>
+#include <spl.h>
+
+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;
+}