linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer
@ 2016-11-28 14:31 Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 01/11] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
                   ` (12 more replies)
  0 siblings, 13 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Hello,

This patch series contain:
- devicetree bindings clarification for rockchip timers
- dts files fixes for rk3228-evb, rk3229-evb and rk3188
- implementation of clocksource for rockchip SoC

The clock supplying the arm-global-timer on the rk3188 is coming from the
the cpu clock itself and thus changes its rate everytime cpufreq adjusts
the cpu frequency making this timer unsuitable as a stable clocksource.
    
The rk3188, rk3288 and following socs share a separate timer block already
handled by the rockchip-timer driver. Therefore adapt this driver to also
be able to act as clocksource on rk3188.
    
In order to test clocksource you can run following commands and check
how much time it take in real. On rk3188 it take about ~45 seconds.
Such error cannot be fixed using NTP. Haven't test clocksource
on rk3288 and onwards. Guess they can also have unstable clocksource.
    
        cpufreq-set -f 1.6GHZ
        date; sleep 60; date

Regards,
Alexander.

This is try 2. Please discard all previous patches:

devicetree:
https://patchwork.ozlabs.org/patch/699019/
https://patchwork.ozlabs.org/patch/699020/

kernel:
https://patchwork.kernel.org/patch/9443975/
https://patchwork.kernel.org/patch/9443971/
https://patchwork.kernel.org/patch/9443959/
https://patchwork.kernel.org/patch/9443963/
https://patchwork.kernel.org/patch/9443979/
https://patchwork.kernel.org/patch/9443989/
https://patchwork.kernel.org/patch/9443987/
https://patchwork.kernel.org/patch/9443977/
https://patchwork.kernel.org/patch/9443991/

Old thread:
http://lists.infradead.org/pipermail/linux-rockchip/2016-November/013147.html

Alexander Kochetkov (11):
  dt-bindings: clarify compatible property for rockchip timers
  ARM: dts: rockchip: update compatible property for rk3228 timer
  ARM: dts: rockchip: update compatible property for rk3229 timer
  ARM: dts: rockchip: add timer entries to rk3188 dtsi
  clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and
    rk_clock_event_device
  clocksource/drivers/rockchip_timer: low level routines take rk_timer
    as parameter
  clocksource/drivers/rockchip_timer: drop unused rk_base() and
    rk_ctrl()
  clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of
    rk_timer_enable()
  clocksource/drivers/rockchip_timer: implement loading 64bit value
    into timer
  clocksource/drivers/rockchip_timer: implement reading 64bit value
    from timer
  clocksource/drivers/rockchip_timer: implement clocksource timer

 .../bindings/timer/rockchip,rk-timer.txt           |   12 +-
 arch/arm/boot/dts/rk3188.dtsi                      |   16 ++
 arch/arm/boot/dts/rk3228-evb.dts                   |    4 +
 arch/arm/boot/dts/rk3229-evb.dts                   |    4 +
 drivers/clocksource/rockchip_timer.c               |  202 +++++++++++++++-----
 5 files changed, 184 insertions(+), 54 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCHv2 01/11] dt-bindings: clarify compatible property for rockchip timers
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 02/11] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Make all properties description in form '"rockchip,<chip>-timer",
"rockchip,rk3288-timer"' for all chips found in linux kernel.

Suggested-by: Heiko Stübner <heiko@sntech.de>
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 .../bindings/timer/rockchip,rk-timer.txt           |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt b/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
index a41b184..16a5f45 100644
--- a/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
+++ b/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
@@ -1,9 +1,15 @@
 Rockchip rk timer
 
 Required properties:
-- compatible: shall be one of:
-  "rockchip,rk3288-timer" - for rk3066, rk3036, rk3188, rk322x, rk3288, rk3368
-  "rockchip,rk3399-timer" - for rk3399
+- compatible: should be:
+  "rockchip,rk3036-timer", "rockchip,rk3288-timer": for Rockchip RK3036
+  "rockchip,rk3066-timer", "rockchip,rk3288-timer": for Rockchip RK3066
+  "rockchip,rk3188-timer", "rockchip,rk3288-timer": for Rockchip RK3188
+  "rockchip,rk3228-timer", "rockchip,rk3288-timer": for Rockchip RK3228
+  "rockchip,rk3229-timer", "rockchip,rk3288-timer": for Rockchip RK3229
+  "rockchip,rk3288-timer": for Rockchip RK3288
+  "rockchip,rk3368-timer", "rockchip,rk3288-timer": for Rockchip RK3368
+  "rockchip,rk3399-timer": for Rockchip RK3399
 - reg: base address of the timer register starting with TIMERS CONTROL register
 - interrupts: should contain the interrupts for Timer0
 - clocks : must contain an entry for each entry in clock-names
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 02/11] ARM: dts: rockchip: update compatible property for rk3228 timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 01/11] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 03/11] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Property set to '"rockchip,rk3228-timer", "rockchip,rk3288-timer"'
to match devicetree bindings.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3228-evb.dts |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
index 904668e..38eab87 100644
--- a/arch/arm/boot/dts/rk3228-evb.dts
+++ b/arch/arm/boot/dts/rk3228-evb.dts
@@ -70,3 +70,7 @@
 &uart2 {
 	status = "okay";
 };
+
+&timer {
+	compatible = "rockchip,rk3228-timer", "rockchip,rk3288-timer";
+};
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 03/11] ARM: dts: rockchip: update compatible property for rk3229 timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 01/11] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 02/11] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 04/11] ARM: dts: rockchip: add timer entries to rk3188 dtsi Alexander Kochetkov
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Property set to '"rockchip,rk3229-timer", "rockchip,rk3288-timer"'
to match devicetree bindings.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3229-evb.dts |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/rk3229-evb.dts b/arch/arm/boot/dts/rk3229-evb.dts
index b6a1203..6629769 100644
--- a/arch/arm/boot/dts/rk3229-evb.dts
+++ b/arch/arm/boot/dts/rk3229-evb.dts
@@ -88,3 +88,7 @@
 &uart2 {
 	status = "okay";
 };
+
+&timer {
+	compatible = "rockchip,rk3229-timer", "rockchip,rk3288-timer";
+};
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 04/11] ARM: dts: rockchip: add timer entries to rk3188 dtsi
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (2 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 03/11] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 05/11] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The patch add two timers to all rk3188 based boards.

The first timer is from alive subsystem and it act as a backup
for the local timers at sleep time. It act the same as timers
on other rockchip chips already present in kernel.

The second timer is from CPU subsystem and act as replacement
for the arm-global-timer clocksource. It run as stable frequency
24MHz.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3188.dtsi |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
index 31f81b2..0dc52fe 100644
--- a/arch/arm/boot/dts/rk3188.dtsi
+++ b/arch/arm/boot/dts/rk3188.dtsi
@@ -106,6 +106,22 @@
 		};
 	};
 
+	timer3: timer@2000e000 {
+		compatible = "rockchip,rk3188-timer", "rockchip,rk3288-timer";
+		reg = <0x2000e000 0x20>;
+		interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TIMER3>, <&cru PCLK_TIMER3>;
+		clock-names = "timer", "pclk";
+	};
+
+	timer6: timer@200380a0 {
+		compatible = "rockchip,rk3188-timer", "rockchip,rk3288-timer";
+		reg = <0x200380a0 0x20>;
+		interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TIMER6>, <&cru PCLK_TIMER0>;
+		clock-names = "timer", "pclk";
+	};
+
 	i2s0: i2s@1011a000 {
 		compatible = "rockchip,rk3188-i2s", "rockchip,rk3066-i2s";
 		reg = <0x1011a000 0x2000>;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 05/11] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (3 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 04/11] ARM: dts: rockchip: add timer entries to rk3188 dtsi Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 06/11] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The patch move ce field out of struct bc_timer into struct
rk_clock_event_device and rename struct bc_timer to struct rk_timer.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 23e267a..6d68d4c 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -29,18 +29,28 @@
 #define TIMER_MODE_USER_DEFINED_COUNT		(1 << 1)
 #define TIMER_INT_UNMASK			(1 << 2)
 
-struct bc_timer {
-	struct clock_event_device ce;
+struct rk_timer {
 	void __iomem *base;
 	void __iomem *ctrl;
 	u32 freq;
 };
 
-static struct bc_timer bc_timer;
+struct rk_clock_event_device {
+	struct clock_event_device ce;
+	struct rk_timer timer;
+};
+
+static struct rk_clock_event_device bc_timer;
+
+static inline struct rk_clock_event_device*
+rk_clock_event_device(struct clock_event_device *ce)
+{
+	return container_of(ce, struct rk_clock_event_device, ce);
+}
 
-static inline struct bc_timer *rk_timer(struct clock_event_device *ce)
+static inline struct rk_timer *rk_timer(struct clock_event_device *ce)
 {
-	return container_of(ce, struct bc_timer, ce);
+	return &rk_clock_event_device(ce)->timer;
 }
 
 static inline void __iomem *rk_base(struct clock_event_device *ce)
@@ -116,16 +126,17 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 {
 	struct clock_event_device *ce = &bc_timer.ce;
+	struct rk_timer *timer = &bc_timer.timer;
 	struct clk *timer_clk;
 	struct clk *pclk;
 	int ret = -EINVAL, irq;
 
-	bc_timer.base = of_iomap(np, 0);
-	if (!bc_timer.base) {
+	timer->base = of_iomap(np, 0);
+	if (!timer->base) {
 		pr_err("Failed to get base address for '%s'\n", TIMER_NAME);
 		return -ENXIO;
 	}
-	bc_timer.ctrl = bc_timer.base + ctrl_reg;
+	timer->ctrl = timer->base + ctrl_reg;
 
 	pclk = of_clk_get_by_name(np, "pclk");
 	if (IS_ERR(pclk)) {
@@ -153,7 +164,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_timer_clk;
 	}
 
-	bc_timer.freq = clk_get_rate(timer_clk);
+	timer->freq = clk_get_rate(timer_clk);
 
 	irq = irq_of_parse_and_map(np, 0);
 	if (!irq) {
@@ -181,7 +192,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_irq;
 	}
 
-	clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX);
+	clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
 
 	return 0;
 
@@ -190,7 +201,7 @@ out_irq:
 out_timer_clk:
 	clk_disable_unprepare(pclk);
 out_unmap:
-	iounmap(bc_timer.base);
+	iounmap(timer->base);
 
 	return ret;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 06/11] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (4 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 05/11] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 07/11] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Pass rk_timer instead of clock_event_device to low lever timer routines.
So that code could be reused by clocksource implementation.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   47 +++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 6d68d4c..aa9ccd1 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -63,60 +63,67 @@ static inline void __iomem *rk_ctrl(struct clock_event_device *ce)
 	return rk_timer(ce)->ctrl;
 }
 
-static inline void rk_timer_disable(struct clock_event_device *ce)
+static inline void rk_timer_disable(struct rk_timer *timer)
 {
-	writel_relaxed(TIMER_DISABLE, rk_ctrl(ce));
+	writel_relaxed(TIMER_DISABLE, timer->ctrl);
 }
 
-static inline void rk_timer_enable(struct clock_event_device *ce, u32 flags)
+static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 {
 	writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
-		       rk_ctrl(ce));
+		       timer->ctrl);
 }
 
 static void rk_timer_update_counter(unsigned long cycles,
-				    struct clock_event_device *ce)
+				    struct rk_timer *timer)
 {
-	writel_relaxed(cycles, rk_base(ce) + TIMER_LOAD_COUNT0);
-	writel_relaxed(0, rk_base(ce) + TIMER_LOAD_COUNT1);
+	writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0);
+	writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1);
 }
 
-static void rk_timer_interrupt_clear(struct clock_event_device *ce)
+static void rk_timer_interrupt_clear(struct rk_timer *timer)
 {
-	writel_relaxed(1, rk_base(ce) + TIMER_INT_STATUS);
+	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
 }
 
 static inline int rk_timer_set_next_event(unsigned long cycles,
 					  struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
-	rk_timer_update_counter(cycles, ce);
-	rk_timer_enable(ce, TIMER_MODE_USER_DEFINED_COUNT);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
+	rk_timer_update_counter(cycles, timer);
+	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT);
 	return 0;
 }
 
 static int rk_timer_shutdown(struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
 	return 0;
 }
 
 static int rk_timer_set_periodic(struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
-	rk_timer_update_counter(rk_timer(ce)->freq / HZ - 1, ce);
-	rk_timer_enable(ce, TIMER_MODE_FREE_RUNNING);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
+	rk_timer_update_counter(timer->freq / HZ - 1, timer);
+	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING);
 	return 0;
 }
 
 static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 {
 	struct clock_event_device *ce = dev_id;
+	struct rk_timer *timer = rk_timer(ce);
 
-	rk_timer_interrupt_clear(ce);
+	rk_timer_interrupt_clear(timer);
 
 	if (clockevent_state_oneshot(ce))
-		rk_timer_disable(ce);
+		rk_timer_disable(timer);
 
 	ce->event_handler(ce);
 
@@ -183,8 +190,8 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 	ce->cpumask = cpu_possible_mask;
 	ce->rating = 250;
 
-	rk_timer_interrupt_clear(ce);
-	rk_timer_disable(ce);
+	rk_timer_interrupt_clear(timer);
+	rk_timer_disable(timer);
 
 	ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
 	if (ret) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 07/11] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl()
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (5 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 06/11] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 08/11] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Use of functions has been ceased by previous commit.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index aa9ccd1..a17dc61 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -53,16 +53,6 @@ static inline struct rk_timer *rk_timer(struct clock_event_device *ce)
 	return &rk_clock_event_device(ce)->timer;
 }
 
-static inline void __iomem *rk_base(struct clock_event_device *ce)
-{
-	return rk_timer(ce)->base;
-}
-
-static inline void __iomem *rk_ctrl(struct clock_event_device *ce)
-{
-	return rk_timer(ce)->ctrl;
-}
-
 static inline void rk_timer_disable(struct rk_timer *timer)
 {
 	writel_relaxed(TIMER_DISABLE, timer->ctrl);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 08/11] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable()
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (6 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 07/11] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 09/11] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer Alexander Kochetkov
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

This allow to enable timer without enabling interrupts from it.
As that mode will be used in clocksource implementation.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index a17dc61..61c3bb1 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -60,8 +60,7 @@ static inline void rk_timer_disable(struct rk_timer *timer)
 
 static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 {
-	writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
-		       timer->ctrl);
+	writel_relaxed(TIMER_ENABLE | flags, timer->ctrl);
 }
 
 static void rk_timer_update_counter(unsigned long cycles,
@@ -83,7 +82,8 @@ static inline int rk_timer_set_next_event(unsigned long cycles,
 
 	rk_timer_disable(timer);
 	rk_timer_update_counter(cycles, timer);
-	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT);
+	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT |
+			       TIMER_INT_UNMASK);
 	return 0;
 }
 
@@ -101,7 +101,7 @@ static int rk_timer_set_periodic(struct clock_event_device *ce)
 
 	rk_timer_disable(timer);
 	rk_timer_update_counter(timer->freq / HZ - 1, timer);
-	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING);
+	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING | TIMER_INT_UNMASK);
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 09/11] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (7 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 08/11] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 10/11] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Alexander Kochetkov
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 61c3bb1..c2b0454 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -63,11 +63,13 @@ static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 	writel_relaxed(TIMER_ENABLE | flags, timer->ctrl);
 }
 
-static void rk_timer_update_counter(unsigned long cycles,
-				    struct rk_timer *timer)
+static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer)
 {
-	writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0);
-	writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1);
+	u32 lower = cycles & 0xFFFFFFFF;
+	u32 upper = (cycles >> 32) & 0xFFFFFFFF;
+
+	writel_relaxed(lower, timer->base + TIMER_LOAD_COUNT0);
+	writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
 }
 
 static void rk_timer_interrupt_clear(struct rk_timer *timer)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 10/11] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (8 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 09/11] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-28 14:31 ` [PATCHv2 11/11] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index c2b0454..6224aa9 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -19,6 +19,8 @@
 
 #define TIMER_LOAD_COUNT0	0x00
 #define TIMER_LOAD_COUNT1	0x04
