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 | 5493e33f12b75207f8b1bb993ba97e47b3d8de85 (patch) | |
tree | af7cad82e49aa2d0aaf227f9d2bac88bb3bf5f27 /hw/stellaris.c | |
parent | 90d37239d4051281d2882117efc73020046c32ca (diff) |
Stellaris SSI qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/stellaris.c')
-rw-r--r-- | hw/stellaris.c | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/hw/stellaris.c b/hw/stellaris.c index 2ca1d51951..a50800ff99 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -8,13 +8,13 @@ */ #include "sysbus.h" +#include "ssi.h" #include "arm-misc.h" #include "primecell.h" #include "devices.h" #include "qemu-timer.h" #include "i2c.h" #include "net.h" -#include "sd.h" #include "sysemu.h" #include "boards.h" @@ -1196,10 +1196,10 @@ static qemu_irq stellaris_adc_init(uint32_t base, qemu_irq irq) 0xff commands that occur when deselecting the SD card. */ typedef struct { - ssi_xfer_cb xfer_cb[2]; - void *opaque[2]; + SSISlave ssidev; qemu_irq irq; int current_dev; + SSIBus *bus[2]; } stellaris_ssi_bus_state; static void stellaris_ssi_bus_select(void *opaque, int irq, int level) @@ -1209,11 +1209,11 @@ static void stellaris_ssi_bus_select(void *opaque, int irq, int level) s->current_dev = level; } -static int stellaris_ssi_bus_xfer(void *opaque, int val) +static uint32_t stellaris_ssi_bus_transfer(SSISlave *dev, uint32_t val) { - stellaris_ssi_bus_state *s = (stellaris_ssi_bus_state *)opaque; + stellaris_ssi_bus_state *s = FROM_SSI_SLAVE(stellaris_ssi_bus_state, dev); - return s->xfer_cb[s->current_dev](s->opaque[s->current_dev], val); + return ssi_transfer(s->bus[s->current_dev], val); } static void stellaris_ssi_bus_save(QEMUFile *f, void *opaque) @@ -1235,23 +1235,18 @@ static int stellaris_ssi_bus_load(QEMUFile *f, void *opaque, int version_id) return 0; } -static void *stellaris_ssi_bus_init(qemu_irq *irqp, - ssi_xfer_cb cb0, void *opaque0, - ssi_xfer_cb cb1, void *opaque1) +static void stellaris_ssi_bus_init(SSISlave *dev) { - qemu_irq *qi; - stellaris_ssi_bus_state *s; - - s = (stellaris_ssi_bus_state *)qemu_mallocz(sizeof(stellaris_ssi_bus_state)); - s->xfer_cb[0] = cb0; - s->opaque[0] = opaque0; - s->xfer_cb[1] = cb1; - s->opaque[1] = opaque1; - qi = qemu_allocate_irqs(stellaris_ssi_bus_select, s, 1); - *irqp = *qi; + stellaris_ssi_bus_state *s = FROM_SSI_SLAVE(stellaris_ssi_bus_state, dev); + + s->bus[0] = ssi_create_bus(); + qdev_attach_child_bus(&dev->qdev, "ssi0", s->bus[0]); + s->bus[1] = ssi_create_bus(); + qdev_attach_child_bus(&dev->qdev, "ssi1", s->bus[1]); + qdev_init_gpio_in(&dev->qdev, stellaris_ssi_bus_select, 1); + register_savevm("stellaris_ssi_bus", -1, 1, stellaris_ssi_bus_save, stellaris_ssi_bus_load, s); - return s; } /* Board init. */ @@ -1338,25 +1333,25 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model, } } if (board->dc2 & (1 << 4)) { + DeviceState *dev; + dev = sysbus_create_simple("pl022", 0x40008000, pic[7]); if (board->peripherals & BP_OLED_SSI) { - void * oled; - void * sd; - void *ssi_bus; - int index; + DeviceState *mux; + void *bus; - oled = ssd0323_init(&gpio_out[GPIO_C][7]); - index = drive_get_index(IF_SD, 0, 0); - sd = ssi_sd_init(drives_table[index].bdrv); + bus = qdev_get_child_bus(dev, "ssi"); + mux = ssi_create_slave(bus, "evb6965-ssi"); + gpio_out[GPIO_D][0] = qdev_get_gpio_in(mux, 0); - ssi_bus = stellaris_ssi_bus_init(&gpio_out[GPIO_D][0], - ssi_sd_xfer, sd, - ssd0323_xfer_ssi, oled); + bus = qdev_get_child_bus(mux, "ssi0"); + dev = ssi_create_slave(bus, "ssi-sd"); + + bus = qdev_get_child_bus(mux, "ssi1"); + dev = ssi_create_slave(bus, "ssd0323"); + gpio_out[GPIO_C][7] = qdev_get_gpio_in(dev, 0); - pl022_init(0x40008000, pic[7], stellaris_ssi_bus_xfer, ssi_bus); /* Make sure the select pin is high. */ qemu_irq_raise(gpio_out[GPIO_D][0]); - } else { - pl022_init(0x40008000, pic[7], NULL, NULL); } } if (board->dc4 & (1 << 28)) { @@ -1413,10 +1408,17 @@ QEMUMachine lm3s6965evb_machine = { .init = lm3s6965evb_init, }; +static SSISlaveInfo stellaris_ssi_bus_info = { + .init = stellaris_ssi_bus_init, + .transfer = stellaris_ssi_bus_transfer +}; + static void stellaris_register_devices(void) { sysbus_register_dev("stellaris-i2c", sizeof(stellaris_i2c_state), stellaris_i2c_init); + ssi_register_slave("evb6965-ssi", sizeof(stellaris_ssi_bus_state), + &stellaris_ssi_bus_info); } device_init(stellaris_register_devices) |