LM832x qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
Paul Brook 2009-05-14 22:35:08 +01:00
parent 6c0bd6bde2
commit 2d9401aa58
3 changed files with 23 additions and 16 deletions

View File

@ -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

View File

@ -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)

View File

@ -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) */