mips: octeon: Add cvmx-helper-cfg.c
[pandora-u-boot.git] / Makefile
index 110296b..3fc9777 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 VERSION = 2021
-PATCHLEVEL = 01
+PATCHLEVEL = 04
 SUBLEVEL =
-EXTRAVERSION = -rc5
+EXTRAVERSION =
 NAME =
 
 # *DOCUMENTATION*
@@ -17,9 +17,13 @@ NAME =
 # o Look for make include files relative to root of kernel src
 MAKEFLAGS += -rR --include-dir=$(CURDIR)
 
-# Determine host architecture
+# Determine target architecture for the sandbox
 include include/host_arch.h
-MK_ARCH="${shell uname -m}"
+ifeq ("", "$(CROSS_COMPILE)")
+  MK_ARCH="${shell uname -m}"
+else
+  MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^\s*\([^\/]*\/\)*\([^-]*\)-\S*/\2/p'}"
+endif
 unexport HOST_ARCH
 ifeq ("x86_64", $(MK_ARCH))
   export HOST_ARCH=$(HOST_ARCH_X86_64)
@@ -27,7 +31,7 @@ else ifneq (,$(findstring $(MK_ARCH), "i386" "i486" "i586" "i686"))
   export HOST_ARCH=$(HOST_ARCH_X86)
 else ifneq (,$(findstring $(MK_ARCH), "aarch64" "armv8l"))
   export HOST_ARCH=$(HOST_ARCH_AARCH64)
-else ifeq ("armv7l", $(MK_ARCH))
+else ifneq (,$(findstring $(MK_ARCH), "arm" "armv7" "armv7l"))
   export HOST_ARCH=$(HOST_ARCH_ARM)
 else ifeq ("riscv32", $(MK_ARCH))
   export HOST_ARCH=$(HOST_ARCH_RISCV32)
@@ -324,11 +328,6 @@ HOSTCC       = $(call os_x_before, 10, 5, "cc", "gcc")
 KBUILD_HOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
 KBUILD_HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
 
-# since Lion (10.7) ASLR is on by default, but we use linker generated lists
-# in some host tools which is a problem then ... so disable ASLR for these
-# tools
-KBUILD_HOSTLDFLAGS += $(call os_x_before, 10, 7, "", "-Xlinker -no_pie")
-
 # macOS Mojave (10.14.X) 
 # Undefined symbols for architecture x86_64: "_PyArg_ParseTuple"
 KBUILD_HOSTLDFLAGS += $(call os_x_after, 10, 14, "-lpython -dynamclib", "")
@@ -677,7 +676,12 @@ else
 KBUILD_CFLAGS  += -O2
 endif
 
+ifeq ($(CONFIG_STACKPROTECTOR),y)
+KBUILD_CFLAGS += $(call cc-option,-fstack-protector-strong)
+CFLAGS_EFI += $(call cc-option,-fno-stack-protector)
+else
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+endif
 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
 
 # disable stringop warnings in gcc 8+
@@ -792,6 +796,7 @@ libs-y += drivers/usb/dwc3/
 libs-y += drivers/usb/common/
 libs-y += drivers/usb/emul/
 libs-y += drivers/usb/eth/
+libs-$(CONFIG_USB_DEVICE) += drivers/usb/gadget/
 libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/
 libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/udc/
 libs-y += drivers/usb/host/
@@ -885,7 +890,7 @@ cmd_static_rela = \
        tools/relocate-rela $(3) $(4) $$start $$end
 else
 quiet_cmd_static_rela =
-cmd_static_rela = true
+cmd_static_rela =
 endif
 
 # Always append INPUTS so that arch config.mk's can add custom ones
@@ -1016,6 +1021,33 @@ quiet_cmd_cfgcheck = CFGCHK  $2
 cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
                $(srctree)/scripts/config_whitelist.txt $(srctree)
 
