Skip to contentSkip to conversation

hw/arm: Enable U-Boot boot on MCIMX6UL-EVK

PATCH Superseded Bin Meng 4 participants 21 messages Sep 4 – Oct 4

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

v2 cover hw/arm: Enable U-Boot boot on MCIMX6UL-EVK

The mcimx6ul-evk machine can boot Linux directly, but it cannot run the U-Boot proper produced by Buildroot far enough to load a kernel from its SD card. Early U-Boot boot test accesses currently abort or observe placeholder values, and the i.MX uSDHC model exposes several issues.

This series lets an unmodified Buildroot 2026.05 U-Boot 2024.07 image run on mcimx6ul-evk, load zImage and imx6ul-14x14-evk.dtb from USDHC2, start Linux, mount the SD card root file system, and reach the Buildroot login prompt. It also documents and tests the existing direct Linux boot path.

Patches 1 through 4 provide the minimum early-firmware-visible state. Patches 5 through 8 address i.MX uSDHC behavior needed by U-Boot. The last two patches document both boot paths and add functional tests for U-Boot and direct Linux boot.

This series is based on:
<[email protected]> as the sdhci changes have conflicts.

Changes in v2:
- rebase on top of the microchip polarfire soc series

Bin Meng (10):
hw/arm: fsl-imx6ul: Add SCU compatibility window hw/misc: imx6ul_ccm: Update PMU_MISC0 reset value hw/arm: fsl-imx6ul: Map early firmware register placeholders hw/arm: fsl-imx6ul: Add a minimal MMDC geometry model hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates hw/sd: sdhci: Preserve uSDHC status enables for U-Boot hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC docs/system/arm: Document MCIMX6UL-EVK Buildroot boot tests/functional/arm: Add MCIMX6UL-EVK boot tests

 MAINTAINERS                               |  1 +
 docs/system/arm/mcimx6ul-evk.rst          | 67 +++++++++++++++++
 include/hw/arm/fsl-imx6ul.h               |  2 +
 include/hw/sd/sdhci.h                     | 15 +++-
 hw/arm/fsl-imx6ul.c                       | 87 +++++++++++++++++++++-
 hw/arm/mcimx6ul-evk.c                     |  2 +
 hw/misc/imx6ul_ccm.c                      |  2 +-
 hw/sd/sdhci.c                             | 89 +++++++++++++++++++----
 tests/functional/arm/meson.build          |  2 +
 tests/functional/arm/test_mcimx6ul_evk.py | 69 ++++++++++++++++++
 10 files changed, 314 insertions(+), 22 deletions(-)
 create mode 100644 tests/functional/arm/test_mcimx6ul_evk.py

---
base-commit: ae88a4d09c609651004dab309cd375d9f90323d3
branch: imx6ul-evk

Signature · 1 line
2.53.0
author
#1 lore raw

PATCH v2 1/10 hw/arm: fsl-imx6ul: Add SCU compatibility window

U-Boot's common i.MX6 CPU identification code reads the Cortex-A9 SCU configuration register at PERIPHBASE + 0x4 even on i.MX6UL. The value is only used to distinguish Cortex-A9 i.MX6 variants.

Cortex-A7 reserves this address and reading it causes data abort.

The same U-Boot abort was discussed on qemu-arm in September 2024:
https://lists.gnu.org/archive/html/qemu-arm/2024-09/msg00072.html

Map only the four-byte configuration-register address as an unimplemented device. Its zero read result gives U-Boot the single-CPU encoding after the low two bits are masked, while the remainder of the reserved Cortex-A7 page stays unmapped.

---

(no changes since v1)

 hw/arm/fsl-imx6ul.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/arm/fsl-imx6ul.c +9 -0
index 1863558a0d..d6f662efe4 100644
@@ -187,6 +187,15 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort);
     sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR);
 
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);
+
     gic = mpcore;
     gicsbd = SYS_BUS_DEVICE(gic);
     cpu = DEVICE(&s->cpu);
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v2 01/10] hw/arm: fsl-imx6ul: Add SCU compatibility window

Quoted 29 lines · Bin Meng

U-Boot's common i.MX6 CPU identification code reads the Cortex-A9 SCU configuration register at PERIPHBASE + 0x4 even on i.MX6UL. The value is only used to distinguish Cortex-A9 i.MX6 variants.

Cortex-A7 reserves this address and reading it causes data abort.

The same U-Boot abort was discussed on qemu-arm in September 2024:
https://lists.gnu.org/archive/html/qemu-arm/2024-09/msg00072.html

Map only the four-byte configuration-register address as an unimplemented device. Its zero read result gives U-Boot the single-CPU encoding after the low two bits are masked, while the remainder of the reserved Cortex-A7 page stays unmapped.

---

(no changes since v1)

 hw/arm/fsl-imx6ul.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/arm/fsl-imx6ul.c +0 -0
index 1863558a0d..d6f662efe4 100644
@@ -187,6 +187,15 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort);

hw/arm/fsl-imx6ul.c static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) · line 197

Quoted 10 lines
hw/arm/fsl-imx6ul.c +8 -0
     sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR);
 
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);

What is actually going on here, though? Why is u-boot reading an address that's only here for the A9? Has this been reported to u-boot as a bug? What does the real hardware do?

Whatever the answers are, I expect the correct fix is not going to be "fake up this specific 4 bytes to ignore accesses in the imx6 SoC model".

thanks
-- PMM

#3 lore raw

Re: [PATCH v2 01/10] hw/arm: fsl-imx6ul: Add SCU compatibility window

Hi Peter,

Quoted 33 lines · Peter Maydell
Quoted 31 lines · Bin Meng

U-Boot's common i.MX6 CPU identification code reads the Cortex-A9 SCU configuration register at PERIPHBASE + 0x4 even on i.MX6UL. The value is only used to distinguish Cortex-A9 i.MX6 variants.

Cortex-A7 reserves this address and reading it causes data abort.

The same U-Boot abort was discussed on qemu-arm in September 2024:
https://lists.gnu.org/archive/html/qemu-arm/2024-09/msg00072.html

Map only the four-byte configuration-register address as an unimplemented device. Its zero read result gives U-Boot the single-CPU encoding after the low two bits are masked, while the remainder of the reserved Cortex-A7 page stays unmapped.

---

(no changes since v1)

 hw/arm/fsl-imx6ul.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/arm/fsl-imx6ul.c +0 -0
index 1863558a0d..d6f662efe4 100644
@@ -187,6 +187,15 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort);
     sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR);
 
Quoted 12 lines

hw/arm/fsl-imx6ul.c static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) · line 197

Quoted 8 lines
hw/arm/fsl-imx6ul.c +8 -0
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);

What is actually going on here, though? Why is u-boot reading an address that's only here for the A9? Has this been reported to u-boot as a bug? What does the real hardware do?

I suspect the reason is that the imx6 family contains both A9 and A7 based SoCs and it's a leftover when imx6ul support was introduced in U-Boot. I do not see a bug report against U-Boot yet.

Quoted 5 lines

Whatever the answers are, I expect the correct fix is not going to be "fake up this specific 4 bytes to ignore accesses in the imx6 SoC model".

