summaryrefslogtreecommitdiffstats
path: root/meta-ti-bsp/classes/ti-devicetree-prefix.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ti-bsp/classes/ti-devicetree-prefix.bbclass')
-rw-r--r--meta-ti-bsp/classes/ti-devicetree-prefix.bbclass43
1 files changed, 43 insertions, 0 deletions
diff --git a/meta-ti-bsp/classes/ti-devicetree-prefix.bbclass b/meta-ti-bsp/classes/ti-devicetree-prefix.bbclass
new file mode 100644
index 00000000..5858cc65
--- /dev/null
+++ b/meta-ti-bsp/classes/ti-devicetree-prefix.bbclass
@@ -0,0 +1,43 @@
1# Generate list of DTBs from the kernel source
2def get_dtbs_from_kernel(dts_dir, dts_prefix):
3 import os
4 import glob
5 matches = []
6
7 for prefix in dts_prefix.split():
8 filenames = glob.glob(dts_dir + prefix + '*.dts')
9 filenames += glob.glob(dts_dir + prefix + '*.dtso')
10 for filename in filenames:
11 # Before v6.2 kernels DTB Overlays shared the same name as DTB files
12 # so we need to search the file to find the type
13 with open(filename) as f:
14 file_postfix = '.dtbo' if '/plugin/;' in f.read() else '.dtb'
15 filename = os.path.split(filename)[1]
16 filename = os.path.splitext(filename)[0] + file_postfix
17 filename = os.path.join(os.path.split(prefix)[0], filename)
18 matches.append(filename)
19 return ' '.join(matches)
20
21# Generate list of "merged" DTBs from the kernel source
22# It is TI custom feature to merge DTB overlays into a single DTB
23def get_merge_dtbs_from_kernel(dts_dir, dts_pattern):
24 import os
25 matches = []
26 if dts_dir == "":
27 return ' '
28 for pattern in dts_pattern.split():
29 pattern_dir = os.path.split(pattern)[0]
30 pattern_target = os.path.split(pattern)[1].replace(".","-") + "s"
31 makefile = dts_dir + "/" + pattern_dir + "/Makefile"
32 if os.path.exists(makefile):
33 with open(makefile) as f:
34 if pattern_target in f.read():
35 matches.append(pattern)
36 return ' '.join(matches)
37
38KERNEL_DEVICETREE = " \
39 ${@get_dtbs_from_kernel('${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/', '${KERNEL_DEVICETREE_PREFIX}')} \
40 ${@get_merge_dtbs_from_kernel('${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/', '${KERNEL_DEVICETREE_DTBMERGE}')} \
41"
42
43do_image_wic[depends] += "virtual/kernel:do_shared_workdir"