Statistics
| Branch: | Revision:

root / hw / i2c.h @ c75a823c

History | View | Annotate | Download (2.8 kB)

1 0ff596d0 pbrook
#ifndef QEMU_I2C_H
2 0ff596d0 pbrook
#define QEMU_I2C_H
3 0ff596d0 pbrook
4 0ff596d0 pbrook
/* The QEMU I2C implementation only supports simple transfers that complete
5 0ff596d0 pbrook
   immediately.  It does not support slave devices that need to be able to
6 0ff596d0 pbrook
   defer their response (eg. CPU slave interfaces where the data is supplied
7 0ff596d0 pbrook
   by the device driver in response to an interrupt).  */
8 0ff596d0 pbrook
9 0ff596d0 pbrook
enum i2c_event {
10 0ff596d0 pbrook
    I2C_START_RECV,
11 0ff596d0 pbrook
    I2C_START_SEND,
12 0ff596d0 pbrook
    I2C_FINISH,
13 aa1f17c1 ths
    I2C_NACK /* Masker NACKed a receive byte.  */
14 0ff596d0 pbrook
};
15 0ff596d0 pbrook
16 0ff596d0 pbrook
/* Master to slave.  */
17 0ff596d0 pbrook
typedef int (*i2c_send_cb)(i2c_slave *s, uint8_t data);
18 0ff596d0 pbrook
/* Slave to master.  */
19 0ff596d0 pbrook
typedef int (*i2c_recv_cb)(i2c_slave *s);
20 0ff596d0 pbrook
/* Notify the slave of a bus state change.  */
21 0ff596d0 pbrook
typedef void (*i2c_event_cb)(i2c_slave *s, enum i2c_event event);
22 0ff596d0 pbrook
23 0ff596d0 pbrook
struct i2c_slave
24 0ff596d0 pbrook
{
25 0ff596d0 pbrook
    /* Callbacks to be set by the device.  */
26 0ff596d0 pbrook
    i2c_event_cb event;
27 0ff596d0 pbrook
    i2c_recv_cb recv;
28 0ff596d0 pbrook
    i2c_send_cb send;
29 0ff596d0 pbrook
30 0ff596d0 pbrook
    /* Remaining fields for internal use by the I2C code.  */
31 0ff596d0 pbrook
    int address;
32 0ff596d0 pbrook
    void *next;
33 0ff596d0 pbrook
};
34 0ff596d0 pbrook
35 0ff596d0 pbrook
i2c_bus *i2c_init_bus(void);
36 0ff596d0 pbrook
i2c_slave *i2c_slave_init(i2c_bus *bus, int address, int size);
37 0ff596d0 pbrook
void i2c_set_slave_address(i2c_slave *dev, int address);
38 0ff596d0 pbrook
int i2c_bus_busy(i2c_bus *bus);
39 0ff596d0 pbrook
int i2c_start_transfer(i2c_bus *bus, int address, int recv);
40 0ff596d0 pbrook
void i2c_end_transfer(i2c_bus *bus);
41 0ff596d0 pbrook
void i2c_nack(i2c_bus *bus);
42 0ff596d0 pbrook
int i2c_send(i2c_bus *bus, uint8_t data);
43 0ff596d0 pbrook
int i2c_recv(i2c_bus *bus);
44 aa941b94 balrog
void i2c_bus_save(QEMUFile *f, i2c_bus *bus);
45 aa941b94 balrog
void i2c_bus_load(QEMUFile *f, i2c_bus *bus);
46 aa941b94 balrog
void i2c_slave_save(QEMUFile *f, i2c_slave *dev);
47 aa941b94 balrog
void i2c_slave_load(QEMUFile *f, i2c_slave *dev);
48 0ff596d0 pbrook
49 87ecb68b pbrook
/* max111x.c */
50 87ecb68b pbrook
struct max111x_s;
51 87ecb68b pbrook
uint32_t max111x_read(void *opaque);
52 87ecb68b pbrook
void max111x_write(void *opaque, uint32_t value);
53 87ecb68b pbrook
struct max111x_s *max1110_init(qemu_irq cb);
54 87ecb68b pbrook
struct max111x_s *max1111_init(qemu_irq cb);
55 87ecb68b pbrook
void max111x_set_input(struct max111x_s *s, int line, uint8_t value);
56 87ecb68b pbrook
57 adb86c37 balrog
/* max7310.c */
58 adb86c37 balrog
i2c_slave *max7310_init(i2c_bus *bus);
59 adb86c37 balrog
void max7310_reset(i2c_slave *i2c);
60 adb86c37 balrog
qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
61 adb86c37 balrog
void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
62 adb86c37 balrog
63 adb86c37 balrog
/* wm8750.c */
64 adb86c37 balrog
i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
65 adb86c37 balrog
void wm8750_reset(i2c_slave *i2c);
66 adb86c37 balrog
void wm8750_data_req_set(i2c_slave *i2c,
67 adb86c37 balrog
                void (*data_req)(void *, int, int), void *opaque);
68 adb86c37 balrog
void wm8750_dac_dat(void *opaque, uint32_t sample);
69 adb86c37 balrog
uint32_t wm8750_adc_dat(void *opaque);
70 662caa6f balrog
void *wm8750_dac_buffer(void *opaque, int samples);
71 662caa6f balrog
void wm8750_dac_commit(void *opaque);
72 adb86c37 balrog
73 87ecb68b pbrook
/* ssd0303.c */
74 87ecb68b pbrook
void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address);
75 87ecb68b pbrook
76 7e7c5e4c balrog
/* twl92230.c */
77 7e7c5e4c balrog
i2c_slave *twl92230_init(i2c_bus *bus, qemu_irq irq);
78 7e7c5e4c balrog
qemu_irq *twl92230_gpio_in_get(i2c_slave *i2c);
79 7e7c5e4c balrog
void twl92230_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
80 7e7c5e4c balrog
81 7e7c5e4c balrog
/* tmp105.c */
82 7e7c5e4c balrog
struct i2c_slave *tmp105_init(i2c_bus *bus, qemu_irq alarm);
83 7e7c5e4c balrog
void tmp105_reset(i2c_slave *i2c);
84 7e7c5e4c balrog
void tmp105_set(i2c_slave *i2c, int temp);
85 7e7c5e4c balrog
86 0ff596d0 pbrook
#endif