1 # SPDX-License-Identifier: GPL-2.0-only 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 # If CONFIG_OF_ALL_DTBS is enabled, all DT blo 3 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built 4 dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) 4 dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) 5 5 6 # Composite DTB (i.e. DTB constructed by overl 6 # Composite DTB (i.e. DTB constructed by overlay) 7 multi-dtb-y := $(call multi-search, $(dtb-y), 7 multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs) 8 # Primitive DTB compiled from *.dts 8 # Primitive DTB compiled from *.dts 9 real-dtb-y := $(call real-search, $(dtb-y), .d 9 real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs) 10 # Base DTB that overlay is applied onto 10 # Base DTB that overlay is applied onto 11 base-dtb-y := $(filter %.dtb, $(call real-sear 11 base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs)) 12 12 13 dtb-y := $(addprefix $(obj)/, $(dtb- 13 dtb-y := $(addprefix $(obj)/, $(dtb-y)) 14 multi-dtb-y := $(addprefix $(obj)/, $(mult 14 multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) 15 real-dtb-y := $(addprefix $(obj)/, $(real 15 real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) 16 16 17 always-y += $(dtb-y) 17 always-y += $(dtb-y) 18 targets += $(real-dtb-y) 18 targets += $(real-dtb-y) 19 19 20 # dtbs-list 20 # dtbs-list 21 # -------------------------------------------- 21 # --------------------------------------------------------------------------- 22 22 23 ifdef need-dtbslist 23 ifdef need-dtbslist 24 subdir-dtbslist := $(addsuffix /dtbs-list, $(s 24 subdir-dtbslist := $(addsuffix /dtbs-list, $(subdir-ym)) 25 dtb-y += $(subdir-dtbslist) 25 dtb-y += $(subdir-dtbslist) 26 always-y += $(obj)/dtbs-list 26 always-y += $(obj)/dtbs-list 27 endif 27 endif 28 28 29 $(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj) 29 $(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ; 30 30 31 $(obj)/dtbs-list: $(dtb-y) FORCE 31 $(obj)/dtbs-list: $(dtb-y) FORCE 32 $(call if_changed,gen_order) 32 $(call if_changed,gen_order) 33 33 34 # Assembly file to wrap dtb(o) 34 # Assembly file to wrap dtb(o) 35 # -------------------------------------------- 35 # --------------------------------------------------------------------------- 36 36 37 builtin-dtb-section = $(if $(filter arch/$(SRC 37 builtin-dtb-section = $(if $(filter arch/$(SRCARCH)/boot/dts%, $(obj)),.dtb.init.rodata,.rodata) 38 38 39 # Generate an assembly file to wrap the output 39 # Generate an assembly file to wrap the output of the device tree compiler 40 quiet_cmd_wrap_S_dtb = WRAP $@ 40 quiet_cmd_wrap_S_dtb = WRAP $@ 41 cmd_wrap_S_dtb = { 41 cmd_wrap_S_dtb = { \ 42 symbase=__$(patsubst .%,%,$(su 42 symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \ 43 echo '\#include <asm-generic/v 43 echo '\#include <asm-generic/vmlinux.lds.h>'; \ 44 echo '.section $(builtin-dtb-s 44 echo '.section $(builtin-dtb-section),"a"'; \ 45 echo '.balign STRUCT_ALIGNMENT 45 echo '.balign STRUCT_ALIGNMENT'; \ 46 echo ".global $${symbase}_begi 46 echo ".global $${symbase}_begin"; \ 47 echo "$${symbase}_begin:"; 47 echo "$${symbase}_begin:"; \ 48 echo '.incbin "$<" '; 48 echo '.incbin "$<" '; \ 49 echo ".global $${symbase}_end" 49 echo ".global $${symbase}_end"; \ 50 echo "$${symbase}_end:"; 50 echo "$${symbase}_end:"; \ 51 echo '.balign STRUCT_ALIGNMENT 51 echo '.balign STRUCT_ALIGNMENT'; \ 52 } > $@ 52 } > $@ 53 53 54 $(obj)/%.dtb.S: $(obj)/%.dtb FORCE 54 $(obj)/%.dtb.S: $(obj)/%.dtb FORCE 55 $(call if_changed,wrap_S_dtb) 55 $(call if_changed,wrap_S_dtb) 56 56 57 $(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE 57 $(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE 58 $(call if_changed,wrap_S_dtb) 58 $(call if_changed,wrap_S_dtb) 59 59 60 # Schema check 60 # Schema check 61 # -------------------------------------------- 61 # --------------------------------------------------------------------------- 62 62 63 ifneq ($(CHECK_DTBS),) 63 ifneq ($(CHECK_DTBS),) 64 DT_CHECKER ?= dt-validate 64 DT_CHECKER ?= dt-validate 65 DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l 65 DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m) 66 DT_BINDING_DIR := Documentation/devicetree/bin 66 DT_BINDING_DIR := Documentation/devicetree/bindings 67 DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/ 67 DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.json 68 dtb-check-enabled = $(if $(filter %.dtb, $@),y 68 dtb-check-enabled = $(if $(filter %.dtb, $@),y) 69 endif 69 endif 70 70 71 quiet_dtb_check_tag = $(if $(dtb-check-enabled 71 quiet_dtb_check_tag = $(if $(dtb-check-enabled),[C], ) 72 cmd_dtb_check = $(if $(dtb-check-enabled),; $( 72 cmd_dtb_check = $(if $(dtb-check-enabled),; $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true) 73 73 74 # Overlay 74 # Overlay 75 # -------------------------------------------- 75 # --------------------------------------------------------------------------- 76 76 77 # NOTE: 77 # NOTE: 78 # Do not replace $(filter %.dtb %.dtbo, $^) wi 78 # Do not replace $(filter %.dtb %.dtbo, $^) with $(real-prereqs). When a single 79 # DTB is turned into a multi-blob DTB, $^ will 79 # DTB is turned into a multi-blob DTB, $^ will contain header file dependencies 80 # recorded in the .*.cmd file. 80 # recorded in the .*.cmd file. 81 quiet_cmd_fdtoverlay = OVL $(quiet_dtb_check_t 81 quiet_cmd_fdtoverlay = OVL $(quiet_dtb_check_tag) $@ 82 cmd_fdtoverlay = $(objtree)/scripts/dtc/ 82 cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) $(cmd_dtb_check) 83 83 84 $(multi-dtb-y): $(DT_TMP_SCHEMA) FORCE 84 $(multi-dtb-y): $(DT_TMP_SCHEMA) FORCE 85 $(call if_changed,fdtoverlay) 85 $(call if_changed,fdtoverlay) 86 $(call multi_depend, $(multi-dtb-y), .dtb, -dt 86 $(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) 87 87 88 # DTC 88 # DTC 89 # -------------------------------------------- 89 # --------------------------------------------------------------------------- 90 90 91 DTC ?= $(objtree)/scripts/dtc/dtc 91 DTC ?= $(objtree)/scripts/dtc/dtc 92 DTC_FLAGS += -Wno-unique_unit_address 92 DTC_FLAGS += -Wno-unique_unit_address 93 93 94 # Disable noisy checks by default 94 # Disable noisy checks by default 95 ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) 95 ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) 96 DTC_FLAGS += -Wno-unit_address_vs_reg \ 96 DTC_FLAGS += -Wno-unit_address_vs_reg \ 97 -Wno-avoid_unnecessary_addr_size 97 -Wno-avoid_unnecessary_addr_size \ 98 -Wno-alias_paths \ 98 -Wno-alias_paths \ 99 -Wno-graph_child_address \ 99 -Wno-graph_child_address \ 100 -Wno-simple_bus_reg 100 -Wno-simple_bus_reg 101 else 101 else 102 DTC_FLAGS += -Wunique_unit_address_if_enabled 102 DTC_FLAGS += -Wunique_unit_address_if_enabled 103 endif 103 endif 104 104 105 ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) 105 ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) 106 DTC_FLAGS += -Wnode_name_chars_strict \ 106 DTC_FLAGS += -Wnode_name_chars_strict \ 107 -Wproperty_name_chars_strict \ 107 -Wproperty_name_chars_strict \ 108 -Wunique_unit_address 108 -Wunique_unit_address 109 endif 109 endif 110 110 111 DTC_FLAGS += $(DTC_FLAGS_$(target-stem)) 111 DTC_FLAGS += $(DTC_FLAGS_$(target-stem)) 112 112 113 # Set -@ if the target is a base DTB that over 113 # Set -@ if the target is a base DTB that overlay is applied onto 114 DTC_FLAGS += $(if $(filter $(patsubst $(obj)/% 114 DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) 115 115 116 DTC_INCLUDE := $(srctree)/scripts/dtc/include- 116 DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes 117 117 118 dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -n 118 dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc -I $(DTC_INCLUDE) -undef -D__DTS__ 119 119 120 dtc-tmp = $(subst $(comma),_,$(dot-target).dts 120 dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) 121 121 122 quiet_cmd_dtc = DTC $(quiet_dtb_check_tag) $@ 122 quiet_cmd_dtc = DTC $(quiet_dtb_check_tag) $@ 123 cmd_dtc = \ 123 cmd_dtc = \ 124 $(HOSTCC) -E $(dtc_cpp_flags) -x assem 124 $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 125 $(DTC) -o $@ -b 0 $(addprefix -i,$(dir 125 $(DTC) -o $@ -b 0 $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) \ 126 $(DTC_FLAGS) -d $(depfile).dtc. 126 $(DTC_FLAGS) -d $(depfile).dtc.tmp $(dtc-tmp) ; \ 127 cat $(depfile).pre.tmp $(depfile).dtc. 127 cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) \ 128 $(cmd_dtb_check) 128 $(cmd_dtb_check) 129 129 130 $(obj)/%.dtb: $(obj)/%.dts $(DTC) $(DT_TMP_SCH 130 $(obj)/%.dtb: $(obj)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE 131 $(call if_changed_dep,dtc) 131 $(call if_changed_dep,dtc) 132 132 133 $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE 133 $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE 134 $(call if_changed_dep,dtc) 134 $(call if_changed_dep,dtc) 135 135 136 # targets 136 # targets 137 # -------------------------------------------- 137 # --------------------------------------------------------------------------- 138 138 139 targets += $(always-y) 139 targets += $(always-y) 140 140 141 # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts 141 # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts 142 # %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso 142 # %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso 143 targets += $(call intermediate_targets, .dtb.o 143 targets += $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \ 144 $(call intermediate_targets, .dtbo. 144 $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.