aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2013-03-15 14:34:20 +0000
committerAnthony Liguori <aliguori@us.ibm.com>2013-04-01 09:08:33 -0500
commita86f200aeb66a4f402b22241a5d8360f02bfc090 (patch)
treea6a7c63dafe6a546a2e37af6ed8b88ea7effb0e8
parent4ce5dae88ecf2bafa0cd663de7e923728b1b3672 (diff)
musicpal: qdevify musicpal-misc
Make musicpal-misc into its own (trivial) qdev device, so we can get rid of the abuse of sysbus_add_memory(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Message-id: 1363358063-23973-3-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--hw/arm/musicpal.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index edd528255f..ea8473db3e 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1033,6 +1033,15 @@ static const TypeInfo mv88w8618_flashcfg_info = {
#define MP_BOARD_REVISION 0x31
+typedef struct {
+ SysBusDevice parent_obj;
+ MemoryRegion iomem;
+} MusicPalMiscState;
+
+#define TYPE_MUSICPAL_MISC "musicpal-misc"
+#define MUSICPAL_MISC(obj) \
+ OBJECT_CHECK(MusicPalMiscState, (obj), TYPE_MUSICPAL_MISC)
+
static uint64_t musicpal_misc_read(void *opaque, hwaddr offset,
unsigned size)
{
@@ -1056,15 +1065,23 @@ static const MemoryRegionOps musicpal_misc_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static void musicpal_misc_init(SysBusDevice *dev)
+static void musicpal_misc_init(Object *obj)
{
- MemoryRegion *iomem = g_new(MemoryRegion, 1);
+ SysBusDevice *sd = SYS_BUS_DEVICE(obj);
+ MusicPalMiscState *s = MUSICPAL_MISC(obj);
- memory_region_init_io(iomem, &musicpal_misc_ops, NULL,
+ memory_region_init_io(&s->iomem, &musicpal_misc_ops, NULL,
"musicpal-misc", MP_MISC_SIZE);
- sysbus_add_memory(dev, MP_MISC_BASE, iomem);
+ sysbus_init_mmio(sd, &s->iomem);
}
+static const TypeInfo musicpal_misc_info = {
+ .name = TYPE_MUSICPAL_MISC,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_init = musicpal_misc_init,
+ .instance_size = sizeof(MusicPalMiscState),
+};
+
/* WLAN register offsets */
#define MP_WLAN_MAGIC1 0x11c
#define MP_WLAN_MAGIC2 0x124
@@ -1614,7 +1631,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
- musicpal_misc_init(SYS_BUS_DEVICE(dev));
+ sysbus_create_simple(TYPE_MUSICPAL_MISC, MP_MISC_BASE, NULL);
dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
@@ -1694,6 +1711,7 @@ static void musicpal_register_types(void)
type_register_static(&musicpal_lcd_info);
type_register_static(&musicpal_gpio_info);
type_register_static(&musicpal_key_info);
+ type_register_static(&musicpal_misc_info);
}
type_init(musicpal_register_types)