1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2012, The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef _LINUX_CORESIGHT_H 7 #define _LINUX_CORESIGHT_H 8 9 #include <linux/amba/bus.h> 10 #include <linux/clk.h> 11 #include <linux/device.h> 12 #include <linux/io.h> 13 #include <linux/perf_event.h> 14 #include <linux/sched.h> 15 #include <linux/platform_device.h> 16 17 /* Peripheral id registers (0xFD0-0xFEC) */ 18 #define CORESIGHT_PERIPHIDR4 0xfd0 19 #define CORESIGHT_PERIPHIDR5 0xfd4 20 #define CORESIGHT_PERIPHIDR6 0xfd8 21 #define CORESIGHT_PERIPHIDR7 0xfdC 22 #define CORESIGHT_PERIPHIDR0 0xfe0 23 #define CORESIGHT_PERIPHIDR1 0xfe4 24 #define CORESIGHT_PERIPHIDR2 0xfe8 25 #define CORESIGHT_PERIPHIDR3 0xfeC 26 /* Component id registers (0xFF0-0xFFC) */ 27 #define CORESIGHT_COMPIDR0 0xff0 28 #define CORESIGHT_COMPIDR1 0xff4 29 #define CORESIGHT_COMPIDR2 0xff8 30 #define CORESIGHT_COMPIDR3 0xffC 31 32 #define ETM_ARCH_V3_3 0x23 33 #define ETM_ARCH_V3_5 0x25 34 #define PFT_ARCH_V1_0 0x30 35 #define PFT_ARCH_V1_1 0x31 36 37 #define CORESIGHT_UNLOCK 0xc5acce55 38 39 extern const struct bus_type coresight_bustype; 40 41 enum coresight_dev_type { 42 CORESIGHT_DEV_TYPE_SINK, 43 CORESIGHT_DEV_TYPE_LINK, 44 CORESIGHT_DEV_TYPE_LINKSINK, 45 CORESIGHT_DEV_TYPE_SOURCE, 46 CORESIGHT_DEV_TYPE_HELPER, 47 CORESIGHT_DEV_TYPE_MAX 48 }; 49 50 enum coresight_dev_subtype_sink { 51 CORESIGHT_DEV_SUBTYPE_SINK_DUMMY, 52 CORESIGHT_DEV_SUBTYPE_SINK_PORT, 53 CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, 54 CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, 55 CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM, 56 }; 57 58 enum coresight_dev_subtype_link { 59 CORESIGHT_DEV_SUBTYPE_LINK_MERG, 60 CORESIGHT_DEV_SUBTYPE_LINK_SPLIT, 61 CORESIGHT_DEV_SUBTYPE_LINK_FIFO, 62 }; 63 64 enum coresight_dev_subtype_source { 65 CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, 66 CORESIGHT_DEV_SUBTYPE_SOURCE_BUS, 67 CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, 68 CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM, 69 CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS, 70 }; 71 72 enum coresight_dev_subtype_helper { 73 CORESIGHT_DEV_SUBTYPE_HELPER_CATU, 74 CORESIGHT_DEV_SUBTYPE_HELPER_ECT_CTI 75 }; 76 77 /** 78 * union coresight_dev_subtype - further characterisation of a type 79 * @sink_subtype: type of sink this component is, as defined 80 * by @coresight_dev_subtype_sink. 81 * @link_subtype: type of link this component is, as defined 82 * by @coresight_dev_subtype_link. 83 * @source_subtype: type of source this component is, as defined 84 * by @coresight_dev_subtype_source. 85 * @helper_subtype: type of helper this component is, as defined 86 * by @coresight_dev_subtype_helper. 87 */ 88 union coresight_dev_subtype { 89 /* We have some devices which acts as LINK and SINK */ 90 struct { 91 enum coresight_dev_subtype_sink sink_subtype; 92 enum coresight_dev_subtype_link link_subtype; 93 }; 94 enum coresight_dev_subtype_source source_subtype; 95 enum coresight_dev_subtype_helper helper_subtype; 96 }; 97 98 /** 99 * struct coresight_platform_data - data harvested from the firmware 100 * specification. 101 * 102 * @nr_inconns: Number of elements for the input connections. 103 * @nr_outconns: Number of elements for the output connections. 104 * @out_conns: Array of nr_outconns pointers to connections from this 105 * component. 106 * @in_conns: Sparse array of pointers to input connections. Sparse 107 * because the source device owns the connection so when it's 108 * unloaded the connection leaves an empty slot. 109 */ 110 struct coresight_platform_data { 111 int nr_inconns; 112 int nr_outconns; 113 struct coresight_connection **out_conns; 114 struct coresight_connection **in_conns; 115 }; 116 117 /** 118 * struct csdev_access - Abstraction of a CoreSight device access. 119 * 120 * @io_mem : True if the device has memory mapped I/O 121 * @base : When io_mem == true, base address of the component 122 * @read : Read from the given "offset" of the given instance. 123 * @write : Write "val" to the given "offset". 124 */ 125 struct csdev_access { 126 bool io_mem; 127 union { 128 void __iomem *base; 129 struct { 130 u64 (*read)(u32 offset, bool relaxed, bool _64bit); 131 void (*write)(u64 val, u32 offset, bool relaxed, 132 bool _64bit); 133 }; 134 }; 135 }; 136 137 #define CSDEV_ACCESS_IOMEM(_addr) \ 138 ((struct csdev_access) { \ 139 .io_mem = true, \ 140 .base = (_addr), \ 141 }) 142 143 /** 144 * struct coresight_desc - description of a component required from drivers 145 * @type: as defined by @coresight_dev_type. 146 * @subtype: as defined by @coresight_dev_subtype. 147 * @ops: generic operations for this component, as defined 148 * by @coresight_ops. 149 * @pdata: platform data collected from DT. 150 * @dev: The device entity associated to this component. 151 * @groups: operations specific to this component. These will end up 152 * in the component's sysfs sub-directory. 153 * @name: name for the coresight device, also shown under sysfs. 154 * @access: Describe access to the device 155 */ 156 struct coresight_desc { 157 enum coresight_dev_type type; 158 union coresight_dev_subtype subtype; 159 const struct coresight_ops *ops; 160 struct coresight_platform_data *pdata; 161 struct device *dev; 162 const struct attribute_group **groups; 163 const char *name; 164 struct csdev_access access; 165 }; 166 167 /** 168 * struct coresight_connection - representation of a single connection 169 * @src_port: a connection's output port number. 170 * @dest_port: destination's input port number @src_port is connected to. 171 * @dest_fwnode: destination component's fwnode handle. 172 * @dest_dev: a @coresight_device representation of the component 173 connected to @src_port. NULL until the device is created 174 * @link: Representation of the connection as a sysfs link. 175 * @filter_src_fwnode: filter source component's fwnode handle. 176 * @filter_src_dev: a @coresight_device representation of the component that 177 needs to be filtered. 178 * 179 * The full connection structure looks like this, where in_conns store 180 * references to same connection as the source device's out_conns. 181 * 182 * +-----------------------------+ +-----------------------------+ 183 * |coresight_device | |coresight_connection | 184 * |-----------------------------| |-----------------------------| 185 * | | | | 186 * | | | dest_dev*|<-- 187 * |pdata->out_conns[nr_outconns]|<->|src_dev* | | 188 * | | | | | 189 * +-----------------------------+ +-----------------------------+ | 190 * | 191 * +-----------------------------+ | 192 * |coresight_device | | 193 * |------------------------------ | 194 * | | | 195 * | pdata->in_conns[nr_inconns]|<-- 196 * | | 197 * +-----------------------------+ 198 */ 199 struct coresight_connection { 200 int src_port; 201 int dest_port; 202 struct fwnode_handle *dest_fwnode; 203 struct coresight_device *dest_dev; 204 struct coresight_sysfs_link *link; 205 struct coresight_device *src_dev; 206 struct fwnode_handle *filter_src_fwnode; 207 struct coresight_device *filter_src_dev; 208 int src_refcnt; 209 int dest_refcnt; 210 }; 211 212 /** 213 * struct coresight_sysfs_link - representation of a connection in sysfs. 214 * @orig: Originating (master) coresight device for the link. 215 * @orig_name: Name to use for the link orig->target. 216 * @target: Target (slave) coresight device for the link. 217 * @target_name: Name to use for the link target->orig. 218 */ 219 struct coresight_sysfs_link { 220 struct coresight_device *orig; 221 const char *orig_name; 222 struct coresight_device *target; 223 const char *target_name; 224 }; 225 226 /* architecturally we have 128 IDs some of which are reserved */ 227 #define CORESIGHT_TRACE_IDS_MAX 128 228 229 /** 230 * Trace ID map. 231 * 232 * @used_ids: Bitmap to register available (bit = 0) and in use (bit = 1) IDs. 233 * Initialised so that the reserved IDs are permanently marked as 234 * in use. 235 * @perf_cs_etm_session_active: Number of Perf sessions using this ID map. 236 */ 237 struct coresight_trace_id_map { 238 DECLARE_BITMAP(used_ids, CORESIGHT_TRACE_IDS_MAX); 239 atomic_t __percpu *cpu_map; 240 atomic_t perf_cs_etm_session_active; 241 spinlock_t lock; 242 }; 243 244 /** 245 * struct coresight_device - representation of a device as used by the framework 246 * @pdata: Platform data with device connections associated to this device. 247 * @type: as defined by @coresight_dev_type. 248 * @subtype: as defined by @coresight_dev_subtype. 249 * @ops: generic operations for this component, as defined 250 * by @coresight_ops. 251 * @access: Device i/o access abstraction for this device. 252 * @dev: The device entity associated to this component. 253 * @mode: This tracer's mode, i.e sysFS, Perf or disabled. This is 254 * actually an 'enum cs_mode', but is stored in an atomic type. 255 * This is always accessed through local_read() and local_set(), 256 * but wherever it's done from within the Coresight device's lock, 257 * a non-atomic read would also work. This is the main point of 258 * synchronisation between code happening inside the sysfs mode's 259 * coresight_mutex and outside when running in Perf mode. A compare 260 * and exchange swap is done to atomically claim one mode or the 261 * other. 262 * @refcnt: keep track of what is in use. Only access this outside of the 263 * device's spinlock when the coresight_mutex held and mode == 264 * CS_MODE_SYSFS. Otherwise it must be accessed from inside the 265 * spinlock. 266 * @orphan: true if the component has connections that haven't been linked. 267 * @sysfs_sink_activated: 'true' when a sink has been selected for use via sysfs 268 * by writing a 1 to the 'enable_sink' file. A sink can be 269 * activated but not yet enabled. Enabling for a _sink_ happens 270 * when a source has been selected and a path is enabled from 271 * source to that sink. A sink can also become enabled but not 272 * activated if it's used via Perf. 273 * @ea: Device attribute for sink representation under PMU directory. 274 * @def_sink: cached reference to default sink found for this device. 275 * @nr_links: number of sysfs links created to other components from this 276 * device. These will appear in the "connections" group. 277 * @has_conns_grp: Have added a "connections" group for sysfs links. 278 * @feature_csdev_list: List of complex feature programming added to the device. 279 * @config_csdev_list: List of system configurations added to the device. 280 * @cscfg_csdev_lock: Protect the lists of configurations and features. 281 * @active_cscfg_ctxt: Context information for current active system configuration. 282 */ 283 struct coresight_device { 284 struct coresight_platform_data *pdata; 285 enum coresight_dev_type type; 286 union coresight_dev_subtype subtype; 287 const struct coresight_ops *ops; 288 struct csdev_access access; 289 struct device dev; 290 local_t mode; 291 int refcnt; 292 bool orphan; 293 /* sink specific fields */ 294 bool sysfs_sink_activated; 295 struct dev_ext_attribute *ea; 296 struct coresight_device *def_sink; 297 struct coresight_trace_id_map perf_sink_id_map; 298 /* sysfs links between components */ 299 int nr_links; 300 bool has_conns_grp; 301 /* system configuration and feature lists */ 302 struct list_head feature_csdev_list; 303 struct list_head config_csdev_list; 304 spinlock_t cscfg_csdev_lock; 305 void *active_cscfg_ctxt; 306 }; 307 308 /* 309 * coresight_dev_list - Mapping for devices to "name" index for device 310 * names. 311 * 312 * @nr_idx: Number of entries already allocated. 313 * @pfx: Prefix pattern for device name. 314 * @fwnode_list: Array of fwnode_handles associated with each allocated 315 * index, upto nr_idx entries. 316 */ 317 struct coresight_dev_list { 318 int nr_idx; 319 const char *pfx; 320 struct fwnode_handle **fwnode_list; 321 }; 322 323 #define DEFINE_CORESIGHT_DEVLIST(var, dev_pfx) \ 324 static struct coresight_dev_list (var) = { \ 325 .pfx = dev_pfx, \ 326 .nr_idx = 0, \ 327 .fwnode_list = NULL, \ 328 } 329 330 #define to_coresight_device(d) container_of(d, struct coresight_device, dev) 331 332 /** 333 * struct coresight_path - data needed by enable/disable path 334 * @path_list: path from source to sink. 335 * @trace_id: trace_id of the whole path. 336 */ 337 struct coresight_path { 338 struct list_head path_list; 339 u8 trace_id; 340 }; 341 342 enum cs_mode { 343 CS_MODE_DISABLED, 344 CS_MODE_SYSFS, 345 CS_MODE_PERF, 346 }; 347 348 #define coresight_ops(csdev) csdev->ops 349 #define source_ops(csdev) csdev->ops->source_ops 350 #define sink_ops(csdev) csdev->ops->sink_ops 351 #define link_ops(csdev) csdev->ops->link_ops 352 #define helper_ops(csdev) csdev->ops->helper_ops 353 #define ect_ops(csdev) csdev->ops->ect_ops 354 #define panic_ops(csdev) csdev->ops->panic_ops 355 356 /** 357 * struct coresight_ops_sink - basic operations for a sink 358 * Operations available for sinks 359 * @enable: enables the sink. 360 * @disable: disables the sink. 361 * @alloc_buffer: initialises perf's ring buffer for trace collection. 362 * @free_buffer: release memory allocated in @get_config. 363 * @update_buffer: update buffer pointers after a trace session. 364 */ 365 struct coresight_ops_sink { 366 int (*enable)(struct coresight_device *csdev, enum cs_mode mode, 367 void *data); 368 int (*disable)(struct coresight_device *csdev); 369 void *(*alloc_buffer)(struct coresight_device *csdev, 370 struct perf_event *event, void **pages, 371 int nr_pages, bool overwrite); 372 void (*free_buffer)(void *config); 373 unsigned long (*update_buffer)(struct coresight_device *csdev, 374 struct perf_output_handle *handle, 375 void *sink_config); 376 }; 377 378 /** 379 * struct coresight_ops_link - basic operations for a link 380 * Operations available for links. 381 * @enable: enables flow between iport and oport. 382 * @disable: disables flow between iport and oport. 383 */ 384 struct coresight_ops_link { 385 int (*enable)(struct coresight_device *csdev, 386 struct coresight_connection *in, 387 struct coresight_connection *out); 388 void (*disable)(struct coresight_device *csdev, 389 struct coresight_connection *in, 390 struct coresight_connection *out); 391 }; 392 393 /** 394 * struct coresight_ops_source - basic operations for a source 395 * Operations available for sources. 396 * @cpu_id: returns the value of the CPU number this component 397 * is associated to. 398 * @enable: enables tracing for a source. 399 * @disable: disables tracing for a source. 400 */ 401 struct coresight_ops_source { 402 int (*cpu_id)(struct coresight_device *csdev); 403 int (*enable)(struct coresight_device *csdev, struct perf_event *event, 404 enum cs_mode mode, struct coresight_path *path); 405 void (*disable)(struct coresight_device *csdev, 406 struct perf_event *event); 407 }; 408 409 /** 410 * struct coresight_ops_helper - Operations for a helper device. 411 * 412 * All operations could pass in a device specific data, which could 413 * help the helper device to determine what to do. 414 * 415 * @enable : Enable the device 416 * @disable : Disable the device 417 */ 418 struct coresight_ops_helper { 419 int (*enable)(struct coresight_device *csdev, enum cs_mode mode, 420 void *data); 421 int (*disable)(struct coresight_device *csdev, void *data); 422 }; 423 424 425 /** 426 * struct coresight_ops_panic - Generic device ops for panic handing 427 * 428 * @sync : Sync the device register state/trace data 429 */ 430 struct coresight_ops_panic { 431 int (*sync)(struct coresight_device *csdev); 432 }; 433 434 struct coresight_ops { 435 int (*trace_id)(struct coresight_device *csdev, enum cs_mode mode, 436 struct coresight_device *sink); 437 const struct coresight_ops_sink *sink_ops; 438 const struct coresight_ops_link *link_ops; 439 const struct coresight_ops_source *source_ops; 440 const struct coresight_ops_helper *helper_ops; 441 const struct coresight_ops_panic *panic_ops; 442 }; 443 444 static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa, 445 u32 offset) 446 { 447 if (likely(csa->io_mem)) 448 return readl_relaxed(csa->base + offset); 449 450 return csa->read(offset, true, false); 451 } 452 453 #define CORESIGHT_CIDRn(i) (0xFF0 + ((i) * 4)) 454 455 static inline u32 coresight_get_cid(void __iomem *base) 456 { 457 u32 i, cid = 0; 458 459 for (i = 0; i < 4; i++) 460 cid |= readl(base + CORESIGHT_CIDRn(i)) << (i * 8); 461 462 return cid; 463 } 464 465 static inline bool is_coresight_device(void __iomem *base) 466 { 467 u32 cid = coresight_get_cid(base); 468 469 return cid == CORESIGHT_CID; 470 } 471 472 /* 473 * Attempt to find and enable "APB clock" for the given device 474 * 475 * Returns: 476 * 477 * clk - Clock is found and enabled 478 * NULL - clock is not found 479 * ERROR - Clock is found but failed to enable 480 */ 481 static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev) 482 { 483 struct clk *pclk; 484 int ret; 485 486 pclk = clk_get(dev, "apb_pclk"); 487 if (IS_ERR(pclk)) { 488 pclk = clk_get(dev, "apb"); 489 if (IS_ERR(pclk)) 490 return NULL; 491 } 492 493 ret = clk_prepare_enable(pclk); 494 if (ret) { 495 clk_put(pclk); 496 return ERR_PTR(ret); 497 } 498 return pclk; 499 } 500 501 #define CORESIGHT_PIDRn(i) (0xFE0 + ((i) * 4)) 502 503 static inline u32 coresight_get_pid(struct csdev_access *csa) 504 { 505 u32 i, pid = 0; 506 507 for (i = 0; i < 4; i++) 508 pid |= csdev_access_relaxed_read32(csa, CORESIGHT_PIDRn(i)) << (i * 8); 509 510 return pid; 511 } 512 513 static inline u64 csdev_access_relaxed_read_pair(struct csdev_access *csa, 514 u32 lo_offset, u32 hi_offset) 515 { 516 if (likely(csa->io_mem)) { 517 return readl_relaxed(csa->base + lo_offset) | 518 ((u64)readl_relaxed(csa->base + hi_offset) << 32); 519 } 520 521 return csa->read(lo_offset, true, false) | (csa->read(hi_offset, true, false) << 32); 522 } 523 524 static inline void csdev_access_relaxed_write_pair(struct csdev_access *csa, u64 val, 525 u32 lo_offset, u32 hi_offset) 526 { 527 if (likely(csa->io_mem)) { 528 writel_relaxed((u32)val, csa->base + lo_offset); 529 writel_relaxed((u32)(val >> 32), csa->base + hi_offset); 530 } else { 531 csa->write((u32)val, lo_offset, true, false); 532 csa->write((u32)(val >> 32), hi_offset, true, false); 533 } 534 } 535 536 static inline u32 csdev_access_read32(struct csdev_access *csa, u32 offset) 537 { 538 if (likely(csa->io_mem)) 539 return readl(csa->base + offset); 540 541 return csa->read(offset, false, false); 542 } 543 544 static inline void csdev_access_relaxed_write32(struct csdev_access *csa, 545 u32 val, u32 offset) 546 { 547 if (likely(csa->io_mem)) 548 writel_relaxed(val, csa->base + offset); 549 else 550 csa->write(val, offset, true, false); 551 } 552 553 static inline void csdev_access_write32(struct csdev_access *csa, u32 val, u32 offset) 554 { 555 if (likely(csa->io_mem)) 556 writel(val, csa->base + offset); 557 else 558 csa->write(val, offset, false, false); 559 } 560 561 #ifdef CONFIG_64BIT 562 563 static inline u64 csdev_access_relaxed_read64(struct csdev_access *csa, 564 u32 offset) 565 { 566 if (likely(csa->io_mem)) 567 return readq_relaxed(csa->base + offset); 568 569 return csa->read(offset, true, true); 570 } 571 572 static inline u64 csdev_access_read64(struct csdev_access *csa, u32 offset) 573 { 574 if (likely(csa->io_mem)) 575 return readq(csa->base + offset); 576 577 return csa->read(offset, false, true); 578 } 579 580 static inline void csdev_access_relaxed_write64(struct csdev_access *csa, 581 u64 val, u32 offset) 582 { 583 if (likely(csa->io_mem)) 584 writeq_relaxed(val, csa->base + offset); 585 else 586 csa->write(val, offset, true, true); 587 } 588 589 static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 offset) 590 { 591 if (likely(csa->io_mem)) 592 writeq(val, csa->base + offset); 593 else 594 csa->write(val, offset, false, true); 595 } 596 597 #else /* !CONFIG_64BIT */ 598 599 static inline u64 csdev_access_relaxed_read64(struct csdev_access *csa, 600 u32 offset) 601 { 602 WARN_ON(1); 603 return 0; 604 } 605 606 static inline u64 csdev_access_read64(struct csdev_access *csa, u32 offset) 607 { 608 WARN_ON(1); 609 return 0; 610 } 611 612 static inline void csdev_access_relaxed_write64(struct csdev_access *csa, 613 u64 val, u32 offset) 614 { 615 WARN_ON(1); 616 } 617 618 static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 offset) 619 { 620 WARN_ON(1); 621 } 622 #endif /* CONFIG_64BIT */ 623 624 static inline bool coresight_is_device_source(struct coresight_device *csdev) 625 { 626 return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SOURCE); 627 } 628 629 static inline bool coresight_is_percpu_source(struct coresight_device *csdev) 630 { 631 return csdev && coresight_is_device_source(csdev) && 632 (csdev->subtype.source_subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_PROC); 633 } 634 635 static inline bool coresight_is_percpu_sink(struct coresight_device *csdev) 636 { 637 return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SINK) && 638 (csdev->subtype.sink_subtype == CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM); 639 } 640 641 /* 642 * Atomically try to take the device and set a new mode. Returns true on 643 * success, false if the device is already taken by someone else. 644 */ 645 static inline bool coresight_take_mode(struct coresight_device *csdev, 646 enum cs_mode new_mode) 647 { 648 return local_cmpxchg(&csdev->mode, CS_MODE_DISABLED, new_mode) == 649 CS_MODE_DISABLED; 650 } 651 652 static inline enum cs_mode coresight_get_mode(struct coresight_device *csdev) 653 { 654 return local_read(&csdev->mode); 655 } 656 657 static inline void coresight_set_mode(struct coresight_device *csdev, 658 enum cs_mode new_mode) 659 { 660 enum cs_mode current_mode = coresight_get_mode(csdev); 661 662 /* 663 * Changing to a new mode must be done from an already disabled state 664 * unless it's synchronized with coresight_take_mode(). Otherwise the 665 * device is already in use and signifies a locking issue. 666 */ 667 WARN(new_mode != CS_MODE_DISABLED && current_mode != CS_MODE_DISABLED && 668 current_mode != new_mode, "Device already in use\n"); 669 670 local_set(&csdev->mode, new_mode); 671 } 672 673 extern struct coresight_device * 674 coresight_register(struct coresight_desc *desc); 675 extern void coresight_unregister(struct coresight_device *csdev); 676 extern int coresight_enable_sysfs(struct coresight_device *csdev); 677 extern void coresight_disable_sysfs(struct coresight_device *csdev); 678 extern int coresight_timeout(struct csdev_access *csa, u32 offset, 679 int position, int value); 680 typedef void (*coresight_timeout_cb_t) (struct csdev_access *, u32, int, int); 681 extern int coresight_timeout_action(struct csdev_access *csa, u32 offset, 682 int position, int value, 683 coresight_timeout_cb_t cb); 684 685 extern int coresight_claim_device(struct coresight_device *csdev); 686 extern int coresight_claim_device_unlocked(struct coresight_device *csdev); 687 688 extern void coresight_disclaim_device(struct coresight_device *csdev); 689 extern void coresight_disclaim_device_unlocked(struct coresight_device *csdev); 690 extern char *coresight_alloc_device_name(struct coresight_dev_list *devs, 691 struct device *dev); 692 693 extern bool coresight_loses_context_with_cpu(struct device *dev); 694 695 u32 coresight_relaxed_read32(struct coresight_device *csdev, u32 offset); 696 u32 coresight_read32(struct coresight_device *csdev, u32 offset); 697 void coresight_write32(struct coresight_device *csdev, u32 val, u32 offset); 698 void coresight_relaxed_write32(struct coresight_device *csdev, 699 u32 val, u32 offset); 700 u64 coresight_relaxed_read64(struct coresight_device *csdev, u32 offset); 701 u64 coresight_read64(struct coresight_device *csdev, u32 offset); 702 void coresight_relaxed_write64(struct coresight_device *csdev, 703 u64 val, u32 offset); 704 void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset); 705 706 extern int coresight_get_cpu(struct device *dev); 707 extern int coresight_get_static_trace_id(struct device *dev, u32 *id); 708 709 struct coresight_platform_data *coresight_get_platform_data(struct device *dev); 710 struct coresight_connection * 711 coresight_add_out_conn(struct device *dev, 712 struct coresight_platform_data *pdata, 713 const struct coresight_connection *new_conn); 714 int coresight_add_in_conn(struct coresight_connection *conn); 715 struct coresight_device * 716 coresight_find_input_type(struct coresight_platform_data *pdata, 717 enum coresight_dev_type type, 718 union coresight_dev_subtype subtype); 719 struct coresight_device * 720 coresight_find_output_type(struct coresight_platform_data *pdata, 721 enum coresight_dev_type type, 722 union coresight_dev_subtype subtype); 723 724 int coresight_init_driver(const char *drv, struct amba_driver *amba_drv, 725 struct platform_driver *pdev_drv); 726 727 void coresight_remove_driver(struct amba_driver *amba_drv, 728 struct platform_driver *pdev_drv); 729 int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode, 730 struct coresight_device *sink); 731 #endif /* _LINUX_COREISGHT_H */ 732