Apparently the real hardware ignores the scu access on A7. So IMO it could be accepted as a workaround for buggy software although guests should not do so.

Regards,
Bin

#4 lore raw

Re: [PATCH v2 01/10] hw/arm: fsl-imx6ul: Add SCU compatibility window

Quoted 25 lines · Bin Meng

Hi Peter,

Quoted 12 lines · Peter Maydell

hw/arm/fsl-imx6ul.c static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) · line 197

Quoted 9 lines · Bin Meng
hw/arm/fsl-imx6ul.c +8 -0
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);
Quoted 3 lines

What is actually going on here, though? Why is u-boot reading an address that's only here for the A9? Has this been reported to u-boot as a bug? What does the real hardware do?

I suspect the reason is that the imx6 family contains both A9 and A7 based SoCs and it's a leftover when imx6ul support was introduced in U-Boot. I do not see a bug report against U-Boot yet.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Whatever the answers are, I expect the correct fix is not going to be "fake up this specific 4 bytes to ignore accesses in the imx6 SoC model".

Apparently the real hardware ignores the scu access on A7. So IMO it could be accepted as a workaround for buggy software although guests should not do so.

Mmm, but I don't think the fix is going to be just this 4 bytes, and possibly it shouldn't be in this SoC specifically.

What does the TRM for the SoC say is at this address?

-- PMM

#5 lore raw

Re: [PATCH v2 01/10] hw/arm: fsl-imx6ul: Add SCU compatibility window

Hi Peter,

Quoted 32 lines · Peter Maydell
Quoted 30 lines · Bin Meng

Hi Peter,

Quoted 12 lines · Peter Maydell

hw/arm/fsl-imx6ul.c static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) · line 197

Quoted 9 lines · Bin Meng
hw/arm/fsl-imx6ul.c +8 -0
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);
Quoted 3 lines

What is actually going on here, though? Why is u-boot reading an address that's only here for the A9? Has this been reported to u-boot as a bug? What does the real hardware do?

I suspect the reason is that the imx6 family contains both A9 and A7 based SoCs and it's a leftover when imx6ul support was introduced in U-Boot. I do not see a bug report against U-Boot yet.

Quoted 5 lines

Whatever the answers are, I expect the correct fix is not going to be "fake up this specific 4 bytes to ignore accesses in the imx6 SoC model".

Quoted 9 lines
Quoted 3 lines

Apparently the real hardware ignores the scu access on A7. So IMO it could be accepted as a workaround for buggy software although guests should not do so.

Mmm, but I don't think the fix is going to be just this 4 bytes, and possibly it shouldn't be in this SoC specifically.

What does the TRM for the SoC say is at this address?

The TRM for the SoC only says 00A0_0000 - 00A0_7FFF windows is for "ARM Peripherals: GIC400 Only visible to ARM core(s)", then in the TRM for Cortex-A7 the address 0x0000 - 0x0FFF is marked as reserved.

I plan to submit a patch to the U-Boot upstream to see how the maintainer thinks.

Regards,
Bin

#6 lore raw

Re: [PATCH v2 01/10] hw/arm: fsl-imx6ul: Add SCU compatibility window

Hi Peter,

Quoted 46 lines · Bin Meng

Hi Peter,

Quoted 32 lines · Peter Maydell
Quoted 30 lines · Bin Meng

Hi Peter,

Quoted 12 lines · Peter Maydell

hw/arm/fsl-imx6ul.c static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) · line 197

Quoted 9 lines · Bin Meng
hw/arm/fsl-imx6ul.c +8 -0
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);
Quoted 3 lines

What is actually going on here, though? Why is u-boot reading an address that's only here for the A9? Has this been reported to u-boot as a bug? What does the real hardware do?

I suspect the reason is that the imx6 family contains both A9 and A7 based SoCs and it's a leftover when imx6ul support was introduced in U-Boot. I do not see a bug report against U-Boot yet.

Quoted 5 lines

Whatever the answers are, I expect the correct fix is not going to be "fake up this specific 4 bytes to ignore accesses in the imx6 SoC model".

Quoted 9 lines
Quoted 3 lines

Apparently the real hardware ignores the scu access on A7. So IMO it could be accepted as a workaround for buggy software although guests should not do so.

Mmm, but I don't think the fix is going to be just this 4 bytes, and possibly it shouldn't be in this SoC specifically.

What does the TRM for the SoC say is at this address?

Quoted 7 lines

The TRM for the SoC only says 00A0_0000 - 00A0_7FFF windows is for "ARM Peripherals: GIC400 Only visible to ARM core(s)", then in the TRM for Cortex-A7 the address 0x0000 - 0x0FFF is marked as reserved.

I plan to submit a patch to the U-Boot upstream to see how the maintainer thinks.

After further reading the GIC-400 TRM (DDI0471B), I found chapter 3.1 says:

The following information applies to the GIC-400 registers:
• The base address of the GIC-400 is not fixed, and can be different for a particular system
implementation. The offset of each register from the base address is fixed.
• Access to reserved or unused address locations is RAZ/WI (Read-as-Zero, Writes Ignored).
• Unless otherwise stated in the accompanying text:
— Do not modify reserved register bits.
— Ignore reserved register bits on reads.
— All register bits are reset to 0 by a system or power-on reset.

It seems we should create a 4KiB unimplemented window within GiC-400.

Regards,
Bin

author
#7 lore raw

PATCH v2 2/10 hw/misc: imx6ul_ccm: Update PMU_MISC0 reset value

In reply to Bin Meng

Commit 56a11a9b7580 ("hw/misc: imx6_ccm: Update PMU_MISC0 reset value") updated the i.MX6 CCM model so U-Boot sees PMU_MISC0[REFTOP_VBGUP] set after reset. The i.MX6UL CCM model still returns this bit clear, causing U-Boot init_bandgap() to wait for a state that the model never reaches.

Apply the same reset behavior to the i.MX6UL CCM model so U-Boot can observe that the bandgap has stabilized.

---

(no changes since v1)

 hw/misc/imx6ul_ccm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/imx6ul_ccm.c +1 -1
index c4f6e372fe..4accbcbeed 100644
@@ -592,7 +592,7 @@ static void imx6ul_ccm_reset(DeviceState *dev)
     s->analog[PMU_REG_3P0] = 0x00000F74;
     s->analog[PMU_REG_2P5] = 0x00001073;
     s->analog[PMU_REG_CORE] = 0x00482012;
-    s->analog[PMU_MISC0] = 0x04000000;
+    s->analog[PMU_MISC0] = 0x04000080;
     s->analog[PMU_MISC1] = 0x00000000;
     s->analog[PMU_MISC2] = 0x00272727;
     s->analog[PMU_LOWPWR_CTRL] = 0x00004009;
Signature · 1 line
2.53.0
author
#8 lore raw

PATCH v2 3/10 hw/arm: fsl-imx6ul: Map early firmware register placeholders

In reply to Bin Meng

U-Boot configures the AIPS bus access controls and the i.MX6UL SNVS low-power registers before its console is available. Its timer setup also enables the system counter through the control window on AIPS2.

