aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/libqos/i2c.h
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2019-09-10 16:41:20 +0200
committerThomas Huth <thuth@redhat.com>2020-01-12 11:42:41 +0100
commit1cf4323ecd03235984e43a416a42f10c975cf785 (patch)
tree57ad5475a4cbbbe0088aecf86b682d8e11150b9f /tests/qtest/libqos/i2c.h
parent833884f37adc9f125fa2f345704d7019b8651619 (diff)
tests/libqos: Move the libqos files under tests/qtest/
The qos stuff belongs to qtest, so move it into that directory, too. Message-Id: <20191218103059.11729-8-thuth@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/qtest/libqos/i2c.h')
-rw-r--r--tests/qtest/libqos/i2c.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/qtest/libqos/i2c.h b/tests/qtest/libqos/i2c.h
new file mode 100644
index 0000000000..945b65b34c
--- /dev/null
+++ b/tests/qtest/libqos/i2c.h
@@ -0,0 +1,82 @@
+/*
+ * I2C libqos
+ *
+ * Copyright (c) 2012 Andreas Färber
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef LIBQOS_I2C_H
+#define LIBQOS_I2C_H
+
+#include "libqtest.h"
+#include "libqos/qgraph.h"
+
+typedef struct I2CAdapter I2CAdapter;
+struct I2CAdapter {
+ void (*send)(I2CAdapter *adapter, uint8_t addr,
+ const uint8_t *buf, uint16_t len);
+ void (*recv)(I2CAdapter *adapter, uint8_t addr,
+ uint8_t *buf, uint16_t len);
+
+ QTestState *qts;
+};
+
+typedef struct QI2CAddress QI2CAddress;
+struct QI2CAddress {
+ uint8_t addr;
+};
+
+typedef struct QI2CDevice QI2CDevice;
+struct QI2CDevice {
+ /*
+ * For now, all devices are simple enough that there is no need for
+ * them to define their own constructor and get_driver functions.
+ * Therefore, QOSGraphObject is included directly in QI2CDevice;
+ * the tests expect to get a QI2CDevice rather than doing something
+ * like obj->get_driver("i2c-device").
+ *
+ * In fact there is no i2c-device interface even, because there are
+ * no generic I2C tests).
+ */
+ QOSGraphObject obj;
+ I2CAdapter *bus;
+ uint8_t addr;
+};
+
+void *i2c_device_create(void *i2c_bus, QGuestAllocator *alloc, void *addr);
+void add_qi2c_address(QOSGraphEdgeOptions *opts, QI2CAddress *addr);
+
+void i2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len);
+void i2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len);
+
+void i2c_read_block(QI2CDevice *dev, uint8_t reg,
+ uint8_t *buf, uint16_t len);
+void i2c_write_block(QI2CDevice *dev, uint8_t reg,
+ const uint8_t *buf, uint16_t len);
+uint8_t i2c_get8(QI2CDevice *dev, uint8_t reg);
+uint16_t i2c_get16(QI2CDevice *dev, uint8_t reg);
+void i2c_set8(QI2CDevice *dev, uint8_t reg, uint8_t value);
+void i2c_set16(QI2CDevice *dev, uint8_t reg, uint16_t value);
+
+/* i2c-omap.c */
+typedef struct OMAPI2C {
+ QOSGraphObject obj;
+ I2CAdapter parent;
+
+ uint64_t addr;
+} OMAPI2C;
+
+void omap_i2c_init(OMAPI2C *s, QTestState *qts, uint64_t addr);
+
+/* i2c-imx.c */
+typedef struct IMXI2C {
+ QOSGraphObject obj;
+ I2CAdapter parent;
+
+ uint64_t addr;
+} IMXI2C;
+
+void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr);
+
+#endif