Skip to content

Commit 0426a92

Browse files
hcodinapH5
authored andcommitted
reset: mchp: sparx5: Map cpu-syscon locally in case of LAN966x
In the LAN966x PCI device use case, the syscon API cannot be used as it does not support device removal [1]. A syscon device is a core "system" device and not a device available in some addon boards and so, it is not supposed to be removed. The syscon API follows this assumption but this assumption is no longer valid in the LAN966x use case. In order to avoid the use of the syscon API and so, support for removal, use a local mapping of the syscon device. Link: https://lore.kernel.org/all/[email protected]/ [1] Signed-off-by: Herve Codina <[email protected]> Reviewed-by: Steen Hegelund <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Philipp Zabel <[email protected]>
1 parent 86f1349 commit 0426a92

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

drivers/reset/reset-microchip-sparx5.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ static const struct reset_control_ops sparx5_reset_ops = {
6262
.reset = sparx5_reset_noop,
6363
};
6464

65+
static const struct regmap_config mchp_lan966x_syscon_regmap_config = {
66+
.reg_bits = 32,
67+
.val_bits = 32,
68+
.reg_stride = 4,
69+
};
70+
71+
static struct regmap *mchp_lan966x_syscon_to_regmap(struct device *dev,
72+
struct device_node *syscon_np)
73+
{
74+
struct regmap_config regmap_config = mchp_lan966x_syscon_regmap_config;
75+
resource_size_t size;
76+
void __iomem *base;
77+
78+
base = devm_of_iomap(dev, syscon_np, 0, &size);
79+
if (IS_ERR(base))
80+
return ERR_CAST(base);
81+
82+
regmap_config.max_register = size - 4;
83+
84+
return devm_regmap_init_mmio(dev, base, &regmap_config);
85+
}
86+
6587
static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name,
6688
struct regmap **target)
6789
{
@@ -72,7 +94,18 @@ static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name,
7294
syscon_np = of_parse_phandle(pdev->dev.of_node, name, 0);
7395
if (!syscon_np)
7496
return -ENODEV;
75-
regmap = syscon_node_to_regmap(syscon_np);
97+
98+
/*
99+
* The syscon API doesn't support syscon device removal.
100+
* When used in LAN966x PCI device, the cpu-syscon device needs to be
101+
* removed when the PCI device is removed.
102+
* In case of LAN966x, map the syscon device locally to support the
103+
* device removal.
104+
*/
105+
if (of_device_is_compatible(pdev->dev.of_node, "microchip,lan966x-switch-reset"))
106+
regmap = mchp_lan966x_syscon_to_regmap(&pdev->dev, syscon_np);
107+
else
108+
regmap = syscon_node_to_regmap(syscon_np);
76109
of_node_put(syscon_np);
77110
if (IS_ERR(regmap)) {
78111
err = PTR_ERR(regmap);

0 commit comments

Comments
 (0)