diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:09 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:09 +0100 |
commit | 1de9610c8ff80aa2a47b6cbe8c198b935916feda (patch) | |
tree | f567259ff1f4af322d7e0a26e14cd73b0872f1e8 | |
parent | e325e1f83e803922e5d33b47203d49e4ba2d5a0a (diff) |
Stellaris I2C qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
-rw-r--r-- | hw/stellaris.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/hw/stellaris.c b/hw/stellaris.c index b7b98ab9b3..2ca1d51951 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -680,6 +680,7 @@ static void stellaris_sys_init(uint32_t base, qemu_irq irq, /* I2C controller. */ typedef struct { + SysBusDevice busdev; i2c_bus *bus; qemu_irq irq; uint32_t msa; @@ -870,18 +871,19 @@ static int stellaris_i2c_load(QEMUFile *f, void *opaque, int version_id) return 0; } -static void stellaris_i2c_init(uint32_t base, qemu_irq irq, i2c_bus *bus) +static void stellaris_i2c_init(SysBusDevice * dev) { - stellaris_i2c_state *s; + stellaris_i2c_state *s = FROM_SYSBUS(stellaris_i2c_state, dev); + i2c_bus *bus = i2c_init_bus(); int iomemtype; - s = (stellaris_i2c_state *)qemu_mallocz(sizeof(stellaris_i2c_state)); - s->irq = irq; + sysbus_init_irq(dev, &s->irq); + qdev_attach_child_bus(&dev->qdev, "i2c", bus); s->bus = bus; iomemtype = cpu_register_io_memory(0, stellaris_i2c_readfn, stellaris_i2c_writefn, s); - cpu_register_physical_memory(base, 0x00001000, iomemtype); + sysbus_init_mmio(dev, 0x1000, iomemtype); /* ??? For now we only implement the master interface. */ stellaris_i2c_reset(s); register_savevm("stellaris_i2c", -1, 1, @@ -1321,8 +1323,9 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model, } if (board->dc2 & (1 << 12)) { - i2c = i2c_init_bus(); - stellaris_i2c_init(0x40020000, pic[8], i2c); + DeviceState *dev; + dev = sysbus_create_simple("stellaris-i2c", 0x40020000, pic[8]); + i2c = qdev_get_child_bus(dev, "i2c"); if (board->peripherals & BP_OLED_I2C) { i2c_create_slave(i2c, "ssd0303", 0x3d); } @@ -1409,3 +1412,11 @@ QEMUMachine lm3s6965evb_machine = { .desc = "Stellaris LM3S6965EVB", .init = lm3s6965evb_init, }; + +static void stellaris_register_devices(void) +{ + sysbus_register_dev("stellaris-i2c", sizeof(stellaris_i2c_state), + stellaris_i2c_init); +} + +device_init(stellaris_register_devices) |