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