Revision 6c0bd6bd hw/max7310.c
b/hw/max7310.c | ||
---|---|---|
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 | 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 | 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) |
Also available in: Unified diff