Commit 6c0bd6bde2fa09d2235320bc95dca5036ec96337
1 parent
d2199005
MAX7310 I2C qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Showing
3 changed files
with
19 additions
and
12 deletions
hw/i2c.h
... | ... | @@ -75,7 +75,6 @@ MAX111xState *max1111_init(qemu_irq cb); |
75 | 75 | void max111x_set_input(MAX111xState *s, int line, uint8_t value); |
76 | 76 | |
77 | 77 | /* max7310.c */ |
78 | -i2c_slave *max7310_init(i2c_bus *bus); | |
79 | 78 | void max7310_reset(i2c_slave *i2c); |
80 | 79 | qemu_irq *max7310_gpio_in_get(i2c_slave *i2c); |
81 | 80 | void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler); | ... | ... |
hw/max7310.c
... | ... | @@ -7,7 +7,6 @@ |
7 | 7 | * This file is licensed under GNU GPL. |
8 | 8 | */ |
9 | 9 | |
10 | -#include "hw.h" | |
11 | 10 | #include "i2c.h" |
12 | 11 | |
13 | 12 | typedef struct { |
... | ... | @@ -191,21 +190,16 @@ static void max7310_gpio_set(void *opaque, int line, int level) |
191 | 190 | |
192 | 191 | /* MAX7310 is SMBus-compatible (can be used with only SMBus protocols), |
193 | 192 | * but also accepts sequences that are not SMBus so return an I2C device. */ |
194 | -i2c_slave *max7310_init(i2c_bus *bus) | |
193 | +static void max7310_init(i2c_slave *i2c) | |
195 | 194 | { |
196 | - MAX7310State *s = (MAX7310State *) | |
197 | - i2c_slave_init(bus, 0, sizeof(MAX7310State)); | |
198 | - s->i2c.event = max7310_event; | |
199 | - s->i2c.recv = max7310_rx; | |
200 | - s->i2c.send = max7310_tx; | |
195 | + MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, i2c); | |
196 | + | |
201 | 197 | s->gpio_in = qemu_allocate_irqs(max7310_gpio_set, s, |
202 | 198 | ARRAY_SIZE(s->handler)); |
203 | 199 | |
204 | 200 | max7310_reset(&s->i2c); |
205 | 201 | |
206 | 202 | register_savevm("max7310", -1, 0, max7310_save, max7310_load, s); |
207 | - | |
208 | - return &s->i2c; | |
209 | 203 | } |
210 | 204 | |
211 | 205 | 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) |
222 | 216 | |
223 | 217 | s->handler[line] = handler; |
224 | 218 | } |
219 | + | |
220 | +static I2CSlaveInfo max7310_info = { | |
221 | + .init = max7310_init, | |
222 | + .event = max7310_event, | |
223 | + .recv = max7310_rx, | |
224 | + .send = max7310_tx | |
225 | +}; | |
226 | + | |
227 | +static void max7310_register_devices(void) | |
228 | +{ | |
229 | + i2c_register_slave("max7310", sizeof(MAX7310State), &max7310_info); | |
230 | +} | |
231 | + | |
232 | +device_init(max7310_register_devices) | ... | ... |
hw/spitz.c
... | ... | @@ -759,8 +759,8 @@ static void spitz_i2c_setup(PXA2xxState *cpu) |
759 | 759 | static void spitz_akita_i2c_setup(PXA2xxState *cpu) |
760 | 760 | { |
761 | 761 | /* Attach a Max7310 to Akita I2C bus. */ |
762 | - i2c_set_slave_address(max7310_init(pxa2xx_i2c_bus(cpu->i2c[0])), | |
763 | - AKITA_MAX_ADDR); | |
762 | + i2c_create_slave(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310", | |
763 | + AKITA_MAX_ADDR); | |
764 | 764 | } |
765 | 765 | |
766 | 766 | /* Other peripherals */ | ... | ... |