18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2008 Advanced Micro Devices, Inc. 38c2ecf20Sopenharmony_ci * Copyright 2008 Red Hat Inc. 48c2ecf20Sopenharmony_ci * Copyright 2009 Jerome Glisse. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 78c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 88c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 98c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 108c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 118c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 148c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 198c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 208c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 218c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 228c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * Authors: Dave Airlie 258c2ecf20Sopenharmony_ci * Alex Deucher 268c2ecf20Sopenharmony_ci * Jerome Glisse 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_ci/* RS600 / Radeon X1250/X1270 integrated GPU 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * This file gather function specific to RS600 which is the IGP of 318c2ecf20Sopenharmony_ci * the X1250/X1270 family supporting intel CPU (while RS690/RS740 328c2ecf20Sopenharmony_ci * is the X1250/X1270 supporting AMD CPU). The display engine are 338c2ecf20Sopenharmony_ci * the avivo one, bios is an atombios, 3D block are the one of the 348c2ecf20Sopenharmony_ci * R4XX family. The GART is different from the RS400 one and is very 358c2ecf20Sopenharmony_ci * close to the one of the R600 family (R600 likely being an evolution 368c2ecf20Sopenharmony_ci * of the RS600 GART block). 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#include <linux/io-64-nonatomic-lo-hi.h> 408c2ecf20Sopenharmony_ci#include <linux/pci.h> 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#include <drm/drm_device.h> 438c2ecf20Sopenharmony_ci#include <drm/drm_vblank.h> 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#include "atom.h" 468c2ecf20Sopenharmony_ci#include "radeon.h" 478c2ecf20Sopenharmony_ci#include "radeon_asic.h" 488c2ecf20Sopenharmony_ci#include "radeon_audio.h" 498c2ecf20Sopenharmony_ci#include "rs600_reg_safe.h" 508c2ecf20Sopenharmony_ci#include "rs600d.h" 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic void rs600_gpu_init(struct radeon_device *rdev); 538c2ecf20Sopenharmony_ciint rs600_mc_wait_for_idle(struct radeon_device *rdev); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic const u32 crtc_offsets[2] = 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci 0, 588c2ecf20Sopenharmony_ci AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic bool avivo_is_in_vblank(struct radeon_device *rdev, int crtc) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci if (RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK) 648c2ecf20Sopenharmony_ci return true; 658c2ecf20Sopenharmony_ci else 668c2ecf20Sopenharmony_ci return false; 678c2ecf20Sopenharmony_ci} 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic bool avivo_is_counter_moving(struct radeon_device *rdev, int crtc) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci u32 pos1, pos2; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci pos1 = RREG32(AVIVO_D1CRTC_STATUS_POSITION + crtc_offsets[crtc]); 748c2ecf20Sopenharmony_ci pos2 = RREG32(AVIVO_D1CRTC_STATUS_POSITION + crtc_offsets[crtc]); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci if (pos1 != pos2) 778c2ecf20Sopenharmony_ci return true; 788c2ecf20Sopenharmony_ci else 798c2ecf20Sopenharmony_ci return false; 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/** 838c2ecf20Sopenharmony_ci * avivo_wait_for_vblank - vblank wait asic callback. 848c2ecf20Sopenharmony_ci * 858c2ecf20Sopenharmony_ci * @rdev: radeon_device pointer 868c2ecf20Sopenharmony_ci * @crtc: crtc to wait for vblank on 878c2ecf20Sopenharmony_ci * 888c2ecf20Sopenharmony_ci * Wait for vblank on the requested crtc (r5xx-r7xx). 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_civoid avivo_wait_for_vblank(struct radeon_device *rdev, int crtc) 918c2ecf20Sopenharmony_ci{ 928c2ecf20Sopenharmony_ci unsigned i = 0; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci if (crtc >= rdev->num_crtc) 958c2ecf20Sopenharmony_ci return; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci if (!(RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[crtc]) & AVIVO_CRTC_EN)) 988c2ecf20Sopenharmony_ci return; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci /* depending on when we hit vblank, we may be close to active; if so, 1018c2ecf20Sopenharmony_ci * wait for another frame. 1028c2ecf20Sopenharmony_ci */ 1038c2ecf20Sopenharmony_ci while (avivo_is_in_vblank(rdev, crtc)) { 1048c2ecf20Sopenharmony_ci if (i++ % 100 == 0) { 1058c2ecf20Sopenharmony_ci if (!avivo_is_counter_moving(rdev, crtc)) 1068c2ecf20Sopenharmony_ci break; 1078c2ecf20Sopenharmony_ci } 1088c2ecf20Sopenharmony_ci } 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci while (!avivo_is_in_vblank(rdev, crtc)) { 1118c2ecf20Sopenharmony_ci if (i++ % 100 == 0) { 1128c2ecf20Sopenharmony_ci if (!avivo_is_counter_moving(rdev, crtc)) 1138c2ecf20Sopenharmony_ci break; 1148c2ecf20Sopenharmony_ci } 1158c2ecf20Sopenharmony_ci } 1168c2ecf20Sopenharmony_ci} 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_civoid rs600_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base, bool async) 1198c2ecf20Sopenharmony_ci{ 1208c2ecf20Sopenharmony_ci struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; 1218c2ecf20Sopenharmony_ci u32 tmp = RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset); 1228c2ecf20Sopenharmony_ci int i; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci /* Lock the graphics update lock */ 1258c2ecf20Sopenharmony_ci tmp |= AVIVO_D1GRPH_UPDATE_LOCK; 1268c2ecf20Sopenharmony_ci WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci /* update the scanout addresses */ 1298c2ecf20Sopenharmony_ci WREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, 1308c2ecf20Sopenharmony_ci async ? AVIVO_D1GRPH_SURFACE_UPDATE_H_RETRACE_EN : 0); 1318c2ecf20Sopenharmony_ci WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 1328c2ecf20Sopenharmony_ci (u32)crtc_base); 1338c2ecf20Sopenharmony_ci WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 1348c2ecf20Sopenharmony_ci (u32)crtc_base); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci /* Wait for update_pending to go high. */ 1378c2ecf20Sopenharmony_ci for (i = 0; i < rdev->usec_timeout; i++) { 1388c2ecf20Sopenharmony_ci if (RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING) 1398c2ecf20Sopenharmony_ci break; 1408c2ecf20Sopenharmony_ci udelay(1); 1418c2ecf20Sopenharmony_ci } 1428c2ecf20Sopenharmony_ci DRM_DEBUG("Update pending now high. Unlocking vupdate_lock.\n"); 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci /* Unlock the lock, so double-buffering can take place inside vblank */ 1458c2ecf20Sopenharmony_ci tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK; 1468c2ecf20Sopenharmony_ci WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); 1478c2ecf20Sopenharmony_ci} 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cibool rs600_page_flip_pending(struct radeon_device *rdev, int crtc_id) 1508c2ecf20Sopenharmony_ci{ 1518c2ecf20Sopenharmony_ci struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci /* Return current update_pending status: */ 1548c2ecf20Sopenharmony_ci return !!(RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & 1558c2ecf20Sopenharmony_ci AVIVO_D1GRPH_SURFACE_UPDATE_PENDING); 1568c2ecf20Sopenharmony_ci} 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_civoid avivo_program_fmt(struct drm_encoder *encoder) 1598c2ecf20Sopenharmony_ci{ 1608c2ecf20Sopenharmony_ci struct drm_device *dev = encoder->dev; 1618c2ecf20Sopenharmony_ci struct radeon_device *rdev = dev->dev_private; 1628c2ecf20Sopenharmony_ci struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1638c2ecf20Sopenharmony_ci struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 1648c2ecf20Sopenharmony_ci int bpc = 0; 1658c2ecf20Sopenharmony_ci u32 tmp = 0; 1668c2ecf20Sopenharmony_ci enum radeon_connector_dither dither = RADEON_FMT_DITHER_DISABLE; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci if (connector) { 1698c2ecf20Sopenharmony_ci struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1708c2ecf20Sopenharmony_ci bpc = radeon_get_monitor_bpc(connector); 1718c2ecf20Sopenharmony_ci dither = radeon_connector->dither; 1728c2ecf20Sopenharmony_ci } 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci /* LVDS FMT is set up by atom */ 1758c2ecf20Sopenharmony_ci if (radeon_encoder->devices & ATOM_DEVICE_LCD_SUPPORT) 1768c2ecf20Sopenharmony_ci return; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci if (bpc == 0) 1798c2ecf20Sopenharmony_ci return; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci switch (bpc) { 1828c2ecf20Sopenharmony_ci case 6: 1838c2ecf20Sopenharmony_ci if (dither == RADEON_FMT_DITHER_ENABLE) 1848c2ecf20Sopenharmony_ci /* XXX sort out optimal dither settings */ 1858c2ecf20Sopenharmony_ci tmp |= AVIVO_TMDS_BIT_DEPTH_CONTROL_SPATIAL_DITHER_EN; 1868c2ecf20Sopenharmony_ci else 1878c2ecf20Sopenharmony_ci tmp |= AVIVO_TMDS_BIT_DEPTH_CONTROL_TRUNCATE_EN; 1888c2ecf20Sopenharmony_ci break; 1898c2ecf20Sopenharmony_ci case 8: 1908c2ecf20Sopenharmony_ci if (dither == RADEON_FMT_DITHER_ENABLE) 1918c2ecf20Sopenharmony_ci /* XXX sort out optimal dither settings */ 1928c2ecf20Sopenharmony_ci tmp |= (AVIVO_TMDS_BIT_DEPTH_CONTROL_SPATIAL_DITHER_EN | 1938c2ecf20Sopenharmony_ci AVIVO_TMDS_BIT_DEPTH_CONTROL_SPATIAL_DITHER_DEPTH); 1948c2ecf20Sopenharmony_ci else 1958c2ecf20Sopenharmony_ci tmp |= (AVIVO_TMDS_BIT_DEPTH_CONTROL_TRUNCATE_EN | 1968c2ecf20Sopenharmony_ci AVIVO_TMDS_BIT_DEPTH_CONTROL_TRUNCATE_DEPTH); 1978c2ecf20Sopenharmony_ci break; 1988c2ecf20Sopenharmony_ci case 10: 1998c2ecf20Sopenharmony_ci default: 2008c2ecf20Sopenharmony_ci /* not needed */ 2018c2ecf20Sopenharmony_ci break; 2028c2ecf20Sopenharmony_ci } 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci switch (radeon_encoder->encoder_id) { 2058c2ecf20Sopenharmony_ci case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: 2068c2ecf20Sopenharmony_ci WREG32(AVIVO_TMDSA_BIT_DEPTH_CONTROL, tmp); 2078c2ecf20Sopenharmony_ci break; 2088c2ecf20Sopenharmony_ci case ENCODER_OBJECT_ID_INTERNAL_LVTM1: 2098c2ecf20Sopenharmony_ci WREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL, tmp); 2108c2ecf20Sopenharmony_ci break; 2118c2ecf20Sopenharmony_ci case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: 2128c2ecf20Sopenharmony_ci WREG32(AVIVO_DVOA_BIT_DEPTH_CONTROL, tmp); 2138c2ecf20Sopenharmony_ci break; 2148c2ecf20Sopenharmony_ci case ENCODER_OBJECT_ID_INTERNAL_DDI: 2158c2ecf20Sopenharmony_ci WREG32(AVIVO_DDIA_BIT_DEPTH_CONTROL, tmp); 2168c2ecf20Sopenharmony_ci break; 2178c2ecf20Sopenharmony_ci default: 2188c2ecf20Sopenharmony_ci break; 2198c2ecf20Sopenharmony_ci } 2208c2ecf20Sopenharmony_ci} 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_civoid rs600_pm_misc(struct radeon_device *rdev) 2238c2ecf20Sopenharmony_ci{ 2248c2ecf20Sopenharmony_ci int requested_index = rdev->pm.requested_power_state_index; 2258c2ecf20Sopenharmony_ci struct radeon_power_state *ps = &rdev->pm.power_state[requested_index]; 2268c2ecf20Sopenharmony_ci struct radeon_voltage *voltage = &ps->clock_info[0].voltage; 2278c2ecf20Sopenharmony_ci u32 tmp, dyn_pwrmgt_sclk_length, dyn_sclk_vol_cntl; 2288c2ecf20Sopenharmony_ci u32 hdp_dyn_cntl, /*mc_host_dyn_cntl,*/ dyn_backbias_cntl; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci if ((voltage->type == VOLTAGE_GPIO) && (voltage->gpio.valid)) { 2318c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) { 2328c2ecf20Sopenharmony_ci tmp = RREG32(voltage->gpio.reg); 2338c2ecf20Sopenharmony_ci if (voltage->active_high) 2348c2ecf20Sopenharmony_ci tmp |= voltage->gpio.mask; 2358c2ecf20Sopenharmony_ci else 2368c2ecf20Sopenharmony_ci tmp &= ~(voltage->gpio.mask); 2378c2ecf20Sopenharmony_ci WREG32(voltage->gpio.reg, tmp); 2388c2ecf20Sopenharmony_ci if (voltage->delay) 2398c2ecf20Sopenharmony_ci udelay(voltage->delay); 2408c2ecf20Sopenharmony_ci } else { 2418c2ecf20Sopenharmony_ci tmp = RREG32(voltage->gpio.reg); 2428c2ecf20Sopenharmony_ci if (voltage->active_high) 2438c2ecf20Sopenharmony_ci tmp &= ~voltage->gpio.mask; 2448c2ecf20Sopenharmony_ci else 2458c2ecf20Sopenharmony_ci tmp |= voltage->gpio.mask; 2468c2ecf20Sopenharmony_ci WREG32(voltage->gpio.reg, tmp); 2478c2ecf20Sopenharmony_ci if (voltage->delay) 2488c2ecf20Sopenharmony_ci udelay(voltage->delay); 2498c2ecf20Sopenharmony_ci } 2508c2ecf20Sopenharmony_ci } else if (voltage->type == VOLTAGE_VDDC) 2518c2ecf20Sopenharmony_ci radeon_atom_set_voltage(rdev, voltage->vddc_id, SET_VOLTAGE_TYPE_ASIC_VDDC); 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length = RREG32_PLL(DYN_PWRMGT_SCLK_LENGTH); 2548c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length &= ~REDUCED_POWER_SCLK_HILEN(0xf); 2558c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length &= ~REDUCED_POWER_SCLK_LOLEN(0xf); 2568c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN) { 2578c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2) { 2588c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_HILEN(2); 2598c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_LOLEN(2); 2608c2ecf20Sopenharmony_ci } else if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4) { 2618c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_HILEN(4); 2628c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_LOLEN(4); 2638c2ecf20Sopenharmony_ci } 2648c2ecf20Sopenharmony_ci } else { 2658c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_HILEN(1); 2668c2ecf20Sopenharmony_ci dyn_pwrmgt_sclk_length |= REDUCED_POWER_SCLK_LOLEN(1); 2678c2ecf20Sopenharmony_ci } 2688c2ecf20Sopenharmony_ci WREG32_PLL(DYN_PWRMGT_SCLK_LENGTH, dyn_pwrmgt_sclk_length); 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci dyn_sclk_vol_cntl = RREG32_PLL(DYN_SCLK_VOL_CNTL); 2718c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN) { 2728c2ecf20Sopenharmony_ci dyn_sclk_vol_cntl |= IO_CG_VOLTAGE_DROP; 2738c2ecf20Sopenharmony_ci if (voltage->delay) { 2748c2ecf20Sopenharmony_ci dyn_sclk_vol_cntl |= VOLTAGE_DROP_SYNC; 2758c2ecf20Sopenharmony_ci dyn_sclk_vol_cntl |= VOLTAGE_DELAY_SEL(voltage->delay); 2768c2ecf20Sopenharmony_ci } else 2778c2ecf20Sopenharmony_ci dyn_sclk_vol_cntl &= ~VOLTAGE_DROP_SYNC; 2788c2ecf20Sopenharmony_ci } else 2798c2ecf20Sopenharmony_ci dyn_sclk_vol_cntl &= ~IO_CG_VOLTAGE_DROP; 2808c2ecf20Sopenharmony_ci WREG32_PLL(DYN_SCLK_VOL_CNTL, dyn_sclk_vol_cntl); 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci hdp_dyn_cntl = RREG32_PLL(HDP_DYN_CNTL); 2838c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN) 2848c2ecf20Sopenharmony_ci hdp_dyn_cntl &= ~HDP_FORCEON; 2858c2ecf20Sopenharmony_ci else 2868c2ecf20Sopenharmony_ci hdp_dyn_cntl |= HDP_FORCEON; 2878c2ecf20Sopenharmony_ci WREG32_PLL(HDP_DYN_CNTL, hdp_dyn_cntl); 2888c2ecf20Sopenharmony_ci#if 0 2898c2ecf20Sopenharmony_ci /* mc_host_dyn seems to cause hangs from time to time */ 2908c2ecf20Sopenharmony_ci mc_host_dyn_cntl = RREG32_PLL(MC_HOST_DYN_CNTL); 2918c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN) 2928c2ecf20Sopenharmony_ci mc_host_dyn_cntl &= ~MC_HOST_FORCEON; 2938c2ecf20Sopenharmony_ci else 2948c2ecf20Sopenharmony_ci mc_host_dyn_cntl |= MC_HOST_FORCEON; 2958c2ecf20Sopenharmony_ci WREG32_PLL(MC_HOST_DYN_CNTL, mc_host_dyn_cntl); 2968c2ecf20Sopenharmony_ci#endif 2978c2ecf20Sopenharmony_ci dyn_backbias_cntl = RREG32_PLL(DYN_BACKBIAS_CNTL); 2988c2ecf20Sopenharmony_ci if (ps->misc & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN) 2998c2ecf20Sopenharmony_ci dyn_backbias_cntl |= IO_CG_BACKBIAS_EN; 3008c2ecf20Sopenharmony_ci else 3018c2ecf20Sopenharmony_ci dyn_backbias_cntl &= ~IO_CG_BACKBIAS_EN; 3028c2ecf20Sopenharmony_ci WREG32_PLL(DYN_BACKBIAS_CNTL, dyn_backbias_cntl); 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci /* set pcie lanes */ 3058c2ecf20Sopenharmony_ci if ((rdev->flags & RADEON_IS_PCIE) && 3068c2ecf20Sopenharmony_ci !(rdev->flags & RADEON_IS_IGP) && 3078c2ecf20Sopenharmony_ci rdev->asic->pm.set_pcie_lanes && 3088c2ecf20Sopenharmony_ci (ps->pcie_lanes != 3098c2ecf20Sopenharmony_ci rdev->pm.power_state[rdev->pm.current_power_state_index].pcie_lanes)) { 3108c2ecf20Sopenharmony_ci radeon_set_pcie_lanes(rdev, 3118c2ecf20Sopenharmony_ci ps->pcie_lanes); 3128c2ecf20Sopenharmony_ci DRM_DEBUG("Setting: p: %d\n", ps->pcie_lanes); 3138c2ecf20Sopenharmony_ci } 3148c2ecf20Sopenharmony_ci} 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_civoid rs600_pm_prepare(struct radeon_device *rdev) 3178c2ecf20Sopenharmony_ci{ 3188c2ecf20Sopenharmony_ci struct drm_device *ddev = rdev->ddev; 3198c2ecf20Sopenharmony_ci struct drm_crtc *crtc; 3208c2ecf20Sopenharmony_ci struct radeon_crtc *radeon_crtc; 3218c2ecf20Sopenharmony_ci u32 tmp; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci /* disable any active CRTCs */ 3248c2ecf20Sopenharmony_ci list_for_each_entry(crtc, &ddev->mode_config.crtc_list, head) { 3258c2ecf20Sopenharmony_ci radeon_crtc = to_radeon_crtc(crtc); 3268c2ecf20Sopenharmony_ci if (radeon_crtc->enabled) { 3278c2ecf20Sopenharmony_ci tmp = RREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset); 3288c2ecf20Sopenharmony_ci tmp |= AVIVO_CRTC_DISP_READ_REQUEST_DISABLE; 3298c2ecf20Sopenharmony_ci WREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset, tmp); 3308c2ecf20Sopenharmony_ci } 3318c2ecf20Sopenharmony_ci } 3328c2ecf20Sopenharmony_ci} 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_civoid rs600_pm_finish(struct radeon_device *rdev) 3358c2ecf20Sopenharmony_ci{ 3368c2ecf20Sopenharmony_ci struct drm_device *ddev = rdev->ddev; 3378c2ecf20Sopenharmony_ci struct drm_crtc *crtc; 3388c2ecf20Sopenharmony_ci struct radeon_crtc *radeon_crtc; 3398c2ecf20Sopenharmony_ci u32 tmp; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci /* enable any active CRTCs */ 3428c2ecf20Sopenharmony_ci list_for_each_entry(crtc, &ddev->mode_config.crtc_list, head) { 3438c2ecf20Sopenharmony_ci radeon_crtc = to_radeon_crtc(crtc); 3448c2ecf20Sopenharmony_ci if (radeon_crtc->enabled) { 3458c2ecf20Sopenharmony_ci tmp = RREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset); 3468c2ecf20Sopenharmony_ci tmp &= ~AVIVO_CRTC_DISP_READ_REQUEST_DISABLE; 3478c2ecf20Sopenharmony_ci WREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset, tmp); 3488c2ecf20Sopenharmony_ci } 3498c2ecf20Sopenharmony_ci } 3508c2ecf20Sopenharmony_ci} 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_ci/* hpd for digital panel detect/disconnect */ 3538c2ecf20Sopenharmony_cibool rs600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) 3548c2ecf20Sopenharmony_ci{ 3558c2ecf20Sopenharmony_ci u32 tmp; 3568c2ecf20Sopenharmony_ci bool connected = false; 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci switch (hpd) { 3598c2ecf20Sopenharmony_ci case RADEON_HPD_1: 3608c2ecf20Sopenharmony_ci tmp = RREG32(R_007D04_DC_HOT_PLUG_DETECT1_INT_STATUS); 3618c2ecf20Sopenharmony_ci if (G_007D04_DC_HOT_PLUG_DETECT1_SENSE(tmp)) 3628c2ecf20Sopenharmony_ci connected = true; 3638c2ecf20Sopenharmony_ci break; 3648c2ecf20Sopenharmony_ci case RADEON_HPD_2: 3658c2ecf20Sopenharmony_ci tmp = RREG32(R_007D14_DC_HOT_PLUG_DETECT2_INT_STATUS); 3668c2ecf20Sopenharmony_ci if (G_007D14_DC_HOT_PLUG_DETECT2_SENSE(tmp)) 3678c2ecf20Sopenharmony_ci connected = true; 3688c2ecf20Sopenharmony_ci break; 3698c2ecf20Sopenharmony_ci default: 3708c2ecf20Sopenharmony_ci break; 3718c2ecf20Sopenharmony_ci } 3728c2ecf20Sopenharmony_ci return connected; 3738c2ecf20Sopenharmony_ci} 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_civoid rs600_hpd_set_polarity(struct radeon_device *rdev, 3768c2ecf20Sopenharmony_ci enum radeon_hpd_id hpd) 3778c2ecf20Sopenharmony_ci{ 3788c2ecf20Sopenharmony_ci u32 tmp; 3798c2ecf20Sopenharmony_ci bool connected = rs600_hpd_sense(rdev, hpd); 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci switch (hpd) { 3828c2ecf20Sopenharmony_ci case RADEON_HPD_1: 3838c2ecf20Sopenharmony_ci tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); 3848c2ecf20Sopenharmony_ci if (connected) 3858c2ecf20Sopenharmony_ci tmp &= ~S_007D08_DC_HOT_PLUG_DETECT1_INT_POLARITY(1); 3868c2ecf20Sopenharmony_ci else 3878c2ecf20Sopenharmony_ci tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_POLARITY(1); 3888c2ecf20Sopenharmony_ci WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); 3898c2ecf20Sopenharmony_ci break; 3908c2ecf20Sopenharmony_ci case RADEON_HPD_2: 3918c2ecf20Sopenharmony_ci tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); 3928c2ecf20Sopenharmony_ci if (connected) 3938c2ecf20Sopenharmony_ci tmp &= ~S_007D18_DC_HOT_PLUG_DETECT2_INT_POLARITY(1); 3948c2ecf20Sopenharmony_ci else 3958c2ecf20Sopenharmony_ci tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_POLARITY(1); 3968c2ecf20Sopenharmony_ci WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); 3978c2ecf20Sopenharmony_ci break; 3988c2ecf20Sopenharmony_ci default: 3998c2ecf20Sopenharmony_ci break; 4008c2ecf20Sopenharmony_ci } 4018c2ecf20Sopenharmony_ci} 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_civoid rs600_hpd_init(struct radeon_device *rdev) 4048c2ecf20Sopenharmony_ci{ 4058c2ecf20Sopenharmony_ci struct drm_device *dev = rdev->ddev; 4068c2ecf20Sopenharmony_ci struct drm_connector *connector; 4078c2ecf20Sopenharmony_ci unsigned enable = 0; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 4108c2ecf20Sopenharmony_ci struct radeon_connector *radeon_connector = to_radeon_connector(connector); 4118c2ecf20Sopenharmony_ci switch (radeon_connector->hpd.hpd) { 4128c2ecf20Sopenharmony_ci case RADEON_HPD_1: 4138c2ecf20Sopenharmony_ci WREG32(R_007D00_DC_HOT_PLUG_DETECT1_CONTROL, 4148c2ecf20Sopenharmony_ci S_007D00_DC_HOT_PLUG_DETECT1_EN(1)); 4158c2ecf20Sopenharmony_ci break; 4168c2ecf20Sopenharmony_ci case RADEON_HPD_2: 4178c2ecf20Sopenharmony_ci WREG32(R_007D10_DC_HOT_PLUG_DETECT2_CONTROL, 4188c2ecf20Sopenharmony_ci S_007D10_DC_HOT_PLUG_DETECT2_EN(1)); 4198c2ecf20Sopenharmony_ci break; 4208c2ecf20Sopenharmony_ci default: 4218c2ecf20Sopenharmony_ci break; 4228c2ecf20Sopenharmony_ci } 4238c2ecf20Sopenharmony_ci if (radeon_connector->hpd.hpd != RADEON_HPD_NONE) 4248c2ecf20Sopenharmony_ci enable |= 1 << radeon_connector->hpd.hpd; 4258c2ecf20Sopenharmony_ci radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); 4268c2ecf20Sopenharmony_ci } 4278c2ecf20Sopenharmony_ci radeon_irq_kms_enable_hpd(rdev, enable); 4288c2ecf20Sopenharmony_ci} 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_civoid rs600_hpd_fini(struct radeon_device *rdev) 4318c2ecf20Sopenharmony_ci{ 4328c2ecf20Sopenharmony_ci struct drm_device *dev = rdev->ddev; 4338c2ecf20Sopenharmony_ci struct drm_connector *connector; 4348c2ecf20Sopenharmony_ci unsigned disable = 0; 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 4378c2ecf20Sopenharmony_ci struct radeon_connector *radeon_connector = to_radeon_connector(connector); 4388c2ecf20Sopenharmony_ci switch (radeon_connector->hpd.hpd) { 4398c2ecf20Sopenharmony_ci case RADEON_HPD_1: 4408c2ecf20Sopenharmony_ci WREG32(R_007D00_DC_HOT_PLUG_DETECT1_CONTROL, 4418c2ecf20Sopenharmony_ci S_007D00_DC_HOT_PLUG_DETECT1_EN(0)); 4428c2ecf20Sopenharmony_ci break; 4438c2ecf20Sopenharmony_ci case RADEON_HPD_2: 4448c2ecf20Sopenharmony_ci WREG32(R_007D10_DC_HOT_PLUG_DETECT2_CONTROL, 4458c2ecf20Sopenharmony_ci S_007D10_DC_HOT_PLUG_DETECT2_EN(0)); 4468c2ecf20Sopenharmony_ci break; 4478c2ecf20Sopenharmony_ci default: 4488c2ecf20Sopenharmony_ci break; 4498c2ecf20Sopenharmony_ci } 4508c2ecf20Sopenharmony_ci if (radeon_connector->hpd.hpd != RADEON_HPD_NONE) 4518c2ecf20Sopenharmony_ci disable |= 1 << radeon_connector->hpd.hpd; 4528c2ecf20Sopenharmony_ci } 4538c2ecf20Sopenharmony_ci radeon_irq_kms_disable_hpd(rdev, disable); 4548c2ecf20Sopenharmony_ci} 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ciint rs600_asic_reset(struct radeon_device *rdev, bool hard) 4578c2ecf20Sopenharmony_ci{ 4588c2ecf20Sopenharmony_ci struct rv515_mc_save save; 4598c2ecf20Sopenharmony_ci u32 status, tmp; 4608c2ecf20Sopenharmony_ci int ret = 0; 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci status = RREG32(R_000E40_RBBM_STATUS); 4638c2ecf20Sopenharmony_ci if (!G_000E40_GUI_ACTIVE(status)) { 4648c2ecf20Sopenharmony_ci return 0; 4658c2ecf20Sopenharmony_ci } 4668c2ecf20Sopenharmony_ci /* Stops all mc clients */ 4678c2ecf20Sopenharmony_ci rv515_mc_stop(rdev, &save); 4688c2ecf20Sopenharmony_ci status = RREG32(R_000E40_RBBM_STATUS); 4698c2ecf20Sopenharmony_ci dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); 4708c2ecf20Sopenharmony_ci /* stop CP */ 4718c2ecf20Sopenharmony_ci WREG32(RADEON_CP_CSQ_CNTL, 0); 4728c2ecf20Sopenharmony_ci tmp = RREG32(RADEON_CP_RB_CNTL); 4738c2ecf20Sopenharmony_ci WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA); 4748c2ecf20Sopenharmony_ci WREG32(RADEON_CP_RB_RPTR_WR, 0); 4758c2ecf20Sopenharmony_ci WREG32(RADEON_CP_RB_WPTR, 0); 4768c2ecf20Sopenharmony_ci WREG32(RADEON_CP_RB_CNTL, tmp); 4778c2ecf20Sopenharmony_ci pci_save_state(rdev->pdev); 4788c2ecf20Sopenharmony_ci /* disable bus mastering */ 4798c2ecf20Sopenharmony_ci pci_clear_master(rdev->pdev); 4808c2ecf20Sopenharmony_ci mdelay(1); 4818c2ecf20Sopenharmony_ci /* reset GA+VAP */ 4828c2ecf20Sopenharmony_ci WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) | 4838c2ecf20Sopenharmony_ci S_0000F0_SOFT_RESET_GA(1)); 4848c2ecf20Sopenharmony_ci RREG32(R_0000F0_RBBM_SOFT_RESET); 4858c2ecf20Sopenharmony_ci mdelay(500); 4868c2ecf20Sopenharmony_ci WREG32(R_0000F0_RBBM_SOFT_RESET, 0); 4878c2ecf20Sopenharmony_ci mdelay(1); 4888c2ecf20Sopenharmony_ci status = RREG32(R_000E40_RBBM_STATUS); 4898c2ecf20Sopenharmony_ci dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); 4908c2ecf20Sopenharmony_ci /* reset CP */ 4918c2ecf20Sopenharmony_ci WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_CP(1)); 4928c2ecf20Sopenharmony_ci RREG32(R_0000F0_RBBM_SOFT_RESET); 4938c2ecf20Sopenharmony_ci mdelay(500); 4948c2ecf20Sopenharmony_ci WREG32(R_0000F0_RBBM_SOFT_RESET, 0); 4958c2ecf20Sopenharmony_ci mdelay(1); 4968c2ecf20Sopenharmony_ci status = RREG32(R_000E40_RBBM_STATUS); 4978c2ecf20Sopenharmony_ci dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); 4988c2ecf20Sopenharmony_ci /* reset MC */ 4998c2ecf20Sopenharmony_ci WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_MC(1)); 5008c2ecf20Sopenharmony_ci RREG32(R_0000F0_RBBM_SOFT_RESET); 5018c2ecf20Sopenharmony_ci mdelay(500); 5028c2ecf20Sopenharmony_ci WREG32(R_0000F0_RBBM_SOFT_RESET, 0); 5038c2ecf20Sopenharmony_ci mdelay(1); 5048c2ecf20Sopenharmony_ci status = RREG32(R_000E40_RBBM_STATUS); 5058c2ecf20Sopenharmony_ci dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); 5068c2ecf20Sopenharmony_ci /* restore PCI & busmastering */ 5078c2ecf20Sopenharmony_ci pci_restore_state(rdev->pdev); 5088c2ecf20Sopenharmony_ci /* Check if GPU is idle */ 5098c2ecf20Sopenharmony_ci if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) { 5108c2ecf20Sopenharmony_ci dev_err(rdev->dev, "failed to reset GPU\n"); 5118c2ecf20Sopenharmony_ci ret = -1; 5128c2ecf20Sopenharmony_ci } else 5138c2ecf20Sopenharmony_ci dev_info(rdev->dev, "GPU reset succeed\n"); 5148c2ecf20Sopenharmony_ci rv515_mc_resume(rdev, &save); 5158c2ecf20Sopenharmony_ci return ret; 5168c2ecf20Sopenharmony_ci} 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci/* 5198c2ecf20Sopenharmony_ci * GART. 5208c2ecf20Sopenharmony_ci */ 5218c2ecf20Sopenharmony_civoid rs600_gart_tlb_flush(struct radeon_device *rdev) 5228c2ecf20Sopenharmony_ci{ 5238c2ecf20Sopenharmony_ci uint32_t tmp; 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 5268c2ecf20Sopenharmony_ci tmp &= C_000100_INVALIDATE_ALL_L1_TLBS & C_000100_INVALIDATE_L2_CACHE; 5278c2ecf20Sopenharmony_ci WREG32_MC(R_000100_MC_PT0_CNTL, tmp); 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 5308c2ecf20Sopenharmony_ci tmp |= S_000100_INVALIDATE_ALL_L1_TLBS(1) | S_000100_INVALIDATE_L2_CACHE(1); 5318c2ecf20Sopenharmony_ci WREG32_MC(R_000100_MC_PT0_CNTL, tmp); 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 5348c2ecf20Sopenharmony_ci tmp &= C_000100_INVALIDATE_ALL_L1_TLBS & C_000100_INVALIDATE_L2_CACHE; 5358c2ecf20Sopenharmony_ci WREG32_MC(R_000100_MC_PT0_CNTL, tmp); 5368c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 5378c2ecf20Sopenharmony_ci} 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_cistatic int rs600_gart_init(struct radeon_device *rdev) 5408c2ecf20Sopenharmony_ci{ 5418c2ecf20Sopenharmony_ci int r; 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci if (rdev->gart.robj) { 5448c2ecf20Sopenharmony_ci WARN(1, "RS600 GART already initialized\n"); 5458c2ecf20Sopenharmony_ci return 0; 5468c2ecf20Sopenharmony_ci } 5478c2ecf20Sopenharmony_ci /* Initialize common gart structure */ 5488c2ecf20Sopenharmony_ci r = radeon_gart_init(rdev); 5498c2ecf20Sopenharmony_ci if (r) { 5508c2ecf20Sopenharmony_ci return r; 5518c2ecf20Sopenharmony_ci } 5528c2ecf20Sopenharmony_ci rdev->gart.table_size = rdev->gart.num_gpu_pages * 8; 5538c2ecf20Sopenharmony_ci return radeon_gart_table_vram_alloc(rdev); 5548c2ecf20Sopenharmony_ci} 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_cistatic int rs600_gart_enable(struct radeon_device *rdev) 5578c2ecf20Sopenharmony_ci{ 5588c2ecf20Sopenharmony_ci u32 tmp; 5598c2ecf20Sopenharmony_ci int r, i; 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci if (rdev->gart.robj == NULL) { 5628c2ecf20Sopenharmony_ci dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); 5638c2ecf20Sopenharmony_ci return -EINVAL; 5648c2ecf20Sopenharmony_ci } 5658c2ecf20Sopenharmony_ci r = radeon_gart_table_vram_pin(rdev); 5668c2ecf20Sopenharmony_ci if (r) 5678c2ecf20Sopenharmony_ci return r; 5688c2ecf20Sopenharmony_ci /* Enable bus master */ 5698c2ecf20Sopenharmony_ci tmp = RREG32(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS; 5708c2ecf20Sopenharmony_ci WREG32(RADEON_BUS_CNTL, tmp); 5718c2ecf20Sopenharmony_ci /* FIXME: setup default page */ 5728c2ecf20Sopenharmony_ci WREG32_MC(R_000100_MC_PT0_CNTL, 5738c2ecf20Sopenharmony_ci (S_000100_EFFECTIVE_L2_CACHE_SIZE(6) | 5748c2ecf20Sopenharmony_ci S_000100_EFFECTIVE_L2_QUEUE_SIZE(6))); 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci for (i = 0; i < 19; i++) { 5778c2ecf20Sopenharmony_ci WREG32_MC(R_00016C_MC_PT0_CLIENT0_CNTL + i, 5788c2ecf20Sopenharmony_ci S_00016C_ENABLE_TRANSLATION_MODE_OVERRIDE(1) | 5798c2ecf20Sopenharmony_ci S_00016C_SYSTEM_ACCESS_MODE_MASK( 5808c2ecf20Sopenharmony_ci V_00016C_SYSTEM_ACCESS_MODE_NOT_IN_SYS) | 5818c2ecf20Sopenharmony_ci S_00016C_SYSTEM_APERTURE_UNMAPPED_ACCESS( 5828c2ecf20Sopenharmony_ci V_00016C_SYSTEM_APERTURE_UNMAPPED_PASSTHROUGH) | 5838c2ecf20Sopenharmony_ci S_00016C_EFFECTIVE_L1_CACHE_SIZE(3) | 5848c2ecf20Sopenharmony_ci S_00016C_ENABLE_FRAGMENT_PROCESSING(1) | 5858c2ecf20Sopenharmony_ci S_00016C_EFFECTIVE_L1_QUEUE_SIZE(3)); 5868c2ecf20Sopenharmony_ci } 5878c2ecf20Sopenharmony_ci /* enable first context */ 5888c2ecf20Sopenharmony_ci WREG32_MC(R_000102_MC_PT0_CONTEXT0_CNTL, 5898c2ecf20Sopenharmony_ci S_000102_ENABLE_PAGE_TABLE(1) | 5908c2ecf20Sopenharmony_ci S_000102_PAGE_TABLE_DEPTH(V_000102_PAGE_TABLE_FLAT)); 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci /* disable all other contexts */ 5938c2ecf20Sopenharmony_ci for (i = 1; i < 8; i++) 5948c2ecf20Sopenharmony_ci WREG32_MC(R_000102_MC_PT0_CONTEXT0_CNTL + i, 0); 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci /* setup the page table */ 5978c2ecf20Sopenharmony_ci WREG32_MC(R_00012C_MC_PT0_CONTEXT0_FLAT_BASE_ADDR, 5988c2ecf20Sopenharmony_ci rdev->gart.table_addr); 5998c2ecf20Sopenharmony_ci WREG32_MC(R_00013C_MC_PT0_CONTEXT0_FLAT_START_ADDR, rdev->mc.gtt_start); 6008c2ecf20Sopenharmony_ci WREG32_MC(R_00014C_MC_PT0_CONTEXT0_FLAT_END_ADDR, rdev->mc.gtt_end); 6018c2ecf20Sopenharmony_ci WREG32_MC(R_00011C_MC_PT0_CONTEXT0_DEFAULT_READ_ADDR, 0); 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci /* System context maps to VRAM space */ 6048c2ecf20Sopenharmony_ci WREG32_MC(R_000112_MC_PT0_SYSTEM_APERTURE_LOW_ADDR, rdev->mc.vram_start); 6058c2ecf20Sopenharmony_ci WREG32_MC(R_000114_MC_PT0_SYSTEM_APERTURE_HIGH_ADDR, rdev->mc.vram_end); 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci /* enable page tables */ 6088c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 6098c2ecf20Sopenharmony_ci WREG32_MC(R_000100_MC_PT0_CNTL, (tmp | S_000100_ENABLE_PT(1))); 6108c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000009_MC_CNTL1); 6118c2ecf20Sopenharmony_ci WREG32_MC(R_000009_MC_CNTL1, (tmp | S_000009_ENABLE_PAGE_TABLES(1))); 6128c2ecf20Sopenharmony_ci rs600_gart_tlb_flush(rdev); 6138c2ecf20Sopenharmony_ci DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", 6148c2ecf20Sopenharmony_ci (unsigned)(rdev->mc.gtt_size >> 20), 6158c2ecf20Sopenharmony_ci (unsigned long long)rdev->gart.table_addr); 6168c2ecf20Sopenharmony_ci rdev->gart.ready = true; 6178c2ecf20Sopenharmony_ci return 0; 6188c2ecf20Sopenharmony_ci} 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_cistatic void rs600_gart_disable(struct radeon_device *rdev) 6218c2ecf20Sopenharmony_ci{ 6228c2ecf20Sopenharmony_ci u32 tmp; 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci /* FIXME: disable out of gart access */ 6258c2ecf20Sopenharmony_ci WREG32_MC(R_000100_MC_PT0_CNTL, 0); 6268c2ecf20Sopenharmony_ci tmp = RREG32_MC(R_000009_MC_CNTL1); 6278c2ecf20Sopenharmony_ci WREG32_MC(R_000009_MC_CNTL1, tmp & C_000009_ENABLE_PAGE_TABLES); 6288c2ecf20Sopenharmony_ci radeon_gart_table_vram_unpin(rdev); 6298c2ecf20Sopenharmony_ci} 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_cistatic void rs600_gart_fini(struct radeon_device *rdev) 6328c2ecf20Sopenharmony_ci{ 6338c2ecf20Sopenharmony_ci radeon_gart_fini(rdev); 6348c2ecf20Sopenharmony_ci rs600_gart_disable(rdev); 6358c2ecf20Sopenharmony_ci radeon_gart_table_vram_free(rdev); 6368c2ecf20Sopenharmony_ci} 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ciuint64_t rs600_gart_get_page_entry(uint64_t addr, uint32_t flags) 6398c2ecf20Sopenharmony_ci{ 6408c2ecf20Sopenharmony_ci addr = addr & 0xFFFFFFFFFFFFF000ULL; 6418c2ecf20Sopenharmony_ci addr |= R600_PTE_SYSTEM; 6428c2ecf20Sopenharmony_ci if (flags & RADEON_GART_PAGE_VALID) 6438c2ecf20Sopenharmony_ci addr |= R600_PTE_VALID; 6448c2ecf20Sopenharmony_ci if (flags & RADEON_GART_PAGE_READ) 6458c2ecf20Sopenharmony_ci addr |= R600_PTE_READABLE; 6468c2ecf20Sopenharmony_ci if (flags & RADEON_GART_PAGE_WRITE) 6478c2ecf20Sopenharmony_ci addr |= R600_PTE_WRITEABLE; 6488c2ecf20Sopenharmony_ci if (flags & RADEON_GART_PAGE_SNOOP) 6498c2ecf20Sopenharmony_ci addr |= R600_PTE_SNOOPED; 6508c2ecf20Sopenharmony_ci return addr; 6518c2ecf20Sopenharmony_ci} 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_civoid rs600_gart_set_page(struct radeon_device *rdev, unsigned i, 6548c2ecf20Sopenharmony_ci uint64_t entry) 6558c2ecf20Sopenharmony_ci{ 6568c2ecf20Sopenharmony_ci void __iomem *ptr = (void *)rdev->gart.ptr; 6578c2ecf20Sopenharmony_ci writeq(entry, ptr + (i * 8)); 6588c2ecf20Sopenharmony_ci} 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ciint rs600_irq_set(struct radeon_device *rdev) 6618c2ecf20Sopenharmony_ci{ 6628c2ecf20Sopenharmony_ci uint32_t tmp = 0; 6638c2ecf20Sopenharmony_ci uint32_t mode_int = 0; 6648c2ecf20Sopenharmony_ci u32 hpd1 = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL) & 6658c2ecf20Sopenharmony_ci ~S_007D08_DC_HOT_PLUG_DETECT1_INT_EN(1); 6668c2ecf20Sopenharmony_ci u32 hpd2 = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL) & 6678c2ecf20Sopenharmony_ci ~S_007D18_DC_HOT_PLUG_DETECT2_INT_EN(1); 6688c2ecf20Sopenharmony_ci u32 hdmi0; 6698c2ecf20Sopenharmony_ci if (ASIC_IS_DCE2(rdev)) 6708c2ecf20Sopenharmony_ci hdmi0 = RREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL) & 6718c2ecf20Sopenharmony_ci ~S_007408_HDMI0_AZ_FORMAT_WTRIG_MASK(1); 6728c2ecf20Sopenharmony_ci else 6738c2ecf20Sopenharmony_ci hdmi0 = 0; 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci if (!rdev->irq.installed) { 6768c2ecf20Sopenharmony_ci WARN(1, "Can't enable IRQ/MSI because no handler is installed\n"); 6778c2ecf20Sopenharmony_ci WREG32(R_000040_GEN_INT_CNTL, 0); 6788c2ecf20Sopenharmony_ci return -EINVAL; 6798c2ecf20Sopenharmony_ci } 6808c2ecf20Sopenharmony_ci if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { 6818c2ecf20Sopenharmony_ci tmp |= S_000040_SW_INT_EN(1); 6828c2ecf20Sopenharmony_ci } 6838c2ecf20Sopenharmony_ci if (rdev->irq.crtc_vblank_int[0] || 6848c2ecf20Sopenharmony_ci atomic_read(&rdev->irq.pflip[0])) { 6858c2ecf20Sopenharmony_ci mode_int |= S_006540_D1MODE_VBLANK_INT_MASK(1); 6868c2ecf20Sopenharmony_ci } 6878c2ecf20Sopenharmony_ci if (rdev->irq.crtc_vblank_int[1] || 6888c2ecf20Sopenharmony_ci atomic_read(&rdev->irq.pflip[1])) { 6898c2ecf20Sopenharmony_ci mode_int |= S_006540_D2MODE_VBLANK_INT_MASK(1); 6908c2ecf20Sopenharmony_ci } 6918c2ecf20Sopenharmony_ci if (rdev->irq.hpd[0]) { 6928c2ecf20Sopenharmony_ci hpd1 |= S_007D08_DC_HOT_PLUG_DETECT1_INT_EN(1); 6938c2ecf20Sopenharmony_ci } 6948c2ecf20Sopenharmony_ci if (rdev->irq.hpd[1]) { 6958c2ecf20Sopenharmony_ci hpd2 |= S_007D18_DC_HOT_PLUG_DETECT2_INT_EN(1); 6968c2ecf20Sopenharmony_ci } 6978c2ecf20Sopenharmony_ci if (rdev->irq.afmt[0]) { 6988c2ecf20Sopenharmony_ci hdmi0 |= S_007408_HDMI0_AZ_FORMAT_WTRIG_MASK(1); 6998c2ecf20Sopenharmony_ci } 7008c2ecf20Sopenharmony_ci WREG32(R_000040_GEN_INT_CNTL, tmp); 7018c2ecf20Sopenharmony_ci WREG32(R_006540_DxMODE_INT_MASK, mode_int); 7028c2ecf20Sopenharmony_ci WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, hpd1); 7038c2ecf20Sopenharmony_ci WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, hpd2); 7048c2ecf20Sopenharmony_ci if (ASIC_IS_DCE2(rdev)) 7058c2ecf20Sopenharmony_ci WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, hdmi0); 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci /* posting read */ 7088c2ecf20Sopenharmony_ci RREG32(R_000040_GEN_INT_CNTL); 7098c2ecf20Sopenharmony_ci 7108c2ecf20Sopenharmony_ci return 0; 7118c2ecf20Sopenharmony_ci} 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_cistatic inline u32 rs600_irq_ack(struct radeon_device *rdev) 7148c2ecf20Sopenharmony_ci{ 7158c2ecf20Sopenharmony_ci uint32_t irqs = RREG32(R_000044_GEN_INT_STATUS); 7168c2ecf20Sopenharmony_ci uint32_t irq_mask = S_000044_SW_INT(1); 7178c2ecf20Sopenharmony_ci u32 tmp; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci if (G_000044_DISPLAY_INT_STAT(irqs)) { 7208c2ecf20Sopenharmony_ci rdev->irq.stat_regs.r500.disp_int = RREG32(R_007EDC_DISP_INTERRUPT_STATUS); 7218c2ecf20Sopenharmony_ci if (G_007EDC_LB_D1_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 7228c2ecf20Sopenharmony_ci WREG32(R_006534_D1MODE_VBLANK_STATUS, 7238c2ecf20Sopenharmony_ci S_006534_D1MODE_VBLANK_ACK(1)); 7248c2ecf20Sopenharmony_ci } 7258c2ecf20Sopenharmony_ci if (G_007EDC_LB_D2_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 7268c2ecf20Sopenharmony_ci WREG32(R_006D34_D2MODE_VBLANK_STATUS, 7278c2ecf20Sopenharmony_ci S_006D34_D2MODE_VBLANK_ACK(1)); 7288c2ecf20Sopenharmony_ci } 7298c2ecf20Sopenharmony_ci if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 7308c2ecf20Sopenharmony_ci tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); 7318c2ecf20Sopenharmony_ci tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_ACK(1); 7328c2ecf20Sopenharmony_ci WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); 7338c2ecf20Sopenharmony_ci } 7348c2ecf20Sopenharmony_ci if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 7358c2ecf20Sopenharmony_ci tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); 7368c2ecf20Sopenharmony_ci tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_ACK(1); 7378c2ecf20Sopenharmony_ci WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); 7388c2ecf20Sopenharmony_ci } 7398c2ecf20Sopenharmony_ci } else { 7408c2ecf20Sopenharmony_ci rdev->irq.stat_regs.r500.disp_int = 0; 7418c2ecf20Sopenharmony_ci } 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci if (ASIC_IS_DCE2(rdev)) { 7448c2ecf20Sopenharmony_ci rdev->irq.stat_regs.r500.hdmi0_status = RREG32(R_007404_HDMI0_STATUS) & 7458c2ecf20Sopenharmony_ci S_007404_HDMI0_AZ_FORMAT_WTRIG(1); 7468c2ecf20Sopenharmony_ci if (G_007404_HDMI0_AZ_FORMAT_WTRIG(rdev->irq.stat_regs.r500.hdmi0_status)) { 7478c2ecf20Sopenharmony_ci tmp = RREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL); 7488c2ecf20Sopenharmony_ci tmp |= S_007408_HDMI0_AZ_FORMAT_WTRIG_ACK(1); 7498c2ecf20Sopenharmony_ci WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, tmp); 7508c2ecf20Sopenharmony_ci } 7518c2ecf20Sopenharmony_ci } else 7528c2ecf20Sopenharmony_ci rdev->irq.stat_regs.r500.hdmi0_status = 0; 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci if (irqs) { 7558c2ecf20Sopenharmony_ci WREG32(R_000044_GEN_INT_STATUS, irqs); 7568c2ecf20Sopenharmony_ci } 7578c2ecf20Sopenharmony_ci return irqs & irq_mask; 7588c2ecf20Sopenharmony_ci} 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_civoid rs600_irq_disable(struct radeon_device *rdev) 7618c2ecf20Sopenharmony_ci{ 7628c2ecf20Sopenharmony_ci u32 hdmi0 = RREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL) & 7638c2ecf20Sopenharmony_ci ~S_007408_HDMI0_AZ_FORMAT_WTRIG_MASK(1); 7648c2ecf20Sopenharmony_ci WREG32(R_007408_HDMI0_AUDIO_PACKET_CONTROL, hdmi0); 7658c2ecf20Sopenharmony_ci WREG32(R_000040_GEN_INT_CNTL, 0); 7668c2ecf20Sopenharmony_ci WREG32(R_006540_DxMODE_INT_MASK, 0); 7678c2ecf20Sopenharmony_ci /* Wait and acknowledge irq */ 7688c2ecf20Sopenharmony_ci mdelay(1); 7698c2ecf20Sopenharmony_ci rs600_irq_ack(rdev); 7708c2ecf20Sopenharmony_ci} 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ciint rs600_irq_process(struct radeon_device *rdev) 7738c2ecf20Sopenharmony_ci{ 7748c2ecf20Sopenharmony_ci u32 status, msi_rearm; 7758c2ecf20Sopenharmony_ci bool queue_hotplug = false; 7768c2ecf20Sopenharmony_ci bool queue_hdmi = false; 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci status = rs600_irq_ack(rdev); 7798c2ecf20Sopenharmony_ci if (!status && 7808c2ecf20Sopenharmony_ci !rdev->irq.stat_regs.r500.disp_int && 7818c2ecf20Sopenharmony_ci !rdev->irq.stat_regs.r500.hdmi0_status) { 7828c2ecf20Sopenharmony_ci return IRQ_NONE; 7838c2ecf20Sopenharmony_ci } 7848c2ecf20Sopenharmony_ci while (status || 7858c2ecf20Sopenharmony_ci rdev->irq.stat_regs.r500.disp_int || 7868c2ecf20Sopenharmony_ci rdev->irq.stat_regs.r500.hdmi0_status) { 7878c2ecf20Sopenharmony_ci /* SW interrupt */ 7888c2ecf20Sopenharmony_ci if (G_000044_SW_INT(status)) { 7898c2ecf20Sopenharmony_ci radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); 7908c2ecf20Sopenharmony_ci } 7918c2ecf20Sopenharmony_ci /* Vertical blank interrupts */ 7928c2ecf20Sopenharmony_ci if (G_007EDC_LB_D1_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 7938c2ecf20Sopenharmony_ci if (rdev->irq.crtc_vblank_int[0]) { 7948c2ecf20Sopenharmony_ci drm_handle_vblank(rdev->ddev, 0); 7958c2ecf20Sopenharmony_ci rdev->pm.vblank_sync = true; 7968c2ecf20Sopenharmony_ci wake_up(&rdev->irq.vblank_queue); 7978c2ecf20Sopenharmony_ci } 7988c2ecf20Sopenharmony_ci if (atomic_read(&rdev->irq.pflip[0])) 7998c2ecf20Sopenharmony_ci radeon_crtc_handle_vblank(rdev, 0); 8008c2ecf20Sopenharmony_ci } 8018c2ecf20Sopenharmony_ci if (G_007EDC_LB_D2_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 8028c2ecf20Sopenharmony_ci if (rdev->irq.crtc_vblank_int[1]) { 8038c2ecf20Sopenharmony_ci drm_handle_vblank(rdev->ddev, 1); 8048c2ecf20Sopenharmony_ci rdev->pm.vblank_sync = true; 8058c2ecf20Sopenharmony_ci wake_up(&rdev->irq.vblank_queue); 8068c2ecf20Sopenharmony_ci } 8078c2ecf20Sopenharmony_ci if (atomic_read(&rdev->irq.pflip[1])) 8088c2ecf20Sopenharmony_ci radeon_crtc_handle_vblank(rdev, 1); 8098c2ecf20Sopenharmony_ci } 8108c2ecf20Sopenharmony_ci if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 8118c2ecf20Sopenharmony_ci queue_hotplug = true; 8128c2ecf20Sopenharmony_ci DRM_DEBUG("HPD1\n"); 8138c2ecf20Sopenharmony_ci } 8148c2ecf20Sopenharmony_ci if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { 8158c2ecf20Sopenharmony_ci queue_hotplug = true; 8168c2ecf20Sopenharmony_ci DRM_DEBUG("HPD2\n"); 8178c2ecf20Sopenharmony_ci } 8188c2ecf20Sopenharmony_ci if (G_007404_HDMI0_AZ_FORMAT_WTRIG(rdev->irq.stat_regs.r500.hdmi0_status)) { 8198c2ecf20Sopenharmony_ci queue_hdmi = true; 8208c2ecf20Sopenharmony_ci DRM_DEBUG("HDMI0\n"); 8218c2ecf20Sopenharmony_ci } 8228c2ecf20Sopenharmony_ci status = rs600_irq_ack(rdev); 8238c2ecf20Sopenharmony_ci } 8248c2ecf20Sopenharmony_ci if (queue_hotplug) 8258c2ecf20Sopenharmony_ci schedule_delayed_work(&rdev->hotplug_work, 0); 8268c2ecf20Sopenharmony_ci if (queue_hdmi) 8278c2ecf20Sopenharmony_ci schedule_work(&rdev->audio_work); 8288c2ecf20Sopenharmony_ci if (rdev->msi_enabled) { 8298c2ecf20Sopenharmony_ci switch (rdev->family) { 8308c2ecf20Sopenharmony_ci case CHIP_RS600: 8318c2ecf20Sopenharmony_ci case CHIP_RS690: 8328c2ecf20Sopenharmony_ci case CHIP_RS740: 8338c2ecf20Sopenharmony_ci msi_rearm = RREG32(RADEON_BUS_CNTL) & ~RS600_MSI_REARM; 8348c2ecf20Sopenharmony_ci WREG32(RADEON_BUS_CNTL, msi_rearm); 8358c2ecf20Sopenharmony_ci WREG32(RADEON_BUS_CNTL, msi_rearm | RS600_MSI_REARM); 8368c2ecf20Sopenharmony_ci break; 8378c2ecf20Sopenharmony_ci default: 8388c2ecf20Sopenharmony_ci WREG32(RADEON_MSI_REARM_EN, RV370_MSI_REARM_EN); 8398c2ecf20Sopenharmony_ci break; 8408c2ecf20Sopenharmony_ci } 8418c2ecf20Sopenharmony_ci } 8428c2ecf20Sopenharmony_ci return IRQ_HANDLED; 8438c2ecf20Sopenharmony_ci} 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ciu32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc) 8468c2ecf20Sopenharmony_ci{ 8478c2ecf20Sopenharmony_ci if (crtc == 0) 8488c2ecf20Sopenharmony_ci return RREG32(R_0060A4_D1CRTC_STATUS_FRAME_COUNT); 8498c2ecf20Sopenharmony_ci else 8508c2ecf20Sopenharmony_ci return RREG32(R_0068A4_D2CRTC_STATUS_FRAME_COUNT); 8518c2ecf20Sopenharmony_ci} 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_ciint rs600_mc_wait_for_idle(struct radeon_device *rdev) 8548c2ecf20Sopenharmony_ci{ 8558c2ecf20Sopenharmony_ci unsigned i; 8568c2ecf20Sopenharmony_ci 8578c2ecf20Sopenharmony_ci for (i = 0; i < rdev->usec_timeout; i++) { 8588c2ecf20Sopenharmony_ci if (G_000000_MC_IDLE(RREG32_MC(R_000000_MC_STATUS))) 8598c2ecf20Sopenharmony_ci return 0; 8608c2ecf20Sopenharmony_ci udelay(1); 8618c2ecf20Sopenharmony_ci } 8628c2ecf20Sopenharmony_ci return -1; 8638c2ecf20Sopenharmony_ci} 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_cistatic void rs600_gpu_init(struct radeon_device *rdev) 8668c2ecf20Sopenharmony_ci{ 8678c2ecf20Sopenharmony_ci r420_pipes_init(rdev); 8688c2ecf20Sopenharmony_ci /* Wait for mc idle */ 8698c2ecf20Sopenharmony_ci if (rs600_mc_wait_for_idle(rdev)) 8708c2ecf20Sopenharmony_ci dev_warn(rdev->dev, "Wait MC idle timeout before updating MC.\n"); 8718c2ecf20Sopenharmony_ci} 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_cistatic void rs600_mc_init(struct radeon_device *rdev) 8748c2ecf20Sopenharmony_ci{ 8758c2ecf20Sopenharmony_ci u64 base; 8768c2ecf20Sopenharmony_ci 8778c2ecf20Sopenharmony_ci rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); 8788c2ecf20Sopenharmony_ci rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); 8798c2ecf20Sopenharmony_ci rdev->mc.vram_is_ddr = true; 8808c2ecf20Sopenharmony_ci rdev->mc.vram_width = 128; 8818c2ecf20Sopenharmony_ci rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); 8828c2ecf20Sopenharmony_ci rdev->mc.mc_vram_size = rdev->mc.real_vram_size; 8838c2ecf20Sopenharmony_ci rdev->mc.visible_vram_size = rdev->mc.aper_size; 8848c2ecf20Sopenharmony_ci rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 8858c2ecf20Sopenharmony_ci base = RREG32_MC(R_000004_MC_FB_LOCATION); 8868c2ecf20Sopenharmony_ci base = G_000004_MC_FB_START(base) << 16; 8878c2ecf20Sopenharmony_ci radeon_vram_location(rdev, &rdev->mc, base); 8888c2ecf20Sopenharmony_ci rdev->mc.gtt_base_align = 0; 8898c2ecf20Sopenharmony_ci radeon_gtt_location(rdev, &rdev->mc); 8908c2ecf20Sopenharmony_ci radeon_update_bandwidth_info(rdev); 8918c2ecf20Sopenharmony_ci} 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_civoid rs600_bandwidth_update(struct radeon_device *rdev) 8948c2ecf20Sopenharmony_ci{ 8958c2ecf20Sopenharmony_ci struct drm_display_mode *mode0 = NULL; 8968c2ecf20Sopenharmony_ci struct drm_display_mode *mode1 = NULL; 8978c2ecf20Sopenharmony_ci u32 d1mode_priority_a_cnt, d2mode_priority_a_cnt; 8988c2ecf20Sopenharmony_ci /* FIXME: implement full support */ 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_ci if (!rdev->mode_info.mode_config_initialized) 9018c2ecf20Sopenharmony_ci return; 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ci radeon_update_display_priority(rdev); 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_ci if (rdev->mode_info.crtcs[0]->base.enabled) 9068c2ecf20Sopenharmony_ci mode0 = &rdev->mode_info.crtcs[0]->base.mode; 9078c2ecf20Sopenharmony_ci if (rdev->mode_info.crtcs[1]->base.enabled) 9088c2ecf20Sopenharmony_ci mode1 = &rdev->mode_info.crtcs[1]->base.mode; 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci rs690_line_buffer_adjust(rdev, mode0, mode1); 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci if (rdev->disp_priority == 2) { 9138c2ecf20Sopenharmony_ci d1mode_priority_a_cnt = RREG32(R_006548_D1MODE_PRIORITY_A_CNT); 9148c2ecf20Sopenharmony_ci d2mode_priority_a_cnt = RREG32(R_006D48_D2MODE_PRIORITY_A_CNT); 9158c2ecf20Sopenharmony_ci d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1); 9168c2ecf20Sopenharmony_ci d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1); 9178c2ecf20Sopenharmony_ci WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt); 9188c2ecf20Sopenharmony_ci WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt); 9198c2ecf20Sopenharmony_ci WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt); 9208c2ecf20Sopenharmony_ci WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt); 9218c2ecf20Sopenharmony_ci } 9228c2ecf20Sopenharmony_ci} 9238c2ecf20Sopenharmony_ci 9248c2ecf20Sopenharmony_ciuint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg) 9258c2ecf20Sopenharmony_ci{ 9268c2ecf20Sopenharmony_ci unsigned long flags; 9278c2ecf20Sopenharmony_ci u32 r; 9288c2ecf20Sopenharmony_ci 9298c2ecf20Sopenharmony_ci spin_lock_irqsave(&rdev->mc_idx_lock, flags); 9308c2ecf20Sopenharmony_ci WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | 9318c2ecf20Sopenharmony_ci S_000070_MC_IND_CITF_ARB0(1)); 9328c2ecf20Sopenharmony_ci r = RREG32(R_000074_MC_IND_DATA); 9338c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); 9348c2ecf20Sopenharmony_ci return r; 9358c2ecf20Sopenharmony_ci} 9368c2ecf20Sopenharmony_ci 9378c2ecf20Sopenharmony_civoid rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 9388c2ecf20Sopenharmony_ci{ 9398c2ecf20Sopenharmony_ci unsigned long flags; 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ci spin_lock_irqsave(&rdev->mc_idx_lock, flags); 9428c2ecf20Sopenharmony_ci WREG32(R_000070_MC_IND_INDEX, S_000070_MC_IND_ADDR(reg) | 9438c2ecf20Sopenharmony_ci S_000070_MC_IND_CITF_ARB0(1) | S_000070_MC_IND_WR_EN(1)); 9448c2ecf20Sopenharmony_ci WREG32(R_000074_MC_IND_DATA, v); 9458c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&rdev->mc_idx_lock, flags); 9468c2ecf20Sopenharmony_ci} 9478c2ecf20Sopenharmony_ci 9488c2ecf20Sopenharmony_cistatic void rs600_debugfs(struct radeon_device *rdev) 9498c2ecf20Sopenharmony_ci{ 9508c2ecf20Sopenharmony_ci if (r100_debugfs_rbbm_init(rdev)) 9518c2ecf20Sopenharmony_ci DRM_ERROR("Failed to register debugfs file for RBBM !\n"); 9528c2ecf20Sopenharmony_ci} 9538c2ecf20Sopenharmony_ci 9548c2ecf20Sopenharmony_civoid rs600_set_safe_registers(struct radeon_device *rdev) 9558c2ecf20Sopenharmony_ci{ 9568c2ecf20Sopenharmony_ci rdev->config.r300.reg_safe_bm = rs600_reg_safe_bm; 9578c2ecf20Sopenharmony_ci rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(rs600_reg_safe_bm); 9588c2ecf20Sopenharmony_ci} 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_cistatic void rs600_mc_program(struct radeon_device *rdev) 9618c2ecf20Sopenharmony_ci{ 9628c2ecf20Sopenharmony_ci struct rv515_mc_save save; 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci /* Stops all mc clients */ 9658c2ecf20Sopenharmony_ci rv515_mc_stop(rdev, &save); 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_ci /* Wait for mc idle */ 9688c2ecf20Sopenharmony_ci if (rs600_mc_wait_for_idle(rdev)) 9698c2ecf20Sopenharmony_ci dev_warn(rdev->dev, "Wait MC idle timeout before updating MC.\n"); 9708c2ecf20Sopenharmony_ci 9718c2ecf20Sopenharmony_ci /* FIXME: What does AGP means for such chipset ? */ 9728c2ecf20Sopenharmony_ci WREG32_MC(R_000005_MC_AGP_LOCATION, 0x0FFFFFFF); 9738c2ecf20Sopenharmony_ci WREG32_MC(R_000006_AGP_BASE, 0); 9748c2ecf20Sopenharmony_ci WREG32_MC(R_000007_AGP_BASE_2, 0); 9758c2ecf20Sopenharmony_ci /* Program MC */ 9768c2ecf20Sopenharmony_ci WREG32_MC(R_000004_MC_FB_LOCATION, 9778c2ecf20Sopenharmony_ci S_000004_MC_FB_START(rdev->mc.vram_start >> 16) | 9788c2ecf20Sopenharmony_ci S_000004_MC_FB_TOP(rdev->mc.vram_end >> 16)); 9798c2ecf20Sopenharmony_ci WREG32(R_000134_HDP_FB_LOCATION, 9808c2ecf20Sopenharmony_ci S_000134_HDP_FB_START(rdev->mc.vram_start >> 16)); 9818c2ecf20Sopenharmony_ci 9828c2ecf20Sopenharmony_ci rv515_mc_resume(rdev, &save); 9838c2ecf20Sopenharmony_ci} 9848c2ecf20Sopenharmony_ci 9858c2ecf20Sopenharmony_cistatic int rs600_startup(struct radeon_device *rdev) 9868c2ecf20Sopenharmony_ci{ 9878c2ecf20Sopenharmony_ci int r; 9888c2ecf20Sopenharmony_ci 9898c2ecf20Sopenharmony_ci rs600_mc_program(rdev); 9908c2ecf20Sopenharmony_ci /* Resume clock */ 9918c2ecf20Sopenharmony_ci rv515_clock_startup(rdev); 9928c2ecf20Sopenharmony_ci /* Initialize GPU configuration (# pipes, ...) */ 9938c2ecf20Sopenharmony_ci rs600_gpu_init(rdev); 9948c2ecf20Sopenharmony_ci /* Initialize GART (initialize after TTM so we can allocate 9958c2ecf20Sopenharmony_ci * memory through TTM but finalize after TTM) */ 9968c2ecf20Sopenharmony_ci r = rs600_gart_enable(rdev); 9978c2ecf20Sopenharmony_ci if (r) 9988c2ecf20Sopenharmony_ci return r; 9998c2ecf20Sopenharmony_ci 10008c2ecf20Sopenharmony_ci /* allocate wb buffer */ 10018c2ecf20Sopenharmony_ci r = radeon_wb_init(rdev); 10028c2ecf20Sopenharmony_ci if (r) 10038c2ecf20Sopenharmony_ci return r; 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); 10068c2ecf20Sopenharmony_ci if (r) { 10078c2ecf20Sopenharmony_ci dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); 10088c2ecf20Sopenharmony_ci return r; 10098c2ecf20Sopenharmony_ci } 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_ci /* Enable IRQ */ 10128c2ecf20Sopenharmony_ci if (!rdev->irq.installed) { 10138c2ecf20Sopenharmony_ci r = radeon_irq_kms_init(rdev); 10148c2ecf20Sopenharmony_ci if (r) 10158c2ecf20Sopenharmony_ci return r; 10168c2ecf20Sopenharmony_ci } 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci rs600_irq_set(rdev); 10198c2ecf20Sopenharmony_ci rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL); 10208c2ecf20Sopenharmony_ci /* 1M ring buffer */ 10218c2ecf20Sopenharmony_ci r = r100_cp_init(rdev, 1024 * 1024); 10228c2ecf20Sopenharmony_ci if (r) { 10238c2ecf20Sopenharmony_ci dev_err(rdev->dev, "failed initializing CP (%d).\n", r); 10248c2ecf20Sopenharmony_ci return r; 10258c2ecf20Sopenharmony_ci } 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci r = radeon_ib_pool_init(rdev); 10288c2ecf20Sopenharmony_ci if (r) { 10298c2ecf20Sopenharmony_ci dev_err(rdev->dev, "IB initialization failed (%d).\n", r); 10308c2ecf20Sopenharmony_ci return r; 10318c2ecf20Sopenharmony_ci } 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci r = radeon_audio_init(rdev); 10348c2ecf20Sopenharmony_ci if (r) { 10358c2ecf20Sopenharmony_ci dev_err(rdev->dev, "failed initializing audio\n"); 10368c2ecf20Sopenharmony_ci return r; 10378c2ecf20Sopenharmony_ci } 10388c2ecf20Sopenharmony_ci 10398c2ecf20Sopenharmony_ci return 0; 10408c2ecf20Sopenharmony_ci} 10418c2ecf20Sopenharmony_ci 10428c2ecf20Sopenharmony_ciint rs600_resume(struct radeon_device *rdev) 10438c2ecf20Sopenharmony_ci{ 10448c2ecf20Sopenharmony_ci int r; 10458c2ecf20Sopenharmony_ci 10468c2ecf20Sopenharmony_ci /* Make sur GART are not working */ 10478c2ecf20Sopenharmony_ci rs600_gart_disable(rdev); 10488c2ecf20Sopenharmony_ci /* Resume clock before doing reset */ 10498c2ecf20Sopenharmony_ci rv515_clock_startup(rdev); 10508c2ecf20Sopenharmony_ci /* Reset gpu before posting otherwise ATOM will enter infinite loop */ 10518c2ecf20Sopenharmony_ci if (radeon_asic_reset(rdev)) { 10528c2ecf20Sopenharmony_ci dev_warn(rdev->dev, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", 10538c2ecf20Sopenharmony_ci RREG32(R_000E40_RBBM_STATUS), 10548c2ecf20Sopenharmony_ci RREG32(R_0007C0_CP_STAT)); 10558c2ecf20Sopenharmony_ci } 10568c2ecf20Sopenharmony_ci /* post */ 10578c2ecf20Sopenharmony_ci atom_asic_init(rdev->mode_info.atom_context); 10588c2ecf20Sopenharmony_ci /* Resume clock after posting */ 10598c2ecf20Sopenharmony_ci rv515_clock_startup(rdev); 10608c2ecf20Sopenharmony_ci /* Initialize surface registers */ 10618c2ecf20Sopenharmony_ci radeon_surface_init(rdev); 10628c2ecf20Sopenharmony_ci 10638c2ecf20Sopenharmony_ci rdev->accel_working = true; 10648c2ecf20Sopenharmony_ci r = rs600_startup(rdev); 10658c2ecf20Sopenharmony_ci if (r) { 10668c2ecf20Sopenharmony_ci rdev->accel_working = false; 10678c2ecf20Sopenharmony_ci } 10688c2ecf20Sopenharmony_ci return r; 10698c2ecf20Sopenharmony_ci} 10708c2ecf20Sopenharmony_ci 10718c2ecf20Sopenharmony_ciint rs600_suspend(struct radeon_device *rdev) 10728c2ecf20Sopenharmony_ci{ 10738c2ecf20Sopenharmony_ci radeon_pm_suspend(rdev); 10748c2ecf20Sopenharmony_ci radeon_audio_fini(rdev); 10758c2ecf20Sopenharmony_ci r100_cp_disable(rdev); 10768c2ecf20Sopenharmony_ci radeon_wb_disable(rdev); 10778c2ecf20Sopenharmony_ci rs600_irq_disable(rdev); 10788c2ecf20Sopenharmony_ci rs600_gart_disable(rdev); 10798c2ecf20Sopenharmony_ci return 0; 10808c2ecf20Sopenharmony_ci} 10818c2ecf20Sopenharmony_ci 10828c2ecf20Sopenharmony_civoid rs600_fini(struct radeon_device *rdev) 10838c2ecf20Sopenharmony_ci{ 10848c2ecf20Sopenharmony_ci radeon_pm_fini(rdev); 10858c2ecf20Sopenharmony_ci radeon_audio_fini(rdev); 10868c2ecf20Sopenharmony_ci r100_cp_fini(rdev); 10878c2ecf20Sopenharmony_ci radeon_wb_fini(rdev); 10888c2ecf20Sopenharmony_ci radeon_ib_pool_fini(rdev); 10898c2ecf20Sopenharmony_ci radeon_gem_fini(rdev); 10908c2ecf20Sopenharmony_ci rs600_gart_fini(rdev); 10918c2ecf20Sopenharmony_ci radeon_irq_kms_fini(rdev); 10928c2ecf20Sopenharmony_ci radeon_fence_driver_fini(rdev); 10938c2ecf20Sopenharmony_ci radeon_bo_fini(rdev); 10948c2ecf20Sopenharmony_ci radeon_atombios_fini(rdev); 10958c2ecf20Sopenharmony_ci kfree(rdev->bios); 10968c2ecf20Sopenharmony_ci rdev->bios = NULL; 10978c2ecf20Sopenharmony_ci} 10988c2ecf20Sopenharmony_ci 10998c2ecf20Sopenharmony_ciint rs600_init(struct radeon_device *rdev) 11008c2ecf20Sopenharmony_ci{ 11018c2ecf20Sopenharmony_ci int r; 11028c2ecf20Sopenharmony_ci 11038c2ecf20Sopenharmony_ci /* Disable VGA */ 11048c2ecf20Sopenharmony_ci rv515_vga_render_disable(rdev); 11058c2ecf20Sopenharmony_ci /* Initialize scratch registers */ 11068c2ecf20Sopenharmony_ci radeon_scratch_init(rdev); 11078c2ecf20Sopenharmony_ci /* Initialize surface registers */ 11088c2ecf20Sopenharmony_ci radeon_surface_init(rdev); 11098c2ecf20Sopenharmony_ci /* restore some register to sane defaults */ 11108c2ecf20Sopenharmony_ci r100_restore_sanity(rdev); 11118c2ecf20Sopenharmony_ci /* BIOS */ 11128c2ecf20Sopenharmony_ci if (!radeon_get_bios(rdev)) { 11138c2ecf20Sopenharmony_ci if (ASIC_IS_AVIVO(rdev)) 11148c2ecf20Sopenharmony_ci return -EINVAL; 11158c2ecf20Sopenharmony_ci } 11168c2ecf20Sopenharmony_ci if (rdev->is_atom_bios) { 11178c2ecf20Sopenharmony_ci r = radeon_atombios_init(rdev); 11188c2ecf20Sopenharmony_ci if (r) 11198c2ecf20Sopenharmony_ci return r; 11208c2ecf20Sopenharmony_ci } else { 11218c2ecf20Sopenharmony_ci dev_err(rdev->dev, "Expecting atombios for RS600 GPU\n"); 11228c2ecf20Sopenharmony_ci return -EINVAL; 11238c2ecf20Sopenharmony_ci } 11248c2ecf20Sopenharmony_ci /* Reset gpu before posting otherwise ATOM will enter infinite loop */ 11258c2ecf20Sopenharmony_ci if (radeon_asic_reset(rdev)) { 11268c2ecf20Sopenharmony_ci dev_warn(rdev->dev, 11278c2ecf20Sopenharmony_ci "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", 11288c2ecf20Sopenharmony_ci RREG32(R_000E40_RBBM_STATUS), 11298c2ecf20Sopenharmony_ci RREG32(R_0007C0_CP_STAT)); 11308c2ecf20Sopenharmony_ci } 11318c2ecf20Sopenharmony_ci /* check if cards are posted or not */ 11328c2ecf20Sopenharmony_ci if (radeon_boot_test_post_card(rdev) == false) 11338c2ecf20Sopenharmony_ci return -EINVAL; 11348c2ecf20Sopenharmony_ci 11358c2ecf20Sopenharmony_ci /* Initialize clocks */ 11368c2ecf20Sopenharmony_ci radeon_get_clock_info(rdev->ddev); 11378c2ecf20Sopenharmony_ci /* initialize memory controller */ 11388c2ecf20Sopenharmony_ci rs600_mc_init(rdev); 11398c2ecf20Sopenharmony_ci rs600_debugfs(rdev); 11408c2ecf20Sopenharmony_ci /* Fence driver */ 11418c2ecf20Sopenharmony_ci r = radeon_fence_driver_init(rdev); 11428c2ecf20Sopenharmony_ci if (r) 11438c2ecf20Sopenharmony_ci return r; 11448c2ecf20Sopenharmony_ci /* Memory manager */ 11458c2ecf20Sopenharmony_ci r = radeon_bo_init(rdev); 11468c2ecf20Sopenharmony_ci if (r) 11478c2ecf20Sopenharmony_ci return r; 11488c2ecf20Sopenharmony_ci r = rs600_gart_init(rdev); 11498c2ecf20Sopenharmony_ci if (r) 11508c2ecf20Sopenharmony_ci return r; 11518c2ecf20Sopenharmony_ci rs600_set_safe_registers(rdev); 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci /* Initialize power management */ 11548c2ecf20Sopenharmony_ci radeon_pm_init(rdev); 11558c2ecf20Sopenharmony_ci 11568c2ecf20Sopenharmony_ci rdev->accel_working = true; 11578c2ecf20Sopenharmony_ci r = rs600_startup(rdev); 11588c2ecf20Sopenharmony_ci if (r) { 11598c2ecf20Sopenharmony_ci /* Somethings want wront with the accel init stop accel */ 11608c2ecf20Sopenharmony_ci dev_err(rdev->dev, "Disabling GPU acceleration\n"); 11618c2ecf20Sopenharmony_ci r100_cp_fini(rdev); 11628c2ecf20Sopenharmony_ci radeon_wb_fini(rdev); 11638c2ecf20Sopenharmony_ci radeon_ib_pool_fini(rdev); 11648c2ecf20Sopenharmony_ci rs600_gart_fini(rdev); 11658c2ecf20Sopenharmony_ci radeon_irq_kms_fini(rdev); 11668c2ecf20Sopenharmony_ci rdev->accel_working = false; 11678c2ecf20Sopenharmony_ci } 11688c2ecf20Sopenharmony_ci return 0; 11698c2ecf20Sopenharmony_ci} 1170