2019-05-27 08:55:01 +02:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2006-10-16 13:52:09 -07:00
/ *
* Copied f r o m < f i l e : a r c h / p o w e r p c / k e r n e l / m i s c _ 3 2 . S >
*
* This f i l e c o n t a i n s m i s c e l l a n e o u s l o w - l e v e l f u n c t i o n s .
* Copyright ( C ) 1 9 9 5 - 1 9 9 6 G a r y T h o m a s ( g d t @linuxppc.org)
*
* Largely r e w r i t t e n b y C o r t D o u g a n ( c o r t @cs.nmt.edu)
* and P a u l M a c k e r r a s .
*
* kexec b i t s :
* Copyright ( C ) 2 0 0 2 - 2 0 0 3 E r i c B i e d e r m a n < e b i e d e r m @xmission.com>
* GameCube/ p p c32 p o r t C o p y r i g h t ( C ) 2 0 0 4 A l b e r t H e r r a n z
* /
# include " p p c _ a s m . h "
# define S P R N _ P V R 0 x11 F / * P r o c e s s o r V e r s i o n R e g i s t e r * /
.text
2020-09-29 06:48:36 +00:00
/ * udelay n e e d s t o k n o w t h e p e r i o d o f t h e
2006-10-16 13:52:09 -07:00
* timebase i n n a n o s e c o n d s . T h i s u s e d t o b e h a r d c o d e d t o b e 6 0 n s
* ( period o f 6 6 M H z / 4 ) . N o w a v a r i a b l e i s u s e d t h a t i s i n i t i a l i z e d t o
* 6 0 for b a c k w a r d c o m p a t i b i l i t y , b u t i t c a n b e o v e r r i d d e n a s n e c e s s a r y
* with c o d e s o m e t h i n g l i k e t h i s :
* extern u n s i g n e d l o n g t i m e b a s e _ p e r i o d _ n s ;
* timebase_ p e r i o d _ n s = 1 0 0 0 0 0 0 0 0 0 / b d - > b i _ t b f r e q ;
* /
.data
.globl timebase_period_ns
timebase_period_ns :
.long 60
.text
/ *
* Delay f o r a n u m b e r o f m i c r o s e c o n d s
* /
.globl udelay
udelay :
mulli r4 ,r3 ,1 0 0 0 / * n a n o s e c o n d s * /
/ * Change r4 t o b e t h e n u m b e r o f t i c k s u s i n g :
* ( nanoseconds + ( t i m e b a s e _ p e r i o d _ n s - 1 ) ) / t i m e b a s e _ p e r i o d _ n s
* timebase_ p e r i o d _ n s d e f a u l t s t o 6 0 ( 1 6 . 6 M H z ) * /
mflr r5
2020-11-27 11:48:42 +11:00
bcl 2 0 ,3 1 ,0 f
2006-10-16 13:52:09 -07:00
0 : mflr r6
mtlr r5
2020-11-27 11:48:42 +11:00
addis r5 ,r6 ,( t i m e b a s e _ p e r i o d _ n s - 0 b ) @ha
lwz r5 ,( t i m e b a s e _ p e r i o d _ n s - 0 b ) @l(r5)
2006-10-16 13:52:09 -07:00
add r4 ,r4 ,r5
addi r4 ,r4 ,- 1
divw r4 ,r4 ,r5 / * B U S t i c k s * /
2017-08-08 13:58:50 +02:00
1 : MFTBU( r5 )
MFTBL( r6 )
MFTBU( r7 )
2006-10-16 13:52:09 -07:00
cmpw 0 ,r5 ,r7
bne 1 b / * G e t [ s y n c e d ] b a s e t i m e * /
addc r9 ,r6 ,r4 / * C o m p u t e e n d t i m e * /
addze r8 ,r5
2017-08-08 13:58:50 +02:00
2 : MFTBU( r5 )
2006-10-16 13:52:09 -07:00
cmpw 0 ,r5 ,r8
blt 2 b
bgt 3 f
2017-08-08 13:58:50 +02:00
MFTBL( r6 )
2006-10-16 13:52:09 -07:00
cmpw 0 ,r6 ,r9
blt 2 b
3 : blr