From 697454eb8e2335c21e07b8cd0a7468d1c53bed08 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Thu, 14 May 2009 22:35:08 +0100 Subject: TMP105 qdev conversion Signed-off-by: Paul Brook --- hw/i2c.h | 2 -- hw/nseries.c | 4 +++- hw/tmp105.c | 26 +++++++++++++++++--------- 3 files changed, 20 insertions(+), 12 deletions(-) (limited to 'hw') diff --git a/hw/i2c.h b/hw/i2c.h index 7e672f0da0..723dbdc1e3 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 bd904c7ddb..b7a1c6be56 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 0877e126fc..59b039804d 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) -- cgit v1.2.3-55-g7522