0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __INTEL_TH_H__
0009 #define __INTEL_TH_H__
0010
0011 #include <linux/irqreturn.h>
0012
0013
0014 enum {
0015
0016 INTEL_TH_SOURCE = 0,
0017
0018 INTEL_TH_OUTPUT,
0019
0020 INTEL_TH_SWITCH,
0021 };
0022
0023 struct intel_th_device;
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 struct intel_th_output {
0040 int port;
0041 unsigned int type;
0042 unsigned int scratchpad;
0043 bool multiblock;
0044 bool active;
0045 };
0046
0047
0048
0049
0050
0051
0052
0053
0054 struct intel_th_drvdata {
0055 unsigned int tscu_enable : 1,
0056 multi_is_broken : 1,
0057 has_mintctl : 1,
0058 host_mode_only : 1;
0059 };
0060
0061 #define INTEL_TH_CAP(_th, _cap) ((_th)->drvdata ? (_th)->drvdata->_cap : 0)
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 struct intel_th_device {
0076 struct device dev;
0077 const struct intel_th_drvdata *drvdata;
0078 struct resource *resource;
0079 unsigned int num_resources;
0080 unsigned int type;
0081 int id;
0082
0083
0084 bool host_mode;
0085
0086
0087 struct intel_th_output output;
0088
0089 char name[];
0090 };
0091
0092 #define to_intel_th_device(_d) \
0093 container_of((_d), struct intel_th_device, dev)
0094
0095
0096
0097
0098
0099
0100
0101 static inline struct resource *
0102 intel_th_device_get_resource(struct intel_th_device *thdev, unsigned int type,
0103 unsigned int num)
0104 {
0105 int i;
0106
0107 for (i = 0; i < thdev->num_resources; i++)
0108 if (resource_type(&thdev->resource[i]) == type && !num--)
0109 return &thdev->resource[i];
0110
0111 return NULL;
0112 }
0113
0114
0115
0116
0117 enum {
0118 GTH_NONE = 0,
0119 GTH_MSU,
0120 GTH_CTP,
0121 GTH_LPP,
0122 GTH_PTI,
0123 };
0124
0125
0126
0127
0128
0129
0130
0131 static inline bool
0132 intel_th_output_assigned(struct intel_th_device *thdev)
0133 {
0134 return thdev->type == INTEL_TH_OUTPUT &&
0135 (thdev->output.port >= 0 ||
0136 thdev->output.type == GTH_NONE);
0137 }
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159 struct intel_th_driver {
0160 struct device_driver driver;
0161 int (*probe)(struct intel_th_device *thdev);
0162 void (*remove)(struct intel_th_device *thdev);
0163
0164 int (*assign)(struct intel_th_device *thdev,
0165 struct intel_th_device *othdev);
0166 void (*unassign)(struct intel_th_device *thdev,
0167 struct intel_th_device *othdev);
0168 void (*prepare)(struct intel_th_device *thdev,
0169 struct intel_th_output *output);
0170 void (*enable)(struct intel_th_device *thdev,
0171 struct intel_th_output *output);
0172 void (*trig_switch)(struct intel_th_device *thdev,
0173 struct intel_th_output *output);
0174 void (*disable)(struct intel_th_device *thdev,
0175 struct intel_th_output *output);
0176
0177 irqreturn_t (*irq)(struct intel_th_device *thdev);
0178 void (*wait_empty)(struct intel_th_device *thdev);
0179 int (*activate)(struct intel_th_device *thdev);
0180 void (*deactivate)(struct intel_th_device *thdev);
0181
0182 const struct file_operations *fops;
0183
0184 const struct attribute_group *attr_group;
0185
0186
0187 int (*set_output)(struct intel_th_device *thdev,
0188 unsigned int master);
0189 };
0190
0191 #define to_intel_th_driver(_d) \
0192 container_of((_d), struct intel_th_driver, driver)
0193
0194 #define to_intel_th_driver_or_null(_d) \
0195 ((_d) ? to_intel_th_driver(_d) : NULL)
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207 static inline struct intel_th_device *
0208 to_intel_th_parent(struct intel_th_device *thdev)
0209 {
0210 struct device *parent = thdev->dev.parent;
0211
0212 if (!parent)
0213 return NULL;
0214
0215 return to_intel_th_device(parent);
0216 }
0217
0218 static inline struct intel_th *to_intel_th(struct intel_th_device *thdev)
0219 {
0220 if (thdev->type == INTEL_TH_OUTPUT)
0221 thdev = to_intel_th_parent(thdev);
0222
0223 if (WARN_ON_ONCE(!thdev || thdev->type == INTEL_TH_OUTPUT))
0224 return NULL;
0225
0226 return dev_get_drvdata(thdev->dev.parent);
0227 }
0228
0229 struct intel_th *
0230 intel_th_alloc(struct device *dev, const struct intel_th_drvdata *drvdata,
0231 struct resource *devres, unsigned int ndevres);
0232 void intel_th_free(struct intel_th *th);
0233
0234 int intel_th_driver_register(struct intel_th_driver *thdrv);
0235 void intel_th_driver_unregister(struct intel_th_driver *thdrv);
0236
0237 int intel_th_trace_enable(struct intel_th_device *thdev);
0238 int intel_th_trace_switch(struct intel_th_device *thdev);
0239 int intel_th_trace_disable(struct intel_th_device *thdev);
0240 int intel_th_set_output(struct intel_th_device *thdev,
0241 unsigned int master);
0242 int intel_th_output_enable(struct intel_th *th, unsigned int otype);
0243
0244 enum th_mmio_idx {
0245 TH_MMIO_CONFIG = 0,
0246 TH_MMIO_SW = 1,
0247 TH_MMIO_RTIT = 2,
0248 TH_MMIO_END,
0249 };
0250
0251 #define TH_POSSIBLE_OUTPUTS 8
0252
0253 #define TH_SUBDEVICE_MAX (TH_POSSIBLE_OUTPUTS + 2)
0254 #define TH_CONFIGURABLE_MASTERS 256
0255 #define TH_MSC_MAX 2
0256
0257
0258 #define TH_NVEC_MAX 8
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273 struct intel_th {
0274 struct device *dev;
0275
0276 struct intel_th_device *thdev[TH_SUBDEVICE_MAX];
0277 struct intel_th_device *hub;
0278 const struct intel_th_drvdata *drvdata;
0279
0280 struct resource resource[TH_MMIO_END];
0281 int (*activate)(struct intel_th *);
0282 void (*deactivate)(struct intel_th *);
0283 unsigned int num_thdevs;
0284 unsigned int num_resources;
0285 int irq;
0286 int num_irqs;
0287
0288 int id;
0289 int major;
0290 #ifdef CONFIG_MODULES
0291 struct work_struct request_module_work;
0292 #endif
0293 #ifdef CONFIG_INTEL_TH_DEBUG
0294 struct dentry *dbg;
0295 #endif
0296 };
0297
0298 static inline struct intel_th_device *
0299 to_intel_th_hub(struct intel_th_device *thdev)
0300 {
0301 if (thdev->type == INTEL_TH_SWITCH)
0302 return thdev;
0303 else if (thdev->type == INTEL_TH_OUTPUT)
0304 return to_intel_th_parent(thdev);
0305
0306 return to_intel_th(thdev)->hub;
0307 }
0308
0309
0310
0311
0312 enum {
0313
0314 REG_GTH_OFFSET = 0x0000,
0315 REG_GTH_LENGTH = 0x2000,
0316
0317
0318 REG_TSCU_OFFSET = 0x2000,
0319 REG_TSCU_LENGTH = 0x1000,
0320
0321 REG_CTS_OFFSET = 0x3000,
0322 REG_CTS_LENGTH = 0x1000,
0323
0324
0325 REG_STH_OFFSET = 0x4000,
0326 REG_STH_LENGTH = 0x2000,
0327
0328
0329 REG_MSU_OFFSET = 0xa0000,
0330 REG_MSU_LENGTH = 0x02000,
0331
0332
0333 BUF_MSU_OFFSET = 0x80000,
0334 BUF_MSU_LENGTH = 0x20000,
0335
0336
0337 REG_PTI_OFFSET = REG_GTH_OFFSET,
0338 REG_PTI_LENGTH = REG_GTH_LENGTH,
0339
0340
0341 REG_DCIH_OFFSET = REG_MSU_OFFSET,
0342 REG_DCIH_LENGTH = REG_MSU_LENGTH,
0343 };
0344
0345
0346
0347
0348
0349 enum {
0350
0351 SCRPD_MEM_IS_PRIM_DEST = BIT(0),
0352
0353 SCRPD_DBC_IS_PRIM_DEST = BIT(1),
0354
0355 SCRPD_PTI_IS_PRIM_DEST = BIT(2),
0356
0357 SCRPD_BSSB_IS_PRIM_DEST = BIT(3),
0358
0359 SCRPD_PTI_IS_ALT_DEST = BIT(4),
0360
0361 SCRPD_BSSB_IS_ALT_DEST = BIT(5),
0362
0363 SCRPD_DEEPSX_EXIT = BIT(6),
0364
0365 SCRPD_S4_EXIT = BIT(7),
0366
0367 SCRPD_S5_EXIT = BIT(8),
0368
0369 SCRPD_MSC0_IS_ENABLED = BIT(9),
0370 SCRPD_MSC1_IS_ENABLED = BIT(10),
0371
0372 SCRPD_SX_EXIT = BIT(11),
0373
0374 SCRPD_TRIGGER_IS_ENABLED = BIT(12),
0375 SCRPD_ODLA_IS_ENABLED = BIT(13),
0376 SCRPD_SOCHAP_IS_ENABLED = BIT(14),
0377 SCRPD_STH_IS_ENABLED = BIT(15),
0378 SCRPD_DCIH_IS_ENABLED = BIT(16),
0379 SCRPD_VER_IS_ENABLED = BIT(17),
0380
0381 SCRPD_DEBUGGER_IN_USE = BIT(24),
0382 };
0383
0384 #endif