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

drm/amd/display: cleaning up smu_if to add future flexibility

why and how:
need to hook in new smu interfaces
cleaning up code that used old variables

Reviewed-by: Nevenko Stupar <Nevenko.Stupar@amd.com>
Acked-by: Alan Liu <HaoPing.Liu@amd.com>
Signed-off-by: Leung, Martin <Martin.Leung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Leung, Martin and committed by
Alex Deucher
4984e3aa df5a07c4

+86 -99
+3 -10
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c
··· 25 25 26 26 #include "dccg.h" 27 27 #include "clk_mgr_internal.h" 28 - 29 28 #include "dcn30_clk_mgr_smu_msg.h" 30 29 #include "dcn20/dcn20_clk_mgr.h" 31 30 #include "dce100/dce_clk_mgr.h" 31 + #include "dcn30/dcn30_clk_mgr.h" 32 32 #include "reg_helper.h" 33 33 #include "core_types.h" 34 34 #include "dm_helpers.h" 35 - 36 35 #include "atomfirmware.h" 37 - 38 - 39 36 #include "sienna_cichlid_ip_offset.h" 40 37 #include "dcn/dcn_3_0_0_offset.h" 41 38 #include "dcn/dcn_3_0_0_sh_mask.h" 42 - 43 39 #include "nbio/nbio_7_4_offset.h" 44 - 45 40 #include "dpcs/dpcs_3_0_0_offset.h" 46 41 #include "dpcs/dpcs_3_0_0_sh_mask.h" 47 - 48 42 #include "mmhub/mmhub_2_0_0_offset.h" 49 43 #include "mmhub/mmhub_2_0_0_sh_mask.h" 50 - /*we don't have clk folder yet*/ 51 - #include "dcn30/dcn30_clk_mgr.h" 44 + #include "dcn30_smu11_driver_if.h" 52 45 53 46 #undef FN 54 47 #define FN(reg_name, field_name) \ ··· 76 83 77 84 78 85 /* Query SMU for all clock states for a particular clock */ 79 - static void dcn3_init_single_clock(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, unsigned int *entry_0, unsigned int *num_levels) 86 + static void dcn3_init_single_clock(struct clk_mgr_internal *clk_mgr, uint32_t clk, unsigned int *entry_0, unsigned int *num_levels) 80 87 { 81 88 unsigned int i; 82 89 char *entry_i = (char *)entry_0;
+5 -4
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.c
··· 29 29 #include "clk_mgr_internal.h" 30 30 #include "reg_helper.h" 31 31 #include "dalsmc.h" 32 + #include "dcn30_smu11_driver_if.h" 32 33 33 34 #define mmDAL_MSG_REG 0x1628A 34 35 #define mmDAL_ARG_REG 0x16273 ··· 198 197 } 199 198 200 199 /* Returns the actual frequency that was set in MHz, 0 on failure */ 201 - unsigned int dcn30_smu_set_hard_min_by_freq(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, uint16_t freq_mhz) 200 + unsigned int dcn30_smu_set_hard_min_by_freq(struct clk_mgr_internal *clk_mgr, uint32_t clk, uint16_t freq_mhz) 202 201 { 203 202 uint32_t response = 0; 204 203 ··· 216 215 } 217 216 218 217 /* Returns the actual frequency that was set in MHz, 0 on failure */ 219 - unsigned int dcn30_smu_set_hard_max_by_freq(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, uint16_t freq_mhz) 218 + unsigned int dcn30_smu_set_hard_max_by_freq(struct clk_mgr_internal *clk_mgr, uint32_t clk, uint16_t freq_mhz) 220 219 { 221 220 uint32_t response = 0; 222 221 ··· 247 246 * 248 247 * Returns 0 on failure 249 248 */ 250 - unsigned int dcn30_smu_get_dpm_freq_by_index(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, uint8_t dpm_level) 249 + unsigned int dcn30_smu_get_dpm_freq_by_index(struct clk_mgr_internal *clk_mgr, uint32_t clk, uint8_t dpm_level) 251 250 { 252 251 uint32_t response = 0; 253 252 ··· 265 264 } 266 265 267 266 /* Returns the max DPM frequency in DC mode in MHz, 0 on failure */ 268 - unsigned int dcn30_smu_get_dc_mode_max_dpm_freq(struct clk_mgr_internal *clk_mgr, PPCLK_e clk) 267 + unsigned int dcn30_smu_get_dc_mode_max_dpm_freq(struct clk_mgr_internal *clk_mgr, uint32_t clk) 269 268 { 270 269 uint32_t response = 0; 271 270
+4 -63
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr_smu_msg.h
··· 28 28 29 29 #include "core_types.h" 30 30 31 - #define SMU11_DRIVER_IF_VERSION 0x1F 32 - 33 - typedef enum { 34 - PPCLK_GFXCLK = 0, 35 - PPCLK_SOCCLK, 36 - PPCLK_UCLK, 37 - PPCLK_FCLK, 38 - PPCLK_DCLK_0, 39 - PPCLK_VCLK_0, 40 - PPCLK_DCLK_1, 41 - PPCLK_VCLK_1, 42 - PPCLK_DCEFCLK, 43 - PPCLK_DISPCLK, 44 - PPCLK_PIXCLK, 45 - PPCLK_PHYCLK, 46 - PPCLK_DTBCLK, 47 - PPCLK_COUNT, 48 - } PPCLK_e; 49 - 50 - typedef struct { 51 - uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz) 52 - uint16_t MaxClock; // This is either DCEFCLK or SOCCLK (in MHz) 53 - uint16_t MinUclk; 54 - uint16_t MaxUclk; 55 - 56 - uint8_t WmSetting; 57 - uint8_t Flags; 58 - uint8_t Padding[2]; 59 - 60 - } WatermarkRowGeneric_t; 61 - 62 - #define NUM_WM_RANGES 4 63 - 64 - typedef enum { 65 - WM_SOCCLK = 0, 66 - WM_DCEFCLK, 67 - WM_COUNT, 68 - } WM_CLOCK_e; 69 - 70 - typedef enum { 71 - WATERMARKS_CLOCK_RANGE = 0, 72 - WATERMARKS_DUMMY_PSTATE, 73 - WATERMARKS_MALL, 74 - WATERMARKS_COUNT, 75 - } WATERMARKS_FLAGS_e; 76 - 77 - typedef struct { 78 - // Watermarks 79 - WatermarkRowGeneric_t WatermarkRow[WM_COUNT][NUM_WM_RANGES]; 80 - } Watermarks_t; 81 - 82 - typedef struct { 83 - Watermarks_t Watermarks; 84 - 85 - uint32_t MmHubPadding[8]; // SMU internal use 86 - } WatermarksExternal_t; 87 - 88 - #define TABLE_WATERMARKS 1 89 - 90 31 struct clk_mgr_internal; 91 32 92 33 bool dcn30_smu_test_message(struct clk_mgr_internal *clk_mgr, uint32_t input); ··· 38 97 void dcn30_smu_set_dram_addr_low(struct clk_mgr_internal *clk_mgr, uint32_t addr_low); 39 98 void dcn30_smu_transfer_wm_table_smu_2_dram(struct clk_mgr_internal *clk_mgr); 40 99 void dcn30_smu_transfer_wm_table_dram_2_smu(struct clk_mgr_internal *clk_mgr); 41 - unsigned int dcn30_smu_set_hard_min_by_freq(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, uint16_t freq_mhz); 42 - unsigned int dcn30_smu_set_hard_max_by_freq(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, uint16_t freq_mhz); 43 - unsigned int dcn30_smu_get_dpm_freq_by_index(struct clk_mgr_internal *clk_mgr, PPCLK_e clk, uint8_t dpm_level); 44 - unsigned int dcn30_smu_get_dc_mode_max_dpm_freq(struct clk_mgr_internal *clk_mgr, PPCLK_e clk); 100 + unsigned int dcn30_smu_set_hard_min_by_freq(struct clk_mgr_internal *clk_mgr, uint32_t clk, uint16_t freq_mhz); 101 + unsigned int dcn30_smu_set_hard_max_by_freq(struct clk_mgr_internal *clk_mgr, uint32_t clk, uint16_t freq_mhz); 102 + unsigned int dcn30_smu_get_dpm_freq_by_index(struct clk_mgr_internal *clk_mgr, uint32_t clk, uint8_t dpm_level); 103 + unsigned int dcn30_smu_get_dc_mode_max_dpm_freq(struct clk_mgr_internal *clk_mgr, uint32_t clk); 45 104 void dcn30_smu_set_min_deep_sleep_dcef_clk(struct clk_mgr_internal *clk_mgr, uint32_t freq_mhz); 46 105 void dcn30_smu_set_num_of_displays(struct clk_mgr_internal *clk_mgr, uint32_t num_displays); 47 106 void dcn30_smu_set_display_refresh_from_mall(struct clk_mgr_internal *clk_mgr, bool enable, uint8_t cache_timer_delay, uint8_t cache_timer_scale);
+74
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_smu11_driver_if.h
··· 1 + // This is a stripped-down version of the smu11_driver_if.h file for the relevant DAL interfaces. 2 + 3 + #define SMU11_DRIVER_IF_VERSION 0x40 4 + 5 + //Only Clks that have DPM descriptors are listed here 6 + typedef enum { 7 + PPCLK_GFXCLK = 0, 8 + PPCLK_SOCCLK, 9 + PPCLK_UCLK, 10 + PPCLK_FCLK, 11 + PPCLK_DCLK_0, 12 + PPCLK_VCLK_0, 13 + PPCLK_DCLK_1, 14 + PPCLK_VCLK_1, 15 + PPCLK_DCEFCLK, 16 + PPCLK_DISPCLK, 17 + PPCLK_PIXCLK, 18 + PPCLK_PHYCLK, 19 + PPCLK_DTBCLK, 20 + PPCLK_COUNT, 21 + } PPCLK_e; 22 + 23 + typedef struct { 24 + uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz) 25 + uint16_t MaxClock; // This is either DCEFCLK or SOCCLK (in MHz) 26 + uint16_t MinUclk; 27 + uint16_t MaxUclk; 28 + 29 + uint8_t WmSetting; 30 + uint8_t Flags; 31 + uint8_t Padding[2]; 32 + 33 + } WatermarkRowGeneric_t; 34 + 35 + #define NUM_WM_RANGES 4 36 + 37 + typedef enum { 38 + WM_SOCCLK = 0, 39 + WM_DCEFCLK, 40 + WM_COUNT, 41 + } WM_CLOCK_e; 42 + 43 + typedef enum { 44 + WATERMARKS_CLOCK_RANGE = 0, 45 + WATERMARKS_DUMMY_PSTATE, 46 + WATERMARKS_MALL, 47 + WATERMARKS_COUNT, 48 + } WATERMARKS_FLAGS_e; 49 + 50 + typedef struct { 51 + // Watermarks 52 + WatermarkRowGeneric_t WatermarkRow[WM_COUNT][NUM_WM_RANGES]; 53 + } Watermarks_t; 54 + 55 + typedef struct { 56 + Watermarks_t Watermarks; 57 + 58 + uint32_t MmHubPadding[8]; // SMU internal use 59 + } WatermarksExternal_t; 60 + 61 + // Table types 62 + #define TABLE_PPTABLE 0 63 + #define TABLE_WATERMARKS 1 64 + #define TABLE_AVFS_PSM_DEBUG 2 65 + #define TABLE_AVFS_FUSE_OVERRIDE 3 66 + #define TABLE_PMSTATUSLOG 4 67 + #define TABLE_SMU_METRICS 5 68 + #define TABLE_DRIVER_SMU_CONFIG 6 69 + #define TABLE_ACTIVITY_MONITOR_COEFF 7 70 + #define TABLE_OVERDRIVE 8 71 + #define TABLE_I2C_COMMANDS 9 72 + #define TABLE_PACE 10 73 + #define TABLE_ECCINFO 11 74 + #define TABLE_COUNT 12
-22
drivers/gpu/drm/amd/display/include/grph_object_ctrl_defs.h
··· 419 419 struct edp_info edp2_info; 420 420 }; 421 421 422 - /** 423 - * Power source ids. 424 - */ 425 - enum power_source { 426 - POWER_SOURCE_AC = 0, 427 - POWER_SOURCE_DC, 428 - POWER_SOURCE_LIMITED_POWER, 429 - POWER_SOURCE_LIMITED_POWER_2, 430 - POWER_SOURCE_MAX 431 - }; 432 - 433 - struct bios_event_info { 434 - uint32_t thermal_state; 435 - uint32_t backlight_level; 436 - enum power_source powerSource; 437 - bool has_thermal_state_changed; 438 - bool has_power_source_changed; 439 - bool has_forced_mode_changed; 440 - bool forced_mode; 441 - bool backlight_changed; 442 - }; 443 - 444 422 /* 445 423 * DFS-bypass flag 446 424 */