blob: d6c2c9daf31d64b6f26ef63af04a5e851f1042ab [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
Simon Glassc3b0de42014-06-12 07:24:43 -060023ifneq ($(EXT_DTB),)
24DTB := $(EXT_DTB)
Simon Glass67bce6b2014-06-02 22:04:50 -060025else
Sumit Gargf7e52842024-02-22 15:06:01 +053026DTB := $(dt_dir)/$(DEVICE_TREE).dtb
Simon Glass67bce6b2014-06-02 22:04:50 -060027endif
Stephen Warrenc198ef72013-07-24 10:09:19 -070028
Simon Glass6886c722020-12-22 19:30:15 -070029$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
Simon Glassc490de82020-12-22 19:30:14 -070030 mkdir -p $(dir $@)
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000031 $(call if_changed,fdtgrep)
32
Anatolij Gustschin08568342020-01-12 15:57:42 +010033ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
34$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
35 $(call if_changed,fdt_rm_props)
36else
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090037$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamada97e101c2014-06-04 10:11:18 +090038 $(call if_changed,shipped)
Anatolij Gustschin08568342020-01-12 15:57:42 +010039endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000040
Simon Glass6886c722020-12-22 19:30:15 -070041targets += dt.dtb
Simon Glass38d6b8d2011-10-15 05:48:21 +000042
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090043$(DTB): arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090044 $(Q)test -e $@ || ( \
45 echo >&2; \
Florian Klinkb0c2a102020-12-27 21:34:43 +010046 echo >&2 "Device Tree Source ($@) is not correctly specified."; \
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090047 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
48 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
49 echo >&2; \
50 /bin/false)
51
Stephen Warrend2d742c2019-02-26 12:20:25 -070052PHONY += arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090053arch-dtbs:
Sumit Gargf7e52842024-02-22 15:06:01 +053054 $(Q)$(MAKE) $(build)=$(dt_dir) dtbs
Simon Glass38d6b8d2011-10-15 05:48:21 +000055
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000056ifeq ($(CONFIG_SPL_BUILD),y)
57obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
58# support "out-of-tree" build for dtb-spl
59$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
60 $(call if_changed_dep,as_o_S)
61else
Masahiro Yamada43c08932014-02-05 11:28:25 +090062obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000063endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000064
Simon Glass6886c722020-12-22 19:30:15 -070065# Target for U-Boot proper
66dtbs: $(obj)/dt.dtb
Masahiro Yamada43c08932014-02-05 11:28:25 +090067 @:
Simon Glass38d6b8d2011-10-15 05:48:21 +000068
Simon Glass6886c722020-12-22 19:30:15 -070069# Target for SPL/TPL
70spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
71 @:
72
73clean-files := dt.dtb.S
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090074
75# Let clean descend into dts directories
Tobias Deiminger48cb5a12023-06-20 00:41:05 +020076subdir- += ../arch/arc/dts ../arch/arm/dts ../arch/m68k/dts ../arch/microblaze/dts \
77 ../arch/mips/dts ../arch/nios2/dts ../arch/powerpc/dts ../arch/riscv/dts \
Sumit Gargf7e52842024-02-22 15:06:01 +053078 ../arch/sandbox/dts ../arch/sh/dts ../arch/x86/dts ../arch/xtensa/dts \
79 ./upstream/src/arm64 ./upstream/src/$(ARCH)