xref: /OK3568_Linux_fs/kernel/drivers/misc/habanalabs/include/common/cpucp_if.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * Copyright 2020 HabanaLabs, Ltd.
4*4882a593Smuzhiyun  * All Rights Reserved.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef CPUCP_IF_H
9*4882a593Smuzhiyun #define CPUCP_IF_H
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/types.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /*
14*4882a593Smuzhiyun  * EVENT QUEUE
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun struct hl_eq_header {
18*4882a593Smuzhiyun 	__le32 reserved;
19*4882a593Smuzhiyun 	__le32 ctl;
20*4882a593Smuzhiyun };
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun struct hl_eq_ecc_data {
23*4882a593Smuzhiyun 	__le64 ecc_address;
24*4882a593Smuzhiyun 	__le64 ecc_syndrom;
25*4882a593Smuzhiyun 	__u8 memory_wrapper_idx;
26*4882a593Smuzhiyun 	__u8 pad[7];
27*4882a593Smuzhiyun };
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun struct hl_eq_entry {
30*4882a593Smuzhiyun 	struct hl_eq_header hdr;
31*4882a593Smuzhiyun 	union {
32*4882a593Smuzhiyun 		struct hl_eq_ecc_data ecc_data;
33*4882a593Smuzhiyun 		__le64 data[7];
34*4882a593Smuzhiyun 	};
35*4882a593Smuzhiyun };
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #define HL_EQ_ENTRY_SIZE		sizeof(struct hl_eq_entry)
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #define EQ_CTL_READY_SHIFT		31
40*4882a593Smuzhiyun #define EQ_CTL_READY_MASK		0x80000000
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #define EQ_CTL_EVENT_TYPE_SHIFT		16
43*4882a593Smuzhiyun #define EQ_CTL_EVENT_TYPE_MASK		0x03FF0000
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun enum pq_init_status {
46*4882a593Smuzhiyun 	PQ_INIT_STATUS_NA = 0,
47*4882a593Smuzhiyun 	PQ_INIT_STATUS_READY_FOR_CP,
48*4882a593Smuzhiyun 	PQ_INIT_STATUS_READY_FOR_HOST,
49*4882a593Smuzhiyun 	PQ_INIT_STATUS_READY_FOR_CP_SINGLE_MSI
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /*
53*4882a593Smuzhiyun  * CpuCP Primary Queue Packets
54*4882a593Smuzhiyun  *
55*4882a593Smuzhiyun  * During normal operation, the host's kernel driver needs to send various
56*4882a593Smuzhiyun  * messages to CpuCP, usually either to SET some value into a H/W periphery or
57*4882a593Smuzhiyun  * to GET the current value of some H/W periphery. For example, SET the
58*4882a593Smuzhiyun  * frequency of MME/TPC and GET the value of the thermal sensor.
59*4882a593Smuzhiyun  *
60*4882a593Smuzhiyun  * These messages can be initiated either by the User application or by the
61*4882a593Smuzhiyun  * host's driver itself, e.g. power management code. In either case, the
62*4882a593Smuzhiyun  * communication from the host's driver to CpuCP will *always* be in
63*4882a593Smuzhiyun  * synchronous mode, meaning that the host will send a single message and poll
64*4882a593Smuzhiyun  * until the message was acknowledged and the results are ready (if results are
65*4882a593Smuzhiyun  * needed).
66*4882a593Smuzhiyun  *
67*4882a593Smuzhiyun  * This means that only a single message can be sent at a time and the host's
68*4882a593Smuzhiyun  * driver must wait for its result before sending the next message. Having said
69*4882a593Smuzhiyun  * that, because these are control messages which are sent in a relatively low
70*4882a593Smuzhiyun  * frequency, this limitation seems acceptable. It's important to note that
71*4882a593Smuzhiyun  * in case of multiple devices, messages to different devices *can* be sent
72*4882a593Smuzhiyun  * at the same time.
73*4882a593Smuzhiyun  *
74*4882a593Smuzhiyun  * The message, inputs/outputs (if relevant) and fence object will be located
75*4882a593Smuzhiyun  * on the device DDR at an address that will be determined by the host's driver.
76*4882a593Smuzhiyun  * During device initialization phase, the host will pass to CpuCP that address.
77*4882a593Smuzhiyun  * Most of the message types will contain inputs/outputs inside the message
78*4882a593Smuzhiyun  * itself. The common part of each message will contain the opcode of the
79*4882a593Smuzhiyun  * message (its type) and a field representing a fence object.
80*4882a593Smuzhiyun  *
81*4882a593Smuzhiyun  * When the host's driver wishes to send a message to CPU CP, it will write the
82*4882a593Smuzhiyun  * message contents to the device DDR, clear the fence object and then write to
83*4882a593Smuzhiyun  * the PSOC_ARC1_AUX_SW_INTR, to issue interrupt 121 to ARC Management CPU.
84*4882a593Smuzhiyun  *
85*4882a593Smuzhiyun  * Upon receiving the interrupt (#121), CpuCP will read the message from the
86*4882a593Smuzhiyun  * DDR. In case the message is a SET operation, CpuCP will first perform the
87*4882a593Smuzhiyun  * operation and then write to the fence object on the device DDR. In case the
88*4882a593Smuzhiyun  * message is a GET operation, CpuCP will first fill the results section on the
89*4882a593Smuzhiyun  * device DDR and then write to the fence object. If an error occurred, CpuCP
90*4882a593Smuzhiyun  * will fill the rc field with the right error code.
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * In the meantime, the host's driver will poll on the fence object. Once the
93*4882a593Smuzhiyun  * host sees that the fence object is signaled, it will read the results from
94*4882a593Smuzhiyun  * the device DDR (if relevant) and resume the code execution in the host's
95*4882a593Smuzhiyun  * driver.
96*4882a593Smuzhiyun  *
97*4882a593Smuzhiyun  * To use QMAN packets, the opcode must be the QMAN opcode, shifted by 8
98*4882a593Smuzhiyun  * so the value being put by the host's driver matches the value read by CpuCP
99*4882a593Smuzhiyun  *
100*4882a593Smuzhiyun  * Non-QMAN packets should be limited to values 1 through (2^8 - 1)
101*4882a593Smuzhiyun  *
102*4882a593Smuzhiyun  * Detailed description:
103*4882a593Smuzhiyun  *
104*4882a593Smuzhiyun  * CPUCP_PACKET_DISABLE_PCI_ACCESS -
105*4882a593Smuzhiyun  *       After receiving this packet the embedded CPU must NOT issue PCI
106*4882a593Smuzhiyun  *       transactions (read/write) towards the Host CPU. This also include
107*4882a593Smuzhiyun  *       sending MSI-X interrupts.
108*4882a593Smuzhiyun  *       This packet is usually sent before the device is moved to D3Hot state.
109*4882a593Smuzhiyun  *
110*4882a593Smuzhiyun  * CPUCP_PACKET_ENABLE_PCI_ACCESS -
111*4882a593Smuzhiyun  *       After receiving this packet the embedded CPU is allowed to issue PCI
112*4882a593Smuzhiyun  *       transactions towards the Host CPU, including sending MSI-X interrupts.
113*4882a593Smuzhiyun  *       This packet is usually send after the device is moved to D0 state.
114*4882a593Smuzhiyun  *
115*4882a593Smuzhiyun  * CPUCP_PACKET_TEMPERATURE_GET -
116*4882a593Smuzhiyun  *       Fetch the current temperature / Max / Max Hyst / Critical /
117*4882a593Smuzhiyun  *       Critical Hyst of a specified thermal sensor. The packet's
118*4882a593Smuzhiyun  *       arguments specify the desired sensor and the field to get.
119*4882a593Smuzhiyun  *
120*4882a593Smuzhiyun  * CPUCP_PACKET_VOLTAGE_GET -
121*4882a593Smuzhiyun  *       Fetch the voltage / Max / Min of a specified sensor. The packet's
122*4882a593Smuzhiyun  *       arguments specify the sensor and type.
123*4882a593Smuzhiyun  *
124*4882a593Smuzhiyun  * CPUCP_PACKET_CURRENT_GET -
125*4882a593Smuzhiyun  *       Fetch the current / Max / Min of a specified sensor. The packet's
126*4882a593Smuzhiyun  *       arguments specify the sensor and type.
127*4882a593Smuzhiyun  *
128*4882a593Smuzhiyun  * CPUCP_PACKET_FAN_SPEED_GET -
129*4882a593Smuzhiyun  *       Fetch the speed / Max / Min of a specified fan. The packet's
130*4882a593Smuzhiyun  *       arguments specify the sensor and type.
131*4882a593Smuzhiyun  *
132*4882a593Smuzhiyun  * CPUCP_PACKET_PWM_GET -
133*4882a593Smuzhiyun  *       Fetch the pwm value / mode of a specified pwm. The packet's
134*4882a593Smuzhiyun  *       arguments specify the sensor and type.
135*4882a593Smuzhiyun  *
136*4882a593Smuzhiyun  * CPUCP_PACKET_PWM_SET -
137*4882a593Smuzhiyun  *       Set the pwm value / mode of a specified pwm. The packet's
138*4882a593Smuzhiyun  *       arguments specify the sensor, type and value.
139*4882a593Smuzhiyun  *
140*4882a593Smuzhiyun  * CPUCP_PACKET_FREQUENCY_SET -
141*4882a593Smuzhiyun  *       Set the frequency of a specified PLL. The packet's arguments specify
142*4882a593Smuzhiyun  *       the PLL and the desired frequency. The actual frequency in the device
143*4882a593Smuzhiyun  *       might differ from the requested frequency.
144*4882a593Smuzhiyun  *
145*4882a593Smuzhiyun  * CPUCP_PACKET_FREQUENCY_GET -
146*4882a593Smuzhiyun  *       Fetch the frequency of a specified PLL. The packet's arguments specify
147*4882a593Smuzhiyun  *       the PLL.
148*4882a593Smuzhiyun  *
149*4882a593Smuzhiyun  * CPUCP_PACKET_LED_SET -
150*4882a593Smuzhiyun  *       Set the state of a specified led. The packet's arguments
151*4882a593Smuzhiyun  *       specify the led and the desired state.
152*4882a593Smuzhiyun  *
153*4882a593Smuzhiyun  * CPUCP_PACKET_I2C_WR -
154*4882a593Smuzhiyun  *       Write 32-bit value to I2C device. The packet's arguments specify the
155*4882a593Smuzhiyun  *       I2C bus, address and value.
156*4882a593Smuzhiyun  *
157*4882a593Smuzhiyun  * CPUCP_PACKET_I2C_RD -
158*4882a593Smuzhiyun  *       Read 32-bit value from I2C device. The packet's arguments specify the
159*4882a593Smuzhiyun  *       I2C bus and address.
160*4882a593Smuzhiyun  *
161*4882a593Smuzhiyun  * CPUCP_PACKET_INFO_GET -
162*4882a593Smuzhiyun  *       Fetch information from the device as specified in the packet's
163*4882a593Smuzhiyun  *       structure. The host's driver passes the max size it allows the CpuCP to
164*4882a593Smuzhiyun  *       write to the structure, to prevent data corruption in case of
165*4882a593Smuzhiyun  *       mismatched driver/FW versions.
166*4882a593Smuzhiyun  *
167*4882a593Smuzhiyun  * CPUCP_PACKET_FLASH_PROGRAM_REMOVED - this packet was removed
168*4882a593Smuzhiyun  *
169*4882a593Smuzhiyun  * CPUCP_PACKET_UNMASK_RAZWI_IRQ -
170*4882a593Smuzhiyun  *       Unmask the given IRQ. The IRQ number is specified in the value field.
171*4882a593Smuzhiyun  *       The packet is sent after receiving an interrupt and printing its
172*4882a593Smuzhiyun  *       relevant information.
173*4882a593Smuzhiyun  *
174*4882a593Smuzhiyun  * CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY -
175*4882a593Smuzhiyun  *       Unmask the given IRQs. The IRQs numbers are specified in an array right
176*4882a593Smuzhiyun  *       after the cpucp_packet structure, where its first element is the array
177*4882a593Smuzhiyun  *       length. The packet is sent after a soft reset was done in order to
178*4882a593Smuzhiyun  *       handle any interrupts that were sent during the reset process.
179*4882a593Smuzhiyun  *
180*4882a593Smuzhiyun  * CPUCP_PACKET_TEST -
181*4882a593Smuzhiyun  *       Test packet for CpuCP connectivity. The CPU will put the fence value
182*4882a593Smuzhiyun  *       in the result field.
183*4882a593Smuzhiyun  *
184*4882a593Smuzhiyun  * CPUCP_PACKET_FREQUENCY_CURR_GET -
185*4882a593Smuzhiyun  *       Fetch the current frequency of a specified PLL. The packet's arguments
186*4882a593Smuzhiyun  *       specify the PLL.
187*4882a593Smuzhiyun  *
188*4882a593Smuzhiyun  * CPUCP_PACKET_MAX_POWER_GET -
189*4882a593Smuzhiyun  *       Fetch the maximal power of the device.
190*4882a593Smuzhiyun  *
191*4882a593Smuzhiyun  * CPUCP_PACKET_MAX_POWER_SET -
192*4882a593Smuzhiyun  *       Set the maximal power of the device. The packet's arguments specify
193*4882a593Smuzhiyun  *       the power.
194*4882a593Smuzhiyun  *
195*4882a593Smuzhiyun  * CPUCP_PACKET_EEPROM_DATA_GET -
196*4882a593Smuzhiyun  *       Get EEPROM data from the CpuCP kernel. The buffer is specified in the
197*4882a593Smuzhiyun  *       addr field. The CPU will put the returned data size in the result
198*4882a593Smuzhiyun  *       field. In addition, the host's driver passes the max size it allows the
199*4882a593Smuzhiyun  *       CpuCP to write to the structure, to prevent data corruption in case of
200*4882a593Smuzhiyun  *       mismatched driver/FW versions.
201*4882a593Smuzhiyun  *
202*4882a593Smuzhiyun  * CPUCP_PACKET_TEMPERATURE_SET -
203*4882a593Smuzhiyun  *       Set the value of the offset property of a specified thermal sensor.
204*4882a593Smuzhiyun  *       The packet's arguments specify the desired sensor and the field to
205*4882a593Smuzhiyun  *       set.
206*4882a593Smuzhiyun  *
207*4882a593Smuzhiyun  * CPUCP_PACKET_VOLTAGE_SET -
208*4882a593Smuzhiyun  *       Trigger the reset_history property of a specified voltage sensor.
209*4882a593Smuzhiyun  *       The packet's arguments specify the desired sensor and the field to
210*4882a593Smuzhiyun  *       set.
211*4882a593Smuzhiyun  *
212*4882a593Smuzhiyun  * CPUCP_PACKET_CURRENT_SET -
213*4882a593Smuzhiyun  *       Trigger the reset_history property of a specified current sensor.
214*4882a593Smuzhiyun  *       The packet's arguments specify the desired sensor and the field to
215*4882a593Smuzhiyun  *       set.
216*4882a593Smuzhiyun  *
217*4882a593Smuzhiyun  * CPUCP_PACKET_PLL_REG_GET
218*4882a593Smuzhiyun  *       Fetch register of PLL from the required PLL IP.
219*4882a593Smuzhiyun  *       The packet's arguments specify the PLL IP and the register to get.
220*4882a593Smuzhiyun  *       Each register is 32-bit value which is returned in result field.
221*4882a593Smuzhiyun  *
222*4882a593Smuzhiyun  */
223*4882a593Smuzhiyun 
224*4882a593Smuzhiyun enum cpucp_packet_id {
225*4882a593Smuzhiyun 	CPUCP_PACKET_DISABLE_PCI_ACCESS = 1,	/* internal */
226*4882a593Smuzhiyun 	CPUCP_PACKET_ENABLE_PCI_ACCESS,		/* internal */
227*4882a593Smuzhiyun 	CPUCP_PACKET_TEMPERATURE_GET,		/* sysfs */
228*4882a593Smuzhiyun 	CPUCP_PACKET_VOLTAGE_GET,		/* sysfs */
229*4882a593Smuzhiyun 	CPUCP_PACKET_CURRENT_GET,		/* sysfs */
230*4882a593Smuzhiyun 	CPUCP_PACKET_FAN_SPEED_GET,		/* sysfs */
231*4882a593Smuzhiyun 	CPUCP_PACKET_PWM_GET,			/* sysfs */
232*4882a593Smuzhiyun 	CPUCP_PACKET_PWM_SET,			/* sysfs */
233*4882a593Smuzhiyun 	CPUCP_PACKET_FREQUENCY_SET,		/* sysfs */
234*4882a593Smuzhiyun 	CPUCP_PACKET_FREQUENCY_GET,		/* sysfs */
235*4882a593Smuzhiyun 	CPUCP_PACKET_LED_SET,			/* debugfs */
236*4882a593Smuzhiyun 	CPUCP_PACKET_I2C_WR,			/* debugfs */
237*4882a593Smuzhiyun 	CPUCP_PACKET_I2C_RD,			/* debugfs */
238*4882a593Smuzhiyun 	CPUCP_PACKET_INFO_GET,			/* IOCTL */
239*4882a593Smuzhiyun 	CPUCP_PACKET_FLASH_PROGRAM_REMOVED,
240*4882a593Smuzhiyun 	CPUCP_PACKET_UNMASK_RAZWI_IRQ,		/* internal */
241*4882a593Smuzhiyun 	CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY,	/* internal */
242*4882a593Smuzhiyun 	CPUCP_PACKET_TEST,			/* internal */
243*4882a593Smuzhiyun 	CPUCP_PACKET_FREQUENCY_CURR_GET,	/* sysfs */
244*4882a593Smuzhiyun 	CPUCP_PACKET_MAX_POWER_GET,		/* sysfs */
245*4882a593Smuzhiyun 	CPUCP_PACKET_MAX_POWER_SET,		/* sysfs */
246*4882a593Smuzhiyun 	CPUCP_PACKET_EEPROM_DATA_GET,		/* sysfs */
247*4882a593Smuzhiyun 	CPUCP_RESERVED,
248*4882a593Smuzhiyun 	CPUCP_PACKET_TEMPERATURE_SET,		/* sysfs */
249*4882a593Smuzhiyun 	CPUCP_PACKET_VOLTAGE_SET,		/* sysfs */
250*4882a593Smuzhiyun 	CPUCP_PACKET_CURRENT_SET,		/* sysfs */
251*4882a593Smuzhiyun 	CPUCP_PACKET_PCIE_THROUGHPUT_GET,		/* internal */
252*4882a593Smuzhiyun 	CPUCP_PACKET_PCIE_REPLAY_CNT_GET,		/* internal */
253*4882a593Smuzhiyun 	CPUCP_PACKET_TOTAL_ENERGY_GET,		/* internal */
254*4882a593Smuzhiyun 	CPUCP_PACKET_PLL_REG_GET,		/* internal */
255*4882a593Smuzhiyun };
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun #define CPUCP_PACKET_FENCE_VAL	0xFE8CE7A5
258*4882a593Smuzhiyun 
259*4882a593Smuzhiyun #define CPUCP_PKT_CTL_RC_SHIFT		12
260*4882a593Smuzhiyun #define CPUCP_PKT_CTL_RC_MASK		0x0000F000
261*4882a593Smuzhiyun 
262*4882a593Smuzhiyun #define CPUCP_PKT_CTL_OPCODE_SHIFT	16
263*4882a593Smuzhiyun #define CPUCP_PKT_CTL_OPCODE_MASK	0x1FFF0000
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun struct cpucp_packet {
266*4882a593Smuzhiyun 	union {
267*4882a593Smuzhiyun 		__le64 value;	/* For SET packets */
268*4882a593Smuzhiyun 		__le64 result;	/* For GET packets */
269*4882a593Smuzhiyun 		__le64 addr;	/* For PQ */
270*4882a593Smuzhiyun 	};
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun 	__le32 ctl;
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun 	__le32 fence;		/* Signal to host that message is completed */
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun 	union {
277*4882a593Smuzhiyun 		struct {/* For temperature/current/voltage/fan/pwm get/set */
278*4882a593Smuzhiyun 			__le16 sensor_index;
279*4882a593Smuzhiyun 			__le16 type;
280*4882a593Smuzhiyun 		};
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun 		struct {	/* For I2C read/write */
283*4882a593Smuzhiyun 			__u8 i2c_bus;
284*4882a593Smuzhiyun 			__u8 i2c_addr;
285*4882a593Smuzhiyun 			__u8 i2c_reg;
286*4882a593Smuzhiyun 			__u8 pad; /* unused */
287*4882a593Smuzhiyun 		};
288*4882a593Smuzhiyun 
289*4882a593Smuzhiyun 		struct {/* For PLL register fetch */
290*4882a593Smuzhiyun 			__le16 pll_type;
291*4882a593Smuzhiyun 			__le16 pll_reg;
292*4882a593Smuzhiyun 		};
293*4882a593Smuzhiyun 
294*4882a593Smuzhiyun 		/* For any general request */
295*4882a593Smuzhiyun 		__le32 index;
296*4882a593Smuzhiyun 
297*4882a593Smuzhiyun 		/* For frequency get/set */
298*4882a593Smuzhiyun 		__le32 pll_index;
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun 		/* For led set */
301*4882a593Smuzhiyun 		__le32 led_index;
302*4882a593Smuzhiyun 
303*4882a593Smuzhiyun 		/* For get CpuCP info/EEPROM data */
304*4882a593Smuzhiyun 		__le32 data_max_size;
305*4882a593Smuzhiyun 	};
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun 	__le32 reserved;
308*4882a593Smuzhiyun };
309*4882a593Smuzhiyun 
310*4882a593Smuzhiyun struct cpucp_unmask_irq_arr_packet {
311*4882a593Smuzhiyun 	struct cpucp_packet cpucp_pkt;
312*4882a593Smuzhiyun 	__le32 length;
313*4882a593Smuzhiyun 	__le32 irqs[0];
314*4882a593Smuzhiyun };
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun enum cpucp_packet_rc {
317*4882a593Smuzhiyun 	cpucp_packet_success,
318*4882a593Smuzhiyun 	cpucp_packet_invalid,
319*4882a593Smuzhiyun 	cpucp_packet_fault
320*4882a593Smuzhiyun };
321*4882a593Smuzhiyun 
322*4882a593Smuzhiyun /*
323*4882a593Smuzhiyun  * cpucp_temp_type should adhere to hwmon_temp_attributes
324*4882a593Smuzhiyun  * defined in Linux kernel hwmon.h file
325*4882a593Smuzhiyun  */
326*4882a593Smuzhiyun enum cpucp_temp_type {
327*4882a593Smuzhiyun 	cpucp_temp_input,
328*4882a593Smuzhiyun 	cpucp_temp_max = 6,
329*4882a593Smuzhiyun 	cpucp_temp_max_hyst,
330*4882a593Smuzhiyun 	cpucp_temp_crit,
331*4882a593Smuzhiyun 	cpucp_temp_crit_hyst,
332*4882a593Smuzhiyun 	cpucp_temp_offset = 19,
333*4882a593Smuzhiyun 	cpucp_temp_highest = 22,
334*4882a593Smuzhiyun 	cpucp_temp_reset_history = 23
335*4882a593Smuzhiyun };
336*4882a593Smuzhiyun 
337*4882a593Smuzhiyun enum cpucp_in_attributes {
338*4882a593Smuzhiyun 	cpucp_in_input,
339*4882a593Smuzhiyun 	cpucp_in_min,
340*4882a593Smuzhiyun 	cpucp_in_max,
341*4882a593Smuzhiyun 	cpucp_in_highest = 7,
342*4882a593Smuzhiyun 	cpucp_in_reset_history
343*4882a593Smuzhiyun };
344*4882a593Smuzhiyun 
345*4882a593Smuzhiyun enum cpucp_curr_attributes {
346*4882a593Smuzhiyun 	cpucp_curr_input,
347*4882a593Smuzhiyun 	cpucp_curr_min,
348*4882a593Smuzhiyun 	cpucp_curr_max,
349*4882a593Smuzhiyun 	cpucp_curr_highest = 7,
350*4882a593Smuzhiyun 	cpucp_curr_reset_history
351*4882a593Smuzhiyun };
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun enum cpucp_fan_attributes {
354*4882a593Smuzhiyun 	cpucp_fan_input,
355*4882a593Smuzhiyun 	cpucp_fan_min = 2,
356*4882a593Smuzhiyun 	cpucp_fan_max
357*4882a593Smuzhiyun };
358*4882a593Smuzhiyun 
359*4882a593Smuzhiyun enum cpucp_pwm_attributes {
360*4882a593Smuzhiyun 	cpucp_pwm_input,
361*4882a593Smuzhiyun 	cpucp_pwm_enable
362*4882a593Smuzhiyun };
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun enum cpucp_pcie_throughput_attributes {
365*4882a593Smuzhiyun 	cpucp_pcie_throughput_tx,
366*4882a593Smuzhiyun 	cpucp_pcie_throughput_rx
367*4882a593Smuzhiyun };
368*4882a593Smuzhiyun 
369*4882a593Smuzhiyun enum cpucp_pll_reg_attributes {
370*4882a593Smuzhiyun 	cpucp_pll_nr_reg,
371*4882a593Smuzhiyun 	cpucp_pll_nf_reg,
372*4882a593Smuzhiyun 	cpucp_pll_od_reg,
373*4882a593Smuzhiyun 	cpucp_pll_div_factor_reg,
374*4882a593Smuzhiyun 	cpucp_pll_div_sel_reg
375*4882a593Smuzhiyun };
376*4882a593Smuzhiyun 
377*4882a593Smuzhiyun enum cpucp_pll_type_attributes {
378*4882a593Smuzhiyun 	cpucp_pll_cpu,
379*4882a593Smuzhiyun 	cpucp_pll_pci,
380*4882a593Smuzhiyun };
381*4882a593Smuzhiyun 
382*4882a593Smuzhiyun /* Event Queue Packets */
383*4882a593Smuzhiyun 
384*4882a593Smuzhiyun struct eq_generic_event {
385*4882a593Smuzhiyun 	__le64 data[7];
386*4882a593Smuzhiyun };
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun /*
389*4882a593Smuzhiyun  * CpuCP info
390*4882a593Smuzhiyun  */
391*4882a593Smuzhiyun 
392*4882a593Smuzhiyun #define CARD_NAME_MAX_LEN		16
393*4882a593Smuzhiyun #define VERSION_MAX_LEN			128
394*4882a593Smuzhiyun #define CPUCP_MAX_SENSORS		128
395*4882a593Smuzhiyun 
396*4882a593Smuzhiyun struct cpucp_sensor {
397*4882a593Smuzhiyun 	__le32 type;
398*4882a593Smuzhiyun 	__le32 flags;
399*4882a593Smuzhiyun };
400*4882a593Smuzhiyun 
401*4882a593Smuzhiyun /**
402*4882a593Smuzhiyun  * struct cpucp_card_types - ASIC card type.
403*4882a593Smuzhiyun  * @cpucp_card_type_pci: PCI card.
404*4882a593Smuzhiyun  * @cpucp_card_type_pmc: PCI Mezzanine Card.
405*4882a593Smuzhiyun  */
406*4882a593Smuzhiyun enum cpucp_card_types {
407*4882a593Smuzhiyun 	cpucp_card_type_pci,
408*4882a593Smuzhiyun 	cpucp_card_type_pmc
409*4882a593Smuzhiyun };
410*4882a593Smuzhiyun 
411*4882a593Smuzhiyun /**
412*4882a593Smuzhiyun  * struct cpucp_info - Info from CpuCP that is necessary to the host's driver
413*4882a593Smuzhiyun  * @sensors: available sensors description.
414*4882a593Smuzhiyun  * @kernel_version: CpuCP linux kernel version.
415*4882a593Smuzhiyun  * @reserved: reserved field.
416*4882a593Smuzhiyun  * @card_type: card configuration type.
417*4882a593Smuzhiyun  * @card_location: in a server, each card has different connections topology
418*4882a593Smuzhiyun  *                 depending on its location (relevant for PMC card type)
419*4882a593Smuzhiyun  * @cpld_version: CPLD programmed F/W version.
420*4882a593Smuzhiyun  * @infineon_version: Infineon main DC-DC version.
421*4882a593Smuzhiyun  * @fuse_version: silicon production FUSE information.
422*4882a593Smuzhiyun  * @thermal_version: thermald S/W version.
423*4882a593Smuzhiyun  * @cpucp_version: CpuCP S/W version.
424*4882a593Smuzhiyun  * @dram_size: available DRAM size.
425*4882a593Smuzhiyun  * @card_name: card name that will be displayed in HWMON subsystem on the host
426*4882a593Smuzhiyun  */
427*4882a593Smuzhiyun struct cpucp_info {
428*4882a593Smuzhiyun 	struct cpucp_sensor sensors[CPUCP_MAX_SENSORS];
429*4882a593Smuzhiyun 	__u8 kernel_version[VERSION_MAX_LEN];
430*4882a593Smuzhiyun 	__le32 reserved;
431*4882a593Smuzhiyun 	__le32 card_type;
432*4882a593Smuzhiyun 	__le32 card_location;
433*4882a593Smuzhiyun 	__le32 cpld_version;
434*4882a593Smuzhiyun 	__le32 infineon_version;
435*4882a593Smuzhiyun 	__u8 fuse_version[VERSION_MAX_LEN];
436*4882a593Smuzhiyun 	__u8 thermal_version[VERSION_MAX_LEN];
437*4882a593Smuzhiyun 	__u8 cpucp_version[VERSION_MAX_LEN];
438*4882a593Smuzhiyun 	__le32 reserved2;
439*4882a593Smuzhiyun 	__le64 dram_size;
440*4882a593Smuzhiyun 	char card_name[CARD_NAME_MAX_LEN];
441*4882a593Smuzhiyun };
442*4882a593Smuzhiyun 
443*4882a593Smuzhiyun #endif /* CPUCP_IF_H */
444