[PATCH 0/9] clk: mediatek: deduplicate clock gate drivers

Julien Stephan jstephan at baylibre.com
Fri Jul 10 16:12:51 CEST 2026


Several MediaTek SoCs expose multiple clock gate controller instances.
In U-Boot, each instance currently requires its own U_BOOT_DRIVER,
mtk_clk_tree, probe() function and compatible table, even though they
all share the same implementation. This results in a significant
amount of duplicated code, and the duplication grows every time a new
clock gate controller is added (for example the ones needed for
upcoming HDMI support on MT8188).

MT8189 already avoids this by using a single generic U_BOOT_DRIVER
shared across all clock gate controller compatibles, with the
SoC-specific gate tables provided through driver data.

This series generalizes that approach. The first patch introduces
struct mtk_gate_clk_data and the MTK_GATE_CLK_DATA() helper in
clk-mtk.h, the second one converts MT8189 to it as the first user, and
the remaining patches convert every SoC that declares more than one
clock gate driver: MT8188, MT7622, MT7623, MT7629, MT7981, MT7988 and
MT8512.

Drivers are only merged when they share the same DM flags and bind()
callback, so device lifecycle (pre-relocation binding/probing, reset
controller binding) is preserved. Controllers that bind a reset
controller keep a dedicated U_BOOT_DRIVER but still share the generic
probe() function.

SoCs with a single clock gate controller (MT7986, MT7987, MT8183,
MT8195, MT8365, MT8516, MT8518) are left untouched since there is no
duplication to remove there.

All conversions are intended to be non-functional changes, with one
exception called out in its commit message: on MT7629 the conversion
fixes an off-by-one in the infracfg gate lookup, whose clock IDs start
at 1 while the driver used a gate offset of 0.

Build-tested using the following command:
./tools/buildman/buildman -b b4/b4-mtk-clk-cleanup-clock-gate-drivers -c 10 -x mips mt7622 mt7623 mt7629 mt7981 mt7986 mt7987 mt7988 mt8183 mt8195 mt8365 mt8512 mt8516 mt8518

Tested on genio-700: clk dump before and after is equivalent (other than
the driver name)

Signed-off-by: Julien Stephan <jstephan at baylibre.com>
---
Julien Stephan (9):
      clk: mediatek: introduce mtk_gate_clk_data
      clk: mediatek: mt8189: convert to mtk_gate_clk_data
      clk: mediatek: mt8188: convert to mtk_gate_clk_data
      clk: mediatek: mt7622: convert to mtk_gate_clk_data
      clk: mediatek: mt7623: convert to mtk_gate_clk_data
      clk: mediatek: mt7629: convert to mtk_gate_clk_data
      clk: mediatek: mt7981: convert to mtk_gate_clk_data
      clk: mediatek: mt7988: convert to mtk_gate_clk_data
      clk: mediatek: mt8512: convert to mtk_gate_clk_data

 drivers/clk/mediatek/clk-mt7622.c | 113 +++++++++-----------------
 drivers/clk/mediatek/clk-mt7623.c |  67 +++++++---------
 drivers/clk/mediatek/clk-mt7629.c | 109 ++++++++++----------------
 drivers/clk/mediatek/clk-mt7981.c |  66 +++++++---------
 drivers/clk/mediatek/clk-mt7988.c |  74 +++++++-----------
 drivers/clk/mediatek/clk-mt8188.c | 161 ++++++++++----------------------------
 drivers/clk/mediatek/clk-mt8189.c |  26 ++----
 drivers/clk/mediatek/clk-mt8512.c |  52 ++++++------
 drivers/clk/mediatek/clk-mtk.h    |  11 +++
 9 files changed, 252 insertions(+), 427 deletions(-)
---
base-commit: b5fca5f601e5da4955a3ab815f614e1a1300ec2b
change-id: 20260710-b4-mtk-clk-cleanup-clock-gate-drivers-0b211852ad81

Best regards,
--  
Julien Stephan <jstephan at baylibre.com>



More information about the U-Boot mailing list