+#define TIMER_CURRENT_VALUE0	0x08
+#define TIMER_CURRENT_VALUE1	0x0C
 #define TIMER_CONTROL_REG3288	0x10
 #define TIMER_CONTROL_REG3399	0x1c
 #define TIMER_INT_STATUS	0x18
@@ -72,6 +74,25 @@ static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer)
 	writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
 }
 
+static u64 rk_timer_counter_read(struct rk_timer *timer)
+{
+	u64 counter;
+	u32 lower;
+	u32 upper, old_upper;
+
+	upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1);
+	do {
+		old_upper = upper;
+		lower = readl_relaxed(timer->base + TIMER_CURRENT_VALUE0);
+		upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1);
+	} while (upper != old_upper);
+
+	counter = upper;
+	counter <<= 32;
+	counter |= lower;
+	return counter;
+}
+
 static void rk_timer_interrupt_clear(struct rk_timer *timer)
 {
 	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCHv2 11/11] clocksource/drivers/rockchip_timer: implement clocksource timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (9 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 10/11] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Alexander Kochetkov
@ 2016-11-28 14:31 ` Alexander Kochetkov
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-28 14:31 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The clock supplying the arm-global-timer on the rk3188 is coming from the
the cpu clock itself and thus changes its rate everytime cpufreq adjusts
the cpu frequency making this timer unsuitable as a stable clocksource.

The rk3188, rk3288 and following socs share a separate timer block already
handled by the rockchip-timer driver. Therefore adapt this driver to also
be able to act as clocksource on rk3188.

In order to test clocksource you can run following commands and check
how much time it take in real. On rk3188 it take about ~45 seconds.
Such error cannot be fixed using NTP. Haven't test clocksource
on rk3288 and onwards. Guess they can also have unstable clocksource.

    cpufreq-set -f 1.6GHZ
    date; sleep 60; date

In order to use the patch you need to declare two timers in the dts
file. The first timer will be initialized as clockevent provider
and the second one as clocksource. The clockevent must be from
alive subsystem as it used as backup for the local timers at sleep
time.

In order to resolve ambiguity between timers in the device tree,
it is possible to correctly number the timers using "aliases" node.

The patch does not break compatibility with older device tree files.
The older device tree files contain only one timer. The timer
will be initialized as clockevent, as expected.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |  101 ++++++++++++++++++++++++++++------
 1 file changed, 85 insertions(+), 16 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 6224aa9..430b182 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -11,6 +11,7 @@
 #include <linux/clockchips.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -42,7 +43,19 @@ struct rk_clock_event_device {
 	struct rk_timer timer;
 };
 
+struct rk_clocksource {
+	struct clocksource cs;
+	struct rk_timer timer;
+};
+
+enum {
+	ROCKCHIP_CLKSRC_CLOCKEVENT = 0,
+	ROCKCHIP_CLKSRC_CLOCKSOURCE = 1,
+};
+
 static struct rk_clock_event_device bc_timer;
+static struct rk_clocksource cs_timer;
+static int rk_next_clksrc = ROCKCHIP_CLKSRC_CLOCKEVENT;
 
 static inline struct rk_clock_event_device*
 rk_clock_event_device(struct clock_event_device *ce)
@@ -143,13 +156,46 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static cycle_t rk_timer_clocksource_read(struct clocksource *cs)
+{
+	struct rk_clocksource *_cs =
+		container_of(cs, struct rk_clocksource, cs);
+
+	return ~rk_timer_counter_read(&_cs->timer);
+}
+
+static u64 notrace rk_timer_sched_clock_read(void)
+{
+	struct rk_clocksource *_cs = &cs_timer;
+
+	return ~rk_timer_counter_read(&_cs->timer);
+}
+
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 {
-	struct clock_event_device *ce = &bc_timer.ce;
-	struct rk_timer *timer = &bc_timer.timer;
+	struct clock_event_device *ce = NULL;
+	struct clocksource *cs = NULL;
+	struct rk_timer *timer = NULL;
 	struct clk *timer_clk;
 	struct clk *pclk;
 	int ret = -EINVAL, irq;
+	int clksrc;
+
+	clksrc = rk_next_clksrc;
+	rk_next_clksrc++;
+
+	switch (clksrc) {
+	case ROCKCHIP_CLKSRC_CLOCKEVENT:
+		ce = &bc_timer.ce;
+		timer = &bc_timer.timer;
+		break;
+	case ROCKCHIP_CLKSRC_CLOCKSOURCE:
+		cs = &cs_timer.cs;
+		timer = &cs_timer.timer;
+		break;
+	default:
+		return -ENODEV;
+	}
 
 	timer->base = of_iomap(np, 0);
 	if (!timer->base) {
@@ -193,26 +239,49 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_irq;
 	}
 
-	ce->name = TIMER_NAME;
-	ce->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
-		       CLOCK_EVT_FEAT_DYNIRQ;
-	ce->set_next_event = rk_timer_set_next_event;
-	ce->set_state_shutdown = rk_timer_shutdown;
-	ce->set_state_periodic = rk_timer_set_periodic;
-	ce->irq = irq;
-	ce->cpumask = cpu_possible_mask;
-	ce->rating = 250;
+	if (ce) {
+		ce->name = TIMER_NAME;
+		ce->features = CLOCK_EVT_FEAT_PERIODIC |
+			       CLOCK_EVT_FEAT_ONESHOT |
+			       CLOCK_EVT_FEAT_DYNIRQ;
+		ce->set_next_event = rk_timer_set_next_event;
+		ce->set_state_shutdown = rk_timer_shutdown;
+		ce->set_state_periodic = rk_timer_set_periodic;
+		ce->irq = irq;
+		ce->cpumask = cpu_possible_mask;
+		ce->rating = 250;
+	}
+
+	if (cs) {
+		cs->name = TIMER_NAME;
+		cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+		cs->mask = CLOCKSOURCE_MASK(64);
+		cs->read = rk_timer_clocksource_read;
+		cs->rating = 350;
+	}
 
 	rk_timer_interrupt_clear(timer);
 	rk_timer_disable(timer);
 
-	ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
-	if (ret) {
-		pr_err("Failed to initialize '%s': %d\n", TIMER_NAME, ret);
-		goto out_irq;
+	if (ce) {
+		ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER,
+				  TIMER_NAME, ce);
+		if (ret) {
+			pr_err("Failed to initialize '%s': %d\n",
+				TIMER_NAME, ret);
+			goto out_irq;
+		}
+
+		clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
 	}
 
-	clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
+	if (cs) {
+		rk_timer_update_counter(U64_MAX, timer);
+		rk_timer_enable(timer, 0);
+		clocksource_register_hz(cs, timer->freq);
+		sched_clock_register(rk_timer_sched_clock_read, 64,
+				     timer->freq);
+	}
 
 	return 0;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (10 preceding siblings ...)
  2016-11-28 14:31 ` [PATCHv2 11/11] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
@ 2016-11-29 13:45 ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 01/13] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
                     ` (12 more replies)
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  12 siblings, 13 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Hello,

This patch series contain:
- devicetree bindings clarification for rockchip timers
- dts files fixes for rk3228-evb, rk3229-evb and rk3188
- implementation of clocksource for rockchip SoC

The clock supplying the arm-global-timer on the rk3188 is coming from the
the cpu clock itself and thus changes its rate everytime cpufreq adjusts
the cpu frequency making this timer unsuitable as a stable clocksource.

The rk3188, rk3288 and following socs share a separate timer block already
handled by the rockchip-timer driver. Therefore adapt this driver to also
be able to act as clocksource on rk3188.

In order to test clocksource you can run following commands and check
how much time it take in real. On rk3188 it take about ~45 seconds.
Such error cannot be fixed using NTP. Haven't test clocksource
on rk3288 and onwards. Guess they can also have unstable clocksource.

       cpufreq-set -f 1.6GHZ
       date; sleep 60; date

Regards,
Alexander.

Changes in v3:
added patches:
ARM: dts: rockchip: disable arm-global-timer for rk3188
clocksource/drivers/rockchip_timer: Prevent ftrace recursion

This is try 3. Please discard all v1 patches:

devicetree:
https://patchwork.ozlabs.org/patch/699019/
https://patchwork.ozlabs.org/patch/699020/

kernel:
https://patchwork.kernel.org/patch/9443975/
https://patchwork.kernel.org/patch/9443971/
https://patchwork.kernel.org/patch/9443959/
https://patchwork.kernel.org/patch/9443963/
https://patchwork.kernel.org/patch/9443979/
https://patchwork.kernel.org/patch/9443989/
https://patchwork.kernel.org/patch/9443987/
https://patchwork.kernel.org/patch/9443977/
https://patchwork.kernel.org/patch/9443991/

Old thread:
http://lists.infradead.org/pipermail/linux-rockchip/2016-November/013147.html

Alexander Kochetkov (13):
  dt-bindings: clarify compatible property for rockchip timers
  ARM: dts: rockchip: update compatible property for rk3228 timer
  ARM: dts: rockchip: update compatible property for rk3229 timer
  ARM: dts: rockchip: add timer entries to rk3188 dtsi
  ARM: dts: rockchip: disable arm-global-timer for rk3188
  clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and
    rk_clock_event_device
  clocksource/drivers/rockchip_timer: low level routines take rk_timer
    as parameter
  clocksource/drivers/rockchip_timer: drop unused rk_base() and
    rk_ctrl()
  clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of
    rk_timer_enable()
  clocksource/drivers/rockchip_timer: implement loading 64bit value
    into timer
  clocksource/drivers/rockchip_timer: implement reading 64bit value
    from timer
  clocksource/drivers/rockchip_timer: implement clocksource timer
  clocksource/drivers/rockchip_timer: Prevent ftrace recursion

 .../bindings/timer/rockchip,rk-timer.txt           |   12 +-
 arch/arm/boot/dts/rk3188.dtsi                      |   17 ++
 arch/arm/boot/dts/rk3228-evb.dts                   |    4 +
 arch/arm/boot/dts/rk3229-evb.dts                   |    4 +
 drivers/clocksource/rockchip_timer.c               |  207 +++++++++++++++-----
 5 files changed, 190 insertions(+), 54 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH v3 01/13] dt-bindings: clarify compatible property for rockchip timers
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 02/13] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Make all properties description in form '"rockchip,<chip>-timer",
"rockchip,rk3288-timer"' for all chips found in linux kernel.

Suggested-by: Heiko Stübner <heiko@sntech.de>
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 .../bindings/timer/rockchip,rk-timer.txt           |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt b/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
index a41b184..16a5f45 100644
--- a/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
+++ b/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
@@ -1,9 +1,15 @@
 Rockchip rk timer
 
 Required properties:
-- compatible: shall be one of:
-  "rockchip,rk3288-timer" - for rk3066, rk3036, rk3188, rk322x, rk3288, rk3368
-  "rockchip,rk3399-timer" - for rk3399
+- compatible: should be:
+  "rockchip,rk3036-timer", "rockchip,rk3288-timer": for Rockchip RK3036
+  "rockchip,rk3066-timer", "rockchip,rk3288-timer": for Rockchip RK3066
+  "rockchip,rk3188-timer", "rockchip,rk3288-timer": for Rockchip RK3188
+  "rockchip,rk3228-timer", "rockchip,rk3288-timer": for Rockchip RK3228
+  "rockchip,rk3229-timer", "rockchip,rk3288-timer": for Rockchip RK3229
+  "rockchip,rk3288-timer": for Rockchip RK3288
+  "rockchip,rk3368-timer", "rockchip,rk3288-timer": for Rockchip RK3368
+  "rockchip,rk3399-timer": for Rockchip RK3399
 - reg: base address of the timer register starting with TIMERS CONTROL register
 - interrupts: should contain the interrupts for Timer0
 - clocks : must contain an entry for each entry in clock-names
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 02/13] ARM: dts: rockchip: update compatible property for rk3228 timer
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 01/13] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 03/13] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Property set to '"rockchip,rk3228-timer", "rockchip,rk3288-timer"'
to match devicetree bindings.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3228-evb.dts |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
index 904668e..38eab87 100644
--- a/arch/arm/boot/dts/rk3228-evb.dts
+++ b/arch/arm/boot/dts/rk3228-evb.dts
@@ -70,3 +70,7 @@
 &uart2 {
 	status = "okay";
 };
+
+&timer {
+	compatible = "rockchip,rk3228-timer", "rockchip,rk3288-timer";
+};
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 03/13] ARM: dts: rockchip: update compatible property for rk3229 timer
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 01/13] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 02/13] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 04/13] ARM: dts: rockchip: add timer entries to rk3188 dtsi Alexander Kochetkov
                     ` (9 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Property set to '"rockchip,rk3229-timer", "rockchip,rk3288-timer"'
to match devicetree bindings.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3229-evb.dts |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/rk3229-evb.dts b/arch/arm/boot/dts/rk3229-evb.dts
index b6a1203..6629769 100644
--- a/arch/arm/boot/dts/rk3229-evb.dts
+++ b/arch/arm/boot/dts/rk3229-evb.dts
@@ -88,3 +88,7 @@
 &uart2 {
 	status = "okay";
 };
+
+&timer {
+	compatible = "rockchip,rk3229-timer", "rockchip,rk3288-timer";
+};
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 04/13] ARM: dts: rockchip: add timer entries to rk3188 dtsi
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (2 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 03/13] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 05/13] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The patch add two timers to all rk3188 based boards.

The first timer is from alive subsystem and it act as a backup
for the local timers at sleep time. It act the same as timers
on other rockchip chips already present in kernel.

The second timer is from CPU subsystem and act as replacement
for the arm-global-timer clocksource. It run as stable frequency
24MHz.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3188.dtsi |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
index 31f81b2..0dc52fe 100644
--- a/arch/arm/boot/dts/rk3188.dtsi
+++ b/arch/arm/boot/dts/rk3188.dtsi
@@ -106,6 +106,22 @@
 		};
 	};
 
+	timer3: timer@2000e000 {
+		compatible = "rockchip,rk3188-timer", "rockchip,rk3288-timer";
+		reg = <0x2000e000 0x20>;
+		interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TIMER3>, <&cru PCLK_TIMER3>;
+		clock-names = "timer", "pclk";
+	};
+
+	timer6: timer@200380a0 {
+		compatible = "rockchip,rk3188-timer", "rockchip,rk3288-timer";
+		reg = <0x200380a0 0x20>;
+		interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TIMER6>, <&cru PCLK_TIMER0>;
+		clock-names = "timer", "pclk";
+	};
+
 	i2s0: i2s@1011a000 {
 		compatible = "rockchip,rk3188-i2s", "rockchip,rk3066-i2s";
 		reg = <0x1011a000 0x2000>;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 05/13] ARM: dts: rockchip: disable arm-global-timer for rk3188
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (3 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 04/13] ARM: dts: rockchip: add timer entries to rk3188 dtsi Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 06/13] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
                     ` (7 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

arm-global-timer can provide clockevents, clocksource and shed_clock. But
on rk3188 platform it provide only clocksource and shed_clock. clockevents
from  arm-global-timer is not used by kernel because there is another
clockevent provider with higher rating (smp-twd).

My commit from the series implement clocksource and shed_clock using
rockchip_timer. But sched clock from rk_timer is not selected by kernel
due to lower frequency than arm-global-timer, and clocksource from
rk_timer is not selected by kernel due to lower rating than
arm-global-timer. And I don't want to increase clocksource rating
because ratings greater than 300 used for high frequency clocksources.

clocksource and shed_clock is quite unstable, because their rate depends
on cpu frequency. So disable arm-global-timer and use clocksource and
sched_clock from rockchip_timer.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3188.dtsi |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
index 0dc52fe..44da3d42 100644
--- a/arch/arm/boot/dts/rk3188.dtsi
+++ b/arch/arm/boot/dts/rk3188.dtsi
@@ -546,6 +546,7 @@
 
 &global_timer {
 	interrupts = <GIC_PPI 11 0xf04>;
+	status = "disabled";
 };
 
 &local_timer {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 06/13] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (4 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 05/13] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 07/13] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The patch move ce field out of struct bc_timer into struct
rk_clock_event_device and rename struct bc_timer to struct rk_timer.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 23e267a..6d68d4c 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -29,18 +29,28 @@
 #define TIMER_MODE_USER_DEFINED_COUNT		(1 << 1)
 #define TIMER_INT_UNMASK			(1 << 2)
 
-struct bc_timer {
-	struct clock_event_device ce;
+struct rk_timer {
 	void __iomem *base;
 	void __iomem *ctrl;
 	u32 freq;
 };
 
-static struct bc_timer bc_timer;
+struct rk_clock_event_device {
+	struct clock_event_device ce;
+	struct rk_timer timer;
+};
+
+static struct rk_clock_event_device bc_timer;
+
+static inline struct rk_clock_event_device*
+rk_clock_event_device(struct clock_event_device *ce)
+{
+	return container_of(ce, struct rk_clock_event_device, ce);
+}
 
-static inline struct bc_timer *rk_timer(struct clock_event_device *ce)
+static inline struct rk_timer *rk_timer(struct clock_event_device *ce)
 {
-	return container_of(ce, struct bc_timer, ce);
+	return &rk_clock_event_device(ce)->timer;
 }
 
 static inline void __iomem *rk_base(struct clock_event_device *ce)
@@ -116,16 +126,17 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 {
 	struct clock_event_device *ce = &bc_timer.ce;
+	struct rk_timer *timer = &bc_timer.timer;
 	struct clk *timer_clk;
 	struct clk *pclk;
 	int ret = -EINVAL, irq;
 
-	bc_timer.base = of_iomap(np, 0);
-	if (!bc_timer.base) {
+	timer->base = of_iomap(np, 0);
+	if (!timer->base) {
 		pr_err("Failed to get base address for '%s'\n", TIMER_NAME);
 		return -ENXIO;
 	}
-	bc_timer.ctrl = bc_timer.base + ctrl_reg;
+	timer->ctrl = timer->base + ctrl_reg;
 
 	pclk = of_clk_get_by_name(np, "pclk");
 	if (IS_ERR(pclk)) {
@@ -153,7 +164,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_timer_clk;
 	}
 
-	bc_timer.freq = clk_get_rate(timer_clk);
+	timer->freq = clk_get_rate(timer_clk);
 
 	irq = irq_of_parse_and_map(np, 0);
 	if (!irq) {
@@ -181,7 +192,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_irq;
 	}
 
-	clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX);
+	clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
 
 	return 0;
 
@@ -190,7 +201,7 @@ out_irq:
 out_timer_clk:
 	clk_disable_unprepare(pclk);
 out_unmap:
-	iounmap(bc_timer.base);
+	iounmap(timer->base);
 
 	return ret;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 07/13] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (5 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 06/13] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 08/13] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Pass rk_timer instead of clock_event_device to low lever timer routines.
So that code could be reused by clocksource implementation.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   47 +++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 6d68d4c..aa9ccd1 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -63,60 +63,67 @@ static inline void __iomem *rk_ctrl(struct clock_event_device *ce)
 	return rk_timer(ce)->ctrl;
 }
 
-static inline void rk_timer_disable(struct clock_event_device *ce)
+static inline void rk_timer_disable(struct rk_timer *timer)
 {
-	writel_relaxed(TIMER_DISABLE, rk_ctrl(ce));
+	writel_relaxed(TIMER_DISABLE, timer->ctrl);
 }
 
-static inline void rk_timer_enable(struct clock_event_device *ce, u32 flags)
+static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 {
 	writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
-		       rk_ctrl(ce));
+		       timer->ctrl);
 }
 
 static void rk_timer_update_counter(unsigned long cycles,
-				    struct clock_event_device *ce)
+				    struct rk_timer *timer)
 {
-	writel_relaxed(cycles, rk_base(ce) + TIMER_LOAD_COUNT0);
-	writel_relaxed(0, rk_base(ce) + TIMER_LOAD_COUNT1);
+	writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0);
+	writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1);
 }
 
-static void rk_timer_interrupt_clear(struct clock_event_device *ce)
+static void rk_timer_interrupt_clear(struct rk_timer *timer)
 {
-	writel_relaxed(1, rk_base(ce) + TIMER_INT_STATUS);
+	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
 }
 
 static inline int rk_timer_set_next_event(unsigned long cycles,
 					  struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
-	rk_timer_update_counter(cycles, ce);
-	rk_timer_enable(ce, TIMER_MODE_USER_DEFINED_COUNT);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
+	rk_timer_update_counter(cycles, timer);
+	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT);
 	return 0;
 }
 
 static int rk_timer_shutdown(struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
 	return 0;
 }
 
 static int rk_timer_set_periodic(struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
-	rk_timer_update_counter(rk_timer(ce)->freq / HZ - 1, ce);
-	rk_timer_enable(ce, TIMER_MODE_FREE_RUNNING);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
+	rk_timer_update_counter(timer->freq / HZ - 1, timer);
+	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING);
 	return 0;
 }
 
 static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 {
 	struct clock_event_device *ce = dev_id;
+	struct rk_timer *timer = rk_timer(ce);
 
-	rk_timer_interrupt_clear(ce);
+	rk_timer_interrupt_clear(timer);
 
 	if (clockevent_state_oneshot(ce))
-		rk_timer_disable(ce);
+		rk_timer_disable(timer);
 
 	ce->event_handler(ce);
 
@@ -183,8 +190,8 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 	ce->cpumask = cpu_possible_mask;
 	ce->rating = 250;
 
-	rk_timer_interrupt_clear(ce);
-	rk_timer_disable(ce);
+	rk_timer_interrupt_clear(timer);
+	rk_timer_disable(timer);
 
 	ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
 	if (ret) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 08/13] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl()
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (6 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 07/13] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 15:03     ` Heiko Stübner
  2016-11-29 13:45   ` [PATCH v3 09/13] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
                     ` (4 subsequent siblings)
  12 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Use of functions has been ceased by previous commit.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index aa9ccd1..a17dc61 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -53,16 +53,6 @@ static inline struct rk_timer *rk_timer(struct clock_event_device *ce)
 	return &rk_clock_event_device(ce)->timer;
 }
 
-static inline void __iomem *rk_base(struct clock_event_device *ce)
-{
-	return rk_timer(ce)->base;
-}
-
-static inline void __iomem *rk_ctrl(struct clock_event_device *ce)
-{
-	return rk_timer(ce)->ctrl;
-}
-
 static inline void rk_timer_disable(struct rk_timer *timer)
 {
 	writel_relaxed(TIMER_DISABLE, timer->ctrl);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 09/13] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable()
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (7 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 08/13] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 10/13] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer Alexander Kochetkov
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

This allow to enable timer without enabling interrupts from it.
As that mode will be used in clocksource implementation.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index a17dc61..61c3bb1 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -60,8 +60,7 @@ static inline void rk_timer_disable(struct rk_timer *timer)
 
 static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 {
-	writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
-		       timer->ctrl);
+	writel_relaxed(TIMER_ENABLE | flags, timer->ctrl);
 }
 
 static void rk_timer_update_counter(unsigned long cycles,
@@ -83,7 +82,8 @@ static inline int rk_timer_set_next_event(unsigned long cycles,
 
 	rk_timer_disable(timer);
 	rk_timer_update_counter(cycles, timer);
-	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT);
+	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT |
+			       TIMER_INT_UNMASK);
 	return 0;
 }
 
@@ -101,7 +101,7 @@ static int rk_timer_set_periodic(struct clock_event_device *ce)
 
 	rk_timer_disable(timer);
 	rk_timer_update_counter(timer->freq / HZ - 1, timer);
-	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING);
+	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING | TIMER_INT_UNMASK);
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 10/13] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (8 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 09/13] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 11/13] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Alexander Kochetkov
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 61c3bb1..c2b0454 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -63,11 +63,13 @@ static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 	writel_relaxed(TIMER_ENABLE | flags, timer->ctrl);
 }
 
