Lines Matching refs:adev

37 static int tonga_set_smc_sram_address(struct amdgpu_device *adev, uint32_t smc_address, uint32_t li…  in tonga_set_smc_sram_address()  argument
56 static int tonga_copy_bytes_to_smc(struct amdgpu_device *adev, uint32_t smc_start_address, const ui… in tonga_copy_bytes_to_smc() argument
72 spin_lock_irqsave(&adev->smc_idx_lock, flags); in tonga_copy_bytes_to_smc()
77 result = tonga_set_smc_sram_address(adev, addr, limit); in tonga_copy_bytes_to_smc()
93 result = tonga_set_smc_sram_address(adev, addr, limit); in tonga_copy_bytes_to_smc()
108 result = tonga_set_smc_sram_address(adev, addr, limit); in tonga_copy_bytes_to_smc()
116 spin_unlock_irqrestore(&adev->smc_idx_lock, flags); in tonga_copy_bytes_to_smc()
120 static int tonga_program_jump_on_start(struct amdgpu_device *adev) in tonga_program_jump_on_start() argument
123 tonga_copy_bytes_to_smc(adev, 0x0, data, 4, sizeof(data)+1); in tonga_program_jump_on_start()
128 static bool tonga_is_smc_ram_running(struct amdgpu_device *adev) in tonga_is_smc_ram_running() argument
136 static int wait_smu_response(struct amdgpu_device *adev) in wait_smu_response() argument
141 for (i = 0; i < adev->usec_timeout; i++) { in wait_smu_response()
148 if (i == adev->usec_timeout) in wait_smu_response()
154 static int tonga_send_msg_to_smc_offset(struct amdgpu_device *adev) in tonga_send_msg_to_smc_offset() argument
156 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc_offset()
164 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc_offset()
172 static int tonga_send_msg_to_smc(struct amdgpu_device *adev, PPSMC_Msg msg) in tonga_send_msg_to_smc() argument
174 if (!tonga_is_smc_ram_running(adev)) in tonga_send_msg_to_smc()
179 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc()
186 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc()
194 static int tonga_send_msg_to_smc_without_waiting(struct amdgpu_device *adev, in tonga_send_msg_to_smc_without_waiting() argument
197 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc_without_waiting()
207 static int tonga_send_msg_to_smc_with_parameter(struct amdgpu_device *adev, in tonga_send_msg_to_smc_with_parameter() argument
211 if (!tonga_is_smc_ram_running(adev)) in tonga_send_msg_to_smc_with_parameter()
214 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc_with_parameter()
221 return tonga_send_msg_to_smc(adev, msg); in tonga_send_msg_to_smc_with_parameter()
225 struct amdgpu_device *adev, in tonga_send_msg_to_smc_with_parameter_without_waiting() argument
228 if (wait_smu_response(adev)) { in tonga_send_msg_to_smc_with_parameter_without_waiting()
235 return tonga_send_msg_to_smc_without_waiting(adev, msg); in tonga_send_msg_to_smc_with_parameter_without_waiting()
239 static int tonga_wait_for_smc_inactive(struct amdgpu_device *adev)
244 if (!tonga_is_smc_ram_running(adev))
247 for (i = 0; i < adev->usec_timeout; i++) {
254 if (i == adev->usec_timeout)
261 static int tonga_smu_upload_firmware_image(struct amdgpu_device *adev) in tonga_smu_upload_firmware_image() argument
272 if (!adev->pm.fw) in tonga_smu_upload_firmware_image()
275 hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; in tonga_smu_upload_firmware_image()
278 adev->pm.fw_version = le32_to_cpu(hdr->header.ucode_version); in tonga_smu_upload_firmware_image()
282 (adev->pm.fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes)); in tonga_smu_upload_firmware_image()
294 spin_lock_irqsave(&adev->smc_idx_lock, flags); in tonga_smu_upload_firmware_image()
309 spin_unlock_irqrestore(&adev->smc_idx_lock, flags); in tonga_smu_upload_firmware_image()
315 static int tonga_read_smc_sram_dword(struct amdgpu_device *adev,
323 spin_lock_irqsave(&adev->smc_idx_lock, flags);
324 result = tonga_set_smc_sram_address(adev, smc_address, limit);
327 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
331 static int tonga_write_smc_sram_dword(struct amdgpu_device *adev,
339 spin_lock_irqsave(&adev->smc_idx_lock, flags);
340 result = tonga_set_smc_sram_address(adev, smc_address, limit);
343 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
347 static int tonga_smu_stop_smc(struct amdgpu_device *adev)
387 static int tonga_smu_populate_single_firmware_entry(struct amdgpu_device *adev, in tonga_smu_populate_single_firmware_entry() argument
392 struct amdgpu_firmware_info *ucode = &adev->firmware.ucode[id]; in tonga_smu_populate_single_firmware_entry()
427 static int tonga_smu_request_load_fw(struct amdgpu_device *adev) in tonga_smu_request_load_fw() argument
429 struct tonga_smu_private_data *private = (struct tonga_smu_private_data *)adev->smu.priv; in tonga_smu_request_load_fw()
435 …tonga_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SMU_DRAM_ADDR_HI, private->smu_buffer_addr_hi… in tonga_smu_request_load_fw()
436 …tonga_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SMU_DRAM_ADDR_LO, private->smu_buffer_addr_lo… in tonga_smu_request_load_fw()
442 if (!adev->firmware.smu_load) in tonga_smu_request_load_fw()
445 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_RLC_G, in tonga_smu_request_load_fw()
451 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_CP_CE, in tonga_smu_request_load_fw()
457 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_CP_PFP, in tonga_smu_request_load_fw()
463 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_CP_ME, in tonga_smu_request_load_fw()
469 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_CP_MEC, in tonga_smu_request_load_fw()
475 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_CP_MEC_JT1, in tonga_smu_request_load_fw()
481 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_CP_MEC_JT2, in tonga_smu_request_load_fw()
487 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_SDMA0, in tonga_smu_request_load_fw()
493 if (tonga_smu_populate_single_firmware_entry(adev, UCODE_ID_SDMA1, in tonga_smu_request_load_fw()
499 tonga_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_DRV_DRAM_ADDR_HI, private->header_addr_high); in tonga_smu_request_load_fw()
500 tonga_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_DRV_DRAM_ADDR_LO, private->header_addr_low); in tonga_smu_request_load_fw()
510 if (tonga_send_msg_to_smc_with_parameter_without_waiting(adev, PPSMC_MSG_LoadUcodes, fw_to_load)) { in tonga_smu_request_load_fw()
543 static int tonga_smu_check_fw_load_finish(struct amdgpu_device *adev, in tonga_smu_check_fw_load_finish() argument
549 for (i = 0; i < adev->usec_timeout; i++) { in tonga_smu_check_fw_load_finish()
555 if (i == adev->usec_timeout) { in tonga_smu_check_fw_load_finish()
563 static int tonga_smu_start_in_protection_mode(struct amdgpu_device *adev) in tonga_smu_start_in_protection_mode() argument
574 result = tonga_smu_upload_firmware_image(adev); in tonga_smu_start_in_protection_mode()
599 for (i = 0; i < adev->usec_timeout; i++) { in tonga_smu_start_in_protection_mode()
606 if (i == adev->usec_timeout) { in tonga_smu_start_in_protection_mode()
614 tonga_send_msg_to_smc_offset(adev); in tonga_smu_start_in_protection_mode()
617 for (i = 0; i < adev->usec_timeout; i++) { in tonga_smu_start_in_protection_mode()
624 if (i == adev->usec_timeout) { in tonga_smu_start_in_protection_mode()
637 for (i = 0; i < adev->usec_timeout; i++) { in tonga_smu_start_in_protection_mode()
644 if (i == adev->usec_timeout) { in tonga_smu_start_in_protection_mode()
652 static int tonga_smu_start_in_non_protection_mode(struct amdgpu_device *adev) in tonga_smu_start_in_non_protection_mode() argument
658 for (i = 0; i < adev->usec_timeout; i++) { in tonga_smu_start_in_non_protection_mode()
666 if (i == adev->usec_timeout) { in tonga_smu_start_in_non_protection_mode()
679 result = tonga_smu_upload_firmware_image(adev); in tonga_smu_start_in_non_protection_mode()
684 tonga_program_jump_on_start(adev); in tonga_smu_start_in_non_protection_mode()
697 for (i = 0; i < adev->usec_timeout; i++) { in tonga_smu_start_in_non_protection_mode()
704 if (i == adev->usec_timeout) { in tonga_smu_start_in_non_protection_mode()
712 int tonga_smu_start(struct amdgpu_device *adev) in tonga_smu_start() argument
717 if (!tonga_is_smc_ram_running(adev)) { in tonga_smu_start()
720 result = tonga_smu_start_in_non_protection_mode(adev); in tonga_smu_start()
724 result = tonga_smu_start_in_protection_mode(adev); in tonga_smu_start()
730 return tonga_smu_request_load_fw(adev); in tonga_smu_start()
739 int tonga_smu_init(struct amdgpu_device *adev) in tonga_smu_init() argument
744 struct amdgpu_bo **toc_buf = &adev->smu.toc_buf; in tonga_smu_init()
745 struct amdgpu_bo **smu_buf = &adev->smu.smu_buf; in tonga_smu_init()
756 if (adev->firmware.smu_load) in tonga_smu_init()
757 amdgpu_ucode_init_bo(adev); in tonga_smu_init()
759 adev->smu.priv = private; in tonga_smu_init()
760 adev->smu.fw_flags = 0; in tonga_smu_init()
763 ret = amdgpu_bo_create(adev, image_size, PAGE_SIZE, in tonga_smu_init()
773 ret = amdgpu_bo_create(adev, smu_internal_buffer_size, PAGE_SIZE, in tonga_smu_init()
783 ret = amdgpu_bo_reserve(adev->smu.toc_buf, false); in tonga_smu_init()
785 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_init()
790 ret = amdgpu_bo_pin(adev->smu.toc_buf, AMDGPU_GEM_DOMAIN_VRAM, &mc_addr); in tonga_smu_init()
792 amdgpu_bo_unreserve(adev->smu.toc_buf); in tonga_smu_init()
793 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_init()
800 amdgpu_bo_unreserve(adev->smu.toc_buf); in tonga_smu_init()
801 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_init()
806 amdgpu_bo_unreserve(adev->smu.toc_buf); in tonga_smu_init()
811 ret = amdgpu_bo_reserve(adev->smu.smu_buf, false); in tonga_smu_init()
813 amdgpu_bo_unref(&adev->smu.smu_buf); in tonga_smu_init()
814 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_init()
819 ret = amdgpu_bo_pin(adev->smu.smu_buf, AMDGPU_GEM_DOMAIN_VRAM, &mc_addr); in tonga_smu_init()
821 amdgpu_bo_unreserve(adev->smu.smu_buf); in tonga_smu_init()
822 amdgpu_bo_unref(&adev->smu.smu_buf); in tonga_smu_init()
823 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_init()
830 amdgpu_bo_unreserve(adev->smu.smu_buf); in tonga_smu_init()
831 amdgpu_bo_unref(&adev->smu.smu_buf); in tonga_smu_init()
832 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_init()
837 amdgpu_bo_unreserve(adev->smu.smu_buf); in tonga_smu_init()
841 adev->smu.smumgr_funcs = &tonga_smumgr_funcs; in tonga_smu_init()
846 int tonga_smu_fini(struct amdgpu_device *adev) in tonga_smu_fini() argument
848 amdgpu_bo_unref(&adev->smu.toc_buf); in tonga_smu_fini()
849 amdgpu_bo_unref(&adev->smu.smu_buf); in tonga_smu_fini()
850 kfree(adev->smu.priv); in tonga_smu_fini()
851 adev->smu.priv = NULL; in tonga_smu_fini()
852 if (adev->firmware.fw_buf) in tonga_smu_fini()
853 amdgpu_ucode_fini_bo(adev); in tonga_smu_fini()