[U-Boot] [PATCH] davinci: Rewrite timer.c to use tbl/tbu emulation variables in gd

Ben Gardiner bengardiner at nanometrics.ca
Thu Dec 2 15:18:11 CET 2010


Hi Nick,

On Thu, Dec 2, 2010 at 8:57 AM, Nick Thompson <nick.thompson at ge.com> wrote:
> This change allows the davinci timer functions to be used before
> relocation since it avoids using static variables prior to BSS being
> made available.
>
> The code is based on that used in the at91 timers, modified to use
> a davinci specific hardware timer. It also maintains reset_timer()
> to allow deprecated timer usage to continue to work (for example,
> in nand_base.c)
>
> Signed-off-by: Nick Thompson <nick.thompson at ge.com>
> ---
> This patch relies on http://patchwork.ozlabs.org/patch/73758/ which has not been
> accepted yet. I have made a comment on it, suggesting that it should be changed:
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/90040/focus=90162
>
>  arch/arm/cpu/arm926ejs/davinci/timer.c |   77 ++++++++++++--------------------
>  1 files changed, 28 insertions(+), 49 deletions(-)

Applies cleanly to v2010.12-rc2 on top of
http://patchwork.ozlabs.org/patch/73758/

Tested on da850evm w/o any config changes. This fixes the freeze on
boot: 10/10 times.

You're awesome, Nick!

Tested-by: Ben Gardiner <bengardiner at nanometrics.ca>

> diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c
> [...]
>  void __udelay(unsigned long usec)
>  {
> -       ulong tmo;
> -       ulong endtime;
> -       signed long diff;
> -
> -       tmo = CONFIG_SYS_HZ_CLOCK / 1000;
> -       tmo *= usec;
> -       tmo /= (1000 * TIM_CLK_DIV);
> -
> -       endtime = get_timer_raw() + tmo;
> +       unsigned long long endtime;
>
> -       do {
> -               ulong now = get_timer_raw();
> -               diff = endtime - now;
> -       } while (diff >= 0);
> -}
> +       endtime = ((unsigned long long )usec * gd->timer_rate_hz) / 1000000UL;

just one minor checkpatch.pl warning; should be (unsigned long long)
-- no space before ')'

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca


More information about the U-Boot mailing list