These blocks are not modeled yet. Map unimplemented regions at their documented addresses so early firmware accesses complete without falling through to unmapped memory.

---

(no changes since v1)

 hw/arm/fsl-imx6ul.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/arm/fsl-imx6ul.c +15 -0
index d6f662efe4..74c1a30959 100644
@@ -210,6 +210,21 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR,
                                 FSL_IMX6UL_A7MPCORE_DAP_SIZE);
 
+    /* AIPS bus configuration */
+    create_unimplemented_device("aips1-config", FSL_IMX6UL_AIPS1_CFG_ADDR,
+                                FSL_IMX6UL_AIPS1_CFG_SIZE);
+    create_unimplemented_device("aips2-config", FSL_IMX6UL_AIPS2_CFG_ADDR,
+                                FSL_IMX6UL_AIPS2_CFG_SIZE);
+
+    /* SNVS low-power general-purpose registers */
+    create_unimplemented_device("snvs-lp", FSL_IMX6UL_SNVS_LP_ADDR,
+                                FSL_IMX6UL_SNVS_LP_SIZE);
+
+    /* System counter control */
+    create_unimplemented_device("sys-counter-control",
+                                FSL_IMX6UL_SYS_CNT_CTRL_ADDR,
+                                FSL_IMX6UL_SYS_CNT_CTRL_SIZE);
+
     /*
      * MMDC
      */
Signature · 1 line
2.53.0
author
#9 lore raw

PATCH v2 4/10 hw/arm: fsl-imx6ul: Add a minimal MMDC geometry model

In reply to Bin Meng

U-Boot probes DRAM size from the MMDC MDCTL and MDMISC registers. The existing unimplemented region returns zero, so U-Boot cannot derive a geometry matching the RAM mapped by the machine.

Replace the placeholder with a small read-only model. Use the 8-bank, 16-bit DDR3 layout of the EVK and derive the row count from the machine RAM size.

---

(no changes since v1)

 include/hw/arm/fsl-imx6ul.h |  2 ++
 hw/arm/fsl-imx6ul.c         | 63 +++++++++++++++++++++++++++++++++++--
 hw/arm/mcimx6ul-evk.c       |  2 ++
 3 files changed, 65 insertions(+), 2 deletions(-)
include/hw/arm/fsl-imx6ul.h +2 -0
index 6205fe6b77..bc0baca721 100644
@@ -90,9 +90,11 @@ struct FslIMX6ULState {
     MemoryRegion       caam;
     MemoryRegion       ocram;
     MemoryRegion       ocram_alias;
+    MemoryRegion       mmdc;
 
     uint32_t           phy_num[FSL_IMX6UL_NUM_ETHS];
     bool               phy_connected[FSL_IMX6UL_NUM_ETHS];
+    uint64_t           ram_size;
 };
 
 enum FslIMX6ULMemoryMap {
hw/arm/fsl-imx6ul.c +61 -2

92 lines not on this page · raw message

hw/arm/mcimx6ul-evk.c +2 -0
index 40071d2c7b..bbc964a3f7 100644
@@ -44,6 +44,8 @@ static void mcimx6ul_evk_init(MachineState *machine)
     object_property_set_uint(OBJECT(s), "fec2-phy-num", 1, &error_fatal);
     object_property_set_bool(OBJECT(s), "fec1-phy-connected", false,
                              &error_fatal);
+    object_property_set_uint(OBJECT(s), "ram-size", machine->ram_size,
+                             &error_fatal);
     qdev_realize(DEVICE(s), NULL, &error_fatal);
 
     memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR,
Signature · 1 line
2.53.0
author
#10 lore raw

PATCH v2 5/10 hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit

In reply to Bin Meng

SDHCI_QUIRK_NO_BUSY_IRQ was copied from Linux with its bit number unchanged. The quirk mask is internal to QEMU: it is neither visible to guests nor part of migration state. Mirroring Linux therefore provides no compatibility benefit and constrains local allocations.

Move it to bit zero so QEMU can allocate SDHCI quirks sequentially in its own namespace.

---

(no changes since v1)

 include/hw/sd/sdhci.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
include/hw/sd/sdhci.h +1 -4
index c485277744..2d03e37653 100644
@@ -111,11 +111,8 @@ typedef struct SDHCIState SDHCIState;
 /*
  * Controller does not provide transfer-complete interrupt when not
  * busy.
- *
- * NOTE: This definition is taken out of Linux kernel and so the
- * original bit number is preserved
  */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(14)
+#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
Signature · 1 line
2.53.0
Reviewed-by on v2 5/10
#11 lore raw

Re: [PATCH v2 05/10] hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit

Am 4. September 2026 16:14:28 UTC schrieb Bin Meng <[email protected]>:

Quoted 22 lines

SDHCI_QUIRK_NO_BUSY_IRQ was copied from Linux with its bit number unchanged. The quirk mask is internal to QEMU: it is neither visible to guests nor part of migration state. Mirroring Linux therefore provides no compatibility benefit and constrains local allocations.

Move it to bit zero so QEMU can allocate SDHCI quirks sequentially in its own namespace.

---

(no changes since v1)

include/hw/sd/sdhci.h | 5 +----

1 file changed, 1 insertion(+), 4 deletions(-)
include/hw/sd/sdhci.h +0 -0
index c485277744..2d03e37653 100644

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

Quoted 9 lines
include/hw/sd/sdhci.h +1 -4
@@ -111,11 +111,8 @@ typedef struct SDHCIState SDHCIState;
 /*
 * Controller does not provide transfer-complete interrupt when not
 * busy.
- *
- * NOTE: This definition is taken out of Linux kernel and so the
- * original bit number is preserved
 */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(14)
+#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)

In anticipation of the upcoming commits you could align the bit such that this line doesn't change again.

Quoted 3 lines
include/hw/sd/sdhci.h +0 -0
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
author
#12 lore raw

PATCH v2 6/10 hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates

In reply to Bin Meng

U-Boot's i.MX uSDHC driver enables IPGEN, HCKEN, PEREN and CKEN in VEND_SPEC rather than the standard SDHCI clock-control fields. QEMU only checks the standard fields before issuing a command. It therefore silently drops U-Boot's MMC commands even though the controller clocks are enabled. U-Boot eventually times out waiting for command completion and cannot load the kernel and device tree from the SD card.

Accept the complete vendor clock-gate set as another valid clock source for i.MX uSDHC. Also report SDSTB when the vendor IP and host clocks are enabled, matching the state U-Boot polls while changing the clock.

Keep this behavior behind an i.MX uSDHC quirk because the shared eSDHC paths also serve controllers which use the standard SDHCI fields.

Reference: IMX6ULRM (Rev 2), section 56.8.10, 56.8.12 and 56.8.26
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

Changes in v2:
- rebase on top of the microchip polarfire soc series

 include/hw/sd/sdhci.h |  7 ++++++-
 hw/sd/sdhci.c         | 27 ++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)
include/hw/sd/sdhci.h +6 -1
index 2d03e37653..83d465774b 100644
@@ -112,7 +112,12 @@ typedef struct SDHCIState SDHCIState;
  * Controller does not provide transfer-complete interrupt when not
  * busy.
  */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)
