radeon_combios.c 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009
  1. /*
  2. * Copyright 2004 ATI Technologies Inc., Markham, Ontario
  3. * Copyright 2007-8 Advanced Micro Devices, Inc.
  4. * Copyright 2008 Red Hat Inc.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. */
  27. #include "drmP.h"
  28. #include "radeon_drm.h"
  29. #include "radeon.h"
  30. #include "atom.h"
  31. #ifdef CONFIG_PPC_PMAC
  32. /* not sure which of these are needed */
  33. #include <asm/machdep.h>
  34. #include <asm/pmac_feature.h>
  35. #include <asm/prom.h>
  36. #include <asm/pci-bridge.h>
  37. #endif /* CONFIG_PPC_PMAC */
  38. /* from radeon_encoder.c */
  39. extern uint32_t
  40. radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device,
  41. uint8_t dac);
  42. extern void radeon_link_encoder_connector(struct drm_device *dev);
  43. /* from radeon_connector.c */
  44. extern void
  45. radeon_add_legacy_connector(struct drm_device *dev,
  46. uint32_t connector_id,
  47. uint32_t supported_device,
  48. int connector_type,
  49. struct radeon_i2c_bus_rec *i2c_bus,
  50. uint16_t connector_object_id,
  51. struct radeon_hpd *hpd);
  52. /* from radeon_legacy_encoder.c */
  53. extern void
  54. radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
  55. uint32_t supported_device);
  56. /* old legacy ATI BIOS routines */
  57. /* COMBIOS table offsets */
  58. enum radeon_combios_table_offset {
  59. /* absolute offset tables */
  60. COMBIOS_ASIC_INIT_1_TABLE,
  61. COMBIOS_BIOS_SUPPORT_TABLE,
  62. COMBIOS_DAC_PROGRAMMING_TABLE,
  63. COMBIOS_MAX_COLOR_DEPTH_TABLE,
  64. COMBIOS_CRTC_INFO_TABLE,
  65. COMBIOS_PLL_INFO_TABLE,
  66. COMBIOS_TV_INFO_TABLE,
  67. COMBIOS_DFP_INFO_TABLE,
  68. COMBIOS_HW_CONFIG_INFO_TABLE,
  69. COMBIOS_MULTIMEDIA_INFO_TABLE,
  70. COMBIOS_TV_STD_PATCH_TABLE,
  71. COMBIOS_LCD_INFO_TABLE,
  72. COMBIOS_MOBILE_INFO_TABLE,
  73. COMBIOS_PLL_INIT_TABLE,
  74. COMBIOS_MEM_CONFIG_TABLE,
  75. COMBIOS_SAVE_MASK_TABLE,
  76. COMBIOS_HARDCODED_EDID_TABLE,
  77. COMBIOS_ASIC_INIT_2_TABLE,
  78. COMBIOS_CONNECTOR_INFO_TABLE,
  79. COMBIOS_DYN_CLK_1_TABLE,
  80. COMBIOS_RESERVED_MEM_TABLE,
  81. COMBIOS_EXT_TMDS_INFO_TABLE,
  82. COMBIOS_MEM_CLK_INFO_TABLE,
  83. COMBIOS_EXT_DAC_INFO_TABLE,
  84. COMBIOS_MISC_INFO_TABLE,
  85. COMBIOS_CRT_INFO_TABLE,
  86. COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE,
  87. COMBIOS_COMPONENT_VIDEO_INFO_TABLE,
  88. COMBIOS_FAN_SPEED_INFO_TABLE,
  89. COMBIOS_OVERDRIVE_INFO_TABLE,
  90. COMBIOS_OEM_INFO_TABLE,
  91. COMBIOS_DYN_CLK_2_TABLE,
  92. COMBIOS_POWER_CONNECTOR_INFO_TABLE,
  93. COMBIOS_I2C_INFO_TABLE,
  94. /* relative offset tables */
  95. COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */
  96. COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */
  97. COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */
  98. COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */
  99. COMBIOS_RAM_RESET_TABLE, /* offset from mem config */
  100. COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */
  101. COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */
  102. COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */
  103. COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */
  104. COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */
  105. COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */
  106. };
  107. enum radeon_combios_ddc {
  108. DDC_NONE_DETECTED,
  109. DDC_MONID,
  110. DDC_DVI,
  111. DDC_VGA,
  112. DDC_CRT2,
  113. DDC_LCD,
  114. DDC_GPIO,
  115. };
  116. enum radeon_combios_connector {
  117. CONNECTOR_NONE_LEGACY,
  118. CONNECTOR_PROPRIETARY_LEGACY,
  119. CONNECTOR_CRT_LEGACY,
  120. CONNECTOR_DVI_I_LEGACY,
  121. CONNECTOR_DVI_D_LEGACY,
  122. CONNECTOR_CTV_LEGACY,
  123. CONNECTOR_STV_LEGACY,
  124. CONNECTOR_UNSUPPORTED_LEGACY
  125. };
  126. const int legacy_connector_convert[] = {
  127. DRM_MODE_CONNECTOR_Unknown,
  128. DRM_MODE_CONNECTOR_DVID,
  129. DRM_MODE_CONNECTOR_VGA,
  130. DRM_MODE_CONNECTOR_DVII,
  131. DRM_MODE_CONNECTOR_DVID,
  132. DRM_MODE_CONNECTOR_Composite,
  133. DRM_MODE_CONNECTOR_SVIDEO,
  134. DRM_MODE_CONNECTOR_Unknown,
  135. };
  136. static uint16_t combios_get_table_offset(struct drm_device *dev,
  137. enum radeon_combios_table_offset table)
  138. {
  139. struct radeon_device *rdev = dev->dev_private;
  140. int rev;
  141. uint16_t offset = 0, check_offset;
  142. switch (table) {
  143. /* absolute offset tables */
  144. case COMBIOS_ASIC_INIT_1_TABLE:
  145. check_offset = RBIOS16(rdev->bios_header_start + 0xc);
  146. if (check_offset)
  147. offset = check_offset;
  148. break;
  149. case COMBIOS_BIOS_SUPPORT_TABLE:
  150. check_offset = RBIOS16(rdev->bios_header_start + 0x14);
  151. if (check_offset)
  152. offset = check_offset;
  153. break;
  154. case COMBIOS_DAC_PROGRAMMING_TABLE:
  155. check_offset = RBIOS16(rdev->bios_header_start + 0x2a);
  156. if (check_offset)
  157. offset = check_offset;
  158. break;
  159. case COMBIOS_MAX_COLOR_DEPTH_TABLE:
  160. check_offset = RBIOS16(rdev->bios_header_start + 0x2c);
  161. if (check_offset)
  162. offset = check_offset;
  163. break;
  164. case COMBIOS_CRTC_INFO_TABLE:
  165. check_offset = RBIOS16(rdev->bios_header_start + 0x2e);
  166. if (check_offset)
  167. offset = check_offset;
  168. break;
  169. case COMBIOS_PLL_INFO_TABLE:
  170. check_offset = RBIOS16(rdev->bios_header_start + 0x30);
  171. if (check_offset)
  172. offset = check_offset;
  173. break;
  174. case COMBIOS_TV_INFO_TABLE:
  175. check_offset = RBIOS16(rdev->bios_header_start + 0x32);
  176. if (check_offset)
  177. offset = check_offset;
  178. break;
  179. case COMBIOS_DFP_INFO_TABLE:
  180. check_offset = RBIOS16(rdev->bios_header_start + 0x34);
  181. if (check_offset)
  182. offset = check_offset;
  183. break;
  184. case COMBIOS_HW_CONFIG_INFO_TABLE:
  185. check_offset = RBIOS16(rdev->bios_header_start + 0x36);
  186. if (check_offset)
  187. offset = check_offset;
  188. break;
  189. case COMBIOS_MULTIMEDIA_INFO_TABLE:
  190. check_offset = RBIOS16(rdev->bios_header_start + 0x38);
  191. if (check_offset)
  192. offset = check_offset;
  193. break;
  194. case COMBIOS_TV_STD_PATCH_TABLE:
  195. check_offset = RBIOS16(rdev->bios_header_start + 0x3e);
  196. if (check_offset)
  197. offset = check_offset;
  198. break;
  199. case COMBIOS_LCD_INFO_TABLE:
  200. check_offset = RBIOS16(rdev->bios_header_start + 0x40);
  201. if (check_offset)
  202. offset = check_offset;
  203. break;
  204. case COMBIOS_MOBILE_INFO_TABLE:
  205. check_offset = RBIOS16(rdev->bios_header_start + 0x42);
  206. if (check_offset)
  207. offset = check_offset;
  208. break;
  209. case COMBIOS_PLL_INIT_TABLE:
  210. check_offset = RBIOS16(rdev->bios_header_start + 0x46);
  211. if (check_offset)
  212. offset = check_offset;
  213. break;
  214. case COMBIOS_MEM_CONFIG_TABLE:
  215. check_offset = RBIOS16(rdev->bios_header_start + 0x48);
  216. if (check_offset)
  217. offset = check_offset;
  218. break;
  219. case COMBIOS_SAVE_MASK_TABLE:
  220. check_offset = RBIOS16(rdev->bios_header_start + 0x4a);
  221. if (check_offset)
  222. offset = check_offset;
  223. break;
  224. case COMBIOS_HARDCODED_EDID_TABLE:
  225. check_offset = RBIOS16(rdev->bios_header_start + 0x4c);
  226. if (check_offset)
  227. offset = check_offset;
  228. break;
  229. case COMBIOS_ASIC_INIT_2_TABLE:
  230. check_offset = RBIOS16(rdev->bios_header_start + 0x4e);
  231. if (check_offset)
  232. offset = check_offset;
  233. break;
  234. case COMBIOS_CONNECTOR_INFO_TABLE:
  235. check_offset = RBIOS16(rdev->bios_header_start + 0x50);
  236. if (check_offset)
  237. offset = check_offset;
  238. break;
  239. case COMBIOS_DYN_CLK_1_TABLE:
  240. check_offset = RBIOS16(rdev->bios_header_start + 0x52);
  241. if (check_offset)
  242. offset = check_offset;
  243. break;
  244. case COMBIOS_RESERVED_MEM_TABLE:
  245. check_offset = RBIOS16(rdev->bios_header_start + 0x54);
  246. if (check_offset)
  247. offset = check_offset;
  248. break;
  249. case COMBIOS_EXT_TMDS_INFO_TABLE:
  250. check_offset = RBIOS16(rdev->bios_header_start + 0x58);
  251. if (check_offset)
  252. offset = check_offset;
  253. break;
  254. case COMBIOS_MEM_CLK_INFO_TABLE:
  255. check_offset = RBIOS16(rdev->bios_header_start + 0x5a);
  256. if (check_offset)
  257. offset = check_offset;
  258. break;
  259. case COMBIOS_EXT_DAC_INFO_TABLE:
  260. check_offset = RBIOS16(rdev->bios_header_start + 0x5c);
  261. if (check_offset)
  262. offset = check_offset;
  263. break;
  264. case COMBIOS_MISC_INFO_TABLE:
  265. check_offset = RBIOS16(rdev->bios_header_start + 0x5e);
  266. if (check_offset)
  267. offset = check_offset;
  268. break;
  269. case COMBIOS_CRT_INFO_TABLE:
  270. check_offset = RBIOS16(rdev->bios_header_start + 0x60);
  271. if (check_offset)
  272. offset = check_offset;
  273. break;
  274. case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
  275. check_offset = RBIOS16(rdev->bios_header_start + 0x62);
  276. if (check_offset)
  277. offset = check_offset;
  278. break;
  279. case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
  280. check_offset = RBIOS16(rdev->bios_header_start + 0x64);
  281. if (check_offset)
  282. offset = check_offset;
  283. break;
  284. case COMBIOS_FAN_SPEED_INFO_TABLE:
  285. check_offset = RBIOS16(rdev->bios_header_start + 0x66);
  286. if (check_offset)
  287. offset = check_offset;
  288. break;
  289. case COMBIOS_OVERDRIVE_INFO_TABLE:
  290. check_offset = RBIOS16(rdev->bios_header_start + 0x68);
  291. if (check_offset)
  292. offset = check_offset;
  293. break;
  294. case COMBIOS_OEM_INFO_TABLE:
  295. check_offset = RBIOS16(rdev->bios_header_start + 0x6a);
  296. if (check_offset)
  297. offset = check_offset;
  298. break;
  299. case COMBIOS_DYN_CLK_2_TABLE:
  300. check_offset = RBIOS16(rdev->bios_header_start + 0x6c);
  301. if (check_offset)
  302. offset = check_offset;
  303. break;
  304. case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
  305. check_offset = RBIOS16(rdev->bios_header_start + 0x6e);
  306. if (check_offset)
  307. offset = check_offset;
  308. break;
  309. case COMBIOS_I2C_INFO_TABLE:
  310. check_offset = RBIOS16(rdev->bios_header_start + 0x70);
  311. if (check_offset)
  312. offset = check_offset;
  313. break;
  314. /* relative offset tables */
  315. case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */
  316. check_offset =
  317. combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
  318. if (check_offset) {
  319. rev = RBIOS8(check_offset);
  320. if (rev > 0) {
  321. check_offset = RBIOS16(check_offset + 0x3);
  322. if (check_offset)
  323. offset = check_offset;
  324. }
  325. }
  326. break;
  327. case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */
  328. check_offset =
  329. combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
  330. if (check_offset) {
  331. rev = RBIOS8(check_offset);
  332. if (rev > 0) {
  333. check_offset = RBIOS16(check_offset + 0x5);
  334. if (check_offset)
  335. offset = check_offset;
  336. }
  337. }
  338. break;
  339. case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */
  340. check_offset =
  341. combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
  342. if (check_offset) {
  343. rev = RBIOS8(check_offset);
  344. if (rev > 0) {
  345. check_offset = RBIOS16(check_offset + 0x7);
  346. if (check_offset)
  347. offset = check_offset;
  348. }
  349. }
  350. break;
  351. case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */
  352. check_offset =
  353. combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
  354. if (check_offset) {
  355. rev = RBIOS8(check_offset);
  356. if (rev == 2) {
  357. check_offset = RBIOS16(check_offset + 0x9);
  358. if (check_offset)
  359. offset = check_offset;
  360. }
  361. }
  362. break;
  363. case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */
  364. check_offset =
  365. combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
  366. if (check_offset) {
  367. while (RBIOS8(check_offset++));
  368. check_offset += 2;
  369. if (check_offset)
  370. offset = check_offset;
  371. }
  372. break;
  373. case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */
  374. check_offset =
  375. combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
  376. if (check_offset) {
  377. check_offset = RBIOS16(check_offset + 0x11);
  378. if (check_offset)
  379. offset = check_offset;
  380. }
  381. break;
  382. case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */
  383. check_offset =
  384. combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
  385. if (check_offset) {
  386. check_offset = RBIOS16(check_offset + 0x13);
  387. if (check_offset)
  388. offset = check_offset;
  389. }
  390. break;
  391. case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */
  392. check_offset =
  393. combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
  394. if (check_offset) {
  395. check_offset = RBIOS16(check_offset + 0x15);
  396. if (check_offset)
  397. offset = check_offset;
  398. }
  399. break;
  400. case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */
  401. check_offset =
  402. combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
  403. if (check_offset) {
  404. check_offset = RBIOS16(check_offset + 0x17);
  405. if (check_offset)
  406. offset = check_offset;
  407. }
  408. break;
  409. case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */
  410. check_offset =
  411. combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
  412. if (check_offset) {
  413. check_offset = RBIOS16(check_offset + 0x2);
  414. if (check_offset)
  415. offset = check_offset;
  416. }
  417. break;
  418. case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */
  419. check_offset =
  420. combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
  421. if (check_offset) {
  422. check_offset = RBIOS16(check_offset + 0x4);
  423. if (check_offset)
  424. offset = check_offset;
  425. }
  426. break;
  427. default:
  428. break;
  429. }
  430. return offset;
  431. }
  432. static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
  433. int ddc_line)
  434. {
  435. struct radeon_i2c_bus_rec i2c;
  436. if (ddc_line == RADEON_GPIOPAD_MASK) {
  437. i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
  438. i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
  439. i2c.a_clk_reg = RADEON_GPIOPAD_A;
  440. i2c.a_data_reg = RADEON_GPIOPAD_A;
  441. i2c.en_clk_reg = RADEON_GPIOPAD_EN;
  442. i2c.en_data_reg = RADEON_GPIOPAD_EN;
  443. i2c.y_clk_reg = RADEON_GPIOPAD_Y;
  444. i2c.y_data_reg = RADEON_GPIOPAD_Y;
  445. } else if (ddc_line == RADEON_MDGPIO_MASK) {
  446. i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
  447. i2c.mask_data_reg = RADEON_MDGPIO_MASK;
  448. i2c.a_clk_reg = RADEON_MDGPIO_A;
  449. i2c.a_data_reg = RADEON_MDGPIO_A;
  450. i2c.en_clk_reg = RADEON_MDGPIO_EN;
  451. i2c.en_data_reg = RADEON_MDGPIO_EN;
  452. i2c.y_clk_reg = RADEON_MDGPIO_Y;
  453. i2c.y_data_reg = RADEON_MDGPIO_Y;
  454. } else {
  455. i2c.mask_clk_mask = RADEON_GPIO_EN_1;
  456. i2c.mask_data_mask = RADEON_GPIO_EN_0;
  457. i2c.a_clk_mask = RADEON_GPIO_A_1;
  458. i2c.a_data_mask = RADEON_GPIO_A_0;
  459. i2c.en_clk_mask = RADEON_GPIO_EN_1;
  460. i2c.en_data_mask = RADEON_GPIO_EN_0;
  461. i2c.y_clk_mask = RADEON_GPIO_Y_1;
  462. i2c.y_data_mask = RADEON_GPIO_Y_0;
  463. i2c.mask_clk_reg = ddc_line;
  464. i2c.mask_data_reg = ddc_line;
  465. i2c.a_clk_reg = ddc_line;
  466. i2c.a_data_reg = ddc_line;
  467. i2c.en_clk_reg = ddc_line;
  468. i2c.en_data_reg = ddc_line;
  469. i2c.y_clk_reg = ddc_line;
  470. i2c.y_data_reg = ddc_line;
  471. }
  472. if (rdev->family < CHIP_R200)
  473. i2c.hw_capable = false;
  474. else {
  475. switch (ddc_line) {
  476. case RADEON_GPIO_VGA_DDC:
  477. case RADEON_GPIO_DVI_DDC:
  478. i2c.hw_capable = true;
  479. break;
  480. case RADEON_GPIO_MONID:
  481. /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
  482. * reliably on some pre-r4xx hardware; not sure why.
  483. */
  484. i2c.hw_capable = false;
  485. break;
  486. default:
  487. i2c.hw_capable = false;
  488. break;
  489. }
  490. }
  491. i2c.mm_i2c = false;
  492. i2c.i2c_id = 0;
  493. if (ddc_line)
  494. i2c.valid = true;
  495. else
  496. i2c.valid = false;
  497. return i2c;
  498. }
  499. bool radeon_combios_get_clock_info(struct drm_device *dev)
  500. {
  501. struct radeon_device *rdev = dev->dev_private;
  502. uint16_t pll_info;
  503. struct radeon_pll *p1pll = &rdev->clock.p1pll;
  504. struct radeon_pll *p2pll = &rdev->clock.p2pll;
  505. struct radeon_pll *spll = &rdev->clock.spll;
  506. struct radeon_pll *mpll = &rdev->clock.mpll;
  507. int8_t rev;
  508. uint16_t sclk, mclk;
  509. if (rdev->bios == NULL)
  510. return false;
  511. pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
  512. if (pll_info) {
  513. rev = RBIOS8(pll_info);
  514. /* pixel clocks */
  515. p1pll->reference_freq = RBIOS16(pll_info + 0xe);
  516. p1pll->reference_div = RBIOS16(pll_info + 0x10);
  517. p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
  518. p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
  519. if (rev > 9) {
  520. p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
  521. p1pll->pll_in_max = RBIOS32(pll_info + 0x3a);
  522. } else {
  523. p1pll->pll_in_min = 40;
  524. p1pll->pll_in_max = 500;
  525. }
  526. *p2pll = *p1pll;
  527. /* system clock */
  528. spll->reference_freq = RBIOS16(pll_info + 0x1a);
  529. spll->reference_div = RBIOS16(pll_info + 0x1c);
  530. spll->pll_out_min = RBIOS32(pll_info + 0x1e);
  531. spll->pll_out_max = RBIOS32(pll_info + 0x22);
  532. if (rev > 10) {
  533. spll->pll_in_min = RBIOS32(pll_info + 0x48);
  534. spll->pll_in_max = RBIOS32(pll_info + 0x4c);
  535. } else {
  536. /* ??? */
  537. spll->pll_in_min = 40;
  538. spll->pll_in_max = 500;
  539. }
  540. /* memory clock */
  541. mpll->reference_freq = RBIOS16(pll_info + 0x26);
  542. mpll->reference_div = RBIOS16(pll_info + 0x28);
  543. mpll->pll_out_min = RBIOS32(pll_info + 0x2a);
  544. mpll->pll_out_max = RBIOS32(pll_info + 0x2e);
  545. if (rev > 10) {
  546. mpll->pll_in_min = RBIOS32(pll_info + 0x5a);
  547. mpll->pll_in_max = RBIOS32(pll_info + 0x5e);
  548. } else {
  549. /* ??? */
  550. mpll->pll_in_min = 40;
  551. mpll->pll_in_max = 500;
  552. }
  553. /* default sclk/mclk */
  554. sclk = RBIOS16(pll_info + 0xa);
  555. mclk = RBIOS16(pll_info + 0x8);
  556. if (sclk == 0)
  557. sclk = 200 * 100;
  558. if (mclk == 0)
  559. mclk = 200 * 100;
  560. rdev->clock.default_sclk = sclk;
  561. rdev->clock.default_mclk = mclk;
  562. return true;
  563. }
  564. return false;
  565. }
  566. struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
  567. radeon_encoder
  568. *encoder)
  569. {
  570. struct drm_device *dev = encoder->base.dev;
  571. struct radeon_device *rdev = dev->dev_private;
  572. uint16_t dac_info;
  573. uint8_t rev, bg, dac;
  574. struct radeon_encoder_primary_dac *p_dac = NULL;
  575. if (rdev->bios == NULL)
  576. return NULL;
  577. /* check CRT table */
  578. dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
  579. if (dac_info) {
  580. p_dac =
  581. kzalloc(sizeof(struct radeon_encoder_primary_dac),
  582. GFP_KERNEL);
  583. if (!p_dac)
  584. return NULL;
  585. rev = RBIOS8(dac_info) & 0x3;
  586. if (rev < 2) {
  587. bg = RBIOS8(dac_info + 0x2) & 0xf;
  588. dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf;
  589. p_dac->ps2_pdac_adj = (bg << 8) | (dac);
  590. } else {
  591. bg = RBIOS8(dac_info + 0x2) & 0xf;
  592. dac = RBIOS8(dac_info + 0x3) & 0xf;
  593. p_dac->ps2_pdac_adj = (bg << 8) | (dac);
  594. }
  595. }
  596. return p_dac;
  597. }
  598. static enum radeon_tv_std
  599. radeon_combios_get_tv_info(struct radeon_encoder *encoder)
  600. {
  601. struct drm_device *dev = encoder->base.dev;
  602. struct radeon_device *rdev = dev->dev_private;
  603. uint16_t tv_info;
  604. enum radeon_tv_std tv_std = TV_STD_NTSC;
  605. tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
  606. if (tv_info) {
  607. if (RBIOS8(tv_info + 6) == 'T') {
  608. switch (RBIOS8(tv_info + 7) & 0xf) {
  609. case 1:
  610. tv_std = TV_STD_NTSC;
  611. DRM_INFO("Default TV standard: NTSC\n");
  612. break;
  613. case 2:
  614. tv_std = TV_STD_PAL;
  615. DRM_INFO("Default TV standard: PAL\n");
  616. break;
  617. case 3:
  618. tv_std = TV_STD_PAL_M;
  619. DRM_INFO("Default TV standard: PAL-M\n");
  620. break;
  621. case 4:
  622. tv_std = TV_STD_PAL_60;
  623. DRM_INFO("Default TV standard: PAL-60\n");
  624. break;
  625. case 5:
  626. tv_std = TV_STD_NTSC_J;
  627. DRM_INFO("Default TV standard: NTSC-J\n");
  628. break;
  629. case 6:
  630. tv_std = TV_STD_SCART_PAL;
  631. DRM_INFO("Default TV standard: SCART-PAL\n");
  632. break;
  633. default:
  634. tv_std = TV_STD_NTSC;
  635. DRM_INFO
  636. ("Unknown TV standard; defaulting to NTSC\n");
  637. break;
  638. }
  639. switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
  640. case 0:
  641. DRM_INFO("29.498928713 MHz TV ref clk\n");
  642. break;
  643. case 1:
  644. DRM_INFO("28.636360000 MHz TV ref clk\n");
  645. break;
  646. case 2:
  647. DRM_INFO("14.318180000 MHz TV ref clk\n");
  648. break;
  649. case 3:
  650. DRM_INFO("27.000000000 MHz TV ref clk\n");
  651. break;
  652. default:
  653. break;
  654. }
  655. }
  656. }
  657. return tv_std;
  658. }
  659. static const uint32_t default_tvdac_adj[CHIP_LAST] = {
  660. 0x00000000, /* r100 */
  661. 0x00280000, /* rv100 */
  662. 0x00000000, /* rs100 */
  663. 0x00880000, /* rv200 */
  664. 0x00000000, /* rs200 */
  665. 0x00000000, /* r200 */
  666. 0x00770000, /* rv250 */
  667. 0x00290000, /* rs300 */
  668. 0x00560000, /* rv280 */
  669. 0x00780000, /* r300 */
  670. 0x00770000, /* r350 */
  671. 0x00780000, /* rv350 */
  672. 0x00780000, /* rv380 */
  673. 0x01080000, /* r420 */
  674. 0x01080000, /* r423 */
  675. 0x01080000, /* rv410 */
  676. 0x00780000, /* rs400 */
  677. 0x00780000, /* rs480 */
  678. };
  679. static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
  680. struct radeon_encoder_tv_dac *tv_dac)
  681. {
  682. tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
  683. if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
  684. tv_dac->ps2_tvdac_adj = 0x00880000;
  685. tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
  686. tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
  687. return;
  688. }
  689. struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
  690. radeon_encoder
  691. *encoder)
  692. {
  693. struct drm_device *dev = encoder->base.dev;
  694. struct radeon_device *rdev = dev->dev_private;
  695. uint16_t dac_info;
  696. uint8_t rev, bg, dac;
  697. struct radeon_encoder_tv_dac *tv_dac = NULL;
  698. int found = 0;
  699. tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
  700. if (!tv_dac)
  701. return NULL;
  702. if (rdev->bios == NULL)
  703. goto out;
  704. /* first check TV table */
  705. dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
  706. if (dac_info) {
  707. rev = RBIOS8(dac_info + 0x3);
  708. if (rev > 4) {
  709. bg = RBIOS8(dac_info + 0xc) & 0xf;
  710. dac = RBIOS8(dac_info + 0xd) & 0xf;
  711. tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
  712. bg = RBIOS8(dac_info + 0xe) & 0xf;
  713. dac = RBIOS8(dac_info + 0xf) & 0xf;
  714. tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
  715. bg = RBIOS8(dac_info + 0x10) & 0xf;
  716. dac = RBIOS8(dac_info + 0x11) & 0xf;
  717. tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
  718. found = 1;
  719. } else if (rev > 1) {
  720. bg = RBIOS8(dac_info + 0xc) & 0xf;
  721. dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
  722. tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
  723. bg = RBIOS8(dac_info + 0xd) & 0xf;
  724. dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
  725. tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
  726. bg = RBIOS8(dac_info + 0xe) & 0xf;
  727. dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
  728. tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
  729. found = 1;
  730. }
  731. tv_dac->tv_std = radeon_combios_get_tv_info(encoder);
  732. }
  733. if (!found) {
  734. /* then check CRT table */
  735. dac_info =
  736. combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
  737. if (dac_info) {
  738. rev = RBIOS8(dac_info) & 0x3;
  739. if (rev < 2) {
  740. bg = RBIOS8(dac_info + 0x3) & 0xf;
  741. dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf;
  742. tv_dac->ps2_tvdac_adj =
  743. (bg << 16) | (dac << 20);
  744. tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
  745. tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
  746. found = 1;
  747. } else {
  748. bg = RBIOS8(dac_info + 0x4) & 0xf;
  749. dac = RBIOS8(dac_info + 0x5) & 0xf;
  750. tv_dac->ps2_tvdac_adj =
  751. (bg << 16) | (dac << 20);
  752. tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
  753. tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
  754. found = 1;
  755. }
  756. } else {
  757. DRM_INFO("No TV DAC info found in BIOS\n");
  758. }
  759. }
  760. out:
  761. if (!found) /* fallback to defaults */
  762. radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
  763. return tv_dac;
  764. }
  765. static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
  766. radeon_device
  767. *rdev)
  768. {
  769. struct radeon_encoder_lvds *lvds = NULL;
  770. uint32_t fp_vert_stretch, fp_horz_stretch;
  771. uint32_t ppll_div_sel, ppll_val;
  772. uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
  773. lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
  774. if (!lvds)
  775. return NULL;
  776. fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
  777. fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
  778. /* These should be fail-safe defaults, fingers crossed */
  779. lvds->panel_pwr_delay = 200;
  780. lvds->panel_vcc_delay = 2000;
  781. lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
  782. lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
  783. lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
  784. if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
  785. lvds->native_mode.vdisplay =
  786. ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
  787. RADEON_VERT_PANEL_SHIFT) + 1;
  788. else
  789. lvds->native_mode.vdisplay =
  790. (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
  791. if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
  792. lvds->native_mode.hdisplay =
  793. (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
  794. RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
  795. else
  796. lvds->native_mode.hdisplay =
  797. ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
  798. if ((lvds->native_mode.hdisplay < 640) ||
  799. (lvds->native_mode.vdisplay < 480)) {
  800. lvds->native_mode.hdisplay = 640;
  801. lvds->native_mode.vdisplay = 480;
  802. }
  803. ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
  804. ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
  805. if ((ppll_val & 0x000707ff) == 0x1bb)
  806. lvds->use_bios_dividers = false;
  807. else {
  808. lvds->panel_ref_divider =
  809. RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
  810. lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
  811. lvds->panel_fb_divider = ppll_val & 0x7ff;
  812. if ((lvds->panel_ref_divider != 0) &&
  813. (lvds->panel_fb_divider > 3))
  814. lvds->use_bios_dividers = true;
  815. }
  816. lvds->panel_vcc_delay = 200;
  817. DRM_INFO("Panel info derived from registers\n");
  818. DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
  819. lvds->native_mode.vdisplay);
  820. return lvds;
  821. }
  822. struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
  823. *encoder)
  824. {
  825. struct drm_device *dev = encoder->base.dev;
  826. struct radeon_device *rdev = dev->dev_private;
  827. uint16_t lcd_info;
  828. uint32_t panel_setup;
  829. char stmp[30];
  830. int tmp, i;
  831. struct radeon_encoder_lvds *lvds = NULL;
  832. if (rdev->bios == NULL) {
  833. lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
  834. goto out;
  835. }
  836. lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
  837. if (lcd_info) {
  838. lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
  839. if (!lvds)
  840. return NULL;
  841. for (i = 0; i < 24; i++)
  842. stmp[i] = RBIOS8(lcd_info + i + 1);
  843. stmp[24] = 0;
  844. DRM_INFO("Panel ID String: %s\n", stmp);
  845. lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
  846. lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
  847. DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
  848. lvds->native_mode.vdisplay);
  849. lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
  850. if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0)
  851. lvds->panel_vcc_delay = 2000;
  852. lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
  853. lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
  854. lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
  855. lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
  856. lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
  857. lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
  858. if ((lvds->panel_ref_divider != 0) &&
  859. (lvds->panel_fb_divider > 3))
  860. lvds->use_bios_dividers = true;
  861. panel_setup = RBIOS32(lcd_info + 0x39);
  862. lvds->lvds_gen_cntl = 0xff00;
  863. if (panel_setup & 0x1)
  864. lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
  865. if ((panel_setup >> 4) & 0x1)
  866. lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
  867. switch ((panel_setup >> 8) & 0x7) {
  868. case 0:
  869. lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
  870. break;
  871. case 1:
  872. lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
  873. break;
  874. case 2:
  875. lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
  876. break;
  877. default:
  878. break;
  879. }
  880. if ((panel_setup >> 16) & 0x1)
  881. lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
  882. if ((panel_setup >> 17) & 0x1)
  883. lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
  884. if ((panel_setup >> 18) & 0x1)
  885. lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
  886. if ((panel_setup >> 23) & 0x1)
  887. lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
  888. lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
  889. for (i = 0; i < 32; i++) {
  890. tmp = RBIOS16(lcd_info + 64 + i * 2);
  891. if (tmp == 0)
  892. break;
  893. if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
  894. (RBIOS16(tmp + 2) ==
  895. lvds->native_mode.vdisplay)) {
  896. lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
  897. lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
  898. lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
  899. RBIOS16(tmp + 21)) * 8;
  900. lvds->native_mode.vtotal = RBIOS16(tmp + 24);
  901. lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
  902. lvds->native_mode.vsync_end =
  903. ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
  904. (RBIOS16(tmp + 28) & 0x7ff);
  905. lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
  906. lvds->native_mode.flags = 0;
  907. /* set crtc values */
  908. drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
  909. }
  910. }
  911. } else {
  912. DRM_INFO("No panel info found in BIOS\n");
  913. lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
  914. }
  915. out:
  916. if (lvds)
  917. encoder->native_mode = lvds->native_mode;
  918. return lvds;
  919. }
  920. static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
  921. {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
  922. {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
  923. {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
  924. {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
  925. {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
  926. {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
  927. {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
  928. {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
  929. {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
  930. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
  931. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
  932. {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
  933. {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
  934. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
  935. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
  936. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
  937. { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
  938. { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
  939. };
  940. bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
  941. struct radeon_encoder_int_tmds *tmds)
  942. {
  943. struct drm_device *dev = encoder->base.dev;
  944. struct radeon_device *rdev = dev->dev_private;
  945. int i;
  946. for (i = 0; i < 4; i++) {
  947. tmds->tmds_pll[i].value =
  948. default_tmds_pll[rdev->family][i].value;
  949. tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
  950. }
  951. return true;
  952. }
  953. bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
  954. struct radeon_encoder_int_tmds *tmds)
  955. {
  956. struct drm_device *dev = encoder->base.dev;
  957. struct radeon_device *rdev = dev->dev_private;
  958. uint16_t tmds_info;
  959. int i, n;
  960. uint8_t ver;
  961. if (rdev->bios == NULL)
  962. return false;
  963. tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
  964. if (tmds_info) {
  965. ver = RBIOS8(tmds_info);
  966. DRM_INFO("DFP table revision: %d\n", ver);
  967. if (ver == 3) {
  968. n = RBIOS8(tmds_info + 5) + 1;
  969. if (n > 4)
  970. n = 4;
  971. for (i = 0; i < n; i++) {
  972. tmds->tmds_pll[i].value =
  973. RBIOS32(tmds_info + i * 10 + 0x08);
  974. tmds->tmds_pll[i].freq =
  975. RBIOS16(tmds_info + i * 10 + 0x10);
  976. DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
  977. tmds->tmds_pll[i].freq,
  978. tmds->tmds_pll[i].value);
  979. }
  980. } else if (ver == 4) {
  981. int stride = 0;
  982. n = RBIOS8(tmds_info + 5) + 1;
  983. if (n > 4)
  984. n = 4;
  985. for (i = 0; i < n; i++) {
  986. tmds->tmds_pll[i].value =
  987. RBIOS32(tmds_info + stride + 0x08);
  988. tmds->tmds_pll[i].freq =
  989. RBIOS16(tmds_info + stride + 0x10);
  990. if (i == 0)
  991. stride += 10;
  992. else
  993. stride += 6;
  994. DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
  995. tmds->tmds_pll[i].freq,
  996. tmds->tmds_pll[i].value);
  997. }
  998. }
  999. } else {
  1000. DRM_INFO("No TMDS info found in BIOS\n");
  1001. return false;
  1002. }
  1003. return true;
  1004. }
  1005. bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
  1006. struct radeon_encoder_ext_tmds *tmds)
  1007. {
  1008. struct drm_device *dev = encoder->base.dev;
  1009. struct radeon_device *rdev = dev->dev_private;
  1010. struct radeon_i2c_bus_rec i2c_bus;
  1011. /* default for macs */
  1012. i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
  1013. tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
  1014. /* XXX some macs have duallink chips */
  1015. switch (rdev->mode_info.connector_table) {
  1016. case CT_POWERBOOK_EXTERNAL:
  1017. case CT_MINI_EXTERNAL:
  1018. default:
  1019. tmds->dvo_chip = DVO_SIL164;
  1020. tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
  1021. break;
  1022. }
  1023. return true;
  1024. }
  1025. bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
  1026. struct radeon_encoder_ext_tmds *tmds)
  1027. {
  1028. struct drm_device *dev = encoder->base.dev;
  1029. struct radeon_device *rdev = dev->dev_private;
  1030. uint16_t offset;
  1031. uint8_t ver, id, blocks, clk, data;
  1032. int i;
  1033. enum radeon_combios_ddc gpio;
  1034. struct radeon_i2c_bus_rec i2c_bus;
  1035. if (rdev->bios == NULL)
  1036. return false;
  1037. tmds->i2c_bus = NULL;
  1038. if (rdev->flags & RADEON_IS_IGP) {
  1039. offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
  1040. if (offset) {
  1041. ver = RBIOS8(offset);
  1042. DRM_INFO("GPIO Table revision: %d\n", ver);
  1043. blocks = RBIOS8(offset + 2);
  1044. for (i = 0; i < blocks; i++) {
  1045. id = RBIOS8(offset + 3 + (i * 5) + 0);
  1046. if (id == 136) {
  1047. clk = RBIOS8(offset + 3 + (i * 5) + 3);
  1048. data = RBIOS8(offset + 3 + (i * 5) + 4);
  1049. i2c_bus.valid = true;
  1050. i2c_bus.mask_clk_mask = (1 << clk);
  1051. i2c_bus.mask_data_mask = (1 << data);
  1052. i2c_bus.a_clk_mask = (1 << clk);
  1053. i2c_bus.a_data_mask = (1 << data);
  1054. i2c_bus.en_clk_mask = (1 << clk);
  1055. i2c_bus.en_data_mask = (1 << data);
  1056. i2c_bus.y_clk_mask = (1 << clk);
  1057. i2c_bus.y_data_mask = (1 << data);
  1058. i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK;
  1059. i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK;
  1060. i2c_bus.a_clk_reg = RADEON_GPIOPAD_A;
  1061. i2c_bus.a_data_reg = RADEON_GPIOPAD_A;
  1062. i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN;
  1063. i2c_bus.en_data_reg = RADEON_GPIOPAD_EN;
  1064. i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y;
  1065. i2c_bus.y_data_reg = RADEON_GPIOPAD_Y;
  1066. tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
  1067. tmds->dvo_chip = DVO_SIL164;
  1068. tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
  1069. break;
  1070. }
  1071. }
  1072. }
  1073. } else {
  1074. offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
  1075. if (offset) {
  1076. ver = RBIOS8(offset);
  1077. DRM_INFO("External TMDS Table revision: %d\n", ver);
  1078. tmds->slave_addr = RBIOS8(offset + 4 + 2);
  1079. tmds->slave_addr >>= 1; /* 7 bit addressing */
  1080. gpio = RBIOS8(offset + 4 + 3);
  1081. switch (gpio) {
  1082. case DDC_MONID:
  1083. i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
  1084. tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
  1085. break;
  1086. case DDC_DVI:
  1087. i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1088. tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
  1089. break;
  1090. case DDC_VGA:
  1091. i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1092. tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
  1093. break;
  1094. case DDC_CRT2:
  1095. /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
  1096. if (rdev->family >= CHIP_R300)
  1097. i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
  1098. else
  1099. i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
  1100. tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
  1101. break;
  1102. case DDC_LCD: /* MM i2c */
  1103. DRM_ERROR("MM i2c requires hw i2c engine\n");
  1104. break;
  1105. default:
  1106. DRM_ERROR("Unsupported gpio %d\n", gpio);
  1107. break;
  1108. }
  1109. }
  1110. }
  1111. if (!tmds->i2c_bus) {
  1112. DRM_INFO("No valid Ext TMDS info found in BIOS\n");
  1113. return false;
  1114. }
  1115. return true;
  1116. }
  1117. bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
  1118. {
  1119. struct radeon_device *rdev = dev->dev_private;
  1120. struct radeon_i2c_bus_rec ddc_i2c;
  1121. struct radeon_hpd hpd;
  1122. rdev->mode_info.connector_table = radeon_connector_table;
  1123. if (rdev->mode_info.connector_table == CT_NONE) {
  1124. #ifdef CONFIG_PPC_PMAC
  1125. if (machine_is_compatible("PowerBook3,3")) {
  1126. /* powerbook with VGA */
  1127. rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
  1128. } else if (machine_is_compatible("PowerBook3,4") ||
  1129. machine_is_compatible("PowerBook3,5")) {
  1130. /* powerbook with internal tmds */
  1131. rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
  1132. } else if (machine_is_compatible("PowerBook5,1") ||
  1133. machine_is_compatible("PowerBook5,2") ||
  1134. machine_is_compatible("PowerBook5,3") ||
  1135. machine_is_compatible("PowerBook5,4") ||
  1136. machine_is_compatible("PowerBook5,5")) {
  1137. /* powerbook with external single link tmds (sil164) */
  1138. rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
  1139. } else if (machine_is_compatible("PowerBook5,6")) {
  1140. /* powerbook with external dual or single link tmds */
  1141. rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
  1142. } else if (machine_is_compatible("PowerBook5,7") ||
  1143. machine_is_compatible("PowerBook5,8") ||
  1144. machine_is_compatible("PowerBook5,9")) {
  1145. /* PowerBook6,2 ? */
  1146. /* powerbook with external dual link tmds (sil1178?) */
  1147. rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
  1148. } else if (machine_is_compatible("PowerBook4,1") ||
  1149. machine_is_compatible("PowerBook4,2") ||
  1150. machine_is_compatible("PowerBook4,3") ||
  1151. machine_is_compatible("PowerBook6,3") ||
  1152. machine_is_compatible("PowerBook6,5") ||
  1153. machine_is_compatible("PowerBook6,7")) {
  1154. /* ibook */
  1155. rdev->mode_info.connector_table = CT_IBOOK;
  1156. } else if (machine_is_compatible("PowerMac4,4")) {
  1157. /* emac */
  1158. rdev->mode_info.connector_table = CT_EMAC;
  1159. } else if (machine_is_compatible("PowerMac10,1")) {
  1160. /* mini with internal tmds */
  1161. rdev->mode_info.connector_table = CT_MINI_INTERNAL;
  1162. } else if (machine_is_compatible("PowerMac10,2")) {
  1163. /* mini with external tmds */
  1164. rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
  1165. } else if (machine_is_compatible("PowerMac12,1")) {
  1166. /* PowerMac8,1 ? */
  1167. /* imac g5 isight */
  1168. rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
  1169. } else
  1170. #endif /* CONFIG_PPC_PMAC */
  1171. rdev->mode_info.connector_table = CT_GENERIC;
  1172. }
  1173. switch (rdev->mode_info.connector_table) {
  1174. case CT_GENERIC:
  1175. DRM_INFO("Connector Table: %d (generic)\n",
  1176. rdev->mode_info.connector_table);
  1177. /* these are the most common settings */
  1178. if (rdev->flags & RADEON_SINGLE_CRTC) {
  1179. /* VGA - primary dac */
  1180. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1181. hpd.hpd = RADEON_HPD_NONE;
  1182. radeon_add_legacy_encoder(dev,
  1183. radeon_get_encoder_id(dev,
  1184. ATOM_DEVICE_CRT1_SUPPORT,
  1185. 1),
  1186. ATOM_DEVICE_CRT1_SUPPORT);
  1187. radeon_add_legacy_connector(dev, 0,
  1188. ATOM_DEVICE_CRT1_SUPPORT,
  1189. DRM_MODE_CONNECTOR_VGA,
  1190. &ddc_i2c,
  1191. CONNECTOR_OBJECT_ID_VGA,
  1192. &hpd);
  1193. } else if (rdev->flags & RADEON_IS_MOBILITY) {
  1194. /* LVDS */
  1195. ddc_i2c = combios_setup_i2c_bus(rdev, 0);
  1196. hpd.hpd = RADEON_HPD_NONE;
  1197. radeon_add_legacy_encoder(dev,
  1198. radeon_get_encoder_id(dev,
  1199. ATOM_DEVICE_LCD1_SUPPORT,
  1200. 0),
  1201. ATOM_DEVICE_LCD1_SUPPORT);
  1202. radeon_add_legacy_connector(dev, 0,
  1203. ATOM_DEVICE_LCD1_SUPPORT,
  1204. DRM_MODE_CONNECTOR_LVDS,
  1205. &ddc_i2c,
  1206. CONNECTOR_OBJECT_ID_LVDS,
  1207. &hpd);
  1208. /* VGA - primary dac */
  1209. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1210. hpd.hpd = RADEON_HPD_NONE;
  1211. radeon_add_legacy_encoder(dev,
  1212. radeon_get_encoder_id(dev,
  1213. ATOM_DEVICE_CRT1_SUPPORT,
  1214. 1),
  1215. ATOM_DEVICE_CRT1_SUPPORT);
  1216. radeon_add_legacy_connector(dev, 1,
  1217. ATOM_DEVICE_CRT1_SUPPORT,
  1218. DRM_MODE_CONNECTOR_VGA,
  1219. &ddc_i2c,
  1220. CONNECTOR_OBJECT_ID_VGA,
  1221. &hpd);
  1222. } else {
  1223. /* DVI-I - tv dac, int tmds */
  1224. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1225. hpd.hpd = RADEON_HPD_1;
  1226. radeon_add_legacy_encoder(dev,
  1227. radeon_get_encoder_id(dev,
  1228. ATOM_DEVICE_DFP1_SUPPORT,
  1229. 0),
  1230. ATOM_DEVICE_DFP1_SUPPORT);
  1231. radeon_add_legacy_encoder(dev,
  1232. radeon_get_encoder_id(dev,
  1233. ATOM_DEVICE_CRT2_SUPPORT,
  1234. 2),
  1235. ATOM_DEVICE_CRT2_SUPPORT);
  1236. radeon_add_legacy_connector(dev, 0,
  1237. ATOM_DEVICE_DFP1_SUPPORT |
  1238. ATOM_DEVICE_CRT2_SUPPORT,
  1239. DRM_MODE_CONNECTOR_DVII,
  1240. &ddc_i2c,
  1241. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1242. &hpd);
  1243. /* VGA - primary dac */
  1244. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1245. hpd.hpd = RADEON_HPD_NONE;
  1246. radeon_add_legacy_encoder(dev,
  1247. radeon_get_encoder_id(dev,
  1248. ATOM_DEVICE_CRT1_SUPPORT,
  1249. 1),
  1250. ATOM_DEVICE_CRT1_SUPPORT);
  1251. radeon_add_legacy_connector(dev, 1,
  1252. ATOM_DEVICE_CRT1_SUPPORT,
  1253. DRM_MODE_CONNECTOR_VGA,
  1254. &ddc_i2c,
  1255. CONNECTOR_OBJECT_ID_VGA,
  1256. &hpd);
  1257. }
  1258. if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
  1259. /* TV - tv dac */
  1260. ddc_i2c.valid = false;
  1261. hpd.hpd = RADEON_HPD_NONE;
  1262. radeon_add_legacy_encoder(dev,
  1263. radeon_get_encoder_id(dev,
  1264. ATOM_DEVICE_TV1_SUPPORT,
  1265. 2),
  1266. ATOM_DEVICE_TV1_SUPPORT);
  1267. radeon_add_legacy_connector(dev, 2,
  1268. ATOM_DEVICE_TV1_SUPPORT,
  1269. DRM_MODE_CONNECTOR_SVIDEO,
  1270. &ddc_i2c,
  1271. CONNECTOR_OBJECT_ID_SVIDEO,
  1272. &hpd);
  1273. }
  1274. break;
  1275. case CT_IBOOK:
  1276. DRM_INFO("Connector Table: %d (ibook)\n",
  1277. rdev->mode_info.connector_table);
  1278. /* LVDS */
  1279. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1280. hpd.hpd = RADEON_HPD_NONE;
  1281. radeon_add_legacy_encoder(dev,
  1282. radeon_get_encoder_id(dev,
  1283. ATOM_DEVICE_LCD1_SUPPORT,
  1284. 0),
  1285. ATOM_DEVICE_LCD1_SUPPORT);
  1286. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1287. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1288. CONNECTOR_OBJECT_ID_LVDS,
  1289. &hpd);
  1290. /* VGA - TV DAC */
  1291. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1292. hpd.hpd = RADEON_HPD_NONE;
  1293. radeon_add_legacy_encoder(dev,
  1294. radeon_get_encoder_id(dev,
  1295. ATOM_DEVICE_CRT2_SUPPORT,
  1296. 2),
  1297. ATOM_DEVICE_CRT2_SUPPORT);
  1298. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1299. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1300. CONNECTOR_OBJECT_ID_VGA,
  1301. &hpd);
  1302. /* TV - TV DAC */
  1303. ddc_i2c.valid = false;
  1304. hpd.hpd = RADEON_HPD_NONE;
  1305. radeon_add_legacy_encoder(dev,
  1306. radeon_get_encoder_id(dev,
  1307. ATOM_DEVICE_TV1_SUPPORT,
  1308. 2),
  1309. ATOM_DEVICE_TV1_SUPPORT);
  1310. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1311. DRM_MODE_CONNECTOR_SVIDEO,
  1312. &ddc_i2c,
  1313. CONNECTOR_OBJECT_ID_SVIDEO,
  1314. &hpd);
  1315. break;
  1316. case CT_POWERBOOK_EXTERNAL:
  1317. DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
  1318. rdev->mode_info.connector_table);
  1319. /* LVDS */
  1320. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1321. hpd.hpd = RADEON_HPD_NONE;
  1322. radeon_add_legacy_encoder(dev,
  1323. radeon_get_encoder_id(dev,
  1324. ATOM_DEVICE_LCD1_SUPPORT,
  1325. 0),
  1326. ATOM_DEVICE_LCD1_SUPPORT);
  1327. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1328. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1329. CONNECTOR_OBJECT_ID_LVDS,
  1330. &hpd);
  1331. /* DVI-I - primary dac, ext tmds */
  1332. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1333. hpd.hpd = RADEON_HPD_2; /* ??? */
  1334. radeon_add_legacy_encoder(dev,
  1335. radeon_get_encoder_id(dev,
  1336. ATOM_DEVICE_DFP2_SUPPORT,
  1337. 0),
  1338. ATOM_DEVICE_DFP2_SUPPORT);
  1339. radeon_add_legacy_encoder(dev,
  1340. radeon_get_encoder_id(dev,
  1341. ATOM_DEVICE_CRT1_SUPPORT,
  1342. 1),
  1343. ATOM_DEVICE_CRT1_SUPPORT);
  1344. /* XXX some are SL */
  1345. radeon_add_legacy_connector(dev, 1,
  1346. ATOM_DEVICE_DFP2_SUPPORT |
  1347. ATOM_DEVICE_CRT1_SUPPORT,
  1348. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1349. CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
  1350. &hpd);
  1351. /* TV - TV DAC */
  1352. ddc_i2c.valid = false;
  1353. hpd.hpd = RADEON_HPD_NONE;
  1354. radeon_add_legacy_encoder(dev,
  1355. radeon_get_encoder_id(dev,
  1356. ATOM_DEVICE_TV1_SUPPORT,
  1357. 2),
  1358. ATOM_DEVICE_TV1_SUPPORT);
  1359. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1360. DRM_MODE_CONNECTOR_SVIDEO,
  1361. &ddc_i2c,
  1362. CONNECTOR_OBJECT_ID_SVIDEO,
  1363. &hpd);
  1364. break;
  1365. case CT_POWERBOOK_INTERNAL:
  1366. DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
  1367. rdev->mode_info.connector_table);
  1368. /* LVDS */
  1369. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1370. hpd.hpd = RADEON_HPD_NONE;
  1371. radeon_add_legacy_encoder(dev,
  1372. radeon_get_encoder_id(dev,
  1373. ATOM_DEVICE_LCD1_SUPPORT,
  1374. 0),
  1375. ATOM_DEVICE_LCD1_SUPPORT);
  1376. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1377. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1378. CONNECTOR_OBJECT_ID_LVDS,
  1379. &hpd);
  1380. /* DVI-I - primary dac, int tmds */
  1381. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1382. hpd.hpd = RADEON_HPD_1; /* ??? */
  1383. radeon_add_legacy_encoder(dev,
  1384. radeon_get_encoder_id(dev,
  1385. ATOM_DEVICE_DFP1_SUPPORT,
  1386. 0),
  1387. ATOM_DEVICE_DFP1_SUPPORT);
  1388. radeon_add_legacy_encoder(dev,
  1389. radeon_get_encoder_id(dev,
  1390. ATOM_DEVICE_CRT1_SUPPORT,
  1391. 1),
  1392. ATOM_DEVICE_CRT1_SUPPORT);
  1393. radeon_add_legacy_connector(dev, 1,
  1394. ATOM_DEVICE_DFP1_SUPPORT |
  1395. ATOM_DEVICE_CRT1_SUPPORT,
  1396. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1397. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1398. &hpd);
  1399. /* TV - TV DAC */
  1400. ddc_i2c.valid = false;
  1401. hpd.hpd = RADEON_HPD_NONE;
  1402. radeon_add_legacy_encoder(dev,
  1403. radeon_get_encoder_id(dev,
  1404. ATOM_DEVICE_TV1_SUPPORT,
  1405. 2),
  1406. ATOM_DEVICE_TV1_SUPPORT);
  1407. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1408. DRM_MODE_CONNECTOR_SVIDEO,
  1409. &ddc_i2c,
  1410. CONNECTOR_OBJECT_ID_SVIDEO,
  1411. &hpd);
  1412. break;
  1413. case CT_POWERBOOK_VGA:
  1414. DRM_INFO("Connector Table: %d (powerbook vga)\n",
  1415. rdev->mode_info.connector_table);
  1416. /* LVDS */
  1417. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1418. hpd.hpd = RADEON_HPD_NONE;
  1419. radeon_add_legacy_encoder(dev,
  1420. radeon_get_encoder_id(dev,
  1421. ATOM_DEVICE_LCD1_SUPPORT,
  1422. 0),
  1423. ATOM_DEVICE_LCD1_SUPPORT);
  1424. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1425. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1426. CONNECTOR_OBJECT_ID_LVDS,
  1427. &hpd);
  1428. /* VGA - primary dac */
  1429. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1430. hpd.hpd = RADEON_HPD_NONE;
  1431. radeon_add_legacy_encoder(dev,
  1432. radeon_get_encoder_id(dev,
  1433. ATOM_DEVICE_CRT1_SUPPORT,
  1434. 1),
  1435. ATOM_DEVICE_CRT1_SUPPORT);
  1436. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
  1437. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1438. CONNECTOR_OBJECT_ID_VGA,
  1439. &hpd);
  1440. /* TV - TV DAC */
  1441. ddc_i2c.valid = false;
  1442. hpd.hpd = RADEON_HPD_NONE;
  1443. radeon_add_legacy_encoder(dev,
  1444. radeon_get_encoder_id(dev,
  1445. ATOM_DEVICE_TV1_SUPPORT,
  1446. 2),
  1447. ATOM_DEVICE_TV1_SUPPORT);
  1448. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1449. DRM_MODE_CONNECTOR_SVIDEO,
  1450. &ddc_i2c,
  1451. CONNECTOR_OBJECT_ID_SVIDEO,
  1452. &hpd);
  1453. break;
  1454. case CT_MINI_EXTERNAL:
  1455. DRM_INFO("Connector Table: %d (mini external tmds)\n",
  1456. rdev->mode_info.connector_table);
  1457. /* DVI-I - tv dac, ext tmds */
  1458. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
  1459. hpd.hpd = RADEON_HPD_2; /* ??? */
  1460. radeon_add_legacy_encoder(dev,
  1461. radeon_get_encoder_id(dev,
  1462. ATOM_DEVICE_DFP2_SUPPORT,
  1463. 0),
  1464. ATOM_DEVICE_DFP2_SUPPORT);
  1465. radeon_add_legacy_encoder(dev,
  1466. radeon_get_encoder_id(dev,
  1467. ATOM_DEVICE_CRT2_SUPPORT,
  1468. 2),
  1469. ATOM_DEVICE_CRT2_SUPPORT);
  1470. /* XXX are any DL? */
  1471. radeon_add_legacy_connector(dev, 0,
  1472. ATOM_DEVICE_DFP2_SUPPORT |
  1473. ATOM_DEVICE_CRT2_SUPPORT,
  1474. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1475. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1476. &hpd);
  1477. /* TV - TV DAC */
  1478. ddc_i2c.valid = false;
  1479. hpd.hpd = RADEON_HPD_NONE;
  1480. radeon_add_legacy_encoder(dev,
  1481. radeon_get_encoder_id(dev,
  1482. ATOM_DEVICE_TV1_SUPPORT,
  1483. 2),
  1484. ATOM_DEVICE_TV1_SUPPORT);
  1485. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
  1486. DRM_MODE_CONNECTOR_SVIDEO,
  1487. &ddc_i2c,
  1488. CONNECTOR_OBJECT_ID_SVIDEO,
  1489. &hpd);
  1490. break;
  1491. case CT_MINI_INTERNAL:
  1492. DRM_INFO("Connector Table: %d (mini internal tmds)\n",
  1493. rdev->mode_info.connector_table);
  1494. /* DVI-I - tv dac, int tmds */
  1495. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
  1496. hpd.hpd = RADEON_HPD_1; /* ??? */
  1497. radeon_add_legacy_encoder(dev,
  1498. radeon_get_encoder_id(dev,
  1499. ATOM_DEVICE_DFP1_SUPPORT,
  1500. 0),
  1501. ATOM_DEVICE_DFP1_SUPPORT);
  1502. radeon_add_legacy_encoder(dev,
  1503. radeon_get_encoder_id(dev,
  1504. ATOM_DEVICE_CRT2_SUPPORT,
  1505. 2),
  1506. ATOM_DEVICE_CRT2_SUPPORT);
  1507. radeon_add_legacy_connector(dev, 0,
  1508. ATOM_DEVICE_DFP1_SUPPORT |
  1509. ATOM_DEVICE_CRT2_SUPPORT,
  1510. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1511. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1512. &hpd);
  1513. /* TV - TV DAC */
  1514. ddc_i2c.valid = false;
  1515. hpd.hpd = RADEON_HPD_NONE;
  1516. radeon_add_legacy_encoder(dev,
  1517. radeon_get_encoder_id(dev,
  1518. ATOM_DEVICE_TV1_SUPPORT,
  1519. 2),
  1520. ATOM_DEVICE_TV1_SUPPORT);
  1521. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
  1522. DRM_MODE_CONNECTOR_SVIDEO,
  1523. &ddc_i2c,
  1524. CONNECTOR_OBJECT_ID_SVIDEO,
  1525. &hpd);
  1526. break;
  1527. case CT_IMAC_G5_ISIGHT:
  1528. DRM_INFO("Connector Table: %d (imac g5 isight)\n",
  1529. rdev->mode_info.connector_table);
  1530. /* DVI-D - int tmds */
  1531. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
  1532. hpd.hpd = RADEON_HPD_1; /* ??? */
  1533. radeon_add_legacy_encoder(dev,
  1534. radeon_get_encoder_id(dev,
  1535. ATOM_DEVICE_DFP1_SUPPORT,
  1536. 0),
  1537. ATOM_DEVICE_DFP1_SUPPORT);
  1538. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
  1539. DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
  1540. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
  1541. &hpd);
  1542. /* VGA - tv dac */
  1543. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1544. hpd.hpd = RADEON_HPD_NONE;
  1545. radeon_add_legacy_encoder(dev,
  1546. radeon_get_encoder_id(dev,
  1547. ATOM_DEVICE_CRT2_SUPPORT,
  1548. 2),
  1549. ATOM_DEVICE_CRT2_SUPPORT);
  1550. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1551. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1552. CONNECTOR_OBJECT_ID_VGA,
  1553. &hpd);
  1554. /* TV - TV DAC */
  1555. ddc_i2c.valid = false;
  1556. hpd.hpd = RADEON_HPD_NONE;
  1557. radeon_add_legacy_encoder(dev,
  1558. radeon_get_encoder_id(dev,
  1559. ATOM_DEVICE_TV1_SUPPORT,
  1560. 2),
  1561. ATOM_DEVICE_TV1_SUPPORT);
  1562. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1563. DRM_MODE_CONNECTOR_SVIDEO,
  1564. &ddc_i2c,
  1565. CONNECTOR_OBJECT_ID_SVIDEO,
  1566. &hpd);
  1567. break;
  1568. case CT_EMAC:
  1569. DRM_INFO("Connector Table: %d (emac)\n",
  1570. rdev->mode_info.connector_table);
  1571. /* VGA - primary dac */
  1572. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1573. hpd.hpd = RADEON_HPD_NONE;
  1574. radeon_add_legacy_encoder(dev,
  1575. radeon_get_encoder_id(dev,
  1576. ATOM_DEVICE_CRT1_SUPPORT,
  1577. 1),
  1578. ATOM_DEVICE_CRT1_SUPPORT);
  1579. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
  1580. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1581. CONNECTOR_OBJECT_ID_VGA,
  1582. &hpd);
  1583. /* VGA - tv dac */
  1584. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
  1585. hpd.hpd = RADEON_HPD_NONE;
  1586. radeon_add_legacy_encoder(dev,
  1587. radeon_get_encoder_id(dev,
  1588. ATOM_DEVICE_CRT2_SUPPORT,
  1589. 2),
  1590. ATOM_DEVICE_CRT2_SUPPORT);
  1591. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1592. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1593. CONNECTOR_OBJECT_ID_VGA,
  1594. &hpd);
  1595. /* TV - TV DAC */
  1596. ddc_i2c.valid = false;
  1597. hpd.hpd = RADEON_HPD_NONE;
  1598. radeon_add_legacy_encoder(dev,
  1599. radeon_get_encoder_id(dev,
  1600. ATOM_DEVICE_TV1_SUPPORT,
  1601. 2),
  1602. ATOM_DEVICE_TV1_SUPPORT);
  1603. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1604. DRM_MODE_CONNECTOR_SVIDEO,
  1605. &ddc_i2c,
  1606. CONNECTOR_OBJECT_ID_SVIDEO,
  1607. &hpd);
  1608. break;
  1609. default:
  1610. DRM_INFO("Connector table: %d (invalid)\n",
  1611. rdev->mode_info.connector_table);
  1612. return false;
  1613. }
  1614. radeon_link_encoder_connector(dev);
  1615. return true;
  1616. }
  1617. static bool radeon_apply_legacy_quirks(struct drm_device *dev,
  1618. int bios_index,
  1619. enum radeon_combios_connector
  1620. *legacy_connector,
  1621. struct radeon_i2c_bus_rec *ddc_i2c,
  1622. struct radeon_hpd *hpd)
  1623. {
  1624. struct radeon_device *rdev = dev->dev_private;
  1625. /* XPRESS DDC quirks */
  1626. if ((rdev->family == CHIP_RS400 ||
  1627. rdev->family == CHIP_RS480) &&
  1628. ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
  1629. *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
  1630. else if ((rdev->family == CHIP_RS400 ||
  1631. rdev->family == CHIP_RS480) &&
  1632. ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
  1633. *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
  1634. ddc_i2c->mask_clk_mask = (0x20 << 8);
  1635. ddc_i2c->mask_data_mask = 0x80;
  1636. ddc_i2c->a_clk_mask = (0x20 << 8);
  1637. ddc_i2c->a_data_mask = 0x80;
  1638. ddc_i2c->en_clk_mask = (0x20 << 8);
  1639. ddc_i2c->en_data_mask = 0x80;
  1640. ddc_i2c->y_clk_mask = (0x20 << 8);
  1641. ddc_i2c->y_data_mask = 0x80;
  1642. }
  1643. /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
  1644. if ((rdev->family >= CHIP_R300) &&
  1645. ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
  1646. *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1647. /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
  1648. one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
  1649. if (dev->pdev->device == 0x515e &&
  1650. dev->pdev->subsystem_vendor == 0x1014) {
  1651. if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
  1652. ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
  1653. return false;
  1654. }
  1655. /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */
  1656. if (dev->pdev->device == 0x5159 &&
  1657. dev->pdev->subsystem_vendor == 0x1002 &&
  1658. dev->pdev->subsystem_device == 0x013a) {
  1659. if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
  1660. *legacy_connector = CONNECTOR_CRT_LEGACY;
  1661. }
  1662. /* X300 card with extra non-existent DVI port */
  1663. if (dev->pdev->device == 0x5B60 &&
  1664. dev->pdev->subsystem_vendor == 0x17af &&
  1665. dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
  1666. if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
  1667. return false;
  1668. }
  1669. return true;
  1670. }
  1671. static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
  1672. {
  1673. /* Acer 5102 has non-existent TV port */
  1674. if (dev->pdev->device == 0x5975 &&
  1675. dev->pdev->subsystem_vendor == 0x1025 &&
  1676. dev->pdev->subsystem_device == 0x009f)
  1677. return false;
  1678. /* HP dc5750 has non-existent TV port */
  1679. if (dev->pdev->device == 0x5974 &&
  1680. dev->pdev->subsystem_vendor == 0x103c &&
  1681. dev->pdev->subsystem_device == 0x280a)
  1682. return false;
  1683. /* MSI S270 has non-existent TV port */
  1684. if (dev->pdev->device == 0x5955 &&
  1685. dev->pdev->subsystem_vendor == 0x1462 &&
  1686. dev->pdev->subsystem_device == 0x0131)
  1687. return false;
  1688. return true;
  1689. }
  1690. static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
  1691. {
  1692. struct radeon_device *rdev = dev->dev_private;
  1693. uint32_t ext_tmds_info;
  1694. if (rdev->flags & RADEON_IS_IGP) {
  1695. if (is_dvi_d)
  1696. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
  1697. else
  1698. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  1699. }
  1700. ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
  1701. if (ext_tmds_info) {
  1702. uint8_t rev = RBIOS8(ext_tmds_info);
  1703. uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
  1704. if (rev >= 3) {
  1705. if (is_dvi_d)
  1706. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
  1707. else
  1708. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
  1709. } else {
  1710. if (flags & 1) {
  1711. if (is_dvi_d)
  1712. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
  1713. else
  1714. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
  1715. }
  1716. }
  1717. }
  1718. if (is_dvi_d)
  1719. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
  1720. else
  1721. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  1722. }
  1723. bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
  1724. {
  1725. struct radeon_device *rdev = dev->dev_private;
  1726. uint32_t conn_info, entry, devices;
  1727. uint16_t tmp, connector_object_id;
  1728. enum radeon_combios_ddc ddc_type;
  1729. enum radeon_combios_connector connector;
  1730. int i = 0;
  1731. struct radeon_i2c_bus_rec ddc_i2c;
  1732. struct radeon_hpd hpd;
  1733. if (rdev->bios == NULL)
  1734. return false;
  1735. conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
  1736. if (conn_info) {
  1737. for (i = 0; i < 4; i++) {
  1738. entry = conn_info + 2 + i * 2;
  1739. if (!RBIOS16(entry))
  1740. break;
  1741. tmp = RBIOS16(entry);
  1742. connector = (tmp >> 12) & 0xf;
  1743. ddc_type = (tmp >> 8) & 0xf;
  1744. switch (ddc_type) {
  1745. case DDC_MONID:
  1746. ddc_i2c =
  1747. combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
  1748. break;
  1749. case DDC_DVI:
  1750. ddc_i2c =
  1751. combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1752. break;
  1753. case DDC_VGA:
  1754. ddc_i2c =
  1755. combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1756. break;
  1757. case DDC_CRT2:
  1758. ddc_i2c =
  1759. combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
  1760. break;
  1761. default:
  1762. break;
  1763. }
  1764. switch (connector) {
  1765. case CONNECTOR_PROPRIETARY_LEGACY:
  1766. case CONNECTOR_DVI_I_LEGACY:
  1767. case CONNECTOR_DVI_D_LEGACY:
  1768. if ((tmp >> 4) & 0x1)
  1769. hpd.hpd = RADEON_HPD_2;
  1770. else
  1771. hpd.hpd = RADEON_HPD_1;
  1772. break;
  1773. default:
  1774. hpd.hpd = RADEON_HPD_NONE;
  1775. break;
  1776. }
  1777. if (!radeon_apply_legacy_quirks(dev, i, &connector,
  1778. &ddc_i2c, &hpd))
  1779. continue;
  1780. switch (connector) {
  1781. case CONNECTOR_PROPRIETARY_LEGACY:
  1782. if ((tmp >> 4) & 0x1)
  1783. devices = ATOM_DEVICE_DFP2_SUPPORT;
  1784. else
  1785. devices = ATOM_DEVICE_DFP1_SUPPORT;
  1786. radeon_add_legacy_encoder(dev,
  1787. radeon_get_encoder_id
  1788. (dev, devices, 0),
  1789. devices);
  1790. radeon_add_legacy_connector(dev, i, devices,
  1791. legacy_connector_convert
  1792. [connector],
  1793. &ddc_i2c,
  1794. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
  1795. &hpd);
  1796. break;
  1797. case CONNECTOR_CRT_LEGACY:
  1798. if (tmp & 0x1) {
  1799. devices = ATOM_DEVICE_CRT2_SUPPORT;
  1800. radeon_add_legacy_encoder(dev,
  1801. radeon_get_encoder_id
  1802. (dev,
  1803. ATOM_DEVICE_CRT2_SUPPORT,
  1804. 2),
  1805. ATOM_DEVICE_CRT2_SUPPORT);
  1806. } else {
  1807. devices = ATOM_DEVICE_CRT1_SUPPORT;
  1808. radeon_add_legacy_encoder(dev,
  1809. radeon_get_encoder_id
  1810. (dev,
  1811. ATOM_DEVICE_CRT1_SUPPORT,
  1812. 1),
  1813. ATOM_DEVICE_CRT1_SUPPORT);
  1814. }
  1815. radeon_add_legacy_connector(dev,
  1816. i,
  1817. devices,
  1818. legacy_connector_convert
  1819. [connector],
  1820. &ddc_i2c,
  1821. CONNECTOR_OBJECT_ID_VGA,
  1822. &hpd);
  1823. break;
  1824. case CONNECTOR_DVI_I_LEGACY:
  1825. devices = 0;
  1826. if (tmp & 0x1) {
  1827. devices |= ATOM_DEVICE_CRT2_SUPPORT;
  1828. radeon_add_legacy_encoder(dev,
  1829. radeon_get_encoder_id
  1830. (dev,
  1831. ATOM_DEVICE_CRT2_SUPPORT,
  1832. 2),
  1833. ATOM_DEVICE_CRT2_SUPPORT);
  1834. } else {
  1835. devices |= ATOM_DEVICE_CRT1_SUPPORT;
  1836. radeon_add_legacy_encoder(dev,
  1837. radeon_get_encoder_id
  1838. (dev,
  1839. ATOM_DEVICE_CRT1_SUPPORT,
  1840. 1),
  1841. ATOM_DEVICE_CRT1_SUPPORT);
  1842. }
  1843. if ((tmp >> 4) & 0x1) {
  1844. devices |= ATOM_DEVICE_DFP2_SUPPORT;
  1845. radeon_add_legacy_encoder(dev,
  1846. radeon_get_encoder_id
  1847. (dev,
  1848. ATOM_DEVICE_DFP2_SUPPORT,
  1849. 0),
  1850. ATOM_DEVICE_DFP2_SUPPORT);
  1851. connector_object_id = combios_check_dl_dvi(dev, 0);
  1852. } else {
  1853. devices |= ATOM_DEVICE_DFP1_SUPPORT;
  1854. radeon_add_legacy_encoder(dev,
  1855. radeon_get_encoder_id
  1856. (dev,
  1857. ATOM_DEVICE_DFP1_SUPPORT,
  1858. 0),
  1859. ATOM_DEVICE_DFP1_SUPPORT);
  1860. connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  1861. }
  1862. radeon_add_legacy_connector(dev,
  1863. i,
  1864. devices,
  1865. legacy_connector_convert
  1866. [connector],
  1867. &ddc_i2c,
  1868. connector_object_id,
  1869. &hpd);
  1870. break;
  1871. case CONNECTOR_DVI_D_LEGACY:
  1872. if ((tmp >> 4) & 0x1) {
  1873. devices = ATOM_DEVICE_DFP2_SUPPORT;
  1874. connector_object_id = combios_check_dl_dvi(dev, 1);
  1875. } else {
  1876. devices = ATOM_DEVICE_DFP1_SUPPORT;
  1877. connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  1878. }
  1879. radeon_add_legacy_encoder(dev,
  1880. radeon_get_encoder_id
  1881. (dev, devices, 0),
  1882. devices);
  1883. radeon_add_legacy_connector(dev, i, devices,
  1884. legacy_connector_convert
  1885. [connector],
  1886. &ddc_i2c,
  1887. connector_object_id,
  1888. &hpd);
  1889. break;
  1890. case CONNECTOR_CTV_LEGACY:
  1891. case CONNECTOR_STV_LEGACY:
  1892. radeon_add_legacy_encoder(dev,
  1893. radeon_get_encoder_id
  1894. (dev,
  1895. ATOM_DEVICE_TV1_SUPPORT,
  1896. 2),
  1897. ATOM_DEVICE_TV1_SUPPORT);
  1898. radeon_add_legacy_connector(dev, i,
  1899. ATOM_DEVICE_TV1_SUPPORT,
  1900. legacy_connector_convert
  1901. [connector],
  1902. &ddc_i2c,
  1903. CONNECTOR_OBJECT_ID_SVIDEO,
  1904. &hpd);
  1905. break;
  1906. default:
  1907. DRM_ERROR("Unknown connector type: %d\n",
  1908. connector);
  1909. continue;
  1910. }
  1911. }
  1912. } else {
  1913. uint16_t tmds_info =
  1914. combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
  1915. if (tmds_info) {
  1916. DRM_DEBUG("Found DFP table, assuming DVI connector\n");
  1917. radeon_add_legacy_encoder(dev,
  1918. radeon_get_encoder_id(dev,
  1919. ATOM_DEVICE_CRT1_SUPPORT,
  1920. 1),
  1921. ATOM_DEVICE_CRT1_SUPPORT);
  1922. radeon_add_legacy_encoder(dev,
  1923. radeon_get_encoder_id(dev,
  1924. ATOM_DEVICE_DFP1_SUPPORT,
  1925. 0),
  1926. ATOM_DEVICE_DFP1_SUPPORT);
  1927. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
  1928. hpd.hpd = RADEON_HPD_NONE;
  1929. radeon_add_legacy_connector(dev,
  1930. 0,
  1931. ATOM_DEVICE_CRT1_SUPPORT |
  1932. ATOM_DEVICE_DFP1_SUPPORT,
  1933. DRM_MODE_CONNECTOR_DVII,
  1934. &ddc_i2c,
  1935. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1936. &hpd);
  1937. } else {
  1938. uint16_t crt_info =
  1939. combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
  1940. DRM_DEBUG("Found CRT table, assuming VGA connector\n");
  1941. if (crt_info) {
  1942. radeon_add_legacy_encoder(dev,
  1943. radeon_get_encoder_id(dev,
  1944. ATOM_DEVICE_CRT1_SUPPORT,
  1945. 1),
  1946. ATOM_DEVICE_CRT1_SUPPORT);
  1947. ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
  1948. hpd.hpd = RADEON_HPD_NONE;
  1949. radeon_add_legacy_connector(dev,
  1950. 0,
  1951. ATOM_DEVICE_CRT1_SUPPORT,
  1952. DRM_MODE_CONNECTOR_VGA,
  1953. &ddc_i2c,
  1954. CONNECTOR_OBJECT_ID_VGA,
  1955. &hpd);
  1956. } else {
  1957. DRM_DEBUG("No connector info found\n");
  1958. return false;
  1959. }
  1960. }
  1961. }
  1962. if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
  1963. uint16_t lcd_info =
  1964. combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
  1965. if (lcd_info) {
  1966. uint16_t lcd_ddc_info =
  1967. combios_get_table_offset(dev,
  1968. COMBIOS_LCD_DDC_INFO_TABLE);
  1969. radeon_add_legacy_encoder(dev,
  1970. radeon_get_encoder_id(dev,
  1971. ATOM_DEVICE_LCD1_SUPPORT,
  1972. 0),
  1973. ATOM_DEVICE_LCD1_SUPPORT);
  1974. if (lcd_ddc_info) {
  1975. ddc_type = RBIOS8(lcd_ddc_info + 2);
  1976. switch (ddc_type) {
  1977. case DDC_MONID:
  1978. ddc_i2c =
  1979. combios_setup_i2c_bus
  1980. (rdev, RADEON_GPIO_MONID);
  1981. break;
  1982. case DDC_DVI:
  1983. ddc_i2c =
  1984. combios_setup_i2c_bus
  1985. (rdev, RADEON_GPIO_DVI_DDC);
  1986. break;
  1987. case DDC_VGA:
  1988. ddc_i2c =
  1989. combios_setup_i2c_bus
  1990. (rdev, RADEON_GPIO_VGA_DDC);
  1991. break;
  1992. case DDC_CRT2:
  1993. ddc_i2c =
  1994. combios_setup_i2c_bus
  1995. (rdev, RADEON_GPIO_CRT2_DDC);
  1996. break;
  1997. case DDC_LCD:
  1998. ddc_i2c =
  1999. combios_setup_i2c_bus
  2000. (rdev, RADEON_GPIOPAD_MASK);
  2001. ddc_i2c.mask_clk_mask =
  2002. RBIOS32(lcd_ddc_info + 3);
  2003. ddc_i2c.mask_data_mask =
  2004. RBIOS32(lcd_ddc_info + 7);
  2005. ddc_i2c.a_clk_mask =
  2006. RBIOS32(lcd_ddc_info + 3);
  2007. ddc_i2c.a_data_mask =
  2008. RBIOS32(lcd_ddc_info + 7);
  2009. ddc_i2c.en_clk_mask =
  2010. RBIOS32(lcd_ddc_info + 3);
  2011. ddc_i2c.en_data_mask =
  2012. RBIOS32(lcd_ddc_info + 7);
  2013. ddc_i2c.y_clk_mask =
  2014. RBIOS32(lcd_ddc_info + 3);
  2015. ddc_i2c.y_data_mask =
  2016. RBIOS32(lcd_ddc_info + 7);
  2017. break;
  2018. case DDC_GPIO:
  2019. ddc_i2c =
  2020. combios_setup_i2c_bus
  2021. (rdev, RADEON_MDGPIO_MASK);
  2022. ddc_i2c.mask_clk_mask =
  2023. RBIOS32(lcd_ddc_info + 3);
  2024. ddc_i2c.mask_data_mask =
  2025. RBIOS32(lcd_ddc_info + 7);
  2026. ddc_i2c.a_clk_mask =
  2027. RBIOS32(lcd_ddc_info + 3);
  2028. ddc_i2c.a_data_mask =
  2029. RBIOS32(lcd_ddc_info + 7);
  2030. ddc_i2c.en_clk_mask =
  2031. RBIOS32(lcd_ddc_info + 3);
  2032. ddc_i2c.en_data_mask =
  2033. RBIOS32(lcd_ddc_info + 7);
  2034. ddc_i2c.y_clk_mask =
  2035. RBIOS32(lcd_ddc_info + 3);
  2036. ddc_i2c.y_data_mask =
  2037. RBIOS32(lcd_ddc_info + 7);
  2038. break;
  2039. default:
  2040. ddc_i2c.valid = false;
  2041. break;
  2042. }
  2043. DRM_DEBUG("LCD DDC Info Table found!\n");
  2044. } else
  2045. ddc_i2c.valid = false;
  2046. hpd.hpd = RADEON_HPD_NONE;
  2047. radeon_add_legacy_connector(dev,
  2048. 5,
  2049. ATOM_DEVICE_LCD1_SUPPORT,
  2050. DRM_MODE_CONNECTOR_LVDS,
  2051. &ddc_i2c,
  2052. CONNECTOR_OBJECT_ID_LVDS,
  2053. &hpd);
  2054. }
  2055. }
  2056. /* check TV table */
  2057. if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
  2058. uint32_t tv_info =
  2059. combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
  2060. if (tv_info) {
  2061. if (RBIOS8(tv_info + 6) == 'T') {
  2062. if (radeon_apply_legacy_tv_quirks(dev)) {
  2063. hpd.hpd = RADEON_HPD_NONE;
  2064. radeon_add_legacy_encoder(dev,
  2065. radeon_get_encoder_id
  2066. (dev,
  2067. ATOM_DEVICE_TV1_SUPPORT,
  2068. 2),
  2069. ATOM_DEVICE_TV1_SUPPORT);
  2070. radeon_add_legacy_connector(dev, 6,
  2071. ATOM_DEVICE_TV1_SUPPORT,
  2072. DRM_MODE_CONNECTOR_SVIDEO,
  2073. &ddc_i2c,
  2074. CONNECTOR_OBJECT_ID_SVIDEO,
  2075. &hpd);
  2076. }
  2077. }
  2078. }
  2079. }
  2080. radeon_link_encoder_connector(dev);
  2081. return true;
  2082. }
  2083. void radeon_external_tmds_setup(struct drm_encoder *encoder)
  2084. {
  2085. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2086. struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
  2087. if (!tmds)
  2088. return;
  2089. switch (tmds->dvo_chip) {
  2090. case DVO_SIL164:
  2091. /* sil 164 */
  2092. radeon_i2c_do_lock(tmds->i2c_bus, 1);
  2093. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2094. tmds->slave_addr,
  2095. 0x08, 0x30);
  2096. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2097. tmds->slave_addr,
  2098. 0x09, 0x00);
  2099. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2100. tmds->slave_addr,
  2101. 0x0a, 0x90);
  2102. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2103. tmds->slave_addr,
  2104. 0x0c, 0x89);
  2105. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2106. tmds->slave_addr,
  2107. 0x08, 0x3b);
  2108. radeon_i2c_do_lock(tmds->i2c_bus, 0);
  2109. break;
  2110. case DVO_SIL1178:
  2111. /* sil 1178 - untested */
  2112. /*
  2113. * 0x0f, 0x44
  2114. * 0x0f, 0x4c
  2115. * 0x0e, 0x01
  2116. * 0x0a, 0x80
  2117. * 0x09, 0x30
  2118. * 0x0c, 0xc9
  2119. * 0x0d, 0x70
  2120. * 0x08, 0x32
  2121. * 0x08, 0x33
  2122. */
  2123. break;
  2124. default:
  2125. break;
  2126. }
  2127. }
  2128. bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
  2129. {
  2130. struct drm_device *dev = encoder->dev;
  2131. struct radeon_device *rdev = dev->dev_private;
  2132. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2133. uint16_t offset;
  2134. uint8_t blocks, slave_addr, rev;
  2135. uint32_t index, id;
  2136. uint32_t reg, val, and_mask, or_mask;
  2137. struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
  2138. if (rdev->bios == NULL)
  2139. return false;
  2140. if (!tmds)
  2141. return false;
  2142. if (rdev->flags & RADEON_IS_IGP) {
  2143. offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
  2144. rev = RBIOS8(offset);
  2145. if (offset) {
  2146. rev = RBIOS8(offset);
  2147. if (rev > 1) {
  2148. blocks = RBIOS8(offset + 3);
  2149. index = offset + 4;
  2150. while (blocks > 0) {
  2151. id = RBIOS16(index);
  2152. index += 2;
  2153. switch (id >> 13) {
  2154. case 0:
  2155. reg = (id & 0x1fff) * 4;
  2156. val = RBIOS32(index);
  2157. index += 4;
  2158. WREG32(reg, val);
  2159. break;
  2160. case 2:
  2161. reg = (id & 0x1fff) * 4;
  2162. and_mask = RBIOS32(index);
  2163. index += 4;
  2164. or_mask = RBIOS32(index);
  2165. index += 4;
  2166. val = RREG32(reg);
  2167. val = (val & and_mask) | or_mask;
  2168. WREG32(reg, val);
  2169. break;
  2170. case 3:
  2171. val = RBIOS16(index);
  2172. index += 2;
  2173. udelay(val);
  2174. break;
  2175. case 4:
  2176. val = RBIOS16(index);
  2177. index += 2;
  2178. udelay(val * 1000);
  2179. break;
  2180. case 6:
  2181. slave_addr = id & 0xff;
  2182. slave_addr >>= 1; /* 7 bit addressing */
  2183. index++;
  2184. reg = RBIOS8(index);
  2185. index++;
  2186. val = RBIOS8(index);
  2187. index++;
  2188. radeon_i2c_do_lock(tmds->i2c_bus, 1);
  2189. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2190. slave_addr,
  2191. reg, val);
  2192. radeon_i2c_do_lock(tmds->i2c_bus, 0);
  2193. break;
  2194. default:
  2195. DRM_ERROR("Unknown id %d\n", id >> 13);
  2196. break;
  2197. }
  2198. blocks--;
  2199. }
  2200. return true;
  2201. }
  2202. }
  2203. } else {
  2204. offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
  2205. if (offset) {
  2206. index = offset + 10;
  2207. id = RBIOS16(index);
  2208. while (id != 0xffff) {
  2209. index += 2;
  2210. switch (id >> 13) {
  2211. case 0:
  2212. reg = (id & 0x1fff) * 4;
  2213. val = RBIOS32(index);
  2214. WREG32(reg, val);
  2215. break;
  2216. case 2:
  2217. reg = (id & 0x1fff) * 4;
  2218. and_mask = RBIOS32(index);
  2219. index += 4;
  2220. or_mask = RBIOS32(index);
  2221. index += 4;
  2222. val = RREG32(reg);
  2223. val = (val & and_mask) | or_mask;
  2224. WREG32(reg, val);
  2225. break;
  2226. case 4:
  2227. val = RBIOS16(index);
  2228. index += 2;
  2229. udelay(val);
  2230. break;
  2231. case 5:
  2232. reg = id & 0x1fff;
  2233. and_mask = RBIOS32(index);
  2234. index += 4;
  2235. or_mask = RBIOS32(index);
  2236. index += 4;
  2237. val = RREG32_PLL(reg);
  2238. val = (val & and_mask) | or_mask;
  2239. WREG32_PLL(reg, val);
  2240. break;
  2241. case 6:
  2242. reg = id & 0x1fff;
  2243. val = RBIOS8(index);
  2244. index += 1;
  2245. radeon_i2c_do_lock(tmds->i2c_bus, 1);
  2246. radeon_i2c_sw_put_byte(tmds->i2c_bus,
  2247. tmds->slave_addr,
  2248. reg, val);
  2249. radeon_i2c_do_lock(tmds->i2c_bus, 0);
  2250. break;
  2251. default:
  2252. DRM_ERROR("Unknown id %d\n", id >> 13);
  2253. break;
  2254. }
  2255. id = RBIOS16(index);
  2256. }
  2257. return true;
  2258. }
  2259. }
  2260. return false;
  2261. }
  2262. static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
  2263. {
  2264. struct radeon_device *rdev = dev->dev_private;
  2265. if (offset) {
  2266. while (RBIOS16(offset)) {
  2267. uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
  2268. uint32_t addr = (RBIOS16(offset) & 0x1fff);
  2269. uint32_t val, and_mask, or_mask;
  2270. uint32_t tmp;
  2271. offset += 2;
  2272. switch (cmd) {
  2273. case 0:
  2274. val = RBIOS32(offset);
  2275. offset += 4;
  2276. WREG32(addr, val);
  2277. break;
  2278. case 1:
  2279. val = RBIOS32(offset);
  2280. offset += 4;
  2281. WREG32(addr, val);
  2282. break;
  2283. case 2:
  2284. and_mask = RBIOS32(offset);
  2285. offset += 4;
  2286. or_mask = RBIOS32(offset);
  2287. offset += 4;
  2288. tmp = RREG32(addr);
  2289. tmp &= and_mask;
  2290. tmp |= or_mask;
  2291. WREG32(addr, tmp);
  2292. break;
  2293. case 3:
  2294. and_mask = RBIOS32(offset);
  2295. offset += 4;
  2296. or_mask = RBIOS32(offset);
  2297. offset += 4;
  2298. tmp = RREG32(addr);
  2299. tmp &= and_mask;
  2300. tmp |= or_mask;
  2301. WREG32(addr, tmp);
  2302. break;
  2303. case 4:
  2304. val = RBIOS16(offset);
  2305. offset += 2;
  2306. udelay(val);
  2307. break;
  2308. case 5:
  2309. val = RBIOS16(offset);
  2310. offset += 2;
  2311. switch (addr) {
  2312. case 8:
  2313. while (val--) {
  2314. if (!
  2315. (RREG32_PLL
  2316. (RADEON_CLK_PWRMGT_CNTL) &
  2317. RADEON_MC_BUSY))
  2318. break;
  2319. }
  2320. break;
  2321. case 9:
  2322. while (val--) {
  2323. if ((RREG32(RADEON_MC_STATUS) &
  2324. RADEON_MC_IDLE))
  2325. break;
  2326. }
  2327. break;
  2328. default:
  2329. break;
  2330. }
  2331. break;
  2332. default:
  2333. break;
  2334. }
  2335. }
  2336. }
  2337. }
  2338. static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
  2339. {
  2340. struct radeon_device *rdev = dev->dev_private;
  2341. if (offset) {
  2342. while (RBIOS8(offset)) {
  2343. uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
  2344. uint8_t addr = (RBIOS8(offset) & 0x3f);
  2345. uint32_t val, shift, tmp;
  2346. uint32_t and_mask, or_mask;
  2347. offset++;
  2348. switch (cmd) {
  2349. case 0:
  2350. val = RBIOS32(offset);
  2351. offset += 4;
  2352. WREG32_PLL(addr, val);
  2353. break;
  2354. case 1:
  2355. shift = RBIOS8(offset) * 8;
  2356. offset++;
  2357. and_mask = RBIOS8(offset) << shift;
  2358. and_mask |= ~(0xff << shift);
  2359. offset++;
  2360. or_mask = RBIOS8(offset) << shift;
  2361. offset++;
  2362. tmp = RREG32_PLL(addr);
  2363. tmp &= and_mask;
  2364. tmp |= or_mask;
  2365. WREG32_PLL(addr, tmp);
  2366. break;
  2367. case 2:
  2368. case 3:
  2369. tmp = 1000;
  2370. switch (addr) {
  2371. case 1:
  2372. udelay(150);
  2373. break;
  2374. case 2:
  2375. udelay(1000);
  2376. break;
  2377. case 3:
  2378. while (tmp--) {
  2379. if (!
  2380. (RREG32_PLL
  2381. (RADEON_CLK_PWRMGT_CNTL) &
  2382. RADEON_MC_BUSY))
  2383. break;
  2384. }
  2385. break;
  2386. case 4:
  2387. while (tmp--) {
  2388. if (RREG32_PLL
  2389. (RADEON_CLK_PWRMGT_CNTL) &
  2390. RADEON_DLL_READY)
  2391. break;
  2392. }
  2393. break;
  2394. case 5:
  2395. tmp =
  2396. RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
  2397. if (tmp & RADEON_CG_NO1_DEBUG_0) {
  2398. #if 0
  2399. uint32_t mclk_cntl =
  2400. RREG32_PLL
  2401. (RADEON_MCLK_CNTL);
  2402. mclk_cntl &= 0xffff0000;
  2403. /*mclk_cntl |= 0x00001111;*//* ??? */
  2404. WREG32_PLL(RADEON_MCLK_CNTL,
  2405. mclk_cntl);
  2406. udelay(10000);
  2407. #endif
  2408. WREG32_PLL
  2409. (RADEON_CLK_PWRMGT_CNTL,
  2410. tmp &
  2411. ~RADEON_CG_NO1_DEBUG_0);
  2412. udelay(10000);
  2413. }
  2414. break;
  2415. default:
  2416. break;
  2417. }
  2418. break;
  2419. default:
  2420. break;
  2421. }
  2422. }
  2423. }
  2424. }
  2425. static void combios_parse_ram_reset_table(struct drm_device *dev,
  2426. uint16_t offset)
  2427. {
  2428. struct radeon_device *rdev = dev->dev_private;
  2429. uint32_t tmp;
  2430. if (offset) {
  2431. uint8_t val = RBIOS8(offset);
  2432. while (val != 0xff) {
  2433. offset++;
  2434. if (val == 0x0f) {
  2435. uint32_t channel_complete_mask;
  2436. if (ASIC_IS_R300(rdev))
  2437. channel_complete_mask =
  2438. R300_MEM_PWRUP_COMPLETE;
  2439. else
  2440. channel_complete_mask =
  2441. RADEON_MEM_PWRUP_COMPLETE;
  2442. tmp = 20000;
  2443. while (tmp--) {
  2444. if ((RREG32(RADEON_MEM_STR_CNTL) &
  2445. channel_complete_mask) ==
  2446. channel_complete_mask)
  2447. break;
  2448. }
  2449. } else {
  2450. uint32_t or_mask = RBIOS16(offset);
  2451. offset += 2;
  2452. tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
  2453. tmp &= RADEON_SDRAM_MODE_MASK;
  2454. tmp |= or_mask;
  2455. WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
  2456. or_mask = val << 24;
  2457. tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
  2458. tmp &= RADEON_B3MEM_RESET_MASK;
  2459. tmp |= or_mask;
  2460. WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
  2461. }
  2462. val = RBIOS8(offset);
  2463. }
  2464. }
  2465. }
  2466. static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
  2467. int mem_addr_mapping)
  2468. {
  2469. struct radeon_device *rdev = dev->dev_private;
  2470. uint32_t mem_cntl;
  2471. uint32_t mem_size;
  2472. uint32_t addr = 0;
  2473. mem_cntl = RREG32(RADEON_MEM_CNTL);
  2474. if (mem_cntl & RV100_HALF_MODE)
  2475. ram /= 2;
  2476. mem_size = ram;
  2477. mem_cntl &= ~(0xff << 8);
  2478. mem_cntl |= (mem_addr_mapping & 0xff) << 8;
  2479. WREG32(RADEON_MEM_CNTL, mem_cntl);
  2480. RREG32(RADEON_MEM_CNTL);
  2481. /* sdram reset ? */
  2482. /* something like this???? */
  2483. while (ram--) {
  2484. addr = ram * 1024 * 1024;
  2485. /* write to each page */
  2486. WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
  2487. WREG32(RADEON_MM_DATA, 0xdeadbeef);
  2488. /* read back and verify */
  2489. WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
  2490. if (RREG32(RADEON_MM_DATA) != 0xdeadbeef)
  2491. return 0;
  2492. }
  2493. return mem_size;
  2494. }
  2495. static void combios_write_ram_size(struct drm_device *dev)
  2496. {
  2497. struct radeon_device *rdev = dev->dev_private;
  2498. uint8_t rev;
  2499. uint16_t offset;
  2500. uint32_t mem_size = 0;
  2501. uint32_t mem_cntl = 0;
  2502. /* should do something smarter here I guess... */
  2503. if (rdev->flags & RADEON_IS_IGP)
  2504. return;
  2505. /* first check detected mem table */
  2506. offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
  2507. if (offset) {
  2508. rev = RBIOS8(offset);
  2509. if (rev < 3) {
  2510. mem_cntl = RBIOS32(offset + 1);
  2511. mem_size = RBIOS16(offset + 5);
  2512. if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) &&
  2513. ((dev->pdev->device != 0x515e)
  2514. && (dev->pdev->device != 0x5969)))
  2515. WREG32(RADEON_MEM_CNTL, mem_cntl);
  2516. }
  2517. }
  2518. if (!mem_size) {
  2519. offset =
  2520. combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
  2521. if (offset) {
  2522. rev = RBIOS8(offset - 1);
  2523. if (rev < 1) {
  2524. if (((rdev->flags & RADEON_FAMILY_MASK) <
  2525. CHIP_R200)
  2526. && ((dev->pdev->device != 0x515e)
  2527. && (dev->pdev->device != 0x5969))) {
  2528. int ram = 0;
  2529. int mem_addr_mapping = 0;
  2530. while (RBIOS8(offset)) {
  2531. ram = RBIOS8(offset);
  2532. mem_addr_mapping =
  2533. RBIOS8(offset + 1);
  2534. if (mem_addr_mapping != 0x25)
  2535. ram *= 2;
  2536. mem_size =
  2537. combios_detect_ram(dev, ram,
  2538. mem_addr_mapping);
  2539. if (mem_size)
  2540. break;
  2541. offset += 2;
  2542. }
  2543. } else
  2544. mem_size = RBIOS8(offset);
  2545. } else {
  2546. mem_size = RBIOS8(offset);
  2547. mem_size *= 2; /* convert to MB */
  2548. }
  2549. }
  2550. }
  2551. mem_size *= (1024 * 1024); /* convert to bytes */
  2552. WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
  2553. }
  2554. void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable)
  2555. {
  2556. uint16_t dyn_clk_info =
  2557. combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
  2558. if (dyn_clk_info)
  2559. combios_parse_pll_table(dev, dyn_clk_info);
  2560. }
  2561. void radeon_combios_asic_init(struct drm_device *dev)
  2562. {
  2563. struct radeon_device *rdev = dev->dev_private;
  2564. uint16_t table;
  2565. /* port hardcoded mac stuff from radeonfb */
  2566. if (rdev->bios == NULL)
  2567. return;
  2568. /* ASIC INIT 1 */
  2569. table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
  2570. if (table)
  2571. combios_parse_mmio_table(dev, table);
  2572. /* PLL INIT */
  2573. table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
  2574. if (table)
  2575. combios_parse_pll_table(dev, table);
  2576. /* ASIC INIT 2 */
  2577. table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
  2578. if (table)
  2579. combios_parse_mmio_table(dev, table);
  2580. if (!(rdev->flags & RADEON_IS_IGP)) {
  2581. /* ASIC INIT 4 */
  2582. table =
  2583. combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
  2584. if (table)
  2585. combios_parse_mmio_table(dev, table);
  2586. /* RAM RESET */
  2587. table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
  2588. if (table)
  2589. combios_parse_ram_reset_table(dev, table);
  2590. /* ASIC INIT 3 */
  2591. table =
  2592. combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
  2593. if (table)
  2594. combios_parse_mmio_table(dev, table);
  2595. /* write CONFIG_MEMSIZE */
  2596. combios_write_ram_size(dev);
  2597. }
  2598. /* DYN CLK 1 */
  2599. table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
  2600. if (table)
  2601. combios_parse_pll_table(dev, table);
  2602. }
  2603. void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
  2604. {
  2605. struct radeon_device *rdev = dev->dev_private;
  2606. uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
  2607. bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
  2608. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  2609. bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
  2610. /* let the bios control the backlight */
  2611. bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
  2612. /* tell the bios not to handle mode switching */
  2613. bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
  2614. RADEON_ACC_MODE_CHANGE);
  2615. /* tell the bios a driver is loaded */
  2616. bios_7_scratch |= RADEON_DRV_LOADED;
  2617. WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
  2618. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  2619. WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
  2620. }
  2621. void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
  2622. {
  2623. struct drm_device *dev = encoder->dev;
  2624. struct radeon_device *rdev = dev->dev_private;
  2625. uint32_t bios_6_scratch;
  2626. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  2627. if (lock)
  2628. bios_6_scratch |= RADEON_DRIVER_CRITICAL;
  2629. else
  2630. bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
  2631. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  2632. }
  2633. void
  2634. radeon_combios_connected_scratch_regs(struct drm_connector *connector,
  2635. struct drm_encoder *encoder,
  2636. bool connected)
  2637. {
  2638. struct drm_device *dev = connector->dev;
  2639. struct radeon_device *rdev = dev->dev_private;
  2640. struct radeon_connector *radeon_connector =
  2641. to_radeon_connector(connector);
  2642. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2643. uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
  2644. uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
  2645. if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
  2646. (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
  2647. if (connected) {
  2648. DRM_DEBUG("TV1 connected\n");
  2649. /* fix me */
  2650. bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
  2651. /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
  2652. bios_5_scratch |= RADEON_TV1_ON;
  2653. bios_5_scratch |= RADEON_ACC_REQ_TV1;
  2654. } else {
  2655. DRM_DEBUG("TV1 disconnected\n");
  2656. bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
  2657. bios_5_scratch &= ~RADEON_TV1_ON;
  2658. bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
  2659. }
  2660. }
  2661. if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
  2662. (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
  2663. if (connected) {
  2664. DRM_DEBUG("LCD1 connected\n");
  2665. bios_4_scratch |= RADEON_LCD1_ATTACHED;
  2666. bios_5_scratch |= RADEON_LCD1_ON;
  2667. bios_5_scratch |= RADEON_ACC_REQ_LCD1;
  2668. } else {
  2669. DRM_DEBUG("LCD1 disconnected\n");
  2670. bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
  2671. bios_5_scratch &= ~RADEON_LCD1_ON;
  2672. bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
  2673. }
  2674. }
  2675. if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
  2676. (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
  2677. if (connected) {
  2678. DRM_DEBUG("CRT1 connected\n");
  2679. bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
  2680. bios_5_scratch |= RADEON_CRT1_ON;
  2681. bios_5_scratch |= RADEON_ACC_REQ_CRT1;
  2682. } else {
  2683. DRM_DEBUG("CRT1 disconnected\n");
  2684. bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
  2685. bios_5_scratch &= ~RADEON_CRT1_ON;
  2686. bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
  2687. }
  2688. }
  2689. if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
  2690. (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
  2691. if (connected) {
  2692. DRM_DEBUG("CRT2 connected\n");
  2693. bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
  2694. bios_5_scratch |= RADEON_CRT2_ON;
  2695. bios_5_scratch |= RADEON_ACC_REQ_CRT2;
  2696. } else {
  2697. DRM_DEBUG("CRT2 disconnected\n");
  2698. bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
  2699. bios_5_scratch &= ~RADEON_CRT2_ON;
  2700. bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
  2701. }
  2702. }
  2703. if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
  2704. (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
  2705. if (connected) {
  2706. DRM_DEBUG("DFP1 connected\n");
  2707. bios_4_scratch |= RADEON_DFP1_ATTACHED;
  2708. bios_5_scratch |= RADEON_DFP1_ON;
  2709. bios_5_scratch |= RADEON_ACC_REQ_DFP1;
  2710. } else {
  2711. DRM_DEBUG("DFP1 disconnected\n");
  2712. bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
  2713. bios_5_scratch &= ~RADEON_DFP1_ON;
  2714. bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
  2715. }
  2716. }
  2717. if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
  2718. (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
  2719. if (connected) {
  2720. DRM_DEBUG("DFP2 connected\n");
  2721. bios_4_scratch |= RADEON_DFP2_ATTACHED;
  2722. bios_5_scratch |= RADEON_DFP2_ON;
  2723. bios_5_scratch |= RADEON_ACC_REQ_DFP2;
  2724. } else {
  2725. DRM_DEBUG("DFP2 disconnected\n");
  2726. bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
  2727. bios_5_scratch &= ~RADEON_DFP2_ON;
  2728. bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
  2729. }
  2730. }
  2731. WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
  2732. WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
  2733. }
  2734. void
  2735. radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
  2736. {
  2737. struct drm_device *dev = encoder->dev;
  2738. struct radeon_device *rdev = dev->dev_private;
  2739. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2740. uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
  2741. if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
  2742. bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
  2743. bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
  2744. }
  2745. if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
  2746. bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
  2747. bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
  2748. }
  2749. if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
  2750. bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
  2751. bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
  2752. }
  2753. if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
  2754. bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
  2755. bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
  2756. }
  2757. if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
  2758. bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
  2759. bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
  2760. }
  2761. if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
  2762. bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
  2763. bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
  2764. }
  2765. WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
  2766. }
  2767. void
  2768. radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
  2769. {
  2770. struct drm_device *dev = encoder->dev;
  2771. struct radeon_device *rdev = dev->dev_private;
  2772. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2773. uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  2774. if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
  2775. if (on)
  2776. bios_6_scratch |= RADEON_TV_DPMS_ON;
  2777. else
  2778. bios_6_scratch &= ~RADEON_TV_DPMS_ON;
  2779. }
  2780. if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
  2781. if (on)
  2782. bios_6_scratch |= RADEON_CRT_DPMS_ON;
  2783. else
  2784. bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
  2785. }
  2786. if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
  2787. if (on)
  2788. bios_6_scratch |= RADEON_LCD_DPMS_ON;
  2789. else
  2790. bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
  2791. }
  2792. if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
  2793. if (on)
  2794. bios_6_scratch |= RADEON_DFP_DPMS_ON;
  2795. else
  2796. bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
  2797. }
  2798. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  2799. }