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