arm: dra7xx: Hang on any failure during IOdelay recalibration
[oweals/u-boot.git] / drivers / serial / serial-uclass.c
index e50f0aa851061fd2a1f00fa2f5225a699bf55f5e..dcdaedefe72e96a0de41b6b6de63b980554a5f6a 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
-#include <environment.h>
+#include <env_internal.h>
 #include <errno.h>
 #include <os.h>
 #include <serial.h>
@@ -62,7 +62,7 @@ static int serial_check_stdout(const void *blob, struct udevice **devp)
         * anyway.
         */
        if (node > 0 && !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node),
-                                       devp)) {
+                                       devp, false)) {
                if (!device_probe(*devp))
                        return 0;
        }
@@ -294,20 +294,44 @@ void serial_setbrg(void)
                ops->setbrg(gd->cur_serial_dev, gd->baudrate);
 }
 
-int serial_setconfig(uint config)
+int serial_getconfig(struct udevice *dev, uint *config)
 {
        struct dm_serial_ops *ops;
 
-       if (!gd->cur_serial_dev)
-               return 0;
+       ops = serial_get_ops(dev);
+       if (ops->getconfig)
+               return ops->getconfig(dev, config);
 
-       ops = serial_get_ops(gd->cur_serial_dev);
+       return 0;
+}
+
+int serial_setconfig(struct udevice *dev, uint config)
+{
+       struct dm_serial_ops *ops;
+
+       ops = serial_get_ops(dev);
        if (ops->setconfig)
-               return ops->setconfig(gd->cur_serial_dev, config);
+               return ops->setconfig(dev, config);
 
        return 0;
 }
 
+int serial_getinfo(struct udevice *dev, struct serial_device_info *info)
+{
+       struct dm_serial_ops *ops;
+
+       if (!info)
+               return -EINVAL;
+
+       info->baudrate = gd->baudrate;
+
+       ops = serial_get_ops(dev);
+       if (ops->getinfo)
+               return ops->getinfo(dev, info);
+
+       return -EINVAL;
+}
+
 void serial_stdio_init(void)
 {
 }
@@ -419,12 +443,16 @@ static int serial_post_probe(struct udevice *dev)
                ops->pending += gd->reloc_off;
        if (ops->clear)
                ops->clear += gd->reloc_off;
+       if (ops->getconfig)
+               ops->getconfig += gd->reloc_off;
        if (ops->setconfig)
                ops->setconfig += gd->reloc_off;
 #if CONFIG_POST & CONFIG_SYS_POST_UART
        if (ops->loop)
-               ops->loop += gd->reloc_off
+               ops->loop += gd->reloc_off;
 #endif
+       if (ops->getinfo)
+               ops->getinfo += gd->reloc_off;
 #endif
        /* Set the baud rate */
        if (ops->setbrg) {