radeon_pm.c 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907
  1. /*
  2. * drivers/video/aty/radeon_pm.c
  3. *
  4. * Copyright 2003,2004 Ben. Herrenschmidt <benh@kernel.crashing.org>
  5. * Copyright 2004 Paul Mackerras <paulus@samba.org>
  6. *
  7. * This is the power management code for ATI radeon chipsets. It contains
  8. * some dynamic clock PM enable/disable code similar to what X.org does,
  9. * some D2-state (APM-style) sleep/wakeup code for use on some PowerMacs,
  10. * and the necessary bits to re-initialize from scratch a few chips found
  11. * on PowerMacs as well. The later could be extended to more platforms
  12. * provided the memory controller configuration code be made more generic,
  13. * and you can get the proper mode register commands for your RAMs.
  14. * Those things may be found in the BIOS image...
  15. */
  16. #include "radeonfb.h"
  17. #include <linux/console.h>
  18. #include <linux/agp_backend.h>
  19. #ifdef CONFIG_PPC_PMAC
  20. #include <asm/machdep.h>
  21. #include <asm/prom.h>
  22. #include <asm/pmac_feature.h>
  23. #endif
  24. #include "ati_ids.h"
  25. /*
  26. * Workarounds for bugs in PC laptops:
  27. * - enable D2 sleep in some IBM Thinkpads
  28. * - special case for Samsung P35
  29. *
  30. * Whitelist by subsystem vendor/device because
  31. * its the subsystem vendor's fault!
  32. */
  33. #if defined(CONFIG_PM) && defined(CONFIG_X86)
  34. static void radeon_reinitialize_M10(struct radeonfb_info *rinfo);
  35. struct radeon_device_id {
  36. const char *ident; /* (arbitrary) Name */
  37. const unsigned short subsystem_vendor; /* Subsystem Vendor ID */
  38. const unsigned short subsystem_device; /* Subsystem Device ID */
  39. const enum radeon_pm_mode pm_mode_modifier; /* modify pm_mode */
  40. const reinit_function_ptr new_reinit_func; /* changed reinit_func */
  41. };
  42. #define BUGFIX(model, sv, sd, pm, fn) { \
  43. .ident = model, \
  44. .subsystem_vendor = sv, \
  45. .subsystem_device = sd, \
  46. .pm_mode_modifier = pm, \
  47. .new_reinit_func = fn \
  48. }
  49. static struct radeon_device_id radeon_workaround_list[] = {
  50. BUGFIX("IBM Thinkpad R32",
  51. PCI_VENDOR_ID_IBM, 0x1905,
  52. radeon_pm_d2, NULL),
  53. BUGFIX("IBM Thinkpad R40",
  54. PCI_VENDOR_ID_IBM, 0x0526,
  55. radeon_pm_d2, NULL),
  56. BUGFIX("IBM Thinkpad R40",
  57. PCI_VENDOR_ID_IBM, 0x0527,
  58. radeon_pm_d2, NULL),
  59. BUGFIX("IBM Thinkpad R50/R51/T40/T41",
  60. PCI_VENDOR_ID_IBM, 0x0531,
  61. radeon_pm_d2, NULL),
  62. BUGFIX("IBM Thinkpad R51/T40/T41/T42",
  63. PCI_VENDOR_ID_IBM, 0x0530,
  64. radeon_pm_d2, NULL),
  65. BUGFIX("IBM Thinkpad T30",
  66. PCI_VENDOR_ID_IBM, 0x0517,
  67. radeon_pm_d2, NULL),
  68. BUGFIX("IBM Thinkpad T40p",
  69. PCI_VENDOR_ID_IBM, 0x054d,
  70. radeon_pm_d2, NULL),
  71. BUGFIX("IBM Thinkpad T42",
  72. PCI_VENDOR_ID_IBM, 0x0550,
  73. radeon_pm_d2, NULL),
  74. BUGFIX("IBM Thinkpad X31/X32",
  75. PCI_VENDOR_ID_IBM, 0x052f,
  76. radeon_pm_d2, NULL),
  77. BUGFIX("Samsung P35",
  78. PCI_VENDOR_ID_SAMSUNG, 0xc00c,
  79. radeon_pm_off, radeon_reinitialize_M10),
  80. BUGFIX("Acer Aspire 2010",
  81. PCI_VENDOR_ID_AI, 0x0061,
  82. radeon_pm_off, radeon_reinitialize_M10),
  83. BUGFIX("Acer Travelmate 290D/292LMi",
  84. PCI_VENDOR_ID_AI, 0x005a,
  85. radeon_pm_off, radeon_reinitialize_M10),
  86. { .ident = NULL }
  87. };
  88. static int radeon_apply_workarounds(struct radeonfb_info *rinfo)
  89. {
  90. struct radeon_device_id *id;
  91. for (id = radeon_workaround_list; id->ident != NULL; id++ )
  92. if ((id->subsystem_vendor == rinfo->pdev->subsystem_vendor ) &&
  93. (id->subsystem_device == rinfo->pdev->subsystem_device )) {
  94. /* we found a device that requires workaround */
  95. printk(KERN_DEBUG "radeonfb: %s detected"
  96. ", enabling workaround\n", id->ident);
  97. rinfo->pm_mode |= id->pm_mode_modifier;
  98. if (id->new_reinit_func != NULL)
  99. rinfo->reinit_func = id->new_reinit_func;
  100. return 1;
  101. }
  102. return 0; /* not found */
  103. }
  104. #else /* defined(CONFIG_PM) && defined(CONFIG_X86) */
  105. static inline int radeon_apply_workarounds(struct radeonfb_info *rinfo)
  106. {
  107. return 0;
  108. }
  109. #endif /* defined(CONFIG_PM) && defined(CONFIG_X86) */
  110. static void radeon_pm_disable_dynamic_mode(struct radeonfb_info *rinfo)
  111. {
  112. u32 tmp;
  113. /* RV100 */
  114. if ((rinfo->family == CHIP_FAMILY_RV100) && (!rinfo->is_mobility)) {
  115. if (rinfo->has_CRTC2) {
  116. tmp = INPLL(pllSCLK_CNTL);
  117. tmp &= ~SCLK_CNTL__DYN_STOP_LAT_MASK;
  118. tmp |= SCLK_CNTL__CP_MAX_DYN_STOP_LAT | SCLK_CNTL__FORCEON_MASK;
  119. OUTPLL(pllSCLK_CNTL, tmp);
  120. }
  121. tmp = INPLL(pllMCLK_CNTL);
  122. tmp |= (MCLK_CNTL__FORCE_MCLKA |
  123. MCLK_CNTL__FORCE_MCLKB |
  124. MCLK_CNTL__FORCE_YCLKA |
  125. MCLK_CNTL__FORCE_YCLKB |
  126. MCLK_CNTL__FORCE_AIC |
  127. MCLK_CNTL__FORCE_MC);
  128. OUTPLL(pllMCLK_CNTL, tmp);
  129. return;
  130. }
  131. /* R100 */
  132. if (!rinfo->has_CRTC2) {
  133. tmp = INPLL(pllSCLK_CNTL);
  134. tmp |= (SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_HDP |
  135. SCLK_CNTL__FORCE_DISP1 | SCLK_CNTL__FORCE_TOP |
  136. SCLK_CNTL__FORCE_E2 | SCLK_CNTL__FORCE_SE |
  137. SCLK_CNTL__FORCE_IDCT | SCLK_CNTL__FORCE_VIP |
  138. SCLK_CNTL__FORCE_RE | SCLK_CNTL__FORCE_PB |
  139. SCLK_CNTL__FORCE_TAM | SCLK_CNTL__FORCE_TDM |
  140. SCLK_CNTL__FORCE_RB);
  141. OUTPLL(pllSCLK_CNTL, tmp);
  142. return;
  143. }
  144. /* RV350 (M10/M11) */
  145. if (rinfo->family == CHIP_FAMILY_RV350) {
  146. /* for RV350/M10/M11, no delays are required. */
  147. tmp = INPLL(pllSCLK_CNTL2);
  148. tmp |= (SCLK_CNTL2__R300_FORCE_TCL |
  149. SCLK_CNTL2__R300_FORCE_GA |
  150. SCLK_CNTL2__R300_FORCE_CBA);
  151. OUTPLL(pllSCLK_CNTL2, tmp);
  152. tmp = INPLL(pllSCLK_CNTL);
  153. tmp |= (SCLK_CNTL__FORCE_DISP2 | SCLK_CNTL__FORCE_CP |
  154. SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 |
  155. SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_E2 |
  156. SCLK_CNTL__R300_FORCE_VAP | SCLK_CNTL__FORCE_IDCT |
  157. SCLK_CNTL__FORCE_VIP | SCLK_CNTL__R300_FORCE_SR |
  158. SCLK_CNTL__R300_FORCE_PX | SCLK_CNTL__R300_FORCE_TX |
  159. SCLK_CNTL__R300_FORCE_US | SCLK_CNTL__FORCE_TV_SCLK |
  160. SCLK_CNTL__R300_FORCE_SU | SCLK_CNTL__FORCE_OV0);
  161. OUTPLL(pllSCLK_CNTL, tmp);
  162. tmp = INPLL(pllSCLK_MORE_CNTL);
  163. tmp |= (SCLK_MORE_CNTL__FORCE_DISPREGS | SCLK_MORE_CNTL__FORCE_MC_GUI |
  164. SCLK_MORE_CNTL__FORCE_MC_HOST);
  165. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  166. tmp = INPLL(pllMCLK_CNTL);
  167. tmp |= (MCLK_CNTL__FORCE_MCLKA |
  168. MCLK_CNTL__FORCE_MCLKB |
  169. MCLK_CNTL__FORCE_YCLKA |
  170. MCLK_CNTL__FORCE_YCLKB |
  171. MCLK_CNTL__FORCE_MC);
  172. OUTPLL(pllMCLK_CNTL, tmp);
  173. tmp = INPLL(pllVCLK_ECP_CNTL);
  174. tmp &= ~(VCLK_ECP_CNTL__PIXCLK_ALWAYS_ONb |
  175. VCLK_ECP_CNTL__PIXCLK_DAC_ALWAYS_ONb |
  176. VCLK_ECP_CNTL__R300_DISP_DAC_PIXCLK_DAC_BLANK_OFF);
  177. OUTPLL(pllVCLK_ECP_CNTL, tmp);
  178. tmp = INPLL(pllPIXCLKS_CNTL);
  179. tmp &= ~(PIXCLKS_CNTL__PIX2CLK_ALWAYS_ONb |
  180. PIXCLKS_CNTL__PIX2CLK_DAC_ALWAYS_ONb |
  181. PIXCLKS_CNTL__DISP_TVOUT_PIXCLK_TV_ALWAYS_ONb |
  182. PIXCLKS_CNTL__R300_DVOCLK_ALWAYS_ONb |
  183. PIXCLKS_CNTL__PIXCLK_BLEND_ALWAYS_ONb |
  184. PIXCLKS_CNTL__PIXCLK_GV_ALWAYS_ONb |
  185. PIXCLKS_CNTL__R300_PIXCLK_DVO_ALWAYS_ONb |
  186. PIXCLKS_CNTL__PIXCLK_LVDS_ALWAYS_ONb |
  187. PIXCLKS_CNTL__PIXCLK_TMDS_ALWAYS_ONb |
  188. PIXCLKS_CNTL__R300_PIXCLK_TRANS_ALWAYS_ONb |
  189. PIXCLKS_CNTL__R300_PIXCLK_TVO_ALWAYS_ONb |
  190. PIXCLKS_CNTL__R300_P2G2CLK_ALWAYS_ONb |
  191. PIXCLKS_CNTL__R300_DISP_DAC_PIXCLK_DAC2_BLANK_OFF);
  192. OUTPLL(pllPIXCLKS_CNTL, tmp);
  193. return;
  194. }
  195. /* Default */
  196. /* Force Core Clocks */
  197. tmp = INPLL(pllSCLK_CNTL);
  198. tmp |= (SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_E2);
  199. /* XFree doesn't do that case, but we had this code from Apple and it
  200. * seem necessary for proper suspend/resume operations
  201. */
  202. if (rinfo->is_mobility) {
  203. tmp |= SCLK_CNTL__FORCE_HDP|
  204. SCLK_CNTL__FORCE_DISP1|
  205. SCLK_CNTL__FORCE_DISP2|
  206. SCLK_CNTL__FORCE_TOP|
  207. SCLK_CNTL__FORCE_SE|
  208. SCLK_CNTL__FORCE_IDCT|
  209. SCLK_CNTL__FORCE_VIP|
  210. SCLK_CNTL__FORCE_PB|
  211. SCLK_CNTL__FORCE_RE|
  212. SCLK_CNTL__FORCE_TAM|
  213. SCLK_CNTL__FORCE_TDM|
  214. SCLK_CNTL__FORCE_RB|
  215. SCLK_CNTL__FORCE_TV_SCLK|
  216. SCLK_CNTL__FORCE_SUBPIC|
  217. SCLK_CNTL__FORCE_OV0;
  218. }
  219. else if (rinfo->family == CHIP_FAMILY_R300 ||
  220. rinfo->family == CHIP_FAMILY_R350) {
  221. tmp |= SCLK_CNTL__FORCE_HDP |
  222. SCLK_CNTL__FORCE_DISP1 |
  223. SCLK_CNTL__FORCE_DISP2 |
  224. SCLK_CNTL__FORCE_TOP |
  225. SCLK_CNTL__FORCE_IDCT |
  226. SCLK_CNTL__FORCE_VIP;
  227. }
  228. OUTPLL(pllSCLK_CNTL, tmp);
  229. radeon_msleep(16);
  230. if (rinfo->family == CHIP_FAMILY_R300 || rinfo->family == CHIP_FAMILY_R350) {
  231. tmp = INPLL(pllSCLK_CNTL2);
  232. tmp |= SCLK_CNTL2__R300_FORCE_TCL |
  233. SCLK_CNTL2__R300_FORCE_GA |
  234. SCLK_CNTL2__R300_FORCE_CBA;
  235. OUTPLL(pllSCLK_CNTL2, tmp);
  236. radeon_msleep(16);
  237. }
  238. tmp = INPLL(pllCLK_PIN_CNTL);
  239. tmp &= ~CLK_PIN_CNTL__SCLK_DYN_START_CNTL;
  240. OUTPLL(pllCLK_PIN_CNTL, tmp);
  241. radeon_msleep(15);
  242. if (rinfo->is_IGP) {
  243. /* Weird ... X is _un_ forcing clocks here, I think it's
  244. * doing backward. Imitate it for now...
  245. */
  246. tmp = INPLL(pllMCLK_CNTL);
  247. tmp &= ~(MCLK_CNTL__FORCE_MCLKA |
  248. MCLK_CNTL__FORCE_YCLKA);
  249. OUTPLL(pllMCLK_CNTL, tmp);
  250. radeon_msleep(16);
  251. }
  252. /* Hrm... same shit, X doesn't do that but I have to */
  253. else if (rinfo->is_mobility) {
  254. tmp = INPLL(pllMCLK_CNTL);
  255. tmp |= (MCLK_CNTL__FORCE_MCLKA |
  256. MCLK_CNTL__FORCE_MCLKB |
  257. MCLK_CNTL__FORCE_YCLKA |
  258. MCLK_CNTL__FORCE_YCLKB);
  259. OUTPLL(pllMCLK_CNTL, tmp);
  260. radeon_msleep(16);
  261. tmp = INPLL(pllMCLK_MISC);
  262. tmp &= ~(MCLK_MISC__MC_MCLK_MAX_DYN_STOP_LAT|
  263. MCLK_MISC__IO_MCLK_MAX_DYN_STOP_LAT|
  264. MCLK_MISC__MC_MCLK_DYN_ENABLE|
  265. MCLK_MISC__IO_MCLK_DYN_ENABLE);
  266. OUTPLL(pllMCLK_MISC, tmp);
  267. radeon_msleep(15);
  268. }
  269. if (rinfo->is_mobility) {
  270. tmp = INPLL(pllSCLK_MORE_CNTL);
  271. tmp |= SCLK_MORE_CNTL__FORCE_DISPREGS|
  272. SCLK_MORE_CNTL__FORCE_MC_GUI|
  273. SCLK_MORE_CNTL__FORCE_MC_HOST;
  274. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  275. radeon_msleep(16);
  276. }
  277. tmp = INPLL(pllPIXCLKS_CNTL);
  278. tmp &= ~(PIXCLKS_CNTL__PIXCLK_GV_ALWAYS_ONb |
  279. PIXCLKS_CNTL__PIXCLK_BLEND_ALWAYS_ONb|
  280. PIXCLKS_CNTL__PIXCLK_DIG_TMDS_ALWAYS_ONb |
  281. PIXCLKS_CNTL__PIXCLK_LVDS_ALWAYS_ONb|
  282. PIXCLKS_CNTL__PIXCLK_TMDS_ALWAYS_ONb|
  283. PIXCLKS_CNTL__PIX2CLK_ALWAYS_ONb|
  284. PIXCLKS_CNTL__PIX2CLK_DAC_ALWAYS_ONb);
  285. OUTPLL(pllPIXCLKS_CNTL, tmp);
  286. radeon_msleep(16);
  287. tmp = INPLL( pllVCLK_ECP_CNTL);
  288. tmp &= ~(VCLK_ECP_CNTL__PIXCLK_ALWAYS_ONb |
  289. VCLK_ECP_CNTL__PIXCLK_DAC_ALWAYS_ONb);
  290. OUTPLL( pllVCLK_ECP_CNTL, tmp);
  291. radeon_msleep(16);
  292. }
  293. static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
  294. {
  295. u32 tmp;
  296. /* R100 */
  297. if (!rinfo->has_CRTC2) {
  298. tmp = INPLL(pllSCLK_CNTL);
  299. if ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) > CFG_ATI_REV_A13)
  300. tmp &= ~(SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_RB);
  301. tmp &= ~(SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 |
  302. SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_SE |
  303. SCLK_CNTL__FORCE_IDCT | SCLK_CNTL__FORCE_RE |
  304. SCLK_CNTL__FORCE_PB | SCLK_CNTL__FORCE_TAM |
  305. SCLK_CNTL__FORCE_TDM);
  306. OUTPLL(pllSCLK_CNTL, tmp);
  307. return;
  308. }
  309. /* M10/M11 */
  310. if (rinfo->family == CHIP_FAMILY_RV350) {
  311. tmp = INPLL(pllSCLK_CNTL2);
  312. tmp &= ~(SCLK_CNTL2__R300_FORCE_TCL |
  313. SCLK_CNTL2__R300_FORCE_GA |
  314. SCLK_CNTL2__R300_FORCE_CBA);
  315. tmp |= (SCLK_CNTL2__R300_TCL_MAX_DYN_STOP_LAT |
  316. SCLK_CNTL2__R300_GA_MAX_DYN_STOP_LAT |
  317. SCLK_CNTL2__R300_CBA_MAX_DYN_STOP_LAT);
  318. OUTPLL(pllSCLK_CNTL2, tmp);
  319. tmp = INPLL(pllSCLK_CNTL);
  320. tmp &= ~(SCLK_CNTL__FORCE_DISP2 | SCLK_CNTL__FORCE_CP |
  321. SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 |
  322. SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_E2 |
  323. SCLK_CNTL__R300_FORCE_VAP | SCLK_CNTL__FORCE_IDCT |
  324. SCLK_CNTL__FORCE_VIP | SCLK_CNTL__R300_FORCE_SR |
  325. SCLK_CNTL__R300_FORCE_PX | SCLK_CNTL__R300_FORCE_TX |
  326. SCLK_CNTL__R300_FORCE_US | SCLK_CNTL__FORCE_TV_SCLK |
  327. SCLK_CNTL__R300_FORCE_SU | SCLK_CNTL__FORCE_OV0);
  328. tmp |= SCLK_CNTL__DYN_STOP_LAT_MASK;
  329. OUTPLL(pllSCLK_CNTL, tmp);
  330. tmp = INPLL(pllSCLK_MORE_CNTL);
  331. tmp &= ~SCLK_MORE_CNTL__FORCEON;
  332. tmp |= SCLK_MORE_CNTL__DISPREGS_MAX_DYN_STOP_LAT |
  333. SCLK_MORE_CNTL__MC_GUI_MAX_DYN_STOP_LAT |
  334. SCLK_MORE_CNTL__MC_HOST_MAX_DYN_STOP_LAT;
  335. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  336. tmp = INPLL(pllVCLK_ECP_CNTL);
  337. tmp |= (VCLK_ECP_CNTL__PIXCLK_ALWAYS_ONb |
  338. VCLK_ECP_CNTL__PIXCLK_DAC_ALWAYS_ONb);
  339. OUTPLL(pllVCLK_ECP_CNTL, tmp);
  340. tmp = INPLL(pllPIXCLKS_CNTL);
  341. tmp |= (PIXCLKS_CNTL__PIX2CLK_ALWAYS_ONb |
  342. PIXCLKS_CNTL__PIX2CLK_DAC_ALWAYS_ONb |
  343. PIXCLKS_CNTL__DISP_TVOUT_PIXCLK_TV_ALWAYS_ONb |
  344. PIXCLKS_CNTL__R300_DVOCLK_ALWAYS_ONb |
  345. PIXCLKS_CNTL__PIXCLK_BLEND_ALWAYS_ONb |
  346. PIXCLKS_CNTL__PIXCLK_GV_ALWAYS_ONb |
  347. PIXCLKS_CNTL__R300_PIXCLK_DVO_ALWAYS_ONb |
  348. PIXCLKS_CNTL__PIXCLK_LVDS_ALWAYS_ONb |
  349. PIXCLKS_CNTL__PIXCLK_TMDS_ALWAYS_ONb |
  350. PIXCLKS_CNTL__R300_PIXCLK_TRANS_ALWAYS_ONb |
  351. PIXCLKS_CNTL__R300_PIXCLK_TVO_ALWAYS_ONb |
  352. PIXCLKS_CNTL__R300_P2G2CLK_ALWAYS_ONb |
  353. PIXCLKS_CNTL__R300_P2G2CLK_DAC_ALWAYS_ONb);
  354. OUTPLL(pllPIXCLKS_CNTL, tmp);
  355. tmp = INPLL(pllMCLK_MISC);
  356. tmp |= (MCLK_MISC__MC_MCLK_DYN_ENABLE |
  357. MCLK_MISC__IO_MCLK_DYN_ENABLE);
  358. OUTPLL(pllMCLK_MISC, tmp);
  359. tmp = INPLL(pllMCLK_CNTL);
  360. tmp |= (MCLK_CNTL__FORCE_MCLKA | MCLK_CNTL__FORCE_MCLKB);
  361. tmp &= ~(MCLK_CNTL__FORCE_YCLKA |
  362. MCLK_CNTL__FORCE_YCLKB |
  363. MCLK_CNTL__FORCE_MC);
  364. /* Some releases of vbios have set DISABLE_MC_MCLKA
  365. * and DISABLE_MC_MCLKB bits in the vbios table. Setting these
  366. * bits will cause H/W hang when reading video memory with dynamic
  367. * clocking enabled.
  368. */
  369. if ((tmp & MCLK_CNTL__R300_DISABLE_MC_MCLKA) &&
  370. (tmp & MCLK_CNTL__R300_DISABLE_MC_MCLKB)) {
  371. /* If both bits are set, then check the active channels */
  372. tmp = INPLL(pllMCLK_CNTL);
  373. if (rinfo->vram_width == 64) {
  374. if (INREG(MEM_CNTL) & R300_MEM_USE_CD_CH_ONLY)
  375. tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKB;
  376. else
  377. tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKA;
  378. } else {
  379. tmp &= ~(MCLK_CNTL__R300_DISABLE_MC_MCLKA |
  380. MCLK_CNTL__R300_DISABLE_MC_MCLKB);
  381. }
  382. }
  383. OUTPLL(pllMCLK_CNTL, tmp);
  384. return;
  385. }
  386. /* R300 */
  387. if (rinfo->family == CHIP_FAMILY_R300 || rinfo->family == CHIP_FAMILY_R350) {
  388. tmp = INPLL(pllSCLK_CNTL);
  389. tmp &= ~(SCLK_CNTL__R300_FORCE_VAP);
  390. tmp |= SCLK_CNTL__FORCE_CP;
  391. OUTPLL(pllSCLK_CNTL, tmp);
  392. radeon_msleep(15);
  393. tmp = INPLL(pllSCLK_CNTL2);
  394. tmp &= ~(SCLK_CNTL2__R300_FORCE_TCL |
  395. SCLK_CNTL2__R300_FORCE_GA |
  396. SCLK_CNTL2__R300_FORCE_CBA);
  397. OUTPLL(pllSCLK_CNTL2, tmp);
  398. }
  399. /* Others */
  400. tmp = INPLL( pllCLK_PWRMGT_CNTL);
  401. tmp &= ~(CLK_PWRMGT_CNTL__ACTIVE_HILO_LAT_MASK|
  402. CLK_PWRMGT_CNTL__DISP_DYN_STOP_LAT_MASK|
  403. CLK_PWRMGT_CNTL__DYN_STOP_MODE_MASK);
  404. tmp |= CLK_PWRMGT_CNTL__ENGINE_DYNCLK_MODE_MASK |
  405. (0x01 << CLK_PWRMGT_CNTL__ACTIVE_HILO_LAT__SHIFT);
  406. OUTPLL( pllCLK_PWRMGT_CNTL, tmp);
  407. radeon_msleep(15);
  408. tmp = INPLL(pllCLK_PIN_CNTL);
  409. tmp |= CLK_PIN_CNTL__SCLK_DYN_START_CNTL;
  410. OUTPLL(pllCLK_PIN_CNTL, tmp);
  411. radeon_msleep(15);
  412. /* When DRI is enabled, setting DYN_STOP_LAT to zero can cause some R200
  413. * to lockup randomly, leave them as set by BIOS.
  414. */
  415. tmp = INPLL(pllSCLK_CNTL);
  416. tmp &= ~SCLK_CNTL__FORCEON_MASK;
  417. /*RAGE_6::A11 A12 A12N1 A13, RV250::A11 A12, R300*/
  418. if ((rinfo->family == CHIP_FAMILY_RV250 &&
  419. ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) ||
  420. ((rinfo->family == CHIP_FAMILY_RV100) &&
  421. ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) {
  422. tmp |= SCLK_CNTL__FORCE_CP;
  423. tmp |= SCLK_CNTL__FORCE_VIP;
  424. }
  425. OUTPLL(pllSCLK_CNTL, tmp);
  426. radeon_msleep(15);
  427. if ((rinfo->family == CHIP_FAMILY_RV200) ||
  428. (rinfo->family == CHIP_FAMILY_RV250) ||
  429. (rinfo->family == CHIP_FAMILY_RV280)) {
  430. tmp = INPLL(pllSCLK_MORE_CNTL);
  431. tmp &= ~SCLK_MORE_CNTL__FORCEON;
  432. /* RV200::A11 A12 RV250::A11 A12 */
  433. if (((rinfo->family == CHIP_FAMILY_RV200) ||
  434. (rinfo->family == CHIP_FAMILY_RV250)) &&
  435. ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13))
  436. tmp |= SCLK_MORE_CNTL__FORCEON;
  437. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  438. radeon_msleep(15);
  439. }
  440. /* RV200::A11 A12, RV250::A11 A12 */
  441. if (((rinfo->family == CHIP_FAMILY_RV200) ||
  442. (rinfo->family == CHIP_FAMILY_RV250)) &&
  443. ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) {
  444. tmp = INPLL(pllPLL_PWRMGT_CNTL);
  445. tmp |= PLL_PWRMGT_CNTL__TCL_BYPASS_DISABLE;
  446. OUTPLL(pllPLL_PWRMGT_CNTL, tmp);
  447. radeon_msleep(15);
  448. }
  449. tmp = INPLL(pllPIXCLKS_CNTL);
  450. tmp |= PIXCLKS_CNTL__PIX2CLK_ALWAYS_ONb |
  451. PIXCLKS_CNTL__PIX2CLK_DAC_ALWAYS_ONb|
  452. PIXCLKS_CNTL__PIXCLK_BLEND_ALWAYS_ONb|
  453. PIXCLKS_CNTL__PIXCLK_GV_ALWAYS_ONb|
  454. PIXCLKS_CNTL__PIXCLK_DIG_TMDS_ALWAYS_ONb|
  455. PIXCLKS_CNTL__PIXCLK_LVDS_ALWAYS_ONb|
  456. PIXCLKS_CNTL__PIXCLK_TMDS_ALWAYS_ONb;
  457. OUTPLL(pllPIXCLKS_CNTL, tmp);
  458. radeon_msleep(15);
  459. tmp = INPLL(pllVCLK_ECP_CNTL);
  460. tmp |= VCLK_ECP_CNTL__PIXCLK_ALWAYS_ONb |
  461. VCLK_ECP_CNTL__PIXCLK_DAC_ALWAYS_ONb;
  462. OUTPLL(pllVCLK_ECP_CNTL, tmp);
  463. /* X doesn't do that ... hrm, we do on mobility && Macs */
  464. #ifdef CONFIG_PPC
  465. if (rinfo->is_mobility) {
  466. tmp = INPLL(pllMCLK_CNTL);
  467. tmp &= ~(MCLK_CNTL__FORCE_MCLKA |
  468. MCLK_CNTL__FORCE_MCLKB |
  469. MCLK_CNTL__FORCE_YCLKA |
  470. MCLK_CNTL__FORCE_YCLKB);
  471. OUTPLL(pllMCLK_CNTL, tmp);
  472. radeon_msleep(15);
  473. tmp = INPLL(pllMCLK_MISC);
  474. tmp |= MCLK_MISC__MC_MCLK_MAX_DYN_STOP_LAT|
  475. MCLK_MISC__IO_MCLK_MAX_DYN_STOP_LAT|
  476. MCLK_MISC__MC_MCLK_DYN_ENABLE|
  477. MCLK_MISC__IO_MCLK_DYN_ENABLE;
  478. OUTPLL(pllMCLK_MISC, tmp);
  479. radeon_msleep(15);
  480. }
  481. #endif /* CONFIG_PPC */
  482. }
  483. #ifdef CONFIG_PM
  484. static void OUTMC( struct radeonfb_info *rinfo, u8 indx, u32 value)
  485. {
  486. OUTREG( MC_IND_INDEX, indx | MC_IND_INDEX__MC_IND_WR_EN);
  487. OUTREG( MC_IND_DATA, value);
  488. }
  489. static u32 INMC(struct radeonfb_info *rinfo, u8 indx)
  490. {
  491. OUTREG( MC_IND_INDEX, indx);
  492. return INREG( MC_IND_DATA);
  493. }
  494. static void radeon_pm_save_regs(struct radeonfb_info *rinfo, int saving_for_d3)
  495. {
  496. rinfo->save_regs[0] = INPLL(PLL_PWRMGT_CNTL);
  497. rinfo->save_regs[1] = INPLL(CLK_PWRMGT_CNTL);
  498. rinfo->save_regs[2] = INPLL(MCLK_CNTL);
  499. rinfo->save_regs[3] = INPLL(SCLK_CNTL);
  500. rinfo->save_regs[4] = INPLL(CLK_PIN_CNTL);
  501. rinfo->save_regs[5] = INPLL(VCLK_ECP_CNTL);
  502. rinfo->save_regs[6] = INPLL(PIXCLKS_CNTL);
  503. rinfo->save_regs[7] = INPLL(MCLK_MISC);
  504. rinfo->save_regs[8] = INPLL(P2PLL_CNTL);
  505. rinfo->save_regs[9] = INREG(DISP_MISC_CNTL);
  506. rinfo->save_regs[10] = INREG(DISP_PWR_MAN);
  507. rinfo->save_regs[11] = INREG(LVDS_GEN_CNTL);
  508. rinfo->save_regs[13] = INREG(TV_DAC_CNTL);
  509. rinfo->save_regs[14] = INREG(BUS_CNTL1);
  510. rinfo->save_regs[15] = INREG(CRTC_OFFSET_CNTL);
  511. rinfo->save_regs[16] = INREG(AGP_CNTL);
  512. rinfo->save_regs[17] = (INREG(CRTC_GEN_CNTL) & 0xfdffffff) | 0x04000000;
  513. rinfo->save_regs[18] = (INREG(CRTC2_GEN_CNTL) & 0xfdffffff) | 0x04000000;
  514. rinfo->save_regs[19] = INREG(GPIOPAD_A);
  515. rinfo->save_regs[20] = INREG(GPIOPAD_EN);
  516. rinfo->save_regs[21] = INREG(GPIOPAD_MASK);
  517. rinfo->save_regs[22] = INREG(ZV_LCDPAD_A);
  518. rinfo->save_regs[23] = INREG(ZV_LCDPAD_EN);
  519. rinfo->save_regs[24] = INREG(ZV_LCDPAD_MASK);
  520. rinfo->save_regs[25] = INREG(GPIO_VGA_DDC);
  521. rinfo->save_regs[26] = INREG(GPIO_DVI_DDC);
  522. rinfo->save_regs[27] = INREG(GPIO_MONID);
  523. rinfo->save_regs[28] = INREG(GPIO_CRT2_DDC);
  524. rinfo->save_regs[29] = INREG(SURFACE_CNTL);
  525. rinfo->save_regs[30] = INREG(MC_FB_LOCATION);
  526. rinfo->save_regs[31] = INREG(DISPLAY_BASE_ADDR);
  527. rinfo->save_regs[32] = INREG(MC_AGP_LOCATION);
  528. rinfo->save_regs[33] = INREG(CRTC2_DISPLAY_BASE_ADDR);
  529. rinfo->save_regs[34] = INPLL(SCLK_MORE_CNTL);
  530. rinfo->save_regs[35] = INREG(MEM_SDRAM_MODE_REG);
  531. rinfo->save_regs[36] = INREG(BUS_CNTL);
  532. rinfo->save_regs[39] = INREG(RBBM_CNTL);
  533. rinfo->save_regs[40] = INREG(DAC_CNTL);
  534. rinfo->save_regs[41] = INREG(HOST_PATH_CNTL);
  535. rinfo->save_regs[37] = INREG(MPP_TB_CONFIG);
  536. rinfo->save_regs[38] = INREG(FCP_CNTL);
  537. if (rinfo->is_mobility) {
  538. rinfo->save_regs[12] = INREG(LVDS_PLL_CNTL);
  539. rinfo->save_regs[43] = INPLL(pllSSPLL_CNTL);
  540. rinfo->save_regs[44] = INPLL(pllSSPLL_REF_DIV);
  541. rinfo->save_regs[45] = INPLL(pllSSPLL_DIV_0);
  542. rinfo->save_regs[90] = INPLL(pllSS_INT_CNTL);
  543. rinfo->save_regs[91] = INPLL(pllSS_TST_CNTL);
  544. rinfo->save_regs[81] = INREG(LVDS_GEN_CNTL);
  545. }
  546. if (rinfo->family >= CHIP_FAMILY_RV200) {
  547. rinfo->save_regs[42] = INREG(MEM_REFRESH_CNTL);
  548. rinfo->save_regs[46] = INREG(MC_CNTL);
  549. rinfo->save_regs[47] = INREG(MC_INIT_GFX_LAT_TIMER);
  550. rinfo->save_regs[48] = INREG(MC_INIT_MISC_LAT_TIMER);
  551. rinfo->save_regs[49] = INREG(MC_TIMING_CNTL);
  552. rinfo->save_regs[50] = INREG(MC_READ_CNTL_AB);
  553. rinfo->save_regs[51] = INREG(MC_IOPAD_CNTL);
  554. rinfo->save_regs[52] = INREG(MC_CHIP_IO_OE_CNTL_AB);
  555. rinfo->save_regs[53] = INREG(MC_DEBUG);
  556. }
  557. rinfo->save_regs[54] = INREG(PAMAC0_DLY_CNTL);
  558. rinfo->save_regs[55] = INREG(PAMAC1_DLY_CNTL);
  559. rinfo->save_regs[56] = INREG(PAD_CTLR_MISC);
  560. rinfo->save_regs[57] = INREG(FW_CNTL);
  561. if (rinfo->family >= CHIP_FAMILY_R300) {
  562. rinfo->save_regs[58] = INMC(rinfo, ixR300_MC_MC_INIT_WR_LAT_TIMER);
  563. rinfo->save_regs[59] = INMC(rinfo, ixR300_MC_IMP_CNTL);
  564. rinfo->save_regs[60] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_C0);
  565. rinfo->save_regs[61] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_C1);
  566. rinfo->save_regs[62] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_D0);
  567. rinfo->save_regs[63] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_D1);
  568. rinfo->save_regs[64] = INMC(rinfo, ixR300_MC_BIST_CNTL_3);
  569. rinfo->save_regs[65] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_A0);
  570. rinfo->save_regs[66] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_A1);
  571. rinfo->save_regs[67] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_B0);
  572. rinfo->save_regs[68] = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_B1);
  573. rinfo->save_regs[69] = INMC(rinfo, ixR300_MC_DEBUG_CNTL);
  574. rinfo->save_regs[70] = INMC(rinfo, ixR300_MC_DLL_CNTL);
  575. rinfo->save_regs[71] = INMC(rinfo, ixR300_MC_IMP_CNTL_0);
  576. rinfo->save_regs[72] = INMC(rinfo, ixR300_MC_ELPIDA_CNTL);
  577. rinfo->save_regs[96] = INMC(rinfo, ixR300_MC_READ_CNTL_CD);
  578. } else {
  579. rinfo->save_regs[59] = INMC(rinfo, ixMC_IMP_CNTL);
  580. rinfo->save_regs[65] = INMC(rinfo, ixMC_CHP_IO_CNTL_A0);
  581. rinfo->save_regs[66] = INMC(rinfo, ixMC_CHP_IO_CNTL_A1);
  582. rinfo->save_regs[67] = INMC(rinfo, ixMC_CHP_IO_CNTL_B0);
  583. rinfo->save_regs[68] = INMC(rinfo, ixMC_CHP_IO_CNTL_B1);
  584. rinfo->save_regs[71] = INMC(rinfo, ixMC_IMP_CNTL_0);
  585. }
  586. rinfo->save_regs[73] = INPLL(pllMPLL_CNTL);
  587. rinfo->save_regs[74] = INPLL(pllSPLL_CNTL);
  588. rinfo->save_regs[75] = INPLL(pllMPLL_AUX_CNTL);
  589. rinfo->save_regs[76] = INPLL(pllSPLL_AUX_CNTL);
  590. rinfo->save_regs[77] = INPLL(pllM_SPLL_REF_FB_DIV);
  591. rinfo->save_regs[78] = INPLL(pllAGP_PLL_CNTL);
  592. rinfo->save_regs[79] = INREG(PAMAC2_DLY_CNTL);
  593. rinfo->save_regs[80] = INREG(OV0_BASE_ADDR);
  594. rinfo->save_regs[82] = INREG(FP_GEN_CNTL);
  595. rinfo->save_regs[83] = INREG(FP2_GEN_CNTL);
  596. rinfo->save_regs[84] = INREG(TMDS_CNTL);
  597. rinfo->save_regs[85] = INREG(TMDS_TRANSMITTER_CNTL);
  598. rinfo->save_regs[86] = INREG(DISP_OUTPUT_CNTL);
  599. rinfo->save_regs[87] = INREG(DISP_HW_DEBUG);
  600. rinfo->save_regs[88] = INREG(TV_MASTER_CNTL);
  601. rinfo->save_regs[89] = INPLL(pllP2PLL_REF_DIV);
  602. rinfo->save_regs[92] = INPLL(pllPPLL_DIV_0);
  603. rinfo->save_regs[93] = INPLL(pllPPLL_CNTL);
  604. rinfo->save_regs[94] = INREG(GRPH_BUFFER_CNTL);
  605. rinfo->save_regs[95] = INREG(GRPH2_BUFFER_CNTL);
  606. rinfo->save_regs[96] = INREG(HDP_DEBUG);
  607. rinfo->save_regs[97] = INPLL(pllMDLL_CKO);
  608. rinfo->save_regs[98] = INPLL(pllMDLL_RDCKA);
  609. rinfo->save_regs[99] = INPLL(pllMDLL_RDCKB);
  610. }
  611. static void radeon_pm_restore_regs(struct radeonfb_info *rinfo)
  612. {
  613. OUTPLL(P2PLL_CNTL, rinfo->save_regs[8] & 0xFFFFFFFE); /* First */
  614. OUTPLL(PLL_PWRMGT_CNTL, rinfo->save_regs[0]);
  615. OUTPLL(CLK_PWRMGT_CNTL, rinfo->save_regs[1]);
  616. OUTPLL(MCLK_CNTL, rinfo->save_regs[2]);
  617. OUTPLL(SCLK_CNTL, rinfo->save_regs[3]);
  618. OUTPLL(CLK_PIN_CNTL, rinfo->save_regs[4]);
  619. OUTPLL(VCLK_ECP_CNTL, rinfo->save_regs[5]);
  620. OUTPLL(PIXCLKS_CNTL, rinfo->save_regs[6]);
  621. OUTPLL(MCLK_MISC, rinfo->save_regs[7]);
  622. if (rinfo->family == CHIP_FAMILY_RV350)
  623. OUTPLL(SCLK_MORE_CNTL, rinfo->save_regs[34]);
  624. OUTREG(SURFACE_CNTL, rinfo->save_regs[29]);
  625. OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]);
  626. OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]);
  627. OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]);
  628. OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
  629. OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
  630. OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]);
  631. OUTREG(DISP_PWR_MAN, rinfo->save_regs[10]);
  632. OUTREG(LVDS_GEN_CNTL, rinfo->save_regs[11]);
  633. OUTREG(LVDS_PLL_CNTL,rinfo->save_regs[12]);
  634. OUTREG(TV_DAC_CNTL, rinfo->save_regs[13]);
  635. OUTREG(BUS_CNTL1, rinfo->save_regs[14]);
  636. OUTREG(CRTC_OFFSET_CNTL, rinfo->save_regs[15]);
  637. OUTREG(AGP_CNTL, rinfo->save_regs[16]);
  638. OUTREG(CRTC_GEN_CNTL, rinfo->save_regs[17]);
  639. OUTREG(CRTC2_GEN_CNTL, rinfo->save_regs[18]);
  640. OUTPLL(P2PLL_CNTL, rinfo->save_regs[8]);
  641. OUTREG(GPIOPAD_A, rinfo->save_regs[19]);
  642. OUTREG(GPIOPAD_EN, rinfo->save_regs[20]);
  643. OUTREG(GPIOPAD_MASK, rinfo->save_regs[21]);
  644. OUTREG(ZV_LCDPAD_A, rinfo->save_regs[22]);
  645. OUTREG(ZV_LCDPAD_EN, rinfo->save_regs[23]);
  646. OUTREG(ZV_LCDPAD_MASK, rinfo->save_regs[24]);
  647. OUTREG(GPIO_VGA_DDC, rinfo->save_regs[25]);
  648. OUTREG(GPIO_DVI_DDC, rinfo->save_regs[26]);
  649. OUTREG(GPIO_MONID, rinfo->save_regs[27]);
  650. OUTREG(GPIO_CRT2_DDC, rinfo->save_regs[28]);
  651. }
  652. static void radeon_pm_disable_iopad(struct radeonfb_info *rinfo)
  653. {
  654. OUTREG(GPIOPAD_MASK, 0x0001ffff);
  655. OUTREG(GPIOPAD_EN, 0x00000400);
  656. OUTREG(GPIOPAD_A, 0x00000000);
  657. OUTREG(ZV_LCDPAD_MASK, 0x00000000);
  658. OUTREG(ZV_LCDPAD_EN, 0x00000000);
  659. OUTREG(ZV_LCDPAD_A, 0x00000000);
  660. OUTREG(GPIO_VGA_DDC, 0x00030000);
  661. OUTREG(GPIO_DVI_DDC, 0x00000000);
  662. OUTREG(GPIO_MONID, 0x00030000);
  663. OUTREG(GPIO_CRT2_DDC, 0x00000000);
  664. }
  665. static void radeon_pm_program_v2clk(struct radeonfb_info *rinfo)
  666. {
  667. /* Set v2clk to 65MHz */
  668. if (rinfo->family <= CHIP_FAMILY_RV280) {
  669. OUTPLL(pllPIXCLKS_CNTL,
  670. __INPLL(rinfo, pllPIXCLKS_CNTL)
  671. & ~PIXCLKS_CNTL__PIX2CLK_SRC_SEL_MASK);
  672. OUTPLL(pllP2PLL_REF_DIV, 0x0000000c);
  673. OUTPLL(pllP2PLL_CNTL, 0x0000bf00);
  674. } else {
  675. OUTPLL(pllP2PLL_REF_DIV, 0x0000000c);
  676. INPLL(pllP2PLL_REF_DIV);
  677. OUTPLL(pllP2PLL_CNTL, 0x0000a700);
  678. }
  679. OUTPLL(pllP2PLL_DIV_0, 0x00020074 | P2PLL_DIV_0__P2PLL_ATOMIC_UPDATE_W);
  680. OUTPLL(pllP2PLL_CNTL, INPLL(pllP2PLL_CNTL) & ~P2PLL_CNTL__P2PLL_SLEEP);
  681. mdelay(1);
  682. OUTPLL(pllP2PLL_CNTL, INPLL(pllP2PLL_CNTL) & ~P2PLL_CNTL__P2PLL_RESET);
  683. mdelay( 1);
  684. OUTPLL(pllPIXCLKS_CNTL,
  685. (INPLL(pllPIXCLKS_CNTL) & ~PIXCLKS_CNTL__PIX2CLK_SRC_SEL_MASK)
  686. | (0x03 << PIXCLKS_CNTL__PIX2CLK_SRC_SEL__SHIFT));
  687. mdelay( 1);
  688. }
  689. static void radeon_pm_low_current(struct radeonfb_info *rinfo)
  690. {
  691. u32 reg;
  692. reg = INREG(BUS_CNTL1);
  693. if (rinfo->family <= CHIP_FAMILY_RV280) {
  694. reg &= ~BUS_CNTL1_MOBILE_PLATFORM_SEL_MASK;
  695. reg |= BUS_CNTL1_AGPCLK_VALID | (1<<BUS_CNTL1_MOBILE_PLATFORM_SEL_SHIFT);
  696. } else {
  697. reg |= 0x4080;
  698. }
  699. OUTREG(BUS_CNTL1, reg);
  700. reg = INPLL(PLL_PWRMGT_CNTL);
  701. reg |= PLL_PWRMGT_CNTL_SPLL_TURNOFF | PLL_PWRMGT_CNTL_PPLL_TURNOFF |
  702. PLL_PWRMGT_CNTL_P2PLL_TURNOFF | PLL_PWRMGT_CNTL_TVPLL_TURNOFF;
  703. reg &= ~PLL_PWRMGT_CNTL_SU_MCLK_USE_BCLK;
  704. reg &= ~PLL_PWRMGT_CNTL_MOBILE_SU;
  705. OUTPLL(PLL_PWRMGT_CNTL, reg);
  706. reg = INREG(TV_DAC_CNTL);
  707. reg &= ~(TV_DAC_CNTL_BGADJ_MASK |TV_DAC_CNTL_DACADJ_MASK);
  708. reg |=TV_DAC_CNTL_BGSLEEP | TV_DAC_CNTL_RDACPD | TV_DAC_CNTL_GDACPD |
  709. TV_DAC_CNTL_BDACPD |
  710. (8<<TV_DAC_CNTL_BGADJ__SHIFT) | (8<<TV_DAC_CNTL_DACADJ__SHIFT);
  711. OUTREG(TV_DAC_CNTL, reg);
  712. reg = INREG(TMDS_TRANSMITTER_CNTL);
  713. reg &= ~(TMDS_PLL_EN | TMDS_PLLRST);
  714. OUTREG(TMDS_TRANSMITTER_CNTL, reg);
  715. reg = INREG(DAC_CNTL);
  716. reg &= ~DAC_CMP_EN;
  717. OUTREG(DAC_CNTL, reg);
  718. reg = INREG(DAC_CNTL2);
  719. reg &= ~DAC2_CMP_EN;
  720. OUTREG(DAC_CNTL2, reg);
  721. reg = INREG(TV_DAC_CNTL);
  722. reg &= ~TV_DAC_CNTL_DETECT;
  723. OUTREG(TV_DAC_CNTL, reg);
  724. }
  725. static void radeon_pm_setup_for_suspend(struct radeonfb_info *rinfo)
  726. {
  727. u32 sclk_cntl, mclk_cntl, sclk_more_cntl;
  728. u32 pll_pwrmgt_cntl;
  729. u32 clk_pwrmgt_cntl;
  730. u32 clk_pin_cntl;
  731. u32 vclk_ecp_cntl;
  732. u32 pixclks_cntl;
  733. u32 disp_mis_cntl;
  734. u32 disp_pwr_man;
  735. u32 tmp;
  736. /* Force Core Clocks */
  737. sclk_cntl = INPLL( pllSCLK_CNTL);
  738. sclk_cntl |= SCLK_CNTL__IDCT_MAX_DYN_STOP_LAT|
  739. SCLK_CNTL__VIP_MAX_DYN_STOP_LAT|
  740. SCLK_CNTL__RE_MAX_DYN_STOP_LAT|
  741. SCLK_CNTL__PB_MAX_DYN_STOP_LAT|
  742. SCLK_CNTL__TAM_MAX_DYN_STOP_LAT|
  743. SCLK_CNTL__TDM_MAX_DYN_STOP_LAT|
  744. SCLK_CNTL__RB_MAX_DYN_STOP_LAT|
  745. SCLK_CNTL__FORCE_DISP2|
  746. SCLK_CNTL__FORCE_CP|
  747. SCLK_CNTL__FORCE_HDP|
  748. SCLK_CNTL__FORCE_DISP1|
  749. SCLK_CNTL__FORCE_TOP|
  750. SCLK_CNTL__FORCE_E2|
  751. SCLK_CNTL__FORCE_SE|
  752. SCLK_CNTL__FORCE_IDCT|
  753. SCLK_CNTL__FORCE_VIP|
  754. SCLK_CNTL__FORCE_PB|
  755. SCLK_CNTL__FORCE_TAM|
  756. SCLK_CNTL__FORCE_TDM|
  757. SCLK_CNTL__FORCE_RB|
  758. SCLK_CNTL__FORCE_TV_SCLK|
  759. SCLK_CNTL__FORCE_SUBPIC|
  760. SCLK_CNTL__FORCE_OV0;
  761. if (rinfo->family <= CHIP_FAMILY_RV280)
  762. sclk_cntl |= SCLK_CNTL__FORCE_RE;
  763. else
  764. sclk_cntl |= SCLK_CNTL__SE_MAX_DYN_STOP_LAT |
  765. SCLK_CNTL__E2_MAX_DYN_STOP_LAT |
  766. SCLK_CNTL__TV_MAX_DYN_STOP_LAT |
  767. SCLK_CNTL__HDP_MAX_DYN_STOP_LAT |
  768. SCLK_CNTL__CP_MAX_DYN_STOP_LAT;
  769. OUTPLL( pllSCLK_CNTL, sclk_cntl);
  770. sclk_more_cntl = INPLL(pllSCLK_MORE_CNTL);
  771. sclk_more_cntl |= SCLK_MORE_CNTL__FORCE_DISPREGS |
  772. SCLK_MORE_CNTL__FORCE_MC_GUI |
  773. SCLK_MORE_CNTL__FORCE_MC_HOST;
  774. OUTPLL(pllSCLK_MORE_CNTL, sclk_more_cntl);
  775. mclk_cntl = INPLL( pllMCLK_CNTL);
  776. mclk_cntl &= ~( MCLK_CNTL__FORCE_MCLKA |
  777. MCLK_CNTL__FORCE_MCLKB |
  778. MCLK_CNTL__FORCE_YCLKA |
  779. MCLK_CNTL__FORCE_YCLKB |
  780. MCLK_CNTL__FORCE_MC
  781. );
  782. OUTPLL( pllMCLK_CNTL, mclk_cntl);
  783. /* Force Display clocks */
  784. vclk_ecp_cntl = INPLL( pllVCLK_ECP_CNTL);
  785. vclk_ecp_cntl &= ~(VCLK_ECP_CNTL__PIXCLK_ALWAYS_ONb
  786. | VCLK_ECP_CNTL__PIXCLK_DAC_ALWAYS_ONb);
  787. vclk_ecp_cntl |= VCLK_ECP_CNTL__ECP_FORCE_ON;
  788. OUTPLL( pllVCLK_ECP_CNTL, vclk_ecp_cntl);
  789. pixclks_cntl = INPLL( pllPIXCLKS_CNTL);
  790. pixclks_cntl &= ~( PIXCLKS_CNTL__PIXCLK_GV_ALWAYS_ONb |
  791. PIXCLKS_CNTL__PIXCLK_BLEND_ALWAYS_ONb|
  792. PIXCLKS_CNTL__PIXCLK_DIG_TMDS_ALWAYS_ONb |
  793. PIXCLKS_CNTL__PIXCLK_LVDS_ALWAYS_ONb|
  794. PIXCLKS_CNTL__PIXCLK_TMDS_ALWAYS_ONb|
  795. PIXCLKS_CNTL__PIX2CLK_ALWAYS_ONb|
  796. PIXCLKS_CNTL__PIX2CLK_DAC_ALWAYS_ONb);
  797. OUTPLL( pllPIXCLKS_CNTL, pixclks_cntl);
  798. /* Switch off LVDS interface */
  799. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) &
  800. ~(LVDS_BLON | LVDS_EN | LVDS_ON | LVDS_DIGON));
  801. /* Enable System power management */
  802. pll_pwrmgt_cntl = INPLL( pllPLL_PWRMGT_CNTL);
  803. pll_pwrmgt_cntl |= PLL_PWRMGT_CNTL__SPLL_TURNOFF |
  804. PLL_PWRMGT_CNTL__MPLL_TURNOFF|
  805. PLL_PWRMGT_CNTL__PPLL_TURNOFF|
  806. PLL_PWRMGT_CNTL__P2PLL_TURNOFF|
  807. PLL_PWRMGT_CNTL__TVPLL_TURNOFF;
  808. OUTPLL( pllPLL_PWRMGT_CNTL, pll_pwrmgt_cntl);
  809. clk_pwrmgt_cntl = INPLL( pllCLK_PWRMGT_CNTL);
  810. clk_pwrmgt_cntl &= ~( CLK_PWRMGT_CNTL__MPLL_PWRMGT_OFF|
  811. CLK_PWRMGT_CNTL__SPLL_PWRMGT_OFF|
  812. CLK_PWRMGT_CNTL__PPLL_PWRMGT_OFF|
  813. CLK_PWRMGT_CNTL__P2PLL_PWRMGT_OFF|
  814. CLK_PWRMGT_CNTL__MCLK_TURNOFF|
  815. CLK_PWRMGT_CNTL__SCLK_TURNOFF|
  816. CLK_PWRMGT_CNTL__PCLK_TURNOFF|
  817. CLK_PWRMGT_CNTL__P2CLK_TURNOFF|
  818. CLK_PWRMGT_CNTL__TVPLL_PWRMGT_OFF|
  819. CLK_PWRMGT_CNTL__GLOBAL_PMAN_EN|
  820. CLK_PWRMGT_CNTL__ENGINE_DYNCLK_MODE|
  821. CLK_PWRMGT_CNTL__ACTIVE_HILO_LAT_MASK|
  822. CLK_PWRMGT_CNTL__CG_NO1_DEBUG_MASK
  823. );
  824. clk_pwrmgt_cntl |= CLK_PWRMGT_CNTL__GLOBAL_PMAN_EN
  825. | CLK_PWRMGT_CNTL__DISP_PM;
  826. OUTPLL( pllCLK_PWRMGT_CNTL, clk_pwrmgt_cntl);
  827. clk_pin_cntl = INPLL( pllCLK_PIN_CNTL);
  828. clk_pin_cntl &= ~CLK_PIN_CNTL__ACCESS_REGS_IN_SUSPEND;
  829. /* because both INPLL and OUTPLL take the same lock, that's why. */
  830. tmp = INPLL( pllMCLK_MISC) | MCLK_MISC__EN_MCLK_TRISTATE_IN_SUSPEND;
  831. OUTPLL( pllMCLK_MISC, tmp);
  832. /* BUS_CNTL1__MOBILE_PLATORM_SEL setting is northbridge chipset
  833. * and radeon chip dependent. Thus we only enable it on Mac for
  834. * now (until we get more info on how to compute the correct
  835. * value for various X86 bridges).
  836. */
  837. #ifdef CONFIG_PPC_PMAC
  838. if (machine_is(powermac)) {
  839. /* AGP PLL control */
  840. if (rinfo->family <= CHIP_FAMILY_RV280) {
  841. OUTREG(BUS_CNTL1, INREG(BUS_CNTL1) | BUS_CNTL1__AGPCLK_VALID);
  842. OUTREG(BUS_CNTL1,
  843. (INREG(BUS_CNTL1) & ~BUS_CNTL1__MOBILE_PLATFORM_SEL_MASK)
  844. | (2<<BUS_CNTL1__MOBILE_PLATFORM_SEL__SHIFT)); // 440BX
  845. } else {
  846. OUTREG(BUS_CNTL1, INREG(BUS_CNTL1));
  847. OUTREG(BUS_CNTL1, (INREG(BUS_CNTL1) & ~0x4000) | 0x8000);
  848. }
  849. }
  850. #endif
  851. OUTREG(CRTC_OFFSET_CNTL, (INREG(CRTC_OFFSET_CNTL)
  852. & ~CRTC_OFFSET_CNTL__CRTC_STEREO_SYNC_OUT_EN));
  853. clk_pin_cntl &= ~CLK_PIN_CNTL__CG_CLK_TO_OUTPIN;
  854. clk_pin_cntl |= CLK_PIN_CNTL__XTALIN_ALWAYS_ONb;
  855. OUTPLL( pllCLK_PIN_CNTL, clk_pin_cntl);
  856. /* Solano2M */
  857. OUTREG(AGP_CNTL,
  858. (INREG(AGP_CNTL) & ~(AGP_CNTL__MAX_IDLE_CLK_MASK))
  859. | (0x20<<AGP_CNTL__MAX_IDLE_CLK__SHIFT));
  860. /* ACPI mode */
  861. /* because both INPLL and OUTPLL take the same lock, that's why. */
  862. tmp = INPLL( pllPLL_PWRMGT_CNTL) & ~PLL_PWRMGT_CNTL__PM_MODE_SEL;
  863. OUTPLL( pllPLL_PWRMGT_CNTL, tmp);
  864. disp_mis_cntl = INREG(DISP_MISC_CNTL);
  865. disp_mis_cntl &= ~( DISP_MISC_CNTL__SOFT_RESET_GRPH_PP |
  866. DISP_MISC_CNTL__SOFT_RESET_SUBPIC_PP |
  867. DISP_MISC_CNTL__SOFT_RESET_OV0_PP |
  868. DISP_MISC_CNTL__SOFT_RESET_GRPH_SCLK|
  869. DISP_MISC_CNTL__SOFT_RESET_SUBPIC_SCLK|
  870. DISP_MISC_CNTL__SOFT_RESET_OV0_SCLK|
  871. DISP_MISC_CNTL__SOFT_RESET_GRPH2_PP|
  872. DISP_MISC_CNTL__SOFT_RESET_GRPH2_SCLK|
  873. DISP_MISC_CNTL__SOFT_RESET_LVDS|
  874. DISP_MISC_CNTL__SOFT_RESET_TMDS|
  875. DISP_MISC_CNTL__SOFT_RESET_DIG_TMDS|
  876. DISP_MISC_CNTL__SOFT_RESET_TV);
  877. OUTREG(DISP_MISC_CNTL, disp_mis_cntl);
  878. disp_pwr_man = INREG(DISP_PWR_MAN);
  879. disp_pwr_man &= ~( DISP_PWR_MAN__DISP_PWR_MAN_D3_CRTC_EN |
  880. DISP_PWR_MAN__DISP2_PWR_MAN_D3_CRTC2_EN |
  881. DISP_PWR_MAN__DISP_PWR_MAN_DPMS_MASK|
  882. DISP_PWR_MAN__DISP_D3_RST|
  883. DISP_PWR_MAN__DISP_D3_REG_RST
  884. );
  885. disp_pwr_man |= DISP_PWR_MAN__DISP_D3_GRPH_RST|
  886. DISP_PWR_MAN__DISP_D3_SUBPIC_RST|
  887. DISP_PWR_MAN__DISP_D3_OV0_RST|
  888. DISP_PWR_MAN__DISP_D1D2_GRPH_RST|
  889. DISP_PWR_MAN__DISP_D1D2_SUBPIC_RST|
  890. DISP_PWR_MAN__DISP_D1D2_OV0_RST|
  891. DISP_PWR_MAN__DIG_TMDS_ENABLE_RST|
  892. DISP_PWR_MAN__TV_ENABLE_RST|
  893. // DISP_PWR_MAN__AUTO_PWRUP_EN|
  894. 0;
  895. OUTREG(DISP_PWR_MAN, disp_pwr_man);
  896. clk_pwrmgt_cntl = INPLL( pllCLK_PWRMGT_CNTL);
  897. pll_pwrmgt_cntl = INPLL( pllPLL_PWRMGT_CNTL) ;
  898. clk_pin_cntl = INPLL( pllCLK_PIN_CNTL);
  899. disp_pwr_man = INREG(DISP_PWR_MAN);
  900. /* D2 */
  901. clk_pwrmgt_cntl |= CLK_PWRMGT_CNTL__DISP_PM;
  902. pll_pwrmgt_cntl |= PLL_PWRMGT_CNTL__MOBILE_SU | PLL_PWRMGT_CNTL__SU_SCLK_USE_BCLK;
  903. clk_pin_cntl |= CLK_PIN_CNTL__XTALIN_ALWAYS_ONb;
  904. disp_pwr_man &= ~(DISP_PWR_MAN__DISP_PWR_MAN_D3_CRTC_EN_MASK
  905. | DISP_PWR_MAN__DISP2_PWR_MAN_D3_CRTC2_EN_MASK);
  906. OUTPLL( pllCLK_PWRMGT_CNTL, clk_pwrmgt_cntl);
  907. OUTPLL( pllPLL_PWRMGT_CNTL, pll_pwrmgt_cntl);
  908. OUTPLL( pllCLK_PIN_CNTL, clk_pin_cntl);
  909. OUTREG(DISP_PWR_MAN, disp_pwr_man);
  910. /* disable display request & disable display */
  911. OUTREG( CRTC_GEN_CNTL, (INREG( CRTC_GEN_CNTL) & ~CRTC_GEN_CNTL__CRTC_EN)
  912. | CRTC_GEN_CNTL__CRTC_DISP_REQ_EN_B);
  913. OUTREG( CRTC2_GEN_CNTL, (INREG( CRTC2_GEN_CNTL) & ~CRTC2_GEN_CNTL__CRTC2_EN)
  914. | CRTC2_GEN_CNTL__CRTC2_DISP_REQ_EN_B);
  915. mdelay(17);
  916. }
  917. static void radeon_pm_yclk_mclk_sync(struct radeonfb_info *rinfo)
  918. {
  919. u32 mc_chp_io_cntl_a1, mc_chp_io_cntl_b1;
  920. mc_chp_io_cntl_a1 = INMC( rinfo, ixMC_CHP_IO_CNTL_A1)
  921. & ~MC_CHP_IO_CNTL_A1__MEM_SYNC_ENA_MASK;
  922. mc_chp_io_cntl_b1 = INMC( rinfo, ixMC_CHP_IO_CNTL_B1)
  923. & ~MC_CHP_IO_CNTL_B1__MEM_SYNC_ENB_MASK;
  924. OUTMC( rinfo, ixMC_CHP_IO_CNTL_A1, mc_chp_io_cntl_a1
  925. | (1<<MC_CHP_IO_CNTL_A1__MEM_SYNC_ENA__SHIFT));
  926. OUTMC( rinfo, ixMC_CHP_IO_CNTL_B1, mc_chp_io_cntl_b1
  927. | (1<<MC_CHP_IO_CNTL_B1__MEM_SYNC_ENB__SHIFT));
  928. OUTMC( rinfo, ixMC_CHP_IO_CNTL_A1, mc_chp_io_cntl_a1);
  929. OUTMC( rinfo, ixMC_CHP_IO_CNTL_B1, mc_chp_io_cntl_b1);
  930. mdelay( 1);
  931. }
  932. static void radeon_pm_yclk_mclk_sync_m10(struct radeonfb_info *rinfo)
  933. {
  934. u32 mc_chp_io_cntl_a1, mc_chp_io_cntl_b1;
  935. mc_chp_io_cntl_a1 = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_A1)
  936. & ~MC_CHP_IO_CNTL_A1__MEM_SYNC_ENA_MASK;
  937. mc_chp_io_cntl_b1 = INMC(rinfo, ixR300_MC_CHP_IO_CNTL_B1)
  938. & ~MC_CHP_IO_CNTL_B1__MEM_SYNC_ENB_MASK;
  939. OUTMC( rinfo, ixR300_MC_CHP_IO_CNTL_A1,
  940. mc_chp_io_cntl_a1 | (1<<MC_CHP_IO_CNTL_A1__MEM_SYNC_ENA__SHIFT));
  941. OUTMC( rinfo, ixR300_MC_CHP_IO_CNTL_B1,
  942. mc_chp_io_cntl_b1 | (1<<MC_CHP_IO_CNTL_B1__MEM_SYNC_ENB__SHIFT));
  943. OUTMC( rinfo, ixR300_MC_CHP_IO_CNTL_A1, mc_chp_io_cntl_a1);
  944. OUTMC( rinfo, ixR300_MC_CHP_IO_CNTL_B1, mc_chp_io_cntl_b1);
  945. mdelay( 1);
  946. }
  947. static void radeon_pm_program_mode_reg(struct radeonfb_info *rinfo, u16 value,
  948. u8 delay_required)
  949. {
  950. u32 mem_sdram_mode;
  951. mem_sdram_mode = INREG( MEM_SDRAM_MODE_REG);
  952. mem_sdram_mode &= ~MEM_SDRAM_MODE_REG__MEM_MODE_REG_MASK;
  953. mem_sdram_mode |= (value<<MEM_SDRAM_MODE_REG__MEM_MODE_REG__SHIFT)
  954. | MEM_SDRAM_MODE_REG__MEM_CFG_TYPE;
  955. OUTREG( MEM_SDRAM_MODE_REG, mem_sdram_mode);
  956. if (delay_required >= 2)
  957. mdelay(1);
  958. mem_sdram_mode |= MEM_SDRAM_MODE_REG__MEM_SDRAM_RESET;
  959. OUTREG( MEM_SDRAM_MODE_REG, mem_sdram_mode);
  960. if (delay_required >= 2)
  961. mdelay(1);
  962. mem_sdram_mode &= ~MEM_SDRAM_MODE_REG__MEM_SDRAM_RESET;
  963. OUTREG( MEM_SDRAM_MODE_REG, mem_sdram_mode);
  964. if (delay_required >= 2)
  965. mdelay(1);
  966. if (delay_required) {
  967. do {
  968. if (delay_required >= 2)
  969. mdelay(1);
  970. } while ((INREG(MC_STATUS)
  971. & (MC_STATUS__MEM_PWRUP_COMPL_A |
  972. MC_STATUS__MEM_PWRUP_COMPL_B)) == 0);
  973. }
  974. }
  975. static void radeon_pm_m10_program_mode_wait(struct radeonfb_info *rinfo)
  976. {
  977. int cnt;
  978. for (cnt = 0; cnt < 100; ++cnt) {
  979. mdelay(1);
  980. if (INREG(MC_STATUS) & (MC_STATUS__MEM_PWRUP_COMPL_A
  981. | MC_STATUS__MEM_PWRUP_COMPL_B))
  982. break;
  983. }
  984. }
  985. static void radeon_pm_enable_dll(struct radeonfb_info *rinfo)
  986. {
  987. #define DLL_RESET_DELAY 5
  988. #define DLL_SLEEP_DELAY 1
  989. u32 cko = INPLL(pllMDLL_CKO) | MDLL_CKO__MCKOA_SLEEP
  990. | MDLL_CKO__MCKOA_RESET;
  991. u32 cka = INPLL(pllMDLL_RDCKA) | MDLL_RDCKA__MRDCKA0_SLEEP
  992. | MDLL_RDCKA__MRDCKA1_SLEEP | MDLL_RDCKA__MRDCKA0_RESET
  993. | MDLL_RDCKA__MRDCKA1_RESET;
  994. u32 ckb = INPLL(pllMDLL_RDCKB) | MDLL_RDCKB__MRDCKB0_SLEEP
  995. | MDLL_RDCKB__MRDCKB1_SLEEP | MDLL_RDCKB__MRDCKB0_RESET
  996. | MDLL_RDCKB__MRDCKB1_RESET;
  997. /* Setting up the DLL range for write */
  998. OUTPLL(pllMDLL_CKO, cko);
  999. OUTPLL(pllMDLL_RDCKA, cka);
  1000. OUTPLL(pllMDLL_RDCKB, ckb);
  1001. mdelay(DLL_RESET_DELAY*2);
  1002. cko &= ~(MDLL_CKO__MCKOA_SLEEP | MDLL_CKO__MCKOB_SLEEP);
  1003. OUTPLL(pllMDLL_CKO, cko);
  1004. mdelay(DLL_SLEEP_DELAY);
  1005. cko &= ~(MDLL_CKO__MCKOA_RESET | MDLL_CKO__MCKOB_RESET);
  1006. OUTPLL(pllMDLL_CKO, cko);
  1007. mdelay(DLL_RESET_DELAY);
  1008. cka &= ~(MDLL_RDCKA__MRDCKA0_SLEEP | MDLL_RDCKA__MRDCKA1_SLEEP);
  1009. OUTPLL(pllMDLL_RDCKA, cka);
  1010. mdelay(DLL_SLEEP_DELAY);
  1011. cka &= ~(MDLL_RDCKA__MRDCKA0_RESET | MDLL_RDCKA__MRDCKA1_RESET);
  1012. OUTPLL(pllMDLL_RDCKA, cka);
  1013. mdelay(DLL_RESET_DELAY);
  1014. ckb &= ~(MDLL_RDCKB__MRDCKB0_SLEEP | MDLL_RDCKB__MRDCKB1_SLEEP);
  1015. OUTPLL(pllMDLL_RDCKB, ckb);
  1016. mdelay(DLL_SLEEP_DELAY);
  1017. ckb &= ~(MDLL_RDCKB__MRDCKB0_RESET | MDLL_RDCKB__MRDCKB1_RESET);
  1018. OUTPLL(pllMDLL_RDCKB, ckb);
  1019. mdelay(DLL_RESET_DELAY);
  1020. #undef DLL_RESET_DELAY
  1021. #undef DLL_SLEEP_DELAY
  1022. }
  1023. static void radeon_pm_enable_dll_m10(struct radeonfb_info *rinfo)
  1024. {
  1025. u32 dll_value;
  1026. u32 dll_sleep_mask = 0;
  1027. u32 dll_reset_mask = 0;
  1028. u32 mc;
  1029. #define DLL_RESET_DELAY 5
  1030. #define DLL_SLEEP_DELAY 1
  1031. OUTMC(rinfo, ixR300_MC_DLL_CNTL, rinfo->save_regs[70]);
  1032. mc = INREG(MC_CNTL);
  1033. /* Check which channels are enabled */
  1034. switch (mc & 0x3) {
  1035. case 1:
  1036. if (mc & 0x4)
  1037. break;
  1038. case 2:
  1039. dll_sleep_mask |= MDLL_R300_RDCK__MRDCKB_SLEEP;
  1040. dll_reset_mask |= MDLL_R300_RDCK__MRDCKB_RESET;
  1041. case 0:
  1042. dll_sleep_mask |= MDLL_R300_RDCK__MRDCKA_SLEEP;
  1043. dll_reset_mask |= MDLL_R300_RDCK__MRDCKA_RESET;
  1044. }
  1045. switch (mc & 0x3) {
  1046. case 1:
  1047. if (!(mc & 0x4))
  1048. break;
  1049. case 2:
  1050. dll_sleep_mask |= MDLL_R300_RDCK__MRDCKD_SLEEP;
  1051. dll_reset_mask |= MDLL_R300_RDCK__MRDCKD_RESET;
  1052. dll_sleep_mask |= MDLL_R300_RDCK__MRDCKC_SLEEP;
  1053. dll_reset_mask |= MDLL_R300_RDCK__MRDCKC_RESET;
  1054. }
  1055. dll_value = INPLL(pllMDLL_RDCKA);
  1056. /* Power Up */
  1057. dll_value &= ~(dll_sleep_mask);
  1058. OUTPLL(pllMDLL_RDCKA, dll_value);
  1059. mdelay( DLL_SLEEP_DELAY);
  1060. dll_value &= ~(dll_reset_mask);
  1061. OUTPLL(pllMDLL_RDCKA, dll_value);
  1062. mdelay( DLL_RESET_DELAY);
  1063. #undef DLL_RESET_DELAY
  1064. #undef DLL_SLEEP_DELAY
  1065. }
  1066. static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
  1067. {
  1068. u32 crtcGenCntl, crtcGenCntl2, memRefreshCntl, crtc_more_cntl,
  1069. fp_gen_cntl, fp2_gen_cntl;
  1070. crtcGenCntl = INREG( CRTC_GEN_CNTL);
  1071. crtcGenCntl2 = INREG( CRTC2_GEN_CNTL);
  1072. crtc_more_cntl = INREG( CRTC_MORE_CNTL);
  1073. fp_gen_cntl = INREG( FP_GEN_CNTL);
  1074. fp2_gen_cntl = INREG( FP2_GEN_CNTL);
  1075. OUTREG( CRTC_MORE_CNTL, 0);
  1076. OUTREG( FP_GEN_CNTL, 0);
  1077. OUTREG( FP2_GEN_CNTL,0);
  1078. OUTREG( CRTC_GEN_CNTL, (crtcGenCntl | CRTC_GEN_CNTL__CRTC_DISP_REQ_EN_B) );
  1079. OUTREG( CRTC2_GEN_CNTL, (crtcGenCntl2 | CRTC2_GEN_CNTL__CRTC2_DISP_REQ_EN_B) );
  1080. /* This is the code for the Aluminium PowerBooks M10 / iBooks M11 */
  1081. if (rinfo->family == CHIP_FAMILY_RV350) {
  1082. u32 sdram_mode_reg = rinfo->save_regs[35];
  1083. static const u32 default_mrtable[] =
  1084. { 0x21320032,
  1085. 0x21321000, 0xa1321000, 0x21321000, 0xffffffff,
  1086. 0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
  1087. 0x21321002, 0xa1321002, 0x21321002, 0xffffffff,
  1088. 0x21320132, 0xa1320132, 0x21320132, 0xffffffff,
  1089. 0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
  1090. 0x31320032 };
  1091. const u32 *mrtable = default_mrtable;
  1092. int i, mrtable_size = ARRAY_SIZE(default_mrtable);
  1093. mdelay(30);
  1094. /* Disable refresh */
  1095. memRefreshCntl = INREG( MEM_REFRESH_CNTL)
  1096. & ~MEM_REFRESH_CNTL__MEM_REFRESH_DIS;
  1097. OUTREG( MEM_REFRESH_CNTL, memRefreshCntl
  1098. | MEM_REFRESH_CNTL__MEM_REFRESH_DIS);
  1099. /* Configure and enable M & SPLLs */
  1100. radeon_pm_enable_dll_m10(rinfo);
  1101. radeon_pm_yclk_mclk_sync_m10(rinfo);
  1102. #ifdef CONFIG_PPC
  1103. if (rinfo->of_node != NULL) {
  1104. int size;
  1105. mrtable = of_get_property(rinfo->of_node, "ATY,MRT", &size);
  1106. if (mrtable)
  1107. mrtable_size = size >> 2;
  1108. else
  1109. mrtable = default_mrtable;
  1110. }
  1111. #endif /* CONFIG_PPC */
  1112. /* Program the SDRAM */
  1113. sdram_mode_reg = mrtable[0];
  1114. OUTREG(MEM_SDRAM_MODE_REG, sdram_mode_reg);
  1115. for (i = 0; i < mrtable_size; i++) {
  1116. if (mrtable[i] == 0xffffffffu)
  1117. radeon_pm_m10_program_mode_wait(rinfo);
  1118. else {
  1119. sdram_mode_reg &= ~(MEM_SDRAM_MODE_REG__MEM_MODE_REG_MASK
  1120. | MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE
  1121. | MEM_SDRAM_MODE_REG__MEM_SDRAM_RESET);
  1122. sdram_mode_reg |= mrtable[i];
  1123. OUTREG(MEM_SDRAM_MODE_REG, sdram_mode_reg);
  1124. mdelay(1);
  1125. }
  1126. }
  1127. /* Restore memory refresh */
  1128. OUTREG(MEM_REFRESH_CNTL, memRefreshCntl);
  1129. mdelay(30);
  1130. }
  1131. /* Here come the desktop RV200 "QW" card */
  1132. else if (!rinfo->is_mobility && rinfo->family == CHIP_FAMILY_RV200) {
  1133. /* Disable refresh */
  1134. memRefreshCntl = INREG( MEM_REFRESH_CNTL)
  1135. & ~MEM_REFRESH_CNTL__MEM_REFRESH_DIS;
  1136. OUTREG(MEM_REFRESH_CNTL, memRefreshCntl
  1137. | MEM_REFRESH_CNTL__MEM_REFRESH_DIS);
  1138. mdelay(30);
  1139. /* Reset memory */
  1140. OUTREG(MEM_SDRAM_MODE_REG,
  1141. INREG( MEM_SDRAM_MODE_REG) & ~MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1142. radeon_pm_program_mode_reg(rinfo, 0x2002, 2);
  1143. radeon_pm_program_mode_reg(rinfo, 0x0132, 2);
  1144. radeon_pm_program_mode_reg(rinfo, 0x0032, 2);
  1145. OUTREG(MEM_SDRAM_MODE_REG,
  1146. INREG(MEM_SDRAM_MODE_REG) | MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1147. OUTREG( MEM_REFRESH_CNTL, memRefreshCntl);
  1148. }
  1149. /* The M6 */
  1150. else if (rinfo->is_mobility && rinfo->family == CHIP_FAMILY_RV100) {
  1151. /* Disable refresh */
  1152. memRefreshCntl = INREG(EXT_MEM_CNTL) & ~(1 << 20);
  1153. OUTREG( EXT_MEM_CNTL, memRefreshCntl | (1 << 20));
  1154. /* Reset memory */
  1155. OUTREG( MEM_SDRAM_MODE_REG,
  1156. INREG( MEM_SDRAM_MODE_REG)
  1157. & ~MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1158. /* DLL */
  1159. radeon_pm_enable_dll(rinfo);
  1160. /* MLCK / YCLK sync */
  1161. radeon_pm_yclk_mclk_sync(rinfo);
  1162. /* Program Mode Register */
  1163. radeon_pm_program_mode_reg(rinfo, 0x2000, 1);
  1164. radeon_pm_program_mode_reg(rinfo, 0x2001, 1);
  1165. radeon_pm_program_mode_reg(rinfo, 0x2002, 1);
  1166. radeon_pm_program_mode_reg(rinfo, 0x0132, 1);
  1167. radeon_pm_program_mode_reg(rinfo, 0x0032, 1);
  1168. /* Complete & re-enable refresh */
  1169. OUTREG( MEM_SDRAM_MODE_REG,
  1170. INREG( MEM_SDRAM_MODE_REG) | MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1171. OUTREG(EXT_MEM_CNTL, memRefreshCntl);
  1172. }
  1173. /* And finally, the M7..M9 models, including M9+ (RV280) */
  1174. else if (rinfo->is_mobility) {
  1175. /* Disable refresh */
  1176. memRefreshCntl = INREG( MEM_REFRESH_CNTL)
  1177. & ~MEM_REFRESH_CNTL__MEM_REFRESH_DIS;
  1178. OUTREG( MEM_REFRESH_CNTL, memRefreshCntl
  1179. | MEM_REFRESH_CNTL__MEM_REFRESH_DIS);
  1180. /* Reset memory */
  1181. OUTREG( MEM_SDRAM_MODE_REG,
  1182. INREG( MEM_SDRAM_MODE_REG)
  1183. & ~MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1184. /* DLL */
  1185. radeon_pm_enable_dll(rinfo);
  1186. /* MLCK / YCLK sync */
  1187. radeon_pm_yclk_mclk_sync(rinfo);
  1188. /* M6, M7 and M9 so far ... */
  1189. if (rinfo->family <= CHIP_FAMILY_RV250) {
  1190. radeon_pm_program_mode_reg(rinfo, 0x2000, 1);
  1191. radeon_pm_program_mode_reg(rinfo, 0x2001, 1);
  1192. radeon_pm_program_mode_reg(rinfo, 0x2002, 1);
  1193. radeon_pm_program_mode_reg(rinfo, 0x0132, 1);
  1194. radeon_pm_program_mode_reg(rinfo, 0x0032, 1);
  1195. }
  1196. /* M9+ (iBook G4) */
  1197. else if (rinfo->family == CHIP_FAMILY_RV280) {
  1198. radeon_pm_program_mode_reg(rinfo, 0x2000, 1);
  1199. radeon_pm_program_mode_reg(rinfo, 0x0132, 1);
  1200. radeon_pm_program_mode_reg(rinfo, 0x0032, 1);
  1201. }
  1202. /* Complete & re-enable refresh */
  1203. OUTREG( MEM_SDRAM_MODE_REG,
  1204. INREG( MEM_SDRAM_MODE_REG) | MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1205. OUTREG( MEM_REFRESH_CNTL, memRefreshCntl);
  1206. }
  1207. OUTREG( CRTC_GEN_CNTL, crtcGenCntl);
  1208. OUTREG( CRTC2_GEN_CNTL, crtcGenCntl2);
  1209. OUTREG( FP_GEN_CNTL, fp_gen_cntl);
  1210. OUTREG( FP2_GEN_CNTL, fp2_gen_cntl);
  1211. OUTREG( CRTC_MORE_CNTL, crtc_more_cntl);
  1212. mdelay( 15);
  1213. }
  1214. #if defined(CONFIG_PM)
  1215. #if defined(CONFIG_X86) || defined(CONFIG_PPC_PMAC)
  1216. static void radeon_pm_reset_pad_ctlr_strength(struct radeonfb_info *rinfo)
  1217. {
  1218. u32 tmp, tmp2;
  1219. int i,j;
  1220. /* Reset the PAD_CTLR_STRENGTH & wait for it to be stable */
  1221. INREG(PAD_CTLR_STRENGTH);
  1222. OUTREG(PAD_CTLR_STRENGTH, INREG(PAD_CTLR_STRENGTH) & ~PAD_MANUAL_OVERRIDE);
  1223. tmp = INREG(PAD_CTLR_STRENGTH);
  1224. for (i = j = 0; i < 65; ++i) {
  1225. mdelay(1);
  1226. tmp2 = INREG(PAD_CTLR_STRENGTH);
  1227. if (tmp != tmp2) {
  1228. tmp = tmp2;
  1229. i = 0;
  1230. j++;
  1231. if (j > 10) {
  1232. printk(KERN_WARNING "radeon: PAD_CTLR_STRENGTH doesn't "
  1233. "stabilize !\n");
  1234. break;
  1235. }
  1236. }
  1237. }
  1238. }
  1239. static void radeon_pm_all_ppls_off(struct radeonfb_info *rinfo)
  1240. {
  1241. u32 tmp;
  1242. tmp = INPLL(pllPPLL_CNTL);
  1243. OUTPLL(pllPPLL_CNTL, tmp | 0x3);
  1244. tmp = INPLL(pllP2PLL_CNTL);
  1245. OUTPLL(pllP2PLL_CNTL, tmp | 0x3);
  1246. tmp = INPLL(pllSPLL_CNTL);
  1247. OUTPLL(pllSPLL_CNTL, tmp | 0x3);
  1248. tmp = INPLL(pllMPLL_CNTL);
  1249. OUTPLL(pllMPLL_CNTL, tmp | 0x3);
  1250. }
  1251. static void radeon_pm_start_mclk_sclk(struct radeonfb_info *rinfo)
  1252. {
  1253. u32 tmp;
  1254. /* Switch SPLL to PCI source */
  1255. tmp = INPLL(pllSCLK_CNTL);
  1256. OUTPLL(pllSCLK_CNTL, tmp & ~SCLK_CNTL__SCLK_SRC_SEL_MASK);
  1257. /* Reconfigure SPLL charge pump, VCO gain, duty cycle */
  1258. tmp = INPLL(pllSPLL_CNTL);
  1259. OUTREG8(CLOCK_CNTL_INDEX, pllSPLL_CNTL + PLL_WR_EN);
  1260. radeon_pll_errata_after_index(rinfo);
  1261. OUTREG8(CLOCK_CNTL_DATA + 1, (tmp >> 8) & 0xff);
  1262. radeon_pll_errata_after_data(rinfo);
  1263. /* Set SPLL feedback divider */
  1264. tmp = INPLL(pllM_SPLL_REF_FB_DIV);
  1265. tmp = (tmp & 0xff00fffful) | (rinfo->save_regs[77] & 0x00ff0000ul);
  1266. OUTPLL(pllM_SPLL_REF_FB_DIV, tmp);
  1267. /* Power up SPLL */
  1268. tmp = INPLL(pllSPLL_CNTL);
  1269. OUTPLL(pllSPLL_CNTL, tmp & ~1);
  1270. (void)INPLL(pllSPLL_CNTL);
  1271. mdelay(10);
  1272. /* Release SPLL reset */
  1273. tmp = INPLL(pllSPLL_CNTL);
  1274. OUTPLL(pllSPLL_CNTL, tmp & ~0x2);
  1275. (void)INPLL(pllSPLL_CNTL);
  1276. mdelay(10);
  1277. /* Select SCLK source */
  1278. tmp = INPLL(pllSCLK_CNTL);
  1279. tmp &= ~SCLK_CNTL__SCLK_SRC_SEL_MASK;
  1280. tmp |= rinfo->save_regs[3] & SCLK_CNTL__SCLK_SRC_SEL_MASK;
  1281. OUTPLL(pllSCLK_CNTL, tmp);
  1282. (void)INPLL(pllSCLK_CNTL);
  1283. mdelay(10);
  1284. /* Reconfigure MPLL charge pump, VCO gain, duty cycle */
  1285. tmp = INPLL(pllMPLL_CNTL);
  1286. OUTREG8(CLOCK_CNTL_INDEX, pllMPLL_CNTL + PLL_WR_EN);
  1287. radeon_pll_errata_after_index(rinfo);
  1288. OUTREG8(CLOCK_CNTL_DATA + 1, (tmp >> 8) & 0xff);
  1289. radeon_pll_errata_after_data(rinfo);
  1290. /* Set MPLL feedback divider */
  1291. tmp = INPLL(pllM_SPLL_REF_FB_DIV);
  1292. tmp = (tmp & 0xffff00fful) | (rinfo->save_regs[77] & 0x0000ff00ul);
  1293. OUTPLL(pllM_SPLL_REF_FB_DIV, tmp);
  1294. /* Power up MPLL */
  1295. tmp = INPLL(pllMPLL_CNTL);
  1296. OUTPLL(pllMPLL_CNTL, tmp & ~0x2);
  1297. (void)INPLL(pllMPLL_CNTL);
  1298. mdelay(10);
  1299. /* Un-reset MPLL */
  1300. tmp = INPLL(pllMPLL_CNTL);
  1301. OUTPLL(pllMPLL_CNTL, tmp & ~0x1);
  1302. (void)INPLL(pllMPLL_CNTL);
  1303. mdelay(10);
  1304. /* Select source for MCLK */
  1305. tmp = INPLL(pllMCLK_CNTL);
  1306. tmp |= rinfo->save_regs[2] & 0xffff;
  1307. OUTPLL(pllMCLK_CNTL, tmp);
  1308. (void)INPLL(pllMCLK_CNTL);
  1309. mdelay(10);
  1310. }
  1311. static void radeon_pm_m10_disable_spread_spectrum(struct radeonfb_info *rinfo)
  1312. {
  1313. u32 r2ec;
  1314. /* GACK ! I though we didn't have a DDA on Radeon's anymore
  1315. * here we rewrite with the same value, ... I suppose we clear
  1316. * some bits that are already clear ? Or maybe this 0x2ec
  1317. * register is something new ?
  1318. */
  1319. mdelay(20);
  1320. r2ec = INREG(VGA_DDA_ON_OFF);
  1321. OUTREG(VGA_DDA_ON_OFF, r2ec);
  1322. mdelay(1);
  1323. /* Spread spectrum PLLL off */
  1324. OUTPLL(pllSSPLL_CNTL, 0xbf03);
  1325. /* Spread spectrum disabled */
  1326. OUTPLL(pllSS_INT_CNTL, rinfo->save_regs[90] & ~3);
  1327. /* The trace shows read & rewrite of LVDS_PLL_CNTL here with same
  1328. * value, not sure what for...
  1329. */
  1330. r2ec |= 0x3f0;
  1331. OUTREG(VGA_DDA_ON_OFF, r2ec);
  1332. mdelay(1);
  1333. }
  1334. static void radeon_pm_m10_enable_lvds_spread_spectrum(struct radeonfb_info *rinfo)
  1335. {
  1336. u32 r2ec, tmp;
  1337. /* GACK (bis) ! I though we didn't have a DDA on Radeon's anymore
  1338. * here we rewrite with the same value, ... I suppose we clear/set
  1339. * some bits that are already clear/set ?
  1340. */
  1341. r2ec = INREG(VGA_DDA_ON_OFF);
  1342. OUTREG(VGA_DDA_ON_OFF, r2ec);
  1343. mdelay(1);
  1344. /* Enable spread spectrum */
  1345. OUTPLL(pllSSPLL_CNTL, rinfo->save_regs[43] | 3);
  1346. mdelay(3);
  1347. OUTPLL(pllSSPLL_REF_DIV, rinfo->save_regs[44]);
  1348. OUTPLL(pllSSPLL_DIV_0, rinfo->save_regs[45]);
  1349. tmp = INPLL(pllSSPLL_CNTL);
  1350. OUTPLL(pllSSPLL_CNTL, tmp & ~0x2);
  1351. mdelay(6);
  1352. tmp = INPLL(pllSSPLL_CNTL);
  1353. OUTPLL(pllSSPLL_CNTL, tmp & ~0x1);
  1354. mdelay(5);
  1355. OUTPLL(pllSS_INT_CNTL, rinfo->save_regs[90]);
  1356. r2ec |= 8;
  1357. OUTREG(VGA_DDA_ON_OFF, r2ec);
  1358. mdelay(20);
  1359. /* Enable LVDS interface */
  1360. tmp = INREG(LVDS_GEN_CNTL);
  1361. OUTREG(LVDS_GEN_CNTL, tmp | LVDS_EN);
  1362. /* Enable LVDS_PLL */
  1363. tmp = INREG(LVDS_PLL_CNTL);
  1364. tmp &= ~0x30000;
  1365. tmp |= 0x10000;
  1366. OUTREG(LVDS_PLL_CNTL, tmp);
  1367. OUTPLL(pllSCLK_MORE_CNTL, rinfo->save_regs[34]);
  1368. OUTPLL(pllSS_TST_CNTL, rinfo->save_regs[91]);
  1369. /* The trace reads that one here, waiting for something to settle down ? */
  1370. INREG(RBBM_STATUS);
  1371. /* Ugh ? SS_TST_DEC is supposed to be a read register in the
  1372. * R300 register spec at least...
  1373. */
  1374. tmp = INPLL(pllSS_TST_CNTL);
  1375. tmp |= 0x00400000;
  1376. OUTPLL(pllSS_TST_CNTL, tmp);
  1377. }
  1378. static void radeon_pm_restore_pixel_pll(struct radeonfb_info *rinfo)
  1379. {
  1380. u32 tmp;
  1381. OUTREG8(CLOCK_CNTL_INDEX, pllHTOTAL_CNTL + PLL_WR_EN);
  1382. radeon_pll_errata_after_index(rinfo);
  1383. OUTREG8(CLOCK_CNTL_DATA, 0);
  1384. radeon_pll_errata_after_data(rinfo);
  1385. tmp = INPLL(pllVCLK_ECP_CNTL);
  1386. OUTPLL(pllVCLK_ECP_CNTL, tmp | 0x80);
  1387. mdelay(5);
  1388. tmp = INPLL(pllPPLL_REF_DIV);
  1389. tmp = (tmp & ~PPLL_REF_DIV_MASK) | rinfo->pll.ref_div;
  1390. OUTPLL(pllPPLL_REF_DIV, tmp);
  1391. INPLL(pllPPLL_REF_DIV);
  1392. /* Reconfigure SPLL charge pump, VCO gain, duty cycle,
  1393. * probably useless since we already did it ...
  1394. */
  1395. tmp = INPLL(pllPPLL_CNTL);
  1396. OUTREG8(CLOCK_CNTL_INDEX, pllSPLL_CNTL + PLL_WR_EN);
  1397. radeon_pll_errata_after_index(rinfo);
  1398. OUTREG8(CLOCK_CNTL_DATA + 1, (tmp >> 8) & 0xff);
  1399. radeon_pll_errata_after_data(rinfo);
  1400. /* Restore our "reference" PPLL divider set by firmware
  1401. * according to proper spread spectrum calculations
  1402. */
  1403. OUTPLL(pllPPLL_DIV_0, rinfo->save_regs[92]);
  1404. tmp = INPLL(pllPPLL_CNTL);
  1405. OUTPLL(pllPPLL_CNTL, tmp & ~0x2);
  1406. mdelay(5);
  1407. tmp = INPLL(pllPPLL_CNTL);
  1408. OUTPLL(pllPPLL_CNTL, tmp & ~0x1);
  1409. mdelay(5);
  1410. tmp = INPLL(pllVCLK_ECP_CNTL);
  1411. OUTPLL(pllVCLK_ECP_CNTL, tmp | 3);
  1412. mdelay(5);
  1413. tmp = INPLL(pllVCLK_ECP_CNTL);
  1414. OUTPLL(pllVCLK_ECP_CNTL, tmp | 3);
  1415. mdelay(5);
  1416. /* Switch pixel clock to firmware default div 0 */
  1417. OUTREG8(CLOCK_CNTL_INDEX+1, 0);
  1418. radeon_pll_errata_after_index(rinfo);
  1419. radeon_pll_errata_after_data(rinfo);
  1420. }
  1421. static void radeon_pm_m10_reconfigure_mc(struct radeonfb_info *rinfo)
  1422. {
  1423. OUTREG(MC_CNTL, rinfo->save_regs[46]);
  1424. OUTREG(MC_INIT_GFX_LAT_TIMER, rinfo->save_regs[47]);
  1425. OUTREG(MC_INIT_MISC_LAT_TIMER, rinfo->save_regs[48]);
  1426. OUTREG(MEM_SDRAM_MODE_REG,
  1427. rinfo->save_regs[35] & ~MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1428. OUTREG(MC_TIMING_CNTL, rinfo->save_regs[49]);
  1429. OUTREG(MEM_REFRESH_CNTL, rinfo->save_regs[42]);
  1430. OUTREG(MC_READ_CNTL_AB, rinfo->save_regs[50]);
  1431. OUTREG(MC_CHIP_IO_OE_CNTL_AB, rinfo->save_regs[52]);
  1432. OUTREG(MC_IOPAD_CNTL, rinfo->save_regs[51]);
  1433. OUTREG(MC_DEBUG, rinfo->save_regs[53]);
  1434. OUTMC(rinfo, ixR300_MC_MC_INIT_WR_LAT_TIMER, rinfo->save_regs[58]);
  1435. OUTMC(rinfo, ixR300_MC_IMP_CNTL, rinfo->save_regs[59]);
  1436. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_C0, rinfo->save_regs[60]);
  1437. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_C1, rinfo->save_regs[61]);
  1438. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_D0, rinfo->save_regs[62]);
  1439. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_D1, rinfo->save_regs[63]);
  1440. OUTMC(rinfo, ixR300_MC_BIST_CNTL_3, rinfo->save_regs[64]);
  1441. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_A0, rinfo->save_regs[65]);
  1442. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_A1, rinfo->save_regs[66]);
  1443. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_B0, rinfo->save_regs[67]);
  1444. OUTMC(rinfo, ixR300_MC_CHP_IO_CNTL_B1, rinfo->save_regs[68]);
  1445. OUTMC(rinfo, ixR300_MC_DEBUG_CNTL, rinfo->save_regs[69]);
  1446. OUTMC(rinfo, ixR300_MC_DLL_CNTL, rinfo->save_regs[70]);
  1447. OUTMC(rinfo, ixR300_MC_IMP_CNTL_0, rinfo->save_regs[71]);
  1448. OUTMC(rinfo, ixR300_MC_ELPIDA_CNTL, rinfo->save_regs[72]);
  1449. OUTMC(rinfo, ixR300_MC_READ_CNTL_CD, rinfo->save_regs[96]);
  1450. OUTREG(MC_IND_INDEX, 0);
  1451. }
  1452. static void radeon_reinitialize_M10(struct radeonfb_info *rinfo)
  1453. {
  1454. u32 tmp, i;
  1455. /* Restore a bunch of registers first */
  1456. OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]);
  1457. OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]);
  1458. OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
  1459. OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]);
  1460. OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]);
  1461. OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
  1462. OUTREG(BUS_CNTL, rinfo->save_regs[36]);
  1463. OUTREG(BUS_CNTL1, rinfo->save_regs[14]);
  1464. OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]);
  1465. OUTREG(FCP_CNTL, rinfo->save_regs[38]);
  1466. OUTREG(RBBM_CNTL, rinfo->save_regs[39]);
  1467. OUTREG(DAC_CNTL, rinfo->save_regs[40]);
  1468. OUTREG(DAC_MACRO_CNTL, (INREG(DAC_MACRO_CNTL) & ~0x6) | 8);
  1469. OUTREG(DAC_MACRO_CNTL, (INREG(DAC_MACRO_CNTL) & ~0x6) | 8);
  1470. /* Hrm... */
  1471. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) | DAC2_EXPAND_MODE);
  1472. /* Reset the PAD CTLR */
  1473. radeon_pm_reset_pad_ctlr_strength(rinfo);
  1474. /* Some PLLs are Read & written identically in the trace here...
  1475. * I suppose it's actually to switch them all off & reset,
  1476. * let's assume off is what we want. I'm just doing that for all major PLLs now.
  1477. */
  1478. radeon_pm_all_ppls_off(rinfo);
  1479. /* Clear tiling, reset swappers */
  1480. INREG(SURFACE_CNTL);
  1481. OUTREG(SURFACE_CNTL, 0);
  1482. /* Some black magic with TV_DAC_CNTL, we should restore those from backups
  1483. * rather than hard coding...
  1484. */
  1485. tmp = INREG(TV_DAC_CNTL) & ~TV_DAC_CNTL_BGADJ_MASK;
  1486. tmp |= 8 << TV_DAC_CNTL_BGADJ__SHIFT;
  1487. OUTREG(TV_DAC_CNTL, tmp);
  1488. tmp = INREG(TV_DAC_CNTL) & ~TV_DAC_CNTL_DACADJ_MASK;
  1489. tmp |= 7 << TV_DAC_CNTL_DACADJ__SHIFT;
  1490. OUTREG(TV_DAC_CNTL, tmp);
  1491. /* More registers restored */
  1492. OUTREG(AGP_CNTL, rinfo->save_regs[16]);
  1493. OUTREG(HOST_PATH_CNTL, rinfo->save_regs[41]);
  1494. OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]);
  1495. /* Hrmmm ... What is that ? */
  1496. tmp = rinfo->save_regs[1]
  1497. & ~(CLK_PWRMGT_CNTL__ACTIVE_HILO_LAT_MASK |
  1498. CLK_PWRMGT_CNTL__MC_BUSY);
  1499. OUTPLL(pllCLK_PWRMGT_CNTL, tmp);
  1500. OUTREG(PAD_CTLR_MISC, rinfo->save_regs[56]);
  1501. OUTREG(FW_CNTL, rinfo->save_regs[57]);
  1502. OUTREG(HDP_DEBUG, rinfo->save_regs[96]);
  1503. OUTREG(PAMAC0_DLY_CNTL, rinfo->save_regs[54]);
  1504. OUTREG(PAMAC1_DLY_CNTL, rinfo->save_regs[55]);
  1505. OUTREG(PAMAC2_DLY_CNTL, rinfo->save_regs[79]);
  1506. /* Restore Memory Controller configuration */
  1507. radeon_pm_m10_reconfigure_mc(rinfo);
  1508. /* Make sure CRTC's dont touch memory */
  1509. OUTREG(CRTC_GEN_CNTL, INREG(CRTC_GEN_CNTL)
  1510. | CRTC_GEN_CNTL__CRTC_DISP_REQ_EN_B);
  1511. OUTREG(CRTC2_GEN_CNTL, INREG(CRTC2_GEN_CNTL)
  1512. | CRTC2_GEN_CNTL__CRTC2_DISP_REQ_EN_B);
  1513. mdelay(30);
  1514. /* Disable SDRAM refresh */
  1515. OUTREG(MEM_REFRESH_CNTL, INREG(MEM_REFRESH_CNTL)
  1516. | MEM_REFRESH_CNTL__MEM_REFRESH_DIS);
  1517. /* Restore XTALIN routing (CLK_PIN_CNTL) */
  1518. OUTPLL(pllCLK_PIN_CNTL, rinfo->save_regs[4]);
  1519. /* Switch MCLK, YCLK and SCLK PLLs to PCI source & force them ON */
  1520. tmp = rinfo->save_regs[2] & 0xff000000;
  1521. tmp |= MCLK_CNTL__FORCE_MCLKA |
  1522. MCLK_CNTL__FORCE_MCLKB |
  1523. MCLK_CNTL__FORCE_YCLKA |
  1524. MCLK_CNTL__FORCE_YCLKB |
  1525. MCLK_CNTL__FORCE_MC;
  1526. OUTPLL(pllMCLK_CNTL, tmp);
  1527. /* Force all clocks on in SCLK */
  1528. tmp = INPLL(pllSCLK_CNTL);
  1529. tmp |= SCLK_CNTL__FORCE_DISP2|
  1530. SCLK_CNTL__FORCE_CP|
  1531. SCLK_CNTL__FORCE_HDP|
  1532. SCLK_CNTL__FORCE_DISP1|
  1533. SCLK_CNTL__FORCE_TOP|
  1534. SCLK_CNTL__FORCE_E2|
  1535. SCLK_CNTL__FORCE_SE|
  1536. SCLK_CNTL__FORCE_IDCT|
  1537. SCLK_CNTL__FORCE_VIP|
  1538. SCLK_CNTL__FORCE_PB|
  1539. SCLK_CNTL__FORCE_TAM|
  1540. SCLK_CNTL__FORCE_TDM|
  1541. SCLK_CNTL__FORCE_RB|
  1542. SCLK_CNTL__FORCE_TV_SCLK|
  1543. SCLK_CNTL__FORCE_SUBPIC|
  1544. SCLK_CNTL__FORCE_OV0;
  1545. tmp |= SCLK_CNTL__CP_MAX_DYN_STOP_LAT |
  1546. SCLK_CNTL__HDP_MAX_DYN_STOP_LAT |
  1547. SCLK_CNTL__TV_MAX_DYN_STOP_LAT |
  1548. SCLK_CNTL__E2_MAX_DYN_STOP_LAT |
  1549. SCLK_CNTL__SE_MAX_DYN_STOP_LAT |
  1550. SCLK_CNTL__IDCT_MAX_DYN_STOP_LAT|
  1551. SCLK_CNTL__VIP_MAX_DYN_STOP_LAT |
  1552. SCLK_CNTL__RE_MAX_DYN_STOP_LAT |
  1553. SCLK_CNTL__PB_MAX_DYN_STOP_LAT |
  1554. SCLK_CNTL__TAM_MAX_DYN_STOP_LAT |
  1555. SCLK_CNTL__TDM_MAX_DYN_STOP_LAT |
  1556. SCLK_CNTL__RB_MAX_DYN_STOP_LAT;
  1557. OUTPLL(pllSCLK_CNTL, tmp);
  1558. OUTPLL(pllVCLK_ECP_CNTL, 0);
  1559. OUTPLL(pllPIXCLKS_CNTL, 0);
  1560. OUTPLL(pllMCLK_MISC,
  1561. MCLK_MISC__MC_MCLK_MAX_DYN_STOP_LAT |
  1562. MCLK_MISC__IO_MCLK_MAX_DYN_STOP_LAT);
  1563. mdelay(5);
  1564. /* Restore the M_SPLL_REF_FB_DIV, MPLL_AUX_CNTL and SPLL_AUX_CNTL values */
  1565. OUTPLL(pllM_SPLL_REF_FB_DIV, rinfo->save_regs[77]);
  1566. OUTPLL(pllMPLL_AUX_CNTL, rinfo->save_regs[75]);
  1567. OUTPLL(pllSPLL_AUX_CNTL, rinfo->save_regs[76]);
  1568. /* Now restore the major PLLs settings, keeping them off & reset though */
  1569. OUTPLL(pllPPLL_CNTL, rinfo->save_regs[93] | 0x3);
  1570. OUTPLL(pllP2PLL_CNTL, rinfo->save_regs[8] | 0x3);
  1571. OUTPLL(pllMPLL_CNTL, rinfo->save_regs[73] | 0x03);
  1572. OUTPLL(pllSPLL_CNTL, rinfo->save_regs[74] | 0x03);
  1573. /* Restore MC DLL state and switch it off/reset too */
  1574. OUTMC(rinfo, ixR300_MC_DLL_CNTL, rinfo->save_regs[70]);
  1575. /* Switch MDLL off & reset */
  1576. OUTPLL(pllMDLL_RDCKA, rinfo->save_regs[98] | 0xff);
  1577. mdelay(5);
  1578. /* Setup some black magic bits in PLL_PWRMGT_CNTL. Hrm... we saved
  1579. * 0xa1100007... and MacOS writes 0xa1000007 ..
  1580. */
  1581. OUTPLL(pllPLL_PWRMGT_CNTL, rinfo->save_regs[0]);
  1582. /* Restore more stuffs */
  1583. OUTPLL(pllHTOTAL_CNTL, 0);
  1584. OUTPLL(pllHTOTAL2_CNTL, 0);
  1585. /* More PLL initial configuration */
  1586. tmp = INPLL(pllSCLK_CNTL2); /* What for ? */
  1587. OUTPLL(pllSCLK_CNTL2, tmp);
  1588. tmp = INPLL(pllSCLK_MORE_CNTL);
  1589. tmp |= SCLK_MORE_CNTL__FORCE_DISPREGS | /* a guess */
  1590. SCLK_MORE_CNTL__FORCE_MC_GUI |
  1591. SCLK_MORE_CNTL__FORCE_MC_HOST;
  1592. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  1593. /* Now we actually start MCLK and SCLK */
  1594. radeon_pm_start_mclk_sclk(rinfo);
  1595. /* Full reset sdrams, this also re-inits the MDLL */
  1596. radeon_pm_full_reset_sdram(rinfo);
  1597. /* Fill palettes */
  1598. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) | 0x20);
  1599. for (i=0; i<256; i++)
  1600. OUTREG(PALETTE_30_DATA, 0x15555555);
  1601. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) & ~20);
  1602. udelay(20);
  1603. for (i=0; i<256; i++)
  1604. OUTREG(PALETTE_30_DATA, 0x15555555);
  1605. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) & ~0x20);
  1606. mdelay(3);
  1607. /* Restore TMDS */
  1608. OUTREG(FP_GEN_CNTL, rinfo->save_regs[82]);
  1609. OUTREG(FP2_GEN_CNTL, rinfo->save_regs[83]);
  1610. /* Set LVDS registers but keep interface & pll down */
  1611. OUTREG(LVDS_GEN_CNTL, rinfo->save_regs[11] &
  1612. ~(LVDS_EN | LVDS_ON | LVDS_DIGON | LVDS_BLON | LVDS_BL_MOD_EN));
  1613. OUTREG(LVDS_PLL_CNTL, (rinfo->save_regs[12] & ~0xf0000) | 0x20000);
  1614. OUTREG(DISP_OUTPUT_CNTL, rinfo->save_regs[86]);
  1615. /* Restore GPIOPAD state */
  1616. OUTREG(GPIOPAD_A, rinfo->save_regs[19]);
  1617. OUTREG(GPIOPAD_EN, rinfo->save_regs[20]);
  1618. OUTREG(GPIOPAD_MASK, rinfo->save_regs[21]);
  1619. /* write some stuff to the framebuffer... */
  1620. for (i = 0; i < 0x8000; ++i)
  1621. writeb(0, rinfo->fb_base + i);
  1622. mdelay(40);
  1623. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) | LVDS_DIGON | LVDS_ON);
  1624. mdelay(40);
  1625. /* Restore a few more things */
  1626. OUTREG(GRPH_BUFFER_CNTL, rinfo->save_regs[94]);
  1627. OUTREG(GRPH2_BUFFER_CNTL, rinfo->save_regs[95]);
  1628. /* Take care of spread spectrum & PPLLs now */
  1629. radeon_pm_m10_disable_spread_spectrum(rinfo);
  1630. radeon_pm_restore_pixel_pll(rinfo);
  1631. /* GRRRR... I can't figure out the proper LVDS power sequence, and the
  1632. * code I have for blank/unblank doesn't quite work on some laptop models
  1633. * it seems ... Hrm. What I have here works most of the time ...
  1634. */
  1635. radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
  1636. }
  1637. #endif
  1638. #ifdef CONFIG_PPC
  1639. #ifdef CONFIG_PPC_PMAC
  1640. static void radeon_pm_m9p_reconfigure_mc(struct radeonfb_info *rinfo)
  1641. {
  1642. OUTREG(MC_CNTL, rinfo->save_regs[46]);
  1643. OUTREG(MC_INIT_GFX_LAT_TIMER, rinfo->save_regs[47]);
  1644. OUTREG(MC_INIT_MISC_LAT_TIMER, rinfo->save_regs[48]);
  1645. OUTREG(MEM_SDRAM_MODE_REG,
  1646. rinfo->save_regs[35] & ~MEM_SDRAM_MODE_REG__MC_INIT_COMPLETE);
  1647. OUTREG(MC_TIMING_CNTL, rinfo->save_regs[49]);
  1648. OUTREG(MC_READ_CNTL_AB, rinfo->save_regs[50]);
  1649. OUTREG(MEM_REFRESH_CNTL, rinfo->save_regs[42]);
  1650. OUTREG(MC_IOPAD_CNTL, rinfo->save_regs[51]);
  1651. OUTREG(MC_DEBUG, rinfo->save_regs[53]);
  1652. OUTREG(MC_CHIP_IO_OE_CNTL_AB, rinfo->save_regs[52]);
  1653. OUTMC(rinfo, ixMC_IMP_CNTL, rinfo->save_regs[59] /*0x00f460d6*/);
  1654. OUTMC(rinfo, ixMC_CHP_IO_CNTL_A0, rinfo->save_regs[65] /*0xfecfa666*/);
  1655. OUTMC(rinfo, ixMC_CHP_IO_CNTL_A1, rinfo->save_regs[66] /*0x141555ff*/);
  1656. OUTMC(rinfo, ixMC_CHP_IO_CNTL_B0, rinfo->save_regs[67] /*0xfecfa666*/);
  1657. OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, rinfo->save_regs[68] /*0x141555ff*/);
  1658. OUTMC(rinfo, ixMC_IMP_CNTL_0, rinfo->save_regs[71] /*0x00009249*/);
  1659. OUTREG(MC_IND_INDEX, 0);
  1660. OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
  1661. mdelay(20);
  1662. }
  1663. static void radeon_reinitialize_M9P(struct radeonfb_info *rinfo)
  1664. {
  1665. u32 tmp, i;
  1666. /* Restore a bunch of registers first */
  1667. OUTREG(SURFACE_CNTL, rinfo->save_regs[29]);
  1668. OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]);
  1669. OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]);
  1670. OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
  1671. OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]);
  1672. OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]);
  1673. OUTREG(BUS_CNTL, rinfo->save_regs[36]);
  1674. OUTREG(BUS_CNTL1, rinfo->save_regs[14]);
  1675. OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]);
  1676. OUTREG(FCP_CNTL, rinfo->save_regs[38]);
  1677. OUTREG(RBBM_CNTL, rinfo->save_regs[39]);
  1678. OUTREG(DAC_CNTL, rinfo->save_regs[40]);
  1679. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) | DAC2_EXPAND_MODE);
  1680. /* Reset the PAD CTLR */
  1681. radeon_pm_reset_pad_ctlr_strength(rinfo);
  1682. /* Some PLLs are Read & written identically in the trace here...
  1683. * I suppose it's actually to switch them all off & reset,
  1684. * let's assume off is what we want. I'm just doing that for all major PLLs now.
  1685. */
  1686. radeon_pm_all_ppls_off(rinfo);
  1687. /* Clear tiling, reset swappers */
  1688. INREG(SURFACE_CNTL);
  1689. OUTREG(SURFACE_CNTL, 0);
  1690. /* Some black magic with TV_DAC_CNTL, we should restore those from backups
  1691. * rather than hard coding...
  1692. */
  1693. tmp = INREG(TV_DAC_CNTL) & ~TV_DAC_CNTL_BGADJ_MASK;
  1694. tmp |= 6 << TV_DAC_CNTL_BGADJ__SHIFT;
  1695. OUTREG(TV_DAC_CNTL, tmp);
  1696. tmp = INREG(TV_DAC_CNTL) & ~TV_DAC_CNTL_DACADJ_MASK;
  1697. tmp |= 6 << TV_DAC_CNTL_DACADJ__SHIFT;
  1698. OUTREG(TV_DAC_CNTL, tmp);
  1699. OUTPLL(pllAGP_PLL_CNTL, rinfo->save_regs[78]);
  1700. OUTREG(PAMAC0_DLY_CNTL, rinfo->save_regs[54]);
  1701. OUTREG(PAMAC1_DLY_CNTL, rinfo->save_regs[55]);
  1702. OUTREG(PAMAC2_DLY_CNTL, rinfo->save_regs[79]);
  1703. OUTREG(AGP_CNTL, rinfo->save_regs[16]);
  1704. OUTREG(HOST_PATH_CNTL, rinfo->save_regs[41]); /* MacOS sets that to 0 !!! */
  1705. OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]);
  1706. tmp = rinfo->save_regs[1]
  1707. & ~(CLK_PWRMGT_CNTL__ACTIVE_HILO_LAT_MASK |
  1708. CLK_PWRMGT_CNTL__MC_BUSY);
  1709. OUTPLL(pllCLK_PWRMGT_CNTL, tmp);
  1710. OUTREG(FW_CNTL, rinfo->save_regs[57]);
  1711. /* Disable SDRAM refresh */
  1712. OUTREG(MEM_REFRESH_CNTL, INREG(MEM_REFRESH_CNTL)
  1713. | MEM_REFRESH_CNTL__MEM_REFRESH_DIS);
  1714. /* Restore XTALIN routing (CLK_PIN_CNTL) */
  1715. OUTPLL(pllCLK_PIN_CNTL, rinfo->save_regs[4]);
  1716. /* Force MCLK to be PCI sourced and forced ON */
  1717. tmp = rinfo->save_regs[2] & 0xff000000;
  1718. tmp |= MCLK_CNTL__FORCE_MCLKA |
  1719. MCLK_CNTL__FORCE_MCLKB |
  1720. MCLK_CNTL__FORCE_YCLKA |
  1721. MCLK_CNTL__FORCE_YCLKB |
  1722. MCLK_CNTL__FORCE_MC |
  1723. MCLK_CNTL__FORCE_AIC;
  1724. OUTPLL(pllMCLK_CNTL, tmp);
  1725. /* Force SCLK to be PCI sourced with a bunch forced */
  1726. tmp = 0 |
  1727. SCLK_CNTL__FORCE_DISP2|
  1728. SCLK_CNTL__FORCE_CP|
  1729. SCLK_CNTL__FORCE_HDP|
  1730. SCLK_CNTL__FORCE_DISP1|
  1731. SCLK_CNTL__FORCE_TOP|
  1732. SCLK_CNTL__FORCE_E2|
  1733. SCLK_CNTL__FORCE_SE|
  1734. SCLK_CNTL__FORCE_IDCT|
  1735. SCLK_CNTL__FORCE_VIP|
  1736. SCLK_CNTL__FORCE_RE|
  1737. SCLK_CNTL__FORCE_PB|
  1738. SCLK_CNTL__FORCE_TAM|
  1739. SCLK_CNTL__FORCE_TDM|
  1740. SCLK_CNTL__FORCE_RB;
  1741. OUTPLL(pllSCLK_CNTL, tmp);
  1742. /* Clear VCLK_ECP_CNTL & PIXCLKS_CNTL */
  1743. OUTPLL(pllVCLK_ECP_CNTL, 0);
  1744. OUTPLL(pllPIXCLKS_CNTL, 0);
  1745. /* Setup MCLK_MISC, non dynamic mode */
  1746. OUTPLL(pllMCLK_MISC,
  1747. MCLK_MISC__MC_MCLK_MAX_DYN_STOP_LAT |
  1748. MCLK_MISC__IO_MCLK_MAX_DYN_STOP_LAT);
  1749. mdelay(5);
  1750. /* Set back the default clock dividers */
  1751. OUTPLL(pllM_SPLL_REF_FB_DIV, rinfo->save_regs[77]);
  1752. OUTPLL(pllMPLL_AUX_CNTL, rinfo->save_regs[75]);
  1753. OUTPLL(pllSPLL_AUX_CNTL, rinfo->save_regs[76]);
  1754. /* PPLL and P2PLL default values & off */
  1755. OUTPLL(pllPPLL_CNTL, rinfo->save_regs[93] | 0x3);
  1756. OUTPLL(pllP2PLL_CNTL, rinfo->save_regs[8] | 0x3);
  1757. /* S and M PLLs are reset & off, configure them */
  1758. OUTPLL(pllMPLL_CNTL, rinfo->save_regs[73] | 0x03);
  1759. OUTPLL(pllSPLL_CNTL, rinfo->save_regs[74] | 0x03);
  1760. /* Default values for MDLL ... fixme */
  1761. OUTPLL(pllMDLL_CKO, 0x9c009c);
  1762. OUTPLL(pllMDLL_RDCKA, 0x08830883);
  1763. OUTPLL(pllMDLL_RDCKB, 0x08830883);
  1764. mdelay(5);
  1765. /* Restore PLL_PWRMGT_CNTL */ // XXXX
  1766. tmp = rinfo->save_regs[0];
  1767. tmp &= ~PLL_PWRMGT_CNTL_SU_SCLK_USE_BCLK;
  1768. tmp |= PLL_PWRMGT_CNTL_SU_MCLK_USE_BCLK;
  1769. OUTPLL(PLL_PWRMGT_CNTL, tmp);
  1770. /* Clear HTOTAL_CNTL & HTOTAL2_CNTL */
  1771. OUTPLL(pllHTOTAL_CNTL, 0);
  1772. OUTPLL(pllHTOTAL2_CNTL, 0);
  1773. /* All outputs off */
  1774. OUTREG(CRTC_GEN_CNTL, 0x04000000);
  1775. OUTREG(CRTC2_GEN_CNTL, 0x04000000);
  1776. OUTREG(FP_GEN_CNTL, 0x00004008);
  1777. OUTREG(FP2_GEN_CNTL, 0x00000008);
  1778. OUTREG(LVDS_GEN_CNTL, 0x08000008);
  1779. /* Restore Memory Controller configuration */
  1780. radeon_pm_m9p_reconfigure_mc(rinfo);
  1781. /* Now we actually start MCLK and SCLK */
  1782. radeon_pm_start_mclk_sclk(rinfo);
  1783. /* Full reset sdrams, this also re-inits the MDLL */
  1784. radeon_pm_full_reset_sdram(rinfo);
  1785. /* Fill palettes */
  1786. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) | 0x20);
  1787. for (i=0; i<256; i++)
  1788. OUTREG(PALETTE_30_DATA, 0x15555555);
  1789. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) & ~20);
  1790. udelay(20);
  1791. for (i=0; i<256; i++)
  1792. OUTREG(PALETTE_30_DATA, 0x15555555);
  1793. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) & ~0x20);
  1794. mdelay(3);
  1795. /* Restore TV stuff, make sure TV DAC is down */
  1796. OUTREG(TV_MASTER_CNTL, rinfo->save_regs[88]);
  1797. OUTREG(TV_DAC_CNTL, rinfo->save_regs[13] | 0x07000000);
  1798. /* Restore GPIOS. MacOS does some magic here with one of the GPIO bits,
  1799. * possibly related to the weird PLL related workarounds and to the
  1800. * fact that CLK_PIN_CNTL is tweaked in ways I don't fully understand,
  1801. * but we keep things the simple way here
  1802. */
  1803. OUTREG(GPIOPAD_A, rinfo->save_regs[19]);
  1804. OUTREG(GPIOPAD_EN, rinfo->save_regs[20]);
  1805. OUTREG(GPIOPAD_MASK, rinfo->save_regs[21]);
  1806. /* Now do things with SCLK_MORE_CNTL. Force bits are already set, copy
  1807. * high bits from backup
  1808. */
  1809. tmp = INPLL(pllSCLK_MORE_CNTL) & 0x0000ffff;
  1810. tmp |= rinfo->save_regs[34] & 0xffff0000;
  1811. tmp |= SCLK_MORE_CNTL__FORCE_DISPREGS;
  1812. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  1813. tmp = INPLL(pllSCLK_MORE_CNTL) & 0x0000ffff;
  1814. tmp |= rinfo->save_regs[34] & 0xffff0000;
  1815. tmp |= SCLK_MORE_CNTL__FORCE_DISPREGS;
  1816. OUTPLL(pllSCLK_MORE_CNTL, tmp);
  1817. OUTREG(LVDS_GEN_CNTL, rinfo->save_regs[11] &
  1818. ~(LVDS_EN | LVDS_ON | LVDS_DIGON | LVDS_BLON | LVDS_BL_MOD_EN));
  1819. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) | LVDS_BLON);
  1820. OUTREG(LVDS_PLL_CNTL, (rinfo->save_regs[12] & ~0xf0000) | 0x20000);
  1821. mdelay(20);
  1822. /* write some stuff to the framebuffer... */
  1823. for (i = 0; i < 0x8000; ++i)
  1824. writeb(0, rinfo->fb_base + i);
  1825. OUTREG(0x2ec, 0x6332a020);
  1826. OUTPLL(pllSSPLL_REF_DIV, rinfo->save_regs[44] /*0x3f */);
  1827. OUTPLL(pllSSPLL_DIV_0, rinfo->save_regs[45] /*0x000081bb */);
  1828. tmp = INPLL(pllSSPLL_CNTL);
  1829. tmp &= ~2;
  1830. OUTPLL(pllSSPLL_CNTL, tmp);
  1831. mdelay(6);
  1832. tmp &= ~1;
  1833. OUTPLL(pllSSPLL_CNTL, tmp);
  1834. mdelay(5);
  1835. tmp |= 3;
  1836. OUTPLL(pllSSPLL_CNTL, tmp);
  1837. mdelay(5);
  1838. OUTPLL(pllSS_INT_CNTL, rinfo->save_regs[90] & ~3);/*0x0020300c*/
  1839. OUTREG(0x2ec, 0x6332a3f0);
  1840. mdelay(17);
  1841. OUTPLL(pllPPLL_REF_DIV, rinfo->pll.ref_div);
  1842. OUTPLL(pllPPLL_DIV_0, rinfo->save_regs[92]);
  1843. mdelay(40);
  1844. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) | LVDS_DIGON | LVDS_ON);
  1845. mdelay(40);
  1846. /* Restore a few more things */
  1847. OUTREG(GRPH_BUFFER_CNTL, rinfo->save_regs[94]);
  1848. OUTREG(GRPH2_BUFFER_CNTL, rinfo->save_regs[95]);
  1849. /* Restore PPLL, spread spectrum & LVDS */
  1850. radeon_pm_m10_disable_spread_spectrum(rinfo);
  1851. radeon_pm_restore_pixel_pll(rinfo);
  1852. radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
  1853. }
  1854. #endif
  1855. #endif
  1856. #if 0 /* Not ready yet */
  1857. static void radeon_reinitialize_QW(struct radeonfb_info *rinfo)
  1858. {
  1859. int i;
  1860. u32 tmp, tmp2;
  1861. u32 cko, cka, ckb;
  1862. u32 cgc, cec, c2gc;
  1863. OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]);
  1864. OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]);
  1865. OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
  1866. OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]);
  1867. OUTREG(BUS_CNTL, rinfo->save_regs[36]);
  1868. OUTREG(RBBM_CNTL, rinfo->save_regs[39]);
  1869. INREG(PAD_CTLR_STRENGTH);
  1870. OUTREG(PAD_CTLR_STRENGTH, INREG(PAD_CTLR_STRENGTH) & ~0x10000);
  1871. for (i = 0; i < 65; ++i) {
  1872. mdelay(1);
  1873. INREG(PAD_CTLR_STRENGTH);
  1874. }
  1875. OUTREG(DISP_TEST_DEBUG_CNTL, INREG(DISP_TEST_DEBUG_CNTL) | 0x10000000);
  1876. OUTREG(OV0_FLAG_CNTRL, INREG(OV0_FLAG_CNTRL) | 0x100);
  1877. OUTREG(CRTC_GEN_CNTL, INREG(CRTC_GEN_CNTL));
  1878. OUTREG(DAC_CNTL, 0xff00410a);
  1879. OUTREG(CRTC2_GEN_CNTL, INREG(CRTC2_GEN_CNTL));
  1880. OUTREG(DAC_CNTL2, INREG(DAC_CNTL2) | 0x4000);
  1881. OUTREG(SURFACE_CNTL, rinfo->save_regs[29]);
  1882. OUTREG(AGP_CNTL, rinfo->save_regs[16]);
  1883. OUTREG(HOST_PATH_CNTL, rinfo->save_regs[41]);
  1884. OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]);
  1885. OUTMC(rinfo, ixMC_CHP_IO_CNTL_A0, 0xf7bb4433);
  1886. OUTREG(MC_IND_INDEX, 0);
  1887. OUTMC(rinfo, ixMC_CHP_IO_CNTL_B0, 0xf7bb4433);
  1888. OUTREG(MC_IND_INDEX, 0);
  1889. OUTREG(CRTC_MORE_CNTL, INREG(CRTC_MORE_CNTL));
  1890. tmp = INPLL(pllVCLK_ECP_CNTL);
  1891. OUTPLL(pllVCLK_ECP_CNTL, tmp);
  1892. tmp = INPLL(pllPIXCLKS_CNTL);
  1893. OUTPLL(pllPIXCLKS_CNTL, tmp);
  1894. OUTPLL(MCLK_CNTL, 0xaa3f0000);
  1895. OUTPLL(SCLK_CNTL, 0xffff0000);
  1896. OUTPLL(pllMPLL_AUX_CNTL, 6);
  1897. OUTPLL(pllSPLL_AUX_CNTL, 1);
  1898. OUTPLL(MDLL_CKO, 0x9f009f);
  1899. OUTPLL(MDLL_RDCKA, 0x830083);
  1900. OUTPLL(pllMDLL_RDCKB, 0x830083);
  1901. OUTPLL(PPLL_CNTL, 0xa433);
  1902. OUTPLL(P2PLL_CNTL, 0xa433);
  1903. OUTPLL(MPLL_CNTL, 0x0400a403);
  1904. OUTPLL(SPLL_CNTL, 0x0400a433);
  1905. tmp = INPLL(M_SPLL_REF_FB_DIV);
  1906. OUTPLL(M_SPLL_REF_FB_DIV, tmp);
  1907. tmp = INPLL(M_SPLL_REF_FB_DIV);
  1908. OUTPLL(M_SPLL_REF_FB_DIV, tmp | 0xc);
  1909. INPLL(M_SPLL_REF_FB_DIV);
  1910. tmp = INPLL(MPLL_CNTL);
  1911. OUTREG8(CLOCK_CNTL_INDEX, MPLL_CNTL + PLL_WR_EN);
  1912. radeon_pll_errata_after_index(rinfo);
  1913. OUTREG8(CLOCK_CNTL_DATA + 1, (tmp >> 8) & 0xff);
  1914. radeon_pll_errata_after_data(rinfo);
  1915. tmp = INPLL(M_SPLL_REF_FB_DIV);
  1916. OUTPLL(M_SPLL_REF_FB_DIV, tmp | 0x5900);
  1917. tmp = INPLL(MPLL_CNTL);
  1918. OUTPLL(MPLL_CNTL, tmp & ~0x2);
  1919. mdelay(1);
  1920. tmp = INPLL(MPLL_CNTL);
  1921. OUTPLL(MPLL_CNTL, tmp & ~0x1);
  1922. mdelay(10);
  1923. OUTPLL(MCLK_CNTL, 0xaa3f1212);
  1924. mdelay(1);
  1925. INPLL(M_SPLL_REF_FB_DIV);
  1926. INPLL(MCLK_CNTL);
  1927. INPLL(M_SPLL_REF_FB_DIV);
  1928. tmp = INPLL(SPLL_CNTL);
  1929. OUTREG8(CLOCK_CNTL_INDEX, SPLL_CNTL + PLL_WR_EN);
  1930. radeon_pll_errata_after_index(rinfo);
  1931. OUTREG8(CLOCK_CNTL_DATA + 1, (tmp >> 8) & 0xff);
  1932. radeon_pll_errata_after_data(rinfo);
  1933. tmp = INPLL(M_SPLL_REF_FB_DIV);
  1934. OUTPLL(M_SPLL_REF_FB_DIV, tmp | 0x780000);
  1935. tmp = INPLL(SPLL_CNTL);
  1936. OUTPLL(SPLL_CNTL, tmp & ~0x1);
  1937. mdelay(1);
  1938. tmp = INPLL(SPLL_CNTL);
  1939. OUTPLL(SPLL_CNTL, tmp & ~0x2);
  1940. mdelay(10);
  1941. tmp = INPLL(SCLK_CNTL);
  1942. OUTPLL(SCLK_CNTL, tmp | 2);
  1943. mdelay(1);
  1944. cko = INPLL(pllMDLL_CKO);
  1945. cka = INPLL(pllMDLL_RDCKA);
  1946. ckb = INPLL(pllMDLL_RDCKB);
  1947. cko &= ~(MDLL_CKO__MCKOA_SLEEP | MDLL_CKO__MCKOB_SLEEP);
  1948. OUTPLL(pllMDLL_CKO, cko);
  1949. mdelay(1);
  1950. cko &= ~(MDLL_CKO__MCKOA_RESET | MDLL_CKO__MCKOB_RESET);
  1951. OUTPLL(pllMDLL_CKO, cko);
  1952. mdelay(5);
  1953. cka &= ~(MDLL_RDCKA__MRDCKA0_SLEEP | MDLL_RDCKA__MRDCKA1_SLEEP);
  1954. OUTPLL(pllMDLL_RDCKA, cka);
  1955. mdelay(1);
  1956. cka &= ~(MDLL_RDCKA__MRDCKA0_RESET | MDLL_RDCKA__MRDCKA1_RESET);
  1957. OUTPLL(pllMDLL_RDCKA, cka);
  1958. mdelay(5);
  1959. ckb &= ~(MDLL_RDCKB__MRDCKB0_SLEEP | MDLL_RDCKB__MRDCKB1_SLEEP);
  1960. OUTPLL(pllMDLL_RDCKB, ckb);
  1961. mdelay(1);
  1962. ckb &= ~(MDLL_RDCKB__MRDCKB0_RESET | MDLL_RDCKB__MRDCKB1_RESET);
  1963. OUTPLL(pllMDLL_RDCKB, ckb);
  1964. mdelay(5);
  1965. OUTMC(rinfo, ixMC_CHP_IO_CNTL_A1, 0x151550ff);
  1966. OUTREG(MC_IND_INDEX, 0);
  1967. OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, 0x151550ff);
  1968. OUTREG(MC_IND_INDEX, 0);
  1969. mdelay(1);
  1970. OUTMC(rinfo, ixMC_CHP_IO_CNTL_A1, 0x141550ff);
  1971. OUTREG(MC_IND_INDEX, 0);
  1972. OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, 0x141550ff);
  1973. OUTREG(MC_IND_INDEX, 0);
  1974. mdelay(1);
  1975. OUTPLL(pllHTOTAL_CNTL, 0);
  1976. OUTPLL(pllHTOTAL2_CNTL, 0);
  1977. OUTREG(MEM_CNTL, 0x29002901);
  1978. OUTREG(MEM_SDRAM_MODE_REG, 0x45320032); /* XXX use save_regs[35]? */
  1979. OUTREG(EXT_MEM_CNTL, 0x1a394333);
  1980. OUTREG(MEM_IO_CNTL_A1, 0x0aac0aac);
  1981. OUTREG(MEM_INIT_LATENCY_TIMER, 0x34444444);
  1982. OUTREG(MEM_REFRESH_CNTL, 0x1f1f7218); /* XXX or save_regs[42]? */
  1983. OUTREG(MC_DEBUG, 0);
  1984. OUTREG(MEM_IO_OE_CNTL, 0x04300430);
  1985. OUTMC(rinfo, ixMC_IMP_CNTL, 0x00f460d6);
  1986. OUTREG(MC_IND_INDEX, 0);
  1987. OUTMC(rinfo, ixMC_IMP_CNTL_0, 0x00009249);
  1988. OUTREG(MC_IND_INDEX, 0);
  1989. OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
  1990. radeon_pm_full_reset_sdram(rinfo);
  1991. INREG(FP_GEN_CNTL);
  1992. OUTREG(TMDS_CNTL, 0x01000000); /* XXX ? */
  1993. tmp = INREG(FP_GEN_CNTL);
  1994. tmp |= FP_CRTC_DONT_SHADOW_HEND | FP_CRTC_DONT_SHADOW_VPAR | 0x200;
  1995. OUTREG(FP_GEN_CNTL, tmp);
  1996. tmp = INREG(DISP_OUTPUT_CNTL);
  1997. tmp &= ~0x400;
  1998. OUTREG(DISP_OUTPUT_CNTL, tmp);
  1999. OUTPLL(CLK_PIN_CNTL, rinfo->save_regs[4]);
  2000. OUTPLL(CLK_PWRMGT_CNTL, rinfo->save_regs[1]);
  2001. OUTPLL(PLL_PWRMGT_CNTL, rinfo->save_regs[0]);
  2002. tmp = INPLL(MCLK_MISC);
  2003. tmp |= MCLK_MISC__MC_MCLK_DYN_ENABLE | MCLK_MISC__IO_MCLK_DYN_ENABLE;
  2004. OUTPLL(MCLK_MISC, tmp);
  2005. tmp = INPLL(SCLK_CNTL);
  2006. OUTPLL(SCLK_CNTL, tmp);
  2007. OUTREG(CRTC_MORE_CNTL, 0);
  2008. OUTREG8(CRTC_GEN_CNTL+1, 6);
  2009. OUTREG8(CRTC_GEN_CNTL+3, 1);
  2010. OUTREG(CRTC_PITCH, 32);
  2011. tmp = INPLL(VCLK_ECP_CNTL);
  2012. OUTPLL(VCLK_ECP_CNTL, tmp);
  2013. tmp = INPLL(PPLL_CNTL);
  2014. OUTPLL(PPLL_CNTL, tmp);
  2015. /* palette stuff and BIOS_1_SCRATCH... */
  2016. tmp = INREG(FP_GEN_CNTL);
  2017. tmp2 = INREG(TMDS_TRANSMITTER_CNTL);
  2018. tmp |= 2;
  2019. OUTREG(FP_GEN_CNTL, tmp);
  2020. mdelay(5);
  2021. OUTREG(FP_GEN_CNTL, tmp);
  2022. mdelay(5);
  2023. OUTREG(TMDS_TRANSMITTER_CNTL, tmp2);
  2024. OUTREG(CRTC_MORE_CNTL, 0);
  2025. mdelay(20);
  2026. tmp = INREG(CRTC_MORE_CNTL);
  2027. OUTREG(CRTC_MORE_CNTL, tmp);
  2028. cgc = INREG(CRTC_GEN_CNTL);
  2029. cec = INREG(CRTC_EXT_CNTL);
  2030. c2gc = INREG(CRTC2_GEN_CNTL);
  2031. OUTREG(CRTC_H_SYNC_STRT_WID, 0x008e0580);
  2032. OUTREG(CRTC_H_TOTAL_DISP, 0x009f00d2);
  2033. OUTREG8(CLOCK_CNTL_INDEX, HTOTAL_CNTL + PLL_WR_EN);
  2034. radeon_pll_errata_after_index(rinfo);
  2035. OUTREG8(CLOCK_CNTL_DATA, 0);
  2036. radeon_pll_errata_after_data(rinfo);
  2037. OUTREG(CRTC_V_SYNC_STRT_WID, 0x00830403);
  2038. OUTREG(CRTC_V_TOTAL_DISP, 0x03ff0429);
  2039. OUTREG(FP_CRTC_H_TOTAL_DISP, 0x009f0033);
  2040. OUTREG(FP_H_SYNC_STRT_WID, 0x008e0080);
  2041. OUTREG(CRT_CRTC_H_SYNC_STRT_WID, 0x008e0080);
  2042. OUTREG(FP_CRTC_V_TOTAL_DISP, 0x03ff002a);
  2043. OUTREG(FP_V_SYNC_STRT_WID, 0x00830004);
  2044. OUTREG(CRT_CRTC_V_SYNC_STRT_WID, 0x00830004);
  2045. OUTREG(FP_HORZ_VERT_ACTIVE, 0x009f03ff);
  2046. OUTREG(FP_HORZ_STRETCH, 0);
  2047. OUTREG(FP_VERT_STRETCH, 0);
  2048. OUTREG(OVR_CLR, 0);
  2049. OUTREG(OVR_WID_LEFT_RIGHT, 0);
  2050. OUTREG(OVR_WID_TOP_BOTTOM, 0);
  2051. tmp = INPLL(PPLL_REF_DIV);
  2052. tmp = (tmp & ~PPLL_REF_DIV_MASK) | rinfo->pll.ref_div;
  2053. OUTPLL(PPLL_REF_DIV, tmp);
  2054. INPLL(PPLL_REF_DIV);
  2055. OUTREG8(CLOCK_CNTL_INDEX, PPLL_CNTL + PLL_WR_EN);
  2056. radeon_pll_errata_after_index(rinfo);
  2057. OUTREG8(CLOCK_CNTL_DATA + 1, 0xbc);
  2058. radeon_pll_errata_after_data(rinfo);
  2059. tmp = INREG(CLOCK_CNTL_INDEX);
  2060. radeon_pll_errata_after_index(rinfo);
  2061. OUTREG(CLOCK_CNTL_INDEX, tmp & 0xff);
  2062. radeon_pll_errata_after_index(rinfo);
  2063. radeon_pll_errata_after_data(rinfo);
  2064. OUTPLL(PPLL_DIV_0, 0x48090);
  2065. tmp = INPLL(PPLL_CNTL);
  2066. OUTPLL(PPLL_CNTL, tmp & ~0x2);
  2067. mdelay(1);
  2068. tmp = INPLL(PPLL_CNTL);
  2069. OUTPLL(PPLL_CNTL, tmp & ~0x1);
  2070. mdelay(10);
  2071. tmp = INPLL(VCLK_ECP_CNTL);
  2072. OUTPLL(VCLK_ECP_CNTL, tmp | 3);
  2073. mdelay(1);
  2074. tmp = INPLL(VCLK_ECP_CNTL);
  2075. OUTPLL(VCLK_ECP_CNTL, tmp);
  2076. c2gc |= CRTC2_DISP_REQ_EN_B;
  2077. OUTREG(CRTC2_GEN_CNTL, c2gc);
  2078. cgc |= CRTC_EN;
  2079. OUTREG(CRTC_GEN_CNTL, cgc);
  2080. OUTREG(CRTC_EXT_CNTL, cec);
  2081. OUTREG(CRTC_PITCH, 0xa0);
  2082. OUTREG(CRTC_OFFSET, 0);
  2083. OUTREG(CRTC_OFFSET_CNTL, 0);
  2084. OUTREG(GRPH_BUFFER_CNTL, 0x20117c7c);
  2085. OUTREG(GRPH2_BUFFER_CNTL, 0x00205c5c);
  2086. tmp2 = INREG(FP_GEN_CNTL);
  2087. tmp = INREG(TMDS_TRANSMITTER_CNTL);
  2088. OUTREG(0x2a8, 0x0000061b);
  2089. tmp |= TMDS_PLL_EN;
  2090. OUTREG(TMDS_TRANSMITTER_CNTL, tmp);
  2091. mdelay(1);
  2092. tmp &= ~TMDS_PLLRST;
  2093. OUTREG(TMDS_TRANSMITTER_CNTL, tmp);
  2094. tmp2 &= ~2;
  2095. tmp2 |= FP_TMDS_EN;
  2096. OUTREG(FP_GEN_CNTL, tmp2);
  2097. mdelay(5);
  2098. tmp2 |= FP_FPON;
  2099. OUTREG(FP_GEN_CNTL, tmp2);
  2100. OUTREG(CUR_HORZ_VERT_OFF, CUR_LOCK | 1);
  2101. cgc = INREG(CRTC_GEN_CNTL);
  2102. OUTREG(CUR_HORZ_VERT_POSN, 0xbfff0fff);
  2103. cgc |= 0x10000;
  2104. OUTREG(CUR_OFFSET, 0);
  2105. }
  2106. #endif /* 0 */
  2107. #endif /* CONFIG_PPC */
  2108. static void radeonfb_whack_power_state(struct radeonfb_info *rinfo, pci_power_t state)
  2109. {
  2110. u16 pwr_cmd;
  2111. for (;;) {
  2112. pci_read_config_word(rinfo->pdev,
  2113. rinfo->pdev->pm_cap + PCI_PM_CTRL,
  2114. &pwr_cmd);
  2115. if (pwr_cmd & state)
  2116. break;
  2117. pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | state;
  2118. pci_write_config_word(rinfo->pdev,
  2119. rinfo->pdev->pm_cap + PCI_PM_CTRL,
  2120. pwr_cmd);
  2121. msleep(500);
  2122. }
  2123. rinfo->pdev->current_state = state;
  2124. }
  2125. static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
  2126. {
  2127. u32 tmp;
  2128. if (!rinfo->pdev->pm_cap)
  2129. return;
  2130. /* Set the chip into appropriate suspend mode (we use D2,
  2131. * D3 would require a compete re-initialization of the chip,
  2132. * including PCI config registers, clocks, AGP conf, ...)
  2133. */
  2134. if (suspend) {
  2135. printk(KERN_DEBUG "radeonfb (%s): switching to D2 state...\n",
  2136. pci_name(rinfo->pdev));
  2137. /* Disable dynamic power management of clocks for the
  2138. * duration of the suspend/resume process
  2139. */
  2140. radeon_pm_disable_dynamic_mode(rinfo);
  2141. /* Save some registers */
  2142. radeon_pm_save_regs(rinfo, 0);
  2143. /* Prepare mobility chips for suspend.
  2144. */
  2145. if (rinfo->is_mobility) {
  2146. /* Program V2CLK */
  2147. radeon_pm_program_v2clk(rinfo);
  2148. /* Disable IO PADs */
  2149. radeon_pm_disable_iopad(rinfo);
  2150. /* Set low current */
  2151. radeon_pm_low_current(rinfo);
  2152. /* Prepare chip for power management */
  2153. radeon_pm_setup_for_suspend(rinfo);
  2154. if (rinfo->family <= CHIP_FAMILY_RV280) {
  2155. /* Reset the MDLL */
  2156. /* because both INPLL and OUTPLL take the same
  2157. * lock, that's why. */
  2158. tmp = INPLL( pllMDLL_CKO) | MDLL_CKO__MCKOA_RESET
  2159. | MDLL_CKO__MCKOB_RESET;
  2160. OUTPLL( pllMDLL_CKO, tmp );
  2161. }
  2162. }
  2163. /* Switch PCI power management to D2. */
  2164. pci_disable_device(rinfo->pdev);
  2165. pci_save_state(rinfo->pdev);
  2166. /* The chip seems to need us to whack the PM register
  2167. * repeatedly until it sticks. We do that -prior- to
  2168. * calling pci_set_power_state()
  2169. */
  2170. radeonfb_whack_power_state(rinfo, PCI_D2);
  2171. __pci_complete_power_transition(rinfo->pdev, PCI_D2);
  2172. } else {
  2173. printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n",
  2174. pci_name(rinfo->pdev));
  2175. if (rinfo->family <= CHIP_FAMILY_RV250) {
  2176. /* Reset the SDRAM controller */
  2177. radeon_pm_full_reset_sdram(rinfo);
  2178. /* Restore some registers */
  2179. radeon_pm_restore_regs(rinfo);
  2180. } else {
  2181. /* Restore registers first */
  2182. radeon_pm_restore_regs(rinfo);
  2183. /* init sdram controller */
  2184. radeon_pm_full_reset_sdram(rinfo);
  2185. }
  2186. }
  2187. }
  2188. int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
  2189. {
  2190. struct fb_info *info = pci_get_drvdata(pdev);
  2191. struct radeonfb_info *rinfo = info->par;
  2192. if (mesg.event == pdev->dev.power.power_state.event)
  2193. return 0;
  2194. printk(KERN_DEBUG "radeonfb (%s): suspending for event: %d...\n",
  2195. pci_name(pdev), mesg.event);
  2196. /* For suspend-to-disk, we cheat here. We don't suspend anything and
  2197. * let fbcon continue drawing until we are all set. That shouldn't
  2198. * really cause any problem at this point, provided that the wakeup
  2199. * code knows that any state in memory may not match the HW
  2200. */
  2201. switch (mesg.event) {
  2202. case PM_EVENT_FREEZE: /* about to take snapshot */
  2203. case PM_EVENT_PRETHAW: /* before restoring snapshot */
  2204. goto done;
  2205. }
  2206. console_lock();
  2207. fb_set_suspend(info, 1);
  2208. if (!(info->flags & FBINFO_HWACCEL_DISABLED)) {
  2209. /* Make sure engine is reset */
  2210. radeon_engine_idle();
  2211. radeonfb_engine_reset(rinfo);
  2212. radeon_engine_idle();
  2213. }
  2214. /* Blank display and LCD */
  2215. radeon_screen_blank(rinfo, FB_BLANK_POWERDOWN, 1);
  2216. /* Sleep */
  2217. rinfo->asleep = 1;
  2218. rinfo->lock_blank = 1;
  2219. del_timer_sync(&rinfo->lvds_timer);
  2220. #ifdef CONFIG_PPC_PMAC
  2221. /* On powermac, we have hooks to properly suspend/resume AGP now,
  2222. * use them here. We'll ultimately need some generic support here,
  2223. * but the generic code isn't quite ready for that yet
  2224. */
  2225. pmac_suspend_agp_for_card(pdev);
  2226. #endif /* CONFIG_PPC_PMAC */
  2227. /* It's unclear whether or when the generic code will do that, so let's
  2228. * do it ourselves. We save state before we do any power management
  2229. */
  2230. pci_save_state(pdev);
  2231. /* If we support wakeup from poweroff, we save all regs we can including cfg
  2232. * space
  2233. */
  2234. if (rinfo->pm_mode & radeon_pm_off) {
  2235. /* Always disable dynamic clocks or weird things are happening when
  2236. * the chip goes off (basically the panel doesn't shut down properly
  2237. * and we crash on wakeup),
  2238. * also, we want the saved regs context to have no dynamic clocks in
  2239. * it, we'll restore the dynamic clocks state on wakeup
  2240. */
  2241. radeon_pm_disable_dynamic_mode(rinfo);
  2242. mdelay(50);
  2243. radeon_pm_save_regs(rinfo, 1);
  2244. if (rinfo->is_mobility && !(rinfo->pm_mode & radeon_pm_d2)) {
  2245. /* Switch off LVDS interface */
  2246. mdelay(1);
  2247. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_BL_MOD_EN));
  2248. mdelay(1);
  2249. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_EN | LVDS_ON));
  2250. OUTREG(LVDS_PLL_CNTL, (INREG(LVDS_PLL_CNTL) & ~30000) | 0x20000);
  2251. mdelay(20);
  2252. OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_DIGON));
  2253. }
  2254. pci_disable_device(pdev);
  2255. }
  2256. /* If we support D2, we go to it (should be fixed later with a flag forcing
  2257. * D3 only for some laptops)
  2258. */
  2259. if (rinfo->pm_mode & radeon_pm_d2)
  2260. radeon_set_suspend(rinfo, 1);
  2261. console_unlock();
  2262. done:
  2263. pdev->dev.power.power_state = mesg;
  2264. return 0;
  2265. }
  2266. static int radeon_check_power_loss(struct radeonfb_info *rinfo)
  2267. {
  2268. return rinfo->save_regs[4] != INPLL(CLK_PIN_CNTL) ||
  2269. rinfo->save_regs[2] != INPLL(MCLK_CNTL) ||
  2270. rinfo->save_regs[3] != INPLL(SCLK_CNTL);
  2271. }
  2272. int radeonfb_pci_resume(struct pci_dev *pdev)
  2273. {
  2274. struct fb_info *info = pci_get_drvdata(pdev);
  2275. struct radeonfb_info *rinfo = info->par;
  2276. int rc = 0;
  2277. if (pdev->dev.power.power_state.event == PM_EVENT_ON)
  2278. return 0;
  2279. if (rinfo->no_schedule) {
  2280. if (!console_trylock())
  2281. return 0;
  2282. } else
  2283. console_lock();
  2284. printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
  2285. pci_name(pdev), pdev->dev.power.power_state.event);
  2286. /* PCI state will have been restored by the core, so
  2287. * we should be in D0 now with our config space fully
  2288. * restored
  2289. */
  2290. if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
  2291. /* Wakeup chip */
  2292. if ((rinfo->pm_mode & radeon_pm_off) && radeon_check_power_loss(rinfo)) {
  2293. if (rinfo->reinit_func != NULL)
  2294. rinfo->reinit_func(rinfo);
  2295. else {
  2296. printk(KERN_ERR "radeonfb (%s): can't resume radeon from"
  2297. " D3 cold, need softboot !", pci_name(pdev));
  2298. rc = -EIO;
  2299. goto bail;
  2300. }
  2301. }
  2302. /* If we support D2, try to resume... we should check what was our
  2303. * state though... (were we really in D2 state ?). Right now, this code
  2304. * is only enable on Macs so it's fine.
  2305. */
  2306. else if (rinfo->pm_mode & radeon_pm_d2)
  2307. radeon_set_suspend(rinfo, 0);
  2308. rinfo->asleep = 0;
  2309. } else
  2310. radeon_engine_idle();
  2311. /* Restore display & engine */
  2312. radeon_write_mode (rinfo, &rinfo->state, 1);
  2313. if (!(info->flags & FBINFO_HWACCEL_DISABLED))
  2314. radeonfb_engine_init (rinfo);
  2315. fb_pan_display(info, &info->var);
  2316. fb_set_cmap(&info->cmap, info);
  2317. /* Refresh */
  2318. fb_set_suspend(info, 0);
  2319. /* Unblank */
  2320. rinfo->lock_blank = 0;
  2321. radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 1);
  2322. #ifdef CONFIG_PPC_PMAC
  2323. /* On powermac, we have hooks to properly suspend/resume AGP now,
  2324. * use them here. We'll ultimately need some generic support here,
  2325. * but the generic code isn't quite ready for that yet
  2326. */
  2327. pmac_resume_agp_for_card(pdev);
  2328. #endif /* CONFIG_PPC_PMAC */
  2329. /* Check status of dynclk */
  2330. if (rinfo->dynclk == 1)
  2331. radeon_pm_enable_dynamic_mode(rinfo);
  2332. else if (rinfo->dynclk == 0)
  2333. radeon_pm_disable_dynamic_mode(rinfo);
  2334. pdev->dev.power.power_state = PMSG_ON;
  2335. bail:
  2336. console_unlock();
  2337. return rc;
  2338. }
  2339. #ifdef CONFIG_PPC__disabled
  2340. static void radeonfb_early_resume(void *data)
  2341. {
  2342. struct radeonfb_info *rinfo = data;
  2343. rinfo->no_schedule = 1;
  2344. pci_restore_state(rinfo->pdev);
  2345. radeonfb_pci_resume(rinfo->pdev);
  2346. rinfo->no_schedule = 0;
  2347. }
  2348. #endif /* CONFIG_PPC */
  2349. #endif /* CONFIG_PM */
  2350. void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk, int ignore_devlist, int force_sleep)
  2351. {
  2352. /* Enable/Disable dynamic clocks: TODO add sysfs access */
  2353. if (rinfo->family == CHIP_FAMILY_RS480)
  2354. rinfo->dynclk = -1;
  2355. else
  2356. rinfo->dynclk = dynclk;
  2357. if (rinfo->dynclk == 1) {
  2358. radeon_pm_enable_dynamic_mode(rinfo);
  2359. printk("radeonfb: Dynamic Clock Power Management enabled\n");
  2360. } else if (rinfo->dynclk == 0) {
  2361. radeon_pm_disable_dynamic_mode(rinfo);
  2362. printk("radeonfb: Dynamic Clock Power Management disabled\n");
  2363. }
  2364. #if defined(CONFIG_PM)
  2365. #if defined(CONFIG_PPC_PMAC)
  2366. /* Check if we can power manage on suspend/resume. We can do
  2367. * D2 on M6, M7 and M9, and we can resume from D3 cold a few other
  2368. * "Mac" cards, but that's all. We need more infos about what the
  2369. * BIOS does tho. Right now, all this PM stuff is pmac-only for that
  2370. * reason. --BenH
  2371. */
  2372. if (machine_is(powermac) && rinfo->of_node) {
  2373. if (rinfo->is_mobility && rinfo->pdev->pm_cap &&
  2374. rinfo->family <= CHIP_FAMILY_RV250)
  2375. rinfo->pm_mode |= radeon_pm_d2;
  2376. /* We can restart Jasper (M10 chip in albooks), BlueStone (7500 chip
  2377. * in some desktop G4s), Via (M9+ chip on iBook G4) and
  2378. * Snowy (M11 chip on iBook G4 manufactured after July 2005)
  2379. */
  2380. if (!strcmp(rinfo->of_node->name, "ATY,JasperParent") ||
  2381. !strcmp(rinfo->of_node->name, "ATY,SnowyParent")) {
  2382. rinfo->reinit_func = radeon_reinitialize_M10;
  2383. rinfo->pm_mode |= radeon_pm_off;
  2384. }
  2385. #if 0 /* Not ready yet */
  2386. if (!strcmp(rinfo->of_node->name, "ATY,BlueStoneParent")) {
  2387. rinfo->reinit_func = radeon_reinitialize_QW;
  2388. rinfo->pm_mode |= radeon_pm_off;
  2389. }
  2390. #endif
  2391. if (!strcmp(rinfo->of_node->name, "ATY,ViaParent")) {
  2392. rinfo->reinit_func = radeon_reinitialize_M9P;
  2393. rinfo->pm_mode |= radeon_pm_off;
  2394. }
  2395. /* If any of the above is set, we assume the machine can sleep/resume.
  2396. * It's a bit of a "shortcut" but will work fine. Ideally, we need infos
  2397. * from the platform about what happens to the chip...
  2398. * Now we tell the platform about our capability
  2399. */
  2400. if (rinfo->pm_mode != radeon_pm_none) {
  2401. pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, rinfo->of_node, 0, 1);
  2402. #if 0 /* Disable the early video resume hack for now as it's causing problems, among
  2403. * others we now rely on the PCI core restoring the config space for us, which
  2404. * isn't the case with that hack, and that code path causes various things to
  2405. * be called with interrupts off while they shouldn't. I'm leaving the code in
  2406. * as it can be useful for debugging purposes
  2407. */
  2408. pmac_set_early_video_resume(radeonfb_early_resume, rinfo);
  2409. #endif
  2410. }
  2411. #if 0
  2412. /* Power down TV DAC, that saves a significant amount of power,
  2413. * we'll have something better once we actually have some TVOut
  2414. * support
  2415. */
  2416. OUTREG(TV_DAC_CNTL, INREG(TV_DAC_CNTL) | 0x07000000);
  2417. #endif
  2418. }
  2419. #endif /* defined(CONFIG_PPC_PMAC) */
  2420. #endif /* defined(CONFIG_PM) */
  2421. if (ignore_devlist)
  2422. printk(KERN_DEBUG
  2423. "radeonfb: skipping test for device workarounds\n");
  2424. else
  2425. radeon_apply_workarounds(rinfo);
  2426. if (force_sleep) {
  2427. printk(KERN_DEBUG
  2428. "radeonfb: forcefully enabling D2 sleep mode\n");
  2429. rinfo->pm_mode |= radeon_pm_d2;
  2430. }
  2431. }
  2432. void radeonfb_pm_exit(struct radeonfb_info *rinfo)
  2433. {
  2434. #if defined(CONFIG_PM) && defined(CONFIG_PPC_PMAC)
  2435. if (rinfo->pm_mode != radeon_pm_none)
  2436. pmac_set_early_video_resume(NULL, NULL);
  2437. #endif
  2438. }