Lines Matching +full:i2c +full:- +full:mux

1 // SPDX-License-Identifier: GPL-2.0-only
3 * General Purpose I2C multiplexer
10 #include <linux/i2c.h>
11 #include <linux/i2c-mux.h>
13 #include <linux/mux/consumer.h>
17 struct mux { struct
25 struct mux *mux = i2c_mux_priv(muxc); in i2c_mux_select() local
28 ret = mux_control_select(mux->control, chan); in i2c_mux_select()
29 mux->do_not_deselect = ret < 0; in i2c_mux_select()
36 struct mux *mux = i2c_mux_priv(muxc); in i2c_mux_deselect() local
38 if (mux->do_not_deselect) in i2c_mux_deselect()
41 return mux_control_deselect(mux->control); in i2c_mux_deselect()
46 struct device_node *np = dev->of_node; in mux_parent_adapter()
50 parent_np = of_parse_phandle(np, "i2c-parent", 0); in mux_parent_adapter()
52 dev_err(dev, "Cannot parse i2c-parent\n"); in mux_parent_adapter()
53 return ERR_PTR(-ENODEV); in mux_parent_adapter()
58 return ERR_PTR(-EPROBE_DEFER); in mux_parent_adapter()
64 { .compatible = "i2c-mux", },
71 struct device *dev = &pdev->dev; in i2c_mux_probe()
72 struct device_node *np = dev->of_node; in i2c_mux_probe()
75 struct mux *mux; in i2c_mux_probe() local
81 return -ENODEV; in i2c_mux_probe()
83 mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL); in i2c_mux_probe()
84 if (!mux) in i2c_mux_probe()
85 return -ENOMEM; in i2c_mux_probe()
87 mux->control = devm_mux_control_get(dev, NULL); in i2c_mux_probe()
88 if (IS_ERR(mux->control)) in i2c_mux_probe()
89 return dev_err_probe(dev, PTR_ERR(mux->control), in i2c_mux_probe()
90 "failed to get control-mux\n"); in i2c_mux_probe()
95 "failed to get i2c-parent adapter\n"); in i2c_mux_probe()
102 ret = -ENOMEM; in i2c_mux_probe()
105 muxc->priv = mux; in i2c_mux_probe()
109 muxc->mux_locked = of_property_read_bool(np, "mux-locked"); in i2c_mux_probe()
121 if (chan >= mux_control_states(mux->control)) { in i2c_mux_probe()
123 ret = -EINVAL; in i2c_mux_probe()
132 dev_info(dev, "%d-port mux on %s adapter\n", children, parent->name); in i2c_mux_probe()
150 i2c_put_adapter(muxc->parent); in i2c_mux_remove()
157 .name = "i2c-mux-gpmux",
163 MODULE_DESCRIPTION("General Purpose I2C multiplexer driver");