From nobody Fri Aug 28 16:03:14 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=1786727081; cv=none; d=zohomail.com; s=zohoarc; b=NSQwetdbjgBX+cBO37Az2cWOUQqUNb4qhKXNZrUaVZQaCddTbPTu7bEBxLx8yArCVjqsvW6DYobKYWFOPnT7rvLXHQrThS/G/OxuNgeqlkr2ikROMa3MAE4JU53t7CClo3f4clRN1Tma+GP3H9mLb1GO0iY3GZh+MtCW6t3UtKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786727081; 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=oQ2MamIsZ2KeLKkmmqjUHALpj5utjzxXi4uD6i0RX6I=; b=R0VZAsp4+fsCFrqQnhWuz3jBT9bOGQzq4qtNYV1qjMmJyR5kW0yJHgQJkvUig2PRlEw9pS+7X5T9OZoEHu4zwnLFalKharGe7DIlD+jHF9yizywub6/s3AH9BrughI5u4vW6N0umDDzM4b3SB7BDfV9B1unUlIN4uaTUat3ngF0= 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 1786727081116388.8270842620392; Fri, 14 Aug 2026 10:04:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1391303.1631203 (Exim 4.92) (envelope-from ) id 1wuvKM-0004ts-TG; Fri, 14 Aug 2026 17:04:18 +0000 Received: by outflank-mailman (output) from mailman id 1391303.1631203; Fri, 14 Aug 2026 17:04:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wuvKM-0004rr-M5; Fri, 14 Aug 2026 17:04:18 +0000 Received: by outflank-mailman (input) for mailman id 1391303; Fri, 14 Aug 2026 16:26:01 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wuujJ-0008H9-Qq for xen-devel@lists.xenproject.org; Fri, 14 Aug 2026 16:26:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wuujJ-00GchW-7i for xen-devel@lists.xenproject.org; Fri, 14 Aug 2026 18:26:01 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7f418b-e002-0a2a0a5209dd-0a2a4502c19c-8 for ; Fri, 14 Aug 2026 18:26:01 +0200 Received: from [209.85.215.172] (helo=mail-pg1-f172.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7f418e-6ca4-0a2a45020019-d155d7aca958-3 for ; Fri, 14 Aug 2026 18:25:51 +0200 Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-cbe6295f05bso1697696a12.1 for ; Fri, 14 Aug 2026 09:25:51 -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 d9443c01a7336-2d3aeb29f62sm12585735ad.38.2026.08.14.09.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 09:25:48 -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=1786724750; x=1787329550; 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=oQ2MamIsZ2KeLKkmmqjUHALpj5utjzxXi4uD6i0RX6I=; b=XHImwinSQiCwRKAPYBp9NiB5dTlp0XnOkr+5BZgr7+y4tEd1ooUipd1W87Do3hKFym DMlorPMJLORJnwj4bYb8TgkWYwfkONfABCOMnA2/4h/T8wGTaFMKyyM4lmsPigBXGwP6 lnB/6rcLBXC1N9d89cLqa1ME6gh7CbXLDppmtZN4VrSI5RjnKZp9q/cfexTHx7rhaBz0 OnYUYaRyIf35GQUoTUXhrPjVtofO4dh76O/F+3CiuoOgWsr0IGwjpfsuiLOjt2d01fJ3 MDjLNpUyrsWeNjE6BnKikh4diwpsZBfalBlVu4fW0l0WRq8fQeA2zfxJtoJEkGT5U2Qr 57QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786724750; x=1787329550; 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=oQ2MamIsZ2KeLKkmmqjUHALpj5utjzxXi4uD6i0RX6I=; b=pTnyrUk41dGPQqMtm+HYVs3IPxsT8Zk2AkrXpZTq8GrQOlg4J2KZtyNsxmT05T8bIV UmsxzmtuZL9Dy8kjvyPL+2CH4LHWDXixwDPeIoRLlesVsPUQlN7XrGdqssuX4eZwD9Oq OFQW2yzu8NW0/+LNn0yVO1R8klP9VjJx569B+ZURcW8r740mYIeumiP7nTZ/+QgRAfPe LBkiuQcTLuXcOoI6WB93KNxgnZ2AkmCOFm8LpaPdqXGKU8U+KVUs2MgqgcE7pElT55x+ WcEZZcVjzKK+UiruD8IqCH1HR2EnS2ZIM+v0v/jf6D6ls1ykGGdn7DZSKuD6/soHev6J 2n5Q== X-Gm-Message-State: AOJu0YwWApHprJd5IwK49yMas/6cv8XKPuPYNDf/1SPDFsJ21LjZevam hvA1CXTIg0zi+7PzemEX6ZCEVu80jRx0OevBnxcCfeUEM0zCSl/TGgKV7TbIDH5I X-Gm-Gg: AR+sD107ELJm0UdLz6muR3Dd201Mq9gVxV+6iTpw3SZWfPNcmHgAuIEkRsZrSzg6Zkx fNyuKtQHHv9O4GRebvJAngh8vE7WIz7b5SM29zmuWXQeaHihO4TD5OYRFnmlQNCeTeAe3vmu1E2 D5NSDyesDG9s3iLhievghqTKE4Gi5+ZJyNJQ+pKc0hs04FSfrhMAeZDpMbN8kTyOMHcJUnHT0yf hUr1VdRP8DW6nZV+M9oDXPAdMHuNDm7Vlesuy134D5VsHdMb7nBudaQfB6jBqTGCgBATuV1Es0N 6WoIRQlUTqzeJ3tbeiA3/n1TwBB4gMLAhqd6z6kovYKwCRFA73YPkh0Rem6Iz42FzUkBYZ5mqEZ GRv/A8X5DvsK6MW1ChWdJt5pcgeWTdLl9voBa+Ev51ffN/JWO0u9Upgnyk9BtGX9T9PG09X01bF N5LEWSkrQiuCX04xH75qXdy4A6u0NLNi5W/9zd5Kl/Lvi7b6K95+6qfM/RA6kgRzFMRivGB18Mb 6kuwJfsLEb1uNaffZSq3A+y2id2tcSh X-Received: by 2002:a17:903:1aa3:b0:2cc:89ce:2f07 with SMTP id d9443c01a7336-2d3afdacd25mr70506165ad.1.1786724749790; Fri, 14 Aug 2026 09:25:49 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , John Ernberg , Peng Fan , Wig Cheng Subject: [PATCH 1/3] xen/char: add classic i.MX UART driver Date: Sat, 15 Aug 2026 00:25:33 +0800 Message-ID: <20260814162535.331459-2-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260814162535.331459-1-onlywig@gmail.com> References: <20260814162535.331459-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1786724752-F16AF2AC-B7559739/0/0 X-purgate-type: clean X-purgate-size: 10603 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1786727082123158500 Content-Type: text/plain; charset="utf-8" Add a console driver for the classic i.MX UART IP ("fsl,imx6q-uart" compatible), as found on the i.MX6/7/8M families. 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. This is needed for the i.MX8M family, whose UART IP differs from the LPUART used on i.MX8QM/8QXP. Signed-off-by: Wig Cheng --- xen/arch/arm/include/asm/imx-uart.h | 62 ++++++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/imx-uart.c | 227 ++++++++++++++++++++++++++++ 4 files changed, 298 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..ad4b0b06ff --- /dev/null +++ b/xen/arch/arm/include/asm/imx-uart.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/include/asm/imx-uart.h + * + * Register definitions for the classic i.MX UART IP + * ("fsl,imx6q-uart" compatible, used on i.MX6/7/8M families). + * + * Register layout taken from Linux drivers/tty/serial/imx.c. + * + * Copyright 2026 Open-EP (E-Paper) Community + */ + +#ifndef __ASM_ARM_IMX_UART_H__ +#define __ASM_ARM_IMX_UART_H__ + +#define URXD0 0x00 /* Receiver Register */ +#define URTX0 0x40 /* Transmitter Register */ +#define UCR1 0x80 /* Control Register 1 */ +#define UCR2 0x84 /* Control Register 2 */ +#define UCR3 0x88 /* Control Register 3 */ +#define UCR4 0x8c /* Control Register 4 */ +#define UFCR 0x90 /* FIFO Control Register */ +#define USR1 0x94 /* Status Register 1 */ +#define USR2 0x98 /* Status Register 2 */ +#define UTS 0xb4 /* Test Register */ + +#define URXD_CHARRDY (1U << 15) +#define URXD_RX_DATA 0xff + +#define UCR1_UARTEN (1U << 0) +#define UCR1_RRDYEN (1U << 9) /* Receiver ready interrupt enable */ +#define UCR1_TRDYEN (1U << 13) /* Transmitter ready interrupt enable = */ +#define UCR1_RXDMAEN (1U << 8) +#define UCR1_TXDMAEN (1U << 3) +#define UCR1_ATDMAEN (1U << 2) + +#define UCR2_SRST (1U << 0) /* 0 =3D issue software reset */ +#define UCR2_RXEN (1U << 1) +#define UCR2_TXEN (1U << 2) + +#define USR1_RRDY (1U << 9) /* Receiver ready */ +#define USR1_TRDY (1U << 13) /* Transmitter ready */ + +#define USR2_RDR (1U << 0) /* Receive data ready */ +#define USR2_ORE (1U << 1) /* Overrun error */ +#define USR2_TXDC (1U << 3) /* Transmission complete */ +#define USR2_TXFE (1U << 14) /* Transmit FIFO empty */ + +#define UTS_TXFULL (1U << 4) +#define UTS_RXEMPTY (1U << 5) +#define UTS_TXEMPTY (1U << 6) + +#endif /* __ASM_ARM_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..5ae8c13c40 --- /dev/null +++ b/xen/drivers/char/imx-uart.c @@ -0,0 +1,227 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/drivers/char/imx-uart.c + * + * Driver for the classic i.MX UART IP ("fsl,imx6q-uart"), as found on + * the i.MX6/7/8M families (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); + + if ( imx_uart_read(uart, USR1) & USR1_TRDY ) + 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 baudrate/format settings: only make sure the + * UART and both directions are enabled, DMA and interrupts are off. + */ + ucr1 =3D imx_uart_read(uart, UCR1); + ucr1 &=3D ~(UCR1_RRDYEN | UCR1_TRDYEN | 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 %d\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 Fri Aug 28 16:03:14 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=1786727082; cv=none; d=zohomail.com; s=zohoarc; b=gmWu02XKUorks9FMODsdnQH5Xnh++EyOy7hrlBcxFLvUXXJZ+SNHGGLRyLkQI9HF2vN9rQmPep6w+QjFfB6YZfNhKYbRFMR9SWSLxc2xubL5MgAO3AmTSShYIAD6jOCggWMMqH00WOkWc9qz2swCHBpIEAAKSxMQyC1GoxEGjLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786727082; 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=jcuSXhXunYsiZRxzXY1y0OZN0WvmTzxBkolAPYMDdmA=; b=QsSs9DhQmHMM3feGLzlHFlMozPOXl84gK9LxCL5Fa1exQOSoreqV+fXE9KFYARgQqUo85BQN37y0Kf68mMrxxgBkZPzFVmDoF0/LMCNLGqzQYhyRzTV4WjbpAwAQhJDuQ1/S3UzfYTAYu1sp4y67hTLShFRV2uyKLaeYxIq0Oas= 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 1786727082881573.5372947848822; Fri, 14 Aug 2026 10:04:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1391300.1631192 (Exim 4.92) (envelope-from ) id 1wuvKM-0004kH-Cl; Fri, 14 Aug 2026 17:04:18 +0000 Received: by outflank-mailman (output) from mailman id 1391300.1631192; Fri, 14 Aug 2026 17:04:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wuvKM-0004k8-88; Fri, 14 Aug 2026 17:04:18 +0000 Received: by outflank-mailman (input) for mailman id 1391300; Fri, 14 Aug 2026 16:25:56 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wuujE-0008GX-MJ for xen-devel@lists.xenproject.org; Fri, 14 Aug 2026 16:25:56 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wuujE-006hmA-3L for xen-devel@lists.xenproject.org; Fri, 14 Aug 2026 18:25:56 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7f4190-2eae-0a2a0a5409dd-0a2a4506afde-4 for ; Fri, 14 Aug 2026 18:25:56 +0200 Received: from [209.85.214.171] (helo=mail-pl1-f171.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7f4192-195a-0a2a45060019-d155d6abb008-3 for ; Fri, 14 Aug 2026 18:25:55 +0200 Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2d5335cf904so3017855ad.2 for ; Fri, 14 Aug 2026 09:25:55 -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 d9443c01a7336-2d3aeb29f62sm12585735ad.38.2026.08.14.09.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 09:25:53 -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=1786724754; x=1787329554; 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=jcuSXhXunYsiZRxzXY1y0OZN0WvmTzxBkolAPYMDdmA=; b=sQHPcxWM0mi3kvu5QDlWR22xDXI78wrZCLn0ZS7ZY8XVAAHaAF/XsQ8IJzmcRcZ3Cl Rrl4kQMQ4ggTZt4aQfGEMmpgOwLCGXJ2d3wYB0XeoWq/ZJYNki9imXqjVY55UeH5nthk jT/bcHrgmrvfZDFwqiqCuNfOoWMa3MlhMebAz4Ita82bB9jIkSbq97piGjiATYUx72H/ CdPeG4AZvqFT93MrGssGcMgrmPxynxPTJvNmyzQkyAUA3JljEWpVcAYi62UZvUIef8vn MbF47qkxXoujeCeuVoFnBdRmtQ7vN0E2vjw84JE0Bj/y1PreTy7iJvvrkd0irMuVl0Pu iQEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786724754; x=1787329554; 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=jcuSXhXunYsiZRxzXY1y0OZN0WvmTzxBkolAPYMDdmA=; b=cw4+QvUzj636ZNk4aKtgJU+pqE283blBMLtyPjj09nQGKlpQb8Zl+lupJ5BblZxKYy aH8D77fSFdgS2XTYKx8ts1ISs5W+SZz9lWr8TWFJc+1XJ4A2R93fr24XfuEm4AxNO6FX XSIrV2mwEg8hKxbG7d2Bl37pJvCIJL64GWtucZWYHOWbZbKhiDDu8AIIS1unR5qmk7ur 7vuARHUsrKPv8T8bSVHcHtOHvrucCdaVUHJaAdDcQOBX+u5EGIn5sb0KBN4BbD9UoJ6P XRF7/o9YbqJojnp2mQreYZps6NOeOgSRF7qLOBCz/7IGw2m9MrhSryohZPHccIG/WHpr 8ybg== X-Gm-Message-State: AOJu0YzjrL+G0rEdLSsSL1axnpAo8BmCmnywZ++TNDEHaEmHVsBRS/h+ Wh+7SR6gGmawU8rKwxt47uer6mlAn9cTMpL5EJtCJ8bpgj/aTwGJzMMSvaajeWL4 X-Gm-Gg: AR+sD10xawtm20mU4nrW9IRth/mWCO2LUykqWW+xrMz2B4/0NUm7RLrSpo6wvYjfCNW ffUffZQs0iwIS4otDGqyIiVWhfPJkn/4d0umYT2j97HRMtkQVmL/iHRN8HWTajLFRbru8lX00FJ A6TD6CCCw+khIqv6fo5As3IWzL0r6NtltlQn5dqJBqZjBvS/9MuEZL3vhEBQ2tW8FRb1R1pj3Fo Uf0Cc7UX6j9Ti7L+42e3e6D3PZo8hbAfFg7qSkGhBhsOl5pxz+i45jCk0wuXrcupsEAy5Fr7pY5 sneWLYijlhcLtVtw502hD/LSfHMQ11TF3NmcESAahd8G1mZms9b/xYQYaqo1mWH/TB4mgSpMB9e tHxg0bXLNDmlK5shLnkBM70+3+BVe7dgbgIugBlDF5So5DAB39umV1vndZrwH/t/gAxa43iwTQR u/4iIkN6nD68ImhDPMvlRnY1ohW429aYUGla0gOYmn2WRVO+mfw5X6I9caK3WiqsA+OWBYmgrWy SZ5XIVV6uVDlOIckgRv/JqFxMlYE3Ew X-Received: by 2002:a17:902:d552:b0:2ca:caa5:9c04 with SMTP id d9443c01a7336-2d3b0d2c159mr94259235ad.23.1786724753801; Fri, 14 Aug 2026 09:25:53 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , John Ernberg , Peng Fan , Wig Cheng Subject: [PATCH 2/3] xen/arm64: add early printk for the classic i.MX UART Date: Sat, 15 Aug 2026 00:25:34 +0800 Message-ID: <20260814162535.331459-3-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260814162535.331459-1-onlywig@gmail.com> References: <20260814162535.331459-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1786724756-F627077B-F0519CC6/0/0 X-purgate-type: clean X-purgate-size: 3066 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1786727083962158500 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 --- xen/arch/arm/Kconfig.debug | 12 +++++++++ xen/arch/arm/arm64/debug-imx-uart.inc | 39 +++++++++++++++++++++++++++ 2 files changed, 51 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..80ac647f5e --- /dev/null +++ b/xen/arch/arm/arm64/debug-imx-uart.inc @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/arm64/debug-imx-uart.inc + * + * Early printk for the classic i.MX UART IP (i.MX6/7/8M families). + * 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 */ + bne 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 Fri Aug 28 16:03:14 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=1786727086; cv=none; d=zohomail.com; s=zohoarc; b=QKnmal7TqjCln4fQODhPRyqql5k03Pc79bCSFivNdv9Z9yH2MSKWutPSRkQFKKwFGgCUnWmgng9ikSmXgVVAUU3ieIu9VQQx8PxH8iLE7joutL5qqOCNe1q27aiiys2gFMlsuvfwbQcBqTBN3Djiy40erS7Dn9p4PA1/65lZYuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786727086; 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=pANIpxy73mwji3KETZ0SQ4NuCZV/pLf/fluSXSojwX0=; b=L/t4IcibBopzNsNio//q3w1HTJepI6YOt01logYws+/T5qdzf/cW6z3gSl7/BhdMDwISoihjMP7OGyL5dUeHVYxNjrUqW29RuUm9471bjz0ZvZVzOCWPNm0Tv0Cqnl/v1Ejz3dET5/i+2VWJzdeFWsKuaQD/plfXHMNmp4rxZFQ= 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 178672708669660.94053549263879; Fri, 14 Aug 2026 10:04:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1391302.1631198 (Exim 4.92) (envelope-from ) id 1wuvKM-0004oW-Kj; Fri, 14 Aug 2026 17:04:18 +0000 Received: by outflank-mailman (output) from mailman id 1391302.1631198; Fri, 14 Aug 2026 17:04:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wuvKM-0004n9-EV; Fri, 14 Aug 2026 17:04:18 +0000 Received: by outflank-mailman (input) for mailman id 1391302; Fri, 14 Aug 2026 16:26:00 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wuujI-0008H0-9x for xen-devel@lists.xenproject.org; Fri, 14 Aug 2026 16:26:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wuujH-006hmA-N6 for xen-devel@lists.xenproject.org; Fri, 14 Aug 2026 18:25:59 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7f4188-2eae-0a2a0a5409dd-0a2a4505d3be-14 for ; Fri, 14 Aug 2026 18:25:59 +0200 Received: from [209.85.214.179] (helo=mail-pl1-f179.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7f4196-4cb1-0a2a45050019-d155d6b3e940-3 for ; Fri, 14 Aug 2026 18:25:59 +0200 Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2ce7d2adef4so21025855ad.3 for ; Fri, 14 Aug 2026 09:25:59 -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 d9443c01a7336-2d3aeb29f62sm12585735ad.38.2026.08.14.09.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 09:25:56 -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=1786724758; x=1787329558; 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=pANIpxy73mwji3KETZ0SQ4NuCZV/pLf/fluSXSojwX0=; b=bv5hcZOBpC8NxwXfQFp5eC6/oYyoISXaCw/FAe5ISCfYNR1pWJIR4axA6bWuxpkmEO odzIsEi0C2AKCutMsyxv8iHwTsw/cYtJakBB2enEq2IaEPeoJg5vs1bcc8aZiMnPe477 u9D9vHudsiQO7kAanqQhzgA1DsiWDyFsD8BWkigATyLWfXfZueCqdKZvNqRhUjCK09k7 MMjIjgF5ojj+ZFordewlofj3WJRk+UewLIdjiMYKm4js6xvxBCUd7BcRZq4uhvsfqFlo BqXmYGa2uoFd+qtHjI9CQD+9qujnlGbZJhpM6gotJ90eTem4R6gnvn4YLULomMCYUr3B hv4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786724758; x=1787329558; 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=pANIpxy73mwji3KETZ0SQ4NuCZV/pLf/fluSXSojwX0=; b=HEX4ECJaZQjS5GUKijDAWNA2J2R1dLBaMafS2rYd7CqAR6YPpblhX2Cke4fZuhmDER OTRSdehB4fs/nuYJGlv6HTETMA7G3TSgFDnkMpwpEtW7UQu9oiJ3DbO/Xd1Wh6mwHICO hfO9nryXzzKgSeY9+W307r35IwKgOSHMQjK3Kb2w1xVrWLjlEVqfcWNcud6zLhQ39FEB KzJqk+sfb5CdGJpq0VrzjqC8VkFcFRs5s2K6OXxvOuLrWO0McSV00rEdjWhvS+26Pt+0 ZN6z/yZvz5WFr9fwVF8nETxHjh7NYp7E6tcP46vbr3ARQ0HfDUaco1dAt2/eO8tliFPg ji4w== X-Gm-Message-State: AOJu0YxRkd9IE6sCrJE+2x2eQS5gSC0WfGNbe6fcAfEJWZHAyXuUOk1E Ctq4q/EXHL78aThum1MOCR35i41SmNg+UlTDHWQHOP9+00dtusmXRh5NsnazCIkG X-Gm-Gg: AR+sD101eE5x5DvFWHGBRgpP9x9Fk+VXMsR5utNnBQaJ40SFK2JQnSZ1NVPk7/90QeA RTbGGUagIxAsZjvutozV/9MmAAQNO5lQPFhWHKuLQMb0cm5d8BXLrj1nFMCR5Bv4f79+lsyukog R7IUZtjIr9xYpN7I9F/FpZoIALy3l8h+X+E7395RcOa+TuuwJpQO2wpmeXMXenxskIE2aIhe7Fm CQw8wiqld8FuwKIws11mEFbNBv4KHck0nEPhQCTuJh1blp6PIHhbRGEhl7Wy+xGT/bN0m8d5LwY MmiB7wIr2vPZdpM9vQwMC8zPpL6OdVsGV/pweGsKBYQJ/eJ7KCA4G4wdebaBM/dwD/G2VXYFx4z 7T4WnmyaDFHLBsVNswTfJTVwbI6T1wlkYs//wBwDOPuCuzD9ZshGinGm3TnltKqLTVVGNGxCISL 7txpIt69HQFbVpF0/RbyrLWrbQ3gNCQWnZRc5x9qtD05refbf/jYMuSc6Tfzwr8nNmpJnl0F2Z8 uPduDa/z8Kk/EexBuHDF0ob63wZTQmZ X-Received: by 2002:a17:903:1103:b0:2c1:98b7:ecf3 with SMTP id d9443c01a7336-2d3b0cd3392mr88100305ad.23.1786724757484; Fri, 14 Aug 2026 09:25:57 -0700 (PDT) From: Wig Cheng To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , John Ernberg , Peng Fan , Wig Cheng Subject: [PATCH 3/3] xen/arm: add i.MX8M platform support Date: Sat, 15 Aug 2026 00:25:35 +0800 Message-ID: <20260814162535.331459-4-onlywig@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260814162535.331459-1-onlywig@gmail.com> References: <20260814162535.331459-1-onlywig@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1786724759-738BE2A1-0552155B/0/0 X-purgate-type: clean X-purgate-size: 5089 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1786727088072158500 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, DDR frequency scaling, SRC (M-core remoteproc), SoC info, NoC QoS and BBSM tamper status. There is no public specification for these calls; the function IDs are taken from the upstream and vendor kernels. Forward this reviewed set of calls from the hardware domain, following the whitelist model of the i.MX8QM platform. CPU frequency scaling is denied because the hardware domain cannot make an informed decision, and any unknown function ID is rejected. Signed-off-by: Wig Cheng --- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/imx8m.c | 116 ++++++++++++++++++++++++++++++++ 2 files changed, 117 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..dc49e754ee --- /dev/null +++ b/xen/arch/arm/platforms/imx8m.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/platforms/imx8m.c + * + * i.MX 8M family setup + * + * Copyright 2026 Open-EP (E-Paper) Community + */ + +#include +#include +#include + +static const char * const imx8m_dt_compat[] __initconst =3D +{ + "fsl,imx8mp", + "fsl,imx8mq", + "fsl,imx8mm", + "fsl,imx8mn", + NULL +}; + +/* + * SiP SMC function IDs used by the i.MX8M Linux drivers. There is no + * public specification for these; the IDs and names are extracted from + * the upstream and vendor kernels (see drivers/soc/imx, drivers/devfreq, + * drivers/remoteproc, drivers/firmware/imx). + */ +#define IMX_SIP_GPC 0xC2000000 /* GPC power-domain control */ +#define IMX_SIP_CPUFREQ 0xC2000001 +#define IMX_SIP_DDR_DVFS 0xC2000004 /* DRAM frequency scaling */ +#define IMX_SIP_SRC 0xC2000005 /* SRC: M-core remoteproc start/st= op */ +#define IMX_SIP_GET_SOC_INFO 0xC2000006 +#define IMX_SIP_NOC 0xC2000008 /* NoC QoS priority setup */ +#define IMX_SIP_BBSM 0xC200000D /* BBSM tamper status */ + +static bool imx8m_smc(struct cpu_user_regs *regs) +{ + uint32_t function_id =3D get_user_reg(regs, 0); + 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; + } + + switch ( function_id ) + { + /* + * All of these manage hardware that belongs to the hardware domain + * (power domains, DRAM controller, M-core, NoC, secure RTC) or are + * read-only queries. Forward them. + */ + case IMX_SIP_GPC: + case IMX_SIP_DDR_DVFS: + case IMX_SIP_SRC: + case IMX_SIP_GET_SOC_INFO: + case IMX_SIP_NOC: + case IMX_SIP_BBSM: + break; + + /* + * CPU frequency scaling: the hardware domain does not see the whole + * system and cannot make an informed decision, so deny it (matches + * the i.MX8QM platform). + */ + case IMX_SIP_CPUFREQ: + return false; + + default: + gprintk(XENLOG_WARNING, "imx8m: smc: Unknown function id %x\n", + function_id); + return false; + } + + arm_smccc_1_1_smc(function_id, + get_user_reg(regs, 1), + 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