Skip to contentSkip to conversation

Clocksource: Flextimer: add LS1 support

PATCH In review Xiubo Li 2 participants 7 messages Sep 5, 2014 – Sep 9, 2014 Clocksource, clockevent drivers

lore
Share & tools
lore

Xiubo Li

author
#0 lore raw

v2 cover Clocksource: Flextimer: add LS1 support

Change in v2:
- Follows Thomas Gleixner advice.

Xiubo Li (4):
Clocksource: Flextimer: Use internal clocksource read API.
Clocksource: Flextimer: Remove the useless code.
Clocksource: Flextimer: Set cpumask to cpu_possible_mask
Clocksource: Flextimer: Fix counter clock prescaler calculation.

 drivers/clocksource/fsl_ftm_timer.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.0.27.g96db324
author
#1 lore raw

PATCH v2 1/4 Clocksource: Flextimer: Use internal clocksource read API.

Since the Flextimer device will be implemented in BE mode on LS1 SoC, and in LE mode on Vybrid, LS2 SoCs, so here we need the endianness judgment before doing the mmio.

---
 drivers/clocksource/fsl_ftm_timer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clocksource/fsl_ftm_timer.c +6 -1
index 454227d..9c6e935 100644
@@ -226,6 +226,11 @@ static int __init ftm_clockevent_init(unsigned long freq, int irq)
 	return 0;
 }
 
+static cycle_t ftm_clocksource_read_up(struct clocksource *c)
+{
+	return ftm_readl(priv->clksrc_base + FTM_CNT) & 0xffff;
+}
+
 static int __init ftm_clocksource_init(unsigned long freq)
 {
 	int err;
@@ -238,7 +243,7 @@ static int __init ftm_clocksource_init(unsigned long freq)
 	sched_clock_register(ftm_read_sched_clock, 16, freq / (1 << priv->ps));
 	err = clocksource_mmio_init(priv->clksrc_base + FTM_CNT, "fsl-ftm",
 				    freq / (1 << priv->ps), 300, 16,
-				    clocksource_mmio_readl_up);
+				    ftm_clocksource_read_up);
 	if (err) {
 		pr_err("ftm: init clock source mmio failed: %d\n", err);
 		return err;
Signature · 1 line
2.1.0.27.g96db324
#2 lore raw

Re: [PATCHv2 1/4] Clocksource: Flextimer: Use internal clocksource read API.

Quoted 3 lines · Xiubo Li

Since the Flextimer device will be implemented in BE mode on LS1 SoC, and in LE mode on Vybrid, LS2 SoCs, so here we need the endianness judgment before doing the mmio.

WTF? I explained you in great length HOW you should solve that, but you just ignore it. Instead of trying to understand what I say you just resend the same nonsense again.

Keep that attitude up, if you want to make sure, that your patches are ignored in the future.

Thanks,

tglx

#3 lore raw

RE: [PATCHv2 1/4] Clocksource: Flextimer: Use internal clocksource read API.

Hi Thomas,

Okay.

I will try to fix this.

Thanks,

BRs
Xiubo

Quoted 24 lines

-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Friday, September 05, 2014 11:40 PM
To: Xiubo Li-B47053
Cc: [email protected]; [email protected]
Subject: Re: [PATCHv2 1/4] Clocksource: Flextimer: Use internal clocksource read API.

Quoted 3 lines · Xiubo Li

Since the Flextimer device will be implemented in BE mode on LS1 SoC, and in LE mode on Vybrid, LS2 SoCs, so here we need the endianness judgment before doing the mmio.

WTF? I explained you in great length HOW you should solve that, but you just ignore it. Instead of trying to understand what I say you just resend the same nonsense again.

Keep that attitude up, if you want to make sure, that your patches are ignored in the future.

Thanks,

tglx

author
#4 lore raw

PATCH v2 2/4 Clocksource: Flextimer: Remove the useless code.

In reply to Xiubo Li

The clock envnt counter will be enabled in proper time and proper place when needed.

---
 drivers/clocksource/fsl_ftm_timer.c | 2 --
 1 file changed, 2 deletions(-)
drivers/clocksource/fsl_ftm_timer.c +0 -2
index 9c6e935..ccb8c32 100644
@@ -221,8 +221,6 @@ static int __init ftm_clockevent_init(unsigned long freq, int irq)
 					freq / (1 << priv->ps),
 					1, 0xffff);
 
-	ftm_counter_enable(priv->clkevt_base);
-
 	return 0;
 }
 
Signature · 1 line
2.1.0.27.g96db324
author
#5 lore raw

PATCH v2 3/4 Clocksource: Flextimer: Set cpumask to cpu_possible_mask

In reply to Xiubo Li

The Flextimer is not tied to CPU0, make it usable on any CPU. For Vybrid there is only one CPU, while for LS1+ there are more than one.

---
 drivers/clocksource/fsl_ftm_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/fsl_ftm_timer.c +1 -1
index ccb8c32..c0ce603 100644
@@ -214,7 +214,7 @@ static int __init ftm_clockevent_init(unsigned long freq, int irq)
 		return err;
 	}
 
-	ftm_clockevent.cpumask = cpumask_of(0);
+	ftm_clockevent.cpumask = cpu_all_mask;
 	ftm_clockevent.irq = irq;
 
 	clockevents_config_and_register(&ftm_clockevent,
Signature · 1 line
2.1.0.27.g96db324
author
#6 lore raw

PATCH v2 4/4 Clocksource: Flextimer: Fix counter clock prescaler calculation.

In reply to Xiubo Li

The old code will use the uncorrect clock prescaler after the loop and the 'ps' must minus one after the loop.

This patch will use new style of this loop and will fix this bug at the same time.

---
 drivers/clocksource/fsl_ftm_timer.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/clocksource/fsl_ftm_timer.c +4 -5
index c0ce603..2b0983d 100644
@@ -300,16 +300,15 @@ static unsigned long __init ftm_clk_init(struct device_node *np)
 
 static int __init ftm_calc_closest_round_cyc(unsigned long freq)
 {
-	priv->ps = 0;
+	int div;
 
 	/* The counter register is only using the lower 16 bits, and
 	 * if the 'freq' value is to big here, then the periodic_cyc
 	 * may exceed 0xFFFF.
 	 */
-	do {
-		priv->periodic_cyc = DIV_ROUND_CLOSEST(freq,
-						HZ * (1 << priv->ps++));
-	} while (priv->periodic_cyc > 0xFFFF);
+	for (priv->ps = 0, priv->periodic_cyc = ~0UL, div = HZ;
+	     priv->periodic_cyc > 0xffff; priv->ps++, div *= 2)
+		priv->periodic_cyc = DIV_ROUND_CLOSEST(freq, div);
 
 	if (priv->ps > FTM_PS_MAX) {
 		pr_err("ftm: the prescaler is %lu > %d\n",
Signature · 1 line
2.1.0.27.g96db324