Merge https://gitlab.denx.de/u-boot/custodians/u-boot-mmc
diff --git a/arch/arm/lib/relocate.S b/arch/arm/lib/relocate.S
index 14b7f61..5102bfa 100644
--- a/arch/arm/lib/relocate.S
+++ b/arch/arm/lib/relocate.S
@@ -78,7 +78,8 @@
  */
 
 ENTRY(relocate_code)
-	adr	r3, relocate_code
+relocate_base:
+	adr	r3, relocate_base
 	ldr	r1, _image_copy_start_ofs
 	add	r1, r3			/* r1 <- Run &__image_copy_start */
 	subs	r4, r0, r1		/* r4 <- Run to copy offset      */
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index e054f30..ca9a2ca 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <addr_map.h>
 #include <cpu_func.h>
 #include <cros_ec.h>
 #include <dm.h>
@@ -155,3 +156,11 @@
 	return 0;
 }
 #endif
+
+int init_addr_map(void)
+{
+	if (IS_ENABLED(CONFIG_ADDR_MAP))
+		addrmap_set_entry(0, 0, CONFIG_SYS_SDRAM_SIZE, 0);
+
+	return 0;
+}
diff --git a/common/cli.c b/common/cli.c
index a7e3d84..a47d6a3 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -126,6 +126,21 @@
 	return rcode;
 }
 
+int run_commandf(const char *fmt, ...)
+{
+	va_list args;
+	char cmd[128];
+	int i, ret;
+
+	va_start(args, fmt);
+	i = vsnprintf(cmd, sizeof(cmd), fmt, args);
+	va_end(args);
+
+	ret = run_command(cmd, 0);
+
+	return ret;
+}
+
 /****************************************************************************/
 
 #if defined(CONFIG_CMD_RUN)
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 572cf8e..eba7bcb 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -31,6 +31,8 @@
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_LOG=y
+CONFIG_LOG_MAX_LEVEL=9
+CONFIG_LOG_DEFAULT_LEVEL=6
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_STACKPROTECTOR=y
 CONFIG_ANDROID_AB=y
@@ -313,6 +315,7 @@
 CONFIG_WDT_SANDBOX=y
 CONFIG_FS_CBFS=y
 CONFIG_FS_CRAMFS=y
+CONFIG_ADDR_MAP=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_ECDSA=y
 CONFIG_ECDSA_VERIFY=y
diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 51095b0..704a6bf 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -66,26 +66,21 @@
    #define LOG_DEBUG
 
 to enable building in of all logging statements in a single file. Put it at
-the top of the file, before any #includes.
-
-To actually get U-Boot to output this you need to also set the default logging
-level - e.g. set CONFIG_LOG_DEFAULT_LEVEL to 7 (:c:data:`LOGL_DEBUG`) or more.
-Otherwise debug output is suppressed and will not be generated.
+the top of the file, before any #includes and any message in the file will be
+written, regardless of the value of CONFIG_LOG_DEFAULT_LEVEL.
 
 Using DEBUG
 -----------
 
 U-Boot has traditionally used a #define called DEBUG to enable debugging on a
-file-by-file basis. The debug() macro compiles to a printf() statement if
-DEBUG is enabled, and an empty statement if not.
+file-by-file basis but LOG_DEBUG are intended to replace it with the logging
+facilities; DEBUG is activated when LOG_DEBUG is activated.
 
 With logging enabled, debug() statements are interpreted as logging output
-with a level of LOGL_DEBUG and a category of LOGC_NONE.
+with a level of LOGL_DEBUG and a category of LOG_CATEGORY.
 
-The logging facilities are intended to replace DEBUG, but if DEBUG is defined
-at the top of a file, then it takes precedence. This means that debug()
-statements will result in output to the console and this output will not be
-logged.
+With logging disabled, the debug() macro compiles to a printf() statement
+if DEBUG is enabled and to an empty statement if not.
 
 Logging statements
 ------------------
