si.c 65 KB

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