linux-stable/drivers/clk/samsung
Sam Protsenko dbf2fb2ab1 clk: samsung: exynos850: Propagate SPI IPCLK rate change
[ Upstream commit 67c15187d4 ]

When SPI transfer is being prepared, the spi-s3c64xx driver will call
clk_set_rate() to change the rate of SPI source clock (IPCLK). But IPCLK
is a gate (leaf) clock, so it must propagate the rate change up the
clock tree, so that corresponding DIV clocks can actually change their
divider values. Add CLK_SET_RATE_PARENT flag to corresponding clocks for
all SPI instances in Exynos850 (spi_0, spi_1 and spi_2) to make it
possible. This change involves next clocks:

usi_spi_0:

    Clock                  Block       Div range
    --------------------------------------------
    gout_spi0_ipclk        CMU_PERI    -
    dout_peri_spi0         CMU_PERI    /1..32
    mout_peri_spi_user     CMU_PERI    -
    dout_peri_ip           CMU_TOP     /1..16

usi_cmgp0:

    Clock                  Block       Div range
    --------------------------------------------
    gout_cmgp_usi0_ipclk   CMU_CMGP    -
    dout_cmgp_usi0         CMU_CMGP    /1..32
    mout_cmgp_usi0         CMU_CMGP    -
    gout_clkcmu_cmgp_bus   CMU_APM     -
    dout_apm_bus           CMU_APM     /1..8

usi_cmgp1:

    Clock                  Block       Div range
    --------------------------------------------
    gout_cmgp_usi1_ipclk   CMU_CMGP    -
    dout_cmgp_usi1         CMU_CMGP    /1..32
    mout_cmgp_usi1         CMU_CMGP    -
    gout_clkcmu_cmgp_bus   CMU_APM     -
    dout_apm_bus           CMU_APM     /1..8

With input clock of 400 MHz, this scheme provides next IPCLK rate range,
for each SPI block:

    SPI0:   781 kHz ... 400 MHz
    SPI1/2: 1.6 MHz ... 400 MHz

Accounting for internal /4 divider in SPI blocks, and because the max
SPI frequency is limited at 50 MHz, it gives us next SPI SCK rates:

    SPI0:   200 kHz ... 49.9 MHz
    SPI1/2: 400 kHz ... 49.9 MHz

Which should cover all possible applications of SPI bus. Of course,
setting SPI frequency to values as low as 500 kHz will also affect the
common bus dividers (dout_apm_bus or dout_peri_ip), which in turn
effectively lowers the rates for all leaf bus clocks derived from those
dividers, like HSI2C and I3C clocks. But at least it gives the board
designer a choice, whether to keep all clocks (SPI/HSI2C/I3C) at high
frequencies, or make all those clocks have lower frequencies. Not
propagating the rate change to those common dividers would limit this
choice to "only high frequencies are allowed for SPI/HSI2C/I3C" option,
making the common dividers useless. This decision follows the "Worse is
better" approach, relying on the users/engineers to know the system
internals when working with such low-level features, instead of trying
to account for all possible use-cases.

Fixes: 7dd0557819 ("clk: samsung: Introduce Exynos850 clock driver")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240125013858.3986-2-semen.protsenko@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:17:02 -04:00
..
Kconfig clk: samsung: add CONFIG_OF dependency 2023-06-12 11:45:20 +02:00
Makefile clk: samsung: clk-gs101: Add cmu_top, cmu_misc and cmu_apm support 2023-12-12 20:29:03 +01:00
clk-cpu.c clk: samsung: Update CPU clk registration 2021-11-20 14:22:49 +01:00
clk-cpu.h clk: samsung: Improve kernel-doc comments 2023-11-16 20:46:03 +01:00
clk-exynos-arm64.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-exynos-arm64.h clk: samsung: exynos5433: Extract PM support to common ARM64 layer 2023-03-07 08:38:54 +01:00
clk-exynos-audss.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-exynos-clkout.c clk: Use device_get_match_data() 2023-10-23 20:16:21 -07:00
clk-exynos4.c clk: samsung: exynos4: do not define number of clocks in bindings 2023-08-15 07:48:51 +02:00
clk-exynos5-subcmu.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-exynos5-subcmu.h clk: samsung: Change signature of exynos5_subcmus_init() function 2019-08-08 13:53:42 -07:00
clk-exynos7.c clk: exynos7: Mark aclk_fsys1_200 as critical 2021-04-07 11:37:17 +02:00
clk-exynos850.c clk: samsung: exynos850: Propagate SPI IPCLK rate change 2024-03-26 18:17:02 -04:00
clk-exynos3250.c clk: samsung: exynos3250: do not define number of clocks in bindings 2023-08-15 07:48:20 +02:00
clk-exynos4412-isp.c clk: samsung: exynos4: do not define number of clocks in bindings 2023-08-15 07:48:51 +02:00
clk-exynos5250.c clk: samsung: exynos5250: do not define number of clocks in bindings 2023-08-15 07:49:01 +02:00
clk-exynos5260.c clk: samsung: exynos5260: do not define number of clocks in bindings 2023-08-15 07:49:12 +02:00
clk-exynos5260.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
clk-exynos5410.c clk: samsung: exynos5410: do not define number of clocks in bindings 2023-08-15 07:49:19 +02:00
clk-exynos5420.c clk: samsung: exynos5420: do not define number of clocks in bindings 2023-08-15 07:49:24 +02:00
clk-exynos5433.c clk: samsung: exynos5433: do not define number of clocks in bindings 2023-08-15 07:49:29 +02:00
clk-exynos7885.c Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
clk-exynosautov9.c Merge branches 'clk-imx', 'clk-samsung', 'clk-annotate', 'clk-marvell' and 'clk-lmk' into clk-next 2023-08-30 14:39:19 -07:00
clk-fsd.c clk: Explicitly include correct DT includes 2023-07-19 13:13:16 -07:00
clk-gs101.c clk: samsung: clk-gs101: comply with the new dt cmu_misc clock names 2024-01-22 11:40:12 +01:00
clk-pll.c clk: samsung: clk-pll: Add support for pll_{0516,0517,518} 2023-12-12 20:28:12 +01:00
clk-pll.h clk: samsung: clk-pll: Add support for pll_{0516,0517,518} 2023-12-12 20:28:12 +01:00
clk-s3c64xx.c clk: samsung: Set dev in samsung_clk_init() 2023-03-06 16:55:26 +01:00
clk-s5pv210-audss.c clk: samsung: s5pv210-audss: Make use of devm_platform_ioremap_resource() 2021-09-13 18:01:09 +02:00
clk-s5pv210.c clk: samsung: Set dev in samsung_clk_init() 2023-03-06 16:55:26 +01:00
clk.c clk: samsung: Extract clocks registration to common function 2023-03-07 08:38:54 +01:00
clk.h clk: samsung: Improve kernel-doc comments 2023-11-16 20:46:03 +01:00