Skip to contentSkip to conversation

clk: spacemit: Fix module build for spacemit common ccu driver

PATCH Applied Inochi Amaoto 2 participants 5 messages Dec 19, 2025 – Dec 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover clk: spacemit: Fix module build for spacemit common ccu driver

Currently, the SPACEMIT_CCU entry is only a switch for enabling entry SPACEMIT_K1_CCU. It does not guide the build for common clock codes even if it is a tristate entry. This makes this entry useless.

Change the Makefile to add a separate build for common clock logic, so the SPACEMIT_CCU entry takes effect, also add necessary MODULE_LICENSE()/MODULE_DESCRIPTION()/EXPORT_SYMBOL() for the module build.

This patch mostly fix the build problem, and it should serve as a basic for the incoming K3 clock driver. See link.

Change from v3:
1. patch 1: change Makefile to trigger module build actually
2. patch 2: new patch for remove internal Kconfig entry

Change from v2:
1. change namespace name to CLK_SPACEMIT

Change from v1:
1. Use EXPORT_SYMBOL_NS_GPL to export clock ops

Inochi Amaoto (2):
clk: spacemit: Respect Kconfig setting when building modules
clk: spacemit: Hide common clock driver from user controller

 drivers/clk/spacemit/Kconfig      | 14 ++++++--------
 drivers/clk/spacemit/Makefile     |  9 +++++++--
 drivers/clk/spacemit/ccu-k1.c     |  1 +
 drivers/clk/spacemit/ccu_common.c |  6 ++++++
 drivers/clk/spacemit/ccu_ddn.c    |  1 +
 drivers/clk/spacemit/ccu_mix.c    |  9 +++++++++
 drivers/clk/spacemit/ccu_pll.c    |  1 +
 7 files changed, 31 insertions(+), 10 deletions(-)
 create mode 100644 drivers/clk/spacemit/ccu_common.c

--
2.52.0

#1 lore raw

PATCH v4 1/2 clk: spacemit: Respect Kconfig setting when building modules

Currently, the SPACEMIT_CCU entry is only a switch for enabling entry SPACEMIT_K1_CCU. It does not guide the build for common clock codes even if it is a tristate entry. This makes this entry useless.

Change the Makefile to add a separate build for common clock logic, so the SPACEMIT_CCU entry takes effect, also add necessary MODULE_LICENSE()/MODULE_DESCRIPTION()/EXPORT_SYMBOL() for the module build.

Fixes 1b72c59db0ad ("clk: spacemit: Add clock support for SpacemiT K1 SoC")
---
 drivers/clk/spacemit/Makefile     | 9 +++++++--
 drivers/clk/spacemit/ccu-k1.c     | 1 +
 drivers/clk/spacemit/ccu_common.c | 6 ++++++
 drivers/clk/spacemit/ccu_ddn.c    | 1 +
 drivers/clk/spacemit/ccu_mix.c    | 9 +++++++++
 drivers/clk/spacemit/ccu_pll.c    | 1 +
 6 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/spacemit/ccu_common.c
drivers/clk/spacemit/Makefile +7 -2
index 5ec6da61db98..ad2bf315109b 100644
@@ -1,5 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_SPACEMIT_K1_CCU)	= spacemit-ccu-k1.o
-spacemit-ccu-k1-y		= ccu_pll.o ccu_mix.o ccu_ddn.o
+obj-$(CONFIG_SPACEMIT_CCU)	+= spacemit-ccu.o
+spacemit-ccu-y			+= ccu_common.o
+spacemit-ccu-y			+= ccu_pll.o
+spacemit-ccu-y			+= ccu_mix.o
+spacemit-ccu-y			+= ccu_ddn.o
+
+obj-$(CONFIG_SPACEMIT_K1_CCU)	+= spacemit-ccu-k1.o
 spacemit-ccu-k1-y		+= ccu-k1.o
drivers/clk/spacemit/ccu-k1.c +1 -0
index 4761bc1e3b6e..01d9485b615d 100644
@@ -1204,6 +1204,7 @@ static struct platform_driver k1_ccu_driver = {
 };
 module_platform_driver(k1_ccu_driver);
 
+MODULE_IMPORT_NS("CLK_SPACEMIT");
 MODULE_DESCRIPTION("SpacemiT K1 CCU driver");
 MODULE_AUTHOR("Haylen Chu <[email protected]>");
 MODULE_LICENSE("GPL");
drivers/clk/spacemit/ccu_common.c new file +6 -0
new file mode 100644
index 000000000000..4412c4104dab
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/module.h>
+
+MODULE_DESCRIPTION("SpacemiT CCU common clock driver");
+MODULE_LICENSE("GPL");
drivers/clk/spacemit/ccu_ddn.c +1 -0
index 5b16e273bee5..b5540e0781ff 100644
@@ -84,3 +84,4 @@ const struct clk_ops spacemit_ccu_ddn_ops = {
 	.determine_rate = ccu_ddn_determine_rate,
 	.set_rate	= ccu_ddn_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_ddn_ops, "CLK_SPACEMIT");
