summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:08 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:08 +0100
commit697454eb8e2335c21e07b8cd0a7468d1c53bed08 (patch)
tree2afa62a2e1142e9d7d5049489f0d0047d9dfe249
parente3b425361b3787ac1bfc6fec8f7ebae8c37d5d13 (diff)
downloadhqemu-697454eb8e2335c21e07b8cd0a7468d1c53bed08.zip
hqemu-697454eb8e2335c21e07b8cd0a7468d1c53bed08.tar.gz
TMP105 qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
-rw-r--r--hw/i2c.h2
-rw-r--r--hw/nseries.c4
-rw-r--r--hw/tmp105.c26
3 files changed, 20 insertions, 12 deletions
diff --git a/hw/i2c.h b/hw/i2c.h
index 7e672f0..723dbdc 100644
--- a/hw/i2c.h
+++ b/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 */
diff --git a/hw/nseries.c b/hw/nseries.c
index bd904c7..b7a1c6b 100644
--- a/hw/nseries.c
+++ b/hw/nseries.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 */
diff --git a/hw/tmp105.c b/hw/tmp105.c
index 0877e12..59b0398 100644
--- a/hw/tmp105.c
+++ b/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);
+}
+
+static I2CSlaveInfo tmp105_info = {
+ .init = tmp105_init,
+ .event = tmp105_event,
+ .recv = tmp105_rx,
+ .send = tmp105_tx
+};
- return &s->i2c;
+static void tmp105_register_devices(void)
+{
+ i2c_register_slave("tmp105", sizeof(TMP105State), &tmp105_info);
}
+
+device_init(tmp105_register_devices)
OpenPOWER on IntegriCloud