radeon_combios.c 83 KB

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