diff --git a/doc/usage/cmd/fdt.rst b/doc/usage/cmd/fdt.rst
new file mode 100644
index 0000000..07fed73
--- /dev/null
+++ b/doc/usage/cmd/fdt.rst
@@ -0,0 +1,69 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+fdt command
+===========
+
+Synopis
+-------
+
+::
+
+    fdt addr [-cq] [addr [len]]
+
+Description
+-----------
+
+The fdt command provides access to flat device tree blobs in memory. It has
+many subcommands, some of which are not documented here.
+
+Flags:
+
+-c
+    Select the control FDT (otherwise the working FDT is used).
+-q
+    Don't display errors
+
+The control FDT is the one used by U-Boot itself to control various features,
+including driver model. This should only be changed if you really know what you
+are doing, since once U-Boot starts it maintains pointers into the FDT from the
+various driver model data structures.
+
+The working FDT is the one passed to the Operating System when booting. This
+can be freely modified, so far as U-Boot is concerned, since it does not affect
+U-Boot's operation.
+
+fdt addr
+~~~~~~~~
+
+With no arguments, this shows the address of the current working or control
+FDT.
+
+If the `addr` argument is provided, then this sets the address of the working or
+control FDT to the provided address.
+
+If the `len` argument is provided, then the device tree is expanded to that
+size. This can be used to make space for more nodes and properties. It is
+assumed that there is enough space in memory for this expansion.
+
+Example
+-------
+
+Get the control address and copy that FDT to free memory::
+
+    => fdt addr -c
+    Control fdt: 0aff9fd0
+    => cp.b 0aff9fd0 10000 10000
+    => md 10000 4
+    00010000: edfe0dd0 5b3d0000 78000000 7c270000  ......=[...x..'|
+
+The second word shows the size of the FDT. Now set the working FDT to that
+address and expand it to 0xf000 in size::
+
+    => fdt addr 10000 f000
+    => md 10000 4
+    00010000: edfe0dd0 00f00000 78000000 7c270000  ...........x..'|
+
+Return value
+------------
+
+The return value $? indicates whether the command succeeded.
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 8b98629..16a3db5 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -43,6 +43,7 @@
    cmd/false
    cmd/fatinfo
    cmd/fatload
+   cmd/fdt
    cmd/for
    cmd/load
    cmd/loadm
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 8eb0070..007dc6a 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -18,7 +18,7 @@
 	  consider using CONFIG_SPL_SYS_MALLOC_SIMPLE. In that case you
 	  must provide CONFIG_SPL_SYS_MALLOC_F_LEN to set the size.
 	  In most cases driver model will only allocate a few uclasses
-	  and devices in SPL, so 1KB should be enable. See
+	  and devices in SPL, so 1KB should be enough. See
 	  CONFIG_SPL_SYS_MALLOC_F_LEN for more details on how to enable it.
 
 config TPL_DM
diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index 0df58db..8457733 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -159,8 +159,8 @@
 		memcpy(item->buf, start, item->size);
 	}
 	item_count++;
-	log_debug("* %s: Added type %d, %p, size %x\n", dev->name, type, start,
-		  item->size);
+	log_debug("* %s: Added type %d, %p, size %x\n",
+		  dev ? dev->name : "other", type, start, item->size);
 
 	return 0;
 }
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 22ccd9f..c49695b 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -223,10 +223,14 @@
 			  compat);
 
 		for (entry = driver; entry != driver + n_ents; entry++) {
+			if (drv) {
+				if (drv != entry)
+					continue;
+				if (!entry->of_match)
+					break;
+			}
 			ret = driver_check_compatible(entry->of_match, &id,
 						      compat);
-			if ((drv) && (drv == entry))
-				break;
 			if (!ret)
 				break;
 		}
@@ -241,9 +245,10 @@
 			}
 		}
 
-		log_debug("   - found match at '%s': '%s' matches '%s'\n",
-			  entry->name, entry->of_match->compatible,
-			  id->compatible);
+		if (entry->of_match)
+			log_debug("   - found match at '%s': '%s' matches '%s'\n",
+				  entry->name, entry->of_match->compatible,
+				  id->compatible);
 		ret = device_bind_with_driver_data(parent, entry, name,
 						   id->data, node, &dev);
 		if (ret == -ENODEV) {
diff --git a/drivers/power/regulator/pca9450.c b/drivers/power/regulator/pca9450.c
index 23badaa..fe18693 100644
--- a/drivers/power/regulator/pca9450.c
+++ b/drivers/power/regulator/pca9450.c
@@ -44,7 +44,6 @@
  * @ranges:	pointer to ranges of regulator voltages and matching register
  *		values
  * @numranges:	number of voltage ranges pointed by ranges
- * @dvs:	whether the voltage can be changed when regulator is enabled
  */
 struct pca9450_plat {
 	const char		*name;
@@ -54,7 +53,6 @@
 	u8			volt_mask;
 	struct pca9450_vrange	*ranges;
 	unsigned int		numranges;
-	bool			dvs;
 };
 
 #define PCA_RANGE(_min, _vstep, _sel_low, _sel_hi) \
@@ -63,11 +61,11 @@
 	.min_sel = (_sel_low), .max_sel = (_sel_hi), \
 }
 
