From aa88d7ad28eafaa7ac187d5bbb0c46f987fac3a4 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Thu, 1 Mar 2018 11:05:45 +0000 Subject: i2c: Move the bus class to i2c.h Some devices need access to it. Signed-off-by: Corey Minyard Reviewed-by: Peter Maydell Signed-off-by: Linus Walleij Message-id: 20180227104903.21353-3-linus.walleij@linaro.org Signed-off-by: Peter Maydell --- include/hw/i2c/i2c.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/hw/i2c') diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 8fd449f..d727379 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -56,6 +56,23 @@ struct I2CSlave { uint8_t address; }; +#define TYPE_I2C_BUS "i2c-bus" +#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS) + +typedef struct I2CNode I2CNode; + +struct I2CNode { + I2CSlave *elt; + QLIST_ENTRY(I2CNode) next; +}; + +struct I2CBus { + BusState qbus; + QLIST_HEAD(, I2CNode) current_devs; + uint8_t saved_address; + bool broadcast; +}; + I2CBus *i2c_init_bus(DeviceState *parent, const char *name); void i2c_set_slave_address(I2CSlave *dev, uint8_t address); int i2c_bus_busy(I2CBus *bus); -- cgit v1.1