Lines Matching +full:reg +full:- +full:mux

1 // SPDX-License-Identifier: GPL-2.0
3 * MMIO register bitfield-controlled multiplexer driver
12 #include <linux/mux/driver.h>
18 static int mux_mmio_set(struct mux_control *mux, int state) in mux_mmio_set() argument
20 struct regmap_field **fields = mux_chip_priv(mux->chip); in mux_mmio_set()
22 return regmap_field_write(fields[mux_control_get_index(mux)], state); in mux_mmio_set()
30 { .compatible = "mmio-mux", },
31 { .compatible = "reg-mux", },
38 struct device *dev = &pdev->dev; in mux_mmio_probe()
39 struct device_node *np = dev->of_node; in mux_mmio_probe()
47 if (of_device_is_compatible(np, "mmio-mux")) in mux_mmio_probe()
48 regmap = syscon_node_to_regmap(np->parent); in mux_mmio_probe()
50 regmap = dev_get_regmap(dev->parent, NULL) ?: ERR_PTR(-ENODEV); in mux_mmio_probe()
57 ret = of_property_count_u32_elems(np, "mux-reg-masks"); in mux_mmio_probe()
59 ret = -EINVAL; in mux_mmio_probe()
61 dev_err(dev, "mux-reg-masks property missing or invalid: %d\n", in mux_mmio_probe()
75 struct mux_control *mux = &mux_chip->mux[i]; in mux_mmio_probe() local
78 u32 reg, mask; in mux_mmio_probe() local
81 ret = of_property_read_u32_index(np, "mux-reg-masks", in mux_mmio_probe()
82 2 * i, &reg); in mux_mmio_probe()
84 ret = of_property_read_u32_index(np, "mux-reg-masks", in mux_mmio_probe()
87 dev_err(dev, "bitfield %d: failed to read mux-reg-masks property: %d\n", in mux_mmio_probe()
92 field.reg = reg; in mux_mmio_probe()
93 field.msb = fls(mask) - 1; in mux_mmio_probe()
94 field.lsb = ffs(mask) - 1; in mux_mmio_probe()
99 return -EINVAL; in mux_mmio_probe()
110 bits = 1 + field.msb - field.lsb; in mux_mmio_probe()
111 mux->states = 1 << bits; in mux_mmio_probe()
113 of_property_read_u32_index(np, "idle-states", i, in mux_mmio_probe()
116 if (idle_state < 0 || idle_state >= mux->states) { in mux_mmio_probe()
119 return -EINVAL; in mux_mmio_probe()
122 mux->idle_state = idle_state; in mux_mmio_probe()
126 mux_chip->ops = &mux_mmio_ops; in mux_mmio_probe()
133 .name = "mmio-mux",
140 MODULE_DESCRIPTION("MMIO register bitfield-controlled multiplexer driver");