+#define SDHCI_QUIRK_NO_BUSY_IRQ          BIT(0)
+/*
+ * Controller uses vendor-specific clock gates in place of the standard
+ * SDHCI clock-control fields
+ */
+#define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
hw/sd/sdhci.c +24 -3
index 14c312a691..b6e447a805 100644
@@ -1107,9 +1107,11 @@ static void sdhci_data_transfer(SDHCIState *s)
     }
 }
 
+static bool sdhci_clocks_on(SDHCIState *s);
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clocks_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 &&
@@ -1810,6 +1812,10 @@ 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_VENDOR_IPGEN              (1 << 11)
+#define ESDHC_VENDOR_HCKEN              (1 << 12)
+#define ESDHC_VENDOR_PEREN              (1 << 13)
+#define ESDHC_VENDOR_CKEN               (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1826,6 +1832,16 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 #define ESDHC_PRNSTS_SDSTB              (1 << 3)
 #define ESDHC_PRNSTS_CLOCK_GATE_OFF     BIT(7)
 
+static bool sdhci_clocks_on(SDHCIState *s)
+{
+    uint32_t vendor_clocks = ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN |
+                             ESDHC_VENDOR_PEREN | ESDHC_VENDOR_CKEN;
+
+    return SDHC_CLOCK_IS_ON(s->clkcon) ||
+           ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+            (s->vendor_spec & vendor_clocks) == vendor_clocks);
+}
+
 static uint64_t esdhc_read(void *opaque, hwaddr offset, unsigned size)
 {
     SDHCIState *s = SYSBUS_SDHCI(opaque);
@@ -1861,7 +1877,11 @@ static uint64_t esdhc_read(void *opaque, hwaddr offset, unsigned size)
     case SDHC_PRNSTS:
         /* Add SDSTB (SD Clock Stable) bit to PRNSTS */
         ret = sdhci_read(opaque, offset, size) & ~ESDHC_PRNSTS_SDSTB;
-        if (s->clkcon & SDHC_CLOCK_INT_STABLE) {
+        if ((s->clkcon & SDHC_CLOCK_INT_STABLE) ||
+            ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+             (s->vendor_spec & (ESDHC_VENDOR_IPGEN |
+                                ESDHC_VENDOR_HCKEN)) ==
+             (ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN))) {
             ret |= ESDHC_PRNSTS_SDSTB;
         }
         break;
@@ -2120,7 +2140,8 @@ static void imx_usdhc_init(Object *obj)
     DeviceState *dev = DEVICE(obj);
 
     s->io_ops = &usdhc_mmio_ops;
-    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ;
+    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
     qdev_prop_set_uint8(dev, "sd-spec-version", 3);
 }
 
Signature · 1 line
2.53.0
#13 lore raw

Re: [PATCH v2 06/10] hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates

Am 4. September 2026 16:14:29 UTC schrieb Bin Meng <[email protected]>:

Quoted 79 lines

U-Boot's i.MX uSDHC driver enables IPGEN, HCKEN, PEREN and CKEN in VEND_SPEC rather than the standard SDHCI clock-control fields. QEMU only checks the standard fields before issuing a command. It therefore silently drops U-Boot's MMC commands even though the controller clocks are enabled. U-Boot eventually times out waiting for command completion and cannot load the kernel and device tree from the SD card.

Accept the complete vendor clock-gate set as another valid clock source for i.MX uSDHC. Also report SDSTB when the vendor IP and host clocks are enabled, matching the state U-Boot polls while changing the clock.

Keep this behavior behind an i.MX uSDHC quirk because the shared eSDHC paths also serve controllers which use the standard SDHCI fields.

Reference: IMX6ULRM (Rev 2), section 56.8.10, 56.8.12 and 56.8.26
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

Changes in v2:
- rebase on top of the microchip polarfire soc series

include/hw/sd/sdhci.h | 7 ++++++-
hw/sd/sdhci.c | 27 ++++++++++++++++++++++++---

2 files changed, 30 insertions(+), 4 deletions(-)
include/hw/sd/sdhci.h +6 -1
index 2d03e37653..83d465774b 100644
@@ -112,7 +112,12 @@ typedef struct SDHCIState SDHCIState;
 * Controller does not provide transfer-complete interrupt when not
 * busy.
 */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)
+#define SDHCI_QUIRK_NO_BUSY_IRQ          BIT(0)
+/*
+ * Controller uses vendor-specific clock gates in place of the standard
+ * SDHCI clock-control fields
+ */
+#define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
hw/sd/sdhci.c +7 -1
index 14c312a691..b6e447a805 100644
@@ -1107,9 +1107,11 @@ static void sdhci_data_transfer(SDHCIState *s)
    }
 }
 
+static bool sdhci_clocks_on(SDHCIState *s);
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clocks_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 &&
@@ -1810,6 +1812,10 @@ 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_VENDOR_IPGEN              (1 << 11)
+#define ESDHC_VENDOR_HCKEN              (1 << 12)
+#define ESDHC_VENDOR_PEREN              (1 << 13)
+#define ESDHC_VENDOR_CKEN               (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1826,6 +1832,16 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 #define ESDHC_PRNSTS_SDSTB              (1 << 3)
 #define ESDHC_PRNSTS_CLOCK_GATE_OFF     BIT(7)
 

hw/sd/sdhci.c static void sdhci_bus_class_init(ObjectClass *klass, const void *data) · line 1844

Quoted 10 lines
hw/sd/sdhci.c +10 -0
+static bool sdhci_clocks_on(SDHCIState *s)
+{
+    uint32_t vendor_clocks = ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN |
+                             ESDHC_VENDOR_PEREN | ESDHC_VENDOR_CKEN;
+
+    return SDHC_CLOCK_IS_ON(s->clkcon) ||
+           ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+            (s->vendor_spec & vendor_clocks) == vendor_clocks);
+}
+

Rather than accumulating vendor-specific quirks in generic code, can we not remap in device-specific "virtual" methods such as usdhc_{read,write}?

Best regards,
Bernhard

Quoted 26 lines
hw/sd/sdhci.c +7 -2
 static uint64_t esdhc_read(void *opaque, hwaddr offset, unsigned size)
 {
    SDHCIState *s = SYSBUS_SDHCI(opaque);
@@ -1861,7 +1877,11 @@ static uint64_t esdhc_read(void *opaque, hwaddr offset, unsigned size)
    case SDHC_PRNSTS:
        /* Add SDSTB (SD Clock Stable) bit to PRNSTS */
        ret = sdhci_read(opaque, offset, size) & ~ESDHC_PRNSTS_SDSTB;
-        if (s->clkcon & SDHC_CLOCK_INT_STABLE) {
+        if ((s->clkcon & SDHC_CLOCK_INT_STABLE) ||
+            ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+             (s->vendor_spec & (ESDHC_VENDOR_IPGEN |
+                                ESDHC_VENDOR_HCKEN)) ==
+             (ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN))) {
            ret |= ESDHC_PRNSTS_SDSTB;
        }
        break;
@@ -2120,7 +2140,8 @@ static void imx_usdhc_init(Object *obj)
    DeviceState *dev = DEVICE(obj);
 
    s->io_ops = &usdhc_mmio_ops;
-    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ;
+    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
    qdev_prop_set_uint8(dev, "sd-spec-version", 3);
 }
 
