blob: 86bf8dc215603c3c02930e9c642d7dc06ce715fc [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
Sumit Gargf7e52842024-02-22 15:06:01 +053013ifeq ($(CONFIG_OF_UPSTREAM),y)
14ifeq ($(CONFIG_ARM64),y)
15dt_dir := dts/upstream/src/arm64
16else
17dt_dir := dts/upstream/src/$(ARCH)
18endif
19else
20dt_dir := arch/$(ARCH)/dts
21endif
22
Marek Vasutb5abbf82024-10-17 03:08:40 +020023ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
24local_dtbos := local-dtbos
25else
26local_dtbos :=
27endif
28
Simon Glassc3b0de42014-06-12 07:24:43 -060029ifneq ($(EXT_DTB),)
30DTB := $(EXT_DTB)
Simon Glass67bce6b2014-06-02 22:04:50 -060031else
Sumit Gargf7e52842024-02-22 15:06:01 +053032DTB := $(dt_dir)/$(DEVICE_TREE).dtb
Simon Glass67bce6b2014-06-02 22:04:50 -060033endif
Stephen Warrenc198ef72013-07-24 10:09:19 -070034
Simon Glass6886c722020-12-22 19:30:15 -070035$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
Simon Glassc490de82020-12-22 19:30:14 -070036 mkdir -p $(dir $@)
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000037 $(call if_changed,fdtgrep)
38
Anatolij Gustschin08568342020-01-12 15:57:42 +010039ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
40$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
41 $(call if_changed,fdt_rm_props)
42else
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090043$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamada97e101c2014-06-04 10:11:18 +090044 $(call if_changed,shipped)
Anatolij Gustschin08568342020-01-12 15:57:42 +010045endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000046
Simon Glass6886c722020-12-22 19:30:15 -070047targets += dt.dtb
Simon Glass38d6b8d2011-10-15 05:48:21 +000048
Marek Vasutb5abbf82024-10-17 03:08:40 +020049$(DTB): arch-dtbs $(local_dtbos)
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090050 $(Q)test -e $@ || ( \
51 echo >&2; \
Florian Klinkb0c2a102020-12-27 21:34:43 +010052 echo >&2 "Device Tree Source ($@) is not correctly specified."; \
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090053 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
54 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
55 echo >&2; \
56 /bin/false)
57
Stephen Warrend2d742c2019-02-26 12:20:25 -070058PHONY += arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090059arch-dtbs:
Sumit Gargf7e52842024-02-22 15:06:01 +053060 $(Q)$(MAKE) $(build)=$(dt_dir) dtbs
Simon Glass38d6b8d2011-10-15 05:48:21 +000061
Marek Vasutb5abbf82024-10-17 03:08:40 +020062ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),)
63PHONY += local-dtbos
64local-dtbos:
65 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbos
66endif
67
Simon Glass0e84d962024-09-29 19:49:50 -060068ifeq ($(CONFIG_XPL_BUILD),y)
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000069obj-$(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)
73else
Masahiro Yamada43c08932014-02-05 11:28:25 +090074obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000075endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000076
Simon Glass6886c722020-12-22 19:30:15 -070077# Target for U-Boot proper
78dtbs: $(obj)/dt.dtb
Masahiro Yamada43c08932014-02-05 11:28:25 +090079 @:
Simon Glass38d6b8d2011-10-15 05:48:21 +000080
Simon Glass6886c722020-12-22 19:30:15 -070081# Target for SPL/TPL
82spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
83 @:
84
85clean-files := dt.dtb.S
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090086
87# Let clean descend into dts directories
Tobias Deiminger48cb5a12023-06-20 00:41:05 +020088subdir- += ../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 \
Sumit Gargf7e52842024-02-22 15:06:01 +053090 ../arch/sandbox/dts ../arch/sh/dts ../arch/x86/dts ../arch/xtensa/dts \
91 ./upstream/src/arm64 ./upstream/src/$(ARCH)