debug-macro.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #define omap_uart_v2p(x) ((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
  17. #define omap_uart_p2v(x) ((x) - PLAT_PHYS_OFFSET + PAGE_OFFSET)
  18. .pushsection .data
  19. omap_uart_phys: .word 0x0
  20. omap_uart_virt: .word 0x0
  21. .popsection
  22. /*
  23. * Note that this code won't work if the bootloader passes
  24. * a wrong machine ID number in r1. To debug, just hardcode
  25. * the desired UART phys and virt addresses temporarily into
  26. * the omap_uart_phys and omap_uart_virt above.
  27. */
  28. .macro addruart, rp, rv
  29. /* Use omap_uart_phys/virt if already configured */
  30. 9: mrc p15, 0, \rp, c1, c0
  31. tst \rp, #1 @ MMU enabled?
  32. ldreq \rp, =omap_uart_v2p(omap_uart_phys) @ MMU disabled
  33. ldrne \rp, =omap_uart_phys @ MMU enabled
  34. add \rv, \rp, #4 @ omap_uart_virt
  35. ldr \rp, [\rp, #0]
  36. ldr \rv, [\rv, #0]
  37. cmp \rp, #0 @ is port configured?
  38. cmpne \rv, #0
  39. bne 99f @ already configured
  40. /* Check the debug UART configuration set in uncompress.h */
  41. mrc p15, 0, \rp, c1, c0
  42. tst \rp, #1 @ MMU enabled?
  43. ldreq \rp, =OMAP_UART_INFO @ MMU not enabled
  44. ldrne \rp, =omap_uart_p2v(OMAP_UART_INFO) @ MMU enabled
  45. ldr \rp, [\rp, #0]
  46. /* Select the UART to use based on the UART1 scratchpad value */
  47. 10: cmp \rp, #0 @ no port configured?
  48. beq 11f @ if none, try to use UART1
  49. cmp \rp, #OMAP1UART1
  50. beq 11f @ configure OMAP1UART1
  51. cmp \rp, #OMAP1UART2
  52. beq 12f @ configure OMAP1UART2
  53. cmp \rp, #OMAP1UART3
  54. beq 13f @ configure OMAP2UART3
  55. /* Configure the UART offset from the phys/virt base */
  56. 11: mov \rp, #0x00fb0000 @ OMAP1UART1
  57. b 98f
  58. 12: mov \rp, #0x00fb0000 @ OMAP1UART1
  59. orr \rp, \rp, #0x00000800 @ OMAP1UART2
  60. b 98f
  61. 13: mov \rp, #0x00fb0000 @ OMAP1UART1
  62. orr \rp, \rp, #0x00000800 @ OMAP1UART2
  63. orr \rp, \rp, #0x00009000 @ OMAP1UART3
  64. /* Store both phys and virt address for the uart */
  65. 98: add \rp, \rp, #0xff000000 @ phys base
  66. mrc p15, 0, \rv, c1, c0
  67. tst \rv, #1 @ MMU enabled?
  68. ldreq \rv, =omap_uart_v2p(omap_uart_phys) @ MMU disabled
  69. ldrne \rv, =omap_uart_phys @ MMU enabled
  70. str \rp, [\rv, #0]
  71. sub \rp, \rp, #0xff000000 @ phys base
  72. add \rp, \rp, #0xfe000000 @ virt base
  73. add \rv, \rv, #4 @ omap_uart_lsr
  74. str \rp, [\rv, #0]
  75. b 9b
  76. 99:
  77. .endm
  78. .macro senduart,rd,rx
  79. strb \rd, [\rx]
  80. .endm
  81. .macro busyuart,rd,rx
  82. 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
  83. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  84. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  85. beq 1002f
  86. ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
  87. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  88. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  89. bne 1001b
  90. 1002:
  91. .endm
  92. .macro waituart,rd,rx
  93. .endm