Lines Matching +full:hpd +full:- +full:gpio

2  * Copyright 2007-8 Advanced Micro Devices, Inc.
35 #include "atom-bits.h"
40 ATOM_GPIO_I2C_ASSIGMENT *gpio, in amdgpu_atombios_lookup_i2c_gpio_quirks() argument
46 …c struct amdgpu_i2c_bus_rec amdgpu_atombios_get_bus_rec_for_i2c_gpio(ATOM_GPIO_I2C_ASSIGMENT *gpio) in amdgpu_atombios_get_bus_rec_for_i2c_gpio() argument
52 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
53 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
54 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
55 i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
56 i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
57 i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
58 i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
59 i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
60 i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
61 i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
62 i2c.en_clk_mask = (1 << gpio->ucClkEnShift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
63 i2c.en_data_mask = (1 << gpio->ucDataEnShift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
64 i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
65 i2c.y_data_mask = (1 << gpio->ucDataY_Shift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
66 i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
67 i2c.a_data_mask = (1 << gpio->ucDataA_Shift); in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
69 if (gpio->sucI2cId.sbfAccess.bfHW_Capable) in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
74 if (gpio->sucI2cId.ucAccess == 0xa0) in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
79 i2c.i2c_id = gpio->sucI2cId.ucAccess; in amdgpu_atombios_get_bus_rec_for_i2c_gpio()
92 struct atom_context *ctx = adev->mode_info.atom_context; in amdgpu_atombios_lookup_i2c_gpio()
93 ATOM_GPIO_I2C_ASSIGMENT *gpio; in amdgpu_atombios_lookup_i2c_gpio() local
104 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); in amdgpu_atombios_lookup_i2c_gpio()
106 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / in amdgpu_atombios_lookup_i2c_gpio()
109 gpio = &i2c_info->asGPIO_Info[0]; in amdgpu_atombios_lookup_i2c_gpio()
112 amdgpu_atombios_lookup_i2c_gpio_quirks(adev, gpio, i); in amdgpu_atombios_lookup_i2c_gpio()
114 if (gpio->sucI2cId.ucAccess == id) { in amdgpu_atombios_lookup_i2c_gpio()
115 i2c = amdgpu_atombios_get_bus_rec_for_i2c_gpio(gpio); in amdgpu_atombios_lookup_i2c_gpio()
118 gpio = (ATOM_GPIO_I2C_ASSIGMENT *) in amdgpu_atombios_lookup_i2c_gpio()
119 ((u8 *)gpio + sizeof(ATOM_GPIO_I2C_ASSIGMENT)); in amdgpu_atombios_lookup_i2c_gpio()
128 struct atom_context *ctx = adev->mode_info.atom_context; in amdgpu_atombios_i2c_init()
129 ATOM_GPIO_I2C_ASSIGMENT *gpio; in amdgpu_atombios_i2c_init() local
138 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); in amdgpu_atombios_i2c_init()
140 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / in amdgpu_atombios_i2c_init()
143 gpio = &i2c_info->asGPIO_Info[0]; in amdgpu_atombios_i2c_init()
145 amdgpu_atombios_lookup_i2c_gpio_quirks(adev, gpio, i); in amdgpu_atombios_i2c_init()
147 i2c = amdgpu_atombios_get_bus_rec_for_i2c_gpio(gpio); in amdgpu_atombios_i2c_init()
151 adev->i2c_bus[i] = amdgpu_i2c_create(adev_to_drm(adev), &i2c, stmp); in amdgpu_atombios_i2c_init()
153 gpio = (ATOM_GPIO_I2C_ASSIGMENT *) in amdgpu_atombios_i2c_init()
154 ((u8 *)gpio + sizeof(ATOM_GPIO_I2C_ASSIGMENT)); in amdgpu_atombios_i2c_init()
163 struct atom_context *ctx = adev->mode_info.atom_context; in amdgpu_atombios_lookup_gpio()
164 struct amdgpu_gpio_rec gpio; in amdgpu_atombios_lookup_gpio() local
171 memset(&gpio, 0, sizeof(struct amdgpu_gpio_rec)); in amdgpu_atombios_lookup_gpio()
172 gpio.valid = false; in amdgpu_atombios_lookup_gpio()
175 gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset); in amdgpu_atombios_lookup_gpio()
177 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / in amdgpu_atombios_lookup_gpio()
180 pin = gpio_info->asGPIO_Pin; in amdgpu_atombios_lookup_gpio()
182 if (id == pin->ucGPIO_ID) { in amdgpu_atombios_lookup_gpio()
183 gpio.id = pin->ucGPIO_ID; in amdgpu_atombios_lookup_gpio()
184 gpio.reg = le16_to_cpu(pin->usGpioPin_AIndex); in amdgpu_atombios_lookup_gpio()
185 gpio.shift = pin->ucGpioPinBitShift; in amdgpu_atombios_lookup_gpio()
186 gpio.mask = (1 << pin->ucGpioPinBitShift); in amdgpu_atombios_lookup_gpio()
187 gpio.valid = true; in amdgpu_atombios_lookup_gpio()
195 return gpio; in amdgpu_atombios_lookup_gpio()
200 struct amdgpu_gpio_rec *gpio) in amdgpu_atombios_get_hpd_info_from_gpio() argument
202 struct amdgpu_hpd hpd; in amdgpu_atombios_get_hpd_info_from_gpio() local
205 memset(&hpd, 0, sizeof(struct amdgpu_hpd)); in amdgpu_atombios_get_hpd_info_from_gpio()
209 hpd.gpio = *gpio; in amdgpu_atombios_get_hpd_info_from_gpio()
210 if (gpio->reg == reg) { in amdgpu_atombios_get_hpd_info_from_gpio()
211 switch(gpio->mask) { in amdgpu_atombios_get_hpd_info_from_gpio()
213 hpd.hpd = AMDGPU_HPD_1; in amdgpu_atombios_get_hpd_info_from_gpio()
216 hpd.hpd = AMDGPU_HPD_2; in amdgpu_atombios_get_hpd_info_from_gpio()
219 hpd.hpd = AMDGPU_HPD_3; in amdgpu_atombios_get_hpd_info_from_gpio()
222 hpd.hpd = AMDGPU_HPD_4; in amdgpu_atombios_get_hpd_info_from_gpio()
225 hpd.hpd = AMDGPU_HPD_5; in amdgpu_atombios_get_hpd_info_from_gpio()
228 hpd.hpd = AMDGPU_HPD_6; in amdgpu_atombios_get_hpd_info_from_gpio()
231 hpd.hpd = AMDGPU_HPD_NONE; in amdgpu_atombios_get_hpd_info_from_gpio()
235 hpd.hpd = AMDGPU_HPD_NONE; in amdgpu_atombios_get_hpd_info_from_gpio()
236 return hpd; in amdgpu_atombios_get_hpd_info_from_gpio()
266 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_has_dce_engine_info()
267 struct atom_context *ctx = mode_info->atom_context; in amdgpu_atombios_has_dce_engine_info()
280 obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset); in amdgpu_atombios_has_dce_engine_info()
282 (ctx->bios + data_offset + in amdgpu_atombios_has_dce_engine_info()
283 le16_to_cpu(obj_header->usDisplayPathTableOffset)); in amdgpu_atombios_has_dce_engine_info()
285 if (path_obj->ucNumOfDispPath) in amdgpu_atombios_has_dce_engine_info()
293 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_connector_info_from_object_table()
294 struct atom_context *ctx = mode_info->atom_context; in amdgpu_atombios_get_connector_info_from_object_table()
308 struct amdgpu_gpio_rec gpio; in amdgpu_atombios_get_connector_info_from_object_table() local
309 struct amdgpu_hpd hpd; in amdgpu_atombios_get_connector_info_from_object_table() local
317 obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset); in amdgpu_atombios_get_connector_info_from_object_table()
319 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
320 le16_to_cpu(obj_header->usDisplayPathTableOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
322 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
323 le16_to_cpu(obj_header->usConnectorObjectTableOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
325 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
326 le16_to_cpu(obj_header->usEncoderObjectTableOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
328 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
329 le16_to_cpu(obj_header->usRouterObjectTableOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
330 device_support = le16_to_cpu(obj_header->usDeviceSupport); in amdgpu_atombios_get_connector_info_from_object_table()
333 for (i = 0; i < path_obj->ucNumOfDispPath; i++) { in amdgpu_atombios_get_connector_info_from_object_table()
334 uint8_t *addr = (uint8_t *) path_obj->asDispPath; in amdgpu_atombios_get_connector_info_from_object_table()
338 path_size += le16_to_cpu(path->usSize); in amdgpu_atombios_get_connector_info_from_object_table()
340 if (device_support & le16_to_cpu(path->usDeviceTag)) { in amdgpu_atombios_get_connector_info_from_object_table()
342 (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK) in amdgpu_atombios_get_connector_info_from_object_table()
346 if ((le16_to_cpu(path->usDeviceTag) == in amdgpu_atombios_get_connector_info_from_object_table()
348 (le16_to_cpu(path->usDeviceTag) == in amdgpu_atombios_get_connector_info_from_object_table()
354 con_obj_id, le16_to_cpu(path->usDeviceTag)); in amdgpu_atombios_get_connector_info_from_object_table()
367 for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); j++) { in amdgpu_atombios_get_connector_info_from_object_table()
369 (le16_to_cpu(path->usGraphicObjIds[j]) & in amdgpu_atombios_get_connector_info_from_object_table()
373 for (k = 0; k < enc_obj->ucNumberOfObjects; k++) { in amdgpu_atombios_get_connector_info_from_object_table()
374 u16 encoder_obj = le16_to_cpu(enc_obj->asObjects[k].usObjectID); in amdgpu_atombios_get_connector_info_from_object_table()
375 if (le16_to_cpu(path->usGraphicObjIds[j]) == encoder_obj) { in amdgpu_atombios_get_connector_info_from_object_table()
377 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
378 le16_to_cpu(enc_obj->asObjects[k].usRecordOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
382 while (record->ucRecordSize > 0 && in amdgpu_atombios_get_connector_info_from_object_table()
383 record->ucRecordType > 0 && in amdgpu_atombios_get_connector_info_from_object_table()
384 record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) { in amdgpu_atombios_get_connector_info_from_object_table()
385 switch (record->ucRecordType) { in amdgpu_atombios_get_connector_info_from_object_table()
389 caps = le16_to_cpu(cap_record->usEncoderCap); in amdgpu_atombios_get_connector_info_from_object_table()
393 ((char *)record + record->ucRecordSize); in amdgpu_atombios_get_connector_info_from_object_table()
396 le16_to_cpu(path->usDeviceTag), in amdgpu_atombios_get_connector_info_from_object_table()
401 for (k = 0; k < router_obj->ucNumberOfObjects; k++) { in amdgpu_atombios_get_connector_info_from_object_table()
402 u16 router_obj_id = le16_to_cpu(router_obj->asObjects[k].usObjectID); in amdgpu_atombios_get_connector_info_from_object_table()
403 if (le16_to_cpu(path->usGraphicObjIds[j]) == router_obj_id) { in amdgpu_atombios_get_connector_info_from_object_table()
405 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
406 le16_to_cpu(router_obj->asObjects[k].usRecordOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
413 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
414 le16_to_cpu(router_obj->asObjects[k].usSrcDstTableOffset)); in amdgpu_atombios_get_connector_info_from_object_table()
417 (router_src_dst_table->ucNumberOfSrc * 2)); in amdgpu_atombios_get_connector_info_from_object_table()
423 if (le16_to_cpu(path->usConnObjectId) == in amdgpu_atombios_get_connector_info_from_object_table()
428 while (record->ucRecordSize > 0 && in amdgpu_atombios_get_connector_info_from_object_table()
429 record->ucRecordType > 0 && in amdgpu_atombios_get_connector_info_from_object_table()
430 record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) { in amdgpu_atombios_get_connector_info_from_object_table()
431 switch (record->ucRecordType) { in amdgpu_atombios_get_connector_info_from_object_table()
438 &i2c_record->sucI2cId; in amdgpu_atombios_get_connector_info_from_object_table()
441 i2c_config-> in amdgpu_atombios_get_connector_info_from_object_table()
443 router.i2c_addr = i2c_record->ucI2CAddr >> 1; in amdgpu_atombios_get_connector_info_from_object_table()
449 router.ddc_mux_type = ddc_path->ucMuxType; in amdgpu_atombios_get_connector_info_from_object_table()
450 router.ddc_mux_control_pin = ddc_path->ucMuxControlPin; in amdgpu_atombios_get_connector_info_from_object_table()
451 router.ddc_mux_state = ddc_path->ucMuxState[enum_id]; in amdgpu_atombios_get_connector_info_from_object_table()
457 router.cd_mux_type = cd_path->ucMuxType; in amdgpu_atombios_get_connector_info_from_object_table()
458 router.cd_mux_control_pin = cd_path->ucMuxControlPin; in amdgpu_atombios_get_connector_info_from_object_table()
459 router.cd_mux_state = cd_path->ucMuxState[enum_id]; in amdgpu_atombios_get_connector_info_from_object_table()
463 ((char *)record + record->ucRecordSize); in amdgpu_atombios_get_connector_info_from_object_table()
470 /* look up gpio for ddc, hpd */ in amdgpu_atombios_get_connector_info_from_object_table()
472 hpd.hpd = AMDGPU_HPD_NONE; in amdgpu_atombios_get_connector_info_from_object_table()
473 if ((le16_to_cpu(path->usDeviceTag) & in amdgpu_atombios_get_connector_info_from_object_table()
475 for (j = 0; j < con_obj->ucNumberOfObjects; j++) { in amdgpu_atombios_get_connector_info_from_object_table()
476 if (le16_to_cpu(path->usConnObjectId) == in amdgpu_atombios_get_connector_info_from_object_table()
477 le16_to_cpu(con_obj->asObjects[j]. in amdgpu_atombios_get_connector_info_from_object_table()
483 (ctx->bios + data_offset + in amdgpu_atombios_get_connector_info_from_object_table()
484 le16_to_cpu(con_obj-> in amdgpu_atombios_get_connector_info_from_object_table()
491 while (record->ucRecordSize > 0 && in amdgpu_atombios_get_connector_info_from_object_table()
492 record->ucRecordType > 0 && in amdgpu_atombios_get_connector_info_from_object_table()
493 record->ucRecordType <= ATOM_MAX_OBJECT_RECORD_NUMBER) { in amdgpu_atombios_get_connector_info_from_object_table()
494 switch (record->ucRecordType) { in amdgpu_atombios_get_connector_info_from_object_table()
501 &i2c_record->sucI2cId; in amdgpu_atombios_get_connector_info_from_object_table()
503 i2c_config-> in amdgpu_atombios_get_connector_info_from_object_table()
510 gpio = amdgpu_atombios_lookup_gpio(adev, in amdgpu_atombios_get_connector_info_from_object_table()
511 hpd_record->ucHPDIntGPIOID); in amdgpu_atombios_get_connector_info_from_object_table()
512 hpd = amdgpu_atombios_get_hpd_info_from_gpio(adev, &gpio); in amdgpu_atombios_get_connector_info_from_object_table()
513 hpd.plugged_state = hpd_record->ucPlugged_PinState; in amdgpu_atombios_get_connector_info_from_object_table()
520 record-> in amdgpu_atombios_get_connector_info_from_object_table()
529 ddc_bus.hpd = hpd.hpd; in amdgpu_atombios_get_connector_info_from_object_table()
531 conn_id = le16_to_cpu(path->usConnObjectId); in amdgpu_atombios_get_connector_info_from_object_table()
535 le16_to_cpu(path->usDeviceTag), in amdgpu_atombios_get_connector_info_from_object_table()
538 &hpd, in amdgpu_atombios_get_connector_info_from_object_table()
560 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_clock_info()
564 int ret = -EINVAL; in amdgpu_atombios_get_clock_info()
566 if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, in amdgpu_atombios_get_clock_info()
569 struct amdgpu_pll *ppll = &adev->clock.ppll[0]; in amdgpu_atombios_get_clock_info()
570 struct amdgpu_pll *spll = &adev->clock.spll; in amdgpu_atombios_get_clock_info()
571 struct amdgpu_pll *mpll = &adev->clock.mpll; in amdgpu_atombios_get_clock_info()
573 (union firmware_info *)(mode_info->atom_context->bios + in amdgpu_atombios_get_clock_info()
576 ppll->reference_freq = in amdgpu_atombios_get_clock_info()
577 le16_to_cpu(firmware_info->info.usReferenceClock); in amdgpu_atombios_get_clock_info()
578 ppll->reference_div = 0; in amdgpu_atombios_get_clock_info()
580 ppll->pll_out_min = in amdgpu_atombios_get_clock_info()
581 le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); in amdgpu_atombios_get_clock_info()
582 ppll->pll_out_max = in amdgpu_atombios_get_clock_info()
583 le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); in amdgpu_atombios_get_clock_info()
585 ppll->lcd_pll_out_min = in amdgpu_atombios_get_clock_info()
586 le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100; in amdgpu_atombios_get_clock_info()
587 if (ppll->lcd_pll_out_min == 0) in amdgpu_atombios_get_clock_info()
588 ppll->lcd_pll_out_min = ppll->pll_out_min; in amdgpu_atombios_get_clock_info()
589 ppll->lcd_pll_out_max = in amdgpu_atombios_get_clock_info()
590 le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100; in amdgpu_atombios_get_clock_info()
591 if (ppll->lcd_pll_out_max == 0) in amdgpu_atombios_get_clock_info()
592 ppll->lcd_pll_out_max = ppll->pll_out_max; in amdgpu_atombios_get_clock_info()
594 if (ppll->pll_out_min == 0) in amdgpu_atombios_get_clock_info()
595 ppll->pll_out_min = 64800; in amdgpu_atombios_get_clock_info()
597 ppll->pll_in_min = in amdgpu_atombios_get_clock_info()
598 le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input); in amdgpu_atombios_get_clock_info()
599 ppll->pll_in_max = in amdgpu_atombios_get_clock_info()
600 le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input); in amdgpu_atombios_get_clock_info()
602 ppll->min_post_div = 2; in amdgpu_atombios_get_clock_info()
603 ppll->max_post_div = 0x7f; in amdgpu_atombios_get_clock_info()
604 ppll->min_frac_feedback_div = 0; in amdgpu_atombios_get_clock_info()
605 ppll->max_frac_feedback_div = 9; in amdgpu_atombios_get_clock_info()
606 ppll->min_ref_div = 2; in amdgpu_atombios_get_clock_info()
607 ppll->max_ref_div = 0x3ff; in amdgpu_atombios_get_clock_info()
608 ppll->min_feedback_div = 4; in amdgpu_atombios_get_clock_info()
609 ppll->max_feedback_div = 0xfff; in amdgpu_atombios_get_clock_info()
610 ppll->best_vco = 0; in amdgpu_atombios_get_clock_info()
613 adev->clock.ppll[i] = *ppll; in amdgpu_atombios_get_clock_info()
616 spll->reference_freq = in amdgpu_atombios_get_clock_info()
617 le16_to_cpu(firmware_info->info_21.usCoreReferenceClock); in amdgpu_atombios_get_clock_info()
618 spll->reference_div = 0; in amdgpu_atombios_get_clock_info()
620 spll->pll_out_min = in amdgpu_atombios_get_clock_info()
621 le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output); in amdgpu_atombios_get_clock_info()
622 spll->pll_out_max = in amdgpu_atombios_get_clock_info()
623 le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output); in amdgpu_atombios_get_clock_info()
626 if (spll->pll_out_min == 0) in amdgpu_atombios_get_clock_info()
627 spll->pll_out_min = 64800; in amdgpu_atombios_get_clock_info()
629 spll->pll_in_min = in amdgpu_atombios_get_clock_info()
630 le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input); in amdgpu_atombios_get_clock_info()
631 spll->pll_in_max = in amdgpu_atombios_get_clock_info()
632 le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input); in amdgpu_atombios_get_clock_info()
634 spll->min_post_div = 1; in amdgpu_atombios_get_clock_info()
635 spll->max_post_div = 1; in amdgpu_atombios_get_clock_info()
636 spll->min_ref_div = 2; in amdgpu_atombios_get_clock_info()
637 spll->max_ref_div = 0xff; in amdgpu_atombios_get_clock_info()
638 spll->min_feedback_div = 4; in amdgpu_atombios_get_clock_info()
639 spll->max_feedback_div = 0xff; in amdgpu_atombios_get_clock_info()
640 spll->best_vco = 0; in amdgpu_atombios_get_clock_info()
643 mpll->reference_freq = in amdgpu_atombios_get_clock_info()
644 le16_to_cpu(firmware_info->info_21.usMemoryReferenceClock); in amdgpu_atombios_get_clock_info()
645 mpll->reference_div = 0; in amdgpu_atombios_get_clock_info()
647 mpll->pll_out_min = in amdgpu_atombios_get_clock_info()
648 le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output); in amdgpu_atombios_get_clock_info()
649 mpll->pll_out_max = in amdgpu_atombios_get_clock_info()
650 le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output); in amdgpu_atombios_get_clock_info()
653 if (mpll->pll_out_min == 0) in amdgpu_atombios_get_clock_info()
654 mpll->pll_out_min = 64800; in amdgpu_atombios_get_clock_info()
656 mpll->pll_in_min = in amdgpu_atombios_get_clock_info()
657 le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input); in amdgpu_atombios_get_clock_info()
658 mpll->pll_in_max = in amdgpu_atombios_get_clock_info()
659 le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input); in amdgpu_atombios_get_clock_info()
661 adev->clock.default_sclk = in amdgpu_atombios_get_clock_info()
662 le32_to_cpu(firmware_info->info.ulDefaultEngineClock); in amdgpu_atombios_get_clock_info()
663 adev->clock.default_mclk = in amdgpu_atombios_get_clock_info()
664 le32_to_cpu(firmware_info->info.ulDefaultMemoryClock); in amdgpu_atombios_get_clock_info()
666 mpll->min_post_div = 1; in amdgpu_atombios_get_clock_info()
667 mpll->max_post_div = 1; in amdgpu_atombios_get_clock_info()
668 mpll->min_ref_div = 2; in amdgpu_atombios_get_clock_info()
669 mpll->max_ref_div = 0xff; in amdgpu_atombios_get_clock_info()
670 mpll->min_feedback_div = 4; in amdgpu_atombios_get_clock_info()
671 mpll->max_feedback_div = 0xff; in amdgpu_atombios_get_clock_info()
672 mpll->best_vco = 0; in amdgpu_atombios_get_clock_info()
675 adev->clock.default_dispclk = in amdgpu_atombios_get_clock_info()
676 le32_to_cpu(firmware_info->info_21.ulDefaultDispEngineClkFreq); in amdgpu_atombios_get_clock_info()
678 if (adev->clock.default_dispclk < 53900) { in amdgpu_atombios_get_clock_info()
680 adev->clock.default_dispclk / 100); in amdgpu_atombios_get_clock_info()
681 adev->clock.default_dispclk = 60000; in amdgpu_atombios_get_clock_info()
682 } else if (adev->clock.default_dispclk <= 60000) { in amdgpu_atombios_get_clock_info()
684 adev->clock.default_dispclk / 100); in amdgpu_atombios_get_clock_info()
685 adev->clock.default_dispclk = 62500; in amdgpu_atombios_get_clock_info()
687 adev->clock.dp_extclk = in amdgpu_atombios_get_clock_info()
688 le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq); in amdgpu_atombios_get_clock_info()
689 adev->clock.current_dispclk = adev->clock.default_dispclk; in amdgpu_atombios_get_clock_info()
691 adev->clock.max_pixel_clock = le16_to_cpu(firmware_info->info.usMaxPixelClock); in amdgpu_atombios_get_clock_info()
692 if (adev->clock.max_pixel_clock == 0) in amdgpu_atombios_get_clock_info()
693 adev->clock.max_pixel_clock = 40000; in amdgpu_atombios_get_clock_info()
696 adev->mode_info.firmware_flags = in amdgpu_atombios_get_clock_info()
697 le16_to_cpu(firmware_info->info.usFirmwareCapability.susAccess); in amdgpu_atombios_get_clock_info()
702 adev->pm.current_sclk = adev->clock.default_sclk; in amdgpu_atombios_get_clock_info()
703 adev->pm.current_mclk = adev->clock.default_mclk; in amdgpu_atombios_get_clock_info()
714 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_gfx_info()
718 int ret = -EINVAL; in amdgpu_atombios_get_gfx_info()
720 if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, in amdgpu_atombios_get_gfx_info()
723 (mode_info->atom_context->bios + data_offset); in amdgpu_atombios_get_gfx_info()
725 adev->gfx.config.max_shader_engines = gfx_info->info.max_shader_engines; in amdgpu_atombios_get_gfx_info()
726 adev->gfx.config.max_tile_pipes = gfx_info->info.max_tile_pipes; in amdgpu_atombios_get_gfx_info()
727 adev->gfx.config.max_cu_per_sh = gfx_info->info.max_cu_per_sh; in amdgpu_atombios_get_gfx_info()
728 adev->gfx.config.max_sh_per_se = gfx_info->info.max_sh_per_se; in amdgpu_atombios_get_gfx_info()
729 adev->gfx.config.max_backends_per_se = gfx_info->info.max_backends_per_se; in amdgpu_atombios_get_gfx_info()
730 adev->gfx.config.max_texture_channel_caches = in amdgpu_atombios_get_gfx_info()
731 gfx_info->info.max_texture_channel_caches; in amdgpu_atombios_get_gfx_info()
753 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_vram_width()
760 if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, &size, in amdgpu_atombios_get_vram_width()
763 (mode_info->atom_context->bios + data_offset); in amdgpu_atombios_get_vram_width()
767 return igp_info->info_8.ucUMAChannelNumber * 64; in amdgpu_atombios_get_vram_width()
780 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_igp_ss_overrides()
788 if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, &size, in amdgpu_atombios_get_igp_ss_overrides()
791 (mode_info->atom_context->bios + data_offset); in amdgpu_atombios_get_igp_ss_overrides()
796 percentage = le16_to_cpu(igp_info->info_6.usDVISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
797 rate = le16_to_cpu(igp_info->info_6.usDVISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
800 percentage = le16_to_cpu(igp_info->info_6.usHDMISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
801 rate = le16_to_cpu(igp_info->info_6.usHDMISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
804 percentage = le16_to_cpu(igp_info->info_6.usLvdsSSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
805 rate = le16_to_cpu(igp_info->info_6.usLvdsSSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
812 percentage = le16_to_cpu(igp_info->info_7.usDVISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
813 rate = le16_to_cpu(igp_info->info_7.usDVISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
816 percentage = le16_to_cpu(igp_info->info_7.usHDMISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
817 rate = le16_to_cpu(igp_info->info_7.usHDMISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
820 percentage = le16_to_cpu(igp_info->info_7.usLvdsSSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
821 rate = le16_to_cpu(igp_info->info_7.usLvdsSSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
828 percentage = le16_to_cpu(igp_info->info_8.usDVISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
829 rate = le16_to_cpu(igp_info->info_8.usDVISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
832 percentage = le16_to_cpu(igp_info->info_8.usHDMISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
833 rate = le16_to_cpu(igp_info->info_8.usHDMISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
836 percentage = le16_to_cpu(igp_info->info_8.usLvdsSSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
837 rate = le16_to_cpu(igp_info->info_8.usLvdsSSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
844 percentage = le16_to_cpu(igp_info->info_9.usDVISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
845 rate = le16_to_cpu(igp_info->info_9.usDVISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
848 percentage = le16_to_cpu(igp_info->info_9.usHDMISSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
849 rate = le16_to_cpu(igp_info->info_9.usHDMISSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
852 percentage = le16_to_cpu(igp_info->info_9.usLvdsSSPercentage); in amdgpu_atombios_get_igp_ss_overrides()
853 rate = le16_to_cpu(igp_info->info_9.usLvdsSSpreadRateIn10Hz); in amdgpu_atombios_get_igp_ss_overrides()
862 ss->percentage = percentage; in amdgpu_atombios_get_igp_ss_overrides()
864 ss->rate = rate; in amdgpu_atombios_get_igp_ss_overrides()
884 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_asic_ss_info()
893 if (!(adev->mode_info.firmware_flags & ATOM_BIOS_INFO_MEMORY_CLOCK_SS_SUPPORT)) in amdgpu_atombios_get_asic_ss_info()
897 if (!(adev->mode_info.firmware_flags & ATOM_BIOS_INFO_ENGINE_CLOCK_SS_SUPPORT)) in amdgpu_atombios_get_asic_ss_info()
902 if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, &size, in amdgpu_atombios_get_asic_ss_info()
906 (union asic_ss_info *)(mode_info->atom_context->bios + data_offset); in amdgpu_atombios_get_asic_ss_info()
910 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / in amdgpu_atombios_get_asic_ss_info()
913 ss_assign = (union asic_ss_assignment *)((u8 *)&ss_info->info.asSpreadSpectrum[0]); in amdgpu_atombios_get_asic_ss_info()
915 if ((ss_assign->v1.ucClockIndication == id) && in amdgpu_atombios_get_asic_ss_info()
916 (clock <= le32_to_cpu(ss_assign->v1.ulTargetClockRange))) { in amdgpu_atombios_get_asic_ss_info()
917 ss->percentage = in amdgpu_atombios_get_asic_ss_info()
918 le16_to_cpu(ss_assign->v1.usSpreadSpectrumPercentage); in amdgpu_atombios_get_asic_ss_info()
919 ss->type = ss_assign->v1.ucSpreadSpectrumMode; in amdgpu_atombios_get_asic_ss_info()
920 ss->rate = le16_to_cpu(ss_assign->v1.usSpreadRateInKhz); in amdgpu_atombios_get_asic_ss_info()
921 ss->percentage_divider = 100; in amdgpu_atombios_get_asic_ss_info()
929 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / in amdgpu_atombios_get_asic_ss_info()
931 ss_assign = (union asic_ss_assignment *)((u8 *)&ss_info->info_2.asSpreadSpectrum[0]); in amdgpu_atombios_get_asic_ss_info()
933 if ((ss_assign->v2.ucClockIndication == id) && in amdgpu_atombios_get_asic_ss_info()
934 (clock <= le32_to_cpu(ss_assign->v2.ulTargetClockRange))) { in amdgpu_atombios_get_asic_ss_info()
935 ss->percentage = in amdgpu_atombios_get_asic_ss_info()
936 le16_to_cpu(ss_assign->v2.usSpreadSpectrumPercentage); in amdgpu_atombios_get_asic_ss_info()
937 ss->type = ss_assign->v2.ucSpreadSpectrumMode; in amdgpu_atombios_get_asic_ss_info()
938 ss->rate = le16_to_cpu(ss_assign->v2.usSpreadRateIn10Hz); in amdgpu_atombios_get_asic_ss_info()
939 ss->percentage_divider = 100; in amdgpu_atombios_get_asic_ss_info()
943 ss->rate /= 100; in amdgpu_atombios_get_asic_ss_info()
951 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / in amdgpu_atombios_get_asic_ss_info()
953 ss_assign = (union asic_ss_assignment *)((u8 *)&ss_info->info_3.asSpreadSpectrum[0]); in amdgpu_atombios_get_asic_ss_info()
955 if ((ss_assign->v3.ucClockIndication == id) && in amdgpu_atombios_get_asic_ss_info()
956 (clock <= le32_to_cpu(ss_assign->v3.ulTargetClockRange))) { in amdgpu_atombios_get_asic_ss_info()
957 ss->percentage = in amdgpu_atombios_get_asic_ss_info()
958 le16_to_cpu(ss_assign->v3.usSpreadSpectrumPercentage); in amdgpu_atombios_get_asic_ss_info()
959 ss->type = ss_assign->v3.ucSpreadSpectrumMode; in amdgpu_atombios_get_asic_ss_info()
960 ss->rate = le16_to_cpu(ss_assign->v3.usSpreadRateIn10Hz); in amdgpu_atombios_get_asic_ss_info()
961 if (ss_assign->v3.ucSpreadSpectrumMode & in amdgpu_atombios_get_asic_ss_info()
963 ss->percentage_divider = 1000; in amdgpu_atombios_get_asic_ss_info()
965 ss->percentage_divider = 100; in amdgpu_atombios_get_asic_ss_info()
968 ss->rate /= 100; in amdgpu_atombios_get_asic_ss_info()
969 if (adev->flags & AMD_IS_APU) in amdgpu_atombios_get_asic_ss_info()
1009 if (!amdgpu_atom_parse_cmd_header(adev->mode_info.atom_context, index, &frev, &crev)) in amdgpu_atombios_get_clock_dividers()
1010 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1021 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_clock_dividers()
1023 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1025 dividers->post_div = args.v3.ucPostDiv; in amdgpu_atombios_get_clock_dividers()
1026 dividers->enable_post_div = (args.v3.ucCntlFlag & in amdgpu_atombios_get_clock_dividers()
1028 dividers->enable_dithen = (args.v3.ucCntlFlag & in amdgpu_atombios_get_clock_dividers()
1030 dividers->whole_fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDiv); in amdgpu_atombios_get_clock_dividers()
1031 dividers->frac_fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDivFrac); in amdgpu_atombios_get_clock_dividers()
1032 dividers->ref_div = args.v3.ucRefDiv; in amdgpu_atombios_get_clock_dividers()
1033 dividers->vco_mode = (args.v3.ucCntlFlag & in amdgpu_atombios_get_clock_dividers()
1037 if (adev->asic_type >= CHIP_TAHITI) in amdgpu_atombios_get_clock_dividers()
1038 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1043 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_clock_dividers()
1045 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1047 dividers->post_div = args.v5.ucPostDiv; in amdgpu_atombios_get_clock_dividers()
1048 dividers->enable_post_div = (args.v5.ucCntlFlag & in amdgpu_atombios_get_clock_dividers()
1050 dividers->enable_dithen = (args.v5.ucCntlFlag & in amdgpu_atombios_get_clock_dividers()
1052 dividers->whole_fb_div = le16_to_cpu(args.v5.ulFbDiv.usFbDiv); in amdgpu_atombios_get_clock_dividers()
1053 dividers->frac_fb_div = le16_to_cpu(args.v5.ulFbDiv.usFbDivFrac); in amdgpu_atombios_get_clock_dividers()
1054 dividers->ref_div = args.v5.ucRefDiv; in amdgpu_atombios_get_clock_dividers()
1055 dividers->vco_mode = (args.v5.ucCntlFlag & in amdgpu_atombios_get_clock_dividers()
1063 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_clock_dividers()
1065 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1067 dividers->post_divider = dividers->post_div = args.v4.ucPostDiv; in amdgpu_atombios_get_clock_dividers()
1068 dividers->real_clock = le32_to_cpu(args.v4.ulClock); in amdgpu_atombios_get_clock_dividers()
1076 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_clock_dividers()
1078 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1080 dividers->whole_fb_div = le16_to_cpu(args.v6_out.ulFbDiv.usFbDiv); in amdgpu_atombios_get_clock_dividers()
1081 dividers->frac_fb_div = le16_to_cpu(args.v6_out.ulFbDiv.usFbDivFrac); in amdgpu_atombios_get_clock_dividers()
1082 dividers->ref_div = args.v6_out.ucPllRefDiv; in amdgpu_atombios_get_clock_dividers()
1083 dividers->post_div = args.v6_out.ucPllPostDiv; in amdgpu_atombios_get_clock_dividers()
1084 dividers->flags = args.v6_out.ucPllCntlFlag; in amdgpu_atombios_get_clock_dividers()
1085 dividers->real_clock = le32_to_cpu(args.v6_out.ulClock.ulClock); in amdgpu_atombios_get_clock_dividers()
1086 dividers->post_divider = args.v6_out.ulClock.ucPostDiv; in amdgpu_atombios_get_clock_dividers()
1089 return -EINVAL; in amdgpu_atombios_get_clock_dividers()
1107 if (!amdgpu_atom_parse_cmd_header(adev->mode_info.atom_context, index, &frev, &crev)) in amdgpu_atombios_get_memory_pll_dividers()
1108 return -EINVAL; in amdgpu_atombios_get_memory_pll_dividers()
1120 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_memory_pll_dividers()
1122 return -EINVAL; in amdgpu_atombios_get_memory_pll_dividers()
1124 mpll_param->clkfrac = le16_to_cpu(args.ulFbDiv.usFbDivFrac); in amdgpu_atombios_get_memory_pll_dividers()
1125 mpll_param->clkf = le16_to_cpu(args.ulFbDiv.usFbDiv); in amdgpu_atombios_get_memory_pll_dividers()
1126 mpll_param->post_div = args.ucPostDiv; in amdgpu_atombios_get_memory_pll_dividers()
1127 mpll_param->dll_speed = args.ucDllSpeed; in amdgpu_atombios_get_memory_pll_dividers()
1128 mpll_param->bwcntl = args.ucBWCntl; in amdgpu_atombios_get_memory_pll_dividers()
1129 mpll_param->vco_mode = in amdgpu_atombios_get_memory_pll_dividers()
1131 mpll_param->yclk_sel = in amdgpu_atombios_get_memory_pll_dividers()
1133 mpll_param->qdr = in amdgpu_atombios_get_memory_pll_dividers()
1135 mpll_param->half_rate = in amdgpu_atombios_get_memory_pll_dividers()
1139 return -EINVAL; in amdgpu_atombios_get_memory_pll_dividers()
1143 return -EINVAL; in amdgpu_atombios_get_memory_pll_dividers()
1164 amdgpu_atom_execute_table(adev->mode_info.atom_context, index, (uint32_t *)&args, in amdgpu_atombios_set_engine_dram_timings()
1171 struct amdgpu_mode_info *mode_info = &adev->mode_info; in amdgpu_atombios_get_default_voltages()
1181 if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, in amdgpu_atombios_get_default_voltages()
1184 (union firmware_info *)(mode_info->atom_context->bios + in amdgpu_atombios_get_default_voltages()
1186 *vddc = le16_to_cpu(firmware_info->info_14.usBootUpVDDCVoltage); in amdgpu_atombios_get_default_voltages()
1188 *vddci = le16_to_cpu(firmware_info->info_22.usBootUpVDDCIVoltage); in amdgpu_atombios_get_default_voltages()
1189 *mvdd = le16_to_cpu(firmware_info->info_22.usBootUpMVDDCVoltage); in amdgpu_atombios_get_default_voltages()
1208 if (!amdgpu_atom_parse_cmd_header(adev->mode_info.atom_context, index, &frev, &crev)) in amdgpu_atombios_get_max_vddc()
1209 return -EINVAL; in amdgpu_atombios_get_max_vddc()
1213 return -EINVAL; in amdgpu_atombios_get_max_vddc()
1219 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_max_vddc()
1221 return -EINVAL; in amdgpu_atombios_get_max_vddc()
1230 if (amdgpu_atom_execute_table(adev->mode_info.atom_context, in amdgpu_atombios_get_max_vddc()
1232 return -EINVAL; in amdgpu_atombios_get_max_vddc()
1238 return -EINVAL; in amdgpu_atombios_get_max_vddc()
1267 u32 size = le16_to_cpu(v3->sHeader.usStructureSize); in amdgpu_atombios_lookup_voltage_object_v3()
1273 if ((vo->asGpioVoltageObj.sHeader.ucVoltageType == voltage_type) && in amdgpu_atombios_lookup_voltage_object_v3()
1274 (vo->asGpioVoltageObj.sHeader.ucVoltageMode == voltage_mode)) in amdgpu_atombios_lookup_voltage_object_v3()
1276 offset += le16_to_cpu(vo->asGpioVoltageObj.sHeader.usSize); in amdgpu_atombios_lookup_voltage_object_v3()
1291 if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, &size, in amdgpu_atombios_get_svi2_info()
1294 (adev->mode_info.atom_context->bios + data_offset); in amdgpu_atombios_get_svi2_info()
1301 amdgpu_atombios_lookup_voltage_object_v3(&voltage_info->v3, in amdgpu_atombios_get_svi2_info()
1305 *svd_gpio_id = voltage_object->v3.asSVID2Obj.ucSVDGpioId; in amdgpu_atombios_get_svi2_info()
1306 *svc_gpio_id = voltage_object->v3.asSVID2Obj.ucSVCGpioId; in amdgpu_atombios_get_svi2_info()
1308 return -EINVAL; in amdgpu_atombios_get_svi2_info()
1313 return -EINVAL; in amdgpu_atombios_get_svi2_info()
1318 return -EINVAL; in amdgpu_atombios_get_svi2_info()
1334 if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, &size, in amdgpu_atombios_is_voltage_gpio()
1337 (adev->mode_info.atom_context->bios + data_offset); in amdgpu_atombios_is_voltage_gpio()
1343 if (amdgpu_atombios_lookup_voltage_object_v3(&voltage_info->v3, in amdgpu_atombios_is_voltage_gpio()
1372 if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, &size, in amdgpu_atombios_get_voltage_table()
1375 (adev->mode_info.atom_context->bios + data_offset); in amdgpu_atombios_get_voltage_table()
1382 amdgpu_atombios_lookup_voltage_object_v3(&voltage_info->v3, in amdgpu_atombios_get_voltage_table()
1385 ATOM_GPIO_VOLTAGE_OBJECT_V3 *gpio = in amdgpu_atombios_get_voltage_table() local
1386 &voltage_object->v3.asGpioVoltageObj; in amdgpu_atombios_get_voltage_table()
1388 if (gpio->ucGpioEntryNum > MAX_VOLTAGE_ENTRIES) in amdgpu_atombios_get_voltage_table()
1389 return -EINVAL; in amdgpu_atombios_get_voltage_table()
1390 lut = &gpio->asVolGpioLut[0]; in amdgpu_atombios_get_voltage_table()
1391 for (i = 0; i < gpio->ucGpioEntryNum; i++) { in amdgpu_atombios_get_voltage_table()
1392 voltage_table->entries[i].value = in amdgpu_atombios_get_voltage_table()
1393 le16_to_cpu(lut->usVoltageValue); in amdgpu_atombios_get_voltage_table()
1394 voltage_table->entries[i].smio_low = in amdgpu_atombios_get_voltage_table()
1395 le32_to_cpu(lut->ulVoltageId); in amdgpu_atombios_get_voltage_table()
1399 voltage_table->mask_low = le32_to_cpu(gpio->ulGpioMaskVal); in amdgpu_atombios_get_voltage_table()
1400 voltage_table->count = gpio->ucGpioEntryNum; in amdgpu_atombios_get_voltage_table()
1401 voltage_table->phase_delay = gpio->ucPhaseDelay; in amdgpu_atombios_get_voltage_table()
1407 return -EINVAL; in amdgpu_atombios_get_voltage_table()
1412 return -EINVAL; in amdgpu_atombios_get_voltage_table()
1415 return -EINVAL; in amdgpu_atombios_get_voltage_table()
1444 if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, &size, in amdgpu_atombios_init_mc_reg_table()
1447 (adev->mode_info.atom_context->bios + data_offset); in amdgpu_atombios_init_mc_reg_table()
1451 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1455 if (module_index < vram_info->v2_1.ucNumOfVRAMModule) { in amdgpu_atombios_init_mc_reg_table()
1458 ((u8 *)vram_info + le16_to_cpu(vram_info->v2_1.usMemClkPatchTblOffset)); in amdgpu_atombios_init_mc_reg_table()
1462 le16_to_cpu(reg_block->usRegIndexTblSize)); in amdgpu_atombios_init_mc_reg_table()
1463 ATOM_INIT_REG_INDEX_FORMAT *format = &reg_block->asRegIndexBuf[0]; in amdgpu_atombios_init_mc_reg_table()
1464 num_entries = (u8)((le16_to_cpu(reg_block->usRegIndexTblSize)) / in amdgpu_atombios_init_mc_reg_table()
1465 sizeof(ATOM_INIT_REG_INDEX_FORMAT)) - 1; in amdgpu_atombios_init_mc_reg_table()
1467 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1469 if (format->ucPreRegDataLength & ACCESS_PLACEHOLDER) in amdgpu_atombios_init_mc_reg_table()
1471 reg_table->mc_reg_address[i].s1 = in amdgpu_atombios_init_mc_reg_table()
1472 (u16)(le16_to_cpu(format->usRegIndex)); in amdgpu_atombios_init_mc_reg_table()
1473 reg_table->mc_reg_address[i].pre_reg_data = in amdgpu_atombios_init_mc_reg_table()
1474 (u8)(format->ucPreRegDataLength); in amdgpu_atombios_init_mc_reg_table()
1479 reg_table->last = i; in amdgpu_atombios_init_mc_reg_table()
1485 reg_table->mc_reg_table_entry[num_ranges].mclk_max = in amdgpu_atombios_init_mc_reg_table()
1488 for (i = 0, j = 1; i < reg_table->last; i++) { in amdgpu_atombios_init_mc_reg_table()
1489 if ((reg_table->mc_reg_address[i].pre_reg_data & LOW_NIBBLE_MASK) == DATA_FROM_TABLE) { in amdgpu_atombios_init_mc_reg_table()
1490 reg_table->mc_reg_table_entry[num_ranges].mc_data[i] = in amdgpu_atombios_init_mc_reg_table()
1493 } else if ((reg_table->mc_reg_address[i].pre_reg_data & LOW_NIBBLE_MASK) == DATA_EQU_PREV) { in amdgpu_atombios_init_mc_reg_table()
1496 reg_table->mc_reg_table_entry[num_ranges].mc_data[i] = in amdgpu_atombios_init_mc_reg_table()
1497 reg_table->mc_reg_table_entry[num_ranges].mc_data[i - 1]; in amdgpu_atombios_init_mc_reg_table()
1503 ((u8 *)reg_data + le16_to_cpu(reg_block->usRegDataBlkSize)); in amdgpu_atombios_init_mc_reg_table()
1506 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1507 reg_table->num_entries = num_ranges; in amdgpu_atombios_init_mc_reg_table()
1509 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1513 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1518 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1522 return -EINVAL; in amdgpu_atombios_init_mc_reg_table()
1532 if (amdgpu_atom_parse_data_header(adev->mode_info.atom_context, index, &size, in amdgpu_atombios_has_gpu_virtualization_table()
1543 bios_6_scratch = RREG32(adev->bios_scratch_reg_offset + 6); in amdgpu_atombios_scratch_regs_lock()
1553 WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); in amdgpu_atombios_scratch_regs_lock()
1560 adev->bios_scratch_reg_offset = mmBIOS_SCRATCH_0; in amdgpu_atombios_scratch_regs_init()
1562 bios_2_scratch = RREG32(adev->bios_scratch_reg_offset + 2); in amdgpu_atombios_scratch_regs_init()
1563 bios_6_scratch = RREG32(adev->bios_scratch_reg_offset + 6); in amdgpu_atombios_scratch_regs_init()
1574 WREG32(adev->bios_scratch_reg_offset + 2, bios_2_scratch); in amdgpu_atombios_scratch_regs_init()
1575 WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); in amdgpu_atombios_scratch_regs_init()
1581 u32 tmp = RREG32(adev->bios_scratch_reg_offset + 3); in amdgpu_atombios_scratch_regs_engine_hung()
1588 WREG32(adev->bios_scratch_reg_offset + 3, tmp); in amdgpu_atombios_scratch_regs_engine_hung()
1594 u32 tmp = RREG32(adev->bios_scratch_reg_offset + 2); in amdgpu_atombios_scratch_regs_set_backlight_level()
1600 WREG32(adev->bios_scratch_reg_offset + 2, tmp); in amdgpu_atombios_scratch_regs_set_backlight_level()
1605 u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7); in amdgpu_atombios_scratch_need_asic_init()
1647 struct atom_context *ctx = adev->mode_info.atom_context; in amdgpu_atombios_allocate_fb_scratch()
1656 firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset); in amdgpu_atombios_allocate_fb_scratch()
1659 le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware), in amdgpu_atombios_allocate_fb_scratch()
1660 le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb)); in amdgpu_atombios_allocate_fb_scratch()
1662 start_addr = firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware; in amdgpu_atombios_allocate_fb_scratch()
1663 size = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb; in amdgpu_atombios_allocate_fb_scratch()
1668 /* Firmware request VRAM reservation for SR-IOV */ in amdgpu_atombios_allocate_fb_scratch()
1669 adev->mman.fw_vram_usage_start_offset = (start_addr & in amdgpu_atombios_allocate_fb_scratch()
1671 adev->mman.fw_vram_usage_size = size << 10; in amdgpu_atombios_allocate_fb_scratch()
1675 usage_bytes = le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 1024; in amdgpu_atombios_allocate_fb_scratch()
1678 ctx->scratch_size_bytes = 0; in amdgpu_atombios_allocate_fb_scratch()
1682 ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL); in amdgpu_atombios_allocate_fb_scratch()
1683 if (!ctx->scratch) in amdgpu_atombios_allocate_fb_scratch()
1684 return -ENOMEM; in amdgpu_atombios_allocate_fb_scratch()
1685 ctx->scratch_size_bytes = usage_bytes; in amdgpu_atombios_allocate_fb_scratch()
1699 * cail_pll_read - read PLL register
1713 * cail_pll_write - write PLL register
1727 * cail_mc_read - read MC (Memory Controller) register
1741 * cail_mc_write - write MC (Memory Controller) register
1755 * cail_reg_write - write MMIO register
1765 struct amdgpu_device *adev = drm_to_adev(info->dev); in cail_reg_write()
1771 * cail_reg_read - read MMIO register
1781 struct amdgpu_device *adev = drm_to_adev(info->dev); in cail_reg_read()
1794 struct atom_context *ctx = adev->mode_info.atom_context; in amdgpu_atombios_get_vbios_version()
1796 return sysfs_emit(buf, "%s\n", ctx->vbios_pn); in amdgpu_atombios_get_vbios_version()
1813 if (adev->mode_info.atom_context) in amdgpu_atombios_sysfs_init()
1814 return devm_device_add_group(adev->dev, in amdgpu_atombios_sysfs_init()
1821 * amdgpu_atombios_fini - free the driver info and callbacks for atombios
1831 if (adev->mode_info.atom_context) { in amdgpu_atombios_fini()
1832 kfree(adev->mode_info.atom_context->scratch); in amdgpu_atombios_fini()
1833 kfree(adev->mode_info.atom_context->iio); in amdgpu_atombios_fini()
1835 kfree(adev->mode_info.atom_context); in amdgpu_atombios_fini()
1836 adev->mode_info.atom_context = NULL; in amdgpu_atombios_fini()
1837 kfree(adev->mode_info.atom_card_info); in amdgpu_atombios_fini()
1838 adev->mode_info.atom_card_info = NULL; in amdgpu_atombios_fini()
1842 * amdgpu_atombios_init - init the driver info and callbacks for atombios
1848 * Returns 0 on sucess, -ENOMEM on failure.
1857 return -ENOMEM; in amdgpu_atombios_init()
1859 adev->mode_info.atom_card_info = atom_card_info; in amdgpu_atombios_init()
1860 atom_card_info->dev = adev_to_drm(adev); in amdgpu_atombios_init()
1861 atom_card_info->reg_read = cail_reg_read; in amdgpu_atombios_init()
1862 atom_card_info->reg_write = cail_reg_write; in amdgpu_atombios_init()
1863 atom_card_info->mc_read = cail_mc_read; in amdgpu_atombios_init()
1864 atom_card_info->mc_write = cail_mc_write; in amdgpu_atombios_init()
1865 atom_card_info->pll_read = cail_pll_read; in amdgpu_atombios_init()
1866 atom_card_info->pll_write = cail_pll_write; in amdgpu_atombios_init()
1868 adev->mode_info.atom_context = amdgpu_atom_parse(atom_card_info, adev->bios); in amdgpu_atombios_init()
1869 if (!adev->mode_info.atom_context) { in amdgpu_atombios_init()
1871 return -ENOMEM; in amdgpu_atombios_init()
1874 mutex_init(&adev->mode_info.atom_context->mutex); in amdgpu_atombios_init()
1875 if (adev->is_atom_fw) { in amdgpu_atombios_init()
1879 adev->mode_info.firmware_flags = in amdgpu_atombios_init()
1898 if (!amdgpu_atom_parse_data_header(adev->mode_info.atom_context, table, in amdgpu_atombios_get_data_table()
1900 return -EINVAL; in amdgpu_atombios_get_data_table()
1902 *addr = (uint8_t *)adev->mode_info.atom_context->bios + data_start; in amdgpu_atombios_get_data_table()