blob: d6c2c9daf31d64b6f26ef63af04a5e851f1042ab [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
Sumit Garge3a98292024-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 Glassd18926a2014-06-12 07:24:43 -060023ifneq ($(EXT_DTB),)
24DTB := $(EXT_DTB)
Simon Glass63b4b5b2014-06-02 22:04:50 -060025else
Sumit Garge3a98292024-02-22 15:06:01 +053026DTB := $(dt_dir)/$(DEVICE_TREE).dtb
Simon Glass63b4b5b2014-06-02 22:04:50 -060027endif
Simon Glassbbb0b122011-10-15 05:48:21 +000028
Simon Glassc7674fc2020-12-22 19:30:15 -070029$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
Simon Glassde3e3722020-12-22 19:30:14 -070030 mkdir -p $(dir $@)
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000031 $(call if_changed,fdtgrep)
32
Anatolij Gustschin43b6e382020-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 Yamada3284c8b2014-02-05 11:28:27 +090037$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamadab9d1dbd2014-06-04 10:11:18 +090038 $(call if_changed,shipped)
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010039endif
Simon Glassbbb0b122011-10-15 05:48:21 +000040
Simon Glassc7674fc2020-12-22 19:30:15 -070041targets += dt.dtb
Simon Glassbbb0b122011-10-15 05:48:21 +000042
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090043$(DTB): arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090044 $(Q)test -e $@ || ( \
45 echo >&2; \
Florian Klink1d55eb12020-12-27 21:34:43 +010046 echo >&2 "Device Tree Source ($@) is not correctly specified."; \
Masahiro Yamada3284c8b2014-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 Warren2737dfe2019-02-26 12:20:25 -070052PHONY += arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090053arch-dtbs:
Sumit Garge3a98292024-02-22 15:06:01 +053054 $(Q)$(MAKE) $(build)=$(dt_dir) dtbs
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090055
Goldschmidt Simon9bd76b82017-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 Yamada6ab6b2a2014-02-05 11:28:25 +090062obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000063endif
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090064
Simon Glassc7674fc2020-12-22 19:30:15 -070065# Target for U-Boot proper
66dtbs: $(obj)/dt.dtb
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090067 @:
68
Simon Glassc7674fc2020-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 Yamada3284c8b2014-02-05 11:28:27 +090074
75# Let clean descend into dts directories
Tobias Deiminger3d3eeae2023-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 Garge3a98292024-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)