From patchwork Thu Nov 2 10:13:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 117767 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1969774qgn; Thu, 2 Nov 2017 03:15:31 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SfsTM3PCPJcuV/Ng+TvvNbAfh2Fc26z9gznWT0RQf1D6IW9MxU2YUjcNURuBTcxB9o/WMc X-Received: by 10.107.133.143 with SMTP id p15mr3313686ioi.144.1509617731759; Thu, 02 Nov 2017 03:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509617731; cv=none; d=google.com; s=arc-20160816; b=F6+xwDs4ys+fjQA6FRX947AHPUOsBpCOFUhXs4EQki+CxiSTy9MW3cSl3XEQR5g2GU c9Ui+ANrWKKqRQEAd/Np9QmeG7vgD6JiUs07rVgk6IvhPprNDHChXqWzVl0qm43FwUtT KsojImPVn3M5C2vJOaB7Open7PnNbBxoZepPyYyDyrut8s04oRTcPf4NxWh4kb7DdTzf 2xT5QHzUgkZ6VwqqHq2YZ+68Ub53S63r+78iBCYBJDkctgkJ5tDMSPZok6tDqNn3ybnq o7Z8mgDn/RFxriwYMeNgfXx045fyR7PxA37shPn/m/tYHNiRusL3979ClzkBH6UHZoTK StLw== 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:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=eI0ZSq7dtb3Zw7hiNtujs9SDWw6J/unSBt7fhyP5zX0=; b=t6Z3J16xXTRQeqdSJnEWFt5/abH6FWny1/iYyv0hkjMB/IIZ7+7leGEpqhucEUyDnD U4RpeMdwGdRk2o6YVB9+9P7VPNZ8I7O8zvXkdSDXW6bKlM8/3JZOlkwNCIdk0q9TBHpi 35M/T9GQJiJATuG2x7aYzd1Nscc4FdYsnmmmgWu/Mv9tJxztJPmpIKIRbotqYt0c5mjs jA8Vr+U+Wa6H4QVtUiRe7oYfhYH5jV7P/pqoJI0koqURBalUkRvpZateYA0fuGcc/72k Lf/2N5jor7gwxFeiVAtCkubuKfCi3ipbQAPoSTh0hVpb40pXxLFjSqIIzpE/R3dgBli6 VIcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UMLQh7j/; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 g124si3421669ith.96.2017.11.02.03.15.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 03:15:31 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) 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=UMLQh7j/; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.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 1eACV2-0001rT-36; Thu, 02 Nov 2017 10:13:24 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eACV0-0001rM-RT for xen-devel@lists.xenproject.org; Thu, 02 Nov 2017 10:13:23 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 7D/50-14867-2CFEAF95; Thu, 02 Nov 2017 10:13:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRvspLvv/a9 Ig8/XLS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owjz16wFJyTrDh8dAZzA2OHaBcjF4eQwDRG iTV/OphAHBaBdmaJfZ+2gTkSAu9YJDYs2QzkcAI5eRLnj/1k7mLkALLTJNoa/CHMSokbL+1AK oQEtCSOnprNCmHvYJL4uL8MpIRNwERiVocESFhEQEni3qrJYNOZBZ4zSRya8JUZJCEs4CNxd+ VUMJtFQFXi4rxFYDavgLfExSnTWSEukJO4ea6TeQIj/wJGhlWMGsWpRWWpRbpGBnpJRZnpGSW 5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIHhwwAEOxh/LQs4xCjJwaQkynt3469IIb6k/JTK jMTijPii0pzU4kOMMhwcShK8B98B5QSLUtNTK9Iyc4CBDJOW4OBREoFI8xYXJOYWZ6ZDpE4xW nLs23PrDxNHx827QPLZzNcNzEIsefl5qVLivLtBGgRAGjJK8+DGwaLtEqOslDAvI9CBQjwFqU W5mSWo8q8YxTkYlYR5L4NM4cnMK4Hb+groICagg7wkfoAcVJKIkJJqYJy26uILjuicbLaPwRY XSy8UTtbSOlKbfl/ssMPrR6oTJHQDjr3lPOAYNG3Z2gPMF6a+unQpeLfdvcXfBS1YFt2uVF/w xr6DbeqMotTD29hOnnn5dR6jkFQC9w0F4cn2grLuTyfNYJsfe5774nwNKy+16H8mq4LKvhjPi fsy5+c7x2vdpRUPXyxVYinOSDTUYi4qTgQAvMGZ+7ECAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-27.messagelabs.com!1509617597!109089698!1 X-Originating-IP: [74.125.83.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 26900 invoked from network); 2 Nov 2017 10:13:18 -0000 Received: from mail-pg0-f66.google.com (HELO mail-pg0-f66.google.com) (74.125.83.66) by server-5.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 2 Nov 2017 10:13:18 -0000 Received: by mail-pg0-f66.google.com with SMTP id p9so4638686pgc.8 for ; Thu, 02 Nov 2017 03:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=EheyQGPs/n3mSWGJ+cTWgrizmjVet1avYsvxFO9Rc4k=; b=UMLQh7j/kP2zBwnWUhSRXc+Hyl70kawRiVAcqZsF8UH5A186Lhldqg5jrcDJOxuD8B Jqu3FfpCqIJxGXbxSp/212tRehnqDo3WkrSX7gm3MH/dJZby+yRCerJ2AlzG+tlrw+BN jfpUFsHO7T4FKD42SJe1ha9ZYso/XOYLroZDw= 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; bh=EheyQGPs/n3mSWGJ+cTWgrizmjVet1avYsvxFO9Rc4k=; b=FgEh4FRGAQGbxxRa0nlqrtxxp0S6hK+SObajIm++8j4FFRLTqSEpPHqfOFB0qIrlZb NL1Nspdz6bn682W+FuTffmcQ9DuhcSKHAATfbfevgIckHSfwZ+C8s8qA3U8XUIWb2U7c 8YuTSJqPSZ99A/9vFRVaQ0/vncePwXjBzgJhuTr7Hudomv59fHI8zXPUGOlAlsrUDcb5 MNj3MKxDBTfYrr+aPCm/AXT0J1nYhYvbSndBh3LaoHuNp5i7Li81EWh5z6T6x+lwbgtw /rojDdJ5wKA8EdzI6T7OAapNbPVElR2gdCBvhUFDTbrtBQwoOfQuPli4kFz3K8TrsLqj J7bg== X-Gm-Message-State: AMCzsaU6Hg8uihPuFwxWzB5o+DAypnXX+9ZOrxmozBWhBROhUsMGRCDJ Ni3ujjwUtk35xNWi19iNhRvtyPQ308M= X-Received: by 10.84.241.15 with SMTP id a15mr2684400pll.388.1509617597122; Thu, 02 Nov 2017 03:13:17 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id z8sm5502642pfl.135.2017.11.02.03.13.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Nov 2017 03:13:16 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Thu, 2 Nov 2017 15:43:08 +0530 Message-Id: <1509617589-22760-1-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 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/2] xen: Add support for initializing 16550 UART using ACPI X-BeenThere: xen-devel@lists.xen.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.xen.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 --- 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 | 57 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/8250-uart.h | 1 + 2 files changed, 58 insertions(+) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index e0f8199..b3f6d85 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1538,6 +1538,63 @@ DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIAL) DT_DEVICE_END #endif /* HAS_DEVICE_TREE */ + +#ifdef CONFIG_ACPI +#include + +static int __init ns16550_acpi_uart_init(const void *data) +{ + struct ns16550 *uart; + acpi_status status; + struct acpi_table_spcr *spcr = NULL; + + 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 = &ns16550_com[0]; + + ns16550_init_common(uart); + + 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_MAX_REG<reg_shift; + + irq_set_type(spcr->interrupt, spcr->interrupt_type); + + 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; + + /* Register with generic serial driver. */ + serial_register_uart(uart - ns16550_com, &ns16550_driver, 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..1b3e137 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_MAX_REG (UART_USR+1) /* Interrupt Enable Register */ #define UART_IER_ERDAI 0x01 /* rx data recv'd */