1 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2011 The Chromium OS Authors.
5 # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
6 # enabled. See doc/README.fdt-control for more details.
8 DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
13 ifeq ($(CONFIG_OF_UPSTREAM),y)
14 ifeq ($(CONFIG_ARM64),y)
15 dt_dir := dts/upstream/src/arm64
17 dt_dir := dts/upstream/src/$(ARCH)
20 dt_dir := arch/$(ARCH)/dts
23 ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
24 local_dtbos := local-dtbos
32 DTB := $(dt_dir)/$(DEVICE_TREE).dtb
35 $(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
37 $(call if_changed,fdtgrep)
39 ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
40 $(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
41 $(call if_changed,fdt_rm_props)
43 $(obj)/dt.dtb: $(DTB) FORCE
44 $(call if_changed,shipped)
49 $(DTB): arch-dtbs $(local_dtbos)
52 echo >&2 "Device Tree Source ($@) is not correctly specified."; \
53 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
54 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
60 $(Q)$(MAKE) $(build)=$(dt_dir) dtbs
62 ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
65 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbos
68 ifeq ($(CONFIG_XPL_BUILD),y)
69 obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
70 # support "out-of-tree" build for dtb-spl
71 $(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
72 $(call if_changed_dep,as_o_S)
74 obj-$(CONFIG_OF_EMBED) := dt.dtb.o
77 # Target for U-Boot proper
82 spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
85 clean-files := dt.dtb.S
87 # Let clean descend into dts directories
88 subdir- += ../arch/arc/dts ../arch/arm/dts ../arch/m68k/dts ../arch/microblaze/dts \
89 ../arch/mips/dts ../arch/nios2/dts ../arch/powerpc/dts ../arch/riscv/dts \
90 ../arch/sandbox/dts ../arch/sh/dts ../arch/x86/dts ../arch/xtensa/dts \
91 ./upstream/src/arm64 ./upstream/src/$(ARCH)