debug-macro.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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, tmp
  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. and \rp, pc, #0xff000000
  43. ldr \rv, =DAVINCI_UART_INFO_OFS
  44. add \rp, \rp, \rv
  45. ldreq \rv, =davinci_uart_v2p(davinci_uart_phys)
  46. ldrne \rv, =davinci_uart_phys
  47. /* Copy uart phys address from decompressor uart info */
  48. ldr \tmp, [\rp, #0]
  49. str \tmp, [\rv, #0]
  50. /* Copy uart virt address from decompressor uart info */
  51. ldr \tmp, [\rp, #4]
  52. str \tmp, [\rv, #4]
  53. b 10b
  54. 99:
  55. .endm
  56. .macro senduart,rd,rx
  57. str \rd, [\rx, #UART_TX << UART_SHIFT]
  58. .endm
  59. .macro busyuart,rd,rx
  60. 1002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
  61. and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
  62. teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
  63. bne 1002b
  64. .endm
  65. .macro waituart,rd,rx
  66. #ifdef FLOW_CONTROL
  67. 1001: ldr \rd, [\rx, #UART_MSR << UART_SHIFT]
  68. tst \rd, #UART_MSR_CTS
  69. beq 1001b
  70. #endif
  71. .endm