aboutsummaryrefslogtreecommitdiff
path: root/hw/pl022.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:09 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:09 +0100
commit5493e33f12b75207f8b1bb993ba97e47b3d8de85 (patch)
treeaf7cad82e49aa2d0aaf227f9d2bac88bb3bf5f27 /hw/pl022.c
parent90d37239d4051281d2882117efc73020046c32ca (diff)
downloadqemu-5493e33f12b75207f8b1bb993ba97e47b3d8de85.zip
qemu-5493e33f12b75207f8b1bb993ba97e47b3d8de85.tar.gz
qemu-5493e33f12b75207f8b1bb993ba97e47b3d8de85.tar.bz2
Stellaris SSI qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/pl022.c')
-rw-r--r--hw/pl022.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/hw/pl022.c b/hw/pl022.c
index 4f0ff87..20d317c 100644
--- a/hw/pl022.c
+++ b/hw/pl022.c
@@ -7,7 +7,8 @@
* This code is licenced under the GPL.
*/
-#include "hw.h"
+#include "sysbus.h"
+#include "ssi.h"
#include "primecell.h"
//#define DEBUG_PL022 1
@@ -40,6 +41,7 @@ do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__);} while (0)
#define PL022_INT_TX 0x08
typedef struct {
+ SysBusDevice busdev;
uint32_t cr0;
uint32_t cr1;
uint32_t bitmask;
@@ -55,8 +57,7 @@ typedef struct {
uint16_t tx_fifo[8];
uint16_t rx_fifo[8];
qemu_irq irq;
- int (*xfer_cb)(void *, int);
- void *opaque;
+ SSIBus *ssi;
} pl022_state;
static const unsigned char pl022_id[8] =
@@ -116,10 +117,8 @@ static void pl022_xfer(pl022_state *s)
val = s->tx_fifo[i];
if (s->cr1 & PL022_CR1_LBM) {
/* Loopback mode. */
- } else if (s->xfer_cb) {
- val = s->xfer_cb(s->opaque, val);
} else {
- val = 0;
+ val = ssi_transfer(s->ssi, val);
}
s->rx_fifo[o] = val & s->bitmask;
i = (i + 1) & 7;
@@ -289,19 +288,24 @@ static int pl022_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-void pl022_init(uint32_t base, qemu_irq irq, int (*xfer_cb)(void *, int),
- void * opaque)
+static void pl022_init(SysBusDevice *dev)
{
+ pl022_state *s = FROM_SYSBUS(pl022_state, dev);
int iomemtype;
- pl022_state *s;
- s = (pl022_state *)qemu_mallocz(sizeof(pl022_state));
iomemtype = cpu_register_io_memory(0, pl022_readfn,
pl022_writefn, s);
- cpu_register_physical_memory(base, 0x00001000, iomemtype);
- s->irq = irq;
- s->xfer_cb = xfer_cb;
- s->opaque = opaque;
+ sysbus_init_mmio(dev, 0x1000, iomemtype);
+ sysbus_init_irq(dev, &s->irq);
+ s->ssi = ssi_create_bus();
+ qdev_attach_child_bus(&dev->qdev, "ssi", s->ssi);
pl022_reset(s);
register_savevm("pl022_ssp", -1, 1, pl022_save, pl022_load, s);
}
+
+static void pl022_register_devices(void)
+{
+ sysbus_register_dev("pl022", sizeof(pl022_state), pl022_init);
+}
+
+device_init(pl022_register_devices)