瀏覽代碼

Merge tag 'dm-pull-28jul20' of git://git.denx.de/u-boot-dm

Use binman instead of one of the Rockchip build scripts
Refactor to allow any arch to create SPI-flash images
New button uclass
Tom Rini 3 年之前
父節點
當前提交
719f42190d
共有 100 個文件被更改,包括 760 次插入268 次删除
  1. 26 3
      Kconfig
  2. 76 93
      Makefile
  3. 1 0
      arch/Kconfig
  4. 5 5
      arch/arm/config.mk
  5. 25 0
      arch/arm/dts/rk3288-u-boot.dtsi
  6. 4 0
      arch/arm/dts/rk3399-gru-u-boot.dtsi
  7. 1 1
      arch/arm/dts/rk3399-gru.dtsi
  8. 27 0
      arch/arm/dts/rk3399-u-boot.dtsi
  9. 64 0
      arch/arm/dts/rockchip-optee.dtsi
  10. 9 1
      arch/arm/dts/rockchip-u-boot.dtsi
  11. 1 1
      arch/arm/mach-at91/config.mk
  12. 1 1
      arch/arm/mach-davinci/config.mk
  13. 5 5
      arch/arm/mach-k3/config.mk
  14. 2 2
      arch/arm/mach-keystone/config.mk
  15. 14 14
      arch/arm/mach-omap2/config.mk
  16. 1 1
      arch/arm/mach-rmobile/Makefile
  17. 9 0
      arch/arm/mach-rockchip/Kconfig
  18. 0 84
      arch/arm/mach-rockchip/fit_spl_optee.sh
  19. 3 0
      arch/arm/mach-rockchip/rk3288/Kconfig
  20. 2 0
      arch/arm/mach-rockchip/rk3399/Kconfig
  21. 2 1
      arch/arm/mach-rockchip/spl.c
  22. 2 2
      arch/arm/mach-stm32mp/config.mk
  23. 1 1
      arch/arm/mach-tegra/Kconfig
  24. 1 1
      arch/powerpc/Kconfig
  25. 14 0
      arch/sandbox/dts/sandbox.dtsi
  26. 18 4
      arch/sandbox/dts/test.dts
  27. 10 1
      arch/x86/Kconfig
  28. 1 0
      arch/x86/cpu/quark/Kconfig
  29. 7 3
      arch/x86/dts/u-boot.dtsi
  30. 2 2
      board/BuR/brppt1/config.mk
  31. 2 2
      board/BuR/brppt2/config.mk
  32. 3 3
      board/BuR/brsmarc1/config.mk
  33. 1 1
      board/imgtec/boston/config.mk
  34. 1 1
      board/intel/edison/config.mk
  35. 11 0
      cmd/Kconfig
  36. 1 0
      cmd/Makefile
  37. 86 0
      cmd/button.c
  38. 1 1
      cmd/host.c
  39. 13 3
      common/image-fdt.c
  40. 1 0
      configs/am335x_evm_defconfig
  41. 1 0
      configs/am335x_hs_evm_defconfig
  42. 1 0
      configs/am335x_hs_evm_uart_defconfig
  43. 1 0
      configs/am43xx_evm_defconfig
  44. 1 0
      configs/am43xx_evm_rtconly_defconfig
  45. 1 0
      configs/am43xx_evm_usbhost_boot_defconfig
  46. 1 0
      configs/am43xx_hs_evm_defconfig
  47. 1 0
      configs/am57xx_evm_defconfig
  48. 1 0
      configs/am57xx_hs_evm_defconfig
  49. 1 0
      configs/am57xx_hs_evm_usb_defconfig
  50. 1 0
      configs/am65x_evm_a53_defconfig
  51. 1 0
      configs/am65x_evm_r5_defconfig
  52. 1 0
      configs/am65x_hs_evm_a53_defconfig
  53. 1 0
      configs/am65x_hs_evm_r5_defconfig
  54. 3 1
      configs/chromebook_bob_defconfig
  55. 1 0
      configs/chromebook_jerry_defconfig
  56. 2 0
      configs/chromebook_link64_defconfig
  57. 1 1
      configs/chromebook_samus_tpl_defconfig
  58. 2 0
      configs/chromebox_panther_defconfig
  59. 1 0
      configs/dh_imx6_defconfig
  60. 1 0
      configs/display5_defconfig
  61. 1 0
      configs/display5_factory_defconfig
  62. 1 0
      configs/dra7xx_evm_defconfig
  63. 1 0
      configs/dra7xx_hs_evm_defconfig
  64. 1 0
      configs/dra7xx_hs_evm_usb_defconfig
  65. 1 1
      configs/evb-rk3229_defconfig
  66. 1 1
      configs/evb-rk3288_defconfig
  67. 1 0
      configs/imx6qdl_icore_mipi_defconfig
  68. 1 0
      configs/imx6qdl_icore_mmc_defconfig
  69. 1 0
      configs/imx6qdl_icore_rqs_defconfig
  70. 1 0
      configs/j721e_evm_a72_defconfig
  71. 1 0
      configs/j721e_evm_r5_defconfig
  72. 1 0
      configs/j721e_hs_evm_a72_defconfig
  73. 1 0
      configs/j721e_hs_evm_r5_defconfig
  74. 1 0
      configs/ls1046ardb_qspi_spl_defconfig
  75. 1 0
      configs/mccmon6_nor_defconfig
  76. 1 0
      configs/mccmon6_sd_defconfig
  77. 1 0
      configs/mx6sabreauto_defconfig
  78. 1 0
      configs/mx6sabresd_defconfig
  79. 1 0
      configs/pico-imx6_defconfig
  80. 1 1
      configs/qemu-x86_64_defconfig
  81. 0 1
      configs/qemu-x86_defconfig
  82. 2 0
      configs/sandbox64_defconfig
  83. 3 0
      configs/sandbox_defconfig
  84. 1 0
      configs/sandbox_spl_defconfig
  85. 1 0
      configs/socfpga_arria10_defconfig
  86. 1 0
      configs/stm32mp15_dhcom_basic_defconfig
  87. 1 0
      configs/stm32mp15_dhcor_basic_defconfig
  88. 1 0
      configs/wandboard_defconfig
  89. 1 0
      configs/xilinx_zynq_virt_defconfig
  90. 2 0
      drivers/Kconfig
  91. 1 0
      drivers/Makefile
  92. 21 0
      drivers/button/Kconfig
  93. 6 0
      drivers/button/Makefile
  94. 112 0
      drivers/button/button-gpio.c
  95. 43 0
      drivers/button/button-uclass.c
  96. 2 8
      drivers/gpio/mxs_gpio.c
  97. 2 8
      drivers/mmc/mxsmmc.c
  98. 2 8
      drivers/spi/mxs_spi.c
  99. 59 0
      include/button.h
  100. 1 1
      include/dm/ofnode.h

+ 26 - 3
Kconfig

@@ -276,9 +276,28 @@ config PHYS_64BIT
 	  This can be used not only for 64bit SoCs, but also for
 	  large physical address extension on 32bit SoCs.
 
+config HAS_ROM
+	bool
+	select BINMAN
+	help
+	  Enables building of a u-boot.rom target. This collects U-Boot and
+	  any necessary binary blobs.
+
+config ROM_NEEDS_BLOBS
+	bool
+	depends on HAS_ROM
+	help
+	  Enable this if building the u-boot.rom target needs binary blobs, and
+	  so cannot be done normally. In this case, U-Boot will only build the
+	  ROM if the required blobs exist. If not, you will see an warning like:
+
+	    Image 'main-section' is missing external blobs and is non-functional:
+	      intel-descriptor intel-me intel-refcode intel-vga intel-mrc
+
 config BUILD_ROM
 	bool "Build U-Boot as BIOS replacement"
-	depends on X86
+	depends on HAS_ROM
+	default y if !ROM_NEEDS_BLOBS
 	help
 	  This option allows to build a ROM version of U-Boot.
 	  The build process generally requires several binary blobs
@@ -302,7 +321,7 @@ config BUILD_TARGET
 	default "u-boot-with-spl.sfp" if TARGET_SOCFPGA_GEN5
 	default "u-boot-spl.kwb" if ARCH_MVEBU && SPL
 	default "u-boot-elf.srec" if RCAR_GEN3
