debug-macro.S 2.7 KB

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