Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 1 | /* |
| 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 Deucher | e9eea90 | 2019-07-31 10:39:40 -0500 | [diff] [blame] | 26 | #include <linux/pci.h> |
| 27 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 28 | #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 Wang | 767acab | 2019-07-05 15:58:46 -0500 | [diff] [blame] | 35 | #include "amdgpu_smu.h" |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 36 | #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" |
Alex Deucher | 29bc37b | 2019-11-13 14:27:54 -0500 | [diff] [blame] | 43 | #include "smuio/smuio_11_0_0_offset.h" |
Alex Deucher | 3967ae6 | 2020-05-28 17:28:17 -0400 | [diff] [blame] | 44 | #include "mp/mp_11_0_offset.h" |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 45 | |
| 46 | #include "soc15.h" |
| 47 | #include "soc15_common.h" |
| 48 | #include "gmc_v10_0.h" |
| 49 | #include "gfxhub_v2_0.h" |
| 50 | #include "mmhub_v2_0.h" |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 51 | #include "nbio_v2_3.h" |
Huang Rui | a7e91bd | 2020-08-27 12:02:37 -0400 | [diff] [blame] | 52 | #include "nbio_v7_2.h" |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 53 | #include "nv.h" |
| 54 | #include "navi10_ih.h" |
| 55 | #include "gfx_v10_0.h" |
| 56 | #include "sdma_v5_0.h" |
Likun Gao | 157e72e | 2019-06-17 13:38:29 +0800 | [diff] [blame] | 57 | #include "sdma_v5_2.h" |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 58 | #include "vcn_v2_0.h" |
Leo Liu | 5be45a2 | 2019-11-08 15:01:42 -0500 | [diff] [blame] | 59 | #include "jpeg_v2_0.h" |
Leo Liu | b8f1058 | 2020-03-24 16:30:24 -0400 | [diff] [blame] | 60 | #include "vcn_v3_0.h" |
Leo Liu | 4d72dd1 | 2020-03-24 16:31:23 -0400 | [diff] [blame] | 61 | #include "jpeg_v3_0.h" |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 62 | #include "dce_virtual.h" |
| 63 | #include "mes_v10_1.h" |
Jiange Zhao | b05b690 | 2019-09-11 17:29:07 +0800 | [diff] [blame] | 64 | #include "mxgpu_nv.h" |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 65 | |
| 66 | static const struct amd_ip_funcs nv_common_ip_funcs; |
| 67 | |
| 68 | /* |
| 69 | * Indirect registers accessor |
| 70 | */ |
| 71 | static u32 nv_pcie_rreg(struct amdgpu_device *adev, u32 reg) |
| 72 | { |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 73 | unsigned long address, data; |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 74 | address = adev->nbio.funcs->get_pcie_index_offset(adev); |
| 75 | data = adev->nbio.funcs->get_pcie_data_offset(adev); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 76 | |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 77 | return amdgpu_device_indirect_rreg(adev, address, data, reg); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | static void nv_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 81 | { |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 82 | unsigned long address, data; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 83 | |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 84 | address = adev->nbio.funcs->get_pcie_index_offset(adev); |
| 85 | data = adev->nbio.funcs->get_pcie_data_offset(adev); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 86 | |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 87 | amdgpu_device_indirect_wreg(adev, address, data, reg, v); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 88 | } |
| 89 | |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 90 | static u64 nv_pcie_rreg64(struct amdgpu_device *adev, u32 reg) |
| 91 | { |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 92 | unsigned long address, data; |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 93 | address = adev->nbio.funcs->get_pcie_index_offset(adev); |
| 94 | data = adev->nbio.funcs->get_pcie_data_offset(adev); |
| 95 | |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 96 | return amdgpu_device_indirect_rreg64(adev, address, data, reg); |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 97 | } |
| 98 | |
Huang Rui | 5de5434 | 2020-08-27 12:01:26 -0400 | [diff] [blame] | 99 | static u32 nv_pcie_port_rreg(struct amdgpu_device *adev, u32 reg) |
| 100 | { |
| 101 | unsigned long flags, address, data; |
| 102 | u32 r; |
| 103 | address = adev->nbio.funcs->get_pcie_port_index_offset(adev); |
| 104 | data = adev->nbio.funcs->get_pcie_port_data_offset(adev); |
| 105 | |
| 106 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); |
| 107 | WREG32(address, reg * 4); |
| 108 | (void)RREG32(address); |
| 109 | r = RREG32(data); |
| 110 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); |
| 111 | return r; |
| 112 | } |
| 113 | |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 114 | static void nv_pcie_wreg64(struct amdgpu_device *adev, u32 reg, u64 v) |
| 115 | { |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 116 | unsigned long address, data; |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 117 | |
| 118 | address = adev->nbio.funcs->get_pcie_index_offset(adev); |
| 119 | data = adev->nbio.funcs->get_pcie_data_offset(adev); |
| 120 | |
Hawking Zhang | 705a2b5 | 2020-09-15 17:57:30 +0800 | [diff] [blame] | 121 | amdgpu_device_indirect_wreg64(adev, address, data, reg, v); |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 122 | } |
| 123 | |
Huang Rui | 5de5434 | 2020-08-27 12:01:26 -0400 | [diff] [blame] | 124 | static void nv_pcie_port_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 125 | { |
| 126 | unsigned long flags, address, data; |
| 127 | |
| 128 | address = adev->nbio.funcs->get_pcie_port_index_offset(adev); |
| 129 | data = adev->nbio.funcs->get_pcie_port_data_offset(adev); |
| 130 | |
| 131 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); |
| 132 | WREG32(address, reg * 4); |
| 133 | (void)RREG32(address); |
| 134 | WREG32(data, v); |
| 135 | (void)RREG32(data); |
| 136 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); |
| 137 | } |
| 138 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 139 | static u32 nv_didt_rreg(struct amdgpu_device *adev, u32 reg) |
| 140 | { |
| 141 | unsigned long flags, address, data; |
| 142 | u32 r; |
| 143 | |
| 144 | address = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_INDEX); |
| 145 | data = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_DATA); |
| 146 | |
| 147 | spin_lock_irqsave(&adev->didt_idx_lock, flags); |
| 148 | WREG32(address, (reg)); |
| 149 | r = RREG32(data); |
| 150 | spin_unlock_irqrestore(&adev->didt_idx_lock, flags); |
| 151 | return r; |
| 152 | } |
| 153 | |
| 154 | static void nv_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 155 | { |
| 156 | unsigned long flags, address, data; |
| 157 | |
| 158 | address = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_INDEX); |
| 159 | data = SOC15_REG_OFFSET(GC, 0, mmDIDT_IND_DATA); |
| 160 | |
| 161 | spin_lock_irqsave(&adev->didt_idx_lock, flags); |
| 162 | WREG32(address, (reg)); |
| 163 | WREG32(data, (v)); |
| 164 | spin_unlock_irqrestore(&adev->didt_idx_lock, flags); |
| 165 | } |
| 166 | |
| 167 | static u32 nv_get_config_memsize(struct amdgpu_device *adev) |
| 168 | { |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 169 | return adev->nbio.funcs->get_memsize(adev); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | static u32 nv_get_xclk(struct amdgpu_device *adev) |
| 173 | { |
Tao Zhou | 462a70d | 2019-05-14 11:37:32 +0800 | [diff] [blame] | 174 | return adev->clock.spll.reference_freq; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | |
| 178 | void nv_grbm_select(struct amdgpu_device *adev, |
| 179 | u32 me, u32 pipe, u32 queue, u32 vmid) |
| 180 | { |
| 181 | u32 grbm_gfx_cntl = 0; |
| 182 | grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, PIPEID, pipe); |
| 183 | grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, MEID, me); |
| 184 | grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, VMID, vmid); |
| 185 | grbm_gfx_cntl = REG_SET_FIELD(grbm_gfx_cntl, GRBM_GFX_CNTL, QUEUEID, queue); |
| 186 | |
| 187 | WREG32(SOC15_REG_OFFSET(GC, 0, mmGRBM_GFX_CNTL), grbm_gfx_cntl); |
| 188 | } |
| 189 | |
| 190 | static void nv_vga_set_state(struct amdgpu_device *adev, bool state) |
| 191 | { |
| 192 | /* todo */ |
| 193 | } |
| 194 | |
| 195 | static bool nv_read_disabled_bios(struct amdgpu_device *adev) |
| 196 | { |
| 197 | /* todo */ |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | static bool nv_read_bios_from_rom(struct amdgpu_device *adev, |
| 202 | u8 *bios, u32 length_bytes) |
| 203 | { |
Alex Deucher | 29bc37b | 2019-11-13 14:27:54 -0500 | [diff] [blame] | 204 | u32 *dw_ptr; |
| 205 | u32 i, length_dw; |
| 206 | |
| 207 | if (bios == NULL) |
| 208 | return false; |
| 209 | if (length_bytes == 0) |
| 210 | return false; |
| 211 | /* APU vbios image is part of sbios image */ |
| 212 | if (adev->flags & AMD_IS_APU) |
| 213 | return false; |
| 214 | |
| 215 | dw_ptr = (u32 *)bios; |
| 216 | length_dw = ALIGN(length_bytes, 4) / 4; |
| 217 | |
| 218 | /* set rom index to 0 */ |
| 219 | WREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_INDEX), 0); |
| 220 | /* read out the rom data */ |
| 221 | for (i = 0; i < length_dw; i++) |
| 222 | dw_ptr[i] = RREG32(SOC15_REG_OFFSET(SMUIO, 0, mmROM_DATA)); |
| 223 | |
| 224 | return true; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | static struct soc15_allowed_register_entry nv_allowed_read_registers[] = { |
| 228 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS)}, |
| 229 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS2)}, |
| 230 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE0)}, |
| 231 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE1)}, |
| 232 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE2)}, |
| 233 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE3)}, |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 234 | { SOC15_REG_ENTRY(SDMA0, 0, mmSDMA0_STATUS_REG)}, |
| 235 | { SOC15_REG_ENTRY(SDMA1, 0, mmSDMA1_STATUS_REG)}, |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 236 | { SOC15_REG_ENTRY(GC, 0, mmCP_STAT)}, |
| 237 | { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT1)}, |
| 238 | { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT2)}, |
| 239 | { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT3)}, |
| 240 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_BUSY_STAT)}, |
| 241 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_STALLED_STAT1)}, |
| 242 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_STATUS)}, |
Marek Olšák | 664fe85 | 2019-10-22 17:22:38 -0400 | [diff] [blame] | 243 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_BUSY_STAT)}, |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 244 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_STALLED_STAT1)}, |
| 245 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_STATUS)}, |
| 246 | { SOC15_REG_ENTRY(GC, 0, mmGB_ADDR_CONFIG)}, |
| 247 | }; |
| 248 | |
| 249 | static uint32_t nv_read_indexed_register(struct amdgpu_device *adev, u32 se_num, |
| 250 | u32 sh_num, u32 reg_offset) |
| 251 | { |
| 252 | uint32_t val; |
| 253 | |
| 254 | mutex_lock(&adev->grbm_idx_mutex); |
| 255 | if (se_num != 0xffffffff || sh_num != 0xffffffff) |
| 256 | amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff); |
| 257 | |
| 258 | val = RREG32(reg_offset); |
| 259 | |
| 260 | if (se_num != 0xffffffff || sh_num != 0xffffffff) |
| 261 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); |
| 262 | mutex_unlock(&adev->grbm_idx_mutex); |
| 263 | return val; |
| 264 | } |
| 265 | |
| 266 | static uint32_t nv_get_register_value(struct amdgpu_device *adev, |
| 267 | bool indexed, u32 se_num, |
| 268 | u32 sh_num, u32 reg_offset) |
| 269 | { |
| 270 | if (indexed) { |
| 271 | return nv_read_indexed_register(adev, se_num, sh_num, reg_offset); |
| 272 | } else { |
| 273 | if (reg_offset == SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG)) |
| 274 | return adev->gfx.config.gb_addr_config; |
| 275 | return RREG32(reg_offset); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | static int nv_read_register(struct amdgpu_device *adev, u32 se_num, |
| 280 | u32 sh_num, u32 reg_offset, u32 *value) |
| 281 | { |
| 282 | uint32_t i; |
| 283 | struct soc15_allowed_register_entry *en; |
| 284 | |
| 285 | *value = 0; |
| 286 | for (i = 0; i < ARRAY_SIZE(nv_allowed_read_registers); i++) { |
| 287 | en = &nv_allowed_read_registers[i]; |
Huang Rui | fced3c3 | 2020-08-28 22:54:32 +0800 | [diff] [blame] | 288 | if ((i == 7 && (adev->sdma.num_instances == 1)) || /* some asics don't have SDMA1 */ |
| 289 | reg_offset != |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 290 | (adev->reg_offset[en->hwip][en->inst][en->seg] + en->reg_offset)) |
| 291 | continue; |
| 292 | |
| 293 | *value = nv_get_register_value(adev, |
| 294 | nv_allowed_read_registers[i].grbm_indexed, |
| 295 | se_num, sh_num, reg_offset); |
| 296 | return 0; |
| 297 | } |
| 298 | return -EINVAL; |
| 299 | } |
| 300 | |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 301 | static int nv_asic_mode1_reset(struct amdgpu_device *adev) |
| 302 | { |
| 303 | u32 i; |
| 304 | int ret = 0; |
| 305 | |
| 306 | amdgpu_atombios_scratch_regs_engine_hung(adev, true); |
| 307 | |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 308 | /* disable BM */ |
| 309 | pci_clear_master(adev->pdev); |
| 310 | |
Andrey Grodzovsky | c1dd4aa | 2020-08-24 12:30:47 -0400 | [diff] [blame] | 311 | amdgpu_device_cache_pci_state(adev->pdev); |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 312 | |
Wenhui Sheng | 311531f | 2020-07-13 15:15:11 +0800 | [diff] [blame] | 313 | if (amdgpu_dpm_is_mode1_reset_supported(adev)) { |
| 314 | dev_info(adev->dev, "GPU smu mode1 reset\n"); |
| 315 | ret = amdgpu_dpm_mode1_reset(adev); |
| 316 | } else { |
| 317 | dev_info(adev->dev, "GPU psp mode1 reset\n"); |
| 318 | ret = psp_gpu_reset(adev); |
| 319 | } |
| 320 | |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 321 | if (ret) |
| 322 | dev_err(adev->dev, "GPU mode1 reset failed\n"); |
Andrey Grodzovsky | c1dd4aa | 2020-08-24 12:30:47 -0400 | [diff] [blame] | 323 | amdgpu_device_load_pci_state(adev->pdev); |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 324 | |
| 325 | /* wait for asic to come out of reset */ |
| 326 | for (i = 0; i < adev->usec_timeout; i++) { |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 327 | u32 memsize = adev->nbio.funcs->get_memsize(adev); |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 328 | |
| 329 | if (memsize != 0xffffffff) |
| 330 | break; |
| 331 | udelay(1); |
| 332 | } |
| 333 | |
| 334 | amdgpu_atombios_scratch_regs_engine_hung(adev, false); |
| 335 | |
| 336 | return ret; |
| 337 | } |
Alex Deucher | 2ddc6c3 | 2019-07-23 23:48:21 -0500 | [diff] [blame] | 338 | |
Alex Deucher | ac74261 | 2019-11-07 18:12:17 -0500 | [diff] [blame] | 339 | static bool nv_asic_supports_baco(struct amdgpu_device *adev) |
| 340 | { |
| 341 | struct smu_context *smu = &adev->smu; |
| 342 | |
| 343 | if (smu_baco_is_support(smu)) |
| 344 | return true; |
| 345 | else |
| 346 | return false; |
| 347 | } |
| 348 | |
Alex Deucher | 2ddc6c3 | 2019-07-23 23:48:21 -0500 | [diff] [blame] | 349 | static enum amd_reset_method |
| 350 | nv_asic_reset_method(struct amdgpu_device *adev) |
| 351 | { |
| 352 | struct smu_context *smu = &adev->smu; |
| 353 | |
Wenhui Sheng | 273da6f | 2020-07-14 16:29:18 +0800 | [diff] [blame] | 354 | if (amdgpu_reset_method == AMD_RESET_METHOD_MODE1 || |
| 355 | amdgpu_reset_method == AMD_RESET_METHOD_BACO) |
| 356 | return amdgpu_reset_method; |
| 357 | |
| 358 | if (amdgpu_reset_method != -1) |
| 359 | dev_warn(adev->dev, "Specified reset method:%d isn't supported, using AUTO instead.\n", |
| 360 | amdgpu_reset_method); |
| 361 | |
Likun Gao | ca6fd7a | 2020-08-06 17:37:28 +0800 | [diff] [blame] | 362 | switch (adev->asic_type) { |
| 363 | case CHIP_SIENNA_CICHLID: |
Jiansong Chen | 22dd44f | 2020-08-25 15:39:57 +0800 | [diff] [blame] | 364 | case CHIP_NAVY_FLOUNDER: |
Alex Deucher | 2ddc6c3 | 2019-07-23 23:48:21 -0500 | [diff] [blame] | 365 | return AMD_RESET_METHOD_MODE1; |
Likun Gao | ca6fd7a | 2020-08-06 17:37:28 +0800 | [diff] [blame] | 366 | default: |
| 367 | if (smu_baco_is_support(smu)) |
| 368 | return AMD_RESET_METHOD_BACO; |
| 369 | else |
| 370 | return AMD_RESET_METHOD_MODE1; |
| 371 | } |
Alex Deucher | 2ddc6c3 | 2019-07-23 23:48:21 -0500 | [diff] [blame] | 372 | } |
| 373 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 374 | static int nv_asic_reset(struct amdgpu_device *adev) |
| 375 | { |
Kevin Wang | 767acab | 2019-07-05 15:58:46 -0500 | [diff] [blame] | 376 | int ret = 0; |
| 377 | struct smu_context *smu = &adev->smu; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 378 | |
Monk Liu | e352625 | 2019-08-27 16:32:55 +0800 | [diff] [blame] | 379 | if (nv_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) { |
Alex Deucher | 11043b7 | 2020-08-11 12:02:21 -0400 | [diff] [blame] | 380 | dev_info(adev->dev, "BACO reset\n"); |
Wenhui Sheng | 311531f | 2020-07-13 15:15:11 +0800 | [diff] [blame] | 381 | |
Alex Deucher | 11520f2 | 2019-10-28 15:20:03 -0400 | [diff] [blame] | 382 | ret = smu_baco_enter(smu); |
| 383 | if (ret) |
| 384 | return ret; |
| 385 | ret = smu_baco_exit(smu); |
| 386 | if (ret) |
| 387 | return ret; |
Alex Deucher | 11043b7 | 2020-08-11 12:02:21 -0400 | [diff] [blame] | 388 | } else { |
| 389 | dev_info(adev->dev, "MODE1 reset\n"); |
Kevin Wang | 3e2bb60 | 2019-07-05 12:51:45 +0800 | [diff] [blame] | 390 | ret = nv_asic_mode1_reset(adev); |
Alex Deucher | 11043b7 | 2020-08-11 12:02:21 -0400 | [diff] [blame] | 391 | } |
Kevin Wang | 767acab | 2019-07-05 15:58:46 -0500 | [diff] [blame] | 392 | |
| 393 | return ret; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | static int nv_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) |
| 397 | { |
| 398 | /* todo */ |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | static int nv_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) |
| 403 | { |
| 404 | /* todo */ |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | static void nv_pcie_gen3_enable(struct amdgpu_device *adev) |
| 409 | { |
| 410 | if (pci_is_root_bus(adev->pdev->bus)) |
| 411 | return; |
| 412 | |
| 413 | if (amdgpu_pcie_gen2 == 0) |
| 414 | return; |
| 415 | |
| 416 | if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | |
| 417 | CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) |
| 418 | return; |
| 419 | |
| 420 | /* todo */ |
| 421 | } |
| 422 | |
| 423 | static void nv_program_aspm(struct amdgpu_device *adev) |
| 424 | { |
| 425 | |
| 426 | if (amdgpu_aspm == 0) |
| 427 | return; |
| 428 | |
| 429 | /* todo */ |
| 430 | } |
| 431 | |
| 432 | static void nv_enable_doorbell_aperture(struct amdgpu_device *adev, |
| 433 | bool enable) |
| 434 | { |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 435 | adev->nbio.funcs->enable_doorbell_aperture(adev, enable); |
| 436 | adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | static const struct amdgpu_ip_block_version nv_common_ip_block = |
| 440 | { |
| 441 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 442 | .major = 1, |
| 443 | .minor = 0, |
| 444 | .rev = 0, |
| 445 | .funcs = &nv_common_ip_funcs, |
| 446 | }; |
| 447 | |
Xiaojie Yuan | b5c7385 | 2019-08-05 16:19:45 +0800 | [diff] [blame] | 448 | static int nv_reg_base_init(struct amdgpu_device *adev) |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 449 | { |
Xiaojie Yuan | b5c7385 | 2019-08-05 16:19:45 +0800 | [diff] [blame] | 450 | int r; |
| 451 | |
Alex Deucher | 8bb3aa1 | 2020-08-28 11:42:44 -0400 | [diff] [blame] | 452 | /* IP discovery table is not available yet */ |
| 453 | if (adev->asic_type == CHIP_VANGOGH) |
| 454 | goto legacy_init; |
| 455 | |
Xiaojie Yuan | b5c7385 | 2019-08-05 16:19:45 +0800 | [diff] [blame] | 456 | if (amdgpu_discovery) { |
| 457 | r = amdgpu_discovery_reg_base_init(adev); |
| 458 | if (r) { |
| 459 | DRM_WARN("failed to init reg base from ip discovery table, " |
| 460 | "fallback to legacy init method\n"); |
| 461 | goto legacy_init; |
| 462 | } |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | legacy_init: |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 468 | switch (adev->asic_type) { |
| 469 | case CHIP_NAVI10: |
| 470 | navi10_reg_base_init(adev); |
| 471 | break; |
Xiaojie Yuan | a0f6d926 | 2018-12-17 18:24:03 +0800 | [diff] [blame] | 472 | case CHIP_NAVI14: |
| 473 | navi14_reg_base_init(adev); |
| 474 | break; |
Xiaojie Yuan | 03d0a07 | 2019-05-14 15:22:53 +0800 | [diff] [blame] | 475 | case CHIP_NAVI12: |
| 476 | navi12_reg_base_init(adev); |
| 477 | break; |
Likun Gao | dccdbf3 | 2019-11-07 16:28:14 +0800 | [diff] [blame] | 478 | case CHIP_SIENNA_CICHLID: |
Jiansong Chen | c8c959f | 2020-02-11 14:00:39 +0800 | [diff] [blame] | 479 | case CHIP_NAVY_FLOUNDER: |
Likun Gao | dccdbf3 | 2019-11-07 16:28:14 +0800 | [diff] [blame] | 480 | sienna_cichlid_reg_base_init(adev); |
| 481 | break; |
Huang Rui | 026570e | 2020-08-27 10:46:19 -0400 | [diff] [blame] | 482 | case CHIP_VANGOGH: |
| 483 | vangogh_reg_base_init(adev); |
| 484 | break; |
Tao Zhou | 038d757 | 2020-10-02 11:34:02 -0400 | [diff] [blame^] | 485 | case CHIP_DIMGREY_CAVEFISH: |
| 486 | dimgrey_cavefish_reg_base_init(adev); |
| 487 | break; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 488 | default: |
| 489 | return -EINVAL; |
| 490 | } |
| 491 | |
Xiaojie Yuan | b5c7385 | 2019-08-05 16:19:45 +0800 | [diff] [blame] | 492 | return 0; |
| 493 | } |
| 494 | |
Wenhui Sheng | c129946 | 2020-06-23 11:35:05 +0800 | [diff] [blame] | 495 | void nv_set_virt_ops(struct amdgpu_device *adev) |
| 496 | { |
| 497 | adev->virt.ops = &xgpu_nv_virt_ops; |
| 498 | } |
| 499 | |
Xiaojie Yuan | b5c7385 | 2019-08-05 16:19:45 +0800 | [diff] [blame] | 500 | int nv_set_ip_blocks(struct amdgpu_device *adev) |
| 501 | { |
| 502 | int r; |
| 503 | |
Huang Rui | a7e91bd | 2020-08-27 12:02:37 -0400 | [diff] [blame] | 504 | if (adev->flags & AMD_IS_APU) { |
| 505 | adev->nbio.funcs = &nbio_v7_2_funcs; |
| 506 | adev->nbio.hdp_flush_reg = &nbio_v7_2_hdp_flush_reg; |
| 507 | } else { |
| 508 | adev->nbio.funcs = &nbio_v2_3_funcs; |
| 509 | adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg; |
| 510 | } |
Monk Liu | 122078d | 2020-03-04 23:51:51 +0800 | [diff] [blame] | 511 | |
John Clements | c652923 | 2020-07-17 14:13:50 +0800 | [diff] [blame] | 512 | if (adev->asic_type == CHIP_SIENNA_CICHLID) |
| 513 | adev->gmc.xgmi.supported = true; |
| 514 | |
Xiaojie Yuan | b5c7385 | 2019-08-05 16:19:45 +0800 | [diff] [blame] | 515 | /* Set IP register base before any HW register access */ |
| 516 | r = nv_reg_base_init(adev); |
| 517 | if (r) |
| 518 | return r; |
| 519 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 520 | switch (adev->asic_type) { |
| 521 | case CHIP_NAVI10: |
Alex Deucher | d1daf85 | 2019-07-02 14:42:25 -0500 | [diff] [blame] | 522 | case CHIP_NAVI14: |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 523 | amdgpu_device_ip_block_add(adev, &nv_common_ip_block); |
| 524 | amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block); |
| 525 | amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block); |
| 526 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); |
| 527 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP && |
Evan Quan | 9530273 | 2020-01-07 16:57:39 +0800 | [diff] [blame] | 528 | !amdgpu_sriov_vf(adev)) |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 529 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
| 530 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
| 531 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
Alex Deucher | f8a7976 | 2019-07-05 15:39:39 -0500 | [diff] [blame] | 532 | #if defined(CONFIG_DRM_AMD_DC) |
Harry Wentland | b4f199c | 2019-02-26 16:25:27 -0500 | [diff] [blame] | 533 | else if (amdgpu_device_has_dc_support(adev)) |
| 534 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
Alex Deucher | f8a7976 | 2019-07-05 15:39:39 -0500 | [diff] [blame] | 535 | #endif |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 536 | amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block); |
| 537 | amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block); |
| 538 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT && |
Evan Quan | 9530273 | 2020-01-07 16:57:39 +0800 | [diff] [blame] | 539 | !amdgpu_sriov_vf(adev)) |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 540 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
| 541 | amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block); |
Leo Liu | 5be45a2 | 2019-11-08 15:01:42 -0500 | [diff] [blame] | 542 | amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 543 | if (adev->enable_mes) |
| 544 | amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block); |
| 545 | break; |
Xiaojie Yuan | 44e9e7c | 2019-05-16 19:58:19 +0800 | [diff] [blame] | 546 | case CHIP_NAVI12: |
| 547 | amdgpu_device_ip_block_add(adev, &nv_common_ip_block); |
| 548 | amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block); |
| 549 | amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block); |
Xiaojie Yuan | 6b66ae2 | 2019-07-18 02:54:29 +0800 | [diff] [blame] | 550 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); |
Monk Liu | 79bebab | 2020-04-22 12:09:16 +0800 | [diff] [blame] | 551 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) |
Xiaojie Yuan | 7f47efe | 2019-07-16 03:26:49 +0800 | [diff] [blame] | 552 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
Xiaojie Yuan | 7990202 | 2019-06-26 19:19:57 +0800 | [diff] [blame] | 553 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
| 554 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
Petr Cvek | 20c14ee | 2019-08-30 16:31:58 +0200 | [diff] [blame] | 555 | #if defined(CONFIG_DRM_AMD_DC) |
Leo Li | 078655d9 | 2019-07-16 18:12:13 -0400 | [diff] [blame] | 556 | else if (amdgpu_device_has_dc_support(adev)) |
| 557 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
Petr Cvek | 20c14ee | 2019-08-30 16:31:58 +0200 | [diff] [blame] | 558 | #endif |
Xiaojie Yuan | 44e9e7c | 2019-05-16 19:58:19 +0800 | [diff] [blame] | 559 | amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block); |
| 560 | amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block); |
Xiaojie Yuan | 7f47efe | 2019-07-16 03:26:49 +0800 | [diff] [blame] | 561 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT && |
Evan Quan | 9530273 | 2020-01-07 16:57:39 +0800 | [diff] [blame] | 562 | !amdgpu_sriov_vf(adev)) |
Xiaojie Yuan | 7f47efe | 2019-07-16 03:26:49 +0800 | [diff] [blame] | 563 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
Boyuan Zhang | 1fbed28 | 2019-07-18 10:13:23 -0400 | [diff] [blame] | 564 | amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block); |
Monk Liu | fe44249 | 2020-03-05 21:10:03 +0800 | [diff] [blame] | 565 | if (!amdgpu_sriov_vf(adev)) |
| 566 | amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block); |
Xiaojie Yuan | 44e9e7c | 2019-05-16 19:58:19 +0800 | [diff] [blame] | 567 | break; |
Likun Gao | 2e1ba10 | 2019-04-18 13:49:07 +0800 | [diff] [blame] | 568 | case CHIP_SIENNA_CICHLID: |
| 569 | amdgpu_device_ip_block_add(adev, &nv_common_ip_block); |
Likun Gao | 0b3df16 | 2019-06-16 22:34:59 +0800 | [diff] [blame] | 570 | amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block); |
Likun Gao | 757b3af | 2019-06-16 22:37:56 +0800 | [diff] [blame] | 571 | amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block); |
Likun Gao | 56304e7 | 2020-03-24 16:27:43 -0400 | [diff] [blame] | 572 | if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) |
| 573 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); |
Likun Gao | b07e5c6 | 2020-03-24 16:24:44 -0400 | [diff] [blame] | 574 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP && |
shaoyunl | 38d5bbe | 2020-03-17 11:41:34 -0400 | [diff] [blame] | 575 | is_support_sw_smu(adev) && !amdgpu_sriov_vf(adev)) |
Likun Gao | b07e5c6 | 2020-03-24 16:24:44 -0400 | [diff] [blame] | 576 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
Likun Gao | 9a98676 | 2019-08-14 17:39:03 +0800 | [diff] [blame] | 577 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
| 578 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
Bhawanpreet Lakha | 464ab91 | 2020-05-21 12:57:27 -0400 | [diff] [blame] | 579 | #if defined(CONFIG_DRM_AMD_DC) |
| 580 | else if (amdgpu_device_has_dc_support(adev)) |
| 581 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
| 582 | #endif |
Likun Gao | 933c8a9 | 2020-05-01 10:21:23 -0400 | [diff] [blame] | 583 | amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block); |
Likun Gao | 157e72e | 2019-06-17 13:38:29 +0800 | [diff] [blame] | 584 | amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block); |
Leo Liu | b8f1058 | 2020-03-24 16:30:24 -0400 | [diff] [blame] | 585 | amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block); |
Jack Zhang | c45fbe1 | 2020-06-23 19:36:24 +0800 | [diff] [blame] | 586 | if (!amdgpu_sriov_vf(adev)) |
| 587 | amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block); |
| 588 | |
Jack Xiao | a346ef8 | 2020-03-24 16:28:43 -0400 | [diff] [blame] | 589 | if (adev->enable_mes) |
| 590 | amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block); |
Likun Gao | 2e1ba10 | 2019-04-18 13:49:07 +0800 | [diff] [blame] | 591 | break; |
Jiansong Chen | 8515e0a | 2020-02-12 21:47:47 +0800 | [diff] [blame] | 592 | case CHIP_NAVY_FLOUNDER: |
| 593 | amdgpu_device_ip_block_add(adev, &nv_common_ip_block); |
Jiansong Chen | fc8f07d | 2020-02-12 22:19:37 +0800 | [diff] [blame] | 594 | amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block); |
Jiansong Chen | 026c396 | 2020-02-12 22:32:01 +0800 | [diff] [blame] | 595 | amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block); |
Jiansong Chen | 7420eab2 | 2020-07-08 17:07:26 -0400 | [diff] [blame] | 596 | if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) |
| 597 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); |
| 598 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP && |
| 599 | is_support_sw_smu(adev)) |
| 600 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
Jiansong Chen | 5404f07 | 2020-02-24 14:28:34 +0800 | [diff] [blame] | 601 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
| 602 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
Bhawanpreet Lakha | a6c5308 | 2020-07-08 17:11:12 -0400 | [diff] [blame] | 603 | #if defined(CONFIG_DRM_AMD_DC) |
| 604 | else if (amdgpu_device_has_dc_support(adev)) |
| 605 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
| 606 | #endif |
Jiansong Chen | 885eb3f | 2020-02-13 15:43:15 +0800 | [diff] [blame] | 607 | amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block); |
Jiansong Chen | df2d15d | 2020-02-14 16:19:13 +0800 | [diff] [blame] | 608 | amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block); |
Boyuan Zhang | 290b4ad | 2020-07-08 16:48:26 -0400 | [diff] [blame] | 609 | amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block); |
| 610 | amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block); |
Jiansong Chen | f4497d1 | 2020-04-15 11:20:19 +0800 | [diff] [blame] | 611 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT && |
| 612 | is_support_sw_smu(adev)) |
| 613 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
Jiansong Chen | 8515e0a | 2020-02-12 21:47:47 +0800 | [diff] [blame] | 614 | break; |
Huang Rui | 88edbad | 2019-10-12 20:02:39 +0800 | [diff] [blame] | 615 | case CHIP_VANGOGH: |
| 616 | amdgpu_device_ip_block_add(adev, &nv_common_ip_block); |
| 617 | amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block); |
| 618 | amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block); |
Huang Rui | ed3b735 | 2020-09-17 12:02:12 -0400 | [diff] [blame] | 619 | if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) |
| 620 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); |
Huang Rui | c821e0f | 2020-05-28 15:46:41 +0800 | [diff] [blame] | 621 | amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); |
Huang Rui | 88edbad | 2019-10-12 20:02:39 +0800 | [diff] [blame] | 622 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
| 623 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
| 624 | amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block); |
| 625 | amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block); |
Thong Thai | b4e532d | 2020-08-27 11:35:13 -0400 | [diff] [blame] | 626 | amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block); |
| 627 | amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block); |
Huang Rui | 88edbad | 2019-10-12 20:02:39 +0800 | [diff] [blame] | 628 | break; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 629 | default: |
| 630 | return -EINVAL; |
| 631 | } |
| 632 | |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | static uint32_t nv_get_rev_id(struct amdgpu_device *adev) |
| 637 | { |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 638 | return adev->nbio.funcs->get_rev_id(adev); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | static void nv_flush_hdp(struct amdgpu_device *adev, struct amdgpu_ring *ring) |
| 642 | { |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 643 | adev->nbio.funcs->hdp_flush(adev, ring); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | static void nv_invalidate_hdp(struct amdgpu_device *adev, |
| 647 | struct amdgpu_ring *ring) |
| 648 | { |
| 649 | if (!ring || !ring->funcs->emit_wreg) { |
Stanley.Yang | 78f0aef | 2020-09-22 16:56:54 +0800 | [diff] [blame] | 650 | WREG32_SOC15_NO_KIQ(HDP, 0, mmHDP_READ_CACHE_INVALIDATE, 1); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 651 | } else { |
| 652 | amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET( |
| 653 | HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 1); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | static bool nv_need_full_reset(struct amdgpu_device *adev) |
| 658 | { |
| 659 | return true; |
| 660 | } |
| 661 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 662 | static bool nv_need_reset_on_init(struct amdgpu_device *adev) |
| 663 | { |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 664 | u32 sol_reg; |
| 665 | |
| 666 | if (adev->flags & AMD_IS_APU) |
| 667 | return false; |
| 668 | |
| 669 | /* Check sOS sign of life register to confirm sys driver and sOS |
| 670 | * are already been loaded. |
| 671 | */ |
| 672 | sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81); |
| 673 | if (sol_reg) |
| 674 | return true; |
Alex Deucher | 3967ae6 | 2020-05-28 17:28:17 -0400 | [diff] [blame] | 675 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 676 | return false; |
| 677 | } |
| 678 | |
Kevin Wang | 2af81531 | 2019-11-05 18:53:30 +0800 | [diff] [blame] | 679 | static uint64_t nv_get_pcie_replay_count(struct amdgpu_device *adev) |
| 680 | { |
| 681 | |
| 682 | /* TODO |
| 683 | * dummy implement for pcie_replay_count sysfs interface |
| 684 | * */ |
| 685 | |
| 686 | return 0; |
| 687 | } |
| 688 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 689 | static void nv_init_doorbell_index(struct amdgpu_device *adev) |
| 690 | { |
| 691 | adev->doorbell_index.kiq = AMDGPU_NAVI10_DOORBELL_KIQ; |
| 692 | adev->doorbell_index.mec_ring0 = AMDGPU_NAVI10_DOORBELL_MEC_RING0; |
| 693 | adev->doorbell_index.mec_ring1 = AMDGPU_NAVI10_DOORBELL_MEC_RING1; |
| 694 | adev->doorbell_index.mec_ring2 = AMDGPU_NAVI10_DOORBELL_MEC_RING2; |
| 695 | adev->doorbell_index.mec_ring3 = AMDGPU_NAVI10_DOORBELL_MEC_RING3; |
| 696 | adev->doorbell_index.mec_ring4 = AMDGPU_NAVI10_DOORBELL_MEC_RING4; |
| 697 | adev->doorbell_index.mec_ring5 = AMDGPU_NAVI10_DOORBELL_MEC_RING5; |
| 698 | adev->doorbell_index.mec_ring6 = AMDGPU_NAVI10_DOORBELL_MEC_RING6; |
| 699 | adev->doorbell_index.mec_ring7 = AMDGPU_NAVI10_DOORBELL_MEC_RING7; |
| 700 | adev->doorbell_index.userqueue_start = AMDGPU_NAVI10_DOORBELL_USERQUEUE_START; |
| 701 | adev->doorbell_index.userqueue_end = AMDGPU_NAVI10_DOORBELL_USERQUEUE_END; |
| 702 | adev->doorbell_index.gfx_ring0 = AMDGPU_NAVI10_DOORBELL_GFX_RING0; |
| 703 | adev->doorbell_index.gfx_ring1 = AMDGPU_NAVI10_DOORBELL_GFX_RING1; |
Jack Xiao | 2051923 | 2019-04-26 18:58:41 +0800 | [diff] [blame] | 704 | adev->doorbell_index.mes_ring = AMDGPU_NAVI10_DOORBELL_MES_RING; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 705 | adev->doorbell_index.sdma_engine[0] = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE0; |
| 706 | adev->doorbell_index.sdma_engine[1] = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE1; |
Likun Gao | 157e72e | 2019-06-17 13:38:29 +0800 | [diff] [blame] | 707 | adev->doorbell_index.sdma_engine[2] = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE2; |
| 708 | adev->doorbell_index.sdma_engine[3] = AMDGPU_NAVI10_DOORBELL_sDMA_ENGINE3; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 709 | adev->doorbell_index.ih = AMDGPU_NAVI10_DOORBELL_IH; |
| 710 | adev->doorbell_index.vcn.vcn_ring0_1 = AMDGPU_NAVI10_DOORBELL64_VCN0_1; |
| 711 | adev->doorbell_index.vcn.vcn_ring2_3 = AMDGPU_NAVI10_DOORBELL64_VCN2_3; |
| 712 | adev->doorbell_index.vcn.vcn_ring4_5 = AMDGPU_NAVI10_DOORBELL64_VCN4_5; |
| 713 | adev->doorbell_index.vcn.vcn_ring6_7 = AMDGPU_NAVI10_DOORBELL64_VCN6_7; |
| 714 | adev->doorbell_index.first_non_cp = AMDGPU_NAVI10_DOORBELL64_FIRST_NON_CP; |
| 715 | adev->doorbell_index.last_non_cp = AMDGPU_NAVI10_DOORBELL64_LAST_NON_CP; |
| 716 | |
| 717 | adev->doorbell_index.max_assignment = AMDGPU_NAVI10_DOORBELL_MAX_ASSIGNMENT << 1; |
| 718 | adev->doorbell_index.sdma_doorbell_range = 20; |
| 719 | } |
| 720 | |
Alex Deucher | a717373 | 2020-08-19 17:04:47 -0400 | [diff] [blame] | 721 | static void nv_pre_asic_init(struct amdgpu_device *adev) |
| 722 | { |
| 723 | } |
| 724 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 725 | static const struct amdgpu_asic_funcs nv_asic_funcs = |
| 726 | { |
| 727 | .read_disabled_bios = &nv_read_disabled_bios, |
| 728 | .read_bios_from_rom = &nv_read_bios_from_rom, |
| 729 | .read_register = &nv_read_register, |
| 730 | .reset = &nv_asic_reset, |
Alex Deucher | 2ddc6c3 | 2019-07-23 23:48:21 -0500 | [diff] [blame] | 731 | .reset_method = &nv_asic_reset_method, |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 732 | .set_vga_state = &nv_vga_set_state, |
| 733 | .get_xclk = &nv_get_xclk, |
| 734 | .set_uvd_clocks = &nv_set_uvd_clocks, |
| 735 | .set_vce_clocks = &nv_set_vce_clocks, |
| 736 | .get_config_memsize = &nv_get_config_memsize, |
| 737 | .flush_hdp = &nv_flush_hdp, |
| 738 | .invalidate_hdp = &nv_invalidate_hdp, |
| 739 | .init_doorbell_index = &nv_init_doorbell_index, |
| 740 | .need_full_reset = &nv_need_full_reset, |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 741 | .need_reset_on_init = &nv_need_reset_on_init, |
Kevin Wang | 2af81531 | 2019-11-05 18:53:30 +0800 | [diff] [blame] | 742 | .get_pcie_replay_count = &nv_get_pcie_replay_count, |
Alex Deucher | ac74261 | 2019-11-07 18:12:17 -0500 | [diff] [blame] | 743 | .supports_baco = &nv_asic_supports_baco, |
Alex Deucher | a717373 | 2020-08-19 17:04:47 -0400 | [diff] [blame] | 744 | .pre_asic_init = &nv_pre_asic_init, |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 745 | }; |
| 746 | |
| 747 | static int nv_common_early_init(void *handle) |
| 748 | { |
Yong Zhao | 923c087 | 2019-09-27 23:30:05 -0400 | [diff] [blame] | 749 | #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE) |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 750 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 751 | |
Yong Zhao | 923c087 | 2019-09-27 23:30:05 -0400 | [diff] [blame] | 752 | adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET; |
| 753 | adev->rmmio_remap.bus_addr = adev->rmmio_base + MMIO_REG_HOLE_OFFSET; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 754 | adev->smc_rreg = NULL; |
| 755 | adev->smc_wreg = NULL; |
| 756 | adev->pcie_rreg = &nv_pcie_rreg; |
| 757 | adev->pcie_wreg = &nv_pcie_wreg; |
John Clements | 4922f1bc | 2020-07-22 09:40:11 +0800 | [diff] [blame] | 758 | adev->pcie_rreg64 = &nv_pcie_rreg64; |
| 759 | adev->pcie_wreg64 = &nv_pcie_wreg64; |
Huang Rui | 5de5434 | 2020-08-27 12:01:26 -0400 | [diff] [blame] | 760 | adev->pciep_rreg = &nv_pcie_port_rreg; |
| 761 | adev->pciep_wreg = &nv_pcie_port_wreg; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 762 | |
| 763 | /* TODO: will add them during VCN v2 implementation */ |
| 764 | adev->uvd_ctx_rreg = NULL; |
| 765 | adev->uvd_ctx_wreg = NULL; |
| 766 | |
| 767 | adev->didt_rreg = &nv_didt_rreg; |
| 768 | adev->didt_wreg = &nv_didt_wreg; |
| 769 | |
| 770 | adev->asic_funcs = &nv_asic_funcs; |
| 771 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 772 | adev->rev_id = nv_get_rev_id(adev); |
| 773 | adev->external_rev_id = 0xff; |
| 774 | switch (adev->asic_type) { |
| 775 | case CHIP_NAVI10: |
| 776 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 777 | AMD_CG_SUPPORT_GFX_CGCG | |
| 778 | AMD_CG_SUPPORT_IH_CG | |
| 779 | AMD_CG_SUPPORT_HDP_MGCG | |
| 780 | AMD_CG_SUPPORT_HDP_LS | |
| 781 | AMD_CG_SUPPORT_SDMA_MGCG | |
| 782 | AMD_CG_SUPPORT_SDMA_LS | |
| 783 | AMD_CG_SUPPORT_MC_MGCG | |
| 784 | AMD_CG_SUPPORT_MC_LS | |
| 785 | AMD_CG_SUPPORT_ATHUB_MGCG | |
| 786 | AMD_CG_SUPPORT_ATHUB_LS | |
| 787 | AMD_CG_SUPPORT_VCN_MGCG | |
Leo Liu | 099d66e | 2019-11-11 15:09:25 -0500 | [diff] [blame] | 788 | AMD_CG_SUPPORT_JPEG_MGCG | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 789 | AMD_CG_SUPPORT_BIF_MGCG | |
| 790 | AMD_CG_SUPPORT_BIF_LS; |
Leo Liu | 157710e | 2019-05-15 13:58:20 -0400 | [diff] [blame] | 791 | adev->pg_flags = AMD_PG_SUPPORT_VCN | |
Huang Rui | c12d410 | 2019-06-14 16:12:51 +0800 | [diff] [blame] | 792 | AMD_PG_SUPPORT_VCN_DPG | |
Leo Liu | 099d66e | 2019-11-11 15:09:25 -0500 | [diff] [blame] | 793 | AMD_PG_SUPPORT_JPEG | |
Huang Rui | a201b6a | 2019-06-14 16:19:36 +0800 | [diff] [blame] | 794 | AMD_PG_SUPPORT_ATHUB; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 795 | adev->external_rev_id = adev->rev_id + 0x1; |
| 796 | break; |
Xiaojie Yuan | 5e71e01 | 2018-12-17 18:23:27 +0800 | [diff] [blame] | 797 | case CHIP_NAVI14: |
Xiaojie Yuan | d0c39f8 | 2019-03-20 16:12:54 +0800 | [diff] [blame] | 798 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
| 799 | AMD_CG_SUPPORT_GFX_CGCG | |
| 800 | AMD_CG_SUPPORT_IH_CG | |
| 801 | AMD_CG_SUPPORT_HDP_MGCG | |
| 802 | AMD_CG_SUPPORT_HDP_LS | |
| 803 | AMD_CG_SUPPORT_SDMA_MGCG | |
| 804 | AMD_CG_SUPPORT_SDMA_LS | |
| 805 | AMD_CG_SUPPORT_MC_MGCG | |
| 806 | AMD_CG_SUPPORT_MC_LS | |
| 807 | AMD_CG_SUPPORT_ATHUB_MGCG | |
| 808 | AMD_CG_SUPPORT_ATHUB_LS | |
| 809 | AMD_CG_SUPPORT_VCN_MGCG | |
Leo Liu | 099d66e | 2019-11-11 15:09:25 -0500 | [diff] [blame] | 810 | AMD_CG_SUPPORT_JPEG_MGCG | |
Xiaojie Yuan | d0c39f8 | 2019-03-20 16:12:54 +0800 | [diff] [blame] | 811 | AMD_CG_SUPPORT_BIF_MGCG | |
| 812 | AMD_CG_SUPPORT_BIF_LS; |
Xiaojie Yuan | 0377b08 | 2019-07-02 12:52:52 -0500 | [diff] [blame] | 813 | adev->pg_flags = AMD_PG_SUPPORT_VCN | |
Leo Liu | 099d66e | 2019-11-11 15:09:25 -0500 | [diff] [blame] | 814 | AMD_PG_SUPPORT_JPEG | |
Xiaojie Yuan | 0377b08 | 2019-07-02 12:52:52 -0500 | [diff] [blame] | 815 | AMD_PG_SUPPORT_VCN_DPG; |
tiancyin | 35ef88f | 2019-08-05 17:32:45 +0800 | [diff] [blame] | 816 | adev->external_rev_id = adev->rev_id + 20; |
Xiaojie Yuan | 5e71e01 | 2018-12-17 18:23:27 +0800 | [diff] [blame] | 817 | break; |
Xiaojie Yuan | 74b5e50 | 2019-05-16 19:47:33 +0800 | [diff] [blame] | 818 | case CHIP_NAVI12: |
Xiaojie Yuan | dca009e | 2019-07-30 11:28:20 +0800 | [diff] [blame] | 819 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
| 820 | AMD_CG_SUPPORT_GFX_MGLS | |
| 821 | AMD_CG_SUPPORT_GFX_CGCG | |
| 822 | AMD_CG_SUPPORT_GFX_CP_LS | |
Xiaojie Yuan | 5211c37 | 2019-08-01 15:00:28 +0800 | [diff] [blame] | 823 | AMD_CG_SUPPORT_GFX_RLC_LS | |
Xiaojie Yuan | fbe0bc5 | 2019-08-01 15:01:23 +0800 | [diff] [blame] | 824 | AMD_CG_SUPPORT_IH_CG | |
Xiaojie Yuan | 5211c37 | 2019-08-01 15:00:28 +0800 | [diff] [blame] | 825 | AMD_CG_SUPPORT_HDP_MGCG | |
Xiaojie Yuan | 358ab97 | 2019-07-30 12:18:55 +0800 | [diff] [blame] | 826 | AMD_CG_SUPPORT_HDP_LS | |
| 827 | AMD_CG_SUPPORT_SDMA_MGCG | |
Xiaojie Yuan | 8b797b3 | 2019-08-01 15:39:59 +0800 | [diff] [blame] | 828 | AMD_CG_SUPPORT_SDMA_LS | |
| 829 | AMD_CG_SUPPORT_MC_MGCG | |
Xiaojie Yuan | ca51678 | 2019-08-01 15:19:10 +0800 | [diff] [blame] | 830 | AMD_CG_SUPPORT_MC_LS | |
| 831 | AMD_CG_SUPPORT_ATHUB_MGCG | |
Xiaojie Yuan | 65872e5 | 2019-08-01 15:22:59 +0800 | [diff] [blame] | 832 | AMD_CG_SUPPORT_ATHUB_LS | |
Leo Liu | 099d66e | 2019-11-11 15:09:25 -0500 | [diff] [blame] | 833 | AMD_CG_SUPPORT_VCN_MGCG | |
| 834 | AMD_CG_SUPPORT_JPEG_MGCG; |
Xiaojie Yuan | c1653ea | 2019-08-27 11:05:23 +0800 | [diff] [blame] | 835 | adev->pg_flags = AMD_PG_SUPPORT_VCN | |
Xiaojie Yuan | 5ef3b8a | 2019-08-27 11:06:13 +0800 | [diff] [blame] | 836 | AMD_PG_SUPPORT_VCN_DPG | |
Leo Liu | 099d66e | 2019-11-11 15:09:25 -0500 | [diff] [blame] | 837 | AMD_PG_SUPPORT_JPEG | |
Likun Gao | 1b0443b | 2020-07-06 10:54:26 +0800 | [diff] [blame] | 838 | AMD_PG_SUPPORT_ATHUB; |
Tiecheng Zhou | df5e984 | 2020-01-08 13:44:29 +0800 | [diff] [blame] | 839 | /* guest vm gets 0xffffffff when reading RCC_DEV0_EPF0_STRAP0, |
| 840 | * as a consequence, the rev_id and external_rev_id are wrong. |
| 841 | * workaround it by hardcoding rev_id to 0 (default value). |
| 842 | */ |
| 843 | if (amdgpu_sriov_vf(adev)) |
| 844 | adev->rev_id = 0; |
Xiaojie Yuan | 74b5e50 | 2019-05-16 19:47:33 +0800 | [diff] [blame] | 845 | adev->external_rev_id = adev->rev_id + 0xa; |
| 846 | break; |
Likun Gao | 117910e | 2019-03-19 11:04:03 +0800 | [diff] [blame] | 847 | case CHIP_SIENNA_CICHLID: |
Likun Gao | 00194de | 2020-01-24 03:57:55 +0800 | [diff] [blame] | 848 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
| 849 | AMD_CG_SUPPORT_GFX_CGCG | |
| 850 | AMD_CG_SUPPORT_GFX_3D_CGCG | |
Likun Gao | 98f8ea2 | 2020-03-18 17:33:47 -0400 | [diff] [blame] | 851 | AMD_CG_SUPPORT_MC_MGCG | |
Likun Gao | 00194de | 2020-01-24 03:57:55 +0800 | [diff] [blame] | 852 | AMD_CG_SUPPORT_VCN_MGCG | |
Kenneth Feng | ca36461 | 2020-02-28 11:57:04 +0800 | [diff] [blame] | 853 | AMD_CG_SUPPORT_JPEG_MGCG | |
| 854 | AMD_CG_SUPPORT_HDP_MGCG | |
Kenneth Feng | 3a32c25 | 2020-02-28 14:09:31 +0800 | [diff] [blame] | 855 | AMD_CG_SUPPORT_HDP_LS | |
Kenneth Feng | bcc8367 | 2020-02-28 14:14:00 +0800 | [diff] [blame] | 856 | AMD_CG_SUPPORT_IH_CG | |
| 857 | AMD_CG_SUPPORT_MC_LS; |
Leo Liu | b467c4f | 2019-12-03 09:23:24 -0500 | [diff] [blame] | 858 | adev->pg_flags = AMD_PG_SUPPORT_VCN | |
Boyuan Zhang | d00b0fa | 2020-04-02 13:28:07 -0400 | [diff] [blame] | 859 | AMD_PG_SUPPORT_VCN_DPG | |
Kenneth Feng | b794616 | 2020-03-26 12:01:15 +0800 | [diff] [blame] | 860 | AMD_PG_SUPPORT_JPEG | |
Likun Gao | 1b0443b | 2020-07-06 10:54:26 +0800 | [diff] [blame] | 861 | AMD_PG_SUPPORT_ATHUB | |
| 862 | AMD_PG_SUPPORT_MMHUB; |
Jack Zhang | c45fbe1 | 2020-06-23 19:36:24 +0800 | [diff] [blame] | 863 | if (amdgpu_sriov_vf(adev)) { |
| 864 | /* hypervisor control CG and PG enablement */ |
| 865 | adev->cg_flags = 0; |
| 866 | adev->pg_flags = 0; |
| 867 | } |
Likun Gao | 117910e | 2019-03-19 11:04:03 +0800 | [diff] [blame] | 868 | adev->external_rev_id = adev->rev_id + 0x28; |
| 869 | break; |
Jiansong Chen | 543aa25 | 2020-02-10 17:00:28 +0800 | [diff] [blame] | 870 | case CHIP_NAVY_FLOUNDER: |
Jiansong Chen | 40582e6 | 2020-07-02 15:34:37 +0800 | [diff] [blame] | 871 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
| 872 | AMD_CG_SUPPORT_GFX_CGCG | |
| 873 | AMD_CG_SUPPORT_GFX_3D_CGCG | |
| 874 | AMD_CG_SUPPORT_VCN_MGCG | |
Jiansong Chen | 92c7375 | 2020-07-08 18:53:36 +0800 | [diff] [blame] | 875 | AMD_CG_SUPPORT_JPEG_MGCG | |
| 876 | AMD_CG_SUPPORT_MC_MGCG | |
Jiansong Chen | 4759f88 | 2020-07-08 18:59:11 +0800 | [diff] [blame] | 877 | AMD_CG_SUPPORT_MC_LS | |
| 878 | AMD_CG_SUPPORT_HDP_MGCG | |
Jiansong Chen | 85e7151 | 2020-07-08 19:02:14 +0800 | [diff] [blame] | 879 | AMD_CG_SUPPORT_HDP_LS | |
| 880 | AMD_CG_SUPPORT_IH_CG; |
Boyuan Zhang | c6e9dd0 | 2020-07-01 17:59:51 -0400 | [diff] [blame] | 881 | adev->pg_flags = AMD_PG_SUPPORT_VCN | |
Boyuan Zhang | 00740df | 2020-07-01 18:02:32 -0400 | [diff] [blame] | 882 | AMD_PG_SUPPORT_VCN_DPG | |
Jiansong Chen | 47fc894 | 2020-07-08 18:42:04 +0800 | [diff] [blame] | 883 | AMD_PG_SUPPORT_JPEG | |
| 884 | AMD_PG_SUPPORT_ATHUB | |
| 885 | AMD_PG_SUPPORT_MMHUB; |
Jiansong Chen | 543aa25 | 2020-02-10 17:00:28 +0800 | [diff] [blame] | 886 | adev->external_rev_id = adev->rev_id + 0x32; |
| 887 | break; |
| 888 | |
Huang Rui | 026570e | 2020-08-27 10:46:19 -0400 | [diff] [blame] | 889 | case CHIP_VANGOGH: |
Huang Rui | ac0dc4c | 2020-09-22 19:08:31 +0800 | [diff] [blame] | 890 | adev->cg_flags = AMD_CG_SUPPORT_GFX_CGCG | |
| 891 | AMD_CG_SUPPORT_GFX_CGLS | |
| 892 | AMD_CG_SUPPORT_GFX_3D_CGCG | |
| 893 | AMD_CG_SUPPORT_GFX_3D_CGLS; |
| 894 | adev->pg_flags = AMD_PG_SUPPORT_GFX_PG; |
Huang Rui | 026570e | 2020-08-27 10:46:19 -0400 | [diff] [blame] | 895 | adev->external_rev_id = adev->rev_id + 0x01; |
| 896 | break; |
Tao Zhou | 550c58e | 2020-10-02 11:30:54 -0400 | [diff] [blame] | 897 | case CHIP_DIMGREY_CAVEFISH: |
| 898 | adev->cg_flags = 0; |
| 899 | adev->pg_flags = 0; |
| 900 | adev->external_rev_id = adev->rev_id + 0x3c; |
| 901 | break; |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 902 | default: |
| 903 | /* FIXME: not supported yet */ |
| 904 | return -EINVAL; |
| 905 | } |
| 906 | |
Jiange Zhao | b05b690 | 2019-09-11 17:29:07 +0800 | [diff] [blame] | 907 | if (amdgpu_sriov_vf(adev)) { |
| 908 | amdgpu_virt_init_setting(adev); |
| 909 | xgpu_nv_mailbox_set_irq_funcs(adev); |
| 910 | } |
| 911 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 912 | return 0; |
| 913 | } |
| 914 | |
| 915 | static int nv_common_late_init(void *handle) |
| 916 | { |
Jiange Zhao | b05b690 | 2019-09-11 17:29:07 +0800 | [diff] [blame] | 917 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 918 | |
| 919 | if (amdgpu_sriov_vf(adev)) |
| 920 | xgpu_nv_mailbox_get_irq(adev); |
| 921 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 922 | return 0; |
| 923 | } |
| 924 | |
| 925 | static int nv_common_sw_init(void *handle) |
| 926 | { |
Jiange Zhao | b05b690 | 2019-09-11 17:29:07 +0800 | [diff] [blame] | 927 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 928 | |
| 929 | if (amdgpu_sriov_vf(adev)) |
| 930 | xgpu_nv_mailbox_add_irq_id(adev); |
| 931 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 932 | return 0; |
| 933 | } |
| 934 | |
| 935 | static int nv_common_sw_fini(void *handle) |
| 936 | { |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | static int nv_common_hw_init(void *handle) |
| 941 | { |
| 942 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 943 | |
| 944 | /* enable pcie gen2/3 link */ |
| 945 | nv_pcie_gen3_enable(adev); |
| 946 | /* enable aspm */ |
| 947 | nv_program_aspm(adev); |
| 948 | /* setup nbio registers */ |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 949 | adev->nbio.funcs->init_registers(adev); |
Yong Zhao | 923c087 | 2019-09-27 23:30:05 -0400 | [diff] [blame] | 950 | /* remap HDP registers to a hole in mmio space, |
| 951 | * for the purpose of expose those registers |
| 952 | * to process space |
| 953 | */ |
| 954 | if (adev->nbio.funcs->remap_hdp_registers) |
| 955 | adev->nbio.funcs->remap_hdp_registers(adev); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 956 | /* enable the doorbell aperture */ |
| 957 | nv_enable_doorbell_aperture(adev, true); |
| 958 | |
| 959 | return 0; |
| 960 | } |
| 961 | |
| 962 | static int nv_common_hw_fini(void *handle) |
| 963 | { |
| 964 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 965 | |
| 966 | /* disable the doorbell aperture */ |
| 967 | nv_enable_doorbell_aperture(adev, false); |
| 968 | |
| 969 | return 0; |
| 970 | } |
| 971 | |
| 972 | static int nv_common_suspend(void *handle) |
| 973 | { |
| 974 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 975 | |
| 976 | return nv_common_hw_fini(adev); |
| 977 | } |
| 978 | |
| 979 | static int nv_common_resume(void *handle) |
| 980 | { |
| 981 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 982 | |
| 983 | return nv_common_hw_init(adev); |
| 984 | } |
| 985 | |
| 986 | static bool nv_common_is_idle(void *handle) |
| 987 | { |
| 988 | return true; |
| 989 | } |
| 990 | |
| 991 | static int nv_common_wait_for_idle(void *handle) |
| 992 | { |
| 993 | return 0; |
| 994 | } |
| 995 | |
| 996 | static int nv_common_soft_reset(void *handle) |
| 997 | { |
| 998 | return 0; |
| 999 | } |
| 1000 | |
| 1001 | static void nv_update_hdp_mem_power_gating(struct amdgpu_device *adev, |
| 1002 | bool enable) |
| 1003 | { |
| 1004 | uint32_t hdp_clk_cntl, hdp_clk_cntl1; |
| 1005 | uint32_t hdp_mem_pwr_cntl; |
| 1006 | |
| 1007 | if (!(adev->cg_flags & (AMD_CG_SUPPORT_HDP_LS | |
| 1008 | AMD_CG_SUPPORT_HDP_DS | |
| 1009 | AMD_CG_SUPPORT_HDP_SD))) |
| 1010 | return; |
| 1011 | |
| 1012 | hdp_clk_cntl = hdp_clk_cntl1 = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL); |
| 1013 | hdp_mem_pwr_cntl = RREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL); |
| 1014 | |
| 1015 | /* Before doing clock/power mode switch, |
| 1016 | * forced on IPH & RC clock */ |
| 1017 | hdp_clk_cntl = REG_SET_FIELD(hdp_clk_cntl, HDP_CLK_CNTL, |
| 1018 | IPH_MEM_CLK_SOFT_OVERRIDE, 1); |
| 1019 | hdp_clk_cntl = REG_SET_FIELD(hdp_clk_cntl, HDP_CLK_CNTL, |
| 1020 | RC_MEM_CLK_SOFT_OVERRIDE, 1); |
| 1021 | WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl); |
| 1022 | |
| 1023 | /* HDP 5.0 doesn't support dynamic power mode switch, |
| 1024 | * disable clock and power gating before any changing */ |
| 1025 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1026 | IPH_MEM_POWER_CTRL_EN, 0); |
| 1027 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1028 | IPH_MEM_POWER_LS_EN, 0); |
| 1029 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1030 | IPH_MEM_POWER_DS_EN, 0); |
| 1031 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1032 | IPH_MEM_POWER_SD_EN, 0); |
| 1033 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1034 | RC_MEM_POWER_CTRL_EN, 0); |
| 1035 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1036 | RC_MEM_POWER_LS_EN, 0); |
| 1037 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1038 | RC_MEM_POWER_DS_EN, 0); |
| 1039 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1040 | RC_MEM_POWER_SD_EN, 0); |
| 1041 | WREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL, hdp_mem_pwr_cntl); |
| 1042 | |
| 1043 | /* only one clock gating mode (LS/DS/SD) can be enabled */ |
| 1044 | if (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS) { |
| 1045 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, |
| 1046 | HDP_MEM_POWER_CTRL, |
| 1047 | IPH_MEM_POWER_LS_EN, enable); |
| 1048 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, |
| 1049 | HDP_MEM_POWER_CTRL, |
| 1050 | RC_MEM_POWER_LS_EN, enable); |
| 1051 | } else if (adev->cg_flags & AMD_CG_SUPPORT_HDP_DS) { |
| 1052 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, |
| 1053 | HDP_MEM_POWER_CTRL, |
| 1054 | IPH_MEM_POWER_DS_EN, enable); |
| 1055 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, |
| 1056 | HDP_MEM_POWER_CTRL, |
| 1057 | RC_MEM_POWER_DS_EN, enable); |
| 1058 | } else if (adev->cg_flags & AMD_CG_SUPPORT_HDP_SD) { |
| 1059 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, |
| 1060 | HDP_MEM_POWER_CTRL, |
| 1061 | IPH_MEM_POWER_SD_EN, enable); |
| 1062 | /* RC should not use shut down mode, fallback to ds */ |
| 1063 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, |
| 1064 | HDP_MEM_POWER_CTRL, |
| 1065 | RC_MEM_POWER_DS_EN, enable); |
| 1066 | } |
| 1067 | |
Kenneth Feng | 91c6adf | 2020-02-28 11:57:04 +0800 | [diff] [blame] | 1068 | /* confirmed that IPH_MEM_POWER_CTRL_EN and RC_MEM_POWER_CTRL_EN have to |
| 1069 | * be set for SRAM LS/DS/SD */ |
| 1070 | if (adev->cg_flags & (AMD_CG_SUPPORT_HDP_LS | AMD_CG_SUPPORT_HDP_DS | |
| 1071 | AMD_CG_SUPPORT_HDP_SD)) { |
| 1072 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1073 | IPH_MEM_POWER_CTRL_EN, 1); |
| 1074 | hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL, |
| 1075 | RC_MEM_POWER_CTRL_EN, 1); |
| 1076 | } |
| 1077 | |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 1078 | WREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL, hdp_mem_pwr_cntl); |
| 1079 | |
| 1080 | /* restore IPH & RC clock override after clock/power mode changing */ |
| 1081 | WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl1); |
| 1082 | } |
| 1083 | |
| 1084 | static void nv_update_hdp_clock_gating(struct amdgpu_device *adev, |
| 1085 | bool enable) |
| 1086 | { |
| 1087 | uint32_t hdp_clk_cntl; |
| 1088 | |
| 1089 | if (!(adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG)) |
| 1090 | return; |
| 1091 | |
| 1092 | hdp_clk_cntl = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL); |
| 1093 | |
| 1094 | if (enable) { |
| 1095 | hdp_clk_cntl &= |
| 1096 | ~(uint32_t) |
| 1097 | (HDP_CLK_CNTL__IPH_MEM_CLK_SOFT_OVERRIDE_MASK | |
| 1098 | HDP_CLK_CNTL__RC_MEM_CLK_SOFT_OVERRIDE_MASK | |
| 1099 | HDP_CLK_CNTL__DBUS_CLK_SOFT_OVERRIDE_MASK | |
| 1100 | HDP_CLK_CNTL__DYN_CLK_SOFT_OVERRIDE_MASK | |
| 1101 | HDP_CLK_CNTL__XDP_REG_CLK_SOFT_OVERRIDE_MASK | |
| 1102 | HDP_CLK_CNTL__HDP_REG_CLK_SOFT_OVERRIDE_MASK); |
| 1103 | } else { |
| 1104 | hdp_clk_cntl |= HDP_CLK_CNTL__IPH_MEM_CLK_SOFT_OVERRIDE_MASK | |
| 1105 | HDP_CLK_CNTL__RC_MEM_CLK_SOFT_OVERRIDE_MASK | |
| 1106 | HDP_CLK_CNTL__DBUS_CLK_SOFT_OVERRIDE_MASK | |
| 1107 | HDP_CLK_CNTL__DYN_CLK_SOFT_OVERRIDE_MASK | |
| 1108 | HDP_CLK_CNTL__XDP_REG_CLK_SOFT_OVERRIDE_MASK | |
| 1109 | HDP_CLK_CNTL__HDP_REG_CLK_SOFT_OVERRIDE_MASK; |
| 1110 | } |
| 1111 | |
| 1112 | WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl); |
| 1113 | } |
| 1114 | |
| 1115 | static int nv_common_set_clockgating_state(void *handle, |
| 1116 | enum amd_clockgating_state state) |
| 1117 | { |
| 1118 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1119 | |
| 1120 | if (amdgpu_sriov_vf(adev)) |
| 1121 | return 0; |
| 1122 | |
| 1123 | switch (adev->asic_type) { |
| 1124 | case CHIP_NAVI10: |
Xiaojie Yuan | 5e71e01 | 2018-12-17 18:23:27 +0800 | [diff] [blame] | 1125 | case CHIP_NAVI14: |
Xiaojie Yuan | 7e17e58 | 2019-05-16 19:51:12 +0800 | [diff] [blame] | 1126 | case CHIP_NAVI12: |
Likun Gao | 117910e | 2019-03-19 11:04:03 +0800 | [diff] [blame] | 1127 | case CHIP_SIENNA_CICHLID: |
Jiansong Chen | 543aa25 | 2020-02-10 17:00:28 +0800 | [diff] [blame] | 1128 | case CHIP_NAVY_FLOUNDER: |
Tao Zhou | 550c58e | 2020-10-02 11:30:54 -0400 | [diff] [blame] | 1129 | case CHIP_DIMGREY_CAVEFISH: |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 1130 | adev->nbio.funcs->update_medium_grain_clock_gating(adev, |
Nirmoy Das | a9d4fe2 | 2020-01-20 13:54:30 +0100 | [diff] [blame] | 1131 | state == AMD_CG_STATE_GATE); |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 1132 | adev->nbio.funcs->update_medium_grain_light_sleep(adev, |
Nirmoy Das | a9d4fe2 | 2020-01-20 13:54:30 +0100 | [diff] [blame] | 1133 | state == AMD_CG_STATE_GATE); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 1134 | nv_update_hdp_mem_power_gating(adev, |
Nirmoy Das | a9d4fe2 | 2020-01-20 13:54:30 +0100 | [diff] [blame] | 1135 | state == AMD_CG_STATE_GATE); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 1136 | nv_update_hdp_clock_gating(adev, |
Nirmoy Das | a9d4fe2 | 2020-01-20 13:54:30 +0100 | [diff] [blame] | 1137 | state == AMD_CG_STATE_GATE); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 1138 | break; |
| 1139 | default: |
| 1140 | break; |
| 1141 | } |
| 1142 | return 0; |
| 1143 | } |
| 1144 | |
| 1145 | static int nv_common_set_powergating_state(void *handle, |
| 1146 | enum amd_powergating_state state) |
| 1147 | { |
| 1148 | /* TODO */ |
| 1149 | return 0; |
| 1150 | } |
| 1151 | |
| 1152 | static void nv_common_get_clockgating_state(void *handle, u32 *flags) |
| 1153 | { |
| 1154 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1155 | uint32_t tmp; |
| 1156 | |
| 1157 | if (amdgpu_sriov_vf(adev)) |
| 1158 | *flags = 0; |
| 1159 | |
Hawking Zhang | bebc076 | 2019-08-23 19:39:18 +0800 | [diff] [blame] | 1160 | adev->nbio.funcs->get_clockgating_state(adev, flags); |
Hawking Zhang | c6b6a42 | 2019-03-04 14:07:37 +0800 | [diff] [blame] | 1161 | |
| 1162 | /* AMD_CG_SUPPORT_HDP_MGCG */ |
| 1163 | tmp = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL); |
| 1164 | if (!(tmp & (HDP_CLK_CNTL__IPH_MEM_CLK_SOFT_OVERRIDE_MASK | |
| 1165 | HDP_CLK_CNTL__RC_MEM_CLK_SOFT_OVERRIDE_MASK | |
| 1166 | HDP_CLK_CNTL__DBUS_CLK_SOFT_OVERRIDE_MASK | |
| 1167 | HDP_CLK_CNTL__DYN_CLK_SOFT_OVERRIDE_MASK | |
| 1168 | HDP_CLK_CNTL__XDP_REG_CLK_SOFT_OVERRIDE_MASK | |
| 1169 | HDP_CLK_CNTL__HDP_REG_CLK_SOFT_OVERRIDE_MASK))) |
| 1170 | *flags |= AMD_CG_SUPPORT_HDP_MGCG; |
| 1171 | |
| 1172 | /* AMD_CG_SUPPORT_HDP_LS/DS/SD */ |
| 1173 | tmp = RREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL); |
| 1174 | if (tmp & HDP_MEM_POWER_CTRL__IPH_MEM_POWER_LS_EN_MASK) |
| 1175 | *flags |= AMD_CG_SUPPORT_HDP_LS; |
| 1176 | else if (tmp & HDP_MEM_POWER_CTRL__IPH_MEM_POWER_DS_EN_MASK) |
| 1177 | *flags |= AMD_CG_SUPPORT_HDP_DS; |
| 1178 | else if (tmp & HDP_MEM_POWER_CTRL__IPH_MEM_POWER_SD_EN_MASK) |
| 1179 | *flags |= AMD_CG_SUPPORT_HDP_SD; |
| 1180 | |
| 1181 | return; |
| 1182 | } |
| 1183 | |
| 1184 | static const struct amd_ip_funcs nv_common_ip_funcs = { |
| 1185 | .name = "nv_common", |
| 1186 | .early_init = nv_common_early_init, |
| 1187 | .late_init = nv_common_late_init, |
| 1188 | .sw_init = nv_common_sw_init, |
| 1189 | .sw_fini = nv_common_sw_fini, |
| 1190 | .hw_init = nv_common_hw_init, |
| 1191 | .hw_fini = nv_common_hw_fini, |
| 1192 | .suspend = nv_common_suspend, |
| 1193 | .resume = nv_common_resume, |
| 1194 | .is_idle = nv_common_is_idle, |
| 1195 | .wait_for_idle = nv_common_wait_for_idle, |
| 1196 | .soft_reset = nv_common_soft_reset, |
| 1197 | .set_clockgating_state = nv_common_set_clockgating_state, |
| 1198 | .set_powergating_state = nv_common_set_powergating_state, |
| 1199 | .get_clockgating_state = nv_common_get_clockgating_state, |
| 1200 | }; |