RISC-V: Support built-in dtb
Subsystems (2)
PATCH 1/1 RISC-V: Support built-in dtb
Build the dtb into the kernel image.
If the DTB is given via bootloader, the external DTB is adopted first.
Signed-off-by Zong Li <[email protected]>
--- arch/riscv/Kconfig | 4 ++++ arch/riscv/Makefile | 9 +++++++++ arch/riscv/boot/Makefile | 17 +++++++++++++++++ arch/riscv/boot/dts/Makefile | 11 +++++++++++ arch/riscv/kernel/setup.c | 2 +- 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/boot/Makefile create mode 100644 arch/riscv/boot/dts/Makefile
arch/riscv/Kconfig +4 -0
@@ -189,6 +189,10 @@ config RISCV_ISA_C config RISCV_ISA_A def_bool y +config RISCV_BUILTIN_DTB + string "Builtin DTB" + default "" + endmenu menu "Kernel type"
arch/riscv/Makefile +9 -0
@@ -57,6 +57,12 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y) KBUILD_CFLAGS += -mcmodel=medany endif +ifneq '$(CONFIG_NDS32_BUILTIN_DTB)' '""' +BUILTIN_DTB := y +else +BUILTIN_DTB := n +endif + # GCC versions that support the "-mstrict-align" option default to allowing # unaligned accesses. While unaligned accesses are explicitly allowed in the # RISC-V ISA, they're emulated by machine mode traps on all extant
@@ -69,4 +75,7 @@ core-y += arch/riscv/kernel/ arch/riscv/mm/ libs-y += arch/riscv/lib/ +boot := arch/riscv/boot +core-$(BUILTIN_DTB) += $(boot)/dts/ + all: vmlinux
arch/riscv/boot/Makefile new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 + +targets := Image Image.gz + +$(obj)/Image: vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/Image.gz: $(obj)/Image FORCE + $(call if_changed,gzip) + +install: $(obj)/Image + $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ + $(obj)/Image System.map "$(INSTALL_PATH)" + +zinstall: $(obj)/Image.gz + $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ + $(obj)/Image.gz System.map "$(INSTALL_PATH)"
arch/riscv/boot/dts/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +ifneq '$(CONFIG_RISCV_BUILTIN_DTB)' '""' +BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_RISCV_BUILTIN_DTB)).dtb.o +else +BUILTIN_DTB := +endif + +obj-$(CONFIG_OF) += $(BUILTIN_DTB) + +clean-files := *.dtb *.dtb.S
arch/riscv/kernel/setup.c +1 -1
@@ -149,7 +149,7 @@ asmlinkage void __init setup_vm(void)void __init sbi_save (unsigned int hartid,void *dtb) { -early_init_dt_scan (__va (dtb)); +early_init_dt_scan (dtb ?__va (dtb) : __dtb_start); }/*
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html