diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
commit | 2d9401aa58f33cfbd0a585306b69916ca18dedcf (patch) | |
tree | ffa962917f407ce1a4f857af80847dca9b979844 | |
parent | 6c0bd6bde2fa09d2235320bc95dca5036ec96337 (diff) | |
download | qemu-2d9401aa58f33cfbd0a585306b69916ca18dedcf.zip qemu-2d9401aa58f33cfbd0a585306b69916ca18dedcf.tar.gz qemu-2d9401aa58f33cfbd0a585306b69916ca18dedcf.tar.bz2 |
LM832x qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
-rw-r--r-- | hw/i2c.h | 3 | ||||
-rw-r--r-- | hw/lm832x.c | 31 | ||||
-rw-r--r-- | hw/nseries.c | 5 |
3 files changed, 23 insertions, 16 deletions
@@ -101,7 +101,6 @@ void tmp105_reset(i2c_slave *i2c); void tmp105_set(i2c_slave *i2c, int temp); /* lm832x.c */ -struct i2c_slave *lm8323_init(i2c_bus *bus, qemu_irq nirq); -void lm832x_key_event(struct i2c_slave *i2c, int key, int state); +void lm832x_key_event(i2c_slave *i2c, int key, int state); #endif diff --git a/hw/lm832x.c b/hw/lm832x.c index f3915f0..decde55 100644 --- a/hw/lm832x.c +++ b/hw/lm832x.c @@ -378,7 +378,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value) static void lm_i2c_event(i2c_slave *i2c, enum i2c_event event) { - LM823KbdState *s = (LM823KbdState *) i2c; + LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c); switch (event) { case I2C_START_RECV: @@ -394,7 +394,7 @@ static void lm_i2c_event(i2c_slave *i2c, enum i2c_event event) static int lm_i2c_rx(i2c_slave *i2c) { - LM823KbdState *s = (LM823KbdState *) i2c; + LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c); return lm_kbd_read(s, s->reg, s->i2c_cycle ++); } @@ -489,27 +489,20 @@ static int lm_kbd_load(QEMUFile *f, void *opaque, int version_id) return 0; } -i2c_slave *lm8323_init(i2c_bus *bus, qemu_irq nirq) +static void lm8323_init(i2c_slave *i2c) { - LM823KbdState *s; + LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c); - s = (LM823KbdState *) i2c_slave_init(bus, 0, sizeof(LM823KbdState)); s->model = 0x8323; s->pwm.tm[0] = qemu_new_timer(vm_clock, lm_kbd_pwm0_tick, s); s->pwm.tm[1] = qemu_new_timer(vm_clock, lm_kbd_pwm1_tick, s); s->pwm.tm[2] = qemu_new_timer(vm_clock, lm_kbd_pwm2_tick, s); - s->nirq = nirq; - - s->i2c.event = lm_i2c_event; - s->i2c.recv = lm_i2c_rx; - s->i2c.send = lm_i2c_tx; + qdev_init_gpio_out(&i2c->qdev, &s->nirq, 1); lm_kbd_reset(s); qemu_register_reset((void *) lm_kbd_reset, s); register_savevm("LM8323", -1, 0, lm_kbd_save, lm_kbd_load, s); - - return &s->i2c; } void lm832x_key_event(struct i2c_slave *i2c, int key, int state) @@ -531,3 +524,17 @@ void lm832x_key_event(struct i2c_slave *i2c, int key, int state) s->status |= INT_KEYPAD; lm_kbd_irq_update(s); } + +static I2CSlaveInfo lm8323_info = { + .init = lm8323_init, + .event = lm_i2c_event, + .recv = lm_i2c_rx, + .send = lm_i2c_tx +}; + +static void lm832x_register_devices(void) +{ + i2c_register_slave("lm8323", sizeof(LM823KbdState), &lm8323_info); +} + +device_init(lm832x_register_devices) diff --git a/hw/nseries.c b/hw/nseries.c index 63a1c33..bd904c7 100644 --- a/hw/nseries.c +++ b/hw/nseries.c @@ -362,6 +362,7 @@ static int n810_keys[0x80] = { static void n810_kbd_setup(struct n800_s *s) { qemu_irq kbd_irq = omap2_gpio_in_get(s->cpu->gpif, N810_KEYBOARD_GPIO)[0]; + DeviceState *dev; int i; for (i = 0; i < 0x80; i ++) @@ -374,8 +375,8 @@ static void n810_kbd_setup(struct n800_s *s) /* Attach the LM8322 keyboard to the I2C bus, * should happen in n8x0_i2c_setup and s->kbd be initialised here. */ - s->kbd = lm8323_init(s->i2c, kbd_irq); - i2c_set_slave_address(s->kbd, N810_LM8323_ADDR); + dev = i2c_create_slave(s->i2c, "lm8323", N810_LM8323_ADDR); + qdev_connect_gpio_out(dev, 0, kbd_irq); } /* LCD MIPI DBI-C controller (URAL) */ |