Lines Matching +full:binary +full:- +full:coded

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2021 HabanaLabs, Ltd.
28 str = strnstr(fw_str, "fw-", VERSION_MAX_LEN); in extract_fw_ver_from_str()
32 /* Skip the fw- part */ in extract_fw_ver_from_str()
40 strscpy(fw_ver, str, whitespace - str + 1); in extract_fw_ver_from_str()
56 rc = request_firmware(firmware_p, fw_name, hdev->dev); in hl_request_fw()
58 dev_err(hdev->dev, "Firmware file %s is not found! (error %d)\n", in hl_request_fw()
63 fw_size = (*firmware_p)->size; in hl_request_fw()
65 dev_err(hdev->dev, "Illegal %s firmware size %zu\n", in hl_request_fw()
67 rc = -EINVAL; in hl_request_fw()
71 dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size); in hl_request_fw()
74 dev_err(hdev->dev, in hl_request_fw()
77 rc = -EINVAL; in hl_request_fw()
90 * hl_release_firmware() - release FW
103 * hl_fw_copy_fw_to_device() - copy FW to device
109 * @size: amount of bytes to copy (0 to copy the whole binary)
111 * actual copy of FW binary data to device, shared by static and dynamic loaders
121 size = fw->size; in hl_fw_copy_fw_to_device()
123 if (src_offset + size > fw->size) { in hl_fw_copy_fw_to_device()
124 dev_err(hdev->dev, in hl_fw_copy_fw_to_device()
127 return -EINVAL; in hl_fw_copy_fw_to_device()
130 fw_data = (const void *) fw->data; in hl_fw_copy_fw_to_device()
137 * hl_fw_copy_msg_to_device() - copy message to device
143 * @size: amount of bytes to copy (0 to copy the whole binary)
158 dev_err(hdev->dev, in hl_fw_copy_msg_to_device()
161 return -EINVAL; in hl_fw_copy_msg_to_device()
172 * hl_fw_load_fw_to_device() - Load F/W code to device's memory.
178 * @size: amount of bytes to copy (0 to copy the whole binary)
182 * Return: 0 on success, non-zero for failure.
206 return hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, in hl_fw_send_pci_access_msg()
213 struct hl_hw_queue *queue = &hdev->kernel_queues[hw_queue_id]; in hl_fw_send_cpu_message()
214 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_send_cpu_message()
220 pkt = hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, len, in hl_fw_send_cpu_message()
223 dev_err(hdev->dev, in hl_fw_send_cpu_message()
225 return -ENOMEM; in hl_fw_send_cpu_message()
230 mutex_lock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
232 if (hdev->disabled) in hl_fw_send_cpu_message()
235 if (hdev->device_cpu_disabled) { in hl_fw_send_cpu_message()
236 rc = -EIO; in hl_fw_send_cpu_message()
241 pkt->fence = cpu_to_le32(UINT_MAX); in hl_fw_send_cpu_message()
253 if (prop->fw_app_cpu_boot_dev_sts0 & CPU_BOOT_DEV_STS0_PKT_PI_ACK_EN) in hl_fw_send_cpu_message()
254 expected_ack_val = queue->pi; in hl_fw_send_cpu_message()
258 rc = hl_poll_timeout_memory(hdev, &pkt->fence, tmp, in hl_fw_send_cpu_message()
264 if (rc == -ETIMEDOUT) { in hl_fw_send_cpu_message()
265 dev_err(hdev->dev, "Device CPU packet timeout (0x%x)\n", tmp); in hl_fw_send_cpu_message()
266 hdev->device_cpu_disabled = true; in hl_fw_send_cpu_message()
270 tmp = le32_to_cpu(pkt->ctl); in hl_fw_send_cpu_message()
274 dev_err(hdev->dev, "F/W ERROR %d for CPU packet %d\n", in hl_fw_send_cpu_message()
278 rc = -EIO; in hl_fw_send_cpu_message()
280 *result = le64_to_cpu(pkt->result); in hl_fw_send_cpu_message()
284 mutex_unlock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
286 hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev, len, pkt); in hl_fw_send_cpu_message()
303 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_unmask_irq()
307 dev_err(hdev->dev, "failed to unmask RAZWI IRQ %d", event_type); in hl_fw_unmask_irq()
323 /* data should be aligned to 8 bytes in order to CPU-CP to copy it */ in hl_fw_unmask_irq_arr()
328 dev_err(hdev->dev, "too many elements in IRQ array\n"); in hl_fw_unmask_irq_arr()
329 return -EINVAL; in hl_fw_unmask_irq_arr()
334 return -ENOMEM; in hl_fw_unmask_irq_arr()
336 pkt->length = cpu_to_le32(irq_arr_size / sizeof(irq_arr[0])); in hl_fw_unmask_irq_arr()
337 memcpy(&pkt->irqs, irq_arr, irq_arr_size); in hl_fw_unmask_irq_arr()
339 pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY << in hl_fw_unmask_irq_arr()
342 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) pkt, in hl_fw_unmask_irq_arr()
346 dev_err(hdev->dev, "failed to unmask IRQ array\n"); in hl_fw_unmask_irq_arr()
363 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &test_pkt, in hl_fw_test_cpu_queue()
368 dev_err(hdev->dev, in hl_fw_test_cpu_queue()
371 dev_err(hdev->dev, "CPU queue test failed, error %d\n", rc); in hl_fw_test_cpu_queue()
382 kernel_addr = gen_pool_alloc(hdev->cpu_accessible_dma_pool, size); in hl_fw_cpu_accessible_dma_pool_alloc()
384 *dma_handle = hdev->cpu_accessible_dma_address + in hl_fw_cpu_accessible_dma_pool_alloc()
385 (kernel_addr - (u64) (uintptr_t) hdev->cpu_accessible_dma_mem); in hl_fw_cpu_accessible_dma_pool_alloc()
393 gen_pool_free(hdev->cpu_accessible_dma_pool, (u64) (uintptr_t) vaddr, in hl_fw_cpu_accessible_dma_pool_free()
408 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &hb_pkt, in hl_fw_send_heartbeat()
412 return -EIO; in hl_fw_send_heartbeat()
416 dev_warn(hdev->dev, "FW reported EQ fault during heartbeat\n"); in hl_fw_send_heartbeat()
417 rc = -EIO; in hl_fw_send_heartbeat()
432 dev_err(hdev->dev, in fw_report_boot_dev0()
433 "Device boot error - DRAM initialization failed\n"); in fw_report_boot_dev0()
438 dev_err(hdev->dev, "Device boot error - FIT image corrupted\n"); in fw_report_boot_dev0()
443 dev_err(hdev->dev, in fw_report_boot_dev0()
444 "Device boot error - Thermal Sensor initialization failed\n"); in fw_report_boot_dev0()
449 dev_warn(hdev->dev, in fw_report_boot_dev0()
450 "Device boot warning - Skipped DRAM initialization\n"); in fw_report_boot_dev0()
458 if (hdev->bmc_enable) { in fw_report_boot_dev0()
459 dev_err(hdev->dev, in fw_report_boot_dev0()
460 "Device boot error - Skipped waiting for BMC\n"); in fw_report_boot_dev0()
463 dev_info(hdev->dev, in fw_report_boot_dev0()
464 "Device boot message - Skipped waiting for BMC\n"); in fw_report_boot_dev0()
473 dev_err(hdev->dev, in fw_report_boot_dev0()
474 "Device boot error - Serdes data from BMC not available\n"); in fw_report_boot_dev0()
479 dev_err(hdev->dev, in fw_report_boot_dev0()
480 "Device boot error - NIC F/W initialization failed\n"); in fw_report_boot_dev0()
485 dev_err(hdev->dev, in fw_report_boot_dev0()
486 "Device boot warning - security not ready\n"); in fw_report_boot_dev0()
491 dev_err(hdev->dev, "Device boot error - security failure\n"); in fw_report_boot_dev0()
496 dev_err(hdev->dev, "Device boot error - eFuse failure\n"); in fw_report_boot_dev0()
501 dev_warn(hdev->dev, in fw_report_boot_dev0()
502 "Device boot warning - Failed to load preboot primary image\n"); in fw_report_boot_dev0()
510 dev_err(hdev->dev, "Device boot error - Failed to load preboot secondary image\n"); in fw_report_boot_dev0()
515 dev_err(hdev->dev, "Device boot error - PLL failure\n"); in fw_report_boot_dev0()
521 dev_dbg(hdev->dev, "device unusable status is set\n"); in fw_report_boot_dev0()
526 dev_dbg(hdev->dev, "Device status0 %#x\n", sts_val); in fw_report_boot_dev0()
529 dev_err(hdev->dev, in fw_report_boot_dev0()
530 "Device boot error - unknown ERR0 error 0x%08x\n", err_val); in fw_report_boot_dev0()
536 lower_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev0()
557 dev_dbg(hdev->dev, "Device status1 %#x\n", sts_val); in fw_report_boot_dev1()
560 dev_err(hdev->dev, in fw_report_boot_dev1()
561 "Device boot error - unknown ERR1 error 0x%08x\n", in fw_report_boot_dev1()
568 upper_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev1()
587 * that is not an error per-se, but it is an error in production in fw_read_errors()
599 return -EIO; in fw_read_errors()
609 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_cpucp_info_get()
618 hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, in hl_fw_cpucp_info_get()
622 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
623 "Failed to allocate DMA memory for CPU-CP info packet\n"); in hl_fw_cpucp_info_get()
624 return -ENOMEM; in hl_fw_cpucp_info_get()
634 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_info_get()
637 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
638 "Failed to handle CPU-CP info pkt, error %d\n", rc); in hl_fw_cpucp_info_get()
645 dev_err(hdev->dev, "Errors in device boot\n"); in hl_fw_cpucp_info_get()
649 memcpy(&prop->cpucp_info, cpucp_info_cpu_addr, in hl_fw_cpucp_info_get()
650 sizeof(prop->cpucp_info)); in hl_fw_cpucp_info_get()
652 rc = hl_build_hwmon_channel_info(hdev, prop->cpucp_info.sensors); in hl_fw_cpucp_info_get()
654 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
656 rc = -EFAULT; in hl_fw_cpucp_info_get()
660 kernel_ver = extract_fw_ver_from_str(prop->cpucp_info.kernel_version); in hl_fw_cpucp_info_get()
662 dev_info(hdev->dev, "Linux version %s", kernel_ver); in hl_fw_cpucp_info_get()
667 hdev->event_queue.check_eqe_index = false; in hl_fw_cpucp_info_get()
670 if (prop->fw_cpu_boot_dev_sts0_valid) { in hl_fw_cpucp_info_get()
671 prop->fw_app_cpu_boot_dev_sts0 = RREG32(sts_boot_dev_sts0_reg); in hl_fw_cpucp_info_get()
672 if (prop->fw_app_cpu_boot_dev_sts0 & in hl_fw_cpucp_info_get()
674 hdev->event_queue.check_eqe_index = true; in hl_fw_cpucp_info_get()
677 if (prop->fw_cpu_boot_dev_sts1_valid) in hl_fw_cpucp_info_get()
678 prop->fw_app_cpu_boot_dev_sts1 = RREG32(sts_boot_dev_sts1_reg); in hl_fw_cpucp_info_get()
681 hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev, in hl_fw_cpucp_info_get()
695 if (!hdev->asic_funcs->get_msi_info) in hl_fw_send_msi_info_msg()
701 /* data should be aligned to 8 bytes in order to CPU-CP to copy it */ in hl_fw_send_msi_info_msg()
706 dev_err(hdev->dev, "CPUCP array data is too big\n"); in hl_fw_send_msi_info_msg()
707 return -EINVAL; in hl_fw_send_msi_info_msg()
712 return -ENOMEM; in hl_fw_send_msi_info_msg()
714 pkt->length = cpu_to_le32(CPUCP_NUM_OF_MSI_TYPES); in hl_fw_send_msi_info_msg()
716 memset((void *) &pkt->data, 0xFF, data_size); in hl_fw_send_msi_info_msg()
717 hdev->asic_funcs->get_msi_info(pkt->data); in hl_fw_send_msi_info_msg()
719 pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_MSI_INFO_SET << in hl_fw_send_msi_info_msg()
722 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *)pkt, in hl_fw_send_msi_info_msg()
727 * this feature and will use default/hard coded MSI values. no reason in hl_fw_send_msi_info_msg()
734 dev_err(hdev->dev, "failed to send CPUCP array data\n"); in hl_fw_send_msi_info_msg()
766 hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, in hl_fw_get_eeprom_data()
769 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
770 "Failed to allocate DMA memory for CPU-CP EEPROM packet\n"); in hl_fw_get_eeprom_data()
771 return -ENOMEM; in hl_fw_get_eeprom_data()
781 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_eeprom_data()
785 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
786 "Failed to handle CPU-CP EEPROM packet, error %d\n", in hl_fw_get_eeprom_data()
795 hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev, max_size, in hl_fw_get_eeprom_data()
813 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
816 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
817 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
820 counters->rx_throughput = result; in hl_fw_cpucp_pci_counters_get()
828 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
831 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
832 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
835 counters->tx_throughput = result; in hl_fw_cpucp_pci_counters_get()
842 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
845 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
846 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
849 counters->replay_cnt = (u32) result; in hl_fw_cpucp_pci_counters_get()
863 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_total_energy_get()
866 dev_err(hdev->dev, in hl_fw_cpucp_total_energy_get()
880 struct asic_fixed_properties *prop = &hdev->asic_prop; in get_used_pll_index()
885 dynamic_pll = !!(prop->fw_app_cpu_boot_dev_sts0 & in get_used_pll_index()
901 fw_pll_idx = hdev->asic_funcs->map_pll_idx_to_fw_idx(input_pll_index); in get_used_pll_index()
903 dev_err(hdev->dev, "Invalid PLL index (%u) error %d\n", in get_used_pll_index()
905 return -EINVAL; in get_used_pll_index()
909 pll_byte = prop->cpucp_info.pll_map[fw_pll_idx >> 3]; in get_used_pll_index()
913 dev_err(hdev->dev, "PLL index %d is not supported\n", in get_used_pll_index()
915 return -EINVAL; in get_used_pll_index()
941 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pll_info_get()
944 dev_err(hdev->dev, "Failed to read PLL info, error %d\n", rc); in hl_fw_cpucp_pll_info_get()
965 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_power_get()
968 dev_err(hdev->dev, "Failed to read power, error %d\n", rc); in hl_fw_cpucp_power_get()
980 &hdev->fw_loader.static_loader; in hl_fw_ask_hard_reset_without_linux()
983 if (hdev->asic_prop.dynamic_fw_load) { in hl_fw_ask_hard_reset_without_linux()
984 rc = hl_fw_dynamic_send_protocol_cmd(hdev, &hdev->fw_loader, in hl_fw_ask_hard_reset_without_linux()
986 hdev->fw_loader.cpu_timeout); in hl_fw_ask_hard_reset_without_linux()
988 dev_warn(hdev->dev, "Failed sending COMMS_RST_DEV\n"); in hl_fw_ask_hard_reset_without_linux()
990 WREG32(static_loader->kmd_msg_to_cpu_reg, KMD_MSG_RST_DEV); in hl_fw_ask_hard_reset_without_linux()
997 &hdev->fw_loader.static_loader; in hl_fw_ask_halt_machine_without_linux()
1000 if (hdev->device_cpu_is_halted) in hl_fw_ask_halt_machine_without_linux()
1004 if (hdev->asic_prop.dynamic_fw_load) { in hl_fw_ask_halt_machine_without_linux()
1005 rc = hl_fw_dynamic_send_protocol_cmd(hdev, &hdev->fw_loader, in hl_fw_ask_halt_machine_without_linux()
1007 hdev->fw_loader.cpu_timeout); in hl_fw_ask_halt_machine_without_linux()
1009 dev_warn(hdev->dev, "Failed sending COMMS_GOTO_WFE\n"); in hl_fw_ask_halt_machine_without_linux()
1011 WREG32(static_loader->kmd_msg_to_cpu_reg, KMD_MSG_GOTO_WFE); in hl_fw_ask_halt_machine_without_linux()
1012 msleep(static_loader->cpu_reset_wait_msec); in hl_fw_ask_halt_machine_without_linux()
1017 WREG32(static_loader->kmd_msg_to_cpu_reg, KMD_MSG_NA); in hl_fw_ask_halt_machine_without_linux()
1020 hdev->device_cpu_is_halted = true; in hl_fw_ask_halt_machine_without_linux()
1030 dev_err(hdev->dev, in detect_cpu_boot_status()
1031 "Device boot progress - BTL did NOT run\n"); in detect_cpu_boot_status()
1034 dev_err(hdev->dev, in detect_cpu_boot_status()
1035 "Device boot progress - Stuck inside WFE loop\n"); in detect_cpu_boot_status()
1038 dev_err(hdev->dev, in detect_cpu_boot_status()
1039 "Device boot progress - Stuck in BTL\n"); in detect_cpu_boot_status()
1042 dev_err(hdev->dev, in detect_cpu_boot_status()
1043 "Device boot progress - Stuck in Preboot\n"); in detect_cpu_boot_status()
1046 dev_err(hdev->dev, in detect_cpu_boot_status()
1047 "Device boot progress - Stuck in SPL\n"); in detect_cpu_boot_status()
1050 dev_err(hdev->dev, in detect_cpu_boot_status()
1051 "Device boot progress - Stuck in u-boot\n"); in detect_cpu_boot_status()
1054 dev_err(hdev->dev, in detect_cpu_boot_status()
1055 "Device boot progress - DRAM initialization failed\n"); in detect_cpu_boot_status()
1058 dev_err(hdev->dev, in detect_cpu_boot_status()
1059 "Device boot progress - Cannot boot\n"); in detect_cpu_boot_status()
1062 dev_err(hdev->dev, in detect_cpu_boot_status()
1063 "Device boot progress - Thermal Sensor initialization failed\n"); in detect_cpu_boot_status()
1066 dev_err(hdev->dev, in detect_cpu_boot_status()
1067 "Device boot progress - Stuck in preboot after security initialization\n"); in detect_cpu_boot_status()
1070 dev_err(hdev->dev, in detect_cpu_boot_status()
1071 "Device boot progress - Invalid status code %d\n", in detect_cpu_boot_status()
1084 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_read_preboot_caps()
1090 * CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT - for newer firmwares where in hl_fw_read_preboot_caps()
1093 * All other status values - for older firmwares where the uboot was in hl_fw_read_preboot_caps()
1110 dev_err(hdev->dev, "CPU boot ready status timeout\n"); in hl_fw_read_preboot_caps()
1116 if (status != -1) in hl_fw_read_preboot_caps()
1120 return -EIO; in hl_fw_read_preboot_caps()
1130 * In case it is not enabled the stored value will be left 0- all in hl_fw_read_preboot_caps()
1135 prop->fw_cpu_boot_dev_sts0_valid = true; in hl_fw_read_preboot_caps()
1136 prop->fw_preboot_cpu_boot_dev_sts0 = reg_val; in hl_fw_read_preboot_caps()
1141 prop->fw_cpu_boot_dev_sts1_valid = true; in hl_fw_read_preboot_caps()
1142 prop->fw_preboot_cpu_boot_dev_sts1 = reg_val; in hl_fw_read_preboot_caps()
1145 prop->dynamic_fw_load = !!(prop->fw_preboot_cpu_boot_dev_sts0 & in hl_fw_read_preboot_caps()
1149 hdev->asic_funcs->init_firmware_loader(hdev); in hl_fw_read_preboot_caps()
1151 dev_dbg(hdev->dev, "Attempting %s FW load\n", in hl_fw_read_preboot_caps()
1152 prop->dynamic_fw_load ? "dynamic" : "legacy"); in hl_fw_read_preboot_caps()
1159 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_static_read_device_fw_version()
1160 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_static_read_device_fw_version()
1167 static_loader = &hdev->fw_loader.static_loader; in hl_fw_static_read_device_fw_version()
1171 ver_off = RREG32(static_loader->boot_fit_version_offset_reg); in hl_fw_static_read_device_fw_version()
1172 dest = prop->uboot_ver; in hl_fw_static_read_device_fw_version()
1173 name = "Boot-fit"; in hl_fw_static_read_device_fw_version()
1174 limit = static_loader->boot_fit_version_max_off; in hl_fw_static_read_device_fw_version()
1177 ver_off = RREG32(static_loader->preboot_version_offset_reg); in hl_fw_static_read_device_fw_version()
1178 dest = prop->preboot_ver; in hl_fw_static_read_device_fw_version()
1180 limit = static_loader->preboot_version_max_off; in hl_fw_static_read_device_fw_version()
1183 dev_warn(hdev->dev, "Undefined FW component: %d\n", fwc); in hl_fw_static_read_device_fw_version()
1184 return -EIO; in hl_fw_static_read_device_fw_version()
1187 ver_off &= static_loader->sram_offset_mask; in hl_fw_static_read_device_fw_version()
1191 hdev->pcie_bar[fw_loader->sram_bar_id] + ver_off, in hl_fw_static_read_device_fw_version()
1194 dev_err(hdev->dev, "%s version offset (0x%x) is above SRAM\n", in hl_fw_static_read_device_fw_version()
1197 return -EIO; in hl_fw_static_read_device_fw_version()
1201 boot_ver = extract_fw_ver_from_str(prop->uboot_ver); in hl_fw_static_read_device_fw_version()
1203 dev_info(hdev->dev, "boot-fit version %s\n", boot_ver); in hl_fw_static_read_device_fw_version()
1207 preboot_ver = strnstr(prop->preboot_ver, "Preboot", in hl_fw_static_read_device_fw_version()
1209 if (preboot_ver && preboot_ver != prop->preboot_ver) { in hl_fw_static_read_device_fw_version()
1210 strscpy(btl_ver, prop->preboot_ver, in hl_fw_static_read_device_fw_version()
1211 min((int) (preboot_ver - prop->preboot_ver), in hl_fw_static_read_device_fw_version()
1213 dev_info(hdev->dev, "%s\n", btl_ver); in hl_fw_static_read_device_fw_version()
1216 preboot_ver = extract_fw_ver_from_str(prop->preboot_ver); in hl_fw_static_read_device_fw_version()
1218 dev_info(hdev->dev, "preboot version %s\n", in hl_fw_static_read_device_fw_version()
1228 * hl_fw_preboot_update_state - update internal data structures during
1234 * @return 0 on success, otherwise non-zero error code
1238 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_preboot_update_state()
1241 cpu_boot_dev_sts0 = prop->fw_preboot_cpu_boot_dev_sts0; in hl_fw_preboot_update_state()
1242 cpu_boot_dev_sts1 = prop->fw_preboot_cpu_boot_dev_sts1; in hl_fw_preboot_update_state()
1245 * 1. preboot - a. Check whether the security status bits are valid in hl_fw_preboot_update_state()
1248 * 2. boot cpu - a. Fetch boot cpu security status in hl_fw_preboot_update_state()
1250 * 3. FW application - a. Fetch fw application security status in hl_fw_preboot_update_state()
1253 prop->hard_reset_done_by_fw = in hl_fw_preboot_update_state()
1256 dev_dbg(hdev->dev, "Firmware preboot boot device status0 %#x\n", in hl_fw_preboot_update_state()
1259 dev_dbg(hdev->dev, "Firmware preboot boot device status1 %#x\n", in hl_fw_preboot_update_state()
1262 dev_dbg(hdev->dev, "Firmware preboot hard-reset is %s\n", in hl_fw_preboot_update_state()
1263 prop->hard_reset_done_by_fw ? "enabled" : "disabled"); in hl_fw_preboot_update_state()
1265 dev_dbg(hdev->dev, "firmware-level security is %s\n", in hl_fw_preboot_update_state()
1266 prop->fw_security_enabled ? "enabled" : "disabled"); in hl_fw_preboot_update_state()
1268 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_preboot_update_state()
1269 prop->gic_interrupts_enable ? "enabled" : "disabled"); in hl_fw_preboot_update_state()
1294 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU) || hdev->pldm) in hl_fw_read_preboot_status()
1311 if (hdev->asic_prop.dynamic_fw_load) in hl_fw_read_preboot_status()
1328 * hl_fw_dynamic_report_error_status - report error status
1342 dev_err(hdev->dev, "Device status %s, expected status: %s\n", in hl_fw_dynamic_report_error_status()
1346 dev_err(hdev->dev, "Device status unknown %d, expected status: %s\n", in hl_fw_dynamic_report_error_status()
1352 * hl_fw_dynamic_send_cmd - send LKD to FW cmd
1372 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_send_cmd()
1377 WREG32(le32_to_cpu(dyn_regs->kmd_msg_to_cpu), val); in hl_fw_dynamic_send_cmd()
1381 * hl_fw_dynamic_extract_fw_response - update the FW response
1388 * @return 0 on success, otherwise non-zero error code
1395 response->status = FIELD_GET(COMMS_STATUS_STATUS_MASK, status); in hl_fw_dynamic_extract_fw_response()
1396 response->ram_offset = FIELD_GET(COMMS_STATUS_OFFSET_MASK, status) << in hl_fw_dynamic_extract_fw_response()
1398 response->ram_type = FIELD_GET(COMMS_STATUS_RAM_TYPE_MASK, status); in hl_fw_dynamic_extract_fw_response()
1400 if ((response->ram_type != COMMS_SRAM) && in hl_fw_dynamic_extract_fw_response()
1401 (response->ram_type != COMMS_DRAM)) { in hl_fw_dynamic_extract_fw_response()
1402 dev_err(hdev->dev, "FW status: invalid RAM type %u\n", in hl_fw_dynamic_extract_fw_response()
1403 response->ram_type); in hl_fw_dynamic_extract_fw_response()
1404 return -EIO; in hl_fw_dynamic_extract_fw_response()
1411 * hl_fw_dynamic_wait_for_status - wait for status in dynamic FW load
1418 * @return 0 on success, otherwise non-zero error code
1432 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_wait_for_status()
1437 le32_to_cpu(dyn_regs->cpu_cmd_status_to_host), in hl_fw_dynamic_wait_for_status()
1446 return -EIO; in hl_fw_dynamic_wait_for_status()
1457 &fw_loader->dynamic_loader.response, in hl_fw_dynamic_wait_for_status()
1463 * hl_fw_dynamic_send_clear_cmd - send clear command to FW
1468 * @return 0 on success, otherwise non-zero error code
1482 fw_loader->cpu_timeout); in hl_fw_dynamic_send_clear_cmd()
1486 * hl_fw_dynamic_send_protocol_cmd - send LKD to FW cmd and wait for ACK
1495 * @return 0 on success, otherwise non-zero error code
1499 * - send clear (clear command and verify clear status register)
1500 * - send the actual protocol command
1501 * - wait for ACK on the protocol command
1502 * - send clear
1503 * - send NOOP
1505 * - wait for OK
1506 * - send clear
1507 * - send NOOP
1561 * hl_fw_compat_crc32 - CRC compatible with FW
1579 * hl_fw_dynamic_validate_memory_bound - validate memory bounds for memory
1588 * @return 0 on success, otherwise non-zero error code
1598 if (end_addr >= region->region_base + region->region_size) { in hl_fw_dynamic_validate_memory_bound()
1599 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
1602 return -EIO; in hl_fw_dynamic_validate_memory_bound()
1610 if (end_addr >= region->region_base - region->offset_in_bar + in hl_fw_dynamic_validate_memory_bound()
1611 region->bar_size) { in hl_fw_dynamic_validate_memory_bound()
1612 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
1614 return -EIO; in hl_fw_dynamic_validate_memory_bound()
1621 * hl_fw_dynamic_validate_descriptor - validate FW descriptor
1627 * @return 0 on success, otherwise non-zero error code
1641 if (le32_to_cpu(fw_desc->header.magic) != HL_COMMS_DESC_MAGIC) { in hl_fw_dynamic_validate_descriptor()
1642 dev_err(hdev->dev, "Invalid magic for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
1643 fw_desc->header.magic); in hl_fw_dynamic_validate_descriptor()
1644 return -EIO; in hl_fw_dynamic_validate_descriptor()
1647 if (fw_desc->header.version != HL_COMMS_DESC_VER) { in hl_fw_dynamic_validate_descriptor()
1648 dev_err(hdev->dev, "Invalid version for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
1649 fw_desc->header.version); in hl_fw_dynamic_validate_descriptor()
1650 return -EIO; in hl_fw_dynamic_validate_descriptor()
1658 data_size = sizeof(struct lkd_fw_comms_desc) - in hl_fw_dynamic_validate_descriptor()
1662 if (le16_to_cpu(fw_desc->header.size) != data_size) { in hl_fw_dynamic_validate_descriptor()
1663 dev_err(hdev->dev, in hl_fw_dynamic_validate_descriptor()
1665 le16_to_cpu(fw_desc->header.size), data_size); in hl_fw_dynamic_validate_descriptor()
1666 return -EIO; in hl_fw_dynamic_validate_descriptor()
1671 if (data_crc32 != le32_to_cpu(fw_desc->header.crc32)) { in hl_fw_dynamic_validate_descriptor()
1672 dev_err(hdev->dev, in hl_fw_dynamic_validate_descriptor()
1674 data_crc32, fw_desc->header.crc32); in hl_fw_dynamic_validate_descriptor()
1675 return -EIO; in hl_fw_dynamic_validate_descriptor()
1679 addr = le64_to_cpu(fw_desc->img_addr); in hl_fw_dynamic_validate_descriptor()
1683 dev_err(hdev->dev, in hl_fw_dynamic_validate_descriptor()
1685 return -EIO; in hl_fw_dynamic_validate_descriptor()
1688 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_validate_descriptor()
1691 fw_loader->dynamic_loader.image_region = region; in hl_fw_dynamic_validate_descriptor()
1698 fw_loader->dynamic_loader.fw_image_size, in hl_fw_dynamic_validate_descriptor()
1701 dev_err(hdev->dev, in hl_fw_dynamic_validate_descriptor()
1716 device_addr = region->region_base + response->ram_offset; in hl_fw_dynamic_validate_response()
1721 * type- testing only the end address is enough in hl_fw_dynamic_validate_response()
1730 * hl_fw_dynamic_read_and_validate_descriptor - read and validate FW descriptor
1735 * @return 0 on success, otherwise non-zero error code
1747 fw_desc = &fw_loader->dynamic_loader.comm_desc; in hl_fw_dynamic_read_and_validate_descriptor()
1748 response = &fw_loader->dynamic_loader.response; in hl_fw_dynamic_read_and_validate_descriptor()
1750 region_id = (response->ram_type == COMMS_SRAM) ? in hl_fw_dynamic_read_and_validate_descriptor()
1753 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_read_and_validate_descriptor()
1757 dev_err(hdev->dev, in hl_fw_dynamic_read_and_validate_descriptor()
1763 src = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_read_and_validate_descriptor()
1764 response->ram_offset; in hl_fw_dynamic_read_and_validate_descriptor()
1771 * hl_fw_dynamic_request_descriptor - handshake with CPU to get FW descriptor
1777 * @return 0 on success, otherwise non-zero error code
1787 fw_loader->cpu_timeout); in hl_fw_dynamic_request_descriptor()
1795 * hl_fw_dynamic_read_device_fw_version - read FW version to exposed properties
1805 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_dynamic_read_device_fw_version()
1811 strscpy(prop->uboot_ver, fw_version, VERSION_MAX_LEN); in hl_fw_dynamic_read_device_fw_version()
1812 boot_ver = extract_fw_ver_from_str(prop->uboot_ver); in hl_fw_dynamic_read_device_fw_version()
1814 dev_info(hdev->dev, "boot-fit version %s\n", boot_ver); in hl_fw_dynamic_read_device_fw_version()
1820 strscpy(prop->preboot_ver, fw_version, VERSION_MAX_LEN); in hl_fw_dynamic_read_device_fw_version()
1821 preboot_ver = strnstr(prop->preboot_ver, "Preboot", in hl_fw_dynamic_read_device_fw_version()
1823 if (preboot_ver && preboot_ver != prop->preboot_ver) { in hl_fw_dynamic_read_device_fw_version()
1824 strscpy(btl_ver, prop->preboot_ver, in hl_fw_dynamic_read_device_fw_version()
1825 min((int) (preboot_ver - prop->preboot_ver), in hl_fw_dynamic_read_device_fw_version()
1827 dev_info(hdev->dev, "%s\n", btl_ver); in hl_fw_dynamic_read_device_fw_version()
1830 preboot_ver = extract_fw_ver_from_str(prop->preboot_ver); in hl_fw_dynamic_read_device_fw_version()
1832 dev_info(hdev->dev, "preboot version %s\n", in hl_fw_dynamic_read_device_fw_version()
1839 dev_warn(hdev->dev, "Undefined FW component: %d\n", fwc); in hl_fw_dynamic_read_device_fw_version()
1845 * hl_fw_dynamic_copy_image - copy image to memory allocated by the FW
1861 fw_desc = &fw_loader->dynamic_loader.comm_desc; in hl_fw_dynamic_copy_image()
1862 addr = le64_to_cpu(fw_desc->img_addr); in hl_fw_dynamic_copy_image()
1865 region = fw_loader->dynamic_loader.image_region; in hl_fw_dynamic_copy_image()
1867 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_image()
1868 (addr - region->region_base); in hl_fw_dynamic_copy_image()
1871 fw_loader->boot_fit_img.src_off, in hl_fw_dynamic_copy_image()
1872 fw_loader->boot_fit_img.copy_size); in hl_fw_dynamic_copy_image()
1878 * hl_fw_dynamic_copy_msg - copy msg to memory allocated by the FW
1893 fw_desc = &fw_loader->dynamic_loader.comm_desc; in hl_fw_dynamic_copy_msg()
1894 addr = le64_to_cpu(fw_desc->img_addr); in hl_fw_dynamic_copy_msg()
1897 region = fw_loader->dynamic_loader.image_region; in hl_fw_dynamic_copy_msg()
1899 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_msg()
1900 (addr - region->region_base); in hl_fw_dynamic_copy_msg()
1908 * hl_fw_boot_fit_update_state - update internal data structures after boot-fit
1915 * @return 0 on success, otherwise non-zero error code
1921 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_boot_fit_update_state()
1924 prop->hard_reset_done_by_fw = false; in hl_fw_boot_fit_update_state()
1927 if (prop->fw_preboot_cpu_boot_dev_sts0 & CPU_BOOT_DEV_STS0_ENABLED) { in hl_fw_boot_fit_update_state()
1928 prop->fw_bootfit_cpu_boot_dev_sts0 = in hl_fw_boot_fit_update_state()
1931 if (prop->fw_bootfit_cpu_boot_dev_sts0 & in hl_fw_boot_fit_update_state()
1933 prop->hard_reset_done_by_fw = true; in hl_fw_boot_fit_update_state()
1935 dev_dbg(hdev->dev, "Firmware boot CPU status0 %#x\n", in hl_fw_boot_fit_update_state()
1936 prop->fw_bootfit_cpu_boot_dev_sts0); in hl_fw_boot_fit_update_state()
1939 if (prop->fw_cpu_boot_dev_sts1_valid) { in hl_fw_boot_fit_update_state()
1940 prop->fw_bootfit_cpu_boot_dev_sts1 = in hl_fw_boot_fit_update_state()
1943 dev_dbg(hdev->dev, "Firmware boot CPU status1 %#x\n", in hl_fw_boot_fit_update_state()
1944 prop->fw_bootfit_cpu_boot_dev_sts1); in hl_fw_boot_fit_update_state()
1947 dev_dbg(hdev->dev, "Firmware boot CPU hard-reset is %s\n", in hl_fw_boot_fit_update_state()
1948 prop->hard_reset_done_by_fw ? "enabled" : "disabled"); in hl_fw_boot_fit_update_state()
1954 &hdev->fw_loader.dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_update_linux_interrupt_if()
1959 if (!hdev->asic_prop.gic_interrupts_enable && in hl_fw_dynamic_update_linux_interrupt_if()
1960 !(hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_fw_dynamic_update_linux_interrupt_if()
1962 dyn_regs->gic_host_halt_irq = dyn_regs->gic_host_pi_upd_irq; in hl_fw_dynamic_update_linux_interrupt_if()
1963 dyn_regs->gic_host_ints_irq = dyn_regs->gic_host_pi_upd_irq; in hl_fw_dynamic_update_linux_interrupt_if()
1965 dev_warn(hdev->dev, in hl_fw_dynamic_update_linux_interrupt_if()
1970 * hl_fw_dynamic_load_image - load FW image using dynamic protocol
1977 * @return 0 on success, otherwise non-zero error code
1991 * 1. current FW component is preboot and we want to load boot-fit in hl_fw_dynamic_load_image()
1992 * 2. current FW component is boot-fit and we want to load linux in hl_fw_dynamic_load_image()
1996 fw_name = fw_loader->boot_fit_img.image_name; in hl_fw_dynamic_load_image()
1999 fw_name = fw_loader->linux_img.image_name; in hl_fw_dynamic_load_image()
2008 fw_loader->dynamic_loader.fw_image_size = fw->size; in hl_fw_dynamic_load_image()
2010 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, fw->size); in hl_fw_dynamic_load_image()
2016 fw_loader->dynamic_loader.comm_desc.cur_fw_ver); in hl_fw_dynamic_load_image()
2023 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_load_image()
2025 le32_to_cpu(dyn_regs->cpu_boot_dev_sts0), in hl_fw_dynamic_load_image()
2026 le32_to_cpu(dyn_regs->cpu_boot_dev_sts1)); in hl_fw_dynamic_load_image()
2036 fw_loader->cpu_timeout); in hl_fw_dynamic_load_image()
2056 dyn_loader = &fw_loader->dynamic_loader; in hl_fw_dynamic_wait_for_boot_fit_active()
2058 /* Make sure CPU boot-loader is running */ in hl_fw_dynamic_wait_for_boot_fit_active()
2061 le32_to_cpu(dyn_loader->comm_desc.cpu_dyn_regs.cpu_boot_status), in hl_fw_dynamic_wait_for_boot_fit_active()
2066 dyn_loader->wait_for_bl_timeout); in hl_fw_dynamic_wait_for_boot_fit_active()
2068 dev_err(hdev->dev, "failed to wait for boot\n"); in hl_fw_dynamic_wait_for_boot_fit_active()
2072 dev_dbg(hdev->dev, "uboot status = %d\n", status); in hl_fw_dynamic_wait_for_boot_fit_active()
2083 dyn_loader = &fw_loader->dynamic_loader; in hl_fw_dynamic_wait_for_linux_active()
2085 /* Make sure CPU boot-loader is running */ in hl_fw_dynamic_wait_for_linux_active()
2089 le32_to_cpu(dyn_loader->comm_desc.cpu_dyn_regs.cpu_boot_status), in hl_fw_dynamic_wait_for_linux_active()
2093 fw_loader->cpu_timeout); in hl_fw_dynamic_wait_for_linux_active()
2095 dev_err(hdev->dev, "failed to wait for Linux\n"); in hl_fw_dynamic_wait_for_linux_active()
2099 dev_dbg(hdev->dev, "Boot status = %d\n", status); in hl_fw_dynamic_wait_for_linux_active()
2104 * hl_fw_linux_update_state - update internal data structures after Linux
2107 * of two stages - loading kernel (SRAM_AVAIL)
2116 * @return 0 on success, otherwise non-zero error code
2122 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_linux_update_state()
2124 hdev->fw_loader.linux_loaded = true; in hl_fw_linux_update_state()
2127 prop->hard_reset_done_by_fw = false; in hl_fw_linux_update_state()
2130 if (prop->fw_cpu_boot_dev_sts0_valid) { in hl_fw_linux_update_state()
2131 prop->fw_app_cpu_boot_dev_sts0 = RREG32(cpu_boot_dev_sts0_reg); in hl_fw_linux_update_state()
2133 if (prop->fw_app_cpu_boot_dev_sts0 & in hl_fw_linux_update_state()
2135 prop->hard_reset_done_by_fw = true; in hl_fw_linux_update_state()
2137 if (prop->fw_app_cpu_boot_dev_sts0 & in hl_fw_linux_update_state()
2139 prop->gic_interrupts_enable = false; in hl_fw_linux_update_state()
2141 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2143 prop->fw_app_cpu_boot_dev_sts0); in hl_fw_linux_update_state()
2145 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_linux_update_state()
2146 prop->gic_interrupts_enable ? in hl_fw_linux_update_state()
2150 if (prop->fw_cpu_boot_dev_sts1_valid) { in hl_fw_linux_update_state()
2151 prop->fw_app_cpu_boot_dev_sts1 = RREG32(cpu_boot_dev_sts1_reg); in hl_fw_linux_update_state()
2153 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2155 prop->fw_app_cpu_boot_dev_sts1); in hl_fw_linux_update_state()
2158 dev_dbg(hdev->dev, "Firmware application CPU hard-reset is %s\n", in hl_fw_linux_update_state()
2159 prop->hard_reset_done_by_fw ? "enabled" : "disabled"); in hl_fw_linux_update_state()
2161 dev_info(hdev->dev, "Successfully loaded firmware to device\n"); in hl_fw_linux_update_state()
2165 * hl_fw_dynamic_report_reset_cause - send a COMMS message with the cause
2172 * @return 0 on success, otherwise non-zero error code
2202 fw_loader->cpu_timeout); in hl_fw_dynamic_report_reset_cause()
2208 fw_loader->cpu_timeout); in hl_fw_dynamic_report_reset_cause()
2216 * hl_fw_dynamic_init_cpu - initialize the device CPU using dynamic protocol
2221 * @return 0 on success, otherwise non-zero error code
2225 * - LKD command register
2226 * - FW status register
2230 * in case of timeout expiration without the desired status from FW- the
2239 dev_info(hdev->dev, in hl_fw_dynamic_init_cpu()
2243 * In this stage, "cpu_dyn_regs" contains only LKD's hard coded values! in hl_fw_dynamic_init_cpu()
2246 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_init_cpu()
2250 fw_loader->cpu_timeout); in hl_fw_dynamic_init_cpu()
2254 if (hdev->curr_reset_cause) { in hl_fw_dynamic_init_cpu()
2256 hdev->curr_reset_cause); in hl_fw_dynamic_init_cpu()
2261 hdev->curr_reset_cause = HL_RESET_CAUSE_UNKNOWN; in hl_fw_dynamic_init_cpu()
2264 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) { in hl_fw_dynamic_init_cpu()
2271 fw_loader->dynamic_loader.comm_desc.cur_fw_ver); in hl_fw_dynamic_init_cpu()
2277 fw_loader->boot_fit_timeout); in hl_fw_dynamic_init_cpu()
2279 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2290 hdev->asic_funcs->init_cpu_scrambler_dram(hdev); in hl_fw_dynamic_init_cpu()
2292 if (!(hdev->fw_components & FW_TYPE_LINUX)) { in hl_fw_dynamic_init_cpu()
2293 dev_info(hdev->dev, "Skip loading Linux F/W\n"); in hl_fw_dynamic_init_cpu()
2297 if (fw_loader->skip_bmc) { in hl_fw_dynamic_init_cpu()
2301 fw_loader->cpu_timeout); in hl_fw_dynamic_init_cpu()
2303 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2310 fw_loader->cpu_timeout); in hl_fw_dynamic_init_cpu()
2312 dev_err(hdev->dev, "failed to load Linux\n"); in hl_fw_dynamic_init_cpu()
2320 hl_fw_linux_update_state(hdev, le32_to_cpu(dyn_regs->cpu_boot_dev_sts0), in hl_fw_dynamic_init_cpu()
2321 le32_to_cpu(dyn_regs->cpu_boot_dev_sts1)); in hl_fw_dynamic_init_cpu()
2328 fw_read_errors(hdev, le32_to_cpu(dyn_regs->cpu_boot_err0), in hl_fw_dynamic_init_cpu()
2329 le32_to_cpu(dyn_regs->cpu_boot_err1), in hl_fw_dynamic_init_cpu()
2330 le32_to_cpu(dyn_regs->cpu_boot_dev_sts0), in hl_fw_dynamic_init_cpu()
2331 le32_to_cpu(dyn_regs->cpu_boot_dev_sts1)); in hl_fw_dynamic_init_cpu()
2336 * hl_fw_static_init_cpu - initialize the device CPU using static protocol
2341 * @return 0 on success, otherwise non-zero error code
2352 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) in hl_fw_static_init_cpu()
2356 cpu_timeout = fw_loader->cpu_timeout; in hl_fw_static_init_cpu()
2359 static_loader = &fw_loader->static_loader; in hl_fw_static_init_cpu()
2360 cpu_msg_status_reg = static_loader->cpu_cmd_status_to_host_reg; in hl_fw_static_init_cpu()
2361 msg_to_cpu_reg = static_loader->kmd_msg_to_cpu_reg; in hl_fw_static_init_cpu()
2362 cpu_boot_dev_status0_reg = static_loader->cpu_boot_dev_status0_reg; in hl_fw_static_init_cpu()
2363 cpu_boot_dev_status1_reg = static_loader->cpu_boot_dev_status1_reg; in hl_fw_static_init_cpu()
2364 cpu_boot_status_reg = static_loader->cpu_boot_status_reg; in hl_fw_static_init_cpu()
2366 dev_info(hdev->dev, "Going to wait for device boot (up to %lds)\n", in hl_fw_static_init_cpu()
2376 fw_loader->boot_fit_timeout); in hl_fw_static_init_cpu()
2379 dev_dbg(hdev->dev, in hl_fw_static_init_cpu()
2382 rc = hdev->asic_funcs->load_boot_fit_to_device(hdev); in hl_fw_static_init_cpu()
2399 fw_loader->boot_fit_timeout); in hl_fw_static_init_cpu()
2402 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2411 /* Make sure CPU boot-loader is running */ in hl_fw_static_init_cpu()
2423 dev_dbg(hdev->dev, "uboot status = %d\n", status); in hl_fw_static_init_cpu()
2425 /* Read U-Boot version now in case we will later fail */ in hl_fw_static_init_cpu()
2434 rc = -EIO; in hl_fw_static_init_cpu()
2441 hdev->asic_funcs->init_cpu_scrambler_dram(hdev); in hl_fw_static_init_cpu()
2443 if (!(hdev->fw_components & FW_TYPE_LINUX)) { in hl_fw_static_init_cpu()
2444 dev_info(hdev->dev, "Skip loading Linux F/W\n"); in hl_fw_static_init_cpu()
2454 dev_info(hdev->dev, in hl_fw_static_init_cpu()
2457 rc = hdev->asic_funcs->load_firmware_to_device(hdev); in hl_fw_static_init_cpu()
2461 if (fw_loader->skip_bmc) { in hl_fw_static_init_cpu()
2473 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2477 rc = -EIO; in hl_fw_static_init_cpu()
2497 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2500 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2504 rc = -EIO; in hl_fw_static_init_cpu()
2508 rc = fw_read_errors(hdev, fw_loader->static_loader.boot_err0_reg, in hl_fw_static_init_cpu()
2509 fw_loader->static_loader.boot_err1_reg, in hl_fw_static_init_cpu()
2521 fw_read_errors(hdev, fw_loader->static_loader.boot_err0_reg, in hl_fw_static_init_cpu()
2522 fw_loader->static_loader.boot_err1_reg, in hl_fw_static_init_cpu()
2530 * hl_fw_init_cpu - initialize the device CPU
2534 * @return 0 on success, otherwise non-zero error code
2541 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_init_cpu()
2542 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_init_cpu()
2544 return prop->dynamic_fw_load ? in hl_fw_init_cpu()