From nobody Sat Aug 29 19:07:02 2026 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787153328; cv=none; d=zohomail.com; s=zohoarc; b=TXNJXwyaWQHvnt9YECpxHrIvbBXdinKc89vPympo48ZXZ6F0tj7cfm571Qbgx1t6P08Zjp2yYsk1tHLZYV+c7UZzuLSDs9TSNJ91s4dWMwdJsGe6evaMDuOFq8dtt6Oj1HzUxF5+4Z+Ef3k4oslEQgDU5Rr+yBGGZsm38nsaANU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787153328; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FBaWu89tr1O3ae9E4zrFCri6nPdlnyNL6tarjmgqd28=; b=gKl1oSlQpFwoJMlVtmw5USCpeKTHnr5Ws0M61ydBkGOpOBuUOU5zhJiOSkKsTC4lEDNud5aN6u4UCRQ1k43saQ3zpbru9NQxpcAVEsBUSMzG0P3SEgi08cCv4ztJdCK+BV0AomqDFHx78IgN2Dvz/YNBFIfFPJzXiE8uhVSZOps= ARC-Authentication-Results: i=1; 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; dmarc=pass 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 178715332800218.69868980115473; Wed, 19 Aug 2026 08:28:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1395587.1633920 (Exim 4.92) (envelope-from ) id 1wwiDS-00043x-8G; Wed, 19 Aug 2026 15:28:34 +0000 Received: by outflank-mailman (output) from mailman id 1395587.1633920; Wed, 19 Aug 2026 15:28:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDS-00043q-5U; Wed, 19 Aug 2026 15:28:34 +0000 Received: by outflank-mailman (input) for mailman id 1395587; Wed, 19 Aug 2026 15:28:33 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDR-00043E-8S for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 15:28:33 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wwiDQ-001HxZ-Le for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 17:28:32 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a85cb88-2eae-0a2a0a5409dd-0a2a45068b12-32 for ; Wed, 19 Aug 2026 17:28:32 +0200 Received: from [209.85.210.179] (helo=mail-pf1-f179.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a85cb9f-195a-0a2a45060019-d155d2b3f151-3 for ; Wed, 19 Aug 2026 17:28:32 +0200 Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-84862b0d5f8so983290b3a.3 for ; Wed, 19 Aug 2026 08:28:32 -0700 (PDT) Received: from wig-Precision-3660.. (125-227-154-99.hinet-ip.hinet.net. [125.227.154.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851d3617434sm787575b3a.29.2026.08.19.08.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:28:28 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787153310; x=1787758110; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=FBaWu89tr1O3ae9E4zrFCri6nPdlnyNL6tarjmgqd28=; b=qtFgaYVe7P16dqvKfLHotcAmkmXK5JVg/JXQwXjWt8MQXmJHws3rpQvB7r5yMhJcza OZ/EudlZZcbKIiVgPwbDcmngRae22YbPPFEkZXk0CUMzKUoUslORojBA5XTNYzri6kDs hS7tduVEeH+OSozic+9uzVCnWnk440I30CZK/tfE1GBY6g/2tfHGEmujF8eBO6U3MJGJ Xr9/y0LuQ2xHMazTxHePPKbbTAirVs151jG2QKXXTjVLRwMbPJVp2F3a9UcplBLs/xX1 yY/yG61JF/vffOg+j2J/LDi7x4TvvsYHxilrh/I+/Fy4ncI0caRsqxb9lAMF3+oSAFhr ETkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787153310; x=1787758110; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=FBaWu89tr1O3ae9E4zrFCri6nPdlnyNL6tarjmgqd28=; b=LGBBD4SnqgcGzApohfvAOX5GX8oG06EETx+L6E7GDF0vRAdiGgvu1dp5oRBmSht4Tg R3gNLGGuRJ1A/FW4UUBwqeVA3ACMZpXzzArAb8NRExCntukcBraZbQ5qdBVYuihzTR/K Tf6ik+Wts/IOXyQ84Xvdq5wqb9hyPMZyWyOvFQCAjfUgBvXDq4Rsum20gY7iJj4ehIyU MKB+2g3PLLeNn99TspQbxWcQTs6FLKw68BPCvTeIhvWtiXbORtgaSEpsA1JZHhY6qf5x mPBz9F6lmECp/cjcK/sdKYNbdrFYJO1fshooGTKQmbfccgiYhkpe5WZelZuVfBas+3MN 4Gpw== X-Gm-Message-State: AOJu0YwY79SrLW1KEKSWVnMJnJbjit1quhPUuaiK4ClFzIDvTjQgEbHB oBBdbvtyMXFfHX1Ng9uRtlwoW+9r3Wl9ut1Xk2T7dDMXKHO7iWzbqLYe6bi208ZG X-Gm-Gg: AR+sD13ikSKxe+/ysZtb1/T5iKMIM0Q6Toy8qxe22YrDbjw5x7ljjovRuEK09CVKKAs EM98cXzO1xMh7qmGUdUqvXiB8Pmklq9UdY80WrjqWucM+LUNpNkYTYH+hNjwLLK6HgBCn8X2gnc MNIlRO4HCjXWmSYWD9TKhN5yDBAyxYhyNA58/voo3AJQB//M3lDM7VUL6sb9o9AGmTW72imWNWv kjVYHPhyeDfmgG1izAGgOZVMaLU1NJykrkqpXHrj93WoDalwc5YXtjWJf4yWmX9L3JKQS4xgGm0 VxEZiEmt4OHbI9SOSZIMhHOWAZR2glUFvM4Q6DgnArlTAfgllBMYXYelGQpagZhArqTsOwsnQL8 YygsnCqdgFB5hkUJOH66t1StvLG1/z15NagGlMxfmZIdwgoD+jQ/DhpOgRcuP+3j0Vc9Ib8BnX7 4JkvcMbls3MS4tJv/90WbMjzKB7MF3o4V0iV+7HDBFF/WAeGJ2nX4I7F9Qy6cwno4lManN3jG33 NHHPSnXfeeFYUzrnwD7D23Mz3f1HAP0 X-Received: by 2002:a05:6a00:22ca:b0:84e:4d6:78fe with SMTP id d2e1a72fcca58-851d3807df1mr8953418b3a.3.1787153309563; Wed, 19 Aug 2026 08:28:29 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , John Ernberg , Peng Fan Subject: [PATCH v4 1/4] xen/char: add classic i.MX UART driver Date: Wed, 19 Aug 2026 23:28:18 +0800 Message-ID: <20260819152821.3361898-2-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819152821.3361898-1-onlywig@gmail.com> References: <20260819152821.3361898-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1787153312-FEC7777B-F173E3FC/0/0 X-purgate-type: clean X-purgate-size: 11487 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787153329836158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michal Orzel --- Changes in v4: - No code changes; picked up Michal's Reviewed-by. MAINTAINERS | 1 + 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 | 233 ++++++++++++++++++++++++++++ 5 files changed, 300 insertions(+) create mode 100644 xen/arch/arm/include/asm/imx-uart.h create mode 100644 xen/drivers/char/imx-uart.c diff --git a/MAINTAINERS b/MAINTAINERS index ed0ffa608f..4dd97ffcad 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -269,6 +269,7 @@ F: xen/arch/arm/ F: xen/drivers/char/cadence-uart.c F: xen/drivers/char/exynos4210-uart.c F: xen/drivers/char/imx-lpuart.c +F: xen/drivers/char/imx-uart.c F: xen/drivers/char/meson-uart.c F: xen/drivers/char/mvebu-uart.c F: xen/drivers/char/omap-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 =3D 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. =20 +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) +=3D scif-uart.o obj-$(CONFIG_HAS_EHCI) +=3D ehci-dbgp.o obj-$(CONFIG_XHCI) +=3D xhci-dbc.o obj-$(CONFIG_HAS_IMX_LPUART) +=3D imx-lpuart.o +obj-$(CONFIG_HAS_IMX_UART) +=3D imx-uart.o obj-$(CONFIG_HAS_LINFLEX) +=3D linflex-uart.o obj-$(CONFIG_GENERIC_UART_INIT) +=3D uart-init.o obj-y +=3D serial.o diff --git a/xen/drivers/char/imx-uart.c b/xen/drivers/char/imx-uart.c new file mode 100644 index 0000000000..2dc531a84e --- /dev/null +++ b/xen/drivers/char/imx-uart.c @@ -0,0 +1,233 @@ +/* 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 =3D data; + struct imx_uart *uart =3D port->uart; + + if ( imx_uart_read(uart, USR2) & USR2_RDR ) + serial_rx_interrupt(port); + + /* + * USR1_TRDY is a raw status bit, set whenever the transmitter has + * room regardless of whether the TX interrupt is enabled. Only treat + * it as a TX interrupt when TRDYEN is set, otherwise an RX-only + * interrupt would spuriously enter serial_tx_interrupt(). + */ + if ( (imx_uart_read(uart, USR1) & USR1_TRDY) && + (imx_uart_read(uart, UCR1) & UCR1_TRDYEN) ) + serial_tx_interrupt(port); +} + +static void __init imx_uart_init_preirq(struct serial_port *port) +{ + struct imx_uart *uart =3D 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 =3D imx_uart_read(uart, UCR1); + ucr1 &=3D ~(UCR1_RRDYEN | UCR1_TRDYEN | UCR1_TXMPTYEN | UCR1_RXDMAEN | + UCR1_TXDMAEN | UCR1_ATDMAEN); + ucr1 |=3D UCR1_UARTEN; + imx_uart_write(uart, UCR1, ucr1); + + ucr2 =3D imx_uart_read(uart, UCR2); + ucr2 |=3D 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 =3D port->uart; + uint32_t ucr1; + + uart->irqaction.handler =3D imx_uart_interrupt; + uart->irqaction.name =3D "imx_uart"; + uart->irqaction.dev_id =3D port; + + if ( setup_irq(uart->irq, 0, &uart->irqaction) !=3D 0 ) + { + dprintk(XENLOG_ERR, "Failed to allocate imx_uart IRQ %u\n", uart->= irq); + return; + } + + /* Enable the receiver ready interrupt */ + ucr1 =3D imx_uart_read(uart, UCR1); + ucr1 |=3D UCR1_RRDYEN; + imx_uart_write(uart, UCR1, ucr1); +} + +static int imx_uart_tx_ready(struct serial_port *port) +{ + struct imx_uart *uart =3D port->uart; + + return !(imx_uart_read(uart, UTS) & UTS_TXFULL); +} + +static void imx_uart_putc(struct serial_port *port, char c) +{ + struct imx_uart *uart =3D port->uart; + + while ( imx_uart_read(uart, UTS) & UTS_TXFULL ) + cpu_relax(); + + imx_uart_write(uart, URTX0, c); +} + +static int imx_uart_getc(struct serial_port *port, char *pc) +{ + struct imx_uart *uart =3D port->uart; + + if ( !(imx_uart_read(uart, USR2) & USR2_RDR) ) + return 0; + + *pc =3D imx_uart_read(uart, URXD0) & URXD_RX_DATA; + + if ( imx_uart_read(uart, USR2) & USR2_ORE ) + imx_uart_write(uart, USR2, USR2_ORE); + + return 1; +} + +static int __init imx_uart_irq(struct serial_port *port) +{ + struct imx_uart *uart =3D port->uart; + + return ((uart->irq > 0) ? uart->irq : -1); +} + +static const struct vuart_info *imx_uart_vuart_info(struct serial_port *po= rt) +{ + struct imx_uart *uart =3D port->uart; + + return &uart->vuart; +} + +static void imx_uart_start_tx(struct serial_port *port) +{ + struct imx_uart *uart =3D port->uart; + uint32_t ucr1; + + ucr1 =3D imx_uart_read(uart, UCR1); + imx_uart_write(uart, UCR1, ucr1 | UCR1_TRDYEN); +} + +static void imx_uart_stop_tx(struct serial_port *port) +{ + struct imx_uart *uart =3D port->uart; + uint32_t ucr1; + + ucr1 =3D imx_uart_read(uart, UCR1); + imx_uart_write(uart, UCR1, ucr1 & ~UCR1_TRDYEN); +} + +static struct uart_driver __read_mostly imx_uart_driver =3D { + .init_preirq =3D imx_uart_init_preirq, + .init_postirq =3D imx_uart_init_postirq, + .tx_ready =3D imx_uart_tx_ready, + .putc =3D imx_uart_putc, + .getc =3D imx_uart_getc, + .irq =3D imx_uart_irq, + .start_tx =3D imx_uart_start_tx, + .stop_tx =3D imx_uart_stop_tx, + .vuart_info =3D imx_uart_vuart_info, +}; + +static int __init imx_uart_init(struct dt_device_node *dev, const void *da= ta) +{ + const char *config =3D data; + struct imx_uart *uart; + int res; + paddr_t addr, size; + + if ( strcmp(config, "") ) + printk("WARNING: UART configuration is not supported\n"); + + uart =3D &imx8m_com; + + res =3D dt_device_get_paddr(dev, 0, &addr, &size); + if ( res ) + { + printk("imx-uart: Unable to retrieve the base address of the UART\= n"); + return res; + } + + res =3D platform_get_irq(dev, 0); + if ( res < 0 ) + { + printk("imx-uart: Unable to retrieve the IRQ\n"); + return -EINVAL; + } + uart->irq =3D res; + + uart->regs =3D ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("imx-uart: 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 URTX0; + uart->vuart.status_off =3D UTS; + uart->vuart.status =3D UTS_TXEMPTY | UTS_RXEMPTY; + + /* Register with generic serial driver */ + serial_register_uart(SERHND_DTUART, &imx_uart_driver, uart); + + dt_device_set_used_by(dev, DOMID_XEN); + + return 0; +} + +static const struct dt_device_match imx_uart_dt_compat[] __initconst =3D +{ + DT_MATCH_COMPATIBLE("fsl,imx6q-uart"), + { /* sentinel */ }, +}; + +DT_DEVICE_START(imx_uart, "i.MX UART", DEVICE_SERIAL) + .dt_match =3D imx_uart_dt_compat, + .init =3D imx_uart_init, +DT_DEVICE_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.43.0 From nobody Sat Aug 29 19:07:02 2026 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787153335; cv=none; d=zohomail.com; s=zohoarc; b=GKFbnrAQ6D0RjFf6d1j10H/wCGb9ci8DLz7D8biv1U1ISLsyZBwhdiisEKfcgxvDZXkRgc5AHerD6Nk9SpJ7Hiz9xxO+l0hbbETVAs7PdKSh0I8vzMEWlKJSFYeQ4uwEHIS/iZKkmY6QnqyBtWEV1CpEakW9v7Ps9tRtiOMjDjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787153335; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NVwP6oo+AcC8zP/zY/rrq1zp653mgLYZ54VIF02BJyk=; b=aud7Mb2nSv4vK0wM+q19aKiJVL9bns0LjjUBX+vTklDAeug9XSVUkJ6+PRkuh4cU65nDPw70g+q7iT8sqLdi0BTZgHSuHbC0xm1BZxvonS/1//GFSxyhsSqlhLvJ/Bs/bLpgvHL5AjRVHdFFFuCVK3uG9qrM2bcuuaSp7ceZDLA= ARC-Authentication-Results: i=1; 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; dmarc=pass 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 1787153335710970.7913952200911; Wed, 19 Aug 2026 08:28:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1395588.1633928 (Exim 4.92) (envelope-from ) id 1wwiDU-0004IP-GC; Wed, 19 Aug 2026 15:28:36 +0000 Received: by outflank-mailman (output) from mailman id 1395588.1633928; Wed, 19 Aug 2026 15:28:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDU-0004II-DN; Wed, 19 Aug 2026 15:28:36 +0000 Received: by outflank-mailman (input) for mailman id 1395588; Wed, 19 Aug 2026 15:28:34 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDS-0004Bl-TG for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 15:28:34 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wwiDS-00FCv4-A5 for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 17:28:34 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a85cba0-e002-0a2a0a5209dd-0a2a450b9086-6 for ; Wed, 19 Aug 2026 17:28:34 +0200 Received: from [209.85.210.178] (helo=mail-pf1-f178.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a85cba0-b7e8-0a2a450b0019-d155d2b2e0d8-3 for ; Wed, 19 Aug 2026 17:28:34 +0200 Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-8518d5ddaabso1032210b3a.2 for ; Wed, 19 Aug 2026 08:28:33 -0700 (PDT) Received: from wig-Precision-3660.. (125-227-154-99.hinet-ip.hinet.net. [125.227.154.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851d3617434sm787575b3a.29.2026.08.19.08.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:28:31 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787153312; x=1787758112; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NVwP6oo+AcC8zP/zY/rrq1zp653mgLYZ54VIF02BJyk=; b=sKnjZlG45dIk1z0ctGnffIqmHDeWelWt1S6UZi008iSE1029HRo8DPLHrUNKRza4Ds Zm2zzN5suumb38M7hry/9gfAQiivklRldCZQcbJCcQsphoUsiSINqDYbe44Ew7LztzD3 zXSBqBJKiO+RxX8d84G81qBhkgjkpstblZXhYYQ7XkWCY5M8ZfR6ImrA97wi1Qvf3rfO 7h3Vaab/QRd42CrJSSQ0MimPvz2IX9HSHuh//ROtabXhfydaLO41wjRx80m7OnRKqnxP Mg8o25VOuZ3cynV1AUtvCo6GGkH9eOvqypiBY3jkNr6mTdTlrByCSpKGE/Uv/4q+XUMb Dzxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787153312; x=1787758112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NVwP6oo+AcC8zP/zY/rrq1zp653mgLYZ54VIF02BJyk=; b=Ab7NlRKZ3lE4GAT2u0rJPgGPvDMfbqcZDsLYEYcuy14G4KDAc443ECtPiyPYrvrgwq fT7HQoGBzyH4I2H1QcOFOVqk5vnDyoWERZrhjdRUqNp1fXwMjqiLITLtNzmD+5OwSHUB AwY12hvq5oHGEVNiheW+Wge4LxOgwMWfA5NdjisWkXrahCtaE34LzL+9n1mthnxN4ety hKkTWCt9l6gs88LTaWa5CksVNZJgmQ71VfiuNez5Q+QMIj5MRs84VGMpXviI/zeY2KJH A1w4PLoPeTdSrO/yNH162KJvR6CyrEHV0Ut7qPFBRl+/eeMvPrN1kcGbXF+3z4Mdgpee I40A== X-Gm-Message-State: AOJu0Yxv2utmfJB+KAuyRKnez9vd+XK+gNVCjla0RdEG2QJgbW91LYMz +RWU8hSwWrp8EJUUhKh2x1PtzHpAILjha4sBtksx27iR68cHQyBG4460gzqYhGoZ X-Gm-Gg: AR+sD11U965trUHsMFRBixXa0ykD3g7bUOpMyRUqVi0OcPXDEFclmYyB59uOf5ktku/ ygLZcsETpwsekVN3UBYoOkywDtmIjnmyjvmPzG5nU3IL5OcOzoJVO5s0pGcYws7pwHRFWx/iZBA kB4Hbxl68ZUZ602Ad6I/cSmY9lCfym8y3PvxEw5Hh99T6bwbQfGafftKvA6smVbafWVxrdwhR4r uXXBntME/4sszrhHKM+fdhPv4iosxvRGHadT467AzPPOUspb6oJKhuYDGLpbBjxE0aFeFngQKkJ EpIHRxk14y9uSu8Eonvl6bC/rt5lUCagg1DQsuwDMuARepH+qBcVwGHkmyBu6S3mmimCy/sAmXb LOVPcnkHqnRmfdJrqfm2jNAVSbyPMrOqK2Ywr8eWrFHLtVsNLcvgKRNj1squcAbg4cKliNXzl5U UGEr5jJPBfMKmJUhAFttIUd7SgT+IaINsgNIDDrI0djhMh3e2MoYBNPyup8PPberbMzKZ7ihOv9 JTb1kQsLkZbPYOGTNfTdOwhkD6JgaWd X-Received: by 2002:a05:6a00:4f91:b0:848:5f4f:289d with SMTP id d2e1a72fcca58-851d3850391mr8923732b3a.4.1787153312230; Wed, 19 Aug 2026 08:28:32 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , John Ernberg , Peng Fan Subject: [PATCH v4 2/4] xen/arm64: add early printk for the classic i.MX UART Date: Wed, 19 Aug 2026 23:28:19 +0800 Message-ID: <20260819152821.3361898-3-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819152821.3361898-1-onlywig@gmail.com> References: <20260819152821.3361898-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1787153314-A8AC89EA-D21BFA9F/0/0 X-purgate-type: clean X-purgate-size: 3091 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787153337664158500 Content-Type: text/plain; charset="utf-8" Add an early printk implementation for the classic i.MX UART IP, selectable via EARLY_UART_CHOICE_IMX_UART. The UART is expected to be fully initialized by the bootloader. Signed-off-by: Wig Cheng Reviewed-by: Michal Orzel --- Changes in v4: - No changes. xen/arch/arm/Kconfig.debug | 12 +++++++++ xen/arch/arm/arm64/debug-imx-uart.inc | 37 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-imx-uart.inc diff --git a/xen/arch/arm/Kconfig.debug b/xen/arch/arm/Kconfig.debug index 5a03b220ac..63a34b813a 100644 --- a/xen/arch/arm/Kconfig.debug +++ b/xen/arch/arm/Kconfig.debug @@ -44,6 +44,14 @@ choice Say Y here if you wish the early printk to direct their output to a i.MX LPUART. =20 + config EARLY_UART_CHOICE_IMX_UART + select EARLY_UART_IMX_UART + depends on ARM_64 + bool "Early printk via i.MX UART" + help + Say Y here if you wish the early printk to direct their + output to the classic i.MX UART (i.MX8M family). + config EARLY_UART_CHOICE_LINFLEX select EARLY_UART_LINFLEX depends on ARM_64 @@ -97,6 +105,9 @@ config EARLY_UART_EXYNOS4210 config EARLY_UART_IMX_LPUART select EARLY_PRINTK bool +config EARLY_UART_IMX_UART + select EARLY_PRINTK + bool config EARLY_UART_LINFLEX select EARLY_PRINTK bool @@ -185,6 +196,7 @@ config EARLY_PRINTK_INC 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-imx-uart.inc" if EARLY_UART_IMX_UART default "debug-linflex.inc" if EARLY_UART_LINFLEX default "debug-meson.inc" if EARLY_UART_MESON default "debug-mvebu.inc" if EARLY_UART_MVEBU diff --git a/xen/arch/arm/arm64/debug-imx-uart.inc b/xen/arch/arm/arm64/deb= ug-imx-uart.inc new file mode 100644 index 0000000000..19b1679020 --- /dev/null +++ b/xen/arch/arm/arm64/debug-imx-uart.inc @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Early printk for the classic i.MX UART IP (i.MX8M family). + * The UART is expected to be fully initialized by the bootloader. + * + * Copyright 2026 Open-EP (E-Paper) Community + */ + +#include + +/* + * Wait for the UART to be ready to transmit + * xb: register which contains the UART base address + * c: scratch register + */ +.macro early_uart_ready xb, c +1: + ldr w\c, [\xb, #UTS] /* <- Test register */ + tst w\c, #UTS_TXFULL /* Check TX FIFO full bit */ + b.ne 1b /* Wait until there is room */ +.endm + +/* + * UART transmit character + * xb: register which contains the UART base address + * wt: register which contains the character to transmit + */ +.macro early_uart_transmit xb, wt + str \wt, [\xb, #URTX0] /* -> Transmitter register */ +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */ --=20 2.43.0 From nobody Sat Aug 29 19:07:02 2026 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787153335; cv=none; d=zohomail.com; s=zohoarc; b=cSczfX08I9C9+UHMB3V234cOsBqfk6scWbE4ogLzteC8zJdcJO2Cuy83aq2liOfwIpylu+Pg47qmOFLmy1fxZEGrBboBqz7k1txpJWTZyyamTJbmnlYR/116uAcuw3hGLYuv5rgvZx9ENjVBjRtnPAa8579OKj59PENGB7Iqy78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787153335; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oCTJm4KprltrO2DL2H0L71Et98Ar4/DK5gqKwieMcHI=; b=HNSSjKCT+7Y/bENQhWIG3+mruUvxR+9tG7sw0lrF/ZmaEMNzBYLF/IaaNTsB7ZWf85fmIZbb+tsQCGpdcTMLTtlbp45bnLQO3+0ZoD8w70KuMt5XAXjgoZZ+a25X5XKw525yMHgTMSF6MRqF2dYwqe92avVzc8trNWWPgwImJuw= ARC-Authentication-Results: i=1; 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; dmarc=pass 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 1787153335004234.22355077174302; Wed, 19 Aug 2026 08:28:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1395589.1633938 (Exim 4.92) (envelope-from ) id 1wwiDW-0004Z5-Rv; Wed, 19 Aug 2026 15:28:38 +0000 Received: by outflank-mailman (output) from mailman id 1395589.1633938; Wed, 19 Aug 2026 15:28:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDW-0004Yw-Oa; Wed, 19 Aug 2026 15:28:38 +0000 Received: by outflank-mailman (input) for mailman id 1395589; Wed, 19 Aug 2026 15:28:37 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDV-0004XO-OZ for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 15:28:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wwiDV-009wZP-5C for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 17:28:37 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a85cb7e-bab6-0a2a0a5309dd-0a2a4504bacc-32 for ; Wed, 19 Aug 2026 17:28:37 +0200 Received: from [209.85.210.169] (helo=mail-pf1-f169.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a85cba3-b57f-0a2a45040019-d155d2a9dd6d-3 for ; Wed, 19 Aug 2026 17:28:36 +0200 Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-84830c774a0so1191353b3a.1 for ; Wed, 19 Aug 2026 08:28:36 -0700 (PDT) Received: from wig-Precision-3660.. (125-227-154-99.hinet-ip.hinet.net. [125.227.154.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851d3617434sm787575b3a.29.2026.08.19.08.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:28:34 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787153315; x=1787758115; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oCTJm4KprltrO2DL2H0L71Et98Ar4/DK5gqKwieMcHI=; b=TGkL8+PFm6hIVmuzNShpvBMa28/sfgXhRlkBZwoHyi8xqXo/O8bcaKUX1QXnBCaVBL DMS14Hdfa80U7qN3rD/GH5yVLGbUgLQKZgPO0wC6GRVzTVkcCW95Ru7ALxfT3V/7dmTb KWQyaaY8jla959gJNU317Ufv5Y6Nq8d57dA6WdS4UWglmu+OgFmrh6Tmu2/9Q74HFe76 OSDV3dTokp/9v4Qiz19GEykCBRCkpPaD0L2fSLv+Z/ljY502lw6tBse1UOhQEeXOGG2D wKVpp4erZGYdhcNREpQ6rSp4lF+9nHhdZNLBwz2sb7on5OxzPGSU8Bi1gd11Qz5UZuSI BFYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787153315; x=1787758115; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=oCTJm4KprltrO2DL2H0L71Et98Ar4/DK5gqKwieMcHI=; b=CEMyHnkOixiNCJqyP4bs/WzWevpc4zI9K5GqOij98KDBiJHttoMR1JDW+Rll28j5ap ffbQLnfSc+Z80cgsgvWkZBr2KtBwOuiiz5MjLef2xuIiSggxSXB6j0ASU3Bjzag1iiW6 zY9Me2yHuzpO5YVOqJxKudWoDnTr/r9Ah0hYtiXxIU2rLWNxLWESx8s09f2IKRJtGROq HlqJmxy7nYOIU9D7IL2l9ZDEn6WfQAzikPgv4lMeHZ7zDhQ4exf9TUIhzlSKKSupi5Gd aTqTJlkoVYw5pTwny1KsJTK44OIw1AW+C4uC63DfvZRokGUANQRMvlMZhZvDP+3f1X74 lvYQ== X-Gm-Message-State: AOJu0Yyxr9j7rCEx5RbjlMRBQUDcxHutgfW3f9EglhlozfpbFwkaigJb 6RSro2ObSYN3r+piX54/xlz+1YkbxieP5cQae94p9iaOUi+zmsVQTqo31/lag+nJ X-Gm-Gg: AR+sD12Oc2SZo1LpR2IpA64WWC2PXPFFzmuADWltgmZeSrGDNlX55JQuajP9KqLlL09 6sS61RBFDFmZcQ/K5Q5VZOEeZMIcSw0IYkGESGpOKLUzcq4LItR2oZScckyljMAE9pYDbuAlDsV jCyseNTQ+gp3ek3TZI2EJcuuhum4n7bL53vUskZSzAq+85PS28MOwbHoTT+6BREKLLWWwmPeQa1 7eXEdf0nPJM03wGEGkwGvoRWiREKENZiX9eh6bPnf6x8tk7RG9sbJ0dQOC8LP47jQPKr98QKnHR HEvWInITn/CMShXJaEoVIE1/zhOr80Y4AK6Q3SuENByGMVmdE5ITo/dXqGkJsBHBzVkXmORvYFh 9IdlOfx0gWZWGOFBeoTgjxlTSXxQauGFLq5lDLf+9ASECExaKurOrI+hUM7dfj3eFPDjMlMGISM 8GkxbbE8u11BR8mEqBjLkfRz4ob/FztDWAo+Sqw7Dz3y8+ehtSi9uSckbBcVFlEqIC9Ke9gnjh4 X669B2KroM5wcSoKGQqypYfz2DxhRod X-Received: by 2002:a05:6a00:ba8e:b0:847:9267:2104 with SMTP id d2e1a72fcca58-851d394802emr8097891b3a.12.1787153314949; Wed, 19 Aug 2026 08:28:34 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , John Ernberg , Peng Fan Subject: [PATCH v4 3/4] xen/arm: add i.MX8M platform support Date: Wed, 19 Aug 2026 23:28:20 +0800 Message-ID: <20260819152821.3361898-4-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819152821.3361898-1-onlywig@gmail.com> References: <20260819152821.3361898-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1787153317-508D9B50-366F072F/0/0 X-purgate-type: clean X-purgate-size: 7252 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787153335609158500 Content-Type: text/plain; charset="utf-8" Add platform glue for the NXP i.MX8M family (i.MX8MP/MQ/MM/MN). When Linux is used as dom0 a number of drivers make SiP SMC calls into TF-A to manage hardware: GPC power domains, SRC (M-core remoteproc), SoC info and NoC QoS. There is no public specification for these calls; the function IDs and their subfunctions are taken from the vendor kernel call sites. Forward only the specific subfunctions the hardware domain issues, following the whitelist model of the i.MX8QM platform. Each service with a fixed set of subfunctions (GPC, SRC, NoC) filters them with an explicit switch on the subfunction id, and the SoC info call is a read-only query. CPU and DRAM frequency scaling are denied because the hardware domain cannot make an informed decision about resources shared with the other domains, and any unknown function ID is rejected. Signed-off-by: Wig Cheng Reviewed-by: Michal Orzel --- Changes in v4: - SRC and NoC: filter the subfunction id with an explicit switch that lists each accepted subfunction, instead of a range check. - NoC: accept only the QoS priority subfunction; the LCDIF subfunction has no caller in the vendor kernel. Note that i.MX8MP issues no NoC call at boot (only i.MX8MQ does). - Print the subfunction id as well when rejecting an unknown function id. - Picked up Michal's Reviewed-by. xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/imx8m.c | 161 ++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 xen/arch/arm/platforms/imx8m.c diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makef= ile index bec6e55d1f..cdf936c50d 100644 --- a/xen/arch/arm/platforms/Makefile +++ b/xen/arch/arm/platforms/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_ALL_PLAT) +=3D sunxi.o obj-$(CONFIG_ALL64_PLAT) +=3D thunderx.o obj-$(CONFIG_ALL64_PLAT) +=3D xgene-storm.o obj-$(CONFIG_ALL64_PLAT) +=3D brcm-raspberry-pi.o +obj-$(CONFIG_ALL64_PLAT) +=3D imx8m.o obj-$(CONFIG_ALL64_PLAT) +=3D imx8qm.o obj-$(CONFIG_MPSOC_PLATFORM) +=3D xilinx-zynqmp.o obj-$(CONFIG_MPSOC_PLATFORM) +=3D xilinx-zynqmp-eemi.o diff --git a/xen/arch/arm/platforms/imx8m.c b/xen/arch/arm/platforms/imx8m.c new file mode 100644 index 0000000000..ad76935f5d --- /dev/null +++ b/xen/arch/arm/platforms/imx8m.c @@ -0,0 +1,161 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * i.MX 8M family setup + * + * Copyright 2026 Open-EP (E-Paper) Community + */ + +#include +#include +#include +#include + +static const char * const imx8m_dt_compat[] __initconst =3D +{ + "fsl,imx8mp", + "fsl,imx8mq", + "fsl,imx8mm", + "fsl,imx8mn", + NULL +}; + +#define IMX_SIP_FID(fid) \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_CONV_64, \ + ARM_SMCCC_OWNER_SIP, \ + (fid)) + +/* + * SiP SMC function IDs used by the i.MX8M Linux drivers. There is no + * public specification for these; the IDs and their subfunctions are + * extracted from the vendor kernel call sites (see drivers/soc/imx, + * drivers/devfreq, drivers/remoteproc). + */ +#define IMX_SIP_F_GPC 0x0 /* GPC power-domain control */ +#define IMX_SIP_F_CPUFREQ 0x1 /* CPU frequency scaling */ +#define IMX_SIP_F_DDR_DVFS 0x4 /* DRAM frequency scaling */ +#define IMX_SIP_F_SRC 0x5 /* SRC: M-core remoteproc start/stop */ +#define IMX_SIP_F_SOC_INFO 0x6 /* read-only SoC info query */ +#define IMX_SIP_F_NOC 0x8 /* NoC QoS priority setup */ + +#define IMX_SIP_GPC_SF_PM_DOMAIN 0x03 + +#define IMX_SIP_SRC_SF_M4_START 0x00 +#define IMX_SIP_SRC_SF_M4_STARTED 0x01 +#define IMX_SIP_SRC_SF_M4_STOP 0x02 + +#define IMX_SIP_NOC_SF_PRIORITY 0x01 + +static bool imx8m_smc(struct cpu_user_regs *regs) +{ + uint32_t function_id =3D get_user_reg(regs, 0); + uint32_t subfunction_id =3D get_user_reg(regs, 1); + struct arm_smccc_res res; + + if ( !cpus_have_const_cap(ARM_SMCCC_1_1) ) + { + printk_once(XENLOG_WARNING + "imx8m: smc: no SMCCC 1.1 support. Disabling firmware = calls\n"); + + return false; + } + + /* Only the hardware domain may use the SiP calls */ + if ( !is_hardware_domain(current->domain) ) + { + gprintk(XENLOG_WARNING, "imx8m: smc: No access\n"); + return false; + } + + /* + * Forward only the subfunctions the dom0 kernel actually issues. All + * of these manage hardware that belongs to the hardware domain (power + * domains, M-core, NoC) or are read-only queries. + */ + switch ( function_id ) + { + case IMX_SIP_FID(IMX_SIP_F_GPC): + if ( subfunction_id !=3D IMX_SIP_GPC_SF_PM_DOMAIN ) + return false; + break; + + /* + * CPU and DRAM frequency scaling: the hardware domain does not see the + * whole system and cannot make an informed decision about resources + * shared with the other domains, so deny both (CPU frequency scaling + * is denied on the i.MX8QM platform for the same reason). + */ + case IMX_SIP_FID(IMX_SIP_F_CPUFREQ): + case IMX_SIP_FID(IMX_SIP_F_DDR_DVFS): + return false; + + case IMX_SIP_FID(IMX_SIP_F_SRC): + /* SRC: M-core remoteproc start, poll-started and stop. */ + switch ( subfunction_id ) + { + case IMX_SIP_SRC_SF_M4_START: + case IMX_SIP_SRC_SF_M4_STARTED: + case IMX_SIP_SRC_SF_M4_STOP: + break; + + default: + return false; + } + break; + + case IMX_SIP_FID(IMX_SIP_F_SOC_INFO): + break; + + case IMX_SIP_FID(IMX_SIP_F_NOC): + /* + * NoC QoS priority setup. Only i.MX8MQ issues this at boot; + * i.MX8MP issues no NoC call, but the platform covers both. + */ + switch ( subfunction_id ) + { + case IMX_SIP_NOC_SF_PRIORITY: + break; + + default: + return false; + } + break; + + default: + gprintk(XENLOG_WARNING, + "imx8m: smc: Unknown function id %x subfunction id %x\n", + function_id, subfunction_id); + return false; + } + + arm_smccc_1_1_smc(function_id, + subfunction_id, + get_user_reg(regs, 2), + get_user_reg(regs, 3), + get_user_reg(regs, 4), + get_user_reg(regs, 5), + get_user_reg(regs, 6), + get_user_reg(regs, 7), + &res); + + set_user_reg(regs, 0, res.a0); + set_user_reg(regs, 1, res.a1); + set_user_reg(regs, 2, res.a2); + set_user_reg(regs, 3, res.a3); + + return true; +} + +PLATFORM_START(imx8m, "i.MX 8M") + .compatible =3D imx8m_dt_compat, + .smc =3D imx8m_smc, +PLATFORM_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.43.0 From nobody Sat Aug 29 19:07:02 2026 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787153343; cv=none; d=zohomail.com; s=zohoarc; b=c/JWu9iFol3pNgjoOZykNL7oeZ7YvwfPLCFayo6JDTwZPpqCiD0rvTzASJh3U45RyR9ZHg52johDmxQH85dlwArDu0pNZbq4YbvGbdV82QK0g0z07pl8oX0/VRqEnxdqcW2VYTMT4blEvMMAIRmB6x2hjmjcs6j44WgZmkhsJ3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787153343; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qexHZlqSFqOa+wu3jRbx9Js4zQ/0pHMbVWziLO2Koe8=; b=X/b/v5LCDJ3a5E/npaSnh3lNMKS65B58fBZk03t4UCbLsq/HUUAcTvgaDRO4iOVjXvNhLy6yVxmINvpWtvWaST6r8Tpk19I/Y2IP9Uj92Gd2YpqiYhn5bicHWqeTrVZ87oBAhieiOi0S5rgmkjfV9woHxEZ9qbNnwDeDWfiXIB0= ARC-Authentication-Results: i=1; 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; dmarc=pass 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 1787153343619233.25139318757942; Wed, 19 Aug 2026 08:29:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1395591.1633947 (Exim 4.92) (envelope-from ) id 1wwiDa-0004qH-36; Wed, 19 Aug 2026 15:28:42 +0000 Received: by outflank-mailman (output) from mailman id 1395591.1633947; Wed, 19 Aug 2026 15:28:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDa-0004q5-03; Wed, 19 Aug 2026 15:28:42 +0000 Received: by outflank-mailman (input) for mailman id 1395591; Wed, 19 Aug 2026 15:28:40 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wwiDY-0004nj-G6 for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 15:28:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wwiDX-00H1ec-T1 for xen-devel@lists.xenproject.org; Wed, 19 Aug 2026 17:28:39 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a85cb8f-8faa-0a2a0a5109dd-0a2a4508bc0c-44 for ; Wed, 19 Aug 2026 17:28:39 +0200 Received: from [209.85.210.175] (helo=mail-pf1-f175.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a85cba6-f659-0a2a45080019-d155d2afd55e-3 for ; Wed, 19 Aug 2026 17:28:39 +0200 Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-84a4d8fd6ecso1218101b3a.1 for ; Wed, 19 Aug 2026 08:28:39 -0700 (PDT) Received: from wig-Precision-3660.. (125-227-154-99.hinet-ip.hinet.net. [125.227.154.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851d3617434sm787575b3a.29.2026.08.19.08.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2026 08:28:37 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787153318; x=1787758118; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qexHZlqSFqOa+wu3jRbx9Js4zQ/0pHMbVWziLO2Koe8=; b=fvjeIXfqWr7lemEYCDFilUOYi0yQOdInrpXfqrQiShNPfmmQ0nMmlUapUqKye7H4aJ hUfD2EqmNb4r3lSBYTzDI8HBoxL4HuO3ngqhPnYwwqYvTxJJRKrq5r7yVf5P+Tm3l+b0 bFNriKoAq05PvxExmuYrx9NscTe0j3KKtGVWGYfXMozJz/BJ3kkprPeeAIzOec5XVHUL Dkp/LGgTxnSEglAqUUoJMv5ie94P40V9Dag8fx35u2K46CBradPHQ8PPAX6PPbnWUXl4 t8Oe7YpPrCjEwHRkRw+gFN6RuxT1QtNMCTumu6BZfpAVKV2gOLBol+ZJ4S82qO+fiqS5 M4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787153318; x=1787758118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qexHZlqSFqOa+wu3jRbx9Js4zQ/0pHMbVWziLO2Koe8=; b=AIGD12ByyomQi+ZQB6tpdaKPPHNmHdN9ruPcjW5FtwQ8BExZvFuCXyzhKHGKgxgML3 2oVQdSM2B5ghDmTe6BQLWlWAILLP09ij54WpJ9EypAAltW6zTOTN3PZlThr3Mj7aV1mD KqFNxqal6BvDL2I0QeeJQHJwXjs7T3xoxLh6LgaClSRQvLDEBbONJy5zvZb+5TiTJxsx T1enbubVErZp3LCQKWiB9al9s1o+Atx4Ddb5OtKWM6YGxtqhwXyTBLw2TEbecpy9PA60 SMvNQ9OBhVfQSnkmRXY3b02IoIr0ZLJi2ZtHKXL8OnkIeXm+skMCXfzW0EIJbopgh5oM /Iqw== X-Gm-Message-State: AOJu0Yw//TKlln6NmyB01mNH+lZKBjhdnZ2KQDgoCgaHDU0sF62UGvwp lzyOJOCqZwrjGKVcWXxD7jVoQ55e5OUDAD04kwZ0eO40RdBZnyUErES3KT2hHAJM X-Gm-Gg: AR+sD13F+DJYckygfntXMNV+cRFI/fQeHgeqrI95cCRsoaMnlDck6KCwLcTFhnSX/lG n5FJX98om1sZ2H7r5xrOwB+BqpV8ri9kS32BjoagV/t9A8Jw+JsGwi3FItXMNAnrUouEIGM2IHH s4YfrCS6A5qcwind/j7xyWlxk8VyT6dIVPB9OzlJUeFVtfT9mUlYcgU/vt3cHE+4hgle4Nbw9WG HqLUGzbFNKuup8A+8iSrcixlfFG5iMQ6OQq3ZKL8uI/hyq1Ug7s5K4PMVMulqDOeRZhGdpnURQz 8mVyFfBZYkelKGa6C2GvtA3i70xYy1pqv3j5+ZitjEN6X+hux3Mn7sgz9GIAIji7n2ZyC2aABaA etD/rpS9bYU/kh4yq2WOKjZ1wPFaC1uU9GTSEbRO/vRIENPFjPachjSg1LIf6MbeVQ1SbJss6T3 pBVujYd0WADp8AatjWCH0S9/ga7q0sGHZOXS3aHenWz2zvmKjOLy7ifDKbt3NjKzqx50kW7fFsa yAijTfxFWdKGfHqvPcNdzfC9U9UkveRkeNZYPY3ltk= X-Received: by 2002:a05:6a00:f05:b0:845:e9e8:645c with SMTP id d2e1a72fcca58-851d3847482mr9283456b3a.6.1787153317737; Wed, 19 Aug 2026 08:28:37 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , John Ernberg , Peng Fan Subject: [PATCH v4 4/4] MAINTAINERS: add myself as reviewer of i.MX8M related patches Date: Wed, 19 Aug 2026 23:28:21 +0800 Message-ID: <20260819152821.3361898-5-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260819152821.3361898-1-onlywig@gmail.com> References: <20260819152821.3361898-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1787153319-D4D7087B-AB079D30/0/0 X-purgate-type: clean X-purgate-size: 835 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787153345687158500 Content-Type: text/plain; charset="utf-8" I wrote the i.MX8M platform and UART support and can help review patches touching these areas. Signed-off-by: Wig Cheng Reviewed-by: Michal Orzel --- Changes in v4: - No changes. MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4dd97ffcad..c60afc93a5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -365,6 +365,13 @@ F: tools/misc/xenhypfs.c F: xen/common/hypfs.c F: xen/include/xen/hypfs.h =20 +IMX8M SUPPORT +R: Wig Cheng +F: xen/arch/arm/arm64/debug-imx-uart.inc +F: xen/arch/arm/include/asm/imx-uart.h +F: xen/arch/arm/platforms/imx8m.c +F: xen/drivers/char/imx-uart.c + IMX8QM/QXP SUPPORT R: John Ernberg F: xen/arch/arm/platforms/imx8qm.c --=20 2.43.0