Skip to contentSkip to conversation

hw/arm: add the NXP i.MX 95 EVK machine

PATCH In review Kyle Fox 2 participants 20 messages Aug 20 – Aug 25

Subsystems (2)
lore
Share & tools
lore

Kyle Fox

author
#0 lore raw

cover hw/arm: add the NXP i.MX 95 EVK machine

This series adds a QEMU machine for the NXP i.MX 95 19x19 LPDDR5 EVK (machine name "imx95-19x19-evk"). The i.MX 95 is a heterogeneous SoC; the machine models a fixed topology of 6 Cortex-A55 application cores, one Cortex-M33 that runs NXP's System Manager (SM) firmware, and one Cortex-M7 real-time core that the SM boots and manages.

What it does
============

It boots an arm64 Linux kernel to a userspace shell on the A55 cluster (both a mainline arm64-defconfig kernel and the NXP BSP kernel work).

The defining property of this SoC -- and the reason the machine is shaped the way it is -- is that the System Manager firmware, running on the M33, is the *only* SCMI provider. Linux's clock, power, performance-domain, sensor and reset operations are all served by the SM over a shared mailbox (MU2); there is no SCMI implementation inside QEMU. The machine models the mailbox cross-connect and the SM's bring-up peripherals (LPUART, MU, System Counter, ANATOP/SRC/GPC, ELE, LPI2C + PMIC, uSDHC, ...) faithfully enough that the *real, unmodified* SM firmware runs on the emulated M33 and answers Linux's SCMI traffic.

A consequence worth stating plainly up front: booting Linux on this machine requires the SM firmware image as an input, loaded onto the M33 with "-device loader,file=m33_image.elf,cpu-num=6". Without it the M33 stays halted, nothing answers SCMI, and Linux hangs at arm-scmi probe. The SM is open source (https://github.com/nxp-imx/imx-sm) and builds with an arm-none-eabi toolchain; docs/system/arm/imx95-evk.rst walks through obtaining every required artifact.

Scope (headless v1)
===================

This is a deliberately minimal first machine: it boots to a serial console. It is headless -- the DPU (display controller) is a probe-completing stub, and the GPU (Mali-G310), VPU (Amphion) and NPU (Neutron) are MMIO stubs that Linux enumerates but that perform no rendering, codec or inference. Real display + Wayland output, the NETC networking complex, and the multimedia blocks are intended as follow-on series on top of this base.

The blocks that are modelled are exactly those on the Linux+SM bring-up critical path; everything else that the stock EVK device tree probes is a logging stub so that enabling those nodes degrades gracefully rather than faulting on the first access.

How to test
===========

  $ qemu-system-aarch64 -M imx95-19x19-evk -m 2G -display none \
      -kernel Image -dtb imx95-19x19-evk.dtb -initrd initramfs.cpio.gz \
      -device loader,file=m33_image.elf,cpu-num=6 \
      -append "earlycon=lpuart32,mmio32,0x44380010 console=ttyLP0,115200 \
               cpuidle.off=1" -serial mon:stdio

A functional test is included (tests/functional/aarch64/test_imx95_evk.py). Because the SM firmware and a matching kernel/dtb are external inputs that are not redistributable, the test is gated on QEMU_TEST_IMX95_* environment variables and skips cleanly when they are unset -- so it will SKIP in upstream CI as posted. I would appreciate guidance on the preferred convention here: I am happy to host a redistributable kernel+dtb (and exercise the SM path separately) as an Asset() so CI actually runs the machine, if that is wanted.

Prerequisites (patches 01-04)
=============================

The first four patches are generic, non-i.MX95 changes that the machine depends on. They are separate commits so they can be reviewed (and taken) on their own merits:

01 hw/sd/sdhci: two opt-in uSDHC quirk bits (SDCLK_AUTO_GATE,
NO_SDMA_BOUNDARY). The i.MX (u)SDHC issues commands with SDCLK auto-gated and its SDMA does not honour the 512 KiB ADMA boundary the generic core assumes.
02 hw/arm/boot: let a board preset info->initrd_start, so a board
with a reserved-memory carveout can keep the initrd clear of it.
03 target/arm: an opt-in "pmsav7-rbar-align-down" CPU property that
aligns down a PMSAv7 MPU region base not aligned to its size, instead of the architectural UNPREDICTABLE drop. An earlier version of this fix changed that behaviour unconditionally and was rightly not taken; this reworks it as a property that defaults to false (so no existing behaviour changes) and is only registered on PMSAv7 (v7-M / v7-R) CPUs. The NXP i.MX 95 Cortex-M7 SDK firmware relies on the align-down for one of its MPU regions.
04 hw/arm/armv7m: forward that property to the CPU object, following
the existing init-svtor / vfp / dsp forwarding, so an SoC can enable it on an affected core. (The i.MX 95 SoC enables it on the M7 only; the M33 is a v8-M / PMSAv8 core and needs no such quirk.)

Series layout
=============

  01-04  generic prerequisites (above)
  05     hw/char: i.MX LPUART
  06     hw/i2c:  i.MX LPI2C
  07     hw/misc: i.MX Messaging Unit (MU v2)
  08     hw/misc: NXP EdgeLock Enclave (ELE) responder
  09     hw/timer: i.MX 95 system counter
  10     hw/misc: i.MX 95 watchdog
  11     hw/misc: ANATOP/AONMIX/GPC/SRC power & clock blocks
  12     hw/misc: PMIC (PF09/PF53/PCAL6408A) + xcache
  13     hw/misc: DPU command-sequencer stub (headless)
  14     hw/arm:  i.MX 95 SoC container (fsl-imx95)
  15     hw/arm:  i.MX 95 19x19 EVK board
  16     docs, MAINTAINERS, tests/functional

Every patch builds on its own (the series is bisectable), device state carries migration vmsd + reset, and checkpatch is clean.

  46 files changed, 6529 insertions(+), 13 deletions(-)

Thanks for reviewing.

Kyle Fox (16):
hw/sd/sdhci: add i.MX uSDHC SDCLK_AUTO_GATE and NO_SDMA_BOUNDARY
quirks
hw/arm/boot: let a board preset initrd_start
target/arm: opt-in align-down for a misaligned PMSAv7 MPU RBAR hw/arm/armv7m: forward pmsav7-rbar-align-down to the CPU hw/char: add i.MX LPUART
hw/i2c: add i.MX LPI2C
hw/misc: add i.MX Messaging Unit (MU v2)
hw/misc: add NXP EdgeLock Enclave (ELE) responder hw/timer: add i.MX 95 system counter
hw/misc: add i.MX 95 watchdog
hw/misc: add i.MX 95 ANATOP/AONMIX/GPC/SRC power and clock blocks hw/misc: add i.MX 95 PMIC (PF09/PF53/PCAL6408A) and xcache controllers hw/misc: add i.MX 95 DPU command-sequencer stub (headless) hw/arm: add i.MX 95 SoC container (fsl-imx95)
hw/arm: add i.MX 95 19x19 EVK board
docs, MAINTAINERS, tests/functional: add i.MX 95 EVK

 MAINTAINERS                                |   18 +
 docs/system/arm/imx95-evk.rst              |  242 +++
 docs/system/target-arm.rst                 |    1 +
 hw/arm/Kconfig                             |   26 +
 hw/arm/armv7m.c                            |    8 +
 hw/arm/boot.c                              |   12 +-
 hw/arm/fsl-imx95.c                         | 1646 ++++++++++++++++++++
 hw/arm/imx95-evk.c                         |  136 ++
 hw/arm/meson.build                         |    2 +
 hw/char/Kconfig                            |    3 +
 hw/char/imx_lpuart.c                       |  382 +++++
 hw/char/meson.build                        |    1 +
 hw/char/trace-events                       |    3 +
 hw/i2c/Kconfig                             |    4 +
 hw/i2c/imx_lpi2c.c                         |  296 ++++
 hw/i2c/meson.build                         |    1 +
 hw/i2c/trace-events                        |    4 +
 hw/misc/Kconfig                            |   32 +
 hw/misc/imx95_anatop.c                     |  201 +++
 hw/misc/imx95_aonmix.c                     |  160 ++
 hw/misc/imx95_dpu.c                        |  117 ++
 hw/misc/imx95_ele_server.c                 |  284 ++++
 hw/misc/imx95_gpc.c                        |  160 ++
 hw/misc/imx95_pmic.c                       |  357 +++++
 hw/misc/imx95_src.c                        |  228 +++
 hw/misc/imx95_wdog.c                       |  198 +++
 hw/misc/imx95_xcache.c                     |  185 +++
 hw/misc/imx_mu.c                           |  454 ++++++
 hw/misc/meson.build                        |   10 +
 hw/misc/trace-events                       |   25 +
 hw/sd/sdhci.c                              |   67 +-
 hw/timer/Kconfig                           |    3 +
 hw/timer/imx95_sysctr.c                    |  241 +++
 hw/timer/meson.build                       |    1 +
 hw/timer/trace-events                      |    2 +
 include/hw/arm/armv7m.h                    |    4 +
 include/hw/arm/fsl-imx95.h                 |  481 ++++++
 include/hw/char/imx_lpuart.h               |  123 ++
 include/hw/misc/imx95_ele_server.h         |   47 +
 include/hw/misc/imx_mu.h                   |  144 ++
 include/hw/sd/sdhci.h                      |   21 +
 target/arm/cpu.c                           |   19 +
 target/arm/cpu.h                           |    6 +
 target/arm/ptw.c                           |   28 +-
 tests/functional/aarch64/meson.build       |    2 +
 tests/functional/aarch64/test_imx95_evk.py |  157 ++
 46 files changed, 6529 insertions(+), 13 deletions(-)
 create mode 100644 docs/system/arm/imx95-evk.rst
 create mode 100644 hw/arm/fsl-imx95.c
 create mode 100644 hw/arm/imx95-evk.c
 create mode 100644 hw/char/imx_lpuart.c
 create mode 100644 hw/i2c/imx_lpi2c.c
 create mode 100644 hw/misc/imx95_anatop.c
 create mode 100644 hw/misc/imx95_aonmix.c
 create mode 100644 hw/misc/imx95_dpu.c
 create mode 100644 hw/misc/imx95_ele_server.c
 create mode 100644 hw/misc/imx95_gpc.c
 create mode 100644 hw/misc/imx95_pmic.c
 create mode 100644 hw/misc/imx95_src.c
 create mode 100644 hw/misc/imx95_wdog.c
 create mode 100644 hw/misc/imx95_xcache.c
 create mode 100644 hw/misc/imx_mu.c
 create mode 100644 hw/timer/imx95_sysctr.c
 create mode 100644 include/hw/arm/fsl-imx95.h
 create mode 100644 include/hw/char/imx_lpuart.h
 create mode 100644 include/hw/misc/imx95_ele_server.h
 create mode 100644 include/hw/misc/imx_mu.h
 create mode 100644 tests/functional/aarch64/test_imx95_evk.py

base-commit: ae4f3443209ab154b48b706a146e5f557ab147cb

Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/16 hw/sd/sdhci: add i.MX uSDHC SDCLK_AUTO_GATE and NO_SDMA_BOUNDARY quirks

The i.MX uSDHC issues commands with SDCLK auto-gated (its driver never sets SDCLK_EN), and its SDMA does not honour the 512 KiB ADMA buffer boundary the generic core assumes. Add two opt-in quirk bits for this:

- SDCLK_AUTO_GATE: treat the clock as running once the internal clock is enabled and stable, instead of also requiring SDCLK_EN.
- NO_SDMA_BOUNDARY: skip the buffer-boundary break in multi-block SDMA.

Both default off and are a no-op when the bit is clear, so no existing user of the SDHCI models changes behaviour; a machine opts in by setting the bits on its own uSDHC instances (the i.MX 95 SoC does so).

---
 hw/sd/sdhci.c         | 67 +++++++++++++++++++++++++++++++++++++++----
 include/hw/sd/sdhci.h | 21 ++++++++++++++
 2 files changed, 82 insertions(+), 6 deletions(-)
hw/sd/sdhci.c +61 -6
index e58a6103970..327e9a7cb74 100644
@@ -611,12 +611,27 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
     }
 
     /*
-     * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for
-     * possible stop at page boundary if initial address is not page aligned,
-     * allow them to work properly
+     * The i.MX/FSL uSDHC silicon does not implement the SDHCI "Host SDMA
+     * Buffer Boundary" mechanism; it transfers all blocks back-to-back
+     * regardless of buffer-boundary address alignment. The blksize-quirk
+     * in esdhc_write() forces bits 14:12 to 0b111 (= 512 KiB) so Linux's
+     * "zero this field out" pattern doesn't trip a 4 KiB boundary break,
+     * but the real hardware never pauses for the boundary at all, so
+     * neither should we. Skipping the page-aligned path makes the SDMA
+     * transfer run to completion (blkcnt -> 0) and fire transfer-complete,
+     * which is what the FSL U-Boot SPL driver expects (it doesn't ack
+     * SDMA-boundary IRQs by re-writing SYSAD). Controllers with this
+     * behaviour set SDHCI_QUIRK_NO_SDMA_BOUNDARY.
      */
