summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/dm/uclass-id.h1
-rw-r--r--include/i2c.h39
2 files changed, 40 insertions, 0 deletions
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index bc057d7..777b101 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -35,6 +35,7 @@ enum uclass_id {
UCLASS_I2C, /* I2C bus */
UCLASS_I2C_EEPROM, /* I2C EEPROM device */
UCLASS_I2C_GENERIC, /* Generic I2C device */
+ UCLASS_I2C_MUX, /* I2C multiplexer */
UCLASS_LED, /* Light-emitting diode (LED) */
UCLASS_LPC, /* x86 'low pin count' interface */
UCLASS_MASS_STORAGE, /* Mass storage device */
diff --git a/include/i2c.h b/include/i2c.h
index d191829..6493931 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -445,6 +445,45 @@ struct dm_i2c_ops {
#define i2c_get_ops(dev) ((struct dm_i2c_ops *)(dev)->driver->ops)
/**
+ * struct i2c_mux_ops - operations for an I2C mux
+ *
+ * The current mux state is expected to be stored in the mux itself since
+ * it is the only thing that knows how to make things work. The mux can
+ * record the current state and then avoid switching unless it is necessary.
+ * So select() can be skipped if the mux is already in the correct state.
+ * Also deselect() can be made a nop if required.
+ */
+struct i2c_mux_ops {
+ /**
+ * select() - select one of of I2C buses attached to a mux
+ *
+ * This will be called when there is no bus currently selected by the
+ * mux. This method does not need to deselect the old bus since
+ * deselect() will be already have been called if necessary.
+ *
+ * @mux: Mux device
+ * @bus: I2C bus to select
+ * @channel: Channel number correponding to the bus to select
+ * @return 0 if OK, -ve on error
+ */
+ int (*select)(struct udevice *mux, struct udevice *bus, uint channel);
+
+ /**
+ * deselect() - select one of of I2C buses attached to a mux
+ *
+ * This is used to deselect the currently selected I2C bus.
+ *
+ * @mux: Mux device
+ * @bus: I2C bus to deselect
+ * @channel: Channel number correponding to the bus to deselect
+ * @return 0 if OK, -ve on error
+ */
+ int (*deselect)(struct udevice *mux, struct udevice *bus, uint channel);
+};
+
+#define i2c_mux_get_ops(dev) ((struct i2c_mux_ops *)(dev)->driver->ops)
+
+/**
* i2c_get_chip() - get a device to use to access a chip on a bus
*
* This returns the device for the given chip address. The device can then