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: 10038335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3598603B5 for ; Thu, 2 Nov 2017 10:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D250228EDE for ; Thu, 2 Nov 2017 10:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C72BB28EE3; Thu, 2 Nov 2017 10:16:06 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 928B628EDE for ; Thu, 2 Nov 2017 10:16:04 +0000 (UTC) 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-Google-Smtp-Source: ABhQp+ROtnktOdN4DwCC7DhIF7oKqFMJio5iLwvyX0zWjq+MXPSEmfkkC4JcTUEJPOyomHkn2Mp53Q== 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 */