Merge tag 'dm-pull-3mar21' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm

dm: Fix an obscure bug with empty of-platdata
Fixes for ns16550 base address and frequency-reading
Other minor fixes
diff --git a/common/Kconfig.boot b/common/Kconfig.boot
index 70c02b9..e650c60 100644
--- a/common/Kconfig.boot
+++ b/common/Kconfig.boot
@@ -449,6 +449,7 @@
 
 config BOOTSTAGE_RECORD_COUNT
 	int "Number of boot stage records to store"
+	depends on BOOTSTAGE
 	default 30
 	help
 	  This is the size of the bootstage record list and is the maximum
@@ -456,6 +457,7 @@
 
 config SPL_BOOTSTAGE_RECORD_COUNT
 	int "Number of boot stage records to store for SPL"
+	depends on SPL_BOOTSTAGE
 	default 5
 	help
 	  This is the size of the bootstage record list and is the maximum
@@ -463,6 +465,7 @@
 
 config TPL_BOOTSTAGE_RECORD_COUNT
 	int "Number of boot stage records to store for TPL"
+	depends on TPL_BOOTSTAGE
 	default 5
 	help
 	  This is the size of the bootstage record list and is the maximum
diff --git a/common/bootstage.c b/common/bootstage.c
index d5b78b9..2c0110c 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -349,7 +349,7 @@
 	}
 	if (data->rec_count > RECORD_COUNT)
 		printf("Overflowed internal boot id table by %d entries\n"
-		       "Please increase CONFIG_(SPL_)BOOTSTAGE_RECORD_COUNT\n",
+		       "Please increase CONFIG_(SPL_TPL_)BOOTSTAGE_RECORD_COUNT\n",
 		       data->rec_count - RECORD_COUNT);
 
 	puts("\nAccumulated time:\n");
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 9d7d68c..e2f229b 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -231,6 +231,18 @@
 }
 
 #ifdef CONFIG_BLK
+
+int sandbox_host_unbind(struct udevice *dev)
+{
+	struct host_block_dev *host_dev;
+
+	/* Data validity is checked in host_dev_bind() */
+	host_dev = dev_get_plat(dev);
+	os_close(host_dev->fd);
+
+	return 0;
+}
+
 static const struct blk_ops sandbox_host_blk_ops = {
 	.read	= host_block_read,
 	.write	= host_block_write,
@@ -240,6 +252,7 @@
 	.name		= "sandbox_host_blk",
 	.id		= UCLASS_BLK,
 	.ops		= &sandbox_host_blk_ops,
+	.unbind		= sandbox_host_unbind,
 	.plat_auto	= sizeof(struct host_block_dev),
 };
 #else
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 6251349..81f6880 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -92,15 +92,19 @@
 	if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
 		dev->seq_ = uclass_find_next_free_seq(uc);
 
+	/* Check if we need to allocate plat */
 	if (drv->plat_auto) {
 		bool alloc = !plat;
 
+		/*
+		 * For of-platdata, we try use the existing data, but if
+		 * plat_auto is larger, we must allocate a new space
+		 */
 		if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
-			if (of_plat_size) {
+			if (of_plat_size)
 				dev_or_flags(dev, DM_FLAG_OF_PLATDATA);
-				if (of_plat_size < drv->plat_auto)
-					alloc = true;
-			}
+			if (of_plat_size < drv->plat_auto)
+				alloc = true;
 		}
 		if (alloc) {
 			dev_or_flags(dev, DM_FLAG_ALLOC_PDATA);
@@ -109,6 +113,11 @@
 				ret = -ENOMEM;
 				goto fail_alloc1;
 			}
+
+			/*
+			 * For of-platdata, copy the old plat into the new
+			 * space
+			 */
 			if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat)
 				memcpy(ptr, plat, of_plat_size);
 			dev_set_plat(dev, ptr);
@@ -128,9 +137,8 @@
 
 	if (parent) {
 		size = parent->driver->per_child_plat_auto;
-		if (!size) {
+		if (!size)
 			size = parent->uclass->uc_drv->per_child_plat_auto;
-		}
 		if (size) {
 			dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA);
 			ptr = calloc(1, size);
@@ -200,14 +208,18 @@
 		}
 	}
 fail_alloc3:
-	if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
-		free(dev_get_uclass_plat(dev));
-		dev_set_uclass_plat(dev, NULL);
+	if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
+		if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
+			free(dev_get_uclass_plat(dev));
+			dev_set_uclass_plat(dev, NULL);
+		}
 	}
 fail_alloc2:
-	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
-		free(dev_get_plat(dev));
-		dev_set_plat(dev, NULL);
+	if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
+		if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
+			free(dev_get_plat(dev));
+			dev_set_plat(dev, NULL);
+		}
 	}
 fail_alloc1:
 	devres_release_all(dev);
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index b9e99ba..cc121ee 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -483,7 +483,7 @@
 	return 0;
 }
 
-static int ns16550_serial_assign_base(struct ns16550_plat *plat, ulong base)
+static int ns16550_serial_assign_base(struct ns16550_plat *plat, fdt_addr_t base)
 {
 	if (base == FDT_ADDR_T_NONE)
 		return -EINVAL;
@@ -564,6 +564,8 @@
 	if (!plat->clock)
 		plat->clock = dev_read_u32_default(dev, "clock-frequency",
 						   CONFIG_SYS_NS16550_CLK);
+	if (!plat->clock)
+		plat->clock = CONFIG_SYS_NS16550_CLK;
 	if (!plat->clock) {
 		debug("ns16550 clock not defined\n");
 		return -EINVAL;
diff --git a/dts/Kconfig b/dts/Kconfig
index 71f5055..00ac29a 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -60,7 +60,7 @@
 
 config OF_LIVE
 	bool "Enable use of a live tree"
-	depends on OF_CONTROL
+	depends on DM && OF_CONTROL
 	help
 	  Normally U-Boot uses a flat device tree which saves space and
 	  avoids the need to unpack the tree before use. However a flat
diff --git a/lib/Kconfig b/lib/Kconfig
index b35a71a..7f4c30e 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -22,7 +22,7 @@
 
 config BINMAN_FDT
 	bool "Allow access to binman information in the device tree"
-	depends on BINMAN && OF_CONTROL
+	depends on BINMAN && DM && OF_CONTROL
 	default y
 	help
 	  This enables U-Boot to access information about binman entries,
diff --git a/tools/patman/series.py b/tools/patman/series.py
index a6746e8..41a1173 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -271,7 +271,7 @@
                 cc += get_maintainer.GetMaintainer(dir_list, commit.patch)
             for x in set(cc) & set(settings.bounces):
                 print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
-            cc = set(cc) - set(settings.bounces)
+            cc = list(set(cc) - set(settings.bounces))
             if limit is not None:
                 cc = cc[:limit]
             all_ccs += cc