debug-macro.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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, rx, tmp
  29. /* Use omap_uart_phys/virt if already configured */
  30. 10: mrc p15, 0, \rx, c1, c0
  31. tst \rx, #1 @ MMU enabled?
  32. ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address
  33. ldrne \rx, =omap_uart_virt @ virtual base address
  34. ldr \rx, [\rx, #0]
  35. cmp \rx, #0 @ is port configured?
  36. bne 99f @ already configured
  37. /* Check the debug UART configuration set in uncompress.h */
  38. mrc p15, 0, \rx, c1, c0
  39. tst \rx, #1 @ MMU enabled?
  40. ldreq \rx, =OMAP_UART_INFO
  41. ldrne \rx, =__phys_to_virt(OMAP_UART_INFO)
  42. ldr \rx, [\rx, #0]
  43. /* Select the UART to use based on the UART1 scratchpad value */
  44. cmp \rx, #0 @ no port configured?
  45. beq 21f @ if none, try to use UART1
  46. cmp \rx, #OMAP2UART1 @ OMAP2/3/4UART1
  47. beq 21f @ configure OMAP2/3/4UART1
  48. cmp \rx, #OMAP2UART2 @ OMAP2/3/4UART2
  49. beq 22f @ configure OMAP2/3/4UART2
  50. cmp \rx, #OMAP2UART3 @ only on 24xx
  51. beq 23f @ configure OMAP2UART3
  52. cmp \rx, #OMAP3UART3 @ only on 34xx
  53. beq 33f @ configure OMAP3UART3
  54. cmp \rx, #OMAP4UART3 @ only on 44xx
  55. beq 43f @ configure OMAP4UART3
  56. cmp \rx, #OMAP3UART4 @ only on 36xx
  57. beq 34f @ configure OMAP3UART4
  58. cmp \rx, #OMAP4UART4 @ only on 44xx
  59. beq 44f @ configure OMAP4UART4
  60. cmp \rx, #ZOOM_UART @ only on zoom2/3
  61. beq 95f @ configure ZOOM_UART
  62. /* Configure the UART offset from the phys/virt base */
  63. 21: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
  64. b 98f
  65. 22: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
  66. b 98f
  67. 23: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE)
  68. b 98f
  69. 33: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
  70. add \rx, \rx, #0x00fb0000
  71. add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE
  72. b 98f
  73. 34: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
  74. add \rx, \rx, #0x00fb0000
  75. add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE
  76. b 98f
  77. 43: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE)
  78. b 98f
  79. 44: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE)
  80. b 98f
  81. 95: ldr \rx, =ZOOM_UART_BASE
  82. mrc p15, 0, \tmp, c1, c0
  83. tst \tmp, #1 @ MMU enabled?
  84. ldreq \tmp, =__virt_to_phys(omap_uart_phys)
  85. ldrne \tmp, =omap_uart_phys
  86. str \rx, [\tmp, #0]
  87. ldr \rx, =ZOOM_UART_VIRT
  88. ldreq \tmp, =__virt_to_phys(omap_uart_virt)
  89. ldrne \tmp, =omap_uart_virt
  90. str \rx, [\tmp, #0]
  91. mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
  92. ldreq \tmp, =__virt_to_phys(omap_uart_lsr)
  93. ldrne \tmp, =omap_uart_lsr
  94. str \rx, [\tmp, #0]
  95. b 10b
  96. /* Store both phys and virt address for the uart */
  97. 98: add \rx, \rx, #0x48000000 @ phys base
  98. mrc p15, 0, \tmp, c1, c0
  99. tst \tmp, #1 @ MMU enabled?
  100. ldreq \tmp, =__virt_to_phys(omap_uart_phys)
  101. ldrne \tmp, =omap_uart_phys
  102. str \rx, [\tmp, #0]
  103. sub \rx, \rx, #0x48000000 @ phys base
  104. add \rx, \rx, #0xfa000000 @ virt base
  105. ldreq \tmp, =__virt_to_phys(omap_uart_virt)
  106. ldrne \tmp, =omap_uart_virt
  107. str \rx, [\tmp, #0]
  108. mov \rx, #(UART_LSR << OMAP_PORT_SHIFT)
  109. ldreq \tmp, =__virt_to_phys(omap_uart_lsr)
  110. ldrne \tmp, =omap_uart_lsr
  111. str \rx, [\tmp, #0]
  112. b 10b
  113. 99:
  114. .endm
  115. .macro senduart,rd,rx
  116. strb \rd, [\rx]
  117. .endm
  118. .macro busyuart,rd,rx
  119. 1001: mrc p15, 0, \rd, c1, c0
  120. tst \rd, #1 @ MMU enabled?
  121. ldreq \rd, =__virt_to_phys(omap_uart_lsr)
  122. ldrne \rd, =omap_uart_lsr
  123. ldr \rd, [\rd, #0]
  124. ldrb \rd, [\rx, \rd]
  125. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  126. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  127. bne 1001b
  128. .endm
  129. .macro waituart,rd,rx
  130. .endm