Add support for discovering the ns16550a UART from the device tree. This
particular UART model is emulated by kvmtool.

Signed-off-by: Alexandru Elisei <[email protected]>
---
 lib/arm/io.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/arm/io.c b/lib/arm/io.c
index d2c1a07c19ee..35fc05aeb4db 100644
--- a/lib/arm/io.c
+++ b/lib/arm/io.c
@@ -32,22 +32,26 @@ static volatile u8 *uart0_base = (u8 *)UART_EARLY_BASE;
 
 static void uart0_init(void)
 {
-       const char *compatible = "arm,pl011";
+       const char *compatible[] = {"arm,pl011", "ns16550a"};
        struct dt_pbus_reg base;
-       int ret;
+       int i, ret;
 
        ret = dt_get_default_console_node();
        assert(ret >= 0 || ret == -FDT_ERR_NOTFOUND);
 
        if (ret == -FDT_ERR_NOTFOUND) {
 
-               ret = dt_pbus_get_base_compatible(compatible, &base);
-               assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
+               for (i = 0; i < ARRAY_SIZE(compatible); i++) {
+                       ret = dt_pbus_get_base_compatible(compatible[i], &base);
+                       assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
+
+                       if (ret == 0)
+                               break;
+               }
 
                if (ret) {
-                       printf("%s: %s not found in the device tree, "
-                               "aborting...\n",
-                               __func__, compatible);
+                       printf("%s: Compatible UART not found in the device 
tree, "
+                               "aborting...\n", __func__);
                        abort();
                }
 
-- 
2.17.0

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Reply via email to