blob: a20930eb9a5e656bbdedf924e4f754c7da7552e4 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass38d6b8d2011-10-15 05:48:21 +00002#
3# Copyright (c) 2011 The Chromium OS Authors.
Simon Glass38d6b8d2011-10-15 05:48:21 +00004
5# This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
6# enabled. See doc/README.fdt-control for more details.
7
Masahiro Yamada43c08932014-02-05 11:28:25 +09008DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
9ifeq ($(DEVICE_TREE),)
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090010DEVICE_TREE := unset
Masahiro Yamada43c08932014-02-05 11:28:25 +090011endif
Stephen Warrenc198ef72013-07-24 10:09:19 -070012
Simon Glassc3b0de42014-06-12 07:24:43 -060013ifneq ($(EXT_DTB),)
14DTB := $(EXT_DTB)
Simon Glass67bce6b2014-06-02 22:04:50 -060015else
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090016DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
Simon Glass67bce6b2014-06-02 22:04:50 -060017endif
Stephen Warrenc198ef72013-07-24 10:09:19 -070018
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000019$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
20 $(call if_changed,fdtgrep)
21
Anatolij Gustschin08568342020-01-12 15:57:42 +010022ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
23$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
24 $(call if_changed,fdt_rm_props)
25else
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090026$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamada97e101c2014-06-04 10:11:18 +090027 $(call if_changed,shipped)
Anatolij Gustschin08568342020-01-12 15:57:42 +010028endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000029
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000030targets += dt.dtb dt-spl.dtb
Simon Glass38d6b8d2011-10-15 05:48:21 +000031
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090032$(DTB): arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090033 $(Q)test -e $@ || ( \
34 echo >&2; \
35 echo >&2 "Device Tree Source is not correctly specified."; \
36 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
37 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
38 echo >&2; \
39 /bin/false)
40
Stephen Warrend2d742c2019-02-26 12:20:25 -070041PHONY += arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090042arch-dtbs:
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090043 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
Simon Glass38d6b8d2011-10-15 05:48:21 +000044
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000045ifeq ($(CONFIG_SPL_BUILD),y)
46obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
47# support "out-of-tree" build for dtb-spl
48$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
49 $(call if_changed_dep,as_o_S)
50else
Masahiro Yamada43c08932014-02-05 11:28:25 +090051obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000052endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000053
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000054dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb
Masahiro Yamada43c08932014-02-05 11:28:25 +090055 @:
Simon Glass38d6b8d2011-10-15 05:48:21 +000056
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000057clean-files := dt.dtb.S dt-spl.dtb.S
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090058
59# Let clean descend into dts directories
Lukas Auerbad1b5e2018-11-22 11:26:11 +010060subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts