[PATCH v2 5/5] rng: msm: keep core clock disabled when PRNG not in use

Neil Armstrong neil.armstrong at linaro.org
Wed Feb 26 14:09:24 CET 2025


On 12/02/2025 08:01, Sam Day wrote:
> This is how the kernel does it. APQ8016E TRM also states that this clock
> can be turned off when no random numbers are needed.
> 
> Signed-off-by: Sam Day <me at samcday.com>
> ---
>   drivers/rng/msm_rng.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rng/msm_rng.c b/drivers/rng/msm_rng.c
> index 01505509103f28f7c91dd47edb83c23359163c82..aab602c5ed0bfed8b7cb9593fe22a8cef8f0f61a 100644
> --- a/drivers/rng/msm_rng.c
> +++ b/drivers/rng/msm_rng.c
> @@ -44,6 +44,11 @@ static int msm_rng_read(struct udevice *dev, void *data, size_t len)
>   	u32 *retdata = data;
>   	size_t maxsize;
>   	u32 val;
> +	int ret;
> +
> +	ret = clk_enable(&priv->clk);
> +	if (ret < 0)
> +		return ret;
>   
>   	/* calculate max size bytes to transfer back to caller */
>   	maxsize = min_t(size_t, MAX_HW_FIFO_SIZE, len);
> @@ -66,6 +71,8 @@ static int msm_rng_read(struct udevice *dev, void *data, size_t len)
>   			break;
>   	} while (currsize < maxsize);
>   
> +	clk_disable(&priv->clk);
> +
>   	return 0;
>   }
>   
> @@ -118,7 +125,9 @@ static int msm_rng_probe(struct udevice *dev)
>   	if (ret < 0)
>   		return ret;
>   
> -	return msm_rng_enable(priv, 1);
> +	ret = msm_rng_enable(priv, 1);
> +	clk_disable(&priv->clk);
> +	return ret;
>   }
>   
>   static int msm_rng_remove(struct udevice *dev)
> 

Looks good

Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>


More information about the U-Boot mailing list