Skip to content

Commit 61de83f

Browse files
glneokrzk
authored andcommitted
mux: mmio: Do not use syscon helper to build regmap
The syscon helper device_node_to_regmap() is used to fetch a regmap registered to a device node. It also currently creates this regmap if the node did not already have a regmap associated with it. This should only be used on "syscon" nodes. This driver is not such a device and instead uses device_node_to_regmap() on its own node as a hacky way to create a regmap for itself. This will not work going forward and so we should create our regmap the normal way by defining our regmap_config, fetching our memory resource, then using the normal regmap_init_mmio() function. Signed-off-by: Andrew Davis <afd@ti.com> Tested-by: Nishanth Menon <nm@ti.com> Link: https://lore.kernel.org/r/20250123182059.597491-1-afd@ti.com Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent 7ea3876 commit 61de83f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/mux/mmio.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,32 @@ static const struct of_device_id mux_mmio_dt_ids[] = {
3333
};
3434
MODULE_DEVICE_TABLE(of, mux_mmio_dt_ids);
3535

36+
static const struct regmap_config mux_mmio_regmap_cfg = {
37+
.reg_bits = 32,
38+
.val_bits = 32,
39+
.reg_stride = 4,
40+
};
41+
3642
static int mux_mmio_probe(struct platform_device *pdev)
3743
{
3844
struct device *dev = &pdev->dev;
3945
struct device_node *np = dev->of_node;
4046
struct regmap_field **fields;
4147
struct mux_chip *mux_chip;
4248
struct regmap *regmap;
49+
void __iomem *base;
4350
int num_fields;
4451
int ret;
4552
int i;
4653

4754
if (of_device_is_compatible(np, "mmio-mux")) {
4855
regmap = syscon_node_to_regmap(np->parent);
4956
} else {
50-
regmap = device_node_to_regmap(np);
57+
base = devm_platform_ioremap_resource(pdev, 0);
58+
if (IS_ERR(base))
59+
regmap = ERR_PTR(-ENODEV);
60+
else
61+
regmap = regmap_init_mmio(dev, base, &mux_mmio_regmap_cfg);
5162
/* Fallback to checking the parent node on "real" errors. */
5263
if (IS_ERR(regmap) && regmap != ERR_PTR(-EPROBE_DEFER)) {
5364
regmap = dev_get_regmap(dev->parent, NULL);

0 commit comments

Comments
 (0)