btc_dpm.c 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825
  1. /*
  2. * Copyright 2011 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Alex Deucher
  23. */
  24. #include "drmP.h"
  25. #include "radeon.h"
  26. #include "radeon_asic.h"
  27. #include "btcd.h"
  28. #include "r600_dpm.h"
  29. #include "cypress_dpm.h"
  30. #include "btc_dpm.h"
  31. #include "atom.h"
  32. #include <linux/seq_file.h>
  33. #define MC_CG_ARB_FREQ_F0 0x0a
  34. #define MC_CG_ARB_FREQ_F1 0x0b
  35. #define MC_CG_ARB_FREQ_F2 0x0c
  36. #define MC_CG_ARB_FREQ_F3 0x0d
  37. #define MC_CG_SEQ_DRAMCONF_S0 0x05
  38. #define MC_CG_SEQ_DRAMCONF_S1 0x06
  39. #define MC_CG_SEQ_YCLK_SUSPEND 0x04
  40. #define MC_CG_SEQ_YCLK_RESUME 0x0a
  41. #define SMC_RAM_END 0x8000
  42. #ifndef BTC_MGCG_SEQUENCE
  43. #define BTC_MGCG_SEQUENCE 300
  44. struct rv7xx_ps *rv770_get_ps(struct radeon_ps *rps);
  45. struct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev);
  46. struct evergreen_power_info *evergreen_get_pi(struct radeon_device *rdev);
  47. extern int ni_mc_load_microcode(struct radeon_device *rdev);
  48. //********* BARTS **************//
  49. static const u32 barts_cgcg_cgls_default[] =
  50. {
  51. /* Register, Value, Mask bits */
  52. 0x000008f8, 0x00000010, 0xffffffff,
  53. 0x000008fc, 0x00000000, 0xffffffff,
  54. 0x000008f8, 0x00000011, 0xffffffff,
  55. 0x000008fc, 0x00000000, 0xffffffff,
  56. 0x000008f8, 0x00000012, 0xffffffff,
  57. 0x000008fc, 0x00000000, 0xffffffff,
  58. 0x000008f8, 0x00000013, 0xffffffff,
  59. 0x000008fc, 0x00000000, 0xffffffff,
  60. 0x000008f8, 0x00000014, 0xffffffff,
  61. 0x000008fc, 0x00000000, 0xffffffff,
  62. 0x000008f8, 0x00000015, 0xffffffff,
  63. 0x000008fc, 0x00000000, 0xffffffff,
  64. 0x000008f8, 0x00000016, 0xffffffff,
  65. 0x000008fc, 0x00000000, 0xffffffff,
  66. 0x000008f8, 0x00000017, 0xffffffff,
  67. 0x000008fc, 0x00000000, 0xffffffff,
  68. 0x000008f8, 0x00000018, 0xffffffff,
  69. 0x000008fc, 0x00000000, 0xffffffff,
  70. 0x000008f8, 0x00000019, 0xffffffff,
  71. 0x000008fc, 0x00000000, 0xffffffff,
  72. 0x000008f8, 0x0000001a, 0xffffffff,
  73. 0x000008fc, 0x00000000, 0xffffffff,
  74. 0x000008f8, 0x0000001b, 0xffffffff,
  75. 0x000008fc, 0x00000000, 0xffffffff,
  76. 0x000008f8, 0x00000020, 0xffffffff,
  77. 0x000008fc, 0x00000000, 0xffffffff,
  78. 0x000008f8, 0x00000021, 0xffffffff,
  79. 0x000008fc, 0x00000000, 0xffffffff,
  80. 0x000008f8, 0x00000022, 0xffffffff,
  81. 0x000008fc, 0x00000000, 0xffffffff,
  82. 0x000008f8, 0x00000023, 0xffffffff,
  83. 0x000008fc, 0x00000000, 0xffffffff,
  84. 0x000008f8, 0x00000024, 0xffffffff,
  85. 0x000008fc, 0x00000000, 0xffffffff,
  86. 0x000008f8, 0x00000025, 0xffffffff,
  87. 0x000008fc, 0x00000000, 0xffffffff,
  88. 0x000008f8, 0x00000026, 0xffffffff,
  89. 0x000008fc, 0x00000000, 0xffffffff,
  90. 0x000008f8, 0x00000027, 0xffffffff,
  91. 0x000008fc, 0x00000000, 0xffffffff,
  92. 0x000008f8, 0x00000028, 0xffffffff,
  93. 0x000008fc, 0x00000000, 0xffffffff,
  94. 0x000008f8, 0x00000029, 0xffffffff,
  95. 0x000008fc, 0x00000000, 0xffffffff,
  96. 0x000008f8, 0x0000002a, 0xffffffff,
  97. 0x000008fc, 0x00000000, 0xffffffff,
  98. 0x000008f8, 0x0000002b, 0xffffffff,
  99. 0x000008fc, 0x00000000, 0xffffffff
  100. };
  101. #define BARTS_CGCG_CGLS_DEFAULT_LENGTH sizeof(barts_cgcg_cgls_default) / (3 * sizeof(u32))
  102. static const u32 barts_cgcg_cgls_disable[] =
  103. {
  104. 0x000008f8, 0x00000010, 0xffffffff,
  105. 0x000008fc, 0xffffffff, 0xffffffff,
  106. 0x000008f8, 0x00000011, 0xffffffff,
  107. 0x000008fc, 0xffffffff, 0xffffffff,
  108. 0x000008f8, 0x00000012, 0xffffffff,
  109. 0x000008fc, 0xffffffff, 0xffffffff,
  110. 0x000008f8, 0x00000013, 0xffffffff,
  111. 0x000008fc, 0xffffffff, 0xffffffff,
  112. 0x000008f8, 0x00000014, 0xffffffff,
  113. 0x000008fc, 0xffffffff, 0xffffffff,
  114. 0x000008f8, 0x00000015, 0xffffffff,
  115. 0x000008fc, 0xffffffff, 0xffffffff,
  116. 0x000008f8, 0x00000016, 0xffffffff,
  117. 0x000008fc, 0xffffffff, 0xffffffff,
  118. 0x000008f8, 0x00000017, 0xffffffff,
  119. 0x000008fc, 0xffffffff, 0xffffffff,
  120. 0x000008f8, 0x00000018, 0xffffffff,
  121. 0x000008fc, 0xffffffff, 0xffffffff,
  122. 0x000008f8, 0x00000019, 0xffffffff,
  123. 0x000008fc, 0xffffffff, 0xffffffff,
  124. 0x000008f8, 0x0000001a, 0xffffffff,
  125. 0x000008fc, 0xffffffff, 0xffffffff,
  126. 0x000008f8, 0x0000001b, 0xffffffff,
  127. 0x000008fc, 0xffffffff, 0xffffffff,
  128. 0x000008f8, 0x00000020, 0xffffffff,
  129. 0x000008fc, 0x00000000, 0xffffffff,
  130. 0x000008f8, 0x00000021, 0xffffffff,
  131. 0x000008fc, 0x00000000, 0xffffffff,
  132. 0x000008f8, 0x00000022, 0xffffffff,
  133. 0x000008fc, 0x00000000, 0xffffffff,
  134. 0x000008f8, 0x00000023, 0xffffffff,
  135. 0x000008fc, 0x00000000, 0xffffffff,
  136. 0x000008f8, 0x00000024, 0xffffffff,
  137. 0x000008fc, 0x00000000, 0xffffffff,
  138. 0x000008f8, 0x00000025, 0xffffffff,
  139. 0x000008fc, 0x00000000, 0xffffffff,
  140. 0x000008f8, 0x00000026, 0xffffffff,
  141. 0x000008fc, 0x00000000, 0xffffffff,
  142. 0x000008f8, 0x00000027, 0xffffffff,
  143. 0x000008fc, 0x00000000, 0xffffffff,
  144. 0x000008f8, 0x00000028, 0xffffffff,
  145. 0x000008fc, 0x00000000, 0xffffffff,
  146. 0x000008f8, 0x00000029, 0xffffffff,
  147. 0x000008fc, 0x00000000, 0xffffffff,
  148. 0x000008f8, 0x0000002a, 0xffffffff,
  149. 0x000008fc, 0x00000000, 0xffffffff,
  150. 0x000008f8, 0x0000002b, 0xffffffff,
  151. 0x000008fc, 0x00000000, 0xffffffff,
  152. 0x00000644, 0x000f7912, 0x001f4180,
  153. 0x00000644, 0x000f3812, 0x001f4180
  154. };
  155. #define BARTS_CGCG_CGLS_DISABLE_LENGTH sizeof(barts_cgcg_cgls_disable) / (3 * sizeof(u32))
  156. static const u32 barts_cgcg_cgls_enable[] =
  157. {
  158. /* 0x0000c124, 0x84180000, 0x00180000, */
  159. 0x00000644, 0x000f7892, 0x001f4080,
  160. 0x000008f8, 0x00000010, 0xffffffff,
  161. 0x000008fc, 0x00000000, 0xffffffff,
  162. 0x000008f8, 0x00000011, 0xffffffff,
  163. 0x000008fc, 0x00000000, 0xffffffff,
  164. 0x000008f8, 0x00000012, 0xffffffff,
  165. 0x000008fc, 0x00000000, 0xffffffff,
  166. 0x000008f8, 0x00000013, 0xffffffff,
  167. 0x000008fc, 0x00000000, 0xffffffff,
  168. 0x000008f8, 0x00000014, 0xffffffff,
  169. 0x000008fc, 0x00000000, 0xffffffff,
  170. 0x000008f8, 0x00000015, 0xffffffff,
  171. 0x000008fc, 0x00000000, 0xffffffff,
  172. 0x000008f8, 0x00000016, 0xffffffff,
  173. 0x000008fc, 0x00000000, 0xffffffff,
  174. 0x000008f8, 0x00000017, 0xffffffff,
  175. 0x000008fc, 0x00000000, 0xffffffff,
  176. 0x000008f8, 0x00000018, 0xffffffff,
  177. 0x000008fc, 0x00000000, 0xffffffff,
  178. 0x000008f8, 0x00000019, 0xffffffff,
  179. 0x000008fc, 0x00000000, 0xffffffff,
  180. 0x000008f8, 0x0000001a, 0xffffffff,
  181. 0x000008fc, 0x00000000, 0xffffffff,
  182. 0x000008f8, 0x0000001b, 0xffffffff,
  183. 0x000008fc, 0x00000000, 0xffffffff,
  184. 0x000008f8, 0x00000020, 0xffffffff,
  185. 0x000008fc, 0xffffffff, 0xffffffff,
  186. 0x000008f8, 0x00000021, 0xffffffff,
  187. 0x000008fc, 0xffffffff, 0xffffffff,
  188. 0x000008f8, 0x00000022, 0xffffffff,
  189. 0x000008fc, 0xffffffff, 0xffffffff,
  190. 0x000008f8, 0x00000023, 0xffffffff,
  191. 0x000008fc, 0xffffffff, 0xffffffff,
  192. 0x000008f8, 0x00000024, 0xffffffff,
  193. 0x000008fc, 0xffffffff, 0xffffffff,
  194. 0x000008f8, 0x00000025, 0xffffffff,
  195. 0x000008fc, 0xffffffff, 0xffffffff,
  196. 0x000008f8, 0x00000026, 0xffffffff,
  197. 0x000008fc, 0xffffffff, 0xffffffff,
  198. 0x000008f8, 0x00000027, 0xffffffff,
  199. 0x000008fc, 0xffffffff, 0xffffffff,
  200. 0x000008f8, 0x00000028, 0xffffffff,
  201. 0x000008fc, 0xffffffff, 0xffffffff,
  202. 0x000008f8, 0x00000029, 0xffffffff,
  203. 0x000008fc, 0xffffffff, 0xffffffff,
  204. 0x000008f8, 0x0000002a, 0xffffffff,
  205. 0x000008fc, 0xffffffff, 0xffffffff,
  206. 0x000008f8, 0x0000002b, 0xffffffff,
  207. 0x000008fc, 0xffffffff, 0xffffffff
  208. };
  209. #define BARTS_CGCG_CGLS_ENABLE_LENGTH sizeof(barts_cgcg_cgls_enable) / (3 * sizeof(u32))
  210. static const u32 barts_mgcg_default[] =
  211. {
  212. 0x0000802c, 0xc0000000, 0xffffffff,
  213. 0x00005448, 0x00000100, 0xffffffff,
  214. 0x000055e4, 0x00600100, 0xffffffff,
  215. 0x0000160c, 0x00000100, 0xffffffff,
  216. 0x0000c164, 0x00000100, 0xffffffff,
  217. 0x00008a18, 0x00000100, 0xffffffff,
  218. 0x0000897c, 0x06000100, 0xffffffff,
  219. 0x00008b28, 0x00000100, 0xffffffff,
  220. 0x00009144, 0x00000100, 0xffffffff,
  221. 0x00009a60, 0x00000100, 0xffffffff,
  222. 0x00009868, 0x00000100, 0xffffffff,
  223. 0x00008d58, 0x00000100, 0xffffffff,
  224. 0x00009510, 0x00000100, 0xffffffff,
  225. 0x0000949c, 0x00000100, 0xffffffff,
  226. 0x00009654, 0x00000100, 0xffffffff,
  227. 0x00009030, 0x00000100, 0xffffffff,
  228. 0x00009034, 0x00000100, 0xffffffff,
  229. 0x00009038, 0x00000100, 0xffffffff,
  230. 0x0000903c, 0x00000100, 0xffffffff,
  231. 0x00009040, 0x00000100, 0xffffffff,
  232. 0x0000a200, 0x00000100, 0xffffffff,
  233. 0x0000a204, 0x00000100, 0xffffffff,
  234. 0x0000a208, 0x00000100, 0xffffffff,
  235. 0x0000a20c, 0x00000100, 0xffffffff,
  236. 0x0000977c, 0x00000100, 0xffffffff,
  237. 0x00003f80, 0x00000100, 0xffffffff,
  238. 0x0000a210, 0x00000100, 0xffffffff,
  239. 0x0000a214, 0x00000100, 0xffffffff,
  240. 0x000004d8, 0x00000100, 0xffffffff,
  241. 0x00009784, 0x00000100, 0xffffffff,
  242. 0x00009698, 0x00000100, 0xffffffff,
  243. 0x000004d4, 0x00000200, 0xffffffff,
  244. 0x000004d0, 0x00000000, 0xffffffff,
  245. 0x000030cc, 0x00000100, 0xffffffff,
  246. 0x0000d0c0, 0xff000100, 0xffffffff,
  247. 0x0000802c, 0x40000000, 0xffffffff,
  248. 0x0000915c, 0x00010000, 0xffffffff,
  249. 0x00009160, 0x00030002, 0xffffffff,
  250. 0x00009164, 0x00050004, 0xffffffff,
  251. 0x00009168, 0x00070006, 0xffffffff,
  252. 0x00009178, 0x00070000, 0xffffffff,
  253. 0x0000917c, 0x00030002, 0xffffffff,
  254. 0x00009180, 0x00050004, 0xffffffff,
  255. 0x0000918c, 0x00010006, 0xffffffff,
  256. 0x00009190, 0x00090008, 0xffffffff,
  257. 0x00009194, 0x00070000, 0xffffffff,
  258. 0x00009198, 0x00030002, 0xffffffff,
  259. 0x0000919c, 0x00050004, 0xffffffff,
  260. 0x000091a8, 0x00010006, 0xffffffff,
  261. 0x000091ac, 0x00090008, 0xffffffff,
  262. 0x000091b0, 0x00070000, 0xffffffff,
  263. 0x000091b4, 0x00030002, 0xffffffff,
  264. 0x000091b8, 0x00050004, 0xffffffff,
  265. 0x000091c4, 0x00010006, 0xffffffff,
  266. 0x000091c8, 0x00090008, 0xffffffff,
  267. 0x000091cc, 0x00070000, 0xffffffff,
  268. 0x000091d0, 0x00030002, 0xffffffff,
  269. 0x000091d4, 0x00050004, 0xffffffff,
  270. 0x000091e0, 0x00010006, 0xffffffff,
  271. 0x000091e4, 0x00090008, 0xffffffff,
  272. 0x000091e8, 0x00000000, 0xffffffff,
  273. 0x000091ec, 0x00070000, 0xffffffff,
  274. 0x000091f0, 0x00030002, 0xffffffff,
  275. 0x000091f4, 0x00050004, 0xffffffff,
  276. 0x00009200, 0x00010006, 0xffffffff,
  277. 0x00009204, 0x00090008, 0xffffffff,
  278. 0x00009208, 0x00070000, 0xffffffff,
  279. 0x0000920c, 0x00030002, 0xffffffff,
  280. 0x00009210, 0x00050004, 0xffffffff,
  281. 0x0000921c, 0x00010006, 0xffffffff,
  282. 0x00009220, 0x00090008, 0xffffffff,
  283. 0x00009224, 0x00070000, 0xffffffff,
  284. 0x00009228, 0x00030002, 0xffffffff,
  285. 0x0000922c, 0x00050004, 0xffffffff,
  286. 0x00009238, 0x00010006, 0xffffffff,
  287. 0x0000923c, 0x00090008, 0xffffffff,
  288. 0x00009294, 0x00000000, 0xffffffff,
  289. 0x0000802c, 0x40010000, 0xffffffff,
  290. 0x0000915c, 0x00010000, 0xffffffff,
  291. 0x00009160, 0x00030002, 0xffffffff,
  292. 0x00009164, 0x00050004, 0xffffffff,
  293. 0x00009168, 0x00070006, 0xffffffff,
  294. 0x00009178, 0x00070000, 0xffffffff,
  295. 0x0000917c, 0x00030002, 0xffffffff,
  296. 0x00009180, 0x00050004, 0xffffffff,
  297. 0x0000918c, 0x00010006, 0xffffffff,
  298. 0x00009190, 0x00090008, 0xffffffff,
  299. 0x00009194, 0x00070000, 0xffffffff,
  300. 0x00009198, 0x00030002, 0xffffffff,
  301. 0x0000919c, 0x00050004, 0xffffffff,
  302. 0x000091a8, 0x00010006, 0xffffffff,
  303. 0x000091ac, 0x00090008, 0xffffffff,
  304. 0x000091b0, 0x00070000, 0xffffffff,
  305. 0x000091b4, 0x00030002, 0xffffffff,
  306. 0x000091b8, 0x00050004, 0xffffffff,
  307. 0x000091c4, 0x00010006, 0xffffffff,
  308. 0x000091c8, 0x00090008, 0xffffffff,
  309. 0x000091cc, 0x00070000, 0xffffffff,
  310. 0x000091d0, 0x00030002, 0xffffffff,
  311. 0x000091d4, 0x00050004, 0xffffffff,
  312. 0x000091e0, 0x00010006, 0xffffffff,
  313. 0x000091e4, 0x00090008, 0xffffffff,
  314. 0x000091e8, 0x00000000, 0xffffffff,
  315. 0x000091ec, 0x00070000, 0xffffffff,
  316. 0x000091f0, 0x00030002, 0xffffffff,
  317. 0x000091f4, 0x00050004, 0xffffffff,
  318. 0x00009200, 0x00010006, 0xffffffff,
  319. 0x00009204, 0x00090008, 0xffffffff,
  320. 0x00009208, 0x00070000, 0xffffffff,
  321. 0x0000920c, 0x00030002, 0xffffffff,
  322. 0x00009210, 0x00050004, 0xffffffff,
  323. 0x0000921c, 0x00010006, 0xffffffff,
  324. 0x00009220, 0x00090008, 0xffffffff,
  325. 0x00009224, 0x00070000, 0xffffffff,
  326. 0x00009228, 0x00030002, 0xffffffff,
  327. 0x0000922c, 0x00050004, 0xffffffff,
  328. 0x00009238, 0x00010006, 0xffffffff,
  329. 0x0000923c, 0x00090008, 0xffffffff,
  330. 0x00009294, 0x00000000, 0xffffffff,
  331. 0x0000802c, 0xc0000000, 0xffffffff,
  332. 0x000008f8, 0x00000010, 0xffffffff,
  333. 0x000008fc, 0x00000000, 0xffffffff,
  334. 0x000008f8, 0x00000011, 0xffffffff,
  335. 0x000008fc, 0x00000000, 0xffffffff,
  336. 0x000008f8, 0x00000012, 0xffffffff,
  337. 0x000008fc, 0x00000000, 0xffffffff,
  338. 0x000008f8, 0x00000013, 0xffffffff,
  339. 0x000008fc, 0x00000000, 0xffffffff,
  340. 0x000008f8, 0x00000014, 0xffffffff,
  341. 0x000008fc, 0x00000000, 0xffffffff,
  342. 0x000008f8, 0x00000015, 0xffffffff,
  343. 0x000008fc, 0x00000000, 0xffffffff,
  344. 0x000008f8, 0x00000016, 0xffffffff,
  345. 0x000008fc, 0x00000000, 0xffffffff,
  346. 0x000008f8, 0x00000017, 0xffffffff,
  347. 0x000008fc, 0x00000000, 0xffffffff,
  348. 0x000008f8, 0x00000018, 0xffffffff,
  349. 0x000008fc, 0x00000000, 0xffffffff,
  350. 0x000008f8, 0x00000019, 0xffffffff,
  351. 0x000008fc, 0x00000000, 0xffffffff,
  352. 0x000008f8, 0x0000001a, 0xffffffff,
  353. 0x000008fc, 0x00000000, 0xffffffff,
  354. 0x000008f8, 0x0000001b, 0xffffffff,
  355. 0x000008fc, 0x00000000, 0xffffffff
  356. };
  357. #define BARTS_MGCG_DEFAULT_LENGTH sizeof(barts_mgcg_default) / (3 * sizeof(u32))
  358. static const u32 barts_mgcg_disable[] =
  359. {
  360. 0x0000802c, 0xc0000000, 0xffffffff,
  361. 0x000008f8, 0x00000000, 0xffffffff,
  362. 0x000008fc, 0xffffffff, 0xffffffff,
  363. 0x000008f8, 0x00000001, 0xffffffff,
  364. 0x000008fc, 0xffffffff, 0xffffffff,
  365. 0x000008f8, 0x00000002, 0xffffffff,
  366. 0x000008fc, 0xffffffff, 0xffffffff,
  367. 0x000008f8, 0x00000003, 0xffffffff,
  368. 0x000008fc, 0xffffffff, 0xffffffff,
  369. 0x00009150, 0x00600000, 0xffffffff
  370. };
  371. #define BARTS_MGCG_DISABLE_LENGTH sizeof(barts_mgcg_disable) / (3 * sizeof(u32))
  372. static const u32 barts_mgcg_enable[] =
  373. {
  374. 0x0000802c, 0xc0000000, 0xffffffff,
  375. 0x000008f8, 0x00000000, 0xffffffff,
  376. 0x000008fc, 0x00000000, 0xffffffff,
  377. 0x000008f8, 0x00000001, 0xffffffff,
  378. 0x000008fc, 0x00000000, 0xffffffff,
  379. 0x000008f8, 0x00000002, 0xffffffff,
  380. 0x000008fc, 0x00000000, 0xffffffff,
  381. 0x000008f8, 0x00000003, 0xffffffff,
  382. 0x000008fc, 0x00000000, 0xffffffff,
  383. 0x00009150, 0x81944000, 0xffffffff
  384. };
  385. #define BARTS_MGCG_ENABLE_LENGTH sizeof(barts_mgcg_enable) / (3 * sizeof(u32))
  386. //********* CAICOS **************//
  387. static const u32 caicos_cgcg_cgls_default[] =
  388. {
  389. 0x000008f8, 0x00000010, 0xffffffff,
  390. 0x000008fc, 0x00000000, 0xffffffff,
  391. 0x000008f8, 0x00000011, 0xffffffff,
  392. 0x000008fc, 0x00000000, 0xffffffff,
  393. 0x000008f8, 0x00000012, 0xffffffff,
  394. 0x000008fc, 0x00000000, 0xffffffff,
  395. 0x000008f8, 0x00000013, 0xffffffff,
  396. 0x000008fc, 0x00000000, 0xffffffff,
  397. 0x000008f8, 0x00000014, 0xffffffff,
  398. 0x000008fc, 0x00000000, 0xffffffff,
  399. 0x000008f8, 0x00000015, 0xffffffff,
  400. 0x000008fc, 0x00000000, 0xffffffff,
  401. 0x000008f8, 0x00000016, 0xffffffff,
  402. 0x000008fc, 0x00000000, 0xffffffff,
  403. 0x000008f8, 0x00000017, 0xffffffff,
  404. 0x000008fc, 0x00000000, 0xffffffff,
  405. 0x000008f8, 0x00000018, 0xffffffff,
  406. 0x000008fc, 0x00000000, 0xffffffff,
  407. 0x000008f8, 0x00000019, 0xffffffff,
  408. 0x000008fc, 0x00000000, 0xffffffff,
  409. 0x000008f8, 0x0000001a, 0xffffffff,
  410. 0x000008fc, 0x00000000, 0xffffffff,
  411. 0x000008f8, 0x0000001b, 0xffffffff,
  412. 0x000008fc, 0x00000000, 0xffffffff,
  413. 0x000008f8, 0x00000020, 0xffffffff,
  414. 0x000008fc, 0x00000000, 0xffffffff,
  415. 0x000008f8, 0x00000021, 0xffffffff,
  416. 0x000008fc, 0x00000000, 0xffffffff,
  417. 0x000008f8, 0x00000022, 0xffffffff,
  418. 0x000008fc, 0x00000000, 0xffffffff,
  419. 0x000008f8, 0x00000023, 0xffffffff,
  420. 0x000008fc, 0x00000000, 0xffffffff,
  421. 0x000008f8, 0x00000024, 0xffffffff,
  422. 0x000008fc, 0x00000000, 0xffffffff,
  423. 0x000008f8, 0x00000025, 0xffffffff,
  424. 0x000008fc, 0x00000000, 0xffffffff,
  425. 0x000008f8, 0x00000026, 0xffffffff,
  426. 0x000008fc, 0x00000000, 0xffffffff,
  427. 0x000008f8, 0x00000027, 0xffffffff,
  428. 0x000008fc, 0x00000000, 0xffffffff,
  429. 0x000008f8, 0x00000028, 0xffffffff,
  430. 0x000008fc, 0x00000000, 0xffffffff,
  431. 0x000008f8, 0x00000029, 0xffffffff,
  432. 0x000008fc, 0x00000000, 0xffffffff,
  433. 0x000008f8, 0x0000002a, 0xffffffff,
  434. 0x000008fc, 0x00000000, 0xffffffff,
  435. 0x000008f8, 0x0000002b, 0xffffffff,
  436. 0x000008fc, 0x00000000, 0xffffffff
  437. };
  438. #define CAICOS_CGCG_CGLS_DEFAULT_LENGTH sizeof(caicos_cgcg_cgls_default) / (3 * sizeof(u32))
  439. static const u32 caicos_cgcg_cgls_disable[] =
  440. {
  441. 0x000008f8, 0x00000010, 0xffffffff,
  442. 0x000008fc, 0xffffffff, 0xffffffff,
  443. 0x000008f8, 0x00000011, 0xffffffff,
  444. 0x000008fc, 0xffffffff, 0xffffffff,
  445. 0x000008f8, 0x00000012, 0xffffffff,
  446. 0x000008fc, 0xffffffff, 0xffffffff,
  447. 0x000008f8, 0x00000013, 0xffffffff,
  448. 0x000008fc, 0xffffffff, 0xffffffff,
  449. 0x000008f8, 0x00000014, 0xffffffff,
  450. 0x000008fc, 0xffffffff, 0xffffffff,
  451. 0x000008f8, 0x00000015, 0xffffffff,
  452. 0x000008fc, 0xffffffff, 0xffffffff,
  453. 0x000008f8, 0x00000016, 0xffffffff,
  454. 0x000008fc, 0xffffffff, 0xffffffff,
  455. 0x000008f8, 0x00000017, 0xffffffff,
  456. 0x000008fc, 0xffffffff, 0xffffffff,
  457. 0x000008f8, 0x00000018, 0xffffffff,
  458. 0x000008fc, 0xffffffff, 0xffffffff,
  459. 0x000008f8, 0x00000019, 0xffffffff,
  460. 0x000008fc, 0xffffffff, 0xffffffff,
  461. 0x000008f8, 0x0000001a, 0xffffffff,
  462. 0x000008fc, 0xffffffff, 0xffffffff,
  463. 0x000008f8, 0x0000001b, 0xffffffff,
  464. 0x000008fc, 0xffffffff, 0xffffffff,
  465. 0x000008f8, 0x00000020, 0xffffffff,
  466. 0x000008fc, 0x00000000, 0xffffffff,
  467. 0x000008f8, 0x00000021, 0xffffffff,
  468. 0x000008fc, 0x00000000, 0xffffffff,
  469. 0x000008f8, 0x00000022, 0xffffffff,
  470. 0x000008fc, 0x00000000, 0xffffffff,
  471. 0x000008f8, 0x00000023, 0xffffffff,
  472. 0x000008fc, 0x00000000, 0xffffffff,
  473. 0x000008f8, 0x00000024, 0xffffffff,
  474. 0x000008fc, 0x00000000, 0xffffffff,
  475. 0x000008f8, 0x00000025, 0xffffffff,
  476. 0x000008fc, 0x00000000, 0xffffffff,
  477. 0x000008f8, 0x00000026, 0xffffffff,
  478. 0x000008fc, 0x00000000, 0xffffffff,
  479. 0x000008f8, 0x00000027, 0xffffffff,
  480. 0x000008fc, 0x00000000, 0xffffffff,
  481. 0x000008f8, 0x00000028, 0xffffffff,
  482. 0x000008fc, 0x00000000, 0xffffffff,
  483. 0x000008f8, 0x00000029, 0xffffffff,
  484. 0x000008fc, 0x00000000, 0xffffffff,
  485. 0x000008f8, 0x0000002a, 0xffffffff,
  486. 0x000008fc, 0x00000000, 0xffffffff,
  487. 0x000008f8, 0x0000002b, 0xffffffff,
  488. 0x000008fc, 0x00000000, 0xffffffff,
  489. 0x00000644, 0x000f7912, 0x001f4180,
  490. 0x00000644, 0x000f3812, 0x001f4180
  491. };
  492. #define CAICOS_CGCG_CGLS_DISABLE_LENGTH sizeof(caicos_cgcg_cgls_disable) / (3 * sizeof(u32))
  493. static const u32 caicos_cgcg_cgls_enable[] =
  494. {
  495. /* 0x0000c124, 0x84180000, 0x00180000, */
  496. 0x00000644, 0x000f7892, 0x001f4080,
  497. 0x000008f8, 0x00000010, 0xffffffff,
  498. 0x000008fc, 0x00000000, 0xffffffff,
  499. 0x000008f8, 0x00000011, 0xffffffff,
  500. 0x000008fc, 0x00000000, 0xffffffff,
  501. 0x000008f8, 0x00000012, 0xffffffff,
  502. 0x000008fc, 0x00000000, 0xffffffff,
  503. 0x000008f8, 0x00000013, 0xffffffff,
  504. 0x000008fc, 0x00000000, 0xffffffff,
  505. 0x000008f8, 0x00000014, 0xffffffff,
  506. 0x000008fc, 0x00000000, 0xffffffff,
  507. 0x000008f8, 0x00000015, 0xffffffff,
  508. 0x000008fc, 0x00000000, 0xffffffff,
  509. 0x000008f8, 0x00000016, 0xffffffff,
  510. 0x000008fc, 0x00000000, 0xffffffff,
  511. 0x000008f8, 0x00000017, 0xffffffff,
  512. 0x000008fc, 0x00000000, 0xffffffff,
  513. 0x000008f8, 0x00000018, 0xffffffff,
  514. 0x000008fc, 0x00000000, 0xffffffff,
  515. 0x000008f8, 0x00000019, 0xffffffff,
  516. 0x000008fc, 0x00000000, 0xffffffff,
  517. 0x000008f8, 0x0000001a, 0xffffffff,
  518. 0x000008fc, 0x00000000, 0xffffffff,
  519. 0x000008f8, 0x0000001b, 0xffffffff,
  520. 0x000008fc, 0x00000000, 0xffffffff,
  521. 0x000008f8, 0x00000020, 0xffffffff,
  522. 0x000008fc, 0xffffffff, 0xffffffff,
  523. 0x000008f8, 0x00000021, 0xffffffff,
  524. 0x000008fc, 0xffffffff, 0xffffffff,
  525. 0x000008f8, 0x00000022, 0xffffffff,
  526. 0x000008fc, 0xffffffff, 0xffffffff,
  527. 0x000008f8, 0x00000023, 0xffffffff,
  528. 0x000008fc, 0xffffffff, 0xffffffff,
  529. 0x000008f8, 0x00000024, 0xffffffff,
  530. 0x000008fc, 0xffffffff, 0xffffffff,
  531. 0x000008f8, 0x00000025, 0xffffffff,
  532. 0x000008fc, 0xffffffff, 0xffffffff,
  533. 0x000008f8, 0x00000026, 0xffffffff,
  534. 0x000008fc, 0xffffffff, 0xffffffff,
  535. 0x000008f8, 0x00000027, 0xffffffff,
  536. 0x000008fc, 0xffffffff, 0xffffffff,
  537. 0x000008f8, 0x00000028, 0xffffffff,
  538. 0x000008fc, 0xffffffff, 0xffffffff,
  539. 0x000008f8, 0x00000029, 0xffffffff,
  540. 0x000008fc, 0xffffffff, 0xffffffff,
  541. 0x000008f8, 0x0000002a, 0xffffffff,
  542. 0x000008fc, 0xffffffff, 0xffffffff,
  543. 0x000008f8, 0x0000002b, 0xffffffff,
  544. 0x000008fc, 0xffffffff, 0xffffffff
  545. };
  546. #define CAICOS_CGCG_CGLS_ENABLE_LENGTH sizeof(caicos_cgcg_cgls_enable) / (3 * sizeof(u32))
  547. static const u32 caicos_mgcg_default[] =
  548. {
  549. 0x0000802c, 0xc0000000, 0xffffffff,
  550. 0x00005448, 0x00000100, 0xffffffff,
  551. 0x000055e4, 0x00600100, 0xffffffff,
  552. 0x0000160c, 0x00000100, 0xffffffff,
  553. 0x0000c164, 0x00000100, 0xffffffff,
  554. 0x00008a18, 0x00000100, 0xffffffff,
  555. 0x0000897c, 0x06000100, 0xffffffff,
  556. 0x00008b28, 0x00000100, 0xffffffff,
  557. 0x00009144, 0x00000100, 0xffffffff,
  558. 0x00009a60, 0x00000100, 0xffffffff,
  559. 0x00009868, 0x00000100, 0xffffffff,
  560. 0x00008d58, 0x00000100, 0xffffffff,
  561. 0x00009510, 0x00000100, 0xffffffff,
  562. 0x0000949c, 0x00000100, 0xffffffff,
  563. 0x00009654, 0x00000100, 0xffffffff,
  564. 0x00009030, 0x00000100, 0xffffffff,
  565. 0x00009034, 0x00000100, 0xffffffff,
  566. 0x00009038, 0x00000100, 0xffffffff,
  567. 0x0000903c, 0x00000100, 0xffffffff,
  568. 0x00009040, 0x00000100, 0xffffffff,
  569. 0x0000a200, 0x00000100, 0xffffffff,
  570. 0x0000a204, 0x00000100, 0xffffffff,
  571. 0x0000a208, 0x00000100, 0xffffffff,
  572. 0x0000a20c, 0x00000100, 0xffffffff,
  573. 0x0000977c, 0x00000100, 0xffffffff,
  574. 0x00003f80, 0x00000100, 0xffffffff,
  575. 0x0000a210, 0x00000100, 0xffffffff,
  576. 0x0000a214, 0x00000100, 0xffffffff,
  577. 0x000004d8, 0x00000100, 0xffffffff,
  578. 0x00009784, 0x00000100, 0xffffffff,
  579. 0x00009698, 0x00000100, 0xffffffff,
  580. 0x000004d4, 0x00000200, 0xffffffff,
  581. 0x000004d0, 0x00000000, 0xffffffff,
  582. 0x000030cc, 0x00000100, 0xffffffff,
  583. 0x0000d0c0, 0xff000100, 0xffffffff,
  584. 0x0000915c, 0x00010000, 0xffffffff,
  585. 0x00009160, 0x00030002, 0xffffffff,
  586. 0x00009164, 0x00050004, 0xffffffff,
  587. 0x00009168, 0x00070006, 0xffffffff,
  588. 0x00009178, 0x00070000, 0xffffffff,
  589. 0x0000917c, 0x00030002, 0xffffffff,
  590. 0x00009180, 0x00050004, 0xffffffff,
  591. 0x0000918c, 0x00010006, 0xffffffff,
  592. 0x00009190, 0x00090008, 0xffffffff,
  593. 0x00009194, 0x00070000, 0xffffffff,
  594. 0x00009198, 0x00030002, 0xffffffff,
  595. 0x0000919c, 0x00050004, 0xffffffff,
  596. 0x000091a8, 0x00010006, 0xffffffff,
  597. 0x000091ac, 0x00090008, 0xffffffff,
  598. 0x000091e8, 0x00000000, 0xffffffff,
  599. 0x00009294, 0x00000000, 0xffffffff,
  600. 0x000008f8, 0x00000010, 0xffffffff,
  601. 0x000008fc, 0x00000000, 0xffffffff,
  602. 0x000008f8, 0x00000011, 0xffffffff,
  603. 0x000008fc, 0x00000000, 0xffffffff,
  604. 0x000008f8, 0x00000012, 0xffffffff,
  605. 0x000008fc, 0x00000000, 0xffffffff,
  606. 0x000008f8, 0x00000013, 0xffffffff,
  607. 0x000008fc, 0x00000000, 0xffffffff,
  608. 0x000008f8, 0x00000014, 0xffffffff,
  609. 0x000008fc, 0x00000000, 0xffffffff,
  610. 0x000008f8, 0x00000015, 0xffffffff,
  611. 0x000008fc, 0x00000000, 0xffffffff,
  612. 0x000008f8, 0x00000016, 0xffffffff,
  613. 0x000008fc, 0x00000000, 0xffffffff,
  614. 0x000008f8, 0x00000017, 0xffffffff,
  615. 0x000008fc, 0x00000000, 0xffffffff,
  616. 0x000008f8, 0x00000018, 0xffffffff,
  617. 0x000008fc, 0x00000000, 0xffffffff,
  618. 0x000008f8, 0x00000019, 0xffffffff,
  619. 0x000008fc, 0x00000000, 0xffffffff,
  620. 0x000008f8, 0x0000001a, 0xffffffff,
  621. 0x000008fc, 0x00000000, 0xffffffff,
  622. 0x000008f8, 0x0000001b, 0xffffffff,
  623. 0x000008fc, 0x00000000, 0xffffffff
  624. };
  625. #define CAICOS_MGCG_DEFAULT_LENGTH sizeof(caicos_mgcg_default) / (3 * sizeof(u32))
  626. static const u32 caicos_mgcg_disable[] =
  627. {
  628. 0x0000802c, 0xc0000000, 0xffffffff,
  629. 0x000008f8, 0x00000000, 0xffffffff,
  630. 0x000008fc, 0xffffffff, 0xffffffff,
  631. 0x000008f8, 0x00000001, 0xffffffff,
  632. 0x000008fc, 0xffffffff, 0xffffffff,
  633. 0x000008f8, 0x00000002, 0xffffffff,
  634. 0x000008fc, 0xffffffff, 0xffffffff,
  635. 0x000008f8, 0x00000003, 0xffffffff,
  636. 0x000008fc, 0xffffffff, 0xffffffff,
  637. 0x00009150, 0x00600000, 0xffffffff
  638. };
  639. #define CAICOS_MGCG_DISABLE_LENGTH sizeof(caicos_mgcg_disable) / (3 * sizeof(u32))
  640. static const u32 caicos_mgcg_enable[] =
  641. {
  642. 0x0000802c, 0xc0000000, 0xffffffff,
  643. 0x000008f8, 0x00000000, 0xffffffff,
  644. 0x000008fc, 0x00000000, 0xffffffff,
  645. 0x000008f8, 0x00000001, 0xffffffff,
  646. 0x000008fc, 0x00000000, 0xffffffff,
  647. 0x000008f8, 0x00000002, 0xffffffff,
  648. 0x000008fc, 0x00000000, 0xffffffff,
  649. 0x000008f8, 0x00000003, 0xffffffff,
  650. 0x000008fc, 0x00000000, 0xffffffff,
  651. 0x00009150, 0x46944040, 0xffffffff
  652. };
  653. #define CAICOS_MGCG_ENABLE_LENGTH sizeof(caicos_mgcg_enable) / (3 * sizeof(u32))
  654. //********* TURKS **************//
  655. static const u32 turks_cgcg_cgls_default[] =
  656. {
  657. 0x000008f8, 0x00000010, 0xffffffff,
  658. 0x000008fc, 0x00000000, 0xffffffff,
  659. 0x000008f8, 0x00000011, 0xffffffff,
  660. 0x000008fc, 0x00000000, 0xffffffff,
  661. 0x000008f8, 0x00000012, 0xffffffff,
  662. 0x000008fc, 0x00000000, 0xffffffff,
  663. 0x000008f8, 0x00000013, 0xffffffff,
  664. 0x000008fc, 0x00000000, 0xffffffff,
  665. 0x000008f8, 0x00000014, 0xffffffff,
  666. 0x000008fc, 0x00000000, 0xffffffff,
  667. 0x000008f8, 0x00000015, 0xffffffff,
  668. 0x000008fc, 0x00000000, 0xffffffff,
  669. 0x000008f8, 0x00000016, 0xffffffff,
  670. 0x000008fc, 0x00000000, 0xffffffff,
  671. 0x000008f8, 0x00000017, 0xffffffff,
  672. 0x000008fc, 0x00000000, 0xffffffff,
  673. 0x000008f8, 0x00000018, 0xffffffff,
  674. 0x000008fc, 0x00000000, 0xffffffff,
  675. 0x000008f8, 0x00000019, 0xffffffff,
  676. 0x000008fc, 0x00000000, 0xffffffff,
  677. 0x000008f8, 0x0000001a, 0xffffffff,
  678. 0x000008fc, 0x00000000, 0xffffffff,
  679. 0x000008f8, 0x0000001b, 0xffffffff,
  680. 0x000008fc, 0x00000000, 0xffffffff,
  681. 0x000008f8, 0x00000020, 0xffffffff,
  682. 0x000008fc, 0x00000000, 0xffffffff,
  683. 0x000008f8, 0x00000021, 0xffffffff,
  684. 0x000008fc, 0x00000000, 0xffffffff,
  685. 0x000008f8, 0x00000022, 0xffffffff,
  686. 0x000008fc, 0x00000000, 0xffffffff,
  687. 0x000008f8, 0x00000023, 0xffffffff,
  688. 0x000008fc, 0x00000000, 0xffffffff,
  689. 0x000008f8, 0x00000024, 0xffffffff,
  690. 0x000008fc, 0x00000000, 0xffffffff,
  691. 0x000008f8, 0x00000025, 0xffffffff,
  692. 0x000008fc, 0x00000000, 0xffffffff,
  693. 0x000008f8, 0x00000026, 0xffffffff,
  694. 0x000008fc, 0x00000000, 0xffffffff,
  695. 0x000008f8, 0x00000027, 0xffffffff,
  696. 0x000008fc, 0x00000000, 0xffffffff,
  697. 0x000008f8, 0x00000028, 0xffffffff,
  698. 0x000008fc, 0x00000000, 0xffffffff,
  699. 0x000008f8, 0x00000029, 0xffffffff,
  700. 0x000008fc, 0x00000000, 0xffffffff,
  701. 0x000008f8, 0x0000002a, 0xffffffff,
  702. 0x000008fc, 0x00000000, 0xffffffff,
  703. 0x000008f8, 0x0000002b, 0xffffffff,
  704. 0x000008fc, 0x00000000, 0xffffffff
  705. };
  706. #define TURKS_CGCG_CGLS_DEFAULT_LENGTH sizeof(turks_cgcg_cgls_default) / (3 * sizeof(u32))
  707. static const u32 turks_cgcg_cgls_disable[] =
  708. {
  709. 0x000008f8, 0x00000010, 0xffffffff,
  710. 0x000008fc, 0xffffffff, 0xffffffff,
  711. 0x000008f8, 0x00000011, 0xffffffff,
  712. 0x000008fc, 0xffffffff, 0xffffffff,
  713. 0x000008f8, 0x00000012, 0xffffffff,
  714. 0x000008fc, 0xffffffff, 0xffffffff,
  715. 0x000008f8, 0x00000013, 0xffffffff,
  716. 0x000008fc, 0xffffffff, 0xffffffff,
  717. 0x000008f8, 0x00000014, 0xffffffff,
  718. 0x000008fc, 0xffffffff, 0xffffffff,
  719. 0x000008f8, 0x00000015, 0xffffffff,
  720. 0x000008fc, 0xffffffff, 0xffffffff,
  721. 0x000008f8, 0x00000016, 0xffffffff,
  722. 0x000008fc, 0xffffffff, 0xffffffff,
  723. 0x000008f8, 0x00000017, 0xffffffff,
  724. 0x000008fc, 0xffffffff, 0xffffffff,
  725. 0x000008f8, 0x00000018, 0xffffffff,
  726. 0x000008fc, 0xffffffff, 0xffffffff,
  727. 0x000008f8, 0x00000019, 0xffffffff,
  728. 0x000008fc, 0xffffffff, 0xffffffff,
  729. 0x000008f8, 0x0000001a, 0xffffffff,
  730. 0x000008fc, 0xffffffff, 0xffffffff,
  731. 0x000008f8, 0x0000001b, 0xffffffff,
  732. 0x000008fc, 0xffffffff, 0xffffffff,
  733. 0x000008f8, 0x00000020, 0xffffffff,
  734. 0x000008fc, 0x00000000, 0xffffffff,
  735. 0x000008f8, 0x00000021, 0xffffffff,
  736. 0x000008fc, 0x00000000, 0xffffffff,
  737. 0x000008f8, 0x00000022, 0xffffffff,
  738. 0x000008fc, 0x00000000, 0xffffffff,
  739. 0x000008f8, 0x00000023, 0xffffffff,
  740. 0x000008fc, 0x00000000, 0xffffffff,
  741. 0x000008f8, 0x00000024, 0xffffffff,
  742. 0x000008fc, 0x00000000, 0xffffffff,
  743. 0x000008f8, 0x00000025, 0xffffffff,
  744. 0x000008fc, 0x00000000, 0xffffffff,
  745. 0x000008f8, 0x00000026, 0xffffffff,
  746. 0x000008fc, 0x00000000, 0xffffffff,
  747. 0x000008f8, 0x00000027, 0xffffffff,
  748. 0x000008fc, 0x00000000, 0xffffffff,
  749. 0x000008f8, 0x00000028, 0xffffffff,
  750. 0x000008fc, 0x00000000, 0xffffffff,
  751. 0x000008f8, 0x00000029, 0xffffffff,
  752. 0x000008fc, 0x00000000, 0xffffffff,
  753. 0x000008f8, 0x0000002a, 0xffffffff,
  754. 0x000008fc, 0x00000000, 0xffffffff,
  755. 0x000008f8, 0x0000002b, 0xffffffff,
  756. 0x000008fc, 0x00000000, 0xffffffff,
  757. 0x00000644, 0x000f7912, 0x001f4180,
  758. 0x00000644, 0x000f3812, 0x001f4180
  759. };
  760. #define TURKS_CGCG_CGLS_DISABLE_LENGTH sizeof(turks_cgcg_cgls_disable) / (3 * sizeof(u32))
  761. static const u32 turks_cgcg_cgls_enable[] =
  762. {
  763. /* 0x0000c124, 0x84180000, 0x00180000, */
  764. 0x00000644, 0x000f7892, 0x001f4080,
  765. 0x000008f8, 0x00000010, 0xffffffff,
  766. 0x000008fc, 0x00000000, 0xffffffff,
  767. 0x000008f8, 0x00000011, 0xffffffff,
  768. 0x000008fc, 0x00000000, 0xffffffff,
  769. 0x000008f8, 0x00000012, 0xffffffff,
  770. 0x000008fc, 0x00000000, 0xffffffff,
  771. 0x000008f8, 0x00000013, 0xffffffff,
  772. 0x000008fc, 0x00000000, 0xffffffff,
  773. 0x000008f8, 0x00000014, 0xffffffff,
  774. 0x000008fc, 0x00000000, 0xffffffff,
  775. 0x000008f8, 0x00000015, 0xffffffff,
  776. 0x000008fc, 0x00000000, 0xffffffff,
  777. 0x000008f8, 0x00000016, 0xffffffff,
  778. 0x000008fc, 0x00000000, 0xffffffff,
  779. 0x000008f8, 0x00000017, 0xffffffff,
  780. 0x000008fc, 0x00000000, 0xffffffff,
  781. 0x000008f8, 0x00000018, 0xffffffff,
  782. 0x000008fc, 0x00000000, 0xffffffff,
  783. 0x000008f8, 0x00000019, 0xffffffff,
  784. 0x000008fc, 0x00000000, 0xffffffff,
  785. 0x000008f8, 0x0000001a, 0xffffffff,
  786. 0x000008fc, 0x00000000, 0xffffffff,
  787. 0x000008f8, 0x0000001b, 0xffffffff,
  788. 0x000008fc, 0x00000000, 0xffffffff,
  789. 0x000008f8, 0x00000020, 0xffffffff,
  790. 0x000008fc, 0xffffffff, 0xffffffff,
  791. 0x000008f8, 0x00000021, 0xffffffff,
  792. 0x000008fc, 0xffffffff, 0xffffffff,
  793. 0x000008f8, 0x00000022, 0xffffffff,
  794. 0x000008fc, 0xffffffff, 0xffffffff,
  795. 0x000008f8, 0x00000023, 0xffffffff,
  796. 0x000008fc, 0xffffffff, 0xffffffff,
  797. 0x000008f8, 0x00000024, 0xffffffff,
  798. 0x000008fc, 0xffffffff, 0xffffffff,
  799. 0x000008f8, 0x00000025, 0xffffffff,
  800. 0x000008fc, 0xffffffff, 0xffffffff,
  801. 0x000008f8, 0x00000026, 0xffffffff,
  802. 0x000008fc, 0xffffffff, 0xffffffff,
  803. 0x000008f8, 0x00000027, 0xffffffff,
  804. 0x000008fc, 0xffffffff, 0xffffffff,
  805. 0x000008f8, 0x00000028, 0xffffffff,
  806. 0x000008fc, 0xffffffff, 0xffffffff,
  807. 0x000008f8, 0x00000029, 0xffffffff,
  808. 0x000008fc, 0xffffffff, 0xffffffff,
  809. 0x000008f8, 0x0000002a, 0xffffffff,
  810. 0x000008fc, 0xffffffff, 0xffffffff,
  811. 0x000008f8, 0x0000002b, 0xffffffff,
  812. 0x000008fc, 0xffffffff, 0xffffffff
  813. };
  814. #define TURKS_CGCG_CGLS_ENABLE_LENGTH sizeof(turks_cgcg_cgls_enable) / (3 * sizeof(u32))
  815. // These are the sequences for turks_mgcg_shls
  816. static const u32 turks_mgcg_default[] =
  817. {
  818. 0x0000802c, 0xc0000000, 0xffffffff,
  819. 0x00005448, 0x00000100, 0xffffffff,
  820. 0x000055e4, 0x00600100, 0xffffffff,
  821. 0x0000160c, 0x00000100, 0xffffffff,
  822. 0x0000c164, 0x00000100, 0xffffffff,
  823. 0x00008a18, 0x00000100, 0xffffffff,
  824. 0x0000897c, 0x06000100, 0xffffffff,
  825. 0x00008b28, 0x00000100, 0xffffffff,
  826. 0x00009144, 0x00000100, 0xffffffff,
  827. 0x00009a60, 0x00000100, 0xffffffff,
  828. 0x00009868, 0x00000100, 0xffffffff,
  829. 0x00008d58, 0x00000100, 0xffffffff,
  830. 0x00009510, 0x00000100, 0xffffffff,
  831. 0x0000949c, 0x00000100, 0xffffffff,
  832. 0x00009654, 0x00000100, 0xffffffff,
  833. 0x00009030, 0x00000100, 0xffffffff,
  834. 0x00009034, 0x00000100, 0xffffffff,
  835. 0x00009038, 0x00000100, 0xffffffff,
  836. 0x0000903c, 0x00000100, 0xffffffff,
  837. 0x00009040, 0x00000100, 0xffffffff,
  838. 0x0000a200, 0x00000100, 0xffffffff,
  839. 0x0000a204, 0x00000100, 0xffffffff,
  840. 0x0000a208, 0x00000100, 0xffffffff,
  841. 0x0000a20c, 0x00000100, 0xffffffff,
  842. 0x0000977c, 0x00000100, 0xffffffff,
  843. 0x00003f80, 0x00000100, 0xffffffff,
  844. 0x0000a210, 0x00000100, 0xffffffff,
  845. 0x0000a214, 0x00000100, 0xffffffff,
  846. 0x000004d8, 0x00000100, 0xffffffff,
  847. 0x00009784, 0x00000100, 0xffffffff,
  848. 0x00009698, 0x00000100, 0xffffffff,
  849. 0x000004d4, 0x00000200, 0xffffffff,
  850. 0x000004d0, 0x00000000, 0xffffffff,
  851. 0x000030cc, 0x00000100, 0xffffffff,
  852. 0x0000d0c0, 0x00000100, 0xffffffff,
  853. 0x0000915c, 0x00010000, 0xffffffff,
  854. 0x00009160, 0x00030002, 0xffffffff,
  855. 0x00009164, 0x00050004, 0xffffffff,
  856. 0x00009168, 0x00070006, 0xffffffff,
  857. 0x00009178, 0x00070000, 0xffffffff,
  858. 0x0000917c, 0x00030002, 0xffffffff,
  859. 0x00009180, 0x00050004, 0xffffffff,
  860. 0x0000918c, 0x00010006, 0xffffffff,
  861. 0x00009190, 0x00090008, 0xffffffff,
  862. 0x00009194, 0x00070000, 0xffffffff,
  863. 0x00009198, 0x00030002, 0xffffffff,
  864. 0x0000919c, 0x00050004, 0xffffffff,
  865. 0x000091a8, 0x00010006, 0xffffffff,
  866. 0x000091ac, 0x00090008, 0xffffffff,
  867. 0x000091b0, 0x00070000, 0xffffffff,
  868. 0x000091b4, 0x00030002, 0xffffffff,
  869. 0x000091b8, 0x00050004, 0xffffffff,
  870. 0x000091c4, 0x00010006, 0xffffffff,
  871. 0x000091c8, 0x00090008, 0xffffffff,
  872. 0x000091cc, 0x00070000, 0xffffffff,
  873. 0x000091d0, 0x00030002, 0xffffffff,
  874. 0x000091d4, 0x00050004, 0xffffffff,
  875. 0x000091e0, 0x00010006, 0xffffffff,
  876. 0x000091e4, 0x00090008, 0xffffffff,
  877. 0x000091e8, 0x00000000, 0xffffffff,
  878. 0x000091ec, 0x00070000, 0xffffffff,
  879. 0x000091f0, 0x00030002, 0xffffffff,
  880. 0x000091f4, 0x00050004, 0xffffffff,
  881. 0x00009200, 0x00010006, 0xffffffff,
  882. 0x00009204, 0x00090008, 0xffffffff,
  883. 0x00009208, 0x00070000, 0xffffffff,
  884. 0x0000920c, 0x00030002, 0xffffffff,
  885. 0x00009210, 0x00050004, 0xffffffff,
  886. 0x0000921c, 0x00010006, 0xffffffff,
  887. 0x00009220, 0x00090008, 0xffffffff,
  888. 0x00009294, 0x00000000, 0xffffffff,
  889. 0x000008f8, 0x00000010, 0xffffffff,
  890. 0x000008fc, 0x00000000, 0xffffffff,
  891. 0x000008f8, 0x00000011, 0xffffffff,
  892. 0x000008fc, 0x00000000, 0xffffffff,
  893. 0x000008f8, 0x00000012, 0xffffffff,
  894. 0x000008fc, 0x00000000, 0xffffffff,
  895. 0x000008f8, 0x00000013, 0xffffffff,
  896. 0x000008fc, 0x00000000, 0xffffffff,
  897. 0x000008f8, 0x00000014, 0xffffffff,
  898. 0x000008fc, 0x00000000, 0xffffffff,
  899. 0x000008f8, 0x00000015, 0xffffffff,
  900. 0x000008fc, 0x00000000, 0xffffffff,
  901. 0x000008f8, 0x00000016, 0xffffffff,
  902. 0x000008fc, 0x00000000, 0xffffffff,
  903. 0x000008f8, 0x00000017, 0xffffffff,
  904. 0x000008fc, 0x00000000, 0xffffffff,
  905. 0x000008f8, 0x00000018, 0xffffffff,
  906. 0x000008fc, 0x00000000, 0xffffffff,
  907. 0x000008f8, 0x00000019, 0xffffffff,
  908. 0x000008fc, 0x00000000, 0xffffffff,
  909. 0x000008f8, 0x0000001a, 0xffffffff,
  910. 0x000008fc, 0x00000000, 0xffffffff,
  911. 0x000008f8, 0x0000001b, 0xffffffff,
  912. 0x000008fc, 0x00000000, 0xffffffff
  913. };
  914. #define TURKS_MGCG_DEFAULT_LENGTH sizeof(turks_mgcg_default) / (3 * sizeof(u32))
  915. static const u32 turks_mgcg_disable[] =
  916. {
  917. 0x0000802c, 0xc0000000, 0xffffffff,
  918. 0x000008f8, 0x00000000, 0xffffffff,
  919. 0x000008fc, 0xffffffff, 0xffffffff,
  920. 0x000008f8, 0x00000001, 0xffffffff,
  921. 0x000008fc, 0xffffffff, 0xffffffff,
  922. 0x000008f8, 0x00000002, 0xffffffff,
  923. 0x000008fc, 0xffffffff, 0xffffffff,
  924. 0x000008f8, 0x00000003, 0xffffffff,
  925. 0x000008fc, 0xffffffff, 0xffffffff,
  926. 0x00009150, 0x00600000, 0xffffffff
  927. };
  928. #define TURKS_MGCG_DISABLE_LENGTH sizeof(turks_mgcg_disable) / (3 * sizeof(u32))
  929. static const u32 turks_mgcg_enable[] =
  930. {
  931. 0x0000802c, 0xc0000000, 0xffffffff,
  932. 0x000008f8, 0x00000000, 0xffffffff,
  933. 0x000008fc, 0x00000000, 0xffffffff,
  934. 0x000008f8, 0x00000001, 0xffffffff,
  935. 0x000008fc, 0x00000000, 0xffffffff,
  936. 0x000008f8, 0x00000002, 0xffffffff,
  937. 0x000008fc, 0x00000000, 0xffffffff,
  938. 0x000008f8, 0x00000003, 0xffffffff,
  939. 0x000008fc, 0x00000000, 0xffffffff,
  940. 0x00009150, 0x6e944000, 0xffffffff
  941. };
  942. #define TURKS_MGCG_ENABLE_LENGTH sizeof(turks_mgcg_enable) / (3 * sizeof(u32))
  943. #endif
  944. #ifndef BTC_SYSLS_SEQUENCE
  945. #define BTC_SYSLS_SEQUENCE 100
  946. //********* BARTS **************//
  947. static const u32 barts_sysls_default[] =
  948. {
  949. /* Register, Value, Mask bits */
  950. 0x000055e8, 0x00000000, 0xffffffff,
  951. 0x0000d0bc, 0x00000000, 0xffffffff,
  952. 0x000015c0, 0x000c1401, 0xffffffff,
  953. 0x0000264c, 0x000c0400, 0xffffffff,
  954. 0x00002648, 0x000c0400, 0xffffffff,
  955. 0x00002650, 0x000c0400, 0xffffffff,
  956. 0x000020b8, 0x000c0400, 0xffffffff,
  957. 0x000020bc, 0x000c0400, 0xffffffff,
  958. 0x000020c0, 0x000c0c80, 0xffffffff,
  959. 0x0000f4a0, 0x000000c0, 0xffffffff,
  960. 0x0000f4a4, 0x00680fff, 0xffffffff,
  961. 0x000004c8, 0x00000001, 0xffffffff,
  962. 0x000064ec, 0x00000000, 0xffffffff,
  963. 0x00000c7c, 0x00000000, 0xffffffff,
  964. 0x00006dfc, 0x00000000, 0xffffffff
  965. };
  966. #define BARTS_SYSLS_DEFAULT_LENGTH sizeof(barts_sysls_default) / (3 * sizeof(u32))
  967. static const u32 barts_sysls_disable[] =
  968. {
  969. 0x000055e8, 0x00000000, 0xffffffff,
  970. 0x0000d0bc, 0x00000000, 0xffffffff,
  971. 0x000015c0, 0x00041401, 0xffffffff,
  972. 0x0000264c, 0x00040400, 0xffffffff,
  973. 0x00002648, 0x00040400, 0xffffffff,
  974. 0x00002650, 0x00040400, 0xffffffff,
  975. 0x000020b8, 0x00040400, 0xffffffff,
  976. 0x000020bc, 0x00040400, 0xffffffff,
  977. 0x000020c0, 0x00040c80, 0xffffffff,
  978. 0x0000f4a0, 0x000000c0, 0xffffffff,
  979. 0x0000f4a4, 0x00680000, 0xffffffff,
  980. 0x000004c8, 0x00000001, 0xffffffff,
  981. 0x000064ec, 0x00007ffd, 0xffffffff,
  982. 0x00000c7c, 0x0000ff00, 0xffffffff,
  983. 0x00006dfc, 0x0000007f, 0xffffffff
  984. };
  985. #define BARTS_SYSLS_DISABLE_LENGTH sizeof(barts_sysls_disable) / (3 * sizeof(u32))
  986. static const u32 barts_sysls_enable[] =
  987. {
  988. 0x000055e8, 0x00000001, 0xffffffff,
  989. 0x0000d0bc, 0x00000100, 0xffffffff,
  990. 0x000015c0, 0x000c1401, 0xffffffff,
  991. 0x0000264c, 0x000c0400, 0xffffffff,
  992. 0x00002648, 0x000c0400, 0xffffffff,
  993. 0x00002650, 0x000c0400, 0xffffffff,
  994. 0x000020b8, 0x000c0400, 0xffffffff,
  995. 0x000020bc, 0x000c0400, 0xffffffff,
  996. 0x000020c0, 0x000c0c80, 0xffffffff,
  997. 0x0000f4a0, 0x000000c0, 0xffffffff,
  998. 0x0000f4a4, 0x00680fff, 0xffffffff,
  999. 0x000004c8, 0x00000000, 0xffffffff,
  1000. 0x000064ec, 0x00000000, 0xffffffff,
  1001. 0x00000c7c, 0x00000000, 0xffffffff,
  1002. 0x00006dfc, 0x00000000, 0xffffffff
  1003. };
  1004. #define BARTS_SYSLS_ENABLE_LENGTH sizeof(barts_sysls_enable) / (3 * sizeof(u32))
  1005. //********* CAICOS **************//
  1006. static const u32 caicos_sysls_default[] =
  1007. {
  1008. 0x000055e8, 0x00000000, 0xffffffff,
  1009. 0x0000d0bc, 0x00000000, 0xffffffff,
  1010. 0x000015c0, 0x000c1401, 0xffffffff,
  1011. 0x0000264c, 0x000c0400, 0xffffffff,
  1012. 0x00002648, 0x000c0400, 0xffffffff,
  1013. 0x00002650, 0x000c0400, 0xffffffff,
  1014. 0x000020b8, 0x000c0400, 0xffffffff,
  1015. 0x000020bc, 0x000c0400, 0xffffffff,
  1016. 0x0000f4a0, 0x000000c0, 0xffffffff,
  1017. 0x0000f4a4, 0x00680fff, 0xffffffff,
  1018. 0x000004c8, 0x00000001, 0xffffffff,
  1019. 0x000064ec, 0x00000000, 0xffffffff,
  1020. 0x00000c7c, 0x00000000, 0xffffffff,
  1021. 0x00006dfc, 0x00000000, 0xffffffff
  1022. };
  1023. #define CAICOS_SYSLS_DEFAULT_LENGTH sizeof(caicos_sysls_default) / (3 * sizeof(u32))
  1024. static const u32 caicos_sysls_disable[] =
  1025. {
  1026. 0x000055e8, 0x00000000, 0xffffffff,
  1027. 0x0000d0bc, 0x00000000, 0xffffffff,
  1028. 0x000015c0, 0x00041401, 0xffffffff,
  1029. 0x0000264c, 0x00040400, 0xffffffff,
  1030. 0x00002648, 0x00040400, 0xffffffff,
  1031. 0x00002650, 0x00040400, 0xffffffff,
  1032. 0x000020b8, 0x00040400, 0xffffffff,
  1033. 0x000020bc, 0x00040400, 0xffffffff,
  1034. 0x0000f4a0, 0x000000c0, 0xffffffff,
  1035. 0x0000f4a4, 0x00680000, 0xffffffff,
  1036. 0x000004c8, 0x00000001, 0xffffffff,
  1037. 0x000064ec, 0x00007ffd, 0xffffffff,
  1038. 0x00000c7c, 0x0000ff00, 0xffffffff,
  1039. 0x00006dfc, 0x0000007f, 0xffffffff
  1040. };
  1041. #define CAICOS_SYSLS_DISABLE_LENGTH sizeof(caicos_sysls_disable) / (3 * sizeof(u32))
  1042. static const u32 caicos_sysls_enable[] =
  1043. {
  1044. 0x000055e8, 0x00000001, 0xffffffff,
  1045. 0x0000d0bc, 0x00000100, 0xffffffff,
  1046. 0x000015c0, 0x000c1401, 0xffffffff,
  1047. 0x0000264c, 0x000c0400, 0xffffffff,
  1048. 0x00002648, 0x000c0400, 0xffffffff,
  1049. 0x00002650, 0x000c0400, 0xffffffff,
  1050. 0x000020b8, 0x000c0400, 0xffffffff,
  1051. 0x000020bc, 0x000c0400, 0xffffffff,
  1052. 0x0000f4a0, 0x000000c0, 0xffffffff,
  1053. 0x0000f4a4, 0x00680fff, 0xffffffff,
  1054. 0x000064ec, 0x00000000, 0xffffffff,
  1055. 0x00000c7c, 0x00000000, 0xffffffff,
  1056. 0x00006dfc, 0x00000000, 0xffffffff,
  1057. 0x000004c8, 0x00000000, 0xffffffff
  1058. };
  1059. #define CAICOS_SYSLS_ENABLE_LENGTH sizeof(caicos_sysls_enable) / (3 * sizeof(u32))
  1060. //********* TURKS **************//
  1061. static const u32 turks_sysls_default[] =
  1062. {
  1063. 0x000055e8, 0x00000000, 0xffffffff,
  1064. 0x0000d0bc, 0x00000000, 0xffffffff,
  1065. 0x000015c0, 0x000c1401, 0xffffffff,
  1066. 0x0000264c, 0x000c0400, 0xffffffff,
  1067. 0x00002648, 0x000c0400, 0xffffffff,
  1068. 0x00002650, 0x000c0400, 0xffffffff,
  1069. 0x000020b8, 0x000c0400, 0xffffffff,
  1070. 0x000020bc, 0x000c0400, 0xffffffff,
  1071. 0x000020c0, 0x000c0c80, 0xffffffff,
  1072. 0x0000f4a0, 0x000000c0, 0xffffffff,
  1073. 0x0000f4a4, 0x00680fff, 0xffffffff,
  1074. 0x000004c8, 0x00000001, 0xffffffff,
  1075. 0x000064ec, 0x00000000, 0xffffffff,
  1076. 0x00000c7c, 0x00000000, 0xffffffff,
  1077. 0x00006dfc, 0x00000000, 0xffffffff
  1078. };
  1079. #define TURKS_SYSLS_DEFAULT_LENGTH sizeof(turks_sysls_default) / (3 * sizeof(u32))
  1080. static const u32 turks_sysls_disable[] =
  1081. {
  1082. 0x000055e8, 0x00000000, 0xffffffff,
  1083. 0x0000d0bc, 0x00000000, 0xffffffff,
  1084. 0x000015c0, 0x00041401, 0xffffffff,
  1085. 0x0000264c, 0x00040400, 0xffffffff,
  1086. 0x00002648, 0x00040400, 0xffffffff,
  1087. 0x00002650, 0x00040400, 0xffffffff,
  1088. 0x000020b8, 0x00040400, 0xffffffff,
  1089. 0x000020bc, 0x00040400, 0xffffffff,
  1090. 0x000020c0, 0x00040c80, 0xffffffff,
  1091. 0x0000f4a0, 0x000000c0, 0xffffffff,
  1092. 0x0000f4a4, 0x00680000, 0xffffffff,
  1093. 0x000004c8, 0x00000001, 0xffffffff,
  1094. 0x000064ec, 0x00007ffd, 0xffffffff,
  1095. 0x00000c7c, 0x0000ff00, 0xffffffff,
  1096. 0x00006dfc, 0x0000007f, 0xffffffff
  1097. };
  1098. #define TURKS_SYSLS_DISABLE_LENGTH sizeof(turks_sysls_disable) / (3 * sizeof(u32))
  1099. static const u32 turks_sysls_enable[] =
  1100. {
  1101. 0x000055e8, 0x00000001, 0xffffffff,
  1102. 0x0000d0bc, 0x00000100, 0xffffffff,
  1103. 0x000015c0, 0x000c1401, 0xffffffff,
  1104. 0x0000264c, 0x000c0400, 0xffffffff,
  1105. 0x00002648, 0x000c0400, 0xffffffff,
  1106. 0x00002650, 0x000c0400, 0xffffffff,
  1107. 0x000020b8, 0x000c0400, 0xffffffff,
  1108. 0x000020bc, 0x000c0400, 0xffffffff,
  1109. 0x000020c0, 0x000c0c80, 0xffffffff,
  1110. 0x0000f4a0, 0x000000c0, 0xffffffff,
  1111. 0x0000f4a4, 0x00680fff, 0xffffffff,
  1112. 0x000004c8, 0x00000000, 0xffffffff,
  1113. 0x000064ec, 0x00000000, 0xffffffff,
  1114. 0x00000c7c, 0x00000000, 0xffffffff,
  1115. 0x00006dfc, 0x00000000, 0xffffffff
  1116. };
  1117. #define TURKS_SYSLS_ENABLE_LENGTH sizeof(turks_sysls_enable) / (3 * sizeof(u32))
  1118. #endif
  1119. u32 btc_valid_sclk[40] =
  1120. {
  1121. 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000,
  1122. 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000,
  1123. 105000, 110000, 11500, 120000, 125000, 130000, 135000, 140000, 145000, 150000,
  1124. 155000, 160000, 165000, 170000, 175000, 180000, 185000, 190000, 195000, 200000
  1125. };
  1126. static const struct radeon_blacklist_clocks btc_blacklist_clocks[] =
  1127. {
  1128. { 10000, 30000, RADEON_SCLK_UP },
  1129. { 15000, 30000, RADEON_SCLK_UP },
  1130. { 20000, 30000, RADEON_SCLK_UP },
  1131. { 25000, 30000, RADEON_SCLK_UP }
  1132. };
  1133. void btc_get_max_clock_from_voltage_dependency_table(struct radeon_clock_voltage_dependency_table *table,
  1134. u32 *max_clock)
  1135. {
  1136. u32 i, clock = 0;
  1137. if ((table == NULL) || (table->count == 0)) {
  1138. *max_clock = clock;
  1139. return;
  1140. }
  1141. for (i = 0; i < table->count; i++) {
  1142. if (clock < table->entries[i].clk)
  1143. clock = table->entries[i].clk;
  1144. }
  1145. *max_clock = clock;
  1146. }
  1147. void btc_apply_voltage_dependency_rules(struct radeon_clock_voltage_dependency_table *table,
  1148. u32 clock, u16 max_voltage, u16 *voltage)
  1149. {
  1150. u32 i;
  1151. if ((table == NULL) || (table->count == 0))
  1152. return;
  1153. for (i= 0; i < table->count; i++) {
  1154. if (clock <= table->entries[i].clk) {
  1155. if (*voltage < table->entries[i].v)
  1156. *voltage = (u16)((table->entries[i].v < max_voltage) ?
  1157. table->entries[i].v : max_voltage);
  1158. return;
  1159. }
  1160. }
  1161. *voltage = (*voltage > max_voltage) ? *voltage : max_voltage;
  1162. }
  1163. static u32 btc_find_valid_clock(struct radeon_clock_array *clocks,
  1164. u32 max_clock, u32 requested_clock)
  1165. {
  1166. unsigned int i;
  1167. if ((clocks == NULL) || (clocks->count == 0))
  1168. return (requested_clock < max_clock) ? requested_clock : max_clock;
  1169. for (i = 0; i < clocks->count; i++) {
  1170. if (clocks->values[i] >= requested_clock)
  1171. return (clocks->values[i] < max_clock) ? clocks->values[i] : max_clock;
  1172. }
  1173. return (clocks->values[clocks->count - 1] < max_clock) ?
  1174. clocks->values[clocks->count - 1] : max_clock;
  1175. }
  1176. static u32 btc_get_valid_mclk(struct radeon_device *rdev,
  1177. u32 max_mclk, u32 requested_mclk)
  1178. {
  1179. return btc_find_valid_clock(&rdev->pm.dpm.dyn_state.valid_mclk_values,
  1180. max_mclk, requested_mclk);
  1181. }
  1182. static u32 btc_get_valid_sclk(struct radeon_device *rdev,
  1183. u32 max_sclk, u32 requested_sclk)
  1184. {
  1185. return btc_find_valid_clock(&rdev->pm.dpm.dyn_state.valid_sclk_values,
  1186. max_sclk, requested_sclk);
  1187. }
  1188. void btc_skip_blacklist_clocks(struct radeon_device *rdev,
  1189. const u32 max_sclk, const u32 max_mclk,
  1190. u32 *sclk, u32 *mclk)
  1191. {
  1192. int i, num_blacklist_clocks;
  1193. if ((sclk == NULL) || (mclk == NULL))
  1194. return;
  1195. num_blacklist_clocks = ARRAY_SIZE(btc_blacklist_clocks);
  1196. for (i = 0; i < num_blacklist_clocks; i++) {
  1197. if ((btc_blacklist_clocks[i].sclk == *sclk) &&
  1198. (btc_blacklist_clocks[i].mclk == *mclk))
  1199. break;
  1200. }
  1201. if (i < num_blacklist_clocks) {
  1202. if (btc_blacklist_clocks[i].action == RADEON_SCLK_UP) {
  1203. *sclk = btc_get_valid_sclk(rdev, max_sclk, *sclk + 1);
  1204. if (*sclk < max_sclk)
  1205. btc_skip_blacklist_clocks(rdev, max_sclk, max_mclk, sclk, mclk);
  1206. }
  1207. }
  1208. }
  1209. void btc_adjust_clock_combinations(struct radeon_device *rdev,
  1210. const struct radeon_clock_and_voltage_limits *max_limits,
  1211. struct rv7xx_pl *pl)
  1212. {
  1213. if ((pl->mclk == 0) || (pl->sclk == 0))
  1214. return;
  1215. if (pl->mclk == pl->sclk)
  1216. return;
  1217. if (pl->mclk > pl->sclk) {
  1218. if (((pl->mclk + (pl->sclk - 1)) / pl->sclk) > rdev->pm.dpm.dyn_state.mclk_sclk_ratio)
  1219. pl->sclk = btc_get_valid_sclk(rdev,
  1220. max_limits->sclk,
  1221. (pl->mclk +
  1222. (rdev->pm.dpm.dyn_state.mclk_sclk_ratio - 1)) /
  1223. rdev->pm.dpm.dyn_state.mclk_sclk_ratio);
  1224. } else {
  1225. if ((pl->sclk - pl->mclk) > rdev->pm.dpm.dyn_state.sclk_mclk_delta)
  1226. pl->mclk = btc_get_valid_mclk(rdev,
  1227. max_limits->mclk,
  1228. pl->sclk -
  1229. rdev->pm.dpm.dyn_state.sclk_mclk_delta);
  1230. }
  1231. }
  1232. static u16 btc_find_voltage(struct atom_voltage_table *table, u16 voltage)
  1233. {
  1234. unsigned int i;
  1235. for (i = 0; i < table->count; i++) {
  1236. if (voltage <= table->entries[i].value)
  1237. return table->entries[i].value;
  1238. }
  1239. return table->entries[table->count - 1].value;
  1240. }
  1241. void btc_apply_voltage_delta_rules(struct radeon_device *rdev,
  1242. u16 max_vddc, u16 max_vddci,
  1243. u16 *vddc, u16 *vddci)
  1244. {
  1245. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1246. u16 new_voltage;
  1247. if ((0 == *vddc) || (0 == *vddci))
  1248. return;
  1249. if (*vddc > *vddci) {
  1250. if ((*vddc - *vddci) > rdev->pm.dpm.dyn_state.vddc_vddci_delta) {
  1251. new_voltage = btc_find_voltage(&eg_pi->vddci_voltage_table,
  1252. (*vddc - rdev->pm.dpm.dyn_state.vddc_vddci_delta));
  1253. *vddci = (new_voltage < max_vddci) ? new_voltage : max_vddci;
  1254. }
  1255. } else {
  1256. if ((*vddci - *vddc) > rdev->pm.dpm.dyn_state.vddc_vddci_delta) {
  1257. new_voltage = btc_find_voltage(&eg_pi->vddc_voltage_table,
  1258. (*vddci - rdev->pm.dpm.dyn_state.vddc_vddci_delta));
  1259. *vddc = (new_voltage < max_vddc) ? new_voltage : max_vddc;
  1260. }
  1261. }
  1262. }
  1263. static void btc_enable_bif_dynamic_pcie_gen2(struct radeon_device *rdev,
  1264. bool enable)
  1265. {
  1266. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  1267. u32 tmp, bif;
  1268. tmp = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
  1269. if (enable) {
  1270. if ((tmp & LC_OTHER_SIDE_EVER_SENT_GEN2) &&
  1271. (tmp & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
  1272. if (!pi->boot_in_gen2) {
  1273. bif = RREG32(CG_BIF_REQ_AND_RSP) & ~CG_CLIENT_REQ_MASK;
  1274. bif |= CG_CLIENT_REQ(0xd);
  1275. WREG32(CG_BIF_REQ_AND_RSP, bif);
  1276. tmp &= ~LC_HW_VOLTAGE_IF_CONTROL_MASK;
  1277. tmp |= LC_HW_VOLTAGE_IF_CONTROL(1);
  1278. tmp |= LC_GEN2_EN_STRAP;
  1279. tmp |= LC_CLR_FAILED_SPD_CHANGE_CNT;
  1280. WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
  1281. udelay(10);
  1282. tmp &= ~LC_CLR_FAILED_SPD_CHANGE_CNT;
  1283. WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
  1284. }
  1285. }
  1286. } else {
  1287. if ((tmp & LC_OTHER_SIDE_EVER_SENT_GEN2) ||
  1288. (tmp & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
  1289. if (!pi->boot_in_gen2) {
  1290. bif = RREG32(CG_BIF_REQ_AND_RSP) & ~CG_CLIENT_REQ_MASK;
  1291. bif |= CG_CLIENT_REQ(0xd);
  1292. WREG32(CG_BIF_REQ_AND_RSP, bif);
  1293. tmp &= ~LC_HW_VOLTAGE_IF_CONTROL_MASK;
  1294. tmp &= ~LC_GEN2_EN_STRAP;
  1295. }
  1296. WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, tmp);
  1297. }
  1298. }
  1299. }
  1300. static void btc_enable_dynamic_pcie_gen2(struct radeon_device *rdev,
  1301. bool enable)
  1302. {
  1303. btc_enable_bif_dynamic_pcie_gen2(rdev, enable);
  1304. if (enable)
  1305. WREG32_P(GENERAL_PWRMGT, ENABLE_GEN2PCIE, ~ENABLE_GEN2PCIE);
  1306. else
  1307. WREG32_P(GENERAL_PWRMGT, 0, ~ENABLE_GEN2PCIE);
  1308. }
  1309. static int btc_disable_ulv(struct radeon_device *rdev)
  1310. {
  1311. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1312. if (eg_pi->ulv.supported) {
  1313. if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_DisableULV) != PPSMC_Result_OK)
  1314. return -EINVAL;
  1315. }
  1316. return 0;
  1317. }
  1318. static int btc_populate_ulv_state(struct radeon_device *rdev,
  1319. RV770_SMC_STATETABLE *table)
  1320. {
  1321. int ret = -EINVAL;
  1322. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1323. struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
  1324. if (ulv_pl->vddc) {
  1325. ret = cypress_convert_power_level_to_smc(rdev,
  1326. ulv_pl,
  1327. &table->ULVState.levels[0],
  1328. PPSMC_DISPLAY_WATERMARK_LOW);
  1329. if (ret == 0) {
  1330. table->ULVState.levels[0].arbValue = MC_CG_ARB_FREQ_F0;
  1331. table->ULVState.levels[0].ACIndex = 1;
  1332. table->ULVState.levels[1] = table->ULVState.levels[0];
  1333. table->ULVState.levels[2] = table->ULVState.levels[0];
  1334. table->ULVState.flags |= PPSMC_SWSTATE_FLAG_DC;
  1335. WREG32(CG_ULV_CONTROL, BTC_CGULVCONTROL_DFLT);
  1336. WREG32(CG_ULV_PARAMETER, BTC_CGULVPARAMETER_DFLT);
  1337. }
  1338. }
  1339. return ret;
  1340. }
  1341. static int btc_populate_smc_acpi_state(struct radeon_device *rdev,
  1342. RV770_SMC_STATETABLE *table)
  1343. {
  1344. int ret = cypress_populate_smc_acpi_state(rdev, table);
  1345. if (ret == 0) {
  1346. table->ACPIState.levels[0].ACIndex = 0;
  1347. table->ACPIState.levels[1].ACIndex = 0;
  1348. table->ACPIState.levels[2].ACIndex = 0;
  1349. }
  1350. return ret;
  1351. }
  1352. void btc_program_mgcg_hw_sequence(struct radeon_device *rdev,
  1353. const u32 *sequence, u32 count)
  1354. {
  1355. u32 i, length = count * 3;
  1356. u32 tmp;
  1357. for (i = 0; i < length; i+=3) {
  1358. tmp = RREG32(sequence[i]);
  1359. tmp &= ~sequence[i+2];
  1360. tmp |= sequence[i+1] & sequence[i+2];
  1361. WREG32(sequence[i], tmp);
  1362. }
  1363. }
  1364. static void btc_cg_clock_gating_default(struct radeon_device *rdev)
  1365. {
  1366. u32 count;
  1367. const u32 *p = NULL;
  1368. if (rdev->family == CHIP_BARTS) {
  1369. p = (const u32 *)&barts_cgcg_cgls_default;
  1370. count = BARTS_CGCG_CGLS_DEFAULT_LENGTH;
  1371. } else if (rdev->family == CHIP_TURKS) {
  1372. p = (const u32 *)&turks_cgcg_cgls_default;
  1373. count = TURKS_CGCG_CGLS_DEFAULT_LENGTH;
  1374. } else if (rdev->family == CHIP_CAICOS) {
  1375. p = (const u32 *)&caicos_cgcg_cgls_default;
  1376. count = CAICOS_CGCG_CGLS_DEFAULT_LENGTH;
  1377. } else
  1378. return;
  1379. btc_program_mgcg_hw_sequence(rdev, p, count);
  1380. }
  1381. static void btc_cg_clock_gating_enable(struct radeon_device *rdev,
  1382. bool enable)
  1383. {
  1384. u32 count;
  1385. const u32 *p = NULL;
  1386. if (enable) {
  1387. if (rdev->family == CHIP_BARTS) {
  1388. p = (const u32 *)&barts_cgcg_cgls_enable;
  1389. count = BARTS_CGCG_CGLS_ENABLE_LENGTH;
  1390. } else if (rdev->family == CHIP_TURKS) {
  1391. p = (const u32 *)&turks_cgcg_cgls_enable;
  1392. count = TURKS_CGCG_CGLS_ENABLE_LENGTH;
  1393. } else if (rdev->family == CHIP_CAICOS) {
  1394. p = (const u32 *)&caicos_cgcg_cgls_enable;
  1395. count = CAICOS_CGCG_CGLS_ENABLE_LENGTH;
  1396. } else
  1397. return;
  1398. } else {
  1399. if (rdev->family == CHIP_BARTS) {
  1400. p = (const u32 *)&barts_cgcg_cgls_disable;
  1401. count = BARTS_CGCG_CGLS_DISABLE_LENGTH;
  1402. } else if (rdev->family == CHIP_TURKS) {
  1403. p = (const u32 *)&turks_cgcg_cgls_disable;
  1404. count = TURKS_CGCG_CGLS_DISABLE_LENGTH;
  1405. } else if (rdev->family == CHIP_CAICOS) {
  1406. p = (const u32 *)&caicos_cgcg_cgls_disable;
  1407. count = CAICOS_CGCG_CGLS_DISABLE_LENGTH;
  1408. } else
  1409. return;
  1410. }
  1411. btc_program_mgcg_hw_sequence(rdev, p, count);
  1412. }
  1413. static void btc_mg_clock_gating_default(struct radeon_device *rdev)
  1414. {
  1415. u32 count;
  1416. const u32 *p = NULL;
  1417. if (rdev->family == CHIP_BARTS) {
  1418. p = (const u32 *)&barts_mgcg_default;
  1419. count = BARTS_MGCG_DEFAULT_LENGTH;
  1420. } else if (rdev->family == CHIP_TURKS) {
  1421. p = (const u32 *)&turks_mgcg_default;
  1422. count = TURKS_MGCG_DEFAULT_LENGTH;
  1423. } else if (rdev->family == CHIP_CAICOS) {
  1424. p = (const u32 *)&caicos_mgcg_default;
  1425. count = CAICOS_MGCG_DEFAULT_LENGTH;
  1426. } else
  1427. return;
  1428. btc_program_mgcg_hw_sequence(rdev, p, count);
  1429. }
  1430. static void btc_mg_clock_gating_enable(struct radeon_device *rdev,
  1431. bool enable)
  1432. {
  1433. u32 count;
  1434. const u32 *p = NULL;
  1435. if (enable) {
  1436. if (rdev->family == CHIP_BARTS) {
  1437. p = (const u32 *)&barts_mgcg_enable;
  1438. count = BARTS_MGCG_ENABLE_LENGTH;
  1439. } else if (rdev->family == CHIP_TURKS) {
  1440. p = (const u32 *)&turks_mgcg_enable;
  1441. count = TURKS_MGCG_ENABLE_LENGTH;
  1442. } else if (rdev->family == CHIP_CAICOS) {
  1443. p = (const u32 *)&caicos_mgcg_enable;
  1444. count = CAICOS_MGCG_ENABLE_LENGTH;
  1445. } else
  1446. return;
  1447. } else {
  1448. if (rdev->family == CHIP_BARTS) {
  1449. p = (const u32 *)&barts_mgcg_disable[0];
  1450. count = BARTS_MGCG_DISABLE_LENGTH;
  1451. } else if (rdev->family == CHIP_TURKS) {
  1452. p = (const u32 *)&turks_mgcg_disable[0];
  1453. count = TURKS_MGCG_DISABLE_LENGTH;
  1454. } else if (rdev->family == CHIP_CAICOS) {
  1455. p = (const u32 *)&caicos_mgcg_disable[0];
  1456. count = CAICOS_MGCG_DISABLE_LENGTH;
  1457. } else
  1458. return;
  1459. }
  1460. btc_program_mgcg_hw_sequence(rdev, p, count);
  1461. }
  1462. static void btc_ls_clock_gating_default(struct radeon_device *rdev)
  1463. {
  1464. u32 count;
  1465. const u32 *p = NULL;
  1466. if (rdev->family == CHIP_BARTS) {
  1467. p = (const u32 *)&barts_sysls_default;
  1468. count = BARTS_SYSLS_DEFAULT_LENGTH;
  1469. } else if (rdev->family == CHIP_TURKS) {
  1470. p = (const u32 *)&turks_sysls_default;
  1471. count = TURKS_SYSLS_DEFAULT_LENGTH;
  1472. } else if (rdev->family == CHIP_CAICOS) {
  1473. p = (const u32 *)&caicos_sysls_default;
  1474. count = CAICOS_SYSLS_DEFAULT_LENGTH;
  1475. } else
  1476. return;
  1477. btc_program_mgcg_hw_sequence(rdev, p, count);
  1478. }
  1479. static void btc_ls_clock_gating_enable(struct radeon_device *rdev,
  1480. bool enable)
  1481. {
  1482. u32 count;
  1483. const u32 *p = NULL;
  1484. if (enable) {
  1485. if (rdev->family == CHIP_BARTS) {
  1486. p = (const u32 *)&barts_sysls_enable;
  1487. count = BARTS_SYSLS_ENABLE_LENGTH;
  1488. } else if (rdev->family == CHIP_TURKS) {
  1489. p = (const u32 *)&turks_sysls_enable;
  1490. count = TURKS_SYSLS_ENABLE_LENGTH;
  1491. } else if (rdev->family == CHIP_CAICOS) {
  1492. p = (const u32 *)&caicos_sysls_enable;
  1493. count = CAICOS_SYSLS_ENABLE_LENGTH;
  1494. } else
  1495. return;
  1496. } else {
  1497. if (rdev->family == CHIP_BARTS) {
  1498. p = (const u32 *)&barts_sysls_disable;
  1499. count = BARTS_SYSLS_DISABLE_LENGTH;
  1500. } else if (rdev->family == CHIP_TURKS) {
  1501. p = (const u32 *)&turks_sysls_disable;
  1502. count = TURKS_SYSLS_DISABLE_LENGTH;
  1503. } else if (rdev->family == CHIP_CAICOS) {
  1504. p = (const u32 *)&caicos_sysls_disable;
  1505. count = CAICOS_SYSLS_DISABLE_LENGTH;
  1506. } else
  1507. return;
  1508. }
  1509. btc_program_mgcg_hw_sequence(rdev, p, count);
  1510. }
  1511. bool btc_dpm_enabled(struct radeon_device *rdev)
  1512. {
  1513. if (rv770_is_smc_running(rdev))
  1514. return true;
  1515. else
  1516. return false;
  1517. }
  1518. static int btc_init_smc_table(struct radeon_device *rdev,
  1519. struct radeon_ps *radeon_boot_state)
  1520. {
  1521. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  1522. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1523. RV770_SMC_STATETABLE *table = &pi->smc_statetable;
  1524. int ret;
  1525. memset(table, 0, sizeof(RV770_SMC_STATETABLE));
  1526. cypress_populate_smc_voltage_tables(rdev, table);
  1527. switch (rdev->pm.int_thermal_type) {
  1528. case THERMAL_TYPE_EVERGREEN:
  1529. case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
  1530. table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
  1531. break;
  1532. case THERMAL_TYPE_NONE:
  1533. table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
  1534. break;
  1535. default:
  1536. table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
  1537. break;
  1538. }
  1539. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
  1540. table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
  1541. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT)
  1542. table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
  1543. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
  1544. table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
  1545. if (pi->mem_gddr5)
  1546. table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
  1547. ret = cypress_populate_smc_initial_state(rdev, radeon_boot_state, table);
  1548. if (ret)
  1549. return ret;
  1550. if (eg_pi->sclk_deep_sleep)
  1551. WREG32_P(SCLK_PSKIP_CNTL, PSKIP_ON_ALLOW_STOP_HI(32),
  1552. ~PSKIP_ON_ALLOW_STOP_HI_MASK);
  1553. ret = btc_populate_smc_acpi_state(rdev, table);
  1554. if (ret)
  1555. return ret;
  1556. if (eg_pi->ulv.supported) {
  1557. ret = btc_populate_ulv_state(rdev, table);
  1558. if (ret)
  1559. eg_pi->ulv.supported = false;
  1560. }
  1561. table->driverState = table->initialState;
  1562. return rv770_copy_bytes_to_smc(rdev,
  1563. pi->state_table_start,
  1564. (u8 *)table,
  1565. sizeof(RV770_SMC_STATETABLE),
  1566. pi->sram_end);
  1567. }
  1568. static void btc_set_at_for_uvd(struct radeon_device *rdev,
  1569. struct radeon_ps *radeon_new_state)
  1570. {
  1571. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  1572. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1573. int idx = 0;
  1574. if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2))
  1575. idx = 1;
  1576. if ((idx == 1) && !eg_pi->smu_uvd_hs) {
  1577. pi->rlp = 10;
  1578. pi->rmp = 100;
  1579. pi->lhp = 100;
  1580. pi->lmp = 10;
  1581. } else {
  1582. pi->rlp = eg_pi->ats[idx].rlp;
  1583. pi->rmp = eg_pi->ats[idx].rmp;
  1584. pi->lhp = eg_pi->ats[idx].lhp;
  1585. pi->lmp = eg_pi->ats[idx].lmp;
  1586. }
  1587. }
  1588. void btc_notify_uvd_to_smc(struct radeon_device *rdev,
  1589. struct radeon_ps *radeon_new_state)
  1590. {
  1591. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1592. if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2)) {
  1593. rv770_write_smc_soft_register(rdev,
  1594. RV770_SMC_SOFT_REGISTER_uvd_enabled, 1);
  1595. eg_pi->uvd_enabled = true;
  1596. } else {
  1597. rv770_write_smc_soft_register(rdev,
  1598. RV770_SMC_SOFT_REGISTER_uvd_enabled, 0);
  1599. eg_pi->uvd_enabled = false;
  1600. }
  1601. }
  1602. int btc_reset_to_default(struct radeon_device *rdev)
  1603. {
  1604. if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_ResetToDefaults) != PPSMC_Result_OK)
  1605. return -EINVAL;
  1606. return 0;
  1607. }
  1608. static void btc_stop_smc(struct radeon_device *rdev)
  1609. {
  1610. int i;
  1611. for (i = 0; i < rdev->usec_timeout; i++) {
  1612. if (((RREG32(LB_SYNC_RESET_SEL) & LB_SYNC_RESET_SEL_MASK) >> LB_SYNC_RESET_SEL_SHIFT) != 1)
  1613. break;
  1614. udelay(1);
  1615. }
  1616. udelay(100);
  1617. r7xx_stop_smc(rdev);
  1618. }
  1619. void btc_read_arb_registers(struct radeon_device *rdev)
  1620. {
  1621. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1622. struct evergreen_arb_registers *arb_registers =
  1623. &eg_pi->bootup_arb_registers;
  1624. arb_registers->mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING);
  1625. arb_registers->mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
  1626. arb_registers->mc_arb_rfsh_rate = RREG32(MC_ARB_RFSH_RATE);
  1627. arb_registers->mc_arb_burst_time = RREG32(MC_ARB_BURST_TIME);
  1628. }
  1629. static void btc_set_arb0_registers(struct radeon_device *rdev,
  1630. struct evergreen_arb_registers *arb_registers)
  1631. {
  1632. u32 val;
  1633. WREG32(MC_ARB_DRAM_TIMING, arb_registers->mc_arb_dram_timing);
  1634. WREG32(MC_ARB_DRAM_TIMING2, arb_registers->mc_arb_dram_timing2);
  1635. val = (arb_registers->mc_arb_rfsh_rate & POWERMODE0_MASK) >>
  1636. POWERMODE0_SHIFT;
  1637. WREG32_P(MC_ARB_RFSH_RATE, POWERMODE0(val), ~POWERMODE0_MASK);
  1638. val = (arb_registers->mc_arb_burst_time & STATE0_MASK) >>
  1639. STATE0_SHIFT;
  1640. WREG32_P(MC_ARB_BURST_TIME, STATE0(val), ~STATE0_MASK);
  1641. }
  1642. static void btc_set_boot_state_timing(struct radeon_device *rdev)
  1643. {
  1644. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1645. if (eg_pi->ulv.supported)
  1646. btc_set_arb0_registers(rdev, &eg_pi->bootup_arb_registers);
  1647. }
  1648. static bool btc_is_state_ulv_compatible(struct radeon_device *rdev,
  1649. struct radeon_ps *radeon_state)
  1650. {
  1651. struct rv7xx_ps *state = rv770_get_ps(radeon_state);
  1652. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1653. struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
  1654. if (state->low.mclk != ulv_pl->mclk)
  1655. return false;
  1656. if (state->low.vddci != ulv_pl->vddci)
  1657. return false;
  1658. /* XXX check minclocks, etc. */
  1659. return true;
  1660. }
  1661. static int btc_set_ulv_dram_timing(struct radeon_device *rdev)
  1662. {
  1663. u32 val;
  1664. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1665. struct rv7xx_pl *ulv_pl = eg_pi->ulv.pl;
  1666. radeon_atom_set_engine_dram_timings(rdev,
  1667. ulv_pl->sclk,
  1668. ulv_pl->mclk);
  1669. val = rv770_calculate_memory_refresh_rate(rdev, ulv_pl->sclk);
  1670. WREG32_P(MC_ARB_RFSH_RATE, POWERMODE0(val), ~POWERMODE0_MASK);
  1671. val = cypress_calculate_burst_time(rdev, ulv_pl->sclk, ulv_pl->mclk);
  1672. WREG32_P(MC_ARB_BURST_TIME, STATE0(val), ~STATE0_MASK);
  1673. return 0;
  1674. }
  1675. static int btc_enable_ulv(struct radeon_device *rdev)
  1676. {
  1677. if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_EnableULV) != PPSMC_Result_OK)
  1678. return -EINVAL;
  1679. return 0;
  1680. }
  1681. static int btc_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev,
  1682. struct radeon_ps *radeon_new_state)
  1683. {
  1684. int ret = 0;
  1685. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1686. if (eg_pi->ulv.supported) {
  1687. if (btc_is_state_ulv_compatible(rdev, radeon_new_state)) {
  1688. // Set ARB[0] to reflect the DRAM timing needed for ULV.
  1689. ret = btc_set_ulv_dram_timing(rdev);
  1690. if (ret == 0)
  1691. ret = btc_enable_ulv(rdev);
  1692. }
  1693. }
  1694. return ret;
  1695. }
  1696. static bool btc_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
  1697. {
  1698. bool result = true;
  1699. switch (in_reg) {
  1700. case MC_SEQ_RAS_TIMING >> 2:
  1701. *out_reg = MC_SEQ_RAS_TIMING_LP >> 2;
  1702. break;
  1703. case MC_SEQ_CAS_TIMING >> 2:
  1704. *out_reg = MC_SEQ_CAS_TIMING_LP >> 2;
  1705. break;
  1706. case MC_SEQ_MISC_TIMING >> 2:
  1707. *out_reg = MC_SEQ_MISC_TIMING_LP >> 2;
  1708. break;
  1709. case MC_SEQ_MISC_TIMING2 >> 2:
  1710. *out_reg = MC_SEQ_MISC_TIMING2_LP >> 2;
  1711. break;
  1712. case MC_SEQ_RD_CTL_D0 >> 2:
  1713. *out_reg = MC_SEQ_RD_CTL_D0_LP >> 2;
  1714. break;
  1715. case MC_SEQ_RD_CTL_D1 >> 2:
  1716. *out_reg = MC_SEQ_RD_CTL_D1_LP >> 2;
  1717. break;
  1718. case MC_SEQ_WR_CTL_D0 >> 2:
  1719. *out_reg = MC_SEQ_WR_CTL_D0_LP >> 2;
  1720. break;
  1721. case MC_SEQ_WR_CTL_D1 >> 2:
  1722. *out_reg = MC_SEQ_WR_CTL_D1_LP >> 2;
  1723. break;
  1724. case MC_PMG_CMD_EMRS >> 2:
  1725. *out_reg = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
  1726. break;
  1727. case MC_PMG_CMD_MRS >> 2:
  1728. *out_reg = MC_SEQ_PMG_CMD_MRS_LP >> 2;
  1729. break;
  1730. case MC_PMG_CMD_MRS1 >> 2:
  1731. *out_reg = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
  1732. break;
  1733. default:
  1734. result = false;
  1735. break;
  1736. }
  1737. return result;
  1738. }
  1739. static void btc_set_valid_flag(struct evergreen_mc_reg_table *table)
  1740. {
  1741. u8 i, j;
  1742. for (i = 0; i < table->last; i++) {
  1743. for (j = 1; j < table->num_entries; j++) {
  1744. if (table->mc_reg_table_entry[j-1].mc_data[i] !=
  1745. table->mc_reg_table_entry[j].mc_data[i]) {
  1746. table->valid_flag |= (1 << i);
  1747. break;
  1748. }
  1749. }
  1750. }
  1751. }
  1752. static int btc_set_mc_special_registers(struct radeon_device *rdev,
  1753. struct evergreen_mc_reg_table *table)
  1754. {
  1755. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  1756. u8 i, j, k;
  1757. u32 tmp;
  1758. for (i = 0, j = table->last; i < table->last; i++) {
  1759. switch (table->mc_reg_address[i].s1) {
  1760. case MC_SEQ_MISC1 >> 2:
  1761. tmp = RREG32(MC_PMG_CMD_EMRS);
  1762. table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS >> 2;
  1763. table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP >> 2;
  1764. for (k = 0; k < table->num_entries; k++) {
  1765. table->mc_reg_table_entry[k].mc_data[j] =
  1766. ((tmp & 0xffff0000)) |
  1767. ((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
  1768. }
  1769. j++;
  1770. if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
  1771. return -EINVAL;
  1772. tmp = RREG32(MC_PMG_CMD_MRS);
  1773. table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS >> 2;
  1774. table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP >> 2;
  1775. for (k = 0; k < table->num_entries; k++) {
  1776. table->mc_reg_table_entry[k].mc_data[j] =
  1777. (tmp & 0xffff0000) |
  1778. (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
  1779. if (!pi->mem_gddr5)
  1780. table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
  1781. }
  1782. j++;
  1783. if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
  1784. return -EINVAL;
  1785. break;
  1786. case MC_SEQ_RESERVE_M >> 2:
  1787. tmp = RREG32(MC_PMG_CMD_MRS1);
  1788. table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1 >> 2;
  1789. table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
  1790. for (k = 0; k < table->num_entries; k++) {
  1791. table->mc_reg_table_entry[k].mc_data[j] =
  1792. (tmp & 0xffff0000) |
  1793. (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
  1794. }
  1795. j++;
  1796. if (j >= SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
  1797. return -EINVAL;
  1798. break;
  1799. default:
  1800. break;
  1801. }
  1802. }
  1803. table->last = j;
  1804. return 0;
  1805. }
  1806. static void btc_set_s0_mc_reg_index(struct evergreen_mc_reg_table *table)
  1807. {
  1808. u32 i;
  1809. u16 address;
  1810. for (i = 0; i < table->last; i++) {
  1811. table->mc_reg_address[i].s0 =
  1812. btc_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
  1813. address : table->mc_reg_address[i].s1;
  1814. }
  1815. }
  1816. static int btc_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
  1817. struct evergreen_mc_reg_table *eg_table)
  1818. {
  1819. u8 i, j;
  1820. if (table->last > SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE)
  1821. return -EINVAL;
  1822. if (table->num_entries > MAX_AC_TIMING_ENTRIES)
  1823. return -EINVAL;
  1824. for (i = 0; i < table->last; i++)
  1825. eg_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
  1826. eg_table->last = table->last;
  1827. for (i = 0; i < table->num_entries; i++) {
  1828. eg_table->mc_reg_table_entry[i].mclk_max =
  1829. table->mc_reg_table_entry[i].mclk_max;
  1830. for(j = 0; j < table->last; j++)
  1831. eg_table->mc_reg_table_entry[i].mc_data[j] =
  1832. table->mc_reg_table_entry[i].mc_data[j];
  1833. }
  1834. eg_table->num_entries = table->num_entries;
  1835. return 0;
  1836. }
  1837. static int btc_initialize_mc_reg_table(struct radeon_device *rdev)
  1838. {
  1839. int ret;
  1840. struct atom_mc_reg_table *table;
  1841. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  1842. struct evergreen_mc_reg_table *eg_table = &eg_pi->mc_reg_table;
  1843. u8 module_index = rv770_get_memory_module_index(rdev);
  1844. table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
  1845. if (!table)
  1846. return -ENOMEM;
  1847. /* Program additional LP registers that are no longer programmed by VBIOS */
  1848. WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
  1849. WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
  1850. WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
  1851. WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
  1852. WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
  1853. WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
  1854. WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
  1855. WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
  1856. WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
  1857. WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
  1858. WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
  1859. ret = radeon_atom_init_mc_reg_table(rdev, module_index, table);
  1860. if (ret)
  1861. goto init_mc_done;
  1862. ret = btc_copy_vbios_mc_reg_table(table, eg_table);
  1863. if (ret)
  1864. goto init_mc_done;
  1865. btc_set_s0_mc_reg_index(eg_table);
  1866. ret = btc_set_mc_special_registers(rdev, eg_table);
  1867. if (ret)
  1868. goto init_mc_done;
  1869. btc_set_valid_flag(eg_table);
  1870. init_mc_done:
  1871. kfree(table);
  1872. return ret;
  1873. }
  1874. static void btc_init_stutter_mode(struct radeon_device *rdev)
  1875. {
  1876. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  1877. u32 tmp;
  1878. if (pi->mclk_stutter_mode_threshold) {
  1879. if (pi->mem_gddr5) {
  1880. tmp = RREG32(MC_PMG_AUTO_CFG);
  1881. if ((0x200 & tmp) == 0) {
  1882. tmp = (tmp & 0xfffffc0b) | 0x204;
  1883. WREG32(MC_PMG_AUTO_CFG, tmp);
  1884. }
  1885. }
  1886. }
  1887. }
  1888. bool btc_dpm_vblank_too_short(struct radeon_device *rdev)
  1889. {
  1890. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  1891. u32 vblank_time = r600_dpm_get_vblank_time(rdev);
  1892. u32 switch_limit = pi->mem_gddr5 ? 450 : 100;
  1893. if (vblank_time < switch_limit)
  1894. return true;
  1895. else
  1896. return false;
  1897. }
  1898. static void btc_apply_state_adjust_rules(struct radeon_device *rdev,
  1899. struct radeon_ps *rps)
  1900. {
  1901. struct rv7xx_ps *ps = rv770_get_ps(rps);
  1902. struct radeon_clock_and_voltage_limits *max_limits;
  1903. bool disable_mclk_switching;
  1904. u32 mclk, sclk;
  1905. u16 vddc, vddci;
  1906. if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
  1907. btc_dpm_vblank_too_short(rdev))
  1908. disable_mclk_switching = true;
  1909. else
  1910. disable_mclk_switching = false;
  1911. if (rdev->pm.dpm.ac_power)
  1912. max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
  1913. else
  1914. max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
  1915. if (rdev->pm.dpm.ac_power == false) {
  1916. if (ps->high.mclk > max_limits->mclk)
  1917. ps->high.mclk = max_limits->mclk;
  1918. if (ps->high.sclk > max_limits->sclk)
  1919. ps->high.sclk = max_limits->sclk;
  1920. if (ps->high.vddc > max_limits->vddc)
  1921. ps->high.vddc = max_limits->vddc;
  1922. if (ps->high.vddci > max_limits->vddci)
  1923. ps->high.vddci = max_limits->vddci;
  1924. if (ps->medium.mclk > max_limits->mclk)
  1925. ps->medium.mclk = max_limits->mclk;
  1926. if (ps->medium.sclk > max_limits->sclk)
  1927. ps->medium.sclk = max_limits->sclk;
  1928. if (ps->medium.vddc > max_limits->vddc)
  1929. ps->medium.vddc = max_limits->vddc;
  1930. if (ps->medium.vddci > max_limits->vddci)
  1931. ps->medium.vddci = max_limits->vddci;
  1932. if (ps->low.mclk > max_limits->mclk)
  1933. ps->low.mclk = max_limits->mclk;
  1934. if (ps->low.sclk > max_limits->sclk)
  1935. ps->low.sclk = max_limits->sclk;
  1936. if (ps->low.vddc > max_limits->vddc)
  1937. ps->low.vddc = max_limits->vddc;
  1938. if (ps->low.vddci > max_limits->vddci)
  1939. ps->low.vddci = max_limits->vddci;
  1940. }
  1941. /* XXX validate the min clocks required for display */
  1942. if (disable_mclk_switching) {
  1943. sclk = ps->low.sclk;
  1944. mclk = ps->high.mclk;
  1945. vddc = ps->low.vddc;
  1946. vddci = ps->high.vddci;
  1947. } else {
  1948. sclk = ps->low.sclk;
  1949. mclk = ps->low.mclk;
  1950. vddc = ps->low.vddc;
  1951. vddci = ps->low.vddci;
  1952. }
  1953. /* adjusted low state */
  1954. ps->low.sclk = sclk;
  1955. ps->low.mclk = mclk;
  1956. ps->low.vddc = vddc;
  1957. ps->low.vddci = vddci;
  1958. btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
  1959. &ps->low.sclk, &ps->low.mclk);
  1960. /* adjusted medium, high states */
  1961. if (ps->medium.sclk < ps->low.sclk)
  1962. ps->medium.sclk = ps->low.sclk;
  1963. if (ps->medium.vddc < ps->low.vddc)
  1964. ps->medium.vddc = ps->low.vddc;
  1965. if (ps->high.sclk < ps->medium.sclk)
  1966. ps->high.sclk = ps->medium.sclk;
  1967. if (ps->high.vddc < ps->medium.vddc)
  1968. ps->high.vddc = ps->medium.vddc;
  1969. if (disable_mclk_switching) {
  1970. mclk = ps->low.mclk;
  1971. if (mclk < ps->medium.mclk)
  1972. mclk = ps->medium.mclk;
  1973. if (mclk < ps->high.mclk)
  1974. mclk = ps->high.mclk;
  1975. ps->low.mclk = mclk;
  1976. ps->low.vddci = vddci;
  1977. ps->medium.mclk = mclk;
  1978. ps->medium.vddci = vddci;
  1979. ps->high.mclk = mclk;
  1980. ps->high.vddci = vddci;
  1981. } else {
  1982. if (ps->medium.mclk < ps->low.mclk)
  1983. ps->medium.mclk = ps->low.mclk;
  1984. if (ps->medium.vddci < ps->low.vddci)
  1985. ps->medium.vddci = ps->low.vddci;
  1986. if (ps->high.mclk < ps->medium.mclk)
  1987. ps->high.mclk = ps->medium.mclk;
  1988. if (ps->high.vddci < ps->medium.vddci)
  1989. ps->high.vddci = ps->medium.vddci;
  1990. }
  1991. btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
  1992. &ps->medium.sclk, &ps->medium.mclk);
  1993. btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
  1994. &ps->high.sclk, &ps->high.mclk);
  1995. btc_adjust_clock_combinations(rdev, max_limits, &ps->low);
  1996. btc_adjust_clock_combinations(rdev, max_limits, &ps->medium);
  1997. btc_adjust_clock_combinations(rdev, max_limits, &ps->high);
  1998. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
  1999. ps->low.sclk, max_limits->vddc, &ps->low.vddc);
  2000. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
  2001. ps->low.mclk, max_limits->vddci, &ps->low.vddci);
  2002. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
  2003. ps->low.mclk, max_limits->vddc, &ps->low.vddc);
  2004. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
  2005. rdev->clock.current_dispclk, max_limits->vddc, &ps->low.vddc);
  2006. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
  2007. ps->medium.sclk, max_limits->vddc, &ps->medium.vddc);
  2008. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
  2009. ps->medium.mclk, max_limits->vddci, &ps->medium.vddci);
  2010. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
  2011. ps->medium.mclk, max_limits->vddc, &ps->medium.vddc);
  2012. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
  2013. rdev->clock.current_dispclk, max_limits->vddc, &ps->medium.vddc);
  2014. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
  2015. ps->high.sclk, max_limits->vddc, &ps->high.vddc);
  2016. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
  2017. ps->high.mclk, max_limits->vddci, &ps->high.vddci);
  2018. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
  2019. ps->high.mclk, max_limits->vddc, &ps->high.vddc);
  2020. btc_apply_voltage_dependency_rules(&rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
  2021. rdev->clock.current_dispclk, max_limits->vddc, &ps->high.vddc);
  2022. btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
  2023. &ps->low.vddc, &ps->low.vddci);
  2024. btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
  2025. &ps->medium.vddc, &ps->medium.vddci);
  2026. btc_apply_voltage_delta_rules(rdev, max_limits->vddc, max_limits->vddci,
  2027. &ps->high.vddc, &ps->high.vddci);
  2028. if ((ps->high.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) &&
  2029. (ps->medium.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc) &&
  2030. (ps->low.vddc <= rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc))
  2031. ps->dc_compatible = true;
  2032. else
  2033. ps->dc_compatible = false;
  2034. if (ps->low.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
  2035. ps->low.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
  2036. if (ps->medium.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
  2037. ps->medium.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
  2038. if (ps->high.vddc < rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2)
  2039. ps->high.flags &= ~ATOM_PPLIB_R600_FLAGS_PCIEGEN2;
  2040. }
  2041. static void btc_update_current_ps(struct radeon_device *rdev,
  2042. struct radeon_ps *rps)
  2043. {
  2044. struct rv7xx_ps *new_ps = rv770_get_ps(rps);
  2045. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2046. eg_pi->current_rps = *rps;
  2047. eg_pi->current_ps = *new_ps;
  2048. eg_pi->current_rps.ps_priv = &eg_pi->current_ps;
  2049. }
  2050. static void btc_update_requested_ps(struct radeon_device *rdev,
  2051. struct radeon_ps *rps)
  2052. {
  2053. struct rv7xx_ps *new_ps = rv770_get_ps(rps);
  2054. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2055. eg_pi->requested_rps = *rps;
  2056. eg_pi->requested_ps = *new_ps;
  2057. eg_pi->requested_rps.ps_priv = &eg_pi->requested_ps;
  2058. }
  2059. #if 0
  2060. void btc_dpm_reset_asic(struct radeon_device *rdev)
  2061. {
  2062. rv770_restrict_performance_levels_before_switch(rdev);
  2063. btc_disable_ulv(rdev);
  2064. btc_set_boot_state_timing(rdev);
  2065. rv770_set_boot_state(rdev);
  2066. }
  2067. #endif
  2068. int btc_dpm_pre_set_power_state(struct radeon_device *rdev)
  2069. {
  2070. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2071. struct radeon_ps requested_ps = *rdev->pm.dpm.requested_ps;
  2072. struct radeon_ps *new_ps = &requested_ps;
  2073. btc_update_requested_ps(rdev, new_ps);
  2074. btc_apply_state_adjust_rules(rdev, &eg_pi->requested_rps);
  2075. return 0;
  2076. }
  2077. int btc_dpm_set_power_state(struct radeon_device *rdev)
  2078. {
  2079. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2080. struct radeon_ps *new_ps = &eg_pi->requested_rps;
  2081. struct radeon_ps *old_ps = &eg_pi->current_rps;
  2082. int ret;
  2083. ret = btc_disable_ulv(rdev);
  2084. btc_set_boot_state_timing(rdev);
  2085. ret = rv770_restrict_performance_levels_before_switch(rdev);
  2086. if (ret) {
  2087. DRM_ERROR("rv770_restrict_performance_levels_before_switch failed\n");
  2088. return ret;
  2089. }
  2090. if (eg_pi->pcie_performance_request)
  2091. cypress_notify_link_speed_change_before_state_change(rdev, new_ps, old_ps);
  2092. rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
  2093. ret = rv770_halt_smc(rdev);
  2094. if (ret) {
  2095. DRM_ERROR("rv770_halt_smc failed\n");
  2096. return ret;
  2097. }
  2098. btc_set_at_for_uvd(rdev, new_ps);
  2099. if (eg_pi->smu_uvd_hs)
  2100. btc_notify_uvd_to_smc(rdev, new_ps);
  2101. ret = cypress_upload_sw_state(rdev, new_ps);
  2102. if (ret) {
  2103. DRM_ERROR("cypress_upload_sw_state failed\n");
  2104. return ret;
  2105. }
  2106. if (eg_pi->dynamic_ac_timing) {
  2107. ret = cypress_upload_mc_reg_table(rdev, new_ps);
  2108. if (ret) {
  2109. DRM_ERROR("cypress_upload_mc_reg_table failed\n");
  2110. return ret;
  2111. }
  2112. }
  2113. cypress_program_memory_timing_parameters(rdev, new_ps);
  2114. ret = rv770_resume_smc(rdev);
  2115. if (ret) {
  2116. DRM_ERROR("rv770_resume_smc failed\n");
  2117. return ret;
  2118. }
  2119. ret = rv770_set_sw_state(rdev);
  2120. if (ret) {
  2121. DRM_ERROR("rv770_set_sw_state failed\n");
  2122. return ret;
  2123. }
  2124. rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
  2125. if (eg_pi->pcie_performance_request)
  2126. cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps);
  2127. ret = btc_set_power_state_conditionally_enable_ulv(rdev, new_ps);
  2128. if (ret) {
  2129. DRM_ERROR("btc_set_power_state_conditionally_enable_ulv failed\n");
  2130. return ret;
  2131. }
  2132. return 0;
  2133. }
  2134. void btc_dpm_post_set_power_state(struct radeon_device *rdev)
  2135. {
  2136. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2137. struct radeon_ps *new_ps = &eg_pi->requested_rps;
  2138. btc_update_current_ps(rdev, new_ps);
  2139. }
  2140. int btc_dpm_enable(struct radeon_device *rdev)
  2141. {
  2142. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  2143. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2144. struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps;
  2145. int ret;
  2146. if (pi->gfx_clock_gating)
  2147. btc_cg_clock_gating_default(rdev);
  2148. if (btc_dpm_enabled(rdev))
  2149. return -EINVAL;
  2150. if (pi->mg_clock_gating)
  2151. btc_mg_clock_gating_default(rdev);
  2152. if (eg_pi->ls_clock_gating)
  2153. btc_ls_clock_gating_default(rdev);
  2154. if (pi->voltage_control) {
  2155. rv770_enable_voltage_control(rdev, true);
  2156. ret = cypress_construct_voltage_tables(rdev);
  2157. if (ret) {
  2158. DRM_ERROR("cypress_construct_voltage_tables failed\n");
  2159. return ret;
  2160. }
  2161. }
  2162. if (pi->mvdd_control) {
  2163. ret = cypress_get_mvdd_configuration(rdev);
  2164. if (ret) {
  2165. DRM_ERROR("cypress_get_mvdd_configuration failed\n");
  2166. return ret;
  2167. }
  2168. }
  2169. if (eg_pi->dynamic_ac_timing) {
  2170. ret = btc_initialize_mc_reg_table(rdev);
  2171. if (ret)
  2172. eg_pi->dynamic_ac_timing = false;
  2173. }
  2174. if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_BACKBIAS)
  2175. rv770_enable_backbias(rdev, true);
  2176. if (pi->dynamic_ss)
  2177. cypress_enable_spread_spectrum(rdev, true);
  2178. if (pi->thermal_protection)
  2179. rv770_enable_thermal_protection(rdev, true);
  2180. rv770_setup_bsp(rdev);
  2181. rv770_program_git(rdev);
  2182. rv770_program_tp(rdev);
  2183. rv770_program_tpp(rdev);
  2184. rv770_program_sstp(rdev);
  2185. rv770_program_engine_speed_parameters(rdev);
  2186. cypress_enable_display_gap(rdev);
  2187. rv770_program_vc(rdev);
  2188. if (pi->dynamic_pcie_gen2)
  2189. btc_enable_dynamic_pcie_gen2(rdev, true);
  2190. ret = rv770_upload_firmware(rdev);
  2191. if (ret) {
  2192. DRM_ERROR("rv770_upload_firmware failed\n");
  2193. return ret;
  2194. }
  2195. ret = cypress_get_table_locations(rdev);
  2196. if (ret) {
  2197. DRM_ERROR("cypress_get_table_locations failed\n");
  2198. return ret;
  2199. }
  2200. ret = btc_init_smc_table(rdev, boot_ps);
  2201. if (ret)
  2202. return ret;
  2203. if (eg_pi->dynamic_ac_timing) {
  2204. ret = cypress_populate_mc_reg_table(rdev, boot_ps);
  2205. if (ret) {
  2206. DRM_ERROR("cypress_populate_mc_reg_table failed\n");
  2207. return ret;
  2208. }
  2209. }
  2210. cypress_program_response_times(rdev);
  2211. r7xx_start_smc(rdev);
  2212. ret = cypress_notify_smc_display_change(rdev, false);
  2213. if (ret) {
  2214. DRM_ERROR("cypress_notify_smc_display_change failed\n");
  2215. return ret;
  2216. }
  2217. cypress_enable_sclk_control(rdev, true);
  2218. if (eg_pi->memory_transition)
  2219. cypress_enable_mclk_control(rdev, true);
  2220. cypress_start_dpm(rdev);
  2221. if (pi->gfx_clock_gating)
  2222. btc_cg_clock_gating_enable(rdev, true);
  2223. if (pi->mg_clock_gating)
  2224. btc_mg_clock_gating_enable(rdev, true);
  2225. if (eg_pi->ls_clock_gating)
  2226. btc_ls_clock_gating_enable(rdev, true);
  2227. rv770_enable_auto_throttle_source(rdev, RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
  2228. btc_init_stutter_mode(rdev);
  2229. btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
  2230. return 0;
  2231. };
  2232. void btc_dpm_disable(struct radeon_device *rdev)
  2233. {
  2234. struct rv7xx_power_info *pi = rv770_get_pi(rdev);
  2235. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2236. if (!btc_dpm_enabled(rdev))
  2237. return;
  2238. rv770_clear_vc(rdev);
  2239. if (pi->thermal_protection)
  2240. rv770_enable_thermal_protection(rdev, false);
  2241. if (pi->dynamic_pcie_gen2)
  2242. btc_enable_dynamic_pcie_gen2(rdev, false);
  2243. if (rdev->irq.installed &&
  2244. r600_is_internal_thermal_sensor(rdev->pm.int_thermal_type)) {
  2245. rdev->irq.dpm_thermal = false;
  2246. radeon_irq_set(rdev);
  2247. }
  2248. if (pi->gfx_clock_gating)
  2249. btc_cg_clock_gating_enable(rdev, false);
  2250. if (pi->mg_clock_gating)
  2251. btc_mg_clock_gating_enable(rdev, false);
  2252. if (eg_pi->ls_clock_gating)
  2253. btc_ls_clock_gating_enable(rdev, false);
  2254. rv770_stop_dpm(rdev);
  2255. btc_reset_to_default(rdev);
  2256. btc_stop_smc(rdev);
  2257. cypress_enable_spread_spectrum(rdev, false);
  2258. btc_update_current_ps(rdev, rdev->pm.dpm.boot_ps);
  2259. }
  2260. void btc_dpm_setup_asic(struct radeon_device *rdev)
  2261. {
  2262. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2263. int r;
  2264. r = ni_mc_load_microcode(rdev);
  2265. if (r)
  2266. DRM_ERROR("Failed to load MC firmware!\n");
  2267. rv770_get_memory_type(rdev);
  2268. rv740_read_clock_registers(rdev);
  2269. btc_read_arb_registers(rdev);
  2270. rv770_read_voltage_smio_registers(rdev);
  2271. if (eg_pi->pcie_performance_request)
  2272. cypress_advertise_gen2_capability(rdev);
  2273. rv770_get_pcie_gen2_status(rdev);
  2274. rv770_enable_acpi_pm(rdev);
  2275. }
  2276. int btc_dpm_init(struct radeon_device *rdev)
  2277. {
  2278. struct rv7xx_power_info *pi;
  2279. struct evergreen_power_info *eg_pi;
  2280. struct atom_clock_dividers dividers;
  2281. int ret;
  2282. eg_pi = kzalloc(sizeof(struct evergreen_power_info), GFP_KERNEL);
  2283. if (eg_pi == NULL)
  2284. return -ENOMEM;
  2285. rdev->pm.dpm.priv = eg_pi;
  2286. pi = &eg_pi->rv7xx;
  2287. rv770_get_max_vddc(rdev);
  2288. eg_pi->ulv.supported = false;
  2289. pi->acpi_vddc = 0;
  2290. eg_pi->acpi_vddci = 0;
  2291. pi->min_vddc_in_table = 0;
  2292. pi->max_vddc_in_table = 0;
  2293. ret = r600_get_platform_caps(rdev);
  2294. if (ret)
  2295. return ret;
  2296. ret = rv7xx_parse_power_table(rdev);
  2297. if (ret)
  2298. return ret;
  2299. ret = r600_parse_extended_power_table(rdev);
  2300. if (ret)
  2301. return ret;
  2302. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
  2303. kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
  2304. if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
  2305. r600_free_extended_power_table(rdev);
  2306. return -ENOMEM;
  2307. }
  2308. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
  2309. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
  2310. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
  2311. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
  2312. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 800;
  2313. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
  2314. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 800;
  2315. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
  2316. rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 800;
  2317. if (rdev->pm.dpm.voltage_response_time == 0)
  2318. rdev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
  2319. if (rdev->pm.dpm.backbias_response_time == 0)
  2320. rdev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
  2321. ret = radeon_atom_get_clock_dividers(rdev, COMPUTE_ENGINE_PLL_PARAM,
  2322. 0, false, &dividers);
  2323. if (ret)
  2324. pi->ref_div = dividers.ref_div + 1;
  2325. else
  2326. pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
  2327. pi->mclk_strobe_mode_threshold = 40000;
  2328. pi->mclk_edc_enable_threshold = 40000;
  2329. eg_pi->mclk_edc_wr_enable_threshold = 40000;
  2330. pi->rlp = RV770_RLP_DFLT;
  2331. pi->rmp = RV770_RMP_DFLT;
  2332. pi->lhp = RV770_LHP_DFLT;
  2333. pi->lmp = RV770_LMP_DFLT;
  2334. eg_pi->ats[0].rlp = RV770_RLP_DFLT;
  2335. eg_pi->ats[0].rmp = RV770_RMP_DFLT;
  2336. eg_pi->ats[0].lhp = RV770_LHP_DFLT;
  2337. eg_pi->ats[0].lmp = RV770_LMP_DFLT;
  2338. eg_pi->ats[1].rlp = BTC_RLP_UVD_DFLT;
  2339. eg_pi->ats[1].rmp = BTC_RMP_UVD_DFLT;
  2340. eg_pi->ats[1].lhp = BTC_LHP_UVD_DFLT;
  2341. eg_pi->ats[1].lmp = BTC_LMP_UVD_DFLT;
  2342. eg_pi->smu_uvd_hs = true;
  2343. pi->voltage_control =
  2344. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, 0);
  2345. pi->mvdd_control =
  2346. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0);
  2347. eg_pi->vddci_control =
  2348. radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
  2349. rv770_get_engine_memory_ss(rdev);
  2350. pi->asi = RV770_ASI_DFLT;
  2351. pi->pasi = CYPRESS_HASI_DFLT;
  2352. pi->vrc = CYPRESS_VRC_DFLT;
  2353. pi->power_gating = false;
  2354. pi->gfx_clock_gating = true;
  2355. pi->mg_clock_gating = true;
  2356. pi->mgcgtssm = true;
  2357. eg_pi->ls_clock_gating = false;
  2358. eg_pi->sclk_deep_sleep = false;
  2359. pi->dynamic_pcie_gen2 = true;
  2360. if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
  2361. pi->thermal_protection = true;
  2362. else
  2363. pi->thermal_protection = false;
  2364. pi->display_gap = true;
  2365. if (rdev->flags & RADEON_IS_MOBILITY)
  2366. pi->dcodt = true;
  2367. else
  2368. pi->dcodt = false;
  2369. pi->ulps = true;
  2370. eg_pi->dynamic_ac_timing = true;
  2371. eg_pi->abm = true;
  2372. eg_pi->mcls = true;
  2373. eg_pi->light_sleep = true;
  2374. eg_pi->memory_transition = true;
  2375. #if defined(CONFIG_ACPI)
  2376. eg_pi->pcie_performance_request =
  2377. radeon_acpi_is_pcie_performance_request_supported(rdev);
  2378. #else
  2379. eg_pi->pcie_performance_request = false;
  2380. #endif
  2381. if (rdev->family == CHIP_BARTS)
  2382. eg_pi->dll_default_on = true;
  2383. else
  2384. eg_pi->dll_default_on = false;
  2385. eg_pi->sclk_deep_sleep = false;
  2386. if (ASIC_IS_LOMBOK(rdev))
  2387. pi->mclk_stutter_mode_threshold = 30000;
  2388. else
  2389. pi->mclk_stutter_mode_threshold = 0;
  2390. pi->sram_end = SMC_RAM_END;
  2391. rdev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
  2392. rdev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
  2393. rdev->pm.dpm.dyn_state.min_vddc_for_pcie_gen2 = 900;
  2394. rdev->pm.dpm.dyn_state.valid_sclk_values.count = ARRAY_SIZE(btc_valid_sclk);
  2395. rdev->pm.dpm.dyn_state.valid_sclk_values.values = btc_valid_sclk;
  2396. rdev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
  2397. rdev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
  2398. if (rdev->family == CHIP_TURKS)
  2399. rdev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
  2400. else
  2401. rdev->pm.dpm.dyn_state.sclk_mclk_delta = 10000;
  2402. /* make sure dc limits are valid */
  2403. if ((rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
  2404. (rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
  2405. rdev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
  2406. rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
  2407. return 0;
  2408. }
  2409. void btc_dpm_fini(struct radeon_device *rdev)
  2410. {
  2411. int i;
  2412. for (i = 0; i < rdev->pm.dpm.num_ps; i++) {
  2413. kfree(rdev->pm.dpm.ps[i].ps_priv);
  2414. }
  2415. kfree(rdev->pm.dpm.ps);
  2416. kfree(rdev->pm.dpm.priv);
  2417. kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
  2418. r600_free_extended_power_table(rdev);
  2419. }
  2420. void btc_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
  2421. struct seq_file *m)
  2422. {
  2423. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2424. struct radeon_ps *rps = &eg_pi->current_rps;
  2425. struct rv7xx_ps *ps = rv770_get_ps(rps);
  2426. struct rv7xx_pl *pl;
  2427. u32 current_index =
  2428. (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
  2429. CURRENT_PROFILE_INDEX_SHIFT;
  2430. if (current_index > 2) {
  2431. seq_printf(m, "invalid dpm profile %d\n", current_index);
  2432. } else {
  2433. if (current_index == 0)
  2434. pl = &ps->low;
  2435. else if (current_index == 1)
  2436. pl = &ps->medium;
  2437. else /* current_index == 2 */
  2438. pl = &ps->high;
  2439. seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
  2440. seq_printf(m, "power level %d sclk: %u mclk: %u vddc: %u vddci: %u\n",
  2441. current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci);
  2442. }
  2443. }
  2444. u32 btc_dpm_get_current_sclk(struct radeon_device *rdev)
  2445. {
  2446. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2447. struct radeon_ps *rps = &eg_pi->current_rps;
  2448. struct rv7xx_ps *ps = rv770_get_ps(rps);
  2449. struct rv7xx_pl *pl;
  2450. u32 current_index =
  2451. (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
  2452. CURRENT_PROFILE_INDEX_SHIFT;
  2453. if (current_index > 2) {
  2454. return 0;
  2455. } else {
  2456. if (current_index == 0)
  2457. pl = &ps->low;
  2458. else if (current_index == 1)
  2459. pl = &ps->medium;
  2460. else /* current_index == 2 */
  2461. pl = &ps->high;
  2462. return pl->sclk;
  2463. }
  2464. }
  2465. u32 btc_dpm_get_current_mclk(struct radeon_device *rdev)
  2466. {
  2467. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2468. struct radeon_ps *rps = &eg_pi->current_rps;
  2469. struct rv7xx_ps *ps = rv770_get_ps(rps);
  2470. struct rv7xx_pl *pl;
  2471. u32 current_index =
  2472. (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_PROFILE_INDEX_MASK) >>
  2473. CURRENT_PROFILE_INDEX_SHIFT;
  2474. if (current_index > 2) {
  2475. return 0;
  2476. } else {
  2477. if (current_index == 0)
  2478. pl = &ps->low;
  2479. else if (current_index == 1)
  2480. pl = &ps->medium;
  2481. else /* current_index == 2 */
  2482. pl = &ps->high;
  2483. return pl->mclk;
  2484. }
  2485. }
  2486. u32 btc_dpm_get_sclk(struct radeon_device *rdev, bool low)
  2487. {
  2488. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2489. struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps);
  2490. if (low)
  2491. return requested_state->low.sclk;
  2492. else
  2493. return requested_state->high.sclk;
  2494. }
  2495. u32 btc_dpm_get_mclk(struct radeon_device *rdev, bool low)
  2496. {
  2497. struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev);
  2498. struct rv7xx_ps *requested_state = rv770_get_ps(&eg_pi->requested_rps);
  2499. if (low)
  2500. return requested_state->low.mclk;
  2501. else
  2502. return requested_state->high.mclk;
  2503. }