debug-macro.S 2.0 KB

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