diff options
-rw-r--r-- | hw/i2c.h | 3 | ||||
-rw-r--r-- | hw/ssd0303.c | 23 | ||||
-rw-r--r-- | hw/stellaris.c | 2 |
3 files changed, 17 insertions, 11 deletions
@@ -91,9 +91,6 @@ void *wm8750_dac_buffer(void *opaque, int samples); void wm8750_dac_commit(void *opaque); void wm8750_set_bclk_in(void *opaque, int new_hz); -/* ssd0303.c */ -void ssd0303_init(i2c_bus *bus, int address); - /* twl92230.c */ i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq); qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c); diff --git a/hw/ssd0303.c b/hw/ssd0303.c index f13f804d7a..5a3a29e87e 100644 --- a/hw/ssd0303.c +++ b/hw/ssd0303.c @@ -10,7 +10,6 @@ /* The controller can support a variety of different displays, but we only implement one. Most of the commends relating to brightness and geometry setup are ignored. */ -#include "hw.h" #include "i2c.h" #include "console.h" @@ -305,17 +304,27 @@ static int ssd0303_load(QEMUFile *f, void *opaque, int version_id) return 0; } -void ssd0303_init(i2c_bus *bus, int address) +static void ssd0303_init(i2c_slave *i2c) { - ssd0303_state *s; + ssd0303_state *s = FROM_I2C_SLAVE(ssd0303_state, i2c); - s = (ssd0303_state *)i2c_slave_init(bus, address, sizeof(ssd0303_state)); - s->i2c.event = ssd0303_event; - s->i2c.recv = ssd0303_recv; - s->i2c.send = ssd0303_send; s->ds = graphic_console_init(ssd0303_update_display, ssd0303_invalidate_display, NULL, NULL, s); qemu_console_resize(s->ds, 96 * MAGNIFY, 16 * MAGNIFY); register_savevm("ssd0303_oled", -1, 1, ssd0303_save, ssd0303_load, s); } + +static I2CSlaveInfo ssd0303_info = { + .init = ssd0303_init, + .event = ssd0303_event, + .recv = ssd0303_recv, + .send = ssd0303_send +}; + +static void ssd0303_register_devices(void) +{ + i2c_register_slave("ssd0303", sizeof(ssd0303_state), &ssd0303_info); +} + +device_init(ssd0303_register_devices) diff --git a/hw/stellaris.c b/hw/stellaris.c index 8d0995a99b..b7b98ab9b3 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -1324,7 +1324,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model, i2c = i2c_init_bus(); stellaris_i2c_init(0x40020000, pic[8], i2c); if (board->peripherals & BP_OLED_I2C) { - ssd0303_init(i2c, 0x3d); + i2c_create_slave(i2c, "ssd0303", 0x3d); } } |