diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2016-08-22 23:57:30 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-09-19 13:22:16 -0400 |
commit | 9c6d4956964d4b0282078dc348ca788dc3189d53 (patch) | |
tree | e5ccc0e5bfc289213d1f8a22fd495f9d4e7bef00 /drivers/gpu | |
parent | 5746f90c56ebc9aeca10ee0296f1bc426a4bb2e1 (diff) |
drm/amd/powerplay: use smu7 common functions and data on icelannd.
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>
Diffstat (limited to 'drivers/gpu')
5 files changed, 82 insertions, 609 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c index 5abe43360ec0..50aa23f15540 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_hwmgr.c | |||
@@ -767,12 +767,7 @@ int iceland_program_voting_clients(struct pp_hwmgr *hwmgr) | |||
767 | 767 | ||
768 | static int iceland_upload_firmware(struct pp_hwmgr *hwmgr) | 768 | static int iceland_upload_firmware(struct pp_hwmgr *hwmgr) |
769 | { | 769 | { |
770 | int ret = 0; | 770 | return 0; |
771 | |||
772 | if (!iceland_is_smc_ram_running(hwmgr->smumgr)) | ||
773 | ret = iceland_smu_upload_firmware_image(hwmgr->smumgr); | ||
774 | |||
775 | return ret; | ||
776 | } | 771 | } |
777 | 772 | ||
778 | /** | 773 | /** |
@@ -789,7 +784,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
789 | int result; | 784 | int result; |
790 | bool error = 0; | 785 | bool error = 0; |
791 | 786 | ||
792 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 787 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
793 | SMU71_FIRMWARE_HEADER_LOCATION + | 788 | SMU71_FIRMWARE_HEADER_LOCATION + |
794 | offsetof(SMU71_Firmware_Header, DpmTable), | 789 | offsetof(SMU71_Firmware_Header, DpmTable), |
795 | &tmp, data->sram_end); | 790 | &tmp, data->sram_end); |
@@ -800,7 +795,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
800 | 795 | ||
801 | error |= (0 != result); | 796 | error |= (0 != result); |
802 | 797 | ||
803 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 798 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
804 | SMU71_FIRMWARE_HEADER_LOCATION + | 799 | SMU71_FIRMWARE_HEADER_LOCATION + |
805 | offsetof(SMU71_Firmware_Header, SoftRegisters), | 800 | offsetof(SMU71_Firmware_Header, SoftRegisters), |
806 | &tmp, data->sram_end); | 801 | &tmp, data->sram_end); |
@@ -812,7 +807,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
812 | error |= (0 != result); | 807 | error |= (0 != result); |
813 | 808 | ||
814 | 809 | ||
815 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 810 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
816 | SMU71_FIRMWARE_HEADER_LOCATION + | 811 | SMU71_FIRMWARE_HEADER_LOCATION + |
817 | offsetof(SMU71_Firmware_Header, mcRegisterTable), | 812 | offsetof(SMU71_Firmware_Header, mcRegisterTable), |
818 | &tmp, data->sram_end); | 813 | &tmp, data->sram_end); |
@@ -821,7 +816,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
821 | data->mc_reg_table_start = tmp; | 816 | data->mc_reg_table_start = tmp; |
822 | } | 817 | } |
823 | 818 | ||
824 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 819 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
825 | SMU71_FIRMWARE_HEADER_LOCATION + | 820 | SMU71_FIRMWARE_HEADER_LOCATION + |
826 | offsetof(SMU71_Firmware_Header, FanTable), | 821 | offsetof(SMU71_Firmware_Header, FanTable), |
827 | &tmp, data->sram_end); | 822 | &tmp, data->sram_end); |
@@ -832,7 +827,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
832 | 827 | ||
833 | error |= (0 != result); | 828 | error |= (0 != result); |
834 | 829 | ||
835 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 830 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
836 | SMU71_FIRMWARE_HEADER_LOCATION + | 831 | SMU71_FIRMWARE_HEADER_LOCATION + |
837 | offsetof(SMU71_Firmware_Header, mcArbDramTimingTable), | 832 | offsetof(SMU71_Firmware_Header, mcArbDramTimingTable), |
838 | &tmp, data->sram_end); | 833 | &tmp, data->sram_end); |
@@ -844,7 +839,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
844 | error |= (0 != result); | 839 | error |= (0 != result); |
845 | 840 | ||
846 | 841 | ||
847 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 842 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
848 | SMU71_FIRMWARE_HEADER_LOCATION + | 843 | SMU71_FIRMWARE_HEADER_LOCATION + |
849 | offsetof(SMU71_Firmware_Header, Version), | 844 | offsetof(SMU71_Firmware_Header, Version), |
850 | &tmp, data->sram_end); | 845 | &tmp, data->sram_end); |
@@ -855,7 +850,7 @@ static int iceland_process_firmware_header(struct pp_hwmgr *hwmgr) | |||
855 | 850 | ||
856 | error |= (0 != result); | 851 | error |= (0 != result); |
857 | 852 | ||
858 | result = iceland_read_smc_sram_dword(hwmgr->smumgr, | 853 | result = smu7_read_smc_sram_dword(hwmgr->smumgr, |
859 | SMU71_FIRMWARE_HEADER_LOCATION + | 854 | SMU71_FIRMWARE_HEADER_LOCATION + |
860 | offsetof(SMU71_Firmware_Header, UlvSettings), | 855 | offsetof(SMU71_Firmware_Header, UlvSettings), |
861 | &tmp, data->sram_end); | 856 | &tmp, data->sram_end); |
@@ -1507,7 +1502,7 @@ int iceland_program_memory_timing_parameters(struct pp_hwmgr *hwmgr) | |||
1507 | } | 1502 | } |
1508 | 1503 | ||
1509 | if (0 == result) { | 1504 | if (0 == result) { |
1510 | result = iceland_copy_bytes_to_smc( | 1505 | result = smu7_copy_bytes_to_smc( |
1511 | hwmgr->smumgr, | 1506 | hwmgr->smumgr, |
1512 | data->arb_table_start, | 1507 | data->arb_table_start, |
1513 | (uint8_t *)&arb_regs, | 1508 | (uint8_t *)&arb_regs, |
@@ -2438,7 +2433,7 @@ static int iceland_populate_all_graphic_levels(struct pp_hwmgr *hwmgr) | |||
2438 | data->smc_state_table.GraphicsLevel[1].pcieDpmLevel = mid_pcie_level_enabled; | 2433 | data->smc_state_table.GraphicsLevel[1].pcieDpmLevel = mid_pcie_level_enabled; |
2439 | 2434 | ||
2440 | /* level count will send to smc once at init smc table and never change*/ | 2435 | /* level count will send to smc once at init smc table and never change*/ |
2441 | result = iceland_copy_bytes_to_smc(hwmgr->smumgr, level_array_adress, (uint8_t *)levels, (uint32_t)level_array_size, data->sram_end); | 2436 | result = smu7_copy_bytes_to_smc(hwmgr->smumgr, level_array_adress, (uint8_t *)levels, (uint32_t)level_array_size, data->sram_end); |
2442 | 2437 | ||
2443 | if (0 != result) | 2438 | if (0 != result) |
2444 | return result; | 2439 | return result; |
@@ -2492,7 +2487,7 @@ static int iceland_populate_all_memory_levels(struct pp_hwmgr *hwmgr) | |||
2492 | data->smc_state_table.MemoryLevel[dpm_table->mclk_table.count-1].DisplayWatermark = PPSMC_DISPLAY_WATERMARK_HIGH; | 2487 | data->smc_state_table.MemoryLevel[dpm_table->mclk_table.count-1].DisplayWatermark = PPSMC_DISPLAY_WATERMARK_HIGH; |
2493 | 2488 | ||
2494 | /* level count will send to smc once at init smc table and never change*/ | 2489 | /* level count will send to smc once at init smc table and never change*/ |
2495 | result = iceland_copy_bytes_to_smc(hwmgr->smumgr, | 2490 | result = smu7_copy_bytes_to_smc(hwmgr->smumgr, |
2496 | level_array_adress, (uint8_t *)levels, (uint32_t)level_array_size, data->sram_end); | 2491 | level_array_adress, (uint8_t *)levels, (uint32_t)level_array_size, data->sram_end); |
2497 | 2492 | ||
2498 | if (0 != result) { | 2493 | if (0 != result) { |
@@ -2754,7 +2749,7 @@ static int iceland_init_smc_table(struct pp_hwmgr *hwmgr) | |||
2754 | table->BootMVdd = PP_HOST_TO_SMC_US(table->BootMVdd * VOLTAGE_SCALE); | 2749 | table->BootMVdd = PP_HOST_TO_SMC_US(table->BootMVdd * VOLTAGE_SCALE); |
2755 | 2750 | ||
2756 | /* Upload all dpm data to SMC memory.(dpm level, dpm level count etc) */ | 2751 | /* Upload all dpm data to SMC memory.(dpm level, dpm level count etc) */ |
2757 | result = iceland_copy_bytes_to_smc(hwmgr->smumgr, data->dpm_table_start + | 2752 | result = smu7_copy_bytes_to_smc(hwmgr->smumgr, data->dpm_table_start + |
2758 | offsetof(SMU71_Discrete_DpmTable, SystemFlags), | 2753 | offsetof(SMU71_Discrete_DpmTable, SystemFlags), |
2759 | (uint8_t *)&(table->SystemFlags), | 2754 | (uint8_t *)&(table->SystemFlags), |
2760 | sizeof(SMU71_Discrete_DpmTable) - 3 * sizeof(SMU71_PIDController), | 2755 | sizeof(SMU71_Discrete_DpmTable) - 3 * sizeof(SMU71_PIDController), |
@@ -2764,7 +2759,7 @@ static int iceland_init_smc_table(struct pp_hwmgr *hwmgr) | |||
2764 | "Failed to upload dpm data to SMC memory!", return result); | 2759 | "Failed to upload dpm data to SMC memory!", return result); |
2765 | 2760 | ||
2766 | /* Upload all ulv setting to SMC memory.(dpm level, dpm level count etc) */ | 2761 | /* Upload all ulv setting to SMC memory.(dpm level, dpm level count etc) */ |
2767 | result = iceland_copy_bytes_to_smc(hwmgr->smumgr, | 2762 | result = smu7_copy_bytes_to_smc(hwmgr->smumgr, |
2768 | data->ulv_settings_start, | 2763 | data->ulv_settings_start, |
2769 | (uint8_t *)&(data->ulv_setting), | 2764 | (uint8_t *)&(data->ulv_setting), |
2770 | sizeof(SMU71_Discrete_Ulv), | 2765 | sizeof(SMU71_Discrete_Ulv), |
@@ -2884,7 +2879,7 @@ int iceland_populate_initial_mc_reg_table(struct pp_hwmgr *hwmgr) | |||
2884 | PP_ASSERT_WITH_CODE(0 == result, | 2879 | PP_ASSERT_WITH_CODE(0 == result, |
2885 | "Failed to initialize MCRegTable for driver state!", return result;); | 2880 | "Failed to initialize MCRegTable for driver state!", return result;); |
2886 | 2881 | ||
2887 | return iceland_copy_bytes_to_smc(hwmgr->smumgr, data->mc_reg_table_start, | 2882 | return smu7_copy_bytes_to_smc(hwmgr->smumgr, data->mc_reg_table_start, |
2888 | (uint8_t *)&data->mc_reg_table, sizeof(SMU71_Discrete_MCRegisters), data->sram_end); | 2883 | (uint8_t *)&data->mc_reg_table, sizeof(SMU71_Discrete_MCRegisters), data->sram_end); |
2889 | } | 2884 | } |
2890 | 2885 | ||
@@ -3047,15 +3042,6 @@ static int iceland_enable_thermal_auto_throttle(struct pp_hwmgr *hwmgr) | |||
3047 | return iceland_enable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); | 3042 | return iceland_enable_auto_throttle_source(hwmgr, PHM_AutoThrottleSource_Thermal); |
3048 | } | 3043 | } |
3049 | 3044 | ||
3050 | static int iceland_tf_start_smc(struct pp_hwmgr *hwmgr) | ||
3051 | { | ||
3052 | int ret = 0; | ||
3053 | |||
3054 | if (!iceland_is_smc_ram_running(hwmgr->smumgr)) | ||
3055 | ret = iceland_smu_start_smc(hwmgr->smumgr); | ||
3056 | |||
3057 | return ret; | ||
3058 | } | ||
3059 | 3045 | ||
3060 | /** | 3046 | /** |
3061 | * Programs the Deep Sleep registers | 3047 | * Programs the Deep Sleep registers |
@@ -3141,10 +3127,6 @@ static int iceland_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
3141 | PP_ASSERT_WITH_CODE((0 == tmp_result), | 3127 | PP_ASSERT_WITH_CODE((0 == tmp_result), |
3142 | "Failed to populate PM fuses!", return tmp_result); | 3128 | "Failed to populate PM fuses!", return tmp_result); |
3143 | 3129 | ||
3144 | /* start SMC */ | ||
3145 | tmp_result = iceland_tf_start_smc(hwmgr); | ||
3146 | PP_ASSERT_WITH_CODE((0 == tmp_result), | ||
3147 | "Failed to start SMC!", return tmp_result); | ||
3148 | 3130 | ||
3149 | /* enable SCLK control */ | 3131 | /* enable SCLK control */ |
3150 | tmp_result = iceland_enable_sclk_control(hwmgr); | 3132 | tmp_result = iceland_enable_sclk_control(hwmgr); |
@@ -4636,7 +4618,7 @@ static int iceland_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
4636 | 4618 | ||
4637 | CONVERT_FROM_HOST_TO_SMC_UL(low_sclk_interrupt_threshold); | 4619 | CONVERT_FROM_HOST_TO_SMC_UL(low_sclk_interrupt_threshold); |
4638 | 4620 | ||
4639 | result = iceland_copy_bytes_to_smc( | 4621 | result = smu7_copy_bytes_to_smc( |
4640 | hwmgr->smumgr, | 4622 | hwmgr->smumgr, |
4641 | data->dpm_table_start + offsetof(SMU71_Discrete_DpmTable, | 4623 | data->dpm_table_start + offsetof(SMU71_Discrete_DpmTable, |
4642 | LowSclkInterruptThreshold), | 4624 | LowSclkInterruptThreshold), |
@@ -4670,7 +4652,7 @@ static int iceland_update_and_upload_mc_reg_table(struct pp_hwmgr *hwmgr) | |||
4670 | 4652 | ||
4671 | address = data->mc_reg_table_start + (uint32_t)offsetof(SMU71_Discrete_MCRegisters, data[0]); | 4653 | address = data->mc_reg_table_start + (uint32_t)offsetof(SMU71_Discrete_MCRegisters, data[0]); |
4672 | 4654 | ||
4673 | return iceland_copy_bytes_to_smc(hwmgr->smumgr, address, | 4655 | return smu7_copy_bytes_to_smc(hwmgr->smumgr, address, |
4674 | (uint8_t *)&data->mc_reg_table.data[0], | 4656 | (uint8_t *)&data->mc_reg_table.data[0], |
4675 | sizeof(SMU71_Discrete_MCRegisterSet) * data->dpm_table.mclk_table.count, | 4657 | sizeof(SMU71_Discrete_MCRegisterSet) * data->dpm_table.mclk_table.count, |
4676 | data->sram_end); | 4658 | data->sram_end); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_powertune.c index 041e9648e592..766280626836 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_powertune.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_powertune.c | |||
@@ -239,7 +239,7 @@ static int iceland_populate_dw8(struct pp_hwmgr *hwmgr, uint32_t fuse_table_offs | |||
239 | const struct iceland_pt_defaults *defaults = data->power_tune_defaults; | 239 | const struct iceland_pt_defaults *defaults = data->power_tune_defaults; |
240 | uint32_t temp; | 240 | uint32_t temp; |
241 | 241 | ||
242 | if (iceland_read_smc_sram_dword(hwmgr->smumgr, | 242 | if (smu7_read_smc_sram_dword(hwmgr->smumgr, |
243 | fuse_table_offset + | 243 | fuse_table_offset + |
244 | offsetof(SMU71_Discrete_PmFuses, TdcWaterfallCtl), | 244 | offsetof(SMU71_Discrete_PmFuses, TdcWaterfallCtl), |
245 | (uint32_t *)&temp, data->sram_end)) | 245 | (uint32_t *)&temp, data->sram_end)) |
@@ -299,7 +299,7 @@ int iceland_populate_pm_fuses(struct pp_hwmgr *hwmgr) | |||
299 | 299 | ||
300 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 300 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
301 | PHM_PlatformCaps_PowerContainment)) { | 301 | PHM_PlatformCaps_PowerContainment)) { |
302 | if (iceland_read_smc_sram_dword(hwmgr->smumgr, | 302 | if (smu7_read_smc_sram_dword(hwmgr->smumgr, |
303 | SMU71_FIRMWARE_HEADER_LOCATION + | 303 | SMU71_FIRMWARE_HEADER_LOCATION + |
304 | offsetof(SMU71_Firmware_Header, PmFuseTable), | 304 | offsetof(SMU71_Firmware_Header, PmFuseTable), |
305 | &pm_fuse_table_offset, data->sram_end)) | 305 | &pm_fuse_table_offset, data->sram_end)) |
@@ -359,7 +359,7 @@ int iceland_populate_pm_fuses(struct pp_hwmgr *hwmgr) | |||
359 | "Attempt to populate BapmVddCBaseLeakage Hi and Lo Sidd Failed!", | 359 | "Attempt to populate BapmVddCBaseLeakage Hi and Lo Sidd Failed!", |
360 | return -EINVAL); | 360 | return -EINVAL); |
361 | 361 | ||
362 | if (iceland_copy_bytes_to_smc(hwmgr->smumgr, pm_fuse_table_offset, | 362 | if (smu7_copy_bytes_to_smc(hwmgr->smumgr, pm_fuse_table_offset, |
363 | (uint8_t *)&data->power_tune_table, | 363 | (uint8_t *)&data->power_tune_table, |
364 | sizeof(struct SMU71_Discrete_PmFuses), data->sram_end)) | 364 | sizeof(struct SMU71_Discrete_PmFuses), data->sram_end)) |
365 | PP_ASSERT_WITH_CODE(false, | 365 | PP_ASSERT_WITH_CODE(false, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_thermal.c index 527f37022424..45d17d715640 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/iceland_thermal.c | |||
@@ -426,7 +426,7 @@ int tf_iceland_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, void *input, void | |||
426 | 426 | ||
427 | //fan_table.FanControl_GL_Flag = 1; | 427 | //fan_table.FanControl_GL_Flag = 1; |
428 | 428 | ||
429 | res = iceland_copy_bytes_to_smc(hwmgr->smumgr, data->fan_table_start, (uint8_t *)&fan_table, (uint32_t)sizeof(fan_table), data->sram_end); | 429 | res = smu7_copy_bytes_to_smc(hwmgr->smumgr, data->fan_table_start, (uint8_t *)&fan_table, (uint32_t)sizeof(fan_table), data->sram_end); |
430 | /* TO DO FOR SOME DEVICE ID 0X692b, send this msg return invalid command. | 430 | /* TO DO FOR SOME DEVICE ID 0X692b, send this msg return invalid command. |
431 | if (res == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit != 0) | 431 | if (res == 0 && hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit != 0) |
432 | res = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanMinPwm, \ | 432 | res = (0 == smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_SetFanMinPwm, \ |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c index f50658332d9d..31b6de858317 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c | |||
@@ -36,119 +36,8 @@ | |||
36 | #include "smu/smu_7_1_1_sh_mask.h" | 36 | #include "smu/smu_7_1_1_sh_mask.h" |
37 | #include "cgs_common.h" | 37 | #include "cgs_common.h" |
38 | 38 | ||
39 | #define ICELAND_SMC_SIZE 0x20000 | 39 | #define ICELAND_SMC_SIZE 0x20000 |
40 | #define BUFFER_SIZE 80000 | ||
41 | #define MAX_STRING_SIZE 15 | ||
42 | #define BUFFER_SIZETWO 131072 /*128 *1024*/ | ||
43 | 40 | ||
44 | /** | ||
45 | * Set the address for reading/writing the SMC SRAM space. | ||
46 | * @param smumgr the address of the powerplay hardware manager. | ||
47 | * @param smcAddress the address in the SMC RAM to access. | ||
48 | */ | ||
49 | static int iceland_set_smc_sram_address(struct pp_smumgr *smumgr, | ||
50 | uint32_t smcAddress, uint32_t limit) | ||
51 | { | ||
52 | if (smumgr == NULL || smumgr->device == NULL) | ||
53 | return -EINVAL; | ||
54 | PP_ASSERT_WITH_CODE((0 == (3 & smcAddress)), | ||
55 | "SMC address must be 4 byte aligned.", | ||
56 | return -1;); | ||
57 | |||
58 | PP_ASSERT_WITH_CODE((limit > (smcAddress + 3)), | ||
59 | "SMC address is beyond the SMC RAM area.", | ||
60 | return -1;); | ||
61 | |||
62 | cgs_write_register(smumgr->device, mmSMC_IND_INDEX_0, smcAddress); | ||
63 | SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, 0); | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Copy bytes from an array into the SMC RAM space. | ||
70 | * | ||
71 | * @param smumgr the address of the powerplay SMU manager. | ||
72 | * @param smcStartAddress the start address in the SMC RAM to copy bytes to. | ||
73 | * @param src the byte array to copy the bytes from. | ||
74 | * @param byteCount the number of bytes to copy. | ||
75 | */ | ||
76 | int iceland_copy_bytes_to_smc(struct pp_smumgr *smumgr, | ||
77 | uint32_t smcStartAddress, const uint8_t *src, | ||
78 | uint32_t byteCount, uint32_t limit) | ||
79 | { | ||
80 | uint32_t addr; | ||
81 | uint32_t data, orig_data; | ||
82 | int result = 0; | ||
83 | uint32_t extra_shift; | ||
84 | |||
85 | if (smumgr == NULL || smumgr->device == NULL) | ||
86 | return -EINVAL; | ||
87 | PP_ASSERT_WITH_CODE((0 == (3 & smcStartAddress)), | ||
88 | "SMC address must be 4 byte aligned.", | ||
89 | return 0;); | ||
90 | |||
91 | PP_ASSERT_WITH_CODE((limit > (smcStartAddress + byteCount)), | ||
92 | "SMC address is beyond the SMC RAM area.", | ||
93 | return 0;); | ||
94 | |||
95 | addr = smcStartAddress; | ||
96 | |||
97 | while (byteCount >= 4) { | ||
98 | /* | ||
99 | * Bytes are written into the | ||
100 | * SMC address space with the MSB first | ||
101 | */ | ||
102 | data = (src[0] << 24) + (src[1] << 16) + (src[2] << 8) + src[3]; | ||
103 | |||
104 | result = iceland_set_smc_sram_address(smumgr, addr, limit); | ||
105 | |||
106 | if (result) | ||
107 | goto out; | ||
108 | |||
109 | cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data); | ||
110 | |||
111 | src += 4; | ||
112 | byteCount -= 4; | ||
113 | addr += 4; | ||
114 | } | ||
115 | |||
116 | if (0 != byteCount) { | ||
117 | /* Now write odd bytes left, do a read modify write cycle */ | ||
118 | data = 0; | ||
119 | |||
120 | result = iceland_set_smc_sram_address(smumgr, addr, limit); | ||
121 | if (result) | ||
122 | goto out; | ||
123 | |||
124 | orig_data = cgs_read_register(smumgr->device, | ||
125 | mmSMC_IND_DATA_0); | ||
126 | extra_shift = 8 * (4 - byteCount); | ||
127 | |||
128 | while (byteCount > 0) { | ||
129 | data = (data << 8) + *src++; | ||
130 | byteCount--; | ||
131 | } | ||
132 | |||
133 | data <<= extra_shift; | ||
134 | data |= (orig_data & ~((~0UL) << extra_shift)); | ||
135 | |||
136 | result = iceland_set_smc_sram_address(smumgr, addr, limit); | ||
137 | if (result) | ||
138 | goto out; | ||
139 | |||
140 | cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data); | ||
141 | } | ||
142 | |||
143 | out: | ||
144 | return result; | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * Deassert the reset'pin' (set it to high). | ||
149 | * | ||
150 | * @param smumgr the address of the powerplay hardware manager. | ||
151 | */ | ||
152 | static int iceland_start_smc(struct pp_smumgr *smumgr) | 41 | static int iceland_start_smc(struct pp_smumgr *smumgr) |
153 | { | 42 | { |
154 | SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, | 43 | SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, |
@@ -157,284 +46,15 @@ static int iceland_start_smc(struct pp_smumgr *smumgr) | |||
157 | return 0; | 46 | return 0; |
158 | } | 47 | } |
159 | 48 | ||
160 | static void iceland_pp_reset_smc(struct pp_smumgr *smumgr) | 49 | static void iceland_reset_smc(struct pp_smumgr *smumgr) |
161 | { | 50 | { |
162 | SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, | 51 | SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, |
163 | SMC_SYSCON_RESET_CNTL, | 52 | SMC_SYSCON_RESET_CNTL, |
164 | rst_reg, 1); | 53 | rst_reg, 1); |
165 | } | 54 | } |
166 | 55 | ||
167 | int iceland_program_jump_on_start(struct pp_smumgr *smumgr) | ||
168 | { | ||
169 | static const unsigned char pData[] = { 0xE0, 0x00, 0x80, 0x40 }; | ||
170 | |||
171 | iceland_copy_bytes_to_smc(smumgr, 0x0, pData, 4, sizeof(pData)+1); | ||
172 | 56 | ||
173 | return 0; | 57 | static void iceland_stop_smc_clock(struct pp_smumgr *smumgr) |
174 | } | ||
175 | |||
176 | /** | ||
177 | * Return if the SMC is currently running. | ||
178 | * | ||
179 | * @param smumgr the address of the powerplay hardware manager. | ||
180 | */ | ||
181 | bool iceland_is_smc_ram_running(struct pp_smumgr *smumgr) | ||
182 | { | ||
183 | uint32_t val1, val2; | ||
184 | |||
185 | val1 = SMUM_READ_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, | ||
186 | SMC_SYSCON_CLOCK_CNTL_0, ck_disable); | ||
187 | val2 = cgs_read_ind_register(smumgr->device, CGS_IND_REG__SMC, | ||
188 | ixSMC_PC_C); | ||
189 | |||
190 | return ((0 == val1) && (0x20100 <= val2)); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Send a message to the SMC, and wait for its response. | ||
195 | * | ||
196 | * @param smumgr the address of the powerplay hardware manager. | ||
197 | * @param msg the message to send. | ||
198 | * @return The response that came from the SMC. | ||
199 | */ | ||
200 | static int iceland_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg) | ||
201 | { | ||
202 | if (smumgr == NULL || smumgr->device == NULL) | ||
203 | return -EINVAL; | ||
204 | |||
205 | if (!iceland_is_smc_ram_running(smumgr)) | ||
206 | return -EINVAL; | ||
207 | |||
208 | SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0); | ||
209 | PP_ASSERT_WITH_CODE( | ||
210 | 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP), | ||
211 | "Failed to send Previous Message.", | ||
212 | ); | ||
213 | |||
214 | cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg); | ||
215 | |||
216 | SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0); | ||
217 | PP_ASSERT_WITH_CODE( | ||
218 | 1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP), | ||
219 | "Failed to send Message.", | ||
220 | ); | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | /** | ||
226 | * Send a message to the SMC with parameter | ||
227 | * | ||
228 | * @param smumgr: the address of the powerplay hardware manager. | ||
229 | * @param msg: the message to send. | ||
230 | * @param parameter: the parameter to send | ||
231 | * @return The response that came from the SMC. | ||
232 | */ | ||
233 | static int iceland_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr, | ||
234 | uint16_t msg, uint32_t parameter) | ||
235 | { | ||
236 | if (smumgr == NULL || smumgr->device == NULL) | ||
237 | return -EINVAL; | ||
238 | |||
239 | cgs_write_register(smumgr->device, mmSMC_MSG_ARG_0, parameter); | ||
240 | |||
241 | return iceland_send_msg_to_smc(smumgr, msg); | ||
242 | } | ||
243 | |||
244 | /* | ||
245 | * Read a 32bit value from the SMC SRAM space. | ||
246 | * ALL PARAMETERS ARE IN HOST BYTE ORDER. | ||
247 | * @param smumgr the address of the powerplay hardware manager. | ||
248 | * @param smcAddress the address in the SMC RAM to access. | ||
249 | * @param value and output parameter for the data read from the SMC SRAM. | ||
250 | */ | ||
251 | int iceland_read_smc_sram_dword(struct pp_smumgr *smumgr, | ||
252 | uint32_t smcAddress, uint32_t *value, | ||
253 | uint32_t limit) | ||
254 | { | ||
255 | int result; | ||
256 | |||
257 | result = iceland_set_smc_sram_address(smumgr, smcAddress, limit); | ||
258 | |||
259 | if (0 != result) | ||
260 | return result; | ||
261 | |||
262 | *value = cgs_read_register(smumgr->device, mmSMC_IND_DATA_0); | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * Write a 32bit value to the SMC SRAM space. | ||
269 | * ALL PARAMETERS ARE IN HOST BYTE ORDER. | ||
270 | * @param smumgr the address of the powerplay hardware manager. | ||
271 | * @param smcAddress the address in the SMC RAM to access. | ||
272 | * @param value to write to the SMC SRAM. | ||
273 | */ | ||
274 | int iceland_write_smc_sram_dword(struct pp_smumgr *smumgr, | ||
275 | uint32_t smcAddress, uint32_t value, | ||
276 | uint32_t limit) | ||
277 | { | ||
278 | int result; | ||
279 | |||
280 | result = iceland_set_smc_sram_address(smumgr, smcAddress, limit); | ||
281 | |||
282 | if (0 != result) | ||
283 | return result; | ||
284 | |||
285 | cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, value); | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | static int iceland_smu_fini(struct pp_smumgr *smumgr) | ||
291 | { | ||
292 | struct iceland_smumgr *priv = (struct iceland_smumgr *)(smumgr->backend); | ||
293 | |||
294 | smu_free_memory(smumgr->device, (void *)priv->header_buffer.handle); | ||
295 | |||
296 | if (smumgr->backend != NULL) { | ||
297 | kfree(smumgr->backend); | ||
298 | smumgr->backend = NULL; | ||
299 | } | ||
300 | |||
301 | cgs_rel_firmware(smumgr->device, CGS_UCODE_ID_SMU); | ||
302 | return 0; | ||
303 | } | ||
304 | |||
305 | static enum cgs_ucode_id iceland_convert_fw_type_to_cgs(uint32_t fw_type) | ||
306 | { | ||
307 | enum cgs_ucode_id result = CGS_UCODE_ID_MAXIMUM; | ||
308 | |||
309 | switch (fw_type) { | ||
310 | case UCODE_ID_SMU: | ||
311 | result = CGS_UCODE_ID_SMU; | ||
312 | break; | ||
313 | case UCODE_ID_SDMA0: | ||
314 | result = CGS_UCODE_ID_SDMA0; | ||
315 | break; | ||
316 | case UCODE_ID_SDMA1: | ||
317 | result = CGS_UCODE_ID_SDMA1; | ||
318 | break; | ||
319 | case UCODE_ID_CP_CE: | ||
320 | result = CGS_UCODE_ID_CP_CE; | ||
321 | break; | ||
322 | case UCODE_ID_CP_PFP: | ||
323 | result = CGS_UCODE_ID_CP_PFP; | ||
324 | break; | ||
325 | case UCODE_ID_CP_ME: | ||
326 | result = CGS_UCODE_ID_CP_ME; | ||
327 | break; | ||
328 | case UCODE_ID_CP_MEC: | ||
329 | result = CGS_UCODE_ID_CP_MEC; | ||
330 | break; | ||
331 | case UCODE_ID_CP_MEC_JT1: | ||
332 | result = CGS_UCODE_ID_CP_MEC_JT1; | ||
333 | break; | ||
334 | case UCODE_ID_CP_MEC_JT2: | ||
335 | result = CGS_UCODE_ID_CP_MEC_JT2; | ||
336 | break; | ||
337 | case UCODE_ID_RLC_G: | ||
338 | result = CGS_UCODE_ID_RLC_G; | ||
339 | break; | ||
340 | default: | ||
341 | break; | ||
342 | } | ||
343 | |||
344 | return result; | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * Convert the PPIRI firmware type to SMU type mask. | ||
349 | * For MEC, we need to check all MEC related type | ||
350 | */ | ||
351 | static uint16_t iceland_get_mask_for_firmware_type(uint16_t firmwareType) | ||
352 | { | ||
353 | uint16_t result = 0; | ||
354 | |||
355 | switch (firmwareType) { | ||
356 | case UCODE_ID_SDMA0: | ||
357 | result = UCODE_ID_SDMA0_MASK; | ||
358 | break; | ||
359 | case UCODE_ID_SDMA1: | ||
360 | result = UCODE_ID_SDMA1_MASK; | ||
361 | break; | ||
362 | case UCODE_ID_CP_CE: | ||
363 | result = UCODE_ID_CP_CE_MASK; | ||
364 | break; | ||
365 | case UCODE_ID_CP_PFP: | ||
366 | result = UCODE_ID_CP_PFP_MASK; | ||
367 | break; | ||
368 | case UCODE_ID_CP_ME: | ||
369 | result = UCODE_ID_CP_ME_MASK; | ||
370 | break; | ||
371 | case UCODE_ID_CP_MEC: | ||
372 | case UCODE_ID_CP_MEC_JT1: | ||
373 | case UCODE_ID_CP_MEC_JT2: | ||
374 | result = UCODE_ID_CP_MEC_MASK; | ||
375 | break; | ||
376 | case UCODE_ID_RLC_G: | ||
377 | result = UCODE_ID_RLC_G_MASK; | ||
378 | break; | ||
379 | default: | ||
380 | break; | ||
381 | } | ||
382 | |||
383 | return result; | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * Check if the FW has been loaded, | ||
388 | * SMU will not return if loading has not finished. | ||
389 | */ | ||
390 | static int iceland_check_fw_load_finish(struct pp_smumgr *smumgr, uint32_t fwType) | ||
391 | { | ||
392 | uint16_t fwMask = iceland_get_mask_for_firmware_type(fwType); | ||
393 | |||
394 | if (0 != SMUM_WAIT_VFPF_INDIRECT_REGISTER(smumgr, SMC_IND, | ||
395 | SOFT_REGISTERS_TABLE_27, fwMask, fwMask)) { | ||
396 | pr_err("[ powerplay ] check firmware loading failed\n"); | ||
397 | return -EINVAL; | ||
398 | } | ||
399 | |||
400 | return 0; | ||
401 | } | ||
402 | |||
403 | /* Populate one firmware image to the data structure */ | ||
404 | static int iceland_populate_single_firmware_entry(struct pp_smumgr *smumgr, | ||
405 | uint16_t firmware_type, | ||
406 | struct SMU_Entry *pentry) | ||
407 | { | ||
408 | int result; | ||
409 | struct cgs_firmware_info info = {0}; | ||
410 | |||
411 | result = cgs_get_firmware_info( | ||
412 | smumgr->device, | ||
413 | iceland_convert_fw_type_to_cgs(firmware_type), | ||
414 | &info); | ||
415 | |||
416 | if (result == 0) { | ||
417 | pentry->version = 0; | ||
418 | pentry->id = (uint16_t)firmware_type; | ||
419 | pentry->image_addr_high = smu_upper_32_bits(info.mc_addr); | ||
420 | pentry->image_addr_low = smu_lower_32_bits(info.mc_addr); | ||
421 | pentry->meta_data_addr_high = 0; | ||
422 | pentry->meta_data_addr_low = 0; | ||
423 | pentry->data_size_byte = info.image_size; | ||
424 | pentry->num_register_entries = 0; | ||
425 | |||
426 | if (firmware_type == UCODE_ID_RLC_G) | ||
427 | pentry->flags = 1; | ||
428 | else | ||
429 | pentry->flags = 0; | ||
430 | } else { | ||
431 | return result; | ||
432 | } | ||
433 | |||
434 | return result; | ||
435 | } | ||
436 | |||
437 | static void iceland_pp_stop_smc_clock(struct pp_smumgr *smumgr) | ||
438 | { | 58 | { |
439 | SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, | 59 | SMUM_WRITE_INDIRECT_FIELD(smumgr->device, CGS_IND_REG__SMC, |
440 | SMC_SYSCON_CLOCK_CNTL_0, | 60 | SMC_SYSCON_CLOCK_CNTL_0, |
@@ -448,10 +68,10 @@ static void iceland_start_smc_clock(struct pp_smumgr *smumgr) | |||
448 | ck_disable, 0); | 68 | ck_disable, 0); |
449 | } | 69 | } |
450 | 70 | ||
451 | int iceland_smu_start_smc(struct pp_smumgr *smumgr) | 71 | static int iceland_smu_start_smc(struct pp_smumgr *smumgr) |
452 | { | 72 | { |
453 | /* set smc instruct start point at 0x0 */ | 73 | /* set smc instruct start point at 0x0 */ |
454 | iceland_program_jump_on_start(smumgr); | 74 | smu7_program_jump_on_start(smumgr); |
455 | 75 | ||
456 | /* enable smc clock */ | 76 | /* enable smc clock */ |
457 | iceland_start_smc_clock(smumgr); | 77 | iceland_start_smc_clock(smumgr); |
@@ -465,17 +85,37 @@ int iceland_smu_start_smc(struct pp_smumgr *smumgr) | |||
465 | return 0; | 85 | return 0; |
466 | } | 86 | } |
467 | 87 | ||
468 | /** | 88 | |
469 | * Upload the SMC firmware to the SMC microcontroller. | 89 | static int iceland_upload_smc_firmware_data(struct pp_smumgr *smumgr, |
470 | * | 90 | uint32_t length, const uint8_t *src, |
471 | * @param smumgr the address of the powerplay hardware manager. | 91 | uint32_t limit, uint32_t start_addr) |
472 | * @param pFirmware the data structure containing the various sections of the firmware. | ||
473 | */ | ||
474 | int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr) | ||
475 | { | 92 | { |
476 | const uint8_t *src; | 93 | uint32_t byte_count = length; |
477 | uint32_t byte_count, val; | ||
478 | uint32_t data; | 94 | uint32_t data; |
95 | |||
96 | PP_ASSERT_WITH_CODE((limit >= byte_count), "SMC address is beyond the SMC RAM area.", return -EINVAL); | ||
97 | |||
98 | cgs_write_register(smumgr->device, mmSMC_IND_INDEX_0, start_addr); | ||
99 | SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, 1); | ||
100 | |||
101 | while (byte_count >= 4) { | ||
102 | data = src[0] * 0x1000000 + src[1] * 0x10000 + src[2] * 0x100 + src[3]; | ||
103 | cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data); | ||
104 | src += 4; | ||
105 | byte_count -= 4; | ||
106 | } | ||
107 | |||
108 | SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, 0); | ||
109 | |||
110 | PP_ASSERT_WITH_CODE((0 == byte_count), "SMC size must be dividable by 4.", return -EINVAL); | ||
111 | |||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | |||
116 | static int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr) | ||
117 | { | ||
118 | uint32_t val; | ||
479 | struct cgs_firmware_info info = {0}; | 119 | struct cgs_firmware_info info = {0}; |
480 | 120 | ||
481 | if (smumgr == NULL || smumgr->device == NULL) | 121 | if (smumgr == NULL || smumgr->device == NULL) |
@@ -483,7 +123,7 @@ int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr) | |||
483 | 123 | ||
484 | /* load SMC firmware */ | 124 | /* load SMC firmware */ |
485 | cgs_get_firmware_info(smumgr->device, | 125 | cgs_get_firmware_info(smumgr->device, |
486 | iceland_convert_fw_type_to_cgs(UCODE_ID_SMU), &info); | 126 | smu7_convert_fw_type_to_cgs(UCODE_ID_SMU), &info); |
487 | 127 | ||
488 | if (info.image_size & 3) { | 128 | if (info.image_size & 3) { |
489 | pr_err("[ powerplay ] SMC ucode is not 4 bytes aligned\n"); | 129 | pr_err("[ powerplay ] SMC ucode is not 4 bytes aligned\n"); |
@@ -506,122 +146,17 @@ int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr) | |||
506 | ixSMC_SYSCON_MISC_CNTL, val | 1); | 146 | ixSMC_SYSCON_MISC_CNTL, val | 1); |
507 | 147 | ||
508 | /* stop smc clock */ | 148 | /* stop smc clock */ |
509 | iceland_pp_stop_smc_clock(smumgr); | 149 | iceland_stop_smc_clock(smumgr); |
510 | 150 | ||
511 | /* reset smc */ | 151 | /* reset smc */ |
512 | iceland_pp_reset_smc(smumgr); | 152 | iceland_reset_smc(smumgr); |
513 | 153 | iceland_upload_smc_firmware_data(smumgr, info.image_size, | |
514 | cgs_write_register(smumgr->device, mmSMC_IND_INDEX_0, | 154 | (uint8_t *)info.kptr, ICELAND_SMC_SIZE, |
515 | info.ucode_start_address); | 155 | info.ucode_start_address); |
516 | |||
517 | SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, | ||
518 | AUTO_INCREMENT_IND_0, 1); | ||
519 | |||
520 | byte_count = info.image_size; | ||
521 | src = (const uint8_t *)info.kptr; | ||
522 | |||
523 | while (byte_count >= 4) { | ||
524 | data = (src[0] << 24) + (src[1] << 16) + (src[2] << 8) + src[3]; | ||
525 | cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data); | ||
526 | src += 4; | ||
527 | byte_count -= 4; | ||
528 | } | ||
529 | |||
530 | SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, | ||
531 | AUTO_INCREMENT_IND_0, 0); | ||
532 | 156 | ||
533 | return 0; | 157 | return 0; |
534 | } | 158 | } |
535 | 159 | ||
536 | static int iceland_request_smu_reload_fw(struct pp_smumgr *smumgr) | ||
537 | { | ||
538 | struct iceland_smumgr *iceland_smu = | ||
539 | (struct iceland_smumgr *)(smumgr->backend); | ||
540 | uint16_t fw_to_load; | ||
541 | int result = 0; | ||
542 | struct SMU_DRAMData_TOC *toc; | ||
543 | |||
544 | toc = (struct SMU_DRAMData_TOC *)iceland_smu->pHeader; | ||
545 | toc->num_entries = 0; | ||
546 | toc->structure_version = 1; | ||
547 | |||
548 | PP_ASSERT_WITH_CODE( | ||
549 | 0 == iceland_populate_single_firmware_entry(smumgr, | ||
550 | UCODE_ID_RLC_G, | ||
551 | &toc->entry[toc->num_entries++]), | ||
552 | "Failed to Get Firmware Entry.\n", | ||
553 | return -1); | ||
554 | PP_ASSERT_WITH_CODE( | ||
555 | 0 == iceland_populate_single_firmware_entry(smumgr, | ||
556 | UCODE_ID_CP_CE, | ||
557 | &toc->entry[toc->num_entries++]), | ||
558 | "Failed to Get Firmware Entry.\n", | ||
559 | return -1); | ||
560 | PP_ASSERT_WITH_CODE( | ||
561 | 0 == iceland_populate_single_firmware_entry | ||
562 | (smumgr, UCODE_ID_CP_PFP, &toc->entry[toc->num_entries++]), | ||
563 | "Failed to Get Firmware Entry.\n", return -1); | ||
564 | PP_ASSERT_WITH_CODE( | ||
565 | 0 == iceland_populate_single_firmware_entry | ||
566 | (smumgr, UCODE_ID_CP_ME, &toc->entry[toc->num_entries++]), | ||
567 | "Failed to Get Firmware Entry.\n", return -1); | ||
568 | PP_ASSERT_WITH_CODE( | ||
569 | 0 == iceland_populate_single_firmware_entry | ||
570 | (smumgr, UCODE_ID_CP_MEC, &toc->entry[toc->num_entries++]), | ||
571 | "Failed to Get Firmware Entry.\n", return -1); | ||
572 | PP_ASSERT_WITH_CODE( | ||
573 | 0 == iceland_populate_single_firmware_entry | ||
574 | (smumgr, UCODE_ID_CP_MEC_JT1, &toc->entry[toc->num_entries++]), | ||
575 | "Failed to Get Firmware Entry.\n", return -1); | ||
576 | PP_ASSERT_WITH_CODE( | ||
577 | 0 == iceland_populate_single_firmware_entry | ||
578 | (smumgr, UCODE_ID_CP_MEC_JT2, &toc->entry[toc->num_entries++]), | ||
579 | "Failed to Get Firmware Entry.\n", return -1); | ||
580 | PP_ASSERT_WITH_CODE( | ||
581 | 0 == iceland_populate_single_firmware_entry | ||
582 | (smumgr, UCODE_ID_SDMA0, &toc->entry[toc->num_entries++]), | ||
583 | "Failed to Get Firmware Entry.\n", return -1); | ||
584 | PP_ASSERT_WITH_CODE( | ||
585 | 0 == iceland_populate_single_firmware_entry | ||
586 | (smumgr, UCODE_ID_SDMA1, &toc->entry[toc->num_entries++]), | ||
587 | "Failed to Get Firmware Entry.\n", return -1); | ||
588 | |||
589 | if (!iceland_is_smc_ram_running(smumgr)) { | ||
590 | result = iceland_smu_upload_firmware_image(smumgr); | ||
591 | if (result) | ||
592 | return result; | ||
593 | |||
594 | result = iceland_smu_start_smc(smumgr); | ||
595 | if (result) | ||
596 | return result; | ||
597 | } | ||
598 | |||
599 | iceland_send_msg_to_smc_with_parameter(smumgr, | ||
600 | PPSMC_MSG_DRV_DRAM_ADDR_HI, | ||
601 | iceland_smu->header_buffer.mc_addr_high); | ||
602 | |||
603 | iceland_send_msg_to_smc_with_parameter(smumgr, | ||
604 | PPSMC_MSG_DRV_DRAM_ADDR_LO, | ||
605 | iceland_smu->header_buffer.mc_addr_low); | ||
606 | |||
607 | fw_to_load = UCODE_ID_RLC_G_MASK | ||
608 | + UCODE_ID_SDMA0_MASK | ||
609 | + UCODE_ID_SDMA1_MASK | ||
610 | + UCODE_ID_CP_CE_MASK | ||
611 | + UCODE_ID_CP_ME_MASK | ||
612 | + UCODE_ID_CP_PFP_MASK | ||
613 | + UCODE_ID_CP_MEC_MASK | ||
614 | + UCODE_ID_CP_MEC_JT1_MASK | ||
615 | + UCODE_ID_CP_MEC_JT2_MASK; | ||
616 | |||
617 | PP_ASSERT_WITH_CODE( | ||
618 | 0 == iceland_send_msg_to_smc_with_parameter( | ||
619 | smumgr, PPSMC_MSG_LoadUcodes, fw_to_load), | ||
620 | "Fail to Request SMU Load uCode", return 0); | ||
621 | |||
622 | return result; | ||
623 | } | ||
624 | |||
625 | static int iceland_request_smu_load_specific_fw(struct pp_smumgr *smumgr, | 160 | static int iceland_request_smu_load_specific_fw(struct pp_smumgr *smumgr, |
626 | uint32_t firmwareType) | 161 | uint32_t firmwareType) |
627 | { | 162 | { |
@@ -635,12 +170,22 @@ static int iceland_start_smu(struct pp_smumgr *smumgr) | |||
635 | result = iceland_smu_upload_firmware_image(smumgr); | 170 | result = iceland_smu_upload_firmware_image(smumgr); |
636 | if (result) | 171 | if (result) |
637 | return result; | 172 | return result; |
638 | |||
639 | result = iceland_smu_start_smc(smumgr); | 173 | result = iceland_smu_start_smc(smumgr); |
640 | if (result) | 174 | if (result) |
641 | return result; | 175 | return result; |
642 | 176 | ||
643 | result = iceland_request_smu_reload_fw(smumgr); | 177 | if (!smu7_is_smc_ram_running(smumgr)) { |
178 | printk("smu not running, upload firmware again \n"); | ||
179 | result = iceland_smu_upload_firmware_image(smumgr); | ||
180 | if (result) | ||
181 | return result; | ||
182 | |||
183 | result = iceland_smu_start_smc(smumgr); | ||
184 | if (result) | ||
185 | return result; | ||
186 | } | ||
187 | |||
188 | result = smu7_request_smu_load_fw(smumgr); | ||
644 | 189 | ||
645 | return result; | 190 | return result; |
646 | } | 191 | } |
@@ -654,45 +199,18 @@ static int iceland_start_smu(struct pp_smumgr *smumgr) | |||
654 | */ | 199 | */ |
655 | static int iceland_smu_init(struct pp_smumgr *smumgr) | 200 | static int iceland_smu_init(struct pp_smumgr *smumgr) |
656 | { | 201 | { |
657 | struct iceland_smumgr *iceland_smu; | 202 | return smu7_init(smumgr); |
658 | uint64_t mc_addr = 0; | ||
659 | |||
660 | /* Allocate memory for backend private data */ | ||
661 | iceland_smu = (struct iceland_smumgr *)(smumgr->backend); | ||
662 | iceland_smu->header_buffer.data_size = | ||
663 | ((sizeof(struct SMU_DRAMData_TOC) / 4096) + 1) * 4096; | ||
664 | |||
665 | smu_allocate_memory(smumgr->device, | ||
666 | iceland_smu->header_buffer.data_size, | ||
667 | CGS_GPU_MEM_TYPE__VISIBLE_CONTIG_FB, | ||
668 | PAGE_SIZE, | ||
669 | &mc_addr, | ||
670 | &iceland_smu->header_buffer.kaddr, | ||
671 | &iceland_smu->header_buffer.handle); | ||
672 | |||
673 | iceland_smu->pHeader = iceland_smu->header_buffer.kaddr; | ||
674 | iceland_smu->header_buffer.mc_addr_high = smu_upper_32_bits(mc_addr); | ||
675 | iceland_smu->header_buffer.mc_addr_low = smu_lower_32_bits(mc_addr); | ||
676 | |||
677 | PP_ASSERT_WITH_CODE((NULL != iceland_smu->pHeader), | ||
678 | "Out of memory.", | ||
679 | kfree(smumgr->backend); | ||
680 | cgs_free_gpu_mem(smumgr->device, | ||
681 | (cgs_handle_t)iceland_smu->header_buffer.handle); | ||
682 | return -1); | ||
683 | |||
684 | return 0; | ||
685 | } | 203 | } |
686 | 204 | ||
687 | static const struct pp_smumgr_func iceland_smu_funcs = { | 205 | static const struct pp_smumgr_func iceland_smu_funcs = { |
688 | .smu_init = &iceland_smu_init, | 206 | .smu_init = &iceland_smu_init, |
689 | .smu_fini = &iceland_smu_fini, | 207 | .smu_fini = &smu7_smu_fini, |
690 | .start_smu = &iceland_start_smu, | 208 | .start_smu = &iceland_start_smu, |
691 | .check_fw_load_finish = &iceland_check_fw_load_finish, | 209 | .check_fw_load_finish = &smu7_check_fw_load_finish, |
692 | .request_smu_load_fw = &iceland_request_smu_reload_fw, | 210 | .request_smu_load_fw = &smu7_reload_firmware, |
693 | .request_smu_load_specific_fw = &iceland_request_smu_load_specific_fw, | 211 | .request_smu_load_specific_fw = &iceland_request_smu_load_specific_fw, |
694 | .send_msg_to_smc = &iceland_send_msg_to_smc, | 212 | .send_msg_to_smc = &smu7_send_msg_to_smc, |
695 | .send_msg_to_smc_with_parameter = &iceland_send_msg_to_smc_with_parameter, | 213 | .send_msg_to_smc_with_parameter = &smu7_send_msg_to_smc_with_parameter, |
696 | .download_pptable_settings = NULL, | 214 | .download_pptable_settings = NULL, |
697 | .upload_pptable_settings = NULL, | 215 | .upload_pptable_settings = NULL, |
698 | }; | 216 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.h index 62009a7ae827..331e2782e5b4 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.h | |||
@@ -26,39 +26,12 @@ | |||
26 | #ifndef _ICELAND_SMUMGR_H_ | 26 | #ifndef _ICELAND_SMUMGR_H_ |
27 | #define _ICELAND_SMUMGR_H_ | 27 | #define _ICELAND_SMUMGR_H_ |
28 | 28 | ||
29 | struct iceland_buffer_entry { | ||
30 | uint32_t data_size; | ||
31 | uint32_t mc_addr_low; | ||
32 | uint32_t mc_addr_high; | ||
33 | void *kaddr; | ||
34 | unsigned long handle; | ||
35 | }; | ||
36 | |||
37 | /* Iceland only has header_buffer, don't have smu buffer. */ | ||
38 | struct iceland_smumgr { | ||
39 | uint8_t *pHeader; | ||
40 | uint8_t *pMecImage; | ||
41 | uint32_t ulSoftRegsStart; | ||
42 | |||
43 | struct iceland_buffer_entry header_buffer; | ||
44 | }; | ||
45 | |||
46 | extern int iceland_smum_init(struct pp_smumgr *smumgr); | ||
47 | extern int iceland_copy_bytes_to_smc(struct pp_smumgr *smumgr, | ||
48 | uint32_t smcStartAddress, | ||
49 | const uint8_t *src, | ||
50 | uint32_t byteCount, uint32_t limit); | ||
51 | 29 | ||
52 | extern int iceland_smu_start_smc(struct pp_smumgr *smumgr); | 30 | #include "smu7_smumgr.h" |
53 | 31 | ||
54 | extern int iceland_read_smc_sram_dword(struct pp_smumgr *smumgr, | ||
55 | uint32_t smcAddress, | ||
56 | uint32_t *value, uint32_t limit); | ||
57 | extern int iceland_write_smc_sram_dword(struct pp_smumgr *smumgr, | ||
58 | uint32_t smcAddress, | ||
59 | uint32_t value, uint32_t limit); | ||
60 | 32 | ||
61 | extern bool iceland_is_smc_ram_running(struct pp_smumgr *smumgr); | 33 | struct iceland_smumgr { |
62 | extern int iceland_smu_upload_firmware_image(struct pp_smumgr *smumgr); | 34 | struct smu7_smumgr smu7_data; |
35 | }; | ||
63 | 36 | ||
64 | #endif | 37 | #endif |