* [PATCH] sh: sh7305: add TMU0 module clock gate
@ 2026-10-22 5:10 Artem Novak
2026-10-30 10:56 ` Geert Uytterhoeven
0 siblings, 1 reply; 2+ messages in thread
From: Artem Novak @ 2026-10-22 5:10 UTC (permalink / raw)
To: glaubitz, dalias; +Cc: linux-sh, linux-kernel, Artem Novak
Register the SH7305 TMU0 module-stop clock using MSTPCR0 bit 15.
Provide the fck clock lookup for the sh-tmu.0 platform device.
Signed-off-by: Artem Novak <artem122novak@gmail.com>
---
arch/sh/kernel/cpu/clock-cpg.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c
index 5b75a384cbf3..5a1f1479416b 100644
--- a/arch/sh/kernel/cpu/clock-cpg.c
+++ b/arch/sh/kernel/cpu/clock-cpg.c
@@ -16,6 +16,20 @@ static struct clk peripheral_clk = {
.flags = CLK_ENABLE_ON_INIT,
};
+#ifdef CONFIG_CPU_SUBTYPE_SH7305
+/*
+ * SH7305 TMU0 module clock.
+ *
+ * MSTPCR0 bit 15 gates the peripheral clock to TMU0.
+ * Early platform initialization enables the gate before timer setup.
+ */
+static struct clk sh7305_tmu0_clk =
+ SH_CLK_MSTP32(&peripheral_clk, 0xa4150030, 15, 0);
+
+static struct clk_lookup sh7305_tmu0_lookup =
+ CLKDEV_ICK_ID("fck", "sh-tmu.0", &sh7305_tmu0_clk);
+#endif
+
static struct clk bus_clk = {
.parent = &master_clk,
.flags = CLK_ENABLE_ON_INIT,
@@ -58,7 +72,15 @@ int __init __deprecated cpg_clk_init(void)
clkdev_add_table(lookups, ARRAY_SIZE(lookups));
clk_add_alias("fck", "sh-tmu-sh3.0", "peripheral_clk", NULL);
+#ifdef CONFIG_CPU_SUBTYPE_SH7305
+ if (!ret) {
+ ret = sh_clk_mstp_register(&sh7305_tmu0_clk, 1);
+ if (!ret)
+ clkdev_add(&sh7305_tmu0_lookup);
+ }
+#else
clk_add_alias("fck", "sh-tmu.0", "peripheral_clk", NULL);
+#endif
clk_add_alias("fck", "sh-tmu.1", "peripheral_clk", NULL);
clk_add_alias("fck", "sh-tmu.2", "peripheral_clk", NULL);
clk_add_alias("fck", "sh-mtu2", "peripheral_clk", NULL);
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] sh: sh7305: add TMU0 module clock gate
2026-10-22 5:10 [PATCH] sh: sh7305: add TMU0 module clock gate Artem Novak
@ 2026-10-30 10:56 ` Geert Uytterhoeven
0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2026-10-30 10:56 UTC (permalink / raw)
To: Artem Novak; +Cc: glaubitz, dalias, linux-sh, linux-kernel
Hi Artem,
On Thu, 22 Oct 2026 at 07:10, Artem Novak <artem122novak@gmail.com> wrote:
> Register the SH7305 TMU0 module-stop clock using MSTPCR0 bit 15.
>
> Provide the fck clock lookup for the sh-tmu.0 platform device.
>
> Signed-off-by: Artem Novak <artem122novak@gmail.com>
Thanks for your patch!
> --- a/arch/sh/kernel/cpu/clock-cpg.c
> +++ b/arch/sh/kernel/cpu/clock-cpg.c
This file is only compiled if CONFIG_SH_CLK_CPG_LEGACY=y.
Probably you should not use it for new SoC support.
E.g. the similar sh7724 has:
arch/sh/kernel/cpu/sh4a/clock-sh7724.c: CLKDEV_ICK_ID("fck",
"sh-tmu.0", &mstp_clks[HWBLK_TMU0]),
> @@ -58,7 +72,15 @@ int __init __deprecated cpg_clk_init(void)
> clkdev_add_table(lookups, ARRAY_SIZE(lookups));
>
> clk_add_alias("fck", "sh-tmu-sh3.0", "peripheral_clk", NULL);
> +#ifdef CONFIG_CPU_SUBTYPE_SH7305
> + if (!ret) {
> + ret = sh_clk_mstp_register(&sh7305_tmu0_clk, 1);
> + if (!ret)
> + clkdev_add(&sh7305_tmu0_lookup);
> + }
> +#else
> clk_add_alias("fck", "sh-tmu.0", "peripheral_clk", NULL);
> +#endif
... and thus there is no need to sprinkle #ifdefs in this file.
> clk_add_alias("fck", "sh-tmu.1", "peripheral_clk", NULL);
> clk_add_alias("fck", "sh-tmu.2", "peripheral_clk", NULL);
> clk_add_alias("fck", "sh-mtu2", "peripheral_clk", NULL);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 10:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 5:10 [PATCH] sh: sh7305: add TMU0 module clock gate Artem Novak
2026-10-30 10:56 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®