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
54
55
56
57
58
59
60struct intel_th_device {
61 struct device dev;
62 struct resource *resource;
63 unsigned int num_resources;
64 unsigned int type;
65 int id;
66
67
68 struct intel_th_output output;
69
70 char name[];
71};
72
73#define to_intel_th_device(_d) \
74 container_of((_d), struct intel_th_device, dev)
75
76
77
78
79
80
81
82static inline struct resource *
83intel_th_device_get_resource(struct intel_th_device *thdev, unsigned int type,
84 unsigned int num)
85{
86 int i;
87
88 for (i = 0; i < thdev->num_resources; i++)
89 if (resource_type(&thdev->resource[i]) == type && !num--)
90 return &thdev->resource[i];
91
92 return NULL;
93}
94
95
96
97
98
99
100
101static inline bool
102intel_th_output_assigned(struct intel_th_device *thdev)
103{
104 return thdev->type == INTEL_TH_OUTPUT &&
105 thdev->output.port >= 0;
106}
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127struct intel_th_driver {
128 struct device_driver driver;
129 int (*probe)(struct intel_th_device *thdev);
130 void (*remove)(struct intel_th_device *thdev);
131
132 int (*assign)(struct intel_th_device *thdev,
133 struct intel_th_device *othdev);
134 void (*unassign)(struct intel_th_device *thdev,
135 struct intel_th_device *othdev);
136 void (*enable)(struct intel_th_device *thdev,
137 struct intel_th_output *output);
138 void (*disable)(struct intel_th_device *thdev,
139 struct intel_th_output *output);
140
141 void (*irq)(struct intel_th_device *thdev);
142 int (*activate)(struct intel_th_device *thdev);
143 void (*deactivate)(struct intel_th_device *thdev);
144
145 const struct file_operations *fops;
146
147 struct attribute_group *attr_group;
148
149
150 int (*set_output)(struct intel_th_device *thdev,
151 unsigned int master);
152};
153
154#define to_intel_th_driver(_d) \
155 container_of((_d), struct intel_th_driver, driver)
156
157#define to_intel_th_driver_or_null(_d) \
158 ((_d) ? to_intel_th_driver(_d) : NULL)
159
160static inline struct intel_th_device *
161to_intel_th_hub(struct intel_th_device *thdev)
162{
163 struct device *parent = thdev->dev.parent;
164
165 if (!parent)
166 return NULL;
167
168 return to_intel_th_device(parent);
169}
170
171struct intel_th *
172intel_th_alloc(struct device *dev, struct resource *devres,
173 unsigned int ndevres, int irq);
174void intel_th_free(struct intel_th *th);
175
176int intel_th_driver_register(struct intel_th_driver *thdrv);
177void intel_th_driver_unregister(struct intel_th_driver *thdrv);
178
179int intel_th_trace_enable(struct intel_th_device *thdev);
180int intel_th_trace_disable(struct intel_th_device *thdev);
181int intel_th_set_output(struct intel_th_device *thdev,
182 unsigned int master);
183
184enum {
185 TH_MMIO_CONFIG = 0,
186 TH_MMIO_SW = 2,
187 TH_MMIO_END,
188};
189
190#define TH_SUBDEVICE_MAX 6
191#define TH_POSSIBLE_OUTPUTS 8
192#define TH_CONFIGURABLE_MASTERS 256
193#define TH_MSC_MAX 2
194
195
196
197
198
199
200
201
202
203struct intel_th {
204 struct device *dev;
205
206 struct intel_th_device *thdev[TH_SUBDEVICE_MAX];
207 struct intel_th_device *hub;
208
209 int id;
210 int major;
211#ifdef CONFIG_MODULES
212 struct work_struct request_module_work;
213#endif
214#ifdef CONFIG_INTEL_TH_DEBUG
215 struct dentry *dbg;
216#endif
217};
218
219
220
221
222enum {
223
224 REG_GTH_OFFSET = 0x0000,
225 REG_GTH_LENGTH = 0x2000,
226
227
228 REG_STH_OFFSET = 0x4000,
229 REG_STH_LENGTH = 0x2000,
230
231
232 REG_MSU_OFFSET = 0xa0000,
233 REG_MSU_LENGTH = 0x02000,
234
235
236 BUF_MSU_OFFSET = 0x80000,
237 BUF_MSU_LENGTH = 0x20000,
238
239
240 REG_PTI_OFFSET = REG_GTH_OFFSET,
241 REG_PTI_LENGTH = REG_GTH_LENGTH,
242
243
244 REG_DCIH_OFFSET = REG_MSU_OFFSET,
245 REG_DCIH_LENGTH = REG_MSU_LENGTH,
246};
247
248
249
250
251enum {
252 GTH_NONE = 0,
253 GTH_MSU,
254 GTH_CTP,
255 GTH_PTI = 4,
256};
257
258
259
260
261
262enum {
263
264 SCRPD_MEM_IS_PRIM_DEST = BIT(0),
265
266 SCRPD_DBC_IS_PRIM_DEST = BIT(1),
267
268 SCRPD_PTI_IS_PRIM_DEST = BIT(2),
269
270 SCRPD_BSSB_IS_PRIM_DEST = BIT(3),
271
272 SCRPD_PTI_IS_ALT_DEST = BIT(4),
273
274 SCRPD_BSSB_IS_ALT_DEST = BIT(5),
275
276 SCRPD_DEEPSX_EXIT = BIT(6),
277
278 SCRPD_S4_EXIT = BIT(7),
279
280 SCRPD_S5_EXIT = BIT(8),
281
282 SCRPD_MSC0_IS_ENABLED = BIT(9),
283 SCRPD_MSC1_IS_ENABLED = BIT(10),
284
285 SCRPD_SX_EXIT = BIT(11),
286
287 SCRPD_TRIGGER_IS_ENABLED = BIT(12),
288 SCRPD_ODLA_IS_ENABLED = BIT(13),
289 SCRPD_SOCHAP_IS_ENABLED = BIT(14),
290 SCRPD_STH_IS_ENABLED = BIT(15),
291 SCRPD_DCIH_IS_ENABLED = BIT(16),
292 SCRPD_VER_IS_ENABLED = BIT(17),
293
294 SCRPD_DEBUGGER_IN_USE = BIT(24),
295};
296
297#endif
298