]> git.sur5r.net Git - u-boot/commitdiff
dm: serial: Deal with stdout-path with an alias
authorSimon Glass <sjg@chromium.org>
Sun, 18 Oct 2015 01:41:17 +0000 (19:41 -0600)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 4 Nov 2015 13:49:52 +0000 (14:49 +0100)
Sometimes stdout-path contains a UART alias along with speed, etc. For
example:

stdout-path = "serial0:115200n8";

Add support for decoding this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/serial/serial-uclass.c

index 55011cc4b9a7e6a36dd5039e5a501c6afc85d86e..842f78bff3c3863c20834cda5c49f08cef4a2c25 100644 (file)
@@ -29,14 +29,34 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE;
 
 static void serial_find_console_or_panic(void)
 {
+       const void *blob = gd->fdt_blob;
        struct udevice *dev;
        int node;
 
-       if (CONFIG_IS_ENABLED(OF_CONTROL) && gd->fdt_blob) {
+       if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
                /* Check for a chosen console */
-               node = fdtdec_get_chosen_node(gd->fdt_blob, "stdout-path");
+               node = fdtdec_get_chosen_node(blob, "stdout-path");
+               if (node < 0) {
+                       const char *str, *p, *name;
+
+                       /*
+                        * Deal with things like
+                        *      stdout-path = "serial0:115200n8";
+                        *
+                        * We need to look up the alias and then follow it to
+                        * the correct node.
+                        */
+                       str = fdtdec_get_chosen_prop(blob, "stdout-path");
+                       if (str) {
+                               p = strchr(str, ':');
+                               name = fdt_get_alias_namelen(blob, str,
+                                               p ? p - str : strlen(str));
+                               if (name)
+                                       node = fdt_path_offset(blob, name);
+                       }
+               }
                if (node < 0)
-                       node = fdt_path_offset(gd->fdt_blob, "console");
+                       node = fdt_path_offset(blob, "console");
                if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node,
                                                    &dev)) {
                        gd->cur_serial_dev = dev;
@@ -48,14 +68,14 @@ static void serial_find_console_or_panic(void)
                * bind it anyway.
                */
                if (node > 0 &&
-                   !lists_bind_fdt(gd->dm_root, gd->fdt_blob, node, &dev)) {
+                   !lists_bind_fdt(gd->dm_root, blob, node, &dev)) {
                        if (!device_probe(dev)) {
                                gd->cur_serial_dev = dev;
                                return;
                        }
                }
        }
-       if (!SPL_BUILD || !CONFIG_IS_ENABLED(OF_CONTROL) || !gd->fdt_blob) {
+       if (!SPL_BUILD || !CONFIG_IS_ENABLED(OF_CONTROL) || !blob) {
                /*
                * Try to use CONFIG_CONS_INDEX if available (it is numbered
                * from 1!).