Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/slab.h> |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 29 | #include <linux/seq_file.h> |
| 30 | #include <linux/firmware.h> |
Paul Gortmaker | e0cd360 | 2011-08-30 11:04:30 -0400 | [diff] [blame] | 31 | #include <linux/module.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 32 | #include <drm/drmP.h> |
| 33 | #include <drm/radeon_drm.h> |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 34 | #include "radeon.h" |
Daniel Vetter | e699037 | 2010-03-11 21:19:17 +0000 | [diff] [blame] | 35 | #include "radeon_asic.h" |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 36 | #include "radeon_mode.h" |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 37 | #include "r600d.h" |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 38 | #include "atom.h" |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 39 | #include "avivod.h" |
Alex Deucher | 138e4e1 | 2013-01-11 15:33:13 -0500 | [diff] [blame] | 40 | #include "radeon_ucode.h" |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 41 | |
| 42 | /* Firmware Names */ |
| 43 | MODULE_FIRMWARE("radeon/R600_pfp.bin"); |
| 44 | MODULE_FIRMWARE("radeon/R600_me.bin"); |
| 45 | MODULE_FIRMWARE("radeon/RV610_pfp.bin"); |
| 46 | MODULE_FIRMWARE("radeon/RV610_me.bin"); |
| 47 | MODULE_FIRMWARE("radeon/RV630_pfp.bin"); |
| 48 | MODULE_FIRMWARE("radeon/RV630_me.bin"); |
| 49 | MODULE_FIRMWARE("radeon/RV620_pfp.bin"); |
| 50 | MODULE_FIRMWARE("radeon/RV620_me.bin"); |
| 51 | MODULE_FIRMWARE("radeon/RV635_pfp.bin"); |
| 52 | MODULE_FIRMWARE("radeon/RV635_me.bin"); |
| 53 | MODULE_FIRMWARE("radeon/RV670_pfp.bin"); |
| 54 | MODULE_FIRMWARE("radeon/RV670_me.bin"); |
| 55 | MODULE_FIRMWARE("radeon/RS780_pfp.bin"); |
| 56 | MODULE_FIRMWARE("radeon/RS780_me.bin"); |
| 57 | MODULE_FIRMWARE("radeon/RV770_pfp.bin"); |
| 58 | MODULE_FIRMWARE("radeon/RV770_me.bin"); |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 59 | MODULE_FIRMWARE("radeon/RV770_smc.bin"); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 60 | MODULE_FIRMWARE("radeon/RV730_pfp.bin"); |
| 61 | MODULE_FIRMWARE("radeon/RV730_me.bin"); |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 62 | MODULE_FIRMWARE("radeon/RV730_smc.bin"); |
| 63 | MODULE_FIRMWARE("radeon/RV740_smc.bin"); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 64 | MODULE_FIRMWARE("radeon/RV710_pfp.bin"); |
| 65 | MODULE_FIRMWARE("radeon/RV710_me.bin"); |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 66 | MODULE_FIRMWARE("radeon/RV710_smc.bin"); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 67 | MODULE_FIRMWARE("radeon/R600_rlc.bin"); |
| 68 | MODULE_FIRMWARE("radeon/R700_rlc.bin"); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 69 | MODULE_FIRMWARE("radeon/CEDAR_pfp.bin"); |
| 70 | MODULE_FIRMWARE("radeon/CEDAR_me.bin"); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 71 | MODULE_FIRMWARE("radeon/CEDAR_rlc.bin"); |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 72 | MODULE_FIRMWARE("radeon/CEDAR_smc.bin"); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 73 | MODULE_FIRMWARE("radeon/REDWOOD_pfp.bin"); |
| 74 | MODULE_FIRMWARE("radeon/REDWOOD_me.bin"); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 75 | MODULE_FIRMWARE("radeon/REDWOOD_rlc.bin"); |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 76 | MODULE_FIRMWARE("radeon/REDWOOD_smc.bin"); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 77 | MODULE_FIRMWARE("radeon/JUNIPER_pfp.bin"); |
| 78 | MODULE_FIRMWARE("radeon/JUNIPER_me.bin"); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 79 | MODULE_FIRMWARE("radeon/JUNIPER_rlc.bin"); |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 80 | MODULE_FIRMWARE("radeon/JUNIPER_smc.bin"); |
Dave Airlie | a743374 | 2010-04-09 15:31:09 +1000 | [diff] [blame] | 81 | MODULE_FIRMWARE("radeon/CYPRESS_pfp.bin"); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 82 | MODULE_FIRMWARE("radeon/CYPRESS_me.bin"); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 83 | MODULE_FIRMWARE("radeon/CYPRESS_rlc.bin"); |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 84 | MODULE_FIRMWARE("radeon/CYPRESS_smc.bin"); |
Alex Deucher | 439bd6c | 2010-11-22 17:56:31 -0500 | [diff] [blame] | 85 | MODULE_FIRMWARE("radeon/PALM_pfp.bin"); |
| 86 | MODULE_FIRMWARE("radeon/PALM_me.bin"); |
| 87 | MODULE_FIRMWARE("radeon/SUMO_rlc.bin"); |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 88 | MODULE_FIRMWARE("radeon/SUMO_pfp.bin"); |
| 89 | MODULE_FIRMWARE("radeon/SUMO_me.bin"); |
| 90 | MODULE_FIRMWARE("radeon/SUMO2_pfp.bin"); |
| 91 | MODULE_FIRMWARE("radeon/SUMO2_me.bin"); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 92 | |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 93 | static const u32 crtc_offsets[2] = |
| 94 | { |
| 95 | 0, |
| 96 | AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL |
| 97 | }; |
| 98 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 99 | int r600_debugfs_mc_info_init(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 100 | |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 101 | /* r600,rv610,rv630,rv620,rv635,rv670 */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 102 | int r600_mc_wait_for_idle(struct radeon_device *rdev); |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 103 | static void r600_gpu_init(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 104 | void r600_fini(struct radeon_device *rdev); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 105 | void r600_irq_disable(struct radeon_device *rdev); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 106 | static void r600_pcie_gen2_enable(struct radeon_device *rdev); |
Alex Deucher | 2948f5e | 2013-04-12 13:52:52 -0400 | [diff] [blame] | 107 | extern int evergreen_rlc_resume(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 108 | |
Alex Deucher | 454d2e2 | 2013-02-14 10:04:02 -0500 | [diff] [blame] | 109 | /** |
| 110 | * r600_get_xclk - get the xclk |
| 111 | * |
| 112 | * @rdev: radeon_device pointer |
| 113 | * |
| 114 | * Returns the reference clock used by the gfx engine |
| 115 | * (r6xx, IGPs, APUs). |
| 116 | */ |
| 117 | u32 r600_get_xclk(struct radeon_device *rdev) |
| 118 | { |
| 119 | return rdev->clock.spll.reference_freq; |
| 120 | } |
| 121 | |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 122 | /* get temperature in millidegrees */ |
Alex Deucher | 20d391d | 2011-02-01 16:12:34 -0500 | [diff] [blame] | 123 | int rv6xx_get_temp(struct radeon_device *rdev) |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 124 | { |
| 125 | u32 temp = (RREG32(CG_THERMAL_STATUS) & ASIC_T_MASK) >> |
| 126 | ASIC_T_SHIFT; |
Alex Deucher | 20d391d | 2011-02-01 16:12:34 -0500 | [diff] [blame] | 127 | int actual_temp = temp & 0xff; |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 128 | |
Alex Deucher | 20d391d | 2011-02-01 16:12:34 -0500 | [diff] [blame] | 129 | if (temp & 0x100) |
| 130 | actual_temp -= 256; |
| 131 | |
| 132 | return actual_temp * 1000; |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 133 | } |
| 134 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 135 | void r600_pm_get_dynpm_state(struct radeon_device *rdev) |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 136 | { |
| 137 | int i; |
| 138 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 139 | rdev->pm.dynpm_can_upclock = true; |
| 140 | rdev->pm.dynpm_can_downclock = true; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 141 | |
| 142 | /* power state array is low to high, default is first */ |
| 143 | if ((rdev->flags & RADEON_IS_IGP) || (rdev->family == CHIP_R600)) { |
| 144 | int min_power_state_index = 0; |
| 145 | |
| 146 | if (rdev->pm.num_power_states > 2) |
| 147 | min_power_state_index = 1; |
| 148 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 149 | switch (rdev->pm.dynpm_planned_action) { |
| 150 | case DYNPM_ACTION_MINIMUM: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 151 | rdev->pm.requested_power_state_index = min_power_state_index; |
| 152 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 153 | rdev->pm.dynpm_can_downclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 154 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 155 | case DYNPM_ACTION_DOWNCLOCK: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 156 | if (rdev->pm.current_power_state_index == min_power_state_index) { |
| 157 | rdev->pm.requested_power_state_index = rdev->pm.current_power_state_index; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 158 | rdev->pm.dynpm_can_downclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 159 | } else { |
| 160 | if (rdev->pm.active_crtc_count > 1) { |
| 161 | for (i = 0; i < rdev->pm.num_power_states; i++) { |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 162 | if (rdev->pm.power_state[i].flags & RADEON_PM_STATE_SINGLE_DISPLAY_ONLY) |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 163 | continue; |
| 164 | else if (i >= rdev->pm.current_power_state_index) { |
| 165 | rdev->pm.requested_power_state_index = |
| 166 | rdev->pm.current_power_state_index; |
| 167 | break; |
| 168 | } else { |
| 169 | rdev->pm.requested_power_state_index = i; |
| 170 | break; |
| 171 | } |
| 172 | } |
Alex Deucher | 773c3fa | 2010-06-25 16:21:27 -0400 | [diff] [blame] | 173 | } else { |
| 174 | if (rdev->pm.current_power_state_index == 0) |
| 175 | rdev->pm.requested_power_state_index = |
| 176 | rdev->pm.num_power_states - 1; |
| 177 | else |
| 178 | rdev->pm.requested_power_state_index = |
| 179 | rdev->pm.current_power_state_index - 1; |
| 180 | } |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 181 | } |
| 182 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 183 | /* don't use the power state if crtcs are active and no display flag is set */ |
| 184 | if ((rdev->pm.active_crtc_count > 0) && |
| 185 | (rdev->pm.power_state[rdev->pm.requested_power_state_index]. |
| 186 | clock_info[rdev->pm.requested_clock_mode_index].flags & |
| 187 | RADEON_PM_MODE_NO_DISPLAY)) { |
| 188 | rdev->pm.requested_power_state_index++; |
| 189 | } |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 190 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 191 | case DYNPM_ACTION_UPCLOCK: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 192 | if (rdev->pm.current_power_state_index == (rdev->pm.num_power_states - 1)) { |
| 193 | rdev->pm.requested_power_state_index = rdev->pm.current_power_state_index; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 194 | rdev->pm.dynpm_can_upclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 195 | } else { |
| 196 | if (rdev->pm.active_crtc_count > 1) { |
| 197 | for (i = (rdev->pm.num_power_states - 1); i >= 0; i--) { |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 198 | if (rdev->pm.power_state[i].flags & RADEON_PM_STATE_SINGLE_DISPLAY_ONLY) |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 199 | continue; |
| 200 | else if (i <= rdev->pm.current_power_state_index) { |
| 201 | rdev->pm.requested_power_state_index = |
| 202 | rdev->pm.current_power_state_index; |
| 203 | break; |
| 204 | } else { |
| 205 | rdev->pm.requested_power_state_index = i; |
| 206 | break; |
| 207 | } |
| 208 | } |
| 209 | } else |
| 210 | rdev->pm.requested_power_state_index = |
| 211 | rdev->pm.current_power_state_index + 1; |
| 212 | } |
| 213 | rdev->pm.requested_clock_mode_index = 0; |
| 214 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 215 | case DYNPM_ACTION_DEFAULT: |
Alex Deucher | 58e21df | 2010-03-22 13:31:08 -0400 | [diff] [blame] | 216 | rdev->pm.requested_power_state_index = rdev->pm.default_power_state_index; |
| 217 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 218 | rdev->pm.dynpm_can_upclock = false; |
Alex Deucher | 58e21df | 2010-03-22 13:31:08 -0400 | [diff] [blame] | 219 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 220 | case DYNPM_ACTION_NONE: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 221 | default: |
| 222 | DRM_ERROR("Requested mode for not defined action\n"); |
| 223 | return; |
| 224 | } |
| 225 | } else { |
| 226 | /* XXX select a power state based on AC/DC, single/dualhead, etc. */ |
| 227 | /* for now just select the first power state and switch between clock modes */ |
| 228 | /* power state array is low to high, default is first (0) */ |
| 229 | if (rdev->pm.active_crtc_count > 1) { |
| 230 | rdev->pm.requested_power_state_index = -1; |
| 231 | /* start at 1 as we don't want the default mode */ |
| 232 | for (i = 1; i < rdev->pm.num_power_states; i++) { |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 233 | if (rdev->pm.power_state[i].flags & RADEON_PM_STATE_SINGLE_DISPLAY_ONLY) |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 234 | continue; |
| 235 | else if ((rdev->pm.power_state[i].type == POWER_STATE_TYPE_PERFORMANCE) || |
| 236 | (rdev->pm.power_state[i].type == POWER_STATE_TYPE_BATTERY)) { |
| 237 | rdev->pm.requested_power_state_index = i; |
| 238 | break; |
| 239 | } |
| 240 | } |
| 241 | /* if nothing selected, grab the default state. */ |
| 242 | if (rdev->pm.requested_power_state_index == -1) |
| 243 | rdev->pm.requested_power_state_index = 0; |
| 244 | } else |
| 245 | rdev->pm.requested_power_state_index = 1; |
| 246 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 247 | switch (rdev->pm.dynpm_planned_action) { |
| 248 | case DYNPM_ACTION_MINIMUM: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 249 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 250 | rdev->pm.dynpm_can_downclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 251 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 252 | case DYNPM_ACTION_DOWNCLOCK: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 253 | if (rdev->pm.requested_power_state_index == rdev->pm.current_power_state_index) { |
| 254 | if (rdev->pm.current_clock_mode_index == 0) { |
| 255 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 256 | rdev->pm.dynpm_can_downclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 257 | } else |
| 258 | rdev->pm.requested_clock_mode_index = |
| 259 | rdev->pm.current_clock_mode_index - 1; |
| 260 | } else { |
| 261 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 262 | rdev->pm.dynpm_can_downclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 263 | } |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 264 | /* don't use the power state if crtcs are active and no display flag is set */ |
| 265 | if ((rdev->pm.active_crtc_count > 0) && |
| 266 | (rdev->pm.power_state[rdev->pm.requested_power_state_index]. |
| 267 | clock_info[rdev->pm.requested_clock_mode_index].flags & |
| 268 | RADEON_PM_MODE_NO_DISPLAY)) { |
| 269 | rdev->pm.requested_clock_mode_index++; |
| 270 | } |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 271 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 272 | case DYNPM_ACTION_UPCLOCK: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 273 | if (rdev->pm.requested_power_state_index == rdev->pm.current_power_state_index) { |
| 274 | if (rdev->pm.current_clock_mode_index == |
| 275 | (rdev->pm.power_state[rdev->pm.requested_power_state_index].num_clock_modes - 1)) { |
| 276 | rdev->pm.requested_clock_mode_index = rdev->pm.current_clock_mode_index; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 277 | rdev->pm.dynpm_can_upclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 278 | } else |
| 279 | rdev->pm.requested_clock_mode_index = |
| 280 | rdev->pm.current_clock_mode_index + 1; |
| 281 | } else { |
| 282 | rdev->pm.requested_clock_mode_index = |
| 283 | rdev->pm.power_state[rdev->pm.requested_power_state_index].num_clock_modes - 1; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 284 | rdev->pm.dynpm_can_upclock = false; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 285 | } |
| 286 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 287 | case DYNPM_ACTION_DEFAULT: |
Alex Deucher | 58e21df | 2010-03-22 13:31:08 -0400 | [diff] [blame] | 288 | rdev->pm.requested_power_state_index = rdev->pm.default_power_state_index; |
| 289 | rdev->pm.requested_clock_mode_index = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 290 | rdev->pm.dynpm_can_upclock = false; |
Alex Deucher | 58e21df | 2010-03-22 13:31:08 -0400 | [diff] [blame] | 291 | break; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 292 | case DYNPM_ACTION_NONE: |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 293 | default: |
| 294 | DRM_ERROR("Requested mode for not defined action\n"); |
| 295 | return; |
| 296 | } |
| 297 | } |
| 298 | |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 299 | DRM_DEBUG_DRIVER("Requested: e: %d m: %d p: %d\n", |
Alex Deucher | ce8a3eb | 2010-05-07 16:58:27 -0400 | [diff] [blame] | 300 | rdev->pm.power_state[rdev->pm.requested_power_state_index]. |
| 301 | clock_info[rdev->pm.requested_clock_mode_index].sclk, |
| 302 | rdev->pm.power_state[rdev->pm.requested_power_state_index]. |
| 303 | clock_info[rdev->pm.requested_clock_mode_index].mclk, |
| 304 | rdev->pm.power_state[rdev->pm.requested_power_state_index]. |
| 305 | pcie_lanes); |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 306 | } |
| 307 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 308 | void rs780_pm_init_profile(struct radeon_device *rdev) |
| 309 | { |
| 310 | if (rdev->pm.num_power_states == 2) { |
| 311 | /* default */ |
| 312 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 313 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 314 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
| 315 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 0; |
| 316 | /* low sh */ |
| 317 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = 0; |
| 318 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = 0; |
| 319 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
| 320 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 321 | /* mid sh */ |
| 322 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = 0; |
| 323 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = 0; |
| 324 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 325 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 326 | /* high sh */ |
| 327 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = 0; |
| 328 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = 1; |
| 329 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
| 330 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = 0; |
| 331 | /* low mh */ |
| 332 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = 0; |
| 333 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = 0; |
| 334 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
| 335 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 336 | /* mid mh */ |
| 337 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = 0; |
| 338 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = 0; |
| 339 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 340 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 341 | /* high mh */ |
| 342 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = 0; |
| 343 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = 1; |
| 344 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
| 345 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = 0; |
| 346 | } else if (rdev->pm.num_power_states == 3) { |
| 347 | /* default */ |
| 348 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 349 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 350 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
| 351 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 0; |
| 352 | /* low sh */ |
| 353 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = 1; |
| 354 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = 1; |
| 355 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
| 356 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 357 | /* mid sh */ |
| 358 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = 1; |
| 359 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = 1; |
| 360 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 361 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 362 | /* high sh */ |
| 363 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = 1; |
| 364 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = 2; |
| 365 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
| 366 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = 0; |
| 367 | /* low mh */ |
| 368 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = 1; |
| 369 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = 1; |
| 370 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
| 371 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 372 | /* mid mh */ |
| 373 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = 1; |
| 374 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = 1; |
| 375 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 376 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 377 | /* high mh */ |
| 378 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = 1; |
| 379 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = 2; |
| 380 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
| 381 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = 0; |
| 382 | } else { |
| 383 | /* default */ |
| 384 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 385 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 386 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
| 387 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 0; |
| 388 | /* low sh */ |
| 389 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = 2; |
| 390 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = 2; |
| 391 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
| 392 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 393 | /* mid sh */ |
| 394 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = 2; |
| 395 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = 2; |
| 396 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 397 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 398 | /* high sh */ |
| 399 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = 2; |
| 400 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = 3; |
| 401 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
| 402 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = 0; |
| 403 | /* low mh */ |
| 404 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = 2; |
| 405 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = 0; |
| 406 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
| 407 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 408 | /* mid mh */ |
| 409 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = 2; |
| 410 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = 0; |
| 411 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 412 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 413 | /* high mh */ |
| 414 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = 2; |
| 415 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = 3; |
| 416 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
| 417 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = 0; |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | void r600_pm_init_profile(struct radeon_device *rdev) |
| 422 | { |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 423 | int idx; |
| 424 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 425 | if (rdev->family == CHIP_R600) { |
| 426 | /* XXX */ |
| 427 | /* default */ |
| 428 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 429 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 430 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 431 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 432 | /* low sh */ |
| 433 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 434 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 435 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 436 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 437 | /* mid sh */ |
| 438 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 439 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 440 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 441 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 442 | /* high sh */ |
| 443 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 444 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 445 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 446 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 447 | /* low mh */ |
| 448 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 449 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 450 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 451 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 452 | /* mid mh */ |
| 453 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 454 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 455 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 456 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 457 | /* high mh */ |
| 458 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 459 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 460 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 461 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 462 | } else { |
| 463 | if (rdev->pm.num_power_states < 4) { |
| 464 | /* default */ |
| 465 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 466 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 467 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
| 468 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 2; |
| 469 | /* low sh */ |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 470 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = 1; |
| 471 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = 1; |
| 472 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 473 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
| 474 | /* mid sh */ |
| 475 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = 1; |
| 476 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = 1; |
| 477 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 478 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 1; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 479 | /* high sh */ |
| 480 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = 1; |
| 481 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = 1; |
| 482 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
| 483 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = 2; |
| 484 | /* low mh */ |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 485 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = 2; |
| 486 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = 2; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 487 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 488 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
| 489 | /* low mh */ |
| 490 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = 2; |
| 491 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = 2; |
| 492 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 493 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 1; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 494 | /* high mh */ |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 495 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = 2; |
| 496 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = 2; |
| 497 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
| 498 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = 2; |
| 499 | } else { |
| 500 | /* default */ |
| 501 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 502 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 503 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
| 504 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 2; |
| 505 | /* low sh */ |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 506 | if (rdev->flags & RADEON_IS_MOBILITY) |
| 507 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_BATTERY, 0); |
| 508 | else |
| 509 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_PERFORMANCE, 0); |
| 510 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = idx; |
| 511 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = idx; |
| 512 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
| 513 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 514 | /* mid sh */ |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 515 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = idx; |
| 516 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = idx; |
| 517 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 518 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 1; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 519 | /* high sh */ |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 520 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_PERFORMANCE, 0); |
| 521 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = idx; |
| 522 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = idx; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 523 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
| 524 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = 2; |
| 525 | /* low mh */ |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 526 | if (rdev->flags & RADEON_IS_MOBILITY) |
| 527 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_BATTERY, 1); |
| 528 | else |
| 529 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_PERFORMANCE, 1); |
| 530 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = idx; |
| 531 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = idx; |
| 532 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
| 533 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame] | 534 | /* mid mh */ |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 535 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = idx; |
| 536 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = idx; |
| 537 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 538 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 1; |
Alex Deucher | 4bff517 | 2010-05-17 19:41:26 -0400 | [diff] [blame] | 539 | /* high mh */ |
Alex Deucher | bbe26ff | 2011-11-04 10:09:42 -0400 | [diff] [blame] | 540 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_PERFORMANCE, 1); |
| 541 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = idx; |
| 542 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = idx; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 543 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
| 544 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = 2; |
| 545 | } |
| 546 | } |
Alex Deucher | bae6b562 | 2010-04-22 13:38:05 -0400 | [diff] [blame] | 547 | } |
| 548 | |
Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 549 | void r600_pm_misc(struct radeon_device *rdev) |
| 550 | { |
Rafał Miłecki | a081a9d | 2010-06-07 18:20:25 -0400 | [diff] [blame] | 551 | int req_ps_idx = rdev->pm.requested_power_state_index; |
| 552 | int req_cm_idx = rdev->pm.requested_clock_mode_index; |
| 553 | struct radeon_power_state *ps = &rdev->pm.power_state[req_ps_idx]; |
| 554 | struct radeon_voltage *voltage = &ps->clock_info[req_cm_idx].voltage; |
Alex Deucher | 7ac9aa5 | 2010-05-27 19:25:54 -0400 | [diff] [blame] | 555 | |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 556 | if ((voltage->type == VOLTAGE_SW) && voltage->voltage) { |
Alex Deucher | a377e18 | 2011-06-20 13:00:31 -0400 | [diff] [blame] | 557 | /* 0xff01 is a flag rather then an actual voltage */ |
| 558 | if (voltage->voltage == 0xff01) |
| 559 | return; |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 560 | if (voltage->voltage != rdev->pm.current_vddc) { |
Alex Deucher | 8a83ec5 | 2011-04-12 14:49:23 -0400 | [diff] [blame] | 561 | radeon_atom_set_voltage(rdev, voltage->voltage, SET_VOLTAGE_TYPE_ASIC_VDDC); |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 562 | rdev->pm.current_vddc = voltage->voltage; |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 563 | DRM_DEBUG_DRIVER("Setting: v: %d\n", voltage->voltage); |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 564 | } |
| 565 | } |
Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 566 | } |
| 567 | |
Alex Deucher | def9ba9 | 2010-04-22 12:39:58 -0400 | [diff] [blame] | 568 | bool r600_gui_idle(struct radeon_device *rdev) |
| 569 | { |
| 570 | if (RREG32(GRBM_STATUS) & GUI_ACTIVE) |
| 571 | return false; |
| 572 | else |
| 573 | return true; |
| 574 | } |
| 575 | |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 576 | /* hpd for digital panel detect/disconnect */ |
| 577 | bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) |
| 578 | { |
| 579 | bool connected = false; |
| 580 | |
| 581 | if (ASIC_IS_DCE3(rdev)) { |
| 582 | switch (hpd) { |
| 583 | case RADEON_HPD_1: |
| 584 | if (RREG32(DC_HPD1_INT_STATUS) & DC_HPDx_SENSE) |
| 585 | connected = true; |
| 586 | break; |
| 587 | case RADEON_HPD_2: |
| 588 | if (RREG32(DC_HPD2_INT_STATUS) & DC_HPDx_SENSE) |
| 589 | connected = true; |
| 590 | break; |
| 591 | case RADEON_HPD_3: |
| 592 | if (RREG32(DC_HPD3_INT_STATUS) & DC_HPDx_SENSE) |
| 593 | connected = true; |
| 594 | break; |
| 595 | case RADEON_HPD_4: |
| 596 | if (RREG32(DC_HPD4_INT_STATUS) & DC_HPDx_SENSE) |
| 597 | connected = true; |
| 598 | break; |
| 599 | /* DCE 3.2 */ |
| 600 | case RADEON_HPD_5: |
| 601 | if (RREG32(DC_HPD5_INT_STATUS) & DC_HPDx_SENSE) |
| 602 | connected = true; |
| 603 | break; |
| 604 | case RADEON_HPD_6: |
| 605 | if (RREG32(DC_HPD6_INT_STATUS) & DC_HPDx_SENSE) |
| 606 | connected = true; |
| 607 | break; |
| 608 | default: |
| 609 | break; |
| 610 | } |
| 611 | } else { |
| 612 | switch (hpd) { |
| 613 | case RADEON_HPD_1: |
| 614 | if (RREG32(DC_HOT_PLUG_DETECT1_INT_STATUS) & DC_HOT_PLUG_DETECTx_SENSE) |
| 615 | connected = true; |
| 616 | break; |
| 617 | case RADEON_HPD_2: |
| 618 | if (RREG32(DC_HOT_PLUG_DETECT2_INT_STATUS) & DC_HOT_PLUG_DETECTx_SENSE) |
| 619 | connected = true; |
| 620 | break; |
| 621 | case RADEON_HPD_3: |
| 622 | if (RREG32(DC_HOT_PLUG_DETECT3_INT_STATUS) & DC_HOT_PLUG_DETECTx_SENSE) |
| 623 | connected = true; |
| 624 | break; |
| 625 | default: |
| 626 | break; |
| 627 | } |
| 628 | } |
| 629 | return connected; |
| 630 | } |
| 631 | |
| 632 | void r600_hpd_set_polarity(struct radeon_device *rdev, |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 633 | enum radeon_hpd_id hpd) |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 634 | { |
| 635 | u32 tmp; |
| 636 | bool connected = r600_hpd_sense(rdev, hpd); |
| 637 | |
| 638 | if (ASIC_IS_DCE3(rdev)) { |
| 639 | switch (hpd) { |
| 640 | case RADEON_HPD_1: |
| 641 | tmp = RREG32(DC_HPD1_INT_CONTROL); |
| 642 | if (connected) |
| 643 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 644 | else |
| 645 | tmp |= DC_HPDx_INT_POLARITY; |
| 646 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 647 | break; |
| 648 | case RADEON_HPD_2: |
| 649 | tmp = RREG32(DC_HPD2_INT_CONTROL); |
| 650 | if (connected) |
| 651 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 652 | else |
| 653 | tmp |= DC_HPDx_INT_POLARITY; |
| 654 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 655 | break; |
| 656 | case RADEON_HPD_3: |
| 657 | tmp = RREG32(DC_HPD3_INT_CONTROL); |
| 658 | if (connected) |
| 659 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 660 | else |
| 661 | tmp |= DC_HPDx_INT_POLARITY; |
| 662 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 663 | break; |
| 664 | case RADEON_HPD_4: |
| 665 | tmp = RREG32(DC_HPD4_INT_CONTROL); |
| 666 | if (connected) |
| 667 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 668 | else |
| 669 | tmp |= DC_HPDx_INT_POLARITY; |
| 670 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 671 | break; |
| 672 | case RADEON_HPD_5: |
| 673 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 674 | if (connected) |
| 675 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 676 | else |
| 677 | tmp |= DC_HPDx_INT_POLARITY; |
| 678 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 679 | break; |
| 680 | /* DCE 3.2 */ |
| 681 | case RADEON_HPD_6: |
| 682 | tmp = RREG32(DC_HPD6_INT_CONTROL); |
| 683 | if (connected) |
| 684 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 685 | else |
| 686 | tmp |= DC_HPDx_INT_POLARITY; |
| 687 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 688 | break; |
| 689 | default: |
| 690 | break; |
| 691 | } |
| 692 | } else { |
| 693 | switch (hpd) { |
| 694 | case RADEON_HPD_1: |
| 695 | tmp = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL); |
| 696 | if (connected) |
| 697 | tmp &= ~DC_HOT_PLUG_DETECTx_INT_POLARITY; |
| 698 | else |
| 699 | tmp |= DC_HOT_PLUG_DETECTx_INT_POLARITY; |
| 700 | WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); |
| 701 | break; |
| 702 | case RADEON_HPD_2: |
| 703 | tmp = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL); |
| 704 | if (connected) |
| 705 | tmp &= ~DC_HOT_PLUG_DETECTx_INT_POLARITY; |
| 706 | else |
| 707 | tmp |= DC_HOT_PLUG_DETECTx_INT_POLARITY; |
| 708 | WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); |
| 709 | break; |
| 710 | case RADEON_HPD_3: |
| 711 | tmp = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL); |
| 712 | if (connected) |
| 713 | tmp &= ~DC_HOT_PLUG_DETECTx_INT_POLARITY; |
| 714 | else |
| 715 | tmp |= DC_HOT_PLUG_DETECTx_INT_POLARITY; |
| 716 | WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, tmp); |
| 717 | break; |
| 718 | default: |
| 719 | break; |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | void r600_hpd_init(struct radeon_device *rdev) |
| 725 | { |
| 726 | struct drm_device *dev = rdev->ddev; |
| 727 | struct drm_connector *connector; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 728 | unsigned enable = 0; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 729 | |
Alex Deucher | 64912e9 | 2011-11-03 11:21:39 -0400 | [diff] [blame] | 730 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 731 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 732 | |
Jerome Glisse | 455c89b | 2012-05-04 11:06:22 -0400 | [diff] [blame] | 733 | if (connector->connector_type == DRM_MODE_CONNECTOR_eDP || |
| 734 | connector->connector_type == DRM_MODE_CONNECTOR_LVDS) { |
| 735 | /* don't try to enable hpd on eDP or LVDS avoid breaking the |
| 736 | * aux dp channel on imac and help (but not completely fix) |
| 737 | * https://bugzilla.redhat.com/show_bug.cgi?id=726143 |
| 738 | */ |
| 739 | continue; |
| 740 | } |
Alex Deucher | 64912e9 | 2011-11-03 11:21:39 -0400 | [diff] [blame] | 741 | if (ASIC_IS_DCE3(rdev)) { |
| 742 | u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | DC_HPDx_RX_INT_TIMER(0xfa); |
| 743 | if (ASIC_IS_DCE32(rdev)) |
| 744 | tmp |= DC_HPDx_EN; |
| 745 | |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 746 | switch (radeon_connector->hpd.hpd) { |
| 747 | case RADEON_HPD_1: |
| 748 | WREG32(DC_HPD1_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 749 | break; |
| 750 | case RADEON_HPD_2: |
| 751 | WREG32(DC_HPD2_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 752 | break; |
| 753 | case RADEON_HPD_3: |
| 754 | WREG32(DC_HPD3_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 755 | break; |
| 756 | case RADEON_HPD_4: |
| 757 | WREG32(DC_HPD4_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 758 | break; |
| 759 | /* DCE 3.2 */ |
| 760 | case RADEON_HPD_5: |
| 761 | WREG32(DC_HPD5_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 762 | break; |
| 763 | case RADEON_HPD_6: |
| 764 | WREG32(DC_HPD6_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 765 | break; |
| 766 | default: |
| 767 | break; |
| 768 | } |
Alex Deucher | 64912e9 | 2011-11-03 11:21:39 -0400 | [diff] [blame] | 769 | } else { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 770 | switch (radeon_connector->hpd.hpd) { |
| 771 | case RADEON_HPD_1: |
| 772 | WREG32(DC_HOT_PLUG_DETECT1_CONTROL, DC_HOT_PLUG_DETECTx_EN); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 773 | break; |
| 774 | case RADEON_HPD_2: |
| 775 | WREG32(DC_HOT_PLUG_DETECT2_CONTROL, DC_HOT_PLUG_DETECTx_EN); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 776 | break; |
| 777 | case RADEON_HPD_3: |
| 778 | WREG32(DC_HOT_PLUG_DETECT3_CONTROL, DC_HOT_PLUG_DETECTx_EN); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 779 | break; |
| 780 | default: |
| 781 | break; |
| 782 | } |
| 783 | } |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 784 | enable |= 1 << radeon_connector->hpd.hpd; |
Alex Deucher | 64912e9 | 2011-11-03 11:21:39 -0400 | [diff] [blame] | 785 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 786 | } |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 787 | radeon_irq_kms_enable_hpd(rdev, enable); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | void r600_hpd_fini(struct radeon_device *rdev) |
| 791 | { |
| 792 | struct drm_device *dev = rdev->ddev; |
| 793 | struct drm_connector *connector; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 794 | unsigned disable = 0; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 795 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 796 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 797 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 798 | if (ASIC_IS_DCE3(rdev)) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 799 | switch (radeon_connector->hpd.hpd) { |
| 800 | case RADEON_HPD_1: |
| 801 | WREG32(DC_HPD1_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 802 | break; |
| 803 | case RADEON_HPD_2: |
| 804 | WREG32(DC_HPD2_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 805 | break; |
| 806 | case RADEON_HPD_3: |
| 807 | WREG32(DC_HPD3_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 808 | break; |
| 809 | case RADEON_HPD_4: |
| 810 | WREG32(DC_HPD4_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 811 | break; |
| 812 | /* DCE 3.2 */ |
| 813 | case RADEON_HPD_5: |
| 814 | WREG32(DC_HPD5_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 815 | break; |
| 816 | case RADEON_HPD_6: |
| 817 | WREG32(DC_HPD6_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 818 | break; |
| 819 | default: |
| 820 | break; |
| 821 | } |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 822 | } else { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 823 | switch (radeon_connector->hpd.hpd) { |
| 824 | case RADEON_HPD_1: |
| 825 | WREG32(DC_HOT_PLUG_DETECT1_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 826 | break; |
| 827 | case RADEON_HPD_2: |
| 828 | WREG32(DC_HOT_PLUG_DETECT2_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 829 | break; |
| 830 | case RADEON_HPD_3: |
| 831 | WREG32(DC_HOT_PLUG_DETECT3_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 832 | break; |
| 833 | default: |
| 834 | break; |
| 835 | } |
| 836 | } |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 837 | disable |= 1 << radeon_connector->hpd.hpd; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 838 | } |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 839 | radeon_irq_kms_disable_hpd(rdev, disable); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 840 | } |
| 841 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 842 | /* |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 843 | * R600 PCIE GART |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 844 | */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 845 | void r600_pcie_gart_tlb_flush(struct radeon_device *rdev) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 846 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 847 | unsigned i; |
| 848 | u32 tmp; |
| 849 | |
Dave Airlie | 2e98f10 | 2010-02-15 15:54:45 +1000 | [diff] [blame] | 850 | /* flush hdp cache so updates hit vram */ |
Alex Deucher | f3886f8 | 2010-12-08 10:05:34 -0500 | [diff] [blame] | 851 | if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) && |
| 852 | !(rdev->flags & RADEON_IS_AGP)) { |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 853 | void __iomem *ptr = (void *)rdev->gart.ptr; |
Alex Deucher | 812d046 | 2010-07-26 18:51:53 -0400 | [diff] [blame] | 854 | u32 tmp; |
| 855 | |
| 856 | /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read |
| 857 | * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL |
Alex Deucher | f3886f8 | 2010-12-08 10:05:34 -0500 | [diff] [blame] | 858 | * This seems to cause problems on some AGP cards. Just use the old |
| 859 | * method for them. |
Alex Deucher | 812d046 | 2010-07-26 18:51:53 -0400 | [diff] [blame] | 860 | */ |
| 861 | WREG32(HDP_DEBUG1, 0); |
| 862 | tmp = readl((void __iomem *)ptr); |
| 863 | } else |
| 864 | WREG32(R_005480_HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1); |
Dave Airlie | 2e98f10 | 2010-02-15 15:54:45 +1000 | [diff] [blame] | 865 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 866 | WREG32(VM_CONTEXT0_INVALIDATION_LOW_ADDR, rdev->mc.gtt_start >> 12); |
| 867 | WREG32(VM_CONTEXT0_INVALIDATION_HIGH_ADDR, (rdev->mc.gtt_end - 1) >> 12); |
| 868 | WREG32(VM_CONTEXT0_REQUEST_RESPONSE, REQUEST_TYPE(1)); |
| 869 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 870 | /* read MC_STATUS */ |
| 871 | tmp = RREG32(VM_CONTEXT0_REQUEST_RESPONSE); |
| 872 | tmp = (tmp & RESPONSE_TYPE_MASK) >> RESPONSE_TYPE_SHIFT; |
| 873 | if (tmp == 2) { |
| 874 | printk(KERN_WARNING "[drm] r600 flush TLB failed\n"); |
| 875 | return; |
| 876 | } |
| 877 | if (tmp) { |
| 878 | return; |
| 879 | } |
| 880 | udelay(1); |
| 881 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 882 | } |
| 883 | |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 884 | int r600_pcie_gart_init(struct radeon_device *rdev) |
| 885 | { |
| 886 | int r; |
| 887 | |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 888 | if (rdev->gart.robj) { |
Joe Perches | fce7d61 | 2010-10-30 21:08:30 +0000 | [diff] [blame] | 889 | WARN(1, "R600 PCIE GART already initialized\n"); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 890 | return 0; |
| 891 | } |
| 892 | /* Initialize common gart structure */ |
| 893 | r = radeon_gart_init(rdev); |
| 894 | if (r) |
| 895 | return r; |
| 896 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 8; |
| 897 | return radeon_gart_table_vram_alloc(rdev); |
| 898 | } |
| 899 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 900 | static int r600_pcie_gart_enable(struct radeon_device *rdev) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 901 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 902 | u32 tmp; |
| 903 | int r, i; |
| 904 | |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 905 | if (rdev->gart.robj == NULL) { |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 906 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); |
| 907 | return -EINVAL; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 908 | } |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 909 | r = radeon_gart_table_vram_pin(rdev); |
| 910 | if (r) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 911 | return r; |
Dave Airlie | 8256856 | 2010-02-05 16:00:07 +1000 | [diff] [blame] | 912 | radeon_gart_restore(rdev); |
Dave Airlie | bc1a631 | 2009-09-15 11:07:52 +1000 | [diff] [blame] | 913 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 914 | /* Setup L2 cache */ |
| 915 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | |
| 916 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 917 | EFFECTIVE_L2_QUEUE_SIZE(7)); |
| 918 | WREG32(VM_L2_CNTL2, 0); |
| 919 | WREG32(VM_L2_CNTL3, BANK_SELECT_0(0) | BANK_SELECT_1(1)); |
| 920 | /* Setup TLB control */ |
| 921 | tmp = ENABLE_L1_TLB | ENABLE_L1_FRAGMENT_PROCESSING | |
| 922 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 923 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5) | |
| 924 | ENABLE_WAIT_L2_QUERY; |
| 925 | WREG32(MC_VM_L1_TLB_MCB_RD_SYS_CNTL, tmp); |
| 926 | WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL, tmp); |
| 927 | WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL, tmp | ENABLE_L1_STRICT_ORDERING); |
| 928 | WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL, tmp); |
| 929 | WREG32(MC_VM_L1_TLB_MCD_RD_A_CNTL, tmp); |
| 930 | WREG32(MC_VM_L1_TLB_MCD_WR_A_CNTL, tmp); |
| 931 | WREG32(MC_VM_L1_TLB_MCD_RD_B_CNTL, tmp); |
| 932 | WREG32(MC_VM_L1_TLB_MCD_WR_B_CNTL, tmp); |
| 933 | WREG32(MC_VM_L1_TLB_MCB_RD_GFX_CNTL, tmp); |
| 934 | WREG32(MC_VM_L1_TLB_MCB_WR_GFX_CNTL, tmp); |
| 935 | WREG32(MC_VM_L1_TLB_MCB_RD_PDMA_CNTL, tmp); |
| 936 | WREG32(MC_VM_L1_TLB_MCB_WR_PDMA_CNTL, tmp); |
| 937 | WREG32(MC_VM_L1_TLB_MCB_RD_SEM_CNTL, tmp | ENABLE_SEMAPHORE_MODE); |
| 938 | WREG32(MC_VM_L1_TLB_MCB_WR_SEM_CNTL, tmp | ENABLE_SEMAPHORE_MODE); |
| 939 | WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, rdev->mc.gtt_start >> 12); |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 940 | WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, rdev->mc.gtt_end >> 12); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 941 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, rdev->gart.table_addr >> 12); |
| 942 | WREG32(VM_CONTEXT0_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) | |
| 943 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT); |
| 944 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
| 945 | (u32)(rdev->dummy_page.addr >> 12)); |
| 946 | for (i = 1; i < 7; i++) |
| 947 | WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); |
| 948 | |
| 949 | r600_pcie_gart_tlb_flush(rdev); |
Tormod Volden | fcf4de5 | 2011-08-31 21:54:07 +0000 | [diff] [blame] | 950 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
| 951 | (unsigned)(rdev->mc.gtt_size >> 20), |
| 952 | (unsigned long long)rdev->gart.table_addr); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 953 | rdev->gart.ready = true; |
| 954 | return 0; |
| 955 | } |
| 956 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 957 | static void r600_pcie_gart_disable(struct radeon_device *rdev) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 958 | { |
| 959 | u32 tmp; |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 960 | int i; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 961 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 962 | /* Disable all tables */ |
| 963 | for (i = 0; i < 7; i++) |
| 964 | WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); |
| 965 | |
| 966 | /* Disable L2 cache */ |
| 967 | WREG32(VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING | |
| 968 | EFFECTIVE_L2_QUEUE_SIZE(7)); |
| 969 | WREG32(VM_L2_CNTL3, BANK_SELECT_0(0) | BANK_SELECT_1(1)); |
| 970 | /* Setup L1 TLB control */ |
| 971 | tmp = EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5) | |
| 972 | ENABLE_WAIT_L2_QUERY; |
| 973 | WREG32(MC_VM_L1_TLB_MCD_RD_A_CNTL, tmp); |
| 974 | WREG32(MC_VM_L1_TLB_MCD_WR_A_CNTL, tmp); |
| 975 | WREG32(MC_VM_L1_TLB_MCD_RD_B_CNTL, tmp); |
| 976 | WREG32(MC_VM_L1_TLB_MCD_WR_B_CNTL, tmp); |
| 977 | WREG32(MC_VM_L1_TLB_MCB_RD_GFX_CNTL, tmp); |
| 978 | WREG32(MC_VM_L1_TLB_MCB_WR_GFX_CNTL, tmp); |
| 979 | WREG32(MC_VM_L1_TLB_MCB_RD_PDMA_CNTL, tmp); |
| 980 | WREG32(MC_VM_L1_TLB_MCB_WR_PDMA_CNTL, tmp); |
| 981 | WREG32(MC_VM_L1_TLB_MCB_RD_SEM_CNTL, tmp); |
| 982 | WREG32(MC_VM_L1_TLB_MCB_WR_SEM_CNTL, tmp); |
| 983 | WREG32(MC_VM_L1_TLB_MCB_RD_SYS_CNTL, tmp); |
| 984 | WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL, tmp); |
| 985 | WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL, tmp); |
| 986 | WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL, tmp); |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 987 | radeon_gart_table_vram_unpin(rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 988 | } |
| 989 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 990 | static void r600_pcie_gart_fini(struct radeon_device *rdev) |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 991 | { |
Jerome Glisse | f927456 | 2010-03-17 14:44:29 +0000 | [diff] [blame] | 992 | radeon_gart_fini(rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 993 | r600_pcie_gart_disable(rdev); |
| 994 | radeon_gart_table_vram_free(rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 995 | } |
| 996 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 997 | static void r600_agp_enable(struct radeon_device *rdev) |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 998 | { |
| 999 | u32 tmp; |
| 1000 | int i; |
| 1001 | |
| 1002 | /* Setup L2 cache */ |
| 1003 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | |
| 1004 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 1005 | EFFECTIVE_L2_QUEUE_SIZE(7)); |
| 1006 | WREG32(VM_L2_CNTL2, 0); |
| 1007 | WREG32(VM_L2_CNTL3, BANK_SELECT_0(0) | BANK_SELECT_1(1)); |
| 1008 | /* Setup TLB control */ |
| 1009 | tmp = ENABLE_L1_TLB | ENABLE_L1_FRAGMENT_PROCESSING | |
| 1010 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 1011 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5) | |
| 1012 | ENABLE_WAIT_L2_QUERY; |
| 1013 | WREG32(MC_VM_L1_TLB_MCB_RD_SYS_CNTL, tmp); |
| 1014 | WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL, tmp); |
| 1015 | WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL, tmp | ENABLE_L1_STRICT_ORDERING); |
| 1016 | WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL, tmp); |
| 1017 | WREG32(MC_VM_L1_TLB_MCD_RD_A_CNTL, tmp); |
| 1018 | WREG32(MC_VM_L1_TLB_MCD_WR_A_CNTL, tmp); |
| 1019 | WREG32(MC_VM_L1_TLB_MCD_RD_B_CNTL, tmp); |
| 1020 | WREG32(MC_VM_L1_TLB_MCD_WR_B_CNTL, tmp); |
| 1021 | WREG32(MC_VM_L1_TLB_MCB_RD_GFX_CNTL, tmp); |
| 1022 | WREG32(MC_VM_L1_TLB_MCB_WR_GFX_CNTL, tmp); |
| 1023 | WREG32(MC_VM_L1_TLB_MCB_RD_PDMA_CNTL, tmp); |
| 1024 | WREG32(MC_VM_L1_TLB_MCB_WR_PDMA_CNTL, tmp); |
| 1025 | WREG32(MC_VM_L1_TLB_MCB_RD_SEM_CNTL, tmp | ENABLE_SEMAPHORE_MODE); |
| 1026 | WREG32(MC_VM_L1_TLB_MCB_WR_SEM_CNTL, tmp | ENABLE_SEMAPHORE_MODE); |
| 1027 | for (i = 0; i < 7; i++) |
| 1028 | WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); |
| 1029 | } |
| 1030 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1031 | int r600_mc_wait_for_idle(struct radeon_device *rdev) |
| 1032 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1033 | unsigned i; |
| 1034 | u32 tmp; |
| 1035 | |
| 1036 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 1037 | /* read MC_STATUS */ |
| 1038 | tmp = RREG32(R_000E50_SRBM_STATUS) & 0x3F00; |
| 1039 | if (!tmp) |
| 1040 | return 0; |
| 1041 | udelay(1); |
| 1042 | } |
| 1043 | return -1; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1044 | } |
| 1045 | |
Samuel Li | 65337e6 | 2013-04-05 17:50:53 -0400 | [diff] [blame] | 1046 | uint32_t rs780_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
| 1047 | { |
| 1048 | uint32_t r; |
| 1049 | |
| 1050 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg)); |
| 1051 | r = RREG32(R_0028FC_MC_DATA); |
| 1052 | WREG32(R_0028F8_MC_INDEX, ~C_0028F8_MC_IND_ADDR); |
| 1053 | return r; |
| 1054 | } |
| 1055 | |
| 1056 | void rs780_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 1057 | { |
| 1058 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg) | |
| 1059 | S_0028F8_MC_IND_WR_EN(1)); |
| 1060 | WREG32(R_0028FC_MC_DATA, v); |
| 1061 | WREG32(R_0028F8_MC_INDEX, 0x7F); |
| 1062 | } |
| 1063 | |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1064 | static void r600_mc_program(struct radeon_device *rdev) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1065 | { |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1066 | struct rv515_mc_save save; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1067 | u32 tmp; |
| 1068 | int i, j; |
| 1069 | |
| 1070 | /* Initialize HDP */ |
| 1071 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 1072 | WREG32((0x2c14 + j), 0x00000000); |
| 1073 | WREG32((0x2c18 + j), 0x00000000); |
| 1074 | WREG32((0x2c1c + j), 0x00000000); |
| 1075 | WREG32((0x2c20 + j), 0x00000000); |
| 1076 | WREG32((0x2c24 + j), 0x00000000); |
| 1077 | } |
| 1078 | WREG32(HDP_REG_COHERENCY_FLUSH_CNTL, 0); |
| 1079 | |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1080 | rv515_mc_stop(rdev, &save); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1081 | if (r600_mc_wait_for_idle(rdev)) { |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1082 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1083 | } |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1084 | /* Lockout access through VGA aperture (doesn't exist before R600) */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1085 | WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1086 | /* Update configuration */ |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 1087 | if (rdev->flags & RADEON_IS_AGP) { |
| 1088 | if (rdev->mc.vram_start < rdev->mc.gtt_start) { |
| 1089 | /* VRAM before AGP */ |
| 1090 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 1091 | rdev->mc.vram_start >> 12); |
| 1092 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 1093 | rdev->mc.gtt_end >> 12); |
| 1094 | } else { |
| 1095 | /* VRAM after AGP */ |
| 1096 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 1097 | rdev->mc.gtt_start >> 12); |
| 1098 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 1099 | rdev->mc.vram_end >> 12); |
| 1100 | } |
| 1101 | } else { |
| 1102 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, rdev->mc.vram_start >> 12); |
| 1103 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, rdev->mc.vram_end >> 12); |
| 1104 | } |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 1105 | WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr >> 12); |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 1106 | tmp = ((rdev->mc.vram_end >> 24) & 0xFFFF) << 16; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1107 | tmp |= ((rdev->mc.vram_start >> 24) & 0xFFFF); |
| 1108 | WREG32(MC_VM_FB_LOCATION, tmp); |
| 1109 | WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); |
| 1110 | WREG32(HDP_NONSURFACE_INFO, (2 << 7)); |
Jerome Glisse | 46fcd2b | 2010-06-03 19:34:48 +0200 | [diff] [blame] | 1111 | WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1112 | if (rdev->flags & RADEON_IS_AGP) { |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 1113 | WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 22); |
| 1114 | WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 22); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1115 | WREG32(MC_VM_AGP_BASE, rdev->mc.agp_base >> 22); |
| 1116 | } else { |
| 1117 | WREG32(MC_VM_AGP_BASE, 0); |
| 1118 | WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF); |
| 1119 | WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF); |
| 1120 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1121 | if (r600_mc_wait_for_idle(rdev)) { |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1122 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1123 | } |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1124 | rv515_mc_resume(rdev, &save); |
Dave Airlie | 698443d | 2009-09-18 14:16:38 +1000 | [diff] [blame] | 1125 | /* we need to own VRAM, so turn off the VGA renderer here |
| 1126 | * to stop it overwriting our objects */ |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1127 | rv515_vga_render_disable(rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1128 | } |
| 1129 | |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1130 | /** |
| 1131 | * r600_vram_gtt_location - try to find VRAM & GTT location |
| 1132 | * @rdev: radeon device structure holding all necessary informations |
| 1133 | * @mc: memory controller structure holding memory informations |
| 1134 | * |
| 1135 | * Function will place try to place VRAM at same place as in CPU (PCI) |
| 1136 | * address space as some GPU seems to have issue when we reprogram at |
| 1137 | * different address space. |
| 1138 | * |
| 1139 | * If there is not enough space to fit the unvisible VRAM after the |
| 1140 | * aperture then we limit the VRAM size to the aperture. |
| 1141 | * |
| 1142 | * If we are using AGP then place VRAM adjacent to AGP aperture are we need |
| 1143 | * them to be in one from GPU point of view so that we can program GPU to |
| 1144 | * catch access outside them (weird GPU policy see ??). |
| 1145 | * |
| 1146 | * This function will never fails, worst case are limiting VRAM or GTT. |
| 1147 | * |
| 1148 | * Note: GTT start, end, size should be initialized before calling this |
| 1149 | * function on AGP platform. |
| 1150 | */ |
Alex Deucher | 0ef0c1f | 2010-11-22 17:56:26 -0500 | [diff] [blame] | 1151 | static void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1152 | { |
| 1153 | u64 size_bf, size_af; |
| 1154 | |
| 1155 | if (mc->mc_vram_size > 0xE0000000) { |
| 1156 | /* leave room for at least 512M GTT */ |
| 1157 | dev_warn(rdev->dev, "limiting VRAM\n"); |
| 1158 | mc->real_vram_size = 0xE0000000; |
| 1159 | mc->mc_vram_size = 0xE0000000; |
| 1160 | } |
| 1161 | if (rdev->flags & RADEON_IS_AGP) { |
| 1162 | size_bf = mc->gtt_start; |
Alex Deucher | 9ed8b1f | 2013-04-08 11:13:01 -0400 | [diff] [blame] | 1163 | size_af = mc->mc_mask - mc->gtt_end; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1164 | if (size_bf > size_af) { |
| 1165 | if (mc->mc_vram_size > size_bf) { |
| 1166 | dev_warn(rdev->dev, "limiting VRAM\n"); |
| 1167 | mc->real_vram_size = size_bf; |
| 1168 | mc->mc_vram_size = size_bf; |
| 1169 | } |
| 1170 | mc->vram_start = mc->gtt_start - mc->mc_vram_size; |
| 1171 | } else { |
| 1172 | if (mc->mc_vram_size > size_af) { |
| 1173 | dev_warn(rdev->dev, "limiting VRAM\n"); |
| 1174 | mc->real_vram_size = size_af; |
| 1175 | mc->mc_vram_size = size_af; |
| 1176 | } |
Jerome Glisse | dfc6ae5 | 2012-04-17 16:51:38 -0400 | [diff] [blame] | 1177 | mc->vram_start = mc->gtt_end + 1; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1178 | } |
| 1179 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
| 1180 | dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n", |
| 1181 | mc->mc_vram_size >> 20, mc->vram_start, |
| 1182 | mc->vram_end, mc->real_vram_size >> 20); |
| 1183 | } else { |
| 1184 | u64 base = 0; |
Alex Deucher | 8961d52 | 2010-12-03 14:37:22 -0500 | [diff] [blame] | 1185 | if (rdev->flags & RADEON_IS_IGP) { |
| 1186 | base = RREG32(MC_VM_FB_LOCATION) & 0xFFFF; |
| 1187 | base <<= 24; |
| 1188 | } |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1189 | radeon_vram_location(rdev, &rdev->mc, base); |
Alex Deucher | 8d369bb | 2010-07-15 10:51:10 -0400 | [diff] [blame] | 1190 | rdev->mc.gtt_base_align = 0; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1191 | radeon_gtt_location(rdev, mc); |
| 1192 | } |
| 1193 | } |
| 1194 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 1195 | static int r600_mc_init(struct radeon_device *rdev) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1196 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1197 | u32 tmp; |
Alex Deucher | 5885b7a | 2009-10-19 17:23:33 -0400 | [diff] [blame] | 1198 | int chansize, numchan; |
Samuel Li | 65337e6 | 2013-04-05 17:50:53 -0400 | [diff] [blame] | 1199 | uint32_t h_addr, l_addr; |
| 1200 | unsigned long long k8_addr; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1201 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1202 | /* Get VRAM informations */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1203 | rdev->mc.vram_is_ddr = true; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1204 | tmp = RREG32(RAMCFG); |
| 1205 | if (tmp & CHANSIZE_OVERRIDE) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1206 | chansize = 16; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1207 | } else if (tmp & CHANSIZE_MASK) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1208 | chansize = 64; |
| 1209 | } else { |
| 1210 | chansize = 32; |
| 1211 | } |
Alex Deucher | 5885b7a | 2009-10-19 17:23:33 -0400 | [diff] [blame] | 1212 | tmp = RREG32(CHMAP); |
| 1213 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 1214 | case 0: |
| 1215 | default: |
| 1216 | numchan = 1; |
| 1217 | break; |
| 1218 | case 1: |
| 1219 | numchan = 2; |
| 1220 | break; |
| 1221 | case 2: |
| 1222 | numchan = 4; |
| 1223 | break; |
| 1224 | case 3: |
| 1225 | numchan = 8; |
| 1226 | break; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1227 | } |
Alex Deucher | 5885b7a | 2009-10-19 17:23:33 -0400 | [diff] [blame] | 1228 | rdev->mc.vram_width = numchan * chansize; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1229 | /* Could aper size report 0 ? */ |
Jordan Crouse | 01d73a6 | 2010-05-27 13:40:24 -0600 | [diff] [blame] | 1230 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
| 1231 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1232 | /* Setup GPU memory space */ |
| 1233 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); |
| 1234 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); |
Jerome Glisse | 51e5fcd | 2010-02-19 14:33:54 +0000 | [diff] [blame] | 1235 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1236 | r600_vram_gtt_location(rdev, &rdev->mc); |
Alex Deucher | f47299c | 2010-03-16 20:54:38 -0400 | [diff] [blame] | 1237 | |
Alex Deucher | f892034 | 2010-06-30 12:02:03 -0400 | [diff] [blame] | 1238 | if (rdev->flags & RADEON_IS_IGP) { |
| 1239 | rs690_pm_info(rdev); |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 1240 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
Samuel Li | 65337e6 | 2013-04-05 17:50:53 -0400 | [diff] [blame] | 1241 | |
| 1242 | if (rdev->family == CHIP_RS780 || rdev->family == CHIP_RS880) { |
| 1243 | /* Use K8 direct mapping for fast fb access. */ |
| 1244 | rdev->fastfb_working = false; |
| 1245 | h_addr = G_000012_K8_ADDR_EXT(RREG32_MC(R_000012_MC_MISC_UMA_CNTL)); |
| 1246 | l_addr = RREG32_MC(R_000011_K8_FB_LOCATION); |
| 1247 | k8_addr = ((unsigned long long)h_addr) << 32 | l_addr; |
| 1248 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) |
| 1249 | if (k8_addr + rdev->mc.visible_vram_size < 0x100000000ULL) |
| 1250 | #endif |
| 1251 | { |
| 1252 | /* FastFB shall be used with UMA memory. Here it is simply disabled when sideport |
| 1253 | * memory is present. |
| 1254 | */ |
| 1255 | if (rdev->mc.igp_sideport_enabled == false && radeon_fastfb == 1) { |
| 1256 | DRM_INFO("Direct mapping: aper base at 0x%llx, replaced by direct mapping base 0x%llx.\n", |
| 1257 | (unsigned long long)rdev->mc.aper_base, k8_addr); |
| 1258 | rdev->mc.aper_base = (resource_size_t)k8_addr; |
| 1259 | rdev->fastfb_working = true; |
| 1260 | } |
| 1261 | } |
| 1262 | } |
Alex Deucher | f892034 | 2010-06-30 12:02:03 -0400 | [diff] [blame] | 1263 | } |
Samuel Li | 65337e6 | 2013-04-05 17:50:53 -0400 | [diff] [blame] | 1264 | |
Alex Deucher | f47299c | 2010-03-16 20:54:38 -0400 | [diff] [blame] | 1265 | radeon_update_bandwidth_info(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1266 | return 0; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1267 | } |
| 1268 | |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 1269 | int r600_vram_scratch_init(struct radeon_device *rdev) |
| 1270 | { |
| 1271 | int r; |
| 1272 | |
| 1273 | if (rdev->vram_scratch.robj == NULL) { |
| 1274 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, |
| 1275 | PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, |
Alex Deucher | 40f5cf9 | 2012-05-10 18:33:13 -0400 | [diff] [blame] | 1276 | NULL, &rdev->vram_scratch.robj); |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 1277 | if (r) { |
| 1278 | return r; |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | r = radeon_bo_reserve(rdev->vram_scratch.robj, false); |
| 1283 | if (unlikely(r != 0)) |
| 1284 | return r; |
| 1285 | r = radeon_bo_pin(rdev->vram_scratch.robj, |
| 1286 | RADEON_GEM_DOMAIN_VRAM, &rdev->vram_scratch.gpu_addr); |
| 1287 | if (r) { |
| 1288 | radeon_bo_unreserve(rdev->vram_scratch.robj); |
| 1289 | return r; |
| 1290 | } |
| 1291 | r = radeon_bo_kmap(rdev->vram_scratch.robj, |
| 1292 | (void **)&rdev->vram_scratch.ptr); |
| 1293 | if (r) |
| 1294 | radeon_bo_unpin(rdev->vram_scratch.robj); |
| 1295 | radeon_bo_unreserve(rdev->vram_scratch.robj); |
| 1296 | |
| 1297 | return r; |
| 1298 | } |
| 1299 | |
| 1300 | void r600_vram_scratch_fini(struct radeon_device *rdev) |
| 1301 | { |
| 1302 | int r; |
| 1303 | |
| 1304 | if (rdev->vram_scratch.robj == NULL) { |
| 1305 | return; |
| 1306 | } |
| 1307 | r = radeon_bo_reserve(rdev->vram_scratch.robj, false); |
| 1308 | if (likely(r == 0)) { |
| 1309 | radeon_bo_kunmap(rdev->vram_scratch.robj); |
| 1310 | radeon_bo_unpin(rdev->vram_scratch.robj); |
| 1311 | radeon_bo_unreserve(rdev->vram_scratch.robj); |
| 1312 | } |
| 1313 | radeon_bo_unref(&rdev->vram_scratch.robj); |
| 1314 | } |
| 1315 | |
Alex Deucher | 410a341 | 2013-01-18 13:05:39 -0500 | [diff] [blame] | 1316 | void r600_set_bios_scratch_engine_hung(struct radeon_device *rdev, bool hung) |
| 1317 | { |
| 1318 | u32 tmp = RREG32(R600_BIOS_3_SCRATCH); |
| 1319 | |
| 1320 | if (hung) |
| 1321 | tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
| 1322 | else |
| 1323 | tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
| 1324 | |
| 1325 | WREG32(R600_BIOS_3_SCRATCH, tmp); |
| 1326 | } |
| 1327 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1328 | static void r600_print_gpu_status_regs(struct radeon_device *rdev) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1329 | { |
Jerome Glisse | 64c56e8 | 2013-01-02 17:30:35 -0500 | [diff] [blame] | 1330 | dev_info(rdev->dev, " R_008010_GRBM_STATUS = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1331 | RREG32(R_008010_GRBM_STATUS)); |
Jerome Glisse | 64c56e8 | 2013-01-02 17:30:35 -0500 | [diff] [blame] | 1332 | dev_info(rdev->dev, " R_008014_GRBM_STATUS2 = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1333 | RREG32(R_008014_GRBM_STATUS2)); |
Jerome Glisse | 64c56e8 | 2013-01-02 17:30:35 -0500 | [diff] [blame] | 1334 | dev_info(rdev->dev, " R_000E50_SRBM_STATUS = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1335 | RREG32(R_000E50_SRBM_STATUS)); |
Jerome Glisse | 440a7cd | 2012-06-27 12:25:01 -0400 | [diff] [blame] | 1336 | dev_info(rdev->dev, " R_008674_CP_STALLED_STAT1 = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1337 | RREG32(CP_STALLED_STAT1)); |
Jerome Glisse | 440a7cd | 2012-06-27 12:25:01 -0400 | [diff] [blame] | 1338 | dev_info(rdev->dev, " R_008678_CP_STALLED_STAT2 = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1339 | RREG32(CP_STALLED_STAT2)); |
Jerome Glisse | 440a7cd | 2012-06-27 12:25:01 -0400 | [diff] [blame] | 1340 | dev_info(rdev->dev, " R_00867C_CP_BUSY_STAT = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1341 | RREG32(CP_BUSY_STAT)); |
Jerome Glisse | 440a7cd | 2012-06-27 12:25:01 -0400 | [diff] [blame] | 1342 | dev_info(rdev->dev, " R_008680_CP_STAT = 0x%08X\n", |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1343 | RREG32(CP_STAT)); |
Alex Deucher | 71e3d15 | 2013-01-03 12:20:35 -0500 | [diff] [blame] | 1344 | dev_info(rdev->dev, " R_00D034_DMA_STATUS_REG = 0x%08X\n", |
| 1345 | RREG32(DMA_STATUS_REG)); |
| 1346 | } |
| 1347 | |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1348 | static bool r600_is_display_hung(struct radeon_device *rdev) |
| 1349 | { |
| 1350 | u32 crtc_hung = 0; |
| 1351 | u32 crtc_status[2]; |
| 1352 | u32 i, j, tmp; |
| 1353 | |
| 1354 | for (i = 0; i < rdev->num_crtc; i++) { |
| 1355 | if (RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[i]) & AVIVO_CRTC_EN) { |
| 1356 | crtc_status[i] = RREG32(AVIVO_D1CRTC_STATUS_HV_COUNT + crtc_offsets[i]); |
| 1357 | crtc_hung |= (1 << i); |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | for (j = 0; j < 10; j++) { |
| 1362 | for (i = 0; i < rdev->num_crtc; i++) { |
| 1363 | if (crtc_hung & (1 << i)) { |
| 1364 | tmp = RREG32(AVIVO_D1CRTC_STATUS_HV_COUNT + crtc_offsets[i]); |
| 1365 | if (tmp != crtc_status[i]) |
| 1366 | crtc_hung &= ~(1 << i); |
| 1367 | } |
| 1368 | } |
| 1369 | if (crtc_hung == 0) |
| 1370 | return false; |
| 1371 | udelay(100); |
| 1372 | } |
| 1373 | |
| 1374 | return true; |
| 1375 | } |
| 1376 | |
Christian König | 2483b4e | 2013-08-13 11:56:54 +0200 | [diff] [blame] | 1377 | u32 r600_gpu_check_soft_reset(struct radeon_device *rdev) |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1378 | { |
| 1379 | u32 reset_mask = 0; |
| 1380 | u32 tmp; |
| 1381 | |
| 1382 | /* GRBM_STATUS */ |
| 1383 | tmp = RREG32(R_008010_GRBM_STATUS); |
| 1384 | if (rdev->family >= CHIP_RV770) { |
| 1385 | if (G_008010_PA_BUSY(tmp) | G_008010_SC_BUSY(tmp) | |
| 1386 | G_008010_SH_BUSY(tmp) | G_008010_SX_BUSY(tmp) | |
| 1387 | G_008010_TA_BUSY(tmp) | G_008010_VGT_BUSY(tmp) | |
| 1388 | G_008010_DB03_BUSY(tmp) | G_008010_CB03_BUSY(tmp) | |
| 1389 | G_008010_SPI03_BUSY(tmp) | G_008010_VGT_BUSY_NO_DMA(tmp)) |
| 1390 | reset_mask |= RADEON_RESET_GFX; |
| 1391 | } else { |
| 1392 | if (G_008010_PA_BUSY(tmp) | G_008010_SC_BUSY(tmp) | |
| 1393 | G_008010_SH_BUSY(tmp) | G_008010_SX_BUSY(tmp) | |
| 1394 | G_008010_TA03_BUSY(tmp) | G_008010_VGT_BUSY(tmp) | |
| 1395 | G_008010_DB03_BUSY(tmp) | G_008010_CB03_BUSY(tmp) | |
| 1396 | G_008010_SPI03_BUSY(tmp) | G_008010_VGT_BUSY_NO_DMA(tmp)) |
| 1397 | reset_mask |= RADEON_RESET_GFX; |
| 1398 | } |
| 1399 | |
| 1400 | if (G_008010_CF_RQ_PENDING(tmp) | G_008010_PF_RQ_PENDING(tmp) | |
| 1401 | G_008010_CP_BUSY(tmp) | G_008010_CP_COHERENCY_BUSY(tmp)) |
| 1402 | reset_mask |= RADEON_RESET_CP; |
| 1403 | |
| 1404 | if (G_008010_GRBM_EE_BUSY(tmp)) |
| 1405 | reset_mask |= RADEON_RESET_GRBM | RADEON_RESET_GFX | RADEON_RESET_CP; |
| 1406 | |
| 1407 | /* DMA_STATUS_REG */ |
| 1408 | tmp = RREG32(DMA_STATUS_REG); |
| 1409 | if (!(tmp & DMA_IDLE)) |
| 1410 | reset_mask |= RADEON_RESET_DMA; |
| 1411 | |
| 1412 | /* SRBM_STATUS */ |
| 1413 | tmp = RREG32(R_000E50_SRBM_STATUS); |
| 1414 | if (G_000E50_RLC_RQ_PENDING(tmp) | G_000E50_RLC_BUSY(tmp)) |
| 1415 | reset_mask |= RADEON_RESET_RLC; |
| 1416 | |
| 1417 | if (G_000E50_IH_BUSY(tmp)) |
| 1418 | reset_mask |= RADEON_RESET_IH; |
| 1419 | |
| 1420 | if (G_000E50_SEM_BUSY(tmp)) |
| 1421 | reset_mask |= RADEON_RESET_SEM; |
| 1422 | |
| 1423 | if (G_000E50_GRBM_RQ_PENDING(tmp)) |
| 1424 | reset_mask |= RADEON_RESET_GRBM; |
| 1425 | |
| 1426 | if (G_000E50_VMC_BUSY(tmp)) |
| 1427 | reset_mask |= RADEON_RESET_VMC; |
| 1428 | |
| 1429 | if (G_000E50_MCB_BUSY(tmp) | G_000E50_MCDZ_BUSY(tmp) | |
| 1430 | G_000E50_MCDY_BUSY(tmp) | G_000E50_MCDX_BUSY(tmp) | |
| 1431 | G_000E50_MCDW_BUSY(tmp)) |
| 1432 | reset_mask |= RADEON_RESET_MC; |
| 1433 | |
| 1434 | if (r600_is_display_hung(rdev)) |
| 1435 | reset_mask |= RADEON_RESET_DISPLAY; |
| 1436 | |
Alex Deucher | d808fc8 | 2013-02-28 10:03:08 -0500 | [diff] [blame] | 1437 | /* Skip MC reset as it's mostly likely not hung, just busy */ |
| 1438 | if (reset_mask & RADEON_RESET_MC) { |
| 1439 | DRM_DEBUG("MC busy: 0x%08X, clearing.\n", reset_mask); |
| 1440 | reset_mask &= ~RADEON_RESET_MC; |
| 1441 | } |
| 1442 | |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1443 | return reset_mask; |
| 1444 | } |
| 1445 | |
| 1446 | static void r600_gpu_soft_reset(struct radeon_device *rdev, u32 reset_mask) |
Alex Deucher | 71e3d15 | 2013-01-03 12:20:35 -0500 | [diff] [blame] | 1447 | { |
| 1448 | struct rv515_mc_save save; |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1449 | u32 grbm_soft_reset = 0, srbm_soft_reset = 0; |
| 1450 | u32 tmp; |
Alex Deucher | 19fc42e | 2013-01-14 11:04:39 -0500 | [diff] [blame] | 1451 | |
Alex Deucher | 71e3d15 | 2013-01-03 12:20:35 -0500 | [diff] [blame] | 1452 | if (reset_mask == 0) |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1453 | return; |
Alex Deucher | 71e3d15 | 2013-01-03 12:20:35 -0500 | [diff] [blame] | 1454 | |
| 1455 | dev_info(rdev->dev, "GPU softreset: 0x%08X\n", reset_mask); |
| 1456 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1457 | r600_print_gpu_status_regs(rdev); |
| 1458 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1459 | /* Disable CP parsing/prefetching */ |
| 1460 | if (rdev->family >= CHIP_RV770) |
| 1461 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1) | S_0086D8_CP_PFP_HALT(1)); |
| 1462 | else |
| 1463 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); |
Alex Deucher | 71e3d15 | 2013-01-03 12:20:35 -0500 | [diff] [blame] | 1464 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1465 | /* disable the RLC */ |
| 1466 | WREG32(RLC_CNTL, 0); |
| 1467 | |
| 1468 | if (reset_mask & RADEON_RESET_DMA) { |
| 1469 | /* Disable DMA */ |
| 1470 | tmp = RREG32(DMA_RB_CNTL); |
| 1471 | tmp &= ~DMA_RB_ENABLE; |
| 1472 | WREG32(DMA_RB_CNTL, tmp); |
| 1473 | } |
| 1474 | |
| 1475 | mdelay(50); |
| 1476 | |
Alex Deucher | ca57802 | 2013-01-23 18:56:08 -0500 | [diff] [blame] | 1477 | rv515_mc_stop(rdev, &save); |
| 1478 | if (r600_mc_wait_for_idle(rdev)) { |
| 1479 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 1480 | } |
| 1481 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1482 | if (reset_mask & (RADEON_RESET_GFX | RADEON_RESET_COMPUTE)) { |
| 1483 | if (rdev->family >= CHIP_RV770) |
| 1484 | grbm_soft_reset |= S_008020_SOFT_RESET_DB(1) | |
| 1485 | S_008020_SOFT_RESET_CB(1) | |
| 1486 | S_008020_SOFT_RESET_PA(1) | |
| 1487 | S_008020_SOFT_RESET_SC(1) | |
| 1488 | S_008020_SOFT_RESET_SPI(1) | |
| 1489 | S_008020_SOFT_RESET_SX(1) | |
| 1490 | S_008020_SOFT_RESET_SH(1) | |
| 1491 | S_008020_SOFT_RESET_TC(1) | |
| 1492 | S_008020_SOFT_RESET_TA(1) | |
| 1493 | S_008020_SOFT_RESET_VC(1) | |
| 1494 | S_008020_SOFT_RESET_VGT(1); |
| 1495 | else |
| 1496 | grbm_soft_reset |= S_008020_SOFT_RESET_CR(1) | |
| 1497 | S_008020_SOFT_RESET_DB(1) | |
| 1498 | S_008020_SOFT_RESET_CB(1) | |
| 1499 | S_008020_SOFT_RESET_PA(1) | |
| 1500 | S_008020_SOFT_RESET_SC(1) | |
| 1501 | S_008020_SOFT_RESET_SMX(1) | |
| 1502 | S_008020_SOFT_RESET_SPI(1) | |
| 1503 | S_008020_SOFT_RESET_SX(1) | |
| 1504 | S_008020_SOFT_RESET_SH(1) | |
| 1505 | S_008020_SOFT_RESET_TC(1) | |
| 1506 | S_008020_SOFT_RESET_TA(1) | |
| 1507 | S_008020_SOFT_RESET_VC(1) | |
| 1508 | S_008020_SOFT_RESET_VGT(1); |
| 1509 | } |
| 1510 | |
| 1511 | if (reset_mask & RADEON_RESET_CP) { |
| 1512 | grbm_soft_reset |= S_008020_SOFT_RESET_CP(1) | |
| 1513 | S_008020_SOFT_RESET_VGT(1); |
| 1514 | |
| 1515 | srbm_soft_reset |= S_000E60_SOFT_RESET_GRBM(1); |
| 1516 | } |
| 1517 | |
| 1518 | if (reset_mask & RADEON_RESET_DMA) { |
| 1519 | if (rdev->family >= CHIP_RV770) |
| 1520 | srbm_soft_reset |= RV770_SOFT_RESET_DMA; |
| 1521 | else |
| 1522 | srbm_soft_reset |= SOFT_RESET_DMA; |
| 1523 | } |
| 1524 | |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1525 | if (reset_mask & RADEON_RESET_RLC) |
| 1526 | srbm_soft_reset |= S_000E60_SOFT_RESET_RLC(1); |
| 1527 | |
| 1528 | if (reset_mask & RADEON_RESET_SEM) |
| 1529 | srbm_soft_reset |= S_000E60_SOFT_RESET_SEM(1); |
| 1530 | |
| 1531 | if (reset_mask & RADEON_RESET_IH) |
| 1532 | srbm_soft_reset |= S_000E60_SOFT_RESET_IH(1); |
| 1533 | |
| 1534 | if (reset_mask & RADEON_RESET_GRBM) |
| 1535 | srbm_soft_reset |= S_000E60_SOFT_RESET_GRBM(1); |
| 1536 | |
Alex Deucher | 24178ec | 2013-01-24 15:00:17 -0500 | [diff] [blame] | 1537 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 1538 | if (reset_mask & RADEON_RESET_MC) |
| 1539 | srbm_soft_reset |= S_000E60_SOFT_RESET_MC(1); |
| 1540 | } |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1541 | |
| 1542 | if (reset_mask & RADEON_RESET_VMC) |
| 1543 | srbm_soft_reset |= S_000E60_SOFT_RESET_VMC(1); |
| 1544 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1545 | if (grbm_soft_reset) { |
| 1546 | tmp = RREG32(R_008020_GRBM_SOFT_RESET); |
| 1547 | tmp |= grbm_soft_reset; |
| 1548 | dev_info(rdev->dev, "R_008020_GRBM_SOFT_RESET=0x%08X\n", tmp); |
| 1549 | WREG32(R_008020_GRBM_SOFT_RESET, tmp); |
| 1550 | tmp = RREG32(R_008020_GRBM_SOFT_RESET); |
| 1551 | |
| 1552 | udelay(50); |
| 1553 | |
| 1554 | tmp &= ~grbm_soft_reset; |
| 1555 | WREG32(R_008020_GRBM_SOFT_RESET, tmp); |
| 1556 | tmp = RREG32(R_008020_GRBM_SOFT_RESET); |
| 1557 | } |
| 1558 | |
| 1559 | if (srbm_soft_reset) { |
| 1560 | tmp = RREG32(SRBM_SOFT_RESET); |
| 1561 | tmp |= srbm_soft_reset; |
| 1562 | dev_info(rdev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp); |
| 1563 | WREG32(SRBM_SOFT_RESET, tmp); |
| 1564 | tmp = RREG32(SRBM_SOFT_RESET); |
| 1565 | |
| 1566 | udelay(50); |
| 1567 | |
| 1568 | tmp &= ~srbm_soft_reset; |
| 1569 | WREG32(SRBM_SOFT_RESET, tmp); |
| 1570 | tmp = RREG32(SRBM_SOFT_RESET); |
| 1571 | } |
Alex Deucher | 71e3d15 | 2013-01-03 12:20:35 -0500 | [diff] [blame] | 1572 | |
| 1573 | /* Wait a little for things to settle down */ |
| 1574 | mdelay(1); |
| 1575 | |
Jerome Glisse | a3c1945 | 2009-10-01 18:02:13 +0200 | [diff] [blame] | 1576 | rv515_mc_resume(rdev, &save); |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1577 | udelay(50); |
Alex Deucher | 410a341 | 2013-01-18 13:05:39 -0500 | [diff] [blame] | 1578 | |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1579 | r600_print_gpu_status_regs(rdev); |
Alex Deucher | d3cb781 | 2013-01-18 13:53:37 -0500 | [diff] [blame] | 1580 | } |
| 1581 | |
| 1582 | int r600_asic_reset(struct radeon_device *rdev) |
| 1583 | { |
Alex Deucher | f13f773 | 2013-01-18 18:12:22 -0500 | [diff] [blame] | 1584 | u32 reset_mask; |
| 1585 | |
| 1586 | reset_mask = r600_gpu_check_soft_reset(rdev); |
| 1587 | |
| 1588 | if (reset_mask) |
| 1589 | r600_set_bios_scratch_engine_hung(rdev, true); |
| 1590 | |
| 1591 | r600_gpu_soft_reset(rdev, reset_mask); |
| 1592 | |
| 1593 | reset_mask = r600_gpu_check_soft_reset(rdev); |
| 1594 | |
| 1595 | if (!reset_mask) |
| 1596 | r600_set_bios_scratch_engine_hung(rdev, false); |
| 1597 | |
| 1598 | return 0; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1599 | } |
| 1600 | |
Alex Deucher | 123bc18 | 2013-01-24 11:37:19 -0500 | [diff] [blame] | 1601 | /** |
| 1602 | * r600_gfx_is_lockup - Check if the GFX engine is locked up |
| 1603 | * |
| 1604 | * @rdev: radeon_device pointer |
| 1605 | * @ring: radeon_ring structure holding ring information |
| 1606 | * |
| 1607 | * Check if the GFX engine is locked up. |
| 1608 | * Returns true if the engine appears to be locked up, false if not. |
| 1609 | */ |
| 1610 | bool r600_gfx_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring) |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 1611 | { |
Alex Deucher | 123bc18 | 2013-01-24 11:37:19 -0500 | [diff] [blame] | 1612 | u32 reset_mask = r600_gpu_check_soft_reset(rdev); |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 1613 | |
Alex Deucher | 123bc18 | 2013-01-24 11:37:19 -0500 | [diff] [blame] | 1614 | if (!(reset_mask & (RADEON_RESET_GFX | |
| 1615 | RADEON_RESET_COMPUTE | |
| 1616 | RADEON_RESET_CP))) { |
Christian König | 069211e | 2012-05-02 15:11:20 +0200 | [diff] [blame] | 1617 | radeon_ring_lockup_update(ring); |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 1618 | return false; |
| 1619 | } |
| 1620 | /* force CP activities */ |
Christian König | 7b9ef16 | 2012-05-02 15:11:23 +0200 | [diff] [blame] | 1621 | radeon_ring_force_activity(rdev, ring); |
Christian König | 069211e | 2012-05-02 15:11:20 +0200 | [diff] [blame] | 1622 | return radeon_ring_test_lockup(rdev, ring); |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 1623 | } |
| 1624 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1625 | u32 r6xx_remap_render_backend(struct radeon_device *rdev, |
| 1626 | u32 tiling_pipe_num, |
| 1627 | u32 max_rb_num, |
| 1628 | u32 total_max_rb_num, |
| 1629 | u32 disabled_rb_mask) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1630 | { |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1631 | u32 rendering_pipe_num, rb_num_width, req_rb_num; |
Mikko Tiihonen | f689e3a | 2013-01-30 14:10:04 -0500 | [diff] [blame] | 1632 | u32 pipe_rb_ratio, pipe_rb_remain, tmp; |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1633 | u32 data = 0, mask = 1 << (max_rb_num - 1); |
| 1634 | unsigned i, j; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1635 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1636 | /* mask out the RBs that don't exist on that asic */ |
Mikko Tiihonen | f689e3a | 2013-01-30 14:10:04 -0500 | [diff] [blame] | 1637 | tmp = disabled_rb_mask | ((0xff << max_rb_num) & 0xff); |
| 1638 | /* make sure at least one RB is available */ |
| 1639 | if ((tmp & 0xff) != 0xff) |
| 1640 | disabled_rb_mask = tmp; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1641 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1642 | rendering_pipe_num = 1 << tiling_pipe_num; |
| 1643 | req_rb_num = total_max_rb_num - r600_count_pipe_bits(disabled_rb_mask); |
| 1644 | BUG_ON(rendering_pipe_num < req_rb_num); |
| 1645 | |
| 1646 | pipe_rb_ratio = rendering_pipe_num / req_rb_num; |
| 1647 | pipe_rb_remain = rendering_pipe_num - pipe_rb_ratio * req_rb_num; |
| 1648 | |
| 1649 | if (rdev->family <= CHIP_RV740) { |
| 1650 | /* r6xx/r7xx */ |
| 1651 | rb_num_width = 2; |
| 1652 | } else { |
| 1653 | /* eg+ */ |
| 1654 | rb_num_width = 4; |
| 1655 | } |
| 1656 | |
| 1657 | for (i = 0; i < max_rb_num; i++) { |
| 1658 | if (!(mask & disabled_rb_mask)) { |
| 1659 | for (j = 0; j < pipe_rb_ratio; j++) { |
| 1660 | data <<= rb_num_width; |
| 1661 | data |= max_rb_num - i - 1; |
| 1662 | } |
| 1663 | if (pipe_rb_remain) { |
| 1664 | data <<= rb_num_width; |
| 1665 | data |= max_rb_num - i - 1; |
| 1666 | pipe_rb_remain--; |
| 1667 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1668 | } |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1669 | mask >>= 1; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1670 | } |
| 1671 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1672 | return data; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1673 | } |
| 1674 | |
| 1675 | int r600_count_pipe_bits(uint32_t val) |
| 1676 | { |
Akinobu Mita | ef8cf3a | 2012-11-09 12:10:41 +0000 | [diff] [blame] | 1677 | return hweight32(val); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1678 | } |
| 1679 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 1680 | static void r600_gpu_init(struct radeon_device *rdev) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1681 | { |
| 1682 | u32 tiling_config; |
| 1683 | u32 ramcfg; |
Alex Deucher | d03f5d5 | 2010-02-19 16:22:31 -0500 | [diff] [blame] | 1684 | u32 cc_rb_backend_disable; |
| 1685 | u32 cc_gc_shader_pipe_config; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1686 | u32 tmp; |
| 1687 | int i, j; |
| 1688 | u32 sq_config; |
| 1689 | u32 sq_gpr_resource_mgmt_1 = 0; |
| 1690 | u32 sq_gpr_resource_mgmt_2 = 0; |
| 1691 | u32 sq_thread_resource_mgmt = 0; |
| 1692 | u32 sq_stack_resource_mgmt_1 = 0; |
| 1693 | u32 sq_stack_resource_mgmt_2 = 0; |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1694 | u32 disabled_rb_mask; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1695 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1696 | rdev->config.r600.tiling_group_size = 256; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1697 | switch (rdev->family) { |
| 1698 | case CHIP_R600: |
| 1699 | rdev->config.r600.max_pipes = 4; |
| 1700 | rdev->config.r600.max_tile_pipes = 8; |
| 1701 | rdev->config.r600.max_simds = 4; |
| 1702 | rdev->config.r600.max_backends = 4; |
| 1703 | rdev->config.r600.max_gprs = 256; |
| 1704 | rdev->config.r600.max_threads = 192; |
| 1705 | rdev->config.r600.max_stack_entries = 256; |
| 1706 | rdev->config.r600.max_hw_contexts = 8; |
| 1707 | rdev->config.r600.max_gs_threads = 16; |
| 1708 | rdev->config.r600.sx_max_export_size = 128; |
| 1709 | rdev->config.r600.sx_max_export_pos_size = 16; |
| 1710 | rdev->config.r600.sx_max_export_smx_size = 128; |
| 1711 | rdev->config.r600.sq_num_cf_insts = 2; |
| 1712 | break; |
| 1713 | case CHIP_RV630: |
| 1714 | case CHIP_RV635: |
| 1715 | rdev->config.r600.max_pipes = 2; |
| 1716 | rdev->config.r600.max_tile_pipes = 2; |
| 1717 | rdev->config.r600.max_simds = 3; |
| 1718 | rdev->config.r600.max_backends = 1; |
| 1719 | rdev->config.r600.max_gprs = 128; |
| 1720 | rdev->config.r600.max_threads = 192; |
| 1721 | rdev->config.r600.max_stack_entries = 128; |
| 1722 | rdev->config.r600.max_hw_contexts = 8; |
| 1723 | rdev->config.r600.max_gs_threads = 4; |
| 1724 | rdev->config.r600.sx_max_export_size = 128; |
| 1725 | rdev->config.r600.sx_max_export_pos_size = 16; |
| 1726 | rdev->config.r600.sx_max_export_smx_size = 128; |
| 1727 | rdev->config.r600.sq_num_cf_insts = 2; |
| 1728 | break; |
| 1729 | case CHIP_RV610: |
| 1730 | case CHIP_RV620: |
| 1731 | case CHIP_RS780: |
| 1732 | case CHIP_RS880: |
| 1733 | rdev->config.r600.max_pipes = 1; |
| 1734 | rdev->config.r600.max_tile_pipes = 1; |
| 1735 | rdev->config.r600.max_simds = 2; |
| 1736 | rdev->config.r600.max_backends = 1; |
| 1737 | rdev->config.r600.max_gprs = 128; |
| 1738 | rdev->config.r600.max_threads = 192; |
| 1739 | rdev->config.r600.max_stack_entries = 128; |
| 1740 | rdev->config.r600.max_hw_contexts = 4; |
| 1741 | rdev->config.r600.max_gs_threads = 4; |
| 1742 | rdev->config.r600.sx_max_export_size = 128; |
| 1743 | rdev->config.r600.sx_max_export_pos_size = 16; |
| 1744 | rdev->config.r600.sx_max_export_smx_size = 128; |
| 1745 | rdev->config.r600.sq_num_cf_insts = 1; |
| 1746 | break; |
| 1747 | case CHIP_RV670: |
| 1748 | rdev->config.r600.max_pipes = 4; |
| 1749 | rdev->config.r600.max_tile_pipes = 4; |
| 1750 | rdev->config.r600.max_simds = 4; |
| 1751 | rdev->config.r600.max_backends = 4; |
| 1752 | rdev->config.r600.max_gprs = 192; |
| 1753 | rdev->config.r600.max_threads = 192; |
| 1754 | rdev->config.r600.max_stack_entries = 256; |
| 1755 | rdev->config.r600.max_hw_contexts = 8; |
| 1756 | rdev->config.r600.max_gs_threads = 16; |
| 1757 | rdev->config.r600.sx_max_export_size = 128; |
| 1758 | rdev->config.r600.sx_max_export_pos_size = 16; |
| 1759 | rdev->config.r600.sx_max_export_smx_size = 128; |
| 1760 | rdev->config.r600.sq_num_cf_insts = 2; |
| 1761 | break; |
| 1762 | default: |
| 1763 | break; |
| 1764 | } |
| 1765 | |
| 1766 | /* Initialize HDP */ |
| 1767 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 1768 | WREG32((0x2c14 + j), 0x00000000); |
| 1769 | WREG32((0x2c18 + j), 0x00000000); |
| 1770 | WREG32((0x2c1c + j), 0x00000000); |
| 1771 | WREG32((0x2c20 + j), 0x00000000); |
| 1772 | WREG32((0x2c24 + j), 0x00000000); |
| 1773 | } |
| 1774 | |
| 1775 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); |
| 1776 | |
| 1777 | /* Setup tiling */ |
| 1778 | tiling_config = 0; |
| 1779 | ramcfg = RREG32(RAMCFG); |
| 1780 | switch (rdev->config.r600.max_tile_pipes) { |
| 1781 | case 1: |
| 1782 | tiling_config |= PIPE_TILING(0); |
| 1783 | break; |
| 1784 | case 2: |
| 1785 | tiling_config |= PIPE_TILING(1); |
| 1786 | break; |
| 1787 | case 4: |
| 1788 | tiling_config |= PIPE_TILING(2); |
| 1789 | break; |
| 1790 | case 8: |
| 1791 | tiling_config |= PIPE_TILING(3); |
| 1792 | break; |
| 1793 | default: |
| 1794 | break; |
| 1795 | } |
Alex Deucher | d03f5d5 | 2010-02-19 16:22:31 -0500 | [diff] [blame] | 1796 | rdev->config.r600.tiling_npipes = rdev->config.r600.max_tile_pipes; |
Jerome Glisse | 961fb59 | 2010-02-10 22:30:05 +0000 | [diff] [blame] | 1797 | rdev->config.r600.tiling_nbanks = 4 << ((ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1798 | tiling_config |= BANK_TILING((ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT); |
Alex Deucher | 881fe6c | 2010-10-18 23:54:56 -0400 | [diff] [blame] | 1799 | tiling_config |= GROUP_SIZE((ramcfg & BURSTLENGTH_MASK) >> BURSTLENGTH_SHIFT); |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1800 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1801 | tmp = (ramcfg & NOOFROWS_MASK) >> NOOFROWS_SHIFT; |
| 1802 | if (tmp > 3) { |
| 1803 | tiling_config |= ROW_TILING(3); |
| 1804 | tiling_config |= SAMPLE_SPLIT(3); |
| 1805 | } else { |
| 1806 | tiling_config |= ROW_TILING(tmp); |
| 1807 | tiling_config |= SAMPLE_SPLIT(tmp); |
| 1808 | } |
| 1809 | tiling_config |= BANK_SWAPS(1); |
Alex Deucher | d03f5d5 | 2010-02-19 16:22:31 -0500 | [diff] [blame] | 1810 | |
| 1811 | cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE) & 0x00ff0000; |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1812 | tmp = R6XX_MAX_BACKENDS - |
| 1813 | r600_count_pipe_bits((cc_rb_backend_disable >> 16) & R6XX_MAX_BACKENDS_MASK); |
| 1814 | if (tmp < rdev->config.r600.max_backends) { |
| 1815 | rdev->config.r600.max_backends = tmp; |
| 1816 | } |
Alex Deucher | d03f5d5 | 2010-02-19 16:22:31 -0500 | [diff] [blame] | 1817 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1818 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0x00ffff00; |
| 1819 | tmp = R6XX_MAX_PIPES - |
| 1820 | r600_count_pipe_bits((cc_gc_shader_pipe_config >> 8) & R6XX_MAX_PIPES_MASK); |
| 1821 | if (tmp < rdev->config.r600.max_pipes) { |
| 1822 | rdev->config.r600.max_pipes = tmp; |
| 1823 | } |
| 1824 | tmp = R6XX_MAX_SIMDS - |
| 1825 | r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R6XX_MAX_SIMDS_MASK); |
| 1826 | if (tmp < rdev->config.r600.max_simds) { |
| 1827 | rdev->config.r600.max_simds = tmp; |
| 1828 | } |
Alex Deucher | d03f5d5 | 2010-02-19 16:22:31 -0500 | [diff] [blame] | 1829 | |
Alex Deucher | 416a2bd | 2012-05-31 19:00:25 -0400 | [diff] [blame] | 1830 | disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R6XX_MAX_BACKENDS_MASK; |
| 1831 | tmp = (tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT; |
| 1832 | tmp = r6xx_remap_render_backend(rdev, tmp, rdev->config.r600.max_backends, |
| 1833 | R6XX_MAX_BACKENDS, disabled_rb_mask); |
| 1834 | tiling_config |= tmp << 16; |
| 1835 | rdev->config.r600.backend_map = tmp; |
| 1836 | |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 1837 | rdev->config.r600.tile_config = tiling_config; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1838 | WREG32(GB_TILING_CONFIG, tiling_config); |
| 1839 | WREG32(DCP_TILING_CONFIG, tiling_config & 0xffff); |
| 1840 | WREG32(HDP_TILING_CONFIG, tiling_config & 0xffff); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 1841 | WREG32(DMA_TILING_CONFIG, tiling_config & 0xffff); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1842 | |
Alex Deucher | d03f5d5 | 2010-02-19 16:22:31 -0500 | [diff] [blame] | 1843 | tmp = R6XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1844 | WREG32(VGT_OUT_DEALLOC_CNTL, (tmp * 4) & DEALLOC_DIST_MASK); |
| 1845 | WREG32(VGT_VERTEX_REUSE_BLOCK_CNTL, ((tmp * 4) - 2) & VTX_REUSE_DEPTH_MASK); |
| 1846 | |
| 1847 | /* Setup some CP states */ |
| 1848 | WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | ROQ_IB2_START(0x2b))); |
| 1849 | WREG32(CP_MEQ_THRESHOLDS, (MEQ_END(0x40) | ROQ_END(0x40))); |
| 1850 | |
| 1851 | WREG32(TA_CNTL_AUX, (DISABLE_CUBE_ANISO | SYNC_GRADIENT | |
| 1852 | SYNC_WALKER | SYNC_ALIGNER)); |
| 1853 | /* Setup various GPU states */ |
| 1854 | if (rdev->family == CHIP_RV670) |
| 1855 | WREG32(ARB_GDEC_RD_CNTL, 0x00000021); |
| 1856 | |
| 1857 | tmp = RREG32(SX_DEBUG_1); |
| 1858 | tmp |= SMX_EVENT_RELEASE; |
| 1859 | if ((rdev->family > CHIP_R600)) |
| 1860 | tmp |= ENABLE_NEW_SMX_ADDRESS; |
| 1861 | WREG32(SX_DEBUG_1, tmp); |
| 1862 | |
| 1863 | if (((rdev->family) == CHIP_R600) || |
| 1864 | ((rdev->family) == CHIP_RV630) || |
| 1865 | ((rdev->family) == CHIP_RV610) || |
| 1866 | ((rdev->family) == CHIP_RV620) || |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 1867 | ((rdev->family) == CHIP_RS780) || |
| 1868 | ((rdev->family) == CHIP_RS880)) { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1869 | WREG32(DB_DEBUG, PREZ_MUST_WAIT_FOR_POSTZ_DONE); |
| 1870 | } else { |
| 1871 | WREG32(DB_DEBUG, 0); |
| 1872 | } |
| 1873 | WREG32(DB_WATERMARKS, (DEPTH_FREE(4) | DEPTH_CACHELINE_FREE(16) | |
| 1874 | DEPTH_FLUSH(16) | DEPTH_PENDING_FREE(4))); |
| 1875 | |
| 1876 | WREG32(PA_SC_MULTI_CHIP_CNTL, 0); |
| 1877 | WREG32(VGT_NUM_INSTANCES, 0); |
| 1878 | |
| 1879 | WREG32(SPI_CONFIG_CNTL, GPR_WRITE_PRIORITY(0)); |
| 1880 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(0)); |
| 1881 | |
| 1882 | tmp = RREG32(SQ_MS_FIFO_SIZES); |
| 1883 | if (((rdev->family) == CHIP_RV610) || |
| 1884 | ((rdev->family) == CHIP_RV620) || |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 1885 | ((rdev->family) == CHIP_RS780) || |
| 1886 | ((rdev->family) == CHIP_RS880)) { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1887 | tmp = (CACHE_FIFO_SIZE(0xa) | |
| 1888 | FETCH_FIFO_HIWATER(0xa) | |
| 1889 | DONE_FIFO_HIWATER(0xe0) | |
| 1890 | ALU_UPDATE_FIFO_HIWATER(0x8)); |
| 1891 | } else if (((rdev->family) == CHIP_R600) || |
| 1892 | ((rdev->family) == CHIP_RV630)) { |
| 1893 | tmp &= ~DONE_FIFO_HIWATER(0xff); |
| 1894 | tmp |= DONE_FIFO_HIWATER(0x4); |
| 1895 | } |
| 1896 | WREG32(SQ_MS_FIFO_SIZES, tmp); |
| 1897 | |
| 1898 | /* SQ_CONFIG, SQ_GPR_RESOURCE_MGMT, SQ_THREAD_RESOURCE_MGMT, SQ_STACK_RESOURCE_MGMT |
| 1899 | * should be adjusted as needed by the 2D/3D drivers. This just sets default values |
| 1900 | */ |
| 1901 | sq_config = RREG32(SQ_CONFIG); |
| 1902 | sq_config &= ~(PS_PRIO(3) | |
| 1903 | VS_PRIO(3) | |
| 1904 | GS_PRIO(3) | |
| 1905 | ES_PRIO(3)); |
| 1906 | sq_config |= (DX9_CONSTS | |
| 1907 | VC_ENABLE | |
| 1908 | PS_PRIO(0) | |
| 1909 | VS_PRIO(1) | |
| 1910 | GS_PRIO(2) | |
| 1911 | ES_PRIO(3)); |
| 1912 | |
| 1913 | if ((rdev->family) == CHIP_R600) { |
| 1914 | sq_gpr_resource_mgmt_1 = (NUM_PS_GPRS(124) | |
| 1915 | NUM_VS_GPRS(124) | |
| 1916 | NUM_CLAUSE_TEMP_GPRS(4)); |
| 1917 | sq_gpr_resource_mgmt_2 = (NUM_GS_GPRS(0) | |
| 1918 | NUM_ES_GPRS(0)); |
| 1919 | sq_thread_resource_mgmt = (NUM_PS_THREADS(136) | |
| 1920 | NUM_VS_THREADS(48) | |
| 1921 | NUM_GS_THREADS(4) | |
| 1922 | NUM_ES_THREADS(4)); |
| 1923 | sq_stack_resource_mgmt_1 = (NUM_PS_STACK_ENTRIES(128) | |
| 1924 | NUM_VS_STACK_ENTRIES(128)); |
| 1925 | sq_stack_resource_mgmt_2 = (NUM_GS_STACK_ENTRIES(0) | |
| 1926 | NUM_ES_STACK_ENTRIES(0)); |
| 1927 | } else if (((rdev->family) == CHIP_RV610) || |
| 1928 | ((rdev->family) == CHIP_RV620) || |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 1929 | ((rdev->family) == CHIP_RS780) || |
| 1930 | ((rdev->family) == CHIP_RS880)) { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1931 | /* no vertex cache */ |
| 1932 | sq_config &= ~VC_ENABLE; |
| 1933 | |
| 1934 | sq_gpr_resource_mgmt_1 = (NUM_PS_GPRS(44) | |
| 1935 | NUM_VS_GPRS(44) | |
| 1936 | NUM_CLAUSE_TEMP_GPRS(2)); |
| 1937 | sq_gpr_resource_mgmt_2 = (NUM_GS_GPRS(17) | |
| 1938 | NUM_ES_GPRS(17)); |
| 1939 | sq_thread_resource_mgmt = (NUM_PS_THREADS(79) | |
| 1940 | NUM_VS_THREADS(78) | |
| 1941 | NUM_GS_THREADS(4) | |
| 1942 | NUM_ES_THREADS(31)); |
| 1943 | sq_stack_resource_mgmt_1 = (NUM_PS_STACK_ENTRIES(40) | |
| 1944 | NUM_VS_STACK_ENTRIES(40)); |
| 1945 | sq_stack_resource_mgmt_2 = (NUM_GS_STACK_ENTRIES(32) | |
| 1946 | NUM_ES_STACK_ENTRIES(16)); |
| 1947 | } else if (((rdev->family) == CHIP_RV630) || |
| 1948 | ((rdev->family) == CHIP_RV635)) { |
| 1949 | sq_gpr_resource_mgmt_1 = (NUM_PS_GPRS(44) | |
| 1950 | NUM_VS_GPRS(44) | |
| 1951 | NUM_CLAUSE_TEMP_GPRS(2)); |
| 1952 | sq_gpr_resource_mgmt_2 = (NUM_GS_GPRS(18) | |
| 1953 | NUM_ES_GPRS(18)); |
| 1954 | sq_thread_resource_mgmt = (NUM_PS_THREADS(79) | |
| 1955 | NUM_VS_THREADS(78) | |
| 1956 | NUM_GS_THREADS(4) | |
| 1957 | NUM_ES_THREADS(31)); |
| 1958 | sq_stack_resource_mgmt_1 = (NUM_PS_STACK_ENTRIES(40) | |
| 1959 | NUM_VS_STACK_ENTRIES(40)); |
| 1960 | sq_stack_resource_mgmt_2 = (NUM_GS_STACK_ENTRIES(32) | |
| 1961 | NUM_ES_STACK_ENTRIES(16)); |
| 1962 | } else if ((rdev->family) == CHIP_RV670) { |
| 1963 | sq_gpr_resource_mgmt_1 = (NUM_PS_GPRS(44) | |
| 1964 | NUM_VS_GPRS(44) | |
| 1965 | NUM_CLAUSE_TEMP_GPRS(2)); |
| 1966 | sq_gpr_resource_mgmt_2 = (NUM_GS_GPRS(17) | |
| 1967 | NUM_ES_GPRS(17)); |
| 1968 | sq_thread_resource_mgmt = (NUM_PS_THREADS(79) | |
| 1969 | NUM_VS_THREADS(78) | |
| 1970 | NUM_GS_THREADS(4) | |
| 1971 | NUM_ES_THREADS(31)); |
| 1972 | sq_stack_resource_mgmt_1 = (NUM_PS_STACK_ENTRIES(64) | |
| 1973 | NUM_VS_STACK_ENTRIES(64)); |
| 1974 | sq_stack_resource_mgmt_2 = (NUM_GS_STACK_ENTRIES(64) | |
| 1975 | NUM_ES_STACK_ENTRIES(64)); |
| 1976 | } |
| 1977 | |
| 1978 | WREG32(SQ_CONFIG, sq_config); |
| 1979 | WREG32(SQ_GPR_RESOURCE_MGMT_1, sq_gpr_resource_mgmt_1); |
| 1980 | WREG32(SQ_GPR_RESOURCE_MGMT_2, sq_gpr_resource_mgmt_2); |
| 1981 | WREG32(SQ_THREAD_RESOURCE_MGMT, sq_thread_resource_mgmt); |
| 1982 | WREG32(SQ_STACK_RESOURCE_MGMT_1, sq_stack_resource_mgmt_1); |
| 1983 | WREG32(SQ_STACK_RESOURCE_MGMT_2, sq_stack_resource_mgmt_2); |
| 1984 | |
| 1985 | if (((rdev->family) == CHIP_RV610) || |
| 1986 | ((rdev->family) == CHIP_RV620) || |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 1987 | ((rdev->family) == CHIP_RS780) || |
| 1988 | ((rdev->family) == CHIP_RS880)) { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1989 | WREG32(VGT_CACHE_INVALIDATION, CACHE_INVALIDATION(TC_ONLY)); |
| 1990 | } else { |
| 1991 | WREG32(VGT_CACHE_INVALIDATION, CACHE_INVALIDATION(VC_AND_TC)); |
| 1992 | } |
| 1993 | |
| 1994 | /* More default values. 2D/3D driver should adjust as needed */ |
| 1995 | WREG32(PA_SC_AA_SAMPLE_LOCS_2S, (S0_X(0xc) | S0_Y(0x4) | |
| 1996 | S1_X(0x4) | S1_Y(0xc))); |
| 1997 | WREG32(PA_SC_AA_SAMPLE_LOCS_4S, (S0_X(0xe) | S0_Y(0xe) | |
| 1998 | S1_X(0x2) | S1_Y(0x2) | |
| 1999 | S2_X(0xa) | S2_Y(0x6) | |
| 2000 | S3_X(0x6) | S3_Y(0xa))); |
| 2001 | WREG32(PA_SC_AA_SAMPLE_LOCS_8S_WD0, (S0_X(0xe) | S0_Y(0xb) | |
| 2002 | S1_X(0x4) | S1_Y(0xc) | |
| 2003 | S2_X(0x1) | S2_Y(0x6) | |
| 2004 | S3_X(0xa) | S3_Y(0xe))); |
| 2005 | WREG32(PA_SC_AA_SAMPLE_LOCS_8S_WD1, (S4_X(0x6) | S4_Y(0x1) | |
| 2006 | S5_X(0x0) | S5_Y(0x0) | |
| 2007 | S6_X(0xb) | S6_Y(0x4) | |
| 2008 | S7_X(0x7) | S7_Y(0x8))); |
| 2009 | |
| 2010 | WREG32(VGT_STRMOUT_EN, 0); |
| 2011 | tmp = rdev->config.r600.max_pipes * 16; |
| 2012 | switch (rdev->family) { |
| 2013 | case CHIP_RV610: |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2014 | case CHIP_RV620: |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 2015 | case CHIP_RS780: |
| 2016 | case CHIP_RS880: |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2017 | tmp += 32; |
| 2018 | break; |
| 2019 | case CHIP_RV670: |
| 2020 | tmp += 128; |
| 2021 | break; |
| 2022 | default: |
| 2023 | break; |
| 2024 | } |
| 2025 | if (tmp > 256) { |
| 2026 | tmp = 256; |
| 2027 | } |
| 2028 | WREG32(VGT_ES_PER_GS, 128); |
| 2029 | WREG32(VGT_GS_PER_ES, tmp); |
| 2030 | WREG32(VGT_GS_PER_VS, 2); |
| 2031 | WREG32(VGT_GS_VERTEX_REUSE, 16); |
| 2032 | |
| 2033 | /* more default values. 2D/3D driver should adjust as needed */ |
| 2034 | WREG32(PA_SC_LINE_STIPPLE_STATE, 0); |
| 2035 | WREG32(VGT_STRMOUT_EN, 0); |
| 2036 | WREG32(SX_MISC, 0); |
| 2037 | WREG32(PA_SC_MODE_CNTL, 0); |
| 2038 | WREG32(PA_SC_AA_CONFIG, 0); |
| 2039 | WREG32(PA_SC_LINE_STIPPLE, 0); |
| 2040 | WREG32(SPI_INPUT_Z, 0); |
| 2041 | WREG32(SPI_PS_IN_CONTROL_0, NUM_INTERP(2)); |
| 2042 | WREG32(CB_COLOR7_FRAG, 0); |
| 2043 | |
| 2044 | /* Clear render buffer base addresses */ |
| 2045 | WREG32(CB_COLOR0_BASE, 0); |
| 2046 | WREG32(CB_COLOR1_BASE, 0); |
| 2047 | WREG32(CB_COLOR2_BASE, 0); |
| 2048 | WREG32(CB_COLOR3_BASE, 0); |
| 2049 | WREG32(CB_COLOR4_BASE, 0); |
| 2050 | WREG32(CB_COLOR5_BASE, 0); |
| 2051 | WREG32(CB_COLOR6_BASE, 0); |
| 2052 | WREG32(CB_COLOR7_BASE, 0); |
| 2053 | WREG32(CB_COLOR7_FRAG, 0); |
| 2054 | |
| 2055 | switch (rdev->family) { |
| 2056 | case CHIP_RV610: |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2057 | case CHIP_RV620: |
Alex Deucher | ee59f2b | 2009-11-05 13:11:46 -0500 | [diff] [blame] | 2058 | case CHIP_RS780: |
| 2059 | case CHIP_RS880: |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2060 | tmp = TC_L2_SIZE(8); |
| 2061 | break; |
| 2062 | case CHIP_RV630: |
| 2063 | case CHIP_RV635: |
| 2064 | tmp = TC_L2_SIZE(4); |
| 2065 | break; |
| 2066 | case CHIP_R600: |
| 2067 | tmp = TC_L2_SIZE(0) | L2_DISABLE_LATE_HIT; |
| 2068 | break; |
| 2069 | default: |
| 2070 | tmp = TC_L2_SIZE(0); |
| 2071 | break; |
| 2072 | } |
| 2073 | WREG32(TC_CNTL, tmp); |
| 2074 | |
| 2075 | tmp = RREG32(HDP_HOST_PATH_CNTL); |
| 2076 | WREG32(HDP_HOST_PATH_CNTL, tmp); |
| 2077 | |
| 2078 | tmp = RREG32(ARB_POP); |
| 2079 | tmp |= ENABLE_TC128; |
| 2080 | WREG32(ARB_POP, tmp); |
| 2081 | |
| 2082 | WREG32(PA_SC_MULTI_CHIP_CNTL, 0); |
| 2083 | WREG32(PA_CL_ENHANCE, (CLIP_VTX_REORDER_ENA | |
| 2084 | NUM_CLIP_SEQ(3))); |
| 2085 | WREG32(PA_SC_ENHANCE, FORCE_EOV_MAX_CLK_CNT(4095)); |
Alex Deucher | b866d13 | 2012-06-14 22:06:36 +0200 | [diff] [blame] | 2086 | WREG32(VC_ENHANCE, 0); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2090 | /* |
| 2091 | * Indirect registers accessor |
| 2092 | */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2093 | u32 r600_pciep_rreg(struct radeon_device *rdev, u32 reg) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2094 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2095 | u32 r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2096 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2097 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); |
| 2098 | (void)RREG32(PCIE_PORT_INDEX); |
| 2099 | r = RREG32(PCIE_PORT_DATA); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2100 | return r; |
| 2101 | } |
| 2102 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2103 | void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 2104 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2105 | WREG32(PCIE_PORT_INDEX, ((reg) & 0xff)); |
| 2106 | (void)RREG32(PCIE_PORT_INDEX); |
| 2107 | WREG32(PCIE_PORT_DATA, (v)); |
| 2108 | (void)RREG32(PCIE_PORT_DATA); |
| 2109 | } |
| 2110 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2111 | /* |
| 2112 | * CP & Ring |
| 2113 | */ |
| 2114 | void r600_cp_stop(struct radeon_device *rdev) |
| 2115 | { |
Dave Airlie | 5359533 | 2011-03-14 09:47:24 +1000 | [diff] [blame] | 2116 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2117 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2118 | WREG32(SCRATCH_UMSK, 0); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2119 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2120 | } |
| 2121 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2122 | int r600_init_microcode(struct radeon_device *rdev) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2123 | { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2124 | const char *chip_name; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2125 | const char *rlc_chip_name; |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2126 | const char *smc_chip_name = "RV770"; |
| 2127 | size_t pfp_req_size, me_req_size, rlc_req_size, smc_req_size = 0; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2128 | char fw_name[30]; |
| 2129 | int err; |
| 2130 | |
| 2131 | DRM_DEBUG("\n"); |
| 2132 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2133 | switch (rdev->family) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2134 | case CHIP_R600: |
| 2135 | chip_name = "R600"; |
| 2136 | rlc_chip_name = "R600"; |
| 2137 | break; |
| 2138 | case CHIP_RV610: |
| 2139 | chip_name = "RV610"; |
| 2140 | rlc_chip_name = "R600"; |
| 2141 | break; |
| 2142 | case CHIP_RV630: |
| 2143 | chip_name = "RV630"; |
| 2144 | rlc_chip_name = "R600"; |
| 2145 | break; |
| 2146 | case CHIP_RV620: |
| 2147 | chip_name = "RV620"; |
| 2148 | rlc_chip_name = "R600"; |
| 2149 | break; |
| 2150 | case CHIP_RV635: |
| 2151 | chip_name = "RV635"; |
| 2152 | rlc_chip_name = "R600"; |
| 2153 | break; |
| 2154 | case CHIP_RV670: |
| 2155 | chip_name = "RV670"; |
| 2156 | rlc_chip_name = "R600"; |
| 2157 | break; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2158 | case CHIP_RS780: |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2159 | case CHIP_RS880: |
| 2160 | chip_name = "RS780"; |
| 2161 | rlc_chip_name = "R600"; |
| 2162 | break; |
| 2163 | case CHIP_RV770: |
| 2164 | chip_name = "RV770"; |
| 2165 | rlc_chip_name = "R700"; |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2166 | smc_chip_name = "RV770"; |
| 2167 | smc_req_size = ALIGN(RV770_SMC_UCODE_SIZE, 4); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2168 | break; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2169 | case CHIP_RV730: |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2170 | chip_name = "RV730"; |
| 2171 | rlc_chip_name = "R700"; |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2172 | smc_chip_name = "RV730"; |
| 2173 | smc_req_size = ALIGN(RV730_SMC_UCODE_SIZE, 4); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2174 | break; |
| 2175 | case CHIP_RV710: |
| 2176 | chip_name = "RV710"; |
| 2177 | rlc_chip_name = "R700"; |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2178 | smc_chip_name = "RV710"; |
| 2179 | smc_req_size = ALIGN(RV710_SMC_UCODE_SIZE, 4); |
| 2180 | break; |
| 2181 | case CHIP_RV740: |
| 2182 | chip_name = "RV730"; |
| 2183 | rlc_chip_name = "R700"; |
| 2184 | smc_chip_name = "RV740"; |
| 2185 | smc_req_size = ALIGN(RV740_SMC_UCODE_SIZE, 4); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2186 | break; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2187 | case CHIP_CEDAR: |
| 2188 | chip_name = "CEDAR"; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2189 | rlc_chip_name = "CEDAR"; |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 2190 | smc_chip_name = "CEDAR"; |
| 2191 | smc_req_size = ALIGN(CEDAR_SMC_UCODE_SIZE, 4); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2192 | break; |
| 2193 | case CHIP_REDWOOD: |
| 2194 | chip_name = "REDWOOD"; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2195 | rlc_chip_name = "REDWOOD"; |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 2196 | smc_chip_name = "REDWOOD"; |
| 2197 | smc_req_size = ALIGN(REDWOOD_SMC_UCODE_SIZE, 4); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2198 | break; |
| 2199 | case CHIP_JUNIPER: |
| 2200 | chip_name = "JUNIPER"; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2201 | rlc_chip_name = "JUNIPER"; |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 2202 | smc_chip_name = "JUNIPER"; |
| 2203 | smc_req_size = ALIGN(JUNIPER_SMC_UCODE_SIZE, 4); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2204 | break; |
| 2205 | case CHIP_CYPRESS: |
| 2206 | case CHIP_HEMLOCK: |
| 2207 | chip_name = "CYPRESS"; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2208 | rlc_chip_name = "CYPRESS"; |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 2209 | smc_chip_name = "CYPRESS"; |
| 2210 | smc_req_size = ALIGN(CYPRESS_SMC_UCODE_SIZE, 4); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2211 | break; |
Alex Deucher | 439bd6c | 2010-11-22 17:56:31 -0500 | [diff] [blame] | 2212 | case CHIP_PALM: |
| 2213 | chip_name = "PALM"; |
| 2214 | rlc_chip_name = "SUMO"; |
| 2215 | break; |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 2216 | case CHIP_SUMO: |
| 2217 | chip_name = "SUMO"; |
| 2218 | rlc_chip_name = "SUMO"; |
| 2219 | break; |
| 2220 | case CHIP_SUMO2: |
| 2221 | chip_name = "SUMO2"; |
| 2222 | rlc_chip_name = "SUMO"; |
| 2223 | break; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2224 | default: BUG(); |
| 2225 | } |
| 2226 | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2227 | if (rdev->family >= CHIP_CEDAR) { |
| 2228 | pfp_req_size = EVERGREEN_PFP_UCODE_SIZE * 4; |
| 2229 | me_req_size = EVERGREEN_PM4_UCODE_SIZE * 4; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2230 | rlc_req_size = EVERGREEN_RLC_UCODE_SIZE * 4; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2231 | } else if (rdev->family >= CHIP_RV770) { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2232 | pfp_req_size = R700_PFP_UCODE_SIZE * 4; |
| 2233 | me_req_size = R700_PM4_UCODE_SIZE * 4; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2234 | rlc_req_size = R700_RLC_UCODE_SIZE * 4; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2235 | } else { |
Alex Deucher | 138e4e1 | 2013-01-11 15:33:13 -0500 | [diff] [blame] | 2236 | pfp_req_size = R600_PFP_UCODE_SIZE * 4; |
| 2237 | me_req_size = R600_PM4_UCODE_SIZE * 12; |
| 2238 | rlc_req_size = R600_RLC_UCODE_SIZE * 4; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2239 | } |
| 2240 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2241 | DRM_INFO("Loading %s Microcode\n", chip_name); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2242 | |
| 2243 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 2244 | err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2245 | if (err) |
| 2246 | goto out; |
| 2247 | if (rdev->pfp_fw->size != pfp_req_size) { |
| 2248 | printk(KERN_ERR |
| 2249 | "r600_cp: Bogus length %zu in firmware \"%s\"\n", |
| 2250 | rdev->pfp_fw->size, fw_name); |
| 2251 | err = -EINVAL; |
| 2252 | goto out; |
| 2253 | } |
| 2254 | |
| 2255 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 2256 | err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2257 | if (err) |
| 2258 | goto out; |
| 2259 | if (rdev->me_fw->size != me_req_size) { |
| 2260 | printk(KERN_ERR |
| 2261 | "r600_cp: Bogus length %zu in firmware \"%s\"\n", |
| 2262 | rdev->me_fw->size, fw_name); |
| 2263 | err = -EINVAL; |
| 2264 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2265 | |
| 2266 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 2267 | err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2268 | if (err) |
| 2269 | goto out; |
| 2270 | if (rdev->rlc_fw->size != rlc_req_size) { |
| 2271 | printk(KERN_ERR |
| 2272 | "r600_rlc: Bogus length %zu in firmware \"%s\"\n", |
| 2273 | rdev->rlc_fw->size, fw_name); |
| 2274 | err = -EINVAL; |
| 2275 | } |
| 2276 | |
Alex Deucher | dc50ba7 | 2013-06-26 00:33:35 -0400 | [diff] [blame] | 2277 | if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) { |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2278 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 2279 | err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); |
Alex Deucher | 8a53fa2 | 2013-08-07 16:09:08 -0400 | [diff] [blame] | 2280 | if (err) { |
| 2281 | printk(KERN_ERR |
| 2282 | "smc: error loading firmware \"%s\"\n", |
| 2283 | fw_name); |
| 2284 | release_firmware(rdev->smc_fw); |
| 2285 | rdev->smc_fw = NULL; |
| 2286 | } else if (rdev->smc_fw->size != smc_req_size) { |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2287 | printk(KERN_ERR |
| 2288 | "smc: Bogus length %zu in firmware \"%s\"\n", |
| 2289 | rdev->smc_fw->size, fw_name); |
| 2290 | err = -EINVAL; |
| 2291 | } |
| 2292 | } |
| 2293 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2294 | out: |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2295 | if (err) { |
| 2296 | if (err != -EINVAL) |
| 2297 | printk(KERN_ERR |
| 2298 | "r600_cp: Failed to load firmware \"%s\"\n", |
| 2299 | fw_name); |
| 2300 | release_firmware(rdev->pfp_fw); |
| 2301 | rdev->pfp_fw = NULL; |
| 2302 | release_firmware(rdev->me_fw); |
| 2303 | rdev->me_fw = NULL; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2304 | release_firmware(rdev->rlc_fw); |
| 2305 | rdev->rlc_fw = NULL; |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 2306 | release_firmware(rdev->smc_fw); |
| 2307 | rdev->smc_fw = NULL; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2308 | } |
| 2309 | return err; |
| 2310 | } |
| 2311 | |
| 2312 | static int r600_cp_load_microcode(struct radeon_device *rdev) |
| 2313 | { |
| 2314 | const __be32 *fw_data; |
| 2315 | int i; |
| 2316 | |
| 2317 | if (!rdev->me_fw || !rdev->pfp_fw) |
| 2318 | return -EINVAL; |
| 2319 | |
| 2320 | r600_cp_stop(rdev); |
| 2321 | |
Cédric Cano | 4eace7f | 2011-02-11 19:45:38 -0500 | [diff] [blame] | 2322 | WREG32(CP_RB_CNTL, |
| 2323 | #ifdef __BIG_ENDIAN |
| 2324 | BUF_SWAP_32BIT | |
| 2325 | #endif |
| 2326 | RB_NO_UPDATE | RB_BLKSZ(15) | RB_BUFSZ(3)); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2327 | |
| 2328 | /* Reset cp */ |
| 2329 | WREG32(GRBM_SOFT_RESET, SOFT_RESET_CP); |
| 2330 | RREG32(GRBM_SOFT_RESET); |
| 2331 | mdelay(15); |
| 2332 | WREG32(GRBM_SOFT_RESET, 0); |
| 2333 | |
| 2334 | WREG32(CP_ME_RAM_WADDR, 0); |
| 2335 | |
| 2336 | fw_data = (const __be32 *)rdev->me_fw->data; |
| 2337 | WREG32(CP_ME_RAM_WADDR, 0); |
Alex Deucher | 138e4e1 | 2013-01-11 15:33:13 -0500 | [diff] [blame] | 2338 | for (i = 0; i < R600_PM4_UCODE_SIZE * 3; i++) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2339 | WREG32(CP_ME_RAM_DATA, |
| 2340 | be32_to_cpup(fw_data++)); |
| 2341 | |
| 2342 | fw_data = (const __be32 *)rdev->pfp_fw->data; |
| 2343 | WREG32(CP_PFP_UCODE_ADDR, 0); |
Alex Deucher | 138e4e1 | 2013-01-11 15:33:13 -0500 | [diff] [blame] | 2344 | for (i = 0; i < R600_PFP_UCODE_SIZE; i++) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2345 | WREG32(CP_PFP_UCODE_DATA, |
| 2346 | be32_to_cpup(fw_data++)); |
| 2347 | |
| 2348 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 2349 | WREG32(CP_ME_RAM_WADDR, 0); |
| 2350 | WREG32(CP_ME_RAM_RADDR, 0); |
| 2351 | return 0; |
| 2352 | } |
| 2353 | |
| 2354 | int r600_cp_start(struct radeon_device *rdev) |
| 2355 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2356 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2357 | int r; |
| 2358 | uint32_t cp_me; |
| 2359 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2360 | r = radeon_ring_lock(rdev, ring, 7); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2361 | if (r) { |
| 2362 | DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r); |
| 2363 | return r; |
| 2364 | } |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2365 | radeon_ring_write(ring, PACKET3(PACKET3_ME_INITIALIZE, 5)); |
| 2366 | radeon_ring_write(ring, 0x1); |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 2367 | if (rdev->family >= CHIP_RV770) { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2368 | radeon_ring_write(ring, 0x0); |
| 2369 | radeon_ring_write(ring, rdev->config.rv770.max_hw_contexts - 1); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 2370 | } else { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2371 | radeon_ring_write(ring, 0x3); |
| 2372 | radeon_ring_write(ring, rdev->config.r600.max_hw_contexts - 1); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2373 | } |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2374 | radeon_ring_write(ring, PACKET3_ME_INITIALIZE_DEVICE_ID(1)); |
| 2375 | radeon_ring_write(ring, 0); |
| 2376 | radeon_ring_write(ring, 0); |
| 2377 | radeon_ring_unlock_commit(rdev, ring); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2378 | |
| 2379 | cp_me = 0xff; |
| 2380 | WREG32(R_0086D8_CP_ME_CNTL, cp_me); |
| 2381 | return 0; |
| 2382 | } |
| 2383 | |
| 2384 | int r600_cp_resume(struct radeon_device *rdev) |
| 2385 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2386 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2387 | u32 tmp; |
| 2388 | u32 rb_bufsz; |
| 2389 | int r; |
| 2390 | |
| 2391 | /* Reset cp */ |
| 2392 | WREG32(GRBM_SOFT_RESET, SOFT_RESET_CP); |
| 2393 | RREG32(GRBM_SOFT_RESET); |
| 2394 | mdelay(15); |
| 2395 | WREG32(GRBM_SOFT_RESET, 0); |
| 2396 | |
| 2397 | /* Set ring buffer size */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2398 | rb_bufsz = drm_order(ring->ring_size / 8); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2399 | tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2400 | #ifdef __BIG_ENDIAN |
Alex Deucher | d6f2893 | 2009-11-02 16:01:27 -0500 | [diff] [blame] | 2401 | tmp |= BUF_SWAP_32BIT; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2402 | #endif |
Alex Deucher | d6f2893 | 2009-11-02 16:01:27 -0500 | [diff] [blame] | 2403 | WREG32(CP_RB_CNTL, tmp); |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 2404 | WREG32(CP_SEM_WAIT_TIMER, 0x0); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2405 | |
| 2406 | /* Set the write pointer delay */ |
| 2407 | WREG32(CP_RB_WPTR_DELAY, 0); |
| 2408 | |
| 2409 | /* Initialize the ring buffer's read and write pointers */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2410 | WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA); |
| 2411 | WREG32(CP_RB_RPTR_WR, 0); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2412 | ring->wptr = 0; |
| 2413 | WREG32(CP_RB_WPTR, ring->wptr); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2414 | |
| 2415 | /* set the wb address whether it's enabled or not */ |
Cédric Cano | 4eace7f | 2011-02-11 19:45:38 -0500 | [diff] [blame] | 2416 | WREG32(CP_RB_RPTR_ADDR, |
Cédric Cano | 4eace7f | 2011-02-11 19:45:38 -0500 | [diff] [blame] | 2417 | ((rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC)); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2418 | WREG32(CP_RB_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFF); |
| 2419 | WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF); |
| 2420 | |
| 2421 | if (rdev->wb.enabled) |
| 2422 | WREG32(SCRATCH_UMSK, 0xff); |
| 2423 | else { |
| 2424 | tmp |= RB_NO_UPDATE; |
| 2425 | WREG32(SCRATCH_UMSK, 0); |
| 2426 | } |
| 2427 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2428 | mdelay(1); |
| 2429 | WREG32(CP_RB_CNTL, tmp); |
| 2430 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2431 | WREG32(CP_RB_BASE, ring->gpu_addr >> 8); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2432 | WREG32(CP_DEBUG, (1 << 27) | (1 << 28)); |
| 2433 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2434 | ring->rptr = RREG32(CP_RB_RPTR); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2435 | |
| 2436 | r600_cp_start(rdev); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2437 | ring->ready = true; |
Alex Deucher | f712812 | 2012-02-23 17:53:45 -0500 | [diff] [blame] | 2438 | r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2439 | if (r) { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2440 | ring->ready = false; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2441 | return r; |
| 2442 | } |
| 2443 | return 0; |
| 2444 | } |
| 2445 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2446 | void r600_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsigned ring_size) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2447 | { |
| 2448 | u32 rb_bufsz; |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2449 | int r; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2450 | |
| 2451 | /* Align ring size */ |
| 2452 | rb_bufsz = drm_order(ring_size / 8); |
| 2453 | ring_size = (1 << (rb_bufsz + 1)) * 4; |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2454 | ring->ring_size = ring_size; |
| 2455 | ring->align_mask = 16 - 1; |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2456 | |
Alex Deucher | 89d3580 | 2012-07-17 14:02:31 -0400 | [diff] [blame] | 2457 | if (radeon_ring_supports_scratch_reg(rdev, ring)) { |
| 2458 | r = radeon_scratch_get(rdev, &ring->rptr_save_reg); |
| 2459 | if (r) { |
| 2460 | DRM_ERROR("failed to get scratch reg for rptr save (%d).\n", r); |
| 2461 | ring->rptr_save_reg = 0; |
| 2462 | } |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2463 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2464 | } |
| 2465 | |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2466 | void r600_cp_fini(struct radeon_device *rdev) |
| 2467 | { |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2468 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2469 | r600_cp_stop(rdev); |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2470 | radeon_ring_fini(rdev, ring); |
| 2471 | radeon_scratch_free(rdev, ring->rptr_save_reg); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2472 | } |
| 2473 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2474 | /* |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2475 | * GPU scratch registers helpers function. |
| 2476 | */ |
| 2477 | void r600_scratch_init(struct radeon_device *rdev) |
| 2478 | { |
| 2479 | int i; |
| 2480 | |
| 2481 | rdev->scratch.num_reg = 7; |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2482 | rdev->scratch.reg_base = SCRATCH_REG0; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2483 | for (i = 0; i < rdev->scratch.num_reg; i++) { |
| 2484 | rdev->scratch.free[i] = true; |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2485 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2486 | } |
| 2487 | } |
| 2488 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2489 | int r600_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2490 | { |
| 2491 | uint32_t scratch; |
| 2492 | uint32_t tmp = 0; |
Alex Deucher | 8b25ed3 | 2012-07-17 14:02:30 -0400 | [diff] [blame] | 2493 | unsigned i; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2494 | int r; |
| 2495 | |
| 2496 | r = radeon_scratch_get(rdev, &scratch); |
| 2497 | if (r) { |
| 2498 | DRM_ERROR("radeon: cp failed to get scratch reg (%d).\n", r); |
| 2499 | return r; |
| 2500 | } |
| 2501 | WREG32(scratch, 0xCAFEDEAD); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2502 | r = radeon_ring_lock(rdev, ring, 3); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2503 | if (r) { |
Alex Deucher | 8b25ed3 | 2012-07-17 14:02:30 -0400 | [diff] [blame] | 2504 | DRM_ERROR("radeon: cp failed to lock ring %d (%d).\n", ring->idx, r); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2505 | radeon_scratch_free(rdev, scratch); |
| 2506 | return r; |
| 2507 | } |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2508 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2509 | radeon_ring_write(ring, ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2)); |
| 2510 | radeon_ring_write(ring, 0xDEADBEEF); |
| 2511 | radeon_ring_unlock_commit(rdev, ring); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2512 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 2513 | tmp = RREG32(scratch); |
| 2514 | if (tmp == 0xDEADBEEF) |
| 2515 | break; |
| 2516 | DRM_UDELAY(1); |
| 2517 | } |
| 2518 | if (i < rdev->usec_timeout) { |
Alex Deucher | 8b25ed3 | 2012-07-17 14:02:30 -0400 | [diff] [blame] | 2519 | DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2520 | } else { |
Christian König | bf85279 | 2011-10-13 13:19:22 +0200 | [diff] [blame] | 2521 | DRM_ERROR("radeon: ring %d test failed (scratch(0x%04X)=0x%08X)\n", |
Alex Deucher | 8b25ed3 | 2012-07-17 14:02:30 -0400 | [diff] [blame] | 2522 | ring->idx, scratch, tmp); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2523 | r = -EINVAL; |
| 2524 | } |
| 2525 | radeon_scratch_free(rdev, scratch); |
| 2526 | return r; |
| 2527 | } |
| 2528 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2529 | /* |
| 2530 | * CP fences/semaphores |
| 2531 | */ |
| 2532 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2533 | void r600_fence_ring_emit(struct radeon_device *rdev, |
| 2534 | struct radeon_fence *fence) |
| 2535 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2536 | struct radeon_ring *ring = &rdev->ring[fence->ring]; |
Christian König | 7b1f248 | 2011-09-23 15:11:23 +0200 | [diff] [blame] | 2537 | |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2538 | if (rdev->wb.use_event) { |
Jerome Glisse | 30eb77f | 2011-11-20 20:45:34 +0000 | [diff] [blame] | 2539 | u64 addr = rdev->fence_drv[fence->ring].gpu_addr; |
Jerome Glisse | 77b1bad | 2011-10-26 11:41:22 -0400 | [diff] [blame] | 2540 | /* flush read cache over gart */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2541 | radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3)); |
| 2542 | radeon_ring_write(ring, PACKET3_TC_ACTION_ENA | |
| 2543 | PACKET3_VC_ACTION_ENA | |
| 2544 | PACKET3_SH_ACTION_ENA); |
| 2545 | radeon_ring_write(ring, 0xFFFFFFFF); |
| 2546 | radeon_ring_write(ring, 0); |
| 2547 | radeon_ring_write(ring, 10); /* poll interval */ |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2548 | /* EVENT_WRITE_EOP - flush caches, send int */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2549 | radeon_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); |
| 2550 | radeon_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_EVENT_TS) | EVENT_INDEX(5)); |
| 2551 | radeon_ring_write(ring, addr & 0xffffffff); |
| 2552 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xff) | DATA_SEL(1) | INT_SEL(2)); |
| 2553 | radeon_ring_write(ring, fence->seq); |
| 2554 | radeon_ring_write(ring, 0); |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2555 | } else { |
Jerome Glisse | 77b1bad | 2011-10-26 11:41:22 -0400 | [diff] [blame] | 2556 | /* flush read cache over gart */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2557 | radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3)); |
| 2558 | radeon_ring_write(ring, PACKET3_TC_ACTION_ENA | |
| 2559 | PACKET3_VC_ACTION_ENA | |
| 2560 | PACKET3_SH_ACTION_ENA); |
| 2561 | radeon_ring_write(ring, 0xFFFFFFFF); |
| 2562 | radeon_ring_write(ring, 0); |
| 2563 | radeon_ring_write(ring, 10); /* poll interval */ |
| 2564 | radeon_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE, 0)); |
| 2565 | radeon_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_EVENT) | EVENT_INDEX(0)); |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2566 | /* wait for 3D idle clean */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2567 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2568 | radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); |
| 2569 | radeon_ring_write(ring, WAIT_3D_IDLE_bit | WAIT_3D_IDLECLEAN_bit); |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2570 | /* Emit fence sequence & fire IRQ */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2571 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2572 | radeon_ring_write(ring, ((rdev->fence_drv[fence->ring].scratch_reg - PACKET3_SET_CONFIG_REG_OFFSET) >> 2)); |
| 2573 | radeon_ring_write(ring, fence->seq); |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2574 | /* CP_INTERRUPT packet 3 no longer exists, use packet 0 */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2575 | radeon_ring_write(ring, PACKET0(CP_INT_STATUS, 0)); |
| 2576 | radeon_ring_write(ring, RB_INT_STAT); |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 2577 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2578 | } |
| 2579 | |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 2580 | void r600_semaphore_ring_emit(struct radeon_device *rdev, |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2581 | struct radeon_ring *ring, |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 2582 | struct radeon_semaphore *semaphore, |
Christian König | 7b1f248 | 2011-09-23 15:11:23 +0200 | [diff] [blame] | 2583 | bool emit_wait) |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 2584 | { |
| 2585 | uint64_t addr = semaphore->gpu_addr; |
| 2586 | unsigned sel = emit_wait ? PACKET3_SEM_SEL_WAIT : PACKET3_SEM_SEL_SIGNAL; |
| 2587 | |
Christian König | 0be7043 | 2012-03-07 11:28:57 +0100 | [diff] [blame] | 2588 | if (rdev->family < CHIP_CAYMAN) |
| 2589 | sel |= PACKET3_SEM_WAIT_ON_SIGNAL; |
| 2590 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2591 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); |
| 2592 | radeon_ring_write(ring, addr & 0xffffffff); |
| 2593 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xff) | sel); |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 2594 | } |
| 2595 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2596 | /** |
Alex Deucher | 072b5ac | 2013-07-11 14:48:05 -0400 | [diff] [blame] | 2597 | * r600_copy_cpdma - copy pages using the CP DMA engine |
| 2598 | * |
| 2599 | * @rdev: radeon_device pointer |
| 2600 | * @src_offset: src GPU address |
| 2601 | * @dst_offset: dst GPU address |
| 2602 | * @num_gpu_pages: number of GPU pages to xfer |
| 2603 | * @fence: radeon fence object |
| 2604 | * |
| 2605 | * Copy GPU paging using the CP DMA engine (r6xx+). |
| 2606 | * Used by the radeon ttm implementation to move pages if |
| 2607 | * registered as the asic copy callback. |
| 2608 | */ |
| 2609 | int r600_copy_cpdma(struct radeon_device *rdev, |
| 2610 | uint64_t src_offset, uint64_t dst_offset, |
| 2611 | unsigned num_gpu_pages, |
| 2612 | struct radeon_fence **fence) |
| 2613 | { |
| 2614 | struct radeon_semaphore *sem = NULL; |
| 2615 | int ring_index = rdev->asic->copy.blit_ring_index; |
| 2616 | struct radeon_ring *ring = &rdev->ring[ring_index]; |
| 2617 | u32 size_in_bytes, cur_size_in_bytes, tmp; |
| 2618 | int i, num_loops; |
| 2619 | int r = 0; |
| 2620 | |
| 2621 | r = radeon_semaphore_create(rdev, &sem); |
| 2622 | if (r) { |
| 2623 | DRM_ERROR("radeon: moving bo (%d).\n", r); |
| 2624 | return r; |
| 2625 | } |
| 2626 | |
| 2627 | size_in_bytes = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT); |
| 2628 | num_loops = DIV_ROUND_UP(size_in_bytes, 0x1fffff); |
Alex Deucher | 745a39a | 2013-07-18 09:24:37 -0400 | [diff] [blame] | 2629 | r = radeon_ring_lock(rdev, ring, num_loops * 6 + 24); |
Alex Deucher | 072b5ac | 2013-07-11 14:48:05 -0400 | [diff] [blame] | 2630 | if (r) { |
| 2631 | DRM_ERROR("radeon: moving bo (%d).\n", r); |
| 2632 | radeon_semaphore_free(rdev, &sem, NULL); |
| 2633 | return r; |
| 2634 | } |
| 2635 | |
| 2636 | if (radeon_fence_need_sync(*fence, ring->idx)) { |
| 2637 | radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring, |
| 2638 | ring->idx); |
| 2639 | radeon_fence_note_sync(*fence, ring->idx); |
| 2640 | } else { |
| 2641 | radeon_semaphore_free(rdev, &sem, NULL); |
| 2642 | } |
| 2643 | |
Alex Deucher | 745a39a | 2013-07-18 09:24:37 -0400 | [diff] [blame] | 2644 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2645 | radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); |
| 2646 | radeon_ring_write(ring, WAIT_3D_IDLE_bit); |
Alex Deucher | 072b5ac | 2013-07-11 14:48:05 -0400 | [diff] [blame] | 2647 | for (i = 0; i < num_loops; i++) { |
| 2648 | cur_size_in_bytes = size_in_bytes; |
| 2649 | if (cur_size_in_bytes > 0x1fffff) |
| 2650 | cur_size_in_bytes = 0x1fffff; |
| 2651 | size_in_bytes -= cur_size_in_bytes; |
| 2652 | tmp = upper_32_bits(src_offset) & 0xff; |
| 2653 | if (size_in_bytes == 0) |
| 2654 | tmp |= PACKET3_CP_DMA_CP_SYNC; |
| 2655 | radeon_ring_write(ring, PACKET3(PACKET3_CP_DMA, 4)); |
| 2656 | radeon_ring_write(ring, src_offset & 0xffffffff); |
| 2657 | radeon_ring_write(ring, tmp); |
| 2658 | radeon_ring_write(ring, dst_offset & 0xffffffff); |
| 2659 | radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff); |
| 2660 | radeon_ring_write(ring, cur_size_in_bytes); |
| 2661 | src_offset += cur_size_in_bytes; |
| 2662 | dst_offset += cur_size_in_bytes; |
| 2663 | } |
| 2664 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2665 | radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); |
| 2666 | radeon_ring_write(ring, WAIT_CP_DMA_IDLE_bit); |
| 2667 | |
| 2668 | r = radeon_fence_emit(rdev, fence, ring->idx); |
| 2669 | if (r) { |
| 2670 | radeon_ring_unlock_undo(rdev, ring); |
| 2671 | return r; |
| 2672 | } |
| 2673 | |
| 2674 | radeon_ring_unlock_commit(rdev, ring); |
| 2675 | radeon_semaphore_free(rdev, &sem, *fence); |
| 2676 | |
| 2677 | return r; |
| 2678 | } |
| 2679 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2680 | int r600_set_surface_reg(struct radeon_device *rdev, int reg, |
| 2681 | uint32_t tiling_flags, uint32_t pitch, |
| 2682 | uint32_t offset, uint32_t obj_size) |
| 2683 | { |
| 2684 | /* FIXME: implement */ |
| 2685 | return 0; |
| 2686 | } |
| 2687 | |
| 2688 | void r600_clear_surface_reg(struct radeon_device *rdev, int reg) |
| 2689 | { |
| 2690 | /* FIXME: implement */ |
| 2691 | } |
| 2692 | |
Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 2693 | static int r600_startup(struct radeon_device *rdev) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2694 | { |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2695 | struct radeon_ring *ring; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2696 | int r; |
| 2697 | |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 2698 | /* enable pcie gen2 link */ |
| 2699 | r600_pcie_gen2_enable(rdev); |
| 2700 | |
Alex Deucher | 6fab3feb | 2013-08-04 12:13:17 -0400 | [diff] [blame] | 2701 | r600_mc_program(rdev); |
| 2702 | |
Alex Deucher | 779720a | 2009-12-09 19:31:44 -0500 | [diff] [blame] | 2703 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { |
| 2704 | r = r600_init_microcode(rdev); |
| 2705 | if (r) { |
| 2706 | DRM_ERROR("Failed to load firmware!\n"); |
| 2707 | return r; |
| 2708 | } |
| 2709 | } |
| 2710 | |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 2711 | r = r600_vram_scratch_init(rdev); |
| 2712 | if (r) |
| 2713 | return r; |
| 2714 | |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 2715 | if (rdev->flags & RADEON_IS_AGP) { |
| 2716 | r600_agp_enable(rdev); |
| 2717 | } else { |
| 2718 | r = r600_pcie_gart_enable(rdev); |
| 2719 | if (r) |
| 2720 | return r; |
| 2721 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2722 | r600_gpu_init(rdev); |
Alex Deucher | b70d6bb | 2010-08-06 21:36:58 -0400 | [diff] [blame] | 2723 | |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2724 | /* allocate wb buffer */ |
| 2725 | r = radeon_wb_init(rdev); |
| 2726 | if (r) |
| 2727 | return r; |
| 2728 | |
Jerome Glisse | 30eb77f | 2011-11-20 20:45:34 +0000 | [diff] [blame] | 2729 | r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 2730 | if (r) { |
| 2731 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 2732 | return r; |
| 2733 | } |
| 2734 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2735 | r = radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_DMA_INDEX); |
| 2736 | if (r) { |
| 2737 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
| 2738 | return r; |
| 2739 | } |
| 2740 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2741 | /* Enable IRQ */ |
Adis Hamzić | e49f395 | 2013-06-02 16:47:54 +0200 | [diff] [blame] | 2742 | if (!rdev->irq.installed) { |
| 2743 | r = radeon_irq_kms_init(rdev); |
| 2744 | if (r) |
| 2745 | return r; |
| 2746 | } |
| 2747 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2748 | r = r600_irq_init(rdev); |
| 2749 | if (r) { |
| 2750 | DRM_ERROR("radeon: IH init failed (%d).\n", r); |
| 2751 | radeon_irq_kms_fini(rdev); |
| 2752 | return r; |
| 2753 | } |
| 2754 | r600_irq_set(rdev); |
| 2755 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2756 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2757 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP_RPTR_OFFSET, |
Alex Deucher | 78c5560 | 2011-11-17 14:25:56 -0500 | [diff] [blame] | 2758 | R600_CP_RB_RPTR, R600_CP_RB_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 2759 | RADEON_CP_PACKET2); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2760 | if (r) |
| 2761 | return r; |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2762 | |
| 2763 | ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
| 2764 | r = radeon_ring_init(rdev, ring, ring->ring_size, R600_WB_DMA_RPTR_OFFSET, |
| 2765 | DMA_RB_RPTR, DMA_RB_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 2766 | DMA_PACKET(DMA_PACKET_NOP, 0, 0, 0)); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2767 | if (r) |
| 2768 | return r; |
| 2769 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2770 | r = r600_cp_load_microcode(rdev); |
| 2771 | if (r) |
| 2772 | return r; |
| 2773 | r = r600_cp_resume(rdev); |
| 2774 | if (r) |
| 2775 | return r; |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2776 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2777 | r = r600_dma_resume(rdev); |
| 2778 | if (r) |
| 2779 | return r; |
| 2780 | |
Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 2781 | r = radeon_ib_pool_init(rdev); |
| 2782 | if (r) { |
| 2783 | dev_err(rdev->dev, "IB initialization failed (%d).\n", r); |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 2784 | return r; |
Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 2785 | } |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 2786 | |
Alex Deucher | d4e30ef | 2012-06-04 17:18:51 -0400 | [diff] [blame] | 2787 | r = r600_audio_init(rdev); |
| 2788 | if (r) { |
| 2789 | DRM_ERROR("radeon: audio init failed\n"); |
| 2790 | return r; |
| 2791 | } |
| 2792 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2793 | return 0; |
| 2794 | } |
| 2795 | |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 2796 | void r600_vga_set_state(struct radeon_device *rdev, bool state) |
| 2797 | { |
| 2798 | uint32_t temp; |
| 2799 | |
| 2800 | temp = RREG32(CONFIG_CNTL); |
| 2801 | if (state == false) { |
| 2802 | temp &= ~(1<<0); |
| 2803 | temp |= (1<<1); |
| 2804 | } else { |
| 2805 | temp &= ~(1<<1); |
| 2806 | } |
| 2807 | WREG32(CONFIG_CNTL, temp); |
| 2808 | } |
| 2809 | |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2810 | int r600_resume(struct radeon_device *rdev) |
| 2811 | { |
| 2812 | int r; |
| 2813 | |
Jerome Glisse | 1a029b7 | 2009-10-06 19:04:30 +0200 | [diff] [blame] | 2814 | /* Do not reset GPU before posting, on r600 hw unlike on r500 hw, |
| 2815 | * posting will perform necessary task to bring back GPU into good |
| 2816 | * shape. |
| 2817 | */ |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2818 | /* post card */ |
Jerome Glisse | e7d40b9 | 2009-10-01 18:02:15 +0200 | [diff] [blame] | 2819 | atom_asic_init(rdev->mode_info.atom_context); |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2820 | |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 2821 | rdev->accel_working = true; |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2822 | r = r600_startup(rdev); |
| 2823 | if (r) { |
| 2824 | DRM_ERROR("r600 startup failed on resume\n"); |
Jerome Glisse | 6b7746e | 2012-02-20 17:57:20 -0500 | [diff] [blame] | 2825 | rdev->accel_working = false; |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2826 | return r; |
| 2827 | } |
| 2828 | |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2829 | return r; |
| 2830 | } |
| 2831 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2832 | int r600_suspend(struct radeon_device *rdev) |
| 2833 | { |
Rafał Miłecki | 38fd2c6 | 2010-01-28 18:16:30 +0100 | [diff] [blame] | 2834 | r600_audio_fini(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2835 | r600_cp_stop(rdev); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2836 | r600_dma_stop(rdev); |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 2837 | r600_irq_suspend(rdev); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2838 | radeon_wb_disable(rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 2839 | r600_pcie_gart_disable(rdev); |
Alex Deucher | 6ddddfe | 2011-10-14 10:51:22 -0400 | [diff] [blame] | 2840 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2841 | return 0; |
| 2842 | } |
| 2843 | |
| 2844 | /* Plan is to move initialization in that function and use |
| 2845 | * helper function so that radeon_device_init pretty much |
| 2846 | * do nothing more than calling asic specific function. This |
| 2847 | * should also allow to remove a bunch of callback function |
| 2848 | * like vram_info. |
| 2849 | */ |
| 2850 | int r600_init(struct radeon_device *rdev) |
| 2851 | { |
| 2852 | int r; |
| 2853 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2854 | if (r600_debugfs_mc_info_init(rdev)) { |
| 2855 | DRM_ERROR("Failed to register debugfs file for mc !\n"); |
| 2856 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2857 | /* Read BIOS */ |
| 2858 | if (!radeon_get_bios(rdev)) { |
| 2859 | if (ASIC_IS_AVIVO(rdev)) |
| 2860 | return -EINVAL; |
| 2861 | } |
| 2862 | /* Must be an ATOMBIOS */ |
Jerome Glisse | e7d40b9 | 2009-10-01 18:02:15 +0200 | [diff] [blame] | 2863 | if (!rdev->is_atom_bios) { |
| 2864 | dev_err(rdev->dev, "Expecting atombios for R600 GPU\n"); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2865 | return -EINVAL; |
Jerome Glisse | e7d40b9 | 2009-10-01 18:02:15 +0200 | [diff] [blame] | 2866 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2867 | r = radeon_atombios_init(rdev); |
| 2868 | if (r) |
| 2869 | return r; |
| 2870 | /* Post card if necessary */ |
Alex Deucher | fd909c3 | 2011-01-11 18:08:59 -0500 | [diff] [blame] | 2871 | if (!radeon_card_posted(rdev)) { |
Dave Airlie | 72542d7 | 2009-12-01 14:06:31 +1000 | [diff] [blame] | 2872 | if (!rdev->bios) { |
| 2873 | dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); |
| 2874 | return -EINVAL; |
| 2875 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2876 | DRM_INFO("GPU not posted. posting now...\n"); |
| 2877 | atom_asic_init(rdev->mode_info.atom_context); |
| 2878 | } |
| 2879 | /* Initialize scratch registers */ |
| 2880 | r600_scratch_init(rdev); |
| 2881 | /* Initialize surface registers */ |
| 2882 | radeon_surface_init(rdev); |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 2883 | /* Initialize clocks */ |
Michel Dänzer | 5e6dde7 | 2009-09-17 09:42:28 +0200 | [diff] [blame] | 2884 | radeon_get_clock_info(rdev->ddev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2885 | /* Fence driver */ |
Jerome Glisse | 30eb77f | 2011-11-20 20:45:34 +0000 | [diff] [blame] | 2886 | r = radeon_fence_driver_init(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2887 | if (r) |
| 2888 | return r; |
Jerome Glisse | 700a0cc | 2010-01-13 15:16:38 +0100 | [diff] [blame] | 2889 | if (rdev->flags & RADEON_IS_AGP) { |
| 2890 | r = radeon_agp_init(rdev); |
| 2891 | if (r) |
| 2892 | radeon_agp_disable(rdev); |
| 2893 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2894 | r = r600_mc_init(rdev); |
Jerome Glisse | b574f25 | 2009-10-06 19:04:29 +0200 | [diff] [blame] | 2895 | if (r) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2896 | return r; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2897 | /* Memory manager */ |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 2898 | r = radeon_bo_init(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2899 | if (r) |
| 2900 | return r; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2901 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2902 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ring_obj = NULL; |
| 2903 | r600_ring_init(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX], 1024 * 1024); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2904 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2905 | rdev->ring[R600_RING_TYPE_DMA_INDEX].ring_obj = NULL; |
| 2906 | r600_ring_init(rdev, &rdev->ring[R600_RING_TYPE_DMA_INDEX], 64 * 1024); |
| 2907 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2908 | rdev->ih.ring_obj = NULL; |
| 2909 | r600_ih_ring_init(rdev, 64 * 1024); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2910 | |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 2911 | r = r600_pcie_gart_init(rdev); |
| 2912 | if (r) |
| 2913 | return r; |
| 2914 | |
Alex Deucher | 779720a | 2009-12-09 19:31:44 -0500 | [diff] [blame] | 2915 | rdev->accel_working = true; |
Dave Airlie | fc30b8e | 2009-09-18 15:19:37 +1000 | [diff] [blame] | 2916 | r = r600_startup(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2917 | if (r) { |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2918 | dev_err(rdev->dev, "disabling GPU acceleration\n"); |
| 2919 | r600_cp_fini(rdev); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2920 | r600_dma_fini(rdev); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2921 | r600_irq_fini(rdev); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2922 | radeon_wb_fini(rdev); |
Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 2923 | radeon_ib_pool_fini(rdev); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2924 | radeon_irq_kms_fini(rdev); |
Jerome Glisse | 75c8129 | 2009-10-01 18:02:14 +0200 | [diff] [blame] | 2925 | r600_pcie_gart_fini(rdev); |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 2926 | rdev->accel_working = false; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2927 | } |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 2928 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2929 | return 0; |
| 2930 | } |
| 2931 | |
| 2932 | void r600_fini(struct radeon_device *rdev) |
| 2933 | { |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 2934 | r600_audio_fini(rdev); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2935 | r600_cp_fini(rdev); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 2936 | r600_dma_fini(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2937 | r600_irq_fini(rdev); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2938 | radeon_wb_fini(rdev); |
Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 2939 | radeon_ib_pool_fini(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 2940 | radeon_irq_kms_fini(rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 2941 | r600_pcie_gart_fini(rdev); |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 2942 | r600_vram_scratch_fini(rdev); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 2943 | radeon_agp_fini(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2944 | radeon_gem_fini(rdev); |
| 2945 | radeon_fence_driver_fini(rdev); |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 2946 | radeon_bo_fini(rdev); |
Jerome Glisse | e7d40b9 | 2009-10-01 18:02:15 +0200 | [diff] [blame] | 2947 | radeon_atombios_fini(rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2948 | kfree(rdev->bios); |
| 2949 | rdev->bios = NULL; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2950 | } |
| 2951 | |
| 2952 | |
| 2953 | /* |
| 2954 | * CS stuff |
| 2955 | */ |
| 2956 | void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) |
| 2957 | { |
Christian König | 876dc9f | 2012-05-08 14:24:01 +0200 | [diff] [blame] | 2958 | struct radeon_ring *ring = &rdev->ring[ib->ring]; |
Alex Deucher | 89d3580 | 2012-07-17 14:02:31 -0400 | [diff] [blame] | 2959 | u32 next_rptr; |
Christian König | 7b1f248 | 2011-09-23 15:11:23 +0200 | [diff] [blame] | 2960 | |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2961 | if (ring->rptr_save_reg) { |
Alex Deucher | 89d3580 | 2012-07-17 14:02:31 -0400 | [diff] [blame] | 2962 | next_rptr = ring->wptr + 3 + 4; |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2963 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1)); |
| 2964 | radeon_ring_write(ring, ((ring->rptr_save_reg - |
| 2965 | PACKET3_SET_CONFIG_REG_OFFSET) >> 2)); |
| 2966 | radeon_ring_write(ring, next_rptr); |
Alex Deucher | 89d3580 | 2012-07-17 14:02:31 -0400 | [diff] [blame] | 2967 | } else if (rdev->wb.enabled) { |
| 2968 | next_rptr = ring->wptr + 5 + 4; |
| 2969 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_WRITE, 3)); |
| 2970 | radeon_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc); |
| 2971 | radeon_ring_write(ring, (upper_32_bits(ring->next_rptr_gpu_addr) & 0xff) | (1 << 18)); |
| 2972 | radeon_ring_write(ring, next_rptr); |
| 2973 | radeon_ring_write(ring, 0); |
Christian König | 45df680 | 2012-07-06 16:22:55 +0200 | [diff] [blame] | 2974 | } |
| 2975 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2976 | radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); |
| 2977 | radeon_ring_write(ring, |
Cédric Cano | 4eace7f | 2011-02-11 19:45:38 -0500 | [diff] [blame] | 2978 | #ifdef __BIG_ENDIAN |
| 2979 | (2 << 0) | |
| 2980 | #endif |
| 2981 | (ib->gpu_addr & 0xFFFFFFFC)); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2982 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFF); |
| 2983 | radeon_ring_write(ring, ib->length_dw); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2984 | } |
| 2985 | |
Alex Deucher | f712812 | 2012-02-23 17:53:45 -0500 | [diff] [blame] | 2986 | int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2987 | { |
Jerome Glisse | f2e3922 | 2012-05-09 15:35:02 +0200 | [diff] [blame] | 2988 | struct radeon_ib ib; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 2989 | uint32_t scratch; |
| 2990 | uint32_t tmp = 0; |
| 2991 | unsigned i; |
| 2992 | int r; |
| 2993 | |
| 2994 | r = radeon_scratch_get(rdev, &scratch); |
| 2995 | if (r) { |
| 2996 | DRM_ERROR("radeon: failed to get scratch reg (%d).\n", r); |
| 2997 | return r; |
| 2998 | } |
| 2999 | WREG32(scratch, 0xCAFEDEAD); |
Christian König | 4bf3dd9 | 2012-08-06 18:57:44 +0200 | [diff] [blame] | 3000 | r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3001 | if (r) { |
| 3002 | DRM_ERROR("radeon: failed to get ib (%d).\n", r); |
Michel Dänzer | af026c5 | 2012-09-20 10:31:10 +0200 | [diff] [blame] | 3003 | goto free_scratch; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3004 | } |
Jerome Glisse | f2e3922 | 2012-05-09 15:35:02 +0200 | [diff] [blame] | 3005 | ib.ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1); |
| 3006 | ib.ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2); |
| 3007 | ib.ptr[2] = 0xDEADBEEF; |
| 3008 | ib.length_dw = 3; |
Christian König | 4ef7256 | 2012-07-13 13:06:00 +0200 | [diff] [blame] | 3009 | r = radeon_ib_schedule(rdev, &ib, NULL); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3010 | if (r) { |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3011 | DRM_ERROR("radeon: failed to schedule ib (%d).\n", r); |
Michel Dänzer | af026c5 | 2012-09-20 10:31:10 +0200 | [diff] [blame] | 3012 | goto free_ib; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3013 | } |
Jerome Glisse | f2e3922 | 2012-05-09 15:35:02 +0200 | [diff] [blame] | 3014 | r = radeon_fence_wait(ib.fence, false); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3015 | if (r) { |
| 3016 | DRM_ERROR("radeon: fence wait failed (%d).\n", r); |
Michel Dänzer | af026c5 | 2012-09-20 10:31:10 +0200 | [diff] [blame] | 3017 | goto free_ib; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3018 | } |
| 3019 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 3020 | tmp = RREG32(scratch); |
| 3021 | if (tmp == 0xDEADBEEF) |
| 3022 | break; |
| 3023 | DRM_UDELAY(1); |
| 3024 | } |
| 3025 | if (i < rdev->usec_timeout) { |
Jerome Glisse | f2e3922 | 2012-05-09 15:35:02 +0200 | [diff] [blame] | 3026 | DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib.fence->ring, i); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3027 | } else { |
Daniel J Blueman | 4417d7f | 2010-09-22 17:57:19 +0100 | [diff] [blame] | 3028 | DRM_ERROR("radeon: ib test failed (scratch(0x%04X)=0x%08X)\n", |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3029 | scratch, tmp); |
| 3030 | r = -EINVAL; |
| 3031 | } |
Michel Dänzer | af026c5 | 2012-09-20 10:31:10 +0200 | [diff] [blame] | 3032 | free_ib: |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3033 | radeon_ib_free(rdev, &ib); |
Michel Dänzer | af026c5 | 2012-09-20 10:31:10 +0200 | [diff] [blame] | 3034 | free_scratch: |
| 3035 | radeon_scratch_free(rdev, scratch); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3036 | return r; |
| 3037 | } |
| 3038 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3039 | /* |
| 3040 | * Interrupts |
| 3041 | * |
| 3042 | * Interrupts use a ring buffer on r6xx/r7xx hardware. It works pretty |
| 3043 | * the same as the CP ring buffer, but in reverse. Rather than the CPU |
| 3044 | * writing to the ring and the GPU consuming, the GPU writes to the ring |
| 3045 | * and host consumes. As the host irq handler processes interrupts, it |
| 3046 | * increments the rptr. When the rptr catches up with the wptr, all the |
| 3047 | * current interrupts have been processed. |
| 3048 | */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3049 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3050 | void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size) |
| 3051 | { |
| 3052 | u32 rb_bufsz; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3053 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3054 | /* Align ring size */ |
| 3055 | rb_bufsz = drm_order(ring_size / 4); |
| 3056 | ring_size = (1 << rb_bufsz) * 4; |
| 3057 | rdev->ih.ring_size = ring_size; |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 3058 | rdev->ih.ptr_mask = rdev->ih.ring_size - 1; |
| 3059 | rdev->ih.rptr = 0; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3060 | } |
| 3061 | |
Alex Deucher | 25a857f | 2012-03-20 17:18:22 -0400 | [diff] [blame] | 3062 | int r600_ih_ring_alloc(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3063 | { |
| 3064 | int r; |
| 3065 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3066 | /* Allocate ring buffer */ |
| 3067 | if (rdev->ih.ring_obj == NULL) { |
Daniel Vetter | 441921d | 2011-02-18 17:59:16 +0100 | [diff] [blame] | 3068 | r = radeon_bo_create(rdev, rdev->ih.ring_size, |
Alex Deucher | 268b251 | 2010-11-17 19:00:26 -0500 | [diff] [blame] | 3069 | PAGE_SIZE, true, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 3070 | RADEON_GEM_DOMAIN_GTT, |
Alex Deucher | 40f5cf9 | 2012-05-10 18:33:13 -0400 | [diff] [blame] | 3071 | NULL, &rdev->ih.ring_obj); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3072 | if (r) { |
| 3073 | DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r); |
| 3074 | return r; |
| 3075 | } |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 3076 | r = radeon_bo_reserve(rdev->ih.ring_obj, false); |
| 3077 | if (unlikely(r != 0)) |
| 3078 | return r; |
| 3079 | r = radeon_bo_pin(rdev->ih.ring_obj, |
| 3080 | RADEON_GEM_DOMAIN_GTT, |
| 3081 | &rdev->ih.gpu_addr); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3082 | if (r) { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 3083 | radeon_bo_unreserve(rdev->ih.ring_obj); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3084 | DRM_ERROR("radeon: failed to pin ih ring buffer (%d).\n", r); |
| 3085 | return r; |
| 3086 | } |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 3087 | r = radeon_bo_kmap(rdev->ih.ring_obj, |
| 3088 | (void **)&rdev->ih.ring); |
| 3089 | radeon_bo_unreserve(rdev->ih.ring_obj); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3090 | if (r) { |
| 3091 | DRM_ERROR("radeon: failed to map ih ring buffer (%d).\n", r); |
| 3092 | return r; |
| 3093 | } |
| 3094 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3095 | return 0; |
| 3096 | } |
| 3097 | |
Alex Deucher | 25a857f | 2012-03-20 17:18:22 -0400 | [diff] [blame] | 3098 | void r600_ih_ring_fini(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3099 | { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 3100 | int r; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3101 | if (rdev->ih.ring_obj) { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 3102 | r = radeon_bo_reserve(rdev->ih.ring_obj, false); |
| 3103 | if (likely(r == 0)) { |
| 3104 | radeon_bo_kunmap(rdev->ih.ring_obj); |
| 3105 | radeon_bo_unpin(rdev->ih.ring_obj); |
| 3106 | radeon_bo_unreserve(rdev->ih.ring_obj); |
| 3107 | } |
| 3108 | radeon_bo_unref(&rdev->ih.ring_obj); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3109 | rdev->ih.ring = NULL; |
| 3110 | rdev->ih.ring_obj = NULL; |
| 3111 | } |
| 3112 | } |
| 3113 | |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3114 | void r600_rlc_stop(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3115 | { |
| 3116 | |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3117 | if ((rdev->family >= CHIP_RV770) && |
| 3118 | (rdev->family <= CHIP_RV740)) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3119 | /* r7xx asics need to soft reset RLC before halting */ |
| 3120 | WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC); |
| 3121 | RREG32(SRBM_SOFT_RESET); |
Arnd Bergmann | 4de833c | 2012-04-05 12:58:22 -0600 | [diff] [blame] | 3122 | mdelay(15); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3123 | WREG32(SRBM_SOFT_RESET, 0); |
| 3124 | RREG32(SRBM_SOFT_RESET); |
| 3125 | } |
| 3126 | |
| 3127 | WREG32(RLC_CNTL, 0); |
| 3128 | } |
| 3129 | |
| 3130 | static void r600_rlc_start(struct radeon_device *rdev) |
| 3131 | { |
| 3132 | WREG32(RLC_CNTL, RLC_ENABLE); |
| 3133 | } |
| 3134 | |
Alex Deucher | 2948f5e | 2013-04-12 13:52:52 -0400 | [diff] [blame] | 3135 | static int r600_rlc_resume(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3136 | { |
| 3137 | u32 i; |
| 3138 | const __be32 *fw_data; |
| 3139 | |
| 3140 | if (!rdev->rlc_fw) |
| 3141 | return -EINVAL; |
| 3142 | |
| 3143 | r600_rlc_stop(rdev); |
| 3144 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3145 | WREG32(RLC_HB_CNTL, 0); |
Alex Deucher | c420c74 | 2012-03-20 17:18:39 -0400 | [diff] [blame] | 3146 | |
Alex Deucher | 2948f5e | 2013-04-12 13:52:52 -0400 | [diff] [blame] | 3147 | WREG32(RLC_HB_BASE, 0); |
| 3148 | WREG32(RLC_HB_RPTR, 0); |
| 3149 | WREG32(RLC_HB_WPTR, 0); |
| 3150 | WREG32(RLC_HB_WPTR_LSB_ADDR, 0); |
| 3151 | WREG32(RLC_HB_WPTR_MSB_ADDR, 0); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3152 | WREG32(RLC_MC_CNTL, 0); |
| 3153 | WREG32(RLC_UCODE_CNTL, 0); |
| 3154 | |
| 3155 | fw_data = (const __be32 *)rdev->rlc_fw->data; |
Alex Deucher | 2948f5e | 2013-04-12 13:52:52 -0400 | [diff] [blame] | 3156 | if (rdev->family >= CHIP_RV770) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3157 | for (i = 0; i < R700_RLC_UCODE_SIZE; i++) { |
| 3158 | WREG32(RLC_UCODE_ADDR, i); |
| 3159 | WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3160 | } |
| 3161 | } else { |
Alex Deucher | 138e4e1 | 2013-01-11 15:33:13 -0500 | [diff] [blame] | 3162 | for (i = 0; i < R600_RLC_UCODE_SIZE; i++) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3163 | WREG32(RLC_UCODE_ADDR, i); |
| 3164 | WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3165 | } |
| 3166 | } |
| 3167 | WREG32(RLC_UCODE_ADDR, 0); |
| 3168 | |
| 3169 | r600_rlc_start(rdev); |
| 3170 | |
| 3171 | return 0; |
| 3172 | } |
| 3173 | |
| 3174 | static void r600_enable_interrupts(struct radeon_device *rdev) |
| 3175 | { |
| 3176 | u32 ih_cntl = RREG32(IH_CNTL); |
| 3177 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
| 3178 | |
| 3179 | ih_cntl |= ENABLE_INTR; |
| 3180 | ih_rb_cntl |= IH_RB_ENABLE; |
| 3181 | WREG32(IH_CNTL, ih_cntl); |
| 3182 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 3183 | rdev->ih.enabled = true; |
| 3184 | } |
| 3185 | |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3186 | void r600_disable_interrupts(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3187 | { |
| 3188 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
| 3189 | u32 ih_cntl = RREG32(IH_CNTL); |
| 3190 | |
| 3191 | ih_rb_cntl &= ~IH_RB_ENABLE; |
| 3192 | ih_cntl &= ~ENABLE_INTR; |
| 3193 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 3194 | WREG32(IH_CNTL, ih_cntl); |
| 3195 | /* set rptr, wptr to 0 */ |
| 3196 | WREG32(IH_RB_RPTR, 0); |
| 3197 | WREG32(IH_RB_WPTR, 0); |
| 3198 | rdev->ih.enabled = false; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3199 | rdev->ih.rptr = 0; |
| 3200 | } |
| 3201 | |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3202 | static void r600_disable_interrupt_state(struct radeon_device *rdev) |
| 3203 | { |
| 3204 | u32 tmp; |
| 3205 | |
Alex Deucher | 3555e53 | 2010-10-08 12:09:12 -0400 | [diff] [blame] | 3206 | WREG32(CP_INT_CNTL, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 3207 | tmp = RREG32(DMA_CNTL) & ~TRAP_ENABLE; |
| 3208 | WREG32(DMA_CNTL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3209 | WREG32(GRBM_INT_CNTL, 0); |
| 3210 | WREG32(DxMODE_INT_MASK, 0); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3211 | WREG32(D1GRPH_INTERRUPT_CONTROL, 0); |
| 3212 | WREG32(D2GRPH_INTERRUPT_CONTROL, 0); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3213 | if (ASIC_IS_DCE3(rdev)) { |
| 3214 | WREG32(DCE3_DACA_AUTODETECT_INT_CONTROL, 0); |
| 3215 | WREG32(DCE3_DACB_AUTODETECT_INT_CONTROL, 0); |
| 3216 | tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 3217 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 3218 | tmp = RREG32(DC_HPD2_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 3219 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 3220 | tmp = RREG32(DC_HPD3_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 3221 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 3222 | tmp = RREG32(DC_HPD4_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 3223 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 3224 | if (ASIC_IS_DCE32(rdev)) { |
| 3225 | tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
Alex Deucher | 5898b1f | 2010-03-24 13:57:29 -0400 | [diff] [blame] | 3226 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3227 | tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
Alex Deucher | 5898b1f | 2010-03-24 13:57:29 -0400 | [diff] [blame] | 3228 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3229 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET0) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3230 | WREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET0, tmp); |
| 3231 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET1) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3232 | WREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET1, tmp); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3233 | } else { |
| 3234 | tmp = RREG32(HDMI0_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3235 | WREG32(HDMI0_AUDIO_PACKET_CONTROL, tmp); |
| 3236 | tmp = RREG32(DCE3_HDMI1_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3237 | WREG32(DCE3_HDMI1_AUDIO_PACKET_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3238 | } |
| 3239 | } else { |
| 3240 | WREG32(DACA_AUTODETECT_INT_CONTROL, 0); |
| 3241 | WREG32(DACB_AUTODETECT_INT_CONTROL, 0); |
| 3242 | tmp = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY; |
Alex Deucher | 5898b1f | 2010-03-24 13:57:29 -0400 | [diff] [blame] | 3243 | WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3244 | tmp = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY; |
Alex Deucher | 5898b1f | 2010-03-24 13:57:29 -0400 | [diff] [blame] | 3245 | WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3246 | tmp = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY; |
Alex Deucher | 5898b1f | 2010-03-24 13:57:29 -0400 | [diff] [blame] | 3247 | WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, tmp); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3248 | tmp = RREG32(HDMI0_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3249 | WREG32(HDMI0_AUDIO_PACKET_CONTROL, tmp); |
| 3250 | tmp = RREG32(HDMI1_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3251 | WREG32(HDMI1_AUDIO_PACKET_CONTROL, tmp); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3252 | } |
| 3253 | } |
| 3254 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3255 | int r600_irq_init(struct radeon_device *rdev) |
| 3256 | { |
| 3257 | int ret = 0; |
| 3258 | int rb_bufsz; |
| 3259 | u32 interrupt_cntl, ih_cntl, ih_rb_cntl; |
| 3260 | |
| 3261 | /* allocate ring */ |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 3262 | ret = r600_ih_ring_alloc(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3263 | if (ret) |
| 3264 | return ret; |
| 3265 | |
| 3266 | /* disable irqs */ |
| 3267 | r600_disable_interrupts(rdev); |
| 3268 | |
| 3269 | /* init rlc */ |
Alex Deucher | 2948f5e | 2013-04-12 13:52:52 -0400 | [diff] [blame] | 3270 | if (rdev->family >= CHIP_CEDAR) |
| 3271 | ret = evergreen_rlc_resume(rdev); |
| 3272 | else |
| 3273 | ret = r600_rlc_resume(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3274 | if (ret) { |
| 3275 | r600_ih_ring_fini(rdev); |
| 3276 | return ret; |
| 3277 | } |
| 3278 | |
| 3279 | /* setup interrupt control */ |
| 3280 | /* set dummy read address to ring address */ |
| 3281 | WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8); |
| 3282 | interrupt_cntl = RREG32(INTERRUPT_CNTL); |
| 3283 | /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi |
| 3284 | * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN |
| 3285 | */ |
| 3286 | interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE; |
| 3287 | /* IH_REQ_NONSNOOP_EN=1 if ring is in non-cacheable memory, e.g., vram */ |
| 3288 | interrupt_cntl &= ~IH_REQ_NONSNOOP_EN; |
| 3289 | WREG32(INTERRUPT_CNTL, interrupt_cntl); |
| 3290 | |
| 3291 | WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8); |
| 3292 | rb_bufsz = drm_order(rdev->ih.ring_size / 4); |
| 3293 | |
| 3294 | ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE | |
| 3295 | IH_WPTR_OVERFLOW_CLEAR | |
| 3296 | (rb_bufsz << 1)); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3297 | |
| 3298 | if (rdev->wb.enabled) |
| 3299 | ih_rb_cntl |= IH_WPTR_WRITEBACK_ENABLE; |
| 3300 | |
| 3301 | /* set the writeback address whether it's enabled or not */ |
| 3302 | WREG32(IH_RB_WPTR_ADDR_LO, (rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFFFFFFFC); |
| 3303 | WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFF); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3304 | |
| 3305 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 3306 | |
| 3307 | /* set rptr, wptr to 0 */ |
| 3308 | WREG32(IH_RB_RPTR, 0); |
| 3309 | WREG32(IH_RB_WPTR, 0); |
| 3310 | |
| 3311 | /* Default settings for IH_CNTL (disabled at first) */ |
| 3312 | ih_cntl = MC_WRREQ_CREDIT(0x10) | MC_WR_CLEAN_CNT(0x10); |
| 3313 | /* RPTR_REARM only works if msi's are enabled */ |
| 3314 | if (rdev->msi_enabled) |
| 3315 | ih_cntl |= RPTR_REARM; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3316 | WREG32(IH_CNTL, ih_cntl); |
| 3317 | |
| 3318 | /* force the active interrupt state to all disabled */ |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3319 | if (rdev->family >= CHIP_CEDAR) |
| 3320 | evergreen_disable_interrupt_state(rdev); |
| 3321 | else |
| 3322 | r600_disable_interrupt_state(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3323 | |
Dave Airlie | 2099810 | 2012-04-03 11:53:05 +0100 | [diff] [blame] | 3324 | /* at this point everything should be setup correctly to enable master */ |
| 3325 | pci_set_master(rdev->pdev); |
| 3326 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3327 | /* enable irqs */ |
| 3328 | r600_enable_interrupts(rdev); |
| 3329 | |
| 3330 | return ret; |
| 3331 | } |
| 3332 | |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 3333 | void r600_irq_suspend(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3334 | { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3335 | r600_irq_disable(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3336 | r600_rlc_stop(rdev); |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 3337 | } |
| 3338 | |
| 3339 | void r600_irq_fini(struct radeon_device *rdev) |
| 3340 | { |
| 3341 | r600_irq_suspend(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3342 | r600_ih_ring_fini(rdev); |
| 3343 | } |
| 3344 | |
| 3345 | int r600_irq_set(struct radeon_device *rdev) |
| 3346 | { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3347 | u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE; |
| 3348 | u32 mode_int = 0; |
| 3349 | u32 hpd1, hpd2, hpd3, hpd4 = 0, hpd5 = 0, hpd6 = 0; |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 3350 | u32 grbm_int_cntl = 0; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3351 | u32 hdmi0, hdmi1; |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3352 | u32 d1grph = 0, d2grph = 0; |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 3353 | u32 dma_cntl; |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3354 | u32 thermal_int = 0; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3355 | |
Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 3356 | if (!rdev->irq.installed) { |
Joe Perches | fce7d61 | 2010-10-30 21:08:30 +0000 | [diff] [blame] | 3357 | WARN(1, "Can't enable IRQ/MSI because no handler is installed\n"); |
Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 3358 | return -EINVAL; |
| 3359 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3360 | /* don't enable anything if the ih is disabled */ |
Jerome Glisse | 79c2bbc | 2010-01-15 14:44:38 +0100 | [diff] [blame] | 3361 | if (!rdev->ih.enabled) { |
| 3362 | r600_disable_interrupts(rdev); |
| 3363 | /* force the active interrupt state to all disabled */ |
| 3364 | r600_disable_interrupt_state(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3365 | return 0; |
Jerome Glisse | 79c2bbc | 2010-01-15 14:44:38 +0100 | [diff] [blame] | 3366 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3367 | |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3368 | if (ASIC_IS_DCE3(rdev)) { |
| 3369 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3370 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3371 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3372 | hpd4 = RREG32(DC_HPD4_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3373 | if (ASIC_IS_DCE32(rdev)) { |
| 3374 | hpd5 = RREG32(DC_HPD5_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3375 | hpd6 = RREG32(DC_HPD6_INT_CONTROL) & ~DC_HPDx_INT_EN; |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3376 | hdmi0 = RREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET0) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 3377 | hdmi1 = RREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET1) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3378 | } else { |
| 3379 | hdmi0 = RREG32(HDMI0_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3380 | hdmi1 = RREG32(DCE3_HDMI1_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3381 | } |
| 3382 | } else { |
| 3383 | hpd1 = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3384 | hpd2 = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 3385 | hpd3 = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL) & ~DC_HPDx_INT_EN; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3386 | hdmi0 = RREG32(HDMI0_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
| 3387 | hdmi1 = RREG32(HDMI1_AUDIO_PACKET_CONTROL) & ~HDMI0_AZ_FORMAT_WTRIG_MASK; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3388 | } |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3389 | |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 3390 | dma_cntl = RREG32(DMA_CNTL) & ~TRAP_ENABLE; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3391 | |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3392 | if ((rdev->family > CHIP_R600) && (rdev->family < CHIP_RV770)) { |
| 3393 | thermal_int = RREG32(CG_THERMAL_INT) & |
| 3394 | ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW); |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 3395 | } else if (rdev->family >= CHIP_RV770) { |
| 3396 | thermal_int = RREG32(RV770_CG_THERMAL_INT) & |
| 3397 | ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW); |
| 3398 | } |
| 3399 | if (rdev->irq.dpm_thermal) { |
| 3400 | DRM_DEBUG("dpm thermal\n"); |
| 3401 | thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW; |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3402 | } |
| 3403 | |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 3404 | if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3405 | DRM_DEBUG("r600_irq_set: sw int\n"); |
| 3406 | cp_int_cntl |= RB_INT_ENABLE; |
Alex Deucher | d0f8a85 | 2010-09-04 05:04:34 -0400 | [diff] [blame] | 3407 | cp_int_cntl |= TIME_STAMP_INT_ENABLE; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3408 | } |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 3409 | |
| 3410 | if (atomic_read(&rdev->irq.ring_int[R600_RING_TYPE_DMA_INDEX])) { |
| 3411 | DRM_DEBUG("r600_irq_set: sw int dma\n"); |
| 3412 | dma_cntl |= TRAP_ENABLE; |
| 3413 | } |
| 3414 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3415 | if (rdev->irq.crtc_vblank_int[0] || |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 3416 | atomic_read(&rdev->irq.pflip[0])) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3417 | DRM_DEBUG("r600_irq_set: vblank 0\n"); |
| 3418 | mode_int |= D1MODE_VBLANK_INT_MASK; |
| 3419 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3420 | if (rdev->irq.crtc_vblank_int[1] || |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 3421 | atomic_read(&rdev->irq.pflip[1])) { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3422 | DRM_DEBUG("r600_irq_set: vblank 1\n"); |
| 3423 | mode_int |= D2MODE_VBLANK_INT_MASK; |
| 3424 | } |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3425 | if (rdev->irq.hpd[0]) { |
| 3426 | DRM_DEBUG("r600_irq_set: hpd 1\n"); |
| 3427 | hpd1 |= DC_HPDx_INT_EN; |
| 3428 | } |
| 3429 | if (rdev->irq.hpd[1]) { |
| 3430 | DRM_DEBUG("r600_irq_set: hpd 2\n"); |
| 3431 | hpd2 |= DC_HPDx_INT_EN; |
| 3432 | } |
| 3433 | if (rdev->irq.hpd[2]) { |
| 3434 | DRM_DEBUG("r600_irq_set: hpd 3\n"); |
| 3435 | hpd3 |= DC_HPDx_INT_EN; |
| 3436 | } |
| 3437 | if (rdev->irq.hpd[3]) { |
| 3438 | DRM_DEBUG("r600_irq_set: hpd 4\n"); |
| 3439 | hpd4 |= DC_HPDx_INT_EN; |
| 3440 | } |
| 3441 | if (rdev->irq.hpd[4]) { |
| 3442 | DRM_DEBUG("r600_irq_set: hpd 5\n"); |
| 3443 | hpd5 |= DC_HPDx_INT_EN; |
| 3444 | } |
| 3445 | if (rdev->irq.hpd[5]) { |
| 3446 | DRM_DEBUG("r600_irq_set: hpd 6\n"); |
| 3447 | hpd6 |= DC_HPDx_INT_EN; |
| 3448 | } |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3449 | if (rdev->irq.afmt[0]) { |
| 3450 | DRM_DEBUG("r600_irq_set: hdmi 0\n"); |
| 3451 | hdmi0 |= HDMI0_AZ_FORMAT_WTRIG_MASK; |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 3452 | } |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3453 | if (rdev->irq.afmt[1]) { |
| 3454 | DRM_DEBUG("r600_irq_set: hdmi 0\n"); |
| 3455 | hdmi1 |= HDMI0_AZ_FORMAT_WTRIG_MASK; |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 3456 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3457 | |
| 3458 | WREG32(CP_INT_CNTL, cp_int_cntl); |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 3459 | WREG32(DMA_CNTL, dma_cntl); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3460 | WREG32(DxMODE_INT_MASK, mode_int); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3461 | WREG32(D1GRPH_INTERRUPT_CONTROL, d1grph); |
| 3462 | WREG32(D2GRPH_INTERRUPT_CONTROL, d2grph); |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 3463 | WREG32(GRBM_INT_CNTL, grbm_int_cntl); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3464 | if (ASIC_IS_DCE3(rdev)) { |
| 3465 | WREG32(DC_HPD1_INT_CONTROL, hpd1); |
| 3466 | WREG32(DC_HPD2_INT_CONTROL, hpd2); |
| 3467 | WREG32(DC_HPD3_INT_CONTROL, hpd3); |
| 3468 | WREG32(DC_HPD4_INT_CONTROL, hpd4); |
| 3469 | if (ASIC_IS_DCE32(rdev)) { |
| 3470 | WREG32(DC_HPD5_INT_CONTROL, hpd5); |
| 3471 | WREG32(DC_HPD6_INT_CONTROL, hpd6); |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3472 | WREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET0, hdmi0); |
| 3473 | WREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET1, hdmi1); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3474 | } else { |
| 3475 | WREG32(HDMI0_AUDIO_PACKET_CONTROL, hdmi0); |
| 3476 | WREG32(DCE3_HDMI1_AUDIO_PACKET_CONTROL, hdmi1); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3477 | } |
| 3478 | } else { |
| 3479 | WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, hpd1); |
| 3480 | WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, hpd2); |
| 3481 | WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, hpd3); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3482 | WREG32(HDMI0_AUDIO_PACKET_CONTROL, hdmi0); |
| 3483 | WREG32(HDMI1_AUDIO_PACKET_CONTROL, hdmi1); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3484 | } |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3485 | if ((rdev->family > CHIP_R600) && (rdev->family < CHIP_RV770)) { |
| 3486 | WREG32(CG_THERMAL_INT, thermal_int); |
Alex Deucher | 66229b2 | 2013-06-26 00:11:19 -0400 | [diff] [blame] | 3487 | } else if (rdev->family >= CHIP_RV770) { |
| 3488 | WREG32(RV770_CG_THERMAL_INT, thermal_int); |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3489 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3490 | |
| 3491 | return 0; |
| 3492 | } |
| 3493 | |
Andi Kleen | ce580fa | 2011-10-13 16:08:47 -0700 | [diff] [blame] | 3494 | static void r600_irq_ack(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3495 | { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3496 | u32 tmp; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3497 | |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3498 | if (ASIC_IS_DCE3(rdev)) { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3499 | rdev->irq.stat_regs.r600.disp_int = RREG32(DCE3_DISP_INTERRUPT_STATUS); |
| 3500 | rdev->irq.stat_regs.r600.disp_int_cont = RREG32(DCE3_DISP_INTERRUPT_STATUS_CONTINUE); |
| 3501 | rdev->irq.stat_regs.r600.disp_int_cont2 = RREG32(DCE3_DISP_INTERRUPT_STATUS_CONTINUE2); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3502 | if (ASIC_IS_DCE32(rdev)) { |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3503 | rdev->irq.stat_regs.r600.hdmi0_status = RREG32(AFMT_STATUS + DCE3_HDMI_OFFSET0); |
| 3504 | rdev->irq.stat_regs.r600.hdmi1_status = RREG32(AFMT_STATUS + DCE3_HDMI_OFFSET1); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3505 | } else { |
| 3506 | rdev->irq.stat_regs.r600.hdmi0_status = RREG32(HDMI0_STATUS); |
| 3507 | rdev->irq.stat_regs.r600.hdmi1_status = RREG32(DCE3_HDMI1_STATUS); |
| 3508 | } |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3509 | } else { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3510 | rdev->irq.stat_regs.r600.disp_int = RREG32(DISP_INTERRUPT_STATUS); |
| 3511 | rdev->irq.stat_regs.r600.disp_int_cont = RREG32(DISP_INTERRUPT_STATUS_CONTINUE); |
| 3512 | rdev->irq.stat_regs.r600.disp_int_cont2 = 0; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3513 | rdev->irq.stat_regs.r600.hdmi0_status = RREG32(HDMI0_STATUS); |
| 3514 | rdev->irq.stat_regs.r600.hdmi1_status = RREG32(HDMI1_STATUS); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3515 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3516 | rdev->irq.stat_regs.r600.d1grph_int = RREG32(D1GRPH_INTERRUPT_STATUS); |
| 3517 | rdev->irq.stat_regs.r600.d2grph_int = RREG32(D2GRPH_INTERRUPT_STATUS); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3518 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3519 | if (rdev->irq.stat_regs.r600.d1grph_int & DxGRPH_PFLIP_INT_OCCURRED) |
| 3520 | WREG32(D1GRPH_INTERRUPT_STATUS, DxGRPH_PFLIP_INT_CLEAR); |
| 3521 | if (rdev->irq.stat_regs.r600.d2grph_int & DxGRPH_PFLIP_INT_OCCURRED) |
| 3522 | WREG32(D2GRPH_INTERRUPT_STATUS, DxGRPH_PFLIP_INT_CLEAR); |
| 3523 | if (rdev->irq.stat_regs.r600.disp_int & LB_D1_VBLANK_INTERRUPT) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3524 | WREG32(D1MODE_VBLANK_STATUS, DxMODE_VBLANK_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3525 | if (rdev->irq.stat_regs.r600.disp_int & LB_D1_VLINE_INTERRUPT) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3526 | WREG32(D1MODE_VLINE_STATUS, DxMODE_VLINE_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3527 | if (rdev->irq.stat_regs.r600.disp_int & LB_D2_VBLANK_INTERRUPT) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3528 | WREG32(D2MODE_VBLANK_STATUS, DxMODE_VBLANK_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3529 | if (rdev->irq.stat_regs.r600.disp_int & LB_D2_VLINE_INTERRUPT) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3530 | WREG32(D2MODE_VLINE_STATUS, DxMODE_VLINE_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3531 | if (rdev->irq.stat_regs.r600.disp_int & DC_HPD1_INTERRUPT) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3532 | if (ASIC_IS_DCE3(rdev)) { |
| 3533 | tmp = RREG32(DC_HPD1_INT_CONTROL); |
| 3534 | tmp |= DC_HPDx_INT_ACK; |
| 3535 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 3536 | } else { |
| 3537 | tmp = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL); |
| 3538 | tmp |= DC_HPDx_INT_ACK; |
| 3539 | WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); |
| 3540 | } |
| 3541 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3542 | if (rdev->irq.stat_regs.r600.disp_int & DC_HPD2_INTERRUPT) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3543 | if (ASIC_IS_DCE3(rdev)) { |
| 3544 | tmp = RREG32(DC_HPD2_INT_CONTROL); |
| 3545 | tmp |= DC_HPDx_INT_ACK; |
| 3546 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 3547 | } else { |
| 3548 | tmp = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL); |
| 3549 | tmp |= DC_HPDx_INT_ACK; |
| 3550 | WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); |
| 3551 | } |
| 3552 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3553 | if (rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD3_INTERRUPT) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3554 | if (ASIC_IS_DCE3(rdev)) { |
| 3555 | tmp = RREG32(DC_HPD3_INT_CONTROL); |
| 3556 | tmp |= DC_HPDx_INT_ACK; |
| 3557 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 3558 | } else { |
| 3559 | tmp = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL); |
| 3560 | tmp |= DC_HPDx_INT_ACK; |
| 3561 | WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, tmp); |
| 3562 | } |
| 3563 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3564 | if (rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD4_INTERRUPT) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3565 | tmp = RREG32(DC_HPD4_INT_CONTROL); |
| 3566 | tmp |= DC_HPDx_INT_ACK; |
| 3567 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 3568 | } |
| 3569 | if (ASIC_IS_DCE32(rdev)) { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3570 | if (rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD5_INTERRUPT) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3571 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 3572 | tmp |= DC_HPDx_INT_ACK; |
| 3573 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 3574 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3575 | if (rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD6_INTERRUPT) { |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3576 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 3577 | tmp |= DC_HPDx_INT_ACK; |
| 3578 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 3579 | } |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3580 | if (rdev->irq.stat_regs.r600.hdmi0_status & AFMT_AZ_FORMAT_WTRIG) { |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3581 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET0); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3582 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3583 | WREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET0, tmp); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3584 | } |
| 3585 | if (rdev->irq.stat_regs.r600.hdmi1_status & AFMT_AZ_FORMAT_WTRIG) { |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3586 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET1); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3587 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
Rafał Miłecki | c6543a6 | 2012-04-28 23:35:24 +0200 | [diff] [blame] | 3588 | WREG32(AFMT_AUDIO_PACKET_CONTROL + DCE3_HDMI_OFFSET1, tmp); |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 3589 | } |
| 3590 | } else { |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3591 | if (rdev->irq.stat_regs.r600.hdmi0_status & HDMI0_AZ_FORMAT_WTRIG) { |
| 3592 | tmp = RREG32(HDMI0_AUDIO_PACKET_CONTROL); |
| 3593 | tmp |= HDMI0_AZ_FORMAT_WTRIG_ACK; |
| 3594 | WREG32(HDMI0_AUDIO_PACKET_CONTROL, tmp); |
| 3595 | } |
| 3596 | if (rdev->irq.stat_regs.r600.hdmi1_status & HDMI0_AZ_FORMAT_WTRIG) { |
| 3597 | if (ASIC_IS_DCE3(rdev)) { |
| 3598 | tmp = RREG32(DCE3_HDMI1_AUDIO_PACKET_CONTROL); |
| 3599 | tmp |= HDMI0_AZ_FORMAT_WTRIG_ACK; |
| 3600 | WREG32(DCE3_HDMI1_AUDIO_PACKET_CONTROL, tmp); |
| 3601 | } else { |
| 3602 | tmp = RREG32(HDMI1_AUDIO_PACKET_CONTROL); |
| 3603 | tmp |= HDMI0_AZ_FORMAT_WTRIG_ACK; |
| 3604 | WREG32(HDMI1_AUDIO_PACKET_CONTROL, tmp); |
| 3605 | } |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 3606 | } |
| 3607 | } |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3608 | } |
| 3609 | |
| 3610 | void r600_irq_disable(struct radeon_device *rdev) |
| 3611 | { |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3612 | r600_disable_interrupts(rdev); |
| 3613 | /* Wait and acknowledge irq */ |
| 3614 | mdelay(1); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3615 | r600_irq_ack(rdev); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3616 | r600_disable_interrupt_state(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3617 | } |
| 3618 | |
Andi Kleen | ce580fa | 2011-10-13 16:08:47 -0700 | [diff] [blame] | 3619 | static u32 r600_get_ih_wptr(struct radeon_device *rdev) |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3620 | { |
| 3621 | u32 wptr, tmp; |
| 3622 | |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3623 | if (rdev->wb.enabled) |
Cédric Cano | 204ae24 | 2011-04-19 11:07:13 -0400 | [diff] [blame] | 3624 | wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3625 | else |
| 3626 | wptr = RREG32(IH_RB_WPTR); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3627 | |
| 3628 | if (wptr & RB_OVERFLOW) { |
Jerome Glisse | 7924e5e | 2010-01-15 14:44:39 +0100 | [diff] [blame] | 3629 | /* When a ring buffer overflow happen start parsing interrupt |
| 3630 | * from the last not overwritten vector (wptr + 16). Hopefully |
| 3631 | * this should allow us to catchup. |
| 3632 | */ |
| 3633 | dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n", |
| 3634 | wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask); |
| 3635 | rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3636 | tmp = RREG32(IH_RB_CNTL); |
| 3637 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 3638 | WREG32(IH_RB_CNTL, tmp); |
| 3639 | } |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 3640 | return (wptr & rdev->ih.ptr_mask); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3641 | } |
| 3642 | |
| 3643 | /* r600 IV Ring |
| 3644 | * Each IV ring entry is 128 bits: |
| 3645 | * [7:0] - interrupt source id |
| 3646 | * [31:8] - reserved |
| 3647 | * [59:32] - interrupt source data |
| 3648 | * [127:60] - reserved |
| 3649 | * |
| 3650 | * The basic interrupt vector entries |
| 3651 | * are decoded as follows: |
| 3652 | * src_id src_data description |
| 3653 | * 1 0 D1 Vblank |
| 3654 | * 1 1 D1 Vline |
| 3655 | * 5 0 D2 Vblank |
| 3656 | * 5 1 D2 Vline |
| 3657 | * 19 0 FP Hot plug detection A |
| 3658 | * 19 1 FP Hot plug detection B |
| 3659 | * 19 2 DAC A auto-detection |
| 3660 | * 19 3 DAC B auto-detection |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 3661 | * 21 4 HDMI block A |
| 3662 | * 21 5 HDMI block B |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3663 | * 176 - CP_INT RB |
| 3664 | * 177 - CP_INT IB1 |
| 3665 | * 178 - CP_INT IB2 |
| 3666 | * 181 - EOP Interrupt |
| 3667 | * 233 - GUI Idle |
| 3668 | * |
| 3669 | * Note, these are based on r600 and may need to be |
| 3670 | * adjusted or added to on newer asics |
| 3671 | */ |
| 3672 | |
| 3673 | int r600_irq_process(struct radeon_device *rdev) |
| 3674 | { |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 3675 | u32 wptr; |
| 3676 | u32 rptr; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3677 | u32 src_id, src_data; |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3678 | u32 ring_index; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3679 | bool queue_hotplug = false; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3680 | bool queue_hdmi = false; |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3681 | bool queue_thermal = false; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3682 | |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 3683 | if (!rdev->ih.enabled || rdev->shutdown) |
Jerome Glisse | 79c2bbc | 2010-01-15 14:44:38 +0100 | [diff] [blame] | 3684 | return IRQ_NONE; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3685 | |
Benjamin Herrenschmidt | f6a5693 | 2011-07-13 06:28:22 +0000 | [diff] [blame] | 3686 | /* No MSIs, need a dummy read to flush PCI DMAs */ |
| 3687 | if (!rdev->msi_enabled) |
| 3688 | RREG32(IH_RB_WPTR); |
| 3689 | |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 3690 | wptr = r600_get_ih_wptr(rdev); |
Christian Koenig | c20dc36 | 2012-05-16 21:45:24 +0200 | [diff] [blame] | 3691 | |
| 3692 | restart_ih: |
| 3693 | /* is somebody else already processing irqs? */ |
| 3694 | if (atomic_xchg(&rdev->ih.lock, 1)) |
| 3695 | return IRQ_NONE; |
| 3696 | |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 3697 | rptr = rdev->ih.rptr; |
| 3698 | DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); |
| 3699 | |
Benjamin Herrenschmidt | 964f664 | 2011-07-13 16:28:19 +1000 | [diff] [blame] | 3700 | /* Order reading of wptr vs. reading of IH ring data */ |
| 3701 | rmb(); |
| 3702 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3703 | /* display interrupts */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3704 | r600_irq_ack(rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3705 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3706 | while (rptr != wptr) { |
| 3707 | /* wptr/rptr are in bytes! */ |
| 3708 | ring_index = rptr / 4; |
Cédric Cano | 4eace7f | 2011-02-11 19:45:38 -0500 | [diff] [blame] | 3709 | src_id = le32_to_cpu(rdev->ih.ring[ring_index]) & 0xff; |
| 3710 | src_data = le32_to_cpu(rdev->ih.ring[ring_index + 1]) & 0xfffffff; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3711 | |
| 3712 | switch (src_id) { |
| 3713 | case 1: /* D1 vblank/vline */ |
| 3714 | switch (src_data) { |
| 3715 | case 0: /* D1 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3716 | if (rdev->irq.stat_regs.r600.disp_int & LB_D1_VBLANK_INTERRUPT) { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3717 | if (rdev->irq.crtc_vblank_int[0]) { |
| 3718 | drm_handle_vblank(rdev->ddev, 0); |
| 3719 | rdev->pm.vblank_sync = true; |
| 3720 | wake_up(&rdev->irq.vblank_queue); |
| 3721 | } |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 3722 | if (atomic_read(&rdev->irq.pflip[0])) |
Mario Kleiner | 3e4ea74 | 2010-11-21 10:59:02 -0500 | [diff] [blame] | 3723 | radeon_crtc_handle_flip(rdev, 0); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3724 | rdev->irq.stat_regs.r600.disp_int &= ~LB_D1_VBLANK_INTERRUPT; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3725 | DRM_DEBUG("IH: D1 vblank\n"); |
| 3726 | } |
| 3727 | break; |
| 3728 | case 1: /* D1 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3729 | if (rdev->irq.stat_regs.r600.disp_int & LB_D1_VLINE_INTERRUPT) { |
| 3730 | rdev->irq.stat_regs.r600.disp_int &= ~LB_D1_VLINE_INTERRUPT; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3731 | DRM_DEBUG("IH: D1 vline\n"); |
| 3732 | } |
| 3733 | break; |
| 3734 | default: |
Alex Deucher | b042589 | 2010-01-11 19:47:38 -0500 | [diff] [blame] | 3735 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3736 | break; |
| 3737 | } |
| 3738 | break; |
| 3739 | case 5: /* D2 vblank/vline */ |
| 3740 | switch (src_data) { |
| 3741 | case 0: /* D2 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3742 | if (rdev->irq.stat_regs.r600.disp_int & LB_D2_VBLANK_INTERRUPT) { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3743 | if (rdev->irq.crtc_vblank_int[1]) { |
| 3744 | drm_handle_vblank(rdev->ddev, 1); |
| 3745 | rdev->pm.vblank_sync = true; |
| 3746 | wake_up(&rdev->irq.vblank_queue); |
| 3747 | } |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 3748 | if (atomic_read(&rdev->irq.pflip[1])) |
Mario Kleiner | 3e4ea74 | 2010-11-21 10:59:02 -0500 | [diff] [blame] | 3749 | radeon_crtc_handle_flip(rdev, 1); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3750 | rdev->irq.stat_regs.r600.disp_int &= ~LB_D2_VBLANK_INTERRUPT; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3751 | DRM_DEBUG("IH: D2 vblank\n"); |
| 3752 | } |
| 3753 | break; |
| 3754 | case 1: /* D1 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3755 | if (rdev->irq.stat_regs.r600.disp_int & LB_D2_VLINE_INTERRUPT) { |
| 3756 | rdev->irq.stat_regs.r600.disp_int &= ~LB_D2_VLINE_INTERRUPT; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3757 | DRM_DEBUG("IH: D2 vline\n"); |
| 3758 | } |
| 3759 | break; |
| 3760 | default: |
Alex Deucher | b042589 | 2010-01-11 19:47:38 -0500 | [diff] [blame] | 3761 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3762 | break; |
| 3763 | } |
| 3764 | break; |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3765 | case 19: /* HPD/DAC hotplug */ |
| 3766 | switch (src_data) { |
| 3767 | case 0: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3768 | if (rdev->irq.stat_regs.r600.disp_int & DC_HPD1_INTERRUPT) { |
| 3769 | rdev->irq.stat_regs.r600.disp_int &= ~DC_HPD1_INTERRUPT; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3770 | queue_hotplug = true; |
| 3771 | DRM_DEBUG("IH: HPD1\n"); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3772 | } |
| 3773 | break; |
| 3774 | case 1: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3775 | if (rdev->irq.stat_regs.r600.disp_int & DC_HPD2_INTERRUPT) { |
| 3776 | rdev->irq.stat_regs.r600.disp_int &= ~DC_HPD2_INTERRUPT; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3777 | queue_hotplug = true; |
| 3778 | DRM_DEBUG("IH: HPD2\n"); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3779 | } |
| 3780 | break; |
| 3781 | case 4: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3782 | if (rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD3_INTERRUPT) { |
| 3783 | rdev->irq.stat_regs.r600.disp_int_cont &= ~DC_HPD3_INTERRUPT; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3784 | queue_hotplug = true; |
| 3785 | DRM_DEBUG("IH: HPD3\n"); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3786 | } |
| 3787 | break; |
| 3788 | case 5: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3789 | if (rdev->irq.stat_regs.r600.disp_int_cont & DC_HPD4_INTERRUPT) { |
| 3790 | rdev->irq.stat_regs.r600.disp_int_cont &= ~DC_HPD4_INTERRUPT; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3791 | queue_hotplug = true; |
| 3792 | DRM_DEBUG("IH: HPD4\n"); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3793 | } |
| 3794 | break; |
| 3795 | case 10: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3796 | if (rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD5_INTERRUPT) { |
| 3797 | rdev->irq.stat_regs.r600.disp_int_cont2 &= ~DC_HPD5_INTERRUPT; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3798 | queue_hotplug = true; |
| 3799 | DRM_DEBUG("IH: HPD5\n"); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3800 | } |
| 3801 | break; |
| 3802 | case 12: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3803 | if (rdev->irq.stat_regs.r600.disp_int_cont2 & DC_HPD6_INTERRUPT) { |
| 3804 | rdev->irq.stat_regs.r600.disp_int_cont2 &= ~DC_HPD6_INTERRUPT; |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3805 | queue_hotplug = true; |
| 3806 | DRM_DEBUG("IH: HPD6\n"); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3807 | } |
| 3808 | break; |
| 3809 | default: |
Alex Deucher | b042589 | 2010-01-11 19:47:38 -0500 | [diff] [blame] | 3810 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
Alex Deucher | e0df1ac | 2009-12-04 15:12:21 -0500 | [diff] [blame] | 3811 | break; |
| 3812 | } |
| 3813 | break; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3814 | case 21: /* hdmi */ |
| 3815 | switch (src_data) { |
| 3816 | case 4: |
| 3817 | if (rdev->irq.stat_regs.r600.hdmi0_status & HDMI0_AZ_FORMAT_WTRIG) { |
| 3818 | rdev->irq.stat_regs.r600.hdmi0_status &= ~HDMI0_AZ_FORMAT_WTRIG; |
| 3819 | queue_hdmi = true; |
| 3820 | DRM_DEBUG("IH: HDMI0\n"); |
| 3821 | } |
| 3822 | break; |
| 3823 | case 5: |
| 3824 | if (rdev->irq.stat_regs.r600.hdmi1_status & HDMI0_AZ_FORMAT_WTRIG) { |
| 3825 | rdev->irq.stat_regs.r600.hdmi1_status &= ~HDMI0_AZ_FORMAT_WTRIG; |
| 3826 | queue_hdmi = true; |
| 3827 | DRM_DEBUG("IH: HDMI1\n"); |
| 3828 | } |
| 3829 | break; |
| 3830 | default: |
| 3831 | DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3832 | break; |
| 3833 | } |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 3834 | break; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3835 | case 176: /* CP_INT in ring buffer */ |
| 3836 | case 177: /* CP_INT in IB1 */ |
| 3837 | case 178: /* CP_INT in IB2 */ |
| 3838 | DRM_DEBUG("IH: CP int: 0x%08x\n", src_data); |
Alex Deucher | 7465280 | 2011-08-25 13:39:48 -0400 | [diff] [blame] | 3839 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3840 | break; |
| 3841 | case 181: /* CP EOP event */ |
| 3842 | DRM_DEBUG("IH: CP EOP\n"); |
Alex Deucher | 7465280 | 2011-08-25 13:39:48 -0400 | [diff] [blame] | 3843 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3844 | break; |
Alex Deucher | 4d75658 | 2012-09-27 15:08:35 -0400 | [diff] [blame] | 3845 | case 224: /* DMA trap event */ |
| 3846 | DRM_DEBUG("IH: DMA trap\n"); |
| 3847 | radeon_fence_process(rdev, R600_RING_TYPE_DMA_INDEX); |
| 3848 | break; |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3849 | case 230: /* thermal low to high */ |
| 3850 | DRM_DEBUG("IH: thermal low to high\n"); |
| 3851 | rdev->pm.dpm.thermal.high_to_low = false; |
| 3852 | queue_thermal = true; |
| 3853 | break; |
| 3854 | case 231: /* thermal high to low */ |
| 3855 | DRM_DEBUG("IH: thermal high to low\n"); |
| 3856 | rdev->pm.dpm.thermal.high_to_low = true; |
| 3857 | queue_thermal = true; |
| 3858 | break; |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 3859 | case 233: /* GUI IDLE */ |
Ilija Hadzic | 303c805 | 2011-06-07 14:54:48 -0400 | [diff] [blame] | 3860 | DRM_DEBUG("IH: GUI idle\n"); |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 3861 | break; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3862 | default: |
Alex Deucher | b042589 | 2010-01-11 19:47:38 -0500 | [diff] [blame] | 3863 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3864 | break; |
| 3865 | } |
| 3866 | |
| 3867 | /* wptr/rptr are in bytes! */ |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 3868 | rptr += 16; |
| 3869 | rptr &= rdev->ih.ptr_mask; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3870 | } |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 3871 | if (queue_hotplug) |
Tejun Heo | 32c87fc | 2011-01-03 14:49:32 +0100 | [diff] [blame] | 3872 | schedule_work(&rdev->hotplug_work); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3873 | if (queue_hdmi) |
| 3874 | schedule_work(&rdev->audio_work); |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 3875 | if (queue_thermal && rdev->pm.dpm_enabled) |
| 3876 | schedule_work(&rdev->pm.dpm.thermal.work); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3877 | rdev->ih.rptr = rptr; |
| 3878 | WREG32(IH_RB_RPTR, rdev->ih.rptr); |
Christian Koenig | c20dc36 | 2012-05-16 21:45:24 +0200 | [diff] [blame] | 3879 | atomic_set(&rdev->ih.lock, 0); |
| 3880 | |
| 3881 | /* make sure wptr hasn't changed while processing */ |
| 3882 | wptr = r600_get_ih_wptr(rdev); |
| 3883 | if (wptr != rptr) |
| 3884 | goto restart_ih; |
| 3885 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 3886 | return IRQ_HANDLED; |
| 3887 | } |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3888 | |
| 3889 | /* |
| 3890 | * Debugfs info |
| 3891 | */ |
| 3892 | #if defined(CONFIG_DEBUG_FS) |
| 3893 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3894 | static int r600_debugfs_mc_info(struct seq_file *m, void *data) |
| 3895 | { |
| 3896 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 3897 | struct drm_device *dev = node->minor->dev; |
| 3898 | struct radeon_device *rdev = dev->dev_private; |
| 3899 | |
| 3900 | DREG32_SYS(m, rdev, R_000E50_SRBM_STATUS); |
| 3901 | DREG32_SYS(m, rdev, VM_L2_STATUS); |
| 3902 | return 0; |
| 3903 | } |
| 3904 | |
| 3905 | static struct drm_info_list r600_mc_info_list[] = { |
| 3906 | {"r600_mc_info", r600_debugfs_mc_info, 0, NULL}, |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 3907 | }; |
| 3908 | #endif |
| 3909 | |
| 3910 | int r600_debugfs_mc_info_init(struct radeon_device *rdev) |
| 3911 | { |
| 3912 | #if defined(CONFIG_DEBUG_FS) |
| 3913 | return radeon_debugfs_add_files(rdev, r600_mc_info_list, ARRAY_SIZE(r600_mc_info_list)); |
| 3914 | #else |
| 3915 | return 0; |
| 3916 | #endif |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 3917 | } |
Jerome Glisse | 062b389 | 2010-02-04 20:36:39 +0100 | [diff] [blame] | 3918 | |
| 3919 | /** |
| 3920 | * r600_ioctl_wait_idle - flush host path cache on wait idle ioctl |
| 3921 | * rdev: radeon device structure |
| 3922 | * bo: buffer object struct which userspace is waiting for idle |
| 3923 | * |
| 3924 | * Some R6XX/R7XX doesn't seems to take into account HDP flush performed |
| 3925 | * through ring buffer, this leads to corruption in rendering, see |
| 3926 | * http://bugzilla.kernel.org/show_bug.cgi?id=15186 to avoid this we |
| 3927 | * directly perform HDP flush by writing register through MMIO. |
| 3928 | */ |
| 3929 | void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo) |
| 3930 | { |
Alex Deucher | 812d046 | 2010-07-26 18:51:53 -0400 | [diff] [blame] | 3931 | /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read |
Alex Deucher | f3886f8 | 2010-12-08 10:05:34 -0500 | [diff] [blame] | 3932 | * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL. |
| 3933 | * This seems to cause problems on some AGP cards. Just use the old |
| 3934 | * method for them. |
Alex Deucher | 812d046 | 2010-07-26 18:51:53 -0400 | [diff] [blame] | 3935 | */ |
Alex Deucher | e488459 | 2010-09-27 10:57:10 -0400 | [diff] [blame] | 3936 | if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) && |
Alex Deucher | f3886f8 | 2010-12-08 10:05:34 -0500 | [diff] [blame] | 3937 | rdev->vram_scratch.ptr && !(rdev->flags & RADEON_IS_AGP)) { |
Alex Deucher | 87cbf8f | 2010-08-27 13:59:54 -0400 | [diff] [blame] | 3938 | void __iomem *ptr = (void *)rdev->vram_scratch.ptr; |
Alex Deucher | 812d046 | 2010-07-26 18:51:53 -0400 | [diff] [blame] | 3939 | u32 tmp; |
| 3940 | |
| 3941 | WREG32(HDP_DEBUG1, 0); |
| 3942 | tmp = readl((void __iomem *)ptr); |
| 3943 | } else |
| 3944 | WREG32(R_005480_HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1); |
Jerome Glisse | 062b389 | 2010-02-04 20:36:39 +0100 | [diff] [blame] | 3945 | } |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3946 | |
| 3947 | void r600_set_pcie_lanes(struct radeon_device *rdev, int lanes) |
| 3948 | { |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 3949 | u32 link_width_cntl, mask; |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3950 | |
| 3951 | if (rdev->flags & RADEON_IS_IGP) |
| 3952 | return; |
| 3953 | |
| 3954 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 3955 | return; |
| 3956 | |
| 3957 | /* x2 cards have a special sequence */ |
| 3958 | if (ASIC_IS_X2(rdev)) |
| 3959 | return; |
| 3960 | |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 3961 | radeon_gui_idle(rdev); |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3962 | |
| 3963 | switch (lanes) { |
| 3964 | case 0: |
| 3965 | mask = RADEON_PCIE_LC_LINK_WIDTH_X0; |
| 3966 | break; |
| 3967 | case 1: |
| 3968 | mask = RADEON_PCIE_LC_LINK_WIDTH_X1; |
| 3969 | break; |
| 3970 | case 2: |
| 3971 | mask = RADEON_PCIE_LC_LINK_WIDTH_X2; |
| 3972 | break; |
| 3973 | case 4: |
| 3974 | mask = RADEON_PCIE_LC_LINK_WIDTH_X4; |
| 3975 | break; |
| 3976 | case 8: |
| 3977 | mask = RADEON_PCIE_LC_LINK_WIDTH_X8; |
| 3978 | break; |
| 3979 | case 12: |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 3980 | /* not actually supported */ |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3981 | mask = RADEON_PCIE_LC_LINK_WIDTH_X12; |
| 3982 | break; |
| 3983 | case 16: |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3984 | mask = RADEON_PCIE_LC_LINK_WIDTH_X16; |
| 3985 | break; |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 3986 | default: |
| 3987 | DRM_ERROR("invalid pcie lane request: %d\n", lanes); |
| 3988 | return; |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3989 | } |
| 3990 | |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 3991 | link_width_cntl = RREG32_PCIE_PORT(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 3992 | link_width_cntl &= ~RADEON_PCIE_LC_LINK_WIDTH_MASK; |
| 3993 | link_width_cntl |= mask << RADEON_PCIE_LC_LINK_WIDTH_SHIFT; |
| 3994 | link_width_cntl |= (RADEON_PCIE_LC_RECONFIG_NOW | |
| 3995 | R600_PCIE_LC_RECONFIG_ARC_MISSING_ESCAPE); |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3996 | |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 3997 | WREG32_PCIE_PORT(RADEON_PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 3998 | } |
| 3999 | |
| 4000 | int r600_get_pcie_lanes(struct radeon_device *rdev) |
| 4001 | { |
| 4002 | u32 link_width_cntl; |
| 4003 | |
| 4004 | if (rdev->flags & RADEON_IS_IGP) |
| 4005 | return 0; |
| 4006 | |
| 4007 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 4008 | return 0; |
| 4009 | |
| 4010 | /* x2 cards have a special sequence */ |
| 4011 | if (ASIC_IS_X2(rdev)) |
| 4012 | return 0; |
| 4013 | |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 4014 | radeon_gui_idle(rdev); |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 4015 | |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4016 | link_width_cntl = RREG32_PCIE_PORT(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 4017 | |
| 4018 | switch ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) >> RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT) { |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 4019 | case RADEON_PCIE_LC_LINK_WIDTH_X1: |
| 4020 | return 1; |
| 4021 | case RADEON_PCIE_LC_LINK_WIDTH_X2: |
| 4022 | return 2; |
| 4023 | case RADEON_PCIE_LC_LINK_WIDTH_X4: |
| 4024 | return 4; |
| 4025 | case RADEON_PCIE_LC_LINK_WIDTH_X8: |
| 4026 | return 8; |
Alex Deucher | d5445a1 | 2013-03-18 18:52:13 -0400 | [diff] [blame] | 4027 | case RADEON_PCIE_LC_LINK_WIDTH_X12: |
| 4028 | /* not actually supported */ |
| 4029 | return 12; |
| 4030 | case RADEON_PCIE_LC_LINK_WIDTH_X0: |
Alex Deucher | 3313e3d | 2011-01-06 18:49:34 -0500 | [diff] [blame] | 4031 | case RADEON_PCIE_LC_LINK_WIDTH_X16: |
| 4032 | default: |
| 4033 | return 16; |
| 4034 | } |
| 4035 | } |
| 4036 | |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4037 | static void r600_pcie_gen2_enable(struct radeon_device *rdev) |
| 4038 | { |
| 4039 | u32 link_width_cntl, lanes, speed_cntl, training_cntl, tmp; |
| 4040 | u16 link_cntl2; |
| 4041 | |
Alex Deucher | d42dd57 | 2011-01-12 20:05:11 -0500 | [diff] [blame] | 4042 | if (radeon_pcie_gen2 == 0) |
| 4043 | return; |
| 4044 | |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4045 | if (rdev->flags & RADEON_IS_IGP) |
| 4046 | return; |
| 4047 | |
| 4048 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 4049 | return; |
| 4050 | |
| 4051 | /* x2 cards have a special sequence */ |
| 4052 | if (ASIC_IS_X2(rdev)) |
| 4053 | return; |
| 4054 | |
| 4055 | /* only RV6xx+ chips are supported */ |
| 4056 | if (rdev->family <= CHIP_R600) |
| 4057 | return; |
| 4058 | |
Kleber Sacilotto de Souza | 7e0e419 | 2013-05-03 19:43:13 -0300 | [diff] [blame] | 4059 | if ((rdev->pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) && |
| 4060 | (rdev->pdev->bus->max_bus_speed != PCIE_SPEED_8_0GT)) |
Dave Airlie | 197bbb3 | 2012-06-27 08:35:54 +0100 | [diff] [blame] | 4061 | return; |
| 4062 | |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4063 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
Alex Deucher | 3691fee | 2012-10-08 17:46:27 -0400 | [diff] [blame] | 4064 | if (speed_cntl & LC_CURRENT_DATA_RATE) { |
| 4065 | DRM_INFO("PCIE gen 2 link speeds already enabled\n"); |
| 4066 | return; |
| 4067 | } |
| 4068 | |
Dave Airlie | 197bbb3 | 2012-06-27 08:35:54 +0100 | [diff] [blame] | 4069 | DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n"); |
| 4070 | |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4071 | /* 55 nm r6xx asics */ |
| 4072 | if ((rdev->family == CHIP_RV670) || |
| 4073 | (rdev->family == CHIP_RV620) || |
| 4074 | (rdev->family == CHIP_RV635)) { |
| 4075 | /* advertise upconfig capability */ |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4076 | link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4077 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4078 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
| 4079 | link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4080 | if (link_width_cntl & LC_RENEGOTIATION_SUPPORT) { |
| 4081 | lanes = (link_width_cntl & LC_LINK_WIDTH_RD_MASK) >> LC_LINK_WIDTH_RD_SHIFT; |
| 4082 | link_width_cntl &= ~(LC_LINK_WIDTH_MASK | |
| 4083 | LC_RECONFIG_ARC_MISSING_ESCAPE); |
| 4084 | link_width_cntl |= lanes | LC_RECONFIG_NOW | LC_RENEGOTIATE_EN; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4085 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4086 | } else { |
| 4087 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4088 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4089 | } |
| 4090 | } |
| 4091 | |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4092 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4093 | if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) && |
| 4094 | (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) { |
| 4095 | |
| 4096 | /* 55 nm r6xx asics */ |
| 4097 | if ((rdev->family == CHIP_RV670) || |
| 4098 | (rdev->family == CHIP_RV620) || |
| 4099 | (rdev->family == CHIP_RV635)) { |
| 4100 | WREG32(MM_CFGREGS_CNTL, 0x8); |
| 4101 | link_cntl2 = RREG32(0x4088); |
| 4102 | WREG32(MM_CFGREGS_CNTL, 0); |
| 4103 | /* not supported yet */ |
| 4104 | if (link_cntl2 & SELECTABLE_DEEMPHASIS) |
| 4105 | return; |
| 4106 | } |
| 4107 | |
| 4108 | speed_cntl &= ~LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_MASK; |
| 4109 | speed_cntl |= (0x3 << LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_SHIFT); |
| 4110 | speed_cntl &= ~LC_VOLTAGE_TIMER_SEL_MASK; |
| 4111 | speed_cntl &= ~LC_FORCE_DIS_HW_SPEED_CHANGE; |
| 4112 | speed_cntl |= LC_FORCE_EN_HW_SPEED_CHANGE; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4113 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4114 | |
| 4115 | tmp = RREG32(0x541c); |
| 4116 | WREG32(0x541c, tmp | 0x8); |
| 4117 | WREG32(MM_CFGREGS_CNTL, MM_WR_TO_CFG_EN); |
| 4118 | link_cntl2 = RREG16(0x4088); |
| 4119 | link_cntl2 &= ~TARGET_LINK_SPEED_MASK; |
| 4120 | link_cntl2 |= 0x2; |
| 4121 | WREG16(0x4088, link_cntl2); |
| 4122 | WREG32(MM_CFGREGS_CNTL, 0); |
| 4123 | |
| 4124 | if ((rdev->family == CHIP_RV670) || |
| 4125 | (rdev->family == CHIP_RV620) || |
| 4126 | (rdev->family == CHIP_RV635)) { |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4127 | training_cntl = RREG32_PCIE_PORT(PCIE_LC_TRAINING_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4128 | training_cntl &= ~LC_POINT_7_PLUS_EN; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4129 | WREG32_PCIE_PORT(PCIE_LC_TRAINING_CNTL, training_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4130 | } else { |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4131 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4132 | speed_cntl &= ~LC_TARGET_LINK_SPEED_OVERRIDE_EN; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4133 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4134 | } |
| 4135 | |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4136 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4137 | speed_cntl |= LC_GEN2_EN_STRAP; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4138 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4139 | |
| 4140 | } else { |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4141 | link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4142 | /* XXX: only disable it if gen1 bridge vendor == 0x111d or 0x1106 */ |
| 4143 | if (1) |
| 4144 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
| 4145 | else |
| 4146 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
Alex Deucher | 492d2b6 | 2012-10-25 16:06:59 -0400 | [diff] [blame] | 4147 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 4148 | } |
| 4149 | } |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 4150 | |
| 4151 | /** |
Alex Deucher | d041889 | 2013-01-24 10:35:23 -0500 | [diff] [blame] | 4152 | * r600_get_gpu_clock_counter - return GPU clock counter snapshot |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 4153 | * |
| 4154 | * @rdev: radeon_device pointer |
| 4155 | * |
| 4156 | * Fetches a GPU clock counter snapshot (R6xx-cayman). |
| 4157 | * Returns the 64 bit clock counter snapshot. |
| 4158 | */ |
Alex Deucher | d041889 | 2013-01-24 10:35:23 -0500 | [diff] [blame] | 4159 | uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev) |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 4160 | { |
| 4161 | uint64_t clock; |
| 4162 | |
| 4163 | mutex_lock(&rdev->gpu_clock_mutex); |
| 4164 | WREG32(RLC_CAPTURE_GPU_CLOCK_COUNT, 1); |
| 4165 | clock = (uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_LSB) | |
| 4166 | ((uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_MSB) << 32ULL); |
| 4167 | mutex_unlock(&rdev->gpu_clock_mutex); |
| 4168 | return clock; |
| 4169 | } |