From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Alistair Francis" <alistair@alistair23.me>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-arm@nongnu.org
Subject: [PATCH 1/2] hw/sd/pxa2xx_mmci: Do not create SD card within the SDHCI controller
Date: Sun, 5 Jul 2020 23:33:49 +0200 [thread overview]
Message-ID: <20200705213350.24725-2-f4bug@amsat.org> (raw)
In-Reply-To: <20200705213350.24725-1-f4bug@amsat.org>
SDHCI controllers provide a SD Bus to plug SD cards, but don't
come with SD card plugged in :) Let the machine/board object
create and plug the SD cards when required.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/arm/pxa.h | 3 +--
hw/arm/pxa2xx.c | 39 +++++++++++++++++++++++++++++----------
hw/sd/pxa2xx_mmci.c | 11 ++---------
3 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index 8843e5f910..d99b6192da 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -89,8 +89,7 @@ void pxa2xx_lcd_vsync_notifier(PXA2xxLCDState *s, qemu_irq handler);
typedef struct PXA2xxMMCIState PXA2xxMMCIState;
PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
hwaddr base,
- BlockBackend *blk, qemu_irq irq,
- qemu_irq rx_dma, qemu_irq tx_dma);
+ qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma);
void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly,
qemu_irq coverswitch);
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index f104a33463..78f6e69f63 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -22,6 +22,7 @@
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "hw/ssi/ssi.h"
+#include "hw/sd/sd.h"
#include "chardev/char-fe.h"
#include "sysemu/blockdev.h"
#include "sysemu/qtest.h"
@@ -2135,15 +2136,24 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
s->gpio = pxa2xx_gpio_init(0x40e00000, s->cpu, s->pic, 121);
- dinfo = drive_get(IF_SD, 0, 0);
- if (!dinfo && !qtest_enabled()) {
- warn_report("missing SecureDigital device");
- }
s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC),
qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI),
qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI));
+ dinfo = drive_get(IF_SD, 0, 0);
+ if (dinfo) {
+ DeviceState *carddev;
+
+ /* Create and plug in the sd card */
+ carddev = qdev_new(TYPE_SD_CARD);
+ qdev_prop_set_drive_err(carddev, "drive",
+ blk_by_legacy_dinfo(dinfo), &error_fatal);
+ qdev_realize_and_unref(carddev, qdev_get_child_bus(DEVICE(s->mmc),
+ "sd-bus"),
+ &error_fatal);
+ } else if (!qtest_enabled()) {
+ warn_report("missing SecureDigital device");
+ }
for (i = 0; pxa270_serial[i].io_base; i++) {
if (serial_hd(i)) {
@@ -2259,15 +2269,24 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
s->gpio = pxa2xx_gpio_init(0x40e00000, s->cpu, s->pic, 85);
- dinfo = drive_get(IF_SD, 0, 0);
- if (!dinfo && !qtest_enabled()) {
- warn_report("missing SecureDigital device");
- }
s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC),
qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI),
qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI));
+ dinfo = drive_get(IF_SD, 0, 0);
+ if (dinfo) {
+ DeviceState *carddev;
+
+ /* Create and plug in the sd card */
+ carddev = qdev_new(TYPE_SD_CARD);
+ qdev_prop_set_drive_err(carddev, "drive",
+ blk_by_legacy_dinfo(dinfo), &error_fatal);
+ qdev_realize_and_unref(carddev, qdev_get_child_bus(DEVICE(s->mmc),
+ "sd-bus"),
+ &error_fatal);
+ } else if (!qtest_enabled()) {
+ warn_report("missing SecureDigital device");
+ }
for (i = 0; pxa255_serial[i].io_base; i++) {
if (serial_hd(i)) {
diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
index 68bed24480..9482b9212d 100644
--- a/hw/sd/pxa2xx_mmci.c
+++ b/hw/sd/pxa2xx_mmci.c
@@ -476,10 +476,9 @@ static const MemoryRegionOps pxa2xx_mmci_ops = {
PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
hwaddr base,
- BlockBackend *blk, qemu_irq irq,
- qemu_irq rx_dma, qemu_irq tx_dma)
+ qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma)
{
- DeviceState *dev, *carddev;
+ DeviceState *dev;
SysBusDevice *sbd;
PXA2xxMMCIState *s;
@@ -492,12 +491,6 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma);
sysbus_realize_and_unref(sbd, &error_fatal);
- /* Create and plug in the sd card */
- carddev = qdev_new(TYPE_SD_CARD);
- qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal);
- qdev_realize_and_unref(carddev, qdev_get_child_bus(dev, "sd-bus"),
- &error_fatal);
-
return s;
}
--
2.21.3
next prev parent reply other threads:[~2020-07-05 21:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-05 21:33 [PATCH 0/2] hw/sd/pxa2xx_mmci: Do not create SD card within the SDHCI controller Philippe Mathieu-Daudé
2020-07-05 21:33 ` Philippe Mathieu-Daudé [this message]
2020-07-06 16:38 ` [PATCH 1/2] " Alistair Francis
2020-07-09 18:43 ` Peter Maydell
2020-07-05 21:33 ` [PATCH 2/2] hw/sd/pxa2xx_mmci: Trivial simplification Philippe Mathieu-Daudé
2020-07-06 16:39 ` Alistair Francis
2020-07-06 17:08 ` Laurent Vivier
2020-07-09 18:45 ` [PATCH 0/2] hw/sd/pxa2xx_mmci: Do not create SD card within the SDHCI controller Peter Maydell
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=20200705213350.24725-2-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=alistair@alistair23.me \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@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 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).