#14 lore raw

Re: [PATCH v2 06/10] hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates

Quoted 83 lines · Bernhard Beschow

Am 4. September 2026 16:14:29 UTC schrieb Bin Meng <[email protected]>:

Quoted 79 lines

U-Boot's i.MX uSDHC driver enables IPGEN, HCKEN, PEREN and CKEN in VEND_SPEC rather than the standard SDHCI clock-control fields. QEMU only checks the standard fields before issuing a command. It therefore silently drops U-Boot's MMC commands even though the controller clocks are enabled. U-Boot eventually times out waiting for command completion and cannot load the kernel and device tree from the SD card.

Accept the complete vendor clock-gate set as another valid clock source for i.MX uSDHC. Also report SDSTB when the vendor IP and host clocks are enabled, matching the state U-Boot polls while changing the clock.

Keep this behavior behind an i.MX uSDHC quirk because the shared eSDHC paths also serve controllers which use the standard SDHCI fields.

Reference: IMX6ULRM (Rev 2), section 56.8.10, 56.8.12 and 56.8.26
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

Changes in v2:
- rebase on top of the microchip polarfire soc series

include/hw/sd/sdhci.h | 7 ++++++-
hw/sd/sdhci.c | 27 ++++++++++++++++++++++++---

2 files changed, 30 insertions(+), 4 deletions(-)
include/hw/sd/sdhci.h +6 -1
index 2d03e37653..83d465774b 100644
@@ -112,7 +112,12 @@ typedef struct SDHCIState SDHCIState;
 * Controller does not provide transfer-complete interrupt when not
 * busy.
 */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)
+#define SDHCI_QUIRK_NO_BUSY_IRQ          BIT(0)
+/*
+ * Controller uses vendor-specific clock gates in place of the standard
+ * SDHCI clock-control fields
+ */
+#define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
hw/sd/sdhci.c +7 -1
index 14c312a691..b6e447a805 100644
@@ -1107,9 +1107,11 @@ static void sdhci_data_transfer(SDHCIState *s)
    }
 }
 
+static bool sdhci_clocks_on(SDHCIState *s);
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clocks_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 &&
@@ -1810,6 +1812,10 @@ 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_VENDOR_IPGEN              (1 << 11)
+#define ESDHC_VENDOR_HCKEN              (1 << 12)
+#define ESDHC_VENDOR_PEREN              (1 << 13)
+#define ESDHC_VENDOR_CKEN               (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1826,6 +1832,16 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 #define ESDHC_PRNSTS_SDSTB              (1 << 3)
 #define ESDHC_PRNSTS_CLOCK_GATE_OFF     BIT(7)
 
Quoted 13 lines

hw/sd/sdhci.c static void sdhci_bus_class_init(ObjectClass *klass, const void *data) · line 1844

Quoted 10 lines
hw/sd/sdhci.c +10 -0
+static bool sdhci_clocks_on(SDHCIState *s)
+{
+    uint32_t vendor_clocks = ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN |
+                             ESDHC_VENDOR_PEREN | ESDHC_VENDOR_CKEN;
+
+    return SDHC_CLOCK_IS_ON(s->clkcon) ||
+           ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+            (s->vendor_spec & vendor_clocks) == vendor_clocks);
+}
+

Rather than accumulating vendor-specific quirks in generic code, can we not remap in device-specific "virtual" methods such as usdhc_{read,write}?

Will do in v3.

Regards,
Bin

author
#15 lore raw

PATCH v2 7/10 hw/sd: sdhci: Preserve uSDHC status enables for U-Boot

In reply to Bin Meng

U-Boot's i.MX uSDHC probe calls fsl_esdhc_init(), which resets the controller and programs INT_STATUS_EN. It then calls esdhc_init_common(), which issues a second RSTA and only clears the BRR/BWR status enables afterward.

The generic SDHCI reset clears QEMU's normal and error status-enable fields. Consequently, the second RSTA removes command-complete, transfer-complete, DMA, and error enables. Commands still reach the card, but QEMU does not latch completion status, so U-Boot times out and fails to expose an MMC block device.

Preserve the normal and error status-enable fields around RSTA in the i.MX uSDHC register path. Signal enables still follow the generic reset because U-Boot disables interrupt signaling and polls INT_STATUS.

The IMX6ULRM describes RSTA as clearing read-write state and does not document INT_STATUS_EN as reset-persistent. Treat this as compatibility with U-Boot's established two-reset initialization sequence rather than as behavior directly specified by the reference manual.

---

(no changes since v1)

 hw/sd/sdhci.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
hw/sd/sdhci.c +27 -0
index b6e447a805..4d7bbdbe7a 100644
@@ -1822,6 +1822,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 #define ESDHC_TUNING_CTRL               0xcc
 #define ESDHC_TUNE_CTRL_STATUS          0x68
 #define ESDHC_WTMK_LVL                  0x44
+#define ESDHC_SYSCTL_RSTA               BIT(24)
 
 /* Undocumented register used by guests working around erratum ERR004536 */
 #define ESDHC_UNDOCUMENTED_REG27        0x6c
@@ -2117,6 +2118,32 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
         sdhci_write(opaque, offset, val | s->trnmod, size);
         break;
 
+    case SDHC_CLKCON:
+        if (value & ESDHC_SYSCTL_RSTA) {
+            uint16_t norintstsen = s->norintstsen;
+            uint16_t errintstsen = s->errintstsen;
+
+            esdhc_write(opaque, offset, val, size);
+
+            /*
+             * U-Boot programs INT_STATUS_EN in fsl_esdhc_init(), then issues
+             * another RSTA from esdhc_init_common(). It only clears BRR/BWR
+             * after that reset and relies on the remaining enables while
+             * polling INT_STATUS for command, transfer, and error completion.
+             *
+             * The generic SDHCI reset clears both status-enable fields,
+             * leaving U-Boot with no completion status. Preserve them across
+             * this uSDHC-specific RSTA path. Signal enables still follow
+             * generic reset semantics because U-Boot disables interrupt
+             * signaling for polling.
+             */
+            s->norintstsen = norintstsen;
+            s->errintstsen = errintstsen;
+        } else {
+            esdhc_write(opaque, offset, val, size);
+        }
+        break;
+
     default:
         esdhc_write(opaque, offset, val, size);
         break;
Signature · 1 line
2.53.0
author
#16 lore raw

PATCH v2 8/10 hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC

In reply to Bin Meng

The standard SDHCI Block Size register encodes an SDMA buffer boundary in bits 14:12. The generic model stops at each selected boundary, sets the DMA status, and waits for software to rewrite the SDMA system address before continuing.

Freescale eSDHC and i.MX uSDHC instead expose BLKATTR without a programmable standard boundary field. On both controller families, bits 14:13 are reserved and bit 12 is the high bit of the 13-bit block-size field. Linux masks the standard boundary encoding before writing BLKATTR.

