Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add helper to execute atomfirmware asic_init

Add helper function to execute atomfirmware asic_init
from the cmd table

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Hawking Zhang and committed by
Alex Deucher
ba75f6eb e24d0e91

+65
+64
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
··· 731 731 732 732 return fw_reserved_fb_size; 733 733 } 734 + 735 + /* 736 + * Helper function to execute asic_init table 737 + * 738 + * @adev: amdgpu_device pointer 739 + * @fb_reset: flag to indicate whether fb is reset or not 740 + * 741 + * Return 0 if succeed, otherwise failed 742 + */ 743 + int amdgpu_atomfirmware_asic_init(struct amdgpu_device *adev, bool fb_reset) 744 + { 745 + struct amdgpu_mode_info *mode_info = &adev->mode_info; 746 + struct atom_context *ctx; 747 + uint8_t frev, crev; 748 + uint16_t data_offset; 749 + uint32_t bootup_sclk_in10khz, bootup_mclk_in10khz; 750 + struct asic_init_ps_allocation_v2_1 asic_init_ps_v2_1; 751 + int index; 752 + 753 + if (!mode_info) 754 + return -EINVAL; 755 + 756 + ctx = mode_info->atom_context; 757 + if (!ctx) 758 + return -EINVAL; 759 + 760 + /* query bootup sclk/mclk from firmware_info table */ 761 + index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, 762 + firmwareinfo); 763 + if (amdgpu_atom_parse_data_header(ctx, index, NULL, 764 + &frev, &crev, &data_offset)) { 765 + union firmware_info *firmware_info = 766 + (union firmware_info *)(ctx->bios + 767 + data_offset); 768 + 769 + bootup_sclk_in10khz = 770 + le32_to_cpu(firmware_info->v31.bootup_sclk_in10khz); 771 + bootup_mclk_in10khz = 772 + le32_to_cpu(firmware_info->v31.bootup_mclk_in10khz); 773 + } else { 774 + return -EINVAL; 775 + } 776 + 777 + index = get_index_into_master_table(atom_master_list_of_command_functions_v2_1, 778 + asic_init); 779 + if (amdgpu_atom_parse_cmd_header(mode_info->atom_context, index, &frev, &crev)) { 780 + if (frev == 2 && crev >= 1) { 781 + memset(&asic_init_ps_v2_1, 0, sizeof(asic_init_ps_v2_1)); 782 + asic_init_ps_v2_1.param.engineparam.sclkfreqin10khz = bootup_sclk_in10khz; 783 + asic_init_ps_v2_1.param.memparam.mclkfreqin10khz = bootup_mclk_in10khz; 784 + asic_init_ps_v2_1.param.engineparam.engineflag = b3NORMAL_ENGINE_INIT; 785 + if (!fb_reset) 786 + asic_init_ps_v2_1.param.memparam.memflag = b3DRAM_SELF_REFRESH_EXIT; 787 + else 788 + asic_init_ps_v2_1.param.memparam.memflag = 0; 789 + } else { 790 + return -EINVAL; 791 + } 792 + } else { 793 + return -EINVAL; 794 + } 795 + 796 + return amdgpu_atom_execute_table(ctx, ATOM_CMD_INIT, (uint32_t *)&asic_init_ps_v2_1); 797 + }
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
··· 40 40 bool amdgpu_atomfirmware_mem_training_supported(struct amdgpu_device *adev); 41 41 bool amdgpu_atomfirmware_dynamic_boot_config_supported(struct amdgpu_device *adev); 42 42 int amdgpu_atomfirmware_get_fw_reserved_fb_size(struct amdgpu_device *adev); 43 + int amdgpu_atomfirmware_asic_init(struct amdgpu_device *adev, bool fb_reset); 43 44 44 45 #endif