coresight-tmc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright(C) 2015 Linaro Limited. All rights reserved.
  3. * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _CORESIGHT_TMC_H
  18. #define _CORESIGHT_TMC_H
  19. #include <linux/miscdevice.h>
  20. #define TMC_RSZ 0x004
  21. #define TMC_STS 0x00c
  22. #define TMC_RRD 0x010
  23. #define TMC_RRP 0x014
  24. #define TMC_RWP 0x018
  25. #define TMC_TRG 0x01c
  26. #define TMC_CTL 0x020
  27. #define TMC_RWD 0x024
  28. #define TMC_MODE 0x028
  29. #define TMC_LBUFLEVEL 0x02c
  30. #define TMC_CBUFLEVEL 0x030
  31. #define TMC_BUFWM 0x034
  32. #define TMC_RRPHI 0x038
  33. #define TMC_RWPHI 0x03c
  34. #define TMC_AXICTL 0x110
  35. #define TMC_DBALO 0x118
  36. #define TMC_DBAHI 0x11c
  37. #define TMC_FFSR 0x300
  38. #define TMC_FFCR 0x304
  39. #define TMC_PSCR 0x308
  40. #define TMC_ITMISCOP0 0xee0
  41. #define TMC_ITTRFLIN 0xee8
  42. #define TMC_ITATBDATA0 0xeec
  43. #define TMC_ITATBCTR2 0xef0
  44. #define TMC_ITATBCTR1 0xef4
  45. #define TMC_ITATBCTR0 0xef8
  46. /* register description */
  47. /* TMC_CTL - 0x020 */
  48. #define TMC_CTL_CAPT_EN BIT(0)
  49. /* TMC_STS - 0x00C */
  50. #define TMC_STS_TMCREADY_BIT 2
  51. #define TMC_STS_FULL BIT(0)
  52. #define TMC_STS_TRIGGERED BIT(1)
  53. /* TMC_AXICTL - 0x110 */
  54. #define TMC_AXICTL_PROT_CTL_B0 BIT(0)
  55. #define TMC_AXICTL_PROT_CTL_B1 BIT(1)
  56. #define TMC_AXICTL_SCT_GAT_MODE BIT(7)
  57. #define TMC_AXICTL_WR_BURST_16 0xF00
  58. /* TMC_FFCR - 0x304 */
  59. #define TMC_FFCR_FLUSHMAN_BIT 6
  60. #define TMC_FFCR_EN_FMT BIT(0)
  61. #define TMC_FFCR_EN_TI BIT(1)
  62. #define TMC_FFCR_FON_FLIN BIT(4)
  63. #define TMC_FFCR_FON_TRIG_EVT BIT(5)
  64. #define TMC_FFCR_TRIGON_TRIGIN BIT(8)
  65. #define TMC_FFCR_STOP_ON_FLUSH BIT(12)
  66. enum tmc_config_type {
  67. TMC_CONFIG_TYPE_ETB,
  68. TMC_CONFIG_TYPE_ETR,
  69. TMC_CONFIG_TYPE_ETF,
  70. };
  71. enum tmc_mode {
  72. TMC_MODE_CIRCULAR_BUFFER,
  73. TMC_MODE_SOFTWARE_FIFO,
  74. TMC_MODE_HARDWARE_FIFO,
  75. };
  76. enum tmc_mem_intf_width {
  77. TMC_MEM_INTF_WIDTH_32BITS = 1,
  78. TMC_MEM_INTF_WIDTH_64BITS = 2,
  79. TMC_MEM_INTF_WIDTH_128BITS = 4,
  80. TMC_MEM_INTF_WIDTH_256BITS = 8,
  81. };
  82. /**
  83. * struct tmc_drvdata - specifics associated to an TMC component
  84. * @base: memory mapped base address for this component.
  85. * @dev: the device entity associated to this component.
  86. * @csdev: component vitals needed by the framework.
  87. * @miscdev: specifics to handle "/dev/xyz.tmc" entry.
  88. * @spinlock: only one at a time pls.
  89. * @buf: area of memory where trace data get sent.
  90. * @paddr: DMA start location in RAM.
  91. * @vaddr: virtual representation of @paddr.
  92. * @size: trace buffer size.
  93. * @len: size of the available trace.
  94. * @mode: how this TMC is being used.
  95. * @config_type: TMC variant, must be of type @tmc_config_type.
  96. * @memwidth: width of the memory interface databus, in bytes.
  97. * @trigger_cntr: amount of words to store after a trigger.
  98. */
  99. struct tmc_drvdata {
  100. void __iomem *base;
  101. struct device *dev;
  102. struct coresight_device *csdev;
  103. struct miscdevice miscdev;
  104. spinlock_t spinlock;
  105. bool reading;
  106. char *buf;
  107. dma_addr_t paddr;
  108. void __iomem *vaddr;
  109. u32 size;
  110. u32 len;
  111. local_t mode;
  112. enum tmc_config_type config_type;
  113. enum tmc_mem_intf_width memwidth;
  114. u32 trigger_cntr;
  115. };
  116. /* Generic functions */
  117. void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata);
  118. void tmc_flush_and_stop(struct tmc_drvdata *drvdata);
  119. void tmc_enable_hw(struct tmc_drvdata *drvdata);
  120. void tmc_disable_hw(struct tmc_drvdata *drvdata);
  121. /* ETB/ETF functions */
  122. int tmc_read_prepare_etb(struct tmc_drvdata *drvdata);
  123. int tmc_read_unprepare_etb(struct tmc_drvdata *drvdata);
  124. extern const struct coresight_ops tmc_etb_cs_ops;
  125. extern const struct coresight_ops tmc_etf_cs_ops;
  126. /* ETR functions */
  127. int tmc_read_prepare_etr(struct tmc_drvdata *drvdata);
  128. int tmc_read_unprepare_etr(struct tmc_drvdata *drvdata);
  129. extern const struct coresight_ops tmc_etr_cs_ops;
  130. #endif