TMP105 qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
parent
e3b425361b
commit
697454eb8e
2
hw/i2c.h
2
hw/i2c.h
@ -96,8 +96,6 @@ qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c);
|
||||
void twl92230_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
|
||||
|
||||
/* tmp105.c */
|
||||
struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm);
|
||||
void tmp105_reset(i2c_slave *i2c);
|
||||
void tmp105_set(i2c_slave *i2c, int temp);
|
||||
|
||||
/* lm832x.c */
|
||||
|
@ -179,6 +179,7 @@ static void n8x0_nand_setup(struct n800_s *s)
|
||||
|
||||
static void n8x0_i2c_setup(struct n800_s *s)
|
||||
{
|
||||
DeviceState *dev;
|
||||
qemu_irq tmp_irq = omap2_gpio_in_get(s->cpu->gpif, N8X0_TMP105_GPIO)[0];
|
||||
|
||||
/* Attach the CPU on one end of our I2C bus. */
|
||||
@ -191,7 +192,8 @@ static void n8x0_i2c_setup(struct n800_s *s)
|
||||
N8X0_MENELAUS_ADDR);
|
||||
|
||||
/* Attach a TMP105 PM chip (A0 wired to ground) */
|
||||
i2c_set_slave_address(tmp105_init(s->i2c, tmp_irq), N8X0_TMP105_ADDR);
|
||||
dev = i2c_create_slave(s->i2c, "tmp105", N8X0_TMP105_ADDR);
|
||||
qdev_connect_gpio_out(dev, 0, tmp_irq);
|
||||
}
|
||||
|
||||
/* Touchscreen and keypad controller */
|
||||
|
28
hw/tmp105.c
28
hw/tmp105.c
@ -214,7 +214,7 @@ static int tmp105_load(QEMUFile *f, void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tmp105_reset(i2c_slave *i2c)
|
||||
static void tmp105_reset(i2c_slave *i2c)
|
||||
{
|
||||
TMP105State *s = (TMP105State *) i2c;
|
||||
|
||||
@ -227,19 +227,27 @@ void tmp105_reset(i2c_slave *i2c)
|
||||
tmp105_interrupt_update(s);
|
||||
}
|
||||
|
||||
struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm)
|
||||
static void tmp105_init(i2c_slave *i2c)
|
||||
{
|
||||
TMP105State *s = (TMP105State *)
|
||||
i2c_slave_init(bus, 0, sizeof(TMP105State));
|
||||
TMP105State *s = FROM_I2C_SLAVE(TMP105State, i2c);
|
||||
|
||||
s->i2c.event = tmp105_event;
|
||||
s->i2c.recv = tmp105_rx;
|
||||
s->i2c.send = tmp105_tx;
|
||||
s->pin = alarm;
|
||||
qdev_init_gpio_out(&i2c->qdev, &s->pin, 1);
|
||||
|
||||
tmp105_reset(&s->i2c);
|
||||
|
||||
register_savevm("TMP105", -1, 0, tmp105_save, tmp105_load, s);
|
||||
|
||||
return &s->i2c;
|
||||
}
|
||||
|
||||
static I2CSlaveInfo tmp105_info = {
|
||||
.init = tmp105_init,
|
||||
.event = tmp105_event,
|
||||
.recv = tmp105_rx,
|
||||
.send = tmp105_tx
|
||||
};
|
||||
|
||||
static void tmp105_register_devices(void)
|
||||
{
|
||||
i2c_register_slave("tmp105", sizeof(TMP105State), &tmp105_info);
|
||||
}
|
||||
|
||||
device_init(tmp105_register_devices)
|
||||
|
Loading…
x
Reference in New Issue
Block a user