powerpc: Fix delay functions for 601 processors
My earlier merge of delay.h introduced a timebase-based udelay for 32-bit machines but also broke the 601, which doesn't have the timebase register. This fixes it by using the 601's RTC register on the 601, and also moves __delay() and udelay() to be out-of-line in arch/powerpc/kernel/time.c. These functions aren't really performance critical, after all. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
@@ -13,43 +13,7 @@
|
||||
* Anton Blanchard.
|
||||
*/
|
||||
|
||||
extern unsigned long tb_ticks_per_usec;
|
||||
|
||||
#ifdef CONFIG_PPC64
|
||||
/* define these here to prevent circular dependencies */
|
||||
/* these instructions control the thread priority on multi-threaded cpus */
|
||||
#define __HMT_low() asm volatile("or 1,1,1")
|
||||
#define __HMT_medium() asm volatile("or 2,2,2")
|
||||
#else
|
||||
#define __HMT_low()
|
||||
#define __HMT_medium()
|
||||
#endif
|
||||
|
||||
#define __barrier() asm volatile("" ::: "memory")
|
||||
|
||||
static inline unsigned long __get_tb(void)
|
||||
{
|
||||
unsigned long rval;
|
||||
|
||||
asm volatile("mftb %0" : "=r" (rval));
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline void __delay(unsigned long loops)
|
||||
{
|
||||
unsigned long start = __get_tb();
|
||||
|
||||
while((__get_tb() - start) < loops)
|
||||
__HMT_low();
|
||||
__HMT_medium();
|
||||
__barrier();
|
||||
}
|
||||
|
||||
static inline void udelay(unsigned long usecs)
|
||||
{
|
||||
unsigned long loops = tb_ticks_per_usec * usecs;
|
||||
|
||||
__delay(loops);
|
||||
}
|
||||
extern void __delay(unsigned long loops);
|
||||
extern void udelay(unsigned long usecs);
|
||||
|
||||
#endif /* _ASM_POWERPC_DELAY_H */
|
||||
|
Reference in New Issue
Block a user