summaryrefslogtreecommitdiffstats
path: root/include/linux/stm.h
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2015-09-22 08:47:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-04 15:28:58 -0400
commit7bd1d4093c2fa37d1ecab05da3c9d48ea2af2264 (patch)
tree24400395a4d56de0499f61e423529769f46fd83f /include/linux/stm.h
parent9b76968db6869666c9b30ea99894e9dd88a0ab13 (diff)
stm class: Introduce an abstraction for System Trace Module devices
A System Trace Module (STM) is a device exporting data in System Trace Protocol (STP) format as defined by MIPI STP standards. Examples of such devices are Intel(R) Trace Hub and Coresight STM. This abstraction provides a unified interface for software trace sources to send their data over an STM device to a debug host. In order to do that, such a trace source needs to be assigned a pair of master/channel identifiers that all the data from this source will be tagged with. The STP decoder on the debug host side will use these master/channel tags to distinguish different trace streams from one another inside one STP stream. This abstraction provides a configfs-based policy management mechanism for dynamic allocation of these master/channel pairs based on trace source-supplied string identifier. It has the flexibility of being defined at runtime and at the same time (provided that the policy definition is aligned with the decoding end) consistency. For userspace trace sources, this abstraction provides write()-based and mmap()-based (if the underlying stm device allows this) output mechanism. For kernel-side trace sources, we provide "stm_source" device class that can be connected to an stm device at run time. Cc: linux-api@vger.kernel.org Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/stm.h')
-rw-r--r--include/linux/stm.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/include/linux/stm.h b/include/linux/stm.h
new file mode 100644
index 000000000000..9d0083d364e6
--- /dev/null
+++ b/include/linux/stm.h
@@ -0,0 +1,126 @@
1/*
2 * System Trace Module (STM) infrastructure apis
3 * Copyright (C) 2014 Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope 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
15#ifndef _STM_H_
16#define _STM_H_
17
18#include <linux/device.h>
19
20/**
21 * enum stp_packet_type - STP packets that an STM driver sends
22 */
23enum stp_packet_type {
24 STP_PACKET_DATA = 0,
25 STP_PACKET_FLAG,
26 STP_PACKET_USER,
27 STP_PACKET_MERR,
28 STP_PACKET_GERR,
29 STP_PACKET_TRIG,
30 STP_PACKET_XSYNC,
31};
32
33/**
34 * enum stp_packet_flags - STP packet modifiers
35 */
36enum stp_packet_flags {
37 STP_PACKET_MARKED = 0x1,
38 STP_PACKET_TIMESTAMPED = 0x2,
39};
40
41struct stp_policy;
42
43struct stm_device;
44
45/**
46 * struct stm_data - STM device description and callbacks
47 * @name: device name
48 * @stm: internal structure, only used by stm class code
49 * @sw_start: first STP master available to software
50 * @sw_end: last STP master available to software
51 * @sw_nchannels: number of STP channels per master
52 * @sw_mmiosz: size of one channel's IO space, for mmap, optional
53 * @packet: callback that sends an STP packet
54 * @mmio_addr: mmap callback, optional
55 * @link: called when a new stm_source gets linked to us, optional
56 * @unlink: likewise for unlinking, again optional
57 * @set_options: set device-specific options on a channel
58 *
59 * Fill out this structure before calling stm_register_device() to create
60 * an STM device and stm_unregister_device() to destroy it. It will also be
61 * passed back to @packet(), @mmio_addr(), @link(), @unlink() and @set_options()
62 * callbacks.
63 *
64 * Normally, an STM device will have a range of masters available to software
65 * and the rest being statically assigned to various hardware trace sources.
66 * The former is defined by the the range [@sw_start..@sw_end] of the device
67 * description. That is, the lowest master that can be allocated to software
68 * writers is @sw_start and data from this writer will appear is @sw_start
69 * master in the STP stream.
70 */
71struct stm_data {
72 const char *name;
73 struct stm_device *stm;
74 unsigned int sw_start;
75 unsigned int sw_end;
76 unsigned int sw_nchannels;
77 unsigned int sw_mmiosz;
78 ssize_t (*packet)(struct stm_data *, unsigned int,
79 unsigned int, unsigned int,
80 unsigned int, unsigned int,
81 const unsigned char *);
82 phys_addr_t (*mmio_addr)(struct stm_data *, unsigned int,
83 unsigned int, unsigned int);
84 int (*link)(struct stm_data *, unsigned int,
85 unsigned int);
86 void (*unlink)(struct stm_data *, unsigned int,
87 unsigned int);
88 long (*set_options)(struct stm_data *, unsigned int,
89 unsigned int, unsigned int,
90 unsigned long);
91};
92
93int stm_register_device(struct device *parent, struct stm_data *stm_data,
94 struct module *owner);
95void stm_unregister_device(struct stm_data *stm_data);
96
97struct stm_source_device;
98
99/**
100 * struct stm_source_data - STM source device description and callbacks
101 * @name: device name, will be used for policy lookup
102 * @src: internal structure, only used by stm class code
103 * @nr_chans: number of channels to allocate
104 * @link: called when this source gets linked to an STM device
105 * @unlink: called when this source is about to get unlinked from its STM
106 *
107 * Fill in this structure before calling stm_source_register_device() to
108 * register a source device. Also pass it to unregister and write calls.
109 */
110struct stm_source_data {
111 const char *name;
112 struct stm_source_device *src;
113 unsigned int percpu;
114 unsigned int nr_chans;
115 int (*link)(struct stm_source_data *data);
116 void (*unlink)(struct stm_source_data *data);
117};
118
119int stm_source_register_device(struct device *parent,
120 struct stm_source_data *data);
121void stm_source_unregister_device(struct stm_source_data *data);
122
123int stm_source_write(struct stm_source_data *data, unsigned int chan,
124 const char *buf, size_t count);
125
126#endif /* _STM_H_ */