1 /* 2 * Copyright 2012-15 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: AMD 23 * 24 */ 25 26 #include <linux/slab.h> 27 28 #include "dm_services.h" 29 30 #include "ObjectID.h" 31 #include "atomfirmware.h" 32 33 #include "dc_bios_types.h" 34 #include "include/grph_object_ctrl_defs.h" 35 #include "include/bios_parser_interface.h" 36 #include "include/i2caux_interface.h" 37 #include "include/logger_interface.h" 38 39 #include "command_table2.h" 40 41 #include "bios_parser_helper.h" 42 #include "command_table_helper2.h" 43 #include "bios_parser2.h" 44 #include "bios_parser_types_internal2.h" 45 #include "bios_parser_interface.h" 46 47 #include "bios_parser_common.h" 48 49 /* Temporarily add in defines until ObjectID.h patch is updated in a few days */ 50 #ifndef GENERIC_OBJECT_ID_BRACKET_LAYOUT 51 #define GENERIC_OBJECT_ID_BRACKET_LAYOUT 0x05 52 #endif /* GENERIC_OBJECT_ID_BRACKET_LAYOUT */ 53 54 #ifndef GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1 55 #define GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1 \ 56 (GRAPH_OBJECT_TYPE_GENERIC << OBJECT_TYPE_SHIFT |\ 57 GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ 58 GENERIC_OBJECT_ID_BRACKET_LAYOUT << OBJECT_ID_SHIFT) 59 #endif /* GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1 */ 60 61 #ifndef GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2 62 #define GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2 \ 63 (GRAPH_OBJECT_TYPE_GENERIC << OBJECT_TYPE_SHIFT |\ 64 GRAPH_OBJECT_ENUM_ID2 << ENUM_ID_SHIFT |\ 65 GENERIC_OBJECT_ID_BRACKET_LAYOUT << OBJECT_ID_SHIFT) 66 #endif /* GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2 */ 67 68 #define DC_LOGGER \ 69 bp->base.ctx->logger 70 71 #define LAST_RECORD_TYPE 0xff 72 #define SMU9_SYSPLL0_ID 0 73 74 struct i2c_id_config_access { 75 uint8_t bfI2C_LineMux:4; 76 uint8_t bfHW_EngineID:3; 77 uint8_t bfHW_Capable:1; 78 uint8_t ucAccess; 79 }; 80 81 static enum bp_result get_gpio_i2c_info(struct bios_parser *bp, 82 struct atom_i2c_record *record, 83 struct graphics_object_i2c_info *info); 84 85 static enum bp_result bios_parser_get_firmware_info( 86 struct dc_bios *dcb, 87 struct dc_firmware_info *info); 88 89 static enum bp_result bios_parser_get_encoder_cap_info( 90 struct dc_bios *dcb, 91 struct graphics_object_id object_id, 92 struct bp_encoder_cap_info *info); 93 94 static enum bp_result get_firmware_info_v3_1( 95 struct bios_parser *bp, 96 struct dc_firmware_info *info); 97 98 static enum bp_result get_firmware_info_v3_2( 99 struct bios_parser *bp, 100 struct dc_firmware_info *info); 101 102 static struct atom_hpd_int_record *get_hpd_record(struct bios_parser *bp, 103 struct atom_display_object_path_v2 *object); 104 105 static struct atom_encoder_caps_record *get_encoder_cap_record( 106 struct bios_parser *bp, 107 struct atom_display_object_path_v2 *object); 108 109 #define BIOS_IMAGE_SIZE_OFFSET 2 110 #define BIOS_IMAGE_SIZE_UNIT 512 111 112 #define DATA_TABLES(table) (bp->master_data_tbl->listOfdatatables.table) 113 114 static void bios_parser2_destruct(struct bios_parser *bp) 115 { 116 kfree(bp->base.bios_local_image); 117 kfree(bp->base.integrated_info); 118 } 119 120 static void firmware_parser_destroy(struct dc_bios **dcb) 121 { 122 struct bios_parser *bp = BP_FROM_DCB(*dcb); 123 124 if (!bp) { 125 BREAK_TO_DEBUGGER(); 126 return; 127 } 128 129 bios_parser2_destruct(bp); 130 131 kfree(bp); 132 *dcb = NULL; 133 } 134 135 static void get_atom_data_table_revision( 136 struct atom_common_table_header *atom_data_tbl, 137 struct atom_data_revision *tbl_revision) 138 { 139 if (!tbl_revision) 140 return; 141 142 /* initialize the revision to 0 which is invalid revision */ 143 tbl_revision->major = 0; 144 tbl_revision->minor = 0; 145 146 if (!atom_data_tbl) 147 return; 148 149 tbl_revision->major = 150 (uint32_t) atom_data_tbl->format_revision & 0x3f; 151 tbl_revision->minor = 152 (uint32_t) atom_data_tbl->content_revision & 0x3f; 153 } 154 155 /* BIOS oject table displaypath is per connector. 156 * There is extra path not for connector. BIOS fill its encoderid as 0 157 */ 158 static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb) 159 { 160 struct bios_parser *bp = BP_FROM_DCB(dcb); 161 unsigned int count = 0; 162 unsigned int i; 163 164 for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) { 165 if (bp->object_info_tbl.v1_4->display_path[i].encoderobjid != 0) 166 count++; 167 } 168 return count; 169 } 170 171 static struct graphics_object_id bios_parser_get_connector_id( 172 struct dc_bios *dcb, 173 uint8_t i) 174 { 175 struct bios_parser *bp = BP_FROM_DCB(dcb); 176 struct graphics_object_id object_id = dal_graphics_object_id_init( 177 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN); 178 struct object_info_table *tbl = &bp->object_info_tbl; 179 struct display_object_info_table_v1_4 *v1_4 = tbl->v1_4; 180 181 if (v1_4->number_of_path > i) { 182 /* If display_objid is generic object id, the encoderObj 183 * /extencoderobjId should be 0 184 */ 185 if (v1_4->display_path[i].encoderobjid != 0 && 186 v1_4->display_path[i].display_objid != 0) 187 object_id = object_id_from_bios_object_id( 188 v1_4->display_path[i].display_objid); 189 } 190 191 return object_id; 192 } 193 194 static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb, 195 struct graphics_object_id object_id, uint32_t index, 196 struct graphics_object_id *src_object_id) 197 { 198 struct bios_parser *bp = BP_FROM_DCB(dcb); 199 unsigned int i; 200 enum bp_result bp_result = BP_RESULT_BADINPUT; 201 struct graphics_object_id obj_id = {0}; 202 struct object_info_table *tbl = &bp->object_info_tbl; 203 204 if (!src_object_id) 205 return bp_result; 206 207 switch (object_id.type) { 208 /* Encoder's Source is GPU. BIOS does not provide GPU, since all 209 * displaypaths point to same GPU (0x1100). Hardcode GPU object type 210 */ 211 case OBJECT_TYPE_ENCODER: 212 /* TODO: since num of src must be less than 2. 213 * If found in for loop, should break. 214 * DAL2 implementation may be changed too 215 */ 216 for (i = 0; i < tbl->v1_4->number_of_path; i++) { 217 obj_id = object_id_from_bios_object_id( 218 tbl->v1_4->display_path[i].encoderobjid); 219 if (object_id.type == obj_id.type && 220 object_id.id == obj_id.id && 221 object_id.enum_id == 222 obj_id.enum_id) { 223 *src_object_id = 224 object_id_from_bios_object_id(0x1100); 225 /* break; */ 226 } 227 } 228 bp_result = BP_RESULT_OK; 229 break; 230 case OBJECT_TYPE_CONNECTOR: 231 for (i = 0; i < tbl->v1_4->number_of_path; i++) { 232 obj_id = object_id_from_bios_object_id( 233 tbl->v1_4->display_path[i].display_objid); 234 235 if (object_id.type == obj_id.type && 236 object_id.id == obj_id.id && 237 object_id.enum_id == obj_id.enum_id) { 238 *src_object_id = 239 object_id_from_bios_object_id( 240 tbl->v1_4->display_path[i].encoderobjid); 241 /* break; */ 242 } 243 } 244 bp_result = BP_RESULT_OK; 245 break; 246 default: 247 break; 248 } 249 250 return bp_result; 251 } 252 253 /* from graphics_object_id, find display path which includes the object_id */ 254 static struct atom_display_object_path_v2 *get_bios_object( 255 struct bios_parser *bp, 256 struct graphics_object_id id) 257 { 258 unsigned int i; 259 struct graphics_object_id obj_id = {0}; 260 261 switch (id.type) { 262 case OBJECT_TYPE_ENCODER: 263 for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) { 264 obj_id = object_id_from_bios_object_id( 265 bp->object_info_tbl.v1_4->display_path[i].encoderobjid); 266 if (id.type == obj_id.type && id.id == obj_id.id 267 && id.enum_id == obj_id.enum_id) 268 return &bp->object_info_tbl.v1_4->display_path[i]; 269 } 270 fallthrough; 271 case OBJECT_TYPE_CONNECTOR: 272 case OBJECT_TYPE_GENERIC: 273 /* Both Generic and Connector Object ID 274 * will be stored on display_objid 275 */ 276 for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) { 277 obj_id = object_id_from_bios_object_id( 278 bp->object_info_tbl.v1_4->display_path[i].display_objid); 279 if (id.type == obj_id.type && id.id == obj_id.id 280 && id.enum_id == obj_id.enum_id) 281 return &bp->object_info_tbl.v1_4->display_path[i]; 282 } 283 fallthrough; 284 default: 285 return NULL; 286 } 287 } 288 289 static enum bp_result bios_parser_get_i2c_info(struct dc_bios *dcb, 290 struct graphics_object_id id, 291 struct graphics_object_i2c_info *info) 292 { 293 uint32_t offset; 294 struct atom_display_object_path_v2 *object; 295 struct atom_common_record_header *header; 296 struct atom_i2c_record *record; 297 struct atom_i2c_record dummy_record = {0}; 298 struct bios_parser *bp = BP_FROM_DCB(dcb); 299 300 if (!info) 301 return BP_RESULT_BADINPUT; 302 303 if (id.type == OBJECT_TYPE_GENERIC) { 304 dummy_record.i2c_id = id.id; 305 306 if (get_gpio_i2c_info(bp, &dummy_record, info) == BP_RESULT_OK) 307 return BP_RESULT_OK; 308 else 309 return BP_RESULT_NORECORD; 310 } 311 312 object = get_bios_object(bp, id); 313 314 if (!object) 315 return BP_RESULT_BADINPUT; 316 317 offset = object->disp_recordoffset + bp->object_info_tbl_offset; 318 319 for (;;) { 320 header = GET_IMAGE(struct atom_common_record_header, offset); 321 322 if (!header) 323 return BP_RESULT_BADBIOSTABLE; 324 325 if (header->record_type == LAST_RECORD_TYPE || 326 !header->record_size) 327 break; 328 329 if (header->record_type == ATOM_I2C_RECORD_TYPE 330 && sizeof(struct atom_i2c_record) <= 331 header->record_size) { 332 /* get the I2C info */ 333 record = (struct atom_i2c_record *) header; 334 335 if (get_gpio_i2c_info(bp, record, info) == 336 BP_RESULT_OK) 337 return BP_RESULT_OK; 338 } 339 340 offset += header->record_size; 341 } 342 343 return BP_RESULT_NORECORD; 344 } 345 346 static enum bp_result get_gpio_i2c_info( 347 struct bios_parser *bp, 348 struct atom_i2c_record *record, 349 struct graphics_object_i2c_info *info) 350 { 351 struct atom_gpio_pin_lut_v2_1 *header; 352 uint32_t count = 0; 353 unsigned int table_index = 0; 354 bool find_valid = false; 355 356 if (!info) 357 return BP_RESULT_BADINPUT; 358 359 /* get the GPIO_I2C info */ 360 if (!DATA_TABLES(gpio_pin_lut)) 361 return BP_RESULT_BADBIOSTABLE; 362 363 header = GET_IMAGE(struct atom_gpio_pin_lut_v2_1, 364 DATA_TABLES(gpio_pin_lut)); 365 if (!header) 366 return BP_RESULT_BADBIOSTABLE; 367 368 if (sizeof(struct atom_common_table_header) + 369 sizeof(struct atom_gpio_pin_assignment) > 370 le16_to_cpu(header->table_header.structuresize)) 371 return BP_RESULT_BADBIOSTABLE; 372 373 /* TODO: is version change? */ 374 if (header->table_header.content_revision != 1) 375 return BP_RESULT_UNSUPPORTED; 376 377 /* get data count */ 378 count = (le16_to_cpu(header->table_header.structuresize) 379 - sizeof(struct atom_common_table_header)) 380 / sizeof(struct atom_gpio_pin_assignment); 381 382 for (table_index = 0; table_index < count; table_index++) { 383 if (((record->i2c_id & I2C_HW_CAP) == ( 384 header->gpio_pin[table_index].gpio_id & 385 I2C_HW_CAP)) && 386 ((record->i2c_id & I2C_HW_ENGINE_ID_MASK) == 387 (header->gpio_pin[table_index].gpio_id & 388 I2C_HW_ENGINE_ID_MASK)) && 389 ((record->i2c_id & I2C_HW_LANE_MUX) == 390 (header->gpio_pin[table_index].gpio_id & 391 I2C_HW_LANE_MUX))) { 392 /* still valid */ 393 find_valid = true; 394 break; 395 } 396 } 397 398 /* If we don't find the entry that we are looking for then 399 * we will return BP_Result_BadBiosTable. 400 */ 401 if (find_valid == false) 402 return BP_RESULT_BADBIOSTABLE; 403 404 /* get the GPIO_I2C_INFO */ 405 info->i2c_hw_assist = (record->i2c_id & I2C_HW_CAP) ? true : false; 406 info->i2c_line = record->i2c_id & I2C_HW_LANE_MUX; 407 info->i2c_engine_id = (record->i2c_id & I2C_HW_ENGINE_ID_MASK) >> 4; 408 info->i2c_slave_address = record->i2c_slave_addr; 409 410 /* TODO: check how to get register offset for en, Y, etc. */ 411 info->gpio_info.clk_a_register_index = 412 le16_to_cpu( 413 header->gpio_pin[table_index].data_a_reg_index); 414 info->gpio_info.clk_a_shift = 415 header->gpio_pin[table_index].gpio_bitshift; 416 417 return BP_RESULT_OK; 418 } 419 420 static enum bp_result bios_parser_get_hpd_info( 421 struct dc_bios *dcb, 422 struct graphics_object_id id, 423 struct graphics_object_hpd_info *info) 424 { 425 struct bios_parser *bp = BP_FROM_DCB(dcb); 426 struct atom_display_object_path_v2 *object; 427 struct atom_hpd_int_record *record = NULL; 428 429 if (!info) 430 return BP_RESULT_BADINPUT; 431 432 object = get_bios_object(bp, id); 433 434 if (!object) 435 return BP_RESULT_BADINPUT; 436 437 record = get_hpd_record(bp, object); 438 439 if (record != NULL) { 440 info->hpd_int_gpio_uid = record->pin_id; 441 info->hpd_active = record->plugin_pin_state; 442 return BP_RESULT_OK; 443 } 444 445 return BP_RESULT_NORECORD; 446 } 447 448 static struct atom_hpd_int_record *get_hpd_record( 449 struct bios_parser *bp, 450 struct atom_display_object_path_v2 *object) 451 { 452 struct atom_common_record_header *header; 453 uint32_t offset; 454 455 if (!object) { 456 BREAK_TO_DEBUGGER(); /* Invalid object */ 457 return NULL; 458 } 459 460 offset = le16_to_cpu(object->disp_recordoffset) 461 + bp->object_info_tbl_offset; 462 463 for (;;) { 464 header = GET_IMAGE(struct atom_common_record_header, offset); 465 466 if (!header) 467 return NULL; 468 469 if (header->record_type == LAST_RECORD_TYPE || 470 !header->record_size) 471 break; 472 473 if (header->record_type == ATOM_HPD_INT_RECORD_TYPE 474 && sizeof(struct atom_hpd_int_record) <= 475 header->record_size) 476 return (struct atom_hpd_int_record *) header; 477 478 offset += header->record_size; 479 } 480 481 return NULL; 482 } 483 484 /** 485 * bios_parser_get_gpio_pin_info 486 * Get GpioPin information of input gpio id 487 * 488 * @dcb: pointer to the DC BIOS 489 * @gpio_id: GPIO ID 490 * @info: GpioPin information structure 491 * return: Bios parser result code 492 * note: 493 * to get the GPIO PIN INFO, we need: 494 * 1. get the GPIO_ID from other object table, see GetHPDInfo() 495 * 2. in DATA_TABLE.GPIO_Pin_LUT, search all records, 496 * to get the registerA offset/mask 497 */ 498 static enum bp_result bios_parser_get_gpio_pin_info( 499 struct dc_bios *dcb, 500 uint32_t gpio_id, 501 struct gpio_pin_info *info) 502 { 503 struct bios_parser *bp = BP_FROM_DCB(dcb); 504 struct atom_gpio_pin_lut_v2_1 *header; 505 uint32_t count = 0; 506 uint32_t i = 0; 507 508 if (!DATA_TABLES(gpio_pin_lut)) 509 return BP_RESULT_BADBIOSTABLE; 510 511 header = GET_IMAGE(struct atom_gpio_pin_lut_v2_1, 512 DATA_TABLES(gpio_pin_lut)); 513 if (!header) 514 return BP_RESULT_BADBIOSTABLE; 515 516 if (sizeof(struct atom_common_table_header) + 517 sizeof(struct atom_gpio_pin_assignment) 518 > le16_to_cpu(header->table_header.structuresize)) 519 return BP_RESULT_BADBIOSTABLE; 520 521 if (header->table_header.content_revision != 1) 522 return BP_RESULT_UNSUPPORTED; 523 524 /* Temporary hard code gpio pin info */ 525 #if defined(FOR_SIMNOW_BOOT) 526 { 527 struct atom_gpio_pin_assignment gpio_pin[8] = { 528 {0x5db5, 0, 0, 1, 0}, 529 {0x5db5, 8, 8, 2, 0}, 530 {0x5db5, 0x10, 0x10, 3, 0}, 531 {0x5db5, 0x18, 0x14, 4, 0}, 532 {0x5db5, 0x1A, 0x18, 5, 0}, 533 {0x5db5, 0x1C, 0x1C, 6, 0}, 534 }; 535 536 count = 6; 537 memmove(header->gpio_pin, gpio_pin, sizeof(gpio_pin)); 538 } 539 #else 540 count = (le16_to_cpu(header->table_header.structuresize) 541 - sizeof(struct atom_common_table_header)) 542 / sizeof(struct atom_gpio_pin_assignment); 543 #endif 544 for (i = 0; i < count; ++i) { 545 if (header->gpio_pin[i].gpio_id != gpio_id) 546 continue; 547 548 info->offset = 549 (uint32_t) le16_to_cpu( 550 header->gpio_pin[i].data_a_reg_index); 551 info->offset_y = info->offset + 2; 552 info->offset_en = info->offset + 1; 553 info->offset_mask = info->offset - 1; 554 555 info->mask = (uint32_t) (1 << 556 header->gpio_pin[i].gpio_bitshift); 557 info->mask_y = info->mask + 2; 558 info->mask_en = info->mask + 1; 559 info->mask_mask = info->mask - 1; 560 561 return BP_RESULT_OK; 562 } 563 564 return BP_RESULT_NORECORD; 565 } 566 567 static struct device_id device_type_from_device_id(uint16_t device_id) 568 { 569 570 struct device_id result_device_id; 571 572 result_device_id.raw_device_tag = device_id; 573 574 switch (device_id) { 575 case ATOM_DISPLAY_LCD1_SUPPORT: 576 result_device_id.device_type = DEVICE_TYPE_LCD; 577 result_device_id.enum_id = 1; 578 break; 579 580 case ATOM_DISPLAY_LCD2_SUPPORT: 581 result_device_id.device_type = DEVICE_TYPE_LCD; 582 result_device_id.enum_id = 2; 583 break; 584 585 case ATOM_DISPLAY_DFP1_SUPPORT: 586 result_device_id.device_type = DEVICE_TYPE_DFP; 587 result_device_id.enum_id = 1; 588 break; 589 590 case ATOM_DISPLAY_DFP2_SUPPORT: 591 result_device_id.device_type = DEVICE_TYPE_DFP; 592 result_device_id.enum_id = 2; 593 break; 594 595 case ATOM_DISPLAY_DFP3_SUPPORT: 596 result_device_id.device_type = DEVICE_TYPE_DFP; 597 result_device_id.enum_id = 3; 598 break; 599 600 case ATOM_DISPLAY_DFP4_SUPPORT: 601 result_device_id.device_type = DEVICE_TYPE_DFP; 602 result_device_id.enum_id = 4; 603 break; 604 605 case ATOM_DISPLAY_DFP5_SUPPORT: 606 result_device_id.device_type = DEVICE_TYPE_DFP; 607 result_device_id.enum_id = 5; 608 break; 609 610 case ATOM_DISPLAY_DFP6_SUPPORT: 611 result_device_id.device_type = DEVICE_TYPE_DFP; 612 result_device_id.enum_id = 6; 613 break; 614 615 default: 616 BREAK_TO_DEBUGGER(); /* Invalid device Id */ 617 result_device_id.device_type = DEVICE_TYPE_UNKNOWN; 618 result_device_id.enum_id = 0; 619 } 620 return result_device_id; 621 } 622 623 static enum bp_result bios_parser_get_device_tag( 624 struct dc_bios *dcb, 625 struct graphics_object_id connector_object_id, 626 uint32_t device_tag_index, 627 struct connector_device_tag_info *info) 628 { 629 struct bios_parser *bp = BP_FROM_DCB(dcb); 630 struct atom_display_object_path_v2 *object; 631 632 if (!info) 633 return BP_RESULT_BADINPUT; 634 635 /* getBiosObject will return MXM object */ 636 object = get_bios_object(bp, connector_object_id); 637 638 if (!object) { 639 BREAK_TO_DEBUGGER(); /* Invalid object id */ 640 return BP_RESULT_BADINPUT; 641 } 642 643 info->acpi_device = 0; /* BIOS no longer provides this */ 644 info->dev_id = device_type_from_device_id(object->device_tag); 645 646 return BP_RESULT_OK; 647 } 648 649 static enum bp_result get_ss_info_v4_1( 650 struct bios_parser *bp, 651 uint32_t id, 652 uint32_t index, 653 struct spread_spectrum_info *ss_info) 654 { 655 enum bp_result result = BP_RESULT_OK; 656 struct atom_display_controller_info_v4_1 *disp_cntl_tbl = NULL; 657 struct atom_smu_info_v3_3 *smu_info = NULL; 658 659 if (!ss_info) 660 return BP_RESULT_BADINPUT; 661 662 if (!DATA_TABLES(dce_info)) 663 return BP_RESULT_BADBIOSTABLE; 664 665 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_1, 666 DATA_TABLES(dce_info)); 667 if (!disp_cntl_tbl) 668 return BP_RESULT_BADBIOSTABLE; 669 670 671 ss_info->type.STEP_AND_DELAY_INFO = false; 672 ss_info->spread_percentage_divider = 1000; 673 /* BIOS no longer uses target clock. Always enable for now */ 674 ss_info->target_clock_range = 0xffffffff; 675 676 switch (id) { 677 case AS_SIGNAL_TYPE_DVI: 678 ss_info->spread_spectrum_percentage = 679 disp_cntl_tbl->dvi_ss_percentage; 680 ss_info->spread_spectrum_range = 681 disp_cntl_tbl->dvi_ss_rate_10hz * 10; 682 if (disp_cntl_tbl->dvi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 683 ss_info->type.CENTER_MODE = true; 684 break; 685 case AS_SIGNAL_TYPE_HDMI: 686 ss_info->spread_spectrum_percentage = 687 disp_cntl_tbl->hdmi_ss_percentage; 688 ss_info->spread_spectrum_range = 689 disp_cntl_tbl->hdmi_ss_rate_10hz * 10; 690 if (disp_cntl_tbl->hdmi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 691 ss_info->type.CENTER_MODE = true; 692 break; 693 /* TODO LVDS not support anymore? */ 694 case AS_SIGNAL_TYPE_DISPLAY_PORT: 695 ss_info->spread_spectrum_percentage = 696 disp_cntl_tbl->dp_ss_percentage; 697 ss_info->spread_spectrum_range = 698 disp_cntl_tbl->dp_ss_rate_10hz * 10; 699 if (disp_cntl_tbl->dp_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 700 ss_info->type.CENTER_MODE = true; 701 break; 702 case AS_SIGNAL_TYPE_GPU_PLL: 703 /* atom_firmware: DAL only get data from dce_info table. 704 * if data within smu_info is needed for DAL, VBIOS should 705 * copy it into dce_info 706 */ 707 result = BP_RESULT_UNSUPPORTED; 708 break; 709 case AS_SIGNAL_TYPE_XGMI: 710 smu_info = GET_IMAGE(struct atom_smu_info_v3_3, 711 DATA_TABLES(smu_info)); 712 if (!smu_info) 713 return BP_RESULT_BADBIOSTABLE; 714 715 ss_info->spread_spectrum_percentage = 716 smu_info->waflclk_ss_percentage; 717 ss_info->spread_spectrum_range = 718 smu_info->gpuclk_ss_rate_10hz * 10; 719 if (smu_info->waflclk_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 720 ss_info->type.CENTER_MODE = true; 721 break; 722 default: 723 result = BP_RESULT_UNSUPPORTED; 724 } 725 726 return result; 727 } 728 729 static enum bp_result get_ss_info_v4_2( 730 struct bios_parser *bp, 731 uint32_t id, 732 uint32_t index, 733 struct spread_spectrum_info *ss_info) 734 { 735 enum bp_result result = BP_RESULT_OK; 736 struct atom_display_controller_info_v4_2 *disp_cntl_tbl = NULL; 737 struct atom_smu_info_v3_1 *smu_info = NULL; 738 739 if (!ss_info) 740 return BP_RESULT_BADINPUT; 741 742 if (!DATA_TABLES(dce_info)) 743 return BP_RESULT_BADBIOSTABLE; 744 745 if (!DATA_TABLES(smu_info)) 746 return BP_RESULT_BADBIOSTABLE; 747 748 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_2, 749 DATA_TABLES(dce_info)); 750 if (!disp_cntl_tbl) 751 return BP_RESULT_BADBIOSTABLE; 752 753 smu_info = GET_IMAGE(struct atom_smu_info_v3_1, DATA_TABLES(smu_info)); 754 if (!smu_info) 755 return BP_RESULT_BADBIOSTABLE; 756 757 ss_info->type.STEP_AND_DELAY_INFO = false; 758 ss_info->spread_percentage_divider = 1000; 759 /* BIOS no longer uses target clock. Always enable for now */ 760 ss_info->target_clock_range = 0xffffffff; 761 762 switch (id) { 763 case AS_SIGNAL_TYPE_DVI: 764 ss_info->spread_spectrum_percentage = 765 disp_cntl_tbl->dvi_ss_percentage; 766 ss_info->spread_spectrum_range = 767 disp_cntl_tbl->dvi_ss_rate_10hz * 10; 768 if (disp_cntl_tbl->dvi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 769 ss_info->type.CENTER_MODE = true; 770 break; 771 case AS_SIGNAL_TYPE_HDMI: 772 ss_info->spread_spectrum_percentage = 773 disp_cntl_tbl->hdmi_ss_percentage; 774 ss_info->spread_spectrum_range = 775 disp_cntl_tbl->hdmi_ss_rate_10hz * 10; 776 if (disp_cntl_tbl->hdmi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 777 ss_info->type.CENTER_MODE = true; 778 break; 779 /* TODO LVDS not support anymore? */ 780 case AS_SIGNAL_TYPE_DISPLAY_PORT: 781 ss_info->spread_spectrum_percentage = 782 smu_info->gpuclk_ss_percentage; 783 ss_info->spread_spectrum_range = 784 smu_info->gpuclk_ss_rate_10hz * 10; 785 if (smu_info->gpuclk_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE) 786 ss_info->type.CENTER_MODE = true; 787 break; 788 case AS_SIGNAL_TYPE_GPU_PLL: 789 /* atom_firmware: DAL only get data from dce_info table. 790 * if data within smu_info is needed for DAL, VBIOS should 791 * copy it into dce_info 792 */ 793 result = BP_RESULT_UNSUPPORTED; 794 break; 795 default: 796 result = BP_RESULT_UNSUPPORTED; 797 } 798 799 return result; 800 } 801 802 /** 803 * bios_parser_get_spread_spectrum_info 804 * Get spread spectrum information from the ASIC_InternalSS_Info(ver 2.1 or 805 * ver 3.1) or SS_Info table from the VBIOS. Currently ASIC_InternalSS_Info 806 * ver 2.1 can co-exist with SS_Info table. Expect ASIC_InternalSS_Info 807 * ver 3.1, 808 * there is only one entry for each signal /ss id. However, there is 809 * no planning of supporting multiple spread Sprectum entry for EverGreen 810 * @dcb: pointer to the DC BIOS 811 * @signal: ASSignalType to be converted to info index 812 * @index: number of entries that match the converted info index 813 * @ss_info: sprectrum information structure, 814 * return: Bios parser result code 815 */ 816 static enum bp_result bios_parser_get_spread_spectrum_info( 817 struct dc_bios *dcb, 818 enum as_signal_type signal, 819 uint32_t index, 820 struct spread_spectrum_info *ss_info) 821 { 822 struct bios_parser *bp = BP_FROM_DCB(dcb); 823 enum bp_result result = BP_RESULT_UNSUPPORTED; 824 struct atom_common_table_header *header; 825 struct atom_data_revision tbl_revision; 826 827 if (!ss_info) /* check for bad input */ 828 return BP_RESULT_BADINPUT; 829 830 if (!DATA_TABLES(dce_info)) 831 return BP_RESULT_UNSUPPORTED; 832 833 header = GET_IMAGE(struct atom_common_table_header, 834 DATA_TABLES(dce_info)); 835 get_atom_data_table_revision(header, &tbl_revision); 836 837 switch (tbl_revision.major) { 838 case 4: 839 switch (tbl_revision.minor) { 840 case 1: 841 return get_ss_info_v4_1(bp, signal, index, ss_info); 842 case 2: 843 case 3: 844 case 4: 845 return get_ss_info_v4_2(bp, signal, index, ss_info); 846 default: 847 ASSERT(0); 848 break; 849 } 850 break; 851 default: 852 break; 853 } 854 /* there can not be more then one entry for SS Info table */ 855 return result; 856 } 857 858 static enum bp_result get_soc_bb_info_v4_4( 859 struct bios_parser *bp, 860 struct bp_soc_bb_info *soc_bb_info) 861 { 862 enum bp_result result = BP_RESULT_OK; 863 struct atom_display_controller_info_v4_4 *disp_cntl_tbl = NULL; 864 865 if (!soc_bb_info) 866 return BP_RESULT_BADINPUT; 867 868 if (!DATA_TABLES(dce_info)) 869 return BP_RESULT_BADBIOSTABLE; 870 871 if (!DATA_TABLES(smu_info)) 872 return BP_RESULT_BADBIOSTABLE; 873 874 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_4, 875 DATA_TABLES(dce_info)); 876 if (!disp_cntl_tbl) 877 return BP_RESULT_BADBIOSTABLE; 878 879 soc_bb_info->dram_clock_change_latency_100ns = disp_cntl_tbl->max_mclk_chg_lat; 880 soc_bb_info->dram_sr_enter_exit_latency_100ns = disp_cntl_tbl->max_sr_enter_exit_lat; 881 soc_bb_info->dram_sr_exit_latency_100ns = disp_cntl_tbl->max_sr_exit_lat; 882 883 return result; 884 } 885 886 static enum bp_result bios_parser_get_soc_bb_info( 887 struct dc_bios *dcb, 888 struct bp_soc_bb_info *soc_bb_info) 889 { 890 struct bios_parser *bp = BP_FROM_DCB(dcb); 891 enum bp_result result = BP_RESULT_UNSUPPORTED; 892 struct atom_common_table_header *header; 893 struct atom_data_revision tbl_revision; 894 895 if (!soc_bb_info) /* check for bad input */ 896 return BP_RESULT_BADINPUT; 897 898 if (!DATA_TABLES(dce_info)) 899 return BP_RESULT_UNSUPPORTED; 900 901 header = GET_IMAGE(struct atom_common_table_header, 902 DATA_TABLES(dce_info)); 903 get_atom_data_table_revision(header, &tbl_revision); 904 905 switch (tbl_revision.major) { 906 case 4: 907 switch (tbl_revision.minor) { 908 case 1: 909 case 2: 910 case 3: 911 break; 912 case 4: 913 result = get_soc_bb_info_v4_4(bp, soc_bb_info); 914 break; 915 default: 916 break; 917 } 918 break; 919 default: 920 break; 921 } 922 923 return result; 924 } 925 926 static enum bp_result get_disp_caps_v4_1( 927 struct bios_parser *bp, 928 uint8_t *dce_caps) 929 { 930 enum bp_result result = BP_RESULT_OK; 931 struct atom_display_controller_info_v4_1 *disp_cntl_tbl = NULL; 932 933 if (!dce_caps) 934 return BP_RESULT_BADINPUT; 935 936 if (!DATA_TABLES(dce_info)) 937 return BP_RESULT_BADBIOSTABLE; 938 939 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_1, 940 DATA_TABLES(dce_info)); 941 942 if (!disp_cntl_tbl) 943 return BP_RESULT_BADBIOSTABLE; 944 945 *dce_caps = disp_cntl_tbl->display_caps; 946 947 return result; 948 } 949 950 static enum bp_result get_disp_caps_v4_2( 951 struct bios_parser *bp, 952 uint8_t *dce_caps) 953 { 954 enum bp_result result = BP_RESULT_OK; 955 struct atom_display_controller_info_v4_2 *disp_cntl_tbl = NULL; 956 957 if (!dce_caps) 958 return BP_RESULT_BADINPUT; 959 960 if (!DATA_TABLES(dce_info)) 961 return BP_RESULT_BADBIOSTABLE; 962 963 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_2, 964 DATA_TABLES(dce_info)); 965 966 if (!disp_cntl_tbl) 967 return BP_RESULT_BADBIOSTABLE; 968 969 *dce_caps = disp_cntl_tbl->display_caps; 970 971 return result; 972 } 973 974 static enum bp_result get_disp_caps_v4_3( 975 struct bios_parser *bp, 976 uint8_t *dce_caps) 977 { 978 enum bp_result result = BP_RESULT_OK; 979 struct atom_display_controller_info_v4_3 *disp_cntl_tbl = NULL; 980 981 if (!dce_caps) 982 return BP_RESULT_BADINPUT; 983 984 if (!DATA_TABLES(dce_info)) 985 return BP_RESULT_BADBIOSTABLE; 986 987 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_3, 988 DATA_TABLES(dce_info)); 989 990 if (!disp_cntl_tbl) 991 return BP_RESULT_BADBIOSTABLE; 992 993 *dce_caps = disp_cntl_tbl->display_caps; 994 995 return result; 996 } 997 998 static enum bp_result get_disp_caps_v4_4( 999 struct bios_parser *bp, 1000 uint8_t *dce_caps) 1001 { 1002 enum bp_result result = BP_RESULT_OK; 1003 struct atom_display_controller_info_v4_4 *disp_cntl_tbl = NULL; 1004 1005 if (!dce_caps) 1006 return BP_RESULT_BADINPUT; 1007 1008 if (!DATA_TABLES(dce_info)) 1009 return BP_RESULT_BADBIOSTABLE; 1010 1011 disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_4, 1012 DATA_TABLES(dce_info)); 1013 1014 if (!disp_cntl_tbl) 1015 return BP_RESULT_BADBIOSTABLE; 1016 1017 *dce_caps = disp_cntl_tbl->display_caps; 1018 1019 return result; 1020 } 1021 1022 static enum bp_result bios_parser_get_lttpr_interop( 1023 struct dc_bios *dcb, 1024 uint8_t *dce_caps) 1025 { 1026 struct bios_parser *bp = BP_FROM_DCB(dcb); 1027 enum bp_result result = BP_RESULT_UNSUPPORTED; 1028 struct atom_common_table_header *header; 1029 struct atom_data_revision tbl_revision; 1030 1031 if (!DATA_TABLES(dce_info)) 1032 return BP_RESULT_UNSUPPORTED; 1033 1034 header = GET_IMAGE(struct atom_common_table_header, 1035 DATA_TABLES(dce_info)); 1036 get_atom_data_table_revision(header, &tbl_revision); 1037 switch (tbl_revision.major) { 1038 case 4: 1039 switch (tbl_revision.minor) { 1040 case 1: 1041 result = get_disp_caps_v4_1(bp, dce_caps); 1042 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_VBIOS_LTTPR_TRANSPARENT_ENABLE); 1043 break; 1044 case 2: 1045 result = get_disp_caps_v4_2(bp, dce_caps); 1046 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_VBIOS_LTTPR_TRANSPARENT_ENABLE); 1047 break; 1048 case 3: 1049 result = get_disp_caps_v4_3(bp, dce_caps); 1050 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_VBIOS_LTTPR_TRANSPARENT_ENABLE); 1051 break; 1052 case 4: 1053 result = get_disp_caps_v4_4(bp, dce_caps); 1054 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_VBIOS_LTTPR_TRANSPARENT_ENABLE); 1055 break; 1056 default: 1057 break; 1058 } 1059 break; 1060 default: 1061 break; 1062 } 1063 1064 return result; 1065 } 1066 1067 static enum bp_result bios_parser_get_lttpr_caps( 1068 struct dc_bios *dcb, 1069 uint8_t *dce_caps) 1070 { 1071 struct bios_parser *bp = BP_FROM_DCB(dcb); 1072 enum bp_result result = BP_RESULT_UNSUPPORTED; 1073 struct atom_common_table_header *header; 1074 struct atom_data_revision tbl_revision; 1075 1076 if (!DATA_TABLES(dce_info)) 1077 return BP_RESULT_UNSUPPORTED; 1078 1079 header = GET_IMAGE(struct atom_common_table_header, 1080 DATA_TABLES(dce_info)); 1081 get_atom_data_table_revision(header, &tbl_revision); 1082 switch (tbl_revision.major) { 1083 case 4: 1084 switch (tbl_revision.minor) { 1085 case 1: 1086 result = get_disp_caps_v4_1(bp, dce_caps); 1087 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_LTTPR_SUPPORT_ENABLE); 1088 break; 1089 case 2: 1090 result = get_disp_caps_v4_2(bp, dce_caps); 1091 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_LTTPR_SUPPORT_ENABLE); 1092 break; 1093 case 3: 1094 result = get_disp_caps_v4_3(bp, dce_caps); 1095 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_LTTPR_SUPPORT_ENABLE); 1096 break; 1097 case 4: 1098 result = get_disp_caps_v4_4(bp, dce_caps); 1099 *dce_caps = !!(*dce_caps & DCE_INFO_CAPS_LTTPR_SUPPORT_ENABLE); 1100 break; 1101 default: 1102 break; 1103 } 1104 break; 1105 default: 1106 break; 1107 } 1108 1109 return result; 1110 } 1111 1112 static enum bp_result get_embedded_panel_info_v2_1( 1113 struct bios_parser *bp, 1114 struct embedded_panel_info *info) 1115 { 1116 struct lcd_info_v2_1 *lvds; 1117 1118 if (!info) 1119 return BP_RESULT_BADINPUT; 1120 1121 if (!DATA_TABLES(lcd_info)) 1122 return BP_RESULT_UNSUPPORTED; 1123 1124 lvds = GET_IMAGE(struct lcd_info_v2_1, DATA_TABLES(lcd_info)); 1125 1126 if (!lvds) 1127 return BP_RESULT_BADBIOSTABLE; 1128 1129 /* TODO: previous vv1_3, should v2_1 */ 1130 if (!((lvds->table_header.format_revision == 2) 1131 && (lvds->table_header.content_revision >= 1))) 1132 return BP_RESULT_UNSUPPORTED; 1133 1134 memset(info, 0, sizeof(struct embedded_panel_info)); 1135 1136 /* We need to convert from 10KHz units into KHz units */ 1137 info->lcd_timing.pixel_clk = le16_to_cpu(lvds->lcd_timing.pixclk) * 10; 1138 /* usHActive does not include borders, according to VBIOS team */ 1139 info->lcd_timing.horizontal_addressable = le16_to_cpu(lvds->lcd_timing.h_active); 1140 /* usHBlanking_Time includes borders, so we should really be 1141 * subtractingborders duing this translation, but LVDS generally 1142 * doesn't have borders, so we should be okay leaving this as is for 1143 * now. May need to revisit if we ever have LVDS with borders 1144 */ 1145 info->lcd_timing.horizontal_blanking_time = le16_to_cpu(lvds->lcd_timing.h_blanking_time); 1146 /* usVActive does not include borders, according to VBIOS team*/ 1147 info->lcd_timing.vertical_addressable = le16_to_cpu(lvds->lcd_timing.v_active); 1148 /* usVBlanking_Time includes borders, so we should really be 1149 * subtracting borders duing this translation, but LVDS generally 1150 * doesn't have borders, so we should be okay leaving this as is for 1151 * now. May need to revisit if we ever have LVDS with borders 1152 */ 1153 info->lcd_timing.vertical_blanking_time = le16_to_cpu(lvds->lcd_timing.v_blanking_time); 1154 info->lcd_timing.horizontal_sync_offset = le16_to_cpu(lvds->lcd_timing.h_sync_offset); 1155 info->lcd_timing.horizontal_sync_width = le16_to_cpu(lvds->lcd_timing.h_sync_width); 1156 info->lcd_timing.vertical_sync_offset = le16_to_cpu(lvds->lcd_timing.v_sync_offset); 1157 info->lcd_timing.vertical_sync_width = le16_to_cpu(lvds->lcd_timing.v_syncwidth); 1158 info->lcd_timing.horizontal_border = lvds->lcd_timing.h_border; 1159 info->lcd_timing.vertical_border = lvds->lcd_timing.v_border; 1160 1161 /* not provided by VBIOS */ 1162 info->lcd_timing.misc_info.HORIZONTAL_CUT_OFF = 0; 1163 1164 info->lcd_timing.misc_info.H_SYNC_POLARITY = ~(uint32_t) (lvds->lcd_timing.miscinfo 1165 & ATOM_HSYNC_POLARITY); 1166 info->lcd_timing.misc_info.V_SYNC_POLARITY = ~(uint32_t) (lvds->lcd_timing.miscinfo 1167 & ATOM_VSYNC_POLARITY); 1168 1169 /* not provided by VBIOS */ 1170 info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0; 1171 1172 info->lcd_timing.misc_info.H_REPLICATION_BY2 = !!(lvds->lcd_timing.miscinfo 1173 & ATOM_H_REPLICATIONBY2); 1174 info->lcd_timing.misc_info.V_REPLICATION_BY2 = !!(lvds->lcd_timing.miscinfo 1175 & ATOM_V_REPLICATIONBY2); 1176 info->lcd_timing.misc_info.COMPOSITE_SYNC = !!(lvds->lcd_timing.miscinfo 1177 & ATOM_COMPOSITESYNC); 1178 info->lcd_timing.misc_info.INTERLACE = !!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE); 1179 1180 /* not provided by VBIOS*/ 1181 info->lcd_timing.misc_info.DOUBLE_CLOCK = 0; 1182 /* not provided by VBIOS*/ 1183 info->ss_id = 0; 1184 1185 info->realtek_eDPToLVDS = !!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID); 1186 1187 return BP_RESULT_OK; 1188 } 1189 1190 static enum bp_result bios_parser_get_embedded_panel_info( 1191 struct dc_bios *dcb, 1192 struct embedded_panel_info *info) 1193 { 1194 struct bios_parser 1195 *bp = BP_FROM_DCB(dcb); 1196 struct atom_common_table_header *header; 1197 struct atom_data_revision tbl_revision; 1198 1199 if (!DATA_TABLES(lcd_info)) 1200 return BP_RESULT_FAILURE; 1201 1202 header = GET_IMAGE(struct atom_common_table_header, DATA_TABLES(lcd_info)); 1203 1204 if (!header) 1205 return BP_RESULT_BADBIOSTABLE; 1206 1207 get_atom_data_table_revision(header, &tbl_revision); 1208 1209 switch (tbl_revision.major) { 1210 case 2: 1211 switch (tbl_revision.minor) { 1212 case 1: 1213 return get_embedded_panel_info_v2_1(bp, info); 1214 default: 1215 break; 1216 } 1217 break; 1218 default: 1219 break; 1220 } 1221 1222 return BP_RESULT_FAILURE; 1223 } 1224 1225 static uint32_t get_support_mask_for_device_id(struct device_id device_id) 1226 { 1227 enum dal_device_type device_type = device_id.device_type; 1228 uint32_t enum_id = device_id.enum_id; 1229 1230 switch (device_type) { 1231 case DEVICE_TYPE_LCD: 1232 switch (enum_id) { 1233 case 1: 1234 return ATOM_DISPLAY_LCD1_SUPPORT; 1235 default: 1236 break; 1237 } 1238 break; 1239 case DEVICE_TYPE_DFP: 1240 switch (enum_id) { 1241 case 1: 1242 return ATOM_DISPLAY_DFP1_SUPPORT; 1243 case 2: 1244 return ATOM_DISPLAY_DFP2_SUPPORT; 1245 case 3: 1246 return ATOM_DISPLAY_DFP3_SUPPORT; 1247 case 4: 1248 return ATOM_DISPLAY_DFP4_SUPPORT; 1249 case 5: 1250 return ATOM_DISPLAY_DFP5_SUPPORT; 1251 case 6: 1252 return ATOM_DISPLAY_DFP6_SUPPORT; 1253 default: 1254 break; 1255 } 1256 break; 1257 default: 1258 break; 1259 } 1260 1261 /* Unidentified device ID, return empty support mask. */ 1262 return 0; 1263 } 1264 1265 static bool bios_parser_is_device_id_supported( 1266 struct dc_bios *dcb, 1267 struct device_id id) 1268 { 1269 struct bios_parser *bp = BP_FROM_DCB(dcb); 1270 1271 uint32_t mask = get_support_mask_for_device_id(id); 1272 1273 return (le16_to_cpu(bp->object_info_tbl.v1_4->supporteddevices) & 1274 mask) != 0; 1275 } 1276 1277 static uint32_t bios_parser_get_ss_entry_number( 1278 struct dc_bios *dcb, 1279 enum as_signal_type signal) 1280 { 1281 /* TODO: DAL2 atomfirmware implementation does not need this. 1282 * why DAL3 need this? 1283 */ 1284 return 1; 1285 } 1286 1287 static enum bp_result bios_parser_transmitter_control( 1288 struct dc_bios *dcb, 1289 struct bp_transmitter_control *cntl) 1290 { 1291 struct bios_parser *bp = BP_FROM_DCB(dcb); 1292 1293 if (!bp->cmd_tbl.transmitter_control) 1294 return BP_RESULT_FAILURE; 1295 1296 return bp->cmd_tbl.transmitter_control(bp, cntl); 1297 } 1298 1299 static enum bp_result bios_parser_encoder_control( 1300 struct dc_bios *dcb, 1301 struct bp_encoder_control *cntl) 1302 { 1303 struct bios_parser *bp = BP_FROM_DCB(dcb); 1304 1305 if (!bp->cmd_tbl.dig_encoder_control) 1306 return BP_RESULT_FAILURE; 1307 1308 return bp->cmd_tbl.dig_encoder_control(bp, cntl); 1309 } 1310 1311 static enum bp_result bios_parser_set_pixel_clock( 1312 struct dc_bios *dcb, 1313 struct bp_pixel_clock_parameters *bp_params) 1314 { 1315 struct bios_parser *bp = BP_FROM_DCB(dcb); 1316 1317 if (!bp->cmd_tbl.set_pixel_clock) 1318 return BP_RESULT_FAILURE; 1319 1320 return bp->cmd_tbl.set_pixel_clock(bp, bp_params); 1321 } 1322 1323 static enum bp_result bios_parser_set_dce_clock( 1324 struct dc_bios *dcb, 1325 struct bp_set_dce_clock_parameters *bp_params) 1326 { 1327 struct bios_parser *bp = BP_FROM_DCB(dcb); 1328 1329 if (!bp->cmd_tbl.set_dce_clock) 1330 return BP_RESULT_FAILURE; 1331 1332 return bp->cmd_tbl.set_dce_clock(bp, bp_params); 1333 } 1334 1335 static enum bp_result bios_parser_program_crtc_timing( 1336 struct dc_bios *dcb, 1337 struct bp_hw_crtc_timing_parameters *bp_params) 1338 { 1339 struct bios_parser *bp = BP_FROM_DCB(dcb); 1340 1341 if (!bp->cmd_tbl.set_crtc_timing) 1342 return BP_RESULT_FAILURE; 1343 1344 return bp->cmd_tbl.set_crtc_timing(bp, bp_params); 1345 } 1346 1347 static enum bp_result bios_parser_enable_crtc( 1348 struct dc_bios *dcb, 1349 enum controller_id id, 1350 bool enable) 1351 { 1352 struct bios_parser *bp = BP_FROM_DCB(dcb); 1353 1354 if (!bp->cmd_tbl.enable_crtc) 1355 return BP_RESULT_FAILURE; 1356 1357 return bp->cmd_tbl.enable_crtc(bp, id, enable); 1358 } 1359 1360 static enum bp_result bios_parser_enable_disp_power_gating( 1361 struct dc_bios *dcb, 1362 enum controller_id controller_id, 1363 enum bp_pipe_control_action action) 1364 { 1365 struct bios_parser *bp = BP_FROM_DCB(dcb); 1366 1367 if (!bp->cmd_tbl.enable_disp_power_gating) 1368 return BP_RESULT_FAILURE; 1369 1370 return bp->cmd_tbl.enable_disp_power_gating(bp, controller_id, 1371 action); 1372 } 1373 1374 static enum bp_result bios_parser_enable_lvtma_control( 1375 struct dc_bios *dcb, 1376 uint8_t uc_pwr_on, 1377 uint8_t panel_instance) 1378 { 1379 struct bios_parser *bp = BP_FROM_DCB(dcb); 1380 1381 if (!bp->cmd_tbl.enable_lvtma_control) 1382 return BP_RESULT_FAILURE; 1383 1384 return bp->cmd_tbl.enable_lvtma_control(bp, uc_pwr_on, panel_instance); 1385 } 1386 1387 static bool bios_parser_is_accelerated_mode( 1388 struct dc_bios *dcb) 1389 { 1390 return bios_is_accelerated_mode(dcb); 1391 } 1392 1393 /** 1394 * bios_parser_set_scratch_critical_state - update critical state bit 1395 * in VBIOS scratch register 1396 * 1397 * @dcb: pointer to the DC BIO 1398 * @state: set or reset state 1399 */ 1400 static void bios_parser_set_scratch_critical_state( 1401 struct dc_bios *dcb, 1402 bool state) 1403 { 1404 bios_set_scratch_critical_state(dcb, state); 1405 } 1406 1407 static enum bp_result bios_parser_get_firmware_info( 1408 struct dc_bios *dcb, 1409 struct dc_firmware_info *info) 1410 { 1411 struct bios_parser *bp = BP_FROM_DCB(dcb); 1412 enum bp_result result = BP_RESULT_BADBIOSTABLE; 1413 struct atom_common_table_header *header; 1414 1415 struct atom_data_revision revision; 1416 1417 if (info && DATA_TABLES(firmwareinfo)) { 1418 header = GET_IMAGE(struct atom_common_table_header, 1419 DATA_TABLES(firmwareinfo)); 1420 get_atom_data_table_revision(header, &revision); 1421 switch (revision.major) { 1422 case 3: 1423 switch (revision.minor) { 1424 case 1: 1425 result = get_firmware_info_v3_1(bp, info); 1426 break; 1427 case 2: 1428 case 3: 1429 case 4: 1430 result = get_firmware_info_v3_2(bp, info); 1431 break; 1432 default: 1433 break; 1434 } 1435 break; 1436 default: 1437 break; 1438 } 1439 } 1440 1441 return result; 1442 } 1443 1444 static enum bp_result get_firmware_info_v3_1( 1445 struct bios_parser *bp, 1446 struct dc_firmware_info *info) 1447 { 1448 struct atom_firmware_info_v3_1 *firmware_info; 1449 struct atom_display_controller_info_v4_1 *dce_info = NULL; 1450 1451 if (!info) 1452 return BP_RESULT_BADINPUT; 1453 1454 firmware_info = GET_IMAGE(struct atom_firmware_info_v3_1, 1455 DATA_TABLES(firmwareinfo)); 1456 1457 dce_info = GET_IMAGE(struct atom_display_controller_info_v4_1, 1458 DATA_TABLES(dce_info)); 1459 1460 if (!firmware_info || !dce_info) 1461 return BP_RESULT_BADBIOSTABLE; 1462 1463 memset(info, 0, sizeof(*info)); 1464 1465 /* Pixel clock pll information. */ 1466 /* We need to convert from 10KHz units into KHz units */ 1467 info->default_memory_clk = firmware_info->bootup_mclk_in10khz * 10; 1468 info->default_engine_clk = firmware_info->bootup_sclk_in10khz * 10; 1469 1470 /* 27MHz for Vega10: */ 1471 info->pll_info.crystal_frequency = dce_info->dce_refclk_10khz * 10; 1472 1473 /* Hardcode frequency if BIOS gives no DCE Ref Clk */ 1474 if (info->pll_info.crystal_frequency == 0) 1475 info->pll_info.crystal_frequency = 27000; 1476 /*dp_phy_ref_clk is not correct for atom_display_controller_info_v4_2, but we don't use it*/ 1477 info->dp_phy_ref_clk = dce_info->dpphy_refclk_10khz * 10; 1478 info->i2c_engine_ref_clk = dce_info->i2c_engine_refclk_10khz * 10; 1479 1480 /* Get GPU PLL VCO Clock */ 1481 1482 if (bp->cmd_tbl.get_smu_clock_info != NULL) { 1483 /* VBIOS gives in 10KHz */ 1484 info->smu_gpu_pll_output_freq = 1485 bp->cmd_tbl.get_smu_clock_info(bp, SMU9_SYSPLL0_ID) * 10; 1486 } 1487 1488 info->oem_i2c_present = false; 1489 1490 return BP_RESULT_OK; 1491 } 1492 1493 static enum bp_result get_firmware_info_v3_2( 1494 struct bios_parser *bp, 1495 struct dc_firmware_info *info) 1496 { 1497 struct atom_firmware_info_v3_2 *firmware_info; 1498 struct atom_display_controller_info_v4_1 *dce_info = NULL; 1499 struct atom_common_table_header *header; 1500 struct atom_data_revision revision; 1501 struct atom_smu_info_v3_2 *smu_info_v3_2 = NULL; 1502 struct atom_smu_info_v3_3 *smu_info_v3_3 = NULL; 1503 1504 if (!info) 1505 return BP_RESULT_BADINPUT; 1506 1507 firmware_info = GET_IMAGE(struct atom_firmware_info_v3_2, 1508 DATA_TABLES(firmwareinfo)); 1509 1510 dce_info = GET_IMAGE(struct atom_display_controller_info_v4_1, 1511 DATA_TABLES(dce_info)); 1512 1513 if (!firmware_info || !dce_info) 1514 return BP_RESULT_BADBIOSTABLE; 1515 1516 memset(info, 0, sizeof(*info)); 1517 1518 header = GET_IMAGE(struct atom_common_table_header, 1519 DATA_TABLES(smu_info)); 1520 get_atom_data_table_revision(header, &revision); 1521 1522 if (revision.minor == 2) { 1523 /* Vega12 */ 1524 smu_info_v3_2 = GET_IMAGE(struct atom_smu_info_v3_2, 1525 DATA_TABLES(smu_info)); 1526 1527 if (!smu_info_v3_2) 1528 return BP_RESULT_BADBIOSTABLE; 1529 1530 info->default_engine_clk = smu_info_v3_2->bootup_dcefclk_10khz * 10; 1531 } else if (revision.minor == 3) { 1532 /* Vega20 */ 1533 smu_info_v3_3 = GET_IMAGE(struct atom_smu_info_v3_3, 1534 DATA_TABLES(smu_info)); 1535 1536 if (!smu_info_v3_3) 1537 return BP_RESULT_BADBIOSTABLE; 1538 1539 info->default_engine_clk = smu_info_v3_3->bootup_dcefclk_10khz * 10; 1540 } 1541 1542 // We need to convert from 10KHz units into KHz units. 1543 info->default_memory_clk = firmware_info->bootup_mclk_in10khz * 10; 1544 1545 /* 27MHz for Vega10 & Vega12; 100MHz for Vega20 */ 1546 info->pll_info.crystal_frequency = dce_info->dce_refclk_10khz * 10; 1547 /* Hardcode frequency if BIOS gives no DCE Ref Clk */ 1548 if (info->pll_info.crystal_frequency == 0) { 1549 if (revision.minor == 2) 1550 info->pll_info.crystal_frequency = 27000; 1551 else if (revision.minor == 3) 1552 info->pll_info.crystal_frequency = 100000; 1553 } 1554 /*dp_phy_ref_clk is not correct for atom_display_controller_info_v4_2, but we don't use it*/ 1555 info->dp_phy_ref_clk = dce_info->dpphy_refclk_10khz * 10; 1556 info->i2c_engine_ref_clk = dce_info->i2c_engine_refclk_10khz * 10; 1557 1558 /* Get GPU PLL VCO Clock */ 1559 if (bp->cmd_tbl.get_smu_clock_info != NULL) { 1560 if (revision.minor == 2) 1561 info->smu_gpu_pll_output_freq = 1562 bp->cmd_tbl.get_smu_clock_info(bp, SMU9_SYSPLL0_ID) * 10; 1563 else if (revision.minor == 3) 1564 info->smu_gpu_pll_output_freq = 1565 bp->cmd_tbl.get_smu_clock_info(bp, SMU11_SYSPLL3_0_ID) * 10; 1566 } 1567 1568 if (firmware_info->board_i2c_feature_id == 0x2) { 1569 info->oem_i2c_present = true; 1570 info->oem_i2c_obj_id = firmware_info->board_i2c_feature_gpio_id; 1571 } else { 1572 info->oem_i2c_present = false; 1573 } 1574 1575 return BP_RESULT_OK; 1576 } 1577 1578 static enum bp_result bios_parser_get_encoder_cap_info( 1579 struct dc_bios *dcb, 1580 struct graphics_object_id object_id, 1581 struct bp_encoder_cap_info *info) 1582 { 1583 struct bios_parser *bp = BP_FROM_DCB(dcb); 1584 struct atom_display_object_path_v2 *object; 1585 struct atom_encoder_caps_record *record = NULL; 1586 1587 if (!info) 1588 return BP_RESULT_BADINPUT; 1589 1590 object = get_bios_object(bp, object_id); 1591 1592 if (!object) 1593 return BP_RESULT_BADINPUT; 1594 1595 record = get_encoder_cap_record(bp, object); 1596 if (!record) 1597 return BP_RESULT_NORECORD; 1598 1599 info->DP_HBR2_CAP = (record->encodercaps & 1600 ATOM_ENCODER_CAP_RECORD_HBR2) ? 1 : 0; 1601 info->DP_HBR2_EN = (record->encodercaps & 1602 ATOM_ENCODER_CAP_RECORD_HBR2_EN) ? 1 : 0; 1603 info->DP_HBR3_EN = (record->encodercaps & 1604 ATOM_ENCODER_CAP_RECORD_HBR3_EN) ? 1 : 0; 1605 info->HDMI_6GB_EN = (record->encodercaps & 1606 ATOM_ENCODER_CAP_RECORD_HDMI6Gbps_EN) ? 1 : 0; 1607 #if defined(CONFIG_DRM_AMD_DC_DCN) 1608 info->IS_DP2_CAPABLE = (record->encodercaps & 1609 ATOM_ENCODER_CAP_RECORD_DP2) ? 1 : 0; 1610 info->DP_UHBR10_EN = (record->encodercaps & 1611 ATOM_ENCODER_CAP_RECORD_UHBR10_EN) ? 1 : 0; 1612 info->DP_UHBR13_5_EN = (record->encodercaps & 1613 ATOM_ENCODER_CAP_RECORD_UHBR13_5_EN) ? 1 : 0; 1614 info->DP_UHBR20_EN = (record->encodercaps & 1615 ATOM_ENCODER_CAP_RECORD_UHBR20_EN) ? 1 : 0; 1616 #endif 1617 info->DP_IS_USB_C = (record->encodercaps & 1618 ATOM_ENCODER_CAP_RECORD_USB_C_TYPE) ? 1 : 0; 1619 1620 return BP_RESULT_OK; 1621 } 1622 1623 1624 static struct atom_encoder_caps_record *get_encoder_cap_record( 1625 struct bios_parser *bp, 1626 struct atom_display_object_path_v2 *object) 1627 { 1628 struct atom_common_record_header *header; 1629 uint32_t offset; 1630 1631 if (!object) { 1632 BREAK_TO_DEBUGGER(); /* Invalid object */ 1633 return NULL; 1634 } 1635 1636 offset = object->encoder_recordoffset + bp->object_info_tbl_offset; 1637 1638 for (;;) { 1639 header = GET_IMAGE(struct atom_common_record_header, offset); 1640 1641 if (!header) 1642 return NULL; 1643 1644 offset += header->record_size; 1645 1646 if (header->record_type == LAST_RECORD_TYPE || 1647 !header->record_size) 1648 break; 1649 1650 if (header->record_type != ATOM_ENCODER_CAP_RECORD_TYPE) 1651 continue; 1652 1653 if (sizeof(struct atom_encoder_caps_record) <= 1654 header->record_size) 1655 return (struct atom_encoder_caps_record *)header; 1656 } 1657 1658 return NULL; 1659 } 1660 1661 static struct atom_disp_connector_caps_record *get_disp_connector_caps_record( 1662 struct bios_parser *bp, 1663 struct atom_display_object_path_v2 *object) 1664 { 1665 struct atom_common_record_header *header; 1666 uint32_t offset; 1667 1668 if (!object) { 1669 BREAK_TO_DEBUGGER(); /* Invalid object */ 1670 return NULL; 1671 } 1672 1673 offset = object->disp_recordoffset + bp->object_info_tbl_offset; 1674 1675 for (;;) { 1676 header = GET_IMAGE(struct atom_common_record_header, offset); 1677 1678 if (!header) 1679 return NULL; 1680 1681 offset += header->record_size; 1682 1683 if (header->record_type == LAST_RECORD_TYPE || 1684 !header->record_size) 1685 break; 1686 1687 if (header->record_type != ATOM_DISP_CONNECTOR_CAPS_RECORD_TYPE) 1688 continue; 1689 1690 if (sizeof(struct atom_disp_connector_caps_record) <= 1691 header->record_size) 1692 return (struct atom_disp_connector_caps_record *)header; 1693 } 1694 1695 return NULL; 1696 } 1697 1698 static enum bp_result bios_parser_get_disp_connector_caps_info( 1699 struct dc_bios *dcb, 1700 struct graphics_object_id object_id, 1701 struct bp_disp_connector_caps_info *info) 1702 { 1703 struct bios_parser *bp = BP_FROM_DCB(dcb); 1704 struct atom_display_object_path_v2 *object; 1705 struct atom_disp_connector_caps_record *record = NULL; 1706 1707 if (!info) 1708 return BP_RESULT_BADINPUT; 1709 1710 object = get_bios_object(bp, object_id); 1711 1712 if (!object) 1713 return BP_RESULT_BADINPUT; 1714 1715 record = get_disp_connector_caps_record(bp, object); 1716 if (!record) 1717 return BP_RESULT_NORECORD; 1718 1719 info->INTERNAL_DISPLAY = (record->connectcaps & ATOM_CONNECTOR_CAP_INTERNAL_DISPLAY) 1720 ? 1 : 0; 1721 info->INTERNAL_DISPLAY_BL = (record->connectcaps & ATOM_CONNECTOR_CAP_INTERNAL_DISPLAY_BL) 1722 ? 1 : 0; 1723 1724 return BP_RESULT_OK; 1725 } 1726 1727 static enum bp_result get_vram_info_v23( 1728 struct bios_parser *bp, 1729 struct dc_vram_info *info) 1730 { 1731 struct atom_vram_info_header_v2_3 *info_v23; 1732 enum bp_result result = BP_RESULT_OK; 1733 1734 info_v23 = GET_IMAGE(struct atom_vram_info_header_v2_3, 1735 DATA_TABLES(vram_info)); 1736 1737 if (info_v23 == NULL) 1738 return BP_RESULT_BADBIOSTABLE; 1739 1740 info->num_chans = info_v23->vram_module[0].channel_num; 1741 info->dram_channel_width_bytes = (1 << info_v23->vram_module[0].channel_width) / 8; 1742 1743 return result; 1744 } 1745 1746 static enum bp_result get_vram_info_v24( 1747 struct bios_parser *bp, 1748 struct dc_vram_info *info) 1749 { 1750 struct atom_vram_info_header_v2_4 *info_v24; 1751 enum bp_result result = BP_RESULT_OK; 1752 1753 info_v24 = GET_IMAGE(struct atom_vram_info_header_v2_4, 1754 DATA_TABLES(vram_info)); 1755 1756 if (info_v24 == NULL) 1757 return BP_RESULT_BADBIOSTABLE; 1758 1759 info->num_chans = info_v24->vram_module[0].channel_num; 1760 info->dram_channel_width_bytes = (1 << info_v24->vram_module[0].channel_width) / 8; 1761 1762 return result; 1763 } 1764 1765 static enum bp_result get_vram_info_v25( 1766 struct bios_parser *bp, 1767 struct dc_vram_info *info) 1768 { 1769 struct atom_vram_info_header_v2_5 *info_v25; 1770 enum bp_result result = BP_RESULT_OK; 1771 1772 info_v25 = GET_IMAGE(struct atom_vram_info_header_v2_5, 1773 DATA_TABLES(vram_info)); 1774 1775 if (info_v25 == NULL) 1776 return BP_RESULT_BADBIOSTABLE; 1777 1778 info->num_chans = info_v25->vram_module[0].channel_num; 1779 info->dram_channel_width_bytes = (1 << info_v25->vram_module[0].channel_width) / 8; 1780 1781 return result; 1782 } 1783 1784 /* 1785 * get_integrated_info_v11 1786 * 1787 * @brief 1788 * Get V8 integrated BIOS information 1789 * 1790 * @param 1791 * bios_parser *bp - [in]BIOS parser handler to get master data table 1792 * integrated_info *info - [out] store and output integrated info 1793 * 1794 * @return 1795 * enum bp_result - BP_RESULT_OK if information is available, 1796 * BP_RESULT_BADBIOSTABLE otherwise. 1797 */ 1798 static enum bp_result get_integrated_info_v11( 1799 struct bios_parser *bp, 1800 struct integrated_info *info) 1801 { 1802 struct atom_integrated_system_info_v1_11 *info_v11; 1803 uint32_t i; 1804 1805 info_v11 = GET_IMAGE(struct atom_integrated_system_info_v1_11, 1806 DATA_TABLES(integratedsysteminfo)); 1807 1808 if (info_v11 == NULL) 1809 return BP_RESULT_BADBIOSTABLE; 1810 1811 info->gpu_cap_info = 1812 le32_to_cpu(info_v11->gpucapinfo); 1813 /* 1814 * system_config: Bit[0] = 0 : PCIE power gating disabled 1815 * = 1 : PCIE power gating enabled 1816 * Bit[1] = 0 : DDR-PLL shut down disabled 1817 * = 1 : DDR-PLL shut down enabled 1818 * Bit[2] = 0 : DDR-PLL power down disabled 1819 * = 1 : DDR-PLL power down enabled 1820 */ 1821 info->system_config = le32_to_cpu(info_v11->system_config); 1822 info->cpu_cap_info = le32_to_cpu(info_v11->cpucapinfo); 1823 info->memory_type = info_v11->memorytype; 1824 info->ma_channel_number = info_v11->umachannelnumber; 1825 info->lvds_ss_percentage = 1826 le16_to_cpu(info_v11->lvds_ss_percentage); 1827 info->dp_ss_control = 1828 le16_to_cpu(info_v11->reserved1); 1829 info->lvds_sspread_rate_in_10hz = 1830 le16_to_cpu(info_v11->lvds_ss_rate_10hz); 1831 info->hdmi_ss_percentage = 1832 le16_to_cpu(info_v11->hdmi_ss_percentage); 1833 info->hdmi_sspread_rate_in_10hz = 1834 le16_to_cpu(info_v11->hdmi_ss_rate_10hz); 1835 info->dvi_ss_percentage = 1836 le16_to_cpu(info_v11->dvi_ss_percentage); 1837 info->dvi_sspread_rate_in_10_hz = 1838 le16_to_cpu(info_v11->dvi_ss_rate_10hz); 1839 info->lvds_misc = info_v11->lvds_misc; 1840 for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; ++i) { 1841 info->ext_disp_conn_info.gu_id[i] = 1842 info_v11->extdispconninfo.guid[i]; 1843 } 1844 1845 for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; ++i) { 1846 info->ext_disp_conn_info.path[i].device_connector_id = 1847 object_id_from_bios_object_id( 1848 le16_to_cpu(info_v11->extdispconninfo.path[i].connectorobjid)); 1849 1850 info->ext_disp_conn_info.path[i].ext_encoder_obj_id = 1851 object_id_from_bios_object_id( 1852 le16_to_cpu( 1853 info_v11->extdispconninfo.path[i].ext_encoder_objid)); 1854 1855 info->ext_disp_conn_info.path[i].device_tag = 1856 le16_to_cpu( 1857 info_v11->extdispconninfo.path[i].device_tag); 1858 info->ext_disp_conn_info.path[i].device_acpi_enum = 1859 le16_to_cpu( 1860 info_v11->extdispconninfo.path[i].device_acpi_enum); 1861 info->ext_disp_conn_info.path[i].ext_aux_ddc_lut_index = 1862 info_v11->extdispconninfo.path[i].auxddclut_index; 1863 info->ext_disp_conn_info.path[i].ext_hpd_pin_lut_index = 1864 info_v11->extdispconninfo.path[i].hpdlut_index; 1865 info->ext_disp_conn_info.path[i].channel_mapping.raw = 1866 info_v11->extdispconninfo.path[i].channelmapping; 1867 info->ext_disp_conn_info.path[i].caps = 1868 le16_to_cpu(info_v11->extdispconninfo.path[i].caps); 1869 } 1870 info->ext_disp_conn_info.checksum = 1871 info_v11->extdispconninfo.checksum; 1872 1873 info->dp0_ext_hdmi_slv_addr = info_v11->dp0_retimer_set.HdmiSlvAddr; 1874 info->dp0_ext_hdmi_reg_num = info_v11->dp0_retimer_set.HdmiRegNum; 1875 for (i = 0; i < info->dp0_ext_hdmi_reg_num; i++) { 1876 info->dp0_ext_hdmi_reg_settings[i].i2c_reg_index = 1877 info_v11->dp0_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 1878 info->dp0_ext_hdmi_reg_settings[i].i2c_reg_val = 1879 info_v11->dp0_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 1880 } 1881 info->dp0_ext_hdmi_6g_reg_num = info_v11->dp0_retimer_set.Hdmi6GRegNum; 1882 for (i = 0; i < info->dp0_ext_hdmi_6g_reg_num; i++) { 1883 info->dp0_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 1884 info_v11->dp0_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 1885 info->dp0_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 1886 info_v11->dp0_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 1887 } 1888 1889 info->dp1_ext_hdmi_slv_addr = info_v11->dp1_retimer_set.HdmiSlvAddr; 1890 info->dp1_ext_hdmi_reg_num = info_v11->dp1_retimer_set.HdmiRegNum; 1891 for (i = 0; i < info->dp1_ext_hdmi_reg_num; i++) { 1892 info->dp1_ext_hdmi_reg_settings[i].i2c_reg_index = 1893 info_v11->dp1_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 1894 info->dp1_ext_hdmi_reg_settings[i].i2c_reg_val = 1895 info_v11->dp1_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 1896 } 1897 info->dp1_ext_hdmi_6g_reg_num = info_v11->dp1_retimer_set.Hdmi6GRegNum; 1898 for (i = 0; i < info->dp1_ext_hdmi_6g_reg_num; i++) { 1899 info->dp1_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 1900 info_v11->dp1_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 1901 info->dp1_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 1902 info_v11->dp1_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 1903 } 1904 1905 info->dp2_ext_hdmi_slv_addr = info_v11->dp2_retimer_set.HdmiSlvAddr; 1906 info->dp2_ext_hdmi_reg_num = info_v11->dp2_retimer_set.HdmiRegNum; 1907 for (i = 0; i < info->dp2_ext_hdmi_reg_num; i++) { 1908 info->dp2_ext_hdmi_reg_settings[i].i2c_reg_index = 1909 info_v11->dp2_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 1910 info->dp2_ext_hdmi_reg_settings[i].i2c_reg_val = 1911 info_v11->dp2_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 1912 } 1913 info->dp2_ext_hdmi_6g_reg_num = info_v11->dp2_retimer_set.Hdmi6GRegNum; 1914 for (i = 0; i < info->dp2_ext_hdmi_6g_reg_num; i++) { 1915 info->dp2_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 1916 info_v11->dp2_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 1917 info->dp2_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 1918 info_v11->dp2_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 1919 } 1920 1921 info->dp3_ext_hdmi_slv_addr = info_v11->dp3_retimer_set.HdmiSlvAddr; 1922 info->dp3_ext_hdmi_reg_num = info_v11->dp3_retimer_set.HdmiRegNum; 1923 for (i = 0; i < info->dp3_ext_hdmi_reg_num; i++) { 1924 info->dp3_ext_hdmi_reg_settings[i].i2c_reg_index = 1925 info_v11->dp3_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 1926 info->dp3_ext_hdmi_reg_settings[i].i2c_reg_val = 1927 info_v11->dp3_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 1928 } 1929 info->dp3_ext_hdmi_6g_reg_num = info_v11->dp3_retimer_set.Hdmi6GRegNum; 1930 for (i = 0; i < info->dp3_ext_hdmi_6g_reg_num; i++) { 1931 info->dp3_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 1932 info_v11->dp3_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 1933 info->dp3_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 1934 info_v11->dp3_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 1935 } 1936 1937 1938 /** TODO - review **/ 1939 #if 0 1940 info->boot_up_engine_clock = le32_to_cpu(info_v11->ulBootUpEngineClock) 1941 * 10; 1942 info->dentist_vco_freq = le32_to_cpu(info_v11->ulDentistVCOFreq) * 10; 1943 info->boot_up_uma_clock = le32_to_cpu(info_v8->ulBootUpUMAClock) * 10; 1944 1945 for (i = 0; i < NUMBER_OF_DISP_CLK_VOLTAGE; ++i) { 1946 /* Convert [10KHz] into [KHz] */ 1947 info->disp_clk_voltage[i].max_supported_clk = 1948 le32_to_cpu(info_v11->sDISPCLK_Voltage[i]. 1949 ulMaximumSupportedCLK) * 10; 1950 info->disp_clk_voltage[i].voltage_index = 1951 le32_to_cpu(info_v11->sDISPCLK_Voltage[i].ulVoltageIndex); 1952 } 1953 1954 info->boot_up_req_display_vector = 1955 le32_to_cpu(info_v11->ulBootUpReqDisplayVector); 1956 info->boot_up_nb_voltage = 1957 le16_to_cpu(info_v11->usBootUpNBVoltage); 1958 info->ext_disp_conn_info_offset = 1959 le16_to_cpu(info_v11->usExtDispConnInfoOffset); 1960 info->gmc_restore_reset_time = 1961 le32_to_cpu(info_v11->ulGMCRestoreResetTime); 1962 info->minimum_n_clk = 1963 le32_to_cpu(info_v11->ulNbpStateNClkFreq[0]); 1964 for (i = 1; i < 4; ++i) 1965 info->minimum_n_clk = 1966 info->minimum_n_clk < 1967 le32_to_cpu(info_v11->ulNbpStateNClkFreq[i]) ? 1968 info->minimum_n_clk : le32_to_cpu( 1969 info_v11->ulNbpStateNClkFreq[i]); 1970 1971 info->idle_n_clk = le32_to_cpu(info_v11->ulIdleNClk); 1972 info->ddr_dll_power_up_time = 1973 le32_to_cpu(info_v11->ulDDR_DLL_PowerUpTime); 1974 info->ddr_pll_power_up_time = 1975 le32_to_cpu(info_v11->ulDDR_PLL_PowerUpTime); 1976 info->pcie_clk_ss_type = le16_to_cpu(info_v11->usPCIEClkSSType); 1977 info->max_lvds_pclk_freq_in_single_link = 1978 le16_to_cpu(info_v11->usMaxLVDSPclkFreqInSingleLink); 1979 info->max_lvds_pclk_freq_in_single_link = 1980 le16_to_cpu(info_v11->usMaxLVDSPclkFreqInSingleLink); 1981 info->lvds_pwr_on_seq_dig_on_to_de_in_4ms = 1982 info_v11->ucLVDSPwrOnSeqDIGONtoDE_in4Ms; 1983 info->lvds_pwr_on_seq_de_to_vary_bl_in_4ms = 1984 info_v11->ucLVDSPwrOnSeqDEtoVARY_BL_in4Ms; 1985 info->lvds_pwr_on_seq_vary_bl_to_blon_in_4ms = 1986 info_v11->ucLVDSPwrOnSeqVARY_BLtoBLON_in4Ms; 1987 info->lvds_pwr_off_seq_vary_bl_to_de_in4ms = 1988 info_v11->ucLVDSPwrOffSeqVARY_BLtoDE_in4Ms; 1989 info->lvds_pwr_off_seq_de_to_dig_on_in4ms = 1990 info_v11->ucLVDSPwrOffSeqDEtoDIGON_in4Ms; 1991 info->lvds_pwr_off_seq_blon_to_vary_bl_in_4ms = 1992 info_v11->ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms; 1993 info->lvds_off_to_on_delay_in_4ms = 1994 info_v11->ucLVDSOffToOnDelay_in4Ms; 1995 info->lvds_bit_depth_control_val = 1996 le32_to_cpu(info_v11->ulLCDBitDepthControlVal); 1997 1998 for (i = 0; i < NUMBER_OF_AVAILABLE_SCLK; ++i) { 1999 /* Convert [10KHz] into [KHz] */ 2000 info->avail_s_clk[i].supported_s_clk = 2001 le32_to_cpu(info_v11->sAvail_SCLK[i].ulSupportedSCLK) 2002 * 10; 2003 info->avail_s_clk[i].voltage_index = 2004 le16_to_cpu(info_v11->sAvail_SCLK[i].usVoltageIndex); 2005 info->avail_s_clk[i].voltage_id = 2006 le16_to_cpu(info_v11->sAvail_SCLK[i].usVoltageID); 2007 } 2008 #endif /* TODO*/ 2009 2010 return BP_RESULT_OK; 2011 } 2012 2013 static enum bp_result get_integrated_info_v2_1( 2014 struct bios_parser *bp, 2015 struct integrated_info *info) 2016 { 2017 struct atom_integrated_system_info_v2_1 *info_v2_1; 2018 uint32_t i; 2019 2020 info_v2_1 = GET_IMAGE(struct atom_integrated_system_info_v2_1, 2021 DATA_TABLES(integratedsysteminfo)); 2022 2023 if (info_v2_1 == NULL) 2024 return BP_RESULT_BADBIOSTABLE; 2025 2026 info->gpu_cap_info = 2027 le32_to_cpu(info_v2_1->gpucapinfo); 2028 /* 2029 * system_config: Bit[0] = 0 : PCIE power gating disabled 2030 * = 1 : PCIE power gating enabled 2031 * Bit[1] = 0 : DDR-PLL shut down disabled 2032 * = 1 : DDR-PLL shut down enabled 2033 * Bit[2] = 0 : DDR-PLL power down disabled 2034 * = 1 : DDR-PLL power down enabled 2035 */ 2036 info->system_config = le32_to_cpu(info_v2_1->system_config); 2037 info->cpu_cap_info = le32_to_cpu(info_v2_1->cpucapinfo); 2038 info->memory_type = info_v2_1->memorytype; 2039 info->ma_channel_number = info_v2_1->umachannelnumber; 2040 info->dp_ss_control = 2041 le16_to_cpu(info_v2_1->reserved1); 2042 2043 for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; ++i) { 2044 info->ext_disp_conn_info.gu_id[i] = 2045 info_v2_1->extdispconninfo.guid[i]; 2046 } 2047 2048 for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; ++i) { 2049 info->ext_disp_conn_info.path[i].device_connector_id = 2050 object_id_from_bios_object_id( 2051 le16_to_cpu(info_v2_1->extdispconninfo.path[i].connectorobjid)); 2052 2053 info->ext_disp_conn_info.path[i].ext_encoder_obj_id = 2054 object_id_from_bios_object_id( 2055 le16_to_cpu( 2056 info_v2_1->extdispconninfo.path[i].ext_encoder_objid)); 2057 2058 info->ext_disp_conn_info.path[i].device_tag = 2059 le16_to_cpu( 2060 info_v2_1->extdispconninfo.path[i].device_tag); 2061 info->ext_disp_conn_info.path[i].device_acpi_enum = 2062 le16_to_cpu( 2063 info_v2_1->extdispconninfo.path[i].device_acpi_enum); 2064 info->ext_disp_conn_info.path[i].ext_aux_ddc_lut_index = 2065 info_v2_1->extdispconninfo.path[i].auxddclut_index; 2066 info->ext_disp_conn_info.path[i].ext_hpd_pin_lut_index = 2067 info_v2_1->extdispconninfo.path[i].hpdlut_index; 2068 info->ext_disp_conn_info.path[i].channel_mapping.raw = 2069 info_v2_1->extdispconninfo.path[i].channelmapping; 2070 info->ext_disp_conn_info.path[i].caps = 2071 le16_to_cpu(info_v2_1->extdispconninfo.path[i].caps); 2072 } 2073 2074 info->ext_disp_conn_info.checksum = 2075 info_v2_1->extdispconninfo.checksum; 2076 info->dp0_ext_hdmi_slv_addr = info_v2_1->dp0_retimer_set.HdmiSlvAddr; 2077 info->dp0_ext_hdmi_reg_num = info_v2_1->dp0_retimer_set.HdmiRegNum; 2078 for (i = 0; i < info->dp0_ext_hdmi_reg_num; i++) { 2079 info->dp0_ext_hdmi_reg_settings[i].i2c_reg_index = 2080 info_v2_1->dp0_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 2081 info->dp0_ext_hdmi_reg_settings[i].i2c_reg_val = 2082 info_v2_1->dp0_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 2083 } 2084 info->dp0_ext_hdmi_6g_reg_num = info_v2_1->dp0_retimer_set.Hdmi6GRegNum; 2085 for (i = 0; i < info->dp0_ext_hdmi_6g_reg_num; i++) { 2086 info->dp0_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 2087 info_v2_1->dp0_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 2088 info->dp0_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 2089 info_v2_1->dp0_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 2090 } 2091 info->dp1_ext_hdmi_slv_addr = info_v2_1->dp1_retimer_set.HdmiSlvAddr; 2092 info->dp1_ext_hdmi_reg_num = info_v2_1->dp1_retimer_set.HdmiRegNum; 2093 for (i = 0; i < info->dp1_ext_hdmi_reg_num; i++) { 2094 info->dp1_ext_hdmi_reg_settings[i].i2c_reg_index = 2095 info_v2_1->dp1_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 2096 info->dp1_ext_hdmi_reg_settings[i].i2c_reg_val = 2097 info_v2_1->dp1_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 2098 } 2099 info->dp1_ext_hdmi_6g_reg_num = info_v2_1->dp1_retimer_set.Hdmi6GRegNum; 2100 for (i = 0; i < info->dp1_ext_hdmi_6g_reg_num; i++) { 2101 info->dp1_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 2102 info_v2_1->dp1_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 2103 info->dp1_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 2104 info_v2_1->dp1_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 2105 } 2106 info->dp2_ext_hdmi_slv_addr = info_v2_1->dp2_retimer_set.HdmiSlvAddr; 2107 info->dp2_ext_hdmi_reg_num = info_v2_1->dp2_retimer_set.HdmiRegNum; 2108 for (i = 0; i < info->dp2_ext_hdmi_reg_num; i++) { 2109 info->dp2_ext_hdmi_reg_settings[i].i2c_reg_index = 2110 info_v2_1->dp2_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 2111 info->dp2_ext_hdmi_reg_settings[i].i2c_reg_val = 2112 info_v2_1->dp2_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 2113 } 2114 info->dp2_ext_hdmi_6g_reg_num = info_v2_1->dp2_retimer_set.Hdmi6GRegNum; 2115 for (i = 0; i < info->dp2_ext_hdmi_6g_reg_num; i++) { 2116 info->dp2_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 2117 info_v2_1->dp2_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 2118 info->dp2_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 2119 info_v2_1->dp2_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 2120 } 2121 info->dp3_ext_hdmi_slv_addr = info_v2_1->dp3_retimer_set.HdmiSlvAddr; 2122 info->dp3_ext_hdmi_reg_num = info_v2_1->dp3_retimer_set.HdmiRegNum; 2123 for (i = 0; i < info->dp3_ext_hdmi_reg_num; i++) { 2124 info->dp3_ext_hdmi_reg_settings[i].i2c_reg_index = 2125 info_v2_1->dp3_retimer_set.HdmiRegSetting[i].ucI2cRegIndex; 2126 info->dp3_ext_hdmi_reg_settings[i].i2c_reg_val = 2127 info_v2_1->dp3_retimer_set.HdmiRegSetting[i].ucI2cRegVal; 2128 } 2129 info->dp3_ext_hdmi_6g_reg_num = info_v2_1->dp3_retimer_set.Hdmi6GRegNum; 2130 for (i = 0; i < info->dp3_ext_hdmi_6g_reg_num; i++) { 2131 info->dp3_ext_hdmi_6g_reg_settings[i].i2c_reg_index = 2132 info_v2_1->dp3_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex; 2133 info->dp3_ext_hdmi_6g_reg_settings[i].i2c_reg_val = 2134 info_v2_1->dp3_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal; 2135 } 2136 2137 info->edp1_info.edp_backlight_pwm_hz = 2138 le16_to_cpu(info_v2_1->edp1_info.edp_backlight_pwm_hz); 2139 info->edp1_info.edp_ss_percentage = 2140 le16_to_cpu(info_v2_1->edp1_info.edp_ss_percentage); 2141 info->edp1_info.edp_ss_rate_10hz = 2142 le16_to_cpu(info_v2_1->edp1_info.edp_ss_rate_10hz); 2143 info->edp1_info.edp_pwr_on_off_delay = 2144 info_v2_1->edp1_info.edp_pwr_on_off_delay; 2145 info->edp1_info.edp_pwr_on_vary_bl_to_blon = 2146 info_v2_1->edp1_info.edp_pwr_on_vary_bl_to_blon; 2147 info->edp1_info.edp_pwr_down_bloff_to_vary_bloff = 2148 info_v2_1->edp1_info.edp_pwr_down_bloff_to_vary_bloff; 2149 info->edp1_info.edp_panel_bpc = 2150 info_v2_1->edp1_info.edp_panel_bpc; 2151 info->edp1_info.edp_bootup_bl_level = info_v2_1->edp1_info.edp_bootup_bl_level; 2152 2153 info->edp2_info.edp_backlight_pwm_hz = 2154 le16_to_cpu(info_v2_1->edp2_info.edp_backlight_pwm_hz); 2155 info->edp2_info.edp_ss_percentage = 2156 le16_to_cpu(info_v2_1->edp2_info.edp_ss_percentage); 2157 info->edp2_info.edp_ss_rate_10hz = 2158 le16_to_cpu(info_v2_1->edp2_info.edp_ss_rate_10hz); 2159 info->edp2_info.edp_pwr_on_off_delay = 2160 info_v2_1->edp2_info.edp_pwr_on_off_delay; 2161 info->edp2_info.edp_pwr_on_vary_bl_to_blon = 2162 info_v2_1->edp2_info.edp_pwr_on_vary_bl_to_blon; 2163 info->edp2_info.edp_pwr_down_bloff_to_vary_bloff = 2164 info_v2_1->edp2_info.edp_pwr_down_bloff_to_vary_bloff; 2165 info->edp2_info.edp_panel_bpc = 2166 info_v2_1->edp2_info.edp_panel_bpc; 2167 info->edp2_info.edp_bootup_bl_level = 2168 info_v2_1->edp2_info.edp_bootup_bl_level; 2169 2170 return BP_RESULT_OK; 2171 } 2172 2173 static enum bp_result get_integrated_info_v2_2( 2174 struct bios_parser *bp, 2175 struct integrated_info *info) 2176 { 2177 struct atom_integrated_system_info_v2_2 *info_v2_2; 2178 uint32_t i; 2179 2180 info_v2_2 = GET_IMAGE(struct atom_integrated_system_info_v2_2, 2181 DATA_TABLES(integratedsysteminfo)); 2182 2183 if (info_v2_2 == NULL) 2184 return BP_RESULT_BADBIOSTABLE; 2185 2186 info->gpu_cap_info = 2187 le32_to_cpu(info_v2_2->gpucapinfo); 2188 /* 2189 * system_config: Bit[0] = 0 : PCIE power gating disabled 2190 * = 1 : PCIE power gating enabled 2191 * Bit[1] = 0 : DDR-PLL shut down disabled 2192 * = 1 : DDR-PLL shut down enabled 2193 * Bit[2] = 0 : DDR-PLL power down disabled 2194 * = 1 : DDR-PLL power down enabled 2195 */ 2196 info->system_config = le32_to_cpu(info_v2_2->system_config); 2197 info->cpu_cap_info = le32_to_cpu(info_v2_2->cpucapinfo); 2198 info->memory_type = info_v2_2->memorytype; 2199 info->ma_channel_number = info_v2_2->umachannelnumber; 2200 info->dp_ss_control = 2201 le16_to_cpu(info_v2_2->reserved1); 2202 2203 for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; ++i) { 2204 info->ext_disp_conn_info.gu_id[i] = 2205 info_v2_2->extdispconninfo.guid[i]; 2206 } 2207 2208 for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; ++i) { 2209 info->ext_disp_conn_info.path[i].device_connector_id = 2210 object_id_from_bios_object_id( 2211 le16_to_cpu(info_v2_2->extdispconninfo.path[i].connectorobjid)); 2212 2213 info->ext_disp_conn_info.path[i].ext_encoder_obj_id = 2214 object_id_from_bios_object_id( 2215 le16_to_cpu( 2216 info_v2_2->extdispconninfo.path[i].ext_encoder_objid)); 2217 2218 info->ext_disp_conn_info.path[i].device_tag = 2219 le16_to_cpu( 2220 info_v2_2->extdispconninfo.path[i].device_tag); 2221 info->ext_disp_conn_info.path[i].device_acpi_enum = 2222 le16_to_cpu( 2223 info_v2_2->extdispconninfo.path[i].device_acpi_enum); 2224 info->ext_disp_conn_info.path[i].ext_aux_ddc_lut_index = 2225 info_v2_2->extdispconninfo.path[i].auxddclut_index; 2226 info->ext_disp_conn_info.path[i].ext_hpd_pin_lut_index = 2227 info_v2_2->extdispconninfo.path[i].hpdlut_index; 2228 info->ext_disp_conn_info.path[i].channel_mapping.raw = 2229 info_v2_2->extdispconninfo.path[i].channelmapping; 2230 info->ext_disp_conn_info.path[i].caps = 2231 le16_to_cpu(info_v2_2->extdispconninfo.path[i].caps); 2232 } 2233 2234 info->ext_disp_conn_info.checksum = 2235 info_v2_2->extdispconninfo.checksum; 2236 2237 info->edp1_info.edp_backlight_pwm_hz = 2238 le16_to_cpu(info_v2_2->edp1_info.edp_backlight_pwm_hz); 2239 info->edp1_info.edp_ss_percentage = 2240 le16_to_cpu(info_v2_2->edp1_info.edp_ss_percentage); 2241 info->edp1_info.edp_ss_rate_10hz = 2242 le16_to_cpu(info_v2_2->edp1_info.edp_ss_rate_10hz); 2243 info->edp1_info.edp_pwr_on_off_delay = 2244 info_v2_2->edp1_info.edp_pwr_on_off_delay; 2245 info->edp1_info.edp_pwr_on_vary_bl_to_blon = 2246 info_v2_2->edp1_info.edp_pwr_on_vary_bl_to_blon; 2247 info->edp1_info.edp_pwr_down_bloff_to_vary_bloff = 2248 info_v2_2->edp1_info.edp_pwr_down_bloff_to_vary_bloff; 2249 info->edp1_info.edp_panel_bpc = 2250 info_v2_2->edp1_info.edp_panel_bpc; 2251 info->edp1_info.edp_bootup_bl_level = 2252 2253 info->edp2_info.edp_backlight_pwm_hz = 2254 le16_to_cpu(info_v2_2->edp2_info.edp_backlight_pwm_hz); 2255 info->edp2_info.edp_ss_percentage = 2256 le16_to_cpu(info_v2_2->edp2_info.edp_ss_percentage); 2257 info->edp2_info.edp_ss_rate_10hz = 2258 le16_to_cpu(info_v2_2->edp2_info.edp_ss_rate_10hz); 2259 info->edp2_info.edp_pwr_on_off_delay = 2260 info_v2_2->edp2_info.edp_pwr_on_off_delay; 2261 info->edp2_info.edp_pwr_on_vary_bl_to_blon = 2262 info_v2_2->edp2_info.edp_pwr_on_vary_bl_to_blon; 2263 info->edp2_info.edp_pwr_down_bloff_to_vary_bloff = 2264 info_v2_2->edp2_info.edp_pwr_down_bloff_to_vary_bloff; 2265 info->edp2_info.edp_panel_bpc = 2266 info_v2_2->edp2_info.edp_panel_bpc; 2267 info->edp2_info.edp_bootup_bl_level = 2268 info_v2_2->edp2_info.edp_bootup_bl_level; 2269 2270 return BP_RESULT_OK; 2271 } 2272 2273 /* 2274 * construct_integrated_info 2275 * 2276 * @brief 2277 * Get integrated BIOS information based on table revision 2278 * 2279 * @param 2280 * bios_parser *bp - [in]BIOS parser handler to get master data table 2281 * integrated_info *info - [out] store and output integrated info 2282 * 2283 * @return 2284 * enum bp_result - BP_RESULT_OK if information is available, 2285 * BP_RESULT_BADBIOSTABLE otherwise. 2286 */ 2287 static enum bp_result construct_integrated_info( 2288 struct bios_parser *bp, 2289 struct integrated_info *info) 2290 { 2291 enum bp_result result = BP_RESULT_BADBIOSTABLE; 2292 2293 struct atom_common_table_header *header; 2294 struct atom_data_revision revision; 2295 uint32_t i; 2296 uint32_t j; 2297 2298 if (info && DATA_TABLES(integratedsysteminfo)) { 2299 header = GET_IMAGE(struct atom_common_table_header, 2300 DATA_TABLES(integratedsysteminfo)); 2301 2302 get_atom_data_table_revision(header, &revision); 2303 2304 switch (revision.major) { 2305 case 1: 2306 switch (revision.minor) { 2307 case 11: 2308 case 12: 2309 result = get_integrated_info_v11(bp, info); 2310 break; 2311 default: 2312 return result; 2313 } 2314 break; 2315 case 2: 2316 switch (revision.minor) { 2317 case 1: 2318 result = get_integrated_info_v2_1(bp, info); 2319 break; 2320 case 2: 2321 result = get_integrated_info_v2_2(bp, info); 2322 break; 2323 default: 2324 return result; 2325 } 2326 break; 2327 default: 2328 return result; 2329 } 2330 } 2331 2332 if (result != BP_RESULT_OK) 2333 return result; 2334 2335 /* Sort voltage table from low to high*/ 2336 for (i = 1; i < NUMBER_OF_DISP_CLK_VOLTAGE; ++i) { 2337 for (j = i; j > 0; --j) { 2338 if (info->disp_clk_voltage[j].max_supported_clk < 2339 info->disp_clk_voltage[j-1].max_supported_clk 2340 ) { 2341 /* swap j and j - 1*/ 2342 swap(info->disp_clk_voltage[j - 1], 2343 info->disp_clk_voltage[j]); 2344 } 2345 } 2346 } 2347 2348 return result; 2349 } 2350 2351 static enum bp_result bios_parser_get_vram_info( 2352 struct dc_bios *dcb, 2353 struct dc_vram_info *info) 2354 { 2355 struct bios_parser *bp = BP_FROM_DCB(dcb); 2356 enum bp_result result = BP_RESULT_BADBIOSTABLE; 2357 struct atom_common_table_header *header; 2358 struct atom_data_revision revision; 2359 2360 if (info && DATA_TABLES(vram_info)) { 2361 header = GET_IMAGE(struct atom_common_table_header, 2362 DATA_TABLES(vram_info)); 2363 2364 get_atom_data_table_revision(header, &revision); 2365 2366 switch (revision.major) { 2367 case 2: 2368 switch (revision.minor) { 2369 case 3: 2370 result = get_vram_info_v23(bp, info); 2371 break; 2372 case 4: 2373 result = get_vram_info_v24(bp, info); 2374 break; 2375 case 5: 2376 result = get_vram_info_v25(bp, info); 2377 break; 2378 default: 2379 break; 2380 } 2381 break; 2382 2383 default: 2384 return result; 2385 } 2386 2387 } 2388 return result; 2389 } 2390 2391 static struct integrated_info *bios_parser_create_integrated_info( 2392 struct dc_bios *dcb) 2393 { 2394 struct bios_parser *bp = BP_FROM_DCB(dcb); 2395 struct integrated_info *info = NULL; 2396 2397 info = kzalloc(sizeof(struct integrated_info), GFP_KERNEL); 2398 2399 if (info == NULL) { 2400 ASSERT_CRITICAL(0); 2401 return NULL; 2402 } 2403 2404 if (construct_integrated_info(bp, info) == BP_RESULT_OK) 2405 return info; 2406 2407 kfree(info); 2408 2409 return NULL; 2410 } 2411 2412 static enum bp_result update_slot_layout_info( 2413 struct dc_bios *dcb, 2414 unsigned int i, 2415 struct slot_layout_info *slot_layout_info) 2416 { 2417 unsigned int record_offset; 2418 unsigned int j; 2419 struct atom_display_object_path_v2 *object; 2420 struct atom_bracket_layout_record *record; 2421 struct atom_common_record_header *record_header; 2422 enum bp_result result; 2423 struct bios_parser *bp; 2424 struct object_info_table *tbl; 2425 struct display_object_info_table_v1_4 *v1_4; 2426 2427 record = NULL; 2428 record_header = NULL; 2429 result = BP_RESULT_NORECORD; 2430 2431 bp = BP_FROM_DCB(dcb); 2432 tbl = &bp->object_info_tbl; 2433 v1_4 = tbl->v1_4; 2434 2435 object = &v1_4->display_path[i]; 2436 record_offset = (unsigned int) 2437 (object->disp_recordoffset) + 2438 (unsigned int)(bp->object_info_tbl_offset); 2439 2440 for (;;) { 2441 2442 record_header = (struct atom_common_record_header *) 2443 GET_IMAGE(struct atom_common_record_header, 2444 record_offset); 2445 if (record_header == NULL) { 2446 result = BP_RESULT_BADBIOSTABLE; 2447 break; 2448 } 2449 2450 /* the end of the list */ 2451 if (record_header->record_type == 0xff || 2452 record_header->record_size == 0) { 2453 break; 2454 } 2455 2456 if (record_header->record_type == 2457 ATOM_BRACKET_LAYOUT_RECORD_TYPE && 2458 sizeof(struct atom_bracket_layout_record) 2459 <= record_header->record_size) { 2460 record = (struct atom_bracket_layout_record *) 2461 (record_header); 2462 result = BP_RESULT_OK; 2463 break; 2464 } 2465 2466 record_offset += record_header->record_size; 2467 } 2468 2469 /* return if the record not found */ 2470 if (result != BP_RESULT_OK) 2471 return result; 2472 2473 /* get slot sizes */ 2474 slot_layout_info->length = record->bracketlen; 2475 slot_layout_info->width = record->bracketwidth; 2476 2477 /* get info for each connector in the slot */ 2478 slot_layout_info->num_of_connectors = record->conn_num; 2479 for (j = 0; j < slot_layout_info->num_of_connectors; ++j) { 2480 slot_layout_info->connectors[j].connector_type = 2481 (enum connector_layout_type) 2482 (record->conn_info[j].connector_type); 2483 switch (record->conn_info[j].connector_type) { 2484 case CONNECTOR_TYPE_DVI_D: 2485 slot_layout_info->connectors[j].connector_type = 2486 CONNECTOR_LAYOUT_TYPE_DVI_D; 2487 slot_layout_info->connectors[j].length = 2488 CONNECTOR_SIZE_DVI; 2489 break; 2490 2491 case CONNECTOR_TYPE_HDMI: 2492 slot_layout_info->connectors[j].connector_type = 2493 CONNECTOR_LAYOUT_TYPE_HDMI; 2494 slot_layout_info->connectors[j].length = 2495 CONNECTOR_SIZE_HDMI; 2496 break; 2497 2498 case CONNECTOR_TYPE_DISPLAY_PORT: 2499 slot_layout_info->connectors[j].connector_type = 2500 CONNECTOR_LAYOUT_TYPE_DP; 2501 slot_layout_info->connectors[j].length = 2502 CONNECTOR_SIZE_DP; 2503 break; 2504 2505 case CONNECTOR_TYPE_MINI_DISPLAY_PORT: 2506 slot_layout_info->connectors[j].connector_type = 2507 CONNECTOR_LAYOUT_TYPE_MINI_DP; 2508 slot_layout_info->connectors[j].length = 2509 CONNECTOR_SIZE_MINI_DP; 2510 break; 2511 2512 default: 2513 slot_layout_info->connectors[j].connector_type = 2514 CONNECTOR_LAYOUT_TYPE_UNKNOWN; 2515 slot_layout_info->connectors[j].length = 2516 CONNECTOR_SIZE_UNKNOWN; 2517 } 2518 2519 slot_layout_info->connectors[j].position = 2520 record->conn_info[j].position; 2521 slot_layout_info->connectors[j].connector_id = 2522 object_id_from_bios_object_id( 2523 record->conn_info[j].connectorobjid); 2524 } 2525 return result; 2526 } 2527 2528 2529 static enum bp_result get_bracket_layout_record( 2530 struct dc_bios *dcb, 2531 unsigned int bracket_layout_id, 2532 struct slot_layout_info *slot_layout_info) 2533 { 2534 unsigned int i; 2535 struct bios_parser *bp = BP_FROM_DCB(dcb); 2536 enum bp_result result; 2537 struct object_info_table *tbl; 2538 struct display_object_info_table_v1_4 *v1_4; 2539 2540 if (slot_layout_info == NULL) { 2541 DC_LOG_DETECTION_EDID_PARSER("Invalid slot_layout_info\n"); 2542 return BP_RESULT_BADINPUT; 2543 } 2544 tbl = &bp->object_info_tbl; 2545 v1_4 = tbl->v1_4; 2546 2547 result = BP_RESULT_NORECORD; 2548 for (i = 0; i < v1_4->number_of_path; ++i) { 2549 2550 if (bracket_layout_id == 2551 v1_4->display_path[i].display_objid) { 2552 result = update_slot_layout_info(dcb, i, 2553 slot_layout_info); 2554 break; 2555 } 2556 } 2557 return result; 2558 } 2559 2560 static enum bp_result bios_get_board_layout_info( 2561 struct dc_bios *dcb, 2562 struct board_layout_info *board_layout_info) 2563 { 2564 unsigned int i; 2565 enum bp_result record_result; 2566 2567 const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = { 2568 GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1, 2569 GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2, 2570 0, 0 2571 }; 2572 2573 if (board_layout_info == NULL) { 2574 DC_LOG_DETECTION_EDID_PARSER("Invalid board_layout_info\n"); 2575 return BP_RESULT_BADINPUT; 2576 } 2577 2578 board_layout_info->num_of_slots = 0; 2579 2580 for (i = 0; i < MAX_BOARD_SLOTS; ++i) { 2581 record_result = get_bracket_layout_record(dcb, 2582 slot_index_to_vbios_id[i], 2583 &board_layout_info->slots[i]); 2584 2585 if (record_result == BP_RESULT_NORECORD && i > 0) 2586 break; /* no more slots present in bios */ 2587 else if (record_result != BP_RESULT_OK) 2588 return record_result; /* fail */ 2589 2590 ++board_layout_info->num_of_slots; 2591 } 2592 2593 /* all data is valid */ 2594 board_layout_info->is_number_of_slots_valid = 1; 2595 board_layout_info->is_slots_size_valid = 1; 2596 board_layout_info->is_connector_offsets_valid = 1; 2597 board_layout_info->is_connector_lengths_valid = 1; 2598 2599 return BP_RESULT_OK; 2600 } 2601 2602 2603 static uint16_t bios_parser_pack_data_tables( 2604 struct dc_bios *dcb, 2605 void *dst) 2606 { 2607 #ifdef PACK_BIOS_DATA 2608 struct bios_parser *bp = BP_FROM_DCB(dcb); 2609 struct atom_rom_header_v2_2 *rom_header = NULL; 2610 struct atom_rom_header_v2_2 *packed_rom_header = NULL; 2611 struct atom_common_table_header *data_tbl_header = NULL; 2612 struct atom_master_list_of_data_tables_v2_1 *data_tbl_list = NULL; 2613 struct atom_master_data_table_v2_1 *packed_master_data_tbl = NULL; 2614 struct atom_data_revision tbl_rev = {0}; 2615 uint16_t *rom_header_offset = NULL; 2616 const uint8_t *bios = bp->base.bios; 2617 uint8_t *bios_dst = (uint8_t *)dst; 2618 uint16_t packed_rom_header_offset; 2619 uint16_t packed_masterdatatable_offset; 2620 uint16_t packed_data_tbl_offset; 2621 uint16_t data_tbl_offset; 2622 unsigned int i; 2623 2624 rom_header_offset = 2625 GET_IMAGE(uint16_t, OFFSET_TO_ATOM_ROM_HEADER_POINTER); 2626 2627 if (!rom_header_offset) 2628 return 0; 2629 2630 rom_header = GET_IMAGE(struct atom_rom_header_v2_2, *rom_header_offset); 2631 2632 if (!rom_header) 2633 return 0; 2634 2635 get_atom_data_table_revision(&rom_header->table_header, &tbl_rev); 2636 if (!(tbl_rev.major >= 2 && tbl_rev.minor >= 2)) 2637 return 0; 2638 2639 get_atom_data_table_revision(&bp->master_data_tbl->table_header, &tbl_rev); 2640 if (!(tbl_rev.major >= 2 && tbl_rev.minor >= 1)) 2641 return 0; 2642 2643 packed_rom_header_offset = 2644 OFFSET_TO_ATOM_ROM_HEADER_POINTER + sizeof(*rom_header_offset); 2645 2646 packed_masterdatatable_offset = 2647 packed_rom_header_offset + rom_header->table_header.structuresize; 2648 2649 packed_data_tbl_offset = 2650 packed_masterdatatable_offset + 2651 bp->master_data_tbl->table_header.structuresize; 2652 2653 packed_rom_header = 2654 (struct atom_rom_header_v2_2 *)(bios_dst + packed_rom_header_offset); 2655 2656 packed_master_data_tbl = 2657 (struct atom_master_data_table_v2_1 *)(bios_dst + 2658 packed_masterdatatable_offset); 2659 2660 memcpy(bios_dst, bios, OFFSET_TO_ATOM_ROM_HEADER_POINTER); 2661 2662 *((uint16_t *)(bios_dst + OFFSET_TO_ATOM_ROM_HEADER_POINTER)) = 2663 packed_rom_header_offset; 2664 2665 memcpy(bios_dst + packed_rom_header_offset, rom_header, 2666 rom_header->table_header.structuresize); 2667 2668 packed_rom_header->masterdatatable_offset = packed_masterdatatable_offset; 2669 2670 memcpy(&packed_master_data_tbl->table_header, 2671 &bp->master_data_tbl->table_header, 2672 sizeof(bp->master_data_tbl->table_header)); 2673 2674 data_tbl_list = &bp->master_data_tbl->listOfdatatables; 2675 2676 /* Each data table offset in data table list is 2 bytes, 2677 * we can use that to iterate through listOfdatatables 2678 * without knowing the name of each member. 2679 */ 2680 for (i = 0; i < sizeof(*data_tbl_list)/sizeof(uint16_t); i++) { 2681 data_tbl_offset = *((uint16_t *)data_tbl_list + i); 2682 2683 if (data_tbl_offset) { 2684 data_tbl_header = 2685 (struct atom_common_table_header *)(bios + data_tbl_offset); 2686 2687 memcpy(bios_dst + packed_data_tbl_offset, data_tbl_header, 2688 data_tbl_header->structuresize); 2689 2690 *((uint16_t *)&packed_master_data_tbl->listOfdatatables + i) = 2691 packed_data_tbl_offset; 2692 2693 packed_data_tbl_offset += data_tbl_header->structuresize; 2694 } else { 2695 *((uint16_t *)&packed_master_data_tbl->listOfdatatables + i) = 0; 2696 } 2697 } 2698 return packed_data_tbl_offset; 2699 #endif 2700 // TODO: There is data bytes alignment issue, disable it for now. 2701 return 0; 2702 } 2703 2704 static struct atom_dc_golden_table_v1 *bios_get_golden_table( 2705 struct bios_parser *bp, 2706 uint32_t rev_major, 2707 uint32_t rev_minor, 2708 uint16_t *dc_golden_table_ver) 2709 { 2710 struct atom_display_controller_info_v4_4 *disp_cntl_tbl_4_4 = NULL; 2711 uint32_t dc_golden_offset = 0; 2712 *dc_golden_table_ver = 0; 2713 2714 if (!DATA_TABLES(dce_info)) 2715 return NULL; 2716 2717 /* ver.4.4 or higher */ 2718 switch (rev_major) { 2719 case 4: 2720 switch (rev_minor) { 2721 case 4: 2722 disp_cntl_tbl_4_4 = GET_IMAGE(struct atom_display_controller_info_v4_4, 2723 DATA_TABLES(dce_info)); 2724 if (!disp_cntl_tbl_4_4) 2725 return NULL; 2726 dc_golden_offset = DATA_TABLES(dce_info) + disp_cntl_tbl_4_4->dc_golden_table_offset; 2727 *dc_golden_table_ver = disp_cntl_tbl_4_4->dc_golden_table_ver; 2728 break; 2729 } 2730 break; 2731 } 2732 2733 if (!dc_golden_offset) 2734 return NULL; 2735 2736 if (*dc_golden_table_ver != 1) 2737 return NULL; 2738 2739 return GET_IMAGE(struct atom_dc_golden_table_v1, 2740 dc_golden_offset); 2741 } 2742 2743 static enum bp_result bios_get_atom_dc_golden_table( 2744 struct dc_bios *dcb) 2745 { 2746 struct bios_parser *bp = BP_FROM_DCB(dcb); 2747 enum bp_result result = BP_RESULT_OK; 2748 struct atom_dc_golden_table_v1 *atom_dc_golden_table = NULL; 2749 struct atom_common_table_header *header; 2750 struct atom_data_revision tbl_revision; 2751 uint16_t dc_golden_table_ver = 0; 2752 2753 header = GET_IMAGE(struct atom_common_table_header, 2754 DATA_TABLES(dce_info)); 2755 if (!header) 2756 return BP_RESULT_UNSUPPORTED; 2757 2758 get_atom_data_table_revision(header, &tbl_revision); 2759 2760 atom_dc_golden_table = bios_get_golden_table(bp, 2761 tbl_revision.major, 2762 tbl_revision.minor, 2763 &dc_golden_table_ver); 2764 2765 if (!atom_dc_golden_table) 2766 return BP_RESULT_UNSUPPORTED; 2767 2768 dcb->golden_table.dc_golden_table_ver = dc_golden_table_ver; 2769 dcb->golden_table.aux_dphy_rx_control0_val = atom_dc_golden_table->aux_dphy_rx_control0_val; 2770 dcb->golden_table.aux_dphy_rx_control1_val = atom_dc_golden_table->aux_dphy_rx_control1_val; 2771 dcb->golden_table.aux_dphy_tx_control_val = atom_dc_golden_table->aux_dphy_tx_control_val; 2772 dcb->golden_table.dc_gpio_aux_ctrl_0_val = atom_dc_golden_table->dc_gpio_aux_ctrl_0_val; 2773 dcb->golden_table.dc_gpio_aux_ctrl_1_val = atom_dc_golden_table->dc_gpio_aux_ctrl_1_val; 2774 dcb->golden_table.dc_gpio_aux_ctrl_2_val = atom_dc_golden_table->dc_gpio_aux_ctrl_2_val; 2775 dcb->golden_table.dc_gpio_aux_ctrl_3_val = atom_dc_golden_table->dc_gpio_aux_ctrl_3_val; 2776 dcb->golden_table.dc_gpio_aux_ctrl_4_val = atom_dc_golden_table->dc_gpio_aux_ctrl_4_val; 2777 dcb->golden_table.dc_gpio_aux_ctrl_5_val = atom_dc_golden_table->dc_gpio_aux_ctrl_5_val; 2778 2779 return result; 2780 } 2781 2782 2783 static const struct dc_vbios_funcs vbios_funcs = { 2784 .get_connectors_number = bios_parser_get_connectors_number, 2785 2786 .get_connector_id = bios_parser_get_connector_id, 2787 2788 .get_src_obj = bios_parser_get_src_obj, 2789 2790 .get_i2c_info = bios_parser_get_i2c_info, 2791 2792 .get_hpd_info = bios_parser_get_hpd_info, 2793 2794 .get_device_tag = bios_parser_get_device_tag, 2795 2796 .get_spread_spectrum_info = bios_parser_get_spread_spectrum_info, 2797 2798 .get_ss_entry_number = bios_parser_get_ss_entry_number, 2799 2800 .get_embedded_panel_info = bios_parser_get_embedded_panel_info, 2801 2802 .get_gpio_pin_info = bios_parser_get_gpio_pin_info, 2803 2804 .get_encoder_cap_info = bios_parser_get_encoder_cap_info, 2805 2806 .is_device_id_supported = bios_parser_is_device_id_supported, 2807 2808 .is_accelerated_mode = bios_parser_is_accelerated_mode, 2809 2810 .set_scratch_critical_state = bios_parser_set_scratch_critical_state, 2811 2812 2813 /* COMMANDS */ 2814 .encoder_control = bios_parser_encoder_control, 2815 2816 .transmitter_control = bios_parser_transmitter_control, 2817 2818 .enable_crtc = bios_parser_enable_crtc, 2819 2820 .set_pixel_clock = bios_parser_set_pixel_clock, 2821 2822 .set_dce_clock = bios_parser_set_dce_clock, 2823 2824 .program_crtc_timing = bios_parser_program_crtc_timing, 2825 2826 .enable_disp_power_gating = bios_parser_enable_disp_power_gating, 2827 2828 .bios_parser_destroy = firmware_parser_destroy, 2829 2830 .get_board_layout_info = bios_get_board_layout_info, 2831 .pack_data_tables = bios_parser_pack_data_tables, 2832 2833 .get_atom_dc_golden_table = bios_get_atom_dc_golden_table, 2834 2835 .enable_lvtma_control = bios_parser_enable_lvtma_control, 2836 2837 .get_soc_bb_info = bios_parser_get_soc_bb_info, 2838 2839 .get_disp_connector_caps_info = bios_parser_get_disp_connector_caps_info, 2840 2841 .get_lttpr_caps = bios_parser_get_lttpr_caps, 2842 2843 .get_lttpr_interop = bios_parser_get_lttpr_interop, 2844 }; 2845 2846 static bool bios_parser2_construct( 2847 struct bios_parser *bp, 2848 struct bp_init_data *init, 2849 enum dce_version dce_version) 2850 { 2851 uint16_t *rom_header_offset = NULL; 2852 struct atom_rom_header_v2_2 *rom_header = NULL; 2853 struct display_object_info_table_v1_4 *object_info_tbl; 2854 struct atom_data_revision tbl_rev = {0}; 2855 2856 if (!init) 2857 return false; 2858 2859 if (!init->bios) 2860 return false; 2861 2862 bp->base.funcs = &vbios_funcs; 2863 bp->base.bios = init->bios; 2864 bp->base.bios_size = bp->base.bios[OFFSET_TO_ATOM_ROM_IMAGE_SIZE] * BIOS_IMAGE_SIZE_UNIT; 2865 2866 bp->base.ctx = init->ctx; 2867 2868 bp->base.bios_local_image = NULL; 2869 2870 rom_header_offset = 2871 GET_IMAGE(uint16_t, OFFSET_TO_ATOM_ROM_HEADER_POINTER); 2872 2873 if (!rom_header_offset) 2874 return false; 2875 2876 rom_header = GET_IMAGE(struct atom_rom_header_v2_2, *rom_header_offset); 2877 2878 if (!rom_header) 2879 return false; 2880 2881 get_atom_data_table_revision(&rom_header->table_header, &tbl_rev); 2882 if (!(tbl_rev.major >= 2 && tbl_rev.minor >= 2)) 2883 return false; 2884 2885 bp->master_data_tbl = 2886 GET_IMAGE(struct atom_master_data_table_v2_1, 2887 rom_header->masterdatatable_offset); 2888 2889 if (!bp->master_data_tbl) 2890 return false; 2891 2892 bp->object_info_tbl_offset = DATA_TABLES(displayobjectinfo); 2893 2894 if (!bp->object_info_tbl_offset) 2895 return false; 2896 2897 object_info_tbl = 2898 GET_IMAGE(struct display_object_info_table_v1_4, 2899 bp->object_info_tbl_offset); 2900 2901 if (!object_info_tbl) 2902 return false; 2903 2904 get_atom_data_table_revision(&object_info_tbl->table_header, 2905 &bp->object_info_tbl.revision); 2906 2907 if (bp->object_info_tbl.revision.major == 1 2908 && bp->object_info_tbl.revision.minor >= 4) { 2909 struct display_object_info_table_v1_4 *tbl_v1_4; 2910 2911 tbl_v1_4 = GET_IMAGE(struct display_object_info_table_v1_4, 2912 bp->object_info_tbl_offset); 2913 if (!tbl_v1_4) 2914 return false; 2915 2916 bp->object_info_tbl.v1_4 = tbl_v1_4; 2917 } else 2918 return false; 2919 2920 dal_firmware_parser_init_cmd_tbl(bp); 2921 dal_bios_parser_init_cmd_tbl_helper2(&bp->cmd_helper, dce_version); 2922 2923 bp->base.integrated_info = bios_parser_create_integrated_info(&bp->base); 2924 bp->base.fw_info_valid = bios_parser_get_firmware_info(&bp->base, &bp->base.fw_info) == BP_RESULT_OK; 2925 bios_parser_get_vram_info(&bp->base, &bp->base.vram_info); 2926 2927 return true; 2928 } 2929 2930 struct dc_bios *firmware_parser_create( 2931 struct bp_init_data *init, 2932 enum dce_version dce_version) 2933 { 2934 struct bios_parser *bp = NULL; 2935 2936 bp = kzalloc(sizeof(struct bios_parser), GFP_KERNEL); 2937 if (!bp) 2938 return NULL; 2939 2940 if (bios_parser2_construct(bp, init, dce_version)) 2941 return &bp->base; 2942 2943 kfree(bp); 2944 return NULL; 2945 } 2946 2947 2948