2009-10-19 17:26:17 -07:00
/ * arch/ a r m / m a c h - o m a p1 / i n c l u d e / m a c h / d e b u g - m a c r o . 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 .
*
* /
2010-02-15 08:48:53 -08:00
# include < l i n u x / s e r i a l _ r e g . h >
2012-10-15 12:50:46 -07:00
# include " s e r i a l . h "
2010-02-15 08:48:53 -08:00
2010-02-15 08:49:01 -08:00
.pushsection .data
omap_uart_phys : .word 0x0
omap_uart_virt : .word 0x0
.popsection
/ *
* Note t h a t t h i s c o d e w o n ' t w o r k i f t h e b o o t l o a d e r p a s s e s
* a w r o n g m a c h i n e I D n u m b e r i n r1 . T o d e b u g , j u s t h a r d c o d e
* the d e s i r e d U A R T p h y s a n d v i r t a d d r e s s e s t e m p o r a r i l y i n t o
* the o m a p _ u a r t _ p h y s a n d o m a p _ u a r t _ v i r t a b o v e .
* /
2011-08-31 22:55:46 -04:00
.macro addruart, r p , r v , t m p
2010-02-15 08:49:01 -08:00
/* Use omap_uart_phys/virt if already configured */
2011-09-01 19:17:43 -04:00
9 : adr \ r p , 9 9 f @ get effective addr of 99f
ldr \ r v , [ \ r p ] @ get absolute addr of 99f
sub \ r v , \ r v , \ r p @ offset between the two
ldr \ r p , [ \ r p , #4 ] @ abs addr of omap_uart_phys
sub \ t m p , \ r p , \ r v @ make it effective
ldr \ r p , [ \ t m p , #0 ] @ omap_uart_phys
ldr \ r v , [ \ t m p , #4 ] @ omap_uart_virt
2010-07-06 18:30:06 +08:00
cmp \ r p , #0 @ is port configured?
cmpne \ r v , #0
2011-09-01 19:17:43 -04:00
bne 1 0 0 f @ already configured
2010-02-15 08:49:01 -08:00
2010-04-30 17:39:19 -07:00
/* Check the debug UART configuration set in uncompress.h */
2011-08-31 13:57:37 -04:00
and \ r p , p c , #0xff000000
ldr \ r v , =OMAP_UART_INFO_OFS
ldr \ r p , [ \ r p , \ r v ]
2010-02-15 08:49:01 -08:00
/* Select the UART to use based on the UART1 scratchpad value */
2010-07-06 18:30:06 +08:00
10 : cmp \ r p , #0 @ no port configured?
2010-02-15 08:49:01 -08:00
beq 1 1 f @ if none, try to use UART1
2010-07-06 18:30:06 +08:00
cmp \ r p , #O M A P 1 U A R T 1
2010-02-15 08:49:01 -08:00
beq 1 1 f @ configure OMAP1UART1
2010-07-06 18:30:06 +08:00
cmp \ r p , #O M A P 1 U A R T 2
2010-02-15 08:49:01 -08:00
beq 1 2 f @ configure OMAP1UART2
2010-07-06 18:30:06 +08:00
cmp \ r p , #O M A P 1 U A R T 3
2010-02-15 08:49:01 -08:00
beq 1 3 f @ configure OMAP2UART3
/* Configure the UART offset from the phys/virt base */
2010-07-06 18:30:06 +08:00
11 : mov \ r p , #0x00fb0000 @ OMAP1UART1
2010-02-15 08:49:01 -08:00
b 9 8 f
2010-07-06 18:30:06 +08:00
12 : mov \ r p , #0x00fb0000 @ OMAP1UART1
orr \ r p , \ r p , #0x00000800 @ OMAP1UART2
2010-02-15 08:49:01 -08:00
b 9 8 f
2010-07-06 18:30:06 +08:00
13 : mov \ r p , #0x00fb0000 @ OMAP1UART1
orr \ r p , \ r p , #0x00000800 @ OMAP1UART2
orr \ r p , \ r p , #0x00009000 @ OMAP1UART3
2010-02-15 08:49:01 -08:00
/* Store both phys and virt address for the uart */
2010-07-06 18:30:06 +08:00
98 : add \ r p , \ r p , #0xff000000 @ phys base
2011-09-01 19:17:43 -04:00
str \ r p , [ \ t m p , #0 ] @ omap_uart_phys
2010-07-06 18:30:06 +08:00
sub \ r p , \ r p , #0xff000000 @ phys base
add \ r p , \ r p , #0xfe000000 @ virt base
2011-09-01 19:17:43 -04:00
str \ r p , [ \ t m p , #4 ] @ omap_uart_virt
2010-02-15 08:49:01 -08:00
b 9 b
2011-09-01 19:17:43 -04:00
.align
99 : .word .
.word omap_uart_phys
.ltorg
100 :
2005-04-16 15:20:36 -07:00
.endm
.macro senduart,r d ,r x
strb \ r d , [ \ r x ]
.endm
.macro busyuart,r d ,r x
2010-02-15 08:48:53 -08:00
1001 : ldrb \ r d , [ \ r x , #( U A R T _ L S R < < O M A P _ P O R T _ S H I F T ) ]
and \ r d , \ r d , #( U A R T _ L S R _ T E M T | U A R T _ L S R _ T H R E )
teq \ r d , #( U A R T _ L S R _ T E M T | U A R T _ L S R _ T H R E )
2005-04-16 15:20:36 -07:00
beq 1 0 0 2 f
2010-02-15 08:48:53 -08:00
ldrb \ r d , [ \ r x , #( U A R T _ L S R < < O M A P 7 X X _ P O R T _ S H I F T ) ]
and \ r d , \ r d , #( U A R T _ L S R _ T E M T | U A R T _ L S R _ T H R E )
teq \ r d , #( U A R T _ L S R _ T E M T | U A R T _ L S R _ T H R E )
2005-04-16 15:20:36 -07:00
bne 1 0 0 1 b
1002 :
.endm
.macro waituart,r d ,r x
.endm