This source file includes following definitions.
- coresight_register
- coresight_unregister
- coresight_enable
- coresight_disable
- coresight_timeout
- coresight_claim_device_unlocked
- coresight_claim_device
- coresight_disclaim_device
- coresight_disclaim_device_unlocked
1
2
3
4
5
6 #ifndef _LINUX_CORESIGHT_H
7 #define _LINUX_CORESIGHT_H
8
9 #include <linux/device.h>
10 #include <linux/perf_event.h>
11 #include <linux/sched.h>
12
13
14 #define CORESIGHT_PERIPHIDR4 0xfd0
15 #define CORESIGHT_PERIPHIDR5 0xfd4
16 #define CORESIGHT_PERIPHIDR6 0xfd8
17 #define CORESIGHT_PERIPHIDR7 0xfdC
18 #define CORESIGHT_PERIPHIDR0 0xfe0
19 #define CORESIGHT_PERIPHIDR1 0xfe4
20 #define CORESIGHT_PERIPHIDR2 0xfe8
21 #define CORESIGHT_PERIPHIDR3 0xfeC
22
23 #define CORESIGHT_COMPIDR0 0xff0
24 #define CORESIGHT_COMPIDR1 0xff4
25 #define CORESIGHT_COMPIDR2 0xff8
26 #define CORESIGHT_COMPIDR3 0xffC
27
28 #define ETM_ARCH_V3_3 0x23
29 #define ETM_ARCH_V3_5 0x25
30 #define PFT_ARCH_V1_0 0x30
31 #define PFT_ARCH_V1_1 0x31
32
33 #define CORESIGHT_UNLOCK 0xc5acce55
34
35 extern struct bus_type coresight_bustype;
36
37 enum coresight_dev_type {
38 CORESIGHT_DEV_TYPE_NONE,
39 CORESIGHT_DEV_TYPE_SINK,
40 CORESIGHT_DEV_TYPE_LINK,
41 CORESIGHT_DEV_TYPE_LINKSINK,
42 CORESIGHT_DEV_TYPE_SOURCE,
43 CORESIGHT_DEV_TYPE_HELPER,
44 };
45
46 enum coresight_dev_subtype_sink {
47 CORESIGHT_DEV_SUBTYPE_SINK_NONE,
48 CORESIGHT_DEV_SUBTYPE_SINK_PORT,
49 CORESIGHT_DEV_SUBTYPE_SINK_BUFFER,
50 };
51
52 enum coresight_dev_subtype_link {
53 CORESIGHT_DEV_SUBTYPE_LINK_NONE,
54 CORESIGHT_DEV_SUBTYPE_LINK_MERG,
55 CORESIGHT_DEV_SUBTYPE_LINK_SPLIT,
56 CORESIGHT_DEV_SUBTYPE_LINK_FIFO,
57 };
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
66 enum coresight_dev_subtype_helper {
67 CORESIGHT_DEV_SUBTYPE_HELPER_NONE,
68 CORESIGHT_DEV_SUBTYPE_HELPER_CATU,
69 };
70
71
72
73
74
75
76
77
78
79
80
81
82 union coresight_dev_subtype {
83
84 struct {
85 enum coresight_dev_subtype_sink sink_subtype;
86 enum coresight_dev_subtype_link link_subtype;
87 };
88 enum coresight_dev_subtype_source source_subtype;
89 enum coresight_dev_subtype_helper helper_subtype;
90 };
91
92
93
94
95
96
97
98 struct coresight_platform_data {
99 int nr_inport;
100 int nr_outport;
101 struct coresight_connection *conns;
102 };
103
104
105
106
107
108
109
110
111
112
113
114
115
116 struct coresight_desc {
117 enum coresight_dev_type type;
118 union coresight_dev_subtype subtype;
119 const struct coresight_ops *ops;
120 struct coresight_platform_data *pdata;
121 struct device *dev;
122 const struct attribute_group **groups;
123 const char *name;
124 };
125
126
127
128
129
130
131
132
133
134 struct coresight_connection {
135 int outport;
136 int child_port;
137 struct fwnode_handle *child_fwnode;
138 struct coresight_device *child_dev;
139 };
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 struct coresight_device {
158 struct coresight_platform_data *pdata;
159 enum coresight_dev_type type;
160 union coresight_dev_subtype subtype;
161 const struct coresight_ops *ops;
162 struct device dev;
163 atomic_t *refcnt;
164 bool orphan;
165 bool enable;
166
167 bool activated;
168 struct dev_ext_attribute *ea;
169 };
170
171
172
173
174
175
176
177
178
179
180 struct coresight_dev_list {
181 int nr_idx;
182 const char *pfx;
183 struct fwnode_handle **fwnode_list;
184 };
185
186 #define DEFINE_CORESIGHT_DEVLIST(var, dev_pfx) \
187 static struct coresight_dev_list (var) = { \
188 .pfx = dev_pfx, \
189 .nr_idx = 0, \
190 .fwnode_list = NULL, \
191 }
192
193 #define to_coresight_device(d) container_of(d, struct coresight_device, dev)
194
195 #define source_ops(csdev) csdev->ops->source_ops
196 #define sink_ops(csdev) csdev->ops->sink_ops
197 #define link_ops(csdev) csdev->ops->link_ops
198 #define helper_ops(csdev) csdev->ops->helper_ops
199
200
201
202
203
204
205
206
207
208
209 struct coresight_ops_sink {
210 int (*enable)(struct coresight_device *csdev, u32 mode, void *data);
211 int (*disable)(struct coresight_device *csdev);
212 void *(*alloc_buffer)(struct coresight_device *csdev,
213 struct perf_event *event, void **pages,
214 int nr_pages, bool overwrite);
215 void (*free_buffer)(void *config);
216 unsigned long (*update_buffer)(struct coresight_device *csdev,
217 struct perf_output_handle *handle,
218 void *sink_config);
219 };
220
221
222
223
224
225
226
227 struct coresight_ops_link {
228 int (*enable)(struct coresight_device *csdev, int iport, int oport);
229 void (*disable)(struct coresight_device *csdev, int iport, int oport);
230 };
231
232
233
234
235
236
237
238
239
240
241
242 struct coresight_ops_source {
243 int (*cpu_id)(struct coresight_device *csdev);
244 int (*trace_id)(struct coresight_device *csdev);
245 int (*enable)(struct coresight_device *csdev,
246 struct perf_event *event, u32 mode);
247 void (*disable)(struct coresight_device *csdev,
248 struct perf_event *event);
249 };
250
251
252
253
254
255
256
257
258
259
260 struct coresight_ops_helper {
261 int (*enable)(struct coresight_device *csdev, void *data);
262 int (*disable)(struct coresight_device *csdev, void *data);
263 };
264
265 struct coresight_ops {
266 const struct coresight_ops_sink *sink_ops;
267 const struct coresight_ops_link *link_ops;
268 const struct coresight_ops_source *source_ops;
269 const struct coresight_ops_helper *helper_ops;
270 };
271
272 #ifdef CONFIG_CORESIGHT
273 extern struct coresight_device *
274 coresight_register(struct coresight_desc *desc);
275 extern void coresight_unregister(struct coresight_device *csdev);
276 extern int coresight_enable(struct coresight_device *csdev);
277 extern void coresight_disable(struct coresight_device *csdev);
278 extern int coresight_timeout(void __iomem *addr, u32 offset,
279 int position, int value);
280
281 extern int coresight_claim_device(void __iomem *base);
282 extern int coresight_claim_device_unlocked(void __iomem *base);
283
284 extern void coresight_disclaim_device(void __iomem *base);
285 extern void coresight_disclaim_device_unlocked(void __iomem *base);
286 extern char *coresight_alloc_device_name(struct coresight_dev_list *devs,
287 struct device *dev);
288 #else
289 static inline struct coresight_device *
290 coresight_register(struct coresight_desc *desc) { return NULL; }
291 static inline void coresight_unregister(struct coresight_device *csdev) {}
292 static inline int
293 coresight_enable(struct coresight_device *csdev) { return -ENOSYS; }
294 static inline void coresight_disable(struct coresight_device *csdev) {}
295 static inline int coresight_timeout(void __iomem *addr, u32 offset,
296 int position, int value) { return 1; }
297 static inline int coresight_claim_device_unlocked(void __iomem *base)
298 {
299 return -EINVAL;
300 }
301
302 static inline int coresight_claim_device(void __iomem *base)
303 {
304 return -EINVAL;
305 }
306
307 static inline void coresight_disclaim_device(void __iomem *base) {}
308 static inline void coresight_disclaim_device_unlocked(void __iomem *base) {}
309
310 #endif
311
312 extern int coresight_get_cpu(struct device *dev);
313
314 struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
315
316 #endif