mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 19:15:32 +00:00
sdhci: Pass drive parameter to sdhci-pci via qdev property
Commit 19109131
disabled the sdhci-pci support because it used
drive_get_next(). This patch reenables sdhci-pci and changes it to
pass the drive via a qdev property - for example:
-device sdhci-pci,drive=drive0 -drive id=drive0,if=sd,file=myimage
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
b37686f7e8
commit
5ec911c30f
@ -492,7 +492,9 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
|
|||||||
sd->blk = blk;
|
sd->blk = blk;
|
||||||
sd_reset(sd);
|
sd_reset(sd);
|
||||||
if (sd->blk) {
|
if (sd->blk) {
|
||||||
blk_attach_dev_nofail(sd->blk, sd);
|
/* Attach dev if not already attached. (This call ignores an
|
||||||
|
* error return code if sd->blk is already attached.) */
|
||||||
|
blk_attach_dev(sd->blk, sd);
|
||||||
blk_set_dev_ops(sd->blk, &sd_block_ops, sd);
|
blk_set_dev_ops(sd->blk, &sd_block_ops, sd);
|
||||||
}
|
}
|
||||||
vmstate_register(NULL, -1, &sd_vmstate, sd);
|
vmstate_register(NULL, -1, &sd_vmstate, sd);
|
||||||
|
@ -1145,13 +1145,9 @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdhci_initfn(SDHCIState *s)
|
static void sdhci_initfn(SDHCIState *s, BlockBackend *blk)
|
||||||
{
|
{
|
||||||
DriveInfo *di;
|
s->card = sd_init(blk, false);
|
||||||
|
|
||||||
/* FIXME use a qdev drive property instead of drive_get_next() */
|
|
||||||
di = drive_get_next(IF_SD);
|
|
||||||
s->card = sd_init(di ? blk_by_legacy_dinfo(di) : NULL, false);
|
|
||||||
if (s->card == NULL) {
|
if (s->card == NULL) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -1215,7 +1211,8 @@ const VMStateDescription sdhci_vmstate = {
|
|||||||
|
|
||||||
/* Capabilities registers provide information on supported features of this
|
/* Capabilities registers provide information on supported features of this
|
||||||
* specific host controller implementation */
|
* specific host controller implementation */
|
||||||
static Property sdhci_properties[] = {
|
static Property sdhci_pci_properties[] = {
|
||||||
|
DEFINE_BLOCK_PROPERTIES(SDHCIState, conf),
|
||||||
DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
|
DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
|
||||||
SDHC_CAPAB_REG_DEFAULT),
|
SDHC_CAPAB_REG_DEFAULT),
|
||||||
DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
|
DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
|
||||||
@ -1227,7 +1224,7 @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
|
|||||||
SDHCIState *s = PCI_SDHCI(dev);
|
SDHCIState *s = PCI_SDHCI(dev);
|
||||||
dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */
|
dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */
|
||||||
dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
|
dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
|
||||||
sdhci_initfn(s);
|
sdhci_initfn(s, s->conf.blk);
|
||||||
s->buf_maxsz = sdhci_get_fifolen(s);
|
s->buf_maxsz = sdhci_get_fifolen(s);
|
||||||
s->fifo_buffer = g_malloc0(s->buf_maxsz);
|
s->fifo_buffer = g_malloc0(s->buf_maxsz);
|
||||||
s->irq = pci_allocate_irq(dev);
|
s->irq = pci_allocate_irq(dev);
|
||||||
@ -1254,9 +1251,7 @@ static void sdhci_pci_class_init(ObjectClass *klass, void *data)
|
|||||||
k->class_id = PCI_CLASS_SYSTEM_SDHCI;
|
k->class_id = PCI_CLASS_SYSTEM_SDHCI;
|
||||||
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
||||||
dc->vmsd = &sdhci_vmstate;
|
dc->vmsd = &sdhci_vmstate;
|
||||||
dc->props = sdhci_properties;
|
dc->props = sdhci_pci_properties;
|
||||||
/* Reason: realize() method uses drive_get_next() */
|
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo sdhci_pci_info = {
|
static const TypeInfo sdhci_pci_info = {
|
||||||
@ -1266,10 +1261,21 @@ static const TypeInfo sdhci_pci_info = {
|
|||||||
.class_init = sdhci_pci_class_init,
|
.class_init = sdhci_pci_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Property sdhci_sysbus_properties[] = {
|
||||||
|
DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
|
||||||
|
SDHC_CAPAB_REG_DEFAULT),
|
||||||
|
DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void sdhci_sysbus_init(Object *obj)
|
static void sdhci_sysbus_init(Object *obj)
|
||||||
{
|
{
|
||||||
SDHCIState *s = SYSBUS_SDHCI(obj);
|
SDHCIState *s = SYSBUS_SDHCI(obj);
|
||||||
sdhci_initfn(s);
|
DriveInfo *di;
|
||||||
|
|
||||||
|
/* FIXME use a qdev drive property instead of drive_get_next() */
|
||||||
|
di = drive_get_next(IF_SD);
|
||||||
|
sdhci_initfn(s, di ? blk_by_legacy_dinfo(di) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdhci_sysbus_finalize(Object *obj)
|
static void sdhci_sysbus_finalize(Object *obj)
|
||||||
@ -1296,7 +1302,7 @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
|
|||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
dc->vmsd = &sdhci_vmstate;
|
dc->vmsd = &sdhci_vmstate;
|
||||||
dc->props = sdhci_properties;
|
dc->props = sdhci_sysbus_properties;
|
||||||
dc->realize = sdhci_sysbus_realize;
|
dc->realize = sdhci_sysbus_realize;
|
||||||
/* Reason: instance_init() method uses drive_get_next() */
|
/* Reason: instance_init() method uses drive_get_next() */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->cannot_instantiate_with_device_add_yet = true;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define SDHCI_H
|
#define SDHCI_H
|
||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "hw/block/block.h"
|
||||||
#include "hw/pci/pci.h"
|
#include "hw/pci/pci.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "hw/sd.h"
|
#include "hw/sd.h"
|
||||||
@ -239,6 +240,7 @@ typedef struct SDHCIState {
|
|||||||
};
|
};
|
||||||
SDState *card;
|
SDState *card;
|
||||||
MemoryRegion iomem;
|
MemoryRegion iomem;
|
||||||
|
BlockConf conf;
|
||||||
|
|
||||||
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
|
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
|
||||||
QEMUTimer *transfer_timer;
|
QEMUTimer *transfer_timer;
|
||||||
|
Loading…
Reference in New Issue
Block a user