omap2plus.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Debugging macro include header
  3. *
  4. * Copyright (C) 1994-1999 Russell King
  5. * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/serial_reg.h>
  13. /* External port on Zoom2/3 */
  14. #define ZOOM_UART_BASE 0x10000000
  15. #define ZOOM_UART_VIRT 0xfa400000
  16. #define OMAP_PORT_SHIFT 2
  17. #define ZOOM_PORT_SHIFT 1
  18. #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
  19. .pushsection .data
  20. .align 2
  21. omap_uart_phys: .word 0
  22. omap_uart_virt: .word 0
  23. omap_uart_lsr: .word 0
  24. .popsection
  25. .macro addruart, rp, rv, tmp
  26. /* Use omap_uart_phys/virt if already configured */
  27. 10: 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. /* Configure the UART offset from the phys/virt base */
  38. #ifdef CONFIG_DEBUG_ZOOM_UART
  39. ldr \rp, =ZOOM_UART_BASE
  40. str \rp, [\tmp, #0] @ omap_uart_phys
  41. ldr \rp, =ZOOM_UART_VIRT
  42. str \rp, [\tmp, #4] @ omap_uart_virt
  43. mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
  44. str \rp, [\tmp, #8] @ omap_uart_lsr
  45. #endif
  46. b 10b
  47. .align
  48. 99: .word .
  49. .word omap_uart_phys
  50. .ltorg
  51. 100: /* Pass the UART_LSR reg address */
  52. ldr \tmp, [\tmp, #8] @ omap_uart_lsr
  53. add \rp, \rp, \tmp
  54. add \rv, \rv, \tmp
  55. .endm
  56. .macro senduart,rd,rx
  57. orr \rd, \rd, \rx, lsl #24 @ preserve LSR reg offset
  58. bic \rx, \rx, #0xff @ get base (THR) reg address
  59. strb \rd, [\rx] @ send lower byte of rd
  60. orr \rx, \rx, \rd, lsr #24 @ restore original rx (LSR)
  61. bic \rd, \rd, #(0xff << 24) @ restore original rd
  62. .endm
  63. .macro busyuart,rd,rx
  64. 1001: ldrb \rd, [\rx] @ rx contains UART_LSR address
  65. and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  66. teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
  67. bne 1001b
  68. .endm
  69. .macro waituart,rd,rx
  70. .endm