feat(nxp-clk): add get_rate for s32cc_fixed_div
The get rate callback is needed for s32cc_fixed_div to allow the
frequency compilation for modules attached to a fixed divider like
LINFLEXD_CLK.
Change-Id: Ibc3e52f7f1127bba0dd793be0a26bdff15260824
Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com>
diff --git a/drivers/nxp/clk/s32cc/s32cc_clk_drv.c b/drivers/nxp/clk/s32cc/s32cc_clk_drv.c
index b77eb21..d41fcb3 100644
--- a/drivers/nxp/clk/s32cc/s32cc_clk_drv.c
+++ b/drivers/nxp/clk/s32cc/s32cc_clk_drv.c
@@ -1365,6 +1365,23 @@
return ret;
}
+static int get_fixed_div_freq(const struct s32cc_clk_obj *module,
+ const struct s32cc_clk_drv *drv,
+ unsigned long *rate, unsigned int depth)
+{
+ const struct s32cc_fixed_div *fdiv = s32cc_obj2fixeddiv(module);
+ unsigned long pfreq;
+ int ret;
+
+ ret = get_module_rate(fdiv->parent, drv, &pfreq, depth);
+ if (ret != 0) {
+ return ret;
+ }
+
+ *rate = (pfreq * FP_PRECISION / fdiv->rate_div) / FP_PRECISION;
+ return 0;
+}
+
static int set_mux_freq(const struct s32cc_clk_obj *module, unsigned long rate,
unsigned long *orate, unsigned int *depth)
{
@@ -1564,6 +1581,9 @@
case s32cc_dfs_div_t:
ret = get_dfs_div_freq(module, drv, rate, ldepth);
break;
+ case s32cc_fixed_div_t:
+ ret = get_fixed_div_freq(module, drv, rate, ldepth);
+ break;
default:
ret = -EINVAL;
break;