]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/serial/serial-uclass.c
Merge branch 'master' of git://git.denx.de/u-boot-video
[people/ms/u-boot.git] / drivers / serial / serial-uclass.c
index 842f78bff3c3863c20834cda5c49f08cef4a2c25..19f38e162e0fcebb1e8488a2c7bde041108039c0 100644 (file)
@@ -33,7 +33,13 @@ static void serial_find_console_or_panic(void)
        struct udevice *dev;
        int node;
 
-       if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
+       if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
+               uclass_first_device(UCLASS_SERIAL, &dev);
+               if (dev) {
+                       gd->cur_serial_dev = dev;
+                       return;
+               }
+       } else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
                /* Check for a chosen console */
                node = fdtdec_get_chosen_node(blob, "stdout-path");
                if (node < 0) {
@@ -64,9 +70,9 @@ static void serial_find_console_or_panic(void)
                }
 
                /*
-               * If the console is not marked to be bound before relocation,
-               * bind it anyway.
-               */
+                * If the console is not marked to be bound before relocation,
+                * bind it anyway.
+                */
                if (node > 0 &&
                    !lists_bind_fdt(gd->dm_root, blob, node, &dev)) {
                        if (!device_probe(dev)) {
@@ -77,13 +83,13 @@ static void serial_find_console_or_panic(void)
        }
        if (!SPL_BUILD || !CONFIG_IS_ENABLED(OF_CONTROL) || !blob) {
                /*
-               * Try to use CONFIG_CONS_INDEX if available (it is numbered
-               * from 1!).
-               *
-               * Failing that, get the device with sequence number 0, or in
-               * extremis just the first serial device we can find. But we
-               * insist on having a console (even if it is silent).
-               */
+                * Try to use CONFIG_CONS_INDEX if available (it is numbered
+                * from 1!).
+                *
+                * Failing that, get the device with sequence number 0, or in
+                * extremis just the first serial device we can find. But we
+                * insist on having a console (even if it is silent).
+                */
 #ifdef CONFIG_CONS_INDEX
 #define INDEX (CONFIG_CONS_INDEX - 1)
 #else
@@ -115,7 +121,7 @@ int serial_init(void)
 /* Called after relocation */
 void serial_initialize(void)
 {
-       serial_find_console_or_panic();
+       serial_init();
 }
 
 static void _serial_putc(struct udevice *dev, char ch)
@@ -123,11 +129,12 @@ static void _serial_putc(struct udevice *dev, char ch)
        struct dm_serial_ops *ops = serial_get_ops(dev);
        int err;
 
+       if (ch == '\n')
+               _serial_putc(dev, '\r');
+
        do {
                err = ops->putc(dev, ch);
        } while (err == -EAGAIN);
-       if (ch == '\n')
-               _serial_putc(dev, '\r');
 }
 
 static void _serial_puts(struct udevice *dev, const char *str)
@@ -204,7 +211,7 @@ void serial_stdio_init(void)
 {
 }
 
-#ifdef CONFIG_DM_STDIO
+#if defined(CONFIG_DM_STDIO) && CONFIG_IS_ENABLED(SERIAL_PRESENT)
 static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
        _serial_putc(sdev->priv, ch);
@@ -287,6 +294,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op,
 }
 U_BOOT_ENV_CALLBACK(baudrate, on_baudrate);
 
+#if CONFIG_IS_ENABLED(SERIAL_PRESENT)
 static int serial_post_probe(struct udevice *dev)
 {
        struct dm_serial_ops *ops = serial_get_ops(dev);
@@ -356,3 +364,4 @@ UCLASS_DRIVER(serial) = {
        .pre_remove     = serial_pre_remove,
        .per_device_auto_alloc_size = sizeof(struct serial_dev_priv),
 };
+#endif