| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2008 Advanced Micro Devices, Inc. | 
|  | 3 | * Copyright 2008 Red Hat Inc. | 
|  | 4 | * Copyright 2009 Jerome Glisse. | 
|  | 5 | * | 
|  | 6 | * Permission is hereby granted, free of charge, to any person obtaining a | 
|  | 7 | * copy of this software and associated documentation files (the "Software"), | 
|  | 8 | * to deal in the Software without restriction, including without limitation | 
|  | 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 
|  | 10 | * and/or sell copies of the Software, and to permit persons to whom the | 
|  | 11 | * Software is furnished to do so, subject to the following conditions: | 
|  | 12 | * | 
|  | 13 | * The above copyright notice and this permission notice shall be included in | 
|  | 14 | * all copies or substantial portions of the Software. | 
|  | 15 | * | 
|  | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
|  | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
|  | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL | 
|  | 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | 
|  | 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 
|  | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 
|  | 22 | * OTHER DEALINGS IN THE SOFTWARE. | 
|  | 23 | * | 
|  | 24 | * Authors: Dave Airlie | 
|  | 25 | *          Alex Deucher | 
|  | 26 | *          Jerome Glisse | 
|  | 27 | */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 28 | /* RS600 / Radeon X1250/X1270 integrated GPU | 
|  | 29 | * | 
|  | 30 | * This file gather function specific to RS600 which is the IGP of | 
|  | 31 | * the X1250/X1270 family supporting intel CPU (while RS690/RS740 | 
|  | 32 | * is the X1250/X1270 supporting AMD CPU). The display engine are | 
|  | 33 | * the avivo one, bios is an atombios, 3D block are the one of the | 
|  | 34 | * R4XX family. The GART is different from the RS400 one and is very | 
|  | 35 | * close to the one of the R600 family (R600 likely being an evolution | 
|  | 36 | * of the RS600 GART block). | 
|  | 37 | */ | 
| David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 38 | #include <drm/drmP.h> | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 39 | #include "radeon.h" | 
| Daniel Vetter | e699037 | 2010-03-11 21:19:17 +0000 | [diff] [blame] | 40 | #include "radeon_asic.h" | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 41 | #include "atom.h" | 
|  | 42 | #include "rs600d.h" | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 43 |  | 
| Dave Airlie | 3f7dc91a | 2009-08-27 11:10:15 +1000 | [diff] [blame] | 44 | #include "rs600_reg_safe.h" | 
|  | 45 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 46 | static void rs600_gpu_init(struct radeon_device *rdev); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 47 | int rs600_mc_wait_for_idle(struct radeon_device *rdev); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 48 |  | 
| Alex Deucher | 75104fa | 2012-08-15 17:06:28 -0400 | [diff] [blame] | 49 | static const u32 crtc_offsets[2] = | 
|  | 50 | { | 
|  | 51 | 0, | 
|  | 52 | AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL | 
|  | 53 | }; | 
|  | 54 |  | 
| Alex Deucher | 3ae19b7 | 2012-02-23 17:53:37 -0500 | [diff] [blame] | 55 | void avivo_wait_for_vblank(struct radeon_device *rdev, int crtc) | 
|  | 56 | { | 
| Alex Deucher | 3ae19b7 | 2012-02-23 17:53:37 -0500 | [diff] [blame] | 57 | int i; | 
|  | 58 |  | 
| Alex Deucher | 75104fa | 2012-08-15 17:06:28 -0400 | [diff] [blame] | 59 | if (crtc >= rdev->num_crtc) | 
|  | 60 | return; | 
|  | 61 |  | 
|  | 62 | if (RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[crtc]) & AVIVO_CRTC_EN) { | 
| Alex Deucher | 3ae19b7 | 2012-02-23 17:53:37 -0500 | [diff] [blame] | 63 | for (i = 0; i < rdev->usec_timeout; i++) { | 
| Alex Deucher | 75104fa | 2012-08-15 17:06:28 -0400 | [diff] [blame] | 64 | if (!(RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK)) | 
| Alex Deucher | 3ae19b7 | 2012-02-23 17:53:37 -0500 | [diff] [blame] | 65 | break; | 
|  | 66 | udelay(1); | 
|  | 67 | } | 
|  | 68 | for (i = 0; i < rdev->usec_timeout; i++) { | 
| Alex Deucher | 75104fa | 2012-08-15 17:06:28 -0400 | [diff] [blame] | 69 | if (RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK) | 
| Alex Deucher | 3ae19b7 | 2012-02-23 17:53:37 -0500 | [diff] [blame] | 70 | break; | 
|  | 71 | udelay(1); | 
|  | 72 | } | 
|  | 73 | } | 
|  | 74 | } | 
|  | 75 |  | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 76 | void rs600_pre_page_flip(struct radeon_device *rdev, int crtc) | 
|  | 77 | { | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 78 | /* enable the pflip int */ | 
|  | 79 | radeon_irq_kms_pflip_irq_get(rdev, crtc); | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | void rs600_post_page_flip(struct radeon_device *rdev, int crtc) | 
|  | 83 | { | 
|  | 84 | /* disable the pflip int */ | 
|  | 85 | radeon_irq_kms_pflip_irq_put(rdev, crtc); | 
|  | 86 | } | 
|  | 87 |  | 
|  | 88 | u32 rs600_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base) | 
|  | 89 | { | 
|  | 90 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; | 
|  | 91 | u32 tmp = RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset); | 
| Alex Deucher | f649647 | 2011-11-28 14:49:26 -0500 | [diff] [blame] | 92 | int i; | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 93 |  | 
|  | 94 | /* Lock the graphics update lock */ | 
|  | 95 | tmp |= AVIVO_D1GRPH_UPDATE_LOCK; | 
|  | 96 | WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); | 
|  | 97 |  | 
|  | 98 | /* update the scanout addresses */ | 
|  | 99 | WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, | 
|  | 100 | (u32)crtc_base); | 
|  | 101 | WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, | 
|  | 102 | (u32)crtc_base); | 
|  | 103 |  | 
|  | 104 | /* Wait for update_pending to go high. */ | 
| Alex Deucher | f649647 | 2011-11-28 14:49:26 -0500 | [diff] [blame] | 105 | for (i = 0; i < rdev->usec_timeout; i++) { | 
|  | 106 | if (RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING) | 
|  | 107 | break; | 
|  | 108 | udelay(1); | 
|  | 109 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 110 | DRM_DEBUG("Update pending now high. Unlocking vupdate_lock.\n"); | 
|  | 111 |  | 
|  | 112 | /* Unlock the lock, so double-buffering can take place inside vblank */ | 
|  | 113 | tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK; | 
|  | 114 | WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); | 
|  | 115 |  | 
|  | 116 | /* Return current update_pending status: */ | 
|  | 117 | return RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING; | 
|  | 118 | } | 
|  | 119 |  | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 120 | void rs600_pm_misc(struct radeon_device *rdev) | 
|  | 121 | { | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 122 | int requested_index = rdev->pm.requested_power_state_index; | 
|  | 123 | struct radeon_power_state *ps = &rdev->pm.power_state[requested_index]; | 
|  | 124 | struct radeon_voltage *voltage = &ps->clock_info[0].voltage; | 
|  | 125 | u32 tmp, dyn_pwrmgt_sclk_length, dyn_sclk_vol_cntl; | 
| Alex Deucher | 536fcd5 | 2010-04-29 16:33:38 -0400 | [diff] [blame] | 126 | u32 hdp_dyn_cntl, /*mc_host_dyn_cntl,*/ dyn_backbias_cntl; | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 127 |  | 
|  | 128 | if ((voltage->type == VOLTAGE_GPIO) && (voltage->gpio.valid)) { | 
|  | 129 | if (ps->misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) { | 
|  | 130 | tmp = RREG32(voltage->gpio.reg); | 
|  | 131 | if (voltage->active_high) | 
|  | 132 | tmp |= voltage->gpio.mask; | 
|  | 133 | else | 
|  | 134 | tmp &= ~(voltage->gpio.mask); | 
|  | 135 | WREG32(voltage->gpio.reg, tmp); | 
|  | 136 | if (voltage->delay) | 
|  | 137 | udelay(voltage->delay); | 
|  | 138 | } else { | 
|  | 139 | tmp = RREG32(voltage->gpio.reg); | 
|  | 140 | if (voltage->active_high) | 
|  | 141 | tmp &= ~voltage->gpio.mask; | 
|  | 142 | else | 
|  | 143 | tmp |= voltage->gpio.mask; | 
|  | 144 | WREG32(voltage->gpio.reg, tmp); | 
|  | 145 | if (voltage->delay) | 
|  | 146 | udelay(voltage->delay); | 
|  | 147 | } | 
| Alex Deucher | 7ac9aa5 | 2010-05-27 19:25:54 -0400 | [diff] [blame] | 148 | } else if (voltage->type == VOLTAGE_VDDC) | 
| Alex Deucher | 8a83ec5 | 2011-04-12 14:49:23 -0400 | [diff] [blame] | 149 | radeon_atom_set_voltage(rdev, voltage->vddc_id, SET_VOLTAGE_TYPE_ASIC_VDDC); | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 150 |  | 
|  | 151 | dyn_pwrmgt_sclk_length = RREG32_PLL(DYN_PWRMGT_SCLK_LENGTH); | 
|  | 152 | dyn_pwrmgt_sclk_length &= ~REDUCED_POWER_SCLK_HILEN(0xf); | 
|  | 153 | dyn_pwrmgt_sclk_length &= ~REDUCED_POWER_SCLK_LOLEN(0xf); | 
|  | 154 | if (ps->misc & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN) { | 
|  | 155 | if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2) { | 
|  | 156 | dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_HILEN(2); | 
|  | 157 | dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_LOLEN(2); | 
|  | 158 | } else if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4) { | 
|  | 159 | dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_HILEN(4); | 
|  | 160 | dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_LOLEN(4); | 
|  | 161 | } | 
|  | 162 | } else { | 
|  | 163 | dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_HILEN(1); | 
|  | 164 | dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_LOLEN(1); | 
|  | 165 | } | 
|  | 166 | WREG32_PLL(DYN_PWRMGT_SCLK_LENGTH, dyn_pwrmgt_sclk_length); | 
|  | 167 |  | 
|  | 168 | dyn_sclk_vol_cntl = RREG32_PLL(DYN_SCLK_VOL_CNTL); | 
|  | 169 | if (ps->misc & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN) { | 
|  | 170 | dyn_sclk_vol_cntl |= IO_CG_VOLTAGE_DROP; | 
|  | 171 | if (voltage->delay) { | 
|  | 172 | dyn_sclk_vol_cntl |= VOLTAGE_DROP_SYNC; | 
|  | 173 | dyn_sclk_vol_cntl |= VOLTAGE_DELAY_SEL(voltage->delay); | 
|  | 174 | } else | 
|  | 175 | dyn_sclk_vol_cntl &= ~VOLTAGE_DROP_SYNC; | 
|  | 176 | } else | 
|  | 177 | dyn_sclk_vol_cntl &= ~IO_CG_VOLTAGE_DROP; | 
|  | 178 | WREG32_PLL(DYN_SCLK_VOL_CNTL, dyn_sclk_vol_cntl); | 
|  | 179 |  | 
|  | 180 | hdp_dyn_cntl = RREG32_PLL(HDP_DYN_CNTL); | 
|  | 181 | if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN) | 
|  | 182 | hdp_dyn_cntl &= ~HDP_FORCEON; | 
|  | 183 | else | 
|  | 184 | hdp_dyn_cntl |= HDP_FORCEON; | 
|  | 185 | WREG32_PLL(HDP_DYN_CNTL, hdp_dyn_cntl); | 
| Alex Deucher | 536fcd5 | 2010-04-29 16:33:38 -0400 | [diff] [blame] | 186 | #if 0 | 
|  | 187 | /* mc_host_dyn seems to cause hangs from time to time */ | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 188 | mc_host_dyn_cntl = RREG32_PLL(MC_HOST_DYN_CNTL); | 
|  | 189 | if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN) | 
|  | 190 | mc_host_dyn_cntl &= ~MC_HOST_FORCEON; | 
|  | 191 | else | 
|  | 192 | mc_host_dyn_cntl |= MC_HOST_FORCEON; | 
|  | 193 | WREG32_PLL(MC_HOST_DYN_CNTL, mc_host_dyn_cntl); | 
| Alex Deucher | 536fcd5 | 2010-04-29 16:33:38 -0400 | [diff] [blame] | 194 | #endif | 
|  | 195 | dyn_backbias_cntl = RREG32_PLL(DYN_BACKBIAS_CNTL); | 
|  | 196 | if (ps->misc & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN) | 
|  | 197 | dyn_backbias_cntl |= IO_CG_BACKBIAS_EN; | 
|  | 198 | else | 
|  | 199 | dyn_backbias_cntl &= ~IO_CG_BACKBIAS_EN; | 
|  | 200 | WREG32_PLL(DYN_BACKBIAS_CNTL, dyn_backbias_cntl); | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 201 |  | 
|  | 202 | /* set pcie lanes */ | 
|  | 203 | if ((rdev->flags & RADEON_IS_PCIE) && | 
|  | 204 | !(rdev->flags & RADEON_IS_IGP) && | 
| Alex Deucher | 798bcf7 | 2012-02-23 17:53:48 -0500 | [diff] [blame] | 205 | rdev->asic->pm.set_pcie_lanes && | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 206 | (ps->pcie_lanes != | 
|  | 207 | rdev->pm.power_state[rdev->pm.current_power_state_index].pcie_lanes)) { | 
|  | 208 | radeon_set_pcie_lanes(rdev, | 
|  | 209 | ps->pcie_lanes); | 
| Alex Deucher | ce8a3eb | 2010-05-07 16:58:27 -0400 | [diff] [blame] | 210 | DRM_DEBUG("Setting: p: %d\n", ps->pcie_lanes); | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 211 | } | 
| Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 212 | } | 
|  | 213 |  | 
|  | 214 | void rs600_pm_prepare(struct radeon_device *rdev) | 
|  | 215 | { | 
|  | 216 | struct drm_device *ddev = rdev->ddev; | 
|  | 217 | struct drm_crtc *crtc; | 
|  | 218 | struct radeon_crtc *radeon_crtc; | 
|  | 219 | u32 tmp; | 
|  | 220 |  | 
|  | 221 | /* disable any active CRTCs */ | 
|  | 222 | list_for_each_entry(crtc, &ddev->mode_config.crtc_list, head) { | 
|  | 223 | radeon_crtc = to_radeon_crtc(crtc); | 
|  | 224 | if (radeon_crtc->enabled) { | 
|  | 225 | tmp = RREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset); | 
|  | 226 | tmp |= AVIVO_CRTC_DISP_READ_REQUEST_DISABLE; | 
|  | 227 | WREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset, tmp); | 
|  | 228 | } | 
|  | 229 | } | 
|  | 230 | } | 
|  | 231 |  | 
|  | 232 | void rs600_pm_finish(struct radeon_device *rdev) | 
|  | 233 | { | 
|  | 234 | struct drm_device *ddev = rdev->ddev; | 
|  | 235 | struct drm_crtc *crtc; | 
|  | 236 | struct radeon_crtc *radeon_crtc; | 
|  | 237 | u32 tmp; | 
|  | 238 |  | 
|  | 239 | /* enable any active CRTCs */ | 
|  | 240 | list_for_each_entry(crtc, &ddev->mode_config.crtc_list, head) { | 
|  | 241 | radeon_crtc = to_radeon_crtc(crtc); | 
|  | 242 | if (radeon_crtc->enabled) { | 
|  | 243 | tmp = RREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset); | 
|  | 244 | tmp &= ~AVIVO_CRTC_DISP_READ_REQUEST_DISABLE; | 
|  | 245 | WREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset, tmp); | 
|  | 246 | } | 
|  | 247 | } | 
|  | 248 | } | 
|  | 249 |  | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 250 | /* hpd for digital panel detect/disconnect */ | 
|  | 251 | bool rs600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) | 
|  | 252 | { | 
|  | 253 | u32 tmp; | 
|  | 254 | bool connected = false; | 
|  | 255 |  | 
|  | 256 | switch (hpd) { | 
|  | 257 | case RADEON_HPD_1: | 
|  | 258 | tmp = RREG32(R_007D04_DC_HOT_PLUG_DETECT1_INT_STATUS); | 
|  | 259 | if (G_007D04_DC_HOT_PLUG_DETECT1_SENSE(tmp)) | 
|  | 260 | connected = true; | 
|  | 261 | break; | 
|  | 262 | case RADEON_HPD_2: | 
|  | 263 | tmp = RREG32(R_007D14_DC_HOT_PLUG_DETECT2_INT_STATUS); | 
|  | 264 | if (G_007D14_DC_HOT_PLUG_DETECT2_SENSE(tmp)) | 
|  | 265 | connected = true; | 
|  | 266 | break; | 
|  | 267 | default: | 
|  | 268 | break; | 
|  | 269 | } | 
|  | 270 | return connected; | 
|  | 271 | } | 
|  | 272 |  | 
|  | 273 | void rs600_hpd_set_polarity(struct radeon_device *rdev, | 
|  | 274 | enum radeon_hpd_id hpd) | 
|  | 275 | { | 
|  | 276 | u32 tmp; | 
|  | 277 | bool connected = rs600_hpd_sense(rdev, hpd); | 
|  | 278 |  | 
|  | 279 | switch (hpd) { | 
|  | 280 | case RADEON_HPD_1: | 
|  | 281 | tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); | 
|  | 282 | if (connected) | 
|  | 283 | tmp &= ~S_007D08_DC_HOT_PLUG_DETECT1_INT_POLARITY(1); | 
|  | 284 | else | 
|  | 285 | tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_POLARITY(1); | 
|  | 286 | WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); | 
|  | 287 | break; | 
|  | 288 | case RADEON_HPD_2: | 
|  | 289 | tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); | 
|  | 290 | if (connected) | 
|  | 291 | tmp &= ~S_007D18_DC_HOT_PLUG_DETECT2_INT_POLARITY(1); | 
|  | 292 | else | 
|  | 293 | tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_POLARITY(1); | 
|  | 294 | WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); | 
|  | 295 | break; | 
|  | 296 | default: | 
|  | 297 | break; | 
|  | 298 | } | 
|  | 299 | } | 
|  | 300 |  | 
|  | 301 | void rs600_hpd_init(struct radeon_device *rdev) | 
|  | 302 | { | 
|  | 303 | struct drm_device *dev = rdev->ddev; | 
|  | 304 | struct drm_connector *connector; | 
| Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 305 | unsigned enable = 0; | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 306 |  | 
|  | 307 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | 
|  | 308 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | 
|  | 309 | switch (radeon_connector->hpd.hpd) { | 
|  | 310 | case RADEON_HPD_1: | 
|  | 311 | WREG32(R_007D00_DC_HOT_PLUG_DETECT1_CONTROL, | 
|  | 312 | S_007D00_DC_HOT_PLUG_DETECT1_EN(1)); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 313 | break; | 
|  | 314 | case RADEON_HPD_2: | 
|  | 315 | WREG32(R_007D10_DC_HOT_PLUG_DETECT2_CONTROL, | 
|  | 316 | S_007D10_DC_HOT_PLUG_DETECT2_EN(1)); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 317 | break; | 
|  | 318 | default: | 
|  | 319 | break; | 
|  | 320 | } | 
| Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 321 | enable |= 1 << radeon_connector->hpd.hpd; | 
| Alex Deucher | 64912e9 | 2011-11-03 11:21:39 -0400 | [diff] [blame] | 322 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 323 | } | 
| Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 324 | radeon_irq_kms_enable_hpd(rdev, enable); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 325 | } | 
|  | 326 |  | 
|  | 327 | void rs600_hpd_fini(struct radeon_device *rdev) | 
|  | 328 | { | 
|  | 329 | struct drm_device *dev = rdev->ddev; | 
|  | 330 | struct drm_connector *connector; | 
| Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 331 | unsigned disable = 0; | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 332 |  | 
|  | 333 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | 
|  | 334 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | 
|  | 335 | switch (radeon_connector->hpd.hpd) { | 
|  | 336 | case RADEON_HPD_1: | 
|  | 337 | WREG32(R_007D00_DC_HOT_PLUG_DETECT1_CONTROL, | 
|  | 338 | S_007D00_DC_HOT_PLUG_DETECT1_EN(0)); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 339 | break; | 
|  | 340 | case RADEON_HPD_2: | 
|  | 341 | WREG32(R_007D10_DC_HOT_PLUG_DETECT2_CONTROL, | 
|  | 342 | S_007D10_DC_HOT_PLUG_DETECT2_EN(0)); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 343 | break; | 
|  | 344 | default: | 
|  | 345 | break; | 
|  | 346 | } | 
| Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 347 | disable |= 1 << radeon_connector->hpd.hpd; | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 348 | } | 
| Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 349 | radeon_irq_kms_disable_hpd(rdev, disable); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 350 | } | 
|  | 351 |  | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 352 | int rs600_asic_reset(struct radeon_device *rdev) | 
|  | 353 | { | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 354 | struct rv515_mc_save save; | 
| Alex Deucher | 25b2ec5b | 2011-01-11 13:36:55 -0500 | [diff] [blame] | 355 | u32 status, tmp; | 
|  | 356 | int ret = 0; | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 357 |  | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 358 | status = RREG32(R_000E40_RBBM_STATUS); | 
|  | 359 | if (!G_000E40_GUI_ACTIVE(status)) { | 
|  | 360 | return 0; | 
|  | 361 | } | 
| Alex Deucher | 25b2ec5b | 2011-01-11 13:36:55 -0500 | [diff] [blame] | 362 | /* Stops all mc clients */ | 
|  | 363 | rv515_mc_stop(rdev, &save); | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 364 | status = RREG32(R_000E40_RBBM_STATUS); | 
|  | 365 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); | 
|  | 366 | /* stop CP */ | 
|  | 367 | WREG32(RADEON_CP_CSQ_CNTL, 0); | 
|  | 368 | tmp = RREG32(RADEON_CP_RB_CNTL); | 
|  | 369 | WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA); | 
|  | 370 | WREG32(RADEON_CP_RB_RPTR_WR, 0); | 
|  | 371 | WREG32(RADEON_CP_RB_WPTR, 0); | 
|  | 372 | WREG32(RADEON_CP_RB_CNTL, tmp); | 
|  | 373 | pci_save_state(rdev->pdev); | 
|  | 374 | /* disable bus mastering */ | 
| Michel Dänzer | 642ce52 | 2012-01-12 16:04:11 +0100 | [diff] [blame] | 375 | pci_clear_master(rdev->pdev); | 
|  | 376 | mdelay(1); | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 377 | /* reset GA+VAP */ | 
|  | 378 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) | | 
|  | 379 | S_0000F0_SOFT_RESET_GA(1)); | 
|  | 380 | RREG32(R_0000F0_RBBM_SOFT_RESET); | 
|  | 381 | mdelay(500); | 
|  | 382 | WREG32(R_0000F0_RBBM_SOFT_RESET, 0); | 
|  | 383 | mdelay(1); | 
|  | 384 | status = RREG32(R_000E40_RBBM_STATUS); | 
|  | 385 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); | 
|  | 386 | /* reset CP */ | 
|  | 387 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_CP(1)); | 
|  | 388 | RREG32(R_0000F0_RBBM_SOFT_RESET); | 
|  | 389 | mdelay(500); | 
|  | 390 | WREG32(R_0000F0_RBBM_SOFT_RESET, 0); | 
|  | 391 | mdelay(1); | 
|  | 392 | status = RREG32(R_000E40_RBBM_STATUS); | 
|  | 393 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); | 
|  | 394 | /* reset MC */ | 
|  | 395 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_MC(1)); | 
|  | 396 | RREG32(R_0000F0_RBBM_SOFT_RESET); | 
|  | 397 | mdelay(500); | 
|  | 398 | WREG32(R_0000F0_RBBM_SOFT_RESET, 0); | 
|  | 399 | mdelay(1); | 
|  | 400 | status = RREG32(R_000E40_RBBM_STATUS); | 
|  | 401 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); | 
|  | 402 | /* restore PCI & busmastering */ | 
|  | 403 | pci_restore_state(rdev->pdev); | 
|  | 404 | /* Check if GPU is idle */ | 
|  | 405 | if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) { | 
|  | 406 | dev_err(rdev->dev, "failed to reset GPU\n"); | 
| Alex Deucher | 25b2ec5b | 2011-01-11 13:36:55 -0500 | [diff] [blame] | 407 | ret = -1; | 
|  | 408 | } else | 
|  | 409 | dev_info(rdev->dev, "GPU reset succeed\n"); | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 410 | rv515_mc_resume(rdev, &save); | 
| Alex Deucher | 25b2ec5b | 2011-01-11 13:36:55 -0500 | [diff] [blame] | 411 | return ret; | 
| Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 412 | } | 
|  | 413 |  | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 414 | /* | 
|  | 415 | * GART. | 
|  | 416 | */ | 
|  | 417 | void rs600_gart_tlb_flush(struct radeon_device *rdev) | 
|  | 418 | { | 
|  | 419 | uint32_t tmp; | 
|  | 420 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 421 | tmp = RREG32_MC(R_000100_MC_PT0_CNTL); | 
|  | 422 | tmp &= C_000100_INVALIDATE_ALL_L1_TLBS & C_000100_INVALIDATE_L2_CACHE; | 
|  | 423 | WREG32_MC(R_000100_MC_PT0_CNTL, tmp); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 424 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 425 | tmp = RREG32_MC(R_000100_MC_PT0_CNTL); | 
| Jerome Glisse | 30f69f3 | 2010-04-16 18:46:35 +0200 | [diff] [blame] | 426 | tmp |= S_000100_INVALIDATE_ALL_L1_TLBS(1) | S_000100_INVALIDATE_L2_CACHE(1); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 427 | WREG32_MC(R_000100_MC_PT0_CNTL, tmp); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 428 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 429 | tmp = RREG32_MC(R_000100_MC_PT0_CNTL); | 
|  | 430 | tmp &= C_000100_INVALIDATE_ALL_L1_TLBS & C_000100_INVALIDATE_L2_CACHE; | 
|  | 431 | WREG32_MC(R_000100_MC_PT0_CNTL, tmp); | 
|  | 432 | tmp = RREG32_MC(R_000100_MC_PT0_CNTL); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 433 | } | 
|  | 434 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 435 | static int rs600_gart_init(struct radeon_device *rdev) | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 436 | { | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 437 | int r; | 
|  | 438 |  | 
| Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 439 | if (rdev->gart.robj) { | 
| Joe Perches | fce7d61 | 2010-10-30 21:08:30 +0000 | [diff] [blame] | 440 | WARN(1, "RS600 GART already initialized\n"); | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 441 | return 0; | 
|  | 442 | } | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 443 | /* Initialize common gart structure */ | 
|  | 444 | r = radeon_gart_init(rdev); | 
|  | 445 | if (r) { | 
|  | 446 | return r; | 
|  | 447 | } | 
|  | 448 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 8; | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 449 | return radeon_gart_table_vram_alloc(rdev); | 
|  | 450 | } | 
|  | 451 |  | 
| Alex Deucher | e22e6d2 | 2011-07-11 20:27:23 +0000 | [diff] [blame] | 452 | static int rs600_gart_enable(struct radeon_device *rdev) | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 453 | { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 454 | u32 tmp; | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 455 | int r, i; | 
|  | 456 |  | 
| Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 457 | if (rdev->gart.robj == NULL) { | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 458 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); | 
|  | 459 | return -EINVAL; | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 460 | } | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 461 | r = radeon_gart_table_vram_pin(rdev); | 
|  | 462 | if (r) | 
|  | 463 | return r; | 
| Dave Airlie | 8256856 | 2010-02-05 16:00:07 +1000 | [diff] [blame] | 464 | radeon_gart_restore(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 465 | /* Enable bus master */ | 
| Alex Deucher | e22e6d2 | 2011-07-11 20:27:23 +0000 | [diff] [blame] | 466 | tmp = RREG32(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS; | 
|  | 467 | WREG32(RADEON_BUS_CNTL, tmp); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 468 | /* FIXME: setup default page */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 469 | WREG32_MC(R_000100_MC_PT0_CNTL, | 
| Alex Deucher | 4f15d24 | 2009-12-05 17:55:37 -0500 | [diff] [blame] | 470 | (S_000100_EFFECTIVE_L2_CACHE_SIZE(6) | | 
|  | 471 | S_000100_EFFECTIVE_L2_QUEUE_SIZE(6))); | 
|  | 472 |  | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 473 | for (i = 0; i < 19; i++) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 474 | WREG32_MC(R_00016C_MC_PT0_CLIENT0_CNTL + i, | 
| Alex Deucher | 4f15d24 | 2009-12-05 17:55:37 -0500 | [diff] [blame] | 475 | S_00016C_ENABLE_TRANSLATION_MODE_OVERRIDE(1) | | 
|  | 476 | S_00016C_SYSTEM_ACCESS_MODE_MASK( | 
|  | 477 | V_00016C_SYSTEM_ACCESS_MODE_NOT_IN_SYS) | | 
|  | 478 | S_00016C_SYSTEM_APERTURE_UNMAPPED_ACCESS( | 
|  | 479 | V_00016C_SYSTEM_APERTURE_UNMAPPED_PASSTHROUGH) | | 
|  | 480 | S_00016C_EFFECTIVE_L1_CACHE_SIZE(3) | | 
|  | 481 | S_00016C_ENABLE_FRAGMENT_PROCESSING(1) | | 
|  | 482 | S_00016C_EFFECTIVE_L1_QUEUE_SIZE(3)); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 483 | } | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 484 | /* enable first context */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 485 | WREG32_MC(R_000102_MC_PT0_CONTEXT0_CNTL, | 
| Alex Deucher | 4f15d24 | 2009-12-05 17:55:37 -0500 | [diff] [blame] | 486 | S_000102_ENABLE_PAGE_TABLE(1) | | 
|  | 487 | S_000102_PAGE_TABLE_DEPTH(V_000102_PAGE_TABLE_FLAT)); | 
|  | 488 |  | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 489 | /* disable all other contexts */ | 
| Alex Deucher | 4f15d24 | 2009-12-05 17:55:37 -0500 | [diff] [blame] | 490 | for (i = 1; i < 8; i++) | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 491 | WREG32_MC(R_000102_MC_PT0_CONTEXT0_CNTL + i, 0); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 492 |  | 
|  | 493 | /* setup the page table */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 494 | WREG32_MC(R_00012C_MC_PT0_CONTEXT0_FLAT_BASE_ADDR, | 
| Alex Deucher | 4f15d24 | 2009-12-05 17:55:37 -0500 | [diff] [blame] | 495 | rdev->gart.table_addr); | 
|  | 496 | WREG32_MC(R_00013C_MC_PT0_CONTEXT0_FLAT_START_ADDR, rdev->mc.gtt_start); | 
|  | 497 | WREG32_MC(R_00014C_MC_PT0_CONTEXT0_FLAT_END_ADDR, rdev->mc.gtt_end); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 498 | WREG32_MC(R_00011C_MC_PT0_CONTEXT0_DEFAULT_READ_ADDR, 0); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 499 |  | 
| Alex Deucher | 4f15d24 | 2009-12-05 17:55:37 -0500 | [diff] [blame] | 500 | /* System context maps to VRAM space */ | 
|  | 501 | WREG32_MC(R_000112_MC_PT0_SYSTEM_APERTURE_LOW_ADDR, rdev->mc.vram_start); | 
|  | 502 | WREG32_MC(R_000114_MC_PT0_SYSTEM_APERTURE_HIGH_ADDR, rdev->mc.vram_end); | 
|  | 503 |  | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 504 | /* enable page tables */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 505 | tmp = RREG32_MC(R_000100_MC_PT0_CNTL); | 
|  | 506 | WREG32_MC(R_000100_MC_PT0_CNTL, (tmp | S_000100_ENABLE_PT(1))); | 
|  | 507 | tmp = RREG32_MC(R_000009_MC_CNTL1); | 
|  | 508 | WREG32_MC(R_000009_MC_CNTL1, (tmp | S_000009_ENABLE_PAGE_TABLES(1))); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 509 | rs600_gart_tlb_flush(rdev); | 
| Tormod Volden | fcf4de5 | 2011-08-31 21:54:07 +0000 | [diff] [blame] | 510 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 
|  | 511 | (unsigned)(rdev->mc.gtt_size >> 20), | 
|  | 512 | (unsigned long long)rdev->gart.table_addr); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 513 | rdev->gart.ready = true; | 
|  | 514 | return 0; | 
|  | 515 | } | 
|  | 516 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 517 | static void rs600_gart_disable(struct radeon_device *rdev) | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 518 | { | 
| Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 519 | u32 tmp; | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 520 |  | 
|  | 521 | /* FIXME: disable out of gart access */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 522 | WREG32_MC(R_000100_MC_PT0_CNTL, 0); | 
|  | 523 | tmp = RREG32_MC(R_000009_MC_CNTL1); | 
|  | 524 | WREG32_MC(R_000009_MC_CNTL1, tmp & C_000009_ENABLE_PAGE_TABLES); | 
| Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 525 | radeon_gart_table_vram_unpin(rdev); | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 526 | } | 
|  | 527 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 528 | static void rs600_gart_fini(struct radeon_device *rdev) | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 529 | { | 
| Jerome Glisse | f927456 | 2010-03-17 14:44:29 +0000 | [diff] [blame] | 530 | radeon_gart_fini(rdev); | 
| Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 531 | rs600_gart_disable(rdev); | 
|  | 532 | radeon_gart_table_vram_free(rdev); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 533 | } | 
|  | 534 |  | 
|  | 535 | #define R600_PTE_VALID     (1 << 0) | 
|  | 536 | #define R600_PTE_SYSTEM    (1 << 1) | 
|  | 537 | #define R600_PTE_SNOOPED   (1 << 2) | 
|  | 538 | #define R600_PTE_READABLE  (1 << 5) | 
|  | 539 | #define R600_PTE_WRITEABLE (1 << 6) | 
|  | 540 |  | 
|  | 541 | int rs600_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) | 
|  | 542 | { | 
| Jerome Glisse | c9a1be9 | 2011-11-03 11:16:49 -0400 | [diff] [blame] | 543 | void __iomem *ptr = (void *)rdev->gart.ptr; | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 544 |  | 
|  | 545 | if (i < 0 || i > rdev->gart.num_gpu_pages) { | 
|  | 546 | return -EINVAL; | 
|  | 547 | } | 
|  | 548 | addr = addr & 0xFFFFFFFFFFFFF000ULL; | 
|  | 549 | addr |= R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED; | 
|  | 550 | addr |= R600_PTE_READABLE | R600_PTE_WRITEABLE; | 
| Benjamin Herrenschmidt | a0533fb | 2011-07-13 06:28:12 +0000 | [diff] [blame] | 551 | writeq(addr, ptr + (i * 8)); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 552 | return 0; | 
|  | 553 | } | 
|  | 554 |  | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 555 | int rs600_irq_set(struct radeon_device *rdev) | 
|  | 556 | { | 
|  | 557 | uint32_t tmp = 0; | 
|  | 558 | uint32_t mode_int = 0; | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 559 | u32 hpd1 = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL) & | 
|  | 560 | ~S_007D08_DC_HOT_PLUG_DETECT1_INT_EN(1); | 
|  | 561 | u32 hpd2 = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL) & | 
|  | 562 | ~S_007D18_DC_HOT_PLUG_DETECT2_INT_EN(1); | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 563 | u32 hdmi0; | 
|  | 564 | if (ASIC_IS_DCE2(rdev)) | 
|  | 565 | hdmi0 = RREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL) & | 
|  | 566 | ~S_007408_HDMI0_AZ_FORMAT_WTRIG_MASK(1); | 
|  | 567 | else | 
|  | 568 | hdmi0 = 0; | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 569 |  | 
| Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 570 | if (!rdev->irq.installed) { | 
| Joe Perches | fce7d61 | 2010-10-30 21:08:30 +0000 | [diff] [blame] | 571 | WARN(1, "Can't enable IRQ/MSI because no handler is installed\n"); | 
| Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 572 | WREG32(R_000040_GEN_INT_CNTL, 0); | 
|  | 573 | return -EINVAL; | 
|  | 574 | } | 
| Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 575 | if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 576 | tmp |= S_000040_SW_INT_EN(1); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 577 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 578 | if (rdev->irq.crtc_vblank_int[0] || | 
| Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 579 | atomic_read(&rdev->irq.pflip[0])) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 580 | mode_int |= S_006540_D1MODE_VBLANK_INT_MASK(1); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 581 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 582 | if (rdev->irq.crtc_vblank_int[1] || | 
| Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 583 | atomic_read(&rdev->irq.pflip[1])) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 584 | mode_int |= S_006540_D2MODE_VBLANK_INT_MASK(1); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 585 | } | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 586 | if (rdev->irq.hpd[0]) { | 
|  | 587 | hpd1 |= S_007D08_DC_HOT_PLUG_DETECT1_INT_EN(1); | 
|  | 588 | } | 
|  | 589 | if (rdev->irq.hpd[1]) { | 
|  | 590 | hpd2 |= S_007D18_DC_HOT_PLUG_DETECT2_INT_EN(1); | 
|  | 591 | } | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 592 | if (rdev->irq.afmt[0]) { | 
|  | 593 | hdmi0 |= S_007408_HDMI0_AZ_FORMAT_WTRIG_MASK(1); | 
|  | 594 | } | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 595 | WREG32(R_000040_GEN_INT_CNTL, tmp); | 
|  | 596 | WREG32(R_006540_DxMODE_INT_MASK, mode_int); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 597 | WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, hpd1); | 
|  | 598 | WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, hpd2); | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 599 | if (ASIC_IS_DCE2(rdev)) | 
|  | 600 | WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, hdmi0); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 601 | return 0; | 
|  | 602 | } | 
|  | 603 |  | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 604 | static inline u32 rs600_irq_ack(struct radeon_device *rdev) | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 605 | { | 
| Jerome Glisse | 01ceae8 | 2009-10-07 11:08:22 +0200 | [diff] [blame] | 606 | uint32_t irqs = RREG32(R_000044_GEN_INT_STATUS); | 
| Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 607 | uint32_t irq_mask = S_000044_SW_INT(1); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 608 | u32 tmp; | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 609 |  | 
| Jerome Glisse | 01ceae8 | 2009-10-07 11:08:22 +0200 | [diff] [blame] | 610 | if (G_000044_DISPLAY_INT_STAT(irqs)) { | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 611 | rdev->irq.stat_regs.r500.disp_int = RREG32(R_007EDC_DISP_INTERRUPT_STATUS); | 
|  | 612 | if (G_007EDC_LB_D1_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 613 | WREG32(R_006534_D1MODE_VBLANK_STATUS, | 
|  | 614 | S_006534_D1MODE_VBLANK_ACK(1)); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 615 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 616 | if (G_007EDC_LB_D2_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 617 | WREG32(R_006D34_D2MODE_VBLANK_STATUS, | 
|  | 618 | S_006D34_D2MODE_VBLANK_ACK(1)); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 619 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 620 | if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 621 | tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); | 
|  | 622 | tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_ACK(1); | 
|  | 623 | WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); | 
|  | 624 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 625 | if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 626 | tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); | 
|  | 627 | tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_ACK(1); | 
|  | 628 | WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); | 
|  | 629 | } | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 630 | } else { | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 631 | rdev->irq.stat_regs.r500.disp_int = 0; | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 632 | } | 
|  | 633 |  | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 634 | if (ASIC_IS_DCE2(rdev)) { | 
|  | 635 | rdev->irq.stat_regs.r500.hdmi0_status = RREG32(R_007404_HDMI0_STATUS) & | 
|  | 636 | S_007404_HDMI0_AZ_FORMAT_WTRIG(1); | 
|  | 637 | if (G_007404_HDMI0_AZ_FORMAT_WTRIG(rdev->irq.stat_regs.r500.hdmi0_status)) { | 
|  | 638 | tmp = RREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL); | 
|  | 639 | tmp |= S_007408_HDMI0_AZ_FORMAT_WTRIG_ACK(1); | 
|  | 640 | WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, tmp); | 
|  | 641 | } | 
|  | 642 | } else | 
|  | 643 | rdev->irq.stat_regs.r500.hdmi0_status = 0; | 
|  | 644 |  | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 645 | if (irqs) { | 
| Jerome Glisse | 01ceae8 | 2009-10-07 11:08:22 +0200 | [diff] [blame] | 646 | WREG32(R_000044_GEN_INT_STATUS, irqs); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 647 | } | 
|  | 648 | return irqs & irq_mask; | 
|  | 649 | } | 
|  | 650 |  | 
| Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 651 | void rs600_irq_disable(struct radeon_device *rdev) | 
|  | 652 | { | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 653 | u32 hdmi0 = RREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL) & | 
|  | 654 | ~S_007408_HDMI0_AZ_FORMAT_WTRIG_MASK(1); | 
|  | 655 | WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, hdmi0); | 
| Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 656 | WREG32(R_000040_GEN_INT_CNTL, 0); | 
|  | 657 | WREG32(R_006540_DxMODE_INT_MASK, 0); | 
|  | 658 | /* Wait and acknowledge irq */ | 
|  | 659 | mdelay(1); | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 660 | rs600_irq_ack(rdev); | 
| Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 661 | } | 
|  | 662 |  | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 663 | int rs600_irq_process(struct radeon_device *rdev) | 
|  | 664 | { | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 665 | u32 status, msi_rearm; | 
| Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 666 | bool queue_hotplug = false; | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 667 | bool queue_hdmi = false; | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 668 |  | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 669 | status = rs600_irq_ack(rdev); | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 670 | if (!status && | 
|  | 671 | !rdev->irq.stat_regs.r500.disp_int && | 
|  | 672 | !rdev->irq.stat_regs.r500.hdmi0_status) { | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 673 | return IRQ_NONE; | 
|  | 674 | } | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 675 | while (status || | 
|  | 676 | rdev->irq.stat_regs.r500.disp_int || | 
|  | 677 | rdev->irq.stat_regs.r500.hdmi0_status) { | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 678 | /* SW interrupt */ | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 679 | if (G_000044_SW_INT(status)) { | 
| Alex Deucher | 7465280 | 2011-08-25 13:39:48 -0400 | [diff] [blame] | 680 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 681 | } | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 682 | /* Vertical blank interrupts */ | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 683 | if (G_007EDC_LB_D1_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 684 | if (rdev->irq.crtc_vblank_int[0]) { | 
|  | 685 | drm_handle_vblank(rdev->ddev, 0); | 
|  | 686 | rdev->pm.vblank_sync = true; | 
|  | 687 | wake_up(&rdev->irq.vblank_queue); | 
|  | 688 | } | 
| Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 689 | if (atomic_read(&rdev->irq.pflip[0])) | 
| Mario Kleiner | 3e4ea74 | 2010-11-21 10:59:02 -0500 | [diff] [blame] | 690 | radeon_crtc_handle_flip(rdev, 0); | 
| Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 691 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 692 | if (G_007EDC_LB_D2_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 693 | if (rdev->irq.crtc_vblank_int[1]) { | 
|  | 694 | drm_handle_vblank(rdev->ddev, 1); | 
|  | 695 | rdev->pm.vblank_sync = true; | 
|  | 696 | wake_up(&rdev->irq.vblank_queue); | 
|  | 697 | } | 
| Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 698 | if (atomic_read(&rdev->irq.pflip[1])) | 
| Mario Kleiner | 3e4ea74 | 2010-11-21 10:59:02 -0500 | [diff] [blame] | 699 | radeon_crtc_handle_flip(rdev, 1); | 
| Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 700 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 701 | if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 702 | queue_hotplug = true; | 
|  | 703 | DRM_DEBUG("HPD1\n"); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 704 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 705 | if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { | 
| Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 706 | queue_hotplug = true; | 
|  | 707 | DRM_DEBUG("HPD2\n"); | 
| Alex Deucher | dcfdd40 | 2009-12-04 15:04:19 -0500 | [diff] [blame] | 708 | } | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 709 | if (G_007404_HDMI0_AZ_FORMAT_WTRIG(rdev->irq.stat_regs.r500.hdmi0_status)) { | 
|  | 710 | queue_hdmi = true; | 
|  | 711 | DRM_DEBUG("HDMI0\n"); | 
|  | 712 | } | 
| Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 713 | status = rs600_irq_ack(rdev); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 714 | } | 
| Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 715 | if (queue_hotplug) | 
| Tejun Heo | 32c87fc | 2011-01-03 14:49:32 +0100 | [diff] [blame] | 716 | schedule_work(&rdev->hotplug_work); | 
| Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 717 | if (queue_hdmi) | 
|  | 718 | schedule_work(&rdev->audio_work); | 
| Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 719 | if (rdev->msi_enabled) { | 
|  | 720 | switch (rdev->family) { | 
|  | 721 | case CHIP_RS600: | 
|  | 722 | case CHIP_RS690: | 
|  | 723 | case CHIP_RS740: | 
|  | 724 | msi_rearm = RREG32(RADEON_BUS_CNTL) & ~RS600_MSI_REARM; | 
|  | 725 | WREG32(RADEON_BUS_CNTL, msi_rearm); | 
|  | 726 | WREG32(RADEON_BUS_CNTL, msi_rearm | RS600_MSI_REARM); | 
|  | 727 | break; | 
|  | 728 | default: | 
| Alex Deucher | b7f5b7d | 2012-02-13 16:36:34 -0500 | [diff] [blame] | 729 | WREG32(RADEON_MSI_REARM_EN, RV370_MSI_REARM_EN); | 
| Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 730 | break; | 
|  | 731 | } | 
|  | 732 | } | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 733 | return IRQ_HANDLED; | 
|  | 734 | } | 
|  | 735 |  | 
|  | 736 | u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc) | 
|  | 737 | { | 
|  | 738 | if (crtc == 0) | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 739 | return RREG32(R_0060A4_D1CRTC_STATUS_FRAME_COUNT); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 740 | else | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 741 | return RREG32(R_0068A4_D2CRTC_STATUS_FRAME_COUNT); | 
| Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 742 | } | 
|  | 743 |  | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 744 | int rs600_mc_wait_for_idle(struct radeon_device *rdev) | 
|  | 745 | { | 
|  | 746 | unsigned i; | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 747 |  | 
|  | 748 | for (i = 0; i < rdev->usec_timeout; i++) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 749 | if (G_000000_MC_IDLE(RREG32_MC(R_000000_MC_STATUS))) | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 750 | return 0; | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 751 | udelay(1); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 752 | } | 
|  | 753 | return -1; | 
|  | 754 | } | 
|  | 755 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 756 | static void rs600_gpu_init(struct radeon_device *rdev) | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 757 | { | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 758 | r420_pipes_init(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 759 | /* Wait for mc idle */ | 
|  | 760 | if (rs600_mc_wait_for_idle(rdev)) | 
|  | 761 | dev_warn(rdev->dev, "Wait MC idle timeout before updating MC.\n"); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 762 | } | 
|  | 763 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 764 | static void rs600_mc_init(struct radeon_device *rdev) | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 765 | { | 
| Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 766 | u64 base; | 
|  | 767 |  | 
| Jordan Crouse | 01d73a6 | 2010-05-27 13:40:24 -0600 | [diff] [blame] | 768 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); | 
|  | 769 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 770 | rdev->mc.vram_is_ddr = true; | 
|  | 771 | rdev->mc.vram_width = 128; | 
| Alex Deucher | 722f294 | 2009-12-03 16:18:19 -0500 | [diff] [blame] | 772 | rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); | 
|  | 773 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | 
| Jerome Glisse | 51e5fcd | 2010-02-19 14:33:54 +0000 | [diff] [blame] | 774 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 
| Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 775 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); | 
|  | 776 | base = RREG32_MC(R_000004_MC_FB_LOCATION); | 
|  | 777 | base = G_000004_MC_FB_START(base) << 16; | 
|  | 778 | radeon_vram_location(rdev, &rdev->mc, base); | 
| Alex Deucher | 8d369bb | 2010-07-15 10:51:10 -0400 | [diff] [blame] | 779 | rdev->mc.gtt_base_align = 0; | 
| Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 780 | radeon_gtt_location(rdev, &rdev->mc); | 
| Alex Deucher | f47299c | 2010-03-16 20:54:38 -0400 | [diff] [blame] | 781 | radeon_update_bandwidth_info(rdev); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 782 | } | 
|  | 783 |  | 
| Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 784 | void rs600_bandwidth_update(struct radeon_device *rdev) | 
|  | 785 | { | 
| Alex Deucher | f46c012 | 2010-03-31 00:33:27 -0400 | [diff] [blame] | 786 | struct drm_display_mode *mode0 = NULL; | 
|  | 787 | struct drm_display_mode *mode1 = NULL; | 
|  | 788 | u32 d1mode_priority_a_cnt, d2mode_priority_a_cnt; | 
|  | 789 | /* FIXME: implement full support */ | 
|  | 790 |  | 
|  | 791 | radeon_update_display_priority(rdev); | 
|  | 792 |  | 
|  | 793 | if (rdev->mode_info.crtcs[0]->base.enabled) | 
|  | 794 | mode0 = &rdev->mode_info.crtcs[0]->base.mode; | 
|  | 795 | if (rdev->mode_info.crtcs[1]->base.enabled) | 
|  | 796 | mode1 = &rdev->mode_info.crtcs[1]->base.mode; | 
|  | 797 |  | 
|  | 798 | rs690_line_buffer_adjust(rdev, mode0, mode1); | 
|  | 799 |  | 
|  | 800 | if (rdev->disp_priority == 2) { | 
|  | 801 | d1mode_priority_a_cnt = RREG32(R_006548_D1MODE_PRIORITY_A_CNT); | 
|  | 802 | d2mode_priority_a_cnt = RREG32(R_006D48_D2MODE_PRIORITY_A_CNT); | 
|  | 803 | d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1); | 
|  | 804 | d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1); | 
|  | 805 | WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt); | 
|  | 806 | WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt); | 
|  | 807 | WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt); | 
|  | 808 | WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt); | 
|  | 809 | } | 
| Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 810 | } | 
|  | 811 |  | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 812 | uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg) | 
|  | 813 | { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 814 | WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | | 
|  | 815 | S_000070_MC_IND_CITF_ARB0(1)); | 
|  | 816 | return RREG32(R_000074_MC_IND_DATA); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 817 | } | 
|  | 818 |  | 
|  | 819 | void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) | 
|  | 820 | { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 821 | WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | | 
|  | 822 | S_000070_MC_IND_CITF_ARB0(1) | S_000070_MC_IND_WR_EN(1)); | 
|  | 823 | WREG32(R_000074_MC_IND_DATA, v); | 
|  | 824 | } | 
|  | 825 |  | 
| Lauri Kasanen | 1109ca0 | 2012-08-31 13:43:50 -0400 | [diff] [blame] | 826 | static void rs600_debugfs(struct radeon_device *rdev) | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 827 | { | 
|  | 828 | if (r100_debugfs_rbbm_init(rdev)) | 
|  | 829 | DRM_ERROR("Failed to register debugfs file for RBBM !\n"); | 
| Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 830 | } | 
| Dave Airlie | 3f7dc91a | 2009-08-27 11:10:15 +1000 | [diff] [blame] | 831 |  | 
| Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 832 | void rs600_set_safe_registers(struct radeon_device *rdev) | 
| Dave Airlie | 3f7dc91a | 2009-08-27 11:10:15 +1000 | [diff] [blame] | 833 | { | 
|  | 834 | rdev->config.r300.reg_safe_bm = rs600_reg_safe_bm; | 
|  | 835 | rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(rs600_reg_safe_bm); | 
| Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 836 | } | 
|  | 837 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 838 | static void rs600_mc_program(struct radeon_device *rdev) | 
|  | 839 | { | 
|  | 840 | struct rv515_mc_save save; | 
|  | 841 |  | 
|  | 842 | /* Stops all mc clients */ | 
|  | 843 | rv515_mc_stop(rdev, &save); | 
|  | 844 |  | 
|  | 845 | /* Wait for mc idle */ | 
|  | 846 | if (rs600_mc_wait_for_idle(rdev)) | 
|  | 847 | dev_warn(rdev->dev, "Wait MC idle timeout before updating MC.\n"); | 
|  | 848 |  | 
|  | 849 | /* FIXME: What does AGP means for such chipset ? */ | 
|  | 850 | WREG32_MC(R_000005_MC_AGP_LOCATION, 0x0FFFFFFF); | 
|  | 851 | WREG32_MC(R_000006_AGP_BASE, 0); | 
|  | 852 | WREG32_MC(R_000007_AGP_BASE_2, 0); | 
|  | 853 | /* Program MC */ | 
|  | 854 | WREG32_MC(R_000004_MC_FB_LOCATION, | 
|  | 855 | S_000004_MC_FB_START(rdev->mc.vram_start >> 16) | | 
|  | 856 | S_000004_MC_FB_TOP(rdev->mc.vram_end >> 16)); | 
|  | 857 | WREG32(R_000134_HDP_FB_LOCATION, | 
|  | 858 | S_000134_HDP_FB_START(rdev->mc.vram_start >> 16)); | 
|  | 859 |  | 
|  | 860 | rv515_mc_resume(rdev, &save); | 
|  | 861 | } | 
|  | 862 |  | 
|  | 863 | static int rs600_startup(struct radeon_device *rdev) | 
|  | 864 | { | 
|  | 865 | int r; | 
|  | 866 |  | 
|  | 867 | rs600_mc_program(rdev); | 
|  | 868 | /* Resume clock */ | 
|  | 869 | rv515_clock_startup(rdev); | 
|  | 870 | /* Initialize GPU configuration (# pipes, ...) */ | 
|  | 871 | rs600_gpu_init(rdev); | 
|  | 872 | /* Initialize GART (initialize after TTM so we can allocate | 
|  | 873 | * memory through TTM but finalize after TTM) */ | 
|  | 874 | r = rs600_gart_enable(rdev); | 
|  | 875 | if (r) | 
|  | 876 | return r; | 
| Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 877 |  | 
|  | 878 | /* allocate wb buffer */ | 
|  | 879 | r = radeon_wb_init(rdev); | 
|  | 880 | if (r) | 
|  | 881 | return r; | 
|  | 882 |  | 
| Jerome Glisse | 30eb77f | 2011-11-20 20:45:34 +0000 | [diff] [blame] | 883 | r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); | 
|  | 884 | if (r) { | 
|  | 885 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); | 
|  | 886 | return r; | 
|  | 887 | } | 
|  | 888 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 889 | /* Enable IRQ */ | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 890 | rs600_irq_set(rdev); | 
| Jerome Glisse | cafe660 | 2010-01-07 12:39:21 +0100 | [diff] [blame] | 891 | rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 892 | /* 1M ring buffer */ | 
|  | 893 | r = r100_cp_init(rdev, 1024 * 1024); | 
|  | 894 | if (r) { | 
| Paul Bolle | ec4f2ac | 2011-01-28 23:32:04 +0100 | [diff] [blame] | 895 | dev_err(rdev->dev, "failed initializing CP (%d).\n", r); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 896 | return r; | 
|  | 897 | } | 
| Rafał Miłecki | fe50ac7 | 2010-06-19 12:24:57 +0200 | [diff] [blame] | 898 |  | 
| Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 899 | r = radeon_ib_pool_init(rdev); | 
|  | 900 | if (r) { | 
|  | 901 | dev_err(rdev->dev, "IB initialization failed (%d).\n", r); | 
| Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 902 | return r; | 
| Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 903 | } | 
| Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 904 |  | 
| Alex Deucher | d4e30ef | 2012-06-04 17:18:51 -0400 | [diff] [blame] | 905 | r = r600_audio_init(rdev); | 
|  | 906 | if (r) { | 
|  | 907 | dev_err(rdev->dev, "failed initializing audio\n"); | 
|  | 908 | return r; | 
|  | 909 | } | 
|  | 910 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 911 | return 0; | 
|  | 912 | } | 
|  | 913 |  | 
|  | 914 | int rs600_resume(struct radeon_device *rdev) | 
|  | 915 | { | 
| Jerome Glisse | 6b7746e | 2012-02-20 17:57:20 -0500 | [diff] [blame] | 916 | int r; | 
|  | 917 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 918 | /* Make sur GART are not working */ | 
|  | 919 | rs600_gart_disable(rdev); | 
|  | 920 | /* Resume clock before doing reset */ | 
|  | 921 | rv515_clock_startup(rdev); | 
|  | 922 | /* Reset gpu before posting otherwise ATOM will enter infinite loop */ | 
| Jerome Glisse | a2d07b7 | 2010-03-09 14:45:11 +0000 | [diff] [blame] | 923 | if (radeon_asic_reset(rdev)) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 924 | dev_warn(rdev->dev, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", | 
|  | 925 | RREG32(R_000E40_RBBM_STATUS), | 
|  | 926 | RREG32(R_0007C0_CP_STAT)); | 
|  | 927 | } | 
|  | 928 | /* post */ | 
|  | 929 | atom_asic_init(rdev->mode_info.atom_context); | 
|  | 930 | /* Resume clock after posting */ | 
|  | 931 | rv515_clock_startup(rdev); | 
| Dave Airlie | 550e2d9 | 2009-12-09 14:15:38 +1000 | [diff] [blame] | 932 | /* Initialize surface registers */ | 
|  | 933 | radeon_surface_init(rdev); | 
| Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 934 |  | 
|  | 935 | rdev->accel_working = true; | 
| Jerome Glisse | 6b7746e | 2012-02-20 17:57:20 -0500 | [diff] [blame] | 936 | r = rs600_startup(rdev); | 
|  | 937 | if (r) { | 
|  | 938 | rdev->accel_working = false; | 
|  | 939 | } | 
|  | 940 | return r; | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 941 | } | 
|  | 942 |  | 
|  | 943 | int rs600_suspend(struct radeon_device *rdev) | 
|  | 944 | { | 
| Rafał Miłecki | fe50ac7 | 2010-06-19 12:24:57 +0200 | [diff] [blame] | 945 | r600_audio_fini(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 946 | r100_cp_disable(rdev); | 
| Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 947 | radeon_wb_disable(rdev); | 
| Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 948 | rs600_irq_disable(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 949 | rs600_gart_disable(rdev); | 
|  | 950 | return 0; | 
|  | 951 | } | 
|  | 952 |  | 
|  | 953 | void rs600_fini(struct radeon_device *rdev) | 
|  | 954 | { | 
| Rafał Miłecki | fe50ac7 | 2010-06-19 12:24:57 +0200 | [diff] [blame] | 955 | r600_audio_fini(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 956 | r100_cp_fini(rdev); | 
| Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 957 | radeon_wb_fini(rdev); | 
| Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 958 | radeon_ib_pool_fini(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 959 | radeon_gem_fini(rdev); | 
|  | 960 | rs600_gart_fini(rdev); | 
|  | 961 | radeon_irq_kms_fini(rdev); | 
|  | 962 | radeon_fence_driver_fini(rdev); | 
| Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 963 | radeon_bo_fini(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 964 | radeon_atombios_fini(rdev); | 
|  | 965 | kfree(rdev->bios); | 
|  | 966 | rdev->bios = NULL; | 
|  | 967 | } | 
|  | 968 |  | 
| Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 969 | int rs600_init(struct radeon_device *rdev) | 
|  | 970 | { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 971 | int r; | 
|  | 972 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 973 | /* Disable VGA */ | 
|  | 974 | rv515_vga_render_disable(rdev); | 
|  | 975 | /* Initialize scratch registers */ | 
|  | 976 | radeon_scratch_init(rdev); | 
|  | 977 | /* Initialize surface registers */ | 
|  | 978 | radeon_surface_init(rdev); | 
| Dave Airlie | 4c712e6 | 2010-07-15 12:13:50 +1000 | [diff] [blame] | 979 | /* restore some register to sane defaults */ | 
|  | 980 | r100_restore_sanity(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 981 | /* BIOS */ | 
|  | 982 | if (!radeon_get_bios(rdev)) { | 
|  | 983 | if (ASIC_IS_AVIVO(rdev)) | 
|  | 984 | return -EINVAL; | 
|  | 985 | } | 
|  | 986 | if (rdev->is_atom_bios) { | 
|  | 987 | r = radeon_atombios_init(rdev); | 
|  | 988 | if (r) | 
|  | 989 | return r; | 
|  | 990 | } else { | 
|  | 991 | dev_err(rdev->dev, "Expecting atombios for RS600 GPU\n"); | 
|  | 992 | return -EINVAL; | 
|  | 993 | } | 
|  | 994 | /* Reset gpu before posting otherwise ATOM will enter infinite loop */ | 
| Jerome Glisse | a2d07b7 | 2010-03-09 14:45:11 +0000 | [diff] [blame] | 995 | if (radeon_asic_reset(rdev)) { | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 996 | dev_warn(rdev->dev, | 
|  | 997 | "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", | 
|  | 998 | RREG32(R_000E40_RBBM_STATUS), | 
|  | 999 | RREG32(R_0007C0_CP_STAT)); | 
|  | 1000 | } | 
|  | 1001 | /* check if cards are posted or not */ | 
| Dave Airlie | 72542d7 | 2009-12-01 14:06:31 +1000 | [diff] [blame] | 1002 | if (radeon_boot_test_post_card(rdev) == false) | 
|  | 1003 | return -EINVAL; | 
|  | 1004 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1005 | /* Initialize clocks */ | 
|  | 1006 | radeon_get_clock_info(rdev->ddev); | 
| Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1007 | /* initialize memory controller */ | 
|  | 1008 | rs600_mc_init(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1009 | rs600_debugfs(rdev); | 
|  | 1010 | /* Fence driver */ | 
| Jerome Glisse | 30eb77f | 2011-11-20 20:45:34 +0000 | [diff] [blame] | 1011 | r = radeon_fence_driver_init(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1012 | if (r) | 
|  | 1013 | return r; | 
|  | 1014 | r = radeon_irq_kms_init(rdev); | 
|  | 1015 | if (r) | 
|  | 1016 | return r; | 
|  | 1017 | /* Memory manager */ | 
| Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1018 | r = radeon_bo_init(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1019 | if (r) | 
|  | 1020 | return r; | 
|  | 1021 | r = rs600_gart_init(rdev); | 
|  | 1022 | if (r) | 
|  | 1023 | return r; | 
|  | 1024 | rs600_set_safe_registers(rdev); | 
| Jerome Glisse | b15ba51 | 2011-11-15 11:48:34 -0500 | [diff] [blame] | 1025 |  | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1026 | rdev->accel_working = true; | 
|  | 1027 | r = rs600_startup(rdev); | 
|  | 1028 | if (r) { | 
|  | 1029 | /* Somethings want wront with the accel init stop accel */ | 
|  | 1030 | dev_err(rdev->dev, "Disabling GPU acceleration\n"); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1031 | r100_cp_fini(rdev); | 
| Alex Deucher | 724c80e | 2010-08-27 18:25:25 -0400 | [diff] [blame] | 1032 | radeon_wb_fini(rdev); | 
| Christian König | 2898c34 | 2012-07-05 11:55:34 +0200 | [diff] [blame] | 1033 | radeon_ib_pool_fini(rdev); | 
| Jerome Glisse | c010f80 | 2009-09-30 22:09:06 +0200 | [diff] [blame] | 1034 | rs600_gart_fini(rdev); | 
|  | 1035 | radeon_irq_kms_fini(rdev); | 
|  | 1036 | rdev->accel_working = false; | 
|  | 1037 | } | 
| Dave Airlie | 3f7dc91a | 2009-08-27 11:10:15 +1000 | [diff] [blame] | 1038 | return 0; | 
|  | 1039 | } |