summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-07-27 15:31:04 (GMT)
committerTom Rini <trini@konsulko.com>2017-07-31 16:21:40 (GMT)
commit7b3c4c3a5305c68a7de2444f555ac7241d6fdb8e (patch)
tree8d8d971ef07cc5f8c3d5096f9061eee71e0c6d7a /common
parent42f9f915c2b7aeac222c93a7f7085d9838722efc (diff)
downloadu-boot-fsl-qoriq-7b3c4c3a5305c68a7de2444f555ac7241d6fdb8e.tar.xz
dm: console: Check for serial devices properly
With driver model the serial device is often not called "serial". Mark driver-model stdio devices so that they can be detected and we can look up the uclass. This is a more reliable way of finding out whether the console is connected to a serial device or not. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/console.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/common/console.c b/common/console.c
index b7ed9a3..ec4af3b 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;