Reset buffer pointers after CR/LF, by Jim Paris.
[qemu/dscho.git] / hw / i2c.h
blob9330ae8521b29052151c2855671b262a6192af9d
1 #ifndef QEMU_I2C_H
2 #define QEMU_I2C_H
4 /* The QEMU I2C implementation only supports simple transfers that complete
5 immediately. It does not support slave devices that need to be able to
6 defer their response (eg. CPU slave interfaces where the data is supplied
7 by the device driver in response to an interrupt). */
9 enum i2c_event {
10 I2C_START_RECV,
11 I2C_START_SEND,
12 I2C_FINISH,
13 I2C_NACK /* Masker NACKed a receive byte. */
16 typedef struct i2c_slave i2c_slave;
18 /* Master to slave. */
19 typedef int (*i2c_send_cb)(i2c_slave *s, uint8_t data);
20 /* Slave to master. */
21 typedef int (*i2c_recv_cb)(i2c_slave *s);
22 /* Notify the slave of a bus state change. */
23 typedef void (*i2c_event_cb)(i2c_slave *s, enum i2c_event event);
25 struct i2c_slave
27 /* Callbacks to be set by the device. */
28 i2c_event_cb event;
29 i2c_recv_cb recv;
30 i2c_send_cb send;
32 /* Remaining fields for internal use by the I2C code. */
33 int address;
34 void *next;
37 typedef struct i2c_bus i2c_bus;
39 i2c_bus *i2c_init_bus(void);
40 i2c_slave *i2c_slave_init(i2c_bus *bus, int address, int size);
41 void i2c_set_slave_address(i2c_slave *dev, int address);
42 int i2c_bus_busy(i2c_bus *bus);
43 int i2c_start_transfer(i2c_bus *bus, int address, int recv);
44 void i2c_end_transfer(i2c_bus *bus);
45 void i2c_nack(i2c_bus *bus);
46 int i2c_send(i2c_bus *bus, uint8_t data);
47 int i2c_recv(i2c_bus *bus);
48 void i2c_bus_save(QEMUFile *f, i2c_bus *bus);
49 void i2c_bus_load(QEMUFile *f, i2c_bus *bus);
50 void i2c_slave_save(QEMUFile *f, i2c_slave *dev);
51 void i2c_slave_load(QEMUFile *f, i2c_slave *dev);
53 /* max7310.c */
54 i2c_slave *max7310_init(i2c_bus *bus);
55 void max7310_reset(i2c_slave *i2c);
56 qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
57 void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
59 /* wm8750.c */
60 i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
61 void wm8750_reset(i2c_slave *i2c);
62 void wm8750_data_req_set(i2c_slave *i2c,
63 void (*data_req)(void *, int, int), void *opaque);
64 void wm8750_dac_dat(void *opaque, uint32_t sample);
65 uint32_t wm8750_adc_dat(void *opaque);
67 #endif