From patchwork Mon Feb 28 01:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12762382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B3158C4332F for ; Mon, 28 Feb 2022 05:12:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.280086.477951 (Exim 4.92) (envelope-from ) id 1nOYKc-0004yq-MW; Mon, 28 Feb 2022 05:12:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 280086.477951; Mon, 28 Feb 2022 05:12:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nOYKc-0004y9-Ha; Mon, 28 Feb 2022 05:12:22 +0000 Received: by outflank-mailman (input) for mailman id 280086; Mon, 28 Feb 2022 00:27:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nOTso-0007Sm-HQ for xen-devel@lists.xenproject.org; Mon, 28 Feb 2022 00:27:22 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0618.outbound.protection.outlook.com [2a01:111:f400:fe02::618]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 30b02d9f-982d-11ec-8eba-a37418f5ba1a; Mon, 28 Feb 2022 01:27:21 +0100 (CET) Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DB8PR04MB6460.eurprd04.prod.outlook.com (2603:10a6:10:10f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.25; Mon, 28 Feb 2022 00:27:18 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::552c:ed46:26dc:77cc]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::552c:ed46:26dc:77cc%4]) with mapi id 15.20.4995.018; Mon, 28 Feb 2022 00:27:18 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 30b02d9f-982d-11ec-8eba-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BjhichTcyAAIgI9ku7T2z284g06GO1wQHMR1atsu2pLjb+pDsaiU+pDnVFpBzOBmelMr1Np476YrFqcoFJ2wZOiWPpyNXXzQ9U1hHT9ee9iaDwa0BMRnrsbIp70M5oZKai3eJbfxSexByydtR1J23kfR9yYWv4ESUDYxptESrrJmvJNK6hb+ldXnIkV4yqivbPUjZj8xZNYN0GzOKhmcpnOpLey0aQtd09SludG0lLVmkeVCPJeSDPzBrzYrtLy7ox6bCUsolMMJY2KwJVap8jdlTaRYXWrh5ryBvn7H6WHXbGhftmFfHwmZf5PktPBsTN4U51UHWGFLy8dQswdkrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+wXOdp/qRyy28MQahFckXGWnjzLCGIX/DgJitz/KjhM=; b=Mny9SoOjoLQyHueLvltwCcOQapOrHDjvMGJMNP2KYt3Oep3jSpoqiw9VDbKYzGj1zXHa2wo+TTsAjHwm93rdwRg4F37RqBdIlGuWbN6W22MU3ih3UAyE6yz9zp6FaRfx/HNem9XH18JrOCcV2f1qnKDx6+xNKYUTkr/lj2baCAfPk4SwGEKxGbQl1KrNaoRMbG5Gc+B74RepTluNDwQ2sjOZglPbUmc2uefWyZLYhdiIDNqaqC94MRMPeOJ+TtXjM52KD8NTZMRsykdlMYD6j8pCNhSIObpcotCkJdoua9AwsuesNeAwx2aUh/zFT+RGbEwg5yCRbiKIBoJdN+bgtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+wXOdp/qRyy28MQahFckXGWnjzLCGIX/DgJitz/KjhM=; b=Kdzt/NhcxG6s67r19Frai88pZThyA/FKeyyEnxzI/nhGlG7pDCUDea5egIYbUjomloOvH5oZzxEmKh5OlXhPHwMXHRXQSnITM1/2lWQ5eRcdcd96IIobBViwctefItanMNcu1NLOmRgomKmvdhDjLpo3ihkMv8P0pqPHSgilAxY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Peng Fan (OSS)" To: sstabellini@kernel.org, julien@xen.org, Volodymyr_Babchuk@epam.com, bertrand.marquis@arm.com Cc: andrew.cooper3@citrix.com, george.dunlap@citrix.com, jbeulich@suse.com, wl@xen.org, xen-devel@lists.xenproject.org, van.freenix@gmail.com, Peng Fan Subject: [PATCH 1/3] xen/arm: Add i.MX lpuart driver Date: Mon, 28 Feb 2022 09:07:09 +0800 Message-Id: <20220228010711.11566-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20220228010711.11566-1-peng.fan@oss.nxp.com> References: <20220228010711.11566-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR02CA0001.apcprd02.prod.outlook.com (2603:1096:4:194::10) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b1b741b-5009-4730-1971-08d9fa511357 X-MS-TrafficTypeDiagnostic: DB8PR04MB6460:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wgCsUBnEjJNfumzMcRGt4qg0+OZHROm9nnA2of5KB9Omjdx7keMJ2i4xo85TOVYhvOuq3/Tw3u69A/cbujCGpfjDH4g3TM/NjJuw3n4RKhY9ycCf/Bla04u97SjrzDbn17G4ZFLfG/ADylzIjaFokJfXuZzHQTRK6tAokVdrpadv4tG8xeEinAZlv+JJLKcYco81OcnGti20y+kKxF62IM569OgwoMzrhrp0YdQEaBMq0phLP7hzy8Pkh6QKTRU3PXyAlm2hzHxN6OQEJ9d/9J+fTIi36KdKfoELuk9m+jr5V3rUKKnmdEdSq8aIGSljYOsZrxNiBDYUXOzphvlq9/ti/XtyRXaR4XxUfwBXTo86PkzNaVXeEKiJw4dDETWrQ8gp5VXoIAiNx7vh8D11dLc8UJJDjhaKYuiyanAD6nHiWAEwlJ43AXei/OzQYrNY/9/l1jAEsLigFfDRM2jBl/Xmku+B5jjM8pgA/gEZljb9qTKs6Jbj7qVMAXie/nUZylKmBHV9KsH4A46hPuErcqTnmJvcey3vOZtF9J4MNojcVNv7Kln8hm1S5/Q3/jlB1QYuyY33rNzIKz9cq9lAbtplX3Enm1FfvU95e6+m3XdivhzxyQWlVZbBIEhiuIJIkEeHWxmvNQrEwFogbikHm73vcniVUkBwgZvLpOqRsfdFIIxYFlwvZcLONzzkIyUBpfRmGCyKob7nYBU6sk05DQZyrUw0Ko3vWVD2fSuXdUU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66946007)(66556008)(66476007)(6512007)(6506007)(6666004)(316002)(4326008)(8676002)(52116002)(2906002)(2616005)(1076003)(86362001)(26005)(186003)(5660300002)(6486002)(38350700002)(38100700002)(30864003)(8936002)(7416002)(508600001)(83380400001)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pTgVCFJ2DKBJDpJW+PMHoAvV3YXiGVvsqmyrrEg2UtPWmo5DVZ7sZnEBbSWEch2qQkYPlCTtLHeFBUNWtnzTib09YgtPtnRuemW1JWPLCicwCtiTa3y4EcOrISn8LbBuznD//bKdokXXWCZ+UYSUkiFzXZP5tlgmPvTH5/brnBWTzFrToiwf8hZapammfFJPTWgXFSggF0vP/oL+fp+70SRrQ5Qb3OgsG1GrAQj1wyMhZw9BZjkSpO67uD93hj9i3V0iJW775AVDt0rlehzrK+LAPTGEILYrNTFUEq1WlQ7mngXboadw0qE3gHNG09fPwnG34TXO4P5WLpiAuqvJ4OlF024rBWbG6c47rtZeHRO7czrWlLzgheP/EA+wOQCwB7QQAjI/ADjjO5rf2+Ayp+UMsClh9SiZSTvR1R5PJ86m7kJSb51yW4gIQxePMKncv2X4HQUR+PE+fuNcM4wRTxVwXgcC4bYcZ3pOiz/ehnguQRmVP15GPPjKm6LMhy4qVvOCNPt/fljxyqHo12UATdle7EVj4H2sGFU8C/t+sZaXsdbk289EEekllJcKN5N/pMpUw9GK9xypqYGdHXSZKKyNbRGcMyNw4CH4GMB5t20e9C+bi23isko+zmf5yKMPO24IC997G1XA5+VgQZYCwX1VZBxcEPr8u4MF4x8hukcQQFfMYAfnlk4IYhs0GC9FIm0pVPzvW8o78lBsJWGB5JW0ujfU5Hi51YnUGq+mIJgsStoC7+9ICQ/QU+1yN+EmD7YZpCllt7cHh+X7oYEzluZOwtvWn8lR7TL09b23aMw4ELJC+kxspfEkXXWR3Hj4GcZX444CNs5cF7cnMZlMIpMOjIoNeQGTbyVEfiHh+ZbyNUCXbfmKbtREmGx+uO2NYDLAbSjRdG78mFc7gk6jPy5RgM1oOyebbndzWcQD4c7bkemMWaGqQXN229yebPbW5/So0EOG/DmWF6jpta6f2debVrtYpusrtvRw6zAbnu0ZrYcGbimoVnOUQz+46XI0pK46leSleW1SumjddJIYFaLFPwe80Q0lkdMWJSIqxoWr3PRU14GnJhM2s4NpDksow0EdIQNBXxaS6o8a8VdLxsIifLAgbcFStZUCjl9+1lX2BHwQLZXDmCOb6AkmgKNrMwZAY0QV/GNqKLvdBvO72GrbaRpYzvthuWqBNgKd6yZh9nRinxQ5EDGLzja2jd7Qj9/3KfwylmSWdi7cW0ZsOPQ2U4b234GmRlG3Ny3YA6A7jbDRPCrzUZCUudhTOq0HO4iILVcXS+GuljbybTgPNRPUOIUDIelXk6z6Dzyl6kreToiBvPVt/RyYWk60PRm6NLXBIH03ykk41QHNlzdnK9vw1WHAIxR+yNA+duqCtdJlRs/WGbRbq3+z3W2R150dDJNglSzZBFNpqhCRkmKgWkg0kqlnfQB3NB0P2wehmglVyFZjV2ZFl+58U0HeJvCoBnfPCA4FitnpBqx2e7h2XMb7RO4ap8+zEpVIlOzdbHDbpgSs7/zuqxH7uANJVYzGJHN6icKbbBvtN0g7BN3/NGSwTdNkCcD6qMXSnxQNskJzZn45CUILc493VjtuwOwP9I9+42XAehagVOHFbcLYU1tX7xhP8zYOb//Wk/pT06E= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b1b741b-5009-4730-1971-08d9fa511357 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 00:27:17.9342 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0ApXLbcKGoXA+hr2XrwmFaMUF9R07QQ2O/Rg644RIiJx8YnaPEHF+bBKY7zNgCsrlaOu4pa3IuOQLrp/3K4vQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6460 From: Peng Fan Signed-off-by: Peng Fan --- xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/imx-lpuart.c | 303 ++++++++++++++++++++++++++++++++++ xen/include/xen/imx-lpuart.h | 64 +++++++ 4 files changed, 376 insertions(+) create mode 100644 xen/drivers/char/imx-lpuart.c create mode 100644 xen/include/xen/imx-lpuart.h diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig index 2ff5b288e2..0efdb2128f 100644 --- a/xen/drivers/char/Kconfig +++ b/xen/drivers/char/Kconfig @@ -13,6 +13,14 @@ config HAS_CADENCE_UART This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq based board, say Y. +config HAS_IMX_LPUART + bool "i.MX LPUART driver" + default y + depends on ARM_64 + help + This selects the i.MX LPUART. If you have a i.MX8QM based board, + say Y. + config HAS_MVEBU bool "Marvell MVEBU UART driver" default y diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile index 7c646d771c..14e67cf072 100644 --- a/xen/drivers/char/Makefile +++ b/xen/drivers/char/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o obj-$(CONFIG_HAS_OMAP) += omap-uart.o obj-$(CONFIG_HAS_SCIF) += scif-uart.o obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o +obj-$(CONFIG_HAS_IMX_LPUART) += imx-lpuart.o obj-$(CONFIG_ARM) += arm-uart.o obj-y += serial.o obj-$(CONFIG_XEN_GUEST) += xen_pv_console.o diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c new file mode 100644 index 0000000000..2a30e3f21a --- /dev/null +++ b/xen/drivers/char/imx-lpuart.c @@ -0,0 +1,303 @@ +/* + * xen/drivers/char/imx-lpuart.c + * + * Driver for i.MX LPUART. + * + * Peng Fan + * Copyright 2022 NXP + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define imx_lpuart_read(uart, off) readl((uart)->regs + off) +#define imx_lpuart_write(uart, off, val) writel((val), (uart)->regs + off) + +static struct imx_lpuart { + unsigned int baud, clock_hz, data_bits, parity, stop_bits, fifo_size; + unsigned int irq; + char __iomem *regs; + struct irqaction irqaction; + struct vuart_info vuart; +} imx8_com = {0}; + +static void imx_lpuart_interrupt(int irq, void *data, + struct cpu_user_regs *regs) +{ + struct serial_port *port = data; + struct imx_lpuart *uart = port->uart; + unsigned int sts, rxcnt; + + sts = imx_lpuart_read(uart, UARTSTAT); + rxcnt = imx_lpuart_read(uart, UARTWATER) >> UARTWATER_RXCNT_OFF; + + if ((sts & UARTSTAT_RDRF) || (rxcnt > 0)) { + serial_rx_interrupt(port, regs); + } + + if ((sts & UARTSTAT_TDRE) && + !(imx_lpuart_read(uart, UARTBAUD) & UARTBAUD_TDMAE)) + serial_tx_interrupt(port, regs); + + imx_lpuart_write(uart, UARTSTAT, sts); +} + +static void __init imx_lpuart_init_preirq(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + u32 sbr, osr; + u32 ctrl, old_ctrl, bd; + u32 baud; + + ctrl = old_ctrl = imx_lpuart_read(uart, UARTCTRL); + ctrl = (old_ctrl & ~UARTCTRL_M) | UARTCTRL_TE | UARTCTRL_RE; + bd = imx_lpuart_read(uart, UARTBAUD); + baud = uart->baud; + + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC)) + barrier(); + + /* Disable trasmit and receive */ + imx_lpuart_write(uart, UARTCTRL, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE)); + + osr = (bd >> UARTBAUD_OSR_SHIFT) & UARTBAUD_OSR_MASK; + sbr = uart->clock_hz / (baud * (osr + 1)); + + bd &= ~ UARTBAUD_SBR_MASK; + bd |= sbr & UARTBAUD_SBR_MASK; + bd |= UARTBAUD_BOTHEDGE; + bd &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE); + + imx_lpuart_write(uart, UARTMODIR, 0); + imx_lpuart_write(uart, UARTBAUD, bd); + imx_lpuart_write(uart, UARTCTRL, ctrl); +} + +static void __init imx_lpuart_init_postirq(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + unsigned int temp; + + uart->irqaction.handler = imx_lpuart_interrupt; + uart->irqaction.name = "imx_lpuart"; + uart->irqaction.dev_id = port; + + if ( setup_irq(uart->irq, 0, &uart->irqaction) != 0 ) + { + dprintk(XENLOG_ERR, "Failed to allocate imx_lpuart IRQ %d\n", + uart->irq); + return; + } + + /* Enable interrupte */ + temp = imx_lpuart_read(uart, UARTCTRL); + temp |= (UARTCTRL_RIE | UARTCTRL_TIE); + temp |= UARTCTRL_ILIE; + imx_lpuart_write(uart, UARTCTRL, temp); +} + +static void imx_lpuart_suspend(struct serial_port *port) +{ + BUG(); +} + +static void imx_lpuart_resume(struct serial_port *port) +{ + BUG(); +} + +static int imx_lpuart_tx_ready(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + + return (imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC) ? 1 : 0; +} + +static void imx_lpuart_putc(struct serial_port *port, char c) +{ + struct imx_lpuart *uart = port->uart; + + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE)) + barrier(); + + imx_lpuart_write(uart, UARTDATA, c); +} + +static int imx_lpuart_getc(struct serial_port *port, char *pc) +{ + struct imx_lpuart *uart = port->uart; + int ch; + + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_RDRF)) + barrier(); + + ch = imx_lpuart_read(uart, UARTDATA); + *pc = ch & 0xff; + + if (imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_OR) + imx_lpuart_write(uart, UARTSTAT, UARTSTAT_OR); + + return 1; +} + +static int __init imx_lpuart_irq(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + + return ((uart->irq >0) ? uart->irq : -1); +} + +static const struct vuart_info *imx_lpuart_vuart_info(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + + return &uart->vuart; +} + +static void imx_lpuart_start_tx(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + unsigned int temp; + + temp = imx_lpuart_read(uart, UARTSTAT); + /* Wait until empty */ + while (!(temp & UARTSTAT_TDRE)) + barrier(); + + temp = imx_lpuart_read(uart, UARTCTRL); + imx_lpuart_write(uart, UARTCTRL, (temp | UARTCTRL_TIE)); + + return; +} + +static void imx_lpuart_stop_tx(struct serial_port *port) +{ + struct imx_lpuart *uart = port->uart; + unsigned int temp; + + temp = imx_lpuart_read(uart, UARTCTRL); + temp &= ~(UARTCTRL_TIE | UARTCTRL_TCIE); + imx_lpuart_write(uart, UARTCTRL, temp); + + return; +} + +static struct uart_driver __read_mostly imx_lpuart_driver = { + .init_preirq = imx_lpuart_init_preirq, + .init_postirq = imx_lpuart_init_postirq, + .endboot = NULL, + .suspend = imx_lpuart_suspend, + .resume = imx_lpuart_resume, + .tx_ready = imx_lpuart_tx_ready, + .putc = imx_lpuart_putc, + .getc = imx_lpuart_getc, + .irq = imx_lpuart_irq, + .start_tx = imx_lpuart_start_tx, + .stop_tx = imx_lpuart_stop_tx, + .vuart_info = imx_lpuart_vuart_info, +}; + +static int __init imx_lpuart_init(struct dt_device_node *dev, + const void *data) +{ + const char *config = data; + struct imx_lpuart *uart; + u32 clkspec; + int res; + u64 addr, size; + + if ( strcmp(config, "") ) + printk("WARNING: UART configuration is not supported\n"); + + uart = &imx8_com; + + res = dt_property_read_u32(dev, "clock-frequency", &clkspec); + if ( !res ) + { + res = dt_property_read_u32(dev, "assigned-clock-rates", &clkspec); + if ( !res ) + { + printk("imx-uart: Unable to retrieve the clock frequency\n"); + return -EINVAL; + } + } + + uart->clock_hz = clkspec; + uart->baud = 115200; + uart->data_bits = 8; + uart->parity = 0; + uart->stop_bits = 1; + + res = dt_device_get_address(dev, 0, &addr, &size); + if ( res ) + { + printk("imx8-lpuart: Unable to retrieve the base" + " address of the UART\n"); + return res; + } + + res = platform_get_irq(dev, 0); + if ( res < 0 ) + { + printk("imx8-lpuart: Unable to retrieve the IRQ\n"); + return -EINVAL; + } + uart->irq = res; + + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("imx8-lpuart: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off = UARTDATA; + /* tmp from uboot */ + uart->vuart.status_off = UARTSTAT; + uart->vuart.status = UARTSTAT_TDRE; + + /* Register with generic serial driver */ + serial_register_uart(SERHND_DTUART, &imx_lpuart_driver, uart); + + dt_device_set_used_by(dev, DOMID_XEN); + + return 0; +} + +static const struct dt_device_match imx_lpuart_dt_compat[] __initconst = +{ + DT_MATCH_COMPATIBLE("fsl,imx8qm-lpuart"), + {}, +}; + +DT_DEVICE_START(imx_lpuart, "i.MX LPUART", DEVICE_SERIAL) + .dt_match = imx_lpuart_dt_compat, + .init = imx_lpuart_init, +DT_DEVICE_END +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/imx-lpuart.h b/xen/include/xen/imx-lpuart.h new file mode 100644 index 0000000000..945ab1c4fa --- /dev/null +++ b/xen/include/xen/imx-lpuart.h @@ -0,0 +1,64 @@ +/* + * xen/include/asm-arm/imx-lpuart.h + * + * Common constant definition between early printk and the LPUART driver + * + * Peng Fan + * Copyright 2022 NXP + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#ifndef __ASM_ARM_IMX_LPUART_H +#define __ASM_ARM_IMX_LPUART_H + +/* 32-bit register definition */ +#define UARTBAUD (0x10) +#define UARTSTAT (0x14) +#define UARTCTRL (0x18) +#define UARTDATA (0x1C) +#define UARTMATCH (0x20) +#define UARTMODIR (0x24) +#define UARTFIFO (0x28) +#define UARTWATER (0x2c) + +#define UARTSTAT_TDRE (1 << 23) +#define UARTSTAT_TC (1 << 22) +#define UARTSTAT_RDRF (1 << 21) +#define UARTSTAT_OR (1 << 19) + +#define UARTBAUD_OSR_SHIFT (24) +#define UARTBAUD_OSR_MASK (0x1f) +#define UARTBAUD_SBR_MASK (0x1fff) +#define UARTBAUD_BOTHEDGE (0x00020000) +#define UARTBAUD_TDMAE (0x00800000) +#define UARTBAUD_RDMAE (0x00200000) + +#define UARTCTRL_TIE (1 << 23) +#define UARTCTRL_TCIE (1 << 22) +#define UARTCTRL_RIE (1 << 21) +#define UARTCTRL_ILIE (1 << 20) +#define UARTCTRL_TE (1 << 19) +#define UARTCTRL_RE (1 << 18) +#define UARTCTRL_M (1 << 4) + +#define UARTWATER_RXCNT_OFF 24 + +#endif /* __ASM_ARM_IMX_LPUART_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Mon Feb 28 01:07:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12762380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E0B6FC433EF for ; Mon, 28 Feb 2022 05:12:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.280087.477960 (Exim 4.92) (envelope-from ) id 1nOYKd-00056X-26; Mon, 28 Feb 2022 05:12:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 280087.477960; Mon, 28 Feb 2022 05:12:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nOYKc-00055l-SI; Mon, 28 Feb 2022 05:12:22 +0000 Received: by outflank-mailman (input) for mailman id 280087; Mon, 28 Feb 2022 00:27:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nOTsq-0007Sm-O5 for xen-devel@lists.xenproject.org; Mon, 28 Feb 2022 00:27:24 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on062e.outbound.protection.outlook.com [2a01:111:f400:fe0c::62e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 329673d4-982d-11ec-8eba-a37418f5ba1a; Mon, 28 Feb 2022 01:27:23 +0100 (CET) Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DB8PR04MB6460.eurprd04.prod.outlook.com (2603:10a6:10:10f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.25; Mon, 28 Feb 2022 00:27:21 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::552c:ed46:26dc:77cc]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::552c:ed46:26dc:77cc%4]) with mapi id 15.20.4995.018; Mon, 28 Feb 2022 00:27:21 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 329673d4-982d-11ec-8eba-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hSfyKXEm88+iJ7OIfLAfKPjFKy6RT5jXGQrj3rrU4e1e6zsWPs+qo/1lWctfGLczFqStJdiZVAGZmRNYR4SSm1s8XbuGCo8UzfDFL0C+jP9AHRH8UVS9acrR8Pm52Y+Xtpn9+rBWcdP0vJG3Pkgd7EQHZUuWIAe2Ufp0sPRAKh2vcCdCBp5BDolmNVVfluL6uKk/tKleQJTdZyoL6PuB1xwZPzVsHtQztlYplQccPYwBde8E7E41mD/S6JbE3cvKxsQcuD67s1JygD5XqSKI4PWg8NouI1ujmPa5MCbPQ+5JcU/Yq3rwTzPH+MOYDf/+juL5WHabtlj8hw3C1+OJLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HQTF4tiGiA6bqr8wGDrApHkfcsxMIqMshDIrr4CmuTU=; b=Ok9F2B6SgOKau2+gFivh8Nj97bBBDFK1K+TzC/pedVZbh+YfjAoplkZYXQkg09I+X3bgr9eyWCHQFYNZezPHFt1keART70YDQWjDud3ypu8XaA5H5xxLuG5qJU3R8OixD5V47Q8Ua+1zqn7ZcdLevjQrkqSiQb4Oms2Cy6jw47cl7bXFoTnrhZyiJigLYpVgls83dWT5I4o7Q5H+GPFhnFJ17EFoA7gj9wmAVRnfDW9VzlRX9qVtc/3cE6/AXvUAPbilL9uV+7kgaoifHOBeBMbavp5eHs/O8i9RrSvRD7hXV1ltKJaOhlhMaM8fn4O9yH/wzpXlAjPtQtkA7gHB/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HQTF4tiGiA6bqr8wGDrApHkfcsxMIqMshDIrr4CmuTU=; b=mPFwL/knohds/yZ6cjH9EZfWgPMgztle4PWcW/4akid82CmmafCb66jBQUZTAlwikDYvJdBw3xZO3qHNzXEYqI36Fl5KUlC4Vbxt+23YuA1C+JbnBB4r+MmTkJIK4kksKS5js+lKlQBsNVrLr79D4CDy0td336lw/djVXew881o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Peng Fan (OSS)" To: sstabellini@kernel.org, julien@xen.org, Volodymyr_Babchuk@epam.com, bertrand.marquis@arm.com Cc: andrew.cooper3@citrix.com, george.dunlap@citrix.com, jbeulich@suse.com, wl@xen.org, xen-devel@lists.xenproject.org, van.freenix@gmail.com, Peng Fan Subject: [PATCH 2/3] xen/arm: Add i.MX lpuart early printk support Date: Mon, 28 Feb 2022 09:07:10 +0800 Message-Id: <20220228010711.11566-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20220228010711.11566-1-peng.fan@oss.nxp.com> References: <20220228010711.11566-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR02CA0001.apcprd02.prod.outlook.com (2603:1096:4:194::10) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c43f520-0d5a-4339-c7f7-08d9fa5115cc X-MS-TrafficTypeDiagnostic: DB8PR04MB6460:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VJ6oA1A33nHN2+3zo9pJwh5y2Y+PfNAZxMIAlUhF6wmiHrXftDIFkofJprp1nVz+WNAPQ9DlnEM09NuOKnJpFbZ//Pk12lh/LycCskzwTQ94skEcmdYQx9GV80qP25I6YzxSD1x3FlL7A70auw95a+qUH3LJ+58Uim4FHBW4Fk9hyeIKRD16tCCWlpFxF0ubfo+X5qyvBO4vm6clGJkkkJzzsg5ZSzYUb5LkhvgTPOVX8HgRNVG8la/hWeO7bS9TURevvIAKqS5dH3bLxKYcosOHKAm9A8NPcL3UpSblFISwKsQl+cAmI/SsJ0yQGhHxD5A7Q3Xw+6szWi0PQ8u9q8xqz7mVuNXY4GARx49C9nH/K5VOx82vc5o7XJXmdOOwC5oXdb5BwPpGJX07nVPBgRHI/VA3rNu4jahEhyQAUjP/RH0hD9LFSjgykKm5VhhQdHV/8HX2pZ0cYhUE02sR4C0JZYxl8jfFh+hjx8fdcM1ori/SEIfBalfIVkU01jYg53hC9Y/SGUKntN/9h0EGQPWPi1iPhbBRJS17b3cp+t2JRckqShWXiQ1WHZCmtiYFaxPFf5hf383QjS52MSfnzSav/GsO7rNMWUmc6oBX3eLMcR5Y1xIsWUa8HtiOjAFUmnL+gXzZw0T7bM/aKAT6M80/wABaEGHRQ/dcGWyrYqBEOkWYWQZyI0ol/41rQDLUbmogTgkSlyudnXEvUHvBd6yr93pHOotuqK4aMlPmYIY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66946007)(66556008)(66476007)(6512007)(6506007)(6666004)(316002)(4326008)(8676002)(52116002)(2906002)(2616005)(1076003)(86362001)(26005)(186003)(5660300002)(6486002)(38350700002)(38100700002)(8936002)(7416002)(508600001)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ox3s7WlQfZ+VfDVreq/oshTEe6eoZyEWMJ/7hudbrfqrZ1RhIf03X1uOkNhLr3jU2UTYSQMIGmA/vN6RyEjf92I9Xv6LADRUlIQfNILnOzCf9dDEpiKI2+Gz0HAWfZe89GkPE67OaeJQhr1PAFsquIRx99FWp+7wm4TL9d03UE+ubR9/ZY1MD34M+SU1+NtYxGt/ZQMiT7hpM2jDeN1QVczwGd63ApGvDJraxk4dJu8YQ6z3v1xKoAahTwz/BLqmhEk4OSnsXLoGSe9fFByDMGKWaAR7k5fD60zDc7PBi1f3LmdrD8oSqRUeBr/KMQ1lhg1wfIqo2oa7mbA293/MTp+jyiYZXbHj1hmlLMw0tVVVuj9MWunDXFQ/Fubzh85EB8R9pmT+fd6EXYoGlXBUi1JkQFmX7fxL6AB/Bsm0LYfLVCesTCcxTNJMeW6+GdQ9ZcWvTehunVAlnz9AOe8KCexiBbK8w+hUDckZBrPUPqS//hTh+5KOBKV9rk16B9i4SM/UE9Bs8TIu36JsDEFIj1ykCkU+zVuCJenXUbMLS5uFnfJUZtGJZwRr1UaCBnyR7nB+lTn0HTu3Gqk058qnK4BdRB9BSsI9CF+HuXuumzft8hY6PTQm9r4lMQC7sONn+tMs1eMHfhbPm2EdustLU1eZDQdWl3arb39q4PqO9tCGiteuR8evkT0L8pfmO0gxLi6GJB4pBuqugzesxLZQMjwYgF6IhNe1Vxeby2Uz89UXu2DIdNXCyNQcCPVMYzOarGpwVrlKxZVdhIhEH9h/ufZdZvblvUriDOhEvgRTqbiVGzaPkPPz8cRNhRjuXKMwbIDIh8LilXW1FaQg9oM7jeJFDF4A1fz+T1XFb1XtG6zNNDeLXF1vhBlFzgNIHaHgTsej0nHmHqmfV2BgRTePlqRcd1wuLarA4T1YtbyHVwFq29mPmfswfAykh70lUvQlpta5k1HjNAcZFEtju7Ov/9GQr8ASWmgI7V8ulXu4lzTFx9bpFhnDY/7hRV+L+9PEn+faV0fR3kBjwFoz2IdVECHxi9kLG6yKy9A8C+1oHco76G79g1Ic6M2BxBHGqgepqTa2gfNf9EKTQTTmu0J6Wb8QLgt4nqGpc+IA6/wr2f378FGPeREyj/8hVxUcXSByCroi/Vbc8/LXnv2diz2/sUEHjxnNTGk8zO2BWmgfE3JEqsTjU3ih+ba6u/GTlS8VhFz7T9N0276v9Uc0FUqm6SXbH5W0OOt5/Y58U0A4mz0Vj2FYUN4EJmdgquCgtFDIcLWUxhsIrSyCK4IlGC0EZvzhQ6lJsDQmzBhITFFS718Q2404oyNz6wKubXKrGrhSgNtRWeRc97IIbDETCm6DIapcAnnb5kTZKLJkuADE45L2pYEkvEn4f4lJdK3Aju8m2nnzPCr6RniEJ42zAYsqX1NJOZyeABxAFzARX5ksPipfLPQYfcXKvYHBhu6sO7hkwQgTtSMvzPA+QR/WtFV5wCEgmM3AOy2Z2VwlY9XQhR+fy+VV9ScxRlFX6+pXoX7HqxmCr4ustgB9ekxc3Zp3pKAMJdiliP0aUMuPfY9rc4IVg1s7cZI7ab+m2JuRgRztsSrMzxyAr/pPOtrbRnTEFEpZfntLRfRObnEbhbHXu6I= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c43f520-0d5a-4339-c7f7-08d9fa5115cc X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 00:27:21.6403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nQDVnKWb2+ruoBIbLr+n6Kvrranrf1p0OwVzodIRM8BZZe/BTHabB8by4SBJ/8kLJ2rrR6OE+ikFJRRuq0+D5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6460 From: Peng Fan Signed-off-by: Peng Fan --- xen/arch/arm/Kconfig.debug | 18 ++++++++++ xen/arch/arm/arm64/debug-imx-lpuart.inc | 48 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc diff --git a/xen/arch/arm/Kconfig.debug b/xen/arch/arm/Kconfig.debug index 35ccd13273..9ecb446b3a 100644 --- a/xen/arch/arm/Kconfig.debug +++ b/xen/arch/arm/Kconfig.debug @@ -55,6 +55,20 @@ choice selecting one of the platform specific options below if you know the parameters for the port. + This option is preferred over the platform specific + options; the platform specific options are deprecated + and will soon be removed. + config EARLY_UART_CHOICE_IMX_LPUART + select EARLY_UART_IMX_LPUART + depends on ARM_64 + bool "Early printk via i.MX LPUART" + help + Say Y here if you wish the early printk to direct their + output to a i.MX LPUART. You can use this option to + provide the parameters for the i.MX LPUART rather than + selecting one of the platform specific options below if + you know the parameters for the port. + This option is preferred over the platform specific options; the platform specific options are deprecated and will soon be removed. @@ -186,6 +200,9 @@ config EARLY_UART_CADENCE config EARLY_UART_EXYNOS4210 select EARLY_PRINTK bool +config EARLY_UART_IMX_LPUART + select EARLY_PRINTK + bool config EARLY_UART_MESON select EARLY_PRINTK bool @@ -283,6 +300,7 @@ config EARLY_PRINTK_INC default "debug-8250.inc" if EARLY_UART_8250 default "debug-cadence.inc" if EARLY_UART_CADENCE default "debug-exynos4210.inc" if EARLY_UART_EXYNOS4210 + default "debug-imx-lpuart.inc" if EARLY_UART_IMX_LPUART default "debug-meson.inc" if EARLY_UART_MESON default "debug-mvebu.inc" if EARLY_UART_MVEBU default "debug-pl011.inc" if EARLY_UART_PL011 diff --git a/xen/arch/arm/arm64/debug-imx-lpuart.inc b/xen/arch/arm/arm64/debug-imx-lpuart.inc new file mode 100644 index 0000000000..7510210d46 --- /dev/null +++ b/xen/arch/arm/arm64/debug-imx-lpuart.inc @@ -0,0 +1,48 @@ +/* + * xen/arch/arm/arm64/debug-imx8qm.inc + * + * i.MX8QM specific debug code + * + * Peng Fan + * Copyright (C) 2016 Freescale Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#include + +.macro early_uart_init wb wc wd +/* Already initialized in bootloader */ +.endm +/* i.MX8QM wait LPUART to be ready to transmit + * rb: register which contains the UART base address + * rc: scratch register + */ +.macro early_uart_ready xb, c +1: + ldr w\c, [\xb, #UARTSTAT] /* <- Flag register */ + tst w\c, #UARTSTAT_TDRE /* Check FIFO EMPTY bit */ + beq 1b /* Wait for the UART to be ready */ +.endm + +/* i.MX8QM LPUART transmit character + * rb: register which contains the UART base address + * rt: register which contains the character to transmit */ +.macro early_uart_transmit xb, wt + str \wt, [\xb, #UARTDATA] /* -> Data Register */ +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */ From patchwork Mon Feb 28 01:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12762381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6DD5DC433FE for ; Mon, 28 Feb 2022 05:12:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.280090.477966 (Exim 4.92) (envelope-from ) id 1nOYKd-0005C0-D3; Mon, 28 Feb 2022 05:12:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 280090.477966; Mon, 28 Feb 2022 05:12:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nOYKd-0005AI-4v; Mon, 28 Feb 2022 05:12:23 +0000 Received: by outflank-mailman (input) for mailman id 280090; Mon, 28 Feb 2022 00:27:28 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nOTsu-0007Sm-8e for xen-devel@lists.xenproject.org; Mon, 28 Feb 2022 00:27:28 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0615.outbound.protection.outlook.com [2a01:111:f400:fe02::615]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 34ac9e04-982d-11ec-8eba-a37418f5ba1a; Mon, 28 Feb 2022 01:27:27 +0100 (CET) Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DB8PR04MB6460.eurprd04.prod.outlook.com (2603:10a6:10:10f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.25; Mon, 28 Feb 2022 00:27:25 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::552c:ed46:26dc:77cc]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::552c:ed46:26dc:77cc%4]) with mapi id 15.20.4995.018; Mon, 28 Feb 2022 00:27:25 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 34ac9e04-982d-11ec-8eba-a37418f5ba1a ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kCH+/SIbWCm2C9FOwOeomig7vCKzcsAQ6VIhYK2b9zhhrFO3/Bb1PICUl0arGYD/TeLUcW++7gGcVwBiA3Jy/aNnAiCGXHkmhM7qaSY60G6ZwYXTCLaeT3WFGCbJGusBbXm2Wvr8ar6n0ALDWEDatuOnFC6d9qxL+5lVuIk7dZ0xAkliarjaf1RTV5Qi7p+hAJpFa+uhVL433ugjGBYeaMETnWxrKH5RDB/ds9Fh8rf3cVPg0SU0Xjrb8uNRDEnmFhfQBRJEDG6kAE8Jo52aJKSLraQixJALC8KOfuftazcBudH+oQuRzGOZAwimYuP+cQhbt6Mk4OPAZ9Jy+YyPYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FsCR7rC+1KKOTplUp+q9rcVTXAyb/TEnoFHsWncVriA=; b=BgNBqjQlhlmHN9e1DrRznU27RVV0fCMo501/Ww+YjhsahoPpHDTSS/vMpXJk4szKQM0ovjZKBMq2PhBo3gSLwKkswJ8996QhIgX8I17vFD8S3ZlWtytvAz/6HS/4GhcZ7wGKjEZGmHMVtCbY+N8YG0FtSuOLxG3KJBjA/7wVPgH9zb0V+getUq2k90ZrQ/tLOJKNUWcQkrTCXv2/RYpsxEFeF5i2kXSjcZdx1FrUc4cgFYAYDl3CdjdBrPsgBw0Om3/WjFB0BOiBZjGqAedVXx7bLDvEx+70nEeGgMrd5j1jRnhtIQeQb0T3y5T/wXv98n7ALd6BV5Z1uqbg7KFMlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FsCR7rC+1KKOTplUp+q9rcVTXAyb/TEnoFHsWncVriA=; b=d0ENjTqy7lns4aX44kXF+NkZN4Y/zJAiPzv8VGvm7ifS5c5si2zm51gjZpq1nyCgqL/OPt2G7BAxcKvZa3z6m2UeQ579OsGsB+lJJ/YkNNC/mTtXpqWCNwRUd4Hd5nyJRCd+Pu6mhbXqNFRZPmX/zLPWJGH2Aq9hkF4YTSWbsu8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Peng Fan (OSS)" To: sstabellini@kernel.org, julien@xen.org, Volodymyr_Babchuk@epam.com, bertrand.marquis@arm.com Cc: andrew.cooper3@citrix.com, george.dunlap@citrix.com, jbeulich@suse.com, wl@xen.org, xen-devel@lists.xenproject.org, van.freenix@gmail.com, Peng Fan Subject: [PATCH 3/3] xen/arm: Add i.MX8QM platform support Date: Mon, 28 Feb 2022 09:07:11 +0800 Message-Id: <20220228010711.11566-4-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20220228010711.11566-1-peng.fan@oss.nxp.com> References: <20220228010711.11566-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR02CA0001.apcprd02.prod.outlook.com (2603:1096:4:194::10) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e9757529-61b1-49b3-2fae-08d9fa5117f6 X-MS-TrafficTypeDiagnostic: DB8PR04MB6460:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1BJfX+UagmLtDP/RCLcKh+2jO8OfGZU1VG709rjFFd/LEvyG3t5bq6GA3cRRTu+Xv2H3BOdNzBtNN3A/f9LO/Bbkqkfr9aWb+PbC5Itbl9L8hUJDwK5iwp9leHwC5bndsJd3/HYJTHgFl6lGyb0A2HgDujl48AjtZuywbD/V5KWdrzx/D5x1fp9IFJdxAV6sIoMa1zIJeQB3aeQiyy2GU89SFV3ju263ag7TW88nJUuLhLZ5vPwFgUJspe7b8aqChgdSGR7vCK0hXSPZuDLkJyKNMw5n7B4eMZ6GeRDkL1L+lRoK50mdsOyczPqm5arByWpyOqRfe+7T0kk6m6D0rL7UH0aAvGQvBfCYczpCn7veGb1VArZ3UoyOc4BsGC6+k6m0JpbuW/Qyo0uctmU9E2oS/gXUYlesgaq3J8gtKq5FoEeYYsiNw4CC7Qi2boCUE68yuHn8MjBBcXEIxMcSZKOQJEcgMjFBBHgpiNvnP1S1XxmwLWHvNPNuj0l8QaHbVvOgnQ3KENzxLauMz0DMAiWvhzc5YUPN4wFGXAwQwiaJSX5ddxB+qPZBAWrpI3mKqb724l8yzU6IT0B3+67uDZa/kl6H3hJvtVuy5ry85Nhbix9g4kVkTHqUOUyH2OtWJSBZonQx4iLvSkR2aFNPGxbLphHMuX1j5mEk2bju0MrcQYeOnOK1kNQoy4/FSjQZFGzmsVHrf5mcYXpi7uJ0YVjaQMws4zGSeyfw6ujv2sU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66946007)(66556008)(66476007)(6512007)(6506007)(6666004)(316002)(4326008)(8676002)(52116002)(2906002)(2616005)(1076003)(86362001)(26005)(186003)(5660300002)(6486002)(38350700002)(38100700002)(8936002)(7416002)(508600001)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F6pBc2KQYLUxP4OI/Flimarlv14niNUbJG2LAdw+BszRLawgaigdHmcFWADKG+UmCGI3pMH4hfI53lsN15jKvVGf9HeEJLF0jBklGnlMLr8juyESjeOvC1rYI57mEBS8OVuHeBw6etVlz9ivXPOZfkzKKPuOBiIRNWGAruzSl0NbdBBmTgwKx5hoOR7Y+ExHuMWWL3Ws70hGWozsINjWzxs9Vghc1qqVGqTyv0Lv4YdfsrzTrrofu0Tu1YZSgVgKG+CiZCb8z+/zLPRHwQi0NSHQGJw3squfxaBIJWdQPxSAr8aHietJHmqbxdBfNNcZjQ5cvOF7/J6XCjNrINTvtHwH1kAxpzJeNAYm2J1qN78/z/vcxH7gGJvXz2FJy3liODTDLoml21+Z/l6RcGAb/YRb3Np8e287EMxuIqdh3xsEteDf4IREFMkSW+63ZTH4Ue4k1hQiGEjwyKcRnVO8r/0ywTyyEmLtIw4lz+geuqHfD4Vz209T7K0gNeybMKkhVALlCx7J24t4CPYpJGln8Y8fmY0bYj8N8+9RVf4F5WZ4yUjQp5NPDnNonqGy+cDZPdGXsRXD6Pw32wGB23NKnCbwnYM/ND/MoYBuNfIZHOHg0shOdHlYSQcBtb3/p1es4xletNiXburmt2seS9G9Wd/1uuk+4lqZLoJJH+mpnzgt/Otutyi+rwOC0uEXF3lAUgxHjXk/lQ0eqsToFz+6CDKJrXfhxWdtafk+2vC6J5Bek7Vg8lo/hdatpKdosloh2DrcvMmvUx7uINt0rdbPtucyGXoQe3iHBFIxftx0Im10qlaSlgGnx5dgt64rZZmJULNDCVz57evrbn3IWhGyEirxPAF83uiW6dtbDJ7/qiTl7ozL2amcOUVBUaFaDCkGPCcsBUwtrLyGOcLy+zIJFD+Chss+SnZfObr3wiXUtViM36f7Z5pEtFi/aegXP1omR+WHHFYgBQ7qVufUgn0pGaADfdZfumvL2QnQ1DFmywIgEo+sPmHHqnjOwudRkA7JaFvVKyHH4a5m6BaQyO8Knv9NeXAb/qWf5x76uqQbhC2GBPVXytZaBfw33ZZS7Ibj7DqAR/cLWLY0X0vKx2Ae0iuzKuZkzPYTq1zyDkJQBENLq5D+sQNq8/NUDD6wzZh/KTuvon9Tp/l32OInONqD6BR8qhHrPOqnUSv88y1rKKSEIs7itW3lJeqOKzwAoRJMgMBBAdDraHozggiAHbpYFSxClkepyZ3ZEvaFT3kGQnWJ3+nWJ3KQ4f+cDCMe5vZ9dqKh3rz4XJSOGX9VrFZg1DgUqn1kPvtAnC3CWwtmV2gMjcT2lppNpAjZggnfa5iD8fEKLMnROyRQJzvt0R55obIGgB+ULHR7stY/8Qm6a7Q54oh3ku/cqAmDGDpZtmKiKVaEd9NjUiC/RPvxqgn7vr3gbRGv36zECv0/OUvxONXzb5C7FJw/W/G62utHQrDgYlq/h7Ee7zposKXci7ceR69RNz9G8ug+ei9M+xOsuqJW4fg227ImYPOU2+fSzMVHuAepbq7lRSYViqTsuKb3CBbx28yYG3YmLEyMhV0f/GZBPPqVsI3xn1Wuq0kyanf9io6vkGSCF03W/YwuFlQWVSIW4KduX+/ytcZDGP1JRB8= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9757529-61b1-49b3-2fae-08d9fa5117f6 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2022 00:27:25.4065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zk/OkScjFGK3h+yhfESsntwx6yW3qKpMRqT54zyJt38rF6Lk4vHSQnYD7U43n3qj3R081hZhC5kxHD4KuPLhIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6460 From: Peng Fan Signed-off-by: Peng Fan --- xen/arch/arm/Kconfig.debug | 3 +++ xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/imx8qm.c | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 xen/arch/arm/platforms/imx8qm.c diff --git a/xen/arch/arm/Kconfig.debug b/xen/arch/arm/Kconfig.debug index 9ecb446b3a..43ccd8fe62 100644 --- a/xen/arch/arm/Kconfig.debug +++ b/xen/arch/arm/Kconfig.debug @@ -143,6 +143,9 @@ choice config EARLY_PRINTK_HIKEY960 bool "Early printk with pl011 with Hikey 960" select EARLY_UART_PL011 + config EARLY_PRINTK_IMX8QM + bool "Early printk with i.MX LPUART with i.MX8QM" + select EARLY_UART_IMX_LPUART config EARLY_PRINTK_JUNO bool "Early printk with pl011 on Juno platform" select EARLY_UART_PL011 diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makefile index 8632f4115f..bec6e55d1f 100644 --- a/xen/arch/arm/platforms/Makefile +++ b/xen/arch/arm/platforms/Makefile @@ -9,5 +9,6 @@ obj-$(CONFIG_ALL_PLAT) += sunxi.o obj-$(CONFIG_ALL64_PLAT) += thunderx.o obj-$(CONFIG_ALL64_PLAT) += xgene-storm.o obj-$(CONFIG_ALL64_PLAT) += brcm-raspberry-pi.o +obj-$(CONFIG_ALL64_PLAT) += imx8qm.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp-eemi.o diff --git a/xen/arch/arm/platforms/imx8qm.c b/xen/arch/arm/platforms/imx8qm.c new file mode 100644 index 0000000000..289c18e5f9 --- /dev/null +++ b/xen/arch/arm/platforms/imx8qm.c @@ -0,0 +1,44 @@ +/* + * xen/arch/arm/platforms/imx8qm.c + * + * i.MX 8QM setup + * + * Copyright 2022 NXP + * + * Peng Fan + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#include +#include +#include +#include +#include + +static const char * const imx8qm_dt_compat[] __initconst = +{ + "fsl,imx8qm", + NULL +}; + +PLATFORM_START(imx8qm, "i.MX 8") + .compatible = imx8qm_dt_compat, +PLATFORM_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */