Re: [PATCH v5 3/5] clk: spacemit: Add clock support for Spacemit K1 SoC

Krzysztof Kozlowski
2025-03-07T08:26:50Z

On Fri, Mar 07, 2025 at 06:42:02AM +0000, Haylen Chu wrote:
> > > +static int k1_ccu_probe(struct platform_device *pdev)
> > > +{
> > > + struct regmap *base_regmap, *lock_regmap = NULL;
> > > + struct device *dev = &pdev->dev;
> > > + int ret;
> > > +
> > > + base_regmap = device_node_to_regmap(dev->of_node);
> > > + if (IS_ERR(base_regmap))
> > > + return dev_err_probe(dev, PTR_ERR(base_regmap),
> > > + "failed to get regmap\n");
> > > +
> > > + if (of_device_is_compatible(dev->of_node, "spacemit,k1-pll")) {
> > ..
> > > + struct device_node *mpmu = of_parse_phandle(dev->of_node,
> > > + "spacemit,mpmu", 0);
> > > + if (!mpmu)
> > > + return dev_err_probe(dev, -ENODEV,
> > > + "Cannot parse MPMU region\n");
> > > +
> > > + lock_regmap = device_node_to_regmap(mpmu);
> > > + of_node_put(mpmu);
> > > +
> > you can simplify above with syscon_regmap_lookup_by_phandle(), which
> > would save a few lines
> >
> > or further, just call syscon_regmap_lookup_by_compatible()? then
> > won't be necessary to introduce the "spacemit,mpmu" property..
> >
>
> These syscon_* functions differ a little from device_node_to_regmap():
> they get and enable the first item in "clocks" property when
> instantiating a regmap, which isn't desired for a clock controller.

Yes. And mpmu is not a syscon, so it would be inaccurate or even wrong
API to use.

Best regards,
Krzysztof