1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef __INTEL_TH_H__
17#define __INTEL_TH_H__
18
19
20enum {
21
22 INTEL_TH_SOURCE = 0,
23
24 INTEL_TH_OUTPUT,
25
26 INTEL_TH_SWITCH,
27};
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42struct intel_th_output {
43 int port;
44 unsigned int type;
45 unsigned int scratchpad;
46 bool multiblock;
47 bool active;
48};
49
50
51
52
53
54struct intel_th_drvdata {
55 unsigned int tscu_enable : 1;
56};
57
58#define INTEL_TH_CAP(_th, _cap) ((_th)->drvdata ? (_th)->drvdata->_cap : 0)
59
60
61
62
63
64
65
66
67
68
69
70
71
72struct intel_th_device {
73 struct device dev;
74 struct intel_th_drvdata *drvdata;
75 struct resource *resource;
76 unsigned int num_resources;
77 unsigned int type;
78 int id;
79
80
81 bool host_mode;
82
83
84 struct intel_th_output output;
85
86 char name[];
87};
88
89#define to_intel_th_device(_d) \
90 container_of((_d), struct intel_th_device, dev)
91
92
93
94
95
96
97
98static inline struct resource *
99intel_th_device_get_resource(struct intel_th_device *thdev, unsigned int type,
100 unsigned int num)
101{
102 int i;
103
104 for (i = 0; i < thdev->num_resources; i++)
105 if (resource_type(&thdev->resource[i]) == type && !num--)
106 return &thdev->resource[i];
107
108 return NULL;
109}
110
111
112
113
114enum {
115 GTH_NONE = 0,
116 GTH_MSU,
117 GTH_CTP,
118 GTH_LPP,
119 GTH_PTI,
120};
121
122
123
124
125
126
127
128static inline bool
129intel_th_output_assigned(struct intel_th_device *thdev)
130{
131 return thdev->type == INTEL_TH_OUTPUT &&
132 (thdev->output.port >= 0 ||
133 thdev->output.type == GTH_NONE);
134}
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155struct intel_th_driver {
156 struct device_driver driver;
157 int (*probe)(struct intel_th_device *thdev);
158 void (*remove)(struct intel_th_device *thdev);
159
160 int (*assign)(struct intel_th_device *thdev,
161 struct intel_th_device *othdev);
162 void (*unassign)(struct intel_th_device *thdev,
163 struct intel_th_device *othdev);
164 void (*enable)(struct intel_th_device *thdev,
165 struct intel_th_output *output);
166 void (*disable)(struct intel_th_device *thdev,
167 struct intel_th_output *output);
168
169 void (*irq)(struct intel_th_device *thdev);
170 int (*activate)(struct intel_th_device *thdev);
171 void (*deactivate)(struct intel_th_device *thdev);
172
173 const struct file_operations *fops;
174
175 struct attribute_group *attr_group;
176
177
178 int (*set_output)(struct intel_th_device *thdev,
179 unsigned int master);
180};
181
182#define to_intel_th_driver(_d) \
183 container_of((_d), struct intel_th_driver, driver)
184
185#define to_intel_th_driver_or_null(_d) \
186 ((_d) ? to_intel_th_driver(_d) : NULL)
187
188
189
190
191
192
193
194
195
196
197
198static inline struct intel_th_device *
199to_intel_th_parent(struct intel_th_device *thdev)
200{
201 struct device *parent = thdev->dev.parent;
202
203 if (!parent)
204 return NULL;
205
206 return to_intel_th_device(parent);
207}
208
209static inline struct intel_th *to_intel_th(struct intel_th_device *thdev)
210{
211 if (thdev->type == INTEL_TH_OUTPUT)
212 thdev = to_intel_th_parent(thdev);
213
214 if (WARN_ON_ONCE(!thdev || thdev->type == INTEL_TH_OUTPUT))
215 return NULL;
216
217 return dev_get_drvdata(thdev->dev.parent);
218}
219
220struct intel_th *
221intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata,
222 struct resource *devres, unsigned int ndevres, int irq);
223void intel_th_free(struct intel_th *th);
224
225int intel_th_driver_register(struct intel_th_driver *thdrv);
226void intel_th_driver_unregister(struct intel_th_driver *thdrv);
227
228int intel_th_trace_enable(struct intel_th_device *thdev);
229int intel_th_trace_disable(struct intel_th_device *thdev);
230int intel_th_set_output(struct intel_th_device *thdev,
231 unsigned int master);
232int intel_th_output_enable(struct intel_th *th, unsigned int otype);
233
234enum {
235 TH_MMIO_CONFIG = 0,
236 TH_MMIO_SW = 2,
237 TH_MMIO_END,
238};
239
240#define TH_POSSIBLE_OUTPUTS 8
241
242#define TH_SUBDEVICE_MAX (TH_POSSIBLE_OUTPUTS + 2)
243#define TH_CONFIGURABLE_MASTERS 256
244#define TH_MSC_MAX 2
245
246
247
248
249
250
251
252
253
254
255
256
257
258struct intel_th {
259 struct device *dev;
260
261 struct intel_th_device *thdev[TH_SUBDEVICE_MAX];
262 struct intel_th_device *hub;
263 struct intel_th_drvdata *drvdata;
264
265 struct resource *resource;
266 int (*activate)(struct intel_th *);
267 void (*deactivate)(struct intel_th *);
268 unsigned int num_thdevs;
269 unsigned int num_resources;
270 int irq;
271
272 int id;
273 int major;
274#ifdef CONFIG_MODULES
275 struct work_struct request_module_work;
276#endif
277#ifdef CONFIG_INTEL_TH_DEBUG
278 struct dentry *dbg;
279#endif
280};
281
282static inline struct intel_th_device *
283to_intel_th_hub(struct intel_th_device *thdev)
284{
285 if (thdev->type == INTEL_TH_SWITCH)
286 return thdev;
287 else if (thdev->type == INTEL_TH_OUTPUT)
288 return to_intel_th_parent(thdev);
289
290 return to_intel_th(thdev)->hub;
291}
292
293
294
295
296enum {
297
298 REG_GTH_OFFSET = 0x0000,
299 REG_GTH_LENGTH = 0x2000,
300
301
302 REG_TSCU_OFFSET = 0x2000,
303 REG_TSCU_LENGTH = 0x1000,
304
305
306 REG_STH_OFFSET = 0x4000,
307 REG_STH_LENGTH = 0x2000,
308
309
310 REG_MSU_OFFSET = 0xa0000,
311 REG_MSU_LENGTH = 0x02000,
312
313
314 BUF_MSU_OFFSET = 0x80000,
315 BUF_MSU_LENGTH = 0x20000,
316
317
318 REG_PTI_OFFSET = REG_GTH_OFFSET,
319 REG_PTI_LENGTH = REG_GTH_LENGTH,
320
321
322 REG_DCIH_OFFSET = REG_MSU_OFFSET,
323 REG_DCIH_LENGTH = REG_MSU_LENGTH,
324};
325
326
327
328
329
330enum {
331
332 SCRPD_MEM_IS_PRIM_DEST = BIT(0),
333
334 SCRPD_DBC_IS_PRIM_DEST = BIT(1),
335
336 SCRPD_PTI_IS_PRIM_DEST = BIT(2),
337
338 SCRPD_BSSB_IS_PRIM_DEST = BIT(3),
339
340 SCRPD_PTI_IS_ALT_DEST = BIT(4),
341
342 SCRPD_BSSB_IS_ALT_DEST = BIT(5),
343
344 SCRPD_DEEPSX_EXIT = BIT(6),
345
346 SCRPD_S4_EXIT = BIT(7),
347
348 SCRPD_S5_EXIT = BIT(8),
349
350 SCRPD_MSC0_IS_ENABLED = BIT(9),
351 SCRPD_MSC1_IS_ENABLED = BIT(10),
352
353 SCRPD_SX_EXIT = BIT(11),
354
355 SCRPD_TRIGGER_IS_ENABLED = BIT(12),
356 SCRPD_ODLA_IS_ENABLED = BIT(13),
357 SCRPD_SOCHAP_IS_ENABLED = BIT(14),
358 SCRPD_STH_IS_ENABLED = BIT(15),
359 SCRPD_DCIH_IS_ENABLED = BIT(16),
360 SCRPD_VER_IS_ENABLED = BIT(17),
361
362 SCRPD_DEBUGGER_IN_USE = BIT(24),
363};
364
365#endif
366