Despite its name, esdhc_write() is the shared register translation helper. usdhc_write() delegates common register accesses to it. The existing translation inserts 0x7 into the generic boundary field so the common core sees a 512 KiB boundary.

For i.MX6UL uSDHC, BLK_ATT bits 15:13 are reserved and bit 12 is part of its 13-bit block size. DINT reports successful completion of the whole internal DMA transfer, not an intermediate boundary pause.

U-Boot programs one contiguous DMA address and a block count, then waits for both DINT and transfer-complete. It never rewrites the address at an intermediate boundary. Reads larger than 512 KiB therefore reach the synthetic boundary and stall with blocks remaining.

The missing field alone does not establish whether every older eSDHC has a fixed internal boundary handshake. Limit the new quirk to only TYPE_IMX_USDHC, where the reference manual, U-Boot behavior, and the observed failure agree. Existing FSL eSDHC and standard SDHCI behavior remain unchanged.

Reference: IMX6ULRM (Rev. 2), section 56.8.2 and 56.8.13
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

(no changes since v1)

 include/hw/sd/sdhci.h |  5 +++++
 hw/sd/sdhci.c         | 37 ++++++++++++++++++++++++-------------
 2 files changed, 29 insertions(+), 13 deletions(-)
include/hw/sd/sdhci.h +5 -0
index 83d465774b..6664822398 100644
@@ -118,6 +118,11 @@ typedef struct SDHCIState SDHCIState;
  * SDHCI clock-control fields
  */
 #define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
