From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: Re: [kvm-unit-tests PATCH 1/7] lib: arm: Discover ns16550a UART Date: Thu, 24 Jan 2019 11:54:18 +0000 Message-ID: <20190124115418.23e1def9@donnerap.cambridge.arm.com> References: <20190124111634.4727-1-alexandru.elisei@arm.com> <20190124111634.4727-2-alexandru.elisei@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org To: Alexandru Elisei Return-path: In-Reply-To: <20190124111634.4727-2-alexandru.elisei@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org On Thu, 24 Jan 2019 11:16:28 +0000 Alexandru Elisei 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 Reviewed-by: Andre Przywara 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(); > } >