22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/i2c.h>
43 static int i2c_mux_master_xfer(
struct i2c_adapter *adap,
54 ret = parent->
algo->master_xfer(parent, msgs, num);
61 static int i2c_mux_smbus_xfer(
struct i2c_adapter *adap,
74 ret = parent->
algo->smbus_xfer(parent, addr, flags,
75 read_write, command, size, data);
88 return parent->
algo->functionality(parent);
92 static unsigned int i2c_mux_parent_classes(
struct i2c_adapter *parent)
94 unsigned int class = 0;
97 class |= parent->
class;
98 parent = i2c_parent_is_i2c_adapter(parent);
106 void *mux_priv,
u32 force_nr,
u32 chan_id,
130 if (parent->
algo->master_xfer)
131 priv->
algo.master_xfer = i2c_mux_master_xfer;
132 if (parent->
algo->smbus_xfer)
133 priv->
algo.smbus_xfer = i2c_mux_smbus_xfer;
134 priv->
algo.functionality = i2c_mux_functionality;
138 "i2c-%d-mux (chan_id %d)", i2c_adapter_id(parent), chan_id);
142 priv->
adap.dev.parent = &parent->
dev;
145 if (i2c_mux_parent_classes(parent) &
class)
147 "Segment %d behind mux can't share classes with ancestors\n",
150 priv->
adap.class =
class;
161 ret = of_property_read_u32(child,
"reg", ®);
164 if (chan_id == reg) {
172 priv->
adap.nr = force_nr;
179 "failed to add mux-adapter (error=%d)\n",
185 dev_info(&parent->
dev,
"Added multiplexed i2c bus %d\n",
186 i2c_adapter_id(&priv->
adap));