Re: [PATCH 06/27] score: create head files delay.h device.h div64.h dma-mapping.h dma.h

Arnd Bergmann
2009-06-13T22:32:46Z

On Saturday 13 June 2009, liqin.chen@sunplusct.com wrote:
> Arnd Bergmann <arnd@arndb.de> 写于 2009-06-10 01:18:20:
>
> > On Tuesday 09 June 2009, liqin.chen@sunplusct.com wrote:
> >
> > Having a working udelay() function is required for many
> > drivers that are sensitive to timing, you should probably
> > implement that at some point in the future.
>
> Add udelay() implement in code.

so you use

static inline void __delay(unsigned long loops)
{
__asm__ __volatile__ (
"1:\tsubi\t%0,1\n\t"
"cmpz.c\t%0\n\t"
"bne\t1b\n\t"
: "=r" (loops)
: "0" (loops));
}

static inline void __udelay(unsigned long usecs)
{
__delay(usecs);
}

This is much better than before, but is far from exact in the __udelay()
case. Please take a look at init/calibrate.c and how other architectures
use loops_per_jiffy if you don't have an exact time source you can use.

If you have a time source with microsecond resolution or better, just loop
until the amount of microseconds has expired.