-#define PCA_DATA(_name, enreg, enmask, vreg, vmask, _range, _dvs) \
+#define PCA_DATA(_name, enreg, enmask, vreg, vmask, _range) \
 { \
 	.name = (_name), .enable_reg = (enreg), .enablemask = (enmask), \
 	.volt_reg = (vreg), .volt_mask = (vmask), .ranges = (_range), \
-	.numranges = ARRAY_SIZE(_range), .dvs = (_dvs), \
+	.numranges = ARRAY_SIZE(_range) \
 }
 
 static struct pca9450_vrange pca9450_buck123_vranges[] = {
@@ -107,39 +105,39 @@
 	/* Bucks 1-3 which support dynamic voltage scaling */
 	PCA_DATA("BUCK1", PCA9450_BUCK1CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK1OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
-		 pca9450_buck123_vranges, true),
+		 pca9450_buck123_vranges),
 	PCA_DATA("BUCK2", PCA9450_BUCK2CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK2OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
-		 pca9450_buck123_vranges, true),
+		 pca9450_buck123_vranges),
 	PCA_DATA("BUCK3", PCA9450_BUCK3CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK3OUT_DVS0, PCA9450_DVS_BUCK_RUN_MASK,
-		 pca9450_buck123_vranges, true),
+		 pca9450_buck123_vranges),
 	/* Bucks 4-6 which do not support dynamic voltage scaling */
 	PCA_DATA("BUCK4", PCA9450_BUCK4CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK4OUT, PCA9450_DVS_BUCK_RUN_MASK,
-		 pca9450_buck456_vranges, false),
+		 pca9450_buck456_vranges),
 	PCA_DATA("BUCK5", PCA9450_BUCK5CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK5OUT, PCA9450_DVS_BUCK_RUN_MASK,
-		 pca9450_buck456_vranges, false),
+		 pca9450_buck456_vranges),
 	PCA_DATA("BUCK6", PCA9450_BUCK6CTRL, HW_STATE_CONTROL,
 		 PCA9450_BUCK6OUT, PCA9450_DVS_BUCK_RUN_MASK,
-		 pca9450_buck456_vranges, false),
+		 pca9450_buck456_vranges),
 	/* LDOs */
 	PCA_DATA("LDO1", PCA9450_LDO1CTRL, HW_STATE_CONTROL,
 		 PCA9450_LDO1CTRL, PCA9450_LDO12_MASK,
-		 pca9450_ldo1_vranges, false),
+		 pca9450_ldo1_vranges),
 	PCA_DATA("LDO2", PCA9450_LDO2CTRL, HW_STATE_CONTROL,
 		 PCA9450_LDO2CTRL, PCA9450_LDO12_MASK,
-		 pca9450_ldo2_vranges, false),
+		 pca9450_ldo2_vranges),
 	PCA_DATA("LDO3", PCA9450_LDO3CTRL, HW_STATE_CONTROL,
 		 PCA9450_LDO3CTRL, PCA9450_LDO34_MASK,
-		 pca9450_ldo34_vranges, false),
+		 pca9450_ldo34_vranges),
 	PCA_DATA("LDO4", PCA9450_LDO4CTRL, HW_STATE_CONTROL,
 		 PCA9450_LDO4CTRL, PCA9450_LDO34_MASK,
-		 pca9450_ldo34_vranges, false),
+		 pca9450_ldo34_vranges),
 	PCA_DATA("LDO5", PCA9450_LDO5CTRL_H, HW_STATE_CONTROL,
 		 PCA9450_LDO5CTRL_H, PCA9450_LDO5_MASK,
-		 pca9450_ldo5_vranges, false),
+		 pca9450_ldo5_vranges),
 };
 
 static int vrange_find_value(struct pca9450_vrange *r, unsigned int sel,
@@ -246,20 +244,6 @@
 	unsigned int sel;
 	int i, found = 0;
 
-	/*
-	 * An under/overshooting may occur if voltage is changed for other
-	 * regulators but buck 1,2,3 or 4 when regulator is enabled. Prevent
-	 * change to protect the HW
-	 */
-	if (!plat->dvs)
-		if (pca9450_get_enable(dev)) {
-			/* If the value is already set, skip the warning. */
-			if (pca9450_get_value(dev) == uvolt)
-				return 0;
-			pr_err("Only DVS bucks can be changed when enabled\n");
-			return -EINVAL;
-		}
-
 	for (i = 0; i < plat->numranges; i++) {
 		struct pca9450_vrange *r = &plat->ranges[i];
 
diff --git a/include/addr_map.h b/include/addr_map.h
index 55d3a6a..db3712b 100644
--- a/include/addr_map.h
+++ b/include/addr_map.h
@@ -14,7 +14,9 @@
 	unsigned long vaddr;
 };
 
+#ifdef CONFIG_ADDR_MAP
 extern struct addrmap address_map[CONFIG_SYS_NUM_ADDR_MAP];
+#endif
 
 phys_addr_t addrmap_virt_to_phys(void *vaddr);
 void *addrmap_phys_to_virt(phys_addr_t paddr);
diff --git a/include/command.h b/include/command.h
index 0cf12fd..44c91f6 100644
--- a/include/command.h
+++ b/include/command.h
@@ -258,6 +258,16 @@
 int run_command_repeatable(const char *cmd, int flag);
 
 /**
+ * run_commandf() - Run a command created by a format string
+ *
+ * The command cannot be larger than 127 characters
+ *
+ * @fmt: printf() format string
+ * @...: Arguments to use (flag is always 0)
+ */
+int run_commandf(const char *fmt, ...);
+
+/**
  * Run a list of commands separated by ; or even \0
  *
  * Note that if 'len' is not -1, then the command does not need to be nul
diff --git a/include/log.h b/include/log.h
index 8f35c10..7abc70e 100644
--- a/include/log.h
+++ b/include/log.h
@@ -194,6 +194,9 @@
 
 #ifdef LOG_DEBUG
 #define _LOG_DEBUG	LOGL_FORCE_DEBUG
+#ifndef DEBUG
+#define DEBUG
+#endif
 #else
 #define _LOG_DEBUG	0
 #endif
diff --git a/include/test/suites.h b/include/test/suites.h
index ddb8827..44025cc 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -38,6 +38,7 @@
 		      char *const argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
diff --git a/lib/addr_map.c b/lib/addr_map.c
index fb2ef40..9b3e0a5 100644
--- a/lib/addr_map.c
+++ b/lib/addr_map.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <addr_map.h>
+#include <mapmem.h>
 
 struct addrmap address_map[CONFIG_SYS_NUM_ADDR_MAP];
 
@@ -18,7 +19,7 @@
 		if (address_map[i].size == 0)
 			continue;
 
-		addr = (u64)((u32)vaddr);
+		addr = map_to_sysmem(vaddr);
 		base = (u64)(address_map[i].vaddr);
 		upper = (u64)(address_map[i].size) + base - 1;
 
@@ -48,7 +49,7 @@
 
 			offset = address_map[i].paddr - address_map[i].vaddr;
 
-			return (void *)(unsigned long)(paddr - offset);
+			return map_sysmem(paddr - offset, 0);
 		}
 	}
 
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 4b2d7df..c331757 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -7,6 +7,7 @@
 endif
 obj-y += mem.o
 obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
+obj-$(CONFIG_CMD_FDT) += fdt.o
 obj-$(CONFIG_CMD_LOADM) += loadm.o
 obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
 obj-$(CONFIG_CMD_PINMUX) += pinmux.o
diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c
index fb74448..1eb5955 100644
--- a/test/cmd/addrmap.c
+++ b/test/cmd/addrmap.c
@@ -29,9 +29,8 @@
 
 int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-	struct unit_test *tests = ll_entry_start(struct unit_test,
-						 addrmap_test);
-	const int n_ents = ll_entry_count(struct unit_test, addrmap_test);
+	struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap_test);
+	const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap_test);
 
 	return cmd_ut_category("cmd_addrmap", "cmd_addrmap_", tests, n_ents,
 			       argc, argv);
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
new file mode 100644
index 0000000..100a7ef
--- /dev/null
+++ b/test/cmd/fdt.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for fdt command
+ *
+ * Copyright 2022 Google LLCmap_to_sysmem(fdt));
+ */
+
+#include <common.h>
+#include <console.h>
+#include <fdt_support.h>
+#include <mapmem.h>
+#include <asm/global_data.h>
+#include <linux/libfdt.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Declare a new fdt test */
+#define FDT_TEST(_name, _flags)	UNIT_TEST(_name, _flags, fdt_test)
+
+/**
+ * make_test_fdt() - Create an FDT with just a root node
+ *
+ * The size is set to the minimum needed
+ *
+ * @uts: Test state
+ * @fdt: Place to write FDT
+ * @size: Maximum size of space for fdt
+ */
+static int make_test_fdt(struct unit_test_state *uts, void *fdt, int size)
+{
+	ut_assertok(fdt_create(fdt, size));
+	ut_assertok(fdt_finish_reservemap(fdt));
+	ut_assert(fdt_begin_node(fdt, "") >= 0);
+	ut_assertok(fdt_end_node(fdt));
+	ut_assertok(fdt_finish(fdt));
+
+	return 0;
+}
+
+/* Test 'fdt addr' getting/setting address */
+static int fdt_test_addr(struct unit_test_state *uts)
+{
+	const void *fdt_blob, *new_fdt;
+	char fdt[256];
+	ulong addr;
+	int ret;
+
+	ut_assertok(console_record_reset_enable());
+	ut_assertok(run_command("fdt addr -c", 0));
+	ut_assert_nextline("Control fdt: %08lx",
+			   (ulong)map_to_sysmem(gd->fdt_blob));
+	ut_assertok(ut_check_console_end(uts));
+
+	/* The working fdt is not set, so this should fail */
+	set_working_fdt_addr(0);
+	ut_asserteq(CMD_RET_FAILURE, run_command("fdt addr", 0));
+	ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC");
+	ut_assertok(ut_check_console_end(uts));
+
+	/* Set up a working FDT and try again */
+	ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+	addr = map_to_sysmem(fdt);
+	set_working_fdt_addr(addr);
+	ut_assertok(run_command("fdt addr", 0));
+	ut_assert_nextline("Working fdt: %08lx", (ulong)map_to_sysmem(fdt));
+	ut_assertok(ut_check_console_end(uts));
+
+	/* Set the working FDT */
+	set_working_fdt_addr(0);
+	ut_assertok(run_commandf("fdt addr %08x", addr));
+	ut_asserteq(addr, map_to_sysmem(working_fdt));
+	ut_assertok(ut_check_console_end(uts));
+	set_working_fdt_addr(0);
+
+	/* Set the working FDT */
+	fdt_blob = gd->fdt_blob;
+	gd->fdt_blob = NULL;
+	ret = run_commandf("fdt addr -c %08x", addr);
+	new_fdt = gd->fdt_blob;
+	gd->fdt_blob = fdt_blob;
+	ut_assertok(ret);
+	ut_asserteq(addr, map_to_sysmem(new_fdt));
+	ut_assertok(ut_check_console_end(uts));
+
+	/* Test setting an invalid FDT */
+	fdt[0] = 123;
+	ut_asserteq(1, run_commandf("fdt addr %08x", addr));
+	ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC");
+	ut_assertok(ut_check_console_end(uts));
+
+	/* Test detecting an invalid FDT */
+	fdt[0] = 123;
+	set_working_fdt_addr(addr);
+	ut_asserteq(1, run_commandf("fdt addr"));
+	ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC");
+	ut_assertok(ut_check_console_end(uts));
+
+	return 0;
+}
+FDT_TEST(fdt_test_addr, UT_TESTF_CONSOLE_REC);
+
+/* Test 'fdt addr' resizing an fdt */
+static int fdt_test_resize(struct unit_test_state *uts)
+{
+	char fdt[256];
+	const int newsize = sizeof(fdt) / 2;
+	ulong addr;
+
+	ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+	addr = map_to_sysmem(fdt);
+	set_working_fdt_addr(addr);
+
+	/* Test setting and resizing the working FDT to a larger size */
+	ut_assertok(console_record_reset_enable());
+	ut_assertok(run_commandf("fdt addr %08x %x", addr, newsize));
+	ut_assertok(ut_check_console_end(uts));
+
+	/* Try shrinking it */
+	ut_assertok(run_commandf("fdt addr %08x %x", addr, sizeof(fdt) / 4));
+	ut_assert_nextline("New length %d < existing length %d, ignoring",
+			   (int)sizeof(fdt) / 4, newsize);
+	ut_assertok(ut_check_console_end(uts));
+
+	/* ...quietly */
+	ut_assertok(run_commandf("fdt addr -q %08x %x", addr, sizeof(fdt) / 4));
+	ut_assertok(ut_check_console_end(uts));
+
+	/* We cannot easily provoke errors in fdt_open_into(), so ignore that */
+
+	return 0;
+}
+FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC);
+
+int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+	struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
+	const int n_ents = UNIT_TEST_SUITE_COUNT(fdt_test);
+
+	return cmd_ut_category("fdt", "fdt_test_", tests, n_ents, argc, argv);
+}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index d70b726..3789c6b 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -39,6 +39,9 @@
 #if defined(CONFIG_UT_ENV)
 	U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
 #endif
+#ifdef CONFIG_CMD_FDT
+	U_BOOT_CMD_MKENT(fdt, CONFIG_SYS_MAXARGS, 1, do_ut_fdt, "", ""),
+#endif
 #ifdef CONFIG_UT_OPTEE
 	U_BOOT_CMD_MKENT(optee, CONFIG_SYS_MAXARGS, 1, do_ut_optee, "", ""),
 #endif
@@ -131,6 +134,9 @@
 #ifdef CONFIG_UT_ENV
 	"ut env [test-name]\n"
 #endif
+#ifdef CONFIG_CMD_FDT
+	"ut fdt [test-name] - test of the fdt command\n"
+#endif
 #ifdef CONFIG_UT_LIB
 	"ut lib [test-name] - test library functions\n"
 #endif
diff --git a/test/log/log_test.c b/test/log/log_test.c
index db7170f..c5abff8 100644
--- a/test/log/log_test.c
+++ b/test/log/log_test.c
@@ -277,7 +277,7 @@
 	log_content("level %d\n", LOGL_DEBUG_CONTENT);
 	log_io("level %d\n", LOGL_DEBUG_IO);
 
-	for (i = LOGL_EMERG; i <= _LOG_MAX_LEVEL; i++)
+	for (i = LOGL_EMERG; i <= gd->default_log_level; i++)
 		ut_assert_nextline("%*s() level %d", CONFIG_LOGF_FUNC_PAD,
 				   __func__, i);
 	ut_assert_console_end();
