compiler: remove GNUC check
[qemu/ar7.git] / tests / qtest / libqos / i2c.h
blob1341bac1c599114e61e99d487855e77bb97526ea
1 /*
2 * I2C libqos
4 * Copyright (c) 2012 Andreas Färber
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9 #ifndef LIBQOS_I2C_H
10 #define LIBQOS_I2C_H
12 #include "libqtest.h"
13 #include "qgraph.h"
15 typedef struct I2CAdapter I2CAdapter;
16 struct I2CAdapter {
17 void (*send)(I2CAdapter *adapter, uint8_t addr,
18 const uint8_t *buf, uint16_t len);
19 void (*recv)(I2CAdapter *adapter, uint8_t addr,
20 uint8_t *buf, uint16_t len);
22 QTestState *qts;
25 typedef struct QI2CAddress QI2CAddress;
26 struct QI2CAddress {
27 uint8_t addr;
30 typedef struct QI2CDevice QI2CDevice;
31 struct QI2CDevice {
33 * For now, all devices are simple enough that there is no need for
34 * them to define their own constructor and get_driver functions.
35 * Therefore, QOSGraphObject is included directly in QI2CDevice;
36 * the tests expect to get a QI2CDevice rather than doing something
37 * like obj->get_driver("i2c-device").
39 * In fact there is no i2c-device interface even, because there are
40 * no generic I2C tests).
42 QOSGraphObject obj;
43 I2CAdapter *bus;
44 uint8_t addr;
47 void *i2c_device_create(void *i2c_bus, QGuestAllocator *alloc, void *addr);
48 void add_qi2c_address(QOSGraphEdgeOptions *opts, QI2CAddress *addr);
50 void qi2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len);
51 void qi2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len);
53 void i2c_read_block(QI2CDevice *dev, uint8_t reg,
54 uint8_t *buf, uint16_t len);
55 void i2c_write_block(QI2CDevice *dev, uint8_t reg,
56 const uint8_t *buf, uint16_t len);
57 uint8_t i2c_get8(QI2CDevice *dev, uint8_t reg);
58 uint16_t i2c_get16(QI2CDevice *dev, uint8_t reg);
59 void i2c_set8(QI2CDevice *dev, uint8_t reg, uint8_t value);
60 void i2c_set16(QI2CDevice *dev, uint8_t reg, uint16_t value);
62 /* i2c-omap.c */
63 typedef struct OMAPI2C {
64 QOSGraphObject obj;
65 I2CAdapter parent;
67 uint64_t addr;
68 } OMAPI2C;
70 void omap_i2c_init(OMAPI2C *s, QTestState *qts, uint64_t addr);
72 /* i2c-imx.c */
73 typedef struct IMXI2C {
74 QOSGraphObject obj;
75 I2CAdapter parent;
77 uint64_t addr;
78 } IMXI2C;
80 void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr);
82 #endif