debug-macro.S 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Debugging macro for DaVinci
  3. *
  4. * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
  5. *
  6. * 2007 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. /* Modifications
  12. * Jan 2009 Chaithrika U S Added senduart, busyuart, waituart
  13. * macros, based on debug-8250.S file
  14. * but using 32-bit accesses required for
  15. * some davinci devices.
  16. */
  17. #include <linux/serial_reg.h>
  18. #include <asm/memory.h>
  19. #include <mach/serial.h>
  20. #define UART_SHIFT 2
  21. #define davinci_uart_v2p(x) ((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
  22. #define davinci_uart_p2v(x) ((x) - PLAT_PHYS_OFFSET + PAGE_OFFSET)
  23. .pushsection .data
  24. davinci_uart_phys: .word 0
  25. davinci_uart_virt: .word 0
  26. .popsection
  27. .macro addruart, rp, rv
  28. /* Use davinci_uart_phys/virt if already configured */
  29. 10: mrc p15, 0, \rp, c1, c0
  30. tst \rp, #1 @ MMU enabled?
  31. ldreq \rp, =davinci_uart_v2p(davinci_uart_phys)
  32. ldrne \rp, =davinci_uart_phys
  33. add \rv, \rp, #4 @ davinci_uart_virt
  34. ldr \rp, [\rp, #0]
  35. ldr \rv, [\rv, #0]
  36. cmp \rp, #0 @ is port configured?
  37. cmpne \rv, #0
  38. bne 99f @ already configured
  39. /* Check the debug UART address set in uncompress.h */
  40. mrc p15, 0, \rp, c1, c0
  41. tst \rp, #1 @ MMU enabled?
  42. /* Copy uart phys address from decompressor uart info */
  43. ldreq \rv, =davinci_uart_v2p(davinci_uart_phys)
  44. ldrne \rv, =davinci_uart_phys
  45. ldreq \rp, =DAVINCI_UART_INFO
  46. ldrne \rp, =davinci_uart_p2v(DAVINCI_UART_INFO)
  47. ldr \rp, [\rp, #0]
  48. str \rp, [\rv]
  49. /* Copy uart virt address from decompressor uart info */
  50. ldreq \rv, =davinci_uart_v2p(davinci_uart_virt)
  51. ldrne \rv, =davinci_uart_virt
  52. ldreq \rp, =DAVINCI_UART_INFO
  53. ldrne \rp, =davinci_uart_p2v(DAVINCI_UART_INFO)
  54. ldr \rp, [\rp, #4]
  55. str \rp, [\rv]
  56. b 10b
  57. 99:
  58. .endm
  59. .macro senduart,rd,rx
  60. str \rd, [\rx, #UART_TX << UART_SHIFT]
  61. .endm
  62. .macro busyuart,rd,rx
  63. 1002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
  64. and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
  65. teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
  66. bne 1002b
  67. .endm
  68. .macro waituart,rd,rx
  69. #ifdef FLOW_CONTROL
  70. 1001: ldr \rd, [\rx, #UART_MSR << UART_SHIFT]
  71. tst \rd, #UART_MSR_CTS
  72. beq 1001b
  73. #endif
  74. .endm