si.c 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901
  1. /*
  2. * Copyright 2015 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. */
  23. #include <linux/firmware.h>
  24. #include <linux/slab.h>
  25. #include <linux/module.h>
  26. #include "drmP.h"
  27. #include "amdgpu.h"
  28. #include "amdgpu_atombios.h"
  29. #include "amdgpu_ih.h"
  30. #include "amdgpu_uvd.h"
  31. #include "amdgpu_vce.h"
  32. #include "atom.h"
  33. #include "amdgpu_powerplay.h"
  34. #include "si/sid.h"
  35. #include "si_ih.h"
  36. #include "gfx_v6_0.h"
  37. #include "gmc_v6_0.h"
  38. #include "si_dma.h"
  39. #include "dce_v6_0.h"
  40. #include "si.h"
  41. #include "dce_virtual.h"
  42. static const u32 tahiti_golden_registers[] =
  43. {
  44. 0x17bc, 0x00000030, 0x00000011,
  45. 0x2684, 0x00010000, 0x00018208,
  46. 0x260c, 0xffffffff, 0x00000000,
  47. 0x260d, 0xf00fffff, 0x00000400,
  48. 0x260e, 0x0002021c, 0x00020200,
  49. 0x031e, 0x00000080, 0x00000000,
  50. 0x340c, 0x000000c0, 0x00800040,
  51. 0x360c, 0x000000c0, 0x00800040,
  52. 0x16ec, 0x000000f0, 0x00000070,
  53. 0x16f0, 0x00200000, 0x50100000,
  54. 0x1c0c, 0x31000311, 0x00000011,
  55. 0x09df, 0x00000003, 0x000007ff,
  56. 0x0903, 0x000007ff, 0x00000000,
  57. 0x2285, 0xf000001f, 0x00000007,
  58. 0x22c9, 0xffffffff, 0x00ffffff,
  59. 0x22c4, 0x0000ff0f, 0x00000000,
  60. 0xa293, 0x07ffffff, 0x4e000000,
  61. 0xa0d4, 0x3f3f3fff, 0x2a00126a,
  62. 0x000c, 0xffffffff, 0x0040,
  63. 0x000d, 0x00000040, 0x00004040,
  64. 0x2440, 0x07ffffff, 0x03000000,
  65. 0x23a2, 0x01ff1f3f, 0x00000000,
  66. 0x23a1, 0x01ff1f3f, 0x00000000,
  67. 0x2418, 0x0000007f, 0x00000020,
  68. 0x2542, 0x00010000, 0x00010000,
  69. 0x2b05, 0x00000200, 0x000002fb,
  70. 0x2b04, 0xffffffff, 0x0000543b,
  71. 0x2b03, 0xffffffff, 0xa9210876,
  72. 0x2234, 0xffffffff, 0x000fff40,
  73. 0x2235, 0x0000001f, 0x00000010,
  74. 0x0504, 0x20000000, 0x20fffed8,
  75. 0x0570, 0x000c0fc0, 0x000c0400,
  76. 0x052c, 0x0fffffff, 0xffffffff,
  77. 0x052d, 0x0fffffff, 0x0fffffff,
  78. 0x052e, 0x0fffffff, 0x0fffffff,
  79. 0x052f, 0x0fffffff, 0x0fffffff
  80. };
  81. static const u32 tahiti_golden_registers2[] =
  82. {
  83. 0x0319, 0x00000001, 0x00000001
  84. };
  85. static const u32 tahiti_golden_rlc_registers[] =
  86. {
  87. 0x263e, 0xffffffff, 0x12011003,
  88. 0x3109, 0xffffffff, 0x00601005,
  89. 0x311f, 0xffffffff, 0x10104040,
  90. 0x3122, 0xffffffff, 0x0100000a,
  91. 0x30c5, 0xffffffff, 0x00000800,
  92. 0x30c3, 0xffffffff, 0x800000f4,
  93. 0x3d2a, 0x00000008, 0x00000000
  94. };
  95. static const u32 pitcairn_golden_registers[] =
  96. {
  97. 0x17bc, 0x00000030, 0x00000011,
  98. 0x2684, 0x00010000, 0x00018208,
  99. 0x260c, 0xffffffff, 0x00000000,
  100. 0x260d, 0xf00fffff, 0x00000400,
  101. 0x260e, 0x0002021c, 0x00020200,
  102. 0x031e, 0x00000080, 0x00000000,
  103. 0x340c, 0x000300c0, 0x00800040,
  104. 0x360c, 0x000300c0, 0x00800040,
  105. 0x16ec, 0x000000f0, 0x00000070,
  106. 0x16f0, 0x00200000, 0x50100000,
  107. 0x1c0c, 0x31000311, 0x00000011,
  108. 0x0ab9, 0x00073ffe, 0x000022a2,
  109. 0x0903, 0x000007ff, 0x00000000,
  110. 0x2285, 0xf000001f, 0x00000007,
  111. 0x22c9, 0xffffffff, 0x00ffffff,
  112. 0x22c4, 0x0000ff0f, 0x00000000,
  113. 0xa293, 0x07ffffff, 0x4e000000,
  114. 0xa0d4, 0x3f3f3fff, 0x2a00126a,
  115. 0x000c, 0xffffffff, 0x0040,
  116. 0x000d, 0x00000040, 0x00004040,
  117. 0x2440, 0x07ffffff, 0x03000000,
  118. 0x2418, 0x0000007f, 0x00000020,
  119. 0x2542, 0x00010000, 0x00010000,
  120. 0x2b05, 0x000003ff, 0x000000f7,
  121. 0x2b04, 0xffffffff, 0x00000000,
  122. 0x2b03, 0xffffffff, 0x32761054,
  123. 0x2235, 0x0000001f, 0x00000010,
  124. 0x0570, 0x000c0fc0, 0x000c0400,
  125. 0x052c, 0x0fffffff, 0xffffffff,
  126. 0x052d, 0x0fffffff, 0x0fffffff,
  127. 0x052e, 0x0fffffff, 0x0fffffff,
  128. 0x052f, 0x0fffffff, 0x0fffffff
  129. };
  130. static const u32 pitcairn_golden_rlc_registers[] =
  131. {
  132. 0x263e, 0xffffffff, 0x12011003,
  133. 0x3109, 0xffffffff, 0x00601004,
  134. 0x311f, 0xffffffff, 0x10102020,
  135. 0x3122, 0xffffffff, 0x01000020,
  136. 0x30c5, 0xffffffff, 0x00000800,
  137. 0x30c3, 0xffffffff, 0x800000a4
  138. };
  139. static const u32 verde_pg_init[] =
  140. {
  141. 0x0d4f, 0xffffffff, 0x40000,
  142. 0x0d4e, 0xffffffff, 0x200010ff,
  143. 0x0d4f, 0xffffffff, 0x0,
  144. 0x0d4f, 0xffffffff, 0x0,
  145. 0x0d4f, 0xffffffff, 0x0,
  146. 0x0d4f, 0xffffffff, 0x0,
  147. 0x0d4f, 0xffffffff, 0x0,
  148. 0x0d4f, 0xffffffff, 0x7007,
  149. 0x0d4e, 0xffffffff, 0x300010ff,
  150. 0x0d4f, 0xffffffff, 0x0,
  151. 0x0d4f, 0xffffffff, 0x0,
  152. 0x0d4f, 0xffffffff, 0x0,
  153. 0x0d4f, 0xffffffff, 0x0,
  154. 0x0d4f, 0xffffffff, 0x0,
  155. 0x0d4f, 0xffffffff, 0x400000,
  156. 0x0d4e, 0xffffffff, 0x100010ff,
  157. 0x0d4f, 0xffffffff, 0x0,
  158. 0x0d4f, 0xffffffff, 0x0,
  159. 0x0d4f, 0xffffffff, 0x0,
  160. 0x0d4f, 0xffffffff, 0x0,
  161. 0x0d4f, 0xffffffff, 0x0,
  162. 0x0d4f, 0xffffffff, 0x120200,
  163. 0x0d4e, 0xffffffff, 0x500010ff,
  164. 0x0d4f, 0xffffffff, 0x0,
  165. 0x0d4f, 0xffffffff, 0x0,
  166. 0x0d4f, 0xffffffff, 0x0,
  167. 0x0d4f, 0xffffffff, 0x0,
  168. 0x0d4f, 0xffffffff, 0x0,
  169. 0x0d4f, 0xffffffff, 0x1e1e16,
  170. 0x0d4e, 0xffffffff, 0x600010ff,
  171. 0x0d4f, 0xffffffff, 0x0,
  172. 0x0d4f, 0xffffffff, 0x0,
  173. 0x0d4f, 0xffffffff, 0x0,
  174. 0x0d4f, 0xffffffff, 0x0,
  175. 0x0d4f, 0xffffffff, 0x0,
  176. 0x0d4f, 0xffffffff, 0x171f1e,
  177. 0x0d4e, 0xffffffff, 0x700010ff,
  178. 0x0d4f, 0xffffffff, 0x0,
  179. 0x0d4f, 0xffffffff, 0x0,
  180. 0x0d4f, 0xffffffff, 0x0,
  181. 0x0d4f, 0xffffffff, 0x0,
  182. 0x0d4f, 0xffffffff, 0x0,
  183. 0x0d4f, 0xffffffff, 0x0,
  184. 0x0d4e, 0xffffffff, 0x9ff,
  185. 0x0d40, 0xffffffff, 0x0,
  186. 0x0d41, 0xffffffff, 0x10000800,
  187. 0x0d41, 0xffffffff, 0xf,
  188. 0x0d41, 0xffffffff, 0xf,
  189. 0x0d40, 0xffffffff, 0x4,
  190. 0x0d41, 0xffffffff, 0x1000051e,
  191. 0x0d41, 0xffffffff, 0xffff,
  192. 0x0d41, 0xffffffff, 0xffff,
  193. 0x0d40, 0xffffffff, 0x8,
  194. 0x0d41, 0xffffffff, 0x80500,
  195. 0x0d40, 0xffffffff, 0x12,
  196. 0x0d41, 0xffffffff, 0x9050c,
  197. 0x0d40, 0xffffffff, 0x1d,
  198. 0x0d41, 0xffffffff, 0xb052c,
  199. 0x0d40, 0xffffffff, 0x2a,
  200. 0x0d41, 0xffffffff, 0x1053e,
  201. 0x0d40, 0xffffffff, 0x2d,
  202. 0x0d41, 0xffffffff, 0x10546,
  203. 0x0d40, 0xffffffff, 0x30,
  204. 0x0d41, 0xffffffff, 0xa054e,
  205. 0x0d40, 0xffffffff, 0x3c,
  206. 0x0d41, 0xffffffff, 0x1055f,
  207. 0x0d40, 0xffffffff, 0x3f,
  208. 0x0d41, 0xffffffff, 0x10567,
  209. 0x0d40, 0xffffffff, 0x42,
  210. 0x0d41, 0xffffffff, 0x1056f,
  211. 0x0d40, 0xffffffff, 0x45,
  212. 0x0d41, 0xffffffff, 0x10572,
  213. 0x0d40, 0xffffffff, 0x48,
  214. 0x0d41, 0xffffffff, 0x20575,
  215. 0x0d40, 0xffffffff, 0x4c,
  216. 0x0d41, 0xffffffff, 0x190801,
  217. 0x0d40, 0xffffffff, 0x67,
  218. 0x0d41, 0xffffffff, 0x1082a,
  219. 0x0d40, 0xffffffff, 0x6a,
  220. 0x0d41, 0xffffffff, 0x1b082d,
  221. 0x0d40, 0xffffffff, 0x87,
  222. 0x0d41, 0xffffffff, 0x310851,
  223. 0x0d40, 0xffffffff, 0xba,
  224. 0x0d41, 0xffffffff, 0x891,
  225. 0x0d40, 0xffffffff, 0xbc,
  226. 0x0d41, 0xffffffff, 0x893,
  227. 0x0d40, 0xffffffff, 0xbe,
  228. 0x0d41, 0xffffffff, 0x20895,
  229. 0x0d40, 0xffffffff, 0xc2,
  230. 0x0d41, 0xffffffff, 0x20899,
  231. 0x0d40, 0xffffffff, 0xc6,
  232. 0x0d41, 0xffffffff, 0x2089d,
  233. 0x0d40, 0xffffffff, 0xca,
  234. 0x0d41, 0xffffffff, 0x8a1,
  235. 0x0d40, 0xffffffff, 0xcc,
  236. 0x0d41, 0xffffffff, 0x8a3,
  237. 0x0d40, 0xffffffff, 0xce,
  238. 0x0d41, 0xffffffff, 0x308a5,
  239. 0x0d40, 0xffffffff, 0xd3,
  240. 0x0d41, 0xffffffff, 0x6d08cd,
  241. 0x0d40, 0xffffffff, 0x142,
  242. 0x0d41, 0xffffffff, 0x2000095a,
  243. 0x0d41, 0xffffffff, 0x1,
  244. 0x0d40, 0xffffffff, 0x144,
  245. 0x0d41, 0xffffffff, 0x301f095b,
  246. 0x0d40, 0xffffffff, 0x165,
  247. 0x0d41, 0xffffffff, 0xc094d,
  248. 0x0d40, 0xffffffff, 0x173,
  249. 0x0d41, 0xffffffff, 0xf096d,
  250. 0x0d40, 0xffffffff, 0x184,
  251. 0x0d41, 0xffffffff, 0x15097f,
  252. 0x0d40, 0xffffffff, 0x19b,
  253. 0x0d41, 0xffffffff, 0xc0998,
  254. 0x0d40, 0xffffffff, 0x1a9,
  255. 0x0d41, 0xffffffff, 0x409a7,
  256. 0x0d40, 0xffffffff, 0x1af,
  257. 0x0d41, 0xffffffff, 0xcdc,
  258. 0x0d40, 0xffffffff, 0x1b1,
  259. 0x0d41, 0xffffffff, 0x800,
  260. 0x0d42, 0xffffffff, 0x6c9b2000,
  261. 0x0d44, 0xfc00, 0x2000,
  262. 0x0d51, 0xffffffff, 0xfc0,
  263. 0x0a35, 0x00000100, 0x100
  264. };
  265. static const u32 verde_golden_rlc_registers[] =
  266. {
  267. 0x263e, 0xffffffff, 0x02010002,
  268. 0x3109, 0xffffffff, 0x033f1005,
  269. 0x311f, 0xffffffff, 0x10808020,
  270. 0x3122, 0xffffffff, 0x00800008,
  271. 0x30c5, 0xffffffff, 0x00001000,
  272. 0x30c3, 0xffffffff, 0x80010014
  273. };
  274. static const u32 verde_golden_registers[] =
  275. {
  276. 0x17bc, 0x00000030, 0x00000011,
  277. 0x2684, 0x00010000, 0x00018208,
  278. 0x260c, 0xffffffff, 0x00000000,
  279. 0x260d, 0xf00fffff, 0x00000400,
  280. 0x260e, 0x0002021c, 0x00020200,
  281. 0x031e, 0x00000080, 0x00000000,
  282. 0x340c, 0x000300c0, 0x00800040,
  283. 0x360c, 0x000300c0, 0x00800040,
  284. 0x16ec, 0x000000f0, 0x00000070,
  285. 0x16f0, 0x00200000, 0x50100000,
  286. 0x1c0c, 0x31000311, 0x00000011,
  287. 0x0ab9, 0x00073ffe, 0x000022a2,
  288. 0x0903, 0x000007ff, 0x00000000,
  289. 0x2285, 0xf000001f, 0x00000007,
  290. 0x22c9, 0xffffffff, 0x00ffffff,
  291. 0x22c4, 0x0000ff0f, 0x00000000,
  292. 0xa293, 0x07ffffff, 0x4e000000,
  293. 0xa0d4, 0x3f3f3fff, 0x0000124a,
  294. 0x000c, 0xffffffff, 0x0040,
  295. 0x000d, 0x00000040, 0x00004040,
  296. 0x2440, 0x07ffffff, 0x03000000,
  297. 0x23a2, 0x01ff1f3f, 0x00000000,
  298. 0x23a1, 0x01ff1f3f, 0x00000000,
  299. 0x2418, 0x0000007f, 0x00000020,
  300. 0x2542, 0x00010000, 0x00010000,
  301. 0x2b05, 0x000003ff, 0x00000003,
  302. 0x2b04, 0xffffffff, 0x00000000,
  303. 0x2b03, 0xffffffff, 0x00001032,
  304. 0x2235, 0x0000001f, 0x00000010,
  305. 0x0570, 0x000c0fc0, 0x000c0400,
  306. 0x052c, 0x0fffffff, 0xffffffff,
  307. 0x052d, 0x0fffffff, 0x0fffffff,
  308. 0x052e, 0x0fffffff, 0x0fffffff,
  309. 0x052f, 0x0fffffff, 0x0fffffff
  310. };
  311. static const u32 oland_golden_registers[] =
  312. {
  313. 0x17bc, 0x00000030, 0x00000011,
  314. 0x2684, 0x00010000, 0x00018208,
  315. 0x260c, 0xffffffff, 0x00000000,
  316. 0x260d, 0xf00fffff, 0x00000400,
  317. 0x260e, 0x0002021c, 0x00020200,
  318. 0x031e, 0x00000080, 0x00000000,
  319. 0x340c, 0x000300c0, 0x00800040,
  320. 0x360c, 0x000300c0, 0x00800040,
  321. 0x16ec, 0x000000f0, 0x00000070,
  322. 0x16f0, 0x00200000, 0x50100000,
  323. 0x1c0c, 0x31000311, 0x00000011,
  324. 0x0ab9, 0x00073ffe, 0x000022a2,
  325. 0x0903, 0x000007ff, 0x00000000,
  326. 0x2285, 0xf000001f, 0x00000007,
  327. 0x22c9, 0xffffffff, 0x00ffffff,
  328. 0x22c4, 0x0000ff0f, 0x00000000,
  329. 0xa293, 0x07ffffff, 0x4e000000,
  330. 0xa0d4, 0x3f3f3fff, 0x00000082,
  331. 0x000c, 0xffffffff, 0x0040,
  332. 0x000d, 0x00000040, 0x00004040,
  333. 0x2440, 0x07ffffff, 0x03000000,
  334. 0x2418, 0x0000007f, 0x00000020,
  335. 0x2542, 0x00010000, 0x00010000,
  336. 0x2b05, 0x000003ff, 0x000000f3,
  337. 0x2b04, 0xffffffff, 0x00000000,
  338. 0x2b03, 0xffffffff, 0x00003210,
  339. 0x2235, 0x0000001f, 0x00000010,
  340. 0x0570, 0x000c0fc0, 0x000c0400,
  341. 0x052c, 0x0fffffff, 0xffffffff,
  342. 0x052d, 0x0fffffff, 0x0fffffff,
  343. 0x052e, 0x0fffffff, 0x0fffffff,
  344. 0x052f, 0x0fffffff, 0x0fffffff
  345. };
  346. static const u32 oland_golden_rlc_registers[] =
  347. {
  348. 0x263e, 0xffffffff, 0x02010002,
  349. 0x3109, 0xffffffff, 0x00601005,
  350. 0x311f, 0xffffffff, 0x10104040,
  351. 0x3122, 0xffffffff, 0x0100000a,
  352. 0x30c5, 0xffffffff, 0x00000800,
  353. 0x30c3, 0xffffffff, 0x800000f4
  354. };
  355. static const u32 hainan_golden_registers[] =
  356. {
  357. 0x17bc, 0x00000030, 0x00000011,
  358. 0x2684, 0x00010000, 0x00018208,
  359. 0x260c, 0xffffffff, 0x00000000,
  360. 0x260d, 0xf00fffff, 0x00000400,
  361. 0x260e, 0x0002021c, 0x00020200,
  362. 0x031e, 0x00000080, 0x00000000,
  363. 0x3430, 0xff000fff, 0x00000100,
  364. 0x340c, 0x000300c0, 0x00800040,
  365. 0x3630, 0xff000fff, 0x00000100,
  366. 0x360c, 0x000300c0, 0x00800040,
  367. 0x16ec, 0x000000f0, 0x00000070,
  368. 0x16f0, 0x00200000, 0x50100000,
  369. 0x1c0c, 0x31000311, 0x00000011,
  370. 0x0ab9, 0x00073ffe, 0x000022a2,
  371. 0x0903, 0x000007ff, 0x00000000,
  372. 0x2285, 0xf000001f, 0x00000007,
  373. 0x22c9, 0xffffffff, 0x00ffffff,
  374. 0x22c4, 0x0000ff0f, 0x00000000,
  375. 0xa293, 0x07ffffff, 0x4e000000,
  376. 0xa0d4, 0x3f3f3fff, 0x00000000,
  377. 0x000c, 0xffffffff, 0x0040,
  378. 0x000d, 0x00000040, 0x00004040,
  379. 0x2440, 0x03e00000, 0x03600000,
  380. 0x2418, 0x0000007f, 0x00000020,
  381. 0x2542, 0x00010000, 0x00010000,
  382. 0x2b05, 0x000003ff, 0x000000f1,
  383. 0x2b04, 0xffffffff, 0x00000000,
  384. 0x2b03, 0xffffffff, 0x00003210,
  385. 0x2235, 0x0000001f, 0x00000010,
  386. 0x0570, 0x000c0fc0, 0x000c0400,
  387. 0x052c, 0x0fffffff, 0xffffffff,
  388. 0x052d, 0x0fffffff, 0x0fffffff,
  389. 0x052e, 0x0fffffff, 0x0fffffff,
  390. 0x052f, 0x0fffffff, 0x0fffffff
  391. };
  392. static const u32 hainan_golden_registers2[] =
  393. {
  394. 0x263e, 0xffffffff, 0x2011003
  395. };
  396. static const u32 tahiti_mgcg_cgcg_init[] =
  397. {
  398. 0x3100, 0xffffffff, 0xfffffffc,
  399. 0x200b, 0xffffffff, 0xe0000000,
  400. 0x2698, 0xffffffff, 0x00000100,
  401. 0x24a9, 0xffffffff, 0x00000100,
  402. 0x3059, 0xffffffff, 0x00000100,
  403. 0x25dd, 0xffffffff, 0x00000100,
  404. 0x2261, 0xffffffff, 0x06000100,
  405. 0x2286, 0xffffffff, 0x00000100,
  406. 0x24a8, 0xffffffff, 0x00000100,
  407. 0x30e0, 0xffffffff, 0x00000100,
  408. 0x22ca, 0xffffffff, 0x00000100,
  409. 0x2451, 0xffffffff, 0x00000100,
  410. 0x2362, 0xffffffff, 0x00000100,
  411. 0x2363, 0xffffffff, 0x00000100,
  412. 0x240c, 0xffffffff, 0x00000100,
  413. 0x240d, 0xffffffff, 0x00000100,
  414. 0x240e, 0xffffffff, 0x00000100,
  415. 0x240f, 0xffffffff, 0x00000100,
  416. 0x2b60, 0xffffffff, 0x00000100,
  417. 0x2b15, 0xffffffff, 0x00000100,
  418. 0x225f, 0xffffffff, 0x06000100,
  419. 0x261a, 0xffffffff, 0x00000100,
  420. 0x2544, 0xffffffff, 0x00000100,
  421. 0x2bc1, 0xffffffff, 0x00000100,
  422. 0x2b81, 0xffffffff, 0x00000100,
  423. 0x2527, 0xffffffff, 0x00000100,
  424. 0x200b, 0xffffffff, 0xe0000000,
  425. 0x2458, 0xffffffff, 0x00010000,
  426. 0x2459, 0xffffffff, 0x00030002,
  427. 0x245a, 0xffffffff, 0x00040007,
  428. 0x245b, 0xffffffff, 0x00060005,
  429. 0x245c, 0xffffffff, 0x00090008,
  430. 0x245d, 0xffffffff, 0x00020001,
  431. 0x245e, 0xffffffff, 0x00040003,
  432. 0x245f, 0xffffffff, 0x00000007,
  433. 0x2460, 0xffffffff, 0x00060005,
  434. 0x2461, 0xffffffff, 0x00090008,
  435. 0x2462, 0xffffffff, 0x00030002,
  436. 0x2463, 0xffffffff, 0x00050004,
  437. 0x2464, 0xffffffff, 0x00000008,
  438. 0x2465, 0xffffffff, 0x00070006,
  439. 0x2466, 0xffffffff, 0x000a0009,
  440. 0x2467, 0xffffffff, 0x00040003,
  441. 0x2468, 0xffffffff, 0x00060005,
  442. 0x2469, 0xffffffff, 0x00000009,
  443. 0x246a, 0xffffffff, 0x00080007,
  444. 0x246b, 0xffffffff, 0x000b000a,
  445. 0x246c, 0xffffffff, 0x00050004,
  446. 0x246d, 0xffffffff, 0x00070006,
  447. 0x246e, 0xffffffff, 0x0008000b,
  448. 0x246f, 0xffffffff, 0x000a0009,
  449. 0x2470, 0xffffffff, 0x000d000c,
  450. 0x2471, 0xffffffff, 0x00060005,
  451. 0x2472, 0xffffffff, 0x00080007,
  452. 0x2473, 0xffffffff, 0x0000000b,
  453. 0x2474, 0xffffffff, 0x000a0009,
  454. 0x2475, 0xffffffff, 0x000d000c,
  455. 0x2476, 0xffffffff, 0x00070006,
  456. 0x2477, 0xffffffff, 0x00090008,
  457. 0x2478, 0xffffffff, 0x0000000c,
  458. 0x2479, 0xffffffff, 0x000b000a,
  459. 0x247a, 0xffffffff, 0x000e000d,
  460. 0x247b, 0xffffffff, 0x00080007,
  461. 0x247c, 0xffffffff, 0x000a0009,
  462. 0x247d, 0xffffffff, 0x0000000d,
  463. 0x247e, 0xffffffff, 0x000c000b,
  464. 0x247f, 0xffffffff, 0x000f000e,
  465. 0x2480, 0xffffffff, 0x00090008,
  466. 0x2481, 0xffffffff, 0x000b000a,
  467. 0x2482, 0xffffffff, 0x000c000f,
  468. 0x2483, 0xffffffff, 0x000e000d,
  469. 0x2484, 0xffffffff, 0x00110010,
  470. 0x2485, 0xffffffff, 0x000a0009,
  471. 0x2486, 0xffffffff, 0x000c000b,
  472. 0x2487, 0xffffffff, 0x0000000f,
  473. 0x2488, 0xffffffff, 0x000e000d,
  474. 0x2489, 0xffffffff, 0x00110010,
  475. 0x248a, 0xffffffff, 0x000b000a,
  476. 0x248b, 0xffffffff, 0x000d000c,
  477. 0x248c, 0xffffffff, 0x00000010,
  478. 0x248d, 0xffffffff, 0x000f000e,
  479. 0x248e, 0xffffffff, 0x00120011,
  480. 0x248f, 0xffffffff, 0x000c000b,
  481. 0x2490, 0xffffffff, 0x000e000d,
  482. 0x2491, 0xffffffff, 0x00000011,
  483. 0x2492, 0xffffffff, 0x0010000f,
  484. 0x2493, 0xffffffff, 0x00130012,
  485. 0x2494, 0xffffffff, 0x000d000c,
  486. 0x2495, 0xffffffff, 0x000f000e,
  487. 0x2496, 0xffffffff, 0x00100013,
  488. 0x2497, 0xffffffff, 0x00120011,
  489. 0x2498, 0xffffffff, 0x00150014,
  490. 0x2499, 0xffffffff, 0x000e000d,
  491. 0x249a, 0xffffffff, 0x0010000f,
  492. 0x249b, 0xffffffff, 0x00000013,
  493. 0x249c, 0xffffffff, 0x00120011,
  494. 0x249d, 0xffffffff, 0x00150014,
  495. 0x249e, 0xffffffff, 0x000f000e,
  496. 0x249f, 0xffffffff, 0x00110010,
  497. 0x24a0, 0xffffffff, 0x00000014,
  498. 0x24a1, 0xffffffff, 0x00130012,
  499. 0x24a2, 0xffffffff, 0x00160015,
  500. 0x24a3, 0xffffffff, 0x0010000f,
  501. 0x24a4, 0xffffffff, 0x00120011,
  502. 0x24a5, 0xffffffff, 0x00000015,
  503. 0x24a6, 0xffffffff, 0x00140013,
  504. 0x24a7, 0xffffffff, 0x00170016,
  505. 0x2454, 0xffffffff, 0x96940200,
  506. 0x21c2, 0xffffffff, 0x00900100,
  507. 0x311e, 0xffffffff, 0x00000080,
  508. 0x3101, 0xffffffff, 0x0020003f,
  509. 0x000c, 0xffffffff, 0x0000001c,
  510. 0x000d, 0x000f0000, 0x000f0000,
  511. 0x0583, 0xffffffff, 0x00000100,
  512. 0x0409, 0xffffffff, 0x00000100,
  513. 0x040b, 0x00000101, 0x00000000,
  514. 0x082a, 0xffffffff, 0x00000104,
  515. 0x0993, 0x000c0000, 0x000c0000,
  516. 0x0992, 0x000c0000, 0x000c0000,
  517. 0x1579, 0xff000fff, 0x00000100,
  518. 0x157a, 0x00000001, 0x00000001,
  519. 0x0bd4, 0x00000001, 0x00000001,
  520. 0x0c33, 0xc0000fff, 0x00000104,
  521. 0x3079, 0x00000001, 0x00000001,
  522. 0x3430, 0xfffffff0, 0x00000100,
  523. 0x3630, 0xfffffff0, 0x00000100
  524. };
  525. static const u32 pitcairn_mgcg_cgcg_init[] =
  526. {
  527. 0x3100, 0xffffffff, 0xfffffffc,
  528. 0x200b, 0xffffffff, 0xe0000000,
  529. 0x2698, 0xffffffff, 0x00000100,
  530. 0x24a9, 0xffffffff, 0x00000100,
  531. 0x3059, 0xffffffff, 0x00000100,
  532. 0x25dd, 0xffffffff, 0x00000100,
  533. 0x2261, 0xffffffff, 0x06000100,
  534. 0x2286, 0xffffffff, 0x00000100,
  535. 0x24a8, 0xffffffff, 0x00000100,
  536. 0x30e0, 0xffffffff, 0x00000100,
  537. 0x22ca, 0xffffffff, 0x00000100,
  538. 0x2451, 0xffffffff, 0x00000100,
  539. 0x2362, 0xffffffff, 0x00000100,
  540. 0x2363, 0xffffffff, 0x00000100,
  541. 0x240c, 0xffffffff, 0x00000100,
  542. 0x240d, 0xffffffff, 0x00000100,
  543. 0x240e, 0xffffffff, 0x00000100,
  544. 0x240f, 0xffffffff, 0x00000100,
  545. 0x2b60, 0xffffffff, 0x00000100,
  546. 0x2b15, 0xffffffff, 0x00000100,
  547. 0x225f, 0xffffffff, 0x06000100,
  548. 0x261a, 0xffffffff, 0x00000100,
  549. 0x2544, 0xffffffff, 0x00000100,
  550. 0x2bc1, 0xffffffff, 0x00000100,
  551. 0x2b81, 0xffffffff, 0x00000100,
  552. 0x2527, 0xffffffff, 0x00000100,
  553. 0x200b, 0xffffffff, 0xe0000000,
  554. 0x2458, 0xffffffff, 0x00010000,
  555. 0x2459, 0xffffffff, 0x00030002,
  556. 0x245a, 0xffffffff, 0x00040007,
  557. 0x245b, 0xffffffff, 0x00060005,
  558. 0x245c, 0xffffffff, 0x00090008,
  559. 0x245d, 0xffffffff, 0x00020001,
  560. 0x245e, 0xffffffff, 0x00040003,
  561. 0x245f, 0xffffffff, 0x00000007,
  562. 0x2460, 0xffffffff, 0x00060005,
  563. 0x2461, 0xffffffff, 0x00090008,
  564. 0x2462, 0xffffffff, 0x00030002,
  565. 0x2463, 0xffffffff, 0x00050004,
  566. 0x2464, 0xffffffff, 0x00000008,
  567. 0x2465, 0xffffffff, 0x00070006,
  568. 0x2466, 0xffffffff, 0x000a0009,
  569. 0x2467, 0xffffffff, 0x00040003,
  570. 0x2468, 0xffffffff, 0x00060005,
  571. 0x2469, 0xffffffff, 0x00000009,
  572. 0x246a, 0xffffffff, 0x00080007,
  573. 0x246b, 0xffffffff, 0x000b000a,
  574. 0x246c, 0xffffffff, 0x00050004,
  575. 0x246d, 0xffffffff, 0x00070006,
  576. 0x246e, 0xffffffff, 0x0008000b,
  577. 0x246f, 0xffffffff, 0x000a0009,
  578. 0x2470, 0xffffffff, 0x000d000c,
  579. 0x2480, 0xffffffff, 0x00090008,
  580. 0x2481, 0xffffffff, 0x000b000a,
  581. 0x2482, 0xffffffff, 0x000c000f,
  582. 0x2483, 0xffffffff, 0x000e000d,
  583. 0x2484, 0xffffffff, 0x00110010,
  584. 0x2485, 0xffffffff, 0x000a0009,
  585. 0x2486, 0xffffffff, 0x000c000b,
  586. 0x2487, 0xffffffff, 0x0000000f,
  587. 0x2488, 0xffffffff, 0x000e000d,
  588. 0x2489, 0xffffffff, 0x00110010,
  589. 0x248a, 0xffffffff, 0x000b000a,
  590. 0x248b, 0xffffffff, 0x000d000c,
  591. 0x248c, 0xffffffff, 0x00000010,
  592. 0x248d, 0xffffffff, 0x000f000e,
  593. 0x248e, 0xffffffff, 0x00120011,
  594. 0x248f, 0xffffffff, 0x000c000b,
  595. 0x2490, 0xffffffff, 0x000e000d,
  596. 0x2491, 0xffffffff, 0x00000011,
  597. 0x2492, 0xffffffff, 0x0010000f,
  598. 0x2493, 0xffffffff, 0x00130012,
  599. 0x2494, 0xffffffff, 0x000d000c,
  600. 0x2495, 0xffffffff, 0x000f000e,
  601. 0x2496, 0xffffffff, 0x00100013,
  602. 0x2497, 0xffffffff, 0x00120011,
  603. 0x2498, 0xffffffff, 0x00150014,
  604. 0x2454, 0xffffffff, 0x96940200,
  605. 0x21c2, 0xffffffff, 0x00900100,
  606. 0x311e, 0xffffffff, 0x00000080,
  607. 0x3101, 0xffffffff, 0x0020003f,
  608. 0x000c, 0xffffffff, 0x0000001c,
  609. 0x000d, 0x000f0000, 0x000f0000,
  610. 0x0583, 0xffffffff, 0x00000100,
  611. 0x0409, 0xffffffff, 0x00000100,
  612. 0x040b, 0x00000101, 0x00000000,
  613. 0x082a, 0xffffffff, 0x00000104,
  614. 0x1579, 0xff000fff, 0x00000100,
  615. 0x157a, 0x00000001, 0x00000001,
  616. 0x0bd4, 0x00000001, 0x00000001,
  617. 0x0c33, 0xc0000fff, 0x00000104,
  618. 0x3079, 0x00000001, 0x00000001,
  619. 0x3430, 0xfffffff0, 0x00000100,
  620. 0x3630, 0xfffffff0, 0x00000100
  621. };
  622. static const u32 verde_mgcg_cgcg_init[] =
  623. {
  624. 0x3100, 0xffffffff, 0xfffffffc,
  625. 0x200b, 0xffffffff, 0xe0000000,
  626. 0x2698, 0xffffffff, 0x00000100,
  627. 0x24a9, 0xffffffff, 0x00000100,
  628. 0x3059, 0xffffffff, 0x00000100,
  629. 0x25dd, 0xffffffff, 0x00000100,
  630. 0x2261, 0xffffffff, 0x06000100,
  631. 0x2286, 0xffffffff, 0x00000100,
  632. 0x24a8, 0xffffffff, 0x00000100,
  633. 0x30e0, 0xffffffff, 0x00000100,
  634. 0x22ca, 0xffffffff, 0x00000100,
  635. 0x2451, 0xffffffff, 0x00000100,
  636. 0x2362, 0xffffffff, 0x00000100,
  637. 0x2363, 0xffffffff, 0x00000100,
  638. 0x240c, 0xffffffff, 0x00000100,
  639. 0x240d, 0xffffffff, 0x00000100,
  640. 0x240e, 0xffffffff, 0x00000100,
  641. 0x240f, 0xffffffff, 0x00000100,
  642. 0x2b60, 0xffffffff, 0x00000100,
  643. 0x2b15, 0xffffffff, 0x00000100,
  644. 0x225f, 0xffffffff, 0x06000100,
  645. 0x261a, 0xffffffff, 0x00000100,
  646. 0x2544, 0xffffffff, 0x00000100,
  647. 0x2bc1, 0xffffffff, 0x00000100,
  648. 0x2b81, 0xffffffff, 0x00000100,
  649. 0x2527, 0xffffffff, 0x00000100,
  650. 0x200b, 0xffffffff, 0xe0000000,
  651. 0x2458, 0xffffffff, 0x00010000,
  652. 0x2459, 0xffffffff, 0x00030002,
  653. 0x245a, 0xffffffff, 0x00040007,
  654. 0x245b, 0xffffffff, 0x00060005,
  655. 0x245c, 0xffffffff, 0x00090008,
  656. 0x245d, 0xffffffff, 0x00020001,
  657. 0x245e, 0xffffffff, 0x00040003,
  658. 0x245f, 0xffffffff, 0x00000007,
  659. 0x2460, 0xffffffff, 0x00060005,
  660. 0x2461, 0xffffffff, 0x00090008,
  661. 0x2462, 0xffffffff, 0x00030002,
  662. 0x2463, 0xffffffff, 0x00050004,
  663. 0x2464, 0xffffffff, 0x00000008,
  664. 0x2465, 0xffffffff, 0x00070006,
  665. 0x2466, 0xffffffff, 0x000a0009,
  666. 0x2467, 0xffffffff, 0x00040003,
  667. 0x2468, 0xffffffff, 0x00060005,
  668. 0x2469, 0xffffffff, 0x00000009,
  669. 0x246a, 0xffffffff, 0x00080007,
  670. 0x246b, 0xffffffff, 0x000b000a,
  671. 0x246c, 0xffffffff, 0x00050004,
  672. 0x246d, 0xffffffff, 0x00070006,
  673. 0x246e, 0xffffffff, 0x0008000b,
  674. 0x246f, 0xffffffff, 0x000a0009,
  675. 0x2470, 0xffffffff, 0x000d000c,
  676. 0x2480, 0xffffffff, 0x00090008,
  677. 0x2481, 0xffffffff, 0x000b000a,
  678. 0x2482, 0xffffffff, 0x000c000f,
  679. 0x2483, 0xffffffff, 0x000e000d,
  680. 0x2484, 0xffffffff, 0x00110010,
  681. 0x2485, 0xffffffff, 0x000a0009,
  682. 0x2486, 0xffffffff, 0x000c000b,
  683. 0x2487, 0xffffffff, 0x0000000f,
  684. 0x2488, 0xffffffff, 0x000e000d,
  685. 0x2489, 0xffffffff, 0x00110010,
  686. 0x248a, 0xffffffff, 0x000b000a,
  687. 0x248b, 0xffffffff, 0x000d000c,
  688. 0x248c, 0xffffffff, 0x00000010,
  689. 0x248d, 0xffffffff, 0x000f000e,
  690. 0x248e, 0xffffffff, 0x00120011,
  691. 0x248f, 0xffffffff, 0x000c000b,
  692. 0x2490, 0xffffffff, 0x000e000d,
  693. 0x2491, 0xffffffff, 0x00000011,
  694. 0x2492, 0xffffffff, 0x0010000f,
  695. 0x2493, 0xffffffff, 0x00130012,
  696. 0x2494, 0xffffffff, 0x000d000c,
  697. 0x2495, 0xffffffff, 0x000f000e,
  698. 0x2496, 0xffffffff, 0x00100013,
  699. 0x2497, 0xffffffff, 0x00120011,
  700. 0x2498, 0xffffffff, 0x00150014,
  701. 0x2454, 0xffffffff, 0x96940200,
  702. 0x21c2, 0xffffffff, 0x00900100,
  703. 0x311e, 0xffffffff, 0x00000080,
  704. 0x3101, 0xffffffff, 0x0020003f,
  705. 0x000c, 0xffffffff, 0x0000001c,
  706. 0x000d, 0x000f0000, 0x000f0000,
  707. 0x0583, 0xffffffff, 0x00000100,
  708. 0x0409, 0xffffffff, 0x00000100,
  709. 0x040b, 0x00000101, 0x00000000,
  710. 0x082a, 0xffffffff, 0x00000104,
  711. 0x0993, 0x000c0000, 0x000c0000,
  712. 0x0992, 0x000c0000, 0x000c0000,
  713. 0x1579, 0xff000fff, 0x00000100,
  714. 0x157a, 0x00000001, 0x00000001,
  715. 0x0bd4, 0x00000001, 0x00000001,
  716. 0x0c33, 0xc0000fff, 0x00000104,
  717. 0x3079, 0x00000001, 0x00000001,
  718. 0x3430, 0xfffffff0, 0x00000100,
  719. 0x3630, 0xfffffff0, 0x00000100
  720. };
  721. static const u32 oland_mgcg_cgcg_init[] =
  722. {
  723. 0x3100, 0xffffffff, 0xfffffffc,
  724. 0x200b, 0xffffffff, 0xe0000000,
  725. 0x2698, 0xffffffff, 0x00000100,
  726. 0x24a9, 0xffffffff, 0x00000100,
  727. 0x3059, 0xffffffff, 0x00000100,
  728. 0x25dd, 0xffffffff, 0x00000100,
  729. 0x2261, 0xffffffff, 0x06000100,
  730. 0x2286, 0xffffffff, 0x00000100,
  731. 0x24a8, 0xffffffff, 0x00000100,
  732. 0x30e0, 0xffffffff, 0x00000100,
  733. 0x22ca, 0xffffffff, 0x00000100,
  734. 0x2451, 0xffffffff, 0x00000100,
  735. 0x2362, 0xffffffff, 0x00000100,
  736. 0x2363, 0xffffffff, 0x00000100,
  737. 0x240c, 0xffffffff, 0x00000100,
  738. 0x240d, 0xffffffff, 0x00000100,
  739. 0x240e, 0xffffffff, 0x00000100,
  740. 0x240f, 0xffffffff, 0x00000100,
  741. 0x2b60, 0xffffffff, 0x00000100,
  742. 0x2b15, 0xffffffff, 0x00000100,
  743. 0x225f, 0xffffffff, 0x06000100,
  744. 0x261a, 0xffffffff, 0x00000100,
  745. 0x2544, 0xffffffff, 0x00000100,
  746. 0x2bc1, 0xffffffff, 0x00000100,
  747. 0x2b81, 0xffffffff, 0x00000100,
  748. 0x2527, 0xffffffff, 0x00000100,
  749. 0x200b, 0xffffffff, 0xe0000000,
  750. 0x2458, 0xffffffff, 0x00010000,
  751. 0x2459, 0xffffffff, 0x00030002,
  752. 0x245a, 0xffffffff, 0x00040007,
  753. 0x245b, 0xffffffff, 0x00060005,
  754. 0x245c, 0xffffffff, 0x00090008,
  755. 0x245d, 0xffffffff, 0x00020001,
  756. 0x245e, 0xffffffff, 0x00040003,
  757. 0x245f, 0xffffffff, 0x00000007,
  758. 0x2460, 0xffffffff, 0x00060005,
  759. 0x2461, 0xffffffff, 0x00090008,
  760. 0x2462, 0xffffffff, 0x00030002,
  761. 0x2463, 0xffffffff, 0x00050004,
  762. 0x2464, 0xffffffff, 0x00000008,
  763. 0x2465, 0xffffffff, 0x00070006,
  764. 0x2466, 0xffffffff, 0x000a0009,
  765. 0x2467, 0xffffffff, 0x00040003,
  766. 0x2468, 0xffffffff, 0x00060005,
  767. 0x2469, 0xffffffff, 0x00000009,
  768. 0x246a, 0xffffffff, 0x00080007,
  769. 0x246b, 0xffffffff, 0x000b000a,
  770. 0x246c, 0xffffffff, 0x00050004,
  771. 0x246d, 0xffffffff, 0x00070006,
  772. 0x246e, 0xffffffff, 0x0008000b,
  773. 0x246f, 0xffffffff, 0x000a0009,
  774. 0x2470, 0xffffffff, 0x000d000c,
  775. 0x2471, 0xffffffff, 0x00060005,
  776. 0x2472, 0xffffffff, 0x00080007,
  777. 0x2473, 0xffffffff, 0x0000000b,
  778. 0x2474, 0xffffffff, 0x000a0009,
  779. 0x2475, 0xffffffff, 0x000d000c,
  780. 0x2454, 0xffffffff, 0x96940200,
  781. 0x21c2, 0xffffffff, 0x00900100,
  782. 0x311e, 0xffffffff, 0x00000080,
  783. 0x3101, 0xffffffff, 0x0020003f,
  784. 0x000c, 0xffffffff, 0x0000001c,
  785. 0x000d, 0x000f0000, 0x000f0000,
  786. 0x0583, 0xffffffff, 0x00000100,
  787. 0x0409, 0xffffffff, 0x00000100,
  788. 0x040b, 0x00000101, 0x00000000,
  789. 0x082a, 0xffffffff, 0x00000104,
  790. 0x0993, 0x000c0000, 0x000c0000,
  791. 0x0992, 0x000c0000, 0x000c0000,
  792. 0x1579, 0xff000fff, 0x00000100,
  793. 0x157a, 0x00000001, 0x00000001,
  794. 0x0bd4, 0x00000001, 0x00000001,
  795. 0x0c33, 0xc0000fff, 0x00000104,
  796. 0x3079, 0x00000001, 0x00000001,
  797. 0x3430, 0xfffffff0, 0x00000100,
  798. 0x3630, 0xfffffff0, 0x00000100
  799. };
  800. static const u32 hainan_mgcg_cgcg_init[] =
  801. {
  802. 0x3100, 0xffffffff, 0xfffffffc,
  803. 0x200b, 0xffffffff, 0xe0000000,
  804. 0x2698, 0xffffffff, 0x00000100,
  805. 0x24a9, 0xffffffff, 0x00000100,
  806. 0x3059, 0xffffffff, 0x00000100,
  807. 0x25dd, 0xffffffff, 0x00000100,
  808. 0x2261, 0xffffffff, 0x06000100,
  809. 0x2286, 0xffffffff, 0x00000100,
  810. 0x24a8, 0xffffffff, 0x00000100,
  811. 0x30e0, 0xffffffff, 0x00000100,
  812. 0x22ca, 0xffffffff, 0x00000100,
  813. 0x2451, 0xffffffff, 0x00000100,
  814. 0x2362, 0xffffffff, 0x00000100,
  815. 0x2363, 0xffffffff, 0x00000100,
  816. 0x240c, 0xffffffff, 0x00000100,
  817. 0x240d, 0xffffffff, 0x00000100,
  818. 0x240e, 0xffffffff, 0x00000100,
  819. 0x240f, 0xffffffff, 0x00000100,
  820. 0x2b60, 0xffffffff, 0x00000100,
  821. 0x2b15, 0xffffffff, 0x00000100,
  822. 0x225f, 0xffffffff, 0x06000100,
  823. 0x261a, 0xffffffff, 0x00000100,
  824. 0x2544, 0xffffffff, 0x00000100,
  825. 0x2bc1, 0xffffffff, 0x00000100,
  826. 0x2b81, 0xffffffff, 0x00000100,
  827. 0x2527, 0xffffffff, 0x00000100,
  828. 0x200b, 0xffffffff, 0xe0000000,
  829. 0x2458, 0xffffffff, 0x00010000,
  830. 0x2459, 0xffffffff, 0x00030002,
  831. 0x245a, 0xffffffff, 0x00040007,
  832. 0x245b, 0xffffffff, 0x00060005,
  833. 0x245c, 0xffffffff, 0x00090008,
  834. 0x245d, 0xffffffff, 0x00020001,
  835. 0x245e, 0xffffffff, 0x00040003,
  836. 0x245f, 0xffffffff, 0x00000007,
  837. 0x2460, 0xffffffff, 0x00060005,
  838. 0x2461, 0xffffffff, 0x00090008,
  839. 0x2462, 0xffffffff, 0x00030002,
  840. 0x2463, 0xffffffff, 0x00050004,
  841. 0x2464, 0xffffffff, 0x00000008,
  842. 0x2465, 0xffffffff, 0x00070006,
  843. 0x2466, 0xffffffff, 0x000a0009,
  844. 0x2467, 0xffffffff, 0x00040003,
  845. 0x2468, 0xffffffff, 0x00060005,
  846. 0x2469, 0xffffffff, 0x00000009,
  847. 0x246a, 0xffffffff, 0x00080007,
  848. 0x246b, 0xffffffff, 0x000b000a,
  849. 0x246c, 0xffffffff, 0x00050004,
  850. 0x246d, 0xffffffff, 0x00070006,
  851. 0x246e, 0xffffffff, 0x0008000b,
  852. 0x246f, 0xffffffff, 0x000a0009,
  853. 0x2470, 0xffffffff, 0x000d000c,
  854. 0x2471, 0xffffffff, 0x00060005,
  855. 0x2472, 0xffffffff, 0x00080007,
  856. 0x2473, 0xffffffff, 0x0000000b,
  857. 0x2474, 0xffffffff, 0x000a0009,
  858. 0x2475, 0xffffffff, 0x000d000c,
  859. 0x2454, 0xffffffff, 0x96940200,
  860. 0x21c2, 0xffffffff, 0x00900100,
  861. 0x311e, 0xffffffff, 0x00000080,
  862. 0x3101, 0xffffffff, 0x0020003f,
  863. 0x000c, 0xffffffff, 0x0000001c,
  864. 0x000d, 0x000f0000, 0x000f0000,
  865. 0x0583, 0xffffffff, 0x00000100,
  866. 0x0409, 0xffffffff, 0x00000100,
  867. 0x082a, 0xffffffff, 0x00000104,
  868. 0x0993, 0x000c0000, 0x000c0000,
  869. 0x0992, 0x000c0000, 0x000c0000,
  870. 0x0bd4, 0x00000001, 0x00000001,
  871. 0x0c33, 0xc0000fff, 0x00000104,
  872. 0x3079, 0x00000001, 0x00000001,
  873. 0x3430, 0xfffffff0, 0x00000100,
  874. 0x3630, 0xfffffff0, 0x00000100
  875. };
  876. static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg)
  877. {
  878. unsigned long flags;
  879. u32 r;
  880. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  881. WREG32(AMDGPU_PCIE_INDEX, reg);
  882. (void)RREG32(AMDGPU_PCIE_INDEX);
  883. r = RREG32(AMDGPU_PCIE_DATA);
  884. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  885. return r;
  886. }
  887. static void si_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
  888. {
  889. unsigned long flags;
  890. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  891. WREG32(AMDGPU_PCIE_INDEX, reg);
  892. (void)RREG32(AMDGPU_PCIE_INDEX);
  893. WREG32(AMDGPU_PCIE_DATA, v);
  894. (void)RREG32(AMDGPU_PCIE_DATA);
  895. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  896. }
  897. static u32 si_pciep_rreg(struct amdgpu_device *adev, u32 reg)
  898. {
  899. unsigned long flags;
  900. u32 r;
  901. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  902. WREG32(PCIE_PORT_INDEX, ((reg) & 0xff));
  903. (void)RREG32(PCIE_PORT_INDEX);
  904. r = RREG32(PCIE_PORT_DATA);
  905. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  906. return r;
  907. }
  908. static void si_pciep_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
  909. {
  910. unsigned long flags;
  911. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  912. WREG32(PCIE_PORT_INDEX, ((reg) & 0xff));
  913. (void)RREG32(PCIE_PORT_INDEX);
  914. WREG32(PCIE_PORT_DATA, (v));
  915. (void)RREG32(PCIE_PORT_DATA);
  916. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  917. }
  918. static u32 si_smc_rreg(struct amdgpu_device *adev, u32 reg)
  919. {
  920. unsigned long flags;
  921. u32 r;
  922. spin_lock_irqsave(&adev->smc_idx_lock, flags);
  923. WREG32(SMC_IND_INDEX_0, (reg));
  924. r = RREG32(SMC_IND_DATA_0);
  925. spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
  926. return r;
  927. }
  928. static void si_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
  929. {
  930. unsigned long flags;
  931. spin_lock_irqsave(&adev->smc_idx_lock, flags);
  932. WREG32(SMC_IND_INDEX_0, (reg));
  933. WREG32(SMC_IND_DATA_0, (v));
  934. spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
  935. }
  936. static struct amdgpu_allowed_register_entry si_allowed_read_registers[] = {
  937. {GRBM_STATUS, false},
  938. {GB_ADDR_CONFIG, false},
  939. {MC_ARB_RAMCFG, false},
  940. {GB_TILE_MODE0, false},
  941. {GB_TILE_MODE1, false},
  942. {GB_TILE_MODE2, false},
  943. {GB_TILE_MODE3, false},
  944. {GB_TILE_MODE4, false},
  945. {GB_TILE_MODE5, false},
  946. {GB_TILE_MODE6, false},
  947. {GB_TILE_MODE7, false},
  948. {GB_TILE_MODE8, false},
  949. {GB_TILE_MODE9, false},
  950. {GB_TILE_MODE10, false},
  951. {GB_TILE_MODE11, false},
  952. {GB_TILE_MODE12, false},
  953. {GB_TILE_MODE13, false},
  954. {GB_TILE_MODE14, false},
  955. {GB_TILE_MODE15, false},
  956. {GB_TILE_MODE16, false},
  957. {GB_TILE_MODE17, false},
  958. {GB_TILE_MODE18, false},
  959. {GB_TILE_MODE19, false},
  960. {GB_TILE_MODE20, false},
  961. {GB_TILE_MODE21, false},
  962. {GB_TILE_MODE22, false},
  963. {GB_TILE_MODE23, false},
  964. {GB_TILE_MODE24, false},
  965. {GB_TILE_MODE25, false},
  966. {GB_TILE_MODE26, false},
  967. {GB_TILE_MODE27, false},
  968. {GB_TILE_MODE28, false},
  969. {GB_TILE_MODE29, false},
  970. {GB_TILE_MODE30, false},
  971. {GB_TILE_MODE31, false},
  972. {CC_RB_BACKEND_DISABLE, false, true},
  973. {GC_USER_RB_BACKEND_DISABLE, false, true},
  974. {PA_SC_RASTER_CONFIG, false, true},
  975. };
  976. static uint32_t si_read_indexed_register(struct amdgpu_device *adev,
  977. u32 se_num, u32 sh_num,
  978. u32 reg_offset)
  979. {
  980. uint32_t val;
  981. mutex_lock(&adev->grbm_idx_mutex);
  982. if (se_num != 0xffffffff || sh_num != 0xffffffff)
  983. amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff);
  984. val = RREG32(reg_offset);
  985. if (se_num != 0xffffffff || sh_num != 0xffffffff)
  986. amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  987. mutex_unlock(&adev->grbm_idx_mutex);
  988. return val;
  989. }
  990. static int si_read_register(struct amdgpu_device *adev, u32 se_num,
  991. u32 sh_num, u32 reg_offset, u32 *value)
  992. {
  993. uint32_t i;
  994. *value = 0;
  995. for (i = 0; i < ARRAY_SIZE(si_allowed_read_registers); i++) {
  996. if (reg_offset != si_allowed_read_registers[i].reg_offset)
  997. continue;
  998. if (!si_allowed_read_registers[i].untouched)
  999. *value = si_allowed_read_registers[i].grbm_indexed ?
  1000. si_read_indexed_register(adev, se_num,
  1001. sh_num, reg_offset) :
  1002. RREG32(reg_offset);
  1003. return 0;
  1004. }
  1005. return -EINVAL;
  1006. }
  1007. static bool si_read_disabled_bios(struct amdgpu_device *adev)
  1008. {
  1009. u32 bus_cntl;
  1010. u32 d1vga_control = 0;
  1011. u32 d2vga_control = 0;
  1012. u32 vga_render_control = 0;
  1013. u32 rom_cntl;
  1014. bool r;
  1015. bus_cntl = RREG32(R600_BUS_CNTL);
  1016. if (adev->mode_info.num_crtc) {
  1017. d1vga_control = RREG32(AVIVO_D1VGA_CONTROL);
  1018. d2vga_control = RREG32(AVIVO_D2VGA_CONTROL);
  1019. vga_render_control = RREG32(VGA_RENDER_CONTROL);
  1020. }
  1021. rom_cntl = RREG32(R600_ROM_CNTL);
  1022. /* enable the rom */
  1023. WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS));
  1024. if (adev->mode_info.num_crtc) {
  1025. /* Disable VGA mode */
  1026. WREG32(AVIVO_D1VGA_CONTROL,
  1027. (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
  1028. AVIVO_DVGA_CONTROL_TIMING_SELECT)));
  1029. WREG32(AVIVO_D2VGA_CONTROL,
  1030. (d2vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
  1031. AVIVO_DVGA_CONTROL_TIMING_SELECT)));
  1032. WREG32(VGA_RENDER_CONTROL,
  1033. (vga_render_control & C_000300_VGA_VSTATUS_CNTL));
  1034. }
  1035. WREG32(R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE);
  1036. r = amdgpu_read_bios(adev);
  1037. /* restore regs */
  1038. WREG32(R600_BUS_CNTL, bus_cntl);
  1039. if (adev->mode_info.num_crtc) {
  1040. WREG32(AVIVO_D1VGA_CONTROL, d1vga_control);
  1041. WREG32(AVIVO_D2VGA_CONTROL, d2vga_control);
  1042. WREG32(VGA_RENDER_CONTROL, vga_render_control);
  1043. }
  1044. WREG32(R600_ROM_CNTL, rom_cntl);
  1045. return r;
  1046. }
  1047. //xxx: not implemented
  1048. static int si_asic_reset(struct amdgpu_device *adev)
  1049. {
  1050. return 0;
  1051. }
  1052. static void si_vga_set_state(struct amdgpu_device *adev, bool state)
  1053. {
  1054. uint32_t temp;
  1055. temp = RREG32(CONFIG_CNTL);
  1056. if (state == false) {
  1057. temp &= ~(1<<0);
  1058. temp |= (1<<1);
  1059. } else {
  1060. temp &= ~(1<<1);
  1061. }
  1062. WREG32(CONFIG_CNTL, temp);
  1063. }
  1064. static u32 si_get_xclk(struct amdgpu_device *adev)
  1065. {
  1066. u32 reference_clock = adev->clock.spll.reference_freq;
  1067. u32 tmp;
  1068. tmp = RREG32(CG_CLKPIN_CNTL_2);
  1069. if (tmp & MUX_TCLK_TO_XCLK)
  1070. return TCLK;
  1071. tmp = RREG32(CG_CLKPIN_CNTL);
  1072. if (tmp & XTALIN_DIVIDE)
  1073. return reference_clock / 4;
  1074. return reference_clock;
  1075. }
  1076. //xxx:not implemented
  1077. static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
  1078. {
  1079. return 0;
  1080. }
  1081. static void si_detect_hw_virtualization(struct amdgpu_device *adev)
  1082. {
  1083. if (is_virtual_machine()) /* passthrough mode */
  1084. adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE;
  1085. }
  1086. static const struct amdgpu_asic_funcs si_asic_funcs =
  1087. {
  1088. .read_disabled_bios = &si_read_disabled_bios,
  1089. .detect_hw_virtualization = si_detect_hw_virtualization,
  1090. .read_register = &si_read_register,
  1091. .reset = &si_asic_reset,
  1092. .set_vga_state = &si_vga_set_state,
  1093. .get_xclk = &si_get_xclk,
  1094. .set_uvd_clocks = &si_set_uvd_clocks,
  1095. .set_vce_clocks = NULL,
  1096. };
  1097. static uint32_t si_get_rev_id(struct amdgpu_device *adev)
  1098. {
  1099. return (RREG32(CC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK)
  1100. >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT;
  1101. }
  1102. static int si_common_early_init(void *handle)
  1103. {
  1104. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  1105. adev->smc_rreg = &si_smc_rreg;
  1106. adev->smc_wreg = &si_smc_wreg;
  1107. adev->pcie_rreg = &si_pcie_rreg;
  1108. adev->pcie_wreg = &si_pcie_wreg;
  1109. adev->pciep_rreg = &si_pciep_rreg;
  1110. adev->pciep_wreg = &si_pciep_wreg;
  1111. adev->uvd_ctx_rreg = NULL;
  1112. adev->uvd_ctx_wreg = NULL;
  1113. adev->didt_rreg = NULL;
  1114. adev->didt_wreg = NULL;
  1115. adev->asic_funcs = &si_asic_funcs;
  1116. adev->rev_id = si_get_rev_id(adev);
  1117. adev->external_rev_id = 0xFF;
  1118. switch (adev->asic_type) {
  1119. case CHIP_TAHITI:
  1120. adev->cg_flags =
  1121. AMD_CG_SUPPORT_GFX_MGCG |
  1122. AMD_CG_SUPPORT_GFX_MGLS |
  1123. /*AMD_CG_SUPPORT_GFX_CGCG |*/
  1124. AMD_CG_SUPPORT_GFX_CGLS |
  1125. AMD_CG_SUPPORT_GFX_CGTS |
  1126. AMD_CG_SUPPORT_GFX_CP_LS |
  1127. AMD_CG_SUPPORT_MC_MGCG |
  1128. AMD_CG_SUPPORT_SDMA_MGCG |
  1129. AMD_CG_SUPPORT_BIF_LS |
  1130. AMD_CG_SUPPORT_VCE_MGCG |
  1131. AMD_CG_SUPPORT_UVD_MGCG |
  1132. AMD_CG_SUPPORT_HDP_LS |
  1133. AMD_CG_SUPPORT_HDP_MGCG;
  1134. adev->pg_flags = 0;
  1135. adev->external_rev_id = (adev->rev_id == 0) ? 1 :
  1136. (adev->rev_id == 1) ? 5 : 6;
  1137. break;
  1138. case CHIP_PITCAIRN:
  1139. adev->cg_flags =
  1140. AMD_CG_SUPPORT_GFX_MGCG |
  1141. AMD_CG_SUPPORT_GFX_MGLS |
  1142. /*AMD_CG_SUPPORT_GFX_CGCG |*/
  1143. AMD_CG_SUPPORT_GFX_CGLS |
  1144. AMD_CG_SUPPORT_GFX_CGTS |
  1145. AMD_CG_SUPPORT_GFX_CP_LS |
  1146. AMD_CG_SUPPORT_GFX_RLC_LS |
  1147. AMD_CG_SUPPORT_MC_LS |
  1148. AMD_CG_SUPPORT_MC_MGCG |
  1149. AMD_CG_SUPPORT_SDMA_MGCG |
  1150. AMD_CG_SUPPORT_BIF_LS |
  1151. AMD_CG_SUPPORT_VCE_MGCG |
  1152. AMD_CG_SUPPORT_UVD_MGCG |
  1153. AMD_CG_SUPPORT_HDP_LS |
  1154. AMD_CG_SUPPORT_HDP_MGCG;
  1155. adev->pg_flags = 0;
  1156. adev->external_rev_id = adev->rev_id + 20;
  1157. break;
  1158. case CHIP_VERDE:
  1159. adev->cg_flags =
  1160. AMD_CG_SUPPORT_GFX_MGCG |
  1161. AMD_CG_SUPPORT_GFX_MGLS |
  1162. AMD_CG_SUPPORT_GFX_CGLS |
  1163. AMD_CG_SUPPORT_GFX_CGTS |
  1164. AMD_CG_SUPPORT_GFX_CGTS_LS |
  1165. AMD_CG_SUPPORT_GFX_CP_LS |
  1166. AMD_CG_SUPPORT_MC_LS |
  1167. AMD_CG_SUPPORT_MC_MGCG |
  1168. AMD_CG_SUPPORT_SDMA_MGCG |
  1169. AMD_CG_SUPPORT_SDMA_LS |
  1170. AMD_CG_SUPPORT_BIF_LS |
  1171. AMD_CG_SUPPORT_VCE_MGCG |
  1172. AMD_CG_SUPPORT_UVD_MGCG |
  1173. AMD_CG_SUPPORT_HDP_LS |
  1174. AMD_CG_SUPPORT_HDP_MGCG;
  1175. adev->pg_flags = 0;
  1176. //???
  1177. adev->external_rev_id = adev->rev_id + 40;
  1178. break;
  1179. case CHIP_OLAND:
  1180. adev->cg_flags =
  1181. AMD_CG_SUPPORT_GFX_MGCG |
  1182. AMD_CG_SUPPORT_GFX_MGLS |
  1183. /*AMD_CG_SUPPORT_GFX_CGCG |*/
  1184. AMD_CG_SUPPORT_GFX_CGLS |
  1185. AMD_CG_SUPPORT_GFX_CGTS |
  1186. AMD_CG_SUPPORT_GFX_CP_LS |
  1187. AMD_CG_SUPPORT_GFX_RLC_LS |
  1188. AMD_CG_SUPPORT_MC_LS |
  1189. AMD_CG_SUPPORT_MC_MGCG |
  1190. AMD_CG_SUPPORT_SDMA_MGCG |
  1191. AMD_CG_SUPPORT_BIF_LS |
  1192. AMD_CG_SUPPORT_UVD_MGCG |
  1193. AMD_CG_SUPPORT_HDP_LS |
  1194. AMD_CG_SUPPORT_HDP_MGCG;
  1195. adev->pg_flags = 0;
  1196. adev->external_rev_id = 60;
  1197. break;
  1198. case CHIP_HAINAN:
  1199. adev->cg_flags =
  1200. AMD_CG_SUPPORT_GFX_MGCG |
  1201. AMD_CG_SUPPORT_GFX_MGLS |
  1202. /*AMD_CG_SUPPORT_GFX_CGCG |*/
  1203. AMD_CG_SUPPORT_GFX_CGLS |
  1204. AMD_CG_SUPPORT_GFX_CGTS |
  1205. AMD_CG_SUPPORT_GFX_CP_LS |
  1206. AMD_CG_SUPPORT_GFX_RLC_LS |
  1207. AMD_CG_SUPPORT_MC_LS |
  1208. AMD_CG_SUPPORT_MC_MGCG |
  1209. AMD_CG_SUPPORT_SDMA_MGCG |
  1210. AMD_CG_SUPPORT_BIF_LS |
  1211. AMD_CG_SUPPORT_HDP_LS |
  1212. AMD_CG_SUPPORT_HDP_MGCG;
  1213. adev->pg_flags = 0;
  1214. adev->external_rev_id = 70;
  1215. break;
  1216. default:
  1217. return -EINVAL;
  1218. }
  1219. return 0;
  1220. }
  1221. static int si_common_sw_init(void *handle)
  1222. {
  1223. return 0;
  1224. }
  1225. static int si_common_sw_fini(void *handle)
  1226. {
  1227. return 0;
  1228. }
  1229. static void si_init_golden_registers(struct amdgpu_device *adev)
  1230. {
  1231. switch (adev->asic_type) {
  1232. case CHIP_TAHITI:
  1233. amdgpu_program_register_sequence(adev,
  1234. tahiti_golden_registers,
  1235. (const u32)ARRAY_SIZE(tahiti_golden_registers));
  1236. amdgpu_program_register_sequence(adev,
  1237. tahiti_golden_rlc_registers,
  1238. (const u32)ARRAY_SIZE(tahiti_golden_rlc_registers));
  1239. amdgpu_program_register_sequence(adev,
  1240. tahiti_mgcg_cgcg_init,
  1241. (const u32)ARRAY_SIZE(tahiti_mgcg_cgcg_init));
  1242. amdgpu_program_register_sequence(adev,
  1243. tahiti_golden_registers2,
  1244. (const u32)ARRAY_SIZE(tahiti_golden_registers2));
  1245. break;
  1246. case CHIP_PITCAIRN:
  1247. amdgpu_program_register_sequence(adev,
  1248. pitcairn_golden_registers,
  1249. (const u32)ARRAY_SIZE(pitcairn_golden_registers));
  1250. amdgpu_program_register_sequence(adev,
  1251. pitcairn_golden_rlc_registers,
  1252. (const u32)ARRAY_SIZE(pitcairn_golden_rlc_registers));
  1253. amdgpu_program_register_sequence(adev,
  1254. pitcairn_mgcg_cgcg_init,
  1255. (const u32)ARRAY_SIZE(pitcairn_mgcg_cgcg_init));
  1256. case CHIP_VERDE:
  1257. amdgpu_program_register_sequence(adev,
  1258. verde_golden_registers,
  1259. (const u32)ARRAY_SIZE(verde_golden_registers));
  1260. amdgpu_program_register_sequence(adev,
  1261. verde_golden_rlc_registers,
  1262. (const u32)ARRAY_SIZE(verde_golden_rlc_registers));
  1263. amdgpu_program_register_sequence(adev,
  1264. verde_mgcg_cgcg_init,
  1265. (const u32)ARRAY_SIZE(verde_mgcg_cgcg_init));
  1266. amdgpu_program_register_sequence(adev,
  1267. verde_pg_init,
  1268. (const u32)ARRAY_SIZE(verde_pg_init));
  1269. break;
  1270. case CHIP_OLAND:
  1271. amdgpu_program_register_sequence(adev,
  1272. oland_golden_registers,
  1273. (const u32)ARRAY_SIZE(oland_golden_registers));
  1274. amdgpu_program_register_sequence(adev,
  1275. oland_golden_rlc_registers,
  1276. (const u32)ARRAY_SIZE(oland_golden_rlc_registers));
  1277. amdgpu_program_register_sequence(adev,
  1278. oland_mgcg_cgcg_init,
  1279. (const u32)ARRAY_SIZE(oland_mgcg_cgcg_init));
  1280. case CHIP_HAINAN:
  1281. amdgpu_program_register_sequence(adev,
  1282. hainan_golden_registers,
  1283. (const u32)ARRAY_SIZE(hainan_golden_registers));
  1284. amdgpu_program_register_sequence(adev,
  1285. hainan_golden_registers2,
  1286. (const u32)ARRAY_SIZE(hainan_golden_registers2));
  1287. amdgpu_program_register_sequence(adev,
  1288. hainan_mgcg_cgcg_init,
  1289. (const u32)ARRAY_SIZE(hainan_mgcg_cgcg_init));
  1290. break;
  1291. default:
  1292. BUG();
  1293. }
  1294. }
  1295. static void si_pcie_gen3_enable(struct amdgpu_device *adev)
  1296. {
  1297. struct pci_dev *root = adev->pdev->bus->self;
  1298. int bridge_pos, gpu_pos;
  1299. u32 speed_cntl, mask, current_data_rate;
  1300. int ret, i;
  1301. u16 tmp16;
  1302. if (pci_is_root_bus(adev->pdev->bus))
  1303. return;
  1304. if (amdgpu_pcie_gen2 == 0)
  1305. return;
  1306. if (adev->flags & AMD_IS_APU)
  1307. return;
  1308. ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);
  1309. if (ret != 0)
  1310. return;
  1311. if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80)))
  1312. return;
  1313. speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
  1314. current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >>
  1315. LC_CURRENT_DATA_RATE_SHIFT;
  1316. if (mask & DRM_PCIE_SPEED_80) {
  1317. if (current_data_rate == 2) {
  1318. DRM_INFO("PCIE gen 3 link speeds already enabled\n");
  1319. return;
  1320. }
  1321. DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n");
  1322. } else if (mask & DRM_PCIE_SPEED_50) {
  1323. if (current_data_rate == 1) {
  1324. DRM_INFO("PCIE gen 2 link speeds already enabled\n");
  1325. return;
  1326. }
  1327. DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n");
  1328. }
  1329. bridge_pos = pci_pcie_cap(root);
  1330. if (!bridge_pos)
  1331. return;
  1332. gpu_pos = pci_pcie_cap(adev->pdev);
  1333. if (!gpu_pos)
  1334. return;
  1335. if (mask & DRM_PCIE_SPEED_80) {
  1336. if (current_data_rate != 2) {
  1337. u16 bridge_cfg, gpu_cfg;
  1338. u16 bridge_cfg2, gpu_cfg2;
  1339. u32 max_lw, current_lw, tmp;
  1340. pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg);
  1341. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg);
  1342. tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD;
  1343. pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16);
  1344. tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD;
  1345. pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16);
  1346. tmp = RREG32_PCIE(PCIE_LC_STATUS1);
  1347. max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT;
  1348. current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT;
  1349. if (current_lw < max_lw) {
  1350. tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL);
  1351. if (tmp & LC_RENEGOTIATION_SUPPORT) {
  1352. tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS);
  1353. tmp |= (max_lw << LC_LINK_WIDTH_SHIFT);
  1354. tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW;
  1355. WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp);
  1356. }
  1357. }
  1358. for (i = 0; i < 10; i++) {
  1359. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16);
  1360. if (tmp16 & PCI_EXP_DEVSTA_TRPND)
  1361. break;
  1362. pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg);
  1363. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg);
  1364. pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2);
  1365. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2);
  1366. tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4);
  1367. tmp |= LC_SET_QUIESCE;
  1368. WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp);
  1369. tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4);
  1370. tmp |= LC_REDO_EQ;
  1371. WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp);
  1372. mdelay(100);
  1373. pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16);
  1374. tmp16 &= ~PCI_EXP_LNKCTL_HAWD;
  1375. tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD);
  1376. pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16);
  1377. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16);
  1378. tmp16 &= ~PCI_EXP_LNKCTL_HAWD;
  1379. tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD);
  1380. pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16);
  1381. pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16);
  1382. tmp16 &= ~((1 << 4) | (7 << 9));
  1383. tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9)));
  1384. pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16);
  1385. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);
  1386. tmp16 &= ~((1 << 4) | (7 << 9));
  1387. tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9)));
  1388. pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
  1389. tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4);
  1390. tmp &= ~LC_SET_QUIESCE;
  1391. WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp);
  1392. }
  1393. }
  1394. }
  1395. speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE;
  1396. speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE;
  1397. WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl);
  1398. pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);
  1399. tmp16 &= ~0xf;
  1400. if (mask & DRM_PCIE_SPEED_80)
  1401. tmp16 |= 3;
  1402. else if (mask & DRM_PCIE_SPEED_50)
  1403. tmp16 |= 2;
  1404. else
  1405. tmp16 |= 1;
  1406. pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
  1407. speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
  1408. speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE;
  1409. WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl);
  1410. for (i = 0; i < adev->usec_timeout; i++) {
  1411. speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);
  1412. if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0)
  1413. break;
  1414. udelay(1);
  1415. }
  1416. }
  1417. static inline u32 si_pif_phy0_rreg(struct amdgpu_device *adev, u32 reg)
  1418. {
  1419. unsigned long flags;
  1420. u32 r;
  1421. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  1422. WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff));
  1423. r = RREG32(EVERGREEN_PIF_PHY0_DATA);
  1424. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  1425. return r;
  1426. }
  1427. static inline void si_pif_phy0_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
  1428. {
  1429. unsigned long flags;
  1430. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  1431. WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff));
  1432. WREG32(EVERGREEN_PIF_PHY0_DATA, (v));
  1433. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  1434. }
  1435. static inline u32 si_pif_phy1_rreg(struct amdgpu_device *adev, u32 reg)
  1436. {
  1437. unsigned long flags;
  1438. u32 r;
  1439. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  1440. WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff));
  1441. r = RREG32(EVERGREEN_PIF_PHY1_DATA);
  1442. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  1443. return r;
  1444. }
  1445. static inline void si_pif_phy1_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
  1446. {
  1447. unsigned long flags;
  1448. spin_lock_irqsave(&adev->pcie_idx_lock, flags);
  1449. WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff));
  1450. WREG32(EVERGREEN_PIF_PHY1_DATA, (v));
  1451. spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
  1452. }
  1453. static void si_program_aspm(struct amdgpu_device *adev)
  1454. {
  1455. u32 data, orig;
  1456. bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
  1457. bool disable_clkreq = false;
  1458. if (amdgpu_aspm == 0)
  1459. return;
  1460. if (adev->flags & AMD_IS_APU)
  1461. return;
  1462. orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL);
  1463. data &= ~LC_XMIT_N_FTS_MASK;
  1464. data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN;
  1465. if (orig != data)
  1466. WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data);
  1467. orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3);
  1468. data |= LC_GO_TO_RECOVERY;
  1469. if (orig != data)
  1470. WREG32_PCIE_PORT(PCIE_LC_CNTL3, data);
  1471. orig = data = RREG32_PCIE(PCIE_P_CNTL);
  1472. data |= P_IGNORE_EDB_ERR;
  1473. if (orig != data)
  1474. WREG32_PCIE(PCIE_P_CNTL, data);
  1475. orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL);
  1476. data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK);
  1477. data |= LC_PMI_TO_L1_DIS;
  1478. if (!disable_l0s)
  1479. data |= LC_L0S_INACTIVITY(7);
  1480. if (!disable_l1) {
  1481. data |= LC_L1_INACTIVITY(7);
  1482. data &= ~LC_PMI_TO_L1_DIS;
  1483. if (orig != data)
  1484. WREG32_PCIE_PORT(PCIE_LC_CNTL, data);
  1485. if (!disable_plloff_in_l1) {
  1486. bool clk_req_support;
  1487. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0);
  1488. data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK);
  1489. data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7);
  1490. if (orig != data)
  1491. si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data);
  1492. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1);
  1493. data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK);
  1494. data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7);
  1495. if (orig != data)
  1496. si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data);
  1497. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0);
  1498. data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK);
  1499. data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7);
  1500. if (orig != data)
  1501. si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data);
  1502. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1);
  1503. data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK);
  1504. data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7);
  1505. if (orig != data)
  1506. si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data);
  1507. if ((adev->family != CHIP_OLAND) && (adev->family != CHIP_HAINAN)) {
  1508. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_0);
  1509. data &= ~PLL_RAMP_UP_TIME_0_MASK;
  1510. if (orig != data)
  1511. si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_0, data);
  1512. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_1);
  1513. data &= ~PLL_RAMP_UP_TIME_1_MASK;
  1514. if (orig != data)
  1515. si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_1, data);
  1516. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_2);
  1517. data &= ~PLL_RAMP_UP_TIME_2_MASK;
  1518. if (orig != data)
  1519. si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_2, data);
  1520. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_PWRDOWN_3);
  1521. data &= ~PLL_RAMP_UP_TIME_3_MASK;
  1522. if (orig != data)
  1523. si_pif_phy0_wreg(adev,PB0_PIF_PWRDOWN_3, data);
  1524. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_0);
  1525. data &= ~PLL_RAMP_UP_TIME_0_MASK;
  1526. if (orig != data)
  1527. si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_0, data);
  1528. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_1);
  1529. data &= ~PLL_RAMP_UP_TIME_1_MASK;
  1530. if (orig != data)
  1531. si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_1, data);
  1532. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_2);
  1533. data &= ~PLL_RAMP_UP_TIME_2_MASK;
  1534. if (orig != data)
  1535. si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_2, data);
  1536. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_PWRDOWN_3);
  1537. data &= ~PLL_RAMP_UP_TIME_3_MASK;
  1538. if (orig != data)
  1539. si_pif_phy1_wreg(adev,PB1_PIF_PWRDOWN_3, data);
  1540. }
  1541. orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL);
  1542. data &= ~LC_DYN_LANES_PWR_STATE_MASK;
  1543. data |= LC_DYN_LANES_PWR_STATE(3);
  1544. if (orig != data)
  1545. WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data);
  1546. orig = data = si_pif_phy0_rreg(adev,PB0_PIF_CNTL);
  1547. data &= ~LS2_EXIT_TIME_MASK;
  1548. if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN))
  1549. data |= LS2_EXIT_TIME(5);
  1550. if (orig != data)
  1551. si_pif_phy0_wreg(adev,PB0_PIF_CNTL, data);
  1552. orig = data = si_pif_phy1_rreg(adev,PB1_PIF_CNTL);
  1553. data &= ~LS2_EXIT_TIME_MASK;
  1554. if ((adev->family == CHIP_OLAND) || (adev->family == CHIP_HAINAN))
  1555. data |= LS2_EXIT_TIME(5);
  1556. if (orig != data)
  1557. si_pif_phy1_wreg(adev,PB1_PIF_CNTL, data);
  1558. if (!disable_clkreq &&
  1559. !pci_is_root_bus(adev->pdev->bus)) {
  1560. struct pci_dev *root = adev->pdev->bus->self;
  1561. u32 lnkcap;
  1562. clk_req_support = false;
  1563. pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap);
  1564. if (lnkcap & PCI_EXP_LNKCAP_CLKPM)
  1565. clk_req_support = true;
  1566. } else {
  1567. clk_req_support = false;
  1568. }
  1569. if (clk_req_support) {
  1570. orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2);
  1571. data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23;
  1572. if (orig != data)
  1573. WREG32_PCIE_PORT(PCIE_LC_CNTL2, data);
  1574. orig = data = RREG32(THM_CLK_CNTL);
  1575. data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK);
  1576. data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1);
  1577. if (orig != data)
  1578. WREG32(THM_CLK_CNTL, data);
  1579. orig = data = RREG32(MISC_CLK_CNTL);
  1580. data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK);
  1581. data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1);
  1582. if (orig != data)
  1583. WREG32(MISC_CLK_CNTL, data);
  1584. orig = data = RREG32(CG_CLKPIN_CNTL);
  1585. data &= ~BCLK_AS_XCLK;
  1586. if (orig != data)
  1587. WREG32(CG_CLKPIN_CNTL, data);
  1588. orig = data = RREG32(CG_CLKPIN_CNTL_2);
  1589. data &= ~FORCE_BIF_REFCLK_EN;
  1590. if (orig != data)
  1591. WREG32(CG_CLKPIN_CNTL_2, data);
  1592. orig = data = RREG32(MPLL_BYPASSCLK_SEL);
  1593. data &= ~MPLL_CLKOUT_SEL_MASK;
  1594. data |= MPLL_CLKOUT_SEL(4);
  1595. if (orig != data)
  1596. WREG32(MPLL_BYPASSCLK_SEL, data);
  1597. orig = data = RREG32(SPLL_CNTL_MODE);
  1598. data &= ~SPLL_REFCLK_SEL_MASK;
  1599. if (orig != data)
  1600. WREG32(SPLL_CNTL_MODE, data);
  1601. }
  1602. }
  1603. } else {
  1604. if (orig != data)
  1605. WREG32_PCIE_PORT(PCIE_LC_CNTL, data);
  1606. }
  1607. orig = data = RREG32_PCIE(PCIE_CNTL2);
  1608. data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN;
  1609. if (orig != data)
  1610. WREG32_PCIE(PCIE_CNTL2, data);
  1611. if (!disable_l0s) {
  1612. data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL);
  1613. if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) {
  1614. data = RREG32_PCIE(PCIE_LC_STATUS1);
  1615. if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) {
  1616. orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL);
  1617. data &= ~LC_L0S_INACTIVITY_MASK;
  1618. if (orig != data)
  1619. WREG32_PCIE_PORT(PCIE_LC_CNTL, data);
  1620. }
  1621. }
  1622. }
  1623. }
  1624. static void si_fix_pci_max_read_req_size(struct amdgpu_device *adev)
  1625. {
  1626. int readrq;
  1627. u16 v;
  1628. readrq = pcie_get_readrq(adev->pdev);
  1629. v = ffs(readrq) - 8;
  1630. if ((v == 0) || (v == 6) || (v == 7))
  1631. pcie_set_readrq(adev->pdev, 512);
  1632. }
  1633. static int si_common_hw_init(void *handle)
  1634. {
  1635. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  1636. si_fix_pci_max_read_req_size(adev);
  1637. si_init_golden_registers(adev);
  1638. si_pcie_gen3_enable(adev);
  1639. si_program_aspm(adev);
  1640. return 0;
  1641. }
  1642. static int si_common_hw_fini(void *handle)
  1643. {
  1644. return 0;
  1645. }
  1646. static int si_common_suspend(void *handle)
  1647. {
  1648. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  1649. return si_common_hw_fini(adev);
  1650. }
  1651. static int si_common_resume(void *handle)
  1652. {
  1653. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  1654. return si_common_hw_init(adev);
  1655. }
  1656. static bool si_common_is_idle(void *handle)
  1657. {
  1658. return true;
  1659. }
  1660. static int si_common_wait_for_idle(void *handle)
  1661. {
  1662. return 0;
  1663. }
  1664. static int si_common_soft_reset(void *handle)
  1665. {
  1666. return 0;
  1667. }
  1668. static int si_common_set_clockgating_state(void *handle,
  1669. enum amd_clockgating_state state)
  1670. {
  1671. return 0;
  1672. }
  1673. static int si_common_set_powergating_state(void *handle,
  1674. enum amd_powergating_state state)
  1675. {
  1676. return 0;
  1677. }
  1678. static const struct amd_ip_funcs si_common_ip_funcs = {
  1679. .name = "si_common",
  1680. .early_init = si_common_early_init,
  1681. .late_init = NULL,
  1682. .sw_init = si_common_sw_init,
  1683. .sw_fini = si_common_sw_fini,
  1684. .hw_init = si_common_hw_init,
  1685. .hw_fini = si_common_hw_fini,
  1686. .suspend = si_common_suspend,
  1687. .resume = si_common_resume,
  1688. .is_idle = si_common_is_idle,
  1689. .wait_for_idle = si_common_wait_for_idle,
  1690. .soft_reset = si_common_soft_reset,
  1691. .set_clockgating_state = si_common_set_clockgating_state,
  1692. .set_powergating_state = si_common_set_powergating_state,
  1693. };
  1694. static const struct amdgpu_ip_block_version si_common_ip_block =
  1695. {
  1696. .type = AMD_IP_BLOCK_TYPE_COMMON,
  1697. .major = 1,
  1698. .minor = 0,
  1699. .rev = 0,
  1700. .funcs = &si_common_ip_funcs,
  1701. };
  1702. int si_set_ip_blocks(struct amdgpu_device *adev)
  1703. {
  1704. switch (adev->asic_type) {
  1705. case CHIP_VERDE:
  1706. case CHIP_TAHITI:
  1707. case CHIP_PITCAIRN:
  1708. amdgpu_ip_block_add(adev, &si_common_ip_block);
  1709. amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block);
  1710. amdgpu_ip_block_add(adev, &si_ih_ip_block);
  1711. amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
  1712. if (adev->enable_virtual_display)
  1713. amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
  1714. else
  1715. amdgpu_ip_block_add(adev, &dce_v6_0_ip_block);
  1716. amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block);
  1717. amdgpu_ip_block_add(adev, &si_dma_ip_block);
  1718. /* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */
  1719. /* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */
  1720. break;
  1721. case CHIP_OLAND:
  1722. amdgpu_ip_block_add(adev, &si_common_ip_block);
  1723. amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block);
  1724. amdgpu_ip_block_add(adev, &si_ih_ip_block);
  1725. amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
  1726. if (adev->enable_virtual_display)
  1727. amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
  1728. else
  1729. amdgpu_ip_block_add(adev, &dce_v6_4_ip_block);
  1730. amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block);
  1731. amdgpu_ip_block_add(adev, &si_dma_ip_block);
  1732. /* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */
  1733. /* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */
  1734. break;
  1735. case CHIP_HAINAN:
  1736. amdgpu_ip_block_add(adev, &si_common_ip_block);
  1737. amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block);
  1738. amdgpu_ip_block_add(adev, &si_ih_ip_block);
  1739. amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block);
  1740. if (adev->enable_virtual_display)
  1741. amdgpu_ip_block_add(adev, &dce_virtual_ip_block);
  1742. amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block);
  1743. amdgpu_ip_block_add(adev, &si_dma_ip_block);
  1744. break;
  1745. default:
  1746. BUG();
  1747. }
  1748. return 0;
  1749. }