-    if ((s->sdmasysad % boundary_chk) == 0) {
-        page_aligned = true;
+    if (!(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY)) {
+        /*
+         * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not
+         * account for possible stop at page boundary if initial address
+         * is not page aligned, allow them to work properly
+         */
+        if ((s->sdmasysad % boundary_chk) == 0) {
+            page_aligned = true;
+        }
     }
 
     s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;
@@ -992,9 +1007,26 @@ static void sdhci_data_transfer(void *opaque)
     }
 }
 
+static bool sdhci_clock_is_on(SDHCIState *s)
+{
+    /*
+     * The i.MX (u)SDHC has no software SD-clock-enable bit (the card clock
+     * is auto-gated by hardware), so its driver never sets
+     * SDHC_CLOCK_SDCLK_EN. For such a controller, treat the clock as
+     * running once the internal clock is enabled and stable; otherwise
+     * every command would be silently dropped (no completion/timeout IRQ),
+     * stalling the guest on 10s host-side timeouts.
+     */
+    if (s->quirks & SDHCI_QUIRK_SDCLK_AUTO_GATE) {
+        return (s->clkcon & (SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE)) ==
+               (SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE);
+    }
+    return SDHC_CLOCK_IS_ON(s->clkcon);
+}
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clock_is_on(s) ||
         (((s->prnsts & SDHC_DATA_INHIBIT) || s->stopped_state) &&
         ((s->cmdreg & SDHC_CMD_DATA_PRESENT) ||
         ((s->cmdreg & SDHC_CMD_RESPONSE) == SDHC_CMD_RSP_WITH_BUSY &&
@@ -1613,6 +1645,9 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 
 #define ESDHC_VENDOR_SPEC               0xc0
 #define ESDHC_FRC_SDCLK_ON              (1 << 8)
+#define ESDHC_VENDORSPEC_IPGEN          (1 << 11)
+#define ESDHC_VENDORSPEC_HCKEN          (1 << 12)
+#define ESDHC_VENDORSPEC_CKEN           (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1707,6 +1742,26 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
         } else {
             s->prnsts |= ESDHC_PRNSTS_CLOCK_GATE_OFF;
         }
+        /*
+         * An SDCLK_AUTO_GATE i.MX uSDHC drives the SD clock through
+         * VENDORSPEC, not through the SDHCI CLKCON. For those instances
+         * mirror the VENDORSPEC clock-enable bits into clkcon so the
+         * standard SDHCI paths (PRNSTS.SDSTB derived from CLOCK_INT_STABLE;
+         * sdhci_can_issue_command gating on CLOCK_IS_ON) see the clock as
+         * enabled; otherwise the U-Boot fsl_esdhc_imx driver waits forever
+         * for SDSTB. Consumers without the quirk keep the upstream behaviour
+         * (a VENDORSPEC write touches only vendor_spec/prnsts).
+         */
+        if (s->quirks & SDHCI_QUIRK_SDCLK_AUTO_GATE) {
+            if (value & (ESDHC_VENDORSPEC_HCKEN | ESDHC_VENDORSPEC_IPGEN)) {
+                s->clkcon |= SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE;
+            }
+            if (value & ESDHC_VENDORSPEC_CKEN) {
+                s->clkcon |= SDHC_CLOCK_SDCLK_EN;
+            } else {
+                s->clkcon &= ~SDHC_CLOCK_SDCLK_EN;
+            }
+        }
         break;
 
     case SDHC_HOSTCTL:
include/hw/sd/sdhci.h +21 -0
index a9da6203fcb..e6940b62562 100644
@@ -115,6 +115,27 @@ typedef struct SDHCIState SDHCIState;
  */
 #define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(14)
 
+/*
+ * The i.MX (u)SDHC gates the SD card clock automatically and has no
+ * software-visible "SD Clock Enable" bit: its driver programs only the
+ * divider and the internal-clock enable, never SDHC_CLOCK_SDCLK_EN. With
+ * this quirk the controller is considered ready to issue commands once the
+ * internal clock is enabled and stable, instead of also requiring
+ * SDHC_CLOCK_SDCLK_EN (which such a driver never sets). QEMU-internal bit,
+ * taken from the top of the word to avoid the Linux quirk numbering.
+ */
+#define SDHCI_QUIRK_SDCLK_AUTO_GATE    BIT(31)
+
+/*
+ * The i.MX uSDHC silicon does not implement the SDHCI "Host SDMA Buffer
+ * Boundary" mechanism; it streams all blocks back-to-back regardless of the
+ * buffer-boundary alignment, never pausing at the boundary. With this quirk
+ * the SDMA engine skips the page-aligned boundary-break path so the transfer
+ * runs to completion. QEMU-internal bit, taken from the top of the word to
+ * avoid the Linux quirk numbering.
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY    BIT(30)
+
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
                          TYPE_PCI_SDHCI)
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 01/16] hw/sd/sdhci: add i.MX uSDHC SDCLK_AUTO_GATE and NO_SDMA_BOUNDARY quirks

Hi Kyle,

Quoted 144 lines · Kyle Fox

The i.MX uSDHC issues commands with SDCLK auto-gated (its driver never sets SDCLK_EN), and its SDMA does not honour the 512 KiB ADMA buffer boundary the generic core assumes. Add two opt-in quirk bits for this:

- SDCLK_AUTO_GATE: treat the clock as running once the internal clock is enabled and stable, instead of also requiring SDCLK_EN.
- NO_SDMA_BOUNDARY: skip the buffer-boundary break in multi-block SDMA.

Both default off and are a no-op when the bit is clear, so no existing user of the SDHCI models changes behaviour; a machine opts in by setting the bits on its own uSDHC instances (the i.MX 95 SoC does so).

---
 hw/sd/sdhci.c         | 67 +++++++++++++++++++++++++++++++++++++++----
 include/hw/sd/sdhci.h | 21 ++++++++++++++
 2 files changed, 82 insertions(+), 6 deletions(-)
hw/sd/sdhci.c +61 -6
index e58a6103970..327e9a7cb74 100644
@@ -611,12 +611,27 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
     }
 
     /*
-     * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for
-     * possible stop at page boundary if initial address is not page aligned,
-     * allow them to work properly
+     * The i.MX/FSL uSDHC silicon does not implement the SDHCI "Host SDMA
+     * Buffer Boundary" mechanism; it transfers all blocks back-to-back
+     * regardless of buffer-boundary address alignment. The blksize-quirk
+     * in esdhc_write() forces bits 14:12 to 0b111 (= 512 KiB) so Linux's
+     * "zero this field out" pattern doesn't trip a 4 KiB boundary break,
+     * but the real hardware never pauses for the boundary at all, so
+     * neither should we. Skipping the page-aligned path makes the SDMA
+     * transfer run to completion (blkcnt -> 0) and fire transfer-complete,
+     * which is what the FSL U-Boot SPL driver expects (it doesn't ack
+     * SDMA-boundary IRQs by re-writing SYSAD). Controllers with this
+     * behaviour set SDHCI_QUIRK_NO_SDMA_BOUNDARY.
      */
-    if ((s->sdmasysad % boundary_chk) == 0) {
-        page_aligned = true;
+    if (!(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY)) {
+        /*
+         * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not
+         * account for possible stop at page boundary if initial address
+         * is not page aligned, allow them to work properly
+         */
+        if ((s->sdmasysad % boundary_chk) == 0) {
+            page_aligned = true;
+        }
     }
 
     s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;
@@ -992,9 +1007,26 @@ static void sdhci_data_transfer(void *opaque)
     }
 }
 
+static bool sdhci_clock_is_on(SDHCIState *s)
+{
+    /*
+     * The i.MX (u)SDHC has no software SD-clock-enable bit (the card clock
+     * is auto-gated by hardware), so its driver never sets
+     * SDHC_CLOCK_SDCLK_EN. For such a controller, treat the clock as
+     * running once the internal clock is enabled and stable; otherwise
+     * every command would be silently dropped (no completion/timeout IRQ),
+     * stalling the guest on 10s host-side timeouts.
+     */
+    if (s->quirks & SDHCI_QUIRK_SDCLK_AUTO_GATE) {
+        return (s->clkcon & (SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE)) ==
+               (SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE);
+    }
+    return SDHC_CLOCK_IS_ON(s->clkcon);
+}
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clock_is_on(s) ||
         (((s->prnsts & SDHC_DATA_INHIBIT) || s->stopped_state) &&
         ((s->cmdreg & SDHC_CMD_DATA_PRESENT) ||
         ((s->cmdreg & SDHC_CMD_RESPONSE) == SDHC_CMD_RSP_WITH_BUSY &&
@@ -1613,6 +1645,9 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 
 #define ESDHC_VENDOR_SPEC               0xc0
 #define ESDHC_FRC_SDCLK_ON              (1 << 8)
+#define ESDHC_VENDORSPEC_IPGEN          (1 << 11)
+#define ESDHC_VENDORSPEC_HCKEN          (1 << 12)
+#define ESDHC_VENDORSPEC_CKEN           (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1707,6 +1742,26 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
         } else {
             s->prnsts |= ESDHC_PRNSTS_CLOCK_GATE_OFF;
         }
+        /*
+         * An SDCLK_AUTO_GATE i.MX uSDHC drives the SD clock through
+         * VENDORSPEC, not through the SDHCI CLKCON. For those instances
+         * mirror the VENDORSPEC clock-enable bits into clkcon so the
+         * standard SDHCI paths (PRNSTS.SDSTB derived from CLOCK_INT_STABLE;
+         * sdhci_can_issue_command gating on CLOCK_IS_ON) see the clock as
+         * enabled; otherwise the U-Boot fsl_esdhc_imx driver waits forever
+         * for SDSTB. Consumers without the quirk keep the upstream behaviour
+         * (a VENDORSPEC write touches only vendor_spec/prnsts).
+         */
+        if (s->quirks & SDHCI_QUIRK_SDCLK_AUTO_GATE) {
+            if (value & (ESDHC_VENDORSPEC_HCKEN | ESDHC_VENDORSPEC_IPGEN)) {
+                s->clkcon |= SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE;
+            }
+            if (value & ESDHC_VENDORSPEC_CKEN) {
+                s->clkcon |= SDHC_CLOCK_SDCLK_EN;
+            } else {
+                s->clkcon &= ~SDHC_CLOCK_SDCLK_EN;
+            }
+        }
         break;
 
     case SDHC_HOSTCTL:
include/hw/sd/sdhci.h +15 -0
index a9da6203fcb..e6940b62562 100644
@@ -115,6 +115,27 @@ typedef struct SDHCIState SDHCIState;
  */
 #define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(14)
 
+/*
+ * The i.MX (u)SDHC gates the SD card clock automatically and has no
+ * software-visible "SD Clock Enable" bit: its driver programs only the
+ * divider and the internal-clock enable, never SDHC_CLOCK_SDCLK_EN. With
+ * this quirk the controller is considered ready to issue commands once the
+ * internal clock is enabled and stable, instead of also requiring
+ * SDHC_CLOCK_SDCLK_EN (which such a driver never sets). QEMU-internal bit,
+ * taken from the top of the word to avoid the Linux quirk numbering.
+ */
+#define SDHCI_QUIRK_SDCLK_AUTO_GATE    BIT(31)
+
+/*
+ * The i.MX uSDHC silicon does not implement the SDHCI "Host SDMA Buffer
+ * Boundary" mechanism; it streams all blocks back-to-back regardless of the
+ * buffer-boundary alignment, never pausing at the boundary. With this quirk

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState;

Quoted 10 lines
include/hw/sd/sdhci.h +6 -1
+ * the SDMA engine skips the page-aligned boundary-break path so the transfer
+ * runs to completion. QEMU-internal bit, taken from the top of the word to
+ * avoid the Linux quirk numbering.
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY    BIT(30)
+
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
                          TYPE_PCI_SDHCI)
--

A patch series was already sent to ML before to enable the i.MX uSDHC controller.
Please see https://patchwork.ozlabs.org/project/qemu-devel/list/?series=518052

Regards,
Bin

#3 lore raw

Re: [PATCH 01/16] hw/sd/sdhci: add i.MX uSDHC SDCLK_AUTO_GATE and NO_SDMA_BOUNDARY quirks

Hi Bin,
Thanks for the pointer -- I had not seen series 518052, and it clearly supersedes my patch 01. Your 06 (honor uSDHC vendor clock gates) and 08 (skip SDMA boundary stops) cover the same two problems more completely than mine, with the RM citations and a functional boot test behind them, and 05's move to a sequential QEMU-local quirk namespace is the right call over the top-of-word bits I picked.

The part that makes this easy on my end: you set NO_SDMA_BOUNDARY (and CLOCKS_IN_VENDOR) directly in imx_usdhc_init(), and the i.MX 95 machine reuses TYPE_IMX_USDHC -- so once your series lands, my uSDHC instances inherit both behaviors with no machine-side code at all.

I'll drop my patch 01 entirely and remove the quirk-set line from the SoC patch in my v2; the i.MX 95 series then just depends on your sdhci work.

On sequencing, I'm happy either way and will follow your preference: I can hold my v2 until 518052 merges and rebase cleanly on top, or post v2 now marked as based-on your series so the dependency is explicit for reviewers.

Whichever is less noise for you.
Thanks again for catching the overlap.

Kyle

Quoted 192 lines · Bin Meng

Hi Kyle,

hw/sd/sdhci.c static void

Quoted 24 lines · Kyle Fox

The i.MX uSDHC issues commands with SDCLK auto-gated (its driver never sets SDCLK_EN), and its SDMA does not honour the 512 KiB ADMA buffer boundary the generic core assumes. Add two opt-in quirk bits for this:

- SDCLK_AUTO_GATE: treat the clock as running once the internal clock is enabled and stable, instead of also requiring SDCLK_EN.
- NO_SDMA_BOUNDARY: skip the buffer-boundary break in multi-block SDMA.

Both default off and are a no-op when the bit is clear, so no existing user of the SDHCI models changes behaviour; a machine opts in by setting the bits on its own uSDHC instances (the i.MX 95 SoC does so).

---
 hw/sd/sdhci.c         | 67 +++++++++++++++++++++++++++++++++++++++----
 include/hw/sd/sdhci.h | 21 ++++++++++++++
 2 files changed, 82 insertions(+), 6 deletions(-)
hw/sd/sdhci.c +0 -0
index e58a6103970..327e9a7cb74 100644
@@ -611,12 +611,27 @@ static void

sdhci_sdma_transfer_multi_blocks(SDHCIState *s)

hw/sd/sdhci.c static void · line 614

Quoted 4 lines
hw/sd/sdhci.c +0 -1
     }
 
     /*
-     * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not

account for

hw/sd/sdhci.c static void · line 615

Quoted 1 line
hw/sd/sdhci.c +0 -1
-     * possible stop at page boundary if initial address is not page

aligned,

hw/sd/sdhci.c static void · line 614

Quoted 2 lines
hw/sd/sdhci.c +1 -1
-     * allow them to work properly
+     * The i.MX/FSL uSDHC silicon does not implement the SDHCI "Host

SDMA

hw/sd/sdhci.c static void · line 616

Quoted 2 lines
hw/sd/sdhci.c +2 -0
+     * Buffer Boundary" mechanism; it transfers all blocks back-to-back
+     * regardless of buffer-boundary address alignment. The

blksize-quirk

hw/sd/sdhci.c static void · line 617

Quoted 1 line
hw/sd/sdhci.c +1 -0
+     * in esdhc_write() forces bits 14:12 to 0b111 (= 512 KiB) so

Linux's

hw/sd/sdhci.c static void · line 618

Quoted 1 line
hw/sd/sdhci.c +1 -0
+     * "zero this field out" pattern doesn't trip a 4 KiB boundary

break,

hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)

Quoted 3 lines
hw/sd/sdhci.c +3 -0
+     * but the real hardware never pauses for the boundary at all, so
+     * neither should we. Skipping the page-aligned path makes the SDMA
+     * transfer run to completion (blkcnt -> 0) and fire

transfer-complete,

Quoted 19 lines
hw/sd/sdhci.c +12 -2
+     * which is what the FSL U-Boot SPL driver expects (it doesn't ack
+     * SDMA-boundary IRQs by re-writing SYSAD). Controllers with this
+     * behaviour set SDHCI_QUIRK_NO_SDMA_BOUNDARY.
      */
-    if ((s->sdmasysad % boundary_chk) == 0) {
-        page_aligned = true;
+    if (!(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY)) {
+        /*
+         * XXX: Some sd/mmc drivers (for example, u-boot-slp) do not
+         * account for possible stop at page boundary if initial address
+         * is not page aligned, allow them to work properly
+         */
+        if ((s->sdmasysad % boundary_chk) == 0) {
+            page_aligned = true;
+        }
     }
 
     s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;

hw/sd/sdhci.c static void sdhci_data_transfer(void *opaque) · line 1013

Quoted 7 lines
hw/sd/sdhci.c +4 -0
@@ -992,9 +1007,26 @@ static void sdhci_data_transfer(void *opaque)
     }
 }
 
+static bool sdhci_clock_is_on(SDHCIState *s)
+{
+    /*
+     * The i.MX (u)SDHC has no software SD-clock-enable bit (the card

clock

hw/sd/sdhci.c static void sdhci_data_transfer(void *opaque)

Quoted 4 lines
hw/sd/sdhci.c +4 -0
+     * is auto-gated by hardware), so its driver never sets
+     * SDHC_CLOCK_SDCLK_EN. For such a controller, treat the clock as
+     * running once the internal clock is enabled and stable; otherwise
+     * every command would be silently dropped (no completion/timeout

IRQ),

hw/sd/sdhci.c static void sdhci_data_transfer(void *opaque)

Quoted 4 lines
hw/sd/sdhci.c +4 -0
+     * stalling the guest on 10s host-side timeouts.
+     */
+    if (s->quirks & SDHCI_QUIRK_SDCLK_AUTO_GATE) {
+        return (s->clkcon & (SDHC_CLOCK_INT_EN |

SDHC_CLOCK_INT_STABLE)) ==

hw/sd/sdhci.c static void sdhci_bus_class_init(ObjectClass

Quoted 13 lines
hw/sd/sdhci.c +6 -1
+               (SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE);
+    }
+    return SDHC_CLOCK_IS_ON(s->clkcon);
+}
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clock_is_on(s) ||
         (((s->prnsts & SDHC_DATA_INHIBIT) || s->stopped_state) &&
         ((s->cmdreg & SDHC_CMD_DATA_PRESENT) ||
         ((s->cmdreg & SDHC_CMD_RESPONSE) == SDHC_CMD_RSP_WITH_BUSY &&
@@ -1613,6 +1645,9 @@ static void sdhci_bus_class_init(ObjectClass

*klass, const void *data)

hw/sd/sdhci.c esdhc_write(void *opaque, hwaddr offset, uint64_t

Quoted 10 lines
hw/sd/sdhci.c +3 -0
 #define ESDHC_VENDOR_SPEC               0xc0
 #define ESDHC_FRC_SDCLK_ON              (1 << 8)
+#define ESDHC_VENDORSPEC_IPGEN          (1 << 11)
+#define ESDHC_VENDORSPEC_HCKEN          (1 << 12)
+#define ESDHC_VENDORSPEC_CKEN           (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1707,6 +1742,26 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t

val, unsigned size)

hw/sd/sdhci.c esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)

Quoted 8 lines
hw/sd/sdhci.c +5 -0
         } else {
             s->prnsts |= ESDHC_PRNSTS_CLOCK_GATE_OFF;
         }
+        /*
+         * An SDCLK_AUTO_GATE i.MX uSDHC drives the SD clock through
+         * VENDORSPEC, not through the SDHCI CLKCON. For those instances
+         * mirror the VENDORSPEC clock-enable bits into clkcon so the
+         * standard SDHCI paths (PRNSTS.SDSTB derived from

CLOCK_INT_STABLE;

hw/sd/sdhci.c esdhc_write(void *opaque, hwaddr offset, uint64_t · line 1750

Quoted 1 line
hw/sd/sdhci.c +1 -0
+         * sdhci_can_issue_command gating on CLOCK_IS_ON) see the clock

as

hw/sd/sdhci.c esdhc_write(void *opaque, hwaddr offset, uint64_t · line 1751

Quoted 1 line
hw/sd/sdhci.c +1 -0
+         * enabled; otherwise the U-Boot fsl_esdhc_imx driver waits

forever

hw/sd/sdhci.c esdhc_write(void *opaque, hwaddr offset, uint64_t · line 1752

Quoted 1 line
hw/sd/sdhci.c +1 -0
+         * for SDSTB. Consumers without the quirk keep the upstream

behaviour

hw/sd/sdhci.c esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)

Quoted 4 lines
hw/sd/sdhci.c +4 -0
+         * (a VENDORSPEC write touches only vendor_spec/prnsts).
+         */
+        if (s->quirks & SDHCI_QUIRK_SDCLK_AUTO_GATE) {
+            if (value & (ESDHC_VENDORSPEC_HCKEN |

ESDHC_VENDORSPEC_IPGEN)) {

Quoted 16 lines
hw/sd/sdhci.c +8 -0
+                s->clkcon |= SDHC_CLOCK_INT_EN | SDHC_CLOCK_INT_STABLE;
+            }
+            if (value & ESDHC_VENDORSPEC_CKEN) {
+                s->clkcon |= SDHC_CLOCK_SDCLK_EN;
+            } else {
+                s->clkcon &= ~SDHC_CLOCK_SDCLK_EN;
+            }
+        }
         break;
 
     case SDHC_HOSTCTL:
include/hw/sd/sdhci.h +0 -0
index a9da6203fcb..e6940b62562 100644

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 121

Quoted 7 lines
include/hw/sd/sdhci.h +4 -0
@@ -115,6 +115,27 @@ typedef struct SDHCIState SDHCIState;
  */
 #define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(14)
 
+/*
+ * The i.MX (u)SDHC gates the SD card clock automatically and has no
+ * software-visible "SD Clock Enable" bit: its driver programs only the
+ * divider and the internal-clock enable, never SDHC_CLOCK_SDCLK_EN.

With

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 122

Quoted 1 line
include/hw/sd/sdhci.h +1 -0
+ * this quirk the controller is considered ready to issue commands once

the

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 124

Quoted 2 lines
include/hw/sd/sdhci.h +2 -0
+ * internal clock is enabled and stable, instead of also requiring
+ * SDHC_CLOCK_SDCLK_EN (which such a driver never sets). QEMU-internal

bit,

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState;

Quoted 7 lines
include/hw/sd/sdhci.h +7 -0
+ * taken from the top of the word to avoid the Linux quirk numbering.
+ */
+#define SDHCI_QUIRK_SDCLK_AUTO_GATE    BIT(31)
+
+/*
+ * The i.MX uSDHC silicon does not implement the SDHCI "Host SDMA Buffer
+ * Boundary" mechanism; it streams all blocks back-to-back regardless

of the

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 132

Quoted 1 line
include/hw/sd/sdhci.h +1 -0
+ * buffer-boundary alignment, never pausing at the boundary. With this

quirk

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 133

Quoted 1 line
include/hw/sd/sdhci.h +1 -0
+ * the SDMA engine skips the page-aligned boundary-break path so the

transfer

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState; · line 134

Quoted 1 line
include/hw/sd/sdhci.h +1 -0
+ * runs to completion. QEMU-internal bit, taken from the top of the

word to

include/hw/sd/sdhci.h typedef struct SDHCIState SDHCIState;

Quoted 8 lines
include/hw/sd/sdhci.h +4 -1
+ * avoid the Linux quirk numbering.
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY    BIT(30)
+
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
                          TYPE_PCI_SDHCI)
--

A patch series was already sent to ML before to enable the i.MX uSDHC controller.
Please see
https://patchwork.ozlabs.org/project/qemu-devel/list/?series=518052

Regards,
Bin

#4 lore raw

Re: [PATCH 01/16] hw/sd/sdhci: add i.MX uSDHC SDCLK_AUTO_GATE and NO_SDMA_BOUNDARY quirks

Hi Kyle,

Quoted 4 lines · kylefoxaustin

Hi Bin,
Thanks for the pointer -- I had not seen series 518052, and it clearly supersedes my patch 01. Your 06 (honor uSDHC vendor clock gates) and 08 (skip SDMA boundary stops) cover the same two problems more completely than mine, with the RM citations and a functional boot test behind them, and 05's move to a sequential QEMU-local quirk namespace is the right call over the top-of-word bits I picked.

Quoted 9 lines

The part that makes this easy on my end: you set NO_SDMA_BOUNDARY (and CLOCKS_IN_VENDOR) directly in imx_usdhc_init(), and the i.MX 95 machine reuses TYPE_IMX_USDHC -- so once your series lands, my uSDHC instances inherit both behaviors with no machine-side code at all.

I'll drop my patch 01 entirely and remove the quirk-set line from the SoC patch in my v2; the i.MX 95 series then just depends on your sdhci work.

On sequencing, I'm happy either way and will follow your preference: I can hold my v2 until 518052 merges and rebase cleanly on top, or post v2 now marked as based-on your series so the dependency is explicit for reviewers.

Whichever is less noise for you.
Thanks again for catching the overlap.

You can send v2 with a based-on reference to my sereis. Thanks!

Regards,
Bin

author
#5 lore raw

PATCH 2/16 hw/arm/boot: let a board preset initrd_start

In reply to Kyle Fox

Allow a board to place the initrd itself (honour a pre-set info->initrd_start) so a board with a reserved-memory carveout can keep the initrd clear of it.

---
 hw/arm/boot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
hw/arm/boot.c +10 -2
index 9b7553dde5e..4bfb0d8264b 100644
@@ -997,8 +997,16 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
      * don't tell us their exact size (eg self-decompressing 32-bit kernels)
      * we might still make a bad choice here.
      */
-    info->initrd_start = info->loader_start +
-        MIN(info->ram_size / 2, 128 * MiB);
+    /*
+     * Boards may preset info->initrd_start to force a placement (e.g. to
+     * dodge a guest reserved-memory carveout that happens to sit where the
+     * default heuristic would land the initrd). Only compute a default when
+     * the board left it unset.
+     */
+    if (!info->initrd_start) {
+        info->initrd_start = info->loader_start +
+            MIN(info->ram_size / 2, 128 * MiB);
+    }
     if (image_high_addr) {
         info->initrd_start = MAX(info->initrd_start, image_high_addr);
     }
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH 3/16 target/arm: opt-in align-down for a misaligned PMSAv7 MPU RBAR

In reply to Kyle Fox

A PMSAv7 MPU region base that is not aligned to its region size is UNPREDICTABLE per the architecture, and QEMU disables such a region. Some PMSAv7 implementations instead ignore the sub-size low bits of RBAR.ADDR and match against the aligned-down base. The NXP i.MX 95 RT core (Cortex-M7) SDK firmware relies on this for a peripheral region (DRBAR 0x4c800000 programmed with a 512MB size, intended as 0x40000000).

Add an opt-in "pmsav7-rbar-align-down" property that aligns such a base down instead of dropping the region. It defaults to false, so existing behaviour is unchanged, and is only registered on PMSAv7 CPUs (v7-M and v7-R, i.e. v7 without v8), where get_phys_addr_pmsav7() runs.

---
 target/arm/cpu.c | 19 +++++++++++++++++++
 target/arm/cpu.h |  6 ++++++
 target/arm/ptw.c | 28 +++++++++++++++++++++++-----
 3 files changed, 48 insertions(+), 5 deletions(-)
target/arm/cpu.c +19 -0
index 77aa78f00e2..22e84c1ced2 100644
@@ -1349,6 +1349,16 @@ static const Property arm_cpu_pmsav7_dregion_property =
             DEFINE_PROP_UNSIGNED_NODEFAULT("pmsav7-dregion", ARMCPU,
                                            pmsav7_dregion,
                                            qdev_prop_uint32, uint32_t);
+
+/*
+ * Opt-in: treat a PMSAv7 MPU region base that is not aligned to its region
+ * size as aligned-down instead of UNPREDICTABLE (see get_phys_addr_pmsav7()).
+ * Only registered on PMSAv7 (v7-M / v7-R) CPUs, and only enabled by an
+ * integrator whose firmware relies on it (e.g. the i.MX 95 Cortex-M7).
+ */
+static const Property arm_cpu_pmsav7_rbar_align_down_property =
+            DEFINE_PROP_BOOL("pmsav7-rbar-align-down", ARMCPU,
+                             pmsav7_rbar_align_down, false);
 #endif
 
 static bool arm_get_pmu(Object *obj, Error **errp)
@@ -1659,6 +1669,15 @@ static void arm_cpu_post_init(Object *obj)
         if (arm_feature(&cpu->env, ARM_FEATURE_V7)) {
             qdev_property_add_static(DEVICE(obj),
                                      &arm_cpu_pmsav7_dregion_property);
+            /*
+             * get_phys_addr_pmsav7() only runs on PMSAv7 CPUs, i.e. v7
+             * without v8 (a v8 M/R core uses the PMSAv8 MPU, which has no
+             * such alignment rule), so only offer the property there.
+             */
+            if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
+                qdev_property_add_static(DEVICE(obj),
+                        &arm_cpu_pmsav7_rbar_align_down_property);
+            }
         }
     }
 
target/arm/cpu.h +6 -0
index c0492c8dfbc..03ead3cda15 100644
@@ -1145,6 +1145,12 @@ struct ArchCPU {
      * architecture version.
      */
     bool cfgend;
+    /*
+     * If set, a PMSAv7 MPU region base that is not aligned to its region
+     * size is treated as aligned-down (matching Cortex-M silicon such as the
+     * i.MX 95 M-cores) instead of the architectural UNPREDICTABLE drop.
+     */
+    bool pmsav7_rbar_align_down;
 
     QLIST_HEAD(, ARMELChangeHook) pre_el_change_hooks;
     QLIST_HEAD(, ARMELChangeHook) el_change_hooks;
target/arm/ptw.c +23 -5
index a29de0385f4..51805c05226 100644
@@ -2757,11 +2757,29 @@ static bool get_phys_addr_pmsav7(CPUARMState *env,
             rmask = (1ull << rsize) - 1;
 
             if (base & rmask) {
-                qemu_log_mask(LOG_GUEST_ERROR,
-                              "DRBAR[%d]: 0x%" PRIx32 " misaligned "
-                              "to DRSR region size, mask = 0x%" PRIx32 "\n",
-                              n, base, rmask);
-                continue;
+                if (cpu->pmsav7_rbar_align_down) {
+                    /*
+                     * Opt-in behaviour for Cortex-M silicon such as the
+                     * i.MX 95 M-cores: a region base not aligned to its size
+                     * is treated as aligned-down (RBAR.ADDR is only
+                     * [31:log2(size)]), matching that hardware, whose SM/RT
+                     * firmware programs e.g. DRBAR 0x4c800000 with a 512MB
+                     * size intended as 0x40000000. Off by default because the
+                     * architecture calls a misaligned base UNPREDICTABLE.
+                     */
+                    qemu_log_mask(LOG_GUEST_ERROR,
+                                  "DRBAR[%d]: 0x%" PRIx32 " not aligned to "
+                                  "DRSR region size (mask 0x%" PRIx32 "); "
+                                  "aligning down to 0x%" PRIx32 "\n",
+                                  n, base, rmask, base & ~rmask);
+                    base &= ~rmask;
+                } else {
+                    qemu_log_mask(LOG_GUEST_ERROR,
+                                  "DRBAR[%d]: 0x%" PRIx32 " misaligned "
+                                  "to DRSR region size, mask = 0x%" PRIx32 "\n",
+                                  n, base, rmask);
+                    continue;
+                }
             }
 
             if (address < base || address > base + rmask) {
Signature · 1 line
2.34.1
author
#7 lore raw

PATCH 4/16 hw/arm/armv7m: forward pmsav7-rbar-align-down to the CPU

In reply to Kyle Fox

Forward the opt-in "pmsav7-rbar-align-down" property to the CPU object, following the existing init-svtor / vfp / dsp forwarding pattern, so an SoC integrating a PMSAv7 core whose firmware relies on the align-down behaviour can enable it.

---
 hw/arm/armv7m.c         | 8 ++++++++
 include/hw/arm/armv7m.h | 4 ++++
 2 files changed, 12 insertions(+)
hw/arm/armv7m.c +8 -0
index 68a1cbd6316..bb0f95d423d 100644
@@ -332,6 +332,12 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
             return;
         }
     }
+    if (object_property_find(OBJECT(s->cpu), "pmsav7-rbar-align-down")) {
+        if (!object_property_set_bool(OBJECT(s->cpu), "pmsav7-rbar-align-down",
+                                      s->pmsav7_rbar_align_down, errp)) {
+            return;
+        }
+    }
     object_property_set_bool(OBJECT(s->cpu), "start-powered-off",
                              s->start_powered_off, &error_abort);
 
@@ -562,6 +568,8 @@ static const Property armv7m_properties[] = {
                      false),
     DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true),
     DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true),
+    DEFINE_PROP_BOOL("pmsav7-rbar-align-down", ARMv7MState,
+                     pmsav7_rbar_align_down, false),
     DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX),
     DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX),
 };