-static void rk_timer_update_counter(unsigned long cycles,
-				    struct rk_timer *timer)
+static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer)
 {
-	writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0);
-	writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1);
+	u32 lower = cycles & 0xFFFFFFFF;
+	u32 upper = (cycles >> 32) & 0xFFFFFFFF;
+
+	writel_relaxed(lower, timer->base + TIMER_LOAD_COUNT0);
+	writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
 }
 
 static void rk_timer_interrupt_clear(struct rk_timer *timer)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 11/13] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (9 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 10/13] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 12/13] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion Alexander Kochetkov
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index c2b0454..6224aa9 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -19,6 +19,8 @@
 
 #define TIMER_LOAD_COUNT0	0x00
 #define TIMER_LOAD_COUNT1	0x04
+#define TIMER_CURRENT_VALUE0	0x08
+#define TIMER_CURRENT_VALUE1	0x0C
 #define TIMER_CONTROL_REG3288	0x10
 #define TIMER_CONTROL_REG3399	0x1c
 #define TIMER_INT_STATUS	0x18
@@ -72,6 +74,25 @@ static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer)
 	writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
 }
 
+static u64 rk_timer_counter_read(struct rk_timer *timer)
+{
+	u64 counter;
+	u32 lower;
+	u32 upper, old_upper;
+
+	upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1);
+	do {
+		old_upper = upper;
+		lower = readl_relaxed(timer->base + TIMER_CURRENT_VALUE0);
+		upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1);
+	} while (upper != old_upper);
+
+	counter = upper;
+	counter <<= 32;
+	counter |= lower;
+	return counter;
+}
+
 static void rk_timer_interrupt_clear(struct rk_timer *timer)
 {
 	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 12/13] clocksource/drivers/rockchip_timer: implement clocksource timer
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (10 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 11/13] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 13:45   ` [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion Alexander Kochetkov
  12 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The clock supplying the arm-global-timer on the rk3188 is coming from the
the cpu clock itself and thus changes its rate everytime cpufreq adjusts
the cpu frequency making this timer unsuitable as a stable clocksource.

The rk3188, rk3288 and following socs share a separate timer block already
handled by the rockchip-timer driver. Therefore adapt this driver to also
be able to act as clocksource on rk3188.

In order to test clocksource you can run following commands and check
how much time it take in real. On rk3188 it take about ~45 seconds.
Such error cannot be fixed using NTP. Haven't test clocksource
on rk3288 and onwards. Guess they can also have unstable clocksource.

    cpufreq-set -f 1.6GHZ
    date; sleep 60; date

In order to use the patch you need to declare two timers in the dts
file. The first timer will be initialized as clockevent provider
and the second one as clocksource. The clockevent must be from
alive subsystem as it used as backup for the local timers at sleep
time.

In order to resolve ambiguity between timers in the device tree,
it is possible to correctly number the timers using "aliases" node.

The patch does not break compatibility with older device tree files.
The older device tree files contain only one timer. The timer
will be initialized as clockevent, as expected.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |  101 ++++++++++++++++++++++++++++------
 1 file changed, 85 insertions(+), 16 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 6224aa9..1af80a0 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -11,6 +11,7 @@
 #include <linux/clockchips.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -42,7 +43,19 @@ struct rk_clock_event_device {
 	struct rk_timer timer;
 };
 
+struct rk_clocksource {
+	struct clocksource cs;
+	struct rk_timer timer;
+};
+
+enum {
+	ROCKCHIP_CLKSRC_CLOCKEVENT = 0,
+	ROCKCHIP_CLKSRC_CLOCKSOURCE = 1,
+};
+
 static struct rk_clock_event_device bc_timer;
+static struct rk_clocksource cs_timer;
+static int rk_next_clksrc = ROCKCHIP_CLKSRC_CLOCKEVENT;
 
 static inline struct rk_clock_event_device*
 rk_clock_event_device(struct clock_event_device *ce)
@@ -143,13 +156,46 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static cycle_t rk_timer_clocksource_read(struct clocksource *cs)
+{
+	struct rk_clocksource *_cs =
+		container_of(cs, struct rk_clocksource, cs);
+
+	return ~rk_timer_counter_read(&_cs->timer);
+}
+
+static u64 notrace rk_timer_sched_clock_read(void)
+{
+	struct rk_clocksource *_cs = &cs_timer;
+
+	return ~rk_timer_counter_read(&_cs->timer);
+}
+
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 {
-	struct clock_event_device *ce = &bc_timer.ce;
-	struct rk_timer *timer = &bc_timer.timer;
+	struct clock_event_device *ce = NULL;
+	struct clocksource *cs = NULL;
+	struct rk_timer *timer = NULL;
 	struct clk *timer_clk;
 	struct clk *pclk;
 	int ret = -EINVAL, irq;
+	int clksrc;
+
+	clksrc = rk_next_clksrc;
+	rk_next_clksrc++;
+
+	switch (clksrc) {
+	case ROCKCHIP_CLKSRC_CLOCKEVENT:
+		ce = &bc_timer.ce;
+		timer = &bc_timer.timer;
+		break;
+	case ROCKCHIP_CLKSRC_CLOCKSOURCE:
+		cs = &cs_timer.cs;
+		timer = &cs_timer.timer;
+		break;
+	default:
+		return -ENODEV;
+	}
 
 	timer->base = of_iomap(np, 0);
 	if (!timer->base) {
@@ -193,26 +239,49 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_irq;
 	}
 
-	ce->name = TIMER_NAME;
-	ce->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
-		       CLOCK_EVT_FEAT_DYNIRQ;
-	ce->set_next_event = rk_timer_set_next_event;
-	ce->set_state_shutdown = rk_timer_shutdown;
-	ce->set_state_periodic = rk_timer_set_periodic;
-	ce->irq = irq;
-	ce->cpumask = cpu_possible_mask;
-	ce->rating = 250;
+	if (ce) {
+		ce->name = TIMER_NAME;
+		ce->features = CLOCK_EVT_FEAT_PERIODIC |
+			       CLOCK_EVT_FEAT_ONESHOT |
+			       CLOCK_EVT_FEAT_DYNIRQ;
+		ce->set_next_event = rk_timer_set_next_event;
+		ce->set_state_shutdown = rk_timer_shutdown;
+		ce->set_state_periodic = rk_timer_set_periodic;
+		ce->irq = irq;
+		ce->cpumask = cpu_possible_mask;
+		ce->rating = 250;
+	}
+
+	if (cs) {
+		cs->name = TIMER_NAME;
+		cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+		cs->mask = CLOCKSOURCE_MASK(64);
+		cs->read = rk_timer_clocksource_read;
+		cs->rating = 250;
+	}
 
 	rk_timer_interrupt_clear(timer);
 	rk_timer_disable(timer);
 
-	ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
-	if (ret) {
-		pr_err("Failed to initialize '%s': %d\n", TIMER_NAME, ret);
-		goto out_irq;
+	if (ce) {
+		ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER,
+				  TIMER_NAME, ce);
+		if (ret) {
+			pr_err("Failed to initialize '%s': %d\n",
+				TIMER_NAME, ret);
+			goto out_irq;
+		}
+
+		clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
 	}
 
-	clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
+	if (cs) {
+		rk_timer_update_counter(U64_MAX, timer);
+		rk_timer_enable(timer, 0);
+		clocksource_register_hz(cs, timer->freq);
+		sched_clock_register(rk_timer_sched_clock_read, 64,
+				     timer->freq);
+	}
 
 	return 0;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (11 preceding siblings ...)
  2016-11-29 13:45   ` [PATCH v3 12/13] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
@ 2016-11-29 13:45   ` Alexander Kochetkov
  2016-11-29 15:01     ` Heiko Stübner
  12 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 13:45 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Currently rockchip_timer can be used as a scheduler clock. We properly
marked rk_timer_sched_clock_read() as notrace but we then call another
function rk_timer_counter_read() that _wasn't_ notrace.

Having a traceable function in the sched_clock() path leads to a recursion
within ftrace and a kernel crash.

Fix this by adding an extra notrace function to keep other users of
rk_timer_counter_read() traceable.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 1af80a0..a127822 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -87,7 +87,7 @@ static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer)
 	writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
 }
 
-static u64 rk_timer_counter_read(struct rk_timer *timer)
+static u64 notrace _rk_timer_counter_read(struct rk_timer *timer)
 {
 	u64 counter;
 	u32 lower;
@@ -106,6 +106,11 @@ static u64 rk_timer_counter_read(struct rk_timer *timer)
 	return counter;
 }
 
