si.c 54 KB

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