From patchwork Fri Nov 24 11:39:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 119572 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2091638qgn; Fri, 24 Nov 2017 03:41:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDhcgWkj0qAVqorZLhgNlw37AE49GSEQhyRhy3vxOwFNCAwBjgbjqsphlxFvyvD38l7+5j X-Received: by 10.36.87.2 with SMTP id u2mr16035861ita.151.1511523718003; Fri, 24 Nov 2017 03:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511523717; cv=none; d=google.com; s=arc-20160816; b=Hao0R0EBWTd02IX2pf6U9WBLC3CovBifGN/kG8ncTPMUjEBy4/P7Xrl2GGIcakFE6M dzXnm3bY3X6xzdwvdhgUe7M7zYjP61+rE+lFs4tYcOKgKsE3qoJRrXbcTFSzuLGtHtnn Jh4LZSA7DOETikGZg7noAI3E5PooGgkahuXdJ51ivtKmR65mRuJXu9PB0fYiwpmGjXg+ 1L2n2XLXrkJUWgFL7SH4pefiJxLykzU1B6VORCr78bOmtQEFyFEyb0u3CSQIodv5jbpm AarUr/jvEmlvYxqVhcYq/Vakpb2h+6yExCum5gXld2lLP40EMvgHlD5QYYlwHXgQICLa xazQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=DZgPgqZvUE8EcJUoxZ36mut2If99wlJd7WRX4kbNt2s=; b=jQagk142tQnP846JTnByaG2Oy0Kc3Mo4BlzukQ6iOhLedBWdmBa2BvNORY5gkQX3xp RIaUJIRgm1oHwYDgZ49C029BNzqK8k419ZlWkPRLSEBzXbx6wUNPlm/hCpdhns8eKoKI 56RCi7EF7Jjwqt7EibLhtAIZ0367d3ZSKVOkzgRmW2WIyswQRpFCf7yGCV0ewHlmk0PA hpPTYaxLcMpZaj2ieEa4lyZclk4zjyC5uaeF20XZJ6Pnb4a+zTLPOoVx5tuyMxMTRnl9 lxqVaRrDjRk6ifbb/Dj2W5ILg8beE3i+vqVvgb0OZZMSnY52th6Mp8uCBD5KTX5rBQUm XC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KskGBSi/; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b82si7148509ioa.122.2017.11.24.03.41.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 03:41:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KskGBSi/; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eICKT-00013X-2n; Fri, 24 Nov 2017 11:39:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eICKR-000130-NT for xen-devel@lists.xenproject.org; Fri, 24 Nov 2017 11:39:31 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 6A/BA-27709-3F4081A5; Fri, 24 Nov 2017 11:39:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRWlGSWpSXmKPExsVyMXSBk+4nFok og549ihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aTuxtYCmZJVyxaL9TA2C3WxcjFISQwjVHi x+8TTCAOi8A8ZokL144zgzgSAv2sEv3fm4AynEBOnsThd4uBEhxAdppE12JhiHC1xPdfi1hAb CEBLYmjp2azQkxtYZLY9+gYE0g9m4CJxKwOCZAaEQEliXurJoMtYxZ4ziRxaMJXZpCEsIC/RG Pbe1YQm0VAVeLc551sIDavgLfEtcs7GCGWyUncPNcJVs8p4CNx5tcnVojF3hL/Ds1nm8AouIC RYRWjRnFqUVlqka6hmV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmDAMQDBDsb7 GwMOMUpyMCmJ8nb0i0cJ8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDdzywRJSRYlJqeWpGWmQMMf Zi0BAePkgjvEyagNG9xQWJucWY6ROoUoz3HhTuX/jBxHNhzC0g+m/m6gZlj2tXWJmYhlrz8vF Qpcd4lIFMFQNoySvPghsJi9RKjrJQwLyPQmUI8BalFuZklqPKvGMU5GJWEeR+BTOHJzCuB2/0 K6CwmoLOenhQHOaskESEl1cCo9KGJs7OY/6DZBJm8VyJnd1q/LONc8VYht2L9r93TVRcZ/cva 2ujy/Oc3xRnpy7et+n81+XS+0dJjzle79u3xEnepb52w195LpqZ/y9sX6+ovh4kIvb4brK7+U /bpur870o9EH03W0uuWcH/R+VWC028Ks3Tydc5Ls82u2ikdc1NIljn15q6UEktxRqKhFnNRcS IA8qq7VtACAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-10.tower-27.messagelabs.com!1511523569!94796611!1 X-Originating-IP: [209.85.160.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17817 invoked from network); 24 Nov 2017 11:39:30 -0000 Received: from mail-pl0-f66.google.com (HELO mail-pl0-f66.google.com) (209.85.160.66) by server-10.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Nov 2017 11:39:30 -0000 Received: by mail-pl0-f66.google.com with SMTP id 62so4333012plc.7 for ; Fri, 24 Nov 2017 03:39:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kNoA8KijPTnDvdThx7cYXiUu1UPwqJRmC72GpyACZjY=; b=KskGBSi/2yiYBMbzGjRdfhcEudxi4QjIXswHsC3lqz839wkGjcsodH58Hq4F9r5HZs jroOGepqjKmYnO3kvHS3GZ3qth8JkbbdMIy47dTvykoMbrBJVS/ObTqR3dj3futniC8/ JihsWyKHkplACHll7wA1E1Jq7NYwJ6fPPs70A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kNoA8KijPTnDvdThx7cYXiUu1UPwqJRmC72GpyACZjY=; b=dvolkpjqhQNukdwfH8khq4pYkqMsNU1rcWYx9Se1Wdz+btpvWFb9FXhPck5pAgCLdj eu/lowNPJrkEC66bkbpW2tqC5ijspqGJQzSZeZZ1iDfezUsZ0vYLNhIVyINjnEegjchK 7ToRy2kPDl2RYLM1Z5Aeoe6DSxa4uTATmw25DXsA/OMBQ2JNQ3nqleq7MG/xnUoEVJwW +qV9blhce4SEZwjuzR2n7ILO/ggnzR2jWjIePbu1XB5tfMab5MrE+Sbc9+z51nfn1GKb ajvEaGiTthxDi7DXe1I+CViCGxlf2AkIkYMRNwZu8f7BZbJW7IkLkYyLixBbqDegLrJl 4MDQ== X-Gm-Message-State: AJaThX4kfMqex+5VeRzJfZPirwrxx5TM7a4FCg873+NYY7stakO86NVH d+h2D+LsZyPvwH9mHir6tEVoZg+2pQU= X-Received: by 10.159.202.130 with SMTP id p2mr28046999plo.309.1511523568827; Fri, 24 Nov 2017 03:39:28 -0800 (PST) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id x6sm33141985pfx.15.2017.11.24.03.39.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Nov 2017 03:39:28 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 24 Nov 2017 17:09:11 +0530 Message-Id: <1511523552-23628-3-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511523552-23628-1-git-send-email-bhupinder.thakur@linaro.org> References: <1511523552-23628-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 2/3 v3] xen: Add support for initializing 16550 UART using ACPI X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently, Xen supports only DT based initialization of 16550 UART. This patch adds support for initializing 16550 UART using ACPI SPCR table. Signed-off-by: Bhupinder Thakur --- Changes since v2: - renamed UART_MAX_REG to UART_NUM_REGS - aligned some assignment statements - some coding style changes CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall xen/drivers/char/ns16550.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/8250-uart.h | 1 + 2 files changed, 68 insertions(+) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index c5dfc1e..af4712f 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -29,6 +29,10 @@ #ifdef CONFIG_X86 #include #endif +#ifdef CONFIG_ACPI +#include +#endif + /* * Configure serial port with a string: @@ -1565,6 +1569,69 @@ DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIAL) DT_DEVICE_END #endif /* HAS_DEVICE_TREE */ + +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM) + +static int ns16550_init_acpi(struct ns16550 **puart) +{ + struct acpi_table_spcr *spcr; + int status; + struct ns16550 *uart = &ns16550_com[0]; + + ns16550_init_common(uart); + + status = acpi_get_table(ACPI_SIG_SPCR, 0, + (struct acpi_table_header **)&spcr); + + if ( ACPI_FAILURE(status) ) + { + printk("ns16550: Failed to get SPCR table\n"); + return -EINVAL; + } + + uart->baud = BAUD_AUTO; + uart->data_bits = 8; + uart->parity = spcr->parity; + uart->stop_bits = spcr->stop_bits; + uart->io_base = spcr->serial_port.address; + uart->irq = spcr->interrupt; + uart->reg_width = spcr->serial_port.bit_width / 8; + uart->reg_shift = 0; + uart->io_size = UART_NUM_REGS << uart->reg_shift; + + irq_set_type(spcr->interrupt, spcr->interrupt_type); + + *puart = uart; + + return 0; +} + +static int __init ns16550_acpi_uart_init(const void *data) +{ + int ret; + struct ns16550 *uart; + + ret = ns16550_init_acpi(&uart); + if ( ret ) + return ret; + + ns16550_vuart_init(uart); + + ns16550_register_uart(uart); + + return 0; +} + +ACPI_DEVICE_START(ns16550c, "16550 COMPAT UART", DEVICE_SERIAL) + .class_type = ACPI_DBG2_16550_COMPATIBLE, + .init = ns16550_acpi_uart_init, +ACPI_DEVICE_END +ACPI_DEVICE_START(ns16550s, "16550 SUBSET UART", DEVICE_SERIAL) + .class_type = ACPI_DBG2_16550_SUBSET, + .init = ns16550_acpi_uart_init, +ACPI_DEVICE_END + +#endif /* * Local variables: * mode: C diff --git a/xen/include/xen/8250-uart.h b/xen/include/xen/8250-uart.h index 5c3bac3..849a5c0 100644 --- a/xen/include/xen/8250-uart.h +++ b/xen/include/xen/8250-uart.h @@ -35,6 +35,7 @@ #define UART_USR 0x1f /* Status register (DW) */ #define UART_DLL 0x00 /* divisor latch (ls) (DLAB=1) */ #define UART_DLM 0x01 /* divisor latch (ms) (DLAB=1) */ +#define UART_NUM_REGS (UART_USR + 1) /* Interrupt Enable Register */ #define UART_IER_ERDAI 0x01 /* rx data recv'd */