1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/auxiliary_bus.h>
6 #include <linux/bits.h>
8 #define VSEC_CAP_TELEMETRY BIT(0)
9 #define VSEC_CAP_WATCHER BIT(1)
10 #define VSEC_CAP_CRASHLOG BIT(2)
11 #define VSEC_CAP_SDSI BIT(3)
12 #define VSEC_CAP_TPMI BIT(4)
14 /* Intel DVSEC offsets */
15 #define INTEL_DVSEC_ENTRIES 0xA
16 #define INTEL_DVSEC_SIZE 0xB
17 #define INTEL_DVSEC_TABLE 0xC
18 #define INTEL_DVSEC_TABLE_BAR(x) ((x) & GENMASK(2, 0))
19 #define INTEL_DVSEC_TABLE_OFFSET(x) ((x) & GENMASK(31, 3))
20 #define TABLE_OFFSET_SHIFT 3
26 VSEC_ID_TELEMETRY
= 2,
34 * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers.
35 * @rev: Revision ID of the VSEC/DVSEC register space
36 * @length: Length of the VSEC/DVSEC register space
37 * @id: ID of the feature
38 * @num_entries: Number of instances of the feature
39 * @entry_size: Size of the discovery table for each feature
40 * @tbir: BAR containing the discovery tables
41 * @offset: BAR offset of start of the first discovery table
43 struct intel_vsec_header
{
53 enum intel_vsec_quirks
{
54 /* Watcher feature not supported */
55 VSEC_QUIRK_NO_WATCHER
= BIT(0),
57 /* Crashlog feature not supported */
58 VSEC_QUIRK_NO_CRASHLOG
= BIT(1),
60 /* Use shift instead of mask to read discovery table offset */
61 VSEC_QUIRK_TABLE_SHIFT
= BIT(2),
63 /* DVSEC not present (provided in driver data) */
64 VSEC_QUIRK_NO_DVSEC
= BIT(3),
66 /* Platforms requiring quirk in the auxiliary driver */
67 VSEC_QUIRK_EARLY_HW
= BIT(4),
71 * struct pmt_callbacks - Callback infrastructure for PMT devices
72 * ->read_telem() when specified, called by client driver to access PMT data (instead
74 * @pdev: PCI device reference for the callback's use
75 * @guid: ID of data to acccss
76 * @data: buffer for the data to be copied
77 * @off: offset into the requested buffer
78 * @count: size of buffer
80 struct pmt_callbacks
{
81 int (*read_telem
)(struct pci_dev
*pdev
, u32 guid
, u64
*data
, loff_t off
, u32 count
);
85 * struct intel_vsec_platform_info - Platform specific data
86 * @parent: parent device in the auxbus chain
87 * @headers: list of headers to define the PMT client devices to create
88 * @priv_data: private data, usable by parent devices, currently a callback
89 * @caps: bitmask of PMT capabilities for the given headers
90 * @quirks: bitmask of VSEC device quirks
91 * @base_addr: allow a base address to be specified (rather than derived)
93 struct intel_vsec_platform_info
{
94 struct device
*parent
;
95 struct intel_vsec_header
**headers
;
103 * struct intel_sec_device - Auxbus specific device information
104 * @auxdev: auxbus device struct for auxbus access
105 * @pcidev: pci device associated with the device
106 * @resource: any resources shared by the parent
108 * @num_resources: number of resources
110 * @priv_data: any private data needed
111 * @quirks: specified quirks
112 * @base_addr: base address of entries (if specified)
114 struct intel_vsec_device
{
115 struct auxiliary_device auxdev
;
116 struct pci_dev
*pcidev
;
117 struct resource
*resource
;
122 size_t priv_data_size
;
123 unsigned long quirks
;
127 int intel_vsec_add_aux(struct pci_dev
*pdev
, struct device
*parent
,
128 struct intel_vsec_device
*intel_vsec_dev
,
131 static inline struct intel_vsec_device
*dev_to_ivdev(struct device
*dev
)
133 return container_of(dev
, struct intel_vsec_device
, auxdev
.dev
);
136 static inline struct intel_vsec_device
*auxdev_to_ivdev(struct auxiliary_device
*auxdev
)
138 return container_of(auxdev
, struct intel_vsec_device
, auxdev
);
141 #if IS_ENABLED(CONFIG_INTEL_VSEC)
142 void intel_vsec_register(struct pci_dev
*pdev
,
143 struct intel_vsec_platform_info
*info
);
145 static inline void intel_vsec_register(struct pci_dev
*pdev
,
146 struct intel_vsec_platform_info
*info
)