blob: 44f539a7f411592d99740ef163f2ef3c80e27f3c [file] [log] [blame]
Hawking Zhangc6b6a422019-03-04 14:07:37 +08001/*
2 * Copyright 2019 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>
Alex Deuchere9eea902019-07-31 10:39:40 -050026#include <linux/pci.h>
27
Hawking Zhangc6b6a422019-03-04 14:07:37 +080028#include "amdgpu.h"
29#include "amdgpu_atombios.h"
30#include "amdgpu_ih.h"
31#include "amdgpu_uvd.h"
32#include "amdgpu_vce.h"
33#include "amdgpu_ucode.h"
34#include "amdgpu_psp.h"
Kevin Wang767acab2019-07-05 15:58:46 -050035#include "amdgpu_smu.h"
Hawking Zhangc6b6a422019-03-04 14:07:37 +080036#include "atom.h"
37#include "amd_pcie.h"
38
39#include "gc/gc_10_1_0_offset.h"
40#include "gc/gc_10_1_0_sh_mask.h"
41#include "hdp/hdp_5_0_0_offset.h"
42#include "hdp/hdp_5_0_0_sh_mask.h"
43
44#include "soc15.h"
45#include "soc15_common.h"
46#include "gmc_v10_0.h"
47#include "gfxhub_v2_0.h"
48#include "mmhub_v2_0.h"
Hawking Zhangbebc0762019-08-23 19:39:18 +080049#include "nbio_v2_3.h"
Hawking Zhangc6b6a422019-03-04 14:07:37 +080050#include "nv.h"
51#include "navi10_ih.h"
52#include "gfx_v10_0.h"
53#include "sdma_v5_0.h"
54#include "vcn_v2_0.h"
55#include "dce_virtual.h"
56#include "mes_v10_1.h"
Jiange Zhaob05b6902019-09-11 17:29:07 +080057#include "mxgpu_nv.h"
Hawking Zhangc6b6a422019-03-04 14:07:37 +080058
59static const struct amd_ip_funcs nv_common_ip_funcs;
60
61/*
62 * Indirect registers accessor
63 */
64static u32 nv_pcie_rreg(struct amdgpu_device *adev, u32 reg)
65{
66 unsigned long flags, address, data;
67 u32 r;
Hawking Zhangbebc0762019-08-23 19:39:18 +080068 address = adev->nbio.funcs->get_pcie_index_offset(adev);
69 data = adev->nbio.funcs->get_pcie_data_offset(adev);
Hawking Zhangc6b6a422019-03-04 14:07:37 +080070
71 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
72 WREG32(address, reg);
73 (void)RREG32(address);
74 r = RREG32(data);
75 spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
76 return r;
77}
78
79static void nv_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
80{
81 unsigned long flags, address, data;
82
Hawking Zhangbebc0762019-08-23 19:39:18 +080083 address = adev->nbio.funcs->get_pcie_index_offset(adev);
84 data = adev->nbio.funcs->get_pcie_data_offset(adev);
Hawking Zhangc6b6a422019-03-04 14:07:37 +080085
86 spin_lock_irqsave(&adev->pcie_idx_lock, flags);
87 WREG32(address, reg);
88 (void)RREG32(address);
89 WREG32(data, v);
90 (void)RREG32(data);
91 spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
92}
93
94static u32 nv_didt_rreg(struct amdgpu_device *adev, u32 reg)
95{
96 unsigned long flags, address, data;
97 u32 r;
98
99 address = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_INDEX);
100 data = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_DATA);
101
102 spin_lock_irqsave(&adev->didt_idx_lock, flags);
103 WREG32(address, (reg));
104 r = RREG32(data);
105 spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
106 return r;
107}
108
109static void nv_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v)
110{
111 unsigned long flags, address, data;
112
113 address = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_INDEX);
114 data = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_DATA);
115
116 spin_lock_irqsave(&adev->didt_idx_lock, flags);
117 WREG32(address, (reg));
118 WREG32(data, (v));
119 spin_unlock_irqrestore(&adev->didt_idx_lock, flags);
120}
121
122static u32 nv_get_config_memsize(struct amdgpu_device *adev)
123{
Hawking Zhangbebc0762019-08-23 19:39:18 +0800124 return adev->nbio.funcs->get_memsize(adev);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800125}
126
127static u32 nv_get_xclk(struct amdgpu_device *adev)
128{
Tao Zhou462a70d2019-05-14 11:37:32 +0800129 return adev->clock.spll.reference_freq;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800130}
131
132
133void nv_grbm_select(struct amdgpu_device *adev,
134 u32 me, u32 pipe, u32 queue, u32 vmid)
135{
136 u32 grbm_gfx_cntl = 0;
137 grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, PIPEID, pipe);
138 grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, MEID, me);
139 grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, VMID, vmid);
140 grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, QUEUEID, queue);
141
142 WREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_GFX_CNTL), grbm_gfx_cntl);
143}
144
145static void nv_vga_set_state(struct amdgpu_device *adev, bool state)
146{
147 /* todo */
148}
149
150static bool nv_read_disabled_bios(struct amdgpu_device *adev)
151{
152 /* todo */
153 return false;
154}
155
156static bool nv_read_bios_from_rom(struct amdgpu_device *adev,
157 u8 *bios, u32 length_bytes)
158{
159 /* TODO: will implement it when SMU header is available */
160 return false;
161}
162
163static struct soc15_allowed_register_entry nv_allowed_read_registers[] = {
164 { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS)},
165 { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS2)},
166 { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE0)},
167 { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE1)},
168 { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE2)},
169 { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE3)},
170#if 0 /* TODO: will set it when SDMA header is available */
171 { SOC15_REG_ENTRY(SDMA0, 0, mmSDMA0_STATUS_REG)},
172 { SOC15_REG_ENTRY(SDMA1, 0, mmSDMA1_STATUS_REG)},
173#endif
174 { SOC15_REG_ENTRY(GC, 0, mmCP_STAT)},
175 { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT1)},
176 { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT2)},
177 { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT3)},
178 { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_BUSY_STAT)},
179 { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_STALLED_STAT1)},
180 { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_STATUS)},
181 { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_STALLED_STAT1)},
182 { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_STATUS)},
183 { SOC15_REG_ENTRY(GC, 0, mmGB_ADDR_CONFIG)},
184};
185
186static uint32_t nv_read_indexed_register(struct amdgpu_device *adev, u32 se_num,
187 u32 sh_num, u32 reg_offset)
188{
189 uint32_t val;
190
191 mutex_lock(&adev->grbm_idx_mutex);
192 if (se_num != 0xffffffff || sh_num != 0xffffffff)
193 amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff);
194
195 val = RREG32(reg_offset);
196
197 if (se_num != 0xffffffff || sh_num != 0xffffffff)
198 amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
199 mutex_unlock(&adev->grbm_idx_mutex);
200 return val;
201}
202
203static uint32_t nv_get_register_value(struct amdgpu_device *adev,
204 bool indexed, u32 se_num,
205 u32 sh_num, u32 reg_offset)
206{
207 if (indexed) {
208 return nv_read_indexed_register(adev, se_num, sh_num, reg_offset);
209 } else {
210 if (reg_offset == SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG))
211 return adev->gfx.config.gb_addr_config;
212 return RREG32(reg_offset);
213 }
214}
215
216static int nv_read_register(struct amdgpu_device *adev, u32 se_num,
217 u32 sh_num, u32 reg_offset, u32 *value)
218{
219 uint32_t i;
220 struct soc15_allowed_register_entry *en;
221
222 *value = 0;
223 for (i = 0; i < ARRAY_SIZE(nv_allowed_read_registers); i++) {
224 en = &nv_allowed_read_registers[i];
225 if (reg_offset !=
226 (adev->reg_offset[en->hwip][en->inst][en->seg] + en->reg_offset))
227 continue;
228
229 *value = nv_get_register_value(adev,
230 nv_allowed_read_registers[i].grbm_indexed,
231 se_num, sh_num, reg_offset);
232 return 0;
233 }
234 return -EINVAL;
235}
236
237#if 0
238static void nv_gpu_pci_config_reset(struct amdgpu_device *adev)
239{
240 u32 i;
241
242 dev_info(adev->dev, "GPU pci config reset\n");
243
244 /* disable BM */
245 pci_clear_master(adev->pdev);
246 /* reset */
247 amdgpu_pci_config_reset(adev);
248
249 udelay(100);
250
251 /* wait for asic to come out of reset */
252 for (i = 0; i < adev->usec_timeout; i++) {
253 u32 memsize = nbio_v2_3_get_memsize(adev);
254 if (memsize != 0xffffffff)
255 break;
256 udelay(1);
257 }
258
259}
260#endif
261
Kevin Wang3e2bb602019-07-05 12:51:45 +0800262static int nv_asic_mode1_reset(struct amdgpu_device *adev)
263{
264 u32 i;
265 int ret = 0;
266
267 amdgpu_atombios_scratch_regs_engine_hung(adev, true);
268
269 dev_info(adev->dev, "GPU mode1 reset\n");
270
271 /* disable BM */
272 pci_clear_master(adev->pdev);
273
274 pci_save_state(adev->pdev);
275
276 ret = psp_gpu_reset(adev);
277 if (ret)
278 dev_err(adev->dev, "GPU mode1 reset failed\n");
279
280 pci_restore_state(adev->pdev);
281
282 /* wait for asic to come out of reset */
283 for (i = 0; i < adev->usec_timeout; i++) {
Hawking Zhangbebc0762019-08-23 19:39:18 +0800284 u32 memsize = adev->nbio.funcs->get_memsize(adev);
Kevin Wang3e2bb602019-07-05 12:51:45 +0800285
286 if (memsize != 0xffffffff)
287 break;
288 udelay(1);
289 }
290
291 amdgpu_atombios_scratch_regs_engine_hung(adev, false);
292
293 return ret;
294}
Alex Deucher2ddc6c32019-07-23 23:48:21 -0500295
296static enum amd_reset_method
297nv_asic_reset_method(struct amdgpu_device *adev)
298{
299 struct smu_context *smu = &adev->smu;
300
301 if (smu_baco_is_support(smu))
302 return AMD_RESET_METHOD_BACO;
303 else
304 return AMD_RESET_METHOD_MODE1;
305}
306
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800307static int nv_asic_reset(struct amdgpu_device *adev)
308{
309
310 /* FIXME: it doesn't work since vega10 */
311#if 0
312 amdgpu_atombios_scratch_regs_engine_hung(adev, true);
313
314 nv_gpu_pci_config_reset(adev);
315
316 amdgpu_atombios_scratch_regs_engine_hung(adev, false);
317#endif
Kevin Wang767acab2019-07-05 15:58:46 -0500318 int ret = 0;
319 struct smu_context *smu = &adev->smu;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800320
Monk Liue3526252019-08-27 16:32:55 +0800321 if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
322 amdgpu_inc_vram_lost(adev);
Kevin Wang767acab2019-07-05 15:58:46 -0500323 ret = smu_baco_reset(smu);
Monk Liue3526252019-08-27 16:32:55 +0800324 } else {
325 amdgpu_inc_vram_lost(adev);
Kevin Wang3e2bb602019-07-05 12:51:45 +0800326 ret = nv_asic_mode1_reset(adev);
Monk Liue3526252019-08-27 16:32:55 +0800327 }
Kevin Wang767acab2019-07-05 15:58:46 -0500328
329 return ret;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800330}
331
332static int nv_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
333{
334 /* todo */
335 return 0;
336}
337
338static int nv_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
339{
340 /* todo */
341 return 0;
342}
343
344static void nv_pcie_gen3_enable(struct amdgpu_device *adev)
345{
346 if (pci_is_root_bus(adev->pdev->bus))
347 return;
348
349 if (amdgpu_pcie_gen2 == 0)
350 return;
351
352 if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |
353 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)))
354 return;
355
356 /* todo */
357}
358
359static void nv_program_aspm(struct amdgpu_device *adev)
360{
361
362 if (amdgpu_aspm == 0)
363 return;
364
365 /* todo */
366}
367
368static void nv_enable_doorbell_aperture(struct amdgpu_device *adev,
369 bool enable)
370{
Hawking Zhangbebc0762019-08-23 19:39:18 +0800371 adev->nbio.funcs->enable_doorbell_aperture(adev, enable);
372 adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800373}
374
375static const struct amdgpu_ip_block_version nv_common_ip_block =
376{
377 .type = AMD_IP_BLOCK_TYPE_COMMON,
378 .major = 1,
379 .minor = 0,
380 .rev = 0,
381 .funcs = &nv_common_ip_funcs,
382};
383
Xiaojie Yuanb5c73852019-08-05 16:19:45 +0800384static int nv_reg_base_init(struct amdgpu_device *adev)
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800385{
Xiaojie Yuanb5c73852019-08-05 16:19:45 +0800386 int r;
387
388 if (amdgpu_discovery) {
389 r = amdgpu_discovery_reg_base_init(adev);
390 if (r) {
391 DRM_WARN("failed to init reg base from ip discovery table, "
392 "fallback to legacy init method\n");
393 goto legacy_init;
394 }
395
396 return 0;
397 }
398
399legacy_init:
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800400 switch (adev->asic_type) {
401 case CHIP_NAVI10:
402 navi10_reg_base_init(adev);
403 break;
Xiaojie Yuana0f6d9262018-12-17 18:24:03 +0800404 case CHIP_NAVI14:
405 navi14_reg_base_init(adev);
406 break;
Xiaojie Yuan03d0a072019-05-14 15:22:53 +0800407 case CHIP_NAVI12:
408 navi12_reg_base_init(adev);
409 break;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800410 default:
411 return -EINVAL;
412 }
413
Xiaojie Yuanb5c73852019-08-05 16:19:45 +0800414 return 0;
415}
416
417int nv_set_ip_blocks(struct amdgpu_device *adev)
418{
419 int r;
420
421 /* Set IP register base before any HW register access */
422 r = nv_reg_base_init(adev);
423 if (r)
424 return r;
425
Hawking Zhangbebc0762019-08-23 19:39:18 +0800426 adev->nbio.funcs = &nbio_v2_3_funcs;
427 adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800428
Hawking Zhangbebc0762019-08-23 19:39:18 +0800429 adev->nbio.funcs->detect_hw_virt(adev);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800430
Jiange Zhaob05b6902019-09-11 17:29:07 +0800431 if (amdgpu_sriov_vf(adev))
432 adev->virt.ops = &xgpu_nv_virt_ops;
433
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800434 switch (adev->asic_type) {
435 case CHIP_NAVI10:
Alex Deucherd1daf852019-07-02 14:42:25 -0500436 case CHIP_NAVI14:
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800437 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
438 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
439 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
440 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
441 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP &&
442 is_support_sw_smu(adev))
443 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
444 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
445 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Alex Deucherf8a79762019-07-05 15:39:39 -0500446#if defined(CONFIG_DRM_AMD_DC)
Harry Wentlandb4f199c2019-02-26 16:25:27 -0500447 else if (amdgpu_device_has_dc_support(adev))
448 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Alex Deucherf8a79762019-07-05 15:39:39 -0500449#endif
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800450 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
451 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
452 if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
453 is_support_sw_smu(adev))
454 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
455 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
456 if (adev->enable_mes)
457 amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
458 break;
Xiaojie Yuan44e9e7c2019-05-16 19:58:19 +0800459 case CHIP_NAVI12:
460 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
461 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
462 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
Xiaojie Yuan6b66ae22019-07-18 02:54:29 +0800463 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
Xiaojie Yuan7f47efe2019-07-16 03:26:49 +0800464 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP &&
465 is_support_sw_smu(adev))
466 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
Xiaojie Yuan79902022019-06-26 19:19:57 +0800467 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
468 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
Petr Cvek20c14ee2019-08-30 16:31:58 +0200469#if defined(CONFIG_DRM_AMD_DC)
Leo Li078655d92019-07-16 18:12:13 -0400470 else if (amdgpu_device_has_dc_support(adev))
471 amdgpu_device_ip_block_add(adev, &dm_ip_block);
Petr Cvek20c14ee2019-08-30 16:31:58 +0200472#endif
Xiaojie Yuan44e9e7c2019-05-16 19:58:19 +0800473 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
474 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
Xiaojie Yuan7f47efe2019-07-16 03:26:49 +0800475 if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
476 is_support_sw_smu(adev))
477 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
Boyuan Zhang1fbed282019-07-18 10:13:23 -0400478 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
Xiaojie Yuan44e9e7c2019-05-16 19:58:19 +0800479 break;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800480 default:
481 return -EINVAL;
482 }
483
484 return 0;
485}
486
487static uint32_t nv_get_rev_id(struct amdgpu_device *adev)
488{
Hawking Zhangbebc0762019-08-23 19:39:18 +0800489 return adev->nbio.funcs->get_rev_id(adev);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800490}
491
492static void nv_flush_hdp(struct amdgpu_device *adev, struct amdgpu_ring *ring)
493{
Hawking Zhangbebc0762019-08-23 19:39:18 +0800494 adev->nbio.funcs->hdp_flush(adev, ring);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800495}
496
497static void nv_invalidate_hdp(struct amdgpu_device *adev,
498 struct amdgpu_ring *ring)
499{
500 if (!ring || !ring->funcs->emit_wreg) {
501 WREG32_SOC15_NO_KIQ(NBIO, 0, mmHDP_READ_CACHE_INVALIDATE, 1);
502 } else {
503 amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET(
504 HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 1);
505 }
506}
507
508static bool nv_need_full_reset(struct amdgpu_device *adev)
509{
510 return true;
511}
512
513static void nv_get_pcie_usage(struct amdgpu_device *adev,
514 uint64_t *count0,
515 uint64_t *count1)
516{
517 /*TODO*/
518}
519
520static bool nv_need_reset_on_init(struct amdgpu_device *adev)
521{
522#if 0
523 u32 sol_reg;
524
525 if (adev->flags & AMD_IS_APU)
526 return false;
527
528 /* Check sOS sign of life register to confirm sys driver and sOS
529 * are already been loaded.
530 */
531 sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
532 if (sol_reg)
533 return true;
534#endif
535 /* TODO: re-enable it when mode1 reset is functional */
536 return false;
537}
538
539static void nv_init_doorbell_index(struct amdgpu_device *adev)
540{
541 adev->doorbell_index.kiq = AMDGPU_NAVI10_DOORBELL_KIQ;
542 adev->doorbell_index.mec_ring0 = AMDGPU_NAVI10_DOORBELL_MEC_RING0;
543 adev->doorbell_index.mec_ring1 = AMDGPU_NAVI10_DOORBELL_MEC_RING1;
544 adev->doorbell_index.mec_ring2 = AMDGPU_NAVI10_DOORBELL_MEC_RING2;
545 adev->doorbell_index.mec_ring3 = AMDGPU_NAVI10_DOORBELL_MEC_RING3;
546 adev->doorbell_index.mec_ring4 = AMDGPU_NAVI10_DOORBELL_MEC_RING4;
547 adev->doorbell_index.mec_ring5 = AMDGPU_NAVI10_DOORBELL_MEC_RING5;
548 adev->doorbell_index.mec_ring6 = AMDGPU_NAVI10_DOORBELL_MEC_RING6;
549 adev->doorbell_index.mec_ring7 = AMDGPU_NAVI10_DOORBELL_MEC_RING7;
550 adev->doorbell_index.userqueue_start = AMDGPU_NAVI10_DOORBELL_USERQUEUE_START;
551 adev->doorbell_index.userqueue_end = AMDGPU_NAVI10_DOORBELL_USERQUEUE_END;
552 adev->doorbell_index.gfx_ring0 = AMDGPU_NAVI10_DOORBELL_GFX_RING0;
553 adev->doorbell_index.gfx_ring1 = AMDGPU_NAVI10_DOORBELL_GFX_RING1;
554 adev->doorbell_index.sdma_engine[0] = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE0;
555 adev->doorbell_index.sdma_engine[1] = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE1;
556 adev->doorbell_index.ih = AMDGPU_NAVI10_DOORBELL_IH;
557 adev->doorbell_index.vcn.vcn_ring0_1 = AMDGPU_NAVI10_DOORBELL64_VCN0_1;
558 adev->doorbell_index.vcn.vcn_ring2_3 = AMDGPU_NAVI10_DOORBELL64_VCN2_3;
559 adev->doorbell_index.vcn.vcn_ring4_5 = AMDGPU_NAVI10_DOORBELL64_VCN4_5;
560 adev->doorbell_index.vcn.vcn_ring6_7 = AMDGPU_NAVI10_DOORBELL64_VCN6_7;
561 adev->doorbell_index.first_non_cp = AMDGPU_NAVI10_DOORBELL64_FIRST_NON_CP;
562 adev->doorbell_index.last_non_cp = AMDGPU_NAVI10_DOORBELL64_LAST_NON_CP;
563
564 adev->doorbell_index.max_assignment = AMDGPU_NAVI10_DOORBELL_MAX_ASSIGNMENT << 1;
565 adev->doorbell_index.sdma_doorbell_range = 20;
566}
567
568static const struct amdgpu_asic_funcs nv_asic_funcs =
569{
570 .read_disabled_bios = &nv_read_disabled_bios,
571 .read_bios_from_rom = &nv_read_bios_from_rom,
572 .read_register = &nv_read_register,
573 .reset = &nv_asic_reset,
Alex Deucher2ddc6c32019-07-23 23:48:21 -0500574 .reset_method = &nv_asic_reset_method,
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800575 .set_vga_state = &nv_vga_set_state,
576 .get_xclk = &nv_get_xclk,
577 .set_uvd_clocks = &nv_set_uvd_clocks,
578 .set_vce_clocks = &nv_set_vce_clocks,
579 .get_config_memsize = &nv_get_config_memsize,
580 .flush_hdp = &nv_flush_hdp,
581 .invalidate_hdp = &nv_invalidate_hdp,
582 .init_doorbell_index = &nv_init_doorbell_index,
583 .need_full_reset = &nv_need_full_reset,
584 .get_pcie_usage = &nv_get_pcie_usage,
585 .need_reset_on_init = &nv_need_reset_on_init,
586};
587
588static int nv_common_early_init(void *handle)
589{
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800590 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
591
592 adev->smc_rreg = NULL;
593 adev->smc_wreg = NULL;
594 adev->pcie_rreg = &nv_pcie_rreg;
595 adev->pcie_wreg = &nv_pcie_wreg;
596
597 /* TODO: will add them during VCN v2 implementation */
598 adev->uvd_ctx_rreg = NULL;
599 adev->uvd_ctx_wreg = NULL;
600
601 adev->didt_rreg = &nv_didt_rreg;
602 adev->didt_wreg = &nv_didt_wreg;
603
604 adev->asic_funcs = &nv_asic_funcs;
605
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800606 adev->rev_id = nv_get_rev_id(adev);
607 adev->external_rev_id = 0xff;
608 switch (adev->asic_type) {
609 case CHIP_NAVI10:
610 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800611 AMD_CG_SUPPORT_GFX_CGCG |
612 AMD_CG_SUPPORT_IH_CG |
613 AMD_CG_SUPPORT_HDP_MGCG |
614 AMD_CG_SUPPORT_HDP_LS |
615 AMD_CG_SUPPORT_SDMA_MGCG |
616 AMD_CG_SUPPORT_SDMA_LS |
617 AMD_CG_SUPPORT_MC_MGCG |
618 AMD_CG_SUPPORT_MC_LS |
619 AMD_CG_SUPPORT_ATHUB_MGCG |
620 AMD_CG_SUPPORT_ATHUB_LS |
621 AMD_CG_SUPPORT_VCN_MGCG |
622 AMD_CG_SUPPORT_BIF_MGCG |
623 AMD_CG_SUPPORT_BIF_LS;
Leo Liu157710e2019-05-15 13:58:20 -0400624 adev->pg_flags = AMD_PG_SUPPORT_VCN |
Huang Ruic12d4102019-06-14 16:12:51 +0800625 AMD_PG_SUPPORT_VCN_DPG |
Huang Ruia201b6a2019-06-14 16:19:36 +0800626 AMD_PG_SUPPORT_ATHUB;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800627 adev->external_rev_id = adev->rev_id + 0x1;
628 break;
Xiaojie Yuan5e71e012018-12-17 18:23:27 +0800629 case CHIP_NAVI14:
Xiaojie Yuand0c39f82019-03-20 16:12:54 +0800630 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
631 AMD_CG_SUPPORT_GFX_CGCG |
632 AMD_CG_SUPPORT_IH_CG |
633 AMD_CG_SUPPORT_HDP_MGCG |
634 AMD_CG_SUPPORT_HDP_LS |
635 AMD_CG_SUPPORT_SDMA_MGCG |
636 AMD_CG_SUPPORT_SDMA_LS |
637 AMD_CG_SUPPORT_MC_MGCG |
638 AMD_CG_SUPPORT_MC_LS |
639 AMD_CG_SUPPORT_ATHUB_MGCG |
640 AMD_CG_SUPPORT_ATHUB_LS |
641 AMD_CG_SUPPORT_VCN_MGCG |
642 AMD_CG_SUPPORT_BIF_MGCG |
643 AMD_CG_SUPPORT_BIF_LS;
Xiaojie Yuan0377b082019-07-02 12:52:52 -0500644 adev->pg_flags = AMD_PG_SUPPORT_VCN |
645 AMD_PG_SUPPORT_VCN_DPG;
tiancyin35ef88f2019-08-05 17:32:45 +0800646 adev->external_rev_id = adev->rev_id + 20;
Xiaojie Yuan5e71e012018-12-17 18:23:27 +0800647 break;
Xiaojie Yuan74b5e502019-05-16 19:47:33 +0800648 case CHIP_NAVI12:
Xiaojie Yuandca009e2019-07-30 11:28:20 +0800649 adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
650 AMD_CG_SUPPORT_GFX_MGLS |
651 AMD_CG_SUPPORT_GFX_CGCG |
652 AMD_CG_SUPPORT_GFX_CP_LS |
Xiaojie Yuan5211c372019-08-01 15:00:28 +0800653 AMD_CG_SUPPORT_GFX_RLC_LS |
Xiaojie Yuanfbe0bc52019-08-01 15:01:23 +0800654 AMD_CG_SUPPORT_IH_CG |
Xiaojie Yuan5211c372019-08-01 15:00:28 +0800655 AMD_CG_SUPPORT_HDP_MGCG |
Xiaojie Yuan358ab972019-07-30 12:18:55 +0800656 AMD_CG_SUPPORT_HDP_LS |
657 AMD_CG_SUPPORT_SDMA_MGCG |
Xiaojie Yuan8b797b32019-08-01 15:39:59 +0800658 AMD_CG_SUPPORT_SDMA_LS |
659 AMD_CG_SUPPORT_MC_MGCG |
Xiaojie Yuanca516782019-08-01 15:19:10 +0800660 AMD_CG_SUPPORT_MC_LS |
661 AMD_CG_SUPPORT_ATHUB_MGCG |
Xiaojie Yuan65872e52019-08-01 15:22:59 +0800662 AMD_CG_SUPPORT_ATHUB_LS |
663 AMD_CG_SUPPORT_VCN_MGCG;
Xiaojie Yuanc1653ea2019-08-27 11:05:23 +0800664 adev->pg_flags = AMD_PG_SUPPORT_VCN |
Xiaojie Yuan5ef3b8a2019-08-27 11:06:13 +0800665 AMD_PG_SUPPORT_VCN_DPG |
666 AMD_PG_SUPPORT_ATHUB;
Xiaojie Yuan74b5e502019-05-16 19:47:33 +0800667 adev->external_rev_id = adev->rev_id + 0xa;
668 break;
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800669 default:
670 /* FIXME: not supported yet */
671 return -EINVAL;
672 }
673
Jiange Zhaob05b6902019-09-11 17:29:07 +0800674 if (amdgpu_sriov_vf(adev)) {
675 amdgpu_virt_init_setting(adev);
676 xgpu_nv_mailbox_set_irq_funcs(adev);
677 }
678
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800679 return 0;
680}
681
682static int nv_common_late_init(void *handle)
683{
Jiange Zhaob05b6902019-09-11 17:29:07 +0800684 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
685
686 if (amdgpu_sriov_vf(adev))
687 xgpu_nv_mailbox_get_irq(adev);
688
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800689 return 0;
690}
691
692static int nv_common_sw_init(void *handle)
693{
Jiange Zhaob05b6902019-09-11 17:29:07 +0800694 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
695
696 if (amdgpu_sriov_vf(adev))
697 xgpu_nv_mailbox_add_irq_id(adev);
698
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800699 return 0;
700}
701
702static int nv_common_sw_fini(void *handle)
703{
704 return 0;
705}
706
707static int nv_common_hw_init(void *handle)
708{
709 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
710
711 /* enable pcie gen2/3 link */
712 nv_pcie_gen3_enable(adev);
713 /* enable aspm */
714 nv_program_aspm(adev);
715 /* setup nbio registers */
Hawking Zhangbebc0762019-08-23 19:39:18 +0800716 adev->nbio.funcs->init_registers(adev);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800717 /* enable the doorbell aperture */
718 nv_enable_doorbell_aperture(adev, true);
719
720 return 0;
721}
722
723static int nv_common_hw_fini(void *handle)
724{
725 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
726
727 /* disable the doorbell aperture */
728 nv_enable_doorbell_aperture(adev, false);
729
730 return 0;
731}
732
733static int nv_common_suspend(void *handle)
734{
735 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
736
737 return nv_common_hw_fini(adev);
738}
739
740static int nv_common_resume(void *handle)
741{
742 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
743
744 return nv_common_hw_init(adev);
745}
746
747static bool nv_common_is_idle(void *handle)
748{
749 return true;
750}
751
752static int nv_common_wait_for_idle(void *handle)
753{
754 return 0;
755}
756
757static int nv_common_soft_reset(void *handle)
758{
759 return 0;
760}
761
762static void nv_update_hdp_mem_power_gating(struct amdgpu_device *adev,
763 bool enable)
764{
765 uint32_t hdp_clk_cntl, hdp_clk_cntl1;
766 uint32_t hdp_mem_pwr_cntl;
767
768 if (!(adev->cg_flags & (AMD_CG_SUPPORT_HDP_LS |
769 AMD_CG_SUPPORT_HDP_DS |
770 AMD_CG_SUPPORT_HDP_SD)))
771 return;
772
773 hdp_clk_cntl = hdp_clk_cntl1 = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL);
774 hdp_mem_pwr_cntl = RREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL);
775
776 /* Before doing clock/power mode switch,
777 * forced on IPH & RC clock */
778 hdp_clk_cntl = REG_SET_FIELD(hdp_clk_cntl, HDP_CLK_CNTL,
779 IPH_MEM_CLK_SOFT_OVERRIDE, 1);
780 hdp_clk_cntl = REG_SET_FIELD(hdp_clk_cntl, HDP_CLK_CNTL,
781 RC_MEM_CLK_SOFT_OVERRIDE, 1);
782 WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl);
783
784 /* HDP 5.0 doesn't support dynamic power mode switch,
785 * disable clock and power gating before any changing */
786 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
787 IPH_MEM_POWER_CTRL_EN, 0);
788 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
789 IPH_MEM_POWER_LS_EN, 0);
790 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
791 IPH_MEM_POWER_DS_EN, 0);
792 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
793 IPH_MEM_POWER_SD_EN, 0);
794 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
795 RC_MEM_POWER_CTRL_EN, 0);
796 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
797 RC_MEM_POWER_LS_EN, 0);
798 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
799 RC_MEM_POWER_DS_EN, 0);
800 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
801 RC_MEM_POWER_SD_EN, 0);
802 WREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL, hdp_mem_pwr_cntl);
803
804 /* only one clock gating mode (LS/DS/SD) can be enabled */
805 if (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS) {
806 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl,
807 HDP_MEM_POWER_CTRL,
808 IPH_MEM_POWER_LS_EN, enable);
809 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl,
810 HDP_MEM_POWER_CTRL,
811 RC_MEM_POWER_LS_EN, enable);
812 } else if (adev->cg_flags & AMD_CG_SUPPORT_HDP_DS) {
813 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl,
814 HDP_MEM_POWER_CTRL,
815 IPH_MEM_POWER_DS_EN, enable);
816 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl,
817 HDP_MEM_POWER_CTRL,
818 RC_MEM_POWER_DS_EN, enable);
819 } else if (adev->cg_flags & AMD_CG_SUPPORT_HDP_SD) {
820 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl,
821 HDP_MEM_POWER_CTRL,
822 IPH_MEM_POWER_SD_EN, enable);
823 /* RC should not use shut down mode, fallback to ds */
824 hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl,
825 HDP_MEM_POWER_CTRL,
826 RC_MEM_POWER_DS_EN, enable);
827 }
828
829 WREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL, hdp_mem_pwr_cntl);
830
831 /* restore IPH & RC clock override after clock/power mode changing */
832 WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl1);
833}
834
835static void nv_update_hdp_clock_gating(struct amdgpu_device *adev,
836 bool enable)
837{
838 uint32_t hdp_clk_cntl;
839
840 if (!(adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG))
841 return;
842
843 hdp_clk_cntl = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL);
844
845 if (enable) {
846 hdp_clk_cntl &=
847 ~(uint32_t)
848 (HDP_CLK_CNTL__IPH_MEM_CLK_SOFT_OVERRIDE_MASK |
849 HDP_CLK_CNTL__RC_MEM_CLK_SOFT_OVERRIDE_MASK |
850 HDP_CLK_CNTL__DBUS_CLK_SOFT_OVERRIDE_MASK |
851 HDP_CLK_CNTL__DYN_CLK_SOFT_OVERRIDE_MASK |
852 HDP_CLK_CNTL__XDP_REG_CLK_SOFT_OVERRIDE_MASK |
853 HDP_CLK_CNTL__HDP_REG_CLK_SOFT_OVERRIDE_MASK);
854 } else {
855 hdp_clk_cntl |= HDP_CLK_CNTL__IPH_MEM_CLK_SOFT_OVERRIDE_MASK |
856 HDP_CLK_CNTL__RC_MEM_CLK_SOFT_OVERRIDE_MASK |
857 HDP_CLK_CNTL__DBUS_CLK_SOFT_OVERRIDE_MASK |
858 HDP_CLK_CNTL__DYN_CLK_SOFT_OVERRIDE_MASK |
859 HDP_CLK_CNTL__XDP_REG_CLK_SOFT_OVERRIDE_MASK |
860 HDP_CLK_CNTL__HDP_REG_CLK_SOFT_OVERRIDE_MASK;
861 }
862
863 WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl);
864}
865
866static int nv_common_set_clockgating_state(void *handle,
867 enum amd_clockgating_state state)
868{
869 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
870
871 if (amdgpu_sriov_vf(adev))
872 return 0;
873
874 switch (adev->asic_type) {
875 case CHIP_NAVI10:
Xiaojie Yuan5e71e012018-12-17 18:23:27 +0800876 case CHIP_NAVI14:
Xiaojie Yuan7e17e582019-05-16 19:51:12 +0800877 case CHIP_NAVI12:
Hawking Zhangbebc0762019-08-23 19:39:18 +0800878 adev->nbio.funcs->update_medium_grain_clock_gating(adev,
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800879 state == AMD_CG_STATE_GATE ? true : false);
Hawking Zhangbebc0762019-08-23 19:39:18 +0800880 adev->nbio.funcs->update_medium_grain_light_sleep(adev,
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800881 state == AMD_CG_STATE_GATE ? true : false);
882 nv_update_hdp_mem_power_gating(adev,
883 state == AMD_CG_STATE_GATE ? true : false);
884 nv_update_hdp_clock_gating(adev,
885 state == AMD_CG_STATE_GATE ? true : false);
886 break;
887 default:
888 break;
889 }
890 return 0;
891}
892
893static int nv_common_set_powergating_state(void *handle,
894 enum amd_powergating_state state)
895{
896 /* TODO */
897 return 0;
898}
899
900static void nv_common_get_clockgating_state(void *handle, u32 *flags)
901{
902 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
903 uint32_t tmp;
904
905 if (amdgpu_sriov_vf(adev))
906 *flags = 0;
907
Hawking Zhangbebc0762019-08-23 19:39:18 +0800908 adev->nbio.funcs->get_clockgating_state(adev, flags);
Hawking Zhangc6b6a422019-03-04 14:07:37 +0800909
910 /* AMD_CG_SUPPORT_HDP_MGCG */
911 tmp = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL);
912 if (!(tmp & (HDP_CLK_CNTL__IPH_MEM_CLK_SOFT_OVERRIDE_MASK |
913 HDP_CLK_CNTL__RC_MEM_CLK_SOFT_OVERRIDE_MASK |
914 HDP_CLK_CNTL__DBUS_CLK_SOFT_OVERRIDE_MASK |
915 HDP_CLK_CNTL__DYN_CLK_SOFT_OVERRIDE_MASK |
916 HDP_CLK_CNTL__XDP_REG_CLK_SOFT_OVERRIDE_MASK |
917 HDP_CLK_CNTL__HDP_REG_CLK_SOFT_OVERRIDE_MASK)))
918 *flags |= AMD_CG_SUPPORT_HDP_MGCG;
919
920 /* AMD_CG_SUPPORT_HDP_LS/DS/SD */
921 tmp = RREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL);
922 if (tmp & HDP_MEM_POWER_CTRL__IPH_MEM_POWER_LS_EN_MASK)
923 *flags |= AMD_CG_SUPPORT_HDP_LS;
924 else if (tmp & HDP_MEM_POWER_CTRL__IPH_MEM_POWER_DS_EN_MASK)
925 *flags |= AMD_CG_SUPPORT_HDP_DS;
926 else if (tmp & HDP_MEM_POWER_CTRL__IPH_MEM_POWER_SD_EN_MASK)
927 *flags |= AMD_CG_SUPPORT_HDP_SD;
928
929 return;
930}
931
932static const struct amd_ip_funcs nv_common_ip_funcs = {
933 .name = "nv_common",
934 .early_init = nv_common_early_init,
935 .late_init = nv_common_late_init,
936 .sw_init = nv_common_sw_init,
937 .sw_fini = nv_common_sw_fini,
938 .hw_init = nv_common_hw_init,
939 .hw_fini = nv_common_hw_fini,
940 .suspend = nv_common_suspend,
941 .resume = nv_common_resume,
942 .is_idle = nv_common_is_idle,
943 .wait_for_idle = nv_common_wait_for_idle,
944 .soft_reset = nv_common_soft_reset,
945 .set_clockgating_state = nv_common_set_clockgating_state,
946 .set_powergating_state = nv_common_set_powergating_state,
947 .get_clockgating_state = nv_common_get_clockgating_state,
948};