Merge tag 'video-20240731' of https://source.denx.de/u-boot/custodians/u-boot-video

 - improve video sync performance with background syncing (cyclic)
 - fix dropping characters when pasting commands over the UART
 - enable background syncing by default for boards using VIDEO
 - make sandbox video more responsive
diff --git a/MAINTAINERS b/MAINTAINERS
index a6e47e8..c283234 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -945,6 +945,7 @@
 T:	git https://source.denx.de/u-boot/custodians/u-boot-dfu.git
 F:	boot/bootmeth_android.c
 F:	boot/bootmeth_android.h
+F:	doc/develop/bootstd/android.rst
 
 BTRFS
 M:	Marek Behún <kabel@kernel.org>
diff --git a/Makefile b/Makefile
index ea562c2..f0e6f07 100644
--- a/Makefile
+++ b/Makefile
@@ -1048,7 +1048,7 @@
 CHECKFLAGS += --arch=$(ARCH)
 
 # insure the checker run with the right endianness
-CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
+CHECKFLAGS += $(if $(CONFIG_SYS_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
 
 # the checker needs the correct machine size
 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
diff --git a/arch/Kconfig b/arch/Kconfig
index abd406d..8f1f466 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -8,6 +8,13 @@
 config HAVE_ARCH_IOREMAP
 	bool
 
+config SUPPORT_BIG_ENDIAN
+	bool
+
+config SUPPORT_LITTLE_ENDIAN
+	bool
+	default y if !SUPPORT_BIG_ENDIAN
+
 config SYS_CACHE_SHIFT_4
 	bool
 
@@ -59,6 +66,8 @@
 	select SUPPORT_OF_CONTROL
 	select SYS_CACHE_SHIFT_7
 	select TIMER
+	select SUPPORT_BIG_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SYS_BIG_ENDIAN if CPU_BIG_ENDIAN
 	select SYS_LITTLE_ENDIAN if !CPU_BIG_ENDIAN
 
@@ -68,6 +77,7 @@
 	select CREATE_ARCH_SYMLINK
 	select HAVE_PRIVATE_LIBGCC if !ARM64
 	select SUPPORT_ACPI
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_OF_CONTROL
 
 config M68K
@@ -77,10 +87,13 @@
 	select SYS_BOOT_GET_CMDLINE
 	select SYS_BOOT_GET_KBD
 	select SYS_CACHE_SHIFT_4
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORT_OF_CONTROL
 
 config MICROBLAZE
 	bool "MicroBlaze architecture"
+	select SUPPORT_BIG_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_OF_CONTROL
 	imply CMD_TIMER
 	imply SPL_REGMAP if SPL
@@ -101,12 +114,14 @@
 	select DM
 	select DM_EVENT
 	select OF_CONTROL
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_OF_CONTROL
 	imply CMD_DM
 
 config PPC
 	bool "PowerPC architecture"
 	select HAVE_PRIVATE_LIBGCC
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORT_OF_CONTROL
 	select SYS_BOOT_GET_CMDLINE
 	select SYS_BOOT_GET_KBD
@@ -115,6 +130,7 @@
 	bool "RISC-V architecture"
 	select CREATE_ARCH_SYMLINK
 	select SUPPORT_ACPI
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_OF_CONTROL
 	select OF_CONTROL
 	select DM
@@ -160,6 +176,8 @@
 	select PCI_ENDPOINT
 	select SPI
 	select SUPPORT_OF_CONTROL
+	select SUPPORT_BIG_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
 	select SYS_CACHE_SHIFT_4
 	select IRQ
@@ -224,6 +242,7 @@
 
 config SH
 	bool "SuperH architecture"
+	select SUPPORT_LITTLE_ENDIAN
 	select HAVE_PRIVATE_LIBGCC
 	select SUPPORT_OF_CONTROL
 
@@ -231,6 +250,7 @@
 	bool "x86 architecture"
 	select SUPPORT_SPL
 	select SUPPORT_TPL
+	select SUPPORT_LITTLE_ENDIAN
 	select CREATE_ARCH_SYMLINK
 	select DM
 	select HAVE_ARCH_IOMAP
@@ -312,6 +332,7 @@
 config XTENSA
 	bool "Xtensa architecture"
 	select CREATE_ARCH_SYMLINK
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_OF_CONTROL
 
 endchoice
@@ -515,24 +536,21 @@
 
 source "board/keymile/Kconfig"
 
-if MIPS || MICROBLAZE
-
 choice
 	prompt "Endianness selection"
+	default SYS_BIG_ENDIAN if MIPS || MICROBLAZE
+	default SYS_LITTLE_ENDIAN
 	help
-	  Some MIPS boards can be configured for either little or big endian
+	  Some boards can be configured for either little or big endian
 	  byte order. These modes require different U-Boot images. In general there
 	  is one preferred byteorder for a particular system but some systems are
 	  just as commonly used in the one or the other endianness.
 
 config SYS_BIG_ENDIAN
 	bool "Big endian"
-	depends on (SUPPORTS_BIG_ENDIAN && MIPS) || MICROBLAZE
+	depends on SUPPORT_BIG_ENDIAN
 
 config SYS_LITTLE_ENDIAN
 	bool "Little endian"
-	depends on (SUPPORTS_LITTLE_ENDIAN && MIPS) || MICROBLAZE
-
+	depends on SUPPORT_LITTLE_ENDIAN
 endchoice
-
-endif
diff --git a/arch/arc/include/asm/arc-bcr.h b/arch/arc/include/asm/arc-bcr.h
index a6c972b..d4de9b8 100644
--- a/arch/arc/include/asm/arc-bcr.h
+++ b/arch/arc/include/asm/arc-bcr.h
@@ -15,7 +15,7 @@
 
 union bcr_di_cache {
 	struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 		unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
 #else
 		unsigned int ver:8, config:4, sz:4, line_len:4, pad:12;
@@ -26,7 +26,7 @@
 
 union bcr_slc_cfg {
 	struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 		unsigned int pad:24, way:2, lsz:2, sz:4;
 #else
 		unsigned int sz:4, lsz:2, way:2, pad:24;
@@ -37,7 +37,7 @@
 
 union bcr_generic {
 	struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 		unsigned int pad:24, ver:8;
 #else
 		unsigned int ver:8, pad:24;
@@ -48,7 +48,7 @@
 
 union bcr_clust_cfg {
 	struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 		unsigned int pad:7, c:1, num_entries:8, num_cores:8, ver:8;
 #else
 		unsigned int ver:8, num_cores:8, num_entries:8, c:1, pad:7;
@@ -59,7 +59,7 @@
 
 union bcr_mmu_4 {
 	struct {
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 	unsigned int ver:8, sasid:1, sz1:4, sz0:4, res:2, pae:1,
 		     n_ways:2, n_entry:2, n_super:2, u_itlb:3, u_dtlb:3;
 #else
diff --git a/arch/arm/cpu/armv8/linux-kernel-image-header-vars.h b/arch/arm/cpu/armv8/linux-kernel-image-header-vars.h
index b6394ae..c6af825 100644
--- a/arch/arm/cpu/armv8/linux-kernel-image-header-vars.h
+++ b/arch/arm/cpu/armv8/linux-kernel-image-header-vars.h
@@ -31,7 +31,7 @@
  * when PIE is in effect. So we need to split them up in 32-bit high and low
  * words.
  */
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 #define DATA_LE32(data)				\
 	((((data) & 0x000000ff) << 24) |	\
 	 (((data) & 0x0000ff00) << 8)  |	\
@@ -55,7 +55,7 @@
 #endif
 #define __MEM_USAGE		(__CODE_DATA_SIZE + __MAX_EXTRA_RAM_USAGE)
 
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 #define __HEAD_FLAG_BE		1
 #else
 #define __HEAD_FLAG_BE		0
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index eb7f3ad..38577af 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -28,14 +28,14 @@
 	select OF_ISA_BUS
 	select PCI_MAP_SYSTEM_MEMORY
 	select ROM_EXCEPTION_VECTORS
-	select SUPPORTS_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	select SUPPORTS_CPU_MIPS32_R6
 	select SUPPORTS_CPU_MIPS64_R1
 	select SUPPORTS_CPU_MIPS64_R2
 	select SUPPORTS_CPU_MIPS64_R6
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_BIG_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SWAP_IO_SPACE
 	imply CMD_DM
 
@@ -86,7 +86,7 @@
 	select ROM_EXCEPTION_VECTORS
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_SPL
 
 config ARCH_JZ47XX
@@ -112,7 +112,7 @@
 	select MIPS_TUNE_OCTEON3
 	select MTD
 	select ROM_EXCEPTION_VECTORS
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS64_OCTEON
 	select PHYS_64BIT
 	select OF_CONTROL
@@ -138,14 +138,14 @@
 	select OF_BOARD_SETUP
 	select OF_CONTROL
 	select ROM_EXCEPTION_VECTORS
-	select SUPPORTS_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	select SUPPORTS_CPU_MIPS32_R6
 	select SUPPORTS_CPU_MIPS64_R1
 	select SUPPORTS_CPU_MIPS64_R2
 	select SUPPORTS_CPU_MIPS64_R6
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_BIG_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	imply CMD_DM
 
 config TARGET_XILFPGA
@@ -159,7 +159,7 @@
 	select ROM_EXCEPTION_VECTORS
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	imply CMD_DM
 	help
 	  This supports IMGTEC MIPSfpga platform
@@ -413,12 +413,6 @@
 
 endmenu
 
-config SUPPORTS_BIG_ENDIAN
-	bool
-
-config SUPPORTS_LITTLE_ENDIAN
-	bool
-
 config SUPPORTS_CPU_MIPS32_R1
 	bool
 
diff --git a/arch/mips/mach-ath79/Kconfig b/arch/mips/mach-ath79/Kconfig
index cd85d1b..2fa6285 100644
--- a/arch/mips/mach-ath79/Kconfig
+++ b/arch/mips/mach-ath79/Kconfig
@@ -8,7 +8,7 @@
 	bool
 	select MIPS_TUNE_24KC
 	select ROM_EXCEPTION_VECTORS
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	help
@@ -17,7 +17,7 @@
 config SOC_AR934X
 	bool
 	select MIPS_TUNE_74KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	select USB_EHCI_IS_TDI if USB_EHCI_HCD
@@ -28,7 +28,7 @@
 	bool
 	select MIPS_TUNE_24KC
 	select ROM_EXCEPTION_VECTORS
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	help
@@ -37,7 +37,7 @@
 config SOC_QCA956X
 	bool
 	select MIPS_TUNE_74KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	help
diff --git a/arch/mips/mach-bmips/Kconfig b/arch/mips/mach-bmips/Kconfig
index eb9ea34..b140552 100644
--- a/arch/mips/mach-bmips/Kconfig
+++ b/arch/mips/mach-bmips/Kconfig
@@ -23,7 +23,7 @@
 	bool "BMIPS BCM3380 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_WATCHDOG
 	help
@@ -33,7 +33,7 @@
 	bool "BMIPS BCM6318 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -43,7 +43,7 @@
 	bool "BMIPS BCM6328 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -53,7 +53,7 @@
 	bool "BMIPS BCM6338 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -63,7 +63,7 @@
 	bool "BMIPS BCM6348 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_WATCHDOG
 	help
@@ -73,7 +73,7 @@
 	bool "BMIPS BCM6358 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -83,7 +83,7 @@
 	bool "BMIPS BCM6368 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -93,7 +93,7 @@
 	bool "BMIPS BCM6362 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -103,7 +103,7 @@
 	bool "BMIPS BCM63268 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
@@ -114,7 +114,7 @@
 	bool "BMIPS BCM6838 family"
 	select SYS_CACHE_SHIFT_4
 	select MIPS_TUNE_4KC
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SYSRESET_SYSCON
 	help
diff --git a/arch/mips/mach-jz47xx/Kconfig b/arch/mips/mach-jz47xx/Kconfig
index dcaac01..858173e 100644
--- a/arch/mips/mach-jz47xx/Kconfig
+++ b/arch/mips/mach-jz47xx/Kconfig
@@ -6,7 +6,7 @@
 
 config SOC_JZ4780
 	bool
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
 	help
diff --git a/arch/mips/mach-mscc/Kconfig b/arch/mips/mach-mscc/Kconfig
index affc472..367d524 100644
--- a/arch/mips/mach-mscc/Kconfig
+++ b/arch/mips/mach-mscc/Kconfig
@@ -6,10 +6,10 @@
 config SOC_VCOREIII
 	select MIPS_TUNE_24KC
 	select ROM_EXCEPTION_VECTORS
-	select SUPPORTS_BIG_ENDIAN
+	select SUPPORT_BIG_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	bool
 
 config SYS_SOC
diff --git a/arch/mips/mach-pic32/Kconfig b/arch/mips/mach-pic32/Kconfig
index 2afa972..52d2eec 100644
--- a/arch/mips/mach-pic32/Kconfig
+++ b/arch/mips/mach-pic32/Kconfig
@@ -13,7 +13,7 @@
 	select ROM_EXCEPTION_VECTORS
 	select SUPPORTS_CPU_MIPS32_R1
 	select SUPPORTS_CPU_MIPS32_R2
-	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
 	select SYS_MIPS_CACHE_INIT_RAM_LOAD
 	help
 	  This supports Microchip PIC32MZ[DA] family of microcontrollers.
diff --git a/boot/bootm.c b/boot/bootm.c
index 376d63a..480f8e6 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -740,18 +740,6 @@
 	eth_halt();
 #endif
 
-#if defined(CONFIG_CMD_USB)
-	/*
-	 * turn off USB to prevent the host controller from writing to the
-	 * SDRAM while Linux is booting. This could happen (at least for OHCI
-	 * controller), because the HCCA (Host Controller Communication Area)
-	 * lies within the SDRAM and the host controller writes continously to
-	 * this area (as busmaster!). The HccaFrameNumber is for example
-	 * updated every 1 ms within the HCCA structure in SDRAM! For more
-	 * details see the OpenHCI specification.
-	 */
-	usb_stop();
-#endif
 	return iflag;
 }
 
diff --git a/doc/develop/bootstd/android.rst b/doc/develop/bootstd/android.rst
new file mode 100644
index 0000000..41701d5
--- /dev/null
+++ b/doc/develop/bootstd/android.rst
@@ -0,0 +1,39 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+Android Bootmeth
+================
+
+Android provides a mechanism for booting its Operating System from eMMC storage,
+described on `source.android.com <https://source.android.com/docs/core/architecture/bootloader>`_.
+
+Android has strong requirements about partitioning layout which are described
+`here <https://source.android.com/docs/core/architecture/partitions>`_.
+Because multiple partitions are required, this bootmeth only operates on whole mmc
+devices which have a valid partition table.
+
+When invoked on a bootdev, this bootmeth searches for the ``misc`` partition in order
+to read the *boot mode*, which can be one of following:
+
+Normal
+  Boot the regular Android Operating System.
+
+Recovery
+  Boot a slimmed down Recovery Operating System. Can be used
+  to factory reset the device or to apply system updates.
+
+Bootloader
+  Stay in U-Boot and wait for fastboot commands from the host.
+
+After the *boot mode* has been determined, this bootmeth will read the *slot suffix*
+from the ``misc`` partition. For details about slots, see
+`the AOSP documentation <https://source.android.com/docs/core/ota/ab#slots>`_.
+
+When both the *boot mode* and the *slot suffix* are known, the bootflow is created.
+
+When the bootflow is booted, the bootmeth reads the kernel, the boot arguments and
+the vendor ramdisk.
+It then boots the kernel using bootm. The relevant devicetree blob is extracted
+from the ``boot`` partition based on the ``adtb_idx`` environment variable.
+
+The compatible string "u-boot,android" is used for the driver. It is present
+if `CONFIG_BOOTMETH_ANDROID` is enabled.
diff --git a/doc/develop/bootstd/index.rst b/doc/develop/bootstd/index.rst
index 9d35b56..4c4e26c 100644
--- a/doc/develop/bootstd/index.rst
+++ b/doc/develop/bootstd/index.rst
@@ -10,6 +10,7 @@
    extlinux
    pxelinux
    qfw
+   android
    cros
    script
    sandbox
diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst
index ff3cc48..c6f0038 100644
--- a/doc/develop/bootstd/overview.rst
+++ b/doc/develop/bootstd/overview.rst
@@ -429,7 +429,7 @@
 
 Bootmeth drivers are provided for booting from various media:
 
-   - Android bootflow (boot image v4)
+   - :doc:`Android <android>` bootflow (boot image v4)
    - :doc:`ChromiumOS <cros>` ChromiumOS boot from a disk
    - EFI boot using bootefi from disk
    - EFI boot using boot manager
diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst
index ca4fb0b..211f7e4 100644
--- a/doc/develop/devicetree/control.rst
+++ b/doc/develop/devicetree/control.rst
@@ -96,12 +96,12 @@
 the next branch opens (refer: :doc:`../release_cycle`) with the latest mainline
 Linux kernel release. To sync the `dts/upstream/` subtree, run::
 
-    ./dts/update-dts-subtree.sh pull <devicetree-rebasing-release-tag>
+    ./tools/update-subtree.sh pull dts <devicetree-rebasing-release-tag>
 
 If required it is also possible to cherry-pick fixes from the
 devicetree-rebasing repository prior to next sync, usage::
 
-    ./dts/update-dts-subtree.sh pick <devicetree-rebasing-commit-id>
+    ./tools/update-subtree.sh pick dts <devicetree-rebasing-commit-id>
 
 
 Configuration
@@ -116,8 +116,8 @@
 newly added board support then one option is that you can add the corresponding
 devicetree source file as `arch/<arch>/dts/<name>.dts`. To select that add `#
 CONFIG_OF_UPSTREAM is not set` and set `DEFAULT_DEVICE_TREE=<name>` when
-prompted by Kconfig. Another option is that you can use use the "pick" option of
-`dts/update-dts-subtree.sh` mentioned above to bring in the commits that you
+prompted by Kconfig. Another option is that you can use the "pick" option of
+`tools/update-subtree.sh` mentioned above to bring in the commits that you
 need.
 
 This should include your CPU or SoC's devicetree file. On top of that any U-Boot
diff --git a/drivers/core/util.c b/drivers/core/util.c
index 108a3bc..fa89348 100644
--- a/drivers/core/util.c
+++ b/drivers/core/util.c
@@ -3,23 +3,13 @@
  * Copyright (c) 2013 Google, Inc
  */
 
+#include <vsprintf.h>
 #include <dm/device.h>
 #include <dm/ofnode.h>
 #include <dm/read.h>
 #include <dm/util.h>
 #include <linux/libfdt.h>
-#include <vsprintf.h>
-
-int list_count_items(struct list_head *head)
-{
-	struct list_head *node;
-	int count = 0;
-
-	list_for_each(node, head)
-		count++;
-
-	return count;
-}
+#include <linux/list.h>
 
 #if CONFIG_IS_ENABLED(OF_REAL)
 int pci_get_devfn(struct udevice *dev)
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index b7bf7cc..b1af3f7 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -1698,7 +1698,7 @@
 	desc->cmd_irq = (dma_cmd << 24) |
 		(end ? (0x03 << 8) : 0) | /* IRQ | STOP */
 		(!!begin) | ((!!end) << 1); /* head, tail */
-#ifdef CONFIG_CPU_BIG_ENDIAN
+#ifdef CONFIG_SYS_BIG_ENDIAN
 	desc->cmd_irq |= 0x01 << 12;
 #endif
 	desc->dram_addr = lower_32_bits(buf);
diff --git a/dts/update-dts-subtree.sh b/dts/update-dts-subtree.sh
deleted file mode 100755
index a57b78a..0000000
--- a/dts/update-dts-subtree.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Copyright 2024 Linaro Ltd.
-#
-# Usage: from the top level U-Boot source tree, run:
-# $ ./dts/update-dts-subtree.sh pull <release-tag>
-# $ ./dts/update-dts-subtree.sh pick <commit-id>
-#
-# The script will pull changes from devicetree-rebasing repo into U-Boot
-# as a subtree located as <U-Boot>/dts/upstream sub-directory. It will
-# automatically create a squash/merge commit listing the commits imported.
-
-set -e
-
-merge_commit_msg=$(cat << EOF
-Subtree merge tag '$2' of devicetree-rebasing repo [1] into dts/upstream
-
-[1] https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git/
-EOF
-)
-
-remote_add_and_fetch() {
-    if ! git remote get-url devicetree-rebasing 2>/dev/null
-    then
-        echo "Warning: Script automatically adds new git remote via:"
-        echo "    git remote add devicetree-rebasing \\"
-        echo "        https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git"
-        git remote add devicetree-rebasing \
-            https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git
-    fi
-    git fetch devicetree-rebasing master
-}
-
-if [ "$1" = "pull" ]
-then
-    remote_add_and_fetch
-    git subtree pull --prefix dts/upstream devicetree-rebasing \
-        "$2" --squash -m "${merge_commit_msg}"
-elif [ "$1" = "pick" ]
-then
-    remote_add_and_fetch
-    git cherry-pick -x --strategy=subtree -Xsubtree=dts/upstream/ "$2"
-else
-    echo "usage: $0 <op> <ref>"
-    echo "  <op>     pull or pick"
-    echo "  <ref>    release tag [pull] or commit id [pick]"
-fi
diff --git a/env/mmc.c b/env/mmc.c
index 776df07..0338aa6 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -110,8 +110,9 @@
 	int hwpart = 0;
 	int err;
 
-	if (IS_ENABLED(CONFIG_SYS_MMC_ENV_PART))
-		hwpart = mmc_get_env_part(mmc);
+#if defined(CONFIG_SYS_MMC_ENV_PART)
+	hwpart = mmc_get_env_part(mmc);
+#endif
 
 #if defined(CONFIG_ENV_MMC_PARTITION)
 	str = CONFIG_ENV_MMC_PARTITION;
diff --git a/include/dm/util.h b/include/dm/util.h
index 95c3527..ec518c5 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -17,14 +17,6 @@
 struct list_head;
 
 /**
- * list_count_items() - Count number of items in a list
- *
- * @param head:		Head of list
- * Return: number of items, or 0 if empty
- */
-int list_count_items(struct list_head *head);
-
-/**
  * Dump out a tree of all devices starting @uclass
  *
  * @dev_name: udevice name
diff --git a/include/linux/list.h b/include/linux/list.h
index 6910721..0f9d939 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -547,6 +547,21 @@
 	     &pos->member != (head);					\
 	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
 
+/**
+ * list_count_nodes - count nodes in the list
+ * @head:	the head for your list.
+ */
+static inline size_t list_count_nodes(struct list_head *head)
+{
+	struct list_head *pos;
+	size_t count = 0;
+
+	list_for_each(pos, head)
+		count++;
+
+	return count;
+}
+
 /*
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is
diff --git a/include/smbios.h b/include/smbios.h
index a4fda9d..00119d7 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -105,6 +105,7 @@
 	u8 bios_minor_release;
 	u8 ec_major_release;
 	u8 ec_minor_release;
+	u16 extended_bios_rom_size;
 	char eos[SMBIOS_STRUCT_EOS_BYTES];
 };
 
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 38e64af..1179c31 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -220,6 +220,7 @@
 config EFI_IGNORE_OSINDICATIONS
 	bool "Ignore OsIndications for CapsuleUpdate on-disk"
 	depends on EFI_CAPSULE_ON_DISK
+	default y if !EFI_RT_VOLATILE_STORE
 	help
 	  There are boards where U-Boot does not support SetVariable at runtime.
 	  Select this option if you want to use the capsule-on-disk feature
@@ -486,6 +487,7 @@
 
 config EFI_EBBR_2_1_CONFORMANCE
 	bool "Add the EBBRv2.1 conformance entry to the ECPT table"
+	depends on BOOTMETH_EFI_BOOTMGR
 	depends on EFI_ECPT
 	depends on EFI_LOADER_HII
 	depends on EFI_RISCV_BOOT_PROTOCOL || !RISCV
diff --git a/lib/efi_loader/efi_fdt.c b/lib/efi_loader/efi_fdt.c
index 4ccf205..c5ecade 100644
--- a/lib/efi_loader/efi_fdt.c
+++ b/lib/efi_loader/efi_fdt.c
@@ -43,6 +43,9 @@
 	case 2:
 		prefix = "/dtb/current";
 		break;
+	case 3:
+		prefix = "/dtbs";
+		break;
 	default:
 		return log_msg_ret("pref", -EINVAL);
 	}
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index 348612c..65d2116 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -133,7 +133,7 @@
 
 		*dp = efi_dp_concat(tmp_dp, fdt_dp, *dp_size);
 		efi_free_pool(tmp_dp);
-		if (!dp)
+		if (!*dp)
 			return EFI_OUT_OF_RESOURCES;
 		*dp_size += efi_dp_size(fdt_dp) + sizeof(END);
 	}
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 12cf23f..c6f1dd0 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -127,7 +127,7 @@
  */
 static void efi_mem_sort(void)
 {
-	struct list_head *lhandle;
+	struct efi_mem_list *lmem;
 	struct efi_mem_list *prevmem = NULL;
 	bool merge_again = true;
 
@@ -136,19 +136,18 @@
 	/* Now merge entries that can be merged */
 	while (merge_again) {
 		merge_again = false;
-		list_for_each(lhandle, &efi_mem) {
-			struct efi_mem_list *lmem;
-			struct efi_mem_desc *prev = &prevmem->desc;
+		list_for_each_entry(lmem, &efi_mem, link) {
+			struct efi_mem_desc *prev;
 			struct efi_mem_desc *cur;
 			uint64_t pages;
 
-			lmem = list_entry(lhandle, struct efi_mem_list, link);
 			if (!prevmem) {
 				prevmem = lmem;
 				continue;
 			}
 
 			cur = &lmem->desc;
+			prev = &prevmem->desc;
 
 			if ((desc_get_end(cur) == prev->physical_start) &&
 			    (prev->type == cur->type) &&
@@ -268,7 +267,7 @@
 					  int memory_type,
 					  bool overlap_only_ram)
 {
-	struct list_head *lhandle;
+	struct efi_mem_list *lmem;
 	struct efi_mem_list *newlist;
 	bool carve_again;
 	uint64_t carved_pages = 0;
@@ -308,11 +307,9 @@
 	/* Add our new map */
 	do {
 		carve_again = false;
-		list_for_each(lhandle, &efi_mem) {
-			struct efi_mem_list *lmem;
+		list_for_each_entry(lmem, &efi_mem, link) {
 			s64 r;
 
-			lmem = list_entry(lhandle, struct efi_mem_list, link);
 			r = efi_mem_carve_out(lmem, &newlist->desc,
 					      overlap_only_ram);
 			switch (r) {
@@ -444,7 +441,7 @@
  */
 static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr)
 {
-	struct list_head *lhandle;
+	struct efi_mem_list *lmem;
 
 	/*
 	 * Prealign input max address, so we simplify our matching
@@ -452,9 +449,7 @@
 	 */
 	max_addr &= ~EFI_PAGE_MASK;
 
-	list_for_each(lhandle, &efi_mem) {
-		struct efi_mem_list *lmem = list_entry(lhandle,
-			struct efi_mem_list, link);
+	list_for_each_entry(lmem, &efi_mem, link) {
 		struct efi_mem_desc *desc = &lmem->desc;
 		uint64_t desc_len = desc->num_pages << EFI_PAGE_SHIFT;
 		uint64_t desc_end = desc->physical_start + desc_len;
@@ -742,9 +737,9 @@
 				efi_uintn_t *descriptor_size,
 				uint32_t *descriptor_version)
 {
+	size_t map_entries;
 	efi_uintn_t map_size = 0;
-	int map_entries = 0;
-	struct list_head *lhandle;
+	struct efi_mem_list *lmem;
 	efi_uintn_t provided_map_size;
 
 	if (!memory_map_size)
@@ -752,8 +747,7 @@
 
 	provided_map_size = *memory_map_size;
 
-	list_for_each(lhandle, &efi_mem)
-		map_entries++;
+	map_entries = list_count_nodes(&efi_mem);
 
 	map_size = map_entries * sizeof(struct efi_mem_desc);
 
@@ -774,10 +768,7 @@
 	/* Copy list into array */
 	/* Return the list in ascending order */
 	memory_map = &memory_map[map_entries - 1];
-	list_for_each(lhandle, &efi_mem) {
-		struct efi_mem_list *lmem;
-
-		lmem = list_entry(lhandle, struct efi_mem_list, link);
+	list_for_each_entry(lmem, &efi_mem, link) {
 		*memory_map = lmem->desc;
 		memory_map--;
 	}
diff --git a/lib/smbios.c b/lib/smbios.c
index 4126466..7c24ea1 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -22,6 +22,7 @@
 #include <cpu.h>
 #include <dm/uclass-internal.h>
 #endif
+#include <linux/sizes.h>
 
 /* Safeguard for checking that U_BOOT_VERSION_NUM macros are compatible with U_BOOT_DMI */
 #if U_BOOT_VERSION_NUM < 2000 || U_BOOT_VERSION_NUM > 2099 || \
@@ -348,7 +349,13 @@
 #endif
 	t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE);
 #ifdef CONFIG_ROM_SIZE
-	t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
+	if (CONFIG_ROM_SIZE < SZ_16M) {
+		t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
+	} else {
+		/* CONFIG_ROM_SIZE < 8 GiB */
+		t->bios_rom_size = 0xff;
+		t->extended_bios_rom_size = CONFIG_ROM_SIZE >> 20;
+	}
 #endif
 	t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED |
 				  BIOS_CHARACTERISTICS_SELECTABLE_BOOT |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 97dd4a6..99cc295 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -224,7 +224,7 @@
 		    $(srctree)/scripts/recordmcount.h
 else
 sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
-	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
+	"$(if $(CONFIG_SYS_BIG_ENDIAN),big,little)" \
 	"$(if $(CONFIG_64BIT),64,32)" \
 	"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \
 	"$(LD) $(KBUILD_LDFLAGS)" "$(NM)" "$(RM)" "$(MV)" \
diff --git a/test/dm/bus.c b/test/dm/bus.c
index a338c7f..95326f2 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -14,6 +14,7 @@
 #include <dm/test.h>
 #include <dm/uclass-internal.h>
 #include <dm/util.h>
+#include <linux/list.h>
 #include <test/test.h>
 #include <test/ut.h>
 
@@ -27,14 +28,14 @@
 	struct uclass *uc;
 
 	ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
-	ut_asserteq(num_devices, list_count_items(&uc->dev_head));
+	ut_asserteq(num_devices, list_count_nodes(&uc->dev_head));
 
 	/* Probe the bus, which should yield 3 more devices */
 	ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
 	num_devices += 3;
 
 	ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
-	ut_asserteq(num_devices, list_count_items(&uc->dev_head));
+	ut_asserteq(num_devices, list_count_nodes(&uc->dev_head));
 
 	ut_assert(!dm_check_devices(uts, num_devices));
 
diff --git a/test/dm/core.c b/test/dm/core.c
index dbad1b3..5bc5e8e 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -16,6 +16,7 @@
 #include <dm/util.h>
 #include <dm/test.h>
 #include <dm/uclass-internal.h>
+#include <linux/list.h>
 #include <test/test.h>
 #include <test/ut.h>
 
@@ -123,15 +124,15 @@
 	 * device with no children.
 	 */
 	ut_assert(uts->root);
-	ut_asserteq(1, list_count_items(gd->uclass_root));
-	ut_asserteq(0, list_count_items(&gd->dm_root->child_head));
+	ut_asserteq(1, list_count_nodes(gd->uclass_root));
+	ut_asserteq(0, list_count_nodes(&gd->dm_root->child_head));
 	ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
 
 	ut_assertok(dm_scan_plat(false));
 
 	/* We should have our test class now at least, plus more children */
-	ut_assert(1 < list_count_items(gd->uclass_root));
-	ut_assert(0 < list_count_items(&gd->dm_root->child_head));
+	ut_assert(1 < list_count_nodes(gd->uclass_root));
+	ut_assert(0 < list_count_nodes(&gd->dm_root->child_head));
 
 	/* Our 3 dm_test_infox children should be bound to the test uclass */
 	ut_asserteq(3, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 18c89ee..31effff 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -19,6 +19,7 @@
 #include <dm/util.h>
 #include <dm/of_access.h>
 #include <linux/ioport.h>
+#include <linux/list.h>
 #include <test/test.h>
 #include <test/ut.h>
 
@@ -162,7 +163,7 @@
 	ut_assert(!ret);
 
 	/* These are num_devices compatible root-level device tree nodes */
-	ut_asserteq(num_devices, list_count_items(&uc->dev_head));
+	ut_asserteq(num_devices, list_count_nodes(&uc->dev_head));
 
 	/* Each should have platform data but no private data */
 	for (i = 0; i < num_devices; i++) {
@@ -217,7 +218,7 @@
 	 * one with "bootph-all" property (a-test node), and the other
 	 * one whose driver marked with DM_FLAG_PRE_RELOC flag (h-test node).
 	 */
-	ut_asserteq(2, list_count_items(&uc->dev_head));
+	ut_asserteq(2, list_count_nodes(&uc->dev_head));
 
 	return 0;
 }
diff --git a/tools/update-subtree.sh b/tools/update-subtree.sh
new file mode 100755
index 0000000..536b331
--- /dev/null
+++ b/tools/update-subtree.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2024 Linaro Limited
+#
+# Usage: from the top level U-Boot source tree, run:
+# $ ./tools/update-subtree.sh pull <subtree-name> <release-tag>
+# Or:
+# $ ./tools/update-subtree.sh pick <subtree-name> <commit-id>
+#
+# The script will pull changes from subtree repo into U-Boot.
+# It will automatically create a squash/merge commit listing the commits
+# imported.
+
+set -e
+
+print_usage() {
+    echo "usage: $0 <op> <subtree-name> <ref>"
+    echo "  <op>           pull or pick"
+    echo "  <subtree-name> mbedtls or dts or lwip"
+    echo "  <ref>          release tag [pull] or commit id [pick]"
+}
+
+if [ $# -ne 3 ]; then
+    print_usage
+    exit 1
+fi
+
+op=$1
+subtree_name=$2
+ref=$3
+
+set_params() {
+    case "$subtree_name" in
+        mbedtls)
+            path=lib/mbedtls/external/mbedtls
+            repo_url=https://github.com/Mbed-TLS/mbedtls.git
+            remote_name="mbedtls_upstream"
+            ;;
+        dts)
+            path=dts/upstream
+            repo_url=https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git
+            remote_name="devicetree-rebasing"
+            ;;
+        lwip)
+            path=lib/lwip/lwip
+            repo_url=https://git.savannah.gnu.org/git/lwip.git
+            remote_name="lwip_upstream"
+            ;;
+        *)
+            echo "Invalid subtree name: $subtree_name"
+            print_usage
+            exit 1
+    esac
+}
+
+set_params
+
+merge_commit_msg=$(cat << EOF
+Subtree merge tag '$ref' of $subtree_name repo [1] into $path
+
+[1] $repo_url
+EOF
+)
+
+remote_add_and_fetch() {
+    if [ -z "$(git remote get-url $remote_name 2>/dev/null)" ]; then
+        echo "Warning: Script automatically adds new git remote via:"
+        echo "    git remote add $remote_name \\"
+        echo "        $repo_url"
+        git remote add $remote_name $repo_url
+    fi
+    git fetch $remote_name master
+}
+
+if [ "$op" = "pull" ]; then
+    remote_add_and_fetch
+    git subtree pull --prefix $path $remote_name "$ref" --squash -m "$merge_commit_msg"
+elif [ "$op" = "pick" ]; then
+    remote_add_and_fetch
+    git cherry-pick -x --strategy=subtree -Xsubtree=$path/ "$ref"
+else
+    print_usage
+    exit 1
+fi