include/hw/arm/armv7m.h +4 -0
index 70555962bb9..23cfed222c1 100644
@@ -52,6 +52,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M)
  * + Property "init-nsvtor": non-secure VTOR reset value (forwarded to CPU object)
  * + Property "vfp": enable VFP (forwarded to CPU object)
  * + Property "dsp": enable DSP (forwarded to CPU object)
+ * + Property "pmsav7-rbar-align-down": align down a misaligned PMSAv7 MPU
+ *   region base rather than treating it as UNPREDICTABLE (forwarded to the
+ *   CPU object, which only offers it on PMSAv7 cores)
  * + Property "enable-bitband": expose bitbanded IO
  * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded
  *   to CPU object pmsav7-dregion property; default is whatever the default
@@ -108,6 +111,7 @@ struct ARMv7MState {
     bool start_powered_off;
     bool vfp;
     bool dsp;
+    bool pmsav7_rbar_align_down;
 };
 
 #endif
Signature · 1 line
2.34.1
author
#8 lore raw

PATCH 5/16 hw/char: add i.MX LPUART

In reply to Kyle Fox

The i.MX Low-Power UART. Models the register subset the Linux fsl-lpuart driver and the SM firmware drive (BAUD/CTRL/STAT/DATA plus the TX/RX FIFOs) as an interrupt- and poll-capable serial device. On this machine LPUART1 is the Linux console (ttyLP0), LPUART2 the SM debug monitor and LPUART3 the M7 console.

