From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org, BALATON Zoltan <balaton@eik.bme.hu>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Andrey Smirnov" <andrew.smirnov@gmail.com>,
"Bernhard Beschow" <shentey@gmail.com>,
"Jean-Christophe Dubois" <jcd@tribudubois.net>,
"Guenter Roeck" <linux@roeck-us.net>,
qemu-block@nongnu.org, "Bin Meng" <bmeng.cn@gmail.com>,
qemu-arm@nongnu.org
Subject: [PATCH v4 10/14] hw/sd/sdhci: Convert SDHCIState::endianness to EndianMode
Date: Sat, 8 Mar 2025 22:36:36 +0100 [thread overview]
Message-ID: <20250308213640.13138-11-philmd@linaro.org> (raw)
In-Reply-To: <20250308213640.13138-1-philmd@linaro.org>
EndianMode enum is preferred over DEVICE_BIG/LITTLE_ENDIAN
values because it is a QAPI type.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sd/sdhci-internal.h | 3 ++-
include/hw/sd/sdhci.h | 3 ++-
hw/ppc/e500.c | 2 +-
hw/sd/sdhci-pci.c | 2 +-
hw/sd/sdhci.c | 7 ++++++-
5 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h
index 9072b06bdde..c459279f3f3 100644
--- a/hw/sd/sdhci-internal.h
+++ b/hw/sd/sdhci-internal.h
@@ -24,6 +24,7 @@
#ifndef SDHCI_INTERNAL_H
#define SDHCI_INTERNAL_H
+#include "hw/qdev-properties-system.h"
#include "hw/registerfields.h"
/* R/W SDMA System Address register 0x0 */
@@ -308,7 +309,7 @@ extern const VMStateDescription sdhci_vmstate;
#define SDHC_CAPAB_REG_DEFAULT 0x057834b4
#define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \
- DEFINE_PROP_UINT8("endianness", _state, endianness, DEVICE_LITTLE_ENDIAN), \
+ DEFINE_PROP_ENDIAN("endianness", _state, endianness, ENDIAN_MODE_LITTLE), \
DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \
DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \
\
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
index 60a0442c805..a91cda16cbe 100644
--- a/include/hw/sd/sdhci.h
+++ b/include/hw/sd/sdhci.h
@@ -25,6 +25,7 @@
#ifndef SDHCI_H
#define SDHCI_H
+#include "qapi/qapi-types-common.h"
#include "hw/pci/pci_device.h"
#include "hw/sysbus.h"
#include "hw/sd/sd.h"
@@ -95,7 +96,7 @@ struct SDHCIState {
/* Configurable properties */
bool pending_insert_quirk; /* Quirk for Raspberry Pi card insert int */
- uint8_t endianness;
+ EndianMode endianness;
uint8_t sd_spec_version;
uint8_t uhs_mode;
/*
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index fe8b9f79621..e85e000f054 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -1042,7 +1042,7 @@ void ppce500_init(MachineState *machine)
*/
dev = qdev_new(TYPE_SYSBUS_SDHCI);
qdev_prop_set_uint8(dev, "sd-spec-version", 2);
- qdev_prop_set_uint8(dev, "endianness", DEVICE_BIG_ENDIAN);
+ qdev_prop_set_enum(dev, "endianness", ENDIAN_MODE_BIG);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC85XX_ESDHC_IRQ));
diff --git a/hw/sd/sdhci-pci.c b/hw/sd/sdhci-pci.c
index 5f82178a76f..49c4f0478b4 100644
--- a/hw/sd/sdhci-pci.c
+++ b/hw/sd/sdhci-pci.c
@@ -32,7 +32,7 @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
SDHCIState *s = PCI_SDHCI(dev);
sdhci_initfn(s);
- qdev_prop_set_uint8(DEVICE(dev), "endianness", DEVICE_LITTLE_ENDIAN);
+ qdev_prop_set_enum(DEVICE(dev), "endianness", ENDIAN_MODE_LITTLE);
sdhci_common_realize(s, errp);
if (*errp) {
return;
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 23af3958a1d..f2bb612c665 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1437,7 +1437,12 @@ void sdhci_common_realize(SDHCIState *s, Error **errp)
const char *class_name = object_get_typename(OBJECT(s));
unsigned ops_index;
- ops_index = s->endianness == DEVICE_BIG_ENDIAN ? 1 : 0;
+ if (s->endianness == ENDIAN_MODE_UNSPECIFIED) {
+ error_setg(errp, "%s property 'endianness'"
+ " must be set to 'big' or 'little'", class_name);
+ return;
+ }
+ ops_index = s->endianness == ENDIAN_MODE_BIG ? 1 : 0;
s->io_ops = sc->io_ops ?: &sdhci_mmio_ops[ops_index];
if (s->io_ops->endianness != sdhci_mmio_ops[ops_index].endianness) {
--
2.47.1
next prev parent reply other threads:[~2025-03-08 21:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 21:36 [PATCH v4 00/14] hw/sd/sdhci: Set reset value of interrupt registers Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 01/14] hw/qdev-properties-system: Include missing 'qapi/qapi-types-common.h' Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 02/14] hw/sd/sdhci: Remove need for SDHCIState::vendor field Philippe Mathieu-Daudé
2025-03-09 11:20 ` BALATON Zoltan
2025-03-09 13:57 ` Bernhard Beschow
2025-03-08 21:36 ` [PATCH v4 03/14] hw/sd/sdhci: Introduce SDHCIClass stub Philippe Mathieu-Daudé
2025-03-08 22:34 ` BALATON Zoltan
2025-03-08 23:16 ` Philippe Mathieu-Daudé
2025-03-09 0:08 ` BALATON Zoltan
2025-03-09 14:20 ` Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 04/14] hw/sd/sdhci: Make quirks a class property Philippe Mathieu-Daudé
2025-03-09 11:43 ` BALATON Zoltan
2025-03-09 12:19 ` Philippe Mathieu-Daudé
2025-03-09 12:43 ` BALATON Zoltan
2025-03-08 21:36 ` [PATCH v4 05/14] hw/sd/sdhci: Make I/O region size " Philippe Mathieu-Daudé
2025-03-09 11:09 ` BALATON Zoltan
2025-03-08 21:36 ` [PATCH v4 06/14] hw/sd/sdhci: Enforce little endianness on PCI devices Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 07/14] hw/sd/sdhci: Allow SDHCI classes to register their own MemoryRegionOps Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 08/14] hw/sd/sdhci: Simplify MemoryRegionOps endianness check Philippe Mathieu-Daudé
2025-03-08 22:39 ` BALATON Zoltan
2025-03-08 21:36 ` [PATCH v4 09/14] hw/sd/sdhci: Unify default MemoryRegionOps Philippe Mathieu-Daudé
2025-03-09 9:27 ` Bernhard Beschow
2025-03-09 22:50 ` Philippe Mathieu-Daudé
2025-03-08 21:36 ` Philippe Mathieu-Daudé [this message]
2025-03-08 21:36 ` [PATCH v4 11/14] hw/sd/sdhci: Add SDHCIClass::ro::capareg field Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 12/14] hw/sd/sdhci: Allow SDHCI classes to have different register reset values Philippe Mathieu-Daudé
2025-03-09 11:34 ` BALATON Zoltan
2025-03-08 21:36 ` [PATCH v4 13/14] hw/sd/sdhci: Implement Freescale eSDHC as TYPE_FSL_ESDHC Philippe Mathieu-Daudé
2025-03-09 11:04 ` BALATON Zoltan
2025-03-09 12:16 ` Philippe Mathieu-Daudé
2025-03-08 21:36 ` [PATCH v4 14/14] hw/ppc/e500: Replace generic SDHCI by Freescale eSDHC Philippe Mathieu-Daudé
2025-03-09 8:31 ` Bernhard Beschow
2025-03-09 13:59 ` 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=20250308213640.13138-11-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=andrew.smirnov@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=berrange@redhat.com \
--cc=bmeng.cn@gmail.com \
--cc=eduardo@habkost.net \
--cc=jcd@tribudubois.net \
--cc=linux@roeck-us.net \
--cc=pbonzini@redhat.com \
--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).