+# Concat the value of all the CONFIGs (result is 'y' or 'yy', etc. )
+got = $(foreach cfg,$(1),$($(cfg)))
+
+# expected value 'y for each one
+expect = $(foreach cfg,$(1),y)
+
+# Show a deprecation message
+# Args:
+# 1: List of CONFIG_DM_... to migrate to (e.g. "CONFIG_DM_MMC CONFIG_BLK")
+# 2: Name of component (e.g . "Ethernet drivers")
+# 3: Release deadline (e.g. "v202.07")
+# 4: Condition to require before checking (e.g. "$(CONFIG_NET)")
+# Note: Script avoids bash construct, hence the strange double 'if'
+# (patches welcome!)
+define deprecated
+       @if [ -n "$(strip $(4))" ]; then if [ "$(got)" != "$(expect)" ]; then \
+               echo >&2 "===================== WARNING ======================"; \
+               echo >&2 "This board does not use $(firstword $(1)) (Driver Model"; \
+               echo >&2 "for $(2)). Please update the board to use"; \
+               echo >&2 "$(firstword $(1)) before the $(3) release. Failure to"; \
+               echo >&2 "update by the deadline may result in board removal."; \
+               echo >&2 "See doc/driver-model/migration.rst for more info."; \
+               echo >&2 "===================================================="; \
+       fi; fi
+
+endef
+
 PHONY += inputs
 inputs: $(INPUTS-y)
 