-	default "u-boot.itb" if SPL_LOAD_FIT && (ARCH_ROCKCHIP || \
+	default "u-boot.itb" if !BINMAN && SPL_LOAD_FIT && (ARCH_ROCKCHIP || \
 				ARCH_SUNXI || RISCV || ARCH_ZYNQMP)
 	default "u-boot.kwb" if ARCH_KIRKWOOD
 	default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
@@ -585,9 +604,13 @@ config SPL_FIT_SOURCE
 	  U-Boot FIT image. This could specify further image to load and/or
 	  execute.
 
+config USE_SPL_FIT_GENERATOR
+	bool "Use a script to generate the .its script"
+	default y if SPL_FIT
+
 config SPL_FIT_GENERATOR
 	string ".its file generator script for U-Boot FIT image"
-	depends on SPL_FIT
+	depends on USE_SPL_FIT_GENERATOR
 	default "board/sunxi/mksunxi_fit_atf.sh" if SPL_LOAD_FIT && ARCH_SUNXI
 	default "arch/arm/mach-rockchip/make_fit_atf.py" if SPL_LOAD_FIT && ARCH_ROCKCHIP
 	default "arch/arm/mach-zynqmp/mkimage_fit_atf.sh" if SPL_LOAD_FIT && ARCH_ZYNQMP

+ 76 - 93
Makefile

@@ -278,7 +278,7 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 HOSTCC       = cc
 HOSTCXX      = c++
 KBUILD_HOSTCFLAGS   := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
-		$(if $(CONFIG_TOOLS_DEBUG),-g) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
+		$(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
 KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
 KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
@@ -735,6 +735,8 @@ KBUILD_CPPFLAGS += $(KCPPFLAGS)
 KBUILD_AFLAGS += $(KAFLAGS)
 KBUILD_CFLAGS += $(KCFLAGS)
 
+KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
+
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
 UBOOTINCLUDE    := \
@@ -885,79 +887,84 @@ quiet_cmd_static_rela =
 cmd_static_rela =
 endif
 
-# Always append ALL so that arch config.mk's can add custom ones
-ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check
+# Always append INPUTS so that arch config.mk's can add custom ones
+INPUTS-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check
 
-ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
+INPUTS-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
 ifeq ($(CONFIG_SPL_FSL_PBL),y)
-ALL-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin
+INPUTS-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin
 else
 ifneq ($(CONFIG_NXP_ESBC), y)
 # For Secure Boot The Image needs to be signed and Header must also
 # be included. So The image has to be built explicitly
-ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
+INPUTS-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
 endif
 endif
-ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
+INPUTS-$(CONFIG_SPL) += spl/u-boot-spl.bin
 ifeq ($(CONFIG_MX6)$(CONFIG_IMX_HAB), yy)
-ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
+INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
 else
 ifeq ($(CONFIG_MX7)$(CONFIG_IMX_HAB), yy)
-ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
+INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
 else
-ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
+INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
 endif
 endif
-ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
-ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb
+INPUTS-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
+INPUTS-$(CONFIG_OF_SEPARATE) += u-boot.dtb
 ifeq ($(CONFIG_SPL_FRAMEWORK),y)
-ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
+INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
 endif
-ALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
+INPUTS-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
 ifneq ($(CONFIG_SPL_TARGET),)
-ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
-endif
-ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
-ALL-$(CONFIG_EFI_APP) += u-boot-app.efi
-ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
-
-ifneq ($(BUILD_ROM)$(CONFIG_BUILD_ROM),)
-ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
-endif
-ifeq ($(CONFIG_SYS_COREBOOT)$(CONFIG_SPL),yy)
-ALL-$(CONFIG_BINMAN) += u-boot-x86-with-spl.bin
+INPUTS-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
+INPUTS-$(CONFIG_REMAKE_ELF) += u-boot.elf
+INPUTS-$(CONFIG_EFI_APP) += u-boot-app.efi
+INPUTS-$(CONFIG_EFI_STUB) += u-boot-payload.efi
 
 # Build a combined spl + u-boot image for sunxi
-ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_SPL),yy)
-ALL-y += u-boot-sunxi-with-spl.bin
+ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_ARM64)$(CONFIG_SPL),yyy)
+INPUTS-y += u-boot-sunxi-with-spl.bin
 endif
 
-# enable combined SPL/u-boot/dtb rules for tegra
-ifeq ($(CONFIG_ARCH_TEGRA)$(CONFIG_SPL),yy)
-ALL-y += u-boot-tegra.bin u-boot-nodtb-tegra.bin
-ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb-tegra.bin
+# Generate this input file for binman
+ifeq ($(CONFIG_SPL),)
+INPUTS-$(CONFIG_ARCH_MEDIATEK) += u-boot-mtk.bin
 endif
 
-ALL-$(CONFIG_ARCH_MEDIATEK) += u-boot-mtk.bin
-
 # Add optional build target if defined in board/cpu/soc headers
 ifneq ($(CONFIG_BUILD_TARGET),)
-ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
+INPUTS-y += $(CONFIG_BUILD_TARGET:"%"=%)
 endif
 
 ifeq ($(CONFIG_INIT_SP_RELATIVE)$(CONFIG_OF_SEPARATE),yy)
-ALL-y += init_sp_bss_offset_check
+INPUTS-y += init_sp_bss_offset_check
 endif
 
 ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
-ALL-y += u-boot-with-dtb.bin
+INPUTS-y += u-boot-with-dtb.bin
 endif
 
-ifeq ($(CONFIG_ARCH_ROCKCHIP)$(CONFIG_SPL),yy)
-ALL-y += u-boot-rockchip.bin
+ifeq ($(CONFIG_ARCH_ROCKCHIP),y)
+# On ARM64 this target is produced by binman so we don't need this dep
+ifeq ($(CONFIG_ARM64),y)
+ifeq ($(CONFIG_SPL),y)
+# TODO: Get binman to generate this too
+INPUTS-y += u-boot-rockchip.bin
+endif
+else
+ifeq ($(CONFIG_SPL),y)
+# Generate these inputs for binman which will create the output files
+INPUTS-y += idbloader.img u-boot.img
+endif
+endif
 endif
 
+INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \
+	$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
+	$(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin)
+
 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
@@ -992,7 +999,8 @@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
 	>$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
 
 quiet_cmd_mkfitimage = MKIMAGE $@
-cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -f $(U_BOOT_ITS) -p $(CONFIG_FIT_EXTERNAL_OFFSET) $@\
+cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) \
+	-f $(U_BOOT_ITS) -p $(CONFIG_FIT_EXTERNAL_OFFSET) $@ \
 	>$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
 
 quiet_cmd_cat = CAT     $@
@@ -1012,7 +1020,18 @@ quiet_cmd_cfgcheck = CFGCHK  $2
 cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
 		$(srctree)/scripts/config_whitelist.txt $(srctree)
 
