mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 06:43:53 -06:00
libqos: convert I2C to qgraph
Create an i2c-bus interface, corresponding to the I2CAdapter struct. Wrap IMXI2C and OMAPI2C with a QOSGraphObject, and add the get_driver function to retrieve the I2CAdapter. The conversion is still not complete; for simplicity, i2c_recv and i2c_send (along with their wrappers) still take an adapter/address pair. Fixing that would be complicated until the tests are converted to qgraph, so it is left for after the conversion. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
732c919cf0
commit
c0825c63cf
5 changed files with 83 additions and 8 deletions
|
@ -186,10 +186,22 @@ static void imx_i2c_recv(I2CAdapter *i2c, uint8_t addr,
|
|||
g_assert((status & I2SR_IBB) == 0);
|
||||
}
|
||||
|
||||
static void *imx_i2c_get_driver(void *obj, const char *interface)
|
||||
{
|
||||
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;
|
||||
|
||||
s->obj.get_driver = imx_i2c_get_driver;
|
||||
|
||||
s->parent.send = imx_i2c_send;
|
||||
s->parent.recv = imx_i2c_recv;
|
||||
s->parent.qts = qts;
|
||||
|
@ -213,3 +225,11 @@ void imx_i2c_free(I2CAdapter *i2c)
|
|||
s = container_of(i2c, IMXI2C, parent);
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue