blob: 82f72cd1aebe68754523f823964d4a3b5f7cfab1 [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 */
23#include <linux/firmware.h>
24#include <linux/slab.h>
25#include <linux/module.h>
26#include "drmP.h"
27#include "amdgpu.h"
28#include "amdgpu_atombios.h"
29#include "amdgpu_ih.h"
30#include "amdgpu_uvd.h"
31#include "amdgpu_vce.h"
32#include "amdgpu_ucode.h"
33#include "atom.h"
Alex Deucherd0dd7f02015-11-11 19:45:06 -050034#include "amd_pcie.h"
Alex Deucheraaa36a92015-04-20 17:31:14 -040035
36#include "gmc/gmc_8_1_d.h"
37#include "gmc/gmc_8_1_sh_mask.h"
38
39#include "oss/oss_3_0_d.h"
40#include "oss/oss_3_0_sh_mask.h"
41
42#include "bif/bif_5_0_d.h"
43#include "bif/bif_5_0_sh_mask.h"
44
45#include "gca/gfx_8_0_d.h"
46#include "gca/gfx_8_0_sh_mask.h"
47
48#include "smu/smu_7_1_1_d.h"
49#include "smu/smu_7_1_1_sh_mask.h"
50
51#include "uvd/uvd_5_0_d.h"
52#include "uvd/uvd_5_0_sh_mask.h"
53
54#include "vce/vce_3_0_d.h"
55#include "vce/vce_3_0_sh_mask.h"
56
57#include "dce/dce_10_0_d.h"
58#include "dce/dce_10_0_sh_mask.h"
59
60#include "vid.h"
61#include "vi.h"
62#include "vi_dpm.h"
63#include "gmc_v8_0.h"
Ken Wang429c45d2016-02-03 19:16:54 +080064#include "gmc_v7_0.h"
Alex Deucheraaa36a92015-04-20 17:31:14 -040065#include "gfx_v8_0.h"
66#include "sdma_v2_4.h"
67#include "sdma_v3_0.h"
68#include "dce_v10_0.h"
69#include "dce_v11_0.h"
70#include "iceland_ih.h"
71#include "tonga_ih.h"
72#include "cz_ih.h"
73#include "uvd_v5_0.h"
74#include "uvd_v6_0.h"
75#include "vce_v3_0.h"
Alex Deucher1f7371b2015-12-02 17:46:21 -050076#include "amdgpu_powerplay.h"
Maruthi Bayyavarapua8fe58c2015-09-22 17:05:20 -040077#if defined(CONFIG_DRM_AMD_ACP)
78#include "amdgpu_acp.h"
79#endif
Emily Denge9ed3a62016-08-08 11:36:45 +080080#include "dce_virtual.h"
Alex Deucheraaa36a92015-04-20 17:31:14 -040081
Rex Zhu9487dd12016-09-19 15:44:50 +080082MODULE_FIRMWARE("amdgpu/topaz_smc.bin");
83MODULE_FIRMWARE("amdgpu/tonga_smc.bin");
84MODULE_FIRMWARE("amdgpu/fiji_smc.bin");
Flora Cuif8951062016-03-18 19:07:55 +080085MODULE_FIRMWARE("amdgpu/polaris10_smc.bin");
86MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin");
87MODULE_FIRMWARE("amdgpu/polaris11_smc.bin");
88MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin");
89
Alex Deucheraaa36a92015-04-20 17:31:14 -040090/*
91 * Indirect registers accessor
92 */
93static u32 vi_pcie_rreg(struct amdgpu_device *adev, u32 reg)
94{
95 unsigned long flags;
96 u32 r;
97
98 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
99 WREG32(mmPCIE_INDEX, reg);
100 (void)RREG32(mmPCIE_INDEX);
101 r = RREG32(mmPCIE_DATA);
102 spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
103 return r;
104}
105
106static void vi_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
107{
108 unsigned long flags;
109
110 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
111 WREG32(mmPCIE_INDEX, reg);
112 (void)RREG32(mmPCIE_INDEX);
113 WREG32(mmPCIE_DATA, v);
114 (void)RREG32(mmPCIE_DATA);
115 spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
116}
117
118static u32 vi_smc_rreg(struct amdgpu_device *adev, u32 reg)
119{
120 unsigned long flags;
121 u32 r;
122
123 spin_lock_irqsave(&adev->smc_idx_lock, flags);
Monk Liu4bc10d12016-03-29 11:01:51 +0800124 WREG32(mmSMC_IND_INDEX_11, (reg));
125 r = RREG32(mmSMC_IND_DATA_11);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400126 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
127 return r;
128}
129
130static void vi_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
131{
132 unsigned long flags;
133
134 spin_lock_irqsave(&adev->smc_idx_lock, flags);
Monk Liu4bc10d12016-03-29 11:01:51 +0800135 WREG32(mmSMC_IND_INDEX_11, (reg));
136 WREG32(mmSMC_IND_DATA_11, (v));
Alex Deucheraaa36a92015-04-20 17:31:14 -0400137 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
138}
139
Alex Deucher7b92cdb2015-07-10 16:21:10 -0400140/* smu_8_0_d.h */
141#define mmMP0PUB_IND_INDEX 0x180
142#define mmMP0PUB_IND_DATA 0x181
143
144static u32 cz_smc_rreg(struct amdgpu_device *adev, u32 reg)
145{
146 unsigned long flags;
147 u32 r;
148
149 spin_lock_irqsave(&adev->smc_idx_lock, flags);
150 WREG32(mmMP0PUB_IND_INDEX, (reg));
151 r = RREG32(mmMP0PUB_IND_DATA);
152 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
153 return r;
154}
155
156static void cz_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
157{
158 unsigned long flags;
159
160 spin_lock_irqsave(&adev->smc_idx_lock, flags);
161 WREG32(mmMP0PUB_IND_INDEX, (reg));
162 WREG32(mmMP0PUB_IND_DATA, (v));
163 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
164}
165
Alex Deucheraaa36a92015-04-20 17:31:14 -0400166static u32 vi_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg)
167{
168 unsigned long flags;
169 u32 r;
170
171 spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
172 WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
173 r = RREG32(mmUVD_CTX_DATA);
174 spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
175 return r;
176}
177
178static void vi_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
179{
180 unsigned long flags;
181
182 spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags);
183 WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff));
184 WREG32(mmUVD_CTX_DATA, (v));
185 spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags);
186}
187
188static u32 vi_didt_rreg(struct amdgpu_device *adev, u32 reg)
189{
190 unsigned long flags;
191 u32 r;
192
193 spin_lock_irqsave(&adev->didt_idx_lock, flags);
194 WREG32(mmDIDT_IND_INDEX, (reg));
195 r = RREG32(mmDIDT_IND_DATA);
196 spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
197 return r;
198}
199
200static void vi_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
201{
202 unsigned long flags;
203
204 spin_lock_irqsave(&adev->didt_idx_lock, flags);
205 WREG32(mmDIDT_IND_INDEX, (reg));
206 WREG32(mmDIDT_IND_DATA, (v));
207 spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
208}
209
Rex Zhuccdbb202016-06-08 12:47:41 +0800210static u32 vi_gc_cac_rreg(struct amdgpu_device *adev, u32 reg)
211{
212 unsigned long flags;
213 u32 r;
214
215 spin_lock_irqsave(&adev->gc_cac_idx_lock, flags);
216 WREG32(mmGC_CAC_IND_INDEX, (reg));
217 r = RREG32(mmGC_CAC_IND_DATA);
218 spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags);
219 return r;
220}
221
222static void vi_gc_cac_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
223{
224 unsigned long flags;
225
226 spin_lock_irqsave(&adev->gc_cac_idx_lock, flags);
227 WREG32(mmGC_CAC_IND_INDEX, (reg));
228 WREG32(mmGC_CAC_IND_DATA, (v));
229 spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags);
230}
231
232
Alex Deucheraaa36a92015-04-20 17:31:14 -0400233static const u32 tonga_mgcg_cgcg_init[] =
234{
235 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100,
236 mmPCIE_INDEX, 0xffffffff, 0x0140001c,
237 mmPCIE_DATA, 0x000f0000, 0x00000000,
238 mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C,
239 mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400240 mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100,
241 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
242};
243
David Zhang48299f92015-07-08 01:05:16 +0800244static const u32 fiji_mgcg_cgcg_init[] =
245{
246 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100,
247 mmPCIE_INDEX, 0xffffffff, 0x0140001c,
248 mmPCIE_DATA, 0x000f0000, 0x00000000,
249 mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C,
250 mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100,
251 mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100,
252 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
253};
254
Alex Deucheraaa36a92015-04-20 17:31:14 -0400255static const u32 iceland_mgcg_cgcg_init[] =
256{
257 mmPCIE_INDEX, 0xffffffff, ixPCIE_CNTL2,
258 mmPCIE_DATA, 0x000f0000, 0x00000000,
259 mmSMC_IND_INDEX_4, 0xffffffff, ixCGTT_ROM_CLK_CTRL0,
260 mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100,
261 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
262};
263
264static const u32 cz_mgcg_cgcg_init[] =
265{
266 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100,
267 mmPCIE_INDEX, 0xffffffff, 0x0140001c,
268 mmPCIE_DATA, 0x000f0000, 0x00000000,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400269 mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100,
270 mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104,
271};
272
Samuel Li39bb0c92015-10-08 16:31:43 -0400273static const u32 stoney_mgcg_cgcg_init[] =
274{
275 mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00000100,
276 mmHDP_XDP_CGTT_BLK_CTRL, 0xffffffff, 0x00000104,
277 mmHDP_HOST_PATH_CNTL, 0xffffffff, 0x0f000027,
278};
279
Alex Deucheraaa36a92015-04-20 17:31:14 -0400280static void vi_init_golden_registers(struct amdgpu_device *adev)
281{
282 /* Some of the registers might be dependent on GRBM_GFX_INDEX */
283 mutex_lock(&adev->grbm_idx_mutex);
284
285 switch (adev->asic_type) {
286 case CHIP_TOPAZ:
287 amdgpu_program_register_sequence(adev,
288 iceland_mgcg_cgcg_init,
289 (const u32)ARRAY_SIZE(iceland_mgcg_cgcg_init));
290 break;
David Zhang48299f92015-07-08 01:05:16 +0800291 case CHIP_FIJI:
292 amdgpu_program_register_sequence(adev,
293 fiji_mgcg_cgcg_init,
294 (const u32)ARRAY_SIZE(fiji_mgcg_cgcg_init));
295 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400296 case CHIP_TONGA:
297 amdgpu_program_register_sequence(adev,
298 tonga_mgcg_cgcg_init,
299 (const u32)ARRAY_SIZE(tonga_mgcg_cgcg_init));
300 break;
301 case CHIP_CARRIZO:
302 amdgpu_program_register_sequence(adev,
303 cz_mgcg_cgcg_init,
304 (const u32)ARRAY_SIZE(cz_mgcg_cgcg_init));
305 break;
Samuel Li39bb0c92015-10-08 16:31:43 -0400306 case CHIP_STONEY:
307 amdgpu_program_register_sequence(adev,
308 stoney_mgcg_cgcg_init,
309 (const u32)ARRAY_SIZE(stoney_mgcg_cgcg_init));
310 break;
Flora Cui2cc0c0b2016-03-14 18:33:29 -0400311 case CHIP_POLARIS11:
312 case CHIP_POLARIS10:
Alex Deucheraaa36a92015-04-20 17:31:14 -0400313 default:
314 break;
315 }
316 mutex_unlock(&adev->grbm_idx_mutex);
317}
318
319/**
320 * vi_get_xclk - get the xclk
321 *
322 * @adev: amdgpu_device pointer
323 *
324 * Returns the reference clock used by the gfx engine
325 * (VI).
326 */
327static u32 vi_get_xclk(struct amdgpu_device *adev)
328{
329 u32 reference_clock = adev->clock.spll.reference_freq;
330 u32 tmp;
331
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800332 if (adev->flags & AMD_IS_APU)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400333 return reference_clock;
334
335 tmp = RREG32_SMC(ixCG_CLKPIN_CNTL_2);
336 if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL_2, MUX_TCLK_TO_XCLK))
337 return 1000;
338
339 tmp = RREG32_SMC(ixCG_CLKPIN_CNTL);
340 if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL, XTALIN_DIVIDE))
341 return reference_clock / 4;
342
343 return reference_clock;
344}
345
346/**
347 * vi_srbm_select - select specific register instances
348 *
349 * @adev: amdgpu_device pointer
350 * @me: selected ME (micro engine)
351 * @pipe: pipe
352 * @queue: queue
353 * @vmid: VMID
354 *
355 * Switches the currently active registers instances. Some
356 * registers are instanced per VMID, others are instanced per
357 * me/pipe/queue combination.
358 */
359void vi_srbm_select(struct amdgpu_device *adev,
360 u32 me, u32 pipe, u32 queue, u32 vmid)
361{
362 u32 srbm_gfx_cntl = 0;
363 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, PIPEID, pipe);
364 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, MEID, me);
365 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, VMID, vmid);
366 srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, QUEUEID, queue);
367 WREG32(mmSRBM_GFX_CNTL, srbm_gfx_cntl);
368}
369
370static void vi_vga_set_state(struct amdgpu_device *adev, bool state)
371{
372 /* todo */
373}
374
375static bool vi_read_disabled_bios(struct amdgpu_device *adev)
376{
377 u32 bus_cntl;
378 u32 d1vga_control = 0;
379 u32 d2vga_control = 0;
380 u32 vga_render_control = 0;
381 u32 rom_cntl;
382 bool r;
383
384 bus_cntl = RREG32(mmBUS_CNTL);
385 if (adev->mode_info.num_crtc) {
386 d1vga_control = RREG32(mmD1VGA_CONTROL);
387 d2vga_control = RREG32(mmD2VGA_CONTROL);
388 vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
389 }
390 rom_cntl = RREG32_SMC(ixROM_CNTL);
391
392 /* enable the rom */
393 WREG32(mmBUS_CNTL, (bus_cntl & ~BUS_CNTL__BIOS_ROM_DIS_MASK));
394 if (adev->mode_info.num_crtc) {
395 /* Disable VGA mode */
396 WREG32(mmD1VGA_CONTROL,
397 (d1vga_control & ~(D1VGA_CONTROL__D1VGA_MODE_ENABLE_MASK |
398 D1VGA_CONTROL__D1VGA_TIMING_SELECT_MASK)));
399 WREG32(mmD2VGA_CONTROL,
400 (d2vga_control & ~(D2VGA_CONTROL__D2VGA_MODE_ENABLE_MASK |
401 D2VGA_CONTROL__D2VGA_TIMING_SELECT_MASK)));
402 WREG32(mmVGA_RENDER_CONTROL,
403 (vga_render_control & ~VGA_RENDER_CONTROL__VGA_VSTATUS_CNTL_MASK));
404 }
405 WREG32_SMC(ixROM_CNTL, rom_cntl | ROM_CNTL__SCK_OVERWRITE_MASK);
406
407 r = amdgpu_read_bios(adev);
408
409 /* restore regs */
410 WREG32(mmBUS_CNTL, bus_cntl);
411 if (adev->mode_info.num_crtc) {
412 WREG32(mmD1VGA_CONTROL, d1vga_control);
413 WREG32(mmD2VGA_CONTROL, d2vga_control);
414 WREG32(mmVGA_RENDER_CONTROL, vga_render_control);
415 }
416 WREG32_SMC(ixROM_CNTL, rom_cntl);
417 return r;
418}
Alex Deucher95addb2a2015-11-24 10:37:54 -0500419
420static bool vi_read_bios_from_rom(struct amdgpu_device *adev,
421 u8 *bios, u32 length_bytes)
422{
423 u32 *dw_ptr;
424 unsigned long flags;
425 u32 i, length_dw;
426
427 if (bios == NULL)
428 return false;
429 if (length_bytes == 0)
430 return false;
431 /* APU vbios image is part of sbios image */
432 if (adev->flags & AMD_IS_APU)
433 return false;
434
435 dw_ptr = (u32 *)bios;
436 length_dw = ALIGN(length_bytes, 4) / 4;
437 /* take the smc lock since we are using the smc index */
438 spin_lock_irqsave(&adev->smc_idx_lock, flags);
439 /* set rom index to 0 */
Monk Liu4bc10d12016-03-29 11:01:51 +0800440 WREG32(mmSMC_IND_INDEX_11, ixROM_INDEX);
441 WREG32(mmSMC_IND_DATA_11, 0);
Alex Deucher95addb2a2015-11-24 10:37:54 -0500442 /* set index to data for continous read */
Monk Liu4bc10d12016-03-29 11:01:51 +0800443 WREG32(mmSMC_IND_INDEX_11, ixROM_DATA);
Alex Deucher95addb2a2015-11-24 10:37:54 -0500444 for (i = 0; i < length_dw; i++)
Monk Liu4bc10d12016-03-29 11:01:51 +0800445 dw_ptr[i] = RREG32(mmSMC_IND_DATA_11);
Alex Deucher95addb2a2015-11-24 10:37:54 -0500446 spin_unlock_irqrestore(&adev->smc_idx_lock, flags);
447
448 return true;
449}
450
Monk Liu4e99a442016-03-31 13:26:59 +0800451static void vi_detect_hw_virtualization(struct amdgpu_device *adev)
Andres Rodriguez048765a2016-06-11 02:51:32 -0400452{
Monk Liu4e99a442016-03-31 13:26:59 +0800453 uint32_t reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER);
454 /* bit0: 0 means pf and 1 means vf */
455 /* bit31: 0 means disable IOV and 1 means enable */
456 if (reg & 1)
457 adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_IS_VF;
Andres Rodriguez048765a2016-06-11 02:51:32 -0400458
Monk Liu4e99a442016-03-31 13:26:59 +0800459 if (reg & 0x80000000)
460 adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV;
Andres Rodriguez048765a2016-06-11 02:51:32 -0400461
Monk Liu4e99a442016-03-31 13:26:59 +0800462 if (reg == 0) {
463 if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */
464 adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE;
465 }
Andres Rodriguez048765a2016-06-11 02:51:32 -0400466}
467
Nils Wallméniuseca22402016-03-19 16:12:17 +0100468static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = {
Alex Deucheraaa36a92015-04-20 17:31:14 -0400469 {mmGB_MACROTILE_MODE7, true},
470};
471
Nils Wallméniuseca22402016-03-19 16:12:17 +0100472static const struct amdgpu_allowed_register_entry cz_allowed_read_registers[] = {
Alex Deucheraaa36a92015-04-20 17:31:14 -0400473 {mmGB_TILE_MODE7, true},
474 {mmGB_TILE_MODE12, true},
475 {mmGB_TILE_MODE17, true},
476 {mmGB_TILE_MODE23, true},
477 {mmGB_MACROTILE_MODE7, true},
478};
479
Nils Wallméniuseca22402016-03-19 16:12:17 +0100480static const struct amdgpu_allowed_register_entry vi_allowed_read_registers[] = {
Alex Deucheraaa36a92015-04-20 17:31:14 -0400481 {mmGRBM_STATUS, false},
Marek Olšákc7890fe2015-07-11 12:08:46 +0200482 {mmGRBM_STATUS2, false},
483 {mmGRBM_STATUS_SE0, false},
484 {mmGRBM_STATUS_SE1, false},
485 {mmGRBM_STATUS_SE2, false},
486 {mmGRBM_STATUS_SE3, false},
487 {mmSRBM_STATUS, false},
488 {mmSRBM_STATUS2, false},
489 {mmSRBM_STATUS3, false},
490 {mmSDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET, false},
491 {mmSDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET, false},
492 {mmCP_STAT, false},
493 {mmCP_STALLED_STAT1, false},
494 {mmCP_STALLED_STAT2, false},
495 {mmCP_STALLED_STAT3, false},
496 {mmCP_CPF_BUSY_STAT, false},
497 {mmCP_CPF_STALLED_STAT1, false},
498 {mmCP_CPF_STATUS, false},
499 {mmCP_CPC_BUSY_STAT, false},
500 {mmCP_CPC_STALLED_STAT1, false},
501 {mmCP_CPC_STATUS, false},
Alex Deucheraaa36a92015-04-20 17:31:14 -0400502 {mmGB_ADDR_CONFIG, false},
503 {mmMC_ARB_RAMCFG, false},
504 {mmGB_TILE_MODE0, false},
505 {mmGB_TILE_MODE1, false},
506 {mmGB_TILE_MODE2, false},
507 {mmGB_TILE_MODE3, false},
508 {mmGB_TILE_MODE4, false},
509 {mmGB_TILE_MODE5, false},
510 {mmGB_TILE_MODE6, false},
511 {mmGB_TILE_MODE7, false},
512 {mmGB_TILE_MODE8, false},
513 {mmGB_TILE_MODE9, false},
514 {mmGB_TILE_MODE10, false},
515 {mmGB_TILE_MODE11, false},
516 {mmGB_TILE_MODE12, false},
517 {mmGB_TILE_MODE13, false},
518 {mmGB_TILE_MODE14, false},
519 {mmGB_TILE_MODE15, false},
520 {mmGB_TILE_MODE16, false},
521 {mmGB_TILE_MODE17, false},
522 {mmGB_TILE_MODE18, false},
523 {mmGB_TILE_MODE19, false},
524 {mmGB_TILE_MODE20, false},
525 {mmGB_TILE_MODE21, false},
526 {mmGB_TILE_MODE22, false},
527 {mmGB_TILE_MODE23, false},
528 {mmGB_TILE_MODE24, false},
529 {mmGB_TILE_MODE25, false},
530 {mmGB_TILE_MODE26, false},
531 {mmGB_TILE_MODE27, false},
532 {mmGB_TILE_MODE28, false},
533 {mmGB_TILE_MODE29, false},
534 {mmGB_TILE_MODE30, false},
535 {mmGB_TILE_MODE31, false},
536 {mmGB_MACROTILE_MODE0, false},
537 {mmGB_MACROTILE_MODE1, false},
538 {mmGB_MACROTILE_MODE2, false},
539 {mmGB_MACROTILE_MODE3, false},
540 {mmGB_MACROTILE_MODE4, false},
541 {mmGB_MACROTILE_MODE5, false},
542 {mmGB_MACROTILE_MODE6, false},
543 {mmGB_MACROTILE_MODE7, false},
544 {mmGB_MACROTILE_MODE8, false},
545 {mmGB_MACROTILE_MODE9, false},
546 {mmGB_MACROTILE_MODE10, false},
547 {mmGB_MACROTILE_MODE11, false},
548 {mmGB_MACROTILE_MODE12, false},
549 {mmGB_MACROTILE_MODE13, false},
550 {mmGB_MACROTILE_MODE14, false},
551 {mmGB_MACROTILE_MODE15, false},
552 {mmCC_RB_BACKEND_DISABLE, false, true},
553 {mmGC_USER_RB_BACKEND_DISABLE, false, true},
554 {mmGB_BACKEND_MAP, false, false},
555 {mmPA_SC_RASTER_CONFIG, false, true},
556 {mmPA_SC_RASTER_CONFIG_1, false, true},
557};
558
Alex Deucherdb9635c2016-10-10 12:05:32 -0400559static uint32_t vi_get_register_value(struct amdgpu_device *adev,
560 bool indexed, u32 se_num,
561 u32 sh_num, u32 reg_offset)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400562{
Alex Deucherdb9635c2016-10-10 12:05:32 -0400563 if (indexed) {
564 uint32_t val;
565 unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num;
566 unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400567
Alex Deucherdb9635c2016-10-10 12:05:32 -0400568 switch (reg_offset) {
569 case mmCC_RB_BACKEND_DISABLE:
570 return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable;
571 case mmGC_USER_RB_BACKEND_DISABLE:
572 return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable;
573 case mmPA_SC_RASTER_CONFIG:
574 return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config;
575 case mmPA_SC_RASTER_CONFIG_1:
576 return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config_1;
577 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400578
Alex Deucherdb9635c2016-10-10 12:05:32 -0400579 mutex_lock(&adev->grbm_idx_mutex);
580 if (se_num != 0xffffffff || sh_num != 0xffffffff)
581 amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400582
Alex Deucherdb9635c2016-10-10 12:05:32 -0400583 val = RREG32(reg_offset);
584
585 if (se_num != 0xffffffff || sh_num != 0xffffffff)
586 amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
587 mutex_unlock(&adev->grbm_idx_mutex);
588 return val;
589 } else {
590 unsigned idx;
591
592 switch (reg_offset) {
593 case mmGB_ADDR_CONFIG:
594 return adev->gfx.config.gb_addr_config;
595 case mmMC_ARB_RAMCFG:
596 return adev->gfx.config.mc_arb_ramcfg;
597 case mmGB_TILE_MODE0:
598 case mmGB_TILE_MODE1:
599 case mmGB_TILE_MODE2:
600 case mmGB_TILE_MODE3:
601 case mmGB_TILE_MODE4:
602 case mmGB_TILE_MODE5:
603 case mmGB_TILE_MODE6:
604 case mmGB_TILE_MODE7:
605 case mmGB_TILE_MODE8:
606 case mmGB_TILE_MODE9:
607 case mmGB_TILE_MODE10:
608 case mmGB_TILE_MODE11:
609 case mmGB_TILE_MODE12:
610 case mmGB_TILE_MODE13:
611 case mmGB_TILE_MODE14:
612 case mmGB_TILE_MODE15:
613 case mmGB_TILE_MODE16:
614 case mmGB_TILE_MODE17:
615 case mmGB_TILE_MODE18:
616 case mmGB_TILE_MODE19:
617 case mmGB_TILE_MODE20:
618 case mmGB_TILE_MODE21:
619 case mmGB_TILE_MODE22:
620 case mmGB_TILE_MODE23:
621 case mmGB_TILE_MODE24:
622 case mmGB_TILE_MODE25:
623 case mmGB_TILE_MODE26:
624 case mmGB_TILE_MODE27:
625 case mmGB_TILE_MODE28:
626 case mmGB_TILE_MODE29:
627 case mmGB_TILE_MODE30:
628 case mmGB_TILE_MODE31:
629 idx = (reg_offset - mmGB_TILE_MODE0);
630 return adev->gfx.config.tile_mode_array[idx];
631 case mmGB_MACROTILE_MODE0:
632 case mmGB_MACROTILE_MODE1:
633 case mmGB_MACROTILE_MODE2:
634 case mmGB_MACROTILE_MODE3:
635 case mmGB_MACROTILE_MODE4:
636 case mmGB_MACROTILE_MODE5:
637 case mmGB_MACROTILE_MODE6:
638 case mmGB_MACROTILE_MODE7:
639 case mmGB_MACROTILE_MODE8:
640 case mmGB_MACROTILE_MODE9:
641 case mmGB_MACROTILE_MODE10:
642 case mmGB_MACROTILE_MODE11:
643 case mmGB_MACROTILE_MODE12:
644 case mmGB_MACROTILE_MODE13:
645 case mmGB_MACROTILE_MODE14:
646 case mmGB_MACROTILE_MODE15:
647 idx = (reg_offset - mmGB_MACROTILE_MODE0);
648 return adev->gfx.config.macrotile_mode_array[idx];
649 default:
650 return RREG32(reg_offset);
651 }
652 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400653}
654
655static int vi_read_register(struct amdgpu_device *adev, u32 se_num,
656 u32 sh_num, u32 reg_offset, u32 *value)
657{
Nils Wallméniuseca22402016-03-19 16:12:17 +0100658 const struct amdgpu_allowed_register_entry *asic_register_table = NULL;
659 const struct amdgpu_allowed_register_entry *asic_register_entry;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400660 uint32_t size, i;
661
662 *value = 0;
663 switch (adev->asic_type) {
664 case CHIP_TOPAZ:
665 asic_register_table = tonga_allowed_read_registers;
666 size = ARRAY_SIZE(tonga_allowed_read_registers);
667 break;
David Zhang48299f92015-07-08 01:05:16 +0800668 case CHIP_FIJI:
Alex Deucheraaa36a92015-04-20 17:31:14 -0400669 case CHIP_TONGA:
Flora Cui2cc0c0b2016-03-14 18:33:29 -0400670 case CHIP_POLARIS11:
671 case CHIP_POLARIS10:
Alex Deucheraaa36a92015-04-20 17:31:14 -0400672 case CHIP_CARRIZO:
Samuel Li39bb0c92015-10-08 16:31:43 -0400673 case CHIP_STONEY:
Alex Deucheraaa36a92015-04-20 17:31:14 -0400674 asic_register_table = cz_allowed_read_registers;
675 size = ARRAY_SIZE(cz_allowed_read_registers);
676 break;
677 default:
678 return -EINVAL;
679 }
680
681 if (asic_register_table) {
682 for (i = 0; i < size; i++) {
683 asic_register_entry = asic_register_table + i;
684 if (reg_offset != asic_register_entry->reg_offset)
685 continue;
686 if (!asic_register_entry->untouched)
Alex Deucherdb9635c2016-10-10 12:05:32 -0400687 *value = vi_get_register_value(adev,
688 asic_register_entry->grbm_indexed,
689 se_num, sh_num, reg_offset);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400690 return 0;
691 }
692 }
693
694 for (i = 0; i < ARRAY_SIZE(vi_allowed_read_registers); i++) {
695 if (reg_offset != vi_allowed_read_registers[i].reg_offset)
696 continue;
697
698 if (!vi_allowed_read_registers[i].untouched)
Alex Deucherdb9635c2016-10-10 12:05:32 -0400699 *value = vi_get_register_value(adev,
700 vi_allowed_read_registers[i].grbm_indexed,
701 se_num, sh_num, reg_offset);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400702 return 0;
703 }
704 return -EINVAL;
705}
706
Chunming Zhou89a31822016-06-06 13:06:45 +0800707static int vi_gpu_pci_config_reset(struct amdgpu_device *adev)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400708{
Alex Deuchera2c5c692015-10-14 09:39:37 -0400709 u32 i;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400710
711 dev_info(adev->dev, "GPU pci config reset\n");
712
Alex Deucheraaa36a92015-04-20 17:31:14 -0400713 /* disable BM */
714 pci_clear_master(adev->pdev);
715 /* reset */
716 amdgpu_pci_config_reset(adev);
717
718 udelay(100);
719
720 /* wait for asic to come out of reset */
721 for (i = 0; i < adev->usec_timeout; i++) {
Chunming Zhoub314f9a2016-06-06 13:50:18 +0800722 if (RREG32(mmCONFIG_MEMSIZE) != 0xffffffff) {
723 /* enable BM */
724 pci_set_master(adev->pdev);
Chunming Zhou89a31822016-06-06 13:06:45 +0800725 return 0;
Chunming Zhoub314f9a2016-06-06 13:50:18 +0800726 }
Alex Deucheraaa36a92015-04-20 17:31:14 -0400727 udelay(1);
728 }
Chunming Zhou89a31822016-06-06 13:06:45 +0800729 return -EINVAL;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400730}
731
732static void vi_set_bios_scratch_engine_hung(struct amdgpu_device *adev, bool hung)
733{
734 u32 tmp = RREG32(mmBIOS_SCRATCH_3);
735
736 if (hung)
737 tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG;
738 else
739 tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG;
740
741 WREG32(mmBIOS_SCRATCH_3, tmp);
742}
743
744/**
745 * vi_asic_reset - soft reset GPU
746 *
747 * @adev: amdgpu_device pointer
748 *
749 * Look up which blocks are hung and attempt
750 * to reset them.
751 * Returns 0 for success.
752 */
753static int vi_asic_reset(struct amdgpu_device *adev)
754{
Chunming Zhou89a31822016-06-06 13:06:45 +0800755 int r;
756
Alex Deuchera2c5c692015-10-14 09:39:37 -0400757 vi_set_bios_scratch_engine_hung(adev, true);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400758
Chunming Zhou89a31822016-06-06 13:06:45 +0800759 r = vi_gpu_pci_config_reset(adev);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400760
Alex Deuchera2c5c692015-10-14 09:39:37 -0400761 vi_set_bios_scratch_engine_hung(adev, false);
Alex Deucheraaa36a92015-04-20 17:31:14 -0400762
Chunming Zhou89a31822016-06-06 13:06:45 +0800763 return r;
Alex Deucheraaa36a92015-04-20 17:31:14 -0400764}
765
766static int vi_set_uvd_clock(struct amdgpu_device *adev, u32 clock,
767 u32 cntl_reg, u32 status_reg)
768{
769 int r, i;
770 struct atom_clock_dividers dividers;
771 uint32_t tmp;
772
773 r = amdgpu_atombios_get_clock_dividers(adev,
774 COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK,
775 clock, false, &dividers);
776 if (r)
777 return r;
778
779 tmp = RREG32_SMC(cntl_reg);
780 tmp &= ~(CG_DCLK_CNTL__DCLK_DIR_CNTL_EN_MASK |
781 CG_DCLK_CNTL__DCLK_DIVIDER_MASK);
782 tmp |= dividers.post_divider;
783 WREG32_SMC(cntl_reg, tmp);
784
785 for (i = 0; i < 100; i++) {
786 if (RREG32_SMC(status_reg) & CG_DCLK_STATUS__DCLK_STATUS_MASK)
787 break;
788 mdelay(10);
789 }
790 if (i == 100)
791 return -ETIMEDOUT;
792
793 return 0;
794}
795
796static int vi_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
797{
798 int r;
799
800 r = vi_set_uvd_clock(adev, vclk, ixCG_VCLK_CNTL, ixCG_VCLK_STATUS);
801 if (r)
802 return r;
803
804 r = vi_set_uvd_clock(adev, dclk, ixCG_DCLK_CNTL, ixCG_DCLK_STATUS);
805
806 return 0;
807}
808
809static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
810{
811 /* todo */
812
813 return 0;
814}
815
816static void vi_pcie_gen3_enable(struct amdgpu_device *adev)
817{
Alex Deuchere79d5c02015-10-06 09:38:45 -0400818 if (pci_is_root_bus(adev->pdev->bus))
819 return;
820
Alex Deucheraaa36a92015-04-20 17:31:14 -0400821 if (amdgpu_pcie_gen2 == 0)
822 return;
823
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800824 if (adev->flags & AMD_IS_APU)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400825 return;
826
Alex Deucherd0dd7f02015-11-11 19:45:06 -0500827 if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |
828 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)))
Alex Deucheraaa36a92015-04-20 17:31:14 -0400829 return;
830
831 /* todo */
832}
833
834static void vi_program_aspm(struct amdgpu_device *adev)
835{
836
837 if (amdgpu_aspm == 0)
838 return;
839
840 /* todo */
841}
842
843static void vi_enable_doorbell_aperture(struct amdgpu_device *adev,
844 bool enable)
845{
846 u32 tmp;
847
848 /* not necessary on CZ */
Jammy Zhou2f7d10b2015-07-22 11:29:01 +0800849 if (adev->flags & AMD_IS_APU)
Alex Deucheraaa36a92015-04-20 17:31:14 -0400850 return;
851
852 tmp = RREG32(mmBIF_DOORBELL_APER_EN);
853 if (enable)
854 tmp = REG_SET_FIELD(tmp, BIF_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, 1);
855 else
856 tmp = REG_SET_FIELD(tmp, BIF_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, 0);
857
858 WREG32(mmBIF_DOORBELL_APER_EN, tmp);
859}
860
861/* topaz has no DCE, UVD, VCE */
862static const struct amdgpu_ip_block_version topaz_ip_blocks[] =
863{
864 /* ORDER MATTERS! */
865 {
yanyang15fc3aee2015-05-22 14:39:35 -0400866 .type = AMD_IP_BLOCK_TYPE_COMMON,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400867 .major = 2,
868 .minor = 0,
869 .rev = 0,
870 .funcs = &vi_common_ip_funcs,
871 },
872 {
yanyang15fc3aee2015-05-22 14:39:35 -0400873 .type = AMD_IP_BLOCK_TYPE_GMC,
Ken Wang429c45d2016-02-03 19:16:54 +0800874 .major = 7,
875 .minor = 4,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400876 .rev = 0,
Ken Wang429c45d2016-02-03 19:16:54 +0800877 .funcs = &gmc_v7_0_ip_funcs,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400878 },
879 {
yanyang15fc3aee2015-05-22 14:39:35 -0400880 .type = AMD_IP_BLOCK_TYPE_IH,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400881 .major = 2,
882 .minor = 4,
883 .rev = 0,
884 .funcs = &iceland_ih_ip_funcs,
885 },
886 {
yanyang15fc3aee2015-05-22 14:39:35 -0400887 .type = AMD_IP_BLOCK_TYPE_SMC,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400888 .major = 7,
889 .minor = 1,
890 .rev = 0,
Alex Deucher1f7371b2015-12-02 17:46:21 -0500891 .funcs = &amdgpu_pp_ip_funcs,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400892 },
893 {
yanyang15fc3aee2015-05-22 14:39:35 -0400894 .type = AMD_IP_BLOCK_TYPE_GFX,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400895 .major = 8,
896 .minor = 0,
897 .rev = 0,
898 .funcs = &gfx_v8_0_ip_funcs,
899 },
900 {
yanyang15fc3aee2015-05-22 14:39:35 -0400901 .type = AMD_IP_BLOCK_TYPE_SDMA,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400902 .major = 2,
903 .minor = 4,
904 .rev = 0,
905 .funcs = &sdma_v2_4_ip_funcs,
906 },
907};
908
Alex Deucher4f4b7832016-08-08 14:45:29 -0400909static const struct amdgpu_ip_block_version topaz_ip_blocks_vd[] =
910{
911 /* ORDER MATTERS! */
912 {
913 .type = AMD_IP_BLOCK_TYPE_COMMON,
914 .major = 2,
915 .minor = 0,
916 .rev = 0,
917 .funcs = &vi_common_ip_funcs,
918 },
919 {
920 .type = AMD_IP_BLOCK_TYPE_GMC,
921 .major = 7,
922 .minor = 4,
923 .rev = 0,
924 .funcs = &gmc_v7_0_ip_funcs,
925 },
926 {
927 .type = AMD_IP_BLOCK_TYPE_IH,
928 .major = 2,
929 .minor = 4,
930 .rev = 0,
931 .funcs = &iceland_ih_ip_funcs,
932 },
933 {
934 .type = AMD_IP_BLOCK_TYPE_SMC,
935 .major = 7,
936 .minor = 1,
937 .rev = 0,
938 .funcs = &amdgpu_pp_ip_funcs,
939 },
940 {
941 .type = AMD_IP_BLOCK_TYPE_DCE,
942 .major = 1,
943 .minor = 0,
944 .rev = 0,
945 .funcs = &dce_virtual_ip_funcs,
946 },
947 {
948 .type = AMD_IP_BLOCK_TYPE_GFX,
949 .major = 8,
950 .minor = 0,
951 .rev = 0,
952 .funcs = &gfx_v8_0_ip_funcs,
953 },
954 {
955 .type = AMD_IP_BLOCK_TYPE_SDMA,
956 .major = 2,
957 .minor = 4,
958 .rev = 0,
959 .funcs = &sdma_v2_4_ip_funcs,
960 },
961};
962
Alex Deucheraaa36a92015-04-20 17:31:14 -0400963static const struct amdgpu_ip_block_version tonga_ip_blocks[] =
964{
965 /* ORDER MATTERS! */
966 {
yanyang15fc3aee2015-05-22 14:39:35 -0400967 .type = AMD_IP_BLOCK_TYPE_COMMON,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400968 .major = 2,
969 .minor = 0,
970 .rev = 0,
971 .funcs = &vi_common_ip_funcs,
972 },
973 {
yanyang15fc3aee2015-05-22 14:39:35 -0400974 .type = AMD_IP_BLOCK_TYPE_GMC,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400975 .major = 8,
976 .minor = 0,
977 .rev = 0,
978 .funcs = &gmc_v8_0_ip_funcs,
979 },
980 {
yanyang15fc3aee2015-05-22 14:39:35 -0400981 .type = AMD_IP_BLOCK_TYPE_IH,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400982 .major = 3,
983 .minor = 0,
984 .rev = 0,
985 .funcs = &tonga_ih_ip_funcs,
986 },
987 {
yanyang15fc3aee2015-05-22 14:39:35 -0400988 .type = AMD_IP_BLOCK_TYPE_SMC,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400989 .major = 7,
990 .minor = 1,
991 .rev = 0,
Alex Deucher1f7371b2015-12-02 17:46:21 -0500992 .funcs = &amdgpu_pp_ip_funcs,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400993 },
994 {
yanyang15fc3aee2015-05-22 14:39:35 -0400995 .type = AMD_IP_BLOCK_TYPE_DCE,
Alex Deucheraaa36a92015-04-20 17:31:14 -0400996 .major = 10,
997 .minor = 0,
998 .rev = 0,
999 .funcs = &dce_v10_0_ip_funcs,
1000 },
1001 {
yanyang15fc3aee2015-05-22 14:39:35 -04001002 .type = AMD_IP_BLOCK_TYPE_GFX,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001003 .major = 8,
1004 .minor = 0,
1005 .rev = 0,
1006 .funcs = &gfx_v8_0_ip_funcs,
1007 },
1008 {
yanyang15fc3aee2015-05-22 14:39:35 -04001009 .type = AMD_IP_BLOCK_TYPE_SDMA,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001010 .major = 3,
1011 .minor = 0,
1012 .rev = 0,
1013 .funcs = &sdma_v3_0_ip_funcs,
1014 },
1015 {
yanyang15fc3aee2015-05-22 14:39:35 -04001016 .type = AMD_IP_BLOCK_TYPE_UVD,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001017 .major = 5,
1018 .minor = 0,
1019 .rev = 0,
1020 .funcs = &uvd_v5_0_ip_funcs,
1021 },
1022 {
yanyang15fc3aee2015-05-22 14:39:35 -04001023 .type = AMD_IP_BLOCK_TYPE_VCE,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001024 .major = 3,
1025 .minor = 0,
1026 .rev = 0,
1027 .funcs = &vce_v3_0_ip_funcs,
1028 },
1029};
1030
Emily Denge9ed3a62016-08-08 11:36:45 +08001031static const struct amdgpu_ip_block_version tonga_ip_blocks_vd[] =
1032{
1033 /* ORDER MATTERS! */
1034 {
1035 .type = AMD_IP_BLOCK_TYPE_COMMON,
1036 .major = 2,
1037 .minor = 0,
1038 .rev = 0,
1039 .funcs = &vi_common_ip_funcs,
1040 },
1041 {
1042 .type = AMD_IP_BLOCK_TYPE_GMC,
1043 .major = 8,
1044 .minor = 0,
1045 .rev = 0,
1046 .funcs = &gmc_v8_0_ip_funcs,
1047 },
1048 {
1049 .type = AMD_IP_BLOCK_TYPE_IH,
1050 .major = 3,
1051 .minor = 0,
1052 .rev = 0,
1053 .funcs = &tonga_ih_ip_funcs,
1054 },
1055 {
1056 .type = AMD_IP_BLOCK_TYPE_SMC,
1057 .major = 7,
1058 .minor = 1,
1059 .rev = 0,
1060 .funcs = &amdgpu_pp_ip_funcs,
1061 },
1062 {
1063 .type = AMD_IP_BLOCK_TYPE_DCE,
1064 .major = 10,
1065 .minor = 0,
1066 .rev = 0,
1067 .funcs = &dce_virtual_ip_funcs,
1068 },
1069 {
1070 .type = AMD_IP_BLOCK_TYPE_GFX,
1071 .major = 8,
1072 .minor = 0,
1073 .rev = 0,
1074 .funcs = &gfx_v8_0_ip_funcs,
1075 },
1076 {
1077 .type = AMD_IP_BLOCK_TYPE_SDMA,
1078 .major = 3,
1079 .minor = 0,
1080 .rev = 0,
1081 .funcs = &sdma_v3_0_ip_funcs,
1082 },
1083 {
1084 .type = AMD_IP_BLOCK_TYPE_UVD,
1085 .major = 5,
1086 .minor = 0,
1087 .rev = 0,
1088 .funcs = &uvd_v5_0_ip_funcs,
1089 },
1090 {
1091 .type = AMD_IP_BLOCK_TYPE_VCE,
1092 .major = 3,
1093 .minor = 0,
1094 .rev = 0,
1095 .funcs = &vce_v3_0_ip_funcs,
1096 },
1097};
1098
David Zhang48299f92015-07-08 01:05:16 +08001099static const struct amdgpu_ip_block_version fiji_ip_blocks[] =
1100{
1101 /* ORDER MATTERS! */
1102 {
1103 .type = AMD_IP_BLOCK_TYPE_COMMON,
1104 .major = 2,
1105 .minor = 0,
1106 .rev = 0,
1107 .funcs = &vi_common_ip_funcs,
David Zhang127a2622015-07-08 01:11:52 +08001108 },
1109 {
1110 .type = AMD_IP_BLOCK_TYPE_GMC,
1111 .major = 8,
1112 .minor = 5,
1113 .rev = 0,
1114 .funcs = &gmc_v8_0_ip_funcs,
1115 },
David Zhangaa8a3b52015-07-08 21:40:31 +08001116 {
1117 .type = AMD_IP_BLOCK_TYPE_IH,
1118 .major = 3,
1119 .minor = 0,
1120 .rev = 0,
1121 .funcs = &tonga_ih_ip_funcs,
1122 },
David Zhang8e711e1a2015-07-08 01:23:25 +08001123 {
1124 .type = AMD_IP_BLOCK_TYPE_SMC,
1125 .major = 7,
1126 .minor = 1,
1127 .rev = 0,
Eric Huang899fa4c2015-09-29 14:58:53 -04001128 .funcs = &amdgpu_pp_ip_funcs,
David Zhang8e711e1a2015-07-08 01:23:25 +08001129 },
David Zhang84390862015-07-08 01:28:20 +08001130 {
1131 .type = AMD_IP_BLOCK_TYPE_DCE,
1132 .major = 10,
1133 .minor = 1,
1134 .rev = 0,
1135 .funcs = &dce_v10_0_ip_funcs,
1136 },
David Zhangaf15a2d2015-07-30 19:42:11 -04001137 {
1138 .type = AMD_IP_BLOCK_TYPE_GFX,
1139 .major = 8,
1140 .minor = 0,
1141 .rev = 0,
1142 .funcs = &gfx_v8_0_ip_funcs,
1143 },
David Zhang1a5bbb62015-07-08 17:29:27 +08001144 {
1145 .type = AMD_IP_BLOCK_TYPE_SDMA,
1146 .major = 3,
1147 .minor = 0,
1148 .rev = 0,
1149 .funcs = &sdma_v3_0_ip_funcs,
1150 },
David Zhang974ee3d2015-07-08 17:32:15 +08001151 {
1152 .type = AMD_IP_BLOCK_TYPE_UVD,
1153 .major = 6,
1154 .minor = 0,
1155 .rev = 0,
1156 .funcs = &uvd_v6_0_ip_funcs,
1157 },
Alex Deucher188a9bc2015-07-27 14:24:14 -04001158 {
1159 .type = AMD_IP_BLOCK_TYPE_VCE,
1160 .major = 3,
1161 .minor = 0,
1162 .rev = 0,
1163 .funcs = &vce_v3_0_ip_funcs,
1164 },
David Zhang48299f92015-07-08 01:05:16 +08001165};
1166
Emily Denge9ed3a62016-08-08 11:36:45 +08001167static const struct amdgpu_ip_block_version fiji_ip_blocks_vd[] =
1168{
1169 /* ORDER MATTERS! */
1170 {
1171 .type = AMD_IP_BLOCK_TYPE_COMMON,
1172 .major = 2,
1173 .minor = 0,
1174 .rev = 0,
1175 .funcs = &vi_common_ip_funcs,
1176 },
1177 {
1178 .type = AMD_IP_BLOCK_TYPE_GMC,
1179 .major = 8,
1180 .minor = 5,
1181 .rev = 0,
1182 .funcs = &gmc_v8_0_ip_funcs,
1183 },
1184 {
1185 .type = AMD_IP_BLOCK_TYPE_IH,
1186 .major = 3,
1187 .minor = 0,
1188 .rev = 0,
1189 .funcs = &tonga_ih_ip_funcs,
1190 },
1191 {
1192 .type = AMD_IP_BLOCK_TYPE_SMC,
1193 .major = 7,
1194 .minor = 1,
1195 .rev = 0,
1196 .funcs = &amdgpu_pp_ip_funcs,
1197 },
1198 {
1199 .type = AMD_IP_BLOCK_TYPE_DCE,
1200 .major = 10,
1201 .minor = 1,
1202 .rev = 0,
1203 .funcs = &dce_virtual_ip_funcs,
1204 },
1205 {
1206 .type = AMD_IP_BLOCK_TYPE_GFX,
1207 .major = 8,
1208 .minor = 0,
1209 .rev = 0,
1210 .funcs = &gfx_v8_0_ip_funcs,
1211 },
1212 {
1213 .type = AMD_IP_BLOCK_TYPE_SDMA,
1214 .major = 3,
1215 .minor = 0,
1216 .rev = 0,
1217 .funcs = &sdma_v3_0_ip_funcs,
1218 },
1219 {
1220 .type = AMD_IP_BLOCK_TYPE_UVD,
1221 .major = 6,
1222 .minor = 0,
1223 .rev = 0,
1224 .funcs = &uvd_v6_0_ip_funcs,
1225 },
1226 {
1227 .type = AMD_IP_BLOCK_TYPE_VCE,
1228 .major = 3,
1229 .minor = 0,
1230 .rev = 0,
1231 .funcs = &vce_v3_0_ip_funcs,
1232 },
1233};
1234
Flora Cui2cc0c0b2016-03-14 18:33:29 -04001235static const struct amdgpu_ip_block_version polaris11_ip_blocks[] =
Flora Cuic0c1f572015-12-07 18:33:10 +08001236{
1237 /* ORDER MATTERS! */
1238 {
1239 .type = AMD_IP_BLOCK_TYPE_COMMON,
1240 .major = 2,
1241 .minor = 0,
1242 .rev = 0,
1243 .funcs = &vi_common_ip_funcs,
1244 },
1245 {
1246 .type = AMD_IP_BLOCK_TYPE_GMC,
1247 .major = 8,
1248 .minor = 1,
1249 .rev = 0,
1250 .funcs = &gmc_v8_0_ip_funcs,
1251 },
1252 {
1253 .type = AMD_IP_BLOCK_TYPE_IH,
1254 .major = 3,
1255 .minor = 1,
1256 .rev = 0,
1257 .funcs = &tonga_ih_ip_funcs,
1258 },
1259 {
1260 .type = AMD_IP_BLOCK_TYPE_SMC,
1261 .major = 7,
1262 .minor = 2,
1263 .rev = 0,
1264 .funcs = &amdgpu_pp_ip_funcs,
1265 },
1266 {
1267 .type = AMD_IP_BLOCK_TYPE_DCE,
1268 .major = 11,
1269 .minor = 2,
1270 .rev = 0,
1271 .funcs = &dce_v11_0_ip_funcs,
1272 },
1273 {
1274 .type = AMD_IP_BLOCK_TYPE_GFX,
1275 .major = 8,
1276 .minor = 0,
1277 .rev = 0,
1278 .funcs = &gfx_v8_0_ip_funcs,
1279 },
1280 {
1281 .type = AMD_IP_BLOCK_TYPE_SDMA,
1282 .major = 3,
1283 .minor = 1,
1284 .rev = 0,
1285 .funcs = &sdma_v3_0_ip_funcs,
1286 },
1287 {
1288 .type = AMD_IP_BLOCK_TYPE_UVD,
1289 .major = 6,
1290 .minor = 3,
1291 .rev = 0,
1292 .funcs = &uvd_v6_0_ip_funcs,
1293 },
1294 {
1295 .type = AMD_IP_BLOCK_TYPE_VCE,
1296 .major = 3,
1297 .minor = 4,
1298 .rev = 0,
1299 .funcs = &vce_v3_0_ip_funcs,
1300 },
1301};
1302
Emily Denge9ed3a62016-08-08 11:36:45 +08001303static const struct amdgpu_ip_block_version polaris11_ip_blocks_vd[] =
1304{
1305 /* ORDER MATTERS! */
1306 {
1307 .type = AMD_IP_BLOCK_TYPE_COMMON,
1308 .major = 2,
1309 .minor = 0,
1310 .rev = 0,
1311 .funcs = &vi_common_ip_funcs,
1312 },
1313 {
1314 .type = AMD_IP_BLOCK_TYPE_GMC,
1315 .major = 8,
1316 .minor = 1,
1317 .rev = 0,
1318 .funcs = &gmc_v8_0_ip_funcs,
1319 },
1320 {
1321 .type = AMD_IP_BLOCK_TYPE_IH,
1322 .major = 3,
1323 .minor = 1,
1324 .rev = 0,
1325 .funcs = &tonga_ih_ip_funcs,
1326 },
1327 {
1328 .type = AMD_IP_BLOCK_TYPE_SMC,
1329 .major = 7,
1330 .minor = 2,
1331 .rev = 0,
1332 .funcs = &amdgpu_pp_ip_funcs,
1333 },
1334 {
1335 .type = AMD_IP_BLOCK_TYPE_DCE,
1336 .major = 11,
1337 .minor = 2,
1338 .rev = 0,
1339 .funcs = &dce_virtual_ip_funcs,
1340 },
1341 {
1342 .type = AMD_IP_BLOCK_TYPE_GFX,
1343 .major = 8,
1344 .minor = 0,
1345 .rev = 0,
1346 .funcs = &gfx_v8_0_ip_funcs,
1347 },
1348 {
1349 .type = AMD_IP_BLOCK_TYPE_SDMA,
1350 .major = 3,
1351 .minor = 1,
1352 .rev = 0,
1353 .funcs = &sdma_v3_0_ip_funcs,
1354 },
1355 {
1356 .type = AMD_IP_BLOCK_TYPE_UVD,
1357 .major = 6,
1358 .minor = 3,
1359 .rev = 0,
1360 .funcs = &uvd_v6_0_ip_funcs,
1361 },
1362 {
1363 .type = AMD_IP_BLOCK_TYPE_VCE,
1364 .major = 3,
1365 .minor = 4,
1366 .rev = 0,
1367 .funcs = &vce_v3_0_ip_funcs,
1368 },
1369};
1370
Alex Deucheraaa36a92015-04-20 17:31:14 -04001371static const struct amdgpu_ip_block_version cz_ip_blocks[] =
1372{
1373 /* ORDER MATTERS! */
1374 {
yanyang15fc3aee2015-05-22 14:39:35 -04001375 .type = AMD_IP_BLOCK_TYPE_COMMON,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001376 .major = 2,
1377 .minor = 0,
1378 .rev = 0,
1379 .funcs = &vi_common_ip_funcs,
1380 },
1381 {
yanyang15fc3aee2015-05-22 14:39:35 -04001382 .type = AMD_IP_BLOCK_TYPE_GMC,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001383 .major = 8,
1384 .minor = 0,
1385 .rev = 0,
1386 .funcs = &gmc_v8_0_ip_funcs,
1387 },
1388 {
yanyang15fc3aee2015-05-22 14:39:35 -04001389 .type = AMD_IP_BLOCK_TYPE_IH,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001390 .major = 3,
1391 .minor = 0,
1392 .rev = 0,
1393 .funcs = &cz_ih_ip_funcs,
1394 },
1395 {
yanyang15fc3aee2015-05-22 14:39:35 -04001396 .type = AMD_IP_BLOCK_TYPE_SMC,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001397 .major = 8,
1398 .minor = 0,
1399 .rev = 0,
Alex Deucher1f7371b2015-12-02 17:46:21 -05001400 .funcs = &amdgpu_pp_ip_funcs
Alex Deucheraaa36a92015-04-20 17:31:14 -04001401 },
1402 {
yanyang15fc3aee2015-05-22 14:39:35 -04001403 .type = AMD_IP_BLOCK_TYPE_DCE,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001404 .major = 11,
1405 .minor = 0,
1406 .rev = 0,
1407 .funcs = &dce_v11_0_ip_funcs,
1408 },
1409 {
yanyang15fc3aee2015-05-22 14:39:35 -04001410 .type = AMD_IP_BLOCK_TYPE_GFX,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001411 .major = 8,
1412 .minor = 0,
1413 .rev = 0,
1414 .funcs = &gfx_v8_0_ip_funcs,
1415 },
1416 {
yanyang15fc3aee2015-05-22 14:39:35 -04001417 .type = AMD_IP_BLOCK_TYPE_SDMA,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001418 .major = 3,
1419 .minor = 0,
1420 .rev = 0,
1421 .funcs = &sdma_v3_0_ip_funcs,
1422 },
1423 {
yanyang15fc3aee2015-05-22 14:39:35 -04001424 .type = AMD_IP_BLOCK_TYPE_UVD,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001425 .major = 6,
1426 .minor = 0,
1427 .rev = 0,
1428 .funcs = &uvd_v6_0_ip_funcs,
1429 },
1430 {
yanyang15fc3aee2015-05-22 14:39:35 -04001431 .type = AMD_IP_BLOCK_TYPE_VCE,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001432 .major = 3,
1433 .minor = 0,
1434 .rev = 0,
1435 .funcs = &vce_v3_0_ip_funcs,
1436 },
Maruthi Bayyavarapua8fe58c2015-09-22 17:05:20 -04001437#if defined(CONFIG_DRM_AMD_ACP)
1438 {
1439 .type = AMD_IP_BLOCK_TYPE_ACP,
1440 .major = 2,
1441 .minor = 2,
1442 .rev = 0,
1443 .funcs = &acp_ip_funcs,
1444 },
1445#endif
Alex Deucheraaa36a92015-04-20 17:31:14 -04001446};
1447
Emily Denge9ed3a62016-08-08 11:36:45 +08001448static const struct amdgpu_ip_block_version cz_ip_blocks_vd[] =
1449{
1450 /* ORDER MATTERS! */
1451 {
1452 .type = AMD_IP_BLOCK_TYPE_COMMON,
1453 .major = 2,
1454 .minor = 0,
1455 .rev = 0,
1456 .funcs = &vi_common_ip_funcs,
1457 },
1458 {
1459 .type = AMD_IP_BLOCK_TYPE_GMC,
1460 .major = 8,
1461 .minor = 0,
1462 .rev = 0,
1463 .funcs = &gmc_v8_0_ip_funcs,
1464 },
1465 {
1466 .type = AMD_IP_BLOCK_TYPE_IH,
1467 .major = 3,
1468 .minor = 0,
1469 .rev = 0,
1470 .funcs = &cz_ih_ip_funcs,
1471 },
1472 {
1473 .type = AMD_IP_BLOCK_TYPE_SMC,
1474 .major = 8,
1475 .minor = 0,
1476 .rev = 0,
1477 .funcs = &amdgpu_pp_ip_funcs
1478 },
1479 {
1480 .type = AMD_IP_BLOCK_TYPE_DCE,
1481 .major = 11,
1482 .minor = 0,
1483 .rev = 0,
1484 .funcs = &dce_virtual_ip_funcs,
1485 },
1486 {
1487 .type = AMD_IP_BLOCK_TYPE_GFX,
1488 .major = 8,
1489 .minor = 0,
1490 .rev = 0,
1491 .funcs = &gfx_v8_0_ip_funcs,
1492 },
1493 {
1494 .type = AMD_IP_BLOCK_TYPE_SDMA,
1495 .major = 3,
1496 .minor = 0,
1497 .rev = 0,
1498 .funcs = &sdma_v3_0_ip_funcs,
1499 },
1500 {
1501 .type = AMD_IP_BLOCK_TYPE_UVD,
1502 .major = 6,
1503 .minor = 0,
1504 .rev = 0,
1505 .funcs = &uvd_v6_0_ip_funcs,
1506 },
1507 {
1508 .type = AMD_IP_BLOCK_TYPE_VCE,
1509 .major = 3,
1510 .minor = 0,
1511 .rev = 0,
1512 .funcs = &vce_v3_0_ip_funcs,
1513 },
1514#if defined(CONFIG_DRM_AMD_ACP)
1515 {
1516 .type = AMD_IP_BLOCK_TYPE_ACP,
1517 .major = 2,
1518 .minor = 2,
1519 .rev = 0,
1520 .funcs = &acp_ip_funcs,
1521 },
1522#endif
1523};
1524
Alex Deucheraaa36a92015-04-20 17:31:14 -04001525int vi_set_ip_blocks(struct amdgpu_device *adev)
1526{
Emily Deng9accf2f2016-08-10 16:01:25 +08001527 if (adev->enable_virtual_display) {
Emily Denga6be7572016-08-08 11:37:50 +08001528 switch (adev->asic_type) {
1529 case CHIP_TOPAZ:
Alex Deucher4f4b7832016-08-08 14:45:29 -04001530 adev->ip_blocks = topaz_ip_blocks_vd;
1531 adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks_vd);
Emily Denga6be7572016-08-08 11:37:50 +08001532 break;
1533 case CHIP_FIJI:
1534 adev->ip_blocks = fiji_ip_blocks_vd;
1535 adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks_vd);
1536 break;
1537 case CHIP_TONGA:
1538 adev->ip_blocks = tonga_ip_blocks_vd;
1539 adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks_vd);
1540 break;
1541 case CHIP_POLARIS11:
1542 case CHIP_POLARIS10:
1543 adev->ip_blocks = polaris11_ip_blocks_vd;
1544 adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks_vd);
1545 break;
1546
1547 case CHIP_CARRIZO:
1548 case CHIP_STONEY:
1549 adev->ip_blocks = cz_ip_blocks_vd;
1550 adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks_vd);
1551 break;
1552 default:
1553 /* FIXME: not supported yet */
1554 return -EINVAL;
1555 }
1556 } else {
1557 switch (adev->asic_type) {
1558 case CHIP_TOPAZ:
1559 adev->ip_blocks = topaz_ip_blocks;
1560 adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks);
1561 break;
1562 case CHIP_FIJI:
1563 adev->ip_blocks = fiji_ip_blocks;
1564 adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks);
1565 break;
1566 case CHIP_TONGA:
1567 adev->ip_blocks = tonga_ip_blocks;
1568 adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks);
1569 break;
1570 case CHIP_POLARIS11:
1571 case CHIP_POLARIS10:
1572 adev->ip_blocks = polaris11_ip_blocks;
1573 adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks);
1574 break;
1575 case CHIP_CARRIZO:
1576 case CHIP_STONEY:
1577 adev->ip_blocks = cz_ip_blocks;
1578 adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks);
1579 break;
1580 default:
1581 /* FIXME: not supported yet */
1582 return -EINVAL;
1583 }
Alex Deucheraaa36a92015-04-20 17:31:14 -04001584 }
1585
Alex Deucheraaa36a92015-04-20 17:31:14 -04001586 return 0;
1587}
1588
Samuel Li39bb0c92015-10-08 16:31:43 -04001589#define ATI_REV_ID_FUSE_MACRO__ADDRESS 0xC0014044
1590#define ATI_REV_ID_FUSE_MACRO__SHIFT 9
1591#define ATI_REV_ID_FUSE_MACRO__MASK 0x00001E00
1592
Alex Deucheraaa36a92015-04-20 17:31:14 -04001593static uint32_t vi_get_rev_id(struct amdgpu_device *adev)
1594{
Flora Cuiabdfb852015-11-20 11:40:53 +08001595 if (adev->flags & AMD_IS_APU)
Samuel Li39bb0c92015-10-08 16:31:43 -04001596 return (RREG32_SMC(ATI_REV_ID_FUSE_MACRO__ADDRESS) & ATI_REV_ID_FUSE_MACRO__MASK)
1597 >> ATI_REV_ID_FUSE_MACRO__SHIFT;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001598 else
Flora Cuiabdfb852015-11-20 11:40:53 +08001599 return (RREG32(mmPCIE_EFUSE4) & PCIE_EFUSE4__STRAP_BIF_ATI_REV_ID_MASK)
1600 >> PCIE_EFUSE4__STRAP_BIF_ATI_REV_ID__SHIFT;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001601}
1602
1603static const struct amdgpu_asic_funcs vi_asic_funcs =
1604{
1605 .read_disabled_bios = &vi_read_disabled_bios,
Alex Deucher95addb2a2015-11-24 10:37:54 -05001606 .read_bios_from_rom = &vi_read_bios_from_rom,
Monk Liu4e99a442016-03-31 13:26:59 +08001607 .detect_hw_virtualization = vi_detect_hw_virtualization,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001608 .read_register = &vi_read_register,
1609 .reset = &vi_asic_reset,
1610 .set_vga_state = &vi_vga_set_state,
1611 .get_xclk = &vi_get_xclk,
1612 .set_uvd_clocks = &vi_set_uvd_clocks,
1613 .set_vce_clocks = &vi_set_vce_clocks,
Alex Deucheraaa36a92015-04-20 17:31:14 -04001614};
1615
yanyang15fc3aee2015-05-22 14:39:35 -04001616static int vi_common_early_init(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001617{
1618 bool smc_enabled = false;
yanyang15fc3aee2015-05-22 14:39:35 -04001619 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001620
Jammy Zhou2f7d10b2015-07-22 11:29:01 +08001621 if (adev->flags & AMD_IS_APU) {
Alex Deucher7b92cdb2015-07-10 16:21:10 -04001622 adev->smc_rreg = &cz_smc_rreg;
1623 adev->smc_wreg = &cz_smc_wreg;
1624 } else {
1625 adev->smc_rreg = &vi_smc_rreg;
1626 adev->smc_wreg = &vi_smc_wreg;
1627 }
Alex Deucheraaa36a92015-04-20 17:31:14 -04001628 adev->pcie_rreg = &vi_pcie_rreg;
1629 adev->pcie_wreg = &vi_pcie_wreg;
1630 adev->uvd_ctx_rreg = &vi_uvd_ctx_rreg;
1631 adev->uvd_ctx_wreg = &vi_uvd_ctx_wreg;
1632 adev->didt_rreg = &vi_didt_rreg;
1633 adev->didt_wreg = &vi_didt_wreg;
Rex Zhuccdbb202016-06-08 12:47:41 +08001634 adev->gc_cac_rreg = &vi_gc_cac_rreg;
1635 adev->gc_cac_wreg = &vi_gc_cac_wreg;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001636
1637 adev->asic_funcs = &vi_asic_funcs;
1638
yanyang15fc3aee2015-05-22 14:39:35 -04001639 if (amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_SMC) &&
1640 (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_SMC)))
Alex Deucheraaa36a92015-04-20 17:31:14 -04001641 smc_enabled = true;
1642
1643 adev->rev_id = vi_get_rev_id(adev);
1644 adev->external_rev_id = 0xFF;
1645 switch (adev->asic_type) {
1646 case CHIP_TOPAZ:
Alex Deucheraaa36a92015-04-20 17:31:14 -04001647 adev->cg_flags = 0;
1648 adev->pg_flags = 0;
1649 adev->external_rev_id = 0x1;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001650 break;
David Zhang48299f92015-07-08 01:05:16 +08001651 case CHIP_FIJI:
Alex Deucher14698b62016-04-07 18:38:00 -04001652 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
1653 AMD_CG_SUPPORT_GFX_MGLS |
1654 AMD_CG_SUPPORT_GFX_RLC_LS |
1655 AMD_CG_SUPPORT_GFX_CP_LS |
1656 AMD_CG_SUPPORT_GFX_CGTS |
1657 AMD_CG_SUPPORT_GFX_CGTS_LS |
1658 AMD_CG_SUPPORT_GFX_CGCG |
Alex Deuchere08d53c2016-04-08 00:42:51 -04001659 AMD_CG_SUPPORT_GFX_CGLS |
1660 AMD_CG_SUPPORT_SDMA_MGCG |
Alex Deucherc90766c2016-04-08 00:52:58 -04001661 AMD_CG_SUPPORT_SDMA_LS |
1662 AMD_CG_SUPPORT_BIF_LS |
1663 AMD_CG_SUPPORT_HDP_MGCG |
1664 AMD_CG_SUPPORT_HDP_LS |
Alex Deucher3fde56b2016-04-08 01:01:18 -04001665 AMD_CG_SUPPORT_ROM_MGCG |
1666 AMD_CG_SUPPORT_MC_MGCG |
1667 AMD_CG_SUPPORT_MC_LS;
Flora Cuib6bc28f2015-11-02 21:21:34 +08001668 adev->pg_flags = 0;
1669 adev->external_rev_id = adev->rev_id + 0x3c;
1670 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001671 case CHIP_TONGA:
Tom St Denis5f64e772016-03-23 13:16:13 -04001672 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG;
Tom St Denisf3fd4512016-09-30 11:00:16 -04001673 adev->pg_flags = AMD_PG_SUPPORT_UVD;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001674 adev->external_rev_id = adev->rev_id + 0x14;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001675 break;
Flora Cui2cc0c0b2016-03-14 18:33:29 -04001676 case CHIP_POLARIS11:
Flora Cuic0c1f572015-12-07 18:33:10 +08001677 adev->cg_flags = 0;
1678 adev->pg_flags = 0;
1679 adev->external_rev_id = adev->rev_id + 0x5A;
1680 break;
Flora Cui2cc0c0b2016-03-14 18:33:29 -04001681 case CHIP_POLARIS10:
Flora Cuic0c1f572015-12-07 18:33:10 +08001682 adev->cg_flags = 0;
1683 adev->pg_flags = 0;
1684 adev->external_rev_id = adev->rev_id + 0x50;
1685 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001686 case CHIP_CARRIZO:
Tom St Denisf0f3a8f2016-05-03 10:36:28 -04001687 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG |
1688 AMD_CG_SUPPORT_GFX_MGCG |
Alex Deucher70eced92016-04-07 23:01:48 -04001689 AMD_CG_SUPPORT_GFX_MGLS |
1690 AMD_CG_SUPPORT_GFX_RLC_LS |
1691 AMD_CG_SUPPORT_GFX_CP_LS |
1692 AMD_CG_SUPPORT_GFX_CGTS |
1693 AMD_CG_SUPPORT_GFX_MGLS |
1694 AMD_CG_SUPPORT_GFX_CGTS_LS |
1695 AMD_CG_SUPPORT_GFX_CGCG |
Alex Deucher03c335d2016-04-08 00:26:46 -04001696 AMD_CG_SUPPORT_GFX_CGLS |
1697 AMD_CG_SUPPORT_BIF_LS |
1698 AMD_CG_SUPPORT_HDP_MGCG |
Alex Deucher6f17a252016-04-08 00:39:54 -04001699 AMD_CG_SUPPORT_HDP_LS |
1700 AMD_CG_SUPPORT_SDMA_MGCG |
Tom St Denis1af69a22016-08-03 10:16:17 -04001701 AMD_CG_SUPPORT_SDMA_LS |
1702 AMD_CG_SUPPORT_VCE_MGCG;
Tom St Denisf6ade302016-07-28 09:33:56 -04001703 /* rev0 hardware requires workarounds to support PG */
Alex Deucher0fd4af92016-02-04 23:31:32 -05001704 adev->pg_flags = 0;
Tom St Denisf6ade302016-07-28 09:33:56 -04001705 if (adev->rev_id != 0x00) {
1706 adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG |
1707 AMD_PG_SUPPORT_GFX_SMG |
Tom St Denis65b42622016-07-28 09:35:57 -04001708 AMD_PG_SUPPORT_GFX_PIPELINE |
Tom St Denis2ed09362016-07-28 09:36:26 -04001709 AMD_PG_SUPPORT_UVD |
1710 AMD_PG_SUPPORT_VCE;
Tom St Denisf6ade302016-07-28 09:33:56 -04001711 }
Alex Deucheraaa36a92015-04-20 17:31:14 -04001712 adev->external_rev_id = adev->rev_id + 0x1;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001713 break;
Tom St Deniscde64932016-03-23 13:17:04 -04001714 case CHIP_STONEY:
Alex Deucher64694902016-04-07 23:17:15 -04001715 adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG |
1716 AMD_CG_SUPPORT_GFX_MGCG |
Alex Deucherb6711d12016-04-13 12:41:50 -04001717 AMD_CG_SUPPORT_GFX_MGLS |
Tom St Denis413cf602016-06-02 08:52:39 -04001718 AMD_CG_SUPPORT_GFX_RLC_LS |
1719 AMD_CG_SUPPORT_GFX_CP_LS |
1720 AMD_CG_SUPPORT_GFX_CGTS |
1721 AMD_CG_SUPPORT_GFX_MGLS |
1722 AMD_CG_SUPPORT_GFX_CGTS_LS |
1723 AMD_CG_SUPPORT_GFX_CGCG |
1724 AMD_CG_SUPPORT_GFX_CGLS |
Alex Deucherb6711d12016-04-13 12:41:50 -04001725 AMD_CG_SUPPORT_BIF_LS |
1726 AMD_CG_SUPPORT_HDP_MGCG |
Alex Deucher1bf912f2016-04-08 00:40:49 -04001727 AMD_CG_SUPPORT_HDP_LS |
1728 AMD_CG_SUPPORT_SDMA_MGCG |
Tom St Denis8ef583e2016-08-03 11:34:35 -04001729 AMD_CG_SUPPORT_SDMA_LS |
1730 AMD_CG_SUPPORT_VCE_MGCG;
Tom St Denis4e86be72016-07-28 09:38:13 -04001731 adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG |
1732 AMD_PG_SUPPORT_GFX_SMG |
Tom St Denisc2cdb04282016-07-28 09:38:29 -04001733 AMD_PG_SUPPORT_GFX_PIPELINE |
Tom St Denis75419c42016-07-28 09:38:45 -04001734 AMD_PG_SUPPORT_UVD |
1735 AMD_PG_SUPPORT_VCE;
Jordan Lazarea47c78d2016-09-01 13:49:33 -04001736 adev->external_rev_id = adev->rev_id + 0x61;
Tom St Deniscde64932016-03-23 13:17:04 -04001737 break;
Alex Deucheraaa36a92015-04-20 17:31:14 -04001738 default:
1739 /* FIXME: not supported yet */
1740 return -EINVAL;
1741 }
1742
Monk Liu4e99a442016-03-31 13:26:59 +08001743 /* in early init stage, vbios code won't work */
1744 if (adev->asic_funcs->detect_hw_virtualization)
1745 amdgpu_asic_detect_hw_virtualization(adev);
1746
Flora Cuia3d08fa2015-11-02 21:15:55 +08001747 if (amdgpu_smc_load_fw && smc_enabled)
1748 adev->firmware.smu_load = true;
1749
Alex Deucherd0dd7f02015-11-11 19:45:06 -05001750 amdgpu_get_pcie_info(adev);
1751
Alex Deucheraaa36a92015-04-20 17:31:14 -04001752 return 0;
1753}
1754
yanyang15fc3aee2015-05-22 14:39:35 -04001755static int vi_common_sw_init(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001756{
1757 return 0;
1758}
1759
yanyang15fc3aee2015-05-22 14:39:35 -04001760static int vi_common_sw_fini(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001761{
1762 return 0;
1763}
1764
yanyang15fc3aee2015-05-22 14:39:35 -04001765static int vi_common_hw_init(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001766{
yanyang15fc3aee2015-05-22 14:39:35 -04001767 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1768
Alex Deucheraaa36a92015-04-20 17:31:14 -04001769 /* move the golden regs per IP block */
1770 vi_init_golden_registers(adev);
1771 /* enable pcie gen2/3 link */
1772 vi_pcie_gen3_enable(adev);
1773 /* enable aspm */
1774 vi_program_aspm(adev);
1775 /* enable the doorbell aperture */
1776 vi_enable_doorbell_aperture(adev, true);
1777
1778 return 0;
1779}
1780
yanyang15fc3aee2015-05-22 14:39:35 -04001781static int vi_common_hw_fini(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001782{
yanyang15fc3aee2015-05-22 14:39:35 -04001783 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1784
Alex Deucheraaa36a92015-04-20 17:31:14 -04001785 /* enable the doorbell aperture */
1786 vi_enable_doorbell_aperture(adev, false);
1787
1788 return 0;
1789}
1790
yanyang15fc3aee2015-05-22 14:39:35 -04001791static int vi_common_suspend(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001792{
yanyang15fc3aee2015-05-22 14:39:35 -04001793 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1794
Alex Deucheraaa36a92015-04-20 17:31:14 -04001795 return vi_common_hw_fini(adev);
1796}
1797
yanyang15fc3aee2015-05-22 14:39:35 -04001798static int vi_common_resume(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001799{
yanyang15fc3aee2015-05-22 14:39:35 -04001800 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1801
Alex Deucheraaa36a92015-04-20 17:31:14 -04001802 return vi_common_hw_init(adev);
1803}
1804
yanyang15fc3aee2015-05-22 14:39:35 -04001805static bool vi_common_is_idle(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001806{
1807 return true;
1808}
1809
yanyang15fc3aee2015-05-22 14:39:35 -04001810static int vi_common_wait_for_idle(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001811{
1812 return 0;
1813}
1814
yanyang15fc3aee2015-05-22 14:39:35 -04001815static int vi_common_soft_reset(void *handle)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001816{
1817 return 0;
1818}
1819
Alex Deucher76f10b92016-04-08 01:37:44 -04001820static void vi_update_bif_medium_grain_light_sleep(struct amdgpu_device *adev,
1821 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001822{
1823 uint32_t temp, data;
1824
1825 temp = data = RREG32_PCIE(ixPCIE_CNTL2);
1826
Alex Deucherc90766c2016-04-08 00:52:58 -04001827 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS))
Eric Huang6cec2652015-11-12 16:59:47 -05001828 data |= PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
1829 PCIE_CNTL2__MST_MEM_LS_EN_MASK |
1830 PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK;
1831 else
1832 data &= ~(PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
1833 PCIE_CNTL2__MST_MEM_LS_EN_MASK |
1834 PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK);
1835
1836 if (temp != data)
1837 WREG32_PCIE(ixPCIE_CNTL2, data);
1838}
1839
Alex Deucher76f10b92016-04-08 01:37:44 -04001840static void vi_update_hdp_medium_grain_clock_gating(struct amdgpu_device *adev,
1841 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001842{
1843 uint32_t temp, data;
1844
1845 temp = data = RREG32(mmHDP_HOST_PATH_CNTL);
1846
Alex Deucherc90766c2016-04-08 00:52:58 -04001847 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG))
Eric Huang6cec2652015-11-12 16:59:47 -05001848 data &= ~HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK;
1849 else
1850 data |= HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK;
1851
1852 if (temp != data)
1853 WREG32(mmHDP_HOST_PATH_CNTL, data);
1854}
1855
Alex Deucher76f10b92016-04-08 01:37:44 -04001856static void vi_update_hdp_light_sleep(struct amdgpu_device *adev,
1857 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001858{
1859 uint32_t temp, data;
1860
1861 temp = data = RREG32(mmHDP_MEM_POWER_LS);
1862
Alex Deucherc90766c2016-04-08 00:52:58 -04001863 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
Eric Huang6cec2652015-11-12 16:59:47 -05001864 data |= HDP_MEM_POWER_LS__LS_ENABLE_MASK;
1865 else
1866 data &= ~HDP_MEM_POWER_LS__LS_ENABLE_MASK;
1867
1868 if (temp != data)
1869 WREG32(mmHDP_MEM_POWER_LS, data);
1870}
1871
Alex Deucher76f10b92016-04-08 01:37:44 -04001872static void vi_update_rom_medium_grain_clock_gating(struct amdgpu_device *adev,
1873 bool enable)
Eric Huang6cec2652015-11-12 16:59:47 -05001874{
1875 uint32_t temp, data;
1876
1877 temp = data = RREG32_SMC(ixCGTT_ROM_CLK_CTRL0);
1878
Alex Deucherc90766c2016-04-08 00:52:58 -04001879 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_ROM_MGCG))
Eric Huang6cec2652015-11-12 16:59:47 -05001880 data &= ~(CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK |
1881 CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE1_MASK);
1882 else
1883 data |= CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK |
1884 CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE1_MASK;
1885
1886 if (temp != data)
1887 WREG32_SMC(ixCGTT_ROM_CLK_CTRL0, data);
1888}
1889
Rex Zhu1bb08f92016-09-18 16:54:00 +08001890static int vi_common_set_clockgating_state_by_smu(void *handle,
1891 enum amd_clockgating_state state)
1892{
1893 uint32_t msg_id, pp_state;
1894 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1895 void *pp_handle = adev->powerplay.pp_handle;
1896
1897 if (state == AMD_CG_STATE_UNGATE)
1898 pp_state = 0;
1899 else
1900 pp_state = PP_STATE_CG | PP_STATE_LS;
1901
1902 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1903 PP_BLOCK_SYS_MC,
1904 PP_STATE_SUPPORT_CG | PP_STATE_SUPPORT_LS,
1905 pp_state);
1906 amd_set_clockgating_by_smu(pp_handle, msg_id);
1907
1908 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1909 PP_BLOCK_SYS_SDMA,
1910 PP_STATE_SUPPORT_CG | PP_STATE_SUPPORT_LS,
1911 pp_state);
1912 amd_set_clockgating_by_smu(pp_handle, msg_id);
1913
1914 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1915 PP_BLOCK_SYS_HDP,
1916 PP_STATE_SUPPORT_CG | PP_STATE_SUPPORT_LS,
1917 pp_state);
1918 amd_set_clockgating_by_smu(pp_handle, msg_id);
1919
1920 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1921 PP_BLOCK_SYS_BIF,
1922 PP_STATE_SUPPORT_LS,
1923 pp_state);
1924 amd_set_clockgating_by_smu(pp_handle, msg_id);
1925
1926 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1927 PP_BLOCK_SYS_BIF,
1928 PP_STATE_SUPPORT_CG,
1929 pp_state);
1930 amd_set_clockgating_by_smu(pp_handle, msg_id);
1931
1932 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1933 PP_BLOCK_SYS_DRM,
1934 PP_STATE_SUPPORT_LS,
1935 pp_state);
1936 amd_set_clockgating_by_smu(pp_handle, msg_id);
1937
1938 msg_id = PP_CG_MSG_ID(PP_GROUP_SYS,
1939 PP_BLOCK_SYS_ROM,
1940 PP_STATE_SUPPORT_CG,
1941 pp_state);
1942 amd_set_clockgating_by_smu(pp_handle, msg_id);
1943
1944 return 0;
1945}
1946
yanyang15fc3aee2015-05-22 14:39:35 -04001947static int vi_common_set_clockgating_state(void *handle,
Alex Deucherc90766c2016-04-08 00:52:58 -04001948 enum amd_clockgating_state state)
Alex Deucheraaa36a92015-04-20 17:31:14 -04001949{
Eric Huang6cec2652015-11-12 16:59:47 -05001950 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1951
1952 switch (adev->asic_type) {
1953 case CHIP_FIJI:
Alex Deucher76f10b92016-04-08 01:37:44 -04001954 vi_update_bif_medium_grain_light_sleep(adev,
Eric Huang6cec2652015-11-12 16:59:47 -05001955 state == AMD_CG_STATE_GATE ? true : false);
Alex Deucher76f10b92016-04-08 01:37:44 -04001956 vi_update_hdp_medium_grain_clock_gating(adev,
Eric Huang6cec2652015-11-12 16:59:47 -05001957 state == AMD_CG_STATE_GATE ? true : false);
Alex Deucher76f10b92016-04-08 01:37:44 -04001958 vi_update_hdp_light_sleep(adev,
Eric Huang6cec2652015-11-12 16:59:47 -05001959 state == AMD_CG_STATE_GATE ? true : false);
Alex Deucher76f10b92016-04-08 01:37:44 -04001960 vi_update_rom_medium_grain_clock_gating(adev,
1961 state == AMD_CG_STATE_GATE ? true : false);
1962 break;
1963 case CHIP_CARRIZO:
1964 case CHIP_STONEY:
1965 vi_update_bif_medium_grain_light_sleep(adev,
1966 state == AMD_CG_STATE_GATE ? true : false);
1967 vi_update_hdp_medium_grain_clock_gating(adev,
1968 state == AMD_CG_STATE_GATE ? true : false);
1969 vi_update_hdp_light_sleep(adev,
Eric Huang6cec2652015-11-12 16:59:47 -05001970 state == AMD_CG_STATE_GATE ? true : false);
1971 break;
Rex Zhu1bb08f92016-09-18 16:54:00 +08001972 case CHIP_TONGA:
1973 case CHIP_POLARIS10:
1974 case CHIP_POLARIS11:
1975 vi_common_set_clockgating_state_by_smu(adev, state);
Eric Huang6cec2652015-11-12 16:59:47 -05001976 default:
1977 break;
1978 }
Alex Deucheraaa36a92015-04-20 17:31:14 -04001979 return 0;
1980}
1981
yanyang15fc3aee2015-05-22 14:39:35 -04001982static int vi_common_set_powergating_state(void *handle,
1983 enum amd_powergating_state state)
1984{
1985 return 0;
1986}
1987
1988const struct amd_ip_funcs vi_common_ip_funcs = {
Tom St Denis88a907d2016-05-04 14:28:35 -04001989 .name = "vi_common",
Alex Deucheraaa36a92015-04-20 17:31:14 -04001990 .early_init = vi_common_early_init,
1991 .late_init = NULL,
1992 .sw_init = vi_common_sw_init,
1993 .sw_fini = vi_common_sw_fini,
1994 .hw_init = vi_common_hw_init,
1995 .hw_fini = vi_common_hw_fini,
1996 .suspend = vi_common_suspend,
1997 .resume = vi_common_resume,
1998 .is_idle = vi_common_is_idle,
1999 .wait_for_idle = vi_common_wait_for_idle,
2000 .soft_reset = vi_common_soft_reset,
Alex Deucheraaa36a92015-04-20 17:31:14 -04002001 .set_clockgating_state = vi_common_set_clockgating_state,
2002 .set_powergating_state = vi_common_set_powergating_state,
2003};
2004