bios_parser2.c 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  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. #include "dm_services.h"
  26. #include "ObjectID.h"
  27. #include "atomfirmware.h"
  28. #include "dc_bios_types.h"
  29. #include "include/grph_object_ctrl_defs.h"
  30. #include "include/bios_parser_interface.h"
  31. #include "include/i2caux_interface.h"
  32. #include "include/logger_interface.h"
  33. #include "command_table2.h"
  34. #include "bios_parser_helper.h"
  35. #include "command_table_helper2.h"
  36. #include "bios_parser2.h"
  37. #include "bios_parser_types_internal2.h"
  38. #include "bios_parser_interface.h"
  39. #include "bios_parser_common.h"
  40. #define LAST_RECORD_TYPE 0xff
  41. #define SMU9_SYSPLL0_ID 0
  42. struct i2c_id_config_access {
  43. uint8_t bfI2C_LineMux:4;
  44. uint8_t bfHW_EngineID:3;
  45. uint8_t bfHW_Capable:1;
  46. uint8_t ucAccess;
  47. };
  48. static enum bp_result get_gpio_i2c_info(struct bios_parser *bp,
  49. struct atom_i2c_record *record,
  50. struct graphics_object_i2c_info *info);
  51. static enum bp_result bios_parser_get_firmware_info(
  52. struct dc_bios *dcb,
  53. struct dc_firmware_info *info);
  54. static enum bp_result bios_parser_get_encoder_cap_info(
  55. struct dc_bios *dcb,
  56. struct graphics_object_id object_id,
  57. struct bp_encoder_cap_info *info);
  58. static enum bp_result get_firmware_info_v3_1(
  59. struct bios_parser *bp,
  60. struct dc_firmware_info *info);
  61. static enum bp_result get_firmware_info_v3_2(
  62. struct bios_parser *bp,
  63. struct dc_firmware_info *info);
  64. static struct atom_hpd_int_record *get_hpd_record(struct bios_parser *bp,
  65. struct atom_display_object_path_v2 *object);
  66. static struct atom_encoder_caps_record *get_encoder_cap_record(
  67. struct bios_parser *bp,
  68. struct atom_display_object_path_v2 *object);
  69. #define BIOS_IMAGE_SIZE_OFFSET 2
  70. #define BIOS_IMAGE_SIZE_UNIT 512
  71. #define DATA_TABLES(table) (bp->master_data_tbl->listOfdatatables.table)
  72. static void destruct(struct bios_parser *bp)
  73. {
  74. kfree(bp->base.bios_local_image);
  75. kfree(bp->base.integrated_info);
  76. }
  77. static void firmware_parser_destroy(struct dc_bios **dcb)
  78. {
  79. struct bios_parser *bp = BP_FROM_DCB(*dcb);
  80. if (!bp) {
  81. BREAK_TO_DEBUGGER();
  82. return;
  83. }
  84. destruct(bp);
  85. kfree(bp);
  86. *dcb = NULL;
  87. }
  88. static void get_atom_data_table_revision(
  89. struct atom_common_table_header *atom_data_tbl,
  90. struct atom_data_revision *tbl_revision)
  91. {
  92. if (!tbl_revision)
  93. return;
  94. /* initialize the revision to 0 which is invalid revision */
  95. tbl_revision->major = 0;
  96. tbl_revision->minor = 0;
  97. if (!atom_data_tbl)
  98. return;
  99. tbl_revision->major =
  100. (uint32_t) atom_data_tbl->format_revision & 0x3f;
  101. tbl_revision->minor =
  102. (uint32_t) atom_data_tbl->content_revision & 0x3f;
  103. }
  104. /* BIOS oject table displaypath is per connector.
  105. * There is extra path not for connector. BIOS fill its encoderid as 0
  106. */
  107. static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb)
  108. {
  109. struct bios_parser *bp = BP_FROM_DCB(dcb);
  110. unsigned int count = 0;
  111. unsigned int i;
  112. for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) {
  113. if (bp->object_info_tbl.v1_4->display_path[i].encoderobjid != 0)
  114. count++;
  115. }
  116. return count;
  117. }
  118. static struct graphics_object_id bios_parser_get_encoder_id(
  119. struct dc_bios *dcb,
  120. uint32_t i)
  121. {
  122. struct bios_parser *bp = BP_FROM_DCB(dcb);
  123. struct graphics_object_id object_id = dal_graphics_object_id_init(
  124. 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN);
  125. if (bp->object_info_tbl.v1_4->number_of_path > i)
  126. object_id = object_id_from_bios_object_id(
  127. bp->object_info_tbl.v1_4->display_path[i].encoderobjid);
  128. return object_id;
  129. }
  130. static struct graphics_object_id bios_parser_get_connector_id(
  131. struct dc_bios *dcb,
  132. uint8_t i)
  133. {
  134. struct bios_parser *bp = BP_FROM_DCB(dcb);
  135. struct graphics_object_id object_id = dal_graphics_object_id_init(
  136. 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN);
  137. struct object_info_table *tbl = &bp->object_info_tbl;
  138. struct display_object_info_table_v1_4 *v1_4 = tbl->v1_4;
  139. if (v1_4->number_of_path > i) {
  140. /* If display_objid is generic object id, the encoderObj
  141. * /extencoderobjId should be 0
  142. */
  143. if (v1_4->display_path[i].encoderobjid != 0 &&
  144. v1_4->display_path[i].display_objid != 0)
  145. object_id = object_id_from_bios_object_id(
  146. v1_4->display_path[i].display_objid);
  147. }
  148. return object_id;
  149. }
  150. /* TODO: GetNumberOfSrc*/
  151. static uint32_t bios_parser_get_dst_number(struct dc_bios *dcb,
  152. struct graphics_object_id id)
  153. {
  154. /* connector has 1 Dest, encoder has 0 Dest */
  155. switch (id.type) {
  156. case OBJECT_TYPE_ENCODER:
  157. return 0;
  158. case OBJECT_TYPE_CONNECTOR:
  159. return 1;
  160. default:
  161. return 0;
  162. }
  163. }
  164. /* removed getSrcObjList, getDestObjList*/
  165. static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb,
  166. struct graphics_object_id object_id, uint32_t index,
  167. struct graphics_object_id *src_object_id)
  168. {
  169. struct bios_parser *bp = BP_FROM_DCB(dcb);
  170. unsigned int i;
  171. enum bp_result bp_result = BP_RESULT_BADINPUT;
  172. struct graphics_object_id obj_id = {0};
  173. struct object_info_table *tbl = &bp->object_info_tbl;
  174. if (!src_object_id)
  175. return bp_result;
  176. switch (object_id.type) {
  177. /* Encoder's Source is GPU. BIOS does not provide GPU, since all
  178. * displaypaths point to same GPU (0x1100). Hardcode GPU object type
  179. */
  180. case OBJECT_TYPE_ENCODER:
  181. /* TODO: since num of src must be less than 2.
  182. * If found in for loop, should break.
  183. * DAL2 implementation may be changed too
  184. */
  185. for (i = 0; i < tbl->v1_4->number_of_path; i++) {
  186. obj_id = object_id_from_bios_object_id(
  187. tbl->v1_4->display_path[i].encoderobjid);
  188. if (object_id.type == obj_id.type &&
  189. object_id.id == obj_id.id &&
  190. object_id.enum_id ==
  191. obj_id.enum_id) {
  192. *src_object_id =
  193. object_id_from_bios_object_id(0x1100);
  194. /* break; */
  195. }
  196. }
  197. bp_result = BP_RESULT_OK;
  198. break;
  199. case OBJECT_TYPE_CONNECTOR:
  200. for (i = 0; i < tbl->v1_4->number_of_path; i++) {
  201. obj_id = object_id_from_bios_object_id(
  202. tbl->v1_4->display_path[i].display_objid);
  203. if (object_id.type == obj_id.type &&
  204. object_id.id == obj_id.id &&
  205. object_id.enum_id == obj_id.enum_id) {
  206. *src_object_id =
  207. object_id_from_bios_object_id(
  208. tbl->v1_4->display_path[i].encoderobjid);
  209. /* break; */
  210. }
  211. }
  212. bp_result = BP_RESULT_OK;
  213. break;
  214. default:
  215. break;
  216. }
  217. return bp_result;
  218. }
  219. static enum bp_result bios_parser_get_dst_obj(struct dc_bios *dcb,
  220. struct graphics_object_id object_id, uint32_t index,
  221. struct graphics_object_id *dest_object_id)
  222. {
  223. struct bios_parser *bp = BP_FROM_DCB(dcb);
  224. unsigned int i;
  225. enum bp_result bp_result = BP_RESULT_BADINPUT;
  226. struct graphics_object_id obj_id = {0};
  227. struct object_info_table *tbl = &bp->object_info_tbl;
  228. if (!dest_object_id)
  229. return BP_RESULT_BADINPUT;
  230. switch (object_id.type) {
  231. case OBJECT_TYPE_ENCODER:
  232. /* TODO: since num of src must be less than 2.
  233. * If found in for loop, should break.
  234. * DAL2 implementation may be changed too
  235. */
  236. for (i = 0; i < tbl->v1_4->number_of_path; i++) {
  237. obj_id = object_id_from_bios_object_id(
  238. tbl->v1_4->display_path[i].encoderobjid);
  239. if (object_id.type == obj_id.type &&
  240. object_id.id == obj_id.id &&
  241. object_id.enum_id ==
  242. obj_id.enum_id) {
  243. *dest_object_id =
  244. object_id_from_bios_object_id(
  245. tbl->v1_4->display_path[i].display_objid);
  246. /* break; */
  247. }
  248. }
  249. bp_result = BP_RESULT_OK;
  250. break;
  251. default:
  252. break;
  253. }
  254. return bp_result;
  255. }
  256. /* from graphics_object_id, find display path which includes the object_id */
  257. static struct atom_display_object_path_v2 *get_bios_object(
  258. struct bios_parser *bp,
  259. struct graphics_object_id id)
  260. {
  261. unsigned int i;
  262. struct graphics_object_id obj_id = {0};
  263. switch (id.type) {
  264. case OBJECT_TYPE_ENCODER:
  265. for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) {
  266. obj_id = object_id_from_bios_object_id(
  267. bp->object_info_tbl.v1_4->display_path[i].encoderobjid);
  268. if (id.type == obj_id.type &&
  269. id.id == obj_id.id &&
  270. id.enum_id == obj_id.enum_id)
  271. return
  272. &bp->object_info_tbl.v1_4->display_path[i];
  273. }
  274. case OBJECT_TYPE_CONNECTOR:
  275. case OBJECT_TYPE_GENERIC:
  276. /* Both Generic and Connector Object ID
  277. * will be stored on display_objid
  278. */
  279. for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) {
  280. obj_id = object_id_from_bios_object_id(
  281. bp->object_info_tbl.v1_4->display_path[i].display_objid
  282. );
  283. if (id.type == obj_id.type &&
  284. id.id == obj_id.id &&
  285. id.enum_id == obj_id.enum_id)
  286. return
  287. &bp->object_info_tbl.v1_4->display_path[i];
  288. }
  289. default:
  290. return NULL;
  291. }
  292. }
  293. static enum bp_result bios_parser_get_i2c_info(struct dc_bios *dcb,
  294. struct graphics_object_id id,
  295. struct graphics_object_i2c_info *info)
  296. {
  297. uint32_t offset;
  298. struct atom_display_object_path_v2 *object;
  299. struct atom_common_record_header *header;
  300. struct atom_i2c_record *record;
  301. struct bios_parser *bp = BP_FROM_DCB(dcb);
  302. if (!info)
  303. return BP_RESULT_BADINPUT;
  304. object = get_bios_object(bp, id);
  305. if (!object)
  306. return BP_RESULT_BADINPUT;
  307. offset = object->disp_recordoffset + bp->object_info_tbl_offset;
  308. for (;;) {
  309. header = GET_IMAGE(struct atom_common_record_header, offset);
  310. if (!header)
  311. return BP_RESULT_BADBIOSTABLE;
  312. if (header->record_type == LAST_RECORD_TYPE ||
  313. !header->record_size)
  314. break;
  315. if (header->record_type == ATOM_I2C_RECORD_TYPE
  316. && sizeof(struct atom_i2c_record) <=
  317. header->record_size) {
  318. /* get the I2C info */
  319. record = (struct atom_i2c_record *) header;
  320. if (get_gpio_i2c_info(bp, record, info) ==
  321. BP_RESULT_OK)
  322. return BP_RESULT_OK;
  323. }
  324. offset += header->record_size;
  325. }
  326. return BP_RESULT_NORECORD;
  327. }
  328. static enum bp_result get_gpio_i2c_info(
  329. struct bios_parser *bp,
  330. struct atom_i2c_record *record,
  331. struct graphics_object_i2c_info *info)
  332. {
  333. struct atom_gpio_pin_lut_v2_1 *header;
  334. uint32_t count = 0;
  335. unsigned int table_index = 0;
  336. if (!info)
  337. return BP_RESULT_BADINPUT;
  338. /* get the GPIO_I2C info */
  339. if (!DATA_TABLES(gpio_pin_lut))
  340. return BP_RESULT_BADBIOSTABLE;
  341. header = GET_IMAGE(struct atom_gpio_pin_lut_v2_1,
  342. DATA_TABLES(gpio_pin_lut));
  343. if (!header)
  344. return BP_RESULT_BADBIOSTABLE;
  345. if (sizeof(struct atom_common_table_header) +
  346. sizeof(struct atom_gpio_pin_assignment) >
  347. le16_to_cpu(header->table_header.structuresize))
  348. return BP_RESULT_BADBIOSTABLE;
  349. /* TODO: is version change? */
  350. if (header->table_header.content_revision != 1)
  351. return BP_RESULT_UNSUPPORTED;
  352. /* get data count */
  353. count = (le16_to_cpu(header->table_header.structuresize)
  354. - sizeof(struct atom_common_table_header))
  355. / sizeof(struct atom_gpio_pin_assignment);
  356. table_index = record->i2c_id & I2C_HW_LANE_MUX;
  357. if (count < table_index) {
  358. bool find_valid = false;
  359. for (table_index = 0; table_index < count; table_index++) {
  360. if (((record->i2c_id & I2C_HW_CAP) == (
  361. header->gpio_pin[table_index].gpio_id &
  362. I2C_HW_CAP)) &&
  363. ((record->i2c_id & I2C_HW_ENGINE_ID_MASK) ==
  364. (header->gpio_pin[table_index].gpio_id &
  365. I2C_HW_ENGINE_ID_MASK)) &&
  366. ((record->i2c_id & I2C_HW_LANE_MUX) ==
  367. (header->gpio_pin[table_index].gpio_id &
  368. I2C_HW_LANE_MUX))) {
  369. /* still valid */
  370. find_valid = true;
  371. break;
  372. }
  373. }
  374. /* If we don't find the entry that we are looking for then
  375. * we will return BP_Result_BadBiosTable.
  376. */
  377. if (find_valid == false)
  378. return BP_RESULT_BADBIOSTABLE;
  379. }
  380. /* get the GPIO_I2C_INFO */
  381. info->i2c_hw_assist = (record->i2c_id & I2C_HW_CAP) ? true : false;
  382. info->i2c_line = record->i2c_id & I2C_HW_LANE_MUX;
  383. info->i2c_engine_id = (record->i2c_id & I2C_HW_ENGINE_ID_MASK) >> 4;
  384. info->i2c_slave_address = record->i2c_slave_addr;
  385. /* TODO: check how to get register offset for en, Y, etc. */
  386. info->gpio_info.clk_a_register_index =
  387. le16_to_cpu(
  388. header->gpio_pin[table_index].data_a_reg_index);
  389. info->gpio_info.clk_a_shift =
  390. header->gpio_pin[table_index].gpio_bitshift;
  391. return BP_RESULT_OK;
  392. }
  393. static enum bp_result get_voltage_ddc_info_v4(
  394. uint8_t *i2c_line,
  395. uint32_t index,
  396. struct atom_common_table_header *header,
  397. uint8_t *address)
  398. {
  399. enum bp_result result = BP_RESULT_NORECORD;
  400. struct atom_voltage_objects_info_v4_1 *info =
  401. (struct atom_voltage_objects_info_v4_1 *) address;
  402. uint8_t *voltage_current_object =
  403. (uint8_t *) (&(info->voltage_object[0]));
  404. while ((address + le16_to_cpu(header->structuresize)) >
  405. voltage_current_object) {
  406. struct atom_i2c_voltage_object_v4 *object =
  407. (struct atom_i2c_voltage_object_v4 *)
  408. voltage_current_object;
  409. if (object->header.voltage_mode ==
  410. ATOM_INIT_VOLTAGE_REGULATOR) {
  411. if (object->header.voltage_type == index) {
  412. *i2c_line = object->i2c_id ^ 0x90;
  413. result = BP_RESULT_OK;
  414. break;
  415. }
  416. }
  417. voltage_current_object +=
  418. le16_to_cpu(object->header.object_size);
  419. }
  420. return result;
  421. }
  422. static enum bp_result bios_parser_get_thermal_ddc_info(
  423. struct dc_bios *dcb,
  424. uint32_t i2c_channel_id,
  425. struct graphics_object_i2c_info *info)
  426. {
  427. struct bios_parser *bp = BP_FROM_DCB(dcb);
  428. struct i2c_id_config_access *config;
  429. struct atom_i2c_record record;
  430. if (!info)
  431. return BP_RESULT_BADINPUT;
  432. config = (struct i2c_id_config_access *) &i2c_channel_id;
  433. record.i2c_id = config->bfHW_Capable;
  434. record.i2c_id |= config->bfI2C_LineMux;
  435. record.i2c_id |= config->bfHW_EngineID;
  436. return get_gpio_i2c_info(bp, &record, info);
  437. }
  438. static enum bp_result bios_parser_get_voltage_ddc_info(struct dc_bios *dcb,
  439. uint32_t index,
  440. struct graphics_object_i2c_info *info)
  441. {
  442. uint8_t i2c_line = 0;
  443. enum bp_result result = BP_RESULT_NORECORD;
  444. uint8_t *voltage_info_address;
  445. struct atom_common_table_header *header;
  446. struct atom_data_revision revision = {0};
  447. struct bios_parser *bp = BP_FROM_DCB(dcb);
  448. if (!DATA_TABLES(voltageobject_info))
  449. return result;
  450. voltage_info_address = bios_get_image(&bp->base,
  451. DATA_TABLES(voltageobject_info),
  452. sizeof(struct atom_common_table_header));
  453. header = (struct atom_common_table_header *) voltage_info_address;
  454. get_atom_data_table_revision(header, &revision);
  455. switch (revision.major) {
  456. case 4:
  457. if (revision.minor != 1)
  458. break;
  459. result = get_voltage_ddc_info_v4(&i2c_line, index, header,
  460. voltage_info_address);
  461. break;
  462. }
  463. if (result == BP_RESULT_OK)
  464. result = bios_parser_get_thermal_ddc_info(dcb,
  465. i2c_line, info);
  466. return result;
  467. }
  468. static enum bp_result bios_parser_get_hpd_info(
  469. struct dc_bios *dcb,
  470. struct graphics_object_id id,
  471. struct graphics_object_hpd_info *info)
  472. {
  473. struct bios_parser *bp = BP_FROM_DCB(dcb);
  474. struct atom_display_object_path_v2 *object;
  475. struct atom_hpd_int_record *record = NULL;
  476. if (!info)
  477. return BP_RESULT_BADINPUT;
  478. object = get_bios_object(bp, id);
  479. if (!object)
  480. return BP_RESULT_BADINPUT;
  481. record = get_hpd_record(bp, object);
  482. if (record != NULL) {
  483. info->hpd_int_gpio_uid = record->pin_id;
  484. info->hpd_active = record->plugin_pin_state;
  485. return BP_RESULT_OK;
  486. }
  487. return BP_RESULT_NORECORD;
  488. }
  489. static struct atom_hpd_int_record *get_hpd_record(
  490. struct bios_parser *bp,
  491. struct atom_display_object_path_v2 *object)
  492. {
  493. struct atom_common_record_header *header;
  494. uint32_t offset;
  495. if (!object) {
  496. BREAK_TO_DEBUGGER(); /* Invalid object */
  497. return NULL;
  498. }
  499. offset = le16_to_cpu(object->disp_recordoffset)
  500. + bp->object_info_tbl_offset;
  501. for (;;) {
  502. header = GET_IMAGE(struct atom_common_record_header, offset);
  503. if (!header)
  504. return NULL;
  505. if (header->record_type == LAST_RECORD_TYPE ||
  506. !header->record_size)
  507. break;
  508. if (header->record_type == ATOM_HPD_INT_RECORD_TYPE
  509. && sizeof(struct atom_hpd_int_record) <=
  510. header->record_size)
  511. return (struct atom_hpd_int_record *) header;
  512. offset += header->record_size;
  513. }
  514. return NULL;
  515. }
  516. /**
  517. * bios_parser_get_gpio_pin_info
  518. * Get GpioPin information of input gpio id
  519. *
  520. * @param gpio_id, GPIO ID
  521. * @param info, GpioPin information structure
  522. * @return Bios parser result code
  523. * @note
  524. * to get the GPIO PIN INFO, we need:
  525. * 1. get the GPIO_ID from other object table, see GetHPDInfo()
  526. * 2. in DATA_TABLE.GPIO_Pin_LUT, search all records,
  527. * to get the registerA offset/mask
  528. */
  529. static enum bp_result bios_parser_get_gpio_pin_info(
  530. struct dc_bios *dcb,
  531. uint32_t gpio_id,
  532. struct gpio_pin_info *info)
  533. {
  534. struct bios_parser *bp = BP_FROM_DCB(dcb);
  535. struct atom_gpio_pin_lut_v2_1 *header;
  536. uint32_t count = 0;
  537. uint32_t i = 0;
  538. if (!DATA_TABLES(gpio_pin_lut))
  539. return BP_RESULT_BADBIOSTABLE;
  540. header = GET_IMAGE(struct atom_gpio_pin_lut_v2_1,
  541. DATA_TABLES(gpio_pin_lut));
  542. if (!header)
  543. return BP_RESULT_BADBIOSTABLE;
  544. if (sizeof(struct atom_common_table_header) +
  545. sizeof(struct atom_gpio_pin_lut_v2_1)
  546. > le16_to_cpu(header->table_header.structuresize))
  547. return BP_RESULT_BADBIOSTABLE;
  548. if (header->table_header.content_revision != 1)
  549. return BP_RESULT_UNSUPPORTED;
  550. /* Temporary hard code gpio pin info */
  551. #if defined(FOR_SIMNOW_BOOT)
  552. {
  553. struct atom_gpio_pin_assignment gpio_pin[8] = {
  554. {0x5db5, 0, 0, 1, 0},
  555. {0x5db5, 8, 8, 2, 0},
  556. {0x5db5, 0x10, 0x10, 3, 0},
  557. {0x5db5, 0x18, 0x14, 4, 0},
  558. {0x5db5, 0x1A, 0x18, 5, 0},
  559. {0x5db5, 0x1C, 0x1C, 6, 0},
  560. };
  561. count = 6;
  562. memmove(header->gpio_pin, gpio_pin, sizeof(gpio_pin));
  563. }
  564. #else
  565. count = (le16_to_cpu(header->table_header.structuresize)
  566. - sizeof(struct atom_common_table_header))
  567. / sizeof(struct atom_gpio_pin_assignment);
  568. #endif
  569. for (i = 0; i < count; ++i) {
  570. if (header->gpio_pin[i].gpio_id != gpio_id)
  571. continue;
  572. info->offset =
  573. (uint32_t) le16_to_cpu(
  574. header->gpio_pin[i].data_a_reg_index);
  575. info->offset_y = info->offset + 2;
  576. info->offset_en = info->offset + 1;
  577. info->offset_mask = info->offset - 1;
  578. info->mask = (uint32_t) (1 <<
  579. header->gpio_pin[i].gpio_bitshift);
  580. info->mask_y = info->mask + 2;
  581. info->mask_en = info->mask + 1;
  582. info->mask_mask = info->mask - 1;
  583. return BP_RESULT_OK;
  584. }
  585. return BP_RESULT_NORECORD;
  586. }
  587. static struct device_id device_type_from_device_id(uint16_t device_id)
  588. {
  589. struct device_id result_device_id;
  590. result_device_id.raw_device_tag = device_id;
  591. switch (device_id) {
  592. case ATOM_DISPLAY_LCD1_SUPPORT:
  593. result_device_id.device_type = DEVICE_TYPE_LCD;
  594. result_device_id.enum_id = 1;
  595. break;
  596. case ATOM_DISPLAY_DFP1_SUPPORT:
  597. result_device_id.device_type = DEVICE_TYPE_DFP;
  598. result_device_id.enum_id = 1;
  599. break;
  600. case ATOM_DISPLAY_DFP2_SUPPORT:
  601. result_device_id.device_type = DEVICE_TYPE_DFP;
  602. result_device_id.enum_id = 2;
  603. break;
  604. case ATOM_DISPLAY_DFP3_SUPPORT:
  605. result_device_id.device_type = DEVICE_TYPE_DFP;
  606. result_device_id.enum_id = 3;
  607. break;
  608. case ATOM_DISPLAY_DFP4_SUPPORT:
  609. result_device_id.device_type = DEVICE_TYPE_DFP;
  610. result_device_id.enum_id = 4;
  611. break;
  612. case ATOM_DISPLAY_DFP5_SUPPORT:
  613. result_device_id.device_type = DEVICE_TYPE_DFP;
  614. result_device_id.enum_id = 5;
  615. break;
  616. case ATOM_DISPLAY_DFP6_SUPPORT:
  617. result_device_id.device_type = DEVICE_TYPE_DFP;
  618. result_device_id.enum_id = 6;
  619. break;
  620. default:
  621. BREAK_TO_DEBUGGER(); /* Invalid device Id */
  622. result_device_id.device_type = DEVICE_TYPE_UNKNOWN;
  623. result_device_id.enum_id = 0;
  624. }
  625. return result_device_id;
  626. }
  627. static enum bp_result bios_parser_get_device_tag(
  628. struct dc_bios *dcb,
  629. struct graphics_object_id connector_object_id,
  630. uint32_t device_tag_index,
  631. struct connector_device_tag_info *info)
  632. {
  633. struct bios_parser *bp = BP_FROM_DCB(dcb);
  634. struct atom_display_object_path_v2 *object;
  635. if (!info)
  636. return BP_RESULT_BADINPUT;
  637. /* getBiosObject will return MXM object */
  638. object = get_bios_object(bp, connector_object_id);
  639. if (!object) {
  640. BREAK_TO_DEBUGGER(); /* Invalid object id */
  641. return BP_RESULT_BADINPUT;
  642. }
  643. info->acpi_device = 0; /* BIOS no longer provides this */
  644. info->dev_id = device_type_from_device_id(object->device_tag);
  645. return BP_RESULT_OK;
  646. }
  647. static enum bp_result get_ss_info_v4_1(
  648. struct bios_parser *bp,
  649. uint32_t id,
  650. uint32_t index,
  651. struct spread_spectrum_info *ss_info)
  652. {
  653. enum bp_result result = BP_RESULT_OK;
  654. struct atom_display_controller_info_v4_1 *disp_cntl_tbl = NULL;
  655. if (!ss_info)
  656. return BP_RESULT_BADINPUT;
  657. if (!DATA_TABLES(dce_info))
  658. return BP_RESULT_BADBIOSTABLE;
  659. disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_1,
  660. DATA_TABLES(dce_info));
  661. if (!disp_cntl_tbl)
  662. return BP_RESULT_BADBIOSTABLE;
  663. ss_info->type.STEP_AND_DELAY_INFO = false;
  664. ss_info->spread_percentage_divider = 1000;
  665. /* BIOS no longer uses target clock. Always enable for now */
  666. ss_info->target_clock_range = 0xffffffff;
  667. switch (id) {
  668. case AS_SIGNAL_TYPE_DVI:
  669. ss_info->spread_spectrum_percentage =
  670. disp_cntl_tbl->dvi_ss_percentage;
  671. ss_info->spread_spectrum_range =
  672. disp_cntl_tbl->dvi_ss_rate_10hz * 10;
  673. if (disp_cntl_tbl->dvi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE)
  674. ss_info->type.CENTER_MODE = true;
  675. break;
  676. case AS_SIGNAL_TYPE_HDMI:
  677. ss_info->spread_spectrum_percentage =
  678. disp_cntl_tbl->hdmi_ss_percentage;
  679. ss_info->spread_spectrum_range =
  680. disp_cntl_tbl->hdmi_ss_rate_10hz * 10;
  681. if (disp_cntl_tbl->hdmi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE)
  682. ss_info->type.CENTER_MODE = true;
  683. break;
  684. /* TODO LVDS not support anymore? */
  685. case AS_SIGNAL_TYPE_DISPLAY_PORT:
  686. ss_info->spread_spectrum_percentage =
  687. disp_cntl_tbl->dp_ss_percentage;
  688. ss_info->spread_spectrum_range =
  689. disp_cntl_tbl->dp_ss_rate_10hz * 10;
  690. if (disp_cntl_tbl->dp_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE)
  691. ss_info->type.CENTER_MODE = true;
  692. break;
  693. case AS_SIGNAL_TYPE_GPU_PLL:
  694. /* atom_firmware: DAL only get data from dce_info table.
  695. * if data within smu_info is needed for DAL, VBIOS should
  696. * copy it into dce_info
  697. */
  698. result = BP_RESULT_UNSUPPORTED;
  699. break;
  700. default:
  701. result = BP_RESULT_UNSUPPORTED;
  702. }
  703. return result;
  704. }
  705. static enum bp_result get_ss_info_v4_2(
  706. struct bios_parser *bp,
  707. uint32_t id,
  708. uint32_t index,
  709. struct spread_spectrum_info *ss_info)
  710. {
  711. enum bp_result result = BP_RESULT_OK;
  712. struct atom_display_controller_info_v4_2 *disp_cntl_tbl = NULL;
  713. struct atom_smu_info_v3_1 *smu_info = NULL;
  714. if (!ss_info)
  715. return BP_RESULT_BADINPUT;
  716. if (!DATA_TABLES(dce_info))
  717. return BP_RESULT_BADBIOSTABLE;
  718. if (!DATA_TABLES(smu_info))
  719. return BP_RESULT_BADBIOSTABLE;
  720. disp_cntl_tbl = GET_IMAGE(struct atom_display_controller_info_v4_2,
  721. DATA_TABLES(dce_info));
  722. if (!disp_cntl_tbl)
  723. return BP_RESULT_BADBIOSTABLE;
  724. smu_info = GET_IMAGE(struct atom_smu_info_v3_1, DATA_TABLES(smu_info));
  725. if (!smu_info)
  726. return BP_RESULT_BADBIOSTABLE;
  727. ss_info->type.STEP_AND_DELAY_INFO = false;
  728. ss_info->spread_percentage_divider = 1000;
  729. /* BIOS no longer uses target clock. Always enable for now */
  730. ss_info->target_clock_range = 0xffffffff;
  731. switch (id) {
  732. case AS_SIGNAL_TYPE_DVI:
  733. ss_info->spread_spectrum_percentage =
  734. disp_cntl_tbl->dvi_ss_percentage;
  735. ss_info->spread_spectrum_range =
  736. disp_cntl_tbl->dvi_ss_rate_10hz * 10;
  737. if (disp_cntl_tbl->dvi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE)
  738. ss_info->type.CENTER_MODE = true;
  739. break;
  740. case AS_SIGNAL_TYPE_HDMI:
  741. ss_info->spread_spectrum_percentage =
  742. disp_cntl_tbl->hdmi_ss_percentage;
  743. ss_info->spread_spectrum_range =
  744. disp_cntl_tbl->hdmi_ss_rate_10hz * 10;
  745. if (disp_cntl_tbl->hdmi_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE)
  746. ss_info->type.CENTER_MODE = true;
  747. break;
  748. /* TODO LVDS not support anymore? */
  749. case AS_SIGNAL_TYPE_DISPLAY_PORT:
  750. ss_info->spread_spectrum_percentage =
  751. smu_info->gpuclk_ss_percentage;
  752. ss_info->spread_spectrum_range =
  753. smu_info->gpuclk_ss_rate_10hz * 10;
  754. if (smu_info->gpuclk_ss_mode & ATOM_SS_CENTRE_SPREAD_MODE)
  755. ss_info->type.CENTER_MODE = true;
  756. break;
  757. case AS_SIGNAL_TYPE_GPU_PLL:
  758. /* atom_firmware: DAL only get data from dce_info table.
  759. * if data within smu_info is needed for DAL, VBIOS should
  760. * copy it into dce_info
  761. */
  762. result = BP_RESULT_UNSUPPORTED;
  763. break;
  764. default:
  765. result = BP_RESULT_UNSUPPORTED;
  766. }
  767. return result;
  768. }
  769. /**
  770. * bios_parser_get_spread_spectrum_info
  771. * Get spread spectrum information from the ASIC_InternalSS_Info(ver 2.1 or
  772. * ver 3.1) or SS_Info table from the VBIOS. Currently ASIC_InternalSS_Info
  773. * ver 2.1 can co-exist with SS_Info table. Expect ASIC_InternalSS_Info
  774. * ver 3.1,
  775. * there is only one entry for each signal /ss id. However, there is
  776. * no planning of supporting multiple spread Sprectum entry for EverGreen
  777. * @param [in] this
  778. * @param [in] signal, ASSignalType to be converted to info index
  779. * @param [in] index, number of entries that match the converted info index
  780. * @param [out] ss_info, sprectrum information structure,
  781. * @return Bios parser result code
  782. */
  783. static enum bp_result bios_parser_get_spread_spectrum_info(
  784. struct dc_bios *dcb,
  785. enum as_signal_type signal,
  786. uint32_t index,
  787. struct spread_spectrum_info *ss_info)
  788. {
  789. struct bios_parser *bp = BP_FROM_DCB(dcb);
  790. enum bp_result result = BP_RESULT_UNSUPPORTED;
  791. struct atom_common_table_header *header;
  792. struct atom_data_revision tbl_revision;
  793. if (!ss_info) /* check for bad input */
  794. return BP_RESULT_BADINPUT;
  795. if (!DATA_TABLES(dce_info))
  796. return BP_RESULT_UNSUPPORTED;
  797. header = GET_IMAGE(struct atom_common_table_header,
  798. DATA_TABLES(dce_info));
  799. get_atom_data_table_revision(header, &tbl_revision);
  800. switch (tbl_revision.major) {
  801. case 4:
  802. switch (tbl_revision.minor) {
  803. case 1:
  804. return get_ss_info_v4_1(bp, signal, index, ss_info);
  805. case 2:
  806. return get_ss_info_v4_2(bp, signal, index, ss_info);
  807. default:
  808. break;
  809. }
  810. break;
  811. default:
  812. break;
  813. }
  814. /* there can not be more then one entry for SS Info table */
  815. return result;
  816. }
  817. static enum bp_result get_embedded_panel_info_v2_1(
  818. struct bios_parser *bp,
  819. struct embedded_panel_info *info)
  820. {
  821. struct lcd_info_v2_1 *lvds;
  822. if (!info)
  823. return BP_RESULT_BADINPUT;
  824. if (!DATA_TABLES(lcd_info))
  825. return BP_RESULT_UNSUPPORTED;
  826. lvds = GET_IMAGE(struct lcd_info_v2_1, DATA_TABLES(lcd_info));
  827. if (!lvds)
  828. return BP_RESULT_BADBIOSTABLE;
  829. /* TODO: previous vv1_3, should v2_1 */
  830. if (!((lvds->table_header.format_revision == 2)
  831. && (lvds->table_header.content_revision >= 1)))
  832. return BP_RESULT_UNSUPPORTED;
  833. memset(info, 0, sizeof(struct embedded_panel_info));
  834. /* We need to convert from 10KHz units into KHz units */
  835. info->lcd_timing.pixel_clk =
  836. le16_to_cpu(lvds->lcd_timing.pixclk) * 10;
  837. /* usHActive does not include borders, according to VBIOS team */
  838. info->lcd_timing.horizontal_addressable =
  839. le16_to_cpu(lvds->lcd_timing.h_active);
  840. /* usHBlanking_Time includes borders, so we should really be
  841. * subtractingborders duing this translation, but LVDS generally
  842. * doesn't have borders, so we should be okay leaving this as is for
  843. * now. May need to revisit if we ever have LVDS with borders
  844. */
  845. info->lcd_timing.horizontal_blanking_time =
  846. le16_to_cpu(lvds->lcd_timing.h_blanking_time);
  847. /* usVActive does not include borders, according to VBIOS team*/
  848. info->lcd_timing.vertical_addressable =
  849. le16_to_cpu(lvds->lcd_timing.v_active);
  850. /* usVBlanking_Time includes borders, so we should really be
  851. * subtracting borders duing this translation, but LVDS generally
  852. * doesn't have borders, so we should be okay leaving this as is for
  853. * now. May need to revisit if we ever have LVDS with borders
  854. */
  855. info->lcd_timing.vertical_blanking_time =
  856. le16_to_cpu(lvds->lcd_timing.v_blanking_time);
  857. info->lcd_timing.horizontal_sync_offset =
  858. le16_to_cpu(lvds->lcd_timing.h_sync_offset);
  859. info->lcd_timing.horizontal_sync_width =
  860. le16_to_cpu(lvds->lcd_timing.h_sync_width);
  861. info->lcd_timing.vertical_sync_offset =
  862. le16_to_cpu(lvds->lcd_timing.v_sync_offset);
  863. info->lcd_timing.vertical_sync_width =
  864. le16_to_cpu(lvds->lcd_timing.v_syncwidth);
  865. info->lcd_timing.horizontal_border = lvds->lcd_timing.h_border;
  866. info->lcd_timing.vertical_border = lvds->lcd_timing.v_border;
  867. /* not provided by VBIOS */
  868. info->lcd_timing.misc_info.HORIZONTAL_CUT_OFF = 0;
  869. info->lcd_timing.misc_info.H_SYNC_POLARITY =
  870. ~(uint32_t)
  871. (lvds->lcd_timing.miscinfo & ATOM_HSYNC_POLARITY);
  872. info->lcd_timing.misc_info.V_SYNC_POLARITY =
  873. ~(uint32_t)
  874. (lvds->lcd_timing.miscinfo & ATOM_VSYNC_POLARITY);
  875. /* not provided by VBIOS */
  876. info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;
  877. info->lcd_timing.misc_info.H_REPLICATION_BY2 =
  878. !!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2);
  879. info->lcd_timing.misc_info.V_REPLICATION_BY2 =
  880. !!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2);
  881. info->lcd_timing.misc_info.COMPOSITE_SYNC =
  882. !!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC);
  883. info->lcd_timing.misc_info.INTERLACE =
  884. !!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE);
  885. /* not provided by VBIOS*/
  886. info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;
  887. /* not provided by VBIOS*/
  888. info->ss_id = 0;
  889. info->realtek_eDPToLVDS =
  890. !!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID);
  891. return BP_RESULT_OK;
  892. }
  893. static enum bp_result bios_parser_get_embedded_panel_info(
  894. struct dc_bios *dcb,
  895. struct embedded_panel_info *info)
  896. {
  897. struct bios_parser *bp = BP_FROM_DCB(dcb);
  898. struct atom_common_table_header *header;
  899. struct atom_data_revision tbl_revision;
  900. if (!DATA_TABLES(lcd_info))
  901. return BP_RESULT_FAILURE;
  902. header = GET_IMAGE(struct atom_common_table_header,
  903. DATA_TABLES(lcd_info));
  904. if (!header)
  905. return BP_RESULT_BADBIOSTABLE;
  906. get_atom_data_table_revision(header, &tbl_revision);
  907. switch (tbl_revision.major) {
  908. case 2:
  909. switch (tbl_revision.minor) {
  910. case 1:
  911. return get_embedded_panel_info_v2_1(bp, info);
  912. default:
  913. break;
  914. }
  915. default:
  916. break;
  917. }
  918. return BP_RESULT_FAILURE;
  919. }
  920. static uint32_t get_support_mask_for_device_id(struct device_id device_id)
  921. {
  922. enum dal_device_type device_type = device_id.device_type;
  923. uint32_t enum_id = device_id.enum_id;
  924. switch (device_type) {
  925. case DEVICE_TYPE_LCD:
  926. switch (enum_id) {
  927. case 1:
  928. return ATOM_DISPLAY_LCD1_SUPPORT;
  929. default:
  930. break;
  931. }
  932. break;
  933. case DEVICE_TYPE_DFP:
  934. switch (enum_id) {
  935. case 1:
  936. return ATOM_DISPLAY_DFP1_SUPPORT;
  937. case 2:
  938. return ATOM_DISPLAY_DFP2_SUPPORT;
  939. case 3:
  940. return ATOM_DISPLAY_DFP3_SUPPORT;
  941. case 4:
  942. return ATOM_DISPLAY_DFP4_SUPPORT;
  943. case 5:
  944. return ATOM_DISPLAY_DFP5_SUPPORT;
  945. case 6:
  946. return ATOM_DISPLAY_DFP6_SUPPORT;
  947. default:
  948. break;
  949. }
  950. break;
  951. default:
  952. break;
  953. };
  954. /* Unidentified device ID, return empty support mask. */
  955. return 0;
  956. }
  957. static bool bios_parser_is_device_id_supported(
  958. struct dc_bios *dcb,
  959. struct device_id id)
  960. {
  961. struct bios_parser *bp = BP_FROM_DCB(dcb);
  962. uint32_t mask = get_support_mask_for_device_id(id);
  963. return (le16_to_cpu(bp->object_info_tbl.v1_4->supporteddevices) &
  964. mask) != 0;
  965. }
  966. static void bios_parser_post_init(
  967. struct dc_bios *dcb)
  968. {
  969. /* TODO for OPM module. Need implement later */
  970. }
  971. static uint32_t bios_parser_get_ss_entry_number(
  972. struct dc_bios *dcb,
  973. enum as_signal_type signal)
  974. {
  975. /* TODO: DAL2 atomfirmware implementation does not need this.
  976. * why DAL3 need this?
  977. */
  978. return 1;
  979. }
  980. static enum bp_result bios_parser_transmitter_control(
  981. struct dc_bios *dcb,
  982. struct bp_transmitter_control *cntl)
  983. {
  984. struct bios_parser *bp = BP_FROM_DCB(dcb);
  985. if (!bp->cmd_tbl.transmitter_control)
  986. return BP_RESULT_FAILURE;
  987. return bp->cmd_tbl.transmitter_control(bp, cntl);
  988. }
  989. static enum bp_result bios_parser_encoder_control(
  990. struct dc_bios *dcb,
  991. struct bp_encoder_control *cntl)
  992. {
  993. struct bios_parser *bp = BP_FROM_DCB(dcb);
  994. if (!bp->cmd_tbl.dig_encoder_control)
  995. return BP_RESULT_FAILURE;
  996. return bp->cmd_tbl.dig_encoder_control(bp, cntl);
  997. }
  998. static enum bp_result bios_parser_set_pixel_clock(
  999. struct dc_bios *dcb,
  1000. struct bp_pixel_clock_parameters *bp_params)
  1001. {
  1002. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1003. if (!bp->cmd_tbl.set_pixel_clock)
  1004. return BP_RESULT_FAILURE;
  1005. return bp->cmd_tbl.set_pixel_clock(bp, bp_params);
  1006. }
  1007. static enum bp_result bios_parser_set_dce_clock(
  1008. struct dc_bios *dcb,
  1009. struct bp_set_dce_clock_parameters *bp_params)
  1010. {
  1011. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1012. if (!bp->cmd_tbl.set_dce_clock)
  1013. return BP_RESULT_FAILURE;
  1014. return bp->cmd_tbl.set_dce_clock(bp, bp_params);
  1015. }
  1016. static unsigned int bios_parser_get_smu_clock_info(
  1017. struct dc_bios *dcb)
  1018. {
  1019. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1020. if (!bp->cmd_tbl.get_smu_clock_info)
  1021. return BP_RESULT_FAILURE;
  1022. return bp->cmd_tbl.get_smu_clock_info(bp, 0);
  1023. }
  1024. static enum bp_result bios_parser_program_crtc_timing(
  1025. struct dc_bios *dcb,
  1026. struct bp_hw_crtc_timing_parameters *bp_params)
  1027. {
  1028. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1029. if (!bp->cmd_tbl.set_crtc_timing)
  1030. return BP_RESULT_FAILURE;
  1031. return bp->cmd_tbl.set_crtc_timing(bp, bp_params);
  1032. }
  1033. static enum bp_result bios_parser_enable_crtc(
  1034. struct dc_bios *dcb,
  1035. enum controller_id id,
  1036. bool enable)
  1037. {
  1038. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1039. if (!bp->cmd_tbl.enable_crtc)
  1040. return BP_RESULT_FAILURE;
  1041. return bp->cmd_tbl.enable_crtc(bp, id, enable);
  1042. }
  1043. static enum bp_result bios_parser_crtc_source_select(
  1044. struct dc_bios *dcb,
  1045. struct bp_crtc_source_select *bp_params)
  1046. {
  1047. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1048. if (!bp->cmd_tbl.select_crtc_source)
  1049. return BP_RESULT_FAILURE;
  1050. return bp->cmd_tbl.select_crtc_source(bp, bp_params);
  1051. }
  1052. static enum bp_result bios_parser_enable_disp_power_gating(
  1053. struct dc_bios *dcb,
  1054. enum controller_id controller_id,
  1055. enum bp_pipe_control_action action)
  1056. {
  1057. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1058. if (!bp->cmd_tbl.enable_disp_power_gating)
  1059. return BP_RESULT_FAILURE;
  1060. return bp->cmd_tbl.enable_disp_power_gating(bp, controller_id,
  1061. action);
  1062. }
  1063. static bool bios_parser_is_accelerated_mode(
  1064. struct dc_bios *dcb)
  1065. {
  1066. return bios_is_accelerated_mode(dcb);
  1067. }
  1068. static uint32_t bios_parser_get_vga_enabled_displays(
  1069. struct dc_bios *bios)
  1070. {
  1071. return bios_get_vga_enabled_displays(bios);
  1072. }
  1073. /**
  1074. * bios_parser_set_scratch_critical_state
  1075. *
  1076. * @brief
  1077. * update critical state bit in VBIOS scratch register
  1078. *
  1079. * @param
  1080. * bool - to set or reset state
  1081. */
  1082. static void bios_parser_set_scratch_critical_state(
  1083. struct dc_bios *dcb,
  1084. bool state)
  1085. {
  1086. bios_set_scratch_critical_state(dcb, state);
  1087. }
  1088. static enum bp_result bios_parser_get_firmware_info(
  1089. struct dc_bios *dcb,
  1090. struct dc_firmware_info *info)
  1091. {
  1092. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1093. enum bp_result result = BP_RESULT_BADBIOSTABLE;
  1094. struct atom_common_table_header *header;
  1095. struct atom_data_revision revision;
  1096. if (info && DATA_TABLES(firmwareinfo)) {
  1097. header = GET_IMAGE(struct atom_common_table_header,
  1098. DATA_TABLES(firmwareinfo));
  1099. get_atom_data_table_revision(header, &revision);
  1100. switch (revision.major) {
  1101. case 3:
  1102. switch (revision.minor) {
  1103. case 1:
  1104. result = get_firmware_info_v3_1(bp, info);
  1105. break;
  1106. case 2:
  1107. result = get_firmware_info_v3_2(bp, info);
  1108. break;
  1109. case 3:
  1110. result = get_firmware_info_v3_2(bp, info);
  1111. break;
  1112. default:
  1113. break;
  1114. }
  1115. break;
  1116. default:
  1117. break;
  1118. }
  1119. }
  1120. return result;
  1121. }
  1122. static enum bp_result get_firmware_info_v3_1(
  1123. struct bios_parser *bp,
  1124. struct dc_firmware_info *info)
  1125. {
  1126. struct atom_firmware_info_v3_1 *firmware_info;
  1127. struct atom_display_controller_info_v4_1 *dce_info = NULL;
  1128. if (!info)
  1129. return BP_RESULT_BADINPUT;
  1130. firmware_info = GET_IMAGE(struct atom_firmware_info_v3_1,
  1131. DATA_TABLES(firmwareinfo));
  1132. dce_info = GET_IMAGE(struct atom_display_controller_info_v4_1,
  1133. DATA_TABLES(dce_info));
  1134. if (!firmware_info || !dce_info)
  1135. return BP_RESULT_BADBIOSTABLE;
  1136. memset(info, 0, sizeof(*info));
  1137. /* Pixel clock pll information. */
  1138. /* We need to convert from 10KHz units into KHz units */
  1139. info->default_memory_clk = firmware_info->bootup_mclk_in10khz * 10;
  1140. info->default_engine_clk = firmware_info->bootup_sclk_in10khz * 10;
  1141. /* 27MHz for Vega10: */
  1142. info->pll_info.crystal_frequency = dce_info->dce_refclk_10khz * 10;
  1143. /* Hardcode frequency if BIOS gives no DCE Ref Clk */
  1144. if (info->pll_info.crystal_frequency == 0)
  1145. info->pll_info.crystal_frequency = 27000;
  1146. /*dp_phy_ref_clk is not correct for atom_display_controller_info_v4_2, but we don't use it*/
  1147. info->dp_phy_ref_clk = dce_info->dpphy_refclk_10khz * 10;
  1148. info->i2c_engine_ref_clk = dce_info->i2c_engine_refclk_10khz * 10;
  1149. /* Get GPU PLL VCO Clock */
  1150. if (bp->cmd_tbl.get_smu_clock_info != NULL) {
  1151. /* VBIOS gives in 10KHz */
  1152. info->smu_gpu_pll_output_freq =
  1153. bp->cmd_tbl.get_smu_clock_info(bp, SMU9_SYSPLL0_ID) * 10;
  1154. }
  1155. return BP_RESULT_OK;
  1156. }
  1157. static enum bp_result get_firmware_info_v3_2(
  1158. struct bios_parser *bp,
  1159. struct dc_firmware_info *info)
  1160. {
  1161. struct atom_firmware_info_v3_2 *firmware_info;
  1162. struct atom_display_controller_info_v4_1 *dce_info = NULL;
  1163. struct atom_common_table_header *header;
  1164. struct atom_data_revision revision;
  1165. struct atom_smu_info_v3_2 *smu_info_v3_2 = NULL;
  1166. struct atom_smu_info_v3_3 *smu_info_v3_3 = NULL;
  1167. if (!info)
  1168. return BP_RESULT_BADINPUT;
  1169. firmware_info = GET_IMAGE(struct atom_firmware_info_v3_2,
  1170. DATA_TABLES(firmwareinfo));
  1171. dce_info = GET_IMAGE(struct atom_display_controller_info_v4_1,
  1172. DATA_TABLES(dce_info));
  1173. if (!firmware_info || !dce_info)
  1174. return BP_RESULT_BADBIOSTABLE;
  1175. memset(info, 0, sizeof(*info));
  1176. header = GET_IMAGE(struct atom_common_table_header,
  1177. DATA_TABLES(smu_info));
  1178. get_atom_data_table_revision(header, &revision);
  1179. if (revision.minor == 2) {
  1180. /* Vega12 */
  1181. smu_info_v3_2 = GET_IMAGE(struct atom_smu_info_v3_2,
  1182. DATA_TABLES(smu_info));
  1183. if (!smu_info_v3_2)
  1184. return BP_RESULT_BADBIOSTABLE;
  1185. info->default_engine_clk = smu_info_v3_2->bootup_dcefclk_10khz * 10;
  1186. } else if (revision.minor == 3) {
  1187. /* Vega20 */
  1188. smu_info_v3_3 = GET_IMAGE(struct atom_smu_info_v3_3,
  1189. DATA_TABLES(smu_info));
  1190. if (!smu_info_v3_3)
  1191. return BP_RESULT_BADBIOSTABLE;
  1192. info->default_engine_clk = smu_info_v3_3->bootup_dcefclk_10khz * 10;
  1193. }
  1194. // We need to convert from 10KHz units into KHz units.
  1195. info->default_memory_clk = firmware_info->bootup_mclk_in10khz * 10;
  1196. /* 27MHz for Vega10 & Vega12; 100MHz for Vega20 */
  1197. info->pll_info.crystal_frequency = dce_info->dce_refclk_10khz * 10;
  1198. /* Hardcode frequency if BIOS gives no DCE Ref Clk */
  1199. if (info->pll_info.crystal_frequency == 0) {
  1200. if (revision.minor == 2)
  1201. info->pll_info.crystal_frequency = 27000;
  1202. else if (revision.minor == 3)
  1203. info->pll_info.crystal_frequency = 100000;
  1204. }
  1205. /*dp_phy_ref_clk is not correct for atom_display_controller_info_v4_2, but we don't use it*/
  1206. info->dp_phy_ref_clk = dce_info->dpphy_refclk_10khz * 10;
  1207. info->i2c_engine_ref_clk = dce_info->i2c_engine_refclk_10khz * 10;
  1208. /* Get GPU PLL VCO Clock */
  1209. if (bp->cmd_tbl.get_smu_clock_info != NULL) {
  1210. if (revision.minor == 2)
  1211. info->smu_gpu_pll_output_freq =
  1212. bp->cmd_tbl.get_smu_clock_info(bp, SMU9_SYSPLL0_ID) * 10;
  1213. else if (revision.minor == 3)
  1214. info->smu_gpu_pll_output_freq =
  1215. bp->cmd_tbl.get_smu_clock_info(bp, SMU11_SYSPLL3_0_ID) * 10;
  1216. }
  1217. return BP_RESULT_OK;
  1218. }
  1219. static enum bp_result bios_parser_get_encoder_cap_info(
  1220. struct dc_bios *dcb,
  1221. struct graphics_object_id object_id,
  1222. struct bp_encoder_cap_info *info)
  1223. {
  1224. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1225. struct atom_display_object_path_v2 *object;
  1226. struct atom_encoder_caps_record *record = NULL;
  1227. if (!info)
  1228. return BP_RESULT_BADINPUT;
  1229. object = get_bios_object(bp, object_id);
  1230. if (!object)
  1231. return BP_RESULT_BADINPUT;
  1232. record = get_encoder_cap_record(bp, object);
  1233. if (!record)
  1234. return BP_RESULT_NORECORD;
  1235. info->DP_HBR2_CAP = (record->encodercaps &
  1236. ATOM_ENCODER_CAP_RECORD_HBR2) ? 1 : 0;
  1237. info->DP_HBR2_EN = (record->encodercaps &
  1238. ATOM_ENCODER_CAP_RECORD_HBR2_EN) ? 1 : 0;
  1239. info->DP_HBR3_EN = (record->encodercaps &
  1240. ATOM_ENCODER_CAP_RECORD_HBR3_EN) ? 1 : 0;
  1241. info->HDMI_6GB_EN = (record->encodercaps &
  1242. ATOM_ENCODER_CAP_RECORD_HDMI6Gbps_EN) ? 1 : 0;
  1243. return BP_RESULT_OK;
  1244. }
  1245. static struct atom_encoder_caps_record *get_encoder_cap_record(
  1246. struct bios_parser *bp,
  1247. struct atom_display_object_path_v2 *object)
  1248. {
  1249. struct atom_common_record_header *header;
  1250. uint32_t offset;
  1251. if (!object) {
  1252. BREAK_TO_DEBUGGER(); /* Invalid object */
  1253. return NULL;
  1254. }
  1255. offset = object->encoder_recordoffset + bp->object_info_tbl_offset;
  1256. for (;;) {
  1257. header = GET_IMAGE(struct atom_common_record_header, offset);
  1258. if (!header)
  1259. return NULL;
  1260. offset += header->record_size;
  1261. if (header->record_type == LAST_RECORD_TYPE ||
  1262. !header->record_size)
  1263. break;
  1264. if (header->record_type != ATOM_ENCODER_CAP_RECORD_TYPE)
  1265. continue;
  1266. if (sizeof(struct atom_encoder_caps_record) <=
  1267. header->record_size)
  1268. return (struct atom_encoder_caps_record *)header;
  1269. }
  1270. return NULL;
  1271. }
  1272. /*
  1273. * get_integrated_info_v11
  1274. *
  1275. * @brief
  1276. * Get V8 integrated BIOS information
  1277. *
  1278. * @param
  1279. * bios_parser *bp - [in]BIOS parser handler to get master data table
  1280. * integrated_info *info - [out] store and output integrated info
  1281. *
  1282. * @return
  1283. * enum bp_result - BP_RESULT_OK if information is available,
  1284. * BP_RESULT_BADBIOSTABLE otherwise.
  1285. */
  1286. static enum bp_result get_integrated_info_v11(
  1287. struct bios_parser *bp,
  1288. struct integrated_info *info)
  1289. {
  1290. struct atom_integrated_system_info_v1_11 *info_v11;
  1291. uint32_t i;
  1292. info_v11 = GET_IMAGE(struct atom_integrated_system_info_v1_11,
  1293. DATA_TABLES(integratedsysteminfo));
  1294. if (info_v11 == NULL)
  1295. return BP_RESULT_BADBIOSTABLE;
  1296. info->gpu_cap_info =
  1297. le32_to_cpu(info_v11->gpucapinfo);
  1298. /*
  1299. * system_config: Bit[0] = 0 : PCIE power gating disabled
  1300. * = 1 : PCIE power gating enabled
  1301. * Bit[1] = 0 : DDR-PLL shut down disabled
  1302. * = 1 : DDR-PLL shut down enabled
  1303. * Bit[2] = 0 : DDR-PLL power down disabled
  1304. * = 1 : DDR-PLL power down enabled
  1305. */
  1306. info->system_config = le32_to_cpu(info_v11->system_config);
  1307. info->cpu_cap_info = le32_to_cpu(info_v11->cpucapinfo);
  1308. info->memory_type = info_v11->memorytype;
  1309. info->ma_channel_number = info_v11->umachannelnumber;
  1310. info->lvds_ss_percentage =
  1311. le16_to_cpu(info_v11->lvds_ss_percentage);
  1312. info->lvds_sspread_rate_in_10hz =
  1313. le16_to_cpu(info_v11->lvds_ss_rate_10hz);
  1314. info->hdmi_ss_percentage =
  1315. le16_to_cpu(info_v11->hdmi_ss_percentage);
  1316. info->hdmi_sspread_rate_in_10hz =
  1317. le16_to_cpu(info_v11->hdmi_ss_rate_10hz);
  1318. info->dvi_ss_percentage =
  1319. le16_to_cpu(info_v11->dvi_ss_percentage);
  1320. info->dvi_sspread_rate_in_10_hz =
  1321. le16_to_cpu(info_v11->dvi_ss_rate_10hz);
  1322. info->lvds_misc = info_v11->lvds_misc;
  1323. for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; ++i) {
  1324. info->ext_disp_conn_info.gu_id[i] =
  1325. info_v11->extdispconninfo.guid[i];
  1326. }
  1327. for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; ++i) {
  1328. info->ext_disp_conn_info.path[i].device_connector_id =
  1329. object_id_from_bios_object_id(
  1330. le16_to_cpu(info_v11->extdispconninfo.path[i].connectorobjid));
  1331. info->ext_disp_conn_info.path[i].ext_encoder_obj_id =
  1332. object_id_from_bios_object_id(
  1333. le16_to_cpu(
  1334. info_v11->extdispconninfo.path[i].ext_encoder_objid));
  1335. info->ext_disp_conn_info.path[i].device_tag =
  1336. le16_to_cpu(
  1337. info_v11->extdispconninfo.path[i].device_tag);
  1338. info->ext_disp_conn_info.path[i].device_acpi_enum =
  1339. le16_to_cpu(
  1340. info_v11->extdispconninfo.path[i].device_acpi_enum);
  1341. info->ext_disp_conn_info.path[i].ext_aux_ddc_lut_index =
  1342. info_v11->extdispconninfo.path[i].auxddclut_index;
  1343. info->ext_disp_conn_info.path[i].ext_hpd_pin_lut_index =
  1344. info_v11->extdispconninfo.path[i].hpdlut_index;
  1345. info->ext_disp_conn_info.path[i].channel_mapping.raw =
  1346. info_v11->extdispconninfo.path[i].channelmapping;
  1347. info->ext_disp_conn_info.path[i].caps =
  1348. le16_to_cpu(info_v11->extdispconninfo.path[i].caps);
  1349. }
  1350. info->ext_disp_conn_info.checksum =
  1351. info_v11->extdispconninfo.checksum;
  1352. info->dp0_ext_hdmi_slv_addr = info_v11->dp0_retimer_set.HdmiSlvAddr;
  1353. info->dp0_ext_hdmi_reg_num = info_v11->dp0_retimer_set.HdmiRegNum;
  1354. for (i = 0; i < info->dp0_ext_hdmi_reg_num; i++) {
  1355. info->dp0_ext_hdmi_reg_settings[i].i2c_reg_index =
  1356. info_v11->dp0_retimer_set.HdmiRegSetting[i].ucI2cRegIndex;
  1357. info->dp0_ext_hdmi_reg_settings[i].i2c_reg_val =
  1358. info_v11->dp0_retimer_set.HdmiRegSetting[i].ucI2cRegVal;
  1359. }
  1360. info->dp0_ext_hdmi_6g_reg_num = info_v11->dp0_retimer_set.Hdmi6GRegNum;
  1361. for (i = 0; i < info->dp0_ext_hdmi_6g_reg_num; i++) {
  1362. info->dp0_ext_hdmi_6g_reg_settings[i].i2c_reg_index =
  1363. info_v11->dp0_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex;
  1364. info->dp0_ext_hdmi_6g_reg_settings[i].i2c_reg_val =
  1365. info_v11->dp0_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal;
  1366. }
  1367. info->dp1_ext_hdmi_slv_addr = info_v11->dp1_retimer_set.HdmiSlvAddr;
  1368. info->dp1_ext_hdmi_reg_num = info_v11->dp1_retimer_set.HdmiRegNum;
  1369. for (i = 0; i < info->dp1_ext_hdmi_reg_num; i++) {
  1370. info->dp1_ext_hdmi_reg_settings[i].i2c_reg_index =
  1371. info_v11->dp1_retimer_set.HdmiRegSetting[i].ucI2cRegIndex;
  1372. info->dp1_ext_hdmi_reg_settings[i].i2c_reg_val =
  1373. info_v11->dp1_retimer_set.HdmiRegSetting[i].ucI2cRegVal;
  1374. }
  1375. info->dp1_ext_hdmi_6g_reg_num = info_v11->dp1_retimer_set.Hdmi6GRegNum;
  1376. for (i = 0; i < info->dp1_ext_hdmi_6g_reg_num; i++) {
  1377. info->dp1_ext_hdmi_6g_reg_settings[i].i2c_reg_index =
  1378. info_v11->dp1_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex;
  1379. info->dp1_ext_hdmi_6g_reg_settings[i].i2c_reg_val =
  1380. info_v11->dp1_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal;
  1381. }
  1382. info->dp2_ext_hdmi_slv_addr = info_v11->dp2_retimer_set.HdmiSlvAddr;
  1383. info->dp2_ext_hdmi_reg_num = info_v11->dp2_retimer_set.HdmiRegNum;
  1384. for (i = 0; i < info->dp2_ext_hdmi_reg_num; i++) {
  1385. info->dp2_ext_hdmi_reg_settings[i].i2c_reg_index =
  1386. info_v11->dp2_retimer_set.HdmiRegSetting[i].ucI2cRegIndex;
  1387. info->dp2_ext_hdmi_reg_settings[i].i2c_reg_val =
  1388. info_v11->dp2_retimer_set.HdmiRegSetting[i].ucI2cRegVal;
  1389. }
  1390. info->dp2_ext_hdmi_6g_reg_num = info_v11->dp2_retimer_set.Hdmi6GRegNum;
  1391. for (i = 0; i < info->dp2_ext_hdmi_6g_reg_num; i++) {
  1392. info->dp2_ext_hdmi_6g_reg_settings[i].i2c_reg_index =
  1393. info_v11->dp2_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex;
  1394. info->dp2_ext_hdmi_6g_reg_settings[i].i2c_reg_val =
  1395. info_v11->dp2_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal;
  1396. }
  1397. info->dp3_ext_hdmi_slv_addr = info_v11->dp3_retimer_set.HdmiSlvAddr;
  1398. info->dp3_ext_hdmi_reg_num = info_v11->dp3_retimer_set.HdmiRegNum;
  1399. for (i = 0; i < info->dp3_ext_hdmi_reg_num; i++) {
  1400. info->dp3_ext_hdmi_reg_settings[i].i2c_reg_index =
  1401. info_v11->dp3_retimer_set.HdmiRegSetting[i].ucI2cRegIndex;
  1402. info->dp3_ext_hdmi_reg_settings[i].i2c_reg_val =
  1403. info_v11->dp3_retimer_set.HdmiRegSetting[i].ucI2cRegVal;
  1404. }
  1405. info->dp3_ext_hdmi_6g_reg_num = info_v11->dp3_retimer_set.Hdmi6GRegNum;
  1406. for (i = 0; i < info->dp3_ext_hdmi_6g_reg_num; i++) {
  1407. info->dp3_ext_hdmi_6g_reg_settings[i].i2c_reg_index =
  1408. info_v11->dp3_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegIndex;
  1409. info->dp3_ext_hdmi_6g_reg_settings[i].i2c_reg_val =
  1410. info_v11->dp3_retimer_set.Hdmi6GhzRegSetting[i].ucI2cRegVal;
  1411. }
  1412. /** TODO - review **/
  1413. #if 0
  1414. info->boot_up_engine_clock = le32_to_cpu(info_v11->ulBootUpEngineClock)
  1415. * 10;
  1416. info->dentist_vco_freq = le32_to_cpu(info_v11->ulDentistVCOFreq) * 10;
  1417. info->boot_up_uma_clock = le32_to_cpu(info_v8->ulBootUpUMAClock) * 10;
  1418. for (i = 0; i < NUMBER_OF_DISP_CLK_VOLTAGE; ++i) {
  1419. /* Convert [10KHz] into [KHz] */
  1420. info->disp_clk_voltage[i].max_supported_clk =
  1421. le32_to_cpu(info_v11->sDISPCLK_Voltage[i].
  1422. ulMaximumSupportedCLK) * 10;
  1423. info->disp_clk_voltage[i].voltage_index =
  1424. le32_to_cpu(info_v11->sDISPCLK_Voltage[i].ulVoltageIndex);
  1425. }
  1426. info->boot_up_req_display_vector =
  1427. le32_to_cpu(info_v11->ulBootUpReqDisplayVector);
  1428. info->boot_up_nb_voltage =
  1429. le16_to_cpu(info_v11->usBootUpNBVoltage);
  1430. info->ext_disp_conn_info_offset =
  1431. le16_to_cpu(info_v11->usExtDispConnInfoOffset);
  1432. info->gmc_restore_reset_time =
  1433. le32_to_cpu(info_v11->ulGMCRestoreResetTime);
  1434. info->minimum_n_clk =
  1435. le32_to_cpu(info_v11->ulNbpStateNClkFreq[0]);
  1436. for (i = 1; i < 4; ++i)
  1437. info->minimum_n_clk =
  1438. info->minimum_n_clk <
  1439. le32_to_cpu(info_v11->ulNbpStateNClkFreq[i]) ?
  1440. info->minimum_n_clk : le32_to_cpu(
  1441. info_v11->ulNbpStateNClkFreq[i]);
  1442. info->idle_n_clk = le32_to_cpu(info_v11->ulIdleNClk);
  1443. info->ddr_dll_power_up_time =
  1444. le32_to_cpu(info_v11->ulDDR_DLL_PowerUpTime);
  1445. info->ddr_pll_power_up_time =
  1446. le32_to_cpu(info_v11->ulDDR_PLL_PowerUpTime);
  1447. info->pcie_clk_ss_type = le16_to_cpu(info_v11->usPCIEClkSSType);
  1448. info->max_lvds_pclk_freq_in_single_link =
  1449. le16_to_cpu(info_v11->usMaxLVDSPclkFreqInSingleLink);
  1450. info->max_lvds_pclk_freq_in_single_link =
  1451. le16_to_cpu(info_v11->usMaxLVDSPclkFreqInSingleLink);
  1452. info->lvds_pwr_on_seq_dig_on_to_de_in_4ms =
  1453. info_v11->ucLVDSPwrOnSeqDIGONtoDE_in4Ms;
  1454. info->lvds_pwr_on_seq_de_to_vary_bl_in_4ms =
  1455. info_v11->ucLVDSPwrOnSeqDEtoVARY_BL_in4Ms;
  1456. info->lvds_pwr_on_seq_vary_bl_to_blon_in_4ms =
  1457. info_v11->ucLVDSPwrOnSeqVARY_BLtoBLON_in4Ms;
  1458. info->lvds_pwr_off_seq_vary_bl_to_de_in4ms =
  1459. info_v11->ucLVDSPwrOffSeqVARY_BLtoDE_in4Ms;
  1460. info->lvds_pwr_off_seq_de_to_dig_on_in4ms =
  1461. info_v11->ucLVDSPwrOffSeqDEtoDIGON_in4Ms;
  1462. info->lvds_pwr_off_seq_blon_to_vary_bl_in_4ms =
  1463. info_v11->ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms;
  1464. info->lvds_off_to_on_delay_in_4ms =
  1465. info_v11->ucLVDSOffToOnDelay_in4Ms;
  1466. info->lvds_bit_depth_control_val =
  1467. le32_to_cpu(info_v11->ulLCDBitDepthControlVal);
  1468. for (i = 0; i < NUMBER_OF_AVAILABLE_SCLK; ++i) {
  1469. /* Convert [10KHz] into [KHz] */
  1470. info->avail_s_clk[i].supported_s_clk =
  1471. le32_to_cpu(info_v11->sAvail_SCLK[i].ulSupportedSCLK)
  1472. * 10;
  1473. info->avail_s_clk[i].voltage_index =
  1474. le16_to_cpu(info_v11->sAvail_SCLK[i].usVoltageIndex);
  1475. info->avail_s_clk[i].voltage_id =
  1476. le16_to_cpu(info_v11->sAvail_SCLK[i].usVoltageID);
  1477. }
  1478. #endif /* TODO*/
  1479. return BP_RESULT_OK;
  1480. }
  1481. /*
  1482. * construct_integrated_info
  1483. *
  1484. * @brief
  1485. * Get integrated BIOS information based on table revision
  1486. *
  1487. * @param
  1488. * bios_parser *bp - [in]BIOS parser handler to get master data table
  1489. * integrated_info *info - [out] store and output integrated info
  1490. *
  1491. * @return
  1492. * enum bp_result - BP_RESULT_OK if information is available,
  1493. * BP_RESULT_BADBIOSTABLE otherwise.
  1494. */
  1495. static enum bp_result construct_integrated_info(
  1496. struct bios_parser *bp,
  1497. struct integrated_info *info)
  1498. {
  1499. enum bp_result result = BP_RESULT_BADBIOSTABLE;
  1500. struct atom_common_table_header *header;
  1501. struct atom_data_revision revision;
  1502. struct clock_voltage_caps temp = {0, 0};
  1503. uint32_t i;
  1504. uint32_t j;
  1505. if (info && DATA_TABLES(integratedsysteminfo)) {
  1506. header = GET_IMAGE(struct atom_common_table_header,
  1507. DATA_TABLES(integratedsysteminfo));
  1508. get_atom_data_table_revision(header, &revision);
  1509. /* Don't need to check major revision as they are all 1 */
  1510. switch (revision.minor) {
  1511. case 11:
  1512. result = get_integrated_info_v11(bp, info);
  1513. break;
  1514. default:
  1515. return result;
  1516. }
  1517. }
  1518. if (result != BP_RESULT_OK)
  1519. return result;
  1520. /* Sort voltage table from low to high*/
  1521. for (i = 1; i < NUMBER_OF_DISP_CLK_VOLTAGE; ++i) {
  1522. for (j = i; j > 0; --j) {
  1523. if (info->disp_clk_voltage[j].max_supported_clk <
  1524. info->disp_clk_voltage[j-1].max_supported_clk
  1525. ) {
  1526. /* swap j and j - 1*/
  1527. temp = info->disp_clk_voltage[j-1];
  1528. info->disp_clk_voltage[j-1] =
  1529. info->disp_clk_voltage[j];
  1530. info->disp_clk_voltage[j] = temp;
  1531. }
  1532. }
  1533. }
  1534. return result;
  1535. }
  1536. static struct integrated_info *bios_parser_create_integrated_info(
  1537. struct dc_bios *dcb)
  1538. {
  1539. struct bios_parser *bp = BP_FROM_DCB(dcb);
  1540. struct integrated_info *info = NULL;
  1541. info = kzalloc(sizeof(struct integrated_info), GFP_KERNEL);
  1542. if (info == NULL) {
  1543. ASSERT_CRITICAL(0);
  1544. return NULL;
  1545. }
  1546. if (construct_integrated_info(bp, info) == BP_RESULT_OK)
  1547. return info;
  1548. kfree(info);
  1549. return NULL;
  1550. }
  1551. static const struct dc_vbios_funcs vbios_funcs = {
  1552. .get_connectors_number = bios_parser_get_connectors_number,
  1553. .get_encoder_id = bios_parser_get_encoder_id,
  1554. .get_connector_id = bios_parser_get_connector_id,
  1555. .get_dst_number = bios_parser_get_dst_number,
  1556. .get_src_obj = bios_parser_get_src_obj,
  1557. .get_dst_obj = bios_parser_get_dst_obj,
  1558. .get_i2c_info = bios_parser_get_i2c_info,
  1559. .get_voltage_ddc_info = bios_parser_get_voltage_ddc_info,
  1560. .get_thermal_ddc_info = bios_parser_get_thermal_ddc_info,
  1561. .get_hpd_info = bios_parser_get_hpd_info,
  1562. .get_device_tag = bios_parser_get_device_tag,
  1563. .get_firmware_info = bios_parser_get_firmware_info,
  1564. .get_spread_spectrum_info = bios_parser_get_spread_spectrum_info,
  1565. .get_ss_entry_number = bios_parser_get_ss_entry_number,
  1566. .get_embedded_panel_info = bios_parser_get_embedded_panel_info,
  1567. .get_gpio_pin_info = bios_parser_get_gpio_pin_info,
  1568. .get_encoder_cap_info = bios_parser_get_encoder_cap_info,
  1569. .is_device_id_supported = bios_parser_is_device_id_supported,
  1570. .is_accelerated_mode = bios_parser_is_accelerated_mode,
  1571. .get_vga_enabled_displays = bios_parser_get_vga_enabled_displays,
  1572. .set_scratch_critical_state = bios_parser_set_scratch_critical_state,
  1573. /* COMMANDS */
  1574. .encoder_control = bios_parser_encoder_control,
  1575. .transmitter_control = bios_parser_transmitter_control,
  1576. .enable_crtc = bios_parser_enable_crtc,
  1577. .set_pixel_clock = bios_parser_set_pixel_clock,
  1578. .set_dce_clock = bios_parser_set_dce_clock,
  1579. .program_crtc_timing = bios_parser_program_crtc_timing,
  1580. /* .blank_crtc = bios_parser_blank_crtc, */
  1581. .crtc_source_select = bios_parser_crtc_source_select,
  1582. /* .external_encoder_control = bios_parser_external_encoder_control, */
  1583. .enable_disp_power_gating = bios_parser_enable_disp_power_gating,
  1584. .post_init = bios_parser_post_init,
  1585. .bios_parser_destroy = firmware_parser_destroy,
  1586. .get_smu_clock_info = bios_parser_get_smu_clock_info,
  1587. };
  1588. static bool bios_parser_construct(
  1589. struct bios_parser *bp,
  1590. struct bp_init_data *init,
  1591. enum dce_version dce_version)
  1592. {
  1593. uint16_t *rom_header_offset = NULL;
  1594. struct atom_rom_header_v2_2 *rom_header = NULL;
  1595. struct display_object_info_table_v1_4 *object_info_tbl;
  1596. struct atom_data_revision tbl_rev = {0};
  1597. if (!init)
  1598. return false;
  1599. if (!init->bios)
  1600. return false;
  1601. bp->base.funcs = &vbios_funcs;
  1602. bp->base.bios = init->bios;
  1603. bp->base.bios_size = bp->base.bios[OFFSET_TO_ATOM_ROM_IMAGE_SIZE] * BIOS_IMAGE_SIZE_UNIT;
  1604. bp->base.ctx = init->ctx;
  1605. bp->base.bios_local_image = NULL;
  1606. rom_header_offset =
  1607. GET_IMAGE(uint16_t, OFFSET_TO_ATOM_ROM_HEADER_POINTER);
  1608. if (!rom_header_offset)
  1609. return false;
  1610. rom_header = GET_IMAGE(struct atom_rom_header_v2_2, *rom_header_offset);
  1611. if (!rom_header)
  1612. return false;
  1613. get_atom_data_table_revision(&rom_header->table_header, &tbl_rev);
  1614. if (!(tbl_rev.major >= 2 && tbl_rev.minor >= 2))
  1615. return false;
  1616. bp->master_data_tbl =
  1617. GET_IMAGE(struct atom_master_data_table_v2_1,
  1618. rom_header->masterdatatable_offset);
  1619. if (!bp->master_data_tbl)
  1620. return false;
  1621. bp->object_info_tbl_offset = DATA_TABLES(displayobjectinfo);
  1622. if (!bp->object_info_tbl_offset)
  1623. return false;
  1624. object_info_tbl =
  1625. GET_IMAGE(struct display_object_info_table_v1_4,
  1626. bp->object_info_tbl_offset);
  1627. if (!object_info_tbl)
  1628. return false;
  1629. get_atom_data_table_revision(&object_info_tbl->table_header,
  1630. &bp->object_info_tbl.revision);
  1631. if (bp->object_info_tbl.revision.major == 1
  1632. && bp->object_info_tbl.revision.minor >= 4) {
  1633. struct display_object_info_table_v1_4 *tbl_v1_4;
  1634. tbl_v1_4 = GET_IMAGE(struct display_object_info_table_v1_4,
  1635. bp->object_info_tbl_offset);
  1636. if (!tbl_v1_4)
  1637. return false;
  1638. bp->object_info_tbl.v1_4 = tbl_v1_4;
  1639. } else
  1640. return false;
  1641. dal_firmware_parser_init_cmd_tbl(bp);
  1642. dal_bios_parser_init_cmd_tbl_helper2(&bp->cmd_helper, dce_version);
  1643. bp->base.integrated_info = bios_parser_create_integrated_info(&bp->base);
  1644. return true;
  1645. }
  1646. struct dc_bios *firmware_parser_create(
  1647. struct bp_init_data *init,
  1648. enum dce_version dce_version)
  1649. {
  1650. struct bios_parser *bp = NULL;
  1651. bp = kzalloc(sizeof(struct bios_parser), GFP_KERNEL);
  1652. if (!bp)
  1653. return NULL;
  1654. if (bios_parser_construct(bp, init, dce_version))
  1655. return &bp->base;
  1656. kfree(bp);
  1657. return NULL;
  1658. }