[PATCH 07/13] clk: en7523: support getting regmap from parent node for EN7581

Christian Marangi
2025-03-09T13:30:52Z

Add support for getting clock regmap from parent node for Airoha EN7581.

This is needed to support new implementation with SCU (System Controller
Unit) as an MFD and clock-controller node as a child node of it.

In such implementation the register regmap is provided as a syscon from
the parent node.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/clk/clk-en7523.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index 2a74bc8fed24..29cb7ccea29a 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -665,6 +665,7 @@ static int en7581_clk_hw_init(struct platform_device *pdev,
const struct en_clk_soc_data *soc_data,
struct clk_hw_onecell_data *clk_data)
{
+ struct device *dev = &pdev->dev;
struct regmap *map, *clk_map;
void __iomem *base;

@@ -672,22 +673,28 @@ static int en7581_clk_hw_init(struct platform_device *pdev,
if (IS_ERR(map))
return PTR_ERR(map);

- base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(base))
- return PTR_ERR(base);
-
- clk_map = devm_regmap_init_mmio(&pdev->dev, base, &en7523_clk_regmap_config);
- if (IS_ERR(clk_map))
- return PTR_ERR(clk_map);
+ if (of_property_present(dev->of_node, "reg")) {
+ base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ clk_map = devm_regmap_init_mmio(dev, base, &en7523_clk_regmap_config);
+ if (IS_ERR(clk_map))
+ return PTR_ERR(clk_map);
+ } else {
+ clk_map = device_node_to_regmap(dev->parent->of_node);
+ if (IS_ERR(clk_map))
+ return PTR_ERR(clk_map);
+ }

- en75xx_register_clocks(&pdev->dev, soc_data, clk_data, map, clk_map);
+ en75xx_register_clocks(dev, soc_data, clk_data, map, clk_map);

regmap_clear_bits(clk_map, REG_NP_SCU_SSTR,
REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK);
regmap_update_bits(clk_map, REG_NP_SCU_PCIC, REG_PCIE_CTRL,
FIELD_PREP(REG_PCIE_CTRL, 3));

- return en7581_reset_register(&pdev->dev, clk_map);
+ return en7581_reset_register(dev, clk_map);
}

static int en7523_clk_probe(struct platform_device *pdev)
--
2.48.1