summaryrefslogtreecommitdiffstats
path: root/tests/libqos/i2c-imx.c
diff options
context:
space:
mode:
authorPeter Maydell2019-06-03 19:26:21 +0200
committerPeter Maydell2019-06-03 19:26:21 +0200
commite2a58ff493a2e00db3e963c1839c5374500110f2 (patch)
tree1136df9621eb962326714fa330eaad310fb8de12 /tests/libqos/i2c-imx.c
parentMerge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jun-1-2019' i... (diff)
parentq35: Revert to kernel irqchip (diff)
downloadqemu-e2a58ff493a2e00db3e963c1839c5374500110f2.tar.gz
qemu-e2a58ff493a2e00db3e963c1839c5374500110f2.tar.xz
qemu-e2a58ff493a2e00db3e963c1839c5374500110f2.zip
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* Revert q35 to kernel irqchip (Alex) * edu device fixes (Li Qiang) * cleanups (Marc-André, Peter) * Improvements to -accel help * Better support for IA32_MISC_ENABLE MSR (Wanpeng) * I2C test conversion to qgraph (Paolo) # gpg: Signature made Mon 03 Jun 2019 14:20:12 BST # gpg: using RSA key BFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (24 commits) q35: Revert to kernel irqchip configure: remove tpm_passthrough & tpm_emulator ci: store Patchew configuration in the tree libqos: i2c: move address into QI2CDevice tests: convert ds1338-test to qtest tests: convert OMAP i2c tests to qgraph libqos: add ARM imx25-pdk machine object libqos: add ARM n800 machine object libqos: convert I2C to qgraph libqos: split I2CAdapter initialization and allocation imx25-pdk: create ds1338 for qtest inside the test pca9552-test: do not rely on state across tests libqos: fix omap-i2c receiving more than 4 bytes libqos: move common i2c code to libqos qgraph: fix qos_node_contains with options qgraph: allow extra_device_opts on contains nodes edu: uses uint64_t in dma operation edu: mmio: allow 64-bit access in read dispatch edu: mmio: allow 64-bit access i386: Enable IA32_MISC_ENABLE MWAIT bit when exposing mwait/monitor ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/libqos/i2c-imx.c')
-rw-r--r--tests/libqos/i2c-imx.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/tests/libqos/i2c-imx.c b/tests/libqos/i2c-imx.c
index 0945f2ecdc..f33ece55a3 100644
--- a/tests/libqos/i2c-imx.c
+++ b/tests/libqos/i2c-imx.c
@@ -30,13 +30,6 @@ enum IMXI2CDirection {
IMX_I2C_WRITE,
};
-typedef struct IMXI2C {
- I2CAdapter parent;
-
- uint64_t addr;
-} IMXI2C;
-
-
static void imx_i2c_set_slave_addr(IMXI2C *s, uint8_t addr,
enum IMXI2CDirection direction)
{
@@ -47,7 +40,7 @@ static void imx_i2c_set_slave_addr(IMXI2C *s, uint8_t addr,
static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr,
const uint8_t *buf, uint16_t len)
{
- IMXI2C *s = (IMXI2C *)i2c;
+ IMXI2C *s = container_of(i2c, IMXI2C, parent);
uint8_t data;
uint8_t status;
uint16_t size = 0;
@@ -107,7 +100,7 @@ static void imx_i2c_send(I2CAdapter *i2c, uint8_t addr,
static void imx_i2c_recv(I2CAdapter *i2c, uint8_t addr,
uint8_t *buf, uint16_t len)
{
- IMXI2C *s = (IMXI2C *)i2c;
+ IMXI2C *s = container_of(i2c, IMXI2C, parent);
uint8_t data;
uint8_t status;
uint16_t size = 0;
@@ -193,16 +186,31 @@ static void imx_i2c_recv(I2CAdapter *i2c, uint8_t addr,
g_assert((status & I2SR_IBB) == 0);
}
-I2CAdapter *imx_i2c_create(QTestState *qts, uint64_t addr)
+static void *imx_i2c_get_driver(void *obj, const char *interface)
{
- IMXI2C *s = g_malloc0(sizeof(*s));
- I2CAdapter *i2c = (I2CAdapter *)s;
+ IMXI2C *s = obj;
+ if (!g_strcmp0(interface, "i2c-bus")) {
+ return &s->parent;
+ }
+ fprintf(stderr, "%s not present in imx-i2c\n", interface);
+ g_assert_not_reached();
+}
+void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr)
+{
s->addr = addr;
- i2c->send = imx_i2c_send;
- i2c->recv = imx_i2c_recv;
- i2c->qts = qts;
+ s->obj.get_driver = imx_i2c_get_driver;
- return i2c;
+ s->parent.send = imx_i2c_send;
+ s->parent.recv = imx_i2c_recv;
+ s->parent.qts = qts;
}
+
+static void imx_i2c_register_nodes(void)
+{
+ qos_node_create_driver("imx.i2c", NULL);
+ qos_node_produces("imx.i2c", "i2c-bus");
+}
+
+libqos_init(imx_i2c_register_nodes);