drivers/clk/spacemit/ccu_mix.c +9 -0
index 7b7990875372..67f8b12b4f5b 100644
@@ -198,24 +198,28 @@ const struct clk_ops spacemit_ccu_gate_ops = {
 	.enable		= ccu_gate_enable,
 	.is_enabled	= ccu_gate_is_enabled,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_gate_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_factor_ops = {
 	.determine_rate = ccu_factor_determine_rate,
 	.recalc_rate	= ccu_factor_recalc_rate,
 	.set_rate	= ccu_factor_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_factor_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_mux_ops = {
 	.determine_rate = ccu_mix_determine_rate,
 	.get_parent	= ccu_mux_get_parent,
 	.set_parent	= ccu_mux_set_parent,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_mux_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_div_ops = {
 	.determine_rate = ccu_mix_determine_rate,
 	.recalc_rate	= ccu_div_recalc_rate,
 	.set_rate	= ccu_mix_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_div_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_factor_gate_ops = {
 	.disable	= ccu_gate_disable,
@@ -226,6 +230,7 @@ const struct clk_ops spacemit_ccu_factor_gate_ops = {
 	.recalc_rate	= ccu_factor_recalc_rate,
 	.set_rate	= ccu_factor_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_factor_gate_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_mux_gate_ops = {
 	.disable	= ccu_gate_disable,
@@ -236,6 +241,7 @@ const struct clk_ops spacemit_ccu_mux_gate_ops = {
 	.get_parent	= ccu_mux_get_parent,
 	.set_parent	= ccu_mux_set_parent,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_mux_gate_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_div_gate_ops = {
 	.disable	= ccu_gate_disable,
@@ -246,6 +252,7 @@ const struct clk_ops spacemit_ccu_div_gate_ops = {
 	.recalc_rate	= ccu_div_recalc_rate,
 	.set_rate	= ccu_mix_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_div_gate_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_mux_div_gate_ops = {
 	.disable	= ccu_gate_disable,
@@ -259,6 +266,7 @@ const struct clk_ops spacemit_ccu_mux_div_gate_ops = {
 	.recalc_rate	= ccu_div_recalc_rate,
 	.set_rate	= ccu_mix_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_mux_div_gate_ops, "CLK_SPACEMIT");
 
 const struct clk_ops spacemit_ccu_mux_div_ops = {
 	.get_parent	= ccu_mux_get_parent,
@@ -268,3 +276,4 @@ const struct clk_ops spacemit_ccu_mux_div_ops = {
 	.recalc_rate	= ccu_div_recalc_rate,
 	.set_rate	= ccu_mix_set_rate,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_mux_div_ops, "CLK_SPACEMIT");
drivers/clk/spacemit/ccu_pll.c +1 -0
index d92f0dae65a4..76d0244873d8 100644
@@ -157,3 +157,4 @@ const struct clk_ops spacemit_ccu_pll_ops = {
 	.determine_rate = ccu_pll_determine_rate,
 	.is_enabled	= ccu_pll_is_enabled,
 };
+EXPORT_SYMBOL_NS_GPL(spacemit_ccu_pll_ops, "CLK_SPACEMIT");
Signature · 1 line
2.52.0
#2 lore raw

PATCH v4 2/2 clk: spacemit: Hide common clock driver from user controller

In reply to Inochi Amaoto

Since the common clock driver is only a dependency for other spacemit clock driver, it should not be enabled individually, so hide this in the Kconfig UI and let other spacemit clock driver select it.

---
 drivers/clk/spacemit/Kconfig | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/clk/spacemit/Kconfig +6 -8
index 3854f6ae6d0e..3351e8bc801d 100644
@@ -1,19 +1,17 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+menu "Clock support for SpacemiT platforms"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+
 config SPACEMIT_CCU
-	tristate "Clock support for SpacemiT SoCs"
-	depends on ARCH_SPACEMIT || COMPILE_TEST
+	tristate
 	select AUXILIARY_BUS
 	select MFD_SYSCON
-	help
-	  Say Y to enable clock controller unit support for SpacemiT SoCs.
-
-if SPACEMIT_CCU
 
 config SPACEMIT_K1_CCU
 	tristate "Support for SpacemiT K1 SoC"
-	depends on ARCH_SPACEMIT || COMPILE_TEST
+	select SPACEMIT_CCU
 	help
 	  Support for clock controller unit in SpacemiT K1 SoC.
 
-endif
+endmenu
Signature · 1 line
2.52.0
Reviewed-by on the v4 series
#3 lore raw
In reply to Inochi Amaoto

Hi Inochi,

Quoted 9 lines · Inochi Amaoto

Currently, the SPACEMIT_CCU entry is only a switch for enabling entry SPACEMIT_K1_CCU. It does not guide the build for common clock codes even if it is a tristate entry. This makes this entry useless.

Change the Makefile to add a separate build for common clock logic, so the SPACEMIT_CCU entry takes effect, also add necessary MODULE_LICENSE()/MODULE_DESCRIPTION()/EXPORT_SYMBOL() for the module build.

Quoted 5 lines

This patch mostly fix the build problem, and it should serve as a basic for the incoming K3 clock driver. See link.

this series looks good to me, so

Signature · 1 line
Yixun Lan (dlan)
Applied
#4 lore raw
In reply to Inochi Amaoto
Quoted 10 lines · Inochi Amaoto

Currently, the SPACEMIT_CCU entry is only a switch for enabling entry SPACEMIT_K1_CCU. It does not guide the build for common clock codes even if it is a tristate entry. This makes this entry useless.

Change the Makefile to add a separate build for common clock logic, so the SPACEMIT_CCU entry takes effect, also add necessary MODULE_LICENSE()/MODULE_DESCRIPTION()/EXPORT_SYMBOL() for the module build.

[...]

Applied, thanks!

[1/2] clk: spacemit: Respect Kconfig setting when building modules

      https://github.com/spacemit-com/linux/commit/5ec8cbbc54c82c0bdae4dbf0e5aecf9817bde2b9
[2/2] clk: spacemit: Hide common clock driver from user controller
      https://github.com/spacemit-com/linux/commit/99735a742f7e9a3e7f4cb6c58edf1b38101e7657

Best regards,

Signature · 1 line
Yixun Lan