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