drm/amdgpu: add helper to execute atomfirmware asic_init
Subsystems (2)
Alex Deucher
maintainerPATCH 1/2 drm/amdgpu: add helper to execute atomfirmware asic_init
From: Hawking Zhang <[email protected]>
Add helper function to execute atomfirmware asic_init from the cmd table
Signed-off-by Hawking Zhang <[email protected]>
Acked-by Alex Deucher <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 64 +++++++++++++++++++ .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | 1 + 2 files changed, 65 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +64 -0
@@ -731,3 +731,67 @@ int amdgpu_atomfirmware_get_fw_reserved_fb_size(struct amdgpu_device *adev)return fw_reserved_fb_size; } + +/* +* Helper function to execute asic_init table +* +* @adev: amdgpu_device pointer +* @fb_reset: flag to indicate whether fb is reset or not +* +* Return 0 if succeed, otherwise failed +*/ +int amdgpu_atomfirmware_asic_init (struct amdgpu_device *adev,bool fb_reset) +{ +struct amdgpu_mode_info *mode_info = &adev->mode_info; +struct atom_context *ctx; +uint8_t frev, crev; +uint16_t data_offset; +uint32_t bootup_sclk_in10khz, bootup_mclk_in10khz; +struct asic_init_ps_allocation_v2_1 asic_init_ps_v2_1; +int index; + +if (!mode_info) +return -EINVAL ; + + ctx = mode_info->atom_context; +if (!ctx) +return -EINVAL ; + +/* query bootup sclk/mclk from firmware_info table */ + index =get_index_into_master_table (atom_master_list_of_data_tables_v2_1, + firmwareinfo); +if (amdgpu_atom_parse_data_header (ctx, index,NULL , + &frev, &crev, &data_offset)) { +union firmware_info *firmware_info = + (union firmware_info *)(ctx->bios + + data_offset); + + bootup_sclk_in10khz = +le32_to_cpu (firmware_info->v31.bootup_sclk_in10khz); + bootup_mclk_in10khz = +le32_to_cpu (firmware_info->v31.bootup_mclk_in10khz); + }else { +return -EINVAL ; + } + + index =get_index_into_master_table (atom_master_list_of_command_functions_v2_1, + asic_init); +if (amdgpu_atom_parse_cmd_header (mode_info->atom_context, index, &frev, &crev)) { +if (frev ==2 && crev >=1 ) { +memset (&asic_init_ps_v2_1,0 ,sizeof (asic_init_ps_v2_1)); + asic_init_ps_v2_1.param.engineparam.sclkfreqin10khz = bootup_sclk_in10khz; + asic_init_ps_v2_1.param.memparam.mclkfreqin10khz = bootup_mclk_in10khz; + asic_init_ps_v2_1.param.engineparam.engineflag = b3NORMAL_ENGINE_INIT; +if (!fb_reset) + asic_init_ps_v2_1.param.memparam.memflag = b3DRAM_SELF_REFRESH_EXIT; +else + asic_init_ps_v2_1.param.memparam.memflag =0 ; + }else { +return -EINVAL ; + } + }else { +return -EINVAL ; + } + +return amdgpu_atom_execute_table (ctx,ATOM_CMD_INIT , (uint32_t *)&asic_init_ps_v2_1); +}
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h +1 -0
@@ -40,5 +40,6 @@ bool amdgpu_atomfirmware_ras_rom_addr(struct amdgpu_device *adev, uint8_t* i2c_abool amdgpu_atomfirmware_mem_training_supported (struct amdgpu_device *adev);bool amdgpu_atomfirmware_dynamic_boot_config_supported (struct amdgpu_device *adev);int amdgpu_atomfirmware_get_fw_reserved_fb_size (struct amdgpu_device *adev); +int amdgpu_atomfirmware_asic_init (struct amdgpu_device *adev,bool fb_reset);#endif
Signature · 1 line
2.35.1
Alex Deucher
maintainerPATCH 2/2 drm/amdgpu: switch to atomfirmware_asic_init
From: Hawking Zhang <[email protected]>
Some initial settings now are not available from the atom data table. The assumption that !ps[0] || !ps[1] in amdgpu_atom_asic_init is not valid. In addition, driver needs to strictly follow atomfirmware structure (asic_init_parameters) to initialize parameters used to execute asic_init function, otherwise, the execution of asic_init would fail.
This shall be applicable to all soc15 adapters,but let make the transition on soc21 first.
Signed-off-by Hawking Zhang <[email protected]>
Acked-by Alex Deucher <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
@@ -913,7 +913,10 @@ static int amdgpu_device_asic_init(struct amdgpu_device *adev) {amdgpu_asic_pre_asic_init (adev); -return amdgpu_atom_asic_init (adev->mode_info.atom_context); +if (adev->ip_versions[GC_HWIP ][0 ] >=IP_VERSION (11 ,0 ,0 )) +return amdgpu_atomfirmware_asic_init (adev, true); +else +return amdgpu_atom_asic_init (adev->mode_info.atom_context); }/**
Signature · 1 line
2.35.1