colibri_vf_defconfig: enable part cmd
[oweals/u-boot.git] / scripts / Makefile.spl
index 56dbbe127baa3866795a14b120c46e2123d9aa38..e6d56a1286f8833fbbc09a5824df761f21bbf6fc 100644 (file)
@@ -22,6 +22,8 @@ include $(srctree)/scripts/Kbuild.include
 -include include/config/auto.conf
 -include $(obj)/include/autoconf.mk
 
+UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
+
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
@@ -71,7 +73,11 @@ HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makef
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
 
+ifeq ($(CONFIG_TPL_BUILD),y)
+libs-$(CONFIG_TPL_FRAMEWORK) += common/spl/
+else
 libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
+endif
 libs-y += common/init/
 
 # Special handling for a few options which support SPL/TPL
@@ -88,6 +94,7 @@ endif
 
 libs-y += drivers/
 libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/dwc3/
+libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/cdns3/
 libs-y += dts/
 libs-y += fs/
 libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
@@ -228,7 +235,13 @@ ifeq ($(CONFIG_SYS_SOC),"at91")
 ALL-y  += $(obj)/boot.bin
 endif
 
-ALL-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-16bit-spl.bin
+ifdef CONFIG_TPL_BUILD
+ALL-$(CONFIG_TPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-tpl.bin \
+       $(obj)/u-boot-x86-reset16-tpl.bin
+else
+ALL-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-spl.bin \
+       $(obj)/u-boot-x86-reset16-spl.bin
+endif
 
 ALL-$(CONFIG_ARCH_ZYNQ)                += $(obj)/boot.bin
 ALL-$(CONFIG_ARCH_ZYNQMP)      += $(obj)/boot.bin
@@ -253,8 +266,20 @@ else
 FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit
 endif
 
+# Build the .dtb file if:
+#   - we are not using OF_PLATDATA
+#   - we are using OF_CONTROL
+#   - we have either OF_SEPARATE or OF_HOSTFILE
+build_dtb :=
+ifeq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA),)
+ifneq ($(CONFIG_$(SPL_TPL_)OF_CONTROL),)
+ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_OF_HOSTFILE),y)
+build_dtb := y
+endif
+endif
+endif
 
-ifeq ($(CONFIG_$(SPL_TPL_)OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy)
+ifneq ($(build_dtb),)
 $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
                $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
                $(FINAL_DTB_CONTAINER)  FORCE
@@ -284,10 +309,11 @@ quiet_cmd_dtoch = DTOC H  $@
 cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct
 
 quiet_cmd_plat = PLAT    $@
-cmd_plat = $(CC) $(c_flags) -c $< -o $@
+cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
 
+targets += $(obj)/dts/dt-platdata.o
 $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \
-               include/generated/dt-structs-gen.h
+               include/generated/dt-structs-gen.h prepare FORCE
        $(call if_changed,plat)
 
 PHONY += dts_dir
@@ -316,13 +342,25 @@ quiet_cmd_objcopy = OBJCOPY $@
 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 
 OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary \
-               $(if $(CONFIG_SPL_X86_16BIT_INIT),-R .start16 -R .resetvec)
+               $(if $(CONFIG_$(SPL_TPL_)X86_16BIT_INIT),-R .start16 -R .resetvec)
 
 $(obj)/$(SPL_BIN)-nodtb.bin: $(obj)/$(SPL_BIN) FORCE
        $(call if_changed,objcopy)
 
-OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j .start16 -j .resetvec
-$(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE
+OBJCOPYFLAGS_u-boot-x86-start16-spl.bin := -O binary -j .start16
+$(obj)/u-boot-x86-start16-spl.bin: $(obj)/u-boot-spl FORCE
+       $(call if_changed,objcopy)
+
+OBJCOPYFLAGS_u-boot-x86-start16-tpl.bin := -O binary -j .start16
+$(obj)/u-boot-x86-start16-tpl.bin: $(obj)/u-boot-tpl FORCE
+       $(call if_changed,objcopy)
+
+OBJCOPYFLAGS_u-boot-x86-reset16-spl.bin := -O binary -j .resetvec
+$(obj)/u-boot-x86-reset16-spl.bin: $(obj)/u-boot-spl FORCE
+       $(call if_changed,objcopy)
+
+OBJCOPYFLAGS_u-boot-x86-reset16-tpl.bin := -O binary -j .resetvec
+$(obj)/u-boot-x86-reset16-tpl.bin: $(obj)/u-boot-tpl FORCE
        $(call if_changed,objcopy)
 
 LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
@@ -372,7 +410,7 @@ $(obj)/u-boot-spl-mtk.bin: $(obj)/u-boot-spl.bin FORCE
 # Rule to link u-boot-spl
 # May be overridden by arch/$(ARCH)/config.mk
 quiet_cmd_u-boot-spl ?= LD      $@
-      cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
+      cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_$(@F)) \
                       $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
                       $(patsubst $(obj)/%,%,$(u-boot-spl-main))  \
                       $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
@@ -386,9 +424,13 @@ $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \
 $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
 
 PHONY += $(u-boot-spl-dirs)
-$(u-boot-spl-dirs): $(u-boot-spl-platdata)
+$(u-boot-spl-dirs): $(u-boot-spl-platdata) prepare
        $(Q)$(MAKE) $(build)=$@
 
+PHONY += prepare
+prepare:
+       $(Q)$(MAKE) $(build)=$(obj)/.
+
 quiet_cmd_cpp_lds = LDS     $@
 cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
                -D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
@@ -417,11 +459,14 @@ dtbs:
 # information in a variable so we can use it in if_changed and friends.
 .PHONY: $(PHONY)
 
-SHRUNK_ARCH_DTB = $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+SPL_OF_LIST_TARGETS = $(patsubst %,dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
+SHRUNK_ARCH_DTB = $(addprefix $(obj)/,$(SPL_OF_LIST_TARGETS))
 .SECONDEXPANSION:
-$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@)
+$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@) dts_dir
        $(call if_changed,fdtgrep)
 
+targets += $(SPL_OF_LIST_TARGETS)
+
 MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
        -n "Multi DTB fit image for $(SPL_BIN)" -E \
        $(patsubst %,-b %,$(SHRUNK_ARCH_DTB))