On Thu, 24 Jan 2019 11:16:28 +0000 Alexandru Elisei <alexandru.elisei@xxxxxxx> wrote: > Add support for discovering the ns16550a UART from the device tree. > This particular UART model is emulated by kvmtool. Maybe we should mention that this happens to work because both UARTs have their TX data register at offset 0, because they are by no means "compatible" otherwise. But that just a documentation issue, so: > Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx> Cheers, Andre. > --- > 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(); > } > _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm