• Home
  • Raw
  • Download

Lines Matching full:mux

10 #include <linux/i2c-mux.h>
15 #include <linux/platform_data/i2c-mux-reg.h>
23 static int i2c_mux_reg_set(const struct regmux *mux, unsigned int chan_id) in i2c_mux_reg_set() argument
25 if (!mux->data.reg) in i2c_mux_reg_set()
34 switch (mux->data.reg_size) { in i2c_mux_reg_set()
36 if (mux->data.little_endian) in i2c_mux_reg_set()
37 iowrite32(chan_id, mux->data.reg); in i2c_mux_reg_set()
39 iowrite32be(chan_id, mux->data.reg); in i2c_mux_reg_set()
40 if (!mux->data.write_only) in i2c_mux_reg_set()
41 ioread32(mux->data.reg); in i2c_mux_reg_set()
44 if (mux->data.little_endian) in i2c_mux_reg_set()
45 iowrite16(chan_id, mux->data.reg); in i2c_mux_reg_set()
47 iowrite16be(chan_id, mux->data.reg); in i2c_mux_reg_set()
48 if (!mux->data.write_only) in i2c_mux_reg_set()
49 ioread16(mux->data.reg); in i2c_mux_reg_set()
52 iowrite8(chan_id, mux->data.reg); in i2c_mux_reg_set()
53 if (!mux->data.write_only) in i2c_mux_reg_set()
54 ioread8(mux->data.reg); in i2c_mux_reg_set()
63 struct regmux *mux = i2c_mux_priv(muxc); in i2c_mux_reg_select() local
65 return i2c_mux_reg_set(mux, chan); in i2c_mux_reg_select()
70 struct regmux *mux = i2c_mux_priv(muxc); in i2c_mux_reg_deselect() local
72 if (mux->data.idle_in_use) in i2c_mux_reg_deselect()
73 return i2c_mux_reg_set(mux, mux->data.idle); in i2c_mux_reg_deselect()
79 static int i2c_mux_reg_probe_dt(struct regmux *mux, in i2c_mux_reg_probe_dt() argument
102 mux->data.parent = i2c_adapter_id(adapter); in i2c_mux_reg_probe_dt()
105 mux->data.n_values = of_get_child_count(np); in i2c_mux_reg_probe_dt()
107 mux->data.little_endian = true; in i2c_mux_reg_probe_dt()
109 mux->data.little_endian = false; in i2c_mux_reg_probe_dt()
113 mux->data.little_endian = true; in i2c_mux_reg_probe_dt()
116 mux->data.little_endian = false; in i2c_mux_reg_probe_dt()
121 mux->data.write_only = of_property_read_bool(np, "write-only"); in i2c_mux_reg_probe_dt()
124 mux->data.n_values, sizeof(*mux->data.values), in i2c_mux_reg_probe_dt()
133 mux->data.values = values; in i2c_mux_reg_probe_dt()
135 if (!of_property_read_u32(np, "idle-state", &mux->data.idle)) in i2c_mux_reg_probe_dt()
136 mux->data.idle_in_use = true; in i2c_mux_reg_probe_dt()
140 mux->data.reg_size = resource_size(&res); in i2c_mux_reg_probe_dt()
141 mux->data.reg = devm_ioremap_resource(&pdev->dev, &res); in i2c_mux_reg_probe_dt()
142 if (IS_ERR(mux->data.reg)) in i2c_mux_reg_probe_dt()
143 return PTR_ERR(mux->data.reg); in i2c_mux_reg_probe_dt()
149 static int i2c_mux_reg_probe_dt(struct regmux *mux, in i2c_mux_reg_probe_dt() argument
159 struct regmux *mux; in i2c_mux_reg_probe() local
165 mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL); in i2c_mux_reg_probe()
166 if (!mux) in i2c_mux_reg_probe()
170 memcpy(&mux->data, dev_get_platdata(&pdev->dev), in i2c_mux_reg_probe()
171 sizeof(mux->data)); in i2c_mux_reg_probe()
173 ret = i2c_mux_reg_probe_dt(mux, pdev); in i2c_mux_reg_probe()
179 parent = i2c_get_adapter(mux->data.parent); in i2c_mux_reg_probe()
183 if (!mux->data.reg) { in i2c_mux_reg_probe()
186 mux->data.reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in i2c_mux_reg_probe()
187 if (IS_ERR(mux->data.reg)) { in i2c_mux_reg_probe()
188 ret = PTR_ERR(mux->data.reg); in i2c_mux_reg_probe()
191 mux->data.reg_size = resource_size(res); in i2c_mux_reg_probe()
194 if (mux->data.reg_size != 4 && mux->data.reg_size != 2 && in i2c_mux_reg_probe()
195 mux->data.reg_size != 1) { in i2c_mux_reg_probe()
201 muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, 0, 0, in i2c_mux_reg_probe()
207 muxc->priv = mux; in i2c_mux_reg_probe()
211 if (mux->data.idle_in_use) in i2c_mux_reg_probe()
214 for (i = 0; i < mux->data.n_values; i++) { in i2c_mux_reg_probe()
215 nr = mux->data.base_nr ? (mux->data.base_nr + i) : 0; in i2c_mux_reg_probe()
216 class = mux->data.classes ? mux->data.classes[i] : 0; in i2c_mux_reg_probe()
218 ret = i2c_mux_add_adapter(muxc, nr, mux->data.values[i], class); in i2c_mux_reg_probe()
223 dev_dbg(&pdev->dev, "%d port mux on %s adapter\n", in i2c_mux_reg_probe()
224 mux->data.n_values, muxc->parent->name); in i2c_mux_reg_probe()
247 { .compatible = "i2c-mux-reg", },
256 .name = "i2c-mux-reg",
266 MODULE_ALIAS("platform:i2c-mux-reg");