rng: msm: keep core clock disabled when PRNG not in use

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@samcday.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Link: https://lore.kernel.org/r/20250212-msm-rng-fixes-v2-5-645cf8d3fd3c@samcday.com
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
This commit is contained in:
Sam Day
2025-02-12 07:01:55 +00:00
committed by Caleb Connolly
parent dc8754e8e4
commit 2babb61428

View File

@@ -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)