* [PATCH 1/4] dt-bindings: mrvl,mmp-timer: add clock
2018-09-10 11:30 [PATCH 0/4] Enable the timer clock on DT MMP2 Lubomir Rintel
@ 2018-09-10 11:30 ` Lubomir Rintel
2018-09-10 15:21 ` Rob Herring
2018-09-10 11:30 ` [PATCH 2/4] DT: marvell,mmp2: add clock to the timer Lubomir Rintel
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Lubomir Rintel @ 2018-09-10 11:30 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arm-kernel, devicetree, Daniel Lezcano, Thomas Gleixner,
Rob Herring, Mark Rutland, Eric Miao, Haojian Zhuang,
Russell King, Lubomir Rintel
The timer needs the timer clock to be enabled, otherwise it stops
ticking.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
Documentation/devicetree/bindings/timer/mrvl,mmp-timer.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/timer/mrvl,mmp-timer.txt b/Documentation/devicetree/bindings/timer/mrvl,mmp-timer.txt
index 9a6e251462e7..a2ede0bd12ca 100644
--- a/Documentation/devicetree/bindings/timer/mrvl,mmp-timer.txt
+++ b/Documentation/devicetree/bindings/timer/mrvl,mmp-timer.txt
@@ -4,10 +4,12 @@ Required properties:
- compatible : Should be "mrvl,mmp-timer".
- reg : Address and length of the register set of timer controller.
- interrupts : Should be the interrupt number.
+- clocks : Should contain a single entry describing the clock input.
Example:
timer0: timer@d4014000 {
compatible = "mrvl,mmp-timer";
reg = <0xd4014000 0x100>;
interrupts = <13>;
+ clocks = <&coreclk 2>;
};
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] DT: marvell,mmp2: add clock to the timer
2018-09-10 11:30 [PATCH 0/4] Enable the timer clock on DT MMP2 Lubomir Rintel
2018-09-10 11:30 ` [PATCH 1/4] dt-bindings: mrvl,mmp-timer: add clock Lubomir Rintel
@ 2018-09-10 11:30 ` Lubomir Rintel
2018-09-10 11:30 ` [PATCH 3/4] ARM: mmp2: initialize clocks before " Lubomir Rintel
2018-09-10 11:30 ` [PATCH 4/4] ARM: mmp/mmp2: dt: enable the clock Lubomir Rintel
3 siblings, 0 replies; 7+ messages in thread
From: Lubomir Rintel @ 2018-09-10 11:30 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arm-kernel, devicetree, Daniel Lezcano, Thomas Gleixner,
Rob Herring, Mark Rutland, Eric Miao, Haojian Zhuang,
Russell King, Lubomir Rintel
The timer needs the timer clock to be enabled, otherwise it stops
ticking.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
arch/arm/boot/dts/mmp2.dtsi | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 766bbb8495b6..58e0098a007d 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -130,6 +130,7 @@
compatible = "mrvl,mmp-timer";
reg = <0xd4014000 0x100>;
interrupts = <13>;
+ clocks = <&soc_clocks MMP2_CLK_TIMER>;
};
uart1: uart@d4030000 {
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] ARM: mmp2: initialize clocks before the timer
2018-09-10 11:30 [PATCH 0/4] Enable the timer clock on DT MMP2 Lubomir Rintel
2018-09-10 11:30 ` [PATCH 1/4] dt-bindings: mrvl,mmp-timer: add clock Lubomir Rintel
2018-09-10 11:30 ` [PATCH 2/4] DT: marvell,mmp2: add clock to the timer Lubomir Rintel
@ 2018-09-10 11:30 ` Lubomir Rintel
2018-09-10 11:30 ` [PATCH 4/4] ARM: mmp/mmp2: dt: enable the clock Lubomir Rintel
3 siblings, 0 replies; 7+ messages in thread
From: Lubomir Rintel @ 2018-09-10 11:30 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arm-kernel, devicetree, Daniel Lezcano, Thomas Gleixner,
Rob Herring, Mark Rutland, Eric Miao, Haojian Zhuang,
Russell King, Lubomir Rintel
The timer shall enable its clock.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
arch/arm/mach-mmp/mmp2-dt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-mmp/mmp2-dt.c b/arch/arm/mach-mmp/mmp2-dt.c
index 0341359b24a4..50c5e8b5be3d 100644
--- a/arch/arm/mach-mmp/mmp2-dt.c
+++ b/arch/arm/mach-mmp/mmp2-dt.c
@@ -26,8 +26,8 @@ static void __init mmp_init_time(void)
#ifdef CONFIG_CACHE_TAUROS2
tauros2_init(0);
#endif
- mmp_dt_init_timer();
of_clk_init(NULL);
+ mmp_dt_init_timer();
}
static const char *const mmp2_dt_board_compat[] __initconst = {
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] ARM: mmp/mmp2: dt: enable the clock
2018-09-10 11:30 [PATCH 0/4] Enable the timer clock on DT MMP2 Lubomir Rintel
` (2 preceding siblings ...)
2018-09-10 11:30 ` [PATCH 3/4] ARM: mmp2: initialize clocks before " Lubomir Rintel
@ 2018-09-10 11:30 ` Lubomir Rintel
3 siblings, 0 replies; 7+ messages in thread
From: Lubomir Rintel @ 2018-09-10 11:30 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arm-kernel, devicetree, Daniel Lezcano, Thomas Gleixner,
Rob Herring, Mark Rutland, Eric Miao, Haojian Zhuang,
Russell King, Lubomir Rintel
The device-tree booted MMP2 needs to enable the timer clock, otherwise
the it would stop ticking when the boot finishes.
It can also use the clock rate from the clk, the non-DT boards need to
keep using the hardcoded rates.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
arch/arm/mach-mmp/common.h | 2 +-
arch/arm/mach-mmp/mmp2.c | 2 +-
arch/arm/mach-mmp/pxa168.c | 2 +-
arch/arm/mach-mmp/time.c | 29 +++++++++++++++++------------
4 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-mmp/common.h b/arch/arm/mach-mmp/common.h
index 7e284d9c429f..5ac2851ef5d3 100644
--- a/arch/arm/mach-mmp/common.h
+++ b/arch/arm/mach-mmp/common.h
@@ -2,7 +2,7 @@
#include <linux/reboot.h>
#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
-extern void timer_init(int irq);
+extern void timer_init(int irq, unsigned long rate);
extern void __init mmp_map_io(void);
extern void mmp_restart(enum reboot_mode, const char *);
diff --git a/arch/arm/mach-mmp/mmp2.c b/arch/arm/mach-mmp/mmp2.c
index afba5460cdaf..fb3e7e32c882 100644
--- a/arch/arm/mach-mmp/mmp2.c
+++ b/arch/arm/mach-mmp/mmp2.c
@@ -134,7 +134,7 @@ void __init mmp2_timer_init(void)
clk_rst = APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(1);
__raw_writel(clk_rst, APBC_TIMERS);
- timer_init(IRQ_MMP2_TIMER1);
+ timer_init(IRQ_MMP2_TIMER1, 6500000);
}
/* on-chip devices */
diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c
index 0f5f16fb8c66..77a358165a56 100644
--- a/arch/arm/mach-mmp/pxa168.c
+++ b/arch/arm/mach-mmp/pxa168.c
@@ -79,7 +79,7 @@ void __init pxa168_timer_init(void)
/* 3.25MHz, bus/functional clock enabled, release reset */
__raw_writel(TIMER_CLK_RST, APBC_TIMERS);
- timer_init(IRQ_PXA168_TIMER1);
+ timer_init(IRQ_PXA168_TIMER1, 6500000);
}
void pxa168_clear_keypad_wakeup(void)
diff --git a/arch/arm/mach-mmp/time.c b/arch/arm/mach-mmp/time.c
index 96ad1db0b04b..ed754a8eef79 100644
--- a/arch/arm/mach-mmp/time.c
+++ b/arch/arm/mach-mmp/time.c
@@ -22,6 +22,7 @@
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/clockchips.h>
+#include <linux/clk.h>
#include <linux/io.h>
#include <linux/irq.h>
@@ -38,12 +39,6 @@
#include "cputype.h"
#include "clock.h"
-#ifdef CONFIG_CPU_MMP2
-#define MMP_CLOCK_FREQ 6500000
-#else
-#define MMP_CLOCK_FREQ 3250000
-#endif
-
#define TIMERS_VIRT_BASE TIMERS1_VIRT_BASE
#define MAX_DELTA (0xfffffffe)
@@ -189,19 +184,18 @@ static struct irqaction timer_irq = {
.dev_id = &ckevt,
};
-void __init timer_init(int irq)
+void __init timer_init(int irq, unsigned long rate)
{
timer_config();
- sched_clock_register(mmp_read_sched_clock, 32, MMP_CLOCK_FREQ);
+ sched_clock_register(mmp_read_sched_clock, 32, rate);
ckevt.cpumask = cpumask_of(0);
setup_irq(irq, &timer_irq);
- clocksource_register_hz(&cksrc, MMP_CLOCK_FREQ);
- clockevents_config_and_register(&ckevt, MMP_CLOCK_FREQ,
- MIN_DELTA, MAX_DELTA);
+ clocksource_register_hz(&cksrc, rate);
+ clockevents_config_and_register(&ckevt, rate, MIN_DELTA, MAX_DELTA);
}
#ifdef CONFIG_OF
@@ -213,6 +207,7 @@ static const struct of_device_id mmp_timer_dt_ids[] = {
void __init mmp_dt_init_timer(void)
{
struct device_node *np;
+ struct clk *clk;
int irq, ret;
np = of_find_matching_node(NULL, mmp_timer_dt_ids);
@@ -221,6 +216,16 @@ void __init mmp_dt_init_timer(void)
goto out;
}
+ clk = of_clk_get(np, 0);
+ if (IS_ERR(clk)) {
+ ret = PTR_ERR(clk);
+ goto out;
+ }
+
+ ret = clk_prepare_enable(clk);
+ if (ret)
+ goto out;
+
irq = irq_of_parse_and_map(np, 0);
if (!irq) {
ret = -EINVAL;
@@ -231,7 +236,7 @@ void __init mmp_dt_init_timer(void)
ret = -ENOMEM;
goto out;
}
- timer_init(irq);
+ timer_init(irq, clk_get_rate(clk) / 2);
return;
out:
pr_err("Failed to get timer from device tree with error:%d\n", ret);
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread