diff mbox series

linux: add support for device tree overlays

Message ID 20240213154847.914068-1-michael@walle.cc
State New
Headers show
Series linux: add support for device tree overlays | expand

Commit Message

Michael Walle Feb. 13, 2024, 3:48 p.m. UTC
The linux kernel can build device tree overlays (.dtbo) itself. Add
support to build and copy them along with the actual device trees.
These can either be in-tree device tree overlays
(BR2_LINUX_KERNEL_INTREE_DTBOS) or they can be provided outside of the
kernel (BR2_LINUX_KERNEL_CUSTOM_DTS_PATH). In the latter case, the
overlay source files will be copied into the kernel tree first.

Signed-off-by: Michael Walle <michael@walle.cc>

---
Alternatively, one could make BR2_LINUX_KERNEL_INTREE_DTS_NAME similar
to BR2_LINUX_KERNEL_CUSTOM_DTS_PATH and provide a list of dts and dtso
files. But that would mean deprecating BR2_LINUX_KERNEL_INTREE_DTS_NAME
and touch all defconfigs to rename that option and append the ".dts"
suffix. I'm not sure what's better here.
---
 linux/Config.in | 14 +++++++++++---
 linux/linux.mk  |  8 ++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/linux/Config.in b/linux/Config.in
index 773cb4fbb5..486a2144e3 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -411,12 +411,20 @@  config BR2_LINUX_KERNEL_INTREE_DTS_NAME
 	  the trailing .dts. You can provide a list of
 	  dts files to build, separated by spaces.
 
+config BR2_LINUX_KERNEL_INTREE_DTBOS
+	string "In-tree Device Tree Overlay file names"
+	help
+	  Names of in-tree device tree overlay files (.dtbo) which
+	  should be built and installed into the target system,
+	  separated by spaces.
+
 config BR2_LINUX_KERNEL_CUSTOM_DTS_PATH
 	string "Out-of-tree Device Tree Source file paths"
 	help
-	  Paths to out-of-tree Device Tree Source (.dts) and Device Tree
-	  Source Include (.dtsi) files, separated by spaces. These files
-	  will be copied to the kernel sources and the .dts files will
+	  Paths to out-of-tree Device Tree Source (.dts), Device Tree
+	  Source Include (.dtsi) and Device Tree Overlay Source (.dtso)
+	  files, separated by spaces. These files will be copied to the
+	  kernel sources and the .dts files will
 	  be compiled from there.
 
 config BR2_LINUX_KERNEL_DTB_KEEP_DIRNAME
diff --git a/linux/linux.mk b/linux/linux.mk
index 53e2ad6d48..de6c5bd602 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -190,14 +190,18 @@  endif
 LINUX_VERSION_PROBED = `MAKEFLAGS='$(filter-out w,$(MAKEFLAGS))' $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease 2>/dev/null`
 
 LINUX_DTS_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
+LINUX_DTBOS += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTBOS))
 
 # We keep only the .dts files, so that the user can specify both .dts
 # and .dtsi files in BR2_LINUX_KERNEL_CUSTOM_DTS_PATH. Both will be
 # copied to arch/<arch>/boot/dts, but only the .dts files will
 # actually be generated as .dtb.
-LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH)))))
+LINUX_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_PATH))
+LINUX_DTS_NAME += $(basename $(filter %.dts,$(notdir $(LINUX_CUSTOM_DTS_PATH))))
+LINUX_DTBOS += $(addsuffix .dtbo,$(basename $(filter %.dtso,$(notdir $(LINUX_CUSTOM_DTS_PATH)))))
+$(error $(LINUX_CUSTOM_DTS_PATH))
 
-LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME))
+LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME)) $(LINUX_DTBOS)
 
 ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y)
 LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME))