Merge commit '90ba25b7cb78bd85c6af0b6429226c6616dedefa' of https://source.denx.de/u-boot/custodians/u-boot-nand-flash

In preparation of re-sync of mtd stack, we opt to move the current stack
slowly in order to have a more easy sync and test. We would like to
prepare uboot to support no-jedec and no-onfi compliant nand so we need
to clean up a bit the code we have now and upstream some of the support.
In this series we expect no functional change

Tested on:
 - imx6ull Micron   MT29F2G08ABAGAH4
 - imx8mn  Macronix MX30LF4G18AC
diff --git a/MAINTAINERS b/MAINTAINERS
index 59f7904..cd54e66 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,6 +161,7 @@
 F:	drivers/pinctrl/meson/
 F:	drivers/power/domain/meson-gx-pwrc-vpu.c
 F:	drivers/video/meson/
+F:	drivers/watchdog/meson_gxbb_wdt.c
 F:	include/configs/meson64.h
 F:	include/configs/meson64_android.h
 F:	doc/board/amlogic/
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 0194b9b..d1a8cc7 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -850,10 +850,19 @@
 		};
 	};
 
-	gpio-wdt {
+	wdt-gpio-toggle {
 		gpios = <&gpio_a 7 0>;
 		compatible = "linux,wdt-gpio";
 		hw_margin_ms = <100>;
+		hw_algo = "toggle";
+		always-running;
+	};
+
+	wdt-gpio-level {
+		gpios = <&gpio_a 7 0>;
+		compatible = "linux,wdt-gpio";
+		hw_margin_ms = <100>;
+		hw_algo = "level";
 		always-running;
 	};
 
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index b08aee9..defbe46 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -532,11 +532,10 @@
 		}
 
 		initrd_addr_str = env_get("ramdisk_addr_r");
-		strcpy(initrd_filesize, simple_xtoa(size));
-
-		strncpy(initrd_str, initrd_addr_str, 18);
-		strcat(initrd_str, ":");
-		strncat(initrd_str, initrd_filesize, 9);
+		size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx",
+				initrd_addr_str, size);
+		if (size >= sizeof(initrd_str))
+			return 1;
 	}
 
 	if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r",
diff --git a/common/cli_readline.c b/common/cli_readline.c
index c7614a4..e86ee73 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -321,6 +321,7 @@
 					act = ESC_CONVERTED;
 					break;	/* pass off to ^N handler */
 				case '1':
+				case '2':
 				case '3':
 				case '4':
 				case '7':
@@ -332,7 +333,8 @@
 					break;
 				}
 			} else if (esc_len == 3) {
-				if (ichar == '~') {
+				switch (ichar) {
+				case '~':
 					switch (esc_save[2]) {
 					case '3':	/* Delete key */
 						ichar = CTL_CH('d');
@@ -349,9 +351,25 @@
 						act = ESC_CONVERTED;
 						break;	/* pass to ^E handler */
 					}
+					break;
+				case '0':
+					if (esc_save[2] == '2')
+						act = ESC_SAVE;
+					break;
+				}
+			} else if (esc_len == 4) {
+				switch (ichar) {
+				case '0':
+				case '1':
+					act = ESC_SAVE;
+					break;		/* bracketed paste */
+				}
+			} else if (esc_len == 5) {
+				if (ichar == '~') {	/* bracketed paste */
+					ichar = 0;
+					act = ESC_CONVERTED;
 				}
 			}
-
 			switch (act) {
 			case ESC_SAVE:
 				esc_save[esc_len++] = ichar;
diff --git a/configs/octeon_ebb7304_defconfig b/configs/octeon_ebb7304_defconfig
index 0a18b94..ee83cd4 100644
--- a/configs/octeon_ebb7304_defconfig
+++ b/configs/octeon_ebb7304_defconfig
@@ -28,6 +28,7 @@
 CONFIG_CMD_PART=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_WDT=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -90,4 +91,5 @@
 CONFIG_USB_ETHER_MCS7830=y
 CONFIG_USB_ETHER_RTL8152=y
 CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_WDT=y
 CONFIG_HEXDUMP=y
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 9c7fadf..cc2ba50 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -73,6 +73,8 @@
 +-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
 | PCIe (+NVMe)                  | *N/A*     | *N/A*           | *N/A*        | **Yes**     | **Yes**    | **Yes**     | **Yes**      |
 +-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
+| Watchdog                      | *N/A*     | **Yes**         | *N/A*        | *N/A*       | *N/A*      | *N/A*       | *N/A*        |
++-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
 
 Boot Documentation
 ------------------
diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst
index 682051a..ee544ad 100644
--- a/doc/build/gcc.rst
+++ b/doc/build/gcc.rst
@@ -30,7 +30,7 @@
       pkg-config python3 python3-asteval python3-coverage \
       python3-pkg-resources python3-pycryptodome python3-pyelftools \
       python3-pytest python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme \
-      python3-subunit python3-testtools python3-virtualenv swig
+      python3-subunit python3-testtools python3-virtualenv swig uuid-dev
 
 SUSE based
 ~~~~~~~~~~
diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst
index 2b13818..a6bc37b 100644
--- a/doc/develop/codingstyle.rst
+++ b/doc/develop/codingstyle.rst
@@ -41,7 +41,7 @@
 
     * The exception here is Python which requires 4 spaces instead.
 
-  * All source files need to be in "Unix" and not "DOS" or "Windows" formatted,
+  * All source files need to be in "Unix" and not "DOS" or "Windows" format,
     with respect to line ends.
 
   * Do not add more than 2 consecutive empty lines to source files
diff --git a/doc/device-tree-bindings/watchdog/gpio-wdt.txt b/doc/device-tree-bindings/watchdog/gpio-wdt.txt
index c9a8559..746c2c0 100644
--- a/doc/device-tree-bindings/watchdog/gpio-wdt.txt
+++ b/doc/device-tree-bindings/watchdog/gpio-wdt.txt
@@ -5,7 +5,12 @@
 Required properties:
 
 - compatible: Must be "linux,wdt-gpio".
-- gpios: gpio to toggle when wdt driver reset method is called.
+- gpios: From common gpio binding; gpio connection to WDT reset pin.
+- hw_algo: The algorithm used by the driver. Should be one of the
+  following values:
+  - toggle: Toggle from high-to-low or low-to-high when resetting the watchdog.
+  - level: Maintain a constant high/low level, and trigger a short pulse when
+    resetting the watchdog. Active level is determined by the GPIO flags.
 - always-running: Boolean property indicating that the watchdog cannot
   be disabled. At present, U-Boot only supports this kind of GPIO
   watchdog.
@@ -15,5 +20,6 @@
 	gpio-wdt {
 		gpios = <&gpio0 1 0>;
 		compatible = "linux,wdt-gpio";
+		hw_algo = "toggle";
 		always-running;
 	};
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 6043fe7..50e6a1e 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -175,6 +175,13 @@
 	help
 	  Select this to enable max6370 watchdog timer.
 
+config WDT_MESON_GXBB
+	bool "Amlogic watchdog timer support"
+	depends on WDT
+	help
+	  Select this to enable Meson watchdog timer,
+	  which can be found on some Amlogic platforms.
+
 config WDT_MPC8xx
 	bool "MPC8xx watchdog timer support"
 	depends on WDT && MPC8xx
@@ -213,14 +220,13 @@
 	  It performs full SoC reset.
 
 config WDT_OCTEONTX
-	bool "OcteonTX core watchdog support"
-	depends on WDT && (ARCH_OCTEONTX || ARCH_OCTEONTX2)
+	bool "Octeon core watchdog support"
+	depends on WDT && (ARCH_OCTEON || ARCH_OCTEONTX || ARCH_OCTEONTX2)
 	default y
 	imply WATCHDOG
 	help
-	  This enables OcteonTX watchdog driver, which can be
-	  found on OcteonTX/TX2 chipsets and inline with driver model.
-	  Only supports watchdog reset.
+	  This enables the Octeon watchdog driver, which can be found on
+	  various Octeon parts such as Octeon II/III and OcteonTX/TX2.
 
 config WDT_OMAP3
 	bool "TI OMAP watchdog timer support"
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 1f6199b..0e2f582 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -27,6 +27,7 @@
 obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
 obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o
 obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o
+obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o
 obj-$(CONFIG_WDT_MPC8xx) += mpc8xx_wdt.o
 obj-$(CONFIG_WDT_MT7620) += mt7620_wdt.o
 obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index 982a66b..fe06ec8 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -4,20 +4,38 @@
 #include <dm/device_compat.h>
 #include <wdt.h>
 #include <asm/gpio.h>
+#include <linux/delay.h>
+
+enum {
+	HW_ALGO_TOGGLE,
+	HW_ALGO_LEVEL,
+};
 
 struct gpio_wdt_priv {
-	struct gpio_desc gpio;
-	bool always_running;
-	int state;
+	struct		gpio_desc gpio;
+	unsigned int	hw_algo;
+	bool		always_running;
+	int		state;
 };
 
 static int gpio_wdt_reset(struct udevice *dev)
 {
 	struct gpio_wdt_priv *priv = dev_get_priv(dev);
 
-	priv->state = !priv->state;
-
-	return dm_gpio_set_value(&priv->gpio, priv->state);
+	switch (priv->hw_algo) {
+	case HW_ALGO_TOGGLE:
+		/* Toggle output pin */
+		priv->state = !priv->state;
+		dm_gpio_set_value(&priv->gpio, priv->state);
+		break;
+	case HW_ALGO_LEVEL:
+		/* Pulse */
+		dm_gpio_set_value(&priv->gpio, 1);
+		udelay(1);
+		dm_gpio_set_value(&priv->gpio, 0);
+		break;
+	}
+	return 0;
 }
 
 static int gpio_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
@@ -34,6 +52,16 @@
 {
 	struct gpio_wdt_priv *priv = dev_get_priv(dev);
 	int ret;
+	const char *algo = dev_read_string(dev, "hw_algo");
+
+	if (!algo)
+		return -EINVAL;
+	if (!strcmp(algo, "toggle"))
+		priv->hw_algo = HW_ALGO_TOGGLE;
+	else if (!strcmp(algo, "level"))
+		priv->hw_algo = HW_ALGO_LEVEL;
+	else
+		return -EINVAL;
 
 	priv->always_running = dev_read_bool(dev, "always-running");
 	ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
new file mode 100644
index 0000000..6ab0058
--- /dev/null
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 BayLibre, SAS.
+ */
+
+#include <clk.h>
+#include <dm.h>
+#include <dm/device_compat.h>
+#include <reset.h>
+#include <wdt.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+
+#define GXBB_WDT_CTRL_REG			0x0
+#define GXBB_WDT_TCNT_REG			0x8
+#define GXBB_WDT_RSET_REG			0xc
+
+#define GXBB_WDT_CTRL_SYS_RESET_NOW		BIT(26)
+#define GXBB_WDT_CTRL_CLKDIV_EN			BIT(25)
+#define GXBB_WDT_CTRL_CLK_EN			BIT(24)
+#define GXBB_WDT_CTRL_EE_RESET			BIT(21)
+#define GXBB_WDT_CTRL_EN			BIT(18)
+
+#define GXBB_WDT_CTRL_DIV_MASK			GENMASK(17, 0)
+#define GXBB_WDT_TCNT_SETUP_MASK		GENMASK(15, 0)
+
+
+struct amlogic_wdt_priv {
+	void __iomem *reg_base;
+};
+
+static int amlogic_wdt_set_timeout(struct udevice *dev, u64 timeout_ms)
+{
+	struct amlogic_wdt_priv *data = dev_get_priv(dev);
+
+	if (timeout_ms > GXBB_WDT_TCNT_SETUP_MASK) {
+		dev_warn(dev, "%s: timeout_ms=%llu: maximum watchdog timeout exceeded\n",
+		         __func__, timeout_ms);
+		timeout_ms = GXBB_WDT_TCNT_SETUP_MASK;
+	}
+
+	writel(timeout_ms, data->reg_base + GXBB_WDT_TCNT_REG);
+
+	return 0;
+}
+
+static int amlogic_wdt_stop(struct udevice *dev)
+{
+	struct amlogic_wdt_priv *data = dev_get_priv(dev);
+
+	writel(readl(data->reg_base + GXBB_WDT_CTRL_REG) & ~GXBB_WDT_CTRL_EN,
+	       data->reg_base + GXBB_WDT_CTRL_REG);
+
+	return 0;
+}
+
+static int amlogic_wdt_start(struct udevice *dev, u64 time_ms, ulong flags)
+{
+	struct amlogic_wdt_priv *data = dev_get_priv(dev);
+
+	writel(readl(data->reg_base + GXBB_WDT_CTRL_REG) | GXBB_WDT_CTRL_EN,
+	       data->reg_base + GXBB_WDT_CTRL_REG);
+
+	return amlogic_wdt_set_timeout(dev, time_ms);
+}
+
+static int amlogic_wdt_reset(struct udevice *dev)
+{
+	struct amlogic_wdt_priv *data = dev_get_priv(dev);
+
+	writel(0, data->reg_base + GXBB_WDT_RSET_REG);
+
+	return 0;
+}
+
+static int amlogic_wdt_expire_now(struct udevice *dev, ulong flags)
+{
+	struct amlogic_wdt_priv *data = dev_get_priv(dev);
+
+	writel(0, data->reg_base + GXBB_WDT_CTRL_SYS_RESET_NOW);
+
+	return 0;
+}
+
+static int amlogic_wdt_probe(struct udevice *dev)
+{
+	struct amlogic_wdt_priv *data = dev_get_priv(dev);
+	int ret;
+
+	data->reg_base = dev_remap_addr(dev);
+	if (!data->reg_base)
+		return -EINVAL;
+
+	struct clk clk;
+
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret)
+		return ret;
+
+	ret = clk_enable(&clk);
+	if (ret) {
+		clk_free(&clk);
+		return ret;
+	}
+
+	/* Setup with 1ms timebase */
+	writel(((clk_get_rate(&clk) / 1000) & GXBB_WDT_CTRL_DIV_MASK) |
+	       GXBB_WDT_CTRL_EE_RESET |
+	       GXBB_WDT_CTRL_CLK_EN |
+	       GXBB_WDT_CTRL_CLKDIV_EN,
+	       data->reg_base + GXBB_WDT_CTRL_REG);
+
+	return 0;
+}
+
+static const struct wdt_ops amlogic_wdt_ops = {
+	.start = amlogic_wdt_start,
+	.reset = amlogic_wdt_reset,
+	.stop = amlogic_wdt_stop,
+	.expire_now = amlogic_wdt_expire_now,
+};
+
+static const struct udevice_id amlogic_wdt_ids[] = {
+	{ .compatible = "amlogic,meson-gxbb-wdt" },
+	{}
+};
+
+U_BOOT_DRIVER(amlogic_wdt) = {
+	.name = "amlogic_wdt",
+	.id = UCLASS_WDT,
+	.of_match = amlogic_wdt_ids,
+	.priv_auto = sizeof(struct amlogic_wdt_priv),
+	.probe = amlogic_wdt_probe,
+	.ops = &amlogic_wdt_ops,
+	.flags = DM_FLAG_PRE_RELOC,
+};
diff --git a/drivers/watchdog/octeontx_wdt.c b/drivers/watchdog/octeontx_wdt.c
index 01b244d..c79d953 100644
--- a/drivers/watchdog/octeontx_wdt.c
+++ b/drivers/watchdog/octeontx_wdt.c
@@ -15,16 +15,22 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define CORE0_WDOG_OFFSET	0x40000
-#define CORE0_POKE_OFFSET	0x50000
 #define CORE0_POKE_OFFSET_MASK	0xfffffULL
 
 #define WDOG_MODE		GENMASK_ULL(1, 0)
 #define WDOG_LEN		GENMASK_ULL(19, 4)
 #define WDOG_CNT		GENMASK_ULL(43, 20)
 
+struct octeontx_wdt_data {
+	u32 wdog_offset;
+	u32 poke_offset;
+	int timer_shift;
+	bool has_clk;
+};
+
 struct octeontx_wdt {
 	void __iomem *reg;
+	const struct octeontx_wdt_data *data;
 	struct clk clk;
 };
 
@@ -34,12 +40,16 @@
 	u64 clk_rate, val;
 	u64 tout_wdog;
 
-	clk_rate = clk_get_rate(&priv->clk);
-	if (IS_ERR_VALUE(clk_rate))
-		return -EINVAL;
+	if (priv->data->has_clk) {
+		clk_rate = clk_get_rate(&priv->clk);
+		if (IS_ERR_VALUE(clk_rate))
+			return -EINVAL;
+	} else {
+		clk_rate = gd->bus_clk;
+	}
 
-	/* Watchdog counts in 1024 cycle steps */
-	tout_wdog = (clk_rate * timeout_ms / 1000) >> 10;
+	/* Watchdog counts in configured cycle steps */
+	tout_wdog = (clk_rate * timeout_ms / 1000) >> priv->data->timer_shift;
 
 	/*
 	 * We can only specify the upper 16 bits of a 24 bit value.
@@ -54,7 +64,7 @@
 	val = FIELD_PREP(WDOG_MODE, 0x3) |
 		FIELD_PREP(WDOG_LEN, tout_wdog) |
 		FIELD_PREP(WDOG_CNT, tout_wdog << 8);
-	writeq(val, priv->reg + CORE0_WDOG_OFFSET);
+	writeq(val, priv->reg + priv->data->wdog_offset);
 
 	return 0;
 }
@@ -63,7 +73,7 @@
 {
 	struct octeontx_wdt *priv = dev_get_priv(dev);
 
-	writeq(0, priv->reg + CORE0_WDOG_OFFSET);
+	writeq(0, priv->reg + priv->data->wdog_offset);
 
 	return 0;
 }
@@ -82,7 +92,7 @@
 {
 	struct octeontx_wdt *priv = dev_get_priv(dev);
 
-	writeq(~0ULL, priv->reg + CORE0_POKE_OFFSET);
+	writeq(~0ULL, priv->reg + priv->data->poke_offset);
 
 	return 0;
 }
@@ -103,6 +113,10 @@
 	if (!priv->reg)
 		return -EINVAL;
 
+	priv->data = (void *)dev_get_driver_data(dev);
+	if (!priv->data)
+		return -EINVAL;
+
 	/*
 	 * Save base register address in reg masking lower 20 bits
 	 * as 0xa0000 appears when extracted from the DT
@@ -110,13 +124,15 @@
 	priv->reg = (void __iomem *)(((u64)priv->reg &
 				      ~CORE0_POKE_OFFSET_MASK));
 
-	ret = clk_get_by_index(dev, 0, &priv->clk);
-	if (ret < 0)
-		return ret;
+	if (priv->data->has_clk) {
+		ret = clk_get_by_index(dev, 0, &priv->clk);
+		if (ret < 0)
+			return ret;
 
-	ret = clk_enable(&priv->clk);
-	if (ret)
-		return ret;
+		ret = clk_enable(&priv->clk);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
@@ -128,8 +144,23 @@
 	.expire_now = octeontx_wdt_expire_now,
 };
 
+static const struct octeontx_wdt_data octeontx_data = {
+	.wdog_offset = 0x40000,
+	.poke_offset = 0x50000,
+	.timer_shift = 10,
+	.has_clk = true,
+};
+
+static const struct octeontx_wdt_data octeon_data = {
+	.wdog_offset = 0x20000,
+	.poke_offset = 0x30000,
+	.timer_shift = 10,
+	.has_clk = false,
+};
+
 static const struct udevice_id octeontx_wdt_ids[] = {
-	{ .compatible = "arm,sbsa-gwdt" },
+	{ .compatible = "arm,sbsa-gwdt", .data = (ulong)&octeontx_data },
+	{ .compatible = "cavium,octeon-7890-ciu3", .data = (ulong)&octeon_data },
 	{}
 };
 
@@ -138,7 +169,7 @@
 	.id = UCLASS_WDT,
 	.of_match = octeontx_wdt_ids,
 	.ops = &octeontx_wdt_ops,
-	.priv_auto	= sizeof(struct octeontx_wdt),
+	.priv_auto = sizeof(struct octeontx_wdt),
 	.probe = octeontx_wdt_probe,
 	.remove = octeontx_wdt_remove,
 	.flags = DM_FLAG_OS_PREPARE,
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index aaaa25ce..f54c244 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -66,7 +66,6 @@
 endif
 obj-y += efi_watchdog.o
 obj-$(CONFIG_EFI_ESRT) += efi_esrt.o
-obj-$(CONFIG_LCD) += efi_gop.o
 obj-$(CONFIG_DM_VIDEO) += efi_gop.o
 obj-$(CONFIG_BLK) += efi_disk.o
 obj-$(CONFIG_NET) += efi_net.o
diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index 2c81859..5908b5c 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -8,7 +8,6 @@
 #include <common.h>
 #include <dm.h>
 #include <efi_loader.h>
-#include <lcd.h>
 #include <log.h>
 #include <malloc.h>
 #include <video.h>
@@ -459,11 +458,7 @@
 	if (ret != EFI_SUCCESS)
 		return EFI_EXIT(ret);
 
-#ifdef CONFIG_DM_VIDEO
 	video_sync_all();
-#else
-	lcd_sync();
-#endif
 
 	return EFI_EXIT(EFI_SUCCESS);
 }
diff --git a/test/dm/wdt.c b/test/dm/wdt.c
index ee615f0..535f00a 100644
--- a/test/dm/wdt.c
+++ b/test/dm/wdt.c
@@ -44,20 +44,20 @@
 }
 DM_TEST(dm_test_wdt_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
-static int dm_test_wdt_gpio(struct unit_test_state *uts)
+static int dm_test_wdt_gpio_toggle(struct unit_test_state *uts)
 {
 	/*
 	 * The sandbox wdt gpio is "connected" to gpio bank a, offset
 	 * 7. Use the sandbox back door to verify that the gpio-wdt
-	 * driver behaves as expected.
+	 * driver behaves as expected when using the 'toggle' algorithm.
 	 */
 	struct udevice *wdt, *gpio;
 	const u64 timeout = 42;
 	const int offset = 7;
 	int val;
 
-	ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
-						DM_DRIVER_GET(wdt_gpio), &wdt));
+	ut_assertok(uclass_get_device_by_name(UCLASS_WDT,
+					      "wdt-gpio-toggle", &wdt));
 	ut_assertnonnull(wdt);
 
 	ut_assertok(uclass_get_device_by_name(UCLASS_GPIO, "base-gpios", &gpio));
@@ -74,7 +74,39 @@
 
 	return 0;
 }
-DM_TEST(dm_test_wdt_gpio, UT_TESTF_SCAN_FDT);
+DM_TEST(dm_test_wdt_gpio_toggle, UT_TESTF_SCAN_FDT);
+
+static int dm_test_wdt_gpio_level(struct unit_test_state *uts)
+{
+	/*
+	 * The sandbox wdt gpio is "connected" to gpio bank a, offset
+	 * 7. Use the sandbox back door to verify that the gpio-wdt
+	 * driver behaves as expected when using the 'level' algorithm.
+	 */
+	struct udevice *wdt, *gpio;
+	const u64 timeout = 42;
+	const int offset = 7;
+	int val;
+
+	ut_assertok(uclass_get_device_by_name(UCLASS_WDT,
+					      "wdt-gpio-level", &wdt));
+	ut_assertnonnull(wdt);
+
+	ut_assertok(uclass_get_device_by_name(UCLASS_GPIO, "base-gpios", &gpio));
+	ut_assertnonnull(gpio);
+	ut_assertok(wdt_start(wdt, timeout, 0));
+
+	val = sandbox_gpio_get_value(gpio, offset);
+	ut_assertok(wdt_reset(wdt));
+	ut_asserteq(val, sandbox_gpio_get_value(gpio, offset));
+	ut_assertok(wdt_reset(wdt));
+	ut_asserteq(val, sandbox_gpio_get_value(gpio, offset));
+
+	ut_asserteq(-ENOSYS, wdt_stop(wdt));
+
+	return 0;
+}
+DM_TEST(dm_test_wdt_gpio_level, UT_TESTF_SCAN_FDT);
 
 static int dm_test_wdt_watchdog_reset(struct unit_test_state *uts)
 {
@@ -86,8 +118,8 @@
 	uint reset_count;
 	int val;
 
-	ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
-						DM_DRIVER_GET(wdt_gpio), &gpio_wdt));
+	ut_assertok(uclass_get_device_by_name(UCLASS_WDT,
+					      "wdt-gpio-toggle", &gpio_wdt));
 	ut_assertnonnull(gpio_wdt);
 	ut_assertok(uclass_get_device_by_driver(UCLASS_WDT,
 						DM_DRIVER_GET(wdt_sandbox), &sandbox_wdt));
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
index 4400b8f..d6ca9b1 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
@@ -40,6 +40,7 @@
         with u_boot_console.log.section('Test Case 1-a, before reboot'):
             output = u_boot_console.run_command_list([
                 'host bind 0 %s' % disk_img,
+                'printenv -e PlatformLangCodes', # workaround for terminal size determination
                 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi',
                 'efidebug boot order 1',
                 'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
@@ -115,6 +116,7 @@
         with u_boot_console.log.section('Test Case 2-a, before reboot'):
             output = u_boot_console.run_command_list([
                 'host bind 0 %s' % disk_img,
+                'printenv -e PlatformLangCodes', # workaround for terminal size determination
                 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi',
                 'efidebug boot order 1',
                 'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
@@ -192,6 +194,7 @@
         with u_boot_console.log.section('Test Case 3-a, before reboot'):
             output = u_boot_console.run_command_list([
                 'host bind 0 %s' % disk_img,
+                'printenv -e PlatformLangCodes', # workaround for terminal size determination
                 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi',
                 'efidebug boot order 1',
                 'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
index 1b5a1bb..2bbaa9c 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
@@ -112,6 +112,7 @@
         with u_boot_console.log.section('Test Case 2-a, before reboot'):
             output = u_boot_console.run_command_list([
                 'host bind 0 %s' % disk_img,
+                'printenv -e PlatformLangCodes', # workaround for terminal size determination
                 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi',
                 'efidebug boot order 1',
                 'env set -e -nv -bs -rt OsIndications =0x0000000000000004',
@@ -189,6 +190,7 @@
         with u_boot_console.log.section('Test Case 3-a, before reboot'):
             output = u_boot_console.run_command_list([
                 'host bind 0 %s' % disk_img,
+                'printenv -e PlatformLangCodes', # workaround for terminal size determination
                 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi',
                 'efidebug boot order 1',
                 'env set -e -nv -bs -rt OsIndications =0x0000000000000004',