blob: c0a953ffac9937ab00800cbe5bedc0f0fb632343 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glassbbb0b122011-10-15 05:48:21 +00002#
3# Copyright (c) 2011 The Chromium OS Authors.
Simon Glassbbb0b122011-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 Yamadaefcf8612014-02-04 17:24:40 +09008DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
9ifeq ($(DEVICE_TREE),)
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090010DEVICE_TREE := unset
Masahiro Yamadaefcf8612014-02-04 17:24:40 +090011endif
Simon Glassbbb0b122011-10-15 05:48:21 +000012
Simon Glassd18926a2014-06-12 07:24:43 -060013ifneq ($(EXT_DTB),)
14DTB := $(EXT_DTB)
Simon Glass63b4b5b2014-06-02 22:04:50 -060015else
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090016DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
Simon Glass63b4b5b2014-06-02 22:04:50 -060017endif
Simon Glassbbb0b122011-10-15 05:48:21 +000018
Simon Glassde3e3722020-12-22 19:30:14 -070019spl/$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
20 mkdir -p $(dir $@)
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000021 $(call if_changed,fdtgrep)
22
Simon Glassde3e3722020-12-22 19:30:14 -070023tpl/$(obj)/dt-tpl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
Simon Glass53db2ee2020-12-22 19:30:13 -070024 $(call if_changed,fdtgrep)
25
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010026ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
27$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
28 $(call if_changed,fdt_rm_props)
29else
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090030$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamadab9d1dbd2014-06-04 10:11:18 +090031 $(call if_changed,shipped)
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010032endif
Simon Glassbbb0b122011-10-15 05:48:21 +000033
Simon Glass53db2ee2020-12-22 19:30:13 -070034targets += dt.dtb dt-spl.dtb dt-tpl.dtb
Simon Glassbbb0b122011-10-15 05:48:21 +000035
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090036$(DTB): arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090037 $(Q)test -e $@ || ( \
38 echo >&2; \
39 echo >&2 "Device Tree Source is not correctly specified."; \
40 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
41 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
42 echo >&2; \
43 /bin/false)
44
Stephen Warren2737dfe2019-02-26 12:20:25 -070045PHONY += arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090046arch-dtbs:
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090047 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090048
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000049ifeq ($(CONFIG_SPL_BUILD),y)
50obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
51# support "out-of-tree" build for dtb-spl
52$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
53 $(call if_changed_dep,as_o_S)
54else
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090055obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000056endif
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090057
Simon Glass53db2ee2020-12-22 19:30:13 -070058dtbs: $(obj)/dt.dtb \
Simon Glassde3e3722020-12-22 19:30:14 -070059 $(if $(CONFIG_SPL),spl/$(obj)/dt-spl.dtb) \
60 $(if $(CONFIG_TPL),tpl/$(obj)/dt-tpl.dtb)
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090061 @:
62
Simon Glass53db2ee2020-12-22 19:30:13 -070063clean-files := dt.dtb.S dt-spl.dtb.S dt-tpl.dtb.S
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090064
65# Let clean descend into dts directories
Lukas Auer17f2ffe2018-11-22 11:26:11 +010066subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts