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 18FA5C5DF70 for ; Tue, 18 Aug 2026 07:21:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1393532.1632352 (Exim 4.92) (envelope-from ) id 1wwE8L-0003y2-Rx; Tue, 18 Aug 2026 07:21:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1393532.1632352; Tue, 18 Aug 2026 07:21:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwE8L-0003xv-OQ; Tue, 18 Aug 2026 07:21:17 +0000 Received: by outflank-mailman (input) for mailman id 1393532; Tue, 18 Aug 2026 07:21:16 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwE8K-0003xn-MH for xen-devel@lists.xenproject.org; Tue, 18 Aug 2026 07:21:16 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wwE8K-005p6h-2n for xen-devel@lists.xenproject.org; Tue, 18 Aug 2026 09:21:16 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a8407e8-2eae-0a2a0a5409dd-0a2a450c81e2-6 for ; Tue, 18 Aug 2026 09:21:15 +0200 Received: from [52.101.56.2] (helo=BN1PR04CU002.outbound.protection.outlook.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a8407ea-f479-0a2a450c0019-34653802f479-4 for ; Tue, 18 Aug 2026 09:21:15 +0200 Received: from BYAPR21CA0003.namprd21.prod.outlook.com (2603:10b6:a03:114::13) by SJ0PR12MB7474.namprd12.prod.outlook.com (2603:10b6:a03:48d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.17; Tue, 18 Aug 2026 07:21:10 +0000 Received: from SJ5PEPF00000205.namprd05.prod.outlook.com (2603:10b6:a03:114:cafe::34) by BYAPR21CA0003.outlook.office365.com (2603:10b6:a03:114::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.0 via Frontend Transport; Tue, 18 Aug 2026 07:21:10 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SJ5PEPF00000205.mail.protection.outlook.com (10.167.244.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.339.3 via Frontend Transport; Tue, 18 Aug 2026 07:21:10 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 18 Aug 2026 02:13:33 -0500 Received: from [10.71.196.80] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.45 via Frontend Transport; Tue, 18 Aug 2026 02:13:32 -0500 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kw96ApVzONTO671Id+xEGKBifjG7Tc7P+Jf+m57NUe68vXILIFmZCzomaN1eGCDkorm5UwhEO3170JZofSl8cU1efob4/hD9ybGyF3s65XNeejP1qCtc9ci3tnwVyXWUevgXlTdHP97TpDTwUZ1xutyyP/hhib+QnJBPhBrn4GA1+aZP7PNjSoWZUX7Q/VlhbdUE/snuo5zWzcls/DAbDDjDRB9UPwwDZl3NlAHspbzlT5FWdtRReUiTO/8hh7sRp7jbbPkf+7Y2LyDROA1468WiuyVarqShkyHI7SBYEZxFaQvuDtSu7E7KNLKK/IIyyWmCTAx7PCALFu3hqT7FuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2VKtktAghtvAyfShnMl7Gov2iTCHFu/RnL+YdTnPlnU=; b=Mg/ivKU+nqV7Gg7A86W1Q7TcaWTu9EpFlJFvyECB26UwLBvJKGTuejzhLHCoSRgS31JW6eeZFStrUJOk6U+tRMi1DEvPAOseVPeNB0WyxB6++mMBHPpu3YRf/9nuIVnGbII26LAeKZffkrsfCvyaFEE4F9jj9W4Y/6NuwZbzHUWCMaKaF4AS9spzmVnI/0EoKPs8C+YttmrhjM85VdFkMsu9lo0Px1IAWRIHJSxXpEOHL5+QTBhTLQ4xZ8fdafZYEmX2d6EX2w7gGNBPZUkRY+ogDjNBjn3XZn7An+Arafi9Xxou4bPJGocz/60Vm4ckNGmpZ1f/iTV0xywq+MbUKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2VKtktAghtvAyfShnMl7Gov2iTCHFu/RnL+YdTnPlnU=; b=ZjGMpiO3L39QWBjbj/zAOCtfs1SH6WQ2as2WzbnrWSlkV9/0uuL+mlHzu1otypBrqRk4FHMLs5ntNXhmueROq9wLf1dVHfkdG8Gg/9dulb80AaHsfAlLVIm9/+WHnJGavhRZzsGiLKu+OqSeFmZHVVvpKBIsdVLdXgeshn3GMRA= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Message-ID: Date: Tue, 18 Aug 2026 09:13:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] xen/char: add classic i.MX UART driver To: Wig Cheng , CC: Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , John Ernberg , Peng Fan References: <20260818025224.4165503-1-onlywig@gmail.com> <20260818025224.4165503-2-onlywig@gmail.com> From: "Orzel, Michal" Content-Language: en-US In-Reply-To: <20260818025224.4165503-2-onlywig@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF00000205:EE_|SJ0PR12MB7474:EE_ X-MS-Office365-Filtering-Correlation-Id: 5acf8983-8bda-4161-c6c3-08defcf94717 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|376014|82310400026|1800799024|10067099003|56012099006|6133799003|18002099003|22082099003|4143699003|11063799006; X-Microsoft-Antispam-Message-Info: 9C2g9/r3PdMY0K0jF6AeDXwXAa8/wbWMWYsLVohFznr+9Mk0eaW/Sjz5+Yav/B8d74OI4wN9G/hVA5fHRKnzutJwXVHONJNzCv3y7fTgNVxKhoympWExFp5DyRSXwAToGKzkraKvtIFundOB31nSR4uAfM77hDh8EZKGYZTBe1nJlnYGRRvISD/RVvCTJj17Y6mPbL9DAQEePU2CcC69PGZ05GVe/MVqKCteDOX/mXAQVZ2cvSXG84CzJMwgBpPL5GMe5eakmz6a/Yubr8rfhmZDd9dKoR1KFUi2+4KU8yqRPCEGDo9LxKKWVOZcdVs+rtCmq8l/+m7VfJ8DGmAcfPka9F1YeMBmnqOVp9lmmdmSZMwEQ59DuksNXeORcALUh9VjKBL/VOtzkmy3zlk9b5MbFJsEpL5AsJ4aKZSVlD96yRLFaqXdC7gD+M6y2LOxh0oSX+OOtaqUhkGl+ngBXWki3zzzSLFAlfZrSqtTgJI0eCXMIgyD4A9iAA51hLYavqb2hX/KDr1qsLjVY59fGNA4R/dKI0K9pnlvqKLXx8piqDwfKBVcf6VgqLYtuEZbUCcijq0NByLn5b+aGhHqflBJXD6vWKyVgi8bo2kW0awHkMtkSJkbu2MtWwJcSceYvjKNnZECyEPFPZj2npwTu34muhzJLrPu6AN2IgE8+7z8S5lmhrPBwXFQb5n5uFLidF29yObaRlzz2S0p8I9PxA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(376014)(82310400026)(1800799024)(10067099003)(56012099006)(6133799003)(18002099003)(22082099003)(4143699003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: buPFfLZsT8NvQh/QnoTaFjdcRuA/RgzPeYQxE3NMDBkxL7e8XPccF7YCjv9BU7sbwqU4AxNRdZdhAwbryzbGjpjozXYLJk5l96dSHcr5T0MA/x5X6dCfzUK84iiXAmjRHkveNm0ucTud9lXcNUmJ6nRvaQErzqWkoNQIOx/bmW8CfDvG2OxB2G0gWzOVLLpYWyvORcrxN5etlkH7opwbtPolBoRLqwwOo/h0M1SJhdJ/DQ0sG0tgg30ufLR3Qdkgq3B/dKN4lDVpzrD45crvSvbG6E8OPGEblB0nQG4FdInwZupUKgf/wdIsfnNVZkdVqPHP4/gJSOcyaInjqmE+sYSFKSs5vyznmXtFkxIPVXFO6hmVvIeCXWI9RSywObF0WoSHPLufcKOwztAvXepC0Pdoy/n0+br9zLsrB9wselPl+Drqs70xGx0D7c/a37G+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2026 07:21:10.1122 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5acf8983-8bda-4161-c6c3-08defcf94717 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF00000205.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7474 X-purgate-ID: tlsNG-d25034/1787037675-772D8A5B-AC374120/0/0 X-purgate-type: clean X-purgate-size: 7568 On 18-Aug-26 04:52, Wig Cheng wrote: > Add a console driver for the classic i.MX UART IP ("fsl,imx6q-uart" > compatible), used as the console UART on the i.MX8M family. Baudrate > and pin configuration are inherited from the bootloader; the driver > only enables the transmitter/receiver and wires up the RX/TX > interrupts, mirroring the existing imx-lpuart driver. > > The i.MX8M family's UART IP differs from the LPUART used on > i.MX8QM/8QXP, so a separate driver is needed. > > Signed-off-by: Wig Cheng > --- > xen/arch/arm/include/asm/imx-uart.h | 57 +++++++ > xen/drivers/char/Kconfig | 8 + > xen/drivers/char/Makefile | 1 + > xen/drivers/char/imx-uart.c | 226 ++++++++++++++++++++++++++++ You should add an entry to the MAINTAINERS file for imx-uart.c so that it falls down under ARM maintainership. Your last patch makes you a reviewer but we still need to be maintainers of it. See how it was done for IMX8QM. > 4 files changed, 292 insertions(+) > create mode 100644 xen/arch/arm/include/asm/imx-uart.h > create mode 100644 xen/drivers/char/imx-uart.c > > diff --git a/xen/arch/arm/include/asm/imx-uart.h b/xen/arch/arm/include/asm/imx-uart.h > new file mode 100644 > index 0000000000..a3892020e6 > --- /dev/null > +++ b/xen/arch/arm/include/asm/imx-uart.h > @@ -0,0 +1,57 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Register definitions for the classic i.MX UART IP > + * ("fsl,imx6q-uart" compatible), used as the console UART on the > + * i.MX8M family. > + * > + * Register layout taken from Linux drivers/tty/serial/imx.c. > + * > + * Copyright 2026 Open-EP (E-Paper) Community > + */ > + > +#ifndef ASM_IMX_UART_H > +#define ASM_IMX_UART_H > + > +#include > + > +#define URXD0 0x00 /* Receiver Register */ > +#define URTX0 0x40 /* Transmitter Register */ > +#define UCR1 0x80 /* Control Register 1 */ > +#define UCR2 0x84 /* Control Register 2 */ > +#define USR1 0x94 /* Status Register 1 */ > +#define USR2 0x98 /* Status Register 2 */ > +#define UTS 0xb4 /* Test Register */ > + > +#define URXD_RX_DATA 0xff > + > +#define UCR1_UARTEN BIT(0, U) /* UART enable */ > +#define UCR1_ATDMAEN BIT(2, U) /* Aging DMA timer enable */ > +#define UCR1_TXDMAEN BIT(3, U) /* Transmitter ready DMA enable */ > +#define UCR1_TXMPTYEN BIT(6, U) /* Transmitter empty interrupt enable */ > +#define UCR1_RXDMAEN BIT(8, U) /* Receiver ready DMA enable */ > +#define UCR1_RRDYEN BIT(9, U) /* Receiver ready interrupt enable */ > +#define UCR1_TRDYEN BIT(13, U) /* Transmitter ready interrupt enable */ > + > +#define UCR2_SRST BIT(0, U) /* 0 = issue software reset */ > +#define UCR2_RXEN BIT(1, U) /* Receiver enable */ > +#define UCR2_TXEN BIT(2, U) /* Transmitter enable */ > + > +#define USR1_TRDY BIT(13, U) /* Transmitter ready */ > + > +#define USR2_RDR BIT(0, U) /* Receive data ready */ > +#define USR2_ORE BIT(1, U) /* Overrun error */ > + > +#define UTS_TXFULL BIT(4, U) /* TX FIFO full */ > +#define UTS_RXEMPTY BIT(5, U) /* RX FIFO empty */ > +#define UTS_TXEMPTY BIT(6, U) /* TX FIFO empty */ > + > +#endif /* ASM_IMX_UART_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 8e49a52c73..f237c0220d 100644 > --- a/xen/drivers/char/Kconfig > +++ b/xen/drivers/char/Kconfig > @@ -30,6 +30,14 @@ config HAS_IMX_LPUART > help > This selects the i.MX LPUART. If you have i.MX8QM based board, say Y. > > +config HAS_IMX_UART > + bool "i.MX UART driver" > + default y > + depends on ARM_64 > + help > + This selects the classic i.MX UART. If you have an i.MX8M family > + 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 8cbbffdca8..039f566926 100644 > --- a/xen/drivers/char/Makefile > +++ b/xen/drivers/char/Makefile > @@ -10,6 +10,7 @@ obj-$(CONFIG_HAS_SCIF) += scif-uart.o > obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o > obj-$(CONFIG_XHCI) += xhci-dbc.o > obj-$(CONFIG_HAS_IMX_LPUART) += imx-lpuart.o > +obj-$(CONFIG_HAS_IMX_UART) += imx-uart.o > obj-$(CONFIG_HAS_LINFLEX) += linflex-uart.o > obj-$(CONFIG_GENERIC_UART_INIT) += uart-init.o > obj-y += serial.o > diff --git a/xen/drivers/char/imx-uart.c b/xen/drivers/char/imx-uart.c > new file mode 100644 > index 0000000000..fd34b0cd11 > --- /dev/null > +++ b/xen/drivers/char/imx-uart.c > @@ -0,0 +1,226 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Driver for the classic i.MX UART IP ("fsl,imx6q-uart"), used as the > + * console UART on the i.MX8M family (e.g. i.MX8MP). > + * > + * Baudrate and pin configuration are inherited from the bootloader. > + * > + * Copyright 2026 Open-EP (E-Paper) Community > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define imx_uart_read(uart, off) readl((uart)->regs + (off)) > +#define imx_uart_write(uart, off, val) writel((val), (uart)->regs + (off)) > + > +static struct imx_uart { > + uint32_t irq; > + char __iomem *regs; > + struct irqaction irqaction; > + struct vuart_info vuart; > +} imx8m_com; > + > +static void imx_uart_interrupt(int irq, void *data) > +{ > + struct serial_port *port = data; > + struct imx_uart *uart = port->uart; > + > + if ( imx_uart_read(uart, USR2) & USR2_RDR ) > + serial_rx_interrupt(port); > + > + if ( imx_uart_read(uart, USR1) & USR1_TRDY ) Looking at Linux's imx.c you should clear TRDY if TRDEN is not enabled to prevent RX interrupt entering serial_tx_interrupt as TRDY is a raw status register. > + serial_tx_interrupt(port); > +} > + > +static void __init imx_uart_init_preirq(struct serial_port *port) > +{ > + struct imx_uart *uart = port->uart; > + uint32_t ucr1, ucr2; > + > + /* > + * Reuse the bootloader settings; only enable the UART and both > + * directions. The console uses UCR1 interrupts (RRDYEN/TRDYEN) > + * exclusively, so just clear UCR1's interrupt and DMA enables. > + */ > + ucr1 = imx_uart_read(uart, UCR1); > + ucr1 &= ~(UCR1_RRDYEN | UCR1_TRDYEN | UCR1_TXMPTYEN | UCR1_RXDMAEN | > + UCR1_TXDMAEN | UCR1_ATDMAEN); > + ucr1 |= UCR1_UARTEN; > + imx_uart_write(uart, UCR1, ucr1); > + > + ucr2 = imx_uart_read(uart, UCR2); > + ucr2 |= UCR2_SRST | UCR2_RXEN | UCR2_TXEN; > + imx_uart_write(uart, UCR2, ucr2); > +} > + > +static void __init imx_uart_init_postirq(struct serial_port *port) > +{ > + struct imx_uart *uart = port->uart; > + uint32_t ucr1; > + > + uart->irqaction.handler = imx_uart_interrupt; > + uart->irqaction.name = "imx_uart"; > + uart->irqaction.dev_id = port; > + > + if ( setup_irq(uart->irq, 0, &uart->irqaction) != 0 ) > + { > + dprintk(XENLOG_ERR, "Failed to allocate imx_uart IRQ %d\n", uart->irq); uart->irq is unsigned, so s/%d/%u. ~Michal