---
 hw/char/Kconfig              |   3 +
 hw/char/imx_lpuart.c         | 382 +++++++++++++++++++++++++++++++++++
 hw/char/meson.build          |   1 +
 hw/char/trace-events         |   3 +
 include/hw/char/imx_lpuart.h | 123 +++++++++++
 5 files changed, 512 insertions(+)
 create mode 100644 hw/char/imx_lpuart.c
 create mode 100644 include/hw/char/imx_lpuart.h
hw/char/Kconfig +3 -0
index 020c0a84bb6..51b4c3e00ce 100644
@@ -95,3 +95,6 @@ config IP_OCTAL_232
     bool
     default y
     depends on IPACK
+
+config IMX_LPUART
+    bool
hw/char/imx_lpuart.c new file +382 -0

382 lines not on this page · raw message

hw/char/meson.build +1 -0
index fc3d7ee506f..440142ae803 100644
@@ -41,3 +41,4 @@ system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c'))
 
 specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
 specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c'))
+system_ss.add(when: 'CONFIG_IMX_LPUART', if_true: files('imx_lpuart.c'))
hw/char/trace-events +3 -0
index a3fcc772877..6d9b71961e5 100644
@@ -141,3 +141,6 @@ stm32f2xx_usart_receive(char *id, uint8_t chr) " %s receiving '%c'"
 # riscv_htif.c
 htif_uart_write_to_host(uint8_t device, uint8_t cmd, uint64_t payload) "device: %u cmd: %02u payload: %016" PRIx64
 htif_uart_unknown_device_command(uint8_t device, uint8_t cmd, uint64_t payload) "device: %u cmd: %02u payload: %016" PRIx64
+imx_lpuart_tx(uint8_t ch) "tx 0x%02x"
+imx_lpuart_rx(uint8_t ch) "rx 0x%02x"
+imx_lpuart_baud(uint32_t baud) "baud <- 0x%08x"
include/hw/char/imx_lpuart.h new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#9 lore raw

PATCH 6/16 hw/i2c: add i.MX LPI2C

In reply to Kyle Fox

The i.MX Low-Power I2C master. Models the polled master transfer path (MCR/MSR, the MTDR command FIFO and the MRDR receive FIFO) that the System Manager firmware uses to bring up the PMIC and IO expander. No interrupts are modelled (MIER reads back 0). Slave devices attach on the QEMU I2C bus.

---
 hw/i2c/Kconfig      |   4 +
 hw/i2c/imx_lpi2c.c  | 296 ++++++++++++++++++++++++++++++++++++++++++++
 hw/i2c/meson.build  |   1 +
 hw/i2c/trace-events |   4 +
 4 files changed, 305 insertions(+)
 create mode 100644 hw/i2c/imx_lpi2c.c
hw/i2c/Kconfig +4 -0
index 0766130b596..ee31513529f 100644
@@ -54,3 +54,7 @@ config PMBUS
 config BCM2835_I2C
     bool
     select I2C