@@ -381,7 +381,8 @@
 	ut_assertok(console_record_reset_enable());
 	log_run();
 	check_log_entries_flags_levels(EXPECT_LOG | EXPECT_DIRECT | EXPECT_FORCE,
-				       LOGL_WARNING + 1, _LOG_MAX_LEVEL);
+				       LOGL_WARNING + 1,
+				       min(gd->default_log_level, LOGL_INFO));
 
 	ut_assertok(log_remove_filter("console", filt1));
 	ut_assertok(log_remove_filter("console", filt2));
@@ -420,9 +421,11 @@
 	gd->log_drop_count = 0;
 
 	ut_assertok(console_record_reset_enable());
-	log_run();
 
-	ut_asserteq(gd->log_drop_count, 3 * (LOGL_COUNT - LOGL_FIRST - 1));
+	log_run();
+	ut_asserteq(2 * (LOGL_COUNT - LOGL_FIRST) +
+		    _LOG_MAX_LEVEL - LOGL_FIRST + 1,
+		    gd->log_drop_count);
 	check_log_entries_flags_levels(EXPECT_DEBUG, LOGL_FIRST, CONFIG_LOG_DEFAULT_LEVEL);
 
 	gd->flags |= GD_FLG_LOG_READY;
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 1230662..ad43fce 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -658,6 +658,7 @@
         # Build a new tree with all nodes and properties starting from the
         # entry node
         fsw = libfdt.FdtSw()
