coresight.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _LINUX_CORESIGHT_H
  13. #define _LINUX_CORESIGHT_H
  14. #include <linux/device.h>
  15. /* Peripheral id registers (0xFD0-0xFEC) */
  16. #define CORESIGHT_PERIPHIDR4 (0xFD0)
  17. #define CORESIGHT_PERIPHIDR5 (0xFD4)
  18. #define CORESIGHT_PERIPHIDR6 (0xFD8)
  19. #define CORESIGHT_PERIPHIDR7 (0xFDC)
  20. #define CORESIGHT_PERIPHIDR0 (0xFE0)
  21. #define CORESIGHT_PERIPHIDR1 (0xFE4)
  22. #define CORESIGHT_PERIPHIDR2 (0xFE8)
  23. #define CORESIGHT_PERIPHIDR3 (0xFEC)
  24. /* Component id registers (0xFF0-0xFFC) */
  25. #define CORESIGHT_COMPIDR0 (0xFF0)
  26. #define CORESIGHT_COMPIDR1 (0xFF4)
  27. #define CORESIGHT_COMPIDR2 (0xFF8)
  28. #define CORESIGHT_COMPIDR3 (0xFFC)
  29. #define ETM_ARCH_V1_0 (0x00)
  30. #define ETM_ARCH_V1_2 (0x02)
  31. #define ETM_ARCH_V3_3 (0x23)
  32. #define ETM_ARCH_V3_5 (0x25)
  33. #define PFT_ARCH_MAJOR (0x30)
  34. #define PFT_ARCH_V1_1 (0x31)
  35. enum coresight_clk_rate {
  36. CORESIGHT_CLK_RATE_OFF,
  37. CORESIGHT_CLK_RATE_TRACE = 1000,
  38. CORESIGHT_CLK_RATE_HSTRACE = 2000,
  39. CORESIGHT_CLK_RATE_FIXED = 3000,
  40. };
  41. enum coresight_dev_type {
  42. CORESIGHT_DEV_TYPE_NONE,
  43. CORESIGHT_DEV_TYPE_SINK,
  44. CORESIGHT_DEV_TYPE_LINK,
  45. CORESIGHT_DEV_TYPE_LINKSINK,
  46. CORESIGHT_DEV_TYPE_SOURCE,
  47. };
  48. enum coresight_dev_subtype_sink {
  49. CORESIGHT_DEV_SUBTYPE_SINK_NONE,
  50. CORESIGHT_DEV_SUBTYPE_SINK_PORT,
  51. CORESIGHT_DEV_SUBTYPE_SINK_BUFFER,
  52. };
  53. enum coresight_dev_subtype_link {
  54. CORESIGHT_DEV_SUBTYPE_LINK_NONE,
  55. CORESIGHT_DEV_SUBTYPE_LINK_MERG,
  56. CORESIGHT_DEV_SUBTYPE_LINK_SPLIT,
  57. CORESIGHT_DEV_SUBTYPE_LINK_FIFO,
  58. };
  59. enum coresight_dev_subtype_source {
  60. CORESIGHT_DEV_SUBTYPE_SOURCE_NONE,
  61. CORESIGHT_DEV_SUBTYPE_SOURCE_PROC,
  62. CORESIGHT_DEV_SUBTYPE_SOURCE_BUS,
  63. CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE,
  64. };
  65. struct coresight_dev_subtype {
  66. enum coresight_dev_subtype_sink sink_subtype;
  67. enum coresight_dev_subtype_link link_subtype;
  68. enum coresight_dev_subtype_source source_subtype;
  69. };
  70. struct coresight_platform_data {
  71. int id;
  72. const char *name;
  73. int nr_inports;
  74. const int *outports;
  75. const int *child_ids;
  76. const int *child_ports;
  77. int nr_outports;
  78. bool default_sink;
  79. };
  80. struct coresight_desc {
  81. enum coresight_dev_type type;
  82. struct coresight_dev_subtype subtype;
  83. const struct coresight_ops *ops;
  84. struct coresight_platform_data *pdata;
  85. struct device *dev;
  86. const struct attribute_group **groups;
  87. struct module *owner;
  88. };
  89. struct coresight_connection {
  90. int outport;
  91. int child_id;
  92. int child_port;
  93. struct coresight_device *child_dev;
  94. struct list_head link;
  95. };
  96. struct coresight_refcnt {
  97. int sink_refcnt;
  98. int *link_refcnts;
  99. int source_refcnt;
  100. };
  101. struct coresight_device {
  102. int id;
  103. struct coresight_connection *conns;
  104. int nr_conns;
  105. enum coresight_dev_type type;
  106. struct coresight_dev_subtype subtype;
  107. const struct coresight_ops *ops;
  108. struct device dev;
  109. struct coresight_refcnt refcnt;
  110. struct list_head dev_link;
  111. struct list_head path_link;
  112. struct module *owner;
  113. bool enable;
  114. };
  115. #define to_coresight_device(d) container_of(d, struct coresight_device, dev)
  116. struct coresight_ops_sink {
  117. int (*enable)(struct coresight_device *csdev);
  118. void (*disable)(struct coresight_device *csdev);
  119. void (*abort)(struct coresight_device *csdev);
  120. };
  121. struct coresight_ops_link {
  122. int (*enable)(struct coresight_device *csdev, int iport, int oport);
  123. void (*disable)(struct coresight_device *csdev, int iport, int oport);
  124. };
  125. struct coresight_ops_source {
  126. int (*enable)(struct coresight_device *csdev);
  127. void (*disable)(struct coresight_device *csdev);
  128. };
  129. struct coresight_ops {
  130. const struct coresight_ops_sink *sink_ops;
  131. const struct coresight_ops_link *link_ops;
  132. const struct coresight_ops_source *source_ops;
  133. };
  134. #ifdef CONFIG_CORESIGHT
  135. extern struct coresight_device *
  136. coresight_register(struct coresight_desc *desc);
  137. extern void coresight_unregister(struct coresight_device *csdev);
  138. extern int coresight_enable(struct coresight_device *csdev);
  139. extern void coresight_disable(struct coresight_device *csdev);
  140. extern void coresight_abort(void);
  141. #else
  142. static inline struct coresight_device *
  143. coresight_register(struct coresight_desc *desc) { return NULL; }
  144. static inline void coresight_unregister(struct coresight_device *csdev) {}
  145. static inline int
  146. coresight_enable(struct coresight_device *csdev) { return -ENOSYS; }
  147. static inline void coresight_disable(struct coresight_device *csdev) {}
  148. static inline void coresight_abort(void) {}
  149. #endif
  150. #endif