radeon_combios.c 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667
  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. if (!found) /* fallback to defaults */
  913. radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac);
  914. return p_dac;
  915. }
  916. enum radeon_tv_std
  917. radeon_combios_get_tv_info(struct radeon_device *rdev)
  918. {
  919. struct drm_device *dev = rdev->ddev;
  920. uint16_t tv_info;
  921. enum radeon_tv_std tv_std = TV_STD_NTSC;
  922. tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
  923. if (tv_info) {
  924. if (RBIOS8(tv_info + 6) == 'T') {
  925. switch (RBIOS8(tv_info + 7) & 0xf) {
  926. case 1:
  927. tv_std = TV_STD_NTSC;
  928. DRM_DEBUG_KMS("Default TV standard: NTSC\n");
  929. break;
  930. case 2:
  931. tv_std = TV_STD_PAL;
  932. DRM_DEBUG_KMS("Default TV standard: PAL\n");
  933. break;
  934. case 3:
  935. tv_std = TV_STD_PAL_M;
  936. DRM_DEBUG_KMS("Default TV standard: PAL-M\n");
  937. break;
  938. case 4:
  939. tv_std = TV_STD_PAL_60;
  940. DRM_DEBUG_KMS("Default TV standard: PAL-60\n");
  941. break;
  942. case 5:
  943. tv_std = TV_STD_NTSC_J;
  944. DRM_DEBUG_KMS("Default TV standard: NTSC-J\n");
  945. break;
  946. case 6:
  947. tv_std = TV_STD_SCART_PAL;
  948. DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n");
  949. break;
  950. default:
  951. tv_std = TV_STD_NTSC;
  952. DRM_DEBUG_KMS
  953. ("Unknown TV standard; defaulting to NTSC\n");
  954. break;
  955. }
  956. switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
  957. case 0:
  958. DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n");
  959. break;
  960. case 1:
  961. DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n");
  962. break;
  963. case 2:
  964. DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n");
  965. break;
  966. case 3:
  967. DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n");
  968. break;
  969. default:
  970. break;
  971. }
  972. }
  973. }
  974. return tv_std;
  975. }
  976. static const uint32_t default_tvdac_adj[CHIP_LAST] = {
  977. 0x00000000, /* r100 */
  978. 0x00280000, /* rv100 */
  979. 0x00000000, /* rs100 */
  980. 0x00880000, /* rv200 */
  981. 0x00000000, /* rs200 */
  982. 0x00000000, /* r200 */
  983. 0x00770000, /* rv250 */
  984. 0x00290000, /* rs300 */
  985. 0x00560000, /* rv280 */
  986. 0x00780000, /* r300 */
  987. 0x00770000, /* r350 */
  988. 0x00780000, /* rv350 */
  989. 0x00780000, /* rv380 */
  990. 0x01080000, /* r420 */
  991. 0x01080000, /* r423 */
  992. 0x01080000, /* rv410 */
  993. 0x00780000, /* rs400 */
  994. 0x00780000, /* rs480 */
  995. };
  996. static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
  997. struct radeon_encoder_tv_dac *tv_dac)
  998. {
  999. tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
  1000. if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
  1001. tv_dac->ps2_tvdac_adj = 0x00880000;
  1002. tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
  1003. tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
  1004. return;
  1005. }
  1006. struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
  1007. radeon_encoder
  1008. *encoder)
  1009. {
  1010. struct drm_device *dev = encoder->base.dev;
  1011. struct radeon_device *rdev = dev->dev_private;
  1012. uint16_t dac_info;
  1013. uint8_t rev, bg, dac;
  1014. struct radeon_encoder_tv_dac *tv_dac = NULL;
  1015. int found = 0;
  1016. tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
  1017. if (!tv_dac)
  1018. return NULL;
  1019. /* first check TV table */
  1020. dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
  1021. if (dac_info) {
  1022. rev = RBIOS8(dac_info + 0x3);
  1023. if (rev > 4) {
  1024. bg = RBIOS8(dac_info + 0xc) & 0xf;
  1025. dac = RBIOS8(dac_info + 0xd) & 0xf;
  1026. tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
  1027. bg = RBIOS8(dac_info + 0xe) & 0xf;
  1028. dac = RBIOS8(dac_info + 0xf) & 0xf;
  1029. tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
  1030. bg = RBIOS8(dac_info + 0x10) & 0xf;
  1031. dac = RBIOS8(dac_info + 0x11) & 0xf;
  1032. tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
  1033. /* if the values are all zeros, use the table */
  1034. if (tv_dac->ps2_tvdac_adj)
  1035. found = 1;
  1036. } else if (rev > 1) {
  1037. bg = RBIOS8(dac_info + 0xc) & 0xf;
  1038. dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
  1039. tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
  1040. bg = RBIOS8(dac_info + 0xd) & 0xf;
  1041. dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
  1042. tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
  1043. bg = RBIOS8(dac_info + 0xe) & 0xf;
  1044. dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
  1045. tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
  1046. /* if the values are all zeros, use the table */
  1047. if (tv_dac->ps2_tvdac_adj)
  1048. found = 1;
  1049. }
  1050. tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
  1051. }
  1052. if (!found) {
  1053. /* then check CRT table */
  1054. dac_info =
  1055. combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
  1056. if (dac_info) {
  1057. rev = RBIOS8(dac_info) & 0x3;
  1058. if (rev < 2) {
  1059. bg = RBIOS8(dac_info + 0x3) & 0xf;
  1060. dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf;
  1061. tv_dac->ps2_tvdac_adj =
  1062. (bg << 16) | (dac << 20);
  1063. tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
  1064. tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
  1065. /* if the values are all zeros, use the table */
  1066. if (tv_dac->ps2_tvdac_adj)
  1067. found = 1;
  1068. } else {
  1069. bg = RBIOS8(dac_info + 0x4) & 0xf;
  1070. dac = RBIOS8(dac_info + 0x5) & 0xf;
  1071. tv_dac->ps2_tvdac_adj =
  1072. (bg << 16) | (dac << 20);
  1073. tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
  1074. tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
  1075. /* if the values are all zeros, use the table */
  1076. if (tv_dac->ps2_tvdac_adj)
  1077. found = 1;
  1078. }
  1079. } else {
  1080. DRM_INFO("No TV DAC info found in BIOS\n");
  1081. }
  1082. }
  1083. if (!found) /* fallback to defaults */
  1084. radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
  1085. return tv_dac;
  1086. }
  1087. static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
  1088. radeon_device
  1089. *rdev)
  1090. {
  1091. struct radeon_encoder_lvds *lvds = NULL;
  1092. uint32_t fp_vert_stretch, fp_horz_stretch;
  1093. uint32_t ppll_div_sel, ppll_val;
  1094. uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
  1095. lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
  1096. if (!lvds)
  1097. return NULL;
  1098. fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
  1099. fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
  1100. /* These should be fail-safe defaults, fingers crossed */
  1101. lvds->panel_pwr_delay = 200;
  1102. lvds->panel_vcc_delay = 2000;
  1103. lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
  1104. lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
  1105. lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
  1106. if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
  1107. lvds->native_mode.vdisplay =
  1108. ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
  1109. RADEON_VERT_PANEL_SHIFT) + 1;
  1110. else
  1111. lvds->native_mode.vdisplay =
  1112. (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
  1113. if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
  1114. lvds->native_mode.hdisplay =
  1115. (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
  1116. RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
  1117. else
  1118. lvds->native_mode.hdisplay =
  1119. ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
  1120. if ((lvds->native_mode.hdisplay < 640) ||
  1121. (lvds->native_mode.vdisplay < 480)) {
  1122. lvds->native_mode.hdisplay = 640;
  1123. lvds->native_mode.vdisplay = 480;
  1124. }
  1125. ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
  1126. ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
  1127. if ((ppll_val & 0x000707ff) == 0x1bb)
  1128. lvds->use_bios_dividers = false;
  1129. else {
  1130. lvds->panel_ref_divider =
  1131. RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
  1132. lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
  1133. lvds->panel_fb_divider = ppll_val & 0x7ff;
  1134. if ((lvds->panel_ref_divider != 0) &&
  1135. (lvds->panel_fb_divider > 3))
  1136. lvds->use_bios_dividers = true;
  1137. }
  1138. lvds->panel_vcc_delay = 200;
  1139. DRM_INFO("Panel info derived from registers\n");
  1140. DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
  1141. lvds->native_mode.vdisplay);
  1142. return lvds;
  1143. }
  1144. struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
  1145. *encoder)
  1146. {
  1147. struct drm_device *dev = encoder->base.dev;
  1148. struct radeon_device *rdev = dev->dev_private;
  1149. uint16_t lcd_info;
  1150. uint32_t panel_setup;
  1151. char stmp[30];
  1152. int tmp, i;
  1153. struct radeon_encoder_lvds *lvds = NULL;
  1154. lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
  1155. if (lcd_info) {
  1156. lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
  1157. if (!lvds)
  1158. return NULL;
  1159. for (i = 0; i < 24; i++)
  1160. stmp[i] = RBIOS8(lcd_info + i + 1);
  1161. stmp[24] = 0;
  1162. DRM_INFO("Panel ID String: %s\n", stmp);
  1163. lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
  1164. lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
  1165. DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
  1166. lvds->native_mode.vdisplay);
  1167. lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
  1168. lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000);
  1169. lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
  1170. lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
  1171. lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
  1172. lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
  1173. lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
  1174. lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
  1175. if ((lvds->panel_ref_divider != 0) &&
  1176. (lvds->panel_fb_divider > 3))
  1177. lvds->use_bios_dividers = true;
  1178. panel_setup = RBIOS32(lcd_info + 0x39);
  1179. lvds->lvds_gen_cntl = 0xff00;
  1180. if (panel_setup & 0x1)
  1181. lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
  1182. if ((panel_setup >> 4) & 0x1)
  1183. lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
  1184. switch ((panel_setup >> 8) & 0x7) {
  1185. case 0:
  1186. lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
  1187. break;
  1188. case 1:
  1189. lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
  1190. break;
  1191. case 2:
  1192. lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
  1193. break;
  1194. default:
  1195. break;
  1196. }
  1197. if ((panel_setup >> 16) & 0x1)
  1198. lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
  1199. if ((panel_setup >> 17) & 0x1)
  1200. lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
  1201. if ((panel_setup >> 18) & 0x1)
  1202. lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
  1203. if ((panel_setup >> 23) & 0x1)
  1204. lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
  1205. lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
  1206. for (i = 0; i < 32; i++) {
  1207. tmp = RBIOS16(lcd_info + 64 + i * 2);
  1208. if (tmp == 0)
  1209. break;
  1210. if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
  1211. (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) {
  1212. lvds->native_mode.htotal = lvds->native_mode.hdisplay +
  1213. (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8;
  1214. lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
  1215. (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8;
  1216. lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
  1217. (RBIOS8(tmp + 23) * 8);
  1218. lvds->native_mode.vtotal = lvds->native_mode.vdisplay +
  1219. (RBIOS16(tmp + 24) - RBIOS16(tmp + 26));
  1220. lvds->native_mode.vsync_start = lvds->native_mode.vdisplay +
  1221. ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26));
  1222. lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
  1223. ((RBIOS16(tmp + 28) & 0xf800) >> 11);
  1224. lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
  1225. lvds->native_mode.flags = 0;
  1226. /* set crtc values */
  1227. drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
  1228. }
  1229. }
  1230. } else {
  1231. DRM_INFO("No panel info found in BIOS\n");
  1232. lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
  1233. }
  1234. if (lvds)
  1235. encoder->native_mode = lvds->native_mode;
  1236. return lvds;
  1237. }
  1238. static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
  1239. {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
  1240. {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
  1241. {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
  1242. {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
  1243. {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
  1244. {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
  1245. {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
  1246. {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
  1247. {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
  1248. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
  1249. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
  1250. {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
  1251. {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
  1252. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
  1253. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
  1254. {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
  1255. { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
  1256. { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
  1257. };
  1258. bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
  1259. struct radeon_encoder_int_tmds *tmds)
  1260. {
  1261. struct drm_device *dev = encoder->base.dev;
  1262. struct radeon_device *rdev = dev->dev_private;
  1263. int i;
  1264. for (i = 0; i < 4; i++) {
  1265. tmds->tmds_pll[i].value =
  1266. default_tmds_pll[rdev->family][i].value;
  1267. tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
  1268. }
  1269. return true;
  1270. }
  1271. bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
  1272. struct radeon_encoder_int_tmds *tmds)
  1273. {
  1274. struct drm_device *dev = encoder->base.dev;
  1275. struct radeon_device *rdev = dev->dev_private;
  1276. uint16_t tmds_info;
  1277. int i, n;
  1278. uint8_t ver;
  1279. tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
  1280. if (tmds_info) {
  1281. ver = RBIOS8(tmds_info);
  1282. DRM_DEBUG_KMS("DFP table revision: %d\n", ver);
  1283. if (ver == 3) {
  1284. n = RBIOS8(tmds_info + 5) + 1;
  1285. if (n > 4)
  1286. n = 4;
  1287. for (i = 0; i < n; i++) {
  1288. tmds->tmds_pll[i].value =
  1289. RBIOS32(tmds_info + i * 10 + 0x08);
  1290. tmds->tmds_pll[i].freq =
  1291. RBIOS16(tmds_info + i * 10 + 0x10);
  1292. DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n",
  1293. tmds->tmds_pll[i].freq,
  1294. tmds->tmds_pll[i].value);
  1295. }
  1296. } else if (ver == 4) {
  1297. int stride = 0;
  1298. n = RBIOS8(tmds_info + 5) + 1;
  1299. if (n > 4)
  1300. n = 4;
  1301. for (i = 0; i < n; i++) {
  1302. tmds->tmds_pll[i].value =
  1303. RBIOS32(tmds_info + stride + 0x08);
  1304. tmds->tmds_pll[i].freq =
  1305. RBIOS16(tmds_info + stride + 0x10);
  1306. if (i == 0)
  1307. stride += 10;
  1308. else
  1309. stride += 6;
  1310. DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n",
  1311. tmds->tmds_pll[i].freq,
  1312. tmds->tmds_pll[i].value);
  1313. }
  1314. }
  1315. } else {
  1316. DRM_INFO("No TMDS info found in BIOS\n");
  1317. return false;
  1318. }
  1319. return true;
  1320. }
  1321. bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
  1322. struct radeon_encoder_ext_tmds *tmds)
  1323. {
  1324. struct drm_device *dev = encoder->base.dev;
  1325. struct radeon_device *rdev = dev->dev_private;
  1326. struct radeon_i2c_bus_rec i2c_bus;
  1327. /* default for macs */
  1328. i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0);
  1329. tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
  1330. /* XXX some macs have duallink chips */
  1331. switch (rdev->mode_info.connector_table) {
  1332. case CT_POWERBOOK_EXTERNAL:
  1333. case CT_MINI_EXTERNAL:
  1334. default:
  1335. tmds->dvo_chip = DVO_SIL164;
  1336. tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
  1337. break;
  1338. }
  1339. return true;
  1340. }
  1341. bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
  1342. struct radeon_encoder_ext_tmds *tmds)
  1343. {
  1344. struct drm_device *dev = encoder->base.dev;
  1345. struct radeon_device *rdev = dev->dev_private;
  1346. uint16_t offset;
  1347. uint8_t ver;
  1348. enum radeon_combios_ddc gpio;
  1349. struct radeon_i2c_bus_rec i2c_bus;
  1350. tmds->i2c_bus = NULL;
  1351. if (rdev->flags & RADEON_IS_IGP) {
  1352. i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0);
  1353. tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
  1354. tmds->dvo_chip = DVO_SIL164;
  1355. tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
  1356. } else {
  1357. offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
  1358. if (offset) {
  1359. ver = RBIOS8(offset);
  1360. DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver);
  1361. tmds->slave_addr = RBIOS8(offset + 4 + 2);
  1362. tmds->slave_addr >>= 1; /* 7 bit addressing */
  1363. gpio = RBIOS8(offset + 4 + 3);
  1364. if (gpio == DDC_LCD) {
  1365. /* MM i2c */
  1366. i2c_bus.valid = true;
  1367. i2c_bus.hw_capable = true;
  1368. i2c_bus.mm_i2c = true;
  1369. i2c_bus.i2c_id = 0xa0;
  1370. } else
  1371. i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0);
  1372. tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
  1373. }
  1374. }
  1375. if (!tmds->i2c_bus) {
  1376. DRM_INFO("No valid Ext TMDS info found in BIOS\n");
  1377. return false;
  1378. }
  1379. return true;
  1380. }
  1381. bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
  1382. {
  1383. struct radeon_device *rdev = dev->dev_private;
  1384. struct radeon_i2c_bus_rec ddc_i2c;
  1385. struct radeon_hpd hpd;
  1386. rdev->mode_info.connector_table = radeon_connector_table;
  1387. if (rdev->mode_info.connector_table == CT_NONE) {
  1388. #ifdef CONFIG_PPC_PMAC
  1389. if (of_machine_is_compatible("PowerBook3,3")) {
  1390. /* powerbook with VGA */
  1391. rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
  1392. } else if (of_machine_is_compatible("PowerBook3,4") ||
  1393. of_machine_is_compatible("PowerBook3,5")) {
  1394. /* powerbook with internal tmds */
  1395. rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
  1396. } else if (of_machine_is_compatible("PowerBook5,1") ||
  1397. of_machine_is_compatible("PowerBook5,2") ||
  1398. of_machine_is_compatible("PowerBook5,3") ||
  1399. of_machine_is_compatible("PowerBook5,4") ||
  1400. of_machine_is_compatible("PowerBook5,5")) {
  1401. /* powerbook with external single link tmds (sil164) */
  1402. rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
  1403. } else if (of_machine_is_compatible("PowerBook5,6")) {
  1404. /* powerbook with external dual or single link tmds */
  1405. rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
  1406. } else if (of_machine_is_compatible("PowerBook5,7") ||
  1407. of_machine_is_compatible("PowerBook5,8") ||
  1408. of_machine_is_compatible("PowerBook5,9")) {
  1409. /* PowerBook6,2 ? */
  1410. /* powerbook with external dual link tmds (sil1178?) */
  1411. rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
  1412. } else if (of_machine_is_compatible("PowerBook4,1") ||
  1413. of_machine_is_compatible("PowerBook4,2") ||
  1414. of_machine_is_compatible("PowerBook4,3") ||
  1415. of_machine_is_compatible("PowerBook6,3") ||
  1416. of_machine_is_compatible("PowerBook6,5") ||
  1417. of_machine_is_compatible("PowerBook6,7")) {
  1418. /* ibook */
  1419. rdev->mode_info.connector_table = CT_IBOOK;
  1420. } else if (of_machine_is_compatible("PowerMac3,5")) {
  1421. /* PowerMac G4 Silver radeon 7500 */
  1422. rdev->mode_info.connector_table = CT_MAC_G4_SILVER;
  1423. } else if (of_machine_is_compatible("PowerMac4,4")) {
  1424. /* emac */
  1425. rdev->mode_info.connector_table = CT_EMAC;
  1426. } else if (of_machine_is_compatible("PowerMac10,1")) {
  1427. /* mini with internal tmds */
  1428. rdev->mode_info.connector_table = CT_MINI_INTERNAL;
  1429. } else if (of_machine_is_compatible("PowerMac10,2")) {
  1430. /* mini with external tmds */
  1431. rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
  1432. } else if (of_machine_is_compatible("PowerMac12,1")) {
  1433. /* PowerMac8,1 ? */
  1434. /* imac g5 isight */
  1435. rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
  1436. } else if ((rdev->pdev->device == 0x4a48) &&
  1437. (rdev->pdev->subsystem_vendor == 0x1002) &&
  1438. (rdev->pdev->subsystem_device == 0x4a48)) {
  1439. /* Mac X800 */
  1440. rdev->mode_info.connector_table = CT_MAC_X800;
  1441. } else if ((of_machine_is_compatible("PowerMac7,2") ||
  1442. of_machine_is_compatible("PowerMac7,3")) &&
  1443. (rdev->pdev->device == 0x4150) &&
  1444. (rdev->pdev->subsystem_vendor == 0x1002) &&
  1445. (rdev->pdev->subsystem_device == 0x4150)) {
  1446. /* Mac G5 tower 9600 */
  1447. rdev->mode_info.connector_table = CT_MAC_G5_9600;
  1448. } else if ((rdev->pdev->device == 0x4c66) &&
  1449. (rdev->pdev->subsystem_vendor == 0x1002) &&
  1450. (rdev->pdev->subsystem_device == 0x4c66)) {
  1451. /* SAM440ep RV250 embedded board */
  1452. rdev->mode_info.connector_table = CT_SAM440EP;
  1453. } else
  1454. #endif /* CONFIG_PPC_PMAC */
  1455. #ifdef CONFIG_PPC64
  1456. if (ASIC_IS_RN50(rdev))
  1457. rdev->mode_info.connector_table = CT_RN50_POWER;
  1458. else
  1459. #endif
  1460. rdev->mode_info.connector_table = CT_GENERIC;
  1461. }
  1462. switch (rdev->mode_info.connector_table) {
  1463. case CT_GENERIC:
  1464. DRM_INFO("Connector Table: %d (generic)\n",
  1465. rdev->mode_info.connector_table);
  1466. /* these are the most common settings */
  1467. if (rdev->flags & RADEON_SINGLE_CRTC) {
  1468. /* VGA - primary dac */
  1469. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1470. hpd.hpd = RADEON_HPD_NONE;
  1471. radeon_add_legacy_encoder(dev,
  1472. radeon_get_encoder_enum(dev,
  1473. ATOM_DEVICE_CRT1_SUPPORT,
  1474. 1),
  1475. ATOM_DEVICE_CRT1_SUPPORT);
  1476. radeon_add_legacy_connector(dev, 0,
  1477. ATOM_DEVICE_CRT1_SUPPORT,
  1478. DRM_MODE_CONNECTOR_VGA,
  1479. &ddc_i2c,
  1480. CONNECTOR_OBJECT_ID_VGA,
  1481. &hpd);
  1482. } else if (rdev->flags & RADEON_IS_MOBILITY) {
  1483. /* LVDS */
  1484. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0);
  1485. hpd.hpd = RADEON_HPD_NONE;
  1486. radeon_add_legacy_encoder(dev,
  1487. radeon_get_encoder_enum(dev,
  1488. ATOM_DEVICE_LCD1_SUPPORT,
  1489. 0),
  1490. ATOM_DEVICE_LCD1_SUPPORT);
  1491. radeon_add_legacy_connector(dev, 0,
  1492. ATOM_DEVICE_LCD1_SUPPORT,
  1493. DRM_MODE_CONNECTOR_LVDS,
  1494. &ddc_i2c,
  1495. CONNECTOR_OBJECT_ID_LVDS,
  1496. &hpd);
  1497. /* VGA - primary dac */
  1498. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1499. hpd.hpd = RADEON_HPD_NONE;
  1500. radeon_add_legacy_encoder(dev,
  1501. radeon_get_encoder_enum(dev,
  1502. ATOM_DEVICE_CRT1_SUPPORT,
  1503. 1),
  1504. ATOM_DEVICE_CRT1_SUPPORT);
  1505. radeon_add_legacy_connector(dev, 1,
  1506. ATOM_DEVICE_CRT1_SUPPORT,
  1507. DRM_MODE_CONNECTOR_VGA,
  1508. &ddc_i2c,
  1509. CONNECTOR_OBJECT_ID_VGA,
  1510. &hpd);
  1511. } else {
  1512. /* DVI-I - tv dac, int tmds */
  1513. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1514. hpd.hpd = RADEON_HPD_1;
  1515. radeon_add_legacy_encoder(dev,
  1516. radeon_get_encoder_enum(dev,
  1517. ATOM_DEVICE_DFP1_SUPPORT,
  1518. 0),
  1519. ATOM_DEVICE_DFP1_SUPPORT);
  1520. radeon_add_legacy_encoder(dev,
  1521. radeon_get_encoder_enum(dev,
  1522. ATOM_DEVICE_CRT2_SUPPORT,
  1523. 2),
  1524. ATOM_DEVICE_CRT2_SUPPORT);
  1525. radeon_add_legacy_connector(dev, 0,
  1526. ATOM_DEVICE_DFP1_SUPPORT |
  1527. ATOM_DEVICE_CRT2_SUPPORT,
  1528. DRM_MODE_CONNECTOR_DVII,
  1529. &ddc_i2c,
  1530. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1531. &hpd);
  1532. /* VGA - primary dac */
  1533. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1534. hpd.hpd = RADEON_HPD_NONE;
  1535. radeon_add_legacy_encoder(dev,
  1536. radeon_get_encoder_enum(dev,
  1537. ATOM_DEVICE_CRT1_SUPPORT,
  1538. 1),
  1539. ATOM_DEVICE_CRT1_SUPPORT);
  1540. radeon_add_legacy_connector(dev, 1,
  1541. ATOM_DEVICE_CRT1_SUPPORT,
  1542. DRM_MODE_CONNECTOR_VGA,
  1543. &ddc_i2c,
  1544. CONNECTOR_OBJECT_ID_VGA,
  1545. &hpd);
  1546. }
  1547. if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
  1548. /* TV - tv dac */
  1549. ddc_i2c.valid = false;
  1550. hpd.hpd = RADEON_HPD_NONE;
  1551. radeon_add_legacy_encoder(dev,
  1552. radeon_get_encoder_enum(dev,
  1553. ATOM_DEVICE_TV1_SUPPORT,
  1554. 2),
  1555. ATOM_DEVICE_TV1_SUPPORT);
  1556. radeon_add_legacy_connector(dev, 2,
  1557. ATOM_DEVICE_TV1_SUPPORT,
  1558. DRM_MODE_CONNECTOR_SVIDEO,
  1559. &ddc_i2c,
  1560. CONNECTOR_OBJECT_ID_SVIDEO,
  1561. &hpd);
  1562. }
  1563. break;
  1564. case CT_IBOOK:
  1565. DRM_INFO("Connector Table: %d (ibook)\n",
  1566. rdev->mode_info.connector_table);
  1567. /* LVDS */
  1568. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1569. hpd.hpd = RADEON_HPD_NONE;
  1570. radeon_add_legacy_encoder(dev,
  1571. radeon_get_encoder_enum(dev,
  1572. ATOM_DEVICE_LCD1_SUPPORT,
  1573. 0),
  1574. ATOM_DEVICE_LCD1_SUPPORT);
  1575. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1576. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1577. CONNECTOR_OBJECT_ID_LVDS,
  1578. &hpd);
  1579. /* VGA - TV DAC */
  1580. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1581. hpd.hpd = RADEON_HPD_NONE;
  1582. radeon_add_legacy_encoder(dev,
  1583. radeon_get_encoder_enum(dev,
  1584. ATOM_DEVICE_CRT2_SUPPORT,
  1585. 2),
  1586. ATOM_DEVICE_CRT2_SUPPORT);
  1587. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1588. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1589. CONNECTOR_OBJECT_ID_VGA,
  1590. &hpd);
  1591. /* TV - TV DAC */
  1592. ddc_i2c.valid = false;
  1593. hpd.hpd = RADEON_HPD_NONE;
  1594. radeon_add_legacy_encoder(dev,
  1595. radeon_get_encoder_enum(dev,
  1596. ATOM_DEVICE_TV1_SUPPORT,
  1597. 2),
  1598. ATOM_DEVICE_TV1_SUPPORT);
  1599. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1600. DRM_MODE_CONNECTOR_SVIDEO,
  1601. &ddc_i2c,
  1602. CONNECTOR_OBJECT_ID_SVIDEO,
  1603. &hpd);
  1604. break;
  1605. case CT_POWERBOOK_EXTERNAL:
  1606. DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
  1607. rdev->mode_info.connector_table);
  1608. /* LVDS */
  1609. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1610. hpd.hpd = RADEON_HPD_NONE;
  1611. radeon_add_legacy_encoder(dev,
  1612. radeon_get_encoder_enum(dev,
  1613. ATOM_DEVICE_LCD1_SUPPORT,
  1614. 0),
  1615. ATOM_DEVICE_LCD1_SUPPORT);
  1616. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1617. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1618. CONNECTOR_OBJECT_ID_LVDS,
  1619. &hpd);
  1620. /* DVI-I - primary dac, ext tmds */
  1621. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1622. hpd.hpd = RADEON_HPD_2; /* ??? */
  1623. radeon_add_legacy_encoder(dev,
  1624. radeon_get_encoder_enum(dev,
  1625. ATOM_DEVICE_DFP2_SUPPORT,
  1626. 0),
  1627. ATOM_DEVICE_DFP2_SUPPORT);
  1628. radeon_add_legacy_encoder(dev,
  1629. radeon_get_encoder_enum(dev,
  1630. ATOM_DEVICE_CRT1_SUPPORT,
  1631. 1),
  1632. ATOM_DEVICE_CRT1_SUPPORT);
  1633. /* XXX some are SL */
  1634. radeon_add_legacy_connector(dev, 1,
  1635. ATOM_DEVICE_DFP2_SUPPORT |
  1636. ATOM_DEVICE_CRT1_SUPPORT,
  1637. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1638. CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
  1639. &hpd);
  1640. /* TV - TV DAC */
  1641. ddc_i2c.valid = false;
  1642. hpd.hpd = RADEON_HPD_NONE;
  1643. radeon_add_legacy_encoder(dev,
  1644. radeon_get_encoder_enum(dev,
  1645. ATOM_DEVICE_TV1_SUPPORT,
  1646. 2),
  1647. ATOM_DEVICE_TV1_SUPPORT);
  1648. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1649. DRM_MODE_CONNECTOR_SVIDEO,
  1650. &ddc_i2c,
  1651. CONNECTOR_OBJECT_ID_SVIDEO,
  1652. &hpd);
  1653. break;
  1654. case CT_POWERBOOK_INTERNAL:
  1655. DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
  1656. rdev->mode_info.connector_table);
  1657. /* LVDS */
  1658. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1659. hpd.hpd = RADEON_HPD_NONE;
  1660. radeon_add_legacy_encoder(dev,
  1661. radeon_get_encoder_enum(dev,
  1662. ATOM_DEVICE_LCD1_SUPPORT,
  1663. 0),
  1664. ATOM_DEVICE_LCD1_SUPPORT);
  1665. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1666. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1667. CONNECTOR_OBJECT_ID_LVDS,
  1668. &hpd);
  1669. /* DVI-I - primary dac, int tmds */
  1670. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1671. hpd.hpd = RADEON_HPD_1; /* ??? */
  1672. radeon_add_legacy_encoder(dev,
  1673. radeon_get_encoder_enum(dev,
  1674. ATOM_DEVICE_DFP1_SUPPORT,
  1675. 0),
  1676. ATOM_DEVICE_DFP1_SUPPORT);
  1677. radeon_add_legacy_encoder(dev,
  1678. radeon_get_encoder_enum(dev,
  1679. ATOM_DEVICE_CRT1_SUPPORT,
  1680. 1),
  1681. ATOM_DEVICE_CRT1_SUPPORT);
  1682. radeon_add_legacy_connector(dev, 1,
  1683. ATOM_DEVICE_DFP1_SUPPORT |
  1684. ATOM_DEVICE_CRT1_SUPPORT,
  1685. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1686. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1687. &hpd);
  1688. /* TV - TV DAC */
  1689. ddc_i2c.valid = false;
  1690. hpd.hpd = RADEON_HPD_NONE;
  1691. radeon_add_legacy_encoder(dev,
  1692. radeon_get_encoder_enum(dev,
  1693. ATOM_DEVICE_TV1_SUPPORT,
  1694. 2),
  1695. ATOM_DEVICE_TV1_SUPPORT);
  1696. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1697. DRM_MODE_CONNECTOR_SVIDEO,
  1698. &ddc_i2c,
  1699. CONNECTOR_OBJECT_ID_SVIDEO,
  1700. &hpd);
  1701. break;
  1702. case CT_POWERBOOK_VGA:
  1703. DRM_INFO("Connector Table: %d (powerbook vga)\n",
  1704. rdev->mode_info.connector_table);
  1705. /* LVDS */
  1706. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1707. hpd.hpd = RADEON_HPD_NONE;
  1708. radeon_add_legacy_encoder(dev,
  1709. radeon_get_encoder_enum(dev,
  1710. ATOM_DEVICE_LCD1_SUPPORT,
  1711. 0),
  1712. ATOM_DEVICE_LCD1_SUPPORT);
  1713. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  1714. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  1715. CONNECTOR_OBJECT_ID_LVDS,
  1716. &hpd);
  1717. /* VGA - primary dac */
  1718. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1719. hpd.hpd = RADEON_HPD_NONE;
  1720. radeon_add_legacy_encoder(dev,
  1721. radeon_get_encoder_enum(dev,
  1722. ATOM_DEVICE_CRT1_SUPPORT,
  1723. 1),
  1724. ATOM_DEVICE_CRT1_SUPPORT);
  1725. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
  1726. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1727. CONNECTOR_OBJECT_ID_VGA,
  1728. &hpd);
  1729. /* TV - TV DAC */
  1730. ddc_i2c.valid = false;
  1731. hpd.hpd = RADEON_HPD_NONE;
  1732. radeon_add_legacy_encoder(dev,
  1733. radeon_get_encoder_enum(dev,
  1734. ATOM_DEVICE_TV1_SUPPORT,
  1735. 2),
  1736. ATOM_DEVICE_TV1_SUPPORT);
  1737. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1738. DRM_MODE_CONNECTOR_SVIDEO,
  1739. &ddc_i2c,
  1740. CONNECTOR_OBJECT_ID_SVIDEO,
  1741. &hpd);
  1742. break;
  1743. case CT_MINI_EXTERNAL:
  1744. DRM_INFO("Connector Table: %d (mini external tmds)\n",
  1745. rdev->mode_info.connector_table);
  1746. /* DVI-I - tv dac, ext tmds */
  1747. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0);
  1748. hpd.hpd = RADEON_HPD_2; /* ??? */
  1749. radeon_add_legacy_encoder(dev,
  1750. radeon_get_encoder_enum(dev,
  1751. ATOM_DEVICE_DFP2_SUPPORT,
  1752. 0),
  1753. ATOM_DEVICE_DFP2_SUPPORT);
  1754. radeon_add_legacy_encoder(dev,
  1755. radeon_get_encoder_enum(dev,
  1756. ATOM_DEVICE_CRT2_SUPPORT,
  1757. 2),
  1758. ATOM_DEVICE_CRT2_SUPPORT);
  1759. /* XXX are any DL? */
  1760. radeon_add_legacy_connector(dev, 0,
  1761. ATOM_DEVICE_DFP2_SUPPORT |
  1762. ATOM_DEVICE_CRT2_SUPPORT,
  1763. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1764. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1765. &hpd);
  1766. /* TV - TV DAC */
  1767. ddc_i2c.valid = false;
  1768. hpd.hpd = RADEON_HPD_NONE;
  1769. radeon_add_legacy_encoder(dev,
  1770. radeon_get_encoder_enum(dev,
  1771. ATOM_DEVICE_TV1_SUPPORT,
  1772. 2),
  1773. ATOM_DEVICE_TV1_SUPPORT);
  1774. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
  1775. DRM_MODE_CONNECTOR_SVIDEO,
  1776. &ddc_i2c,
  1777. CONNECTOR_OBJECT_ID_SVIDEO,
  1778. &hpd);
  1779. break;
  1780. case CT_MINI_INTERNAL:
  1781. DRM_INFO("Connector Table: %d (mini internal tmds)\n",
  1782. rdev->mode_info.connector_table);
  1783. /* DVI-I - tv dac, int tmds */
  1784. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0);
  1785. hpd.hpd = RADEON_HPD_1; /* ??? */
  1786. radeon_add_legacy_encoder(dev,
  1787. radeon_get_encoder_enum(dev,
  1788. ATOM_DEVICE_DFP1_SUPPORT,
  1789. 0),
  1790. ATOM_DEVICE_DFP1_SUPPORT);
  1791. radeon_add_legacy_encoder(dev,
  1792. radeon_get_encoder_enum(dev,
  1793. ATOM_DEVICE_CRT2_SUPPORT,
  1794. 2),
  1795. ATOM_DEVICE_CRT2_SUPPORT);
  1796. radeon_add_legacy_connector(dev, 0,
  1797. ATOM_DEVICE_DFP1_SUPPORT |
  1798. ATOM_DEVICE_CRT2_SUPPORT,
  1799. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1800. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1801. &hpd);
  1802. /* TV - TV DAC */
  1803. ddc_i2c.valid = false;
  1804. hpd.hpd = RADEON_HPD_NONE;
  1805. radeon_add_legacy_encoder(dev,
  1806. radeon_get_encoder_enum(dev,
  1807. ATOM_DEVICE_TV1_SUPPORT,
  1808. 2),
  1809. ATOM_DEVICE_TV1_SUPPORT);
  1810. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
  1811. DRM_MODE_CONNECTOR_SVIDEO,
  1812. &ddc_i2c,
  1813. CONNECTOR_OBJECT_ID_SVIDEO,
  1814. &hpd);
  1815. break;
  1816. case CT_IMAC_G5_ISIGHT:
  1817. DRM_INFO("Connector Table: %d (imac g5 isight)\n",
  1818. rdev->mode_info.connector_table);
  1819. /* DVI-D - int tmds */
  1820. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0);
  1821. hpd.hpd = RADEON_HPD_1; /* ??? */
  1822. radeon_add_legacy_encoder(dev,
  1823. radeon_get_encoder_enum(dev,
  1824. ATOM_DEVICE_DFP1_SUPPORT,
  1825. 0),
  1826. ATOM_DEVICE_DFP1_SUPPORT);
  1827. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
  1828. DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
  1829. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
  1830. &hpd);
  1831. /* VGA - tv dac */
  1832. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1833. hpd.hpd = RADEON_HPD_NONE;
  1834. radeon_add_legacy_encoder(dev,
  1835. radeon_get_encoder_enum(dev,
  1836. ATOM_DEVICE_CRT2_SUPPORT,
  1837. 2),
  1838. ATOM_DEVICE_CRT2_SUPPORT);
  1839. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1840. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1841. CONNECTOR_OBJECT_ID_VGA,
  1842. &hpd);
  1843. /* TV - TV DAC */
  1844. ddc_i2c.valid = false;
  1845. hpd.hpd = RADEON_HPD_NONE;
  1846. radeon_add_legacy_encoder(dev,
  1847. radeon_get_encoder_enum(dev,
  1848. ATOM_DEVICE_TV1_SUPPORT,
  1849. 2),
  1850. ATOM_DEVICE_TV1_SUPPORT);
  1851. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1852. DRM_MODE_CONNECTOR_SVIDEO,
  1853. &ddc_i2c,
  1854. CONNECTOR_OBJECT_ID_SVIDEO,
  1855. &hpd);
  1856. break;
  1857. case CT_EMAC:
  1858. DRM_INFO("Connector Table: %d (emac)\n",
  1859. rdev->mode_info.connector_table);
  1860. /* VGA - primary dac */
  1861. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1862. hpd.hpd = RADEON_HPD_NONE;
  1863. radeon_add_legacy_encoder(dev,
  1864. radeon_get_encoder_enum(dev,
  1865. ATOM_DEVICE_CRT1_SUPPORT,
  1866. 1),
  1867. ATOM_DEVICE_CRT1_SUPPORT);
  1868. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
  1869. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1870. CONNECTOR_OBJECT_ID_VGA,
  1871. &hpd);
  1872. /* VGA - tv dac */
  1873. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0);
  1874. hpd.hpd = RADEON_HPD_NONE;
  1875. radeon_add_legacy_encoder(dev,
  1876. radeon_get_encoder_enum(dev,
  1877. ATOM_DEVICE_CRT2_SUPPORT,
  1878. 2),
  1879. ATOM_DEVICE_CRT2_SUPPORT);
  1880. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1881. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1882. CONNECTOR_OBJECT_ID_VGA,
  1883. &hpd);
  1884. /* TV - TV DAC */
  1885. ddc_i2c.valid = false;
  1886. hpd.hpd = RADEON_HPD_NONE;
  1887. radeon_add_legacy_encoder(dev,
  1888. radeon_get_encoder_enum(dev,
  1889. ATOM_DEVICE_TV1_SUPPORT,
  1890. 2),
  1891. ATOM_DEVICE_TV1_SUPPORT);
  1892. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  1893. DRM_MODE_CONNECTOR_SVIDEO,
  1894. &ddc_i2c,
  1895. CONNECTOR_OBJECT_ID_SVIDEO,
  1896. &hpd);
  1897. break;
  1898. case CT_RN50_POWER:
  1899. DRM_INFO("Connector Table: %d (rn50-power)\n",
  1900. rdev->mode_info.connector_table);
  1901. /* VGA - primary dac */
  1902. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1903. hpd.hpd = RADEON_HPD_NONE;
  1904. radeon_add_legacy_encoder(dev,
  1905. radeon_get_encoder_enum(dev,
  1906. ATOM_DEVICE_CRT1_SUPPORT,
  1907. 1),
  1908. ATOM_DEVICE_CRT1_SUPPORT);
  1909. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
  1910. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1911. CONNECTOR_OBJECT_ID_VGA,
  1912. &hpd);
  1913. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_CRT2, 0, 0);
  1914. hpd.hpd = RADEON_HPD_NONE;
  1915. radeon_add_legacy_encoder(dev,
  1916. radeon_get_encoder_enum(dev,
  1917. ATOM_DEVICE_CRT2_SUPPORT,
  1918. 2),
  1919. ATOM_DEVICE_CRT2_SUPPORT);
  1920. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
  1921. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  1922. CONNECTOR_OBJECT_ID_VGA,
  1923. &hpd);
  1924. break;
  1925. case CT_MAC_X800:
  1926. DRM_INFO("Connector Table: %d (mac x800)\n",
  1927. rdev->mode_info.connector_table);
  1928. /* DVI - primary dac, internal tmds */
  1929. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1930. hpd.hpd = RADEON_HPD_1; /* ??? */
  1931. radeon_add_legacy_encoder(dev,
  1932. radeon_get_encoder_enum(dev,
  1933. ATOM_DEVICE_DFP1_SUPPORT,
  1934. 0),
  1935. ATOM_DEVICE_DFP1_SUPPORT);
  1936. radeon_add_legacy_encoder(dev,
  1937. radeon_get_encoder_enum(dev,
  1938. ATOM_DEVICE_CRT1_SUPPORT,
  1939. 1),
  1940. ATOM_DEVICE_CRT1_SUPPORT);
  1941. radeon_add_legacy_connector(dev, 0,
  1942. ATOM_DEVICE_DFP1_SUPPORT |
  1943. ATOM_DEVICE_CRT1_SUPPORT,
  1944. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1945. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1946. &hpd);
  1947. /* DVI - tv dac, dvo */
  1948. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0);
  1949. hpd.hpd = RADEON_HPD_2; /* ??? */
  1950. radeon_add_legacy_encoder(dev,
  1951. radeon_get_encoder_enum(dev,
  1952. ATOM_DEVICE_DFP2_SUPPORT,
  1953. 0),
  1954. ATOM_DEVICE_DFP2_SUPPORT);
  1955. radeon_add_legacy_encoder(dev,
  1956. radeon_get_encoder_enum(dev,
  1957. ATOM_DEVICE_CRT2_SUPPORT,
  1958. 2),
  1959. ATOM_DEVICE_CRT2_SUPPORT);
  1960. radeon_add_legacy_connector(dev, 1,
  1961. ATOM_DEVICE_DFP2_SUPPORT |
  1962. ATOM_DEVICE_CRT2_SUPPORT,
  1963. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1964. CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
  1965. &hpd);
  1966. break;
  1967. case CT_MAC_G5_9600:
  1968. DRM_INFO("Connector Table: %d (mac g5 9600)\n",
  1969. rdev->mode_info.connector_table);
  1970. /* DVI - tv dac, dvo */
  1971. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  1972. hpd.hpd = RADEON_HPD_1; /* ??? */
  1973. radeon_add_legacy_encoder(dev,
  1974. radeon_get_encoder_enum(dev,
  1975. ATOM_DEVICE_DFP2_SUPPORT,
  1976. 0),
  1977. ATOM_DEVICE_DFP2_SUPPORT);
  1978. radeon_add_legacy_encoder(dev,
  1979. radeon_get_encoder_enum(dev,
  1980. ATOM_DEVICE_CRT2_SUPPORT,
  1981. 2),
  1982. ATOM_DEVICE_CRT2_SUPPORT);
  1983. radeon_add_legacy_connector(dev, 0,
  1984. ATOM_DEVICE_DFP2_SUPPORT |
  1985. ATOM_DEVICE_CRT2_SUPPORT,
  1986. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  1987. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  1988. &hpd);
  1989. /* ADC - primary dac, internal tmds */
  1990. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  1991. hpd.hpd = RADEON_HPD_2; /* ??? */
  1992. radeon_add_legacy_encoder(dev,
  1993. radeon_get_encoder_enum(dev,
  1994. ATOM_DEVICE_DFP1_SUPPORT,
  1995. 0),
  1996. ATOM_DEVICE_DFP1_SUPPORT);
  1997. radeon_add_legacy_encoder(dev,
  1998. radeon_get_encoder_enum(dev,
  1999. ATOM_DEVICE_CRT1_SUPPORT,
  2000. 1),
  2001. ATOM_DEVICE_CRT1_SUPPORT);
  2002. radeon_add_legacy_connector(dev, 1,
  2003. ATOM_DEVICE_DFP1_SUPPORT |
  2004. ATOM_DEVICE_CRT1_SUPPORT,
  2005. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  2006. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  2007. &hpd);
  2008. /* TV - TV DAC */
  2009. ddc_i2c.valid = false;
  2010. hpd.hpd = RADEON_HPD_NONE;
  2011. radeon_add_legacy_encoder(dev,
  2012. radeon_get_encoder_enum(dev,
  2013. ATOM_DEVICE_TV1_SUPPORT,
  2014. 2),
  2015. ATOM_DEVICE_TV1_SUPPORT);
  2016. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  2017. DRM_MODE_CONNECTOR_SVIDEO,
  2018. &ddc_i2c,
  2019. CONNECTOR_OBJECT_ID_SVIDEO,
  2020. &hpd);
  2021. break;
  2022. case CT_SAM440EP:
  2023. DRM_INFO("Connector Table: %d (SAM440ep embedded board)\n",
  2024. rdev->mode_info.connector_table);
  2025. /* LVDS */
  2026. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_NONE_DETECTED, 0, 0);
  2027. hpd.hpd = RADEON_HPD_NONE;
  2028. radeon_add_legacy_encoder(dev,
  2029. radeon_get_encoder_enum(dev,
  2030. ATOM_DEVICE_LCD1_SUPPORT,
  2031. 0),
  2032. ATOM_DEVICE_LCD1_SUPPORT);
  2033. radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
  2034. DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
  2035. CONNECTOR_OBJECT_ID_LVDS,
  2036. &hpd);
  2037. /* DVI-I - secondary dac, int tmds */
  2038. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  2039. hpd.hpd = RADEON_HPD_1; /* ??? */
  2040. radeon_add_legacy_encoder(dev,
  2041. radeon_get_encoder_enum(dev,
  2042. ATOM_DEVICE_DFP1_SUPPORT,
  2043. 0),
  2044. ATOM_DEVICE_DFP1_SUPPORT);
  2045. radeon_add_legacy_encoder(dev,
  2046. radeon_get_encoder_enum(dev,
  2047. ATOM_DEVICE_CRT2_SUPPORT,
  2048. 2),
  2049. ATOM_DEVICE_CRT2_SUPPORT);
  2050. radeon_add_legacy_connector(dev, 1,
  2051. ATOM_DEVICE_DFP1_SUPPORT |
  2052. ATOM_DEVICE_CRT2_SUPPORT,
  2053. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  2054. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  2055. &hpd);
  2056. /* VGA - primary dac */
  2057. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  2058. hpd.hpd = RADEON_HPD_NONE;
  2059. radeon_add_legacy_encoder(dev,
  2060. radeon_get_encoder_enum(dev,
  2061. ATOM_DEVICE_CRT1_SUPPORT,
  2062. 1),
  2063. ATOM_DEVICE_CRT1_SUPPORT);
  2064. radeon_add_legacy_connector(dev, 2,
  2065. ATOM_DEVICE_CRT1_SUPPORT,
  2066. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  2067. CONNECTOR_OBJECT_ID_VGA,
  2068. &hpd);
  2069. /* TV - TV DAC */
  2070. ddc_i2c.valid = false;
  2071. hpd.hpd = RADEON_HPD_NONE;
  2072. radeon_add_legacy_encoder(dev,
  2073. radeon_get_encoder_enum(dev,
  2074. ATOM_DEVICE_TV1_SUPPORT,
  2075. 2),
  2076. ATOM_DEVICE_TV1_SUPPORT);
  2077. radeon_add_legacy_connector(dev, 3, ATOM_DEVICE_TV1_SUPPORT,
  2078. DRM_MODE_CONNECTOR_SVIDEO,
  2079. &ddc_i2c,
  2080. CONNECTOR_OBJECT_ID_SVIDEO,
  2081. &hpd);
  2082. break;
  2083. case CT_MAC_G4_SILVER:
  2084. DRM_INFO("Connector Table: %d (mac g4 silver)\n",
  2085. rdev->mode_info.connector_table);
  2086. /* DVI-I - tv dac, int tmds */
  2087. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  2088. hpd.hpd = RADEON_HPD_1; /* ??? */
  2089. radeon_add_legacy_encoder(dev,
  2090. radeon_get_encoder_enum(dev,
  2091. ATOM_DEVICE_DFP1_SUPPORT,
  2092. 0),
  2093. ATOM_DEVICE_DFP1_SUPPORT);
  2094. radeon_add_legacy_encoder(dev,
  2095. radeon_get_encoder_enum(dev,
  2096. ATOM_DEVICE_CRT2_SUPPORT,
  2097. 2),
  2098. ATOM_DEVICE_CRT2_SUPPORT);
  2099. radeon_add_legacy_connector(dev, 0,
  2100. ATOM_DEVICE_DFP1_SUPPORT |
  2101. ATOM_DEVICE_CRT2_SUPPORT,
  2102. DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
  2103. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  2104. &hpd);
  2105. /* VGA - primary dac */
  2106. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  2107. hpd.hpd = RADEON_HPD_NONE;
  2108. radeon_add_legacy_encoder(dev,
  2109. radeon_get_encoder_enum(dev,
  2110. ATOM_DEVICE_CRT1_SUPPORT,
  2111. 1),
  2112. ATOM_DEVICE_CRT1_SUPPORT);
  2113. radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
  2114. DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
  2115. CONNECTOR_OBJECT_ID_VGA,
  2116. &hpd);
  2117. /* TV - TV DAC */
  2118. ddc_i2c.valid = false;
  2119. hpd.hpd = RADEON_HPD_NONE;
  2120. radeon_add_legacy_encoder(dev,
  2121. radeon_get_encoder_enum(dev,
  2122. ATOM_DEVICE_TV1_SUPPORT,
  2123. 2),
  2124. ATOM_DEVICE_TV1_SUPPORT);
  2125. radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
  2126. DRM_MODE_CONNECTOR_SVIDEO,
  2127. &ddc_i2c,
  2128. CONNECTOR_OBJECT_ID_SVIDEO,
  2129. &hpd);
  2130. break;
  2131. default:
  2132. DRM_INFO("Connector table: %d (invalid)\n",
  2133. rdev->mode_info.connector_table);
  2134. return false;
  2135. }
  2136. radeon_link_encoder_connector(dev);
  2137. return true;
  2138. }
  2139. static bool radeon_apply_legacy_quirks(struct drm_device *dev,
  2140. int bios_index,
  2141. enum radeon_combios_connector
  2142. *legacy_connector,
  2143. struct radeon_i2c_bus_rec *ddc_i2c,
  2144. struct radeon_hpd *hpd)
  2145. {
  2146. /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
  2147. one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
  2148. if (dev->pdev->device == 0x515e &&
  2149. dev->pdev->subsystem_vendor == 0x1014) {
  2150. if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
  2151. ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
  2152. return false;
  2153. }
  2154. /* X300 card with extra non-existent DVI port */
  2155. if (dev->pdev->device == 0x5B60 &&
  2156. dev->pdev->subsystem_vendor == 0x17af &&
  2157. dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
  2158. if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
  2159. return false;
  2160. }
  2161. return true;
  2162. }
  2163. static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
  2164. {
  2165. /* Acer 5102 has non-existent TV port */
  2166. if (dev->pdev->device == 0x5975 &&
  2167. dev->pdev->subsystem_vendor == 0x1025 &&
  2168. dev->pdev->subsystem_device == 0x009f)
  2169. return false;
  2170. /* HP dc5750 has non-existent TV port */
  2171. if (dev->pdev->device == 0x5974 &&
  2172. dev->pdev->subsystem_vendor == 0x103c &&
  2173. dev->pdev->subsystem_device == 0x280a)
  2174. return false;
  2175. /* MSI S270 has non-existent TV port */
  2176. if (dev->pdev->device == 0x5955 &&
  2177. dev->pdev->subsystem_vendor == 0x1462 &&
  2178. dev->pdev->subsystem_device == 0x0131)
  2179. return false;
  2180. return true;
  2181. }
  2182. static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
  2183. {
  2184. struct radeon_device *rdev = dev->dev_private;
  2185. uint32_t ext_tmds_info;
  2186. if (rdev->flags & RADEON_IS_IGP) {
  2187. if (is_dvi_d)
  2188. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
  2189. else
  2190. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  2191. }
  2192. ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
  2193. if (ext_tmds_info) {
  2194. uint8_t rev = RBIOS8(ext_tmds_info);
  2195. uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
  2196. if (rev >= 3) {
  2197. if (is_dvi_d)
  2198. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
  2199. else
  2200. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
  2201. } else {
  2202. if (flags & 1) {
  2203. if (is_dvi_d)
  2204. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
  2205. else
  2206. return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
  2207. }
  2208. }
  2209. }
  2210. if (is_dvi_d)
  2211. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
  2212. else
  2213. return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  2214. }
  2215. bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
  2216. {
  2217. struct radeon_device *rdev = dev->dev_private;
  2218. uint32_t conn_info, entry, devices;
  2219. uint16_t tmp, connector_object_id;
  2220. enum radeon_combios_ddc ddc_type;
  2221. enum radeon_combios_connector connector;
  2222. int i = 0;
  2223. struct radeon_i2c_bus_rec ddc_i2c;
  2224. struct radeon_hpd hpd;
  2225. conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
  2226. if (conn_info) {
  2227. for (i = 0; i < 4; i++) {
  2228. entry = conn_info + 2 + i * 2;
  2229. if (!RBIOS16(entry))
  2230. break;
  2231. tmp = RBIOS16(entry);
  2232. connector = (tmp >> 12) & 0xf;
  2233. ddc_type = (tmp >> 8) & 0xf;
  2234. if (ddc_type == 5)
  2235. ddc_i2c = radeon_combios_get_i2c_info_from_table(rdev);
  2236. else
  2237. ddc_i2c = combios_setup_i2c_bus(rdev, ddc_type, 0, 0);
  2238. switch (connector) {
  2239. case CONNECTOR_PROPRIETARY_LEGACY:
  2240. case CONNECTOR_DVI_I_LEGACY:
  2241. case CONNECTOR_DVI_D_LEGACY:
  2242. if ((tmp >> 4) & 0x1)
  2243. hpd.hpd = RADEON_HPD_2;
  2244. else
  2245. hpd.hpd = RADEON_HPD_1;
  2246. break;
  2247. default:
  2248. hpd.hpd = RADEON_HPD_NONE;
  2249. break;
  2250. }
  2251. if (!radeon_apply_legacy_quirks(dev, i, &connector,
  2252. &ddc_i2c, &hpd))
  2253. continue;
  2254. switch (connector) {
  2255. case CONNECTOR_PROPRIETARY_LEGACY:
  2256. if ((tmp >> 4) & 0x1)
  2257. devices = ATOM_DEVICE_DFP2_SUPPORT;
  2258. else
  2259. devices = ATOM_DEVICE_DFP1_SUPPORT;
  2260. radeon_add_legacy_encoder(dev,
  2261. radeon_get_encoder_enum
  2262. (dev, devices, 0),
  2263. devices);
  2264. radeon_add_legacy_connector(dev, i, devices,
  2265. legacy_connector_convert
  2266. [connector],
  2267. &ddc_i2c,
  2268. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
  2269. &hpd);
  2270. break;
  2271. case CONNECTOR_CRT_LEGACY:
  2272. if (tmp & 0x1) {
  2273. devices = ATOM_DEVICE_CRT2_SUPPORT;
  2274. radeon_add_legacy_encoder(dev,
  2275. radeon_get_encoder_enum
  2276. (dev,
  2277. ATOM_DEVICE_CRT2_SUPPORT,
  2278. 2),
  2279. ATOM_DEVICE_CRT2_SUPPORT);
  2280. } else {
  2281. devices = ATOM_DEVICE_CRT1_SUPPORT;
  2282. radeon_add_legacy_encoder(dev,
  2283. radeon_get_encoder_enum
  2284. (dev,
  2285. ATOM_DEVICE_CRT1_SUPPORT,
  2286. 1),
  2287. ATOM_DEVICE_CRT1_SUPPORT);
  2288. }
  2289. radeon_add_legacy_connector(dev,
  2290. i,
  2291. devices,
  2292. legacy_connector_convert
  2293. [connector],
  2294. &ddc_i2c,
  2295. CONNECTOR_OBJECT_ID_VGA,
  2296. &hpd);
  2297. break;
  2298. case CONNECTOR_DVI_I_LEGACY:
  2299. devices = 0;
  2300. if (tmp & 0x1) {
  2301. devices |= ATOM_DEVICE_CRT2_SUPPORT;
  2302. radeon_add_legacy_encoder(dev,
  2303. radeon_get_encoder_enum
  2304. (dev,
  2305. ATOM_DEVICE_CRT2_SUPPORT,
  2306. 2),
  2307. ATOM_DEVICE_CRT2_SUPPORT);
  2308. } else {
  2309. devices |= ATOM_DEVICE_CRT1_SUPPORT;
  2310. radeon_add_legacy_encoder(dev,
  2311. radeon_get_encoder_enum
  2312. (dev,
  2313. ATOM_DEVICE_CRT1_SUPPORT,
  2314. 1),
  2315. ATOM_DEVICE_CRT1_SUPPORT);
  2316. }
  2317. /* RV100 board with external TDMS bit mis-set.
  2318. * Actually uses internal TMDS, clear the bit.
  2319. */
  2320. if (dev->pdev->device == 0x5159 &&
  2321. dev->pdev->subsystem_vendor == 0x1014 &&
  2322. dev->pdev->subsystem_device == 0x029A) {
  2323. tmp &= ~(1 << 4);
  2324. }
  2325. if ((tmp >> 4) & 0x1) {
  2326. devices |= ATOM_DEVICE_DFP2_SUPPORT;
  2327. radeon_add_legacy_encoder(dev,
  2328. radeon_get_encoder_enum
  2329. (dev,
  2330. ATOM_DEVICE_DFP2_SUPPORT,
  2331. 0),
  2332. ATOM_DEVICE_DFP2_SUPPORT);
  2333. connector_object_id = combios_check_dl_dvi(dev, 0);
  2334. } else {
  2335. devices |= ATOM_DEVICE_DFP1_SUPPORT;
  2336. radeon_add_legacy_encoder(dev,
  2337. radeon_get_encoder_enum
  2338. (dev,
  2339. ATOM_DEVICE_DFP1_SUPPORT,
  2340. 0),
  2341. ATOM_DEVICE_DFP1_SUPPORT);
  2342. connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  2343. }
  2344. radeon_add_legacy_connector(dev,
  2345. i,
  2346. devices,
  2347. legacy_connector_convert
  2348. [connector],
  2349. &ddc_i2c,
  2350. connector_object_id,
  2351. &hpd);
  2352. break;
  2353. case CONNECTOR_DVI_D_LEGACY:
  2354. if ((tmp >> 4) & 0x1) {
  2355. devices = ATOM_DEVICE_DFP2_SUPPORT;
  2356. connector_object_id = combios_check_dl_dvi(dev, 1);
  2357. } else {
  2358. devices = ATOM_DEVICE_DFP1_SUPPORT;
  2359. connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
  2360. }
  2361. radeon_add_legacy_encoder(dev,
  2362. radeon_get_encoder_enum
  2363. (dev, devices, 0),
  2364. devices);
  2365. radeon_add_legacy_connector(dev, i, devices,
  2366. legacy_connector_convert
  2367. [connector],
  2368. &ddc_i2c,
  2369. connector_object_id,
  2370. &hpd);
  2371. break;
  2372. case CONNECTOR_CTV_LEGACY:
  2373. case CONNECTOR_STV_LEGACY:
  2374. radeon_add_legacy_encoder(dev,
  2375. radeon_get_encoder_enum
  2376. (dev,
  2377. ATOM_DEVICE_TV1_SUPPORT,
  2378. 2),
  2379. ATOM_DEVICE_TV1_SUPPORT);
  2380. radeon_add_legacy_connector(dev, i,
  2381. ATOM_DEVICE_TV1_SUPPORT,
  2382. legacy_connector_convert
  2383. [connector],
  2384. &ddc_i2c,
  2385. CONNECTOR_OBJECT_ID_SVIDEO,
  2386. &hpd);
  2387. break;
  2388. default:
  2389. DRM_ERROR("Unknown connector type: %d\n",
  2390. connector);
  2391. continue;
  2392. }
  2393. }
  2394. } else {
  2395. uint16_t tmds_info =
  2396. combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
  2397. if (tmds_info) {
  2398. DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n");
  2399. radeon_add_legacy_encoder(dev,
  2400. radeon_get_encoder_enum(dev,
  2401. ATOM_DEVICE_CRT1_SUPPORT,
  2402. 1),
  2403. ATOM_DEVICE_CRT1_SUPPORT);
  2404. radeon_add_legacy_encoder(dev,
  2405. radeon_get_encoder_enum(dev,
  2406. ATOM_DEVICE_DFP1_SUPPORT,
  2407. 0),
  2408. ATOM_DEVICE_DFP1_SUPPORT);
  2409. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_DVI, 0, 0);
  2410. hpd.hpd = RADEON_HPD_1;
  2411. radeon_add_legacy_connector(dev,
  2412. 0,
  2413. ATOM_DEVICE_CRT1_SUPPORT |
  2414. ATOM_DEVICE_DFP1_SUPPORT,
  2415. DRM_MODE_CONNECTOR_DVII,
  2416. &ddc_i2c,
  2417. CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
  2418. &hpd);
  2419. } else {
  2420. uint16_t crt_info =
  2421. combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
  2422. DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n");
  2423. if (crt_info) {
  2424. radeon_add_legacy_encoder(dev,
  2425. radeon_get_encoder_enum(dev,
  2426. ATOM_DEVICE_CRT1_SUPPORT,
  2427. 1),
  2428. ATOM_DEVICE_CRT1_SUPPORT);
  2429. ddc_i2c = combios_setup_i2c_bus(rdev, DDC_VGA, 0, 0);
  2430. hpd.hpd = RADEON_HPD_NONE;
  2431. radeon_add_legacy_connector(dev,
  2432. 0,
  2433. ATOM_DEVICE_CRT1_SUPPORT,
  2434. DRM_MODE_CONNECTOR_VGA,
  2435. &ddc_i2c,
  2436. CONNECTOR_OBJECT_ID_VGA,
  2437. &hpd);
  2438. } else {
  2439. DRM_DEBUG_KMS("No connector info found\n");
  2440. return false;
  2441. }
  2442. }
  2443. }
  2444. if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
  2445. uint16_t lcd_info =
  2446. combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
  2447. if (lcd_info) {
  2448. uint16_t lcd_ddc_info =
  2449. combios_get_table_offset(dev,
  2450. COMBIOS_LCD_DDC_INFO_TABLE);
  2451. radeon_add_legacy_encoder(dev,
  2452. radeon_get_encoder_enum(dev,
  2453. ATOM_DEVICE_LCD1_SUPPORT,
  2454. 0),
  2455. ATOM_DEVICE_LCD1_SUPPORT);
  2456. if (lcd_ddc_info) {
  2457. ddc_type = RBIOS8(lcd_ddc_info + 2);
  2458. switch (ddc_type) {
  2459. case DDC_LCD:
  2460. ddc_i2c =
  2461. combios_setup_i2c_bus(rdev,
  2462. DDC_LCD,
  2463. RBIOS32(lcd_ddc_info + 3),
  2464. RBIOS32(lcd_ddc_info + 7));
  2465. radeon_i2c_add(rdev, &ddc_i2c, "LCD");
  2466. break;
  2467. case DDC_GPIO:
  2468. ddc_i2c =
  2469. combios_setup_i2c_bus(rdev,
  2470. DDC_GPIO,
  2471. RBIOS32(lcd_ddc_info + 3),
  2472. RBIOS32(lcd_ddc_info + 7));
  2473. radeon_i2c_add(rdev, &ddc_i2c, "LCD");
  2474. break;
  2475. default:
  2476. ddc_i2c =
  2477. combios_setup_i2c_bus(rdev, ddc_type, 0, 0);
  2478. break;
  2479. }
  2480. DRM_DEBUG_KMS("LCD DDC Info Table found!\n");
  2481. } else
  2482. ddc_i2c.valid = false;
  2483. hpd.hpd = RADEON_HPD_NONE;
  2484. radeon_add_legacy_connector(dev,
  2485. 5,
  2486. ATOM_DEVICE_LCD1_SUPPORT,
  2487. DRM_MODE_CONNECTOR_LVDS,
  2488. &ddc_i2c,
  2489. CONNECTOR_OBJECT_ID_LVDS,
  2490. &hpd);
  2491. }
  2492. }
  2493. /* check TV table */
  2494. if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
  2495. uint32_t tv_info =
  2496. combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
  2497. if (tv_info) {
  2498. if (RBIOS8(tv_info + 6) == 'T') {
  2499. if (radeon_apply_legacy_tv_quirks(dev)) {
  2500. hpd.hpd = RADEON_HPD_NONE;
  2501. ddc_i2c.valid = false;
  2502. radeon_add_legacy_encoder(dev,
  2503. radeon_get_encoder_enum
  2504. (dev,
  2505. ATOM_DEVICE_TV1_SUPPORT,
  2506. 2),
  2507. ATOM_DEVICE_TV1_SUPPORT);
  2508. radeon_add_legacy_connector(dev, 6,
  2509. ATOM_DEVICE_TV1_SUPPORT,
  2510. DRM_MODE_CONNECTOR_SVIDEO,
  2511. &ddc_i2c,
  2512. CONNECTOR_OBJECT_ID_SVIDEO,
  2513. &hpd);
  2514. }
  2515. }
  2516. }
  2517. }
  2518. radeon_link_encoder_connector(dev);
  2519. return true;
  2520. }
  2521. static const char *thermal_controller_names[] = {
  2522. "NONE",
  2523. "lm63",
  2524. "adm1032",
  2525. };
  2526. void radeon_combios_get_power_modes(struct radeon_device *rdev)
  2527. {
  2528. struct drm_device *dev = rdev->ddev;
  2529. u16 offset, misc, misc2 = 0;
  2530. u8 rev, blocks, tmp;
  2531. int state_index = 0;
  2532. struct radeon_i2c_bus_rec i2c_bus;
  2533. rdev->pm.default_power_state_index = -1;
  2534. /* allocate 2 power states */
  2535. rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL);
  2536. if (rdev->pm.power_state) {
  2537. /* allocate 1 clock mode per state */
  2538. rdev->pm.power_state[0].clock_info =
  2539. kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
  2540. rdev->pm.power_state[1].clock_info =
  2541. kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
  2542. if (!rdev->pm.power_state[0].clock_info ||
  2543. !rdev->pm.power_state[1].clock_info)
  2544. goto pm_failed;
  2545. } else
  2546. goto pm_failed;
  2547. /* check for a thermal chip */
  2548. offset = combios_get_table_offset(dev, COMBIOS_OVERDRIVE_INFO_TABLE);
  2549. if (offset) {
  2550. u8 thermal_controller = 0, gpio = 0, i2c_addr = 0, clk_bit = 0, data_bit = 0;
  2551. rev = RBIOS8(offset);
  2552. if (rev == 0) {
  2553. thermal_controller = RBIOS8(offset + 3);
  2554. gpio = RBIOS8(offset + 4) & 0x3f;
  2555. i2c_addr = RBIOS8(offset + 5);
  2556. } else if (rev == 1) {
  2557. thermal_controller = RBIOS8(offset + 4);
  2558. gpio = RBIOS8(offset + 5) & 0x3f;
  2559. i2c_addr = RBIOS8(offset + 6);
  2560. } else if (rev == 2) {
  2561. thermal_controller = RBIOS8(offset + 4);
  2562. gpio = RBIOS8(offset + 5) & 0x3f;
  2563. i2c_addr = RBIOS8(offset + 6);
  2564. clk_bit = RBIOS8(offset + 0xa);
  2565. data_bit = RBIOS8(offset + 0xb);
  2566. }
  2567. if ((thermal_controller > 0) && (thermal_controller < 3)) {
  2568. DRM_INFO("Possible %s thermal controller at 0x%02x\n",
  2569. thermal_controller_names[thermal_controller],
  2570. i2c_addr >> 1);
  2571. if (gpio == DDC_LCD) {
  2572. /* MM i2c */
  2573. i2c_bus.valid = true;
  2574. i2c_bus.hw_capable = true;
  2575. i2c_bus.mm_i2c = true;
  2576. i2c_bus.i2c_id = 0xa0;
  2577. } else if (gpio == DDC_GPIO)
  2578. i2c_bus = combios_setup_i2c_bus(rdev, gpio, 1 << clk_bit, 1 << data_bit);
  2579. else
  2580. i2c_bus = combios_setup_i2c_bus(rdev, gpio, 0, 0);
  2581. rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
  2582. if (rdev->pm.i2c_bus) {
  2583. struct i2c_board_info info = { };
  2584. const char *name = thermal_controller_names[thermal_controller];
  2585. info.addr = i2c_addr >> 1;
  2586. strlcpy(info.type, name, sizeof(info.type));
  2587. i2c_new_device(&rdev->pm.i2c_bus->adapter, &info);
  2588. }
  2589. }
  2590. } else {
  2591. /* boards with a thermal chip, but no overdrive table */
  2592. /* Asus 9600xt has an f75375 on the monid bus */
  2593. if ((dev->pdev->device == 0x4152) &&
  2594. (dev->pdev->subsystem_vendor == 0x1043) &&
  2595. (dev->pdev->subsystem_device == 0xc002)) {
  2596. i2c_bus = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0);
  2597. rdev->pm.i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
  2598. if (rdev->pm.i2c_bus) {
  2599. struct i2c_board_info info = { };
  2600. const char *name = "f75375";
  2601. info.addr = 0x28;
  2602. strlcpy(info.type, name, sizeof(info.type));
  2603. i2c_new_device(&rdev->pm.i2c_bus->adapter, &info);
  2604. DRM_INFO("Possible %s thermal controller at 0x%02x\n",
  2605. name, info.addr);
  2606. }
  2607. }
  2608. }
  2609. if (rdev->flags & RADEON_IS_MOBILITY) {
  2610. offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
  2611. if (offset) {
  2612. rev = RBIOS8(offset);
  2613. blocks = RBIOS8(offset + 0x2);
  2614. /* power mode 0 tends to be the only valid one */
  2615. rdev->pm.power_state[state_index].num_clock_modes = 1;
  2616. rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2);
  2617. rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6);
  2618. if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
  2619. (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
  2620. goto default_mode;
  2621. rdev->pm.power_state[state_index].type =
  2622. POWER_STATE_TYPE_BATTERY;
  2623. misc = RBIOS16(offset + 0x5 + 0x0);
  2624. if (rev > 4)
  2625. misc2 = RBIOS16(offset + 0x5 + 0xe);
  2626. rdev->pm.power_state[state_index].misc = misc;
  2627. rdev->pm.power_state[state_index].misc2 = misc2;
  2628. if (misc & 0x4) {
  2629. rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO;
  2630. if (misc & 0x8)
  2631. rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
  2632. true;
  2633. else
  2634. rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
  2635. false;
  2636. rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true;
  2637. if (rev < 6) {
  2638. rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
  2639. RBIOS16(offset + 0x5 + 0xb) * 4;
  2640. tmp = RBIOS8(offset + 0x5 + 0xd);
  2641. rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
  2642. } else {
  2643. u8 entries = RBIOS8(offset + 0x5 + 0xb);
  2644. u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc);
  2645. if (entries && voltage_table_offset) {
  2646. rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
  2647. RBIOS16(voltage_table_offset) * 4;
  2648. tmp = RBIOS8(voltage_table_offset + 0x2);
  2649. rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
  2650. } else
  2651. rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false;
  2652. }
  2653. switch ((misc2 & 0x700) >> 8) {
  2654. case 0:
  2655. default:
  2656. rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0;
  2657. break;
  2658. case 1:
  2659. rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33;
  2660. break;
  2661. case 2:
  2662. rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66;
  2663. break;
  2664. case 3:
  2665. rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99;
  2666. break;
  2667. case 4:
  2668. rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132;
  2669. break;
  2670. }
  2671. } else
  2672. rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
  2673. if (rev > 6)
  2674. rdev->pm.power_state[state_index].pcie_lanes =
  2675. RBIOS8(offset + 0x5 + 0x10);
  2676. rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY;
  2677. state_index++;
  2678. } else {
  2679. /* XXX figure out some good default low power mode for mobility cards w/out power tables */
  2680. }
  2681. } else {
  2682. /* XXX figure out some good default low power mode for desktop cards */
  2683. }
  2684. default_mode:
  2685. /* add the default mode */
  2686. rdev->pm.power_state[state_index].type =
  2687. POWER_STATE_TYPE_DEFAULT;
  2688. rdev->pm.power_state[state_index].num_clock_modes = 1;
  2689. rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
  2690. rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
  2691. rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
  2692. if ((state_index > 0) &&
  2693. (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO))
  2694. rdev->pm.power_state[state_index].clock_info[0].voltage =
  2695. rdev->pm.power_state[0].clock_info[0].voltage;
  2696. else
  2697. rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
  2698. rdev->pm.power_state[state_index].pcie_lanes = 16;
  2699. rdev->pm.power_state[state_index].flags = 0;
  2700. rdev->pm.default_power_state_index = state_index;
  2701. rdev->pm.num_power_states = state_index + 1;
  2702. rdev->pm.current_power_state_index = rdev->pm.default_power_state_index;
  2703. rdev->pm.current_clock_mode_index = 0;
  2704. return;
  2705. pm_failed:
  2706. rdev->pm.default_power_state_index = state_index;
  2707. rdev->pm.num_power_states = 0;
  2708. rdev->pm.current_power_state_index = rdev->pm.default_power_state_index;
  2709. rdev->pm.current_clock_mode_index = 0;
  2710. }
  2711. void radeon_external_tmds_setup(struct drm_encoder *encoder)
  2712. {
  2713. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2714. struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
  2715. if (!tmds)
  2716. return;
  2717. switch (tmds->dvo_chip) {
  2718. case DVO_SIL164:
  2719. /* sil 164 */
  2720. radeon_i2c_put_byte(tmds->i2c_bus,
  2721. tmds->slave_addr,
  2722. 0x08, 0x30);
  2723. radeon_i2c_put_byte(tmds->i2c_bus,
  2724. tmds->slave_addr,
  2725. 0x09, 0x00);
  2726. radeon_i2c_put_byte(tmds->i2c_bus,
  2727. tmds->slave_addr,
  2728. 0x0a, 0x90);
  2729. radeon_i2c_put_byte(tmds->i2c_bus,
  2730. tmds->slave_addr,
  2731. 0x0c, 0x89);
  2732. radeon_i2c_put_byte(tmds->i2c_bus,
  2733. tmds->slave_addr,
  2734. 0x08, 0x3b);
  2735. break;
  2736. case DVO_SIL1178:
  2737. /* sil 1178 - untested */
  2738. /*
  2739. * 0x0f, 0x44
  2740. * 0x0f, 0x4c
  2741. * 0x0e, 0x01
  2742. * 0x0a, 0x80
  2743. * 0x09, 0x30
  2744. * 0x0c, 0xc9
  2745. * 0x0d, 0x70
  2746. * 0x08, 0x32
  2747. * 0x08, 0x33
  2748. */
  2749. break;
  2750. default:
  2751. break;
  2752. }
  2753. }
  2754. bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
  2755. {
  2756. struct drm_device *dev = encoder->dev;
  2757. struct radeon_device *rdev = dev->dev_private;
  2758. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  2759. uint16_t offset;
  2760. uint8_t blocks, slave_addr, rev;
  2761. uint32_t index, id;
  2762. uint32_t reg, val, and_mask, or_mask;
  2763. struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
  2764. if (!tmds)
  2765. return false;
  2766. if (rdev->flags & RADEON_IS_IGP) {
  2767. offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
  2768. rev = RBIOS8(offset);
  2769. if (offset) {
  2770. rev = RBIOS8(offset);
  2771. if (rev > 1) {
  2772. blocks = RBIOS8(offset + 3);
  2773. index = offset + 4;
  2774. while (blocks > 0) {
  2775. id = RBIOS16(index);
  2776. index += 2;
  2777. switch (id >> 13) {
  2778. case 0:
  2779. reg = (id & 0x1fff) * 4;
  2780. val = RBIOS32(index);
  2781. index += 4;
  2782. WREG32(reg, val);
  2783. break;
  2784. case 2:
  2785. reg = (id & 0x1fff) * 4;
  2786. and_mask = RBIOS32(index);
  2787. index += 4;
  2788. or_mask = RBIOS32(index);
  2789. index += 4;
  2790. val = RREG32(reg);
  2791. val = (val & and_mask) | or_mask;
  2792. WREG32(reg, val);
  2793. break;
  2794. case 3:
  2795. val = RBIOS16(index);
  2796. index += 2;
  2797. udelay(val);
  2798. break;
  2799. case 4:
  2800. val = RBIOS16(index);
  2801. index += 2;
  2802. mdelay(val);
  2803. break;
  2804. case 6:
  2805. slave_addr = id & 0xff;
  2806. slave_addr >>= 1; /* 7 bit addressing */
  2807. index++;
  2808. reg = RBIOS8(index);
  2809. index++;
  2810. val = RBIOS8(index);
  2811. index++;
  2812. radeon_i2c_put_byte(tmds->i2c_bus,
  2813. slave_addr,
  2814. reg, val);
  2815. break;
  2816. default:
  2817. DRM_ERROR("Unknown id %d\n", id >> 13);
  2818. break;
  2819. }
  2820. blocks--;
  2821. }
  2822. return true;
  2823. }
  2824. }
  2825. } else {
  2826. offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
  2827. if (offset) {
  2828. index = offset + 10;
  2829. id = RBIOS16(index);
  2830. while (id != 0xffff) {
  2831. index += 2;
  2832. switch (id >> 13) {
  2833. case 0:
  2834. reg = (id & 0x1fff) * 4;
  2835. val = RBIOS32(index);
  2836. WREG32(reg, val);
  2837. break;
  2838. case 2:
  2839. reg = (id & 0x1fff) * 4;
  2840. and_mask = RBIOS32(index);
  2841. index += 4;
  2842. or_mask = RBIOS32(index);
  2843. index += 4;
  2844. val = RREG32(reg);
  2845. val = (val & and_mask) | or_mask;
  2846. WREG32(reg, val);
  2847. break;
  2848. case 4:
  2849. val = RBIOS16(index);
  2850. index += 2;
  2851. udelay(val);
  2852. break;
  2853. case 5:
  2854. reg = id & 0x1fff;
  2855. and_mask = RBIOS32(index);
  2856. index += 4;
  2857. or_mask = RBIOS32(index);
  2858. index += 4;
  2859. val = RREG32_PLL(reg);
  2860. val = (val & and_mask) | or_mask;
  2861. WREG32_PLL(reg, val);
  2862. break;
  2863. case 6:
  2864. reg = id & 0x1fff;
  2865. val = RBIOS8(index);
  2866. index += 1;
  2867. radeon_i2c_put_byte(tmds->i2c_bus,
  2868. tmds->slave_addr,
  2869. reg, val);
  2870. break;
  2871. default:
  2872. DRM_ERROR("Unknown id %d\n", id >> 13);
  2873. break;
  2874. }
  2875. id = RBIOS16(index);
  2876. }
  2877. return true;
  2878. }
  2879. }
  2880. return false;
  2881. }
  2882. static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
  2883. {
  2884. struct radeon_device *rdev = dev->dev_private;
  2885. if (offset) {
  2886. while (RBIOS16(offset)) {
  2887. uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
  2888. uint32_t addr = (RBIOS16(offset) & 0x1fff);
  2889. uint32_t val, and_mask, or_mask;
  2890. uint32_t tmp;
  2891. offset += 2;
  2892. switch (cmd) {
  2893. case 0:
  2894. val = RBIOS32(offset);
  2895. offset += 4;
  2896. WREG32(addr, val);
  2897. break;
  2898. case 1:
  2899. val = RBIOS32(offset);
  2900. offset += 4;
  2901. WREG32(addr, val);
  2902. break;
  2903. case 2:
  2904. and_mask = RBIOS32(offset);
  2905. offset += 4;
  2906. or_mask = RBIOS32(offset);
  2907. offset += 4;
  2908. tmp = RREG32(addr);
  2909. tmp &= and_mask;
  2910. tmp |= or_mask;
  2911. WREG32(addr, tmp);
  2912. break;
  2913. case 3:
  2914. and_mask = RBIOS32(offset);
  2915. offset += 4;
  2916. or_mask = RBIOS32(offset);
  2917. offset += 4;
  2918. tmp = RREG32(addr);
  2919. tmp &= and_mask;
  2920. tmp |= or_mask;
  2921. WREG32(addr, tmp);
  2922. break;
  2923. case 4:
  2924. val = RBIOS16(offset);
  2925. offset += 2;
  2926. udelay(val);
  2927. break;
  2928. case 5:
  2929. val = RBIOS16(offset);
  2930. offset += 2;
  2931. switch (addr) {
  2932. case 8:
  2933. while (val--) {
  2934. if (!
  2935. (RREG32_PLL
  2936. (RADEON_CLK_PWRMGT_CNTL) &
  2937. RADEON_MC_BUSY))
  2938. break;
  2939. }
  2940. break;
  2941. case 9:
  2942. while (val--) {
  2943. if ((RREG32(RADEON_MC_STATUS) &
  2944. RADEON_MC_IDLE))
  2945. break;
  2946. }
  2947. break;
  2948. default:
  2949. break;
  2950. }
  2951. break;
  2952. default:
  2953. break;
  2954. }
  2955. }
  2956. }
  2957. }
  2958. static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
  2959. {
  2960. struct radeon_device *rdev = dev->dev_private;
  2961. if (offset) {
  2962. while (RBIOS8(offset)) {
  2963. uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
  2964. uint8_t addr = (RBIOS8(offset) & 0x3f);
  2965. uint32_t val, shift, tmp;
  2966. uint32_t and_mask, or_mask;
  2967. offset++;
  2968. switch (cmd) {
  2969. case 0:
  2970. val = RBIOS32(offset);
  2971. offset += 4;
  2972. WREG32_PLL(addr, val);
  2973. break;
  2974. case 1:
  2975. shift = RBIOS8(offset) * 8;
  2976. offset++;
  2977. and_mask = RBIOS8(offset) << shift;
  2978. and_mask |= ~(0xff << shift);
  2979. offset++;
  2980. or_mask = RBIOS8(offset) << shift;
  2981. offset++;
  2982. tmp = RREG32_PLL(addr);
  2983. tmp &= and_mask;
  2984. tmp |= or_mask;
  2985. WREG32_PLL(addr, tmp);
  2986. break;
  2987. case 2:
  2988. case 3:
  2989. tmp = 1000;
  2990. switch (addr) {
  2991. case 1:
  2992. udelay(150);
  2993. break;
  2994. case 2:
  2995. mdelay(1);
  2996. break;
  2997. case 3:
  2998. while (tmp--) {
  2999. if (!
  3000. (RREG32_PLL
  3001. (RADEON_CLK_PWRMGT_CNTL) &
  3002. RADEON_MC_BUSY))
  3003. break;
  3004. }
  3005. break;
  3006. case 4:
  3007. while (tmp--) {
  3008. if (RREG32_PLL
  3009. (RADEON_CLK_PWRMGT_CNTL) &
  3010. RADEON_DLL_READY)
  3011. break;
  3012. }
  3013. break;
  3014. case 5:
  3015. tmp =
  3016. RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
  3017. if (tmp & RADEON_CG_NO1_DEBUG_0) {
  3018. #if 0
  3019. uint32_t mclk_cntl =
  3020. RREG32_PLL
  3021. (RADEON_MCLK_CNTL);
  3022. mclk_cntl &= 0xffff0000;
  3023. /*mclk_cntl |= 0x00001111;*//* ??? */
  3024. WREG32_PLL(RADEON_MCLK_CNTL,
  3025. mclk_cntl);
  3026. mdelay(10);
  3027. #endif
  3028. WREG32_PLL
  3029. (RADEON_CLK_PWRMGT_CNTL,
  3030. tmp &
  3031. ~RADEON_CG_NO1_DEBUG_0);
  3032. mdelay(10);
  3033. }
  3034. break;
  3035. default:
  3036. break;
  3037. }
  3038. break;
  3039. default:
  3040. break;
  3041. }
  3042. }
  3043. }
  3044. }
  3045. static void combios_parse_ram_reset_table(struct drm_device *dev,
  3046. uint16_t offset)
  3047. {
  3048. struct radeon_device *rdev = dev->dev_private;
  3049. uint32_t tmp;
  3050. if (offset) {
  3051. uint8_t val = RBIOS8(offset);
  3052. while (val != 0xff) {
  3053. offset++;
  3054. if (val == 0x0f) {
  3055. uint32_t channel_complete_mask;
  3056. if (ASIC_IS_R300(rdev))
  3057. channel_complete_mask =
  3058. R300_MEM_PWRUP_COMPLETE;
  3059. else
  3060. channel_complete_mask =
  3061. RADEON_MEM_PWRUP_COMPLETE;
  3062. tmp = 20000;
  3063. while (tmp--) {
  3064. if ((RREG32(RADEON_MEM_STR_CNTL) &
  3065. channel_complete_mask) ==
  3066. channel_complete_mask)
  3067. break;
  3068. }
  3069. } else {
  3070. uint32_t or_mask = RBIOS16(offset);
  3071. offset += 2;
  3072. tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
  3073. tmp &= RADEON_SDRAM_MODE_MASK;
  3074. tmp |= or_mask;
  3075. WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
  3076. or_mask = val << 24;
  3077. tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
  3078. tmp &= RADEON_B3MEM_RESET_MASK;
  3079. tmp |= or_mask;
  3080. WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
  3081. }
  3082. val = RBIOS8(offset);
  3083. }
  3084. }
  3085. }
  3086. static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
  3087. int mem_addr_mapping)
  3088. {
  3089. struct radeon_device *rdev = dev->dev_private;
  3090. uint32_t mem_cntl;
  3091. uint32_t mem_size;
  3092. uint32_t addr = 0;
  3093. mem_cntl = RREG32(RADEON_MEM_CNTL);
  3094. if (mem_cntl & RV100_HALF_MODE)
  3095. ram /= 2;
  3096. mem_size = ram;
  3097. mem_cntl &= ~(0xff << 8);
  3098. mem_cntl |= (mem_addr_mapping & 0xff) << 8;
  3099. WREG32(RADEON_MEM_CNTL, mem_cntl);
  3100. RREG32(RADEON_MEM_CNTL);
  3101. /* sdram reset ? */
  3102. /* something like this???? */
  3103. while (ram--) {
  3104. addr = ram * 1024 * 1024;
  3105. /* write to each page */
  3106. WREG32_IDX((addr) | RADEON_MM_APER, 0xdeadbeef);
  3107. /* read back and verify */
  3108. if (RREG32_IDX((addr) | RADEON_MM_APER) != 0xdeadbeef)
  3109. return 0;
  3110. }
  3111. return mem_size;
  3112. }
  3113. static void combios_write_ram_size(struct drm_device *dev)
  3114. {
  3115. struct radeon_device *rdev = dev->dev_private;
  3116. uint8_t rev;
  3117. uint16_t offset;
  3118. uint32_t mem_size = 0;
  3119. uint32_t mem_cntl = 0;
  3120. /* should do something smarter here I guess... */
  3121. if (rdev->flags & RADEON_IS_IGP)
  3122. return;
  3123. /* first check detected mem table */
  3124. offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
  3125. if (offset) {
  3126. rev = RBIOS8(offset);
  3127. if (rev < 3) {
  3128. mem_cntl = RBIOS32(offset + 1);
  3129. mem_size = RBIOS16(offset + 5);
  3130. if ((rdev->family < CHIP_R200) &&
  3131. !ASIC_IS_RN50(rdev))
  3132. WREG32(RADEON_MEM_CNTL, mem_cntl);
  3133. }
  3134. }
  3135. if (!mem_size) {
  3136. offset =
  3137. combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
  3138. if (offset) {
  3139. rev = RBIOS8(offset - 1);
  3140. if (rev < 1) {
  3141. if ((rdev->family < CHIP_R200)
  3142. && !ASIC_IS_RN50(rdev)) {
  3143. int ram = 0;
  3144. int mem_addr_mapping = 0;
  3145. while (RBIOS8(offset)) {
  3146. ram = RBIOS8(offset);
  3147. mem_addr_mapping =
  3148. RBIOS8(offset + 1);
  3149. if (mem_addr_mapping != 0x25)
  3150. ram *= 2;
  3151. mem_size =
  3152. combios_detect_ram(dev, ram,
  3153. mem_addr_mapping);
  3154. if (mem_size)
  3155. break;
  3156. offset += 2;
  3157. }
  3158. } else
  3159. mem_size = RBIOS8(offset);
  3160. } else {
  3161. mem_size = RBIOS8(offset);
  3162. mem_size *= 2; /* convert to MB */
  3163. }
  3164. }
  3165. }
  3166. mem_size *= (1024 * 1024); /* convert to bytes */
  3167. WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
  3168. }
  3169. void radeon_combios_asic_init(struct drm_device *dev)
  3170. {
  3171. struct radeon_device *rdev = dev->dev_private;
  3172. uint16_t table;
  3173. /* port hardcoded mac stuff from radeonfb */
  3174. if (rdev->bios == NULL)
  3175. return;
  3176. /* ASIC INIT 1 */
  3177. table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
  3178. if (table)
  3179. combios_parse_mmio_table(dev, table);
  3180. /* PLL INIT */
  3181. table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
  3182. if (table)
  3183. combios_parse_pll_table(dev, table);
  3184. /* ASIC INIT 2 */
  3185. table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
  3186. if (table)
  3187. combios_parse_mmio_table(dev, table);
  3188. if (!(rdev->flags & RADEON_IS_IGP)) {
  3189. /* ASIC INIT 4 */
  3190. table =
  3191. combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
  3192. if (table)
  3193. combios_parse_mmio_table(dev, table);
  3194. /* RAM RESET */
  3195. table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
  3196. if (table)
  3197. combios_parse_ram_reset_table(dev, table);
  3198. /* ASIC INIT 3 */
  3199. table =
  3200. combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
  3201. if (table)
  3202. combios_parse_mmio_table(dev, table);
  3203. /* write CONFIG_MEMSIZE */
  3204. combios_write_ram_size(dev);
  3205. }
  3206. /* quirk for rs4xx HP nx6125 laptop to make it resume
  3207. * - it hangs on resume inside the dynclk 1 table.
  3208. */
  3209. if (rdev->family == CHIP_RS480 &&
  3210. rdev->pdev->subsystem_vendor == 0x103c &&
  3211. rdev->pdev->subsystem_device == 0x308b)
  3212. return;
  3213. /* quirk for rs4xx HP dv5000 laptop to make it resume
  3214. * - it hangs on resume inside the dynclk 1 table.
  3215. */
  3216. if (rdev->family == CHIP_RS480 &&
  3217. rdev->pdev->subsystem_vendor == 0x103c &&
  3218. rdev->pdev->subsystem_device == 0x30a4)
  3219. return;
  3220. /* quirk for rs4xx Compaq Presario V5245EU laptop to make it resume
  3221. * - it hangs on resume inside the dynclk 1 table.
  3222. */
  3223. if (rdev->family == CHIP_RS480 &&
  3224. rdev->pdev->subsystem_vendor == 0x103c &&
  3225. rdev->pdev->subsystem_device == 0x30ae)
  3226. return;
  3227. /* DYN CLK 1 */
  3228. table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
  3229. if (table)
  3230. combios_parse_pll_table(dev, table);
  3231. }
  3232. void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
  3233. {
  3234. struct radeon_device *rdev = dev->dev_private;
  3235. uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
  3236. bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
  3237. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  3238. bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
  3239. /* let the bios control the backlight */
  3240. bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
  3241. /* tell the bios not to handle mode switching */
  3242. bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
  3243. RADEON_ACC_MODE_CHANGE);
  3244. /* tell the bios a driver is loaded */
  3245. bios_7_scratch |= RADEON_DRV_LOADED;
  3246. WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
  3247. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  3248. WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
  3249. }
  3250. void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
  3251. {
  3252. struct drm_device *dev = encoder->dev;
  3253. struct radeon_device *rdev = dev->dev_private;
  3254. uint32_t bios_6_scratch;
  3255. bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  3256. if (lock)
  3257. bios_6_scratch |= RADEON_DRIVER_CRITICAL;
  3258. else
  3259. bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
  3260. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  3261. }
  3262. void
  3263. radeon_combios_connected_scratch_regs(struct drm_connector *connector,
  3264. struct drm_encoder *encoder,
  3265. bool connected)
  3266. {
  3267. struct drm_device *dev = connector->dev;
  3268. struct radeon_device *rdev = dev->dev_private;
  3269. struct radeon_connector *radeon_connector =
  3270. to_radeon_connector(connector);
  3271. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  3272. uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
  3273. uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
  3274. if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
  3275. (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
  3276. if (connected) {
  3277. DRM_DEBUG_KMS("TV1 connected\n");
  3278. /* fix me */
  3279. bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
  3280. /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
  3281. bios_5_scratch |= RADEON_TV1_ON;
  3282. bios_5_scratch |= RADEON_ACC_REQ_TV1;
  3283. } else {
  3284. DRM_DEBUG_KMS("TV1 disconnected\n");
  3285. bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
  3286. bios_5_scratch &= ~RADEON_TV1_ON;
  3287. bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
  3288. }
  3289. }
  3290. if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
  3291. (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
  3292. if (connected) {
  3293. DRM_DEBUG_KMS("LCD1 connected\n");
  3294. bios_4_scratch |= RADEON_LCD1_ATTACHED;
  3295. bios_5_scratch |= RADEON_LCD1_ON;
  3296. bios_5_scratch |= RADEON_ACC_REQ_LCD1;
  3297. } else {
  3298. DRM_DEBUG_KMS("LCD1 disconnected\n");
  3299. bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
  3300. bios_5_scratch &= ~RADEON_LCD1_ON;
  3301. bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
  3302. }
  3303. }
  3304. if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
  3305. (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
  3306. if (connected) {
  3307. DRM_DEBUG_KMS("CRT1 connected\n");
  3308. bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
  3309. bios_5_scratch |= RADEON_CRT1_ON;
  3310. bios_5_scratch |= RADEON_ACC_REQ_CRT1;
  3311. } else {
  3312. DRM_DEBUG_KMS("CRT1 disconnected\n");
  3313. bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
  3314. bios_5_scratch &= ~RADEON_CRT1_ON;
  3315. bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
  3316. }
  3317. }
  3318. if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
  3319. (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
  3320. if (connected) {
  3321. DRM_DEBUG_KMS("CRT2 connected\n");
  3322. bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
  3323. bios_5_scratch |= RADEON_CRT2_ON;
  3324. bios_5_scratch |= RADEON_ACC_REQ_CRT2;
  3325. } else {
  3326. DRM_DEBUG_KMS("CRT2 disconnected\n");
  3327. bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
  3328. bios_5_scratch &= ~RADEON_CRT2_ON;
  3329. bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
  3330. }
  3331. }
  3332. if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
  3333. (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
  3334. if (connected) {
  3335. DRM_DEBUG_KMS("DFP1 connected\n");
  3336. bios_4_scratch |= RADEON_DFP1_ATTACHED;
  3337. bios_5_scratch |= RADEON_DFP1_ON;
  3338. bios_5_scratch |= RADEON_ACC_REQ_DFP1;
  3339. } else {
  3340. DRM_DEBUG_KMS("DFP1 disconnected\n");
  3341. bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
  3342. bios_5_scratch &= ~RADEON_DFP1_ON;
  3343. bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
  3344. }
  3345. }
  3346. if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
  3347. (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
  3348. if (connected) {
  3349. DRM_DEBUG_KMS("DFP2 connected\n");
  3350. bios_4_scratch |= RADEON_DFP2_ATTACHED;
  3351. bios_5_scratch |= RADEON_DFP2_ON;
  3352. bios_5_scratch |= RADEON_ACC_REQ_DFP2;
  3353. } else {
  3354. DRM_DEBUG_KMS("DFP2 disconnected\n");
  3355. bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
  3356. bios_5_scratch &= ~RADEON_DFP2_ON;
  3357. bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
  3358. }
  3359. }
  3360. WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
  3361. WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
  3362. }
  3363. void
  3364. radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
  3365. {
  3366. struct drm_device *dev = encoder->dev;
  3367. struct radeon_device *rdev = dev->dev_private;
  3368. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  3369. uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
  3370. if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
  3371. bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
  3372. bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
  3373. }
  3374. if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
  3375. bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
  3376. bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
  3377. }
  3378. if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
  3379. bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
  3380. bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
  3381. }
  3382. if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
  3383. bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
  3384. bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
  3385. }
  3386. if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
  3387. bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
  3388. bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
  3389. }
  3390. if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
  3391. bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
  3392. bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
  3393. }
  3394. WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
  3395. }
  3396. void
  3397. radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
  3398. {
  3399. struct drm_device *dev = encoder->dev;
  3400. struct radeon_device *rdev = dev->dev_private;
  3401. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  3402. uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
  3403. if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
  3404. if (on)
  3405. bios_6_scratch |= RADEON_TV_DPMS_ON;
  3406. else
  3407. bios_6_scratch &= ~RADEON_TV_DPMS_ON;
  3408. }
  3409. if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
  3410. if (on)
  3411. bios_6_scratch |= RADEON_CRT_DPMS_ON;
  3412. else
  3413. bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
  3414. }
  3415. if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
  3416. if (on)
  3417. bios_6_scratch |= RADEON_LCD_DPMS_ON;
  3418. else
  3419. bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
  3420. }
  3421. if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
  3422. if (on)
  3423. bios_6_scratch |= RADEON_DFP_DPMS_ON;
  3424. else
  3425. bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
  3426. }
  3427. WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
  3428. }