u-boot/drivers/clk/exynos
Sam Protsenko f77780b0ee clk: exynos: Fix incorrect clock lookup for non-top CMUs
Samsung clock drivers usually define the clock indices that are unique
per one CMU, but are not unique across all CMUs. That is, clock indices
start from 1 for each CMU, as provided in CMU bindings header. The way
the clock lookup via clk_get_by_index() works at the moment is by using
clk_of_xlate_default(), which returns globally non-unique clock ids for
for clocks registered with Samsung CCF API, which leads to incorrect
clocks being obtained. One way to fix that would be to make all clock
ids defined in the bindings header unique, but it'd make it incompatible
with Linux kernel bindings header. A better way to solve this issue is
to calculate the global clock id and use it when registering a clock
with clk_dm() and when obtaining it, in a custom .of_xlate function.

This patch adds an API for such mapping calculation, introducing the
necessary modifications to CMU registering functions in Samsung CCF.
Exynos850 clock driver (the only driver that uses Samsung CCF at the
moment) is modified accordingly, as it uses the changed API. So the
clock lookup with clk-exynos850.c driver is also fixed here.

The global clock id is calculated from CMU id and local clock id in
SAMSUNG_TO_CLK_ID() macro like this:

    clk_id_global = cmu_id * 256 + clk_id_local

leaving a range of up to 256 clocks for each CMU. Then this mapping
macro is used in clk_dm() to register clocks using their global ids, and
in .of_xlate() to lookup the clock by its local id correctly. Because
.of_xlate() operation has a separate function for each CMU, it "knows"
the correct way of finding the correct clk_id_global by provided
clk_id_local.

Fixes: ff3e8b8c6c ("clk: exynos: Add Samsung clock framework")
Fixes: a36cc5e3ef ("clk: exynos: Add Exynos850 clock driver")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
2024-03-26 18:56:55 +09:00
..
clk-exynos850.c clk: exynos: Fix incorrect clock lookup for non-top CMUs 2024-03-26 18:56:55 +09:00
clk-exynos7420.c clk: exynos: Move pll code into clk-exynos7420 2024-01-24 11:23:20 +09:00
clk-pll.c clk: exynos: Fix incorrect clock lookup for non-top CMUs 2024-03-26 18:56:55 +09:00
clk-pll.h clk: exynos: Fix incorrect clock lookup for non-top CMUs 2024-03-26 18:56:55 +09:00
clk.c clk: exynos: Fix incorrect clock lookup for non-top CMUs 2024-03-26 18:56:55 +09:00
clk.h clk: exynos: Fix incorrect clock lookup for non-top CMUs 2024-03-26 18:56:55 +09:00
Kconfig clk: exynos: Add Exynos850 clock driver 2024-01-24 11:23:20 +09:00
Makefile clk: exynos: Add Exynos850 clock driver 2024-01-24 11:23:20 +09:00