public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer()
@ 2009-11-03 12:12 Alessandro Rubini
  2009-11-03 13:27 ` Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Alessandro Rubini @ 2009-11-03 12:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

The timer decrements and READ_TIMER() negates the value read.
Writing 0 in reset_timer() is this wrong, as a readback before 400us
will read back 0 and will report 1780 seconds, so nand operations did
timeout.  This patch writes ~0 in reset_timer to prevent this.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---

This must be applied for nand to work. It's a simple bugfix so
I think it got simply forgotten.

BTW: I got no feedback for the lcd/keypad stuff, neither positive
nor negative. Shall I repost my current status in that regard?

thanks
/alessandro

 cpu/arm926ejs/nomadik/timer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpu/arm926ejs/nomadik/timer.c b/cpu/arm926ejs/nomadik/timer.c
index 16067c9..2115b71 100644
--- a/cpu/arm926ejs/nomadik/timer.c
+++ b/cpu/arm926ejs/nomadik/timer.c
@@ -46,10 +46,10 @@ int timer_init(void)
 	return 0;
 }
 
-/* Restart counting from 0 */
+/* Restart counting from ~0 (can't be 0, since READ_TIMER negates) */
 void reset_timer(void)
 {
-	writel(0, CONFIG_SYS_TIMERBASE + MTU_LR(0)); /* Immediate effect */
+	writel(~0, CONFIG_SYS_TIMERBASE + MTU_LR(0)); /* Immediate effect */
 }
 
 /* Return how many HZ passed since "base" */
-- 
1.5.6.5

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

* [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer()
  2009-11-03 12:12 [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer() Alessandro Rubini
@ 2009-11-03 13:27 ` Wolfgang Denk
  2009-11-03 15:23   ` Alessandro Rubini
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2009-11-03 13:27 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <20091103121250.GA8577@mail.gnudd.com> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> The timer decrements and READ_TIMER() negates the value read.
> Writing 0 in reset_timer() is this wrong, as a readback before 400us
> will read back 0 and will report 1780 seconds, so nand operations did
> timeout.  This patch writes ~0 in reset_timer to prevent this.
> 
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
> ---
> 
> This must be applied for nand to work. It's a simple bugfix so
> I think it got simply forgotten.

Um... why is READ_TIMER doing such a stupid thing as negating values?
This is not what it is supposed to do - as the name says, it should
_read_ the _timer_. There is no mentioning of "NEgATE" anywhere?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The majority of the stupid is  invincible  and  guaranteed  for  all
time.  The  terror  of their tyranny, however, is alleviated by their
lack of consistency."                               - Albert Einstein

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

* [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer()
  2009-11-03 13:27 ` Wolfgang Denk
@ 2009-11-03 15:23   ` Alessandro Rubini
  2009-11-03 15:59     ` Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Alessandro Rubini @ 2009-11-03 15:23 UTC (permalink / raw)
  To: u-boot

> Um... why is READ_TIMER doing such a stupid thing as negating values?

Because the counter counts down. I could have returns "0 - value" or
"~value".  Since I chose the latter initially, this fix keeps the same
approach.  I can't return the value I read, since it goes backwards.

/alessandro

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

* [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer()
  2009-11-03 15:23   ` Alessandro Rubini
@ 2009-11-03 15:59     ` Wolfgang Denk
  2009-11-03 16:03       ` Alessandro Rubini
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2009-11-03 15:59 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <20091103152354.GA12451@mail.gnudd.com> you wrote:
> > Um... why is READ_TIMER doing such a stupid thing as negating values?
> 
> Because the counter counts down. I could have returns "0 - value" or
> "~value".  Since I chose the latter initially, this fix keeps the same
> approach.  I can't return the value I read, since it goes backwards.

Well, to me READ_TIMER() sounds like a function/macro to read some
value from some timer; if that timer counts doen, then successive
calls to that macro/function would return decreasing values. Counting
up or down is a property of the specific timer and should be handled
elsewhere; such policy does IMHO not belong into some accessor
function.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Brain: an apparatus with which we think we think.    - Ambrose Bierce

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

* [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer()
  2009-11-03 15:59     ` Wolfgang Denk
@ 2009-11-03 16:03       ` Alessandro Rubini
  0 siblings, 0 replies; 5+ messages in thread
From: Alessandro Rubini @ 2009-11-03 16:03 UTC (permalink / raw)
  To: u-boot

> Well, to me READ_TIMER() sounds like a function/macro to read some
> value from some timer; if that timer counts doen, then successive
> calls to that macro/function would return decreasing values. Counting
> up or down is a property of the specific timer and should be handled
> elsewhere; such policy does IMHO not belong into some accessor
> function.

Well, I thought this was an easy fix. Unfortunately, I can't test any
new code for a few days, so a patch that changes this, while trivial,
may be bugged. Unless I get an ack from you, I'll send a timer which
negates elsewhere in a day or so.

/alessandro

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

end of thread, other threads:[~2009-11-03 16:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-03 12:12 [U-Boot] [PATCH (repost)] Nomadik: fix reset_timer() Alessandro Rubini
2009-11-03 13:27 ` Wolfgang Denk
2009-11-03 15:23   ` Alessandro Rubini
2009-11-03 15:59     ` Wolfgang Denk
2009-11-03 16:03       ` Alessandro Rubini

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