clk: qcom: clk-rcg2: add support for rcg2 freq multi ops
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 20 Dec 2023 22:17:23 +0000 (23:17 +0100)
committerBjorn Andersson <andersson@kernel.org>
Sat, 27 Apr 2024 18:01:14 +0000 (13:01 -0500)
commit89da22456af0762477d8c1345fdd17961b3ada80
treeffd2d70e1e7a077a59281abe4bbb9bf43fc296a0
parentd06b1043644a1831ab141bbee2669002bba15b0f
clk: qcom: clk-rcg2: add support for rcg2 freq multi ops

Some RCG frequency can be reached by multiple configuration.

Add clk_rcg2_fm_ops ops to support these special RCG configurations.

These alternative ops will select the frequency using a CEIL policy.

When the correct frequency is found, the correct config is selected by
calculating the final rate (by checking the defined parent and values
in the config that is being checked) and deciding based on the one that
is less different than the requested one.

These check are skipped if there is just one config for the requested
freq.

qcom_find_freq_multi is added to search the freq with the new struct
freq_multi_tbl.
__clk_rcg2_select_conf is used to select the correct conf by simulating
the final clock.
If a conf can't be found due to parent not reachable, a WARN is printed
and -EINVAL is returned.

Tested-by: Wei Lei <quic_leiwei@quicinc.com>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231220221724.3822-3-ansuelsmth@gmail.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/clk/qcom/clk-rcg.h
drivers/clk/qcom/clk-rcg2.c
drivers/clk/qcom/common.c
drivers/clk/qcom/common.h