From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: BALATON Zoltan <balaton@eik.bme.hu>, qemu-devel@nongnu.org
Cc: "Bernhard Beschow" <shentey@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-ppc@nongnu.org, "Andrey Smirnov" <andrew.smirnov@gmail.com>,
"Jean-Christophe Dubois" <jcd@tribudubois.net>,
"Bin Meng" <bmeng.cn@gmail.com>,
qemu-arm@nongnu.org, qemu-block@nongnu.org,
"Guenter Roeck" <linux@roeck-us.net>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 11/12] hw/sd/sdhci: Implement Freescale eSDHC as TYPE_FSL_ESDHC
Date: Sat, 8 Mar 2025 20:02:29 +0100 [thread overview]
Message-ID: <20250308190230.7508-12-philmd@linaro.org> (raw)
In-Reply-To: <20250308190230.7508-1-philmd@linaro.org>
Per the MPC8569E reference manual, its SDHC I/O range is 4KiB
wide, mapped in big endian order, and it only accepts 32-bit
aligned access. Set the default register reset values.
Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/sd/sdhci.h | 2 ++
hw/sd/sdhci.c | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
index e24392eb10d..0e9d3b10d1b 100644
--- a/include/hw/sd/sdhci.h
+++ b/include/hw/sd/sdhci.h
@@ -161,6 +161,8 @@ DECLARE_INSTANCE_CHECKER(SDHCIState, SYSBUS_SDHCI,
DECLARE_CLASS_CHECKERS(SDHCIClass, SYSBUS_SDHCI,
TYPE_SYSBUS_SDHCI)
+#define TYPE_FSL_ESDHC "fsl-esdhc"
+
#define TYPE_IMX_USDHC "imx-usdhc"
#define TYPE_S3C_SDHCI "s3c-sdhci"
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index cda608f8ec2..a78cff40fb1 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1644,7 +1644,37 @@ static void sdhci_bus_class_init(ObjectClass *klass, void *data)
sbc->set_readonly = sdhci_set_readonly;
}
-/* --- qdev i.MX eSDHC --- */
+/* --- Freescale eSDHC (MPC8569ERM Rev.2 from 06/2011) --- */
+
+static const MemoryRegionOps fsl_esdhc_mmio_ops = {
+ .read = sdhci_read,
+ .write = sdhci_write,
+ .valid = {
+ .min_access_size = 4,
+ .unaligned = false
+ },
+ .endianness = DEVICE_BIG_ENDIAN,
+};
+
+static void fsl_esdhc_class_init(ObjectClass *oc, void *data)
+{
+ SDHCIClass *sc = SYSBUS_SDHCI_CLASS(oc);
+
+ sc->iomem_size = 0x1000;
+ sc->io_ops = &fsl_esdhc_mmio_ops;
+ sc->ro.capareg = 0x01e30000;
+ sc->reset.sdmasysad = 8;
+ sc->reset.blkcnt = 8;
+ sc->reset.prnsts = 0xff800000;
+ sc->reset.hostctl1 = 0x20; /* Endian mode (address-invariant) */
+ sc->reset.clkcon = 0x8000;
+ sc->reset.norintstsen = 0x013f;
+ sc->reset.errintstsen = 0x117f;
+
+ sdhci_common_class_init(oc, data);
+}
+
+/* --- qdev i.MX uSDHC --- */
#define USDHC_MIX_CTRL 0x48
@@ -1974,6 +2004,11 @@ static const TypeInfo sdhci_types[] = {
.class_size = sizeof(SDHCIClass),
.class_init = sdhci_sysbus_class_init,
},
+ {
+ .name = TYPE_FSL_ESDHC,
+ .parent = TYPE_SYSBUS_SDHCI,
+ .class_init = fsl_esdhc_class_init,
+ },
{
.name = TYPE_IMX_USDHC,
.parent = TYPE_SYSBUS_SDHCI,
--
2.47.1
next prev parent reply other threads:[~2025-03-08 19:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 19:02 [PATCH v3 00/12] hw/sd/sdhci: Set reset value of interrupt registers Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 01/12] hw/sd/sdhci: Remove need for SDHCIState::vendor field Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 02/12] hw/sd/sdhci: Introduce SDHCIClass stub Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 03/12] hw/sd/sdhci: Make quirks a class property Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 04/12] hw/sd/sdhci: Make I/O region size " Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 05/12] hw/sd/sdhci: Enforce little endianness on PCI devices Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 06/12] hw/sd/sdhci: Allow SDHCI classes to register their own MemoryRegionOps Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 07/12] hw/sd/sdhci: Simplify MemoryRegionOps endianness check Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 08/12] hw/sd/sdhci: Unify default MemoryRegionOps Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 09/12] hw/sd/sdhci: Add SDHCIClass::ro::capareg field Philippe Mathieu-Daudé
2025-03-08 19:02 ` [PATCH v3 10/12] hw/sd/sdhci: Allow SDHCI classes to have different register reset values Philippe Mathieu-Daudé
2025-03-08 19:02 ` Philippe Mathieu-Daudé [this message]
2025-03-08 19:02 ` [PATCH v3 12/12] hw/ppc/e500: Replace generic SDHCI by Freescale eSDHC Philippe Mathieu-Daudé
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=20250308190230.7508-12-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=andrew.smirnov@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=bmeng.cn@gmail.com \
--cc=jcd@tribudubois.net \
--cc=linux@roeck-us.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=shentey@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).