Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Advanced Micro Devices, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | * Authors: Alex Deucher |
| 23 | */ |
| 24 | #include <linux/firmware.h> |
| 25 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 27 | #include "drmP.h" |
| 28 | #include "radeon.h" |
Daniel Vetter | e699037 | 2010-03-11 21:19:17 +0000 | [diff] [blame] | 29 | #include "radeon_asic.h" |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 30 | #include "radeon_drm.h" |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 31 | #include "evergreend.h" |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 32 | #include "atom.h" |
| 33 | #include "avivod.h" |
| 34 | #include "evergreen_reg.h" |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 35 | #include "evergreen_blit_shaders.h" |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 36 | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 37 | #define EVERGREEN_PFP_UCODE_SIZE 1120 |
| 38 | #define EVERGREEN_PM4_UCODE_SIZE 1376 |
| 39 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 40 | static void evergreen_gpu_init(struct radeon_device *rdev); |
| 41 | void evergreen_fini(struct radeon_device *rdev); |
Ilija Hadzic | b07759b | 2011-09-20 10:22:58 -0400 | [diff] [blame] | 42 | void evergreen_pcie_gen2_enable(struct radeon_device *rdev); |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 43 | extern void cayman_cp_int_cntl_setup(struct radeon_device *rdev, |
| 44 | int ring, u32 cp_int_cntl); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 45 | |
Jerome Glisse | 285484e | 2011-12-16 17:03:42 -0500 | [diff] [blame] | 46 | void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw, |
| 47 | unsigned *bankh, unsigned *mtaspect, |
| 48 | unsigned *tile_split) |
| 49 | { |
| 50 | *bankw = (tiling_flags >> RADEON_TILING_EG_BANKW_SHIFT) & RADEON_TILING_EG_BANKW_MASK; |
| 51 | *bankh = (tiling_flags >> RADEON_TILING_EG_BANKH_SHIFT) & RADEON_TILING_EG_BANKH_MASK; |
| 52 | *mtaspect = (tiling_flags >> RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT) & RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK; |
| 53 | *tile_split = (tiling_flags >> RADEON_TILING_EG_TILE_SPLIT_SHIFT) & RADEON_TILING_EG_TILE_SPLIT_MASK; |
| 54 | switch (*bankw) { |
| 55 | default: |
| 56 | case 1: *bankw = EVERGREEN_ADDR_SURF_BANK_WIDTH_1; break; |
| 57 | case 2: *bankw = EVERGREEN_ADDR_SURF_BANK_WIDTH_2; break; |
| 58 | case 4: *bankw = EVERGREEN_ADDR_SURF_BANK_WIDTH_4; break; |
| 59 | case 8: *bankw = EVERGREEN_ADDR_SURF_BANK_WIDTH_8; break; |
| 60 | } |
| 61 | switch (*bankh) { |
| 62 | default: |
| 63 | case 1: *bankh = EVERGREEN_ADDR_SURF_BANK_HEIGHT_1; break; |
| 64 | case 2: *bankh = EVERGREEN_ADDR_SURF_BANK_HEIGHT_2; break; |
| 65 | case 4: *bankh = EVERGREEN_ADDR_SURF_BANK_HEIGHT_4; break; |
| 66 | case 8: *bankh = EVERGREEN_ADDR_SURF_BANK_HEIGHT_8; break; |
| 67 | } |
| 68 | switch (*mtaspect) { |
| 69 | default: |
| 70 | case 1: *mtaspect = EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_1; break; |
| 71 | case 2: *mtaspect = EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_2; break; |
| 72 | case 4: *mtaspect = EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_4; break; |
| 73 | case 8: *mtaspect = EVERGREEN_ADDR_SURF_MACRO_TILE_ASPECT_8; break; |
| 74 | } |
| 75 | } |
| 76 | |
Alex Deucher | d054ac1 | 2011-09-01 17:46:15 +0000 | [diff] [blame] | 77 | void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev) |
| 78 | { |
| 79 | u16 ctl, v; |
| 80 | int cap, err; |
| 81 | |
| 82 | cap = pci_pcie_cap(rdev->pdev); |
| 83 | if (!cap) |
| 84 | return; |
| 85 | |
| 86 | err = pci_read_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, &ctl); |
| 87 | if (err) |
| 88 | return; |
| 89 | |
| 90 | v = (ctl & PCI_EXP_DEVCTL_READRQ) >> 12; |
| 91 | |
| 92 | /* if bios or OS sets MAX_READ_REQUEST_SIZE to an invalid value, fix it |
| 93 | * to avoid hangs or perfomance issues |
| 94 | */ |
| 95 | if ((v == 0) || (v == 6) || (v == 7)) { |
| 96 | ctl &= ~PCI_EXP_DEVCTL_READRQ; |
| 97 | ctl |= (2 << 12); |
| 98 | pci_write_config_word(rdev->pdev, cap + PCI_EXP_DEVCTL, ctl); |
| 99 | } |
| 100 | } |
| 101 | |
Alex Deucher | 3ae19b7 | 2012-02-23 17:53:37 -0500 | [diff] [blame] | 102 | void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc) |
| 103 | { |
| 104 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc]; |
| 105 | int i; |
| 106 | |
| 107 | if (RREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset) & EVERGREEN_CRTC_MASTER_EN) { |
| 108 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 109 | if (!(RREG32(EVERGREEN_CRTC_STATUS + radeon_crtc->crtc_offset) & EVERGREEN_CRTC_V_BLANK)) |
| 110 | break; |
| 111 | udelay(1); |
| 112 | } |
| 113 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 114 | if (RREG32(EVERGREEN_CRTC_STATUS + radeon_crtc->crtc_offset) & EVERGREEN_CRTC_V_BLANK) |
| 115 | break; |
| 116 | udelay(1); |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 121 | void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc) |
| 122 | { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 123 | /* enable the pflip int */ |
| 124 | radeon_irq_kms_pflip_irq_get(rdev, crtc); |
| 125 | } |
| 126 | |
| 127 | void evergreen_post_page_flip(struct radeon_device *rdev, int crtc) |
| 128 | { |
| 129 | /* disable the pflip int */ |
| 130 | radeon_irq_kms_pflip_irq_put(rdev, crtc); |
| 131 | } |
| 132 | |
| 133 | u32 evergreen_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base) |
| 134 | { |
| 135 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; |
| 136 | u32 tmp = RREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset); |
Alex Deucher | f649647 | 2011-11-28 14:49:26 -0500 | [diff] [blame] | 137 | int i; |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 138 | |
| 139 | /* Lock the graphics update lock */ |
| 140 | tmp |= EVERGREEN_GRPH_UPDATE_LOCK; |
| 141 | WREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); |
| 142 | |
| 143 | /* update the scanout addresses */ |
| 144 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + radeon_crtc->crtc_offset, |
| 145 | upper_32_bits(crtc_base)); |
| 146 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
| 147 | (u32)crtc_base); |
| 148 | |
| 149 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + radeon_crtc->crtc_offset, |
| 150 | upper_32_bits(crtc_base)); |
| 151 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, |
| 152 | (u32)crtc_base); |
| 153 | |
| 154 | /* Wait for update_pending to go high. */ |
Alex Deucher | f649647 | 2011-11-28 14:49:26 -0500 | [diff] [blame] | 155 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 156 | if (RREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset) & EVERGREEN_GRPH_SURFACE_UPDATE_PENDING) |
| 157 | break; |
| 158 | udelay(1); |
| 159 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 160 | DRM_DEBUG("Update pending now high. Unlocking vupdate_lock.\n"); |
| 161 | |
| 162 | /* Unlock the lock, so double-buffering can take place inside vblank */ |
| 163 | tmp &= ~EVERGREEN_GRPH_UPDATE_LOCK; |
| 164 | WREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); |
| 165 | |
| 166 | /* Return current update_pending status: */ |
| 167 | return RREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset) & EVERGREEN_GRPH_SURFACE_UPDATE_PENDING; |
| 168 | } |
| 169 | |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 170 | /* get temperature in millidegrees */ |
Alex Deucher | 20d391d | 2011-02-01 16:12:34 -0500 | [diff] [blame] | 171 | int evergreen_get_temp(struct radeon_device *rdev) |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 172 | { |
Alex Deucher | 1c88d74 | 2011-06-14 19:15:53 +0000 | [diff] [blame] | 173 | u32 temp, toffset; |
| 174 | int actual_temp = 0; |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 175 | |
Alex Deucher | 67b3f82 | 2011-05-25 18:45:37 -0400 | [diff] [blame] | 176 | if (rdev->family == CHIP_JUNIPER) { |
| 177 | toffset = (RREG32(CG_THERMAL_CTRL) & TOFFSET_MASK) >> |
| 178 | TOFFSET_SHIFT; |
| 179 | temp = (RREG32(CG_TS0_STATUS) & TS0_ADC_DOUT_MASK) >> |
| 180 | TS0_ADC_DOUT_SHIFT; |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 181 | |
Alex Deucher | 67b3f82 | 2011-05-25 18:45:37 -0400 | [diff] [blame] | 182 | if (toffset & 0x100) |
| 183 | actual_temp = temp / 2 - (0x200 - toffset); |
| 184 | else |
| 185 | actual_temp = temp / 2 + toffset; |
| 186 | |
| 187 | actual_temp = actual_temp * 1000; |
| 188 | |
| 189 | } else { |
| 190 | temp = (RREG32(CG_MULT_THERMAL_STATUS) & ASIC_T_MASK) >> |
| 191 | ASIC_T_SHIFT; |
| 192 | |
| 193 | if (temp & 0x400) |
| 194 | actual_temp = -256; |
| 195 | else if (temp & 0x200) |
| 196 | actual_temp = 255; |
| 197 | else if (temp & 0x100) { |
| 198 | actual_temp = temp & 0x1ff; |
| 199 | actual_temp |= ~0x1ff; |
| 200 | } else |
| 201 | actual_temp = temp & 0xff; |
| 202 | |
| 203 | actual_temp = (actual_temp * 1000) / 2; |
| 204 | } |
| 205 | |
| 206 | return actual_temp; |
Alex Deucher | 21a8122 | 2010-07-02 12:58:16 -0400 | [diff] [blame] | 207 | } |
| 208 | |
Alex Deucher | 20d391d | 2011-02-01 16:12:34 -0500 | [diff] [blame] | 209 | int sumo_get_temp(struct radeon_device *rdev) |
Alex Deucher | e33df25 | 2010-11-22 17:56:32 -0500 | [diff] [blame] | 210 | { |
| 211 | u32 temp = RREG32(CG_THERMAL_STATUS) & 0xff; |
Alex Deucher | 20d391d | 2011-02-01 16:12:34 -0500 | [diff] [blame] | 212 | int actual_temp = temp - 49; |
Alex Deucher | e33df25 | 2010-11-22 17:56:32 -0500 | [diff] [blame] | 213 | |
| 214 | return actual_temp * 1000; |
| 215 | } |
| 216 | |
Alex Deucher | a4c9e2e | 2011-11-04 10:09:41 -0400 | [diff] [blame] | 217 | void sumo_pm_init_profile(struct radeon_device *rdev) |
| 218 | { |
| 219 | int idx; |
| 220 | |
| 221 | /* default */ |
| 222 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_ps_idx = rdev->pm.default_power_state_index; |
| 223 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_ps_idx = rdev->pm.default_power_state_index; |
| 224 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_off_cm_idx = 0; |
| 225 | rdev->pm.profiles[PM_PROFILE_DEFAULT_IDX].dpms_on_cm_idx = 0; |
| 226 | |
| 227 | /* low,mid sh/mh */ |
| 228 | if (rdev->flags & RADEON_IS_MOBILITY) |
| 229 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_BATTERY, 0); |
| 230 | else |
| 231 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_PERFORMANCE, 0); |
| 232 | |
| 233 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_ps_idx = idx; |
| 234 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_ps_idx = idx; |
| 235 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_off_cm_idx = 0; |
| 236 | rdev->pm.profiles[PM_PROFILE_LOW_SH_IDX].dpms_on_cm_idx = 0; |
| 237 | |
| 238 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_ps_idx = idx; |
| 239 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_ps_idx = idx; |
| 240 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_off_cm_idx = 0; |
| 241 | rdev->pm.profiles[PM_PROFILE_LOW_MH_IDX].dpms_on_cm_idx = 0; |
| 242 | |
| 243 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_ps_idx = idx; |
| 244 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_ps_idx = idx; |
| 245 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_off_cm_idx = 0; |
| 246 | rdev->pm.profiles[PM_PROFILE_MID_SH_IDX].dpms_on_cm_idx = 0; |
| 247 | |
| 248 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_ps_idx = idx; |
| 249 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_ps_idx = idx; |
| 250 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_off_cm_idx = 0; |
| 251 | rdev->pm.profiles[PM_PROFILE_MID_MH_IDX].dpms_on_cm_idx = 0; |
| 252 | |
| 253 | /* high sh/mh */ |
| 254 | idx = radeon_pm_get_type_index(rdev, POWER_STATE_TYPE_PERFORMANCE, 0); |
| 255 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_ps_idx = idx; |
| 256 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_ps_idx = idx; |
| 257 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_off_cm_idx = 0; |
| 258 | rdev->pm.profiles[PM_PROFILE_HIGH_SH_IDX].dpms_on_cm_idx = |
| 259 | rdev->pm.power_state[idx].num_clock_modes - 1; |
| 260 | |
| 261 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_ps_idx = idx; |
| 262 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_ps_idx = idx; |
| 263 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_off_cm_idx = 0; |
| 264 | rdev->pm.profiles[PM_PROFILE_HIGH_MH_IDX].dpms_on_cm_idx = |
| 265 | rdev->pm.power_state[idx].num_clock_modes - 1; |
| 266 | } |
| 267 | |
Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 268 | void evergreen_pm_misc(struct radeon_device *rdev) |
| 269 | { |
Rafał Miłecki | a081a9d | 2010-06-07 18:20:25 -0400 | [diff] [blame] | 270 | int req_ps_idx = rdev->pm.requested_power_state_index; |
| 271 | int req_cm_idx = rdev->pm.requested_clock_mode_index; |
| 272 | struct radeon_power_state *ps = &rdev->pm.power_state[req_ps_idx]; |
| 273 | struct radeon_voltage *voltage = &ps->clock_info[req_cm_idx].voltage; |
Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 274 | |
Alex Deucher | 2feea49 | 2011-04-12 14:49:24 -0400 | [diff] [blame] | 275 | if (voltage->type == VOLTAGE_SW) { |
Alex Deucher | a377e18 | 2011-06-20 13:00:31 -0400 | [diff] [blame] | 276 | /* 0xff01 is a flag rather then an actual voltage */ |
| 277 | if (voltage->voltage == 0xff01) |
| 278 | return; |
Alex Deucher | 2feea49 | 2011-04-12 14:49:24 -0400 | [diff] [blame] | 279 | if (voltage->voltage && (voltage->voltage != rdev->pm.current_vddc)) { |
Alex Deucher | 8a83ec5 | 2011-04-12 14:49:23 -0400 | [diff] [blame] | 280 | radeon_atom_set_voltage(rdev, voltage->voltage, SET_VOLTAGE_TYPE_ASIC_VDDC); |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 281 | rdev->pm.current_vddc = voltage->voltage; |
Alex Deucher | 2feea49 | 2011-04-12 14:49:24 -0400 | [diff] [blame] | 282 | DRM_DEBUG("Setting: vddc: %d\n", voltage->voltage); |
| 283 | } |
Alex Deucher | a377e18 | 2011-06-20 13:00:31 -0400 | [diff] [blame] | 284 | /* 0xff01 is a flag rather then an actual voltage */ |
| 285 | if (voltage->vddci == 0xff01) |
| 286 | return; |
Alex Deucher | 2feea49 | 2011-04-12 14:49:24 -0400 | [diff] [blame] | 287 | if (voltage->vddci && (voltage->vddci != rdev->pm.current_vddci)) { |
| 288 | radeon_atom_set_voltage(rdev, voltage->vddci, SET_VOLTAGE_TYPE_ASIC_VDDCI); |
| 289 | rdev->pm.current_vddci = voltage->vddci; |
| 290 | DRM_DEBUG("Setting: vddci: %d\n", voltage->vddci); |
Alex Deucher | 4d60173 | 2010-06-07 18:15:18 -0400 | [diff] [blame] | 291 | } |
| 292 | } |
Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | void evergreen_pm_prepare(struct radeon_device *rdev) |
| 296 | { |
| 297 | struct drm_device *ddev = rdev->ddev; |
| 298 | struct drm_crtc *crtc; |
| 299 | struct radeon_crtc *radeon_crtc; |
| 300 | u32 tmp; |
| 301 | |
| 302 | /* disable any active CRTCs */ |
| 303 | list_for_each_entry(crtc, &ddev->mode_config.crtc_list, head) { |
| 304 | radeon_crtc = to_radeon_crtc(crtc); |
| 305 | if (radeon_crtc->enabled) { |
| 306 | tmp = RREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset); |
| 307 | tmp |= EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE; |
| 308 | WREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | void evergreen_pm_finish(struct radeon_device *rdev) |
| 314 | { |
| 315 | struct drm_device *ddev = rdev->ddev; |
| 316 | struct drm_crtc *crtc; |
| 317 | struct radeon_crtc *radeon_crtc; |
| 318 | u32 tmp; |
| 319 | |
| 320 | /* enable any active CRTCs */ |
| 321 | list_for_each_entry(crtc, &ddev->mode_config.crtc_list, head) { |
| 322 | radeon_crtc = to_radeon_crtc(crtc); |
| 323 | if (radeon_crtc->enabled) { |
| 324 | tmp = RREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset); |
| 325 | tmp &= ~EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE; |
| 326 | WREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 331 | bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) |
| 332 | { |
| 333 | bool connected = false; |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 334 | |
| 335 | switch (hpd) { |
| 336 | case RADEON_HPD_1: |
| 337 | if (RREG32(DC_HPD1_INT_STATUS) & DC_HPDx_SENSE) |
| 338 | connected = true; |
| 339 | break; |
| 340 | case RADEON_HPD_2: |
| 341 | if (RREG32(DC_HPD2_INT_STATUS) & DC_HPDx_SENSE) |
| 342 | connected = true; |
| 343 | break; |
| 344 | case RADEON_HPD_3: |
| 345 | if (RREG32(DC_HPD3_INT_STATUS) & DC_HPDx_SENSE) |
| 346 | connected = true; |
| 347 | break; |
| 348 | case RADEON_HPD_4: |
| 349 | if (RREG32(DC_HPD4_INT_STATUS) & DC_HPDx_SENSE) |
| 350 | connected = true; |
| 351 | break; |
| 352 | case RADEON_HPD_5: |
| 353 | if (RREG32(DC_HPD5_INT_STATUS) & DC_HPDx_SENSE) |
| 354 | connected = true; |
| 355 | break; |
| 356 | case RADEON_HPD_6: |
| 357 | if (RREG32(DC_HPD6_INT_STATUS) & DC_HPDx_SENSE) |
| 358 | connected = true; |
| 359 | break; |
| 360 | default: |
| 361 | break; |
| 362 | } |
| 363 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 364 | return connected; |
| 365 | } |
| 366 | |
| 367 | void evergreen_hpd_set_polarity(struct radeon_device *rdev, |
| 368 | enum radeon_hpd_id hpd) |
| 369 | { |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 370 | u32 tmp; |
| 371 | bool connected = evergreen_hpd_sense(rdev, hpd); |
| 372 | |
| 373 | switch (hpd) { |
| 374 | case RADEON_HPD_1: |
| 375 | tmp = RREG32(DC_HPD1_INT_CONTROL); |
| 376 | if (connected) |
| 377 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 378 | else |
| 379 | tmp |= DC_HPDx_INT_POLARITY; |
| 380 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 381 | break; |
| 382 | case RADEON_HPD_2: |
| 383 | tmp = RREG32(DC_HPD2_INT_CONTROL); |
| 384 | if (connected) |
| 385 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 386 | else |
| 387 | tmp |= DC_HPDx_INT_POLARITY; |
| 388 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 389 | break; |
| 390 | case RADEON_HPD_3: |
| 391 | tmp = RREG32(DC_HPD3_INT_CONTROL); |
| 392 | if (connected) |
| 393 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 394 | else |
| 395 | tmp |= DC_HPDx_INT_POLARITY; |
| 396 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 397 | break; |
| 398 | case RADEON_HPD_4: |
| 399 | tmp = RREG32(DC_HPD4_INT_CONTROL); |
| 400 | if (connected) |
| 401 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 402 | else |
| 403 | tmp |= DC_HPDx_INT_POLARITY; |
| 404 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 405 | break; |
| 406 | case RADEON_HPD_5: |
| 407 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 408 | if (connected) |
| 409 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 410 | else |
| 411 | tmp |= DC_HPDx_INT_POLARITY; |
| 412 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 413 | break; |
| 414 | case RADEON_HPD_6: |
| 415 | tmp = RREG32(DC_HPD6_INT_CONTROL); |
| 416 | if (connected) |
| 417 | tmp &= ~DC_HPDx_INT_POLARITY; |
| 418 | else |
| 419 | tmp |= DC_HPDx_INT_POLARITY; |
| 420 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 421 | break; |
| 422 | default: |
| 423 | break; |
| 424 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | void evergreen_hpd_init(struct radeon_device *rdev) |
| 428 | { |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 429 | struct drm_device *dev = rdev->ddev; |
| 430 | struct drm_connector *connector; |
| 431 | u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | |
| 432 | DC_HPDx_RX_INT_TIMER(0xfa) | DC_HPDx_EN; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 433 | |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 434 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 435 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 436 | switch (radeon_connector->hpd.hpd) { |
| 437 | case RADEON_HPD_1: |
| 438 | WREG32(DC_HPD1_CONTROL, tmp); |
| 439 | rdev->irq.hpd[0] = true; |
| 440 | break; |
| 441 | case RADEON_HPD_2: |
| 442 | WREG32(DC_HPD2_CONTROL, tmp); |
| 443 | rdev->irq.hpd[1] = true; |
| 444 | break; |
| 445 | case RADEON_HPD_3: |
| 446 | WREG32(DC_HPD3_CONTROL, tmp); |
| 447 | rdev->irq.hpd[2] = true; |
| 448 | break; |
| 449 | case RADEON_HPD_4: |
| 450 | WREG32(DC_HPD4_CONTROL, tmp); |
| 451 | rdev->irq.hpd[3] = true; |
| 452 | break; |
| 453 | case RADEON_HPD_5: |
| 454 | WREG32(DC_HPD5_CONTROL, tmp); |
| 455 | rdev->irq.hpd[4] = true; |
| 456 | break; |
| 457 | case RADEON_HPD_6: |
| 458 | WREG32(DC_HPD6_CONTROL, tmp); |
| 459 | rdev->irq.hpd[5] = true; |
| 460 | break; |
| 461 | default: |
| 462 | break; |
| 463 | } |
Alex Deucher | 64912e9 | 2011-11-03 11:21:39 -0400 | [diff] [blame] | 464 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 465 | } |
| 466 | if (rdev->irq.installed) |
| 467 | evergreen_irq_set(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | void evergreen_hpd_fini(struct radeon_device *rdev) |
| 471 | { |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 472 | struct drm_device *dev = rdev->ddev; |
| 473 | struct drm_connector *connector; |
| 474 | |
| 475 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 476 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
| 477 | switch (radeon_connector->hpd.hpd) { |
| 478 | case RADEON_HPD_1: |
| 479 | WREG32(DC_HPD1_CONTROL, 0); |
| 480 | rdev->irq.hpd[0] = false; |
| 481 | break; |
| 482 | case RADEON_HPD_2: |
| 483 | WREG32(DC_HPD2_CONTROL, 0); |
| 484 | rdev->irq.hpd[1] = false; |
| 485 | break; |
| 486 | case RADEON_HPD_3: |
| 487 | WREG32(DC_HPD3_CONTROL, 0); |
| 488 | rdev->irq.hpd[2] = false; |
| 489 | break; |
| 490 | case RADEON_HPD_4: |
| 491 | WREG32(DC_HPD4_CONTROL, 0); |
| 492 | rdev->irq.hpd[3] = false; |
| 493 | break; |
| 494 | case RADEON_HPD_5: |
| 495 | WREG32(DC_HPD5_CONTROL, 0); |
| 496 | rdev->irq.hpd[4] = false; |
| 497 | break; |
| 498 | case RADEON_HPD_6: |
| 499 | WREG32(DC_HPD6_CONTROL, 0); |
| 500 | rdev->irq.hpd[5] = false; |
| 501 | break; |
| 502 | default: |
| 503 | break; |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 508 | /* watermark setup */ |
| 509 | |
| 510 | static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev, |
| 511 | struct radeon_crtc *radeon_crtc, |
| 512 | struct drm_display_mode *mode, |
| 513 | struct drm_display_mode *other_mode) |
| 514 | { |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 515 | u32 tmp; |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 516 | /* |
| 517 | * Line Buffer Setup |
| 518 | * There are 3 line buffers, each one shared by 2 display controllers. |
| 519 | * DC_LB_MEMORY_SPLIT controls how that line buffer is shared between |
| 520 | * the display controllers. The paritioning is done via one of four |
| 521 | * preset allocations specified in bits 2:0: |
| 522 | * first display controller |
| 523 | * 0 - first half of lb (3840 * 2) |
| 524 | * 1 - first 3/4 of lb (5760 * 2) |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 525 | * 2 - whole lb (7680 * 2), other crtc must be disabled |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 526 | * 3 - first 1/4 of lb (1920 * 2) |
| 527 | * second display controller |
| 528 | * 4 - second half of lb (3840 * 2) |
| 529 | * 5 - second 3/4 of lb (5760 * 2) |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 530 | * 6 - whole lb (7680 * 2), other crtc must be disabled |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 531 | * 7 - last 1/4 of lb (1920 * 2) |
| 532 | */ |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 533 | /* this can get tricky if we have two large displays on a paired group |
| 534 | * of crtcs. Ideally for multiple large displays we'd assign them to |
| 535 | * non-linked crtcs for maximum line buffer allocation. |
| 536 | */ |
| 537 | if (radeon_crtc->base.enabled && mode) { |
| 538 | if (other_mode) |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 539 | tmp = 0; /* 1/2 */ |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 540 | else |
| 541 | tmp = 2; /* whole */ |
| 542 | } else |
| 543 | tmp = 0; |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 544 | |
| 545 | /* second controller of the pair uses second half of the lb */ |
| 546 | if (radeon_crtc->crtc_id % 2) |
| 547 | tmp += 4; |
| 548 | WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset, tmp); |
| 549 | |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 550 | if (radeon_crtc->base.enabled && mode) { |
| 551 | switch (tmp) { |
| 552 | case 0: |
| 553 | case 4: |
| 554 | default: |
| 555 | if (ASIC_IS_DCE5(rdev)) |
| 556 | return 4096 * 2; |
| 557 | else |
| 558 | return 3840 * 2; |
| 559 | case 1: |
| 560 | case 5: |
| 561 | if (ASIC_IS_DCE5(rdev)) |
| 562 | return 6144 * 2; |
| 563 | else |
| 564 | return 5760 * 2; |
| 565 | case 2: |
| 566 | case 6: |
| 567 | if (ASIC_IS_DCE5(rdev)) |
| 568 | return 8192 * 2; |
| 569 | else |
| 570 | return 7680 * 2; |
| 571 | case 3: |
| 572 | case 7: |
| 573 | if (ASIC_IS_DCE5(rdev)) |
| 574 | return 2048 * 2; |
| 575 | else |
| 576 | return 1920 * 2; |
| 577 | } |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 578 | } |
Alex Deucher | 12dfc84 | 2011-04-14 19:07:34 -0400 | [diff] [blame] | 579 | |
| 580 | /* controller not enabled, so no lb used */ |
| 581 | return 0; |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 582 | } |
| 583 | |
Alex Deucher | ca7db22 | 2012-03-20 17:18:30 -0400 | [diff] [blame] | 584 | u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev) |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 585 | { |
| 586 | u32 tmp = RREG32(MC_SHARED_CHMAP); |
| 587 | |
| 588 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 589 | case 0: |
| 590 | default: |
| 591 | return 1; |
| 592 | case 1: |
| 593 | return 2; |
| 594 | case 2: |
| 595 | return 4; |
| 596 | case 3: |
| 597 | return 8; |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | struct evergreen_wm_params { |
| 602 | u32 dram_channels; /* number of dram channels */ |
| 603 | u32 yclk; /* bandwidth per dram data pin in kHz */ |
| 604 | u32 sclk; /* engine clock in kHz */ |
| 605 | u32 disp_clk; /* display clock in kHz */ |
| 606 | u32 src_width; /* viewport width */ |
| 607 | u32 active_time; /* active display time in ns */ |
| 608 | u32 blank_time; /* blank time in ns */ |
| 609 | bool interlaced; /* mode is interlaced */ |
| 610 | fixed20_12 vsc; /* vertical scale ratio */ |
| 611 | u32 num_heads; /* number of active crtcs */ |
| 612 | u32 bytes_per_pixel; /* bytes per pixel display + overlay */ |
| 613 | u32 lb_size; /* line buffer allocated to pipe */ |
| 614 | u32 vtaps; /* vertical scaler taps */ |
| 615 | }; |
| 616 | |
| 617 | static u32 evergreen_dram_bandwidth(struct evergreen_wm_params *wm) |
| 618 | { |
| 619 | /* Calculate DRAM Bandwidth and the part allocated to display. */ |
| 620 | fixed20_12 dram_efficiency; /* 0.7 */ |
| 621 | fixed20_12 yclk, dram_channels, bandwidth; |
| 622 | fixed20_12 a; |
| 623 | |
| 624 | a.full = dfixed_const(1000); |
| 625 | yclk.full = dfixed_const(wm->yclk); |
| 626 | yclk.full = dfixed_div(yclk, a); |
| 627 | dram_channels.full = dfixed_const(wm->dram_channels * 4); |
| 628 | a.full = dfixed_const(10); |
| 629 | dram_efficiency.full = dfixed_const(7); |
| 630 | dram_efficiency.full = dfixed_div(dram_efficiency, a); |
| 631 | bandwidth.full = dfixed_mul(dram_channels, yclk); |
| 632 | bandwidth.full = dfixed_mul(bandwidth, dram_efficiency); |
| 633 | |
| 634 | return dfixed_trunc(bandwidth); |
| 635 | } |
| 636 | |
| 637 | static u32 evergreen_dram_bandwidth_for_display(struct evergreen_wm_params *wm) |
| 638 | { |
| 639 | /* Calculate DRAM Bandwidth and the part allocated to display. */ |
| 640 | fixed20_12 disp_dram_allocation; /* 0.3 to 0.7 */ |
| 641 | fixed20_12 yclk, dram_channels, bandwidth; |
| 642 | fixed20_12 a; |
| 643 | |
| 644 | a.full = dfixed_const(1000); |
| 645 | yclk.full = dfixed_const(wm->yclk); |
| 646 | yclk.full = dfixed_div(yclk, a); |
| 647 | dram_channels.full = dfixed_const(wm->dram_channels * 4); |
| 648 | a.full = dfixed_const(10); |
| 649 | disp_dram_allocation.full = dfixed_const(3); /* XXX worse case value 0.3 */ |
| 650 | disp_dram_allocation.full = dfixed_div(disp_dram_allocation, a); |
| 651 | bandwidth.full = dfixed_mul(dram_channels, yclk); |
| 652 | bandwidth.full = dfixed_mul(bandwidth, disp_dram_allocation); |
| 653 | |
| 654 | return dfixed_trunc(bandwidth); |
| 655 | } |
| 656 | |
| 657 | static u32 evergreen_data_return_bandwidth(struct evergreen_wm_params *wm) |
| 658 | { |
| 659 | /* Calculate the display Data return Bandwidth */ |
| 660 | fixed20_12 return_efficiency; /* 0.8 */ |
| 661 | fixed20_12 sclk, bandwidth; |
| 662 | fixed20_12 a; |
| 663 | |
| 664 | a.full = dfixed_const(1000); |
| 665 | sclk.full = dfixed_const(wm->sclk); |
| 666 | sclk.full = dfixed_div(sclk, a); |
| 667 | a.full = dfixed_const(10); |
| 668 | return_efficiency.full = dfixed_const(8); |
| 669 | return_efficiency.full = dfixed_div(return_efficiency, a); |
| 670 | a.full = dfixed_const(32); |
| 671 | bandwidth.full = dfixed_mul(a, sclk); |
| 672 | bandwidth.full = dfixed_mul(bandwidth, return_efficiency); |
| 673 | |
| 674 | return dfixed_trunc(bandwidth); |
| 675 | } |
| 676 | |
| 677 | static u32 evergreen_dmif_request_bandwidth(struct evergreen_wm_params *wm) |
| 678 | { |
| 679 | /* Calculate the DMIF Request Bandwidth */ |
| 680 | fixed20_12 disp_clk_request_efficiency; /* 0.8 */ |
| 681 | fixed20_12 disp_clk, bandwidth; |
| 682 | fixed20_12 a; |
| 683 | |
| 684 | a.full = dfixed_const(1000); |
| 685 | disp_clk.full = dfixed_const(wm->disp_clk); |
| 686 | disp_clk.full = dfixed_div(disp_clk, a); |
| 687 | a.full = dfixed_const(10); |
| 688 | disp_clk_request_efficiency.full = dfixed_const(8); |
| 689 | disp_clk_request_efficiency.full = dfixed_div(disp_clk_request_efficiency, a); |
| 690 | a.full = dfixed_const(32); |
| 691 | bandwidth.full = dfixed_mul(a, disp_clk); |
| 692 | bandwidth.full = dfixed_mul(bandwidth, disp_clk_request_efficiency); |
| 693 | |
| 694 | return dfixed_trunc(bandwidth); |
| 695 | } |
| 696 | |
| 697 | static u32 evergreen_available_bandwidth(struct evergreen_wm_params *wm) |
| 698 | { |
| 699 | /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */ |
| 700 | u32 dram_bandwidth = evergreen_dram_bandwidth(wm); |
| 701 | u32 data_return_bandwidth = evergreen_data_return_bandwidth(wm); |
| 702 | u32 dmif_req_bandwidth = evergreen_dmif_request_bandwidth(wm); |
| 703 | |
| 704 | return min(dram_bandwidth, min(data_return_bandwidth, dmif_req_bandwidth)); |
| 705 | } |
| 706 | |
| 707 | static u32 evergreen_average_bandwidth(struct evergreen_wm_params *wm) |
| 708 | { |
| 709 | /* Calculate the display mode Average Bandwidth |
| 710 | * DisplayMode should contain the source and destination dimensions, |
| 711 | * timing, etc. |
| 712 | */ |
| 713 | fixed20_12 bpp; |
| 714 | fixed20_12 line_time; |
| 715 | fixed20_12 src_width; |
| 716 | fixed20_12 bandwidth; |
| 717 | fixed20_12 a; |
| 718 | |
| 719 | a.full = dfixed_const(1000); |
| 720 | line_time.full = dfixed_const(wm->active_time + wm->blank_time); |
| 721 | line_time.full = dfixed_div(line_time, a); |
| 722 | bpp.full = dfixed_const(wm->bytes_per_pixel); |
| 723 | src_width.full = dfixed_const(wm->src_width); |
| 724 | bandwidth.full = dfixed_mul(src_width, bpp); |
| 725 | bandwidth.full = dfixed_mul(bandwidth, wm->vsc); |
| 726 | bandwidth.full = dfixed_div(bandwidth, line_time); |
| 727 | |
| 728 | return dfixed_trunc(bandwidth); |
| 729 | } |
| 730 | |
| 731 | static u32 evergreen_latency_watermark(struct evergreen_wm_params *wm) |
| 732 | { |
| 733 | /* First calcualte the latency in ns */ |
| 734 | u32 mc_latency = 2000; /* 2000 ns. */ |
| 735 | u32 available_bandwidth = evergreen_available_bandwidth(wm); |
| 736 | u32 worst_chunk_return_time = (512 * 8 * 1000) / available_bandwidth; |
| 737 | u32 cursor_line_pair_return_time = (128 * 4 * 1000) / available_bandwidth; |
| 738 | u32 dc_latency = 40000000 / wm->disp_clk; /* dc pipe latency */ |
| 739 | u32 other_heads_data_return_time = ((wm->num_heads + 1) * worst_chunk_return_time) + |
| 740 | (wm->num_heads * cursor_line_pair_return_time); |
| 741 | u32 latency = mc_latency + other_heads_data_return_time + dc_latency; |
| 742 | u32 max_src_lines_per_dst_line, lb_fill_bw, line_fill_time; |
| 743 | fixed20_12 a, b, c; |
| 744 | |
| 745 | if (wm->num_heads == 0) |
| 746 | return 0; |
| 747 | |
| 748 | a.full = dfixed_const(2); |
| 749 | b.full = dfixed_const(1); |
| 750 | if ((wm->vsc.full > a.full) || |
| 751 | ((wm->vsc.full > b.full) && (wm->vtaps >= 3)) || |
| 752 | (wm->vtaps >= 5) || |
| 753 | ((wm->vsc.full >= a.full) && wm->interlaced)) |
| 754 | max_src_lines_per_dst_line = 4; |
| 755 | else |
| 756 | max_src_lines_per_dst_line = 2; |
| 757 | |
| 758 | a.full = dfixed_const(available_bandwidth); |
| 759 | b.full = dfixed_const(wm->num_heads); |
| 760 | a.full = dfixed_div(a, b); |
| 761 | |
| 762 | b.full = dfixed_const(1000); |
| 763 | c.full = dfixed_const(wm->disp_clk); |
| 764 | b.full = dfixed_div(c, b); |
| 765 | c.full = dfixed_const(wm->bytes_per_pixel); |
| 766 | b.full = dfixed_mul(b, c); |
| 767 | |
| 768 | lb_fill_bw = min(dfixed_trunc(a), dfixed_trunc(b)); |
| 769 | |
| 770 | a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); |
| 771 | b.full = dfixed_const(1000); |
| 772 | c.full = dfixed_const(lb_fill_bw); |
| 773 | b.full = dfixed_div(c, b); |
| 774 | a.full = dfixed_div(a, b); |
| 775 | line_fill_time = dfixed_trunc(a); |
| 776 | |
| 777 | if (line_fill_time < wm->active_time) |
| 778 | return latency; |
| 779 | else |
| 780 | return latency + (line_fill_time - wm->active_time); |
| 781 | |
| 782 | } |
| 783 | |
| 784 | static bool evergreen_average_bandwidth_vs_dram_bandwidth_for_display(struct evergreen_wm_params *wm) |
| 785 | { |
| 786 | if (evergreen_average_bandwidth(wm) <= |
| 787 | (evergreen_dram_bandwidth_for_display(wm) / wm->num_heads)) |
| 788 | return true; |
| 789 | else |
| 790 | return false; |
| 791 | }; |
| 792 | |
| 793 | static bool evergreen_average_bandwidth_vs_available_bandwidth(struct evergreen_wm_params *wm) |
| 794 | { |
| 795 | if (evergreen_average_bandwidth(wm) <= |
| 796 | (evergreen_available_bandwidth(wm) / wm->num_heads)) |
| 797 | return true; |
| 798 | else |
| 799 | return false; |
| 800 | }; |
| 801 | |
| 802 | static bool evergreen_check_latency_hiding(struct evergreen_wm_params *wm) |
| 803 | { |
| 804 | u32 lb_partitions = wm->lb_size / wm->src_width; |
| 805 | u32 line_time = wm->active_time + wm->blank_time; |
| 806 | u32 latency_tolerant_lines; |
| 807 | u32 latency_hiding; |
| 808 | fixed20_12 a; |
| 809 | |
| 810 | a.full = dfixed_const(1); |
| 811 | if (wm->vsc.full > a.full) |
| 812 | latency_tolerant_lines = 1; |
| 813 | else { |
| 814 | if (lb_partitions <= (wm->vtaps + 1)) |
| 815 | latency_tolerant_lines = 1; |
| 816 | else |
| 817 | latency_tolerant_lines = 2; |
| 818 | } |
| 819 | |
| 820 | latency_hiding = (latency_tolerant_lines * line_time + wm->blank_time); |
| 821 | |
| 822 | if (evergreen_latency_watermark(wm) <= latency_hiding) |
| 823 | return true; |
| 824 | else |
| 825 | return false; |
| 826 | } |
| 827 | |
| 828 | static void evergreen_program_watermarks(struct radeon_device *rdev, |
| 829 | struct radeon_crtc *radeon_crtc, |
| 830 | u32 lb_size, u32 num_heads) |
| 831 | { |
| 832 | struct drm_display_mode *mode = &radeon_crtc->base.mode; |
| 833 | struct evergreen_wm_params wm; |
| 834 | u32 pixel_period; |
| 835 | u32 line_time = 0; |
| 836 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
| 837 | u32 priority_a_mark = 0, priority_b_mark = 0; |
| 838 | u32 priority_a_cnt = PRIORITY_OFF; |
| 839 | u32 priority_b_cnt = PRIORITY_OFF; |
| 840 | u32 pipe_offset = radeon_crtc->crtc_id * 16; |
| 841 | u32 tmp, arb_control3; |
| 842 | fixed20_12 a, b, c; |
| 843 | |
| 844 | if (radeon_crtc->base.enabled && num_heads && mode) { |
| 845 | pixel_period = 1000000 / (u32)mode->clock; |
| 846 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); |
| 847 | priority_a_cnt = 0; |
| 848 | priority_b_cnt = 0; |
| 849 | |
| 850 | wm.yclk = rdev->pm.current_mclk * 10; |
| 851 | wm.sclk = rdev->pm.current_sclk * 10; |
| 852 | wm.disp_clk = mode->clock; |
| 853 | wm.src_width = mode->crtc_hdisplay; |
| 854 | wm.active_time = mode->crtc_hdisplay * pixel_period; |
| 855 | wm.blank_time = line_time - wm.active_time; |
| 856 | wm.interlaced = false; |
| 857 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 858 | wm.interlaced = true; |
| 859 | wm.vsc = radeon_crtc->vsc; |
| 860 | wm.vtaps = 1; |
| 861 | if (radeon_crtc->rmx_type != RMX_OFF) |
| 862 | wm.vtaps = 2; |
| 863 | wm.bytes_per_pixel = 4; /* XXX: get this from fb config */ |
| 864 | wm.lb_size = lb_size; |
| 865 | wm.dram_channels = evergreen_get_number_of_dram_channels(rdev); |
| 866 | wm.num_heads = num_heads; |
| 867 | |
| 868 | /* set for high clocks */ |
| 869 | latency_watermark_a = min(evergreen_latency_watermark(&wm), (u32)65535); |
| 870 | /* set for low clocks */ |
| 871 | /* wm.yclk = low clk; wm.sclk = low clk */ |
| 872 | latency_watermark_b = min(evergreen_latency_watermark(&wm), (u32)65535); |
| 873 | |
| 874 | /* possibly force display priority to high */ |
| 875 | /* should really do this at mode validation time... */ |
| 876 | if (!evergreen_average_bandwidth_vs_dram_bandwidth_for_display(&wm) || |
| 877 | !evergreen_average_bandwidth_vs_available_bandwidth(&wm) || |
| 878 | !evergreen_check_latency_hiding(&wm) || |
| 879 | (rdev->disp_priority == 2)) { |
Alex Deucher | 92bdfd4 | 2011-08-04 17:28:40 +0000 | [diff] [blame] | 880 | DRM_DEBUG_KMS("force priority to high\n"); |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 881 | priority_a_cnt |= PRIORITY_ALWAYS_ON; |
| 882 | priority_b_cnt |= PRIORITY_ALWAYS_ON; |
| 883 | } |
| 884 | |
| 885 | a.full = dfixed_const(1000); |
| 886 | b.full = dfixed_const(mode->clock); |
| 887 | b.full = dfixed_div(b, a); |
| 888 | c.full = dfixed_const(latency_watermark_a); |
| 889 | c.full = dfixed_mul(c, b); |
| 890 | c.full = dfixed_mul(c, radeon_crtc->hsc); |
| 891 | c.full = dfixed_div(c, a); |
| 892 | a.full = dfixed_const(16); |
| 893 | c.full = dfixed_div(c, a); |
| 894 | priority_a_mark = dfixed_trunc(c); |
| 895 | priority_a_cnt |= priority_a_mark & PRIORITY_MARK_MASK; |
| 896 | |
| 897 | a.full = dfixed_const(1000); |
| 898 | b.full = dfixed_const(mode->clock); |
| 899 | b.full = dfixed_div(b, a); |
| 900 | c.full = dfixed_const(latency_watermark_b); |
| 901 | c.full = dfixed_mul(c, b); |
| 902 | c.full = dfixed_mul(c, radeon_crtc->hsc); |
| 903 | c.full = dfixed_div(c, a); |
| 904 | a.full = dfixed_const(16); |
| 905 | c.full = dfixed_div(c, a); |
| 906 | priority_b_mark = dfixed_trunc(c); |
| 907 | priority_b_cnt |= priority_b_mark & PRIORITY_MARK_MASK; |
| 908 | } |
| 909 | |
| 910 | /* select wm A */ |
| 911 | arb_control3 = RREG32(PIPE0_ARBITRATION_CONTROL3 + pipe_offset); |
| 912 | tmp = arb_control3; |
| 913 | tmp &= ~LATENCY_WATERMARK_MASK(3); |
| 914 | tmp |= LATENCY_WATERMARK_MASK(1); |
| 915 | WREG32(PIPE0_ARBITRATION_CONTROL3 + pipe_offset, tmp); |
| 916 | WREG32(PIPE0_LATENCY_CONTROL + pipe_offset, |
| 917 | (LATENCY_LOW_WATERMARK(latency_watermark_a) | |
| 918 | LATENCY_HIGH_WATERMARK(line_time))); |
| 919 | /* select wm B */ |
| 920 | tmp = RREG32(PIPE0_ARBITRATION_CONTROL3 + pipe_offset); |
| 921 | tmp &= ~LATENCY_WATERMARK_MASK(3); |
| 922 | tmp |= LATENCY_WATERMARK_MASK(2); |
| 923 | WREG32(PIPE0_ARBITRATION_CONTROL3 + pipe_offset, tmp); |
| 924 | WREG32(PIPE0_LATENCY_CONTROL + pipe_offset, |
| 925 | (LATENCY_LOW_WATERMARK(latency_watermark_b) | |
| 926 | LATENCY_HIGH_WATERMARK(line_time))); |
| 927 | /* restore original selection */ |
| 928 | WREG32(PIPE0_ARBITRATION_CONTROL3 + pipe_offset, arb_control3); |
| 929 | |
| 930 | /* write the priority marks */ |
| 931 | WREG32(PRIORITY_A_CNT + radeon_crtc->crtc_offset, priority_a_cnt); |
| 932 | WREG32(PRIORITY_B_CNT + radeon_crtc->crtc_offset, priority_b_cnt); |
| 933 | |
| 934 | } |
| 935 | |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 936 | void evergreen_bandwidth_update(struct radeon_device *rdev) |
| 937 | { |
Alex Deucher | f9d9c36 | 2010-10-22 02:51:05 -0400 | [diff] [blame] | 938 | struct drm_display_mode *mode0 = NULL; |
| 939 | struct drm_display_mode *mode1 = NULL; |
| 940 | u32 num_heads = 0, lb_size; |
| 941 | int i; |
| 942 | |
| 943 | radeon_update_display_priority(rdev); |
| 944 | |
| 945 | for (i = 0; i < rdev->num_crtc; i++) { |
| 946 | if (rdev->mode_info.crtcs[i]->base.enabled) |
| 947 | num_heads++; |
| 948 | } |
| 949 | for (i = 0; i < rdev->num_crtc; i += 2) { |
| 950 | mode0 = &rdev->mode_info.crtcs[i]->base.mode; |
| 951 | mode1 = &rdev->mode_info.crtcs[i+1]->base.mode; |
| 952 | lb_size = evergreen_line_buffer_adjust(rdev, rdev->mode_info.crtcs[i], mode0, mode1); |
| 953 | evergreen_program_watermarks(rdev, rdev->mode_info.crtcs[i], lb_size, num_heads); |
| 954 | lb_size = evergreen_line_buffer_adjust(rdev, rdev->mode_info.crtcs[i+1], mode1, mode0); |
| 955 | evergreen_program_watermarks(rdev, rdev->mode_info.crtcs[i+1], lb_size, num_heads); |
| 956 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 957 | } |
| 958 | |
Alex Deucher | b9952a8 | 2011-03-02 20:07:33 -0500 | [diff] [blame] | 959 | int evergreen_mc_wait_for_idle(struct radeon_device *rdev) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 960 | { |
| 961 | unsigned i; |
| 962 | u32 tmp; |
| 963 | |
| 964 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 965 | /* read MC_STATUS */ |
| 966 | tmp = RREG32(SRBM_STATUS) & 0x1F00; |
| 967 | if (!tmp) |
| 968 | return 0; |
| 969 | udelay(1); |
| 970 | } |
| 971 | return -1; |
| 972 | } |
| 973 | |
| 974 | /* |
| 975 | * GART |
| 976 | */ |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 977 | void evergreen_pcie_gart_tlb_flush(struct radeon_device *rdev) |
| 978 | { |
| 979 | unsigned i; |
| 980 | u32 tmp; |
| 981 | |
Alex Deucher | 6f2f48a | 2010-12-15 11:01:56 -0500 | [diff] [blame] | 982 | WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1); |
| 983 | |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 984 | WREG32(VM_CONTEXT0_REQUEST_RESPONSE, REQUEST_TYPE(1)); |
| 985 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 986 | /* read MC_STATUS */ |
| 987 | tmp = RREG32(VM_CONTEXT0_REQUEST_RESPONSE); |
| 988 | tmp = (tmp & RESPONSE_TYPE_MASK) >> RESPONSE_TYPE_SHIFT; |
| 989 | if (tmp == 2) { |
| 990 | printk(KERN_WARNING "[drm] r600 flush TLB failed\n"); |
| 991 | return; |
| 992 | } |
| 993 | if (tmp) { |
| 994 | return; |
| 995 | } |
| 996 | udelay(1); |
| 997 | } |
| 998 | } |
| 999 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1000 | int evergreen_pcie_gart_enable(struct radeon_device *rdev) |
| 1001 | { |
| 1002 | u32 tmp; |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 1003 | int r; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1004 | |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 1005 | if (rdev->gart.robj == NULL) { |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1006 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); |
| 1007 | return -EINVAL; |
| 1008 | } |
| 1009 | r = radeon_gart_table_vram_pin(rdev); |
| 1010 | if (r) |
| 1011 | return r; |
Dave Airlie | 8256856 | 2010-02-05 16:00:07 +1000 | [diff] [blame] | 1012 | radeon_gart_restore(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1013 | /* Setup L2 cache */ |
| 1014 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | |
| 1015 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 1016 | EFFECTIVE_L2_QUEUE_SIZE(7)); |
| 1017 | WREG32(VM_L2_CNTL2, 0); |
| 1018 | WREG32(VM_L2_CNTL3, BANK_SELECT(0) | CACHE_UPDATE_MODE(2)); |
| 1019 | /* Setup TLB control */ |
| 1020 | tmp = ENABLE_L1_TLB | ENABLE_L1_FRAGMENT_PROCESSING | |
| 1021 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 1022 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | |
| 1023 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); |
Alex Deucher | 8aeb96f | 2011-05-03 19:28:02 -0400 | [diff] [blame] | 1024 | if (rdev->flags & RADEON_IS_IGP) { |
| 1025 | WREG32(FUS_MC_VM_MD_L1_TLB0_CNTL, tmp); |
| 1026 | WREG32(FUS_MC_VM_MD_L1_TLB1_CNTL, tmp); |
| 1027 | WREG32(FUS_MC_VM_MD_L1_TLB2_CNTL, tmp); |
| 1028 | } else { |
| 1029 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); |
| 1030 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); |
| 1031 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); |
| 1032 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1033 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); |
| 1034 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); |
| 1035 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); |
| 1036 | WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); |
| 1037 | WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, rdev->mc.gtt_start >> 12); |
| 1038 | WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, rdev->mc.gtt_end >> 12); |
| 1039 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, rdev->gart.table_addr >> 12); |
| 1040 | WREG32(VM_CONTEXT0_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) | |
| 1041 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT); |
| 1042 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
| 1043 | (u32)(rdev->dummy_page.addr >> 12)); |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 1044 | WREG32(VM_CONTEXT1_CNTL, 0); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1045 | |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 1046 | evergreen_pcie_gart_tlb_flush(rdev); |
Tormod Volden | fcf4de5 | 2011-08-31 21:54:07 +0000 | [diff] [blame] | 1047 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
| 1048 | (unsigned)(rdev->mc.gtt_size >> 20), |
| 1049 | (unsigned long long)rdev->gart.table_addr); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1050 | rdev->gart.ready = true; |
| 1051 | return 0; |
| 1052 | } |
| 1053 | |
| 1054 | void evergreen_pcie_gart_disable(struct radeon_device *rdev) |
| 1055 | { |
| 1056 | u32 tmp; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1057 | |
| 1058 | /* Disable all tables */ |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 1059 | WREG32(VM_CONTEXT0_CNTL, 0); |
| 1060 | WREG32(VM_CONTEXT1_CNTL, 0); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1061 | |
| 1062 | /* Setup L2 cache */ |
| 1063 | WREG32(VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING | |
| 1064 | EFFECTIVE_L2_QUEUE_SIZE(7)); |
| 1065 | WREG32(VM_L2_CNTL2, 0); |
| 1066 | WREG32(VM_L2_CNTL3, BANK_SELECT(0) | CACHE_UPDATE_MODE(2)); |
| 1067 | /* Setup TLB control */ |
| 1068 | tmp = EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); |
| 1069 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); |
| 1070 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); |
| 1071 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); |
| 1072 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); |
| 1073 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); |
| 1074 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); |
| 1075 | WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); |
Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 1076 | radeon_gart_table_vram_unpin(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1077 | } |
| 1078 | |
| 1079 | void evergreen_pcie_gart_fini(struct radeon_device *rdev) |
| 1080 | { |
| 1081 | evergreen_pcie_gart_disable(rdev); |
| 1082 | radeon_gart_table_vram_free(rdev); |
| 1083 | radeon_gart_fini(rdev); |
| 1084 | } |
| 1085 | |
| 1086 | |
| 1087 | void evergreen_agp_enable(struct radeon_device *rdev) |
| 1088 | { |
| 1089 | u32 tmp; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1090 | |
| 1091 | /* Setup L2 cache */ |
| 1092 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | |
| 1093 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 1094 | EFFECTIVE_L2_QUEUE_SIZE(7)); |
| 1095 | WREG32(VM_L2_CNTL2, 0); |
| 1096 | WREG32(VM_L2_CNTL3, BANK_SELECT(0) | CACHE_UPDATE_MODE(2)); |
| 1097 | /* Setup TLB control */ |
| 1098 | tmp = ENABLE_L1_TLB | ENABLE_L1_FRAGMENT_PROCESSING | |
| 1099 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 1100 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | |
| 1101 | EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); |
| 1102 | WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); |
| 1103 | WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); |
| 1104 | WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); |
| 1105 | WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); |
| 1106 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); |
| 1107 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); |
| 1108 | WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 1109 | WREG32(VM_CONTEXT0_CNTL, 0); |
| 1110 | WREG32(VM_CONTEXT1_CNTL, 0); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1111 | } |
| 1112 | |
Alex Deucher | b9952a8 | 2011-03-02 20:07:33 -0500 | [diff] [blame] | 1113 | void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1114 | { |
| 1115 | save->vga_control[0] = RREG32(D1VGA_CONTROL); |
| 1116 | save->vga_control[1] = RREG32(D2VGA_CONTROL); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1117 | save->vga_render_control = RREG32(VGA_RENDER_CONTROL); |
| 1118 | save->vga_hdp_control = RREG32(VGA_HDP_CONTROL); |
| 1119 | save->crtc_control[0] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET); |
| 1120 | save->crtc_control[1] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1121 | if (rdev->num_crtc >= 4) { |
| 1122 | save->vga_control[2] = RREG32(EVERGREEN_D3VGA_CONTROL); |
| 1123 | save->vga_control[3] = RREG32(EVERGREEN_D4VGA_CONTROL); |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1124 | save->crtc_control[2] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET); |
| 1125 | save->crtc_control[3] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1126 | } |
| 1127 | if (rdev->num_crtc >= 6) { |
| 1128 | save->vga_control[4] = RREG32(EVERGREEN_D5VGA_CONTROL); |
| 1129 | save->vga_control[5] = RREG32(EVERGREEN_D6VGA_CONTROL); |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1130 | save->crtc_control[4] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET); |
| 1131 | save->crtc_control[5] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET); |
| 1132 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1133 | |
| 1134 | /* Stop all video */ |
| 1135 | WREG32(VGA_RENDER_CONTROL, 0); |
| 1136 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 1); |
| 1137 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 1); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1138 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1139 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 1); |
| 1140 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 1); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1141 | } |
| 1142 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1143 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 1); |
| 1144 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 1); |
| 1145 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1146 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 1147 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1148 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1149 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 1150 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1151 | } |
| 1152 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1153 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 1154 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 1155 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1156 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 1157 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1158 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1159 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 1160 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1161 | } |
| 1162 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1163 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 1164 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 1165 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1166 | |
| 1167 | WREG32(D1VGA_CONTROL, 0); |
| 1168 | WREG32(D2VGA_CONTROL, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1169 | if (rdev->num_crtc >= 4) { |
| 1170 | WREG32(EVERGREEN_D3VGA_CONTROL, 0); |
| 1171 | WREG32(EVERGREEN_D4VGA_CONTROL, 0); |
| 1172 | } |
| 1173 | if (rdev->num_crtc >= 6) { |
| 1174 | WREG32(EVERGREEN_D5VGA_CONTROL, 0); |
| 1175 | WREG32(EVERGREEN_D6VGA_CONTROL, 0); |
| 1176 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1177 | } |
| 1178 | |
Alex Deucher | b9952a8 | 2011-03-02 20:07:33 -0500 | [diff] [blame] | 1179 | void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1180 | { |
| 1181 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC0_REGISTER_OFFSET, |
| 1182 | upper_32_bits(rdev->mc.vram_start)); |
| 1183 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC0_REGISTER_OFFSET, |
| 1184 | upper_32_bits(rdev->mc.vram_start)); |
| 1185 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + EVERGREEN_CRTC0_REGISTER_OFFSET, |
| 1186 | (u32)rdev->mc.vram_start); |
| 1187 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC0_REGISTER_OFFSET, |
| 1188 | (u32)rdev->mc.vram_start); |
| 1189 | |
| 1190 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC1_REGISTER_OFFSET, |
| 1191 | upper_32_bits(rdev->mc.vram_start)); |
| 1192 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC1_REGISTER_OFFSET, |
| 1193 | upper_32_bits(rdev->mc.vram_start)); |
| 1194 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + EVERGREEN_CRTC1_REGISTER_OFFSET, |
| 1195 | (u32)rdev->mc.vram_start); |
| 1196 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC1_REGISTER_OFFSET, |
| 1197 | (u32)rdev->mc.vram_start); |
| 1198 | |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1199 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1200 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC2_REGISTER_OFFSET, |
| 1201 | upper_32_bits(rdev->mc.vram_start)); |
| 1202 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC2_REGISTER_OFFSET, |
| 1203 | upper_32_bits(rdev->mc.vram_start)); |
| 1204 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + EVERGREEN_CRTC2_REGISTER_OFFSET, |
| 1205 | (u32)rdev->mc.vram_start); |
| 1206 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC2_REGISTER_OFFSET, |
| 1207 | (u32)rdev->mc.vram_start); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1208 | |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1209 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC3_REGISTER_OFFSET, |
| 1210 | upper_32_bits(rdev->mc.vram_start)); |
| 1211 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC3_REGISTER_OFFSET, |
| 1212 | upper_32_bits(rdev->mc.vram_start)); |
| 1213 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + EVERGREEN_CRTC3_REGISTER_OFFSET, |
| 1214 | (u32)rdev->mc.vram_start); |
| 1215 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC3_REGISTER_OFFSET, |
| 1216 | (u32)rdev->mc.vram_start); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1217 | } |
| 1218 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1219 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC4_REGISTER_OFFSET, |
| 1220 | upper_32_bits(rdev->mc.vram_start)); |
| 1221 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC4_REGISTER_OFFSET, |
| 1222 | upper_32_bits(rdev->mc.vram_start)); |
| 1223 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + EVERGREEN_CRTC4_REGISTER_OFFSET, |
| 1224 | (u32)rdev->mc.vram_start); |
| 1225 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC4_REGISTER_OFFSET, |
| 1226 | (u32)rdev->mc.vram_start); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1227 | |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1228 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC5_REGISTER_OFFSET, |
| 1229 | upper_32_bits(rdev->mc.vram_start)); |
| 1230 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC5_REGISTER_OFFSET, |
| 1231 | upper_32_bits(rdev->mc.vram_start)); |
| 1232 | WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS + EVERGREEN_CRTC5_REGISTER_OFFSET, |
| 1233 | (u32)rdev->mc.vram_start); |
| 1234 | WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC5_REGISTER_OFFSET, |
| 1235 | (u32)rdev->mc.vram_start); |
| 1236 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1237 | |
| 1238 | WREG32(EVERGREEN_VGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(rdev->mc.vram_start)); |
| 1239 | WREG32(EVERGREEN_VGA_MEMORY_BASE_ADDRESS, (u32)rdev->mc.vram_start); |
| 1240 | /* Unlock host access */ |
| 1241 | WREG32(VGA_HDP_CONTROL, save->vga_hdp_control); |
| 1242 | mdelay(1); |
| 1243 | /* Restore video state */ |
| 1244 | WREG32(D1VGA_CONTROL, save->vga_control[0]); |
| 1245 | WREG32(D2VGA_CONTROL, save->vga_control[1]); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1246 | if (rdev->num_crtc >= 4) { |
| 1247 | WREG32(EVERGREEN_D3VGA_CONTROL, save->vga_control[2]); |
| 1248 | WREG32(EVERGREEN_D4VGA_CONTROL, save->vga_control[3]); |
| 1249 | } |
| 1250 | if (rdev->num_crtc >= 6) { |
| 1251 | WREG32(EVERGREEN_D5VGA_CONTROL, save->vga_control[4]); |
| 1252 | WREG32(EVERGREEN_D6VGA_CONTROL, save->vga_control[5]); |
| 1253 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1254 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 1); |
| 1255 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 1); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1256 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1257 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 1); |
| 1258 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 1); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1259 | } |
| 1260 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1261 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 1); |
| 1262 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 1); |
| 1263 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1264 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, save->crtc_control[0]); |
| 1265 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, save->crtc_control[1]); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1266 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1267 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, save->crtc_control[2]); |
| 1268 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, save->crtc_control[3]); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1269 | } |
| 1270 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1271 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, save->crtc_control[4]); |
| 1272 | WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, save->crtc_control[5]); |
| 1273 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1274 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 1275 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1276 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1277 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 1278 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 1279 | } |
| 1280 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 1281 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 1282 | WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 1283 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1284 | WREG32(VGA_RENDER_CONTROL, save->vga_render_control); |
| 1285 | } |
| 1286 | |
Alex Deucher | 755d819 | 2011-03-02 20:07:34 -0500 | [diff] [blame] | 1287 | void evergreen_mc_program(struct radeon_device *rdev) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1288 | { |
| 1289 | struct evergreen_mc_save save; |
| 1290 | u32 tmp; |
| 1291 | int i, j; |
| 1292 | |
| 1293 | /* Initialize HDP */ |
| 1294 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 1295 | WREG32((0x2c14 + j), 0x00000000); |
| 1296 | WREG32((0x2c18 + j), 0x00000000); |
| 1297 | WREG32((0x2c1c + j), 0x00000000); |
| 1298 | WREG32((0x2c20 + j), 0x00000000); |
| 1299 | WREG32((0x2c24 + j), 0x00000000); |
| 1300 | } |
| 1301 | WREG32(HDP_REG_COHERENCY_FLUSH_CNTL, 0); |
| 1302 | |
| 1303 | evergreen_mc_stop(rdev, &save); |
| 1304 | if (evergreen_mc_wait_for_idle(rdev)) { |
| 1305 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 1306 | } |
| 1307 | /* Lockout access through VGA aperture*/ |
| 1308 | WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE); |
| 1309 | /* Update configuration */ |
| 1310 | if (rdev->flags & RADEON_IS_AGP) { |
| 1311 | if (rdev->mc.vram_start < rdev->mc.gtt_start) { |
| 1312 | /* VRAM before AGP */ |
| 1313 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 1314 | rdev->mc.vram_start >> 12); |
| 1315 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 1316 | rdev->mc.gtt_end >> 12); |
| 1317 | } else { |
| 1318 | /* VRAM after AGP */ |
| 1319 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 1320 | rdev->mc.gtt_start >> 12); |
| 1321 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 1322 | rdev->mc.vram_end >> 12); |
| 1323 | } |
| 1324 | } else { |
| 1325 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 1326 | rdev->mc.vram_start >> 12); |
| 1327 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 1328 | rdev->mc.vram_end >> 12); |
| 1329 | } |
Alex Deucher | 3b9832f | 2011-11-10 08:59:39 -0500 | [diff] [blame] | 1330 | WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr >> 12); |
Alex Deucher | 05b3ef6 | 2012-03-20 17:18:37 -0400 | [diff] [blame] | 1331 | /* llano/ontario only */ |
| 1332 | if ((rdev->family == CHIP_PALM) || |
| 1333 | (rdev->family == CHIP_SUMO) || |
| 1334 | (rdev->family == CHIP_SUMO2)) { |
Alex Deucher | b4183e3 | 2010-12-15 11:04:10 -0500 | [diff] [blame] | 1335 | tmp = RREG32(MC_FUS_VM_FB_OFFSET) & 0x000FFFFF; |
| 1336 | tmp |= ((rdev->mc.vram_end >> 20) & 0xF) << 24; |
| 1337 | tmp |= ((rdev->mc.vram_start >> 20) & 0xF) << 20; |
| 1338 | WREG32(MC_FUS_VM_FB_OFFSET, tmp); |
| 1339 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1340 | tmp = ((rdev->mc.vram_end >> 24) & 0xFFFF) << 16; |
| 1341 | tmp |= ((rdev->mc.vram_start >> 24) & 0xFFFF); |
| 1342 | WREG32(MC_VM_FB_LOCATION, tmp); |
| 1343 | WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); |
Alex Deucher | c46cb4d | 2011-01-06 19:12:37 -0500 | [diff] [blame] | 1344 | WREG32(HDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); |
Jerome Glisse | 46fcd2b | 2010-06-03 19:34:48 +0200 | [diff] [blame] | 1345 | WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1346 | if (rdev->flags & RADEON_IS_AGP) { |
| 1347 | WREG32(MC_VM_AGP_TOP, rdev->mc.gtt_end >> 16); |
| 1348 | WREG32(MC_VM_AGP_BOT, rdev->mc.gtt_start >> 16); |
| 1349 | WREG32(MC_VM_AGP_BASE, rdev->mc.agp_base >> 22); |
| 1350 | } else { |
| 1351 | WREG32(MC_VM_AGP_BASE, 0); |
| 1352 | WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF); |
| 1353 | WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF); |
| 1354 | } |
| 1355 | if (evergreen_mc_wait_for_idle(rdev)) { |
| 1356 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 1357 | } |
| 1358 | evergreen_mc_resume(rdev, &save); |
| 1359 | /* we need to own VRAM, so turn off the VGA renderer here |
| 1360 | * to stop it overwriting our objects */ |
| 1361 | rv515_vga_render_disable(rdev); |
| 1362 | } |
| 1363 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1364 | /* |
| 1365 | * CP. |
| 1366 | */ |
Alex Deucher | 1292059 | 2011-02-02 12:37:40 -0500 | [diff] [blame] | 1367 | void evergreen_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) |
| 1368 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1369 | struct radeon_ring *ring = &rdev->ring[ib->fence->ring]; |
Christian König | 7b1f248 | 2011-09-23 15:11:23 +0200 | [diff] [blame] | 1370 | |
Alex Deucher | 1292059 | 2011-02-02 12:37:40 -0500 | [diff] [blame] | 1371 | /* set to DX10/11 mode */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1372 | radeon_ring_write(ring, PACKET3(PACKET3_MODE_CONTROL, 0)); |
| 1373 | radeon_ring_write(ring, 1); |
Alex Deucher | 1292059 | 2011-02-02 12:37:40 -0500 | [diff] [blame] | 1374 | /* FIXME: implement */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1375 | radeon_ring_write(ring, PACKET3(PACKET3_INDIRECT_BUFFER, 2)); |
| 1376 | radeon_ring_write(ring, |
Alex Deucher | 0f234f5f | 2011-02-13 19:06:33 -0500 | [diff] [blame] | 1377 | #ifdef __BIG_ENDIAN |
| 1378 | (2 << 0) | |
| 1379 | #endif |
| 1380 | (ib->gpu_addr & 0xFFFFFFFC)); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1381 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFF); |
| 1382 | radeon_ring_write(ring, ib->length_dw); |
Alex Deucher | 1292059 | 2011-02-02 12:37:40 -0500 | [diff] [blame] | 1383 | } |
| 1384 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1385 | |
| 1386 | static int evergreen_cp_load_microcode(struct radeon_device *rdev) |
| 1387 | { |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1388 | const __be32 *fw_data; |
| 1389 | int i; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1390 | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1391 | if (!rdev->me_fw || !rdev->pfp_fw) |
| 1392 | return -EINVAL; |
| 1393 | |
| 1394 | r700_cp_stop(rdev); |
Alex Deucher | 0f234f5f | 2011-02-13 19:06:33 -0500 | [diff] [blame] | 1395 | WREG32(CP_RB_CNTL, |
| 1396 | #ifdef __BIG_ENDIAN |
| 1397 | BUF_SWAP_32BIT | |
| 1398 | #endif |
| 1399 | RB_NO_UPDATE | RB_BLKSZ(15) | RB_BUFSZ(3)); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1400 | |
| 1401 | fw_data = (const __be32 *)rdev->pfp_fw->data; |
| 1402 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 1403 | for (i = 0; i < EVERGREEN_PFP_UCODE_SIZE; i++) |
| 1404 | WREG32(CP_PFP_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 1405 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 1406 | |
| 1407 | fw_data = (const __be32 *)rdev->me_fw->data; |
| 1408 | WREG32(CP_ME_RAM_WADDR, 0); |
| 1409 | for (i = 0; i < EVERGREEN_PM4_UCODE_SIZE; i++) |
| 1410 | WREG32(CP_ME_RAM_DATA, be32_to_cpup(fw_data++)); |
| 1411 | |
| 1412 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 1413 | WREG32(CP_ME_RAM_WADDR, 0); |
| 1414 | WREG32(CP_ME_RAM_RADDR, 0); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1415 | return 0; |
| 1416 | } |
| 1417 | |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1418 | static int evergreen_cp_start(struct radeon_device *rdev) |
| 1419 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1420 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1421 | int r, i; |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1422 | uint32_t cp_me; |
| 1423 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1424 | r = radeon_ring_lock(rdev, ring, 7); |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1425 | if (r) { |
| 1426 | DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r); |
| 1427 | return r; |
| 1428 | } |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1429 | radeon_ring_write(ring, PACKET3(PACKET3_ME_INITIALIZE, 5)); |
| 1430 | radeon_ring_write(ring, 0x1); |
| 1431 | radeon_ring_write(ring, 0x0); |
| 1432 | radeon_ring_write(ring, rdev->config.evergreen.max_hw_contexts - 1); |
| 1433 | radeon_ring_write(ring, PACKET3_ME_INITIALIZE_DEVICE_ID(1)); |
| 1434 | radeon_ring_write(ring, 0); |
| 1435 | radeon_ring_write(ring, 0); |
| 1436 | radeon_ring_unlock_commit(rdev, ring); |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1437 | |
| 1438 | cp_me = 0xff; |
| 1439 | WREG32(CP_ME_CNTL, cp_me); |
| 1440 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1441 | r = radeon_ring_lock(rdev, ring, evergreen_default_size + 19); |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1442 | if (r) { |
| 1443 | DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r); |
| 1444 | return r; |
| 1445 | } |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1446 | |
| 1447 | /* setup clear context state */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1448 | radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 1449 | radeon_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1450 | |
| 1451 | for (i = 0; i < evergreen_default_size; i++) |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1452 | radeon_ring_write(ring, evergreen_default_state[i]); |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1453 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1454 | radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 1455 | radeon_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE); |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1456 | |
| 1457 | /* set clear context state */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1458 | radeon_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0)); |
| 1459 | radeon_ring_write(ring, 0); |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1460 | |
| 1461 | /* SQ_VTX_BASE_VTX_LOC */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1462 | radeon_ring_write(ring, 0xc0026f00); |
| 1463 | radeon_ring_write(ring, 0x00000000); |
| 1464 | radeon_ring_write(ring, 0x00000000); |
| 1465 | radeon_ring_write(ring, 0x00000000); |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1466 | |
| 1467 | /* Clear consts */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1468 | radeon_ring_write(ring, 0xc0036f00); |
| 1469 | radeon_ring_write(ring, 0x00000bc4); |
| 1470 | radeon_ring_write(ring, 0xffffffff); |
| 1471 | radeon_ring_write(ring, 0xffffffff); |
| 1472 | radeon_ring_write(ring, 0xffffffff); |
Alex Deucher | 2281a37 | 2010-10-21 13:31:38 -0400 | [diff] [blame] | 1473 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1474 | radeon_ring_write(ring, 0xc0026900); |
| 1475 | radeon_ring_write(ring, 0x00000316); |
| 1476 | radeon_ring_write(ring, 0x0000000e); /* VGT_VERTEX_REUSE_BLOCK_CNTL */ |
| 1477 | radeon_ring_write(ring, 0x00000010); /* */ |
Alex Deucher | 18ff84d | 2011-02-02 12:37:41 -0500 | [diff] [blame] | 1478 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1479 | radeon_ring_unlock_commit(rdev, ring); |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1480 | |
| 1481 | return 0; |
| 1482 | } |
| 1483 | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1484 | int evergreen_cp_resume(struct radeon_device *rdev) |
| 1485 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1486 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1487 | u32 tmp; |
| 1488 | u32 rb_bufsz; |
| 1489 | int r; |
| 1490 | |
| 1491 | /* Reset cp; if cp is reset, then PA, SH, VGT also need to be reset */ |
| 1492 | WREG32(GRBM_SOFT_RESET, (SOFT_RESET_CP | |
| 1493 | SOFT_RESET_PA | |
| 1494 | SOFT_RESET_SH | |
| 1495 | SOFT_RESET_VGT | |
Jerome Glisse | a49a50d | 2011-08-24 20:00:17 +0000 | [diff] [blame] | 1496 | SOFT_RESET_SPI | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1497 | SOFT_RESET_SX)); |
| 1498 | RREG32(GRBM_SOFT_RESET); |
| 1499 | mdelay(15); |
| 1500 | WREG32(GRBM_SOFT_RESET, 0); |
| 1501 | RREG32(GRBM_SOFT_RESET); |
| 1502 | |
| 1503 | /* Set ring buffer size */ |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1504 | rb_bufsz = drm_order(ring->ring_size / 8); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 1505 | tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1506 | #ifdef __BIG_ENDIAN |
| 1507 | tmp |= BUF_SWAP_32BIT; |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1508 | #endif |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1509 | WREG32(CP_RB_CNTL, tmp); |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 1510 | WREG32(CP_SEM_WAIT_TIMER, 0x0); |
Alex Deucher | 11ef3f1f | 2012-01-20 14:47:43 -0500 | [diff] [blame] | 1511 | WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1512 | |
| 1513 | /* Set the write pointer delay */ |
| 1514 | WREG32(CP_RB_WPTR_DELAY, 0); |
| 1515 | |
| 1516 | /* Initialize the ring buffer's read and write pointers */ |
| 1517 | WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA); |
| 1518 | WREG32(CP_RB_RPTR_WR, 0); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1519 | ring->wptr = 0; |
| 1520 | WREG32(CP_RB_WPTR, ring->wptr); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 1521 | |
| 1522 | /* set the wb address wether it's enabled or not */ |
Alex Deucher | 0f234f5f | 2011-02-13 19:06:33 -0500 | [diff] [blame] | 1523 | WREG32(CP_RB_RPTR_ADDR, |
Alex Deucher | 0f234f5f | 2011-02-13 19:06:33 -0500 | [diff] [blame] | 1524 | ((rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC)); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 1525 | WREG32(CP_RB_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFF); |
| 1526 | WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF); |
| 1527 | |
| 1528 | if (rdev->wb.enabled) |
| 1529 | WREG32(SCRATCH_UMSK, 0xff); |
| 1530 | else { |
| 1531 | tmp |= RB_NO_UPDATE; |
| 1532 | WREG32(SCRATCH_UMSK, 0); |
| 1533 | } |
| 1534 | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1535 | mdelay(1); |
| 1536 | WREG32(CP_RB_CNTL, tmp); |
| 1537 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1538 | WREG32(CP_RB_BASE, ring->gpu_addr >> 8); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1539 | WREG32(CP_DEBUG, (1 << 27) | (1 << 28)); |
| 1540 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1541 | ring->rptr = RREG32(CP_RB_RPTR); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1542 | |
Alex Deucher | 7e7b41d | 2010-09-02 21:32:32 -0400 | [diff] [blame] | 1543 | evergreen_cp_start(rdev); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1544 | ring->ready = true; |
Alex Deucher | f712812 | 2012-02-23 17:53:45 -0500 | [diff] [blame] | 1545 | r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1546 | if (r) { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 1547 | ring->ready = false; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1548 | return r; |
| 1549 | } |
| 1550 | return 0; |
| 1551 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1552 | |
| 1553 | /* |
| 1554 | * Core functions |
| 1555 | */ |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1556 | static u32 evergreen_get_tile_pipe_to_backend_map(struct radeon_device *rdev, |
| 1557 | u32 num_tile_pipes, |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1558 | u32 num_backends, |
| 1559 | u32 backend_disable_mask) |
| 1560 | { |
| 1561 | u32 backend_map = 0; |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1562 | u32 enabled_backends_mask = 0; |
| 1563 | u32 enabled_backends_count = 0; |
| 1564 | u32 cur_pipe; |
| 1565 | u32 swizzle_pipe[EVERGREEN_MAX_PIPES]; |
| 1566 | u32 cur_backend = 0; |
| 1567 | u32 i; |
| 1568 | bool force_no_swizzle; |
| 1569 | |
| 1570 | if (num_tile_pipes > EVERGREEN_MAX_PIPES) |
| 1571 | num_tile_pipes = EVERGREEN_MAX_PIPES; |
| 1572 | if (num_tile_pipes < 1) |
| 1573 | num_tile_pipes = 1; |
| 1574 | if (num_backends > EVERGREEN_MAX_BACKENDS) |
| 1575 | num_backends = EVERGREEN_MAX_BACKENDS; |
| 1576 | if (num_backends < 1) |
| 1577 | num_backends = 1; |
| 1578 | |
| 1579 | for (i = 0; i < EVERGREEN_MAX_BACKENDS; ++i) { |
| 1580 | if (((backend_disable_mask >> i) & 1) == 0) { |
| 1581 | enabled_backends_mask |= (1 << i); |
| 1582 | ++enabled_backends_count; |
| 1583 | } |
| 1584 | if (enabled_backends_count == num_backends) |
| 1585 | break; |
| 1586 | } |
| 1587 | |
| 1588 | if (enabled_backends_count == 0) { |
| 1589 | enabled_backends_mask = 1; |
| 1590 | enabled_backends_count = 1; |
| 1591 | } |
| 1592 | |
| 1593 | if (enabled_backends_count != num_backends) |
| 1594 | num_backends = enabled_backends_count; |
| 1595 | |
| 1596 | memset((uint8_t *)&swizzle_pipe[0], 0, sizeof(u32) * EVERGREEN_MAX_PIPES); |
| 1597 | switch (rdev->family) { |
| 1598 | case CHIP_CEDAR: |
| 1599 | case CHIP_REDWOOD: |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 1600 | case CHIP_PALM: |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 1601 | case CHIP_SUMO: |
| 1602 | case CHIP_SUMO2: |
Alex Deucher | adb68fa | 2011-01-06 21:19:24 -0500 | [diff] [blame] | 1603 | case CHIP_TURKS: |
| 1604 | case CHIP_CAICOS: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1605 | force_no_swizzle = false; |
| 1606 | break; |
| 1607 | case CHIP_CYPRESS: |
| 1608 | case CHIP_HEMLOCK: |
| 1609 | case CHIP_JUNIPER: |
Alex Deucher | adb68fa | 2011-01-06 21:19:24 -0500 | [diff] [blame] | 1610 | case CHIP_BARTS: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1611 | default: |
| 1612 | force_no_swizzle = true; |
| 1613 | break; |
| 1614 | } |
| 1615 | if (force_no_swizzle) { |
| 1616 | bool last_backend_enabled = false; |
| 1617 | |
| 1618 | force_no_swizzle = false; |
| 1619 | for (i = 0; i < EVERGREEN_MAX_BACKENDS; ++i) { |
| 1620 | if (((enabled_backends_mask >> i) & 1) == 1) { |
| 1621 | if (last_backend_enabled) |
| 1622 | force_no_swizzle = true; |
| 1623 | last_backend_enabled = true; |
| 1624 | } else |
| 1625 | last_backend_enabled = false; |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | switch (num_tile_pipes) { |
| 1630 | case 1: |
| 1631 | case 3: |
| 1632 | case 5: |
| 1633 | case 7: |
| 1634 | DRM_ERROR("odd number of pipes!\n"); |
| 1635 | break; |
| 1636 | case 2: |
| 1637 | swizzle_pipe[0] = 0; |
| 1638 | swizzle_pipe[1] = 1; |
| 1639 | break; |
| 1640 | case 4: |
| 1641 | if (force_no_swizzle) { |
| 1642 | swizzle_pipe[0] = 0; |
| 1643 | swizzle_pipe[1] = 1; |
| 1644 | swizzle_pipe[2] = 2; |
| 1645 | swizzle_pipe[3] = 3; |
| 1646 | } else { |
| 1647 | swizzle_pipe[0] = 0; |
| 1648 | swizzle_pipe[1] = 2; |
| 1649 | swizzle_pipe[2] = 1; |
| 1650 | swizzle_pipe[3] = 3; |
| 1651 | } |
| 1652 | break; |
| 1653 | case 6: |
| 1654 | if (force_no_swizzle) { |
| 1655 | swizzle_pipe[0] = 0; |
| 1656 | swizzle_pipe[1] = 1; |
| 1657 | swizzle_pipe[2] = 2; |
| 1658 | swizzle_pipe[3] = 3; |
| 1659 | swizzle_pipe[4] = 4; |
| 1660 | swizzle_pipe[5] = 5; |
| 1661 | } else { |
| 1662 | swizzle_pipe[0] = 0; |
| 1663 | swizzle_pipe[1] = 2; |
| 1664 | swizzle_pipe[2] = 4; |
| 1665 | swizzle_pipe[3] = 1; |
| 1666 | swizzle_pipe[4] = 3; |
| 1667 | swizzle_pipe[5] = 5; |
| 1668 | } |
| 1669 | break; |
| 1670 | case 8: |
| 1671 | if (force_no_swizzle) { |
| 1672 | swizzle_pipe[0] = 0; |
| 1673 | swizzle_pipe[1] = 1; |
| 1674 | swizzle_pipe[2] = 2; |
| 1675 | swizzle_pipe[3] = 3; |
| 1676 | swizzle_pipe[4] = 4; |
| 1677 | swizzle_pipe[5] = 5; |
| 1678 | swizzle_pipe[6] = 6; |
| 1679 | swizzle_pipe[7] = 7; |
| 1680 | } else { |
| 1681 | swizzle_pipe[0] = 0; |
| 1682 | swizzle_pipe[1] = 2; |
| 1683 | swizzle_pipe[2] = 4; |
| 1684 | swizzle_pipe[3] = 6; |
| 1685 | swizzle_pipe[4] = 1; |
| 1686 | swizzle_pipe[5] = 3; |
| 1687 | swizzle_pipe[6] = 5; |
| 1688 | swizzle_pipe[7] = 7; |
| 1689 | } |
| 1690 | break; |
| 1691 | } |
| 1692 | |
| 1693 | for (cur_pipe = 0; cur_pipe < num_tile_pipes; ++cur_pipe) { |
| 1694 | while (((1 << cur_backend) & enabled_backends_mask) == 0) |
| 1695 | cur_backend = (cur_backend + 1) % EVERGREEN_MAX_BACKENDS; |
| 1696 | |
| 1697 | backend_map |= (((cur_backend & 0xf) << (swizzle_pipe[cur_pipe] * 4))); |
| 1698 | |
| 1699 | cur_backend = (cur_backend + 1) % EVERGREEN_MAX_BACKENDS; |
| 1700 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1701 | |
| 1702 | return backend_map; |
| 1703 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1704 | |
| 1705 | static void evergreen_gpu_init(struct radeon_device *rdev) |
| 1706 | { |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1707 | u32 cc_rb_backend_disable = 0; |
| 1708 | u32 cc_gc_shader_pipe_config; |
| 1709 | u32 gb_addr_config = 0; |
| 1710 | u32 mc_shared_chmap, mc_arb_ramcfg; |
| 1711 | u32 gb_backend_map; |
| 1712 | u32 grbm_gfx_index; |
| 1713 | u32 sx_debug_1; |
| 1714 | u32 smx_dc_ctl0; |
| 1715 | u32 sq_config; |
| 1716 | u32 sq_lds_resource_mgmt; |
| 1717 | u32 sq_gpr_resource_mgmt_1; |
| 1718 | u32 sq_gpr_resource_mgmt_2; |
| 1719 | u32 sq_gpr_resource_mgmt_3; |
| 1720 | u32 sq_thread_resource_mgmt; |
| 1721 | u32 sq_thread_resource_mgmt_2; |
| 1722 | u32 sq_stack_resource_mgmt_1; |
| 1723 | u32 sq_stack_resource_mgmt_2; |
| 1724 | u32 sq_stack_resource_mgmt_3; |
| 1725 | u32 vgt_cache_invalidation; |
Alex Deucher | f25a5c6 | 2011-05-19 11:07:57 -0400 | [diff] [blame] | 1726 | u32 hdp_host_path_cntl, tmp; |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1727 | int i, j, num_shader_engines, ps_thread_count; |
| 1728 | |
| 1729 | switch (rdev->family) { |
| 1730 | case CHIP_CYPRESS: |
| 1731 | case CHIP_HEMLOCK: |
| 1732 | rdev->config.evergreen.num_ses = 2; |
| 1733 | rdev->config.evergreen.max_pipes = 4; |
| 1734 | rdev->config.evergreen.max_tile_pipes = 8; |
| 1735 | rdev->config.evergreen.max_simds = 10; |
| 1736 | rdev->config.evergreen.max_backends = 4 * rdev->config.evergreen.num_ses; |
| 1737 | rdev->config.evergreen.max_gprs = 256; |
| 1738 | rdev->config.evergreen.max_threads = 248; |
| 1739 | rdev->config.evergreen.max_gs_threads = 32; |
| 1740 | rdev->config.evergreen.max_stack_entries = 512; |
| 1741 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1742 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1743 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1744 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1745 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1746 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1747 | |
| 1748 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; |
| 1749 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1750 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1751 | break; |
| 1752 | case CHIP_JUNIPER: |
| 1753 | rdev->config.evergreen.num_ses = 1; |
| 1754 | rdev->config.evergreen.max_pipes = 4; |
| 1755 | rdev->config.evergreen.max_tile_pipes = 4; |
| 1756 | rdev->config.evergreen.max_simds = 10; |
| 1757 | rdev->config.evergreen.max_backends = 4 * rdev->config.evergreen.num_ses; |
| 1758 | rdev->config.evergreen.max_gprs = 256; |
| 1759 | rdev->config.evergreen.max_threads = 248; |
| 1760 | rdev->config.evergreen.max_gs_threads = 32; |
| 1761 | rdev->config.evergreen.max_stack_entries = 512; |
| 1762 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1763 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1764 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1765 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1766 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1767 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1768 | |
| 1769 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; |
| 1770 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1771 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1772 | break; |
| 1773 | case CHIP_REDWOOD: |
| 1774 | rdev->config.evergreen.num_ses = 1; |
| 1775 | rdev->config.evergreen.max_pipes = 4; |
| 1776 | rdev->config.evergreen.max_tile_pipes = 4; |
| 1777 | rdev->config.evergreen.max_simds = 5; |
| 1778 | rdev->config.evergreen.max_backends = 2 * rdev->config.evergreen.num_ses; |
| 1779 | rdev->config.evergreen.max_gprs = 256; |
| 1780 | rdev->config.evergreen.max_threads = 248; |
| 1781 | rdev->config.evergreen.max_gs_threads = 32; |
| 1782 | rdev->config.evergreen.max_stack_entries = 256; |
| 1783 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1784 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1785 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1786 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1787 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1788 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1789 | |
| 1790 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; |
| 1791 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1792 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1793 | break; |
| 1794 | case CHIP_CEDAR: |
| 1795 | default: |
| 1796 | rdev->config.evergreen.num_ses = 1; |
| 1797 | rdev->config.evergreen.max_pipes = 2; |
| 1798 | rdev->config.evergreen.max_tile_pipes = 2; |
| 1799 | rdev->config.evergreen.max_simds = 2; |
| 1800 | rdev->config.evergreen.max_backends = 1 * rdev->config.evergreen.num_ses; |
| 1801 | rdev->config.evergreen.max_gprs = 256; |
| 1802 | rdev->config.evergreen.max_threads = 192; |
| 1803 | rdev->config.evergreen.max_gs_threads = 16; |
| 1804 | rdev->config.evergreen.max_stack_entries = 256; |
| 1805 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1806 | rdev->config.evergreen.sx_max_export_size = 128; |
| 1807 | rdev->config.evergreen.sx_max_export_pos_size = 32; |
| 1808 | rdev->config.evergreen.sx_max_export_smx_size = 96; |
| 1809 | rdev->config.evergreen.max_hw_contexts = 4; |
| 1810 | rdev->config.evergreen.sq_num_cf_insts = 1; |
| 1811 | |
| 1812 | rdev->config.evergreen.sc_prim_fifo_size = 0x40; |
| 1813 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1814 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1815 | break; |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 1816 | case CHIP_PALM: |
| 1817 | rdev->config.evergreen.num_ses = 1; |
| 1818 | rdev->config.evergreen.max_pipes = 2; |
| 1819 | rdev->config.evergreen.max_tile_pipes = 2; |
| 1820 | rdev->config.evergreen.max_simds = 2; |
| 1821 | rdev->config.evergreen.max_backends = 1 * rdev->config.evergreen.num_ses; |
| 1822 | rdev->config.evergreen.max_gprs = 256; |
| 1823 | rdev->config.evergreen.max_threads = 192; |
| 1824 | rdev->config.evergreen.max_gs_threads = 16; |
| 1825 | rdev->config.evergreen.max_stack_entries = 256; |
| 1826 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1827 | rdev->config.evergreen.sx_max_export_size = 128; |
| 1828 | rdev->config.evergreen.sx_max_export_pos_size = 32; |
| 1829 | rdev->config.evergreen.sx_max_export_smx_size = 96; |
| 1830 | rdev->config.evergreen.max_hw_contexts = 4; |
| 1831 | rdev->config.evergreen.sq_num_cf_insts = 1; |
| 1832 | |
| 1833 | rdev->config.evergreen.sc_prim_fifo_size = 0x40; |
| 1834 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1835 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1836 | break; |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 1837 | case CHIP_SUMO: |
| 1838 | rdev->config.evergreen.num_ses = 1; |
| 1839 | rdev->config.evergreen.max_pipes = 4; |
| 1840 | rdev->config.evergreen.max_tile_pipes = 2; |
| 1841 | if (rdev->pdev->device == 0x9648) |
| 1842 | rdev->config.evergreen.max_simds = 3; |
| 1843 | else if ((rdev->pdev->device == 0x9647) || |
| 1844 | (rdev->pdev->device == 0x964a)) |
| 1845 | rdev->config.evergreen.max_simds = 4; |
| 1846 | else |
| 1847 | rdev->config.evergreen.max_simds = 5; |
| 1848 | rdev->config.evergreen.max_backends = 2 * rdev->config.evergreen.num_ses; |
| 1849 | rdev->config.evergreen.max_gprs = 256; |
| 1850 | rdev->config.evergreen.max_threads = 248; |
| 1851 | rdev->config.evergreen.max_gs_threads = 32; |
| 1852 | rdev->config.evergreen.max_stack_entries = 256; |
| 1853 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1854 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1855 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1856 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1857 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1858 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1859 | |
| 1860 | rdev->config.evergreen.sc_prim_fifo_size = 0x40; |
| 1861 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1862 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1863 | break; |
| 1864 | case CHIP_SUMO2: |
| 1865 | rdev->config.evergreen.num_ses = 1; |
| 1866 | rdev->config.evergreen.max_pipes = 4; |
| 1867 | rdev->config.evergreen.max_tile_pipes = 4; |
| 1868 | rdev->config.evergreen.max_simds = 2; |
| 1869 | rdev->config.evergreen.max_backends = 1 * rdev->config.evergreen.num_ses; |
| 1870 | rdev->config.evergreen.max_gprs = 256; |
| 1871 | rdev->config.evergreen.max_threads = 248; |
| 1872 | rdev->config.evergreen.max_gs_threads = 32; |
| 1873 | rdev->config.evergreen.max_stack_entries = 512; |
| 1874 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1875 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1876 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1877 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1878 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1879 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1880 | |
| 1881 | rdev->config.evergreen.sc_prim_fifo_size = 0x40; |
| 1882 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1883 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1884 | break; |
Alex Deucher | adb68fa | 2011-01-06 21:19:24 -0500 | [diff] [blame] | 1885 | case CHIP_BARTS: |
| 1886 | rdev->config.evergreen.num_ses = 2; |
| 1887 | rdev->config.evergreen.max_pipes = 4; |
| 1888 | rdev->config.evergreen.max_tile_pipes = 8; |
| 1889 | rdev->config.evergreen.max_simds = 7; |
| 1890 | rdev->config.evergreen.max_backends = 4 * rdev->config.evergreen.num_ses; |
| 1891 | rdev->config.evergreen.max_gprs = 256; |
| 1892 | rdev->config.evergreen.max_threads = 248; |
| 1893 | rdev->config.evergreen.max_gs_threads = 32; |
| 1894 | rdev->config.evergreen.max_stack_entries = 512; |
| 1895 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1896 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1897 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1898 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1899 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1900 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1901 | |
| 1902 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; |
| 1903 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1904 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1905 | break; |
| 1906 | case CHIP_TURKS: |
| 1907 | rdev->config.evergreen.num_ses = 1; |
| 1908 | rdev->config.evergreen.max_pipes = 4; |
| 1909 | rdev->config.evergreen.max_tile_pipes = 4; |
| 1910 | rdev->config.evergreen.max_simds = 6; |
| 1911 | rdev->config.evergreen.max_backends = 2 * rdev->config.evergreen.num_ses; |
| 1912 | rdev->config.evergreen.max_gprs = 256; |
| 1913 | rdev->config.evergreen.max_threads = 248; |
| 1914 | rdev->config.evergreen.max_gs_threads = 32; |
| 1915 | rdev->config.evergreen.max_stack_entries = 256; |
| 1916 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1917 | rdev->config.evergreen.sx_max_export_size = 256; |
| 1918 | rdev->config.evergreen.sx_max_export_pos_size = 64; |
| 1919 | rdev->config.evergreen.sx_max_export_smx_size = 192; |
| 1920 | rdev->config.evergreen.max_hw_contexts = 8; |
| 1921 | rdev->config.evergreen.sq_num_cf_insts = 2; |
| 1922 | |
| 1923 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; |
| 1924 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1925 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1926 | break; |
| 1927 | case CHIP_CAICOS: |
| 1928 | rdev->config.evergreen.num_ses = 1; |
| 1929 | rdev->config.evergreen.max_pipes = 4; |
| 1930 | rdev->config.evergreen.max_tile_pipes = 2; |
| 1931 | rdev->config.evergreen.max_simds = 2; |
| 1932 | rdev->config.evergreen.max_backends = 1 * rdev->config.evergreen.num_ses; |
| 1933 | rdev->config.evergreen.max_gprs = 256; |
| 1934 | rdev->config.evergreen.max_threads = 192; |
| 1935 | rdev->config.evergreen.max_gs_threads = 16; |
| 1936 | rdev->config.evergreen.max_stack_entries = 256; |
| 1937 | rdev->config.evergreen.sx_num_of_sets = 4; |
| 1938 | rdev->config.evergreen.sx_max_export_size = 128; |
| 1939 | rdev->config.evergreen.sx_max_export_pos_size = 32; |
| 1940 | rdev->config.evergreen.sx_max_export_smx_size = 96; |
| 1941 | rdev->config.evergreen.max_hw_contexts = 4; |
| 1942 | rdev->config.evergreen.sq_num_cf_insts = 1; |
| 1943 | |
| 1944 | rdev->config.evergreen.sc_prim_fifo_size = 0x40; |
| 1945 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; |
| 1946 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; |
| 1947 | break; |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | /* Initialize HDP */ |
| 1951 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 1952 | WREG32((0x2c14 + j), 0x00000000); |
| 1953 | WREG32((0x2c18 + j), 0x00000000); |
| 1954 | WREG32((0x2c1c + j), 0x00000000); |
| 1955 | WREG32((0x2c20 + j), 0x00000000); |
| 1956 | WREG32((0x2c24 + j), 0x00000000); |
| 1957 | } |
| 1958 | |
| 1959 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); |
| 1960 | |
Alex Deucher | d054ac1 | 2011-09-01 17:46:15 +0000 | [diff] [blame] | 1961 | evergreen_fix_pci_max_read_req_size(rdev); |
| 1962 | |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1963 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & ~2; |
| 1964 | |
| 1965 | cc_gc_shader_pipe_config |= |
| 1966 | INACTIVE_QD_PIPES((EVERGREEN_MAX_PIPES_MASK << rdev->config.evergreen.max_pipes) |
| 1967 | & EVERGREEN_MAX_PIPES_MASK); |
| 1968 | cc_gc_shader_pipe_config |= |
| 1969 | INACTIVE_SIMDS((EVERGREEN_MAX_SIMDS_MASK << rdev->config.evergreen.max_simds) |
| 1970 | & EVERGREEN_MAX_SIMDS_MASK); |
| 1971 | |
| 1972 | cc_rb_backend_disable = |
| 1973 | BACKEND_DISABLE((EVERGREEN_MAX_BACKENDS_MASK << rdev->config.evergreen.max_backends) |
| 1974 | & EVERGREEN_MAX_BACKENDS_MASK); |
| 1975 | |
| 1976 | |
| 1977 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); |
Alex Deucher | 05b3ef6 | 2012-03-20 17:18:37 -0400 | [diff] [blame] | 1978 | if ((rdev->family == CHIP_PALM) || |
| 1979 | (rdev->family == CHIP_SUMO) || |
| 1980 | (rdev->family == CHIP_SUMO2)) |
Alex Deucher | d9282fc | 2011-05-11 03:15:24 -0400 | [diff] [blame] | 1981 | mc_arb_ramcfg = RREG32(FUS_MC_ARB_RAMCFG); |
| 1982 | else |
| 1983 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 1984 | |
| 1985 | switch (rdev->config.evergreen.max_tile_pipes) { |
| 1986 | case 1: |
| 1987 | default: |
| 1988 | gb_addr_config |= NUM_PIPES(0); |
| 1989 | break; |
| 1990 | case 2: |
| 1991 | gb_addr_config |= NUM_PIPES(1); |
| 1992 | break; |
| 1993 | case 4: |
| 1994 | gb_addr_config |= NUM_PIPES(2); |
| 1995 | break; |
| 1996 | case 8: |
| 1997 | gb_addr_config |= NUM_PIPES(3); |
| 1998 | break; |
| 1999 | } |
| 2000 | |
| 2001 | gb_addr_config |= PIPE_INTERLEAVE_SIZE((mc_arb_ramcfg & BURSTLENGTH_MASK) >> BURSTLENGTH_SHIFT); |
| 2002 | gb_addr_config |= BANK_INTERLEAVE_SIZE(0); |
| 2003 | gb_addr_config |= NUM_SHADER_ENGINES(rdev->config.evergreen.num_ses - 1); |
| 2004 | gb_addr_config |= SHADER_ENGINE_TILE_SIZE(1); |
| 2005 | gb_addr_config |= NUM_GPUS(0); /* Hemlock? */ |
| 2006 | gb_addr_config |= MULTI_GPU_TILE_SIZE(2); |
| 2007 | |
| 2008 | if (((mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) > 2) |
| 2009 | gb_addr_config |= ROW_SIZE(2); |
| 2010 | else |
| 2011 | gb_addr_config |= ROW_SIZE((mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT); |
| 2012 | |
| 2013 | if (rdev->ddev->pdev->device == 0x689e) { |
| 2014 | u32 efuse_straps_4; |
| 2015 | u32 efuse_straps_3; |
| 2016 | u8 efuse_box_bit_131_124; |
| 2017 | |
| 2018 | WREG32(RCU_IND_INDEX, 0x204); |
| 2019 | efuse_straps_4 = RREG32(RCU_IND_DATA); |
| 2020 | WREG32(RCU_IND_INDEX, 0x203); |
| 2021 | efuse_straps_3 = RREG32(RCU_IND_DATA); |
| 2022 | efuse_box_bit_131_124 = (u8)(((efuse_straps_4 & 0xf) << 4) | ((efuse_straps_3 & 0xf0000000) >> 28)); |
| 2023 | |
| 2024 | switch(efuse_box_bit_131_124) { |
| 2025 | case 0x00: |
| 2026 | gb_backend_map = 0x76543210; |
| 2027 | break; |
| 2028 | case 0x55: |
| 2029 | gb_backend_map = 0x77553311; |
| 2030 | break; |
| 2031 | case 0x56: |
| 2032 | gb_backend_map = 0x77553300; |
| 2033 | break; |
| 2034 | case 0x59: |
| 2035 | gb_backend_map = 0x77552211; |
| 2036 | break; |
| 2037 | case 0x66: |
| 2038 | gb_backend_map = 0x77443300; |
| 2039 | break; |
| 2040 | case 0x99: |
| 2041 | gb_backend_map = 0x66552211; |
| 2042 | break; |
| 2043 | case 0x5a: |
| 2044 | gb_backend_map = 0x77552200; |
| 2045 | break; |
| 2046 | case 0xaa: |
| 2047 | gb_backend_map = 0x66442200; |
| 2048 | break; |
| 2049 | case 0x95: |
| 2050 | gb_backend_map = 0x66553311; |
| 2051 | break; |
| 2052 | default: |
| 2053 | DRM_ERROR("bad backend map, using default\n"); |
| 2054 | gb_backend_map = |
| 2055 | evergreen_get_tile_pipe_to_backend_map(rdev, |
| 2056 | rdev->config.evergreen.max_tile_pipes, |
| 2057 | rdev->config.evergreen.max_backends, |
| 2058 | ((EVERGREEN_MAX_BACKENDS_MASK << |
| 2059 | rdev->config.evergreen.max_backends) & |
| 2060 | EVERGREEN_MAX_BACKENDS_MASK)); |
| 2061 | break; |
| 2062 | } |
| 2063 | } else if (rdev->ddev->pdev->device == 0x68b9) { |
| 2064 | u32 efuse_straps_3; |
| 2065 | u8 efuse_box_bit_127_124; |
| 2066 | |
| 2067 | WREG32(RCU_IND_INDEX, 0x203); |
| 2068 | efuse_straps_3 = RREG32(RCU_IND_DATA); |
Alex Deucher | d31dba5 | 2010-10-11 12:41:32 -0400 | [diff] [blame] | 2069 | efuse_box_bit_127_124 = (u8)((efuse_straps_3 & 0xF0000000) >> 28); |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2070 | |
| 2071 | switch(efuse_box_bit_127_124) { |
| 2072 | case 0x0: |
| 2073 | gb_backend_map = 0x00003210; |
| 2074 | break; |
| 2075 | case 0x5: |
| 2076 | case 0x6: |
| 2077 | case 0x9: |
| 2078 | case 0xa: |
| 2079 | gb_backend_map = 0x00003311; |
| 2080 | break; |
| 2081 | default: |
| 2082 | DRM_ERROR("bad backend map, using default\n"); |
| 2083 | gb_backend_map = |
| 2084 | evergreen_get_tile_pipe_to_backend_map(rdev, |
| 2085 | rdev->config.evergreen.max_tile_pipes, |
| 2086 | rdev->config.evergreen.max_backends, |
| 2087 | ((EVERGREEN_MAX_BACKENDS_MASK << |
| 2088 | rdev->config.evergreen.max_backends) & |
| 2089 | EVERGREEN_MAX_BACKENDS_MASK)); |
| 2090 | break; |
| 2091 | } |
Alex Deucher | b741be8 | 2010-09-09 19:15:23 -0400 | [diff] [blame] | 2092 | } else { |
| 2093 | switch (rdev->family) { |
| 2094 | case CHIP_CYPRESS: |
| 2095 | case CHIP_HEMLOCK: |
Alex Deucher | 03f4009 | 2011-01-06 21:19:25 -0500 | [diff] [blame] | 2096 | case CHIP_BARTS: |
Alex Deucher | b741be8 | 2010-09-09 19:15:23 -0400 | [diff] [blame] | 2097 | gb_backend_map = 0x66442200; |
| 2098 | break; |
| 2099 | case CHIP_JUNIPER: |
Alex Deucher | 9a4a0b9 | 2011-07-11 19:45:32 +0000 | [diff] [blame] | 2100 | gb_backend_map = 0x00002200; |
Alex Deucher | b741be8 | 2010-09-09 19:15:23 -0400 | [diff] [blame] | 2101 | break; |
| 2102 | default: |
| 2103 | gb_backend_map = |
| 2104 | evergreen_get_tile_pipe_to_backend_map(rdev, |
| 2105 | rdev->config.evergreen.max_tile_pipes, |
| 2106 | rdev->config.evergreen.max_backends, |
| 2107 | ((EVERGREEN_MAX_BACKENDS_MASK << |
| 2108 | rdev->config.evergreen.max_backends) & |
| 2109 | EVERGREEN_MAX_BACKENDS_MASK)); |
| 2110 | } |
| 2111 | } |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2112 | |
Alex Deucher | 1aa52bd | 2010-11-17 12:11:03 -0500 | [diff] [blame] | 2113 | /* setup tiling info dword. gb_addr_config is not adequate since it does |
| 2114 | * not have bank info, so create a custom tiling dword. |
| 2115 | * bits 3:0 num_pipes |
| 2116 | * bits 7:4 num_banks |
| 2117 | * bits 11:8 group_size |
| 2118 | * bits 15:12 row_size |
| 2119 | */ |
| 2120 | rdev->config.evergreen.tile_config = 0; |
| 2121 | switch (rdev->config.evergreen.max_tile_pipes) { |
| 2122 | case 1: |
| 2123 | default: |
| 2124 | rdev->config.evergreen.tile_config |= (0 << 0); |
| 2125 | break; |
| 2126 | case 2: |
| 2127 | rdev->config.evergreen.tile_config |= (1 << 0); |
| 2128 | break; |
| 2129 | case 4: |
| 2130 | rdev->config.evergreen.tile_config |= (2 << 0); |
| 2131 | break; |
| 2132 | case 8: |
| 2133 | rdev->config.evergreen.tile_config |= (3 << 0); |
| 2134 | break; |
| 2135 | } |
Alex Deucher | d698a34 | 2011-06-23 00:49:29 -0400 | [diff] [blame] | 2136 | /* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */ |
Alex Deucher | 5bfa487 | 2011-05-20 12:35:22 -0400 | [diff] [blame] | 2137 | if (rdev->flags & RADEON_IS_IGP) |
Alex Deucher | d698a34 | 2011-06-23 00:49:29 -0400 | [diff] [blame] | 2138 | rdev->config.evergreen.tile_config |= 1 << 4; |
Alex Deucher | 5bfa487 | 2011-05-20 12:35:22 -0400 | [diff] [blame] | 2139 | else |
| 2140 | rdev->config.evergreen.tile_config |= |
| 2141 | ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4; |
Alex Deucher | 1aa52bd | 2010-11-17 12:11:03 -0500 | [diff] [blame] | 2142 | rdev->config.evergreen.tile_config |= |
| 2143 | ((mc_arb_ramcfg & BURSTLENGTH_MASK) >> BURSTLENGTH_SHIFT) << 8; |
| 2144 | rdev->config.evergreen.tile_config |= |
| 2145 | ((gb_addr_config & 0x30000000) >> 28) << 12; |
| 2146 | |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 2147 | rdev->config.evergreen.backend_map = gb_backend_map; |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2148 | WREG32(GB_BACKEND_MAP, gb_backend_map); |
| 2149 | WREG32(GB_ADDR_CONFIG, gb_addr_config); |
| 2150 | WREG32(DMIF_ADDR_CONFIG, gb_addr_config); |
| 2151 | WREG32(HDP_ADDR_CONFIG, gb_addr_config); |
| 2152 | |
| 2153 | num_shader_engines = ((RREG32(GB_ADDR_CONFIG) & NUM_SHADER_ENGINES(3)) >> 12) + 1; |
| 2154 | grbm_gfx_index = INSTANCE_BROADCAST_WRITES; |
| 2155 | |
| 2156 | for (i = 0; i < rdev->config.evergreen.num_ses; i++) { |
| 2157 | u32 rb = cc_rb_backend_disable | (0xf0 << 16); |
| 2158 | u32 sp = cc_gc_shader_pipe_config; |
| 2159 | u32 gfx = grbm_gfx_index | SE_INDEX(i); |
| 2160 | |
| 2161 | if (i == num_shader_engines) { |
| 2162 | rb |= BACKEND_DISABLE(EVERGREEN_MAX_BACKENDS_MASK); |
| 2163 | sp |= INACTIVE_SIMDS(EVERGREEN_MAX_SIMDS_MASK); |
| 2164 | } |
| 2165 | |
| 2166 | WREG32(GRBM_GFX_INDEX, gfx); |
| 2167 | WREG32(RLC_GFX_INDEX, gfx); |
| 2168 | |
| 2169 | WREG32(CC_RB_BACKEND_DISABLE, rb); |
| 2170 | WREG32(CC_SYS_RB_BACKEND_DISABLE, rb); |
| 2171 | WREG32(GC_USER_RB_BACKEND_DISABLE, rb); |
| 2172 | WREG32(CC_GC_SHADER_PIPE_CONFIG, sp); |
| 2173 | } |
| 2174 | |
| 2175 | grbm_gfx_index |= SE_BROADCAST_WRITES; |
| 2176 | WREG32(GRBM_GFX_INDEX, grbm_gfx_index); |
| 2177 | WREG32(RLC_GFX_INDEX, grbm_gfx_index); |
| 2178 | |
| 2179 | WREG32(CGTS_SYS_TCC_DISABLE, 0); |
| 2180 | WREG32(CGTS_TCC_DISABLE, 0); |
| 2181 | WREG32(CGTS_USER_SYS_TCC_DISABLE, 0); |
| 2182 | WREG32(CGTS_USER_TCC_DISABLE, 0); |
| 2183 | |
| 2184 | /* set HW defaults for 3D engine */ |
| 2185 | WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | |
| 2186 | ROQ_IB2_START(0x2b))); |
| 2187 | |
| 2188 | WREG32(CP_MEQ_THRESHOLDS, STQ_SPLIT(0x30)); |
| 2189 | |
| 2190 | WREG32(TA_CNTL_AUX, (DISABLE_CUBE_ANISO | |
| 2191 | SYNC_GRADIENT | |
| 2192 | SYNC_WALKER | |
| 2193 | SYNC_ALIGNER)); |
| 2194 | |
| 2195 | sx_debug_1 = RREG32(SX_DEBUG_1); |
| 2196 | sx_debug_1 |= ENABLE_NEW_SMX_ADDRESS; |
| 2197 | WREG32(SX_DEBUG_1, sx_debug_1); |
| 2198 | |
| 2199 | |
| 2200 | smx_dc_ctl0 = RREG32(SMX_DC_CTL0); |
| 2201 | smx_dc_ctl0 &= ~NUMBER_OF_SETS(0x1ff); |
| 2202 | smx_dc_ctl0 |= NUMBER_OF_SETS(rdev->config.evergreen.sx_num_of_sets); |
| 2203 | WREG32(SMX_DC_CTL0, smx_dc_ctl0); |
| 2204 | |
| 2205 | WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_size / 4) - 1) | |
| 2206 | POSITION_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_pos_size / 4) - 1) | |
| 2207 | SMX_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_smx_size / 4) - 1))); |
| 2208 | |
| 2209 | WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.evergreen.sc_prim_fifo_size) | |
| 2210 | SC_HIZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_hiz_tile_fifo_size) | |
| 2211 | SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_earlyz_tile_fifo_size))); |
| 2212 | |
| 2213 | WREG32(VGT_NUM_INSTANCES, 1); |
| 2214 | WREG32(SPI_CONFIG_CNTL, 0); |
| 2215 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4)); |
| 2216 | WREG32(CP_PERFMON_CNTL, 0); |
| 2217 | |
| 2218 | WREG32(SQ_MS_FIFO_SIZES, (CACHE_FIFO_SIZE(16 * rdev->config.evergreen.sq_num_cf_insts) | |
| 2219 | FETCH_FIFO_HIWATER(0x4) | |
| 2220 | DONE_FIFO_HIWATER(0xe0) | |
| 2221 | ALU_UPDATE_FIFO_HIWATER(0x8))); |
| 2222 | |
| 2223 | sq_config = RREG32(SQ_CONFIG); |
| 2224 | sq_config &= ~(PS_PRIO(3) | |
| 2225 | VS_PRIO(3) | |
| 2226 | GS_PRIO(3) | |
| 2227 | ES_PRIO(3)); |
| 2228 | sq_config |= (VC_ENABLE | |
| 2229 | EXPORT_SRC_C | |
| 2230 | PS_PRIO(0) | |
| 2231 | VS_PRIO(1) | |
| 2232 | GS_PRIO(2) | |
| 2233 | ES_PRIO(3)); |
| 2234 | |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2235 | switch (rdev->family) { |
| 2236 | case CHIP_CEDAR: |
| 2237 | case CHIP_PALM: |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 2238 | case CHIP_SUMO: |
| 2239 | case CHIP_SUMO2: |
Alex Deucher | adb68fa | 2011-01-06 21:19:24 -0500 | [diff] [blame] | 2240 | case CHIP_CAICOS: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2241 | /* no vertex cache */ |
| 2242 | sq_config &= ~VC_ENABLE; |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2243 | break; |
| 2244 | default: |
| 2245 | break; |
| 2246 | } |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2247 | |
| 2248 | sq_lds_resource_mgmt = RREG32(SQ_LDS_RESOURCE_MGMT); |
| 2249 | |
| 2250 | sq_gpr_resource_mgmt_1 = NUM_PS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2))* 12 / 32); |
| 2251 | sq_gpr_resource_mgmt_1 |= NUM_VS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 6 / 32); |
| 2252 | sq_gpr_resource_mgmt_1 |= NUM_CLAUSE_TEMP_GPRS(4); |
| 2253 | sq_gpr_resource_mgmt_2 = NUM_GS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 4 / 32); |
| 2254 | sq_gpr_resource_mgmt_2 |= NUM_ES_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 4 / 32); |
| 2255 | sq_gpr_resource_mgmt_3 = NUM_HS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 3 / 32); |
| 2256 | sq_gpr_resource_mgmt_3 |= NUM_LS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 3 / 32); |
| 2257 | |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2258 | switch (rdev->family) { |
| 2259 | case CHIP_CEDAR: |
| 2260 | case CHIP_PALM: |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 2261 | case CHIP_SUMO: |
| 2262 | case CHIP_SUMO2: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2263 | ps_thread_count = 96; |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2264 | break; |
| 2265 | default: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2266 | ps_thread_count = 128; |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2267 | break; |
| 2268 | } |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2269 | |
| 2270 | sq_thread_resource_mgmt = NUM_PS_THREADS(ps_thread_count); |
Alex Deucher | f96b35c | 2010-06-16 12:24:07 -0400 | [diff] [blame] | 2271 | sq_thread_resource_mgmt |= NUM_VS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8); |
| 2272 | sq_thread_resource_mgmt |= NUM_GS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8); |
| 2273 | sq_thread_resource_mgmt |= NUM_ES_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8); |
| 2274 | sq_thread_resource_mgmt_2 = NUM_HS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8); |
| 2275 | sq_thread_resource_mgmt_2 |= NUM_LS_THREADS((((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8); |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2276 | |
| 2277 | sq_stack_resource_mgmt_1 = NUM_PS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); |
| 2278 | sq_stack_resource_mgmt_1 |= NUM_VS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); |
| 2279 | sq_stack_resource_mgmt_2 = NUM_GS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); |
| 2280 | sq_stack_resource_mgmt_2 |= NUM_ES_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); |
| 2281 | sq_stack_resource_mgmt_3 = NUM_HS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); |
| 2282 | sq_stack_resource_mgmt_3 |= NUM_LS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); |
| 2283 | |
| 2284 | WREG32(SQ_CONFIG, sq_config); |
| 2285 | WREG32(SQ_GPR_RESOURCE_MGMT_1, sq_gpr_resource_mgmt_1); |
| 2286 | WREG32(SQ_GPR_RESOURCE_MGMT_2, sq_gpr_resource_mgmt_2); |
| 2287 | WREG32(SQ_GPR_RESOURCE_MGMT_3, sq_gpr_resource_mgmt_3); |
| 2288 | WREG32(SQ_THREAD_RESOURCE_MGMT, sq_thread_resource_mgmt); |
| 2289 | WREG32(SQ_THREAD_RESOURCE_MGMT_2, sq_thread_resource_mgmt_2); |
| 2290 | WREG32(SQ_STACK_RESOURCE_MGMT_1, sq_stack_resource_mgmt_1); |
| 2291 | WREG32(SQ_STACK_RESOURCE_MGMT_2, sq_stack_resource_mgmt_2); |
| 2292 | WREG32(SQ_STACK_RESOURCE_MGMT_3, sq_stack_resource_mgmt_3); |
| 2293 | WREG32(SQ_DYN_GPR_CNTL_PS_FLUSH_REQ, 0); |
| 2294 | WREG32(SQ_LDS_RESOURCE_MGMT, sq_lds_resource_mgmt); |
| 2295 | |
| 2296 | WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) | |
| 2297 | FORCE_EOV_MAX_REZ_CNT(255))); |
| 2298 | |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2299 | switch (rdev->family) { |
| 2300 | case CHIP_CEDAR: |
| 2301 | case CHIP_PALM: |
Alex Deucher | d5c5a72 | 2011-05-31 15:42:48 -0400 | [diff] [blame] | 2302 | case CHIP_SUMO: |
| 2303 | case CHIP_SUMO2: |
Alex Deucher | adb68fa | 2011-01-06 21:19:24 -0500 | [diff] [blame] | 2304 | case CHIP_CAICOS: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2305 | vgt_cache_invalidation = CACHE_INVALIDATION(TC_ONLY); |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2306 | break; |
| 2307 | default: |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2308 | vgt_cache_invalidation = CACHE_INVALIDATION(VC_AND_TC); |
Alex Deucher | d5e455e | 2010-11-22 17:56:29 -0500 | [diff] [blame] | 2309 | break; |
| 2310 | } |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2311 | vgt_cache_invalidation |= AUTO_INVLD_EN(ES_AND_GS_AUTO); |
| 2312 | WREG32(VGT_CACHE_INVALIDATION, vgt_cache_invalidation); |
| 2313 | |
| 2314 | WREG32(VGT_GS_VERTEX_REUSE, 16); |
Alex Deucher | 1292059 | 2011-02-02 12:37:40 -0500 | [diff] [blame] | 2315 | WREG32(PA_SU_LINE_STIPPLE_VALUE, 0); |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2316 | WREG32(PA_SC_LINE_STIPPLE_STATE, 0); |
| 2317 | |
Alex Deucher | 60a4a3e | 2010-06-29 17:03:35 -0400 | [diff] [blame] | 2318 | WREG32(VGT_VERTEX_REUSE_BLOCK_CNTL, 14); |
| 2319 | WREG32(VGT_OUT_DEALLOC_CNTL, 16); |
| 2320 | |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2321 | WREG32(CB_PERF_CTR0_SEL_0, 0); |
| 2322 | WREG32(CB_PERF_CTR0_SEL_1, 0); |
| 2323 | WREG32(CB_PERF_CTR1_SEL_0, 0); |
| 2324 | WREG32(CB_PERF_CTR1_SEL_1, 0); |
| 2325 | WREG32(CB_PERF_CTR2_SEL_0, 0); |
| 2326 | WREG32(CB_PERF_CTR2_SEL_1, 0); |
| 2327 | WREG32(CB_PERF_CTR3_SEL_0, 0); |
| 2328 | WREG32(CB_PERF_CTR3_SEL_1, 0); |
| 2329 | |
Alex Deucher | 60a4a3e | 2010-06-29 17:03:35 -0400 | [diff] [blame] | 2330 | /* clear render buffer base addresses */ |
| 2331 | WREG32(CB_COLOR0_BASE, 0); |
| 2332 | WREG32(CB_COLOR1_BASE, 0); |
| 2333 | WREG32(CB_COLOR2_BASE, 0); |
| 2334 | WREG32(CB_COLOR3_BASE, 0); |
| 2335 | WREG32(CB_COLOR4_BASE, 0); |
| 2336 | WREG32(CB_COLOR5_BASE, 0); |
| 2337 | WREG32(CB_COLOR6_BASE, 0); |
| 2338 | WREG32(CB_COLOR7_BASE, 0); |
| 2339 | WREG32(CB_COLOR8_BASE, 0); |
| 2340 | WREG32(CB_COLOR9_BASE, 0); |
| 2341 | WREG32(CB_COLOR10_BASE, 0); |
| 2342 | WREG32(CB_COLOR11_BASE, 0); |
| 2343 | |
| 2344 | /* set the shader const cache sizes to 0 */ |
| 2345 | for (i = SQ_ALU_CONST_BUFFER_SIZE_PS_0; i < 0x28200; i += 4) |
| 2346 | WREG32(i, 0); |
| 2347 | for (i = SQ_ALU_CONST_BUFFER_SIZE_HS_0; i < 0x29000; i += 4) |
| 2348 | WREG32(i, 0); |
| 2349 | |
Alex Deucher | f25a5c6 | 2011-05-19 11:07:57 -0400 | [diff] [blame] | 2350 | tmp = RREG32(HDP_MISC_CNTL); |
| 2351 | tmp |= HDP_FLUSH_INVALIDATE_CACHE; |
| 2352 | WREG32(HDP_MISC_CNTL, tmp); |
| 2353 | |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 2354 | hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); |
| 2355 | WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); |
| 2356 | |
| 2357 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); |
| 2358 | |
| 2359 | udelay(50); |
| 2360 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2361 | } |
| 2362 | |
| 2363 | int evergreen_mc_init(struct radeon_device *rdev) |
| 2364 | { |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2365 | u32 tmp; |
| 2366 | int chansize, numchan; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2367 | |
| 2368 | /* Get VRAM informations */ |
| 2369 | rdev->mc.vram_is_ddr = true; |
Alex Deucher | 05b3ef6 | 2012-03-20 17:18:37 -0400 | [diff] [blame] | 2370 | if ((rdev->family == CHIP_PALM) || |
| 2371 | (rdev->family == CHIP_SUMO) || |
| 2372 | (rdev->family == CHIP_SUMO2)) |
Alex Deucher | 8208441 | 2011-07-01 13:18:28 -0400 | [diff] [blame] | 2373 | tmp = RREG32(FUS_MC_ARB_RAMCFG); |
| 2374 | else |
| 2375 | tmp = RREG32(MC_ARB_RAMCFG); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2376 | if (tmp & CHANSIZE_OVERRIDE) { |
| 2377 | chansize = 16; |
| 2378 | } else if (tmp & CHANSIZE_MASK) { |
| 2379 | chansize = 64; |
| 2380 | } else { |
| 2381 | chansize = 32; |
| 2382 | } |
| 2383 | tmp = RREG32(MC_SHARED_CHMAP); |
| 2384 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 2385 | case 0: |
| 2386 | default: |
| 2387 | numchan = 1; |
| 2388 | break; |
| 2389 | case 1: |
| 2390 | numchan = 2; |
| 2391 | break; |
| 2392 | case 2: |
| 2393 | numchan = 4; |
| 2394 | break; |
| 2395 | case 3: |
| 2396 | numchan = 8; |
| 2397 | break; |
| 2398 | } |
| 2399 | rdev->mc.vram_width = numchan * chansize; |
| 2400 | /* Could aper size report 0 ? */ |
Jordan Crouse | 01d73a6 | 2010-05-27 13:40:24 -0600 | [diff] [blame] | 2401 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
| 2402 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2403 | /* Setup GPU memory space */ |
Alex Deucher | 05b3ef6 | 2012-03-20 17:18:37 -0400 | [diff] [blame] | 2404 | if ((rdev->family == CHIP_PALM) || |
| 2405 | (rdev->family == CHIP_SUMO) || |
| 2406 | (rdev->family == CHIP_SUMO2)) { |
Alex Deucher | 6eb18f8 | 2010-11-22 17:56:27 -0500 | [diff] [blame] | 2407 | /* size in bytes on fusion */ |
| 2408 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); |
| 2409 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); |
| 2410 | } else { |
Alex Deucher | 05b3ef6 | 2012-03-20 17:18:37 -0400 | [diff] [blame] | 2411 | /* size in MB on evergreen/cayman/tn */ |
Alex Deucher | 6eb18f8 | 2010-11-22 17:56:27 -0500 | [diff] [blame] | 2412 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; |
| 2413 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; |
| 2414 | } |
Jerome Glisse | 51e5fcd | 2010-02-19 14:33:54 +0000 | [diff] [blame] | 2415 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
Alex Deucher | 0ef0c1f | 2010-11-22 17:56:26 -0500 | [diff] [blame] | 2416 | r700_vram_gtt_location(rdev, &rdev->mc); |
Alex Deucher | f47299c | 2010-03-16 20:54:38 -0400 | [diff] [blame] | 2417 | radeon_update_bandwidth_info(rdev); |
| 2418 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2419 | return 0; |
| 2420 | } |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 2421 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 2422 | bool evergreen_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring) |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 2423 | { |
Alex Deucher | 17db704 | 2010-12-21 16:05:39 -0500 | [diff] [blame] | 2424 | u32 srbm_status; |
| 2425 | u32 grbm_status; |
| 2426 | u32 grbm_status_se0, grbm_status_se1; |
Alex Deucher | 17db704 | 2010-12-21 16:05:39 -0500 | [diff] [blame] | 2427 | |
| 2428 | srbm_status = RREG32(SRBM_STATUS); |
| 2429 | grbm_status = RREG32(GRBM_STATUS); |
| 2430 | grbm_status_se0 = RREG32(GRBM_STATUS_SE0); |
| 2431 | grbm_status_se1 = RREG32(GRBM_STATUS_SE1); |
| 2432 | if (!(grbm_status & GUI_ACTIVE)) { |
Christian König | 069211e | 2012-05-02 15:11:20 +0200 | [diff] [blame] | 2433 | radeon_ring_lockup_update(ring); |
Alex Deucher | 17db704 | 2010-12-21 16:05:39 -0500 | [diff] [blame] | 2434 | return false; |
| 2435 | } |
| 2436 | /* force CP activities */ |
Christian König | 7b9ef16 | 2012-05-02 15:11:23 +0200 | [diff] [blame^] | 2437 | radeon_ring_force_activity(rdev, ring); |
Christian König | 069211e | 2012-05-02 15:11:20 +0200 | [diff] [blame] | 2438 | return radeon_ring_test_lockup(rdev, ring); |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 2439 | } |
| 2440 | |
Alex Deucher | 747943e | 2010-03-24 13:26:36 -0400 | [diff] [blame] | 2441 | static int evergreen_gpu_soft_reset(struct radeon_device *rdev) |
| 2442 | { |
| 2443 | struct evergreen_mc_save save; |
Alex Deucher | 747943e | 2010-03-24 13:26:36 -0400 | [diff] [blame] | 2444 | u32 grbm_reset = 0; |
| 2445 | |
Alex Deucher | 8d96fe9 | 2011-01-21 15:38:22 +0000 | [diff] [blame] | 2446 | if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE)) |
| 2447 | return 0; |
| 2448 | |
Alex Deucher | 747943e | 2010-03-24 13:26:36 -0400 | [diff] [blame] | 2449 | dev_info(rdev->dev, "GPU softreset \n"); |
| 2450 | dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", |
| 2451 | RREG32(GRBM_STATUS)); |
| 2452 | dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n", |
| 2453 | RREG32(GRBM_STATUS_SE0)); |
| 2454 | dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n", |
| 2455 | RREG32(GRBM_STATUS_SE1)); |
| 2456 | dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", |
| 2457 | RREG32(SRBM_STATUS)); |
| 2458 | evergreen_mc_stop(rdev, &save); |
| 2459 | if (evergreen_mc_wait_for_idle(rdev)) { |
| 2460 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 2461 | } |
| 2462 | /* Disable CP parsing/prefetching */ |
| 2463 | WREG32(CP_ME_CNTL, CP_ME_HALT | CP_PFP_HALT); |
| 2464 | |
| 2465 | /* reset all the gfx blocks */ |
| 2466 | grbm_reset = (SOFT_RESET_CP | |
| 2467 | SOFT_RESET_CB | |
| 2468 | SOFT_RESET_DB | |
| 2469 | SOFT_RESET_PA | |
| 2470 | SOFT_RESET_SC | |
| 2471 | SOFT_RESET_SPI | |
| 2472 | SOFT_RESET_SH | |
| 2473 | SOFT_RESET_SX | |
| 2474 | SOFT_RESET_TC | |
| 2475 | SOFT_RESET_TA | |
| 2476 | SOFT_RESET_VC | |
| 2477 | SOFT_RESET_VGT); |
| 2478 | |
| 2479 | dev_info(rdev->dev, " GRBM_SOFT_RESET=0x%08X\n", grbm_reset); |
| 2480 | WREG32(GRBM_SOFT_RESET, grbm_reset); |
| 2481 | (void)RREG32(GRBM_SOFT_RESET); |
| 2482 | udelay(50); |
| 2483 | WREG32(GRBM_SOFT_RESET, 0); |
| 2484 | (void)RREG32(GRBM_SOFT_RESET); |
Alex Deucher | 747943e | 2010-03-24 13:26:36 -0400 | [diff] [blame] | 2485 | /* Wait a little for things to settle down */ |
| 2486 | udelay(50); |
| 2487 | dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", |
| 2488 | RREG32(GRBM_STATUS)); |
| 2489 | dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n", |
| 2490 | RREG32(GRBM_STATUS_SE0)); |
| 2491 | dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n", |
| 2492 | RREG32(GRBM_STATUS_SE1)); |
| 2493 | dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", |
| 2494 | RREG32(SRBM_STATUS)); |
Alex Deucher | 747943e | 2010-03-24 13:26:36 -0400 | [diff] [blame] | 2495 | evergreen_mc_resume(rdev, &save); |
| 2496 | return 0; |
| 2497 | } |
| 2498 | |
Jerome Glisse | a2d07b7 | 2010-03-09 14:45:11 +0000 | [diff] [blame] | 2499 | int evergreen_asic_reset(struct radeon_device *rdev) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2500 | { |
Alex Deucher | 747943e | 2010-03-24 13:26:36 -0400 | [diff] [blame] | 2501 | return evergreen_gpu_soft_reset(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2502 | } |
| 2503 | |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2504 | /* Interrupts */ |
| 2505 | |
| 2506 | u32 evergreen_get_vblank_counter(struct radeon_device *rdev, int crtc) |
| 2507 | { |
| 2508 | switch (crtc) { |
| 2509 | case 0: |
| 2510 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC0_REGISTER_OFFSET); |
| 2511 | case 1: |
| 2512 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC1_REGISTER_OFFSET); |
| 2513 | case 2: |
| 2514 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC2_REGISTER_OFFSET); |
| 2515 | case 3: |
| 2516 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC3_REGISTER_OFFSET); |
| 2517 | case 4: |
| 2518 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC4_REGISTER_OFFSET); |
| 2519 | case 5: |
| 2520 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC5_REGISTER_OFFSET); |
| 2521 | default: |
| 2522 | return 0; |
| 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | void evergreen_disable_interrupt_state(struct radeon_device *rdev) |
| 2527 | { |
| 2528 | u32 tmp; |
| 2529 | |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 2530 | if (rdev->family >= CHIP_CAYMAN) { |
| 2531 | cayman_cp_int_cntl_setup(rdev, 0, |
| 2532 | CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 2533 | cayman_cp_int_cntl_setup(rdev, 1, 0); |
| 2534 | cayman_cp_int_cntl_setup(rdev, 2, 0); |
| 2535 | } else |
| 2536 | WREG32(CP_INT_CNTL, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2537 | WREG32(GRBM_INT_CNTL, 0); |
| 2538 | WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 2539 | WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2540 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 2541 | WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 2542 | WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2543 | } |
| 2544 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 2545 | WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 2546 | WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 2547 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2548 | |
| 2549 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 2550 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2551 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 2552 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 2553 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2554 | } |
| 2555 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 2556 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 2557 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 2558 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2559 | |
Alex Deucher | 05b3ef6 | 2012-03-20 17:18:37 -0400 | [diff] [blame] | 2560 | /* only one DAC on DCE6 */ |
| 2561 | if (!ASIC_IS_DCE6(rdev)) |
| 2562 | WREG32(DACA_AUTODETECT_INT_CONTROL, 0); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2563 | WREG32(DACB_AUTODETECT_INT_CONTROL, 0); |
| 2564 | |
| 2565 | tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 2566 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 2567 | tmp = RREG32(DC_HPD2_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 2568 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 2569 | tmp = RREG32(DC_HPD3_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 2570 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 2571 | tmp = RREG32(DC_HPD4_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 2572 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 2573 | tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 2574 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 2575 | tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 2576 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 2577 | |
| 2578 | } |
| 2579 | |
| 2580 | int evergreen_irq_set(struct radeon_device *rdev) |
| 2581 | { |
| 2582 | u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE; |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 2583 | u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2584 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; |
| 2585 | u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6; |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 2586 | u32 grbm_int_cntl = 0; |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2587 | u32 grph1 = 0, grph2 = 0, grph3 = 0, grph4 = 0, grph5 = 0, grph6 = 0; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2588 | u32 afmt1 = 0, afmt2 = 0, afmt3 = 0, afmt4 = 0, afmt5 = 0, afmt6 = 0; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2589 | |
| 2590 | if (!rdev->irq.installed) { |
Joe Perches | fce7d61 | 2010-10-30 21:08:30 +0000 | [diff] [blame] | 2591 | WARN(1, "Can't enable IRQ/MSI because no handler is installed\n"); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2592 | return -EINVAL; |
| 2593 | } |
| 2594 | /* don't enable anything if the ih is disabled */ |
| 2595 | if (!rdev->ih.enabled) { |
| 2596 | r600_disable_interrupts(rdev); |
| 2597 | /* force the active interrupt state to all disabled */ |
| 2598 | evergreen_disable_interrupt_state(rdev); |
| 2599 | return 0; |
| 2600 | } |
| 2601 | |
| 2602 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 2603 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 2604 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 2605 | hpd4 = RREG32(DC_HPD4_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 2606 | hpd5 = RREG32(DC_HPD5_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 2607 | hpd6 = RREG32(DC_HPD6_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 2608 | |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2609 | afmt1 = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2610 | afmt2 = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2611 | afmt3 = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2612 | afmt4 = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2613 | afmt5 = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2614 | afmt6 = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET) & ~AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2615 | |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 2616 | if (rdev->family >= CHIP_CAYMAN) { |
| 2617 | /* enable CP interrupts on all rings */ |
| 2618 | if (rdev->irq.sw_int[RADEON_RING_TYPE_GFX_INDEX]) { |
| 2619 | DRM_DEBUG("evergreen_irq_set: sw int gfx\n"); |
| 2620 | cp_int_cntl |= TIME_STAMP_INT_ENABLE; |
| 2621 | } |
| 2622 | if (rdev->irq.sw_int[CAYMAN_RING_TYPE_CP1_INDEX]) { |
| 2623 | DRM_DEBUG("evergreen_irq_set: sw int cp1\n"); |
| 2624 | cp_int_cntl1 |= TIME_STAMP_INT_ENABLE; |
| 2625 | } |
| 2626 | if (rdev->irq.sw_int[CAYMAN_RING_TYPE_CP2_INDEX]) { |
| 2627 | DRM_DEBUG("evergreen_irq_set: sw int cp2\n"); |
| 2628 | cp_int_cntl2 |= TIME_STAMP_INT_ENABLE; |
| 2629 | } |
| 2630 | } else { |
| 2631 | if (rdev->irq.sw_int[RADEON_RING_TYPE_GFX_INDEX]) { |
| 2632 | DRM_DEBUG("evergreen_irq_set: sw int gfx\n"); |
| 2633 | cp_int_cntl |= RB_INT_ENABLE; |
| 2634 | cp_int_cntl |= TIME_STAMP_INT_ENABLE; |
| 2635 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2636 | } |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 2637 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2638 | if (rdev->irq.crtc_vblank_int[0] || |
| 2639 | rdev->irq.pflip[0]) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2640 | DRM_DEBUG("evergreen_irq_set: vblank 0\n"); |
| 2641 | crtc1 |= VBLANK_INT_MASK; |
| 2642 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2643 | if (rdev->irq.crtc_vblank_int[1] || |
| 2644 | rdev->irq.pflip[1]) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2645 | DRM_DEBUG("evergreen_irq_set: vblank 1\n"); |
| 2646 | crtc2 |= VBLANK_INT_MASK; |
| 2647 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2648 | if (rdev->irq.crtc_vblank_int[2] || |
| 2649 | rdev->irq.pflip[2]) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2650 | DRM_DEBUG("evergreen_irq_set: vblank 2\n"); |
| 2651 | crtc3 |= VBLANK_INT_MASK; |
| 2652 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2653 | if (rdev->irq.crtc_vblank_int[3] || |
| 2654 | rdev->irq.pflip[3]) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2655 | DRM_DEBUG("evergreen_irq_set: vblank 3\n"); |
| 2656 | crtc4 |= VBLANK_INT_MASK; |
| 2657 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2658 | if (rdev->irq.crtc_vblank_int[4] || |
| 2659 | rdev->irq.pflip[4]) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2660 | DRM_DEBUG("evergreen_irq_set: vblank 4\n"); |
| 2661 | crtc5 |= VBLANK_INT_MASK; |
| 2662 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2663 | if (rdev->irq.crtc_vblank_int[5] || |
| 2664 | rdev->irq.pflip[5]) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2665 | DRM_DEBUG("evergreen_irq_set: vblank 5\n"); |
| 2666 | crtc6 |= VBLANK_INT_MASK; |
| 2667 | } |
| 2668 | if (rdev->irq.hpd[0]) { |
| 2669 | DRM_DEBUG("evergreen_irq_set: hpd 1\n"); |
| 2670 | hpd1 |= DC_HPDx_INT_EN; |
| 2671 | } |
| 2672 | if (rdev->irq.hpd[1]) { |
| 2673 | DRM_DEBUG("evergreen_irq_set: hpd 2\n"); |
| 2674 | hpd2 |= DC_HPDx_INT_EN; |
| 2675 | } |
| 2676 | if (rdev->irq.hpd[2]) { |
| 2677 | DRM_DEBUG("evergreen_irq_set: hpd 3\n"); |
| 2678 | hpd3 |= DC_HPDx_INT_EN; |
| 2679 | } |
| 2680 | if (rdev->irq.hpd[3]) { |
| 2681 | DRM_DEBUG("evergreen_irq_set: hpd 4\n"); |
| 2682 | hpd4 |= DC_HPDx_INT_EN; |
| 2683 | } |
| 2684 | if (rdev->irq.hpd[4]) { |
| 2685 | DRM_DEBUG("evergreen_irq_set: hpd 5\n"); |
| 2686 | hpd5 |= DC_HPDx_INT_EN; |
| 2687 | } |
| 2688 | if (rdev->irq.hpd[5]) { |
| 2689 | DRM_DEBUG("evergreen_irq_set: hpd 6\n"); |
| 2690 | hpd6 |= DC_HPDx_INT_EN; |
| 2691 | } |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2692 | if (rdev->irq.afmt[0]) { |
| 2693 | DRM_DEBUG("evergreen_irq_set: hdmi 0\n"); |
| 2694 | afmt1 |= AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2695 | } |
| 2696 | if (rdev->irq.afmt[1]) { |
| 2697 | DRM_DEBUG("evergreen_irq_set: hdmi 1\n"); |
| 2698 | afmt2 |= AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2699 | } |
| 2700 | if (rdev->irq.afmt[2]) { |
| 2701 | DRM_DEBUG("evergreen_irq_set: hdmi 2\n"); |
| 2702 | afmt3 |= AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2703 | } |
| 2704 | if (rdev->irq.afmt[3]) { |
| 2705 | DRM_DEBUG("evergreen_irq_set: hdmi 3\n"); |
| 2706 | afmt4 |= AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2707 | } |
| 2708 | if (rdev->irq.afmt[4]) { |
| 2709 | DRM_DEBUG("evergreen_irq_set: hdmi 4\n"); |
| 2710 | afmt5 |= AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2711 | } |
| 2712 | if (rdev->irq.afmt[5]) { |
| 2713 | DRM_DEBUG("evergreen_irq_set: hdmi 5\n"); |
| 2714 | afmt6 |= AFMT_AZ_FORMAT_WTRIG_MASK; |
| 2715 | } |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 2716 | if (rdev->irq.gui_idle) { |
| 2717 | DRM_DEBUG("gui idle\n"); |
| 2718 | grbm_int_cntl |= GUI_IDLE_INT_ENABLE; |
| 2719 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2720 | |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 2721 | if (rdev->family >= CHIP_CAYMAN) { |
| 2722 | cayman_cp_int_cntl_setup(rdev, 0, cp_int_cntl); |
| 2723 | cayman_cp_int_cntl_setup(rdev, 1, cp_int_cntl1); |
| 2724 | cayman_cp_int_cntl_setup(rdev, 2, cp_int_cntl2); |
| 2725 | } else |
| 2726 | WREG32(CP_INT_CNTL, cp_int_cntl); |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 2727 | WREG32(GRBM_INT_CNTL, grbm_int_cntl); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2728 | |
| 2729 | WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, crtc1); |
| 2730 | WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, crtc2); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2731 | if (rdev->num_crtc >= 4) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 2732 | WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, crtc3); |
| 2733 | WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, crtc4); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2734 | } |
| 2735 | if (rdev->num_crtc >= 6) { |
Alex Deucher | 1800740 | 2010-11-22 17:56:28 -0500 | [diff] [blame] | 2736 | WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, crtc5); |
| 2737 | WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, crtc6); |
| 2738 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2739 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2740 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, grph1); |
| 2741 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, grph2); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2742 | if (rdev->num_crtc >= 4) { |
| 2743 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, grph3); |
| 2744 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, grph4); |
| 2745 | } |
| 2746 | if (rdev->num_crtc >= 6) { |
| 2747 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, grph5); |
| 2748 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, grph6); |
| 2749 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2750 | |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2751 | WREG32(DC_HPD1_INT_CONTROL, hpd1); |
| 2752 | WREG32(DC_HPD2_INT_CONTROL, hpd2); |
| 2753 | WREG32(DC_HPD3_INT_CONTROL, hpd3); |
| 2754 | WREG32(DC_HPD4_INT_CONTROL, hpd4); |
| 2755 | WREG32(DC_HPD5_INT_CONTROL, hpd5); |
| 2756 | WREG32(DC_HPD6_INT_CONTROL, hpd6); |
| 2757 | |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2758 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, afmt1); |
| 2759 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, afmt2); |
| 2760 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, afmt3); |
| 2761 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, afmt4); |
| 2762 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, afmt5); |
| 2763 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, afmt6); |
| 2764 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 2765 | return 0; |
| 2766 | } |
| 2767 | |
Andi Kleen | cbdd450 | 2011-10-13 16:08:46 -0700 | [diff] [blame] | 2768 | static void evergreen_irq_ack(struct radeon_device *rdev) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2769 | { |
| 2770 | u32 tmp; |
| 2771 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2772 | rdev->irq.stat_regs.evergreen.disp_int = RREG32(DISP_INTERRUPT_STATUS); |
| 2773 | rdev->irq.stat_regs.evergreen.disp_int_cont = RREG32(DISP_INTERRUPT_STATUS_CONTINUE); |
| 2774 | rdev->irq.stat_regs.evergreen.disp_int_cont2 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE2); |
| 2775 | rdev->irq.stat_regs.evergreen.disp_int_cont3 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE3); |
| 2776 | rdev->irq.stat_regs.evergreen.disp_int_cont4 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE4); |
| 2777 | rdev->irq.stat_regs.evergreen.disp_int_cont5 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE5); |
| 2778 | rdev->irq.stat_regs.evergreen.d1grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET); |
| 2779 | rdev->irq.stat_regs.evergreen.d2grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET); |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2780 | if (rdev->num_crtc >= 4) { |
| 2781 | rdev->irq.stat_regs.evergreen.d3grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET); |
| 2782 | rdev->irq.stat_regs.evergreen.d4grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET); |
| 2783 | } |
| 2784 | if (rdev->num_crtc >= 6) { |
| 2785 | rdev->irq.stat_regs.evergreen.d5grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET); |
| 2786 | rdev->irq.stat_regs.evergreen.d6grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET); |
| 2787 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2788 | |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2789 | rdev->irq.stat_regs.evergreen.afmt_status1 = RREG32(AFMT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET); |
| 2790 | rdev->irq.stat_regs.evergreen.afmt_status2 = RREG32(AFMT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET); |
| 2791 | rdev->irq.stat_regs.evergreen.afmt_status3 = RREG32(AFMT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET); |
| 2792 | rdev->irq.stat_regs.evergreen.afmt_status4 = RREG32(AFMT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET); |
| 2793 | rdev->irq.stat_regs.evergreen.afmt_status5 = RREG32(AFMT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET); |
| 2794 | rdev->irq.stat_regs.evergreen.afmt_status6 = RREG32(AFMT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET); |
| 2795 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2796 | if (rdev->irq.stat_regs.evergreen.d1grph_int & GRPH_PFLIP_INT_OCCURRED) |
| 2797 | WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); |
| 2798 | if (rdev->irq.stat_regs.evergreen.d2grph_int & GRPH_PFLIP_INT_OCCURRED) |
| 2799 | WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2800 | if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2801 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VBLANK_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2802 | if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2803 | WREG32(VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VLINE_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2804 | if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2805 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VBLANK_ACK); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2806 | if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2807 | WREG32(VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VLINE_ACK); |
| 2808 | |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2809 | if (rdev->num_crtc >= 4) { |
| 2810 | if (rdev->irq.stat_regs.evergreen.d3grph_int & GRPH_PFLIP_INT_OCCURRED) |
| 2811 | WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); |
| 2812 | if (rdev->irq.stat_regs.evergreen.d4grph_int & GRPH_PFLIP_INT_OCCURRED) |
| 2813 | WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); |
| 2814 | if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) |
| 2815 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK); |
| 2816 | if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) |
| 2817 | WREG32(VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK); |
| 2818 | if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) |
| 2819 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK); |
| 2820 | if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) |
| 2821 | WREG32(VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK); |
| 2822 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2823 | |
Alex Deucher | b7eff39 | 2011-07-08 11:44:56 -0400 | [diff] [blame] | 2824 | if (rdev->num_crtc >= 6) { |
| 2825 | if (rdev->irq.stat_regs.evergreen.d5grph_int & GRPH_PFLIP_INT_OCCURRED) |
| 2826 | WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); |
| 2827 | if (rdev->irq.stat_regs.evergreen.d6grph_int & GRPH_PFLIP_INT_OCCURRED) |
| 2828 | WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); |
| 2829 | if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) |
| 2830 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK); |
| 2831 | if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) |
| 2832 | WREG32(VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK); |
| 2833 | if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) |
| 2834 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK); |
| 2835 | if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) |
| 2836 | WREG32(VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK); |
| 2837 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2838 | |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2839 | if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2840 | tmp = RREG32(DC_HPD1_INT_CONTROL); |
| 2841 | tmp |= DC_HPDx_INT_ACK; |
| 2842 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 2843 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2844 | if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2845 | tmp = RREG32(DC_HPD2_INT_CONTROL); |
| 2846 | tmp |= DC_HPDx_INT_ACK; |
| 2847 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 2848 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2849 | if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2850 | tmp = RREG32(DC_HPD3_INT_CONTROL); |
| 2851 | tmp |= DC_HPDx_INT_ACK; |
| 2852 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 2853 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2854 | if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2855 | tmp = RREG32(DC_HPD4_INT_CONTROL); |
| 2856 | tmp |= DC_HPDx_INT_ACK; |
| 2857 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 2858 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2859 | if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2860 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 2861 | tmp |= DC_HPDx_INT_ACK; |
| 2862 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 2863 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2864 | if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT) { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2865 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 2866 | tmp |= DC_HPDx_INT_ACK; |
| 2867 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 2868 | } |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2869 | if (rdev->irq.stat_regs.evergreen.afmt_status1 & AFMT_AZ_FORMAT_WTRIG) { |
| 2870 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET); |
| 2871 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
| 2872 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, tmp); |
| 2873 | } |
| 2874 | if (rdev->irq.stat_regs.evergreen.afmt_status2 & AFMT_AZ_FORMAT_WTRIG) { |
| 2875 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET); |
| 2876 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
| 2877 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, tmp); |
| 2878 | } |
| 2879 | if (rdev->irq.stat_regs.evergreen.afmt_status3 & AFMT_AZ_FORMAT_WTRIG) { |
| 2880 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET); |
| 2881 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
| 2882 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, tmp); |
| 2883 | } |
| 2884 | if (rdev->irq.stat_regs.evergreen.afmt_status4 & AFMT_AZ_FORMAT_WTRIG) { |
| 2885 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET); |
| 2886 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
| 2887 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, tmp); |
| 2888 | } |
| 2889 | if (rdev->irq.stat_regs.evergreen.afmt_status5 & AFMT_AZ_FORMAT_WTRIG) { |
| 2890 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET); |
| 2891 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
| 2892 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, tmp); |
| 2893 | } |
| 2894 | if (rdev->irq.stat_regs.evergreen.afmt_status6 & AFMT_AZ_FORMAT_WTRIG) { |
| 2895 | tmp = RREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET); |
| 2896 | tmp |= AFMT_AZ_FORMAT_WTRIG_ACK; |
| 2897 | WREG32(AFMT_AUDIO_PACKET_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, tmp); |
| 2898 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2899 | } |
| 2900 | |
| 2901 | void evergreen_irq_disable(struct radeon_device *rdev) |
| 2902 | { |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2903 | r600_disable_interrupts(rdev); |
| 2904 | /* Wait and acknowledge irq */ |
| 2905 | mdelay(1); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2906 | evergreen_irq_ack(rdev); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2907 | evergreen_disable_interrupt_state(rdev); |
| 2908 | } |
| 2909 | |
Alex Deucher | 755d819 | 2011-03-02 20:07:34 -0500 | [diff] [blame] | 2910 | void evergreen_irq_suspend(struct radeon_device *rdev) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2911 | { |
| 2912 | evergreen_irq_disable(rdev); |
| 2913 | r600_rlc_stop(rdev); |
| 2914 | } |
| 2915 | |
Andi Kleen | cbdd450 | 2011-10-13 16:08:46 -0700 | [diff] [blame] | 2916 | static u32 evergreen_get_ih_wptr(struct radeon_device *rdev) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2917 | { |
| 2918 | u32 wptr, tmp; |
| 2919 | |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 2920 | if (rdev->wb.enabled) |
Cédric Cano | 204ae24 | 2011-04-19 11:07:13 -0400 | [diff] [blame] | 2921 | 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] | 2922 | else |
| 2923 | wptr = RREG32(IH_RB_WPTR); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2924 | |
| 2925 | if (wptr & RB_OVERFLOW) { |
| 2926 | /* When a ring buffer overflow happen start parsing interrupt |
| 2927 | * from the last not overwritten vector (wptr + 16). Hopefully |
| 2928 | * this should allow us to catchup. |
| 2929 | */ |
| 2930 | dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n", |
| 2931 | wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask); |
| 2932 | rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask; |
| 2933 | tmp = RREG32(IH_RB_CNTL); |
| 2934 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 2935 | WREG32(IH_RB_CNTL, tmp); |
| 2936 | } |
| 2937 | return (wptr & rdev->ih.ptr_mask); |
| 2938 | } |
| 2939 | |
| 2940 | int evergreen_irq_process(struct radeon_device *rdev) |
| 2941 | { |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 2942 | u32 wptr; |
| 2943 | u32 rptr; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2944 | u32 src_id, src_data; |
| 2945 | u32 ring_index; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2946 | unsigned long flags; |
| 2947 | bool queue_hotplug = false; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 2948 | bool queue_hdmi = false; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2949 | |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 2950 | if (!rdev->ih.enabled || rdev->shutdown) |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2951 | return IRQ_NONE; |
| 2952 | |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 2953 | wptr = evergreen_get_ih_wptr(rdev); |
| 2954 | rptr = rdev->ih.rptr; |
| 2955 | DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2956 | |
Dave Airlie | 682f1a5 | 2011-06-18 03:59:51 +0000 | [diff] [blame] | 2957 | spin_lock_irqsave(&rdev->ih.lock, flags); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2958 | if (rptr == wptr) { |
| 2959 | spin_unlock_irqrestore(&rdev->ih.lock, flags); |
| 2960 | return IRQ_NONE; |
| 2961 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2962 | restart_ih: |
Benjamin Herrenschmidt | 964f664 | 2011-07-13 16:28:19 +1000 | [diff] [blame] | 2963 | /* Order reading of wptr vs. reading of IH ring data */ |
| 2964 | rmb(); |
| 2965 | |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2966 | /* display interrupts */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2967 | evergreen_irq_ack(rdev); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2968 | |
| 2969 | rdev->ih.wptr = wptr; |
| 2970 | while (rptr != wptr) { |
| 2971 | /* wptr/rptr are in bytes! */ |
| 2972 | ring_index = rptr / 4; |
Alex Deucher | 0f234f5f | 2011-02-13 19:06:33 -0500 | [diff] [blame] | 2973 | src_id = le32_to_cpu(rdev->ih.ring[ring_index]) & 0xff; |
| 2974 | src_data = le32_to_cpu(rdev->ih.ring[ring_index + 1]) & 0xfffffff; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2975 | |
| 2976 | switch (src_id) { |
| 2977 | case 1: /* D1 vblank/vline */ |
| 2978 | switch (src_data) { |
| 2979 | case 0: /* D1 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2980 | if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT) { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2981 | if (rdev->irq.crtc_vblank_int[0]) { |
| 2982 | drm_handle_vblank(rdev->ddev, 0); |
| 2983 | rdev->pm.vblank_sync = true; |
| 2984 | wake_up(&rdev->irq.vblank_queue); |
| 2985 | } |
Mario Kleiner | 3e4ea74 | 2010-11-21 10:59:02 -0500 | [diff] [blame] | 2986 | if (rdev->irq.pflip[0]) |
| 2987 | radeon_crtc_handle_flip(rdev, 0); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2988 | rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VBLANK_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2989 | DRM_DEBUG("IH: D1 vblank\n"); |
| 2990 | } |
| 2991 | break; |
| 2992 | case 1: /* D1 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 2993 | if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT) { |
| 2994 | rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VLINE_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 2995 | DRM_DEBUG("IH: D1 vline\n"); |
| 2996 | } |
| 2997 | break; |
| 2998 | default: |
| 2999 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3000 | break; |
| 3001 | } |
| 3002 | break; |
| 3003 | case 2: /* D2 vblank/vline */ |
| 3004 | switch (src_data) { |
| 3005 | case 0: /* D2 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3006 | if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT) { |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3007 | if (rdev->irq.crtc_vblank_int[1]) { |
| 3008 | drm_handle_vblank(rdev->ddev, 1); |
| 3009 | rdev->pm.vblank_sync = true; |
| 3010 | wake_up(&rdev->irq.vblank_queue); |
| 3011 | } |
Mario Kleiner | 3e4ea74 | 2010-11-21 10:59:02 -0500 | [diff] [blame] | 3012 | if (rdev->irq.pflip[1]) |
| 3013 | radeon_crtc_handle_flip(rdev, 1); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3014 | rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3015 | DRM_DEBUG("IH: D2 vblank\n"); |
| 3016 | } |
| 3017 | break; |
| 3018 | case 1: /* D2 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3019 | if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT) { |
| 3020 | rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3021 | DRM_DEBUG("IH: D2 vline\n"); |
| 3022 | } |
| 3023 | break; |
| 3024 | default: |
| 3025 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3026 | break; |
| 3027 | } |
| 3028 | break; |
| 3029 | case 3: /* D3 vblank/vline */ |
| 3030 | switch (src_data) { |
| 3031 | case 0: /* D3 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3032 | if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { |
| 3033 | if (rdev->irq.crtc_vblank_int[2]) { |
| 3034 | drm_handle_vblank(rdev->ddev, 2); |
| 3035 | rdev->pm.vblank_sync = true; |
| 3036 | wake_up(&rdev->irq.vblank_queue); |
| 3037 | } |
| 3038 | if (rdev->irq.pflip[2]) |
| 3039 | radeon_crtc_handle_flip(rdev, 2); |
| 3040 | rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3041 | DRM_DEBUG("IH: D3 vblank\n"); |
| 3042 | } |
| 3043 | break; |
| 3044 | case 1: /* D3 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3045 | if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { |
| 3046 | rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3047 | DRM_DEBUG("IH: D3 vline\n"); |
| 3048 | } |
| 3049 | break; |
| 3050 | default: |
| 3051 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3052 | break; |
| 3053 | } |
| 3054 | break; |
| 3055 | case 4: /* D4 vblank/vline */ |
| 3056 | switch (src_data) { |
| 3057 | case 0: /* D4 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3058 | if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { |
| 3059 | if (rdev->irq.crtc_vblank_int[3]) { |
| 3060 | drm_handle_vblank(rdev->ddev, 3); |
| 3061 | rdev->pm.vblank_sync = true; |
| 3062 | wake_up(&rdev->irq.vblank_queue); |
| 3063 | } |
| 3064 | if (rdev->irq.pflip[3]) |
| 3065 | radeon_crtc_handle_flip(rdev, 3); |
| 3066 | rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3067 | DRM_DEBUG("IH: D4 vblank\n"); |
| 3068 | } |
| 3069 | break; |
| 3070 | case 1: /* D4 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3071 | if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { |
| 3072 | rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3073 | DRM_DEBUG("IH: D4 vline\n"); |
| 3074 | } |
| 3075 | break; |
| 3076 | default: |
| 3077 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3078 | break; |
| 3079 | } |
| 3080 | break; |
| 3081 | case 5: /* D5 vblank/vline */ |
| 3082 | switch (src_data) { |
| 3083 | case 0: /* D5 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3084 | if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { |
| 3085 | if (rdev->irq.crtc_vblank_int[4]) { |
| 3086 | drm_handle_vblank(rdev->ddev, 4); |
| 3087 | rdev->pm.vblank_sync = true; |
| 3088 | wake_up(&rdev->irq.vblank_queue); |
| 3089 | } |
| 3090 | if (rdev->irq.pflip[4]) |
| 3091 | radeon_crtc_handle_flip(rdev, 4); |
| 3092 | rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3093 | DRM_DEBUG("IH: D5 vblank\n"); |
| 3094 | } |
| 3095 | break; |
| 3096 | case 1: /* D5 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3097 | if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { |
| 3098 | rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3099 | DRM_DEBUG("IH: D5 vline\n"); |
| 3100 | } |
| 3101 | break; |
| 3102 | default: |
| 3103 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3104 | break; |
| 3105 | } |
| 3106 | break; |
| 3107 | case 6: /* D6 vblank/vline */ |
| 3108 | switch (src_data) { |
| 3109 | case 0: /* D6 vblank */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3110 | if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { |
| 3111 | if (rdev->irq.crtc_vblank_int[5]) { |
| 3112 | drm_handle_vblank(rdev->ddev, 5); |
| 3113 | rdev->pm.vblank_sync = true; |
| 3114 | wake_up(&rdev->irq.vblank_queue); |
| 3115 | } |
| 3116 | if (rdev->irq.pflip[5]) |
| 3117 | radeon_crtc_handle_flip(rdev, 5); |
| 3118 | rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3119 | DRM_DEBUG("IH: D6 vblank\n"); |
| 3120 | } |
| 3121 | break; |
| 3122 | case 1: /* D6 vline */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3123 | if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { |
| 3124 | rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3125 | DRM_DEBUG("IH: D6 vline\n"); |
| 3126 | } |
| 3127 | break; |
| 3128 | default: |
| 3129 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3130 | break; |
| 3131 | } |
| 3132 | break; |
| 3133 | case 42: /* HPD hotplug */ |
| 3134 | switch (src_data) { |
| 3135 | case 0: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3136 | if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) { |
| 3137 | rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3138 | queue_hotplug = true; |
| 3139 | DRM_DEBUG("IH: HPD1\n"); |
| 3140 | } |
| 3141 | break; |
| 3142 | case 1: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3143 | if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT) { |
| 3144 | rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3145 | queue_hotplug = true; |
| 3146 | DRM_DEBUG("IH: HPD2\n"); |
| 3147 | } |
| 3148 | break; |
| 3149 | case 2: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3150 | if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT) { |
| 3151 | rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3152 | queue_hotplug = true; |
| 3153 | DRM_DEBUG("IH: HPD3\n"); |
| 3154 | } |
| 3155 | break; |
| 3156 | case 3: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3157 | if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT) { |
| 3158 | rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3159 | queue_hotplug = true; |
| 3160 | DRM_DEBUG("IH: HPD4\n"); |
| 3161 | } |
| 3162 | break; |
| 3163 | case 4: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3164 | if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT) { |
| 3165 | rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3166 | queue_hotplug = true; |
| 3167 | DRM_DEBUG("IH: HPD5\n"); |
| 3168 | } |
| 3169 | break; |
| 3170 | case 5: |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 3171 | if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT) { |
| 3172 | rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3173 | queue_hotplug = true; |
| 3174 | DRM_DEBUG("IH: HPD6\n"); |
| 3175 | } |
| 3176 | break; |
| 3177 | default: |
| 3178 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3179 | break; |
| 3180 | } |
| 3181 | break; |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3182 | case 44: /* hdmi */ |
| 3183 | switch (src_data) { |
| 3184 | case 0: |
| 3185 | if (rdev->irq.stat_regs.evergreen.afmt_status1 & AFMT_AZ_FORMAT_WTRIG) { |
| 3186 | rdev->irq.stat_regs.evergreen.afmt_status1 &= ~AFMT_AZ_FORMAT_WTRIG; |
| 3187 | queue_hdmi = true; |
| 3188 | DRM_DEBUG("IH: HDMI0\n"); |
| 3189 | } |
| 3190 | break; |
| 3191 | case 1: |
| 3192 | if (rdev->irq.stat_regs.evergreen.afmt_status2 & AFMT_AZ_FORMAT_WTRIG) { |
| 3193 | rdev->irq.stat_regs.evergreen.afmt_status2 &= ~AFMT_AZ_FORMAT_WTRIG; |
| 3194 | queue_hdmi = true; |
| 3195 | DRM_DEBUG("IH: HDMI1\n"); |
| 3196 | } |
| 3197 | break; |
| 3198 | case 2: |
| 3199 | if (rdev->irq.stat_regs.evergreen.afmt_status3 & AFMT_AZ_FORMAT_WTRIG) { |
| 3200 | rdev->irq.stat_regs.evergreen.afmt_status3 &= ~AFMT_AZ_FORMAT_WTRIG; |
| 3201 | queue_hdmi = true; |
| 3202 | DRM_DEBUG("IH: HDMI2\n"); |
| 3203 | } |
| 3204 | break; |
| 3205 | case 3: |
| 3206 | if (rdev->irq.stat_regs.evergreen.afmt_status4 & AFMT_AZ_FORMAT_WTRIG) { |
| 3207 | rdev->irq.stat_regs.evergreen.afmt_status4 &= ~AFMT_AZ_FORMAT_WTRIG; |
| 3208 | queue_hdmi = true; |
| 3209 | DRM_DEBUG("IH: HDMI3\n"); |
| 3210 | } |
| 3211 | break; |
| 3212 | case 4: |
| 3213 | if (rdev->irq.stat_regs.evergreen.afmt_status5 & AFMT_AZ_FORMAT_WTRIG) { |
| 3214 | rdev->irq.stat_regs.evergreen.afmt_status5 &= ~AFMT_AZ_FORMAT_WTRIG; |
| 3215 | queue_hdmi = true; |
| 3216 | DRM_DEBUG("IH: HDMI4\n"); |
| 3217 | } |
| 3218 | break; |
| 3219 | case 5: |
| 3220 | if (rdev->irq.stat_regs.evergreen.afmt_status6 & AFMT_AZ_FORMAT_WTRIG) { |
| 3221 | rdev->irq.stat_regs.evergreen.afmt_status6 &= ~AFMT_AZ_FORMAT_WTRIG; |
| 3222 | queue_hdmi = true; |
| 3223 | DRM_DEBUG("IH: HDMI5\n"); |
| 3224 | } |
| 3225 | break; |
| 3226 | default: |
| 3227 | DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3228 | break; |
| 3229 | } |
| 3230 | break; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3231 | case 176: /* CP_INT in ring buffer */ |
| 3232 | case 177: /* CP_INT in IB1 */ |
| 3233 | case 178: /* CP_INT in IB2 */ |
| 3234 | DRM_DEBUG("IH: CP int: 0x%08x\n", src_data); |
Alex Deucher | 7465280 | 2011-08-25 13:39:48 -0400 | [diff] [blame] | 3235 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3236 | break; |
| 3237 | case 181: /* CP EOP event */ |
| 3238 | DRM_DEBUG("IH: CP EOP\n"); |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 3239 | if (rdev->family >= CHIP_CAYMAN) { |
| 3240 | switch (src_data) { |
| 3241 | case 0: |
| 3242 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 3243 | break; |
| 3244 | case 1: |
| 3245 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP1_INDEX); |
| 3246 | break; |
| 3247 | case 2: |
| 3248 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP2_INDEX); |
| 3249 | break; |
| 3250 | } |
| 3251 | } else |
| 3252 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3253 | break; |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 3254 | case 233: /* GUI IDLE */ |
Ilija Hadzic | 303c805 | 2011-06-07 14:54:48 -0400 | [diff] [blame] | 3255 | DRM_DEBUG("IH: GUI idle\n"); |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 3256 | rdev->pm.gui_idle = true; |
| 3257 | wake_up(&rdev->irq.idle_queue); |
| 3258 | break; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3259 | default: |
| 3260 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 3261 | break; |
| 3262 | } |
| 3263 | |
| 3264 | /* wptr/rptr are in bytes! */ |
| 3265 | rptr += 16; |
| 3266 | rptr &= rdev->ih.ptr_mask; |
| 3267 | } |
| 3268 | /* make sure wptr hasn't changed while processing */ |
| 3269 | wptr = evergreen_get_ih_wptr(rdev); |
| 3270 | if (wptr != rdev->ih.wptr) |
| 3271 | goto restart_ih; |
| 3272 | if (queue_hotplug) |
Tejun Heo | 32c87fc | 2011-01-03 14:49:32 +0100 | [diff] [blame] | 3273 | schedule_work(&rdev->hotplug_work); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 3274 | if (queue_hdmi) |
| 3275 | schedule_work(&rdev->audio_work); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3276 | rdev->ih.rptr = rptr; |
| 3277 | WREG32(IH_RB_RPTR, rdev->ih.rptr); |
| 3278 | spin_unlock_irqrestore(&rdev->ih.lock, flags); |
| 3279 | return IRQ_HANDLED; |
| 3280 | } |
| 3281 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3282 | static int evergreen_startup(struct radeon_device *rdev) |
| 3283 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 3284 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3285 | int r; |
| 3286 | |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 3287 | /* enable pcie gen2 link */ |
Ilija Hadzic | cd54033 | 2011-09-20 10:22:57 -0400 | [diff] [blame] | 3288 | evergreen_pcie_gen2_enable(rdev); |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 3289 | |
Alex Deucher | 0af62b0 | 2011-01-06 21:19:31 -0500 | [diff] [blame] | 3290 | if (ASIC_IS_DCE5(rdev)) { |
| 3291 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) { |
| 3292 | r = ni_init_microcode(rdev); |
| 3293 | if (r) { |
| 3294 | DRM_ERROR("Failed to load firmware!\n"); |
| 3295 | return r; |
| 3296 | } |
| 3297 | } |
Alex Deucher | 755d819 | 2011-03-02 20:07:34 -0500 | [diff] [blame] | 3298 | r = ni_mc_load_microcode(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3299 | if (r) { |
Alex Deucher | 0af62b0 | 2011-01-06 21:19:31 -0500 | [diff] [blame] | 3300 | DRM_ERROR("Failed to load MC firmware!\n"); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3301 | return r; |
| 3302 | } |
Alex Deucher | 0af62b0 | 2011-01-06 21:19:31 -0500 | [diff] [blame] | 3303 | } else { |
| 3304 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { |
| 3305 | r = r600_init_microcode(rdev); |
| 3306 | if (r) { |
| 3307 | DRM_ERROR("Failed to load firmware!\n"); |
| 3308 | return r; |
| 3309 | } |
| 3310 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3311 | } |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3312 | |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 3313 | r = r600_vram_scratch_init(rdev); |
| 3314 | if (r) |
| 3315 | return r; |
| 3316 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3317 | evergreen_mc_program(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3318 | if (rdev->flags & RADEON_IS_AGP) { |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 3319 | evergreen_agp_enable(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3320 | } else { |
| 3321 | r = evergreen_pcie_gart_enable(rdev); |
| 3322 | if (r) |
| 3323 | return r; |
| 3324 | } |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3325 | evergreen_gpu_init(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3326 | |
Alex Deucher | d7ccd8f | 2010-09-09 11:33:36 -0400 | [diff] [blame] | 3327 | r = evergreen_blit_init(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3328 | if (r) { |
Ilija Hadzic | fb3d9e9 | 2011-10-12 23:29:41 -0400 | [diff] [blame] | 3329 | r600_blit_fini(rdev); |
Alex Deucher | 27cd776 | 2012-02-23 17:53:42 -0500 | [diff] [blame] | 3330 | rdev->asic->copy.copy = NULL; |
Alex Deucher | d7ccd8f | 2010-09-09 11:33:36 -0400 | [diff] [blame] | 3331 | dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3332 | } |
| 3333 | |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3334 | /* allocate wb buffer */ |
| 3335 | r = radeon_wb_init(rdev); |
| 3336 | if (r) |
| 3337 | return r; |
| 3338 | |
Jerome Glisse | 30eb77f | 2011-11-20 20:45:34 +0000 | [diff] [blame] | 3339 | r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 3340 | if (r) { |
| 3341 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 3342 | return r; |
| 3343 | } |
| 3344 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3345 | /* Enable IRQ */ |
| 3346 | r = r600_irq_init(rdev); |
| 3347 | if (r) { |
| 3348 | DRM_ERROR("radeon: IH init failed (%d).\n", r); |
| 3349 | radeon_irq_kms_fini(rdev); |
| 3350 | return r; |
| 3351 | } |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3352 | evergreen_irq_set(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3353 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 3354 | 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] | 3355 | R600_CP_RB_RPTR, R600_CP_RB_WPTR, |
| 3356 | 0, 0xfffff, RADEON_CP_PACKET2); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3357 | if (r) |
| 3358 | return r; |
| 3359 | r = evergreen_cp_load_microcode(rdev); |
| 3360 | if (r) |
| 3361 | return r; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3362 | r = evergreen_cp_resume(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3363 | if (r) |
| 3364 | return r; |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3365 | |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3366 | r = radeon_ib_pool_start(rdev); |
| 3367 | if (r) |
| 3368 | return r; |
| 3369 | |
Christian König | 7bd560e | 2012-05-02 15:11:12 +0200 | [diff] [blame] | 3370 | r = radeon_ib_ring_tests(rdev); |
| 3371 | if (r) |
Matthijs Kooijman | 3fe89a0 | 2012-02-02 21:23:11 +0100 | [diff] [blame] | 3372 | return r; |
Dave Airlie | 7a7e873 | 2012-01-03 09:43:28 +0000 | [diff] [blame] | 3373 | |
Rafał Miłecki | 69d2ae5 | 2011-12-07 23:32:24 +0100 | [diff] [blame] | 3374 | r = r600_audio_init(rdev); |
| 3375 | if (r) { |
| 3376 | DRM_ERROR("radeon: audio init failed\n"); |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3377 | return r; |
| 3378 | } |
| 3379 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3380 | return 0; |
| 3381 | } |
| 3382 | |
| 3383 | int evergreen_resume(struct radeon_device *rdev) |
| 3384 | { |
| 3385 | int r; |
| 3386 | |
Alex Deucher | 86f5c9e | 2010-12-20 12:35:04 -0500 | [diff] [blame] | 3387 | /* reset the asic, the gfx blocks are often in a bad state |
| 3388 | * after the driver is unloaded or after a resume |
| 3389 | */ |
| 3390 | if (radeon_asic_reset(rdev)) |
| 3391 | dev_warn(rdev->dev, "GPU reset failed !\n"); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3392 | /* Do not reset GPU before posting, on rv770 hw unlike on r500 hw, |
| 3393 | * posting will perform necessary task to bring back GPU into good |
| 3394 | * shape. |
| 3395 | */ |
| 3396 | /* post card */ |
| 3397 | atom_asic_init(rdev->mode_info.atom_context); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3398 | |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3399 | rdev->accel_working = true; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3400 | r = evergreen_startup(rdev); |
| 3401 | if (r) { |
Alex Deucher | 755d819 | 2011-03-02 20:07:34 -0500 | [diff] [blame] | 3402 | DRM_ERROR("evergreen startup failed on resume\n"); |
Jerome Glisse | 6b7746e | 2012-02-20 17:57:20 -0500 | [diff] [blame] | 3403 | rdev->accel_working = false; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3404 | return r; |
| 3405 | } |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3406 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3407 | return r; |
| 3408 | |
| 3409 | } |
| 3410 | |
| 3411 | int evergreen_suspend(struct radeon_device *rdev) |
| 3412 | { |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 3413 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Christian König | 7b1f248 | 2011-09-23 15:11:23 +0200 | [diff] [blame] | 3414 | |
Rafał Miłecki | 69d2ae5 | 2011-12-07 23:32:24 +0100 | [diff] [blame] | 3415 | r600_audio_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3416 | /* FIXME: we should wait for ring to be empty */ |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3417 | radeon_ib_pool_suspend(rdev); |
| 3418 | r600_blit_suspend(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3419 | r700_cp_stop(rdev); |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 3420 | ring->ready = false; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3421 | evergreen_irq_suspend(rdev); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3422 | radeon_wb_disable(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3423 | evergreen_pcie_gart_disable(rdev); |
Alex Deucher | d7ccd8f | 2010-09-09 11:33:36 -0400 | [diff] [blame] | 3424 | |
| 3425 | return 0; |
| 3426 | } |
| 3427 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3428 | /* Plan is to move initialization in that function and use |
| 3429 | * helper function so that radeon_device_init pretty much |
| 3430 | * do nothing more than calling asic specific function. This |
| 3431 | * should also allow to remove a bunch of callback function |
| 3432 | * like vram_info. |
| 3433 | */ |
| 3434 | int evergreen_init(struct radeon_device *rdev) |
| 3435 | { |
| 3436 | int r; |
| 3437 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3438 | /* This don't do much */ |
| 3439 | r = radeon_gem_init(rdev); |
| 3440 | if (r) |
| 3441 | return r; |
| 3442 | /* Read BIOS */ |
| 3443 | if (!radeon_get_bios(rdev)) { |
| 3444 | if (ASIC_IS_AVIVO(rdev)) |
| 3445 | return -EINVAL; |
| 3446 | } |
| 3447 | /* Must be an ATOMBIOS */ |
| 3448 | if (!rdev->is_atom_bios) { |
Alex Deucher | 755d819 | 2011-03-02 20:07:34 -0500 | [diff] [blame] | 3449 | dev_err(rdev->dev, "Expecting atombios for evergreen GPU\n"); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3450 | return -EINVAL; |
| 3451 | } |
| 3452 | r = radeon_atombios_init(rdev); |
| 3453 | if (r) |
| 3454 | return r; |
Alex Deucher | 86f5c9e | 2010-12-20 12:35:04 -0500 | [diff] [blame] | 3455 | /* reset the asic, the gfx blocks are often in a bad state |
| 3456 | * after the driver is unloaded or after a resume |
| 3457 | */ |
| 3458 | if (radeon_asic_reset(rdev)) |
| 3459 | dev_warn(rdev->dev, "GPU reset failed !\n"); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3460 | /* Post card if necessary */ |
Alex Deucher | fd909c3 | 2011-01-11 18:08:59 -0500 | [diff] [blame] | 3461 | if (!radeon_card_posted(rdev)) { |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3462 | if (!rdev->bios) { |
| 3463 | dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); |
| 3464 | return -EINVAL; |
| 3465 | } |
| 3466 | DRM_INFO("GPU not posted. posting now...\n"); |
| 3467 | atom_asic_init(rdev->mode_info.atom_context); |
| 3468 | } |
| 3469 | /* Initialize scratch registers */ |
| 3470 | r600_scratch_init(rdev); |
| 3471 | /* Initialize surface registers */ |
| 3472 | radeon_surface_init(rdev); |
| 3473 | /* Initialize clocks */ |
| 3474 | radeon_get_clock_info(rdev->ddev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3475 | /* Fence driver */ |
| 3476 | r = radeon_fence_driver_init(rdev); |
| 3477 | if (r) |
| 3478 | return r; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 3479 | /* initialize AGP */ |
| 3480 | if (rdev->flags & RADEON_IS_AGP) { |
| 3481 | r = radeon_agp_init(rdev); |
| 3482 | if (r) |
| 3483 | radeon_agp_disable(rdev); |
| 3484 | } |
| 3485 | /* initialize memory controller */ |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3486 | r = evergreen_mc_init(rdev); |
| 3487 | if (r) |
| 3488 | return r; |
| 3489 | /* Memory manager */ |
| 3490 | r = radeon_bo_init(rdev); |
| 3491 | if (r) |
| 3492 | return r; |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3493 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3494 | r = radeon_irq_kms_init(rdev); |
| 3495 | if (r) |
| 3496 | return r; |
| 3497 | |
Christian König | e32eb50 | 2011-10-23 12:56:27 +0200 | [diff] [blame] | 3498 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ring_obj = NULL; |
| 3499 | r600_ring_init(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX], 1024 * 1024); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3500 | |
| 3501 | rdev->ih.ring_obj = NULL; |
| 3502 | r600_ih_ring_init(rdev, 64 * 1024); |
| 3503 | |
| 3504 | r = r600_pcie_gart_init(rdev); |
| 3505 | if (r) |
| 3506 | return r; |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 3507 | |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3508 | r = radeon_ib_pool_init(rdev); |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 3509 | rdev->accel_working = true; |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3510 | if (r) { |
| 3511 | dev_err(rdev->dev, "IB initialization failed (%d).\n", r); |
| 3512 | rdev->accel_working = false; |
| 3513 | } |
| 3514 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3515 | r = evergreen_startup(rdev); |
| 3516 | if (r) { |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3517 | dev_err(rdev->dev, "disabling GPU acceleration\n"); |
| 3518 | r700_cp_fini(rdev); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3519 | r600_irq_fini(rdev); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3520 | radeon_wb_fini(rdev); |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3521 | r100_ib_fini(rdev); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 3522 | radeon_irq_kms_fini(rdev); |
Alex Deucher | 0fcdb61 | 2010-03-24 13:20:41 -0400 | [diff] [blame] | 3523 | evergreen_pcie_gart_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3524 | rdev->accel_working = false; |
| 3525 | } |
Alex Deucher | 77e00f2 | 2011-12-21 11:58:17 -0500 | [diff] [blame] | 3526 | |
| 3527 | /* Don't start up if the MC ucode is missing on BTC parts. |
| 3528 | * The default clocks and voltages before the MC ucode |
| 3529 | * is loaded are not suffient for advanced operations. |
| 3530 | */ |
| 3531 | if (ASIC_IS_DCE5(rdev)) { |
| 3532 | if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) { |
| 3533 | DRM_ERROR("radeon: MC ucode required for NI+.\n"); |
| 3534 | return -EINVAL; |
| 3535 | } |
| 3536 | } |
| 3537 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3538 | return 0; |
| 3539 | } |
| 3540 | |
| 3541 | void evergreen_fini(struct radeon_device *rdev) |
| 3542 | { |
Rafał Miłecki | 69d2ae5 | 2011-12-07 23:32:24 +0100 | [diff] [blame] | 3543 | r600_audio_fini(rdev); |
Ilija Hadzic | fb3d9e9 | 2011-10-12 23:29:41 -0400 | [diff] [blame] | 3544 | r600_blit_fini(rdev); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 3545 | r700_cp_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3546 | r600_irq_fini(rdev); |
Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 3547 | radeon_wb_fini(rdev); |
Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 3548 | r100_ib_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3549 | radeon_irq_kms_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3550 | evergreen_pcie_gart_fini(rdev); |
Alex Deucher | 16cdf04 | 2011-10-28 10:30:02 -0400 | [diff] [blame] | 3551 | r600_vram_scratch_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3552 | radeon_gem_fini(rdev); |
Christian König | 15d3332 | 2011-09-15 19:02:22 +0200 | [diff] [blame] | 3553 | radeon_semaphore_driver_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3554 | radeon_fence_driver_fini(rdev); |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3555 | radeon_agp_fini(rdev); |
| 3556 | radeon_bo_fini(rdev); |
| 3557 | radeon_atombios_fini(rdev); |
| 3558 | kfree(rdev->bios); |
| 3559 | rdev->bios = NULL; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 3560 | } |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 3561 | |
Ilija Hadzic | b07759b | 2011-09-20 10:22:58 -0400 | [diff] [blame] | 3562 | void evergreen_pcie_gen2_enable(struct radeon_device *rdev) |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 3563 | { |
| 3564 | u32 link_width_cntl, speed_cntl; |
| 3565 | |
Alex Deucher | d42dd57 | 2011-01-12 20:05:11 -0500 | [diff] [blame] | 3566 | if (radeon_pcie_gen2 == 0) |
| 3567 | return; |
| 3568 | |
Alex Deucher | 9e46a48 | 2011-01-06 18:49:35 -0500 | [diff] [blame] | 3569 | if (rdev->flags & RADEON_IS_IGP) |
| 3570 | return; |
| 3571 | |
| 3572 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 3573 | return; |
| 3574 | |
| 3575 | /* x2 cards have a special sequence */ |
| 3576 | if (ASIC_IS_X2(rdev)) |
| 3577 | return; |
| 3578 | |
| 3579 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
| 3580 | if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) || |
| 3581 | (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) { |
| 3582 | |
| 3583 | link_width_cntl = RREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL); |
| 3584 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
| 3585 | WREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
| 3586 | |
| 3587 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
| 3588 | speed_cntl &= ~LC_TARGET_LINK_SPEED_OVERRIDE_EN; |
| 3589 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 3590 | |
| 3591 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
| 3592 | speed_cntl |= LC_CLR_FAILED_SPD_CHANGE_CNT; |
| 3593 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 3594 | |
| 3595 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
| 3596 | speed_cntl &= ~LC_CLR_FAILED_SPD_CHANGE_CNT; |
| 3597 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 3598 | |
| 3599 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
| 3600 | speed_cntl |= LC_GEN2_EN_STRAP; |
| 3601 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 3602 | |
| 3603 | } else { |
| 3604 | link_width_cntl = RREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL); |
| 3605 | /* XXX: only disable it if gen1 bridge vendor == 0x111d or 0x1106 */ |
| 3606 | if (1) |
| 3607 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
| 3608 | else |
| 3609 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
| 3610 | WREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
| 3611 | } |
| 3612 | } |