Skip to contentSkip to conversation

: clockevents/clocksource for 3.18

GIT PULL New Daniel Lezcano 1 participant 14 messages Sep 29, 2014

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

Hi Thomas, Ingo,

sorry for sending my PR so late but I have been very busy.

This PR contains the following changes:

* Simon Horman provided the DT soc bindings for the sh_cmt, sh_mtu2
and sh_tmu

* Carlo Caione implemented the driver for the Meson6 with its
documentation

* Gael Portay fixed to unprepare the clock when the irq request fails
and he took the opportunity to replace 'setup_irq' by 'request_irq' for the 'tcb_clrsrc' driver

* Hao Liu disabled the timer before setting it again for the 'sirf' driver

* Michal Simek changed the 'cadence_ttc' timer to make configurable
the counter width (16 and 32), defaulting to 16 which is the current setting

* Nathan Lynch provided a set of cleanup for the architected arm timer
in preparation of the vdso support

* Stefan Agner disabled the 'vf_pit_timer' when the system is entering
in suspend in order to prevent the system to be woken up by the timer

* Sudeep Holla added a check to make sure the mem and the cp15 timers
are available if they are defined in the DT

Thanks !

-- Daniel

The following changes since commit 88299c9bdb109e0d95abdca648065631ff91b2cb:

timerfd: Remove an always true check (2014-08-27 11:17:48 +0200)

are available in the git repository at:

http://git.linaro.org/people/daniel.lezcano/linux.git clockevents/3.18

for you to fetch changes up to 867f667fb9c6734e06cc24e96fc7f06a7e772084:

Merge tag 'renesas-clocksource-for-v3.18' of
git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into clockevents/3.18 (2014-09-29 01:59:51 +0200)

----------------------------------------------------------------

Carlo Caione (2):
ARM: meson: documentation: Add timer documentation
ARM: meson6: clocksource: Add Meson6 timer support

Daniel Lezcano (1):
Merge tag 'renesas-clocksource-for-v3.18' of
git://git.kernel.org/.../horms/renesas into clockevents/3.18

Gael Portay (1):
clocksource: tcb_clksrc: Sanitize IRQ request

Hao Liu (1):
clocksource: sirf: Disable counter before re-setting it

Michal Simek (1):
clocksource: cadence_ttc: Add support for 32bit mode

Nathan Lynch (3):
clocksource: arm_arch_timer: Change clocksource name if CP15
unavailable
clocksource: arm_arch_timer: Enable counter access for 32-bit ARM
clocksource: arm_arch_timer: Consolidate arch_timer_evtstrm_enable

Simon Horman (3):
clocksource: sh_cmt: Document SoC specific bindings
clocksource: sh_mtu2: Document r7s72100 binding
clocksource: sh_tmu: Document r8a7779 binding

Stefan Agner (1):
clocksource: vf_pit_timer: Support shutdown mode

Sudeep Holla (1):
clocksource: arm_arch_timer: Discard unavailable timers correctly

 .../bindings/timer/amlogic,meson6-timer.txt        |  15 ++
 .../devicetree/bindings/timer/renesas,cmt.txt      |  44 +++++-
 .../devicetree/bindings/timer/renesas,mtu2.txt     |   7 +-
 .../devicetree/bindings/timer/renesas,tmu.txt      |   7 +-
 arch/arm/include/asm/arch_timer.h                  |  25 ---
 arch/arm64/include/asm/arch_timer.h                |  31 ----
 drivers/clocksource/Kconfig                        |   3 +
 drivers/clocksource/Makefile                       |   1 +
 drivers/clocksource/arm_arch_timer.c               |  64 +++++++-
 drivers/clocksource/cadence_ttc_timer.c            |  15 +-
 drivers/clocksource/meson6_timer.c                 | 167 
+++++++++++++++++++++
 drivers/clocksource/tcb_clksrc.c                   |  13 +-
 drivers/clocksource/timer-marco.c                  |   5 +-
 drivers/clocksource/vf_pit_timer.c                 |   4 +
 14 files changed, 314 insertions(+), 87 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/timer/amlogic,meson6-timer.txt
 create mode 100644 drivers/clocksource/meson6_timer.c
Signature · 5 lines
 <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
#1 lore raw

PATCH 1/13 clocksource: sh_cmt: Document SoC specific bindings

From: Simon Horman <[email protected]>

In general Renesas hardware is not documented to the extent where the relationship between IP blocks on different SoCs can be assumed although they may appear to operate the same way. Furthermore the documentation typically does not specify a version for individual IP blocks. For these reasons a convention of using the SoC name in place of a version and providing SoC-specific compat strings has been adopted.

Although not universally liked this convention is used in the bindings for a number of drivers for Renesas hardware. The purpose of this patch is to update the Renesas R-Car Compare Match Timer (CMT) driver to follow this convention.

---
* I plan to follow up with patches to use these new bindings in the dtsi files for the affected SoCs.

v2
* Reorder compat entries so more-specific entries and their fallbacks are grouped with the fallback entry coming last.
* Explicitly document fallback

v3
* Avoid circular dependency in documentation of fallback behaviour of renesas,cmt-48-gen2
* Use consistent case for SoC names in compat string descriptions

---
 .../devicetree/bindings/timer/renesas,cmt.txt      | 44 +++++++++++++++++++---
 1 file changed, 38 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +38 -6
index a17418b..1a05c1b 100644
@@ -11,15 +11,47 @@ datasheets.
 
 Required Properties:
 
-  - compatible: must contain one of the following.
-    - "renesas,cmt-32" for the 32-bit CMT
+  - compatible: must contain one or more of the following:
+    - "renesas,cmt-32-r8a7740" for the r8a7740 32-bit CMT
+		(CMT0)
+    - "renesas,cmt-32-sh7372" for the sh7372 32-bit CMT
+		(CMT0)
+    - "renesas,cmt-32-sh73a0" for the sh73a0 32-bit CMT
+		(CMT0)
+    - "renesas,cmt-32" for all 32-bit CMT without fast clock support
 		(CMT0 on sh7372, sh73a0 and r8a7740)
-    - "renesas,cmt-32-fast" for the 32-bit CMT with fast clock support
+		This is a fallback for the above renesas,cmt-32-* entries.
+
+    - "renesas,cmt-32-fast-r8a7740" for the r8a7740 32-bit CMT with fast
+		clock support (CMT[234])
+    - "renesas,cmt-32-fast-sh7372" for the sh7372 32-bit CMT with fast
+		clock support (CMT[234])
+    - "renesas,cmt-32-fast-sh73a0" for the sh73A0 32-bit CMT with fast
+		clock support (CMT[234])
+    - "renesas,cmt-32-fast" for all 32-bit CMT with fast clock support
 		(CMT[234] on sh7372, sh73a0 and r8a7740)
-    - "renesas,cmt-48" for the 48-bit CMT
+		This is a fallback for the above renesas,cmt-32-fast-* entries.
+
+    - "renesas,cmt-48-sh7372" for the sh7372 48-bit CMT
+		(CMT1)
+    - "renesas,cmt-48-sh73a0" for the sh73A0 48-bit CMT
+		(CMT1)
+    - "renesas,cmt-48-r8a7740" for the r8a7740 48-bit CMT
+		(CMT1)
+    - "renesas,cmt-48" for all non-second generation 48-bit CMT
 		(CMT1 on sh7372, sh73a0 and r8a7740)
-    - "renesas,cmt-48-gen2" for the second generation 48-bit CMT
+		This is a fallback for the above renesas,cmt-48-* entries.
+
+    - "renesas,cmt-48-r8a73a4" for the r8a73a4 48-bit CMT
+		(CMT[01])
+    - "renesas,cmt-48-r8a7790" for the r8a7790 48-bit CMT
+		(CMT[01])
+    - "renesas,cmt-48-r8a7791" for the r8a7791 48-bit CMT
+		(CMT[01])
+    - "renesas,cmt-48-gen2" for all second generation 48-bit CMT
 		(CMT[01] on r8a73a4, r8a7790 and r8a7791)
