blob: 9cddb8bca6939832e10a51ca39411cc22953716d [file] [log] [blame]
James Feist139cb572018-09-10 15:26:18 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2018 Intel Corporation */
3
4#ifndef __PECI_IOCTL_H
5#define __PECI_IOCTL_H
6
7#include <linux/ioctl.h>
8#include <linux/types.h>
9
10/* Base Address of 48d */
11#define PECI_BASE_ADDR 0x30 /* The PECI client's default address of 0x30 */
12#define PECI_OFFSET_MAX 8 /* Max numver of CPU clients */
13
14/* PCI Access */
15#define MAX_PCI_READ_LEN 24 /* Number of bytes of the PCI Space read */
16
17#define PCI_BUS0_CPU0 0x00
18#define PCI_BUS0_CPU1 0x80
19#define PCI_CPUBUSNO_BUS 0x00
20#define PCI_CPUBUSNO_DEV 0x08
21#define PCI_CPUBUSNO_FUNC 0x02
22#define PCI_CPUBUSNO 0xcc
23#define PCI_CPUBUSNO_1 0xd0
24#define PCI_CPUBUSNO_VALID 0xd4
25
26/* Package Identifier Read Parameter Value */
27#define PKG_ID_CPU_ID 0x0000 /* CPUID Info */
28#define PKG_ID_PLATFORM_ID 0x0001 /* Platform ID */
29#define PKG_ID_UNCORE_ID 0x0002 /* Uncore Device ID */
30#define PKG_ID_MAX_THREAD_ID 0x0003 /* Max Thread ID */
31#define PKG_ID_MICROCODE_REV 0x0004 /* CPU Microcode Update Revision */
32#define PKG_ID_MACHINE_CHECK_STATUS 0x0005 /* Machine Check Status */
33
34/* Crashdump Parameters */
35enum crashdump_agent {
36 CRASHDUMP_CORE = 0x00,
37 CRASHDUMP_TOR = 0x01,
38};
39enum crashdump_discovery_sub_opcode {
40 CRASHDUMP_ENABLED = 0x00,
41 CRASHDUMP_NUM_AGENTS = 0x01,
42 CRASHDUMP_AGENT_DATA = 0x02,
43};
44enum crashdump_agent_data_param {
45 CRASHDUMP_AGENT_ID = 0x00,
46 CRASHDUMP_AGENT_PARAM = 0x01,
47};
48enum crashdump_agent_param {
49 CRASHDUMP_PAYLOAD_SIZE = 0x00,
50};
51
52/* RdPkgConfig Index */
53#define MBX_INDEX_CPU_ID 0 /* Package Identifier Read */
54#define MBX_INDEX_VR_DEBUG 1 /* VR Debug */
55#define MBX_INDEX_PKG_TEMP_READ 2 /* Package Temperature Read */
56#define MBX_INDEX_ENERGY_COUNTER 3 /* Energy counter */
57#define MBX_INDEX_ENERGY_STATUS 4 /* DDR Energy Status */
58#define MBX_INDEX_WAKE_MODE_BIT 5 /* "Wake on PECI" Mode bit */
59#define MBX_INDEX_EPI 6 /* Efficient Performance Indication */
60#define MBX_INDEX_PKG_RAPL_PERF 8 /* Pkg RAPL Performance Status Read */
61#define MBX_INDEX_PER_CORE_DTS_TEMP 9 /* Per Core DTS Temperature Read */
62#define MBX_INDEX_DTS_MARGIN 10 /* DTS thermal margin */
63#define MBX_INDEX_SKT_PWR_THRTL_DUR 11 /* Socket Power Throttled Duration */
64#define MBX_INDEX_CFG_TDP_CONTROL 12 /* TDP Config Control */
65#define MBX_INDEX_CFG_TDP_LEVELS 13 /* TDP Config Levels */
66#define MBX_INDEX_DDR_DIMM_TEMP 14 /* DDR DIMM Temperature */
67#define MBX_INDEX_CFG_ICCMAX 15 /* Configurable ICCMAX */
68#define MBX_INDEX_TEMP_TARGET 16 /* Temperature Target Read */
69#define MBX_INDEX_CURR_CFG_LIMIT 17 /* Current Config Limit */
70#define MBX_INDEX_DIMM_TEMP_READ 20 /* Package Thermal Status Read */
71#define MBX_INDEX_DRAM_IMC_TMP_READ 22 /* DRAM IMC Temperature Read */
72#define MBX_INDEX_DDR_CH_THERM_STAT 23 /* DDR Channel Thermal Status */
73#define MBX_INDEX_PKG_POWER_LIMIT1 26 /* Package Power Limit1 */
74#define MBX_INDEX_PKG_POWER_LIMIT2 27 /* Package Power Limit2 */
75#define MBX_INDEX_TDP 28 /* Thermal design power minimum */
76#define MBX_INDEX_TDP_HIGH 29 /* Thermal design power maximum */
77#define MBX_INDEX_TDP_UNITS 30 /* Units for power/energy registers */
78#define MBX_INDEX_RUN_TIME 31 /* Accumulated Run Time */
79#define MBX_INDEX_CONSTRAINED_TIME 32 /* Thermally Constrained Time Read */
80#define MBX_INDEX_TURBO_RATIO 33 /* Turbo Activation Ratio */
81#define MBX_INDEX_DDR_RAPL_PL1 34 /* DDR RAPL PL1 */
82#define MBX_INDEX_DDR_PWR_INFO_HIGH 35 /* DRAM Power Info Read (high) */
83#define MBX_INDEX_DDR_PWR_INFO_LOW 36 /* DRAM Power Info Read (low) */
84#define MBX_INDEX_DDR_RAPL_PL2 37 /* DDR RAPL PL2 */
85#define MBX_INDEX_DDR_RAPL_STATUS 38 /* DDR RAPL Performance Status */
86#define MBX_INDEX_DDR_HOT_ABSOLUTE 43 /* DDR Hottest Dimm Absolute Temp */
87#define MBX_INDEX_DDR_HOT_RELATIVE 44 /* DDR Hottest Dimm Relative Temp */
88#define MBX_INDEX_DDR_THROTTLE_TIME 45 /* DDR Throttle Time */
89#define MBX_INDEX_DDR_THERM_STATUS 46 /* DDR Thermal Status */
90#define MBX_INDEX_TIME_AVG_TEMP 47 /* Package time-averaged temperature */
91#define MBX_INDEX_TURBO_RATIO_LIMIT 49 /* Turbo Ratio Limit Read */
92#define MBX_INDEX_HWP_AUTO_OOB 53 /* HWP Autonomous Out-of-band */
93#define MBX_INDEX_DDR_WARM_BUDGET 55 /* DDR Warm Power Budget */
94#define MBX_INDEX_DDR_HOT_BUDGET 56 /* DDR Hot Power Budget */
95#define MBX_INDEX_PKG_PSYS_PWR_LIM3 57 /* Package/Psys Power Limit3 */
96#define MBX_INDEX_PKG_PSYS_PWR_LIM1 58 /* Package/Psys Power Limit1 */
97#define MBX_INDEX_PKG_PSYS_PWR_LIM2 59 /* Package/Psys Power Limit2 */
98#define MBX_INDEX_PKG_PSYS_PWR_LIM4 60 /* Package/Psys Power Limit4 */
99#define MBX_INDEX_PERF_LIMIT_REASON 65 /* Performance Limit Reasons */
100
101/* WrPkgConfig Index */
102#define MBX_INDEX_DIMM_AMBIENT 19
103#define MBX_INDEX_DIMM_TEMP 24
104
105enum peci_cmd {
106 PECI_CMD_XFER = 0,
107 PECI_CMD_PING,
108 PECI_CMD_GET_DIB,
109 PECI_CMD_GET_TEMP,
110 PECI_CMD_RD_PKG_CFG,
111 PECI_CMD_WR_PKG_CFG,
112 PECI_CMD_RD_IA_MSR,
113 PECI_CMD_WR_IA_MSR,
114 PECI_CMD_RD_PCI_CFG,
115 PECI_CMD_WR_PCI_CFG,
116 PECI_CMD_RD_PCI_CFG_LOCAL,
117 PECI_CMD_WR_PCI_CFG_LOCAL,
118 PECI_CMD_CRASHDUMP_DISC,
119 PECI_CMD_CRASHDUMP_GET_FRAME,
120 PECI_CMD_MAX
121};
122
123struct peci_ping_msg {
124 __u8 addr;
125} __attribute__((__packed__));
126
127struct peci_get_dib_msg {
128 __u8 addr;
129 __u32 dib;
130} __attribute__((__packed__));
131
132struct peci_get_temp_msg {
133 __u8 addr;
134 __s16 temp_raw;
135} __attribute__((__packed__));
136
137struct peci_rd_pkg_cfg_msg {
138 __u8 addr;
139 __u8 index;
140 __u16 param;
141 __u8 rx_len;
142 __u8 pkg_config[4];
143} __attribute__((__packed__));
144
145struct peci_wr_pkg_cfg_msg {
146 __u8 addr;
147 __u8 index;
148 __u16 param;
149 __u8 tx_len;
150 __u32 value;
151} __attribute__((__packed__));
152
153struct peci_rd_ia_msr_msg {
154 __u8 addr;
155 __u8 thread_id;
156 __u16 address;
157 __u64 value;
158} __attribute__((__packed__));
159
160struct peci_rd_pci_cfg_msg {
161 __u8 addr;
162 __u8 bus;
163 __u8 device;
164 __u8 function;
165 __u16 reg;
166 __u8 pci_config[4];
167} __attribute__((__packed__));
168
169struct peci_rd_pci_cfg_local_msg {
170 __u8 addr;
171 __u8 bus;
172 __u8 device;
173 __u8 function;
174 __u16 reg;
175 __u8 rx_len;
176 __u8 pci_config[4];
177} __attribute__((__packed__));
178
179struct peci_wr_pci_cfg_local_msg {
180 __u8 addr;
181 __u8 bus;
182 __u8 device;
183 __u8 function;
184 __u16 reg;
185 __u8 tx_len;
186 __u32 value;
187} __attribute__((__packed__));
188
189struct peci_crashdump_disc_msg {
190 __u8 addr;
191 __u8 subopcode;
192 __u8 param0;
193 __u16 param1;
194 __u8 param2;
195 __u8 rx_len;
196 __u8 data[8];
197} __attribute__((__packed__));
198
199struct peci_crashdump_get_frame_msg {
200 __u8 addr;
201 __u16 param0;
202 __u16 param1;
203 __u16 param2;
204 __u8 rx_len;
205 __u8 data[16];
206} __attribute__((__packed__));
207
208#define PECI_IOC_BASE 0xb6
209
210#define PECI_IOC_PING \
211 _IOWR(PECI_IOC_BASE, PECI_CMD_PING, struct peci_ping_msg)
212
213#define PECI_IOC_GET_DIB \
214 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_DIB, struct peci_get_dib_msg)
215
216#define PECI_IOC_GET_TEMP \
217 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_TEMP, struct peci_get_temp_msg)
218
219#define PECI_IOC_RD_PKG_CFG \
220 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PKG_CFG, struct peci_rd_pkg_cfg_msg)
221
222#define PECI_IOC_WR_PKG_CFG \
223 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PKG_CFG, struct peci_wr_pkg_cfg_msg)
224
225#define PECI_IOC_RD_IA_MSR \
226 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSR, struct peci_rd_ia_msr_msg)
227
228#define PECI_IOC_RD_PCI_CFG \
229 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG, struct peci_rd_pci_cfg_msg)
230
231#define PECI_IOC_RD_PCI_CFG_LOCAL \
232 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG_LOCAL, \
233 struct peci_rd_pci_cfg_local_msg)
234
235#define PECI_IOC_WR_PCI_CFG_LOCAL \
236 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG_LOCAL, \
237 struct peci_wr_pci_cfg_local_msg)
238
239#define PECI_IOC_CRASHDUMP_DISC \
240 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_DISC, \
241 struct peci_crashdump_disc_msg)
242
243#define PECI_IOC_CRASHDUMP_GET_FRAME \
244 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_GET_FRAME, \
245 struct peci_crashdump_get_frame_msg)
246
247#endif /* __PECI_IOCTL_H */