-all:		$(ALL-y)
+PHONY += inputs
+inputs: $(INPUTS-y)
+
+all: .binman_stamp inputs
+ifeq ($(CONFIG_BINMAN),y)
+	$(call if_changed,binman)
+endif
+
+# Timestamp file to make sure that binman always runs
+.binman_stamp: FORCE
+	@touch $@
+
 ifeq ($(CONFIG_DEPRECATED),y)
 	$(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.")
 ifeq ($(CONFIG_SPI),y)
@@ -1129,6 +1148,13 @@ ifneq ($(CONFIG_DM_ETH),y)
 	@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"
+	@echo >&2 "to binman instead, to avoid the proliferation of"
+	@echo >&2 "arch-specific scripts with no tests."
+	@echo >&2 "===================================================="
 endif
 	@# Check that this build does not use CONFIG options that we do not
 	@# know about unless they are in Kconfig. All the existing CONFIG
@@ -1304,7 +1330,8 @@ quiet_cmd_binman = BINMAN  $@
 cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
                 --toolpath $(objtree)/tools \
 		$(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
-		build -u -d u-boot.dtb -O . -m \
+		build -u -d u-boot.dtb -O . \
+		$(if $(BUILD_ROM),,-m --allow-missing) \
 		-I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
 		$(BINMAN_$(@F))
 
@@ -1325,12 +1352,14 @@ endif
 
 # Boards with more complex image requirements can provide an .its source file
 # or a generator script
+# NOTE: Please do not use this. We are migrating away from Makefile rules to use
+# binman instead.
 ifneq ($(CONFIG_SPL_FIT_SOURCE),"")
 U_BOOT_ITS := u-boot.its
 $(U_BOOT_ITS): $(subst ",,$(CONFIG_SPL_FIT_SOURCE))
 	$(call if_changed,copy)
 else
-ifneq ($(CONFIG_SPL_FIT_GENERATOR),"")
+ifneq ($(CONFIG_USE_SPL_FIT_GENERATOR),)
 U_BOOT_ITS := u-boot.its
 ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-imx/mkimage_fit_atf.sh")
 U_BOOT_ITS_DEPS += u-boot-nodtb.bin
@@ -1456,10 +1485,7 @@ idbloader.img: spl/u-boot-spl.bin FORCE
 	$(call if_changed,mkimage)
 endif
 
-ifeq ($(CONFIG_ARM64),)
-u-boot-rockchip.bin: idbloader.img u-boot.img FORCE
-	$(call if_changed,binman)
-else
+ifeq ($(CONFIG_ARM64),y)
 OBJCOPYFLAGS_u-boot-rockchip.bin = -I binary -O binary \
 	--pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff
 u-boot-rockchip.bin: idbloader.img u-boot.itb FORCE
@@ -1581,26 +1607,11 @@ u-boot-br.bin: u-boot FORCE
 endif
 endif
 
-# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
-# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in
-# the middle. This is handled by binman based on an image description in the
-# board's device tree.
-ifneq ($(CONFIG_X86_RESET_VECTOR),)
-rom: u-boot.rom FORCE
-
-refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE
-	$(call if_changed,copy)
-
 quiet_cmd_ldr = LD      $@
 cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
 	       $(filter-out FORCE,$^) -o $@
 
-u-boot.rom: u-boot-x86-start16.bin u-boot-x86-reset16.bin u-boot.bin \
-		$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
-		$(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) \
-		$(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE
-	$(call if_changed,binman)
-
+ifdef CONFIG_X86
 OBJCOPYFLAGS_u-boot-x86-start16.bin := -O binary -j .start16
 u-boot-x86-start16.bin: u-boot FORCE
 	$(call if_changed,objcopy)
@@ -1608,41 +1619,16 @@ u-boot-x86-start16.bin: u-boot FORCE
 OBJCOPYFLAGS_u-boot-x86-reset16.bin := -O binary -j .resetvec
 u-boot-x86-reset16.bin: u-boot FORCE
 	$(call if_changed,objcopy)
-endif
+
+endif # CONFIG_X86
 
 ifneq ($(CONFIG_ARCH_SUNXI),)
-ifeq ($(CONFIG_ARM64),)
-u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
-	$(call if_changed,binman)
-else
+ifeq ($(CONFIG_ARM64),y)
 u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.itb FORCE
 	$(call if_changed,cat)
 endif
 endif
 
-u-boot-x86-with-spl.bin: spl/u-boot-spl.bin u-boot.bin FORCE
-	$(call if_changed,binman)
-
-ifneq ($(CONFIG_ARCH_TEGRA),)
-ifneq ($(CONFIG_BINMAN),)
-# Makes u-boot-dtb-tegra.bin u-boot-tegra.bin u-boot-nodtb-tegra.bin
-%-dtb-tegra.bin %-tegra.bin %-nodtb-tegra.bin: \
-		spl/%-spl %.bin FORCE
-	$(call if_changed,binman)
-else
-OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
-u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot-nodtb.bin FORCE
-	$(call if_changed,pad_cat)
-
-OBJCOPYFLAGS_u-boot-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
-u-boot-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
-	$(call if_changed,pad_cat)
-
-u-boot-dtb-tegra.bin: u-boot-tegra.bin FORCE
-	$(call if_changed,copy)
-endif  # binman
-endif
-
 OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI)
 u-boot-app.efi: u-boot FORCE
 	$(call if_changed,zobjcopy)
@@ -1726,9 +1712,6 @@ 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.dtb u-boot.img spl/u-boot-spl-mtk.bin FORCE
-	$(call if_changed,binman)
 else
 MKIMAGEFLAGS_u-boot-mtk.bin = -T mtk_image \
 	-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \

+ 1 - 0
arch/Kconfig

@@ -160,6 +160,7 @@ config X86
 	select TIMER
 	select USE_PRIVATE_LIBGCC
 	select X86_TSC_TIMER
+	imply HAS_ROM if X86_RESET_VECTOR
 	imply BLK
 	imply CMD_DM
 	imply CMD_FPGA_LOADMK

+ 5 - 5
arch/arm/config.mk

@@ -122,7 +122,7 @@ endif
 
 ifneq ($(CONFIG_SPL_BUILD),y)
 # Check that only R_ARM_RELATIVE relocations are generated.
-ALL-y += checkarmreloc
+INPUTS-y += checkarmreloc
 # The movt / movw can hardcode 16 bit parts of the addresses in the
 # instruction. Relocation is not supported for that case, so disable
 # such usage by requiring word relocations.
@@ -154,17 +154,17 @@ endif
 ifneq ($(CONFIG_IMX_CONFIG),)
 ifdef CONFIG_SPL
 ifndef CONFIG_SPL_BUILD
-ALL-y += SPL
+INPUTS-y += SPL
 endif
 else
 ifeq ($(CONFIG_OF_SEPARATE),y)
-ALL-y += u-boot-dtb.imx
+INPUTS-y += u-boot-dtb.imx
 else
-ALL-y += u-boot.imx
+INPUTS-y += u-boot.imx
 endif
 endif
 ifneq ($(CONFIG_VF610),)
-ALL-y += u-boot.vyb
+INPUTS-y += u-boot.vyb
 endif
 endif
 

+ 25 - 0
arch/arm/dts/rk3288-u-boot.dtsi

@@ -4,6 +4,7 @@
  */
 
 #include "rockchip-u-boot.dtsi"
+#include "rockchip-optee.dtsi"
 
 / {
 	chosen {
@@ -12,6 +13,30 @@
 	};
 };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	rom {
+		filename = "u-boot.rom";
+		size = <0x400000>;
+		pad-byte = <0xff>;
+
+		mkimage {
+			args = "-n rk3288 -T rkspi";
+			u-boot-spl {
+			};
+		};
+		u-boot-img {
+			offset = <0x20000>;
+		};
+		u-boot {
+			offset = <0x300000>;
+		};
+		fdtmap {
+		};
+	};
+};
+#endif
+
 &dmc {
 	u-boot,dm-pre-reloc;
 };

+ 4 - 0
arch/arm/dts/rk3399-gru-u-boot.dtsi

@@ -4,3 +4,7 @@
  */
 
 #include "rk3399-u-boot.dtsi"
+
+&spi_flash {
+	u-boot,dm-pre-reloc;
+};

+ 1 - 1
arch/arm/dts/rk3399-gru.dtsi

@@ -537,7 +537,7 @@ ap_i2c_audio: &i2c8 {
 	pinctrl-names = "default", "sleep";
 	pinctrl-1 = <&spi1_sleep>;
 
-	spiflash@0 {
+	spi_flash: spiflash@0 {
 		compatible = "jedec,spi-nor";
 		reg = <0>;
 

+ 27 - 0
arch/arm/dts/rk3399-u-boot.dtsi

@@ -4,11 +4,14 @@
  */
 #define USB_CLASS_HUB			9
 
+#include "rockchip-u-boot.dtsi"
+
 / {
 	aliases {
 		mmc0 = &sdhci;
 		mmc1 = &sdmmc;
 		pci0 = &pcie0;
+		spi1 = &spi1;
 	};
 
 	cic: syscon@ff620000 {
@@ -57,6 +60,30 @@
 
 };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	rom {
+		filename = "u-boot.rom";
+		size = <0x400000>;
+		pad-byte = <0xff>;
+
+		mkimage {
+			args = "-n rk3399 -T rkspi";
+			u-boot-spl {
+			};
+		};
+		u-boot-img {
+			offset = <0x40000>;
+		};
+		u-boot {
+			offset = <0x300000>;
+		};
+		fdtmap {
+		};
+	};
+};
+#endif
+
 &cru {
 	u-boot,dm-pre-reloc;
 };

+ 64 - 0
arch/arm/dts/rockchip-optee.dtsi

@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#include <config.h>
+
+#if defined(CONFIG_HAS_ROM) && defined(CONFIG_FIT)
+&binman {
+	itb {
+		filename = "u-boot.itb";
+		fit {
+			fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
+			description = "FIT image with OP-TEE support";
+			#address-cells = <1>;
+
+			images {
+				uboot {
+					description = "U-Boot";
+					type = "standalone";
+					os = "U-Boot";
+					arch = "arm";
+					compression = "none";
+					load = <CONFIG_SYS_TEXT_BASE>;
+
+					u-boot-nodtb {
+					};
+				};
+				optee {
+					description = "OP-TEE";
+					type = "firmware";
+					arch = "arm";
+					os = "tee";
+					compression = "none";
+					load = <(CONFIG_SYS_SDRAM_BASE + 0x8400000)>;
+					entry = <(CONFIG_SYS_SDRAM_BASE + 0x8400000)>;
+
+					blob-ext {
+						filename = "tee.bin";
+					};
+				};
+				fdt {
+					description = CONFIG_SYS_BOARD;
+					type = "flat_dt";
+					compression = "none";
+
+					u-boot-dtb {
+					};
+				};
+			};
+
+			configurations {
+				default = "conf";
+				conf {
+					description = CONFIG_SYS_BOARD;
+					firmware = "optee";
+					loadables = "uboot";
+					fdt = "fdt";
+				};
+			};
+		};
+	};
+};
+#endif

+ 9 - 1
arch/arm/dts/rockchip-u-boot.dtsi

@@ -6,7 +6,14 @@
 #include <config.h>
 
 / {
-	binman {
+	binman: binman {
+		multiple-images;
+	};
+};
+
+#ifdef CONFIG_SPL
+&binman {
+	simple-bin {
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
 
@@ -19,3 +26,4 @@
 		};
 	};
 };
+#endif

+ 1 - 1
arch/arm/mach-at91/config.mk

@@ -4,6 +4,6 @@ endif
 
 ifeq ($(CONFIG_CPU_V7A),y)
 ifndef CONFIG_SPL_BUILD
-ALL-y	+= u-boot.img
+INPUTS-y	+= u-boot.img
 endif
 endif

+ 1 - 1
arch/arm/mach-davinci/config.mk

@@ -2,5 +2,5 @@
 #
 # Copyright (C) 2012, Texas Instruments, Incorporated - http://www.ti.com/
 ifndef CONFIG_SPL_BUILD
-ALL-$(CONFIG_SPL_FRAMEWORK)	+= u-boot.ais
+INPUTS-$(CONFIG_SPL_FRAMEWORK)	+= u-boot.ais
 endif

+ 5 - 5
arch/arm/mach-k3/config.mk

@@ -44,7 +44,7 @@ tiboot3.bin: image_check FORCE
 	$(srctree)/tools/k3_gen_x509_cert.sh -c 16 -b $(obj)/u-boot-spl.bin \
 				-o $@ -l $(CONFIG_SPL_TEXT_BASE) -k $(KEY)
 
-ALL-y	+= tiboot3.bin
+INPUTS-y	+= tiboot3.bin
 endif
 
 ifdef CONFIG_ARM64
@@ -52,10 +52,10 @@ ifdef CONFIG_ARM64
 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
 SPL_ITS := u-boot-spl-k3_HS.its
 $(SPL_ITS): export IS_HS=1
-ALL-y	+= tispl.bin_HS
+INPUTS-y	+= tispl.bin_HS
 else
 SPL_ITS := u-boot-spl-k3.its
-ALL-y	+= tispl.bin
+INPUTS-y	+= tispl.bin
 endif
 
 quiet_cmd_k3_mkits = MKITS   $@
@@ -70,9 +70,9 @@ endif
 else
 
 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-ALL-y	+= u-boot.img_HS
+INPUTS-y	+= u-boot.img_HS
 else
-ALL-y	+= u-boot.img
+INPUTS-y	+= u-boot.img
 endif
 endif
 

+ 2 - 2
arch/arm/mach-keystone/config.mk

@@ -9,9 +9,9 @@ include  $(srctree)/arch/arm/mach-omap2/config_secure.mk
 
 ifndef CONFIG_SPL_BUILD
 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-ALL-y += u-boot_HS_MLO
+INPUTS-y += u-boot_HS_MLO
 else
-ALL-y += MLO
+INPUTS-y += MLO
 endif
 endif
 

+ 14 - 14
arch/arm/mach-omap2/config.mk

@@ -18,9 +18,9 @@ ifeq ($(CONFIG_TI_SECURE_DEVICE),y) # Refer to README.ti-secure for more info
 # For booting spl from QSPI or NOR use
 # u-boot-spl_HS_X-LOADER
 ifeq ($(CONFIG_OMAP54XX),y)
-ALL-y += u-boot-spl_HS_MLO
-ALL-y += u-boot-spl_HS_ULO
-ALL-y += u-boot-spl_HS_X-LOADER
+INPUTS-y += u-boot-spl_HS_MLO
+INPUTS-y += u-boot-spl_HS_ULO
+INPUTS-y += u-boot-spl_HS_X-LOADER
 endif
 # On AM43XX:
 #
@@ -30,8 +30,8 @@ endif
 # For booting spl from all other media use
 # u-boot-spl_HS_ISSW
 ifeq ($(CONFIG_AM43XX),y)
-ALL-y += u-boot-spl_HS_SPI_X-LOADER
-ALL-y += u-boot-spl_HS_ISSW
+INPUTS-y += u-boot-spl_HS_SPI_X-LOADER
+INPUTS-y += u-boot-spl_HS_ISSW
 endif
 # On AM33XX:
 #
@@ -47,21 +47,21 @@ endif
 # For booting spl over UART, USB, or Ethernet use
 # u-boot-spl_HS_2ND
 ifeq ($(CONFIG_AM33XX),y)
-ALL-y += u-boot-spl_HS_SPI_X-LOADER
-ALL-y += u-boot-spl_HS_X-LOADER
-ALL-y += u-boot-spl_HS_MLO
-ALL-y += u-boot-spl_HS_2ND
+INPUTS-y += u-boot-spl_HS_SPI_X-LOADER
+INPUTS-y += u-boot-spl_HS_X-LOADER
+INPUTS-y += u-boot-spl_HS_MLO
+INPUTS-y += u-boot-spl_HS_2ND
 endif
 else
-ALL-y += MLO
+INPUTS-y += MLO
 ifeq ($(CONFIG_AM33XX),y)
-ALL-y += MLO.byteswap
+INPUTS-y += MLO.byteswap
 endif
 endif
 else
 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
-ALL-$(CONFIG_QSPI_BOOT) += u-boot_HS_XIP_X-LOADER
-ALL-$(CONFIG_SPL_LOAD_FIT) += u-boot_HS.img
+INPUTS-$(CONFIG_QSPI_BOOT) += u-boot_HS_XIP_X-LOADER
+INPUTS-$(CONFIG_SPL_LOAD_FIT) += u-boot_HS.img
 endif
-ALL-y += u-boot.img
+INPUTS-y += u-boot.img
 endif

+ 1 - 1
arch/arm/mach-rmobile/Makefile

@@ -84,5 +84,5 @@ spl/u-boot-spl.scif: spl/u-boot-spl.srec spl/u-boot-spl.bin
 
 # if srec_cat is present build u-boot-spl.scif by default
 has_srec_cat = $(call try-run,srec_cat -VERSion,y,n)
-ALL-$(has_srec_cat) += u-boot-spl.scif
+INPUTS-$(has_srec_cat) += u-boot-spl.scif
 CLEAN_FILES += u-boot-spl.scif

+ 9 - 0
arch/arm/mach-rockchip/Kconfig

@@ -367,6 +367,15 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
 config SPL_MMC_SUPPORT
 	default y if !SPL_ROCKCHIP_BACK_TO_BROM
 
+config ROCKCHIP_SPI_IMAGE
+	bool "Build a SPI image for rockchip"
+	depends on HAS_ROM
+	help
+	  Some Rockchip SoCs support booting from SPI flash. Enable this
+	  option to produce a 4MB SPI-flash image (called u-boot.rom)
+	  containing U-Boot. The image is built by binman. U-Boot sits near
+	  the start of the image.
+
 source "arch/arm/mach-rockchip/px30/Kconfig"
 source "arch/arm/mach-rockchip/rk3036/Kconfig"
 source "arch/arm/mach-rockchip/rk3128/Kconfig"

+ 0 - 84
arch/arm/mach-rockchip/fit_spl_optee.sh

@@ -1,84 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier:      GPL-2.0+
-#
-# Copyright (C) 2019 Rockchip Electronic Co.,Ltd
-#
-# Script to generate FIT image source for 32-bit Rockchip SoCs with
-# U-Boot proper, OPTEE, and devicetree.
-#
-# usage: $0 <dt_name>
-
-[ -z "$TEE" ] && TEE="tee.bin"
-
-if [ ! -f $TEE ]; then
-	echo "WARNING: TEE file $TEE NOT found, U-Boot.itb is non-functional" >&2
-	echo "Please export path for TEE or copy tee.bin to U-Boot folder" >&2
-	TEE=/dev/null
-fi
-
-dtname=$1
-text_base=`sed -n "/SYS_TEXT_BASE=/s/CONFIG_SYS_TEXT_BASE=//p" .config \
-	   |tr -d '\r'`
-dram_base=`sed -n "/SYS_SDRAM_BASE=/s/CONFIG_SYS_SDRAM_BASE=//p" \
-	   include/autoconf.mk|tr -d '\r'`
-tee_base=`echo "obase=16;$(($dram_base+0x8400000))"|bc`
-tee_base='0x'$tee_base
-
-cat << __HEADER_EOF
-/*
- * Copyright (C) 2017-2019 Rockchip Electronic Co.,Ltd
- *
- * Simple U-boot FIT source file containing U-Boot, dtb and optee
- */
-
-/dts-v1/;
-
-/ {
-	description = "FIT image with OP-TEE support";
-	#address-cells = <1>;
-
-	images {
-		uboot {
-			description = "U-Boot";
-			data = /incbin/("u-boot-nodtb.bin");
-			type = "standalone";
-			os = "U-Boot";
-			arch = "arm";
-			compression = "none";
-			load = <$text_base>;
-		};
-		optee {
-			description = "OP-TEE";
-			data = /incbin/("$TEE");
-			type = "firmware";
-			arch = "arm";
-			os = "tee";
-			compression = "none";
-			load = <$tee_base>;
-			entry = <$tee_base>;
-		};
-		fdt {
-			description = "$(basename $dtname .dtb)";
-			data = /incbin/("$dtname");
-			type = "flat_dt";
-			compression = "none";
-		};
-__HEADER_EOF
-
-cat << __CONF_HEADER_EOF
-	};
-
-	configurations {
-		default = "conf";
-		conf {
-			description = "$(basename $dtname .dtb)";
-			firmware = "optee";
-			loadables = "uboot";
-			fdt = "fdt";
-		};
-__CONF_HEADER_EOF
-
-cat << __ITS_EOF
-	};
-};
-__ITS_EOF

+ 3 - 0
arch/arm/mach-rockchip/rk3288/Kconfig

@@ -5,7 +5,9 @@ choice
 
 config TARGET_CHROMEBOOK_JERRY
 	bool "Google/Rockchip Veyron-Jerry Chromebook"
+	select HAS_ROM
 	select BOARD_LATE_INIT
+	select ROCKCHIP_SPI_IMAGE
 	help
 	  Jerry is a RK3288-based clamshell device with 2 USB 3.0 ports,
 	  HDMI, an 11.9 inch EDP display, micro-SD card, touchpad and
@@ -46,6 +48,7 @@ config TARGET_CHROMEBOOK_SPEEDY
 
 config TARGET_EVB_RK3288
 	bool "Evb-RK3288"
+	select HAS_ROM
 	select BOARD_LATE_INIT
 	select TPL
 	help

+ 2 - 0
arch/arm/mach-rockchip/rk3399/Kconfig

@@ -5,6 +5,8 @@ choice
 
 config TARGET_CHROMEBOOK_BOB
 	bool "Asus Flip C101PA Chromebook (RK3399)"
+	select HAS_ROM
+	select ROCKCHIP_SPI_IMAGE
 	help
 	  Bob is a small RK3299-based device similar in apperance to Minnie.
 	  It has two USB 3.0 type-C ports, 4GB of SDRAM, WiFi and a 10.1",

+ 2 - 1
arch/arm/mach-rockchip/spl.c

@@ -54,7 +54,8 @@ u32 spl_boot_device(void)
 #if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
 		defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
 		defined(CONFIG_TARGET_CHROMEBOOK_MINNIE) || \
-		defined(CONFIG_TARGET_CHROMEBOOK_SPEEDY)
+		defined(CONFIG_TARGET_CHROMEBOOK_SPEEDY) || \
+		defined(CONFIG_TARGET_CHROMEBOOK_BOB)
 	return BOOT_DEVICE_SPI;
 #endif
 	if (CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM))

+ 2 - 2
arch/arm/mach-stm32mp/config.mk

@@ -4,10 +4,10 @@
 #
 
 ifndef CONFIG_SPL
-ALL-y += u-boot.stm32
+INPUTS-y += u-boot.stm32
 else
 ifdef CONFIG_SPL_BUILD
-ALL-y += u-boot-spl.stm32
+INPUTS-y += u-boot-spl.stm32
 endif
 endif
 

+ 1 - 1
arch/arm/mach-tegra/Kconfig

@@ -41,7 +41,6 @@ config TEGRA_PMC_SECURE
 
 config TEGRA_COMMON
 	bool "Tegra common options"
-	select BINMAN
 	select BOARD_EARLY_INIT_F
 	select CLK
 	select DM
@@ -69,6 +68,7 @@ config TEGRA_NO_BPMP
 
 config TEGRA_ARMV7_COMMON
 	bool "Tegra 32-bit common options"
+	select BINMAN
 	select CPU_V7A
 	select SPL
 	select SPL_BOARD_INIT if SPL

+ 1 - 1
arch/powerpc/Kconfig

@@ -20,7 +20,7 @@ config MPC85xx
 	select CREATE_ARCH_SYMLINK
 	select SYS_FSL_DDR
 	select SYS_FSL_DDR_BE
-	select BINMAN
+	select BINMAN if OF_SEPARATE
 	imply CMD_HASH
 	imply CMD_IRQ
 	imply USB_EHCI_HCD if USB

+ 14 - 0
arch/sandbox/dts/sandbox.dtsi

@@ -15,6 +15,20 @@
 		#sound-dai-cells = <1>;
 	};
 
+	buttons {
+		compatible = "gpio-keys";
+
+		summer {
+			gpios = <&gpio_a 3 0>;
+			label = "summer";
+		};
+
+		christmas {
+			gpios = <&gpio_a 4 0>;
+			label = "christmas";
+		};
+	};
+
 	gpio_a: gpios@0 {
 		u-boot,dm-pre-reloc;
 		gpio-controller;

+ 18 - 4
arch/sandbox/dts/test.dts

@@ -51,6 +51,20 @@
 		#sound-dai-cells = <1>;
 	};
 
+	buttons {
+		compatible = "gpio-keys";
+
+		summer {
+			gpios = <&gpio_a 3 0>;
+			label = "summer";
+		};
+
+		christmas {
+			gpios = <&gpio_a 4 0>;
+			label = "christmas";
+		};
+	};
+
 	cros_ec: cros-ec {
 		reg = <0 0>;
 		compatible = "google,cros-ec-sandbox";
@@ -355,22 +369,22 @@
 			hog_input_active_low {
 				gpio-hog;
 				input;
-				gpios = <0 GPIO_ACTIVE_LOW>;
+				gpios = <10 GPIO_ACTIVE_LOW>;
 			};
 			hog_input_active_high {
 				gpio-hog;
 				input;
-				gpios = <1 GPIO_ACTIVE_HIGH>;
+				gpios = <11 GPIO_ACTIVE_HIGH>;
 			};
 			hog_output_low {
 				gpio-hog;
 				output-low;
-				gpios = <2 GPIO_ACTIVE_HIGH>;
+				gpios = <12 GPIO_ACTIVE_HIGH>;
 			};
 			hog_output_high {
 				gpio-hog;
 				output-high;
-				gpios = <3 GPIO_ACTIVE_HIGH>;
+				gpios = <13 GPIO_ACTIVE_HIGH>;
 			};
 		};
 

+ 10 - 1
arch/x86/Kconfig

@@ -360,6 +360,8 @@ config HAVE_FSP
 	bool "Add an Firmware Support Package binary"
 	depends on !EFI
 	select USE_HOB
+	select HAS_ROM
+	select ROM_NEEDS_BLOBS
 	help
 	  Select this option to add an Firmware Support Package binary to
 	  the resulting U-Boot image. It is a binary blob which U-Boot uses
@@ -519,6 +521,8 @@ config ENABLE_MRC_CACHE
 
 config HAVE_MRC
 	bool "Add a System Agent binary"
+	select HAS_ROM
+	select ROM_NEEDS_BLOBS
 	depends on !HAVE_FSP
 	help
 	  Select this option to add a System Agent binary to
@@ -590,8 +594,13 @@ config HAVE_REFCODE
           Various peripherals may fail to work.
 
 config HAVE_MICROCODE
-	bool
+	bool "Board requires a microcode binary"
 	default y if !FSP_VERSION2
+	help
+	  Enable this if the board requires microcode to be loaded on boot.
+	  Typically this is handed by the FSP for modern boards, but for
+	  some older boards, it must be programmed by U-Boot, and that form
+	  part of the image.
 
 config SMP
 	bool "Enable Symmetric Multiprocessing"

+ 1 - 0
arch/x86/cpu/quark/Kconfig

@@ -24,6 +24,7 @@ if INTEL_QUARK
 
 config HAVE_RMU
 	bool "Add a Remote Management Unit (RMU) binary"
+	select ROM_NEEDS_BLOBS
 	help
 	  Select this option to add a Remote Management Unit (RMU) binary
 	  to the resulting U-Boot image. It is a data block (up to 64K) of

+ 7 - 3
arch/x86/dts/u-boot.dtsi

@@ -75,11 +75,15 @@
 	u-boot {
 		offset = <CONFIG_SYS_TEXT_BASE>;
 	};
-# else
+# elif defined(CONFIG_HAVE_MICROCODE)
 	/* If there is no SPL then we need to put microcode in U-Boot */
 	u-boot-with-ucode-ptr {
 		offset = <CONFIG_X86_OFFSET_U_BOOT>;
 	};
+# else
+	u-boot-nodtb {
+		offset = <CONFIG_X86_OFFSET_U_BOOT>;
+	};
 # endif
 #endif
 #ifdef CONFIG_HAVE_MICROCODE
@@ -92,6 +96,8 @@
 	u-boot-dtb {
 	};
 #endif
+	fdtmap {
+	};
 #ifdef CONFIG_HAVE_X86_FIT
 	intel-fit {
 	};
@@ -139,8 +145,6 @@
 		filename = CONFIG_FSP_FILE_S;
 	};
 #endif
-	fdtmap {
-	};
 #ifdef CONFIG_HAVE_CMC
 	intel-cmc {
 		filename = CONFIG_CMC_FILE;

+ 2 - 2
board/BuR/brppt1/config.mk

@@ -25,8 +25,8 @@ cmd_prodzip =					\
 	zip -9 -r $@ misc/* >/dev/null $<
 
 ifeq ($(hw-platform-y),brppt1-spi)
-ALL-y += $(hw-platform-y)_prog.bin
-ALL-y += $(hw-platform-y)_prod.zip
+INPUTS-y += $(hw-platform-y)_prog.bin
+INPUTS-y += $(hw-platform-y)_prod.zip
 endif
 
 $(hw-platform-y)_prog.bin: u-boot-dtb.img spl/u-boot-spl.bin

+ 2 - 2
board/BuR/brppt2/config.mk

@@ -24,8 +24,8 @@ cmd_prodzip =					\
 
 ifeq ($(hw-platform-y),brppt2)
 ifneq ($(CONFIG_SPL_BUILD),y)
-ALL-y += $(hw-platform-y)_prog.bin
-ALL-y += $(hw-platform-y)_prod.zip
+INPUTS-y += $(hw-platform-y)_prog.bin
+INPUTS-y += $(hw-platform-y)_prod.zip
 endif
 endif
 

+ 3 - 3
board/BuR/brsmarc1/config.mk

@@ -23,11 +23,11 @@ cmd_prodzip =					\
 	cp u-boot-dtb.img misc/ &&		\
 	zip -9 -r $@ misc/* >/dev/null $<
 
-ALL-y += $(hw-platform-y)_prog.bin
-ALL-y += $(hw-platform-y)_prod.zip
+INPUTS-y += $(hw-platform-y)_prog.bin
+INPUTS-y += $(hw-platform-y)_prod.zip
 
 $(hw-platform-y)_prog.bin: u-boot-dtb.img spl/u-boot-spl.bin
 	$(call if_changed,prodbin)
 
 $(hw-platform-y)_prod.zip: $(hw-platform-y)_prog.bin
-	$(call if_changed,prodzip)
+	$(call if_changed,prodzip)

+ 1 - 1
board/imgtec/boston/config.mk

@@ -11,5 +11,5 @@ u-boot.mcs: u-boot.bin
 
 # if srec_cat is present build u-boot.mcs by default
 has_srec_cat = $(call try-run,srec_cat -VERSion,y,n)
-ALL-$(has_srec_cat) += u-boot.mcs
+INPUTS-$(has_srec_cat) += u-boot.mcs
 CLEAN_FILES += u-boot.mcs

+ 1 - 1
board/intel/edison/config.mk

@@ -10,7 +10,7 @@ cmd_mkalign_eds =							\
 	dd if=$^ of=$@ bs=4k seek=1 2>/dev/null &&			\
 	mv $@ $^
 
-ALL-y += u-boot-align.bin
+INPUTS-y += u-boot-align.bin
 u-boot-align.bin: u-boot.bin
 	$(call if_changed,mkalign_eds)
 

+ 11 - 0
cmd/Kconfig

@@ -1680,6 +1680,17 @@ config CMD_BLOCK_CACHE
 	  during development, but also allows the cache to be disabled when
 	  it might hurt performance (e.g. when using the ums command).
 
+config CMD_BUTTON
+	bool "button"
+	depends on BUTTON
+	default y if BUTTON
+	help
+	  Enable the 'button' command which allows to get the status of
+	  buttons supported by the board. The buttonss can be listed with
+	  'button list' and state can be known with 'button <label>'.
+	  Any button drivers can be controlled with this command, e.g.
+	  button_gpio.
+
 config CMD_CACHE
 	bool "icache or dcache"
 	help

+ 1 - 0
cmd/Makefile

@@ -33,6 +33,7 @@ obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o
 obj-$(CONFIG_CMD_BOOTZ) += bootz.o
 obj-$(CONFIG_CMD_BOOTI) += booti.o
 obj-$(CONFIG_CMD_BTRFS) += btrfs.o
+obj-$(CONFIG_CMD_BUTTON) += button.o
 obj-$(CONFIG_CMD_CACHE) += cache.o
 obj-$(CONFIG_CMD_CBFS) += cbfs.o
 obj-$(CONFIG_CMD_CLK) += clk.o

+ 86 - 0
cmd/button.c

@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
+ *
+ * Based on led.c
+ */
+
+#include <common.h>
+#include <command.h>
+#include <dm.h>
+#include <button.h>
+#include <dm/uclass-internal.h>
+
+static const char *const state_label[] = {
+	[BUTTON_OFF]	= "off",
+	[BUTTON_ON]	= "on",
+};
+
+static int show_button_state(struct udevice *dev)
+{
+	int ret;
+
+	ret = button_get_state(dev);
+	if (ret >= BUTTON_COUNT)
+		ret = -EINVAL;
+	if (ret >= 0)
+		printf("%s\n", state_label[ret]);
+
+	return ret;
+}
+
+static int list_buttons(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	for (uclass_find_first_device(UCLASS_BUTTON, &dev);
+	     dev;
+	     uclass_find_next_device(&dev)) {
+		struct button_uc_plat *plat = dev_get_uclass_platdata(dev);
+
+		if (!plat->label)
+			continue;
+		printf("%-15s ", plat->label);
+		if (device_active(dev)) {
+			ret = show_button_state(dev);
+			if (ret < 0)
+				printf("Error %d\n", ret);
+		} else {
+			printf("<inactive>\n");
+		}
+	}
+
+	return 0;
+}
+
+int do_button(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+	const char *button_label;
+	struct udevice *dev;
+	int ret;
+
+	/* Validate arguments */
+	if (argc < 2)
+		return CMD_RET_USAGE;
+	button_label = argv[1];
+	if (strncmp(button_label, "list", 4) == 0)
+		return list_buttons();
+
+	ret = button_get_by_label(button_label, &dev);
+	if (ret) {
+		printf("Button '%s' not found (err=%d)\n", button_label, ret);
+		return CMD_RET_FAILURE;
+	}
+
+	ret = show_button_state(dev);
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	button, 4, 1, do_button,
+	"manage buttons",
+	"<button_label> \tGet button state\n"
+	"button list\t\tShow a list of buttons"
+);

+ 1 - 1
cmd/host.c

@@ -51,7 +51,7 @@ static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc,
 		printf("** Bad device specification %s **\n", dev_str);
 		return CMD_RET_USAGE;
 	}
-	return host_dev_bind(dev, file);
+	return !!host_dev_bind(dev, file);
 }
 
 static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc,

+ 13 - 3
common/image-fdt.c

@@ -465,10 +465,20 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
 #ifdef CONFIG_ANDROID_BOOT_IMAGE
 	} else if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID) {
 		struct andr_img_hdr *hdr = buf;
-		ulong fdt_data, fdt_len;
+		ulong		fdt_data, fdt_len;
+		u32			fdt_size, dtb_idx;
+		/*
+		 * Firstly check if this android boot image has dtb field.
+		 */
+		dtb_idx = (u32)env_get_ulong("adtb_idx", 10, 0);
+		if (android_image_get_dtb_by_index((ulong)hdr, dtb_idx, &fdt_addr, &fdt_size)) {
+			fdt_blob = (char *)map_sysmem(fdt_addr, 0);
+			if (fdt_check_header(fdt_blob))
+				goto no_fdt;
 
-		if (!android_image_get_second(hdr, &fdt_data, &fdt_len) &&
-		    !fdt_check_header((char *)fdt_data)) {
+			debug("## Using FDT in Android image dtb area with idx %u\n", dtb_idx);
+		} else if (!android_image_get_second(hdr, &fdt_data, &fdt_len) &&
+			!fdt_check_header((char *)fdt_data)) {
 			fdt_blob = (char *)fdt_data;
 			if (fdt_totalsize(fdt_blob) != fdt_len)
 				goto error;

+ 1 - 0
configs/am335x_evm_defconfig

@@ -7,6 +7,7 @@ CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-evm"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd"
 CONFIG_LOGLEVEL=3

+ 1 - 0
configs/am335x_hs_evm_defconfig

@@ -11,6 +11,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd"
 CONFIG_LOGLEVEL=3

+ 1 - 0
configs/am335x_hs_evm_uart_defconfig

@@ -14,6 +14,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run findfdt; run init_console; run envboot; run distro_bootcmd"
 CONFIG_LOGLEVEL=3

+ 1 - 0
configs/am43xx_evm_defconfig

@@ -11,6 +11,7 @@ CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="am437x-gp-evm"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_MISC_INIT_R is not set

+ 1 - 0
configs/am43xx_evm_rtconly_defconfig

@@ -11,6 +11,7 @@ CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="am437x-gp-evm"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_MISC_INIT_R is not set

+ 1 - 0
configs/am43xx_evm_usbhost_boot_defconfig

@@ -10,6 +10,7 @@ CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="am437x-gp-evm"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_MISC_INIT_R is not set

+ 1 - 0
configs/am43xx_hs_evm_defconfig

@@ -19,6 +19,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_SYS_CONSOLE_INFO_QUIET=y

+ 1 - 0
configs/am57xx_evm_defconfig

@@ -18,6 +18,7 @@ CONFIG_DEFAULT_DEVICE_TREE="am572x-idk"
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS2,115200 androidboot.console=ttyS2 androidboot.hardware=beagle_x15board"

+ 1 - 0
configs/am57xx_hs_evm_defconfig

@@ -23,6 +23,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS2,115200 androidboot.console=ttyS2 androidboot.hardware=beagle_x15board"

+ 1 - 0
configs/am57xx_hs_evm_usb_defconfig

@@ -25,6 +25,7 @@ CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80200000
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS2,115200 androidboot.console=ttyS2 androidboot.hardware=beagle_x15board"

+ 1 - 0
configs/am65x_evm_a53_defconfig

@@ -26,6 +26,7 @@ CONFIG_DEFAULT_DEVICE_TREE="k3-am654-base-board"
 CONFIG_DISTRO_DEFAULTS=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern"
 CONFIG_CONSOLE_MUX=y

+ 1 - 0
configs/am65x_evm_r5_defconfig

@@ -24,6 +24,7 @@ CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am654-r5-base-board"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_BOOTCOMMAND=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_STACK_R=y

+ 1 - 0
configs/am65x_hs_evm_a53_defconfig

@@ -29,6 +29,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run get_fit_${boot}; run get_overlaystring; run run_fit"
 CONFIG_CONSOLE_MUX=y

+ 1 - 0
configs/am65x_hs_evm_r5_defconfig

@@ -26,6 +26,7 @@ CONFIG_DEFAULT_DEVICE_TREE="k3-am654-r5-base-board"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_BOOTCOMMAND=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_STACK_R=y

+ 3 - 1
configs/chromebook_bob_defconfig

@@ -3,7 +3,7 @@ CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_ENV_OFFSET=0x3F8000
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000
 CONFIG_SPL_TEXT_BASE=0xff8c2000
 CONFIG_ROCKCHIP_RK3399=y
 CONFIG_ROCKCHIP_BOOT_MODE_REG=0
@@ -40,6 +40,7 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SYS_I2C_ROCKCHIP=y
@@ -53,6 +54,7 @@ CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y
+CONFIG_SF_DEFAULT_BUS=1
 CONFIG_SF_DEFAULT_SPEED=20000000
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_DM_ETH=y

+ 1 - 0
configs/chromebook_jerry_defconfig

@@ -85,6 +85,7 @@ CONFIG_PWM_ROCKCHIP=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
 CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_ROCKCHIP_SERIAL=y
 CONFIG_SOUND=y
 CONFIG_I2S=y
 CONFIG_I2S_ROCKCHIP=y

+ 2 - 0
configs/chromebook_link64_defconfig

@@ -17,8 +17,10 @@ CONFIG_DEBUG_UART=y
 CONFIG_HAVE_MRC=y
 CONFIG_SMP=y
 CONFIG_HAVE_VGA_BIOS=y
+CONFIG_X86_OFFSET_U_BOOT=0xffa00000
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SHOW_BOOT_PROGRESS=y

+ 1 - 1
configs/chromebook_samus_tpl_defconfig

@@ -18,7 +18,7 @@ CONFIG_HAVE_MRC=y
 CONFIG_HAVE_REFCODE=y
 CONFIG_SMP=y
 CONFIG_HAVE_VGA_BIOS=y
-CONFIG_X86_OFFSET_U_BOOT=0xfff00000
+CONFIG_X86_OFFSET_U_BOOT=0xffee0000
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SHOW_BOOT_PROGRESS=y

+ 2 - 0
configs/chromebox_panther_defconfig

@@ -8,7 +8,9 @@ CONFIG_DEFAULT_DEVICE_TREE="chromebox_panther"
 CONFIG_VENDOR_GOOGLE=y
 CONFIG_TARGET_CHROMEBOX_PANTHER=y
 CONFIG_HAVE_MRC=y
+# CONFIG_HAVE_MICROCODE is not set
 CONFIG_HAVE_VGA_BIOS=y
+CONFIG_X86_OFFSET_U_BOOT=0xffa00000
 CONFIG_FIT=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y

+ 1 - 0
configs/dh_imx6_defconfig

@@ -26,6 +26,7 @@ CONFIG_DISTRO_DEFAULTS=y
 # CONFIG_SYS_MALLOC_F is not set
 CONFIG_FIT=y
 CONFIG_SPL_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTDELAY=3
 # CONFIG_USE_BOOTCOMMAND is not set

+ 1 - 0
configs/display5_defconfig

@@ -29,6 +29,7 @@ CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-display5"
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q"
 CONFIG_SUPPORT_RAW_INITRD=y

+ 1 - 0
configs/display5_factory_defconfig

@@ -26,6 +26,7 @@ CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-display5"
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q"
 CONFIG_BOOTDELAY=3

+ 1 - 0
configs/dra7xx_evm_defconfig

@@ -19,6 +19,7 @@ CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80200000
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS0,115200 androidboot.console=ttyS0 androidboot.hardware=jacinto6evmboard"

+ 1 - 0
configs/dra7xx_hs_evm_defconfig

@@ -24,6 +24,7 @@ CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80200000
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS0,115200 androidboot.console=ttyS0 androidboot.hardware=jacinto6evmboard"

+ 1 - 0
configs/dra7xx_hs_evm_usb_defconfig

@@ -26,6 +26,7 @@ CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80200000
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="androidboot.serialno=${serial#} console=ttyS0,115200 androidboot.console=ttyS0 androidboot.hardware=jacinto6evmboard"

+ 1 - 1
configs/evb-rk3229_defconfig

@@ -16,7 +16,7 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
-CONFIG_SPL_FIT_GENERATOR="arch/arm/mach-rockchip/fit_spl_optee.sh"
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_PREBOOT=y
 CONFIG_DEFAULT_FDT_FILE="rk3229-evb.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set

+ 1 - 1
configs/evb-rk3288_defconfig

@@ -15,7 +15,7 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
-CONFIG_SPL_FIT_GENERATOR="arch/arm/mach-rockchip/fit_spl_optee.sh"
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_PREBOOT=y
 CONFIG_SILENT_CONSOLE=y
 CONFIG_DEFAULT_FDT_FILE="rk3288-evb-rk808.dtb"

+ 1 - 0
configs/imx6qdl_icore_mipi_defconfig

@@ -21,6 +21,7 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTDELAY=3

+ 1 - 0
configs/imx6qdl_icore_mmc_defconfig

@@ -24,6 +24,7 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTDELAY=3

+ 1 - 0
configs/imx6qdl_icore_rqs_defconfig

@@ -18,6 +18,7 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTDELAY=3

+ 1 - 0
configs/j721e_evm_a72_defconfig

@@ -28,6 +28,7 @@ CONFIG_DISTRO_DEFAULTS=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern"
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y

+ 1 - 0
configs/j721e_evm_r5_defconfig

@@ -24,6 +24,7 @@ CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80080000
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_BOOTCOMMAND=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_BOARD_INIT=y

+ 1 - 0
configs/j721e_hs_evm_a72_defconfig

@@ -29,6 +29,7 @@ CONFIG_FIT_IMAGE_POST_PROCESS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x81000000
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run boot_rprocs; run get_fit_${boot}; run get_overlaystring; run run_fit"
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y

+ 1 - 0
configs/j721e_hs_evm_r5_defconfig

@@ -27,6 +27,7 @@ CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-common-proc-board"
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80080000
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_BOOTCOMMAND=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_STACK_R=y

+ 1 - 0
configs/ls1046ardb_qspi_spl_defconfig

@@ -20,6 +20,7 @@ CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_QSPI_BOOT=y
 CONFIG_BOOTDELAY=10

+ 1 - 0
configs/mccmon6_nor_defconfig

@@ -17,6 +17,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6q-mccmon6"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/liebherr/mccmon6/mon6_imximage_nor.cfg"
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_BOARD_LATE_INIT=y

+ 1 - 0
configs/mccmon6_sd_defconfig

@@ -18,6 +18,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6q-mccmon6"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/liebherr/mccmon6/mon6_imximage_sd.cfg"
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_BOARD_LATE_INIT=y

+ 1 - 0
configs/mx6sabreauto_defconfig

@@ -20,6 +20,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6q-sabreauto"
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 # CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y

+ 1 - 0
configs/mx6sabresd_defconfig

@@ -19,6 +19,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6q-sabresd"
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 # CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y

+ 1 - 0
configs/pico-imx6_defconfig

@@ -19,6 +19,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTCOMMAND="run default_boot"
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y

+ 1 - 1
configs/qemu-x86_64_defconfig

@@ -18,9 +18,9 @@ CONFIG_GENERATE_MP_TABLE=y
 CONFIG_GENERATE_ACPI_TABLE=y
 CONFIG_X86_OFFSET_U_BOOT=0xfff00000
 CONFIG_DISTRO_DEFAULTS=y
-CONFIG_BUILD_ROM=y
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SHOW_BOOT_PROGRESS=y

+ 0 - 1
configs/qemu-x86_defconfig

@@ -9,7 +9,6 @@ CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
 CONFIG_GENERATE_ACPI_TABLE=y
 CONFIG_DISTRO_DEFAULTS=y
-CONFIG_BUILD_ROM=y
 CONFIG_FIT=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y

+ 2 - 0
configs/sandbox64_defconfig

@@ -93,6 +93,8 @@ CONFIG_ADC=y
 CONFIG_ADC_SANDBOX=y
 CONFIG_AXI=y
 CONFIG_AXI_SANDBOX=y
+CONFIG_BUTTON=y
+CONFIG_BUTTON_GPIO=y
 CONFIG_CLK=y
 CONFIG_CPU=y
 CONFIG_DM_DEMO=y

+ 3 - 0
configs/sandbox_defconfig

@@ -8,6 +8,7 @@ CONFIG_DEBUG_UART=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_CIPHER=y
 CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_BOOTSTAGE=y
@@ -107,6 +108,8 @@ CONFIG_AXI_SANDBOX=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_DM_BOOTCOUNT=y
 CONFIG_DM_BOOTCOUNT_RTC=y
+CONFIG_BUTTON=y
+CONFIG_BUTTON_GPIO=y
 CONFIG_CLK=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SANDBOX_CLK_CCF=y

+ 1 - 0
configs/sandbox_spl_defconfig

@@ -14,6 +14,7 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y

+ 1 - 0
configs/socfpga_arria10_defconfig

@@ -12,6 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set

+ 1 - 0
configs/stm32mp15_dhcom_basic_defconfig

@@ -16,6 +16,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_SOURCE="board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its"
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_LEGACY_IMAGE_SUPPORT=y

+ 1 - 0
configs/stm32mp15_dhcor_basic_defconfig

@@ -16,6 +16,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_SOURCE="board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its"
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_LEGACY_IMAGE_SUPPORT=y

+ 1 - 0
configs/wandboard_defconfig

@@ -24,6 +24,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTCOMMAND="run findfdt; run finduuid; run distro_bootcmd"
 # CONFIG_CONSOLE_MUX is not set

+ 1 - 0
configs/xilinx_zynq_virt_defconfig

@@ -16,6 +16,7 @@ CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_FIT_PRINT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x10000000
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_USE_PREBOOT=y
 CONFIG_SPL_STACK_R=y

+ 2 - 0
drivers/Kconfig

@@ -16,6 +16,8 @@ source "drivers/block/Kconfig"
 
 source "drivers/bootcount/Kconfig"
 
+source "drivers/button/Kconfig"
+
 source "drivers/cache/Kconfig"
 
 source "drivers/clk/Kconfig"

+ 1 - 0
drivers/Makefile

@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-$(CONFIG_$(SPL_TPL_)BUTTON) += button/
 obj-$(CONFIG_$(SPL_TPL_)CACHE) += cache/
 obj-$(CONFIG_$(SPL_TPL_)CLK) += clk/
 obj-$(CONFIG_$(SPL_TPL_)DM) += core/

+ 21 - 0
drivers/button/Kconfig

@@ -0,0 +1,21 @@
+menu "Button Support"
+
+config BUTTON
+	bool "Enable button support"
+	depends on DM
+	help
+	  Many boards have buttons which can be used to change behaviour (reset, ...).
+	  U-Boot provides a uclass API to implement this feature. Button drivers
+	  can provide access to board-specific buttons. Use of the device tree
+	  for configuration is encouraged.
+
+config BUTTON_GPIO
+	bool "Button gpio"
+	depends on BUTTON
+	help
+	  Enable support for buttons which are connected to GPIO lines. These
+	  GPIOs may be on the SoC or some other device which provides GPIOs.
+	  The GPIO driver must used driver model. Buttons are configured using
+	  the device tree.
+
+endmenu

+ 6 - 0
drivers/button/Makefile

@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
+
+obj-$(CONFIG_BUTTON) += button-uclass.o
+obj-$(CONFIG_BUTTON_GPIO) += button-gpio.o

+ 112 - 0
drivers/button/button-gpio.c

@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+#include <common.h>
+#include <button.h>
+#include <dm.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+#include <log.h>
+#include <asm/gpio.h>
+
+struct button_gpio_priv {
+	struct gpio_desc gpio;
+};
+
+static enum button_state_t button_gpio_get_state(struct udevice *dev)
+{
+	struct button_gpio_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	if (!dm_gpio_is_valid(&priv->gpio))
+		return -EREMOTEIO;
+	ret = dm_gpio_get_value(&priv->gpio);
+	if (ret < 0)
+		return ret;
+
+	return ret ? BUTTON_ON : BUTTON_OFF;
+}
+
+static int button_gpio_probe(struct udevice *dev)
+{
+	struct button_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
+	struct button_gpio_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	/* Ignore the top-level button node */
+	if (!uc_plat->label)
+		return 0;
+
+	ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_IN);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int button_gpio_remove(struct udevice *dev)
+{
+	/*
+	 * The GPIO driver may have already been removed. We will need to
+	 * address this more generally.
+	 */
+	if (!IS_ENABLED(CONFIG_SANDBOX)) {
+		struct button_gpio_priv *priv = dev_get_priv(dev);
+
+		if (dm_gpio_is_valid(&priv->gpio))
+			dm_gpio_free(dev, &priv->gpio);
+	}
+
+	return 0;
+}
+
+static int button_gpio_bind(struct udevice *parent)
+{
+	struct udevice *dev;
+	ofnode node;
+	int ret;
+
+	dev_for_each_subnode(node, parent) {
+		struct button_uc_plat *uc_plat;
+		const char *label;
+
+		label = ofnode_read_string(node, "label");
+		if (!label) {
+			debug("%s: node %s has no label\n", __func__,
+			      ofnode_get_name(node));
+			return -EINVAL;
+		}
+		ret = device_bind_driver_to_node(parent, "button_gpio",
+						 ofnode_get_name(node),
+						 node, &dev);
+		if (ret)
+			return ret;
+		uc_plat = dev_get_uclass_platdata(dev);
+		uc_plat->label = label;
+	}
+
+	return 0;
+}
+
+static const struct button_ops button_gpio_ops = {
+	.get_state	= button_gpio_get_state,
+};
+
+static const struct udevice_id button_gpio_ids[] = {
+	{ .compatible = "gpio-keys" },
+	{ .compatible = "gpio-keys-polled" },
+	{ }
+};
+
+U_BOOT_DRIVER(button_gpio) = {
+	.name		= "button_gpio",
+	.id		= UCLASS_BUTTON,
+	.of_match	= button_gpio_ids,
+	.ops		= &button_gpio_ops,
+	.priv_auto_alloc_size = sizeof(struct button_gpio_priv),
+	.bind		= button_gpio_bind,
+	.probe		= button_gpio_probe,
+	.remove		= button_gpio_remove,
+};

+ 43 - 0
drivers/button/button-uclass.c

@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
+ *
+ * Based on led-uclass.c
+ */
+
+#include <common.h>
+#include <button.h>
+#include <dm.h>
+#include <dm/uclass-internal.h>
+
+int button_get_by_label(const char *label, struct udevice **devp)
+{
+	struct udevice *dev;
+	struct uclass *uc;
+
+	uclass_id_foreach_dev(UCLASS_BUTTON, dev, uc) {
+		struct button_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
+
+		/* Ignore the top-level button node */
+		if (uc_plat->label && !strcmp(label, uc_plat->label))
+			return uclass_get_device_tail(dev, 0, devp);
+	}
+
+	return -ENODEV;
+}
+
+enum button_state_t button_get_state(struct udevice *dev)
+{
+	struct button_ops *ops = button_get_ops(dev);
+
+	if (!ops->get_state)
+		return -ENOSYS;
+
+	return ops->get_state(dev);
+}
+
+UCLASS_DRIVER(button) = {
+	.id		= UCLASS_BUTTON,
+	.name		= "button",
+	.per_device_platdata_auto_alloc_size = sizeof(struct button_uc_plat),
+};

+ 2 - 8
drivers/gpio/mxs_gpio.c

@@ -138,12 +138,6 @@ int name_to_gpio(const char *name)
 #include <asm/arch/gpio.h>
 #define MXS_MAX_GPIO_PER_BANK		32
 
-#ifdef CONFIG_MX28
-#define dtd_fsl_imx_gpio dtd_fsl_imx28_gpio
-#else /* CONFIG_MX23 */
-#define dtd_fsl_imx_gpio dtd_fsl_imx23_gpio
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 /*
  * According to i.MX28 Reference Manual:
@@ -158,7 +152,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct mxs_gpio_platdata {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_fsl_imx_gpio dtplat;
+	struct dtd_fsl_imx23_gpio dtplat;
 #endif
 	unsigned int bank;
 	int gpio_ranges;
@@ -247,7 +241,7 @@ static int mxs_gpio_probe(struct udevice *dev)
 	char name[16], *str;
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_fsl_imx_gpio *dtplat = &plat->dtplat;
+	struct dtd_fsl_imx23_gpio *dtplat = &plat->dtplat;
 	priv->bank = (unsigned int)dtplat->reg[0];
 	uc_priv->gpio_count = dtplat->gpio_ranges[3];
 #else

+ 2 - 8
drivers/mmc/mxsmmc.c

@@ -52,15 +52,9 @@ struct mxsmmc_priv {
 #include <dm/read.h>
 #include <dt-structs.h>
 
-#ifdef CONFIG_MX28
-#define dtd_fsl_imx_mmc dtd_fsl_imx28_mmc
-#else /* CONFIG_MX23 */
-#define dtd_fsl_imx_mmc dtd_fsl_imx23_mmc
-#endif
-
 struct mxsmmc_platdata {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_fsl_imx_mmc dtplat;
+	struct dtd_fsl_imx23_mmc dtplat;
 #endif
 	struct mmc_config cfg;
 	struct mmc mmc;
@@ -582,7 +576,7 @@ static int mxsmmc_probe(struct udevice *dev)
 	debug("%s: probe\n", __func__);
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_fsl_imx_mmc *dtplat = &plat->dtplat;
+	struct dtd_fsl_imx23_mmc *dtplat = &plat->dtplat;
 	struct phandle_1_arg *p1a = &dtplat->clocks[0];
 
 	priv->buswidth = dtplat->bus_width;

+ 2 - 8
drivers/spi/mxs_spi.c

@@ -41,15 +41,9 @@
 #define MXS_SSP_IMX23_CLKID_SSP0 33
 #define MXS_SSP_IMX28_CLKID_SSP0 46
 
-#ifdef CONFIG_MX28
-#define dtd_fsl_imx_spi dtd_fsl_imx28_spi
-#else /* CONFIG_MX23 */
-#define dtd_fsl_imx_spi dtd_fsl_imx23_spi
-#endif
-
 struct mxs_spi_platdata {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_fsl_imx_spi dtplat;
+	struct dtd_fsl_imx23_spi dtplat;
 #endif
 	s32 frequency;		/* Default clock frequency, -1 for none */
 	fdt_addr_t base;        /* SPI IP block base address */
@@ -324,7 +318,7 @@ static int mxs_spi_probe(struct udevice *bus)
 	debug("%s: probe\n", __func__);
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-	struct dtd_fsl_imx_spi *dtplat = &plat->dtplat;
+	struct dtd_fsl_imx23_spi *dtplat = &plat->dtplat;
 	struct phandle_1_arg *p1a = &dtplat->clocks[0];
 
 	priv->regs = (struct mxs_ssp_regs *)dtplat->reg[0];

+ 59 - 0
include/button.h

@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+#ifndef __BUTTON_H
+#define __BUTTON_H
+
+/**
+ * struct button_uc_plat - Platform data the uclass stores about each device
+ *
+ * @label:	Button label
+ */
+struct button_uc_plat {
+	const char *label;
+};
+
+/**
+ * enum button_state_t - State used for button
+ * - BUTTON_OFF - Button is not pressed
+ * - BUTTON_ON - Button is pressed
+ * - BUTTON_COUNT - Number of button state
+ */
+enum button_state_t {
+	BUTTON_OFF = 0,
+	BUTTON_ON = 1,
+	BUTTON_COUNT,
+};
+
+struct button_ops {
+	/**
+	 * get_state() - get the state of a button
+	 *
+	 * @dev:	button device to change
+	 * @return button state button_state_t, or -ve on error
+	 */
+	enum button_state_t (*get_state)(struct udevice *dev);
+};
+
+#define button_get_ops(dev)	((struct button_ops *)(dev)->driver->ops)
+
+/**
+ * button_get_by_label() - Find a button device by label
+ *
+ * @label:	button label to look up
+ * @devp:	Returns the associated device, if found
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int button_get_by_label(const char *label, struct udevice **devp);
+
+/**
+ * button_get_state() - get the state of a button
+ *
+ * @dev:	button device to change
+ * @return button state button_state_t, or -ve on error
+ */
+enum button_state_t button_get_state(struct udevice *dev);
+
+#endif

+ 1 - 1
include/dm/ofnode.h

@@ -48,7 +48,7 @@ struct resource;
  *	is not a really a pointer to a node: it is an offset value. See above.
  */
 typedef union ofnode_union {
-	const struct device_node *np;	/* will be used for future live tree */
+	const struct device_node *np;
 	long of_offset;
 } ofnode;
 

Some files were not shown because too many files changed in this diff