@@ -1030,80 +1062,6 @@ endif
 
 ifeq ($(CONFIG_DEPRECATED),y)
        $(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.")
-ifeq ($(CONFIG_SPI),y)
-ifneq ($(CONFIG_DM_SPI)$(CONFIG_OF_CONTROL),yy)
-       $(warning "The relevant config item with associated code will remove in v2019.07 release.")
-endif
-endif
-endif
-ifneq ($(CONFIG_DM),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM. CONFIG_DM will be"
-       @echo >&2 "compulsory starting with the v2020.01 release."
-       @echo >&2 "Failure to update may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-ifeq ($(CONFIG_MMC),y)
-ifneq ($(CONFIG_DM_MMC)$(CONFIG_BLK),yy)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM_MMC. Please update"
-       @echo >&2 "the board to use CONFIG_DM_MMC before the v2019.04 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
-ifeq ($(CONFIG_USB),y)
-ifneq ($(CONFIG_DM_USB)$(CONFIG_OF_CONTROL)$(CONFIG_BLK),yyy)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM_USB. Please update"
-       @echo >&2 "the board to use CONFIG_DM_USB before the v2019.07 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
-ifeq ($(CONFIG_MVSATA_IDE),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does use CONFIG_MVSATA_IDE which is not"
-       @echo >&2 "ported to driver-model (DM) yet. Please update the storage"
-       @echo >&2 "controller driver to use CONFIG_AHCI before the v2019.07"
-       @echo >&2 "release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-ifeq ($(CONFIG_LIBATA),y)
-ifneq ($(CONFIG_AHCI),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does use CONFIG_LIBATA but has CONFIG_AHCI not"
-       @echo >&2 "enabled. Please update the storage controller driver to use"
-       @echo >&2 "CONFIG_AHCI before the v2019.07 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
-ifeq ($(CONFIG_PCI),y)
-ifneq ($(CONFIG_DM_PCI),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM_PCI Please update"
-       @echo >&2 "the board to use CONFIG_DM_PCI before the v2019.07 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
-ifneq ($(CONFIG_LCD)$(CONFIG_VIDEO),)
-ifneq ($(CONFIG_DM_VIDEO),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM_VIDEO Please update"
-       @echo >&2 "the board to use CONFIG_DM_VIDEO before the v2019.07 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
 endif
 ifeq ($(CONFIG_OF_EMBED),y)
        @echo >&2 "===================== WARNING ======================"
@@ -1113,38 +1071,6 @@ ifeq ($(CONFIG_OF_EMBED),y)
        @echo >&2 "See doc/README.fdt-control for more info."
        @echo >&2 "===================================================="
 endif
-ifeq ($(CONFIG_SPI_FLASH),y)
-ifneq ($(CONFIG_DM_SPI_FLASH)$(CONFIG_OF_CONTROL),yy)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM_SPI_FLASH. Please update"
-       @echo >&2 "the board to use CONFIG_SPI_FLASH before the v2019.07 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
-ifneq ($(CONFIG_WATCHDOG)$(CONFIG_HW_WATCHDOG),)
-ifneq ($(CONFIG_WDT),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_WDT (DM watchdog support)."
-       @echo >&2 "Please update the board to use CONFIG_WDT before the"
-       @echo >&2 "v2019.10 release."
-       @echo >&2 "Failure to update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
-ifneq ($(CONFIG_NET),)
-ifneq ($(CONFIG_DM_ETH),y)
-       @echo >&2 "===================== WARNING ======================"
-       @echo >&2 "This board does not use CONFIG_DM_ETH (Driver Model"
-       @echo >&2 "for Ethernet drivers). Please update the board to use"
-       @echo >&2 "CONFIG_DM_ETH before the v2020.07 release. Failure to"
-       @echo >&2 "update by the deadline may result in board removal."
-       @echo >&2 "See doc/driver-model/migration.rst for more info."
-       @echo >&2 "===================================================="
-endif
-endif
 ifneq ($(CONFIG_SPL_FIT_GENERATOR),)
        @echo >&2 "===================== WARNING ======================"
        @echo >&2 "This board uses CONFIG_SPL_FIT_GENERATOR. Please migrate"
@@ -1152,6 +1078,27 @@ ifneq ($(CONFIG_SPL_FIT_GENERATOR),)
        @echo >&2 "arch-specific scripts with no tests."
        @echo >&2 "===================================================="
 endif
+ifneq ($(CONFIG_DM),y)
+       @echo >&2 "===================== WARNING ======================"
+       @echo >&2 "This board does not use CONFIG_DM. CONFIG_DM will be"
+       @echo >&2 "compulsory starting with the v2020.01 release."
+       @echo >&2 "Failure to update may result in board removal."
+       @echo >&2 "See doc/driver-model/migration.rst for more info."
+       @echo >&2 "===================================================="
+endif
+       $(call deprecated,CONFIG_DM_MMC CONFIG_BLK,MMC,v2019.04,$(CONFIG_MMC))
+       $(call deprecated,CONFIG_DM_USB CONFIG_OF_CONTROL CONFIG_BLK,\
+               USB,v2019.07,$(CONFIG_USB))
+       $(call deprecated,CONFIG_AHCI,AHCI,v2019.07, $(CONFIG_LIBATA))
+       $(call deprecated,CONFIG_DM_PCI,PCI,v2019.07,$(CONFIG_PCI))
+       $(call deprecated,CONFIG_DM_VIDEO,video,v2019.07,\
+               $(CONFIG_LCD)$(CONFIG_VIDEO))
+       $(call deprecated,CONFIG_DM_SPI_FLASH,SPI flash,v2019.07,\
+               $(CONFIG_SPI_FLASH))
+       $(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\
+               $(CONFIG_WATCHDOG)$(CONFIG_HW_WATCHDOG))
+       $(call deprecated,CONFIG_DM_ETH,Ethernet drivers,v2020.07,$(CONFIG_NET))
+       $(call deprecated,CONFIG_DM_I2C,I2C drivers,v2022.04,$(CONFIG_I2C))
        @# Check that this build does not use CONFIG options that we do not
        @# know about unless they are in Kconfig. All the existing CONFIG
        @# options are whitelisted, so new ones should not be added.
@@ -1263,11 +1210,6 @@ OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
                $(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec) \
                $(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR),-R .bootpg -R .resetvec)
 
-OBJCOPYFLAGS_u-boot-spl.hex = $(OBJCOPYFLAGS_u-boot.hex)
-
-spl/u-boot-spl.hex: spl/u-boot-spl FORCE
-       $(call if_changed,objcopy)
-
 binary_size_check: u-boot-nodtb.bin FORCE
        @file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \
        map_size=$(shell cat u-boot.map | \
@@ -1312,7 +1254,11 @@ endif
 shell_cmd = { $(call echo-cmd,$(1)) $(cmd_$(1)); }
 
 quiet_cmd_objcopy_uboot = OBJCOPY $@
+ifdef cmd_static_rela
 cmd_objcopy_uboot = $(cmd_objcopy) && $(call shell_cmd,static_rela,$<,$@,$(CONFIG_SYS_TEXT_BASE)) || { rm -f $@; false; }
+else
+cmd_objcopy_uboot = $(cmd_objcopy)
+endif
 
 u-boot-nodtb.bin: u-boot FORCE
        $(call if_changed,objcopy_uboot)
@@ -1326,7 +1272,13 @@ u-boot.ldr:      u-boot
 # binman
 # ---------------------------------------------------------------------------
 # Use 'make BINMAN_DEBUG=1' to enable debugging
+# Use 'make BINMAN_VERBOSE=3' to set vebosity level
 default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
+
+# Tell binman whether we have a devicetree for SPL and TPL
+have_spl_dt := $(if $(CONFIG_SPL_OF_PLATDATA),,$(CONFIG_SPL_OF_CONTROL))
+have_tpl_dt := $(if $(CONFIG_TPL_OF_PLATDATA),,$(CONFIG_TPL_OF_CONTROL))
+
 quiet_cmd_binman = BINMAN  $@
 cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
                 --toolpath $(objtree)/tools \
@@ -1337,6 +1289,9 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
                -a atf-bl31-path=${BL31} \
                -a default-dt=$(default_dt) \
                -a scp-path=$(SCP) \
+               -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
+               -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
+               -a spl-dtb=$(have_spl_dt) -a tpl-dtb=$(have_tpl_dt) \
                $(BINMAN_$(@F))
 
 OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
@@ -1382,6 +1337,7 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
        -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
        -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
        -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
+       $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(DEVICE_TREE))) \
        $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) \
        $(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst ",,$(CONFIG_OF_OVERLAY_LIST)))
 else
@@ -1542,7 +1498,10 @@ flash.bin: spl/u-boot-spl.bin u-boot.itb FORCE
 endif
 endif
 
-u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE
+u-boot.uim: u-boot.bin FORCE
+       $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
+
+u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
        $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
 
 MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE)
@@ -1583,7 +1542,10 @@ u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE
 
 ifneq ($(CONFIG_ARCH_SOCFPGA),)
 quiet_cmd_gensplx4 = GENSPLX4 $@
-cmd_gensplx4 = cat     spl/u-boot-spl.sfp spl/u-boot-spl.sfp   \
+cmd_gensplx4 = $(OBJCOPY) -I binary -O binary --gap-fill=0x0           \
+                       --pad-to=$(CONFIG_SPL_PAD_TO)                   \
+                       spl/u-boot-spl.sfp spl/u-boot-spl.sfp &&        \
+               cat     spl/u-boot-spl.sfp spl/u-boot-spl.sfp           \
                        spl/u-boot-spl.sfp spl/u-boot-spl.sfp > $@ || { rm -f $@; false; }
 spl/u-boot-splx4.sfp: spl/u-boot-spl.sfp FORCE
        $(call if_changed,gensplx4)
@@ -1720,6 +1682,9 @@ u-boot-elf.lds: arch/u-boot-elf.lds prepare FORCE
 
 ifeq ($(CONFIG_SPL),y)
 spl/u-boot-spl-mtk.bin: spl/u-boot-spl
+
+u-boot-mtk.bin: u-boot-with-spl.bin
+       $(call if_changed,copy)
 else
 MKIMAGEFLAGS_u-boot-mtk.bin = -T mtk_image \
        -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
@@ -1846,9 +1811,13 @@ prepare: prepare0
 # Generate some files
 # ---------------------------------------------------------------------------
 
+# Use sed to remove leading zeros from PATCHLEVEL to avoid using octal numbers
 define filechk_version.h
        (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \
        echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \
+       echo \#define U_BOOT_VERSION_NUM $(VERSION); \
+       echo \#define U_BOOT_VERSION_NUM_PATCH $$(echo $(PATCHLEVEL) | \
+               sed -e "s/^0*//"); \
        echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \
        echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; )
 endef
@@ -1924,6 +1893,12 @@ spl/u-boot-spl.bin: spl/u-boot-spl
        @:
        $(SPL_SIZE_CHECK)
 
+spl/u-boot-spl-dtb.bin: spl/u-boot-spl
+       @:
+
+spl/u-boot-spl-dtb.hex: spl/u-boot-spl
+       @:
+
 spl/u-boot-spl: tools prepare \
                $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \
                $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)