blob: da2b99c2d95f06953d285b0e6bbd4093e768f423 [file] [log] [blame]
Alex Deucheraaa36a92015-04-20 17:31:14 -04001/*
2 * Copyright 2014 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
Alex Deucheraaa36a92015-04-20 17:31:14 -040023#include <linux/slab.h>
Masahiro Yamada248a1d62017-04-24 13:50:21 +090024#include <drm/drmP.h>
Alex Deucheraaa36a92015-04-20 17:31:14 -040025#include "amdgpu.h"
26#include "amdgpu_atombios.h"
27#include "amdgpu_ih.h"
28#include "amdgpu_uvd.h"
29#include "amdgpu_vce.h"
30#include "amdgpu_ucode.h"
31#include "atom.h"
Alex Deucherd0dd7f02015-11-11 19:45:06 -050032#include "amd_pcie.h"
Alex Deucheraaa36a92015-04-20 17:31:14 -040033
34#include "gmc/gmc_8_1_d.h"
35#include "gmc/gmc_8_1_sh_mask.h"
36
37#include "oss/oss_3_0_d.h"
38#include "oss/oss_3_0_sh_mask.h"
39
40#include "bif/bif_5_0_d.h"
41#include "bif/bif_5_0_sh_mask.h"
42
43#include "gca/gfx_8_0_d.h"
44#include "gca/gfx_8_0_sh_mask.h"
45
46#include "smu/smu_7_1_1_d.h"
47#include "smu/smu_7_1_1_sh_mask.h"
48
49#include "uvd/uvd_5_0_d.h"
50#include "uvd/uvd_5_0_sh_mask.h"
51
52#include "vce/vce_3_0_d.h"
53#include "vce/vce_3_0_sh_mask.h"
54
55#include "dce/dce_10_0_d.h"
56#include "dce/dce_10_0_sh_mask.h"
57
58#include "vid.h"
59#include "vi.h"
60#include "vi_dpm.h"
61#include "gmc_v8_0.h"
Ken Wang429c45d2016-02-03 19:16:54 +080062#include "gmc_v7_0.h"
Alex Deucheraaa36a92015-04-20 17:31:14 -040063#include "gfx_v8_0.h"
64#include "sdma_v2_4.h"
65#include "sdma_v3_0.h"
66#include "dce_v10_0.h"
67#include "dce_v11_0.h"
68#include "iceland_ih.h"
69#include "tonga_ih.h"
70#include "cz_ih.h"
71#include "uvd_v5_0.h"
72#include "uvd_v6_0.h"
73#include "vce_v3_0.h"
Alex Deucher1f7371b2015-12-02 17:46:21 -050074#include "amdgpu_powerplay.h"
Maruthi Bayyavarapua8fe58c2015-09-22 17:05:20 -040075#if defined(CONFIG_DRM_AMD_ACP)
76#include "amdgpu_acp.h"
77#endif
Emily Denge9ed3a62016-08-08 11:36:45 +080078#include "dce_virtual.h"
Xiangliang Yu99581cc2017-01-12 15:22:18 +080079#include "mxgpu_vi.h"
Harry Wentland45622362017-09-12 15:58:20 -040080#include "amdgpu_dm.h"
Alex Deucheraaa36a92015-04-20 17:31:14 -040081
82/*
83 * Indirect registers accessor
84 */
85static u32 vi_pcie_rreg(struct amdgpu_device *adev, u32 reg)
86{
87 unsigned long flags;
88 u32 r;
89
90 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
91 WREG32(mmPCIE_INDEX, reg);
92 (void)RREG32(mmPCIE_INDEX);
93 r = RREG32(mmPCIE_DATA);
94 spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
95 return r;
96}
97
98static void vi_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
99{
100 unsigned long flags;
101
102 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
103 WREG32(mmPCIE_INDEX, reg);
104 (void)RREG32(mmPCIE_INDEX);
105 WREG32(mmPCIE_DATA, v);
106 (void)RREG32(mmPCIE_DATA);
107 spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
108}
109
110static u32 vi_smc_rreg(struct amdgpu_device *adev, u32 reg)
111{
112 unsigned long flags;
113 u32 r;
114
115 spin_lock_irqsave(&adev->smc_idx_lock, flags);
Monk Liu4bc10d12016-03-29 11:01:51 +0800116 WREG32(mmSMC_IND_INDEX_11, (reg));
117 r = RREG32(mmSMC_IND_DATA_11);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400118 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
119 return r;
120}
121
122static void vi_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
123{
124 unsigned long flags;
125
126 spin_lock_irqsave(&adev->smc_idx_lock, flags);
Monk Liu4bc10d12016-03-29 11:01:51 +0800127 WREG32(mmSMC_IND_INDEX_11, (reg));
128 WREG32(mmSMC_IND_DATA_11, (v));
Alex Deucheraaa36a92015-04-20 17:31:14 -0400129 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
130}
131
Alex Deucher7b92cdb2015-07-10 16:21:10 -0400132/* smu_8_0_d.h */
133#define mmMP0PUB_IND_INDEX 0x180
134#define mmMP0PUB_IND_DATA 0x181
135
136static u32 cz_smc_rreg(struct amdgpu_device *adev, u32 reg)
137{
138 unsigned long flags;
139 u32 r;
140
141 spin_lock_irqsave(&adev->smc_idx_lock, flags);
142 WREG32(mmMP0PUB_IND_INDEX, (reg));
143 r = RREG32(mmMP0PUB_IND_DATA);
144 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
145 return r;
146}
147
148static void cz_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
149{
150 unsigned long flags;
151
152 spin_lock_irqsave(&adev->smc_idx_lock, flags);
153 WREG32(mmMP0PUB_IND_INDEX, (reg));
154 WREG32(mmMP0PUB_IND_DATA, (v));
155 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
156}
157
Alex Deucheraaa36a92015-04-20 17:31:14 -0400158static u32 vi_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
159{
160 unsigned long flags;
161 u32 r;
162
163 spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
164 WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
165 r = RREG32(mmUVD_CTX_DATA);
166 spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
167 return r;
168}
169
170static void vi_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
171{
172 unsigned long flags;
173
174 spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
175 WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
176 WREG32(mmUVD_CTX_DATA, (v));
177 spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
178}
179
180static u32 vi_didt_rreg(struct amdgpu_device *adev, u32 reg)
181{
182 unsigned long flags;
183 u32 r;
184
185 spin_lock_irqsave(&adev->didt_idx_lock, flags);
186 WREG32(mmDIDT_IND_INDEX, (reg));
187 r = RREG32(mmDIDT_IND_DATA);
188 spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
189 return r;
190}
191
192static void vi_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
193{
194 unsigned long flags;
195
196 spin_lock_irqsave(&adev->didt_idx_lock, flags);
197 WREG32(mmDIDT_IND_INDEX, (reg));
198 WREG32(mmDIDT_IND_DATA, (v));
199 spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
200}
201
Rex Zhuccdbb202016-06-08 12:47:41 +0800202static u32 vi_gc_cac_rreg(struct amdgpu_device *adev, u32 reg)
203{
204 unsigned long flags;
205 u32 r;
206
207 spin_lock_irqsave(&adev->gc_cac_idx_lock, flags);
208 WREG32(mmGC_CAC_IND_INDEX, (reg));
209 r = RREG32(mmGC_CAC_IND_DATA);
210 spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags);
211 return r;
212}
213
214static void vi_gc_cac_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
215{
216 unsigned long flags;
217
218 spin_lock_irqsave(&adev->gc_cac_idx_lock, flags);
219 WREG32(mmGC_CAC_IND_INDEX, (reg));
220 WREG32(mmGC_CAC_IND_DATA, (v));
221 spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags);
222}
223
224
Alex Deucheraaa36a92015-04-20 17:31:14 -0400225static const u32 tonga_mgcg_cgcg_init[] =
226{
227 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100,
228 mmPCIE_INDEX, 0xffffffff, 0x0140001c,
229 mmPCIE_DATA, 0x000f0000, 0x00000000,
230 mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C,
231 mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400232 mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100,
233 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
234};
235
David Zhang48299f92015-07-08 01:05:16 +0800236static const u32 fiji_mgcg_cgcg_init[] =
237{
238 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100,
239 mmPCIE_INDEX, 0xffffffff, 0x0140001c,
240 mmPCIE_DATA, 0x000f0000, 0x00000000,
241 mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C,
242 mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100,
243 mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100,
244 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
245};
246
Alex Deucheraaa36a92015-04-20 17:31:14 -0400247static const u32 iceland_mgcg_cgcg_init[] =
248{
249 mmPCIE_INDEX, 0xffffffff, ixPCIE_CNTL2,
250 mmPCIE_DATA, 0x000f0000, 0x00000000,
251 mmSMC_IND_INDEX_4, 0xffffffff, ixCGTT_ROM_CLK_CTRL0,
252 mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100,
253 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
254};
255
256static const u32 cz_mgcg_cgcg_init[] =
257{
258 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100,
259 mmPCIE_INDEX, 0xffffffff, 0x0140001c,
260 mmPCIE_DATA, 0x000f0000, 0x00000000,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400261 mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100,
262 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
263};
264
Samuel Li39bb0c92015-10-08 16:31:43 -0400265static const u32 stoney_mgcg_cgcg_init[] =
266{
267 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00000100,
268 mmHDP_XDP_CGTT_BLK_CTRL, 0xffffffff, 0x00000104,
269 mmHDP_HOST_PATH_CNTL, 0xffffffff, 0x0f000027,
270};
271
Alex Deucheraaa36a92015-04-20 17:31:14 -0400272static void vi_init_golden_registers(struct amdgpu_device *adev)
273{
274 /* Some of the registers might be dependent on GRBM_GFX_INDEX */
275 mutex_lock(&adev->grbm_idx_mutex);
276
Xiangliang Yu99581cc2017-01-12 15:22:18 +0800277 if (amdgpu_sriov_vf(adev)) {
278 xgpu_vi_init_golden_registers(adev);
279 mutex_unlock(&adev->grbm_idx_mutex);
280 return;
281 }
282
Alex Deucheraaa36a92015-04-20 17:31:14 -0400283 switch (adev->asic_type) {
284 case CHIP_TOPAZ:
Alex Deucher9c3f2b52017-12-14 16:20:19 -0500285 amdgpu_device_program_register_sequence(adev,
286 iceland_mgcg_cgcg_init,
287 ARRAY_SIZE(iceland_mgcg_cgcg_init));
Alex Deucheraaa36a92015-04-20 17:31:14 -0400288 break;
David Zhang48299f92015-07-08 01:05:16 +0800289 case CHIP_FIJI:
Alex Deucher9c3f2b52017-12-14 16:20:19 -0500290 amdgpu_device_program_register_sequence(adev,
291 fiji_mgcg_cgcg_init,
292 ARRAY_SIZE(fiji_mgcg_cgcg_init));
David Zhang48299f92015-07-08 01:05:16 +0800293 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400294 case CHIP_TONGA:
Alex Deucher9c3f2b52017-12-14 16:20:19 -0500295 amdgpu_device_program_register_sequence(adev,
296 tonga_mgcg_cgcg_init,
297 ARRAY_SIZE(tonga_mgcg_cgcg_init));
Alex Deucheraaa36a92015-04-20 17:31:14 -0400298 break;
299 case CHIP_CARRIZO:
Alex Deucher9c3f2b52017-12-14 16:20:19 -0500300 amdgpu_device_program_register_sequence(adev,
301 cz_mgcg_cgcg_init,
302 ARRAY_SIZE(cz_mgcg_cgcg_init));
Alex Deucheraaa36a92015-04-20 17:31:14 -0400303 break;
Samuel Li39bb0c92015-10-08 16:31:43 -0400304 case CHIP_STONEY:
Alex Deucher9c3f2b52017-12-14 16:20:19 -0500305 amdgpu_device_program_register_sequence(adev,
306 stoney_mgcg_cgcg_init,
307 ARRAY_SIZE(stoney_mgcg_cgcg_init));
Samuel Li39bb0c92015-10-08 16:31:43 -0400308 break;
Flora Cui2cc0c0b2016-03-14 18:33:29 -0400309 case CHIP_POLARIS11:
310 case CHIP_POLARIS10:
Junwei Zhangc4642a42016-12-14 15:32:28 -0500311 case CHIP_POLARIS12:
Alex Deucheraaa36a92015-04-20 17:31:14 -0400312 default:
313 break;
314 }
315 mutex_unlock(&adev->grbm_idx_mutex);
316}
317
318/**
319 * vi_get_xclk - get the xclk
320 *
321 * @adev: amdgpu_device pointer
322 *
323 * Returns the reference clock used by the gfx engine
324 * (VI).
325 */
326static u32 vi_get_xclk(struct amdgpu_device *adev)
327{
328 u32 reference_clock = adev->clock.spll.reference_freq;
329 u32 tmp;
330
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800331 if (adev->flags & AMD_IS_APU)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400332 return reference_clock;
333
334 tmp = RREG32_SMC(ixCG_CLKPIN_CNTL_2);
335 if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL_2, MUX_TCLK_TO_XCLK))
336 return 1000;
337
338 tmp = RREG32_SMC(ixCG_CLKPIN_CNTL);
339 if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL, XTALIN_DIVIDE))
340 return reference_clock / 4;
341
342 return reference_clock;
343}
344
345/**
346 * vi_srbm_select - select specific register instances
347 *
348 * @adev: amdgpu_device pointer
349 * @me: selected ME (micro engine)
350 * @pipe: pipe
351 * @queue: queue
352 * @vmid: VMID
353 *
354 * Switches the currently active registers instances. Some
355 * registers are instanced per VMID, others are instanced per
356 * me/pipe/queue combination.
357 */
358void vi_srbm_select(struct amdgpu_device *adev,
359 u32 me, u32 pipe, u32 queue, u32 vmid)
360{
361 u32 srbm_gfx_cntl = 0;
362 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, PIPEID, pipe);
363 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, MEID, me);
364 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, VMID, vmid);
365 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, QUEUEID, queue);
366 WREG32(mmSRBM_GFX_CNTL, srbm_gfx_cntl);
367}
368
369static void vi_vga_set_state(struct amdgpu_device *adev, bool state)
370{
371 /* todo */
372}
373
374static bool vi_read_disabled_bios(struct amdgpu_device *adev)
375{
376 u32 bus_cntl;
377 u32 d1vga_control = 0;
378 u32 d2vga_control = 0;
379 u32 vga_render_control = 0;
380 u32 rom_cntl;
381 bool r;
382
383 bus_cntl = RREG32(mmBUS_CNTL);
384 if (adev->mode_info.num_crtc) {
385 d1vga_control = RREG32(mmD1VGA_CONTROL);
386 d2vga_control = RREG32(mmD2VGA_CONTROL);
387 vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
388 }
389 rom_cntl = RREG32_SMC(ixROM_CNTL);
390
391 /* enable the rom */
392 WREG32(mmBUS_CNTL, (bus_cntl & ~BUS_CNTL__BIOS_ROM_DIS_MASK));
393 if (adev->mode_info.num_crtc) {
394 /* Disable VGA mode */
395 WREG32(mmD1VGA_CONTROL,
396 (d1vga_control & ~(D1VGA_CONTROL__D1VGA_MODE_ENABLE_MASK |
397 D1VGA_CONTROL__D1VGA_TIMING_SELECT_MASK)));
398 WREG32(mmD2VGA_CONTROL,
399 (d2vga_control & ~(D2VGA_CONTROL__D2VGA_MODE_ENABLE_MASK |
400 D2VGA_CONTROL__D2VGA_TIMING_SELECT_MASK)));
401 WREG32(mmVGA_RENDER_CONTROL,
402 (vga_render_control & ~VGA_RENDER_CONTROL__VGA_VSTATUS_CNTL_MASK));
403 }
404 WREG32_SMC(ixROM_CNTL, rom_cntl | ROM_CNTL__SCK_OVERWRITE_MASK);
405
406 r = amdgpu_read_bios(adev);
407
408 /* restore regs */
409 WREG32(mmBUS_CNTL, bus_cntl);
410 if (adev->mode_info.num_crtc) {
411 WREG32(mmD1VGA_CONTROL, d1vga_control);
412 WREG32(mmD2VGA_CONTROL, d2vga_control);
413 WREG32(mmVGA_RENDER_CONTROL, vga_render_control);
414 }
415 WREG32_SMC(ixROM_CNTL, rom_cntl);
416 return r;
417}
Alex Deucher95addb2a2015-11-24 10:37:54 -0500418
419static bool vi_read_bios_from_rom(struct amdgpu_device *adev,
420 u8 *bios, u32 length_bytes)
421{
422 u32 *dw_ptr;
423 unsigned long flags;
424 u32 i, length_dw;
425
426 if (bios == NULL)
427 return false;
428 if (length_bytes == 0)
429 return false;
430 /* APU vbios image is part of sbios image */
431 if (adev->flags & AMD_IS_APU)
432 return false;
433
434 dw_ptr = (u32 *)bios;
435 length_dw = ALIGN(length_bytes, 4) / 4;
436 /* take the smc lock since we are using the smc index */
437 spin_lock_irqsave(&adev->smc_idx_lock, flags);
438 /* set rom index to 0 */
Monk Liu4bc10d12016-03-29 11:01:51 +0800439 WREG32(mmSMC_IND_INDEX_11, ixROM_INDEX);
440 WREG32(mmSMC_IND_DATA_11, 0);
Alex Deucher95addb2a2015-11-24 10:37:54 -0500441 /* set index to data for continous read */
Monk Liu4bc10d12016-03-29 11:01:51 +0800442 WREG32(mmSMC_IND_INDEX_11, ixROM_DATA);
Alex Deucher95addb2a2015-11-24 10:37:54 -0500443 for (i = 0; i < length_dw; i++)
Monk Liu4bc10d12016-03-29 11:01:51 +0800444 dw_ptr[i] = RREG32(mmSMC_IND_DATA_11);
Alex Deucher95addb2a2015-11-24 10:37:54 -0500445 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
446
447 return true;
448}
449
Monk Liu4e99a442016-03-31 13:26:59 +0800450static void vi_detect_hw_virtualization(struct amdgpu_device *adev)
Andres Rodriguez048765a2016-06-11 02:51:32 -0400451{
Alex Deucher57ad33a2017-12-19 09:52:31 -0500452 uint32_t reg = 0;
Andres Rodriguez048765a2016-06-11 02:51:32 -0400453
Alex Deucher57ad33a2017-12-19 09:52:31 -0500454 if (adev->asic_type == CHIP_TONGA ||
455 adev->asic_type == CHIP_FIJI) {
456 reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER);
457 /* bit0: 0 means pf and 1 means vf */
Alex Deucher04a0d2d2017-12-19 09:57:53 -0500458 if (REG_GET_FIELD(reg, BIF_IOV_FUNC_IDENTIFIER, FUNC_IDENTIFIER))
Alex Deucher57ad33a2017-12-19 09:52:31 -0500459 adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF;
Alex Deucher04a0d2d2017-12-19 09:57:53 -0500460 /* bit31: 0 means disable IOV and 1 means enable */
461 if (REG_GET_FIELD(reg, BIF_IOV_FUNC_IDENTIFIER, IOV_ENABLE))
Alex Deucher57ad33a2017-12-19 09:52:31 -0500462 adev->virt.caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV;
463 }
Andres Rodriguez048765a2016-06-11 02:51:32 -0400464
Monk Liu4e99a442016-03-31 13:26:59 +0800465 if (reg == 0) {
466 if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */
Xiangliang Yu5a5099c2017-01-09 18:06:57 -0500467 adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
Monk Liu4e99a442016-03-31 13:26:59 +0800468 }
Andres Rodriguez048765a2016-06-11 02:51:32 -0400469}
470
Nils Wallméniuseca22402016-03-19 16:12:17 +0100471static const struct amdgpu_allowed_register_entry vi_allowed_read_registers[] = {
Christian König97fcc762017-04-12 12:49:54 +0200472 {mmGRBM_STATUS},
473 {mmGRBM_STATUS2},
474 {mmGRBM_STATUS_SE0},
475 {mmGRBM_STATUS_SE1},
476 {mmGRBM_STATUS_SE2},
477 {mmGRBM_STATUS_SE3},
478 {mmSRBM_STATUS},
479 {mmSRBM_STATUS2},
480 {mmSRBM_STATUS3},
481 {mmSDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET},
482 {mmSDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET},
483 {mmCP_STAT},
484 {mmCP_STALLED_STAT1},
485 {mmCP_STALLED_STAT2},
486 {mmCP_STALLED_STAT3},
487 {mmCP_CPF_BUSY_STAT},
488 {mmCP_CPF_STALLED_STAT1},
489 {mmCP_CPF_STATUS},
490 {mmCP_CPC_BUSY_STAT},
491 {mmCP_CPC_STALLED_STAT1},
492 {mmCP_CPC_STATUS},
493 {mmGB_ADDR_CONFIG},
494 {mmMC_ARB_RAMCFG},
495 {mmGB_TILE_MODE0},
496 {mmGB_TILE_MODE1},
497 {mmGB_TILE_MODE2},
498 {mmGB_TILE_MODE3},
499 {mmGB_TILE_MODE4},
500 {mmGB_TILE_MODE5},
501 {mmGB_TILE_MODE6},
502 {mmGB_TILE_MODE7},
503 {mmGB_TILE_MODE8},
504 {mmGB_TILE_MODE9},
505 {mmGB_TILE_MODE10},
506 {mmGB_TILE_MODE11},
507 {mmGB_TILE_MODE12},
508 {mmGB_TILE_MODE13},
509 {mmGB_TILE_MODE14},
510 {mmGB_TILE_MODE15},
511 {mmGB_TILE_MODE16},
512 {mmGB_TILE_MODE17},
513 {mmGB_TILE_MODE18},
514 {mmGB_TILE_MODE19},
515 {mmGB_TILE_MODE20},
516 {mmGB_TILE_MODE21},
517 {mmGB_TILE_MODE22},
518 {mmGB_TILE_MODE23},
519 {mmGB_TILE_MODE24},
520 {mmGB_TILE_MODE25},
521 {mmGB_TILE_MODE26},
522 {mmGB_TILE_MODE27},
523 {mmGB_TILE_MODE28},
524 {mmGB_TILE_MODE29},
525 {mmGB_TILE_MODE30},
526 {mmGB_TILE_MODE31},
527 {mmGB_MACROTILE_MODE0},
528 {mmGB_MACROTILE_MODE1},
529 {mmGB_MACROTILE_MODE2},
530 {mmGB_MACROTILE_MODE3},
531 {mmGB_MACROTILE_MODE4},
532 {mmGB_MACROTILE_MODE5},
533 {mmGB_MACROTILE_MODE6},
534 {mmGB_MACROTILE_MODE7},
535 {mmGB_MACROTILE_MODE8},
536 {mmGB_MACROTILE_MODE9},
537 {mmGB_MACROTILE_MODE10},
538 {mmGB_MACROTILE_MODE11},
539 {mmGB_MACROTILE_MODE12},
540 {mmGB_MACROTILE_MODE13},
541 {mmGB_MACROTILE_MODE14},
542 {mmGB_MACROTILE_MODE15},
543 {mmCC_RB_BACKEND_DISABLE, true},
544 {mmGC_USER_RB_BACKEND_DISABLE, true},
545 {mmGB_BACKEND_MAP, false},
546 {mmPA_SC_RASTER_CONFIG, true},
547 {mmPA_SC_RASTER_CONFIG_1, true},
Alex Deucheraaa36a92015-04-20 17:31:14 -0400548};
549
Alex Deucherdb9635c2016-10-10 12:05:32 -0400550static uint32_t vi_get_register_value(struct amdgpu_device *adev,
551 bool indexed, u32 se_num,
552 u32 sh_num, u32 reg_offset)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400553{
Alex Deucherdb9635c2016-10-10 12:05:32 -0400554 if (indexed) {
555 uint32_t val;
556 unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num;
557 unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400558
Alex Deucherdb9635c2016-10-10 12:05:32 -0400559 switch (reg_offset) {
560 case mmCC_RB_BACKEND_DISABLE:
561 return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable;
562 case mmGC_USER_RB_BACKEND_DISABLE:
563 return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable;
564 case mmPA_SC_RASTER_CONFIG:
565 return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config;
566 case mmPA_SC_RASTER_CONFIG_1:
567 return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config_1;
568 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400569
Alex Deucherdb9635c2016-10-10 12:05:32 -0400570 mutex_lock(&adev->grbm_idx_mutex);
571 if (se_num != 0xffffffff || sh_num != 0xffffffff)
572 amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400573
Alex Deucherdb9635c2016-10-10 12:05:32 -0400574 val = RREG32(reg_offset);
575
576 if (se_num != 0xffffffff || sh_num != 0xffffffff)
577 amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
578 mutex_unlock(&adev->grbm_idx_mutex);
579 return val;
580 } else {
581 unsigned idx;
582
583 switch (reg_offset) {
584 case mmGB_ADDR_CONFIG:
585 return adev->gfx.config.gb_addr_config;
586 case mmMC_ARB_RAMCFG:
587 return adev->gfx.config.mc_arb_ramcfg;
588 case mmGB_TILE_MODE0:
589 case mmGB_TILE_MODE1:
590 case mmGB_TILE_MODE2:
591 case mmGB_TILE_MODE3:
592 case mmGB_TILE_MODE4:
593 case mmGB_TILE_MODE5:
594 case mmGB_TILE_MODE6:
595 case mmGB_TILE_MODE7:
596 case mmGB_TILE_MODE8:
597 case mmGB_TILE_MODE9:
598 case mmGB_TILE_MODE10:
599 case mmGB_TILE_MODE11:
600 case mmGB_TILE_MODE12:
601 case mmGB_TILE_MODE13:
602 case mmGB_TILE_MODE14:
603 case mmGB_TILE_MODE15:
604 case mmGB_TILE_MODE16:
605 case mmGB_TILE_MODE17:
606 case mmGB_TILE_MODE18:
607 case mmGB_TILE_MODE19:
608 case mmGB_TILE_MODE20:
609 case mmGB_TILE_MODE21:
610 case mmGB_TILE_MODE22:
611 case mmGB_TILE_MODE23:
612 case mmGB_TILE_MODE24:
613 case mmGB_TILE_MODE25:
614 case mmGB_TILE_MODE26:
615 case mmGB_TILE_MODE27:
616 case mmGB_TILE_MODE28:
617 case mmGB_TILE_MODE29:
618 case mmGB_TILE_MODE30:
619 case mmGB_TILE_MODE31:
620 idx = (reg_offset - mmGB_TILE_MODE0);
621 return adev->gfx.config.tile_mode_array[idx];
622 case mmGB_MACROTILE_MODE0:
623 case mmGB_MACROTILE_MODE1:
624 case mmGB_MACROTILE_MODE2:
625 case mmGB_MACROTILE_MODE3:
626 case mmGB_MACROTILE_MODE4:
627 case mmGB_MACROTILE_MODE5:
628 case mmGB_MACROTILE_MODE6:
629 case mmGB_MACROTILE_MODE7:
630 case mmGB_MACROTILE_MODE8:
631 case mmGB_MACROTILE_MODE9:
632 case mmGB_MACROTILE_MODE10:
633 case mmGB_MACROTILE_MODE11:
634 case mmGB_MACROTILE_MODE12:
635 case mmGB_MACROTILE_MODE13:
636 case mmGB_MACROTILE_MODE14:
637 case mmGB_MACROTILE_MODE15:
638 idx = (reg_offset - mmGB_MACROTILE_MODE0);
639 return adev->gfx.config.macrotile_mode_array[idx];
640 default:
641 return RREG32(reg_offset);
642 }
643 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400644}
645
646static int vi_read_register(struct amdgpu_device *adev, u32 se_num,
647 u32 sh_num, u32 reg_offset, u32 *value)
648{
Christian König3032f352017-04-12 12:53:18 +0200649 uint32_t i;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400650
651 *value = 0;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400652 for (i = 0; i < ARRAY_SIZE(vi_allowed_read_registers); i++) {
Christian König97fcc762017-04-12 12:49:54 +0200653 bool indexed = vi_allowed_read_registers[i].grbm_indexed;
654
Alex Deucheraaa36a92015-04-20 17:31:14 -0400655 if (reg_offset != vi_allowed_read_registers[i].reg_offset)
656 continue;
657
Christian König97fcc762017-04-12 12:49:54 +0200658 *value = vi_get_register_value(adev, indexed, se_num, sh_num,
659 reg_offset);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400660 return 0;
661 }
662 return -EINVAL;
663}
664
Chunming Zhou89a31822016-06-06 13:06:45 +0800665static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400666{
Alex Deuchera2c5c692015-10-14 09:39:37 -0400667 u32 i;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400668
669 dev_info(adev->dev, "GPU pci config reset\n");
670
Alex Deucheraaa36a92015-04-20 17:31:14 -0400671 /* disable BM */
672 pci_clear_master(adev->pdev);
673 /* reset */
Alex Deucher8111c382017-12-14 16:22:53 -0500674 amdgpu_device_pci_config_reset(adev);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400675
676 udelay(100);
677
678 /* wait for asic to come out of reset */
679 for (i = 0; i < adev->usec_timeout; i++) {
Chunming Zhoub314f9a2016-06-06 13:50:18 +0800680 if (RREG32(mmCONFIG_MEMSIZE) != 0xffffffff) {
681 /* enable BM */
682 pci_set_master(adev->pdev);
Jim Quc836fec2017-02-10 15:59:59 +0800683 adev->has_hw_reset = true;
Chunming Zhou89a31822016-06-06 13:06:45 +0800684 return 0;
Chunming Zhoub314f9a2016-06-06 13:50:18 +0800685 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400686 udelay(1);
687 }
Chunming Zhou89a31822016-06-06 13:06:45 +0800688 return -EINVAL;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400689}
690
Alex Deucheraaa36a92015-04-20 17:31:14 -0400691/**
692 * vi_asic_reset - soft reset GPU
693 *
694 * @adev: amdgpu_device pointer
695 *
696 * Look up which blocks are hung and attempt
697 * to reset them.
698 * Returns 0 for success.
699 */
700static int vi_asic_reset(struct amdgpu_device *adev)
701{
Chunming Zhou89a31822016-06-06 13:06:45 +0800702 int r;
703
Alex Deucher72a57432016-10-21 15:45:22 -0400704 amdgpu_atombios_scratch_regs_engine_hung(adev, true);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400705
Chunming Zhou89a31822016-06-06 13:06:45 +0800706 r = vi_gpu_pci_config_reset(adev);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400707
Alex Deucher72a57432016-10-21 15:45:22 -0400708 amdgpu_atombios_scratch_regs_engine_hung(adev, false);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400709
Chunming Zhou89a31822016-06-06 13:06:45 +0800710 return r;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400711}
712
Alex Deucherbbf282d2017-03-03 17:26:10 -0500713static u32 vi_get_config_memsize(struct amdgpu_device *adev)
714{
715 return RREG32(mmCONFIG_MEMSIZE);
716}
717
Alex Deucheraaa36a92015-04-20 17:31:14 -0400718static int vi_set_uvd_clock(struct amdgpu_device *adev, u32 clock,
719 u32 cntl_reg, u32 status_reg)
720{
721 int r, i;
722 struct atom_clock_dividers dividers;
723 uint32_t tmp;
724
725 r = amdgpu_atombios_get_clock_dividers(adev,
726 COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK,
727 clock, false, &dividers);
728 if (r)
729 return r;
730
731 tmp = RREG32_SMC(cntl_reg);
732 tmp &= ~(CG_DCLK_CNTL__DCLK_DIR_CNTL_EN_MASK |
733 CG_DCLK_CNTL__DCLK_DIVIDER_MASK);
734 tmp |= dividers.post_divider;
735 WREG32_SMC(cntl_reg, tmp);
736
737 for (i = 0; i < 100; i++) {
738 if (RREG32_SMC(status_reg) & CG_DCLK_STATUS__DCLK_STATUS_MASK)
739 break;
740 mdelay(10);
741 }
742 if (i == 100)
743 return -ETIMEDOUT;
744
745 return 0;
746}
747
748static int vi_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
749{
750 int r;
751
752 r = vi_set_uvd_clock(adev, vclk, ixCG_VCLK_CNTL, ixCG_VCLK_STATUS);
753 if (r)
754 return r;
755
756 r = vi_set_uvd_clock(adev, dclk, ixCG_DCLK_CNTL, ixCG_DCLK_STATUS);
Alex Deucherd319c2b2017-03-15 22:05:20 -0400757 if (r)
758 return r;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400759
760 return 0;
761}
762
763static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
764{
Rex Zhu714b1f52017-01-10 19:54:25 +0800765 int r, i;
766 struct atom_clock_dividers dividers;
767 u32 tmp;
768
769 r = amdgpu_atombios_get_clock_dividers(adev,
770 COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK,
771 ecclk, false, &dividers);
772 if (r)
773 return r;
774
775 for (i = 0; i < 100; i++) {
776 if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
777 break;
778 mdelay(10);
779 }
780 if (i == 100)
781 return -ETIMEDOUT;
782
783 tmp = RREG32_SMC(ixCG_ECLK_CNTL);
784 tmp &= ~(CG_ECLK_CNTL__ECLK_DIR_CNTL_EN_MASK |
785 CG_ECLK_CNTL__ECLK_DIVIDER_MASK);
786 tmp |= dividers.post_divider;
787 WREG32_SMC(ixCG_ECLK_CNTL, tmp);
788
789 for (i = 0; i < 100; i++) {
790 if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
791 break;
792 mdelay(10);
793 }
794 if (i == 100)
795 return -ETIMEDOUT;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400796
797 return 0;
798}
799
800static void vi_pcie_gen3_enable(struct amdgpu_device *adev)
801{
Alex Deuchere79d5c02015-10-06 09:38:45 -0400802 if (pci_is_root_bus(adev->pdev->bus))
803 return;
804
Alex Deucheraaa36a92015-04-20 17:31:14 -0400805 if (amdgpu_pcie_gen2 == 0)
806 return;
807
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800808 if (adev->flags & AMD_IS_APU)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400809 return;
810
Alex Deucherd0dd7f02015-11-11 19:45:06 -0500811 if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |
812 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)))
Alex Deucheraaa36a92015-04-20 17:31:14 -0400813 return;
814
815 /* todo */
816}
817
818static void vi_program_aspm(struct amdgpu_device *adev)
819{
820
821 if (amdgpu_aspm == 0)
822 return;
823
824 /* todo */
825}
826
827static void vi_enable_doorbell_aperture(struct amdgpu_device *adev,
828 bool enable)
829{
830 u32 tmp;
831
832 /* not necessary on CZ */
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800833 if (adev->flags & AMD_IS_APU)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400834 return;
835
836 tmp = RREG32(mmBIF_DOORBELL_APER_EN);
837 if (enable)
838 tmp = REG_SET_FIELD(tmp, BIF_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, 1);
839 else
840 tmp = REG_SET_FIELD(tmp, BIF_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, 0);
841
842 WREG32(mmBIF_DOORBELL_APER_EN, tmp);
843}
844
Samuel Li39bb0c92015-10-08 16:31:43 -0400845#define ATI_REV_ID_FUSE_MACRO__ADDRESS 0xC0014044
846#define ATI_REV_ID_FUSE_MACRO__SHIFT 9
847#define ATI_REV_ID_FUSE_MACRO__MASK 0x00001E00
848
Alex Deucheraaa36a92015-04-20 17:31:14 -0400849static uint32_t vi_get_rev_id(struct amdgpu_device *adev)
850{
Flora Cuiabdfb852015-11-20 11:40:53 +0800851 if (adev->flags & AMD_IS_APU)
Samuel Li39bb0c92015-10-08 16:31:43 -0400852 return (RREG32_SMC(ATI_REV_ID_FUSE_MACRO__ADDRESS) & ATI_REV_ID_FUSE_MACRO__MASK)
853 >> ATI_REV_ID_FUSE_MACRO__SHIFT;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400854 else
Flora Cuiabdfb852015-11-20 11:40:53 +0800855 return (RREG32(mmPCIE_EFUSE4) & PCIE_EFUSE4__STRAP_BIF_ATI_REV_ID_MASK)
856 >> PCIE_EFUSE4__STRAP_BIF_ATI_REV_ID__SHIFT;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400857}
858
859static const struct amdgpu_asic_funcs vi_asic_funcs =
860{
861 .read_disabled_bios = &vi_read_disabled_bios,
Alex Deucher95addb2a2015-11-24 10:37:54 -0500862 .read_bios_from_rom = &vi_read_bios_from_rom,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400863 .read_register = &vi_read_register,
864 .reset = &vi_asic_reset,
865 .set_vga_state = &vi_vga_set_state,
866 .get_xclk = &vi_get_xclk,
867 .set_uvd_clocks = &vi_set_uvd_clocks,
868 .set_vce_clocks = &vi_set_vce_clocks,
Alex Deucherbbf282d2017-03-03 17:26:10 -0500869 .get_config_memsize = &vi_get_config_memsize,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400870};
871
Eric Huang170d6e92016-08-12 13:47:08 -0400872#define CZ_REV_BRISTOL(rev) \
873 ((rev >= 0xC8 && rev <= 0xCE) || (rev >= 0xE1 && rev <= 0xE6))
874
yanyang15fc3aee2015-05-22 14:39:35 -0400875static int vi_common_early_init(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400876{
877 bool smc_enabled = false;
yanyang15fc3aee2015-05-22 14:39:35 -0400878 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400879
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800880 if (adev->flags & AMD_IS_APU) {
Alex Deucher7b92cdb2015-07-10 16:21:10 -0400881 adev->smc_rreg = &cz_smc_rreg;
882 adev->smc_wreg = &cz_smc_wreg;
883 } else {
884 adev->smc_rreg = &vi_smc_rreg;
885 adev->smc_wreg = &vi_smc_wreg;
886 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400887 adev->pcie_rreg = &vi_pcie_rreg;
888 adev->pcie_wreg = &vi_pcie_wreg;
889 adev->uvd_ctx_rreg = &vi_uvd_ctx_rreg;
890 adev->uvd_ctx_wreg = &vi_uvd_ctx_wreg;
891 adev->didt_rreg = &vi_didt_rreg;
892 adev->didt_wreg = &vi_didt_wreg;
Rex Zhuccdbb202016-06-08 12:47:41 +0800893 adev->gc_cac_rreg = &vi_gc_cac_rreg;
894 adev->gc_cac_wreg = &vi_gc_cac_wreg;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400895
896 adev->asic_funcs = &vi_asic_funcs;
897
Alex Deucher2990a1f2017-12-15 16:18:00 -0500898 if (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_SMC) &&
899 (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_SMC)))
Alex Deucheraaa36a92015-04-20 17:31:14 -0400900 smc_enabled = true;
901
902 adev->rev_id = vi_get_rev_id(adev);
903 adev->external_rev_id = 0xFF;
904 switch (adev->asic_type) {
905 case CHIP_TOPAZ:
Alex Deucheraaa36a92015-04-20 17:31:14 -0400906 adev->cg_flags = 0;
907 adev->pg_flags = 0;
908 adev->external_rev_id = 0x1;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400909 break;
David Zhang48299f92015-07-08 01:05:16 +0800910 case CHIP_FIJI:
Alex Deucher14698b62016-04-07 18:38:00 -0400911 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
912 AMD_CG_SUPPORT_GFX_MGLS |
913 AMD_CG_SUPPORT_GFX_RLC_LS |
914 AMD_CG_SUPPORT_GFX_CP_LS |
915 AMD_CG_SUPPORT_GFX_CGTS |
916 AMD_CG_SUPPORT_GFX_CGTS_LS |
917 AMD_CG_SUPPORT_GFX_CGCG |
Alex Deuchere08d53c2016-04-08 00:42:51 -0400918 AMD_CG_SUPPORT_GFX_CGLS |
919 AMD_CG_SUPPORT_SDMA_MGCG |
Alex Deucherc90766c2016-04-08 00:52:58 -0400920 AMD_CG_SUPPORT_SDMA_LS |
921 AMD_CG_SUPPORT_BIF_LS |
922 AMD_CG_SUPPORT_HDP_MGCG |
923 AMD_CG_SUPPORT_HDP_LS |
Alex Deucher3fde56b2016-04-08 01:01:18 -0400924 AMD_CG_SUPPORT_ROM_MGCG |
925 AMD_CG_SUPPORT_MC_MGCG |
Rex Zhu79abf1a2016-11-09 14:30:25 +0800926 AMD_CG_SUPPORT_MC_LS |
927 AMD_CG_SUPPORT_UVD_MGCG;
Flora Cuib6bc28f2015-11-02 21:21:34 +0800928 adev->pg_flags = 0;
929 adev->external_rev_id = adev->rev_id + 0x3c;
930 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400931 case CHIP_TONGA:
Rex Zhuca18b842016-12-07 18:22:38 +0800932 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
933 AMD_CG_SUPPORT_GFX_CGCG |
934 AMD_CG_SUPPORT_GFX_CGLS |
935 AMD_CG_SUPPORT_SDMA_MGCG |
936 AMD_CG_SUPPORT_SDMA_LS |
937 AMD_CG_SUPPORT_BIF_LS |
938 AMD_CG_SUPPORT_HDP_MGCG |
939 AMD_CG_SUPPORT_HDP_LS |
940 AMD_CG_SUPPORT_ROM_MGCG |
941 AMD_CG_SUPPORT_MC_MGCG |
942 AMD_CG_SUPPORT_MC_LS |
943 AMD_CG_SUPPORT_DRM_LS |
944 AMD_CG_SUPPORT_UVD_MGCG;
Rex Zhu54971402016-12-07 16:06:38 +0800945 adev->pg_flags = 0;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400946 adev->external_rev_id = adev->rev_id + 0x14;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400947 break;
Flora Cui2cc0c0b2016-03-14 18:33:29 -0400948 case CHIP_POLARIS11:
Rex Zhuca18b842016-12-07 18:22:38 +0800949 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
950 AMD_CG_SUPPORT_GFX_RLC_LS |
951 AMD_CG_SUPPORT_GFX_CP_LS |
952 AMD_CG_SUPPORT_GFX_CGCG |
953 AMD_CG_SUPPORT_GFX_CGLS |
954 AMD_CG_SUPPORT_GFX_3D_CGCG |
955 AMD_CG_SUPPORT_GFX_3D_CGLS |
956 AMD_CG_SUPPORT_SDMA_MGCG |
957 AMD_CG_SUPPORT_SDMA_LS |
958 AMD_CG_SUPPORT_BIF_MGCG |
959 AMD_CG_SUPPORT_BIF_LS |
960 AMD_CG_SUPPORT_HDP_MGCG |
961 AMD_CG_SUPPORT_HDP_LS |
962 AMD_CG_SUPPORT_ROM_MGCG |
963 AMD_CG_SUPPORT_MC_MGCG |
964 AMD_CG_SUPPORT_MC_LS |
965 AMD_CG_SUPPORT_DRM_LS |
966 AMD_CG_SUPPORT_UVD_MGCG |
Maruthi Srinivas Bayyavarapuecc2cf72016-11-17 17:29:50 +0530967 AMD_CG_SUPPORT_VCE_MGCG;
Flora Cuic0c1f572015-12-07 18:33:10 +0800968 adev->pg_flags = 0;
969 adev->external_rev_id = adev->rev_id + 0x5A;
970 break;
Flora Cui2cc0c0b2016-03-14 18:33:29 -0400971 case CHIP_POLARIS10:
Rex Zhuca18b842016-12-07 18:22:38 +0800972 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
973 AMD_CG_SUPPORT_GFX_RLC_LS |
974 AMD_CG_SUPPORT_GFX_CP_LS |
975 AMD_CG_SUPPORT_GFX_CGCG |
976 AMD_CG_SUPPORT_GFX_CGLS |
977 AMD_CG_SUPPORT_GFX_3D_CGCG |
978 AMD_CG_SUPPORT_GFX_3D_CGLS |
979 AMD_CG_SUPPORT_SDMA_MGCG |
980 AMD_CG_SUPPORT_SDMA_LS |
981 AMD_CG_SUPPORT_BIF_MGCG |
982 AMD_CG_SUPPORT_BIF_LS |
983 AMD_CG_SUPPORT_HDP_MGCG |
984 AMD_CG_SUPPORT_HDP_LS |
985 AMD_CG_SUPPORT_ROM_MGCG |
986 AMD_CG_SUPPORT_MC_MGCG |
987 AMD_CG_SUPPORT_MC_LS |
988 AMD_CG_SUPPORT_DRM_LS |
989 AMD_CG_SUPPORT_UVD_MGCG |
Maruthi Srinivas Bayyavarapuecc2cf72016-11-17 17:29:50 +0530990 AMD_CG_SUPPORT_VCE_MGCG;
Flora Cuic0c1f572015-12-07 18:33:10 +0800991 adev->pg_flags = 0;
992 adev->external_rev_id = adev->rev_id + 0x50;
993 break;
Junwei Zhangc4642a42016-12-14 15:32:28 -0500994 case CHIP_POLARIS12:
Rex Zhu739e9ff2017-03-17 19:04:55 +0800995 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
996 AMD_CG_SUPPORT_GFX_RLC_LS |
997 AMD_CG_SUPPORT_GFX_CP_LS |
998 AMD_CG_SUPPORT_GFX_CGCG |
999 AMD_CG_SUPPORT_GFX_CGLS |
1000 AMD_CG_SUPPORT_GFX_3D_CGCG |
1001 AMD_CG_SUPPORT_GFX_3D_CGLS |
1002 AMD_CG_SUPPORT_SDMA_MGCG |
1003 AMD_CG_SUPPORT_SDMA_LS |
1004 AMD_CG_SUPPORT_BIF_MGCG |
1005 AMD_CG_SUPPORT_BIF_LS |
1006 AMD_CG_SUPPORT_HDP_MGCG |
1007 AMD_CG_SUPPORT_HDP_LS |
1008 AMD_CG_SUPPORT_ROM_MGCG |
1009 AMD_CG_SUPPORT_MC_MGCG |
1010 AMD_CG_SUPPORT_MC_LS |
1011 AMD_CG_SUPPORT_DRM_LS |
1012 AMD_CG_SUPPORT_UVD_MGCG |
1013 AMD_CG_SUPPORT_VCE_MGCG;
Junwei Zhangc4642a42016-12-14 15:32:28 -05001014 adev->pg_flags = 0;
1015 adev->external_rev_id = adev->rev_id + 0x64;
1016 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001017 case CHIP_CARRIZO:
Tom St Denisf0f3a8f2016-05-03 10:36:28 -04001018 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG |
1019 AMD_CG_SUPPORT_GFX_MGCG |
Alex Deucher70eced92016-04-07 23:01:48 -04001020 AMD_CG_SUPPORT_GFX_MGLS |
1021 AMD_CG_SUPPORT_GFX_RLC_LS |
1022 AMD_CG_SUPPORT_GFX_CP_LS |
1023 AMD_CG_SUPPORT_GFX_CGTS |
Alex Deucher70eced92016-04-07 23:01:48 -04001024 AMD_CG_SUPPORT_GFX_CGTS_LS |
1025 AMD_CG_SUPPORT_GFX_CGCG |
Alex Deucher03c335d2016-04-08 00:26:46 -04001026 AMD_CG_SUPPORT_GFX_CGLS |
1027 AMD_CG_SUPPORT_BIF_LS |
1028 AMD_CG_SUPPORT_HDP_MGCG |
Alex Deucher6f17a252016-04-08 00:39:54 -04001029 AMD_CG_SUPPORT_HDP_LS |
1030 AMD_CG_SUPPORT_SDMA_MGCG |
Tom St Denis1af69a22016-08-03 10:16:17 -04001031 AMD_CG_SUPPORT_SDMA_LS |
1032 AMD_CG_SUPPORT_VCE_MGCG;
Tom St Denisf6ade302016-07-28 09:33:56 -04001033 /* rev0 hardware requires workarounds to support PG */
Alex Deucher0fd4af92016-02-04 23:31:32 -05001034 adev->pg_flags = 0;
Eric Huang170d6e92016-08-12 13:47:08 -04001035 if (adev->rev_id != 0x00 || CZ_REV_BRISTOL(adev->pdev->revision)) {
Felix Kuehlingc2cade32017-08-15 23:00:16 -04001036 adev->pg_flags |= AMD_PG_SUPPORT_GFX_SMG |
Tom St Denis65b42622016-07-28 09:35:57 -04001037 AMD_PG_SUPPORT_GFX_PIPELINE |
Rex Zhu98fccc72016-12-07 17:48:48 +08001038 AMD_PG_SUPPORT_CP |
Tom St Denis2ed09362016-07-28 09:36:26 -04001039 AMD_PG_SUPPORT_UVD |
1040 AMD_PG_SUPPORT_VCE;
Tom St Denisf6ade302016-07-28 09:33:56 -04001041 }
Alex Deucheraaa36a92015-04-20 17:31:14 -04001042 adev->external_rev_id = adev->rev_id + 0x1;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001043 break;
Tom St Deniscde64932016-03-23 13:17:04 -04001044 case CHIP_STONEY:
Alex Deucher64694902016-04-07 23:17:15 -04001045 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG |
1046 AMD_CG_SUPPORT_GFX_MGCG |
Alex Deucherb6711d12016-04-13 12:41:50 -04001047 AMD_CG_SUPPORT_GFX_MGLS |
Tom St Denis413cf602016-06-02 08:52:39 -04001048 AMD_CG_SUPPORT_GFX_RLC_LS |
1049 AMD_CG_SUPPORT_GFX_CP_LS |
1050 AMD_CG_SUPPORT_GFX_CGTS |
Tom St Denis413cf602016-06-02 08:52:39 -04001051 AMD_CG_SUPPORT_GFX_CGTS_LS |
1052 AMD_CG_SUPPORT_GFX_CGCG |
1053 AMD_CG_SUPPORT_GFX_CGLS |
Alex Deucherb6711d12016-04-13 12:41:50 -04001054 AMD_CG_SUPPORT_BIF_LS |
1055 AMD_CG_SUPPORT_HDP_MGCG |
Alex Deucher1bf912f2016-04-08 00:40:49 -04001056 AMD_CG_SUPPORT_HDP_LS |
1057 AMD_CG_SUPPORT_SDMA_MGCG |
Tom St Denis8ef583e2016-08-03 11:34:35 -04001058 AMD_CG_SUPPORT_SDMA_LS |
1059 AMD_CG_SUPPORT_VCE_MGCG;
Alex Deuchere6b2a7d2016-10-19 13:06:14 -04001060 adev->pg_flags = AMD_PG_SUPPORT_GFX_PG |
Tom St Denis4e86be72016-07-28 09:38:13 -04001061 AMD_PG_SUPPORT_GFX_SMG |
Tom St Denisc2cdb04282016-07-28 09:38:29 -04001062 AMD_PG_SUPPORT_GFX_PIPELINE |
Rex Zhu98fccc72016-12-07 17:48:48 +08001063 AMD_PG_SUPPORT_CP |
Tom St Denis75419c42016-07-28 09:38:45 -04001064 AMD_PG_SUPPORT_UVD |
1065 AMD_PG_SUPPORT_VCE;
Jordan Lazarea47c78d2016-09-01 13:49:33 -04001066 adev->external_rev_id = adev->rev_id + 0x61;
Tom St Deniscde64932016-03-23 13:17:04 -04001067 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001068 default:
1069 /* FIXME: not supported yet */
1070 return -EINVAL;
1071 }
1072
Xiangliang Yuab276632017-04-21 14:06:09 +08001073 if (amdgpu_sriov_vf(adev)) {
1074 amdgpu_virt_init_setting(adev);
1075 xgpu_vi_mailbox_set_irq_funcs(adev);
1076 }
1077
Huang Ruie635ee02016-11-01 15:35:38 +08001078 /* vi use smc load by default */
1079 adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type);
Flora Cuia3d08fa2015-11-02 21:15:55 +08001080
Alex Deucher041d9d92017-12-15 16:49:33 -05001081 amdgpu_device_get_pcie_info(adev);
Alex Deucherd0dd7f02015-11-11 19:45:06 -05001082
Alex Deucheraaa36a92015-04-20 17:31:14 -04001083 return 0;
1084}
1085
Xiangliang Yu99581cc2017-01-12 15:22:18 +08001086static int vi_common_late_init(void *handle)
1087{
1088 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1089
1090 if (amdgpu_sriov_vf(adev))
1091 xgpu_vi_mailbox_get_irq(adev);
1092
1093 return 0;
1094}
1095
yanyang15fc3aee2015-05-22 14:39:35 -04001096static int vi_common_sw_init(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001097{
Xiangliang Yu99581cc2017-01-12 15:22:18 +08001098 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1099
1100 if (amdgpu_sriov_vf(adev))
1101 xgpu_vi_mailbox_add_irq_id(adev);
1102
Alex Deucheraaa36a92015-04-20 17:31:14 -04001103 return 0;
1104}
1105
yanyang15fc3aee2015-05-22 14:39:35 -04001106static int vi_common_sw_fini(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001107{
1108 return 0;
1109}
1110
yanyang15fc3aee2015-05-22 14:39:35 -04001111static int vi_common_hw_init(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001112{
yanyang15fc3aee2015-05-22 14:39:35 -04001113 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1114
Alex Deucheraaa36a92015-04-20 17:31:14 -04001115 /* move the golden regs per IP block */
1116 vi_init_golden_registers(adev);
1117 /* enable pcie gen2/3 link */
1118 vi_pcie_gen3_enable(adev);
1119 /* enable aspm */
1120 vi_program_aspm(adev);
1121 /* enable the doorbell aperture */
1122 vi_enable_doorbell_aperture(adev, true);
1123
1124 return 0;
1125}
1126
yanyang15fc3aee2015-05-22 14:39:35 -04001127static int vi_common_hw_fini(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001128{
yanyang15fc3aee2015-05-22 14:39:35 -04001129 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1130
Alex Deucheraaa36a92015-04-20 17:31:14 -04001131 /* enable the doorbell aperture */
1132 vi_enable_doorbell_aperture(adev, false);
1133
Xiangliang Yu63d24f82017-01-18 12:50:14 +08001134 if (amdgpu_sriov_vf(adev))
1135 xgpu_vi_mailbox_put_irq(adev);
1136
Alex Deucheraaa36a92015-04-20 17:31:14 -04001137 return 0;
1138}
1139
yanyang15fc3aee2015-05-22 14:39:35 -04001140static int vi_common_suspend(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001141{
yanyang15fc3aee2015-05-22 14:39:35 -04001142 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1143
Alex Deucheraaa36a92015-04-20 17:31:14 -04001144 return vi_common_hw_fini(adev);
1145}
1146
yanyang15fc3aee2015-05-22 14:39:35 -04001147static int vi_common_resume(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001148{
yanyang15fc3aee2015-05-22 14:39:35 -04001149 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1150
Alex Deucheraaa36a92015-04-20 17:31:14 -04001151 return vi_common_hw_init(adev);
1152}
1153
yanyang15fc3aee2015-05-22 14:39:35 -04001154static bool vi_common_is_idle(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001155{
1156 return true;
1157}
1158
yanyang15fc3aee2015-05-22 14:39:35 -04001159static int vi_common_wait_for_idle(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001160{
1161 return 0;
1162}
1163
yanyang15fc3aee2015-05-22 14:39:35 -04001164static int vi_common_soft_reset(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001165{
1166 return 0;
1167}
1168
Alex Deucher76f10b92016-04-08 01:37:44 -04001169static void vi_update_bif_medium_grain_light_sleep(struct amdgpu_device *adev,
1170 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001171{
1172 uint32_t temp, data;
1173
1174 temp = data = RREG32_PCIE(ixPCIE_CNTL2);
1175
Alex Deucherc90766c2016-04-08 00:52:58 -04001176 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS))
Eric Huang6cec2652015-11-12 16:59:47 -05001177 data |= PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
1178 PCIE_CNTL2__MST_MEM_LS_EN_MASK |
1179 PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK;
1180 else
1181 data &= ~(PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
1182 PCIE_CNTL2__MST_MEM_LS_EN_MASK |
1183 PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK);
1184
1185 if (temp != data)
1186 WREG32_PCIE(ixPCIE_CNTL2, data);
1187}
1188
Alex Deucher76f10b92016-04-08 01:37:44 -04001189static void vi_update_hdp_medium_grain_clock_gating(struct amdgpu_device *adev,
1190 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001191{
1192 uint32_t temp, data;
1193
1194 temp = data = RREG32(mmHDP_HOST_PATH_CNTL);
1195
Alex Deucherc90766c2016-04-08 00:52:58 -04001196 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG))
Eric Huang6cec2652015-11-12 16:59:47 -05001197 data &= ~HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK;
1198 else
1199 data |= HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK;
1200
1201 if (temp != data)
1202 WREG32(mmHDP_HOST_PATH_CNTL, data);
1203}
1204
Alex Deucher76f10b92016-04-08 01:37:44 -04001205static void vi_update_hdp_light_sleep(struct amdgpu_device *adev,
1206 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001207{
1208 uint32_t temp, data;
1209
1210 temp = data = RREG32(mmHDP_MEM_POWER_LS);
1211
Alex Deucherc90766c2016-04-08 00:52:58 -04001212 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
Eric Huang6cec2652015-11-12 16:59:47 -05001213 data |= HDP_MEM_POWER_LS__LS_ENABLE_MASK;
1214 else
1215 data &= ~HDP_MEM_POWER_LS__LS_ENABLE_MASK;
1216
1217 if (temp != data)
1218 WREG32(mmHDP_MEM_POWER_LS, data);
1219}
1220
Rex Zhuf6f534e2016-12-08 10:58:15 +08001221static void vi_update_drm_light_sleep(struct amdgpu_device *adev,
1222 bool enable)
1223{
1224 uint32_t temp, data;
1225
1226 temp = data = RREG32(0x157a);
1227
1228 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_DRM_LS))
1229 data |= 1;
1230 else
1231 data &= ~1;
1232
1233 if (temp != data)
1234 WREG32(0x157a, data);
1235}
1236
1237
Alex Deucher76f10b92016-04-08 01:37:44 -04001238static void vi_update_rom_medium_grain_clock_gating(struct amdgpu_device *adev,
1239 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001240{
1241 uint32_t temp, data;
1242
1243 temp = data = RREG32_SMC(ixCGTT_ROM_CLK_CTRL0);
1244
Alex Deucherc90766c2016-04-08 00:52:58 -04001245 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_ROM_MGCG))
Eric Huang6cec2652015-11-12 16:59:47 -05001246 data &= ~(CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK |
1247 CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE1_MASK);
1248 else
1249 data |= CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK |
1250 CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE1_MASK;
1251
1252 if (temp != data)
1253 WREG32_SMC(ixCGTT_ROM_CLK_CTRL0, data);
1254}
1255
Rex Zhu1bb08f92016-09-18 16:54:00 +08001256static int vi_common_set_clockgating_state_by_smu(void *handle,
1257 enum amd_clockgating_state state)
1258{
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001259 uint32_t msg_id, pp_state = 0;
1260 uint32_t pp_support_state = 0;
Rex Zhu1bb08f92016-09-18 16:54:00 +08001261 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Rex Zhu1bb08f92016-09-18 16:54:00 +08001262
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001263 if (adev->cg_flags & (AMD_CG_SUPPORT_MC_LS | AMD_CG_SUPPORT_MC_MGCG)) {
1264 if (adev->cg_flags & AMD_CG_SUPPORT_MC_LS) {
1265 pp_support_state = AMD_CG_SUPPORT_MC_LS;
1266 pp_state = PP_STATE_LS;
1267 }
1268 if (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG) {
1269 pp_support_state |= AMD_CG_SUPPORT_MC_MGCG;
1270 pp_state |= PP_STATE_CG;
1271 }
1272 if (state == AMD_CG_STATE_UNGATE)
1273 pp_state = 0;
1274 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1275 PP_BLOCK_SYS_MC,
1276 pp_support_state,
1277 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001278 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1279 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001280 }
Rex Zhu1bb08f92016-09-18 16:54:00 +08001281
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001282 if (adev->cg_flags & (AMD_CG_SUPPORT_SDMA_LS | AMD_CG_SUPPORT_SDMA_MGCG)) {
1283 if (adev->cg_flags & AMD_CG_SUPPORT_SDMA_LS) {
1284 pp_support_state = AMD_CG_SUPPORT_SDMA_LS;
1285 pp_state = PP_STATE_LS;
1286 }
1287 if (adev->cg_flags & AMD_CG_SUPPORT_SDMA_MGCG) {
1288 pp_support_state |= AMD_CG_SUPPORT_SDMA_MGCG;
1289 pp_state |= PP_STATE_CG;
1290 }
1291 if (state == AMD_CG_STATE_UNGATE)
1292 pp_state = 0;
1293 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1294 PP_BLOCK_SYS_SDMA,
1295 pp_support_state,
1296 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001297 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1298 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001299 }
Rex Zhu1bb08f92016-09-18 16:54:00 +08001300
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001301 if (adev->cg_flags & (AMD_CG_SUPPORT_HDP_LS | AMD_CG_SUPPORT_HDP_MGCG)) {
1302 if (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS) {
1303 pp_support_state = AMD_CG_SUPPORT_HDP_LS;
1304 pp_state = PP_STATE_LS;
1305 }
1306 if (adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG) {
1307 pp_support_state |= AMD_CG_SUPPORT_HDP_MGCG;
1308 pp_state |= PP_STATE_CG;
1309 }
1310 if (state == AMD_CG_STATE_UNGATE)
1311 pp_state = 0;
1312 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1313 PP_BLOCK_SYS_HDP,
1314 pp_support_state,
1315 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001316 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1317 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001318 }
Rex Zhu1bb08f92016-09-18 16:54:00 +08001319
Rex Zhu1bb08f92016-09-18 16:54:00 +08001320
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001321 if (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS) {
1322 if (state == AMD_CG_STATE_UNGATE)
1323 pp_state = 0;
1324 else
1325 pp_state = PP_STATE_LS;
Rex Zhu1bb08f92016-09-18 16:54:00 +08001326
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001327 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1328 PP_BLOCK_SYS_BIF,
1329 PP_STATE_SUPPORT_LS,
1330 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001331 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1332 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001333 }
1334 if (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG) {
1335 if (state == AMD_CG_STATE_UNGATE)
1336 pp_state = 0;
1337 else
1338 pp_state = PP_STATE_CG;
Rex Zhu1bb08f92016-09-18 16:54:00 +08001339
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001340 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1341 PP_BLOCK_SYS_BIF,
1342 PP_STATE_SUPPORT_CG,
1343 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001344 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1345 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001346 }
Rex Zhu1bb08f92016-09-18 16:54:00 +08001347
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001348 if (adev->cg_flags & AMD_CG_SUPPORT_DRM_LS) {
Rex Zhu1bb08f92016-09-18 16:54:00 +08001349
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001350 if (state == AMD_CG_STATE_UNGATE)
1351 pp_state = 0;
1352 else
1353 pp_state = PP_STATE_LS;
1354
1355 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1356 PP_BLOCK_SYS_DRM,
1357 PP_STATE_SUPPORT_LS,
1358 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001359 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1360 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001361 }
1362
1363 if (adev->cg_flags & AMD_CG_SUPPORT_ROM_MGCG) {
1364
1365 if (state == AMD_CG_STATE_UNGATE)
1366 pp_state = 0;
1367 else
1368 pp_state = PP_STATE_CG;
1369
1370 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1371 PP_BLOCK_SYS_ROM,
1372 PP_STATE_SUPPORT_CG,
1373 pp_state);
Rex Zhu3811f8f2017-09-26 13:39:38 +08001374 if (adev->powerplay.pp_funcs->set_clockgating_by_smu)
1375 amdgpu_dpm_set_clockgating_by_smu(adev, msg_id);
Rex Zhu8a19e7f2016-12-07 19:11:49 +08001376 }
Rex Zhu1bb08f92016-09-18 16:54:00 +08001377 return 0;
1378}
1379
yanyang15fc3aee2015-05-22 14:39:35 -04001380static int vi_common_set_clockgating_state(void *handle,
Alex Deucherc90766c2016-04-08 00:52:58 -04001381 enum amd_clockgating_state state)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001382{
Eric Huang6cec2652015-11-12 16:59:47 -05001383 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1384
Monk Liuce137c02017-01-23 10:49:33 +08001385 if (amdgpu_sriov_vf(adev))
1386 return 0;
1387
Eric Huang6cec2652015-11-12 16:59:47 -05001388 switch (adev->asic_type) {
1389 case CHIP_FIJI:
Alex Deucher76f10b92016-04-08 01:37:44 -04001390 vi_update_bif_medium_grain_light_sleep(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001391 state == AMD_CG_STATE_GATE);
Alex Deucher76f10b92016-04-08 01:37:44 -04001392 vi_update_hdp_medium_grain_clock_gating(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001393 state == AMD_CG_STATE_GATE);
Alex Deucher76f10b92016-04-08 01:37:44 -04001394 vi_update_hdp_light_sleep(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001395 state == AMD_CG_STATE_GATE);
Alex Deucher76f10b92016-04-08 01:37:44 -04001396 vi_update_rom_medium_grain_clock_gating(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001397 state == AMD_CG_STATE_GATE);
Alex Deucher76f10b92016-04-08 01:37:44 -04001398 break;
1399 case CHIP_CARRIZO:
1400 case CHIP_STONEY:
1401 vi_update_bif_medium_grain_light_sleep(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001402 state == AMD_CG_STATE_GATE);
Alex Deucher76f10b92016-04-08 01:37:44 -04001403 vi_update_hdp_medium_grain_clock_gating(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001404 state == AMD_CG_STATE_GATE);
Alex Deucher76f10b92016-04-08 01:37:44 -04001405 vi_update_hdp_light_sleep(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001406 state == AMD_CG_STATE_GATE);
Rex Zhuf6f534e2016-12-08 10:58:15 +08001407 vi_update_drm_light_sleep(adev,
Andrew F. Davis7e913662017-03-15 11:20:23 -05001408 state == AMD_CG_STATE_GATE);
Eric Huang6cec2652015-11-12 16:59:47 -05001409 break;
Rex Zhu1bb08f92016-09-18 16:54:00 +08001410 case CHIP_TONGA:
1411 case CHIP_POLARIS10:
1412 case CHIP_POLARIS11:
Junwei Zhangc4642a42016-12-14 15:32:28 -05001413 case CHIP_POLARIS12:
Rex Zhu1bb08f92016-09-18 16:54:00 +08001414 vi_common_set_clockgating_state_by_smu(adev, state);
Eric Huang6cec2652015-11-12 16:59:47 -05001415 default:
1416 break;
1417 }
Alex Deucheraaa36a92015-04-20 17:31:14 -04001418 return 0;
1419}
1420
yanyang15fc3aee2015-05-22 14:39:35 -04001421static int vi_common_set_powergating_state(void *handle,
1422 enum amd_powergating_state state)
1423{
1424 return 0;
1425}
1426
Huang Ruiabd2c2f2017-01-05 20:48:06 +08001427static void vi_common_get_clockgating_state(void *handle, u32 *flags)
1428{
1429 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1430 int data;
1431
Monk Liuce137c02017-01-23 10:49:33 +08001432 if (amdgpu_sriov_vf(adev))
1433 *flags = 0;
1434
Huang Ruiabd2c2f2017-01-05 20:48:06 +08001435 /* AMD_CG_SUPPORT_BIF_LS */
1436 data = RREG32_PCIE(ixPCIE_CNTL2);
1437 if (data & PCIE_CNTL2__SLV_MEM_LS_EN_MASK)
1438 *flags |= AMD_CG_SUPPORT_BIF_LS;
1439
1440 /* AMD_CG_SUPPORT_HDP_LS */
1441 data = RREG32(mmHDP_MEM_POWER_LS);
1442 if (data & HDP_MEM_POWER_LS__LS_ENABLE_MASK)
1443 *flags |= AMD_CG_SUPPORT_HDP_LS;
1444
1445 /* AMD_CG_SUPPORT_HDP_MGCG */
1446 data = RREG32(mmHDP_HOST_PATH_CNTL);
1447 if (!(data & HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK))
1448 *flags |= AMD_CG_SUPPORT_HDP_MGCG;
1449
1450 /* AMD_CG_SUPPORT_ROM_MGCG */
1451 data = RREG32_SMC(ixCGTT_ROM_CLK_CTRL0);
1452 if (!(data & CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK))
1453 *flags |= AMD_CG_SUPPORT_ROM_MGCG;
1454}
1455
Alex Deuchera1255102016-10-13 17:41:13 -04001456static const struct amd_ip_funcs vi_common_ip_funcs = {
Tom St Denis88a907d2016-05-04 14:28:35 -04001457 .name = "vi_common",
Alex Deucheraaa36a92015-04-20 17:31:14 -04001458 .early_init = vi_common_early_init,
Xiangliang Yu99581cc2017-01-12 15:22:18 +08001459 .late_init = vi_common_late_init,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001460 .sw_init = vi_common_sw_init,
1461 .sw_fini = vi_common_sw_fini,
1462 .hw_init = vi_common_hw_init,
1463 .hw_fini = vi_common_hw_fini,
1464 .suspend = vi_common_suspend,
1465 .resume = vi_common_resume,
1466 .is_idle = vi_common_is_idle,
1467 .wait_for_idle = vi_common_wait_for_idle,
1468 .soft_reset = vi_common_soft_reset,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001469 .set_clockgating_state = vi_common_set_clockgating_state,
1470 .set_powergating_state = vi_common_set_powergating_state,
Huang Ruiabd2c2f2017-01-05 20:48:06 +08001471 .get_clockgating_state = vi_common_get_clockgating_state,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001472};
1473
Alex Deuchera1255102016-10-13 17:41:13 -04001474static const struct amdgpu_ip_block_version vi_common_ip_block =
1475{
1476 .type = AMD_IP_BLOCK_TYPE_COMMON,
1477 .major = 1,
1478 .minor = 0,
1479 .rev = 0,
1480 .funcs = &vi_common_ip_funcs,
1481};
1482
1483int vi_set_ip_blocks(struct amdgpu_device *adev)
1484{
Xiangliang Yu91caa082017-01-09 11:49:27 +08001485 /* in early init stage, vbios code won't work */
1486 vi_detect_hw_virtualization(adev);
1487
Xiangliang Yu99581cc2017-01-12 15:22:18 +08001488 if (amdgpu_sriov_vf(adev))
1489 adev->virt.ops = &xgpu_vi_virt_ops;
1490
Alex Deuchera1255102016-10-13 17:41:13 -04001491 switch (adev->asic_type) {
1492 case CHIP_TOPAZ:
1493 /* topaz has no DCE, UVD, VCE */
Alex Deucher2990a1f2017-12-15 16:18:00 -05001494 amdgpu_device_ip_block_add(adev, &vi_common_ip_block);
1495 amdgpu_device_ip_block_add(adev, &gmc_v7_4_ip_block);
1496 amdgpu_device_ip_block_add(adev, &iceland_ih_ip_block);
1497 amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001498 if (adev->enable_virtual_display)
Alex Deucher2990a1f2017-12-15 16:18:00 -05001499 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
1500 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block);
1501 amdgpu_device_ip_block_add(adev, &sdma_v2_4_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001502 break;
1503 case CHIP_FIJI:
Alex Deucher2990a1f2017-12-15 16:18:00 -05001504 amdgpu_device_ip_block_add(adev, &vi_common_ip_block);
1505 amdgpu_device_ip_block_add(adev, &gmc_v8_5_ip_block);
1506 amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block);
1507 amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block);
Xiangliang Yu91caa082017-01-09 11:49:27 +08001508 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001509 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001510#if defined(CONFIG_DRM_AMD_DC)
1511 else if (amdgpu_device_has_dc_support(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001512 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001513#endif
Alex Deuchera1255102016-10-13 17:41:13 -04001514 else
Alex Deucher2990a1f2017-12-15 16:18:00 -05001515 amdgpu_device_ip_block_add(adev, &dce_v10_1_ip_block);
1516 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block);
1517 amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block);
Xiangliang Yu91caa082017-01-09 11:49:27 +08001518 if (!amdgpu_sriov_vf(adev)) {
Alex Deucher2990a1f2017-12-15 16:18:00 -05001519 amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block);
1520 amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block);
Xiangliang Yu91caa082017-01-09 11:49:27 +08001521 }
Alex Deuchera1255102016-10-13 17:41:13 -04001522 break;
1523 case CHIP_TONGA:
Alex Deucher2990a1f2017-12-15 16:18:00 -05001524 amdgpu_device_ip_block_add(adev, &vi_common_ip_block);
1525 amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block);
1526 amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block);
1527 amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block);
Xiangliang Yu91caa082017-01-09 11:49:27 +08001528 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001529 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001530#if defined(CONFIG_DRM_AMD_DC)
1531 else if (amdgpu_device_has_dc_support(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001532 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001533#endif
Alex Deuchera1255102016-10-13 17:41:13 -04001534 else
Alex Deucher2990a1f2017-12-15 16:18:00 -05001535 amdgpu_device_ip_block_add(adev, &dce_v10_0_ip_block);
1536 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block);
1537 amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block);
Xiangliang Yu91caa082017-01-09 11:49:27 +08001538 if (!amdgpu_sriov_vf(adev)) {
Alex Deucher2990a1f2017-12-15 16:18:00 -05001539 amdgpu_device_ip_block_add(adev, &uvd_v5_0_ip_block);
1540 amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block);
Xiangliang Yu91caa082017-01-09 11:49:27 +08001541 }
Alex Deuchera1255102016-10-13 17:41:13 -04001542 break;
1543 case CHIP_POLARIS11:
1544 case CHIP_POLARIS10:
Junwei Zhangc4642a42016-12-14 15:32:28 -05001545 case CHIP_POLARIS12:
Alex Deucher2990a1f2017-12-15 16:18:00 -05001546 amdgpu_device_ip_block_add(adev, &vi_common_ip_block);
1547 amdgpu_device_ip_block_add(adev, &gmc_v8_1_ip_block);
1548 amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block);
1549 amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001550 if (adev->enable_virtual_display)
Alex Deucher2990a1f2017-12-15 16:18:00 -05001551 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001552#if defined(CONFIG_DRM_AMD_DC)
1553 else if (amdgpu_device_has_dc_support(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001554 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001555#endif
Alex Deuchera1255102016-10-13 17:41:13 -04001556 else
Alex Deucher2990a1f2017-12-15 16:18:00 -05001557 amdgpu_device_ip_block_add(adev, &dce_v11_2_ip_block);
1558 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block);
1559 amdgpu_device_ip_block_add(adev, &sdma_v3_1_ip_block);
1560 amdgpu_device_ip_block_add(adev, &uvd_v6_3_ip_block);
1561 amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001562 break;
1563 case CHIP_CARRIZO:
Alex Deucher2990a1f2017-12-15 16:18:00 -05001564 amdgpu_device_ip_block_add(adev, &vi_common_ip_block);
1565 amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block);
1566 amdgpu_device_ip_block_add(adev, &cz_ih_ip_block);
1567 amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001568 if (adev->enable_virtual_display)
Alex Deucher2990a1f2017-12-15 16:18:00 -05001569 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001570#if defined(CONFIG_DRM_AMD_DC)
1571 else if (amdgpu_device_has_dc_support(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001572 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001573#endif
Alex Deuchera1255102016-10-13 17:41:13 -04001574 else
Alex Deucher2990a1f2017-12-15 16:18:00 -05001575 amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block);
1576 amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block);
1577 amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block);
1578 amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block);
1579 amdgpu_device_ip_block_add(adev, &vce_v3_1_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001580#if defined(CONFIG_DRM_AMD_ACP)
Alex Deucher2990a1f2017-12-15 16:18:00 -05001581 amdgpu_device_ip_block_add(adev, &acp_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001582#endif
1583 break;
1584 case CHIP_STONEY:
Alex Deucher2990a1f2017-12-15 16:18:00 -05001585 amdgpu_device_ip_block_add(adev, &vi_common_ip_block);
1586 amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block);
1587 amdgpu_device_ip_block_add(adev, &cz_ih_ip_block);
1588 amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001589 if (adev->enable_virtual_display)
Alex Deucher2990a1f2017-12-15 16:18:00 -05001590 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001591#if defined(CONFIG_DRM_AMD_DC)
1592 else if (amdgpu_device_has_dc_support(adev))
Alex Deucher2990a1f2017-12-15 16:18:00 -05001593 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Harry Wentland45622362017-09-12 15:58:20 -04001594#endif
Alex Deuchera1255102016-10-13 17:41:13 -04001595 else
Alex Deucher2990a1f2017-12-15 16:18:00 -05001596 amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block);
1597 amdgpu_device_ip_block_add(adev, &gfx_v8_1_ip_block);
1598 amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block);
1599 amdgpu_device_ip_block_add(adev, &uvd_v6_2_ip_block);
1600 amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001601#if defined(CONFIG_DRM_AMD_ACP)
Alex Deucher2990a1f2017-12-15 16:18:00 -05001602 amdgpu_device_ip_block_add(adev, &acp_ip_block);
Alex Deuchera1255102016-10-13 17:41:13 -04001603#endif
1604 break;
1605 default:
1606 /* FIXME: not supported yet */
1607 return -EINVAL;
1608 }
1609
1610 return 0;
1611}