xref: /linux/drivers/platform/x86/intel/pmt/class.h (revision 45d8b572fac3aa8b49d53c946b3685eaf78a2824)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _INTEL_PMT_CLASS_H
3 #define _INTEL_PMT_CLASS_H
4 
5 #include <linux/xarray.h>
6 #include <linux/types.h>
7 #include <linux/bits.h>
8 #include <linux/err.h>
9 #include <linux/io.h>
10 
11 #include "../vsec.h"
12 #include "telemetry.h"
13 
14 /* PMT access types */
15 #define ACCESS_BARID		2
16 #define ACCESS_LOCAL		3
17 
18 /* PMT discovery base address/offset register layout */
19 #define GET_BIR(v)		((v) & GENMASK(2, 0))
20 #define GET_ADDRESS(v)		((v) & GENMASK(31, 3))
21 
22 struct pci_dev;
23 
24 struct telem_endpoint {
25 	struct pci_dev		*pcidev;
26 	struct telem_header	header;
27 	void __iomem		*base;
28 	bool			present;
29 	struct kref		kref;
30 };
31 
32 struct intel_pmt_header {
33 	u32	base_offset;
34 	u32	size;
35 	u32	guid;
36 	u8	access_type;
37 };
38 
39 struct intel_pmt_entry {
40 	struct telem_endpoint	*ep;
41 	struct intel_pmt_header	header;
42 	struct bin_attribute	pmt_bin_attr;
43 	struct kobject		*kobj;
44 	void __iomem		*disc_table;
45 	void __iomem		*base;
46 	unsigned long		base_addr;
47 	size_t			size;
48 	u32			guid;
49 	int			devid;
50 };
51 
52 struct intel_pmt_namespace {
53 	const char *name;
54 	struct xarray *xa;
55 	const struct attribute_group *attr_grp;
56 	int (*pmt_header_decode)(struct intel_pmt_entry *entry,
57 				 struct device *dev);
58 	int (*pmt_add_endpoint)(struct intel_pmt_entry *entry,
59 				struct pci_dev *pdev);
60 };
61 
62 bool intel_pmt_is_early_client_hw(struct device *dev);
63 int intel_pmt_dev_create(struct intel_pmt_entry *entry,
64 			 struct intel_pmt_namespace *ns,
65 			 struct intel_vsec_device *dev, int idx);
66 void intel_pmt_dev_destroy(struct intel_pmt_entry *entry,
67 			   struct intel_pmt_namespace *ns);
68 #endif
69