drm/amd/powerplay: Add floor DCEF for DS on boot.
authorRex Zhu <Rex.Zhu@amd.com>
Wed, 31 May 2017 08:58:31 +0000 (16:58 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 1 Jun 2017 20:00:18 +0000 (16:00 -0400)
Use the vbios to look up the default frequencies
for socclk and dcefclk.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h

index 56023114ad6fb495a660b45d1b6204f166c6dccb..1ba05cc3a972a5fccd72bdadfd9c2671d470e6ae 100644 (file)
@@ -388,11 +388,33 @@ int pp_atomfwctrl_get_gpio_information(struct pp_hwmgr *hwmgr,
        return 0;
 }
 
+int pp_atomfwctrl__get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLKID id, uint32_t *frequency)
+{
+       struct atom_get_smu_clock_info_parameters_v3_1   parameters;
+       struct atom_get_smu_clock_info_output_parameters_v3_1 *output;
+       uint32_t ix;
+
+       parameters.clk_id = id;
+       parameters.command = GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ;
+
+       ix = GetIndexIntoMasterCmdTable(getsmuclockinfo);
+       if (!cgs_atom_exec_cmd_table(hwmgr->device, ix, &parameters)) {
+               output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)&parameters;
+               *frequency = output->atom_smu_outputclkfreq.smu_clock_freq_hz / 10000;
+       } else {
+               pr_info("Error execute_table getsmuclockinfo!");
+               return -1;
+       }
+
+       return 0;
+}
+
 int pp_atomfwctrl_get_vbios_bootup_values(struct pp_hwmgr *hwmgr,
                        struct pp_atomfwctrl_bios_boot_up_values *boot_values)
 {
        struct atom_firmware_info_v3_1 *info = NULL;
        uint16_t ix;
+       uint32_t frequency = 0;
 
        ix = GetIndexIntoMasterDataTable(firmwareinfo);
        info = (struct atom_firmware_info_v3_1 *)
@@ -407,11 +429,18 @@ int pp_atomfwctrl_get_vbios_bootup_values(struct pp_hwmgr *hwmgr,
        boot_values->ulRevision = info->firmware_revision;
        boot_values->ulGfxClk   = info->bootup_sclk_in10khz;
        boot_values->ulUClk     = info->bootup_mclk_in10khz;
-       boot_values->ulSocClk   = 0;
        boot_values->usVddc     = info->bootup_vddc_mv;
        boot_values->usVddci    = info->bootup_vddci_mv;
        boot_values->usMvddc    = info->bootup_mvddc_mv;
        boot_values->usVddGfx   = info->bootup_vddgfx_mv;
+       boot_values->ulSocClk   = 0;
+       boot_values->ulDCEFClk   = 0;
+
+       if (!pp_atomfwctrl__get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_SOCCLK_ID, &frequency))
+               boot_values->ulSocClk   = frequency;
+
+       if (!pp_atomfwctrl__get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_DCEFCLK_ID, &frequency))
+               boot_values->ulDCEFClk   = frequency;
 
        return 0;
 }
\ No newline at end of file
index 43a6711e3c0648eb93a702d4ae96d3f5310d91e5..81908b5cfd5f11f226df1b9c4054588802394701 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "hwmgr.h"
 
+typedef enum atom_smu9_syspll0_clock_id BIOS_CLKID;
+
 #define GetIndexIntoMasterCmdTable(FieldName) \
        (((char*)(&((struct atom_master_list_of_command_functions_v2_1*)0)->FieldName)-(char*)0)/sizeof(uint16_t))
 #define GetIndexIntoMasterDataTable(FieldName) \
@@ -125,6 +127,7 @@ struct pp_atomfwctrl_bios_boot_up_values {
        uint32_t   ulGfxClk;
        uint32_t   ulUClk;
        uint32_t   ulSocClk;
+       uint32_t   ulDCEFClk;
        uint16_t   usVddc;
        uint16_t   usVddci;
        uint16_t   usMvddc;
index a50a6efaf54c1e338fe5e80642011dedf2b578c9..30bc0537a4b8f5591f788dd318b5bb2ba007efca 100644 (file)
@@ -2451,6 +2451,7 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr)
                data->vbios_boot_state.gfx_clock = boot_up_values.ulGfxClk;
                data->vbios_boot_state.mem_clock = boot_up_values.ulUClk;
                data->vbios_boot_state.soc_clock = boot_up_values.ulSocClk;
+               data->vbios_boot_state.dcef_clock = boot_up_values.ulDCEFClk;
                if (0 != boot_up_values.usVddc) {
                        smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
                                                PPSMC_MSG_SetFloorSocVoltage,
@@ -2459,6 +2460,9 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr)
                } else {
                        data->vbios_boot_state.bsoc_vddc_lock = false;
                }
+               smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
+                               PPSMC_MSG_SetMinDeepSleepDcefclk,
+                       (uint32_t)(data->vbios_boot_state.dcef_clock / 100));
        }
 
        result = vega10_populate_avfs_parameters(hwmgr);
index 1d7dbad66ab39c02b8ecfefeb7df65e71282da05..6e5c5b99593bcb8922546dc4c02983b88019d46b 100644 (file)
@@ -185,6 +185,7 @@ struct vega10_vbios_boot_state {
        uint32_t    gfx_clock;
        uint32_t    mem_clock;
        uint32_t    soc_clock;
+       uint32_t    dcef_clock;
 };
 
 #define DPMTABLE_OD_UPDATE_SCLK     0x00000001