+static u64 rk_timer_counter_read(struct rk_timer *timer)
+{
+	return _rk_timer_counter_read(timer);
+}
+
 static void rk_timer_interrupt_clear(struct rk_timer *timer)
 {
 	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
@@ -168,7 +173,7 @@ static u64 notrace rk_timer_sched_clock_read(void)
 {
 	struct rk_clocksource *_cs = &cs_timer;
 
-	return ~rk_timer_counter_read(&_cs->timer);
+	return ~_rk_timer_counter_read(&_cs->timer);
 }
 
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* Re: [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion
  2016-11-29 13:45   ` [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion Alexander Kochetkov
@ 2016-11-29 15:01     ` Heiko Stübner
  2016-11-29 15:36       ` Alexander Kochetkov
  0 siblings, 1 reply; 54+ messages in thread
From: Heiko Stübner @ 2016-11-29 15:01 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao, Daniel Lezcano

Am Dienstag, 29. November 2016, 16:45:18 schrieb Alexander Kochetkov:
> Currently rockchip_timer can be used as a scheduler clock. We properly
> marked rk_timer_sched_clock_read() as notrace but we then call another
> function rk_timer_counter_read() that _wasn't_ notrace.
> 
> Having a traceable function in the sched_clock() path leads to a recursion
> within ftrace and a kernel crash.
> 
> Fix this by adding an extra notrace function to keep other users of
> rk_timer_counter_read() traceable.
> 
> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>

you introduced the issue yourself in patch 11/13. In general any patch should 
never leave the kernel in a worse state than it was before, so no patch should 
ever introduce known issues itself.

In that line of thought, don't patches 10+11 introduce warnings about unused 
functions as well when applied without patch 12?

Maybe merge them?


Heiko

> ---
>  drivers/clocksource/rockchip_timer.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clocksource/rockchip_timer.c
> b/drivers/clocksource/rockchip_timer.c index 1af80a0..a127822 100644
> --- a/drivers/clocksource/rockchip_timer.c
> +++ b/drivers/clocksource/rockchip_timer.c
> @@ -87,7 +87,7 @@ static void rk_timer_update_counter(u64 cycles, struct
> rk_timer *timer) writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
>  }
> 
> -static u64 rk_timer_counter_read(struct rk_timer *timer)
> +static u64 notrace _rk_timer_counter_read(struct rk_timer *timer)
>  {
>  	u64 counter;
>  	u32 lower;
> @@ -106,6 +106,11 @@ static u64 rk_timer_counter_read(struct rk_timer
> *timer) return counter;
>  }
> 
> +static u64 rk_timer_counter_read(struct rk_timer *timer)
> +{
> +	return _rk_timer_counter_read(timer);
> +}
> +
>  static void rk_timer_interrupt_clear(struct rk_timer *timer)
>  {
>  	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
> @@ -168,7 +173,7 @@ static u64 notrace rk_timer_sched_clock_read(void)
>  {
>  	struct rk_clocksource *_cs = &cs_timer;
> 
> -	return ~rk_timer_counter_read(&_cs->timer);
> +	return ~_rk_timer_counter_read(&_cs->timer);
>  }
> 
>  static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v3 08/13] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl()
  2016-11-29 13:45   ` [PATCH v3 08/13] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
@ 2016-11-29 15:03     ` Heiko Stübner
  0 siblings, 0 replies; 54+ messages in thread
From: Heiko Stübner @ 2016-11-29 15:03 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao, Daniel Lezcano

Am Dienstag, 29. November 2016, 16:45:13 schrieb Alexander Kochetkov:
> Use of functions has been ceased by previous commit.

Then why do you need another patch to remove them and don't do that in the 
patch removing their respective usage?

> 
> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
> ---
>  drivers/clocksource/rockchip_timer.c |   10 ----------
>  1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/clocksource/rockchip_timer.c
> b/drivers/clocksource/rockchip_timer.c index aa9ccd1..a17dc61 100644
> --- a/drivers/clocksource/rockchip_timer.c
> +++ b/drivers/clocksource/rockchip_timer.c
> @@ -53,16 +53,6 @@ static inline struct rk_timer *rk_timer(struct
> clock_event_device *ce) return &rk_clock_event_device(ce)->timer;
>  }
> 
> -static inline void __iomem *rk_base(struct clock_event_device *ce)
> -{
> -	return rk_timer(ce)->base;
> -}
> -
> -static inline void __iomem *rk_ctrl(struct clock_event_device *ce)
> -{
> -	return rk_timer(ce)->ctrl;
> -}
> -
>  static inline void rk_timer_disable(struct rk_timer *timer)
>  {
>  	writel_relaxed(TIMER_DISABLE, timer->ctrl);

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion
  2016-11-29 15:01     ` Heiko Stübner
@ 2016-11-29 15:36       ` Alexander Kochetkov
  0 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 15:36 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: LKML, devicetree, LAK, linux-rockchip, Thomas Gleixner,
	Mark Rutland, Rob Herring, Russell King, Caesar Wang, Huang Tao,
	Daniel Lezcano

Hello Heiko!
Thank you for patch review!

> 29 нояб. 2016 г., в 18:01, Heiko Stübner <heiko@sntech.de> написал(а):
> 
> you introduced the issue yourself in patch 11/13. In general any patch should 
> never leave the kernel in a worse state than it was before, so no patch should 
> ever introduce known issues itself.

Agree.

> In that line of thought, don't patches 10+11 introduce warnings about unused 
> functions as well when applied without patch 12?
7 - yes
10 - not
11 - yes

> 29 нояб. 2016 г., в 18:03, Heiko Stübner <heiko@sntech.de> написал(а):
> 
> Then why do you need another patch to remove them and don't do that in the 
> patch removing their respective usage?


To make 7 more readable. Overwise patch messed up and unreadable.
It’s hard to track what going on in the patch.

> Maybe merge them?

I'll merge all of them.

P.S.
here comment from another thead about the patches.
http://lists.infradead.org/pipermail/linux-arm-kernel/2016-November/thread.html#470957

> 29 нояб. 2016 г., в 18:07, Robin Murphy <robin.murphy@arm.com> написал(а):
> 
> 3288 (and probably anything newer) is irrelevant to this discussion, as
> it has the arch timer interface - that may be busted in other ways (such
> as not being correctly set up by firmware and not being always-on as it
> should), but frequency is not one of them. This only affects
> Cortex-A9/A5 based parts.


So I update comments for patches.

Looks, like I study archeology with my patches, as all new ARM chips not
affected by the problem anymore.

Regards,
Alexander.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                   ` (11 preceding siblings ...)
  2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
@ 2016-11-29 16:14 ` Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
                     ` (9 more replies)
  12 siblings, 10 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Hello,

This patch series contain:
- devicetree bindings clarification for rockchip timers
- dts files fixes for rk3228-evb, rk3229-evb and rk3188
- implementation of clocksource and sched clock for rockchip SoC

The clock supplying the arm-global-timer on the rk3188 is coming from the
the cpu clock itself and thus changes its rate everytime cpufreq adjusts
the cpu frequency making this timer unsuitable as a stable clocksource.
    
The rk3188, rk3288 and following socs share a separate timer block already
handled by the rockchip-timer driver. Therefore adapt this driver to also
be able to act as clocksource on rk3188.
    
In order to test clocksource you can run following commands and check
how much time it take in real. On rk3188 it take about ~45 seconds.
    
        cpufreq-set -f 1.6GHZ
        date; sleep 60; date

rk3288 (and probably anything newer) is irrelevant to this patch,
as it has the arch timer interface. This patch may be usefull
for Cortex-A9/A5 based parts.

Regards,
Alexander.

This is try 4. Please discard all v1, v2, v3 patches.

Changes in v4:
merged 7 and 8 from series 3
merged 10, 11, 12, 13 from series 3
fixed commit message

Changes in v3:
added patches:
ARM: dts: rockchip: disable arm-global-timer for rk3188
clocksource/drivers/rockchip_timer: Prevent ftrace recursion

devicetree v1 patches:
https://patchwork.ozlabs.org/patch/699019/
https://patchwork.ozlabs.org/patch/699020/

kernel v1 patches:
https://patchwork.kernel.org/patch/9443975/
https://patchwork.kernel.org/patch/9443971/
https://patchwork.kernel.org/patch/9443959/
https://patchwork.kernel.org/patch/9443963/
https://patchwork.kernel.org/patch/9443979/
https://patchwork.kernel.org/patch/9443989/
https://patchwork.kernel.org/patch/9443987/
https://patchwork.kernel.org/patch/9443977/
https://patchwork.kernel.org/patch/9443991/

Alexander Kochetkov (9):
  dt-bindings: clarify compatible property for rockchip timers
  ARM: dts: rockchip: update compatible property for rk3228 timer
  ARM: dts: rockchip: update compatible property for rk3229 timer
  ARM: dts: rockchip: add timer entries to rk3188 SoC
  ARM: dts: rockchip: disable arm-global-timer for rk3188
  clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and
    rk_clock_event_device
  clocksource/drivers/rockchip_timer: low level routines take rk_timer
    as parameter
  clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of
    rk_timer_enable()
  clocksource/drivers/rockchip_timer: implement clocksource timer

 .../bindings/timer/rockchip,rk-timer.txt           |   12 +-
 arch/arm/boot/dts/rk3188.dtsi                      |   17 ++
 arch/arm/boot/dts/rk3228-evb.dts                   |    4 +
 arch/arm/boot/dts/rk3229-evb.dts                   |    4 +
 drivers/clocksource/rockchip_timer.c               |  207 +++++++++++++++-----
 5 files changed, 190 insertions(+), 54 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2016-12-05 22:22     ` Rob Herring
  2016-11-29 16:14   ` [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Make all properties description in form '"rockchip,<chip>-timer",
"rockchip,rk3288-timer"' for all chips found in linux kernel.

Suggested-by: Heiko Stübner <heiko@sntech.de>
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 .../bindings/timer/rockchip,rk-timer.txt           |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt b/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
index a41b184..16a5f45 100644
--- a/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
+++ b/Documentation/devicetree/bindings/timer/rockchip,rk-timer.txt
@@ -1,9 +1,15 @@
 Rockchip rk timer
 
 Required properties:
-- compatible: shall be one of:
-  "rockchip,rk3288-timer" - for rk3066, rk3036, rk3188, rk322x, rk3288, rk3368
-  "rockchip,rk3399-timer" - for rk3399
+- compatible: should be:
+  "rockchip,rk3036-timer", "rockchip,rk3288-timer": for Rockchip RK3036
+  "rockchip,rk3066-timer", "rockchip,rk3288-timer": for Rockchip RK3066
+  "rockchip,rk3188-timer", "rockchip,rk3288-timer": for Rockchip RK3188
+  "rockchip,rk3228-timer", "rockchip,rk3288-timer": for Rockchip RK3228
+  "rockchip,rk3229-timer", "rockchip,rk3288-timer": for Rockchip RK3229
+  "rockchip,rk3288-timer": for Rockchip RK3288
+  "rockchip,rk3368-timer", "rockchip,rk3288-timer": for Rockchip RK3368
+  "rockchip,rk3399-timer": for Rockchip RK3399
 - reg: base address of the timer register starting with TIMERS CONTROL register
 - interrupts: should contain the interrupts for Timer0
 - clocks : must contain an entry for each entry in clock-names
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2017-01-23 15:40     ` Daniel Lezcano
  2016-11-29 16:14   ` [PATCH v4 3/9] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
                     ` (7 subsequent siblings)
  9 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Property set to '"rockchip,rk3228-timer", "rockchip,rk3288-timer"'
to match devicetree bindings.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3228-evb.dts |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
index 904668e..38eab87 100644
--- a/arch/arm/boot/dts/rk3228-evb.dts
+++ b/arch/arm/boot/dts/rk3228-evb.dts
@@ -70,3 +70,7 @@
 &uart2 {
 	status = "okay";
 };
+
+&timer {
+	compatible = "rockchip,rk3228-timer", "rockchip,rk3288-timer";
+};
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 3/9] ARM: dts: rockchip: update compatible property for rk3229 timer
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 4/9] ARM: dts: rockchip: add timer entries to rk3188 SoC Alexander Kochetkov
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Property set to '"rockchip,rk3229-timer", "rockchip,rk3288-timer"'
to match devicetree bindings.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3229-evb.dts |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/rk3229-evb.dts b/arch/arm/boot/dts/rk3229-evb.dts
index b6a1203..6629769 100644
--- a/arch/arm/boot/dts/rk3229-evb.dts
+++ b/arch/arm/boot/dts/rk3229-evb.dts
@@ -88,3 +88,7 @@
 &uart2 {
 	status = "okay";
 };
+
+&timer {
+	compatible = "rockchip,rk3229-timer", "rockchip,rk3288-timer";
+};
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 4/9] ARM: dts: rockchip: add timer entries to rk3188 SoC
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (2 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 3/9] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 5/9] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The patch add two timers to all rk3188 based boards.

The first timer is from alive subsystem and it act as a backup
for the local timers at sleep time. It act the same as other
SoC rockchip timers already present in kernel.

The second timer is from CPU subsystem and act as replacement
for the arm-global-timer clocksource and sched clock. It run
at stable frequency 24MHz.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3188.dtsi |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
index 31f81b2..0dc52fe 100644
--- a/arch/arm/boot/dts/rk3188.dtsi
+++ b/arch/arm/boot/dts/rk3188.dtsi
@@ -106,6 +106,22 @@
 		};
 	};
 
+	timer3: timer@2000e000 {
+		compatible = "rockchip,rk3188-timer", "rockchip,rk3288-timer";
+		reg = <0x2000e000 0x20>;
+		interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TIMER3>, <&cru PCLK_TIMER3>;
+		clock-names = "timer", "pclk";
+	};
+
+	timer6: timer@200380a0 {
+		compatible = "rockchip,rk3188-timer", "rockchip,rk3288-timer";
+		reg = <0x200380a0 0x20>;
+		interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TIMER6>, <&cru PCLK_TIMER0>;
+		clock-names = "timer", "pclk";
+	};
+
 	i2s0: i2s@1011a000 {
 		compatible = "rockchip,rk3188-i2s", "rockchip,rk3066-i2s";
 		reg = <0x1011a000 0x2000>;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 5/9] ARM: dts: rockchip: disable arm-global-timer for rk3188
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (3 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 4/9] ARM: dts: rockchip: add timer entries to rk3188 SoC Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2017-01-23 16:14     ` Heiko Stübner
  2016-11-29 16:14   ` [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
                     ` (4 subsequent siblings)
  9 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

arm-global-timer can provide clockevents, clocksource and shed_clock. But
on rk3188 platform it provide only clocksource and shed_clock. clockevents
from  arm-global-timer is not used by kernel because there is another
clockevent provider with higher rating (smp-twd).

My commit from the series implement clocksource and shed_clock using
rockchip_timer. But sched clock from rk_timer is not selected by kernel
due to lower frequency than arm-global-timer, and clocksource from
rk_timer is not selected by kernel due to lower rating than
arm-global-timer. And I don't want to increase clocksource rating
because ratings greater 300 used for high frequency clocksources.

clocksource and shed_clock is quite unstable, because their rate depends
on cpu frequency. So disable arm-global-timer and use clocksource and
sched_clock from rockchip_timer.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 arch/arm/boot/dts/rk3188.dtsi |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
index 0dc52fe..44da3d42 100644
--- a/arch/arm/boot/dts/rk3188.dtsi
+++ b/arch/arm/boot/dts/rk3188.dtsi
@@ -546,6 +546,7 @@
 
 &global_timer {
 	interrupts = <GIC_PPI 11 0xf04>;
+	status = "disabled";
 };
 
 &local_timer {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (4 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 5/9] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2017-01-23 16:26     ` Daniel Lezcano
  2016-11-29 16:14   ` [PATCH v4 7/9] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
                     ` (3 subsequent siblings)
  9 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The patch move ce field out of struct bc_timer into struct
rk_clock_event_device and rename struct bc_timer to struct rk_timer.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 23e267a..6d68d4c 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -29,18 +29,28 @@
 #define TIMER_MODE_USER_DEFINED_COUNT		(1 << 1)
 #define TIMER_INT_UNMASK			(1 << 2)
 
-struct bc_timer {
-	struct clock_event_device ce;
+struct rk_timer {
 	void __iomem *base;
 	void __iomem *ctrl;
 	u32 freq;
 };
 
-static struct bc_timer bc_timer;
+struct rk_clock_event_device {
+	struct clock_event_device ce;
+	struct rk_timer timer;
+};
+
+static struct rk_clock_event_device bc_timer;
+
+static inline struct rk_clock_event_device*
+rk_clock_event_device(struct clock_event_device *ce)
+{
+	return container_of(ce, struct rk_clock_event_device, ce);
+}
 
-static inline struct bc_timer *rk_timer(struct clock_event_device *ce)
+static inline struct rk_timer *rk_timer(struct clock_event_device *ce)
 {
-	return container_of(ce, struct bc_timer, ce);
+	return &rk_clock_event_device(ce)->timer;
 }
 
 static inline void __iomem *rk_base(struct clock_event_device *ce)
@@ -116,16 +126,17 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 {
 	struct clock_event_device *ce = &bc_timer.ce;
+	struct rk_timer *timer = &bc_timer.timer;
 	struct clk *timer_clk;
 	struct clk *pclk;
 	int ret = -EINVAL, irq;
 
-	bc_timer.base = of_iomap(np, 0);
-	if (!bc_timer.base) {
+	timer->base = of_iomap(np, 0);
+	if (!timer->base) {
 		pr_err("Failed to get base address for '%s'\n", TIMER_NAME);
 		return -ENXIO;
 	}
-	bc_timer.ctrl = bc_timer.base + ctrl_reg;
+	timer->ctrl = timer->base + ctrl_reg;
 
 	pclk = of_clk_get_by_name(np, "pclk");
 	if (IS_ERR(pclk)) {
@@ -153,7 +164,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_timer_clk;
 	}
 
-	bc_timer.freq = clk_get_rate(timer_clk);
+	timer->freq = clk_get_rate(timer_clk);
 
 	irq = irq_of_parse_and_map(np, 0);
 	if (!irq) {
@@ -181,7 +192,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_irq;
 	}
 
-	clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX);
+	clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
 
 	return 0;
 
@@ -190,7 +201,7 @@ out_irq:
 out_timer_clk:
 	clk_disable_unprepare(pclk);
 out_unmap:
-	iounmap(bc_timer.base);
+	iounmap(timer->base);
 
 	return ret;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 7/9] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (5 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 8/9] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

Pass rk_timer instead of clock_event_device to low lever timer routines.
So that code could be reused by clocksource implementation.

Drop rk_base() and rk_ctrl().

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |   57 ++++++++++++++++------------------
 1 file changed, 27 insertions(+), 30 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 6d68d4c..a17dc61 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -53,70 +53,67 @@ static inline struct rk_timer *rk_timer(struct clock_event_device *ce)
 	return &rk_clock_event_device(ce)->timer;
 }
 
-static inline void __iomem *rk_base(struct clock_event_device *ce)
+static inline void rk_timer_disable(struct rk_timer *timer)
 {
-	return rk_timer(ce)->base;
+	writel_relaxed(TIMER_DISABLE, timer->ctrl);
 }
 
-static inline void __iomem *rk_ctrl(struct clock_event_device *ce)
-{
-	return rk_timer(ce)->ctrl;
-}
-
-static inline void rk_timer_disable(struct clock_event_device *ce)
-{
-	writel_relaxed(TIMER_DISABLE, rk_ctrl(ce));
-}
-
-static inline void rk_timer_enable(struct clock_event_device *ce, u32 flags)
+static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 {
 	writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
-		       rk_ctrl(ce));
+		       timer->ctrl);
 }
 
 static void rk_timer_update_counter(unsigned long cycles,
-				    struct clock_event_device *ce)
+				    struct rk_timer *timer)
 {
-	writel_relaxed(cycles, rk_base(ce) + TIMER_LOAD_COUNT0);
-	writel_relaxed(0, rk_base(ce) + TIMER_LOAD_COUNT1);
+	writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0);
+	writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1);
 }
 
-static void rk_timer_interrupt_clear(struct clock_event_device *ce)
+static void rk_timer_interrupt_clear(struct rk_timer *timer)
 {
-	writel_relaxed(1, rk_base(ce) + TIMER_INT_STATUS);
+	writel_relaxed(1, timer->base + TIMER_INT_STATUS);
 }
 
 static inline int rk_timer_set_next_event(unsigned long cycles,
 					  struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
-	rk_timer_update_counter(cycles, ce);
-	rk_timer_enable(ce, TIMER_MODE_USER_DEFINED_COUNT);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
+	rk_timer_update_counter(cycles, timer);
+	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT);
 	return 0;
 }
 
 static int rk_timer_shutdown(struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
 	return 0;
 }
 
 static int rk_timer_set_periodic(struct clock_event_device *ce)
 {
-	rk_timer_disable(ce);
-	rk_timer_update_counter(rk_timer(ce)->freq / HZ - 1, ce);
-	rk_timer_enable(ce, TIMER_MODE_FREE_RUNNING);
+	struct rk_timer *timer = rk_timer(ce);
+
+	rk_timer_disable(timer);
+	rk_timer_update_counter(timer->freq / HZ - 1, timer);
+	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING);
 	return 0;
 }
 
 static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 {
 	struct clock_event_device *ce = dev_id;
+	struct rk_timer *timer = rk_timer(ce);
 
-	rk_timer_interrupt_clear(ce);
+	rk_timer_interrupt_clear(timer);
 
 	if (clockevent_state_oneshot(ce))
-		rk_timer_disable(ce);
+		rk_timer_disable(timer);
 
 	ce->event_handler(ce);
 
@@ -183,8 +180,8 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 	ce->cpumask = cpu_possible_mask;
 	ce->rating = 250;
 
-	rk_timer_interrupt_clear(ce);
-	rk_timer_disable(ce);
+	rk_timer_interrupt_clear(timer);
+	rk_timer_disable(timer);
 
 	ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
 	if (ret) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 8/9] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable()
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (6 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 7/9] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2016-11-29 16:14   ` [PATCH v4 9/9] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
  2016-12-21 14:21   ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  9 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

This allow to enable timer without enabling interrupts from it.
As that mode will be used in clocksource implementation.

This is refactoring step without functional changes.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index a17dc61..61c3bb1 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -60,8 +60,7 @@ static inline void rk_timer_disable(struct rk_timer *timer)
 
 static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 {
-	writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
-		       timer->ctrl);
+	writel_relaxed(TIMER_ENABLE | flags, timer->ctrl);
 }
 
 static void rk_timer_update_counter(unsigned long cycles,
@@ -83,7 +82,8 @@ static inline int rk_timer_set_next_event(unsigned long cycles,
 
 	rk_timer_disable(timer);
 	rk_timer_update_counter(cycles, timer);
-	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT);
+	rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT |
+			       TIMER_INT_UNMASK);
 	return 0;
 }
 
@@ -101,7 +101,7 @@ static int rk_timer_set_periodic(struct clock_event_device *ce)
 
 	rk_timer_disable(timer);
 	rk_timer_update_counter(timer->freq / HZ - 1, timer);
-	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING);
+	rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING | TIMER_INT_UNMASK);
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH v4 9/9] clocksource/drivers/rockchip_timer: implement clocksource timer
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (7 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 8/9] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
@ 2016-11-29 16:14   ` Alexander Kochetkov
  2017-01-23 17:09     ` Heiko Stübner
  2016-12-21 14:21   ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
  9 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-11-29 16:14 UTC (permalink / raw)
  To: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip
  Cc: Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao, Daniel Lezcano,
	Alexander Kochetkov

