* [U-Boot] arm imx35 timer failure
@ 2011-03-29 14:24 Laurent Joye
2011-04-05 13:48 ` Stefano Babic
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Joye @ 2011-03-29 14:24 UTC (permalink / raw)
To: u-boot
Hello,
I'm developing a product based on the imx35 cpu with NOR and NAND flash.
The SBC I use is the pcm-043 from Phytec.
I use the FEC to communicate over the ethernet.
I've made my own BSP for Das U-boot based on the release tagged
v2011.03-rc2 on the git://git.denx.de/u-boot.git master repository.
I've encountered one problem in uboot so that my board can work
properly:
This concerns the FEC autonegotiation timeout.
I had some MDIO read an write and autonegotiation wait timeout failures.
By debugging the problem I've found that the changes I've brought to the
timer.c file (see patch below for arch/arm/cpu/arm1136/timer.c) of the
imx35 cpu solves the problem.
It seems that the return value of the "get_timer_masked" function is not
given with the same unit as the input value for the "get_timer"
function. It seems also to me that this value should be dependent of the
"CONFIG_SYS_HZ" macro.
Did anybody encountered this problem?
Could you please tell me if there is really something wrong in timer.c
file?
Laurent Joye
HaslerRail AG
Bern, Switzerland
Related patch:
diff --git a/arch/arm/cpu/arm1136/mx35/timer.c
b/arch/arm/cpu/arm1136/mx35/timer.c
index db1e2c9..00ca3e6 100644
--- a/arch/arm/cpu/arm1136/mx35/timer.c
+++ b/arch/arm/cpu/arm1136/mx35/timer.c
@@ -70,7 +70,7 @@ inline ulong get_timer_masked(void)
struct gpt_regs *gpt = (struct gpt_regs *)GPT1_BASE_ADDR;
ulong val = readl(&gpt->counter);
- return val;
+ return val / CONFIG_SYS_HZ;
}
void reset_timer(void)
@@ -84,12 +84,14 @@ ulong get_timer(ulong base)
tmp = get_timer_masked();
- if (tmp <= (base * 1000)) {
+ if (tmp < base) {
/* Overflow */
- tmp += (0xffffffff - base);
+ tmp = (0xffffffff - (base - tmp));
+ } else {
+ tmp = tmp -base;
}
- return (tmp / 1000) - base;
+ return tmp;
}
void set_timer(ulong t)
@@ -103,6 +105,7 @@ void set_timer(ulong t)
void __udelay(unsigned long usec)
{
ulong tmp;
+ usec /= CONFIG_SYS_HZ;
tmp = get_timer_masked(); /* get current timestamp */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] arm imx35 timer failure
2011-03-29 14:24 [U-Boot] arm imx35 timer failure Laurent Joye
@ 2011-04-05 13:48 ` Stefano Babic
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Babic @ 2011-04-05 13:48 UTC (permalink / raw)
To: u-boot
On 03/29/2011 04:24 PM, Laurent Joye wrote:
> Hello,
> I'm developing a product based on the imx35 cpu with NOR and NAND flash.
> The SBC I use is the pcm-043 from Phytec.
> I use the FEC to communicate over the ethernet.
Hi Laurent,
> It seems that the return value of the "get_timer_masked" function is not
> given with the same unit as the input value for the "get_timer"
> function. It seems also to me that this value should be dependent of the
> "CONFIG_SYS_HZ" macro.
I think you are right. However, examining your problem I checked that
the i.MX35 timer functions are quite different compared to other i.MX
processors (mX31 and MX5). There is no good reason to make things
different and I think we should refactor this code containing the timer
functions for the i.MX35 (and better having one single file with the
i.MX31 code).
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-05 13:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-29 14:24 [U-Boot] arm imx35 timer failure Laurent Joye
2011-04-05 13:48 ` Stefano Babic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox