2011-10-15 05:48:21 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2011 The Chromium OS Authors.
|
|
|
|
#
|
2013-07-08 07:37:19 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2011-10-15 05:48:21 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
|
|
|
|
# enabled. See doc/README.fdt-control for more details.
|
|
|
|
|
2014-02-05 02:28:25 +00:00
|
|
|
DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
|
|
|
|
ifeq ($(DEVICE_TREE),)
|
2014-02-05 02:28:27 +00:00
|
|
|
DEVICE_TREE := unset
|
2014-02-05 02:28:25 +00:00
|
|
|
endif
|
2013-07-24 17:09:19 +00:00
|
|
|
|
2017-03-16 04:11:31 +00:00
|
|
|
ARCH_PATH := arch/$(ARCH)/dts
|
|
|
|
dtb_depends := arch-dtbs
|
|
|
|
|
2014-06-12 13:24:43 +00:00
|
|
|
ifneq ($(EXT_DTB),)
|
|
|
|
DTB := $(EXT_DTB)
|
2014-06-03 04:04:50 +00:00
|
|
|
else
|
2017-03-16 04:11:31 +00:00
|
|
|
DTB := $(ARCH_PATH)/$(DEVICE_TREE).dtb
|
|
|
|
dtb_depends += $(DTB:.dtb=.dts)
|
2014-06-03 04:04:50 +00:00
|
|
|
endif
|
2013-07-24 17:09:19 +00:00
|
|
|
|
2017-11-21 12:29:56 +00:00
|
|
|
# Pass the original device tree file through fdtgrep twice. The first pass
|
|
|
|
# removes any unwanted nodes (i.e. those which don't have the
|
|
|
|
# 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
|
|
|
|
# pass removes various unused properties from the remaining nodes.
|
|
|
|
# The output is typically a much smaller device tree file.
|
|
|
|
ifeq ($(CONFIG_TPL_BUILD),y)
|
|
|
|
fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
|
|
|
|
else
|
|
|
|
fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
|
|
|
|
endif
|
|
|
|
quiet_cmd_fdtgrep = FDTGREP $@
|
|
|
|
cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \
|
|
|
|
-n /chosen -n /config -O dtb | \
|
|
|
|
$(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
|
|
|
|
$(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
|
|
|
|
|
|
|
|
$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
|
|
|
|
$(call if_changed,fdtgrep)
|
|
|
|
|
2014-02-05 02:28:27 +00:00
|
|
|
$(obj)/dt.dtb: $(DTB) FORCE
|
2014-06-04 01:11:18 +00:00
|
|
|
$(call if_changed,shipped)
|
2011-10-15 05:48:21 +00:00
|
|
|
|
2017-11-21 12:29:56 +00:00
|
|
|
targets += dt.dtb dt-spl.dtb
|
2011-10-15 05:48:21 +00:00
|
|
|
|
2017-03-16 04:11:31 +00:00
|
|
|
$(DTB): $(dtb_depends)
|
|
|
|
ifeq ($(EXT_DTB),)
|
|
|
|
$(Q)$(MAKE) $(build)=$(ARCH_PATH) $@
|
|
|
|
endif
|
2014-02-05 02:28:27 +00:00
|
|
|
$(Q)test -e $@ || ( \
|
|
|
|
echo >&2; \
|
|
|
|
echo >&2 "Device Tree Source is not correctly specified."; \
|
|
|
|
echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
|
|
|
|
echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
|
|
|
|
echo >&2; \
|
|
|
|
/bin/false)
|
|
|
|
|
|
|
|
arch-dtbs:
|
2017-03-16 04:11:31 +00:00
|
|
|
$(Q)$(MAKE) $(build)=$(ARCH_PATH) dtbs
|
2011-10-15 05:48:21 +00:00
|
|
|
|
2017-11-21 12:29:56 +00:00
|
|
|
.SECONDARY: $(obj)/dt.dtb.S $(obj)/dt-spl.dtb.S
|
2011-10-15 05:48:21 +00:00
|
|
|
|
2017-11-21 12:29:56 +00:00
|
|
|
|
|
|
|
ifeq ($(CONFIG_SPL_BUILD),y)
|
|
|
|
obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
|
|
|
|
# support "out-of-tree" build for dtb-spl
|
|
|
|
$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
|
|
|
|
$(call if_changed_dep,as_o_S)
|
|
|
|
else
|
2014-02-05 02:28:25 +00:00
|
|
|
obj-$(CONFIG_OF_EMBED) := dt.dtb.o
|
2017-11-21 12:29:56 +00:00
|
|
|
endif
|
2011-10-15 05:48:21 +00:00
|
|
|
|
2017-11-21 12:29:56 +00:00
|
|
|
dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb
|
2014-02-05 02:28:25 +00:00
|
|
|
@:
|
2011-10-15 05:48:21 +00:00
|
|
|
|
2017-11-21 12:29:56 +00:00
|
|
|
clean-files := dt.dtb.S dt-spl.dtb.S
|
2014-02-05 02:28:27 +00:00
|
|
|
|
|
|
|
# Let clean descend into dts directories
|
2016-01-23 18:50:02 +00:00
|
|
|
subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts
|