Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Advanced Micro Devices, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | */ |
| 23 | #include <linux/firmware.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/module.h> |
| 26 | #include "drmP.h" |
| 27 | #include "amdgpu.h" |
| 28 | #include "amdgpu_atombios.h" |
| 29 | #include "amdgpu_ih.h" |
| 30 | #include "amdgpu_uvd.h" |
| 31 | #include "amdgpu_vce.h" |
| 32 | #include "amdgpu_ucode.h" |
| 33 | #include "atom.h" |
Alex Deucher | d0dd7f0 | 2015-11-11 19:45:06 -0500 | [diff] [blame] | 34 | #include "amd_pcie.h" |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 35 | |
| 36 | #include "gmc/gmc_8_1_d.h" |
| 37 | #include "gmc/gmc_8_1_sh_mask.h" |
| 38 | |
| 39 | #include "oss/oss_3_0_d.h" |
| 40 | #include "oss/oss_3_0_sh_mask.h" |
| 41 | |
| 42 | #include "bif/bif_5_0_d.h" |
| 43 | #include "bif/bif_5_0_sh_mask.h" |
| 44 | |
| 45 | #include "gca/gfx_8_0_d.h" |
| 46 | #include "gca/gfx_8_0_sh_mask.h" |
| 47 | |
| 48 | #include "smu/smu_7_1_1_d.h" |
| 49 | #include "smu/smu_7_1_1_sh_mask.h" |
| 50 | |
| 51 | #include "uvd/uvd_5_0_d.h" |
| 52 | #include "uvd/uvd_5_0_sh_mask.h" |
| 53 | |
| 54 | #include "vce/vce_3_0_d.h" |
| 55 | #include "vce/vce_3_0_sh_mask.h" |
| 56 | |
| 57 | #include "dce/dce_10_0_d.h" |
| 58 | #include "dce/dce_10_0_sh_mask.h" |
| 59 | |
| 60 | #include "vid.h" |
| 61 | #include "vi.h" |
| 62 | #include "vi_dpm.h" |
| 63 | #include "gmc_v8_0.h" |
Ken Wang | 429c45d | 2016-02-03 19:16:54 +0800 | [diff] [blame] | 64 | #include "gmc_v7_0.h" |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 65 | #include "gfx_v8_0.h" |
| 66 | #include "sdma_v2_4.h" |
| 67 | #include "sdma_v3_0.h" |
| 68 | #include "dce_v10_0.h" |
| 69 | #include "dce_v11_0.h" |
| 70 | #include "iceland_ih.h" |
| 71 | #include "tonga_ih.h" |
| 72 | #include "cz_ih.h" |
| 73 | #include "uvd_v5_0.h" |
| 74 | #include "uvd_v6_0.h" |
| 75 | #include "vce_v3_0.h" |
Alex Deucher | 1f7371b | 2015-12-02 17:46:21 -0500 | [diff] [blame] | 76 | #include "amdgpu_powerplay.h" |
Maruthi Bayyavarapu | a8fe58c | 2015-09-22 17:05:20 -0400 | [diff] [blame] | 77 | #if defined(CONFIG_DRM_AMD_ACP) |
| 78 | #include "amdgpu_acp.h" |
| 79 | #endif |
Emily Deng | e9ed3a6 | 2016-08-08 11:36:45 +0800 | [diff] [blame] | 80 | #include "dce_virtual.h" |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 81 | |
Rex Zhu | 9487dd1 | 2016-09-19 15:44:50 +0800 | [diff] [blame] | 82 | MODULE_FIRMWARE("amdgpu/topaz_smc.bin"); |
| 83 | MODULE_FIRMWARE("amdgpu/tonga_smc.bin"); |
| 84 | MODULE_FIRMWARE("amdgpu/fiji_smc.bin"); |
Flora Cui | f895106 | 2016-03-18 19:07:55 +0800 | [diff] [blame] | 85 | MODULE_FIRMWARE("amdgpu/polaris10_smc.bin"); |
| 86 | MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin"); |
| 87 | MODULE_FIRMWARE("amdgpu/polaris11_smc.bin"); |
| 88 | MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin"); |
| 89 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 90 | /* |
| 91 | * Indirect registers accessor |
| 92 | */ |
| 93 | static u32 vi_pcie_rreg(struct amdgpu_device *adev, u32 reg) |
| 94 | { |
| 95 | unsigned long flags; |
| 96 | u32 r; |
| 97 | |
| 98 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); |
| 99 | WREG32(mmPCIE_INDEX, reg); |
| 100 | (void)RREG32(mmPCIE_INDEX); |
| 101 | r = RREG32(mmPCIE_DATA); |
| 102 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); |
| 103 | return r; |
| 104 | } |
| 105 | |
| 106 | static void vi_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 107 | { |
| 108 | unsigned long flags; |
| 109 | |
| 110 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); |
| 111 | WREG32(mmPCIE_INDEX, reg); |
| 112 | (void)RREG32(mmPCIE_INDEX); |
| 113 | WREG32(mmPCIE_DATA, v); |
| 114 | (void)RREG32(mmPCIE_DATA); |
| 115 | spin_unlock_irqrestore(&adev->pcie_idx_lock, flags); |
| 116 | } |
| 117 | |
| 118 | static u32 vi_smc_rreg(struct amdgpu_device *adev, u32 reg) |
| 119 | { |
| 120 | unsigned long flags; |
| 121 | u32 r; |
| 122 | |
| 123 | spin_lock_irqsave(&adev->smc_idx_lock, flags); |
Monk Liu | 4bc10d1 | 2016-03-29 11:01:51 +0800 | [diff] [blame] | 124 | WREG32(mmSMC_IND_INDEX_11, (reg)); |
| 125 | r = RREG32(mmSMC_IND_DATA_11); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 126 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); |
| 127 | return r; |
| 128 | } |
| 129 | |
| 130 | static void vi_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 131 | { |
| 132 | unsigned long flags; |
| 133 | |
| 134 | spin_lock_irqsave(&adev->smc_idx_lock, flags); |
Monk Liu | 4bc10d1 | 2016-03-29 11:01:51 +0800 | [diff] [blame] | 135 | WREG32(mmSMC_IND_INDEX_11, (reg)); |
| 136 | WREG32(mmSMC_IND_DATA_11, (v)); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 137 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); |
| 138 | } |
| 139 | |
Alex Deucher | 7b92cdb | 2015-07-10 16:21:10 -0400 | [diff] [blame] | 140 | /* smu_8_0_d.h */ |
| 141 | #define mmMP0PUB_IND_INDEX 0x180 |
| 142 | #define mmMP0PUB_IND_DATA 0x181 |
| 143 | |
| 144 | static u32 cz_smc_rreg(struct amdgpu_device *adev, u32 reg) |
| 145 | { |
| 146 | unsigned long flags; |
| 147 | u32 r; |
| 148 | |
| 149 | spin_lock_irqsave(&adev->smc_idx_lock, flags); |
| 150 | WREG32(mmMP0PUB_IND_INDEX, (reg)); |
| 151 | r = RREG32(mmMP0PUB_IND_DATA); |
| 152 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); |
| 153 | return r; |
| 154 | } |
| 155 | |
| 156 | static void cz_smc_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 157 | { |
| 158 | unsigned long flags; |
| 159 | |
| 160 | spin_lock_irqsave(&adev->smc_idx_lock, flags); |
| 161 | WREG32(mmMP0PUB_IND_INDEX, (reg)); |
| 162 | WREG32(mmMP0PUB_IND_DATA, (v)); |
| 163 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); |
| 164 | } |
| 165 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 166 | static u32 vi_uvd_ctx_rreg(struct amdgpu_device *adev, u32 reg) |
| 167 | { |
| 168 | unsigned long flags; |
| 169 | u32 r; |
| 170 | |
| 171 | spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags); |
| 172 | WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff)); |
| 173 | r = RREG32(mmUVD_CTX_DATA); |
| 174 | spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags); |
| 175 | return r; |
| 176 | } |
| 177 | |
| 178 | static void vi_uvd_ctx_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 179 | { |
| 180 | unsigned long flags; |
| 181 | |
| 182 | spin_lock_irqsave(&adev->uvd_ctx_idx_lock, flags); |
| 183 | WREG32(mmUVD_CTX_INDEX, ((reg) & 0x1ff)); |
| 184 | WREG32(mmUVD_CTX_DATA, (v)); |
| 185 | spin_unlock_irqrestore(&adev->uvd_ctx_idx_lock, flags); |
| 186 | } |
| 187 | |
| 188 | static u32 vi_didt_rreg(struct amdgpu_device *adev, u32 reg) |
| 189 | { |
| 190 | unsigned long flags; |
| 191 | u32 r; |
| 192 | |
| 193 | spin_lock_irqsave(&adev->didt_idx_lock, flags); |
| 194 | WREG32(mmDIDT_IND_INDEX, (reg)); |
| 195 | r = RREG32(mmDIDT_IND_DATA); |
| 196 | spin_unlock_irqrestore(&adev->didt_idx_lock, flags); |
| 197 | return r; |
| 198 | } |
| 199 | |
| 200 | static void vi_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 201 | { |
| 202 | unsigned long flags; |
| 203 | |
| 204 | spin_lock_irqsave(&adev->didt_idx_lock, flags); |
| 205 | WREG32(mmDIDT_IND_INDEX, (reg)); |
| 206 | WREG32(mmDIDT_IND_DATA, (v)); |
| 207 | spin_unlock_irqrestore(&adev->didt_idx_lock, flags); |
| 208 | } |
| 209 | |
Rex Zhu | ccdbb20 | 2016-06-08 12:47:41 +0800 | [diff] [blame] | 210 | static u32 vi_gc_cac_rreg(struct amdgpu_device *adev, u32 reg) |
| 211 | { |
| 212 | unsigned long flags; |
| 213 | u32 r; |
| 214 | |
| 215 | spin_lock_irqsave(&adev->gc_cac_idx_lock, flags); |
| 216 | WREG32(mmGC_CAC_IND_INDEX, (reg)); |
| 217 | r = RREG32(mmGC_CAC_IND_DATA); |
| 218 | spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags); |
| 219 | return r; |
| 220 | } |
| 221 | |
| 222 | static void vi_gc_cac_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
| 223 | { |
| 224 | unsigned long flags; |
| 225 | |
| 226 | spin_lock_irqsave(&adev->gc_cac_idx_lock, flags); |
| 227 | WREG32(mmGC_CAC_IND_INDEX, (reg)); |
| 228 | WREG32(mmGC_CAC_IND_DATA, (v)); |
| 229 | spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags); |
| 230 | } |
| 231 | |
| 232 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 233 | static const u32 tonga_mgcg_cgcg_init[] = |
| 234 | { |
| 235 | mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, |
| 236 | mmPCIE_INDEX, 0xffffffff, 0x0140001c, |
| 237 | mmPCIE_DATA, 0x000f0000, 0x00000000, |
| 238 | mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, |
| 239 | mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 240 | mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, |
| 241 | mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, |
| 242 | }; |
| 243 | |
David Zhang | 48299f9 | 2015-07-08 01:05:16 +0800 | [diff] [blame] | 244 | static const u32 fiji_mgcg_cgcg_init[] = |
| 245 | { |
| 246 | mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, |
| 247 | mmPCIE_INDEX, 0xffffffff, 0x0140001c, |
| 248 | mmPCIE_DATA, 0x000f0000, 0x00000000, |
| 249 | mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, |
| 250 | mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, |
| 251 | mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, |
| 252 | mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, |
| 253 | }; |
| 254 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 255 | static const u32 iceland_mgcg_cgcg_init[] = |
| 256 | { |
| 257 | mmPCIE_INDEX, 0xffffffff, ixPCIE_CNTL2, |
| 258 | mmPCIE_DATA, 0x000f0000, 0x00000000, |
| 259 | mmSMC_IND_INDEX_4, 0xffffffff, ixCGTT_ROM_CLK_CTRL0, |
| 260 | mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, |
| 261 | mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, |
| 262 | }; |
| 263 | |
| 264 | static const u32 cz_mgcg_cgcg_init[] = |
| 265 | { |
| 266 | mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, |
| 267 | mmPCIE_INDEX, 0xffffffff, 0x0140001c, |
| 268 | mmPCIE_DATA, 0x000f0000, 0x00000000, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 269 | mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, |
| 270 | mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, |
| 271 | }; |
| 272 | |
Samuel Li | 39bb0c9 | 2015-10-08 16:31:43 -0400 | [diff] [blame] | 273 | static const u32 stoney_mgcg_cgcg_init[] = |
| 274 | { |
| 275 | mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00000100, |
| 276 | mmHDP_XDP_CGTT_BLK_CTRL, 0xffffffff, 0x00000104, |
| 277 | mmHDP_HOST_PATH_CNTL, 0xffffffff, 0x0f000027, |
| 278 | }; |
| 279 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 280 | static void vi_init_golden_registers(struct amdgpu_device *adev) |
| 281 | { |
| 282 | /* Some of the registers might be dependent on GRBM_GFX_INDEX */ |
| 283 | mutex_lock(&adev->grbm_idx_mutex); |
| 284 | |
| 285 | switch (adev->asic_type) { |
| 286 | case CHIP_TOPAZ: |
| 287 | amdgpu_program_register_sequence(adev, |
| 288 | iceland_mgcg_cgcg_init, |
| 289 | (const u32)ARRAY_SIZE(iceland_mgcg_cgcg_init)); |
| 290 | break; |
David Zhang | 48299f9 | 2015-07-08 01:05:16 +0800 | [diff] [blame] | 291 | case CHIP_FIJI: |
| 292 | amdgpu_program_register_sequence(adev, |
| 293 | fiji_mgcg_cgcg_init, |
| 294 | (const u32)ARRAY_SIZE(fiji_mgcg_cgcg_init)); |
| 295 | break; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 296 | case CHIP_TONGA: |
| 297 | amdgpu_program_register_sequence(adev, |
| 298 | tonga_mgcg_cgcg_init, |
| 299 | (const u32)ARRAY_SIZE(tonga_mgcg_cgcg_init)); |
| 300 | break; |
| 301 | case CHIP_CARRIZO: |
| 302 | amdgpu_program_register_sequence(adev, |
| 303 | cz_mgcg_cgcg_init, |
| 304 | (const u32)ARRAY_SIZE(cz_mgcg_cgcg_init)); |
| 305 | break; |
Samuel Li | 39bb0c9 | 2015-10-08 16:31:43 -0400 | [diff] [blame] | 306 | case CHIP_STONEY: |
| 307 | amdgpu_program_register_sequence(adev, |
| 308 | stoney_mgcg_cgcg_init, |
| 309 | (const u32)ARRAY_SIZE(stoney_mgcg_cgcg_init)); |
| 310 | break; |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 311 | case CHIP_POLARIS11: |
| 312 | case CHIP_POLARIS10: |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 313 | default: |
| 314 | break; |
| 315 | } |
| 316 | mutex_unlock(&adev->grbm_idx_mutex); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * vi_get_xclk - get the xclk |
| 321 | * |
| 322 | * @adev: amdgpu_device pointer |
| 323 | * |
| 324 | * Returns the reference clock used by the gfx engine |
| 325 | * (VI). |
| 326 | */ |
| 327 | static u32 vi_get_xclk(struct amdgpu_device *adev) |
| 328 | { |
| 329 | u32 reference_clock = adev->clock.spll.reference_freq; |
| 330 | u32 tmp; |
| 331 | |
Jammy Zhou | 2f7d10b | 2015-07-22 11:29:01 +0800 | [diff] [blame] | 332 | if (adev->flags & AMD_IS_APU) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 333 | return reference_clock; |
| 334 | |
| 335 | tmp = RREG32_SMC(ixCG_CLKPIN_CNTL_2); |
| 336 | if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL_2, MUX_TCLK_TO_XCLK)) |
| 337 | return 1000; |
| 338 | |
| 339 | tmp = RREG32_SMC(ixCG_CLKPIN_CNTL); |
| 340 | if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL, XTALIN_DIVIDE)) |
| 341 | return reference_clock / 4; |
| 342 | |
| 343 | return reference_clock; |
| 344 | } |
| 345 | |
| 346 | /** |
| 347 | * vi_srbm_select - select specific register instances |
| 348 | * |
| 349 | * @adev: amdgpu_device pointer |
| 350 | * @me: selected ME (micro engine) |
| 351 | * @pipe: pipe |
| 352 | * @queue: queue |
| 353 | * @vmid: VMID |
| 354 | * |
| 355 | * Switches the currently active registers instances. Some |
| 356 | * registers are instanced per VMID, others are instanced per |
| 357 | * me/pipe/queue combination. |
| 358 | */ |
| 359 | void vi_srbm_select(struct amdgpu_device *adev, |
| 360 | u32 me, u32 pipe, u32 queue, u32 vmid) |
| 361 | { |
| 362 | u32 srbm_gfx_cntl = 0; |
| 363 | srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, PIPEID, pipe); |
| 364 | srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, MEID, me); |
| 365 | srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, VMID, vmid); |
| 366 | srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, QUEUEID, queue); |
| 367 | WREG32(mmSRBM_GFX_CNTL, srbm_gfx_cntl); |
| 368 | } |
| 369 | |
| 370 | static void vi_vga_set_state(struct amdgpu_device *adev, bool state) |
| 371 | { |
| 372 | /* todo */ |
| 373 | } |
| 374 | |
| 375 | static bool vi_read_disabled_bios(struct amdgpu_device *adev) |
| 376 | { |
| 377 | u32 bus_cntl; |
| 378 | u32 d1vga_control = 0; |
| 379 | u32 d2vga_control = 0; |
| 380 | u32 vga_render_control = 0; |
| 381 | u32 rom_cntl; |
| 382 | bool r; |
| 383 | |
| 384 | bus_cntl = RREG32(mmBUS_CNTL); |
| 385 | if (adev->mode_info.num_crtc) { |
| 386 | d1vga_control = RREG32(mmD1VGA_CONTROL); |
| 387 | d2vga_control = RREG32(mmD2VGA_CONTROL); |
| 388 | vga_render_control = RREG32(mmVGA_RENDER_CONTROL); |
| 389 | } |
| 390 | rom_cntl = RREG32_SMC(ixROM_CNTL); |
| 391 | |
| 392 | /* enable the rom */ |
| 393 | WREG32(mmBUS_CNTL, (bus_cntl & ~BUS_CNTL__BIOS_ROM_DIS_MASK)); |
| 394 | if (adev->mode_info.num_crtc) { |
| 395 | /* Disable VGA mode */ |
| 396 | WREG32(mmD1VGA_CONTROL, |
| 397 | (d1vga_control & ~(D1VGA_CONTROL__D1VGA_MODE_ENABLE_MASK | |
| 398 | D1VGA_CONTROL__D1VGA_TIMING_SELECT_MASK))); |
| 399 | WREG32(mmD2VGA_CONTROL, |
| 400 | (d2vga_control & ~(D2VGA_CONTROL__D2VGA_MODE_ENABLE_MASK | |
| 401 | D2VGA_CONTROL__D2VGA_TIMING_SELECT_MASK))); |
| 402 | WREG32(mmVGA_RENDER_CONTROL, |
| 403 | (vga_render_control & ~VGA_RENDER_CONTROL__VGA_VSTATUS_CNTL_MASK)); |
| 404 | } |
| 405 | WREG32_SMC(ixROM_CNTL, rom_cntl | ROM_CNTL__SCK_OVERWRITE_MASK); |
| 406 | |
| 407 | r = amdgpu_read_bios(adev); |
| 408 | |
| 409 | /* restore regs */ |
| 410 | WREG32(mmBUS_CNTL, bus_cntl); |
| 411 | if (adev->mode_info.num_crtc) { |
| 412 | WREG32(mmD1VGA_CONTROL, d1vga_control); |
| 413 | WREG32(mmD2VGA_CONTROL, d2vga_control); |
| 414 | WREG32(mmVGA_RENDER_CONTROL, vga_render_control); |
| 415 | } |
| 416 | WREG32_SMC(ixROM_CNTL, rom_cntl); |
| 417 | return r; |
| 418 | } |
Alex Deucher | 95addb2a | 2015-11-24 10:37:54 -0500 | [diff] [blame] | 419 | |
| 420 | static bool vi_read_bios_from_rom(struct amdgpu_device *adev, |
| 421 | u8 *bios, u32 length_bytes) |
| 422 | { |
| 423 | u32 *dw_ptr; |
| 424 | unsigned long flags; |
| 425 | u32 i, length_dw; |
| 426 | |
| 427 | if (bios == NULL) |
| 428 | return false; |
| 429 | if (length_bytes == 0) |
| 430 | return false; |
| 431 | /* APU vbios image is part of sbios image */ |
| 432 | if (adev->flags & AMD_IS_APU) |
| 433 | return false; |
| 434 | |
| 435 | dw_ptr = (u32 *)bios; |
| 436 | length_dw = ALIGN(length_bytes, 4) / 4; |
| 437 | /* take the smc lock since we are using the smc index */ |
| 438 | spin_lock_irqsave(&adev->smc_idx_lock, flags); |
| 439 | /* set rom index to 0 */ |
Monk Liu | 4bc10d1 | 2016-03-29 11:01:51 +0800 | [diff] [blame] | 440 | WREG32(mmSMC_IND_INDEX_11, ixROM_INDEX); |
| 441 | WREG32(mmSMC_IND_DATA_11, 0); |
Alex Deucher | 95addb2a | 2015-11-24 10:37:54 -0500 | [diff] [blame] | 442 | /* set index to data for continous read */ |
Monk Liu | 4bc10d1 | 2016-03-29 11:01:51 +0800 | [diff] [blame] | 443 | WREG32(mmSMC_IND_INDEX_11, ixROM_DATA); |
Alex Deucher | 95addb2a | 2015-11-24 10:37:54 -0500 | [diff] [blame] | 444 | for (i = 0; i < length_dw; i++) |
Monk Liu | 4bc10d1 | 2016-03-29 11:01:51 +0800 | [diff] [blame] | 445 | dw_ptr[i] = RREG32(mmSMC_IND_DATA_11); |
Alex Deucher | 95addb2a | 2015-11-24 10:37:54 -0500 | [diff] [blame] | 446 | spin_unlock_irqrestore(&adev->smc_idx_lock, flags); |
| 447 | |
| 448 | return true; |
| 449 | } |
| 450 | |
Monk Liu | 4e99a44 | 2016-03-31 13:26:59 +0800 | [diff] [blame] | 451 | static void vi_detect_hw_virtualization(struct amdgpu_device *adev) |
Andres Rodriguez | 048765a | 2016-06-11 02:51:32 -0400 | [diff] [blame] | 452 | { |
Monk Liu | 4e99a44 | 2016-03-31 13:26:59 +0800 | [diff] [blame] | 453 | uint32_t reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER); |
| 454 | /* bit0: 0 means pf and 1 means vf */ |
| 455 | /* bit31: 0 means disable IOV and 1 means enable */ |
| 456 | if (reg & 1) |
| 457 | adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_IS_VF; |
Andres Rodriguez | 048765a | 2016-06-11 02:51:32 -0400 | [diff] [blame] | 458 | |
Monk Liu | 4e99a44 | 2016-03-31 13:26:59 +0800 | [diff] [blame] | 459 | if (reg & 0x80000000) |
| 460 | adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV; |
Andres Rodriguez | 048765a | 2016-06-11 02:51:32 -0400 | [diff] [blame] | 461 | |
Monk Liu | 4e99a44 | 2016-03-31 13:26:59 +0800 | [diff] [blame] | 462 | if (reg == 0) { |
| 463 | if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */ |
| 464 | adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; |
| 465 | } |
Andres Rodriguez | 048765a | 2016-06-11 02:51:32 -0400 | [diff] [blame] | 466 | } |
| 467 | |
Nils Wallménius | eca2240 | 2016-03-19 16:12:17 +0100 | [diff] [blame] | 468 | static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = { |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 469 | {mmGB_MACROTILE_MODE7, true}, |
| 470 | }; |
| 471 | |
Nils Wallménius | eca2240 | 2016-03-19 16:12:17 +0100 | [diff] [blame] | 472 | static const struct amdgpu_allowed_register_entry cz_allowed_read_registers[] = { |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 473 | {mmGB_TILE_MODE7, true}, |
| 474 | {mmGB_TILE_MODE12, true}, |
| 475 | {mmGB_TILE_MODE17, true}, |
| 476 | {mmGB_TILE_MODE23, true}, |
| 477 | {mmGB_MACROTILE_MODE7, true}, |
| 478 | }; |
| 479 | |
Nils Wallménius | eca2240 | 2016-03-19 16:12:17 +0100 | [diff] [blame] | 480 | static const struct amdgpu_allowed_register_entry vi_allowed_read_registers[] = { |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 481 | {mmGRBM_STATUS, false}, |
Marek Olšák | c7890fe | 2015-07-11 12:08:46 +0200 | [diff] [blame] | 482 | {mmGRBM_STATUS2, false}, |
| 483 | {mmGRBM_STATUS_SE0, false}, |
| 484 | {mmGRBM_STATUS_SE1, false}, |
| 485 | {mmGRBM_STATUS_SE2, false}, |
| 486 | {mmGRBM_STATUS_SE3, false}, |
| 487 | {mmSRBM_STATUS, false}, |
| 488 | {mmSRBM_STATUS2, false}, |
| 489 | {mmSRBM_STATUS3, false}, |
| 490 | {mmSDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET, false}, |
| 491 | {mmSDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET, false}, |
| 492 | {mmCP_STAT, false}, |
| 493 | {mmCP_STALLED_STAT1, false}, |
| 494 | {mmCP_STALLED_STAT2, false}, |
| 495 | {mmCP_STALLED_STAT3, false}, |
| 496 | {mmCP_CPF_BUSY_STAT, false}, |
| 497 | {mmCP_CPF_STALLED_STAT1, false}, |
| 498 | {mmCP_CPF_STATUS, false}, |
| 499 | {mmCP_CPC_BUSY_STAT, false}, |
| 500 | {mmCP_CPC_STALLED_STAT1, false}, |
| 501 | {mmCP_CPC_STATUS, false}, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 502 | {mmGB_ADDR_CONFIG, false}, |
| 503 | {mmMC_ARB_RAMCFG, false}, |
| 504 | {mmGB_TILE_MODE0, false}, |
| 505 | {mmGB_TILE_MODE1, false}, |
| 506 | {mmGB_TILE_MODE2, false}, |
| 507 | {mmGB_TILE_MODE3, false}, |
| 508 | {mmGB_TILE_MODE4, false}, |
| 509 | {mmGB_TILE_MODE5, false}, |
| 510 | {mmGB_TILE_MODE6, false}, |
| 511 | {mmGB_TILE_MODE7, false}, |
| 512 | {mmGB_TILE_MODE8, false}, |
| 513 | {mmGB_TILE_MODE9, false}, |
| 514 | {mmGB_TILE_MODE10, false}, |
| 515 | {mmGB_TILE_MODE11, false}, |
| 516 | {mmGB_TILE_MODE12, false}, |
| 517 | {mmGB_TILE_MODE13, false}, |
| 518 | {mmGB_TILE_MODE14, false}, |
| 519 | {mmGB_TILE_MODE15, false}, |
| 520 | {mmGB_TILE_MODE16, false}, |
| 521 | {mmGB_TILE_MODE17, false}, |
| 522 | {mmGB_TILE_MODE18, false}, |
| 523 | {mmGB_TILE_MODE19, false}, |
| 524 | {mmGB_TILE_MODE20, false}, |
| 525 | {mmGB_TILE_MODE21, false}, |
| 526 | {mmGB_TILE_MODE22, false}, |
| 527 | {mmGB_TILE_MODE23, false}, |
| 528 | {mmGB_TILE_MODE24, false}, |
| 529 | {mmGB_TILE_MODE25, false}, |
| 530 | {mmGB_TILE_MODE26, false}, |
| 531 | {mmGB_TILE_MODE27, false}, |
| 532 | {mmGB_TILE_MODE28, false}, |
| 533 | {mmGB_TILE_MODE29, false}, |
| 534 | {mmGB_TILE_MODE30, false}, |
| 535 | {mmGB_TILE_MODE31, false}, |
| 536 | {mmGB_MACROTILE_MODE0, false}, |
| 537 | {mmGB_MACROTILE_MODE1, false}, |
| 538 | {mmGB_MACROTILE_MODE2, false}, |
| 539 | {mmGB_MACROTILE_MODE3, false}, |
| 540 | {mmGB_MACROTILE_MODE4, false}, |
| 541 | {mmGB_MACROTILE_MODE5, false}, |
| 542 | {mmGB_MACROTILE_MODE6, false}, |
| 543 | {mmGB_MACROTILE_MODE7, false}, |
| 544 | {mmGB_MACROTILE_MODE8, false}, |
| 545 | {mmGB_MACROTILE_MODE9, false}, |
| 546 | {mmGB_MACROTILE_MODE10, false}, |
| 547 | {mmGB_MACROTILE_MODE11, false}, |
| 548 | {mmGB_MACROTILE_MODE12, false}, |
| 549 | {mmGB_MACROTILE_MODE13, false}, |
| 550 | {mmGB_MACROTILE_MODE14, false}, |
| 551 | {mmGB_MACROTILE_MODE15, false}, |
| 552 | {mmCC_RB_BACKEND_DISABLE, false, true}, |
| 553 | {mmGC_USER_RB_BACKEND_DISABLE, false, true}, |
| 554 | {mmGB_BACKEND_MAP, false, false}, |
| 555 | {mmPA_SC_RASTER_CONFIG, false, true}, |
| 556 | {mmPA_SC_RASTER_CONFIG_1, false, true}, |
| 557 | }; |
| 558 | |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 559 | static uint32_t vi_get_register_value(struct amdgpu_device *adev, |
| 560 | bool indexed, u32 se_num, |
| 561 | u32 sh_num, u32 reg_offset) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 562 | { |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 563 | if (indexed) { |
| 564 | uint32_t val; |
| 565 | unsigned se_idx = (se_num == 0xffffffff) ? 0 : se_num; |
| 566 | unsigned sh_idx = (sh_num == 0xffffffff) ? 0 : sh_num; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 567 | |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 568 | switch (reg_offset) { |
| 569 | case mmCC_RB_BACKEND_DISABLE: |
| 570 | return adev->gfx.config.rb_config[se_idx][sh_idx].rb_backend_disable; |
| 571 | case mmGC_USER_RB_BACKEND_DISABLE: |
| 572 | return adev->gfx.config.rb_config[se_idx][sh_idx].user_rb_backend_disable; |
| 573 | case mmPA_SC_RASTER_CONFIG: |
| 574 | return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config; |
| 575 | case mmPA_SC_RASTER_CONFIG_1: |
| 576 | return adev->gfx.config.rb_config[se_idx][sh_idx].raster_config_1; |
| 577 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 578 | |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 579 | mutex_lock(&adev->grbm_idx_mutex); |
| 580 | if (se_num != 0xffffffff || sh_num != 0xffffffff) |
| 581 | amdgpu_gfx_select_se_sh(adev, se_num, sh_num, 0xffffffff); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 582 | |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 583 | val = RREG32(reg_offset); |
| 584 | |
| 585 | if (se_num != 0xffffffff || sh_num != 0xffffffff) |
| 586 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); |
| 587 | mutex_unlock(&adev->grbm_idx_mutex); |
| 588 | return val; |
| 589 | } else { |
| 590 | unsigned idx; |
| 591 | |
| 592 | switch (reg_offset) { |
| 593 | case mmGB_ADDR_CONFIG: |
| 594 | return adev->gfx.config.gb_addr_config; |
| 595 | case mmMC_ARB_RAMCFG: |
| 596 | return adev->gfx.config.mc_arb_ramcfg; |
| 597 | case mmGB_TILE_MODE0: |
| 598 | case mmGB_TILE_MODE1: |
| 599 | case mmGB_TILE_MODE2: |
| 600 | case mmGB_TILE_MODE3: |
| 601 | case mmGB_TILE_MODE4: |
| 602 | case mmGB_TILE_MODE5: |
| 603 | case mmGB_TILE_MODE6: |
| 604 | case mmGB_TILE_MODE7: |
| 605 | case mmGB_TILE_MODE8: |
| 606 | case mmGB_TILE_MODE9: |
| 607 | case mmGB_TILE_MODE10: |
| 608 | case mmGB_TILE_MODE11: |
| 609 | case mmGB_TILE_MODE12: |
| 610 | case mmGB_TILE_MODE13: |
| 611 | case mmGB_TILE_MODE14: |
| 612 | case mmGB_TILE_MODE15: |
| 613 | case mmGB_TILE_MODE16: |
| 614 | case mmGB_TILE_MODE17: |
| 615 | case mmGB_TILE_MODE18: |
| 616 | case mmGB_TILE_MODE19: |
| 617 | case mmGB_TILE_MODE20: |
| 618 | case mmGB_TILE_MODE21: |
| 619 | case mmGB_TILE_MODE22: |
| 620 | case mmGB_TILE_MODE23: |
| 621 | case mmGB_TILE_MODE24: |
| 622 | case mmGB_TILE_MODE25: |
| 623 | case mmGB_TILE_MODE26: |
| 624 | case mmGB_TILE_MODE27: |
| 625 | case mmGB_TILE_MODE28: |
| 626 | case mmGB_TILE_MODE29: |
| 627 | case mmGB_TILE_MODE30: |
| 628 | case mmGB_TILE_MODE31: |
| 629 | idx = (reg_offset - mmGB_TILE_MODE0); |
| 630 | return adev->gfx.config.tile_mode_array[idx]; |
| 631 | case mmGB_MACROTILE_MODE0: |
| 632 | case mmGB_MACROTILE_MODE1: |
| 633 | case mmGB_MACROTILE_MODE2: |
| 634 | case mmGB_MACROTILE_MODE3: |
| 635 | case mmGB_MACROTILE_MODE4: |
| 636 | case mmGB_MACROTILE_MODE5: |
| 637 | case mmGB_MACROTILE_MODE6: |
| 638 | case mmGB_MACROTILE_MODE7: |
| 639 | case mmGB_MACROTILE_MODE8: |
| 640 | case mmGB_MACROTILE_MODE9: |
| 641 | case mmGB_MACROTILE_MODE10: |
| 642 | case mmGB_MACROTILE_MODE11: |
| 643 | case mmGB_MACROTILE_MODE12: |
| 644 | case mmGB_MACROTILE_MODE13: |
| 645 | case mmGB_MACROTILE_MODE14: |
| 646 | case mmGB_MACROTILE_MODE15: |
| 647 | idx = (reg_offset - mmGB_MACROTILE_MODE0); |
| 648 | return adev->gfx.config.macrotile_mode_array[idx]; |
| 649 | default: |
| 650 | return RREG32(reg_offset); |
| 651 | } |
| 652 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | static int vi_read_register(struct amdgpu_device *adev, u32 se_num, |
| 656 | u32 sh_num, u32 reg_offset, u32 *value) |
| 657 | { |
Nils Wallménius | eca2240 | 2016-03-19 16:12:17 +0100 | [diff] [blame] | 658 | const struct amdgpu_allowed_register_entry *asic_register_table = NULL; |
| 659 | const struct amdgpu_allowed_register_entry *asic_register_entry; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 660 | uint32_t size, i; |
| 661 | |
| 662 | *value = 0; |
| 663 | switch (adev->asic_type) { |
| 664 | case CHIP_TOPAZ: |
| 665 | asic_register_table = tonga_allowed_read_registers; |
| 666 | size = ARRAY_SIZE(tonga_allowed_read_registers); |
| 667 | break; |
David Zhang | 48299f9 | 2015-07-08 01:05:16 +0800 | [diff] [blame] | 668 | case CHIP_FIJI: |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 669 | case CHIP_TONGA: |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 670 | case CHIP_POLARIS11: |
| 671 | case CHIP_POLARIS10: |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 672 | case CHIP_CARRIZO: |
Samuel Li | 39bb0c9 | 2015-10-08 16:31:43 -0400 | [diff] [blame] | 673 | case CHIP_STONEY: |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 674 | asic_register_table = cz_allowed_read_registers; |
| 675 | size = ARRAY_SIZE(cz_allowed_read_registers); |
| 676 | break; |
| 677 | default: |
| 678 | return -EINVAL; |
| 679 | } |
| 680 | |
| 681 | if (asic_register_table) { |
| 682 | for (i = 0; i < size; i++) { |
| 683 | asic_register_entry = asic_register_table + i; |
| 684 | if (reg_offset != asic_register_entry->reg_offset) |
| 685 | continue; |
| 686 | if (!asic_register_entry->untouched) |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 687 | *value = vi_get_register_value(adev, |
| 688 | asic_register_entry->grbm_indexed, |
| 689 | se_num, sh_num, reg_offset); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 690 | return 0; |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | for (i = 0; i < ARRAY_SIZE(vi_allowed_read_registers); i++) { |
| 695 | if (reg_offset != vi_allowed_read_registers[i].reg_offset) |
| 696 | continue; |
| 697 | |
| 698 | if (!vi_allowed_read_registers[i].untouched) |
Alex Deucher | db9635c | 2016-10-10 12:05:32 -0400 | [diff] [blame] | 699 | *value = vi_get_register_value(adev, |
| 700 | vi_allowed_read_registers[i].grbm_indexed, |
| 701 | se_num, sh_num, reg_offset); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 702 | return 0; |
| 703 | } |
| 704 | return -EINVAL; |
| 705 | } |
| 706 | |
Chunming Zhou | 89a3182 | 2016-06-06 13:06:45 +0800 | [diff] [blame] | 707 | static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 708 | { |
Alex Deucher | a2c5c69 | 2015-10-14 09:39:37 -0400 | [diff] [blame] | 709 | u32 i; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 710 | |
| 711 | dev_info(adev->dev, "GPU pci config reset\n"); |
| 712 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 713 | /* disable BM */ |
| 714 | pci_clear_master(adev->pdev); |
| 715 | /* reset */ |
| 716 | amdgpu_pci_config_reset(adev); |
| 717 | |
| 718 | udelay(100); |
| 719 | |
| 720 | /* wait for asic to come out of reset */ |
| 721 | for (i = 0; i < adev->usec_timeout; i++) { |
Chunming Zhou | b314f9a | 2016-06-06 13:50:18 +0800 | [diff] [blame] | 722 | if (RREG32(mmCONFIG_MEMSIZE) != 0xffffffff) { |
| 723 | /* enable BM */ |
| 724 | pci_set_master(adev->pdev); |
Chunming Zhou | 89a3182 | 2016-06-06 13:06:45 +0800 | [diff] [blame] | 725 | return 0; |
Chunming Zhou | b314f9a | 2016-06-06 13:50:18 +0800 | [diff] [blame] | 726 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 727 | udelay(1); |
| 728 | } |
Chunming Zhou | 89a3182 | 2016-06-06 13:06:45 +0800 | [diff] [blame] | 729 | return -EINVAL; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | static void vi_set_bios_scratch_engine_hung(struct amdgpu_device *adev, bool hung) |
| 733 | { |
| 734 | u32 tmp = RREG32(mmBIOS_SCRATCH_3); |
| 735 | |
| 736 | if (hung) |
| 737 | tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
| 738 | else |
| 739 | tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
| 740 | |
| 741 | WREG32(mmBIOS_SCRATCH_3, tmp); |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * vi_asic_reset - soft reset GPU |
| 746 | * |
| 747 | * @adev: amdgpu_device pointer |
| 748 | * |
| 749 | * Look up which blocks are hung and attempt |
| 750 | * to reset them. |
| 751 | * Returns 0 for success. |
| 752 | */ |
| 753 | static int vi_asic_reset(struct amdgpu_device *adev) |
| 754 | { |
Chunming Zhou | 89a3182 | 2016-06-06 13:06:45 +0800 | [diff] [blame] | 755 | int r; |
| 756 | |
Alex Deucher | a2c5c69 | 2015-10-14 09:39:37 -0400 | [diff] [blame] | 757 | vi_set_bios_scratch_engine_hung(adev, true); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 758 | |
Chunming Zhou | 89a3182 | 2016-06-06 13:06:45 +0800 | [diff] [blame] | 759 | r = vi_gpu_pci_config_reset(adev); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 760 | |
Alex Deucher | a2c5c69 | 2015-10-14 09:39:37 -0400 | [diff] [blame] | 761 | vi_set_bios_scratch_engine_hung(adev, false); |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 762 | |
Chunming Zhou | 89a3182 | 2016-06-06 13:06:45 +0800 | [diff] [blame] | 763 | return r; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | static int vi_set_uvd_clock(struct amdgpu_device *adev, u32 clock, |
| 767 | u32 cntl_reg, u32 status_reg) |
| 768 | { |
| 769 | int r, i; |
| 770 | struct atom_clock_dividers dividers; |
| 771 | uint32_t tmp; |
| 772 | |
| 773 | r = amdgpu_atombios_get_clock_dividers(adev, |
| 774 | COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, |
| 775 | clock, false, ÷rs); |
| 776 | if (r) |
| 777 | return r; |
| 778 | |
| 779 | tmp = RREG32_SMC(cntl_reg); |
| 780 | tmp &= ~(CG_DCLK_CNTL__DCLK_DIR_CNTL_EN_MASK | |
| 781 | CG_DCLK_CNTL__DCLK_DIVIDER_MASK); |
| 782 | tmp |= dividers.post_divider; |
| 783 | WREG32_SMC(cntl_reg, tmp); |
| 784 | |
| 785 | for (i = 0; i < 100; i++) { |
| 786 | if (RREG32_SMC(status_reg) & CG_DCLK_STATUS__DCLK_STATUS_MASK) |
| 787 | break; |
| 788 | mdelay(10); |
| 789 | } |
| 790 | if (i == 100) |
| 791 | return -ETIMEDOUT; |
| 792 | |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | static int vi_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) |
| 797 | { |
| 798 | int r; |
| 799 | |
| 800 | r = vi_set_uvd_clock(adev, vclk, ixCG_VCLK_CNTL, ixCG_VCLK_STATUS); |
| 801 | if (r) |
| 802 | return r; |
| 803 | |
| 804 | r = vi_set_uvd_clock(adev, dclk, ixCG_DCLK_CNTL, ixCG_DCLK_STATUS); |
| 805 | |
| 806 | return 0; |
| 807 | } |
| 808 | |
| 809 | static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) |
| 810 | { |
| 811 | /* todo */ |
| 812 | |
| 813 | return 0; |
| 814 | } |
| 815 | |
| 816 | static void vi_pcie_gen3_enable(struct amdgpu_device *adev) |
| 817 | { |
Alex Deucher | e79d5c0 | 2015-10-06 09:38:45 -0400 | [diff] [blame] | 818 | if (pci_is_root_bus(adev->pdev->bus)) |
| 819 | return; |
| 820 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 821 | if (amdgpu_pcie_gen2 == 0) |
| 822 | return; |
| 823 | |
Jammy Zhou | 2f7d10b | 2015-07-22 11:29:01 +0800 | [diff] [blame] | 824 | if (adev->flags & AMD_IS_APU) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 825 | return; |
| 826 | |
Alex Deucher | d0dd7f0 | 2015-11-11 19:45:06 -0500 | [diff] [blame] | 827 | if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | |
| 828 | CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 829 | return; |
| 830 | |
| 831 | /* todo */ |
| 832 | } |
| 833 | |
| 834 | static void vi_program_aspm(struct amdgpu_device *adev) |
| 835 | { |
| 836 | |
| 837 | if (amdgpu_aspm == 0) |
| 838 | return; |
| 839 | |
| 840 | /* todo */ |
| 841 | } |
| 842 | |
| 843 | static void vi_enable_doorbell_aperture(struct amdgpu_device *adev, |
| 844 | bool enable) |
| 845 | { |
| 846 | u32 tmp; |
| 847 | |
| 848 | /* not necessary on CZ */ |
Jammy Zhou | 2f7d10b | 2015-07-22 11:29:01 +0800 | [diff] [blame] | 849 | if (adev->flags & AMD_IS_APU) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 850 | return; |
| 851 | |
| 852 | tmp = RREG32(mmBIF_DOORBELL_APER_EN); |
| 853 | if (enable) |
| 854 | tmp = REG_SET_FIELD(tmp, BIF_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, 1); |
| 855 | else |
| 856 | tmp = REG_SET_FIELD(tmp, BIF_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, 0); |
| 857 | |
| 858 | WREG32(mmBIF_DOORBELL_APER_EN, tmp); |
| 859 | } |
| 860 | |
| 861 | /* topaz has no DCE, UVD, VCE */ |
| 862 | static const struct amdgpu_ip_block_version topaz_ip_blocks[] = |
| 863 | { |
| 864 | /* ORDER MATTERS! */ |
| 865 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 866 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 867 | .major = 2, |
| 868 | .minor = 0, |
| 869 | .rev = 0, |
| 870 | .funcs = &vi_common_ip_funcs, |
| 871 | }, |
| 872 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 873 | .type = AMD_IP_BLOCK_TYPE_GMC, |
Ken Wang | 429c45d | 2016-02-03 19:16:54 +0800 | [diff] [blame] | 874 | .major = 7, |
| 875 | .minor = 4, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 876 | .rev = 0, |
Ken Wang | 429c45d | 2016-02-03 19:16:54 +0800 | [diff] [blame] | 877 | .funcs = &gmc_v7_0_ip_funcs, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 878 | }, |
| 879 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 880 | .type = AMD_IP_BLOCK_TYPE_IH, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 881 | .major = 2, |
| 882 | .minor = 4, |
| 883 | .rev = 0, |
| 884 | .funcs = &iceland_ih_ip_funcs, |
| 885 | }, |
| 886 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 887 | .type = AMD_IP_BLOCK_TYPE_SMC, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 888 | .major = 7, |
| 889 | .minor = 1, |
| 890 | .rev = 0, |
Alex Deucher | 1f7371b | 2015-12-02 17:46:21 -0500 | [diff] [blame] | 891 | .funcs = &amdgpu_pp_ip_funcs, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 892 | }, |
| 893 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 894 | .type = AMD_IP_BLOCK_TYPE_GFX, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 895 | .major = 8, |
| 896 | .minor = 0, |
| 897 | .rev = 0, |
| 898 | .funcs = &gfx_v8_0_ip_funcs, |
| 899 | }, |
| 900 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 901 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 902 | .major = 2, |
| 903 | .minor = 4, |
| 904 | .rev = 0, |
| 905 | .funcs = &sdma_v2_4_ip_funcs, |
| 906 | }, |
| 907 | }; |
| 908 | |
Alex Deucher | 4f4b783 | 2016-08-08 14:45:29 -0400 | [diff] [blame] | 909 | static const struct amdgpu_ip_block_version topaz_ip_blocks_vd[] = |
| 910 | { |
| 911 | /* ORDER MATTERS! */ |
| 912 | { |
| 913 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 914 | .major = 2, |
| 915 | .minor = 0, |
| 916 | .rev = 0, |
| 917 | .funcs = &vi_common_ip_funcs, |
| 918 | }, |
| 919 | { |
| 920 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 921 | .major = 7, |
| 922 | .minor = 4, |
| 923 | .rev = 0, |
| 924 | .funcs = &gmc_v7_0_ip_funcs, |
| 925 | }, |
| 926 | { |
| 927 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 928 | .major = 2, |
| 929 | .minor = 4, |
| 930 | .rev = 0, |
| 931 | .funcs = &iceland_ih_ip_funcs, |
| 932 | }, |
| 933 | { |
| 934 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 935 | .major = 7, |
| 936 | .minor = 1, |
| 937 | .rev = 0, |
| 938 | .funcs = &amdgpu_pp_ip_funcs, |
| 939 | }, |
| 940 | { |
| 941 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 942 | .major = 1, |
| 943 | .minor = 0, |
| 944 | .rev = 0, |
| 945 | .funcs = &dce_virtual_ip_funcs, |
| 946 | }, |
| 947 | { |
| 948 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 949 | .major = 8, |
| 950 | .minor = 0, |
| 951 | .rev = 0, |
| 952 | .funcs = &gfx_v8_0_ip_funcs, |
| 953 | }, |
| 954 | { |
| 955 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 956 | .major = 2, |
| 957 | .minor = 4, |
| 958 | .rev = 0, |
| 959 | .funcs = &sdma_v2_4_ip_funcs, |
| 960 | }, |
| 961 | }; |
| 962 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 963 | static const struct amdgpu_ip_block_version tonga_ip_blocks[] = |
| 964 | { |
| 965 | /* ORDER MATTERS! */ |
| 966 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 967 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 968 | .major = 2, |
| 969 | .minor = 0, |
| 970 | .rev = 0, |
| 971 | .funcs = &vi_common_ip_funcs, |
| 972 | }, |
| 973 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 974 | .type = AMD_IP_BLOCK_TYPE_GMC, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 975 | .major = 8, |
| 976 | .minor = 0, |
| 977 | .rev = 0, |
| 978 | .funcs = &gmc_v8_0_ip_funcs, |
| 979 | }, |
| 980 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 981 | .type = AMD_IP_BLOCK_TYPE_IH, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 982 | .major = 3, |
| 983 | .minor = 0, |
| 984 | .rev = 0, |
| 985 | .funcs = &tonga_ih_ip_funcs, |
| 986 | }, |
| 987 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 988 | .type = AMD_IP_BLOCK_TYPE_SMC, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 989 | .major = 7, |
| 990 | .minor = 1, |
| 991 | .rev = 0, |
Alex Deucher | 1f7371b | 2015-12-02 17:46:21 -0500 | [diff] [blame] | 992 | .funcs = &amdgpu_pp_ip_funcs, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 993 | }, |
| 994 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 995 | .type = AMD_IP_BLOCK_TYPE_DCE, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 996 | .major = 10, |
| 997 | .minor = 0, |
| 998 | .rev = 0, |
| 999 | .funcs = &dce_v10_0_ip_funcs, |
| 1000 | }, |
| 1001 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1002 | .type = AMD_IP_BLOCK_TYPE_GFX, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1003 | .major = 8, |
| 1004 | .minor = 0, |
| 1005 | .rev = 0, |
| 1006 | .funcs = &gfx_v8_0_ip_funcs, |
| 1007 | }, |
| 1008 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1009 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1010 | .major = 3, |
| 1011 | .minor = 0, |
| 1012 | .rev = 0, |
| 1013 | .funcs = &sdma_v3_0_ip_funcs, |
| 1014 | }, |
| 1015 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1016 | .type = AMD_IP_BLOCK_TYPE_UVD, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1017 | .major = 5, |
| 1018 | .minor = 0, |
| 1019 | .rev = 0, |
| 1020 | .funcs = &uvd_v5_0_ip_funcs, |
| 1021 | }, |
| 1022 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1023 | .type = AMD_IP_BLOCK_TYPE_VCE, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1024 | .major = 3, |
| 1025 | .minor = 0, |
| 1026 | .rev = 0, |
| 1027 | .funcs = &vce_v3_0_ip_funcs, |
| 1028 | }, |
| 1029 | }; |
| 1030 | |
Emily Deng | e9ed3a6 | 2016-08-08 11:36:45 +0800 | [diff] [blame] | 1031 | static const struct amdgpu_ip_block_version tonga_ip_blocks_vd[] = |
| 1032 | { |
| 1033 | /* ORDER MATTERS! */ |
| 1034 | { |
| 1035 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 1036 | .major = 2, |
| 1037 | .minor = 0, |
| 1038 | .rev = 0, |
| 1039 | .funcs = &vi_common_ip_funcs, |
| 1040 | }, |
| 1041 | { |
| 1042 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 1043 | .major = 8, |
| 1044 | .minor = 0, |
| 1045 | .rev = 0, |
| 1046 | .funcs = &gmc_v8_0_ip_funcs, |
| 1047 | }, |
| 1048 | { |
| 1049 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 1050 | .major = 3, |
| 1051 | .minor = 0, |
| 1052 | .rev = 0, |
| 1053 | .funcs = &tonga_ih_ip_funcs, |
| 1054 | }, |
| 1055 | { |
| 1056 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 1057 | .major = 7, |
| 1058 | .minor = 1, |
| 1059 | .rev = 0, |
| 1060 | .funcs = &amdgpu_pp_ip_funcs, |
| 1061 | }, |
| 1062 | { |
| 1063 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 1064 | .major = 10, |
| 1065 | .minor = 0, |
| 1066 | .rev = 0, |
| 1067 | .funcs = &dce_virtual_ip_funcs, |
| 1068 | }, |
| 1069 | { |
| 1070 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 1071 | .major = 8, |
| 1072 | .minor = 0, |
| 1073 | .rev = 0, |
| 1074 | .funcs = &gfx_v8_0_ip_funcs, |
| 1075 | }, |
| 1076 | { |
| 1077 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 1078 | .major = 3, |
| 1079 | .minor = 0, |
| 1080 | .rev = 0, |
| 1081 | .funcs = &sdma_v3_0_ip_funcs, |
| 1082 | }, |
| 1083 | { |
| 1084 | .type = AMD_IP_BLOCK_TYPE_UVD, |
| 1085 | .major = 5, |
| 1086 | .minor = 0, |
| 1087 | .rev = 0, |
| 1088 | .funcs = &uvd_v5_0_ip_funcs, |
| 1089 | }, |
| 1090 | { |
| 1091 | .type = AMD_IP_BLOCK_TYPE_VCE, |
| 1092 | .major = 3, |
| 1093 | .minor = 0, |
| 1094 | .rev = 0, |
| 1095 | .funcs = &vce_v3_0_ip_funcs, |
| 1096 | }, |
| 1097 | }; |
| 1098 | |
David Zhang | 48299f9 | 2015-07-08 01:05:16 +0800 | [diff] [blame] | 1099 | static const struct amdgpu_ip_block_version fiji_ip_blocks[] = |
| 1100 | { |
| 1101 | /* ORDER MATTERS! */ |
| 1102 | { |
| 1103 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 1104 | .major = 2, |
| 1105 | .minor = 0, |
| 1106 | .rev = 0, |
| 1107 | .funcs = &vi_common_ip_funcs, |
David Zhang | 127a262 | 2015-07-08 01:11:52 +0800 | [diff] [blame] | 1108 | }, |
| 1109 | { |
| 1110 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 1111 | .major = 8, |
| 1112 | .minor = 5, |
| 1113 | .rev = 0, |
| 1114 | .funcs = &gmc_v8_0_ip_funcs, |
| 1115 | }, |
David Zhang | aa8a3b5 | 2015-07-08 21:40:31 +0800 | [diff] [blame] | 1116 | { |
| 1117 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 1118 | .major = 3, |
| 1119 | .minor = 0, |
| 1120 | .rev = 0, |
| 1121 | .funcs = &tonga_ih_ip_funcs, |
| 1122 | }, |
David Zhang | 8e711e1a | 2015-07-08 01:23:25 +0800 | [diff] [blame] | 1123 | { |
| 1124 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 1125 | .major = 7, |
| 1126 | .minor = 1, |
| 1127 | .rev = 0, |
Eric Huang | 899fa4c | 2015-09-29 14:58:53 -0400 | [diff] [blame] | 1128 | .funcs = &amdgpu_pp_ip_funcs, |
David Zhang | 8e711e1a | 2015-07-08 01:23:25 +0800 | [diff] [blame] | 1129 | }, |
David Zhang | 8439086 | 2015-07-08 01:28:20 +0800 | [diff] [blame] | 1130 | { |
| 1131 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 1132 | .major = 10, |
| 1133 | .minor = 1, |
| 1134 | .rev = 0, |
| 1135 | .funcs = &dce_v10_0_ip_funcs, |
| 1136 | }, |
David Zhang | af15a2d | 2015-07-30 19:42:11 -0400 | [diff] [blame] | 1137 | { |
| 1138 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 1139 | .major = 8, |
| 1140 | .minor = 0, |
| 1141 | .rev = 0, |
| 1142 | .funcs = &gfx_v8_0_ip_funcs, |
| 1143 | }, |
David Zhang | 1a5bbb6 | 2015-07-08 17:29:27 +0800 | [diff] [blame] | 1144 | { |
| 1145 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 1146 | .major = 3, |
| 1147 | .minor = 0, |
| 1148 | .rev = 0, |
| 1149 | .funcs = &sdma_v3_0_ip_funcs, |
| 1150 | }, |
David Zhang | 974ee3d | 2015-07-08 17:32:15 +0800 | [diff] [blame] | 1151 | { |
| 1152 | .type = AMD_IP_BLOCK_TYPE_UVD, |
| 1153 | .major = 6, |
| 1154 | .minor = 0, |
| 1155 | .rev = 0, |
| 1156 | .funcs = &uvd_v6_0_ip_funcs, |
| 1157 | }, |
Alex Deucher | 188a9bc | 2015-07-27 14:24:14 -0400 | [diff] [blame] | 1158 | { |
| 1159 | .type = AMD_IP_BLOCK_TYPE_VCE, |
| 1160 | .major = 3, |
| 1161 | .minor = 0, |
| 1162 | .rev = 0, |
| 1163 | .funcs = &vce_v3_0_ip_funcs, |
| 1164 | }, |
David Zhang | 48299f9 | 2015-07-08 01:05:16 +0800 | [diff] [blame] | 1165 | }; |
| 1166 | |
Emily Deng | e9ed3a6 | 2016-08-08 11:36:45 +0800 | [diff] [blame] | 1167 | static const struct amdgpu_ip_block_version fiji_ip_blocks_vd[] = |
| 1168 | { |
| 1169 | /* ORDER MATTERS! */ |
| 1170 | { |
| 1171 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 1172 | .major = 2, |
| 1173 | .minor = 0, |
| 1174 | .rev = 0, |
| 1175 | .funcs = &vi_common_ip_funcs, |
| 1176 | }, |
| 1177 | { |
| 1178 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 1179 | .major = 8, |
| 1180 | .minor = 5, |
| 1181 | .rev = 0, |
| 1182 | .funcs = &gmc_v8_0_ip_funcs, |
| 1183 | }, |
| 1184 | { |
| 1185 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 1186 | .major = 3, |
| 1187 | .minor = 0, |
| 1188 | .rev = 0, |
| 1189 | .funcs = &tonga_ih_ip_funcs, |
| 1190 | }, |
| 1191 | { |
| 1192 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 1193 | .major = 7, |
| 1194 | .minor = 1, |
| 1195 | .rev = 0, |
| 1196 | .funcs = &amdgpu_pp_ip_funcs, |
| 1197 | }, |
| 1198 | { |
| 1199 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 1200 | .major = 10, |
| 1201 | .minor = 1, |
| 1202 | .rev = 0, |
| 1203 | .funcs = &dce_virtual_ip_funcs, |
| 1204 | }, |
| 1205 | { |
| 1206 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 1207 | .major = 8, |
| 1208 | .minor = 0, |
| 1209 | .rev = 0, |
| 1210 | .funcs = &gfx_v8_0_ip_funcs, |
| 1211 | }, |
| 1212 | { |
| 1213 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 1214 | .major = 3, |
| 1215 | .minor = 0, |
| 1216 | .rev = 0, |
| 1217 | .funcs = &sdma_v3_0_ip_funcs, |
| 1218 | }, |
| 1219 | { |
| 1220 | .type = AMD_IP_BLOCK_TYPE_UVD, |
| 1221 | .major = 6, |
| 1222 | .minor = 0, |
| 1223 | .rev = 0, |
| 1224 | .funcs = &uvd_v6_0_ip_funcs, |
| 1225 | }, |
| 1226 | { |
| 1227 | .type = AMD_IP_BLOCK_TYPE_VCE, |
| 1228 | .major = 3, |
| 1229 | .minor = 0, |
| 1230 | .rev = 0, |
| 1231 | .funcs = &vce_v3_0_ip_funcs, |
| 1232 | }, |
| 1233 | }; |
| 1234 | |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 1235 | static const struct amdgpu_ip_block_version polaris11_ip_blocks[] = |
Flora Cui | c0c1f57 | 2015-12-07 18:33:10 +0800 | [diff] [blame] | 1236 | { |
| 1237 | /* ORDER MATTERS! */ |
| 1238 | { |
| 1239 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 1240 | .major = 2, |
| 1241 | .minor = 0, |
| 1242 | .rev = 0, |
| 1243 | .funcs = &vi_common_ip_funcs, |
| 1244 | }, |
| 1245 | { |
| 1246 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 1247 | .major = 8, |
| 1248 | .minor = 1, |
| 1249 | .rev = 0, |
| 1250 | .funcs = &gmc_v8_0_ip_funcs, |
| 1251 | }, |
| 1252 | { |
| 1253 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 1254 | .major = 3, |
| 1255 | .minor = 1, |
| 1256 | .rev = 0, |
| 1257 | .funcs = &tonga_ih_ip_funcs, |
| 1258 | }, |
| 1259 | { |
| 1260 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 1261 | .major = 7, |
| 1262 | .minor = 2, |
| 1263 | .rev = 0, |
| 1264 | .funcs = &amdgpu_pp_ip_funcs, |
| 1265 | }, |
| 1266 | { |
| 1267 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 1268 | .major = 11, |
| 1269 | .minor = 2, |
| 1270 | .rev = 0, |
| 1271 | .funcs = &dce_v11_0_ip_funcs, |
| 1272 | }, |
| 1273 | { |
| 1274 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 1275 | .major = 8, |
| 1276 | .minor = 0, |
| 1277 | .rev = 0, |
| 1278 | .funcs = &gfx_v8_0_ip_funcs, |
| 1279 | }, |
| 1280 | { |
| 1281 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 1282 | .major = 3, |
| 1283 | .minor = 1, |
| 1284 | .rev = 0, |
| 1285 | .funcs = &sdma_v3_0_ip_funcs, |
| 1286 | }, |
| 1287 | { |
| 1288 | .type = AMD_IP_BLOCK_TYPE_UVD, |
| 1289 | .major = 6, |
| 1290 | .minor = 3, |
| 1291 | .rev = 0, |
| 1292 | .funcs = &uvd_v6_0_ip_funcs, |
| 1293 | }, |
| 1294 | { |
| 1295 | .type = AMD_IP_BLOCK_TYPE_VCE, |
| 1296 | .major = 3, |
| 1297 | .minor = 4, |
| 1298 | .rev = 0, |
| 1299 | .funcs = &vce_v3_0_ip_funcs, |
| 1300 | }, |
| 1301 | }; |
| 1302 | |
Emily Deng | e9ed3a6 | 2016-08-08 11:36:45 +0800 | [diff] [blame] | 1303 | static const struct amdgpu_ip_block_version polaris11_ip_blocks_vd[] = |
| 1304 | { |
| 1305 | /* ORDER MATTERS! */ |
| 1306 | { |
| 1307 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 1308 | .major = 2, |
| 1309 | .minor = 0, |
| 1310 | .rev = 0, |
| 1311 | .funcs = &vi_common_ip_funcs, |
| 1312 | }, |
| 1313 | { |
| 1314 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 1315 | .major = 8, |
| 1316 | .minor = 1, |
| 1317 | .rev = 0, |
| 1318 | .funcs = &gmc_v8_0_ip_funcs, |
| 1319 | }, |
| 1320 | { |
| 1321 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 1322 | .major = 3, |
| 1323 | .minor = 1, |
| 1324 | .rev = 0, |
| 1325 | .funcs = &tonga_ih_ip_funcs, |
| 1326 | }, |
| 1327 | { |
| 1328 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 1329 | .major = 7, |
| 1330 | .minor = 2, |
| 1331 | .rev = 0, |
| 1332 | .funcs = &amdgpu_pp_ip_funcs, |
| 1333 | }, |
| 1334 | { |
| 1335 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 1336 | .major = 11, |
| 1337 | .minor = 2, |
| 1338 | .rev = 0, |
| 1339 | .funcs = &dce_virtual_ip_funcs, |
| 1340 | }, |
| 1341 | { |
| 1342 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 1343 | .major = 8, |
| 1344 | .minor = 0, |
| 1345 | .rev = 0, |
| 1346 | .funcs = &gfx_v8_0_ip_funcs, |
| 1347 | }, |
| 1348 | { |
| 1349 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 1350 | .major = 3, |
| 1351 | .minor = 1, |
| 1352 | .rev = 0, |
| 1353 | .funcs = &sdma_v3_0_ip_funcs, |
| 1354 | }, |
| 1355 | { |
| 1356 | .type = AMD_IP_BLOCK_TYPE_UVD, |
| 1357 | .major = 6, |
| 1358 | .minor = 3, |
| 1359 | .rev = 0, |
| 1360 | .funcs = &uvd_v6_0_ip_funcs, |
| 1361 | }, |
| 1362 | { |
| 1363 | .type = AMD_IP_BLOCK_TYPE_VCE, |
| 1364 | .major = 3, |
| 1365 | .minor = 4, |
| 1366 | .rev = 0, |
| 1367 | .funcs = &vce_v3_0_ip_funcs, |
| 1368 | }, |
| 1369 | }; |
| 1370 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1371 | static const struct amdgpu_ip_block_version cz_ip_blocks[] = |
| 1372 | { |
| 1373 | /* ORDER MATTERS! */ |
| 1374 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1375 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1376 | .major = 2, |
| 1377 | .minor = 0, |
| 1378 | .rev = 0, |
| 1379 | .funcs = &vi_common_ip_funcs, |
| 1380 | }, |
| 1381 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1382 | .type = AMD_IP_BLOCK_TYPE_GMC, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1383 | .major = 8, |
| 1384 | .minor = 0, |
| 1385 | .rev = 0, |
| 1386 | .funcs = &gmc_v8_0_ip_funcs, |
| 1387 | }, |
| 1388 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1389 | .type = AMD_IP_BLOCK_TYPE_IH, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1390 | .major = 3, |
| 1391 | .minor = 0, |
| 1392 | .rev = 0, |
| 1393 | .funcs = &cz_ih_ip_funcs, |
| 1394 | }, |
| 1395 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1396 | .type = AMD_IP_BLOCK_TYPE_SMC, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1397 | .major = 8, |
| 1398 | .minor = 0, |
| 1399 | .rev = 0, |
Alex Deucher | 1f7371b | 2015-12-02 17:46:21 -0500 | [diff] [blame] | 1400 | .funcs = &amdgpu_pp_ip_funcs |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1401 | }, |
| 1402 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1403 | .type = AMD_IP_BLOCK_TYPE_DCE, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1404 | .major = 11, |
| 1405 | .minor = 0, |
| 1406 | .rev = 0, |
| 1407 | .funcs = &dce_v11_0_ip_funcs, |
| 1408 | }, |
| 1409 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1410 | .type = AMD_IP_BLOCK_TYPE_GFX, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1411 | .major = 8, |
| 1412 | .minor = 0, |
| 1413 | .rev = 0, |
| 1414 | .funcs = &gfx_v8_0_ip_funcs, |
| 1415 | }, |
| 1416 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1417 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1418 | .major = 3, |
| 1419 | .minor = 0, |
| 1420 | .rev = 0, |
| 1421 | .funcs = &sdma_v3_0_ip_funcs, |
| 1422 | }, |
| 1423 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1424 | .type = AMD_IP_BLOCK_TYPE_UVD, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1425 | .major = 6, |
| 1426 | .minor = 0, |
| 1427 | .rev = 0, |
| 1428 | .funcs = &uvd_v6_0_ip_funcs, |
| 1429 | }, |
| 1430 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1431 | .type = AMD_IP_BLOCK_TYPE_VCE, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1432 | .major = 3, |
| 1433 | .minor = 0, |
| 1434 | .rev = 0, |
| 1435 | .funcs = &vce_v3_0_ip_funcs, |
| 1436 | }, |
Maruthi Bayyavarapu | a8fe58c | 2015-09-22 17:05:20 -0400 | [diff] [blame] | 1437 | #if defined(CONFIG_DRM_AMD_ACP) |
| 1438 | { |
| 1439 | .type = AMD_IP_BLOCK_TYPE_ACP, |
| 1440 | .major = 2, |
| 1441 | .minor = 2, |
| 1442 | .rev = 0, |
| 1443 | .funcs = &acp_ip_funcs, |
| 1444 | }, |
| 1445 | #endif |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1446 | }; |
| 1447 | |
Emily Deng | e9ed3a6 | 2016-08-08 11:36:45 +0800 | [diff] [blame] | 1448 | static const struct amdgpu_ip_block_version cz_ip_blocks_vd[] = |
| 1449 | { |
| 1450 | /* ORDER MATTERS! */ |
| 1451 | { |
| 1452 | .type = AMD_IP_BLOCK_TYPE_COMMON, |
| 1453 | .major = 2, |
| 1454 | .minor = 0, |
| 1455 | .rev = 0, |
| 1456 | .funcs = &vi_common_ip_funcs, |
| 1457 | }, |
| 1458 | { |
| 1459 | .type = AMD_IP_BLOCK_TYPE_GMC, |
| 1460 | .major = 8, |
| 1461 | .minor = 0, |
| 1462 | .rev = 0, |
| 1463 | .funcs = &gmc_v8_0_ip_funcs, |
| 1464 | }, |
| 1465 | { |
| 1466 | .type = AMD_IP_BLOCK_TYPE_IH, |
| 1467 | .major = 3, |
| 1468 | .minor = 0, |
| 1469 | .rev = 0, |
| 1470 | .funcs = &cz_ih_ip_funcs, |
| 1471 | }, |
| 1472 | { |
| 1473 | .type = AMD_IP_BLOCK_TYPE_SMC, |
| 1474 | .major = 8, |
| 1475 | .minor = 0, |
| 1476 | .rev = 0, |
| 1477 | .funcs = &amdgpu_pp_ip_funcs |
| 1478 | }, |
| 1479 | { |
| 1480 | .type = AMD_IP_BLOCK_TYPE_DCE, |
| 1481 | .major = 11, |
| 1482 | .minor = 0, |
| 1483 | .rev = 0, |
| 1484 | .funcs = &dce_virtual_ip_funcs, |
| 1485 | }, |
| 1486 | { |
| 1487 | .type = AMD_IP_BLOCK_TYPE_GFX, |
| 1488 | .major = 8, |
| 1489 | .minor = 0, |
| 1490 | .rev = 0, |
| 1491 | .funcs = &gfx_v8_0_ip_funcs, |
| 1492 | }, |
| 1493 | { |
| 1494 | .type = AMD_IP_BLOCK_TYPE_SDMA, |
| 1495 | .major = 3, |
| 1496 | .minor = 0, |
| 1497 | .rev = 0, |
| 1498 | .funcs = &sdma_v3_0_ip_funcs, |
| 1499 | }, |
| 1500 | { |
| 1501 | .type = AMD_IP_BLOCK_TYPE_UVD, |
| 1502 | .major = 6, |
| 1503 | .minor = 0, |
| 1504 | .rev = 0, |
| 1505 | .funcs = &uvd_v6_0_ip_funcs, |
| 1506 | }, |
| 1507 | { |
| 1508 | .type = AMD_IP_BLOCK_TYPE_VCE, |
| 1509 | .major = 3, |
| 1510 | .minor = 0, |
| 1511 | .rev = 0, |
| 1512 | .funcs = &vce_v3_0_ip_funcs, |
| 1513 | }, |
| 1514 | #if defined(CONFIG_DRM_AMD_ACP) |
| 1515 | { |
| 1516 | .type = AMD_IP_BLOCK_TYPE_ACP, |
| 1517 | .major = 2, |
| 1518 | .minor = 2, |
| 1519 | .rev = 0, |
| 1520 | .funcs = &acp_ip_funcs, |
| 1521 | }, |
| 1522 | #endif |
| 1523 | }; |
| 1524 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1525 | int vi_set_ip_blocks(struct amdgpu_device *adev) |
| 1526 | { |
Emily Deng | 9accf2f | 2016-08-10 16:01:25 +0800 | [diff] [blame] | 1527 | if (adev->enable_virtual_display) { |
Emily Deng | a6be757 | 2016-08-08 11:37:50 +0800 | [diff] [blame] | 1528 | switch (adev->asic_type) { |
| 1529 | case CHIP_TOPAZ: |
Alex Deucher | 4f4b783 | 2016-08-08 14:45:29 -0400 | [diff] [blame] | 1530 | adev->ip_blocks = topaz_ip_blocks_vd; |
| 1531 | adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks_vd); |
Emily Deng | a6be757 | 2016-08-08 11:37:50 +0800 | [diff] [blame] | 1532 | break; |
| 1533 | case CHIP_FIJI: |
| 1534 | adev->ip_blocks = fiji_ip_blocks_vd; |
| 1535 | adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks_vd); |
| 1536 | break; |
| 1537 | case CHIP_TONGA: |
| 1538 | adev->ip_blocks = tonga_ip_blocks_vd; |
| 1539 | adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks_vd); |
| 1540 | break; |
| 1541 | case CHIP_POLARIS11: |
| 1542 | case CHIP_POLARIS10: |
| 1543 | adev->ip_blocks = polaris11_ip_blocks_vd; |
| 1544 | adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks_vd); |
| 1545 | break; |
| 1546 | |
| 1547 | case CHIP_CARRIZO: |
| 1548 | case CHIP_STONEY: |
| 1549 | adev->ip_blocks = cz_ip_blocks_vd; |
| 1550 | adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks_vd); |
| 1551 | break; |
| 1552 | default: |
| 1553 | /* FIXME: not supported yet */ |
| 1554 | return -EINVAL; |
| 1555 | } |
| 1556 | } else { |
| 1557 | switch (adev->asic_type) { |
| 1558 | case CHIP_TOPAZ: |
| 1559 | adev->ip_blocks = topaz_ip_blocks; |
| 1560 | adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks); |
| 1561 | break; |
| 1562 | case CHIP_FIJI: |
| 1563 | adev->ip_blocks = fiji_ip_blocks; |
| 1564 | adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks); |
| 1565 | break; |
| 1566 | case CHIP_TONGA: |
| 1567 | adev->ip_blocks = tonga_ip_blocks; |
| 1568 | adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks); |
| 1569 | break; |
| 1570 | case CHIP_POLARIS11: |
| 1571 | case CHIP_POLARIS10: |
| 1572 | adev->ip_blocks = polaris11_ip_blocks; |
| 1573 | adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks); |
| 1574 | break; |
| 1575 | case CHIP_CARRIZO: |
| 1576 | case CHIP_STONEY: |
| 1577 | adev->ip_blocks = cz_ip_blocks; |
| 1578 | adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks); |
| 1579 | break; |
| 1580 | default: |
| 1581 | /* FIXME: not supported yet */ |
| 1582 | return -EINVAL; |
| 1583 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1584 | } |
| 1585 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1586 | return 0; |
| 1587 | } |
| 1588 | |
Samuel Li | 39bb0c9 | 2015-10-08 16:31:43 -0400 | [diff] [blame] | 1589 | #define ATI_REV_ID_FUSE_MACRO__ADDRESS 0xC0014044 |
| 1590 | #define ATI_REV_ID_FUSE_MACRO__SHIFT 9 |
| 1591 | #define ATI_REV_ID_FUSE_MACRO__MASK 0x00001E00 |
| 1592 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1593 | static uint32_t vi_get_rev_id(struct amdgpu_device *adev) |
| 1594 | { |
Flora Cui | abdfb85 | 2015-11-20 11:40:53 +0800 | [diff] [blame] | 1595 | if (adev->flags & AMD_IS_APU) |
Samuel Li | 39bb0c9 | 2015-10-08 16:31:43 -0400 | [diff] [blame] | 1596 | return (RREG32_SMC(ATI_REV_ID_FUSE_MACRO__ADDRESS) & ATI_REV_ID_FUSE_MACRO__MASK) |
| 1597 | >> ATI_REV_ID_FUSE_MACRO__SHIFT; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1598 | else |
Flora Cui | abdfb85 | 2015-11-20 11:40:53 +0800 | [diff] [blame] | 1599 | return (RREG32(mmPCIE_EFUSE4) & PCIE_EFUSE4__STRAP_BIF_ATI_REV_ID_MASK) |
| 1600 | >> PCIE_EFUSE4__STRAP_BIF_ATI_REV_ID__SHIFT; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1601 | } |
| 1602 | |
| 1603 | static const struct amdgpu_asic_funcs vi_asic_funcs = |
| 1604 | { |
| 1605 | .read_disabled_bios = &vi_read_disabled_bios, |
Alex Deucher | 95addb2a | 2015-11-24 10:37:54 -0500 | [diff] [blame] | 1606 | .read_bios_from_rom = &vi_read_bios_from_rom, |
Monk Liu | 4e99a44 | 2016-03-31 13:26:59 +0800 | [diff] [blame] | 1607 | .detect_hw_virtualization = vi_detect_hw_virtualization, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1608 | .read_register = &vi_read_register, |
| 1609 | .reset = &vi_asic_reset, |
| 1610 | .set_vga_state = &vi_vga_set_state, |
| 1611 | .get_xclk = &vi_get_xclk, |
| 1612 | .set_uvd_clocks = &vi_set_uvd_clocks, |
| 1613 | .set_vce_clocks = &vi_set_vce_clocks, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1614 | }; |
| 1615 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1616 | static int vi_common_early_init(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1617 | { |
| 1618 | bool smc_enabled = false; |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1619 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1620 | |
Jammy Zhou | 2f7d10b | 2015-07-22 11:29:01 +0800 | [diff] [blame] | 1621 | if (adev->flags & AMD_IS_APU) { |
Alex Deucher | 7b92cdb | 2015-07-10 16:21:10 -0400 | [diff] [blame] | 1622 | adev->smc_rreg = &cz_smc_rreg; |
| 1623 | adev->smc_wreg = &cz_smc_wreg; |
| 1624 | } else { |
| 1625 | adev->smc_rreg = &vi_smc_rreg; |
| 1626 | adev->smc_wreg = &vi_smc_wreg; |
| 1627 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1628 | adev->pcie_rreg = &vi_pcie_rreg; |
| 1629 | adev->pcie_wreg = &vi_pcie_wreg; |
| 1630 | adev->uvd_ctx_rreg = &vi_uvd_ctx_rreg; |
| 1631 | adev->uvd_ctx_wreg = &vi_uvd_ctx_wreg; |
| 1632 | adev->didt_rreg = &vi_didt_rreg; |
| 1633 | adev->didt_wreg = &vi_didt_wreg; |
Rex Zhu | ccdbb20 | 2016-06-08 12:47:41 +0800 | [diff] [blame] | 1634 | adev->gc_cac_rreg = &vi_gc_cac_rreg; |
| 1635 | adev->gc_cac_wreg = &vi_gc_cac_wreg; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1636 | |
| 1637 | adev->asic_funcs = &vi_asic_funcs; |
| 1638 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1639 | if (amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_SMC) && |
| 1640 | (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_SMC))) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1641 | smc_enabled = true; |
| 1642 | |
| 1643 | adev->rev_id = vi_get_rev_id(adev); |
| 1644 | adev->external_rev_id = 0xFF; |
| 1645 | switch (adev->asic_type) { |
| 1646 | case CHIP_TOPAZ: |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1647 | adev->cg_flags = 0; |
| 1648 | adev->pg_flags = 0; |
| 1649 | adev->external_rev_id = 0x1; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1650 | break; |
David Zhang | 48299f9 | 2015-07-08 01:05:16 +0800 | [diff] [blame] | 1651 | case CHIP_FIJI: |
Alex Deucher | 14698b6 | 2016-04-07 18:38:00 -0400 | [diff] [blame] | 1652 | adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG | |
| 1653 | AMD_CG_SUPPORT_GFX_MGLS | |
| 1654 | AMD_CG_SUPPORT_GFX_RLC_LS | |
| 1655 | AMD_CG_SUPPORT_GFX_CP_LS | |
| 1656 | AMD_CG_SUPPORT_GFX_CGTS | |
| 1657 | AMD_CG_SUPPORT_GFX_CGTS_LS | |
| 1658 | AMD_CG_SUPPORT_GFX_CGCG | |
Alex Deucher | e08d53c | 2016-04-08 00:42:51 -0400 | [diff] [blame] | 1659 | AMD_CG_SUPPORT_GFX_CGLS | |
| 1660 | AMD_CG_SUPPORT_SDMA_MGCG | |
Alex Deucher | c90766c | 2016-04-08 00:52:58 -0400 | [diff] [blame] | 1661 | AMD_CG_SUPPORT_SDMA_LS | |
| 1662 | AMD_CG_SUPPORT_BIF_LS | |
| 1663 | AMD_CG_SUPPORT_HDP_MGCG | |
| 1664 | AMD_CG_SUPPORT_HDP_LS | |
Alex Deucher | 3fde56b | 2016-04-08 01:01:18 -0400 | [diff] [blame] | 1665 | AMD_CG_SUPPORT_ROM_MGCG | |
| 1666 | AMD_CG_SUPPORT_MC_MGCG | |
| 1667 | AMD_CG_SUPPORT_MC_LS; |
Flora Cui | b6bc28f | 2015-11-02 21:21:34 +0800 | [diff] [blame] | 1668 | adev->pg_flags = 0; |
| 1669 | adev->external_rev_id = adev->rev_id + 0x3c; |
| 1670 | break; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1671 | case CHIP_TONGA: |
Tom St Denis | 5f64e77 | 2016-03-23 13:16:13 -0400 | [diff] [blame] | 1672 | adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG; |
Tom St Denis | f3fd451 | 2016-09-30 11:00:16 -0400 | [diff] [blame] | 1673 | adev->pg_flags = AMD_PG_SUPPORT_UVD; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1674 | adev->external_rev_id = adev->rev_id + 0x14; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1675 | break; |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 1676 | case CHIP_POLARIS11: |
Flora Cui | c0c1f57 | 2015-12-07 18:33:10 +0800 | [diff] [blame] | 1677 | adev->cg_flags = 0; |
| 1678 | adev->pg_flags = 0; |
| 1679 | adev->external_rev_id = adev->rev_id + 0x5A; |
| 1680 | break; |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 1681 | case CHIP_POLARIS10: |
Flora Cui | c0c1f57 | 2015-12-07 18:33:10 +0800 | [diff] [blame] | 1682 | adev->cg_flags = 0; |
| 1683 | adev->pg_flags = 0; |
| 1684 | adev->external_rev_id = adev->rev_id + 0x50; |
| 1685 | break; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1686 | case CHIP_CARRIZO: |
Tom St Denis | f0f3a8f | 2016-05-03 10:36:28 -0400 | [diff] [blame] | 1687 | adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG | |
| 1688 | AMD_CG_SUPPORT_GFX_MGCG | |
Alex Deucher | 70eced9 | 2016-04-07 23:01:48 -0400 | [diff] [blame] | 1689 | AMD_CG_SUPPORT_GFX_MGLS | |
| 1690 | AMD_CG_SUPPORT_GFX_RLC_LS | |
| 1691 | AMD_CG_SUPPORT_GFX_CP_LS | |
| 1692 | AMD_CG_SUPPORT_GFX_CGTS | |
| 1693 | AMD_CG_SUPPORT_GFX_MGLS | |
| 1694 | AMD_CG_SUPPORT_GFX_CGTS_LS | |
| 1695 | AMD_CG_SUPPORT_GFX_CGCG | |
Alex Deucher | 03c335d | 2016-04-08 00:26:46 -0400 | [diff] [blame] | 1696 | AMD_CG_SUPPORT_GFX_CGLS | |
| 1697 | AMD_CG_SUPPORT_BIF_LS | |
| 1698 | AMD_CG_SUPPORT_HDP_MGCG | |
Alex Deucher | 6f17a25 | 2016-04-08 00:39:54 -0400 | [diff] [blame] | 1699 | AMD_CG_SUPPORT_HDP_LS | |
| 1700 | AMD_CG_SUPPORT_SDMA_MGCG | |
Tom St Denis | 1af69a2 | 2016-08-03 10:16:17 -0400 | [diff] [blame] | 1701 | AMD_CG_SUPPORT_SDMA_LS | |
| 1702 | AMD_CG_SUPPORT_VCE_MGCG; |
Tom St Denis | f6ade30 | 2016-07-28 09:33:56 -0400 | [diff] [blame] | 1703 | /* rev0 hardware requires workarounds to support PG */ |
Alex Deucher | 0fd4af9 | 2016-02-04 23:31:32 -0500 | [diff] [blame] | 1704 | adev->pg_flags = 0; |
Tom St Denis | f6ade30 | 2016-07-28 09:33:56 -0400 | [diff] [blame] | 1705 | if (adev->rev_id != 0x00) { |
| 1706 | adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | |
| 1707 | AMD_PG_SUPPORT_GFX_SMG | |
Tom St Denis | 65b4262 | 2016-07-28 09:35:57 -0400 | [diff] [blame] | 1708 | AMD_PG_SUPPORT_GFX_PIPELINE | |
Tom St Denis | 2ed0936 | 2016-07-28 09:36:26 -0400 | [diff] [blame] | 1709 | AMD_PG_SUPPORT_UVD | |
| 1710 | AMD_PG_SUPPORT_VCE; |
Tom St Denis | f6ade30 | 2016-07-28 09:33:56 -0400 | [diff] [blame] | 1711 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1712 | adev->external_rev_id = adev->rev_id + 0x1; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1713 | break; |
Tom St Denis | cde6493 | 2016-03-23 13:17:04 -0400 | [diff] [blame] | 1714 | case CHIP_STONEY: |
Alex Deucher | 6469490 | 2016-04-07 23:17:15 -0400 | [diff] [blame] | 1715 | adev->cg_flags = AMD_CG_SUPPORT_UVD_MGCG | |
| 1716 | AMD_CG_SUPPORT_GFX_MGCG | |
Alex Deucher | b6711d1 | 2016-04-13 12:41:50 -0400 | [diff] [blame] | 1717 | AMD_CG_SUPPORT_GFX_MGLS | |
Tom St Denis | 413cf60 | 2016-06-02 08:52:39 -0400 | [diff] [blame] | 1718 | AMD_CG_SUPPORT_GFX_RLC_LS | |
| 1719 | AMD_CG_SUPPORT_GFX_CP_LS | |
| 1720 | AMD_CG_SUPPORT_GFX_CGTS | |
| 1721 | AMD_CG_SUPPORT_GFX_MGLS | |
| 1722 | AMD_CG_SUPPORT_GFX_CGTS_LS | |
| 1723 | AMD_CG_SUPPORT_GFX_CGCG | |
| 1724 | AMD_CG_SUPPORT_GFX_CGLS | |
Alex Deucher | b6711d1 | 2016-04-13 12:41:50 -0400 | [diff] [blame] | 1725 | AMD_CG_SUPPORT_BIF_LS | |
| 1726 | AMD_CG_SUPPORT_HDP_MGCG | |
Alex Deucher | 1bf912f | 2016-04-08 00:40:49 -0400 | [diff] [blame] | 1727 | AMD_CG_SUPPORT_HDP_LS | |
| 1728 | AMD_CG_SUPPORT_SDMA_MGCG | |
Tom St Denis | 8ef583e | 2016-08-03 11:34:35 -0400 | [diff] [blame] | 1729 | AMD_CG_SUPPORT_SDMA_LS | |
| 1730 | AMD_CG_SUPPORT_VCE_MGCG; |
Tom St Denis | 4e86be7 | 2016-07-28 09:38:13 -0400 | [diff] [blame] | 1731 | adev->pg_flags |= AMD_PG_SUPPORT_GFX_PG | |
| 1732 | AMD_PG_SUPPORT_GFX_SMG | |
Tom St Denis | c2cdb0428 | 2016-07-28 09:38:29 -0400 | [diff] [blame] | 1733 | AMD_PG_SUPPORT_GFX_PIPELINE | |
Tom St Denis | 75419c4 | 2016-07-28 09:38:45 -0400 | [diff] [blame] | 1734 | AMD_PG_SUPPORT_UVD | |
| 1735 | AMD_PG_SUPPORT_VCE; |
Jordan Lazare | a47c78d | 2016-09-01 13:49:33 -0400 | [diff] [blame] | 1736 | adev->external_rev_id = adev->rev_id + 0x61; |
Tom St Denis | cde6493 | 2016-03-23 13:17:04 -0400 | [diff] [blame] | 1737 | break; |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1738 | default: |
| 1739 | /* FIXME: not supported yet */ |
| 1740 | return -EINVAL; |
| 1741 | } |
| 1742 | |
Monk Liu | 4e99a44 | 2016-03-31 13:26:59 +0800 | [diff] [blame] | 1743 | /* in early init stage, vbios code won't work */ |
| 1744 | if (adev->asic_funcs->detect_hw_virtualization) |
| 1745 | amdgpu_asic_detect_hw_virtualization(adev); |
| 1746 | |
Flora Cui | a3d08fa | 2015-11-02 21:15:55 +0800 | [diff] [blame] | 1747 | if (amdgpu_smc_load_fw && smc_enabled) |
| 1748 | adev->firmware.smu_load = true; |
| 1749 | |
Alex Deucher | d0dd7f0 | 2015-11-11 19:45:06 -0500 | [diff] [blame] | 1750 | amdgpu_get_pcie_info(adev); |
| 1751 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1752 | return 0; |
| 1753 | } |
| 1754 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1755 | static int vi_common_sw_init(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1756 | { |
| 1757 | return 0; |
| 1758 | } |
| 1759 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1760 | static int vi_common_sw_fini(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1761 | { |
| 1762 | return 0; |
| 1763 | } |
| 1764 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1765 | static int vi_common_hw_init(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1766 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1767 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1768 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1769 | /* move the golden regs per IP block */ |
| 1770 | vi_init_golden_registers(adev); |
| 1771 | /* enable pcie gen2/3 link */ |
| 1772 | vi_pcie_gen3_enable(adev); |
| 1773 | /* enable aspm */ |
| 1774 | vi_program_aspm(adev); |
| 1775 | /* enable the doorbell aperture */ |
| 1776 | vi_enable_doorbell_aperture(adev, true); |
| 1777 | |
| 1778 | return 0; |
| 1779 | } |
| 1780 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1781 | static int vi_common_hw_fini(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1782 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1783 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1784 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1785 | /* enable the doorbell aperture */ |
| 1786 | vi_enable_doorbell_aperture(adev, false); |
| 1787 | |
| 1788 | return 0; |
| 1789 | } |
| 1790 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1791 | static int vi_common_suspend(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1792 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1793 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1794 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1795 | return vi_common_hw_fini(adev); |
| 1796 | } |
| 1797 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1798 | static int vi_common_resume(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1799 | { |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1800 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1801 | |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1802 | return vi_common_hw_init(adev); |
| 1803 | } |
| 1804 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1805 | static bool vi_common_is_idle(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1806 | { |
| 1807 | return true; |
| 1808 | } |
| 1809 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1810 | static int vi_common_wait_for_idle(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1811 | { |
| 1812 | return 0; |
| 1813 | } |
| 1814 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1815 | static int vi_common_soft_reset(void *handle) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1816 | { |
| 1817 | return 0; |
| 1818 | } |
| 1819 | |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1820 | static void vi_update_bif_medium_grain_light_sleep(struct amdgpu_device *adev, |
| 1821 | bool enable) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1822 | { |
| 1823 | uint32_t temp, data; |
| 1824 | |
| 1825 | temp = data = RREG32_PCIE(ixPCIE_CNTL2); |
| 1826 | |
Alex Deucher | c90766c | 2016-04-08 00:52:58 -0400 | [diff] [blame] | 1827 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS)) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1828 | data |= PCIE_CNTL2__SLV_MEM_LS_EN_MASK | |
| 1829 | PCIE_CNTL2__MST_MEM_LS_EN_MASK | |
| 1830 | PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK; |
| 1831 | else |
| 1832 | data &= ~(PCIE_CNTL2__SLV_MEM_LS_EN_MASK | |
| 1833 | PCIE_CNTL2__MST_MEM_LS_EN_MASK | |
| 1834 | PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK); |
| 1835 | |
| 1836 | if (temp != data) |
| 1837 | WREG32_PCIE(ixPCIE_CNTL2, data); |
| 1838 | } |
| 1839 | |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1840 | static void vi_update_hdp_medium_grain_clock_gating(struct amdgpu_device *adev, |
| 1841 | bool enable) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1842 | { |
| 1843 | uint32_t temp, data; |
| 1844 | |
| 1845 | temp = data = RREG32(mmHDP_HOST_PATH_CNTL); |
| 1846 | |
Alex Deucher | c90766c | 2016-04-08 00:52:58 -0400 | [diff] [blame] | 1847 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG)) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1848 | data &= ~HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK; |
| 1849 | else |
| 1850 | data |= HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK; |
| 1851 | |
| 1852 | if (temp != data) |
| 1853 | WREG32(mmHDP_HOST_PATH_CNTL, data); |
| 1854 | } |
| 1855 | |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1856 | static void vi_update_hdp_light_sleep(struct amdgpu_device *adev, |
| 1857 | bool enable) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1858 | { |
| 1859 | uint32_t temp, data; |
| 1860 | |
| 1861 | temp = data = RREG32(mmHDP_MEM_POWER_LS); |
| 1862 | |
Alex Deucher | c90766c | 2016-04-08 00:52:58 -0400 | [diff] [blame] | 1863 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS)) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1864 | data |= HDP_MEM_POWER_LS__LS_ENABLE_MASK; |
| 1865 | else |
| 1866 | data &= ~HDP_MEM_POWER_LS__LS_ENABLE_MASK; |
| 1867 | |
| 1868 | if (temp != data) |
| 1869 | WREG32(mmHDP_MEM_POWER_LS, data); |
| 1870 | } |
| 1871 | |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1872 | static void vi_update_rom_medium_grain_clock_gating(struct amdgpu_device *adev, |
| 1873 | bool enable) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1874 | { |
| 1875 | uint32_t temp, data; |
| 1876 | |
| 1877 | temp = data = RREG32_SMC(ixCGTT_ROM_CLK_CTRL0); |
| 1878 | |
Alex Deucher | c90766c | 2016-04-08 00:52:58 -0400 | [diff] [blame] | 1879 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_ROM_MGCG)) |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1880 | data &= ~(CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK | |
| 1881 | CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE1_MASK); |
| 1882 | else |
| 1883 | data |= CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK | |
| 1884 | CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE1_MASK; |
| 1885 | |
| 1886 | if (temp != data) |
| 1887 | WREG32_SMC(ixCGTT_ROM_CLK_CTRL0, data); |
| 1888 | } |
| 1889 | |
Rex Zhu | 1bb08f9 | 2016-09-18 16:54:00 +0800 | [diff] [blame] | 1890 | static int vi_common_set_clockgating_state_by_smu(void *handle, |
| 1891 | enum amd_clockgating_state state) |
| 1892 | { |
| 1893 | uint32_t msg_id, pp_state; |
| 1894 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1895 | void *pp_handle = adev->powerplay.pp_handle; |
| 1896 | |
| 1897 | if (state == AMD_CG_STATE_UNGATE) |
| 1898 | pp_state = 0; |
| 1899 | else |
| 1900 | pp_state = PP_STATE_CG | PP_STATE_LS; |
| 1901 | |
| 1902 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1903 | PP_BLOCK_SYS_MC, |
| 1904 | PP_STATE_SUPPORT_CG | PP_STATE_SUPPORT_LS, |
| 1905 | pp_state); |
| 1906 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1907 | |
| 1908 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1909 | PP_BLOCK_SYS_SDMA, |
| 1910 | PP_STATE_SUPPORT_CG | PP_STATE_SUPPORT_LS, |
| 1911 | pp_state); |
| 1912 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1913 | |
| 1914 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1915 | PP_BLOCK_SYS_HDP, |
| 1916 | PP_STATE_SUPPORT_CG | PP_STATE_SUPPORT_LS, |
| 1917 | pp_state); |
| 1918 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1919 | |
| 1920 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1921 | PP_BLOCK_SYS_BIF, |
| 1922 | PP_STATE_SUPPORT_LS, |
| 1923 | pp_state); |
| 1924 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1925 | |
| 1926 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1927 | PP_BLOCK_SYS_BIF, |
| 1928 | PP_STATE_SUPPORT_CG, |
| 1929 | pp_state); |
| 1930 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1931 | |
| 1932 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1933 | PP_BLOCK_SYS_DRM, |
| 1934 | PP_STATE_SUPPORT_LS, |
| 1935 | pp_state); |
| 1936 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1937 | |
| 1938 | msg_id = PP_CG_MSG_ID(PP_GROUP_SYS, |
| 1939 | PP_BLOCK_SYS_ROM, |
| 1940 | PP_STATE_SUPPORT_CG, |
| 1941 | pp_state); |
| 1942 | amd_set_clockgating_by_smu(pp_handle, msg_id); |
| 1943 | |
| 1944 | return 0; |
| 1945 | } |
| 1946 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1947 | static int vi_common_set_clockgating_state(void *handle, |
Alex Deucher | c90766c | 2016-04-08 00:52:58 -0400 | [diff] [blame] | 1948 | enum amd_clockgating_state state) |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1949 | { |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1950 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1951 | |
| 1952 | switch (adev->asic_type) { |
| 1953 | case CHIP_FIJI: |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1954 | vi_update_bif_medium_grain_light_sleep(adev, |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1955 | state == AMD_CG_STATE_GATE ? true : false); |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1956 | vi_update_hdp_medium_grain_clock_gating(adev, |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1957 | state == AMD_CG_STATE_GATE ? true : false); |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1958 | vi_update_hdp_light_sleep(adev, |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1959 | state == AMD_CG_STATE_GATE ? true : false); |
Alex Deucher | 76f10b9 | 2016-04-08 01:37:44 -0400 | [diff] [blame] | 1960 | vi_update_rom_medium_grain_clock_gating(adev, |
| 1961 | state == AMD_CG_STATE_GATE ? true : false); |
| 1962 | break; |
| 1963 | case CHIP_CARRIZO: |
| 1964 | case CHIP_STONEY: |
| 1965 | vi_update_bif_medium_grain_light_sleep(adev, |
| 1966 | state == AMD_CG_STATE_GATE ? true : false); |
| 1967 | vi_update_hdp_medium_grain_clock_gating(adev, |
| 1968 | state == AMD_CG_STATE_GATE ? true : false); |
| 1969 | vi_update_hdp_light_sleep(adev, |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1970 | state == AMD_CG_STATE_GATE ? true : false); |
| 1971 | break; |
Rex Zhu | 1bb08f9 | 2016-09-18 16:54:00 +0800 | [diff] [blame] | 1972 | case CHIP_TONGA: |
| 1973 | case CHIP_POLARIS10: |
| 1974 | case CHIP_POLARIS11: |
| 1975 | vi_common_set_clockgating_state_by_smu(adev, state); |
Eric Huang | 6cec265 | 2015-11-12 16:59:47 -0500 | [diff] [blame] | 1976 | default: |
| 1977 | break; |
| 1978 | } |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1979 | return 0; |
| 1980 | } |
| 1981 | |
yanyang1 | 5fc3aee | 2015-05-22 14:39:35 -0400 | [diff] [blame] | 1982 | static int vi_common_set_powergating_state(void *handle, |
| 1983 | enum amd_powergating_state state) |
| 1984 | { |
| 1985 | return 0; |
| 1986 | } |
| 1987 | |
| 1988 | const struct amd_ip_funcs vi_common_ip_funcs = { |
Tom St Denis | 88a907d | 2016-05-04 14:28:35 -0400 | [diff] [blame] | 1989 | .name = "vi_common", |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 1990 | .early_init = vi_common_early_init, |
| 1991 | .late_init = NULL, |
| 1992 | .sw_init = vi_common_sw_init, |
| 1993 | .sw_fini = vi_common_sw_fini, |
| 1994 | .hw_init = vi_common_hw_init, |
| 1995 | .hw_fini = vi_common_hw_fini, |
| 1996 | .suspend = vi_common_suspend, |
| 1997 | .resume = vi_common_resume, |
| 1998 | .is_idle = vi_common_is_idle, |
| 1999 | .wait_for_idle = vi_common_wait_for_idle, |
| 2000 | .soft_reset = vi_common_soft_reset, |
Alex Deucher | aaa36a9 | 2015-04-20 17:31:14 -0400 | [diff] [blame] | 2001 | .set_clockgating_state = vi_common_set_clockgating_state, |
| 2002 | .set_powergating_state = vi_common_set_powergating_state, |
| 2003 | }; |
| 2004 | |