From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: "Bin Meng" <bmeng.cn@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
qemu-block@nongnu.org
Subject: [PATCH 07/10] hw/sd: sdhci: Preserve uSDHC status enables for U-Boot
Date: Wed, 12 Aug 2026 09:36:10 +0800 [thread overview]
Message-ID: <20260812013619.2134092-8-bin.meng@processmission.com> (raw)
In-Reply-To: <20260812013619.2134092-1-bin.meng@processmission.com>
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.
Signed-off-by: Bin Meng <bin.meng@processmission.com>
---
hw/sd/sdhci.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 09aea733ba..2ee62847cb 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1625,6 +1625,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
@@ -1920,6 +1921,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;
--
2.53.0
next prev parent reply other threads:[~2026-08-12 1:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 1:36 [PATCH 00/10] hw/arm: Enable U-Boot boot on MCIMX6UL-EVK Bin Meng
2026-08-12 1:36 ` [PATCH 01/10] hw/arm: fsl-imx6ul: Add SCU compatibility window Bin Meng
2026-08-12 1:36 ` [PATCH 02/10] hw/misc: imx6ul_ccm: Update PMU_MISC0 reset value Bin Meng
2026-08-12 1:36 ` [PATCH 03/10] hw/arm: fsl-imx6ul: Map early firmware register placeholders Bin Meng
2026-08-12 1:36 ` [PATCH 04/10] hw/arm: fsl-imx6ul: Add a minimal MMDC geometry model Bin Meng
2026-08-12 1:36 ` [PATCH 05/10] hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit Bin Meng
2026-08-12 1:36 ` [PATCH 06/10] hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates Bin Meng
2026-08-12 1:36 ` Bin Meng [this message]
2026-08-12 1:36 ` [PATCH 08/10] hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC Bin Meng
2026-08-12 1:36 ` [PATCH 09/10] docs/system/arm: Document MCIMX6UL-EVK Buildroot boot Bin Meng
2026-08-12 1:36 ` [PATCH 10/10] tests/functional/arm: Add MCIMX6UL-EVK boot tests Bin Meng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812013619.2134092-8-bin.meng@processmission.com \
--to=bin.meng@processmission.com \
--cc=bmeng.cn@gmail.com \
--cc=philmd@mailo.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.