Skip to contentSkip to conversation

clockevents for 4.17

GIT PULL In review Daniel Lezcano 4 participants 11 messages Apr 3, 2018 – Apr 30, 2018 1 message not in the archive

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

Hi Thomas,

sorry for the late pull request.

It contains the following changes for 4.17:

- Fix timer name and register flow for imx's timer tmp and handle
different counter width (Anson Huang)

- Add the NPCM7xx timer support (Tomer Maimon)

Thanks

-- Daniel

The following changes since commit bd03143007eb9b03a7f2316c677780561b68ba2a:

alarmtimer: Init nanosleep alarm timer on stack (2018-03-29 16:10:07
+0200)

are available in the git repository at:

https://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.17

for you to fetch changes up to 0136c741ff40e03323419feec05fcd594f36a463:

clocksource/drivers/imx-tpm: Add different counter width support
(2018-03-30 22:44:11 +0200)

----------------------------------------------------------------
Anson Huang (4):
dt-bindings: timer: tpm: fix typo of clock name clocksource/drivers/imx-tpm: Fix typo of clock name clocksource/drivers/imx-tpm: Correct some registers operation flow clocksource/drivers/imx-tpm: Add different counter width support

Tomer Maimon (2):
dt-binding: timer: document NPCM7xx timer DT bindings clocksource/drivers/npcm: Add NPCM7xx timer driver

 Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt |  21
++++++++++++++++++++
 Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt         |   2 +-
 drivers/clocksource/Kconfig                                       |   8
++++++++
 drivers/clocksource/Makefile                                      |   1 +
 drivers/clocksource/timer-imx-tpm.c                               |  43
++++++++++++++++++++++++++++++----------
 drivers/clocksource/timer-npcm7xx.c                               | 215
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 279 insertions(+), 11 deletions(-)
 create mode 100644
Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt
 create mode 100644 drivers/clocksource/timer-npcm7xx.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/6 dt-binding: timer: document NPCM7xx timer DT bindings

From: Tomer Maimon <[email protected]>

Added device tree binding documentation for Nuvoton NPCM7xx timer.

---
 .../bindings/timer/nuvoton,npcm7xx-timer.txt        | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt
Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt new file +21 -0
new file mode 100644
index 0000000..ea22dfe
@@ -0,0 +1,21 @@
+Nuvoton NPCM7xx timer
+
+Nuvoton NPCM7xx have three timer modules, each timer module provides five 24-bit
+timer counters.
+
+Required properties:
+- compatible      : "nuvoton,npcm750-timer" for Poleg NPCM750.
+- reg             : Offset and length of the register set for the device.
+- interrupts      : Contain the timer interrupt with flags for
+                    falling edge.
+- clocks          : phandle of timer reference clock (usually a 25 MHz clock).
+
+Example:
+
+timer@f0008000 {
+    compatible = "nuvoton,npcm750-timer";
+    interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+    reg = <0xf0008000 0x50>;
+    clocks = <&clk NPCM7XX_CLK_TIMER>;
+};
+
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/6 clocksource/drivers/npcm: Add NPCM7xx timer driver

From: Tomer Maimon <[email protected]>

Add Nuvoton BMC NPCM7xx timer driver.

The clocksource Enable 24-bit TIMER0 and TIMER1 counters, while TIMER0 serve as clockevent and TIMER1 serve as clocksource.

---
 drivers/clocksource/Kconfig         |   8 ++
 drivers/clocksource/Makefile        |   1 +
 drivers/clocksource/timer-npcm7xx.c | 215 ++++++++++++++++++++++++++++++++++++
 3 files changed, 224 insertions(+)
 create mode 100644 drivers/clocksource/timer-npcm7xx.c
drivers/clocksource/Kconfig +8 -0
index b3b4ed9..76194bc 100644
@@ -130,6 +130,14 @@ config VT8500_TIMER
 	help
 	  Enables support for the VT8500 driver.
 
+config NPCM7XX_TIMER
+	bool "NPCM7xx timer driver" if COMPILE_TEST
+	depends on HAS_IOMEM
+	select CLKSRC_MMIO
+	help
+	  Enable 24-bit TIMER0 and TIMER1 counters in the NPCM7xx architecture,
+	  While TIMER0 serves as clockevent and TIMER1 serves as clocksource.
+
 config CADENCE_TTC_TIMER
 	bool "Cadence TTC timer driver" if COMPILE_TEST
 	depends on COMMON_CLK
drivers/clocksource/Makefile +1 -0
index d6dec44..7438787 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_CLKSRC_NPS)	+= timer-nps.o
 obj-$(CONFIG_OXNAS_RPS_TIMER)	+= timer-oxnas-rps.o
 obj-$(CONFIG_OWL_TIMER)		+= owl-timer.o
 obj-$(CONFIG_SPRD_TIMER)	+= timer-sprd.o
