1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _INTEL_PMT_CLASS_H
3 #define _INTEL_PMT_CLASS_H
4 
5 #include <linux/platform_device.h>
6 #include <linux/xarray.h>
7 #include <linux/types.h>
8 #include <linux/bits.h>
9 #include <linux/err.h>
10 #include <linux/io.h>
11 
12 /* PMT access types */
13 #define ACCESS_BARID		2
14 #define ACCESS_LOCAL		3
15 
16 /* PMT discovery base address/offset register layout */
17 #define GET_BIR(v)		((v) & GENMASK(2, 0))
18 #define GET_ADDRESS(v)		((v) & GENMASK(31, 3))
19 
20 struct intel_pmt_entry {
21 	struct bin_attribute	pmt_bin_attr;
22 	struct kobject		*kobj;
23 	void __iomem		*disc_table;
24 	void __iomem		*base;
25 	unsigned long		base_addr;
26 	size_t			size;
27 	u32			guid;
28 	int			devid;
29 };
30 
31 struct intel_pmt_header {
32 	u32	base_offset;
33 	u32	size;
34 	u32	guid;
35 	u8	access_type;
36 };
37 
38 struct intel_pmt_namespace {
39 	const char *name;
40 	struct xarray *xa;
41 	const struct attribute_group *attr_grp;
42 	int (*pmt_header_decode)(struct intel_pmt_entry *entry,
43 				 struct intel_pmt_header *header,
44 				 struct device *dev);
45 };
46 
47 bool intel_pmt_is_early_client_hw(struct device *dev);
48 int intel_pmt_dev_create(struct intel_pmt_entry *entry,
49 			 struct intel_pmt_namespace *ns,
50 			 struct platform_device *pdev, int idx);
51 void intel_pmt_dev_destroy(struct intel_pmt_entry *entry,
52 			   struct intel_pmt_namespace *ns);
53 #endif
54