omap2plus.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  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. #include <linux/serial_reg.h>
  9. /* External port on Zoom2/3 */
  10. #define ZOOM_UART_BASE 0x10000000
  11. #define ZOOM_UART_VIRT 0xfa400000
  12. #define OMAP_PORT_SHIFT 2
  13. #define ZOOM_PORT_SHIFT 1
  14. #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
  15. .pushsection .data
  16. .align 2
  17. omap_uart_phys: .word 0
  18. omap_uart_virt: .word 0
  19. omap_uart_lsr: .word 0
  20. .popsection
  21. .macro addruart, rp, rv, tmp
  22. /* Use omap_uart_phys/virt if already configured */
  23. 10: adr \rp, 99f @ get effective addr of 99f
  24. ldr \rv, [\rp] @ get absolute addr of 99f
  25. sub \rv, \rv, \rp @ offset between the two
  26. ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys
  27. sub \tmp, \rp, \rv @ make it effective
  28. ldr \rp, [\tmp, #0] @ omap_uart_phys
  29. ldr \rv, [\tmp, #4] @ omap_uart_virt
  30. cmp \rp, #0 @ is port configured?
  31. cmpne \rv, #0
  32. bne 100f @ already configured
  33. /* Configure the UART offset from the phys/virt base */
  34. #ifdef CONFIG_DEBUG_ZOOM_UART
  35. ldr \rp, =ZOOM_UART_BASE
  36. str \rp, [\tmp, #0] @ omap_uart_phys
  37. ldr \rp, =ZOOM_UART_VIRT
  38. str \rp, [\tmp, #4] @ omap_uart_virt
  39. mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
  40. str \rp, [\tmp, #8] @ omap_uart_lsr
  41. #endif
  42. b 10b
  43. .align
  44. 99: .word .
  45. .word omap_uart_phys
  46. .ltorg
  47. 100: /* Pass the UART_LSR reg address */
  48. ldr \tmp, [\tmp, #8] @ omap_uart_lsr
  49. add \rp, \rp, \tmp
  50. add \rv, \rv, \tmp
  51. .endm
  52. .macro senduart,rd,rx
  53. orr \rd, \rd, \rx, lsl #24 @ preserve LSR reg offset
  54. bic \rx, \rx, #0xff @ get base (THR) reg address
  55. strb \rd, [\rx] @ send lower byte of rd
  56. orr \rx, \rx, \rd, lsr #24 @ restore original rx (LSR)
  57. bic \rd, \rd, #(0xff << 24) @ restore original rd
  58. .endm
  59. .macro busyuart,rd,rx
  60. 1001: ldrb \rd, [\rx] @ rx contains UART_LSR address
  61. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  62. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  63. bne 1001b
  64. .endm
  65. .macro waituartcts,rd,rx
  66. .endm
  67. .macro waituarttxrdy,rd,rx
  68. .endm