blob: cb311138295914f2447472cbb549194538a804a4 [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 Glassc7674fc2020-12-22 19:30:15 -070019$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
Simon Glassde3e3722020-12-22 19:30:14 -070020 mkdir -p $(dir $@)
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000021 $(call if_changed,fdtgrep)
22
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010023ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
24$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
25 $(call if_changed,fdt_rm_props)
26else
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090027$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamadab9d1dbd2014-06-04 10:11:18 +090028 $(call if_changed,shipped)
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010029endif
Simon Glassbbb0b122011-10-15 05:48:21 +000030
Simon Glassc7674fc2020-12-22 19:30:15 -070031targets += dt.dtb
Simon Glassbbb0b122011-10-15 05:48:21 +000032
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090033$(DTB): arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090034 $(Q)test -e $@ || ( \
35 echo >&2; \
Florian Klink1d55eb12020-12-27 21:34:43 +010036 echo >&2 "Device Tree Source ($@) is not correctly specified."; \
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090037 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
38 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
39 echo >&2; \
40 /bin/false)
41
Stephen Warren2737dfe2019-02-26 12:20:25 -070042PHONY += arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090043arch-dtbs:
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090044 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090045
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000046ifeq ($(CONFIG_SPL_BUILD),y)
47obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
48# support "out-of-tree" build for dtb-spl
49$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
50 $(call if_changed_dep,as_o_S)
51else
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090052obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000053endif
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090054
Simon Glassc7674fc2020-12-22 19:30:15 -070055# Target for U-Boot proper
56dtbs: $(obj)/dt.dtb
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090057 @:
58
Simon Glassc7674fc2020-12-22 19:30:15 -070059# Target for SPL/TPL
60spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
61 @:
62
63clean-files := dt.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