debug-macro.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 <plat/serial.h>
  15. #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
  16. .pushsection .data
  17. omap_uart_phys: .word 0
  18. omap_uart_virt: .word 0
  19. omap_uart_lsr: .word 0
  20. .popsection
  21. /*
  22. * Note that this code won't work if the bootloader passes
  23. * a wrong machine ID number in r1. To debug, just hardcode
  24. * the desired UART phys and virt addresses temporarily into
  25. * the omap_uart_phys and omap_uart_virt above.
  26. */
  27. .macro addruart, rp, rv, tmp
  28. /* Use omap_uart_phys/virt if already configured */
  29. 10: adr \rp, 99f @ get effective addr of 99f
  30. ldr \rv, [\rp] @ get absolute addr of 99f
  31. sub \rv, \rv, \rp @ offset between the two
  32. ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys
  33. sub \tmp, \rp, \rv @ make it effective
  34. ldr \rp, [\tmp, #0] @ omap_uart_phys
  35. ldr \rv, [\tmp, #4] @ omap_uart_virt
  36. cmp \rp, #0 @ is port configured?
  37. cmpne \rv, #0
  38. bne 100f @ already configured
  39. /* Check the debug UART configuration set in uncompress.h */
  40. mov \rp, pc
  41. ldr \rv, =OMAP_UART_INFO_OFS
  42. and \rp, \rp, #0xff000000
  43. ldr \rp, [\rp, \rv]
  44. /* Select the UART to use based on the UART1 scratchpad value */
  45. cmp \rp, #0 @ no port configured?
  46. beq 21f @ if none, try to use UART1
  47. cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1
  48. beq 21f @ configure OMAP2/3/4UART1
  49. cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2
  50. beq 22f @ configure OMAP2/3/4UART2
  51. cmp \rp, #OMAP2UART3 @ only on 24xx
  52. beq 23f @ configure OMAP2UART3
  53. cmp \rp, #OMAP3UART3 @ only on 34xx
  54. beq 33f @ configure OMAP3UART3
  55. cmp \rp, #OMAP4UART3 @ only on 44xx
  56. beq 43f @ configure OMAP4UART3
  57. cmp \rp, #OMAP3UART4 @ only on 36xx
  58. beq 34f @ configure OMAP3UART4
  59. cmp \rp, #OMAP4UART4 @ only on 44xx
  60. beq 44f @ configure OMAP4UART4
  61. cmp \rp, #TI81XXUART1 @ ti81Xx UART offsets different
  62. beq 81f @ configure UART1
  63. cmp \rp, #TI81XXUART2 @ ti81Xx UART offsets different
  64. beq 82f @ configure UART2
  65. cmp \rp, #TI81XXUART3 @ ti81Xx UART offsets different
  66. beq 83f @ configure UART3
  67. cmp \rp, #ZOOM_UART @ only on zoom2/3
  68. beq 95f @ configure ZOOM_UART
  69. /* Configure the UART offset from the phys/virt base */
  70. 21: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
  71. b 98f
  72. 22: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
  73. b 98f
  74. 23: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
  75. b 98f
  76. 33: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
  77. add \rp, \rp, #0x00fb0000
  78. add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
  79. b 98f
  80. 34: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
  81. add \rp, \rp, #0x00fb0000
  82. add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
  83. b 98f
  84. 43: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
  85. b 98f
  86. 44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
  87. b 98f
  88. 81: mov \rp, #UART_OFFSET(TI81XX_UART1_BASE)
  89. b 98f
  90. 82: mov \rp, #UART_OFFSET(TI81XX_UART2_BASE)
  91. b 98f
  92. 83: mov \rp, #UART_OFFSET(TI81XX_UART3_BASE)
  93. b 98f
  94. 95: ldr \rp, =ZOOM_UART_BASE
  95. str \rp, [\tmp, #0] @ omap_uart_phys
  96. ldr \rp, =ZOOM_UART_VIRT
  97. str \rp, [\tmp, #4] @ omap_uart_virt
  98. mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
  99. str \rp, [\tmp, #8] @ omap_uart_lsr
  100. b 10b
  101. /* Store both phys and virt address for the uart */
  102. 98: add \rp, \rp, #0x48000000 @ phys base
  103. str \rp, [\tmp, #0] @ omap_uart_phys
  104. sub \rp, \rp, #0x48000000 @ phys base
  105. add \rp, \rp, #0xfa000000 @ virt base
  106. str \rp, [\tmp, #4] @ omap_uart_virt
  107. mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
  108. str \rp, [\tmp, #8] @ omap_uart_lsr
  109. b 10b
  110. .align
  111. 99: .word .
  112. .word omap_uart_phys
  113. .ltorg
  114. 100: /* Pass the UART_LSR reg address */
  115. ldr \tmp, [\tmp, #8] @ omap_uart_lsr
  116. add \rp, \rp, \tmp
  117. add \rv, \rv, \tmp
  118. .endm
  119. .macro senduart,rd,rx
  120. orr \rd, \rd, \rx, lsl #24 @ preserve LSR reg offset
  121. bic \rx, \rx, #0xff @ get base (THR) reg address
  122. strb \rd, [\rx] @ send lower byte of rd
  123. orr \rx, \rx, \rd, lsr #24 @ restore original rx (LSR)
  124. bic \rd, \rd, #(0xff << 24) @ restore original rd
  125. .endm
  126. .macro busyuart,rd,rx
  127. 1001: ldrb \rd, [\rx] @ rx contains UART_LSR address
  128. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  129. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  130. bne 1001b
  131. .endm
  132. .macro waituart,rd,rx
  133. .endm