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: 182868 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp9130000ile; Thu, 16 Jan 2020 19:46:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwPOQcjed5zsfl07BEzzXWjRfXKpn3eAx0K/kmqWu8T3QPCxQ2BleN3iJNgVL+7IskxGhqr X-Received: by 2002:a92:5806:: with SMTP id m6mr1433413ilb.234.1579232783465; Thu, 16 Jan 2020 19:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579232783; cv=none; d=google.com; s=arc-20160816; b=hwwlUtVJMG5StuvMlaNHpbeMmsQFp/cNtIgBwTBVNJx3zs8u36DxAi2Yg7rn45PeZ1 7UXG8UAS8t4rlaFka3GjqYNcsPZclotPc1TIrq05mjlKwG4/BTSWW5fO8T9swRPkUlHd ps2sYX+iAvFRTPnZd3ANY2bsytcOkn8ecnT3WEn0KyV1H+W5U94urgo5mzkAIWW82add 7K8H6xIKf770bbzA6Cd0RTVRKWKFsEPOOvTSPCS/heecI/vP+7oN4N7FIrvK2mVLSmVD PtawX//DSjuoZ8XDzbDJE0pqLFfy+ZJsmFeebEsr/IpD3rz+f4B41qysDzuHq6o/dZcm dEmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from; bh=zr78V70sMNw720oGKJiO88/a15oQp7OZ1xjBSnNMVW4=; b=teiEOReP/pMGp4Xy1gD83Vd/mP59vGrepuIRcxnCqGod+1xFaltGV6QyJ0jE8cB1fz 0IYN+kXMDfuKKvCpb1mxvsDuFE9FpGIaBvkKSuer5gtwcfhkwz8GexMgWy28cVVfETKv xgeODyxpzg1NoOjOZff6FHNTQd+Ds88vFTIQ951XrOaZonnVjbc/mz27ZM8JGJ5fDkvb fBT+uZDnR6fNTDrxfMn+koopjttgPwVCHjnyBPblEE7I8BR5PRzYnREQQEnhhOsnmoA5 M8U6LRGmvd57gvW1PWO97Zgi1VZ21WqeE7HrN4z0zsWi9uk+DQJ+pb5tGxcYdS6ZQctP CW0g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z144si18937685jab.74.2020.01.16.19.46.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Jan 2020 19:46:23 -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; 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 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