2014-11-06 10:20:23 +03:00
/ * arch/ a r m / i n c l u d e / d e b u g / s a11 0 0 . S
2005-04-16 15:20:36 -07:00
*
* Debugging m a c r o i n c l u d e h e a d e r
*
* Copyright ( C ) 1 9 9 4 - 1 9 9 9 R u s s e l l K i n g
* Moved f r o m l i n u x / a r c h / a r m / k e r n e l / d e b u g . S b y B e n D o o k s
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
*
* /
2014-11-06 10:20:23 +03:00
# define U T C R 3 0 x0 c
# define U T D R 0 x14
# define U T S R 1 0 x20
# define U T C R 3 _ T X E 0 x00 0 0 0 0 0 2 / * T r a n s m i t E n a b l e * /
# define U T S R 1 _ T B Y 0 x00 0 0 0 0 0 1 / * T r a n s m i t t e r B u s Y ( r e a d ) * /
# define U T S R 1 _ T N F 0 x00 0 0 0 0 0 4 / * T r a n s m i t F I F O N o t F u l l ( r e a d ) * /
2005-04-16 15:20:36 -07:00
2011-08-31 22:55:46 -04:00
.macro addruart, r p , r v , t m p
2010-07-06 18:30:06 +08:00
mrc p15 , 0 , \ r p , c1 , c0
tst \ r p , #1 @ MMU enabled?
moveq \ r p , #0x80000000 @ physical base address
movne \ r p , #0xf8000000 @ virtual address
2005-04-16 15:20:36 -07:00
@ We probe for the active serial port here, coherently with
2008-08-05 16:14:15 +01:00
@ the comment in arch/arm/mach-sa1100/include/mach/uncompress.h.
2005-04-16 15:20:36 -07:00
@ We assume r1 can be clobbered.
@ see if Ser3 is active
2010-07-06 18:30:06 +08:00
add \ r p , \ r p , #0x00050000
ldr \ r v , [ \ r p , #U T C R 3 ]
tst \ r v , #U T C R 3 _ T X E
2005-04-16 15:20:36 -07:00
@ if Ser3 is inactive, then try Ser1
2010-07-06 18:30:06 +08:00
addeq \ r p , \ r p , #( 0x00010000 - 0 x00 0 5 0 0 0 0 )
ldreq \ r v , [ \ r p , #U T C R 3 ]
tsteq \ r v , #U T C R 3 _ T X E
2005-04-16 15:20:36 -07:00
@ if Ser1 is inactive, then try Ser2
2010-07-06 18:30:06 +08:00
addeq \ r p , \ r p , #( 0x00030000 - 0 x00 0 1 0 0 0 0 )
ldreq \ r v , [ \ r p , #U T C R 3 ]
tsteq \ r v , #U T C R 3 _ T X E
@ clear top bits, and generate both phys and virt addresses
lsl \ r p , \ r p , #8
lsr \ r p , \ r p , #8
orr \ r v , \ r p , #0xf8000000 @ virtual
orr \ r p , \ r p , #0x80000000 @ physical
2005-04-16 15:20:36 -07:00
.endm
.macro senduart,r d ,r x
str \ r d , [ \ r x , #U T D R ]
.endm
.macro waituart,r d ,r x
1001 : ldr \ r d , [ \ r x , #U T S R 1 ]
tst \ r d , #U T S R 1 _ T N F
beq 1 0 0 1 b
.endm
.macro busyuart,r d ,r x
1001 : ldr \ r d , [ \ r x , #U T S R 1 ]
tst \ r d , #U T S R 1 _ T B Y
bne 1 0 0 1 b
.endm