Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1323972 > unrolled thread
| Started by | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| First post | 2016-02-02 12:00 +0100 |
| Last post | 2016-02-02 12:10 +0100 |
| Articles | 4 on this page of 24 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH 0/9] ARC clockevent/clocksource modernization Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:00 +0100
[PATCH 2/9] ARC: [dts] Introduce Timer bindings Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:00 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-02 13:50 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-02 14:20 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Vineet Gupta <vgupta@synopsys.com> - 2016-02-02 15:30 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-02 16:40 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-03 00:00 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-03 14:50 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-03 15:00 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Rob Herring <robh@kernel.org> - 2016-02-02 23:10 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-03 09:10 +0100
Re: [PATCH 2/9] ARC: [dts] Introduce Timer bindings Rob Herring <robh@kernel.org> - 2016-02-03 16:40 +0100
[PATCH 6/9] ARC: clocksource: DT based probe Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
Re: [PATCH 6/9] ARC: clocksource: DT based probe Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-02-08 13:20 +0100
Re: [PATCH 6/9] ARC: clocksource: DT based probe Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-08 13:30 +0100
[PATCH 3/9] ARC: clockevent: switch to cpu notifier for clockevent setup Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
[PATCH 9/9] ARC: RIP arc_{get|set}_core_freq() clk API Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
[PATCH 4/9] ARC: clockevent: Prepare for DT based probe Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
[PATCH 7/9] ARC: use fixed frequencies in arc_set_early_base_baud() Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
Re: [PATCH 7/9] ARC: use fixed frequencies in arc_set_early_base_baud() Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-02 14:00 +0100
Re: [PATCH 7/9] ARC: use fixed frequencies in arc_set_early_base_baud() christian.ruppert@alitech.com - 2016-02-02 15:10 +0100
Re: [PATCH 7/9] ARC: use fixed frequencies in arc_set_early_base_baud() Alexey Brodkin <Alexey.Brodkin@synopsys.com> - 2016-02-02 15:30 +0100
[PATCH 5/9] ARC: clockevent: DT based probe Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
[PATCH 8/9] ARC: [plat-axs] Don't use arc_{get|set}_core_freq() for manipulating core clk Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-02-02 12:10 +0100
Page 2 of 2 — ← Prev page 1 [2]
| From | christian.ruppert@alitech.com |
|---|---|
| Date | 2016-02-02 15:10 +0100 |
| Subject | Re: [PATCH 7/9] ARC: use fixed frequencies in arc_set_early_base_baud() |
| Message-ID | <qXJOx-43R-3@gated-at.bofh.it> |
| In reply to | #1324056 |
Alexey Brodkin <Alexey.Brodkin@synopsys.com> wrote on 02.02.2016 13:53:26:
>
> Adding Christian for Abilis TB10x clocks review.
>
> On Tue, 2016-02-02 at 16:28 +0530, Vineet Gupta wrote:
> > From: Alexey Brodkin <abrodkin@synopsys.com>
> >
> > UARTs usually have fixed clock so we're switching to use of
> > constant values instead of something derived from core clock
> > frequency.
> >
> > Among other things this will allow us to get rid of
> > arc_{get|set}_core_freq() and switch to generic clock
> > framework later on.
> >
> > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> > Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> > ---
> > arch/arc/kernel/devtree.c | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c
> > index 7e844fd8213f..e155126c79b1 100644
> > --- a/arch/arc/kernel/devtree.c
> > +++ b/arch/arc/kernel/devtree.c
> > @@ -28,14 +28,12 @@ unsigned int __init arc_early_base_baud(void)
> >
> > static void __init arc_set_early_base_baud(unsigned long dt_root)
> > {
> > - unsigned int core_clk = arc_get_core_freq();
> > -
> > if (of_flat_dt_is_compatible(dt_root, "abilis,arc-tb10x"))
> > - arc_base_baud = core_clk/3;
> > + arc_base_baud = 166666667; /* Fixed 166.7MHz clk (TB10x) */
Actually, (int)core_clk/(int)3 is 166666666 not 166666667.
I seem to remember that this rounding detail did make a difference at some
point. Unluckily, the details are long forgotten in the mist of time...
> > else if (of_flat_dt_is_compatible(dt_root, "snps,arc-sdp"))
> > arc_base_baud = 33333333; /* Fixed 33MHz clk (AXS10x) */
> > else
> > - arc_base_baud = core_clk;
> > + arc_base_baud = 50000000; /* Fixed default 50MHz */
> > }
> > #else
> > #define arc_set_early_base_baud(dt_root)
>
> -Alexey
[toc] | [prev] | [next] | [standalone]
| From | Alexey Brodkin <Alexey.Brodkin@synopsys.com> |
|---|---|
| Date | 2016-02-02 15:30 +0100 |
| Subject | Re: [PATCH 7/9] ARC: use fixed frequencies in arc_set_early_base_baud() |
| Message-ID | <qXK7U-4be-31@gated-at.bofh.it> |
| In reply to | #1324107 |
Hi Christian,
On Tue, 2016-02-02 at 14:43 +0100, christian.ruppert@alitech.com wrote:
> Alexey Brodkin <Alexey.Brodkin@synopsys.com> wrote on 02.02.2016 13:53:26:
> >
> > Adding Christian for Abilis TB10x clocks review.
> >
> > On Tue, 2016-02-02 at 16:28 +0530, Vineet Gupta wrote:
> > > From: Alexey Brodkin <abrodkin@synopsys.com>
> > >
> > > UARTs usually have fixed clock so we're switching to use of
> > > constant values instead of something derived from core clock
> > > frequency.
> > >
> > > Among other things this will allow us to get rid of
> > > arc_{get|set}_core_freq() and switch to generic clock
> > > framework later on.
> > >
> > > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> > > Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> > > ---
> > > arch/arc/kernel/devtree.c | 6 ++----
> > > 1 file changed, 2 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/arch/arc/kernel/devtree.c b/arch/arc/kernel/devtree.c
> > > index 7e844fd8213f..e155126c79b1 100644
> > > --- a/arch/arc/kernel/devtree.c
> > > +++ b/arch/arc/kernel/devtree.c
> > > @@ -28,14 +28,12 @@ unsigned int __init arc_early_base_baud(void)
> > >
> > > static void __init arc_set_early_base_baud(unsigned long dt_root)
> > > {
> > > - unsigned int core_clk = arc_get_core_freq();
> > > -
> > > if (of_flat_dt_is_compatible(dt_root, "abilis,arc-tb10x"))
> > > - arc_base_baud = core_clk/3;
> > > + arc_base_baud = 166666667; /* Fixed 166.7MHz clk (TB10x) */
>
> Actually, (int)core_clk/(int)3 is 166666666 not 166666667.
> I seem to remember that this rounding detail did make a difference at some
> point. Unluckily, the details are long forgotten in the mist of time...
Interesting :)
I did that rounding intentionally hoping for the best.
But so good we've got your valuable input before it's too late.
-Alexey
[toc] | [prev] | [next] | [standalone]
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| Date | 2016-02-02 12:10 +0100 |
| Subject | [PATCH 5/9] ARC: clockevent: DT based probe |
| Message-ID | <qXH0m-1Rh-21@gated-at.bofh.it> |
| In reply to | #1323972 |
- timer frequency is derived from DT (no longer rely on top level
DT "clock-frequency" probed early and exported by asm/clk.h)
- TIMER0_IRQ need not be exported across arch code, confided to intc as
it is property of same
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
arch/arc/include/asm/irq.h | 4 ---
arch/arc/kernel/intc-compact.c | 2 ++
arch/arc/kernel/time.c | 67 ++++++++++++++++++++++++++----------------
3 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/arch/arc/include/asm/irq.h b/arch/arc/include/asm/irq.h
index 0c86f0787bcd..44b6ea85e8fb 100644
--- a/arch/arc/include/asm/irq.h
+++ b/arch/arc/include/asm/irq.h
@@ -14,12 +14,8 @@
/* Platform Independent IRQs */
#ifdef CONFIG_ISA_ARCOMPACT
-#define TIMER0_IRQ 3
-#define TIMER1_IRQ 4
#define IPI_IRQ (NR_CPU_IRQS-1) /* dummy to enable SMP build for up hardware */
#else
-#define TIMER0_IRQ 16
-#define TIMER1_IRQ 17
#define IPI_IRQ 19
#endif
diff --git a/arch/arc/kernel/intc-compact.c b/arch/arc/kernel/intc-compact.c
index 06bcedf19b62..5d390958d233 100644
--- a/arch/arc/kernel/intc-compact.c
+++ b/arch/arc/kernel/intc-compact.c
@@ -14,6 +14,8 @@
#include <linux/irqchip.h>
#include <asm/irq.h>
+#define TIMER0_IRQ 3 /* Fixed by ISA */
+
/*
* Early Hardware specific Interrupt setup
* -Platform independent, needed for each CPU (not foldable into init_IRQ)
diff --git a/arch/arc/kernel/time.c b/arch/arc/kernel/time.c
index 1f5a6fe03bcc..43ef22853473 100644
--- a/arch/arc/kernel/time.c
+++ b/arch/arc/kernel/time.c
@@ -29,22 +29,16 @@
* which however is currently broken
*/
-#include <linux/spinlock.h>
#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <linux/init.h>
-#include <linux/timex.h>
-#include <linux/profile.h>
#include <linux/clk-provider.h>
+#include <linux/clk.h>
#include <linux/clocksource.h>
#include <linux/clockchips.h>
+#include <linux/cpu.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
#include <asm/irq.h>
#include <asm/arcregs.h>
-#include <asm/clk.h>
-#include <asm/mach_desc.h>
#include <asm/mcip.h>
@@ -61,6 +55,24 @@
#define ARC_TIMER_MAX 0xFFFFFFFF
+static unsigned long arc_timer_freq;
+
+static void noinline arc_get_timer_clk(struct device_node *node)
+{
+ struct clk *clk;
+ int ret;
+
+ clk = of_clk_get(node, 0);
+ if (IS_ERR(clk))
+ panic("Can't get timer clock");
+
+ ret = clk_prepare_enable(clk);
+ if (ret)
+ pr_err("Couldn't enable parent clock\n");
+
+ arc_timer_freq = clk_get_rate(clk);
+}
+
/********** Clock Source Device *********/
#ifdef CONFIG_ARC_HAS_GFRC
@@ -184,7 +196,7 @@ static struct clocksource arc_counter = {
/********** Clock Event Device *********/
-static int arc_timer_irq = TIMER0_IRQ;
+static int arc_timer_irq;
/*
* Arm the timer to interrupt after @cycles
@@ -212,7 +224,7 @@ static int arc_clkevent_set_periodic(struct clock_event_device *dev)
* At X Hz, 1 sec = 1000ms -> X cycles;
* 10ms -> X / 100 cycles
*/
- arc_timer_event_setup(arc_get_core_freq() / HZ);
+ arc_timer_event_setup(arc_timer_freq / HZ);
return 0;
}
@@ -221,7 +233,6 @@ static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {
.features = CLOCK_EVT_FEAT_ONESHOT |
CLOCK_EVT_FEAT_PERIODIC,
.rating = 300,
- .irq = TIMER0_IRQ, /* hardwired, no need for resources */
.set_next_event = arc_clkevent_set_next_event,
.set_state_periodic = arc_clkevent_set_periodic,
};
@@ -256,7 +267,7 @@ static int arc_timer_cpu_notify(struct notifier_block *self,
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_STARTING:
- clockevents_config_and_register(evt, arc_get_core_freq(),
+ clockevents_config_and_register(evt, arc_timer_freq,
0, ULONG_MAX);
enable_percpu_irq(arc_timer_irq, 0);
break;
@@ -268,32 +279,41 @@ static int arc_timer_cpu_notify(struct notifier_block *self,
return NOTIFY_OK;
}
-static struct notifier_block nps_timer_cpu_nb = {
+static struct notifier_block arc_timer_cpu_nb = {
.notifier_call = arc_timer_cpu_notify,
};
/*
* clockevent setup for boot CPU
*/
-static void __init arc_clockevent_setup()
+static void __init arc_clockevent_setup(struct device_node *node)
{
struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
+ int ret;
register_cpu_notifier(&arc_timer_cpu_nb);
+ arc_timer_irq = irq_of_parse_and_map(node, 0);
+ if (arc_timer_irq <= 0)
+ panic("Can't parse IRQ");
+
+ arc_get_timer_clk(node);
+
+ evt->irq = arc_timer_irq;
evt->cpumask = cpumask_of(smp_processor_id());
- clockevents_config_and_register(evt, arc_get_core_freq(),
+ clockevents_config_and_register(evt, arc_timer_freq,
0, ARC_TIMER_MAX);
/* setup the per-cpu timer IRQ handler - for all cpus */
- request_percpu_irq(arc_timer_irq, timer_irq_handler,
- "Timer0 (per-cpu-tick)", evt);
+ ret = request_percpu_irq(arc_timer_irq, timer_irq_handler,
+ "Timer0 (per-cpu-tick)", evt);
+ if (ret)
+ pr_err("Unable to register interrupt\n");
enable_percpu_irq(arc_timer_irq, 0);
- if (ret)
- pr_err("Unable to register interrupt\n");
}
+CLOCKSOURCE_OF_DECLARE(arc_clkevt, "snps,arc-timer0", arc_clockevent_setup);
/*
* Called from start_kernel() - boot CPU only
@@ -302,7 +322,6 @@ static void __init arc_clockevent_setup()
* -Also sets up any global state needed for timer subsystem:
* - for "counting" timer, registers a clocksource, usable across CPUs
* (provided that underlying counter h/w is synchronized across cores)
- * - for "event" timer, sets up TIMER0 IRQ (as that is platform agnostic)
*/
void __init time_init(void)
{
@@ -318,7 +337,5 @@ void __init time_init(void)
* CLK upto 4.29 GHz can be safely represented in 32 bits
* because Max 32 bit number is 4,294,967,295
*/
- clocksource_register_hz(&arc_counter, arc_get_core_freq());
-
- arc_clockevent_setup();
+ clocksource_register_hz(&arc_counter, arc_timer_freq);
}
--
2.5.0
[toc] | [prev] | [next] | [standalone]
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| Date | 2016-02-02 12:10 +0100 |
| Subject | [PATCH 8/9] ARC: [plat-axs] Don't use arc_{get|set}_core_freq() for manipulating core clk |
| Message-ID | <qXH0m-1Rh-25@gated-at.bofh.it> |
| In reply to | #1323972 |
From: Alexey Brodkin <abrodkin@synopsys.com>
For AXS103, certain bitfile configurations may not work with stock
"clock-frequency" specified in DT. Instead of duplicating the DT files, we
fixup the DT in-place.
This used to be done differently - as in top level "clock-frequency" was
read very early from FDT and exported using arc_{get|set}_core_freq()
also used in setting up clockevent/clocksource timers
This homebrew clk API served well for legacy timer probe (non DT)
However TIMERS are now probed from DT and use "core_clk" defined in DT,
and thus can no longer use the top level "clock-frequency".
This change reduces the number of users of ARC clk hack and paves way
for removal.
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
[vgupta: broken out of from bigger patch]
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
arch/arc/kernel/setup.c | 12 +++++++-----
arch/arc/plat-axs10x/axs10x.c | 27 +++++++++++++++++++++------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 953068e9c9e1..c35552dca46a 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -24,7 +24,6 @@
#include <asm/page.h>
#include <asm/irq.h>
#include <asm/unwind.h>
-#include <asm/clk.h>
#include <asm/mach_desc.h>
#include <asm/smp.h>
@@ -208,10 +207,6 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
if (tbl->info.id == 0)
n += scnprintf(buf + n, len - n, "UNKNOWN ARC Processor\n");
- n += scnprintf(buf + n, len - n, "CPU speed\t: %u.%02u Mhz\n",
- (unsigned int)(arc_get_core_freq() / 1000000),
- (unsigned int)(arc_get_core_freq() / 10000) % 100);
-
n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ",
IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
IS_AVAIL1(cpu->extn.timer1, "Timer1 "),
@@ -467,6 +462,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)
{
char *str;
int cpu_id = ptr_to_cpu(v);
+ struct device_node *pll = of_find_node_by_name(NULL, "core_clk");
+ u32 freq;
+
+ of_property_read_u32(pll, "clock-frequency", &freq);
if (!cpu_online(cpu_id)) {
seq_printf(m, "processor [%d]\t: Offline\n", cpu_id);
@@ -478,6 +477,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
goto done;
seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE));
+ seq_printf(m, "CPU speed\t: %u.%02u Mhz\n",
+ (unsigned int)(freq / 1000000),
+ (unsigned int)(freq / 10000) % 100);
seq_printf(m, "Bogo MIPS\t: %lu.%02lu\n",
loops_per_jiffy / (500000 / HZ),
diff --git a/arch/arc/plat-axs10x/axs10x.c b/arch/arc/plat-axs10x/axs10x.c
index 1b0f0f458a2b..9701c93f315d 100644
--- a/arch/arc/plat-axs10x/axs10x.c
+++ b/arch/arc/plat-axs10x/axs10x.c
@@ -14,10 +14,11 @@
*
*/
+#include <linux/of_fdt.h>
#include <linux/of_platform.h>
+#include <linux/libfdt.h>
#include <asm/asm-offsets.h>
-#include <asm/clk.h>
#include <asm/io.h>
#include <asm/mach_desc.h>
#include <asm/mcip.h>
@@ -389,6 +390,13 @@ axs103_set_freq(unsigned int id, unsigned int fd, unsigned int od)
static void __init axs103_early_init(void)
{
+ int offset = fdt_path_offset(initial_boot_params, "/cpu_card/core_clk");
+ const struct fdt_property *prop = fdt_get_property(initial_boot_params,
+ offset,
+ "clock-frequency",
+ NULL);
+ u32 freq = be32_to_cpu(*(u32*)(prop->data)) / 1000000, orig = freq;
+
/*
* AXS103 configurations for SMP/QUAD configurations share device tree
* which defaults to 90 MHz. However recent failures of Quad config
@@ -401,12 +409,12 @@ static void __init axs103_early_init(void)
#ifdef CONFIG_ARC_MCIP
unsigned int num_cores = (read_aux_reg(ARC_REG_MCIP_BCR) >> 16) & 0x3F;
if (num_cores > 2)
- arc_set_core_freq(50 * 1000000);
+ freq = 50;
else if (num_cores == 2)
- arc_set_core_freq(75 * 1000000);
+ freq = 75;
#endif
- switch (arc_get_core_freq()/1000000) {
+ switch (freq) {
case 33:
axs103_set_freq(1, 1, 1);
break;
@@ -431,11 +439,18 @@ static void __init axs103_early_init(void)
* DT "clock-frequency" might not match with board value.
* Hence update it to match the board value.
*/
- arc_set_core_freq(axs103_get_freq() * 1000000);
+ freq = axs103_get_freq();
break;
}
- pr_info("Freq is %dMHz\n", axs103_get_freq());
+ pr_info("Freq is %dMHz\n", freq);
+
+ /* Patching .dtb in-place with new core clock value */
+ if (freq != orig ) {
+ freq = cpu_to_be32(freq * 1000000);
+ fdt_setprop_inplace(initial_boot_params, offset,
+ "clock-frequency", &freq, sizeof(freq));
+ }
/* Memory maps already config in pre-bootloader */
--
2.5.0
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web