Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH v3 0/4] clocksource: Add module support for timer drivers
@ 2026-03-04  2:57 Zhipeng Wang
  2026-03-04  2:57 ` [PATCH v3 1/4] clocksource/drivers/mmio: Export clocksource_mmio_init() Zhipeng Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  2:57 UTC (permalink / raw)
  To: daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

This patch series enables clocksource timer drivers to be built as
loadable kernel modules, which is particularly useful for GKI
(Generic Kernel Image) configurations.

This series is based on the previous MediaTek timer modularization work:
Link: https://lore.kernel.org/all/20230517022557.24388-1-walter.chang@mediatek.com/

The series includes:
1. Export necessary functions from clocksource/mmio
2. Remove __init markings from timer-of to support modules
3. Convert MediaTek timer driver to support module build
4. Convert i.MX TPM timer driver to support module build

Testing performed:
- Built and tested on i.MX8ULP platform
- Built and tested on MediaTek platform
- Verified both built-in and module configurations
- Confirmed timer functionality in both configurations

Changes in v3:
- Reworded summary line for timer-mediatek driver as suggested.
- Improved commit message formatting (line wrapping).
- No functional changes to the code.

Changes in v2:
- Added Signed-off-by from submitter (Zhipeng Wang) to all patches
  as requested by reviewers

Changes in v1:
- Fixed 'unsigned' to 'unsigned int' in clocksource_mmio_init()
- Changed MODULE_LICENSE from "GPL v2" to "GPL" for mediatek driver
- Added i.MX TPM timer driver module support

Chun-Hung Wu (3):
  clocksource/drivers/mmio: Export clocksource_mmio_init()
  clocksource/drivers/timer-of: Remove __init markings
  clocksource/drivers/timer-mediatek: Convert timer-mediatek to a
    loadable module

Jindong Yue (1):
  clocksource/drivers/imx-tpm: Support building imx-tpm driver as module

 drivers/clocksource/Kconfig          |  4 ++--
 drivers/clocksource/mmio.c           |  8 ++++---
 drivers/clocksource/timer-imx-tpm.c  | 36 +++++++++++++++++++++++++---
 drivers/clocksource/timer-mediatek.c | 33 +++++++++++++++++++++++++
 drivers/clocksource/timer-of.c       | 23 +++++++++---------
 drivers/clocksource/timer-of.h       |  6 ++---
 6 files changed, 88 insertions(+), 22 deletions(-)

-- 
2.34.1


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

* [PATCH v3 1/4] clocksource/drivers/mmio: Export clocksource_mmio_init()
  2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
@ 2026-03-04  2:57 ` Zhipeng Wang
  2026-03-04  2:57 ` [PATCH v3 2/4] clocksource/drivers/timer-of: Remove __init markings Zhipeng Wang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  2:57 UTC (permalink / raw)
  To: daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

From: Chun-Hung Wu <chun-hung.wu@mediatek.com>

Export clocksource_mmio_init() and clocksource_mmio_readl_up()
to support building clocksource driver as module,
such as timer-mediatek.c.

Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Signed-off-by: Walter Chang <walter.chang@mediatek.com>
Acked-by: John Stultz <jstultz@google.com>
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
 drivers/clocksource/mmio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
index cd5fbf49ac29..238bf29db6f7 100644
--- a/drivers/clocksource/mmio.c
+++ b/drivers/clocksource/mmio.c
@@ -21,6 +21,7 @@ u64 clocksource_mmio_readl_up(struct clocksource *c)
 {
 	return (u64)readl_relaxed(to_mmio_clksrc(c)->reg);
 }
+EXPORT_SYMBOL_GPL(clocksource_mmio_readl_up);
 
 u64 clocksource_mmio_readl_down(struct clocksource *c)
 {
@@ -46,9 +47,9 @@ u64 clocksource_mmio_readw_down(struct clocksource *c)
  * @bits:	Number of valid bits
  * @read:	One of clocksource_mmio_read*() above
  */
-int __init clocksource_mmio_init(void __iomem *base, const char *name,
-	unsigned long hz, int rating, unsigned bits,
-	u64 (*read)(struct clocksource *))
+int clocksource_mmio_init(void __iomem *base, const char *name,
+			  unsigned long hz, int rating, unsigned int bits,
+			  u64 (*read)(struct clocksource *))
 {
 	struct clocksource_mmio *cs;
 
@@ -68,3 +69,4 @@ int __init clocksource_mmio_init(void __iomem *base, const char *name,
 
 	return clocksource_register_hz(&cs->clksrc, hz);
 }
+EXPORT_SYMBOL_GPL(clocksource_mmio_init);
-- 
2.34.1


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

* [PATCH v3 2/4] clocksource/drivers/timer-of: Remove __init markings
  2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
  2026-03-04  2:57 ` [PATCH v3 1/4] clocksource/drivers/mmio: Export clocksource_mmio_init() Zhipeng Wang
@ 2026-03-04  2:57 ` Zhipeng Wang
  2026-03-04  2:57 ` [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module Zhipeng Wang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  2:57 UTC (permalink / raw)
  To: daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

From: Chun-Hung Wu <chun-hung.wu@mediatek.com>

Remove __init markings to allow timer drivers
can be compiled as modules.

Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Signed-off-by: Walter Chang <walter.chang@mediatek.com>
Acked-by: John Stultz <jstultz@google.com>
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
 drivers/clocksource/timer-of.c | 23 ++++++++++++-----------
 drivers/clocksource/timer-of.h |  6 +++---
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index 420202bf76e4..b7c186dc83da 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -19,7 +19,7 @@
  *
  * Free the irq resource
  */
-static __init void timer_of_irq_exit(struct of_timer_irq *of_irq)
+static void timer_of_irq_exit(struct of_timer_irq *of_irq)
 {
 	struct timer_of *to = container_of(of_irq, struct timer_of, of_irq);
 
@@ -41,8 +41,8 @@ static __init void timer_of_irq_exit(struct of_timer_irq *of_irq)
  *
  * Returns 0 on success, < 0 otherwise
  */
-static __init int timer_of_irq_init(struct device_node *np,
-				    struct of_timer_irq *of_irq)
+static int timer_of_irq_init(struct device_node *np,
+			     struct of_timer_irq *of_irq)
 {
 	int ret;
 	struct timer_of *to = container_of(of_irq, struct timer_of, of_irq);
@@ -82,7 +82,7 @@ static __init int timer_of_irq_init(struct device_node *np,
  *
  * Disables and releases the refcount on the clk
  */
-static __init void timer_of_clk_exit(struct of_timer_clk *of_clk)
+static void timer_of_clk_exit(struct of_timer_clk *of_clk)
 {
 	of_clk->rate = 0;
 	clk_disable_unprepare(of_clk->clk);
@@ -98,8 +98,8 @@ static __init void timer_of_clk_exit(struct of_timer_clk *of_clk)
  *
  * Returns 0 on success, < 0 otherwise
  */
-static __init int timer_of_clk_init(struct device_node *np,
-				    struct of_timer_clk *of_clk)
+static int timer_of_clk_init(struct device_node *np,
+			     struct of_timer_clk *of_clk)
 {
 	int ret;
 
@@ -137,13 +137,13 @@ static __init int timer_of_clk_init(struct device_node *np,
 	goto out;
 }
 
-static __init void timer_of_base_exit(struct of_timer_base *of_base)
+static void timer_of_base_exit(struct of_timer_base *of_base)
 {
 	iounmap(of_base->base);
 }
 
-static __init int timer_of_base_init(struct device_node *np,
-				     struct of_timer_base *of_base)
+static int timer_of_base_init(struct device_node *np,
+			      struct of_timer_base *of_base)
 {
 	of_base->base = of_base->name ?
 		of_io_request_and_map(np, of_base->index, of_base->name) :
@@ -156,7 +156,7 @@ static __init int timer_of_base_init(struct device_node *np,
 	return 0;
 }
 
-int __init timer_of_init(struct device_node *np, struct timer_of *to)
+int timer_of_init(struct device_node *np, struct timer_of *to)
 {
 	int ret = -EINVAL;
 	int flags = 0;
@@ -200,6 +200,7 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
 		timer_of_base_exit(&to->of_base);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(timer_of_init);
 
 /**
  * timer_of_cleanup - release timer_of resources
@@ -208,7 +209,7 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
  * Release the resources that has been used in timer_of_init().
  * This function should be called in init error cases
  */
-void __init timer_of_cleanup(struct timer_of *to)
+void timer_of_cleanup(struct timer_of *to)
 {
 	if (to->flags & TIMER_OF_IRQ)
 		timer_of_irq_exit(&to->of_irq);
diff --git a/drivers/clocksource/timer-of.h b/drivers/clocksource/timer-of.h
index 01a2c6b7db06..367d7023c623 100644
--- a/drivers/clocksource/timer-of.h
+++ b/drivers/clocksource/timer-of.h
@@ -65,9 +65,9 @@ static inline unsigned long timer_of_period(struct timer_of *to)
 	return to->of_clk.period;
 }
 
-extern int __init timer_of_init(struct device_node *np,
-				struct timer_of *to);
+extern int timer_of_init(struct device_node *np,
+			 struct timer_of *to);
 
-extern void __init timer_of_cleanup(struct timer_of *to);
+extern void timer_of_cleanup(struct timer_of *to);
 
 #endif
-- 
2.34.1


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

* [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module
  2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
  2026-03-04  2:57 ` [PATCH v3 1/4] clocksource/drivers/mmio: Export clocksource_mmio_init() Zhipeng Wang
  2026-03-04  2:57 ` [PATCH v3 2/4] clocksource/drivers/timer-of: Remove __init markings Zhipeng Wang
@ 2026-03-04  2:57 ` Zhipeng Wang
  2026-03-04  5:41   ` Trilok Soni
  2026-03-04  2:57 ` [PATCH v3 4/4] clocksource/drivers/imx-tpm: Support building imx-tpm driver as module Zhipeng Wang
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  2:57 UTC (permalink / raw)
  To: daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

From: Chun-Hung Wu <chun-hung.wu@mediatek.com>

Convert the timer-mediatek driver into a loadable module so that
it can register an always-on timer as the tick_broadcast_device on
MediaTek SoCs. This helps support GKI modular configurations.

Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Signed-off-by: Walter Chang <walter.chang@mediatek.com>
Tested-by: Walter Chang <walter.chang@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
 drivers/clocksource/Kconfig          |  2 +-
 drivers/clocksource/timer-mediatek.c | 33 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index fd9112706545..2112efb85029 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -488,7 +488,7 @@ config SYS_SUPPORTS_SH_CMT
 	bool
 
 config MTK_TIMER
-	bool "Mediatek timer driver" if COMPILE_TEST
+	tristate "MediaTek timer driver"
 	depends on HAS_IOMEM
 	select TIMER_OF
 	select CLKSRC_MMIO
diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index 7bcb4a3f26fb..4ad4bac6f34b 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -13,6 +13,9 @@
 #include <linux/clocksource.h>
 #include <linux/interrupt.h>
 #include <linux/irqreturn.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
 #include <linux/sched_clock.h>
 #include <linux/slab.h>
 #include "timer-of.h"
@@ -337,5 +340,35 @@ static int __init mtk_gpt_init(struct device_node *node)
 
 	return 0;
 }
+
+#ifndef MODULE
 TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
 TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
+#else
+static int mtk_timer_probe(struct platform_device *pdev)
+{
+	int (*timer_init)(struct device_node *node);
+	struct device_node *np = pdev->dev.of_node;
+
+	timer_init = of_device_get_match_data(&pdev->dev);
+	return timer_init(np);
+}
+
+static const struct of_device_id mtk_timer_match_table[] = {
+	{ .compatible = "mediatek,mt6577-timer", .data = mtk_gpt_init },
+	{ .compatible = "mediatek,mt6765-timer", .data = mtk_syst_init },
+	{ /* sentinel */ }
+};
+
+static struct platform_driver mtk_timer_driver = {
+	.probe = mtk_timer_probe,
+	.driver = {
+		.name = "mediatek-timer",
+		.of_match_table = mtk_timer_match_table,
+	},
+};
+module_platform_driver(mtk_timer_driver);
+
+MODULE_DESCRIPTION("MediaTek Timer driver");
+MODULE_LICENSE("GPL");
+#endif
-- 
2.34.1


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

* [PATCH v3 4/4] clocksource/drivers/imx-tpm: Support building imx-tpm driver as module
  2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
                   ` (2 preceding siblings ...)
  2026-03-04  2:57 ` [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module Zhipeng Wang
@ 2026-03-04  2:57 ` Zhipeng Wang
  2026-03-04  4:26 ` [PATCH v3 0/4] clocksource: Add module support for timer drivers Frank Li
  2026-03-04  5:40 ` Trilok Soni
  5 siblings, 0 replies; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  2:57 UTC (permalink / raw)
  To: daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

From: Jindong Yue <jindong.yue@nxp.com>

Change defconfig as tristate type and add platform driver
to support building it as a module.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
 drivers/clocksource/Kconfig         |  2 +-
 drivers/clocksource/timer-imx-tpm.c | 36 ++++++++++++++++++++++++++---
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 2112efb85029..1ba3e9bca3db 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -613,7 +613,7 @@ config CLKSRC_IMX_GPT
 	select CLKSRC_MMIO
 
 config CLKSRC_IMX_TPM
-	bool "Clocksource using i.MX TPM" if COMPILE_TEST
+	tristate "Clocksource using i.MX TPM"
 	depends on (ARM || ARM64) && HAVE_CLK
 	select CLKSRC_MMIO
 	select TIMER_OF
diff --git a/drivers/clocksource/timer-imx-tpm.c b/drivers/clocksource/timer-imx-tpm.c
index 92c025b70eb6..419d094459b2 100644
--- a/drivers/clocksource/timer-imx-tpm.c
+++ b/drivers/clocksource/timer-imx-tpm.c
@@ -8,6 +8,8 @@
 #include <linux/clocksource.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
 #include <linux/sched_clock.h>
 
 #include "timer-of.h"
@@ -152,7 +154,7 @@ static struct timer_of to_tpm = {
 	},
 };
 
-static int __init tpm_clocksource_init(void)
+static int tpm_clocksource_init(void)
 {
 #if defined(CONFIG_ARM)
 	tpm_delay_timer.read_current_timer = &tpm_read_current_timer;
@@ -171,7 +173,7 @@ static int __init tpm_clocksource_init(void)
 				     clocksource_mmio_readl_up);
 }
 
-static void __init tpm_clockevent_init(void)
+static void tpm_clockevent_init(void)
 {
 	clockevents_config_and_register(&to_tpm.clkevt,
 					timer_of_rate(&to_tpm) >> 3,
@@ -180,7 +182,7 @@ static void __init tpm_clockevent_init(void)
 					1));
 }
 
-static int __init tpm_timer_init(struct device_node *np)
+static int tpm_timer_init(struct device_node *np)
 {
 	struct clk *ipg;
 	int ret;
@@ -241,4 +243,32 @@ static int __init tpm_timer_init(struct device_node *np)
 
 	return tpm_clocksource_init();
 }
+#ifdef MODULE
+static int tpm_timer_probe(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+
+	return tpm_timer_init(np);
+}
+
+static const struct of_device_id tpm_timer_match_table[] = {
+	{ .compatible = "fsl,imx7ulp-tpm" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, tpm_timer_match_table);
+
+static struct platform_driver tpm_timer_driver = {
+	.probe		= tpm_timer_probe,
+	.driver		= {
+		.name	= "tpm-timer",
+		.of_match_table = tpm_timer_match_table,
+	},
+};
+module_platform_driver(tpm_timer_driver);
+
+#else
 TIMER_OF_DECLARE(imx7ulp, "fsl,imx7ulp-tpm", tpm_timer_init);
+#endif
+
+MODULE_DESCRIPTION("i.MX TPM Timer Driver");
+MODULE_LICENSE("GPL");
-- 
2.34.1


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

* Re: [PATCH v3 0/4] clocksource: Add module support for timer drivers
  2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
                   ` (3 preceding siblings ...)
  2026-03-04  2:57 ` [PATCH v3 4/4] clocksource/drivers/imx-tpm: Support building imx-tpm driver as module Zhipeng Wang
@ 2026-03-04  4:26 ` Frank Li
  2026-03-04  5:40 ` Trilok Soni
  5 siblings, 0 replies; 10+ messages in thread
From: Frank Li @ 2026-03-04  4:26 UTC (permalink / raw)
  To: Zhipeng Wang
  Cc: daniel.lezcano, tglx, shawnguo, s.hauer, kernel, festevam,
	matthias.bgg, angelogioacchino.delregno, linux-kernel, imx,
	linux-arm-kernel, linux-mediatek, chun-hung.wu, walter.chang,
	jstultz, amergnat, aisheng.dong, jindong.yue, xuegang.liu

On Wed, Mar 04, 2026 at 11:57:16AM +0900, Zhipeng Wang wrote:
> This patch series enables clocksource timer drivers to be built as
> loadable kernel modules, which is particularly useful for GKI
> (Generic Kernel Image) configurations.
>
> This series is based on the previous MediaTek timer modularization work:
> Link: https://lore.kernel.org/all/20230517022557.24388-1-walter.chang@mediatek.com/

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> The series includes:
> 1. Export necessary functions from clocksource/mmio
> 2. Remove __init markings from timer-of to support modules
> 3. Convert MediaTek timer driver to support module build
> 4. Convert i.MX TPM timer driver to support module build
>
...


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

* Re: [PATCH v3 0/4] clocksource: Add module support for timer drivers
  2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
                   ` (4 preceding siblings ...)
  2026-03-04  4:26 ` [PATCH v3 0/4] clocksource: Add module support for timer drivers Frank Li
@ 2026-03-04  5:40 ` Trilok Soni
  2026-03-04  7:22   ` [EXT] " Zhipeng Wang
  5 siblings, 1 reply; 10+ messages in thread
From: Trilok Soni @ 2026-03-04  5:40 UTC (permalink / raw)
  To: Zhipeng Wang, daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

On 3/3/2026 6:57 PM, Zhipeng Wang wrote:
> This patch series enables clocksource timer drivers to be built as
> loadable kernel modules, which is particularly useful for GKI
> (Generic Kernel Image) configurations.
> 
> This series is based on the previous MediaTek timer modularization work:
> Link: https://lore.kernel.org/all/20230517022557.24388-1-walter.chang@mediatek.com/

You are not explaining clearly on the why part? Does MTK doesn't have
ARM compliant timers and due to which you have specific timer driver?

It is not clear. 


> 
> The series includes:
> 1. Export necessary functions from clocksource/mmio
> 2. Remove __init markings from timer-of to support modules
> 3. Convert MediaTek timer driver to support module build
> 4. Convert i.MX TPM timer driver to support module build
> 
> Testing performed:
> - Built and tested on i.MX8ULP platform
> - Built and tested on MediaTek platform
> - Verified both built-in and module configurations
> - Confirmed timer functionality in both configurations
> 
> Changes in v3:
> - Reworded summary line for timer-mediatek driver as suggested.
> - Improved commit message formatting (line wrapping).
> - No functional changes to the code.
> 
> Changes in v2:
> - Added Signed-off-by from submitter (Zhipeng Wang) to all patches
>   as requested by reviewers
> 
> Changes in v1:
> - Fixed 'unsigned' to 'unsigned int' in clocksource_mmio_init()
> - Changed MODULE_LICENSE from "GPL v2" to "GPL" for mediatek driver
> - Added i.MX TPM timer driver module support
> 
> Chun-Hung Wu (3):
>   clocksource/drivers/mmio: Export clocksource_mmio_init()
>   clocksource/drivers/timer-of: Remove __init markings
>   clocksource/drivers/timer-mediatek: Convert timer-mediatek to a
>     loadable module
> 
> Jindong Yue (1):
>   clocksource/drivers/imx-tpm: Support building imx-tpm driver as module
> 
>  drivers/clocksource/Kconfig          |  4 ++--
>  drivers/clocksource/mmio.c           |  8 ++++---
>  drivers/clocksource/timer-imx-tpm.c  | 36 +++++++++++++++++++++++++---
>  drivers/clocksource/timer-mediatek.c | 33 +++++++++++++++++++++++++
>  drivers/clocksource/timer-of.c       | 23 +++++++++---------
>  drivers/clocksource/timer-of.h       |  6 ++---
>  6 files changed, 88 insertions(+), 22 deletions(-)
> 


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

* Re: [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module
  2026-03-04  2:57 ` [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module Zhipeng Wang
@ 2026-03-04  5:41   ` Trilok Soni
  2026-03-04  7:30     ` [EXT] " Zhipeng Wang
  0 siblings, 1 reply; 10+ messages in thread
From: Trilok Soni @ 2026-03-04  5:41 UTC (permalink / raw)
  To: Zhipeng Wang, daniel.lezcano, tglx
  Cc: shawnguo, s.hauer, kernel, festevam, matthias.bgg,
	angelogioacchino.delregno, linux-kernel, imx, linux-arm-kernel,
	linux-mediatek, chun-hung.wu, walter.chang, jstultz, amergnat,
	aisheng.dong, jindong.yue, xuegang.liu

On 3/3/2026 6:57 PM, Zhipeng Wang wrote:
> From: Chun-Hung Wu <chun-hung.wu@mediatek.com>
> 
> Convert the timer-mediatek driver into a loadable module so that
> it can register an always-on timer as the tick_broadcast_device on
> MediaTek SoCs. This helps support GKI modular configurations.

You have expanded GKI in the cover letter but not in the commit text. 

Please add that in the commit text since this patch will be committed
and not the cover letter. 

> 
> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
> Signed-off-by: Walter Chang <walter.chang@mediatek.com>
> Tested-by: Walter Chang <walter.chang@mediatek.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
> Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
> ---
>  drivers/clocksource/Kconfig          |  2 +-
>  drivers/clocksource/timer-mediatek.c | 33 ++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index fd9112706545..2112efb85029 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -488,7 +488,7 @@ config SYS_SUPPORTS_SH_CMT
>  	bool
>  
>  config MTK_TIMER
> -	bool "Mediatek timer driver" if COMPILE_TEST
> +	tristate "MediaTek timer driver"
>  	depends on HAS_IOMEM
>  	select TIMER_OF
>  	select CLKSRC_MMIO
> diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
> index 7bcb4a3f26fb..4ad4bac6f34b 100644
> --- a/drivers/clocksource/timer-mediatek.c
> +++ b/drivers/clocksource/timer-mediatek.c
> @@ -13,6 +13,9 @@
>  #include <linux/clocksource.h>
>  #include <linux/interrupt.h>
>  #include <linux/irqreturn.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
>  #include <linux/sched_clock.h>
>  #include <linux/slab.h>
>  #include "timer-of.h"
> @@ -337,5 +340,35 @@ static int __init mtk_gpt_init(struct device_node *node)
>  
>  	return 0;
>  }
> +
> +#ifndef MODULE
>  TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
>  TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
> +#else
> +static int mtk_timer_probe(struct platform_device *pdev)
> +{
> +	int (*timer_init)(struct device_node *node);
> +	struct device_node *np = pdev->dev.of_node;
> +
> +	timer_init = of_device_get_match_data(&pdev->dev);
> +	return timer_init(np);
> +}
> +
> +static const struct of_device_id mtk_timer_match_table[] = {
> +	{ .compatible = "mediatek,mt6577-timer", .data = mtk_gpt_init },
> +	{ .compatible = "mediatek,mt6765-timer", .data = mtk_syst_init },
> +	{ /* sentinel */ }
> +};
> +
> +static struct platform_driver mtk_timer_driver = {
> +	.probe = mtk_timer_probe,
> +	.driver = {
> +		.name = "mediatek-timer",
> +		.of_match_table = mtk_timer_match_table,
> +	},
> +};
> +module_platform_driver(mtk_timer_driver);
> +
> +MODULE_DESCRIPTION("MediaTek Timer driver");
> +MODULE_LICENSE("GPL");
> +#endif


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

* RE: [EXT] Re: [PATCH v3 0/4] clocksource: Add module support for timer drivers
  2026-03-04  5:40 ` Trilok Soni
@ 2026-03-04  7:22   ` Zhipeng Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  7:22 UTC (permalink / raw)
  To: Trilok Soni, daniel.lezcano@linaro.org, tglx@kernel.org
  Cc: shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, chun-hung.wu@mediatek.com,
	walter.chang@mediatek.com, jstultz@google.com,
	amergnat@baylibre.com, Aisheng Dong, Jindong Yue, Xuegang Liu

Hello Trilok,

Thank you for the feedback.

Yes, MediaTek SoCs have ARM architectural timers. The timer-mediatek
driver provides an always-on system timer that complements, rather than
replaces, the ARM architected timer.

I will send v4 with an updated cover letter to clarify this.

BRs,
Zhipeng


> -----Original Message-----
> From: Trilok Soni <trilokkumar.soni@oss.qualcomm.com>
> Sent: 2026年3月4日 13:41
> To: Zhipeng Wang <zhipeng.wang_1@nxp.com>; daniel.lezcano@linaro.org;
> tglx@kernel.org
> Cc: shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> festevam@gmail.com; matthias.bgg@gmail.com;
> angelogioacchino.delregno@collabora.com; linux-kernel@vger.kernel.org;
> imx@lists.linux.dev; linux-arm-kernel@lists.infradead.org;
> linux-mediatek@lists.infradead.org; chun-hung.wu@mediatek.com;
> walter.chang@mediatek.com; jstultz@google.com; amergnat@baylibre.com;
> Aisheng Dong <aisheng.dong@nxp.com>; Jindong Yue
> <jindong.yue@nxp.com>; Xuegang Liu <xuegang.liu@nxp.com>
> Subject: [EXT] Re: [PATCH v3 0/4] clocksource: Add module support for timer
> drivers
> 
> [You don't often get email from trilokkumar.soni@oss.qualcomm.com. Learn
> why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
> 
> 
> On 3/3/2026 6:57 PM, Zhipeng Wang wrote:
> > This patch series enables clocksource timer drivers to be built as
> > loadable kernel modules, which is particularly useful for GKI (Generic
> > Kernel Image) configurations.
> >
> > This series is based on the previous MediaTek timer modularization work:
> > Link:
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore
> > .kernel.org%2Fall%2F20230517022557.24388-1-walter.chang%40mediatek.c
> om
> > %2F&data=05%7C02%7Czhipeng.wang_1%40nxp.com%7C3c600569cf2c45f
> e76d308de
> >
> 79b09401%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6390819
> 964656056
> >
> 68%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjA
> uMDAwMCI
> >
> sIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sda
> ta=l
> > Y0pdTxMyzbZospgoWZHb4sOFTwdl84pJXxvRt4fN3I%3D&reserved=0
> 
> You are not explaining clearly on the why part? Does MTK doesn't have ARM
> compliant timers and due to which you have specific timer driver?
> 
> It is not clear.
> 
> 
> >
> > The series includes:
> > 1. Export necessary functions from clocksource/mmio 2. Remove __init
> > markings from timer-of to support modules 3. Convert MediaTek timer
> > driver to support module build 4. Convert i.MX TPM timer driver to
> > support module build
> >
> > Testing performed:
> > - Built and tested on i.MX8ULP platform
> > - Built and tested on MediaTek platform
> > - Verified both built-in and module configurations
> > - Confirmed timer functionality in both configurations
> >
> > Changes in v3:
> > - Reworded summary line for timer-mediatek driver as suggested.
> > - Improved commit message formatting (line wrapping).
> > - No functional changes to the code.
> >
> > Changes in v2:
> > - Added Signed-off-by from submitter (Zhipeng Wang) to all patches
> >   as requested by reviewers
> >
> > Changes in v1:
> > - Fixed 'unsigned' to 'unsigned int' in clocksource_mmio_init()
> > - Changed MODULE_LICENSE from "GPL v2" to "GPL" for mediatek driver
> > - Added i.MX TPM timer driver module support
> >
> > Chun-Hung Wu (3):
> >   clocksource/drivers/mmio: Export clocksource_mmio_init()
> >   clocksource/drivers/timer-of: Remove __init markings
> >   clocksource/drivers/timer-mediatek: Convert timer-mediatek to a
> >     loadable module
> >
> > Jindong Yue (1):
> >   clocksource/drivers/imx-tpm: Support building imx-tpm driver as
> > module
> >
> >  drivers/clocksource/Kconfig          |  4 ++--
> >  drivers/clocksource/mmio.c           |  8 ++++---
> >  drivers/clocksource/timer-imx-tpm.c  | 36
> > +++++++++++++++++++++++++---  drivers/clocksource/timer-mediatek.c |
> 33 +++++++++++++++++++++++++
> >  drivers/clocksource/timer-of.c       | 23 +++++++++---------
> >  drivers/clocksource/timer-of.h       |  6 ++---
> >  6 files changed, 88 insertions(+), 22 deletions(-)
> >


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

* RE: [EXT] Re: [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module
  2026-03-04  5:41   ` Trilok Soni
@ 2026-03-04  7:30     ` Zhipeng Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Zhipeng Wang @ 2026-03-04  7:30 UTC (permalink / raw)
  To: Trilok Soni, daniel.lezcano@linaro.org, tglx@kernel.org
  Cc: shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, chun-hung.wu@mediatek.com,
	walter.chang@mediatek.com, jstultz@google.com,
	amergnat@baylibre.com, Aisheng Dong, Jindong Yue, Xuegang Liu

Hello Trilok,

Thank you for the feedback.

I will update it.

BRs,
Zhipeng

> -----Original Message-----
> From: Trilok Soni <trilokkumar.soni@oss.qualcomm.com>
> Sent: 2026年3月4日 13:42
> To: Zhipeng Wang <zhipeng.wang_1@nxp.com>; daniel.lezcano@linaro.org;
> tglx@kernel.org
> Cc: shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> festevam@gmail.com; matthias.bgg@gmail.com;
> angelogioacchino.delregno@collabora.com; linux-kernel@vger.kernel.org;
> imx@lists.linux.dev; linux-arm-kernel@lists.infradead.org;
> linux-mediatek@lists.infradead.org; chun-hung.wu@mediatek.com;
> walter.chang@mediatek.com; jstultz@google.com; amergnat@baylibre.com;
> Aisheng Dong <aisheng.dong@nxp.com>; Jindong Yue
> <jindong.yue@nxp.com>; Xuegang Liu <xuegang.liu@nxp.com>
> Subject: [EXT] Re: [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert
> timer-mediatek to a loadable module
> 
> [You don't often get email from trilokkumar.soni@oss.qualcomm.com. Learn
> why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
> 
> 
> On 3/3/2026 6:57 PM, Zhipeng Wang wrote:
> > From: Chun-Hung Wu <chun-hung.wu@mediatek.com>
> >
> > Convert the timer-mediatek driver into a loadable module so that it
> > can register an always-on timer as the tick_broadcast_device on
> > MediaTek SoCs. This helps support GKI modular configurations.
> 
> You have expanded GKI in the cover letter but not in the commit text.
> 
> Please add that in the commit text since this patch will be committed and not
> the cover letter.
> 
> >
> > Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
> > Signed-off-by: Walter Chang <walter.chang@mediatek.com>
> > Tested-by: Walter Chang <walter.chang@mediatek.com>
> > Reviewed-by: AngeloGioacchino Del Regno
> > <angelogioacchino.delregno@collabora.com>
> > Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
> > Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
> > ---
> >  drivers/clocksource/Kconfig          |  2 +-
> >  drivers/clocksource/timer-mediatek.c | 33
> > ++++++++++++++++++++++++++++
> >  2 files changed, 34 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > index fd9112706545..2112efb85029 100644
> > --- a/drivers/clocksource/Kconfig
> > +++ b/drivers/clocksource/Kconfig
> > @@ -488,7 +488,7 @@ config SYS_SUPPORTS_SH_CMT
> >       bool
> >
> >  config MTK_TIMER
> > -     bool "Mediatek timer driver" if COMPILE_TEST
> > +     tristate "MediaTek timer driver"
> >       depends on HAS_IOMEM
> >       select TIMER_OF
> >       select CLKSRC_MMIO
> > diff --git a/drivers/clocksource/timer-mediatek.c
> > b/drivers/clocksource/timer-mediatek.c
> > index 7bcb4a3f26fb..4ad4bac6f34b 100644
> > --- a/drivers/clocksource/timer-mediatek.c
> > +++ b/drivers/clocksource/timer-mediatek.c
> > @@ -13,6 +13,9 @@
> >  #include <linux/clocksource.h>
> >  #include <linux/interrupt.h>
> >  #include <linux/irqreturn.h>
> > +#include <linux/module.h>
> > +#include <linux/of_device.h>
> > +#include <linux/platform_device.h>
> >  #include <linux/sched_clock.h>
> >  #include <linux/slab.h>
> >  #include "timer-of.h"
> > @@ -337,5 +340,35 @@ static int __init mtk_gpt_init(struct device_node
> > *node)
> >
> >       return 0;
> >  }
> > +
> > +#ifndef MODULE
> >  TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer",
> mtk_gpt_init);
> > TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer",
> mtk_syst_init);
> > +#else
> > +static int mtk_timer_probe(struct platform_device *pdev) {
> > +     int (*timer_init)(struct device_node *node);
> > +     struct device_node *np = pdev->dev.of_node;
> > +
> > +     timer_init = of_device_get_match_data(&pdev->dev);
> > +     return timer_init(np);
> > +}
> > +
> > +static const struct of_device_id mtk_timer_match_table[] = {
> > +     { .compatible = "mediatek,mt6577-timer", .data = mtk_gpt_init },
> > +     { .compatible = "mediatek,mt6765-timer", .data = mtk_syst_init },
> > +     { /* sentinel */ }
> > +};
> > +
> > +static struct platform_driver mtk_timer_driver = {
> > +     .probe = mtk_timer_probe,
> > +     .driver = {
> > +             .name = "mediatek-timer",
> > +             .of_match_table = mtk_timer_match_table,
> > +     },
> > +};
> > +module_platform_driver(mtk_timer_driver);
> > +
> > +MODULE_DESCRIPTION("MediaTek Timer driver");
> MODULE_LICENSE("GPL");
> > +#endif


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

end of thread, other threads:[~2026-03-04  7:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04  2:57 [PATCH v3 0/4] clocksource: Add module support for timer drivers Zhipeng Wang
2026-03-04  2:57 ` [PATCH v3 1/4] clocksource/drivers/mmio: Export clocksource_mmio_init() Zhipeng Wang
2026-03-04  2:57 ` [PATCH v3 2/4] clocksource/drivers/timer-of: Remove __init markings Zhipeng Wang
2026-03-04  2:57 ` [PATCH v3 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module Zhipeng Wang
2026-03-04  5:41   ` Trilok Soni
2026-03-04  7:30     ` [EXT] " Zhipeng Wang
2026-03-04  2:57 ` [PATCH v3 4/4] clocksource/drivers/imx-tpm: Support building imx-tpm driver as module Zhipeng Wang
2026-03-04  4:26 ` [PATCH v3 0/4] clocksource: Add module support for timer drivers Frank Li
2026-03-04  5:40 ` Trilok Soni
2026-03-04  7:22   ` [EXT] " Zhipeng Wang

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