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 |
14 * This value cannot be 255, otherwise the loop of the multi-BD communication
17 #define HCCS_DIE_MAX_PORT_ID 254
19 struct hccs_port_info {
23 bool enable; /* if the port is enabled */
26 struct hccs_die_info *die; /* point to the die the port is located */
29 struct hccs_die_info {
34 struct hccs_port_info *ports;
37 struct hccs_chip_info *chip; /* point to the chip the die is located */
40 struct hccs_chip_info {
43 struct hccs_die_info *dies;
45 struct hccs_dev *hdev;
48 struct hccs_mbox_client_info {
49 struct mbox_client client;
50 struct mbox_chan *mbox_chan;
51 struct pcc_mbox_chan *pcc_chan;
53 void __iomem *pcc_comm_addr;
54 struct completion done;
59 struct hccs_verspecific_data {
60 void (*rx_callback)(struct mbox_client *cl, void *mssg);
61 int (*wait_cmd_complete)(struct hccs_dev *hdev);
62 void (*fill_pcc_shared_mem)(struct hccs_dev *hdev,
63 u8 cmd, struct hccs_desc *desc,
64 void __iomem *comm_space,
72 struct acpi_device *acpi_dev;
73 const struct hccs_verspecific_data *verspec_data;
76 struct hccs_chip_info *chips;
79 struct hccs_mbox_client_info cl_info;
82 #define HCCS_SERDES_MODULE_CODE 0x32
83 enum hccs_subcmd_type {
84 HCCS_GET_CHIP_NUM = 0x1,
87 HCCS_GET_DIE_PORT_INFO,
89 HCCS_GET_PORT_LINK_STATUS,
90 HCCS_GET_PORT_CRC_ERR_CNT,
91 HCCS_GET_DIE_PORTS_LANE_STA,
92 HCCS_GET_DIE_PORTS_LINK_STA,
93 HCCS_GET_DIE_PORTS_CRC_ERR_CNT,
94 HCCS_SUB_CMD_MAX = 255,
97 struct hccs_die_num_req_param {
101 struct hccs_die_info_req_param {
106 struct hccs_die_info_rsp_data {
113 struct hccs_port_attr {
117 u8 enable : 1; /* if the port is enabled */
122 * The common command request for getting the information of all HCCS port on
125 struct hccs_die_comm_req_param {
127 u8 die_id; /* id in hardware */
130 /* The common command request for getting the information of a specific port */
131 struct hccs_port_comm_req_param {
137 #define HCCS_PORT_RESET 1
138 #define HCCS_PORT_SETUP 2
139 #define HCCS_PORT_CONFIG 3
140 #define HCCS_PORT_READY 4
141 struct hccs_link_status {
142 u8 lane_mask; /* indicate which lanes are used. */
143 u8 link_fsm : 3; /* link fsm, 1: reset 2: setup 3: config 4: link-up */
144 u8 lane_num : 5; /* current lane number */
147 struct hccs_req_head {
148 u8 module_code; /* set to 0x32 for serdes */
153 struct hccs_rsp_head {
159 struct hccs_fw_inner_head {
160 u8 retStatus; /* 0: success, other: failure */
164 #define HCCS_PCC_SHARE_MEM_BYTES 64
165 #define HCCS_FW_INNER_HEAD_BYTES 8
166 #define HCCS_RSP_HEAD_BYTES 4
168 #define HCCS_MAX_RSP_DATA_BYTES (HCCS_PCC_SHARE_MEM_BYTES - \
169 HCCS_FW_INNER_HEAD_BYTES - \
171 #define HCCS_MAX_RSP_DATA_SIZE_MAX (HCCS_MAX_RSP_DATA_BYTES / 4)
174 * Note: Actual available size of data field also depands on the PCC header
175 * bytes of the specific type. Driver needs to copy the response data in the
176 * communication space based on the real length.
178 struct hccs_rsp_desc {
179 struct hccs_fw_inner_head fw_inner_head; /* 8 Bytes */
180 struct hccs_rsp_head rsp_head; /* 4 Bytes */
181 u32 data[HCCS_MAX_RSP_DATA_SIZE_MAX];
184 #define HCCS_REQ_HEAD_BYTES 4
185 #define HCCS_MAX_REQ_DATA_BYTES (HCCS_PCC_SHARE_MEM_BYTES - \
187 #define HCCS_MAX_REQ_DATA_SIZE_MAX (HCCS_MAX_REQ_DATA_BYTES / 4)
190 * Note: Actual available size of data field also depands on the PCC header
191 * bytes of the specific type. Driver needs to copy the request data to the
192 * communication space based on the real length.
194 struct hccs_req_desc {
195 struct hccs_req_head req_head; /* 4 Bytes */
196 u32 data[HCCS_MAX_REQ_DATA_SIZE_MAX];
201 struct hccs_req_desc req;
202 struct hccs_rsp_desc rsp;
206 #endif /* __KUNPENG_HCCS_H__ */