1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2023 Hisilicon Limited. */
4 #ifndef __KUNPENG_HCCS_H__
5 #define __KUNPENG_HCCS_H__
8 * |--------------- Chip0 ---------------|---------------- ChipN -------------|
9 * |--------Die0-------|--------DieN-------|--------Die0-------|-------DieN-------|
10 * | P0 | P1 | P2 | P3 | P0 | P1 | P2 | P3 | P0 | P1 | P2 | P3 |P0 | P1 | P2 | P3 |
18 #define HCCS_IP_PREFIX "HCCS-v"
19 #define HCCS_IP_MAX 255
20 #define HCCS_NAME_MAX_LEN 9
21 struct hccs_type_name_map {
23 char name[HCCS_NAME_MAX_LEN + 1];
27 * This value cannot be 255, otherwise the loop of the multi-BD communication
30 #define HCCS_DIE_MAX_PORT_ID 254
32 struct hccs_port_info {
36 bool enable; /* if the port is enabled */
39 struct hccs_die_info *die; /* point to the die the port is located */
42 struct hccs_die_info {
47 struct hccs_port_info *ports;
50 struct hccs_chip_info *chip; /* point to the chip the die is located */
53 struct hccs_chip_info {
56 struct hccs_die_info *dies;
58 struct hccs_dev *hdev;
61 struct hccs_mbox_client_info {
62 struct mbox_client client;
63 struct mbox_chan *mbox_chan;
64 struct pcc_mbox_chan *pcc_chan;
66 void __iomem *pcc_comm_addr;
67 struct completion done;
72 struct hccs_verspecific_data {
73 void (*rx_callback)(struct mbox_client *cl, void *mssg);
74 int (*wait_cmd_complete)(struct hccs_dev *hdev);
75 void (*fill_pcc_shared_mem)(struct hccs_dev *hdev,
76 u8 cmd, struct hccs_desc *desc,
77 void __iomem *comm_space,
83 #define HCCS_CAPS_HCCS_V2_PM BIT_ULL(0)
87 struct acpi_device *acpi_dev;
88 const struct hccs_verspecific_data *verspec_data;
89 /* device capabilities from firmware, like HCCS_CAPS_xxx. */
92 struct hccs_chip_info *chips;
94 struct hccs_type_name_map *type_name_maps;
97 struct hccs_mbox_client_info cl_info;
100 #define HCCS_SERDES_MODULE_CODE 0x32
101 enum hccs_subcmd_type {
102 HCCS_GET_CHIP_NUM = 0x1,
105 HCCS_GET_DIE_PORT_INFO,
107 HCCS_GET_PORT_LINK_STATUS,
108 HCCS_GET_PORT_CRC_ERR_CNT,
109 HCCS_GET_DIE_PORTS_LANE_STA,
110 HCCS_GET_DIE_PORTS_LINK_STA,
111 HCCS_GET_DIE_PORTS_CRC_ERR_CNT,
112 HCCS_GET_PORT_IDLE_STATUS,
115 HCCS_SUB_CMD_MAX = 255,
118 struct hccs_die_num_req_param {
122 struct hccs_die_info_req_param {
127 struct hccs_die_info_rsp_data {
134 struct hccs_port_attr {
138 u8 enable : 1; /* if the port is enabled */
143 * The common command request for getting the information of all HCCS port on
146 struct hccs_die_comm_req_param {
148 u8 die_id; /* id in hardware */
151 /* The common command request for getting the information of a specific port */
152 struct hccs_port_comm_req_param {
158 #define HCCS_PREPARE_INC_LANE 1
159 #define HCCS_GET_ADAPT_RES 2
160 #define HCCS_START_RETRAINING 3
161 struct hccs_inc_lane_req_param {
166 #define HCCS_PORT_RESET 1
167 #define HCCS_PORT_SETUP 2
168 #define HCCS_PORT_CONFIG 3
169 #define HCCS_PORT_READY 4
170 struct hccs_link_status {
171 u8 lane_mask; /* indicate which lanes are used. */
172 u8 link_fsm : 3; /* link fsm, 1: reset 2: setup 3: config 4: link-up */
173 u8 lane_num : 5; /* current lane number */
176 struct hccs_req_head {
177 u8 module_code; /* set to 0x32 for serdes */
182 struct hccs_rsp_head {
188 struct hccs_fw_inner_head {
189 u8 retStatus; /* 0: success, other: failure */
193 #define HCCS_PCC_SHARE_MEM_BYTES 64
194 #define HCCS_FW_INNER_HEAD_BYTES 8
195 #define HCCS_RSP_HEAD_BYTES 4
197 #define HCCS_MAX_RSP_DATA_BYTES (HCCS_PCC_SHARE_MEM_BYTES - \
198 HCCS_FW_INNER_HEAD_BYTES - \
200 #define HCCS_MAX_RSP_DATA_SIZE_MAX (HCCS_MAX_RSP_DATA_BYTES / 4)
203 * Note: Actual available size of data field also depands on the PCC header
204 * bytes of the specific type. Driver needs to copy the response data in the
205 * communication space based on the real length.
207 struct hccs_rsp_desc {
208 struct hccs_fw_inner_head fw_inner_head; /* 8 Bytes */
209 struct hccs_rsp_head rsp_head; /* 4 Bytes */
210 u32 data[HCCS_MAX_RSP_DATA_SIZE_MAX];
213 #define HCCS_REQ_HEAD_BYTES 4
214 #define HCCS_MAX_REQ_DATA_BYTES (HCCS_PCC_SHARE_MEM_BYTES - \
216 #define HCCS_MAX_REQ_DATA_SIZE_MAX (HCCS_MAX_REQ_DATA_BYTES / 4)
219 * Note: Actual available size of data field also depands on the PCC header
220 * bytes of the specific type. Driver needs to copy the request data to the
221 * communication space based on the real length.
223 struct hccs_req_desc {
224 struct hccs_req_head req_head; /* 4 Bytes */
225 u32 data[HCCS_MAX_REQ_DATA_SIZE_MAX];
230 struct hccs_req_desc req;
231 struct hccs_rsp_desc rsp;
235 #endif /* __KUNPENG_HCCS_H__ */