From nobody Fri May 17 05:50:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=oss.nxp.com); dmarc=fail(p=none dis=none) header.from=oss.nxp.com ARC-Seal: i=2; a=rsa-sha256; t=1650340734; cv=pass; d=zohomail.com; s=zohoarc; b=Qnu3PWci5qOZ/ghhlueyZ2bJ/cLHnurMt1vx5YYfMQ1YJ1SAj81/bTkvHmONuziNXSvVsZ3F7HdBAQYHXMNUKDb6Tzz97x+6j9vmcE6Qs5HT9MR7HPEvSGPqQwre3h5Fe9Jj8Fn3zUuKRGGZT3hL8msPC9QdZo+Ox6Nu3FYGgHw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650340734; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HB7FHGMy0DRrx8MRkr42iYpWGBdzJjb/gHU7cgqfC0o=; b=Yw4HmWcXQIIsLDGJkPYPEPdd/MKy7t/1CJvO8HdjWRQ+CKh6DFf66lkKb+n/DewI5Ows0SmH9EK7NoIwUXcZ1tx6tFOiloRky85igqE3kwcWPIq4uSboBkRJGuhuL4l2XEuQUOCXVliUGsA9IpS1YJtMjaadjKXQ4yRSoSB5738= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=oss.nxp.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 165034073414937.91490768948677; Mon, 18 Apr 2022 20:58:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.307707.522961 (Exim 4.92) (envelope-from ) id 1ngf0N-0001Oc-Ap; Tue, 19 Apr 2022 03:58:19 +0000 Received: by outflank-mailman (output) from mailman id 307707.522961; Tue, 19 Apr 2022 03:58:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ngf0N-0001OT-62; Tue, 19 Apr 2022 03:58:19 +0000 Received: by outflank-mailman (input) for mailman id 307707; Tue, 19 Apr 2022 03:58:17 +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 1ngf0L-00018p-El for xen-devel@lists.xenproject.org; Tue, 19 Apr 2022 03:58:17 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0601.outbound.protection.outlook.com [2a01:111:f400:fe07::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f0da61bf-bf94-11ec-a405-831a346695d4; Tue, 19 Apr 2022 05:58:16 +0200 (CEST) Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DB6PR0401MB2280.eurprd04.prod.outlook.com (2603:10a6:4:48::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Tue, 19 Apr 2022 03:58:14 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::389f:e6eb:a7a2:61b6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::389f:e6eb:a7a2:61b6%8]) with mapi id 15.20.5164.025; Tue, 19 Apr 2022 03:58:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: f0da61bf-bf94-11ec-a405-831a346695d4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lFiHHvj9ejnuAhU7kyrWgpG2Gc6YMHm3y+EQKikp6L4eI5guNyyxiRhNAoMH6stxuYbRWny5AJDVnzht21iHnN3OEXSh1kIvA1DyCD+Li6eI1hSWw6iypeWT/D0eLthiKbxdoLWUVE05bwKKRIAYQ6CsRfBw86ELycT9i2yUVn9o3DewdoSDm8uhuEHjoQb+/St1N1meCCMa1rB6oefGUmeGgr4OzUQVUMDVfIMLFM0uUuurF7DG0GMATmexDSCvq6M+RRU9gkmd1lefhY3AL89sBz9Mbnoyqouco5mJ7i+/JIgacJhEYLiCG5cyD8AQJLpYq3v2X4FzPDDbaYDWyw== 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=HB7FHGMy0DRrx8MRkr42iYpWGBdzJjb/gHU7cgqfC0o=; b=DXbNpagu9QV+CSPQnyOSxAecxX9LMYjGzaC/17rP3yHy8V1Zh5bMTZjrVTY64yBTbrGmGdopJ8kynHvBslFZt1Cv8GmLK+DBf1DKpvoNnf76POjseCAWSDxXLD9mEC7q86R/uPpixMHBLMpIay7R7YXC34+0auc1Y1tkHnfVa4Rw/Hkt+cOnRKLut9UjXSa3GY5yKRxIzDOiP9UXIG5iwNwShz06fOrlmNkcIr9Xz2AsYWJRorkbya+hZ8e6/d8bvVNsn6Fc2tAi6ACQnQjidJT3Ge0Pq1Ndpe1EB0MDOeyX/X5LK2CmPZlW7h5GQDyx3gdl0ogBN4JgGQ7mB2QWhA== 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=HB7FHGMy0DRrx8MRkr42iYpWGBdzJjb/gHU7cgqfC0o=; b=hZO6dYzW3iZzimY6k4+v/WCutuijtdt5BW8dfN1Chctp6J8kIgqt1YombYOuB/cI5y2JLAU+gPtkFCssoteqhPHwerJYRSPW43KXkh6eizX+Gx+a2BIIMyhBEuTu9ys6RiH++fCtk3c3fDs/9EShePsYMveBrvRA1hPTXsLswpI= 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, michal.orzel@arm.com, Peng Fan , Henry Wang Subject: [PATCH V6 1/2] xen/arm: Add i.MX lpuart driver Date: Tue, 19 Apr 2022 12:39:26 +0800 Message-Id: <20220419043927.23542-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419043927.23542-1-peng.fan@oss.nxp.com> References: <20220419043927.23542-1-peng.fan@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0052.apcprd01.prod.exchangelabs.com (2603:1096:4:193::11) 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: 98db2f6a-6d8e-4a67-7e16-08da21b8d3bd X-MS-TrafficTypeDiagnostic: DB6PR0401MB2280: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: ty4ggYOJ6M+CGyC6f8D9HXVZ6g6Z3FSWIa38b5atzcIUQhYxaNtUGtw6/SmhHFPhc8g3lHcVmWTC1GS36estMcenfIbiRvDTsfSJR9WcFMHs7h/H6fvP4i21aSiZK1FmbcCgIY3hDPi2WRFBSl5TsSD8Mg6LWrS7oGY6z2QhGFLSnwJFy7sVkMcHGjRMx0d6vs+XTL8eWpcTRCUCN3QmESUp1DRSJmTAHv8TjU90EUiK9fcSxphV2Nnhi0mhyIfwiRGs1HiLGwiVDjxbV3MJyzuIzFevObttzNduzbH/cxFO7/ly3CBOHkabnT3c+2IvCC6Q4HjtvSlD85dh7dRz8ZE8ebAGv2GfAy1zxWLxb8Yu2FAg0tQSYIveIU+mMcIbtf8y8uQSKIIuOe/ciPObyHcXIpJF6x7sk/vu4L0kUz193KQAEvhDOS1Fkz5Udz0mD+ooWw6XVEdL0u9oAeGWe0UrQE3UFC9OEtciuS7LjR30HzitS+FoNHx+RDaQ9dHCFxDzfvRda+AqBUwgJAYJeEvcRbRjeNslpvfY7jlvGlq4GsyxiKf9JMil3vZMTmYdaqhPReztof1XYt+dOKC9qqf4lRiCBSiXlV6LsOHXSdm45luIP0egI4LsIJYP9RZ2Xk7GEXhrHiAo9K8gxwmF5wPuPFSfa3pkwHexEbviao0XgabLl2t+XYiHOJ1DNKukYagVfcEwL3ANz3ueDwhe2ZmI3HVIOjnJjQufIR+U+Tmnqhu74rmA+l+0SJaPOVSvnZaWPGKIHeN6ET0kMuNqluTx0z1LgO+JikdU+Z9S5QIcM/Icq5F0wzgj2CDOP2k8 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)(66476007)(66946007)(30864003)(316002)(38100700002)(38350700002)(66556008)(4326008)(8676002)(54906003)(1076003)(2616005)(86362001)(6486002)(966005)(6512007)(508600001)(186003)(26005)(8936002)(5660300002)(7416002)(6506007)(52116002)(6666004)(83380400001)(2906002)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X4fT9t3aA05AbZB55klRlED/0zH0jx4xd8gEnoPUCATQdiz4LkwV3M0fr9g1?= =?us-ascii?Q?nCLmpsO1ejIKv0Z/DeG5wqDPjEFGyGpzyBBxmSDtLSmYO0sObyHlWShbHVnX?= =?us-ascii?Q?SrlsJbORVeIaTuJ+Q5JwLpepi89ii+cMsIReydgdY0vXVFdLt8ZuW5hTw6o4?= =?us-ascii?Q?gGoe9vZQwsrjsH24faVxorpk4dmxTZUYfMm/s0myCy4vziBFbSKDxPG7NN4V?= =?us-ascii?Q?yz3XM3pQiS7D+RoycQ5HaSoNYVGUfGM9fF7O9qs47BNsgQI1q6+fOVfyXo1W?= =?us-ascii?Q?A0ltZaGwbzQplo/8KsyKUmXkkTAFvowD7hWb59itxvYOVcFupsdIjWGPOTCw?= =?us-ascii?Q?uJ8vGuuugRFvvAqv02fQlCjAf26txko4WiFT6JX/Ktf7XDjumHpOOLhq9ub7?= =?us-ascii?Q?kh3ldux332QOqWEKFngjtC6izkjh5a8Cdq22SDOLRbbtyGEWP/g9rIQY/oPU?= =?us-ascii?Q?VzyJ/XHghXOeqae4FJjWHrWkE1fV+r2AZGpbdlvFJskkv0vM9zEfxWNnYqCK?= =?us-ascii?Q?T6q9MqYjyWyVbPDUU6o9AguJg+RQEhkpuyQeMef3JsxMPf1xqGGWDBQjoFWm?= =?us-ascii?Q?FXA/XfmoOSr9wEQt3A3HrVu4ueZvTETHkQybsclrMWH2QGBj8kNg3o7XaVAW?= =?us-ascii?Q?9FSg9h87fnO2ZOHXq/AXLxN7fAmLRIUYftTaQH8cJa4/VZiwKSBzYsxpALBC?= =?us-ascii?Q?c8WqSRvjI8wVelv2OC5u4dHMSbx+Y3Qba+VRREvl1tLskugZQ+y39gZbDVqE?= =?us-ascii?Q?tQP/+QtJulnNDQTnEI2N+Z8pEXN0gfIS+wt9vSfiXOJ3qroDJMDum+go44rM?= =?us-ascii?Q?QBPUImtquepId3v0Hz4BBU7h+peowVYV9H6hGl1/Pltcjb7+Lo+l5K06vL3N?= =?us-ascii?Q?RIoZj/qAiPHughg9lhrsMRZ72COrJR01xaoDdcje6LSNGARkBfq5he1FMjsF?= =?us-ascii?Q?KdEixNRQMe1gkLFBeKUH2zWlDZHg3aYqZfmFIWZQ5f1GwXW+vkT/jsuve2pN?= =?us-ascii?Q?9SL0nBB08TtDG4UZh0gbwZ+oUmFjcKwqCovTEpLluNSqLwOd/hgfY+CNICz7?= =?us-ascii?Q?xBGqaISCZQLqHa4548APf2ZO8qMpd9bUPItzncuGjtybY5mDS+GYHg2jfpFJ?= =?us-ascii?Q?VOV9n+6YLzd0o3f5SXKfVHF9w/afw4c6G9p7YR/9cqOsYYTsVL497XqFVVfs?= =?us-ascii?Q?dWwwikEKB6Yd8+voF+TncUrIdjNRcYSKIupMu91OjbNOGlahZyWJZqwI205Z?= =?us-ascii?Q?7mTxjflQKjnwJ6aFSsrKcFDJNVFxWUhUDahJVil7rwm/4DMJHhiO/GXIBeWE?= =?us-ascii?Q?wIzLfUMbPSQV8XRZXesm0DTbX+hGBurwKzsx3aIOSaAFYDiuXN3e6riE8sPT?= =?us-ascii?Q?WXv2JGcqEJROaaK/OoNWrTNscccNLCXWfvcTXu0h+cdiLsFX0Ha1WQnyAKyU?= =?us-ascii?Q?luXJRBcgjOWO35KzKLF99+AJ7rgaBJYGxt9Xpv7ZhMTOP3C45OPXOdMdRXqd?= =?us-ascii?Q?IqKRidwkO3PLQr0FFvldYHOjcbsMp/Y6yDEPHb2l0oQmSMHeQCNq3jD0Fw4A?= =?us-ascii?Q?ImVzGAdKWBJXQY73exF8LgOsgMf+W4mr+EsgbDUGEzrspgeeeNFGxU1xUaSI?= =?us-ascii?Q?JBiWU2GJXsrGWzdVxvGoWFk/PhRpVMHidOkbtv7um++uoPPlUDSMCExfxYXu?= =?us-ascii?Q?IZgSFLqTNTuY3cw/17PmuAdkeKL02LLrYxpNwacidbGcP/0eLX4Um3u95n6U?= =?us-ascii?Q?croumJrutQ=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98db2f6a-6d8e-4a67-7e16-08da21b8d3bd X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2022 03:58:13.9580 (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: 1d6qE92Wpybxzwe2D+UmCTzsZFHBiplIP9ZAnjYhaGKtK2rCMBOOC7SWgVUXWwFh/eJ32JXxwk4I+jtE5p+Yag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2280 X-ZohoMail-DKIM: pass (identity @NXP1.onmicrosoft.com) X-ZM-MESSAGEID: 1650340735798100001 Content-Type: text/plain; charset="utf-8" From: Peng Fan The i.MX LPUART Documentation: https://www.nxp.com/webapp/Download?colCode=3DIMX8QMIEC Chatper 13.6 Low Power Universal Asynchronous Receiver/ Transmitter (LPUART) Tested-by: Henry Wang Signed-off-by: Peng Fan Reviewed-by: Michal Orzel --- xen/arch/arm/include/asm/imx-lpuart.h | 64 ++++++ xen/drivers/char/Kconfig | 7 + xen/drivers/char/Makefile | 1 + xen/drivers/char/imx-lpuart.c | 275 ++++++++++++++++++++++++++ 4 files changed, 347 insertions(+) create mode 100644 xen/arch/arm/include/asm/imx-lpuart.h create mode 100644 xen/drivers/char/imx-lpuart.c diff --git a/xen/arch/arm/include/asm/imx-lpuart.h b/xen/arch/arm/include/a= sm/imx-lpuart.h new file mode 100644 index 0000000000..fe859045dc --- /dev/null +++ b/xen/arch/arm/include/asm/imx-lpuart.h @@ -0,0 +1,64 @@ +/* + * xen/arch/arm/include/asm/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 BIT(23, UL) +#define UARTSTAT_TC BIT(22, UL) +#define UARTSTAT_RDRF BIT(21, UL) +#define UARTSTAT_OR BIT(19, UL) + +#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 BIT(23, UL) +#define UARTCTRL_TCIE BIT(22, UL) +#define UARTCTRL_RIE BIT(21, UL) +#define UARTCTRL_ILIE BIT(20, UL) +#define UARTCTRL_TE BIT(19, UL) +#define UARTCTRL_RE BIT(18, UL) +#define UARTCTRL_M BIT(4, UL) + +#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: + */ diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig index 2ff5b288e2..e5f7b1d8eb 100644 --- a/xen/drivers/char/Kconfig +++ b/xen/drivers/char/Kconfig @@ -13,6 +13,13 @@ config HAS_CADENCE_UART This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq based board, say Y. =20 +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 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) +=3D mvebu-uart.o obj-$(CONFIG_HAS_OMAP) +=3D omap-uart.o obj-$(CONFIG_HAS_SCIF) +=3D scif-uart.o obj-$(CONFIG_HAS_EHCI) +=3D ehci-dbgp.o +obj-$(CONFIG_HAS_IMX_LPUART) +=3D imx-lpuart.o obj-$(CONFIG_ARM) +=3D arm-uart.o obj-y +=3D serial.o obj-$(CONFIG_XEN_GUEST) +=3D 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..2709136081 --- /dev/null +++ b/xen/drivers/char/imx-lpuart.c @@ -0,0 +1,275 @@ +/* + * 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 + +#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 { + uint32_t baud, clock_hz, data_bits, parity, stop_bits, fifo_size; + uint32_t irq; + char __iomem *regs; + struct irqaction irqaction; + struct vuart_info vuart; +} imx8_com; + +static void imx_lpuart_interrupt(int irq, void *data, + struct cpu_user_regs *regs) +{ + struct serial_port *port =3D data; + struct imx_lpuart *uart =3D port->uart; + uint32_t sts, rxcnt; + + sts =3D imx_lpuart_read(uart, UARTSTAT); + rxcnt =3D imx_lpuart_read(uart, UARTWATER) >> UARTWATER_RXCNT_OFF; + + if ( (sts & UARTSTAT_RDRF) || (rxcnt > 0) ) + serial_rx_interrupt(port, regs); + + if ( sts & UARTSTAT_TDRE ) + 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 =3D port->uart; + uint32_t ctrl, old_ctrl, bd; + + old_ctrl =3D imx_lpuart_read(uart, UARTCTRL); + ctrl =3D (old_ctrl & ~UARTCTRL_M) | UARTCTRL_TE | UARTCTRL_RE; + bd =3D imx_lpuart_read(uart, UARTBAUD); + + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC) ) + cpu_relax(); + + /* Disable transmit and receive */ + imx_lpuart_write(uart, UARTCTRL, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_R= E)); + + /* Reuse firmware baudrate settings, only disable DMA here */ + bd &=3D ~(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 =3D port->uart; + uint32_t temp; + + uart->irqaction.handler =3D imx_lpuart_interrupt; + uart->irqaction.name =3D "imx_lpuart"; + uart->irqaction.dev_id =3D port; + + if ( setup_irq(uart->irq, 0, &uart->irqaction) !=3D 0 ) + { + dprintk(XENLOG_ERR, "Failed to allocate imx_lpuart IRQ %d\n", + uart->irq); + return; + } + + /* Enable interrupts */ + temp =3D imx_lpuart_read(uart, UARTCTRL); + temp |=3D (UARTCTRL_RIE | UARTCTRL_TIE); + temp |=3D 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 =3D port->uart; + + return imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC; +} + +static void imx_lpuart_putc(struct serial_port *port, char c) +{ + struct imx_lpuart *uart =3D port->uart; + + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE) ) + cpu_relax(); + + imx_lpuart_write(uart, UARTDATA, c); +} + +static int imx_lpuart_getc(struct serial_port *port, char *pc) +{ + struct imx_lpuart *uart =3D port->uart; + int ch; + + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_RDRF) ) + return 0; + + ch =3D imx_lpuart_read(uart, UARTDATA); + *pc =3D 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 =3D 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 =3D port->uart; + + return &uart->vuart; +} + +static void imx_lpuart_start_tx(struct serial_port *port) +{ + struct imx_lpuart *uart =3D port->uart; + uint32_t temp; + + /* Wait until empty */ + while ( !(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE) ) + cpu_relax(); + + temp =3D imx_lpuart_read(uart, UARTCTRL); + imx_lpuart_write(uart, UARTCTRL, (temp | UARTCTRL_TIE)); +} + +static void imx_lpuart_stop_tx(struct serial_port *port) +{ + struct imx_lpuart *uart =3D port->uart; + uint32_t temp; + + temp =3D imx_lpuart_read(uart, UARTCTRL); + temp &=3D ~(UARTCTRL_TIE | UARTCTRL_TCIE); + imx_lpuart_write(uart, UARTCTRL, temp); +} + +static struct uart_driver __read_mostly imx_lpuart_driver =3D { + .init_preirq =3D imx_lpuart_init_preirq, + .init_postirq =3D imx_lpuart_init_postirq, + .endboot =3D NULL, + .suspend =3D imx_lpuart_suspend, + .resume =3D imx_lpuart_resume, + .tx_ready =3D imx_lpuart_tx_ready, + .putc =3D imx_lpuart_putc, + .getc =3D imx_lpuart_getc, + .irq =3D imx_lpuart_irq, + .start_tx =3D imx_lpuart_start_tx, + .stop_tx =3D imx_lpuart_stop_tx, + .vuart_info =3D imx_lpuart_vuart_info, +}; + +static int __init imx_lpuart_init(struct dt_device_node *dev, + const void *data) +{ + const char *config =3D data; + struct imx_lpuart *uart; + int res; + u64 addr, size; + + if ( strcmp(config, "") ) + printk("WARNING: UART configuration is not supported\n"); + + uart =3D &imx8_com; + + uart->baud =3D 115200; + uart->data_bits =3D 8; + uart->parity =3D 0; + uart->stop_bits =3D 1; + + res =3D 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 =3D platform_get_irq(dev, 0); + if ( res < 0 ) + { + printk("imx8-lpuart: Unable to retrieve the IRQ\n"); + return -EINVAL; + } + uart->irq =3D res; + + uart->regs =3D ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("imx8-lpuart: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->vuart.base_addr =3D addr; + uart->vuart.size =3D size; + uart->vuart.data_off =3D UARTDATA; + /* tmp from uboot */ + uart->vuart.status_off =3D UARTSTAT; + uart->vuart.status =3D 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 =3D +{ + DT_MATCH_COMPATIBLE("fsl,imx8qm-lpuart"), + { /* sentinel */ }, +}; + +DT_DEVICE_START(imx_lpuart, "i.MX LPUART", DEVICE_SERIAL) + .dt_match =3D imx_lpuart_dt_compat, + .init =3D imx_lpuart_init, +DT_DEVICE_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.35.1 From nobody Fri May 17 05:50:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=oss.nxp.com); dmarc=fail(p=none dis=none) header.from=oss.nxp.com ARC-Seal: i=2; a=rsa-sha256; t=1650340730; cv=pass; d=zohomail.com; s=zohoarc; b=hoelgNgCcgJhd5LvCnM/Ejws1IT0osCEZXNgFQkO7WmxZ1MYZ10fof/cC9Y5VxKmwk03KDuYRsI9Pn1eGbNy2CQrTYliw0uYDLcTniTEQ/+FLd6BABXZhfRLBB4PjKV9v3z0kGaF6TzV3PcSGV0bscTcK71hUQ6kp3V4HH0cAI8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650340730; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1QqFMtw5JqTtw6Jd6dkBHTwFJGE0lWl5lR8Rfrbsrcs=; b=SBnQelIb44zOB4lvmECNWEC6CAkdbDUYSbyPb1Sbs8IW/v6k1DXr2FjXn1/pVNrsMXokiC5/du95ZuxpBUdf14ufnGsJdzoAOps0dMrKV9QjyJL5C4Ocoj0GTjplZYNApytanzOBIazNPcLNeWZ4friO1zYkGoSJ+7CYxTTd7gA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=oss.nxp.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1650340730198303.51342979739445; Mon, 18 Apr 2022 20:58:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.307708.522972 (Exim 4.92) (envelope-from ) id 1ngf0S-0001iY-MF; Tue, 19 Apr 2022 03:58:24 +0000 Received: by outflank-mailman (output) from mailman id 307708.522972; Tue, 19 Apr 2022 03:58:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ngf0S-0001iP-IV; Tue, 19 Apr 2022 03:58:24 +0000 Received: by outflank-mailman (input) for mailman id 307708; Tue, 19 Apr 2022 03:58:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ngf0R-0001gE-Bl for xen-devel@lists.xenproject.org; Tue, 19 Apr 2022 03:58:23 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0612.outbound.protection.outlook.com [2a01:111:f400:fe07::612]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f32f76e3-bf94-11ec-8fbe-03012f2f19d4; Tue, 19 Apr 2022 05:58:20 +0200 (CEST) Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DB6PR0401MB2280.eurprd04.prod.outlook.com (2603:10a6:4:48::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Tue, 19 Apr 2022 03:58:17 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::389f:e6eb:a7a2:61b6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::389f:e6eb:a7a2:61b6%8]) with mapi id 15.20.5164.025; Tue, 19 Apr 2022 03:58:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: f32f76e3-bf94-11ec-8fbe-03012f2f19d4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NokNkjQgXjeU0q4+ieTn2/tYXsOVscHqhLIkkc8DnMTivIhHd/GdlT4Ik5jUS+A/sSRnKM8iXhXWn44ihoaxD8MZc8VJqs1mrCceWF2EUMA7W5/rcV2TzZ0Uf6IXZ2yKbHi3BjPvGWvfWOV78dCJij8PQk/IM7qp/STV0CEQg+K+KJ1T3NcApCZNayuVfv3AHK5PiS2h3hzvcTOYJCBmY7gO1gznSVeecQQa04/y71fNulC03V0KBMNHVF+Z8HcEn+UTmElWeLDs5kkjJR4LxVQ3W8QNP4h1CmdcDrG6J4ojDVNH2epp4KQJq2URXzA9QQ9BKXqs4RIYIbOmJ7EmIQ== 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=1QqFMtw5JqTtw6Jd6dkBHTwFJGE0lWl5lR8Rfrbsrcs=; b=aDD18Rg8nFeSZ3UyhM/y+RA7ttSFruXJYwXWxnZtWpIJSBkJAi+cq+Y8HL3a84kBN3Qm7yF+zAACbg8QGpNPJFvHvzujuOwyxNH00MHFIkBhwTpOjkmR2icFwZqhETg9eEQ648ZPizkIsRzFTCjwHBrla6kNkQ2L8VOOkbmnZAvnVET1lDSl7YCiaOuwFMWZjD8Oab/M3hYH7OnH4kMfkPOR5kx8o2H8Zfhdjsc379Axv/OZ8W9LjK41/7O/rI+2DZw3bTuNzdiMnJ9X5Xem0I6v7Ft4aoEMkf7gIMFJ9hjJLykKBadewG0NsZJklBofgENoNWU/VU3TOrt6aqsXlg== 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=1QqFMtw5JqTtw6Jd6dkBHTwFJGE0lWl5lR8Rfrbsrcs=; b=UhhbzYelBYXvXpWMcKkr93zuRqaygNKCYL3hW/Pe5RbhoUPMeG2lfXbdfWS5qz5fewe7nqj7TvMwAXKXtlFM/kZM8bRdN2hoR/OSB0jn+3nGrlU4oQqtOeWtmqdPRcLLfhUgedEC4rbV8DKXHQxp+jaqdnrr9JyoBu+vJPQ8RXk= 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, michal.orzel@arm.com, Peng Fan Subject: [PATCH V6 2/2] xen/arm: Add i.MX lpuart early printk support Date: Tue, 19 Apr 2022 12:39:27 +0800 Message-Id: <20220419043927.23542-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419043927.23542-1-peng.fan@oss.nxp.com> References: <20220419043927.23542-1-peng.fan@oss.nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0052.apcprd01.prod.exchangelabs.com (2603:1096:4:193::11) 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: a50d6403-c86f-4e33-dccc-08da21b8d624 X-MS-TrafficTypeDiagnostic: DB6PR0401MB2280: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: EmWWVXJfKTOfceRLFZ2s2G7Y1P2LFh/hAvODm5fiNH3gggDVWySMJMNTBbiyP+8XC19AzwG8uFmGieN7svG02Y7/t/r+Af1ffPaAYyewlTjBRYkEUCM/p14Rm5GxK9ttJAYlLogcgq/fH22hPGHibZQ5X46vpd+2z6SKBnClNfeAf+BJRhgzho12f8ilVfBYjanVRRiFJhPHooSn1ZRb/xtANv3OQutcHhi7WuHsT0S6A3daMdANFqDoAwB3zagclFYlK4d42jHXjPNdRxmML7cKN7PEwFZx4hOp9VgLBLDpjBosU/u9QtftPhczAUh9L1Lh0FOrgCyKuq2xQA6cig8pE9Rd7hoxuvXTNuCTYFwgtk8Qq40qSY1FX6uuXANqtb8B+k4BI0DFWSHkQ3GCBumY697mFPMlf/MfSVEpISVGDnmlMU+c16GlHdZS2qzv5uqYu2R7+XBAkHtKxM/AZig/VAEPw7TAhZq8hpbvBmMVDldmlUs9F8ILTljFYp5KERaB3hbCntMyZ+HjEuCmrFJcwXN3SDAijYXwBkyccOMcLfd9VDBC3SSyFzSFRk85f+eCR7M0vCVMlJor2eet0GxwZsmrA/LWBGGiD5VIjC/2lXuyQeTkCjcBV2EreXCzADWOl3g1O6jL6TqsEcyfC5nYxd4D6N6y5NNgXezKKHZS918q9gmVolLD4RvEgDG12s3BSKkI2u2lnOqywaEC3r08sEnA55MsxR7J9KlSJ2M= 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)(66476007)(66946007)(316002)(38100700002)(38350700002)(66556008)(4326008)(8676002)(1076003)(2616005)(86362001)(6486002)(6512007)(508600001)(186003)(26005)(8936002)(5660300002)(7416002)(6506007)(52116002)(6666004)(2906002)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cFfs4C0rjaAXJdhbVcZIfKu/WwtfYAFfaQzgGIHYQHKQKgtuaPhe7VAvcl/4?= =?us-ascii?Q?9GF2S0QjC2XVZavfdyBGldZ2dr3Sr845Pow8PrE0uxIeZh8Wvs+24yqpRFoN?= =?us-ascii?Q?L5ckKdMEjW57mhQFVo0nvDzaCVViR2tcTLpps9U4nkHwoevgCrs7eYnrcsCA?= =?us-ascii?Q?NUrjTrEdw2HFe6ptkmMsqqTbcpn37zfKsmKnBZAQbC8Ze1o12tLVBUhxElNH?= =?us-ascii?Q?W8qdRYxJb2kHmYTJDllTJQWTAWKrFqdor1tIPTKdPcDI8bVz1Y+YdmnRJEeb?= =?us-ascii?Q?4UfSMOuYMn+wJmLRB/EceZdRHT3SjzkoFSHfSWWVcmvZiJHI/65wJIAYpGpY?= =?us-ascii?Q?rwTEVsYWwx+t4e6qysLJd9aYgrfPMv8FqtK7chDECy8ifmAMMHqzrpNrijrI?= =?us-ascii?Q?7zyKdsfUtQduhBInw2WlmQcPdIraERxNZelV0/G7bo4uTSUFMwJ3YlSoxpev?= =?us-ascii?Q?VU8BlLdqRr/STHZ8W23HtriAmwydT2+Z1xFBmhJAXA92JZ5z1zhNVIXu6WG4?= =?us-ascii?Q?CdEyeTb3wdq21Lnzv532KJvjPhdTCO2zJR8At+PLNoHcxceb3Nqg17D3TRqe?= =?us-ascii?Q?ct6C1/gx+UZLtswfLF9ZQNd4go1TDnzZkg24Pz7/HKBgNzWG6TSg7qF3e+mb?= =?us-ascii?Q?Mo4AnccZR+Au7os20uksUMwRx+F/1FxkkBQwYBDEu+HY2A21ocToN1LcHtP/?= =?us-ascii?Q?xS+/FaScFlb4AZZ6/xqKKn4GVBwhIyMDDorqsxQlc2Jxd/f230C5H+F+3o9S?= =?us-ascii?Q?BjoBreWZ5E94R2ryXWIpZHDdFUaP0H8p7jbURRc9VLcXET7eSvBzKa02jUUR?= =?us-ascii?Q?XfdcRmKQTuY/tnSayRZjgxy4AlmJPNam86V2agq6siZfCmezT0YMmlIqADNl?= =?us-ascii?Q?KIp75m18YiYelC24i3JUSDLPbuGkpFig2inMqu7W78A2oC+Ul/+69WtPq9Ew?= =?us-ascii?Q?dq3YuyExr2CtLSG7nJLbbJN8BUODofHXmTp4HZLATQyxo7dHVb2q9FWrqycm?= =?us-ascii?Q?D5Ib3MWp8IhFTqjcz7FMdAIJuE8YCTPLYdtx182AX1qbEFjNZAibbwzrEyrz?= =?us-ascii?Q?ADXmcfIBaS3g+yNfcXXH15vVz85OMCnEHO5586sti1jpS45sidG3a8qztMu4?= =?us-ascii?Q?756gDwJ6Lr41S81jyGA0/wpJgM+qjQRDhEz8KCRVlkx09UXCg4NE4DfIpG0c?= =?us-ascii?Q?A6CYlzS34wGgZvwQAPNUOvj5PXhg5C0d/opX7Gh5v/SIOvyXCOwzlLEixPem?= =?us-ascii?Q?n4TW7CYfHZ3H6CninpvjB3k3AUlKgCRFPqNjm9DXIoxC7pbSOOONn0ueJ3Jf?= =?us-ascii?Q?dgixTw30MHeSH2rcEAdIC5i21zJ2e8wF/xQ6dXNIWvgO/ZrEdZ1BCLKTKZvE?= =?us-ascii?Q?1MlAiwcL35YFVTcX8y+NtnNpwRGa1aDBazXuyeFI8IKzBnumwvjGXio/py0a?= =?us-ascii?Q?KJStVk2OCT//K1weDse5p6ksixbC0RQOaDicp3MkR8YBuV4kTQebNPbJF+Gv?= =?us-ascii?Q?L79owxCZyBlYKXEEcoY1Qb/sXLHrEds6M0ifxEa7L6+F6VFrcYnEyWGZfoaS?= =?us-ascii?Q?9+GO2KFs4ybdytFcCXsRSXvRhp/YQQSeBqlM6/lSU9gu+Mtu7eG67dt6nybw?= =?us-ascii?Q?zHkuC9ULAGhvmjKrJwtenpEtEmjvX/Q8tl869wkgv2p7ktOvBcKBy/EgDyVR?= =?us-ascii?Q?/VkOC71Bgao3ChqhoGdwxKej5mwIhUz8Vkf5rGjw5NQLepT7uMkgurYN0m4X?= =?us-ascii?Q?v4UaH3rpLA=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a50d6403-c86f-4e33-dccc-08da21b8d624 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2022 03:58:17.8805 (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: MSsgpO+r5e5W6DLtFyj8O7aU3k+CA1EPn858AOoVbKu5rl+at+oQXjJgPgmXa9bQJl2KjasrIpIXNt8AavM6Jw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2280 X-ZohoMail-DKIM: pass (identity @NXP1.onmicrosoft.com) X-ZM-MESSAGEID: 1650340732549100003 Content-Type: text/plain; charset="utf-8" From: Peng Fan Signed-off-by: Peng Fan Reviewed-by: Michal Orzel --- xen/arch/arm/Kconfig.debug | 14 ++++++++ xen/arch/arm/arm64/debug-imx-lpuart.inc | 48 +++++++++++++++++++++++++ 2 files changed, 62 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..842d768280 100644 --- a/xen/arch/arm/Kconfig.debug +++ b/xen/arch/arm/Kconfig.debug @@ -58,6 +58,16 @@ choice 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. config EARLY_UART_CHOICE_MESON select EARLY_UART_MESON depends on ARM_64 @@ -186,6 +196,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 +296,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/d= ebug-imx-lpuart.inc new file mode 100644 index 0000000000..b169332932 --- /dev/null +++ b/xen/arch/arm/arm64/debug-imx-lpuart.inc @@ -0,0 +1,48 @@ +/* + * xen/arch/arm/arm64/debug-imx-lpuart.inc + * + * i.MX8QM specific debug code + * + * 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 + +/* + * 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 + +/* + * 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: + */ --=20 2.35.1