From patchwork Wed Feb 4 14:02:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 44363 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B710D2029F for ; Wed, 4 Feb 2015 14:06:59 +0000 (UTC) Received: by mail-we0-f200.google.com with SMTP id m14sf1468302wev.3 for ; Wed, 04 Feb 2015 06:06:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=jsMHXSRuqUVL6D3vD1f2Vz7qc2HeE9twGq+GYxvr5sc=; b=KkJuWU+r1HZRwi2cwY339gP/2iwTm0IDZAV47GGNQDROq0bXhds1qtOwkeBAyN/mlU lq9NymSZ8QWl0yHYg33kX9vgpladPX1IRhg5r+q77iqjVnSs2MLOoCc8A8mfR73fv7Mp 12OrQ0fnw/qf6n/En68sI+Ue1ISEUeOXKwVpXaTnH9lAC6T/hDLD+b276N3I/VXM1vIJ /5p9iwbvX1e8lBqC+oIYX3GKEG2CW9aGd+ELdyJYxlDlPkarp2b7Oyj1F2ormHcmQVaC pdCSjD29LI4P70U1FsC5rUGmnzx3/zkh4i962VaNj1YiNrmjHK7AxXtup7/R64zw+AQE xYRw== X-Gm-Message-State: ALoCoQnB+roEIzrJMCsL6pPF82k789s77281BXbtSWxyXlHKAKEUmfYcr6OfkaPm4x4CzAm2bnv8 X-Received: by 10.194.204.201 with SMTP id la9mr3906429wjc.6.1423058818888; Wed, 04 Feb 2015 06:06:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.74 with SMTP id j10ls40240lag.7.gmail; Wed, 04 Feb 2015 06:06:58 -0800 (PST) X-Received: by 10.113.11.12 with SMTP id ee12mr30518067lbd.79.1423058818724; Wed, 04 Feb 2015 06:06:58 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id lc9si1382545lac.120.2015.02.04.06.06.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 06:06:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so1637976lbv.8 for ; Wed, 04 Feb 2015 06:06:58 -0800 (PST) X-Received: by 10.112.25.104 with SMTP id b8mr30564296lbg.69.1423058818639; Wed, 04 Feb 2015 06:06:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp508051lbj; Wed, 4 Feb 2015 06:06:57 -0800 (PST) X-Received: by 10.229.64.67 with SMTP id d3mr21410467qci.9.1423058814226; Wed, 04 Feb 2015 06:06:54 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id e4si2061150qai.92.2015.02.04.06.06.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Feb 2015 06:06:54 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0Za-0007ZA-8w; Wed, 04 Feb 2015 14:04:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0ZY-0007We-5P for xen-devel@lists.xen.org; Wed, 04 Feb 2015 14:04:52 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id DB/C7-02991-30722D45; Wed, 04 Feb 2015 14:04:51 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1423058689!12015705!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2409 invoked from network); 4 Feb 2015 14:04:50 -0000 Received: from mail-pd0-f179.google.com (HELO mail-pd0-f179.google.com) (209.85.192.179) by server-5.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 4 Feb 2015 14:04:50 -0000 Received: by pdbfp1 with SMTP id fp1so877420pdb.4 for ; Wed, 04 Feb 2015 06:04:48 -0800 (PST) X-Received: by 10.68.239.4 with SMTP id vo4mr47024037pbc.14.1423058688809; Wed, 04 Feb 2015 06:04:48 -0800 (PST) Received: from parthd-ubunutu.qualcomm.com ([202.46.23.62]) by mx.google.com with ESMTPSA id kg12sm2161881pbb.44.2015.02.04.06.04.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Feb 2015 06:04:47 -0800 (PST) From: parth.dixit@linaro.org To: xen-devel@lists.xen.org Date: Wed, 4 Feb 2015 19:32:01 +0530 Message-Id: <1423058539-26403-18-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> References: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> Cc: ian.campbell@citrix.com, Naresh Bhat , julien.grall@linaro.org, tim@xen.org, stefano.stabellini@citrix.com, jbeulich@suse.com, Parth Dixit , christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH RFC 17/35] pl011: Initialize serial from ACPI SPCR table X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Naresh Bhat Parse ACPI SPCR (Serial Port Console Redirection table) table and initialize the serial port pl011. Signed-off-by: Naresh Bhat Signed-off-by: Parth Dixit --- xen/arch/arm/setup.c | 6 +++++ xen/drivers/char/pl011.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ xen/include/acpi/actbl2.h | 6 +++++ xen/include/xen/serial.h | 1 + 4 files changed, 82 insertions(+) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index af9f429..317b985 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -762,7 +762,13 @@ void __init start_xen(unsigned long boot_phys_offset, init_IRQ(); + /* If ACPI enabled and ARM64 arch then UART initialization from SPCR table */ +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM_64) + acpi_uart_init(); +#else dt_uart_init(); +#endif + console_init_preirq(); console_init_ring(); diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index dd19ce8..3499ee3 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -280,6 +280,75 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) .init = pl011_uart_init, DT_DEVICE_END +/* Parse the SPCR table and initialize the Serial UART */ +#if defined(CONFIG_ARM_64) && defined(CONFIG_ACPI) + +#include + +static int __init acpi_pl011_uart_init(struct acpi_table_spcr *spcr) +{ + struct pl011 *uart; + u64 addr, size; + + uart = &pl011_com; + uart->clock_hz = 0x16e3600; + uart->baud = spcr->baud_rate; + uart->data_bits = 8; + uart->parity = spcr->parity; + uart->stop_bits = spcr->stop_bits; + + if ( spcr->interrupt < 0 ) + { + printk("pl011: Unable to retrieve the IRQ\n"); + return -EINVAL; + } + + uart->irq = spcr->interrupt; + addr = spcr->serial_port.address; + size = 0x1000; + uart->regs = ioremap_nocache(addr, size); + + acpi_set_irq(uart->irq, DT_IRQ_TYPE_EDGE_BOTH); + + if ( !uart->regs ) + { + printk("pl011: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off = DR; + uart->vuart.status_off = FR; + uart->vuart.status = 0; + + /* Register with generic serial driver. */ + serial_register_uart(SERHND_DTUART, &pl011_driver, uart); + + return 0; +} + +void __init acpi_uart_init(void) +{ + struct acpi_table_spcr *spcr=NULL; + + printk("ACPI UART Init\n"); + acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr); + + switch(spcr->interface_type) { + case ACPI_SPCR_TYPPE_PL011: + acpi_pl011_uart_init(spcr); + break; + /* Not implemented yet */ + case ACPI_SPCR_TYPE_16550: + case ACPI_SPCR_TYPE_16550_SUB: + default: + printk("iinvalid uart type\n"); + } +} + +#endif + /* * Local variables: * mode: C diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h index 87bc6b3..6aad200 100644 --- a/xen/include/acpi/actbl2.h +++ b/xen/include/acpi/actbl2.h @@ -815,6 +815,12 @@ struct acpi_table_spcr { #define ACPI_SPCR_DO_NOT_DISABLE (1) +/* UART Interface type */ +#define ACPI_SPCR_TYPE_16550 0 +#define ACPI_SPCR_TYPE_16550_SUB 1 +#define ACPI_SPCR_TYPPE_PL011 3 + + /******************************************************************************* * * SPMI - Server Platform Management Interface table diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h index 9f4451b..99e53d4 100644 --- a/xen/include/xen/serial.h +++ b/xen/include/xen/serial.h @@ -167,6 +167,7 @@ void ns16550_init(int index, struct ns16550_defaults *defaults); void ehci_dbgp_init(void); void __init dt_uart_init(void); +void __init acpi_uart_init(void); struct physdev_dbgp_op; int dbgp_op(const struct physdev_dbgp_op *);