From patchwork Thu Jan 24 11:16:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 10778747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D02413BF for ; Thu, 24 Jan 2019 11:17:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CE362EA87 for ; Thu, 24 Jan 2019 11:17:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 112122EB51; Thu, 24 Jan 2019 11:17:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A65492EA87 for ; Thu, 24 Jan 2019 11:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727587AbfAXLRA (ORCPT ); Thu, 24 Jan 2019 06:17:00 -0500 Received: from foss.arm.com ([217.140.101.70]:54760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfAXLRA (ORCPT ); Thu, 24 Jan 2019 06:17:00 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4332C1650; Thu, 24 Jan 2019 03:17:00 -0800 (PST) Received: from login12.euhpc.arm.com (login12.euhpc.arm.com [10.6.27.168]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3400A3F237; Thu, 24 Jan 2019 03:16:59 -0800 (PST) From: Alexandru Elisei To: kvm@vger.kernel.org Cc: drjones@redhat.com, kvmarm@lists.cs.columbia.edu, andre.przywara@arm.com, vladimir.murzin@arm.com Subject: [kvm-unit-tests PATCH 1/7] lib: arm: Discover ns16550a UART Date: Thu, 24 Jan 2019 11:16:28 +0000 Message-Id: <20190124111634.4727-2-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190124111634.4727-1-alexandru.elisei@arm.com> References: <20190124111634.4727-1-alexandru.elisei@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for discovering the ns16550a UART from the device tree. This particular UART model is emulated by kvmtool. Signed-off-by: Alexandru Elisei Reviewed-by: Andre Przywara --- 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(); }