diff mbox series

[meta-ti,master/kirkstone,v2,1/2] ti-kernel-devicetree-prefix: Add search function for DTBMERGE

Message ID 20230727151216.23224-1-reatmon@ti.com
State Accepted
Delegated to: Ryan Eatmon
Headers show
Series [meta-ti,master/kirkstone,v2,1/2] ti-kernel-devicetree-prefix: Add search function for DTBMERGE | expand

Commit Message

Ryan Eatmon July 27, 2023, 3:12 p.m. UTC
With the change to the vendored arch/arm/boot/dts directory, we need to
add support to the KERNEL_DEVICETREE_DTBMERGE to make it a search
pattern instead of a fixed list.

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
---
 .../linux/ti-kernel-devicetree-prefix.inc     | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta-ti-bsp/recipes-kernel/linux/ti-kernel-devicetree-prefix.inc b/meta-ti-bsp/recipes-kernel/linux/ti-kernel-devicetree-prefix.inc
index 1496a749..04c91004 100644
--- a/meta-ti-bsp/recipes-kernel/linux/ti-kernel-devicetree-prefix.inc
+++ b/meta-ti-bsp/recipes-kernel/linux/ti-kernel-devicetree-prefix.inc
@@ -18,5 +18,25 @@  def get_dtbs_from_kernel(dts_dir, dts_prefix):
             matches.append(filename)
     return ' '.join(matches)
 
-KERNEL_DEVICETREE = "${@get_dtbs_from_kernel('${S}/arch/${ARCH}/boot/dts/', '${KERNEL_DEVICETREE_PREFIX}')} ${KERNEL_DEVICETREE_DTBMERGE}"
+def get_merge_dtbs_from_kernel(dts_dir, dts_pattern):
+    import os
+    matches = []
+    if dts_dir == "":
+        return ' '
+    for pattern in dts_pattern.split():
+        pattern_dir = os.path.split(pattern)[0]
+        pattern_target = os.path.split(pattern)[1].replace(".","-") + "s"
+        makefile = dts_dir + "/" + pattern_dir + "/Makefile"
+        if os.path.exists(makefile):
+            with open(makefile) as f:
+                if pattern_target in f.read():
+                    matches.append(pattern)
+    return ' '.join(matches)
+
+KERNEL_DEVICETREE_DTBMERGE ?= ""
+
+KERNEL_DEVICETREE = " \
+    ${@get_dtbs_from_kernel('${S}/arch/${ARCH}/boot/dts/', '${KERNEL_DEVICETREE_PREFIX}')} \
+    ${@get_merge_dtbs_from_kernel('${S}/arch/${ARCH}/boot/dts/', '${KERNEL_DEVICETREE_DTBMERGE}')} \
+"