#include <linux/module.h>
#include <linux/mux/driver.h>
#include <linux/property.h>
#define ADG792A_LDSW BIT(0)
#define ADG792A_RESETB BIT(1)
#define ADG792A_DISABLE(mux) (0x50 | (mux))
#define ADG792A_DISABLE_ALL (0x5f)
#define ADG792A_MUX(mux, state) (0xc0 | (((mux) + 1) << 2) | (state))
#define ADG792A_MUX_ALL(state) (0xc0 | (state))
static int adg792a_write_cmd(struct i2c_client *i2c, u8 cmd, int reset)
u8 data = ADG792A_RESETB | ADG792A_LDSW;
return i2c_smbus_write_byte_data(i2c, cmd, data);
static int adg792a_set(struct mux_control *mux, int state)
struct i2c_client *i2c = to_i2c_client(mux->chip->dev.parent);
if (mux->chip->controllers == 1) {
if (state == MUX_IDLE_DISCONNECT)
cmd = ADG792A_DISABLE_ALL;
cmd = ADG792A_MUX_ALL(state);
unsigned int controller = mux_control_get_index(mux);
if (state == MUX_IDLE_DISCONNECT)
cmd = ADG792A_DISABLE(controller);
cmd = ADG792A_MUX(controller, state);
return adg792a_write_cmd(i2c, cmd, 0);
static const struct mux_control_ops adg792a_ops = {
static int adg792a_probe(struct i2c_client *i2c)
struct device *dev = &i2c->dev;