Commit | Line | Data |
---|---|---|
ad0dfdfd MP |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* | |
3 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. | |
a06ae860 PP |
4 | */ |
5 | ||
6 | #ifndef _LINUX_CORESIGHT_H | |
7 | #define _LINUX_CORESIGHT_H | |
8 | ||
9 | #include <linux/device.h> | |
6e736c60 | 10 | #include <linux/io.h> |
882d5e11 | 11 | #include <linux/perf_event.h> |
ff63ec13 | 12 | #include <linux/sched.h> |
a06ae860 PP |
13 | |
14 | /* Peripheral id registers (0xFD0-0xFEC) */ | |
15 | #define CORESIGHT_PERIPHIDR4 0xfd0 | |
16 | #define CORESIGHT_PERIPHIDR5 0xfd4 | |
17 | #define CORESIGHT_PERIPHIDR6 0xfd8 | |
18 | #define CORESIGHT_PERIPHIDR7 0xfdC | |
19 | #define CORESIGHT_PERIPHIDR0 0xfe0 | |
20 | #define CORESIGHT_PERIPHIDR1 0xfe4 | |
21 | #define CORESIGHT_PERIPHIDR2 0xfe8 | |
22 | #define CORESIGHT_PERIPHIDR3 0xfeC | |
23 | /* Component id registers (0xFF0-0xFFC) */ | |
24 | #define CORESIGHT_COMPIDR0 0xff0 | |
25 | #define CORESIGHT_COMPIDR1 0xff4 | |
26 | #define CORESIGHT_COMPIDR2 0xff8 | |
27 | #define CORESIGHT_COMPIDR3 0xffC | |
28 | ||
29 | #define ETM_ARCH_V3_3 0x23 | |
30 | #define ETM_ARCH_V3_5 0x25 | |
31 | #define PFT_ARCH_V1_0 0x30 | |
32 | #define PFT_ARCH_V1_1 0x31 | |
33 | ||
34 | #define CORESIGHT_UNLOCK 0xc5acce55 | |
35 | ||
36 | extern struct bus_type coresight_bustype; | |
37 | ||
38 | enum coresight_dev_type { | |
a06ae860 PP |
39 | CORESIGHT_DEV_TYPE_SINK, |
40 | CORESIGHT_DEV_TYPE_LINK, | |
41 | CORESIGHT_DEV_TYPE_LINKSINK, | |
42 | CORESIGHT_DEV_TYPE_SOURCE, | |
8a091d84 | 43 | CORESIGHT_DEV_TYPE_HELPER, |
835d722b | 44 | CORESIGHT_DEV_TYPE_ECT, |
a06ae860 PP |
45 | }; |
46 | ||
47 | enum coresight_dev_subtype_sink { | |
a06ae860 PP |
48 | CORESIGHT_DEV_SUBTYPE_SINK_PORT, |
49 | CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, | |
0336bdfd | 50 | CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, |
2cd87a7b | 51 | CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM, |
a06ae860 PP |
52 | }; |
53 | ||
54 | enum coresight_dev_subtype_link { | |
a06ae860 PP |
55 | CORESIGHT_DEV_SUBTYPE_LINK_MERG, |
56 | CORESIGHT_DEV_SUBTYPE_LINK_SPLIT, | |
57 | CORESIGHT_DEV_SUBTYPE_LINK_FIFO, | |
58 | }; | |
59 | ||
60 | enum coresight_dev_subtype_source { | |
a06ae860 PP |
61 | CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, |
62 | CORESIGHT_DEV_SUBTYPE_SOURCE_BUS, | |
63 | CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, | |
b3c71626 | 64 | CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS, |
a06ae860 PP |
65 | }; |
66 | ||
8a091d84 | 67 | enum coresight_dev_subtype_helper { |
fcacb5c1 | 68 | CORESIGHT_DEV_SUBTYPE_HELPER_CATU, |
8a091d84 SP |
69 | }; |
70 | ||
835d722b ML |
71 | /* Embedded Cross Trigger (ECT) sub-types */ |
72 | enum coresight_dev_subtype_ect { | |
73 | CORESIGHT_DEV_SUBTYPE_ECT_NONE, | |
74 | CORESIGHT_DEV_SUBTYPE_ECT_CTI, | |
75 | }; | |
76 | ||
a06ae860 | 77 | /** |
00b78e8b | 78 | * union coresight_dev_subtype - further characterisation of a type |
a06ae860 | 79 | * @sink_subtype: type of sink this component is, as defined |
00b78e8b | 80 | * by @coresight_dev_subtype_sink. |
a06ae860 | 81 | * @link_subtype: type of link this component is, as defined |
00b78e8b | 82 | * by @coresight_dev_subtype_link. |
a06ae860 | 83 | * @source_subtype: type of source this component is, as defined |
00b78e8b | 84 | * by @coresight_dev_subtype_source. |
8a091d84 SP |
85 | * @helper_subtype: type of helper this component is, as defined |
86 | * by @coresight_dev_subtype_helper. | |
835d722b ML |
87 | * @ect_subtype: type of cross trigger this component is, as |
88 | * defined by @coresight_dev_subtype_ect | |
a06ae860 | 89 | */ |
00b78e8b SP |
90 | union coresight_dev_subtype { |
91 | /* We have some devices which acts as LINK and SINK */ | |
92 | struct { | |
93 | enum coresight_dev_subtype_sink sink_subtype; | |
94 | enum coresight_dev_subtype_link link_subtype; | |
95 | }; | |
a06ae860 | 96 | enum coresight_dev_subtype_source source_subtype; |
8a091d84 | 97 | enum coresight_dev_subtype_helper helper_subtype; |
835d722b | 98 | enum coresight_dev_subtype_ect ect_subtype; |
a06ae860 PP |
99 | }; |
100 | ||
101 | /** | |
d375b356 SP |
102 | * struct coresight_platform_data - data harvested from the firmware |
103 | * specification. | |
104 | * | |
105 | * @nr_inport: Number of elements for the input connections. | |
106 | * @nr_outport: Number of elements for the output connections. | |
107 | * @conns: Sparse array of nr_outport connections from this component. | |
a06ae860 PP |
108 | */ |
109 | struct coresight_platform_data { | |
a06ae860 | 110 | int nr_inport; |
a06ae860 | 111 | int nr_outport; |
c2c72941 | 112 | struct coresight_connection *conns; |
a06ae860 PP |
113 | }; |
114 | ||
6e736c60 SP |
115 | /** |
116 | * struct csdev_access - Abstraction of a CoreSight device access. | |
117 | * | |
118 | * @io_mem : True if the device has memory mapped I/O | |
119 | * @base : When io_mem == true, base address of the component | |
120 | * @read : Read from the given "offset" of the given instance. | |
121 | * @write : Write "val" to the given "offset". | |
122 | */ | |
123 | struct csdev_access { | |
124 | bool io_mem; | |
125 | union { | |
126 | void __iomem *base; | |
127 | struct { | |
128 | u64 (*read)(u32 offset, bool relaxed, bool _64bit); | |
129 | void (*write)(u64 val, u32 offset, bool relaxed, | |
130 | bool _64bit); | |
131 | }; | |
132 | }; | |
133 | }; | |
134 | ||
135 | #define CSDEV_ACCESS_IOMEM(_addr) \ | |
136 | ((struct csdev_access) { \ | |
137 | .io_mem = true, \ | |
138 | .base = (_addr), \ | |
139 | }) | |
140 | ||
a06ae860 PP |
141 | /** |
142 | * struct coresight_desc - description of a component required from drivers | |
143 | * @type: as defined by @coresight_dev_type. | |
144 | * @subtype: as defined by @coresight_dev_subtype. | |
145 | * @ops: generic operations for this component, as defined | |
2ede79a6 | 146 | * by @coresight_ops. |
a06ae860 PP |
147 | * @pdata: platform data collected from DT. |
148 | * @dev: The device entity associated to this component. | |
8ee885a9 | 149 | * @groups: operations specific to this component. These will end up |
2ede79a6 SP |
150 | * in the component's sysfs sub-directory. |
151 | * @name: name for the coresight device, also shown under sysfs. | |
6e736c60 | 152 | * @access: Describe access to the device |
a06ae860 PP |
153 | */ |
154 | struct coresight_desc { | |
155 | enum coresight_dev_type type; | |
00b78e8b | 156 | union coresight_dev_subtype subtype; |
a06ae860 PP |
157 | const struct coresight_ops *ops; |
158 | struct coresight_platform_data *pdata; | |
159 | struct device *dev; | |
160 | const struct attribute_group **groups; | |
2ede79a6 | 161 | const char *name; |
6e736c60 | 162 | struct csdev_access access; |
a06ae860 PP |
163 | }; |
164 | ||
165 | /** | |
166 | * struct coresight_connection - representation of a single connection | |
a06ae860 | 167 | * @outport: a connection's output port number. |
a06ae860 | 168 | * @child_port: remote component's port number @output is connected to. |
37ea1ffd | 169 | * @chid_fwnode: remote component's fwnode handle. |
a06ae860 PP |
170 | * @child_dev: a @coresight_device representation of the component |
171 | connected to @outport. | |
8a7365c2 | 172 | * @link: Representation of the connection as a sysfs link. |
a06ae860 PP |
173 | */ |
174 | struct coresight_connection { | |
175 | int outport; | |
a06ae860 | 176 | int child_port; |
37ea1ffd | 177 | struct fwnode_handle *child_fwnode; |
a06ae860 | 178 | struct coresight_device *child_dev; |
8a7365c2 | 179 | struct coresight_sysfs_link *link; |
a06ae860 PP |
180 | }; |
181 | ||
80961525 ML |
182 | /** |
183 | * struct coresight_sysfs_link - representation of a connection in sysfs. | |
184 | * @orig: Originating (master) coresight device for the link. | |
185 | * @orig_name: Name to use for the link orig->target. | |
186 | * @target: Target (slave) coresight device for the link. | |
187 | * @target_name: Name to use for the link target->orig. | |
188 | */ | |
189 | struct coresight_sysfs_link { | |
190 | struct coresight_device *orig; | |
191 | const char *orig_name; | |
192 | struct coresight_device *target; | |
193 | const char *target_name; | |
194 | }; | |
195 | ||
a06ae860 PP |
196 | /** |
197 | * struct coresight_device - representation of a device as used by the framework | |
b77e3ed0 | 198 | * @pdata: Platform data with device connections associated to this device. |
a06ae860 PP |
199 | * @type: as defined by @coresight_dev_type. |
200 | * @subtype: as defined by @coresight_dev_subtype. | |
201 | * @ops: generic operations for this component, as defined | |
6e736c60 SP |
202 | * by @coresight_ops. |
203 | * @access: Device i/o access abstraction for this device. | |
a06ae860 PP |
204 | * @dev: The device entity associated to this component. |
205 | * @refcnt: keep track of what is in use. | |
a06ae860 PP |
206 | * @orphan: true if the component has connections that haven't been linked. |
207 | * @enable: 'true' if component is currently part of an active path. | |
208 | * @activated: 'true' only if a _sink_ has been activated. A sink can be | |
bb8e370b | 209 | * activated but not yet enabled. Enabling for a _sink_ |
d061cd73 ML |
210 | * happens when a source has been selected and a path is enabled |
211 | * from source to that sink. | |
bb8e370b | 212 | * @ea: Device attribute for sink representation under PMU directory. |
0336bdfd | 213 | * @def_sink: cached reference to default sink found for this device. |
177af828 ML |
214 | * @ect_dev: Associated cross trigger device. Not part of the trace data |
215 | * path or connections. | |
80961525 ML |
216 | * @nr_links: number of sysfs links created to other components from this |
217 | * device. These will appear in the "connections" group. | |
218 | * @has_conns_grp: Have added a "connections" group for sysfs links. | |
42ff700f ML |
219 | * @feature_csdev_list: List of complex feature programming added to the device. |
220 | * @config_csdev_list: List of system configurations added to the device. | |
221 | * @cscfg_csdev_lock: Protect the lists of configurations and features. | |
f8cce2ff | 222 | * @active_cscfg_ctxt: Context information for current active system configuration. |
a06ae860 PP |
223 | */ |
224 | struct coresight_device { | |
b77e3ed0 | 225 | struct coresight_platform_data *pdata; |
a06ae860 | 226 | enum coresight_dev_type type; |
00b78e8b | 227 | union coresight_dev_subtype subtype; |
a06ae860 | 228 | const struct coresight_ops *ops; |
6e736c60 | 229 | struct csdev_access access; |
a06ae860 PP |
230 | struct device dev; |
231 | atomic_t *refcnt; | |
a06ae860 PP |
232 | bool orphan; |
233 | bool enable; /* true only if configured as part of a path */ | |
bb8e370b | 234 | /* sink specific fields */ |
a06ae860 | 235 | bool activated; /* true only if a sink is part of a path */ |
bb8e370b | 236 | struct dev_ext_attribute *ea; |
0336bdfd | 237 | struct coresight_device *def_sink; |
177af828 ML |
238 | /* cross trigger handling */ |
239 | struct coresight_device *ect_dev; | |
80961525 ML |
240 | /* sysfs links between components */ |
241 | int nr_links; | |
242 | bool has_conns_grp; | |
f2ccc7b7 | 243 | bool ect_enabled; /* true only if associated ect device is enabled */ |
42ff700f ML |
244 | /* system configuration and feature lists */ |
245 | struct list_head feature_csdev_list; | |
246 | struct list_head config_csdev_list; | |
247 | spinlock_t cscfg_csdev_lock; | |
f8cce2ff | 248 | void *active_cscfg_ctxt; |
a06ae860 PP |
249 | }; |
250 | ||
0f5f9b6b SP |
251 | /* |
252 | * coresight_dev_list - Mapping for devices to "name" index for device | |
253 | * names. | |
254 | * | |
255 | * @nr_idx: Number of entries already allocated. | |
256 | * @pfx: Prefix pattern for device name. | |
257 | * @fwnode_list: Array of fwnode_handles associated with each allocated | |
258 | * index, upto nr_idx entries. | |
259 | */ | |
260 | struct coresight_dev_list { | |
261 | int nr_idx; | |
262 | const char *pfx; | |
263 | struct fwnode_handle **fwnode_list; | |
264 | }; | |
265 | ||
266 | #define DEFINE_CORESIGHT_DEVLIST(var, dev_pfx) \ | |
267 | static struct coresight_dev_list (var) = { \ | |
268 | .pfx = dev_pfx, \ | |
269 | .nr_idx = 0, \ | |
270 | .fwnode_list = NULL, \ | |
271 | } | |
272 | ||
a06ae860 PP |
273 | #define to_coresight_device(d) container_of(d, struct coresight_device, dev) |
274 | ||
275 | #define source_ops(csdev) csdev->ops->source_ops | |
276 | #define sink_ops(csdev) csdev->ops->sink_ops | |
277 | #define link_ops(csdev) csdev->ops->link_ops | |
8a091d84 | 278 | #define helper_ops(csdev) csdev->ops->helper_ops |
835d722b | 279 | #define ect_ops(csdev) csdev->ops->ect_ops |
a06ae860 | 280 | |
a06ae860 PP |
281 | /** |
282 | * struct coresight_ops_sink - basic operations for a sink | |
283 | * Operations available for sinks | |
2997aa40 MP |
284 | * @enable: enables the sink. |
285 | * @disable: disables the sink. | |
286 | * @alloc_buffer: initialises perf's ring buffer for trace collection. | |
287 | * @free_buffer: release memory allocated in @get_config. | |
2997aa40 | 288 | * @update_buffer: update buffer pointers after a trace session. |
a06ae860 PP |
289 | */ |
290 | struct coresight_ops_sink { | |
3d6e8935 | 291 | int (*enable)(struct coresight_device *csdev, u32 mode, void *data); |
6c817a95 | 292 | int (*disable)(struct coresight_device *csdev); |
a0f08a6a MP |
293 | void *(*alloc_buffer)(struct coresight_device *csdev, |
294 | struct perf_event *event, void **pages, | |
295 | int nr_pages, bool overwrite); | |
2997aa40 | 296 | void (*free_buffer)(void *config); |
7ec786ad | 297 | unsigned long (*update_buffer)(struct coresight_device *csdev, |
2997aa40 MP |
298 | struct perf_output_handle *handle, |
299 | void *sink_config); | |
a06ae860 PP |
300 | }; |
301 | ||
302 | /** | |
303 | * struct coresight_ops_link - basic operations for a link | |
304 | * Operations available for links. | |
305 | * @enable: enables flow between iport and oport. | |
306 | * @disable: disables flow between iport and oport. | |
307 | */ | |
308 | struct coresight_ops_link { | |
309 | int (*enable)(struct coresight_device *csdev, int iport, int oport); | |
310 | void (*disable)(struct coresight_device *csdev, int iport, int oport); | |
311 | }; | |
312 | ||
313 | /** | |
314 | * struct coresight_ops_source - basic operations for a source | |
315 | * Operations available for sources. | |
52210c87 MP |
316 | * @cpu_id: returns the value of the CPU number this component |
317 | * is associated to. | |
1d27ff5a | 318 | * @enable: enables tracing for a source. |
a06ae860 PP |
319 | * @disable: disables tracing for a source. |
320 | */ | |
321 | struct coresight_ops_source { | |
52210c87 | 322 | int (*cpu_id)(struct coresight_device *csdev); |
882d5e11 | 323 | int (*enable)(struct coresight_device *csdev, |
68905d73 MP |
324 | struct perf_event *event, u32 mode); |
325 | void (*disable)(struct coresight_device *csdev, | |
326 | struct perf_event *event); | |
a06ae860 PP |
327 | }; |
328 | ||
8a091d84 SP |
329 | /** |
330 | * struct coresight_ops_helper - Operations for a helper device. | |
331 | * | |
332 | * All operations could pass in a device specific data, which could | |
333 | * help the helper device to determine what to do. | |
334 | * | |
335 | * @enable : Enable the device | |
336 | * @disable : Disable the device | |
337 | */ | |
338 | struct coresight_ops_helper { | |
339 | int (*enable)(struct coresight_device *csdev, void *data); | |
340 | int (*disable)(struct coresight_device *csdev, void *data); | |
341 | }; | |
342 | ||
835d722b ML |
343 | /** |
344 | * struct coresight_ops_ect - Ops for an embedded cross trigger device | |
345 | * | |
346 | * @enable : Enable the device | |
347 | * @disable : Disable the device | |
348 | */ | |
349 | struct coresight_ops_ect { | |
350 | int (*enable)(struct coresight_device *csdev); | |
351 | int (*disable)(struct coresight_device *csdev); | |
352 | }; | |
353 | ||
a06ae860 PP |
354 | struct coresight_ops { |
355 | const struct coresight_ops_sink *sink_ops; | |
356 | const struct coresight_ops_link *link_ops; | |
357 | const struct coresight_ops_source *source_ops; | |
8a091d84 | 358 | const struct coresight_ops_helper *helper_ops; |
835d722b | 359 | const struct coresight_ops_ect *ect_ops; |
a06ae860 PP |
360 | }; |
361 | ||
b8127113 | 362 | #if IS_ENABLED(CONFIG_CORESIGHT) |
6e736c60 SP |
363 | |
364 | static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa, | |
365 | u32 offset) | |
366 | { | |
367 | if (likely(csa->io_mem)) | |
368 | return readl_relaxed(csa->base + offset); | |
369 | ||
370 | return csa->read(offset, true, false); | |
371 | } | |
372 | ||
b6df1cbb | 373 | static inline u64 csdev_access_relaxed_read_pair(struct csdev_access *csa, |
0a98181f | 374 | u32 lo_offset, u32 hi_offset) |
b6df1cbb | 375 | { |
b6df1cbb | 376 | if (likely(csa->io_mem)) { |
0a98181f JC |
377 | return readl_relaxed(csa->base + lo_offset) | |
378 | ((u64)readl_relaxed(csa->base + hi_offset) << 32); | |
b6df1cbb JC |
379 | } |
380 | ||
0a98181f JC |
381 | return csa->read(lo_offset, true, false) | (csa->read(hi_offset, true, false) << 32); |
382 | } | |
383 | ||
384 | static inline void csdev_access_relaxed_write_pair(struct csdev_access *csa, u64 val, | |
385 | u32 lo_offset, u32 hi_offset) | |
386 | { | |
387 | if (likely(csa->io_mem)) { | |
388 | writel_relaxed((u32)val, csa->base + lo_offset); | |
389 | writel_relaxed((u32)(val >> 32), csa->base + hi_offset); | |
390 | } else { | |
391 | csa->write((u32)val, lo_offset, true, false); | |
392 | csa->write((u32)(val >> 32), hi_offset, true, false); | |
393 | } | |
b6df1cbb JC |
394 | } |
395 | ||
6e736c60 SP |
396 | static inline u32 csdev_access_read32(struct csdev_access *csa, u32 offset) |
397 | { | |
398 | if (likely(csa->io_mem)) | |
399 | return readl(csa->base + offset); | |
400 | ||
401 | return csa->read(offset, false, false); | |
402 | } | |
403 | ||
404 | static inline void csdev_access_relaxed_write32(struct csdev_access *csa, | |
405 | u32 val, u32 offset) | |
406 | { | |
407 | if (likely(csa->io_mem)) | |
408 | writel_relaxed(val, csa->base + offset); | |
409 | else | |
410 | csa->write(val, offset, true, false); | |
411 | } | |
412 | ||
413 | static inline void csdev_access_write32(struct csdev_access *csa, u32 val, u32 offset) | |
414 | { | |
415 | if (likely(csa->io_mem)) | |
416 | writel(val, csa->base + offset); | |
417 | else | |
418 | csa->write(val, offset, false, false); | |
419 | } | |
420 | ||
421 | #ifdef CONFIG_64BIT | |
422 | ||
423 | static inline u64 csdev_access_relaxed_read64(struct csdev_access *csa, | |
424 | u32 offset) | |
425 | { | |
426 | if (likely(csa->io_mem)) | |
427 | return readq_relaxed(csa->base + offset); | |
428 | ||
429 | return csa->read(offset, true, true); | |
430 | } | |
431 | ||
432 | static inline u64 csdev_access_read64(struct csdev_access *csa, u32 offset) | |
433 | { | |
434 | if (likely(csa->io_mem)) | |
435 | return readq(csa->base + offset); | |
436 | ||
437 | return csa->read(offset, false, true); | |
438 | } | |
439 | ||
440 | static inline void csdev_access_relaxed_write64(struct csdev_access *csa, | |
441 | u64 val, u32 offset) | |
442 | { | |
443 | if (likely(csa->io_mem)) | |
444 | writeq_relaxed(val, csa->base + offset); | |
445 | else | |
446 | csa->write(val, offset, true, true); | |
447 | } | |
448 | ||
449 | static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 offset) | |
450 | { | |
451 | if (likely(csa->io_mem)) | |
452 | writeq(val, csa->base + offset); | |
453 | else | |
454 | csa->write(val, offset, false, true); | |
455 | } | |
456 | ||
457 | #else /* !CONFIG_64BIT */ | |
458 | ||
459 | static inline u64 csdev_access_relaxed_read64(struct csdev_access *csa, | |
460 | u32 offset) | |
461 | { | |
462 | WARN_ON(1); | |
463 | return 0; | |
464 | } | |
465 | ||
466 | static inline u64 csdev_access_read64(struct csdev_access *csa, u32 offset) | |
467 | { | |
468 | WARN_ON(1); | |
469 | return 0; | |
470 | } | |
471 | ||
472 | static inline void csdev_access_relaxed_write64(struct csdev_access *csa, | |
473 | u64 val, u32 offset) | |
474 | { | |
475 | WARN_ON(1); | |
476 | } | |
477 | ||
478 | static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 offset) | |
479 | { | |
480 | WARN_ON(1); | |
481 | } | |
482 | #endif /* CONFIG_64BIT */ | |
483 | ||
2cd87a7b AK |
484 | static inline bool coresight_is_percpu_source(struct coresight_device *csdev) |
485 | { | |
486 | return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SOURCE) && | |
487 | (csdev->subtype.source_subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_PROC); | |
488 | } | |
489 | ||
490 | static inline bool coresight_is_percpu_sink(struct coresight_device *csdev) | |
491 | { | |
492 | return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SINK) && | |
493 | (csdev->subtype.sink_subtype == CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM); | |
494 | } | |
495 | ||
a06ae860 PP |
496 | extern struct coresight_device * |
497 | coresight_register(struct coresight_desc *desc); | |
498 | extern void coresight_unregister(struct coresight_device *csdev); | |
499 | extern int coresight_enable(struct coresight_device *csdev); | |
500 | extern void coresight_disable(struct coresight_device *csdev); | |
02005282 | 501 | extern int coresight_timeout(struct csdev_access *csa, u32 offset, |
a06ae860 | 502 | int position, int value); |
2478a6ae | 503 | |
8ce00296 SP |
504 | extern int coresight_claim_device(struct coresight_device *csdev); |
505 | extern int coresight_claim_device_unlocked(struct coresight_device *csdev); | |
2478a6ae | 506 | |
8ce00296 SP |
507 | extern void coresight_disclaim_device(struct coresight_device *csdev); |
508 | extern void coresight_disclaim_device_unlocked(struct coresight_device *csdev); | |
0f5f9b6b SP |
509 | extern char *coresight_alloc_device_name(struct coresight_dev_list *devs, |
510 | struct device *dev); | |
f188b5e7 AM |
511 | |
512 | extern bool coresight_loses_context_with_cpu(struct device *dev); | |
6e736c60 SP |
513 | |
514 | u32 coresight_relaxed_read32(struct coresight_device *csdev, u32 offset); | |
515 | u32 coresight_read32(struct coresight_device *csdev, u32 offset); | |
516 | void coresight_write32(struct coresight_device *csdev, u32 val, u32 offset); | |
517 | void coresight_relaxed_write32(struct coresight_device *csdev, | |
518 | u32 val, u32 offset); | |
519 | u64 coresight_relaxed_read64(struct coresight_device *csdev, u32 offset); | |
520 | u64 coresight_read64(struct coresight_device *csdev, u32 offset); | |
521 | void coresight_relaxed_write64(struct coresight_device *csdev, | |
522 | u64 val, u32 offset); | |
523 | void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset); | |
524 | ||
a06ae860 PP |
525 | #else |
526 | static inline struct coresight_device * | |
527 | coresight_register(struct coresight_desc *desc) { return NULL; } | |
528 | static inline void coresight_unregister(struct coresight_device *csdev) {} | |
529 | static inline int | |
530 | coresight_enable(struct coresight_device *csdev) { return -ENOSYS; } | |
531 | static inline void coresight_disable(struct coresight_device *csdev) {} | |
02005282 SP |
532 | |
533 | static inline int coresight_timeout(struct csdev_access *csa, u32 offset, | |
534 | int position, int value) | |
535 | { | |
536 | return 1; | |
537 | } | |
538 | ||
8ce00296 | 539 | static inline int coresight_claim_device_unlocked(struct coresight_device *csdev) |
2478a6ae SP |
540 | { |
541 | return -EINVAL; | |
542 | } | |
543 | ||
8ce00296 | 544 | static inline int coresight_claim_device(struct coresight_device *csdev) |
2478a6ae SP |
545 | { |
546 | return -EINVAL; | |
547 | } | |
548 | ||
8ce00296 SP |
549 | static inline void coresight_disclaim_device(struct coresight_device *csdev) {} |
550 | static inline void coresight_disclaim_device_unlocked(struct coresight_device *csdev) {} | |
2478a6ae | 551 | |
f188b5e7 AM |
552 | static inline bool coresight_loses_context_with_cpu(struct device *dev) |
553 | { | |
554 | return false; | |
555 | } | |
6e736c60 SP |
556 | |
557 | static inline u32 coresight_relaxed_read32(struct coresight_device *csdev, u32 offset) | |
558 | { | |
559 | WARN_ON_ONCE(1); | |
560 | return 0; | |
561 | } | |
562 | ||
563 | static inline u32 coresight_read32(struct coresight_device *csdev, u32 offset) | |
564 | { | |
565 | WARN_ON_ONCE(1); | |
566 | return 0; | |
567 | } | |
568 | ||
569 | static inline void coresight_write32(struct coresight_device *csdev, u32 val, u32 offset) | |
570 | { | |
571 | } | |
572 | ||
573 | static inline void coresight_relaxed_write32(struct coresight_device *csdev, | |
574 | u32 val, u32 offset) | |
575 | { | |
576 | } | |
577 | ||
578 | static inline u64 coresight_relaxed_read64(struct coresight_device *csdev, | |
579 | u32 offset) | |
580 | { | |
581 | WARN_ON_ONCE(1); | |
582 | return 0; | |
583 | } | |
584 | ||
585 | static inline u64 coresight_read64(struct coresight_device *csdev, u32 offset) | |
586 | { | |
587 | WARN_ON_ONCE(1); | |
588 | return 0; | |
589 | } | |
590 | ||
591 | static inline void coresight_relaxed_write64(struct coresight_device *csdev, | |
592 | u64 val, u32 offset) | |
593 | { | |
594 | } | |
595 | ||
596 | static inline void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset) | |
597 | { | |
598 | } | |
599 | ||
600 | #endif /* IS_ENABLED(CONFIG_CORESIGHT) */ | |
c61c4b5d | 601 | |
91824db2 | 602 | extern int coresight_get_cpu(struct device *dev); |
a06ae860 | 603 | |
f03631da SP |
604 | struct coresight_platform_data *coresight_get_platform_data(struct device *dev); |
605 | ||
6e736c60 | 606 | #endif /* _LINUX_COREISGHT_H */ |