]> www.infradead.org Git - users/jedix/linux-maple.git/commit
clk: qcom: gcc-sdm845: Add general purpose clock ops
authorDzmitry Sankouski <dsankouski@gmail.com>
Mon, 18 Nov 2024 10:15:21 +0000 (13:15 +0300)
committerBjorn Andersson <andersson@kernel.org>
Tue, 7 Jan 2025 17:16:27 +0000 (11:16 -0600)
commit898b72fa44f5739d22016ec5ff6697ba4ac4464d
tree717ad5c863ee551f0d3bfc95d4fbd982ed2a9e52
parentfaddad527c82714dede83d932b4d31f7e38c1766
clk: qcom: gcc-sdm845: Add general purpose clock ops

SDM845 has "General Purpose" clocks that can be muxed to
SoC pins to clock various external devices.
Those clocks may be used as e.g. PWM sources for external peripherals.

GPCLK can in theory have arbitrary value depending on the use case, so
the concept of frequency tables, used in rcg2 clock driver, is not
efficient, because it allows only defined frequencies.

Introduce clk_rcg2_gp_ops, which automatically calculate clock
mnd values for arbitrary clock rate. The calculation done as follows:
- upon determine rate request, we calculate m/n/pre_div as follows:
  - find parent(from our client's assigned-clock-parent) rate
  - find scaled rates by dividing rates on its greatest common divisor
  - assign requested scaled rate to m
  - factorize scaled parent rate, put multipliers to n till max value
    (determined by mnd_width)
- validate calculated values with *_width:
  - if doesn't fit, delete divisor and multiplier by 2 until fit
- return determined rate

Limitations:
- The driver doesn't select a parent clock (it may be selected by client
  in device tree with assigned-clocks, assigned-clock-parents properties)

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Link: https://lore.kernel.org/r/20241118-starqltechn_integration_upstream-v8-3-ac8e36a3aa65@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/gcc-sdm845.c