Lines Matching full:mux
9 #include <linux/i2c-mux.h>
10 #include <linux/platform_data/i2c-mux-gpio.h>
25 static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) in i2c_mux_gpio_set() argument
31 gpiod_set_array_value_cansleep(mux->ngpios, mux->gpios, NULL, values); in i2c_mux_gpio_set()
36 struct gpiomux *mux = i2c_mux_priv(muxc); in i2c_mux_gpio_select() local
38 i2c_mux_gpio_set(mux, chan); in i2c_mux_gpio_select()
45 struct gpiomux *mux = i2c_mux_priv(muxc); in i2c_mux_gpio_deselect() local
47 i2c_mux_gpio_set(mux, mux->data.idle); in i2c_mux_gpio_deselect()
53 static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, in i2c_mux_gpio_probe_dt() argument
75 mux->data.parent = i2c_adapter_id(adapter); in i2c_mux_gpio_probe_dt()
78 mux->data.n_values = of_get_child_count(np); in i2c_mux_gpio_probe_dt()
81 mux->data.n_values, sizeof(*mux->data.values), in i2c_mux_gpio_probe_dt()
92 mux->data.values = values; in i2c_mux_gpio_probe_dt()
94 if (of_property_read_u32(np, "idle-state", &mux->data.idle)) in i2c_mux_gpio_probe_dt()
95 mux->data.idle = I2C_MUX_GPIO_NO_IDLE; in i2c_mux_gpio_probe_dt()
100 static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, in i2c_mux_gpio_probe_dt() argument
110 struct gpiomux *mux; in i2c_mux_gpio_probe() local
116 mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL); in i2c_mux_gpio_probe()
117 if (!mux) in i2c_mux_gpio_probe()
121 ret = i2c_mux_gpio_probe_dt(mux, pdev); in i2c_mux_gpio_probe()
125 memcpy(&mux->data, dev_get_platdata(&pdev->dev), in i2c_mux_gpio_probe()
126 sizeof(mux->data)); in i2c_mux_gpio_probe()
129 ngpios = gpiod_count(&pdev->dev, "mux"); in i2c_mux_gpio_probe()
134 mux->ngpios = ngpios; in i2c_mux_gpio_probe()
136 parent = i2c_get_adapter(mux->data.parent); in i2c_mux_gpio_probe()
140 muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, in i2c_mux_gpio_probe()
141 ngpios * sizeof(*mux->gpios), 0, in i2c_mux_gpio_probe()
147 mux->gpios = muxc->priv; in i2c_mux_gpio_probe()
148 muxc->priv = mux; in i2c_mux_gpio_probe()
156 if (mux->data.idle != I2C_MUX_GPIO_NO_IDLE) { in i2c_mux_gpio_probe()
157 initial_state = mux->data.idle; in i2c_mux_gpio_probe()
160 initial_state = mux->data.values[0]; in i2c_mux_gpio_probe()
172 gpiod = devm_gpiod_get_index(&pdev->dev, "mux", i, flag); in i2c_mux_gpio_probe()
178 mux->gpios[i] = gpiod; in i2c_mux_gpio_probe()
189 dev_info(&pdev->dev, "mux-locked i2c mux\n"); in i2c_mux_gpio_probe()
191 for (i = 0; i < mux->data.n_values; i++) { in i2c_mux_gpio_probe()
192 u32 nr = mux->data.base_nr ? (mux->data.base_nr + i) : 0; in i2c_mux_gpio_probe()
193 unsigned int class = mux->data.classes ? mux->data.classes[i] : 0; in i2c_mux_gpio_probe()
195 ret = i2c_mux_add_adapter(muxc, nr, mux->data.values[i], class); in i2c_mux_gpio_probe()
200 dev_info(&pdev->dev, "%d port mux on %s adapter\n", in i2c_mux_gpio_probe()
201 mux->data.n_values, parent->name); in i2c_mux_gpio_probe()
224 { .compatible = "i2c-mux-gpio", },
233 .name = "i2c-mux-gpio",
243 MODULE_ALIAS("platform:i2c-mux-gpio");