linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <ying.zhang22455@nxp.com>
To: <linux-kernel@vger.kernel.org>
Cc: <jiafei.pan@nxp.com>, Meng Yi <meng.yi@nxp.com>
Subject: [PATCH 5/5] Fix errata A-007728 for flextimer
Date: Fri, 21 Apr 2017 15:42:47 +0800	[thread overview]
Message-ID: <1492760567-27894-5-git-send-email-ying.zhang22455@nxp.com> (raw)
In-Reply-To: <1492760567-27894-1-git-send-email-ying.zhang22455@nxp.com>

From: Meng Yi <meng.yi@nxp.com>

If the FTM counter reaches the FTM_MOD value between the reading of the
TOF bit and the writing of 0 to the TOF bit, the process of clearing the
TOF bit does not work as expected when FTMx_CONF[NUMTOF] != 0 and the
current TOF count is less than FTMx_CONF[NUMTOF]. If the above condition
is met, the TOF bit remains set. If the TOF interrupt is enabled
(FTMx_SC[TOIE] = 1), the TOF interrupt also remains asserted.

Above is the errata discription

In one word: software clearing TOF bit not works when FTMx_CONF[NUMTOF]
was seted as nonzero and FTM counter reaches the FTM_MOD value.

The workaround is clearing TOF bit until it works(FTM counter doesn't
always reache the FTM_MOD anyway),which may cost some cycles.

Signed-off-by: Meng Yi <meng.yi@nxp.com>
---
 drivers/clocksource/fsl_ftm_timer.c    | 8 ++++----
 drivers/soc/fsl/layerscape/ftm_alarm.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c
index 738515b..770bbbc 100644
--- a/drivers/clocksource/fsl_ftm_timer.c
+++ b/drivers/clocksource/fsl_ftm_timer.c
@@ -83,11 +83,11 @@ static inline void ftm_counter_disable(void __iomem *base)
 
 static inline void ftm_irq_acknowledge(void __iomem *base)
 {
-	u32 val;
+	unsigned int timeout = 100;
 
-	val = ftm_readl(base + FTM_SC);
-	val &= ~FTM_SC_TOF;
-	ftm_writel(val, base + FTM_SC);
+	while ((FTM_SC_TOF & ftm_readl(base + FTM_SC)) && timeout--)
+		ftm_writel(ftm_readl(base + FTM_SC) & (~FTM_SC_TOF),
+			   base + FTM_SC);
 }
 
 static inline void ftm_irq_enable(void __iomem *base)
diff --git a/drivers/soc/fsl/layerscape/ftm_alarm.c b/drivers/soc/fsl/layerscape/ftm_alarm.c
index c42b26b..c0b8ae1 100644
--- a/drivers/soc/fsl/layerscape/ftm_alarm.c
+++ b/drivers/soc/fsl/layerscape/ftm_alarm.c
@@ -78,11 +78,11 @@ static inline void ftm_counter_disable(void __iomem *base)
 
 static inline void ftm_irq_acknowledge(void __iomem *base)
 {
-	u32 val;
+	unsigned int timeout = 100;
 
-	val = ftm_readl(base + FTM_SC);
-	val &= ~FTM_SC_TOF;
-	ftm_writel(val, base + FTM_SC);
+	while ((FTM_SC_TOF & ftm_readl(base + FTM_SC)) && timeout--)
+		ftm_writel(ftm_readl(base + FTM_SC) & (~FTM_SC_TOF),
+			   base + FTM_SC);
 }
 
 static inline void ftm_irq_enable(void __iomem *base)
-- 
2.1.0.27.g96db324

      parent reply	other threads:[~2017-04-21  7:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21  7:42 [PATCH 1/5] soc: fsl: add support for arm64/Layerscape SOC specific drivers ying.zhang22455
2017-04-21  7:42 ` [PATCH 2/5] soc: fsl: add flextimer module alarm driver for Layerscape ying.zhang22455
2017-04-21 12:51   ` kbuild test robot
2017-04-21 17:01   ` kbuild test robot
2017-04-21  7:42 ` [PATCH 3/5] arm64: ls1021a: dts: add ftm0 nodes ying.zhang22455
2017-04-21  7:42 ` [PATCH 4/5] arm64: ls1043a: dts: add rcpm and " ying.zhang22455
2017-04-21  7:42 ` ying.zhang22455 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492760567-27894-5-git-send-email-ying.zhang22455@nxp.com \
    --to=ying.zhang22455@nxp.com \
    --cc=jiafei.pan@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meng.yi@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).