omap2plus.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Debugging macro include header
  3. *
  4. * Copyright (C) 1994-1999 Russell King
  5. * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/serial_reg.h>
  13. /* OMAP2 serial ports */
  14. #define OMAP2_UART1_BASE 0x4806a000
  15. #define OMAP2_UART2_BASE 0x4806c000
  16. #define OMAP2_UART3_BASE 0x4806e000
  17. /* OMAP3 serial ports */
  18. #define OMAP3_UART1_BASE OMAP2_UART1_BASE
  19. #define OMAP3_UART2_BASE OMAP2_UART2_BASE
  20. #define OMAP3_UART3_BASE 0x49020000
  21. #define OMAP3_UART4_BASE 0x49042000 /* Only on 36xx */
  22. #define OMAP3_UART4_AM35XX_BASE 0x4809E000 /* Only on AM35xx */
  23. /* OMAP4 serial ports */
  24. #define OMAP4_UART1_BASE OMAP2_UART1_BASE
  25. #define OMAP4_UART2_BASE OMAP2_UART2_BASE
  26. #define OMAP4_UART3_BASE 0x48020000
  27. #define OMAP4_UART4_BASE 0x4806e000
  28. /* TI81XX serial ports */
  29. #define TI81XX_UART1_BASE 0x48020000
  30. #define TI81XX_UART2_BASE 0x48022000
  31. #define TI81XX_UART3_BASE 0x48024000
  32. /* AM3505/3517 UART4 */
  33. #define AM35XX_UART4_BASE 0x4809E000 /* Only on AM3505/3517 */
  34. /* AM33XX serial port */
  35. #define AM33XX_UART1_BASE 0x44E09000
  36. /* OMAP5 serial ports */
  37. #define OMAP5_UART1_BASE OMAP2_UART1_BASE
  38. #define OMAP5_UART2_BASE OMAP2_UART2_BASE
  39. #define OMAP5_UART3_BASE OMAP4_UART3_BASE
  40. #define OMAP5_UART4_BASE OMAP4_UART4_BASE
  41. #define OMAP5_UART5_BASE 0x48066000
  42. #define OMAP5_UART6_BASE 0x48068000
  43. /* External port on Zoom2/3 */
  44. #define ZOOM_UART_BASE 0x10000000
  45. #define ZOOM_UART_VIRT 0xfa400000
  46. #define OMAP_PORT_SHIFT 2
  47. #define ZOOM_PORT_SHIFT 1
  48. #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
  49. .pushsection .data
  50. omap_uart_phys: .word 0
  51. omap_uart_virt: .word 0
  52. omap_uart_lsr: .word 0
  53. .popsection
  54. .macro addruart, rp, rv, tmp
  55. /* Use omap_uart_phys/virt if already configured */
  56. 10: adr \rp, 99f @ get effective addr of 99f
  57. ldr \rv, [\rp] @ get absolute addr of 99f
  58. sub \rv, \rv, \rp @ offset between the two
  59. ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys
  60. sub \tmp, \rp, \rv @ make it effective
  61. ldr \rp, [\tmp, #0] @ omap_uart_phys
  62. ldr \rv, [\tmp, #4] @ omap_uart_virt
  63. cmp \rp, #0 @ is port configured?
  64. cmpne \rv, #0
  65. bne 100f @ already configured
  66. /* Configure the UART offset from the phys/virt base */
  67. #ifdef CONFIG_DEBUG_OMAP2UART1
  68. mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
  69. b 98f
  70. #endif
  71. #ifdef CONFIG_DEBUG_OMAP2UART2
  72. mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
  73. b 98f
  74. #endif
  75. #ifdef CONFIG_DEBUG_OMAP2UART3
  76. mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
  77. b 98f
  78. #endif
  79. #ifdef CONFIG_DEBUG_OMAP3UART3
  80. mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
  81. add \rp, \rp, #0x00fb0000
  82. add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
  83. b 98f
  84. #endif
  85. #ifdef CONFIG_DEBUG_OMAP4UART3
  86. mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
  87. b 98f
  88. #endif
  89. #ifdef CONFIG_DEBUG_OMAP3UART4
  90. mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
  91. add \rp, \rp, #0x00fb0000
  92. add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
  93. b 98f
  94. #endif
  95. #ifdef CONFIG_DEBUG_OMAP4UART4
  96. mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
  97. b 98f
  98. #endif
  99. #ifdef CONFIG_DEBUG_TI81XXUART1
  100. mov \rp, #UART_OFFSET(TI81XX_UART1_BASE)
  101. b 98f
  102. #endif
  103. #ifdef CONFIG_DEBUG_TI81XXUART2
  104. mov \rp, #UART_OFFSET(TI81XX_UART2_BASE)
  105. b 98f
  106. #endif
  107. #ifdef CONFIG_DEBUG_TI81XXUART3
  108. mov \rp, #UART_OFFSET(TI81XX_UART3_BASE)
  109. b 98f
  110. #endif
  111. #ifdef CONFIG_DEBUG_AM33XXUART1
  112. ldr \rp, =AM33XX_UART1_BASE
  113. and \rp, \rp, #0x00ffffff
  114. b 97f
  115. #endif
  116. #ifdef CONFIG_DEBUG_ZOOM_UART
  117. ldr \rp, =ZOOM_UART_BASE
  118. str \rp, [\tmp, #0] @ omap_uart_phys
  119. ldr \rp, =ZOOM_UART_VIRT
  120. str \rp, [\tmp, #4] @ omap_uart_virt
  121. mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
  122. str \rp, [\tmp, #8] @ omap_uart_lsr
  123. #endif
  124. b 10b
  125. /* AM33XX: Store both phys and virt address for the uart */
  126. 97: add \rp, \rp, #0x44000000 @ phys base
  127. str \rp, [\tmp, #0] @ omap_uart_phys
  128. sub \rp, \rp, #0x44000000 @ phys base
  129. add \rp, \rp, #0xf9000000 @ virt base
  130. str \rp, [\tmp, #4] @ omap_uart_virt
  131. mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
  132. str \rp, [\tmp, #8] @ omap_uart_lsr
  133. b 10b
  134. /* Store both phys and virt address for the uart */
  135. 98: add \rp, \rp, #0x48000000 @ phys base
  136. str \rp, [\tmp, #0] @ omap_uart_phys
  137. sub \rp, \rp, #0x48000000 @ phys base
  138. add \rp, \rp, #0xfa000000 @ virt base
  139. str \rp, [\tmp, #4] @ omap_uart_virt
  140. mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
  141. str \rp, [\tmp, #8] @ omap_uart_lsr
  142. b 10b
  143. .align
  144. 99: .word .
  145. .word omap_uart_phys
  146. .ltorg
  147. 100: /* Pass the UART_LSR reg address */
  148. ldr \tmp, [\tmp, #8] @ omap_uart_lsr
  149. add \rp, \rp, \tmp
  150. add \rv, \rv, \tmp
  151. .endm
  152. .macro senduart,rd,rx
  153. orr \rd, \rd, \rx, lsl #24 @ preserve LSR reg offset
  154. bic \rx, \rx, #0xff @ get base (THR) reg address
  155. strb \rd, [\rx] @ send lower byte of rd
  156. orr \rx, \rx, \rd, lsr #24 @ restore original rx (LSR)
  157. bic \rd, \rd, #(0xff << 24) @ restore original rd
  158. .endm
  159. .macro busyuart,rd,rx
  160. 1001: ldrb \rd, [\rx] @ rx contains UART_LSR address
  161. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  162. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  163. bne 1001b
  164. .endm
  165. .macro waituart,rd,rx
  166. .endm