debug-macro.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* arch/arm/mach-omap1/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. .pushsection .data
  16. omap_uart_phys: .word 0x0
  17. omap_uart_virt: .word 0x0
  18. .popsection
  19. /*
  20. * Note that this code won't work if the bootloader passes
  21. * a wrong machine ID number in r1. To debug, just hardcode
  22. * the desired UART phys and virt addresses temporarily into
  23. * the omap_uart_phys and omap_uart_virt above.
  24. */
  25. .macro addruart, rx, tmp
  26. /* Use omap_uart_phys/virt if already configured */
  27. 9: mrc p15, 0, \rx, c1, c0
  28. tst \rx, #1 @ MMU enabled?
  29. ldreq \rx, =omap_uart_phys @ physical base address
  30. ldrne \rx, =omap_uart_virt @ virtual base
  31. ldr \rx, [\rx, #0]
  32. cmp \rx, #0 @ is port configured?
  33. bne 99f @ already configured
  34. /* Check 7XX UART1 scratchpad register for uart to use */
  35. mrc p15, 0, \rx, c1, c0
  36. tst \rx, #1 @ MMU enabled?
  37. moveq \rx, #0xff000000 @ physical base address
  38. movne \rx, #0xfe000000 @ virtual base
  39. orr \rx, \rx, #0x00fb0000 @ OMAP1UART1
  40. ldrb \rx, [\rx, #(UART_SCR << OMAP7XX_PORT_SHIFT)]
  41. cmp \rx, #0 @ anything in 7XX scratchpad?
  42. bne 10f @ found 7XX uart
  43. /* Check 15xx/16xx UART1 scratchpad register for uart to use */
  44. mrc p15, 0, \rx, c1, c0
  45. tst \rx, #1 @ MMU enabled?
  46. moveq \rx, #0xff000000 @ physical base address
  47. movne \rx, #0xfe000000 @ virtual base
  48. orr \rx, \rx, #0x00fb0000 @ OMAP1UART1
  49. ldrb \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)]
  50. /* Select the UART to use based on the UART1 scratchpad value */
  51. 10: cmp \rx, #0 @ no port configured?
  52. beq 11f @ if none, try to use UART1
  53. cmp \rx, #OMAP1UART1
  54. beq 11f @ configure OMAP1UART1
  55. cmp \rx, #OMAP1UART2
  56. beq 12f @ configure OMAP1UART2
  57. cmp \rx, #OMAP1UART3
  58. beq 13f @ configure OMAP2UART3
  59. /* Configure the UART offset from the phys/virt base */
  60. 11: mov \rx, #0x00fb0000 @ OMAP1UART1
  61. b 98f
  62. 12: mov \rx, #0x00fb0000 @ OMAP1UART1
  63. orr \rx, \rx, #0x00000800 @ OMAP1UART2
  64. b 98f
  65. 13: mov \rx, #0x00fb0000 @ OMAP1UART1
  66. orr \rx, \rx, #0x00000800 @ OMAP1UART2
  67. orr \rx, \rx, #0x00009000 @ OMAP1UART3
  68. /* Store both phys and virt address for the uart */
  69. 98: add \rx, \rx, #0xff000000 @ phys base
  70. ldr \tmp, =omap_uart_phys
  71. str \rx, [\tmp, #0]
  72. sub \rx, \rx, #0xff000000 @ phys base
  73. add \rx, \rx, #0xfe000000 @ virt base
  74. ldr \tmp, =omap_uart_virt
  75. str \rx, [\tmp, #0]
  76. b 9b
  77. 99:
  78. .endm
  79. .macro senduart,rd,rx
  80. strb \rd, [\rx]
  81. .endm
  82. .macro busyuart,rd,rx
  83. 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
  84. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  85. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  86. beq 1002f
  87. ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
  88. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  89. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  90. bne 1001b
  91. 1002:
  92. .endm
  93. .macro waituart,rd,rx
  94. .endm