Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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/20240923100741.11277439@bootlin.com/ [1]
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20241014124636.24221-4-herve.codina@bootlin.com
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Herve Codina and committed by
Philipp Zabel
0426a920 86f13494

+34 -1
+34 -1
drivers/reset/reset-microchip-sparx5.c
··· 62 62 .reset = sparx5_reset_noop, 63 63 }; 64 64 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 + 65 87 static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name, 66 88 struct regmap **target) 67 89 { ··· 94 72 syscon_np = of_parse_phandle(pdev->dev.of_node, name, 0); 95 73 if (!syscon_np) 96 74 return -ENODEV; 97 - regmap = syscon_node_to_regmap(syscon_np); 75 + 76 + /* 77 + * The syscon API doesn't support syscon device removal. 78 + * When used in LAN966x PCI device, the cpu-syscon device needs to be 79 + * removed when the PCI device is removed. 80 + * In case of LAN966x, map the syscon device locally to support the 81 + * device removal. 82 + */ 83 + if (of_device_is_compatible(pdev->dev.of_node, "microchip,lan966x-switch-reset")) 84 + regmap = mchp_lan966x_syscon_to_regmap(&pdev->dev, syscon_np); 85 + else 86 + regmap = syscon_node_to_regmap(syscon_np); 98 87 of_node_put(syscon_np); 99 88 if (IS_ERR(regmap)) { 100 89 err = PTR_ERR(regmap);