coresight.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * linux/arch/arm/include/asm/hardware/coresight.h
  3. *
  4. * CoreSight components' registers
  5. *
  6. * Copyright (C) 2009 Nokia Corporation.
  7. * Alexander Shishkin
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef __ASM_HARDWARE_CORESIGHT_H
  14. #define __ASM_HARDWARE_CORESIGHT_H
  15. #define TRACER_ACCESSED_BIT 0
  16. #define TRACER_RUNNING_BIT 1
  17. #define TRACER_CYCLE_ACC_BIT 2
  18. #define TRACER_ACCESSED BIT(TRACER_ACCESSED_BIT)
  19. #define TRACER_RUNNING BIT(TRACER_RUNNING_BIT)
  20. #define TRACER_CYCLE_ACC BIT(TRACER_CYCLE_ACC_BIT)
  21. #define TRACER_TIMEOUT 10000
  22. #define etm_writel(t, v, x) \
  23. (__raw_writel((v), (t)->etm_regs + (x)))
  24. #define etm_readl(t, x) (__raw_readl((t)->etm_regs + (x)))
  25. /* CoreSight Management Registers */
  26. #define CSMR_LOCKACCESS 0xfb0
  27. #define CSMR_LOCKSTATUS 0xfb4
  28. #define CSMR_AUTHSTATUS 0xfb8
  29. #define CSMR_DEVID 0xfc8
  30. #define CSMR_DEVTYPE 0xfcc
  31. /* CoreSight Component Registers */
  32. #define CSCR_CLASS 0xff4
  33. #define UNLOCK_MAGIC 0xc5acce55
  34. /* ETM control register, "ETM Architecture", 3.3.1 */
  35. #define ETMR_CTRL 0
  36. #define ETMCTRL_POWERDOWN 1
  37. #define ETMCTRL_PROGRAM (1 << 10)
  38. #define ETMCTRL_PORTSEL (1 << 11)
  39. #define ETMCTRL_DO_CONTEXTID (3 << 14)
  40. #define ETMCTRL_PORTMASK1 (7 << 4)
  41. #define ETMCTRL_PORTMASK2 (1 << 21)
  42. #define ETMCTRL_PORTMASK (ETMCTRL_PORTMASK1 | ETMCTRL_PORTMASK2)
  43. #define ETMCTRL_PORTSIZE(x) ((((x) & 7) << 4) | (!!((x) & 8)) << 21)
  44. #define ETMCTRL_DO_CPRT (1 << 1)
  45. #define ETMCTRL_DATAMASK (3 << 2)
  46. #define ETMCTRL_DATA_DO_DATA (1 << 2)
  47. #define ETMCTRL_DATA_DO_ADDR (1 << 3)
  48. #define ETMCTRL_DATA_DO_BOTH (ETMCTRL_DATA_DO_DATA | ETMCTRL_DATA_DO_ADDR)
  49. #define ETMCTRL_BRANCH_OUTPUT (1 << 8)
  50. #define ETMCTRL_CYCLEACCURATE (1 << 12)
  51. /* ETM configuration code register */
  52. #define ETMR_CONFCODE (0x04)
  53. /* ETM trace start/stop resource control register */
  54. #define ETMR_TRACESSCTRL (0x18)
  55. /* ETM trigger event register */
  56. #define ETMR_TRIGEVT (0x08)
  57. /* address access type register bits, "ETM architecture",
  58. * table 3-27 */
  59. /* - access type */
  60. #define ETMAAT_IFETCH 0
  61. #define ETMAAT_IEXEC 1
  62. #define ETMAAT_IEXECPASS 2
  63. #define ETMAAT_IEXECFAIL 3
  64. #define ETMAAT_DLOADSTORE 4
  65. #define ETMAAT_DLOAD 5
  66. #define ETMAAT_DSTORE 6
  67. /* - comparison access size */
  68. #define ETMAAT_JAVA (0 << 3)
  69. #define ETMAAT_THUMB (1 << 3)
  70. #define ETMAAT_ARM (3 << 3)
  71. /* - data value comparison control */
  72. #define ETMAAT_NOVALCMP (0 << 5)
  73. #define ETMAAT_VALMATCH (1 << 5)
  74. #define ETMAAT_VALNOMATCH (3 << 5)
  75. /* - exact match */
  76. #define ETMAAT_EXACTMATCH (1 << 7)
  77. /* - context id comparator control */
  78. #define ETMAAT_IGNCONTEXTID (0 << 8)
  79. #define ETMAAT_VALUE1 (1 << 8)
  80. #define ETMAAT_VALUE2 (2 << 8)
  81. #define ETMAAT_VALUE3 (3 << 8)
  82. /* - security level control */
  83. #define ETMAAT_IGNSECURITY (0 << 10)
  84. #define ETMAAT_NSONLY (1 << 10)
  85. #define ETMAAT_SONLY (2 << 10)
  86. #define ETMR_COMP_VAL(x) (0x40 + (x) * 4)
  87. #define ETMR_COMP_ACC_TYPE(x) (0x80 + (x) * 4)
  88. /* ETM status register, "ETM Architecture", 3.3.2 */
  89. #define ETMR_STATUS (0x10)
  90. #define ETMST_OVERFLOW BIT(0)
  91. #define ETMST_PROGBIT BIT(1)
  92. #define ETMST_STARTSTOP BIT(2)
  93. #define ETMST_TRIGGER BIT(3)
  94. #define etm_progbit(t) (etm_readl((t), ETMR_STATUS) & ETMST_PROGBIT)
  95. #define etm_started(t) (etm_readl((t), ETMR_STATUS) & ETMST_STARTSTOP)
  96. #define etm_triggered(t) (etm_readl((t), ETMR_STATUS) & ETMST_TRIGGER)
  97. #define ETMR_TRACEENCTRL2 0x1c
  98. #define ETMR_TRACEENCTRL 0x24
  99. #define ETMTE_INCLEXCL BIT(24)
  100. #define ETMR_TRACEENEVT 0x20
  101. #define ETMCTRL_OPTS (ETMCTRL_DO_CPRT | \
  102. ETMCTRL_DATA_DO_ADDR | \
  103. ETMCTRL_BRANCH_OUTPUT | \
  104. ETMCTRL_DO_CONTEXTID)
  105. /* ETM management registers, "ETM Architecture", 3.5.24 */
  106. #define ETMMR_OSLAR 0x300
  107. #define ETMMR_OSLSR 0x304
  108. #define ETMMR_OSSRR 0x308
  109. #define ETMMR_PDSR 0x314
  110. /* ETB registers, "CoreSight Components TRM", 9.3 */
  111. #define ETBR_DEPTH 0x04
  112. #define ETBR_STATUS 0x0c
  113. #define ETBR_READMEM 0x10
  114. #define ETBR_READADDR 0x14
  115. #define ETBR_WRITEADDR 0x18
  116. #define ETBR_TRIGGERCOUNT 0x1c
  117. #define ETBR_CTRL 0x20
  118. #define ETBR_FORMATTERCTRL 0x304
  119. #define ETBFF_ENFTC 1
  120. #define ETBFF_ENFCONT BIT(1)
  121. #define ETBFF_FONFLIN BIT(4)
  122. #define ETBFF_MANUAL_FLUSH BIT(6)
  123. #define ETBFF_TRIGIN BIT(8)
  124. #define ETBFF_TRIGEVT BIT(9)
  125. #define ETBFF_TRIGFL BIT(10)
  126. #define etb_writel(t, v, x) \
  127. (__raw_writel((v), (t)->etb_regs + (x)))
  128. #define etb_readl(t, x) (__raw_readl((t)->etb_regs + (x)))
  129. #define etm_lock(t) do { etm_writel((t), 0, CSMR_LOCKACCESS); } while (0)
  130. #define etm_unlock(t) \
  131. do { etm_writel((t), UNLOCK_MAGIC, CSMR_LOCKACCESS); } while (0)
  132. #define etb_lock(t) do { etb_writel((t), 0, CSMR_LOCKACCESS); } while (0)
  133. #define etb_unlock(t) \
  134. do { etb_writel((t), UNLOCK_MAGIC, CSMR_LOCKACCESS); } while (0)
  135. #endif /* __ASM_HARDWARE_CORESIGHT_H */