+/*
+ * Controller completes contiguous SDMA transfers without the standard
+ * intermediate buffer-boundary stop and address-update handshake
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY     BIT(2)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
hw/sd/sdhci.c +24 -13
index 4d7bbdbe7a..de0883497b 100644
@@ -687,12 +687,14 @@ static void sdhci_advance_sdma_address(SDHCIState *s, uint32_t bytes)
 /* Multi block SDMA transfer */
 static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
 {
+    bool boundary_enabled =
+        !(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY);
     bool page_aligned = false;
     unsigned int begin;
     const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK;
-    uint32_t boundary_chk = 1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+    uint32_t boundary_chk = 0;
     uint64_t sdma_address = sdhci_sdma_address(s);
-    uint32_t boundary_count = boundary_chk - (sdma_address % boundary_chk);
+    uint32_t boundary_count = 0;
 
     if (!(s->trnmod & SDHC_TRNS_BLK_CNT_EN) || !s->blkcnt) {
         qemu_log_mask(LOG_UNIMP, "infinite transfer is not supported\n");
@@ -704,8 +706,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
      * possible stop at page boundary if initial address is not page aligned,
      * allow them to work properly
      */
-    if ((sdma_address % boundary_chk) == 0) {
-        page_aligned = true;
+    if (boundary_enabled) {
+        boundary_chk =
+            1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+        boundary_count = boundary_chk - (sdma_address % boundary_chk);
+        page_aligned = (sdma_address % boundary_chk) == 0;
     }
 
     s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;
@@ -721,7 +726,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                 boundary_count = 0;
              } else {
                 s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
                 if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
                     s->blkcnt--;
                 }
@@ -746,7 +753,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                 boundary_count = 0;
              } else {
                 s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
             }
             dma_memory_read(s->dma_as, sdhci_sdma_address(s),
                             &s->fifo_buffer[begin],
@@ -2015,13 +2024,14 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 
     case SDHC_BLKSIZE:
         /*
-         * ESDHCI does not implement "Host SDMA Buffer Boundary", and
-         * Linux driver will try to zero this field out which will
-         * break the rest of SDHCI emulation.
+         * Freescale eSDHC and i.MX uSDHC use BLKATTR without the standard
+         * Host SDMA Buffer Boundary field. uSDHC accesses reach this shared
+         * register translation through usdhc_write().
          *
-         * Linux defaults to maximum possible setting (512K boundary)
-         * and it seems to be the only option that i.MX IP implements,
-         * so we artificially set it to that value.
+         * Keep the largest boundary in the generic representation to
+         * preserve existing eSDHC behavior. TYPE_IMX_USDHC separately
+         * disables the associated stop semantics because its DINT reports
+         * completion of the entire transfer rather than a boundary event.
          */
         val |= 0x7 << 12;
         /* FALLTHROUGH */
@@ -2168,7 +2178,8 @@ static void imx_usdhc_init(Object *obj)
 
     s->io_ops = &usdhc_mmio_ops;
     s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
-                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR |
+                SDHCI_QUIRK_NO_SDMA_BOUNDARY;
     qdev_prop_set_uint8(dev, "sd-spec-version", 3);
 }
 
Signature · 1 line
2.53.0
Reviewed-by on v2 8/10
#17 lore raw

Re: [PATCH v2 08/10] hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC

Am 4. September 2026 16:14:31 UTC schrieb Bin Meng <[email protected]>:

Quoted 138 lines

The standard SDHCI Block Size register encodes an SDMA buffer boundary in bits 14:12. The generic model stops at each selected boundary, sets the DMA status, and waits for software to rewrite the SDMA system address before continuing.

Freescale eSDHC and i.MX uSDHC instead expose BLKATTR without a programmable standard boundary field. On both controller families, bits 14:13 are reserved and bit 12 is the high bit of the 13-bit block-size field. Linux masks the standard boundary encoding before writing BLKATTR.

Despite its name, esdhc_write() is the shared register translation helper. usdhc_write() delegates common register accesses to it. The existing translation inserts 0x7 into the generic boundary field so the common core sees a 512 KiB boundary.

For i.MX6UL uSDHC, BLK_ATT bits 15:13 are reserved and bit 12 is part of its 13-bit block size. DINT reports successful completion of the whole internal DMA transfer, not an intermediate boundary pause.

U-Boot programs one contiguous DMA address and a block count, then waits for both DINT and transfer-complete. It never rewrites the address at an intermediate boundary. Reads larger than 512 KiB therefore reach the synthetic boundary and stall with blocks remaining.

The missing field alone does not establish whether every older eSDHC has a fixed internal boundary handshake. Limit the new quirk to only TYPE_IMX_USDHC, where the reference manual, U-Boot behavior, and the observed failure agree. Existing FSL eSDHC and standard SDHCI behavior remain unchanged.

Reference: IMX6ULRM (Rev. 2), section 56.8.2 and 56.8.13
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

(no changes since v1)

include/hw/sd/sdhci.h | 5 +++++
hw/sd/sdhci.c | 37 ++++++++++++++++++++++++-------------

2 files changed, 29 insertions(+), 13 deletions(-)
include/hw/sd/sdhci.h +5 -0
index 83d465774b..6664822398 100644
@@ -118,6 +118,11 @@ typedef struct SDHCIState SDHCIState;
 * SDHCI clock-control fields
 */
 #define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
+/*
+ * Controller completes contiguous SDMA transfers without the standard
+ * intermediate buffer-boundary stop and address-update handshake
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY     BIT(2)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
hw/sd/sdhci.c +22 -12
index 4d7bbdbe7a..de0883497b 100644
@@ -687,12 +687,14 @@ static void sdhci_advance_sdma_address(SDHCIState *s, uint32_t bytes)
 /* Multi block SDMA transfer */
 static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
 {
+    bool boundary_enabled =
+        !(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY);
    bool page_aligned = false;
    unsigned int begin;
    const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK;
-    uint32_t boundary_chk = 1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+    uint32_t boundary_chk = 0;
    uint64_t sdma_address = sdhci_sdma_address(s);
-    uint32_t boundary_count = boundary_chk - (sdma_address % boundary_chk);
+    uint32_t boundary_count = 0;
 
    if (!(s->trnmod & SDHC_TRNS_BLK_CNT_EN) || !s->blkcnt) {
        qemu_log_mask(LOG_UNIMP, "infinite transfer is not supported\n");
@@ -704,8 +706,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
     * possible stop at page boundary if initial address is not page aligned,
     * allow them to work properly
     */
-    if ((sdma_address % boundary_chk) == 0) {
-        page_aligned = true;
+    if (boundary_enabled) {
+        boundary_chk =
+            1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+        boundary_count = boundary_chk - (sdma_address % boundary_chk);
+        page_aligned = (sdma_address % boundary_chk) == 0;
    }
 
    s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;
@@ -721,7 +726,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                boundary_count = 0;
             } else {
                s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
                if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
                    s->blkcnt--;
                }
@@ -746,7 +753,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                boundary_count = 0;
             } else {
                s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
            }
            dma_memory_read(s->dma_as, sdhci_sdma_address(s),
                            &s->fifo_buffer[begin],
@@ -2015,13 +2024,14 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 
    case SDHC_BLKSIZE:
        /*
-         * ESDHCI does not implement "Host SDMA Buffer Boundary", and
-         * Linux driver will try to zero this field out which will
-         * break the rest of SDHCI emulation.
+         * Freescale eSDHC and i.MX uSDHC use BLKATTR without the standard
+         * Host SDMA Buffer Boundary field. uSDHC accesses reach this shared
+         * register translation through usdhc_write().
         *
-         * Linux defaults to maximum possible setting (512K boundary)
-         * and it seems to be the only option that i.MX IP implements,
-         * so we artificially set it to that value.
+         * Keep the largest boundary in the generic representation to
+         * preserve existing eSDHC behavior. TYPE_IMX_USDHC separately
+         * disables the associated stop semantics because its DINT reports
+         * completion of the entire transfer rather than a boundary event.
         */
        val |= 0x7 << 12;
        /* FALLTHROUGH */

hw/sd/sdhci.c static void imx_usdhc_init(Object *obj) · line 2182

Quoted 6 lines
hw/sd/sdhci.c +2 -1
@@ -2168,7 +2178,8 @@ static void imx_usdhc_init(Object *obj)
 
    s->io_ops = &usdhc_mmio_ops;
    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
-                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR |
+                SDHCI_QUIRK_NO_SDMA_BOUNDARY;

Given the above comments please also add the quirk to both ESDHC variants. Thanks!

With the above fixed:

Quoted 3 lines
hw/sd/sdhci.c +0 -0
    qdev_prop_set_uint8(dev, "sd-spec-version", 3);
 }
 
#18 lore raw

Re: [PATCH v2 08/10] hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC

Quoted 143 lines · Bernhard Beschow

Am 4. September 2026 16:14:31 UTC schrieb Bin Meng <[email protected]>:

Quoted 139 lines

The standard SDHCI Block Size register encodes an SDMA buffer boundary in bits 14:12. The generic model stops at each selected boundary, sets the DMA status, and waits for software to rewrite the SDMA system address before continuing.

Freescale eSDHC and i.MX uSDHC instead expose BLKATTR without a programmable standard boundary field. On both controller families, bits 14:13 are reserved and bit 12 is the high bit of the 13-bit block-size field. Linux masks the standard boundary encoding before writing BLKATTR.

Despite its name, esdhc_write() is the shared register translation helper. usdhc_write() delegates common register accesses to it. The existing translation inserts 0x7 into the generic boundary field so the common core sees a 512 KiB boundary.

For i.MX6UL uSDHC, BLK_ATT bits 15:13 are reserved and bit 12 is part of its 13-bit block size. DINT reports successful completion of the whole internal DMA transfer, not an intermediate boundary pause.

U-Boot programs one contiguous DMA address and a block count, then waits for both DINT and transfer-complete. It never rewrites the address at an intermediate boundary. Reads larger than 512 KiB therefore reach the synthetic boundary and stall with blocks remaining.

The missing field alone does not establish whether every older eSDHC has a fixed internal boundary handshake. Limit the new quirk to only TYPE_IMX_USDHC, where the reference manual, U-Boot behavior, and the observed failure agree. Existing FSL eSDHC and standard SDHCI behavior remain unchanged.

Reference: IMX6ULRM (Rev. 2), section 56.8.2 and 56.8.13
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

(no changes since v1)

include/hw/sd/sdhci.h | 5 +++++
hw/sd/sdhci.c | 37 ++++++++++++++++++++++++-------------

2 files changed, 29 insertions(+), 13 deletions(-)
include/hw/sd/sdhci.h +5 -0
index 83d465774b..6664822398 100644
@@ -118,6 +118,11 @@ typedef struct SDHCIState SDHCIState;
 * SDHCI clock-control fields
 */
 #define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
+/*
+ * Controller completes contiguous SDMA transfers without the standard
+ * intermediate buffer-boundary stop and address-update handshake
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY     BIT(2)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
hw/sd/sdhci.c +22 -12
index 4d7bbdbe7a..de0883497b 100644
@@ -687,12 +687,14 @@ static void sdhci_advance_sdma_address(SDHCIState *s, uint32_t bytes)
 /* Multi block SDMA transfer */
 static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
 {
+    bool boundary_enabled =
+        !(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY);
    bool page_aligned = false;
    unsigned int begin;
    const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK;
-    uint32_t boundary_chk = 1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+    uint32_t boundary_chk = 0;
    uint64_t sdma_address = sdhci_sdma_address(s);
-    uint32_t boundary_count = boundary_chk - (sdma_address % boundary_chk);
+    uint32_t boundary_count = 0;
 
    if (!(s->trnmod & SDHC_TRNS_BLK_CNT_EN) || !s->blkcnt) {
        qemu_log_mask(LOG_UNIMP, "infinite transfer is not supported\n");
@@ -704,8 +706,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
     * possible stop at page boundary if initial address is not page aligned,
     * allow them to work properly
     */
-    if ((sdma_address % boundary_chk) == 0) {
-        page_aligned = true;
+    if (boundary_enabled) {
+        boundary_chk =
+            1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+        boundary_count = boundary_chk - (sdma_address % boundary_chk);
+        page_aligned = (sdma_address % boundary_chk) == 0;
    }
 
    s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;
@@ -721,7 +726,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                boundary_count = 0;
             } else {
                s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
                if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
                    s->blkcnt--;
                }
@@ -746,7 +753,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                boundary_count = 0;
             } else {
                s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
            }
            dma_memory_read(s->dma_as, sdhci_sdma_address(s),
                            &s->fifo_buffer[begin],
@@ -2015,13 +2024,14 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 
    case SDHC_BLKSIZE:
        /*
-         * ESDHCI does not implement "Host SDMA Buffer Boundary", and
-         * Linux driver will try to zero this field out which will
-         * break the rest of SDHCI emulation.
+         * Freescale eSDHC and i.MX uSDHC use BLKATTR without the standard
+         * Host SDMA Buffer Boundary field. uSDHC accesses reach this shared
+         * register translation through usdhc_write().
         *
-         * Linux defaults to maximum possible setting (512K boundary)
-         * and it seems to be the only option that i.MX IP implements,
-         * so we artificially set it to that value.
+         * Keep the largest boundary in the generic representation to
+         * preserve existing eSDHC behavior. TYPE_IMX_USDHC separately
+         * disables the associated stop semantics because its DINT reports
+         * completion of the entire transfer rather than a boundary event.
         */
        val |= 0x7 << 12;
        /* FALLTHROUGH */
@@ -2168,7 +2178,8 @@ static void imx_usdhc_init(Object *obj)
 
Quoted 7 lines

hw/sd/sdhci.c static void imx_usdhc_init(Object *obj) · line 2182

Quoted 5 lines
hw/sd/sdhci.c +2 -1
    s->io_ops = &usdhc_mmio_ops;
    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
-                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR |
+                SDHCI_QUIRK_NO_SDMA_BOUNDARY;

Given the above comments please also add the quirk to both ESDHC variants. Thanks!

Will extend the quirk to eSDHC variants in v3.

Quoted 5 lines

With the above fixed:

Regards,
Bin

author
#19 lore raw

PATCH v2 9/10 docs/system/arm: Document MCIMX6UL-EVK Buildroot boot

In reply to Bin Meng

Provide verified instructions for U-Boot and direct Linux boot using Buildroot images.

---

(no changes since v1)

 docs/system/arm/mcimx6ul-evk.rst | 67 ++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
docs/system/arm/mcimx6ul-evk.rst +67 -0
index 8871138ab3..84331b734d 100644
@@ -3,3 +3,70 @@ NXP MCIMX6UL-EVK (``mcimx6ul-evk``)
 
 The ``mcimx6ul-evk`` machine models the NXP i.MX6UltraLite Evaluation Kit
 MCIMX6UL-EVK development board. It has a single Cortex-A7 CPU.
+
+Booting Buildroot images
+------------------------
+
+Build the SD card image with the tested Buildroot version:
+
+.. code-block:: bash
+
+  $ git clone https://gitlab.com/buildroot.org/buildroot.git
+  $ cd buildroot
+  $ git checkout 2026.05
+  $ make imx6ulevk_defconfig
+  $ make
+
+The following examples use images generated by Buildroot::
+
+  IMAGES=/path/to/buildroot/output/images
+  QEMU_BUILD=/path/to/qemu/build
+
+The generated raw ``sdcard.img`` is about 84 MiB, which is not a capacity
+supported by QEMU's SD card model. Resize the image in place to 128 MiB::
+
+  "$QEMU_BUILD/qemu-img" resize -f raw "$IMAGES/sdcard.img" 128M
+
+This modifies the Buildroot output image; rebuilding the image restores its
+original size.
+
+The SD card must be attached to USDHC2 with ``index=1``. It is consequently
+named ``mmc1`` by U-Boot and ``mmcblk1`` by Linux. The first partition contains
+the kernel and device tree, while the second partition contains the root file
+system.
+
+U-Boot boot
+~~~~~~~~~~~
+
+The machine does not model the i.MX6UL Boot ROM or its SPL loading sequence.
+Load U-Boot proper at its linked address::
+
+.. code-block:: bash
+
+  "$QEMU_BUILD/qemu-system-arm" \
+      -M mcimx6ul-evk -m 512M \
+      -device loader,file="$IMAGES/u-boot.bin",addr=0x87800000,cpu-num=0 \
+      -drive file="$IMAGES/sdcard.img",if=sd,index=1,format=raw \
+      -nographic
+
+The default Buildroot U-Boot environment selects ``mmc1``, loads ``zImage``
+and ``imx6ul-14x14-evk.dtb`` from the first partition, and starts Linux with
+``/dev/mmcblk1p2`` as the root file system. A ``bad CRC`` warning while loading
+an uninitialized persistent U-Boot environment is expected; U-Boot continues
+with its compiled-in defaults.
+
+Direct Linux boot
+~~~~~~~~~~~~~~~~~
+
+QEMU can load the Buildroot kernel and device tree directly. The kernel then
+mounts the second SD card partition as its root file system::
+
+.. code-block:: bash
+
+  "$QEMU_BUILD/qemu-system-arm" \
+      -M mcimx6ul-evk -m 512M \
+      -kernel "$IMAGES/zImage" \
+      -dtb "$IMAGES/imx6ul-14x14-evk.dtb" \
+      -append "console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw" \
+      -drive file="$IMAGES/sdcard.img",if=sd,index=1,format=raw \
+      -nographic
Signature · 1 line
2.53.0
author
#20 lore raw

PATCH v2 10/10 tests/functional/arm: Add MCIMX6UL-EVK boot tests

In reply to Bin Meng

The MCIMX6UL-EVK machine supports loading U-Boot proper with the generic loader and booting Linux directly, but neither path has functional coverage.

Add a versioned Buildroot asset containing U-Boot, a Linux kernel, the board DTB, and a 128 MiB SD card image. Exercise both boot paths and verify that they reach the Buildroot login prompt.

---

(no changes since v1)

 MAINTAINERS                               |  1 +
 tests/functional/arm/meson.build          |  2 +
 tests/functional/arm/test_mcimx6ul_evk.py | 69 +++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 tests/functional/arm/test_mcimx6ul_evk.py
MAINTAINERS +1 -0
index 9590de2509..527f41b39f 100644
@@ -918,6 +918,7 @@ F: include/hw/arm/fsl-imx6ul.h
 F: include/hw/display/imx6ul_lcdif.h
 F: include/hw/misc/imx6ul_ccm.h
 F: docs/system/arm/mcimx6ul-evk.rst
+F: tests/functional/arm/test_mcimx6ul_evk.py
 
 MCIMX7D SABRE / i.MX7
 M: Peter Maydell <[email protected]>
tests/functional/arm/meson.build +2 -0
index 61b00932db..d8b1408b13 100644
@@ -20,6 +20,7 @@ test_arm_timeouts = {
   'bpim2u' : 500,
   'collie' : 180,
   'cubieboard' : 360,
+  'mcimx6ul_evk' : 240,
   'orangepi' : 540,
   'quanta_gsj' : 240,
   'raspi2' : 120,
@@ -59,6 +60,7 @@ tests_arm_system_thorough = [
   'emcraft_sf2',
   'integratorcp',
   'max78000fthr',
+  'mcimx6ul_evk',
   'microbit',
   'orangepi',
   'quanta_gsj',
tests/functional/arm/test_mcimx6ul_evk.py new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.53.0