Lines Matching defs:hdev
86 static int hccs_get_pcc_chan_id(struct hccs_dev *hdev)
88 acpi_handle handle = ACPI_HANDLE(hdev->dev);
95 ctx.dev = hdev->dev;
100 hdev->chan_id = ctx.chan_id;
115 static void hccs_unregister_pcc_channel(struct hccs_dev *hdev)
117 struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
121 pcc_mbox_free_channel(hdev->cl_info.pcc_chan);
124 static int hccs_register_pcc_channel(struct hccs_dev *hdev)
126 struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
129 struct device *dev = hdev->dev;
136 pcc_chan = pcc_mbox_request_channel(cl, hdev->chan_id);
163 hdev->chan_id);
177 static int hccs_check_chan_cmd_complete(struct hccs_dev *hdev)
179 struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
194 dev_err(hdev->dev, "poll PCC status failed, ret = %d.\n", ret);
199 static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd,
202 struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
211 tmp.signature = HCCS_PCC_SIGNATURE_MASK | hdev->chan_id;
227 dev_err(hdev->dev, "Send PCC mbox message failed, ret = %d.\n",
233 ret = hccs_check_chan_cmd_complete(hdev);
241 dev_err(hdev->dev, "Execute PCC command failed, error code = %u.\n",
259 static int hccs_get_dev_caps(struct hccs_dev *hdev)
265 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_DEV_CAP, &desc);
267 dev_err(hdev->dev, "Get device capabilities failed, ret = %d.\n",
271 memcpy(&hdev->caps, desc.rsp.data, sizeof(hdev->caps));
276 static int hccs_query_chip_num_on_platform(struct hccs_dev *hdev)
282 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_CHIP_NUM, &desc);
284 dev_err(hdev->dev, "query system chip number failed, ret = %d.\n",
289 hdev->chip_num = *((u8 *)&desc.rsp.data);
290 if (!hdev->chip_num) {
291 dev_err(hdev->dev, "chip num obtained from firmware is zero.\n");
298 static int hccs_get_chip_info(struct hccs_dev *hdev,
308 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_DIE_NUM, &desc);
317 static int hccs_query_chip_info_on_platform(struct hccs_dev *hdev)
323 ret = hccs_query_chip_num_on_platform(hdev);
325 dev_err(hdev->dev, "query chip number on platform failed, ret = %d.\n",
330 hdev->chips = devm_kzalloc(hdev->dev,
331 hdev->chip_num * sizeof(struct hccs_chip_info),
333 if (!hdev->chips) {
334 dev_err(hdev->dev, "allocate all chips memory failed.\n");
338 for (idx = 0; idx < hdev->chip_num; idx++) {
339 chip = &hdev->chips[idx];
341 ret = hccs_get_chip_info(hdev, chip);
343 dev_err(hdev->dev, "get chip%u info failed, ret = %d.\n",
347 chip->hdev = hdev;
353 static int hccs_query_die_info_on_chip(struct hccs_dev *hdev, u8 chip_id,
365 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_DIE_INFO, &desc);
375 dev_err(hdev->dev, "min port id(%u) > max port id(%u) on die_idx(%u).\n",
380 dev_err(hdev->dev, "max port id(%u) on die_idx(%u) is too big.\n",
388 static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
390 struct device *dev = hdev->dev;
396 for (i = 0; i < hdev->chip_num; i++) {
397 chip = &hdev->chips[i];
401 chip->dies = devm_kzalloc(hdev->dev,
412 ret = hccs_query_die_info_on_chip(hdev, i, j, die);
425 static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
434 ret = hccs_pcc_cmd_send(hdev, opcode, desc);
441 dev_err(hdev->dev,
453 static int hccs_get_all_port_attr(struct hccs_dev *hdev,
478 ret = hccs_get_bd_info(hdev, HCCS_GET_DIE_PORT_INFO, &desc,
481 dev_err(hdev->dev,
490 dev_err(hdev->dev,
501 static int hccs_get_all_port_info_on_die(struct hccs_dev *hdev,
514 ret = hccs_get_all_port_attr(hdev, die, attrs, die->port_num);
532 static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
535 struct device *dev = hdev->dev;
541 for (i = 0; i < hdev->chip_num; i++) {
542 chip = &hdev->chips[i];
557 ret = hccs_get_all_port_info_on_die(hdev, die);
569 static int hccs_get_hw_info(struct hccs_dev *hdev)
573 ret = hccs_query_chip_info_on_platform(hdev);
575 dev_err(hdev->dev, "query chip info on platform failed, ret = %d.\n",
580 ret = hccs_query_all_die_info_on_platform(hdev);
582 dev_err(hdev->dev, "query all die info on platform failed, ret = %d.\n",
587 ret = hccs_query_all_port_info_on_platform(hdev);
589 dev_err(hdev->dev, "query all port info on platform failed, ret = %d.\n",
597 static int hccs_query_port_link_status(struct hccs_dev *hdev,
612 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_PORT_LINK_STATUS, &desc);
614 dev_err(hdev->dev,
624 static int hccs_query_port_crc_err_cnt(struct hccs_dev *hdev,
639 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_PORT_CRC_ERR_CNT, &desc);
641 dev_err(hdev->dev,
651 static int hccs_get_die_all_link_status(struct hccs_dev *hdev,
668 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_DIE_PORTS_LINK_STA, &desc);
670 dev_err(hdev->dev,
681 static int hccs_get_die_all_port_lane_status(struct hccs_dev *hdev,
698 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_DIE_PORTS_LANE_STA, &desc);
700 dev_err(hdev->dev, "get lane status of all ports failed on die%u, ret = %d.\n",
710 static int hccs_get_die_total_crc_err_cnt(struct hccs_dev *hdev,
727 ret = hccs_pcc_cmd_send(hdev, HCCS_GET_DIE_PORTS_CRC_ERR_CNT, &desc);
729 dev_err(hdev->dev, "get crc error count sum failed on die%u, ret = %d.\n",
783 struct hccs_dev *hdev = port->die->chip->hdev;
787 mutex_lock(&hdev->lock);
788 ret = hccs_query_port_link_status(hdev, port, &link_status);
789 mutex_unlock(&hdev->lock);
801 struct hccs_dev *hdev = port->die->chip->hdev;
816 mutex_lock(&hdev->lock);
817 ret = hccs_query_port_link_status(hdev, port, &link_status);
818 mutex_unlock(&hdev->lock);
837 struct hccs_dev *hdev = port->die->chip->hdev;
841 mutex_lock(&hdev->lock);
842 ret = hccs_query_port_link_status(hdev, port, &link_status);
843 mutex_unlock(&hdev->lock);
855 struct hccs_dev *hdev = port->die->chip->hdev;
859 mutex_lock(&hdev->lock);
860 ret = hccs_query_port_crc_err_cnt(hdev, port, &crc_err_cnt);
861 mutex_unlock(&hdev->lock);
890 struct hccs_dev *hdev = die->chip->hdev;
894 mutex_lock(&hdev->lock);
895 ret = hccs_get_die_all_link_status(hdev, die, &all_linked);
896 mutex_unlock(&hdev->lock);
910 struct hccs_dev *hdev = die->chip->hdev;
914 mutex_lock(&hdev->lock);
915 ret = hccs_get_die_all_port_lane_status(hdev, die, &full_lane);
916 mutex_unlock(&hdev->lock);
930 struct hccs_dev *hdev = die->chip->hdev;
934 mutex_lock(&hdev->lock);
935 ret = hccs_get_die_total_crc_err_cnt(hdev, die, &total_crc_err_cnt);
936 mutex_unlock(&hdev->lock);
962 struct hccs_dev *hdev = chip->hdev;
968 mutex_lock(&hdev->lock);
971 ret = hccs_get_die_all_link_status(hdev, die, &tmp);
973 mutex_unlock(&hdev->lock);
981 mutex_unlock(&hdev->lock);
993 struct hccs_dev *hdev = chip->hdev;
999 mutex_lock(&hdev->lock);
1002 ret = hccs_get_die_all_port_lane_status(hdev, die, &tmp);
1004 mutex_unlock(&hdev->lock);
1012 mutex_unlock(&hdev->lock);
1025 struct hccs_dev *hdev = chip->hdev;
1030 mutex_lock(&hdev->lock);
1033 ret = hccs_get_die_total_crc_err_cnt(hdev, die, &crc_err_cnt);
1035 mutex_unlock(&hdev->lock);
1041 mutex_unlock(&hdev->lock);
1089 static void hccs_remove_topo_dirs(struct hccs_dev *hdev)
1093 for (i = 0; i < hdev->chip_num; i++)
1094 hccs_remove_chip_dir(&hdev->chips[i]);
1097 static int hccs_create_hccs_dir(struct hccs_dev *hdev,
1113 static int hccs_create_die_dir(struct hccs_dev *hdev,
1130 ret = hccs_create_hccs_dir(hdev, die, port);
1132 dev_err(hdev->dev, "create hccs%d dir failed.\n",
1146 static int hccs_create_chip_dir(struct hccs_dev *hdev,
1154 &hdev->dev->kobj, "chip%d", chip->chip_id);
1162 ret = hccs_create_die_dir(hdev, chip, die);
1175 static int hccs_create_topo_dirs(struct hccs_dev *hdev)
1181 for (id = 0; id < hdev->chip_num; id++) {
1182 chip = &hdev->chips[id];
1183 ret = hccs_create_chip_dir(hdev, chip);
1185 dev_err(hdev->dev, "init chip%d dir failed!\n", id);
1193 hccs_remove_chip_dir(&hdev->chips[k]);
1201 struct hccs_dev *hdev;
1212 hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL);
1213 if (!hdev)
1215 hdev->acpi_dev = acpi_dev;
1216 hdev->dev = &pdev->dev;
1217 platform_set_drvdata(pdev, hdev);
1219 mutex_init(&hdev->lock);
1220 rc = hccs_get_pcc_chan_id(hdev);
1223 rc = hccs_register_pcc_channel(hdev);
1227 rc = hccs_get_dev_caps(hdev);
1231 rc = hccs_get_hw_info(hdev);
1235 rc = hccs_create_topo_dirs(hdev);
1242 hccs_unregister_pcc_channel(hdev);
1249 struct hccs_dev *hdev = platform_get_drvdata(pdev);
1251 hccs_remove_topo_dirs(hdev);
1252 hccs_unregister_pcc_channel(hdev);