+		This is a fallback for the renesas,cmt-48-r8a73a4,
+		renesas,cmt-48-r8a7790 and renesas,cmt-48-r8a7791 entries.
 
   - reg: base address and length of the registers block for the timer module.
   - interrupts: interrupt-specifier for the timer, one per channel.
@@ -36,7 +68,7 @@ Example: R8A7790 (R-Car H2) CMT0 node
 	them channels 0 and 1 in the documentation.
 
 	cmt0: timer@ffca0000 {
-		compatible = "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
 		reg = <0 0xffca0000 0 0x1004>;
 		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 142 IRQ_TYPE_LEVEL_HIGH>;
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/13 clocksource: sh_tmu: Document r8a7779 binding

From: Simon Horman <[email protected]>

In general Renesas hardware is not documented to the extent where the relationship between IP blocks on different SoCs can be assumed although they may appear to operate the same way. Furthermore the documentation typically does not specify a version for individual IP blocks. For these reasons a convention of using the SoC name in place of a version and providing SoC-specific compat strings has been adopted.

Although not universally liked this convention is used in the bindings for a number of drivers for Renesas hardware. The purpose of this patch is to update the Renesas R-Car Timer Unit (TMU) driver to follow this convention.

---
* I plan to follow up with a patch patch to use the new binding in the dtsi files for the r8a7779 SoC.
commit 471269b790aec03385dc4fb127ed7094ff83c16d

v2
* Suggestions by Mark Rutland and Sergei Shtylyov
- Compatible strings should be "one or more" not "one" of those listed
- Describe the generic binding as covering any MTU2 device
- Re-order compat strings from most to least specific

v3
* Suggested by Laurent Pinchart
- Reword in keeping with a similar though more extensive patch for CMT

---
 Documentation/devicetree/bindings/timer/renesas,tmu.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/timer/renesas,tmu.txt +5 -2
index 425d0c5..7db89fb 100644
@@ -8,7 +8,10 @@ are independent. The TMU hardware supports up to three channels.
 
 Required Properties:
 
-  - compatible: must contain "renesas,tmu"
+  - compatible: must contain one or more of the following:
+    - "renesas,tmu-r8a7779" for the r8a7779 TMU
+    - "renesas,tmu" for any TMU.
+      This is a fallback for the above renesas,tmu-* entries
 
   - reg: base address and length of the registers block for the timer module.
 
@@ -27,7 +30,7 @@ Optional Properties:
 Example: R8A7779 (R-Car H1) TMU0 node
 
 	tmu0: timer@ffd80000 {
-		compatible = "renesas,tmu";
+		compatible = "renesas,tmu-r8a7779", "renesas,tmu";
 		reg = <0xffd80000 0x30>;
 		interrupts = <0 32 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 33 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/13 ARM: meson: documentation: Add timer documentation

In reply to Daniel Lezcano

From: Carlo Caione <[email protected]>

---
 .../devicetree/bindings/timer/amlogic,meson6-timer.txt    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/amlogic,meson6-timer.txt
Documentation/devicetree/bindings/timer/amlogic,meson6-timer.txt new file +15 -0
new file mode 100644
index 0000000..a092053
@@ -0,0 +1,15 @@
+Amlogic Meson6 SoCs Timer Controller
+
+Required properties:
+
+- compatible : should be "amlogic,meson6-timer"
+- reg : Specifies base physical address and size of the registers.
+- interrupts : The interrupt of the first timer
+
+Example:
+
+timer@c1109940 {
+	compatible = "amlogic,meson6-timer";
+	reg = <0xc1109940 0x14>;
+	interrupts = <0 10 1>;
+};
Signature · 1 line
1.9.1
#7 lore raw

PATCH 7/13 clocksource: arm_arch_timer: Discard unavailable timers correctly

In reply to Daniel Lezcano

From: Sudeep Holla <[email protected]>

Currently we wait until both cp15 and mem timers are probed if we have both timer device nodes present in the device tree without checking if the device is actually available. If one of the timer device node present is disabled, the system locks up on the boot as no timer gets registered.

This patch adds the check for the availability of the timer device so that unavailable timers are discarded correctly. It also adds the missing of_node_put.

---
 drivers/clocksource/arm_arch_timer.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/clocksource/arm_arch_timer.c +16 -4
index 5163ec1..7e267e3 100644
@@ -616,17 +616,29 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = {
 	{},
 };
 
+static bool __init
+arch_timer_probed(int type, const struct of_device_id *matches)
+{
+	struct device_node *dn;
+	bool probed = false;
+
+	dn = of_find_matching_node(NULL, matches);
+	if (dn && of_device_is_available(dn) && (arch_timers_present & type))
+		probed = true;
+	of_node_put(dn);
+
+	return probed;
+}
+
 static void __init arch_timer_common_init(void)
 {
 	unsigned mask = ARCH_CP15_TIMER | ARCH_MEM_TIMER;
 
 	/* Wait until both nodes are probed if we have two timers */
 	if ((arch_timers_present & mask) != mask) {
-		if (of_find_matching_node(NULL, arch_timer_mem_of_match) &&
-				!(arch_timers_present & ARCH_MEM_TIMER))
+		if (!arch_timer_probed(ARCH_MEM_TIMER, arch_timer_mem_of_match))
 			return;
-		if (of_find_matching_node(NULL, arch_timer_of_match) &&
-				!(arch_timers_present & ARCH_CP15_TIMER))
+		if (!arch_timer_probed(ARCH_CP15_TIMER, arch_timer_of_match))
 			return;
 	}
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH 6/13 clocksource: vf_pit_timer: Support shutdown mode

In reply to Daniel Lezcano

From: Stefan Agner <[email protected]>

In order to avoid waking up the system in a low power mode, the clocksource should not generate interrupts anymore. Disable the PIT timer interrupt when changing into the CLOCK_EVT_MODE_SHUTDOWN mode.

[dlezcano] : remove superfluous empty line

---
 drivers/clocksource/vf_pit_timer.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clocksource/vf_pit_timer.c +4 -0
index a918bc4..b45ac62 100644
@@ -93,6 +93,10 @@ static void pit_set_mode(enum clock_event_mode mode,
 	case CLOCK_EVT_MODE_PERIODIC:
 		pit_set_next_event(cycle_per_jiffy, evt);
 		break;
+	case CLOCK_EVT_MODE_SHUTDOWN:
+	case CLOCK_EVT_MODE_UNUSED:
+		pit_timer_disable();
+		break;
 	default:
 		break;
 	}
Signature · 1 line
1.9.1
#8 lore raw

PATCH 8/13 clocksource: tcb_clksrc: Sanitize IRQ request

In reply to Daniel Lezcano

From: Gael Portay <[email protected]>

The clock is not unprepared in case of the request IRQ fails.

Also update to request_irq.

---
 drivers/clocksource/tcb_clksrc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/clocksource/tcb_clksrc.c +4 -9
index a8d7ea1..c0b56ea 100644
@@ -178,12 +178,6 @@ static irqreturn_t ch2_irq(int irq, void *handle)
 	return IRQ_NONE;
 }
 
-static struct irqaction tc_irqaction = {
-	.name		= "tc_clkevt",
-	.flags		= IRQF_TIMER,
-	.handler	= ch2_irq,
-};
-
 static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
 {
 	int ret;
@@ -198,15 +192,16 @@ static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
 
 	clkevt.regs = tc->regs;
 	clkevt.clk = t2_clk;
-	tc_irqaction.dev_id = &clkevt;
 
 	timer_clock = clk32k_divisor_idx;
 
 	clkevt.clkevt.cpumask = cpumask_of(0);
 
-	ret = setup_irq(irq, &tc_irqaction);
-	if (ret)
+	ret = request_irq(irq, ch2_irq, IRQF_TIMER, "tc_clkevt", &clkevt);
+	if (ret) {
+		clk_disable_unprepare(t2_clk);
 		return ret;
+	}
 
 	clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
 
Signature · 1 line
1.9.1
#9 lore raw

PATCH 9/13 clocksource: cadence_ttc: Add support for 32bit mode

In reply to Daniel Lezcano

From: Michal Simek <[email protected]>

New TTCs support 32bit mode. Older versions support only 16bit modes. Keep 16bit mode as default and 32bit optional.

---
 drivers/clocksource/cadence_ttc_timer.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/clocksource/cadence_ttc_timer.c +10 -5
index 7a08811..510c8a1 100644
@@ -25,7 +25,7 @@
 #include <linux/sched_clock.h>
 
 /*
- * This driver configures the 2 16-bit count-up timers as follows:
+ * This driver configures the 2 16/32-bit count-up timers as follows:
  *
  * T1: Timer 1, clocksource for generic timekeeping
  * T2: Timer 2, clockevent source for hrtimers
@@ -321,7 +321,8 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
 	return NOTIFY_DONE;
 }
 
-static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
+static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base,
+					 u32 timer_width)
 {
 	struct ttc_timer_clocksource *ttccs;
 	int err;
@@ -351,7 +352,7 @@ static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
 	ttccs->cs.name = "ttc_clocksource";
 	ttccs->cs.rating = 200;
 	ttccs->cs.read = __ttc_clocksource_read;
-	ttccs->cs.mask = CLOCKSOURCE_MASK(16);
+	ttccs->cs.mask = CLOCKSOURCE_MASK(timer_width);
 	ttccs->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
 	/*
@@ -372,7 +373,8 @@ static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
 	}
 
 	ttc_sched_clock_val_reg = base + TTC_COUNT_VAL_OFFSET;
-	sched_clock_register(ttc_sched_clock_read, 16, ttccs->ttc.freq / PRESCALE);
+	sched_clock_register(ttc_sched_clock_read, timer_width,
+			     ttccs->ttc.freq / PRESCALE);
 }
 
 static int ttc_rate_change_clockevent_cb(struct notifier_block *nb,
@@ -467,6 +469,7 @@ static void __init ttc_timer_init(struct device_node *timer)
 	struct clk *clk_cs, *clk_ce;
 	static int initialized;
 	int clksel;
+	u32 timer_width = 16;
 
 	if (initialized)
 		return;
@@ -490,6 +493,8 @@ static void __init ttc_timer_init(struct device_node *timer)
 		BUG();
 	}
 
+	of_property_read_u32(timer, "timer-width", &timer_width);
+
 	clksel = readl_relaxed(timer_baseaddr + TTC_CLK_CNTRL_OFFSET);
 	clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK);
 	clk_cs = of_clk_get(timer, clksel);
@@ -506,7 +511,7 @@ static void __init ttc_timer_init(struct device_node *timer)
 		BUG();
 	}
 
-	ttc_setup_clocksource(clk_cs, timer_baseaddr);
+	ttc_setup_clocksource(clk_cs, timer_baseaddr, timer_width);
 	ttc_setup_clockevent(clk_ce, timer_baseaddr + 4, irq);
 
 	pr_info("%s #0 at %p, irq=%d\n", timer->name, timer_baseaddr, irq);
Signature · 1 line
1.9.1
#12 lore raw

PATCH 12/13 clocksource: arm_arch_timer: Enable counter access for 32-bit ARM

In reply to Daniel Lezcano

From: Nathan Lynch <[email protected]>

The only difference between arm and arm64's implementations of arch_counter_set_user_access is that 32-bit ARM does not enable user access to the virtual counter. We want to enable this access for the 32-bit ARM VDSO, so copy the arm64 version to the driver itself, and remove the arch-specific implementations.

---
 arch/arm/include/asm/arch_timer.h    | 14 --------------
 arch/arm64/include/asm/arch_timer.h  | 17 -----------------
 drivers/clocksource/arm_arch_timer.c | 17 +++++++++++++++++
 3 files changed, 17 insertions(+), 31 deletions(-)
arch/arm/include/asm/arch_timer.h +0 -14
index 0704e0c..b7ae444 100644
@@ -99,20 +99,6 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
 	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
 }
 
-static inline void arch_counter_set_user_access(void)
-{
-	u32 cntkctl = arch_timer_get_cntkctl();
-
-	/* Disable user access to both physical/virtual counters/timers */
-	/* Also disable virtual event stream */
-	cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
-			| ARCH_TIMER_USR_VT_ACCESS_EN
-			| ARCH_TIMER_VIRT_EVT_EN
-			| ARCH_TIMER_USR_VCT_ACCESS_EN
-			| ARCH_TIMER_USR_PCT_ACCESS_EN);
-	arch_timer_set_cntkctl(cntkctl);
-}
-
 static inline void arch_timer_evtstrm_enable(int divider)
 {
 	u32 cntkctl = arch_timer_get_cntkctl();
arch/arm64/include/asm/arch_timer.h +0 -17
index 9400596..49e94c6 100644
@@ -104,23 +104,6 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
 	asm volatile("msr	cntkctl_el1, %0" : : "r" (cntkctl));
 }
 
-static inline void arch_counter_set_user_access(void)
-{
-	u32 cntkctl = arch_timer_get_cntkctl();
-
-	/* Disable user access to the timers and the physical counter */
-	/* Also disable virtual event stream */
-	cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
-			| ARCH_TIMER_USR_VT_ACCESS_EN
-			| ARCH_TIMER_VIRT_EVT_EN
-			| ARCH_TIMER_USR_PCT_ACCESS_EN);
-
-	/* Enable user access to the virtual counter */
-	cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
-
-	arch_timer_set_cntkctl(cntkctl);
-}
-
 static inline void arch_timer_evtstrm_enable(int divider)
 {
 	u32 cntkctl = arch_timer_get_cntkctl();
drivers/clocksource/arm_arch_timer.c +17 -0
index e0e7729..42bd445 100644
@@ -312,6 +312,23 @@ static void arch_timer_configure_evtstream(void)
 	arch_timer_evtstrm_enable(min(pos, 15));
 }
 
