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