+        fsw.INC_SIZE = 65536
         fsw.finish_reservemap()
         to_remove = []
         loadables = []
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index 70ba561..d1b902d 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -186,7 +186,7 @@
     return result
 
 
-def check_patch(fname, verbose=False, show_types=False):
+def check_patch(fname, verbose=False, show_types=False, use_tree=False):
     """Run checkpatch.pl on a file and parse the results.
 
     Args:
@@ -194,6 +194,7 @@
         verbose: True to print out every line of the checkpatch output as it is
             parsed
         show_types: Tell checkpatch to show the type (number) of each message
+        use_tree (bool): If False we'll pass '--no-tree' to checkpatch.
 
     Returns:
         namedtuple containing:
@@ -210,7 +211,9 @@
             stdout: Full output of checkpatch
     """
     chk = find_check_patch()
-    args = [chk, '--no-tree']
+    args = [chk]
+    if not use_tree:
+        args.append('--no-tree')
     if show_types:
         args.append('--show-types')
     output = command.output(*args, fname, raise_on_error=False)
@@ -236,13 +239,13 @@
     line_str = '' if line is None else '%d' % line
     return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg)
 
-def check_patches(verbose, args):
+def check_patches(verbose, args, use_tree):
     '''Run the checkpatch.pl script on each patch'''
     error_count, warning_count, check_count = 0, 0, 0
     col = terminal.Color()
 
     for fname in args:
