aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hw/pl080.c36
-rw-r--r--hw/realview.c2
-rw-r--r--hw/versatilepb.c2
3 files changed, 28 insertions, 12 deletions
diff --git a/hw/pl080.c b/hw/pl080.c
index d18445b47..e43b11df7 100644
--- a/hw/pl080.c
+++ b/hw/pl080.c
@@ -7,8 +7,7 @@
* This code is licenced under the GPL.
*/
-#include "hw.h"
-#include "primecell.h"
+#include "sysbus.h"
#define PL080_MAX_CHANNELS 8
#define PL080_CONF_E 0x1
@@ -37,6 +36,7 @@ typedef struct {
} pl080_channel;
typedef struct {
+ SysBusDevice busdev;
uint8_t tc_int;
uint8_t tc_mask;
uint8_t err_int;
@@ -319,19 +319,35 @@ static CPUWriteMemoryFunc *pl080_writefn[] = {
pl080_write
};
-/* The PL080 and PL081 are the same except for the number of channels
- they implement (8 and 2 respectively). */
-void *pl080_init(uint32_t base, qemu_irq irq, int nchannels)
+static void pl08x_init(SysBusDevice *dev, int nchannels)
{
int iomemtype;
- pl080_state *s;
+ pl080_state *s = FROM_SYSBUS(pl080_state, dev);
- s = (pl080_state *)qemu_mallocz(sizeof(pl080_state));
iomemtype = cpu_register_io_memory(0, pl080_readfn,
pl080_writefn, s);
- cpu_register_physical_memory(base, 0x00001000, iomemtype);
- s->irq = irq;
+ sysbus_init_mmio(dev, 0x1000, iomemtype);
+ sysbus_init_irq(dev, &s->irq);
s->nchannels = nchannels;
/* ??? Save/restore. */
- return s;
}
+
+static void pl080_init(SysBusDevice *dev)
+{
+ pl08x_init(dev, 8);
+}
+
+static void pl081_init(SysBusDevice *dev)
+{
+ pl08x_init(dev, 2);
+}
+
+/* The PL080 and PL081 are the same except for the number of channels
+ they implement (8 and 2 respectively). */
+static void pl080_register_devices(void)
+{
+ sysbus_register_dev("pl080", sizeof(pl080_state), pl080_init);
+ sysbus_register_dev("pl081", sizeof(pl080_state), pl081_init);
+}
+
+device_init(pl080_register_devices)
diff --git a/hw/realview.c b/hw/realview.c
index 24ff3c844..a482487de 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -89,7 +89,7 @@ static void realview_init(ram_addr_t ram_size,
sysbus_create_simple("pl011", 0x1000c000, pic[15]);
/* DMA controller is optional, apparently. */
- pl080_init(0x10030000, pic[24], 2);
+ sysbus_create_simple("pl081", 0x10030000, pic[24]);
sysbus_create_simple("sp804", 0x10011000, pic[4]);
sysbus_create_simple("sp804", 0x10012000, pic[5]);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 415111974..13a8e1940 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -226,7 +226,7 @@ static void versatile_init(ram_addr_t ram_size,
sysbus_create_simple("pl011", 0x101f3000, pic[14]);
sysbus_create_simple("pl011", 0x10009000, sic[6]);
- pl080_init(0x10130000, pic[17], 8);
+ sysbus_create_simple("pl080", 0x10130000, pic[17]);
sysbus_create_simple("sp804", 0x101e2000, pic[4]);
sysbus_create_simple("sp804", 0x101e3000, pic[5]);