From patchwork Fri Jan 17 03:40:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 11338267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDECA13A0 for ; Fri, 17 Jan 2020 03:46:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB5E22082F for ; Fri, 17 Jan 2020 03:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB5E22082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isIZ2-00015a-Bp; Fri, 17 Jan 2020 03:44:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isIZ0-00015V-Gs for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 03:44:50 +0000 X-Inumbo-ID: af6708f4-38db-11ea-b89f-bc764e2007e4 Received: from huawei.com (unknown [45.249.212.32]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id af6708f4-38db-11ea-b89f-bc764e2007e4; Fri, 17 Jan 2020 03:44:39 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 057E82E1E6815E486D0C; Fri, 17 Jan 2020 11:44:37 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Fri, 17 Jan 2020 11:44:28 +0800 From: Wei Xu To: , , Andrew Cooper , George Dunlap , "Ian Jackson" , Jan Beulich , "Konrad Rzeszutek Wilk" , Wei Liu , Date: Fri, 17 Jan 2020 11:40:58 +0800 Message-ID: <1579232458-26803-1-git-send-email-xuwei5@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Subject: [Xen-devel] [PATCH] ns16550: Add ACPI support X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: prime.zeng@hisilicon.com, shameerali.kolothum.thodi@huawei.com, xuwei5@hisilicon.com, linuxarm@huawei.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Parse the ACPI SPCR table and initialize the 16550 compatible serial port. Signed-off-by: Wei Xu --- xen/drivers/char/ns16550.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index aa87c57..eb32891 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -1620,6 +1620,61 @@ 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 acpi_table_spcr *spcr = NULL; + acpi_status status; + struct ns16550 *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 = &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->io_size = 8; + uart->reg_shift = spcr->serial_port.bit_offset; + uart->reg_width = 1; + + /* trigger/polarity information is not available in spcr */ + irq_set_type(spcr->interrupt, IRQ_TYPE_LEVEL_HIGH); + uart->irq = spcr->interrupt; + + 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; + + /* Register with generic serial driver. */ + serial_register_uart(uart - ns16550_com, &ns16550_driver, uart); + + return 0; +} + +ACPI_DEVICE_START(ans16550, "NS16550 UART", DEVICE_SERIAL) + .class_type = ACPI_DBG2_16550_COMPATIBLE, + .init = ns16550_acpi_uart_init, +ACPI_DEVICE_END + +#endif /* CONFIG_ACPI */ + /* * Local variables: * mode: C