1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev * Copyright 2012 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev *
4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev *
11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev *
14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev *
22*b843c749SSergey Zigachev * Authors: Alex Deucher
23*b843c749SSergey Zigachev */
24*b843c749SSergey Zigachev #include <linux/firmware.h>
25*b843c749SSergey Zigachev #include <linux/slab.h>
26*b843c749SSergey Zigachev #include <linux/module.h>
27*b843c749SSergey Zigachev #include <drm/drmP.h>
28*b843c749SSergey Zigachev #include "amdgpu.h"
29*b843c749SSergey Zigachev #include "amdgpu_atombios.h"
30*b843c749SSergey Zigachev #include "amdgpu_ih.h"
31*b843c749SSergey Zigachev #include "amdgpu_uvd.h"
32*b843c749SSergey Zigachev #include "amdgpu_vce.h"
33*b843c749SSergey Zigachev #include "cikd.h"
34*b843c749SSergey Zigachev #include "atom.h"
35*b843c749SSergey Zigachev #include "amd_pcie.h"
36*b843c749SSergey Zigachev
37*b843c749SSergey Zigachev #include "cik.h"
38*b843c749SSergey Zigachev #include "gmc_v7_0.h"
39*b843c749SSergey Zigachev #include "cik_ih.h"
40*b843c749SSergey Zigachev #include "dce_v8_0.h"
41*b843c749SSergey Zigachev #include "gfx_v7_0.h"
42*b843c749SSergey Zigachev #include "cik_sdma.h"
43*b843c749SSergey Zigachev #include "uvd_v4_2.h"
44*b843c749SSergey Zigachev #include "vce_v2_0.h"
45*b843c749SSergey Zigachev #include "cik_dpm.h"
46*b843c749SSergey Zigachev
47*b843c749SSergey Zigachev #include "uvd/uvd_4_2_d.h"
48*b843c749SSergey Zigachev
49*b843c749SSergey Zigachev #include "smu/smu_7_0_1_d.h"
50*b843c749SSergey Zigachev #include "smu/smu_7_0_1_sh_mask.h"
51*b843c749SSergey Zigachev
52*b843c749SSergey Zigachev #include "dce/dce_8_0_d.h"
53*b843c749SSergey Zigachev #include "dce/dce_8_0_sh_mask.h"
54*b843c749SSergey Zigachev
55*b843c749SSergey Zigachev #include "bif/bif_4_1_d.h"
56*b843c749SSergey Zigachev #include "bif/bif_4_1_sh_mask.h"
57*b843c749SSergey Zigachev
58*b843c749SSergey Zigachev #include "gca/gfx_7_2_d.h"
59*b843c749SSergey Zigachev #include "gca/gfx_7_2_enum.h"
60*b843c749SSergey Zigachev #include "gca/gfx_7_2_sh_mask.h"
61*b843c749SSergey Zigachev
62*b843c749SSergey Zigachev #include "gmc/gmc_7_1_d.h"
63*b843c749SSergey Zigachev #include "gmc/gmc_7_1_sh_mask.h"
64*b843c749SSergey Zigachev
65*b843c749SSergey Zigachev #include "oss/oss_2_0_d.h"
66*b843c749SSergey Zigachev #include "oss/oss_2_0_sh_mask.h"
67*b843c749SSergey Zigachev
68*b843c749SSergey Zigachev #include "amdgpu_dm.h"
69*b843c749SSergey Zigachev #include "amdgpu_amdkfd.h"
70*b843c749SSergey Zigachev #include "dce_virtual.h"
71*b843c749SSergey Zigachev
72*b843c749SSergey Zigachev /*
73*b843c749SSergey Zigachev * Indirect registers accessor
74*b843c749SSergey Zigachev */
cik_pcie_rreg(struct amdgpu_device * adev,u32 reg)75*b843c749SSergey Zigachev static u32 cik_pcie_rreg(struct amdgpu_device *adev, u32 reg)
76*b843c749SSergey Zigachev {
77*b843c749SSergey Zigachev unsigned long flags;
78*b843c749SSergey Zigachev u32 r;
79*b843c749SSergey Zigachev
80*b843c749SSergey Zigachev spin_lock_irqsave(&adev->pcie_idx_lock, flags);
81*b843c749SSergey Zigachev WREG32(mmPCIE_INDEX, reg);
82*b843c749SSergey Zigachev (void)RREG32(mmPCIE_INDEX);
83*b843c749SSergey Zigachev r = RREG32(mmPCIE_DATA);
84*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
85*b843c749SSergey Zigachev return r;
86*b843c749SSergey Zigachev }
87*b843c749SSergey Zigachev
cik_pcie_wreg(struct amdgpu_device * adev,u32 reg,u32 v)88*b843c749SSergey Zigachev static void cik_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
89*b843c749SSergey Zigachev {
90*b843c749SSergey Zigachev unsigned long flags;
91*b843c749SSergey Zigachev
92*b843c749SSergey Zigachev spin_lock_irqsave(&adev->pcie_idx_lock, flags);
93*b843c749SSergey Zigachev WREG32(mmPCIE_INDEX, reg);
94*b843c749SSergey Zigachev (void)RREG32(mmPCIE_INDEX);
95*b843c749SSergey Zigachev WREG32(mmPCIE_DATA, v);
96*b843c749SSergey Zigachev (void)RREG32(mmPCIE_DATA);
97*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
98*b843c749SSergey Zigachev }
99*b843c749SSergey Zigachev
cik_smc_rreg(struct amdgpu_device * adev,u32 reg)100*b843c749SSergey Zigachev static u32 cik_smc_rreg(struct amdgpu_device *adev, u32 reg)
101*b843c749SSergey Zigachev {
102*b843c749SSergey Zigachev unsigned long flags;
103*b843c749SSergey Zigachev u32 r;
104*b843c749SSergey Zigachev
105*b843c749SSergey Zigachev spin_lock_irqsave(&adev->smc_idx_lock, flags);
106*b843c749SSergey Zigachev WREG32(mmSMC_IND_INDEX_0, (reg));
107*b843c749SSergey Zigachev r = RREG32(mmSMC_IND_DATA_0);
108*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
109*b843c749SSergey Zigachev return r;
110*b843c749SSergey Zigachev }
111*b843c749SSergey Zigachev
cik_smc_wreg(struct amdgpu_device * adev,u32 reg,u32 v)112*b843c749SSergey Zigachev static void cik_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
113*b843c749SSergey Zigachev {
114*b843c749SSergey Zigachev unsigned long flags;
115*b843c749SSergey Zigachev
116*b843c749SSergey Zigachev spin_lock_irqsave(&adev->smc_idx_lock, flags);
117*b843c749SSergey Zigachev WREG32(mmSMC_IND_INDEX_0, (reg));
118*b843c749SSergey Zigachev WREG32(mmSMC_IND_DATA_0, (v));
119*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
120*b843c749SSergey Zigachev }
121*b843c749SSergey Zigachev
cik_uvd_ctx_rreg(struct amdgpu_device * adev,u32 reg)122*b843c749SSergey Zigachev static u32 cik_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
123*b843c749SSergey Zigachev {
124*b843c749SSergey Zigachev unsigned long flags;
125*b843c749SSergey Zigachev u32 r;
126*b843c749SSergey Zigachev
127*b843c749SSergey Zigachev spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
128*b843c749SSergey Zigachev WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
129*b843c749SSergey Zigachev r = RREG32(mmUVD_CTX_DATA);
130*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
131*b843c749SSergey Zigachev return r;
132*b843c749SSergey Zigachev }
133*b843c749SSergey Zigachev
cik_uvd_ctx_wreg(struct amdgpu_device * adev,u32 reg,u32 v)134*b843c749SSergey Zigachev static void cik_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
135*b843c749SSergey Zigachev {
136*b843c749SSergey Zigachev unsigned long flags;
137*b843c749SSergey Zigachev
138*b843c749SSergey Zigachev spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
139*b843c749SSergey Zigachev WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
140*b843c749SSergey Zigachev WREG32(mmUVD_CTX_DATA, (v));
141*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
142*b843c749SSergey Zigachev }
143*b843c749SSergey Zigachev
cik_didt_rreg(struct amdgpu_device * adev,u32 reg)144*b843c749SSergey Zigachev static u32 cik_didt_rreg(struct amdgpu_device *adev, u32 reg)
145*b843c749SSergey Zigachev {
146*b843c749SSergey Zigachev unsigned long flags;
147*b843c749SSergey Zigachev u32 r;
148*b843c749SSergey Zigachev
149*b843c749SSergey Zigachev spin_lock_irqsave(&adev->didt_idx_lock, flags);
150*b843c749SSergey Zigachev WREG32(mmDIDT_IND_INDEX, (reg));
151*b843c749SSergey Zigachev r = RREG32(mmDIDT_IND_DATA);
152*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
153*b843c749SSergey Zigachev return r;
154*b843c749SSergey Zigachev }
155*b843c749SSergey Zigachev
cik_didt_wreg(struct amdgpu_device * adev,u32 reg,u32 v)156*b843c749SSergey Zigachev static void cik_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
157*b843c749SSergey Zigachev {
158*b843c749SSergey Zigachev unsigned long flags;
159*b843c749SSergey Zigachev
160*b843c749SSergey Zigachev spin_lock_irqsave(&adev->didt_idx_lock, flags);
161*b843c749SSergey Zigachev WREG32(mmDIDT_IND_INDEX, (reg));
162*b843c749SSergey Zigachev WREG32(mmDIDT_IND_DATA, (v));
163*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
164*b843c749SSergey Zigachev }
165*b843c749SSergey Zigachev
166*b843c749SSergey Zigachev static const u32 bonaire_golden_spm_registers[] =
167*b843c749SSergey Zigachev {
168*b843c749SSergey Zigachev 0xc200, 0xe0ffffff, 0xe0000000
169*b843c749SSergey Zigachev };
170*b843c749SSergey Zigachev
171*b843c749SSergey Zigachev static const u32 bonaire_golden_common_registers[] =
172*b843c749SSergey Zigachev {
173*b843c749SSergey Zigachev 0x31dc, 0xffffffff, 0x00000800,
174*b843c749SSergey Zigachev 0x31dd, 0xffffffff, 0x00000800,
175*b843c749SSergey Zigachev 0x31e6, 0xffffffff, 0x00007fbf,
176*b843c749SSergey Zigachev 0x31e7, 0xffffffff, 0x00007faf
177*b843c749SSergey Zigachev };
178*b843c749SSergey Zigachev
179*b843c749SSergey Zigachev static const u32 bonaire_golden_registers[] =
180*b843c749SSergey Zigachev {
181*b843c749SSergey Zigachev 0xcd5, 0x00000333, 0x00000333,
182*b843c749SSergey Zigachev 0xcd4, 0x000c0fc0, 0x00040200,
183*b843c749SSergey Zigachev 0x2684, 0x00010000, 0x00058208,
184*b843c749SSergey Zigachev 0xf000, 0xffff1fff, 0x00140000,
185*b843c749SSergey Zigachev 0xf080, 0xfdfc0fff, 0x00000100,
186*b843c749SSergey Zigachev 0xf08d, 0x40000000, 0x40000200,
187*b843c749SSergey Zigachev 0x260c, 0xffffffff, 0x00000000,
188*b843c749SSergey Zigachev 0x260d, 0xf00fffff, 0x00000400,
189*b843c749SSergey Zigachev 0x260e, 0x0002021c, 0x00020200,
190*b843c749SSergey Zigachev 0x31e, 0x00000080, 0x00000000,
191*b843c749SSergey Zigachev 0x16ec, 0x000000f0, 0x00000070,
192*b843c749SSergey Zigachev 0x16f0, 0xf0311fff, 0x80300000,
193*b843c749SSergey Zigachev 0x263e, 0x73773777, 0x12010001,
194*b843c749SSergey Zigachev 0xd43, 0x00810000, 0x408af000,
195*b843c749SSergey Zigachev 0x1c0c, 0x31000111, 0x00000011,
196*b843c749SSergey Zigachev 0xbd2, 0x73773777, 0x12010001,
197*b843c749SSergey Zigachev 0x883, 0x00007fb6, 0x0021a1b1,
198*b843c749SSergey Zigachev 0x884, 0x00007fb6, 0x002021b1,
199*b843c749SSergey Zigachev 0x860, 0x00007fb6, 0x00002191,
200*b843c749SSergey Zigachev 0x886, 0x00007fb6, 0x002121b1,
201*b843c749SSergey Zigachev 0x887, 0x00007fb6, 0x002021b1,
202*b843c749SSergey Zigachev 0x877, 0x00007fb6, 0x00002191,
203*b843c749SSergey Zigachev 0x878, 0x00007fb6, 0x00002191,
204*b843c749SSergey Zigachev 0xd8a, 0x0000003f, 0x0000000a,
205*b843c749SSergey Zigachev 0xd8b, 0x0000003f, 0x0000000a,
206*b843c749SSergey Zigachev 0xab9, 0x00073ffe, 0x000022a2,
207*b843c749SSergey Zigachev 0x903, 0x000007ff, 0x00000000,
208*b843c749SSergey Zigachev 0x2285, 0xf000003f, 0x00000007,
209*b843c749SSergey Zigachev 0x22fc, 0x00002001, 0x00000001,
210*b843c749SSergey Zigachev 0x22c9, 0xffffffff, 0x00ffffff,
211*b843c749SSergey Zigachev 0xc281, 0x0000ff0f, 0x00000000,
212*b843c749SSergey Zigachev 0xa293, 0x07ffffff, 0x06000000,
213*b843c749SSergey Zigachev 0x136, 0x00000fff, 0x00000100,
214*b843c749SSergey Zigachev 0xf9e, 0x00000001, 0x00000002,
215*b843c749SSergey Zigachev 0x2440, 0x03000000, 0x0362c688,
216*b843c749SSergey Zigachev 0x2300, 0x000000ff, 0x00000001,
217*b843c749SSergey Zigachev 0x390, 0x00001fff, 0x00001fff,
218*b843c749SSergey Zigachev 0x2418, 0x0000007f, 0x00000020,
219*b843c749SSergey Zigachev 0x2542, 0x00010000, 0x00010000,
220*b843c749SSergey Zigachev 0x2b05, 0x000003ff, 0x000000f3,
221*b843c749SSergey Zigachev 0x2b03, 0xffffffff, 0x00001032
222*b843c749SSergey Zigachev };
223*b843c749SSergey Zigachev
224*b843c749SSergey Zigachev static const u32 bonaire_mgcg_cgcg_init[] =
225*b843c749SSergey Zigachev {
226*b843c749SSergey Zigachev 0x3108, 0xffffffff, 0xfffffffc,
227*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
228*b843c749SSergey Zigachev 0xf0a8, 0xffffffff, 0x00000100,
229*b843c749SSergey Zigachev 0xf082, 0xffffffff, 0x00000100,
230*b843c749SSergey Zigachev 0xf0b0, 0xffffffff, 0xc0000100,
231*b843c749SSergey Zigachev 0xf0b2, 0xffffffff, 0xc0000100,
232*b843c749SSergey Zigachev 0xf0b1, 0xffffffff, 0xc0000100,
233*b843c749SSergey Zigachev 0x1579, 0xffffffff, 0x00600100,
234*b843c749SSergey Zigachev 0xf0a0, 0xffffffff, 0x00000100,
235*b843c749SSergey Zigachev 0xf085, 0xffffffff, 0x06000100,
236*b843c749SSergey Zigachev 0xf088, 0xffffffff, 0x00000100,
237*b843c749SSergey Zigachev 0xf086, 0xffffffff, 0x06000100,
238*b843c749SSergey Zigachev 0xf081, 0xffffffff, 0x00000100,
239*b843c749SSergey Zigachev 0xf0b8, 0xffffffff, 0x00000100,
240*b843c749SSergey Zigachev 0xf089, 0xffffffff, 0x00000100,
241*b843c749SSergey Zigachev 0xf080, 0xffffffff, 0x00000100,
242*b843c749SSergey Zigachev 0xf08c, 0xffffffff, 0x00000100,
243*b843c749SSergey Zigachev 0xf08d, 0xffffffff, 0x00000100,
244*b843c749SSergey Zigachev 0xf094, 0xffffffff, 0x00000100,
245*b843c749SSergey Zigachev 0xf095, 0xffffffff, 0x00000100,
246*b843c749SSergey Zigachev 0xf096, 0xffffffff, 0x00000100,
247*b843c749SSergey Zigachev 0xf097, 0xffffffff, 0x00000100,
248*b843c749SSergey Zigachev 0xf098, 0xffffffff, 0x00000100,
249*b843c749SSergey Zigachev 0xf09f, 0xffffffff, 0x00000100,
250*b843c749SSergey Zigachev 0xf09e, 0xffffffff, 0x00000100,
251*b843c749SSergey Zigachev 0xf084, 0xffffffff, 0x06000100,
252*b843c749SSergey Zigachev 0xf0a4, 0xffffffff, 0x00000100,
253*b843c749SSergey Zigachev 0xf09d, 0xffffffff, 0x00000100,
254*b843c749SSergey Zigachev 0xf0ad, 0xffffffff, 0x00000100,
255*b843c749SSergey Zigachev 0xf0ac, 0xffffffff, 0x00000100,
256*b843c749SSergey Zigachev 0xf09c, 0xffffffff, 0x00000100,
257*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
258*b843c749SSergey Zigachev 0xf008, 0xffffffff, 0x00010000,
259*b843c749SSergey Zigachev 0xf009, 0xffffffff, 0x00030002,
260*b843c749SSergey Zigachev 0xf00a, 0xffffffff, 0x00040007,
261*b843c749SSergey Zigachev 0xf00b, 0xffffffff, 0x00060005,
262*b843c749SSergey Zigachev 0xf00c, 0xffffffff, 0x00090008,
263*b843c749SSergey Zigachev 0xf00d, 0xffffffff, 0x00010000,
264*b843c749SSergey Zigachev 0xf00e, 0xffffffff, 0x00030002,
265*b843c749SSergey Zigachev 0xf00f, 0xffffffff, 0x00040007,
266*b843c749SSergey Zigachev 0xf010, 0xffffffff, 0x00060005,
267*b843c749SSergey Zigachev 0xf011, 0xffffffff, 0x00090008,
268*b843c749SSergey Zigachev 0xf012, 0xffffffff, 0x00010000,
269*b843c749SSergey Zigachev 0xf013, 0xffffffff, 0x00030002,
270*b843c749SSergey Zigachev 0xf014, 0xffffffff, 0x00040007,
271*b843c749SSergey Zigachev 0xf015, 0xffffffff, 0x00060005,
272*b843c749SSergey Zigachev 0xf016, 0xffffffff, 0x00090008,
273*b843c749SSergey Zigachev 0xf017, 0xffffffff, 0x00010000,
274*b843c749SSergey Zigachev 0xf018, 0xffffffff, 0x00030002,
275*b843c749SSergey Zigachev 0xf019, 0xffffffff, 0x00040007,
276*b843c749SSergey Zigachev 0xf01a, 0xffffffff, 0x00060005,
277*b843c749SSergey Zigachev 0xf01b, 0xffffffff, 0x00090008,
278*b843c749SSergey Zigachev 0xf01c, 0xffffffff, 0x00010000,
279*b843c749SSergey Zigachev 0xf01d, 0xffffffff, 0x00030002,
280*b843c749SSergey Zigachev 0xf01e, 0xffffffff, 0x00040007,
281*b843c749SSergey Zigachev 0xf01f, 0xffffffff, 0x00060005,
282*b843c749SSergey Zigachev 0xf020, 0xffffffff, 0x00090008,
283*b843c749SSergey Zigachev 0xf021, 0xffffffff, 0x00010000,
284*b843c749SSergey Zigachev 0xf022, 0xffffffff, 0x00030002,
285*b843c749SSergey Zigachev 0xf023, 0xffffffff, 0x00040007,
286*b843c749SSergey Zigachev 0xf024, 0xffffffff, 0x00060005,
287*b843c749SSergey Zigachev 0xf025, 0xffffffff, 0x00090008,
288*b843c749SSergey Zigachev 0xf026, 0xffffffff, 0x00010000,
289*b843c749SSergey Zigachev 0xf027, 0xffffffff, 0x00030002,
290*b843c749SSergey Zigachev 0xf028, 0xffffffff, 0x00040007,
291*b843c749SSergey Zigachev 0xf029, 0xffffffff, 0x00060005,
292*b843c749SSergey Zigachev 0xf02a, 0xffffffff, 0x00090008,
293*b843c749SSergey Zigachev 0xf000, 0xffffffff, 0x96e00200,
294*b843c749SSergey Zigachev 0x21c2, 0xffffffff, 0x00900100,
295*b843c749SSergey Zigachev 0x3109, 0xffffffff, 0x0020003f,
296*b843c749SSergey Zigachev 0xe, 0xffffffff, 0x0140001c,
297*b843c749SSergey Zigachev 0xf, 0x000f0000, 0x000f0000,
298*b843c749SSergey Zigachev 0x88, 0xffffffff, 0xc060000c,
299*b843c749SSergey Zigachev 0x89, 0xc0000fff, 0x00000100,
300*b843c749SSergey Zigachev 0x3e4, 0xffffffff, 0x00000100,
301*b843c749SSergey Zigachev 0x3e6, 0x00000101, 0x00000000,
302*b843c749SSergey Zigachev 0x82a, 0xffffffff, 0x00000104,
303*b843c749SSergey Zigachev 0x1579, 0xff000fff, 0x00000100,
304*b843c749SSergey Zigachev 0xc33, 0xc0000fff, 0x00000104,
305*b843c749SSergey Zigachev 0x3079, 0x00000001, 0x00000001,
306*b843c749SSergey Zigachev 0x3403, 0xff000ff0, 0x00000100,
307*b843c749SSergey Zigachev 0x3603, 0xff000ff0, 0x00000100
308*b843c749SSergey Zigachev };
309*b843c749SSergey Zigachev
310*b843c749SSergey Zigachev static const u32 spectre_golden_spm_registers[] =
311*b843c749SSergey Zigachev {
312*b843c749SSergey Zigachev 0xc200, 0xe0ffffff, 0xe0000000
313*b843c749SSergey Zigachev };
314*b843c749SSergey Zigachev
315*b843c749SSergey Zigachev static const u32 spectre_golden_common_registers[] =
316*b843c749SSergey Zigachev {
317*b843c749SSergey Zigachev 0x31dc, 0xffffffff, 0x00000800,
318*b843c749SSergey Zigachev 0x31dd, 0xffffffff, 0x00000800,
319*b843c749SSergey Zigachev 0x31e6, 0xffffffff, 0x00007fbf,
320*b843c749SSergey Zigachev 0x31e7, 0xffffffff, 0x00007faf
321*b843c749SSergey Zigachev };
322*b843c749SSergey Zigachev
323*b843c749SSergey Zigachev static const u32 spectre_golden_registers[] =
324*b843c749SSergey Zigachev {
325*b843c749SSergey Zigachev 0xf000, 0xffff1fff, 0x96940200,
326*b843c749SSergey Zigachev 0xf003, 0xffff0001, 0xff000000,
327*b843c749SSergey Zigachev 0xf080, 0xfffc0fff, 0x00000100,
328*b843c749SSergey Zigachev 0x1bb6, 0x00010101, 0x00010000,
329*b843c749SSergey Zigachev 0x260d, 0xf00fffff, 0x00000400,
330*b843c749SSergey Zigachev 0x260e, 0xfffffffc, 0x00020200,
331*b843c749SSergey Zigachev 0x16ec, 0x000000f0, 0x00000070,
332*b843c749SSergey Zigachev 0x16f0, 0xf0311fff, 0x80300000,
333*b843c749SSergey Zigachev 0x263e, 0x73773777, 0x12010001,
334*b843c749SSergey Zigachev 0x26df, 0x00ff0000, 0x00fc0000,
335*b843c749SSergey Zigachev 0xbd2, 0x73773777, 0x12010001,
336*b843c749SSergey Zigachev 0x2285, 0xf000003f, 0x00000007,
337*b843c749SSergey Zigachev 0x22c9, 0xffffffff, 0x00ffffff,
338*b843c749SSergey Zigachev 0xa0d4, 0x3f3f3fff, 0x00000082,
339*b843c749SSergey Zigachev 0xa0d5, 0x0000003f, 0x00000000,
340*b843c749SSergey Zigachev 0xf9e, 0x00000001, 0x00000002,
341*b843c749SSergey Zigachev 0x244f, 0xffff03df, 0x00000004,
342*b843c749SSergey Zigachev 0x31da, 0x00000008, 0x00000008,
343*b843c749SSergey Zigachev 0x2300, 0x000008ff, 0x00000800,
344*b843c749SSergey Zigachev 0x2542, 0x00010000, 0x00010000,
345*b843c749SSergey Zigachev 0x2b03, 0xffffffff, 0x54763210,
346*b843c749SSergey Zigachev 0x853e, 0x01ff01ff, 0x00000002,
347*b843c749SSergey Zigachev 0x8526, 0x007ff800, 0x00200000,
348*b843c749SSergey Zigachev 0x8057, 0xffffffff, 0x00000f40,
349*b843c749SSergey Zigachev 0xc24d, 0xffffffff, 0x00000001
350*b843c749SSergey Zigachev };
351*b843c749SSergey Zigachev
352*b843c749SSergey Zigachev static const u32 spectre_mgcg_cgcg_init[] =
353*b843c749SSergey Zigachev {
354*b843c749SSergey Zigachev 0x3108, 0xffffffff, 0xfffffffc,
355*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
356*b843c749SSergey Zigachev 0xf0a8, 0xffffffff, 0x00000100,
357*b843c749SSergey Zigachev 0xf082, 0xffffffff, 0x00000100,
358*b843c749SSergey Zigachev 0xf0b0, 0xffffffff, 0x00000100,
359*b843c749SSergey Zigachev 0xf0b2, 0xffffffff, 0x00000100,
360*b843c749SSergey Zigachev 0xf0b1, 0xffffffff, 0x00000100,
361*b843c749SSergey Zigachev 0x1579, 0xffffffff, 0x00600100,
362*b843c749SSergey Zigachev 0xf0a0, 0xffffffff, 0x00000100,
363*b843c749SSergey Zigachev 0xf085, 0xffffffff, 0x06000100,
364*b843c749SSergey Zigachev 0xf088, 0xffffffff, 0x00000100,
365*b843c749SSergey Zigachev 0xf086, 0xffffffff, 0x06000100,
366*b843c749SSergey Zigachev 0xf081, 0xffffffff, 0x00000100,
367*b843c749SSergey Zigachev 0xf0b8, 0xffffffff, 0x00000100,
368*b843c749SSergey Zigachev 0xf089, 0xffffffff, 0x00000100,
369*b843c749SSergey Zigachev 0xf080, 0xffffffff, 0x00000100,
370*b843c749SSergey Zigachev 0xf08c, 0xffffffff, 0x00000100,
371*b843c749SSergey Zigachev 0xf08d, 0xffffffff, 0x00000100,
372*b843c749SSergey Zigachev 0xf094, 0xffffffff, 0x00000100,
373*b843c749SSergey Zigachev 0xf095, 0xffffffff, 0x00000100,
374*b843c749SSergey Zigachev 0xf096, 0xffffffff, 0x00000100,
375*b843c749SSergey Zigachev 0xf097, 0xffffffff, 0x00000100,
376*b843c749SSergey Zigachev 0xf098, 0xffffffff, 0x00000100,
377*b843c749SSergey Zigachev 0xf09f, 0xffffffff, 0x00000100,
378*b843c749SSergey Zigachev 0xf09e, 0xffffffff, 0x00000100,
379*b843c749SSergey Zigachev 0xf084, 0xffffffff, 0x06000100,
380*b843c749SSergey Zigachev 0xf0a4, 0xffffffff, 0x00000100,
381*b843c749SSergey Zigachev 0xf09d, 0xffffffff, 0x00000100,
382*b843c749SSergey Zigachev 0xf0ad, 0xffffffff, 0x00000100,
383*b843c749SSergey Zigachev 0xf0ac, 0xffffffff, 0x00000100,
384*b843c749SSergey Zigachev 0xf09c, 0xffffffff, 0x00000100,
385*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
386*b843c749SSergey Zigachev 0xf008, 0xffffffff, 0x00010000,
387*b843c749SSergey Zigachev 0xf009, 0xffffffff, 0x00030002,
388*b843c749SSergey Zigachev 0xf00a, 0xffffffff, 0x00040007,
389*b843c749SSergey Zigachev 0xf00b, 0xffffffff, 0x00060005,
390*b843c749SSergey Zigachev 0xf00c, 0xffffffff, 0x00090008,
391*b843c749SSergey Zigachev 0xf00d, 0xffffffff, 0x00010000,
392*b843c749SSergey Zigachev 0xf00e, 0xffffffff, 0x00030002,
393*b843c749SSergey Zigachev 0xf00f, 0xffffffff, 0x00040007,
394*b843c749SSergey Zigachev 0xf010, 0xffffffff, 0x00060005,
395*b843c749SSergey Zigachev 0xf011, 0xffffffff, 0x00090008,
396*b843c749SSergey Zigachev 0xf012, 0xffffffff, 0x00010000,
397*b843c749SSergey Zigachev 0xf013, 0xffffffff, 0x00030002,
398*b843c749SSergey Zigachev 0xf014, 0xffffffff, 0x00040007,
399*b843c749SSergey Zigachev 0xf015, 0xffffffff, 0x00060005,
400*b843c749SSergey Zigachev 0xf016, 0xffffffff, 0x00090008,
401*b843c749SSergey Zigachev 0xf017, 0xffffffff, 0x00010000,
402*b843c749SSergey Zigachev 0xf018, 0xffffffff, 0x00030002,
403*b843c749SSergey Zigachev 0xf019, 0xffffffff, 0x00040007,
404*b843c749SSergey Zigachev 0xf01a, 0xffffffff, 0x00060005,
405*b843c749SSergey Zigachev 0xf01b, 0xffffffff, 0x00090008,
406*b843c749SSergey Zigachev 0xf01c, 0xffffffff, 0x00010000,
407*b843c749SSergey Zigachev 0xf01d, 0xffffffff, 0x00030002,
408*b843c749SSergey Zigachev 0xf01e, 0xffffffff, 0x00040007,
409*b843c749SSergey Zigachev 0xf01f, 0xffffffff, 0x00060005,
410*b843c749SSergey Zigachev 0xf020, 0xffffffff, 0x00090008,
411*b843c749SSergey Zigachev 0xf021, 0xffffffff, 0x00010000,
412*b843c749SSergey Zigachev 0xf022, 0xffffffff, 0x00030002,
413*b843c749SSergey Zigachev 0xf023, 0xffffffff, 0x00040007,
414*b843c749SSergey Zigachev 0xf024, 0xffffffff, 0x00060005,
415*b843c749SSergey Zigachev 0xf025, 0xffffffff, 0x00090008,
416*b843c749SSergey Zigachev 0xf026, 0xffffffff, 0x00010000,
417*b843c749SSergey Zigachev 0xf027, 0xffffffff, 0x00030002,
418*b843c749SSergey Zigachev 0xf028, 0xffffffff, 0x00040007,
419*b843c749SSergey Zigachev 0xf029, 0xffffffff, 0x00060005,
420*b843c749SSergey Zigachev 0xf02a, 0xffffffff, 0x00090008,
421*b843c749SSergey Zigachev 0xf02b, 0xffffffff, 0x00010000,
422*b843c749SSergey Zigachev 0xf02c, 0xffffffff, 0x00030002,
423*b843c749SSergey Zigachev 0xf02d, 0xffffffff, 0x00040007,
424*b843c749SSergey Zigachev 0xf02e, 0xffffffff, 0x00060005,
425*b843c749SSergey Zigachev 0xf02f, 0xffffffff, 0x00090008,
426*b843c749SSergey Zigachev 0xf000, 0xffffffff, 0x96e00200,
427*b843c749SSergey Zigachev 0x21c2, 0xffffffff, 0x00900100,
428*b843c749SSergey Zigachev 0x3109, 0xffffffff, 0x0020003f,
429*b843c749SSergey Zigachev 0xe, 0xffffffff, 0x0140001c,
430*b843c749SSergey Zigachev 0xf, 0x000f0000, 0x000f0000,
431*b843c749SSergey Zigachev 0x88, 0xffffffff, 0xc060000c,
432*b843c749SSergey Zigachev 0x89, 0xc0000fff, 0x00000100,
433*b843c749SSergey Zigachev 0x3e4, 0xffffffff, 0x00000100,
434*b843c749SSergey Zigachev 0x3e6, 0x00000101, 0x00000000,
435*b843c749SSergey Zigachev 0x82a, 0xffffffff, 0x00000104,
436*b843c749SSergey Zigachev 0x1579, 0xff000fff, 0x00000100,
437*b843c749SSergey Zigachev 0xc33, 0xc0000fff, 0x00000104,
438*b843c749SSergey Zigachev 0x3079, 0x00000001, 0x00000001,
439*b843c749SSergey Zigachev 0x3403, 0xff000ff0, 0x00000100,
440*b843c749SSergey Zigachev 0x3603, 0xff000ff0, 0x00000100
441*b843c749SSergey Zigachev };
442*b843c749SSergey Zigachev
443*b843c749SSergey Zigachev static const u32 kalindi_golden_spm_registers[] =
444*b843c749SSergey Zigachev {
445*b843c749SSergey Zigachev 0xc200, 0xe0ffffff, 0xe0000000
446*b843c749SSergey Zigachev };
447*b843c749SSergey Zigachev
448*b843c749SSergey Zigachev static const u32 kalindi_golden_common_registers[] =
449*b843c749SSergey Zigachev {
450*b843c749SSergey Zigachev 0x31dc, 0xffffffff, 0x00000800,
451*b843c749SSergey Zigachev 0x31dd, 0xffffffff, 0x00000800,
452*b843c749SSergey Zigachev 0x31e6, 0xffffffff, 0x00007fbf,
453*b843c749SSergey Zigachev 0x31e7, 0xffffffff, 0x00007faf
454*b843c749SSergey Zigachev };
455*b843c749SSergey Zigachev
456*b843c749SSergey Zigachev static const u32 kalindi_golden_registers[] =
457*b843c749SSergey Zigachev {
458*b843c749SSergey Zigachev 0xf000, 0xffffdfff, 0x6e944040,
459*b843c749SSergey Zigachev 0x1579, 0xff607fff, 0xfc000100,
460*b843c749SSergey Zigachev 0xf088, 0xff000fff, 0x00000100,
461*b843c749SSergey Zigachev 0xf089, 0xff000fff, 0x00000100,
462*b843c749SSergey Zigachev 0xf080, 0xfffc0fff, 0x00000100,
463*b843c749SSergey Zigachev 0x1bb6, 0x00010101, 0x00010000,
464*b843c749SSergey Zigachev 0x260c, 0xffffffff, 0x00000000,
465*b843c749SSergey Zigachev 0x260d, 0xf00fffff, 0x00000400,
466*b843c749SSergey Zigachev 0x16ec, 0x000000f0, 0x00000070,
467*b843c749SSergey Zigachev 0x16f0, 0xf0311fff, 0x80300000,
468*b843c749SSergey Zigachev 0x263e, 0x73773777, 0x12010001,
469*b843c749SSergey Zigachev 0x263f, 0xffffffff, 0x00000010,
470*b843c749SSergey Zigachev 0x26df, 0x00ff0000, 0x00fc0000,
471*b843c749SSergey Zigachev 0x200c, 0x00001f0f, 0x0000100a,
472*b843c749SSergey Zigachev 0xbd2, 0x73773777, 0x12010001,
473*b843c749SSergey Zigachev 0x902, 0x000fffff, 0x000c007f,
474*b843c749SSergey Zigachev 0x2285, 0xf000003f, 0x00000007,
475*b843c749SSergey Zigachev 0x22c9, 0x3fff3fff, 0x00ffcfff,
476*b843c749SSergey Zigachev 0xc281, 0x0000ff0f, 0x00000000,
477*b843c749SSergey Zigachev 0xa293, 0x07ffffff, 0x06000000,
478*b843c749SSergey Zigachev 0x136, 0x00000fff, 0x00000100,
479*b843c749SSergey Zigachev 0xf9e, 0x00000001, 0x00000002,
480*b843c749SSergey Zigachev 0x31da, 0x00000008, 0x00000008,
481*b843c749SSergey Zigachev 0x2300, 0x000000ff, 0x00000003,
482*b843c749SSergey Zigachev 0x853e, 0x01ff01ff, 0x00000002,
483*b843c749SSergey Zigachev 0x8526, 0x007ff800, 0x00200000,
484*b843c749SSergey Zigachev 0x8057, 0xffffffff, 0x00000f40,
485*b843c749SSergey Zigachev 0x2231, 0x001f3ae3, 0x00000082,
486*b843c749SSergey Zigachev 0x2235, 0x0000001f, 0x00000010,
487*b843c749SSergey Zigachev 0xc24d, 0xffffffff, 0x00000000
488*b843c749SSergey Zigachev };
489*b843c749SSergey Zigachev
490*b843c749SSergey Zigachev static const u32 kalindi_mgcg_cgcg_init[] =
491*b843c749SSergey Zigachev {
492*b843c749SSergey Zigachev 0x3108, 0xffffffff, 0xfffffffc,
493*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
494*b843c749SSergey Zigachev 0xf0a8, 0xffffffff, 0x00000100,
495*b843c749SSergey Zigachev 0xf082, 0xffffffff, 0x00000100,
496*b843c749SSergey Zigachev 0xf0b0, 0xffffffff, 0x00000100,
497*b843c749SSergey Zigachev 0xf0b2, 0xffffffff, 0x00000100,
498*b843c749SSergey Zigachev 0xf0b1, 0xffffffff, 0x00000100,
499*b843c749SSergey Zigachev 0x1579, 0xffffffff, 0x00600100,
500*b843c749SSergey Zigachev 0xf0a0, 0xffffffff, 0x00000100,
501*b843c749SSergey Zigachev 0xf085, 0xffffffff, 0x06000100,
502*b843c749SSergey Zigachev 0xf088, 0xffffffff, 0x00000100,
503*b843c749SSergey Zigachev 0xf086, 0xffffffff, 0x06000100,
504*b843c749SSergey Zigachev 0xf081, 0xffffffff, 0x00000100,
505*b843c749SSergey Zigachev 0xf0b8, 0xffffffff, 0x00000100,
506*b843c749SSergey Zigachev 0xf089, 0xffffffff, 0x00000100,
507*b843c749SSergey Zigachev 0xf080, 0xffffffff, 0x00000100,
508*b843c749SSergey Zigachev 0xf08c, 0xffffffff, 0x00000100,
509*b843c749SSergey Zigachev 0xf08d, 0xffffffff, 0x00000100,
510*b843c749SSergey Zigachev 0xf094, 0xffffffff, 0x00000100,
511*b843c749SSergey Zigachev 0xf095, 0xffffffff, 0x00000100,
512*b843c749SSergey Zigachev 0xf096, 0xffffffff, 0x00000100,
513*b843c749SSergey Zigachev 0xf097, 0xffffffff, 0x00000100,
514*b843c749SSergey Zigachev 0xf098, 0xffffffff, 0x00000100,
515*b843c749SSergey Zigachev 0xf09f, 0xffffffff, 0x00000100,
516*b843c749SSergey Zigachev 0xf09e, 0xffffffff, 0x00000100,
517*b843c749SSergey Zigachev 0xf084, 0xffffffff, 0x06000100,
518*b843c749SSergey Zigachev 0xf0a4, 0xffffffff, 0x00000100,
519*b843c749SSergey Zigachev 0xf09d, 0xffffffff, 0x00000100,
520*b843c749SSergey Zigachev 0xf0ad, 0xffffffff, 0x00000100,
521*b843c749SSergey Zigachev 0xf0ac, 0xffffffff, 0x00000100,
522*b843c749SSergey Zigachev 0xf09c, 0xffffffff, 0x00000100,
523*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
524*b843c749SSergey Zigachev 0xf008, 0xffffffff, 0x00010000,
525*b843c749SSergey Zigachev 0xf009, 0xffffffff, 0x00030002,
526*b843c749SSergey Zigachev 0xf00a, 0xffffffff, 0x00040007,
527*b843c749SSergey Zigachev 0xf00b, 0xffffffff, 0x00060005,
528*b843c749SSergey Zigachev 0xf00c, 0xffffffff, 0x00090008,
529*b843c749SSergey Zigachev 0xf00d, 0xffffffff, 0x00010000,
530*b843c749SSergey Zigachev 0xf00e, 0xffffffff, 0x00030002,
531*b843c749SSergey Zigachev 0xf00f, 0xffffffff, 0x00040007,
532*b843c749SSergey Zigachev 0xf010, 0xffffffff, 0x00060005,
533*b843c749SSergey Zigachev 0xf011, 0xffffffff, 0x00090008,
534*b843c749SSergey Zigachev 0xf000, 0xffffffff, 0x96e00200,
535*b843c749SSergey Zigachev 0x21c2, 0xffffffff, 0x00900100,
536*b843c749SSergey Zigachev 0x3109, 0xffffffff, 0x0020003f,
537*b843c749SSergey Zigachev 0xe, 0xffffffff, 0x0140001c,
538*b843c749SSergey Zigachev 0xf, 0x000f0000, 0x000f0000,
539*b843c749SSergey Zigachev 0x88, 0xffffffff, 0xc060000c,
540*b843c749SSergey Zigachev 0x89, 0xc0000fff, 0x00000100,
541*b843c749SSergey Zigachev 0x82a, 0xffffffff, 0x00000104,
542*b843c749SSergey Zigachev 0x1579, 0xff000fff, 0x00000100,
543*b843c749SSergey Zigachev 0xc33, 0xc0000fff, 0x00000104,
544*b843c749SSergey Zigachev 0x3079, 0x00000001, 0x00000001,
545*b843c749SSergey Zigachev 0x3403, 0xff000ff0, 0x00000100,
546*b843c749SSergey Zigachev 0x3603, 0xff000ff0, 0x00000100
547*b843c749SSergey Zigachev };
548*b843c749SSergey Zigachev
549*b843c749SSergey Zigachev static const u32 hawaii_golden_spm_registers[] =
550*b843c749SSergey Zigachev {
551*b843c749SSergey Zigachev 0xc200, 0xe0ffffff, 0xe0000000
552*b843c749SSergey Zigachev };
553*b843c749SSergey Zigachev
554*b843c749SSergey Zigachev static const u32 hawaii_golden_common_registers[] =
555*b843c749SSergey Zigachev {
556*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
557*b843c749SSergey Zigachev 0xa0d4, 0xffffffff, 0x3a00161a,
558*b843c749SSergey Zigachev 0xa0d5, 0xffffffff, 0x0000002e,
559*b843c749SSergey Zigachev 0x2684, 0xffffffff, 0x00018208,
560*b843c749SSergey Zigachev 0x263e, 0xffffffff, 0x12011003
561*b843c749SSergey Zigachev };
562*b843c749SSergey Zigachev
563*b843c749SSergey Zigachev static const u32 hawaii_golden_registers[] =
564*b843c749SSergey Zigachev {
565*b843c749SSergey Zigachev 0xcd5, 0x00000333, 0x00000333,
566*b843c749SSergey Zigachev 0x2684, 0x00010000, 0x00058208,
567*b843c749SSergey Zigachev 0x260c, 0xffffffff, 0x00000000,
568*b843c749SSergey Zigachev 0x260d, 0xf00fffff, 0x00000400,
569*b843c749SSergey Zigachev 0x260e, 0x0002021c, 0x00020200,
570*b843c749SSergey Zigachev 0x31e, 0x00000080, 0x00000000,
571*b843c749SSergey Zigachev 0x16ec, 0x000000f0, 0x00000070,
572*b843c749SSergey Zigachev 0x16f0, 0xf0311fff, 0x80300000,
573*b843c749SSergey Zigachev 0xd43, 0x00810000, 0x408af000,
574*b843c749SSergey Zigachev 0x1c0c, 0x31000111, 0x00000011,
575*b843c749SSergey Zigachev 0xbd2, 0x73773777, 0x12010001,
576*b843c749SSergey Zigachev 0x848, 0x0000007f, 0x0000001b,
577*b843c749SSergey Zigachev 0x877, 0x00007fb6, 0x00002191,
578*b843c749SSergey Zigachev 0xd8a, 0x0000003f, 0x0000000a,
579*b843c749SSergey Zigachev 0xd8b, 0x0000003f, 0x0000000a,
580*b843c749SSergey Zigachev 0xab9, 0x00073ffe, 0x000022a2,
581*b843c749SSergey Zigachev 0x903, 0x000007ff, 0x00000000,
582*b843c749SSergey Zigachev 0x22fc, 0x00002001, 0x00000001,
583*b843c749SSergey Zigachev 0x22c9, 0xffffffff, 0x00ffffff,
584*b843c749SSergey Zigachev 0xc281, 0x0000ff0f, 0x00000000,
585*b843c749SSergey Zigachev 0xa293, 0x07ffffff, 0x06000000,
586*b843c749SSergey Zigachev 0xf9e, 0x00000001, 0x00000002,
587*b843c749SSergey Zigachev 0x31da, 0x00000008, 0x00000008,
588*b843c749SSergey Zigachev 0x31dc, 0x00000f00, 0x00000800,
589*b843c749SSergey Zigachev 0x31dd, 0x00000f00, 0x00000800,
590*b843c749SSergey Zigachev 0x31e6, 0x00ffffff, 0x00ff7fbf,
591*b843c749SSergey Zigachev 0x31e7, 0x00ffffff, 0x00ff7faf,
592*b843c749SSergey Zigachev 0x2300, 0x000000ff, 0x00000800,
593*b843c749SSergey Zigachev 0x390, 0x00001fff, 0x00001fff,
594*b843c749SSergey Zigachev 0x2418, 0x0000007f, 0x00000020,
595*b843c749SSergey Zigachev 0x2542, 0x00010000, 0x00010000,
596*b843c749SSergey Zigachev 0x2b80, 0x00100000, 0x000ff07c,
597*b843c749SSergey Zigachev 0x2b05, 0x000003ff, 0x0000000f,
598*b843c749SSergey Zigachev 0x2b04, 0xffffffff, 0x7564fdec,
599*b843c749SSergey Zigachev 0x2b03, 0xffffffff, 0x3120b9a8,
600*b843c749SSergey Zigachev 0x2b02, 0x20000000, 0x0f9c0000
601*b843c749SSergey Zigachev };
602*b843c749SSergey Zigachev
603*b843c749SSergey Zigachev static const u32 hawaii_mgcg_cgcg_init[] =
604*b843c749SSergey Zigachev {
605*b843c749SSergey Zigachev 0x3108, 0xffffffff, 0xfffffffd,
606*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
607*b843c749SSergey Zigachev 0xf0a8, 0xffffffff, 0x00000100,
608*b843c749SSergey Zigachev 0xf082, 0xffffffff, 0x00000100,
609*b843c749SSergey Zigachev 0xf0b0, 0xffffffff, 0x00000100,
610*b843c749SSergey Zigachev 0xf0b2, 0xffffffff, 0x00000100,
611*b843c749SSergey Zigachev 0xf0b1, 0xffffffff, 0x00000100,
612*b843c749SSergey Zigachev 0x1579, 0xffffffff, 0x00200100,
613*b843c749SSergey Zigachev 0xf0a0, 0xffffffff, 0x00000100,
614*b843c749SSergey Zigachev 0xf085, 0xffffffff, 0x06000100,
615*b843c749SSergey Zigachev 0xf088, 0xffffffff, 0x00000100,
616*b843c749SSergey Zigachev 0xf086, 0xffffffff, 0x06000100,
617*b843c749SSergey Zigachev 0xf081, 0xffffffff, 0x00000100,
618*b843c749SSergey Zigachev 0xf0b8, 0xffffffff, 0x00000100,
619*b843c749SSergey Zigachev 0xf089, 0xffffffff, 0x00000100,
620*b843c749SSergey Zigachev 0xf080, 0xffffffff, 0x00000100,
621*b843c749SSergey Zigachev 0xf08c, 0xffffffff, 0x00000100,
622*b843c749SSergey Zigachev 0xf08d, 0xffffffff, 0x00000100,
623*b843c749SSergey Zigachev 0xf094, 0xffffffff, 0x00000100,
624*b843c749SSergey Zigachev 0xf095, 0xffffffff, 0x00000100,
625*b843c749SSergey Zigachev 0xf096, 0xffffffff, 0x00000100,
626*b843c749SSergey Zigachev 0xf097, 0xffffffff, 0x00000100,
627*b843c749SSergey Zigachev 0xf098, 0xffffffff, 0x00000100,
628*b843c749SSergey Zigachev 0xf09f, 0xffffffff, 0x00000100,
629*b843c749SSergey Zigachev 0xf09e, 0xffffffff, 0x00000100,
630*b843c749SSergey Zigachev 0xf084, 0xffffffff, 0x06000100,
631*b843c749SSergey Zigachev 0xf0a4, 0xffffffff, 0x00000100,
632*b843c749SSergey Zigachev 0xf09d, 0xffffffff, 0x00000100,
633*b843c749SSergey Zigachev 0xf0ad, 0xffffffff, 0x00000100,
634*b843c749SSergey Zigachev 0xf0ac, 0xffffffff, 0x00000100,
635*b843c749SSergey Zigachev 0xf09c, 0xffffffff, 0x00000100,
636*b843c749SSergey Zigachev 0xc200, 0xffffffff, 0xe0000000,
637*b843c749SSergey Zigachev 0xf008, 0xffffffff, 0x00010000,
638*b843c749SSergey Zigachev 0xf009, 0xffffffff, 0x00030002,
639*b843c749SSergey Zigachev 0xf00a, 0xffffffff, 0x00040007,
640*b843c749SSergey Zigachev 0xf00b, 0xffffffff, 0x00060005,
641*b843c749SSergey Zigachev 0xf00c, 0xffffffff, 0x00090008,
642*b843c749SSergey Zigachev 0xf00d, 0xffffffff, 0x00010000,
643*b843c749SSergey Zigachev 0xf00e, 0xffffffff, 0x00030002,
644*b843c749SSergey Zigachev 0xf00f, 0xffffffff, 0x00040007,
645*b843c749SSergey Zigachev 0xf010, 0xffffffff, 0x00060005,
646*b843c749SSergey Zigachev 0xf011, 0xffffffff, 0x00090008,
647*b843c749SSergey Zigachev 0xf012, 0xffffffff, 0x00010000,
648*b843c749SSergey Zigachev 0xf013, 0xffffffff, 0x00030002,
649*b843c749SSergey Zigachev 0xf014, 0xffffffff, 0x00040007,
650*b843c749SSergey Zigachev 0xf015, 0xffffffff, 0x00060005,
651*b843c749SSergey Zigachev 0xf016, 0xffffffff, 0x00090008,
652*b843c749SSergey Zigachev 0xf017, 0xffffffff, 0x00010000,
653*b843c749SSergey Zigachev 0xf018, 0xffffffff, 0x00030002,
654*b843c749SSergey Zigachev 0xf019, 0xffffffff, 0x00040007,
655*b843c749SSergey Zigachev 0xf01a, 0xffffffff, 0x00060005,
656*b843c749SSergey Zigachev 0xf01b, 0xffffffff, 0x00090008,
657*b843c749SSergey Zigachev 0xf01c, 0xffffffff, 0x00010000,
658*b843c749SSergey Zigachev 0xf01d, 0xffffffff, 0x00030002,
659*b843c749SSergey Zigachev 0xf01e, 0xffffffff, 0x00040007,
660*b843c749SSergey Zigachev 0xf01f, 0xffffffff, 0x00060005,
661*b843c749SSergey Zigachev 0xf020, 0xffffffff, 0x00090008,
662*b843c749SSergey Zigachev 0xf021, 0xffffffff, 0x00010000,
663*b843c749SSergey Zigachev 0xf022, 0xffffffff, 0x00030002,
664*b843c749SSergey Zigachev 0xf023, 0xffffffff, 0x00040007,
665*b843c749SSergey Zigachev 0xf024, 0xffffffff, 0x00060005,
666*b843c749SSergey Zigachev 0xf025, 0xffffffff, 0x00090008,
667*b843c749SSergey Zigachev 0xf026, 0xffffffff, 0x00010000,
668*b843c749SSergey Zigachev 0xf027, 0xffffffff, 0x00030002,
669*b843c749SSergey Zigachev 0xf028, 0xffffffff, 0x00040007,
670*b843c749SSergey Zigachev 0xf029, 0xffffffff, 0x00060005,
671*b843c749SSergey Zigachev 0xf02a, 0xffffffff, 0x00090008,
672*b843c749SSergey Zigachev 0xf02b, 0xffffffff, 0x00010000,
673*b843c749SSergey Zigachev 0xf02c, 0xffffffff, 0x00030002,
674*b843c749SSergey Zigachev 0xf02d, 0xffffffff, 0x00040007,
675*b843c749SSergey Zigachev 0xf02e, 0xffffffff, 0x00060005,
676*b843c749SSergey Zigachev 0xf02f, 0xffffffff, 0x00090008,
677*b843c749SSergey Zigachev 0xf030, 0xffffffff, 0x00010000,
678*b843c749SSergey Zigachev 0xf031, 0xffffffff, 0x00030002,
679*b843c749SSergey Zigachev 0xf032, 0xffffffff, 0x00040007,
680*b843c749SSergey Zigachev 0xf033, 0xffffffff, 0x00060005,
681*b843c749SSergey Zigachev 0xf034, 0xffffffff, 0x00090008,
682*b843c749SSergey Zigachev 0xf035, 0xffffffff, 0x00010000,
683*b843c749SSergey Zigachev 0xf036, 0xffffffff, 0x00030002,
684*b843c749SSergey Zigachev 0xf037, 0xffffffff, 0x00040007,
685*b843c749SSergey Zigachev 0xf038, 0xffffffff, 0x00060005,
686*b843c749SSergey Zigachev 0xf039, 0xffffffff, 0x00090008,
687*b843c749SSergey Zigachev 0xf03a, 0xffffffff, 0x00010000,
688*b843c749SSergey Zigachev 0xf03b, 0xffffffff, 0x00030002,
689*b843c749SSergey Zigachev 0xf03c, 0xffffffff, 0x00040007,
690*b843c749SSergey Zigachev 0xf03d, 0xffffffff, 0x00060005,
691*b843c749SSergey Zigachev 0xf03e, 0xffffffff, 0x00090008,
692*b843c749SSergey Zigachev 0x30c6, 0xffffffff, 0x00020200,
693*b843c749SSergey Zigachev 0xcd4, 0xffffffff, 0x00000200,
694*b843c749SSergey Zigachev 0x570, 0xffffffff, 0x00000400,
695*b843c749SSergey Zigachev 0x157a, 0xffffffff, 0x00000000,
696*b843c749SSergey Zigachev 0xbd4, 0xffffffff, 0x00000902,
697*b843c749SSergey Zigachev 0xf000, 0xffffffff, 0x96940200,
698*b843c749SSergey Zigachev 0x21c2, 0xffffffff, 0x00900100,
699*b843c749SSergey Zigachev 0x3109, 0xffffffff, 0x0020003f,
700*b843c749SSergey Zigachev 0xe, 0xffffffff, 0x0140001c,
701*b843c749SSergey Zigachev 0xf, 0x000f0000, 0x000f0000,
702*b843c749SSergey Zigachev 0x88, 0xffffffff, 0xc060000c,
703*b843c749SSergey Zigachev 0x89, 0xc0000fff, 0x00000100,
704*b843c749SSergey Zigachev 0x3e4, 0xffffffff, 0x00000100,
705*b843c749SSergey Zigachev 0x3e6, 0x00000101, 0x00000000,
706*b843c749SSergey Zigachev 0x82a, 0xffffffff, 0x00000104,
707*b843c749SSergey Zigachev 0x1579, 0xff000fff, 0x00000100,
708*b843c749SSergey Zigachev 0xc33, 0xc0000fff, 0x00000104,
709*b843c749SSergey Zigachev 0x3079, 0x00000001, 0x00000001,
710*b843c749SSergey Zigachev 0x3403, 0xff000ff0, 0x00000100,
711*b843c749SSergey Zigachev 0x3603, 0xff000ff0, 0x00000100
712*b843c749SSergey Zigachev };
713*b843c749SSergey Zigachev
714*b843c749SSergey Zigachev static const u32 godavari_golden_registers[] =
715*b843c749SSergey Zigachev {
716*b843c749SSergey Zigachev 0x1579, 0xff607fff, 0xfc000100,
717*b843c749SSergey Zigachev 0x1bb6, 0x00010101, 0x00010000,
718*b843c749SSergey Zigachev 0x260c, 0xffffffff, 0x00000000,
719*b843c749SSergey Zigachev 0x260c0, 0xf00fffff, 0x00000400,
720*b843c749SSergey Zigachev 0x184c, 0xffffffff, 0x00010000,
721*b843c749SSergey Zigachev 0x16ec, 0x000000f0, 0x00000070,
722*b843c749SSergey Zigachev 0x16f0, 0xf0311fff, 0x80300000,
723*b843c749SSergey Zigachev 0x263e, 0x73773777, 0x12010001,
724*b843c749SSergey Zigachev 0x263f, 0xffffffff, 0x00000010,
725*b843c749SSergey Zigachev 0x200c, 0x00001f0f, 0x0000100a,
726*b843c749SSergey Zigachev 0xbd2, 0x73773777, 0x12010001,
727*b843c749SSergey Zigachev 0x902, 0x000fffff, 0x000c007f,
728*b843c749SSergey Zigachev 0x2285, 0xf000003f, 0x00000007,
729*b843c749SSergey Zigachev 0x22c9, 0xffffffff, 0x00ff0fff,
730*b843c749SSergey Zigachev 0xc281, 0x0000ff0f, 0x00000000,
731*b843c749SSergey Zigachev 0xa293, 0x07ffffff, 0x06000000,
732*b843c749SSergey Zigachev 0x136, 0x00000fff, 0x00000100,
733*b843c749SSergey Zigachev 0x3405, 0x00010000, 0x00810001,
734*b843c749SSergey Zigachev 0x3605, 0x00010000, 0x00810001,
735*b843c749SSergey Zigachev 0xf9e, 0x00000001, 0x00000002,
736*b843c749SSergey Zigachev 0x31da, 0x00000008, 0x00000008,
737*b843c749SSergey Zigachev 0x31dc, 0x00000f00, 0x00000800,
738*b843c749SSergey Zigachev 0x31dd, 0x00000f00, 0x00000800,
739*b843c749SSergey Zigachev 0x31e6, 0x00ffffff, 0x00ff7fbf,
740*b843c749SSergey Zigachev 0x31e7, 0x00ffffff, 0x00ff7faf,
741*b843c749SSergey Zigachev 0x2300, 0x000000ff, 0x00000001,
742*b843c749SSergey Zigachev 0x853e, 0x01ff01ff, 0x00000002,
743*b843c749SSergey Zigachev 0x8526, 0x007ff800, 0x00200000,
744*b843c749SSergey Zigachev 0x8057, 0xffffffff, 0x00000f40,
745*b843c749SSergey Zigachev 0x2231, 0x001f3ae3, 0x00000082,
746*b843c749SSergey Zigachev 0x2235, 0x0000001f, 0x00000010,
747*b843c749SSergey Zigachev 0xc24d, 0xffffffff, 0x00000000
748*b843c749SSergey Zigachev };
749*b843c749SSergey Zigachev
cik_init_golden_registers(struct amdgpu_device * adev)750*b843c749SSergey Zigachev static void cik_init_golden_registers(struct amdgpu_device *adev)
751*b843c749SSergey Zigachev {
752*b843c749SSergey Zigachev /* Some of the registers might be dependent on GRBM_GFX_INDEX */
753*b843c749SSergey Zigachev mutex_lock(&adev->grbm_idx_mutex);
754*b843c749SSergey Zigachev
755*b843c749SSergey Zigachev switch (adev->asic_type) {
756*b843c749SSergey Zigachev case CHIP_BONAIRE:
757*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
758*b843c749SSergey Zigachev bonaire_mgcg_cgcg_init,
759*b843c749SSergey Zigachev ARRAY_SIZE(bonaire_mgcg_cgcg_init));
760*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
761*b843c749SSergey Zigachev bonaire_golden_registers,
762*b843c749SSergey Zigachev ARRAY_SIZE(bonaire_golden_registers));
763*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
764*b843c749SSergey Zigachev bonaire_golden_common_registers,
765*b843c749SSergey Zigachev ARRAY_SIZE(bonaire_golden_common_registers));
766*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
767*b843c749SSergey Zigachev bonaire_golden_spm_registers,
768*b843c749SSergey Zigachev ARRAY_SIZE(bonaire_golden_spm_registers));
769*b843c749SSergey Zigachev break;
770*b843c749SSergey Zigachev case CHIP_KABINI:
771*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
772*b843c749SSergey Zigachev kalindi_mgcg_cgcg_init,
773*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_mgcg_cgcg_init));
774*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
775*b843c749SSergey Zigachev kalindi_golden_registers,
776*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_golden_registers));
777*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
778*b843c749SSergey Zigachev kalindi_golden_common_registers,
779*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_golden_common_registers));
780*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
781*b843c749SSergey Zigachev kalindi_golden_spm_registers,
782*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_golden_spm_registers));
783*b843c749SSergey Zigachev break;
784*b843c749SSergey Zigachev case CHIP_MULLINS:
785*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
786*b843c749SSergey Zigachev kalindi_mgcg_cgcg_init,
787*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_mgcg_cgcg_init));
788*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
789*b843c749SSergey Zigachev godavari_golden_registers,
790*b843c749SSergey Zigachev ARRAY_SIZE(godavari_golden_registers));
791*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
792*b843c749SSergey Zigachev kalindi_golden_common_registers,
793*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_golden_common_registers));
794*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
795*b843c749SSergey Zigachev kalindi_golden_spm_registers,
796*b843c749SSergey Zigachev ARRAY_SIZE(kalindi_golden_spm_registers));
797*b843c749SSergey Zigachev break;
798*b843c749SSergey Zigachev case CHIP_KAVERI:
799*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
800*b843c749SSergey Zigachev spectre_mgcg_cgcg_init,
801*b843c749SSergey Zigachev ARRAY_SIZE(spectre_mgcg_cgcg_init));
802*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
803*b843c749SSergey Zigachev spectre_golden_registers,
804*b843c749SSergey Zigachev ARRAY_SIZE(spectre_golden_registers));
805*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
806*b843c749SSergey Zigachev spectre_golden_common_registers,
807*b843c749SSergey Zigachev ARRAY_SIZE(spectre_golden_common_registers));
808*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
809*b843c749SSergey Zigachev spectre_golden_spm_registers,
810*b843c749SSergey Zigachev ARRAY_SIZE(spectre_golden_spm_registers));
811*b843c749SSergey Zigachev break;
812*b843c749SSergey Zigachev case CHIP_HAWAII:
813*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
814*b843c749SSergey Zigachev hawaii_mgcg_cgcg_init,
815*b843c749SSergey Zigachev ARRAY_SIZE(hawaii_mgcg_cgcg_init));
816*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
817*b843c749SSergey Zigachev hawaii_golden_registers,
818*b843c749SSergey Zigachev ARRAY_SIZE(hawaii_golden_registers));
819*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
820*b843c749SSergey Zigachev hawaii_golden_common_registers,
821*b843c749SSergey Zigachev ARRAY_SIZE(hawaii_golden_common_registers));
822*b843c749SSergey Zigachev amdgpu_device_program_register_sequence(adev,
823*b843c749SSergey Zigachev hawaii_golden_spm_registers,
824*b843c749SSergey Zigachev ARRAY_SIZE(hawaii_golden_spm_registers));
825*b843c749SSergey Zigachev break;
826*b843c749SSergey Zigachev default:
827*b843c749SSergey Zigachev break;
828*b843c749SSergey Zigachev }
829*b843c749SSergey Zigachev mutex_unlock(&adev->grbm_idx_mutex);
830*b843c749SSergey Zigachev }
831*b843c749SSergey Zigachev
832*b843c749SSergey Zigachev /**
833*b843c749SSergey Zigachev * cik_get_xclk - get the xclk
834*b843c749SSergey Zigachev *
835*b843c749SSergey Zigachev * @adev: amdgpu_device pointer
836*b843c749SSergey Zigachev *
837*b843c749SSergey Zigachev * Returns the reference clock used by the gfx engine
838*b843c749SSergey Zigachev * (CIK).
839*b843c749SSergey Zigachev */
cik_get_xclk(struct amdgpu_device * adev)840*b843c749SSergey Zigachev static u32 cik_get_xclk(struct amdgpu_device *adev)
841*b843c749SSergey Zigachev {
842*b843c749SSergey Zigachev u32 reference_clock = adev->clock.spll.reference_freq;
843*b843c749SSergey Zigachev
844*b843c749SSergey Zigachev if (adev->flags & AMD_IS_APU) {
845*b843c749SSergey Zigachev if (RREG32_SMC(ixGENERAL_PWRMGT) & GENERAL_PWRMGT__GPU_COUNTER_CLK_MASK)
846*b843c749SSergey Zigachev return reference_clock / 2;
847*b843c749SSergey Zigachev } else {
848*b843c749SSergey Zigachev if (RREG32_SMC(ixCG_CLKPIN_CNTL) & CG_CLKPIN_CNTL__XTALIN_DIVIDE_MASK)
849*b843c749SSergey Zigachev return reference_clock / 4;
850*b843c749SSergey Zigachev }
851*b843c749SSergey Zigachev return reference_clock;
852*b843c749SSergey Zigachev }
853*b843c749SSergey Zigachev
854*b843c749SSergey Zigachev /**
855*b843c749SSergey Zigachev * cik_srbm_select - select specific register instances
856*b843c749SSergey Zigachev *
857*b843c749SSergey Zigachev * @adev: amdgpu_device pointer
858*b843c749SSergey Zigachev * @me: selected ME (micro engine)
859*b843c749SSergey Zigachev * @pipe: pipe
860*b843c749SSergey Zigachev * @queue: queue
861*b843c749SSergey Zigachev * @vmid: VMID
862*b843c749SSergey Zigachev *
863*b843c749SSergey Zigachev * Switches the currently active registers instances. Some
864*b843c749SSergey Zigachev * registers are instanced per VMID, others are instanced per
865*b843c749SSergey Zigachev * me/pipe/queue combination.
866*b843c749SSergey Zigachev */
cik_srbm_select(struct amdgpu_device * adev,u32 me,u32 pipe,u32 queue,u32 vmid)867*b843c749SSergey Zigachev void cik_srbm_select(struct amdgpu_device *adev,
868*b843c749SSergey Zigachev u32 me, u32 pipe, u32 queue, u32 vmid)
869*b843c749SSergey Zigachev {
870*b843c749SSergey Zigachev u32 srbm_gfx_cntl =
871*b843c749SSergey Zigachev (((pipe << SRBM_GFX_CNTL__PIPEID__SHIFT) & SRBM_GFX_CNTL__PIPEID_MASK)|
872*b843c749SSergey Zigachev ((me << SRBM_GFX_CNTL__MEID__SHIFT) & SRBM_GFX_CNTL__MEID_MASK)|
873*b843c749SSergey Zigachev ((vmid << SRBM_GFX_CNTL__VMID__SHIFT) & SRBM_GFX_CNTL__VMID_MASK)|
874*b843c749SSergey Zigachev ((queue << SRBM_GFX_CNTL__QUEUEID__SHIFT) & SRBM_GFX_CNTL__QUEUEID_MASK));
875*b843c749SSergey Zigachev WREG32(mmSRBM_GFX_CNTL, srbm_gfx_cntl);
876*b843c749SSergey Zigachev }
877*b843c749SSergey Zigachev
cik_vga_set_state(struct amdgpu_device * adev,bool state)878*b843c749SSergey Zigachev static void cik_vga_set_state(struct amdgpu_device *adev, bool state)
879*b843c749SSergey Zigachev {
880*b843c749SSergey Zigachev uint32_t tmp;
881*b843c749SSergey Zigachev
882*b843c749SSergey Zigachev tmp = RREG32(mmCONFIG_CNTL);
883*b843c749SSergey Zigachev if (!state)
884*b843c749SSergey Zigachev tmp |= CONFIG_CNTL__VGA_DIS_MASK;
885*b843c749SSergey Zigachev else
886*b843c749SSergey Zigachev tmp &= ~CONFIG_CNTL__VGA_DIS_MASK;
887*b843c749SSergey Zigachev WREG32(mmCONFIG_CNTL, tmp);
888*b843c749SSergey Zigachev }
889*b843c749SSergey Zigachev
cik_read_disabled_bios(struct amdgpu_device * adev)890*b843c749SSergey Zigachev static bool cik_read_disabled_bios(struct amdgpu_device *adev)
891*b843c749SSergey Zigachev {
892*b843c749SSergey Zigachev u32 bus_cntl;
893*b843c749SSergey Zigachev u32 d1vga_control = 0;
894*b843c749SSergey Zigachev u32 d2vga_control = 0;
895*b843c749SSergey Zigachev u32 vga_render_control = 0;
896*b843c749SSergey Zigachev u32 rom_cntl;
897*b843c749SSergey Zigachev bool r;
898*b843c749SSergey Zigachev
899*b843c749SSergey Zigachev bus_cntl = RREG32(mmBUS_CNTL);
900*b843c749SSergey Zigachev if (adev->mode_info.num_crtc) {
901*b843c749SSergey Zigachev d1vga_control = RREG32(mmD1VGA_CONTROL);
902*b843c749SSergey Zigachev d2vga_control = RREG32(mmD2VGA_CONTROL);
903*b843c749SSergey Zigachev vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
904*b843c749SSergey Zigachev }
905*b843c749SSergey Zigachev rom_cntl = RREG32_SMC(ixROM_CNTL);
906*b843c749SSergey Zigachev
907*b843c749SSergey Zigachev /* enable the rom */
908*b843c749SSergey Zigachev WREG32(mmBUS_CNTL, (bus_cntl & ~BUS_CNTL__BIOS_ROM_DIS_MASK));
909*b843c749SSergey Zigachev if (adev->mode_info.num_crtc) {
910*b843c749SSergey Zigachev /* Disable VGA mode */
911*b843c749SSergey Zigachev WREG32(mmD1VGA_CONTROL,
912*b843c749SSergey Zigachev (d1vga_control & ~(D1VGA_CONTROL__D1VGA_MODE_ENABLE_MASK |
913*b843c749SSergey Zigachev D1VGA_CONTROL__D1VGA_TIMING_SELECT_MASK)));
914*b843c749SSergey Zigachev WREG32(mmD2VGA_CONTROL,
915*b843c749SSergey Zigachev (d2vga_control & ~(D1VGA_CONTROL__D1VGA_MODE_ENABLE_MASK |
916*b843c749SSergey Zigachev D1VGA_CONTROL__D1VGA_TIMING_SELECT_MASK)));
917*b843c749SSergey Zigachev WREG32(mmVGA_RENDER_CONTROL,
918*b843c749SSergey Zigachev (vga_render_control & ~VGA_RENDER_CONTROL__VGA_VSTATUS_CNTL_MASK));
919*b843c749SSergey Zigachev }
920*b843c749SSergey Zigachev WREG32_SMC(ixROM_CNTL, rom_cntl | ROM_CNTL__SCK_OVERWRITE_MASK);
921*b843c749SSergey Zigachev
922*b843c749SSergey Zigachev r = amdgpu_read_bios(adev);
923*b843c749SSergey Zigachev
924*b843c749SSergey Zigachev /* restore regs */
925*b843c749SSergey Zigachev WREG32(mmBUS_CNTL, bus_cntl);
926*b843c749SSergey Zigachev if (adev->mode_info.num_crtc) {
927*b843c749SSergey Zigachev WREG32(mmD1VGA_CONTROL, d1vga_control);
928*b843c749SSergey Zigachev WREG32(mmD2VGA_CONTROL, d2vga_control);
929*b843c749SSergey Zigachev WREG32(mmVGA_RENDER_CONTROL, vga_render_control);
930*b843c749SSergey Zigachev }
931*b843c749SSergey Zigachev WREG32_SMC(ixROM_CNTL, rom_cntl);
932*b843c749SSergey Zigachev return r;
933*b843c749SSergey Zigachev }
934*b843c749SSergey Zigachev
cik_read_bios_from_rom(struct amdgpu_device * adev,u8 * bios,u32 length_bytes)935*b843c749SSergey Zigachev static bool cik_read_bios_from_rom(struct amdgpu_device *adev,
936*b843c749SSergey Zigachev u8 *bios, u32 length_bytes)
937*b843c749SSergey Zigachev {
938*b843c749SSergey Zigachev u32 *dw_ptr;
939*b843c749SSergey Zigachev unsigned long flags;
940*b843c749SSergey Zigachev u32 i, length_dw;
941*b843c749SSergey Zigachev
942*b843c749SSergey Zigachev if (bios == NULL)
943*b843c749SSergey Zigachev return false;
944*b843c749SSergey Zigachev if (length_bytes == 0)
945*b843c749SSergey Zigachev return false;
946*b843c749SSergey Zigachev /* APU vbios image is part of sbios image */
947*b843c749SSergey Zigachev if (adev->flags & AMD_IS_APU)
948*b843c749SSergey Zigachev return false;
949*b843c749SSergey Zigachev
950*b843c749SSergey Zigachev dw_ptr = (u32 *)bios;
951*b843c749SSergey Zigachev length_dw = ALIGN(length_bytes, 4) / 4;
952*b843c749SSergey Zigachev /* take the smc lock since we are using the smc index */
953*b843c749SSergey Zigachev spin_lock_irqsave(&adev->smc_idx_lock, flags);
954*b843c749SSergey Zigachev /* set rom index to 0 */
955*b843c749SSergey Zigachev WREG32(mmSMC_IND_INDEX_0, ixROM_INDEX);
956*b843c749SSergey Zigachev WREG32(mmSMC_IND_DATA_0, 0);
957*b843c749SSergey Zigachev /* set index to data for continous read */
958*b843c749SSergey Zigachev WREG32(mmSMC_IND_INDEX_0, ixROM_DATA);
959*b843c749SSergey Zigachev for (i = 0; i < length_dw; i++)
960*b843c749SSergey Zigachev dw_ptr[i] = RREG32(mmSMC_IND_DATA_0);
961*b843c749SSergey Zigachev spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
962*b843c749SSergey Zigachev
963*b843c749SSergey Zigachev return true;
964*b843c749SSergey Zigachev }
965*b843c749SSergey Zigachev
966*b843c749SSergey Zigachev static const struct amdgpu_allowed_register_entry cik_allowed_read_registers[] = {
967*b843c749SSergey Zigachev {mmGRBM_STATUS},
968*b843c749SSergey Zigachev {mmGB_ADDR_CONFIG},
969*b843c749SSergey Zigachev {mmMC_ARB_RAMCFG},
970*b843c749SSergey Zigachev {mmGB_TILE_MODE0},
971*b843c749SSergey Zigachev {mmGB_TILE_MODE1},
972*b843c749SSergey Zigachev {mmGB_TILE_MODE2},
973*b843c749SSergey Zigachev {mmGB_TILE_MODE3},
974*b843c749SSergey Zigachev {mmGB_TILE_MODE4},
975*b843c749SSergey Zigachev {mmGB_TILE_MODE5},
976*b843c749SSergey Zigachev {mmGB_TILE_MODE6},
977*b843c749SSergey Zigachev {mmGB_TILE_MODE7},
978*b843c749SSergey Zigachev {mmGB_TILE_MODE8},
979*b843c749SSergey Zigachev {mmGB_TILE_MODE9},
980*b843c749SSergey Zigachev {mmGB_TILE_MODE10},
981*b843c749SSergey Zigachev {mmGB_TILE_MODE11},
982*b843c749SSergey Zigachev {mmGB_TILE_MODE12},
983*b843c749SSergey Zigachev {mmGB_TILE_MODE13},
984*b843c749SSergey Zigachev {mmGB_TILE_MODE14},
985*b843c749SSergey Zigachev {mmGB_TILE_MODE15},
986*b843c749SSergey Zigachev {mmGB_TILE_MODE16},
987*b843c749SSergey Zigachev {mmGB_TILE_MODE17},
988*b843c749SSergey Zigachev {mmGB_TILE_MODE18},
989*b843c749SSergey Zigachev {mmGB_TILE_MODE19},
990*b843c749SSergey Zigachev {mmGB_TILE_MODE20},
991*b843c749SSergey Zigachev {mmGB_TILE_MODE21},
992*b843c749SSergey Zigachev {mmGB_TILE_MODE22},
993*b843c749SSergey Zigachev {mmGB_TILE_MODE23},
994*b843c749SSergey Zigachev {mmGB_TILE_MODE24},
995*b843c749SSergey Zigachev {mmGB_TILE_MODE25},
996*b843c749SSergey Zigachev {mmGB_TILE_MODE26},
997*b843c749SSergey Zigachev {mmGB_TILE_MODE27},
998*b843c749SSergey Zigachev {mmGB_TILE_MODE28},
999*b843c749SSergey Zigachev {mmGB_TILE_MODE29},
1000*b843c749SSergey Zigachev {mmGB_TILE_MODE30},
1001*b843c749SSergey Zigachev {mmGB_TILE_MODE31},
1002*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE0},
1003*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE1},
1004*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE2},
1005*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE3},
1006*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE4},
1007*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE5},
1008*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE6},
1009*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE7},
1010*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE8},
1011*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE9},
1012*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE10},
1013*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE11},
1014*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE12},
1015*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE13},
1016*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE14},
1017*b843c749SSergey Zigachev {mmGB_MACROTILE_MODE15},
1018*b843c749SSergey Zigachev {mmCC_RB_BACKEND_DISABLE, true},
1019*b843c749SSergey Zigachev {mmGC_USER_RB_BACKEND_DISABLE, true},
1020*b843c749SSergey Zigachev {mmGB_BACKEND_MAP, false},
1021*b843c749SSergey Zigachev {mmPA_SC_RASTER_CONFIG, true},
1022*b843c749SSergey Zigachev {mmPA_SC_RASTER_CONFIG_1, true},
1023*b843c749SSergey Zigachev };
1024*b843c749SSergey Zigachev
1025*b843c749SSergey Zigachev
cik_get_register_value(struct amdgpu_device * adev,bool indexed,u32 se_num,u32 sh_num,u32 reg_offset)1026*b843c749SSergey Zigachev static uint32_t cik_get_register_value(struct amdgpu_device *adev,
1027*b843c749SSergey Zigachev bool indexed, u32 se_num,
1028*b843c749SSergey Zigachev u32 sh_num, u32 reg_offset)
1029*b843c749SSergey Zigachev {
1030*b843c749SSergey Zigachev if (indexed) {
1031*b843c749SSergey Zigachev uint32_t val;
1032*b843c749SSergey Zigachev unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num;
1033*b843c749SSergey Zigachev unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num;
1034*b843c749SSergey Zigachev
1035*b843c749SSergey Zigachev switch (reg_offset) {
1036*b843c749SSergey Zigachev case mmCC_RB_BACKEND_DISABLE:
1037*b843c749SSergey Zigachev return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable;
1038*b843c749SSergey Zigachev case mmGC_USER_RB_BACKEND_DISABLE:
1039*b843c749SSergey Zigachev return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable;
1040*b843c749SSergey Zigachev case mmPA_SC_RASTER_CONFIG:
1041*b843c749SSergey Zigachev return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config;
1042*b843c749SSergey Zigachev case mmPA_SC_RASTER_CONFIG_1:
1043*b843c749SSergey Zigachev return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config_1;
1044*b843c749SSergey Zigachev }
1045*b843c749SSergey Zigachev
1046*b843c749SSergey Zigachev mutex_lock(&adev->grbm_idx_mutex);
1047*b843c749SSergey Zigachev if (se_num != 0xffffffff || sh_num != 0xffffffff)
1048*b843c749SSergey Zigachev amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff);
1049*b843c749SSergey Zigachev
1050*b843c749SSergey Zigachev val = RREG32(reg_offset);
1051*b843c749SSergey Zigachev
1052*b843c749SSergey Zigachev if (se_num != 0xffffffff || sh_num != 0xffffffff)
1053*b843c749SSergey Zigachev amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
1054*b843c749SSergey Zigachev mutex_unlock(&adev->grbm_idx_mutex);
1055*b843c749SSergey Zigachev return val;
1056*b843c749SSergey Zigachev } else {
1057*b843c749SSergey Zigachev unsigned idx;
1058*b843c749SSergey Zigachev
1059*b843c749SSergey Zigachev switch (reg_offset) {
1060*b843c749SSergey Zigachev case mmGB_ADDR_CONFIG:
1061*b843c749SSergey Zigachev return adev->gfx.config.gb_addr_config;
1062*b843c749SSergey Zigachev case mmMC_ARB_RAMCFG:
1063*b843c749SSergey Zigachev return adev->gfx.config.mc_arb_ramcfg;
1064*b843c749SSergey Zigachev case mmGB_TILE_MODE0:
1065*b843c749SSergey Zigachev case mmGB_TILE_MODE1:
1066*b843c749SSergey Zigachev case mmGB_TILE_MODE2:
1067*b843c749SSergey Zigachev case mmGB_TILE_MODE3:
1068*b843c749SSergey Zigachev case mmGB_TILE_MODE4:
1069*b843c749SSergey Zigachev case mmGB_TILE_MODE5:
1070*b843c749SSergey Zigachev case mmGB_TILE_MODE6:
1071*b843c749SSergey Zigachev case mmGB_TILE_MODE7:
1072*b843c749SSergey Zigachev case mmGB_TILE_MODE8:
1073*b843c749SSergey Zigachev case mmGB_TILE_MODE9:
1074*b843c749SSergey Zigachev case mmGB_TILE_MODE10:
1075*b843c749SSergey Zigachev case mmGB_TILE_MODE11:
1076*b843c749SSergey Zigachev case mmGB_TILE_MODE12:
1077*b843c749SSergey Zigachev case mmGB_TILE_MODE13:
1078*b843c749SSergey Zigachev case mmGB_TILE_MODE14:
1079*b843c749SSergey Zigachev case mmGB_TILE_MODE15:
1080*b843c749SSergey Zigachev case mmGB_TILE_MODE16:
1081*b843c749SSergey Zigachev case mmGB_TILE_MODE17:
1082*b843c749SSergey Zigachev case mmGB_TILE_MODE18:
1083*b843c749SSergey Zigachev case mmGB_TILE_MODE19:
1084*b843c749SSergey Zigachev case mmGB_TILE_MODE20:
1085*b843c749SSergey Zigachev case mmGB_TILE_MODE21:
1086*b843c749SSergey Zigachev case mmGB_TILE_MODE22:
1087*b843c749SSergey Zigachev case mmGB_TILE_MODE23:
1088*b843c749SSergey Zigachev case mmGB_TILE_MODE24:
1089*b843c749SSergey Zigachev case mmGB_TILE_MODE25:
1090*b843c749SSergey Zigachev case mmGB_TILE_MODE26:
1091*b843c749SSergey Zigachev case mmGB_TILE_MODE27:
1092*b843c749SSergey Zigachev case mmGB_TILE_MODE28:
1093*b843c749SSergey Zigachev case mmGB_TILE_MODE29:
1094*b843c749SSergey Zigachev case mmGB_TILE_MODE30:
1095*b843c749SSergey Zigachev case mmGB_TILE_MODE31:
1096*b843c749SSergey Zigachev idx = (reg_offset - mmGB_TILE_MODE0);
1097*b843c749SSergey Zigachev return adev->gfx.config.tile_mode_array[idx];
1098*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE0:
1099*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE1:
1100*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE2:
1101*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE3:
1102*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE4:
1103*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE5:
1104*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE6:
1105*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE7:
1106*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE8:
1107*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE9:
1108*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE10:
1109*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE11:
1110*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE12:
1111*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE13:
1112*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE14:
1113*b843c749SSergey Zigachev case mmGB_MACROTILE_MODE15:
1114*b843c749SSergey Zigachev idx = (reg_offset - mmGB_MACROTILE_MODE0);
1115*b843c749SSergey Zigachev return adev->gfx.config.macrotile_mode_array[idx];
1116*b843c749SSergey Zigachev default:
1117*b843c749SSergey Zigachev return RREG32(reg_offset);
1118*b843c749SSergey Zigachev }
1119*b843c749SSergey Zigachev }
1120*b843c749SSergey Zigachev }
1121*b843c749SSergey Zigachev
cik_read_register(struct amdgpu_device * adev,u32 se_num,u32 sh_num,u32 reg_offset,u32 * value)1122*b843c749SSergey Zigachev static int cik_read_register(struct amdgpu_device *adev, u32 se_num,
1123*b843c749SSergey Zigachev u32 sh_num, u32 reg_offset, u32 *value)
1124*b843c749SSergey Zigachev {
1125*b843c749SSergey Zigachev uint32_t i;
1126*b843c749SSergey Zigachev
1127*b843c749SSergey Zigachev *value = 0;
1128*b843c749SSergey Zigachev for (i = 0; i < ARRAY_SIZE(cik_allowed_read_registers); i++) {
1129*b843c749SSergey Zigachev bool indexed = cik_allowed_read_registers[i].grbm_indexed;
1130*b843c749SSergey Zigachev
1131*b843c749SSergey Zigachev if (reg_offset != cik_allowed_read_registers[i].reg_offset)
1132*b843c749SSergey Zigachev continue;
1133*b843c749SSergey Zigachev
1134*b843c749SSergey Zigachev *value = cik_get_register_value(adev, indexed, se_num, sh_num,
1135*b843c749SSergey Zigachev reg_offset);
1136*b843c749SSergey Zigachev return 0;
1137*b843c749SSergey Zigachev }
1138*b843c749SSergey Zigachev return -EINVAL;
1139*b843c749SSergey Zigachev }
1140*b843c749SSergey Zigachev
1141*b843c749SSergey Zigachev struct kv_reset_save_regs {
1142*b843c749SSergey Zigachev u32 gmcon_reng_execute;
1143*b843c749SSergey Zigachev u32 gmcon_misc;
1144*b843c749SSergey Zigachev u32 gmcon_misc3;
1145*b843c749SSergey Zigachev };
1146*b843c749SSergey Zigachev
kv_save_regs_for_reset(struct amdgpu_device * adev,struct kv_reset_save_regs * save)1147*b843c749SSergey Zigachev static void kv_save_regs_for_reset(struct amdgpu_device *adev,
1148*b843c749SSergey Zigachev struct kv_reset_save_regs *save)
1149*b843c749SSergey Zigachev {
1150*b843c749SSergey Zigachev save->gmcon_reng_execute = RREG32(mmGMCON_RENG_EXECUTE);
1151*b843c749SSergey Zigachev save->gmcon_misc = RREG32(mmGMCON_MISC);
1152*b843c749SSergey Zigachev save->gmcon_misc3 = RREG32(mmGMCON_MISC3);
1153*b843c749SSergey Zigachev
1154*b843c749SSergey Zigachev WREG32(mmGMCON_RENG_EXECUTE, save->gmcon_reng_execute &
1155*b843c749SSergey Zigachev ~GMCON_RENG_EXECUTE__RENG_EXECUTE_ON_PWR_UP_MASK);
1156*b843c749SSergey Zigachev WREG32(mmGMCON_MISC, save->gmcon_misc &
1157*b843c749SSergey Zigachev ~(GMCON_MISC__RENG_EXECUTE_ON_REG_UPDATE_MASK |
1158*b843c749SSergey Zigachev GMCON_MISC__STCTRL_STUTTER_EN_MASK));
1159*b843c749SSergey Zigachev }
1160*b843c749SSergey Zigachev
kv_restore_regs_for_reset(struct amdgpu_device * adev,struct kv_reset_save_regs * save)1161*b843c749SSergey Zigachev static void kv_restore_regs_for_reset(struct amdgpu_device *adev,
1162*b843c749SSergey Zigachev struct kv_reset_save_regs *save)
1163*b843c749SSergey Zigachev {
1164*b843c749SSergey Zigachev int i;
1165*b843c749SSergey Zigachev
1166*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1167*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0x200010ff);
1168*b843c749SSergey Zigachev
1169*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1170*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1171*b843c749SSergey Zigachev
1172*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1173*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0x300010ff);
1174*b843c749SSergey Zigachev
1175*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1176*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1177*b843c749SSergey Zigachev
1178*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x210000);
1179*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0xa00010ff);
1180*b843c749SSergey Zigachev
1181*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1182*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1183*b843c749SSergey Zigachev
1184*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x21003);
1185*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0xb00010ff);
1186*b843c749SSergey Zigachev
1187*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1188*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1189*b843c749SSergey Zigachev
1190*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x2b00);
1191*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0xc00010ff);
1192*b843c749SSergey Zigachev
1193*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1194*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1195*b843c749SSergey Zigachev
1196*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1197*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0xd00010ff);
1198*b843c749SSergey Zigachev
1199*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1200*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1201*b843c749SSergey Zigachev
1202*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x420000);
1203*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0x100010ff);
1204*b843c749SSergey Zigachev
1205*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1206*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1207*b843c749SSergey Zigachev
1208*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x120202);
1209*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0x500010ff);
1210*b843c749SSergey Zigachev
1211*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1212*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1213*b843c749SSergey Zigachev
1214*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x3e3e36);
1215*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0x600010ff);
1216*b843c749SSergey Zigachev
1217*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1218*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1219*b843c749SSergey Zigachev
1220*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x373f3e);
1221*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0x700010ff);
1222*b843c749SSergey Zigachev
1223*b843c749SSergey Zigachev for (i = 0; i < 5; i++)
1224*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0);
1225*b843c749SSergey Zigachev
1226*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_WRITE, 0x3e1332);
1227*b843c749SSergey Zigachev WREG32(mmGMCON_PGFSM_CONFIG, 0xe00010ff);
1228*b843c749SSergey Zigachev
1229*b843c749SSergey Zigachev WREG32(mmGMCON_MISC3, save->gmcon_misc3);
1230*b843c749SSergey Zigachev WREG32(mmGMCON_MISC, save->gmcon_misc);
1231*b843c749SSergey Zigachev WREG32(mmGMCON_RENG_EXECUTE, save->gmcon_reng_execute);
1232*b843c749SSergey Zigachev }
1233*b843c749SSergey Zigachev
cik_gpu_pci_config_reset(struct amdgpu_device * adev)1234*b843c749SSergey Zigachev static int cik_gpu_pci_config_reset(struct amdgpu_device *adev)
1235*b843c749SSergey Zigachev {
1236*b843c749SSergey Zigachev struct kv_reset_save_regs kv_save = { 0 };
1237*b843c749SSergey Zigachev u32 i;
1238*b843c749SSergey Zigachev int r = -EINVAL;
1239*b843c749SSergey Zigachev
1240*b843c749SSergey Zigachev dev_info(adev->dev, "GPU pci config reset\n");
1241*b843c749SSergey Zigachev
1242*b843c749SSergey Zigachev if (adev->flags & AMD_IS_APU)
1243*b843c749SSergey Zigachev kv_save_regs_for_reset(adev, &kv_save);
1244*b843c749SSergey Zigachev
1245*b843c749SSergey Zigachev /* disable BM */
1246*b843c749SSergey Zigachev pci_clear_master(adev->pdev);
1247*b843c749SSergey Zigachev /* reset */
1248*b843c749SSergey Zigachev amdgpu_device_pci_config_reset(adev);
1249*b843c749SSergey Zigachev
1250*b843c749SSergey Zigachev udelay(100);
1251*b843c749SSergey Zigachev
1252*b843c749SSergey Zigachev /* wait for asic to come out of reset */
1253*b843c749SSergey Zigachev for (i = 0; i < adev->usec_timeout; i++) {
1254*b843c749SSergey Zigachev if (RREG32(mmCONFIG_MEMSIZE) != 0xffffffff) {
1255*b843c749SSergey Zigachev /* enable BM */
1256*b843c749SSergey Zigachev pci_set_master(adev->pdev);
1257*b843c749SSergey Zigachev adev->has_hw_reset = true;
1258*b843c749SSergey Zigachev r = 0;
1259*b843c749SSergey Zigachev break;
1260*b843c749SSergey Zigachev }
1261*b843c749SSergey Zigachev udelay(1);
1262*b843c749SSergey Zigachev }
1263*b843c749SSergey Zigachev
1264*b843c749SSergey Zigachev /* does asic init need to be run first??? */
1265*b843c749SSergey Zigachev if (adev->flags & AMD_IS_APU)
1266*b843c749SSergey Zigachev kv_restore_regs_for_reset(adev, &kv_save);
1267*b843c749SSergey Zigachev
1268*b843c749SSergey Zigachev return r;
1269*b843c749SSergey Zigachev }
1270*b843c749SSergey Zigachev
1271*b843c749SSergey Zigachev /**
1272*b843c749SSergey Zigachev * cik_asic_reset - soft reset GPU
1273*b843c749SSergey Zigachev *
1274*b843c749SSergey Zigachev * @adev: amdgpu_device pointer
1275*b843c749SSergey Zigachev *
1276*b843c749SSergey Zigachev * Look up which blocks are hung and attempt
1277*b843c749SSergey Zigachev * to reset them.
1278*b843c749SSergey Zigachev * Returns 0 for success.
1279*b843c749SSergey Zigachev */
cik_asic_reset(struct amdgpu_device * adev)1280*b843c749SSergey Zigachev static int cik_asic_reset(struct amdgpu_device *adev)
1281*b843c749SSergey Zigachev {
1282*b843c749SSergey Zigachev int r;
1283*b843c749SSergey Zigachev
1284*b843c749SSergey Zigachev amdgpu_atombios_scratch_regs_engine_hung(adev, true);
1285*b843c749SSergey Zigachev
1286*b843c749SSergey Zigachev r = cik_gpu_pci_config_reset(adev);
1287*b843c749SSergey Zigachev
1288*b843c749SSergey Zigachev amdgpu_atombios_scratch_regs_engine_hung(adev, false);
1289*b843c749SSergey Zigachev
1290*b843c749SSergey Zigachev return r;
1291*b843c749SSergey Zigachev }
1292*b843c749SSergey Zigachev
cik_get_config_memsize(struct amdgpu_device * adev)1293*b843c749SSergey Zigachev static u32 cik_get_config_memsize(struct amdgpu_device *adev)
1294*b843c749SSergey Zigachev {
1295*b843c749SSergey Zigachev return RREG32(mmCONFIG_MEMSIZE);
1296*b843c749SSergey Zigachev }
1297*b843c749SSergey Zigachev
cik_set_uvd_clock(struct amdgpu_device * adev,u32 clock,u32 cntl_reg,u32 status_reg)1298*b843c749SSergey Zigachev static int cik_set_uvd_clock(struct amdgpu_device *adev, u32 clock,
1299*b843c749SSergey Zigachev u32 cntl_reg, u32 status_reg)
1300*b843c749SSergey Zigachev {
1301*b843c749SSergey Zigachev int r, i;
1302*b843c749SSergey Zigachev struct atom_clock_dividers dividers;
1303*b843c749SSergey Zigachev uint32_t tmp;
1304*b843c749SSergey Zigachev
1305*b843c749SSergey Zigachev r = amdgpu_atombios_get_clock_dividers(adev,
1306*b843c749SSergey Zigachev COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK,
1307*b843c749SSergey Zigachev clock, false, ÷rs);
1308*b843c749SSergey Zigachev if (r)
1309*b843c749SSergey Zigachev return r;
1310*b843c749SSergey Zigachev
1311*b843c749SSergey Zigachev tmp = RREG32_SMC(cntl_reg);
1312*b843c749SSergey Zigachev tmp &= ~(CG_DCLK_CNTL__DCLK_DIR_CNTL_EN_MASK |
1313*b843c749SSergey Zigachev CG_DCLK_CNTL__DCLK_DIVIDER_MASK);
1314*b843c749SSergey Zigachev tmp |= dividers.post_divider;
1315*b843c749SSergey Zigachev WREG32_SMC(cntl_reg, tmp);
1316*b843c749SSergey Zigachev
1317*b843c749SSergey Zigachev for (i = 0; i < 100; i++) {
1318*b843c749SSergey Zigachev if (RREG32_SMC(status_reg) & CG_DCLK_STATUS__DCLK_STATUS_MASK)
1319*b843c749SSergey Zigachev break;
1320*b843c749SSergey Zigachev mdelay(10);
1321*b843c749SSergey Zigachev }
1322*b843c749SSergey Zigachev if (i == 100)
1323*b843c749SSergey Zigachev return -ETIMEDOUT;
1324*b843c749SSergey Zigachev
1325*b843c749SSergey Zigachev return 0;
1326*b843c749SSergey Zigachev }
1327*b843c749SSergey Zigachev
cik_set_uvd_clocks(struct amdgpu_device * adev,u32 vclk,u32 dclk)1328*b843c749SSergey Zigachev static int cik_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
1329*b843c749SSergey Zigachev {
1330*b843c749SSergey Zigachev int r = 0;
1331*b843c749SSergey Zigachev
1332*b843c749SSergey Zigachev r = cik_set_uvd_clock(adev, vclk, ixCG_VCLK_CNTL, ixCG_VCLK_STATUS);
1333*b843c749SSergey Zigachev if (r)
1334*b843c749SSergey Zigachev return r;
1335*b843c749SSergey Zigachev
1336*b843c749SSergey Zigachev r = cik_set_uvd_clock(adev, dclk, ixCG_DCLK_CNTL, ixCG_DCLK_STATUS);
1337*b843c749SSergey Zigachev return r;
1338*b843c749SSergey Zigachev }
1339*b843c749SSergey Zigachev
cik_set_vce_clocks(struct amdgpu_device * adev,u32 evclk,u32 ecclk)1340*b843c749SSergey Zigachev static int cik_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
1341*b843c749SSergey Zigachev {
1342*b843c749SSergey Zigachev int r, i;
1343*b843c749SSergey Zigachev struct atom_clock_dividers dividers;
1344*b843c749SSergey Zigachev u32 tmp;
1345*b843c749SSergey Zigachev
1346*b843c749SSergey Zigachev r = amdgpu_atombios_get_clock_dividers(adev,
1347*b843c749SSergey Zigachev COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK,
1348*b843c749SSergey Zigachev ecclk, false, ÷rs);
1349*b843c749SSergey Zigachev if (r)
1350*b843c749SSergey Zigachev return r;
1351*b843c749SSergey Zigachev
1352*b843c749SSergey Zigachev for (i = 0; i < 100; i++) {
1353*b843c749SSergey Zigachev if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
1354*b843c749SSergey Zigachev break;
1355*b843c749SSergey Zigachev mdelay(10);
1356*b843c749SSergey Zigachev }
1357*b843c749SSergey Zigachev if (i == 100)
1358*b843c749SSergey Zigachev return -ETIMEDOUT;
1359*b843c749SSergey Zigachev
1360*b843c749SSergey Zigachev tmp = RREG32_SMC(ixCG_ECLK_CNTL);
1361*b843c749SSergey Zigachev tmp &= ~(CG_ECLK_CNTL__ECLK_DIR_CNTL_EN_MASK |
1362*b843c749SSergey Zigachev CG_ECLK_CNTL__ECLK_DIVIDER_MASK);
1363*b843c749SSergey Zigachev tmp |= dividers.post_divider;
1364*b843c749SSergey Zigachev WREG32_SMC(ixCG_ECLK_CNTL, tmp);
1365*b843c749SSergey Zigachev
1366*b843c749SSergey Zigachev for (i = 0; i < 100; i++) {
1367*b843c749SSergey Zigachev if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
1368*b843c749SSergey Zigachev break;
1369*b843c749SSergey Zigachev mdelay(10);
1370*b843c749SSergey Zigachev }
1371*b843c749SSergey Zigachev if (i == 100)
1372*b843c749SSergey Zigachev return -ETIMEDOUT;
1373*b843c749SSergey Zigachev
1374*b843c749SSergey Zigachev return 0;
1375*b843c749SSergey Zigachev }
1376*b843c749SSergey Zigachev
cik_pcie_gen3_enable(struct amdgpu_device * adev)1377*b843c749SSergey Zigachev static void cik_pcie_gen3_enable(struct amdgpu_device *adev)
1378*b843c749SSergey Zigachev {
1379*b843c749SSergey Zigachev struct pci_dev *root = adev->pdev->bus->self;
1380*b843c749SSergey Zigachev int bridge_pos, gpu_pos;
1381*b843c749SSergey Zigachev u32 speed_cntl, current_data_rate;
1382*b843c749SSergey Zigachev int i;
1383*b843c749SSergey Zigachev u16 tmp16;
1384*b843c749SSergey Zigachev
1385*b843c749SSergey Zigachev if (pci_is_root_bus(adev->pdev->bus))
1386*b843c749SSergey Zigachev return;
1387*b843c749SSergey Zigachev
1388*b843c749SSergey Zigachev if (amdgpu_pcie_gen2 == 0)
1389*b843c749SSergey Zigachev return;
1390*b843c749SSergey Zigachev
1391*b843c749SSergey Zigachev if (adev->flags & AMD_IS_APU)
1392*b843c749SSergey Zigachev return;
1393*b843c749SSergey Zigachev
1394*b843c749SSergey Zigachev if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |
1395*b843c749SSergey Zigachev CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)))
1396*b843c749SSergey Zigachev return;
1397*b843c749SSergey Zigachev
1398*b843c749SSergey Zigachev speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL);
1399*b843c749SSergey Zigachev current_data_rate = (speed_cntl & PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK) >>
1400*b843c749SSergey Zigachev PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT;
1401*b843c749SSergey Zigachev if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) {
1402*b843c749SSergey Zigachev if (current_data_rate == 2) {
1403*b843c749SSergey Zigachev DRM_INFO("PCIE gen 3 link speeds already enabled\n");
1404*b843c749SSergey Zigachev return;
1405*b843c749SSergey Zigachev }
1406*b843c749SSergey Zigachev DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n");
1407*b843c749SSergey Zigachev } else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) {
1408*b843c749SSergey Zigachev if (current_data_rate == 1) {
1409*b843c749SSergey Zigachev DRM_INFO("PCIE gen 2 link speeds already enabled\n");
1410*b843c749SSergey Zigachev return;
1411*b843c749SSergey Zigachev }
1412*b843c749SSergey Zigachev DRM_INFO("enabling PCIE gen 2 link speeds, disable with amdgpu.pcie_gen2=0\n");
1413*b843c749SSergey Zigachev }
1414*b843c749SSergey Zigachev
1415*b843c749SSergey Zigachev bridge_pos = pci_pcie_cap(root);
1416*b843c749SSergey Zigachev if (!bridge_pos)
1417*b843c749SSergey Zigachev return;
1418*b843c749SSergey Zigachev
1419*b843c749SSergey Zigachev gpu_pos = pci_pcie_cap(adev->pdev);
1420*b843c749SSergey Zigachev if (!gpu_pos)
1421*b843c749SSergey Zigachev return;
1422*b843c749SSergey Zigachev
1423*b843c749SSergey Zigachev if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) {
1424*b843c749SSergey Zigachev /* re-try equalization if gen3 is not already enabled */
1425*b843c749SSergey Zigachev if (current_data_rate != 2) {
1426*b843c749SSergey Zigachev u16 bridge_cfg, gpu_cfg;
1427*b843c749SSergey Zigachev u16 bridge_cfg2, gpu_cfg2;
1428*b843c749SSergey Zigachev u32 max_lw, current_lw, tmp;
1429*b843c749SSergey Zigachev
1430*b843c749SSergey Zigachev pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg);
1431*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg);
1432*b843c749SSergey Zigachev
1433*b843c749SSergey Zigachev tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD;
1434*b843c749SSergey Zigachev pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16);
1435*b843c749SSergey Zigachev
1436*b843c749SSergey Zigachev tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD;
1437*b843c749SSergey Zigachev pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16);
1438*b843c749SSergey Zigachev
1439*b843c749SSergey Zigachev tmp = RREG32_PCIE(ixPCIE_LC_STATUS1);
1440*b843c749SSergey Zigachev max_lw = (tmp & PCIE_LC_STATUS1__LC_DETECTED_LINK_WIDTH_MASK) >>
1441*b843c749SSergey Zigachev PCIE_LC_STATUS1__LC_DETECTED_LINK_WIDTH__SHIFT;
1442*b843c749SSergey Zigachev current_lw = (tmp & PCIE_LC_STATUS1__LC_OPERATING_LINK_WIDTH_MASK)
1443*b843c749SSergey Zigachev >> PCIE_LC_STATUS1__LC_OPERATING_LINK_WIDTH__SHIFT;
1444*b843c749SSergey Zigachev
1445*b843c749SSergey Zigachev if (current_lw < max_lw) {
1446*b843c749SSergey Zigachev tmp = RREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL);
1447*b843c749SSergey Zigachev if (tmp & PCIE_LC_LINK_WIDTH_CNTL__LC_RENEGOTIATION_SUPPORT_MASK) {
1448*b843c749SSergey Zigachev tmp &= ~(PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH_MASK |
1449*b843c749SSergey Zigachev PCIE_LC_LINK_WIDTH_CNTL__LC_UPCONFIGURE_DIS_MASK);
1450*b843c749SSergey Zigachev tmp |= (max_lw <<
1451*b843c749SSergey Zigachev PCIE_LC_LINK_WIDTH_CNTL__LC_LINK_WIDTH__SHIFT);
1452*b843c749SSergey Zigachev tmp |= PCIE_LC_LINK_WIDTH_CNTL__LC_UPCONFIGURE_SUPPORT_MASK |
1453*b843c749SSergey Zigachev PCIE_LC_LINK_WIDTH_CNTL__LC_RENEGOTIATE_EN_MASK |
1454*b843c749SSergey Zigachev PCIE_LC_LINK_WIDTH_CNTL__LC_RECONFIG_NOW_MASK;
1455*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL, tmp);
1456*b843c749SSergey Zigachev }
1457*b843c749SSergey Zigachev }
1458*b843c749SSergey Zigachev
1459*b843c749SSergey Zigachev for (i = 0; i < 10; i++) {
1460*b843c749SSergey Zigachev /* check status */
1461*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16);
1462*b843c749SSergey Zigachev if (tmp16 & PCI_EXP_DEVSTA_TRPND)
1463*b843c749SSergey Zigachev break;
1464*b843c749SSergey Zigachev
1465*b843c749SSergey Zigachev pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg);
1466*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg);
1467*b843c749SSergey Zigachev
1468*b843c749SSergey Zigachev pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2);
1469*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2);
1470*b843c749SSergey Zigachev
1471*b843c749SSergey Zigachev tmp = RREG32_PCIE(ixPCIE_LC_CNTL4);
1472*b843c749SSergey Zigachev tmp |= PCIE_LC_CNTL4__LC_SET_QUIESCE_MASK;
1473*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL4, tmp);
1474*b843c749SSergey Zigachev
1475*b843c749SSergey Zigachev tmp = RREG32_PCIE(ixPCIE_LC_CNTL4);
1476*b843c749SSergey Zigachev tmp |= PCIE_LC_CNTL4__LC_REDO_EQ_MASK;
1477*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL4, tmp);
1478*b843c749SSergey Zigachev
1479*b843c749SSergey Zigachev msleep(100);
1480*b843c749SSergey Zigachev
1481*b843c749SSergey Zigachev /* linkctl */
1482*b843c749SSergey Zigachev pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16);
1483*b843c749SSergey Zigachev tmp16 &= ~PCI_EXP_LNKCTL_HAWD;
1484*b843c749SSergey Zigachev tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD);
1485*b843c749SSergey Zigachev pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16);
1486*b843c749SSergey Zigachev
1487*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16);
1488*b843c749SSergey Zigachev tmp16 &= ~PCI_EXP_LNKCTL_HAWD;
1489*b843c749SSergey Zigachev tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD);
1490*b843c749SSergey Zigachev pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16);
1491*b843c749SSergey Zigachev
1492*b843c749SSergey Zigachev /* linkctl2 */
1493*b843c749SSergey Zigachev pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16);
1494*b843c749SSergey Zigachev tmp16 &= ~((1 << 4) | (7 << 9));
1495*b843c749SSergey Zigachev tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9)));
1496*b843c749SSergey Zigachev pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16);
1497*b843c749SSergey Zigachev
1498*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);
1499*b843c749SSergey Zigachev tmp16 &= ~((1 << 4) | (7 << 9));
1500*b843c749SSergey Zigachev tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9)));
1501*b843c749SSergey Zigachev pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
1502*b843c749SSergey Zigachev
1503*b843c749SSergey Zigachev tmp = RREG32_PCIE(ixPCIE_LC_CNTL4);
1504*b843c749SSergey Zigachev tmp &= ~PCIE_LC_CNTL4__LC_SET_QUIESCE_MASK;
1505*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL4, tmp);
1506*b843c749SSergey Zigachev }
1507*b843c749SSergey Zigachev }
1508*b843c749SSergey Zigachev }
1509*b843c749SSergey Zigachev
1510*b843c749SSergey Zigachev /* set the link speed */
1511*b843c749SSergey Zigachev speed_cntl |= PCIE_LC_SPEED_CNTL__LC_FORCE_EN_SW_SPEED_CHANGE_MASK |
1512*b843c749SSergey Zigachev PCIE_LC_SPEED_CNTL__LC_FORCE_DIS_HW_SPEED_CHANGE_MASK;
1513*b843c749SSergey Zigachev speed_cntl &= ~PCIE_LC_SPEED_CNTL__LC_FORCE_DIS_SW_SPEED_CHANGE_MASK;
1514*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_SPEED_CNTL, speed_cntl);
1515*b843c749SSergey Zigachev
1516*b843c749SSergey Zigachev pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);
1517*b843c749SSergey Zigachev tmp16 &= ~0xf;
1518*b843c749SSergey Zigachev if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)
1519*b843c749SSergey Zigachev tmp16 |= 3; /* gen3 */
1520*b843c749SSergey Zigachev else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2)
1521*b843c749SSergey Zigachev tmp16 |= 2; /* gen2 */
1522*b843c749SSergey Zigachev else
1523*b843c749SSergey Zigachev tmp16 |= 1; /* gen1 */
1524*b843c749SSergey Zigachev pci_write_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16);
1525*b843c749SSergey Zigachev
1526*b843c749SSergey Zigachev speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL);
1527*b843c749SSergey Zigachev speed_cntl |= PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK;
1528*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_SPEED_CNTL, speed_cntl);
1529*b843c749SSergey Zigachev
1530*b843c749SSergey Zigachev for (i = 0; i < adev->usec_timeout; i++) {
1531*b843c749SSergey Zigachev speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL);
1532*b843c749SSergey Zigachev if ((speed_cntl & PCIE_LC_SPEED_CNTL__LC_INITIATE_LINK_SPEED_CHANGE_MASK) == 0)
1533*b843c749SSergey Zigachev break;
1534*b843c749SSergey Zigachev udelay(1);
1535*b843c749SSergey Zigachev }
1536*b843c749SSergey Zigachev }
1537*b843c749SSergey Zigachev
cik_program_aspm(struct amdgpu_device * adev)1538*b843c749SSergey Zigachev static void cik_program_aspm(struct amdgpu_device *adev)
1539*b843c749SSergey Zigachev {
1540*b843c749SSergey Zigachev u32 data, orig;
1541*b843c749SSergey Zigachev bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
1542*b843c749SSergey Zigachev bool disable_clkreq = false;
1543*b843c749SSergey Zigachev
1544*b843c749SSergey Zigachev if (amdgpu_aspm == 0)
1545*b843c749SSergey Zigachev return;
1546*b843c749SSergey Zigachev
1547*b843c749SSergey Zigachev if (pci_is_root_bus(adev->pdev->bus))
1548*b843c749SSergey Zigachev return;
1549*b843c749SSergey Zigachev
1550*b843c749SSergey Zigachev /* XXX double check APUs */
1551*b843c749SSergey Zigachev if (adev->flags & AMD_IS_APU)
1552*b843c749SSergey Zigachev return;
1553*b843c749SSergey Zigachev
1554*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_LC_N_FTS_CNTL);
1555*b843c749SSergey Zigachev data &= ~PCIE_LC_N_FTS_CNTL__LC_XMIT_N_FTS_MASK;
1556*b843c749SSergey Zigachev data |= (0x24 << PCIE_LC_N_FTS_CNTL__LC_XMIT_N_FTS__SHIFT) |
1557*b843c749SSergey Zigachev PCIE_LC_N_FTS_CNTL__LC_XMIT_N_FTS_OVERRIDE_EN_MASK;
1558*b843c749SSergey Zigachev if (orig != data)
1559*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_N_FTS_CNTL, data);
1560*b843c749SSergey Zigachev
1561*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_LC_CNTL3);
1562*b843c749SSergey Zigachev data |= PCIE_LC_CNTL3__LC_GO_TO_RECOVERY_MASK;
1563*b843c749SSergey Zigachev if (orig != data)
1564*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL3, data);
1565*b843c749SSergey Zigachev
1566*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_P_CNTL);
1567*b843c749SSergey Zigachev data |= PCIE_P_CNTL__P_IGNORE_EDB_ERR_MASK;
1568*b843c749SSergey Zigachev if (orig != data)
1569*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_P_CNTL, data);
1570*b843c749SSergey Zigachev
1571*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_LC_CNTL);
1572*b843c749SSergey Zigachev data &= ~(PCIE_LC_CNTL__LC_L0S_INACTIVITY_MASK |
1573*b843c749SSergey Zigachev PCIE_LC_CNTL__LC_L1_INACTIVITY_MASK);
1574*b843c749SSergey Zigachev data |= PCIE_LC_CNTL__LC_PMI_TO_L1_DIS_MASK;
1575*b843c749SSergey Zigachev if (!disable_l0s)
1576*b843c749SSergey Zigachev data |= (7 << PCIE_LC_CNTL__LC_L0S_INACTIVITY__SHIFT);
1577*b843c749SSergey Zigachev
1578*b843c749SSergey Zigachev if (!disable_l1) {
1579*b843c749SSergey Zigachev data |= (7 << PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT);
1580*b843c749SSergey Zigachev data &= ~PCIE_LC_CNTL__LC_PMI_TO_L1_DIS_MASK;
1581*b843c749SSergey Zigachev if (orig != data)
1582*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL, data);
1583*b843c749SSergey Zigachev
1584*b843c749SSergey Zigachev if (!disable_plloff_in_l1) {
1585*b843c749SSergey Zigachev bool clk_req_support;
1586*b843c749SSergey Zigachev
1587*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPB0_PIF_PWRDOWN_0);
1588*b843c749SSergey Zigachev data &= ~(PB0_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_OFF_0_MASK |
1589*b843c749SSergey Zigachev PB0_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_TXS2_0_MASK);
1590*b843c749SSergey Zigachev data |= (7 << PB0_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_OFF_0__SHIFT) |
1591*b843c749SSergey Zigachev (7 << PB0_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_TXS2_0__SHIFT);
1592*b843c749SSergey Zigachev if (orig != data)
1593*b843c749SSergey Zigachev WREG32_PCIE(ixPB0_PIF_PWRDOWN_0, data);
1594*b843c749SSergey Zigachev
1595*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPB0_PIF_PWRDOWN_1);
1596*b843c749SSergey Zigachev data &= ~(PB0_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_OFF_1_MASK |
1597*b843c749SSergey Zigachev PB0_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1_MASK);
1598*b843c749SSergey Zigachev data |= (7 << PB0_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_OFF_1__SHIFT) |
1599*b843c749SSergey Zigachev (7 << PB0_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1__SHIFT);
1600*b843c749SSergey Zigachev if (orig != data)
1601*b843c749SSergey Zigachev WREG32_PCIE(ixPB0_PIF_PWRDOWN_1, data);
1602*b843c749SSergey Zigachev
1603*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPB1_PIF_PWRDOWN_0);
1604*b843c749SSergey Zigachev data &= ~(PB1_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_OFF_0_MASK |
1605*b843c749SSergey Zigachev PB1_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_TXS2_0_MASK);
1606*b843c749SSergey Zigachev data |= (7 << PB1_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_OFF_0__SHIFT) |
1607*b843c749SSergey Zigachev (7 << PB1_PIF_PWRDOWN_0__PLL_POWER_STATE_IN_TXS2_0__SHIFT);
1608*b843c749SSergey Zigachev if (orig != data)
1609*b843c749SSergey Zigachev WREG32_PCIE(ixPB1_PIF_PWRDOWN_0, data);
1610*b843c749SSergey Zigachev
1611*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPB1_PIF_PWRDOWN_1);
1612*b843c749SSergey Zigachev data &= ~(PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_OFF_1_MASK |
1613*b843c749SSergey Zigachev PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1_MASK);
1614*b843c749SSergey Zigachev data |= (7 << PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_OFF_1__SHIFT) |
1615*b843c749SSergey Zigachev (7 << PB1_PIF_PWRDOWN_1__PLL_POWER_STATE_IN_TXS2_1__SHIFT);
1616*b843c749SSergey Zigachev if (orig != data)
1617*b843c749SSergey Zigachev WREG32_PCIE(ixPB1_PIF_PWRDOWN_1, data);
1618*b843c749SSergey Zigachev
1619*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL);
1620*b843c749SSergey Zigachev data &= ~PCIE_LC_LINK_WIDTH_CNTL__LC_DYN_LANES_PWR_STATE_MASK;
1621*b843c749SSergey Zigachev data |= ~(3 << PCIE_LC_LINK_WIDTH_CNTL__LC_DYN_LANES_PWR_STATE__SHIFT);
1622*b843c749SSergey Zigachev if (orig != data)
1623*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL, data);
1624*b843c749SSergey Zigachev
1625*b843c749SSergey Zigachev if (!disable_clkreq) {
1626*b843c749SSergey Zigachev struct pci_dev *root = adev->pdev->bus->self;
1627*b843c749SSergey Zigachev u32 lnkcap;
1628*b843c749SSergey Zigachev
1629*b843c749SSergey Zigachev clk_req_support = false;
1630*b843c749SSergey Zigachev pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap);
1631*b843c749SSergey Zigachev if (lnkcap & PCI_EXP_LNKCAP_CLKPM)
1632*b843c749SSergey Zigachev clk_req_support = true;
1633*b843c749SSergey Zigachev } else {
1634*b843c749SSergey Zigachev clk_req_support = false;
1635*b843c749SSergey Zigachev }
1636*b843c749SSergey Zigachev
1637*b843c749SSergey Zigachev if (clk_req_support) {
1638*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_LC_CNTL2);
1639*b843c749SSergey Zigachev data |= PCIE_LC_CNTL2__LC_ALLOW_PDWN_IN_L1_MASK |
1640*b843c749SSergey Zigachev PCIE_LC_CNTL2__LC_ALLOW_PDWN_IN_L23_MASK;
1641*b843c749SSergey Zigachev if (orig != data)
1642*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL2, data);
1643*b843c749SSergey Zigachev
1644*b843c749SSergey Zigachev orig = data = RREG32_SMC(ixTHM_CLK_CNTL);
1645*b843c749SSergey Zigachev data &= ~(THM_CLK_CNTL__CMON_CLK_SEL_MASK |
1646*b843c749SSergey Zigachev THM_CLK_CNTL__TMON_CLK_SEL_MASK);
1647*b843c749SSergey Zigachev data |= (1 << THM_CLK_CNTL__CMON_CLK_SEL__SHIFT) |
1648*b843c749SSergey Zigachev (1 << THM_CLK_CNTL__TMON_CLK_SEL__SHIFT);
1649*b843c749SSergey Zigachev if (orig != data)
1650*b843c749SSergey Zigachev WREG32_SMC(ixTHM_CLK_CNTL, data);
1651*b843c749SSergey Zigachev
1652*b843c749SSergey Zigachev orig = data = RREG32_SMC(ixMISC_CLK_CTRL);
1653*b843c749SSergey Zigachev data &= ~(MISC_CLK_CTRL__DEEP_SLEEP_CLK_SEL_MASK |
1654*b843c749SSergey Zigachev MISC_CLK_CTRL__ZCLK_SEL_MASK);
1655*b843c749SSergey Zigachev data |= (1 << MISC_CLK_CTRL__DEEP_SLEEP_CLK_SEL__SHIFT) |
1656*b843c749SSergey Zigachev (1 << MISC_CLK_CTRL__ZCLK_SEL__SHIFT);
1657*b843c749SSergey Zigachev if (orig != data)
1658*b843c749SSergey Zigachev WREG32_SMC(ixMISC_CLK_CTRL, data);
1659*b843c749SSergey Zigachev
1660*b843c749SSergey Zigachev orig = data = RREG32_SMC(ixCG_CLKPIN_CNTL);
1661*b843c749SSergey Zigachev data &= ~CG_CLKPIN_CNTL__BCLK_AS_XCLK_MASK;
1662*b843c749SSergey Zigachev if (orig != data)
1663*b843c749SSergey Zigachev WREG32_SMC(ixCG_CLKPIN_CNTL, data);
1664*b843c749SSergey Zigachev
1665*b843c749SSergey Zigachev orig = data = RREG32_SMC(ixCG_CLKPIN_CNTL_2);
1666*b843c749SSergey Zigachev data &= ~CG_CLKPIN_CNTL_2__FORCE_BIF_REFCLK_EN_MASK;
1667*b843c749SSergey Zigachev if (orig != data)
1668*b843c749SSergey Zigachev WREG32_SMC(ixCG_CLKPIN_CNTL_2, data);
1669*b843c749SSergey Zigachev
1670*b843c749SSergey Zigachev orig = data = RREG32_SMC(ixMPLL_BYPASSCLK_SEL);
1671*b843c749SSergey Zigachev data &= ~MPLL_BYPASSCLK_SEL__MPLL_CLKOUT_SEL_MASK;
1672*b843c749SSergey Zigachev data |= (4 << MPLL_BYPASSCLK_SEL__MPLL_CLKOUT_SEL__SHIFT);
1673*b843c749SSergey Zigachev if (orig != data)
1674*b843c749SSergey Zigachev WREG32_SMC(ixMPLL_BYPASSCLK_SEL, data);
1675*b843c749SSergey Zigachev }
1676*b843c749SSergey Zigachev }
1677*b843c749SSergey Zigachev } else {
1678*b843c749SSergey Zigachev if (orig != data)
1679*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL, data);
1680*b843c749SSergey Zigachev }
1681*b843c749SSergey Zigachev
1682*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_CNTL2);
1683*b843c749SSergey Zigachev data |= PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
1684*b843c749SSergey Zigachev PCIE_CNTL2__MST_MEM_LS_EN_MASK |
1685*b843c749SSergey Zigachev PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK;
1686*b843c749SSergey Zigachev if (orig != data)
1687*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_CNTL2, data);
1688*b843c749SSergey Zigachev
1689*b843c749SSergey Zigachev if (!disable_l0s) {
1690*b843c749SSergey Zigachev data = RREG32_PCIE(ixPCIE_LC_N_FTS_CNTL);
1691*b843c749SSergey Zigachev if ((data & PCIE_LC_N_FTS_CNTL__LC_N_FTS_MASK) ==
1692*b843c749SSergey Zigachev PCIE_LC_N_FTS_CNTL__LC_N_FTS_MASK) {
1693*b843c749SSergey Zigachev data = RREG32_PCIE(ixPCIE_LC_STATUS1);
1694*b843c749SSergey Zigachev if ((data & PCIE_LC_STATUS1__LC_REVERSE_XMIT_MASK) &&
1695*b843c749SSergey Zigachev (data & PCIE_LC_STATUS1__LC_REVERSE_RCVR_MASK)) {
1696*b843c749SSergey Zigachev orig = data = RREG32_PCIE(ixPCIE_LC_CNTL);
1697*b843c749SSergey Zigachev data &= ~PCIE_LC_CNTL__LC_L0S_INACTIVITY_MASK;
1698*b843c749SSergey Zigachev if (orig != data)
1699*b843c749SSergey Zigachev WREG32_PCIE(ixPCIE_LC_CNTL, data);
1700*b843c749SSergey Zigachev }
1701*b843c749SSergey Zigachev }
1702*b843c749SSergey Zigachev }
1703*b843c749SSergey Zigachev }
1704*b843c749SSergey Zigachev
cik_get_rev_id(struct amdgpu_device * adev)1705*b843c749SSergey Zigachev static uint32_t cik_get_rev_id(struct amdgpu_device *adev)
1706*b843c749SSergey Zigachev {
1707*b843c749SSergey Zigachev return (RREG32(mmCC_DRM_ID_STRAPS) & CC_DRM_ID_STRAPS__ATI_REV_ID_MASK)
1708*b843c749SSergey Zigachev >> CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT;
1709*b843c749SSergey Zigachev }
1710*b843c749SSergey Zigachev
cik_detect_hw_virtualization(struct amdgpu_device * adev)1711*b843c749SSergey Zigachev static void cik_detect_hw_virtualization(struct amdgpu_device *adev)
1712*b843c749SSergey Zigachev {
1713*b843c749SSergey Zigachev if (is_virtual_machine()) /* passthrough mode */
1714*b843c749SSergey Zigachev adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
1715*b843c749SSergey Zigachev }
1716*b843c749SSergey Zigachev
cik_flush_hdp(struct amdgpu_device * adev,struct amdgpu_ring * ring)1717*b843c749SSergey Zigachev static void cik_flush_hdp(struct amdgpu_device *adev, struct amdgpu_ring *ring)
1718*b843c749SSergey Zigachev {
1719*b843c749SSergey Zigachev if (!ring || !ring->funcs->emit_wreg) {
1720*b843c749SSergey Zigachev WREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1);
1721*b843c749SSergey Zigachev RREG32(mmHDP_MEM_COHERENCY_FLUSH_CNTL);
1722*b843c749SSergey Zigachev } else {
1723*b843c749SSergey Zigachev amdgpu_ring_emit_wreg(ring, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 1);
1724*b843c749SSergey Zigachev }
1725*b843c749SSergey Zigachev }
1726*b843c749SSergey Zigachev
cik_invalidate_hdp(struct amdgpu_device * adev,struct amdgpu_ring * ring)1727*b843c749SSergey Zigachev static void cik_invalidate_hdp(struct amdgpu_device *adev,
1728*b843c749SSergey Zigachev struct amdgpu_ring *ring)
1729*b843c749SSergey Zigachev {
1730*b843c749SSergey Zigachev if (!ring || !ring->funcs->emit_wreg) {
1731*b843c749SSergey Zigachev WREG32(mmHDP_DEBUG0, 1);
1732*b843c749SSergey Zigachev RREG32(mmHDP_DEBUG0);
1733*b843c749SSergey Zigachev } else {
1734*b843c749SSergey Zigachev amdgpu_ring_emit_wreg(ring, mmHDP_DEBUG0, 1);
1735*b843c749SSergey Zigachev }
1736*b843c749SSergey Zigachev }
1737*b843c749SSergey Zigachev
cik_need_full_reset(struct amdgpu_device * adev)1738*b843c749SSergey Zigachev static bool cik_need_full_reset(struct amdgpu_device *adev)
1739*b843c749SSergey Zigachev {
1740*b843c749SSergey Zigachev /* change this when we support soft reset */
1741*b843c749SSergey Zigachev return true;
1742*b843c749SSergey Zigachev }
1743*b843c749SSergey Zigachev
1744*b843c749SSergey Zigachev static const struct amdgpu_asic_funcs cik_asic_funcs =
1745*b843c749SSergey Zigachev {
1746*b843c749SSergey Zigachev .read_disabled_bios = &cik_read_disabled_bios,
1747*b843c749SSergey Zigachev .read_bios_from_rom = &cik_read_bios_from_rom,
1748*b843c749SSergey Zigachev .read_register = &cik_read_register,
1749*b843c749SSergey Zigachev .reset = &cik_asic_reset,
1750*b843c749SSergey Zigachev .set_vga_state = &cik_vga_set_state,
1751*b843c749SSergey Zigachev .get_xclk = &cik_get_xclk,
1752*b843c749SSergey Zigachev .set_uvd_clocks = &cik_set_uvd_clocks,
1753*b843c749SSergey Zigachev .set_vce_clocks = &cik_set_vce_clocks,
1754*b843c749SSergey Zigachev .get_config_memsize = &cik_get_config_memsize,
1755*b843c749SSergey Zigachev .flush_hdp = &cik_flush_hdp,
1756*b843c749SSergey Zigachev .invalidate_hdp = &cik_invalidate_hdp,
1757*b843c749SSergey Zigachev .need_full_reset = &cik_need_full_reset,
1758*b843c749SSergey Zigachev };
1759*b843c749SSergey Zigachev
cik_common_early_init(void * handle)1760*b843c749SSergey Zigachev static int cik_common_early_init(void *handle)
1761*b843c749SSergey Zigachev {
1762*b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1763*b843c749SSergey Zigachev
1764*b843c749SSergey Zigachev adev->smc_rreg = &cik_smc_rreg;
1765*b843c749SSergey Zigachev adev->smc_wreg = &cik_smc_wreg;
1766*b843c749SSergey Zigachev adev->pcie_rreg = &cik_pcie_rreg;
1767*b843c749SSergey Zigachev adev->pcie_wreg = &cik_pcie_wreg;
1768*b843c749SSergey Zigachev adev->uvd_ctx_rreg = &cik_uvd_ctx_rreg;
1769*b843c749SSergey Zigachev adev->uvd_ctx_wreg = &cik_uvd_ctx_wreg;
1770*b843c749SSergey Zigachev adev->didt_rreg = &cik_didt_rreg;
1771*b843c749SSergey Zigachev adev->didt_wreg = &cik_didt_wreg;
1772*b843c749SSergey Zigachev
1773*b843c749SSergey Zigachev adev->asic_funcs = &cik_asic_funcs;
1774*b843c749SSergey Zigachev
1775*b843c749SSergey Zigachev adev->rev_id = cik_get_rev_id(adev);
1776*b843c749SSergey Zigachev adev->external_rev_id = 0xFF;
1777*b843c749SSergey Zigachev switch (adev->asic_type) {
1778*b843c749SSergey Zigachev case CHIP_BONAIRE:
1779*b843c749SSergey Zigachev adev->cg_flags =
1780*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGCG |
1781*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGLS |
1782*b843c749SSergey Zigachev /*AMD_CG_SUPPORT_GFX_CGCG |*/
1783*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGLS |
1784*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS |
1785*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS_LS |
1786*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CP_LS |
1787*b843c749SSergey Zigachev AMD_CG_SUPPORT_MC_LS |
1788*b843c749SSergey Zigachev AMD_CG_SUPPORT_MC_MGCG |
1789*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_MGCG |
1790*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_LS |
1791*b843c749SSergey Zigachev AMD_CG_SUPPORT_BIF_LS |
1792*b843c749SSergey Zigachev AMD_CG_SUPPORT_VCE_MGCG |
1793*b843c749SSergey Zigachev AMD_CG_SUPPORT_UVD_MGCG |
1794*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_LS |
1795*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_MGCG;
1796*b843c749SSergey Zigachev adev->pg_flags = 0;
1797*b843c749SSergey Zigachev adev->external_rev_id = adev->rev_id + 0x14;
1798*b843c749SSergey Zigachev break;
1799*b843c749SSergey Zigachev case CHIP_HAWAII:
1800*b843c749SSergey Zigachev adev->cg_flags =
1801*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGCG |
1802*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGLS |
1803*b843c749SSergey Zigachev /*AMD_CG_SUPPORT_GFX_CGCG |*/
1804*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGLS |
1805*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS |
1806*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CP_LS |
1807*b843c749SSergey Zigachev AMD_CG_SUPPORT_MC_LS |
1808*b843c749SSergey Zigachev AMD_CG_SUPPORT_MC_MGCG |
1809*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_MGCG |
1810*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_LS |
1811*b843c749SSergey Zigachev AMD_CG_SUPPORT_BIF_LS |
1812*b843c749SSergey Zigachev AMD_CG_SUPPORT_VCE_MGCG |
1813*b843c749SSergey Zigachev AMD_CG_SUPPORT_UVD_MGCG |
1814*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_LS |
1815*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_MGCG;
1816*b843c749SSergey Zigachev adev->pg_flags = 0;
1817*b843c749SSergey Zigachev adev->external_rev_id = 0x28;
1818*b843c749SSergey Zigachev break;
1819*b843c749SSergey Zigachev case CHIP_KAVERI:
1820*b843c749SSergey Zigachev adev->cg_flags =
1821*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGCG |
1822*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGLS |
1823*b843c749SSergey Zigachev /*AMD_CG_SUPPORT_GFX_CGCG |*/
1824*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGLS |
1825*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS |
1826*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS_LS |
1827*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CP_LS |
1828*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_MGCG |
1829*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_LS |
1830*b843c749SSergey Zigachev AMD_CG_SUPPORT_BIF_LS |
1831*b843c749SSergey Zigachev AMD_CG_SUPPORT_VCE_MGCG |
1832*b843c749SSergey Zigachev AMD_CG_SUPPORT_UVD_MGCG |
1833*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_LS |
1834*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_MGCG;
1835*b843c749SSergey Zigachev adev->pg_flags =
1836*b843c749SSergey Zigachev /*AMD_PG_SUPPORT_GFX_PG |
1837*b843c749SSergey Zigachev AMD_PG_SUPPORT_GFX_SMG |
1838*b843c749SSergey Zigachev AMD_PG_SUPPORT_GFX_DMG |*/
1839*b843c749SSergey Zigachev AMD_PG_SUPPORT_UVD |
1840*b843c749SSergey Zigachev AMD_PG_SUPPORT_VCE |
1841*b843c749SSergey Zigachev /* AMD_PG_SUPPORT_CP |
1842*b843c749SSergey Zigachev AMD_PG_SUPPORT_GDS |
1843*b843c749SSergey Zigachev AMD_PG_SUPPORT_RLC_SMU_HS |
1844*b843c749SSergey Zigachev AMD_PG_SUPPORT_ACP |
1845*b843c749SSergey Zigachev AMD_PG_SUPPORT_SAMU |*/
1846*b843c749SSergey Zigachev 0;
1847*b843c749SSergey Zigachev if (adev->pdev->device == 0x1312 ||
1848*b843c749SSergey Zigachev adev->pdev->device == 0x1316 ||
1849*b843c749SSergey Zigachev adev->pdev->device == 0x1317)
1850*b843c749SSergey Zigachev adev->external_rev_id = 0x41;
1851*b843c749SSergey Zigachev else
1852*b843c749SSergey Zigachev adev->external_rev_id = 0x1;
1853*b843c749SSergey Zigachev break;
1854*b843c749SSergey Zigachev case CHIP_KABINI:
1855*b843c749SSergey Zigachev case CHIP_MULLINS:
1856*b843c749SSergey Zigachev adev->cg_flags =
1857*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGCG |
1858*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_MGLS |
1859*b843c749SSergey Zigachev /*AMD_CG_SUPPORT_GFX_CGCG |*/
1860*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGLS |
1861*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS |
1862*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CGTS_LS |
1863*b843c749SSergey Zigachev AMD_CG_SUPPORT_GFX_CP_LS |
1864*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_MGCG |
1865*b843c749SSergey Zigachev AMD_CG_SUPPORT_SDMA_LS |
1866*b843c749SSergey Zigachev AMD_CG_SUPPORT_BIF_LS |
1867*b843c749SSergey Zigachev AMD_CG_SUPPORT_VCE_MGCG |
1868*b843c749SSergey Zigachev AMD_CG_SUPPORT_UVD_MGCG |
1869*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_LS |
1870*b843c749SSergey Zigachev AMD_CG_SUPPORT_HDP_MGCG;
1871*b843c749SSergey Zigachev adev->pg_flags =
1872*b843c749SSergey Zigachev /*AMD_PG_SUPPORT_GFX_PG |
1873*b843c749SSergey Zigachev AMD_PG_SUPPORT_GFX_SMG | */
1874*b843c749SSergey Zigachev AMD_PG_SUPPORT_UVD |
1875*b843c749SSergey Zigachev /*AMD_PG_SUPPORT_VCE |
1876*b843c749SSergey Zigachev AMD_PG_SUPPORT_CP |
1877*b843c749SSergey Zigachev AMD_PG_SUPPORT_GDS |
1878*b843c749SSergey Zigachev AMD_PG_SUPPORT_RLC_SMU_HS |
1879*b843c749SSergey Zigachev AMD_PG_SUPPORT_SAMU |*/
1880*b843c749SSergey Zigachev 0;
1881*b843c749SSergey Zigachev if (adev->asic_type == CHIP_KABINI) {
1882*b843c749SSergey Zigachev if (adev->rev_id == 0)
1883*b843c749SSergey Zigachev adev->external_rev_id = 0x81;
1884*b843c749SSergey Zigachev else if (adev->rev_id == 1)
1885*b843c749SSergey Zigachev adev->external_rev_id = 0x82;
1886*b843c749SSergey Zigachev else if (adev->rev_id == 2)
1887*b843c749SSergey Zigachev adev->external_rev_id = 0x85;
1888*b843c749SSergey Zigachev } else
1889*b843c749SSergey Zigachev adev->external_rev_id = adev->rev_id + 0xa1;
1890*b843c749SSergey Zigachev break;
1891*b843c749SSergey Zigachev default:
1892*b843c749SSergey Zigachev /* FIXME: not supported yet */
1893*b843c749SSergey Zigachev return -EINVAL;
1894*b843c749SSergey Zigachev }
1895*b843c749SSergey Zigachev
1896*b843c749SSergey Zigachev return 0;
1897*b843c749SSergey Zigachev }
1898*b843c749SSergey Zigachev
cik_common_sw_init(void * handle)1899*b843c749SSergey Zigachev static int cik_common_sw_init(void *handle)
1900*b843c749SSergey Zigachev {
1901*b843c749SSergey Zigachev return 0;
1902*b843c749SSergey Zigachev }
1903*b843c749SSergey Zigachev
cik_common_sw_fini(void * handle)1904*b843c749SSergey Zigachev static int cik_common_sw_fini(void *handle)
1905*b843c749SSergey Zigachev {
1906*b843c749SSergey Zigachev return 0;
1907*b843c749SSergey Zigachev }
1908*b843c749SSergey Zigachev
cik_common_hw_init(void * handle)1909*b843c749SSergey Zigachev static int cik_common_hw_init(void *handle)
1910*b843c749SSergey Zigachev {
1911*b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1912*b843c749SSergey Zigachev
1913*b843c749SSergey Zigachev /* move the golden regs per IP block */
1914*b843c749SSergey Zigachev cik_init_golden_registers(adev);
1915*b843c749SSergey Zigachev /* enable pcie gen2/3 link */
1916*b843c749SSergey Zigachev cik_pcie_gen3_enable(adev);
1917*b843c749SSergey Zigachev /* enable aspm */
1918*b843c749SSergey Zigachev cik_program_aspm(adev);
1919*b843c749SSergey Zigachev
1920*b843c749SSergey Zigachev return 0;
1921*b843c749SSergey Zigachev }
1922*b843c749SSergey Zigachev
cik_common_hw_fini(void * handle)1923*b843c749SSergey Zigachev static int cik_common_hw_fini(void *handle)
1924*b843c749SSergey Zigachev {
1925*b843c749SSergey Zigachev return 0;
1926*b843c749SSergey Zigachev }
1927*b843c749SSergey Zigachev
cik_common_suspend(void * handle)1928*b843c749SSergey Zigachev static int cik_common_suspend(void *handle)
1929*b843c749SSergey Zigachev {
1930*b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1931*b843c749SSergey Zigachev
1932*b843c749SSergey Zigachev return cik_common_hw_fini(adev);
1933*b843c749SSergey Zigachev }
1934*b843c749SSergey Zigachev
cik_common_resume(void * handle)1935*b843c749SSergey Zigachev static int cik_common_resume(void *handle)
1936*b843c749SSergey Zigachev {
1937*b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1938*b843c749SSergey Zigachev
1939*b843c749SSergey Zigachev return cik_common_hw_init(adev);
1940*b843c749SSergey Zigachev }
1941*b843c749SSergey Zigachev
cik_common_is_idle(void * handle)1942*b843c749SSergey Zigachev static bool cik_common_is_idle(void *handle)
1943*b843c749SSergey Zigachev {
1944*b843c749SSergey Zigachev return true;
1945*b843c749SSergey Zigachev }
1946*b843c749SSergey Zigachev
cik_common_wait_for_idle(void * handle)1947*b843c749SSergey Zigachev static int cik_common_wait_for_idle(void *handle)
1948*b843c749SSergey Zigachev {
1949*b843c749SSergey Zigachev return 0;
1950*b843c749SSergey Zigachev }
1951*b843c749SSergey Zigachev
cik_common_soft_reset(void * handle)1952*b843c749SSergey Zigachev static int cik_common_soft_reset(void *handle)
1953*b843c749SSergey Zigachev {
1954*b843c749SSergey Zigachev /* XXX hard reset?? */
1955*b843c749SSergey Zigachev return 0;
1956*b843c749SSergey Zigachev }
1957*b843c749SSergey Zigachev
cik_common_set_clockgating_state(void * handle,enum amd_clockgating_state state)1958*b843c749SSergey Zigachev static int cik_common_set_clockgating_state(void *handle,
1959*b843c749SSergey Zigachev enum amd_clockgating_state state)
1960*b843c749SSergey Zigachev {
1961*b843c749SSergey Zigachev return 0;
1962*b843c749SSergey Zigachev }
1963*b843c749SSergey Zigachev
cik_common_set_powergating_state(void * handle,enum amd_powergating_state state)1964*b843c749SSergey Zigachev static int cik_common_set_powergating_state(void *handle,
1965*b843c749SSergey Zigachev enum amd_powergating_state state)
1966*b843c749SSergey Zigachev {
1967*b843c749SSergey Zigachev return 0;
1968*b843c749SSergey Zigachev }
1969*b843c749SSergey Zigachev
1970*b843c749SSergey Zigachev static const struct amd_ip_funcs cik_common_ip_funcs = {
1971*b843c749SSergey Zigachev .name = "cik_common",
1972*b843c749SSergey Zigachev .early_init = cik_common_early_init,
1973*b843c749SSergey Zigachev .late_init = NULL,
1974*b843c749SSergey Zigachev .sw_init = cik_common_sw_init,
1975*b843c749SSergey Zigachev .sw_fini = cik_common_sw_fini,
1976*b843c749SSergey Zigachev .hw_init = cik_common_hw_init,
1977*b843c749SSergey Zigachev .hw_fini = cik_common_hw_fini,
1978*b843c749SSergey Zigachev .suspend = cik_common_suspend,
1979*b843c749SSergey Zigachev .resume = cik_common_resume,
1980*b843c749SSergey Zigachev .is_idle = cik_common_is_idle,
1981*b843c749SSergey Zigachev .wait_for_idle = cik_common_wait_for_idle,
1982*b843c749SSergey Zigachev .soft_reset = cik_common_soft_reset,
1983*b843c749SSergey Zigachev .set_clockgating_state = cik_common_set_clockgating_state,
1984*b843c749SSergey Zigachev .set_powergating_state = cik_common_set_powergating_state,
1985*b843c749SSergey Zigachev };
1986*b843c749SSergey Zigachev
1987*b843c749SSergey Zigachev static const struct amdgpu_ip_block_version cik_common_ip_block =
1988*b843c749SSergey Zigachev {
1989*b843c749SSergey Zigachev .type = AMD_IP_BLOCK_TYPE_COMMON,
1990*b843c749SSergey Zigachev .major = 1,
1991*b843c749SSergey Zigachev .minor = 0,
1992*b843c749SSergey Zigachev .rev = 0,
1993*b843c749SSergey Zigachev .funcs = &cik_common_ip_funcs,
1994*b843c749SSergey Zigachev };
1995*b843c749SSergey Zigachev
cik_set_ip_blocks(struct amdgpu_device * adev)1996*b843c749SSergey Zigachev int cik_set_ip_blocks(struct amdgpu_device *adev)
1997*b843c749SSergey Zigachev {
1998*b843c749SSergey Zigachev cik_detect_hw_virtualization(adev);
1999*b843c749SSergey Zigachev
2000*b843c749SSergey Zigachev switch (adev->asic_type) {
2001*b843c749SSergey Zigachev case CHIP_BONAIRE:
2002*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_common_ip_block);
2003*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block);
2004*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_ih_ip_block);
2005*b843c749SSergey Zigachev if (amdgpu_dpm == -1)
2006*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
2007*b843c749SSergey Zigachev else
2008*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &ci_smu_ip_block);
2009*b843c749SSergey Zigachev if (adev->enable_virtual_display)
2010*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
2011*b843c749SSergey Zigachev #if defined(CONFIG_DRM_AMD_DC)
2012*b843c749SSergey Zigachev else if (amdgpu_device_has_dc_support(adev))
2013*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dm_ip_block);
2014*b843c749SSergey Zigachev #endif
2015*b843c749SSergey Zigachev else
2016*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_v8_2_ip_block);
2017*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block);
2018*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block);
2019*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block);
2020*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block);
2021*b843c749SSergey Zigachev break;
2022*b843c749SSergey Zigachev case CHIP_HAWAII:
2023*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_common_ip_block);
2024*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block);
2025*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_ih_ip_block);
2026*b843c749SSergey Zigachev if (amdgpu_dpm == -1)
2027*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
2028*b843c749SSergey Zigachev else
2029*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &ci_smu_ip_block);
2030*b843c749SSergey Zigachev if (adev->enable_virtual_display)
2031*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
2032*b843c749SSergey Zigachev #if defined(CONFIG_DRM_AMD_DC)
2033*b843c749SSergey Zigachev else if (amdgpu_device_has_dc_support(adev))
2034*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dm_ip_block);
2035*b843c749SSergey Zigachev #endif
2036*b843c749SSergey Zigachev else
2037*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_v8_5_ip_block);
2038*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gfx_v7_3_ip_block);
2039*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block);
2040*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block);
2041*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block);
2042*b843c749SSergey Zigachev break;
2043*b843c749SSergey Zigachev case CHIP_KAVERI:
2044*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_common_ip_block);
2045*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block);
2046*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_ih_ip_block);
2047*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &kv_smu_ip_block);
2048*b843c749SSergey Zigachev if (adev->enable_virtual_display)
2049*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
2050*b843c749SSergey Zigachev #if defined(CONFIG_DRM_AMD_DC)
2051*b843c749SSergey Zigachev else if (amdgpu_device_has_dc_support(adev))
2052*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dm_ip_block);
2053*b843c749SSergey Zigachev #endif
2054*b843c749SSergey Zigachev else
2055*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_v8_1_ip_block);
2056*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gfx_v7_1_ip_block);
2057*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block);
2058*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block);
2059*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block);
2060*b843c749SSergey Zigachev break;
2061*b843c749SSergey Zigachev case CHIP_KABINI:
2062*b843c749SSergey Zigachev case CHIP_MULLINS:
2063*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_common_ip_block);
2064*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block);
2065*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_ih_ip_block);
2066*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &kv_smu_ip_block);
2067*b843c749SSergey Zigachev if (adev->enable_virtual_display)
2068*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
2069*b843c749SSergey Zigachev #if defined(CONFIG_DRM_AMD_DC)
2070*b843c749SSergey Zigachev else if (amdgpu_device_has_dc_support(adev))
2071*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dm_ip_block);
2072*b843c749SSergey Zigachev #endif
2073*b843c749SSergey Zigachev else
2074*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &dce_v8_3_ip_block);
2075*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block);
2076*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block);
2077*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block);
2078*b843c749SSergey Zigachev amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block);
2079*b843c749SSergey Zigachev break;
2080*b843c749SSergey Zigachev default:
2081*b843c749SSergey Zigachev /* FIXME: not supported yet */
2082*b843c749SSergey Zigachev return -EINVAL;
2083*b843c749SSergey Zigachev }
2084*b843c749SSergey Zigachev return 0;
2085*b843c749SSergey Zigachev }
2086