11 #include <linux/i2c.h>
16 #include <linux/module.h>
17 #include <linux/slab.h>
27 static void i2c_mux_gpio_set(
const struct gpiomux *mux,
unsigned val)
31 for (i = 0; i < mux->
data.n_gpios; i++)
40 i2c_mux_gpio_set(mux, mux->
data.values[chan]);
49 i2c_mux_gpio_set(mux, mux->
data.idle);
54 static int __devinit match_gpio_chip_by_label(
struct gpio_chip *
chip,
57 return !
strcmp(chip->label, data);
69 pdata = pdev->
dev.platform_data;
71 dev_err(&pdev->
dev,
"Missing platform data\n");
80 struct gpio_chip *
gpio;
83 match_gpio_chip_by_label);
87 gpio_base = gpio->base;
94 dev_err(&pdev->
dev,
"Parent adapter (%d) not found\n",
117 initial_state = pdata->
idle;
118 deselect = i2c_mux_gpio_deselect;
120 initial_state = pdata->
values[0];
124 for (i = 0; i < pdata->
n_gpios; i++) {
127 goto err_request_gpio;
129 initial_state & (1 << i));
132 for (i = 0; i < pdata->
n_values; i++) {
134 unsigned int class = pdata->classes ? pdata->classes[i] : 0;
138 i2c_mux_gpio_select, deselect);
141 dev_err(&pdev->
dev,
"Failed to add adapter %d\n", i);
142 goto add_adapter_failed;
146 dev_info(&pdev->
dev,
"%d port mux on %s adapter\n",
149 platform_set_drvdata(pdev, mux);
168 struct gpiomux *mux = platform_get_drvdata(pdev);
171 for (i = 0; i < mux->
data.n_values; i++)
174 for (i = 0; i < mux->
data.n_gpios; i++)
177 platform_set_drvdata(pdev,
NULL);
184 .probe = i2c_mux_gpio_probe,
188 .name =
"i2c-mux-gpio",