Maximilian Brune has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83848?usp=email )
Change subject: arch/riscv: Add common FDT build ......................................................................
arch/riscv: Add common FDT build
Currently all platforms on RISC-V require a FDT. The inclusion of the FDT is currently done in the platform Makefiles. In order to factor out some common code this patch adds the inclusion in the architecture Makefile.
Signed-off-by: Maximilian Brune maximilian.brune@9elements.com Change-Id: I3b304a89646fe84c98e9f199f315bebb156de16c --- M src/arch/riscv/Kconfig M src/arch/riscv/Makefile.mk 2 files changed, 37 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/48/83848/1
diff --git a/src/arch/riscv/Kconfig b/src/arch/riscv/Kconfig index 7bf643f..9a2d54e 100644 --- a/src/arch/riscv/Kconfig +++ b/src/arch/riscv/Kconfig @@ -134,4 +134,19 @@ bool default y
+config RISCV_DTS + bool + default n + help + This option is selected by mainboards that include a devicetree + source file (not to be confused with the coreboot devicetree.cb files). + The devicetree will be preprocessed and compiled into a FDT (flattened devicetree). + Said FDT will be put into a CBFS file for use in runtime. + +config RISCV_DTS_FILE + string + depends on RISCV_DTS + help + Path to the devicetree source file in .dts format. + endif # if ARCH_RISCV diff --git a/src/arch/riscv/Makefile.mk b/src/arch/riscv/Makefile.mk index 05407f8..c2e8023 100644 --- a/src/arch/riscv/Makefile.mk +++ b/src/arch/riscv/Makefile.mk @@ -67,6 +67,28 @@ $(top)/src/lib/memset.c all-$(CONFIG_RISCV_USE_ARCH_TIMER) += arch_timer.c
+## FDT (Flattened Devicetree) inclusion + +ifeq ($(CONFIG_RISCV_DTS),y) + +# at some point dtc may be compiled by our toolchain +DTC ?= dtc +CPPFLAGS_dts += -nostdinc -P -x assembler-with-cpp -I src/arch/riscv/include + +$(obj)/preprocessed.dts: $(call strip_quotes, $(CONFIG_RISCV_DTS_FILE)) + $(CPP_riscv) $(CPPFLAGS_dts) -o $@ $< + +$(obj)/dtb: $(obj)/preprocessed.dts + $(DTC) -I dts -O dtb -o $@ $< + +# This may be optimized in the future by letting cbfstool parse our FDT into a unflattened +# devicetree blob in build time, so that we only need to flatten it in runtime instead of +# unflatten and flatten it in runtime. +cbfs-files-y += DTB +DTB-file := $(obj)/dtb +DTB-type := raw + +endif # CONFIG_RISCV_DTS
################################################################################ ## bootblock