18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Copyright 2020 HabanaLabs, Ltd.
48c2ecf20Sopenharmony_ci * All Rights Reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef CPUCP_IF_H
98c2ecf20Sopenharmony_ci#define CPUCP_IF_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * EVENT QUEUE
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct hl_eq_header {
188c2ecf20Sopenharmony_ci	__le32 reserved;
198c2ecf20Sopenharmony_ci	__le32 ctl;
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct hl_eq_ecc_data {
238c2ecf20Sopenharmony_ci	__le64 ecc_address;
248c2ecf20Sopenharmony_ci	__le64 ecc_syndrom;
258c2ecf20Sopenharmony_ci	__u8 memory_wrapper_idx;
268c2ecf20Sopenharmony_ci	__u8 pad[7];
278c2ecf20Sopenharmony_ci};
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistruct hl_eq_entry {
308c2ecf20Sopenharmony_ci	struct hl_eq_header hdr;
318c2ecf20Sopenharmony_ci	union {
328c2ecf20Sopenharmony_ci		struct hl_eq_ecc_data ecc_data;
338c2ecf20Sopenharmony_ci		__le64 data[7];
348c2ecf20Sopenharmony_ci	};
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define HL_EQ_ENTRY_SIZE		sizeof(struct hl_eq_entry)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define EQ_CTL_READY_SHIFT		31
408c2ecf20Sopenharmony_ci#define EQ_CTL_READY_MASK		0x80000000
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define EQ_CTL_EVENT_TYPE_SHIFT		16
438c2ecf20Sopenharmony_ci#define EQ_CTL_EVENT_TYPE_MASK		0x03FF0000
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cienum pq_init_status {
468c2ecf20Sopenharmony_ci	PQ_INIT_STATUS_NA = 0,
478c2ecf20Sopenharmony_ci	PQ_INIT_STATUS_READY_FOR_CP,
488c2ecf20Sopenharmony_ci	PQ_INIT_STATUS_READY_FOR_HOST,
498c2ecf20Sopenharmony_ci	PQ_INIT_STATUS_READY_FOR_CP_SINGLE_MSI
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/*
538c2ecf20Sopenharmony_ci * CpuCP Primary Queue Packets
548c2ecf20Sopenharmony_ci *
558c2ecf20Sopenharmony_ci * During normal operation, the host's kernel driver needs to send various
568c2ecf20Sopenharmony_ci * messages to CpuCP, usually either to SET some value into a H/W periphery or
578c2ecf20Sopenharmony_ci * to GET the current value of some H/W periphery. For example, SET the
588c2ecf20Sopenharmony_ci * frequency of MME/TPC and GET the value of the thermal sensor.
598c2ecf20Sopenharmony_ci *
608c2ecf20Sopenharmony_ci * These messages can be initiated either by the User application or by the
618c2ecf20Sopenharmony_ci * host's driver itself, e.g. power management code. In either case, the
628c2ecf20Sopenharmony_ci * communication from the host's driver to CpuCP will *always* be in
638c2ecf20Sopenharmony_ci * synchronous mode, meaning that the host will send a single message and poll
648c2ecf20Sopenharmony_ci * until the message was acknowledged and the results are ready (if results are
658c2ecf20Sopenharmony_ci * needed).
668c2ecf20Sopenharmony_ci *
678c2ecf20Sopenharmony_ci * This means that only a single message can be sent at a time and the host's
688c2ecf20Sopenharmony_ci * driver must wait for its result before sending the next message. Having said
698c2ecf20Sopenharmony_ci * that, because these are control messages which are sent in a relatively low
708c2ecf20Sopenharmony_ci * frequency, this limitation seems acceptable. It's important to note that
718c2ecf20Sopenharmony_ci * in case of multiple devices, messages to different devices *can* be sent
728c2ecf20Sopenharmony_ci * at the same time.
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * The message, inputs/outputs (if relevant) and fence object will be located
758c2ecf20Sopenharmony_ci * on the device DDR at an address that will be determined by the host's driver.
768c2ecf20Sopenharmony_ci * During device initialization phase, the host will pass to CpuCP that address.
778c2ecf20Sopenharmony_ci * Most of the message types will contain inputs/outputs inside the message
788c2ecf20Sopenharmony_ci * itself. The common part of each message will contain the opcode of the
798c2ecf20Sopenharmony_ci * message (its type) and a field representing a fence object.
808c2ecf20Sopenharmony_ci *
818c2ecf20Sopenharmony_ci * When the host's driver wishes to send a message to CPU CP, it will write the
828c2ecf20Sopenharmony_ci * message contents to the device DDR, clear the fence object and then write to
838c2ecf20Sopenharmony_ci * the PSOC_ARC1_AUX_SW_INTR, to issue interrupt 121 to ARC Management CPU.
848c2ecf20Sopenharmony_ci *
858c2ecf20Sopenharmony_ci * Upon receiving the interrupt (#121), CpuCP will read the message from the
868c2ecf20Sopenharmony_ci * DDR. In case the message is a SET operation, CpuCP will first perform the
878c2ecf20Sopenharmony_ci * operation and then write to the fence object on the device DDR. In case the
888c2ecf20Sopenharmony_ci * message is a GET operation, CpuCP will first fill the results section on the
898c2ecf20Sopenharmony_ci * device DDR and then write to the fence object. If an error occurred, CpuCP
908c2ecf20Sopenharmony_ci * will fill the rc field with the right error code.
918c2ecf20Sopenharmony_ci *
928c2ecf20Sopenharmony_ci * In the meantime, the host's driver will poll on the fence object. Once the
938c2ecf20Sopenharmony_ci * host sees that the fence object is signaled, it will read the results from
948c2ecf20Sopenharmony_ci * the device DDR (if relevant) and resume the code execution in the host's
958c2ecf20Sopenharmony_ci * driver.
968c2ecf20Sopenharmony_ci *
978c2ecf20Sopenharmony_ci * To use QMAN packets, the opcode must be the QMAN opcode, shifted by 8
988c2ecf20Sopenharmony_ci * so the value being put by the host's driver matches the value read by CpuCP
998c2ecf20Sopenharmony_ci *
1008c2ecf20Sopenharmony_ci * Non-QMAN packets should be limited to values 1 through (2^8 - 1)
1018c2ecf20Sopenharmony_ci *
1028c2ecf20Sopenharmony_ci * Detailed description:
1038c2ecf20Sopenharmony_ci *
1048c2ecf20Sopenharmony_ci * CPUCP_PACKET_DISABLE_PCI_ACCESS -
1058c2ecf20Sopenharmony_ci *       After receiving this packet the embedded CPU must NOT issue PCI
1068c2ecf20Sopenharmony_ci *       transactions (read/write) towards the Host CPU. This also include
1078c2ecf20Sopenharmony_ci *       sending MSI-X interrupts.
1088c2ecf20Sopenharmony_ci *       This packet is usually sent before the device is moved to D3Hot state.
1098c2ecf20Sopenharmony_ci *
1108c2ecf20Sopenharmony_ci * CPUCP_PACKET_ENABLE_PCI_ACCESS -
1118c2ecf20Sopenharmony_ci *       After receiving this packet the embedded CPU is allowed to issue PCI
1128c2ecf20Sopenharmony_ci *       transactions towards the Host CPU, including sending MSI-X interrupts.
1138c2ecf20Sopenharmony_ci *       This packet is usually send after the device is moved to D0 state.
1148c2ecf20Sopenharmony_ci *
1158c2ecf20Sopenharmony_ci * CPUCP_PACKET_TEMPERATURE_GET -
1168c2ecf20Sopenharmony_ci *       Fetch the current temperature / Max / Max Hyst / Critical /
1178c2ecf20Sopenharmony_ci *       Critical Hyst of a specified thermal sensor. The packet's
1188c2ecf20Sopenharmony_ci *       arguments specify the desired sensor and the field to get.
1198c2ecf20Sopenharmony_ci *
1208c2ecf20Sopenharmony_ci * CPUCP_PACKET_VOLTAGE_GET -
1218c2ecf20Sopenharmony_ci *       Fetch the voltage / Max / Min of a specified sensor. The packet's
1228c2ecf20Sopenharmony_ci *       arguments specify the sensor and type.
1238c2ecf20Sopenharmony_ci *
1248c2ecf20Sopenharmony_ci * CPUCP_PACKET_CURRENT_GET -
1258c2ecf20Sopenharmony_ci *       Fetch the current / Max / Min of a specified sensor. The packet's
1268c2ecf20Sopenharmony_ci *       arguments specify the sensor and type.
1278c2ecf20Sopenharmony_ci *
1288c2ecf20Sopenharmony_ci * CPUCP_PACKET_FAN_SPEED_GET -
1298c2ecf20Sopenharmony_ci *       Fetch the speed / Max / Min of a specified fan. The packet's
1308c2ecf20Sopenharmony_ci *       arguments specify the sensor and type.
1318c2ecf20Sopenharmony_ci *
1328c2ecf20Sopenharmony_ci * CPUCP_PACKET_PWM_GET -
1338c2ecf20Sopenharmony_ci *       Fetch the pwm value / mode of a specified pwm. The packet's
1348c2ecf20Sopenharmony_ci *       arguments specify the sensor and type.
1358c2ecf20Sopenharmony_ci *
1368c2ecf20Sopenharmony_ci * CPUCP_PACKET_PWM_SET -
1378c2ecf20Sopenharmony_ci *       Set the pwm value / mode of a specified pwm. The packet's
1388c2ecf20Sopenharmony_ci *       arguments specify the sensor, type and value.
1398c2ecf20Sopenharmony_ci *
1408c2ecf20Sopenharmony_ci * CPUCP_PACKET_FREQUENCY_SET -
1418c2ecf20Sopenharmony_ci *       Set the frequency of a specified PLL. The packet's arguments specify
1428c2ecf20Sopenharmony_ci *       the PLL and the desired frequency. The actual frequency in the device
1438c2ecf20Sopenharmony_ci *       might differ from the requested frequency.
1448c2ecf20Sopenharmony_ci *
1458c2ecf20Sopenharmony_ci * CPUCP_PACKET_FREQUENCY_GET -
1468c2ecf20Sopenharmony_ci *       Fetch the frequency of a specified PLL. The packet's arguments specify
1478c2ecf20Sopenharmony_ci *       the PLL.
1488c2ecf20Sopenharmony_ci *
1498c2ecf20Sopenharmony_ci * CPUCP_PACKET_LED_SET -
1508c2ecf20Sopenharmony_ci *       Set the state of a specified led. The packet's arguments
1518c2ecf20Sopenharmony_ci *       specify the led and the desired state.
1528c2ecf20Sopenharmony_ci *
1538c2ecf20Sopenharmony_ci * CPUCP_PACKET_I2C_WR -
1548c2ecf20Sopenharmony_ci *       Write 32-bit value to I2C device. The packet's arguments specify the
1558c2ecf20Sopenharmony_ci *       I2C bus, address and value.
1568c2ecf20Sopenharmony_ci *
1578c2ecf20Sopenharmony_ci * CPUCP_PACKET_I2C_RD -
1588c2ecf20Sopenharmony_ci *       Read 32-bit value from I2C device. The packet's arguments specify the
1598c2ecf20Sopenharmony_ci *       I2C bus and address.
1608c2ecf20Sopenharmony_ci *
1618c2ecf20Sopenharmony_ci * CPUCP_PACKET_INFO_GET -
1628c2ecf20Sopenharmony_ci *       Fetch information from the device as specified in the packet's
1638c2ecf20Sopenharmony_ci *       structure. The host's driver passes the max size it allows the CpuCP to
1648c2ecf20Sopenharmony_ci *       write to the structure, to prevent data corruption in case of
1658c2ecf20Sopenharmony_ci *       mismatched driver/FW versions.
1668c2ecf20Sopenharmony_ci *
1678c2ecf20Sopenharmony_ci * CPUCP_PACKET_FLASH_PROGRAM_REMOVED - this packet was removed
1688c2ecf20Sopenharmony_ci *
1698c2ecf20Sopenharmony_ci * CPUCP_PACKET_UNMASK_RAZWI_IRQ -
1708c2ecf20Sopenharmony_ci *       Unmask the given IRQ. The IRQ number is specified in the value field.
1718c2ecf20Sopenharmony_ci *       The packet is sent after receiving an interrupt and printing its
1728c2ecf20Sopenharmony_ci *       relevant information.
1738c2ecf20Sopenharmony_ci *
1748c2ecf20Sopenharmony_ci * CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY -
1758c2ecf20Sopenharmony_ci *       Unmask the given IRQs. The IRQs numbers are specified in an array right
1768c2ecf20Sopenharmony_ci *       after the cpucp_packet structure, where its first element is the array
1778c2ecf20Sopenharmony_ci *       length. The packet is sent after a soft reset was done in order to
1788c2ecf20Sopenharmony_ci *       handle any interrupts that were sent during the reset process.
1798c2ecf20Sopenharmony_ci *
1808c2ecf20Sopenharmony_ci * CPUCP_PACKET_TEST -
1818c2ecf20Sopenharmony_ci *       Test packet for CpuCP connectivity. The CPU will put the fence value
1828c2ecf20Sopenharmony_ci *       in the result field.
1838c2ecf20Sopenharmony_ci *
1848c2ecf20Sopenharmony_ci * CPUCP_PACKET_FREQUENCY_CURR_GET -
1858c2ecf20Sopenharmony_ci *       Fetch the current frequency of a specified PLL. The packet's arguments
1868c2ecf20Sopenharmony_ci *       specify the PLL.
1878c2ecf20Sopenharmony_ci *
1888c2ecf20Sopenharmony_ci * CPUCP_PACKET_MAX_POWER_GET -
1898c2ecf20Sopenharmony_ci *       Fetch the maximal power of the device.
1908c2ecf20Sopenharmony_ci *
1918c2ecf20Sopenharmony_ci * CPUCP_PACKET_MAX_POWER_SET -
1928c2ecf20Sopenharmony_ci *       Set the maximal power of the device. The packet's arguments specify
1938c2ecf20Sopenharmony_ci *       the power.
1948c2ecf20Sopenharmony_ci *
1958c2ecf20Sopenharmony_ci * CPUCP_PACKET_EEPROM_DATA_GET -
1968c2ecf20Sopenharmony_ci *       Get EEPROM data from the CpuCP kernel. The buffer is specified in the
1978c2ecf20Sopenharmony_ci *       addr field. The CPU will put the returned data size in the result
1988c2ecf20Sopenharmony_ci *       field. In addition, the host's driver passes the max size it allows the
1998c2ecf20Sopenharmony_ci *       CpuCP to write to the structure, to prevent data corruption in case of
2008c2ecf20Sopenharmony_ci *       mismatched driver/FW versions.
2018c2ecf20Sopenharmony_ci *
2028c2ecf20Sopenharmony_ci * CPUCP_PACKET_TEMPERATURE_SET -
2038c2ecf20Sopenharmony_ci *       Set the value of the offset property of a specified thermal sensor.
2048c2ecf20Sopenharmony_ci *       The packet's arguments specify the desired sensor and the field to
2058c2ecf20Sopenharmony_ci *       set.
2068c2ecf20Sopenharmony_ci *
2078c2ecf20Sopenharmony_ci * CPUCP_PACKET_VOLTAGE_SET -
2088c2ecf20Sopenharmony_ci *       Trigger the reset_history property of a specified voltage sensor.
2098c2ecf20Sopenharmony_ci *       The packet's arguments specify the desired sensor and the field to
2108c2ecf20Sopenharmony_ci *       set.
2118c2ecf20Sopenharmony_ci *
2128c2ecf20Sopenharmony_ci * CPUCP_PACKET_CURRENT_SET -
2138c2ecf20Sopenharmony_ci *       Trigger the reset_history property of a specified current sensor.
2148c2ecf20Sopenharmony_ci *       The packet's arguments specify the desired sensor and the field to
2158c2ecf20Sopenharmony_ci *       set.
2168c2ecf20Sopenharmony_ci *
2178c2ecf20Sopenharmony_ci * CPUCP_PACKET_PLL_REG_GET
2188c2ecf20Sopenharmony_ci *       Fetch register of PLL from the required PLL IP.
2198c2ecf20Sopenharmony_ci *       The packet's arguments specify the PLL IP and the register to get.
2208c2ecf20Sopenharmony_ci *       Each register is 32-bit value which is returned in result field.
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci */
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_cienum cpucp_packet_id {
2258c2ecf20Sopenharmony_ci	CPUCP_PACKET_DISABLE_PCI_ACCESS = 1,	/* internal */
2268c2ecf20Sopenharmony_ci	CPUCP_PACKET_ENABLE_PCI_ACCESS,		/* internal */
2278c2ecf20Sopenharmony_ci	CPUCP_PACKET_TEMPERATURE_GET,		/* sysfs */
2288c2ecf20Sopenharmony_ci	CPUCP_PACKET_VOLTAGE_GET,		/* sysfs */
2298c2ecf20Sopenharmony_ci	CPUCP_PACKET_CURRENT_GET,		/* sysfs */
2308c2ecf20Sopenharmony_ci	CPUCP_PACKET_FAN_SPEED_GET,		/* sysfs */
2318c2ecf20Sopenharmony_ci	CPUCP_PACKET_PWM_GET,			/* sysfs */
2328c2ecf20Sopenharmony_ci	CPUCP_PACKET_PWM_SET,			/* sysfs */
2338c2ecf20Sopenharmony_ci	CPUCP_PACKET_FREQUENCY_SET,		/* sysfs */
2348c2ecf20Sopenharmony_ci	CPUCP_PACKET_FREQUENCY_GET,		/* sysfs */
2358c2ecf20Sopenharmony_ci	CPUCP_PACKET_LED_SET,			/* debugfs */
2368c2ecf20Sopenharmony_ci	CPUCP_PACKET_I2C_WR,			/* debugfs */
2378c2ecf20Sopenharmony_ci	CPUCP_PACKET_I2C_RD,			/* debugfs */
2388c2ecf20Sopenharmony_ci	CPUCP_PACKET_INFO_GET,			/* IOCTL */
2398c2ecf20Sopenharmony_ci	CPUCP_PACKET_FLASH_PROGRAM_REMOVED,
2408c2ecf20Sopenharmony_ci	CPUCP_PACKET_UNMASK_RAZWI_IRQ,		/* internal */
2418c2ecf20Sopenharmony_ci	CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY,	/* internal */
2428c2ecf20Sopenharmony_ci	CPUCP_PACKET_TEST,			/* internal */
2438c2ecf20Sopenharmony_ci	CPUCP_PACKET_FREQUENCY_CURR_GET,	/* sysfs */
2448c2ecf20Sopenharmony_ci	CPUCP_PACKET_MAX_POWER_GET,		/* sysfs */
2458c2ecf20Sopenharmony_ci	CPUCP_PACKET_MAX_POWER_SET,		/* sysfs */
2468c2ecf20Sopenharmony_ci	CPUCP_PACKET_EEPROM_DATA_GET,		/* sysfs */
2478c2ecf20Sopenharmony_ci	CPUCP_RESERVED,
2488c2ecf20Sopenharmony_ci	CPUCP_PACKET_TEMPERATURE_SET,		/* sysfs */
2498c2ecf20Sopenharmony_ci	CPUCP_PACKET_VOLTAGE_SET,		/* sysfs */
2508c2ecf20Sopenharmony_ci	CPUCP_PACKET_CURRENT_SET,		/* sysfs */
2518c2ecf20Sopenharmony_ci	CPUCP_PACKET_PCIE_THROUGHPUT_GET,		/* internal */
2528c2ecf20Sopenharmony_ci	CPUCP_PACKET_PCIE_REPLAY_CNT_GET,		/* internal */
2538c2ecf20Sopenharmony_ci	CPUCP_PACKET_TOTAL_ENERGY_GET,		/* internal */
2548c2ecf20Sopenharmony_ci	CPUCP_PACKET_PLL_REG_GET,		/* internal */
2558c2ecf20Sopenharmony_ci};
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci#define CPUCP_PACKET_FENCE_VAL	0xFE8CE7A5
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci#define CPUCP_PKT_CTL_RC_SHIFT		12
2608c2ecf20Sopenharmony_ci#define CPUCP_PKT_CTL_RC_MASK		0x0000F000
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci#define CPUCP_PKT_CTL_OPCODE_SHIFT	16
2638c2ecf20Sopenharmony_ci#define CPUCP_PKT_CTL_OPCODE_MASK	0x1FFF0000
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistruct cpucp_packet {
2668c2ecf20Sopenharmony_ci	union {
2678c2ecf20Sopenharmony_ci		__le64 value;	/* For SET packets */
2688c2ecf20Sopenharmony_ci		__le64 result;	/* For GET packets */
2698c2ecf20Sopenharmony_ci		__le64 addr;	/* For PQ */
2708c2ecf20Sopenharmony_ci	};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	__le32 ctl;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	__le32 fence;		/* Signal to host that message is completed */
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	union {
2778c2ecf20Sopenharmony_ci		struct {/* For temperature/current/voltage/fan/pwm get/set */
2788c2ecf20Sopenharmony_ci			__le16 sensor_index;
2798c2ecf20Sopenharmony_ci			__le16 type;
2808c2ecf20Sopenharmony_ci		};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci		struct {	/* For I2C read/write */
2838c2ecf20Sopenharmony_ci			__u8 i2c_bus;
2848c2ecf20Sopenharmony_ci			__u8 i2c_addr;
2858c2ecf20Sopenharmony_ci			__u8 i2c_reg;
2868c2ecf20Sopenharmony_ci			__u8 pad; /* unused */
2878c2ecf20Sopenharmony_ci		};
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci		struct {/* For PLL register fetch */
2908c2ecf20Sopenharmony_ci			__le16 pll_type;
2918c2ecf20Sopenharmony_ci			__le16 pll_reg;
2928c2ecf20Sopenharmony_ci		};
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci		/* For any general request */
2958c2ecf20Sopenharmony_ci		__le32 index;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci		/* For frequency get/set */
2988c2ecf20Sopenharmony_ci		__le32 pll_index;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci		/* For led set */
3018c2ecf20Sopenharmony_ci		__le32 led_index;
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci		/* For get CpuCP info/EEPROM data */
3048c2ecf20Sopenharmony_ci		__le32 data_max_size;
3058c2ecf20Sopenharmony_ci	};
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	__le32 reserved;
3088c2ecf20Sopenharmony_ci};
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_cistruct cpucp_unmask_irq_arr_packet {
3118c2ecf20Sopenharmony_ci	struct cpucp_packet cpucp_pkt;
3128c2ecf20Sopenharmony_ci	__le32 length;
3138c2ecf20Sopenharmony_ci	__le32 irqs[0];
3148c2ecf20Sopenharmony_ci};
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cienum cpucp_packet_rc {
3178c2ecf20Sopenharmony_ci	cpucp_packet_success,
3188c2ecf20Sopenharmony_ci	cpucp_packet_invalid,
3198c2ecf20Sopenharmony_ci	cpucp_packet_fault
3208c2ecf20Sopenharmony_ci};
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/*
3238c2ecf20Sopenharmony_ci * cpucp_temp_type should adhere to hwmon_temp_attributes
3248c2ecf20Sopenharmony_ci * defined in Linux kernel hwmon.h file
3258c2ecf20Sopenharmony_ci */
3268c2ecf20Sopenharmony_cienum cpucp_temp_type {
3278c2ecf20Sopenharmony_ci	cpucp_temp_input,
3288c2ecf20Sopenharmony_ci	cpucp_temp_max = 6,
3298c2ecf20Sopenharmony_ci	cpucp_temp_max_hyst,
3308c2ecf20Sopenharmony_ci	cpucp_temp_crit,
3318c2ecf20Sopenharmony_ci	cpucp_temp_crit_hyst,
3328c2ecf20Sopenharmony_ci	cpucp_temp_offset = 19,
3338c2ecf20Sopenharmony_ci	cpucp_temp_highest = 22,
3348c2ecf20Sopenharmony_ci	cpucp_temp_reset_history = 23
3358c2ecf20Sopenharmony_ci};
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_cienum cpucp_in_attributes {
3388c2ecf20Sopenharmony_ci	cpucp_in_input,
3398c2ecf20Sopenharmony_ci	cpucp_in_min,
3408c2ecf20Sopenharmony_ci	cpucp_in_max,
3418c2ecf20Sopenharmony_ci	cpucp_in_highest = 7,
3428c2ecf20Sopenharmony_ci	cpucp_in_reset_history
3438c2ecf20Sopenharmony_ci};
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_cienum cpucp_curr_attributes {
3468c2ecf20Sopenharmony_ci	cpucp_curr_input,
3478c2ecf20Sopenharmony_ci	cpucp_curr_min,
3488c2ecf20Sopenharmony_ci	cpucp_curr_max,
3498c2ecf20Sopenharmony_ci	cpucp_curr_highest = 7,
3508c2ecf20Sopenharmony_ci	cpucp_curr_reset_history
3518c2ecf20Sopenharmony_ci};
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_cienum cpucp_fan_attributes {
3548c2ecf20Sopenharmony_ci	cpucp_fan_input,
3558c2ecf20Sopenharmony_ci	cpucp_fan_min = 2,
3568c2ecf20Sopenharmony_ci	cpucp_fan_max
3578c2ecf20Sopenharmony_ci};
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_cienum cpucp_pwm_attributes {
3608c2ecf20Sopenharmony_ci	cpucp_pwm_input,
3618c2ecf20Sopenharmony_ci	cpucp_pwm_enable
3628c2ecf20Sopenharmony_ci};
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_cienum cpucp_pcie_throughput_attributes {
3658c2ecf20Sopenharmony_ci	cpucp_pcie_throughput_tx,
3668c2ecf20Sopenharmony_ci	cpucp_pcie_throughput_rx
3678c2ecf20Sopenharmony_ci};
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_cienum cpucp_pll_reg_attributes {
3708c2ecf20Sopenharmony_ci	cpucp_pll_nr_reg,
3718c2ecf20Sopenharmony_ci	cpucp_pll_nf_reg,
3728c2ecf20Sopenharmony_ci	cpucp_pll_od_reg,
3738c2ecf20Sopenharmony_ci	cpucp_pll_div_factor_reg,
3748c2ecf20Sopenharmony_ci	cpucp_pll_div_sel_reg
3758c2ecf20Sopenharmony_ci};
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_cienum cpucp_pll_type_attributes {
3788c2ecf20Sopenharmony_ci	cpucp_pll_cpu,
3798c2ecf20Sopenharmony_ci	cpucp_pll_pci,
3808c2ecf20Sopenharmony_ci};
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci/* Event Queue Packets */
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_cistruct eq_generic_event {
3858c2ecf20Sopenharmony_ci	__le64 data[7];
3868c2ecf20Sopenharmony_ci};
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci/*
3898c2ecf20Sopenharmony_ci * CpuCP info
3908c2ecf20Sopenharmony_ci */
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci#define CARD_NAME_MAX_LEN		16
3938c2ecf20Sopenharmony_ci#define VERSION_MAX_LEN			128
3948c2ecf20Sopenharmony_ci#define CPUCP_MAX_SENSORS		128
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistruct cpucp_sensor {
3978c2ecf20Sopenharmony_ci	__le32 type;
3988c2ecf20Sopenharmony_ci	__le32 flags;
3998c2ecf20Sopenharmony_ci};
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci/**
4028c2ecf20Sopenharmony_ci * struct cpucp_card_types - ASIC card type.
4038c2ecf20Sopenharmony_ci * @cpucp_card_type_pci: PCI card.
4048c2ecf20Sopenharmony_ci * @cpucp_card_type_pmc: PCI Mezzanine Card.
4058c2ecf20Sopenharmony_ci */
4068c2ecf20Sopenharmony_cienum cpucp_card_types {
4078c2ecf20Sopenharmony_ci	cpucp_card_type_pci,
4088c2ecf20Sopenharmony_ci	cpucp_card_type_pmc
4098c2ecf20Sopenharmony_ci};
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci/**
4128c2ecf20Sopenharmony_ci * struct cpucp_info - Info from CpuCP that is necessary to the host's driver
4138c2ecf20Sopenharmony_ci * @sensors: available sensors description.
4148c2ecf20Sopenharmony_ci * @kernel_version: CpuCP linux kernel version.
4158c2ecf20Sopenharmony_ci * @reserved: reserved field.
4168c2ecf20Sopenharmony_ci * @card_type: card configuration type.
4178c2ecf20Sopenharmony_ci * @card_location: in a server, each card has different connections topology
4188c2ecf20Sopenharmony_ci *                 depending on its location (relevant for PMC card type)
4198c2ecf20Sopenharmony_ci * @cpld_version: CPLD programmed F/W version.
4208c2ecf20Sopenharmony_ci * @infineon_version: Infineon main DC-DC version.
4218c2ecf20Sopenharmony_ci * @fuse_version: silicon production FUSE information.
4228c2ecf20Sopenharmony_ci * @thermal_version: thermald S/W version.
4238c2ecf20Sopenharmony_ci * @cpucp_version: CpuCP S/W version.
4248c2ecf20Sopenharmony_ci * @dram_size: available DRAM size.
4258c2ecf20Sopenharmony_ci * @card_name: card name that will be displayed in HWMON subsystem on the host
4268c2ecf20Sopenharmony_ci */
4278c2ecf20Sopenharmony_cistruct cpucp_info {
4288c2ecf20Sopenharmony_ci	struct cpucp_sensor sensors[CPUCP_MAX_SENSORS];
4298c2ecf20Sopenharmony_ci	__u8 kernel_version[VERSION_MAX_LEN];
4308c2ecf20Sopenharmony_ci	__le32 reserved;
4318c2ecf20Sopenharmony_ci	__le32 card_type;
4328c2ecf20Sopenharmony_ci	__le32 card_location;
4338c2ecf20Sopenharmony_ci	__le32 cpld_version;
4348c2ecf20Sopenharmony_ci	__le32 infineon_version;
4358c2ecf20Sopenharmony_ci	__u8 fuse_version[VERSION_MAX_LEN];
4368c2ecf20Sopenharmony_ci	__u8 thermal_version[VERSION_MAX_LEN];
4378c2ecf20Sopenharmony_ci	__u8 cpucp_version[VERSION_MAX_LEN];
4388c2ecf20Sopenharmony_ci	__le32 reserved2;
4398c2ecf20Sopenharmony_ci	__le64 dram_size;
4408c2ecf20Sopenharmony_ci	char card_name[CARD_NAME_MAX_LEN];
4418c2ecf20Sopenharmony_ci};
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci#endif /* CPUCP_IF_H */
444