[PATCH 1/2] clk: scmi: export scmi_clk_resolve_attr

Patrice CHOTARD patrice.chotard at foss.st.com
Thu Dec 11 13:26:47 CET 2025



On 12/11/25 09:31, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan at nxp.com>
> 
> With commit 3547e315c188 ("clk: scmi: Defer issue of SCMI_CLOCK_ATTRIBUTES"),
> the SCMI clock names might be defered. However the SCMI clock may be
> input to other clock controllers, such as clk-imx95-blkctrl.
> 
> Without the clock names being resolved, there will be error:
> clk_register: failed to get hsiopll device (parent of hsio_blk_ctl_clk)
> 
> So export this API for users.
> 
> Fixes: 3547e315c188 ("clk: scmi: Defer issue of SCMI_CLOCK_ATTRIBUTES"),
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
> ---
>  drivers/clk/clk_scmi.c | 20 +++++++++++---------
>  include/clk/scmi.h     | 12 ++++++++++++
>  2 files changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
> index cbd44f310b1..bc665e0bd3a 100644
> --- a/drivers/clk/clk_scmi.c
> +++ b/drivers/clk/clk_scmi.c
> @@ -6,6 +6,7 @@
>  #define LOG_CATEGORY UCLASS_CLK
>  
>  #include <clk-uclass.h>
> +#include <clk/scmi.h>
>  #include <dm.h>
>  #include <dm/device_compat.h>
>  #include <dm/device-internal.h>
> @@ -170,7 +171,7 @@ static int scmi_clk_gate(struct clk *clk, int enable)
>  	return scmi_to_linux_errno(out.status);
>  }
>  
> -static int scmi_clk_get_ctrl_flags(struct clk *clk, u32 *ctrl_flags)
> +int scmi_clk_resolve_attr(ulong id, u32 *ctrl_flags)
>  {
>  	struct clk_scmi *clkscmi;
>  	struct udevice *dev;
> @@ -178,7 +179,7 @@ static int scmi_clk_get_ctrl_flags(struct clk *clk, u32 *ctrl_flags)
>  	struct clk *c;
>  	int ret;
>  
> -	ret = clk_get_by_id(clk->id, &c);
> +	ret = clk_get_by_id(id, &c);
>  	if (ret)
>  		return ret;
>  
> @@ -188,7 +189,7 @@ static int scmi_clk_get_ctrl_flags(struct clk *clk, u32 *ctrl_flags)
>  
>  	if (!clkscmi->attrs_resolved) {
>  		char name[SCMI_CLOCK_NAME_LENGTH_MAX];
> -		ret = scmi_clk_get_attribute(dev, clk->id & CLK_ID_MSK,
> +		ret = scmi_clk_get_attribute(dev, id & CLK_ID_MSK,
>  					     name, &attributes);
>  		if (ret)
>  			return ret;
> @@ -197,7 +198,7 @@ static int scmi_clk_get_ctrl_flags(struct clk *clk, u32 *ctrl_flags)
>  		if (CLK_HAS_RESTRICTIONS(attributes)) {
>  			u32 perm;
>  
> -			ret = scmi_clk_get_permissions(dev, clk->id & CLK_ID_MSK, &perm);
> +			ret = scmi_clk_get_permissions(dev, id & CLK_ID_MSK, &perm);
>  			if (ret < 0)
>  				clkscmi->ctrl_flags = 0;
>  			else
> @@ -211,7 +212,8 @@ static int scmi_clk_get_ctrl_flags(struct clk *clk, u32 *ctrl_flags)
>  		clkscmi->attrs_resolved = true;
>  	}
>  
> -	*ctrl_flags = clkscmi->ctrl_flags;
> +	if (ctrl_flags)
> +		*ctrl_flags = clkscmi->ctrl_flags;
>  
>  	return 0;
>  }
> @@ -224,7 +226,7 @@ static int scmi_clk_enable(struct clk *clk)
>  	if (!CONFIG_IS_ENABLED(CLK_CCF))
>  		return scmi_clk_gate(clk, 1);
>  
> -	ret = scmi_clk_get_ctrl_flags(clk, &ctrl_flags);
> +	ret = scmi_clk_resolve_attr(clk->id, &ctrl_flags);
>  	if (ret)
>  		return ret;
>  
> @@ -244,7 +246,7 @@ static int scmi_clk_disable(struct clk *clk)
>  	if (!CONFIG_IS_ENABLED(CLK_CCF))
>  		return scmi_clk_gate(clk, 0);
>  
> -	ret = scmi_clk_get_ctrl_flags(clk, &ctrl_flags);
> +	ret = scmi_clk_resolve_attr(clk->id, &ctrl_flags);
>  	if (ret)
>  		return ret;
>  
> @@ -312,7 +314,7 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate)
>  	if (!CONFIG_IS_ENABLED(CLK_CCF))
>  		return __scmi_clk_set_rate(clk, rate);
>  
> -	ret = scmi_clk_get_ctrl_flags(clk, &ctrl_flags);
> +	ret = scmi_clk_resolve_attr(clk->id, &ctrl_flags);
>  	if (ret)
>  		return ret;
>  
> @@ -402,7 +404,7 @@ static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
>  	if (!CONFIG_IS_ENABLED(CLK_CCF))
>  		return __scmi_clk_set_parent(clk, parent);
>  
> -	ret = scmi_clk_get_ctrl_flags(clk, &ctrl_flags);
> +	ret = scmi_clk_resolve_attr(clk->id, &ctrl_flags);
>  	if (ret)
>  		return ret;
>  
> diff --git a/include/clk/scmi.h b/include/clk/scmi.h
> new file mode 100644
> index 00000000000..9c669ba4adc
> --- /dev/null
> +++ b/include/clk/scmi.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright 2025 NXP
> + */
> +
> +#ifndef _CLK_SCMI_H
> +#define _CLK_SCMI_H
> +
> +#include <linux/types.h>
> +
> +int scmi_clk_resolve_attr(ulong id, u32 *ctrl_flags);
> +#endif
> 
Hi Peng

I encountered the same issue on STM32MP13/25 platforms.

First, I converted our clock drivers to use clock indexes instead of clock names
and proceed with clock name resolution inside our clock driver implementation.
which was complicated and riksy because STM32MP13 supports both SPL and SCMI boot.

I was about to submit my proposal, but your solution convinced me.
Using your proposal, it's much simpler and less prone to regression.

Reviewed-by: Patrice Chotard <patrice.chotard at foss.st.com>

Thanks
Patrice






More information about the U-Boot mailing list