From: Qing Zhang <zhangqing@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Thomas Gleixner <tglx@linutronix.de>,
Marc Zyngier <maz@kernel.org>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
wangming01@loongson.cn
Subject: [PATCH v3 3/7] MIPS: Loongson64: Add support for the 2K1000 to get cpu_clock_freq
Date: Sat, 6 Mar 2021 10:36:29 +0800 [thread overview]
Message-ID: <20210306023633.9579-4-zhangqing@loongson.cn> (raw)
In-Reply-To: <20210306023633.9579-1-zhangqing@loongson.cn>
Get the fixed-clock from the CPU0 node of the device tree.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
---
v2-v3: Add error process
arch/mips/loongson64/time.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c
index 91e842b58365..84f01424c8c0 100644
--- a/arch/mips/loongson64/time.c
+++ b/arch/mips/loongson64/time.c
@@ -11,9 +11,29 @@
#include <asm/hpet.h>
#include <loongson.h>
+#include <linux/clk.h>
+#include <linux/of_clk.h>
void __init plat_time_init(void)
{
+ struct clk *clk = NULL;
+ struct device_node *np;
+
+ if (loongson_sysconf.fw_interface != LOONGSON_LEFI) {
+ of_clk_init(NULL);
+
+ np = of_get_cpu_node(0, NULL);
+ if (!np)
+ pr_err("Failed to get CPU node\n");
+
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk))
+ pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
+
+ cpu_clock_freq = clk_get_rate(clk);
+ clk_put(clk);
+ }
+
/* setup mips r4k timer */
mips_hpt_frequency = cpu_clock_freq / 2;
--
2.20.1
next prev parent reply other threads:[~2021-03-06 2:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-06 2:36 [PATCH v3 0/7] Add basic support for Loongson-2K1000 Qing Zhang
2021-03-06 2:36 ` [PATCH v3 1/7] MIPS: Loongson64: DeviceTree for 2K1000 Qing Zhang
2021-03-06 7:23 ` Ming Wang
2021-03-06 2:36 ` [PATCH v3 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Qing Zhang
2021-03-06 7:24 ` Ming Wang
2021-03-06 2:36 ` Qing Zhang [this message]
2021-03-06 7:25 ` [PATCH v3 3/7] MIPS: Loongson64: Add support for the 2K1000 to get cpu_clock_freq Ming Wang
2021-03-06 2:36 ` [PATCH v3 4/7] MIPS: Loongson64: Add 2K1000 early_printk_port Qing Zhang
2021-03-06 7:26 ` Ming Wang
2021-03-06 2:36 ` [PATCH v3 5/7] irqchip/loongson-liointc: irqchip add 2.0 version Qing Zhang
2021-03-06 3:06 ` Huacai Chen
2021-03-06 3:25 ` zhangqing
2021-03-06 7:27 ` Ming Wang
2021-03-09 9:10 ` Marc Zyngier
2021-03-10 2:26 ` zhangqing
2021-03-10 8:47 ` Sergei Shtylyov
2021-03-10 9:36 ` zhangqing
2021-03-10 9:30 ` Marc Zyngier
2021-03-10 9:39 ` zhangqing
2021-03-06 2:36 ` [PATCH v3 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC Qing Zhang
2021-03-06 7:28 ` Ming Wang
2021-03-06 2:36 ` [PATCH v3 7/7] MIPS: Loongson64: Add a Loongson-2k default config file Qing Zhang
2021-03-06 7:28 ` Ming Wang
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=20210306023633.9579-4-zhangqing@loongson.cn \
--to=zhangqing@loongson.cn \
--cc=chenhuacai@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=maz@kernel.org \
--cc=tglx@linutronix.de \
--cc=tsbogend@alpha.franken.de \
--cc=wangming01@loongson.cn \
/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;
as well as URLs for NNTP newsgroup(s).