+
+config IMX_LPI2C
+    bool
+    select I2C
hw/i2c/imx_lpi2c.c new file +296 -0

296 lines not on this page · raw message

hw/i2c/meson.build +1 -0
index 88aea35662d..ad6738f820e 100644
@@ -19,4 +19,5 @@ i2c_ss.add(when: 'CONFIG_PPC4XX', if_true: files('ppc4xx_i2c.c'))
 i2c_ss.add(when: 'CONFIG_PCA954X', if_true: files('i2c_mux_pca954x.c'))
 i2c_ss.add(when: 'CONFIG_PMBUS', if_true: files('pmbus_device.c'))
 i2c_ss.add(when: 'CONFIG_BCM2835_I2C', if_true: files('bcm2835_i2c.c'))
+i2c_ss.add(when: 'CONFIG_IMX_LPI2C', if_true: files('imx_lpi2c.c'))
 system_ss.add_all(when: 'CONFIG_I2C', if_true: i2c_ss)
hw/i2c/trace-events +4 -0
index 1ad0e95c0e6..88078e1c590 100644
@@ -61,3 +61,7 @@ pca954x_read_data(uint8_t value) "PCA954X read data: 0x%02x"
 
 imx_i2c_read(const char *id, const char *reg, uint64_t ofs, uint64_t value) "%s:[%s (0x%" PRIx64 ")] -> 0x%02" PRIx64
 imx_i2c_write(const char *id, const char *reg, uint64_t ofs, uint64_t value) "%s:[%s (0x%" PRIx64 ")] <- 0x%02" PRIx64
+imx_lpi2c_start(uint8_t addr, int recv) "start addr 0x%02x recv %d"
+imx_lpi2c_send(uint8_t data) "tx 0x%02x"
+imx_lpi2c_recv(uint8_t data) "rx 0x%02x"
+imx_lpi2c_stop(void) "stop"
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH 7/16 hw/misc: add i.MX Messaging Unit (MU v2)

In reply to Kyle Fox

The i.MX Messaging Unit (V2 register layout): the mailbox that carries SCMI between the A55 cluster and the M33 System Manager. Models CR/SR/GCR/GSR/GIER, the TR/RR data registers and the GCR.GIRn/GSR.GIPn doorbell. Two endpoints pair through a peer QOM link: a TR write is delivered into the peer's RR and the TX handshake completes when the peer reads RR, so the real, unmodified SM firmware answers Linux's SCMI traffic over the emulated mailbox.

---
 hw/misc/Kconfig          |   3 +
 hw/misc/imx_mu.c         | 454 +++++++++++++++++++++++++++++++++++++++
 hw/misc/meson.build      |   1 +
 hw/misc/trace-events     |   4 +
 include/hw/misc/imx_mu.h | 144 +++++++++++++
 5 files changed, 606 insertions(+)
 create mode 100644 hw/misc/imx_mu.c
 create mode 100644 include/hw/misc/imx_mu.h
hw/misc/Kconfig +3 -0
index b8860dd3e77..8645ca11f3f 100644
@@ -261,3 +261,6 @@ config AXIADO_CLK
     bool
 
 source macio/Kconfig
+
+config IMX_MU
+    bool
hw/misc/imx_mu.c new file +454 -0

454 lines not on this page · raw message

hw/misc/meson.build +1 -0
index e86d9ad6b39..9d0e3ed220d 100644
@@ -171,3 +171,4 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))
 system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c'))
 
 system_ss.add(when: 'CONFIG_AXIADO_CLK', if_true: files('axiado_clk.c'))
+system_ss.add(when: 'CONFIG_IMX_MU', if_true: files('imx_mu.c'))
hw/misc/trace-events +4 -0
index c9a868b3efb..01b0b275f7f 100644
@@ -442,3 +442,7 @@ iommu_testdev_dma_read(uint64_t gva, uint32_t len) "gva=0x%" PRIx64 " len=%u"
 iommu_testdev_dma_verify(uint32_t expected, uint32_t actual) "expected=0x%x actual=0x%x"
 iommu_testdev_dma_result(uint32_t result) "DMA completed result=0x%x"
 iommu_testdev_dma_armed(bool armed) "armed=%d"
+imx_mu_tr_write(unsigned idx, uint32_t val) "TR[%u] <- 0x%08x"
+imx_mu_rr_deliver(unsigned idx, uint32_t val) "RR[%u] <- 0x%08x"
+imx_mu_doorbell(unsigned idx) "doorbell GIR channel %u"
+imx_mu_gip(unsigned idx) "GIP assert channel %u"
include/hw/misc/imx_mu.h new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#11 lore raw

PATCH 8/16 hw/misc: add NXP EdgeLock Enclave (ELE) responder

In reply to Kyle Fox

The NXP EdgeLock Enclave (ELE) responder. U-Boot and the SM firmware issue ELE service requests (e.g. GET_INFO, get-random) over a dedicated MU; this models the responder that consumes the request words and returns a response so the secure bring-up sequence proceeds. It is linked to its MU through a QOM link property.

---
 hw/misc/Kconfig                    |   4 +
 hw/misc/imx95_ele_server.c         | 284 +++++++++++++++++++++++++++++
 hw/misc/meson.build                |   1 +
 hw/misc/trace-events               |   2 +
 include/hw/misc/imx95_ele_server.h |  47 +++++
 5 files changed, 338 insertions(+)
 create mode 100644 hw/misc/imx95_ele_server.c
 create mode 100644 include/hw/misc/imx95_ele_server.h
hw/misc/Kconfig +4 -0
index 8645ca11f3f..ded60e21a6c 100644
@@ -264,3 +264,7 @@ source macio/Kconfig
 
 config IMX_MU
     bool
+
+config IMX95_ELE_SERVER
+    bool
+    select IMX_MU
hw/misc/imx95_ele_server.c new file +284 -0

284 lines not on this page · raw message

hw/misc/meson.build +1 -0
index 9d0e3ed220d..b0dade72c6c 100644
@@ -172,3 +172,4 @@ system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c'))
 
 system_ss.add(when: 'CONFIG_AXIADO_CLK', if_true: files('axiado_clk.c'))
 system_ss.add(when: 'CONFIG_IMX_MU', if_true: files('imx_mu.c'))
+system_ss.add(when: 'CONFIG_IMX95_ELE_SERVER', if_true: files('imx95_ele_server.c'))
hw/misc/trace-events +2 -0
index 01b0b275f7f..6b3cff74549 100644
@@ -446,3 +446,5 @@ imx_mu_tr_write(unsigned idx, uint32_t val) "TR[%u] <- 0x%08x"
 imx_mu_rr_deliver(unsigned idx, uint32_t val) "RR[%u] <- 0x%08x"
 imx_mu_doorbell(unsigned idx) "doorbell GIR channel %u"
 imx_mu_gip(unsigned idx) "GIP assert channel %u"
+imx95_ele_msg(uint8_t command, uint8_t tag, uint32_t size) "received cmd 0x%02x tag 0x%02x size %u"
+imx95_ele_response(uint8_t command) "response cmd 0x%02x"
include/hw/misc/imx95_ele_server.h new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#12 lore raw

PATCH 9/16 hw/timer: add i.MX 95 system counter

In reply to Kyle Fox

The i.MX 95 System Counter: a 24 MHz free-running up-counter with a compare-match interrupt. On this machine it is the Linux broadcast clockevent. Models the counter read-back, compare-value programming and the compare IRQ (backed by a QEMUTimer).

---
 hw/timer/Kconfig        |   3 +
 hw/timer/imx95_sysctr.c | 241 ++++++++++++++++++++++++++++++++++++++++
 hw/timer/meson.build    |   1 +
 hw/timer/trace-events   |   2 +
 4 files changed, 247 insertions(+)
 create mode 100644 hw/timer/imx95_sysctr.c
hw/timer/Kconfig +3 -0
index e1b751a54a7..1e8c5d50d7e 100644
@@ -68,3 +68,6 @@ config AVR_TIMER16
 
 config HEX_QTIMER
     bool
+
+config IMX95_SYSCTR
+    bool
hw/timer/imx95_sysctr.c new file +241 -0

241 lines not on this page · raw message

hw/timer/meson.build +1 -0
index 8323efaf46b..5ce27a6df0a 100644
@@ -36,3 +36,4 @@ system_ss.add(when: 'CONFIG_SIFIVE_PWM', if_true: files('sifive_pwm.c'))
 system_ss.add(when: 'CONFIG_AVR_TIMER16', if_true: files('avr_timer16.c'))
 
 system_ss.add(when: 'CONFIG_HEX_QTIMER', if_true: files('qct-qtimer.c'))
+system_ss.add(when: 'CONFIG_IMX95_SYSCTR', if_true: files('imx95_sysctr.c'))
hw/timer/trace-events +2 -0
index 636310f8caa..df457bbb967 100644
@@ -133,3 +133,5 @@ imx_epit_cmp(uint32_t sr) "sr was %d"
 qtimer_interrupt(void) "qtimer interrupt line updated"
 qtimer_read(uint64_t offset) "offset 0x%" PRIx64
 qtimer_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
+imx95_sysctr_cmp(uint64_t cmpcv) "compare value 0x%" PRIx64
+imx95_sysctr_expire(void) "compare fired"
Signature · 1 line
2.34.1
author
#13 lore raw

PATCH 10/16 hw/misc: add i.MX 95 watchdog

In reply to Kyle Fox

The i.MX 95 watchdog. A register-level model of the CS/CNT/TOVAL/WIN registers and the unlock sequence, enough for the SM and Linux to configure and refresh it. It has no live timer and does not reset the machine on timeout; it exists so the watchdog node probes and is programmable rather than faulting on first access.

---
 hw/misc/Kconfig      |   3 +
 hw/misc/imx95_wdog.c | 198 +++++++++++++++++++++++++++++++++++++++++++
 hw/misc/meson.build  |   1 +
 hw/misc/trace-events |   2 +
 4 files changed, 204 insertions(+)
 create mode 100644 hw/misc/imx95_wdog.c
