xen/arm: add i.MX8M platform and UART support
v4 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, the platform glue (SiP SMC whitelist for the calls the dom0 kernel issues to TF-A), and a MAINTAINERS entry.
Tested on i.MX8MP (4x Cortex-A53, GICv3) with the vendor kernel 6.18:
dom0 boots to login on the hypervisor console, and a domU starts with a PV disk and virtio devices running a full Wayland distro.
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 specific subfunctions the dom0 kernel issues, extracted from the vendor kernel call sites. CPU and DRAM frequency scaling are both denied: the hardware domain cannot make an informed decision about resources it shares with the other domains. dom0's i.MX8M DDRC devfreq driver issues the DDR DVFS call at boot; with it denied that driver just skips DRAM frequency scaling (the DRAM stays at the frequency set by firmware) and dom0 boots normally.
Changes since v3:
- Patch 3: filter the SRC and NoC subfunctions with an explicit switch that lists each accepted subfunction, instead of a range check (Michal Orzel). The NoC service now accepts only the QoS priority subfunction, and the unknown-function-id warning also prints the subfunction id.
- Patches 1, 2 and 4 are unchanged; all four patches now carry Michal's Reviewed-by.
Per-patch changelogs are in each patch.
v3: https://lore.kernel.org/xen-devel/[email protected]/
Wig Cheng (4):
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
MAINTAINERS: add myself as reviewer of i.MX8M related patches
MAINTAINERS | 8 + xen/arch/arm/Kconfig.debug | 12 ++ xen/arch/arm/arm64/debug-imx-uart.inc | 37 ++++ xen/arch/arm/include/asm/imx-uart.h | 57 +++++++ xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/imx8m.c | 161 ++++++++++++++++++ xen/drivers/char/Kconfig | 8 + xen/drivers/char/Makefile | 1 + xen/drivers/char/imx-uart.c | 233 ++++++++++++++++++++++++++ 9 files changed, 518 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 v4 1/4 xen/char: add classic i.MX UART driver
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.
---
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
MAINTAINERS +1 -0
@@ -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
xen/arch/arm/include/asm/imx-uart.h new file +57 -0
57 lines not on this page · raw message
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 +233 -0
233 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 3/4 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, 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.
---
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
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 +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 2/4 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.
---
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
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 +37 -0
@@ -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 <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 */ + 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: + */
Signature · 1 line
2.43.0
PATCH v4 4/4 MAINTAINERS: add myself as reviewer of i.MX8M related patches
In reply to Wig ChengI wrote the i.MX8M platform and UART support and can help review patches touching these areas.
---
Changes in v4:
- No changes.
MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -365,6 +365,13 @@ F: tools/misc/xenhypfs.c F: xen/common/hypfs.c F: xen/include/xen/hypfs.h +IMX8M SUPPORT +R: Wig Cheng <[email protected]> +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 <[email protected]> F: xen/arch/arm/platforms/imx8qm.c
Signature · 1 line
2.43.0
Re: [PATCH v4 3/4] xen/arm: add i.MX8M platform support
In reply to Wig ChengQuoted 159 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, 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 <[email protected]>Reviewed-by Michal Orzel <[email protected]>---
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.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 +106
-0@@ -0,0 +1,161 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* i.MX 8M family setup +* +* Copyright 2026 Open-EP (E-Paper) Community +*/ + +#include <xen/sched.h> +#include <asm/platform.h> +#include <asm/regs.h> +#include <asm/smccc.h> + +static const char *const imx8m_dt_compat[]__initconst = +{ +"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 =get_user_reg (regs,0 ); +uint32_t subfunction_id =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 !=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 ):
xen/arch/arm/platforms/imx8m.c line 116
Quoted 10 lines
xen/arch/arm/platforms/imx8m.c new file +10
-0+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 :
No need for a switch for a single case. This can be simplified the same way as you did for IMX_SIP_GPC_SF_PM_DOMAIN i.e.:
if ( subfunction_id != IMX_SIP_NOC_SF_PRIORITY )
return false;
break;
I'll fix on commit. Thanks for the series. I'll commit it shortly.
~Michal