blob: 42a997962ea2c720bd4443218054d71253bc54dd [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001/* SPDX-License-Identifier: GPL-2.0 */
Jae Hyun Yoob9122032019-12-23 15:34:59 -08002/* Copyright (c) 2018-2019 Intel Corporation */
James Feist6714a252018-09-10 15:26:18 -07003
James Feist582be092018-11-27 10:54:59 -08004// clang-format off
5
James Feist6714a252018-09-10 15:26:18 -07006#ifndef __PECI_IOCTL_H
7#define __PECI_IOCTL_H
8
Ed Tanousec77caa2023-02-17 10:46:06 -08009#ifdef __cplusplus
10extern "C" {
11#endif
12
James Feist6714a252018-09-10 15:26:18 -070013#include <linux/ioctl.h>
14#include <linux/types.h>
15
Jae Hyun Yoob9122032019-12-23 15:34:59 -080016/* The PECI client's default address of 0x30 */
17#define PECI_BASE_ADDR 0x30
James Feist6714a252018-09-10 15:26:18 -070018
Jae Hyun Yoob9122032019-12-23 15:34:59 -080019/* Max number of CPU clients */
20#define PECI_OFFSET_MAX 8
James Feist6714a252018-09-10 15:26:18 -070021
Jae Hyun Yoob9122032019-12-23 15:34:59 -080022/* PECI read/write data buffer size max */
23#define PECI_BUFFER_SIZE 255
James Feist6714a252018-09-10 15:26:18 -070024
Jae Hyun Yoob9122032019-12-23 15:34:59 -080025/* Device Specific Completion Code (CC) Definition */
26#define PECI_DEV_CC_SUCCESS 0x40
27#define PECI_DEV_CC_NEED_RETRY 0x80
28#define PECI_DEV_CC_OUT_OF_RESOURCE 0x81
29#define PECI_DEV_CC_UNAVAIL_RESOURCE 0x82
30#define PECI_DEV_CC_INVALID_REQ 0x90
31#define PECI_DEV_CC_MCA_ERROR 0x91
32#define PECI_DEV_CC_CATASTROPHIC_MCA_ERROR 0x93
33#define PECI_DEV_CC_FATAL_MCA_DETECTED 0x94
34#define PECI_DEV_CC_PARITY_ERROR_ON_GPSB_OR_PMSB 0x98
35#define PECI_DEV_CC_PARITY_ERROR_ON_GPSB_OR_PMSB_IERR 0x9B
36#define PECI_DEV_CC_PARITY_ERROR_ON_GPSB_OR_PMSB_MCA 0x9C
James Feist6714a252018-09-10 15:26:18 -070037
Jae Hyun Yoob9122032019-12-23 15:34:59 -080038/* Completion Code mask to check retry needs */
39#define PECI_DEV_CC_RETRY_CHECK_MASK 0xf0
James Feist6714a252018-09-10 15:26:18 -070040
Jae Hyun Yoob9122032019-12-23 15:34:59 -080041#define PECI_DEV_RETRY_TIMEOUT msecs_to_jiffies(700)
42#define PECI_DEV_RETRY_INTERVAL_MIN_MSEC 1
43#define PECI_DEV_RETRY_INTERVAL_MAX_MSEC 128
44#define PECI_DEV_RETRY_BIT 0x01
James Feist6714a252018-09-10 15:26:18 -070045
Jae Hyun Yoob9122032019-12-23 15:34:59 -080046/**
47 * enum peci_cmd - PECI client commands
48 * @PECI_CMD_XFER: raw PECI transfer
49 * @PECI_CMD_PING: ping, a required message for all PECI devices
50 * @PECI_CMD_GET_DIB: get DIB (Device Info Byte)
51 * @PECI_CMD_GET_TEMP: get maximum die temperature
52 * @PECI_CMD_RD_PKG_CFG: read access to the PCS (Package Configuration Space)
53 * @PECI_CMD_WR_PKG_CFG: write access to the PCS (Package Configuration Space)
54 * @PECI_CMD_RD_IA_MSR: read access to MSRs (Model Specific Registers)
55 * @PECI_CMD_WR_IA_MSR: write access to MSRs (Model Specific Registers)
56 * @PECI_CMD_RD_IA_MSREX: read access to MSRs (Model Specific Registers)
57 * @PECI_CMD_RD_PCI_CFG: sideband read access to the PCI configuration space
58 * maintained in downstream devices external to the processor
59 * @PECI_CMD_WR_PCI_CFG: sideband write access to the PCI configuration space
60 * maintained in downstream devices external to the processor
61 * @PECI_CMD_RD_PCI_CFG_LOCAL: sideband read access to the PCI configuration
62 * space that resides within the processor
63 * @PECI_CMD_WR_PCI_CFG_LOCAL: sideband write access to the PCI configuration
64 * space that resides within the processor
65 *
66 * Available commands depend on client's PECI revision.
67 */
James Feist6714a252018-09-10 15:26:18 -070068enum peci_cmd {
69 PECI_CMD_XFER = 0,
70 PECI_CMD_PING,
71 PECI_CMD_GET_DIB,
72 PECI_CMD_GET_TEMP,
73 PECI_CMD_RD_PKG_CFG,
74 PECI_CMD_WR_PKG_CFG,
75 PECI_CMD_RD_IA_MSR,
76 PECI_CMD_WR_IA_MSR,
Jae Hyun Yoob9122032019-12-23 15:34:59 -080077 PECI_CMD_RD_IA_MSREX,
James Feist6714a252018-09-10 15:26:18 -070078 PECI_CMD_RD_PCI_CFG,
79 PECI_CMD_WR_PCI_CFG,
80 PECI_CMD_RD_PCI_CFG_LOCAL,
81 PECI_CMD_WR_PCI_CFG_LOCAL,
Jae Hyun Yoob9122032019-12-23 15:34:59 -080082 PECI_CMD_RD_END_PT_CFG,
83 PECI_CMD_WR_END_PT_CFG,
James Feist6714a252018-09-10 15:26:18 -070084 PECI_CMD_CRASHDUMP_DISC,
85 PECI_CMD_CRASHDUMP_GET_FRAME,
86 PECI_CMD_MAX
87};
88
Jae Hyun Yoob9122032019-12-23 15:34:59 -080089/**
90 * struct peci_xfer_msg - raw PECI transfer command
91 * @addr; address of the client
92 * @tx_len: number of data to be written in bytes
93 * @rx_len: number of data to be read in bytes
94 * @tx_buf: data to be written, or NULL
95 * @rx_buf: data to be read, or NULL
96 *
97 * raw PECI transfer
98 */
99struct peci_xfer_msg {
100 __u8 addr;
101 __u8 tx_len;
102 __u8 rx_len;
103 __u8 padding;
104 __u8 *tx_buf;
105 __u8 *rx_buf;
106} __attribute__((__packed__));
107
108/**
109 * struct peci_ping_msg - ping command
110 * @addr: address of the client
111 *
112 * Ping() is a required message for all PECI devices. This message is used to
113 * enumerate devices or determine if a device has been removed, been
114 * powered-off, etc.
115 */
James Feist6714a252018-09-10 15:26:18 -0700116struct peci_ping_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800117 __u8 addr;
118 __u8 padding[3];
James Feist6714a252018-09-10 15:26:18 -0700119} __attribute__((__packed__));
120
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800121/**
122 * struct peci_get_dib_msg - GetDIB command
123 * @addr: address of the client
124 * @dib: DIB data to be read
125 *
126 * The processor PECI client implementation of GetDIB() includes an 8-byte
127 * response and provides information regarding client revision number and the
128 * number of supported domains. All processor PECI clients support the GetDIB()
129 * command.
130 */
James Feist6714a252018-09-10 15:26:18 -0700131struct peci_get_dib_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800132#define PECI_GET_DIB_WR_LEN 1
133#define PECI_GET_DIB_RD_LEN 8
134#define PECI_GET_DIB_CMD 0xf7
135
136 __u8 addr;
137 __u8 padding[3];
138 __u64 dib;
James Feist6714a252018-09-10 15:26:18 -0700139} __attribute__((__packed__));
140
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800141/**
142 * struct peci_get_temp_msg - GetTemp command
143 * @addr: address of the client
144 * @temp_raw: raw temperature data to be read
145 *
146 * The GetTemp() command is used to retrieve the maximum die temperature from a
147 * target PECI address. The temperature is used by the external thermal
148 * management system to regulate the temperature on the die. The data is
149 * returned as a negative value representing the number of degrees centigrade
150 * below the maximum processor junction temperature.
151 */
James Feist6714a252018-09-10 15:26:18 -0700152struct peci_get_temp_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800153#define PECI_GET_TEMP_WR_LEN 1
154#define PECI_GET_TEMP_RD_LEN 2
155#define PECI_GET_TEMP_CMD 0x01
156
157 __u8 addr;
158 __u8 padding;
159 __s16 temp_raw;
James Feist6714a252018-09-10 15:26:18 -0700160} __attribute__((__packed__));
161
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800162/**
163 * struct peci_rd_pkg_cfg_msg - RdPkgConfig command
164 * @addr: address of the client
165 * @index: encoding index for the requested service
166 * @param: specific data being requested
167 * @rx_len: number of data to be read in bytes
168 * @cc: completion code
169 * @pkg_config: package config data to be read
170 *
171 * The RdPkgConfig() command provides read access to the Package Configuration
172 * Space (PCS) within the processor, including various power and thermal
173 * management functions. Typical PCS read services supported by the processor
174 * may include access to temperature data, energy status, run time information,
175 * DIMM temperatures and so on.
176 */
James Feist6714a252018-09-10 15:26:18 -0700177struct peci_rd_pkg_cfg_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800178#define PECI_RDPKGCFG_WRITE_LEN 5
179#define PECI_RDPKGCFG_READ_LEN_BASE 1
180#define PECI_RDPKGCFG_CMD 0xa1
181
182 __u8 addr;
183 __u8 index;
184#define PECI_MBX_INDEX_CPU_ID 0 /* Package Identifier Read */
185#define PECI_MBX_INDEX_VR_DEBUG 1 /* VR Debug */
186#define PECI_MBX_INDEX_PKG_TEMP_READ 2 /* Package Temperature Read */
187#define PECI_MBX_INDEX_ENERGY_COUNTER 3 /* Energy counter */
188#define PECI_MBX_INDEX_ENERGY_STATUS 4 /* DDR Energy Status */
189#define PECI_MBX_INDEX_WAKE_MODE_BIT 5 /* "Wake on PECI" Mode bit */
190#define PECI_MBX_INDEX_EPI 6 /* Efficient Performance Indication */
191#define PECI_MBX_INDEX_PKG_RAPL_PERF 8 /* Pkg RAPL Performance Status Read */
192#define PECI_MBX_INDEX_PER_CORE_DTS_TEMP 9 /* Per Core DTS Temperature Read */
193#define PECI_MBX_INDEX_DTS_MARGIN 10 /* DTS thermal margin */
194#define PECI_MBX_INDEX_SKT_PWR_THRTL_DUR 11 /* Socket Power Throttled Duration */
195#define PECI_MBX_INDEX_CFG_TDP_CONTROL 12 /* TDP Config Control */
196#define PECI_MBX_INDEX_CFG_TDP_LEVELS 13 /* TDP Config Levels */
197#define PECI_MBX_INDEX_DDR_DIMM_TEMP 14 /* DDR DIMM Temperature */
198#define PECI_MBX_INDEX_CFG_ICCMAX 15 /* Configurable ICCMAX */
199#define PECI_MBX_INDEX_TEMP_TARGET 16 /* Temperature Target Read */
200#define PECI_MBX_INDEX_CURR_CFG_LIMIT 17 /* Current Config Limit */
201#define PECI_MBX_INDEX_DIMM_TEMP_READ 20 /* Package Thermal Status Read */
202#define PECI_MBX_INDEX_DRAM_IMC_TMP_READ 22 /* DRAM IMC Temperature Read */
203#define PECI_MBX_INDEX_DDR_CH_THERM_STAT 23 /* DDR Channel Thermal Status */
204#define PECI_MBX_INDEX_PKG_POWER_LIMIT1 26 /* Package Power Limit1 */
205#define PECI_MBX_INDEX_PKG_POWER_LIMIT2 27 /* Package Power Limit2 */
206#define PECI_MBX_INDEX_TDP 28 /* Thermal design power minimum */
207#define PECI_MBX_INDEX_TDP_HIGH 29 /* Thermal design power maximum */
208#define PECI_MBX_INDEX_TDP_UNITS 30 /* Units for power/energy registers */
209#define PECI_MBX_INDEX_RUN_TIME 31 /* Accumulated Run Time */
210#define PECI_MBX_INDEX_CONSTRAINED_TIME 32 /* Thermally Constrained Time Read */
211#define PECI_MBX_INDEX_TURBO_RATIO 33 /* Turbo Activation Ratio */
212#define PECI_MBX_INDEX_DDR_RAPL_PL1 34 /* DDR RAPL PL1 */
213#define PECI_MBX_INDEX_DDR_PWR_INFO_HIGH 35 /* DRAM Power Info Read (high) */
214#define PECI_MBX_INDEX_DDR_PWR_INFO_LOW 36 /* DRAM Power Info Read (low) */
215#define PECI_MBX_INDEX_DDR_RAPL_PL2 37 /* DDR RAPL PL2 */
216#define PECI_MBX_INDEX_DDR_RAPL_STATUS 38 /* DDR RAPL Performance Status */
217#define PECI_MBX_INDEX_DDR_HOT_ABSOLUTE 43 /* DDR Hottest Dimm Absolute Temp */
218#define PECI_MBX_INDEX_DDR_HOT_RELATIVE 44 /* DDR Hottest Dimm Relative Temp */
219#define PECI_MBX_INDEX_DDR_THROTTLE_TIME 45 /* DDR Throttle Time */
220#define PECI_MBX_INDEX_DDR_THERM_STATUS 46 /* DDR Thermal Status */
221#define PECI_MBX_INDEX_TIME_AVG_TEMP 47 /* Package time-averaged temperature */
222#define PECI_MBX_INDEX_TURBO_RATIO_LIMIT 49 /* Turbo Ratio Limit Read */
223#define PECI_MBX_INDEX_HWP_AUTO_OOB 53 /* HWP Autonomous Out-of-band */
224#define PECI_MBX_INDEX_DDR_WARM_BUDGET 55 /* DDR Warm Power Budget */
225#define PECI_MBX_INDEX_DDR_HOT_BUDGET 56 /* DDR Hot Power Budget */
226#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM3 57 /* Package/Psys Power Limit3 */
227#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM1 58 /* Package/Psys Power Limit1 */
228#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM2 59 /* Package/Psys Power Limit2 */
229#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM4 60 /* Package/Psys Power Limit4 */
230#define PECI_MBX_INDEX_PERF_LIMIT_REASON 65 /* Performance Limit Reasons */
231
232 __u16 param;
233/* When index is PECI_MBX_INDEX_CPU_ID */
234#define PECI_PKG_ID_CPU_ID 0x0000 /* CPUID Info */
235#define PECI_PKG_ID_PLATFORM_ID 0x0001 /* Platform ID */
236#define PECI_PKG_ID_UNCORE_ID 0x0002 /* Uncore Device ID */
237#define PECI_PKG_ID_MAX_THREAD_ID 0x0003 /* Max Thread ID */
238#define PECI_PKG_ID_MICROCODE_REV 0x0004 /* CPU Microcode Update Revision */
239#define PECI_PKG_ID_MACHINE_CHECK_STATUS 0x0005 /* Machine Check Status */
240
241 __u8 rx_len;
242 __u8 cc;
243 __u8 padding[2];
244 __u8 pkg_config[4];
James Feist6714a252018-09-10 15:26:18 -0700245} __attribute__((__packed__));
246
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800247/**
248 * struct peci_wr_pkg_cfg_msg - WrPkgConfig command
249 * @addr: address of the client
250 * @index: encoding index for the requested service
251 * @param: specific data being requested
252 * @tx_len: number of data to be written in bytes
253 * @cc: completion code
254 * @value: package config data to be written
255 *
256 * The WrPkgConfig() command provides write access to the Package Configuration
257 * Space (PCS) within the processor, including various power and thermal
258 * management functions. Typical PCS write services supported by the processor
259 * may include power limiting, thermal averaging constant programming and so
260 * on.
261 */
James Feist6714a252018-09-10 15:26:18 -0700262struct peci_wr_pkg_cfg_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800263#define PECI_WRPKGCFG_WRITE_LEN_BASE 6
264#define PECI_WRPKGCFG_READ_LEN 1
265#define PECI_WRPKGCFG_CMD 0xa5
266
267 __u8 addr;
268 __u8 index;
269#define PECI_MBX_INDEX_DIMM_AMBIENT 19
270#define PECI_MBX_INDEX_DIMM_TEMP 24
271
272 __u16 param;
273 __u8 tx_len;
274 __u8 cc;
275 __u8 padding[2];
276 __u32 value;
James Feist6714a252018-09-10 15:26:18 -0700277} __attribute__((__packed__));
278
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800279/**
280 * struct peci_rd_ia_msr_msg - RdIAMSR command
281 * @addr: address of the client
282 * @thread_id: ID of the specific logical processor
283 * @address: address of MSR to read from
284 * @cc: completion code
285 * @value: data to be read
286 *
287 * The RdIAMSR() PECI command provides read access to Model Specific Registers
288 * (MSRs) defined in the processor's Intel Architecture (IA).
289 */
James Feist6714a252018-09-10 15:26:18 -0700290struct peci_rd_ia_msr_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800291#define PECI_RDIAMSR_WRITE_LEN 5
292#define PECI_RDIAMSR_READ_LEN 9
293#define PECI_RDIAMSR_CMD 0xb1
294
295 __u8 addr;
296 __u8 thread_id;
297 __u16 address;
298 __u8 cc;
299 __u8 padding[3];
300 __u64 value;
James Feist6714a252018-09-10 15:26:18 -0700301} __attribute__((__packed__));
302
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800303/**
304 * struct peci_wr_ia_msr_msg - WrIAMSR command
305 * @addr: address of the client
306 * @thread_id: ID of the specific logical processor
307 * @address: address of MSR to write to
308 * @tx_len: number of data to be written in bytes
309 * @cc: completion code
310 * @value: data to be written
311 *
312 * The WrIAMSR() PECI command provides write access to Model Specific Registers
313 * (MSRs) defined in the processor's Intel Architecture (IA).
314 */
315struct peci_wr_ia_msr_msg {
316#define PECI_WRIAMSR_CMD 0xb5
317
318 __u8 addr;
319 __u8 thread_id;
320 __u16 address;
321 __u8 tx_len;
322 __u8 cc;
323 __u8 padding[2];
324 __u64 value;
325} __attribute__((__packed__));
326
327/**
328 * struct peci_rd_ia_msrex_msg - RdIAMSREX command
329 * @addr: address of the client
330 * @thread_id: ID of the specific logical processor
331 * @address: address of MSR to read from
332 * @cc: completion code
333 * @value: data to be read
334 *
335 * The RdIAMSREX() PECI command provides read access to Model Specific
336 * Registers (MSRs) defined in the processor's Intel Architecture (IA).
337 * The differences between RdIAMSREX() and RdIAMSR() are that:
338 * (1)RdIAMSR() can only read MC registers, RdIAMSREX() can read all MSRs
339 * (2)thread_id of RdIAMSR() is u8, thread_id of RdIAMSREX() is u16
340 */
341struct peci_rd_ia_msrex_msg {
342#define PECI_RDIAMSREX_WRITE_LEN 6
343#define PECI_RDIAMSREX_READ_LEN 9
344#define PECI_RDIAMSREX_CMD 0xd1
345
346 __u8 addr;
347 __u8 padding0;
348 __u16 thread_id;
349 __u16 address;
350 __u8 cc;
351 __u8 padding1;
352 __u64 value;
353} __attribute__((__packed__));
354
355/**
356 * struct peci_rd_pci_cfg_msg - RdPCIConfig command
357 * @addr: address of the client
358 * @bus: PCI bus number
359 * @device: PCI device number
360 * @function: specific function to read from
361 * @reg: specific register to read from
362 * @cc: completion code
363 * @pci_config: config data to be read
364 *
365 * The RdPCIConfig() command provides sideband read access to the PCI
366 * configuration space maintained in downstream devices external to the
367 * processor.
368 */
James Feist6714a252018-09-10 15:26:18 -0700369struct peci_rd_pci_cfg_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800370#define PECI_RDPCICFG_WRITE_LEN 6
371#define PECI_RDPCICFG_READ_LEN 5
372#define PECI_RDPCICFG_READ_LEN_MAX 24
373#define PECI_RDPCICFG_CMD 0x61
374
375 __u8 addr;
376 __u8 bus;
377#define PECI_PCI_BUS0_CPU0 0x00
378#define PECI_PCI_BUS0_CPU1 0x80
379#define PECI_PCI_CPUBUSNO_BUS 0x00
380#define PECI_PCI_CPUBUSNO_DEV 0x08
381#define PECI_PCI_CPUBUSNO_FUNC 0x02
382#define PECI_PCI_CPUBUSNO 0xcc
383#define PECI_PCI_CPUBUSNO_1 0xd0
384#define PECI_PCI_CPUBUSNO_VALID 0xd4
385
386 __u8 device;
387 __u8 function;
388 __u16 reg;
389 __u8 cc;
390 __u8 padding[1];
391 __u8 pci_config[4];
James Feist6714a252018-09-10 15:26:18 -0700392} __attribute__((__packed__));
393
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800394/**
395 * struct peci_wr_pci_cfg_msg - WrPCIConfig command
396 * @addr: address of the client
397 * @bus: PCI bus number
398 * @device: PCI device number
399 * @function: specific function to write to
400 * @reg: specific register to write to
401 * @tx_len: number of data to be written in bytes
402 * @cc: completion code
403 * @pci_config: config data to be written
404 *
405 * The RdPCIConfig() command provides sideband write access to the PCI
406 * configuration space maintained in downstream devices external to the
407 * processor.
408 */
409struct peci_wr_pci_cfg_msg {
410#define PECI_WRPCICFG_CMD 0x65
411
412 __u8 addr;
413 __u8 bus;
414 __u8 device;
415 __u8 function;
416 __u16 reg;
417 __u8 tx_len;
418 __u8 cc;
419 __u8 pci_config[4];
420} __attribute__((__packed__));
421
422/**
423 * struct peci_rd_pci_cfg_local_msg - RdPCIConfigLocal command
424 * @addr: address of the client
425 * @bus: PCI bus number
426 * @device: PCI device number
427 * @function: specific function to read from
428 * @reg: specific register to read from
429 * @rx_len: number of data to be read in bytes
430 * @cc: completion code
431 * @pci_config: config data to be read
432 *
433 * The RdPCIConfigLocal() command provides sideband read access to the PCI
434 * configuration space that resides within the processor. This includes all
435 * processor IIO and uncore registers within the PCI configuration space.
436 */
James Feist6714a252018-09-10 15:26:18 -0700437struct peci_rd_pci_cfg_local_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800438#define PECI_RDPCICFGLOCAL_WRITE_LEN 5
439#define PECI_RDPCICFGLOCAL_READ_LEN_BASE 1
440#define PECI_RDPCICFGLOCAL_CMD 0xe1
441
442 __u8 addr;
443 __u8 bus;
444 __u8 device;
445 __u8 function;
446 __u16 reg;
447 __u8 rx_len;
448 __u8 cc;
449 __u8 pci_config[4];
James Feist6714a252018-09-10 15:26:18 -0700450} __attribute__((__packed__));
451
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800452/**
453 * struct peci_wr_pci_cfg_local_msg - WrPCIConfigLocal command
454 * @addr: address of the client
455 * @bus: PCI bus number
456 * @device: PCI device number
457 * @function: specific function to read from
458 * @reg: specific register to read from
459 * @tx_len: number of data to be written in bytes
460 * @cc: completion code
461 * @value: config data to be written
462 *
463 * The WrPCIConfigLocal() command provides sideband write access to the PCI
464 * configuration space that resides within the processor. PECI originators can
465 * access this space even before BIOS enumeration of the system buses.
466 */
James Feist6714a252018-09-10 15:26:18 -0700467struct peci_wr_pci_cfg_local_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800468#define PECI_WRPCICFGLOCAL_WRITE_LEN_BASE 6
469#define PECI_WRPCICFGLOCAL_READ_LEN 1
470#define PECI_WRPCICFGLOCAL_CMD 0xe5
471
472 __u8 addr;
473 __u8 bus;
474 __u8 device;
475 __u8 function;
476 __u16 reg;
477 __u8 tx_len;
478 __u8 cc;
479 __u32 value;
James Feist6714a252018-09-10 15:26:18 -0700480} __attribute__((__packed__));
481
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800482struct peci_rd_end_pt_cfg_msg {
483#define PECI_RDENDPTCFG_PCI_WRITE_LEN 12
484#define PECI_RDENDPTCFG_MMIO_D_WRITE_LEN 14
485#define PECI_RDENDPTCFG_MMIO_Q_WRITE_LEN 18
486#define PECI_RDENDPTCFG_READ_LEN_BASE 1
487#define PECI_RDENDPTCFG_CMD 0xc1
488
489 __u8 addr;
490 __u8 msg_type;
491#define PECI_ENDPTCFG_TYPE_LOCAL_PCI 0x03
492#define PECI_ENDPTCFG_TYPE_PCI 0x04
493#define PECI_ENDPTCFG_TYPE_MMIO 0x05
494
495 union {
496 struct {
497 __u8 seg;
498 __u8 bus;
499 __u8 device;
500 __u8 function;
501 __u16 reg;
502 } pci_cfg;
503 struct {
504 __u8 seg;
505 __u8 bus;
506 __u8 device;
507 __u8 function;
508 __u8 bar;
509 __u8 addr_type;
510#define PECI_ENDPTCFG_ADDR_TYPE_PCI 0x04
511#define PECI_ENDPTCFG_ADDR_TYPE_MMIO_D 0x05
512#define PECI_ENDPTCFG_ADDR_TYPE_MMIO_Q 0x06
513
514 __u64 offset;
515 } mmio;
516 } params;
517 __u8 rx_len;
518 __u8 cc;
519 __u8 padding[2];
520 __u8 data[8];
521} __attribute__((__packed__));
522
523struct peci_wr_end_pt_cfg_msg {
524#define PECI_WRENDPTCFG_PCI_WRITE_LEN_BASE 13
525#define PECI_WRENDPTCFG_MMIO_D_WRITE_LEN_BASE 15
526#define PECI_WRENDPTCFG_MMIO_Q_WRITE_LEN_BASE 19
527#define PECI_WRENDPTCFG_READ_LEN 1
528#define PECI_WRENDPTCFG_CMD 0xc5
529
530 __u8 addr;
531 __u8 msg_type;
532 /* See msg_type in struct peci_rd_end_pt_cfg_msg */
533
534 union {
535 struct {
536 __u8 seg;
537 __u8 bus;
538 __u8 device;
539 __u8 function;
540 __u16 reg;
541 } pci_cfg;
542 struct {
543 __u8 seg;
544 __u8 bus;
545 __u8 device;
546 __u8 function;
547 __u8 bar;
548 __u8 addr_type;
549 /* See addr_type in struct peci_rd_end_pt_cfg_msg */
550
551 __u64 offset;
552 } mmio;
553 } params;
554 __u8 tx_len;
555 __u8 cc;
556 __u8 padding[2];
557 __u64 value;
558} __attribute__((__packed__));
559
560/* Crashdump Agent */
561#define PECI_CRASHDUMP_CORE 0x00
562#define PECI_CRASHDUMP_TOR 0x01
563
564/* Crashdump Agent Param */
565#define PECI_CRASHDUMP_PAYLOAD_SIZE 0x00
566
567/* Crashdump Agent Data Param */
568#define PECI_CRASHDUMP_AGENT_ID 0x00
569#define PECI_CRASHDUMP_AGENT_PARAM 0x01
570
James Feist6714a252018-09-10 15:26:18 -0700571struct peci_crashdump_disc_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800572 __u8 addr;
573 __u8 subopcode;
574#define PECI_CRASHDUMP_ENABLED 0x00
575#define PECI_CRASHDUMP_NUM_AGENTS 0x01
576#define PECI_CRASHDUMP_AGENT_DATA 0x02
577
578 __u8 cc;
579 __u8 param0;
580 __u16 param1;
581 __u8 param2;
582 __u8 rx_len;
583 __u8 data[8];
James Feist6714a252018-09-10 15:26:18 -0700584} __attribute__((__packed__));
585
586struct peci_crashdump_get_frame_msg {
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800587#define PECI_CRASHDUMP_DISC_WRITE_LEN 9
588#define PECI_CRASHDUMP_DISC_READ_LEN_BASE 1
589#define PECI_CRASHDUMP_DISC_VERSION 0
590#define PECI_CRASHDUMP_DISC_OPCODE 1
591#define PECI_CRASHDUMP_GET_FRAME_WRITE_LEN 10
592#define PECI_CRASHDUMP_GET_FRAME_READ_LEN_BASE 1
593#define PECI_CRASHDUMP_GET_FRAME_VERSION 0
594#define PECI_CRASHDUMP_GET_FRAME_OPCODE 3
595#define PECI_CRASHDUMP_CMD 0x71
596
597 __u8 addr;
598 __u8 padding0;
599 __u16 param0;
600 __u16 param1;
601 __u16 param2;
602 __u8 rx_len;
603 __u8 cc;
604 __u8 padding1[2];
605 __u8 data[16];
James Feist6714a252018-09-10 15:26:18 -0700606} __attribute__((__packed__));
607
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800608#define PECI_IOC_BASE 0xb7
609
610#define PECI_IOC_XFER \
611 _IOWR(PECI_IOC_BASE, PECI_CMD_XFER, struct peci_xfer_msg)
James Feist6714a252018-09-10 15:26:18 -0700612
613#define PECI_IOC_PING \
614 _IOWR(PECI_IOC_BASE, PECI_CMD_PING, struct peci_ping_msg)
615
616#define PECI_IOC_GET_DIB \
617 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_DIB, struct peci_get_dib_msg)
618
619#define PECI_IOC_GET_TEMP \
620 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_TEMP, struct peci_get_temp_msg)
621
622#define PECI_IOC_RD_PKG_CFG \
623 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PKG_CFG, struct peci_rd_pkg_cfg_msg)
624
625#define PECI_IOC_WR_PKG_CFG \
626 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PKG_CFG, struct peci_wr_pkg_cfg_msg)
627
628#define PECI_IOC_RD_IA_MSR \
629 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSR, struct peci_rd_ia_msr_msg)
630
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800631#define PECI_IOC_WR_IA_MSR \
632 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_IA_MSR, struct peci_wr_ia_msr_msg)
633
634#define PECI_IOC_RD_IA_MSREX \
635 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSREX, struct peci_rd_ia_msrex_msg)
636
James Feist6714a252018-09-10 15:26:18 -0700637#define PECI_IOC_RD_PCI_CFG \
638 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG, struct peci_rd_pci_cfg_msg)
639
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800640#define PECI_IOC_WR_PCI_CFG \
641 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG, struct peci_wr_pci_cfg_msg)
642
James Feist6714a252018-09-10 15:26:18 -0700643#define PECI_IOC_RD_PCI_CFG_LOCAL \
644 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG_LOCAL, \
645 struct peci_rd_pci_cfg_local_msg)
646
647#define PECI_IOC_WR_PCI_CFG_LOCAL \
648 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG_LOCAL, \
649 struct peci_wr_pci_cfg_local_msg)
650
Jae Hyun Yoob9122032019-12-23 15:34:59 -0800651#define PECI_IOC_RD_END_PT_CFG \
652 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_END_PT_CFG, \
653 struct peci_rd_end_pt_cfg_msg)
654
655#define PECI_IOC_WR_END_PT_CFG \
656 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_END_PT_CFG, \
657 struct peci_wr_end_pt_cfg_msg)
658
James Feist6714a252018-09-10 15:26:18 -0700659#define PECI_IOC_CRASHDUMP_DISC \
660 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_DISC, \
661 struct peci_crashdump_disc_msg)
662
663#define PECI_IOC_CRASHDUMP_GET_FRAME \
664 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_GET_FRAME, \
665 struct peci_crashdump_get_frame_msg)
666
Ed Tanousec77caa2023-02-17 10:46:06 -0800667#ifdef __cplusplus
668}
669#endif
670
James Feist6714a252018-09-10 15:26:18 -0700671#endif /* __PECI_IOCTL_H */
James Feist582be092018-11-27 10:54:59 -0800672// clang-format on