hw/misc/Kconfig +3 -0
index ded60e21a6c..2bae76b4ec1 100644
@@ -268,3 +268,6 @@ config IMX_MU
 config IMX95_ELE_SERVER
     bool
     select IMX_MU
+
+config IMX95_WDOG
+    bool
hw/misc/imx95_wdog.c new file +198 -0

198 lines not on this page · raw message

hw/misc/meson.build +1 -0
index b0dade72c6c..3f8cd1d825e 100644
@@ -173,3 +173,4 @@ system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c'))
 system_ss.add(when: 'CONFIG_AXIADO_CLK', if_true: files('axiado_clk.c'))
 system_ss.add(when: 'CONFIG_IMX_MU', if_true: files('imx_mu.c'))
 system_ss.add(when: 'CONFIG_IMX95_ELE_SERVER', if_true: files('imx95_ele_server.c'))
+system_ss.add(when: 'CONFIG_IMX95_WDOG', if_true: files('imx95_wdog.c'))
hw/misc/trace-events +2 -0
index 6b3cff74549..584c1f90963 100644
@@ -448,3 +448,5 @@ imx_mu_doorbell(unsigned idx) "doorbell GIR channel %u"
 imx_mu_gip(unsigned idx) "GIP assert channel %u"
 imx95_ele_msg(uint8_t command, uint8_t tag, uint32_t size) "received cmd 0x%02x tag 0x%02x size %u"
 imx95_ele_response(uint8_t command) "response cmd 0x%02x"
+imx95_wdog_config(uint32_t cs) "CS <- 0x%08x"
+imx95_wdog_unlock(void) "unlock word written"
Signature · 1 line
2.34.1
author
#14 lore raw

PATCH 11/16 hw/misc: add i.MX 95 ANATOP/AONMIX/GPC/SRC power and clock blocks

In reply to Kyle Fox

