1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _LINUX_CORESIGHT_H
14#define _LINUX_CORESIGHT_H
15
16#include <linux/device.h>
17
18
19#define CORESIGHT_PERIPHIDR4 0xfd0
20#define CORESIGHT_PERIPHIDR5 0xfd4
21#define CORESIGHT_PERIPHIDR6 0xfd8
22#define CORESIGHT_PERIPHIDR7 0xfdC
23#define CORESIGHT_PERIPHIDR0 0xfe0
24#define CORESIGHT_PERIPHIDR1 0xfe4
25#define CORESIGHT_PERIPHIDR2 0xfe8
26#define CORESIGHT_PERIPHIDR3 0xfeC
27
28#define CORESIGHT_COMPIDR0 0xff0
29#define CORESIGHT_COMPIDR1 0xff4
30#define CORESIGHT_COMPIDR2 0xff8
31#define CORESIGHT_COMPIDR3 0xffC
32
33#define ETM_ARCH_V3_3 0x23
34#define ETM_ARCH_V3_5 0x25
35#define PFT_ARCH_V1_0 0x30
36#define PFT_ARCH_V1_1 0x31
37
38#define CORESIGHT_UNLOCK 0xc5acce55
39
40extern struct bus_type coresight_bustype;
41
42enum coresight_dev_type {
43 CORESIGHT_DEV_TYPE_NONE,
44 CORESIGHT_DEV_TYPE_SINK,
45 CORESIGHT_DEV_TYPE_LINK,
46 CORESIGHT_DEV_TYPE_LINKSINK,
47 CORESIGHT_DEV_TYPE_SOURCE,
48};
49
50enum coresight_dev_subtype_sink {
51 CORESIGHT_DEV_SUBTYPE_SINK_NONE,
52 CORESIGHT_DEV_SUBTYPE_SINK_PORT,
53 CORESIGHT_DEV_SUBTYPE_SINK_BUFFER,
54};
55
56enum coresight_dev_subtype_link {
57 CORESIGHT_DEV_SUBTYPE_LINK_NONE,
58 CORESIGHT_DEV_SUBTYPE_LINK_MERG,
59 CORESIGHT_DEV_SUBTYPE_LINK_SPLIT,
60 CORESIGHT_DEV_SUBTYPE_LINK_FIFO,
61};
62
63enum coresight_dev_subtype_source {
64 CORESIGHT_DEV_SUBTYPE_SOURCE_NONE,
65 CORESIGHT_DEV_SUBTYPE_SOURCE_PROC,
66 CORESIGHT_DEV_SUBTYPE_SOURCE_BUS,
67 CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE,
68};
69
70
71
72
73
74
75
76
77
78
79struct coresight_dev_subtype {
80 enum coresight_dev_subtype_sink sink_subtype;
81 enum coresight_dev_subtype_link link_subtype;
82 enum coresight_dev_subtype_source source_subtype;
83};
84
85
86
87
88
89
90
91
92
93
94
95
96
97struct coresight_platform_data {
98 int cpu;
99 const char *name;
100 int nr_inport;
101 int *outports;
102 const char **child_names;
103 int *child_ports;
104 int nr_outport;
105 struct clk *clk;
106};
107
108
109
110
111
112
113
114
115
116
117
118
119struct coresight_desc {
120 enum coresight_dev_type type;
121 struct coresight_dev_subtype subtype;
122 const struct coresight_ops *ops;
123 struct coresight_platform_data *pdata;
124 struct device *dev;
125 const struct attribute_group **groups;
126};
127
128
129
130
131
132
133
134
135
136struct coresight_connection {
137 int outport;
138 const char *child_name;
139 int child_port;
140 struct coresight_device *child_dev;
141};
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161struct coresight_device {
162 struct coresight_connection *conns;
163 int nr_inport;
164 int nr_outport;
165 enum coresight_dev_type type;
166 struct coresight_dev_subtype subtype;
167 const struct coresight_ops *ops;
168 struct device dev;
169 atomic_t *refcnt;
170 struct list_head path_link;
171 bool orphan;
172 bool enable;
173 bool activated;
174};
175
176#define to_coresight_device(d) container_of(d, struct coresight_device, dev)
177
178#define source_ops(csdev) csdev->ops->source_ops
179#define sink_ops(csdev) csdev->ops->sink_ops
180#define link_ops(csdev) csdev->ops->link_ops
181
182
183
184
185
186
187
188struct coresight_ops_sink {
189 int (*enable)(struct coresight_device *csdev);
190 void (*disable)(struct coresight_device *csdev);
191};
192
193
194
195
196
197
198
199struct coresight_ops_link {
200 int (*enable)(struct coresight_device *csdev, int iport, int oport);
201 void (*disable)(struct coresight_device *csdev, int iport, int oport);
202};
203
204
205
206
207
208
209
210
211
212struct coresight_ops_source {
213 int (*trace_id)(struct coresight_device *csdev);
214 int (*enable)(struct coresight_device *csdev);
215 void (*disable)(struct coresight_device *csdev);
216};
217
218struct coresight_ops {
219 const struct coresight_ops_sink *sink_ops;
220 const struct coresight_ops_link *link_ops;
221 const struct coresight_ops_source *source_ops;
222};
223
224#ifdef CONFIG_CORESIGHT
225extern struct coresight_device *
226coresight_register(struct coresight_desc *desc);
227extern void coresight_unregister(struct coresight_device *csdev);
228extern int coresight_enable(struct coresight_device *csdev);
229extern void coresight_disable(struct coresight_device *csdev);
230extern int coresight_timeout(void __iomem *addr, u32 offset,
231 int position, int value);
232#else
233static inline struct coresight_device *
234coresight_register(struct coresight_desc *desc) { return NULL; }
235static inline void coresight_unregister(struct coresight_device *csdev) {}
236static inline int
237coresight_enable(struct coresight_device *csdev) { return -ENOSYS; }
238static inline void coresight_disable(struct coresight_device *csdev) {}
239static inline int coresight_timeout(void __iomem *addr, u32 offset,
240 int position, int value) { return 1; }
241#endif
242
243#ifdef CONFIG_OF
244extern struct coresight_platform_data *of_get_coresight_platform_data(
245 struct device *dev, struct device_node *node);
246#else
247static inline struct coresight_platform_data *of_get_coresight_platform_data(
248 struct device *dev, struct device_node *node) { return NULL; }
249#endif
250
251#endif
252