drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / drivers / platform / x86 / intel / pmt / telemetry.h
blobd45af5512b4e2dd8de7f35a0b02f84482b39efdf
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TELEMETRY_H
3 #define _TELEMETRY_H
5 /* Telemetry types */
6 #define PMT_TELEM_TELEMETRY 0
7 #define PMT_TELEM_CRASHLOG 1
9 struct telem_endpoint;
10 struct pci_dev;
12 struct telem_header {
13 u8 access_type;
14 u16 size;
15 u32 guid;
16 u32 base_offset;
19 struct telem_endpoint_info {
20 struct pci_dev *pdev;
21 struct telem_header header;
24 /**
25 * pmt_telem_get_next_endpoint() - Get next device id for a telemetry endpoint
26 * @start: starting devid to look from
28 * This functions can be used in a while loop predicate to retrieve the devid
29 * of all available telemetry endpoints. Functions pmt_telem_get_next_endpoint()
30 * and pmt_telem_register_endpoint() can be used inside of the loop to examine
31 * endpoint info and register to receive a pointer to the endpoint. The pointer
32 * is then usable in the telemetry read calls to access the telemetry data.
34 * Return:
35 * * devid - devid of the next present endpoint from start
36 * * 0 - when no more endpoints are present after start
38 unsigned long pmt_telem_get_next_endpoint(unsigned long start);
40 /**
41 * pmt_telem_register_endpoint() - Register a telemetry endpoint
42 * @devid: device id/handle of the telemetry endpoint
44 * Increments the kref usage counter for the endpoint.
46 * Return:
47 * * endpoint - On success returns pointer to the telemetry endpoint
48 * * -ENXIO - telemetry endpoint not found
50 struct telem_endpoint *pmt_telem_register_endpoint(int devid);
52 /**
53 * pmt_telem_unregister_endpoint() - Unregister a telemetry endpoint
54 * @ep: ep structure to populate.
56 * Decrements the kref usage counter for the endpoint.
58 void pmt_telem_unregister_endpoint(struct telem_endpoint *ep);
60 /**
61 * pmt_telem_get_endpoint_info() - Get info for an endpoint from its devid
62 * @devid: device id/handle of the telemetry endpoint
63 * @info: Endpoint info structure to be populated
65 * Return:
66 * * 0 - Success
67 * * -ENXIO - telemetry endpoint not found for the devid
68 * * -EINVAL - @info is NULL
70 int pmt_telem_get_endpoint_info(int devid, struct telem_endpoint_info *info);
72 /**
73 * pmt_telem_find_and_register_endpoint() - Get a telemetry endpoint from
74 * pci_dev device, guid and pos
75 * @pdev: PCI device inside the Intel vsec
76 * @guid: GUID of the telemetry space
77 * @pos: Instance of the guid
79 * Return:
80 * * endpoint - On success returns pointer to the telemetry endpoint
81 * * -ENXIO - telemetry endpoint not found
83 struct telem_endpoint *pmt_telem_find_and_register_endpoint(struct pci_dev *pcidev,
84 u32 guid, u16 pos);
86 /**
87 * pmt_telem_read() - Read qwords from counter sram using sample id
88 * @ep: Telemetry endpoint to be read
89 * @id: The beginning sample id of the metric(s) to be read
90 * @data: Allocated qword buffer
91 * @count: Number of qwords requested
93 * Callers must ensure reads are aligned. When the call returns -ENODEV,
94 * the device has been removed and callers should unregister the telemetry
95 * endpoint.
97 * Return:
98 * * 0 - Success
99 * * -ENODEV - The device is not present.
100 * * -EINVAL - The offset is out bounds
101 * * -EPIPE - The device was removed during the read. Data written
102 * but should be considered invalid.
104 int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count);
107 * pmt_telem_read32() - Read qwords from counter sram using sample id
108 * @ep: Telemetry endpoint to be read
109 * @id: The beginning sample id of the metric(s) to be read
110 * @data: Allocated dword buffer
111 * @count: Number of dwords requested
113 * Callers must ensure reads are aligned. When the call returns -ENODEV,
114 * the device has been removed and callers should unregister the telemetry
115 * endpoint.
117 * Return:
118 * * 0 - Success
119 * * -ENODEV - The device is not present.
120 * * -EINVAL - The offset is out bounds
121 * * -EPIPE - The device was removed during the read. Data written
122 * but should be considered invalid.
124 int pmt_telem_read32(struct telem_endpoint *ep, u32 id, u32 *data, u32 count);
126 #endif