debug-macro.S 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. .pushsection .data
  22. davinci_uart_phys: .word 0
  23. davinci_uart_virt: .word 0
  24. .popsection
  25. .macro addruart, rp, rv
  26. /* Use davinci_uart_phys/virt if already configured */
  27. 10: mrc p15, 0, \rp, c1, c0
  28. tst \rp, #1 @ MMU enabled?
  29. ldreq \rp, =__virt_to_phys(davinci_uart_phys)
  30. ldrne \rp, =davinci_uart_phys
  31. add \rv, \rp, #4 @ davinci_uart_virt
  32. ldr \rp, [\rp, #0]
  33. ldr \rv, [\rv, #0]
  34. cmp \rp, #0 @ is port configured?
  35. cmpne \rv, #0
  36. bne 99f @ already configured
  37. /* Check the debug UART address set in uncompress.h */
  38. mrc p15, 0, \rp, c1, c0
  39. tst \rp, #1 @ MMU enabled?
  40. /* Copy uart phys address from decompressor uart info */
  41. ldreq \rv, =__virt_to_phys(davinci_uart_phys)
  42. ldrne \rv, =davinci_uart_phys
  43. ldreq \rp, =DAVINCI_UART_INFO
  44. ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
  45. ldr \rp, [\rp, #0]
  46. str \rp, [\rv]
  47. /* Copy uart virt address from decompressor uart info */
  48. ldreq \rv, =__virt_to_phys(davinci_uart_virt)
  49. ldrne \rv, =davinci_uart_virt
  50. ldreq \rp, =DAVINCI_UART_INFO
  51. ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
  52. ldr \rp, [\rp, #4]
  53. str \rp, [\rv]
  54. b 10b
  55. 99:
  56. .endm
  57. .macro senduart,rd,rx
  58. str \rd, [\rx, #UART_TX << UART_SHIFT]
  59. .endm
  60. .macro busyuart,rd,rx
  61. 1002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
  62. and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
  63. teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
  64. bne 1002b
  65. .endm
  66. .macro waituart,rd,rx
  67. #ifdef FLOW_CONTROL
  68. 1001: ldr \rd, [\rx, #UART_MSR << UART_SHIFT]
  69. tst \rd, #UART_MSR_CTS
  70. beq 1001b
  71. #endif
  72. .endm