Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver
@ 2025-12-19  1:28 Inochi Amaoto
  2025-12-19  1:28 ` [PATCH v4 1/2] clk: spacemit: Respect Kconfig setting when building modules Inochi Amaoto
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Inochi Amaoto @ 2025-12-19  1:28 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Yixun Lan, Haylen Chu,
	Alex Elder, Inochi Amaoto, Troy Mitchell, Charles Mirabile,
	Brian Masney, Akhilesh Patil
  Cc: linux-kernel, linux-clk, linux-riscv, spacemit, Longbin Li

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.

Link: https://lore.kernel.org/all/20251217001833-GYE1903981@gentoo.org

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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/2] clk: spacemit: Respect Kconfig setting when building modules
  2025-12-19  1:28 [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Inochi Amaoto
@ 2025-12-19  1:28 ` Inochi Amaoto
  2025-12-19  1:28 ` [PATCH v4 2/2] clk: spacemit: Hide common clock driver from user controller Inochi Amaoto
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Inochi Amaoto @ 2025-12-19  1:28 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Yixun Lan, Haylen Chu,
	Alex Elder, Inochi Amaoto, Troy Mitchell, Charles Mirabile,
	Brian Masney, Akhilesh Patil
  Cc: linux-kernel, linux-clk, linux-riscv, spacemit, Longbin Li

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")
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
 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

diff --git a/drivers/clk/spacemit/Makefile b/drivers/clk/spacemit/Makefile
index 5ec6da61db98..ad2bf315109b 100644
--- a/drivers/clk/spacemit/Makefile
+++ b/drivers/clk/spacemit/Makefile
@@ -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
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
index 4761bc1e3b6e..01d9485b615d 100644
--- a/drivers/clk/spacemit/ccu-k1.c
+++ b/drivers/clk/spacemit/ccu-k1.c
@@ -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 <heylenay@4d2.org>");
 MODULE_LICENSE("GPL");
diff --git a/drivers/clk/spacemit/ccu_common.c b/drivers/clk/spacemit/ccu_common.c
new file mode 100644
index 000000000000..4412c4104dab
--- /dev/null
+++ b/drivers/clk/spacemit/ccu_common.c
@@ -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");
diff --git a/drivers/clk/spacemit/ccu_ddn.c b/drivers/clk/spacemit/ccu_ddn.c
index 5b16e273bee5..b5540e0781ff 100644
--- a/drivers/clk/spacemit/ccu_ddn.c
+++ b/drivers/clk/spacemit/ccu_ddn.c
@@ -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");
diff --git a/drivers/clk/spacemit/ccu_mix.c b/drivers/clk/spacemit/ccu_mix.c
index 7b7990875372..67f8b12b4f5b 100644
--- a/drivers/clk/spacemit/ccu_mix.c
+++ b/drivers/clk/spacemit/ccu_mix.c
@@ -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");
diff --git a/drivers/clk/spacemit/ccu_pll.c b/drivers/clk/spacemit/ccu_pll.c
index d92f0dae65a4..76d0244873d8 100644
--- a/drivers/clk/spacemit/ccu_pll.c
+++ b/drivers/clk/spacemit/ccu_pll.c
@@ -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");
-- 
2.52.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 2/2] clk: spacemit: Hide common clock driver from user controller
  2025-12-19  1:28 [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Inochi Amaoto
  2025-12-19  1:28 ` [PATCH v4 1/2] clk: spacemit: Respect Kconfig setting when building modules Inochi Amaoto
@ 2025-12-19  1:28 ` Inochi Amaoto
  2025-12-19  9:53 ` [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Yixun Lan
  2025-12-25  2:22 ` Yixun Lan
  3 siblings, 0 replies; 5+ messages in thread
From: Inochi Amaoto @ 2025-12-19  1:28 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Yixun Lan, Haylen Chu,
	Alex Elder, Inochi Amaoto, Troy Mitchell, Charles Mirabile,
	Brian Masney, Akhilesh Patil
  Cc: linux-kernel, linux-clk, linux-riscv, spacemit, Longbin Li

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.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
 drivers/clk/spacemit/Kconfig | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/spacemit/Kconfig b/drivers/clk/spacemit/Kconfig
index 3854f6ae6d0e..3351e8bc801d 100644
--- a/drivers/clk/spacemit/Kconfig
+++ b/drivers/clk/spacemit/Kconfig
@@ -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
-- 
2.52.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver
  2025-12-19  1:28 [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Inochi Amaoto
  2025-12-19  1:28 ` [PATCH v4 1/2] clk: spacemit: Respect Kconfig setting when building modules Inochi Amaoto
  2025-12-19  1:28 ` [PATCH v4 2/2] clk: spacemit: Hide common clock driver from user controller Inochi Amaoto
@ 2025-12-19  9:53 ` Yixun Lan
  2025-12-25  2:22 ` Yixun Lan
  3 siblings, 0 replies; 5+ messages in thread
From: Yixun Lan @ 2025-12-19  9:53 UTC (permalink / raw)
  To: Inochi Amaoto
  Cc: Michael Turquette, Stephen Boyd, Haylen Chu, Alex Elder,
	Troy Mitchell, Charles Mirabile, Brian Masney, Akhilesh Patil,
	linux-kernel, linux-clk, linux-riscv, spacemit, Longbin Li

Hi Inochi, 

On 09:28 Fri 19 Dec     , Inochi Amaoto wrote:
> 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.
> 
> Link: https://lore.kernel.org/all/20251217001833-GYE1903981@gentoo.org
> 
this series looks good to me, so

Reviewed-by: Yixun Lan <dlan@gentoo.org>

-- 
Yixun Lan (dlan)

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver
  2025-12-19  1:28 [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Inochi Amaoto
                   ` (2 preceding siblings ...)
  2025-12-19  9:53 ` [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Yixun Lan
@ 2025-12-25  2:22 ` Yixun Lan
  3 siblings, 0 replies; 5+ messages in thread
From: Yixun Lan @ 2025-12-25  2:22 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Haylen Chu, Alex Elder,
	Troy Mitchell, Charles Mirabile, Brian Masney, Akhilesh Patil,
	Inochi Amaoto
  Cc: Yixun Lan, linux-kernel, linux-clk, linux-riscv, spacemit,
	Longbin Li


On Fri, 19 Dec 2025 09:28:16 +0800, Inochi Amaoto wrote:
> 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,
-- 
Yixun Lan


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-25  2:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-19  1:28 [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Inochi Amaoto
2025-12-19  1:28 ` [PATCH v4 1/2] clk: spacemit: Respect Kconfig setting when building modules Inochi Amaoto
2025-12-19  1:28 ` [PATCH v4 2/2] clk: spacemit: Hide common clock driver from user controller Inochi Amaoto
2025-12-19  9:53 ` [PATCH v4 0/2] clk: spacemit: Fix module build for spacemit common ccu driver Yixun Lan
2025-12-25  2:22 ` Yixun Lan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox