diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2017-07-10 10:39:09 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-07-14 11:06:38 -0400 |
commit | 79077ee1edceb95d8c0215a9af5e8373232672df (patch) | |
tree | bdd0bd533b8f26681e38e05fd70e33fbdb44643a /drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | |
parent | 9f57f7b47d4c9559ae85666eeaf9ffd150096574 (diff) |
drm/amdgpu: add get_clock_info for atomfirmware
The information has moved to different tables, notably
smu_info for core refclk and umc_info for mem refclk.
Acked-by: Chunming Zhou <david1.zhou@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c index a7d65f033883..f9ffe8ef0cd6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | |||
@@ -128,3 +128,96 @@ int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev) | |||
128 | 128 | ||
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
131 | |||
132 | union firmware_info { | ||
133 | struct atom_firmware_info_v3_1 v31; | ||
134 | }; | ||
135 | |||
136 | union smu_info { | ||
137 | struct atom_smu_info_v3_1 v31; | ||
138 | }; | ||
139 | |||
140 | union umc_info { | ||
141 | struct atom_umc_info_v3_1 v31; | ||
142 | }; | ||
143 | |||
144 | int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev) | ||
145 | { | ||
146 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | ||
147 | struct amdgpu_pll *spll = &adev->clock.spll; | ||
148 | struct amdgpu_pll *mpll = &adev->clock.mpll; | ||
149 | uint8_t frev, crev; | ||
150 | uint16_t data_offset; | ||
151 | int ret = -EINVAL, index; | ||
152 | |||
153 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
154 | firmwareinfo); | ||
155 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
156 | &frev, &crev, &data_offset)) { | ||
157 | union firmware_info *firmware_info = | ||
158 | (union firmware_info *)(mode_info->atom_context->bios + | ||
159 | data_offset); | ||
160 | |||
161 | adev->clock.default_sclk = | ||
162 | le32_to_cpu(firmware_info->v31.bootup_sclk_in10khz); | ||
163 | adev->clock.default_mclk = | ||
164 | le32_to_cpu(firmware_info->v31.bootup_mclk_in10khz); | ||
165 | |||
166 | adev->pm.current_sclk = adev->clock.default_sclk; | ||
167 | adev->pm.current_mclk = adev->clock.default_mclk; | ||
168 | |||
169 | /* not technically a clock, but... */ | ||
170 | adev->mode_info.firmware_flags = | ||
171 | le32_to_cpu(firmware_info->v31.firmware_capability); | ||
172 | |||
173 | ret = 0; | ||
174 | } | ||
175 | |||
176 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
177 | smu_info); | ||
178 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
179 | &frev, &crev, &data_offset)) { | ||
180 | union smu_info *smu_info = | ||
181 | (union smu_info *)(mode_info->atom_context->bios + | ||
182 | data_offset); | ||
183 | |||
184 | /* system clock */ | ||
185 | spll->reference_freq = le32_to_cpu(smu_info->v31.core_refclk_10khz); | ||
186 | |||
187 | spll->reference_div = 0; | ||
188 | spll->min_post_div = 1; | ||
189 | spll->max_post_div = 1; | ||
190 | spll->min_ref_div = 2; | ||
191 | spll->max_ref_div = 0xff; | ||
192 | spll->min_feedback_div = 4; | ||
193 | spll->max_feedback_div = 0xff; | ||
194 | spll->best_vco = 0; | ||
195 | |||
196 | ret = 0; | ||
197 | } | ||
198 | |||
199 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
200 | umc_info); | ||
201 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
202 | &frev, &crev, &data_offset)) { | ||
203 | union umc_info *umc_info = | ||
204 | (union umc_info *)(mode_info->atom_context->bios + | ||
205 | data_offset); | ||
206 | |||
207 | /* memory clock */ | ||
208 | mpll->reference_freq = le32_to_cpu(umc_info->v31.mem_refclk_10khz); | ||
209 | |||
210 | mpll->reference_div = 0; | ||
211 | mpll->min_post_div = 1; | ||
212 | mpll->max_post_div = 1; | ||
213 | mpll->min_ref_div = 2; | ||
214 | mpll->max_ref_div = 0xff; | ||
215 | mpll->min_feedback_div = 4; | ||
216 | mpll->max_feedback_div = 0xff; | ||
217 | mpll->best_vco = 0; | ||
218 | |||
219 | ret = 0; | ||
220 | } | ||
221 | |||
222 | return ret; | ||
223 | } | ||