-        result = check_patch(fname, verbose)
+        result = check_patch(fname, verbose, use_tree=use_tree)
         if not result.ok:
             error_count += result.errors
             warning_count += result.warnings
diff --git a/tools/patman/control.py b/tools/patman/control.py
index b403823..bf426cf 100644
--- a/tools/patman/control.py
+++ b/tools/patman/control.py
@@ -64,7 +64,7 @@
         patchstream.insert_cover_letter(cover_fname, series, to_do)
     return series, cover_fname, patch_files
 
-def check_patches(series, patch_files, run_checkpatch, verbose):
+def check_patches(series, patch_files, run_checkpatch, verbose, use_tree):
     """Run some checks on a set of patches
 
     This santiy-checks the patman tags like Series-version and runs the patches
@@ -77,6 +77,7 @@
         run_checkpatch (bool): True to run checkpatch.pl
         verbose (bool): True to print out every line of the checkpatch output as
             it is parsed
+        use_tree (bool): If False we'll pass '--no-tree' to checkpatch.
 
     Returns:
         bool: True if the patches had no errors, False if they did
@@ -86,7 +87,7 @@
 
     # Check the patches, and run them through 'git am' just to be sure
     if run_checkpatch:
-        ok = checkpatch.check_patches(verbose, patch_files)
+        ok = checkpatch.check_patches(verbose, patch_files, use_tree)
     else:
         ok = True
     return ok
@@ -165,7 +166,7 @@
         col, args.branch, args.count, args.start, args.end,
         args.ignore_binary, args.add_signoff)
     ok = check_patches(series, patch_files, args.check_patch,
-                       args.verbose)
+                       args.verbose, args.check_patch_use_tree)
 
     ok = ok and gitutil.check_suppress_cc_config()
 
diff --git a/tools/patman/main.py b/tools/patman/main.py
index 66d4806..15e7af0 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -81,6 +81,12 @@
 send.add_argument('--no-check', action='store_false', dest='check_patch',
                   default=True,
                   help="Don't check for patch compliance")
+send.add_argument('--tree', dest='check_patch_use_tree', default=False,
+                  action='store_true',
+                  help=("Set `tree` to True. If `tree` is False then we'll "
+                  "pass '--no-tree' to checkpatch (default: tree=%(default)s)"))
+send.add_argument('--no-tree', dest='check_patch_use_tree',
+                  action='store_false', help="Set `tree` to False")
 send.add_argument('--no-tags', action='store_false', dest='process_tags',
                   default=True, help="Don't process subject tags as aliases")
 send.add_argument('--no-signoff', action='store_false', dest='add_signoff',
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 4c847fe..903d6fc 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -23,6 +23,7 @@
     "u-boot": {},
     "linux": {
         "process_tags": "False",
+        "check_patch_use_tree": "True",
     },
     "gcc": {
         "process_tags": "False",
@@ -71,7 +72,7 @@
     >>> config = _ProjectConfigParser("linux")
     >>> config.readfp(StringIO(sample_config))
     >>> sorted((str(a), str(b)) for (a, b) in config.items("settings"))
-    [('am_hero', 'True'), ('process_tags', 'False')]
+    [('am_hero', 'True'), ('check_patch_use_tree', 'True'), ('process_tags', 'False')]
 
     # Check to make sure that settings works with unknown project.
     >>> config = _ProjectConfigParser("unknown")