]> git.proxmox.com Git - mirror_qemu.git/blame - tests/libqos/i2c.h
minikconf: do not include variables from MINIKCONF_ARGS in config-all-devices.mak
[mirror_qemu.git] / tests / libqos / i2c.h
CommitLineData
2bf7b457
AF
1/*
2 * I2C libqos
3 *
4 * Copyright (c) 2012 Andreas Färber
5 *
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
11
f1dfd507 12#include "libqtest.h"
c0825c63 13#include "libqos/qgraph.h"
2bf7b457
AF
14
15typedef struct I2CAdapter I2CAdapter;
16struct 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);
f1dfd507
EB
21
22 QTestState *qts;
2bf7b457
AF
23};
24
06599472
PB
25typedef struct QI2CAddress QI2CAddress;
26struct QI2CAddress {
27 uint8_t addr;
28};
29
c0825c63
PB
30typedef struct QI2CDevice QI2CDevice;
31struct QI2CDevice {
32 /*
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").
38 *
39 * In fact there is no i2c-device interface even, because there are
40 * no generic I2C tests).
41 */
42 QOSGraphObject obj;
43 I2CAdapter *bus;
06599472 44 uint8_t addr;
c0825c63
PB
45};
46
c0825c63 47void *i2c_device_create(void *i2c_bus, QGuestAllocator *alloc, void *addr);
06599472 48void add_qi2c_address(QOSGraphEdgeOptions *opts, QI2CAddress *addr);
c0825c63 49
06599472
PB
50void i2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len);
51void i2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len);
2bf7b457 52
06599472 53void i2c_read_block(QI2CDevice *dev, uint8_t reg,
e8ecb706 54 uint8_t *buf, uint16_t len);
06599472 55void i2c_write_block(QI2CDevice *dev, uint8_t reg,
e8ecb706 56 const uint8_t *buf, uint16_t len);
06599472
PB
57uint8_t i2c_get8(QI2CDevice *dev, uint8_t reg);
58uint16_t i2c_get16(QI2CDevice *dev, uint8_t reg);
59void i2c_set8(QI2CDevice *dev, uint8_t reg, uint8_t value);
60void i2c_set16(QI2CDevice *dev, uint8_t reg, uint16_t value);
e8ecb706 61
732c919c
PB
62/* i2c-omap.c */
63typedef struct OMAPI2C {
c0825c63 64 QOSGraphObject obj;
732c919c
PB
65 I2CAdapter parent;
66
67 uint64_t addr;
68} OMAPI2C;
69
70void omap_i2c_init(OMAPI2C *s, QTestState *qts, uint64_t addr);
732c919c
PB
71
72/* i2c-imx.c */
73typedef struct IMXI2C {
c0825c63 74 QOSGraphObject obj;
732c919c
PB
75 I2CAdapter parent;
76
77 uint64_t addr;
78} IMXI2C;
2bf7b457 79
732c919c 80void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr);
7f398627 81
2bf7b457 82#endif