From 43b4b29fb996ee05d2ca98c7f824d6a003342215 Mon Sep 17 00:00:00 2001 From: Ghennadi Procopciuc Date: Wed, 15 Jan 2025 14:57:58 +0200 Subject: [PATCH] feat(nxp-clk): get pll rate using get_module_rate The DFS can use the get_module_rate instead of assuming its parent object is a PLL. It also has the advantage that the frequency will be returned based on the hardware state of the PLL module. Change-Id: I3a270cbc92622ae82606382df1301597dc29782a Signed-off-by: Ghennadi Procopciuc --- drivers/nxp/clk/s32cc/s32cc_clk_drv.c | 33 ++++++--------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/nxp/clk/s32cc/s32cc_clk_drv.c b/drivers/nxp/clk/s32cc/s32cc_clk_drv.c index 17def0108..a7320486d 100644 --- a/drivers/nxp/clk/s32cc/s32cc_clk_drv.c +++ b/drivers/nxp/clk/s32cc/s32cc_clk_drv.c @@ -694,24 +694,6 @@ static struct s32cc_dfs *get_div_dfs(const struct s32cc_dfs_div *dfs_div) return s32cc_obj2dfs(parent); } -static struct s32cc_pll *dfsdiv2pll(const struct s32cc_dfs_div *dfs_div) -{ - const struct s32cc_clk_obj *parent; - const struct s32cc_dfs *dfs; - - dfs = get_div_dfs(dfs_div); - if (dfs == NULL) { - return NULL; - } - - parent = dfs->parent; - if (parent->type != s32cc_pll_t) { - return NULL; - } - - return s32cc_obj2pll(parent); -} - static int get_dfs_mfi_mfn(unsigned long dfs_freq, const struct s32cc_dfs_div *dfs_div, uint32_t *mfi, uint32_t *mfn) { @@ -839,9 +821,9 @@ static int enable_dfs_div(struct s32cc_clk_obj *module, { const struct s32cc_dfs_div *dfs_div = s32cc_obj2dfsdiv(module); unsigned int ldepth = depth; - const struct s32cc_pll *pll; const struct s32cc_dfs *dfs; uintptr_t dfs_addr = 0UL; + unsigned long dfs_freq; uint32_t mfi, mfn; int ret = 0; @@ -855,18 +837,17 @@ static int enable_dfs_div(struct s32cc_clk_obj *module, return -EINVAL; } - pll = dfsdiv2pll(dfs_div); - if (pll == NULL) { - ERROR("Failed to identify DFS divider's parent\n"); - return -EINVAL; - } - ret = get_base_addr(dfs->instance, drv, &dfs_addr); if ((ret != 0) || (dfs_addr == 0UL)) { return -EINVAL; } - ret = get_dfs_mfi_mfn(pll->vco_freq, dfs_div, &mfi, &mfn); + ret = get_module_rate(&dfs->desc, drv, &dfs_freq, depth); + if (ret != 0) { + return ret; + } + + ret = get_dfs_mfi_mfn(dfs_freq, dfs_div, &mfi, &mfn); if (ret != 0) { return -EINVAL; }