]> git.proxmox.com Git - qemu.git/blame - hw/i2c.h
Use i2c_slave_init() to allocate the PXA (dummy) I2C slave.
[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,
13 I2C_NACK /* Masker NACKed a recieve byte. */
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);
48
adb86c37
AZ
49/* max7310.c */
50i2c_slave *max7310_init(i2c_bus *bus);
51void max7310_reset(i2c_slave *i2c);
52qemu_irq *max7310_gpio_in_get(i2c_slave *i2c);
53void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler);
54
55/* wm8750.c */
56i2c_slave *wm8750_init(i2c_bus *bus, AudioState *audio);
57void wm8750_reset(i2c_slave *i2c);
58void wm8750_data_req_set(i2c_slave *i2c,
59 void (*data_req)(void *, int, int), void *opaque);
60void wm8750_dac_dat(void *opaque, uint32_t sample);
61uint32_t wm8750_adc_dat(void *opaque);
62
0ff596d0 63#endif