The clock supplying the arm-global-timer on the rk3188 is coming from the
the cpu clock itself and thus changes its rate everytime cpufreq adjusts
the cpu frequency making this timer unsuitable as a stable clocksource
and sched clock.

The rk3188, rk3288 and following socs share a separate timer block already
handled by the rockchip-timer driver. Therefore adapt this driver to also
be able to act as clocksource and sched clock on rk3188.

In order to test clocksource you can run following commands and check
how much time it take in real. On rk3188 it take about ~45 seconds.

    cpufreq-set -f 1.6GHZ
    date; sleep 60; date

In order to use the patch you need to declare two timers in the dts
file. The first timer will be initialized as clockevent provider
and the second one as clocksource. The clockevent must be from
alive subsystem as it used as backup for the local timers at sleep
time.

The patch does not break compatibility with older device tree files.
The older device tree files contain only one timer. The timer
will be initialized as clockevent, as expected.

rk3288 (and probably anything newer) is irrelevant to this patch,
as it has the arch timer interface. This patch may be usefull
for Cortex-A9/A5 based parts.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/clocksource/rockchip_timer.c |  137 +++++++++++++++++++++++++++++-----
 1 file changed, 117 insertions(+), 20 deletions(-)

diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index 61c3bb1..a127822 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -11,6 +11,7 @@
 #include <linux/clockchips.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/sched_clock.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -19,6 +20,8 @@
 
 #define TIMER_LOAD_COUNT0	0x00
 #define TIMER_LOAD_COUNT1	0x04
+#define TIMER_CURRENT_VALUE0	0x08
+#define TIMER_CURRENT_VALUE1	0x0C
 #define TIMER_CONTROL_REG3288	0x10
 #define TIMER_CONTROL_REG3399	0x1c
 #define TIMER_INT_STATUS	0x18
@@ -40,7 +43,19 @@ struct rk_clock_event_device {
 	struct rk_timer timer;
 };
 
+struct rk_clocksource {
+	struct clocksource cs;
+	struct rk_timer timer;
+};
+
+enum {
+	ROCKCHIP_CLKSRC_CLOCKEVENT = 0,
+	ROCKCHIP_CLKSRC_CLOCKSOURCE = 1,
+};
+
 static struct rk_clock_event_device bc_timer;
+static struct rk_clocksource cs_timer;
+static int rk_next_clksrc = ROCKCHIP_CLKSRC_CLOCKEVENT;
 
 static inline struct rk_clock_event_device*
 rk_clock_event_device(struct clock_event_device *ce)
@@ -63,11 +78,37 @@ static inline void rk_timer_enable(struct rk_timer *timer, u32 flags)
 	writel_relaxed(TIMER_ENABLE | flags, timer->ctrl);
 }
 
-static void rk_timer_update_counter(unsigned long cycles,
-				    struct rk_timer *timer)
+static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer)
+{
+	u32 lower = cycles & 0xFFFFFFFF;
+	u32 upper = (cycles >> 32) & 0xFFFFFFFF;
+
+	writel_relaxed(lower, timer->base + TIMER_LOAD_COUNT0);
+	writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1);
+}
+
+static u64 notrace _rk_timer_counter_read(struct rk_timer *timer)
 {
-	writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0);
-	writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1);
+	u64 counter;
+	u32 lower;
+	u32 upper, old_upper;
+
+	upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1);
+	do {
+		old_upper = upper;
+		lower = readl_relaxed(timer->base + TIMER_CURRENT_VALUE0);
+		upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1);
+	} while (upper != old_upper);
+
+	counter = upper;
+	counter <<= 32;
+	counter |= lower;
+	return counter;
+}
+
+static u64 rk_timer_counter_read(struct rk_timer *timer)
+{
+	return _rk_timer_counter_read(timer);
 }
 
 static void rk_timer_interrupt_clear(struct rk_timer *timer)
@@ -120,13 +161,46 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static cycle_t rk_timer_clocksource_read(struct clocksource *cs)
+{
+	struct rk_clocksource *_cs =
+		container_of(cs, struct rk_clocksource, cs);
+
+	return ~rk_timer_counter_read(&_cs->timer);
+}
+
+static u64 notrace rk_timer_sched_clock_read(void)
+{
+	struct rk_clocksource *_cs = &cs_timer;
+
+	return ~_rk_timer_counter_read(&_cs->timer);
+}
+
 static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 {
-	struct clock_event_device *ce = &bc_timer.ce;
-	struct rk_timer *timer = &bc_timer.timer;
+	struct clock_event_device *ce = NULL;
+	struct clocksource *cs = NULL;
+	struct rk_timer *timer = NULL;
 	struct clk *timer_clk;
 	struct clk *pclk;
 	int ret = -EINVAL, irq;
+	int clksrc;
+
+	clksrc = rk_next_clksrc;
+	rk_next_clksrc++;
+
+	switch (clksrc) {
+	case ROCKCHIP_CLKSRC_CLOCKEVENT:
+		ce = &bc_timer.ce;
+		timer = &bc_timer.timer;
+		break;
+	case ROCKCHIP_CLKSRC_CLOCKSOURCE:
+		cs = &cs_timer.cs;
+		timer = &cs_timer.timer;
+		break;
+	default:
+		return -ENODEV;
+	}
 
 	timer->base = of_iomap(np, 0);
 	if (!timer->base) {
@@ -170,26 +244,49 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg)
 		goto out_irq;
 	}
 
-	ce->name = TIMER_NAME;
-	ce->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
-		       CLOCK_EVT_FEAT_DYNIRQ;
-	ce->set_next_event = rk_timer_set_next_event;
-	ce->set_state_shutdown = rk_timer_shutdown;
-	ce->set_state_periodic = rk_timer_set_periodic;
-	ce->irq = irq;
-	ce->cpumask = cpu_possible_mask;
-	ce->rating = 250;
+	if (ce) {
+		ce->name = TIMER_NAME;
+		ce->features = CLOCK_EVT_FEAT_PERIODIC |
+			       CLOCK_EVT_FEAT_ONESHOT |
+			       CLOCK_EVT_FEAT_DYNIRQ;
+		ce->set_next_event = rk_timer_set_next_event;
+		ce->set_state_shutdown = rk_timer_shutdown;
+		ce->set_state_periodic = rk_timer_set_periodic;
+		ce->irq = irq;
+		ce->cpumask = cpu_possible_mask;
+		ce->rating = 250;
+	}
+
+	if (cs) {
+		cs->name = TIMER_NAME;
+		cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
+		cs->mask = CLOCKSOURCE_MASK(64);
+		cs->read = rk_timer_clocksource_read;
+		cs->rating = 250;
+	}
 
 	rk_timer_interrupt_clear(timer);
 	rk_timer_disable(timer);
 
-	ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce);
-	if (ret) {
-		pr_err("Failed to initialize '%s': %d\n", TIMER_NAME, ret);
-		goto out_irq;
+	if (ce) {
+		ret = request_irq(irq, rk_timer_interrupt, IRQF_TIMER,
+				  TIMER_NAME, ce);
+		if (ret) {
+			pr_err("Failed to initialize '%s': %d\n",
+				TIMER_NAME, ret);
+			goto out_irq;
+		}
+
+		clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
 	}
 
-	clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX);
+	if (cs) {
+		rk_timer_update_counter(U64_MAX, timer);
+		rk_timer_enable(timer, 0);
+		clocksource_register_hz(cs, timer->freq);
+		sched_clock_register(rk_timer_sched_clock_read, 64,
+				     timer->freq);
+	}
 
 	return 0;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers
  2016-11-29 16:14   ` [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
@ 2016-12-05 22:22     ` Rob Herring
  0 siblings, 0 replies; 54+ messages in thread