+obj-$(CONFIG_NPCM7XX_TIMER)	+= timer-npcm7xx.o
 
 obj-$(CONFIG_ARC_TIMERS)		+= arc_timer.o
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
drivers/clocksource/timer-npcm7xx.c new file +215 -0

215 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/6 dt-bindings: timer: tpm: fix typo of clock name

In reply to Daniel Lezcano

From: Anson Huang <[email protected]>

The clock name should be ipg instead of igp.

---
 Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt +1 -1
index b4aa7dd..f82087b 100644
@@ -15,7 +15,7 @@ Required properties:
 - interrupts :	Should be the clock event device interrupt.
 - clocks :	The clocks provided by the SoC to drive the timer, must contain
 		an entry for each entry in clock-names.
-- clock-names : Must include the following entries: "igp" and "per".
+- clock-names : Must include the following entries: "ipg" and "per".
 
 Example:
 tpm5: tpm@40260000 {
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/6 clocksource/drivers/imx-tpm: Fix typo of clock name

In reply to Daniel Lezcano

From: Anson Huang <[email protected]>

The clock name should be ipg instead of igp.

---
 drivers/clocksource/timer-imx-tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-imx-tpm.c +1 -1
index 21bffdc..3f97d49 100644
@@ -179,7 +179,7 @@ static int __init tpm_timer_init(struct device_node *np)
 	ipg = of_clk_get_by_name(np, "ipg");
 	per = of_clk_get_by_name(np, "per");
 	if (IS_ERR(ipg) || IS_ERR(per)) {
-		pr_err("tpm: failed to get igp or per clk\n");
+		pr_err("tpm: failed to get ipg or per clk\n");
 		ret = -ENODEV;
 		goto err_clk_get;
 	}
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/6 clocksource/drivers/imx-tpm: Correct some registers operation flow

In reply to Daniel Lezcano

From: Anson Huang <[email protected]>

According to i.MX7ULP reference manual, TPM_SC_CPWMS can ONLY be written when counter is disabled, TPM_SC_TOF is write-1-clear, TPM_C0SC_CHF is also write-1-clear, correct these registers initialization flow;

---
 drivers/clocksource/timer-imx-tpm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/clocksource/timer-imx-tpm.c +7 -1
index 3f97d49..7403e49 100644
@@ -20,6 +20,7 @@
 #define TPM_SC				0x10
 #define TPM_SC_CMOD_INC_PER_CNT		(0x1 << 3)
 #define TPM_SC_CMOD_DIV_DEFAULT		0x3
+#define TPM_SC_TOF_MASK			(0x1 << 7)
 #define TPM_CNT				0x14
 #define TPM_MOD				0x18
 #define TPM_STATUS			0x1c
@@ -29,6 +30,7 @@
 #define TPM_C0SC_MODE_SHIFT		2
 #define TPM_C0SC_MODE_MASK		0x3c
 #define TPM_C0SC_MODE_SW_COMPARE	0x4
+#define TPM_C0SC_CHF_MASK		(0x1 << 7)
 #define TPM_C0V				0x24
 
 static void __iomem *timer_base;
@@ -205,9 +207,13 @@ static int __init tpm_timer_init(struct device_node *np)
 	 * 4) Channel0 disabled
 	 * 5) DMA transfers disabled
 	 */
+	/* make sure counter is disabled */
 	writel(0, timer_base + TPM_SC);
+	/* TOF is W1C */
+	writel(TPM_SC_TOF_MASK, timer_base + TPM_SC);
 	writel(0, timer_base + TPM_CNT);
-	writel(0, timer_base + TPM_C0SC);
+	/* CHF is W1C */
+	writel(TPM_C0SC_CHF_MASK, timer_base + TPM_C0SC);
 
 	/* increase per cnt, div 8 by default */
 	writel(TPM_SC_CMOD_INC_PER_CNT | TPM_SC_CMOD_DIV_DEFAULT,
Signature · 1 line
2.7.4
#6 lore raw

Re: [PATCH 5/6] clocksource/drivers/imx-tpm: Correct some registers operation flow

Hi.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 11.8806)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Failed to apply! Possible dependencies:
506a7be93ff7 ("clocksource/drivers/imx-tpm: Correct some registers operation flow")

v4.4.126: Failed to apply! Possible dependencies:
506a7be93ff7 ("clocksource/drivers/imx-tpm: Correct some registers operation flow")

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#7 lore raw

PATCH 6/6 clocksource/drivers/imx-tpm: Add different counter width support

In reply to Daniel Lezcano

From: Anson Huang <[email protected]>

Different TPM modules have different width counters which is 16-bit or 32-bit, the counter width can be read from TPM_PARAM register bit[23:16], this patch adds dynamic check for counter width to support both 16-bit and 32-bit TPM modules.

---
 drivers/clocksource/timer-imx-tpm.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)
drivers/clocksource/timer-imx-tpm.c +25 -8
index 7403e49..05d97a6 100644
@@ -17,9 +17,13 @@
 #include <linux/of_irq.h>
 #include <linux/sched_clock.h>
 
+#define TPM_PARAM			0x4
+#define TPM_PARAM_WIDTH_SHIFT		16
+#define TPM_PARAM_WIDTH_MASK		(0xff << 16)
 #define TPM_SC				0x10
 #define TPM_SC_CMOD_INC_PER_CNT		(0x1 << 3)
 #define TPM_SC_CMOD_DIV_DEFAULT		0x3
+#define TPM_SC_CMOD_DIV_MAX		0x7
 #define TPM_SC_TOF_MASK			(0x1 << 7)
 #define TPM_CNT				0x14
 #define TPM_MOD				0x18
@@ -33,6 +37,8 @@
 #define TPM_C0SC_CHF_MASK		(0x1 << 7)
 #define TPM_C0V				0x24
 
+static int counter_width;
+static int rating;
 static void __iomem *timer_base;
 static struct clock_event_device clockevent_tpm;
 
@@ -85,10 +91,11 @@ static int __init tpm_clocksource_init(unsigned long rate)
 	tpm_delay_timer.freq = rate;
 	register_current_timer_delay(&tpm_delay_timer);
 
-	sched_clock_register(tpm_read_sched_clock, 32, rate);
+	sched_clock_register(tpm_read_sched_clock, counter_width, rate);
 
 	return clocksource_mmio_init(timer_base + TPM_CNT, "imx-tpm",
-				     rate, 200, 32, clocksource_mmio_readl_up);
+				     rate, rating, counter_width,
+				     clocksource_mmio_readl_up);
 }
 
 static int tpm_set_next_event(unsigned long delta,
@@ -141,7 +148,6 @@ static struct clock_event_device clockevent_tpm = {
 	.set_state_oneshot	= tpm_set_state_oneshot,
 	.set_next_event		= tpm_set_next_event,
 	.set_state_shutdown	= tpm_set_state_shutdown,
-	.rating			= 200,
 };
 
 static int __init tpm_clockevent_init(unsigned long rate, int irq)
@@ -151,10 +157,11 @@ static int __init tpm_clockevent_init(unsigned long rate, int irq)
 	ret = request_irq(irq, tpm_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
 			  "i.MX7ULP TPM Timer", &clockevent_tpm);
 
+	clockevent_tpm.rating = rating;
 	clockevent_tpm.cpumask = cpumask_of(0);
 	clockevent_tpm.irq = irq;
-	clockevents_config_and_register(&clockevent_tpm,
-					rate, 300, 0xfffffffe);
+	clockevents_config_and_register(&clockevent_tpm, rate, 300,
+					GENMASK(counter_width - 1, 1));
 
 	return ret;
 }
@@ -199,6 +206,11 @@ static int __init tpm_timer_init(struct device_node *np)
 		goto err_per_clk_enable;
 	}
 
+	counter_width = (readl(timer_base + TPM_PARAM) & TPM_PARAM_WIDTH_MASK)
+		>> TPM_PARAM_WIDTH_SHIFT;
+	/* use rating 200 for 32-bit counter and 150 for 16-bit counter */
+	rating = counter_width == 0x20 ? 200 : 150;
+
 	/*
 	 * Initialize tpm module to a known state
 	 * 1) Counter disabled
@@ -215,12 +227,17 @@ static int __init tpm_timer_init(struct device_node *np)
 	/* CHF is W1C */
 	writel(TPM_C0SC_CHF_MASK, timer_base + TPM_C0SC);
 
