From: Artem Novak <artem122novak@gmail.com>
To: ysato@users.sourceforge.jp, dalias@libc.org,
glaubitz@physik.fu-berlin.de, linux-sh@vger.kernel.org
Cc: geert+renesas@glider.be, linux-kernel@vger.kernel.org,
Artem Novak <artem122novak@gmail.com>
Subject: [PATCH v3] sh: sh7305: add TMU0 clock support
Date: Mon, 2 Nov 2026 18:56:45 -0600 [thread overview]
Message-ID: <20261103005645.101643-1-artem122novak@gmail.com> (raw)
Register the SH7305 master, peripheral, bus and CPU clocks using
the SuperH clock framework. Add the TMU0 module clock gate using
MSTPCR0 bit 15.
Keeping SH7305 clock initialization independent of the legacy CPG
initialization framework, which relies on arch_init_clk_ops().
Disable SH_CLK_CPG_LEGACY for SH7305.
Signed-off-by: Artem Novak <artem122novak@gmail.com>
---
arch/sh/Kconfig | 2 +-
arch/sh/kernel/cpu/sh4a/clock-sh7305.c | 78 +++++++++++++++++++-------
2 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 5ce7df11c3ec..c5cc486eb1a3 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -536,7 +536,7 @@ config SH_CLK_CPG_LEGACY
def_bool y if !CPU_SUBTYPE_SH7785 && !ARCH_SHMOBILE && \
!CPU_SHX3 && !CPU_SUBTYPE_SH7757 && \
!CPU_SUBTYPE_SH7734 && !CPU_SUBTYPE_SH7264 && \
- !CPU_SUBTYPE_SH7269
+ !CPU_SUBTYPE_SH7269 && !CPU_SUBTYPE_SH7305
endmenu
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7305.c b/arch/sh/kernel/cpu/sh4a/clock-sh7305.c
index 0e683dd6de11..03d4b5f987dd 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7305.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7305.c
@@ -7,6 +7,8 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
#include <linux/sh_clk.h>
#include <asm/clock.h>
@@ -84,13 +86,13 @@ static unsigned int sh7305_divisor(unsigned int shift)
/*
* master_clk is the clock before the B/I/P divider stages.
*/
-static void master_clk_init(struct clk *clk)
+static unsigned long master_clk_recalc(struct clk *clk)
{
- clk->rate = sh7305_base_rate();
+ return sh7305_base_rate();
}
static struct sh_clk_ops sh7305_master_clk_ops = {
- .init = master_clk_init,
+ .recalc = master_clk_recalc,
};
@@ -140,27 +142,63 @@ static struct sh_clk_ops sh7305_cpu_clk_ops = {
/*
- * Ordering must match arch/sh/kernel/cpu/clock-cpg.c:
- *
- * 0 master
- * 1 peripheral
- * 2 bus
- * 3 cpu
+ * SH7305 main clocks.
*/
-static struct sh_clk_ops *sh7305_clk_ops[] = {
- &sh7305_master_clk_ops,
- &sh7305_peripheral_clk_ops,
- &sh7305_bus_clk_ops,
- &sh7305_cpu_clk_ops,
+static struct clk master_clk = {
+ .ops = &sh7305_master_clk_ops,
+ .flags = CLK_ENABLE_ON_INIT,
};
-void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
-{
- if (idx < ARRAY_SIZE(sh7305_clk_ops))
- *ops = sh7305_clk_ops[idx];
-}
+static struct clk peripheral_clk = {
+ .ops = &sh7305_peripheral_clk_ops,
+ .parent = &master_clk,
+ .flags = CLK_ENABLE_ON_INIT,
+};
+
+static struct clk bus_clk = {
+ .ops = &sh7305_bus_clk_ops,
+ .parent = &master_clk,
+ .flags = CLK_ENABLE_ON_INIT,
+};
+
+static struct clk cpu_clk = {
+ .ops = &sh7305_cpu_clk_ops,
+ .parent = &master_clk,
+ .flags = CLK_ENABLE_ON_INIT,
+};
+
+static struct clk *main_clks[] = {
+ &master_clk,
+ &peripheral_clk,
+ &bus_clk,
+ &cpu_clk,
+};
+
+#define MSTPCR0 0xa4150030
+
+static struct clk mstp_clks[] = {
+ SH_CLK_MSTP32(&peripheral_clk, MSTPCR0, 15, 0),
+};
+
+static struct clk_lookup lookups[] = {
+ CLKDEV_CON_ID("master_clk", &master_clk),
+ CLKDEV_CON_ID("peripheral_clk", &peripheral_clk),
+ CLKDEV_CON_ID("bus_clk", &bus_clk),
+ CLKDEV_CON_ID("cpu_clk", &cpu_clk),
+ CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[0]),
+};
int __init arch_clk_init(void)
{
- return cpg_clk_init();
+ int i, ret = 0;
+
+ for (i = 0; !ret && i < ARRAY_SIZE(main_clks); i++)
+ ret = clk_register(main_clks[i]);
+
+ if (ret)
+ return ret;
+
+ clkdev_add_table(lookups, ARRAY_SIZE(lookups));
+
+ return sh_clk_mstp_register(mstp_clks, ARRAY_SIZE(mstp_clks));
}
--
2.56.0
reply other threads:[~2026-11-03 0:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103005645.101643-1-artem122novak@gmail.com \
--to=artem122novak@gmail.com \
--cc=dalias@libc.org \
--cc=geert+renesas@glider.be \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®