debug-macro.S 2.9 KB

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