Merge branch '2023-04-25-assorted-updates-and-fixes'

- A few TI, mpc8379erdb and vexpress64 updates, some arm64 core updates,
  test cleanups, Xen cleanups, assorted code and Kconfig cleanups (many
  in preparation for using clang on ARM), psci pre-reloc fixes, enable
  PCI bus mastering for ATA devices, and a gpio-uclass bugfix
diff --git a/Kconfig b/Kconfig
index f24e4f0..888b998 100644
--- a/Kconfig
+++ b/Kconfig
@@ -175,6 +175,8 @@
 
 config XEN
 	bool "Select U-Boot be run as a bootloader for XEN Virtual Machine"
+	depends on ARM64
+	select SSCANF
 	help
 	  Enabling this option will make U-Boot be run as a bootloader
 	  for XEN [1] Virtual Machine.
diff --git a/Makefile b/Makefile
index eaaf7d2..166acba 100644
--- a/Makefile
+++ b/Makefile
@@ -437,6 +437,7 @@
 ifeq ($(cc-name),clang)
 ifneq ($(CROSS_COMPILE),)
 CLANG_TARGET	:= --target=$(notdir $(CROSS_COMPILE:%-=%))
+LDPPFLAGS	+= $(CLANG_TARGET)
 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
 CLANG_PREFIX	:= --prefix=$(GCC_TOOLCHAIN_DIR)
 GCC_TOOLCHAIN	:= $(realpath $(GCC_TOOLCHAIN_DIR)/..)
@@ -893,8 +894,10 @@
 ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 else
+ifndef CONFIG_CC_IS_CLANG
 PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
 endif
+endif
 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
 
 ifdef CONFIG_CC_COVERAGE
diff --git a/api/Kconfig b/api/Kconfig
index 6072288..b5a7399 100644
--- a/api/Kconfig
+++ b/api/Kconfig
@@ -1,13 +1,14 @@
-menu "API"
-
 config API
 	bool "Enable U-Boot API"
+	depends on CC_IS_GCC
 	help
 	  This option enables the U-Boot API. See api/README for more information.
 
+menu "API"
+	depends on API
+
 config SYS_MMC_MAX_DEVICE
 	int  "Maximum number of MMC devices exposed via the API"
-	depends on API
 	default 1
 
 config EXAMPLES
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f0118e2..ab22c0e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -12,7 +12,7 @@
 
 config ARM64_CRC32
 	bool "Enable support for CRC32 instruction"
-	depends on ARM64
+	depends on ARM64 && CC_IS_GCC
 	default y
 	help
 	  ARMv8 implements dedicated crc32 instruction for crc32 calculation.
@@ -2044,7 +2044,6 @@
 	select OF_CONTROL
 	select LINUX_KERNEL_IMAGE_HEADER
 	select XEN_SERIAL
-	select SSCANF
 	imply OF_HAS_PRIOR_STAGE
 
 config ARCH_GXP
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index bf781f1..5530d02 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -3,7 +3,13 @@
 # (C) Copyright 2000-2002
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
-CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \
+ifeq ($(CONFIG_ARM64),y)
+FIXED_REG := -ffixed-x18
+else
+FIXED_REG := -ffixed-r9
+endif
+
+CFLAGS_NON_EFI := -fno-pic $(FIXED_REG) -ffunction-sections -fdata-sections \
 		  -fstack-protector-strong
 CFLAGS_EFI := -fpic -fshort-wchar
 
@@ -15,7 +21,7 @@
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 endif
 
-PLATFORM_RELFLAGS += -fno-common -ffixed-r9
+PLATFORM_RELFLAGS += -fno-common $(FIXED_REG)
 PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
 		     $(call cc-option,-mgeneral-regs-only) \
       $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 7d7aac0..69e281b 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -134,8 +134,8 @@
  */
 #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
 	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
-	mcr     p15, 0, r0, c7, c10, 4	@ DSB
-	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+	dsb
+	isb
 #endif
 
 	bx	lr
@@ -188,8 +188,8 @@
 	mcr	p15, 0, r0, c8, c7, 0	@ invalidate TLBs
 	mcr	p15, 0, r0, c7, c5, 0	@ invalidate icache
 	mcr	p15, 0, r0, c7, c5, 6	@ invalidate BP array
-	mcr     p15, 0, r0, c7, c10, 4	@ DSB
-	mcr     p15, 0, r0, c7, c5, 4	@ ISB
+	dsb
+	isb
 
 	/*
 	 * disable MMU stuff and caches
diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 6973340..cb1131a 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -93,10 +93,16 @@
 
 	if (el == 1) {
 		tcr = TCR_EL1_RSVD | (ips << 32) | TCR_EPD1_DISABLE;
+		if (gd->arch.has_hafdbs)
+			tcr |= TCR_EL1_HA | TCR_EL1_HD;
 	} else if (el == 2) {
 		tcr = TCR_EL2_RSVD | (ips << 16);
+		if (gd->arch.has_hafdbs)
+			tcr |= TCR_EL2_HA | TCR_EL2_HD;
 	} else {
 		tcr = TCR_EL3_RSVD | (ips << 16);
+		if (gd->arch.has_hafdbs)
+			tcr |= TCR_EL3_HA | TCR_EL3_HD;
 	}
 
 	/* PTWs cacheable, inner/outer WBWA and inner shareable */
