From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: edgar.iglesias@gmail.com, peter.crosthwaite@xilinx.com,
michael@walle.cc, armbru@redhat.com, peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH for-2.3 v2 2/2] sdhci: add "drive" property
Date: Mon, 23 Mar 2015 15:55:38 +0100 [thread overview]
Message-ID: <1427122538-26060-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1427122538-26060-1-git-send-email-pbonzini@redhat.com>
Add a drive property that can be used with sdhci-pci (instead of the odd
"-drive if=sd,... -device sdhci-pci" that has no equivalent in the rest
of QEMU). Then adjust the zynq platform to set it based on the DriveInfo
that it gets.
Note that in this case the BlockBackend is attached to the SDHCI controller.
This is not a problem; the ->dev field is really unused and the dev_opaque
still points to the SDState struct.
Required for 2.3, as it changes how users access the sdhci-pci device.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/arm/xilinx_zynq.c | 11 ++++++++++-
hw/sd/sdhci.c | 11 ++---------
hw/sd/sdhci.h | 1 +
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 5c37521..3d25c1a 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -114,6 +114,7 @@ static void zynq_init(MachineState *machine)
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
+ DriveInfo *dinfo;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
@@ -172,7 +173,7 @@ static void zynq_init(MachineState *machine)
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
- DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
+ dinfo = drive_get(IF_PFLASH, 0, 0);
/* AMD */
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
@@ -217,11 +218,19 @@ static void zynq_init(MachineState *machine)
gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
+ dinfo = drive_get_next(IF_SD);
+ if (dinfo) {
+ qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(dinfo));
+ }
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
+ dinfo = drive_get_next(IF_SD);
+ if (dinfo) {
+ qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(dinfo));
+ }
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index ed60674..078b0bd 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1144,15 +1144,7 @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s)
static void sdhci_initfn(SDHCIState *s)
{
- DriveInfo *di;
- BlockBackend *blk;
-
- di = drive_get_next(IF_SD);
- blk = di ? blk_by_legacy_dinfo(di) : NULL;
- if (blk) {
- blk_attach_dev_nofail(blk, s);
- }
- s->card = sd_init(blk, false);
+ s->card = sd_init(s->blk, false);
if (s->card == NULL) {
exit(1);
}
@@ -1222,6 +1214,7 @@ static Property sdhci_properties[] = {
DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
SDHC_CAPAB_REG_DEFAULT),
DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
+ DEFINE_PROP_DRIVE("drive", SDHCIState, blk),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/sd/sdhci.h b/hw/sd/sdhci.h
index 3352d23..69ccf58 100644
--- a/hw/sd/sdhci.h
+++ b/hw/sd/sdhci.h
@@ -237,6 +237,7 @@ typedef struct SDHCIState {
PCIDevice pcidev;
SysBusDevice busdev;
};
+ BlockBackend *blk;
SDState *card;
MemoryRegion iomem;
--
2.3.3
prev parent reply other threads:[~2015-03-23 14:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 14:55 [Qemu-devel] [PATCH for-2.3 v2 0/2] sdhci: add "drive" property Paolo Bonzini
2015-03-23 14:55 ` [Qemu-devel] [PATCH for-2.3 v2 1/2] sd: move blk_attach_dev_nofail to caller Paolo Bonzini
2015-03-23 14:55 ` Paolo Bonzini [this message]
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=1427122538-26060-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=michael@walle.cc \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.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).