From patchwork Fri Nov 24 11:39:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 119573 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2091643qgn; Fri, 24 Nov 2017 03:41:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMb88WfXSTaLxFkwb5BvLGVEZVyoQfHfIaBf2cGqRYhUMtmNedGPoUY3Aj1a8BcJYJzV++Oa X-Received: by 10.36.67.199 with SMTP id s190mr7072109itb.153.1511523718350; Fri, 24 Nov 2017 03:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511523718; cv=none; d=google.com; s=arc-20160816; b=Yb7S11QQOkKIeLSYTNFR8v6UUQ45CqhDHU4GhpuDHLwyBUP+hjmLoXybk9gag5Ho5N srGxvqgAUmyf8nVpdlB2YLVHcdslMC6urq4oIOBTjS7SGtC4GwW6mm+457V4G2k7jgq/ ZYETRaAq9sJ87GbCLTgCayoRujd68I9u/zpVhH5sr1tpcKwAswMrtrHZBYQtSOTBSG5x yzLC1sGv7w3UIm1ny1yQXTNZM/oz+3dQgQxNesBZrYKjXO4CZBBe24okvw1r4xPetBkz t0JlW96b6TZEoicR6g/ZXTP/Qo+Hlev1ui4NReSNZCYE6KIzfxRResu/I2pRayGgmzWo tFVQ== 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=h9Oh4WRJJK7MVHROtD2LR+mEqMASMeEr75O7EYsG31M=; b=wSkdHNzoRJFUMKkM2wameBgVPjKSK656Nx1ufVZSaD99vUztHGIHPEVIoKCuqZNdcB ZttyaFFE8kP2uQ2SW5mRatTb97tW1ptxxE4ONNe9OnsIIpjGnhl5keTf7x7+UBIhildV rHhJDZGXkIiqjsiKG5xF7xMboqOt+MX+eXh2RaRedZyuPwnQDbIN62AES1y0mVxDWQE1 Yf4yUtXKa+S0PwwUTnz/QfYA7THLGz4IuDnt2yYAd3h5cgazOSRw9gPfrnxf4TVMOcuM HSf8mg7C1U2YPqS/r4JSqKdnonhArhCWdFSp6T54Ig61tQBclmASTEQ1jVQTUn9T80iS 0xXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fVz+eATt; 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 g84si16848220ioi.188.2017.11.24.03.41.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 03:41:58 -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=fVz+eATt; 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 1eICKO-00012N-OT; Fri, 24 Nov 2017 11:39:28 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eICKO-00012H-3Z for xen-devel@lists.xenproject.org; Fri, 24 Nov 2017 11:39:28 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id BB/7E-15802-FE4081A5; Fri, 24 Nov 2017 11:39:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsVyMfTAEd13LBJ RBosPqVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBntz+8wF0yQrDi+eA17A+NKkS5GLg4hgRmM Ene3XWcHcVgE5jFLNL09xQziSAj0s0o82raIsYuRE8jJk+g/MI0dwk6TmPv5KZRdIXGyaRITi C0koCVx9NRsVoixLUwSXbvOAiU4ONgETCRmdUiA1IgIKEncWzWZCaSGWeA5k8ShCV+ZQWqEBU wlPkxgAalhEVCVeL25HWwmr4C3xNITu6FukJO4ea6TGcTmFPCROPPrEyvEXm+Jf4fms01gFFz AyLCKUaM4tagstUjXyEwvqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMw5OoZGBh3 MN6e7HeIUZKDSUmUt6NfPEqILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO9+ZokoIcGi1PTUirTMH GDww6QlOHiURHivgKR5iwsSc4sz0yFSpxjtOS7cufSHiePAnltA8tnM1w3MHNOutjYxC7Hk5e elSonzLgFpEwBpyyjNgxsKi9ZLjLJSwryMDAwMQjwFqUW5mSWo8q8YxTkYlYR5l4NM4cnMK4H b/QroLCags56eFAc5qyQRISXVwGjNeCRJcs0bq/XLdM+lS6h/enHYxzlae9sskXzWGbFC+8S9 Tjy375imfvCsxtGbpb3+P5fZKX5ji9x/R7Rpfs7+dapvjt75skLUZq2qp2/JjBoDu7x8+1veX k9kElm0uRseZj9YmaT2geeZs1tj0FMThTXvfl5b4l96XIPd/s/lxRzSZxe1NCixFGckGmoxFx UnAgCr4NNn0QIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1511523565!94642144!1 X-Originating-IP: [209.85.192.196] 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 33431 invoked from network); 24 Nov 2017 11:39:26 -0000 Received: from mail-pf0-f196.google.com (HELO mail-pf0-f196.google.com) (209.85.192.196) by server-15.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Nov 2017 11:39:26 -0000 Received: by mail-pf0-f196.google.com with SMTP id k24so4984590pfb.1 for ; Fri, 24 Nov 2017 03:39:26 -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=VLpInEGlVQN05yhi5hEUQxWscaKy/Ca0A7W8U7X+2TY=; b=fVz+eATtjBzf6spXkZZCbWexY1ZcRITgYeGYwgNiF9AtdYeFaPfT1+aFHoLJ07qNJW WS01OL4hCZVDSJva1WM2t75fPs1+LbG5eJphDHcYGs5FLJhkBNSRg9pFmhlzTIKOaaqv Mm6OyZE9MQrr7zOxjEb8jOCcBpSdAzmldf+Qc= 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=VLpInEGlVQN05yhi5hEUQxWscaKy/Ca0A7W8U7X+2TY=; b=VT29Py6AOJlh27S56Mee2BfGQ9IVNWqB10qi+5bp8hbsmqeZ5BzHt4lG6utksa5hjo SYVJiOKKANkkxqwBf3lTSKFTwJIk+bX+qw+Lt8yPVsgHSDOcPBedVzUP2dJHCoEViLKE 5s9zOgpf8i7JQWCvCoNq9qWBwKgTcXYE7iQov1wvMnhBJFtGML8tclROk4DrBNHTII6U qQRu/FN3LvYQa0Gz5efzL0C/b1ndnGTMi0l3Zp2zqA34GgJ7UAB5DiGl3Uf+aoyvSkB8 uegzM8rMYwu2+1rO8vE5Mq/16l26O1KGwg3ZRaeSGzDxtjlu3cwmN8vKwITSBacFv7PW HjIA== X-Gm-Message-State: AJaThX5lOcOgcZ1V4DlPpQ+mKFsVjyfsgYd/vKY2MiDFOiqKi/fb9V5l pyiJzKynqQu04FnB3l31HC93sHpNPNI= X-Received: by 10.98.79.86 with SMTP id d83mr26867954pfb.26.1511523564713; Fri, 24 Nov 2017 03:39:24 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Nov 2017 03:39:24 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 24 Nov 2017 17:09:10 +0530 Message-Id: <1511523552-23628-2-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 1/3 v3] xen: Refactor 16550 UART code 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" This patch refactors the 8250 UART code so that code can be reused by later patches, which add support for ACPI based UART initialization. Signed-off-by: Bhupinder Thakur Reviewed-by: Konrad Rzeszutek Wilk --- Changes since v2: - Refactored the code to prepare for later patches. 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 | 53 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index e0f8199..c5dfc1e 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1462,16 +1462,32 @@ void __init ns16550_init(int index, struct ns16550_defaults *defaults) ns16550_parse_port_config(uart, (index == 0) ? opt_com1 : opt_com2); } +#ifdef CONFIG_ARM +static void ns16550_vuart_init(struct ns16550 *uart) +{ + uart->vuart.base_addr = uart->io_base; + uart->vuart.size = uart->io_size; + uart->vuart.data_off = UART_THR << uart->reg_shift; + uart->vuart.status_off = UART_LSR << uart->reg_shift; + uart->vuart.status = UART_LSR_THRE | UART_LSR_TEMT; +} +#endif + +static void ns16550_register_uart(struct ns16550 *uart) +{ + /* Register with generic serial driver. */ + serial_register_uart(uart - ns16550_com, &ns16550_driver, uart); +} + #ifdef CONFIG_HAS_DEVICE_TREE -static int __init ns16550_uart_dt_init(struct dt_device_node *dev, - const void *data) + +static int ns16550_init_dt(struct ns16550 **puart, + const struct dt_device_node *dev) { - struct ns16550 *uart; int res; u32 reg_shift, reg_width; u64 io_size; - - uart = &ns16550_com[0]; + struct ns16550 *uart = &ns16550_com[0]; ns16550_init_common(uart); @@ -1510,18 +1526,29 @@ static int __init ns16550_uart_dt_init(struct dt_device_node *dev, uart->dw_usr_bsy = dt_device_is_compatible(dev, "snps,dw-apb-uart"); - uart->vuart.base_addr = uart->io_base; - uart->vuart.size = uart->io_size; - uart->vuart.data_off = UART_THR <reg_shift; - uart->vuart.status_off = UART_LSR<reg_shift; - uart->vuart.status = UART_LSR_THRE|UART_LSR_TEMT; + *puart = uart; - /* Register with generic serial driver. */ - serial_register_uart(uart - ns16550_com, &ns16550_driver, uart); + return 0; +} + +static int __init ns16550_uart_dt_init(struct dt_device_node *dev, + const void *data) +{ + struct ns16550 *uart; + int ret; + + ret = ns16550_init_dt(&uart, data); + + if ( ret ) + return ret; + + ns16550_vuart_init(uart); + + ns16550_register_uart(uart); dt_device_set_used_by(dev, DOMID_XEN); - return 0; + return ret; } static const struct dt_device_match ns16550_dt_match[] __initconst = 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 */ From patchwork Fri Nov 24 11:39:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 119575 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2091815qgn; Fri, 24 Nov 2017 03:42:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMafZ1/TkI4cmxF4IMyy1R2XJPcxiJGWi2OZ31r8ojeJTo86TlprLHxbTyUaWqwDX66DpwU4 X-Received: by 10.107.180.147 with SMTP id d141mr30979697iof.25.1511523728056; Fri, 24 Nov 2017 03:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511523728; cv=none; d=google.com; s=arc-20160816; b=L7NQOxrs8QIUYEYCKmpUDsWJ2MfygLUKt75bl6waouoMJwL6ZUHkr7DkkBUwcYl8yV gqQU3xcSlJ+lhcAI1NjkCoqsXHVIeyFOGmQl7kBmnBv+Gu2DIujDHoRSHoUqtKTXKdRC zzzM1P0RHDcFoOIBbcLX8w0jzAscyBMyimP0UHE1DZv+90h6+vqYj7cKxV57riurUkhC f+tnmEvknSKA7ywnm10qRPsMZf/+R8EtIoBBI+4VbmKNlZ9Vofoj976cT0ZrEyh2yvht LTySVJWGExpTRxt+UuT0clAttnlPlr13uCu5GWI2oS+HzBsUcNITCyrWMyJZWKe0x44j uJhA== 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=w9zmYrouzxWgm6JpbKu11TDVZDg0t6EaMZe5hyxmMos=; b=hq0GRMmFxfwKSdgLtMdnWhuCWMPl9IBCIDtp6mWlLoKuamyREO1zVlm/ufWSQHe8ua RaN8r1qbOJIRWviFl0w2HeMwS9x43w5SKuJWCEB4LOakhQutghPLPmRIMRs5Wo7PfQPL Xy7FoApDwxDCHGkgD2lOEeg5DkeR2fZ5M6SDIM4DcKBs9HhpbVVRaub5sYiZKdoPfwSi u1WqvZ0uLdzwtimU1I2HXkbvG/fs0wMLe6MYebFIJpQSPFwUAdJtztQ7U0TyGNFeBFdd dgPtMGdqy13569FEiHNG0+V31qieuGT9azIUpkGV66PG7UQ34zxADmk51KjHVvH5LZuv Kljw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Q91hDhpT; 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 c65si2022595itg.125.2017.11.24.03.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 03:42:08 -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=Q91hDhpT; 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 1eICKY-00015E-9q; Fri, 24 Nov 2017 11:39:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eICKW-000150-W8 for xen-devel@lists.xenproject.org; Fri, 24 Nov 2017 11:39:37 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 83/E7-27451-8F4081A5; Fri, 24 Nov 2017 11:39:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsXiVRvsovudRSL K4HuPjsX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvFm3U/Wgq8yFW1n57A1MK4R72Lk4hASmMEo 0fz2LSOIwyIwj1liwZrjYI6EQD+rxIFjK9m7GDmBnDyJJe17mSDsNIkfdz6ydTFyANkVEj872 UDCQgJaEkdPzWaFmNrCJPHl9AF2kBo2AROJWR0SIDUiAkoS91ZNZgKpYRZ4ziRxaMJXZpCEsE CYRNea82CDWARUJV5deMoIYvMKeEusPfaIEWKvnMTNc51g9ZwCPhJnfn1ihVjsLfHv0Hy2CYy CCxgZVjGqF6cWlaUW6VroJRVlpmeU5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIEBhwDEOxg PNjsfIhRkoNJSZS3o188SogvKT+lMiOxOCO+qDQntfgQowwHh5IE7w9miSghwaLU9NSKtMwcY OjDpCU4eJREeK+ApHmLCxJzizPTIVKnGC059u259YeJ49nM1w3MHNOutjYxC7Hk5eelSonzLg FpEABpyCjNgxsHi89LjLJSwryMQAcK8RSkFuVmlqDKv2IU52BUEuZ9BDKFJzOvBG7rK6CDmIA OenpSHOSgkkSElFQD40ZzwYlxvzbYbGV/O98vuzdCTveTkWem28n2r0e2e8kuVs5+tkTtaMe0 W/s1om0vJ4ttK01kKyiy8v84LX6e27eLfEfuzbtRWPc3t2D6iZdvD61nP2T0ZYXh597fT64tq Yjvvdq2lJ/17Iwcp749S+REJjWHbDowfffOzx5T7i925/w9VXZZ1G0lluKMREMt5qLiRADd16 uwygIAAA== X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1511523574!69830096!1 X-Originating-IP: [74.125.83.68] 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 63858 invoked from network); 24 Nov 2017 11:39:35 -0000 Received: from mail-pg0-f68.google.com (HELO mail-pg0-f68.google.com) (74.125.83.68) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Nov 2017 11:39:35 -0000 Received: by mail-pg0-f68.google.com with SMTP id s11so15241405pgc.5 for ; Fri, 24 Nov 2017 03:39:35 -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=AO7hTeEqqoM1gnL+o4ZAMqcM355fPvcntn4YtSAg8jk=; b=Q91hDhpTrFjAX7/j9XLwfy/3AKeQXojTc8B37wy9lgGLf3MnDxOTbhmlRAA50usbOs NIrU66FBDAPHgGroRBTEagC02F9rnqq+ikBLmYHFJyNmuYIeGjM2Vi93hwhZjkBWslrm uPeo+zvvm+0S3cJElAphb4k98NJH+Vs5sik1Q= 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=AO7hTeEqqoM1gnL+o4ZAMqcM355fPvcntn4YtSAg8jk=; b=M3dF/069X744KzvUvvDS8hMLyTZaU13OyWFxBl4KuEgHfnZjrHTu+gVuZflYCB3Ggp Ud5Z41O+CqV9T/0QINm7xBSdUKno602NjP6013IRnIUN0zOgnNaSN2Y+zErVUlagZZRg gH/037ldQ5e5se46x8GE2yN0mD9eu9ikEbwiLIFNshiZCZUy+rZOL3fbBJpCerUbjcDf BMtvbhzcflPQ6R6XRwvjgMVyb9YvDfymkLaX/pOTESrgO4RbQt4CRU5HrCdZjNkjSi3C rUFjfQkNgETIrvk+AM43rJkMm19udZ1i6fhqxB4lZub9zPe4ETXD6CrvbEP5SCQ2jarV UudQ== X-Gm-Message-State: AJaThX6nbExTl6wiIYukhlQCUQTCqR8+iz+bd5KVb2wHATbbaqC3UE40 5TbWeh8QsWPATATDBK9tUydS9TS4B48= X-Received: by 10.99.168.67 with SMTP id i3mr28338792pgp.63.1511523573809; Fri, 24 Nov 2017 03:39:33 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Nov 2017 03:39:33 -0800 (PST) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 24 Nov 2017 17:09:12 +0530 Message-Id: <1511523552-23628-4-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 3/3 v3] xen: Fix 16550 UART console for HP Moonshot (Aarch64) platform 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" The console was not working on HP Moonshot (HPE Proliant Aarch64) because the UART registers were accessed as 8-bit aligned addresses. However, registers are 32-bit aligned for HP Moonshot. Since ACPI/SPCR table does not specify the register shift to be applied to the register offset, this patch implements an erratum to correctly set the register shift for HP Moonshot. Similar erratum was implemented in linux in the following commit: commit 79a648328d2a604524a30523ca763fbeca0f70e3 Author: Loc Ho Date: Mon Jul 3 14:33:09 2017 -0700 ACPI: SPCR: Workaround for APM X-Gene 8250 UART 32-alignment errata APM X-Gene verion 1 and 2 have an 8250 UART with its register aligned to 32-bit. In addition, the latest released BIOS encodes the access field as 8-bit access instead 32-bit access. This causes no console with ACPI boot as the console will not match X-Gene UART port due to the lack of mmio32 option. Signed-off-by: Loc Ho Acked-by: Greg Kroah-Hartman Signed-off-by: Rafael J. Wysocki Signed-off-by: Bhupinder Thakur Reviewed-by: Konrad Rzeszutek Wilk --- Changes since v2: - removed the use of local variable xgene_8250 in xgene_8250_erratum_present 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 | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index af4712f..8c4720a 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1571,6 +1571,30 @@ DT_DEVICE_END #endif /* HAS_DEVICE_TREE */ #if defined(CONFIG_ACPI) && defined(CONFIG_ARM) +/* + * APM X-Gene v1 and v2 UART hardware is an 16550 like device but has its + * register aligned to 32-bit. In addition, the BIOS also encoded the + * access width to be 8 bits. This function detects this errata condition. + */ +static bool xgene_8250_erratum_present(struct acpi_table_spcr *tb) +{ + if ( tb->interface_type != ACPI_DBG2_16550_COMPATIBLE ) + return false; + + if ( memcmp(tb->header.oem_id, "APMC0D", ACPI_OEM_ID_SIZE) && + memcmp(tb->header.oem_id, "HPE ", ACPI_OEM_ID_SIZE) ) + return false; + + if ( !memcmp(tb->header.oem_table_id, "XGENESPC", + ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 0 ) + return true; + + if ( !memcmp(tb->header.oem_table_id, "ProLiant", + ACPI_OEM_TABLE_ID_SIZE) && tb->header.oem_revision == 1 ) + return true; + + return false; +} static int ns16550_init_acpi(struct ns16550 **puart) { @@ -1596,7 +1620,19 @@ static int ns16550_init_acpi(struct ns16550 **puart) uart->io_base = spcr->serial_port.address; uart->irq = spcr->interrupt; uart->reg_width = spcr->serial_port.bit_width / 8; - uart->reg_shift = 0; + + if ( xgene_8250_erratum_present(spcr) ) + { + /* + * For xgene v1 and v2 the registers are 32-bit and so a + * register shift of 2 has to be applied to get the + * correct register offset. + */ + uart->reg_shift = 2; + } + else + uart->reg_shift = 0; + uart->io_size = UART_NUM_REGS << uart->reg_shift; irq_set_type(spcr->interrupt, spcr->interrupt_type);