Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1711133
| From | Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/5] ARC: set and print cpu frequency at boot time |
| Date | 2017-08-14 18:20 +0200 |
| Message-ID | <ueqfU-6mT-7@gated-at.bofh.it> (permalink) |
| References | <ueqfT-6mT-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Print cpu frequency at boot time. In case we have pre-defined
cpu frequency value in device tree try to set it.
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
arch/arc/kernel/setup.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 877cec8..b5fcc5d 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -464,12 +464,61 @@ void __init setup_arch(char **cmdline_p)
arc_unwind_init();
}
+static int __init set_cpu_freq(int cpu_id)
+{
+ struct device_node *cpunode;
+ u32 cpu_freq_required;
+ struct clk *clk;
+ int ret;
+
+ cpunode = of_get_cpu_node(cpu_id, NULL);
+ if (cpunode == NULL) {
+ pr_err("Can't find CPU %d node.\n", cpu_id);
+ return -ENOENT;
+ }
+
+ clk = of_clk_get(cpunode, 0);
+ if (IS_ERR(clk)) {
+ pr_err("CPU %d missing clk.\n", cpu_id);
+ return PTR_ERR(clk);
+ }
+
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ pr_err("Couldn't enable CPU %d clk.\n", cpu_id);
+ return ret;
+ }
+
+ /*
+ * In case we have pre-defined cpu frequency value in device tree
+ * try to set it. Otherwise just print current cpu frequency.
+ */
+ if (of_property_read_u32(cpunode, "cpu-freq", &cpu_freq_required)) {
+ pr_info("CPU %d has no cpu-freq param. Frequency is %lu Hz.\n",
+ cpu_id, clk_get_rate(clk));
+ return 0;
+ }
+
+ if (clk_set_rate(clk, cpu_freq_required))
+ pr_err("CPU %d frequency set failed. Probably fixed-clock is used for cpu.\n",
+ cpu_id);
+
+ pr_info("CPU %d frequency is %lu Hz.\n", cpu_id, clk_get_rate(clk));
+
+ return 0;
+}
+
/*
* Called from start_kernel() - boot CPU only
*/
void __init time_init(void)
{
of_clk_init(NULL);
+ /*
+ * As for now we have common clock for all cpu cores, so set
+ * frequency only for master cpu.
+ */
+ set_cpu_freq(0);
timer_probe();
}
--
2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] Updates to arc clock tree managment Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-14 18:20 +0200
[PATCH 2/5] ARC: AXS103: Get rid of platform specific cpu clock configuration Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-14 18:20 +0200
Re: [PATCH 2/5] ARC: AXS103: Get rid of platform specific cpu clock configuration Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-08-22 22:40 +0200
[PATCH 1/5] ARC: set and print cpu frequency at boot time Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-14 18:20 +0200
[PATCH 3/5] ARC: AXS103: DTS: Add core pll node to manage cpu frequency Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-14 18:20 +0200
Re: [PATCH 3/5] ARC: AXS103: DTS: Add core pll node to manage cpu frequency Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-08-22 22:50 +0200
Re: [PATCH 3/5] ARC: AXS103: DTS: Add core pll node to manage cpu frequency Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-08-22 22:50 +0200
Re: [PATCH 3/5] ARC: AXS103: DTS: Add core pll node to manage cpu frequency Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-23 14:20 +0200
[PATCH 4/5] ARC: AXS103: DTS: Set cpu frequency explicitly via dts Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-14 18:20 +0200
Re: [PATCH 4/5] ARC: AXS103: DTS: Set cpu frequency explicitly via dts Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-08-22 23:50 +0200
Re: [PATCH 4/5] ARC: AXS103: DTS: Set cpu frequency explicitly via dts Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-23 13:30 +0200
Re: [PATCH 4/5] ARC: AXS103: DTS: Set cpu frequency explicitly via dts Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2017-08-23 18:50 +0200
[PATCH 5/5] ARC: AXS103: use cpu-freq param instead of /cpu_card/core_clk Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> - 2017-08-14 18:20 +0200
csiph-web