38 #include <linux/module.h>
40 #include <linux/slab.h>
41 #include <linux/device.h>
42 #include <linux/i2c.h>
47 #define PCA954X_MAX_NCHANS 8
122 static int pca954x_reg_write(
struct i2c_adapter *adap,
127 if (adap->
algo->master_xfer) {
136 ret = adap->
algo->master_xfer(adap, &
msg, 1);
139 ret = adap->
algo->smbus_xfer(adap, client->
addr,
148 static int pca954x_select_chan(
struct i2c_adapter *adap,
158 regval = chan | chip->
enable;
164 ret = pca954x_reg_write(adap, client, regval);
171 static int pca954x_deselect_mux(
struct i2c_adapter *adap,
172 void *client,
u32 chan)
174 struct pca954x *data = i2c_get_clientdata(client);
178 return pca954x_reg_write(adap, client, data->
last_chan);
184 static int pca954x_probe(
struct i2c_client *client,
202 i2c_set_clientdata(client, data);
213 data->
type =
id->driver_data;
217 for (num = 0; num < chips[data->
type].
nchans; num++) {
221 if (num < pdata->num_modes) {
223 force = pdata->
modes[num].adap_id;
224 class = pdata->modes[num].
class;
232 force, num,
class, pca954x_select_chan,
233 (pdata && pdata->
modes[num].deselect_on_exit)
234 ? pca954x_deselect_mux :
NULL);
239 "failed to register multiplexed adapter"
240 " %d as bus %d\n", num, force);
241 goto virt_reg_failed;
246 "registered %d multiplexed busses for I2C %s %s\n",
248 ?
"mux" :
"switch", client->
name);
253 for (num--; num >= 0; num--)
261 static int pca954x_remove(
struct i2c_client *client)
263 struct pca954x *data = i2c_get_clientdata(client);
267 for (i = 0; i < chip->
nchans; ++
i)
284 .probe = pca954x_probe,
285 .remove = pca954x_remove,
286 .id_table = pca954x_id,