+static void arch_counter_set_user_access(void)
+{
+	u32 cntkctl = arch_timer_get_cntkctl();
+
+	/* Disable user access to the timers and the physical counter */
+	/* Also disable virtual event stream */
+	cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
+			| ARCH_TIMER_USR_VT_ACCESS_EN
+			| ARCH_TIMER_VIRT_EVT_EN
+			| ARCH_TIMER_USR_PCT_ACCESS_EN);
+
+	/* Enable user access to the virtual counter */
+	cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
+
+	arch_timer_set_cntkctl(cntkctl);
+}
+
 static int arch_timer_setup(struct clock_event_device *clk)
 {
 	__arch_timer_setup(ARCH_CP15_TIMER, clk);
Signature · 1 line
1.9.1
#10 lore raw

PATCH 10/13 clocksource: sirf: Disable counter before re-setting it

In reply to Daniel Lezcano

From: Hao Liu <[email protected]>

According to HW spec, we have to disable the counter before setting it, if we don't this, in pressure test, sometimes the timer might not generate interrupt any more.

And this patch also fixes a typo for register set by changing 0x7 to 0x3. 0x7 is loop mode in HW, but here we are using oneshot 0x3.

---
 drivers/clocksource/timer-marco.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/timer-marco.c +4 -1
index 330e930..caf7a20 100644
@@ -63,7 +63,7 @@ static inline void sirfsoc_timer_count_disable(int idx)
 /* enable count and interrupt */
 static inline void sirfsoc_timer_count_enable(int idx)
 {
-	writel_relaxed(readl_relaxed(sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL + 4 * idx) | 0x7,
+	writel_relaxed(readl_relaxed(sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL + 4 * idx) | 0x3,
 		sirfsoc_timer_base + SIRFSOC_TIMER_32COUNTER_0_CTRL + 4 * idx);
 }
 
@@ -103,6 +103,9 @@ static int sirfsoc_timer_set_next_event(unsigned long delta,
 {
 	int cpu = smp_processor_id();
 
+	/* disable timer first, then modify the related registers */
+	sirfsoc_timer_count_disable(cpu);
+
 	writel_relaxed(0, sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_0 +
 		4 * cpu);
 	writel_relaxed(delta, sirfsoc_timer_base + SIRFSOC_TIMER_MATCH_0 +
Signature · 1 line
1.9.1
#11 lore raw

PATCH 11/13 clocksource: arm_arch_timer: Change clocksource name if CP15 unavailable

In reply to Daniel Lezcano

From: Nathan Lynch <[email protected]>

The arm and arm64 VDSOs need CP15 access to the architected counter. If this is unavailable (which is allowed by ARM v7), indicate this by changing the clocksource name to "arch_mem_counter" before registering the clocksource.

Suggested by Stephen Boyd.

---
 drivers/clocksource/arm_arch_timer.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clocksource/arm_arch_timer.c +10 -2
index 7e267e3..e0e7729 100644
@@ -429,11 +429,19 @@ static void __init arch_counter_register(unsigned type)
 	u64 start_count;
 
 	/* Register the CP15 based counter if we have one */
-	if (type & ARCH_CP15_TIMER)
+	if (type & ARCH_CP15_TIMER) {
 		arch_timer_read_counter = arch_counter_get_cntvct;
-	else
+	} else {
 		arch_timer_read_counter = arch_counter_get_cntvct_mem;
 
+		/* If the clocksource name is "arch_sys_counter" the
+		 * VDSO will attempt to read the CP15-based counter.
+		 * Ensure this does not happen when CP15-based
+		 * counter is not available.
+		 */
+		clocksource_counter.name = "arch_mem_counter";
+	}
+
 	start_count = arch_timer_read_counter();
 	clocksource_register_hz(&clocksource_counter, arch_timer_rate);
 	cyclecounter.mult = clocksource_counter.mult;
Signature · 1 line
1.9.1
#13 lore raw

PATCH 13/13 clocksource: arm_arch_timer: Consolidate arch_timer_evtstrm_enable

In reply to Daniel Lezcano

From: Nathan Lynch <[email protected]>

The arch_timer_evtstrm_enable hooks in arm and arm64 are substantially similar, the only difference being a CONFIG_COMPAT-conditional section which is relevant only for arm64. Copy the arm64 version to the driver, removing the arch-specific hooks.

---
 arch/arm/include/asm/arch_timer.h    | 11 -----------
 arch/arm64/include/asm/arch_timer.h  | 14 --------------
 drivers/clocksource/arm_arch_timer.c | 15 +++++++++++++++
 3 files changed, 15 insertions(+), 25 deletions(-)
arch/arm/include/asm/arch_timer.h +0 -11
index b7ae444..92793ba 100644
@@ -99,17 +99,6 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
 	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
 }
 
-static inline void arch_timer_evtstrm_enable(int divider)
-{
-	u32 cntkctl = arch_timer_get_cntkctl();
-	cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
-	/* Set the divider and enable virtual event stream */
-	cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
-			| ARCH_TIMER_VIRT_EVT_EN;
-	arch_timer_set_cntkctl(cntkctl);
-	elf_hwcap |= HWCAP_EVTSTRM;
-}
-
 #endif
 
 #endif
arch/arm64/include/asm/arch_timer.h +0 -14
index 49e94c6..f190971 100644
@@ -104,20 +104,6 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
 	asm volatile("msr	cntkctl_el1, %0" : : "r" (cntkctl));
 }
 
-static inline void arch_timer_evtstrm_enable(int divider)
-{
-	u32 cntkctl = arch_timer_get_cntkctl();
-	cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
-	/* Set the divider and enable virtual event stream */
-	cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
-			| ARCH_TIMER_VIRT_EVT_EN;
-	arch_timer_set_cntkctl(cntkctl);
-	elf_hwcap |= HWCAP_EVTSTRM;
-#ifdef CONFIG_COMPAT
-	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
-#endif
-}
-
 static inline u64 arch_counter_get_cntvct(void)
 {
 	u64 cval;
drivers/clocksource/arm_arch_timer.c +15 -0
index 42bd445..2133f9d 100644
@@ -299,6 +299,21 @@ static void __arch_timer_setup(unsigned type,
 	clockevents_config_and_register(clk, arch_timer_rate, 0xf, 0x7fffffff);
 }
 
+static void arch_timer_evtstrm_enable(int divider)
+{
+	u32 cntkctl = arch_timer_get_cntkctl();
+
+	cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
+	/* Set the divider and enable virtual event stream */
+	cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
+			| ARCH_TIMER_VIRT_EVT_EN;
+	arch_timer_set_cntkctl(cntkctl);
+	elf_hwcap |= HWCAP_EVTSTRM;
+#ifdef CONFIG_COMPAT
+	compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
+#endif
+}
+
 static void arch_timer_configure_evtstream(void)
 {
 	int evt_stream_div, pos;
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/13 ARM: meson6: clocksource: Add Meson6 timer support

In reply to Daniel Lezcano

From: Carlo Caione <[email protected]>

Meson6 SoCs are equipped with 5 32-bit timers, called TIMER_A, TIMER_B, TIMER_C, TIMER_D and TIMER_E.

The driver is providing clocksource support for the 32-bit counter using TIMER_E. Clockevents are also supported using TIMER_A.

---
 drivers/clocksource/Kconfig        |   3 +
 drivers/clocksource/Makefile       |   1 +
 drivers/clocksource/meson6_timer.c | 167 +++++++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 drivers/clocksource/meson6_timer.c
drivers/clocksource/Kconfig +3 -0
index cfd6519d..38029ca 100644
@@ -30,6 +30,9 @@ config ARMADA_370_XP_TIMER
 	bool
 	select CLKSRC_OF
 
+config MESON6_TIMER
+	bool
+
 config ORION_TIMER
 	select CLKSRC_OF
 	select CLKSRC_MMIO
drivers/clocksource/Makefile +1 -0
index 7fd9fd1..e4ae987 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_ARCH_PRIMA2)	+= timer-prima2.o
 obj-$(CONFIG_ARCH_U300)		+= timer-u300.o
 obj-$(CONFIG_SUN4I_TIMER)	+= sun4i_timer.o
 obj-$(CONFIG_SUN5I_HSTIMER)	+= timer-sun5i.o
+obj-$(CONFIG_MESON6_TIMER)	+= meson6_timer.o
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra20_timer.o
 obj-$(CONFIG_VT8500_TIMER)	+= vt8500_timer.o
 obj-$(CONFIG_ARCH_NSPIRE)	+= zevio-timer.o
drivers/clocksource/meson6_timer.c new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/13 clocksource: sh_mtu2: Document r7s72100 binding

In reply to Daniel Lezcano

From: Simon Horman <[email protected]>

In general Renesas hardware is not documented to the extent where the relationship between IP blocks on different SoCs can be assumed although they may appear to operate the same way. Furthermore the documentation typically does not specify a version for individual IP blocks. For these reasons a convention of using the SoC name in place of a version and providing SoC-specific compat strings has been adopted.

Although not universally liked this convention is used in the bindings for a number of drivers for Renesas hardware. The purpose of this patch is to update the Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2) driver to follow this convention.

---
* I plan to follow up with a patch patch to use the new binding in the dtsi files for the r7s72100 SoC.

v2
* Suggestions by Mark Rutland and Sergei Shtylyov
- Compatible strings should be "one or more" not "one" of those listed
- Describe the generic binding as covering any MTU2 device
- Re-order compat strings from most to least specific

v3
* Suggested by Laurent Pinchart
- Reword compat documentation for consistency with a more extensive CMT change

---
 Documentation/devicetree/bindings/timer/renesas,mtu2.txt | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/timer/renesas,mtu2.txt +5 -2
index 917453f..d9a8d5a 100644
@@ -8,7 +8,10 @@ are independent. The MTU2 hardware supports five channels indexed from 0 to 4.
 
 Required Properties:
 
-  - compatible: must contain "renesas,mtu2"
+  - compatible: must be one or more of the following:
+    - "renesas,mtu2-r7s72100" for the r7s72100 MTU2
+    - "renesas,mtu2" for any MTU2
+      This is a fallback for the above renesas,mtu2-* entries
 
   - reg: base address and length of the registers block for the timer module.
 
@@ -26,7 +29,7 @@ Required Properties:
 Example: R7S72100 (RZ/A1H) MTU2 node
 
 	mtu2: timer@fcff0000 {
-		compatible = "renesas,mtu2";
+		compatible = "renesas,mtu2-r7s72100", "renesas,mtu2";
 		reg = <0xfcff0000 0x400>;
 		interrupts = <0 139 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 146 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
1.9.1