[PATCH] drivers: clk: mtk: Decouple MediaTek clock drivers from SoC

Alicja Michalska alicja.michalska at 9elements.com
Sun Jun 8 03:07:58 CEST 2025


As a part of ongoing coreboot/U-Boot payload work on modern ARM64
Chromebooks, we need to decouple MediaTek's clock driver from depending
on SoC targets.

This patch essentially mimicks behaviour of Qualcomm clock drivers in
U-Boot, allowing us to pick them independently if we're building for
coreboot target.

Choosing CONFIG_TARGET_$SOC will still automatically enable the clock
driver for desired target, avoiding breakage.

Signed-off-by: Alicja Michalska <alicja.michalska at 9elements.com>
---
 drivers/clk/Kconfig           |   1 +
 drivers/clk/Makefile          |   2 +-
 drivers/clk/mediatek/Kconfig  | 127 ++++++++++++++++++++++++++++++++++
 drivers/clk/mediatek/Makefile |  27 ++++----
 4 files changed, 143 insertions(+), 14 deletions(-)
 create mode 100644 drivers/clk/mediatek/Kconfig

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 19aa2ffa539..f8f82fc9f3f 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -260,6 +260,7 @@ source "drivers/clk/exynos/Kconfig"
 source "drivers/clk/imx/Kconfig"
 source "drivers/clk/meson/Kconfig"
 source "drivers/clk/microchip/Kconfig"
+source "drivers/clk/mediatek/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/owl/Kconfig"
 source "drivers/clk/qcom/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 5f0c0d8a5c2..da58381b247 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -23,7 +23,7 @@ obj-y += ti/
 obj-$(CONFIG_CLK_THEAD) += thead/
 obj-$(CONFIG_$(PHASE_)CLK_INTEL) += intel/
 obj-$(CONFIG_ARCH_ASPEED) += aspeed/
-obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
+obj-$(CONFIG_CLK_MEDIATEK) += mediatek/
 obj-$(CONFIG_ARCH_MESON) += meson/
 obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
 obj-$(CONFIG_ARCH_NPCM) += nuvoton/
diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
new file mode 100644
index 00000000000..9c34a000d0e
--- /dev/null
+++ b/drivers/clk/mediatek/Kconfig
@@ -0,0 +1,127 @@
+if ARCH_MEDIATEK || ARCH_COREBOOT
+
+config CLK_MTK
+	bool
+	depends on CLK && DM_RESET && POWER_DOMAIN
+	def_bool n
+
+menu "MediaTek clock drivers"
+
+config CLK_MTK_MT7623
+	bool "MediaTek MT7623 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7623
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7623 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config MT7622
+	bool "MediaTek MT7622 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7622
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7622 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT7629
+	bool "MediaTek MT7629 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7629
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7629 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT7986
+	bool "MediaTek MT7986 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7986
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7986 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT7981
+	bool "MediaTek MT7981 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7981
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7981 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT7988
+	bool "MediaTek MT7988 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7988
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7988 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT7987
+	bool "MediaTek MT7987 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT7987
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT7987 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT8183
+	bool "MediaTek MT8183 GCC"
+	default y if CONFIG_TARGET_MT8183 || ARCH_COREBOOT
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT8183 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT8186
+	bool "MediaTek MT8186 GCC"
+	select CLK_MTK
+	default y if ARCH_COREBOOT
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT8186 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT8365
+	bool "MediaTek MT8365 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT8365
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT8365 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT8512
+	bool "MediaTek MT8512 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT8512
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT8512 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT8516
+	bool "MediaTek MT8516 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT8516
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT8516 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+config CLK_MTK_MT8518
+	bool "MediaTek MT8518 GCC"
+	select CLK_MTK
+	default y if CONFIG_TARGET_MT8518
+	help
+	Say Y here to enable support for the Global Clock Controller
+	on the MediaTek MT8518 SoC. This driver supports the clocks
+	and resets exposed by the GCC hardware block.
+
+endmenu
+endif
diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index 12893687b68..4abe09a2452 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -1,17 +1,18 @@
 # SPDX-License-Identifier: GPL-2.0
 # Core
-obj-$(CONFIG_ARCH_MEDIATEK) += clk-mtk.o
+obj-y += clk-mtk.o
 
 # SoC Drivers
-obj-$(CONFIG_TARGET_MT7623) += clk-mt7623.o
-obj-$(CONFIG_TARGET_MT7622) += clk-mt7622.o
-obj-$(CONFIG_TARGET_MT7629) += clk-mt7629.o
-obj-$(CONFIG_TARGET_MT7986) += clk-mt7986.o
-obj-$(CONFIG_TARGET_MT7981) += clk-mt7981.o
-obj-$(CONFIG_TARGET_MT7988) += clk-mt7988.o
-obj-$(CONFIG_TARGET_MT7987) += clk-mt7987.o
-obj-$(CONFIG_TARGET_MT8183) += clk-mt8183.o
-obj-$(CONFIG_TARGET_MT8365) += clk-mt8365.o
-obj-$(CONFIG_TARGET_MT8512) += clk-mt8512.o
-obj-$(CONFIG_TARGET_MT8516) += clk-mt8516.o
-obj-$(CONFIG_TARGET_MT8518) += clk-mt8518.o
+obj-$(CONFIG_CLK_MTK_MT7623) += clk-mt7623.o
+obj-$(CONFIG_CLK_MTK_MT7622) += clk-mt7622.o
+obj-$(CONFIG_CLK_MTK_MT7629) += clk-mt7629.o
+obj-$(CONFIG_CLK_MTK_MT7986) += clk-mt7986.o
+obj-$(CONFIG_CLK_MTK_MT7981) += clk-mt7981.o
+obj-$(CONFIG_CLK_MTK_MT7988) += clk-mt7988.o
+obj-$(CONFIG_CLK_MTK_MT7987) += clk-mt7987.o
+obj-$(CONFIG_CLK_MTK_MT8183) += clk-mt8183.o
+obj-$(CONFIG_CLK_MTK_MT8186) += clk-mt8186.o
+obj-$(CONFIG_CLK_MTK_MT8365) += clk-mt8365.o
+obj-$(CONFIG_CLK_MTK_MT8512) += clk-mt8512.o
+obj-$(CONFIG_CLK_MTK_MT8516) += clk-mt8516.o
+obj-$(CONFIG_CLK_MTK_MT8518) += clk-mt8518.o
-- 
2.49.0



More information about the U-Boot mailing list