radeon_combios.c 104 KB

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