debug-macro.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * arch/arm/mach-tegra/include/mach/debug-macro.S
  3. *
  4. * Copyright (C) 2010,2011 Google, Inc.
  5. * Copyright (C) 2011-2012 NVIDIA CORPORATION. All Rights Reserved.
  6. *
  7. * Author:
  8. * Colin Cross <ccross@google.com>
  9. * Erik Gilling <konkers@google.com>
  10. * Doug Anderson <dianders@chromium.org>
  11. * Stephen Warren <swarren@nvidia.com>
  12. *
  13. * Portions based on mach-omap2's debug-macro.S
  14. * Copyright (C) 1994-1999 Russell King
  15. *
  16. * This software is licensed under the terms of the GNU General Public
  17. * License version 2, as published by the Free Software Foundation, and
  18. * may be copied, distributed, and modified under those terms.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. */
  26. #include <linux/serial_reg.h>
  27. #include <mach/iomap.h>
  28. #include <mach/irammap.h>
  29. .macro addruart, rp, rv, tmp
  30. adr \rp, 99f @ actual addr of 99f
  31. ldr \rv, [\rp] @ linked addr is stored there
  32. sub \rv, \rv, \rp @ offset between the two
  33. ldr \rp, [\rp, #4] @ linked tegra_uart_config
  34. sub \tmp, \rp, \rv @ actual tegra_uart_config
  35. ldr \rp, [\tmp] @ Load tegra_uart_config
  36. cmp \rp, #1 @ needs intitialization?
  37. bne 100f @ no; go load the addresses
  38. mov \rv, #0 @ yes; record init is done
  39. str \rv, [\tmp]
  40. mov \rp, #TEGRA_IRAM_BASE @ See if cookie is in IRAM
  41. ldr \rv, [\rp, #TEGRA_IRAM_DEBUG_UART_OFFSET]
  42. movw \rp, #TEGRA_IRAM_DEBUG_UART_COOKIE & 0xffff
  43. movt \rp, #TEGRA_IRAM_DEBUG_UART_COOKIE >> 16
  44. cmp \rv, \rp @ Cookie present?
  45. bne 100f @ No, use default UART
  46. mov \rp, #TEGRA_IRAM_BASE @ Load UART address from IRAM
  47. ldr \rv, [\rp, #TEGRA_IRAM_DEBUG_UART_OFFSET + 4]
  48. str \rv, [\tmp, #4] @ Store in tegra_uart_phys
  49. sub \rv, \rv, #IO_APB_PHYS @ Calculate virt address
  50. add \rv, \rv, #IO_APB_VIRT
  51. str \rv, [\tmp, #8] @ Store in tegra_uart_virt
  52. b 100f
  53. .align
  54. 99: .word .
  55. .word tegra_uart_config
  56. .ltorg
  57. 100: ldr \rp, [\tmp, #4] @ Load tegra_uart_phys
  58. ldr \rv, [\tmp, #8] @ Load tegra_uart_virt
  59. .endm
  60. #define UART_SHIFT 2
  61. /*
  62. * Code below is swiped from <asm/hardware/debug-8250.S>, but add an extra
  63. * check to make sure that we aren't in the CONFIG_TEGRA_DEBUG_UART_NONE case.
  64. * We use the fact that all 5 valid UART addresses all have something in the
  65. * 2nd-to-lowest byte.
  66. */
  67. .macro senduart, rd, rx
  68. tst \rx, #0x0000ff00
  69. strneb \rd, [\rx, #UART_TX << UART_SHIFT]
  70. 1001:
  71. .endm
  72. .macro busyuart, rd, rx
  73. tst \rx, #0x0000ff00
  74. beq 1002f
  75. 1001: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT]
  76. and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
  77. teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
  78. bne 1001b
  79. 1002:
  80. .endm
  81. .macro waituart, rd, rx
  82. #ifdef FLOW_CONTROL
  83. tst \rx, #0x0000ff00
  84. beq 1002f
  85. 1001: ldrb \rd, [\rx, #UART_MSR << UART_SHIFT]
  86. tst \rd, #UART_MSR_CTS
  87. beq 1001b
  88. 1002:
  89. #endif
  90. .endm