debug-macro.S 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* arch/arm/mach-omap2/include/mach/debug-macro.S
  2. *
  3. * Debugging macro include header
  4. *
  5. * Copyright (C) 1994-1999 Russell King
  6. * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #include <linux/serial_reg.h>
  14. #include <asm/memory.h>
  15. #include <plat/serial.h>
  16. #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
  17. .pushsection .data
  18. omap_uart_phys: .word 0
  19. omap_uart_virt: .word 0
  20. omap_uart_lsr: .word 0
  21. .popsection
  22. /*
  23. * Note that this code won't work if the bootloader passes
  24. * a wrong machine ID number in r1. To debug, just hardcode
  25. * the desired UART phys and virt addresses temporarily into
  26. * the omap_uart_phys and omap_uart_virt above.
  27. */
  28. .macro addruart, rp, rv
  29. /* Use omap_uart_phys/virt if already configured */
  30. 10: mrc p15, 0, \rp, c1, c0
  31. tst \rp, #1 @ MMU enabled?
  32. ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
  33. ldrne \rp, =omap_uart_phys @ MMU enabled
  34. add \rv, \rp, #4 @ omap_uart_virt
  35. ldr \rp, [\rp, #0]
  36. ldr \rv, [\rv, #0]
  37. cmp \rp, #0 @ is port configured?
  38. cmpne \rv, #0
  39. bne 99f @ already configured
  40. /* Check the debug UART configuration set in uncompress.h */
  41. mrc p15, 0, \rp, c1, c0
  42. tst \rp, #1 @ MMU enabled?
  43. ldreq \rp, =OMAP_UART_INFO @ MMU not enabled
  44. ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled
  45. ldr \rp, [\rp, #0]
  46. /* Select the UART to use based on the UART1 scratchpad value */
  47. cmp \rp, #0 @ no port configured?
  48. beq 21f @ if none, try to use UART1
  49. cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1
  50. beq 21f @ configure OMAP2/3/4UART1
  51. cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2
  52. beq 22f @ configure OMAP2/3/4UART2
  53. cmp \rp, #OMAP2UART3 @ only on 24xx
  54. beq 23f @ configure OMAP2UART3
  55. cmp \rp, #OMAP3UART3 @ only on 34xx
  56. beq 33f @ configure OMAP3UART3
  57. cmp \rp, #OMAP4UART3 @ only on 44xx
  58. beq 43f @ configure OMAP4UART3
  59. cmp \rp, #OMAP3UART4 @ only on 36xx
  60. beq 34f @ configure OMAP3UART4
  61. cmp \rp, #OMAP4UART4 @ only on 44xx
  62. beq 44f @ configure OMAP4UART4
  63. cmp \rp, #TI816XUART1 @ ti816x UART offsets different
  64. beq 81f @ configure UART1
  65. cmp \rp, #TI816XUART2 @ ti816x UART offsets different
  66. beq 82f @ configure UART2
  67. cmp \rp, #TI816XUART3 @ ti816x UART offsets different
  68. beq 83f @ configure UART3
  69. cmp \rp, #ZOOM_UART @ only on zoom2/3
  70. beq 95f @ configure ZOOM_UART
  71. /* Configure the UART offset from the phys/virt base */
  72. 21: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
  73. b 98f
  74. 22: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
  75. b 98f
  76. 23: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
  77. b 98f
  78. 33: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
  79. add \rp, \rp, #0x00fb0000
  80. add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
  81. b 98f
  82. 34: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
  83. add \rp, \rp, #0x00fb0000
  84. add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
  85. b 98f
  86. 43: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
  87. b 98f
  88. 44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
  89. b 98f
  90. 81: mov \rp, #UART_OFFSET(TI816X_UART1_BASE)
  91. b 98f
  92. 82: mov \rp, #UART_OFFSET(TI816X_UART2_BASE)
  93. b 98f
  94. 83: mov \rp, #UART_OFFSET(TI816X_UART3_BASE)
  95. b 98f
  96. 95: ldr \rp, =ZOOM_UART_BASE
  97. mrc p15, 0, \rv, c1, c0
  98. tst \rv, #1 @ MMU enabled?
  99. ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
  100. ldrne \rv, =omap_uart_phys @ MMU enabled
  101. str \rp, [\rv, #0]
  102. ldr \rp, =ZOOM_UART_VIRT
  103. add \rv, \rv, #4 @ omap_uart_virt
  104. str \rp, [\rv, #0]
  105. mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
  106. add \rv, \rv, #4 @ omap_uart_lsr
  107. str \rp, [\rv, #0]
  108. b 10b
  109. /* Store both phys and virt address for the uart */
  110. 98: add \rp, \rp, #0x48000000 @ phys base
  111. mrc p15, 0, \rv, c1, c0
  112. tst \rv, #1 @ MMU enabled?
  113. ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
  114. ldrne \rv, =omap_uart_phys @ MMU enabled
  115. str \rp, [\rv, #0]
  116. sub \rp, \rp, #0x48000000 @ phys base
  117. add \rp, \rp, #0xfa000000 @ virt base
  118. add \rv, \rv, #4 @ omap_uart_virt
  119. str \rp, [\rv, #0]
  120. mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
  121. add \rv, \rv, #4 @ omap_uart_lsr
  122. str \rp, [\rv, #0]
  123. b 10b
  124. 99:
  125. .endm
  126. .macro senduart,rd,rx
  127. strb \rd, [\rx]
  128. .endm
  129. .macro busyuart,rd,rx
  130. 1001: mrc p15, 0, \rd, c1, c0
  131. tst \rd, #1 @ MMU enabled?
  132. ldreq \rd, =__virt_to_phys(omap_uart_lsr) @ MMU not enabled
  133. ldrne \rd, =omap_uart_lsr @ MMU enabled
  134. ldr \rd, [\rd, #0]
  135. ldrb \rd, [\rx, \rd]
  136. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  137. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  138. bne 1001b
  139. .endm
  140. .macro waituart,rd,rx
  141. .endm