[PATCH v2 3/3] clk: mediatek: fix parent rate lookup for fixed PLL clocks

Weijie Gao weijie.gao at mediatek.com
Thu Apr 16 10:23:10 CEST 2026


From: Sam Shih <sam.shih at mediatek.com>

The refactoring in commit 00d0ff7f81bf ("clk: mediatek: refactor parent
rate lookup functions") introduced a regression where fixed PLL clocks
using mtk_clk_fixed_pll_ops are not properly recognized as valid parents
in the CLK_PARENT_APMIXED case.

Fixed PLL clocks are implemented using mtk_clk_fixed_pll_ops instead of
mtk_clk_apmixedsys_ops, but they can also serve as parent clocks in the
APMIXED domain. The parent lookup function needs to check for both
driver ops to properly resolve the parent clock device.

Add mtk_clk_fixed_pll_ops checks alongside mtk_clk_apmixedsys_ops checks
in mtk_find_parent_rate() to restore support for fixed PLL parent clocks.

Also refactor the grandparent lookup code to extract the repeated
dev_get_parent(priv->parent) call into a local variable to keep lines
under 100 characters and pass checkpatch validation.

Fixes: 00d0ff7f81bf ("clk: mediatek: refactor parent rate lookup functions")
Signed-off-by: Sam Shih <sam.shih at mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
---
 drivers/clk/mediatek/clk-mtk.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index f974f0f2432..d209bc5eb47 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -212,14 +212,17 @@ static ulong mtk_find_parent_rate(struct mtk_clk_priv *priv, struct clk *clk,
 	switch (flags & CLK_PARENT_MASK) {
 	case CLK_PARENT_APMIXED:
 		/* APMIXEDSYS can be parent or grandparent. */
-		if (dev_get_driver_ops(clk->dev) == &mtk_clk_apmixedsys_ops)
+		if (dev_get_driver_ops(clk->dev) == &mtk_clk_apmixedsys_ops ||
+		    dev_get_driver_ops(clk->dev) == &mtk_clk_fixed_pll_ops) {
 			parent_dev = clk->dev;
-		else if (dev_get_driver_ops(priv->parent) == &mtk_clk_apmixedsys_ops)
+		} else if (dev_get_driver_ops(priv->parent) == &mtk_clk_apmixedsys_ops ||
+			dev_get_driver_ops(priv->parent) == &mtk_clk_fixed_pll_ops) {
 			parent_dev = priv->parent;
-		else {
+		} else {
 			struct udevice *grandparent_dev = dev_get_parent(priv->parent);
 
-			if (dev_get_driver_ops(grandparent_dev) == &mtk_clk_apmixedsys_ops)
+			if (dev_get_driver_ops(grandparent_dev) == &mtk_clk_apmixedsys_ops ||
+			    dev_get_driver_ops(grandparent_dev) == &mtk_clk_fixed_pll_ops)
 				parent_dev = grandparent_dev;
 			else
 				return -EINVAL;
-- 
2.45.2



More information about the U-Boot mailing list