From: Rob Herring @ 2016-12-05 22:22 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Heiko Stuebner, Mark Rutland, Russell King,
	Caesar Wang, Huang Tao, Daniel Lezcano

On Tue, Nov 29, 2016 at 07:14:44PM +0300, Alexander Kochetkov wrote:
> Make all properties description in form '"rockchip,<chip>-timer",
> "rockchip,rk3288-timer"' for all chips found in linux kernel.
> 
> Suggested-by: Heiko Stübner <heiko@sntech.de>
> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
> ---
>  .../bindings/timer/rockchip,rk-timer.txt           |   12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
                     ` (8 preceding siblings ...)
  2016-11-29 16:14   ` [PATCH v4 9/9] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
@ 2016-12-21 14:21   ` Alexander Kochetkov
  2017-01-23 14:47     ` Daniel Lezcano
  9 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2016-12-21 14:21 UTC (permalink / raw)
  To: LKML, devicetree, LAK, linux-rockchip, Daniel Lezcano, Heiko Stuebner
  Cc: Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

Hello Heiko, Daniel!

Are there any reasons why the patches [1][2] are not applied yet into kernel?
How can I help in applying patches?

Regards,
Alexander.

[1] http://lists.infradead.org/pipermail/linux-rockchip/2016-November/thread.html#13236
     [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer 
[2] http://lists.infradead.org/pipermail/linux-rockchip/2016-December/013308.html 


> 29 нояб. 2016 г., в 19:14, Alexander Kochetkov <al.kochet@gmail.com> написал(а):
> 
> Hello,
> 
> This patch series contain:
> - devicetree bindings clarification for rockchip timers
> - dts files fixes for rk3228-evb, rk3229-evb and rk3188
> - implementation of clocksource and sched clock for rockchip SoC
> 
> The clock supplying the arm-global-timer on the rk3188 is coming from the
> the cpu clock itself and thus changes its rate everytime cpufreq adjusts
> the cpu frequency making this timer unsuitable as a stable clocksource.
> 
> The rk3188, rk3288 and following socs share a separate timer block already
> handled by the rockchip-timer driver. Therefore adapt this driver to also
> be able to act as clocksource on rk3188.
> 
> In order to test clocksource you can run following commands and check
> how much time it take in real. On rk3188 it take about ~45 seconds.
> 
>        cpufreq-set -f 1.6GHZ
>        date; sleep 60; date
> 
> rk3288 (and probably anything newer) is irrelevant to this patch,
> as it has the arch timer interface. This patch may be usefull
> for Cortex-A9/A5 based parts.
> 
> Regards,
> Alexander.
> 
> This is try 4. Please discard all v1, v2, v3 patches.
> 
> Changes in v4:
> merged 7 and 8 from series 3
> merged 10, 11, 12, 13 from series 3
> fixed commit message
> 
> Changes in v3:
> added patches:
> ARM: dts: rockchip: disable arm-global-timer for rk3188
> clocksource/drivers/rockchip_timer: Prevent ftrace recursion
> 
> devicetree v1 patches:
> https://patchwork.ozlabs.org/patch/699019/
> https://patchwork.ozlabs.org/patch/699020/
> 
> kernel v1 patches:
> https://patchwork.kernel.org/patch/9443975/
> https://patchwork.kernel.org/patch/9443971/
> https://patchwork.kernel.org/patch/9443959/
> https://patchwork.kernel.org/patch/9443963/
> https://patchwork.kernel.org/patch/9443979/
> https://patchwork.kernel.org/patch/9443989/
> https://patchwork.kernel.org/patch/9443987/
> https://patchwork.kernel.org/patch/9443977/
> https://patchwork.kernel.org/patch/9443991/
> 
> Alexander Kochetkov (9):
>  dt-bindings: clarify compatible property for rockchip timers
>  ARM: dts: rockchip: update compatible property for rk3228 timer
>  ARM: dts: rockchip: update compatible property for rk3229 timer
>  ARM: dts: rockchip: add timer entries to rk3188 SoC
>  ARM: dts: rockchip: disable arm-global-timer for rk3188
>  clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and
>    rk_clock_event_device
>  clocksource/drivers/rockchip_timer: low level routines take rk_timer
>    as parameter
>  clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of
>    rk_timer_enable()
>  clocksource/drivers/rockchip_timer: implement clocksource timer
> 
> .../bindings/timer/rockchip,rk-timer.txt           |   12 +-
> arch/arm/boot/dts/rk3188.dtsi                      |   17 ++
> arch/arm/boot/dts/rk3228-evb.dts                   |    4 +
> arch/arm/boot/dts/rk3229-evb.dts                   |    4 +
> drivers/clocksource/rockchip_timer.c               |  207 +++++++++++++++-----
> 5 files changed, 190 insertions(+), 54 deletions(-)
> 
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2016-12-21 14:21   ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
@ 2017-01-23 14:47     ` Daniel Lezcano
  2017-01-23 17:12       ` Heiko Stübner
  0 siblings, 1 reply; 54+ messages in thread
From: Daniel Lezcano @ 2017-01-23 14:47 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: LKML, devicetree, LAK, linux-rockchip, Heiko Stuebner,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

On Wed, Dec 21, 2016 at 05:21:05PM +0300, Alexander Kochetkov wrote:
> Hello Heiko, Daniel!
> 
> Are there any reasons why the patches [1][2] are not applied yet into kernel?
> How can I help in applying patches?

Hi Alexander,

sorry for the delay. Let me review them before taking the patchset.

Heiko, can you have a look to them also ?

Thanks.

  -- Daniel

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer
  2016-11-29 16:14   ` [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
@ 2017-01-23 15:40     ` Daniel Lezcano
  2017-01-23 16:12       ` Heiko Stübner
  2017-01-23 16:13       ` Alexander Kochetkov
  0 siblings, 2 replies; 54+ messages in thread
From: Daniel Lezcano @ 2017-01-23 15:40 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao

On Tue, Nov 29, 2016 at 07:14:45PM +0300, Alexander Kochetkov wrote:
> Property set to '"rockchip,rk3228-timer", "rockchip,rk3288-timer"'
> to match devicetree bindings.
> 
> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
> ---
>  arch/arm/boot/dts/rk3228-evb.dts |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
> index 904668e..38eab87 100644
> --- a/arch/arm/boot/dts/rk3228-evb.dts
> +++ b/arch/arm/boot/dts/rk3228-evb.dts
> @@ -70,3 +70,7 @@
>  &uart2 {
>  	status = "okay";
>  };
> +
> +&timer {
> +	compatible = "rockchip,rk3228-timer", "rockchip,rk3288-timer";
> +};

I'm not sure this is correct, to which timer &timer will refer ?

        timer {
                compatible = "arm,armv7-timer";
		...
	}

        timer: timer@110c0000 {
                compatible = "rockchip,rk3288-timer";
		...
	}

Why not change the compatible string in the timer definition in rk322x.dtsi ?

Same comment for the other patches doing these changes.

  -- Daniel

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer
  2017-01-23 15:40     ` Daniel Lezcano
@ 2017-01-23 16:12       ` Heiko Stübner
  2017-01-23 16:13       ` Alexander Kochetkov
  1 sibling, 0 replies; 54+ messages in thread
From: Heiko Stübner @ 2017-01-23 16:12 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexander Kochetkov, linux-kernel, devicetree, linux-arm-kernel,
	linux-rockchip, Thomas Gleixner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao

Am Montag, 23. Januar 2017, 16:40:46 CET schrieb Daniel Lezcano:
> On Tue, Nov 29, 2016 at 07:14:45PM +0300, Alexander Kochetkov wrote:
> > Property set to '"rockchip,rk3228-timer", "rockchip,rk3288-timer"'
> > to match devicetree bindings.
> > 
> > Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
> > ---
> > 
> >  arch/arm/boot/dts/rk3228-evb.dts |    4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/rk3228-evb.dts
> > b/arch/arm/boot/dts/rk3228-evb.dts index 904668e..38eab87 100644
> > --- a/arch/arm/boot/dts/rk3228-evb.dts
> > +++ b/arch/arm/boot/dts/rk3228-evb.dts
> > @@ -70,3 +70,7 @@
> > 
> >  &uart2 {
> >  
> >  	status = "okay";
> >  
> >  };
> > 
> > +
> > +&timer {
> > +	compatible = "rockchip,rk3228-timer", "rockchip,rk3288-timer";
> > +};
> 
> I'm not sure this is correct, to which timer &timer will refer ?
> 
>         timer {
>                 compatible = "arm,armv7-timer";
> 		...
> 	}
> 
>         timer: timer@110c0000 {
>                 compatible = "rockchip,rk3288-timer";
> 		...
> 	}
> 
> Why not change the compatible string in the timer definition in rk322x.dtsi
> ?
> 
> Same comment for the other patches doing these changes.

I think Alexander didn't know which timer name to use.
Both the rk3228 and rk3229 are so similar that so far no-one has seen any 
difference and thus they really share the whole rk322x.dtsi file.

On the other hand compatibles are supposed to be explicit, so a rk322x-timer 
compatible is not allowed.


But as the socs are soooo similar, I'd suggest just using the rk3228-timer 
compatible in the rk322x.dtsi and not changing individual board files.
Similar to what Daniel suggested.

Heiko

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer
  2017-01-23 15:40     ` Daniel Lezcano
  2017-01-23 16:12       ` Heiko Stübner
@ 2017-01-23 16:13       ` Alexander Kochetkov
  1 sibling, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2017-01-23 16:13 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao

Hello Daniel!

:
> +
> +&timer {
> +	compatible = "rockchip,rk3228-timer", "rockchip,rk3288-timer";
> +};

> 23 янв. 2017 г., в 18:40, Daniel Lezcano <daniel.lezcano@linaro.org> написал(а):
> 
> I'm not sure this is correct, to which timer &timer will refer ?
> 
>        timer {
>                compatible = "arm,armv7-timer";
> 		...
> 	}
> 
>        timer: timer@110c0000 {
>                compatible = "rockchip,rk3288-timer";
> 		...
> 	}

The block '&timer { …}' change compatible string for 'timer: timer@110c0000’ timer'. It refers to it using ’timer:’ label.
'arm,armv7-timer’ has ’timer’ node name without label and cannot be addressed in underline dts files.

> Why not change the compatible string in the timer definition in rk322x.dtsi ?

Initially my patch series was for rk3188 only. I declared rk3188 timer using rk3228 compatible string[1].
Heiko reviewed the series and suggest[2] to use another ‘compatible=‘ binding for rk3188. And
suggest[3] to update rockchip,rk-timer.txt bindings, like mmc/rockchip-dw-mshc.txt does.
So I updated rockchip,rk-timer.txt. rk322x family has has two parts rk3228 and rk3229. So I replaced
rk322x to rk3228 and rk3229 and updated dts file to match bindings.

[1] http://lists.infradead.org/pipermail/linux-rockchip/2016-November/013152.html
[2] http://lists.infradead.org/pipermail/linux-rockchip/2016-November/013174.html
[3] http://lists.infradead.org/pipermail/linux-rockchip/2016-November/013174.html

> Same comment for the other patches doing these changes.
> 
>  -- Daniel

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 5/9] ARM: dts: rockchip: disable arm-global-timer for rk3188
  2016-11-29 16:14   ` [PATCH v4 5/9] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
@ 2017-01-23 16:14     ` Heiko Stübner
  0 siblings, 0 replies; 54+ messages in thread
From: Heiko Stübner @ 2017-01-23 16:14 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao, Daniel Lezcano

Am Dienstag, 29. November 2016, 19:14:48 CET schrieb Alexander Kochetkov:
> arm-global-timer can provide clockevents, clocksource and shed_clock. But
> on rk3188 platform it provide only clocksource and shed_clock. clockevents
> from  arm-global-timer is not used by kernel because there is another
> clockevent provider with higher rating (smp-twd).
> 
> My commit from the series implement clocksource and shed_clock using
> rockchip_timer. But sched clock from rk_timer is not selected by kernel
> due to lower frequency than arm-global-timer, and clocksource from
> rk_timer is not selected by kernel due to lower rating than
> arm-global-timer. And I don't want to increase clocksource rating
> because ratings greater 300 used for high frequency clocksources.
> 
> clocksource and shed_clock is quite unstable, because their rate depends
> on cpu frequency. So disable arm-global-timer and use clocksource and
> sched_clock from rockchip_timer.

That commit message is hard to understand in its entirety, but this last 
paragraph is essentially enough to describe the problem. So maybe you could 
shorten that somehow.


Heiko


> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
> ---
>  arch/arm/boot/dts/rk3188.dtsi |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
> index 0dc52fe..44da3d42 100644
> --- a/arch/arm/boot/dts/rk3188.dtsi
> +++ b/arch/arm/boot/dts/rk3188.dtsi
> @@ -546,6 +546,7 @@
> 
>  &global_timer {
>  	interrupts = <GIC_PPI 11 0xf04>;
> +	status = "disabled";
>  };
> 
>  &local_timer {

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device
  2016-11-29 16:14   ` [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
@ 2017-01-23 16:26     ` Daniel Lezcano
  2017-01-23 16:45       ` Alexander Kochetkov
  0 siblings, 1 reply; 54+ messages in thread
From: Daniel Lezcano @ 2017-01-23 16:26 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Heiko Stuebner, Mark Rutland, Rob Herring,
	Russell King, Caesar Wang, Huang Tao

On Tue, Nov 29, 2016 at 07:14:49PM +0300, Alexander Kochetkov wrote:
> The patch move ce field out of struct bc_timer into struct
> rk_clock_event_device and rename struct bc_timer to struct rk_timer.

Why ?

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device
  2017-01-23 16:26     ` Daniel Lezcano
@ 2017-01-23 16:45       ` Alexander Kochetkov
  0 siblings, 0 replies; 54+ messages in thread
From: Alexander Kochetkov @ 2017-01-23 16:45 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: LKML, devicetree, LAK, linux-rockchip, Thomas Gleixner,
	Heiko Stuebner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

Daniel, thanks for reviewing patches!

> 23 янв. 2017 г., в 19:26, Daniel Lezcano <daniel.lezcano@linaro.org> написал(а):
> 
> On Tue, Nov 29, 2016 at 07:14:49PM +0300, Alexander Kochetkov wrote:
>> The patch move ce field out of struct bc_timer into struct
>> rk_clock_event_device and rename struct bc_timer to struct rk_timer.
> 
> Why ?

Single rockchip timer can be either broadcast timer/clockevent (current implementation) or
clocksource (the one I’ve implemented in series). Both implementations based on
low level timer routines (rk_timer_disable, rk_timer_enable, rk_timer_update_counter, 
rk_timer_counter_read and so on). Both implementations use timers in different modes
(interrupts vs free running). In order to distinguish this concepts I tried to split
low level timer routines from bc_timer.

Otherwise I can place all needed clocksource filelds into 'struct bc_timer’ and rename 'struct bc_timer’
into 'struct rk_timer’. If this is more clear solution I can rewrite patches.

Alexander.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 9/9] clocksource/drivers/rockchip_timer: implement clocksource timer
  2016-11-29 16:14   ` [PATCH v4 9/9] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
@ 2017-01-23 17:09     ` Heiko Stübner
  0 siblings, 0 replies; 54+ messages in thread
From: Heiko Stübner @ 2017-01-23 17:09 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: linux-kernel, devicetree, linux-arm-kernel, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao, Daniel Lezcano

Am Dienstag, 29. November 2016, 19:14:52 CET schrieb Alexander Kochetkov:
> The clock supplying the arm-global-timer on the rk3188 is coming from the
> the cpu clock itself and thus changes its rate everytime cpufreq adjusts
> the cpu frequency making this timer unsuitable as a stable clocksource
> and sched clock.
> 
> The rk3188, rk3288 and following socs share a separate timer block already
> handled by the rockchip-timer driver. Therefore adapt this driver to also
> be able to act as clocksource and sched clock on rk3188.
> 
> In order to test clocksource you can run following commands and check
> how much time it take in real. On rk3188 it take about ~45 seconds.
> 
>     cpufreq-set -f 1.6GHZ
>     date; sleep 60; date
> 
> In order to use the patch you need to declare two timers in the dts
> file. The first timer will be initialized as clockevent provider
> and the second one as clocksource. The clockevent must be from
> alive subsystem as it used as backup for the local timers at sleep
> time.
> 
> The patch does not break compatibility with older device tree files.
> The older device tree files contain only one timer. The timer
> will be initialized as clockevent, as expected.
> 
> rk3288 (and probably anything newer) is irrelevant to this patch,
> as it has the arch timer interface. This patch may be usefull
> for Cortex-A9/A5 based parts.
> 
> Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>

[...]

> @@ -120,13 +161,46 @@ static irqreturn_t rk_timer_interrupt(int irq, void
> *dev_id) return IRQ_HANDLED;
>  }
> 
> +static cycle_t rk_timer_clocksource_read(struct clocksource *cs)
^^
../drivers/clocksource/rockchip_timer.c:164:8: error: unknown type name ‘cycle_t’
 static cycle_t rk_timer_clocksource_read(struct clocksource *cs)

looks like something in clocksources changed since november

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2017-01-23 14:47     ` Daniel Lezcano
@ 2017-01-23 17:12       ` Heiko Stübner
  2017-01-23 17:24         ` Alexander Kochetkov
  0 siblings, 1 reply; 54+ messages in thread
From: Heiko Stübner @ 2017-01-23 17:12 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexander Kochetkov, LKML, devicetree, LAK, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

Am Montag, 23. Januar 2017, 15:47:44 CET schrieb Daniel Lezcano:
> On Wed, Dec 21, 2016 at 05:21:05PM +0300, Alexander Kochetkov wrote:
> > Hello Heiko, Daniel!
> > 
> > Are there any reasons why the patches [1][2] are not applied yet into
> > kernel? How can I help in applying patches?
> 
> Hi Alexander,
> 
> sorry for the delay. Let me review them before taking the patchset.
> 
> Heiko, can you have a look to them also ?

somehow this series moved down to much in my inbox, sorry.

Devicetree changes look good, except where I commented.
I guess it would be best (least intrusive) if I queue up the (then fixed) 
devicetree changes after you are satisfied with the code parts.

I've also looked over the code changes again, test-build them and found the 
build error mentioned separately. Overall they look good though.


Heiko

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2017-01-23 17:12       ` Heiko Stübner
@ 2017-01-23 17:24         ` Alexander Kochetkov
  2017-01-23 17:57           ` Daniel Lezcano
  0 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2017-01-23 17:24 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: Daniel Lezcano, LKML, devicetree, LAK, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

Heiko, Daniel, thanks a lot for review!
I’ll send v5 series this week.

Heiko, Daniel, may I add 'Reviewed-by:’ to patch series?

Reviewed-by: Heiko Stübner <heiko@sntech.de> ?
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> ?

Regards,
Alexander.

> 23 янв. 2017 г., в 20:12, Heiko Stübner <heiko@sntech.de> написал(а):
> 
> Am Montag, 23. Januar 2017, 15:47:44 CET schrieb Daniel Lezcano:
>> On Wed, Dec 21, 2016 at 05:21:05PM +0300, Alexander Kochetkov wrote:
>>> Hello Heiko, Daniel!
>>> 
>>> Are there any reasons why the patches [1][2] are not applied yet into
>>> kernel? How can I help in applying patches?
>> 
>> Hi Alexander,
>> 
>> sorry for the delay. Let me review them before taking the patchset.
>> 
>> Heiko, can you have a look to them also ?
> 
> somehow this series moved down to much in my inbox, sorry.
> 
> Devicetree changes look good, except where I commented.
> I guess it would be best (least intrusive) if I queue up the (then fixed) 
> devicetree changes after you are satisfied with the code parts.
> 
> I've also looked over the code changes again, test-build them and found the 
> build error mentioned separately. Overall they look good though.
> 
> 
> Heiko

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2017-01-23 17:24         ` Alexander Kochetkov
@ 2017-01-23 17:57           ` Daniel Lezcano
  2017-01-26 11:08             ` Alexander Kochetkov
  0 siblings, 1 reply; 54+ messages in thread
From: Daniel Lezcano @ 2017-01-23 17:57 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: Heiko Stübner, LKML, devicetree, LAK, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

On Mon, Jan 23, 2017 at 08:24:47PM +0300, Alexander Kochetkov wrote:
> Heiko, Daniel, thanks a lot for review!
> I’ll send v5 series this week.
> 
> Heiko, Daniel, may I add 'Reviewed-by:’ to patch series?
> 
> Reviewed-by: Heiko Stübner <heiko@sntech.de> ?
> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> ?
> 

I will answer with the corresponding tag myself when you send the v5.

Thanks.

  -- Daniel

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2017-01-23 17:57           ` Daniel Lezcano
@ 2017-01-26 11:08             ` Alexander Kochetkov
  2017-01-26 13:19               ` Daniel Lezcano
  0 siblings, 1 reply; 54+ messages in thread
From: Alexander Kochetkov @ 2017-01-26 11:08 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Heiko Stübner, LKML, devicetree, LAK, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

Hello Daniel!

Sorry for bothering you. Just let you know that I sent v5 here:
http://lists.infradead.org/pipermail/linux-rockchip/2017-January/thread.html#13812

Because previous series was somehow missed in your inbox.

Heiko don’t want to add  "Reviewed-by» to my patches. Could you please
apply the patches without the tag.

Let me know is all ok with series now? Or may be I have to do something else?

Regards,
Alexander.


> 23 янв. 2017 г., в 20:57, Daniel Lezcano <daniel.lezcano@linaro.org> написал(а):
> 
> On Mon, Jan 23, 2017 at 08:24:47PM +0300, Alexander Kochetkov wrote:
>> Heiko, Daniel, thanks a lot for review!
>> I’ll send v5 series this week.
>> 
>> Heiko, Daniel, may I add 'Reviewed-by:’ to patch series?
>> 
>> Reviewed-by: Heiko Stübner <heiko@sntech.de> ?
>> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> ?
>> 
> 
> I will answer with the corresponding tag myself when you send the v5.
> 
> Thanks.
> 
>  -- Daniel
> 
> -- 
> 
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer
  2017-01-26 11:08             ` Alexander Kochetkov
@ 2017-01-26 13:19               ` Daniel Lezcano
  0 siblings, 0 replies; 54+ messages in thread
From: Daniel Lezcano @ 2017-01-26 13:19 UTC (permalink / raw)
  To: Alexander Kochetkov
  Cc: Heiko Stübner, LKML, devicetree, LAK, linux-rockchip,
	Thomas Gleixner, Mark Rutland, Rob Herring, Russell King,
	Caesar Wang, Huang Tao

On Thu, Jan 26, 2017 at 02:08:45PM +0300, Alexander Kochetkov wrote:
> Hello Daniel!
> 
> Sorry for bothering you. Just let you know that I sent v5 here:
> http://lists.infradead.org/pipermail/linux-rockchip/2017-January/thread.html#13812
> 
> Because previous series was somehow missed in your inbox.
> 
> Heiko don’t want to add  "Reviewed-by» to my patches. Could you please
> apply the patches without the tag.
> 
> Let me know is all ok with series now? Or may be I have to do something else?

Alexander,

I think you misinterpreted Heiko's comment. He just want to take the time to
review the driver in details and add himself the reviewed-by tag which is
usually the procedure. I have to review the driver also.

Meanwile you can have a look at https://lkml.org/lkml/2017/1/25/236



-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2017-01-26 13:20 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28 14:31 [PATCHv2 00/11] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 01/11] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 02/11] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 03/11] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 04/11] ARM: dts: rockchip: add timer entries to rk3188 dtsi Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 05/11] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 06/11] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 07/11] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 08/11] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 09/11] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 10/11] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Alexander Kochetkov
2016-11-28 14:31 ` [PATCHv2 11/11] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
2016-11-29 13:45 ` [PATCH v3 00/13] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 01/13] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 02/13] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 03/13] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 04/13] ARM: dts: rockchip: add timer entries to rk3188 dtsi Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 05/13] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 06/13] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 07/13] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 08/13] clocksource/drivers/rockchip_timer: drop unused rk_base() and rk_ctrl() Alexander Kochetkov
2016-11-29 15:03     ` Heiko Stübner
2016-11-29 13:45   ` [PATCH v3 09/13] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 10/13] clocksource/drivers/rockchip_timer: implement loading 64bit value into timer Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 11/13] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 12/13] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
2016-11-29 13:45   ` [PATCH v3 13/13] clocksource/drivers/rockchip_timer: Prevent ftrace recursion Alexander Kochetkov
2016-11-29 15:01     ` Heiko Stübner
2016-11-29 15:36       ` Alexander Kochetkov
2016-11-29 16:14 ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 1/9] dt-bindings: clarify compatible property for rockchip timers Alexander Kochetkov
2016-12-05 22:22     ` Rob Herring
2016-11-29 16:14   ` [PATCH v4 2/9] ARM: dts: rockchip: update compatible property for rk3228 timer Alexander Kochetkov
2017-01-23 15:40     ` Daniel Lezcano
2017-01-23 16:12       ` Heiko Stübner
2017-01-23 16:13       ` Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 3/9] ARM: dts: rockchip: update compatible property for rk3229 timer Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 4/9] ARM: dts: rockchip: add timer entries to rk3188 SoC Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 5/9] ARM: dts: rockchip: disable arm-global-timer for rk3188 Alexander Kochetkov
2017-01-23 16:14     ` Heiko Stübner
2016-11-29 16:14   ` [PATCH v4 6/9] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Alexander Kochetkov
2017-01-23 16:26     ` Daniel Lezcano
2017-01-23 16:45       ` Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 7/9] clocksource/drivers/rockchip_timer: low level routines take rk_timer as parameter Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 8/9] clocksource/drivers/rockchip_timer: move TIMER_INT_UNMASK out of rk_timer_enable() Alexander Kochetkov
2016-11-29 16:14   ` [PATCH v4 9/9] clocksource/drivers/rockchip_timer: implement clocksource timer Alexander Kochetkov
2017-01-23 17:09     ` Heiko Stübner
2016-12-21 14:21   ` [PATCH v4 0/9] Implement clocksource for rockchip SoC using rockchip timer Alexander Kochetkov
2017-01-23 14:47     ` Daniel Lezcano
2017-01-23 17:12       ` Heiko Stübner
2017-01-23 17:24         ` Alexander Kochetkov
2017-01-23 17:57           ` Daniel Lezcano
2017-01-26 11:08             ` Alexander Kochetkov
2017-01-26 13:19               ` Daniel Lezcano

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).