From patchwork Thu Mar 21 10:25:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Tomer X-Patchwork-Id: 10863277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9E751390 for ; Thu, 21 Mar 2019 10:28:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF4A12A095 for ; Thu, 21 Mar 2019 10:28:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3C162A0A8; Thu, 21 Mar 2019 10:28:22 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C376B2A095 for ; Thu, 21 Mar 2019 10:28:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6utZ-0008Bi-6C; Thu, 21 Mar 2019 10:25:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6utX-0008Bd-JE for xen-devel@lists.xenproject.org; Thu, 21 Mar 2019 10:25:55 +0000 X-Inumbo-ID: b51138cd-4bc3-11e9-bc90-bc764e045a96 Received: from mail-pg1-x541.google.com (unknown [2607:f8b0:4864:20::541]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id b51138cd-4bc3-11e9-bc90-bc764e045a96; Thu, 21 Mar 2019 10:25:54 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id v12so3927166pgq.1 for ; Thu, 21 Mar 2019 03:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KuZ+cW+cdDWicrERWr2YtFt2ZTL8d3zsamiUESnlGow=; b=eAofXjOPL8ZTHSa7PzmtqJRvcP8NOBCHL/mKoP758aU3anahXpbUtA4O3yFn9wVfEv lo+Uf+/0TgI3tCuCqcTzcgqbY6hsd9pNTvw+yrknXH6Qu/uGU7I8LKpoeLRmsU3GgJ0r LxZoRKif8HAOC92CVXBohSy4TDEb4kLKRyGXMMcX8Oo6+w31nn4eKxRJ/ujDmvHQGKI/ S/hsIalis/XTi+g5AozD5QWXzuBFxWwfqe99FLc+Wwm7wNfwj7Q1xXwYyoh2R3mwKqSn I73nW4uCR3nmXMYSNNQ0gbciF0dRtTV5VmdmF+5AGJ59fTpkEx1KTOAqLHM+XiV9iKuX 6g7g== 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=KuZ+cW+cdDWicrERWr2YtFt2ZTL8d3zsamiUESnlGow=; b=EecwBRSpk9TfW7NQsfx6MhJv5ZCXR4cYLyfkHjhIYie55RtAQ2K6nnUybS6mFrBS8x BYCDBqbmrBCar+L+UdmK/YAPiTf5mX5AGrx/ydHqezCWIzio5Phowi+nhMcpBFn+cOKX IEpZTezlS6LocPBheedC/w1D3cdWcubMqTPVnbhYUsB5mUnfdwp0eQh0L8n7i4O769hH OrQ1G6hUn7DMjhiQ1LpDVpr2CR6P6yPL3EXZPTWfjutYM49pUrX8BUBZfDOtliQnXBiF 2sMJ6GcTJoaE00tQ7+g0YAxrGwlLgo9EunWpQGVhDIFUPfrPCIAnjLli/kIkJeA2UOcS uUIQ== X-Gm-Message-State: APjAAAW99Jo5TYhmQVm9P8pSysXj2G7mDC16AUZ+ePG+arHcIC/qLD/C da4dTaLDuY0tpw+G05H/qT/OFm9P X-Google-Smtp-Source: APXvYqzFhvmZbrrKqUZkzHqytuCuQ2HAk593qXXLAOwmDh4WzjkH4i1aiMOBxWfLQLYuDc20V10Gww== X-Received: by 2002:a63:f558:: with SMTP id e24mr2544766pgk.373.1553163953352; Thu, 21 Mar 2019 03:25:53 -0700 (PDT) Received: from localhost.localdomain ([47.31.89.138]) by smtp.gmail.com with ESMTPSA id f87sm6657208pff.38.2019.03.21.03.25.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:25:52 -0700 (PDT) From: Amit Singh Tomar To: xen-devel@lists.xenproject.org Date: Thu, 21 Mar 2019 15:55:33 +0530 Message-Id: <1553163935-12862-1-git-send-email-amittomer25@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH v2 1/3] xen/arm: Add Amlogic Meson SoCs earlyprintk 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: andre.przywara@arm.com, julien.grall@arm.com, sstabellini@kernel.org, Amit Singh Tomar MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Amit Singh Tomar Reviewed-by: Andre Przywara Tested-by: Andre Przywara --- TODO: * Capture XEN boot info on WIKI. Changes since v1: * Fixed coding style issue. * Undone changes in early-printk.txt. Changes since RFC: * Replaced LDRH with LDR, with this there is no scattered output on console now. * Used tbnz instead of tst and b.ne. * Used AML_ prefix against register names. --- xen/arch/arm/arm64/debug-meson.inc | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-meson.inc diff --git a/xen/arch/arm/arm64/debug-meson.inc b/xen/arch/arm/arm64/debug-meson.inc new file mode 100644 index 0000000..01b70f0 --- /dev/null +++ b/xen/arch/arm/arm64/debug-meson.inc @@ -0,0 +1,51 @@ +/* + * xen/arch/arm/arm64/debug-meson.inc + * + * MESON specific debug code. + * + * Copyright (c) 2019, Amit Singh Tomar . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + */ + +#define AML_UART_WFIFO_REG 0x00 +#define AML_UART_STATUS_REG 0x0c + +#define AML_UART_TX_FIFO_FULL 21 + +/* + * MESON UART wait UART to be ready to transmit + * xb: register which contains the UART base address + * c: scratch register + */ +.macro early_uart_ready xb c +1: + ldr w\c, [\xb, #AML_UART_STATUS_REG] /* status register */ + tbnz w\c, #AML_UART_TX_FIFO_FULL, 1b /* Check TXFIFO FULL bit */ +.endm + +/* + * MESON UART transmit character + * xb: register which contains the UART base address + * wt: register which contains the character to transmit + */ +.macro early_uart_transmit xb wt + str \wt, [\xb, #AML_UART_WFIFO_REG] +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */ From patchwork Thu Mar 21 10:25:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Tomer X-Patchwork-Id: 10863279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE0031390 for ; Thu, 21 Mar 2019 10:28:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D14092A095 for ; Thu, 21 Mar 2019 10:28:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C59DF2A0A7; Thu, 21 Mar 2019 10:28:29 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A25562A09F for ; Thu, 21 Mar 2019 10:28:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6utf-0008Cc-Fs; Thu, 21 Mar 2019 10:26:03 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6ute-0008CW-UA for xen-devel@lists.xenproject.org; Thu, 21 Mar 2019 10:26:02 +0000 X-Inumbo-ID: b90e732a-4bc3-11e9-bc90-bc764e045a96 Received: from mail-pf1-x442.google.com (unknown [2607:f8b0:4864:20::442]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id b90e732a-4bc3-11e9-bc90-bc764e045a96; Thu, 21 Mar 2019 10:26:01 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id d25so4002195pfn.8 for ; Thu, 21 Mar 2019 03:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6PyfgNSTdDQnMZEI4H9ir9rec9M/CwXOoZ5tAhUbJn0=; b=TbRZwHbwIHhZlkevRpnxDYQ7/oJgV8X0bhZJWRitWCGTZpIVGdQKP9ApWvQWe+jzD7 KOrahMlD/jJpmORq7eVhvn2iQ8X1MDL85SHDUSSKjsZ5IkT7cpIZZJHPR8Rp2HB/ob8D SIlkNHoZgD2W9SthXlD1LtsWDh1A+ioWym9G1zxi4uVF+v9UhJKNPsFj+D4sXCmLHRdO vJ06ct1enpcAsyRGgYETTwtvPx/Te3x79wHFiQcf+8K0NGMQFBD6ZPsV1lGHFBE2SopF w8Zar4MWAvNAQ3+m7iaO69UBIkbjtsiewEw0bNCGuGdV/BN21qge78IbF6r+C2rLsBnC 4NgQ== 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:in-reply-to :references; bh=6PyfgNSTdDQnMZEI4H9ir9rec9M/CwXOoZ5tAhUbJn0=; b=QiAKKT+9TcIfdGfuhQF8Q/UtgAoZBR/srMRUBxjpBJ3SWFFqvh0vOoygg+LEfncYq1 XCYM0VtVCzyHJFTLNicfX4qDbg/PknFkSc+NnxigvcaKSJFRvenhqwk5JKszcv/sQmBD DMLrxLJr5yiCpHhook8VtrXpPWyyW9FYqxBy3RMp5wtNE5FRAfgtHD/r9NCEe7ArhC0P EwPpz9TdetFz7J7tC7mFvTQo+bbhS8SPlMOmZBYNJ+IhDKz+578W9FC1pUx76xmnJ804 dD3Ej8En0ErrFmFC+5n6bRd8Nq2dYxUQWgoeRHydsxSklbw8zh01HDzj7MVRmxq/O2QD Nu7w== X-Gm-Message-State: APjAAAWdhvkwO1WSO6kkzf+Dujm+YJteInzM3G1hx0lr8hakxnixbncW EmQH0Ry5wx2lz0XXqo/Xz9YFq99g X-Google-Smtp-Source: APXvYqwE/BWjLTP7tOw12L2ciQruH5x8DAmeDlkAdjtCUC1HH1aXSspMKHnjoX/BHm104r4JfRUCrw== X-Received: by 2002:a17:902:32b:: with SMTP id 40mr2686308pld.122.1553163960099; Thu, 21 Mar 2019 03:26:00 -0700 (PDT) Received: from localhost.localdomain ([47.31.89.138]) by smtp.gmail.com with ESMTPSA id f87sm6657208pff.38.2019.03.21.03.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:25:59 -0700 (PDT) From: Amit Singh Tomar To: xen-devel@lists.xenproject.org Date: Thu, 21 Mar 2019 15:55:34 +0530 Message-Id: <1553163935-12862-2-git-send-email-amittomer25@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553163935-12862-1-git-send-email-amittomer25@gmail.com> References: <1553163935-12862-1-git-send-email-amittomer25@gmail.com> Subject: [Xen-devel] [PATCH v2 2/3] xen/arm: Add MESON UART driver for Amlogic Meson SoCs 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: andre.przywara@arm.com, julien.grall@arm.com, sstabellini@kernel.org, Amit Singh Tomar MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds driver for UART controller present on Amlogic Meson SoCs and it has been tested on Nanopi K2 board based on S905 SoC. Controller registers defination is taken from Linux 4.20. https://github.com/torvalds/linux/blob/v4.20-rc1/drivers/tty/serial/meson_uart.c Signed-off-by: Amit Singh Tomar Reviewed-by: Andre Przywara Acked-by: Julien Grall --- Changes since v1: * Removed clrsetbits macro. * Fixed coding style issue. * Updated MAINTAINERS file. Changes since RFC: * Removed S905 reference as other Amlogic SoCs have this uart controller. * Replaced meson_s905_read/write helper with clrsetbit and friends helper. * Followed proper UART reset sequence. * List all UART compatible strings same as Linux driver. --- xen/drivers/char/Kconfig | 8 ++ xen/drivers/char/Makefile | 1 + xen/drivers/char/meson-uart.c | 276 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 xen/drivers/char/meson-uart.c diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig index b1f07f8..b572305 100644 --- a/xen/drivers/char/Kconfig +++ b/xen/drivers/char/Kconfig @@ -20,6 +20,14 @@ config HAS_MVEBU This selects the Marvell MVEBU UART. If you have a ARMADA 3700 based board, say Y. +config HAS_MESON + bool "Amlogic MESON UART driver" + default y + depends on ARM_64 + help + This selects the Amlogic MESON UART. If you have a Amlogic based + board, say Y. + config HAS_PL011 bool "ARM PL011 UART driver" default y diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile index b68c330..7c646d7 100644 --- a/xen/drivers/char/Makefile +++ b/xen/drivers/char/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_HAS_NS16550) += ns16550.o obj-$(CONFIG_HAS_CADENCE_UART) += cadence-uart.o obj-$(CONFIG_HAS_PL011) += pl011.o obj-$(CONFIG_HAS_EXYNOS4210) += exynos4210-uart.o +obj-$(CONFIG_HAS_MESON) += meson-uart.o obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o obj-$(CONFIG_HAS_OMAP) += omap-uart.o obj-$(CONFIG_HAS_SCIF) += scif-uart.o diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c new file mode 100644 index 0000000..c16c188 --- /dev/null +++ b/xen/drivers/char/meson-uart.c @@ -0,0 +1,276 @@ +/* + * xen/drivers/char/meson-uart.c + * + * Driver for Amlogic MESON UART + * + * Copyright (c) 2019, Amit Singh Tomar . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + */ + +#include +#include +#include +#include + +/* Register offsets */ +#define AML_UART_WFIFO_REG 0x00 +#define AML_UART_RFIFO_REG 0x04 +#define AML_UART_CONTROL_REG 0x08 +#define AML_UART_STATUS_REG 0x0c +#define AML_UART_MISC_REG 0x10 + +/* UART_CONTROL bits */ +#define AML_UART_TX_RST BIT(22) +#define AML_UART_RX_RST BIT(23) +#define AML_UART_CLEAR_ERR BIT(24) +#define AML_UART_RX_INT_EN BIT(27) +#define AML_UART_TX_INT_EN BIT(28) + +/* UART_STATUS bits */ +#define AML_UART_RX_FIFO_EMPTY BIT(20) +#define AML_UART_TX_FIFO_FULL BIT(21) +#define AML_UART_TX_FIFO_EMPTY BIT(22) +#define AML_UART_TX_CNT_MASK GENMASK(14, 8) + +/* AML_UART_MISC bits */ +#define AML_UART_XMIT_IRQ(c) (((c) & 0xff) << 8) +#define AML_UART_RECV_IRQ(c) ((c) & 0xff) + +#define TX_FIFO_SIZE 64 + +#define setbits(addr, set) writel((readl(addr) | (set)), (addr)) +#define clrbits(addr, clear) writel((readl(addr) & ~(clear)), (addr)) + +static struct meson_uart { + unsigned int irq; + void __iomem *regs; + struct irqaction irqaction; + struct vuart_info vuart; +} meson_com; + +static void meson_uart_interrupt(int irq, void *data, + struct cpu_user_regs *regs) +{ + struct serial_port *port = data; + struct meson_uart *uart = port->uart; + uint32_t st = readl(uart->regs + AML_UART_STATUS_REG); + + if ( !(st & AML_UART_RX_FIFO_EMPTY) ) + serial_rx_interrupt(port, regs); + + if ( !(st & AML_UART_TX_FIFO_FULL) ) + serial_tx_interrupt(port, regs); +} + +static void __init meson_uart_init_preirq(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + + /* Reset UART */ + setbits(uart->regs + AML_UART_CONTROL_REG, + (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR)); + + clrbits(uart->regs + AML_UART_CONTROL_REG, + (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLEAR_ERR)); + + /* Disable Rx/Tx interrupts */ + clrbits(uart->regs + AML_UART_CONTROL_REG, + (AML_UART_RX_INT_EN | AML_UART_TX_INT_EN)); +} + +static void __init meson_uart_init_postirq(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + + uart->irqaction.handler = meson_uart_interrupt; + uart->irqaction.name = "meson_uart"; + uart->irqaction.dev_id = port; + + if ( setup_irq(uart->irq, 0, &uart->irqaction) != 0 ) + { + printk("Failed to allocated Meson UART IRQ %d\n", uart->irq); + return; + } + + /* + * Configure Rx/Tx interrupts based on bytes in FIFO, these bits have + * taken from Linux driver + */ + writel((AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(TX_FIFO_SIZE / 2)), + uart->regs + AML_UART_MISC_REG); + + /* Make sure Rx/Tx interrupts are enabled now */ + setbits(uart->regs + AML_UART_CONTROL_REG, + (AML_UART_RX_INT_EN | AML_UART_TX_INT_EN)); +} + +static void meson_uart_suspend(struct serial_port *port) +{ + BUG(); +} + +static void meson_uart_resume(struct serial_port *port) +{ + BUG(); +} + +static void meson_uart_putc(struct serial_port *port, char c) +{ + struct meson_uart *uart = port->uart; + + writel(c, uart->regs + AML_UART_WFIFO_REG); +} + +static int meson_uart_getc(struct serial_port *port, char *c) +{ + struct meson_uart *uart = port->uart; + + if ( (readl(uart->regs + AML_UART_STATUS_REG) & AML_UART_RX_FIFO_EMPTY) ) + return 0; + + *c = readl(uart->regs + AML_UART_RFIFO_REG) & 0xff; + + return 1; +} + +static int __init meson_irq(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + + return uart->irq; +} + +static const struct vuart_info *meson_vuart_info(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + + return &uart->vuart; +} + +static void meson_uart_stop_tx(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + + clrbits(uart->regs + AML_UART_CONTROL_REG, AML_UART_TX_INT_EN); +} + +static void meson_uart_start_tx(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + + setbits(uart->regs + AML_UART_CONTROL_REG, AML_UART_TX_INT_EN); +} + +static int meson_uart_tx_ready(struct serial_port *port) +{ + struct meson_uart *uart = port->uart; + uint32_t reg; + + reg = readl(uart->regs + AML_UART_STATUS_REG); + + if ( reg & AML_UART_TX_FIFO_EMPTY ) + return TX_FIFO_SIZE; + if ( reg & AML_UART_TX_FIFO_FULL ) + return 0; + + return (reg & AML_UART_TX_CNT_MASK) >> 8; +} + +static struct uart_driver __read_mostly meson_uart_driver = { + .init_preirq = meson_uart_init_preirq, + .init_postirq = meson_uart_init_postirq, + .endboot = NULL, + .suspend = meson_uart_suspend, + .resume = meson_uart_resume, + .putc = meson_uart_putc, + .getc = meson_uart_getc, + .tx_ready = meson_uart_tx_ready, + .stop_tx = meson_uart_stop_tx, + .start_tx = meson_uart_start_tx, + .irq = meson_irq, + .vuart_info = meson_vuart_info, +}; + +static int __init meson_uart_init(struct dt_device_node *dev, const void *data) +{ + const char *config = data; + struct meson_uart *uart; + int res; + u64 addr, size; + + if ( strcmp(config, "") ) + printk("WARNING: UART configuration is not supported\n"); + + uart = &meson_com; + + res = dt_device_get_address(dev, 0, &addr, &size); + if ( res ) + { + printk("meson: Unable to retrieve the base address of the UART\n"); + return res; + } + + res = platform_get_irq(dev, 0); + if ( res < 0 ) + { + printk("meson: Unable to retrieve the IRQ\n"); + return -EINVAL; + } + + uart->irq = res; + + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("meson: Unable to map the UART\n"); + return -ENOMEM; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off = AML_UART_WFIFO_REG; + uart->vuart.status_off = AML_UART_STATUS_REG; + uart->vuart.status = AML_UART_RX_FIFO_EMPTY | AML_UART_TX_FIFO_EMPTY; + + /* Register with generic serial driver. */ + serial_register_uart(SERHND_DTUART, &meson_uart_driver, uart); + + dt_device_set_used_by(dev, DOMID_XEN); + + return 0; +} + +static const struct dt_device_match meson_dt_match[] __initconst = +{ + DT_MATCH_COMPATIBLE("amlogic,meson-uart"), + DT_MATCH_COMPATIBLE("amlogic,meson6-uart"), + DT_MATCH_COMPATIBLE("amlogic,meson8-uart"), + DT_MATCH_COMPATIBLE("amlogic,meson8b-uart"), + DT_MATCH_COMPATIBLE("amlogic,meson-gx-uart"), + { /* sentinel */ }, +}; + +DT_DEVICE_START(meson, "Amlogic UART", DEVICE_SERIAL) + .dt_match = meson_dt_match, + .init = meson_uart_init, +DT_DEVICE_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: +*/ From patchwork Thu Mar 21 10:25:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Tomer X-Patchwork-Id: 10863275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6A5614DE for ; Thu, 21 Mar 2019 10:28:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA752A09F for ; Thu, 21 Mar 2019 10:28:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E7712A0A5; Thu, 21 Mar 2019 10:28:22 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5AAE82A09F for ; Thu, 21 Mar 2019 10:28:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6utj-0008Cw-Q4; Thu, 21 Mar 2019 10:26:07 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6uti-0008Cq-Kc for xen-devel@lists.xenproject.org; Thu, 21 Mar 2019 10:26:06 +0000 X-Inumbo-ID: bb906924-4bc3-11e9-bc90-bc764e045a96 Received: from mail-pf1-x443.google.com (unknown [2607:f8b0:4864:20::443]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id bb906924-4bc3-11e9-bc90-bc764e045a96; Thu, 21 Mar 2019 10:26:05 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id r15so4003182pfn.9 for ; Thu, 21 Mar 2019 03:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cceAQfakHG7glULO1YGQFPNr5HaUFN4BFI35V20ylW8=; b=lvo7/5M3Fhp2P2bRIz76QsXu2ZhZwZmttn6or59xuyMDTCN1BPO5h+JZgfkXIo8Euf c4iVke4Ry4u+27uIx0TFOhJVgVcI6HJwMK8xRKsQfSLIf9cXmz/8zrzdeGaPAH0SqNMx ZzXGy26QcUnCgIYnO7ddoWnyAMLrrKAscQ3SfBoCJTckmE8J9a4cZxg8/jif7boBrEgd DOPvjoOl0eJsVB2nq+mkcphLKO8WFagj4UzwdJP4xkLexRGvSkIeDgcE/ieUpTlXwJ0b mPy1ZYtNQJX6im4O7O12UFO2+OAf+cPEzbPKIua4SynlCC2Rfm2r9napMKs/aXa87tOf ldMQ== 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:in-reply-to :references; bh=cceAQfakHG7glULO1YGQFPNr5HaUFN4BFI35V20ylW8=; b=cWO1sojzAWMTbrrS6/KfG60MTNHpbb1WV64uzUck4QBZyr1Uti5d6CBS2xoTLqpV4W EcPLsXblUYJtOxFK64BAC+mordQQ6jnOtN+kMJTzu1yFLinKQWAH5VJYZiPGrhfchVzW pwfOehzJpqb5njA3ui2WgVB6q33MSchXWSrH0/BTUymjGb0ACSQxf0HwY9HK9XGa31fM PW0fiSvgi0trsAkqCcm3TVpkk6WuvC5JTOvoEMC9UHLy4KYWhJ1mtZxUSftXfSGG4Hqh KFMMf4qyLtVAVOBN1nzw+Voi31YJLaaU9eQhzYMp9g7QTbJegDXFawCr6GDKkhlU3k4K jKKg== X-Gm-Message-State: APjAAAVDiqIxZ9rYDf2USZj8a7CJpLrrLSvGQ1DgnzDtHJdTCU5V/t9o s6jo5W9f6y+mjL1JWhTkjYVH30EX X-Google-Smtp-Source: APXvYqx4LN/hd1PPYDGXuYCjjlbGbWdPl0xYhouOeJV92ox1iFg8jdQ29hDFm1EMKJRGLEcGFiaArw== X-Received: by 2002:a62:ed08:: with SMTP id u8mr2573832pfh.200.1553163964367; Thu, 21 Mar 2019 03:26:04 -0700 (PDT) Received: from localhost.localdomain ([47.31.89.138]) by smtp.gmail.com with ESMTPSA id f87sm6657208pff.38.2019.03.21.03.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:26:03 -0700 (PDT) From: Amit Singh Tomar To: xen-devel@lists.xenproject.org Date: Thu, 21 Mar 2019 15:55:35 +0530 Message-Id: <1553163935-12862-3-git-send-email-amittomer25@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553163935-12862-1-git-send-email-amittomer25@gmail.com> References: <1553163935-12862-1-git-send-email-amittomer25@gmail.com> Subject: [Xen-devel] [PATCH v2 3/3] MAINTAINERS: add ARM meson serial driver 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: andre.przywara@arm.com, julien.grall@arm.com, sstabellini@kernel.org, Amit Singh Tomar MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The meson-uart.c is an ARM specific UART driver for the Amlogic MESON SoC family. Signed-off-by: Amit Singh Tomar Reviewed-by: Andre Przywara --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index ba7527c..aff7f81 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -182,6 +182,7 @@ F: xen/arch/arm/ F: xen/drivers/char/arm-uart.c F: xen/drivers/char/cadence-uart.c F: xen/drivers/char/exynos4210-uart.c +F: xen/drivers/char/meson-uart.c F: xen/drivers/char/mvebu-uart.c F: xen/drivers/char/omap-uart.c F: xen/drivers/char/pl011.c