1e098bc96SEvan Quan /*
2e098bc96SEvan Quan * Copyright 2016 Advanced Micro Devices, Inc.
3e098bc96SEvan Quan *
4e098bc96SEvan Quan * Permission is hereby granted, free of charge, to any person obtaining a
5e098bc96SEvan Quan * copy of this software and associated documentation files (the "Software"),
6e098bc96SEvan Quan * to deal in the Software without restriction, including without limitation
7e098bc96SEvan Quan * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8e098bc96SEvan Quan * and/or sell copies of the Software, and to permit persons to whom the
9e098bc96SEvan Quan * Software is furnished to do so, subject to the following conditions:
10e098bc96SEvan Quan *
11e098bc96SEvan Quan * The above copyright notice and this permission notice shall be included in
12e098bc96SEvan Quan * all copies or substantial portions of the Software.
13e098bc96SEvan Quan *
14e098bc96SEvan Quan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15e098bc96SEvan Quan * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16e098bc96SEvan Quan * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17e098bc96SEvan Quan * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18e098bc96SEvan Quan * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19e098bc96SEvan Quan * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20e098bc96SEvan Quan * OTHER DEALINGS IN THE SOFTWARE.
21e098bc96SEvan Quan *
22e098bc96SEvan Quan */
23e098bc96SEvan Quan
24e098bc96SEvan Quan #include "ppatomfwctrl.h"
25e098bc96SEvan Quan #include "atomfirmware.h"
26e098bc96SEvan Quan #include "atom.h"
27e098bc96SEvan Quan #include "pp_debug.h"
28e098bc96SEvan Quan
pp_atomfwctrl_lookup_voltage_type_v4(const struct atom_voltage_objects_info_v4_1 * voltage_object_info_table,uint8_t voltage_type,uint8_t voltage_mode)29e098bc96SEvan Quan static const union atom_voltage_object_v4 *pp_atomfwctrl_lookup_voltage_type_v4(
30e098bc96SEvan Quan const struct atom_voltage_objects_info_v4_1 *voltage_object_info_table,
31e098bc96SEvan Quan uint8_t voltage_type, uint8_t voltage_mode)
32e098bc96SEvan Quan {
33e098bc96SEvan Quan unsigned int size = le16_to_cpu(
34e098bc96SEvan Quan voltage_object_info_table->table_header.structuresize);
35e098bc96SEvan Quan unsigned int offset =
36e098bc96SEvan Quan offsetof(struct atom_voltage_objects_info_v4_1, voltage_object[0]);
37e098bc96SEvan Quan unsigned long start = (unsigned long)voltage_object_info_table;
38e098bc96SEvan Quan
39e098bc96SEvan Quan while (offset < size) {
40e098bc96SEvan Quan const union atom_voltage_object_v4 *voltage_object =
41e098bc96SEvan Quan (const union atom_voltage_object_v4 *)(start + offset);
42e098bc96SEvan Quan
43e098bc96SEvan Quan if (voltage_type == voltage_object->gpio_voltage_obj.header.voltage_type &&
44e098bc96SEvan Quan voltage_mode == voltage_object->gpio_voltage_obj.header.voltage_mode)
45e098bc96SEvan Quan return voltage_object;
46e098bc96SEvan Quan
47e098bc96SEvan Quan offset += le16_to_cpu(voltage_object->gpio_voltage_obj.header.object_size);
48e098bc96SEvan Quan
49e098bc96SEvan Quan }
50e098bc96SEvan Quan
51e098bc96SEvan Quan return NULL;
52e098bc96SEvan Quan }
53e098bc96SEvan Quan
pp_atomfwctrl_get_voltage_info_table(struct pp_hwmgr * hwmgr)54e098bc96SEvan Quan static struct atom_voltage_objects_info_v4_1 *pp_atomfwctrl_get_voltage_info_table(
55e098bc96SEvan Quan struct pp_hwmgr *hwmgr)
56e098bc96SEvan Quan {
57e098bc96SEvan Quan const void *table_address;
58e098bc96SEvan Quan uint16_t idx;
59e098bc96SEvan Quan
60e098bc96SEvan Quan idx = GetIndexIntoMasterDataTable(voltageobject_info);
61e098bc96SEvan Quan table_address = smu_atom_get_data_table(hwmgr->adev,
62e098bc96SEvan Quan idx, NULL, NULL, NULL);
63e098bc96SEvan Quan
64e098bc96SEvan Quan PP_ASSERT_WITH_CODE(table_address,
65e098bc96SEvan Quan "Error retrieving BIOS Table Address!",
66e098bc96SEvan Quan return NULL);
67e098bc96SEvan Quan
68e098bc96SEvan Quan return (struct atom_voltage_objects_info_v4_1 *)table_address;
69e098bc96SEvan Quan }
70e098bc96SEvan Quan
71*5ca53687SLee Jones /*
72e098bc96SEvan Quan * Returns TRUE if the given voltage type is controlled by GPIO pins.
73e098bc96SEvan Quan * voltage_type is one of SET_VOLTAGE_TYPE_ASIC_VDDC, SET_VOLTAGE_TYPE_ASIC_MVDDC, SET_VOLTAGE_TYPE_ASIC_MVDDQ.
74e098bc96SEvan Quan * voltage_mode is one of ATOM_SET_VOLTAGE, ATOM_SET_VOLTAGE_PHASE
75e098bc96SEvan Quan */
pp_atomfwctrl_is_voltage_controlled_by_gpio_v4(struct pp_hwmgr * hwmgr,uint8_t voltage_type,uint8_t voltage_mode)76e098bc96SEvan Quan bool pp_atomfwctrl_is_voltage_controlled_by_gpio_v4(struct pp_hwmgr *hwmgr,
77e098bc96SEvan Quan uint8_t voltage_type, uint8_t voltage_mode)
78e098bc96SEvan Quan {
79e098bc96SEvan Quan struct atom_voltage_objects_info_v4_1 *voltage_info =
80e098bc96SEvan Quan (struct atom_voltage_objects_info_v4_1 *)
81e098bc96SEvan Quan pp_atomfwctrl_get_voltage_info_table(hwmgr);
82e098bc96SEvan Quan bool ret;
83e098bc96SEvan Quan
84e098bc96SEvan Quan /* If we cannot find the table do NOT try to control this voltage. */
85e098bc96SEvan Quan PP_ASSERT_WITH_CODE(voltage_info,
86e098bc96SEvan Quan "Could not find Voltage Table in BIOS.",
87e098bc96SEvan Quan return false);
88e098bc96SEvan Quan
89e098bc96SEvan Quan ret = (pp_atomfwctrl_lookup_voltage_type_v4(voltage_info,
90e098bc96SEvan Quan voltage_type, voltage_mode)) ? true : false;
91e098bc96SEvan Quan
92e098bc96SEvan Quan return ret;
93e098bc96SEvan Quan }
94e098bc96SEvan Quan
pp_atomfwctrl_get_voltage_table_v4(struct pp_hwmgr * hwmgr,uint8_t voltage_type,uint8_t voltage_mode,struct pp_atomfwctrl_voltage_table * voltage_table)95e098bc96SEvan Quan int pp_atomfwctrl_get_voltage_table_v4(struct pp_hwmgr *hwmgr,
96e098bc96SEvan Quan uint8_t voltage_type, uint8_t voltage_mode,
97e098bc96SEvan Quan struct pp_atomfwctrl_voltage_table *voltage_table)
98e098bc96SEvan Quan {
99e098bc96SEvan Quan struct atom_voltage_objects_info_v4_1 *voltage_info =
100e098bc96SEvan Quan (struct atom_voltage_objects_info_v4_1 *)
101e098bc96SEvan Quan pp_atomfwctrl_get_voltage_info_table(hwmgr);
102e098bc96SEvan Quan const union atom_voltage_object_v4 *voltage_object;
103e098bc96SEvan Quan unsigned int i;
104e098bc96SEvan Quan int result = 0;
105e098bc96SEvan Quan
106e098bc96SEvan Quan PP_ASSERT_WITH_CODE(voltage_info,
107e098bc96SEvan Quan "Could not find Voltage Table in BIOS.",
108e098bc96SEvan Quan return -1);
109e098bc96SEvan Quan
110e098bc96SEvan Quan voltage_object = pp_atomfwctrl_lookup_voltage_type_v4(voltage_info,
111e098bc96SEvan Quan voltage_type, voltage_mode);
112e098bc96SEvan Quan
113e098bc96SEvan Quan if (!voltage_object)
114e098bc96SEvan Quan return -1;
115e098bc96SEvan Quan
116e098bc96SEvan Quan voltage_table->count = 0;
117e098bc96SEvan Quan if (voltage_mode == VOLTAGE_OBJ_GPIO_LUT) {
118e098bc96SEvan Quan PP_ASSERT_WITH_CODE(
119e098bc96SEvan Quan (voltage_object->gpio_voltage_obj.gpio_entry_num <=
120e098bc96SEvan Quan PP_ATOMFWCTRL_MAX_VOLTAGE_ENTRIES),
121e098bc96SEvan Quan "Too many voltage entries!",
122e098bc96SEvan Quan result = -1);
123e098bc96SEvan Quan
124e098bc96SEvan Quan if (!result) {
125e098bc96SEvan Quan for (i = 0; i < voltage_object->gpio_voltage_obj.
126e098bc96SEvan Quan gpio_entry_num; i++) {
127e098bc96SEvan Quan voltage_table->entries[i].value =
128e098bc96SEvan Quan le16_to_cpu(voltage_object->gpio_voltage_obj.
129e098bc96SEvan Quan voltage_gpio_lut[i].voltage_level_mv);
130e098bc96SEvan Quan voltage_table->entries[i].smio_low =
131e098bc96SEvan Quan le32_to_cpu(voltage_object->gpio_voltage_obj.
132e098bc96SEvan Quan voltage_gpio_lut[i].voltage_gpio_reg_val);
133e098bc96SEvan Quan }
134e098bc96SEvan Quan voltage_table->count =
135e098bc96SEvan Quan voltage_object->gpio_voltage_obj.gpio_entry_num;
136e098bc96SEvan Quan voltage_table->mask_low =
137e098bc96SEvan Quan le32_to_cpu(
138e098bc96SEvan Quan voltage_object->gpio_voltage_obj.gpio_mask_val);
139e098bc96SEvan Quan voltage_table->phase_delay =
140e098bc96SEvan Quan voltage_object->gpio_voltage_obj.phase_delay_us;
141e098bc96SEvan Quan }
142e098bc96SEvan Quan } else if (voltage_mode == VOLTAGE_OBJ_SVID2) {
143e098bc96SEvan Quan voltage_table->psi1_enable =
144e098bc96SEvan Quan (voltage_object->svid2_voltage_obj.loadline_psi1 & 0x20) >> 5;
145e098bc96SEvan Quan voltage_table->psi0_enable =
146e098bc96SEvan Quan voltage_object->svid2_voltage_obj.psi0_enable & 0x1;
147e098bc96SEvan Quan voltage_table->max_vid_step =
148e098bc96SEvan Quan voltage_object->svid2_voltage_obj.maxvstep;
149e098bc96SEvan Quan voltage_table->telemetry_offset =
150e098bc96SEvan Quan voltage_object->svid2_voltage_obj.telemetry_offset;
151e098bc96SEvan Quan voltage_table->telemetry_slope =
152e098bc96SEvan Quan voltage_object->svid2_voltage_obj.telemetry_gain;
153e098bc96SEvan Quan } else
154e098bc96SEvan Quan PP_ASSERT_WITH_CODE(false,
155e098bc96SEvan Quan "Unsupported Voltage Object Mode!",
156e098bc96SEvan Quan result = -1);
157e098bc96SEvan Quan
158e098bc96SEvan Quan return result;
159e098bc96SEvan Quan }
160e098bc96SEvan Quan
161e098bc96SEvan Quan
pp_atomfwctrl_get_gpio_lookup_table(struct pp_hwmgr * hwmgr)162e098bc96SEvan Quan static struct atom_gpio_pin_lut_v2_1 *pp_atomfwctrl_get_gpio_lookup_table(
163e098bc96SEvan Quan struct pp_hwmgr *hwmgr)
164e098bc96SEvan Quan {
165e098bc96SEvan Quan const void *table_address;
166e098bc96SEvan Quan uint16_t idx;
167e098bc96SEvan Quan
168e098bc96SEvan Quan idx = GetIndexIntoMasterDataTable(gpio_pin_lut);
169e098bc96SEvan Quan table_address = smu_atom_get_data_table(hwmgr->adev,
170e098bc96SEvan Quan idx, NULL, NULL, NULL);
171e098bc96SEvan Quan PP_ASSERT_WITH_CODE(table_address,
172e098bc96SEvan Quan "Error retrieving BIOS Table Address!",
173e098bc96SEvan Quan return NULL);
174e098bc96SEvan Quan
175e098bc96SEvan Quan return (struct atom_gpio_pin_lut_v2_1 *)table_address;
176e098bc96SEvan Quan }
177e098bc96SEvan Quan
pp_atomfwctrl_lookup_gpio_pin(struct atom_gpio_pin_lut_v2_1 * gpio_lookup_table,const uint32_t pin_id,struct pp_atomfwctrl_gpio_pin_assignment * gpio_pin_assignment)178e098bc96SEvan Quan static bool pp_atomfwctrl_lookup_gpio_pin(
179e098bc96SEvan Quan struct atom_gpio_pin_lut_v2_1 *gpio_lookup_table,
180e098bc96SEvan Quan const uint32_t pin_id,
181e098bc96SEvan Quan struct pp_atomfwctrl_gpio_pin_assignment *gpio_pin_assignment)
182e098bc96SEvan Quan {
183e098bc96SEvan Quan unsigned int size = le16_to_cpu(
184e098bc96SEvan Quan gpio_lookup_table->table_header.structuresize);
185e098bc96SEvan Quan unsigned int offset =
186e098bc96SEvan Quan offsetof(struct atom_gpio_pin_lut_v2_1, gpio_pin[0]);
187e098bc96SEvan Quan unsigned long start = (unsigned long)gpio_lookup_table;
188e098bc96SEvan Quan
189e098bc96SEvan Quan while (offset < size) {
190e098bc96SEvan Quan const struct atom_gpio_pin_assignment *pin_assignment =
191e098bc96SEvan Quan (const struct atom_gpio_pin_assignment *)(start + offset);
192e098bc96SEvan Quan
193e098bc96SEvan Quan if (pin_id == pin_assignment->gpio_id) {
194e098bc96SEvan Quan gpio_pin_assignment->uc_gpio_pin_bit_shift =
195e098bc96SEvan Quan pin_assignment->gpio_bitshift;
196e098bc96SEvan Quan gpio_pin_assignment->us_gpio_pin_aindex =
197e098bc96SEvan Quan le16_to_cpu(pin_assignment->data_a_reg_index);
198e098bc96SEvan Quan return true;
199e098bc96SEvan Quan }
200e098bc96SEvan Quan offset += offsetof(struct atom_gpio_pin_assignment, gpio_id) + 1;
201e098bc96SEvan Quan }
202e098bc96SEvan Quan return false;
203e098bc96SEvan Quan }
204e098bc96SEvan Quan
205*5ca53687SLee Jones /*
206e098bc96SEvan Quan * Returns TRUE if the given pin id find in lookup table.
207e098bc96SEvan Quan */
pp_atomfwctrl_get_pp_assign_pin(struct pp_hwmgr * hwmgr,const uint32_t pin_id,struct pp_atomfwctrl_gpio_pin_assignment * gpio_pin_assignment)208e098bc96SEvan Quan bool pp_atomfwctrl_get_pp_assign_pin(struct pp_hwmgr *hwmgr,
209e098bc96SEvan Quan const uint32_t pin_id,
210e098bc96SEvan Quan struct pp_atomfwctrl_gpio_pin_assignment *gpio_pin_assignment)
211e098bc96SEvan Quan {
212e098bc96SEvan Quan bool ret = false;
213e098bc96SEvan Quan struct atom_gpio_pin_lut_v2_1 *gpio_lookup_table =
214e098bc96SEvan Quan pp_atomfwctrl_get_gpio_lookup_table(hwmgr);
215e098bc96SEvan Quan
216e098bc96SEvan Quan /* If we cannot find the table do NOT try to control this voltage. */
217e098bc96SEvan Quan PP_ASSERT_WITH_CODE(gpio_lookup_table,
218e098bc96SEvan Quan "Could not find GPIO lookup Table in BIOS.",
219e098bc96SEvan Quan return false);
220e098bc96SEvan Quan
221e098bc96SEvan Quan ret = pp_atomfwctrl_lookup_gpio_pin(gpio_lookup_table,
222e098bc96SEvan Quan pin_id, gpio_pin_assignment);
223e098bc96SEvan Quan
224e098bc96SEvan Quan return ret;
225e098bc96SEvan Quan }
226e098bc96SEvan Quan
227*5ca53687SLee Jones /*
228e098bc96SEvan Quan * Enter to SelfRefresh mode.
229e098bc96SEvan Quan * @param hwmgr
230e098bc96SEvan Quan */
pp_atomfwctrl_enter_self_refresh(struct pp_hwmgr * hwmgr)231e098bc96SEvan Quan int pp_atomfwctrl_enter_self_refresh(struct pp_hwmgr *hwmgr)
232e098bc96SEvan Quan {
233e098bc96SEvan Quan /* 0 - no action
234e098bc96SEvan Quan * 1 - leave power to video memory always on
235e098bc96SEvan Quan */
236e098bc96SEvan Quan return 0;
237e098bc96SEvan Quan }
238e098bc96SEvan Quan
239e098bc96SEvan Quan /** pp_atomfwctrl_get_gpu_pll_dividers_vega10().
240e098bc96SEvan Quan *
241e098bc96SEvan Quan * @param hwmgr input parameter: pointer to HwMgr
242e098bc96SEvan Quan * @param clock_type input parameter: Clock type: 1 - GFXCLK, 2 - UCLK, 0 - All other clocks
243e098bc96SEvan Quan * @param clock_value input parameter: Clock
244e098bc96SEvan Quan * @param dividers output parameter:Clock dividers
245e098bc96SEvan Quan */
pp_atomfwctrl_get_gpu_pll_dividers_vega10(struct pp_hwmgr * hwmgr,uint32_t clock_type,uint32_t clock_value,struct pp_atomfwctrl_clock_dividers_soc15 * dividers)246e098bc96SEvan Quan int pp_atomfwctrl_get_gpu_pll_dividers_vega10(struct pp_hwmgr *hwmgr,
247e098bc96SEvan Quan uint32_t clock_type, uint32_t clock_value,
248e098bc96SEvan Quan struct pp_atomfwctrl_clock_dividers_soc15 *dividers)
249e098bc96SEvan Quan {
250e098bc96SEvan Quan struct amdgpu_device *adev = hwmgr->adev;
251e098bc96SEvan Quan struct compute_gpu_clock_input_parameter_v1_8 pll_parameters;
252e098bc96SEvan Quan struct compute_gpu_clock_output_parameter_v1_8 *pll_output;
253e098bc96SEvan Quan uint32_t idx;
254e098bc96SEvan Quan
255e098bc96SEvan Quan pll_parameters.gpuclock_10khz = (uint32_t)clock_value;
256e098bc96SEvan Quan pll_parameters.gpu_clock_type = clock_type;
257e098bc96SEvan Quan
258e098bc96SEvan Quan idx = GetIndexIntoMasterCmdTable(computegpuclockparam);
259e098bc96SEvan Quan
260e098bc96SEvan Quan if (amdgpu_atom_execute_table(
261e098bc96SEvan Quan adev->mode_info.atom_context, idx, (uint32_t *)&pll_parameters))
262e098bc96SEvan Quan return -EINVAL;
263e098bc96SEvan Quan
264e098bc96SEvan Quan pll_output = (struct compute_gpu_clock_output_parameter_v1_8 *)
265e098bc96SEvan Quan &pll_parameters;
266e098bc96SEvan Quan dividers->ulClock = le32_to_cpu(pll_output->gpuclock_10khz);
267e098bc96SEvan Quan dividers->ulDid = le32_to_cpu(pll_output->dfs_did);
268e098bc96SEvan Quan dividers->ulPll_fb_mult = le32_to_cpu(pll_output->pll_fb_mult);
269e098bc96SEvan Quan dividers->ulPll_ss_fbsmult = le32_to_cpu(pll_output->pll_ss_fbsmult);
270e098bc96SEvan Quan dividers->usPll_ss_slew_frac = le16_to_cpu(pll_output->pll_ss_slew_frac);
271e098bc96SEvan Quan dividers->ucPll_ss_enable = pll_output->pll_ss_enable;
272e098bc96SEvan Quan
273e098bc96SEvan Quan return 0;
274e098bc96SEvan Quan }
275e098bc96SEvan Quan
pp_atomfwctrl_get_avfs_information(struct pp_hwmgr * hwmgr,struct pp_atomfwctrl_avfs_parameters * param)276e098bc96SEvan Quan int pp_atomfwctrl_get_avfs_information(struct pp_hwmgr *hwmgr,
277e098bc96SEvan Quan struct pp_atomfwctrl_avfs_parameters *param)
278e098bc96SEvan Quan {
279e098bc96SEvan Quan uint16_t idx;
280e098bc96SEvan Quan uint8_t format_revision, content_revision;
281e098bc96SEvan Quan
282e098bc96SEvan Quan struct atom_asic_profiling_info_v4_1 *profile;
283e098bc96SEvan Quan struct atom_asic_profiling_info_v4_2 *profile_v4_2;
284e098bc96SEvan Quan
285e098bc96SEvan Quan idx = GetIndexIntoMasterDataTable(asic_profiling_info);
286e098bc96SEvan Quan profile = (struct atom_asic_profiling_info_v4_1 *)
287e098bc96SEvan Quan smu_atom_get_data_table(hwmgr->adev,
288e098bc96SEvan Quan idx, NULL, NULL, NULL);
289e098bc96SEvan Quan
290e098bc96SEvan Quan if (!profile)
291e098bc96SEvan Quan return -1;
292e098bc96SEvan Quan
293e098bc96SEvan Quan format_revision = ((struct atom_common_table_header *)profile)->format_revision;
294e098bc96SEvan Quan content_revision = ((struct atom_common_table_header *)profile)->content_revision;
295e098bc96SEvan Quan
296e098bc96SEvan Quan if (format_revision == 4 && content_revision == 1) {
297e098bc96SEvan Quan param->ulMaxVddc = le32_to_cpu(profile->maxvddc);
298e098bc96SEvan Quan param->ulMinVddc = le32_to_cpu(profile->minvddc);
299e098bc96SEvan Quan param->ulMeanNsigmaAcontant0 =
300e098bc96SEvan Quan le32_to_cpu(profile->avfs_meannsigma_acontant0);
301e098bc96SEvan Quan param->ulMeanNsigmaAcontant1 =
302e098bc96SEvan Quan le32_to_cpu(profile->avfs_meannsigma_acontant1);
303e098bc96SEvan Quan param->ulMeanNsigmaAcontant2 =
304e098bc96SEvan Quan le32_to_cpu(profile->avfs_meannsigma_acontant2);
305e098bc96SEvan Quan param->usMeanNsigmaDcTolSigma =
306e098bc96SEvan Quan le16_to_cpu(profile->avfs_meannsigma_dc_tol_sigma);
307e098bc96SEvan Quan param->usMeanNsigmaPlatformMean =
308e098bc96SEvan Quan le16_to_cpu(profile->avfs_meannsigma_platform_mean);
309e098bc96SEvan Quan param->usMeanNsigmaPlatformSigma =
310e098bc96SEvan Quan le16_to_cpu(profile->avfs_meannsigma_platform_sigma);
311e098bc96SEvan Quan param->ulGbVdroopTableCksoffA0 =
312e098bc96SEvan Quan le32_to_cpu(profile->gb_vdroop_table_cksoff_a0);
313e098bc96SEvan Quan param->ulGbVdroopTableCksoffA1 =
314e098bc96SEvan Quan le32_to_cpu(profile->gb_vdroop_table_cksoff_a1);
315e098bc96SEvan Quan param->ulGbVdroopTableCksoffA2 =
316e098bc96SEvan Quan le32_to_cpu(profile->gb_vdroop_table_cksoff_a2);
317e098bc96SEvan Quan param->ulGbVdroopTableCksonA0 =
318e098bc96SEvan Quan le32_to_cpu(profile->gb_vdroop_table_ckson_a0);
319e098bc96SEvan Quan param->ulGbVdroopTableCksonA1 =
320e098bc96SEvan Quan le32_to_cpu(profile->gb_vdroop_table_ckson_a1);
321e098bc96SEvan Quan param->ulGbVdroopTableCksonA2 =
322e098bc96SEvan Quan le32_to_cpu(profile->gb_vdroop_table_ckson_a2);
323e098bc96SEvan Quan param->ulGbFuseTableCksoffM1 =
324e098bc96SEvan Quan le32_to_cpu(profile->avfsgb_fuse_table_cksoff_m1);
325e098bc96SEvan Quan param->ulGbFuseTableCksoffM2 =
326e098bc96SEvan Quan le32_to_cpu(profile->avfsgb_fuse_table_cksoff_m2);
327e098bc96SEvan Quan param->ulGbFuseTableCksoffB =
328e098bc96SEvan Quan le32_to_cpu(profile->avfsgb_fuse_table_cksoff_b);
329e098bc96SEvan Quan param->ulGbFuseTableCksonM1 =
330e098bc96SEvan Quan le32_to_cpu(profile->avfsgb_fuse_table_ckson_m1);
331e098bc96SEvan Quan param->ulGbFuseTableCksonM2 =
332e098bc96SEvan Quan le32_to_cpu(profile->avfsgb_fuse_table_ckson_m2);
333e098bc96SEvan Quan param->ulGbFuseTableCksonB =
334e098bc96SEvan Quan le32_to_cpu(profile->avfsgb_fuse_table_ckson_b);
335e098bc96SEvan Quan
336e098bc96SEvan Quan param->ucEnableGbVdroopTableCkson =
337e098bc96SEvan Quan profile->enable_gb_vdroop_table_ckson;
338e098bc96SEvan Quan param->ucEnableGbFuseTableCkson =
339e098bc96SEvan Quan profile->enable_gb_fuse_table_ckson;
340e098bc96SEvan Quan param->usPsmAgeComfactor =
341e098bc96SEvan Quan le16_to_cpu(profile->psm_age_comfactor);
342e098bc96SEvan Quan
343e098bc96SEvan Quan param->ulDispclk2GfxclkM1 =
344e098bc96SEvan Quan le32_to_cpu(profile->dispclk2gfxclk_a);
345e098bc96SEvan Quan param->ulDispclk2GfxclkM2 =
346e098bc96SEvan Quan le32_to_cpu(profile->dispclk2gfxclk_b);
347e098bc96SEvan Quan param->ulDispclk2GfxclkB =
348e098bc96SEvan Quan le32_to_cpu(profile->dispclk2gfxclk_c);
349e098bc96SEvan Quan param->ulDcefclk2GfxclkM1 =
350e098bc96SEvan Quan le32_to_cpu(profile->dcefclk2gfxclk_a);
351e098bc96SEvan Quan param->ulDcefclk2GfxclkM2 =
352e098bc96SEvan Quan le32_to_cpu(profile->dcefclk2gfxclk_b);
353e098bc96SEvan Quan param->ulDcefclk2GfxclkB =
354e098bc96SEvan Quan le32_to_cpu(profile->dcefclk2gfxclk_c);
355e098bc96SEvan Quan param->ulPixelclk2GfxclkM1 =
356e098bc96SEvan Quan le32_to_cpu(profile->pixclk2gfxclk_a);
357e098bc96SEvan Quan param->ulPixelclk2GfxclkM2 =
358e098bc96SEvan Quan le32_to_cpu(profile->pixclk2gfxclk_b);
359e098bc96SEvan Quan param->ulPixelclk2GfxclkB =
360e098bc96SEvan Quan le32_to_cpu(profile->pixclk2gfxclk_c);
361e098bc96SEvan Quan param->ulPhyclk2GfxclkM1 =
362e098bc96SEvan Quan le32_to_cpu(profile->phyclk2gfxclk_a);
363e098bc96SEvan Quan param->ulPhyclk2GfxclkM2 =
364e098bc96SEvan Quan le32_to_cpu(profile->phyclk2gfxclk_b);
365e098bc96SEvan Quan param->ulPhyclk2GfxclkB =
366e098bc96SEvan Quan le32_to_cpu(profile->phyclk2gfxclk_c);
367e098bc96SEvan Quan param->ulAcgGbVdroopTableA0 = 0;
368e098bc96SEvan Quan param->ulAcgGbVdroopTableA1 = 0;
369e098bc96SEvan Quan param->ulAcgGbVdroopTableA2 = 0;
370e098bc96SEvan Quan param->ulAcgGbFuseTableM1 = 0;
371e098bc96SEvan Quan param->ulAcgGbFuseTableM2 = 0;
372e098bc96SEvan Quan param->ulAcgGbFuseTableB = 0;
373e098bc96SEvan Quan param->ucAcgEnableGbVdroopTable = 0;
374e098bc96SEvan Quan param->ucAcgEnableGbFuseTable = 0;
375e098bc96SEvan Quan } else if (format_revision == 4 && content_revision == 2) {
376e098bc96SEvan Quan profile_v4_2 = (struct atom_asic_profiling_info_v4_2 *)profile;
377e098bc96SEvan Quan param->ulMaxVddc = le32_to_cpu(profile_v4_2->maxvddc);
378e098bc96SEvan Quan param->ulMinVddc = le32_to_cpu(profile_v4_2->minvddc);
379e098bc96SEvan Quan param->ulMeanNsigmaAcontant0 =
380e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfs_meannsigma_acontant0);
381e098bc96SEvan Quan param->ulMeanNsigmaAcontant1 =
382e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfs_meannsigma_acontant1);
383e098bc96SEvan Quan param->ulMeanNsigmaAcontant2 =
384e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfs_meannsigma_acontant2);
385e098bc96SEvan Quan param->usMeanNsigmaDcTolSigma =
386e098bc96SEvan Quan le16_to_cpu(profile_v4_2->avfs_meannsigma_dc_tol_sigma);
387e098bc96SEvan Quan param->usMeanNsigmaPlatformMean =
388e098bc96SEvan Quan le16_to_cpu(profile_v4_2->avfs_meannsigma_platform_mean);
389e098bc96SEvan Quan param->usMeanNsigmaPlatformSigma =
390e098bc96SEvan Quan le16_to_cpu(profile_v4_2->avfs_meannsigma_platform_sigma);
391e098bc96SEvan Quan param->ulGbVdroopTableCksoffA0 =
392e098bc96SEvan Quan le32_to_cpu(profile_v4_2->gb_vdroop_table_cksoff_a0);
393e098bc96SEvan Quan param->ulGbVdroopTableCksoffA1 =
394e098bc96SEvan Quan le32_to_cpu(profile_v4_2->gb_vdroop_table_cksoff_a1);
395e098bc96SEvan Quan param->ulGbVdroopTableCksoffA2 =
396e098bc96SEvan Quan le32_to_cpu(profile_v4_2->gb_vdroop_table_cksoff_a2);
397e098bc96SEvan Quan param->ulGbVdroopTableCksonA0 =
398e098bc96SEvan Quan le32_to_cpu(profile_v4_2->gb_vdroop_table_ckson_a0);
399e098bc96SEvan Quan param->ulGbVdroopTableCksonA1 =
400e098bc96SEvan Quan le32_to_cpu(profile_v4_2->gb_vdroop_table_ckson_a1);
401e098bc96SEvan Quan param->ulGbVdroopTableCksonA2 =
402e098bc96SEvan Quan le32_to_cpu(profile_v4_2->gb_vdroop_table_ckson_a2);
403e098bc96SEvan Quan param->ulGbFuseTableCksoffM1 =
404e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfsgb_fuse_table_cksoff_m1);
405e098bc96SEvan Quan param->ulGbFuseTableCksoffM2 =
406e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfsgb_fuse_table_cksoff_m2);
407e098bc96SEvan Quan param->ulGbFuseTableCksoffB =
408e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfsgb_fuse_table_cksoff_b);
409e098bc96SEvan Quan param->ulGbFuseTableCksonM1 =
410e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfsgb_fuse_table_ckson_m1);
411e098bc96SEvan Quan param->ulGbFuseTableCksonM2 =
412e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfsgb_fuse_table_ckson_m2);
413e098bc96SEvan Quan param->ulGbFuseTableCksonB =
414e098bc96SEvan Quan le32_to_cpu(profile_v4_2->avfsgb_fuse_table_ckson_b);
415e098bc96SEvan Quan
416e098bc96SEvan Quan param->ucEnableGbVdroopTableCkson =
417e098bc96SEvan Quan profile_v4_2->enable_gb_vdroop_table_ckson;
418e098bc96SEvan Quan param->ucEnableGbFuseTableCkson =
419e098bc96SEvan Quan profile_v4_2->enable_gb_fuse_table_ckson;
420e098bc96SEvan Quan param->usPsmAgeComfactor =
421e098bc96SEvan Quan le16_to_cpu(profile_v4_2->psm_age_comfactor);
422e098bc96SEvan Quan
423e098bc96SEvan Quan param->ulDispclk2GfxclkM1 =
424e098bc96SEvan Quan le32_to_cpu(profile_v4_2->dispclk2gfxclk_a);
425e098bc96SEvan Quan param->ulDispclk2GfxclkM2 =
426e098bc96SEvan Quan le32_to_cpu(profile_v4_2->dispclk2gfxclk_b);
427e098bc96SEvan Quan param->ulDispclk2GfxclkB =
428e098bc96SEvan Quan le32_to_cpu(profile_v4_2->dispclk2gfxclk_c);
429e098bc96SEvan Quan param->ulDcefclk2GfxclkM1 =
430e098bc96SEvan Quan le32_to_cpu(profile_v4_2->dcefclk2gfxclk_a);
431e098bc96SEvan Quan param->ulDcefclk2GfxclkM2 =
432e098bc96SEvan Quan le32_to_cpu(profile_v4_2->dcefclk2gfxclk_b);
433e098bc96SEvan Quan param->ulDcefclk2GfxclkB =
434e098bc96SEvan Quan le32_to_cpu(profile_v4_2->dcefclk2gfxclk_c);
435e098bc96SEvan Quan param->ulPixelclk2GfxclkM1 =
436e098bc96SEvan Quan le32_to_cpu(profile_v4_2->pixclk2gfxclk_a);
437e098bc96SEvan Quan param->ulPixelclk2GfxclkM2 =
438e098bc96SEvan Quan le32_to_cpu(profile_v4_2->pixclk2gfxclk_b);
439e098bc96SEvan Quan param->ulPixelclk2GfxclkB =
440e098bc96SEvan Quan le32_to_cpu(profile_v4_2->pixclk2gfxclk_c);
441e098bc96SEvan Quan param->ulPhyclk2GfxclkM1 =
442e098bc96SEvan Quan le32_to_cpu(profile->phyclk2gfxclk_a);
443e098bc96SEvan Quan param->ulPhyclk2GfxclkM2 =
444e098bc96SEvan Quan le32_to_cpu(profile_v4_2->phyclk2gfxclk_b);
445e098bc96SEvan Quan param->ulPhyclk2GfxclkB =
446e098bc96SEvan Quan le32_to_cpu(profile_v4_2->phyclk2gfxclk_c);
447e098bc96SEvan Quan param->ulAcgGbVdroopTableA0 = le32_to_cpu(profile_v4_2->acg_gb_vdroop_table_a0);
448e098bc96SEvan Quan param->ulAcgGbVdroopTableA1 = le32_to_cpu(profile_v4_2->acg_gb_vdroop_table_a1);
449e098bc96SEvan Quan param->ulAcgGbVdroopTableA2 = le32_to_cpu(profile_v4_2->acg_gb_vdroop_table_a2);
450e098bc96SEvan Quan param->ulAcgGbFuseTableM1 = le32_to_cpu(profile_v4_2->acg_avfsgb_fuse_table_m1);
451e098bc96SEvan Quan param->ulAcgGbFuseTableM2 = le32_to_cpu(profile_v4_2->acg_avfsgb_fuse_table_m2);
452e098bc96SEvan Quan param->ulAcgGbFuseTableB = le32_to_cpu(profile_v4_2->acg_avfsgb_fuse_table_b);
453e098bc96SEvan Quan param->ucAcgEnableGbVdroopTable = le32_to_cpu(profile_v4_2->enable_acg_gb_vdroop_table);
454e098bc96SEvan Quan param->ucAcgEnableGbFuseTable = le32_to_cpu(profile_v4_2->enable_acg_gb_fuse_table);
455e098bc96SEvan Quan } else {
456e098bc96SEvan Quan pr_info("Invalid VBIOS AVFS ProfilingInfo Revision!\n");
457e098bc96SEvan Quan return -EINVAL;
458e098bc96SEvan Quan }
459e098bc96SEvan Quan
460e098bc96SEvan Quan return 0;
461e098bc96SEvan Quan }
462e098bc96SEvan Quan
pp_atomfwctrl_get_gpio_information(struct pp_hwmgr * hwmgr,struct pp_atomfwctrl_gpio_parameters * param)463e098bc96SEvan Quan int pp_atomfwctrl_get_gpio_information(struct pp_hwmgr *hwmgr,
464e098bc96SEvan Quan struct pp_atomfwctrl_gpio_parameters *param)
465e098bc96SEvan Quan {
466e098bc96SEvan Quan struct atom_smu_info_v3_1 *info;
467e098bc96SEvan Quan uint16_t idx;
468e098bc96SEvan Quan
469e098bc96SEvan Quan idx = GetIndexIntoMasterDataTable(smu_info);
470e098bc96SEvan Quan info = (struct atom_smu_info_v3_1 *)
471e098bc96SEvan Quan smu_atom_get_data_table(hwmgr->adev,
472e098bc96SEvan Quan idx, NULL, NULL, NULL);
473e098bc96SEvan Quan
474e098bc96SEvan Quan if (!info) {
475e098bc96SEvan Quan pr_info("Error retrieving BIOS smu_info Table Address!");
476e098bc96SEvan Quan return -1;
477e098bc96SEvan Quan }
478e098bc96SEvan Quan
479e098bc96SEvan Quan param->ucAcDcGpio = info->ac_dc_gpio_bit;
480e098bc96SEvan Quan param->ucAcDcPolarity = info->ac_dc_polarity;
481e098bc96SEvan Quan param->ucVR0HotGpio = info->vr0hot_gpio_bit;
482e098bc96SEvan Quan param->ucVR0HotPolarity = info->vr0hot_polarity;
483e098bc96SEvan Quan param->ucVR1HotGpio = info->vr1hot_gpio_bit;
484e098bc96SEvan Quan param->ucVR1HotPolarity = info->vr1hot_polarity;
485e098bc96SEvan Quan param->ucFwCtfGpio = info->fw_ctf_gpio_bit;
486e098bc96SEvan Quan param->ucFwCtfPolarity = info->fw_ctf_polarity;
487e098bc96SEvan Quan
488e098bc96SEvan Quan return 0;
489e098bc96SEvan Quan }
490e098bc96SEvan Quan
pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr * hwmgr,uint8_t clk_id,uint8_t syspll_id,uint32_t * frequency)491e098bc96SEvan Quan int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr,
492e098bc96SEvan Quan uint8_t clk_id, uint8_t syspll_id,
493e098bc96SEvan Quan uint32_t *frequency)
494e098bc96SEvan Quan {
495e098bc96SEvan Quan struct amdgpu_device *adev = hwmgr->adev;
496e098bc96SEvan Quan struct atom_get_smu_clock_info_parameters_v3_1 parameters;
497e098bc96SEvan Quan struct atom_get_smu_clock_info_output_parameters_v3_1 *output;
498e098bc96SEvan Quan uint32_t ix;
499e098bc96SEvan Quan
500e098bc96SEvan Quan parameters.clk_id = clk_id;
501e098bc96SEvan Quan parameters.syspll_id = syspll_id;
502e098bc96SEvan Quan parameters.command = GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ;
503e098bc96SEvan Quan parameters.dfsdid = 0;
504e098bc96SEvan Quan
505e098bc96SEvan Quan ix = GetIndexIntoMasterCmdTable(getsmuclockinfo);
506e098bc96SEvan Quan
507e098bc96SEvan Quan if (amdgpu_atom_execute_table(
508e098bc96SEvan Quan adev->mode_info.atom_context, ix, (uint32_t *)¶meters))
509e098bc96SEvan Quan return -EINVAL;
510e098bc96SEvan Quan
511e098bc96SEvan Quan output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)¶meters;
512e098bc96SEvan Quan *frequency = le32_to_cpu(output->atom_smu_outputclkfreq.smu_clock_freq_hz) / 10000;
513e098bc96SEvan Quan
514e098bc96SEvan Quan return 0;
515e098bc96SEvan Quan }
516e098bc96SEvan Quan
pp_atomfwctrl_copy_vbios_bootup_values_3_2(struct pp_hwmgr * hwmgr,struct pp_atomfwctrl_bios_boot_up_values * boot_values,struct atom_firmware_info_v3_2 * fw_info)517e098bc96SEvan Quan static void pp_atomfwctrl_copy_vbios_bootup_values_3_2(struct pp_hwmgr *hwmgr,
518e098bc96SEvan Quan struct pp_atomfwctrl_bios_boot_up_values *boot_values,
519e098bc96SEvan Quan struct atom_firmware_info_v3_2 *fw_info)
520e098bc96SEvan Quan {
521e098bc96SEvan Quan uint32_t frequency = 0;
522e098bc96SEvan Quan
523e098bc96SEvan Quan boot_values->ulRevision = fw_info->firmware_revision;
524e098bc96SEvan Quan boot_values->ulGfxClk = fw_info->bootup_sclk_in10khz;
525e098bc96SEvan Quan boot_values->ulUClk = fw_info->bootup_mclk_in10khz;
526e098bc96SEvan Quan boot_values->usVddc = fw_info->bootup_vddc_mv;
527e098bc96SEvan Quan boot_values->usVddci = fw_info->bootup_vddci_mv;
528e098bc96SEvan Quan boot_values->usMvddc = fw_info->bootup_mvddc_mv;
529e098bc96SEvan Quan boot_values->usVddGfx = fw_info->bootup_vddgfx_mv;
530e098bc96SEvan Quan boot_values->ucCoolingID = fw_info->coolingsolution_id;
531e098bc96SEvan Quan boot_values->ulSocClk = 0;
532e098bc96SEvan Quan boot_values->ulDCEFClk = 0;
533e098bc96SEvan Quan
534e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU11_SYSPLL0_SOCCLK_ID, SMU11_SYSPLL0_ID, &frequency))
535e098bc96SEvan Quan boot_values->ulSocClk = frequency;
536e098bc96SEvan Quan
537e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU11_SYSPLL0_DCEFCLK_ID, SMU11_SYSPLL0_ID, &frequency))
538e098bc96SEvan Quan boot_values->ulDCEFClk = frequency;
539e098bc96SEvan Quan
540e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU11_SYSPLL0_ECLK_ID, SMU11_SYSPLL0_ID, &frequency))
541e098bc96SEvan Quan boot_values->ulEClk = frequency;
542e098bc96SEvan Quan
543e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU11_SYSPLL0_VCLK_ID, SMU11_SYSPLL0_ID, &frequency))
544e098bc96SEvan Quan boot_values->ulVClk = frequency;
545e098bc96SEvan Quan
546e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU11_SYSPLL0_DCLK_ID, SMU11_SYSPLL0_ID, &frequency))
547e098bc96SEvan Quan boot_values->ulDClk = frequency;
548e098bc96SEvan Quan
549e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU11_SYSPLL1_0_FCLK_ID, SMU11_SYSPLL1_2_ID, &frequency))
550e098bc96SEvan Quan boot_values->ulFClk = frequency;
551e098bc96SEvan Quan }
552e098bc96SEvan Quan
pp_atomfwctrl_copy_vbios_bootup_values_3_1(struct pp_hwmgr * hwmgr,struct pp_atomfwctrl_bios_boot_up_values * boot_values,struct atom_firmware_info_v3_1 * fw_info)553e098bc96SEvan Quan static void pp_atomfwctrl_copy_vbios_bootup_values_3_1(struct pp_hwmgr *hwmgr,
554e098bc96SEvan Quan struct pp_atomfwctrl_bios_boot_up_values *boot_values,
555e098bc96SEvan Quan struct atom_firmware_info_v3_1 *fw_info)
556e098bc96SEvan Quan {
557e098bc96SEvan Quan uint32_t frequency = 0;
558e098bc96SEvan Quan
559e098bc96SEvan Quan boot_values->ulRevision = fw_info->firmware_revision;
560e098bc96SEvan Quan boot_values->ulGfxClk = fw_info->bootup_sclk_in10khz;
561e098bc96SEvan Quan boot_values->ulUClk = fw_info->bootup_mclk_in10khz;
562e098bc96SEvan Quan boot_values->usVddc = fw_info->bootup_vddc_mv;
563e098bc96SEvan Quan boot_values->usVddci = fw_info->bootup_vddci_mv;
564e098bc96SEvan Quan boot_values->usMvddc = fw_info->bootup_mvddc_mv;
565e098bc96SEvan Quan boot_values->usVddGfx = fw_info->bootup_vddgfx_mv;
566e098bc96SEvan Quan boot_values->ucCoolingID = fw_info->coolingsolution_id;
567e098bc96SEvan Quan boot_values->ulSocClk = 0;
568e098bc96SEvan Quan boot_values->ulDCEFClk = 0;
569e098bc96SEvan Quan
570e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_SOCCLK_ID, 0, &frequency))
571e098bc96SEvan Quan boot_values->ulSocClk = frequency;
572e098bc96SEvan Quan
573e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_DCEFCLK_ID, 0, &frequency))
574e098bc96SEvan Quan boot_values->ulDCEFClk = frequency;
575e098bc96SEvan Quan
576e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_ECLK_ID, 0, &frequency))
577e098bc96SEvan Quan boot_values->ulEClk = frequency;
578e098bc96SEvan Quan
579e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_VCLK_ID, 0, &frequency))
580e098bc96SEvan Quan boot_values->ulVClk = frequency;
581e098bc96SEvan Quan
582e098bc96SEvan Quan if (!pp_atomfwctrl_get_clk_information_by_clkid(hwmgr, SMU9_SYSPLL0_DCLK_ID, 0, &frequency))
583e098bc96SEvan Quan boot_values->ulDClk = frequency;
584e098bc96SEvan Quan }
585e098bc96SEvan Quan
pp_atomfwctrl_get_vbios_bootup_values(struct pp_hwmgr * hwmgr,struct pp_atomfwctrl_bios_boot_up_values * boot_values)586e098bc96SEvan Quan int pp_atomfwctrl_get_vbios_bootup_values(struct pp_hwmgr *hwmgr,
587e098bc96SEvan Quan struct pp_atomfwctrl_bios_boot_up_values *boot_values)
588e098bc96SEvan Quan {
589e098bc96SEvan Quan struct atom_firmware_info_v3_2 *fwinfo_3_2;
590e098bc96SEvan Quan struct atom_firmware_info_v3_1 *fwinfo_3_1;
591e098bc96SEvan Quan struct atom_common_table_header *info = NULL;
592e098bc96SEvan Quan uint16_t ix;
593e098bc96SEvan Quan
594e098bc96SEvan Quan ix = GetIndexIntoMasterDataTable(firmwareinfo);
595e098bc96SEvan Quan info = (struct atom_common_table_header *)
596e098bc96SEvan Quan smu_atom_get_data_table(hwmgr->adev,
597e098bc96SEvan Quan ix, NULL, NULL, NULL);
598e098bc96SEvan Quan
599e098bc96SEvan Quan if (!info) {
600e098bc96SEvan Quan pr_info("Error retrieving BIOS firmwareinfo!");
601e098bc96SEvan Quan return -EINVAL;
602e098bc96SEvan Quan }
603e098bc96SEvan Quan
604e098bc96SEvan Quan if ((info->format_revision == 3) && (info->content_revision == 2)) {
605e098bc96SEvan Quan fwinfo_3_2 = (struct atom_firmware_info_v3_2 *)info;
606e098bc96SEvan Quan pp_atomfwctrl_copy_vbios_bootup_values_3_2(hwmgr,
607e098bc96SEvan Quan boot_values, fwinfo_3_2);
608e098bc96SEvan Quan } else if ((info->format_revision == 3) && (info->content_revision == 1)) {
609e098bc96SEvan Quan fwinfo_3_1 = (struct atom_firmware_info_v3_1 *)info;
610e098bc96SEvan Quan pp_atomfwctrl_copy_vbios_bootup_values_3_1(hwmgr,
611e098bc96SEvan Quan boot_values, fwinfo_3_1);
612e098bc96SEvan Quan } else {
613e098bc96SEvan Quan pr_info("Fw info table revision does not match!");
614e098bc96SEvan Quan return -EINVAL;
615e098bc96SEvan Quan }
616e098bc96SEvan Quan
617e098bc96SEvan Quan return 0;
618e098bc96SEvan Quan }
619e098bc96SEvan Quan
pp_atomfwctrl_get_smc_dpm_information(struct pp_hwmgr * hwmgr,struct pp_atomfwctrl_smc_dpm_parameters * param)620e098bc96SEvan Quan int pp_atomfwctrl_get_smc_dpm_information(struct pp_hwmgr *hwmgr,
621e098bc96SEvan Quan struct pp_atomfwctrl_smc_dpm_parameters *param)
622e098bc96SEvan Quan {
623e098bc96SEvan Quan struct atom_smc_dpm_info_v4_1 *info;
624e098bc96SEvan Quan uint16_t ix;
625e098bc96SEvan Quan
626e098bc96SEvan Quan ix = GetIndexIntoMasterDataTable(smc_dpm_info);
627e098bc96SEvan Quan info = (struct atom_smc_dpm_info_v4_1 *)
628e098bc96SEvan Quan smu_atom_get_data_table(hwmgr->adev,
629e098bc96SEvan Quan ix, NULL, NULL, NULL);
630e098bc96SEvan Quan if (!info) {
631e098bc96SEvan Quan pr_info("Error retrieving BIOS Table Address!");
632e098bc96SEvan Quan return -EINVAL;
633e098bc96SEvan Quan }
634e098bc96SEvan Quan
635e098bc96SEvan Quan param->liquid1_i2c_address = info->liquid1_i2c_address;
636e098bc96SEvan Quan param->liquid2_i2c_address = info->liquid2_i2c_address;
637e098bc96SEvan Quan param->vr_i2c_address = info->vr_i2c_address;
638e098bc96SEvan Quan param->plx_i2c_address = info->plx_i2c_address;
639e098bc96SEvan Quan
640e098bc96SEvan Quan param->liquid_i2c_linescl = info->liquid_i2c_linescl;
641e098bc96SEvan Quan param->liquid_i2c_linesda = info->liquid_i2c_linesda;
642e098bc96SEvan Quan param->vr_i2c_linescl = info->vr_i2c_linescl;
643e098bc96SEvan Quan param->vr_i2c_linesda = info->vr_i2c_linesda;
644e098bc96SEvan Quan
645e098bc96SEvan Quan param->plx_i2c_linescl = info->plx_i2c_linescl;
646e098bc96SEvan Quan param->plx_i2c_linesda = info->plx_i2c_linesda;
647e098bc96SEvan Quan param->vrsensorpresent = info->vrsensorpresent;
648e098bc96SEvan Quan param->liquidsensorpresent = info->liquidsensorpresent;
649e098bc96SEvan Quan
650e098bc96SEvan Quan param->maxvoltagestepgfx = info->maxvoltagestepgfx;
651e098bc96SEvan Quan param->maxvoltagestepsoc = info->maxvoltagestepsoc;
652e098bc96SEvan Quan
653e098bc96SEvan Quan param->vddgfxvrmapping = info->vddgfxvrmapping;
654e098bc96SEvan Quan param->vddsocvrmapping = info->vddsocvrmapping;
655e098bc96SEvan Quan param->vddmem0vrmapping = info->vddmem0vrmapping;
656e098bc96SEvan Quan param->vddmem1vrmapping = info->vddmem1vrmapping;
657e098bc96SEvan Quan
658e098bc96SEvan Quan param->gfxulvphasesheddingmask = info->gfxulvphasesheddingmask;
659e098bc96SEvan Quan param->soculvphasesheddingmask = info->soculvphasesheddingmask;
660e098bc96SEvan Quan
661e098bc96SEvan Quan param->gfxmaxcurrent = info->gfxmaxcurrent;
662e098bc96SEvan Quan param->gfxoffset = info->gfxoffset;
663e098bc96SEvan Quan param->padding_telemetrygfx = info->padding_telemetrygfx;
664e098bc96SEvan Quan
665e098bc96SEvan Quan param->socmaxcurrent = info->socmaxcurrent;
666e098bc96SEvan Quan param->socoffset = info->socoffset;
667e098bc96SEvan Quan param->padding_telemetrysoc = info->padding_telemetrysoc;
668e098bc96SEvan Quan
669e098bc96SEvan Quan param->mem0maxcurrent = info->mem0maxcurrent;
670e098bc96SEvan Quan param->mem0offset = info->mem0offset;
671e098bc96SEvan Quan param->padding_telemetrymem0 = info->padding_telemetrymem0;
672e098bc96SEvan Quan
673e098bc96SEvan Quan param->mem1maxcurrent = info->mem1maxcurrent;
674e098bc96SEvan Quan param->mem1offset = info->mem1offset;
675e098bc96SEvan Quan param->padding_telemetrymem1 = info->padding_telemetrymem1;
676e098bc96SEvan Quan
677e098bc96SEvan Quan param->acdcgpio = info->acdcgpio;
678e098bc96SEvan Quan param->acdcpolarity = info->acdcpolarity;
679e098bc96SEvan Quan param->vr0hotgpio = info->vr0hotgpio;
680e098bc96SEvan Quan param->vr0hotpolarity = info->vr0hotpolarity;
681e098bc96SEvan Quan
682e098bc96SEvan Quan param->vr1hotgpio = info->vr1hotgpio;
683e098bc96SEvan Quan param->vr1hotpolarity = info->vr1hotpolarity;
684e098bc96SEvan Quan param->padding1 = info->padding1;
685e098bc96SEvan Quan param->padding2 = info->padding2;
686e098bc96SEvan Quan
687e098bc96SEvan Quan param->ledpin0 = info->ledpin0;
688e098bc96SEvan Quan param->ledpin1 = info->ledpin1;
689e098bc96SEvan Quan param->ledpin2 = info->ledpin2;
690e098bc96SEvan Quan
691e098bc96SEvan Quan param->pllgfxclkspreadenabled = info->pllgfxclkspreadenabled;
692e098bc96SEvan Quan param->pllgfxclkspreadpercent = info->pllgfxclkspreadpercent;
693e098bc96SEvan Quan param->pllgfxclkspreadfreq = info->pllgfxclkspreadfreq;
694e098bc96SEvan Quan
695e098bc96SEvan Quan param->uclkspreadenabled = info->uclkspreadenabled;
696e098bc96SEvan Quan param->uclkspreadpercent = info->uclkspreadpercent;
697e098bc96SEvan Quan param->uclkspreadfreq = info->uclkspreadfreq;
698e098bc96SEvan Quan
699e098bc96SEvan Quan param->socclkspreadenabled = info->socclkspreadenabled;
700e098bc96SEvan Quan param->socclkspreadpercent = info->socclkspreadpercent;
701e098bc96SEvan Quan param->socclkspreadfreq = info->socclkspreadfreq;
702e098bc96SEvan Quan
703e098bc96SEvan Quan param->acggfxclkspreadenabled = info->acggfxclkspreadenabled;
704e098bc96SEvan Quan param->acggfxclkspreadpercent = info->acggfxclkspreadpercent;
705e098bc96SEvan Quan param->acggfxclkspreadfreq = info->acggfxclkspreadfreq;
706e098bc96SEvan Quan
707e098bc96SEvan Quan param->Vr2_I2C_address = info->Vr2_I2C_address;
708e098bc96SEvan Quan
709e098bc96SEvan Quan return 0;
710e098bc96SEvan Quan }
711