diff --git a/common/console.c b/common/console.c
index b7ed9a3b9debc312d5cbc8addb210489d7c253cf..ec4af3bd90dfdca971b912ec65034d46754d024c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <console.h>
 #include <debug_uart.h>
+#include <dm.h>
 #include <stdarg.h>
 #include <iomux.h>
 #include <malloc.h>
@@ -150,12 +151,20 @@ static int console_setfile(int file, struct stdio_dev * dev)
  * console_dev_is_serial() - Check if a stdio device is a serial device
  *
  * @sdev: Device to check
- * @return true if this device is a serial device
+ * @return true if this device is in the serial uclass (or for pre-driver-model,
+ * whether it is called "serial".
  */
 static bool console_dev_is_serial(struct stdio_dev *sdev)
 {
 	bool is_serial;
 
+#ifdef CONFIG_DM_SERIAL
+	if (sdev->flags & DEV_FLAGS_DM) {
+		struct udevice *dev = sdev->priv;
+
+		is_serial = device_get_uclass_id(dev) == UCLASS_SERIAL;
+	} else
+#endif
 	is_serial = !strcmp(sdev->name, "serial");
 
 	return is_serial;
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 9cae9fbd871a9a621e92851c27423b9e56f7bc80..998d372da6bddaba0a5f2ce482274a4939aaf5b9 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -353,7 +353,7 @@ static int serial_post_probe(struct udevice *dev)
 	memset(&sdev, '\0', sizeof(sdev));
 
 	strncpy(sdev.name, dev->name, sizeof(sdev.name));
-	sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
+	sdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_DM;
 	sdev.priv = dev;
 	sdev.putc = serial_stub_putc;
 	sdev.puts = serial_stub_puts;
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index e4fc8b138b45495467da8741f34735db50a32187..3164fa2a557960482b0fd5d4a4ba5e2ba08f5318 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -16,6 +16,7 @@
 
 #define DEV_FLAGS_INPUT	 0x00000001	/* Device can be used as input	console */
 #define DEV_FLAGS_OUTPUT 0x00000002	/* Device can be used as output console */
+#define DEV_FLAGS_DM     0x00000004	/* Device priv is a struct udevice * */
 
 /* Device information */
 struct stdio_dev {