Lines Matching +full:i2c +full:- +full:mux
1 // SPDX-License-Identifier: GPL-2.0
3 * Multiplexer driver for Analog Devices ADG792A/G Triple 4:1 mux
11 #include <linux/i2c.h>
13 #include <linux/mux/driver.h>
18 #define ADG792A_DISABLE(mux) (0x50 | (mux)) argument
20 #define ADG792A_MUX(mux, state) (0xc0 | (((mux) + 1) << 2) | (state)) argument
23 static int adg792a_write_cmd(struct i2c_client *i2c, u8 cmd, int reset) in adg792a_write_cmd() argument
31 return i2c_smbus_write_byte_data(i2c, cmd, data); in adg792a_write_cmd()
34 static int adg792a_set(struct mux_control *mux, int state) in adg792a_set() argument
36 struct i2c_client *i2c = to_i2c_client(mux->chip->dev.parent); in adg792a_set() local
39 if (mux->chip->controllers == 1) { in adg792a_set()
40 /* parallel mux controller operation */ in adg792a_set()
46 unsigned int controller = mux_control_get_index(mux); in adg792a_set()
54 return adg792a_write_cmd(i2c, cmd, 0); in adg792a_set()
61 static int adg792a_probe(struct i2c_client *i2c) in adg792a_probe() argument
63 struct device *dev = &i2c->dev; in adg792a_probe()
70 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in adg792a_probe()
71 return -ENODEV; in adg792a_probe()
73 ret = device_property_read_u32(dev, "#mux-control-cells", &cells); in adg792a_probe()
77 return -EINVAL; in adg792a_probe()
83 mux_chip->ops = &adg792a_ops; in adg792a_probe()
85 ret = adg792a_write_cmd(i2c, ADG792A_DISABLE_ALL, 1); in adg792a_probe()
89 ret = device_property_read_u32_array(dev, "idle-state", in adg792a_probe()
91 mux_chip->controllers); in adg792a_probe()
98 for (i = 0; i < mux_chip->controllers; ++i) { in adg792a_probe()
99 struct mux_control *mux = &mux_chip->mux[i]; in adg792a_probe() local
101 mux->states = 4; in adg792a_probe()
107 mux->idle_state = idle_state[i]; in adg792a_probe()
110 dev_err(dev, "invalid idle-state %d\n", idle_state[i]); in adg792a_probe()
111 return -EINVAL; in adg792a_probe()
122 dev_info(dev, "triple pole quadruple throw mux registered\n"); in adg792a_probe()
132 MODULE_DEVICE_TABLE(i2c, adg792a_id);
151 MODULE_DESCRIPTION("Analog Devices ADG792A/G Triple 4:1 mux driver");