xen/arm: add i.MX8M platform and UART support
cover xen/arm: add i.MX8M platform and UART support
This series adds Xen support for the NXP i.MX8M family (i.MX8MP / MQ / MM / MN). It provides the console UART driver, its early printk, and the platform glue (SiP SMC whitelist for the calls the dom0 kernel issues to TF-A).
Tested on i.MX8MP (4x Cortex-A53, GICv3): dom0 boots to login on the hypervisor console, and a domU starts with a PV disk and virtio devices running a full Wayland distro. This addresses the concern raised on the 2019 i.MX8MQ RFC that only a ramfs dom0 had been shown.
Notes for reviewers:
- Unlike i.MX8MQ, the i.MX8MP device tree uses the GIC as the root interrupt controller (interrupt-parent = <&gic>), so no device-tree workaround is needed and power domains keep working.
- The i.MX8M family has no SMMU, so device passthrough relies on the 1:1 direct-mapped hardware domain.
- The SiP SMC whitelist forwards only the function IDs the dom0 kernel actually issues (extracted from the upstream and vendor kernels); no call outside the whitelist was observed at runtime.
Wig Cheng (3):
xen/char: add classic i.MX UART driver xen/arm64: add early printk for the classic i.MX UART xen/arm: add i.MX8M platform support
xen/arch/arm/Kconfig.debug | 12 ++ xen/arch/arm/arm64/debug-imx-uart.inc | 39 +++++ xen/arch/arm/include/asm/imx-uart.h | 62 +++++++ xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/imx8m.c | 116 +++++++++++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/imx-uart.c | 227 ++++++++++++++++++++++++++ 8 files changed, 466 insertions(+) create mode 100644 xen/arch/arm/arm64/debug-imx-uart.inc create mode 100644 xen/arch/arm/include/asm/imx-uart.h create mode 100644 xen/arch/arm/platforms/imx8m.c create mode 100644 xen/drivers/char/imx-uart.c
Signature · 1 line
2.43.0
PATCH 1/3 xen/char: add classic i.MX UART driver
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.
--- 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
xen/arch/arm/include/asm/imx-uart.h new file +62 -0
@@ -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 = 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: +*/
xen/drivers/char/Kconfig +8 -0
@@ -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
xen/drivers/char/Makefile +1 -0
@@ -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
xen/drivers/char/imx-uart.c new file +227 -0
227 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 3/3 xen/arm: add i.MX8M platform support
In reply to Wig ChengAdd 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.
--- 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
xen/arch/arm/platforms/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_ALL_PLAT) += sunxi.o obj-$(CONFIG_ALL64_PLAT) += thunderx.o obj-$(CONFIG_ALL64_PLAT) += xgene-storm.o obj-$(CONFIG_ALL64_PLAT) += brcm-raspberry-pi.o +obj-$(CONFIG_ALL64_PLAT) += imx8m.o obj-$(CONFIG_ALL64_PLAT) += imx8qm.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp-eemi.o
xen/arch/arm/platforms/imx8m.c new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 2/3 xen/arm64: add early printk for the classic i.MX UART
In reply to Wig ChengAdd 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.
--- 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
xen/arch/arm/Kconfig.debug +12 -0
@@ -44,6 +44,14 @@ choice Say Y here if you wish the early printk to direct their output to a i.MX LPUART. + 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
xen/arch/arm/arm64/debug-imx-uart.inc new file +39 -0
@@ -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 <asm/imx-uart.h> + +/* + * 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: + */
Signature · 1 line
2.43.0
Re: [PATCH 2/3] xen/arm64: add early printk for the classic i.MX UART
Quoted 54 lines · Wig Cheng
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 <[email protected]>--- 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.incxen/arch/arm/Kconfig.debug +12
-0@@ -44,6 +44,14 @@ choice Say Y here if you wish the early printk to direct their output to a i.MX LPUART. + 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_MVEBUxen/arch/arm/arm64/debug-imx-uart.inc new file +0
-0
xen/arch/arm/arm64/debug-imx-uart.inc line 3
Quoted 3 lines
xen/arch/arm/arm64/debug-imx-uart.inc new file +3
-0@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * xen/arch/arm/arm64/debug-imx-uart.inc
This can go stale. Please drop.
xen/arch/arm/arm64/debug-imx-uart.inc line 5
Quoted 2 lines
xen/arch/arm/arm64/debug-imx-uart.inc new file +2
-0+ * + * Early printk for the classic i.MX UART IP (i.MX6/7/8M families).
Don't mention 6 and 7 in a arm64 driver.
xen/arch/arm/arm64/debug-imx-uart.inc line 11
Quoted 6 lines
xen/arch/arm/arm64/debug-imx-uart.inc new file +6
-0+ * The UART is expected to be fully initialized by the bootloader. + * + * Copyright 2026 Open-EP (E-Paper) Community + */ + +#include <asm/imx-uart.h>
This header contains non-asm compatible macros. Please fix.
xen/arch/arm/arm64/debug-imx-uart.inc line 22
Quoted 11 lines
xen/arch/arm/arm64/debug-imx-uart.inc new file +11
-0+ +/* + * 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 */
b.ne please
Quoted 7 lines
xen/arch/arm/arm64/debug-imx-uart.inc new file +7
-0+.endm + +/* + * UART transmit character + * xb: register which contains the UART base address + * wt: register which contains the character to transmit + */
xen/arch/arm/arm64/debug-imx-uart.inc line 39
Quoted 10 lines
xen/arch/arm/arm64/debug-imx-uart.inc new file +10
-0+.macro early_uart_transmit xb, wt + str \wt, [\xb, #URTX0] /* -> Transmitter register */ +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */
Other than that, it looks good.
~Michal
Re: [PATCH 1/3] xen/char: add classic i.MX UART driver
In reply to Wig ChengQuoted 2 lines · Wig Cheng
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
You often mention i.MX 6 and 7 but guard the driver on Arm64. Please do not mention them if you only intend to support/test i.MX 8.
Quoted 7 lines
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.
Quoted 6 lines
Signed-off-by Wig Cheng <[email protected]>--- 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 ++++++++++++++++++++++++++++
Please add entry to MAINTAINERS for this file under ARM
xen/arch/arm/include/asm/imx-uart.h line 1
Quoted 11 lines
4 files changed, 298 insertions(+) create mode 100644 xen/arch/arm/include/asm/imx-uart.h create mode 100644 xen/drivers/char/imx-uart.cxen/arch/arm/include/asm/imx-uart.h new file +1
-0@@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
Can this be GPL-2.0 only?
xen/arch/arm/include/asm/imx-uart.h line 3
Quoted 2 lines
xen/arch/arm/include/asm/imx-uart.h new file +2
-0+/* +* xen/arch/arm/include/asm/imx-uart.h
This can go stale. Please drop.
xen/arch/arm/include/asm/imx-uart.h line 13
Quoted 10 lines
xen/arch/arm/include/asm/imx-uart.h new file +10
-0+* +* 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__
Should be ASM_IMX_UART_H
xen/arch/arm/include/asm/imx-uart.h line 20
Quoted 7 lines
xen/arch/arm/include/asm/imx-uart.h new file +7
-0+#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 */
Given that this is not a verbatim 1:1 copy from Linux (no need for it to be), please do not define macros that are unused.
xen/arch/arm/include/asm/imx-uart.h line 27
Quoted 7 lines
xen/arch/arm/include/asm/imx-uart.h new file +7
-0+#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)
Please use BIT(n, U)
Quoted 72 lines
xen/arch/arm/include/asm/imx-uart.h new file +35
-0+#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 = 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: +*/ xen/drivers/char/Kconfig +8
-0@@ -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 yxen/drivers/char/Makefile +1
-0@@ -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.oxen/drivers/char/imx-uart.c new file +0
-0
xen/drivers/char/imx-uart.c line 3
Quoted 3 lines
xen/drivers/char/imx-uart.c new file +3
-0@@ -0,0 +1,227 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* xen/drivers/char/imx-uart.c
This can go stale. Please drop.
Quoted 42 lines
xen/drivers/char/imx-uart.c new file +42
-0+* +* 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 <xen/errno.h> +#include <xen/init.h> +#include <xen/irq.h> +#include <xen/mm.h> +#include <xen/serial.h> +#include <asm/device.h> +#include <asm/imx-uart.h> +#include <asm/io.h> + +#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 ) +serial_tx_interrupt (port); +} + +static void __init imx_uart_init_preirq (struct serial_port *port) +{
xen/drivers/char/imx-uart.c line 55
Quoted 10 lines
xen/drivers/char/imx-uart.c new file +10
-0+struct imx_uart *uart = 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 =imx_uart_read (uart,UCR1 ); + ucr1 &= ~(UCR1_RRDYEN |UCR1_TRDYEN |UCR1_RXDMAEN |UCR1_TXDMAEN | +UCR1_ATDMAEN );
What about TXMPTYEN?
xen/drivers/char/imx-uart.c line 57
Quoted 2 lines
xen/drivers/char/imx-uart.c new file +2
-0+ ucr1 |=UCR1_UARTEN ; +imx_uart_write (uart,UCR1 , ucr1);
Only UCR1's enables are cleared, while other UCRs interrupt enables keep whatever the bootloader left. Either mention UCR1 only or clear others too.
~Michal
Re: [PATCH 3/3] xen/arm: add i.MX8M platform support
In reply to Wig ChengQuoted 38 lines · Wig Cheng
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 <[email protected]>--- 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.cxen/arch/arm/platforms/Makefile +1
-0@@ -9,6 +9,7 @@ obj-$(CONFIG_ALL_PLAT) += sunxi.o obj-$(CONFIG_ALL64_PLAT) += thunderx.o obj-$(CONFIG_ALL64_PLAT) += xgene-storm.o obj-$(CONFIG_ALL64_PLAT) += brcm-raspberry-pi.o +obj-$(CONFIG_ALL64_PLAT) += imx8m.o obj-$(CONFIG_ALL64_PLAT) += imx8qm.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp.o obj-$(CONFIG_MPSOC_PLATFORM) += xilinx-zynqmp-eemi.oxen/arch/arm/platforms/imx8m.c new file +0
-0
xen/arch/arm/platforms/imx8m.c line 1
Quoted 1 line
xen/arch/arm/platforms/imx8m.c new file +1
-0@@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
Any specific reason for 2+? Can it be just GPLv2 only? We tend to prefer the former as some companies are wary of v3.
xen/arch/arm/platforms/imx8m.c line 3
Quoted 2 lines
xen/arch/arm/platforms/imx8m.c new file +2
-0+/* +* xen/arch/arm/platforms/imx8m.c
Please remove this line. It does not add any useful information and can quickly go stale.
Quoted 16 lines
xen/arch/arm/platforms/imx8m.c new file +16
-0+* +* i.MX 8M family setup +* +* Copyright 2026 Open-EP (E-Paper) Community +*/ + +#include <xen/sched.h> +#include <asm/platform.h> +#include <asm/smccc.h> + +static const char *const imx8m_dt_compat[]__initconst = +{ +"fsl,imx8mp" , +"fsl,imx8mq" , +"fsl,imx8mm" , +"fsl,imx8mn" ,
xen/arch/arm/platforms/imx8m.c line 29
Quoted 10 lines
xen/arch/arm/platforms/imx8m.c new file +10
-0+ 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 */
Please create a macro utilizing ARM_SMCCC_CALL_VAL same as i.MX 8QM platform driver (or EEMI) so that these values denote actual functions
xen/arch/arm/platforms/imx8m.c line 33
Quoted 4 lines
xen/arch/arm/platforms/imx8m.c new file +4
-0+#define IMX_SIP_CPUFREQ 0xC2000001 +#define IMX_SIP_DDR_DVFS 0xC2000004/* DRAM frequency scaling */ +#define IMX_SIP_SRC 0xC2000005/* SRC: M-core remoteproc start/stop */ +#define IMX_SIP_GET_SOC_INFO 0xC2000006
All values should be equally indented
Quoted 18 lines
xen/arch/arm/platforms/imx8m.c new file +18
-0+#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 =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) )
xen/arch/arm/platforms/imx8m.c line 61
Quoted 10 lines
xen/arch/arm/platforms/imx8m.c new file +10
-0+ { +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
You mention RTC but there's no call for it. Did you miss it?
xen/arch/arm/platforms/imx8m.c line 62
Quoted 1 line
xen/arch/arm/platforms/imx8m.c new file +1
-0+* read-only queries. Forward them.
Stray space before Forward
Quoted 12 lines
xen/arch/arm/platforms/imx8m.c new file +12
-0+*/ +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
xen/arch/arm/platforms/imx8m.c line 84
Quoted 10 lines
xen/arch/arm/platforms/imx8m.c new file +10
-0+* 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; + }
The difference between this driver and QM is that the latter whitelists subfunctions whereas you whitelist whole services which seems like a lot. I don't want to go into details of TF-A, Linux but I would recommend you looking at subfunctions dom0 actually needs.
~Michal
Quoted 32 lines
xen/arch/arm/platforms/imx8m.c new file +32
-0+ +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 = imx8m_dt_compat, + .smc = imx8m_smc, +PLATFORM_END + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/