The power and clock bring-up blocks that the System Manager firmware programs before Linux starts: ANATOP (PLL lock / DFS status), SRC (system reset controller, including the M7 mix-slice release), GPC (general power controller mode requests) and the AONMIX block-control M7 CPU-WAIT gate (the SM's M7 hold/run control). These are register-level models that return the lock, ack and status bits the firmware polls.

---
 hw/misc/Kconfig        |  12 +++
 hw/misc/imx95_anatop.c | 201 ++++++++++++++++++++++++++++++++++++
 hw/misc/imx95_aonmix.c | 160 +++++++++++++++++++++++++++++
 hw/misc/imx95_gpc.c    | 160 +++++++++++++++++++++++++++++
 hw/misc/imx95_src.c    | 228 +++++++++++++++++++++++++++++++++++++++++
 hw/misc/meson.build    |   4 +
 hw/misc/trace-events   |   8 ++
 7 files changed, 773 insertions(+)
 create mode 100644 hw/misc/imx95_anatop.c
 create mode 100644 hw/misc/imx95_aonmix.c
 create mode 100644 hw/misc/imx95_gpc.c
 create mode 100644 hw/misc/imx95_src.c
hw/misc/Kconfig +12 -0
index 2bae76b4ec1..1e1cae92f6f 100644
@@ -271,3 +271,15 @@ config IMX95_ELE_SERVER
 
 config IMX95_WDOG
     bool
+
+config IMX95_ANATOP
+    bool
+
+config IMX95_AONMIX
+    bool
+
+config IMX95_GPC
+    bool
+
+config IMX95_SRC
+    bool
hw/misc/imx95_anatop.c new file +201 -0

201 lines not on this page · raw message

hw/misc/imx95_aonmix.c new file +160 -0

160 lines not on this page · raw message

hw/misc/imx95_gpc.c new file +160 -0

160 lines not on this page · raw message

hw/misc/imx95_src.c new file +228 -0

228 lines not on this page · raw message

hw/misc/meson.build +4 -0
index 3f8cd1d825e..0b7f5e4382d 100644
@@ -174,3 +174,7 @@ system_ss.add(when: 'CONFIG_AXIADO_CLK', if_true: files('axiado_clk.c'))
 system_ss.add(when: 'CONFIG_IMX_MU', if_true: files('imx_mu.c'))
 system_ss.add(when: 'CONFIG_IMX95_ELE_SERVER', if_true: files('imx95_ele_server.c'))
 system_ss.add(when: 'CONFIG_IMX95_WDOG', if_true: files('imx95_wdog.c'))
+system_ss.add(when: 'CONFIG_IMX95_ANATOP', if_true: files('imx95_anatop.c'))
+system_ss.add(when: 'CONFIG_IMX95_AONMIX', if_true: files('imx95_aonmix.c'))
+system_ss.add(when: 'CONFIG_IMX95_GPC', if_true: files('imx95_gpc.c'))
+system_ss.add(when: 'CONFIG_IMX95_SRC', if_true: files('imx95_src.c'))
hw/misc/trace-events +8 -0
index 584c1f90963..15fab0596c2 100644
@@ -450,3 +450,11 @@ imx95_ele_msg(uint8_t command, uint8_t tag, uint32_t size) "received cmd 0x%02x
 imx95_ele_response(uint8_t command) "response cmd 0x%02x"
 imx95_wdog_config(uint32_t cs) "CS <- 0x%08x"
 imx95_wdog_unlock(void) "unlock word written"
+imx95_anatop_read(uint64_t offset) "read off 0x%" PRIx64
+imx95_anatop_write(uint64_t offset, uint64_t value) "write off 0x%" PRIx64 " <- 0x%08" PRIx64
+imx95_aonmix_read(uint64_t offset) "read off 0x%" PRIx64
+imx95_aonmix_write(uint64_t offset, uint64_t value) "write off 0x%" PRIx64 " <- 0x%08" PRIx64
+imx95_aonmix_m7_gate(int run) "M7 wait gate -> run=%d"
+imx95_gpc_mode(uint64_t offset, uint32_t target) "CMC_MODE_CTRL off 0x%" PRIx64 " target %u"
+imx95_src_m7mix_release(void) "SRC_GEN.SCR M7MIX reset released"
+imx95_src_slice_ctrl(uint64_t offset, uint32_t value) "SLICE_SW_CTRL off 0x%" PRIx64 " <- 0x%08x"
Signature · 1 line
2.34.1
author
#15 lore raw

PATCH 12/16 hw/misc: add i.MX 95 PMIC (PF09/PF53/PCAL6408A) and xcache controllers

In reply to Kyle Fox

The i.MX 95 EVK power devices on LPI2C - the PF09 and PF53 regulators and the PCAL6408A IO expander that the SM firmware sequences during power-up - modelled as I2C-slave register files, plus the xcache (cache controller) register block.

---
 hw/misc/Kconfig        |   7 +
 hw/misc/imx95_pmic.c   | 357 +++++++++++++++++++++++++++++++++++++++++
 hw/misc/imx95_xcache.c | 185 +++++++++++++++++++++
 hw/misc/meson.build    |   2 +
 hw/misc/trace-events   |   8 +
 5 files changed, 559 insertions(+)
 create mode 100644 hw/misc/imx95_pmic.c
 create mode 100644 hw/misc/imx95_xcache.c
hw/misc/Kconfig +7 -0
index 1e1cae92f6f..e1b8c390312 100644
@@ -283,3 +283,10 @@ config IMX95_GPC
 
 config IMX95_SRC
     bool
+
+config IMX95_PMIC
+    bool
+    select I2C
+
+config IMX95_XCACHE
+    bool
hw/misc/imx95_pmic.c new file +357 -0

357 lines not on this page · raw message

hw/misc/imx95_xcache.c new file +185 -0

185 lines not on this page · raw message

hw/misc/meson.build +2 -0
index 0b7f5e4382d..d7d283a191b 100644
@@ -178,3 +178,5 @@ system_ss.add(when: 'CONFIG_IMX95_ANATOP', if_true: files('imx95_anatop.c'))
 system_ss.add(when: 'CONFIG_IMX95_AONMIX', if_true: files('imx95_aonmix.c'))
 system_ss.add(when: 'CONFIG_IMX95_GPC', if_true: files('imx95_gpc.c'))
 system_ss.add(when: 'CONFIG_IMX95_SRC', if_true: files('imx95_src.c'))
+system_ss.add(when: 'CONFIG_IMX95_PMIC', if_true: files('imx95_pmic.c'))
+system_ss.add(when: 'CONFIG_IMX95_XCACHE', if_true: files('imx95_xcache.c'))
hw/misc/trace-events +8 -0
index 15fab0596c2..0555b15a1f3 100644
@@ -458,3 +458,11 @@ imx95_aonmix_m7_gate(int run) "M7 wait gate -> run=%d"
 imx95_gpc_mode(uint64_t offset, uint32_t target) "CMC_MODE_CTRL off 0x%" PRIx64 " target %u"
 imx95_src_m7mix_release(void) "SRC_GEN.SCR M7MIX reset released"
 imx95_src_slice_ctrl(uint64_t offset, uint32_t value) "SLICE_SW_CTRL off 0x%" PRIx64 " <- 0x%08x"
+imx95_xcache_read(uint64_t offset) "read off 0x%" PRIx64
+imx95_xcache_write(uint64_t offset, uint64_t value) "write off 0x%" PRIx64 " <- 0x%08" PRIx64
+pf09_reg_read(uint8_t reg, uint8_t val) "PF09 reg 0x%02x -> 0x%02x"
+pf09_reg_write(uint8_t reg, uint8_t val) "PF09 reg 0x%02x <- 0x%02x"
+pcal6408a_reg_read(uint8_t reg, uint8_t val) "PCAL6408A reg 0x%02x -> 0x%02x"
+pcal6408a_reg_write(uint8_t reg, uint8_t val) "PCAL6408A reg 0x%02x <- 0x%02x"
+pf53_reg_read(uint8_t reg, uint8_t val) "PF53 reg 0x%02x -> 0x%02x"
+pf53_reg_write(uint8_t reg, uint8_t val) "PF53 reg 0x%02x <- 0x%02x"
Signature · 1 line
2.34.1
author
#16 lore raw

PATCH 13/16 hw/misc: add i.MX 95 DPU command-sequencer stub (headless)

In reply to Kyle Fox

A minimal stub for the i.MX 95 DPU (display controller) command sequencer. This machine is headless, but Linux's dpu95 driver busy-waits with no timeout on the sequencer status register during probe, so a reads-as-zero stub would hang userspace bring-up. The stub reports the sequencer idle with FIFO space so the probe completes. Real display scanout is left to a follow-on series.

---
 hw/misc/Kconfig      |   3 ++
 hw/misc/imx95_dpu.c  | 117 +++++++++++++++++++++++++++++++++++++++++++
 hw/misc/meson.build  |   1 +
 hw/misc/trace-events |   1 +
 4 files changed, 122 insertions(+)
 create mode 100644 hw/misc/imx95_dpu.c
hw/misc/Kconfig +3 -0
index e1b8c390312..59c55cb5b83 100644
@@ -290,3 +290,6 @@ config IMX95_PMIC
 
 config IMX95_XCACHE
     bool
+
+config IMX95_DPU
+    bool
hw/misc/imx95_dpu.c new file +117 -0

117 lines not on this page · raw message

hw/misc/meson.build +1 -0
index d7d283a191b..9d629c8efef 100644
@@ -180,3 +180,4 @@ system_ss.add(when: 'CONFIG_IMX95_GPC', if_true: files('imx95_gpc.c'))
 system_ss.add(when: 'CONFIG_IMX95_SRC', if_true: files('imx95_src.c'))
 system_ss.add(when: 'CONFIG_IMX95_PMIC', if_true: files('imx95_pmic.c'))
 system_ss.add(when: 'CONFIG_IMX95_XCACHE', if_true: files('imx95_xcache.c'))
+system_ss.add(when: 'CONFIG_IMX95_DPU', if_true: files('imx95_dpu.c'))
hw/misc/trace-events +1 -0
index 0555b15a1f3..e921b5f290a 100644
@@ -466,3 +466,4 @@ pcal6408a_reg_read(uint8_t reg, uint8_t val) "PCAL6408A reg 0x%02x -> 0x%02x"
 pcal6408a_reg_write(uint8_t reg, uint8_t val) "PCAL6408A reg 0x%02x <- 0x%02x"
 pf53_reg_read(uint8_t reg, uint8_t val) "PF53 reg 0x%02x -> 0x%02x"
 pf53_reg_write(uint8_t reg, uint8_t val) "PF53 reg 0x%02x <- 0x%02x"
+imx95_dpu_cmdseq_status(uint32_t value) "CMDSEQ_STATUS -> 0x%08x"
Signature · 1 line
2.34.1
author
#17 lore raw

PATCH 14/16 hw/arm: add i.MX 95 SoC container (fsl-imx95)

In reply to Kyle Fox

The i.MX 95 SoC container. Assembles the six Cortex-A55 application cores with a GICv3, the Cortex-M33 that runs the System Manager and the SM-managed Cortex-M7, the MU cross-connects that carry SCMI and rpmsg, the bring-up peripherals, and the uSDHC used for SD boot; it lays out the SoC memory map and wires PSCI for the A55 cluster. Blocks that are not on the boot path are mapped as logging stubs so that enabling their device-tree nodes degrades gracefully.

---
 hw/arm/Kconfig             |   19 +
 hw/arm/fsl-imx95.c         | 1646 ++++++++++++++++++++++++++++++++++++
 hw/arm/meson.build         |    1 +
 include/hw/arm/fsl-imx95.h |  481 +++++++++++
 4 files changed, 2147 insertions(+)
 create mode 100644 hw/arm/fsl-imx95.c
 create mode 100644 include/hw/arm/fsl-imx95.h
hw/arm/Kconfig +19 -0
index 260d2f07516..7f1c0723ec0 100644
@@ -745,3 +745,22 @@ config AXIADO_EVK
     default y
     depends on TCG && ARM
     select AXIADO_SOC
+config FSL_IMX95
+    bool
+    select ARM_GIC
+    select ARM_GICV3
+    select IMX_LPUART
+    select IMX_MU
+    select IMX95_ELE_SERVER
+    select IMX95_WDOG
+    select IMX95_XCACHE
+    select IMX95_PMIC
+    select IMX95_GPC
+    select IMX95_SRC
+    select IMX95_AONMIX
+    select IMX95_ANATOP
+    select IMX95_DPU
+    select IMX95_SYSCTR
+    select IMX_LPI2C
+    select SDHCI
+    select UNIMP
hw/arm/fsl-imx95.c new file +1646 -0

1,646 lines not on this page · raw message

hw/arm/meson.build +1 -0
index 8ee5307a919..96fef4c5b5f 100644
@@ -117,5 +117,6 @@ arm_common_ss.add(when: ['CONFIG_AXIADO_EVK', 'TARGET_AARCH64'], if_true: files(
   'ax3000-evk.c'))
 
 arm_common_ss.add(files('boot.c'))
+arm_common_ss.add(when: 'CONFIG_FSL_IMX95', if_true: files('fsl-imx95.c'))
 
 hw_common_arch += {'arm': arm_common_ss}
include/hw/arm/fsl-imx95.h new file +481 -0

481 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#18 lore raw

PATCH 15/16 hw/arm: add i.MX 95 19x19 EVK board

In reply to Kyle Fox

The i.MX 95 19x19 EVK board (machine type imx95-19x19-evk). Instantiates the SoC, sets up the LPDDR5 DRAM, and provides the direct -kernel/-dtb/-initrd Linux boot path alongside the System Manager firmware loaded on the M33. This is the user-facing machine type.

---
 hw/arm/Kconfig     |   7 +++
 hw/arm/imx95-evk.c | 136 +++++++++++++++++++++++++++++++++++++++++++++
 hw/arm/meson.build |   1 +
 3 files changed, 144 insertions(+)
 create mode 100644 hw/arm/imx95-evk.c
hw/arm/Kconfig +7 -0
index 7f1c0723ec0..d93808a48ee 100644
@@ -764,3 +764,10 @@ config FSL_IMX95
     select IMX_LPI2C
     select SDHCI
     select UNIMP
+
+config FSL_IMX95_EVK
+    bool
+    default y
+    depends on AARCH64
+    depends on TCG
+    select FSL_IMX95
hw/arm/imx95-evk.c new file +136 -0

136 lines not on this page · raw message

hw/arm/meson.build +1 -0
index 96fef4c5b5f..cdb61fa1612 100644
@@ -118,5 +118,6 @@ arm_common_ss.add(when: ['CONFIG_AXIADO_EVK', 'TARGET_AARCH64'], if_true: files(
 
 arm_common_ss.add(files('boot.c'))
 arm_common_ss.add(when: 'CONFIG_FSL_IMX95', if_true: files('fsl-imx95.c'))
+arm_common_ss.add(when: 'CONFIG_FSL_IMX95_EVK', if_true: files('imx95-evk.c'))
 
 hw_common_arch += {'arm': arm_common_ss}
Signature · 1 line
2.34.1
author
#19 lore raw

PATCH 16/16 docs, MAINTAINERS, tests/functional: add i.MX 95 EVK

In reply to Kyle Fox

Add the machine documentation (docs/system/arm/imx95-evk.rst, linked into the target-arm manual), the MAINTAINERS entry, and an environment-gated functional test that boots Linux to userspace on the real System Manager firmware.

---
 MAINTAINERS                                |  18 ++
 docs/system/arm/imx95-evk.rst              | 242 +++++++++++++++++++++
 docs/system/target-arm.rst                 |   1 +
 tests/functional/aarch64/meson.build       |   2 +
 tests/functional/aarch64/test_imx95_evk.py | 157 +++++++++++++
 5 files changed, 420 insertions(+)
 create mode 100644 docs/system/arm/imx95-evk.rst
 create mode 100644 tests/functional/aarch64/test_imx95_evk.py
MAINTAINERS +18 -0
index b51f5c3e602..f66082eadc4 100644
@@ -956,6 +956,24 @@ F: docs/system/arm/imx8m.rst
 F: tests/functional/aarch64/test_imx8mp_evk.py
 F: tests/qtest/rs5c372-test.c
 
+MCIMX95-19X19-EVK / i.MX95
+M: Kyle Fox <[email protected]>
+L: [email protected]
+S: Maintained
+F: hw/arm/imx95-evk.c
+F: hw/arm/fsl-imx95.c
+F: hw/misc/imx95_*.c
+F: hw/timer/imx95_sysctr.c
+F: hw/char/imx_lpuart.c
+F: hw/i2c/imx_lpi2c.c
+F: hw/misc/imx_mu.c
+F: include/hw/arm/fsl-imx95.h
+F: include/hw/char/imx_lpuart.h
+F: include/hw/misc/imx_mu.h
+F: include/hw/misc/imx95_*.h
+F: docs/system/arm/imx95-evk.rst
+F: tests/functional/aarch64/test_imx95_evk.py
+
 MPS2 / MPS3
 M: Peter Maydell <[email protected]>
 L: [email protected]
docs/system/arm/imx95-evk.rst new file +242 -0

242 lines not on this page · raw message

docs/system/target-arm.rst +1 -0
index e34492402f0..514d89e2d59 100644
@@ -95,6 +95,7 @@ Board-specific documentation
    arm/mcimx6ul-evk
    arm/mcimx7d-sabre
    arm/imx8m
+   arm/imx95-evk
    arm/orangepi
    arm/raspi
    arm/collie
tests/functional/aarch64/meson.build +2 -0
index e81afd6c39f..972e896c149 100644
@@ -7,6 +7,7 @@ test_aarch64_timeouts = {
   'device_passthrough' : 720,
   'imx8mm_evk' : 240,
   'imx8mp_evk' : 240,
+  'imx95_evk' : 240,
   'raspi4' : 480,
   'reverse_debug' : 180,
   'rme_virt' : 1200,
@@ -33,6 +34,7 @@ tests_aarch64_system_thorough = [
   'hotplug_pci',
   'imx8mm_evk',
   'imx8mp_evk',
+  'imx95_evk',
   'kvm',
   'multiprocess',
   'raspi3',
tests/functional/aarch64/test_imx95_evk.py new file +157 -0

157 lines not on this page · raw message

Signature · 1 line
2.34.1