clk: qcom: Allow polling for clock status in qcom_gate_clk_en()
authorStephan Gerhold <stephan.gerhold@linaro.org>
Thu, 24 Apr 2025 09:16:44 +0000 (11:16 +0200)
committerCasey Connolly <casey.connolly@linaro.org>
Mon, 2 Jun 2025 16:20:15 +0000 (18:20 +0200)
commit6c049ed99392353bcda24f708e1cfa5c21f2a0f9
treeed9621159422ee3fe60331b9f58ce38fd87ffa49
parent94e57ba2011b4bb96c0714e02a5056bc0c7f87d0
clk: qcom: Allow polling for clock status in qcom_gate_clk_en()

GATE_CLK() in its current state is unsafe: A simple write to the clock
enable register does not guarantee that the clock is immediately running.
Without polling the clock status, we may issue writes to registers before
the necessary clocks start running. This doesn't seem to cause issues in
U-Boot at the moment, but for example removing the CLK_OFF polling in TF-A
for the SMMU clocks on DB410c reliably triggers an exception during boot.

Make it possible to poll the branch clock status register, by adding a new
GATE_CLK_POLLED() macro that takes the extra register address. Existing
usages work just as before, without polling the clock status. Ideally all
usages should be updated to specify the correct poll address in the future.

The Qualcomm naming for these clocks is "branch" and not "gate", but let's
keep the existing naming for now to avoid confusion until all others
drivers have been converted.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Reviewed-by: Casey Connolly <casey.connolly@linaro.org>
Link: https://lore.kernel.org/r/20250424-apq8016-clock-fixes2-v2-4-fcc371c9e45f@linaro.org
Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
drivers/clk/qcom/clock-qcom.c
drivers/clk/qcom/clock-qcom.h