@@ -200,6 +206,9 @@
 		    attrs != PTE_BLOCK_MEMTYPE(MT_NORMAL_NC))
 			continue;
 
+		if (gd->arch.has_hafdbs && (pte & (PTE_RDONLY | PTE_DBM)) != PTE_DBM)
+			continue;
+
 		end = va + BIT(level2shift(level)) - 1;
 
 		/* No intersection with RAM? */
@@ -309,7 +318,7 @@
 	for (i = idx; size; i++) {
 		u64 next_size, *next_table;
 
-		if (level >= 1 &&
+		if (level >= gd->arch.first_block_level &&
 		    size >= map_size && !(virt & (map_size - 1))) {
 			if (level == 3)
 				table[i] = phys | attrs | PTE_TYPE_PAGE;
@@ -348,6 +357,12 @@
 	if (va_bits < 39)
 		level = 1;
 
+	if (!gd->arch.first_block_level)
+		gd->arch.first_block_level = 1;
+
+	if (gd->arch.has_hafdbs)
+		attrs |= PTE_DBM | PTE_RDONLY;
+
 	map_range(map->virt, map->phys, map->size, level,
 		  (u64 *)gd->arch.tlb_addr, attrs);
 }
@@ -361,7 +376,7 @@
 	for (i = idx; size; i++) {
 		u64 next_size;
 
-		if (level >= 1 &&
+		if (level >= gd->arch.first_block_level &&
 		    size >= map_size && !(virt & (map_size - 1))) {
 			virt += map_size;
 			size -= map_size;
@@ -399,7 +414,16 @@
 __weak u64 get_page_table_size(void)
 {
 	u64 one_pt = MAX_PTE_ENTRIES * sizeof(u64);
-	u64 size;
+	u64 size, mmfr1;
+
+	asm volatile("mrs %0, id_aa64mmfr1_el1" : "=r" (mmfr1));
+	if ((mmfr1 & 0xf) == 2) {
+		gd->arch.has_hafdbs = true;
+		gd->arch.first_block_level = 2;
+	} else {
+		gd->arch.has_hafdbs = false;
+		gd->arch.first_block_level = 1;
+	}
 
 	/* Account for all page tables we would need to cover our memory map */
 	size = one_pt * count_ranges();
diff --git a/arch/arm/cpu/armv8/config.mk b/arch/arm/cpu/armv8/config.mk
index ca06ed3..4d74b2a 100644
--- a/arch/arm/cpu/armv8/config.mk
+++ b/arch/arm/cpu/armv8/config.mk
@@ -2,7 +2,6 @@
 #
 # (C) Copyright 2002
 # Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
-PLATFORM_RELFLAGS += -fno-common -ffixed-x18
 PLATFORM_RELFLAGS += $(call cc-option,-mbranch-protection=none)
 
 PF_NO_UNALIGNED := $(call cc-option, -mstrict-align)
diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
index 9f58ced..19a9e11 100644
--- a/arch/arm/include/asm/armv8/mmu.h
+++ b/arch/arm/include/asm/armv8/mmu.h
@@ -49,10 +49,13 @@
 #define PTE_TYPE_BLOCK		(1 << 0)
 #define PTE_TYPE_VALID		(1 << 0)
 
-#define PTE_TABLE_PXN		(1UL << 59)
-#define PTE_TABLE_XN		(1UL << 60)
-#define PTE_TABLE_AP		(1UL << 61)
-#define PTE_TABLE_NS		(1UL << 63)
+#define PTE_RDONLY		BIT(7)
+#define PTE_DBM			BIT(51)
+
+#define PTE_TABLE_PXN		BIT(59)
+#define PTE_TABLE_XN		BIT(60)
+#define PTE_TABLE_AP		BIT(61)
+#define PTE_TABLE_NS		BIT(63)
 
 /*
  * Block
@@ -99,6 +102,15 @@
 #define TCR_TG0_16K		(2 << 14)
 #define TCR_EPD1_DISABLE	(1 << 23)
 
+#define TCR_EL1_HA		BIT(39)
+#define TCR_EL1_HD		BIT(40)
+
+#define TCR_EL2_HA		BIT(21)
+#define TCR_EL2_HD		BIT(22)
+
+#define TCR_EL3_HA		BIT(21)
+#define TCR_EL3_HD		BIT(22)
+
 #define TCR_EL1_RSVD		(1U << 31)
 #define TCR_EL2_RSVD		(1U << 31 | 1 << 23)
 #define TCR_EL3_RSVD		(1U << 31 | 1 << 23)
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 8698783..0c13075 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -52,6 +52,8 @@
 #if defined(CONFIG_ARM64)
 	unsigned long tlb_fillptr;
 	unsigned long tlb_emerg;
+	unsigned int first_block_level;
+	bool has_hafdbs;
 #endif
 #endif
 #ifdef CFG_SYS_MEM_RESERVE_SECURE
diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index 2e09141..125dc0b 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -37,6 +37,40 @@
 	efi_print_image_infos((void *)regs->elr);
 }
 
+static void dump_far(unsigned long esr)
+{
+	unsigned long el, far;
+
+	switch ((esr >> 26) & 0b111111) {
+	case 0x20:
+	case 0x21:
+	case 0x24:
+	case 0x25:
+	case 0x22:
+	case 0x34:
+	case 0x35:
+		break;
+	default:
+		return;
+	}
+
+	asm("mrs	%0, CurrentEl": "=r" (el));
+
+	switch (el >> 2) {
+	case 1:
+		asm("mrs	%0, FAR_EL1": "=r" (far));
+		break;
+	case 2:
+		asm("mrs	%0, FAR_EL2": "=r" (far));
+		break;
+	default:
+		/* don't print anything to make output pretty */
+		return;
+	}
+
+	printf(", far 0x%lx", far);
+}
+
 static void dump_instr(struct pt_regs *regs)
 {
 	u32 *addr = (u32 *)(regs->elr & ~3UL);
@@ -165,7 +199,9 @@
 	    smh_emulate_trap(pt_regs))
 		return;
 	efi_restore_gd();
-	printf("\"Synchronous Abort\" handler, esr 0x%08lx\n", pt_regs->esr);
+	printf("\"Synchronous Abort\" handler, esr 0x%08lx", pt_regs->esr);
+	dump_far(pt_regs->esr);
+	printf("\n");
 	show_regs(pt_regs);
 	show_efi_loaded_images(pt_regs);
 	panic("Resetting CPU ...\n");
diff --git a/arch/arm/mach-k3/j721s2_init.c b/arch/arm/mach-k3/j721s2_init.c
index 001d946..712a7e2 100644
--- a/arch/arm/mach-k3/j721s2_init.c
+++ b/arch/arm/mach-k3/j721s2_init.c
@@ -22,6 +22,51 @@
 #include <mmc.h>
 #include <remoteproc.h>
 
+struct fwl_data cbass_hc_cfg0_fwls[] = {
+	{ "PCIE0_CFG", 2577, 7 },
+	{ "EMMC8SS0_CFG", 2579, 4 },
+	{ "USB3SS0_CORE", 2580, 4 },
+	{ "USB3SS1_CORE", 2581, 1 },
+}, cbass_hc2_fwls[] = {
+	{ "PCIE0", 2547, 24 },
+	{ "HC2_WIZ16B8M4CT2", 2552, 1 },
+}, cbass_rc_cfg0_fwls[] = {
+	{ "EMMCSD4SS0_CFG", 2400, 4 },
+}, infra_cbass0_fwls[] = {
+	{ "PSC0", 5, 1 },
+	{ "PLL_CTRL0", 6, 1 },
+	{ "PLL_MMR0", 8, 26 },
+	{ "CTRL_MMR0", 9, 16 },
+	{ "GPIO0", 16, 1 },
+}, mcu_cbass0_fwls[] = {
+	{ "MCU_R5FSS0_CORE0", 1024, 4 },
+	{ "MCU_R5FSS0_CORE0_CFG", 1025, 3 },
+	{ "MCU_R5FSS0_CORE1", 1028, 4 },
+	{ "MCU_R5FSS0_CORE1_CFG", 1029, 1 },
+	{ "MCU_FSS0_CFG", 1032, 12 },
+	{ "MCU_FSS0_S1", 1033, 8 },
+	{ "MCU_FSS0_S0", 1036, 8 },
+	{ "MCU_PSROM49152X32", 1048, 1 },
+	{ "MCU_MSRAM128KX64", 1050, 8 },
+	{ "MCU_MSRAM128KX64_CFG", 1051, 1 },
+	{ "MCU_TIMER0", 1056, 1 },
+	{ "MCU_TIMER9", 1065, 1 },
+	{ "MCU_USART0", 1120, 1 },
+	{ "MCU_I2C0", 1152, 1 },
+	{ "MCU_CTRL_MMR0", 1200, 8 },
+	{ "MCU_PLL_MMR0", 1201, 3 },
+	{ "MCU_CPSW0", 1220, 2 },
+}, wkup_cbass0_fwls[] = {
+	{ "WKUP_PSC0", 129, 1 },
+	{ "WKUP_PLL_CTRL0", 130, 1 },
+	{ "WKUP_CTRL_MMR0", 131, 16 },
+	{ "WKUP_GPIO0", 132, 1 },
+	{ "WKUP_I2C0", 144, 1 },
+	{ "WKUP_USART0", 160, 1 },
+}, navss_cbass0_fwls[] = {
+	{ "NACSS_VIRT0", 6253, 1 },
+};
+
 static void ctrl_mmr_unlock(void)
 {
 	/* Unlock all WKUP_CTRL_MMR0 module registers */
@@ -150,6 +195,14 @@
 			if (ret)
 				panic("Failed to initialize clk-k3!\n");
 		}
+
+		remove_fwl_configs(cbass_hc_cfg0_fwls, ARRAY_SIZE(cbass_hc_cfg0_fwls));
+		remove_fwl_configs(cbass_hc2_fwls, ARRAY_SIZE(cbass_hc2_fwls));
+		remove_fwl_configs(cbass_rc_cfg0_fwls, ARRAY_SIZE(cbass_rc_cfg0_fwls));
+		remove_fwl_configs(infra_cbass0_fwls, ARRAY_SIZE(infra_cbass0_fwls));
+		remove_fwl_configs(mcu_cbass0_fwls, ARRAY_SIZE(mcu_cbass0_fwls));
+		remove_fwl_configs(wkup_cbass0_fwls, ARRAY_SIZE(wkup_cbass0_fwls));
+		remove_fwl_configs(navss_cbass0_fwls, ARRAY_SIZE(navss_cbass0_fwls));
 	}
 
 	/* Output System Firmware version info */
diff --git a/arch/arm/mach-omap2/omap3/lowlevel_init.S b/arch/arm/mach-omap2/omap3/lowlevel_init.S
index ab7cdcf..1ab9472 100644
--- a/arch/arm/mach-omap2/omap3/lowlevel_init.S
+++ b/arch/arm/mach-omap2/omap3/lowlevel_init.S
@@ -15,13 +15,14 @@
 #include <asm/arch/clocks_omap3.h>
 #include <linux/linkage.h>
 
+.arch_extension sec
+
 /*
  * Funtion for making PPA HAL API calls in secure devices
  * Input:
  *	R0 - Service ID
  *	R1 - paramer list
  */
-/* TODO: Re-evaluate the comment at the end regarding armv5 vs armv7 */
 ENTRY(do_omap3_emu_romcode_call)
 	PUSH {r4-r12, lr} @ Save all registers from ROM code!
 	MOV r12, r0	@ Copy the Secure Service ID in R12
@@ -32,8 +33,7 @@
 	MOV r6, #0xFF	@ Indicate new Task call
 	mcr     p15, 0, r0, c7, c10, 4	@ DSB
 	mcr     p15, 0, r0, c7, c10, 5	@ DMB
-	.word	0xe1600071	@ SMC #1 to call PPA service - hand assembled
-				@ because we use -march=armv5
+	SMC     #1	@ Call PPA service
 	POP {r4-r12, pc}
 ENDPROC(do_omap3_emu_romcode_call)
 
diff --git a/arch/powerpc/dts/mpc8379erdb.dts b/arch/powerpc/dts/mpc8379erdb.dts
index 2e7c8f1..3db5ece 100644
--- a/arch/powerpc/dts/mpc8379erdb.dts
+++ b/arch/powerpc/dts/mpc8379erdb.dts
@@ -13,6 +13,11 @@
 	#address-cells = <1>;
 	#size-cells = <1>;
 
+	aliases {
+		serial0 = &serial0;
+		serial1 = &serial1;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
@@ -60,6 +65,28 @@
 			clock-frequency = <0>;
 		};
 
+		serial0: serial@4500 {
+			cell-index = <0>;
+			device_type = "serial";
+			compatible = "fsl,ns16550", "ns16550";
+			reg = <0x4500 0x100>;
+			clock-frequency = <333333000>;
+			interrupts = <9 0x8>;
+			interrupt-parent = <&ipic>;
+			bootph-all;
+		};
+
+		serial1: serial@4600 {
+			cell-index = <1>;
+			device_type = "serial";
+			compatible = "fsl,ns16550", "ns16550";
+			reg = <0x4600 0x100>;
+			clock-frequency = <333333000>;
+			interrupts = <10 0x8>;
+			interrupt-parent = <&ipic>;
+			bootph-all;
+		};
+
 		ipic: interrupt-controller@700 {
 			compatible = "fsl,ipic";
 			interrupt-controller;
diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
index 5616e22..cf998096 100644
--- a/board/armltd/vexpress64/Kconfig
+++ b/board/armltd/vexpress64/Kconfig
@@ -12,8 +12,13 @@
 config VEXPRESS64_BASE_MODEL
 	bool
 	select SEMIHOSTING
+	imply VIRTIO_MMIO
 	select VIRTIO_BLK if VIRTIO_MMIO
 	select VIRTIO_NET if VIRTIO_MMIO
+	select DM_ETH if VIRTIO_NET
+	imply RTC_PL031
+	select DM_RTC if RTC_PL031
+	imply EFI_SET_TIME if DM_RTC
 	select LINUX_KERNEL_IMAGE_HEADER
 	select POSITION_INDEPENDENT
 
@@ -23,7 +28,7 @@
 config TARGET_VEXPRESS64_BASE_FVP
 	bool "Support Versatile Express ARMv8a FVP BASE model"
 	select VEXPRESS64_BASE_MODEL
-	select OF_BOARD
+	imply OF_HAS_PRIOR_STAGE
 
 config TARGET_VEXPRESS64_BASER_FVP
 	bool "Support Versatile Express ARMv8r64 FVP BASE model"
diff --git a/board/emulation/common/qemu_dfu.c b/board/emulation/common/qemu_dfu.c
index 332d659..7e7d84f 100644
--- a/board/emulation/common/qemu_dfu.c
+++ b/board/emulation/common/qemu_dfu.c
@@ -48,7 +48,7 @@
 	    env_get("dfu_alt_info"))
 		return;
 
-	memset(buf, 0, sizeof(buf));
+	memset(buf, 0, DFU_ALT_BUF_LEN);
 
 	/*
 	 * Currently dfu_alt_info is needed on Qemu ARM64 for
diff --git a/board/ti/am64x/am64x.env b/board/ti/am64x/am64x.env
new file mode 100644
index 0000000..c3960be
--- /dev/null
+++ b/board/ti/am64x/am64x.env
@@ -0,0 +1,63 @@
+#include <environment/ti/ti_armv7_common.env>
+#include <environment/ti/mmc.env>
+#include <environment/ti/k3_dfu.env>
+
+findfdt=
+	if test $board_name = am64x_gpevm; then
+		setenv name_fdt k3-am642-evm.dtb; fi;
+	if test $board_name = am64x_skevm; then
+		setenv name_fdt k3-am642-sk.dtb; fi;
+	if test $name_fdt = undefined; then
+		echo WARNING: Could not determine device tree to use; fi;
+name_kern=Image
+console=ttyS2,115200n8
+args_all=setenv optargs earlycon=ns16550a,mmio32,0x02800000 ${mtdparts}
+run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
+
+boot=mmc
+mmcdev=1
+bootpart=1:2
+bootdir=/boot
+rd_spec=-
+init_mmc=run args_all args_mmc
+get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}
+get_overlay_mmc=
+	fdt address ${fdtaddr};
+	fdt resize 0x100000;
+	for overlay in $name_overlays;
+	do;
+	load mmc ${bootpart} ${dtboaddr} ${bootdir}/${overlay} &&
+	fdt apply ${dtboaddr};
+	done;
+get_kern_mmc=load mmc ${bootpart} ${loadaddr}
+	${bootdir}/${name_kern}
+get_fit_mmc=load mmc ${bootpart} ${addr_fit}
+	${bootdir}/${name_fit}
+partitions=name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}
+
+args_usb=run finduuid;setenv bootargs console=${console}
+	${optargs}
+	root=PARTUUID=${uuid} rw
+	rootfstype=${mmcrootfstype}
+init_usb=run args_all args_usb
+get_fdt_usb=load usb ${bootpart} ${fdtaddr} ${bootdir}/${name_fdt}
+get_overlay_usb=
+	fdt address ${fdtaddr};
+	fdt resize 0x100000;
+	for overlay in $name_overlays;
+	do;
+	load usb ${bootpart} ${dtboaddr} ${bootdir}/${overlay} && fdt apply
+	${dtboaddr};
+	done;
+get_kern_usb=load usb ${bootpart} ${loadaddr}
+	${bootdir}/${name_kern}
+get_fit_usb=load usb ${bootpart} ${addr_fit}
+	${bootdir}/${name_fit}
+usbboot=setenv boot usb;
+	setenv bootpart 0:2;
+	usb start;
+	run findfdt;
+	run init_usb;
+	run get_kern_usb;
+	run get_fdt_usb;
+	run run_kern;
diff --git a/boot/image-board.c b/boot/image-board.c
index c602832..d500da1 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -328,7 +328,7 @@
 	bool done_select = !select;
 	bool done = false;
 	int rd_noffset;
-	ulong rd_addr;
+	ulong rd_addr = 0;
 	char *buf;
 
 	if (CONFIG_IS_ENABLED(FIT)) {
diff --git a/configs/MPC837XERDB_defconfig b/configs/MPC837XERDB_defconfig
index 8f3f54c..7bb878f 100644
--- a/configs/MPC837XERDB_defconfig
+++ b/configs/MPC837XERDB_defconfig
@@ -4,6 +4,8 @@
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_SECT_SIZE=0x10000
 CONFIG_DEFAULT_DEVICE_TREE="mpc8379erdb"
+CONFIG_DEBUG_UART_BASE=0xe0004500
+CONFIG_DEBUG_UART_CLOCK=333333000
 CONFIG_SYS_CLK_FREQ=66666667
 CONFIG_ENV_ADDR=0xFE080000
 # CONFIG_SYS_PCI_64BIT is not set
@@ -118,6 +120,7 @@
 CONFIG_LCRR_CLKDIV_8=y
 CONFIG_FSL_SERDES=y
 CONFIG_USE_UBOOTPATH=y
+CONFIG_DEBUG_UART=y
 CONFIG_SYS_MONITOR_LEN=524288
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
@@ -185,7 +188,9 @@
 CONFIG_VSC7385_ENET=y
 CONFIG_TSEC_ENET=y
 CONFIG_RTC_DS1374=y
-CONFIG_SYS_NS16550_SERIAL=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
+CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_FSL=y
diff --git a/configs/vexpress_fvp_defconfig b/configs/vexpress_fvp_defconfig
new file mode 100644
index 0000000..7362c1f
--- /dev/null
+++ b/configs/vexpress_fvp_defconfig
@@ -0,0 +1,5 @@
+CONFIG_ARM=y
+CONFIG_ARCH_VEXPRESS64=y
+CONFIG_DEFAULT_DEVICE_TREE="arm_fvp"
+CONFIG_IDENT_STRING=" arm_fvp"
+# CONFIG_DISPLAY_CPUINFO is not set
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6998b82..cb2c648 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1152,7 +1152,12 @@
 int ahci_probe_scsi_pci(struct udevice *ahci_dev)
 {
 	ulong base;
-	u16 vendor, device;
+	u16 vendor, device, cmd;
+
+	/* Enable bus mastering */
+	dm_pci_read_config16(ahci_dev, PCI_COMMAND, &cmd);
+	cmd |= PCI_COMMAND_MASTER;
+	dm_pci_write_config16(ahci_dev, PCI_COMMAND, cmd);
 
 	base = (ulong)dm_pci_map_bar(ahci_dev, PCI_BASE_ADDRESS_5, 0, 0,
 				     PCI_REGION_TYPE, PCI_REGION_MEM);
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index ef3e983..c6b9efa 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -319,4 +319,5 @@
 #ifdef CONFIG_ARM_SMCCC_FEATURES
 	.plat_auto = sizeof(struct psci_plat_data),
 #endif
+	.flags = DM_FLAG_PRE_RELOC,
 };
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index c8be5a4..712119c 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -1219,7 +1219,7 @@
 	return count;
 
 err:
-	gpio_free_list_nodev(desc, count - 1);
+	gpio_free_list_nodev(desc, count);
 
 	return ret;
 }
diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c
index 42430d7..b720131 100644
--- a/drivers/soc/soc_ti_k3.c
+++ b/drivers/soc/soc_ti_k3.c
@@ -70,12 +70,12 @@
 
 	switch (soc) {
 	case JTAG_ID_PARTNO_J721E:
-		if (rev > ARRAY_SIZE(j721e_rev_string_map))
+		if (rev >= ARRAY_SIZE(j721e_rev_string_map))
 			goto bail;
 		return j721e_rev_string_map[rev];
 
 	default:
-		if (rev > ARRAY_SIZE(typical_rev_string_map))
+		if (rev >= ARRAY_SIZE(typical_rev_string_map))
 			goto bail;
 		return typical_rev_string_map[rev];
 	};
diff --git a/drivers/sysreset/sysreset_psci.c b/drivers/sysreset/sysreset_psci.c
index 83ecbcb..a8a4152 100644
--- a/drivers/sysreset/sysreset_psci.c
+++ b/drivers/sysreset/sysreset_psci.c
@@ -9,6 +9,11 @@
 #include <linux/errno.h>
 #include <linux/psci.h>
 
+__weak int psci_sysreset_get_status(struct udevice *dev, char *buf, int size)
+{
+	return -EOPNOTSUPP;
+}
+
 static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
 	switch (type) {
@@ -28,10 +33,12 @@
 
 static struct sysreset_ops psci_sysreset_ops = {
 	.request = psci_sysreset_request,
+	.get_status = psci_sysreset_get_status,
 };
 
 U_BOOT_DRIVER(psci_sysreset) = {
 	.name = "psci-sysreset",
 	.id = UCLASS_SYSRESET,
 	.ops = &psci_sysreset_ops,
+	.flags = DM_FLAG_PRE_RELOC,
 };
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 45f0504..f46829e 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -1117,7 +1117,7 @@
 {
 	struct fsg_lun	*curlun = &common->luns[common->lun];
 	u8		*buf = (u8 *) bh->buf;
-	u32		sd, sdinfo;
+	u32		sd, sdinfo = 0;
 	int		valid;
 
 	/*
@@ -1145,7 +1145,6 @@
 	if (!curlun) {		/* Unsupported LUNs are okay */
 		common->bad_lun_okay = 1;
 		sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;
-		sdinfo = 0;
 		valid = 0;
 	} else {
 		sd = curlun->sense_data;
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 0ee74d0..6cb9149 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -1,6 +1,6 @@
 config PVBLOCK
 	bool "Xen para-virtualized block device"
-	depends on DM
+	depends on DM && XEN
 	select BLK
 	help
 	  This driver implements the front-end of the Xen virtual
diff --git a/drivers/xen/hypervisor.c b/drivers/xen/hypervisor.c
index 16c7c96..0b2311b 100644
--- a/drivers/xen/hypervisor.c
+++ b/drivers/xen/hypervisor.c
@@ -264,8 +264,15 @@
 
 int xen_init(void)
 {
+	int el = current_el();
+
 	debug("%s\n", __func__);
 
+	if (el != 1) {
+		puts("XEN:\tnot running from EL1\n");
+		return 0;
+	}
+
 	map_shared_info(NULL);
 	init_events();
 	init_xenbus();
diff --git a/fs/yaffs2/yaffsfs.c b/fs/yaffs2/yaffsfs.c
index 510faae..d615f02 100644
--- a/fs/yaffs2/yaffsfs.c
+++ b/fs/yaffs2/yaffsfs.c
@@ -468,7 +468,7 @@
 	return 0;
 }
 
-LIST_HEAD(yaffsfs_deviceList);
+static LIST_HEAD(yaffsfs_deviceList);
 
 /*
  * yaffsfs_FindDevice
diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h
index 70b1c39..3967cc2 100644
--- a/include/configs/MPC837XERDB.h
+++ b/include/configs/MPC837XERDB.h
@@ -140,7 +140,9 @@
 /*
  * Serial Port
  */
+#if !CONFIG_IS_ENABLED(DM_SERIAL) && !CONFIG_IS_ENABLED(DM_CLK)
 #define CFG_SYS_NS16550_CLK		get_bus_freq(0)
+#endif
 
 #define CFG_SYS_BAUDRATE_TABLE \
 		{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 115200}
diff --git a/include/configs/am64x_evm.h b/include/configs/am64x_evm.h
index 26a7f25..1e37ab4 100644
--- a/include/configs/am64x_evm.h
+++ b/include/configs/am64x_evm.h
@@ -18,91 +18,6 @@
 /* DDR Configuration */
 #define CFG_SYS_SDRAM_BASE1		0x880000000
 
-#define PARTS_DEFAULT \
-	/* Linux partitions */ \
-	"name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}\0"
-
-/* U-Boot general configuration */
-#define EXTRA_ENV_AM642_BOARD_SETTINGS					\
-	"findfdt="							\
-		"if test $board_name = am64x_gpevm; then " \
-			"setenv fdtfile k3-am642-evm.dtb; fi; " \
-		"if test $board_name = am64x_skevm; then " \
-			"setenv fdtfile k3-am642-sk.dtb; fi;" \
-		"if test $fdtfile = undefined; then " \
-			"echo WARNING: Could not determine device tree to use; fi; \0" \
-	"name_kern=Image\0"						\
-	"console=ttyS2,115200n8\0"					\
-	"args_all=setenv optargs earlycon=ns16550a,mmio32,0x02800000 "	\
-		"${mtdparts}\0"						\
-	"run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}\0"
-
-/* U-Boot MMC-specific configuration */
-#define EXTRA_ENV_AM642_BOARD_SETTINGS_MMC				\
-	"boot=mmc\0"							\
-	"mmcdev=1\0"							\
-	"bootpart=1:2\0"						\
-	"bootdir=/boot\0"						\
-	"rd_spec=-\0"							\
-	"init_mmc=run args_all args_mmc\0"				\
-	"get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
-	"get_overlay_mmc="						\
-		"fdt address ${fdtaddr};"				\
-		"fdt resize 0x100000;"					\
-		"for overlay in $name_overlays;"			\
-		"do;"							\
-		"load mmc ${bootpart} ${dtboaddr} ${bootdir}/${overlay} && "	\
-		"fdt apply ${dtboaddr};"				\
-		"done;\0"						\
-	"get_kern_mmc=load mmc ${bootpart} ${loadaddr} "		\
-		"${bootdir}/${name_kern}\0"				\
-	"get_fit_mmc=load mmc ${bootpart} ${addr_fit} "			\
-		"${bootdir}/${name_fit}\0"				\
-	"partitions=" PARTS_DEFAULT
-
-#define EXTRA_ENV_AM642_BOARD_SETTING_USBMSC				\
-	"args_usb=run finduuid;setenv bootargs console=${console} "	\
-		"${optargs} "						\
-		"root=PARTUUID=${uuid} rw "				\
-		"rootfstype=${mmcrootfstype}\0"				\
-	"init_usb=run args_all args_usb\0"				\
-	"get_fdt_usb=load usb ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}\0" \
-	"get_overlay_usb="						\
-		"fdt address ${fdtaddr};"				\
-		"fdt resize 0x100000;"					\
-		"for overlay in $name_overlays;"			\
-		"do;"							\
-		"load usb ${bootpart} ${dtboaddr} ${bootdir}/${overlay} && "	\
-		"fdt apply ${dtboaddr};"				\
-		"done;\0"						\
-	"get_kern_usb=load usb ${bootpart} ${loadaddr} "		\
-		"${bootdir}/${name_kern}\0"				\
-	"get_fit_usb=load usb ${bootpart} ${addr_fit} "			\
-		"${bootdir}/${name_fit}\0"				\
-	"usbboot=setenv boot usb;"					\
-		"setenv bootpart 0:2;"					\
-		"usb start;"						\
-		"run findfdt;"						\
-		"run init_usb;"						\
-		"run get_kern_usb;"					\
-		"run get_fdt_usb;"					\
-		"run run_kern\0"
-
-#define EXTRA_ENV_DFUARGS \
-	DFU_ALT_INFO_MMC \
-	DFU_ALT_INFO_EMMC \
-	DFU_ALT_INFO_RAM \
-	DFU_ALT_INFO_OSPI
-
-/* Incorporate settings into the U-Boot environment */
-#define CFG_EXTRA_ENV_SETTINGS					\
-	DEFAULT_LINUX_BOOT_ENV						\
-	DEFAULT_MMC_TI_ARGS						\
-	EXTRA_ENV_AM642_BOARD_SETTINGS					\
-	EXTRA_ENV_AM642_BOARD_SETTINGS_MMC				\
-	EXTRA_ENV_DFUARGS						\
-	EXTRA_ENV_AM642_BOARD_SETTING_USBMSC
-
 /* Now for the remaining common defines */
 #include <configs/ti_armv7_common.h>
 
diff --git a/test/Kconfig b/test/Kconfig
index 4650282..6e859fb 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -3,7 +3,9 @@
 	help
 	  See doc/README.POST for more details
 
-menuconfig UNIT_TEST
+menu "Unit tests"
+
+config UNIT_TEST
 	bool "Unit tests"
 	help
 	  Select this to compile in unit tests for various parts of
@@ -107,3 +109,5 @@
 source "test/lib/Kconfig"
 source "test/optee/Kconfig"
 source "test/overlay/Kconfig"
+
+endmenu
diff --git a/test/lib/Kconfig b/test/lib/Kconfig
index dbb03e4..ae0aa2f 100644
--- a/test/lib/Kconfig
+++ b/test/lib/Kconfig
@@ -1,23 +1,24 @@
 # SPDX-License-Identifier: GPL-2.0+
 # Copyright 2022 Google LLC
 
-if SANDBOX
-
 config TEST_KCONFIG
 	bool "Enable detection of Kconfig macro errors"
+	depends on SANDBOX
 	help
 	  This is used to test that the IF_ENABLED_INT() macro causes a build error
-	  if the value is used when the CONFIG Is not enabled.
+	  if the value is used when the CONFIG is not enabled.
+
+if TEST_KCONFIG
 
 config TEST_KCONFIG_ENABLE
-	bool "Option to enable"
+	bool "Provide a value for the Kconfig test"
 	help
 	  This is the option that controls whether the value is present.
 
 config TEST_KCONFIG_VALUE
-	int "Value associated with the option"
+	int "Value used in Kconfig test"
 	depends on TEST_KCONFIG_ENABLE
 	help
-	  This is the value whgch is present if TEST_KCONFIG_ENABLE is enabled.
+	  This is the value which is present if TEST_KCONFIG_ENABLE is enabled.
 
-endif # SANDBOX
+endif # TEST_KCONFIG
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index e8c8a6d..0b45863 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -213,7 +213,7 @@
               str(exc))
     finally:
         if mounted:
-            u_boot_utils.run_and_log(cons, 'sudo umount %s' % mnt)
+            u_boot_utils.run_and_log(cons, 'sudo umount --lazy %s' % mnt)
         if loop:
             u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop)
 
@@ -274,7 +274,7 @@
               str(exc))
     finally:
         if mounted:
-            u_boot_utils.run_and_log(cons, 'sudo umount %s' % mnt)
+            u_boot_utils.run_and_log(cons, 'sudo umount --lazy %s' % mnt)
         if loop:
             u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop)
 
diff --git a/tools/env/README b/tools/env/README
index 7092513..480a893 100644
--- a/tools/env/README
+++ b/tools/env/README
@@ -59,5 +59,5 @@
 within which bad blocks are skipped, on NOR it is not used.
 
 To prevent losing changes to the environment and to prevent confusing the MTD
-drivers, a lock file at /var/lock/fw_printenv.lock is used to serialize access
+drivers, a lock file at /run/fw_printenv.lock is used to serialize access
 to the environment.