Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | * Authors: Alex Deucher |
| 23 | */ |
| 24 | #include <linux/firmware.h> |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 25 | #include <linux/slab.h> |
| 26 | #include <linux/module.h> |
| 27 | #include "drmP.h" |
| 28 | #include "radeon.h" |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 29 | #include "radeon_asic.h" |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 30 | #include "cikd.h" |
| 31 | #include "atom.h" |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 32 | #include "cik_blit_shaders.h" |
Alex Deucher | 8c68e39 | 2013-06-21 15:38:37 -0400 | [diff] [blame] | 33 | #include "radeon_ucode.h" |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 34 | #include "clearstate_ci.h" |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 35 | |
| 36 | MODULE_FIRMWARE("radeon/BONAIRE_pfp.bin"); |
| 37 | MODULE_FIRMWARE("radeon/BONAIRE_me.bin"); |
| 38 | MODULE_FIRMWARE("radeon/BONAIRE_ce.bin"); |
| 39 | MODULE_FIRMWARE("radeon/BONAIRE_mec.bin"); |
| 40 | MODULE_FIRMWARE("radeon/BONAIRE_mc.bin"); |
| 41 | MODULE_FIRMWARE("radeon/BONAIRE_rlc.bin"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 42 | MODULE_FIRMWARE("radeon/BONAIRE_sdma.bin"); |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 43 | MODULE_FIRMWARE("radeon/BONAIRE_smc.bin"); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 44 | MODULE_FIRMWARE("radeon/KAVERI_pfp.bin"); |
| 45 | MODULE_FIRMWARE("radeon/KAVERI_me.bin"); |
| 46 | MODULE_FIRMWARE("radeon/KAVERI_ce.bin"); |
| 47 | MODULE_FIRMWARE("radeon/KAVERI_mec.bin"); |
| 48 | MODULE_FIRMWARE("radeon/KAVERI_rlc.bin"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 49 | MODULE_FIRMWARE("radeon/KAVERI_sdma.bin"); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 50 | MODULE_FIRMWARE("radeon/KABINI_pfp.bin"); |
| 51 | MODULE_FIRMWARE("radeon/KABINI_me.bin"); |
| 52 | MODULE_FIRMWARE("radeon/KABINI_ce.bin"); |
| 53 | MODULE_FIRMWARE("radeon/KABINI_mec.bin"); |
| 54 | MODULE_FIRMWARE("radeon/KABINI_rlc.bin"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 55 | MODULE_FIRMWARE("radeon/KABINI_sdma.bin"); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 56 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 57 | extern int r600_ih_ring_alloc(struct radeon_device *rdev); |
| 58 | extern void r600_ih_ring_fini(struct radeon_device *rdev); |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 59 | extern void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save); |
| 60 | extern void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save); |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 61 | extern bool evergreen_is_display_hung(struct radeon_device *rdev); |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 62 | extern void sumo_rlc_fini(struct radeon_device *rdev); |
| 63 | extern int sumo_rlc_init(struct radeon_device *rdev); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 64 | extern void si_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 65 | extern void si_rlc_reset(struct radeon_device *rdev); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 66 | extern void si_init_uvd_internal_cg(struct radeon_device *rdev); |
Christian König | 2483b4e | 2013-08-13 11:56:54 +0200 | [diff] [blame] | 67 | extern int cik_sdma_resume(struct radeon_device *rdev); |
| 68 | extern void cik_sdma_enable(struct radeon_device *rdev, bool enable); |
| 69 | extern void cik_sdma_fini(struct radeon_device *rdev); |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 70 | static void cik_rlc_stop(struct radeon_device *rdev); |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 71 | static void cik_pcie_gen3_enable(struct radeon_device *rdev); |
Alex Deucher | 7235711a4 | 2013-04-04 13:58:09 -0400 | [diff] [blame] | 72 | static void cik_program_aspm(struct radeon_device *rdev); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 73 | static void cik_init_pg(struct radeon_device *rdev); |
| 74 | static void cik_init_cg(struct radeon_device *rdev); |
Alex Deucher | fb2c7f4 | 2013-10-02 14:54:44 -0400 | [diff] [blame] | 75 | static void cik_fini_pg(struct radeon_device *rdev); |
| 76 | static void cik_fini_cg(struct radeon_device *rdev); |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 77 | static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev, |
| 78 | bool enable); |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 79 | |
Alex Deucher | 286d9cc | 2013-06-21 15:50:47 -0400 | [diff] [blame] | 80 | /* get temperature in millidegrees */ |
| 81 | int ci_get_temp(struct radeon_device *rdev) |
| 82 | { |
| 83 | u32 temp; |
| 84 | int actual_temp = 0; |
| 85 | |
| 86 | temp = (RREG32_SMC(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >> |
| 87 | CTF_TEMP_SHIFT; |
| 88 | |
| 89 | if (temp & 0x200) |
| 90 | actual_temp = 255; |
| 91 | else |
| 92 | actual_temp = temp & 0x1ff; |
| 93 | |
| 94 | actual_temp = actual_temp * 1000; |
| 95 | |
| 96 | return actual_temp; |
| 97 | } |
| 98 | |
| 99 | /* get temperature in millidegrees */ |
| 100 | int kv_get_temp(struct radeon_device *rdev) |
| 101 | { |
| 102 | u32 temp; |
| 103 | int actual_temp = 0; |
| 104 | |
| 105 | temp = RREG32_SMC(0xC0300E0C); |
| 106 | |
| 107 | if (temp) |
| 108 | actual_temp = (temp / 8) - 49; |
| 109 | else |
| 110 | actual_temp = 0; |
| 111 | |
| 112 | actual_temp = actual_temp * 1000; |
| 113 | |
| 114 | return actual_temp; |
| 115 | } |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 116 | |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 117 | /* |
| 118 | * Indirect registers accessor |
| 119 | */ |
| 120 | u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg) |
| 121 | { |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 122 | unsigned long flags; |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 123 | u32 r; |
| 124 | |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 125 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 126 | WREG32(PCIE_INDEX, reg); |
| 127 | (void)RREG32(PCIE_INDEX); |
| 128 | r = RREG32(PCIE_DATA); |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 129 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 130 | return r; |
| 131 | } |
| 132 | |
| 133 | void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
| 134 | { |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 135 | unsigned long flags; |
| 136 | |
| 137 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 138 | WREG32(PCIE_INDEX, reg); |
| 139 | (void)RREG32(PCIE_INDEX); |
| 140 | WREG32(PCIE_DATA, v); |
| 141 | (void)RREG32(PCIE_DATA); |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 142 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 143 | } |
| 144 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 145 | static const u32 spectre_rlc_save_restore_register_list[] = |
| 146 | { |
| 147 | (0x0e00 << 16) | (0xc12c >> 2), |
| 148 | 0x00000000, |
| 149 | (0x0e00 << 16) | (0xc140 >> 2), |
| 150 | 0x00000000, |
| 151 | (0x0e00 << 16) | (0xc150 >> 2), |
| 152 | 0x00000000, |
| 153 | (0x0e00 << 16) | (0xc15c >> 2), |
| 154 | 0x00000000, |
| 155 | (0x0e00 << 16) | (0xc168 >> 2), |
| 156 | 0x00000000, |
| 157 | (0x0e00 << 16) | (0xc170 >> 2), |
| 158 | 0x00000000, |
| 159 | (0x0e00 << 16) | (0xc178 >> 2), |
| 160 | 0x00000000, |
| 161 | (0x0e00 << 16) | (0xc204 >> 2), |
| 162 | 0x00000000, |
| 163 | (0x0e00 << 16) | (0xc2b4 >> 2), |
| 164 | 0x00000000, |
| 165 | (0x0e00 << 16) | (0xc2b8 >> 2), |
| 166 | 0x00000000, |
| 167 | (0x0e00 << 16) | (0xc2bc >> 2), |
| 168 | 0x00000000, |
| 169 | (0x0e00 << 16) | (0xc2c0 >> 2), |
| 170 | 0x00000000, |
| 171 | (0x0e00 << 16) | (0x8228 >> 2), |
| 172 | 0x00000000, |
| 173 | (0x0e00 << 16) | (0x829c >> 2), |
| 174 | 0x00000000, |
| 175 | (0x0e00 << 16) | (0x869c >> 2), |
| 176 | 0x00000000, |
| 177 | (0x0600 << 16) | (0x98f4 >> 2), |
| 178 | 0x00000000, |
| 179 | (0x0e00 << 16) | (0x98f8 >> 2), |
| 180 | 0x00000000, |
| 181 | (0x0e00 << 16) | (0x9900 >> 2), |
| 182 | 0x00000000, |
| 183 | (0x0e00 << 16) | (0xc260 >> 2), |
| 184 | 0x00000000, |
| 185 | (0x0e00 << 16) | (0x90e8 >> 2), |
| 186 | 0x00000000, |
| 187 | (0x0e00 << 16) | (0x3c000 >> 2), |
| 188 | 0x00000000, |
| 189 | (0x0e00 << 16) | (0x3c00c >> 2), |
| 190 | 0x00000000, |
| 191 | (0x0e00 << 16) | (0x8c1c >> 2), |
| 192 | 0x00000000, |
| 193 | (0x0e00 << 16) | (0x9700 >> 2), |
| 194 | 0x00000000, |
| 195 | (0x0e00 << 16) | (0xcd20 >> 2), |
| 196 | 0x00000000, |
| 197 | (0x4e00 << 16) | (0xcd20 >> 2), |
| 198 | 0x00000000, |
| 199 | (0x5e00 << 16) | (0xcd20 >> 2), |
| 200 | 0x00000000, |
| 201 | (0x6e00 << 16) | (0xcd20 >> 2), |
| 202 | 0x00000000, |
| 203 | (0x7e00 << 16) | (0xcd20 >> 2), |
| 204 | 0x00000000, |
| 205 | (0x8e00 << 16) | (0xcd20 >> 2), |
| 206 | 0x00000000, |
| 207 | (0x9e00 << 16) | (0xcd20 >> 2), |
| 208 | 0x00000000, |
| 209 | (0xae00 << 16) | (0xcd20 >> 2), |
| 210 | 0x00000000, |
| 211 | (0xbe00 << 16) | (0xcd20 >> 2), |
| 212 | 0x00000000, |
| 213 | (0x0e00 << 16) | (0x89bc >> 2), |
| 214 | 0x00000000, |
| 215 | (0x0e00 << 16) | (0x8900 >> 2), |
| 216 | 0x00000000, |
| 217 | 0x3, |
| 218 | (0x0e00 << 16) | (0xc130 >> 2), |
| 219 | 0x00000000, |
| 220 | (0x0e00 << 16) | (0xc134 >> 2), |
| 221 | 0x00000000, |
| 222 | (0x0e00 << 16) | (0xc1fc >> 2), |
| 223 | 0x00000000, |
| 224 | (0x0e00 << 16) | (0xc208 >> 2), |
| 225 | 0x00000000, |
| 226 | (0x0e00 << 16) | (0xc264 >> 2), |
| 227 | 0x00000000, |
| 228 | (0x0e00 << 16) | (0xc268 >> 2), |
| 229 | 0x00000000, |
| 230 | (0x0e00 << 16) | (0xc26c >> 2), |
| 231 | 0x00000000, |
| 232 | (0x0e00 << 16) | (0xc270 >> 2), |
| 233 | 0x00000000, |
| 234 | (0x0e00 << 16) | (0xc274 >> 2), |
| 235 | 0x00000000, |
| 236 | (0x0e00 << 16) | (0xc278 >> 2), |
| 237 | 0x00000000, |
| 238 | (0x0e00 << 16) | (0xc27c >> 2), |
| 239 | 0x00000000, |
| 240 | (0x0e00 << 16) | (0xc280 >> 2), |
| 241 | 0x00000000, |
| 242 | (0x0e00 << 16) | (0xc284 >> 2), |
| 243 | 0x00000000, |
| 244 | (0x0e00 << 16) | (0xc288 >> 2), |
| 245 | 0x00000000, |
| 246 | (0x0e00 << 16) | (0xc28c >> 2), |
| 247 | 0x00000000, |
| 248 | (0x0e00 << 16) | (0xc290 >> 2), |
| 249 | 0x00000000, |
| 250 | (0x0e00 << 16) | (0xc294 >> 2), |
| 251 | 0x00000000, |
| 252 | (0x0e00 << 16) | (0xc298 >> 2), |
| 253 | 0x00000000, |
| 254 | (0x0e00 << 16) | (0xc29c >> 2), |
| 255 | 0x00000000, |
| 256 | (0x0e00 << 16) | (0xc2a0 >> 2), |
| 257 | 0x00000000, |
| 258 | (0x0e00 << 16) | (0xc2a4 >> 2), |
| 259 | 0x00000000, |
| 260 | (0x0e00 << 16) | (0xc2a8 >> 2), |
| 261 | 0x00000000, |
| 262 | (0x0e00 << 16) | (0xc2ac >> 2), |
| 263 | 0x00000000, |
| 264 | (0x0e00 << 16) | (0xc2b0 >> 2), |
| 265 | 0x00000000, |
| 266 | (0x0e00 << 16) | (0x301d0 >> 2), |
| 267 | 0x00000000, |
| 268 | (0x0e00 << 16) | (0x30238 >> 2), |
| 269 | 0x00000000, |
| 270 | (0x0e00 << 16) | (0x30250 >> 2), |
| 271 | 0x00000000, |
| 272 | (0x0e00 << 16) | (0x30254 >> 2), |
| 273 | 0x00000000, |
| 274 | (0x0e00 << 16) | (0x30258 >> 2), |
| 275 | 0x00000000, |
| 276 | (0x0e00 << 16) | (0x3025c >> 2), |
| 277 | 0x00000000, |
| 278 | (0x4e00 << 16) | (0xc900 >> 2), |
| 279 | 0x00000000, |
| 280 | (0x5e00 << 16) | (0xc900 >> 2), |
| 281 | 0x00000000, |
| 282 | (0x6e00 << 16) | (0xc900 >> 2), |
| 283 | 0x00000000, |
| 284 | (0x7e00 << 16) | (0xc900 >> 2), |
| 285 | 0x00000000, |
| 286 | (0x8e00 << 16) | (0xc900 >> 2), |
| 287 | 0x00000000, |
| 288 | (0x9e00 << 16) | (0xc900 >> 2), |
| 289 | 0x00000000, |
| 290 | (0xae00 << 16) | (0xc900 >> 2), |
| 291 | 0x00000000, |
| 292 | (0xbe00 << 16) | (0xc900 >> 2), |
| 293 | 0x00000000, |
| 294 | (0x4e00 << 16) | (0xc904 >> 2), |
| 295 | 0x00000000, |
| 296 | (0x5e00 << 16) | (0xc904 >> 2), |
| 297 | 0x00000000, |
| 298 | (0x6e00 << 16) | (0xc904 >> 2), |
| 299 | 0x00000000, |
| 300 | (0x7e00 << 16) | (0xc904 >> 2), |
| 301 | 0x00000000, |
| 302 | (0x8e00 << 16) | (0xc904 >> 2), |
| 303 | 0x00000000, |
| 304 | (0x9e00 << 16) | (0xc904 >> 2), |
| 305 | 0x00000000, |
| 306 | (0xae00 << 16) | (0xc904 >> 2), |
| 307 | 0x00000000, |
| 308 | (0xbe00 << 16) | (0xc904 >> 2), |
| 309 | 0x00000000, |
| 310 | (0x4e00 << 16) | (0xc908 >> 2), |
| 311 | 0x00000000, |
| 312 | (0x5e00 << 16) | (0xc908 >> 2), |
| 313 | 0x00000000, |
| 314 | (0x6e00 << 16) | (0xc908 >> 2), |
| 315 | 0x00000000, |
| 316 | (0x7e00 << 16) | (0xc908 >> 2), |
| 317 | 0x00000000, |
| 318 | (0x8e00 << 16) | (0xc908 >> 2), |
| 319 | 0x00000000, |
| 320 | (0x9e00 << 16) | (0xc908 >> 2), |
| 321 | 0x00000000, |
| 322 | (0xae00 << 16) | (0xc908 >> 2), |
| 323 | 0x00000000, |
| 324 | (0xbe00 << 16) | (0xc908 >> 2), |
| 325 | 0x00000000, |
| 326 | (0x4e00 << 16) | (0xc90c >> 2), |
| 327 | 0x00000000, |
| 328 | (0x5e00 << 16) | (0xc90c >> 2), |
| 329 | 0x00000000, |
| 330 | (0x6e00 << 16) | (0xc90c >> 2), |
| 331 | 0x00000000, |
| 332 | (0x7e00 << 16) | (0xc90c >> 2), |
| 333 | 0x00000000, |
| 334 | (0x8e00 << 16) | (0xc90c >> 2), |
| 335 | 0x00000000, |
| 336 | (0x9e00 << 16) | (0xc90c >> 2), |
| 337 | 0x00000000, |
| 338 | (0xae00 << 16) | (0xc90c >> 2), |
| 339 | 0x00000000, |
| 340 | (0xbe00 << 16) | (0xc90c >> 2), |
| 341 | 0x00000000, |
| 342 | (0x4e00 << 16) | (0xc910 >> 2), |
| 343 | 0x00000000, |
| 344 | (0x5e00 << 16) | (0xc910 >> 2), |
| 345 | 0x00000000, |
| 346 | (0x6e00 << 16) | (0xc910 >> 2), |
| 347 | 0x00000000, |
| 348 | (0x7e00 << 16) | (0xc910 >> 2), |
| 349 | 0x00000000, |
| 350 | (0x8e00 << 16) | (0xc910 >> 2), |
| 351 | 0x00000000, |
| 352 | (0x9e00 << 16) | (0xc910 >> 2), |
| 353 | 0x00000000, |
| 354 | (0xae00 << 16) | (0xc910 >> 2), |
| 355 | 0x00000000, |
| 356 | (0xbe00 << 16) | (0xc910 >> 2), |
| 357 | 0x00000000, |
| 358 | (0x0e00 << 16) | (0xc99c >> 2), |
| 359 | 0x00000000, |
| 360 | (0x0e00 << 16) | (0x9834 >> 2), |
| 361 | 0x00000000, |
| 362 | (0x0000 << 16) | (0x30f00 >> 2), |
| 363 | 0x00000000, |
| 364 | (0x0001 << 16) | (0x30f00 >> 2), |
| 365 | 0x00000000, |
| 366 | (0x0000 << 16) | (0x30f04 >> 2), |
| 367 | 0x00000000, |
| 368 | (0x0001 << 16) | (0x30f04 >> 2), |
| 369 | 0x00000000, |
| 370 | (0x0000 << 16) | (0x30f08 >> 2), |
| 371 | 0x00000000, |
| 372 | (0x0001 << 16) | (0x30f08 >> 2), |
| 373 | 0x00000000, |
| 374 | (0x0000 << 16) | (0x30f0c >> 2), |
| 375 | 0x00000000, |
| 376 | (0x0001 << 16) | (0x30f0c >> 2), |
| 377 | 0x00000000, |
| 378 | (0x0600 << 16) | (0x9b7c >> 2), |
| 379 | 0x00000000, |
| 380 | (0x0e00 << 16) | (0x8a14 >> 2), |
| 381 | 0x00000000, |
| 382 | (0x0e00 << 16) | (0x8a18 >> 2), |
| 383 | 0x00000000, |
| 384 | (0x0600 << 16) | (0x30a00 >> 2), |
| 385 | 0x00000000, |
| 386 | (0x0e00 << 16) | (0x8bf0 >> 2), |
| 387 | 0x00000000, |
| 388 | (0x0e00 << 16) | (0x8bcc >> 2), |
| 389 | 0x00000000, |
| 390 | (0x0e00 << 16) | (0x8b24 >> 2), |
| 391 | 0x00000000, |
| 392 | (0x0e00 << 16) | (0x30a04 >> 2), |
| 393 | 0x00000000, |
| 394 | (0x0600 << 16) | (0x30a10 >> 2), |
| 395 | 0x00000000, |
| 396 | (0x0600 << 16) | (0x30a14 >> 2), |
| 397 | 0x00000000, |
| 398 | (0x0600 << 16) | (0x30a18 >> 2), |
| 399 | 0x00000000, |
| 400 | (0x0600 << 16) | (0x30a2c >> 2), |
| 401 | 0x00000000, |
| 402 | (0x0e00 << 16) | (0xc700 >> 2), |
| 403 | 0x00000000, |
| 404 | (0x0e00 << 16) | (0xc704 >> 2), |
| 405 | 0x00000000, |
| 406 | (0x0e00 << 16) | (0xc708 >> 2), |
| 407 | 0x00000000, |
| 408 | (0x0e00 << 16) | (0xc768 >> 2), |
| 409 | 0x00000000, |
| 410 | (0x0400 << 16) | (0xc770 >> 2), |
| 411 | 0x00000000, |
| 412 | (0x0400 << 16) | (0xc774 >> 2), |
| 413 | 0x00000000, |
| 414 | (0x0400 << 16) | (0xc778 >> 2), |
| 415 | 0x00000000, |
| 416 | (0x0400 << 16) | (0xc77c >> 2), |
| 417 | 0x00000000, |
| 418 | (0x0400 << 16) | (0xc780 >> 2), |
| 419 | 0x00000000, |
| 420 | (0x0400 << 16) | (0xc784 >> 2), |
| 421 | 0x00000000, |
| 422 | (0x0400 << 16) | (0xc788 >> 2), |
| 423 | 0x00000000, |
| 424 | (0x0400 << 16) | (0xc78c >> 2), |
| 425 | 0x00000000, |
| 426 | (0x0400 << 16) | (0xc798 >> 2), |
| 427 | 0x00000000, |
| 428 | (0x0400 << 16) | (0xc79c >> 2), |
| 429 | 0x00000000, |
| 430 | (0x0400 << 16) | (0xc7a0 >> 2), |
| 431 | 0x00000000, |
| 432 | (0x0400 << 16) | (0xc7a4 >> 2), |
| 433 | 0x00000000, |
| 434 | (0x0400 << 16) | (0xc7a8 >> 2), |
| 435 | 0x00000000, |
| 436 | (0x0400 << 16) | (0xc7ac >> 2), |
| 437 | 0x00000000, |
| 438 | (0x0400 << 16) | (0xc7b0 >> 2), |
| 439 | 0x00000000, |
| 440 | (0x0400 << 16) | (0xc7b4 >> 2), |
| 441 | 0x00000000, |
| 442 | (0x0e00 << 16) | (0x9100 >> 2), |
| 443 | 0x00000000, |
| 444 | (0x0e00 << 16) | (0x3c010 >> 2), |
| 445 | 0x00000000, |
| 446 | (0x0e00 << 16) | (0x92a8 >> 2), |
| 447 | 0x00000000, |
| 448 | (0x0e00 << 16) | (0x92ac >> 2), |
| 449 | 0x00000000, |
| 450 | (0x0e00 << 16) | (0x92b4 >> 2), |
| 451 | 0x00000000, |
| 452 | (0x0e00 << 16) | (0x92b8 >> 2), |
| 453 | 0x00000000, |
| 454 | (0x0e00 << 16) | (0x92bc >> 2), |
| 455 | 0x00000000, |
| 456 | (0x0e00 << 16) | (0x92c0 >> 2), |
| 457 | 0x00000000, |
| 458 | (0x0e00 << 16) | (0x92c4 >> 2), |
| 459 | 0x00000000, |
| 460 | (0x0e00 << 16) | (0x92c8 >> 2), |
| 461 | 0x00000000, |
| 462 | (0x0e00 << 16) | (0x92cc >> 2), |
| 463 | 0x00000000, |
| 464 | (0x0e00 << 16) | (0x92d0 >> 2), |
| 465 | 0x00000000, |
| 466 | (0x0e00 << 16) | (0x8c00 >> 2), |
| 467 | 0x00000000, |
| 468 | (0x0e00 << 16) | (0x8c04 >> 2), |
| 469 | 0x00000000, |
| 470 | (0x0e00 << 16) | (0x8c20 >> 2), |
| 471 | 0x00000000, |
| 472 | (0x0e00 << 16) | (0x8c38 >> 2), |
| 473 | 0x00000000, |
| 474 | (0x0e00 << 16) | (0x8c3c >> 2), |
| 475 | 0x00000000, |
| 476 | (0x0e00 << 16) | (0xae00 >> 2), |
| 477 | 0x00000000, |
| 478 | (0x0e00 << 16) | (0x9604 >> 2), |
| 479 | 0x00000000, |
| 480 | (0x0e00 << 16) | (0xac08 >> 2), |
| 481 | 0x00000000, |
| 482 | (0x0e00 << 16) | (0xac0c >> 2), |
| 483 | 0x00000000, |
| 484 | (0x0e00 << 16) | (0xac10 >> 2), |
| 485 | 0x00000000, |
| 486 | (0x0e00 << 16) | (0xac14 >> 2), |
| 487 | 0x00000000, |
| 488 | (0x0e00 << 16) | (0xac58 >> 2), |
| 489 | 0x00000000, |
| 490 | (0x0e00 << 16) | (0xac68 >> 2), |
| 491 | 0x00000000, |
| 492 | (0x0e00 << 16) | (0xac6c >> 2), |
| 493 | 0x00000000, |
| 494 | (0x0e00 << 16) | (0xac70 >> 2), |
| 495 | 0x00000000, |
| 496 | (0x0e00 << 16) | (0xac74 >> 2), |
| 497 | 0x00000000, |
| 498 | (0x0e00 << 16) | (0xac78 >> 2), |
| 499 | 0x00000000, |
| 500 | (0x0e00 << 16) | (0xac7c >> 2), |
| 501 | 0x00000000, |
| 502 | (0x0e00 << 16) | (0xac80 >> 2), |
| 503 | 0x00000000, |
| 504 | (0x0e00 << 16) | (0xac84 >> 2), |
| 505 | 0x00000000, |
| 506 | (0x0e00 << 16) | (0xac88 >> 2), |
| 507 | 0x00000000, |
| 508 | (0x0e00 << 16) | (0xac8c >> 2), |
| 509 | 0x00000000, |
| 510 | (0x0e00 << 16) | (0x970c >> 2), |
| 511 | 0x00000000, |
| 512 | (0x0e00 << 16) | (0x9714 >> 2), |
| 513 | 0x00000000, |
| 514 | (0x0e00 << 16) | (0x9718 >> 2), |
| 515 | 0x00000000, |
| 516 | (0x0e00 << 16) | (0x971c >> 2), |
| 517 | 0x00000000, |
| 518 | (0x0e00 << 16) | (0x31068 >> 2), |
| 519 | 0x00000000, |
| 520 | (0x4e00 << 16) | (0x31068 >> 2), |
| 521 | 0x00000000, |
| 522 | (0x5e00 << 16) | (0x31068 >> 2), |
| 523 | 0x00000000, |
| 524 | (0x6e00 << 16) | (0x31068 >> 2), |
| 525 | 0x00000000, |
| 526 | (0x7e00 << 16) | (0x31068 >> 2), |
| 527 | 0x00000000, |
| 528 | (0x8e00 << 16) | (0x31068 >> 2), |
| 529 | 0x00000000, |
| 530 | (0x9e00 << 16) | (0x31068 >> 2), |
| 531 | 0x00000000, |
| 532 | (0xae00 << 16) | (0x31068 >> 2), |
| 533 | 0x00000000, |
| 534 | (0xbe00 << 16) | (0x31068 >> 2), |
| 535 | 0x00000000, |
| 536 | (0x0e00 << 16) | (0xcd10 >> 2), |
| 537 | 0x00000000, |
| 538 | (0x0e00 << 16) | (0xcd14 >> 2), |
| 539 | 0x00000000, |
| 540 | (0x0e00 << 16) | (0x88b0 >> 2), |
| 541 | 0x00000000, |
| 542 | (0x0e00 << 16) | (0x88b4 >> 2), |
| 543 | 0x00000000, |
| 544 | (0x0e00 << 16) | (0x88b8 >> 2), |
| 545 | 0x00000000, |
| 546 | (0x0e00 << 16) | (0x88bc >> 2), |
| 547 | 0x00000000, |
| 548 | (0x0400 << 16) | (0x89c0 >> 2), |
| 549 | 0x00000000, |
| 550 | (0x0e00 << 16) | (0x88c4 >> 2), |
| 551 | 0x00000000, |
| 552 | (0x0e00 << 16) | (0x88c8 >> 2), |
| 553 | 0x00000000, |
| 554 | (0x0e00 << 16) | (0x88d0 >> 2), |
| 555 | 0x00000000, |
| 556 | (0x0e00 << 16) | (0x88d4 >> 2), |
| 557 | 0x00000000, |
| 558 | (0x0e00 << 16) | (0x88d8 >> 2), |
| 559 | 0x00000000, |
| 560 | (0x0e00 << 16) | (0x8980 >> 2), |
| 561 | 0x00000000, |
| 562 | (0x0e00 << 16) | (0x30938 >> 2), |
| 563 | 0x00000000, |
| 564 | (0x0e00 << 16) | (0x3093c >> 2), |
| 565 | 0x00000000, |
| 566 | (0x0e00 << 16) | (0x30940 >> 2), |
| 567 | 0x00000000, |
| 568 | (0x0e00 << 16) | (0x89a0 >> 2), |
| 569 | 0x00000000, |
| 570 | (0x0e00 << 16) | (0x30900 >> 2), |
| 571 | 0x00000000, |
| 572 | (0x0e00 << 16) | (0x30904 >> 2), |
| 573 | 0x00000000, |
| 574 | (0x0e00 << 16) | (0x89b4 >> 2), |
| 575 | 0x00000000, |
| 576 | (0x0e00 << 16) | (0x3c210 >> 2), |
| 577 | 0x00000000, |
| 578 | (0x0e00 << 16) | (0x3c214 >> 2), |
| 579 | 0x00000000, |
| 580 | (0x0e00 << 16) | (0x3c218 >> 2), |
| 581 | 0x00000000, |
| 582 | (0x0e00 << 16) | (0x8904 >> 2), |
| 583 | 0x00000000, |
| 584 | 0x5, |
| 585 | (0x0e00 << 16) | (0x8c28 >> 2), |
| 586 | (0x0e00 << 16) | (0x8c2c >> 2), |
| 587 | (0x0e00 << 16) | (0x8c30 >> 2), |
| 588 | (0x0e00 << 16) | (0x8c34 >> 2), |
| 589 | (0x0e00 << 16) | (0x9600 >> 2), |
| 590 | }; |
| 591 | |
| 592 | static const u32 kalindi_rlc_save_restore_register_list[] = |
| 593 | { |
| 594 | (0x0e00 << 16) | (0xc12c >> 2), |
| 595 | 0x00000000, |
| 596 | (0x0e00 << 16) | (0xc140 >> 2), |
| 597 | 0x00000000, |
| 598 | (0x0e00 << 16) | (0xc150 >> 2), |
| 599 | 0x00000000, |
| 600 | (0x0e00 << 16) | (0xc15c >> 2), |
| 601 | 0x00000000, |
| 602 | (0x0e00 << 16) | (0xc168 >> 2), |
| 603 | 0x00000000, |
| 604 | (0x0e00 << 16) | (0xc170 >> 2), |
| 605 | 0x00000000, |
| 606 | (0x0e00 << 16) | (0xc204 >> 2), |
| 607 | 0x00000000, |
| 608 | (0x0e00 << 16) | (0xc2b4 >> 2), |
| 609 | 0x00000000, |
| 610 | (0x0e00 << 16) | (0xc2b8 >> 2), |
| 611 | 0x00000000, |
| 612 | (0x0e00 << 16) | (0xc2bc >> 2), |
| 613 | 0x00000000, |
| 614 | (0x0e00 << 16) | (0xc2c0 >> 2), |
| 615 | 0x00000000, |
| 616 | (0x0e00 << 16) | (0x8228 >> 2), |
| 617 | 0x00000000, |
| 618 | (0x0e00 << 16) | (0x829c >> 2), |
| 619 | 0x00000000, |
| 620 | (0x0e00 << 16) | (0x869c >> 2), |
| 621 | 0x00000000, |
| 622 | (0x0600 << 16) | (0x98f4 >> 2), |
| 623 | 0x00000000, |
| 624 | (0x0e00 << 16) | (0x98f8 >> 2), |
| 625 | 0x00000000, |
| 626 | (0x0e00 << 16) | (0x9900 >> 2), |
| 627 | 0x00000000, |
| 628 | (0x0e00 << 16) | (0xc260 >> 2), |
| 629 | 0x00000000, |
| 630 | (0x0e00 << 16) | (0x90e8 >> 2), |
| 631 | 0x00000000, |
| 632 | (0x0e00 << 16) | (0x3c000 >> 2), |
| 633 | 0x00000000, |
| 634 | (0x0e00 << 16) | (0x3c00c >> 2), |
| 635 | 0x00000000, |
| 636 | (0x0e00 << 16) | (0x8c1c >> 2), |
| 637 | 0x00000000, |
| 638 | (0x0e00 << 16) | (0x9700 >> 2), |
| 639 | 0x00000000, |
| 640 | (0x0e00 << 16) | (0xcd20 >> 2), |
| 641 | 0x00000000, |
| 642 | (0x4e00 << 16) | (0xcd20 >> 2), |
| 643 | 0x00000000, |
| 644 | (0x5e00 << 16) | (0xcd20 >> 2), |
| 645 | 0x00000000, |
| 646 | (0x6e00 << 16) | (0xcd20 >> 2), |
| 647 | 0x00000000, |
| 648 | (0x7e00 << 16) | (0xcd20 >> 2), |
| 649 | 0x00000000, |
| 650 | (0x0e00 << 16) | (0x89bc >> 2), |
| 651 | 0x00000000, |
| 652 | (0x0e00 << 16) | (0x8900 >> 2), |
| 653 | 0x00000000, |
| 654 | 0x3, |
| 655 | (0x0e00 << 16) | (0xc130 >> 2), |
| 656 | 0x00000000, |
| 657 | (0x0e00 << 16) | (0xc134 >> 2), |
| 658 | 0x00000000, |
| 659 | (0x0e00 << 16) | (0xc1fc >> 2), |
| 660 | 0x00000000, |
| 661 | (0x0e00 << 16) | (0xc208 >> 2), |
| 662 | 0x00000000, |
| 663 | (0x0e00 << 16) | (0xc264 >> 2), |
| 664 | 0x00000000, |
| 665 | (0x0e00 << 16) | (0xc268 >> 2), |
| 666 | 0x00000000, |
| 667 | (0x0e00 << 16) | (0xc26c >> 2), |
| 668 | 0x00000000, |
| 669 | (0x0e00 << 16) | (0xc270 >> 2), |
| 670 | 0x00000000, |
| 671 | (0x0e00 << 16) | (0xc274 >> 2), |
| 672 | 0x00000000, |
| 673 | (0x0e00 << 16) | (0xc28c >> 2), |
| 674 | 0x00000000, |
| 675 | (0x0e00 << 16) | (0xc290 >> 2), |
| 676 | 0x00000000, |
| 677 | (0x0e00 << 16) | (0xc294 >> 2), |
| 678 | 0x00000000, |
| 679 | (0x0e00 << 16) | (0xc298 >> 2), |
| 680 | 0x00000000, |
| 681 | (0x0e00 << 16) | (0xc2a0 >> 2), |
| 682 | 0x00000000, |
| 683 | (0x0e00 << 16) | (0xc2a4 >> 2), |
| 684 | 0x00000000, |
| 685 | (0x0e00 << 16) | (0xc2a8 >> 2), |
| 686 | 0x00000000, |
| 687 | (0x0e00 << 16) | (0xc2ac >> 2), |
| 688 | 0x00000000, |
| 689 | (0x0e00 << 16) | (0x301d0 >> 2), |
| 690 | 0x00000000, |
| 691 | (0x0e00 << 16) | (0x30238 >> 2), |
| 692 | 0x00000000, |
| 693 | (0x0e00 << 16) | (0x30250 >> 2), |
| 694 | 0x00000000, |
| 695 | (0x0e00 << 16) | (0x30254 >> 2), |
| 696 | 0x00000000, |
| 697 | (0x0e00 << 16) | (0x30258 >> 2), |
| 698 | 0x00000000, |
| 699 | (0x0e00 << 16) | (0x3025c >> 2), |
| 700 | 0x00000000, |
| 701 | (0x4e00 << 16) | (0xc900 >> 2), |
| 702 | 0x00000000, |
| 703 | (0x5e00 << 16) | (0xc900 >> 2), |
| 704 | 0x00000000, |
| 705 | (0x6e00 << 16) | (0xc900 >> 2), |
| 706 | 0x00000000, |
| 707 | (0x7e00 << 16) | (0xc900 >> 2), |
| 708 | 0x00000000, |
| 709 | (0x4e00 << 16) | (0xc904 >> 2), |
| 710 | 0x00000000, |
| 711 | (0x5e00 << 16) | (0xc904 >> 2), |
| 712 | 0x00000000, |
| 713 | (0x6e00 << 16) | (0xc904 >> 2), |
| 714 | 0x00000000, |
| 715 | (0x7e00 << 16) | (0xc904 >> 2), |
| 716 | 0x00000000, |
| 717 | (0x4e00 << 16) | (0xc908 >> 2), |
| 718 | 0x00000000, |
| 719 | (0x5e00 << 16) | (0xc908 >> 2), |
| 720 | 0x00000000, |
| 721 | (0x6e00 << 16) | (0xc908 >> 2), |
| 722 | 0x00000000, |
| 723 | (0x7e00 << 16) | (0xc908 >> 2), |
| 724 | 0x00000000, |
| 725 | (0x4e00 << 16) | (0xc90c >> 2), |
| 726 | 0x00000000, |
| 727 | (0x5e00 << 16) | (0xc90c >> 2), |
| 728 | 0x00000000, |
| 729 | (0x6e00 << 16) | (0xc90c >> 2), |
| 730 | 0x00000000, |
| 731 | (0x7e00 << 16) | (0xc90c >> 2), |
| 732 | 0x00000000, |
| 733 | (0x4e00 << 16) | (0xc910 >> 2), |
| 734 | 0x00000000, |
| 735 | (0x5e00 << 16) | (0xc910 >> 2), |
| 736 | 0x00000000, |
| 737 | (0x6e00 << 16) | (0xc910 >> 2), |
| 738 | 0x00000000, |
| 739 | (0x7e00 << 16) | (0xc910 >> 2), |
| 740 | 0x00000000, |
| 741 | (0x0e00 << 16) | (0xc99c >> 2), |
| 742 | 0x00000000, |
| 743 | (0x0e00 << 16) | (0x9834 >> 2), |
| 744 | 0x00000000, |
| 745 | (0x0000 << 16) | (0x30f00 >> 2), |
| 746 | 0x00000000, |
| 747 | (0x0000 << 16) | (0x30f04 >> 2), |
| 748 | 0x00000000, |
| 749 | (0x0000 << 16) | (0x30f08 >> 2), |
| 750 | 0x00000000, |
| 751 | (0x0000 << 16) | (0x30f0c >> 2), |
| 752 | 0x00000000, |
| 753 | (0x0600 << 16) | (0x9b7c >> 2), |
| 754 | 0x00000000, |
| 755 | (0x0e00 << 16) | (0x8a14 >> 2), |
| 756 | 0x00000000, |
| 757 | (0x0e00 << 16) | (0x8a18 >> 2), |
| 758 | 0x00000000, |
| 759 | (0x0600 << 16) | (0x30a00 >> 2), |
| 760 | 0x00000000, |
| 761 | (0x0e00 << 16) | (0x8bf0 >> 2), |
| 762 | 0x00000000, |
| 763 | (0x0e00 << 16) | (0x8bcc >> 2), |
| 764 | 0x00000000, |
| 765 | (0x0e00 << 16) | (0x8b24 >> 2), |
| 766 | 0x00000000, |
| 767 | (0x0e00 << 16) | (0x30a04 >> 2), |
| 768 | 0x00000000, |
| 769 | (0x0600 << 16) | (0x30a10 >> 2), |
| 770 | 0x00000000, |
| 771 | (0x0600 << 16) | (0x30a14 >> 2), |
| 772 | 0x00000000, |
| 773 | (0x0600 << 16) | (0x30a18 >> 2), |
| 774 | 0x00000000, |
| 775 | (0x0600 << 16) | (0x30a2c >> 2), |
| 776 | 0x00000000, |
| 777 | (0x0e00 << 16) | (0xc700 >> 2), |
| 778 | 0x00000000, |
| 779 | (0x0e00 << 16) | (0xc704 >> 2), |
| 780 | 0x00000000, |
| 781 | (0x0e00 << 16) | (0xc708 >> 2), |
| 782 | 0x00000000, |
| 783 | (0x0e00 << 16) | (0xc768 >> 2), |
| 784 | 0x00000000, |
| 785 | (0x0400 << 16) | (0xc770 >> 2), |
| 786 | 0x00000000, |
| 787 | (0x0400 << 16) | (0xc774 >> 2), |
| 788 | 0x00000000, |
| 789 | (0x0400 << 16) | (0xc798 >> 2), |
| 790 | 0x00000000, |
| 791 | (0x0400 << 16) | (0xc79c >> 2), |
| 792 | 0x00000000, |
| 793 | (0x0e00 << 16) | (0x9100 >> 2), |
| 794 | 0x00000000, |
| 795 | (0x0e00 << 16) | (0x3c010 >> 2), |
| 796 | 0x00000000, |
| 797 | (0x0e00 << 16) | (0x8c00 >> 2), |
| 798 | 0x00000000, |
| 799 | (0x0e00 << 16) | (0x8c04 >> 2), |
| 800 | 0x00000000, |
| 801 | (0x0e00 << 16) | (0x8c20 >> 2), |
| 802 | 0x00000000, |
| 803 | (0x0e00 << 16) | (0x8c38 >> 2), |
| 804 | 0x00000000, |
| 805 | (0x0e00 << 16) | (0x8c3c >> 2), |
| 806 | 0x00000000, |
| 807 | (0x0e00 << 16) | (0xae00 >> 2), |
| 808 | 0x00000000, |
| 809 | (0x0e00 << 16) | (0x9604 >> 2), |
| 810 | 0x00000000, |
| 811 | (0x0e00 << 16) | (0xac08 >> 2), |
| 812 | 0x00000000, |
| 813 | (0x0e00 << 16) | (0xac0c >> 2), |
| 814 | 0x00000000, |
| 815 | (0x0e00 << 16) | (0xac10 >> 2), |
| 816 | 0x00000000, |
| 817 | (0x0e00 << 16) | (0xac14 >> 2), |
| 818 | 0x00000000, |
| 819 | (0x0e00 << 16) | (0xac58 >> 2), |
| 820 | 0x00000000, |
| 821 | (0x0e00 << 16) | (0xac68 >> 2), |
| 822 | 0x00000000, |
| 823 | (0x0e00 << 16) | (0xac6c >> 2), |
| 824 | 0x00000000, |
| 825 | (0x0e00 << 16) | (0xac70 >> 2), |
| 826 | 0x00000000, |
| 827 | (0x0e00 << 16) | (0xac74 >> 2), |
| 828 | 0x00000000, |
| 829 | (0x0e00 << 16) | (0xac78 >> 2), |
| 830 | 0x00000000, |
| 831 | (0x0e00 << 16) | (0xac7c >> 2), |
| 832 | 0x00000000, |
| 833 | (0x0e00 << 16) | (0xac80 >> 2), |
| 834 | 0x00000000, |
| 835 | (0x0e00 << 16) | (0xac84 >> 2), |
| 836 | 0x00000000, |
| 837 | (0x0e00 << 16) | (0xac88 >> 2), |
| 838 | 0x00000000, |
| 839 | (0x0e00 << 16) | (0xac8c >> 2), |
| 840 | 0x00000000, |
| 841 | (0x0e00 << 16) | (0x970c >> 2), |
| 842 | 0x00000000, |
| 843 | (0x0e00 << 16) | (0x9714 >> 2), |
| 844 | 0x00000000, |
| 845 | (0x0e00 << 16) | (0x9718 >> 2), |
| 846 | 0x00000000, |
| 847 | (0x0e00 << 16) | (0x971c >> 2), |
| 848 | 0x00000000, |
| 849 | (0x0e00 << 16) | (0x31068 >> 2), |
| 850 | 0x00000000, |
| 851 | (0x4e00 << 16) | (0x31068 >> 2), |
| 852 | 0x00000000, |
| 853 | (0x5e00 << 16) | (0x31068 >> 2), |
| 854 | 0x00000000, |
| 855 | (0x6e00 << 16) | (0x31068 >> 2), |
| 856 | 0x00000000, |
| 857 | (0x7e00 << 16) | (0x31068 >> 2), |
| 858 | 0x00000000, |
| 859 | (0x0e00 << 16) | (0xcd10 >> 2), |
| 860 | 0x00000000, |
| 861 | (0x0e00 << 16) | (0xcd14 >> 2), |
| 862 | 0x00000000, |
| 863 | (0x0e00 << 16) | (0x88b0 >> 2), |
| 864 | 0x00000000, |
| 865 | (0x0e00 << 16) | (0x88b4 >> 2), |
| 866 | 0x00000000, |
| 867 | (0x0e00 << 16) | (0x88b8 >> 2), |
| 868 | 0x00000000, |
| 869 | (0x0e00 << 16) | (0x88bc >> 2), |
| 870 | 0x00000000, |
| 871 | (0x0400 << 16) | (0x89c0 >> 2), |
| 872 | 0x00000000, |
| 873 | (0x0e00 << 16) | (0x88c4 >> 2), |
| 874 | 0x00000000, |
| 875 | (0x0e00 << 16) | (0x88c8 >> 2), |
| 876 | 0x00000000, |
| 877 | (0x0e00 << 16) | (0x88d0 >> 2), |
| 878 | 0x00000000, |
| 879 | (0x0e00 << 16) | (0x88d4 >> 2), |
| 880 | 0x00000000, |
| 881 | (0x0e00 << 16) | (0x88d8 >> 2), |
| 882 | 0x00000000, |
| 883 | (0x0e00 << 16) | (0x8980 >> 2), |
| 884 | 0x00000000, |
| 885 | (0x0e00 << 16) | (0x30938 >> 2), |
| 886 | 0x00000000, |
| 887 | (0x0e00 << 16) | (0x3093c >> 2), |
| 888 | 0x00000000, |
| 889 | (0x0e00 << 16) | (0x30940 >> 2), |
| 890 | 0x00000000, |
| 891 | (0x0e00 << 16) | (0x89a0 >> 2), |
| 892 | 0x00000000, |
| 893 | (0x0e00 << 16) | (0x30900 >> 2), |
| 894 | 0x00000000, |
| 895 | (0x0e00 << 16) | (0x30904 >> 2), |
| 896 | 0x00000000, |
| 897 | (0x0e00 << 16) | (0x89b4 >> 2), |
| 898 | 0x00000000, |
| 899 | (0x0e00 << 16) | (0x3e1fc >> 2), |
| 900 | 0x00000000, |
| 901 | (0x0e00 << 16) | (0x3c210 >> 2), |
| 902 | 0x00000000, |
| 903 | (0x0e00 << 16) | (0x3c214 >> 2), |
| 904 | 0x00000000, |
| 905 | (0x0e00 << 16) | (0x3c218 >> 2), |
| 906 | 0x00000000, |
| 907 | (0x0e00 << 16) | (0x8904 >> 2), |
| 908 | 0x00000000, |
| 909 | 0x5, |
| 910 | (0x0e00 << 16) | (0x8c28 >> 2), |
| 911 | (0x0e00 << 16) | (0x8c2c >> 2), |
| 912 | (0x0e00 << 16) | (0x8c30 >> 2), |
| 913 | (0x0e00 << 16) | (0x8c34 >> 2), |
| 914 | (0x0e00 << 16) | (0x9600 >> 2), |
| 915 | }; |
| 916 | |
Alex Deucher | 0aafd31 | 2013-04-09 14:43:30 -0400 | [diff] [blame] | 917 | static const u32 bonaire_golden_spm_registers[] = |
| 918 | { |
| 919 | 0x30800, 0xe0ffffff, 0xe0000000 |
| 920 | }; |
| 921 | |
| 922 | static const u32 bonaire_golden_common_registers[] = |
| 923 | { |
| 924 | 0xc770, 0xffffffff, 0x00000800, |
| 925 | 0xc774, 0xffffffff, 0x00000800, |
| 926 | 0xc798, 0xffffffff, 0x00007fbf, |
| 927 | 0xc79c, 0xffffffff, 0x00007faf |
| 928 | }; |
| 929 | |
| 930 | static const u32 bonaire_golden_registers[] = |
| 931 | { |
| 932 | 0x3354, 0x00000333, 0x00000333, |
| 933 | 0x3350, 0x000c0fc0, 0x00040200, |
| 934 | 0x9a10, 0x00010000, 0x00058208, |
| 935 | 0x3c000, 0xffff1fff, 0x00140000, |
| 936 | 0x3c200, 0xfdfc0fff, 0x00000100, |
| 937 | 0x3c234, 0x40000000, 0x40000200, |
| 938 | 0x9830, 0xffffffff, 0x00000000, |
| 939 | 0x9834, 0xf00fffff, 0x00000400, |
| 940 | 0x9838, 0x0002021c, 0x00020200, |
| 941 | 0xc78, 0x00000080, 0x00000000, |
| 942 | 0x5bb0, 0x000000f0, 0x00000070, |
| 943 | 0x5bc0, 0xf0311fff, 0x80300000, |
| 944 | 0x98f8, 0x73773777, 0x12010001, |
| 945 | 0x350c, 0x00810000, 0x408af000, |
| 946 | 0x7030, 0x31000111, 0x00000011, |
| 947 | 0x2f48, 0x73773777, 0x12010001, |
| 948 | 0x220c, 0x00007fb6, 0x0021a1b1, |
| 949 | 0x2210, 0x00007fb6, 0x002021b1, |
| 950 | 0x2180, 0x00007fb6, 0x00002191, |
| 951 | 0x2218, 0x00007fb6, 0x002121b1, |
| 952 | 0x221c, 0x00007fb6, 0x002021b1, |
| 953 | 0x21dc, 0x00007fb6, 0x00002191, |
| 954 | 0x21e0, 0x00007fb6, 0x00002191, |
| 955 | 0x3628, 0x0000003f, 0x0000000a, |
| 956 | 0x362c, 0x0000003f, 0x0000000a, |
| 957 | 0x2ae4, 0x00073ffe, 0x000022a2, |
| 958 | 0x240c, 0x000007ff, 0x00000000, |
| 959 | 0x8a14, 0xf000003f, 0x00000007, |
| 960 | 0x8bf0, 0x00002001, 0x00000001, |
| 961 | 0x8b24, 0xffffffff, 0x00ffffff, |
| 962 | 0x30a04, 0x0000ff0f, 0x00000000, |
| 963 | 0x28a4c, 0x07ffffff, 0x06000000, |
| 964 | 0x4d8, 0x00000fff, 0x00000100, |
| 965 | 0x3e78, 0x00000001, 0x00000002, |
| 966 | 0x9100, 0x03000000, 0x0362c688, |
| 967 | 0x8c00, 0x000000ff, 0x00000001, |
| 968 | 0xe40, 0x00001fff, 0x00001fff, |
| 969 | 0x9060, 0x0000007f, 0x00000020, |
| 970 | 0x9508, 0x00010000, 0x00010000, |
| 971 | 0xac14, 0x000003ff, 0x000000f3, |
| 972 | 0xac0c, 0xffffffff, 0x00001032 |
| 973 | }; |
| 974 | |
| 975 | static const u32 bonaire_mgcg_cgcg_init[] = |
| 976 | { |
| 977 | 0xc420, 0xffffffff, 0xfffffffc, |
| 978 | 0x30800, 0xffffffff, 0xe0000000, |
| 979 | 0x3c2a0, 0xffffffff, 0x00000100, |
| 980 | 0x3c208, 0xffffffff, 0x00000100, |
| 981 | 0x3c2c0, 0xffffffff, 0xc0000100, |
| 982 | 0x3c2c8, 0xffffffff, 0xc0000100, |
| 983 | 0x3c2c4, 0xffffffff, 0xc0000100, |
| 984 | 0x55e4, 0xffffffff, 0x00600100, |
| 985 | 0x3c280, 0xffffffff, 0x00000100, |
| 986 | 0x3c214, 0xffffffff, 0x06000100, |
| 987 | 0x3c220, 0xffffffff, 0x00000100, |
| 988 | 0x3c218, 0xffffffff, 0x06000100, |
| 989 | 0x3c204, 0xffffffff, 0x00000100, |
| 990 | 0x3c2e0, 0xffffffff, 0x00000100, |
| 991 | 0x3c224, 0xffffffff, 0x00000100, |
| 992 | 0x3c200, 0xffffffff, 0x00000100, |
| 993 | 0x3c230, 0xffffffff, 0x00000100, |
| 994 | 0x3c234, 0xffffffff, 0x00000100, |
| 995 | 0x3c250, 0xffffffff, 0x00000100, |
| 996 | 0x3c254, 0xffffffff, 0x00000100, |
| 997 | 0x3c258, 0xffffffff, 0x00000100, |
| 998 | 0x3c25c, 0xffffffff, 0x00000100, |
| 999 | 0x3c260, 0xffffffff, 0x00000100, |
| 1000 | 0x3c27c, 0xffffffff, 0x00000100, |
| 1001 | 0x3c278, 0xffffffff, 0x00000100, |
| 1002 | 0x3c210, 0xffffffff, 0x06000100, |
| 1003 | 0x3c290, 0xffffffff, 0x00000100, |
| 1004 | 0x3c274, 0xffffffff, 0x00000100, |
| 1005 | 0x3c2b4, 0xffffffff, 0x00000100, |
| 1006 | 0x3c2b0, 0xffffffff, 0x00000100, |
| 1007 | 0x3c270, 0xffffffff, 0x00000100, |
| 1008 | 0x30800, 0xffffffff, 0xe0000000, |
| 1009 | 0x3c020, 0xffffffff, 0x00010000, |
| 1010 | 0x3c024, 0xffffffff, 0x00030002, |
| 1011 | 0x3c028, 0xffffffff, 0x00040007, |
| 1012 | 0x3c02c, 0xffffffff, 0x00060005, |
| 1013 | 0x3c030, 0xffffffff, 0x00090008, |
| 1014 | 0x3c034, 0xffffffff, 0x00010000, |
| 1015 | 0x3c038, 0xffffffff, 0x00030002, |
| 1016 | 0x3c03c, 0xffffffff, 0x00040007, |
| 1017 | 0x3c040, 0xffffffff, 0x00060005, |
| 1018 | 0x3c044, 0xffffffff, 0x00090008, |
| 1019 | 0x3c048, 0xffffffff, 0x00010000, |
| 1020 | 0x3c04c, 0xffffffff, 0x00030002, |
| 1021 | 0x3c050, 0xffffffff, 0x00040007, |
| 1022 | 0x3c054, 0xffffffff, 0x00060005, |
| 1023 | 0x3c058, 0xffffffff, 0x00090008, |
| 1024 | 0x3c05c, 0xffffffff, 0x00010000, |
| 1025 | 0x3c060, 0xffffffff, 0x00030002, |
| 1026 | 0x3c064, 0xffffffff, 0x00040007, |
| 1027 | 0x3c068, 0xffffffff, 0x00060005, |
| 1028 | 0x3c06c, 0xffffffff, 0x00090008, |
| 1029 | 0x3c070, 0xffffffff, 0x00010000, |
| 1030 | 0x3c074, 0xffffffff, 0x00030002, |
| 1031 | 0x3c078, 0xffffffff, 0x00040007, |
| 1032 | 0x3c07c, 0xffffffff, 0x00060005, |
| 1033 | 0x3c080, 0xffffffff, 0x00090008, |
| 1034 | 0x3c084, 0xffffffff, 0x00010000, |
| 1035 | 0x3c088, 0xffffffff, 0x00030002, |
| 1036 | 0x3c08c, 0xffffffff, 0x00040007, |
| 1037 | 0x3c090, 0xffffffff, 0x00060005, |
| 1038 | 0x3c094, 0xffffffff, 0x00090008, |
| 1039 | 0x3c098, 0xffffffff, 0x00010000, |
| 1040 | 0x3c09c, 0xffffffff, 0x00030002, |
| 1041 | 0x3c0a0, 0xffffffff, 0x00040007, |
| 1042 | 0x3c0a4, 0xffffffff, 0x00060005, |
| 1043 | 0x3c0a8, 0xffffffff, 0x00090008, |
| 1044 | 0x3c000, 0xffffffff, 0x96e00200, |
| 1045 | 0x8708, 0xffffffff, 0x00900100, |
| 1046 | 0xc424, 0xffffffff, 0x0020003f, |
| 1047 | 0x38, 0xffffffff, 0x0140001c, |
| 1048 | 0x3c, 0x000f0000, 0x000f0000, |
| 1049 | 0x220, 0xffffffff, 0xC060000C, |
| 1050 | 0x224, 0xc0000fff, 0x00000100, |
| 1051 | 0xf90, 0xffffffff, 0x00000100, |
| 1052 | 0xf98, 0x00000101, 0x00000000, |
| 1053 | 0x20a8, 0xffffffff, 0x00000104, |
| 1054 | 0x55e4, 0xff000fff, 0x00000100, |
| 1055 | 0x30cc, 0xc0000fff, 0x00000104, |
| 1056 | 0xc1e4, 0x00000001, 0x00000001, |
| 1057 | 0xd00c, 0xff000ff0, 0x00000100, |
| 1058 | 0xd80c, 0xff000ff0, 0x00000100 |
| 1059 | }; |
| 1060 | |
| 1061 | static const u32 spectre_golden_spm_registers[] = |
| 1062 | { |
| 1063 | 0x30800, 0xe0ffffff, 0xe0000000 |
| 1064 | }; |
| 1065 | |
| 1066 | static const u32 spectre_golden_common_registers[] = |
| 1067 | { |
| 1068 | 0xc770, 0xffffffff, 0x00000800, |
| 1069 | 0xc774, 0xffffffff, 0x00000800, |
| 1070 | 0xc798, 0xffffffff, 0x00007fbf, |
| 1071 | 0xc79c, 0xffffffff, 0x00007faf |
| 1072 | }; |
| 1073 | |
| 1074 | static const u32 spectre_golden_registers[] = |
| 1075 | { |
| 1076 | 0x3c000, 0xffff1fff, 0x96940200, |
| 1077 | 0x3c00c, 0xffff0001, 0xff000000, |
| 1078 | 0x3c200, 0xfffc0fff, 0x00000100, |
| 1079 | 0x6ed8, 0x00010101, 0x00010000, |
| 1080 | 0x9834, 0xf00fffff, 0x00000400, |
| 1081 | 0x9838, 0xfffffffc, 0x00020200, |
| 1082 | 0x5bb0, 0x000000f0, 0x00000070, |
| 1083 | 0x5bc0, 0xf0311fff, 0x80300000, |
| 1084 | 0x98f8, 0x73773777, 0x12010001, |
| 1085 | 0x9b7c, 0x00ff0000, 0x00fc0000, |
| 1086 | 0x2f48, 0x73773777, 0x12010001, |
| 1087 | 0x8a14, 0xf000003f, 0x00000007, |
| 1088 | 0x8b24, 0xffffffff, 0x00ffffff, |
| 1089 | 0x28350, 0x3f3f3fff, 0x00000082, |
| 1090 | 0x28355, 0x0000003f, 0x00000000, |
| 1091 | 0x3e78, 0x00000001, 0x00000002, |
| 1092 | 0x913c, 0xffff03df, 0x00000004, |
| 1093 | 0xc768, 0x00000008, 0x00000008, |
| 1094 | 0x8c00, 0x000008ff, 0x00000800, |
| 1095 | 0x9508, 0x00010000, 0x00010000, |
| 1096 | 0xac0c, 0xffffffff, 0x54763210, |
| 1097 | 0x214f8, 0x01ff01ff, 0x00000002, |
| 1098 | 0x21498, 0x007ff800, 0x00200000, |
| 1099 | 0x2015c, 0xffffffff, 0x00000f40, |
| 1100 | 0x30934, 0xffffffff, 0x00000001 |
| 1101 | }; |
| 1102 | |
| 1103 | static const u32 spectre_mgcg_cgcg_init[] = |
| 1104 | { |
| 1105 | 0xc420, 0xffffffff, 0xfffffffc, |
| 1106 | 0x30800, 0xffffffff, 0xe0000000, |
| 1107 | 0x3c2a0, 0xffffffff, 0x00000100, |
| 1108 | 0x3c208, 0xffffffff, 0x00000100, |
| 1109 | 0x3c2c0, 0xffffffff, 0x00000100, |
| 1110 | 0x3c2c8, 0xffffffff, 0x00000100, |
| 1111 | 0x3c2c4, 0xffffffff, 0x00000100, |
| 1112 | 0x55e4, 0xffffffff, 0x00600100, |
| 1113 | 0x3c280, 0xffffffff, 0x00000100, |
| 1114 | 0x3c214, 0xffffffff, 0x06000100, |
| 1115 | 0x3c220, 0xffffffff, 0x00000100, |
| 1116 | 0x3c218, 0xffffffff, 0x06000100, |
| 1117 | 0x3c204, 0xffffffff, 0x00000100, |
| 1118 | 0x3c2e0, 0xffffffff, 0x00000100, |
| 1119 | 0x3c224, 0xffffffff, 0x00000100, |
| 1120 | 0x3c200, 0xffffffff, 0x00000100, |
| 1121 | 0x3c230, 0xffffffff, 0x00000100, |
| 1122 | 0x3c234, 0xffffffff, 0x00000100, |
| 1123 | 0x3c250, 0xffffffff, 0x00000100, |
| 1124 | 0x3c254, 0xffffffff, 0x00000100, |
| 1125 | 0x3c258, 0xffffffff, 0x00000100, |
| 1126 | 0x3c25c, 0xffffffff, 0x00000100, |
| 1127 | 0x3c260, 0xffffffff, 0x00000100, |
| 1128 | 0x3c27c, 0xffffffff, 0x00000100, |
| 1129 | 0x3c278, 0xffffffff, 0x00000100, |
| 1130 | 0x3c210, 0xffffffff, 0x06000100, |
| 1131 | 0x3c290, 0xffffffff, 0x00000100, |
| 1132 | 0x3c274, 0xffffffff, 0x00000100, |
| 1133 | 0x3c2b4, 0xffffffff, 0x00000100, |
| 1134 | 0x3c2b0, 0xffffffff, 0x00000100, |
| 1135 | 0x3c270, 0xffffffff, 0x00000100, |
| 1136 | 0x30800, 0xffffffff, 0xe0000000, |
| 1137 | 0x3c020, 0xffffffff, 0x00010000, |
| 1138 | 0x3c024, 0xffffffff, 0x00030002, |
| 1139 | 0x3c028, 0xffffffff, 0x00040007, |
| 1140 | 0x3c02c, 0xffffffff, 0x00060005, |
| 1141 | 0x3c030, 0xffffffff, 0x00090008, |
| 1142 | 0x3c034, 0xffffffff, 0x00010000, |
| 1143 | 0x3c038, 0xffffffff, 0x00030002, |
| 1144 | 0x3c03c, 0xffffffff, 0x00040007, |
| 1145 | 0x3c040, 0xffffffff, 0x00060005, |
| 1146 | 0x3c044, 0xffffffff, 0x00090008, |
| 1147 | 0x3c048, 0xffffffff, 0x00010000, |
| 1148 | 0x3c04c, 0xffffffff, 0x00030002, |
| 1149 | 0x3c050, 0xffffffff, 0x00040007, |
| 1150 | 0x3c054, 0xffffffff, 0x00060005, |
| 1151 | 0x3c058, 0xffffffff, 0x00090008, |
| 1152 | 0x3c05c, 0xffffffff, 0x00010000, |
| 1153 | 0x3c060, 0xffffffff, 0x00030002, |
| 1154 | 0x3c064, 0xffffffff, 0x00040007, |
| 1155 | 0x3c068, 0xffffffff, 0x00060005, |
| 1156 | 0x3c06c, 0xffffffff, 0x00090008, |
| 1157 | 0x3c070, 0xffffffff, 0x00010000, |
| 1158 | 0x3c074, 0xffffffff, 0x00030002, |
| 1159 | 0x3c078, 0xffffffff, 0x00040007, |
| 1160 | 0x3c07c, 0xffffffff, 0x00060005, |
| 1161 | 0x3c080, 0xffffffff, 0x00090008, |
| 1162 | 0x3c084, 0xffffffff, 0x00010000, |
| 1163 | 0x3c088, 0xffffffff, 0x00030002, |
| 1164 | 0x3c08c, 0xffffffff, 0x00040007, |
| 1165 | 0x3c090, 0xffffffff, 0x00060005, |
| 1166 | 0x3c094, 0xffffffff, 0x00090008, |
| 1167 | 0x3c098, 0xffffffff, 0x00010000, |
| 1168 | 0x3c09c, 0xffffffff, 0x00030002, |
| 1169 | 0x3c0a0, 0xffffffff, 0x00040007, |
| 1170 | 0x3c0a4, 0xffffffff, 0x00060005, |
| 1171 | 0x3c0a8, 0xffffffff, 0x00090008, |
| 1172 | 0x3c0ac, 0xffffffff, 0x00010000, |
| 1173 | 0x3c0b0, 0xffffffff, 0x00030002, |
| 1174 | 0x3c0b4, 0xffffffff, 0x00040007, |
| 1175 | 0x3c0b8, 0xffffffff, 0x00060005, |
| 1176 | 0x3c0bc, 0xffffffff, 0x00090008, |
| 1177 | 0x3c000, 0xffffffff, 0x96e00200, |
| 1178 | 0x8708, 0xffffffff, 0x00900100, |
| 1179 | 0xc424, 0xffffffff, 0x0020003f, |
| 1180 | 0x38, 0xffffffff, 0x0140001c, |
| 1181 | 0x3c, 0x000f0000, 0x000f0000, |
| 1182 | 0x220, 0xffffffff, 0xC060000C, |
| 1183 | 0x224, 0xc0000fff, 0x00000100, |
| 1184 | 0xf90, 0xffffffff, 0x00000100, |
| 1185 | 0xf98, 0x00000101, 0x00000000, |
| 1186 | 0x20a8, 0xffffffff, 0x00000104, |
| 1187 | 0x55e4, 0xff000fff, 0x00000100, |
| 1188 | 0x30cc, 0xc0000fff, 0x00000104, |
| 1189 | 0xc1e4, 0x00000001, 0x00000001, |
| 1190 | 0xd00c, 0xff000ff0, 0x00000100, |
| 1191 | 0xd80c, 0xff000ff0, 0x00000100 |
| 1192 | }; |
| 1193 | |
| 1194 | static const u32 kalindi_golden_spm_registers[] = |
| 1195 | { |
| 1196 | 0x30800, 0xe0ffffff, 0xe0000000 |
| 1197 | }; |
| 1198 | |
| 1199 | static const u32 kalindi_golden_common_registers[] = |
| 1200 | { |
| 1201 | 0xc770, 0xffffffff, 0x00000800, |
| 1202 | 0xc774, 0xffffffff, 0x00000800, |
| 1203 | 0xc798, 0xffffffff, 0x00007fbf, |
| 1204 | 0xc79c, 0xffffffff, 0x00007faf |
| 1205 | }; |
| 1206 | |
| 1207 | static const u32 kalindi_golden_registers[] = |
| 1208 | { |
| 1209 | 0x3c000, 0xffffdfff, 0x6e944040, |
| 1210 | 0x55e4, 0xff607fff, 0xfc000100, |
| 1211 | 0x3c220, 0xff000fff, 0x00000100, |
| 1212 | 0x3c224, 0xff000fff, 0x00000100, |
| 1213 | 0x3c200, 0xfffc0fff, 0x00000100, |
| 1214 | 0x6ed8, 0x00010101, 0x00010000, |
| 1215 | 0x9830, 0xffffffff, 0x00000000, |
| 1216 | 0x9834, 0xf00fffff, 0x00000400, |
| 1217 | 0x5bb0, 0x000000f0, 0x00000070, |
| 1218 | 0x5bc0, 0xf0311fff, 0x80300000, |
| 1219 | 0x98f8, 0x73773777, 0x12010001, |
| 1220 | 0x98fc, 0xffffffff, 0x00000010, |
| 1221 | 0x9b7c, 0x00ff0000, 0x00fc0000, |
| 1222 | 0x8030, 0x00001f0f, 0x0000100a, |
| 1223 | 0x2f48, 0x73773777, 0x12010001, |
| 1224 | 0x2408, 0x000fffff, 0x000c007f, |
| 1225 | 0x8a14, 0xf000003f, 0x00000007, |
| 1226 | 0x8b24, 0x3fff3fff, 0x00ffcfff, |
| 1227 | 0x30a04, 0x0000ff0f, 0x00000000, |
| 1228 | 0x28a4c, 0x07ffffff, 0x06000000, |
| 1229 | 0x4d8, 0x00000fff, 0x00000100, |
| 1230 | 0x3e78, 0x00000001, 0x00000002, |
| 1231 | 0xc768, 0x00000008, 0x00000008, |
| 1232 | 0x8c00, 0x000000ff, 0x00000003, |
| 1233 | 0x214f8, 0x01ff01ff, 0x00000002, |
| 1234 | 0x21498, 0x007ff800, 0x00200000, |
| 1235 | 0x2015c, 0xffffffff, 0x00000f40, |
| 1236 | 0x88c4, 0x001f3ae3, 0x00000082, |
| 1237 | 0x88d4, 0x0000001f, 0x00000010, |
| 1238 | 0x30934, 0xffffffff, 0x00000000 |
| 1239 | }; |
| 1240 | |
| 1241 | static const u32 kalindi_mgcg_cgcg_init[] = |
| 1242 | { |
| 1243 | 0xc420, 0xffffffff, 0xfffffffc, |
| 1244 | 0x30800, 0xffffffff, 0xe0000000, |
| 1245 | 0x3c2a0, 0xffffffff, 0x00000100, |
| 1246 | 0x3c208, 0xffffffff, 0x00000100, |
| 1247 | 0x3c2c0, 0xffffffff, 0x00000100, |
| 1248 | 0x3c2c8, 0xffffffff, 0x00000100, |
| 1249 | 0x3c2c4, 0xffffffff, 0x00000100, |
| 1250 | 0x55e4, 0xffffffff, 0x00600100, |
| 1251 | 0x3c280, 0xffffffff, 0x00000100, |
| 1252 | 0x3c214, 0xffffffff, 0x06000100, |
| 1253 | 0x3c220, 0xffffffff, 0x00000100, |
| 1254 | 0x3c218, 0xffffffff, 0x06000100, |
| 1255 | 0x3c204, 0xffffffff, 0x00000100, |
| 1256 | 0x3c2e0, 0xffffffff, 0x00000100, |
| 1257 | 0x3c224, 0xffffffff, 0x00000100, |
| 1258 | 0x3c200, 0xffffffff, 0x00000100, |
| 1259 | 0x3c230, 0xffffffff, 0x00000100, |
| 1260 | 0x3c234, 0xffffffff, 0x00000100, |
| 1261 | 0x3c250, 0xffffffff, 0x00000100, |
| 1262 | 0x3c254, 0xffffffff, 0x00000100, |
| 1263 | 0x3c258, 0xffffffff, 0x00000100, |
| 1264 | 0x3c25c, 0xffffffff, 0x00000100, |
| 1265 | 0x3c260, 0xffffffff, 0x00000100, |
| 1266 | 0x3c27c, 0xffffffff, 0x00000100, |
| 1267 | 0x3c278, 0xffffffff, 0x00000100, |
| 1268 | 0x3c210, 0xffffffff, 0x06000100, |
| 1269 | 0x3c290, 0xffffffff, 0x00000100, |
| 1270 | 0x3c274, 0xffffffff, 0x00000100, |
| 1271 | 0x3c2b4, 0xffffffff, 0x00000100, |
| 1272 | 0x3c2b0, 0xffffffff, 0x00000100, |
| 1273 | 0x3c270, 0xffffffff, 0x00000100, |
| 1274 | 0x30800, 0xffffffff, 0xe0000000, |
| 1275 | 0x3c020, 0xffffffff, 0x00010000, |
| 1276 | 0x3c024, 0xffffffff, 0x00030002, |
| 1277 | 0x3c028, 0xffffffff, 0x00040007, |
| 1278 | 0x3c02c, 0xffffffff, 0x00060005, |
| 1279 | 0x3c030, 0xffffffff, 0x00090008, |
| 1280 | 0x3c034, 0xffffffff, 0x00010000, |
| 1281 | 0x3c038, 0xffffffff, 0x00030002, |
| 1282 | 0x3c03c, 0xffffffff, 0x00040007, |
| 1283 | 0x3c040, 0xffffffff, 0x00060005, |
| 1284 | 0x3c044, 0xffffffff, 0x00090008, |
| 1285 | 0x3c000, 0xffffffff, 0x96e00200, |
| 1286 | 0x8708, 0xffffffff, 0x00900100, |
| 1287 | 0xc424, 0xffffffff, 0x0020003f, |
| 1288 | 0x38, 0xffffffff, 0x0140001c, |
| 1289 | 0x3c, 0x000f0000, 0x000f0000, |
| 1290 | 0x220, 0xffffffff, 0xC060000C, |
| 1291 | 0x224, 0xc0000fff, 0x00000100, |
| 1292 | 0x20a8, 0xffffffff, 0x00000104, |
| 1293 | 0x55e4, 0xff000fff, 0x00000100, |
| 1294 | 0x30cc, 0xc0000fff, 0x00000104, |
| 1295 | 0xc1e4, 0x00000001, 0x00000001, |
| 1296 | 0xd00c, 0xff000ff0, 0x00000100, |
| 1297 | 0xd80c, 0xff000ff0, 0x00000100 |
| 1298 | }; |
| 1299 | |
| 1300 | static void cik_init_golden_registers(struct radeon_device *rdev) |
| 1301 | { |
| 1302 | switch (rdev->family) { |
| 1303 | case CHIP_BONAIRE: |
| 1304 | radeon_program_register_sequence(rdev, |
| 1305 | bonaire_mgcg_cgcg_init, |
| 1306 | (const u32)ARRAY_SIZE(bonaire_mgcg_cgcg_init)); |
| 1307 | radeon_program_register_sequence(rdev, |
| 1308 | bonaire_golden_registers, |
| 1309 | (const u32)ARRAY_SIZE(bonaire_golden_registers)); |
| 1310 | radeon_program_register_sequence(rdev, |
| 1311 | bonaire_golden_common_registers, |
| 1312 | (const u32)ARRAY_SIZE(bonaire_golden_common_registers)); |
| 1313 | radeon_program_register_sequence(rdev, |
| 1314 | bonaire_golden_spm_registers, |
| 1315 | (const u32)ARRAY_SIZE(bonaire_golden_spm_registers)); |
| 1316 | break; |
| 1317 | case CHIP_KABINI: |
| 1318 | radeon_program_register_sequence(rdev, |
| 1319 | kalindi_mgcg_cgcg_init, |
| 1320 | (const u32)ARRAY_SIZE(kalindi_mgcg_cgcg_init)); |
| 1321 | radeon_program_register_sequence(rdev, |
| 1322 | kalindi_golden_registers, |
| 1323 | (const u32)ARRAY_SIZE(kalindi_golden_registers)); |
| 1324 | radeon_program_register_sequence(rdev, |
| 1325 | kalindi_golden_common_registers, |
| 1326 | (const u32)ARRAY_SIZE(kalindi_golden_common_registers)); |
| 1327 | radeon_program_register_sequence(rdev, |
| 1328 | kalindi_golden_spm_registers, |
| 1329 | (const u32)ARRAY_SIZE(kalindi_golden_spm_registers)); |
| 1330 | break; |
| 1331 | case CHIP_KAVERI: |
| 1332 | radeon_program_register_sequence(rdev, |
| 1333 | spectre_mgcg_cgcg_init, |
| 1334 | (const u32)ARRAY_SIZE(spectre_mgcg_cgcg_init)); |
| 1335 | radeon_program_register_sequence(rdev, |
| 1336 | spectre_golden_registers, |
| 1337 | (const u32)ARRAY_SIZE(spectre_golden_registers)); |
| 1338 | radeon_program_register_sequence(rdev, |
| 1339 | spectre_golden_common_registers, |
| 1340 | (const u32)ARRAY_SIZE(spectre_golden_common_registers)); |
| 1341 | radeon_program_register_sequence(rdev, |
| 1342 | spectre_golden_spm_registers, |
| 1343 | (const u32)ARRAY_SIZE(spectre_golden_spm_registers)); |
| 1344 | break; |
| 1345 | default: |
| 1346 | break; |
| 1347 | } |
| 1348 | } |
| 1349 | |
Alex Deucher | 2c67912 | 2013-04-09 13:32:18 -0400 | [diff] [blame] | 1350 | /** |
| 1351 | * cik_get_xclk - get the xclk |
| 1352 | * |
| 1353 | * @rdev: radeon_device pointer |
| 1354 | * |
| 1355 | * Returns the reference clock used by the gfx engine |
| 1356 | * (CIK). |
| 1357 | */ |
| 1358 | u32 cik_get_xclk(struct radeon_device *rdev) |
| 1359 | { |
| 1360 | u32 reference_clock = rdev->clock.spll.reference_freq; |
| 1361 | |
| 1362 | if (rdev->flags & RADEON_IS_IGP) { |
| 1363 | if (RREG32_SMC(GENERAL_PWRMGT) & GPU_COUNTER_CLK) |
| 1364 | return reference_clock / 2; |
| 1365 | } else { |
| 1366 | if (RREG32_SMC(CG_CLKPIN_CNTL) & XTALIN_DIVIDE) |
| 1367 | return reference_clock / 4; |
| 1368 | } |
| 1369 | return reference_clock; |
| 1370 | } |
| 1371 | |
Alex Deucher | 75efdee | 2013-03-04 12:47:46 -0500 | [diff] [blame] | 1372 | /** |
| 1373 | * cik_mm_rdoorbell - read a doorbell dword |
| 1374 | * |
| 1375 | * @rdev: radeon_device pointer |
| 1376 | * @offset: byte offset into the aperture |
| 1377 | * |
| 1378 | * Returns the value in the doorbell aperture at the |
| 1379 | * requested offset (CIK). |
| 1380 | */ |
| 1381 | u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset) |
| 1382 | { |
| 1383 | if (offset < rdev->doorbell.size) { |
| 1384 | return readl(((void __iomem *)rdev->doorbell.ptr) + offset); |
| 1385 | } else { |
| 1386 | DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", offset); |
| 1387 | return 0; |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | /** |
| 1392 | * cik_mm_wdoorbell - write a doorbell dword |
| 1393 | * |
| 1394 | * @rdev: radeon_device pointer |
| 1395 | * @offset: byte offset into the aperture |
| 1396 | * @v: value to write |
| 1397 | * |
| 1398 | * Writes @v to the doorbell aperture at the |
| 1399 | * requested offset (CIK). |
| 1400 | */ |
| 1401 | void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v) |
| 1402 | { |
| 1403 | if (offset < rdev->doorbell.size) { |
| 1404 | writel(v, ((void __iomem *)rdev->doorbell.ptr) + offset); |
| 1405 | } else { |
| 1406 | DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", offset); |
| 1407 | } |
| 1408 | } |
| 1409 | |
Alex Deucher | bc8273f | 2012-06-29 19:44:04 -0400 | [diff] [blame] | 1410 | #define BONAIRE_IO_MC_REGS_SIZE 36 |
| 1411 | |
| 1412 | static const u32 bonaire_io_mc_regs[BONAIRE_IO_MC_REGS_SIZE][2] = |
| 1413 | { |
| 1414 | {0x00000070, 0x04400000}, |
| 1415 | {0x00000071, 0x80c01803}, |
| 1416 | {0x00000072, 0x00004004}, |
| 1417 | {0x00000073, 0x00000100}, |
| 1418 | {0x00000074, 0x00ff0000}, |
| 1419 | {0x00000075, 0x34000000}, |
| 1420 | {0x00000076, 0x08000014}, |
| 1421 | {0x00000077, 0x00cc08ec}, |
| 1422 | {0x00000078, 0x00000400}, |
| 1423 | {0x00000079, 0x00000000}, |
| 1424 | {0x0000007a, 0x04090000}, |
| 1425 | {0x0000007c, 0x00000000}, |
| 1426 | {0x0000007e, 0x4408a8e8}, |
| 1427 | {0x0000007f, 0x00000304}, |
| 1428 | {0x00000080, 0x00000000}, |
| 1429 | {0x00000082, 0x00000001}, |
| 1430 | {0x00000083, 0x00000002}, |
| 1431 | {0x00000084, 0xf3e4f400}, |
| 1432 | {0x00000085, 0x052024e3}, |
| 1433 | {0x00000087, 0x00000000}, |
| 1434 | {0x00000088, 0x01000000}, |
| 1435 | {0x0000008a, 0x1c0a0000}, |
| 1436 | {0x0000008b, 0xff010000}, |
| 1437 | {0x0000008d, 0xffffefff}, |
| 1438 | {0x0000008e, 0xfff3efff}, |
| 1439 | {0x0000008f, 0xfff3efbf}, |
| 1440 | {0x00000092, 0xf7ffffff}, |
| 1441 | {0x00000093, 0xffffff7f}, |
| 1442 | {0x00000095, 0x00101101}, |
| 1443 | {0x00000096, 0x00000fff}, |
| 1444 | {0x00000097, 0x00116fff}, |
| 1445 | {0x00000098, 0x60010000}, |
| 1446 | {0x00000099, 0x10010000}, |
| 1447 | {0x0000009a, 0x00006000}, |
| 1448 | {0x0000009b, 0x00001000}, |
| 1449 | {0x0000009f, 0x00b48000} |
| 1450 | }; |
| 1451 | |
Alex Deucher | b556b12 | 2013-01-29 10:44:22 -0500 | [diff] [blame] | 1452 | /** |
| 1453 | * cik_srbm_select - select specific register instances |
| 1454 | * |
| 1455 | * @rdev: radeon_device pointer |
| 1456 | * @me: selected ME (micro engine) |
| 1457 | * @pipe: pipe |
| 1458 | * @queue: queue |
| 1459 | * @vmid: VMID |
| 1460 | * |
| 1461 | * Switches the currently active registers instances. Some |
| 1462 | * registers are instanced per VMID, others are instanced per |
| 1463 | * me/pipe/queue combination. |
| 1464 | */ |
| 1465 | static void cik_srbm_select(struct radeon_device *rdev, |
| 1466 | u32 me, u32 pipe, u32 queue, u32 vmid) |
| 1467 | { |
| 1468 | u32 srbm_gfx_cntl = (PIPEID(pipe & 0x3) | |
| 1469 | MEID(me & 0x3) | |
| 1470 | VMID(vmid & 0xf) | |
| 1471 | QUEUEID(queue & 0x7)); |
| 1472 | WREG32(SRBM_GFX_CNTL, srbm_gfx_cntl); |
| 1473 | } |
| 1474 | |
Alex Deucher | bc8273f | 2012-06-29 19:44:04 -0400 | [diff] [blame] | 1475 | /* ucode loading */ |
| 1476 | /** |
| 1477 | * ci_mc_load_microcode - load MC ucode into the hw |
| 1478 | * |
| 1479 | * @rdev: radeon_device pointer |
| 1480 | * |
| 1481 | * Load the GDDR MC ucode into the hw (CIK). |
| 1482 | * Returns 0 on success, error on failure. |
| 1483 | */ |
| 1484 | static int ci_mc_load_microcode(struct radeon_device *rdev) |
| 1485 | { |
| 1486 | const __be32 *fw_data; |
| 1487 | u32 running, blackout = 0; |
| 1488 | u32 *io_mc_regs; |
| 1489 | int i, ucode_size, regs_size; |
| 1490 | |
| 1491 | if (!rdev->mc_fw) |
| 1492 | return -EINVAL; |
| 1493 | |
| 1494 | switch (rdev->family) { |
| 1495 | case CHIP_BONAIRE: |
| 1496 | default: |
| 1497 | io_mc_regs = (u32 *)&bonaire_io_mc_regs; |
| 1498 | ucode_size = CIK_MC_UCODE_SIZE; |
| 1499 | regs_size = BONAIRE_IO_MC_REGS_SIZE; |
| 1500 | break; |
| 1501 | } |
| 1502 | |
| 1503 | running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK; |
| 1504 | |
| 1505 | if (running == 0) { |
| 1506 | if (running) { |
| 1507 | blackout = RREG32(MC_SHARED_BLACKOUT_CNTL); |
| 1508 | WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1); |
| 1509 | } |
| 1510 | |
| 1511 | /* reset the engine and set to writable */ |
| 1512 | WREG32(MC_SEQ_SUP_CNTL, 0x00000008); |
| 1513 | WREG32(MC_SEQ_SUP_CNTL, 0x00000010); |
| 1514 | |
| 1515 | /* load mc io regs */ |
| 1516 | for (i = 0; i < regs_size; i++) { |
| 1517 | WREG32(MC_SEQ_IO_DEBUG_INDEX, io_mc_regs[(i << 1)]); |
| 1518 | WREG32(MC_SEQ_IO_DEBUG_DATA, io_mc_regs[(i << 1) + 1]); |
| 1519 | } |
| 1520 | /* load the MC ucode */ |
| 1521 | fw_data = (const __be32 *)rdev->mc_fw->data; |
| 1522 | for (i = 0; i < ucode_size; i++) |
| 1523 | WREG32(MC_SEQ_SUP_PGM, be32_to_cpup(fw_data++)); |
| 1524 | |
| 1525 | /* put the engine back into the active state */ |
| 1526 | WREG32(MC_SEQ_SUP_CNTL, 0x00000008); |
| 1527 | WREG32(MC_SEQ_SUP_CNTL, 0x00000004); |
| 1528 | WREG32(MC_SEQ_SUP_CNTL, 0x00000001); |
| 1529 | |
| 1530 | /* wait for training to complete */ |
| 1531 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 1532 | if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D0) |
| 1533 | break; |
| 1534 | udelay(1); |
| 1535 | } |
| 1536 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 1537 | if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D1) |
| 1538 | break; |
| 1539 | udelay(1); |
| 1540 | } |
| 1541 | |
| 1542 | if (running) |
| 1543 | WREG32(MC_SHARED_BLACKOUT_CNTL, blackout); |
| 1544 | } |
| 1545 | |
| 1546 | return 0; |
| 1547 | } |
| 1548 | |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1549 | /** |
| 1550 | * cik_init_microcode - load ucode images from disk |
| 1551 | * |
| 1552 | * @rdev: radeon_device pointer |
| 1553 | * |
| 1554 | * Use the firmware interface to load the ucode images into |
| 1555 | * the driver (not loaded into hw). |
| 1556 | * Returns 0 on success, error on failure. |
| 1557 | */ |
| 1558 | static int cik_init_microcode(struct radeon_device *rdev) |
| 1559 | { |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1560 | const char *chip_name; |
| 1561 | size_t pfp_req_size, me_req_size, ce_req_size, |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1562 | mec_req_size, rlc_req_size, mc_req_size, |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1563 | sdma_req_size, smc_req_size; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1564 | char fw_name[30]; |
| 1565 | int err; |
| 1566 | |
| 1567 | DRM_DEBUG("\n"); |
| 1568 | |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1569 | switch (rdev->family) { |
| 1570 | case CHIP_BONAIRE: |
| 1571 | chip_name = "BONAIRE"; |
| 1572 | pfp_req_size = CIK_PFP_UCODE_SIZE * 4; |
| 1573 | me_req_size = CIK_ME_UCODE_SIZE * 4; |
| 1574 | ce_req_size = CIK_CE_UCODE_SIZE * 4; |
| 1575 | mec_req_size = CIK_MEC_UCODE_SIZE * 4; |
| 1576 | rlc_req_size = BONAIRE_RLC_UCODE_SIZE * 4; |
| 1577 | mc_req_size = CIK_MC_UCODE_SIZE * 4; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1578 | sdma_req_size = CIK_SDMA_UCODE_SIZE * 4; |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1579 | smc_req_size = ALIGN(BONAIRE_SMC_UCODE_SIZE, 4); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1580 | break; |
| 1581 | case CHIP_KAVERI: |
| 1582 | chip_name = "KAVERI"; |
| 1583 | pfp_req_size = CIK_PFP_UCODE_SIZE * 4; |
| 1584 | me_req_size = CIK_ME_UCODE_SIZE * 4; |
| 1585 | ce_req_size = CIK_CE_UCODE_SIZE * 4; |
| 1586 | mec_req_size = CIK_MEC_UCODE_SIZE * 4; |
| 1587 | rlc_req_size = KV_RLC_UCODE_SIZE * 4; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1588 | sdma_req_size = CIK_SDMA_UCODE_SIZE * 4; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1589 | break; |
| 1590 | case CHIP_KABINI: |
| 1591 | chip_name = "KABINI"; |
| 1592 | pfp_req_size = CIK_PFP_UCODE_SIZE * 4; |
| 1593 | me_req_size = CIK_ME_UCODE_SIZE * 4; |
| 1594 | ce_req_size = CIK_CE_UCODE_SIZE * 4; |
| 1595 | mec_req_size = CIK_MEC_UCODE_SIZE * 4; |
| 1596 | rlc_req_size = KB_RLC_UCODE_SIZE * 4; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1597 | sdma_req_size = CIK_SDMA_UCODE_SIZE * 4; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1598 | break; |
| 1599 | default: BUG(); |
| 1600 | } |
| 1601 | |
| 1602 | DRM_INFO("Loading %s Microcode\n", chip_name); |
| 1603 | |
| 1604 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1605 | err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1606 | if (err) |
| 1607 | goto out; |
| 1608 | if (rdev->pfp_fw->size != pfp_req_size) { |
| 1609 | printk(KERN_ERR |
| 1610 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1611 | rdev->pfp_fw->size, fw_name); |
| 1612 | err = -EINVAL; |
| 1613 | goto out; |
| 1614 | } |
| 1615 | |
| 1616 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1617 | err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1618 | if (err) |
| 1619 | goto out; |
| 1620 | if (rdev->me_fw->size != me_req_size) { |
| 1621 | printk(KERN_ERR |
| 1622 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1623 | rdev->me_fw->size, fw_name); |
| 1624 | err = -EINVAL; |
| 1625 | } |
| 1626 | |
| 1627 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1628 | err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1629 | if (err) |
| 1630 | goto out; |
| 1631 | if (rdev->ce_fw->size != ce_req_size) { |
| 1632 | printk(KERN_ERR |
| 1633 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1634 | rdev->ce_fw->size, fw_name); |
| 1635 | err = -EINVAL; |
| 1636 | } |
| 1637 | |
| 1638 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1639 | err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1640 | if (err) |
| 1641 | goto out; |
| 1642 | if (rdev->mec_fw->size != mec_req_size) { |
| 1643 | printk(KERN_ERR |
| 1644 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1645 | rdev->mec_fw->size, fw_name); |
| 1646 | err = -EINVAL; |
| 1647 | } |
| 1648 | |
| 1649 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1650 | err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1651 | if (err) |
| 1652 | goto out; |
| 1653 | if (rdev->rlc_fw->size != rlc_req_size) { |
| 1654 | printk(KERN_ERR |
| 1655 | "cik_rlc: Bogus length %zu in firmware \"%s\"\n", |
| 1656 | rdev->rlc_fw->size, fw_name); |
| 1657 | err = -EINVAL; |
| 1658 | } |
| 1659 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1660 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1661 | err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1662 | if (err) |
| 1663 | goto out; |
| 1664 | if (rdev->sdma_fw->size != sdma_req_size) { |
| 1665 | printk(KERN_ERR |
| 1666 | "cik_sdma: Bogus length %zu in firmware \"%s\"\n", |
| 1667 | rdev->sdma_fw->size, fw_name); |
| 1668 | err = -EINVAL; |
| 1669 | } |
| 1670 | |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1671 | /* No SMC, MC ucode on APUs */ |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1672 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 1673 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1674 | err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1675 | if (err) |
| 1676 | goto out; |
| 1677 | if (rdev->mc_fw->size != mc_req_size) { |
| 1678 | printk(KERN_ERR |
| 1679 | "cik_mc: Bogus length %zu in firmware \"%s\"\n", |
| 1680 | rdev->mc_fw->size, fw_name); |
| 1681 | err = -EINVAL; |
| 1682 | } |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1683 | |
| 1684 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); |
| 1685 | err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); |
| 1686 | if (err) { |
| 1687 | printk(KERN_ERR |
| 1688 | "smc: error loading firmware \"%s\"\n", |
| 1689 | fw_name); |
| 1690 | release_firmware(rdev->smc_fw); |
| 1691 | rdev->smc_fw = NULL; |
Alex Deucher | d30d71e | 2013-10-16 11:40:48 -0400 | [diff] [blame] | 1692 | err = 0; |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1693 | } else if (rdev->smc_fw->size != smc_req_size) { |
| 1694 | printk(KERN_ERR |
| 1695 | "cik_smc: Bogus length %zu in firmware \"%s\"\n", |
| 1696 | rdev->smc_fw->size, fw_name); |
| 1697 | err = -EINVAL; |
| 1698 | } |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1699 | } |
| 1700 | |
| 1701 | out: |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1702 | if (err) { |
| 1703 | if (err != -EINVAL) |
| 1704 | printk(KERN_ERR |
| 1705 | "cik_cp: Failed to load firmware \"%s\"\n", |
| 1706 | fw_name); |
| 1707 | release_firmware(rdev->pfp_fw); |
| 1708 | rdev->pfp_fw = NULL; |
| 1709 | release_firmware(rdev->me_fw); |
| 1710 | rdev->me_fw = NULL; |
| 1711 | release_firmware(rdev->ce_fw); |
| 1712 | rdev->ce_fw = NULL; |
| 1713 | release_firmware(rdev->rlc_fw); |
| 1714 | rdev->rlc_fw = NULL; |
| 1715 | release_firmware(rdev->mc_fw); |
| 1716 | rdev->mc_fw = NULL; |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1717 | release_firmware(rdev->smc_fw); |
| 1718 | rdev->smc_fw = NULL; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1719 | } |
| 1720 | return err; |
| 1721 | } |
| 1722 | |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 1723 | /* |
| 1724 | * Core functions |
| 1725 | */ |
| 1726 | /** |
| 1727 | * cik_tiling_mode_table_init - init the hw tiling table |
| 1728 | * |
| 1729 | * @rdev: radeon_device pointer |
| 1730 | * |
| 1731 | * Starting with SI, the tiling setup is done globally in a |
| 1732 | * set of 32 tiling modes. Rather than selecting each set of |
| 1733 | * parameters per surface as on older asics, we just select |
| 1734 | * which index in the tiling table we want to use, and the |
| 1735 | * surface uses those parameters (CIK). |
| 1736 | */ |
| 1737 | static void cik_tiling_mode_table_init(struct radeon_device *rdev) |
| 1738 | { |
| 1739 | const u32 num_tile_mode_states = 32; |
| 1740 | const u32 num_secondary_tile_mode_states = 16; |
| 1741 | u32 reg_offset, gb_tile_moden, split_equal_to_row_size; |
| 1742 | u32 num_pipe_configs; |
| 1743 | u32 num_rbs = rdev->config.cik.max_backends_per_se * |
| 1744 | rdev->config.cik.max_shader_engines; |
| 1745 | |
| 1746 | switch (rdev->config.cik.mem_row_size_in_kb) { |
| 1747 | case 1: |
| 1748 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB; |
| 1749 | break; |
| 1750 | case 2: |
| 1751 | default: |
| 1752 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB; |
| 1753 | break; |
| 1754 | case 4: |
| 1755 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB; |
| 1756 | break; |
| 1757 | } |
| 1758 | |
| 1759 | num_pipe_configs = rdev->config.cik.max_tile_pipes; |
| 1760 | if (num_pipe_configs > 8) |
| 1761 | num_pipe_configs = 8; /* ??? */ |
| 1762 | |
| 1763 | if (num_pipe_configs == 8) { |
| 1764 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 1765 | switch (reg_offset) { |
| 1766 | case 0: |
| 1767 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1768 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1769 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1770 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 1771 | break; |
| 1772 | case 1: |
| 1773 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1774 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1775 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1776 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 1777 | break; |
| 1778 | case 2: |
| 1779 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1780 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1781 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1782 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 1783 | break; |
| 1784 | case 3: |
| 1785 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1786 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1787 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1788 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 1789 | break; |
| 1790 | case 4: |
| 1791 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1792 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1793 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1794 | TILE_SPLIT(split_equal_to_row_size)); |
| 1795 | break; |
| 1796 | case 5: |
| 1797 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1798 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 1799 | break; |
| 1800 | case 6: |
| 1801 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1802 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1803 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1804 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 1805 | break; |
| 1806 | case 7: |
| 1807 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1808 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1809 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1810 | TILE_SPLIT(split_equal_to_row_size)); |
| 1811 | break; |
| 1812 | case 8: |
| 1813 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | |
| 1814 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16)); |
| 1815 | break; |
| 1816 | case 9: |
| 1817 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1818 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 1819 | break; |
| 1820 | case 10: |
| 1821 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1822 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 1823 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1824 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1825 | break; |
| 1826 | case 11: |
| 1827 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 1828 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 1829 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
| 1830 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1831 | break; |
| 1832 | case 12: |
| 1833 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1834 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 1835 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1836 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1837 | break; |
| 1838 | case 13: |
| 1839 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1840 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 1841 | break; |
| 1842 | case 14: |
| 1843 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1844 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 1845 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1846 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1847 | break; |
| 1848 | case 16: |
| 1849 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 1850 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 1851 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
| 1852 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1853 | break; |
| 1854 | case 17: |
| 1855 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1856 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 1857 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1858 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1859 | break; |
| 1860 | case 27: |
| 1861 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1862 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 1863 | break; |
| 1864 | case 28: |
| 1865 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1866 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 1867 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1868 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1869 | break; |
| 1870 | case 29: |
| 1871 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 1872 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 1873 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
| 1874 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1875 | break; |
| 1876 | case 30: |
| 1877 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1878 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 1879 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1880 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1881 | break; |
| 1882 | default: |
| 1883 | gb_tile_moden = 0; |
| 1884 | break; |
| 1885 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 1886 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 1887 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 1888 | } |
| 1889 | for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) { |
| 1890 | switch (reg_offset) { |
| 1891 | case 0: |
| 1892 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1893 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 1894 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 1895 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1896 | break; |
| 1897 | case 1: |
| 1898 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1899 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 1900 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1901 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1902 | break; |
| 1903 | case 2: |
| 1904 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1905 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1906 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1907 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1908 | break; |
| 1909 | case 3: |
| 1910 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1911 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1912 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1913 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1914 | break; |
| 1915 | case 4: |
| 1916 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1917 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1918 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1919 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 1920 | break; |
| 1921 | case 5: |
| 1922 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1923 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1924 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1925 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 1926 | break; |
| 1927 | case 6: |
| 1928 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1929 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1930 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1931 | NUM_BANKS(ADDR_SURF_2_BANK)); |
| 1932 | break; |
| 1933 | case 8: |
| 1934 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1935 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
| 1936 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 1937 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1938 | break; |
| 1939 | case 9: |
| 1940 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1941 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 1942 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 1943 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1944 | break; |
| 1945 | case 10: |
| 1946 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1947 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 1948 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1949 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1950 | break; |
| 1951 | case 11: |
| 1952 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1953 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1954 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1955 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1956 | break; |
| 1957 | case 12: |
| 1958 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1959 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1960 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1961 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 1962 | break; |
| 1963 | case 13: |
| 1964 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1965 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1966 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1967 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 1968 | break; |
| 1969 | case 14: |
| 1970 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1971 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1972 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1973 | NUM_BANKS(ADDR_SURF_2_BANK)); |
| 1974 | break; |
| 1975 | default: |
| 1976 | gb_tile_moden = 0; |
| 1977 | break; |
| 1978 | } |
| 1979 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 1980 | } |
| 1981 | } else if (num_pipe_configs == 4) { |
| 1982 | if (num_rbs == 4) { |
| 1983 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 1984 | switch (reg_offset) { |
| 1985 | case 0: |
| 1986 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1987 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1988 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 1989 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 1990 | break; |
| 1991 | case 1: |
| 1992 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1993 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1994 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 1995 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 1996 | break; |
| 1997 | case 2: |
| 1998 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1999 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2000 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2001 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2002 | break; |
| 2003 | case 3: |
| 2004 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2005 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2006 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2007 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 2008 | break; |
| 2009 | case 4: |
| 2010 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2011 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2012 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2013 | TILE_SPLIT(split_equal_to_row_size)); |
| 2014 | break; |
| 2015 | case 5: |
| 2016 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2017 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 2018 | break; |
| 2019 | case 6: |
| 2020 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2021 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2022 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2023 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2024 | break; |
| 2025 | case 7: |
| 2026 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2027 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2028 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2029 | TILE_SPLIT(split_equal_to_row_size)); |
| 2030 | break; |
| 2031 | case 8: |
| 2032 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | |
| 2033 | PIPE_CONFIG(ADDR_SURF_P4_16x16)); |
| 2034 | break; |
| 2035 | case 9: |
| 2036 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2037 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 2038 | break; |
| 2039 | case 10: |
| 2040 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2041 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2042 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2043 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2044 | break; |
| 2045 | case 11: |
| 2046 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2047 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2048 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2049 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2050 | break; |
| 2051 | case 12: |
| 2052 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2053 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2054 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2055 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2056 | break; |
| 2057 | case 13: |
| 2058 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2059 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 2060 | break; |
| 2061 | case 14: |
| 2062 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2063 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2064 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2065 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2066 | break; |
| 2067 | case 16: |
| 2068 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2069 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2070 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2071 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2072 | break; |
| 2073 | case 17: |
| 2074 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2075 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2076 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2077 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2078 | break; |
| 2079 | case 27: |
| 2080 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2081 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 2082 | break; |
| 2083 | case 28: |
| 2084 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2085 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2086 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2087 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2088 | break; |
| 2089 | case 29: |
| 2090 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2091 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2092 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2093 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2094 | break; |
| 2095 | case 30: |
| 2096 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2097 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2098 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2099 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2100 | break; |
| 2101 | default: |
| 2102 | gb_tile_moden = 0; |
| 2103 | break; |
| 2104 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 2105 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2106 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2107 | } |
| 2108 | } else if (num_rbs < 4) { |
| 2109 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 2110 | switch (reg_offset) { |
| 2111 | case 0: |
| 2112 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2113 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2114 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2115 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 2116 | break; |
| 2117 | case 1: |
| 2118 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2119 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2120 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2121 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 2122 | break; |
| 2123 | case 2: |
| 2124 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2125 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2126 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2127 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2128 | break; |
| 2129 | case 3: |
| 2130 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2131 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2132 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2133 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 2134 | break; |
| 2135 | case 4: |
| 2136 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2137 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2138 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2139 | TILE_SPLIT(split_equal_to_row_size)); |
| 2140 | break; |
| 2141 | case 5: |
| 2142 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2143 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 2144 | break; |
| 2145 | case 6: |
| 2146 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2147 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2148 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2149 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2150 | break; |
| 2151 | case 7: |
| 2152 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2153 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2154 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2155 | TILE_SPLIT(split_equal_to_row_size)); |
| 2156 | break; |
| 2157 | case 8: |
| 2158 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | |
| 2159 | PIPE_CONFIG(ADDR_SURF_P4_8x16)); |
| 2160 | break; |
| 2161 | case 9: |
| 2162 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2163 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 2164 | break; |
| 2165 | case 10: |
| 2166 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2167 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2168 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2169 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2170 | break; |
| 2171 | case 11: |
| 2172 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2173 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2174 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2175 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2176 | break; |
| 2177 | case 12: |
| 2178 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2179 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2180 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2181 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2182 | break; |
| 2183 | case 13: |
| 2184 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2185 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 2186 | break; |
| 2187 | case 14: |
| 2188 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2189 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2190 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2191 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2192 | break; |
| 2193 | case 16: |
| 2194 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2195 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2196 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2197 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2198 | break; |
| 2199 | case 17: |
| 2200 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2201 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2202 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2203 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2204 | break; |
| 2205 | case 27: |
| 2206 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2207 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 2208 | break; |
| 2209 | case 28: |
| 2210 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2211 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2212 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2213 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2214 | break; |
| 2215 | case 29: |
| 2216 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2217 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2218 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2219 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2220 | break; |
| 2221 | case 30: |
| 2222 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2223 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2224 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2225 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2226 | break; |
| 2227 | default: |
| 2228 | gb_tile_moden = 0; |
| 2229 | break; |
| 2230 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 2231 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2232 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2233 | } |
| 2234 | } |
| 2235 | for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) { |
| 2236 | switch (reg_offset) { |
| 2237 | case 0: |
| 2238 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2239 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2240 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2241 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2242 | break; |
| 2243 | case 1: |
| 2244 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2245 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2246 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2247 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2248 | break; |
| 2249 | case 2: |
| 2250 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2251 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2252 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2253 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2254 | break; |
| 2255 | case 3: |
| 2256 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2257 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2258 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2259 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2260 | break; |
| 2261 | case 4: |
| 2262 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2263 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2264 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2265 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2266 | break; |
| 2267 | case 5: |
| 2268 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2269 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2270 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2271 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2272 | break; |
| 2273 | case 6: |
| 2274 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2275 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2276 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 2277 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 2278 | break; |
| 2279 | case 8: |
| 2280 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2281 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
| 2282 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2283 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2284 | break; |
| 2285 | case 9: |
| 2286 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2287 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2288 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2289 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2290 | break; |
| 2291 | case 10: |
| 2292 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2293 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2294 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2295 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2296 | break; |
| 2297 | case 11: |
| 2298 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2299 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2300 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2301 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2302 | break; |
| 2303 | case 12: |
| 2304 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2305 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2306 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2307 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2308 | break; |
| 2309 | case 13: |
| 2310 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2311 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2312 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2313 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2314 | break; |
| 2315 | case 14: |
| 2316 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2317 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2318 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 2319 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 2320 | break; |
| 2321 | default: |
| 2322 | gb_tile_moden = 0; |
| 2323 | break; |
| 2324 | } |
| 2325 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2326 | } |
| 2327 | } else if (num_pipe_configs == 2) { |
| 2328 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 2329 | switch (reg_offset) { |
| 2330 | case 0: |
| 2331 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2332 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2333 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2334 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 2335 | break; |
| 2336 | case 1: |
| 2337 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2338 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2339 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2340 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 2341 | break; |
| 2342 | case 2: |
| 2343 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2344 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2345 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2346 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2347 | break; |
| 2348 | case 3: |
| 2349 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2350 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2351 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2352 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 2353 | break; |
| 2354 | case 4: |
| 2355 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2356 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2357 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2358 | TILE_SPLIT(split_equal_to_row_size)); |
| 2359 | break; |
| 2360 | case 5: |
| 2361 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2362 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 2363 | break; |
| 2364 | case 6: |
| 2365 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2366 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2367 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2368 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2369 | break; |
| 2370 | case 7: |
| 2371 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2372 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2373 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2374 | TILE_SPLIT(split_equal_to_row_size)); |
| 2375 | break; |
| 2376 | case 8: |
| 2377 | gb_tile_moden = ARRAY_MODE(ARRAY_LINEAR_ALIGNED); |
| 2378 | break; |
| 2379 | case 9: |
| 2380 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2381 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 2382 | break; |
| 2383 | case 10: |
| 2384 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2385 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2386 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2387 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2388 | break; |
| 2389 | case 11: |
| 2390 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2391 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2392 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2393 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2394 | break; |
| 2395 | case 12: |
| 2396 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2397 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2398 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2399 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2400 | break; |
| 2401 | case 13: |
| 2402 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2403 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 2404 | break; |
| 2405 | case 14: |
| 2406 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2407 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2408 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2409 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2410 | break; |
| 2411 | case 16: |
| 2412 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2413 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2414 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2415 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2416 | break; |
| 2417 | case 17: |
| 2418 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2419 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2420 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2421 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2422 | break; |
| 2423 | case 27: |
| 2424 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2425 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 2426 | break; |
| 2427 | case 28: |
| 2428 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2429 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2430 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2431 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2432 | break; |
| 2433 | case 29: |
| 2434 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2435 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2436 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2437 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2438 | break; |
| 2439 | case 30: |
| 2440 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2441 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2442 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2443 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2444 | break; |
| 2445 | default: |
| 2446 | gb_tile_moden = 0; |
| 2447 | break; |
| 2448 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 2449 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2450 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2451 | } |
| 2452 | for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) { |
| 2453 | switch (reg_offset) { |
| 2454 | case 0: |
| 2455 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2456 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2457 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2458 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2459 | break; |
| 2460 | case 1: |
| 2461 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2462 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2463 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2464 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2465 | break; |
| 2466 | case 2: |
| 2467 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2468 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2469 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2470 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2471 | break; |
| 2472 | case 3: |
| 2473 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2474 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2475 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2476 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2477 | break; |
| 2478 | case 4: |
| 2479 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2480 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2481 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2482 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2483 | break; |
| 2484 | case 5: |
| 2485 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2486 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2487 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2488 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2489 | break; |
| 2490 | case 6: |
| 2491 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2492 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2493 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2494 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2495 | break; |
| 2496 | case 8: |
| 2497 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) | |
| 2498 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
| 2499 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2500 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2501 | break; |
| 2502 | case 9: |
| 2503 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) | |
| 2504 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2505 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2506 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2507 | break; |
| 2508 | case 10: |
| 2509 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2510 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2511 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2512 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2513 | break; |
| 2514 | case 11: |
| 2515 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2516 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2517 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2518 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2519 | break; |
| 2520 | case 12: |
| 2521 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2522 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2523 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2524 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2525 | break; |
| 2526 | case 13: |
| 2527 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2528 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2529 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2530 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2531 | break; |
| 2532 | case 14: |
| 2533 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2534 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2535 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2536 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2537 | break; |
| 2538 | default: |
| 2539 | gb_tile_moden = 0; |
| 2540 | break; |
| 2541 | } |
| 2542 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2543 | } |
| 2544 | } else |
| 2545 | DRM_ERROR("unknown num pipe config: 0x%x\n", num_pipe_configs); |
| 2546 | } |
| 2547 | |
| 2548 | /** |
| 2549 | * cik_select_se_sh - select which SE, SH to address |
| 2550 | * |
| 2551 | * @rdev: radeon_device pointer |
| 2552 | * @se_num: shader engine to address |
| 2553 | * @sh_num: sh block to address |
| 2554 | * |
| 2555 | * Select which SE, SH combinations to address. Certain |
| 2556 | * registers are instanced per SE or SH. 0xffffffff means |
| 2557 | * broadcast to all SEs or SHs (CIK). |
| 2558 | */ |
| 2559 | static void cik_select_se_sh(struct radeon_device *rdev, |
| 2560 | u32 se_num, u32 sh_num) |
| 2561 | { |
| 2562 | u32 data = INSTANCE_BROADCAST_WRITES; |
| 2563 | |
| 2564 | if ((se_num == 0xffffffff) && (sh_num == 0xffffffff)) |
Alex Deucher | b0fe3d3 | 2013-04-18 16:25:47 -0400 | [diff] [blame] | 2565 | data |= SH_BROADCAST_WRITES | SE_BROADCAST_WRITES; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2566 | else if (se_num == 0xffffffff) |
| 2567 | data |= SE_BROADCAST_WRITES | SH_INDEX(sh_num); |
| 2568 | else if (sh_num == 0xffffffff) |
| 2569 | data |= SH_BROADCAST_WRITES | SE_INDEX(se_num); |
| 2570 | else |
| 2571 | data |= SH_INDEX(sh_num) | SE_INDEX(se_num); |
| 2572 | WREG32(GRBM_GFX_INDEX, data); |
| 2573 | } |
| 2574 | |
| 2575 | /** |
| 2576 | * cik_create_bitmask - create a bitmask |
| 2577 | * |
| 2578 | * @bit_width: length of the mask |
| 2579 | * |
| 2580 | * create a variable length bit mask (CIK). |
| 2581 | * Returns the bitmask. |
| 2582 | */ |
| 2583 | static u32 cik_create_bitmask(u32 bit_width) |
| 2584 | { |
| 2585 | u32 i, mask = 0; |
| 2586 | |
| 2587 | for (i = 0; i < bit_width; i++) { |
| 2588 | mask <<= 1; |
| 2589 | mask |= 1; |
| 2590 | } |
| 2591 | return mask; |
| 2592 | } |
| 2593 | |
| 2594 | /** |
| 2595 | * cik_select_se_sh - select which SE, SH to address |
| 2596 | * |
| 2597 | * @rdev: radeon_device pointer |
| 2598 | * @max_rb_num: max RBs (render backends) for the asic |
| 2599 | * @se_num: number of SEs (shader engines) for the asic |
| 2600 | * @sh_per_se: number of SH blocks per SE for the asic |
| 2601 | * |
| 2602 | * Calculates the bitmask of disabled RBs (CIK). |
| 2603 | * Returns the disabled RB bitmask. |
| 2604 | */ |
| 2605 | static u32 cik_get_rb_disabled(struct radeon_device *rdev, |
| 2606 | u32 max_rb_num, u32 se_num, |
| 2607 | u32 sh_per_se) |
| 2608 | { |
| 2609 | u32 data, mask; |
| 2610 | |
| 2611 | data = RREG32(CC_RB_BACKEND_DISABLE); |
| 2612 | if (data & 1) |
| 2613 | data &= BACKEND_DISABLE_MASK; |
| 2614 | else |
| 2615 | data = 0; |
| 2616 | data |= RREG32(GC_USER_RB_BACKEND_DISABLE); |
| 2617 | |
| 2618 | data >>= BACKEND_DISABLE_SHIFT; |
| 2619 | |
| 2620 | mask = cik_create_bitmask(max_rb_num / se_num / sh_per_se); |
| 2621 | |
| 2622 | return data & mask; |
| 2623 | } |
| 2624 | |
| 2625 | /** |
| 2626 | * cik_setup_rb - setup the RBs on the asic |
| 2627 | * |
| 2628 | * @rdev: radeon_device pointer |
| 2629 | * @se_num: number of SEs (shader engines) for the asic |
| 2630 | * @sh_per_se: number of SH blocks per SE for the asic |
| 2631 | * @max_rb_num: max RBs (render backends) for the asic |
| 2632 | * |
| 2633 | * Configures per-SE/SH RB registers (CIK). |
| 2634 | */ |
| 2635 | static void cik_setup_rb(struct radeon_device *rdev, |
| 2636 | u32 se_num, u32 sh_per_se, |
| 2637 | u32 max_rb_num) |
| 2638 | { |
| 2639 | int i, j; |
| 2640 | u32 data, mask; |
| 2641 | u32 disabled_rbs = 0; |
| 2642 | u32 enabled_rbs = 0; |
| 2643 | |
| 2644 | for (i = 0; i < se_num; i++) { |
| 2645 | for (j = 0; j < sh_per_se; j++) { |
| 2646 | cik_select_se_sh(rdev, i, j); |
| 2647 | data = cik_get_rb_disabled(rdev, max_rb_num, se_num, sh_per_se); |
| 2648 | disabled_rbs |= data << ((i * sh_per_se + j) * CIK_RB_BITMAP_WIDTH_PER_SH); |
| 2649 | } |
| 2650 | } |
| 2651 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 2652 | |
| 2653 | mask = 1; |
| 2654 | for (i = 0; i < max_rb_num; i++) { |
| 2655 | if (!(disabled_rbs & mask)) |
| 2656 | enabled_rbs |= mask; |
| 2657 | mask <<= 1; |
| 2658 | } |
| 2659 | |
| 2660 | for (i = 0; i < se_num; i++) { |
| 2661 | cik_select_se_sh(rdev, i, 0xffffffff); |
| 2662 | data = 0; |
| 2663 | for (j = 0; j < sh_per_se; j++) { |
| 2664 | switch (enabled_rbs & 3) { |
| 2665 | case 1: |
| 2666 | data |= (RASTER_CONFIG_RB_MAP_0 << (i * sh_per_se + j) * 2); |
| 2667 | break; |
| 2668 | case 2: |
| 2669 | data |= (RASTER_CONFIG_RB_MAP_3 << (i * sh_per_se + j) * 2); |
| 2670 | break; |
| 2671 | case 3: |
| 2672 | default: |
| 2673 | data |= (RASTER_CONFIG_RB_MAP_2 << (i * sh_per_se + j) * 2); |
| 2674 | break; |
| 2675 | } |
| 2676 | enabled_rbs >>= 2; |
| 2677 | } |
| 2678 | WREG32(PA_SC_RASTER_CONFIG, data); |
| 2679 | } |
| 2680 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 2681 | } |
| 2682 | |
| 2683 | /** |
| 2684 | * cik_gpu_init - setup the 3D engine |
| 2685 | * |
| 2686 | * @rdev: radeon_device pointer |
| 2687 | * |
| 2688 | * Configures the 3D engine and tiling configuration |
| 2689 | * registers so that the 3D engine is usable. |
| 2690 | */ |
| 2691 | static void cik_gpu_init(struct radeon_device *rdev) |
| 2692 | { |
| 2693 | u32 gb_addr_config = RREG32(GB_ADDR_CONFIG); |
| 2694 | u32 mc_shared_chmap, mc_arb_ramcfg; |
| 2695 | u32 hdp_host_path_cntl; |
| 2696 | u32 tmp; |
| 2697 | int i, j; |
| 2698 | |
| 2699 | switch (rdev->family) { |
| 2700 | case CHIP_BONAIRE: |
| 2701 | rdev->config.cik.max_shader_engines = 2; |
| 2702 | rdev->config.cik.max_tile_pipes = 4; |
| 2703 | rdev->config.cik.max_cu_per_sh = 7; |
| 2704 | rdev->config.cik.max_sh_per_se = 1; |
| 2705 | rdev->config.cik.max_backends_per_se = 2; |
| 2706 | rdev->config.cik.max_texture_channel_caches = 4; |
| 2707 | rdev->config.cik.max_gprs = 256; |
| 2708 | rdev->config.cik.max_gs_threads = 32; |
| 2709 | rdev->config.cik.max_hw_contexts = 8; |
| 2710 | |
| 2711 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2712 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2713 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2714 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2715 | gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
| 2716 | break; |
Alex Deucher | b496038 | 2013-08-06 15:42:49 -0400 | [diff] [blame] | 2717 | case CHIP_HAWAII: |
| 2718 | rdev->config.cik.max_shader_engines = 4; |
| 2719 | rdev->config.cik.max_tile_pipes = 16; |
| 2720 | rdev->config.cik.max_cu_per_sh = 11; |
| 2721 | rdev->config.cik.max_sh_per_se = 1; |
| 2722 | rdev->config.cik.max_backends_per_se = 4; |
| 2723 | rdev->config.cik.max_texture_channel_caches = 16; |
| 2724 | rdev->config.cik.max_gprs = 256; |
| 2725 | rdev->config.cik.max_gs_threads = 32; |
| 2726 | rdev->config.cik.max_hw_contexts = 8; |
| 2727 | |
| 2728 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2729 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2730 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2731 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2732 | gb_addr_config = HAWAII_GB_ADDR_CONFIG_GOLDEN; |
| 2733 | break; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2734 | case CHIP_KAVERI: |
Alex Deucher | b2e4c70 | 2013-06-10 15:18:26 -0400 | [diff] [blame] | 2735 | rdev->config.cik.max_shader_engines = 1; |
| 2736 | rdev->config.cik.max_tile_pipes = 4; |
| 2737 | if ((rdev->pdev->device == 0x1304) || |
| 2738 | (rdev->pdev->device == 0x1305) || |
| 2739 | (rdev->pdev->device == 0x130C) || |
| 2740 | (rdev->pdev->device == 0x130F) || |
| 2741 | (rdev->pdev->device == 0x1310) || |
| 2742 | (rdev->pdev->device == 0x1311) || |
| 2743 | (rdev->pdev->device == 0x131C)) { |
| 2744 | rdev->config.cik.max_cu_per_sh = 8; |
| 2745 | rdev->config.cik.max_backends_per_se = 2; |
| 2746 | } else if ((rdev->pdev->device == 0x1309) || |
| 2747 | (rdev->pdev->device == 0x130A) || |
| 2748 | (rdev->pdev->device == 0x130D) || |
Alex Deucher | 7c4622d | 2013-09-04 16:46:07 -0400 | [diff] [blame] | 2749 | (rdev->pdev->device == 0x1313) || |
| 2750 | (rdev->pdev->device == 0x131D)) { |
Alex Deucher | b2e4c70 | 2013-06-10 15:18:26 -0400 | [diff] [blame] | 2751 | rdev->config.cik.max_cu_per_sh = 6; |
| 2752 | rdev->config.cik.max_backends_per_se = 2; |
| 2753 | } else if ((rdev->pdev->device == 0x1306) || |
| 2754 | (rdev->pdev->device == 0x1307) || |
| 2755 | (rdev->pdev->device == 0x130B) || |
| 2756 | (rdev->pdev->device == 0x130E) || |
| 2757 | (rdev->pdev->device == 0x1315) || |
| 2758 | (rdev->pdev->device == 0x131B)) { |
| 2759 | rdev->config.cik.max_cu_per_sh = 4; |
| 2760 | rdev->config.cik.max_backends_per_se = 1; |
| 2761 | } else { |
| 2762 | rdev->config.cik.max_cu_per_sh = 3; |
| 2763 | rdev->config.cik.max_backends_per_se = 1; |
| 2764 | } |
| 2765 | rdev->config.cik.max_sh_per_se = 1; |
| 2766 | rdev->config.cik.max_texture_channel_caches = 4; |
| 2767 | rdev->config.cik.max_gprs = 256; |
| 2768 | rdev->config.cik.max_gs_threads = 16; |
| 2769 | rdev->config.cik.max_hw_contexts = 8; |
| 2770 | |
| 2771 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2772 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2773 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2774 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2775 | gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2776 | break; |
| 2777 | case CHIP_KABINI: |
| 2778 | default: |
| 2779 | rdev->config.cik.max_shader_engines = 1; |
| 2780 | rdev->config.cik.max_tile_pipes = 2; |
| 2781 | rdev->config.cik.max_cu_per_sh = 2; |
| 2782 | rdev->config.cik.max_sh_per_se = 1; |
| 2783 | rdev->config.cik.max_backends_per_se = 1; |
| 2784 | rdev->config.cik.max_texture_channel_caches = 2; |
| 2785 | rdev->config.cik.max_gprs = 256; |
| 2786 | rdev->config.cik.max_gs_threads = 16; |
| 2787 | rdev->config.cik.max_hw_contexts = 8; |
| 2788 | |
| 2789 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2790 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2791 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2792 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2793 | gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
| 2794 | break; |
| 2795 | } |
| 2796 | |
| 2797 | /* Initialize HDP */ |
| 2798 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 2799 | WREG32((0x2c14 + j), 0x00000000); |
| 2800 | WREG32((0x2c18 + j), 0x00000000); |
| 2801 | WREG32((0x2c1c + j), 0x00000000); |
| 2802 | WREG32((0x2c20 + j), 0x00000000); |
| 2803 | WREG32((0x2c24 + j), 0x00000000); |
| 2804 | } |
| 2805 | |
| 2806 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); |
| 2807 | |
| 2808 | WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN); |
| 2809 | |
| 2810 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); |
| 2811 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); |
| 2812 | |
| 2813 | rdev->config.cik.num_tile_pipes = rdev->config.cik.max_tile_pipes; |
| 2814 | rdev->config.cik.mem_max_burst_length_bytes = 256; |
| 2815 | tmp = (mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT; |
| 2816 | rdev->config.cik.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024; |
| 2817 | if (rdev->config.cik.mem_row_size_in_kb > 4) |
| 2818 | rdev->config.cik.mem_row_size_in_kb = 4; |
| 2819 | /* XXX use MC settings? */ |
| 2820 | rdev->config.cik.shader_engine_tile_size = 32; |
| 2821 | rdev->config.cik.num_gpus = 1; |
| 2822 | rdev->config.cik.multi_gpu_tile_size = 64; |
| 2823 | |
| 2824 | /* fix up row size */ |
| 2825 | gb_addr_config &= ~ROW_SIZE_MASK; |
| 2826 | switch (rdev->config.cik.mem_row_size_in_kb) { |
| 2827 | case 1: |
| 2828 | default: |
| 2829 | gb_addr_config |= ROW_SIZE(0); |
| 2830 | break; |
| 2831 | case 2: |
| 2832 | gb_addr_config |= ROW_SIZE(1); |
| 2833 | break; |
| 2834 | case 4: |
| 2835 | gb_addr_config |= ROW_SIZE(2); |
| 2836 | break; |
| 2837 | } |
| 2838 | |
| 2839 | /* setup tiling info dword. gb_addr_config is not adequate since it does |
| 2840 | * not have bank info, so create a custom tiling dword. |
| 2841 | * bits 3:0 num_pipes |
| 2842 | * bits 7:4 num_banks |
| 2843 | * bits 11:8 group_size |
| 2844 | * bits 15:12 row_size |
| 2845 | */ |
| 2846 | rdev->config.cik.tile_config = 0; |
| 2847 | switch (rdev->config.cik.num_tile_pipes) { |
| 2848 | case 1: |
| 2849 | rdev->config.cik.tile_config |= (0 << 0); |
| 2850 | break; |
| 2851 | case 2: |
| 2852 | rdev->config.cik.tile_config |= (1 << 0); |
| 2853 | break; |
| 2854 | case 4: |
| 2855 | rdev->config.cik.tile_config |= (2 << 0); |
| 2856 | break; |
| 2857 | case 8: |
| 2858 | default: |
| 2859 | /* XXX what about 12? */ |
| 2860 | rdev->config.cik.tile_config |= (3 << 0); |
| 2861 | break; |
| 2862 | } |
Michel Dänzer | a537314 | 2013-09-18 15:39:41 +0200 | [diff] [blame] | 2863 | rdev->config.cik.tile_config |= |
| 2864 | ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2865 | rdev->config.cik.tile_config |= |
| 2866 | ((gb_addr_config & PIPE_INTERLEAVE_SIZE_MASK) >> PIPE_INTERLEAVE_SIZE_SHIFT) << 8; |
| 2867 | rdev->config.cik.tile_config |= |
| 2868 | ((gb_addr_config & ROW_SIZE_MASK) >> ROW_SIZE_SHIFT) << 12; |
| 2869 | |
| 2870 | WREG32(GB_ADDR_CONFIG, gb_addr_config); |
| 2871 | WREG32(HDP_ADDR_CONFIG, gb_addr_config); |
| 2872 | WREG32(DMIF_ADDR_CALC, gb_addr_config); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 2873 | WREG32(SDMA0_TILING_CONFIG + SDMA0_REGISTER_OFFSET, gb_addr_config & 0x70); |
| 2874 | WREG32(SDMA0_TILING_CONFIG + SDMA1_REGISTER_OFFSET, gb_addr_config & 0x70); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 2875 | WREG32(UVD_UDEC_ADDR_CONFIG, gb_addr_config); |
| 2876 | WREG32(UVD_UDEC_DB_ADDR_CONFIG, gb_addr_config); |
| 2877 | WREG32(UVD_UDEC_DBW_ADDR_CONFIG, gb_addr_config); |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2878 | |
| 2879 | cik_tiling_mode_table_init(rdev); |
| 2880 | |
| 2881 | cik_setup_rb(rdev, rdev->config.cik.max_shader_engines, |
| 2882 | rdev->config.cik.max_sh_per_se, |
| 2883 | rdev->config.cik.max_backends_per_se); |
| 2884 | |
| 2885 | /* set HW defaults for 3D engine */ |
| 2886 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); |
| 2887 | |
| 2888 | WREG32(SX_DEBUG_1, 0x20); |
| 2889 | |
| 2890 | WREG32(TA_CNTL_AUX, 0x00010000); |
| 2891 | |
| 2892 | tmp = RREG32(SPI_CONFIG_CNTL); |
| 2893 | tmp |= 0x03000000; |
| 2894 | WREG32(SPI_CONFIG_CNTL, tmp); |
| 2895 | |
| 2896 | WREG32(SQ_CONFIG, 1); |
| 2897 | |
| 2898 | WREG32(DB_DEBUG, 0); |
| 2899 | |
| 2900 | tmp = RREG32(DB_DEBUG2) & ~0xf00fffff; |
| 2901 | tmp |= 0x00000400; |
| 2902 | WREG32(DB_DEBUG2, tmp); |
| 2903 | |
| 2904 | tmp = RREG32(DB_DEBUG3) & ~0x0002021c; |
| 2905 | tmp |= 0x00020200; |
| 2906 | WREG32(DB_DEBUG3, tmp); |
| 2907 | |
| 2908 | tmp = RREG32(CB_HW_CONTROL) & ~0x00010000; |
| 2909 | tmp |= 0x00018208; |
| 2910 | WREG32(CB_HW_CONTROL, tmp); |
| 2911 | |
| 2912 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4)); |
| 2913 | |
| 2914 | WREG32(PA_SC_FIFO_SIZE, (SC_FRONTEND_PRIM_FIFO_SIZE(rdev->config.cik.sc_prim_fifo_size_frontend) | |
| 2915 | SC_BACKEND_PRIM_FIFO_SIZE(rdev->config.cik.sc_prim_fifo_size_backend) | |
| 2916 | SC_HIZ_TILE_FIFO_SIZE(rdev->config.cik.sc_hiz_tile_fifo_size) | |
| 2917 | SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.cik.sc_earlyz_tile_fifo_size))); |
| 2918 | |
| 2919 | WREG32(VGT_NUM_INSTANCES, 1); |
| 2920 | |
| 2921 | WREG32(CP_PERFMON_CNTL, 0); |
| 2922 | |
| 2923 | WREG32(SQ_CONFIG, 0); |
| 2924 | |
| 2925 | WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) | |
| 2926 | FORCE_EOV_MAX_REZ_CNT(255))); |
| 2927 | |
| 2928 | WREG32(VGT_CACHE_INVALIDATION, CACHE_INVALIDATION(VC_AND_TC) | |
| 2929 | AUTO_INVLD_EN(ES_AND_GS_AUTO)); |
| 2930 | |
| 2931 | WREG32(VGT_GS_VERTEX_REUSE, 16); |
| 2932 | WREG32(PA_SC_LINE_STIPPLE_STATE, 0); |
| 2933 | |
| 2934 | tmp = RREG32(HDP_MISC_CNTL); |
| 2935 | tmp |= HDP_FLUSH_INVALIDATE_CACHE; |
| 2936 | WREG32(HDP_MISC_CNTL, tmp); |
| 2937 | |
| 2938 | hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); |
| 2939 | WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); |
| 2940 | |
| 2941 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); |
| 2942 | WREG32(PA_SC_ENHANCE, ENABLE_PA_SC_OUT_OF_ORDER); |
| 2943 | |
| 2944 | udelay(50); |
| 2945 | } |
| 2946 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 2947 | /* |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 2948 | * GPU scratch registers helpers function. |
| 2949 | */ |
| 2950 | /** |
| 2951 | * cik_scratch_init - setup driver info for CP scratch regs |
| 2952 | * |
| 2953 | * @rdev: radeon_device pointer |
| 2954 | * |
| 2955 | * Set up the number and offset of the CP scratch registers. |
| 2956 | * NOTE: use of CP scratch registers is a legacy inferface and |
| 2957 | * is not used by default on newer asics (r6xx+). On newer asics, |
| 2958 | * memory buffers are used for fences rather than scratch regs. |
| 2959 | */ |
| 2960 | static void cik_scratch_init(struct radeon_device *rdev) |
| 2961 | { |
| 2962 | int i; |
| 2963 | |
| 2964 | rdev->scratch.num_reg = 7; |
| 2965 | rdev->scratch.reg_base = SCRATCH_REG0; |
| 2966 | for (i = 0; i < rdev->scratch.num_reg; i++) { |
| 2967 | rdev->scratch.free[i] = true; |
| 2968 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); |
| 2969 | } |
| 2970 | } |
| 2971 | |
| 2972 | /** |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 2973 | * cik_ring_test - basic gfx ring test |
| 2974 | * |
| 2975 | * @rdev: radeon_device pointer |
| 2976 | * @ring: radeon_ring structure holding ring information |
| 2977 | * |
| 2978 | * Allocate a scratch register and write to it using the gfx ring (CIK). |
| 2979 | * Provides a basic gfx ring test to verify that the ring is working. |
| 2980 | * Used by cik_cp_gfx_resume(); |
| 2981 | * Returns 0 on success, error on failure. |
| 2982 | */ |
| 2983 | int cik_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) |
| 2984 | { |
| 2985 | uint32_t scratch; |
| 2986 | uint32_t tmp = 0; |
| 2987 | unsigned i; |
| 2988 | int r; |
| 2989 | |
| 2990 | r = radeon_scratch_get(rdev, &scratch); |
| 2991 | if (r) { |
| 2992 | DRM_ERROR("radeon: cp failed to get scratch reg (%d).\n", r); |
| 2993 | return r; |
| 2994 | } |
| 2995 | WREG32(scratch, 0xCAFEDEAD); |
| 2996 | r = radeon_ring_lock(rdev, ring, 3); |
| 2997 | if (r) { |
| 2998 | DRM_ERROR("radeon: cp failed to lock ring %d (%d).\n", ring->idx, r); |
| 2999 | radeon_scratch_free(rdev, scratch); |
| 3000 | return r; |
| 3001 | } |
| 3002 | radeon_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1)); |
| 3003 | radeon_ring_write(ring, ((scratch - PACKET3_SET_UCONFIG_REG_START) >> 2)); |
| 3004 | radeon_ring_write(ring, 0xDEADBEEF); |
| 3005 | radeon_ring_unlock_commit(rdev, ring); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3006 | |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3007 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 3008 | tmp = RREG32(scratch); |
| 3009 | if (tmp == 0xDEADBEEF) |
| 3010 | break; |
| 3011 | DRM_UDELAY(1); |
| 3012 | } |
| 3013 | if (i < rdev->usec_timeout) { |
| 3014 | DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i); |
| 3015 | } else { |
| 3016 | DRM_ERROR("radeon: ring %d test failed (scratch(0x%04X)=0x%08X)\n", |
| 3017 | ring->idx, scratch, tmp); |
| 3018 | r = -EINVAL; |
| 3019 | } |
| 3020 | radeon_scratch_free(rdev, scratch); |
| 3021 | return r; |
| 3022 | } |
| 3023 | |
| 3024 | /** |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 3025 | * cik_fence_gfx_ring_emit - emit a fence on the gfx ring |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3026 | * |
| 3027 | * @rdev: radeon_device pointer |
| 3028 | * @fence: radeon fence object |
| 3029 | * |
| 3030 | * Emits a fence sequnce number on the gfx ring and flushes |
| 3031 | * GPU caches. |
| 3032 | */ |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 3033 | void cik_fence_gfx_ring_emit(struct radeon_device *rdev, |
| 3034 | struct radeon_fence *fence) |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3035 | { |
| 3036 | struct radeon_ring *ring = &rdev->ring[fence->ring]; |
| 3037 | u64 addr = rdev->fence_drv[fence->ring].gpu_addr; |
| 3038 | |
| 3039 | /* EVENT_WRITE_EOP - flush caches, send int */ |
| 3040 | radeon_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); |
| 3041 | radeon_ring_write(ring, (EOP_TCL1_ACTION_EN | |
| 3042 | EOP_TC_ACTION_EN | |
| 3043 | EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | |
| 3044 | EVENT_INDEX(5))); |
| 3045 | radeon_ring_write(ring, addr & 0xfffffffc); |
| 3046 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xffff) | DATA_SEL(1) | INT_SEL(2)); |
| 3047 | radeon_ring_write(ring, fence->seq); |
| 3048 | radeon_ring_write(ring, 0); |
| 3049 | /* HDP flush */ |
| 3050 | /* We should be using the new WAIT_REG_MEM special op packet here |
| 3051 | * but it causes the CP to hang |
| 3052 | */ |
| 3053 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 3054 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 3055 | WRITE_DATA_DST_SEL(0))); |
| 3056 | radeon_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL >> 2); |
| 3057 | radeon_ring_write(ring, 0); |
| 3058 | radeon_ring_write(ring, 0); |
| 3059 | } |
| 3060 | |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 3061 | /** |
| 3062 | * cik_fence_compute_ring_emit - emit a fence on the compute ring |
| 3063 | * |
| 3064 | * @rdev: radeon_device pointer |
| 3065 | * @fence: radeon fence object |
| 3066 | * |
| 3067 | * Emits a fence sequnce number on the compute ring and flushes |
| 3068 | * GPU caches. |
| 3069 | */ |
| 3070 | void cik_fence_compute_ring_emit(struct radeon_device *rdev, |
| 3071 | struct radeon_fence *fence) |
| 3072 | { |
| 3073 | struct radeon_ring *ring = &rdev->ring[fence->ring]; |
| 3074 | u64 addr = rdev->fence_drv[fence->ring].gpu_addr; |
| 3075 | |
| 3076 | /* RELEASE_MEM - flush caches, send int */ |
| 3077 | radeon_ring_write(ring, PACKET3(PACKET3_RELEASE_MEM, 5)); |
| 3078 | radeon_ring_write(ring, (EOP_TCL1_ACTION_EN | |
| 3079 | EOP_TC_ACTION_EN | |
| 3080 | EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | |
| 3081 | EVENT_INDEX(5))); |
| 3082 | radeon_ring_write(ring, DATA_SEL(1) | INT_SEL(2)); |
| 3083 | radeon_ring_write(ring, addr & 0xfffffffc); |
| 3084 | radeon_ring_write(ring, upper_32_bits(addr)); |
| 3085 | radeon_ring_write(ring, fence->seq); |
| 3086 | radeon_ring_write(ring, 0); |
| 3087 | /* HDP flush */ |
| 3088 | /* We should be using the new WAIT_REG_MEM special op packet here |
| 3089 | * but it causes the CP to hang |
| 3090 | */ |
| 3091 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 3092 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 3093 | WRITE_DATA_DST_SEL(0))); |
| 3094 | radeon_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL >> 2); |
| 3095 | radeon_ring_write(ring, 0); |
| 3096 | radeon_ring_write(ring, 0); |
| 3097 | } |
| 3098 | |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3099 | void cik_semaphore_ring_emit(struct radeon_device *rdev, |
| 3100 | struct radeon_ring *ring, |
| 3101 | struct radeon_semaphore *semaphore, |
| 3102 | bool emit_wait) |
| 3103 | { |
| 3104 | uint64_t addr = semaphore->gpu_addr; |
| 3105 | unsigned sel = emit_wait ? PACKET3_SEM_SEL_WAIT : PACKET3_SEM_SEL_SIGNAL; |
| 3106 | |
| 3107 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); |
| 3108 | radeon_ring_write(ring, addr & 0xffffffff); |
| 3109 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xffff) | sel); |
| 3110 | } |
| 3111 | |
Alex Deucher | c9dbd70 | 2013-10-01 16:36:51 -0400 | [diff] [blame] | 3112 | /** |
| 3113 | * cik_copy_cpdma - copy pages using the CP DMA engine |
| 3114 | * |
| 3115 | * @rdev: radeon_device pointer |
| 3116 | * @src_offset: src GPU address |
| 3117 | * @dst_offset: dst GPU address |
| 3118 | * @num_gpu_pages: number of GPU pages to xfer |
| 3119 | * @fence: radeon fence object |
| 3120 | * |
| 3121 | * Copy GPU paging using the CP DMA engine (CIK+). |
| 3122 | * Used by the radeon ttm implementation to move pages if |
| 3123 | * registered as the asic copy callback. |
| 3124 | */ |
| 3125 | int cik_copy_cpdma(struct radeon_device *rdev, |
| 3126 | uint64_t src_offset, uint64_t dst_offset, |
| 3127 | unsigned num_gpu_pages, |
| 3128 | struct radeon_fence **fence) |
| 3129 | { |
| 3130 | struct radeon_semaphore *sem = NULL; |
| 3131 | int ring_index = rdev->asic->copy.blit_ring_index; |
| 3132 | struct radeon_ring *ring = &rdev->ring[ring_index]; |
| 3133 | u32 size_in_bytes, cur_size_in_bytes, control; |
| 3134 | int i, num_loops; |
| 3135 | int r = 0; |
| 3136 | |
| 3137 | r = radeon_semaphore_create(rdev, &sem); |
| 3138 | if (r) { |
| 3139 | DRM_ERROR("radeon: moving bo (%d).\n", r); |
| 3140 | return r; |
| 3141 | } |
| 3142 | |
| 3143 | size_in_bytes = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT); |
| 3144 | num_loops = DIV_ROUND_UP(size_in_bytes, 0x1fffff); |
| 3145 | r = radeon_ring_lock(rdev, ring, num_loops * 7 + 18); |
| 3146 | if (r) { |
| 3147 | DRM_ERROR("radeon: moving bo (%d).\n", r); |
| 3148 | radeon_semaphore_free(rdev, &sem, NULL); |
| 3149 | return r; |
| 3150 | } |
| 3151 | |
| 3152 | if (radeon_fence_need_sync(*fence, ring->idx)) { |
| 3153 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, |
| 3154 | ring->idx); |
| 3155 | radeon_fence_note_sync(*fence, ring->idx); |
| 3156 | } else { |
| 3157 | radeon_semaphore_free(rdev, &sem, NULL); |
| 3158 | } |
| 3159 | |
| 3160 | for (i = 0; i < num_loops; i++) { |
| 3161 | cur_size_in_bytes = size_in_bytes; |
| 3162 | if (cur_size_in_bytes > 0x1fffff) |
| 3163 | cur_size_in_bytes = 0x1fffff; |
| 3164 | size_in_bytes -= cur_size_in_bytes; |
| 3165 | control = 0; |
| 3166 | if (size_in_bytes == 0) |
| 3167 | control |= PACKET3_DMA_DATA_CP_SYNC; |
| 3168 | radeon_ring_write(ring, PACKET3(PACKET3_DMA_DATA, 5)); |
| 3169 | radeon_ring_write(ring, control); |
| 3170 | radeon_ring_write(ring, lower_32_bits(src_offset)); |
| 3171 | radeon_ring_write(ring, upper_32_bits(src_offset)); |
| 3172 | radeon_ring_write(ring, lower_32_bits(dst_offset)); |
| 3173 | radeon_ring_write(ring, upper_32_bits(dst_offset)); |
| 3174 | radeon_ring_write(ring, cur_size_in_bytes); |
| 3175 | src_offset += cur_size_in_bytes; |
| 3176 | dst_offset += cur_size_in_bytes; |
| 3177 | } |
| 3178 | |
| 3179 | r = radeon_fence_emit(rdev, fence, ring->idx); |
| 3180 | if (r) { |
| 3181 | radeon_ring_unlock_undo(rdev, ring); |
| 3182 | return r; |
| 3183 | } |
| 3184 | |
| 3185 | radeon_ring_unlock_commit(rdev, ring); |
| 3186 | radeon_semaphore_free(rdev, &sem, *fence); |
| 3187 | |
| 3188 | return r; |
| 3189 | } |
| 3190 | |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3191 | /* |
| 3192 | * IB stuff |
| 3193 | */ |
| 3194 | /** |
| 3195 | * cik_ring_ib_execute - emit an IB (Indirect Buffer) on the gfx ring |
| 3196 | * |
| 3197 | * @rdev: radeon_device pointer |
| 3198 | * @ib: radeon indirect buffer object |
| 3199 | * |
| 3200 | * Emits an DE (drawing engine) or CE (constant engine) IB |
| 3201 | * on the gfx ring. IBs are usually generated by userspace |
| 3202 | * acceleration drivers and submitted to the kernel for |
| 3203 | * sheduling on the ring. This function schedules the IB |
| 3204 | * on the gfx ring for execution by the GPU. |
| 3205 | */ |
| 3206 | void cik_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) |
| 3207 | { |
| 3208 | struct radeon_ring *ring = &rdev->ring[ib->ring]; |
| 3209 | u32 header, control = INDIRECT_BUFFER_VALID; |
| 3210 | |
| 3211 | if (ib->is_const_ib) { |
| 3212 | /* set switch buffer packet before const IB */ |
| 3213 | radeon_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); |
| 3214 | radeon_ring_write(ring, 0); |
| 3215 | |
| 3216 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); |
| 3217 | } else { |
| 3218 | u32 next_rptr; |
| 3219 | if (ring->rptr_save_reg) { |
| 3220 | next_rptr = ring->wptr + 3 + 4; |
| 3221 | radeon_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1)); |
| 3222 | radeon_ring_write(ring, ((ring->rptr_save_reg - |
| 3223 | PACKET3_SET_UCONFIG_REG_START) >> 2)); |
| 3224 | radeon_ring_write(ring, next_rptr); |
| 3225 | } else if (rdev->wb.enabled) { |
| 3226 | next_rptr = ring->wptr + 5 + 4; |
| 3227 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 3228 | radeon_ring_write(ring, WRITE_DATA_DST_SEL(1)); |
| 3229 | radeon_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc); |
| 3230 | radeon_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr) & 0xffffffff); |
| 3231 | radeon_ring_write(ring, next_rptr); |
| 3232 | } |
| 3233 | |
| 3234 | header = PACKET3(PACKET3_INDIRECT_BUFFER, 2); |
| 3235 | } |
| 3236 | |
| 3237 | control |= ib->length_dw | |
| 3238 | (ib->vm ? (ib->vm->id << 24) : 0); |
| 3239 | |
| 3240 | radeon_ring_write(ring, header); |
| 3241 | radeon_ring_write(ring, |
| 3242 | #ifdef __BIG_ENDIAN |
| 3243 | (2 << 0) | |
| 3244 | #endif |
| 3245 | (ib->gpu_addr & 0xFFFFFFFC)); |
| 3246 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF); |
| 3247 | radeon_ring_write(ring, control); |
| 3248 | } |
| 3249 | |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3250 | /** |
| 3251 | * cik_ib_test - basic gfx ring IB test |
| 3252 | * |
| 3253 | * @rdev: radeon_device pointer |
| 3254 | * @ring: radeon_ring structure holding ring information |
| 3255 | * |
| 3256 | * Allocate an IB and execute it on the gfx ring (CIK). |
| 3257 | * Provides a basic gfx ring test to verify that IBs are working. |
| 3258 | * Returns 0 on success, error on failure. |
| 3259 | */ |
| 3260 | int cik_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) |
| 3261 | { |
| 3262 | struct radeon_ib ib; |
| 3263 | uint32_t scratch; |
| 3264 | uint32_t tmp = 0; |
| 3265 | unsigned i; |
| 3266 | int r; |
| 3267 | |
| 3268 | r = radeon_scratch_get(rdev, &scratch); |
| 3269 | if (r) { |
| 3270 | DRM_ERROR("radeon: failed to get scratch reg (%d).\n", r); |
| 3271 | return r; |
| 3272 | } |
| 3273 | WREG32(scratch, 0xCAFEDEAD); |
| 3274 | r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256); |
| 3275 | if (r) { |
| 3276 | DRM_ERROR("radeon: failed to get ib (%d).\n", r); |
Christian König | 5510f12 | 2013-10-14 11:32:28 +0200 | [diff] [blame] | 3277 | radeon_scratch_free(rdev, scratch); |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3278 | return r; |
| 3279 | } |
| 3280 | ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1); |
| 3281 | ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START) >> 2); |
| 3282 | ib.ptr[2] = 0xDEADBEEF; |
| 3283 | ib.length_dw = 3; |
| 3284 | r = radeon_ib_schedule(rdev, &ib, NULL); |
| 3285 | if (r) { |
| 3286 | radeon_scratch_free(rdev, scratch); |
| 3287 | radeon_ib_free(rdev, &ib); |
| 3288 | DRM_ERROR("radeon: failed to schedule ib (%d).\n", r); |
| 3289 | return r; |
| 3290 | } |
| 3291 | r = radeon_fence_wait(ib.fence, false); |
| 3292 | if (r) { |
| 3293 | DRM_ERROR("radeon: fence wait failed (%d).\n", r); |
Christian König | 5510f12 | 2013-10-14 11:32:28 +0200 | [diff] [blame] | 3294 | radeon_scratch_free(rdev, scratch); |
| 3295 | radeon_ib_free(rdev, &ib); |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3296 | return r; |
| 3297 | } |
| 3298 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 3299 | tmp = RREG32(scratch); |
| 3300 | if (tmp == 0xDEADBEEF) |
| 3301 | break; |
| 3302 | DRM_UDELAY(1); |
| 3303 | } |
| 3304 | if (i < rdev->usec_timeout) { |
| 3305 | DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib.fence->ring, i); |
| 3306 | } else { |
| 3307 | DRM_ERROR("radeon: ib test failed (scratch(0x%04X)=0x%08X)\n", |
| 3308 | scratch, tmp); |
| 3309 | r = -EINVAL; |
| 3310 | } |
| 3311 | radeon_scratch_free(rdev, scratch); |
| 3312 | radeon_ib_free(rdev, &ib); |
| 3313 | return r; |
| 3314 | } |
| 3315 | |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3316 | /* |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3317 | * CP. |
| 3318 | * On CIK, gfx and compute now have independant command processors. |
| 3319 | * |
| 3320 | * GFX |
| 3321 | * Gfx consists of a single ring and can process both gfx jobs and |
| 3322 | * compute jobs. The gfx CP consists of three microengines (ME): |
| 3323 | * PFP - Pre-Fetch Parser |
| 3324 | * ME - Micro Engine |
| 3325 | * CE - Constant Engine |
| 3326 | * The PFP and ME make up what is considered the Drawing Engine (DE). |
| 3327 | * The CE is an asynchronous engine used for updating buffer desciptors |
| 3328 | * used by the DE so that they can be loaded into cache in parallel |
| 3329 | * while the DE is processing state update packets. |
| 3330 | * |
| 3331 | * Compute |
| 3332 | * The compute CP consists of two microengines (ME): |
| 3333 | * MEC1 - Compute MicroEngine 1 |
| 3334 | * MEC2 - Compute MicroEngine 2 |
| 3335 | * Each MEC supports 4 compute pipes and each pipe supports 8 queues. |
| 3336 | * The queues are exposed to userspace and are programmed directly |
| 3337 | * by the compute runtime. |
| 3338 | */ |
| 3339 | /** |
| 3340 | * cik_cp_gfx_enable - enable/disable the gfx CP MEs |
| 3341 | * |
| 3342 | * @rdev: radeon_device pointer |
| 3343 | * @enable: enable or disable the MEs |
| 3344 | * |
| 3345 | * Halts or unhalts the gfx MEs. |
| 3346 | */ |
| 3347 | static void cik_cp_gfx_enable(struct radeon_device *rdev, bool enable) |
| 3348 | { |
| 3349 | if (enable) |
| 3350 | WREG32(CP_ME_CNTL, 0); |
| 3351 | else { |
| 3352 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT)); |
| 3353 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; |
| 3354 | } |
| 3355 | udelay(50); |
| 3356 | } |
| 3357 | |
| 3358 | /** |
| 3359 | * cik_cp_gfx_load_microcode - load the gfx CP ME ucode |
| 3360 | * |
| 3361 | * @rdev: radeon_device pointer |
| 3362 | * |
| 3363 | * Loads the gfx PFP, ME, and CE ucode. |
| 3364 | * Returns 0 for success, -EINVAL if the ucode is not available. |
| 3365 | */ |
| 3366 | static int cik_cp_gfx_load_microcode(struct radeon_device *rdev) |
| 3367 | { |
| 3368 | const __be32 *fw_data; |
| 3369 | int i; |
| 3370 | |
| 3371 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw) |
| 3372 | return -EINVAL; |
| 3373 | |
| 3374 | cik_cp_gfx_enable(rdev, false); |
| 3375 | |
| 3376 | /* PFP */ |
| 3377 | fw_data = (const __be32 *)rdev->pfp_fw->data; |
| 3378 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 3379 | for (i = 0; i < CIK_PFP_UCODE_SIZE; i++) |
| 3380 | WREG32(CP_PFP_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3381 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 3382 | |
| 3383 | /* CE */ |
| 3384 | fw_data = (const __be32 *)rdev->ce_fw->data; |
| 3385 | WREG32(CP_CE_UCODE_ADDR, 0); |
| 3386 | for (i = 0; i < CIK_CE_UCODE_SIZE; i++) |
| 3387 | WREG32(CP_CE_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3388 | WREG32(CP_CE_UCODE_ADDR, 0); |
| 3389 | |
| 3390 | /* ME */ |
| 3391 | fw_data = (const __be32 *)rdev->me_fw->data; |
| 3392 | WREG32(CP_ME_RAM_WADDR, 0); |
| 3393 | for (i = 0; i < CIK_ME_UCODE_SIZE; i++) |
| 3394 | WREG32(CP_ME_RAM_DATA, be32_to_cpup(fw_data++)); |
| 3395 | WREG32(CP_ME_RAM_WADDR, 0); |
| 3396 | |
| 3397 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 3398 | WREG32(CP_CE_UCODE_ADDR, 0); |
| 3399 | WREG32(CP_ME_RAM_WADDR, 0); |
| 3400 | WREG32(CP_ME_RAM_RADDR, 0); |
| 3401 | return 0; |
| 3402 | } |
| 3403 | |
| 3404 | /** |
| 3405 | * cik_cp_gfx_start - start the gfx ring |
| 3406 | * |
| 3407 | * @rdev: radeon_device pointer |
| 3408 | * |
| 3409 | * Enables the ring and loads the clear state context and other |
| 3410 | * packets required to init the ring. |
| 3411 | * Returns 0 for success, error for failure. |
| 3412 | */ |
| 3413 | static int cik_cp_gfx_start(struct radeon_device *rdev) |
| 3414 | { |
| 3415 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
| 3416 | int r, i; |
| 3417 | |
| 3418 | /* init the CP */ |
| 3419 | WREG32(CP_MAX_CONTEXT, rdev->config.cik.max_hw_contexts - 1); |
| 3420 | WREG32(CP_ENDIAN_SWAP, 0); |
| 3421 | WREG32(CP_DEVICE_ID, 1); |
| 3422 | |
| 3423 | cik_cp_gfx_enable(rdev, true); |
| 3424 | |
| 3425 | r = radeon_ring_lock(rdev, ring, cik_default_size + 17); |
| 3426 | if (r) { |
| 3427 | DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r); |
| 3428 | return r; |
| 3429 | } |
| 3430 | |
| 3431 | /* init the CE partitions. CE only used for gfx on CIK */ |
| 3432 | radeon_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2)); |
| 3433 | radeon_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE)); |
| 3434 | radeon_ring_write(ring, 0xc000); |
| 3435 | radeon_ring_write(ring, 0xc000); |
| 3436 | |
| 3437 | /* setup clear context state */ |
| 3438 | radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 3439 | radeon_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); |
| 3440 | |
| 3441 | radeon_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); |
| 3442 | radeon_ring_write(ring, 0x80000000); |
| 3443 | radeon_ring_write(ring, 0x80000000); |
| 3444 | |
| 3445 | for (i = 0; i < cik_default_size; i++) |
| 3446 | radeon_ring_write(ring, cik_default_state[i]); |
| 3447 | |
| 3448 | radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 3449 | radeon_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE); |
| 3450 | |
| 3451 | /* set clear context state */ |
| 3452 | radeon_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0)); |
| 3453 | radeon_ring_write(ring, 0); |
| 3454 | |
| 3455 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2)); |
| 3456 | radeon_ring_write(ring, 0x00000316); |
| 3457 | radeon_ring_write(ring, 0x0000000e); /* VGT_VERTEX_REUSE_BLOCK_CNTL */ |
| 3458 | radeon_ring_write(ring, 0x00000010); /* VGT_OUT_DEALLOC_CNTL */ |
| 3459 | |
| 3460 | radeon_ring_unlock_commit(rdev, ring); |
| 3461 | |
| 3462 | return 0; |
| 3463 | } |
| 3464 | |
| 3465 | /** |
| 3466 | * cik_cp_gfx_fini - stop the gfx ring |
| 3467 | * |
| 3468 | * @rdev: radeon_device pointer |
| 3469 | * |
| 3470 | * Stop the gfx ring and tear down the driver ring |
| 3471 | * info. |
| 3472 | */ |
| 3473 | static void cik_cp_gfx_fini(struct radeon_device *rdev) |
| 3474 | { |
| 3475 | cik_cp_gfx_enable(rdev, false); |
| 3476 | radeon_ring_fini(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]); |
| 3477 | } |
| 3478 | |
| 3479 | /** |
| 3480 | * cik_cp_gfx_resume - setup the gfx ring buffer registers |
| 3481 | * |
| 3482 | * @rdev: radeon_device pointer |
| 3483 | * |
| 3484 | * Program the location and size of the gfx ring buffer |
| 3485 | * and test it to make sure it's working. |
| 3486 | * Returns 0 for success, error for failure. |
| 3487 | */ |
| 3488 | static int cik_cp_gfx_resume(struct radeon_device *rdev) |
| 3489 | { |
| 3490 | struct radeon_ring *ring; |
| 3491 | u32 tmp; |
| 3492 | u32 rb_bufsz; |
| 3493 | u64 rb_addr; |
| 3494 | int r; |
| 3495 | |
| 3496 | WREG32(CP_SEM_WAIT_TIMER, 0x0); |
Alex Deucher | 939c0d3 | 2013-09-30 18:03:06 -0400 | [diff] [blame^] | 3497 | if (rdev->family != CHIP_HAWAII) |
| 3498 | WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3499 | |
| 3500 | /* Set the write pointer delay */ |
| 3501 | WREG32(CP_RB_WPTR_DELAY, 0); |
| 3502 | |
| 3503 | /* set the RB to use vmid 0 */ |
| 3504 | WREG32(CP_RB_VMID, 0); |
| 3505 | |
| 3506 | WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF); |
| 3507 | |
| 3508 | /* ring 0 - compute and gfx */ |
| 3509 | /* Set ring buffer size */ |
| 3510 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 3511 | rb_bufsz = order_base_2(ring->ring_size / 8); |
| 3512 | tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3513 | #ifdef __BIG_ENDIAN |
| 3514 | tmp |= BUF_SWAP_32BIT; |
| 3515 | #endif |
| 3516 | WREG32(CP_RB0_CNTL, tmp); |
| 3517 | |
| 3518 | /* Initialize the ring buffer's read and write pointers */ |
| 3519 | WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA); |
| 3520 | ring->wptr = 0; |
| 3521 | WREG32(CP_RB0_WPTR, ring->wptr); |
| 3522 | |
| 3523 | /* set the wb address wether it's enabled or not */ |
| 3524 | WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC); |
| 3525 | WREG32(CP_RB0_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFF); |
| 3526 | |
| 3527 | /* scratch register shadowing is no longer supported */ |
| 3528 | WREG32(SCRATCH_UMSK, 0); |
| 3529 | |
| 3530 | if (!rdev->wb.enabled) |
| 3531 | tmp |= RB_NO_UPDATE; |
| 3532 | |
| 3533 | mdelay(1); |
| 3534 | WREG32(CP_RB0_CNTL, tmp); |
| 3535 | |
| 3536 | rb_addr = ring->gpu_addr >> 8; |
| 3537 | WREG32(CP_RB0_BASE, rb_addr); |
| 3538 | WREG32(CP_RB0_BASE_HI, upper_32_bits(rb_addr)); |
| 3539 | |
| 3540 | ring->rptr = RREG32(CP_RB0_RPTR); |
| 3541 | |
| 3542 | /* start the ring */ |
| 3543 | cik_cp_gfx_start(rdev); |
| 3544 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = true; |
| 3545 | r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]); |
| 3546 | if (r) { |
| 3547 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; |
| 3548 | return r; |
| 3549 | } |
| 3550 | return 0; |
| 3551 | } |
| 3552 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3553 | u32 cik_compute_ring_get_rptr(struct radeon_device *rdev, |
| 3554 | struct radeon_ring *ring) |
| 3555 | { |
| 3556 | u32 rptr; |
| 3557 | |
| 3558 | |
| 3559 | |
| 3560 | if (rdev->wb.enabled) { |
| 3561 | rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]); |
| 3562 | } else { |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3563 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3564 | cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); |
| 3565 | rptr = RREG32(CP_HQD_PQ_RPTR); |
| 3566 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3567 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3568 | } |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3569 | |
| 3570 | return rptr; |
| 3571 | } |
| 3572 | |
| 3573 | u32 cik_compute_ring_get_wptr(struct radeon_device *rdev, |
| 3574 | struct radeon_ring *ring) |
| 3575 | { |
| 3576 | u32 wptr; |
| 3577 | |
| 3578 | if (rdev->wb.enabled) { |
| 3579 | wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]); |
| 3580 | } else { |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3581 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3582 | cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); |
| 3583 | wptr = RREG32(CP_HQD_PQ_WPTR); |
| 3584 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3585 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3586 | } |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3587 | |
| 3588 | return wptr; |
| 3589 | } |
| 3590 | |
| 3591 | void cik_compute_ring_set_wptr(struct radeon_device *rdev, |
| 3592 | struct radeon_ring *ring) |
| 3593 | { |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 3594 | rdev->wb.wb[ring->wptr_offs/4] = cpu_to_le32(ring->wptr); |
| 3595 | WDOORBELL32(ring->doorbell_offset, ring->wptr); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3596 | } |
| 3597 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3598 | /** |
| 3599 | * cik_cp_compute_enable - enable/disable the compute CP MEs |
| 3600 | * |
| 3601 | * @rdev: radeon_device pointer |
| 3602 | * @enable: enable or disable the MEs |
| 3603 | * |
| 3604 | * Halts or unhalts the compute MEs. |
| 3605 | */ |
| 3606 | static void cik_cp_compute_enable(struct radeon_device *rdev, bool enable) |
| 3607 | { |
| 3608 | if (enable) |
| 3609 | WREG32(CP_MEC_CNTL, 0); |
| 3610 | else |
| 3611 | WREG32(CP_MEC_CNTL, (MEC_ME1_HALT | MEC_ME2_HALT)); |
| 3612 | udelay(50); |
| 3613 | } |
| 3614 | |
| 3615 | /** |
| 3616 | * cik_cp_compute_load_microcode - load the compute CP ME ucode |
| 3617 | * |
| 3618 | * @rdev: radeon_device pointer |
| 3619 | * |
| 3620 | * Loads the compute MEC1&2 ucode. |
| 3621 | * Returns 0 for success, -EINVAL if the ucode is not available. |
| 3622 | */ |
| 3623 | static int cik_cp_compute_load_microcode(struct radeon_device *rdev) |
| 3624 | { |
| 3625 | const __be32 *fw_data; |
| 3626 | int i; |
| 3627 | |
| 3628 | if (!rdev->mec_fw) |
| 3629 | return -EINVAL; |
| 3630 | |
| 3631 | cik_cp_compute_enable(rdev, false); |
| 3632 | |
| 3633 | /* MEC1 */ |
| 3634 | fw_data = (const __be32 *)rdev->mec_fw->data; |
| 3635 | WREG32(CP_MEC_ME1_UCODE_ADDR, 0); |
| 3636 | for (i = 0; i < CIK_MEC_UCODE_SIZE; i++) |
| 3637 | WREG32(CP_MEC_ME1_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3638 | WREG32(CP_MEC_ME1_UCODE_ADDR, 0); |
| 3639 | |
| 3640 | if (rdev->family == CHIP_KAVERI) { |
| 3641 | /* MEC2 */ |
| 3642 | fw_data = (const __be32 *)rdev->mec_fw->data; |
| 3643 | WREG32(CP_MEC_ME2_UCODE_ADDR, 0); |
| 3644 | for (i = 0; i < CIK_MEC_UCODE_SIZE; i++) |
| 3645 | WREG32(CP_MEC_ME2_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3646 | WREG32(CP_MEC_ME2_UCODE_ADDR, 0); |
| 3647 | } |
| 3648 | |
| 3649 | return 0; |
| 3650 | } |
| 3651 | |
| 3652 | /** |
| 3653 | * cik_cp_compute_start - start the compute queues |
| 3654 | * |
| 3655 | * @rdev: radeon_device pointer |
| 3656 | * |
| 3657 | * Enable the compute queues. |
| 3658 | * Returns 0 for success, error for failure. |
| 3659 | */ |
| 3660 | static int cik_cp_compute_start(struct radeon_device *rdev) |
| 3661 | { |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3662 | cik_cp_compute_enable(rdev, true); |
| 3663 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3664 | return 0; |
| 3665 | } |
| 3666 | |
| 3667 | /** |
| 3668 | * cik_cp_compute_fini - stop the compute queues |
| 3669 | * |
| 3670 | * @rdev: radeon_device pointer |
| 3671 | * |
| 3672 | * Stop the compute queues and tear down the driver queue |
| 3673 | * info. |
| 3674 | */ |
| 3675 | static void cik_cp_compute_fini(struct radeon_device *rdev) |
| 3676 | { |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3677 | int i, idx, r; |
| 3678 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3679 | cik_cp_compute_enable(rdev, false); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3680 | |
| 3681 | for (i = 0; i < 2; i++) { |
| 3682 | if (i == 0) |
| 3683 | idx = CAYMAN_RING_TYPE_CP1_INDEX; |
| 3684 | else |
| 3685 | idx = CAYMAN_RING_TYPE_CP2_INDEX; |
| 3686 | |
| 3687 | if (rdev->ring[idx].mqd_obj) { |
| 3688 | r = radeon_bo_reserve(rdev->ring[idx].mqd_obj, false); |
| 3689 | if (unlikely(r != 0)) |
| 3690 | dev_warn(rdev->dev, "(%d) reserve MQD bo failed\n", r); |
| 3691 | |
| 3692 | radeon_bo_unpin(rdev->ring[idx].mqd_obj); |
| 3693 | radeon_bo_unreserve(rdev->ring[idx].mqd_obj); |
| 3694 | |
| 3695 | radeon_bo_unref(&rdev->ring[idx].mqd_obj); |
| 3696 | rdev->ring[idx].mqd_obj = NULL; |
| 3697 | } |
| 3698 | } |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3699 | } |
| 3700 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3701 | static void cik_mec_fini(struct radeon_device *rdev) |
| 3702 | { |
| 3703 | int r; |
| 3704 | |
| 3705 | if (rdev->mec.hpd_eop_obj) { |
| 3706 | r = radeon_bo_reserve(rdev->mec.hpd_eop_obj, false); |
| 3707 | if (unlikely(r != 0)) |
| 3708 | dev_warn(rdev->dev, "(%d) reserve HPD EOP bo failed\n", r); |
| 3709 | radeon_bo_unpin(rdev->mec.hpd_eop_obj); |
| 3710 | radeon_bo_unreserve(rdev->mec.hpd_eop_obj); |
| 3711 | |
| 3712 | radeon_bo_unref(&rdev->mec.hpd_eop_obj); |
| 3713 | rdev->mec.hpd_eop_obj = NULL; |
| 3714 | } |
| 3715 | } |
| 3716 | |
| 3717 | #define MEC_HPD_SIZE 2048 |
| 3718 | |
| 3719 | static int cik_mec_init(struct radeon_device *rdev) |
| 3720 | { |
| 3721 | int r; |
| 3722 | u32 *hpd; |
| 3723 | |
| 3724 | /* |
| 3725 | * KV: 2 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 64 Queues total |
| 3726 | * CI/KB: 1 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 32 Queues total |
| 3727 | */ |
| 3728 | if (rdev->family == CHIP_KAVERI) |
| 3729 | rdev->mec.num_mec = 2; |
| 3730 | else |
| 3731 | rdev->mec.num_mec = 1; |
| 3732 | rdev->mec.num_pipe = 4; |
| 3733 | rdev->mec.num_queue = rdev->mec.num_mec * rdev->mec.num_pipe * 8; |
| 3734 | |
| 3735 | if (rdev->mec.hpd_eop_obj == NULL) { |
| 3736 | r = radeon_bo_create(rdev, |
| 3737 | rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2, |
| 3738 | PAGE_SIZE, true, |
| 3739 | RADEON_GEM_DOMAIN_GTT, NULL, |
| 3740 | &rdev->mec.hpd_eop_obj); |
| 3741 | if (r) { |
| 3742 | dev_warn(rdev->dev, "(%d) create HDP EOP bo failed\n", r); |
| 3743 | return r; |
| 3744 | } |
| 3745 | } |
| 3746 | |
| 3747 | r = radeon_bo_reserve(rdev->mec.hpd_eop_obj, false); |
| 3748 | if (unlikely(r != 0)) { |
| 3749 | cik_mec_fini(rdev); |
| 3750 | return r; |
| 3751 | } |
| 3752 | r = radeon_bo_pin(rdev->mec.hpd_eop_obj, RADEON_GEM_DOMAIN_GTT, |
| 3753 | &rdev->mec.hpd_eop_gpu_addr); |
| 3754 | if (r) { |
| 3755 | dev_warn(rdev->dev, "(%d) pin HDP EOP bo failed\n", r); |
| 3756 | cik_mec_fini(rdev); |
| 3757 | return r; |
| 3758 | } |
| 3759 | r = radeon_bo_kmap(rdev->mec.hpd_eop_obj, (void **)&hpd); |
| 3760 | if (r) { |
| 3761 | dev_warn(rdev->dev, "(%d) map HDP EOP bo failed\n", r); |
| 3762 | cik_mec_fini(rdev); |
| 3763 | return r; |
| 3764 | } |
| 3765 | |
| 3766 | /* clear memory. Not sure if this is required or not */ |
| 3767 | memset(hpd, 0, rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2); |
| 3768 | |
| 3769 | radeon_bo_kunmap(rdev->mec.hpd_eop_obj); |
| 3770 | radeon_bo_unreserve(rdev->mec.hpd_eop_obj); |
| 3771 | |
| 3772 | return 0; |
| 3773 | } |
| 3774 | |
| 3775 | struct hqd_registers |
| 3776 | { |
| 3777 | u32 cp_mqd_base_addr; |
| 3778 | u32 cp_mqd_base_addr_hi; |
| 3779 | u32 cp_hqd_active; |
| 3780 | u32 cp_hqd_vmid; |
| 3781 | u32 cp_hqd_persistent_state; |
| 3782 | u32 cp_hqd_pipe_priority; |
| 3783 | u32 cp_hqd_queue_priority; |
| 3784 | u32 cp_hqd_quantum; |
| 3785 | u32 cp_hqd_pq_base; |
| 3786 | u32 cp_hqd_pq_base_hi; |
| 3787 | u32 cp_hqd_pq_rptr; |
| 3788 | u32 cp_hqd_pq_rptr_report_addr; |
| 3789 | u32 cp_hqd_pq_rptr_report_addr_hi; |
| 3790 | u32 cp_hqd_pq_wptr_poll_addr; |
| 3791 | u32 cp_hqd_pq_wptr_poll_addr_hi; |
| 3792 | u32 cp_hqd_pq_doorbell_control; |
| 3793 | u32 cp_hqd_pq_wptr; |
| 3794 | u32 cp_hqd_pq_control; |
| 3795 | u32 cp_hqd_ib_base_addr; |
| 3796 | u32 cp_hqd_ib_base_addr_hi; |
| 3797 | u32 cp_hqd_ib_rptr; |
| 3798 | u32 cp_hqd_ib_control; |
| 3799 | u32 cp_hqd_iq_timer; |
| 3800 | u32 cp_hqd_iq_rptr; |
| 3801 | u32 cp_hqd_dequeue_request; |
| 3802 | u32 cp_hqd_dma_offload; |
| 3803 | u32 cp_hqd_sema_cmd; |
| 3804 | u32 cp_hqd_msg_type; |
| 3805 | u32 cp_hqd_atomic0_preop_lo; |
| 3806 | u32 cp_hqd_atomic0_preop_hi; |
| 3807 | u32 cp_hqd_atomic1_preop_lo; |
| 3808 | u32 cp_hqd_atomic1_preop_hi; |
| 3809 | u32 cp_hqd_hq_scheduler0; |
| 3810 | u32 cp_hqd_hq_scheduler1; |
| 3811 | u32 cp_mqd_control; |
| 3812 | }; |
| 3813 | |
| 3814 | struct bonaire_mqd |
| 3815 | { |
| 3816 | u32 header; |
| 3817 | u32 dispatch_initiator; |
| 3818 | u32 dimensions[3]; |
| 3819 | u32 start_idx[3]; |
| 3820 | u32 num_threads[3]; |
| 3821 | u32 pipeline_stat_enable; |
| 3822 | u32 perf_counter_enable; |
| 3823 | u32 pgm[2]; |
| 3824 | u32 tba[2]; |
| 3825 | u32 tma[2]; |
| 3826 | u32 pgm_rsrc[2]; |
| 3827 | u32 vmid; |
| 3828 | u32 resource_limits; |
| 3829 | u32 static_thread_mgmt01[2]; |
| 3830 | u32 tmp_ring_size; |
| 3831 | u32 static_thread_mgmt23[2]; |
| 3832 | u32 restart[3]; |
| 3833 | u32 thread_trace_enable; |
| 3834 | u32 reserved1; |
| 3835 | u32 user_data[16]; |
| 3836 | u32 vgtcs_invoke_count[2]; |
| 3837 | struct hqd_registers queue_state; |
| 3838 | u32 dequeue_cntr; |
| 3839 | u32 interrupt_queue[64]; |
| 3840 | }; |
| 3841 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3842 | /** |
| 3843 | * cik_cp_compute_resume - setup the compute queue registers |
| 3844 | * |
| 3845 | * @rdev: radeon_device pointer |
| 3846 | * |
| 3847 | * Program the compute queues and test them to make sure they |
| 3848 | * are working. |
| 3849 | * Returns 0 for success, error for failure. |
| 3850 | */ |
| 3851 | static int cik_cp_compute_resume(struct radeon_device *rdev) |
| 3852 | { |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3853 | int r, i, idx; |
| 3854 | u32 tmp; |
| 3855 | bool use_doorbell = true; |
| 3856 | u64 hqd_gpu_addr; |
| 3857 | u64 mqd_gpu_addr; |
| 3858 | u64 eop_gpu_addr; |
| 3859 | u64 wb_gpu_addr; |
| 3860 | u32 *buf; |
| 3861 | struct bonaire_mqd *mqd; |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3862 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3863 | r = cik_cp_compute_start(rdev); |
| 3864 | if (r) |
| 3865 | return r; |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3866 | |
| 3867 | /* fix up chicken bits */ |
| 3868 | tmp = RREG32(CP_CPF_DEBUG); |
| 3869 | tmp |= (1 << 23); |
| 3870 | WREG32(CP_CPF_DEBUG, tmp); |
| 3871 | |
| 3872 | /* init the pipes */ |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3873 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3874 | for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) { |
| 3875 | int me = (i < 4) ? 1 : 2; |
| 3876 | int pipe = (i < 4) ? i : (i - 4); |
| 3877 | |
| 3878 | eop_gpu_addr = rdev->mec.hpd_eop_gpu_addr + (i * MEC_HPD_SIZE * 2); |
| 3879 | |
| 3880 | cik_srbm_select(rdev, me, pipe, 0, 0); |
| 3881 | |
| 3882 | /* write the EOP addr */ |
| 3883 | WREG32(CP_HPD_EOP_BASE_ADDR, eop_gpu_addr >> 8); |
| 3884 | WREG32(CP_HPD_EOP_BASE_ADDR_HI, upper_32_bits(eop_gpu_addr) >> 8); |
| 3885 | |
| 3886 | /* set the VMID assigned */ |
| 3887 | WREG32(CP_HPD_EOP_VMID, 0); |
| 3888 | |
| 3889 | /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ |
| 3890 | tmp = RREG32(CP_HPD_EOP_CONTROL); |
| 3891 | tmp &= ~EOP_SIZE_MASK; |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 3892 | tmp |= order_base_2(MEC_HPD_SIZE / 8); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3893 | WREG32(CP_HPD_EOP_CONTROL, tmp); |
| 3894 | } |
| 3895 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3896 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3897 | |
| 3898 | /* init the queues. Just two for now. */ |
| 3899 | for (i = 0; i < 2; i++) { |
| 3900 | if (i == 0) |
| 3901 | idx = CAYMAN_RING_TYPE_CP1_INDEX; |
| 3902 | else |
| 3903 | idx = CAYMAN_RING_TYPE_CP2_INDEX; |
| 3904 | |
| 3905 | if (rdev->ring[idx].mqd_obj == NULL) { |
| 3906 | r = radeon_bo_create(rdev, |
| 3907 | sizeof(struct bonaire_mqd), |
| 3908 | PAGE_SIZE, true, |
| 3909 | RADEON_GEM_DOMAIN_GTT, NULL, |
| 3910 | &rdev->ring[idx].mqd_obj); |
| 3911 | if (r) { |
| 3912 | dev_warn(rdev->dev, "(%d) create MQD bo failed\n", r); |
| 3913 | return r; |
| 3914 | } |
| 3915 | } |
| 3916 | |
| 3917 | r = radeon_bo_reserve(rdev->ring[idx].mqd_obj, false); |
| 3918 | if (unlikely(r != 0)) { |
| 3919 | cik_cp_compute_fini(rdev); |
| 3920 | return r; |
| 3921 | } |
| 3922 | r = radeon_bo_pin(rdev->ring[idx].mqd_obj, RADEON_GEM_DOMAIN_GTT, |
| 3923 | &mqd_gpu_addr); |
| 3924 | if (r) { |
| 3925 | dev_warn(rdev->dev, "(%d) pin MQD bo failed\n", r); |
| 3926 | cik_cp_compute_fini(rdev); |
| 3927 | return r; |
| 3928 | } |
| 3929 | r = radeon_bo_kmap(rdev->ring[idx].mqd_obj, (void **)&buf); |
| 3930 | if (r) { |
| 3931 | dev_warn(rdev->dev, "(%d) map MQD bo failed\n", r); |
| 3932 | cik_cp_compute_fini(rdev); |
| 3933 | return r; |
| 3934 | } |
| 3935 | |
| 3936 | /* doorbell offset */ |
| 3937 | rdev->ring[idx].doorbell_offset = |
| 3938 | (rdev->ring[idx].doorbell_page_num * PAGE_SIZE) + 0; |
| 3939 | |
| 3940 | /* init the mqd struct */ |
| 3941 | memset(buf, 0, sizeof(struct bonaire_mqd)); |
| 3942 | |
| 3943 | mqd = (struct bonaire_mqd *)buf; |
| 3944 | mqd->header = 0xC0310800; |
| 3945 | mqd->static_thread_mgmt01[0] = 0xffffffff; |
| 3946 | mqd->static_thread_mgmt01[1] = 0xffffffff; |
| 3947 | mqd->static_thread_mgmt23[0] = 0xffffffff; |
| 3948 | mqd->static_thread_mgmt23[1] = 0xffffffff; |
| 3949 | |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3950 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3951 | cik_srbm_select(rdev, rdev->ring[idx].me, |
| 3952 | rdev->ring[idx].pipe, |
| 3953 | rdev->ring[idx].queue, 0); |
| 3954 | |
| 3955 | /* disable wptr polling */ |
| 3956 | tmp = RREG32(CP_PQ_WPTR_POLL_CNTL); |
| 3957 | tmp &= ~WPTR_POLL_EN; |
| 3958 | WREG32(CP_PQ_WPTR_POLL_CNTL, tmp); |
| 3959 | |
| 3960 | /* enable doorbell? */ |
| 3961 | mqd->queue_state.cp_hqd_pq_doorbell_control = |
| 3962 | RREG32(CP_HQD_PQ_DOORBELL_CONTROL); |
| 3963 | if (use_doorbell) |
| 3964 | mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN; |
| 3965 | else |
| 3966 | mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_EN; |
| 3967 | WREG32(CP_HQD_PQ_DOORBELL_CONTROL, |
| 3968 | mqd->queue_state.cp_hqd_pq_doorbell_control); |
| 3969 | |
| 3970 | /* disable the queue if it's active */ |
| 3971 | mqd->queue_state.cp_hqd_dequeue_request = 0; |
| 3972 | mqd->queue_state.cp_hqd_pq_rptr = 0; |
| 3973 | mqd->queue_state.cp_hqd_pq_wptr= 0; |
| 3974 | if (RREG32(CP_HQD_ACTIVE) & 1) { |
| 3975 | WREG32(CP_HQD_DEQUEUE_REQUEST, 1); |
| 3976 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 3977 | if (!(RREG32(CP_HQD_ACTIVE) & 1)) |
| 3978 | break; |
| 3979 | udelay(1); |
| 3980 | } |
| 3981 | WREG32(CP_HQD_DEQUEUE_REQUEST, mqd->queue_state.cp_hqd_dequeue_request); |
| 3982 | WREG32(CP_HQD_PQ_RPTR, mqd->queue_state.cp_hqd_pq_rptr); |
| 3983 | WREG32(CP_HQD_PQ_WPTR, mqd->queue_state.cp_hqd_pq_wptr); |
| 3984 | } |
| 3985 | |
| 3986 | /* set the pointer to the MQD */ |
| 3987 | mqd->queue_state.cp_mqd_base_addr = mqd_gpu_addr & 0xfffffffc; |
| 3988 | mqd->queue_state.cp_mqd_base_addr_hi = upper_32_bits(mqd_gpu_addr); |
| 3989 | WREG32(CP_MQD_BASE_ADDR, mqd->queue_state.cp_mqd_base_addr); |
| 3990 | WREG32(CP_MQD_BASE_ADDR_HI, mqd->queue_state.cp_mqd_base_addr_hi); |
| 3991 | /* set MQD vmid to 0 */ |
| 3992 | mqd->queue_state.cp_mqd_control = RREG32(CP_MQD_CONTROL); |
| 3993 | mqd->queue_state.cp_mqd_control &= ~MQD_VMID_MASK; |
| 3994 | WREG32(CP_MQD_CONTROL, mqd->queue_state.cp_mqd_control); |
| 3995 | |
| 3996 | /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ |
| 3997 | hqd_gpu_addr = rdev->ring[idx].gpu_addr >> 8; |
| 3998 | mqd->queue_state.cp_hqd_pq_base = hqd_gpu_addr; |
| 3999 | mqd->queue_state.cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr); |
| 4000 | WREG32(CP_HQD_PQ_BASE, mqd->queue_state.cp_hqd_pq_base); |
| 4001 | WREG32(CP_HQD_PQ_BASE_HI, mqd->queue_state.cp_hqd_pq_base_hi); |
| 4002 | |
| 4003 | /* set up the HQD, this is similar to CP_RB0_CNTL */ |
| 4004 | mqd->queue_state.cp_hqd_pq_control = RREG32(CP_HQD_PQ_CONTROL); |
| 4005 | mqd->queue_state.cp_hqd_pq_control &= |
| 4006 | ~(QUEUE_SIZE_MASK | RPTR_BLOCK_SIZE_MASK); |
| 4007 | |
| 4008 | mqd->queue_state.cp_hqd_pq_control |= |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 4009 | order_base_2(rdev->ring[idx].ring_size / 8); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 4010 | mqd->queue_state.cp_hqd_pq_control |= |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 4011 | (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 4012 | #ifdef __BIG_ENDIAN |
| 4013 | mqd->queue_state.cp_hqd_pq_control |= BUF_SWAP_32BIT; |
| 4014 | #endif |
| 4015 | mqd->queue_state.cp_hqd_pq_control &= |
| 4016 | ~(UNORD_DISPATCH | ROQ_PQ_IB_FLIP | PQ_VOLATILE); |
| 4017 | mqd->queue_state.cp_hqd_pq_control |= |
| 4018 | PRIV_STATE | KMD_QUEUE; /* assuming kernel queue control */ |
| 4019 | WREG32(CP_HQD_PQ_CONTROL, mqd->queue_state.cp_hqd_pq_control); |
| 4020 | |
| 4021 | /* only used if CP_PQ_WPTR_POLL_CNTL.WPTR_POLL_EN=1 */ |
| 4022 | if (i == 0) |
| 4023 | wb_gpu_addr = rdev->wb.gpu_addr + CIK_WB_CP1_WPTR_OFFSET; |
| 4024 | else |
| 4025 | wb_gpu_addr = rdev->wb.gpu_addr + CIK_WB_CP2_WPTR_OFFSET; |
| 4026 | mqd->queue_state.cp_hqd_pq_wptr_poll_addr = wb_gpu_addr & 0xfffffffc; |
| 4027 | mqd->queue_state.cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff; |
| 4028 | WREG32(CP_HQD_PQ_WPTR_POLL_ADDR, mqd->queue_state.cp_hqd_pq_wptr_poll_addr); |
| 4029 | WREG32(CP_HQD_PQ_WPTR_POLL_ADDR_HI, |
| 4030 | mqd->queue_state.cp_hqd_pq_wptr_poll_addr_hi); |
| 4031 | |
| 4032 | /* set the wb address wether it's enabled or not */ |
| 4033 | if (i == 0) |
| 4034 | wb_gpu_addr = rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET; |
| 4035 | else |
| 4036 | wb_gpu_addr = rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET; |
| 4037 | mqd->queue_state.cp_hqd_pq_rptr_report_addr = wb_gpu_addr & 0xfffffffc; |
| 4038 | mqd->queue_state.cp_hqd_pq_rptr_report_addr_hi = |
| 4039 | upper_32_bits(wb_gpu_addr) & 0xffff; |
| 4040 | WREG32(CP_HQD_PQ_RPTR_REPORT_ADDR, |
| 4041 | mqd->queue_state.cp_hqd_pq_rptr_report_addr); |
| 4042 | WREG32(CP_HQD_PQ_RPTR_REPORT_ADDR_HI, |
| 4043 | mqd->queue_state.cp_hqd_pq_rptr_report_addr_hi); |
| 4044 | |
| 4045 | /* enable the doorbell if requested */ |
| 4046 | if (use_doorbell) { |
| 4047 | mqd->queue_state.cp_hqd_pq_doorbell_control = |
| 4048 | RREG32(CP_HQD_PQ_DOORBELL_CONTROL); |
| 4049 | mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_OFFSET_MASK; |
| 4050 | mqd->queue_state.cp_hqd_pq_doorbell_control |= |
| 4051 | DOORBELL_OFFSET(rdev->ring[idx].doorbell_offset / 4); |
| 4052 | mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN; |
| 4053 | mqd->queue_state.cp_hqd_pq_doorbell_control &= |
| 4054 | ~(DOORBELL_SOURCE | DOORBELL_HIT); |
| 4055 | |
| 4056 | } else { |
| 4057 | mqd->queue_state.cp_hqd_pq_doorbell_control = 0; |
| 4058 | } |
| 4059 | WREG32(CP_HQD_PQ_DOORBELL_CONTROL, |
| 4060 | mqd->queue_state.cp_hqd_pq_doorbell_control); |
| 4061 | |
| 4062 | /* read and write pointers, similar to CP_RB0_WPTR/_RPTR */ |
| 4063 | rdev->ring[idx].wptr = 0; |
| 4064 | mqd->queue_state.cp_hqd_pq_wptr = rdev->ring[idx].wptr; |
| 4065 | WREG32(CP_HQD_PQ_WPTR, mqd->queue_state.cp_hqd_pq_wptr); |
| 4066 | rdev->ring[idx].rptr = RREG32(CP_HQD_PQ_RPTR); |
| 4067 | mqd->queue_state.cp_hqd_pq_rptr = rdev->ring[idx].rptr; |
| 4068 | |
| 4069 | /* set the vmid for the queue */ |
| 4070 | mqd->queue_state.cp_hqd_vmid = 0; |
| 4071 | WREG32(CP_HQD_VMID, mqd->queue_state.cp_hqd_vmid); |
| 4072 | |
| 4073 | /* activate the queue */ |
| 4074 | mqd->queue_state.cp_hqd_active = 1; |
| 4075 | WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active); |
| 4076 | |
| 4077 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 4078 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 4079 | |
| 4080 | radeon_bo_kunmap(rdev->ring[idx].mqd_obj); |
| 4081 | radeon_bo_unreserve(rdev->ring[idx].mqd_obj); |
| 4082 | |
| 4083 | rdev->ring[idx].ready = true; |
| 4084 | r = radeon_ring_test(rdev, idx, &rdev->ring[idx]); |
| 4085 | if (r) |
| 4086 | rdev->ring[idx].ready = false; |
| 4087 | } |
| 4088 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4089 | return 0; |
| 4090 | } |
| 4091 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4092 | static void cik_cp_enable(struct radeon_device *rdev, bool enable) |
| 4093 | { |
| 4094 | cik_cp_gfx_enable(rdev, enable); |
| 4095 | cik_cp_compute_enable(rdev, enable); |
| 4096 | } |
| 4097 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4098 | static int cik_cp_load_microcode(struct radeon_device *rdev) |
| 4099 | { |
| 4100 | int r; |
| 4101 | |
| 4102 | r = cik_cp_gfx_load_microcode(rdev); |
| 4103 | if (r) |
| 4104 | return r; |
| 4105 | r = cik_cp_compute_load_microcode(rdev); |
| 4106 | if (r) |
| 4107 | return r; |
| 4108 | |
| 4109 | return 0; |
| 4110 | } |
| 4111 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4112 | static void cik_cp_fini(struct radeon_device *rdev) |
| 4113 | { |
| 4114 | cik_cp_gfx_fini(rdev); |
| 4115 | cik_cp_compute_fini(rdev); |
| 4116 | } |
| 4117 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4118 | static int cik_cp_resume(struct radeon_device *rdev) |
| 4119 | { |
| 4120 | int r; |
| 4121 | |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 4122 | cik_enable_gui_idle_interrupt(rdev, false); |
| 4123 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4124 | r = cik_cp_load_microcode(rdev); |
| 4125 | if (r) |
| 4126 | return r; |
| 4127 | |
| 4128 | r = cik_cp_gfx_resume(rdev); |
| 4129 | if (r) |
| 4130 | return r; |
| 4131 | r = cik_cp_compute_resume(rdev); |
| 4132 | if (r) |
| 4133 | return r; |
| 4134 | |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 4135 | cik_enable_gui_idle_interrupt(rdev, true); |
| 4136 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4137 | return 0; |
| 4138 | } |
| 4139 | |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4140 | static void cik_print_gpu_status_regs(struct radeon_device *rdev) |
| 4141 | { |
| 4142 | dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", |
| 4143 | RREG32(GRBM_STATUS)); |
| 4144 | dev_info(rdev->dev, " GRBM_STATUS2=0x%08X\n", |
| 4145 | RREG32(GRBM_STATUS2)); |
| 4146 | dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n", |
| 4147 | RREG32(GRBM_STATUS_SE0)); |
| 4148 | dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n", |
| 4149 | RREG32(GRBM_STATUS_SE1)); |
| 4150 | dev_info(rdev->dev, " GRBM_STATUS_SE2=0x%08X\n", |
| 4151 | RREG32(GRBM_STATUS_SE2)); |
| 4152 | dev_info(rdev->dev, " GRBM_STATUS_SE3=0x%08X\n", |
| 4153 | RREG32(GRBM_STATUS_SE3)); |
| 4154 | dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", |
| 4155 | RREG32(SRBM_STATUS)); |
| 4156 | dev_info(rdev->dev, " SRBM_STATUS2=0x%08X\n", |
| 4157 | RREG32(SRBM_STATUS2)); |
| 4158 | dev_info(rdev->dev, " SDMA0_STATUS_REG = 0x%08X\n", |
| 4159 | RREG32(SDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET)); |
| 4160 | dev_info(rdev->dev, " SDMA1_STATUS_REG = 0x%08X\n", |
| 4161 | RREG32(SDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET)); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 4162 | dev_info(rdev->dev, " CP_STAT = 0x%08x\n", RREG32(CP_STAT)); |
| 4163 | dev_info(rdev->dev, " CP_STALLED_STAT1 = 0x%08x\n", |
| 4164 | RREG32(CP_STALLED_STAT1)); |
| 4165 | dev_info(rdev->dev, " CP_STALLED_STAT2 = 0x%08x\n", |
| 4166 | RREG32(CP_STALLED_STAT2)); |
| 4167 | dev_info(rdev->dev, " CP_STALLED_STAT3 = 0x%08x\n", |
| 4168 | RREG32(CP_STALLED_STAT3)); |
| 4169 | dev_info(rdev->dev, " CP_CPF_BUSY_STAT = 0x%08x\n", |
| 4170 | RREG32(CP_CPF_BUSY_STAT)); |
| 4171 | dev_info(rdev->dev, " CP_CPF_STALLED_STAT1 = 0x%08x\n", |
| 4172 | RREG32(CP_CPF_STALLED_STAT1)); |
| 4173 | dev_info(rdev->dev, " CP_CPF_STATUS = 0x%08x\n", RREG32(CP_CPF_STATUS)); |
| 4174 | dev_info(rdev->dev, " CP_CPC_BUSY_STAT = 0x%08x\n", RREG32(CP_CPC_BUSY_STAT)); |
| 4175 | dev_info(rdev->dev, " CP_CPC_STALLED_STAT1 = 0x%08x\n", |
| 4176 | RREG32(CP_CPC_STALLED_STAT1)); |
| 4177 | dev_info(rdev->dev, " CP_CPC_STATUS = 0x%08x\n", RREG32(CP_CPC_STATUS)); |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4178 | } |
| 4179 | |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4180 | /** |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4181 | * cik_gpu_check_soft_reset - check which blocks are busy |
| 4182 | * |
| 4183 | * @rdev: radeon_device pointer |
| 4184 | * |
| 4185 | * Check which blocks are busy and return the relevant reset |
| 4186 | * mask to be used by cik_gpu_soft_reset(). |
| 4187 | * Returns a mask of the blocks to be reset. |
| 4188 | */ |
Christian König | 2483b4e | 2013-08-13 11:56:54 +0200 | [diff] [blame] | 4189 | u32 cik_gpu_check_soft_reset(struct radeon_device *rdev) |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4190 | { |
| 4191 | u32 reset_mask = 0; |
| 4192 | u32 tmp; |
| 4193 | |
| 4194 | /* GRBM_STATUS */ |
| 4195 | tmp = RREG32(GRBM_STATUS); |
| 4196 | if (tmp & (PA_BUSY | SC_BUSY | |
| 4197 | BCI_BUSY | SX_BUSY | |
| 4198 | TA_BUSY | VGT_BUSY | |
| 4199 | DB_BUSY | CB_BUSY | |
| 4200 | GDS_BUSY | SPI_BUSY | |
| 4201 | IA_BUSY | IA_BUSY_NO_DMA)) |
| 4202 | reset_mask |= RADEON_RESET_GFX; |
| 4203 | |
| 4204 | if (tmp & (CP_BUSY | CP_COHERENCY_BUSY)) |
| 4205 | reset_mask |= RADEON_RESET_CP; |
| 4206 | |
| 4207 | /* GRBM_STATUS2 */ |
| 4208 | tmp = RREG32(GRBM_STATUS2); |
| 4209 | if (tmp & RLC_BUSY) |
| 4210 | reset_mask |= RADEON_RESET_RLC; |
| 4211 | |
| 4212 | /* SDMA0_STATUS_REG */ |
| 4213 | tmp = RREG32(SDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET); |
| 4214 | if (!(tmp & SDMA_IDLE)) |
| 4215 | reset_mask |= RADEON_RESET_DMA; |
| 4216 | |
| 4217 | /* SDMA1_STATUS_REG */ |
| 4218 | tmp = RREG32(SDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET); |
| 4219 | if (!(tmp & SDMA_IDLE)) |
| 4220 | reset_mask |= RADEON_RESET_DMA1; |
| 4221 | |
| 4222 | /* SRBM_STATUS2 */ |
| 4223 | tmp = RREG32(SRBM_STATUS2); |
| 4224 | if (tmp & SDMA_BUSY) |
| 4225 | reset_mask |= RADEON_RESET_DMA; |
| 4226 | |
| 4227 | if (tmp & SDMA1_BUSY) |
| 4228 | reset_mask |= RADEON_RESET_DMA1; |
| 4229 | |
| 4230 | /* SRBM_STATUS */ |
| 4231 | tmp = RREG32(SRBM_STATUS); |
| 4232 | |
| 4233 | if (tmp & IH_BUSY) |
| 4234 | reset_mask |= RADEON_RESET_IH; |
| 4235 | |
| 4236 | if (tmp & SEM_BUSY) |
| 4237 | reset_mask |= RADEON_RESET_SEM; |
| 4238 | |
| 4239 | if (tmp & GRBM_RQ_PENDING) |
| 4240 | reset_mask |= RADEON_RESET_GRBM; |
| 4241 | |
| 4242 | if (tmp & VMC_BUSY) |
| 4243 | reset_mask |= RADEON_RESET_VMC; |
| 4244 | |
| 4245 | if (tmp & (MCB_BUSY | MCB_NON_DISPLAY_BUSY | |
| 4246 | MCC_BUSY | MCD_BUSY)) |
| 4247 | reset_mask |= RADEON_RESET_MC; |
| 4248 | |
| 4249 | if (evergreen_is_display_hung(rdev)) |
| 4250 | reset_mask |= RADEON_RESET_DISPLAY; |
| 4251 | |
| 4252 | /* Skip MC reset as it's mostly likely not hung, just busy */ |
| 4253 | if (reset_mask & RADEON_RESET_MC) { |
| 4254 | DRM_DEBUG("MC busy: 0x%08X, clearing.\n", reset_mask); |
| 4255 | reset_mask &= ~RADEON_RESET_MC; |
| 4256 | } |
| 4257 | |
| 4258 | return reset_mask; |
| 4259 | } |
| 4260 | |
| 4261 | /** |
| 4262 | * cik_gpu_soft_reset - soft reset GPU |
| 4263 | * |
| 4264 | * @rdev: radeon_device pointer |
| 4265 | * @reset_mask: mask of which blocks to reset |
| 4266 | * |
| 4267 | * Soft reset the blocks specified in @reset_mask. |
| 4268 | */ |
| 4269 | static void cik_gpu_soft_reset(struct radeon_device *rdev, u32 reset_mask) |
| 4270 | { |
| 4271 | struct evergreen_mc_save save; |
| 4272 | u32 grbm_soft_reset = 0, srbm_soft_reset = 0; |
| 4273 | u32 tmp; |
| 4274 | |
| 4275 | if (reset_mask == 0) |
| 4276 | return; |
| 4277 | |
| 4278 | dev_info(rdev->dev, "GPU softreset: 0x%08X\n", reset_mask); |
| 4279 | |
| 4280 | cik_print_gpu_status_regs(rdev); |
| 4281 | dev_info(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
| 4282 | RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); |
| 4283 | dev_info(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
| 4284 | RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); |
| 4285 | |
Alex Deucher | fb2c7f4 | 2013-10-02 14:54:44 -0400 | [diff] [blame] | 4286 | /* disable CG/PG */ |
| 4287 | cik_fini_pg(rdev); |
| 4288 | cik_fini_cg(rdev); |
| 4289 | |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4290 | /* stop the rlc */ |
| 4291 | cik_rlc_stop(rdev); |
| 4292 | |
| 4293 | /* Disable GFX parsing/prefetching */ |
| 4294 | WREG32(CP_ME_CNTL, CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT); |
| 4295 | |
| 4296 | /* Disable MEC parsing/prefetching */ |
| 4297 | WREG32(CP_MEC_CNTL, MEC_ME1_HALT | MEC_ME2_HALT); |
| 4298 | |
| 4299 | if (reset_mask & RADEON_RESET_DMA) { |
| 4300 | /* sdma0 */ |
| 4301 | tmp = RREG32(SDMA0_ME_CNTL + SDMA0_REGISTER_OFFSET); |
| 4302 | tmp |= SDMA_HALT; |
| 4303 | WREG32(SDMA0_ME_CNTL + SDMA0_REGISTER_OFFSET, tmp); |
| 4304 | } |
| 4305 | if (reset_mask & RADEON_RESET_DMA1) { |
| 4306 | /* sdma1 */ |
| 4307 | tmp = RREG32(SDMA0_ME_CNTL + SDMA1_REGISTER_OFFSET); |
| 4308 | tmp |= SDMA_HALT; |
| 4309 | WREG32(SDMA0_ME_CNTL + SDMA1_REGISTER_OFFSET, tmp); |
| 4310 | } |
| 4311 | |
| 4312 | evergreen_mc_stop(rdev, &save); |
| 4313 | if (evergreen_mc_wait_for_idle(rdev)) { |
| 4314 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 4315 | } |
| 4316 | |
| 4317 | if (reset_mask & (RADEON_RESET_GFX | RADEON_RESET_COMPUTE | RADEON_RESET_CP)) |
| 4318 | grbm_soft_reset = SOFT_RESET_CP | SOFT_RESET_GFX; |
| 4319 | |
| 4320 | if (reset_mask & RADEON_RESET_CP) { |
| 4321 | grbm_soft_reset |= SOFT_RESET_CP; |
| 4322 | |
| 4323 | srbm_soft_reset |= SOFT_RESET_GRBM; |
| 4324 | } |
| 4325 | |
| 4326 | if (reset_mask & RADEON_RESET_DMA) |
| 4327 | srbm_soft_reset |= SOFT_RESET_SDMA; |
| 4328 | |
| 4329 | if (reset_mask & RADEON_RESET_DMA1) |
| 4330 | srbm_soft_reset |= SOFT_RESET_SDMA1; |
| 4331 | |
| 4332 | if (reset_mask & RADEON_RESET_DISPLAY) |
| 4333 | srbm_soft_reset |= SOFT_RESET_DC; |
| 4334 | |
| 4335 | if (reset_mask & RADEON_RESET_RLC) |
| 4336 | grbm_soft_reset |= SOFT_RESET_RLC; |
| 4337 | |
| 4338 | if (reset_mask & RADEON_RESET_SEM) |
| 4339 | srbm_soft_reset |= SOFT_RESET_SEM; |
| 4340 | |
| 4341 | if (reset_mask & RADEON_RESET_IH) |
| 4342 | srbm_soft_reset |= SOFT_RESET_IH; |
| 4343 | |
| 4344 | if (reset_mask & RADEON_RESET_GRBM) |
| 4345 | srbm_soft_reset |= SOFT_RESET_GRBM; |
| 4346 | |
| 4347 | if (reset_mask & RADEON_RESET_VMC) |
| 4348 | srbm_soft_reset |= SOFT_RESET_VMC; |
| 4349 | |
| 4350 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 4351 | if (reset_mask & RADEON_RESET_MC) |
| 4352 | srbm_soft_reset |= SOFT_RESET_MC; |
| 4353 | } |
| 4354 | |
| 4355 | if (grbm_soft_reset) { |
| 4356 | tmp = RREG32(GRBM_SOFT_RESET); |
| 4357 | tmp |= grbm_soft_reset; |
| 4358 | dev_info(rdev->dev, "GRBM_SOFT_RESET=0x%08X\n", tmp); |
| 4359 | WREG32(GRBM_SOFT_RESET, tmp); |
| 4360 | tmp = RREG32(GRBM_SOFT_RESET); |
| 4361 | |
| 4362 | udelay(50); |
| 4363 | |
| 4364 | tmp &= ~grbm_soft_reset; |
| 4365 | WREG32(GRBM_SOFT_RESET, tmp); |
| 4366 | tmp = RREG32(GRBM_SOFT_RESET); |
| 4367 | } |
| 4368 | |
| 4369 | if (srbm_soft_reset) { |
| 4370 | tmp = RREG32(SRBM_SOFT_RESET); |
| 4371 | tmp |= srbm_soft_reset; |
| 4372 | dev_info(rdev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp); |
| 4373 | WREG32(SRBM_SOFT_RESET, tmp); |
| 4374 | tmp = RREG32(SRBM_SOFT_RESET); |
| 4375 | |
| 4376 | udelay(50); |
| 4377 | |
| 4378 | tmp &= ~srbm_soft_reset; |
| 4379 | WREG32(SRBM_SOFT_RESET, tmp); |
| 4380 | tmp = RREG32(SRBM_SOFT_RESET); |
| 4381 | } |
| 4382 | |
| 4383 | /* Wait a little for things to settle down */ |
| 4384 | udelay(50); |
| 4385 | |
| 4386 | evergreen_mc_resume(rdev, &save); |
| 4387 | udelay(50); |
| 4388 | |
| 4389 | cik_print_gpu_status_regs(rdev); |
| 4390 | } |
| 4391 | |
| 4392 | /** |
| 4393 | * cik_asic_reset - soft reset GPU |
| 4394 | * |
| 4395 | * @rdev: radeon_device pointer |
| 4396 | * |
| 4397 | * Look up which blocks are hung and attempt |
| 4398 | * to reset them. |
| 4399 | * Returns 0 for success. |
| 4400 | */ |
| 4401 | int cik_asic_reset(struct radeon_device *rdev) |
| 4402 | { |
| 4403 | u32 reset_mask; |
| 4404 | |
| 4405 | reset_mask = cik_gpu_check_soft_reset(rdev); |
| 4406 | |
| 4407 | if (reset_mask) |
| 4408 | r600_set_bios_scratch_engine_hung(rdev, true); |
| 4409 | |
| 4410 | cik_gpu_soft_reset(rdev, reset_mask); |
| 4411 | |
| 4412 | reset_mask = cik_gpu_check_soft_reset(rdev); |
| 4413 | |
| 4414 | if (!reset_mask) |
| 4415 | r600_set_bios_scratch_engine_hung(rdev, false); |
| 4416 | |
| 4417 | return 0; |
| 4418 | } |
| 4419 | |
| 4420 | /** |
| 4421 | * cik_gfx_is_lockup - check if the 3D engine is locked up |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4422 | * |
| 4423 | * @rdev: radeon_device pointer |
| 4424 | * @ring: radeon_ring structure holding ring information |
| 4425 | * |
| 4426 | * Check if the 3D engine is locked up (CIK). |
| 4427 | * Returns true if the engine is locked, false if not. |
| 4428 | */ |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4429 | bool cik_gfx_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring) |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4430 | { |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4431 | u32 reset_mask = cik_gpu_check_soft_reset(rdev); |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4432 | |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4433 | if (!(reset_mask & (RADEON_RESET_GFX | |
| 4434 | RADEON_RESET_COMPUTE | |
| 4435 | RADEON_RESET_CP))) { |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4436 | radeon_ring_lockup_update(ring); |
| 4437 | return false; |
| 4438 | } |
| 4439 | /* force CP activities */ |
| 4440 | radeon_ring_force_activity(rdev, ring); |
| 4441 | return radeon_ring_test_lockup(rdev, ring); |
| 4442 | } |
| 4443 | |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4444 | /* MC */ |
| 4445 | /** |
| 4446 | * cik_mc_program - program the GPU memory controller |
| 4447 | * |
| 4448 | * @rdev: radeon_device pointer |
| 4449 | * |
| 4450 | * Set the location of vram, gart, and AGP in the GPU's |
| 4451 | * physical address space (CIK). |
| 4452 | */ |
| 4453 | static void cik_mc_program(struct radeon_device *rdev) |
| 4454 | { |
| 4455 | struct evergreen_mc_save save; |
| 4456 | u32 tmp; |
| 4457 | int i, j; |
| 4458 | |
| 4459 | /* Initialize HDP */ |
| 4460 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 4461 | WREG32((0x2c14 + j), 0x00000000); |
| 4462 | WREG32((0x2c18 + j), 0x00000000); |
| 4463 | WREG32((0x2c1c + j), 0x00000000); |
| 4464 | WREG32((0x2c20 + j), 0x00000000); |
| 4465 | WREG32((0x2c24 + j), 0x00000000); |
| 4466 | } |
| 4467 | WREG32(HDP_REG_COHERENCY_FLUSH_CNTL, 0); |
| 4468 | |
| 4469 | evergreen_mc_stop(rdev, &save); |
| 4470 | if (radeon_mc_wait_for_idle(rdev)) { |
| 4471 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 4472 | } |
| 4473 | /* Lockout access through VGA aperture*/ |
| 4474 | WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE); |
| 4475 | /* Update configuration */ |
| 4476 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 4477 | rdev->mc.vram_start >> 12); |
| 4478 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 4479 | rdev->mc.vram_end >> 12); |
| 4480 | WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, |
| 4481 | rdev->vram_scratch.gpu_addr >> 12); |
| 4482 | tmp = ((rdev->mc.vram_end >> 24) & 0xFFFF) << 16; |
| 4483 | tmp |= ((rdev->mc.vram_start >> 24) & 0xFFFF); |
| 4484 | WREG32(MC_VM_FB_LOCATION, tmp); |
| 4485 | /* XXX double check these! */ |
| 4486 | WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); |
| 4487 | WREG32(HDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); |
| 4488 | WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF); |
| 4489 | WREG32(MC_VM_AGP_BASE, 0); |
| 4490 | WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF); |
| 4491 | WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF); |
| 4492 | if (radeon_mc_wait_for_idle(rdev)) { |
| 4493 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 4494 | } |
| 4495 | evergreen_mc_resume(rdev, &save); |
| 4496 | /* we need to own VRAM, so turn off the VGA renderer here |
| 4497 | * to stop it overwriting our objects */ |
| 4498 | rv515_vga_render_disable(rdev); |
| 4499 | } |
| 4500 | |
| 4501 | /** |
| 4502 | * cik_mc_init - initialize the memory controller driver params |
| 4503 | * |
| 4504 | * @rdev: radeon_device pointer |
| 4505 | * |
| 4506 | * Look up the amount of vram, vram width, and decide how to place |
| 4507 | * vram and gart within the GPU's physical address space (CIK). |
| 4508 | * Returns 0 for success. |
| 4509 | */ |
| 4510 | static int cik_mc_init(struct radeon_device *rdev) |
| 4511 | { |
| 4512 | u32 tmp; |
| 4513 | int chansize, numchan; |
| 4514 | |
| 4515 | /* Get VRAM informations */ |
| 4516 | rdev->mc.vram_is_ddr = true; |
| 4517 | tmp = RREG32(MC_ARB_RAMCFG); |
| 4518 | if (tmp & CHANSIZE_MASK) { |
| 4519 | chansize = 64; |
| 4520 | } else { |
| 4521 | chansize = 32; |
| 4522 | } |
| 4523 | tmp = RREG32(MC_SHARED_CHMAP); |
| 4524 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 4525 | case 0: |
| 4526 | default: |
| 4527 | numchan = 1; |
| 4528 | break; |
| 4529 | case 1: |
| 4530 | numchan = 2; |
| 4531 | break; |
| 4532 | case 2: |
| 4533 | numchan = 4; |
| 4534 | break; |
| 4535 | case 3: |
| 4536 | numchan = 8; |
| 4537 | break; |
| 4538 | case 4: |
| 4539 | numchan = 3; |
| 4540 | break; |
| 4541 | case 5: |
| 4542 | numchan = 6; |
| 4543 | break; |
| 4544 | case 6: |
| 4545 | numchan = 10; |
| 4546 | break; |
| 4547 | case 7: |
| 4548 | numchan = 12; |
| 4549 | break; |
| 4550 | case 8: |
| 4551 | numchan = 16; |
| 4552 | break; |
| 4553 | } |
| 4554 | rdev->mc.vram_width = numchan * chansize; |
| 4555 | /* Could aper size report 0 ? */ |
| 4556 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
| 4557 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
| 4558 | /* size in MB on si */ |
Alex Deucher | 13c5bfd | 2013-09-24 10:56:55 -0400 | [diff] [blame] | 4559 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
| 4560 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4561 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
| 4562 | si_vram_gtt_location(rdev, &rdev->mc); |
| 4563 | radeon_update_bandwidth_info(rdev); |
| 4564 | |
| 4565 | return 0; |
| 4566 | } |
| 4567 | |
| 4568 | /* |
| 4569 | * GART |
| 4570 | * VMID 0 is the physical GPU addresses as used by the kernel. |
| 4571 | * VMIDs 1-15 are used for userspace clients and are handled |
| 4572 | * by the radeon vm/hsa code. |
| 4573 | */ |
| 4574 | /** |
| 4575 | * cik_pcie_gart_tlb_flush - gart tlb flush callback |
| 4576 | * |
| 4577 | * @rdev: radeon_device pointer |
| 4578 | * |
| 4579 | * Flush the TLB for the VMID 0 page table (CIK). |
| 4580 | */ |
| 4581 | void cik_pcie_gart_tlb_flush(struct radeon_device *rdev) |
| 4582 | { |
| 4583 | /* flush hdp cache */ |
| 4584 | WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0); |
| 4585 | |
| 4586 | /* bits 0-15 are the VM contexts0-15 */ |
| 4587 | WREG32(VM_INVALIDATE_REQUEST, 0x1); |
| 4588 | } |
| 4589 | |
| 4590 | /** |
| 4591 | * cik_pcie_gart_enable - gart enable |
| 4592 | * |
| 4593 | * @rdev: radeon_device pointer |
| 4594 | * |
| 4595 | * This sets up the TLBs, programs the page tables for VMID0, |
| 4596 | * sets up the hw for VMIDs 1-15 which are allocated on |
| 4597 | * demand, and sets up the global locations for the LDS, GDS, |
| 4598 | * and GPUVM for FSA64 clients (CIK). |
| 4599 | * Returns 0 for success, errors for failure. |
| 4600 | */ |
| 4601 | static int cik_pcie_gart_enable(struct radeon_device *rdev) |
| 4602 | { |
| 4603 | int r, i; |
| 4604 | |
| 4605 | if (rdev->gart.robj == NULL) { |
| 4606 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); |
| 4607 | return -EINVAL; |
| 4608 | } |
| 4609 | r = radeon_gart_table_vram_pin(rdev); |
| 4610 | if (r) |
| 4611 | return r; |
| 4612 | radeon_gart_restore(rdev); |
| 4613 | /* Setup TLB control */ |
| 4614 | WREG32(MC_VM_MX_L1_TLB_CNTL, |
| 4615 | (0xA << 7) | |
| 4616 | ENABLE_L1_TLB | |
| 4617 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 4618 | ENABLE_ADVANCED_DRIVER_MODEL | |
| 4619 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU); |
| 4620 | /* Setup L2 cache */ |
| 4621 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | |
| 4622 | ENABLE_L2_FRAGMENT_PROCESSING | |
| 4623 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 4624 | ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE | |
| 4625 | EFFECTIVE_L2_QUEUE_SIZE(7) | |
| 4626 | CONTEXT1_IDENTITY_ACCESS_MODE(1)); |
| 4627 | WREG32(VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS | INVALIDATE_L2_CACHE); |
| 4628 | WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY | |
| 4629 | L2_CACHE_BIGK_FRAGMENT_SIZE(6)); |
| 4630 | /* setup context0 */ |
| 4631 | WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, rdev->mc.gtt_start >> 12); |
| 4632 | WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, rdev->mc.gtt_end >> 12); |
| 4633 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, rdev->gart.table_addr >> 12); |
| 4634 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
| 4635 | (u32)(rdev->dummy_page.addr >> 12)); |
| 4636 | WREG32(VM_CONTEXT0_CNTL2, 0); |
| 4637 | WREG32(VM_CONTEXT0_CNTL, (ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) | |
| 4638 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT)); |
| 4639 | |
| 4640 | WREG32(0x15D4, 0); |
| 4641 | WREG32(0x15D8, 0); |
| 4642 | WREG32(0x15DC, 0); |
| 4643 | |
| 4644 | /* empty context1-15 */ |
| 4645 | /* FIXME start with 4G, once using 2 level pt switch to full |
| 4646 | * vm size space |
| 4647 | */ |
| 4648 | /* set vm size, must be a multiple of 4 */ |
| 4649 | WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); |
| 4650 | WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); |
| 4651 | for (i = 1; i < 16; i++) { |
| 4652 | if (i < 8) |
| 4653 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), |
| 4654 | rdev->gart.table_addr >> 12); |
| 4655 | else |
| 4656 | WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2), |
| 4657 | rdev->gart.table_addr >> 12); |
| 4658 | } |
| 4659 | |
| 4660 | /* enable context1-15 */ |
| 4661 | WREG32(VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR, |
| 4662 | (u32)(rdev->dummy_page.addr >> 12)); |
Alex Deucher | a00024b | 2012-09-18 16:06:01 -0400 | [diff] [blame] | 4663 | WREG32(VM_CONTEXT1_CNTL2, 4); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4664 | WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(1) | |
Alex Deucher | a00024b | 2012-09-18 16:06:01 -0400 | [diff] [blame] | 4665 | RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4666 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4667 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4668 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4669 | PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4670 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4671 | VALID_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4672 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4673 | READ_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4674 | READ_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4675 | WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4676 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4677 | |
| 4678 | /* TC cache setup ??? */ |
| 4679 | WREG32(TC_CFG_L1_LOAD_POLICY0, 0); |
| 4680 | WREG32(TC_CFG_L1_LOAD_POLICY1, 0); |
| 4681 | WREG32(TC_CFG_L1_STORE_POLICY, 0); |
| 4682 | |
| 4683 | WREG32(TC_CFG_L2_LOAD_POLICY0, 0); |
| 4684 | WREG32(TC_CFG_L2_LOAD_POLICY1, 0); |
| 4685 | WREG32(TC_CFG_L2_STORE_POLICY0, 0); |
| 4686 | WREG32(TC_CFG_L2_STORE_POLICY1, 0); |
| 4687 | WREG32(TC_CFG_L2_ATOMIC_POLICY, 0); |
| 4688 | |
| 4689 | WREG32(TC_CFG_L1_VOLATILE, 0); |
| 4690 | WREG32(TC_CFG_L2_VOLATILE, 0); |
| 4691 | |
| 4692 | if (rdev->family == CHIP_KAVERI) { |
| 4693 | u32 tmp = RREG32(CHUB_CONTROL); |
| 4694 | tmp &= ~BYPASS_VM; |
| 4695 | WREG32(CHUB_CONTROL, tmp); |
| 4696 | } |
| 4697 | |
| 4698 | /* XXX SH_MEM regs */ |
| 4699 | /* where to put LDS, scratch, GPUVM in FSA64 space */ |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 4700 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4701 | for (i = 0; i < 16; i++) { |
Alex Deucher | b556b12 | 2013-01-29 10:44:22 -0500 | [diff] [blame] | 4702 | cik_srbm_select(rdev, 0, 0, 0, i); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 4703 | /* CP and shaders */ |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4704 | WREG32(SH_MEM_CONFIG, 0); |
| 4705 | WREG32(SH_MEM_APE1_BASE, 1); |
| 4706 | WREG32(SH_MEM_APE1_LIMIT, 0); |
| 4707 | WREG32(SH_MEM_BASES, 0); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 4708 | /* SDMA GFX */ |
| 4709 | WREG32(SDMA0_GFX_VIRTUAL_ADDR + SDMA0_REGISTER_OFFSET, 0); |
| 4710 | WREG32(SDMA0_GFX_APE1_CNTL + SDMA0_REGISTER_OFFSET, 0); |
| 4711 | WREG32(SDMA0_GFX_VIRTUAL_ADDR + SDMA1_REGISTER_OFFSET, 0); |
| 4712 | WREG32(SDMA0_GFX_APE1_CNTL + SDMA1_REGISTER_OFFSET, 0); |
| 4713 | /* XXX SDMA RLC - todo */ |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4714 | } |
Alex Deucher | b556b12 | 2013-01-29 10:44:22 -0500 | [diff] [blame] | 4715 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 4716 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4717 | |
| 4718 | cik_pcie_gart_tlb_flush(rdev); |
| 4719 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
| 4720 | (unsigned)(rdev->mc.gtt_size >> 20), |
| 4721 | (unsigned long long)rdev->gart.table_addr); |
| 4722 | rdev->gart.ready = true; |
| 4723 | return 0; |
| 4724 | } |
| 4725 | |
| 4726 | /** |
| 4727 | * cik_pcie_gart_disable - gart disable |
| 4728 | * |
| 4729 | * @rdev: radeon_device pointer |
| 4730 | * |
| 4731 | * This disables all VM page table (CIK). |
| 4732 | */ |
| 4733 | static void cik_pcie_gart_disable(struct radeon_device *rdev) |
| 4734 | { |
| 4735 | /* Disable all tables */ |
| 4736 | WREG32(VM_CONTEXT0_CNTL, 0); |
| 4737 | WREG32(VM_CONTEXT1_CNTL, 0); |
| 4738 | /* Setup TLB control */ |
| 4739 | WREG32(MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 4740 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU); |
| 4741 | /* Setup L2 cache */ |
| 4742 | WREG32(VM_L2_CNTL, |
| 4743 | ENABLE_L2_FRAGMENT_PROCESSING | |
| 4744 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 4745 | ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE | |
| 4746 | EFFECTIVE_L2_QUEUE_SIZE(7) | |
| 4747 | CONTEXT1_IDENTITY_ACCESS_MODE(1)); |
| 4748 | WREG32(VM_L2_CNTL2, 0); |
| 4749 | WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY | |
| 4750 | L2_CACHE_BIGK_FRAGMENT_SIZE(6)); |
| 4751 | radeon_gart_table_vram_unpin(rdev); |
| 4752 | } |
| 4753 | |
| 4754 | /** |
| 4755 | * cik_pcie_gart_fini - vm fini callback |
| 4756 | * |
| 4757 | * @rdev: radeon_device pointer |
| 4758 | * |
| 4759 | * Tears down the driver GART/VM setup (CIK). |
| 4760 | */ |
| 4761 | static void cik_pcie_gart_fini(struct radeon_device *rdev) |
| 4762 | { |
| 4763 | cik_pcie_gart_disable(rdev); |
| 4764 | radeon_gart_table_vram_free(rdev); |
| 4765 | radeon_gart_fini(rdev); |
| 4766 | } |
| 4767 | |
| 4768 | /* vm parser */ |
| 4769 | /** |
| 4770 | * cik_ib_parse - vm ib_parse callback |
| 4771 | * |
| 4772 | * @rdev: radeon_device pointer |
| 4773 | * @ib: indirect buffer pointer |
| 4774 | * |
| 4775 | * CIK uses hw IB checking so this is a nop (CIK). |
| 4776 | */ |
| 4777 | int cik_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib) |
| 4778 | { |
| 4779 | return 0; |
| 4780 | } |
| 4781 | |
| 4782 | /* |
| 4783 | * vm |
| 4784 | * VMID 0 is the physical GPU addresses as used by the kernel. |
| 4785 | * VMIDs 1-15 are used for userspace clients and are handled |
| 4786 | * by the radeon vm/hsa code. |
| 4787 | */ |
| 4788 | /** |
| 4789 | * cik_vm_init - cik vm init callback |
| 4790 | * |
| 4791 | * @rdev: radeon_device pointer |
| 4792 | * |
| 4793 | * Inits cik specific vm parameters (number of VMs, base of vram for |
| 4794 | * VMIDs 1-15) (CIK). |
| 4795 | * Returns 0 for success. |
| 4796 | */ |
| 4797 | int cik_vm_init(struct radeon_device *rdev) |
| 4798 | { |
| 4799 | /* number of VMs */ |
| 4800 | rdev->vm_manager.nvm = 16; |
| 4801 | /* base offset of vram pages */ |
| 4802 | if (rdev->flags & RADEON_IS_IGP) { |
| 4803 | u64 tmp = RREG32(MC_VM_FB_OFFSET); |
| 4804 | tmp <<= 22; |
| 4805 | rdev->vm_manager.vram_base_offset = tmp; |
| 4806 | } else |
| 4807 | rdev->vm_manager.vram_base_offset = 0; |
| 4808 | |
| 4809 | return 0; |
| 4810 | } |
| 4811 | |
| 4812 | /** |
| 4813 | * cik_vm_fini - cik vm fini callback |
| 4814 | * |
| 4815 | * @rdev: radeon_device pointer |
| 4816 | * |
| 4817 | * Tear down any asic specific VM setup (CIK). |
| 4818 | */ |
| 4819 | void cik_vm_fini(struct radeon_device *rdev) |
| 4820 | { |
| 4821 | } |
| 4822 | |
Alex Deucher | f96ab48 | 2012-08-31 10:37:47 -0400 | [diff] [blame] | 4823 | /** |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4824 | * cik_vm_decode_fault - print human readable fault info |
| 4825 | * |
| 4826 | * @rdev: radeon_device pointer |
| 4827 | * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value |
| 4828 | * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value |
| 4829 | * |
| 4830 | * Print human readable fault information (CIK). |
| 4831 | */ |
| 4832 | static void cik_vm_decode_fault(struct radeon_device *rdev, |
| 4833 | u32 status, u32 addr, u32 mc_client) |
| 4834 | { |
Alex Deucher | 939c0d3 | 2013-09-30 18:03:06 -0400 | [diff] [blame^] | 4835 | u32 mc_id; |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4836 | u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT; |
| 4837 | u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT; |
Michel Dänzer | 328a50c7b | 2013-09-18 15:39:40 +0200 | [diff] [blame] | 4838 | char block[5] = { mc_client >> 24, (mc_client >> 16) & 0xff, |
| 4839 | (mc_client >> 8) & 0xff, mc_client & 0xff, 0 }; |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4840 | |
Alex Deucher | 939c0d3 | 2013-09-30 18:03:06 -0400 | [diff] [blame^] | 4841 | if (rdev->family == CHIP_HAWAII) |
| 4842 | mc_id = (status & HAWAII_MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT; |
| 4843 | else |
| 4844 | mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT; |
| 4845 | |
Michel Dänzer | 328a50c7b | 2013-09-18 15:39:40 +0200 | [diff] [blame] | 4846 | printk("VM fault (0x%02x, vmid %d) at page %u, %s from '%s' (0x%08x) (%d)\n", |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4847 | protections, vmid, addr, |
| 4848 | (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read", |
Michel Dänzer | 328a50c7b | 2013-09-18 15:39:40 +0200 | [diff] [blame] | 4849 | block, mc_client, mc_id); |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4850 | } |
| 4851 | |
| 4852 | /** |
Alex Deucher | f96ab48 | 2012-08-31 10:37:47 -0400 | [diff] [blame] | 4853 | * cik_vm_flush - cik vm flush using the CP |
| 4854 | * |
| 4855 | * @rdev: radeon_device pointer |
| 4856 | * |
| 4857 | * Update the page table base and flush the VM TLB |
| 4858 | * using the CP (CIK). |
| 4859 | */ |
| 4860 | void cik_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm) |
| 4861 | { |
| 4862 | struct radeon_ring *ring = &rdev->ring[ridx]; |
| 4863 | |
| 4864 | if (vm == NULL) |
| 4865 | return; |
| 4866 | |
| 4867 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4868 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4869 | WRITE_DATA_DST_SEL(0))); |
| 4870 | if (vm->id < 8) { |
| 4871 | radeon_ring_write(ring, |
| 4872 | (VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (vm->id << 2)) >> 2); |
| 4873 | } else { |
| 4874 | radeon_ring_write(ring, |
| 4875 | (VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((vm->id - 8) << 2)) >> 2); |
| 4876 | } |
| 4877 | radeon_ring_write(ring, 0); |
| 4878 | radeon_ring_write(ring, vm->pd_gpu_addr >> 12); |
| 4879 | |
| 4880 | /* update SH_MEM_* regs */ |
| 4881 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4882 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4883 | WRITE_DATA_DST_SEL(0))); |
| 4884 | radeon_ring_write(ring, SRBM_GFX_CNTL >> 2); |
| 4885 | radeon_ring_write(ring, 0); |
| 4886 | radeon_ring_write(ring, VMID(vm->id)); |
| 4887 | |
| 4888 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 6)); |
| 4889 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4890 | WRITE_DATA_DST_SEL(0))); |
| 4891 | radeon_ring_write(ring, SH_MEM_BASES >> 2); |
| 4892 | radeon_ring_write(ring, 0); |
| 4893 | |
| 4894 | radeon_ring_write(ring, 0); /* SH_MEM_BASES */ |
| 4895 | radeon_ring_write(ring, 0); /* SH_MEM_CONFIG */ |
| 4896 | radeon_ring_write(ring, 1); /* SH_MEM_APE1_BASE */ |
| 4897 | radeon_ring_write(ring, 0); /* SH_MEM_APE1_LIMIT */ |
| 4898 | |
| 4899 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4900 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4901 | WRITE_DATA_DST_SEL(0))); |
| 4902 | radeon_ring_write(ring, SRBM_GFX_CNTL >> 2); |
| 4903 | radeon_ring_write(ring, 0); |
| 4904 | radeon_ring_write(ring, VMID(0)); |
| 4905 | |
| 4906 | /* HDP flush */ |
| 4907 | /* We should be using the WAIT_REG_MEM packet here like in |
| 4908 | * cik_fence_ring_emit(), but it causes the CP to hang in this |
| 4909 | * context... |
| 4910 | */ |
| 4911 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4912 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4913 | WRITE_DATA_DST_SEL(0))); |
| 4914 | radeon_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL >> 2); |
| 4915 | radeon_ring_write(ring, 0); |
| 4916 | radeon_ring_write(ring, 0); |
| 4917 | |
| 4918 | /* bits 0-15 are the VM contexts0-15 */ |
| 4919 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4920 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4921 | WRITE_DATA_DST_SEL(0))); |
| 4922 | radeon_ring_write(ring, VM_INVALIDATE_REQUEST >> 2); |
| 4923 | radeon_ring_write(ring, 0); |
| 4924 | radeon_ring_write(ring, 1 << vm->id); |
| 4925 | |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 4926 | /* compute doesn't have PFP */ |
| 4927 | if (ridx == RADEON_RING_TYPE_GFX_INDEX) { |
| 4928 | /* sync PFP to ME, otherwise we might get invalid PFP reads */ |
| 4929 | radeon_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0)); |
| 4930 | radeon_ring_write(ring, 0x0); |
| 4931 | } |
Alex Deucher | f96ab48 | 2012-08-31 10:37:47 -0400 | [diff] [blame] | 4932 | } |
| 4933 | |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4934 | /* |
| 4935 | * RLC |
| 4936 | * The RLC is a multi-purpose microengine that handles a |
| 4937 | * variety of functions, the most important of which is |
| 4938 | * the interrupt controller. |
| 4939 | */ |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4940 | static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev, |
| 4941 | bool enable) |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4942 | { |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4943 | u32 tmp = RREG32(CP_INT_CNTL_RING0); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4944 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4945 | if (enable) |
| 4946 | tmp |= (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 4947 | else |
| 4948 | tmp &= ~(CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4949 | WREG32(CP_INT_CNTL_RING0, tmp); |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4950 | } |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4951 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4952 | static void cik_enable_lbpw(struct radeon_device *rdev, bool enable) |
| 4953 | { |
| 4954 | u32 tmp; |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4955 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4956 | tmp = RREG32(RLC_LB_CNTL); |
| 4957 | if (enable) |
| 4958 | tmp |= LOAD_BALANCE_ENABLE; |
| 4959 | else |
| 4960 | tmp &= ~LOAD_BALANCE_ENABLE; |
| 4961 | WREG32(RLC_LB_CNTL, tmp); |
| 4962 | } |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4963 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4964 | static void cik_wait_for_rlc_serdes(struct radeon_device *rdev) |
| 4965 | { |
| 4966 | u32 i, j, k; |
| 4967 | u32 mask; |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4968 | |
| 4969 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { |
| 4970 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { |
| 4971 | cik_select_se_sh(rdev, i, j); |
| 4972 | for (k = 0; k < rdev->usec_timeout; k++) { |
| 4973 | if (RREG32(RLC_SERDES_CU_MASTER_BUSY) == 0) |
| 4974 | break; |
| 4975 | udelay(1); |
| 4976 | } |
| 4977 | } |
| 4978 | } |
| 4979 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 4980 | |
| 4981 | mask = SE_MASTER_BUSY_MASK | GC_MASTER_BUSY | TC0_MASTER_BUSY | TC1_MASTER_BUSY; |
| 4982 | for (k = 0; k < rdev->usec_timeout; k++) { |
| 4983 | if ((RREG32(RLC_SERDES_NONCU_MASTER_BUSY) & mask) == 0) |
| 4984 | break; |
| 4985 | udelay(1); |
| 4986 | } |
| 4987 | } |
| 4988 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 4989 | static void cik_update_rlc(struct radeon_device *rdev, u32 rlc) |
| 4990 | { |
| 4991 | u32 tmp; |
| 4992 | |
| 4993 | tmp = RREG32(RLC_CNTL); |
| 4994 | if (tmp != rlc) |
| 4995 | WREG32(RLC_CNTL, rlc); |
| 4996 | } |
| 4997 | |
| 4998 | static u32 cik_halt_rlc(struct radeon_device *rdev) |
| 4999 | { |
| 5000 | u32 data, orig; |
| 5001 | |
| 5002 | orig = data = RREG32(RLC_CNTL); |
| 5003 | |
| 5004 | if (data & RLC_ENABLE) { |
| 5005 | u32 i; |
| 5006 | |
| 5007 | data &= ~RLC_ENABLE; |
| 5008 | WREG32(RLC_CNTL, data); |
| 5009 | |
| 5010 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 5011 | if ((RREG32(RLC_GPM_STAT) & RLC_GPM_BUSY) == 0) |
| 5012 | break; |
| 5013 | udelay(1); |
| 5014 | } |
| 5015 | |
| 5016 | cik_wait_for_rlc_serdes(rdev); |
| 5017 | } |
| 5018 | |
| 5019 | return orig; |
| 5020 | } |
| 5021 | |
Alex Deucher | a412fce | 2013-04-22 20:23:31 -0400 | [diff] [blame] | 5022 | void cik_enter_rlc_safe_mode(struct radeon_device *rdev) |
| 5023 | { |
| 5024 | u32 tmp, i, mask; |
| 5025 | |
| 5026 | tmp = REQ | MESSAGE(MSG_ENTER_RLC_SAFE_MODE); |
| 5027 | WREG32(RLC_GPR_REG2, tmp); |
| 5028 | |
| 5029 | mask = GFX_POWER_STATUS | GFX_CLOCK_STATUS; |
| 5030 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 5031 | if ((RREG32(RLC_GPM_STAT) & mask) == mask) |
| 5032 | break; |
| 5033 | udelay(1); |
| 5034 | } |
| 5035 | |
| 5036 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 5037 | if ((RREG32(RLC_GPR_REG2) & REQ) == 0) |
| 5038 | break; |
| 5039 | udelay(1); |
| 5040 | } |
| 5041 | } |
| 5042 | |
| 5043 | void cik_exit_rlc_safe_mode(struct radeon_device *rdev) |
| 5044 | { |
| 5045 | u32 tmp; |
| 5046 | |
| 5047 | tmp = REQ | MESSAGE(MSG_EXIT_RLC_SAFE_MODE); |
| 5048 | WREG32(RLC_GPR_REG2, tmp); |
| 5049 | } |
| 5050 | |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5051 | /** |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5052 | * cik_rlc_stop - stop the RLC ME |
| 5053 | * |
| 5054 | * @rdev: radeon_device pointer |
| 5055 | * |
| 5056 | * Halt the RLC ME (MicroEngine) (CIK). |
| 5057 | */ |
| 5058 | static void cik_rlc_stop(struct radeon_device *rdev) |
| 5059 | { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5060 | WREG32(RLC_CNTL, 0); |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5061 | |
| 5062 | cik_enable_gui_idle_interrupt(rdev, false); |
| 5063 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5064 | cik_wait_for_rlc_serdes(rdev); |
| 5065 | } |
| 5066 | |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5067 | /** |
| 5068 | * cik_rlc_start - start the RLC ME |
| 5069 | * |
| 5070 | * @rdev: radeon_device pointer |
| 5071 | * |
| 5072 | * Unhalt the RLC ME (MicroEngine) (CIK). |
| 5073 | */ |
| 5074 | static void cik_rlc_start(struct radeon_device *rdev) |
| 5075 | { |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5076 | WREG32(RLC_CNTL, RLC_ENABLE); |
| 5077 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5078 | cik_enable_gui_idle_interrupt(rdev, true); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5079 | |
| 5080 | udelay(50); |
| 5081 | } |
| 5082 | |
| 5083 | /** |
| 5084 | * cik_rlc_resume - setup the RLC hw |
| 5085 | * |
| 5086 | * @rdev: radeon_device pointer |
| 5087 | * |
| 5088 | * Initialize the RLC registers, load the ucode, |
| 5089 | * and start the RLC (CIK). |
| 5090 | * Returns 0 for success, -EINVAL if the ucode is not available. |
| 5091 | */ |
| 5092 | static int cik_rlc_resume(struct radeon_device *rdev) |
| 5093 | { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5094 | u32 i, size, tmp; |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5095 | const __be32 *fw_data; |
| 5096 | |
| 5097 | if (!rdev->rlc_fw) |
| 5098 | return -EINVAL; |
| 5099 | |
| 5100 | switch (rdev->family) { |
| 5101 | case CHIP_BONAIRE: |
| 5102 | default: |
| 5103 | size = BONAIRE_RLC_UCODE_SIZE; |
| 5104 | break; |
| 5105 | case CHIP_KAVERI: |
| 5106 | size = KV_RLC_UCODE_SIZE; |
| 5107 | break; |
| 5108 | case CHIP_KABINI: |
| 5109 | size = KB_RLC_UCODE_SIZE; |
| 5110 | break; |
| 5111 | } |
| 5112 | |
| 5113 | cik_rlc_stop(rdev); |
| 5114 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5115 | /* disable CG */ |
| 5116 | tmp = RREG32(RLC_CGCG_CGLS_CTRL) & 0xfffffffc; |
| 5117 | WREG32(RLC_CGCG_CGLS_CTRL, tmp); |
| 5118 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5119 | si_rlc_reset(rdev); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5120 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5121 | cik_init_pg(rdev); |
| 5122 | |
| 5123 | cik_init_cg(rdev); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5124 | |
| 5125 | WREG32(RLC_LB_CNTR_INIT, 0); |
| 5126 | WREG32(RLC_LB_CNTR_MAX, 0x00008000); |
| 5127 | |
| 5128 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5129 | WREG32(RLC_LB_INIT_CU_MASK, 0xffffffff); |
| 5130 | WREG32(RLC_LB_PARAMS, 0x00600408); |
| 5131 | WREG32(RLC_LB_CNTL, 0x80000004); |
| 5132 | |
| 5133 | WREG32(RLC_MC_CNTL, 0); |
| 5134 | WREG32(RLC_UCODE_CNTL, 0); |
| 5135 | |
| 5136 | fw_data = (const __be32 *)rdev->rlc_fw->data; |
| 5137 | WREG32(RLC_GPM_UCODE_ADDR, 0); |
| 5138 | for (i = 0; i < size; i++) |
| 5139 | WREG32(RLC_GPM_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 5140 | WREG32(RLC_GPM_UCODE_ADDR, 0); |
| 5141 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5142 | /* XXX - find out what chips support lbpw */ |
| 5143 | cik_enable_lbpw(rdev, false); |
| 5144 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5145 | if (rdev->family == CHIP_BONAIRE) |
| 5146 | WREG32(RLC_DRIVER_DMA_STATUS, 0); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5147 | |
| 5148 | cik_rlc_start(rdev); |
| 5149 | |
| 5150 | return 0; |
| 5151 | } |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 5152 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5153 | static void cik_enable_cgcg(struct radeon_device *rdev, bool enable) |
| 5154 | { |
| 5155 | u32 data, orig, tmp, tmp2; |
| 5156 | |
| 5157 | orig = data = RREG32(RLC_CGCG_CGLS_CTRL); |
| 5158 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5159 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CGCG)) { |
Alex Deucher | ddc76ff | 2013-08-12 17:25:26 -0400 | [diff] [blame] | 5160 | cik_enable_gui_idle_interrupt(rdev, true); |
| 5161 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5162 | tmp = cik_halt_rlc(rdev); |
| 5163 | |
| 5164 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5165 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
| 5166 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
| 5167 | tmp2 = BPM_ADDR_MASK | CGCG_OVERRIDE_0 | CGLS_ENABLE; |
| 5168 | WREG32(RLC_SERDES_WR_CTRL, tmp2); |
| 5169 | |
| 5170 | cik_update_rlc(rdev, tmp); |
| 5171 | |
| 5172 | data |= CGCG_EN | CGLS_EN; |
| 5173 | } else { |
Alex Deucher | ddc76ff | 2013-08-12 17:25:26 -0400 | [diff] [blame] | 5174 | cik_enable_gui_idle_interrupt(rdev, false); |
| 5175 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5176 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5177 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5178 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5179 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5180 | |
| 5181 | data &= ~(CGCG_EN | CGLS_EN); |
| 5182 | } |
| 5183 | |
| 5184 | if (orig != data) |
| 5185 | WREG32(RLC_CGCG_CGLS_CTRL, data); |
| 5186 | |
| 5187 | } |
| 5188 | |
| 5189 | static void cik_enable_mgcg(struct radeon_device *rdev, bool enable) |
| 5190 | { |
| 5191 | u32 data, orig, tmp = 0; |
| 5192 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5193 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_MGCG)) { |
| 5194 | if (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_MGLS) { |
| 5195 | if (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CP_LS) { |
| 5196 | orig = data = RREG32(CP_MEM_SLP_CNTL); |
| 5197 | data |= CP_MEM_LS_EN; |
| 5198 | if (orig != data) |
| 5199 | WREG32(CP_MEM_SLP_CNTL, data); |
| 5200 | } |
| 5201 | } |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5202 | |
| 5203 | orig = data = RREG32(RLC_CGTT_MGCG_OVERRIDE); |
| 5204 | data &= 0xfffffffd; |
| 5205 | if (orig != data) |
| 5206 | WREG32(RLC_CGTT_MGCG_OVERRIDE, data); |
| 5207 | |
| 5208 | tmp = cik_halt_rlc(rdev); |
| 5209 | |
| 5210 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5211 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
| 5212 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
| 5213 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_0; |
| 5214 | WREG32(RLC_SERDES_WR_CTRL, data); |
| 5215 | |
| 5216 | cik_update_rlc(rdev, tmp); |
| 5217 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5218 | if (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CGTS) { |
| 5219 | orig = data = RREG32(CGTS_SM_CTRL_REG); |
| 5220 | data &= ~SM_MODE_MASK; |
| 5221 | data |= SM_MODE(0x2); |
| 5222 | data |= SM_MODE_ENABLE; |
| 5223 | data &= ~CGTS_OVERRIDE; |
| 5224 | if ((rdev->cg_flags & RADEON_CG_SUPPORT_GFX_MGLS) && |
| 5225 | (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CGTS_LS)) |
| 5226 | data &= ~CGTS_LS_OVERRIDE; |
| 5227 | data &= ~ON_MONITOR_ADD_MASK; |
| 5228 | data |= ON_MONITOR_ADD_EN; |
| 5229 | data |= ON_MONITOR_ADD(0x96); |
| 5230 | if (orig != data) |
| 5231 | WREG32(CGTS_SM_CTRL_REG, data); |
| 5232 | } |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5233 | } else { |
| 5234 | orig = data = RREG32(RLC_CGTT_MGCG_OVERRIDE); |
| 5235 | data |= 0x00000002; |
| 5236 | if (orig != data) |
| 5237 | WREG32(RLC_CGTT_MGCG_OVERRIDE, data); |
| 5238 | |
| 5239 | data = RREG32(RLC_MEM_SLP_CNTL); |
| 5240 | if (data & RLC_MEM_LS_EN) { |
| 5241 | data &= ~RLC_MEM_LS_EN; |
| 5242 | WREG32(RLC_MEM_SLP_CNTL, data); |
| 5243 | } |
| 5244 | |
| 5245 | data = RREG32(CP_MEM_SLP_CNTL); |
| 5246 | if (data & CP_MEM_LS_EN) { |
| 5247 | data &= ~CP_MEM_LS_EN; |
| 5248 | WREG32(CP_MEM_SLP_CNTL, data); |
| 5249 | } |
| 5250 | |
| 5251 | orig = data = RREG32(CGTS_SM_CTRL_REG); |
| 5252 | data |= CGTS_OVERRIDE | CGTS_LS_OVERRIDE; |
| 5253 | if (orig != data) |
| 5254 | WREG32(CGTS_SM_CTRL_REG, data); |
| 5255 | |
| 5256 | tmp = cik_halt_rlc(rdev); |
| 5257 | |
| 5258 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5259 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
| 5260 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
| 5261 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_1; |
| 5262 | WREG32(RLC_SERDES_WR_CTRL, data); |
| 5263 | |
| 5264 | cik_update_rlc(rdev, tmp); |
| 5265 | } |
| 5266 | } |
| 5267 | |
| 5268 | static const u32 mc_cg_registers[] = |
| 5269 | { |
| 5270 | MC_HUB_MISC_HUB_CG, |
| 5271 | MC_HUB_MISC_SIP_CG, |
| 5272 | MC_HUB_MISC_VM_CG, |
| 5273 | MC_XPB_CLK_GAT, |
| 5274 | ATC_MISC_CG, |
| 5275 | MC_CITF_MISC_WR_CG, |
| 5276 | MC_CITF_MISC_RD_CG, |
| 5277 | MC_CITF_MISC_VM_CG, |
| 5278 | VM_L2_CG, |
| 5279 | }; |
| 5280 | |
| 5281 | static void cik_enable_mc_ls(struct radeon_device *rdev, |
| 5282 | bool enable) |
| 5283 | { |
| 5284 | int i; |
| 5285 | u32 orig, data; |
| 5286 | |
| 5287 | for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) { |
| 5288 | orig = data = RREG32(mc_cg_registers[i]); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5289 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_MC_LS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5290 | data |= MC_LS_ENABLE; |
| 5291 | else |
| 5292 | data &= ~MC_LS_ENABLE; |
| 5293 | if (data != orig) |
| 5294 | WREG32(mc_cg_registers[i], data); |
| 5295 | } |
| 5296 | } |
| 5297 | |
| 5298 | static void cik_enable_mc_mgcg(struct radeon_device *rdev, |
| 5299 | bool enable) |
| 5300 | { |
| 5301 | int i; |
| 5302 | u32 orig, data; |
| 5303 | |
| 5304 | for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) { |
| 5305 | orig = data = RREG32(mc_cg_registers[i]); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5306 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_MC_MGCG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5307 | data |= MC_CG_ENABLE; |
| 5308 | else |
| 5309 | data &= ~MC_CG_ENABLE; |
| 5310 | if (data != orig) |
| 5311 | WREG32(mc_cg_registers[i], data); |
| 5312 | } |
| 5313 | } |
| 5314 | |
| 5315 | static void cik_enable_sdma_mgcg(struct radeon_device *rdev, |
| 5316 | bool enable) |
| 5317 | { |
| 5318 | u32 orig, data; |
| 5319 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5320 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_SDMA_MGCG)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5321 | WREG32(SDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, 0x00000100); |
| 5322 | WREG32(SDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, 0x00000100); |
| 5323 | } else { |
| 5324 | orig = data = RREG32(SDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET); |
| 5325 | data |= 0xff000000; |
| 5326 | if (data != orig) |
| 5327 | WREG32(SDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, data); |
| 5328 | |
| 5329 | orig = data = RREG32(SDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET); |
| 5330 | data |= 0xff000000; |
| 5331 | if (data != orig) |
| 5332 | WREG32(SDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, data); |
| 5333 | } |
| 5334 | } |
| 5335 | |
| 5336 | static void cik_enable_sdma_mgls(struct radeon_device *rdev, |
| 5337 | bool enable) |
| 5338 | { |
| 5339 | u32 orig, data; |
| 5340 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5341 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_SDMA_LS)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5342 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET); |
| 5343 | data |= 0x100; |
| 5344 | if (orig != data) |
| 5345 | WREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET, data); |
| 5346 | |
| 5347 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET); |
| 5348 | data |= 0x100; |
| 5349 | if (orig != data) |
| 5350 | WREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET, data); |
| 5351 | } else { |
| 5352 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET); |
| 5353 | data &= ~0x100; |
| 5354 | if (orig != data) |
| 5355 | WREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET, data); |
| 5356 | |
| 5357 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET); |
| 5358 | data &= ~0x100; |
| 5359 | if (orig != data) |
| 5360 | WREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET, data); |
| 5361 | } |
| 5362 | } |
| 5363 | |
| 5364 | static void cik_enable_uvd_mgcg(struct radeon_device *rdev, |
| 5365 | bool enable) |
| 5366 | { |
| 5367 | u32 orig, data; |
| 5368 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5369 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_UVD_MGCG)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5370 | data = RREG32_UVD_CTX(UVD_CGC_MEM_CTRL); |
| 5371 | data = 0xfff; |
| 5372 | WREG32_UVD_CTX(UVD_CGC_MEM_CTRL, data); |
| 5373 | |
| 5374 | orig = data = RREG32(UVD_CGC_CTRL); |
| 5375 | data |= DCM; |
| 5376 | if (orig != data) |
| 5377 | WREG32(UVD_CGC_CTRL, data); |
| 5378 | } else { |
| 5379 | data = RREG32_UVD_CTX(UVD_CGC_MEM_CTRL); |
| 5380 | data &= ~0xfff; |
| 5381 | WREG32_UVD_CTX(UVD_CGC_MEM_CTRL, data); |
| 5382 | |
| 5383 | orig = data = RREG32(UVD_CGC_CTRL); |
| 5384 | data &= ~DCM; |
| 5385 | if (orig != data) |
| 5386 | WREG32(UVD_CGC_CTRL, data); |
| 5387 | } |
| 5388 | } |
| 5389 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5390 | static void cik_enable_bif_mgls(struct radeon_device *rdev, |
| 5391 | bool enable) |
| 5392 | { |
| 5393 | u32 orig, data; |
| 5394 | |
| 5395 | orig = data = RREG32_PCIE_PORT(PCIE_CNTL2); |
| 5396 | |
| 5397 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_BIF_LS)) |
| 5398 | data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | |
| 5399 | REPLAY_MEM_LS_EN | SLV_MEM_AGGRESSIVE_LS_EN; |
| 5400 | else |
| 5401 | data &= ~(SLV_MEM_LS_EN | MST_MEM_LS_EN | |
| 5402 | REPLAY_MEM_LS_EN | SLV_MEM_AGGRESSIVE_LS_EN); |
| 5403 | |
| 5404 | if (orig != data) |
| 5405 | WREG32_PCIE_PORT(PCIE_CNTL2, data); |
| 5406 | } |
| 5407 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5408 | static void cik_enable_hdp_mgcg(struct radeon_device *rdev, |
| 5409 | bool enable) |
| 5410 | { |
| 5411 | u32 orig, data; |
| 5412 | |
| 5413 | orig = data = RREG32(HDP_HOST_PATH_CNTL); |
| 5414 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5415 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_HDP_MGCG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5416 | data &= ~CLOCK_GATING_DIS; |
| 5417 | else |
| 5418 | data |= CLOCK_GATING_DIS; |
| 5419 | |
| 5420 | if (orig != data) |
| 5421 | WREG32(HDP_HOST_PATH_CNTL, data); |
| 5422 | } |
| 5423 | |
| 5424 | static void cik_enable_hdp_ls(struct radeon_device *rdev, |
| 5425 | bool enable) |
| 5426 | { |
| 5427 | u32 orig, data; |
| 5428 | |
| 5429 | orig = data = RREG32(HDP_MEM_POWER_LS); |
| 5430 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5431 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_HDP_LS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5432 | data |= HDP_LS_ENABLE; |
| 5433 | else |
| 5434 | data &= ~HDP_LS_ENABLE; |
| 5435 | |
| 5436 | if (orig != data) |
| 5437 | WREG32(HDP_MEM_POWER_LS, data); |
| 5438 | } |
| 5439 | |
| 5440 | void cik_update_cg(struct radeon_device *rdev, |
| 5441 | u32 block, bool enable) |
| 5442 | { |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5443 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5444 | if (block & RADEON_CG_BLOCK_GFX) { |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5445 | cik_enable_gui_idle_interrupt(rdev, false); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5446 | /* order matters! */ |
| 5447 | if (enable) { |
| 5448 | cik_enable_mgcg(rdev, true); |
| 5449 | cik_enable_cgcg(rdev, true); |
| 5450 | } else { |
| 5451 | cik_enable_cgcg(rdev, false); |
| 5452 | cik_enable_mgcg(rdev, false); |
| 5453 | } |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5454 | cik_enable_gui_idle_interrupt(rdev, true); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5455 | } |
| 5456 | |
| 5457 | if (block & RADEON_CG_BLOCK_MC) { |
| 5458 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 5459 | cik_enable_mc_mgcg(rdev, enable); |
| 5460 | cik_enable_mc_ls(rdev, enable); |
| 5461 | } |
| 5462 | } |
| 5463 | |
| 5464 | if (block & RADEON_CG_BLOCK_SDMA) { |
| 5465 | cik_enable_sdma_mgcg(rdev, enable); |
| 5466 | cik_enable_sdma_mgls(rdev, enable); |
| 5467 | } |
| 5468 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5469 | if (block & RADEON_CG_BLOCK_BIF) { |
| 5470 | cik_enable_bif_mgls(rdev, enable); |
| 5471 | } |
| 5472 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5473 | if (block & RADEON_CG_BLOCK_UVD) { |
| 5474 | if (rdev->has_uvd) |
| 5475 | cik_enable_uvd_mgcg(rdev, enable); |
| 5476 | } |
| 5477 | |
| 5478 | if (block & RADEON_CG_BLOCK_HDP) { |
| 5479 | cik_enable_hdp_mgcg(rdev, enable); |
| 5480 | cik_enable_hdp_ls(rdev, enable); |
| 5481 | } |
| 5482 | } |
| 5483 | |
| 5484 | static void cik_init_cg(struct radeon_device *rdev) |
| 5485 | { |
| 5486 | |
Alex Deucher | ddc76ff | 2013-08-12 17:25:26 -0400 | [diff] [blame] | 5487 | cik_update_cg(rdev, RADEON_CG_BLOCK_GFX, true); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5488 | |
| 5489 | if (rdev->has_uvd) |
| 5490 | si_init_uvd_internal_cg(rdev); |
| 5491 | |
| 5492 | cik_update_cg(rdev, (RADEON_CG_BLOCK_MC | |
| 5493 | RADEON_CG_BLOCK_SDMA | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5494 | RADEON_CG_BLOCK_BIF | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5495 | RADEON_CG_BLOCK_UVD | |
| 5496 | RADEON_CG_BLOCK_HDP), true); |
| 5497 | } |
| 5498 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5499 | static void cik_fini_cg(struct radeon_device *rdev) |
| 5500 | { |
| 5501 | cik_update_cg(rdev, (RADEON_CG_BLOCK_MC | |
| 5502 | RADEON_CG_BLOCK_SDMA | |
| 5503 | RADEON_CG_BLOCK_BIF | |
| 5504 | RADEON_CG_BLOCK_UVD | |
| 5505 | RADEON_CG_BLOCK_HDP), false); |
| 5506 | |
| 5507 | cik_update_cg(rdev, RADEON_CG_BLOCK_GFX, false); |
| 5508 | } |
| 5509 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5510 | static void cik_enable_sck_slowdown_on_pu(struct radeon_device *rdev, |
| 5511 | bool enable) |
| 5512 | { |
| 5513 | u32 data, orig; |
| 5514 | |
| 5515 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5516 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_RLC_SMU_HS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5517 | data |= SMU_CLK_SLOWDOWN_ON_PU_ENABLE; |
| 5518 | else |
| 5519 | data &= ~SMU_CLK_SLOWDOWN_ON_PU_ENABLE; |
| 5520 | if (orig != data) |
| 5521 | WREG32(RLC_PG_CNTL, data); |
| 5522 | } |
| 5523 | |
| 5524 | static void cik_enable_sck_slowdown_on_pd(struct radeon_device *rdev, |
| 5525 | bool enable) |
| 5526 | { |
| 5527 | u32 data, orig; |
| 5528 | |
| 5529 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5530 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_RLC_SMU_HS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5531 | data |= SMU_CLK_SLOWDOWN_ON_PD_ENABLE; |
| 5532 | else |
| 5533 | data &= ~SMU_CLK_SLOWDOWN_ON_PD_ENABLE; |
| 5534 | if (orig != data) |
| 5535 | WREG32(RLC_PG_CNTL, data); |
| 5536 | } |
| 5537 | |
| 5538 | static void cik_enable_cp_pg(struct radeon_device *rdev, bool enable) |
| 5539 | { |
| 5540 | u32 data, orig; |
| 5541 | |
| 5542 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5543 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_CP)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5544 | data &= ~DISABLE_CP_PG; |
| 5545 | else |
| 5546 | data |= DISABLE_CP_PG; |
| 5547 | if (orig != data) |
| 5548 | WREG32(RLC_PG_CNTL, data); |
| 5549 | } |
| 5550 | |
| 5551 | static void cik_enable_gds_pg(struct radeon_device *rdev, bool enable) |
| 5552 | { |
| 5553 | u32 data, orig; |
| 5554 | |
| 5555 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5556 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GDS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5557 | data &= ~DISABLE_GDS_PG; |
| 5558 | else |
| 5559 | data |= DISABLE_GDS_PG; |
| 5560 | if (orig != data) |
| 5561 | WREG32(RLC_PG_CNTL, data); |
| 5562 | } |
| 5563 | |
| 5564 | #define CP_ME_TABLE_SIZE 96 |
| 5565 | #define CP_ME_TABLE_OFFSET 2048 |
| 5566 | #define CP_MEC_TABLE_OFFSET 4096 |
| 5567 | |
| 5568 | void cik_init_cp_pg_table(struct radeon_device *rdev) |
| 5569 | { |
| 5570 | const __be32 *fw_data; |
| 5571 | volatile u32 *dst_ptr; |
| 5572 | int me, i, max_me = 4; |
| 5573 | u32 bo_offset = 0; |
| 5574 | u32 table_offset; |
| 5575 | |
| 5576 | if (rdev->family == CHIP_KAVERI) |
| 5577 | max_me = 5; |
| 5578 | |
| 5579 | if (rdev->rlc.cp_table_ptr == NULL) |
| 5580 | return; |
| 5581 | |
| 5582 | /* write the cp table buffer */ |
| 5583 | dst_ptr = rdev->rlc.cp_table_ptr; |
| 5584 | for (me = 0; me < max_me; me++) { |
| 5585 | if (me == 0) { |
| 5586 | fw_data = (const __be32 *)rdev->ce_fw->data; |
| 5587 | table_offset = CP_ME_TABLE_OFFSET; |
| 5588 | } else if (me == 1) { |
| 5589 | fw_data = (const __be32 *)rdev->pfp_fw->data; |
| 5590 | table_offset = CP_ME_TABLE_OFFSET; |
| 5591 | } else if (me == 2) { |
| 5592 | fw_data = (const __be32 *)rdev->me_fw->data; |
| 5593 | table_offset = CP_ME_TABLE_OFFSET; |
| 5594 | } else { |
| 5595 | fw_data = (const __be32 *)rdev->mec_fw->data; |
| 5596 | table_offset = CP_MEC_TABLE_OFFSET; |
| 5597 | } |
| 5598 | |
| 5599 | for (i = 0; i < CP_ME_TABLE_SIZE; i ++) { |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5600 | dst_ptr[bo_offset + i] = cpu_to_le32(be32_to_cpu(fw_data[table_offset + i])); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5601 | } |
| 5602 | bo_offset += CP_ME_TABLE_SIZE; |
| 5603 | } |
| 5604 | } |
| 5605 | |
| 5606 | static void cik_enable_gfx_cgpg(struct radeon_device *rdev, |
| 5607 | bool enable) |
| 5608 | { |
| 5609 | u32 data, orig; |
| 5610 | |
Alex Deucher | 2b19d17 | 2013-09-04 16:58:29 -0400 | [diff] [blame] | 5611 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5612 | orig = data = RREG32(RLC_PG_CNTL); |
| 5613 | data |= GFX_PG_ENABLE; |
| 5614 | if (orig != data) |
| 5615 | WREG32(RLC_PG_CNTL, data); |
| 5616 | |
| 5617 | orig = data = RREG32(RLC_AUTO_PG_CTRL); |
| 5618 | data |= AUTO_PG_EN; |
| 5619 | if (orig != data) |
| 5620 | WREG32(RLC_AUTO_PG_CTRL, data); |
| 5621 | } else { |
| 5622 | orig = data = RREG32(RLC_PG_CNTL); |
| 5623 | data &= ~GFX_PG_ENABLE; |
| 5624 | if (orig != data) |
| 5625 | WREG32(RLC_PG_CNTL, data); |
| 5626 | |
| 5627 | orig = data = RREG32(RLC_AUTO_PG_CTRL); |
| 5628 | data &= ~AUTO_PG_EN; |
| 5629 | if (orig != data) |
| 5630 | WREG32(RLC_AUTO_PG_CTRL, data); |
| 5631 | |
| 5632 | data = RREG32(DB_RENDER_CONTROL); |
| 5633 | } |
| 5634 | } |
| 5635 | |
| 5636 | static u32 cik_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh) |
| 5637 | { |
| 5638 | u32 mask = 0, tmp, tmp1; |
| 5639 | int i; |
| 5640 | |
| 5641 | cik_select_se_sh(rdev, se, sh); |
| 5642 | tmp = RREG32(CC_GC_SHADER_ARRAY_CONFIG); |
| 5643 | tmp1 = RREG32(GC_USER_SHADER_ARRAY_CONFIG); |
| 5644 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5645 | |
| 5646 | tmp &= 0xffff0000; |
| 5647 | |
| 5648 | tmp |= tmp1; |
| 5649 | tmp >>= 16; |
| 5650 | |
| 5651 | for (i = 0; i < rdev->config.cik.max_cu_per_sh; i ++) { |
| 5652 | mask <<= 1; |
| 5653 | mask |= 1; |
| 5654 | } |
| 5655 | |
| 5656 | return (~tmp) & mask; |
| 5657 | } |
| 5658 | |
| 5659 | static void cik_init_ao_cu_mask(struct radeon_device *rdev) |
| 5660 | { |
| 5661 | u32 i, j, k, active_cu_number = 0; |
| 5662 | u32 mask, counter, cu_bitmap; |
| 5663 | u32 tmp = 0; |
| 5664 | |
| 5665 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { |
| 5666 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { |
| 5667 | mask = 1; |
| 5668 | cu_bitmap = 0; |
| 5669 | counter = 0; |
| 5670 | for (k = 0; k < rdev->config.cik.max_cu_per_sh; k ++) { |
| 5671 | if (cik_get_cu_active_bitmap(rdev, i, j) & mask) { |
| 5672 | if (counter < 2) |
| 5673 | cu_bitmap |= mask; |
| 5674 | counter ++; |
| 5675 | } |
| 5676 | mask <<= 1; |
| 5677 | } |
| 5678 | |
| 5679 | active_cu_number += counter; |
| 5680 | tmp |= (cu_bitmap << (i * 16 + j * 8)); |
| 5681 | } |
| 5682 | } |
| 5683 | |
| 5684 | WREG32(RLC_PG_AO_CU_MASK, tmp); |
| 5685 | |
| 5686 | tmp = RREG32(RLC_MAX_PG_CU); |
| 5687 | tmp &= ~MAX_PU_CU_MASK; |
| 5688 | tmp |= MAX_PU_CU(active_cu_number); |
| 5689 | WREG32(RLC_MAX_PG_CU, tmp); |
| 5690 | } |
| 5691 | |
| 5692 | static void cik_enable_gfx_static_mgpg(struct radeon_device *rdev, |
| 5693 | bool enable) |
| 5694 | { |
| 5695 | u32 data, orig; |
| 5696 | |
| 5697 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5698 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_SMG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5699 | data |= STATIC_PER_CU_PG_ENABLE; |
| 5700 | else |
| 5701 | data &= ~STATIC_PER_CU_PG_ENABLE; |
| 5702 | if (orig != data) |
| 5703 | WREG32(RLC_PG_CNTL, data); |
| 5704 | } |
| 5705 | |
| 5706 | static void cik_enable_gfx_dynamic_mgpg(struct radeon_device *rdev, |
| 5707 | bool enable) |
| 5708 | { |
| 5709 | u32 data, orig; |
| 5710 | |
| 5711 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5712 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_DMG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5713 | data |= DYN_PER_CU_PG_ENABLE; |
| 5714 | else |
| 5715 | data &= ~DYN_PER_CU_PG_ENABLE; |
| 5716 | if (orig != data) |
| 5717 | WREG32(RLC_PG_CNTL, data); |
| 5718 | } |
| 5719 | |
| 5720 | #define RLC_SAVE_AND_RESTORE_STARTING_OFFSET 0x90 |
| 5721 | #define RLC_CLEAR_STATE_DESCRIPTOR_OFFSET 0x3D |
| 5722 | |
| 5723 | static void cik_init_gfx_cgpg(struct radeon_device *rdev) |
| 5724 | { |
| 5725 | u32 data, orig; |
| 5726 | u32 i; |
| 5727 | |
| 5728 | if (rdev->rlc.cs_data) { |
| 5729 | WREG32(RLC_GPM_SCRATCH_ADDR, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET); |
| 5730 | WREG32(RLC_GPM_SCRATCH_DATA, upper_32_bits(rdev->rlc.clear_state_gpu_addr)); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5731 | WREG32(RLC_GPM_SCRATCH_DATA, lower_32_bits(rdev->rlc.clear_state_gpu_addr)); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5732 | WREG32(RLC_GPM_SCRATCH_DATA, rdev->rlc.clear_state_size); |
| 5733 | } else { |
| 5734 | WREG32(RLC_GPM_SCRATCH_ADDR, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET); |
| 5735 | for (i = 0; i < 3; i++) |
| 5736 | WREG32(RLC_GPM_SCRATCH_DATA, 0); |
| 5737 | } |
| 5738 | if (rdev->rlc.reg_list) { |
| 5739 | WREG32(RLC_GPM_SCRATCH_ADDR, RLC_SAVE_AND_RESTORE_STARTING_OFFSET); |
| 5740 | for (i = 0; i < rdev->rlc.reg_list_size; i++) |
| 5741 | WREG32(RLC_GPM_SCRATCH_DATA, rdev->rlc.reg_list[i]); |
| 5742 | } |
| 5743 | |
| 5744 | orig = data = RREG32(RLC_PG_CNTL); |
| 5745 | data |= GFX_PG_SRC; |
| 5746 | if (orig != data) |
| 5747 | WREG32(RLC_PG_CNTL, data); |
| 5748 | |
| 5749 | WREG32(RLC_SAVE_AND_RESTORE_BASE, rdev->rlc.save_restore_gpu_addr >> 8); |
| 5750 | WREG32(RLC_CP_TABLE_RESTORE, rdev->rlc.cp_table_gpu_addr >> 8); |
| 5751 | |
| 5752 | data = RREG32(CP_RB_WPTR_POLL_CNTL); |
| 5753 | data &= ~IDLE_POLL_COUNT_MASK; |
| 5754 | data |= IDLE_POLL_COUNT(0x60); |
| 5755 | WREG32(CP_RB_WPTR_POLL_CNTL, data); |
| 5756 | |
| 5757 | data = 0x10101010; |
| 5758 | WREG32(RLC_PG_DELAY, data); |
| 5759 | |
| 5760 | data = RREG32(RLC_PG_DELAY_2); |
| 5761 | data &= ~0xff; |
| 5762 | data |= 0x3; |
| 5763 | WREG32(RLC_PG_DELAY_2, data); |
| 5764 | |
| 5765 | data = RREG32(RLC_AUTO_PG_CTRL); |
| 5766 | data &= ~GRBM_REG_SGIT_MASK; |
| 5767 | data |= GRBM_REG_SGIT(0x700); |
| 5768 | WREG32(RLC_AUTO_PG_CTRL, data); |
| 5769 | |
| 5770 | } |
| 5771 | |
| 5772 | static void cik_update_gfx_pg(struct radeon_device *rdev, bool enable) |
| 5773 | { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5774 | cik_enable_gfx_cgpg(rdev, enable); |
| 5775 | cik_enable_gfx_static_mgpg(rdev, enable); |
| 5776 | cik_enable_gfx_dynamic_mgpg(rdev, enable); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5777 | } |
| 5778 | |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5779 | u32 cik_get_csb_size(struct radeon_device *rdev) |
| 5780 | { |
| 5781 | u32 count = 0; |
| 5782 | const struct cs_section_def *sect = NULL; |
| 5783 | const struct cs_extent_def *ext = NULL; |
| 5784 | |
| 5785 | if (rdev->rlc.cs_data == NULL) |
| 5786 | return 0; |
| 5787 | |
| 5788 | /* begin clear state */ |
| 5789 | count += 2; |
| 5790 | /* context control state */ |
| 5791 | count += 3; |
| 5792 | |
| 5793 | for (sect = rdev->rlc.cs_data; sect->section != NULL; ++sect) { |
| 5794 | for (ext = sect->section; ext->extent != NULL; ++ext) { |
| 5795 | if (sect->id == SECT_CONTEXT) |
| 5796 | count += 2 + ext->reg_count; |
| 5797 | else |
| 5798 | return 0; |
| 5799 | } |
| 5800 | } |
| 5801 | /* pa_sc_raster_config/pa_sc_raster_config1 */ |
| 5802 | count += 4; |
| 5803 | /* end clear state */ |
| 5804 | count += 2; |
| 5805 | /* clear state */ |
| 5806 | count += 2; |
| 5807 | |
| 5808 | return count; |
| 5809 | } |
| 5810 | |
| 5811 | void cik_get_csb_buffer(struct radeon_device *rdev, volatile u32 *buffer) |
| 5812 | { |
| 5813 | u32 count = 0, i; |
| 5814 | const struct cs_section_def *sect = NULL; |
| 5815 | const struct cs_extent_def *ext = NULL; |
| 5816 | |
| 5817 | if (rdev->rlc.cs_data == NULL) |
| 5818 | return; |
| 5819 | if (buffer == NULL) |
| 5820 | return; |
| 5821 | |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5822 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 5823 | buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5824 | |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5825 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL, 1)); |
| 5826 | buffer[count++] = cpu_to_le32(0x80000000); |
| 5827 | buffer[count++] = cpu_to_le32(0x80000000); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5828 | |
| 5829 | for (sect = rdev->rlc.cs_data; sect->section != NULL; ++sect) { |
| 5830 | for (ext = sect->section; ext->extent != NULL; ++ext) { |
| 5831 | if (sect->id == SECT_CONTEXT) { |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5832 | buffer[count++] = |
| 5833 | cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); |
| 5834 | buffer[count++] = cpu_to_le32(ext->reg_index - 0xa000); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5835 | for (i = 0; i < ext->reg_count; i++) |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5836 | buffer[count++] = cpu_to_le32(ext->extent[i]); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5837 | } else { |
| 5838 | return; |
| 5839 | } |
| 5840 | } |
| 5841 | } |
| 5842 | |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5843 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, 2)); |
| 5844 | buffer[count++] = cpu_to_le32(PA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5845 | switch (rdev->family) { |
| 5846 | case CHIP_BONAIRE: |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5847 | buffer[count++] = cpu_to_le32(0x16000012); |
| 5848 | buffer[count++] = cpu_to_le32(0x00000000); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5849 | break; |
| 5850 | case CHIP_KAVERI: |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5851 | buffer[count++] = cpu_to_le32(0x00000000); /* XXX */ |
| 5852 | buffer[count++] = cpu_to_le32(0x00000000); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5853 | break; |
| 5854 | case CHIP_KABINI: |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5855 | buffer[count++] = cpu_to_le32(0x00000000); /* XXX */ |
| 5856 | buffer[count++] = cpu_to_le32(0x00000000); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5857 | break; |
| 5858 | default: |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5859 | buffer[count++] = cpu_to_le32(0x00000000); |
| 5860 | buffer[count++] = cpu_to_le32(0x00000000); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5861 | break; |
| 5862 | } |
| 5863 | |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5864 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 5865 | buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5866 | |
Alex Deucher | 6ba81e5 | 2013-10-23 18:27:10 -0400 | [diff] [blame] | 5867 | buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0)); |
| 5868 | buffer[count++] = cpu_to_le32(0); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5869 | } |
| 5870 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5871 | static void cik_init_pg(struct radeon_device *rdev) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5872 | { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5873 | if (rdev->pg_flags) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5874 | cik_enable_sck_slowdown_on_pu(rdev, true); |
| 5875 | cik_enable_sck_slowdown_on_pd(rdev, true); |
Alex Deucher | 2b19d17 | 2013-09-04 16:58:29 -0400 | [diff] [blame] | 5876 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5877 | cik_init_gfx_cgpg(rdev); |
| 5878 | cik_enable_cp_pg(rdev, true); |
| 5879 | cik_enable_gds_pg(rdev, true); |
| 5880 | } |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5881 | cik_init_ao_cu_mask(rdev); |
| 5882 | cik_update_gfx_pg(rdev, true); |
| 5883 | } |
| 5884 | } |
| 5885 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5886 | static void cik_fini_pg(struct radeon_device *rdev) |
| 5887 | { |
| 5888 | if (rdev->pg_flags) { |
| 5889 | cik_update_gfx_pg(rdev, false); |
Alex Deucher | 2b19d17 | 2013-09-04 16:58:29 -0400 | [diff] [blame] | 5890 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5891 | cik_enable_cp_pg(rdev, false); |
| 5892 | cik_enable_gds_pg(rdev, false); |
| 5893 | } |
| 5894 | } |
| 5895 | } |
| 5896 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 5897 | /* |
| 5898 | * Interrupts |
| 5899 | * Starting with r6xx, interrupts are handled via a ring buffer. |
| 5900 | * Ring buffers are areas of GPU accessible memory that the GPU |
| 5901 | * writes interrupt vectors into and the host reads vectors out of. |
| 5902 | * There is a rptr (read pointer) that determines where the |
| 5903 | * host is currently reading, and a wptr (write pointer) |
| 5904 | * which determines where the GPU has written. When the |
| 5905 | * pointers are equal, the ring is idle. When the GPU |
| 5906 | * writes vectors to the ring buffer, it increments the |
| 5907 | * wptr. When there is an interrupt, the host then starts |
| 5908 | * fetching commands and processing them until the pointers are |
| 5909 | * equal again at which point it updates the rptr. |
| 5910 | */ |
| 5911 | |
| 5912 | /** |
| 5913 | * cik_enable_interrupts - Enable the interrupt ring buffer |
| 5914 | * |
| 5915 | * @rdev: radeon_device pointer |
| 5916 | * |
| 5917 | * Enable the interrupt ring buffer (CIK). |
| 5918 | */ |
| 5919 | static void cik_enable_interrupts(struct radeon_device *rdev) |
| 5920 | { |
| 5921 | u32 ih_cntl = RREG32(IH_CNTL); |
| 5922 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
| 5923 | |
| 5924 | ih_cntl |= ENABLE_INTR; |
| 5925 | ih_rb_cntl |= IH_RB_ENABLE; |
| 5926 | WREG32(IH_CNTL, ih_cntl); |
| 5927 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 5928 | rdev->ih.enabled = true; |
| 5929 | } |
| 5930 | |
| 5931 | /** |
| 5932 | * cik_disable_interrupts - Disable the interrupt ring buffer |
| 5933 | * |
| 5934 | * @rdev: radeon_device pointer |
| 5935 | * |
| 5936 | * Disable the interrupt ring buffer (CIK). |
| 5937 | */ |
| 5938 | static void cik_disable_interrupts(struct radeon_device *rdev) |
| 5939 | { |
| 5940 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
| 5941 | u32 ih_cntl = RREG32(IH_CNTL); |
| 5942 | |
| 5943 | ih_rb_cntl &= ~IH_RB_ENABLE; |
| 5944 | ih_cntl &= ~ENABLE_INTR; |
| 5945 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 5946 | WREG32(IH_CNTL, ih_cntl); |
| 5947 | /* set rptr, wptr to 0 */ |
| 5948 | WREG32(IH_RB_RPTR, 0); |
| 5949 | WREG32(IH_RB_WPTR, 0); |
| 5950 | rdev->ih.enabled = false; |
| 5951 | rdev->ih.rptr = 0; |
| 5952 | } |
| 5953 | |
| 5954 | /** |
| 5955 | * cik_disable_interrupt_state - Disable all interrupt sources |
| 5956 | * |
| 5957 | * @rdev: radeon_device pointer |
| 5958 | * |
| 5959 | * Clear all interrupt enable bits used by the driver (CIK). |
| 5960 | */ |
| 5961 | static void cik_disable_interrupt_state(struct radeon_device *rdev) |
| 5962 | { |
| 5963 | u32 tmp; |
| 5964 | |
| 5965 | /* gfx ring */ |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5966 | tmp = RREG32(CP_INT_CNTL_RING0) & |
| 5967 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 5968 | WREG32(CP_INT_CNTL_RING0, tmp); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 5969 | /* sdma */ |
| 5970 | tmp = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 5971 | WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, tmp); |
| 5972 | tmp = RREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 5973 | WREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET, tmp); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 5974 | /* compute queues */ |
| 5975 | WREG32(CP_ME1_PIPE0_INT_CNTL, 0); |
| 5976 | WREG32(CP_ME1_PIPE1_INT_CNTL, 0); |
| 5977 | WREG32(CP_ME1_PIPE2_INT_CNTL, 0); |
| 5978 | WREG32(CP_ME1_PIPE3_INT_CNTL, 0); |
| 5979 | WREG32(CP_ME2_PIPE0_INT_CNTL, 0); |
| 5980 | WREG32(CP_ME2_PIPE1_INT_CNTL, 0); |
| 5981 | WREG32(CP_ME2_PIPE2_INT_CNTL, 0); |
| 5982 | WREG32(CP_ME2_PIPE3_INT_CNTL, 0); |
| 5983 | /* grbm */ |
| 5984 | WREG32(GRBM_INT_CNTL, 0); |
| 5985 | /* vline/vblank, etc. */ |
| 5986 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 5987 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
| 5988 | if (rdev->num_crtc >= 4) { |
| 5989 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 5990 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
| 5991 | } |
| 5992 | if (rdev->num_crtc >= 6) { |
| 5993 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 5994 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 5995 | } |
| 5996 | |
| 5997 | /* dac hotplug */ |
| 5998 | WREG32(DAC_AUTODETECT_INT_CONTROL, 0); |
| 5999 | |
| 6000 | /* digital hotplug */ |
| 6001 | tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 6002 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 6003 | tmp = RREG32(DC_HPD2_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 6004 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 6005 | tmp = RREG32(DC_HPD3_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 6006 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 6007 | tmp = RREG32(DC_HPD4_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 6008 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 6009 | tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 6010 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 6011 | tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 6012 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 6013 | |
| 6014 | } |
| 6015 | |
| 6016 | /** |
| 6017 | * cik_irq_init - init and enable the interrupt ring |
| 6018 | * |
| 6019 | * @rdev: radeon_device pointer |
| 6020 | * |
| 6021 | * Allocate a ring buffer for the interrupt controller, |
| 6022 | * enable the RLC, disable interrupts, enable the IH |
| 6023 | * ring buffer and enable it (CIK). |
| 6024 | * Called at device load and reume. |
| 6025 | * Returns 0 for success, errors for failure. |
| 6026 | */ |
| 6027 | static int cik_irq_init(struct radeon_device *rdev) |
| 6028 | { |
| 6029 | int ret = 0; |
| 6030 | int rb_bufsz; |
| 6031 | u32 interrupt_cntl, ih_cntl, ih_rb_cntl; |
| 6032 | |
| 6033 | /* allocate ring */ |
| 6034 | ret = r600_ih_ring_alloc(rdev); |
| 6035 | if (ret) |
| 6036 | return ret; |
| 6037 | |
| 6038 | /* disable irqs */ |
| 6039 | cik_disable_interrupts(rdev); |
| 6040 | |
| 6041 | /* init rlc */ |
| 6042 | ret = cik_rlc_resume(rdev); |
| 6043 | if (ret) { |
| 6044 | r600_ih_ring_fini(rdev); |
| 6045 | return ret; |
| 6046 | } |
| 6047 | |
| 6048 | /* setup interrupt control */ |
| 6049 | /* XXX this should actually be a bus address, not an MC address. same on older asics */ |
| 6050 | WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8); |
| 6051 | interrupt_cntl = RREG32(INTERRUPT_CNTL); |
| 6052 | /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi |
| 6053 | * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN |
| 6054 | */ |
| 6055 | interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE; |
| 6056 | /* IH_REQ_NONSNOOP_EN=1 if ring is in non-cacheable memory, e.g., vram */ |
| 6057 | interrupt_cntl &= ~IH_REQ_NONSNOOP_EN; |
| 6058 | WREG32(INTERRUPT_CNTL, interrupt_cntl); |
| 6059 | |
| 6060 | WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8); |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 6061 | rb_bufsz = order_base_2(rdev->ih.ring_size / 4); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6062 | |
| 6063 | ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE | |
| 6064 | IH_WPTR_OVERFLOW_CLEAR | |
| 6065 | (rb_bufsz << 1)); |
| 6066 | |
| 6067 | if (rdev->wb.enabled) |
| 6068 | ih_rb_cntl |= IH_WPTR_WRITEBACK_ENABLE; |
| 6069 | |
| 6070 | /* set the writeback address whether it's enabled or not */ |
| 6071 | WREG32(IH_RB_WPTR_ADDR_LO, (rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFFFFFFFC); |
| 6072 | WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFF); |
| 6073 | |
| 6074 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 6075 | |
| 6076 | /* set rptr, wptr to 0 */ |
| 6077 | WREG32(IH_RB_RPTR, 0); |
| 6078 | WREG32(IH_RB_WPTR, 0); |
| 6079 | |
| 6080 | /* Default settings for IH_CNTL (disabled at first) */ |
| 6081 | ih_cntl = MC_WRREQ_CREDIT(0x10) | MC_WR_CLEAN_CNT(0x10) | MC_VMID(0); |
| 6082 | /* RPTR_REARM only works if msi's are enabled */ |
| 6083 | if (rdev->msi_enabled) |
| 6084 | ih_cntl |= RPTR_REARM; |
| 6085 | WREG32(IH_CNTL, ih_cntl); |
| 6086 | |
| 6087 | /* force the active interrupt state to all disabled */ |
| 6088 | cik_disable_interrupt_state(rdev); |
| 6089 | |
| 6090 | pci_set_master(rdev->pdev); |
| 6091 | |
| 6092 | /* enable irqs */ |
| 6093 | cik_enable_interrupts(rdev); |
| 6094 | |
| 6095 | return ret; |
| 6096 | } |
| 6097 | |
| 6098 | /** |
| 6099 | * cik_irq_set - enable/disable interrupt sources |
| 6100 | * |
| 6101 | * @rdev: radeon_device pointer |
| 6102 | * |
| 6103 | * Enable interrupt sources on the GPU (vblanks, hpd, |
| 6104 | * etc.) (CIK). |
| 6105 | * Returns 0 for success, errors for failure. |
| 6106 | */ |
| 6107 | int cik_irq_set(struct radeon_device *rdev) |
| 6108 | { |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 6109 | u32 cp_int_cntl; |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6110 | u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3; |
| 6111 | u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6112 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; |
| 6113 | u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6; |
| 6114 | u32 grbm_int_cntl = 0; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6115 | u32 dma_cntl, dma_cntl1; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6116 | u32 thermal_int; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6117 | |
| 6118 | if (!rdev->irq.installed) { |
| 6119 | WARN(1, "Can't enable IRQ/MSI because no handler is installed\n"); |
| 6120 | return -EINVAL; |
| 6121 | } |
| 6122 | /* don't enable anything if the ih is disabled */ |
| 6123 | if (!rdev->ih.enabled) { |
| 6124 | cik_disable_interrupts(rdev); |
| 6125 | /* force the active interrupt state to all disabled */ |
| 6126 | cik_disable_interrupt_state(rdev); |
| 6127 | return 0; |
| 6128 | } |
| 6129 | |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 6130 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0) & |
| 6131 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 6132 | cp_int_cntl |= PRIV_INSTR_INT_ENABLE | PRIV_REG_INT_ENABLE; |
| 6133 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6134 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6135 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6136 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6137 | hpd4 = RREG32(DC_HPD4_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6138 | hpd5 = RREG32(DC_HPD5_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6139 | hpd6 = RREG32(DC_HPD6_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6140 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6141 | dma_cntl = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 6142 | dma_cntl1 = RREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 6143 | |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6144 | cp_m1p0 = RREG32(CP_ME1_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6145 | cp_m1p1 = RREG32(CP_ME1_PIPE1_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6146 | cp_m1p2 = RREG32(CP_ME1_PIPE2_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6147 | cp_m1p3 = RREG32(CP_ME1_PIPE3_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6148 | cp_m2p0 = RREG32(CP_ME2_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6149 | cp_m2p1 = RREG32(CP_ME2_PIPE1_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6150 | cp_m2p2 = RREG32(CP_ME2_PIPE2_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6151 | cp_m2p3 = RREG32(CP_ME2_PIPE3_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6152 | |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 6153 | if (rdev->flags & RADEON_IS_IGP) |
| 6154 | thermal_int = RREG32_SMC(CG_THERMAL_INT_CTRL) & |
| 6155 | ~(THERM_INTH_MASK | THERM_INTL_MASK); |
| 6156 | else |
| 6157 | thermal_int = RREG32_SMC(CG_THERMAL_INT) & |
| 6158 | ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW); |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6159 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6160 | /* enable CP interrupts on all rings */ |
| 6161 | if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { |
| 6162 | DRM_DEBUG("cik_irq_set: sw int gfx\n"); |
| 6163 | cp_int_cntl |= TIME_STAMP_INT_ENABLE; |
| 6164 | } |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6165 | if (atomic_read(&rdev->irq.ring_int[CAYMAN_RING_TYPE_CP1_INDEX])) { |
| 6166 | struct radeon_ring *ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 6167 | DRM_DEBUG("si_irq_set: sw int cp1\n"); |
| 6168 | if (ring->me == 1) { |
| 6169 | switch (ring->pipe) { |
| 6170 | case 0: |
| 6171 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; |
| 6172 | break; |
| 6173 | case 1: |
| 6174 | cp_m1p1 |= TIME_STAMP_INT_ENABLE; |
| 6175 | break; |
| 6176 | case 2: |
| 6177 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6178 | break; |
| 6179 | case 3: |
| 6180 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6181 | break; |
| 6182 | default: |
| 6183 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); |
| 6184 | break; |
| 6185 | } |
| 6186 | } else if (ring->me == 2) { |
| 6187 | switch (ring->pipe) { |
| 6188 | case 0: |
| 6189 | cp_m2p0 |= TIME_STAMP_INT_ENABLE; |
| 6190 | break; |
| 6191 | case 1: |
| 6192 | cp_m2p1 |= TIME_STAMP_INT_ENABLE; |
| 6193 | break; |
| 6194 | case 2: |
| 6195 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6196 | break; |
| 6197 | case 3: |
| 6198 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6199 | break; |
| 6200 | default: |
| 6201 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); |
| 6202 | break; |
| 6203 | } |
| 6204 | } else { |
| 6205 | DRM_DEBUG("si_irq_set: sw int cp1 invalid me %d\n", ring->me); |
| 6206 | } |
| 6207 | } |
| 6208 | if (atomic_read(&rdev->irq.ring_int[CAYMAN_RING_TYPE_CP2_INDEX])) { |
| 6209 | struct radeon_ring *ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 6210 | DRM_DEBUG("si_irq_set: sw int cp2\n"); |
| 6211 | if (ring->me == 1) { |
| 6212 | switch (ring->pipe) { |
| 6213 | case 0: |
| 6214 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; |
| 6215 | break; |
| 6216 | case 1: |
| 6217 | cp_m1p1 |= TIME_STAMP_INT_ENABLE; |
| 6218 | break; |
| 6219 | case 2: |
| 6220 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6221 | break; |
| 6222 | case 3: |
| 6223 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6224 | break; |
| 6225 | default: |
| 6226 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); |
| 6227 | break; |
| 6228 | } |
| 6229 | } else if (ring->me == 2) { |
| 6230 | switch (ring->pipe) { |
| 6231 | case 0: |
| 6232 | cp_m2p0 |= TIME_STAMP_INT_ENABLE; |
| 6233 | break; |
| 6234 | case 1: |
| 6235 | cp_m2p1 |= TIME_STAMP_INT_ENABLE; |
| 6236 | break; |
| 6237 | case 2: |
| 6238 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6239 | break; |
| 6240 | case 3: |
| 6241 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6242 | break; |
| 6243 | default: |
| 6244 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); |
| 6245 | break; |
| 6246 | } |
| 6247 | } else { |
| 6248 | DRM_DEBUG("si_irq_set: sw int cp2 invalid me %d\n", ring->me); |
| 6249 | } |
| 6250 | } |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6251 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6252 | if (atomic_read(&rdev->irq.ring_int[R600_RING_TYPE_DMA_INDEX])) { |
| 6253 | DRM_DEBUG("cik_irq_set: sw int dma\n"); |
| 6254 | dma_cntl |= TRAP_ENABLE; |
| 6255 | } |
| 6256 | |
| 6257 | if (atomic_read(&rdev->irq.ring_int[CAYMAN_RING_TYPE_DMA1_INDEX])) { |
| 6258 | DRM_DEBUG("cik_irq_set: sw int dma1\n"); |
| 6259 | dma_cntl1 |= TRAP_ENABLE; |
| 6260 | } |
| 6261 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6262 | if (rdev->irq.crtc_vblank_int[0] || |
| 6263 | atomic_read(&rdev->irq.pflip[0])) { |
| 6264 | DRM_DEBUG("cik_irq_set: vblank 0\n"); |
| 6265 | crtc1 |= VBLANK_INTERRUPT_MASK; |
| 6266 | } |
| 6267 | if (rdev->irq.crtc_vblank_int[1] || |
| 6268 | atomic_read(&rdev->irq.pflip[1])) { |
| 6269 | DRM_DEBUG("cik_irq_set: vblank 1\n"); |
| 6270 | crtc2 |= VBLANK_INTERRUPT_MASK; |
| 6271 | } |
| 6272 | if (rdev->irq.crtc_vblank_int[2] || |
| 6273 | atomic_read(&rdev->irq.pflip[2])) { |
| 6274 | DRM_DEBUG("cik_irq_set: vblank 2\n"); |
| 6275 | crtc3 |= VBLANK_INTERRUPT_MASK; |
| 6276 | } |
| 6277 | if (rdev->irq.crtc_vblank_int[3] || |
| 6278 | atomic_read(&rdev->irq.pflip[3])) { |
| 6279 | DRM_DEBUG("cik_irq_set: vblank 3\n"); |
| 6280 | crtc4 |= VBLANK_INTERRUPT_MASK; |
| 6281 | } |
| 6282 | if (rdev->irq.crtc_vblank_int[4] || |
| 6283 | atomic_read(&rdev->irq.pflip[4])) { |
| 6284 | DRM_DEBUG("cik_irq_set: vblank 4\n"); |
| 6285 | crtc5 |= VBLANK_INTERRUPT_MASK; |
| 6286 | } |
| 6287 | if (rdev->irq.crtc_vblank_int[5] || |
| 6288 | atomic_read(&rdev->irq.pflip[5])) { |
| 6289 | DRM_DEBUG("cik_irq_set: vblank 5\n"); |
| 6290 | crtc6 |= VBLANK_INTERRUPT_MASK; |
| 6291 | } |
| 6292 | if (rdev->irq.hpd[0]) { |
| 6293 | DRM_DEBUG("cik_irq_set: hpd 1\n"); |
| 6294 | hpd1 |= DC_HPDx_INT_EN; |
| 6295 | } |
| 6296 | if (rdev->irq.hpd[1]) { |
| 6297 | DRM_DEBUG("cik_irq_set: hpd 2\n"); |
| 6298 | hpd2 |= DC_HPDx_INT_EN; |
| 6299 | } |
| 6300 | if (rdev->irq.hpd[2]) { |
| 6301 | DRM_DEBUG("cik_irq_set: hpd 3\n"); |
| 6302 | hpd3 |= DC_HPDx_INT_EN; |
| 6303 | } |
| 6304 | if (rdev->irq.hpd[3]) { |
| 6305 | DRM_DEBUG("cik_irq_set: hpd 4\n"); |
| 6306 | hpd4 |= DC_HPDx_INT_EN; |
| 6307 | } |
| 6308 | if (rdev->irq.hpd[4]) { |
| 6309 | DRM_DEBUG("cik_irq_set: hpd 5\n"); |
| 6310 | hpd5 |= DC_HPDx_INT_EN; |
| 6311 | } |
| 6312 | if (rdev->irq.hpd[5]) { |
| 6313 | DRM_DEBUG("cik_irq_set: hpd 6\n"); |
| 6314 | hpd6 |= DC_HPDx_INT_EN; |
| 6315 | } |
| 6316 | |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6317 | if (rdev->irq.dpm_thermal) { |
| 6318 | DRM_DEBUG("dpm thermal\n"); |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 6319 | if (rdev->flags & RADEON_IS_IGP) |
| 6320 | thermal_int |= THERM_INTH_MASK | THERM_INTL_MASK; |
| 6321 | else |
| 6322 | thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6323 | } |
| 6324 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6325 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); |
| 6326 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6327 | WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, dma_cntl); |
| 6328 | WREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET, dma_cntl1); |
| 6329 | |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6330 | WREG32(CP_ME1_PIPE0_INT_CNTL, cp_m1p0); |
| 6331 | WREG32(CP_ME1_PIPE1_INT_CNTL, cp_m1p1); |
| 6332 | WREG32(CP_ME1_PIPE2_INT_CNTL, cp_m1p2); |
| 6333 | WREG32(CP_ME1_PIPE3_INT_CNTL, cp_m1p3); |
| 6334 | WREG32(CP_ME2_PIPE0_INT_CNTL, cp_m2p0); |
| 6335 | WREG32(CP_ME2_PIPE1_INT_CNTL, cp_m2p1); |
| 6336 | WREG32(CP_ME2_PIPE2_INT_CNTL, cp_m2p2); |
| 6337 | WREG32(CP_ME2_PIPE3_INT_CNTL, cp_m2p3); |
| 6338 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6339 | WREG32(GRBM_INT_CNTL, grbm_int_cntl); |
| 6340 | |
| 6341 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, crtc1); |
| 6342 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, crtc2); |
| 6343 | if (rdev->num_crtc >= 4) { |
| 6344 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, crtc3); |
| 6345 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, crtc4); |
| 6346 | } |
| 6347 | if (rdev->num_crtc >= 6) { |
| 6348 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, crtc5); |
| 6349 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, crtc6); |
| 6350 | } |
| 6351 | |
| 6352 | WREG32(DC_HPD1_INT_CONTROL, hpd1); |
| 6353 | WREG32(DC_HPD2_INT_CONTROL, hpd2); |
| 6354 | WREG32(DC_HPD3_INT_CONTROL, hpd3); |
| 6355 | WREG32(DC_HPD4_INT_CONTROL, hpd4); |
| 6356 | WREG32(DC_HPD5_INT_CONTROL, hpd5); |
| 6357 | WREG32(DC_HPD6_INT_CONTROL, hpd6); |
| 6358 | |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 6359 | if (rdev->flags & RADEON_IS_IGP) |
| 6360 | WREG32_SMC(CG_THERMAL_INT_CTRL, thermal_int); |
| 6361 | else |
| 6362 | WREG32_SMC(CG_THERMAL_INT, thermal_int); |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6363 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6364 | return 0; |
| 6365 | } |
| 6366 | |
| 6367 | /** |
| 6368 | * cik_irq_ack - ack interrupt sources |
| 6369 | * |
| 6370 | * @rdev: radeon_device pointer |
| 6371 | * |
| 6372 | * Ack interrupt sources on the GPU (vblanks, hpd, |
| 6373 | * etc.) (CIK). Certain interrupts sources are sw |
| 6374 | * generated and do not require an explicit ack. |
| 6375 | */ |
| 6376 | static inline void cik_irq_ack(struct radeon_device *rdev) |
| 6377 | { |
| 6378 | u32 tmp; |
| 6379 | |
| 6380 | rdev->irq.stat_regs.cik.disp_int = RREG32(DISP_INTERRUPT_STATUS); |
| 6381 | rdev->irq.stat_regs.cik.disp_int_cont = RREG32(DISP_INTERRUPT_STATUS_CONTINUE); |
| 6382 | rdev->irq.stat_regs.cik.disp_int_cont2 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE2); |
| 6383 | rdev->irq.stat_regs.cik.disp_int_cont3 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE3); |
| 6384 | rdev->irq.stat_regs.cik.disp_int_cont4 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE4); |
| 6385 | rdev->irq.stat_regs.cik.disp_int_cont5 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE5); |
| 6386 | rdev->irq.stat_regs.cik.disp_int_cont6 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE6); |
| 6387 | |
| 6388 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VBLANK_INTERRUPT) |
| 6389 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VBLANK_ACK); |
| 6390 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VLINE_INTERRUPT) |
| 6391 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VLINE_ACK); |
| 6392 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VBLANK_INTERRUPT) |
| 6393 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VBLANK_ACK); |
| 6394 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VLINE_INTERRUPT) |
| 6395 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VLINE_ACK); |
| 6396 | |
| 6397 | if (rdev->num_crtc >= 4) { |
| 6398 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) |
| 6399 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK); |
| 6400 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) |
| 6401 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK); |
| 6402 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) |
| 6403 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK); |
| 6404 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) |
| 6405 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK); |
| 6406 | } |
| 6407 | |
| 6408 | if (rdev->num_crtc >= 6) { |
| 6409 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) |
| 6410 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK); |
| 6411 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) |
| 6412 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK); |
| 6413 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) |
| 6414 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK); |
| 6415 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) |
| 6416 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK); |
| 6417 | } |
| 6418 | |
| 6419 | if (rdev->irq.stat_regs.cik.disp_int & DC_HPD1_INTERRUPT) { |
| 6420 | tmp = RREG32(DC_HPD1_INT_CONTROL); |
| 6421 | tmp |= DC_HPDx_INT_ACK; |
| 6422 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 6423 | } |
| 6424 | if (rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_INTERRUPT) { |
| 6425 | tmp = RREG32(DC_HPD2_INT_CONTROL); |
| 6426 | tmp |= DC_HPDx_INT_ACK; |
| 6427 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 6428 | } |
| 6429 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_INTERRUPT) { |
| 6430 | tmp = RREG32(DC_HPD3_INT_CONTROL); |
| 6431 | tmp |= DC_HPDx_INT_ACK; |
| 6432 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 6433 | } |
| 6434 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_INTERRUPT) { |
| 6435 | tmp = RREG32(DC_HPD4_INT_CONTROL); |
| 6436 | tmp |= DC_HPDx_INT_ACK; |
| 6437 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 6438 | } |
| 6439 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_INTERRUPT) { |
| 6440 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 6441 | tmp |= DC_HPDx_INT_ACK; |
| 6442 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 6443 | } |
| 6444 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_INTERRUPT) { |
| 6445 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 6446 | tmp |= DC_HPDx_INT_ACK; |
| 6447 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 6448 | } |
| 6449 | } |
| 6450 | |
| 6451 | /** |
| 6452 | * cik_irq_disable - disable interrupts |
| 6453 | * |
| 6454 | * @rdev: radeon_device pointer |
| 6455 | * |
| 6456 | * Disable interrupts on the hw (CIK). |
| 6457 | */ |
| 6458 | static void cik_irq_disable(struct radeon_device *rdev) |
| 6459 | { |
| 6460 | cik_disable_interrupts(rdev); |
| 6461 | /* Wait and acknowledge irq */ |
| 6462 | mdelay(1); |
| 6463 | cik_irq_ack(rdev); |
| 6464 | cik_disable_interrupt_state(rdev); |
| 6465 | } |
| 6466 | |
| 6467 | /** |
| 6468 | * cik_irq_disable - disable interrupts for suspend |
| 6469 | * |
| 6470 | * @rdev: radeon_device pointer |
| 6471 | * |
| 6472 | * Disable interrupts and stop the RLC (CIK). |
| 6473 | * Used for suspend. |
| 6474 | */ |
| 6475 | static void cik_irq_suspend(struct radeon_device *rdev) |
| 6476 | { |
| 6477 | cik_irq_disable(rdev); |
| 6478 | cik_rlc_stop(rdev); |
| 6479 | } |
| 6480 | |
| 6481 | /** |
| 6482 | * cik_irq_fini - tear down interrupt support |
| 6483 | * |
| 6484 | * @rdev: radeon_device pointer |
| 6485 | * |
| 6486 | * Disable interrupts on the hw and free the IH ring |
| 6487 | * buffer (CIK). |
| 6488 | * Used for driver unload. |
| 6489 | */ |
| 6490 | static void cik_irq_fini(struct radeon_device *rdev) |
| 6491 | { |
| 6492 | cik_irq_suspend(rdev); |
| 6493 | r600_ih_ring_fini(rdev); |
| 6494 | } |
| 6495 | |
| 6496 | /** |
| 6497 | * cik_get_ih_wptr - get the IH ring buffer wptr |
| 6498 | * |
| 6499 | * @rdev: radeon_device pointer |
| 6500 | * |
| 6501 | * Get the IH ring buffer wptr from either the register |
| 6502 | * or the writeback memory buffer (CIK). Also check for |
| 6503 | * ring buffer overflow and deal with it. |
| 6504 | * Used by cik_irq_process(). |
| 6505 | * Returns the value of the wptr. |
| 6506 | */ |
| 6507 | static inline u32 cik_get_ih_wptr(struct radeon_device *rdev) |
| 6508 | { |
| 6509 | u32 wptr, tmp; |
| 6510 | |
| 6511 | if (rdev->wb.enabled) |
| 6512 | wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]); |
| 6513 | else |
| 6514 | wptr = RREG32(IH_RB_WPTR); |
| 6515 | |
| 6516 | if (wptr & RB_OVERFLOW) { |
| 6517 | /* When a ring buffer overflow happen start parsing interrupt |
| 6518 | * from the last not overwritten vector (wptr + 16). Hopefully |
| 6519 | * this should allow us to catchup. |
| 6520 | */ |
| 6521 | dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n", |
| 6522 | wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask); |
| 6523 | rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask; |
| 6524 | tmp = RREG32(IH_RB_CNTL); |
| 6525 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 6526 | WREG32(IH_RB_CNTL, tmp); |
| 6527 | } |
| 6528 | return (wptr & rdev->ih.ptr_mask); |
| 6529 | } |
| 6530 | |
| 6531 | /* CIK IV Ring |
| 6532 | * Each IV ring entry is 128 bits: |
| 6533 | * [7:0] - interrupt source id |
| 6534 | * [31:8] - reserved |
| 6535 | * [59:32] - interrupt source data |
| 6536 | * [63:60] - reserved |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6537 | * [71:64] - RINGID |
| 6538 | * CP: |
| 6539 | * ME_ID [1:0], PIPE_ID[1:0], QUEUE_ID[2:0] |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6540 | * QUEUE_ID - for compute, which of the 8 queues owned by the dispatcher |
| 6541 | * - for gfx, hw shader state (0=PS...5=LS, 6=CS) |
| 6542 | * ME_ID - 0 = gfx, 1 = first 4 CS pipes, 2 = second 4 CS pipes |
| 6543 | * PIPE_ID - ME0 0=3D |
| 6544 | * - ME1&2 compute dispatcher (4 pipes each) |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6545 | * SDMA: |
| 6546 | * INSTANCE_ID [1:0], QUEUE_ID[1:0] |
| 6547 | * INSTANCE_ID - 0 = sdma0, 1 = sdma1 |
| 6548 | * QUEUE_ID - 0 = gfx, 1 = rlc0, 2 = rlc1 |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6549 | * [79:72] - VMID |
| 6550 | * [95:80] - PASID |
| 6551 | * [127:96] - reserved |
| 6552 | */ |
| 6553 | /** |
| 6554 | * cik_irq_process - interrupt handler |
| 6555 | * |
| 6556 | * @rdev: radeon_device pointer |
| 6557 | * |
| 6558 | * Interrupt hander (CIK). Walk the IH ring, |
| 6559 | * ack interrupts and schedule work to handle |
| 6560 | * interrupt events. |
| 6561 | * Returns irq process return code. |
| 6562 | */ |
| 6563 | int cik_irq_process(struct radeon_device *rdev) |
| 6564 | { |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6565 | struct radeon_ring *cp1_ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 6566 | struct radeon_ring *cp2_ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6567 | u32 wptr; |
| 6568 | u32 rptr; |
| 6569 | u32 src_id, src_data, ring_id; |
| 6570 | u8 me_id, pipe_id, queue_id; |
| 6571 | u32 ring_index; |
| 6572 | bool queue_hotplug = false; |
| 6573 | bool queue_reset = false; |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6574 | u32 addr, status, mc_client; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6575 | bool queue_thermal = false; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6576 | |
| 6577 | if (!rdev->ih.enabled || rdev->shutdown) |
| 6578 | return IRQ_NONE; |
| 6579 | |
| 6580 | wptr = cik_get_ih_wptr(rdev); |
| 6581 | |
| 6582 | restart_ih: |
| 6583 | /* is somebody else already processing irqs? */ |
| 6584 | if (atomic_xchg(&rdev->ih.lock, 1)) |
| 6585 | return IRQ_NONE; |
| 6586 | |
| 6587 | rptr = rdev->ih.rptr; |
| 6588 | DRM_DEBUG("cik_irq_process start: rptr %d, wptr %d\n", rptr, wptr); |
| 6589 | |
| 6590 | /* Order reading of wptr vs. reading of IH ring data */ |
| 6591 | rmb(); |
| 6592 | |
| 6593 | /* display interrupts */ |
| 6594 | cik_irq_ack(rdev); |
| 6595 | |
| 6596 | while (rptr != wptr) { |
| 6597 | /* wptr/rptr are in bytes! */ |
| 6598 | ring_index = rptr / 4; |
| 6599 | src_id = le32_to_cpu(rdev->ih.ring[ring_index]) & 0xff; |
| 6600 | src_data = le32_to_cpu(rdev->ih.ring[ring_index + 1]) & 0xfffffff; |
| 6601 | ring_id = le32_to_cpu(rdev->ih.ring[ring_index + 2]) & 0xff; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6602 | |
| 6603 | switch (src_id) { |
| 6604 | case 1: /* D1 vblank/vline */ |
| 6605 | switch (src_data) { |
| 6606 | case 0: /* D1 vblank */ |
| 6607 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VBLANK_INTERRUPT) { |
| 6608 | if (rdev->irq.crtc_vblank_int[0]) { |
| 6609 | drm_handle_vblank(rdev->ddev, 0); |
| 6610 | rdev->pm.vblank_sync = true; |
| 6611 | wake_up(&rdev->irq.vblank_queue); |
| 6612 | } |
| 6613 | if (atomic_read(&rdev->irq.pflip[0])) |
| 6614 | radeon_crtc_handle_flip(rdev, 0); |
| 6615 | rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VBLANK_INTERRUPT; |
| 6616 | DRM_DEBUG("IH: D1 vblank\n"); |
| 6617 | } |
| 6618 | break; |
| 6619 | case 1: /* D1 vline */ |
| 6620 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VLINE_INTERRUPT) { |
| 6621 | rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VLINE_INTERRUPT; |
| 6622 | DRM_DEBUG("IH: D1 vline\n"); |
| 6623 | } |
| 6624 | break; |
| 6625 | default: |
| 6626 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6627 | break; |
| 6628 | } |
| 6629 | break; |
| 6630 | case 2: /* D2 vblank/vline */ |
| 6631 | switch (src_data) { |
| 6632 | case 0: /* D2 vblank */ |
| 6633 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VBLANK_INTERRUPT) { |
| 6634 | if (rdev->irq.crtc_vblank_int[1]) { |
| 6635 | drm_handle_vblank(rdev->ddev, 1); |
| 6636 | rdev->pm.vblank_sync = true; |
| 6637 | wake_up(&rdev->irq.vblank_queue); |
| 6638 | } |
| 6639 | if (atomic_read(&rdev->irq.pflip[1])) |
| 6640 | radeon_crtc_handle_flip(rdev, 1); |
| 6641 | rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; |
| 6642 | DRM_DEBUG("IH: D2 vblank\n"); |
| 6643 | } |
| 6644 | break; |
| 6645 | case 1: /* D2 vline */ |
| 6646 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VLINE_INTERRUPT) { |
| 6647 | rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; |
| 6648 | DRM_DEBUG("IH: D2 vline\n"); |
| 6649 | } |
| 6650 | break; |
| 6651 | default: |
| 6652 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6653 | break; |
| 6654 | } |
| 6655 | break; |
| 6656 | case 3: /* D3 vblank/vline */ |
| 6657 | switch (src_data) { |
| 6658 | case 0: /* D3 vblank */ |
| 6659 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { |
| 6660 | if (rdev->irq.crtc_vblank_int[2]) { |
| 6661 | drm_handle_vblank(rdev->ddev, 2); |
| 6662 | rdev->pm.vblank_sync = true; |
| 6663 | wake_up(&rdev->irq.vblank_queue); |
| 6664 | } |
| 6665 | if (atomic_read(&rdev->irq.pflip[2])) |
| 6666 | radeon_crtc_handle_flip(rdev, 2); |
| 6667 | rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; |
| 6668 | DRM_DEBUG("IH: D3 vblank\n"); |
| 6669 | } |
| 6670 | break; |
| 6671 | case 1: /* D3 vline */ |
| 6672 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { |
| 6673 | rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; |
| 6674 | DRM_DEBUG("IH: D3 vline\n"); |
| 6675 | } |
| 6676 | break; |
| 6677 | default: |
| 6678 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6679 | break; |
| 6680 | } |
| 6681 | break; |
| 6682 | case 4: /* D4 vblank/vline */ |
| 6683 | switch (src_data) { |
| 6684 | case 0: /* D4 vblank */ |
| 6685 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { |
| 6686 | if (rdev->irq.crtc_vblank_int[3]) { |
| 6687 | drm_handle_vblank(rdev->ddev, 3); |
| 6688 | rdev->pm.vblank_sync = true; |
| 6689 | wake_up(&rdev->irq.vblank_queue); |
| 6690 | } |
| 6691 | if (atomic_read(&rdev->irq.pflip[3])) |
| 6692 | radeon_crtc_handle_flip(rdev, 3); |
| 6693 | rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; |
| 6694 | DRM_DEBUG("IH: D4 vblank\n"); |
| 6695 | } |
| 6696 | break; |
| 6697 | case 1: /* D4 vline */ |
| 6698 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { |
| 6699 | rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; |
| 6700 | DRM_DEBUG("IH: D4 vline\n"); |
| 6701 | } |
| 6702 | break; |
| 6703 | default: |
| 6704 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6705 | break; |
| 6706 | } |
| 6707 | break; |
| 6708 | case 5: /* D5 vblank/vline */ |
| 6709 | switch (src_data) { |
| 6710 | case 0: /* D5 vblank */ |
| 6711 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { |
| 6712 | if (rdev->irq.crtc_vblank_int[4]) { |
| 6713 | drm_handle_vblank(rdev->ddev, 4); |
| 6714 | rdev->pm.vblank_sync = true; |
| 6715 | wake_up(&rdev->irq.vblank_queue); |
| 6716 | } |
| 6717 | if (atomic_read(&rdev->irq.pflip[4])) |
| 6718 | radeon_crtc_handle_flip(rdev, 4); |
| 6719 | rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; |
| 6720 | DRM_DEBUG("IH: D5 vblank\n"); |
| 6721 | } |
| 6722 | break; |
| 6723 | case 1: /* D5 vline */ |
| 6724 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { |
| 6725 | rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; |
| 6726 | DRM_DEBUG("IH: D5 vline\n"); |
| 6727 | } |
| 6728 | break; |
| 6729 | default: |
| 6730 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6731 | break; |
| 6732 | } |
| 6733 | break; |
| 6734 | case 6: /* D6 vblank/vline */ |
| 6735 | switch (src_data) { |
| 6736 | case 0: /* D6 vblank */ |
| 6737 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { |
| 6738 | if (rdev->irq.crtc_vblank_int[5]) { |
| 6739 | drm_handle_vblank(rdev->ddev, 5); |
| 6740 | rdev->pm.vblank_sync = true; |
| 6741 | wake_up(&rdev->irq.vblank_queue); |
| 6742 | } |
| 6743 | if (atomic_read(&rdev->irq.pflip[5])) |
| 6744 | radeon_crtc_handle_flip(rdev, 5); |
| 6745 | rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; |
| 6746 | DRM_DEBUG("IH: D6 vblank\n"); |
| 6747 | } |
| 6748 | break; |
| 6749 | case 1: /* D6 vline */ |
| 6750 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { |
| 6751 | rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; |
| 6752 | DRM_DEBUG("IH: D6 vline\n"); |
| 6753 | } |
| 6754 | break; |
| 6755 | default: |
| 6756 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6757 | break; |
| 6758 | } |
| 6759 | break; |
| 6760 | case 42: /* HPD hotplug */ |
| 6761 | switch (src_data) { |
| 6762 | case 0: |
| 6763 | if (rdev->irq.stat_regs.cik.disp_int & DC_HPD1_INTERRUPT) { |
| 6764 | rdev->irq.stat_regs.cik.disp_int &= ~DC_HPD1_INTERRUPT; |
| 6765 | queue_hotplug = true; |
| 6766 | DRM_DEBUG("IH: HPD1\n"); |
| 6767 | } |
| 6768 | break; |
| 6769 | case 1: |
| 6770 | if (rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_INTERRUPT) { |
| 6771 | rdev->irq.stat_regs.cik.disp_int_cont &= ~DC_HPD2_INTERRUPT; |
| 6772 | queue_hotplug = true; |
| 6773 | DRM_DEBUG("IH: HPD2\n"); |
| 6774 | } |
| 6775 | break; |
| 6776 | case 2: |
| 6777 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_INTERRUPT) { |
| 6778 | rdev->irq.stat_regs.cik.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; |
| 6779 | queue_hotplug = true; |
| 6780 | DRM_DEBUG("IH: HPD3\n"); |
| 6781 | } |
| 6782 | break; |
| 6783 | case 3: |
| 6784 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_INTERRUPT) { |
| 6785 | rdev->irq.stat_regs.cik.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; |
| 6786 | queue_hotplug = true; |
| 6787 | DRM_DEBUG("IH: HPD4\n"); |
| 6788 | } |
| 6789 | break; |
| 6790 | case 4: |
| 6791 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_INTERRUPT) { |
| 6792 | rdev->irq.stat_regs.cik.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; |
| 6793 | queue_hotplug = true; |
| 6794 | DRM_DEBUG("IH: HPD5\n"); |
| 6795 | } |
| 6796 | break; |
| 6797 | case 5: |
| 6798 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_INTERRUPT) { |
| 6799 | rdev->irq.stat_regs.cik.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; |
| 6800 | queue_hotplug = true; |
| 6801 | DRM_DEBUG("IH: HPD6\n"); |
| 6802 | } |
| 6803 | break; |
| 6804 | default: |
| 6805 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6806 | break; |
| 6807 | } |
| 6808 | break; |
Christian König | 6a3808b | 2013-08-30 11:10:33 +0200 | [diff] [blame] | 6809 | case 124: /* UVD */ |
| 6810 | DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data); |
| 6811 | radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX); |
| 6812 | break; |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6813 | case 146: |
| 6814 | case 147: |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6815 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); |
| 6816 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); |
| 6817 | mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT); |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6818 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); |
| 6819 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6820 | addr); |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6821 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6822 | status); |
| 6823 | cik_vm_decode_fault(rdev, status, addr, mc_client); |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6824 | /* reset addr and status */ |
| 6825 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); |
| 6826 | break; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6827 | case 176: /* GFX RB CP_INT */ |
| 6828 | case 177: /* GFX IB CP_INT */ |
| 6829 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 6830 | break; |
| 6831 | case 181: /* CP EOP event */ |
| 6832 | DRM_DEBUG("IH: CP EOP\n"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6833 | /* XXX check the bitfield order! */ |
| 6834 | me_id = (ring_id & 0x60) >> 5; |
| 6835 | pipe_id = (ring_id & 0x18) >> 3; |
| 6836 | queue_id = (ring_id & 0x7) >> 0; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6837 | switch (me_id) { |
| 6838 | case 0: |
| 6839 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 6840 | break; |
| 6841 | case 1: |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6842 | case 2: |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6843 | if ((cp1_ring->me == me_id) & (cp1_ring->pipe == pipe_id)) |
| 6844 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP1_INDEX); |
| 6845 | if ((cp2_ring->me == me_id) & (cp2_ring->pipe == pipe_id)) |
| 6846 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP2_INDEX); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6847 | break; |
| 6848 | } |
| 6849 | break; |
| 6850 | case 184: /* CP Privileged reg access */ |
| 6851 | DRM_ERROR("Illegal register access in command stream\n"); |
| 6852 | /* XXX check the bitfield order! */ |
| 6853 | me_id = (ring_id & 0x60) >> 5; |
| 6854 | pipe_id = (ring_id & 0x18) >> 3; |
| 6855 | queue_id = (ring_id & 0x7) >> 0; |
| 6856 | switch (me_id) { |
| 6857 | case 0: |
| 6858 | /* This results in a full GPU reset, but all we need to do is soft |
| 6859 | * reset the CP for gfx |
| 6860 | */ |
| 6861 | queue_reset = true; |
| 6862 | break; |
| 6863 | case 1: |
| 6864 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6865 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6866 | break; |
| 6867 | case 2: |
| 6868 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6869 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6870 | break; |
| 6871 | } |
| 6872 | break; |
| 6873 | case 185: /* CP Privileged inst */ |
| 6874 | DRM_ERROR("Illegal instruction in command stream\n"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6875 | /* XXX check the bitfield order! */ |
| 6876 | me_id = (ring_id & 0x60) >> 5; |
| 6877 | pipe_id = (ring_id & 0x18) >> 3; |
| 6878 | queue_id = (ring_id & 0x7) >> 0; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6879 | switch (me_id) { |
| 6880 | case 0: |
| 6881 | /* This results in a full GPU reset, but all we need to do is soft |
| 6882 | * reset the CP for gfx |
| 6883 | */ |
| 6884 | queue_reset = true; |
| 6885 | break; |
| 6886 | case 1: |
| 6887 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6888 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6889 | break; |
| 6890 | case 2: |
| 6891 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6892 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6893 | break; |
| 6894 | } |
| 6895 | break; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6896 | case 224: /* SDMA trap event */ |
| 6897 | /* XXX check the bitfield order! */ |
| 6898 | me_id = (ring_id & 0x3) >> 0; |
| 6899 | queue_id = (ring_id & 0xc) >> 2; |
| 6900 | DRM_DEBUG("IH: SDMA trap\n"); |
| 6901 | switch (me_id) { |
| 6902 | case 0: |
| 6903 | switch (queue_id) { |
| 6904 | case 0: |
| 6905 | radeon_fence_process(rdev, R600_RING_TYPE_DMA_INDEX); |
| 6906 | break; |
| 6907 | case 1: |
| 6908 | /* XXX compute */ |
| 6909 | break; |
| 6910 | case 2: |
| 6911 | /* XXX compute */ |
| 6912 | break; |
| 6913 | } |
| 6914 | break; |
| 6915 | case 1: |
| 6916 | switch (queue_id) { |
| 6917 | case 0: |
| 6918 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_DMA1_INDEX); |
| 6919 | break; |
| 6920 | case 1: |
| 6921 | /* XXX compute */ |
| 6922 | break; |
| 6923 | case 2: |
| 6924 | /* XXX compute */ |
| 6925 | break; |
| 6926 | } |
| 6927 | break; |
| 6928 | } |
| 6929 | break; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6930 | case 230: /* thermal low to high */ |
| 6931 | DRM_DEBUG("IH: thermal low to high\n"); |
| 6932 | rdev->pm.dpm.thermal.high_to_low = false; |
| 6933 | queue_thermal = true; |
| 6934 | break; |
| 6935 | case 231: /* thermal high to low */ |
| 6936 | DRM_DEBUG("IH: thermal high to low\n"); |
| 6937 | rdev->pm.dpm.thermal.high_to_low = true; |
| 6938 | queue_thermal = true; |
| 6939 | break; |
| 6940 | case 233: /* GUI IDLE */ |
| 6941 | DRM_DEBUG("IH: GUI idle\n"); |
| 6942 | break; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6943 | case 241: /* SDMA Privileged inst */ |
| 6944 | case 247: /* SDMA Privileged inst */ |
| 6945 | DRM_ERROR("Illegal instruction in SDMA command stream\n"); |
| 6946 | /* XXX check the bitfield order! */ |
| 6947 | me_id = (ring_id & 0x3) >> 0; |
| 6948 | queue_id = (ring_id & 0xc) >> 2; |
| 6949 | switch (me_id) { |
| 6950 | case 0: |
| 6951 | switch (queue_id) { |
| 6952 | case 0: |
| 6953 | queue_reset = true; |
| 6954 | break; |
| 6955 | case 1: |
| 6956 | /* XXX compute */ |
| 6957 | queue_reset = true; |
| 6958 | break; |
| 6959 | case 2: |
| 6960 | /* XXX compute */ |
| 6961 | queue_reset = true; |
| 6962 | break; |
| 6963 | } |
| 6964 | break; |
| 6965 | case 1: |
| 6966 | switch (queue_id) { |
| 6967 | case 0: |
| 6968 | queue_reset = true; |
| 6969 | break; |
| 6970 | case 1: |
| 6971 | /* XXX compute */ |
| 6972 | queue_reset = true; |
| 6973 | break; |
| 6974 | case 2: |
| 6975 | /* XXX compute */ |
| 6976 | queue_reset = true; |
| 6977 | break; |
| 6978 | } |
| 6979 | break; |
| 6980 | } |
| 6981 | break; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6982 | default: |
| 6983 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6984 | break; |
| 6985 | } |
| 6986 | |
| 6987 | /* wptr/rptr are in bytes! */ |
| 6988 | rptr += 16; |
| 6989 | rptr &= rdev->ih.ptr_mask; |
| 6990 | } |
| 6991 | if (queue_hotplug) |
| 6992 | schedule_work(&rdev->hotplug_work); |
| 6993 | if (queue_reset) |
| 6994 | schedule_work(&rdev->reset_work); |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6995 | if (queue_thermal) |
| 6996 | schedule_work(&rdev->pm.dpm.thermal.work); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6997 | rdev->ih.rptr = rptr; |
| 6998 | WREG32(IH_RB_RPTR, rdev->ih.rptr); |
| 6999 | atomic_set(&rdev->ih.lock, 0); |
| 7000 | |
| 7001 | /* make sure wptr hasn't changed while processing */ |
| 7002 | wptr = cik_get_ih_wptr(rdev); |
| 7003 | if (wptr != rptr) |
| 7004 | goto restart_ih; |
| 7005 | |
| 7006 | return IRQ_HANDLED; |
| 7007 | } |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7008 | |
| 7009 | /* |
| 7010 | * startup/shutdown callbacks |
| 7011 | */ |
| 7012 | /** |
| 7013 | * cik_startup - program the asic to a functional state |
| 7014 | * |
| 7015 | * @rdev: radeon_device pointer |
| 7016 | * |
| 7017 | * Programs the asic to a functional state (CIK). |
| 7018 | * Called by cik_init() and cik_resume(). |
| 7019 | * Returns 0 for success, error for failure. |
| 7020 | */ |
| 7021 | static int cik_startup(struct radeon_device *rdev) |
| 7022 | { |
| 7023 | struct radeon_ring *ring; |
| 7024 | int r; |
| 7025 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 7026 | /* enable pcie gen2/3 link */ |
| 7027 | cik_pcie_gen3_enable(rdev); |
Alex Deucher | 7235711a4 | 2013-04-04 13:58:09 -0400 | [diff] [blame] | 7028 | /* enable aspm */ |
| 7029 | cik_program_aspm(rdev); |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 7030 | |
Alex Deucher | e5903d3 | 2013-08-30 08:58:20 -0400 | [diff] [blame] | 7031 | /* scratch needs to be initialized before MC */ |
| 7032 | r = r600_vram_scratch_init(rdev); |
| 7033 | if (r) |
| 7034 | return r; |
| 7035 | |
Alex Deucher | 6fab3feb | 2013-08-04 12:13:17 -0400 | [diff] [blame] | 7036 | cik_mc_program(rdev); |
| 7037 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7038 | if (rdev->flags & RADEON_IS_IGP) { |
| 7039 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || |
| 7040 | !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) { |
| 7041 | r = cik_init_microcode(rdev); |
| 7042 | if (r) { |
| 7043 | DRM_ERROR("Failed to load firmware!\n"); |
| 7044 | return r; |
| 7045 | } |
| 7046 | } |
| 7047 | } else { |
| 7048 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || |
| 7049 | !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw || |
| 7050 | !rdev->mc_fw) { |
| 7051 | r = cik_init_microcode(rdev); |
| 7052 | if (r) { |
| 7053 | DRM_ERROR("Failed to load firmware!\n"); |
| 7054 | return r; |
| 7055 | } |
| 7056 | } |
| 7057 | |
| 7058 | r = ci_mc_load_microcode(rdev); |
| 7059 | if (r) { |
| 7060 | DRM_ERROR("Failed to load MC firmware!\n"); |
| 7061 | return r; |
| 7062 | } |
| 7063 | } |
| 7064 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7065 | r = cik_pcie_gart_enable(rdev); |
| 7066 | if (r) |
| 7067 | return r; |
| 7068 | cik_gpu_init(rdev); |
| 7069 | |
| 7070 | /* allocate rlc buffers */ |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 7071 | if (rdev->flags & RADEON_IS_IGP) { |
| 7072 | if (rdev->family == CHIP_KAVERI) { |
| 7073 | rdev->rlc.reg_list = spectre_rlc_save_restore_register_list; |
| 7074 | rdev->rlc.reg_list_size = |
| 7075 | (u32)ARRAY_SIZE(spectre_rlc_save_restore_register_list); |
| 7076 | } else { |
| 7077 | rdev->rlc.reg_list = kalindi_rlc_save_restore_register_list; |
| 7078 | rdev->rlc.reg_list_size = |
| 7079 | (u32)ARRAY_SIZE(kalindi_rlc_save_restore_register_list); |
| 7080 | } |
| 7081 | } |
| 7082 | rdev->rlc.cs_data = ci_cs_data; |
| 7083 | rdev->rlc.cp_table_size = CP_ME_TABLE_SIZE * 5 * 4; |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 7084 | r = sumo_rlc_init(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7085 | if (r) { |
| 7086 | DRM_ERROR("Failed to init rlc BOs!\n"); |
| 7087 | return r; |
| 7088 | } |
| 7089 | |
| 7090 | /* allocate wb buffer */ |
| 7091 | r = radeon_wb_init(rdev); |
| 7092 | if (r) |
| 7093 | return r; |
| 7094 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7095 | /* allocate mec buffers */ |
| 7096 | r = cik_mec_init(rdev); |
| 7097 | if (r) { |
| 7098 | DRM_ERROR("Failed to init MEC BOs!\n"); |
| 7099 | return r; |
| 7100 | } |
| 7101 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7102 | r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 7103 | if (r) { |
| 7104 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 7105 | return r; |
| 7106 | } |
| 7107 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7108 | r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_CP1_INDEX); |
| 7109 | if (r) { |
| 7110 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 7111 | return r; |
| 7112 | } |
| 7113 | |
| 7114 | r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_CP2_INDEX); |
| 7115 | if (r) { |
| 7116 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 7117 | return r; |
| 7118 | } |
| 7119 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7120 | r = radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_DMA_INDEX); |
| 7121 | if (r) { |
| 7122 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
| 7123 | return r; |
| 7124 | } |
| 7125 | |
| 7126 | r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_DMA1_INDEX); |
| 7127 | if (r) { |
| 7128 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
| 7129 | return r; |
| 7130 | } |
| 7131 | |
Alex Deucher | 2ce529d | 2013-08-28 18:12:59 -0400 | [diff] [blame] | 7132 | r = radeon_uvd_resume(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7133 | if (!r) { |
Alex Deucher | 2ce529d | 2013-08-28 18:12:59 -0400 | [diff] [blame] | 7134 | r = uvd_v4_2_resume(rdev); |
| 7135 | if (!r) { |
| 7136 | r = radeon_fence_driver_start_ring(rdev, |
| 7137 | R600_RING_TYPE_UVD_INDEX); |
| 7138 | if (r) |
| 7139 | dev_err(rdev->dev, "UVD fences init error (%d).\n", r); |
| 7140 | } |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7141 | } |
| 7142 | if (r) |
| 7143 | rdev->ring[R600_RING_TYPE_UVD_INDEX].ring_size = 0; |
| 7144 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7145 | /* Enable IRQ */ |
| 7146 | if (!rdev->irq.installed) { |
| 7147 | r = radeon_irq_kms_init(rdev); |
| 7148 | if (r) |
| 7149 | return r; |
| 7150 | } |
| 7151 | |
| 7152 | r = cik_irq_init(rdev); |
| 7153 | if (r) { |
| 7154 | DRM_ERROR("radeon: IH init failed (%d).\n", r); |
| 7155 | radeon_irq_kms_fini(rdev); |
| 7156 | return r; |
| 7157 | } |
| 7158 | cik_irq_set(rdev); |
| 7159 | |
| 7160 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
| 7161 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP_RPTR_OFFSET, |
| 7162 | CP_RB0_RPTR, CP_RB0_WPTR, |
Marek Olšák | 1dac28e | 2013-10-30 14:41:35 +0100 | [diff] [blame] | 7163 | PACKET3(PACKET3_NOP, 0x3FFF)); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7164 | if (r) |
| 7165 | return r; |
| 7166 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7167 | /* set up the compute queues */ |
Alex Deucher | 2615b53 | 2013-06-03 11:21:58 -0400 | [diff] [blame] | 7168 | /* type-2 packets are deprecated on MEC, use type-3 instead */ |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7169 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 7170 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP1_RPTR_OFFSET, |
| 7171 | CP_HQD_PQ_RPTR, CP_HQD_PQ_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7172 | PACKET3(PACKET3_NOP, 0x3FFF)); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7173 | if (r) |
| 7174 | return r; |
| 7175 | ring->me = 1; /* first MEC */ |
| 7176 | ring->pipe = 0; /* first pipe */ |
| 7177 | ring->queue = 0; /* first queue */ |
| 7178 | ring->wptr_offs = CIK_WB_CP1_WPTR_OFFSET; |
| 7179 | |
Alex Deucher | 2615b53 | 2013-06-03 11:21:58 -0400 | [diff] [blame] | 7180 | /* type-2 packets are deprecated on MEC, use type-3 instead */ |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7181 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 7182 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP2_RPTR_OFFSET, |
| 7183 | CP_HQD_PQ_RPTR, CP_HQD_PQ_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7184 | PACKET3(PACKET3_NOP, 0x3FFF)); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7185 | if (r) |
| 7186 | return r; |
| 7187 | /* dGPU only have 1 MEC */ |
| 7188 | ring->me = 1; /* first MEC */ |
| 7189 | ring->pipe = 0; /* first pipe */ |
| 7190 | ring->queue = 1; /* second queue */ |
| 7191 | ring->wptr_offs = CIK_WB_CP2_WPTR_OFFSET; |
| 7192 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7193 | ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
| 7194 | r = radeon_ring_init(rdev, ring, ring->ring_size, R600_WB_DMA_RPTR_OFFSET, |
| 7195 | SDMA0_GFX_RB_RPTR + SDMA0_REGISTER_OFFSET, |
| 7196 | SDMA0_GFX_RB_WPTR + SDMA0_REGISTER_OFFSET, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7197 | SDMA_PACKET(SDMA_OPCODE_NOP, 0, 0)); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7198 | if (r) |
| 7199 | return r; |
| 7200 | |
| 7201 | ring = &rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX]; |
| 7202 | r = radeon_ring_init(rdev, ring, ring->ring_size, CAYMAN_WB_DMA1_RPTR_OFFSET, |
| 7203 | SDMA0_GFX_RB_RPTR + SDMA1_REGISTER_OFFSET, |
| 7204 | SDMA0_GFX_RB_WPTR + SDMA1_REGISTER_OFFSET, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7205 | SDMA_PACKET(SDMA_OPCODE_NOP, 0, 0)); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7206 | if (r) |
| 7207 | return r; |
| 7208 | |
| 7209 | r = cik_cp_resume(rdev); |
| 7210 | if (r) |
| 7211 | return r; |
| 7212 | |
| 7213 | r = cik_sdma_resume(rdev); |
| 7214 | if (r) |
| 7215 | return r; |
| 7216 | |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7217 | ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; |
| 7218 | if (ring->ring_size) { |
Christian König | 02c9f7f | 2013-08-13 11:56:51 +0200 | [diff] [blame] | 7219 | r = radeon_ring_init(rdev, ring, ring->ring_size, 0, |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7220 | UVD_RBC_RB_RPTR, UVD_RBC_RB_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7221 | RADEON_CP_PACKET2); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7222 | if (!r) |
Christian König | e409b12 | 2013-08-13 11:56:53 +0200 | [diff] [blame] | 7223 | r = uvd_v1_0_init(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7224 | if (r) |
| 7225 | DRM_ERROR("radeon: failed initializing UVD (%d).\n", r); |
| 7226 | } |
| 7227 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7228 | r = radeon_ib_pool_init(rdev); |
| 7229 | if (r) { |
| 7230 | dev_err(rdev->dev, "IB initialization failed (%d).\n", r); |
| 7231 | return r; |
| 7232 | } |
| 7233 | |
| 7234 | r = radeon_vm_manager_init(rdev); |
| 7235 | if (r) { |
| 7236 | dev_err(rdev->dev, "vm manager initialization failed (%d).\n", r); |
| 7237 | return r; |
| 7238 | } |
| 7239 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 7240 | r = dce6_audio_init(rdev); |
| 7241 | if (r) |
| 7242 | return r; |
| 7243 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7244 | return 0; |
| 7245 | } |
| 7246 | |
| 7247 | /** |
| 7248 | * cik_resume - resume the asic to a functional state |
| 7249 | * |
| 7250 | * @rdev: radeon_device pointer |
| 7251 | * |
| 7252 | * Programs the asic to a functional state (CIK). |
| 7253 | * Called at resume. |
| 7254 | * Returns 0 for success, error for failure. |
| 7255 | */ |
| 7256 | int cik_resume(struct radeon_device *rdev) |
| 7257 | { |
| 7258 | int r; |
| 7259 | |
| 7260 | /* post card */ |
| 7261 | atom_asic_init(rdev->mode_info.atom_context); |
| 7262 | |
Alex Deucher | 0aafd31 | 2013-04-09 14:43:30 -0400 | [diff] [blame] | 7263 | /* init golden registers */ |
| 7264 | cik_init_golden_registers(rdev); |
| 7265 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7266 | rdev->accel_working = true; |
| 7267 | r = cik_startup(rdev); |
| 7268 | if (r) { |
| 7269 | DRM_ERROR("cik startup failed on resume\n"); |
| 7270 | rdev->accel_working = false; |
| 7271 | return r; |
| 7272 | } |
| 7273 | |
| 7274 | return r; |
| 7275 | |
| 7276 | } |
| 7277 | |
| 7278 | /** |
| 7279 | * cik_suspend - suspend the asic |
| 7280 | * |
| 7281 | * @rdev: radeon_device pointer |
| 7282 | * |
| 7283 | * Bring the chip into a state suitable for suspend (CIK). |
| 7284 | * Called at suspend. |
| 7285 | * Returns 0 for success. |
| 7286 | */ |
| 7287 | int cik_suspend(struct radeon_device *rdev) |
| 7288 | { |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 7289 | dce6_audio_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7290 | radeon_vm_manager_fini(rdev); |
| 7291 | cik_cp_enable(rdev, false); |
| 7292 | cik_sdma_enable(rdev, false); |
Christian König | e409b12 | 2013-08-13 11:56:53 +0200 | [diff] [blame] | 7293 | uvd_v1_0_fini(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7294 | radeon_uvd_suspend(rdev); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 7295 | cik_fini_pg(rdev); |
| 7296 | cik_fini_cg(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7297 | cik_irq_suspend(rdev); |
| 7298 | radeon_wb_disable(rdev); |
| 7299 | cik_pcie_gart_disable(rdev); |
| 7300 | return 0; |
| 7301 | } |
| 7302 | |
| 7303 | /* Plan is to move initialization in that function and use |
| 7304 | * helper function so that radeon_device_init pretty much |
| 7305 | * do nothing more than calling asic specific function. This |
| 7306 | * should also allow to remove a bunch of callback function |
| 7307 | * like vram_info. |
| 7308 | */ |
| 7309 | /** |
| 7310 | * cik_init - asic specific driver and hw init |
| 7311 | * |
| 7312 | * @rdev: radeon_device pointer |
| 7313 | * |
| 7314 | * Setup asic specific driver variables and program the hw |
| 7315 | * to a functional state (CIK). |
| 7316 | * Called at driver startup. |
| 7317 | * Returns 0 for success, errors for failure. |
| 7318 | */ |
| 7319 | int cik_init(struct radeon_device *rdev) |
| 7320 | { |
| 7321 | struct radeon_ring *ring; |
| 7322 | int r; |
| 7323 | |
| 7324 | /* Read BIOS */ |
| 7325 | if (!radeon_get_bios(rdev)) { |
| 7326 | if (ASIC_IS_AVIVO(rdev)) |
| 7327 | return -EINVAL; |
| 7328 | } |
| 7329 | /* Must be an ATOMBIOS */ |
| 7330 | if (!rdev->is_atom_bios) { |
| 7331 | dev_err(rdev->dev, "Expecting atombios for cayman GPU\n"); |
| 7332 | return -EINVAL; |
| 7333 | } |
| 7334 | r = radeon_atombios_init(rdev); |
| 7335 | if (r) |
| 7336 | return r; |
| 7337 | |
| 7338 | /* Post card if necessary */ |
| 7339 | if (!radeon_card_posted(rdev)) { |
| 7340 | if (!rdev->bios) { |
| 7341 | dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); |
| 7342 | return -EINVAL; |
| 7343 | } |
| 7344 | DRM_INFO("GPU not posted. posting now...\n"); |
| 7345 | atom_asic_init(rdev->mode_info.atom_context); |
| 7346 | } |
Alex Deucher | 0aafd31 | 2013-04-09 14:43:30 -0400 | [diff] [blame] | 7347 | /* init golden registers */ |
| 7348 | cik_init_golden_registers(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7349 | /* Initialize scratch registers */ |
| 7350 | cik_scratch_init(rdev); |
| 7351 | /* Initialize surface registers */ |
| 7352 | radeon_surface_init(rdev); |
| 7353 | /* Initialize clocks */ |
| 7354 | radeon_get_clock_info(rdev->ddev); |
| 7355 | |
| 7356 | /* Fence driver */ |
| 7357 | r = radeon_fence_driver_init(rdev); |
| 7358 | if (r) |
| 7359 | return r; |
| 7360 | |
| 7361 | /* initialize memory controller */ |
| 7362 | r = cik_mc_init(rdev); |
| 7363 | if (r) |
| 7364 | return r; |
| 7365 | /* Memory manager */ |
| 7366 | r = radeon_bo_init(rdev); |
| 7367 | if (r) |
| 7368 | return r; |
| 7369 | |
| 7370 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
| 7371 | ring->ring_obj = NULL; |
| 7372 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7373 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7374 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 7375 | ring->ring_obj = NULL; |
| 7376 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7377 | r = radeon_doorbell_get(rdev, &ring->doorbell_page_num); |
| 7378 | if (r) |
| 7379 | return r; |
| 7380 | |
| 7381 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 7382 | ring->ring_obj = NULL; |
| 7383 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7384 | r = radeon_doorbell_get(rdev, &ring->doorbell_page_num); |
| 7385 | if (r) |
| 7386 | return r; |
| 7387 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7388 | ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
| 7389 | ring->ring_obj = NULL; |
| 7390 | r600_ring_init(rdev, ring, 256 * 1024); |
| 7391 | |
| 7392 | ring = &rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX]; |
| 7393 | ring->ring_obj = NULL; |
| 7394 | r600_ring_init(rdev, ring, 256 * 1024); |
| 7395 | |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7396 | r = radeon_uvd_init(rdev); |
| 7397 | if (!r) { |
| 7398 | ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; |
| 7399 | ring->ring_obj = NULL; |
| 7400 | r600_ring_init(rdev, ring, 4096); |
| 7401 | } |
| 7402 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7403 | rdev->ih.ring_obj = NULL; |
| 7404 | r600_ih_ring_init(rdev, 64 * 1024); |
| 7405 | |
| 7406 | r = r600_pcie_gart_init(rdev); |
| 7407 | if (r) |
| 7408 | return r; |
| 7409 | |
| 7410 | rdev->accel_working = true; |
| 7411 | r = cik_startup(rdev); |
| 7412 | if (r) { |
| 7413 | dev_err(rdev->dev, "disabling GPU acceleration\n"); |
| 7414 | cik_cp_fini(rdev); |
| 7415 | cik_sdma_fini(rdev); |
| 7416 | cik_irq_fini(rdev); |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 7417 | sumo_rlc_fini(rdev); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7418 | cik_mec_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7419 | radeon_wb_fini(rdev); |
| 7420 | radeon_ib_pool_fini(rdev); |
| 7421 | radeon_vm_manager_fini(rdev); |
| 7422 | radeon_irq_kms_fini(rdev); |
| 7423 | cik_pcie_gart_fini(rdev); |
| 7424 | rdev->accel_working = false; |
| 7425 | } |
| 7426 | |
| 7427 | /* Don't start up if the MC ucode is missing. |
| 7428 | * The default clocks and voltages before the MC ucode |
| 7429 | * is loaded are not suffient for advanced operations. |
| 7430 | */ |
| 7431 | if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) { |
| 7432 | DRM_ERROR("radeon: MC ucode required for NI+.\n"); |
| 7433 | return -EINVAL; |
| 7434 | } |
| 7435 | |
| 7436 | return 0; |
| 7437 | } |
| 7438 | |
| 7439 | /** |
| 7440 | * cik_fini - asic specific driver and hw fini |
| 7441 | * |
| 7442 | * @rdev: radeon_device pointer |
| 7443 | * |
| 7444 | * Tear down the asic specific driver variables and program the hw |
| 7445 | * to an idle state (CIK). |
| 7446 | * Called at driver unload. |
| 7447 | */ |
| 7448 | void cik_fini(struct radeon_device *rdev) |
| 7449 | { |
| 7450 | cik_cp_fini(rdev); |
| 7451 | cik_sdma_fini(rdev); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 7452 | cik_fini_pg(rdev); |
| 7453 | cik_fini_cg(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7454 | cik_irq_fini(rdev); |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 7455 | sumo_rlc_fini(rdev); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7456 | cik_mec_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7457 | radeon_wb_fini(rdev); |
| 7458 | radeon_vm_manager_fini(rdev); |
| 7459 | radeon_ib_pool_fini(rdev); |
| 7460 | radeon_irq_kms_fini(rdev); |
Christian König | e409b12 | 2013-08-13 11:56:53 +0200 | [diff] [blame] | 7461 | uvd_v1_0_fini(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7462 | radeon_uvd_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7463 | cik_pcie_gart_fini(rdev); |
| 7464 | r600_vram_scratch_fini(rdev); |
| 7465 | radeon_gem_fini(rdev); |
| 7466 | radeon_fence_driver_fini(rdev); |
| 7467 | radeon_bo_fini(rdev); |
| 7468 | radeon_atombios_fini(rdev); |
| 7469 | kfree(rdev->bios); |
| 7470 | rdev->bios = NULL; |
| 7471 | } |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7472 | |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7473 | void dce8_program_fmt(struct drm_encoder *encoder) |
| 7474 | { |
| 7475 | struct drm_device *dev = encoder->dev; |
| 7476 | struct radeon_device *rdev = dev->dev_private; |
| 7477 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 7478 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
| 7479 | struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); |
| 7480 | int bpc = 0; |
| 7481 | u32 tmp = 0; |
Alex Deucher | 6214bb7 | 2013-09-24 17:26:26 -0400 | [diff] [blame] | 7482 | enum radeon_connector_dither dither = RADEON_FMT_DITHER_DISABLE; |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7483 | |
Alex Deucher | 6214bb7 | 2013-09-24 17:26:26 -0400 | [diff] [blame] | 7484 | if (connector) { |
| 7485 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7486 | bpc = radeon_get_monitor_bpc(connector); |
Alex Deucher | 6214bb7 | 2013-09-24 17:26:26 -0400 | [diff] [blame] | 7487 | dither = radeon_connector->dither; |
| 7488 | } |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7489 | |
| 7490 | /* LVDS/eDP FMT is set up by atom */ |
| 7491 | if (radeon_encoder->devices & ATOM_DEVICE_LCD_SUPPORT) |
| 7492 | return; |
| 7493 | |
| 7494 | /* not needed for analog */ |
| 7495 | if ((radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1) || |
| 7496 | (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2)) |
| 7497 | return; |
| 7498 | |
| 7499 | if (bpc == 0) |
| 7500 | return; |
| 7501 | |
| 7502 | switch (bpc) { |
| 7503 | case 6: |
Alex Deucher | 6214bb7 | 2013-09-24 17:26:26 -0400 | [diff] [blame] | 7504 | if (dither == RADEON_FMT_DITHER_ENABLE) |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7505 | /* XXX sort out optimal dither settings */ |
| 7506 | tmp |= (FMT_FRAME_RANDOM_ENABLE | FMT_HIGHPASS_RANDOM_ENABLE | |
| 7507 | FMT_SPATIAL_DITHER_EN | FMT_SPATIAL_DITHER_DEPTH(0)); |
| 7508 | else |
| 7509 | tmp |= (FMT_TRUNCATE_EN | FMT_TRUNCATE_DEPTH(0)); |
| 7510 | break; |
| 7511 | case 8: |
Alex Deucher | 6214bb7 | 2013-09-24 17:26:26 -0400 | [diff] [blame] | 7512 | if (dither == RADEON_FMT_DITHER_ENABLE) |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7513 | /* XXX sort out optimal dither settings */ |
| 7514 | tmp |= (FMT_FRAME_RANDOM_ENABLE | FMT_HIGHPASS_RANDOM_ENABLE | |
| 7515 | FMT_RGB_RANDOM_ENABLE | |
| 7516 | FMT_SPATIAL_DITHER_EN | FMT_SPATIAL_DITHER_DEPTH(1)); |
| 7517 | else |
| 7518 | tmp |= (FMT_TRUNCATE_EN | FMT_TRUNCATE_DEPTH(1)); |
| 7519 | break; |
| 7520 | case 10: |
Alex Deucher | 6214bb7 | 2013-09-24 17:26:26 -0400 | [diff] [blame] | 7521 | if (dither == RADEON_FMT_DITHER_ENABLE) |
Alex Deucher | 134b480 | 2013-09-23 12:22:11 -0400 | [diff] [blame] | 7522 | /* XXX sort out optimal dither settings */ |
| 7523 | tmp |= (FMT_FRAME_RANDOM_ENABLE | FMT_HIGHPASS_RANDOM_ENABLE | |
| 7524 | FMT_RGB_RANDOM_ENABLE | |
| 7525 | FMT_SPATIAL_DITHER_EN | FMT_SPATIAL_DITHER_DEPTH(2)); |
| 7526 | else |
| 7527 | tmp |= (FMT_TRUNCATE_EN | FMT_TRUNCATE_DEPTH(2)); |
| 7528 | break; |
| 7529 | default: |
| 7530 | /* not needed */ |
| 7531 | break; |
| 7532 | } |
| 7533 | |
| 7534 | WREG32(FMT_BIT_DEPTH_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 7535 | } |
| 7536 | |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7537 | /* display watermark setup */ |
| 7538 | /** |
| 7539 | * dce8_line_buffer_adjust - Set up the line buffer |
| 7540 | * |
| 7541 | * @rdev: radeon_device pointer |
| 7542 | * @radeon_crtc: the selected display controller |
| 7543 | * @mode: the current display mode on the selected display |
| 7544 | * controller |
| 7545 | * |
| 7546 | * Setup up the line buffer allocation for |
| 7547 | * the selected display controller (CIK). |
| 7548 | * Returns the line buffer size in pixels. |
| 7549 | */ |
| 7550 | static u32 dce8_line_buffer_adjust(struct radeon_device *rdev, |
| 7551 | struct radeon_crtc *radeon_crtc, |
| 7552 | struct drm_display_mode *mode) |
| 7553 | { |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7554 | u32 tmp, buffer_alloc, i; |
| 7555 | u32 pipe_offset = radeon_crtc->crtc_id * 0x20; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7556 | /* |
| 7557 | * Line Buffer Setup |
| 7558 | * There are 6 line buffers, one for each display controllers. |
| 7559 | * There are 3 partitions per LB. Select the number of partitions |
| 7560 | * to enable based on the display width. For display widths larger |
| 7561 | * than 4096, you need use to use 2 display controllers and combine |
| 7562 | * them using the stereo blender. |
| 7563 | */ |
| 7564 | if (radeon_crtc->base.enabled && mode) { |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7565 | if (mode->crtc_hdisplay < 1920) { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7566 | tmp = 1; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7567 | buffer_alloc = 2; |
| 7568 | } else if (mode->crtc_hdisplay < 2560) { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7569 | tmp = 2; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7570 | buffer_alloc = 2; |
| 7571 | } else if (mode->crtc_hdisplay < 4096) { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7572 | tmp = 0; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7573 | buffer_alloc = (rdev->flags & RADEON_IS_IGP) ? 2 : 4; |
| 7574 | } else { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7575 | DRM_DEBUG_KMS("Mode too big for LB!\n"); |
| 7576 | tmp = 0; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7577 | buffer_alloc = (rdev->flags & RADEON_IS_IGP) ? 2 : 4; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7578 | } |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7579 | } else { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7580 | tmp = 1; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7581 | buffer_alloc = 0; |
| 7582 | } |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7583 | |
| 7584 | WREG32(LB_MEMORY_CTRL + radeon_crtc->crtc_offset, |
| 7585 | LB_MEMORY_CONFIG(tmp) | LB_MEMORY_SIZE(0x6B0)); |
| 7586 | |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7587 | WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset, |
| 7588 | DMIF_BUFFERS_ALLOCATED(buffer_alloc)); |
| 7589 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 7590 | if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) & |
| 7591 | DMIF_BUFFERS_ALLOCATED_COMPLETED) |
| 7592 | break; |
| 7593 | udelay(1); |
| 7594 | } |
| 7595 | |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7596 | if (radeon_crtc->base.enabled && mode) { |
| 7597 | switch (tmp) { |
| 7598 | case 0: |
| 7599 | default: |
| 7600 | return 4096 * 2; |
| 7601 | case 1: |
| 7602 | return 1920 * 2; |
| 7603 | case 2: |
| 7604 | return 2560 * 2; |
| 7605 | } |
| 7606 | } |
| 7607 | |
| 7608 | /* controller not enabled, so no lb used */ |
| 7609 | return 0; |
| 7610 | } |
| 7611 | |
| 7612 | /** |
| 7613 | * cik_get_number_of_dram_channels - get the number of dram channels |
| 7614 | * |
| 7615 | * @rdev: radeon_device pointer |
| 7616 | * |
| 7617 | * Look up the number of video ram channels (CIK). |
| 7618 | * Used for display watermark bandwidth calculations |
| 7619 | * Returns the number of dram channels |
| 7620 | */ |
| 7621 | static u32 cik_get_number_of_dram_channels(struct radeon_device *rdev) |
| 7622 | { |
| 7623 | u32 tmp = RREG32(MC_SHARED_CHMAP); |
| 7624 | |
| 7625 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 7626 | case 0: |
| 7627 | default: |
| 7628 | return 1; |
| 7629 | case 1: |
| 7630 | return 2; |
| 7631 | case 2: |
| 7632 | return 4; |
| 7633 | case 3: |
| 7634 | return 8; |
| 7635 | case 4: |
| 7636 | return 3; |
| 7637 | case 5: |
| 7638 | return 6; |
| 7639 | case 6: |
| 7640 | return 10; |
| 7641 | case 7: |
| 7642 | return 12; |
| 7643 | case 8: |
| 7644 | return 16; |
| 7645 | } |
| 7646 | } |
| 7647 | |
| 7648 | struct dce8_wm_params { |
| 7649 | u32 dram_channels; /* number of dram channels */ |
| 7650 | u32 yclk; /* bandwidth per dram data pin in kHz */ |
| 7651 | u32 sclk; /* engine clock in kHz */ |
| 7652 | u32 disp_clk; /* display clock in kHz */ |
| 7653 | u32 src_width; /* viewport width */ |
| 7654 | u32 active_time; /* active display time in ns */ |
| 7655 | u32 blank_time; /* blank time in ns */ |
| 7656 | bool interlaced; /* mode is interlaced */ |
| 7657 | fixed20_12 vsc; /* vertical scale ratio */ |
| 7658 | u32 num_heads; /* number of active crtcs */ |
| 7659 | u32 bytes_per_pixel; /* bytes per pixel display + overlay */ |
| 7660 | u32 lb_size; /* line buffer allocated to pipe */ |
| 7661 | u32 vtaps; /* vertical scaler taps */ |
| 7662 | }; |
| 7663 | |
| 7664 | /** |
| 7665 | * dce8_dram_bandwidth - get the dram bandwidth |
| 7666 | * |
| 7667 | * @wm: watermark calculation data |
| 7668 | * |
| 7669 | * Calculate the raw dram bandwidth (CIK). |
| 7670 | * Used for display watermark bandwidth calculations |
| 7671 | * Returns the dram bandwidth in MBytes/s |
| 7672 | */ |
| 7673 | static u32 dce8_dram_bandwidth(struct dce8_wm_params *wm) |
| 7674 | { |
| 7675 | /* Calculate raw DRAM Bandwidth */ |
| 7676 | fixed20_12 dram_efficiency; /* 0.7 */ |
| 7677 | fixed20_12 yclk, dram_channels, bandwidth; |
| 7678 | fixed20_12 a; |
| 7679 | |
| 7680 | a.full = dfixed_const(1000); |
| 7681 | yclk.full = dfixed_const(wm->yclk); |
| 7682 | yclk.full = dfixed_div(yclk, a); |
| 7683 | dram_channels.full = dfixed_const(wm->dram_channels * 4); |
| 7684 | a.full = dfixed_const(10); |
| 7685 | dram_efficiency.full = dfixed_const(7); |
| 7686 | dram_efficiency.full = dfixed_div(dram_efficiency, a); |
| 7687 | bandwidth.full = dfixed_mul(dram_channels, yclk); |
| 7688 | bandwidth.full = dfixed_mul(bandwidth, dram_efficiency); |
| 7689 | |
| 7690 | return dfixed_trunc(bandwidth); |
| 7691 | } |
| 7692 | |
| 7693 | /** |
| 7694 | * dce8_dram_bandwidth_for_display - get the dram bandwidth for display |
| 7695 | * |
| 7696 | * @wm: watermark calculation data |
| 7697 | * |
| 7698 | * Calculate the dram bandwidth used for display (CIK). |
| 7699 | * Used for display watermark bandwidth calculations |
| 7700 | * Returns the dram bandwidth for display in MBytes/s |
| 7701 | */ |
| 7702 | static u32 dce8_dram_bandwidth_for_display(struct dce8_wm_params *wm) |
| 7703 | { |
| 7704 | /* Calculate DRAM Bandwidth and the part allocated to display. */ |
| 7705 | fixed20_12 disp_dram_allocation; /* 0.3 to 0.7 */ |
| 7706 | fixed20_12 yclk, dram_channels, bandwidth; |
| 7707 | fixed20_12 a; |
| 7708 | |
| 7709 | a.full = dfixed_const(1000); |
| 7710 | yclk.full = dfixed_const(wm->yclk); |
| 7711 | yclk.full = dfixed_div(yclk, a); |
| 7712 | dram_channels.full = dfixed_const(wm->dram_channels * 4); |
| 7713 | a.full = dfixed_const(10); |
| 7714 | disp_dram_allocation.full = dfixed_const(3); /* XXX worse case value 0.3 */ |
| 7715 | disp_dram_allocation.full = dfixed_div(disp_dram_allocation, a); |
| 7716 | bandwidth.full = dfixed_mul(dram_channels, yclk); |
| 7717 | bandwidth.full = dfixed_mul(bandwidth, disp_dram_allocation); |
| 7718 | |
| 7719 | return dfixed_trunc(bandwidth); |
| 7720 | } |
| 7721 | |
| 7722 | /** |
| 7723 | * dce8_data_return_bandwidth - get the data return bandwidth |
| 7724 | * |
| 7725 | * @wm: watermark calculation data |
| 7726 | * |
| 7727 | * Calculate the data return bandwidth used for display (CIK). |
| 7728 | * Used for display watermark bandwidth calculations |
| 7729 | * Returns the data return bandwidth in MBytes/s |
| 7730 | */ |
| 7731 | static u32 dce8_data_return_bandwidth(struct dce8_wm_params *wm) |
| 7732 | { |
| 7733 | /* Calculate the display Data return Bandwidth */ |
| 7734 | fixed20_12 return_efficiency; /* 0.8 */ |
| 7735 | fixed20_12 sclk, bandwidth; |
| 7736 | fixed20_12 a; |
| 7737 | |
| 7738 | a.full = dfixed_const(1000); |
| 7739 | sclk.full = dfixed_const(wm->sclk); |
| 7740 | sclk.full = dfixed_div(sclk, a); |
| 7741 | a.full = dfixed_const(10); |
| 7742 | return_efficiency.full = dfixed_const(8); |
| 7743 | return_efficiency.full = dfixed_div(return_efficiency, a); |
| 7744 | a.full = dfixed_const(32); |
| 7745 | bandwidth.full = dfixed_mul(a, sclk); |
| 7746 | bandwidth.full = dfixed_mul(bandwidth, return_efficiency); |
| 7747 | |
| 7748 | return dfixed_trunc(bandwidth); |
| 7749 | } |
| 7750 | |
| 7751 | /** |
| 7752 | * dce8_dmif_request_bandwidth - get the dmif bandwidth |
| 7753 | * |
| 7754 | * @wm: watermark calculation data |
| 7755 | * |
| 7756 | * Calculate the dmif bandwidth used for display (CIK). |
| 7757 | * Used for display watermark bandwidth calculations |
| 7758 | * Returns the dmif bandwidth in MBytes/s |
| 7759 | */ |
| 7760 | static u32 dce8_dmif_request_bandwidth(struct dce8_wm_params *wm) |
| 7761 | { |
| 7762 | /* Calculate the DMIF Request Bandwidth */ |
| 7763 | fixed20_12 disp_clk_request_efficiency; /* 0.8 */ |
| 7764 | fixed20_12 disp_clk, bandwidth; |
| 7765 | fixed20_12 a, b; |
| 7766 | |
| 7767 | a.full = dfixed_const(1000); |
| 7768 | disp_clk.full = dfixed_const(wm->disp_clk); |
| 7769 | disp_clk.full = dfixed_div(disp_clk, a); |
| 7770 | a.full = dfixed_const(32); |
| 7771 | b.full = dfixed_mul(a, disp_clk); |
| 7772 | |
| 7773 | a.full = dfixed_const(10); |
| 7774 | disp_clk_request_efficiency.full = dfixed_const(8); |
| 7775 | disp_clk_request_efficiency.full = dfixed_div(disp_clk_request_efficiency, a); |
| 7776 | |
| 7777 | bandwidth.full = dfixed_mul(b, disp_clk_request_efficiency); |
| 7778 | |
| 7779 | return dfixed_trunc(bandwidth); |
| 7780 | } |
| 7781 | |
| 7782 | /** |
| 7783 | * dce8_available_bandwidth - get the min available bandwidth |
| 7784 | * |
| 7785 | * @wm: watermark calculation data |
| 7786 | * |
| 7787 | * Calculate the min available bandwidth used for display (CIK). |
| 7788 | * Used for display watermark bandwidth calculations |
| 7789 | * Returns the min available bandwidth in MBytes/s |
| 7790 | */ |
| 7791 | static u32 dce8_available_bandwidth(struct dce8_wm_params *wm) |
| 7792 | { |
| 7793 | /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */ |
| 7794 | u32 dram_bandwidth = dce8_dram_bandwidth(wm); |
| 7795 | u32 data_return_bandwidth = dce8_data_return_bandwidth(wm); |
| 7796 | u32 dmif_req_bandwidth = dce8_dmif_request_bandwidth(wm); |
| 7797 | |
| 7798 | return min(dram_bandwidth, min(data_return_bandwidth, dmif_req_bandwidth)); |
| 7799 | } |
| 7800 | |
| 7801 | /** |
| 7802 | * dce8_average_bandwidth - get the average available bandwidth |
| 7803 | * |
| 7804 | * @wm: watermark calculation data |
| 7805 | * |
| 7806 | * Calculate the average available bandwidth used for display (CIK). |
| 7807 | * Used for display watermark bandwidth calculations |
| 7808 | * Returns the average available bandwidth in MBytes/s |
| 7809 | */ |
| 7810 | static u32 dce8_average_bandwidth(struct dce8_wm_params *wm) |
| 7811 | { |
| 7812 | /* Calculate the display mode Average Bandwidth |
| 7813 | * DisplayMode should contain the source and destination dimensions, |
| 7814 | * timing, etc. |
| 7815 | */ |
| 7816 | fixed20_12 bpp; |
| 7817 | fixed20_12 line_time; |
| 7818 | fixed20_12 src_width; |
| 7819 | fixed20_12 bandwidth; |
| 7820 | fixed20_12 a; |
| 7821 | |
| 7822 | a.full = dfixed_const(1000); |
| 7823 | line_time.full = dfixed_const(wm->active_time + wm->blank_time); |
| 7824 | line_time.full = dfixed_div(line_time, a); |
| 7825 | bpp.full = dfixed_const(wm->bytes_per_pixel); |
| 7826 | src_width.full = dfixed_const(wm->src_width); |
| 7827 | bandwidth.full = dfixed_mul(src_width, bpp); |
| 7828 | bandwidth.full = dfixed_mul(bandwidth, wm->vsc); |
| 7829 | bandwidth.full = dfixed_div(bandwidth, line_time); |
| 7830 | |
| 7831 | return dfixed_trunc(bandwidth); |
| 7832 | } |
| 7833 | |
| 7834 | /** |
| 7835 | * dce8_latency_watermark - get the latency watermark |
| 7836 | * |
| 7837 | * @wm: watermark calculation data |
| 7838 | * |
| 7839 | * Calculate the latency watermark (CIK). |
| 7840 | * Used for display watermark bandwidth calculations |
| 7841 | * Returns the latency watermark in ns |
| 7842 | */ |
| 7843 | static u32 dce8_latency_watermark(struct dce8_wm_params *wm) |
| 7844 | { |
| 7845 | /* First calculate the latency in ns */ |
| 7846 | u32 mc_latency = 2000; /* 2000 ns. */ |
| 7847 | u32 available_bandwidth = dce8_available_bandwidth(wm); |
| 7848 | u32 worst_chunk_return_time = (512 * 8 * 1000) / available_bandwidth; |
| 7849 | u32 cursor_line_pair_return_time = (128 * 4 * 1000) / available_bandwidth; |
| 7850 | u32 dc_latency = 40000000 / wm->disp_clk; /* dc pipe latency */ |
| 7851 | u32 other_heads_data_return_time = ((wm->num_heads + 1) * worst_chunk_return_time) + |
| 7852 | (wm->num_heads * cursor_line_pair_return_time); |
| 7853 | u32 latency = mc_latency + other_heads_data_return_time + dc_latency; |
| 7854 | u32 max_src_lines_per_dst_line, lb_fill_bw, line_fill_time; |
| 7855 | u32 tmp, dmif_size = 12288; |
| 7856 | fixed20_12 a, b, c; |
| 7857 | |
| 7858 | if (wm->num_heads == 0) |
| 7859 | return 0; |
| 7860 | |
| 7861 | a.full = dfixed_const(2); |
| 7862 | b.full = dfixed_const(1); |
| 7863 | if ((wm->vsc.full > a.full) || |
| 7864 | ((wm->vsc.full > b.full) && (wm->vtaps >= 3)) || |
| 7865 | (wm->vtaps >= 5) || |
| 7866 | ((wm->vsc.full >= a.full) && wm->interlaced)) |
| 7867 | max_src_lines_per_dst_line = 4; |
| 7868 | else |
| 7869 | max_src_lines_per_dst_line = 2; |
| 7870 | |
| 7871 | a.full = dfixed_const(available_bandwidth); |
| 7872 | b.full = dfixed_const(wm->num_heads); |
| 7873 | a.full = dfixed_div(a, b); |
| 7874 | |
| 7875 | b.full = dfixed_const(mc_latency + 512); |
| 7876 | c.full = dfixed_const(wm->disp_clk); |
| 7877 | b.full = dfixed_div(b, c); |
| 7878 | |
| 7879 | c.full = dfixed_const(dmif_size); |
| 7880 | b.full = dfixed_div(c, b); |
| 7881 | |
| 7882 | tmp = min(dfixed_trunc(a), dfixed_trunc(b)); |
| 7883 | |
| 7884 | b.full = dfixed_const(1000); |
| 7885 | c.full = dfixed_const(wm->disp_clk); |
| 7886 | b.full = dfixed_div(c, b); |
| 7887 | c.full = dfixed_const(wm->bytes_per_pixel); |
| 7888 | b.full = dfixed_mul(b, c); |
| 7889 | |
| 7890 | lb_fill_bw = min(tmp, dfixed_trunc(b)); |
| 7891 | |
| 7892 | a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); |
| 7893 | b.full = dfixed_const(1000); |
| 7894 | c.full = dfixed_const(lb_fill_bw); |
| 7895 | b.full = dfixed_div(c, b); |
| 7896 | a.full = dfixed_div(a, b); |
| 7897 | line_fill_time = dfixed_trunc(a); |
| 7898 | |
| 7899 | if (line_fill_time < wm->active_time) |
| 7900 | return latency; |
| 7901 | else |
| 7902 | return latency + (line_fill_time - wm->active_time); |
| 7903 | |
| 7904 | } |
| 7905 | |
| 7906 | /** |
| 7907 | * dce8_average_bandwidth_vs_dram_bandwidth_for_display - check |
| 7908 | * average and available dram bandwidth |
| 7909 | * |
| 7910 | * @wm: watermark calculation data |
| 7911 | * |
| 7912 | * Check if the display average bandwidth fits in the display |
| 7913 | * dram bandwidth (CIK). |
| 7914 | * Used for display watermark bandwidth calculations |
| 7915 | * Returns true if the display fits, false if not. |
| 7916 | */ |
| 7917 | static bool dce8_average_bandwidth_vs_dram_bandwidth_for_display(struct dce8_wm_params *wm) |
| 7918 | { |
| 7919 | if (dce8_average_bandwidth(wm) <= |
| 7920 | (dce8_dram_bandwidth_for_display(wm) / wm->num_heads)) |
| 7921 | return true; |
| 7922 | else |
| 7923 | return false; |
| 7924 | } |
| 7925 | |
| 7926 | /** |
| 7927 | * dce8_average_bandwidth_vs_available_bandwidth - check |
| 7928 | * average and available bandwidth |
| 7929 | * |
| 7930 | * @wm: watermark calculation data |
| 7931 | * |
| 7932 | * Check if the display average bandwidth fits in the display |
| 7933 | * available bandwidth (CIK). |
| 7934 | * Used for display watermark bandwidth calculations |
| 7935 | * Returns true if the display fits, false if not. |
| 7936 | */ |
| 7937 | static bool dce8_average_bandwidth_vs_available_bandwidth(struct dce8_wm_params *wm) |
| 7938 | { |
| 7939 | if (dce8_average_bandwidth(wm) <= |
| 7940 | (dce8_available_bandwidth(wm) / wm->num_heads)) |
| 7941 | return true; |
| 7942 | else |
| 7943 | return false; |
| 7944 | } |
| 7945 | |
| 7946 | /** |
| 7947 | * dce8_check_latency_hiding - check latency hiding |
| 7948 | * |
| 7949 | * @wm: watermark calculation data |
| 7950 | * |
| 7951 | * Check latency hiding (CIK). |
| 7952 | * Used for display watermark bandwidth calculations |
| 7953 | * Returns true if the display fits, false if not. |
| 7954 | */ |
| 7955 | static bool dce8_check_latency_hiding(struct dce8_wm_params *wm) |
| 7956 | { |
| 7957 | u32 lb_partitions = wm->lb_size / wm->src_width; |
| 7958 | u32 line_time = wm->active_time + wm->blank_time; |
| 7959 | u32 latency_tolerant_lines; |
| 7960 | u32 latency_hiding; |
| 7961 | fixed20_12 a; |
| 7962 | |
| 7963 | a.full = dfixed_const(1); |
| 7964 | if (wm->vsc.full > a.full) |
| 7965 | latency_tolerant_lines = 1; |
| 7966 | else { |
| 7967 | if (lb_partitions <= (wm->vtaps + 1)) |
| 7968 | latency_tolerant_lines = 1; |
| 7969 | else |
| 7970 | latency_tolerant_lines = 2; |
| 7971 | } |
| 7972 | |
| 7973 | latency_hiding = (latency_tolerant_lines * line_time + wm->blank_time); |
| 7974 | |
| 7975 | if (dce8_latency_watermark(wm) <= latency_hiding) |
| 7976 | return true; |
| 7977 | else |
| 7978 | return false; |
| 7979 | } |
| 7980 | |
| 7981 | /** |
| 7982 | * dce8_program_watermarks - program display watermarks |
| 7983 | * |
| 7984 | * @rdev: radeon_device pointer |
| 7985 | * @radeon_crtc: the selected display controller |
| 7986 | * @lb_size: line buffer size |
| 7987 | * @num_heads: number of display controllers in use |
| 7988 | * |
| 7989 | * Calculate and program the display watermarks for the |
| 7990 | * selected display controller (CIK). |
| 7991 | */ |
| 7992 | static void dce8_program_watermarks(struct radeon_device *rdev, |
| 7993 | struct radeon_crtc *radeon_crtc, |
| 7994 | u32 lb_size, u32 num_heads) |
| 7995 | { |
| 7996 | struct drm_display_mode *mode = &radeon_crtc->base.mode; |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7997 | struct dce8_wm_params wm_low, wm_high; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7998 | u32 pixel_period; |
| 7999 | u32 line_time = 0; |
| 8000 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
| 8001 | u32 tmp, wm_mask; |
| 8002 | |
| 8003 | if (radeon_crtc->base.enabled && num_heads && mode) { |
| 8004 | pixel_period = 1000000 / (u32)mode->clock; |
| 8005 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); |
| 8006 | |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8007 | /* watermark for high clocks */ |
| 8008 | if ((rdev->pm.pm_method == PM_METHOD_DPM) && |
| 8009 | rdev->pm.dpm_enabled) { |
| 8010 | wm_high.yclk = |
| 8011 | radeon_dpm_get_mclk(rdev, false) * 10; |
| 8012 | wm_high.sclk = |
| 8013 | radeon_dpm_get_sclk(rdev, false) * 10; |
| 8014 | } else { |
| 8015 | wm_high.yclk = rdev->pm.current_mclk * 10; |
| 8016 | wm_high.sclk = rdev->pm.current_sclk * 10; |
| 8017 | } |
| 8018 | |
| 8019 | wm_high.disp_clk = mode->clock; |
| 8020 | wm_high.src_width = mode->crtc_hdisplay; |
| 8021 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; |
| 8022 | wm_high.blank_time = line_time - wm_high.active_time; |
| 8023 | wm_high.interlaced = false; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8024 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8025 | wm_high.interlaced = true; |
| 8026 | wm_high.vsc = radeon_crtc->vsc; |
| 8027 | wm_high.vtaps = 1; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8028 | if (radeon_crtc->rmx_type != RMX_OFF) |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8029 | wm_high.vtaps = 2; |
| 8030 | wm_high.bytes_per_pixel = 4; /* XXX: get this from fb config */ |
| 8031 | wm_high.lb_size = lb_size; |
| 8032 | wm_high.dram_channels = cik_get_number_of_dram_channels(rdev); |
| 8033 | wm_high.num_heads = num_heads; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8034 | |
| 8035 | /* set for high clocks */ |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8036 | latency_watermark_a = min(dce8_latency_watermark(&wm_high), (u32)65535); |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8037 | |
| 8038 | /* possibly force display priority to high */ |
| 8039 | /* should really do this at mode validation time... */ |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8040 | if (!dce8_average_bandwidth_vs_dram_bandwidth_for_display(&wm_high) || |
| 8041 | !dce8_average_bandwidth_vs_available_bandwidth(&wm_high) || |
| 8042 | !dce8_check_latency_hiding(&wm_high) || |
| 8043 | (rdev->disp_priority == 2)) { |
| 8044 | DRM_DEBUG_KMS("force priority to high\n"); |
| 8045 | } |
| 8046 | |
| 8047 | /* watermark for low clocks */ |
| 8048 | if ((rdev->pm.pm_method == PM_METHOD_DPM) && |
| 8049 | rdev->pm.dpm_enabled) { |
| 8050 | wm_low.yclk = |
| 8051 | radeon_dpm_get_mclk(rdev, true) * 10; |
| 8052 | wm_low.sclk = |
| 8053 | radeon_dpm_get_sclk(rdev, true) * 10; |
| 8054 | } else { |
| 8055 | wm_low.yclk = rdev->pm.current_mclk * 10; |
| 8056 | wm_low.sclk = rdev->pm.current_sclk * 10; |
| 8057 | } |
| 8058 | |
| 8059 | wm_low.disp_clk = mode->clock; |
| 8060 | wm_low.src_width = mode->crtc_hdisplay; |
| 8061 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; |
| 8062 | wm_low.blank_time = line_time - wm_low.active_time; |
| 8063 | wm_low.interlaced = false; |
| 8064 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 8065 | wm_low.interlaced = true; |
| 8066 | wm_low.vsc = radeon_crtc->vsc; |
| 8067 | wm_low.vtaps = 1; |
| 8068 | if (radeon_crtc->rmx_type != RMX_OFF) |
| 8069 | wm_low.vtaps = 2; |
| 8070 | wm_low.bytes_per_pixel = 4; /* XXX: get this from fb config */ |
| 8071 | wm_low.lb_size = lb_size; |
| 8072 | wm_low.dram_channels = cik_get_number_of_dram_channels(rdev); |
| 8073 | wm_low.num_heads = num_heads; |
| 8074 | |
| 8075 | /* set for low clocks */ |
| 8076 | latency_watermark_b = min(dce8_latency_watermark(&wm_low), (u32)65535); |
| 8077 | |
| 8078 | /* possibly force display priority to high */ |
| 8079 | /* should really do this at mode validation time... */ |
| 8080 | if (!dce8_average_bandwidth_vs_dram_bandwidth_for_display(&wm_low) || |
| 8081 | !dce8_average_bandwidth_vs_available_bandwidth(&wm_low) || |
| 8082 | !dce8_check_latency_hiding(&wm_low) || |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8083 | (rdev->disp_priority == 2)) { |
| 8084 | DRM_DEBUG_KMS("force priority to high\n"); |
| 8085 | } |
| 8086 | } |
| 8087 | |
| 8088 | /* select wm A */ |
| 8089 | wm_mask = RREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset); |
| 8090 | tmp = wm_mask; |
| 8091 | tmp &= ~LATENCY_WATERMARK_MASK(3); |
| 8092 | tmp |= LATENCY_WATERMARK_MASK(1); |
| 8093 | WREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 8094 | WREG32(DPG_PIPE_LATENCY_CONTROL + radeon_crtc->crtc_offset, |
| 8095 | (LATENCY_LOW_WATERMARK(latency_watermark_a) | |
| 8096 | LATENCY_HIGH_WATERMARK(line_time))); |
| 8097 | /* select wm B */ |
| 8098 | tmp = RREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset); |
| 8099 | tmp &= ~LATENCY_WATERMARK_MASK(3); |
| 8100 | tmp |= LATENCY_WATERMARK_MASK(2); |
| 8101 | WREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 8102 | WREG32(DPG_PIPE_LATENCY_CONTROL + radeon_crtc->crtc_offset, |
| 8103 | (LATENCY_LOW_WATERMARK(latency_watermark_b) | |
| 8104 | LATENCY_HIGH_WATERMARK(line_time))); |
| 8105 | /* restore original selection */ |
| 8106 | WREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset, wm_mask); |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8107 | |
| 8108 | /* save values for DPM */ |
| 8109 | radeon_crtc->line_time = line_time; |
| 8110 | radeon_crtc->wm_high = latency_watermark_a; |
| 8111 | radeon_crtc->wm_low = latency_watermark_b; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8112 | } |
| 8113 | |
| 8114 | /** |
| 8115 | * dce8_bandwidth_update - program display watermarks |
| 8116 | * |
| 8117 | * @rdev: radeon_device pointer |
| 8118 | * |
| 8119 | * Calculate and program the display watermarks and line |
| 8120 | * buffer allocation (CIK). |
| 8121 | */ |
| 8122 | void dce8_bandwidth_update(struct radeon_device *rdev) |
| 8123 | { |
| 8124 | struct drm_display_mode *mode = NULL; |
| 8125 | u32 num_heads = 0, lb_size; |
| 8126 | int i; |
| 8127 | |
| 8128 | radeon_update_display_priority(rdev); |
| 8129 | |
| 8130 | for (i = 0; i < rdev->num_crtc; i++) { |
| 8131 | if (rdev->mode_info.crtcs[i]->base.enabled) |
| 8132 | num_heads++; |
| 8133 | } |
| 8134 | for (i = 0; i < rdev->num_crtc; i++) { |
| 8135 | mode = &rdev->mode_info.crtcs[i]->base.mode; |
| 8136 | lb_size = dce8_line_buffer_adjust(rdev, rdev->mode_info.crtcs[i], mode); |
| 8137 | dce8_program_watermarks(rdev, rdev->mode_info.crtcs[i], lb_size, num_heads); |
| 8138 | } |
| 8139 | } |
Alex Deucher | 44fa346 | 2012-12-18 22:17:00 -0500 | [diff] [blame] | 8140 | |
| 8141 | /** |
| 8142 | * cik_get_gpu_clock_counter - return GPU clock counter snapshot |
| 8143 | * |
| 8144 | * @rdev: radeon_device pointer |
| 8145 | * |
| 8146 | * Fetches a GPU clock counter snapshot (SI). |
| 8147 | * Returns the 64 bit clock counter snapshot. |
| 8148 | */ |
| 8149 | uint64_t cik_get_gpu_clock_counter(struct radeon_device *rdev) |
| 8150 | { |
| 8151 | uint64_t clock; |
| 8152 | |
| 8153 | mutex_lock(&rdev->gpu_clock_mutex); |
| 8154 | WREG32(RLC_CAPTURE_GPU_CLOCK_COUNT, 1); |
| 8155 | clock = (uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_LSB) | |
| 8156 | ((uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_MSB) << 32ULL); |
| 8157 | mutex_unlock(&rdev->gpu_clock_mutex); |
| 8158 | return clock; |
| 8159 | } |
| 8160 | |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8161 | static int cik_set_uvd_clock(struct radeon_device *rdev, u32 clock, |
| 8162 | u32 cntl_reg, u32 status_reg) |
| 8163 | { |
| 8164 | int r, i; |
| 8165 | struct atom_clock_dividers dividers; |
| 8166 | uint32_t tmp; |
| 8167 | |
| 8168 | r = radeon_atom_get_clock_dividers(rdev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, |
| 8169 | clock, false, ÷rs); |
| 8170 | if (r) |
| 8171 | return r; |
| 8172 | |
| 8173 | tmp = RREG32_SMC(cntl_reg); |
| 8174 | tmp &= ~(DCLK_DIR_CNTL_EN|DCLK_DIVIDER_MASK); |
| 8175 | tmp |= dividers.post_divider; |
| 8176 | WREG32_SMC(cntl_reg, tmp); |
| 8177 | |
| 8178 | for (i = 0; i < 100; i++) { |
| 8179 | if (RREG32_SMC(status_reg) & DCLK_STATUS) |
| 8180 | break; |
| 8181 | mdelay(10); |
| 8182 | } |
| 8183 | if (i == 100) |
| 8184 | return -ETIMEDOUT; |
| 8185 | |
| 8186 | return 0; |
| 8187 | } |
| 8188 | |
| 8189 | int cik_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk) |
| 8190 | { |
| 8191 | int r = 0; |
| 8192 | |
| 8193 | r = cik_set_uvd_clock(rdev, vclk, CG_VCLK_CNTL, CG_VCLK_STATUS); |
| 8194 | if (r) |
| 8195 | return r; |
| 8196 | |
| 8197 | r = cik_set_uvd_clock(rdev, dclk, CG_DCLK_CNTL, CG_DCLK_STATUS); |
| 8198 | return r; |
| 8199 | } |
| 8200 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8201 | static void cik_pcie_gen3_enable(struct radeon_device *rdev) |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8202 | { |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8203 | struct pci_dev *root = rdev->pdev->bus->self; |
| 8204 | int bridge_pos, gpu_pos; |
| 8205 | u32 speed_cntl, mask, current_data_rate; |
| 8206 | int ret, i; |
| 8207 | u16 tmp16; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8208 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8209 | if (radeon_pcie_gen2 == 0) |
| 8210 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8211 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8212 | if (rdev->flags & RADEON_IS_IGP) |
| 8213 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8214 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8215 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 8216 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8217 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8218 | ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask); |
| 8219 | if (ret != 0) |
| 8220 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8221 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8222 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) |
| 8223 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8224 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8225 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
| 8226 | current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> |
| 8227 | LC_CURRENT_DATA_RATE_SHIFT; |
| 8228 | if (mask & DRM_PCIE_SPEED_80) { |
| 8229 | if (current_data_rate == 2) { |
| 8230 | DRM_INFO("PCIE gen 3 link speeds already enabled\n"); |
| 8231 | return; |
| 8232 | } |
| 8233 | DRM_INFO("enabling PCIE gen 3 link speeds, disable with radeon.pcie_gen2=0\n"); |
| 8234 | } else if (mask & DRM_PCIE_SPEED_50) { |
| 8235 | if (current_data_rate == 1) { |
| 8236 | DRM_INFO("PCIE gen 2 link speeds already enabled\n"); |
| 8237 | return; |
| 8238 | } |
| 8239 | DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n"); |
| 8240 | } |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8241 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8242 | bridge_pos = pci_pcie_cap(root); |
| 8243 | if (!bridge_pos) |
| 8244 | return; |
| 8245 | |
| 8246 | gpu_pos = pci_pcie_cap(rdev->pdev); |
| 8247 | if (!gpu_pos) |
| 8248 | return; |
| 8249 | |
| 8250 | if (mask & DRM_PCIE_SPEED_80) { |
| 8251 | /* re-try equalization if gen3 is not already enabled */ |
| 8252 | if (current_data_rate != 2) { |
| 8253 | u16 bridge_cfg, gpu_cfg; |
| 8254 | u16 bridge_cfg2, gpu_cfg2; |
| 8255 | u32 max_lw, current_lw, tmp; |
| 8256 | |
| 8257 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); |
| 8258 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); |
| 8259 | |
| 8260 | tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD; |
| 8261 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); |
| 8262 | |
| 8263 | tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD; |
| 8264 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); |
| 8265 | |
| 8266 | tmp = RREG32_PCIE_PORT(PCIE_LC_STATUS1); |
| 8267 | max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; |
| 8268 | current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; |
| 8269 | |
| 8270 | if (current_lw < max_lw) { |
| 8271 | tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
| 8272 | if (tmp & LC_RENEGOTIATION_SUPPORT) { |
| 8273 | tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); |
| 8274 | tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); |
| 8275 | tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; |
| 8276 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); |
| 8277 | } |
| 8278 | } |
| 8279 | |
| 8280 | for (i = 0; i < 10; i++) { |
| 8281 | /* check status */ |
| 8282 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16); |
| 8283 | if (tmp16 & PCI_EXP_DEVSTA_TRPND) |
| 8284 | break; |
| 8285 | |
| 8286 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); |
| 8287 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); |
| 8288 | |
| 8289 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); |
| 8290 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); |
| 8291 | |
| 8292 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
| 8293 | tmp |= LC_SET_QUIESCE; |
| 8294 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
| 8295 | |
| 8296 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
| 8297 | tmp |= LC_REDO_EQ; |
| 8298 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
| 8299 | |
| 8300 | mdelay(100); |
| 8301 | |
| 8302 | /* linkctl */ |
| 8303 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16); |
| 8304 | tmp16 &= ~PCI_EXP_LNKCTL_HAWD; |
| 8305 | tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD); |
| 8306 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); |
| 8307 | |
| 8308 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16); |
| 8309 | tmp16 &= ~PCI_EXP_LNKCTL_HAWD; |
| 8310 | tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD); |
| 8311 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); |
| 8312 | |
| 8313 | /* linkctl2 */ |
| 8314 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16); |
| 8315 | tmp16 &= ~((1 << 4) | (7 << 9)); |
| 8316 | tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9))); |
| 8317 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16); |
| 8318 | |
| 8319 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); |
| 8320 | tmp16 &= ~((1 << 4) | (7 << 9)); |
| 8321 | tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); |
| 8322 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); |
| 8323 | |
| 8324 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
| 8325 | tmp &= ~LC_SET_QUIESCE; |
| 8326 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
| 8327 | } |
| 8328 | } |
| 8329 | } |
| 8330 | |
| 8331 | /* set the link speed */ |
| 8332 | speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; |
| 8333 | speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; |
| 8334 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 8335 | |
| 8336 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); |
| 8337 | tmp16 &= ~0xf; |
| 8338 | if (mask & DRM_PCIE_SPEED_80) |
| 8339 | tmp16 |= 3; /* gen3 */ |
| 8340 | else if (mask & DRM_PCIE_SPEED_50) |
| 8341 | tmp16 |= 2; /* gen2 */ |
| 8342 | else |
| 8343 | tmp16 |= 1; /* gen1 */ |
| 8344 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); |
| 8345 | |
| 8346 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
| 8347 | speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; |
| 8348 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 8349 | |
| 8350 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 8351 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
| 8352 | if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) |
| 8353 | break; |
| 8354 | udelay(1); |
| 8355 | } |
| 8356 | } |
Alex Deucher | 7235711a4 | 2013-04-04 13:58:09 -0400 | [diff] [blame] | 8357 | |
| 8358 | static void cik_program_aspm(struct radeon_device *rdev) |
| 8359 | { |
| 8360 | u32 data, orig; |
| 8361 | bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; |
| 8362 | bool disable_clkreq = false; |
| 8363 | |
| 8364 | if (radeon_aspm == 0) |
| 8365 | return; |
| 8366 | |
| 8367 | /* XXX double check IGPs */ |
| 8368 | if (rdev->flags & RADEON_IS_IGP) |
| 8369 | return; |
| 8370 | |
| 8371 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 8372 | return; |
| 8373 | |
| 8374 | orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); |
| 8375 | data &= ~LC_XMIT_N_FTS_MASK; |
| 8376 | data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; |
| 8377 | if (orig != data) |
| 8378 | WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); |
| 8379 | |
| 8380 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); |
| 8381 | data |= LC_GO_TO_RECOVERY; |
| 8382 | if (orig != data) |
| 8383 | WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); |
| 8384 | |
| 8385 | orig = data = RREG32_PCIE_PORT(PCIE_P_CNTL); |
| 8386 | data |= P_IGNORE_EDB_ERR; |
| 8387 | if (orig != data) |
| 8388 | WREG32_PCIE_PORT(PCIE_P_CNTL, data); |
| 8389 | |
| 8390 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); |
| 8391 | data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); |
| 8392 | data |= LC_PMI_TO_L1_DIS; |
| 8393 | if (!disable_l0s) |
| 8394 | data |= LC_L0S_INACTIVITY(7); |
| 8395 | |
| 8396 | if (!disable_l1) { |
| 8397 | data |= LC_L1_INACTIVITY(7); |
| 8398 | data &= ~LC_PMI_TO_L1_DIS; |
| 8399 | if (orig != data) |
| 8400 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
| 8401 | |
| 8402 | if (!disable_plloff_in_l1) { |
| 8403 | bool clk_req_support; |
| 8404 | |
| 8405 | orig = data = RREG32_PCIE_PORT(PB0_PIF_PWRDOWN_0); |
| 8406 | data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); |
| 8407 | data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); |
| 8408 | if (orig != data) |
| 8409 | WREG32_PCIE_PORT(PB0_PIF_PWRDOWN_0, data); |
| 8410 | |
| 8411 | orig = data = RREG32_PCIE_PORT(PB0_PIF_PWRDOWN_1); |
| 8412 | data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); |
| 8413 | data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); |
| 8414 | if (orig != data) |
| 8415 | WREG32_PCIE_PORT(PB0_PIF_PWRDOWN_1, data); |
| 8416 | |
| 8417 | orig = data = RREG32_PCIE_PORT(PB1_PIF_PWRDOWN_0); |
| 8418 | data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); |
| 8419 | data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); |
| 8420 | if (orig != data) |
| 8421 | WREG32_PCIE_PORT(PB1_PIF_PWRDOWN_0, data); |
| 8422 | |
| 8423 | orig = data = RREG32_PCIE_PORT(PB1_PIF_PWRDOWN_1); |
| 8424 | data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); |
| 8425 | data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); |
| 8426 | if (orig != data) |
| 8427 | WREG32_PCIE_PORT(PB1_PIF_PWRDOWN_1, data); |
| 8428 | |
| 8429 | orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
| 8430 | data &= ~LC_DYN_LANES_PWR_STATE_MASK; |
| 8431 | data |= LC_DYN_LANES_PWR_STATE(3); |
| 8432 | if (orig != data) |
| 8433 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); |
| 8434 | |
| 8435 | if (!disable_clkreq) { |
| 8436 | struct pci_dev *root = rdev->pdev->bus->self; |
| 8437 | u32 lnkcap; |
| 8438 | |
| 8439 | clk_req_support = false; |
| 8440 | pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); |
| 8441 | if (lnkcap & PCI_EXP_LNKCAP_CLKPM) |
| 8442 | clk_req_support = true; |
| 8443 | } else { |
| 8444 | clk_req_support = false; |
| 8445 | } |
| 8446 | |
| 8447 | if (clk_req_support) { |
| 8448 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); |
| 8449 | data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; |
| 8450 | if (orig != data) |
| 8451 | WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); |
| 8452 | |
| 8453 | orig = data = RREG32_SMC(THM_CLK_CNTL); |
| 8454 | data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); |
| 8455 | data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); |
| 8456 | if (orig != data) |
| 8457 | WREG32_SMC(THM_CLK_CNTL, data); |
| 8458 | |
| 8459 | orig = data = RREG32_SMC(MISC_CLK_CTRL); |
| 8460 | data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); |
| 8461 | data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); |
| 8462 | if (orig != data) |
| 8463 | WREG32_SMC(MISC_CLK_CTRL, data); |
| 8464 | |
| 8465 | orig = data = RREG32_SMC(CG_CLKPIN_CNTL); |
| 8466 | data &= ~BCLK_AS_XCLK; |
| 8467 | if (orig != data) |
| 8468 | WREG32_SMC(CG_CLKPIN_CNTL, data); |
| 8469 | |
| 8470 | orig = data = RREG32_SMC(CG_CLKPIN_CNTL_2); |
| 8471 | data &= ~FORCE_BIF_REFCLK_EN; |
| 8472 | if (orig != data) |
| 8473 | WREG32_SMC(CG_CLKPIN_CNTL_2, data); |
| 8474 | |
| 8475 | orig = data = RREG32_SMC(MPLL_BYPASSCLK_SEL); |
| 8476 | data &= ~MPLL_CLKOUT_SEL_MASK; |
| 8477 | data |= MPLL_CLKOUT_SEL(4); |
| 8478 | if (orig != data) |
| 8479 | WREG32_SMC(MPLL_BYPASSCLK_SEL, data); |
| 8480 | } |
| 8481 | } |
| 8482 | } else { |
| 8483 | if (orig != data) |
| 8484 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
| 8485 | } |
| 8486 | |
| 8487 | orig = data = RREG32_PCIE_PORT(PCIE_CNTL2); |
| 8488 | data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; |
| 8489 | if (orig != data) |
| 8490 | WREG32_PCIE_PORT(PCIE_CNTL2, data); |
| 8491 | |
| 8492 | if (!disable_l0s) { |
| 8493 | data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); |
| 8494 | if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { |
| 8495 | data = RREG32_PCIE_PORT(PCIE_LC_STATUS1); |
| 8496 | if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { |
| 8497 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); |
| 8498 | data &= ~LC_L0S_INACTIVITY_MASK; |
| 8499 | if (orig != data) |
| 8500 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
| 8501 | } |
| 8502 | } |
| 8503 | } |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8504 | } |