debug-macro.S 2.8 KB

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