[Concept,22/25] Makefile: Integrate CHID files into the build

Message ID 20250903133639.3235920-23-sjg@u-boot.org
State New
Headers
Series Selection of devicetree using CHIDs |

Commit Message

Simon Glass Sept. 3, 2025, 1:36 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

When CONFIG_CHID is enabled, U-Boot must have access to a set of CHIDs
which it can use to identfy the hardware it is running on.

Add support for reading a hwids/compatible.hwidmap file in the board
directory and including the information in the board's devicetree.

This works by running the hwids_to_dtsi.py.py script and putting the
result in the dtsi_include_list variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/Makefile.lib | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
  

Patch

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6d6a21f262a..1156024a446 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -204,6 +204,21 @@  ifdef DEVICE_TREE_DEBUG
 u_boot_dtsi_options_debug = $(warning $(u_boot_dtsi_options_raw))
 endif
 
+# Computer Hardware Identification (CHID)
+# Convert files mentioned in the compatible.hwidmap file into .dtsi includes for
+# addition to the board's devicetree.
+ifdef CONFIG_CHID
+chid_hwids_dtsi=hwids.dtsi
+
+quiet_cmd_chid_dtsi_gen = CHID_DTSI_GEN $@
+cmd_chid_dtsi_gen = $(srctree)/scripts/hwids_to_dtsi.py \
+	-m $(srctree)/board/$(BOARDDIR)/hwids/compatible.hwidmap -o $@
+
+$(obj)/$(chid_hwids_dtsi): $(srctree)/board/$(BOARDDIR)/hwids/compatible.hwidmap \
+		$(wildcard $(srctree)/board/$(BOARDDIR)/hwids/*.txt) FORCE
+	$(call cmd,chid_dtsi_gen)
+endif
+
 # We use the first match to be included
 dtsi_include_list = $(strip $(u_boot_dtsi_options_debug) \
 	$(notdir $(firstword $(u_boot_dtsi_options))))
@@ -429,6 +444,12 @@  quiet_cmd_dtb = $(quiet_cmd_dtc)
       cmd_dtb = $(cmd_dtc)
 endif
 
+# Add CHID dependency to dtsi_include_list
+ifdef CONFIG_CHID
+dtsi_include_list += $(chid_hwids_dtsi)
+dtsi_include_list_deps += $(obj)/$(chid_hwids_dtsi)
+endif
+
 $(obj)/%.dtb: $(src)/%.dts $(DTC) $(dtsi_include_list_deps) $(DT_TMP_SCHEMA) FORCE
 	$(call if_changed_dep,dtb)