mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 08:57:58 +00:00
Nomadik: fix reset_timer()
Previous code was failing when reading back the timer less than 400us after resetting it. This lead nand operations to incorrectly timeout any now and then. Moreover, writing the load register isn't immediately reflected in the value register. We must wait for a clock edge, so read_timer now waits for the value to change at least once, otherwise nand operation would timeout anyways (though less frequently). Signed-off-by: Alessandro Rubini <rubini@unipv.it> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
This commit is contained in:
parent
f936aa0528
commit
4b894a97d3
1 changed files with 12 additions and 3 deletions
|
@ -34,8 +34,8 @@
|
||||||
#define TICKS_PER_HZ (TIMER_CLOCK / CONFIG_SYS_HZ)
|
#define TICKS_PER_HZ (TIMER_CLOCK / CONFIG_SYS_HZ)
|
||||||
#define TICKS_TO_HZ(x) ((x) / TICKS_PER_HZ)
|
#define TICKS_TO_HZ(x) ((x) / TICKS_PER_HZ)
|
||||||
|
|
||||||
/* macro to read the 32 bit timer: since it decrements, we invert read value */
|
/* macro to read the decrementing 32 bit timer as an increasing count */
|
||||||
#define READ_TIMER() (~readl(CONFIG_SYS_TIMERBASE + MTU_VAL(0)))
|
#define READ_TIMER() (0 - readl(CONFIG_SYS_TIMERBASE + MTU_VAL(0)))
|
||||||
|
|
||||||
/* Configure a free-running, auto-wrap counter with no prescaler */
|
/* Configure a free-running, auto-wrap counter with no prescaler */
|
||||||
int timer_init(void)
|
int timer_init(void)
|
||||||
|
@ -49,7 +49,16 @@ int timer_init(void)
|
||||||
/* Restart counting from 0 */
|
/* Restart counting from 0 */
|
||||||
void reset_timer(void)
|
void reset_timer(void)
|
||||||
{
|
{
|
||||||
writel(0, CONFIG_SYS_TIMERBASE + MTU_LR(0)); /* Immediate effect */
|
ulong val;
|
||||||
|
writel(0, CONFIG_SYS_TIMERBASE + MTU_LR(0));
|
||||||
|
/*
|
||||||
|
* The load-register isn't really immediate: it changes on clock
|
||||||
|
* edges, so we must wait for our newly-written value to appear.
|
||||||
|
* Since we might miss reading 0, wait for any change in value.
|
||||||
|
*/
|
||||||
|
val = READ_TIMER();
|
||||||
|
while (READ_TIMER() == val)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return how many HZ passed since "base" */
|
/* Return how many HZ passed since "base" */
|
||||||
|
|
Loading…
Reference in a new issue