* [PATCH] clocksource/drivers/timer-mediatek: initialize GPT6 as system counter
@ 2026-03-26 1:00 Roman Vivchar via B4 Relay
2026-03-26 13:08 ` Akari Tsuyukusa
0 siblings, 1 reply; 2+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-03-26 1:00 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: linux-kernel, linux-arm-kernel, linux-mediatek, Akari Tsuyukusa,
Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
On certain MediaTek SoCs like mt6572 (likely before the CPUXGPT was
introduced), the generic arch timer is fed by the GPT6. Some bootloaders
don't initialize it properly, leading to dead arch timer.
Fix this by configuring GPT6 when the MediaTek timer is probed. This
makes arch timer work properly and removes IPI overhead from MediaTek
timer broadcast when arch timer is used.
If the timer was configured by the bootloader, this change is no-op.
Tested-by: Akari Tsuyukusa <akkun11.open@gmail.com> # MT6589
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
On certain MediaTek SoCs like mt6572 (likely before the CPUXGPT was
introduced), the generic arch timer is fed by the GPT6. Some bootloaders
don't initialize it properly, leading to dead arch timer.
Fix this by configuring GPT6 when the MediaTek timer is probed. This
makes arch timer work properly and removes IPI overhead from MediaTek
timer broadcast when arch timer is used.
If the timer was configured by the bootloader, this change is no-op.
---
drivers/clocksource/timer-mediatek.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index 7bcb4a3f26fb..7de34cace572 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -22,6 +22,8 @@
#define TIMER_SYNC_TICKS (3)
+#define TIMER_SYSCNT (6)
+
/* gpt */
#define GPT_IRQ_EN_REG 0x00
#define GPT_IRQ_ENABLE(val) BIT((val) - 1)
@@ -335,6 +337,9 @@ static int __init mtk_gpt_init(struct device_node *node)
mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
+ /* Configure GPT6 to feed arch timer */
+ mtk_gpt_setup(&to, TIMER_SYSCNT, GPT_CTRL_OP_FREERUN);
+
return 0;
}
TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
---
base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260325-archtimer-357b02f74058
Best regards,
--
Roman Vivchar <rva333@protonmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clocksource/drivers/timer-mediatek: initialize GPT6 as system counter
2026-03-26 1:00 [PATCH] clocksource/drivers/timer-mediatek: initialize GPT6 as system counter Roman Vivchar via B4 Relay
@ 2026-03-26 13:08 ` Akari Tsuyukusa
0 siblings, 0 replies; 2+ messages in thread
From: Akari Tsuyukusa @ 2026-03-26 13:08 UTC (permalink / raw)
To: rva333
Cc: Daniel Lezcano, Thomas Gleixner, Matthias Brugger,
AngeloGioacchino Del Regno, linux-kernel, linux-arm-kernel,
linux-mediatek
On Thu, Mar 26, 2026 at 10:00 AM Roman Vivchar via B4 Relay
<devnull+rva333.protonmail.com@kernel.org> wrote:
> On certain MediaTek SoCs like mt6572 (likely before the CPUXGPT was
> introduced), the generic arch timer is fed by the GPT6. Some bootloaders
> don't initialize it properly, leading to dead arch timer.
>
> Fix this by configuring GPT6 when the MediaTek timer is probed. This
> makes arch timer work properly and removes IPI overhead from MediaTek
> timer broadcast when arch timer is used.
>
> If the timer was configured by the bootloader, this change is no-op.
>
> Tested-by: Akari Tsuyukusa <akkun11.open@gmail.com> # MT6589
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
> ---
> drivers/clocksource/timer-mediatek.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
> index 7bcb4a3f26fb..7de34cace572 100644
> --- a/drivers/clocksource/timer-mediatek.c
> +++ b/drivers/clocksource/timer-mediatek.c
> @@ -22,6 +22,8 @@
>
> #define TIMER_SYNC_TICKS (3)
>
> +#define TIMER_SYSCNT (6)
> +
> /* gpt */
> #define GPT_IRQ_EN_REG 0x00
> #define GPT_IRQ_ENABLE(val) BIT((val) - 1)
> @@ -335,6 +337,9 @@ static int __init mtk_gpt_init(struct device_node *node)
>
> mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
>
> + /* Configure GPT6 to feed arch timer */
> + mtk_gpt_setup(&to, TIMER_SYSCNT, GPT_CTRL_OP_FREERUN);
> +
> return 0;
> }
> TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
>
> ---
Although it has already been written,
I tested this patch on MT6589 (Lenovo YOGA Tablet 10 Wi-Fi),
and I have confirmed that MediaTek's timer and Arm Generic Timer are
working properly as before the patch was applied.
Therefore,
Tested-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Best regards,
Akari Tsuyukusa
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-26 13:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 1:00 [PATCH] clocksource/drivers/timer-mediatek: initialize GPT6 as system counter Roman Vivchar via B4 Relay
2026-03-26 13:08 ` Akari Tsuyukusa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox