debug-macro.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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, rx, tmp
  27. /* Use omap_uart_phys/virt if already configured */
  28. 9: mrc p15, 0, \rx, c1, c0
  29. tst \rx, #1 @ MMU enabled?
  30. ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address
  31. ldrne \rx, =omap_uart_virt @ virtual base
  32. ldr \rx, [\rx, #0]
  33. cmp \rx, #0 @ is port configured?
  34. bne 99f @ already configured
  35. /* Check the debug UART configuration set in uncompress.h */
  36. mrc p15, 0, \rx, c1, c0
  37. tst \rx, #1 @ MMU enabled?
  38. ldreq \rx, =OMAP_UART_INFO
  39. ldrne \rx, =__phys_to_virt(OMAP_UART_INFO)
  40. ldr \rx, [\rx, #0]
  41. /* Select the UART to use based on the UART1 scratchpad value */
  42. 10: cmp \rx, #0 @ no port configured?
  43. beq 11f @ if none, try to use UART1
  44. cmp \rx, #OMAP1UART1
  45. beq 11f @ configure OMAP1UART1
  46. cmp \rx, #OMAP1UART2
  47. beq 12f @ configure OMAP1UART2
  48. cmp \rx, #OMAP1UART3
  49. beq 13f @ configure OMAP2UART3
  50. /* Configure the UART offset from the phys/virt base */
  51. 11: mov \rx, #0x00fb0000 @ OMAP1UART1
  52. b 98f
  53. 12: mov \rx, #0x00fb0000 @ OMAP1UART1
  54. orr \rx, \rx, #0x00000800 @ OMAP1UART2
  55. b 98f
  56. 13: mov \rx, #0x00fb0000 @ OMAP1UART1
  57. orr \rx, \rx, #0x00000800 @ OMAP1UART2
  58. orr \rx, \rx, #0x00009000 @ OMAP1UART3
  59. /* Store both phys and virt address for the uart */
  60. 98: add \rx, \rx, #0xff000000 @ phys base
  61. mrc p15, 0, \tmp, c1, c0
  62. tst \tmp, #1 @ MMU enabled?
  63. ldreq \tmp, =__virt_to_phys(omap_uart_phys)
  64. ldrne \tmp, =omap_uart_phys
  65. str \rx, [\tmp, #0]
  66. sub \rx, \rx, #0xff000000 @ phys base
  67. add \rx, \rx, #0xfe000000 @ virt base
  68. ldreq \tmp, =__virt_to_phys(omap_uart_virt)
  69. ldrne \tmp, =omap_uart_virt
  70. str \rx, [\tmp, #0]
  71. b 9b
  72. 99:
  73. .endm
  74. .macro senduart,rd,rx
  75. strb \rd, [\rx]
  76. .endm
  77. .macro busyuart,rd,rx
  78. 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
  79. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  80. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  81. beq 1002f
  82. ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
  83. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  84. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  85. bne 1001b
  86. 1002:
  87. .endm
  88. .macro waituart,rd,rx
  89. .endm