summaryrefslogtreecommitdiffstats
path: root/hw
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
commit6c0bd6bde2fa09d2235320bc95dca5036ec96337 (patch)
tree4b9ec74a8d4c79bbae897016415d5efd65c42542 /hw
parentd2199005d558962641169178cf668be946026797 (diff)
downloadhqemu-6c0bd6bde2fa09d2235320bc95dca5036ec96337.zip
hqemu-6c0bd6bde2fa09d2235320bc95dca5036ec96337.tar.gz
MAX7310 I2C qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/i2c.h1
-rw-r--r--hw/max7310.c26
-rw-r--r--hw/spitz.c4
3 files changed, 19 insertions, 12 deletions
diff --git a/hw/i2c.h b/hw/i2c.h
index 7958b0e..6d223ea 100644
--- a/hw/i2c.h
+++ b/hw/i2c.h
@@ -75,7 +75,6 @@ MAX111xState *max1111_init(qemu_irq cb);
void max111x_set_input(MAX111xState *s, int line, uint8_t value);
/* max7310.c */
-i2c_slave *max7310_init(i2c_bus *bus);
void max7310_reset(i2c_slave *i2c);
qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
diff --git a/hw/max7310.c b/hw/max7310.c
index f2a4b1b..69ede32 100644
--- a/hw/max7310.c
+++ b/hw/max7310.c
@@ -7,7 +7,6 @@
* This file is licensed under GNU GPL.
*/
-#include "hw.h"
#include "i2c.h"
typedef struct {
@@ -191,21 +190,16 @@ static void max7310_gpio_set(void *opaque, int line, int level)
/* MAX7310 is SMBus-compatible (can be used with only SMBus protocols),
* but also accepts sequences that are not SMBus so return an I2C device. */
-i2c_slave *max7310_init(i2c_bus *bus)
+static void max7310_init(i2c_slave *i2c)
{
- MAX7310State *s = (MAX7310State *)
- i2c_slave_init(bus, 0, sizeof(MAX7310State));
- s->i2c.event = max7310_event;
- s->i2c.recv = max7310_rx;
- s->i2c.send = max7310_tx;
+ MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, i2c);
+
s->gpio_in = qemu_allocate_irqs(max7310_gpio_set, s,
ARRAY_SIZE(s->handler));
max7310_reset(&s->i2c);
register_savevm("max7310", -1, 0, max7310_save, max7310_load, s);
-
- return &s->i2c;
}
qemu_irq *max7310_gpio_in_get(i2c_slave *i2c)
@@ -222,3 +216,17 @@ void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)
s->handler[line] = handler;
}
+
+static I2CSlaveInfo max7310_info = {
+ .init = max7310_init,
+ .event = max7310_event,
+ .recv = max7310_rx,
+ .send = max7310_tx
+};
+
+static void max7310_register_devices(void)
+{
+ i2c_register_slave("max7310", sizeof(MAX7310State), &max7310_info);
+}
+
+device_init(max7310_register_devices)
diff --git a/hw/spitz.c b/hw/spitz.c
index d22174e..943302b 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -759,8 +759,8 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
static void spitz_akita_i2c_setup(PXA2xxState *cpu)
{
/* Attach a Max7310 to Akita I2C bus. */
- i2c_set_slave_address(max7310_init(pxa2xx_i2c_bus(cpu->i2c[0])),
- AKITA_MAX_ADDR);
+ i2c_create_slave(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310",
+ AKITA_MAX_ADDR);
}
/* Other peripherals */
OpenPOWER on IntegriCloud