-	/* increase per cnt, div 8 by default */
-	writel(TPM_SC_CMOD_INC_PER_CNT | TPM_SC_CMOD_DIV_DEFAULT,
+	/*
+	 * increase per cnt,
+	 * div 8 for 32-bit counter and div 128 for 16-bit counter
+	 */
+	writel(TPM_SC_CMOD_INC_PER_CNT |
+		(counter_width == 0x20 ?
+		TPM_SC_CMOD_DIV_DEFAULT : TPM_SC_CMOD_DIV_MAX),
 		     timer_base + TPM_SC);
 
 	/* set MOD register to maximum for free running mode */
-	writel(0xffffffff, timer_base + TPM_MOD);
+	writel(GENMASK(counter_width - 1, 0), timer_base + TPM_MOD);
 
 	rate = clk_get_rate(per) >> 3;
 	ret = tpm_clocksource_init(rate);
Signature · 1 line
2.7.4
#8 lore raw
In reply to Daniel Lezcano

Hi Thomas,

Quoted 6 lines · Daniel Lezcano

It contains the following changes for 4.17:

- Fix timer name and register flow for imx's timer tmp and handle
different counter width (Anson Huang)

- Add the NPCM7xx timer support (Tomer Maimon)

I can't see this tree in 4.17-rc1. Do you know what happened there?

Cheers,

Joel

Quoted 56 lines

Thanks

-- Daniel

The following changes since commit bd03143007eb9b03a7f2316c677780561b68ba2a:

alarmtimer: Init nanosleep alarm timer on stack (2018-03-29 16:10:07
+0200)

are available in the git repository at:

https://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.17

for you to fetch changes up to 0136c741ff40e03323419feec05fcd594f36a463:

clocksource/drivers/imx-tpm: Add different counter width support
(2018-03-30 22:44:11 +0200)

----------------------------------------------------------------
Anson Huang (4):
dt-bindings: timer: tpm: fix typo of clock name clocksource/drivers/imx-tpm: Fix typo of clock name clocksource/drivers/imx-tpm: Correct some registers operation flow clocksource/drivers/imx-tpm: Add different counter width support

Tomer Maimon (2):
dt-binding: timer: document NPCM7xx timer DT bindings clocksource/drivers/npcm: Add NPCM7xx timer driver

 Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt |  21
++++++++++++++++++++
 Documentation/devicetree/bindings/timer/nxp,tpm-timer.txt         |   2 +-
 drivers/clocksource/Kconfig                                       |   8
++++++++
 drivers/clocksource/Makefile                                      |   1 +
 drivers/clocksource/timer-imx-tpm.c                               |  43
++++++++++++++++++++++++++++++----------
 drivers/clocksource/timer-npcm7xx.c                               | 215
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 279 insertions(+), 11 deletions(-)
 create mode 100644
Documentation/devicetree/bindings/timer/nuvoton,npcm7xx-timer.txt
 create mode 100644 drivers/clocksource/timer-npcm7xx.c

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

A message that is not in the archive (sent off-list or not yet received): CAP6Zq1jdXj0f0WfWK-b1X0hW=LcyMhxcLchHDkfVk2Fhho_HVg@mail.gmail.com

#10 lore raw
Quoted 16 lines · Tomer Maimon

Hi Thomas and Daniel,

Do you have news about the question below (from Joel)?

We hoped that NPCM7xx clocksource driver will upstream at 4.17

Quoted 10 lines
Quoted 6 lines · Daniel Lezcano

It contains the following changes for 4.17:

- Fix timer name and register flow for imx's timer tmp and handle
different counter width (Anson Huang)

- Add the NPCM7xx timer support (Tomer Maimon)

I can't see this tree in 4.17-rc1. Do you know what happened there?

I'm pretty sure that I handled this pull request at some point, but then I have no clue either where it got lost.

Sorry. I'll look at it later today.

Thanks,

tglx

#11 lore raw
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines · Tomer Maimon

Hi Thomas and Daniel,

Quoted 8 lines
Quoted 5 lines

Do you have news about the question below (from Joel)?

We hoped that NPCM7xx clocksource driver will upstream at 4.17

Quoted 2 lines

I can't see this tree in 4.17-rc1. Do you know what happened there?

I'm pretty sure that I handled this pull request at some point, but then I have no clue either where it got lost.

If you had checked Linus tree before asking that question then you would have seen:

commit d95c8844399885cd511c6f6395621cc1a9fe2e68
Merge: e6d9bfdeb439 90c7c0c24e22
Author: Linus Torvalds <[email protected]>
Date: Mon Apr 16 12:44:03 2018 -0700

Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull missed timer updates from Thomas Gleixner:
"This is a branch which got forgotten during the merge window, but it
contains only fixes and hardware enablement. No fundamental changes.

- Various fixes for the imx-tpm clocksource driver

- A new timer driver for the NCPM7xx SoC family"

* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
clocksource/drivers/imx-tpm: Add different counter width support clocksource/drivers/imx-tpm: Correct some registers operation flow clocksource/drivers/imx-tpm: Fix typo of clock name
dt-bindings: timer: tpm: fix typo of clock name clocksource/drivers/npcm: Add NPCM7xx timer driver
dt-binding: timer: document NPCM7xx timer DT bindings

or just checking for drivers/clocksource/timer-npcm7xx.c would have answered your question as well.

Thanks for stealing my time

tglx