]> git.proxmox.com Git - mirror_qemu.git/blame - hw/i2c.h
sd.c build fix.
[mirror_qemu.git] / hw / i2c.h
CommitLineData
0ff596d0
PB
1#ifndef QEMU_I2C_H
2#define QEMU_I2C_H
3
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). */
8
9enum i2c_event {
10 I2C_START_RECV,
11 I2C_START_SEND,
12 I2C_FINISH,
aa1f17c1 13 I2C_NACK /* Masker NACKed a receive byte. */
0ff596d0
PB
14};
15
16typedef struct i2c_slave i2c_slave;
17
18/* Master to slave. */
19typedef int (*i2c_send_cb)(i2c_slave *s, uint8_t data);
20/* Slave to master. */
21typedef int (*i2c_recv_cb)(i2c_slave *s);
22/* Notify the slave of a bus state change. */
23typedef void (*i2c_event_cb)(i2c_slave *s, enum i2c_event event);
24
25struct i2c_slave
26{
27 /* Callbacks to be set by the device. */
28 i2c_event_cb event;
29 i2c_recv_cb recv;
30 i2c_send_cb send;
31
32 /* Remaining fields for internal use by the I2C code. */
33 int address;
34 void *next;
35};
36
37typedef struct i2c_bus i2c_bus;
38
39i2c_bus *i2c_init_bus(void);
40i2c_slave *i2c_slave_init(i2c_bus *bus, int address, int size);
41void i2c_set_slave_address(i2c_slave *dev, int address);
42int i2c_bus_busy(i2c_bus *bus);
43int i2c_start_transfer(i2c_bus *bus, int address, int recv);
44void i2c_end_transfer(i2c_bus *bus);
45void i2c_nack(i2c_bus *bus);
46int i2c_send(i2c_bus *bus, uint8_t data);
47int i2c_recv(i2c_bus *bus);
aa941b94
AZ
48void i2c_bus_save(QEMUFile *f, i2c_bus *bus);
49void i2c_bus_load(QEMUFile *f, i2c_bus *bus);
50void i2c_slave_save(QEMUFile *f, i2c_slave *dev);
51void i2c_slave_load(QEMUFile *f, i2c_slave *dev);
0ff596d0 52
adb86c37
AZ
53/* max7310.c */
54i2c_slave *max7310_init(i2c_bus *bus);
55void max7310_reset(i2c_slave *i2c);
56qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
57void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
58
59/* wm8750.c */
60i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
61void wm8750_reset(i2c_slave *i2c);
62void wm8750_data_req_set(i2c_slave *i2c,
63 void (*data_req)(void *, int, int), void *opaque);
64void wm8750_dac_dat(void *opaque, uint32_t sample);
65uint32_t wm8750_adc_dat(void *opaque);
66
0ff596d0 67#endif