summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Stephan <[email protected]>2026-07-15 16:28:42 +0200
committerDavid Lechner <[email protected]>2026-07-29 10:10:04 -0500
commit7cac2672755b230f9bf1dfcac4f20033a7fd5a9d (patch)
treecae13d147c985490bb5e0d1454ee3e8ca138574b
parent6644d823acea9752f7a64963a14f94de9429e803 (diff)
clk: mediatek: mt7987: use driver data to store the clock tree
Pass each controller's struct mtk_clk_tree through the driver data and use the generic probe function for the MT7987 clock drivers, instead of a dedicated probe per controller. The fixed-pll, topckgen and infracfg controllers keep their own U_BOOT_DRIVER since they rely on dedicated ops and on the parent bind() callback, but they now get their tree from the compatible data. The topckgen probe still performs its SoC specific register tweaks. No functional change intended. Signed-off-by: Julien Stephan <[email protected]> Link: https://patch.msgid.link/20260715-b4-mtk-clk-cleanup-clock-gate-drivers-v2-14-23e907516010@baylibre.com Signed-off-by: David Lechner <[email protected]>
-rw-r--r--drivers/clk/mediatek/clk-mt7987.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/clk/mediatek/clk-mt7987.c b/drivers/clk/mediatek/clk-mt7987.c
index 55e57a90775..25faad9edc6 100644
--- a/drivers/clk/mediatek/clk-mt7987.c
+++ b/drivers/clk/mediatek/clk-mt7987.c
@@ -71,22 +71,23 @@ static const struct mtk_clk_tree mt7987_fixed_pll_clk_tree = {
};
static const struct udevice_id mt7987_fixed_pll_compat[] = {
- { .compatible = "mediatek,mt7987-fixed-plls" },
- { .compatible = "mediatek,mt7987-apmixedsys" },
+ {
+ .compatible = "mediatek,mt7987-fixed-plls",
+ .data = (ulong)&mt7987_fixed_pll_clk_tree,
+ },
+ {
+ .compatible = "mediatek,mt7987-apmixedsys",
+ .data = (ulong)&mt7987_fixed_pll_clk_tree,
+ },
{}
};
-static int mt7987_fixed_pll_probe(struct udevice *dev)
-{
- return mtk_common_clk_init(dev, &mt7987_fixed_pll_clk_tree);
-}
-
U_BOOT_DRIVER(mt7987_clk_apmixedsys) = {
.name = "mt7987-clock-fixed-pll",
.id = UCLASS_CLK,
.of_match = mt7987_fixed_pll_compat,
.bind = mtk_common_clk_parent_bind,
- .probe = mt7987_fixed_pll_probe,
+ .probe = mt7987_clk_probe,
.priv_auto = sizeof(struct mtk_clk_priv),
.ops = &mtk_clk_fixed_pll_ops,
.flags = DM_FLAG_PRE_RELOC,
@@ -470,20 +471,24 @@ static const struct mtk_clk_tree mt7987_topckgen_clk_tree = {
};
static const struct udevice_id mt7987_topckgen_compat[] = {
- { .compatible = "mediatek,mt7987-topckgen" },
+ {
+ .compatible = "mediatek,mt7987-topckgen",
+ .data = (ulong)&mt7987_topckgen_clk_tree,
+ },
{}
};
static int mt7987_topckgen_probe(struct udevice *dev)
{
struct mtk_clk_priv *priv = dev_get_priv(dev);
+ const struct mtk_clk_tree *tree = (void *)dev_get_driver_data(dev);
priv->base = dev_read_addr_ptr(dev);
if (!priv->base)
return -ENOENT;
writel(MT7987_CLK_PDN_EN_WRITE, priv->base + MT7987_CLK_PDN);
- return mtk_common_clk_init(dev, &mt7987_topckgen_clk_tree);
+ return mtk_common_clk_init(dev, tree);
}
U_BOOT_DRIVER(mt7987_clk_topckgen) = {
@@ -798,22 +803,23 @@ static const struct mtk_clk_tree mt7987_infracfg_clk_tree = {
};
static const struct udevice_id mt7987_infracfg_compat[] = {
- { .compatible = "mediatek,mt7987-infracfg_ao" },
- { .compatible = "mediatek,mt7987-infracfg" },
+ {
+ .compatible = "mediatek,mt7987-infracfg_ao",
+ .data = (ulong)&mt7987_infracfg_clk_tree,
+ },
+ {
+ .compatible = "mediatek,mt7987-infracfg",
+ .data = (ulong)&mt7987_infracfg_clk_tree,
+ },
{}
};
-static int mt7987_infracfg_probe(struct udevice *dev)
-{
- return mtk_common_clk_init(dev, &mt7987_infracfg_clk_tree);
-}
-
U_BOOT_DRIVER(mt7987_clk_infracfg) = {
.name = "mt7987-clock-infracfg",
.id = UCLASS_CLK,
.of_match = mt7987_infracfg_compat,
.bind = mtk_common_clk_parent_bind,
- .probe = mt7987_infracfg_probe,
+ .probe = mt7987_clk_probe,
.priv_auto = sizeof(struct mtk_clk_priv),
.ops = &mtk_clk_infrasys_ops,
.flags = DM_FLAG_PRE_RELOC,