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 06/12] hw/sd/sdhci: Allow SDHCI classes to register their own MemoryRegionOps
Date: Sat, 8 Mar 2025 20:02:24 +0100 [thread overview]
Message-ID: <20250308190230.7508-7-philmd@linaro.org> (raw)
In-Reply-To: <20250308190230.7508-1-philmd@linaro.org>
Add MemoryRegionOps as a class property. For now it is only
used by TYPE_IMX_USDHC.
Otherwise the default remains in little endian.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/sd/sdhci.h | 1 +
hw/sd/sdhci.c | 22 ++++++++--------------
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
index 2709a7a69d5..60a0442c805 100644
--- a/include/hw/sd/sdhci.h
+++ b/include/hw/sd/sdhci.h
@@ -112,6 +112,7 @@ typedef struct SDHCIClass {
SysBusDeviceClass sbd_parent_class;
};
+ const MemoryRegionOps *io_ops;
uint32_t quirks;
uint64_t iomem_size;
} SDHCIClass;
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 59d506cafa3..d87a7bb45a4 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1427,8 +1427,6 @@ void sdhci_initfn(SDHCIState *s)
sdhci_raise_insertion_irq, s);
s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
sdhci_data_transfer, s);
-
- s->io_ops = &sdhci_mmio_le_ops;
}
void sdhci_uninitfn(SDHCIState *s)
@@ -1445,6 +1443,7 @@ void sdhci_common_realize(SDHCIState *s, Error **errp)
ERRP_GUARD();
SDHCIClass *sc = SYSBUS_SDHCI_GET_CLASS(s);
+ s->io_ops = sc->io_ops ?: &sdhci_mmio_le_ops;
switch (s->endianness) {
case DEVICE_LITTLE_ENDIAN:
/* s->io_ops is little endian by default */
@@ -1888,17 +1887,11 @@ static const MemoryRegionOps usdhc_mmio_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
-static void imx_usdhc_init(Object *obj)
-{
- SDHCIState *s = SYSBUS_SDHCI(obj);
-
- s->io_ops = &usdhc_mmio_ops;
-}
-
static void imx_usdhc_class_init(ObjectClass *oc, void *data)
{
SDHCIClass *sc = SYSBUS_SDHCI_CLASS(oc);
+ sc->io_ops = &usdhc_mmio_ops;
sc->quirks = SDHCI_QUIRK_NO_BUSY_IRQ;
sdhci_common_class_init(oc, data);
@@ -1955,11 +1948,13 @@ static const MemoryRegionOps sdhci_s3c_mmio_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
-static void sdhci_s3c_init(Object *obj)
+static void sdhci_s3c_class_init(ObjectClass *oc, void *data)
{
- SDHCIState *s = SYSBUS_SDHCI(obj);
+ SDHCIClass *sc = SYSBUS_SDHCI_CLASS(oc);
- s->io_ops = &sdhci_s3c_mmio_ops;
+ sc->io_ops = &sdhci_s3c_mmio_ops;
+
+ sdhci_common_class_init(oc, data);
}
static const TypeInfo sdhci_types[] = {
@@ -1981,13 +1976,12 @@ static const TypeInfo sdhci_types[] = {
{
.name = TYPE_IMX_USDHC,
.parent = TYPE_SYSBUS_SDHCI,
- .instance_init = imx_usdhc_init,
.class_init = imx_usdhc_class_init,
},
{
.name = TYPE_S3C_SDHCI,
.parent = TYPE_SYSBUS_SDHCI,
- .instance_init = sdhci_s3c_init,
+ .class_init = sdhci_s3c_class_init,
},
};
--
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 ` Philippe Mathieu-Daudé [this message]
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 ` [PATCH v3 11/12] hw/sd/sdhci: Implement Freescale eSDHC as TYPE_FSL_ESDHC Philippe Mathieu-Daudé
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-7-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).