radeon_combios.c 98 KB

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