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 =