From 9adf1cf6096a13c11d2ff57f9132a6ad178d177c Mon Sep 17 00:00:00 2001 From: Xingyu Wu Date: Fri, 7 Jul 2023 18:50:11 +0800 Subject: clk: starfive: jh7110: Add of_xlate ops and macros for clock id conversion Modify the drivers to add of_xlate ops and transform clock id. Signed-off-by: Xingyu Wu Signed-off-by: Hal Feng Reviewed-by: Torsten Duwe Reviewed-by: Leo Yu-Chi Liang --- drivers/clk/starfive/clk-jh7110-pll.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'drivers/clk/starfive/clk-jh7110-pll.c') diff --git a/drivers/clk/starfive/clk-jh7110-pll.c b/drivers/clk/starfive/clk-jh7110-pll.c index bb75a6d6cf..1568a1f4cd 100644 --- a/drivers/clk/starfive/clk-jh7110-pll.c +++ b/drivers/clk/starfive/clk-jh7110-pll.c @@ -19,6 +19,8 @@ #include #include +#include "clk.h" + #define UBOOT_DM_CLK_JH7110_PLLX "jh7110_clk_pllx" #define PLL_PD_OFF 1 @@ -31,6 +33,8 @@ #define CLK_DDR_BUS_PLL1_DIV4 2 #define CLK_DDR_BUS_PLL1_DIV8 3 +#define JH7110_PLL_ID_TRANS(id) ((id) + JH7110_EXTCLK_END) + enum starfive_pll_type { PLL0 = 0, PLL1, @@ -371,29 +375,46 @@ static int jh7110_pll_clk_probe(struct udevice *dev) if (sysreg == FDT_ADDR_T_NONE) return -EINVAL; - clk_dm(JH7110_SYSCLK_PLL0_OUT, + clk_dm(JH7110_PLL_ID_TRANS(JH7110_SYSCLK_PLL0_OUT), starfive_jh7110_pll("pll0_out", "oscillator", reg, (void __iomem *)sysreg, &starfive_jh7110_pll0)); - clk_dm(JH7110_SYSCLK_PLL1_OUT, + clk_dm(JH7110_PLL_ID_TRANS(JH7110_SYSCLK_PLL1_OUT), starfive_jh7110_pll("pll1_out", "oscillator", reg, (void __iomem *)sysreg, &starfive_jh7110_pll1)); - clk_dm(JH7110_SYSCLK_PLL2_OUT, + clk_dm(JH7110_PLL_ID_TRANS(JH7110_SYSCLK_PLL2_OUT), starfive_jh7110_pll("pll2_out", "oscillator", reg, (void __iomem *)sysreg, &starfive_jh7110_pll2)); return 0; } +static int jh7110_pll_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args) +{ + if (args->args_count > 1) { + debug("Invalid args_count: %d\n", args->args_count); + return -EINVAL; + } + + if (args->args_count) + clk->id = JH7110_PLL_ID_TRANS(args->args[0]); + else + clk->id = 0; + + return 0; +} + static const struct udevice_id jh7110_pll_clk_of_match[] = { { .compatible = "starfive,jh7110-pll", }, { } }; +JH7110_CLK_OPS(pll); + /* PLL clk device */ U_BOOT_DRIVER(jh7110_pll_clk) = { .name = "jh7110_pll_clk", .id = UCLASS_CLK, .of_match = jh7110_pll_clk_of_match, .probe = jh7110_pll_clk_probe, - .ops = &ccf_clk_ops, + .ops = &jh7110_pll_clk_ops, }; -- cgit v1.2.3