public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] nds32: ag101/ag102: Fix setting lastdec and now values
@ 2013-07-08  6:29 Axel Lin
  2013-07-24  4:48 ` Macpaul Lin
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2013-07-08  6:29 UTC (permalink / raw)
  To: u-boot

The timer3 counter unit for lastdesc and now values are inconsistent in current
code. The unit of "readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2)" is
second. However, CONFIG_SYS_HZ is defined as 1000 in board config file.
This means the accuracy of "lastdec" and "now" should be in millisecond,
thus fix the equation to set lastdec and now variables accordingly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi Kuan-Yu,
This change is based on your suggestion.
I don't have this hardware, can you test if this patch works?

Thanks,
Axel
 arch/nds32/cpu/n1213/ag101/timer.c | 7 ++++---
 arch/nds32/cpu/n1213/ag102/timer.c | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/nds32/cpu/n1213/ag101/timer.c b/arch/nds32/cpu/n1213/ag101/timer.c
index caa36b8..926091f 100644
--- a/arch/nds32/cpu/n1213/ag101/timer.c
+++ b/arch/nds32/cpu/n1213/ag101/timer.c
@@ -86,7 +86,8 @@ void reset_timer_masked(void)
 #ifdef CONFIG_FTTMR010_EXT_CLK
 	lastdec = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 #else
-	lastdec = readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2);
+	lastdec = readl(&tmr->timer3_counter) /
+			(CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ);
 #endif
 	timestamp = 0;		/* start "advancing" time stamp from 0 */
 
@@ -110,8 +111,8 @@ ulong get_timer_masked(void)
 #ifdef CONFIG_FTTMR010_EXT_CLK
 	ulong now = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 #else
-	ulong now = readl(&tmr->timer3_counter) / \
-			(CONFIG_SYS_CLK_FREQ / 2 / 1024);
+	ulong now = readl(&tmr->timer3_counter) /
+			(CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ);
 #endif
 
 	debug("%s(): now = %lx, lastdec = %lx\n", __func__, now, lastdec);
diff --git a/arch/nds32/cpu/n1213/ag102/timer.c b/arch/nds32/cpu/n1213/ag102/timer.c
index caa36b8..926091f 100644
--- a/arch/nds32/cpu/n1213/ag102/timer.c
+++ b/arch/nds32/cpu/n1213/ag102/timer.c
@@ -86,7 +86,8 @@ void reset_timer_masked(void)
 #ifdef CONFIG_FTTMR010_EXT_CLK
 	lastdec = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 #else
-	lastdec = readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2);
+	lastdec = readl(&tmr->timer3_counter) /
+			(CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ);
 #endif
 	timestamp = 0;		/* start "advancing" time stamp from 0 */
 
@@ -110,8 +111,8 @@ ulong get_timer_masked(void)
 #ifdef CONFIG_FTTMR010_EXT_CLK
 	ulong now = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 #else
-	ulong now = readl(&tmr->timer3_counter) / \
-			(CONFIG_SYS_CLK_FREQ / 2 / 1024);
+	ulong now = readl(&tmr->timer3_counter) /
+			(CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ);
 #endif
 
 	debug("%s(): now = %lx, lastdec = %lx\n", __func__, now, lastdec);
-- 
1.8.1.2

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

* [U-Boot] [PATCH] nds32: ag101/ag102: Fix setting lastdec and now values
  2013-07-08  6:29 [U-Boot] [PATCH] nds32: ag101/ag102: Fix setting lastdec and now values Axel Lin
@ 2013-07-24  4:48 ` Macpaul Lin
  0 siblings, 0 replies; 2+ messages in thread
From: Macpaul Lin @ 2013-07-24  4:48 UTC (permalink / raw)
  To: u-boot

Hi Axel,

2013/7/8 Axel Lin <axel.lin@ingics.com>:
> The timer3 counter unit for lastdesc and now values are inconsistent in current
> code. The unit of "readl(&tmr->timer3_counter) / (CONFIG_SYS_CLK_FREQ / 2)" is
> second. However, CONFIG_SYS_HZ is defined as 1000 in board config file.
> This means the accuracy of "lastdec" and "now" should be in millisecond,
> thus fix the equation to set lastdec and now variables accordingly.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> Hi Kuan-Yu,
> This change is based on your suggestion.
> I don't have this hardware, can you test if this patch works?
>
> Thanks,

Applied to u-boot-nds32/master
Thanks for your help!

-- 
Best regards,
Macpaul Lin

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

end of thread, other threads:[~2013-07-24  4:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-08  6:29 [U-Boot] [PATCH] nds32: ag101/ag102: Fix setting lastdec and now values Axel Lin
2013-07-24  4:48 ` Macpaul Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox