0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _LINUX_I2C_MUX_H
0012 #define _LINUX_I2C_MUX_H
0013
0014 #ifdef __KERNEL__
0015
0016 #include <linux/bitops.h>
0017
0018 struct i2c_mux_core {
0019 struct i2c_adapter *parent;
0020 struct device *dev;
0021 unsigned int mux_locked:1;
0022 unsigned int arbitrator:1;
0023 unsigned int gate:1;
0024
0025 void *priv;
0026
0027 int (*select)(struct i2c_mux_core *, u32 chan_id);
0028 int (*deselect)(struct i2c_mux_core *, u32 chan_id);
0029
0030 int num_adapters;
0031 int max_adapters;
0032 struct i2c_adapter *adapter[];
0033 };
0034
0035 struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
0036 struct device *dev, int max_adapters,
0037 int sizeof_priv, u32 flags,
0038 int (*select)(struct i2c_mux_core *, u32),
0039 int (*deselect)(struct i2c_mux_core *, u32));
0040
0041
0042 #define I2C_MUX_LOCKED BIT(0)
0043 #define I2C_MUX_ARBITRATOR BIT(1)
0044 #define I2C_MUX_GATE BIT(2)
0045
0046 static inline void *i2c_mux_priv(struct i2c_mux_core *muxc)
0047 {
0048 return muxc->priv;
0049 }
0050
0051 struct i2c_adapter *i2c_root_adapter(struct device *dev);
0052
0053
0054
0055
0056
0057
0058 int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
0059 u32 force_nr, u32 chan_id,
0060 unsigned int class);
0061
0062 void i2c_mux_del_adapters(struct i2c_mux_core *muxc);
0063
0064 #endif
0065
0066 #endif