1771fe6b9SJerome Glisse /* 2771fe6b9SJerome Glisse * Copyright 2008 Advanced Micro Devices, Inc. 3771fe6b9SJerome Glisse * Copyright 2008 Red Hat Inc. 4771fe6b9SJerome Glisse * Copyright 2009 Jerome Glisse. 5771fe6b9SJerome Glisse * 6771fe6b9SJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining a 7771fe6b9SJerome Glisse * copy of this software and associated documentation files (the "Software"), 8771fe6b9SJerome Glisse * to deal in the Software without restriction, including without limitation 9771fe6b9SJerome Glisse * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10771fe6b9SJerome Glisse * and/or sell copies of the Software, and to permit persons to whom the 11771fe6b9SJerome Glisse * Software is furnished to do so, subject to the following conditions: 12771fe6b9SJerome Glisse * 13771fe6b9SJerome Glisse * The above copyright notice and this permission notice shall be included in 14771fe6b9SJerome Glisse * all copies or substantial portions of the Software. 15771fe6b9SJerome Glisse * 16771fe6b9SJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17771fe6b9SJerome Glisse * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18771fe6b9SJerome Glisse * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19771fe6b9SJerome Glisse * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20771fe6b9SJerome Glisse * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21771fe6b9SJerome Glisse * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22771fe6b9SJerome Glisse * OTHER DEALINGS IN THE SOFTWARE. 23771fe6b9SJerome Glisse * 24771fe6b9SJerome Glisse * Authors: Dave Airlie 25771fe6b9SJerome Glisse * Alex Deucher 26771fe6b9SJerome Glisse * Jerome Glisse 27771fe6b9SJerome Glisse */ 28771fe6b9SJerome Glisse #include <linux/seq_file.h> 29771fe6b9SJerome Glisse #include "drmP.h" 30771fe6b9SJerome Glisse #include "radeon_reg.h" 31771fe6b9SJerome Glisse #include "radeon.h" 329f022ddfSJerome Glisse #include "atom.h" 33*62cdc0c2SCorbin Simpson #include "r100d.h" 34905b6822SJerome Glisse #include "r420d.h" 35771fe6b9SJerome Glisse 36771fe6b9SJerome Glisse int r420_mc_init(struct radeon_device *rdev) 37771fe6b9SJerome Glisse { 38771fe6b9SJerome Glisse int r; 39771fe6b9SJerome Glisse 40771fe6b9SJerome Glisse /* Setup GPU memory space */ 41771fe6b9SJerome Glisse rdev->mc.vram_location = 0xFFFFFFFFUL; 42771fe6b9SJerome Glisse rdev->mc.gtt_location = 0xFFFFFFFFUL; 43771fe6b9SJerome Glisse if (rdev->flags & RADEON_IS_AGP) { 44771fe6b9SJerome Glisse r = radeon_agp_init(rdev); 45771fe6b9SJerome Glisse if (r) { 46771fe6b9SJerome Glisse printk(KERN_WARNING "[drm] Disabling AGP\n"); 47771fe6b9SJerome Glisse rdev->flags &= ~RADEON_IS_AGP; 48771fe6b9SJerome Glisse rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; 49771fe6b9SJerome Glisse } else { 50771fe6b9SJerome Glisse rdev->mc.gtt_location = rdev->mc.agp_base; 51771fe6b9SJerome Glisse } 52771fe6b9SJerome Glisse } 53771fe6b9SJerome Glisse r = radeon_mc_setup(rdev); 54771fe6b9SJerome Glisse if (r) { 55771fe6b9SJerome Glisse return r; 56771fe6b9SJerome Glisse } 57771fe6b9SJerome Glisse return 0; 58771fe6b9SJerome Glisse } 59771fe6b9SJerome Glisse 60771fe6b9SJerome Glisse void r420_pipes_init(struct radeon_device *rdev) 61771fe6b9SJerome Glisse { 62771fe6b9SJerome Glisse unsigned tmp; 63771fe6b9SJerome Glisse unsigned gb_pipe_select; 64771fe6b9SJerome Glisse unsigned num_pipes; 65771fe6b9SJerome Glisse 66771fe6b9SJerome Glisse /* GA_ENHANCE workaround TCL deadlock issue */ 67771fe6b9SJerome Glisse WREG32(0x4274, (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); 6818a4cd2eSDave Airlie /* add idle wait as per freedesktop.org bug 24041 */ 6918a4cd2eSDave Airlie if (r100_gui_wait_for_idle(rdev)) { 7018a4cd2eSDave Airlie printk(KERN_WARNING "Failed to wait GUI idle while " 7118a4cd2eSDave Airlie "programming pipes. Bad things might happen.\n"); 7218a4cd2eSDave Airlie } 73771fe6b9SJerome Glisse /* get max number of pipes */ 74771fe6b9SJerome Glisse gb_pipe_select = RREG32(0x402C); 75771fe6b9SJerome Glisse num_pipes = ((gb_pipe_select >> 12) & 3) + 1; 76771fe6b9SJerome Glisse rdev->num_gb_pipes = num_pipes; 77771fe6b9SJerome Glisse tmp = 0; 78771fe6b9SJerome Glisse switch (num_pipes) { 79771fe6b9SJerome Glisse default: 80771fe6b9SJerome Glisse /* force to 1 pipe */ 81771fe6b9SJerome Glisse num_pipes = 1; 82771fe6b9SJerome Glisse case 1: 83771fe6b9SJerome Glisse tmp = (0 << 1); 84771fe6b9SJerome Glisse break; 85771fe6b9SJerome Glisse case 2: 86771fe6b9SJerome Glisse tmp = (3 << 1); 87771fe6b9SJerome Glisse break; 88771fe6b9SJerome Glisse case 3: 89771fe6b9SJerome Glisse tmp = (6 << 1); 90771fe6b9SJerome Glisse break; 91771fe6b9SJerome Glisse case 4: 92771fe6b9SJerome Glisse tmp = (7 << 1); 93771fe6b9SJerome Glisse break; 94771fe6b9SJerome Glisse } 95771fe6b9SJerome Glisse WREG32(0x42C8, (1 << num_pipes) - 1); 96771fe6b9SJerome Glisse /* Sub pixel 1/12 so we can have 4K rendering according to doc */ 97771fe6b9SJerome Glisse tmp |= (1 << 4) | (1 << 0); 98771fe6b9SJerome Glisse WREG32(0x4018, tmp); 99771fe6b9SJerome Glisse if (r100_gui_wait_for_idle(rdev)) { 100771fe6b9SJerome Glisse printk(KERN_WARNING "Failed to wait GUI idle while " 101771fe6b9SJerome Glisse "programming pipes. Bad things might happen.\n"); 102771fe6b9SJerome Glisse } 103771fe6b9SJerome Glisse 104771fe6b9SJerome Glisse tmp = RREG32(0x170C); 105771fe6b9SJerome Glisse WREG32(0x170C, tmp | (1 << 31)); 106771fe6b9SJerome Glisse 107771fe6b9SJerome Glisse WREG32(R300_RB2D_DSTCACHE_MODE, 108771fe6b9SJerome Glisse RREG32(R300_RB2D_DSTCACHE_MODE) | 109771fe6b9SJerome Glisse R300_DC_AUTOFLUSH_ENABLE | 110771fe6b9SJerome Glisse R300_DC_DC_DISABLE_IGNORE_PE); 111771fe6b9SJerome Glisse 112771fe6b9SJerome Glisse if (r100_gui_wait_for_idle(rdev)) { 113771fe6b9SJerome Glisse printk(KERN_WARNING "Failed to wait GUI idle while " 114771fe6b9SJerome Glisse "programming pipes. Bad things might happen.\n"); 115771fe6b9SJerome Glisse } 116f779b3e5SAlex Deucher 117f779b3e5SAlex Deucher if (rdev->family == CHIP_RV530) { 118f779b3e5SAlex Deucher tmp = RREG32(RV530_GB_PIPE_SELECT2); 119f779b3e5SAlex Deucher if ((tmp & 3) == 3) 120f779b3e5SAlex Deucher rdev->num_z_pipes = 2; 121f779b3e5SAlex Deucher else 122f779b3e5SAlex Deucher rdev->num_z_pipes = 1; 123f779b3e5SAlex Deucher } else 124f779b3e5SAlex Deucher rdev->num_z_pipes = 1; 125f779b3e5SAlex Deucher 126f779b3e5SAlex Deucher DRM_INFO("radeon: %d quad pipes, %d z pipes initialized.\n", 127f779b3e5SAlex Deucher rdev->num_gb_pipes, rdev->num_z_pipes); 128771fe6b9SJerome Glisse } 129771fe6b9SJerome Glisse 1309f022ddfSJerome Glisse u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg) 131771fe6b9SJerome Glisse { 1329f022ddfSJerome Glisse u32 r; 1339f022ddfSJerome Glisse 1349f022ddfSJerome Glisse WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg)); 1359f022ddfSJerome Glisse r = RREG32(R_0001FC_MC_IND_DATA); 1369f022ddfSJerome Glisse return r; 1379f022ddfSJerome Glisse } 1389f022ddfSJerome Glisse 1399f022ddfSJerome Glisse void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v) 1409f022ddfSJerome Glisse { 1419f022ddfSJerome Glisse WREG32(R_0001F8_MC_IND_INDEX, S_0001F8_MC_IND_ADDR(reg) | 1429f022ddfSJerome Glisse S_0001F8_MC_IND_WR_EN(1)); 1439f022ddfSJerome Glisse WREG32(R_0001FC_MC_IND_DATA, v); 1449f022ddfSJerome Glisse } 1459f022ddfSJerome Glisse 1469f022ddfSJerome Glisse static void r420_debugfs(struct radeon_device *rdev) 1479f022ddfSJerome Glisse { 1489f022ddfSJerome Glisse if (r100_debugfs_rbbm_init(rdev)) { 1499f022ddfSJerome Glisse DRM_ERROR("Failed to register debugfs file for RBBM !\n"); 1509f022ddfSJerome Glisse } 1519f022ddfSJerome Glisse if (r420_debugfs_pipes_info_init(rdev)) { 1529f022ddfSJerome Glisse DRM_ERROR("Failed to register debugfs file for pipes !\n"); 1539f022ddfSJerome Glisse } 1549f022ddfSJerome Glisse } 1559f022ddfSJerome Glisse 1569f022ddfSJerome Glisse static void r420_clock_resume(struct radeon_device *rdev) 1579f022ddfSJerome Glisse { 1589f022ddfSJerome Glisse u32 sclk_cntl; 159ca6ffc64SJerome Glisse 160ca6ffc64SJerome Glisse if (radeon_dynclks != -1 && radeon_dynclks) 161ca6ffc64SJerome Glisse radeon_atom_set_clock_gating(rdev, 1); 1629f022ddfSJerome Glisse sclk_cntl = RREG32_PLL(R_00000D_SCLK_CNTL); 1639f022ddfSJerome Glisse sclk_cntl |= S_00000D_FORCE_CP(1) | S_00000D_FORCE_VIP(1); 1649f022ddfSJerome Glisse if (rdev->family == CHIP_R420) 1659f022ddfSJerome Glisse sclk_cntl |= S_00000D_FORCE_PX(1) | S_00000D_FORCE_TX(1); 1669f022ddfSJerome Glisse WREG32_PLL(R_00000D_SCLK_CNTL, sclk_cntl); 1679f022ddfSJerome Glisse } 1689f022ddfSJerome Glisse 169*62cdc0c2SCorbin Simpson static void r420_cp_errata_init(struct radeon_device *rdev) 170*62cdc0c2SCorbin Simpson { 171*62cdc0c2SCorbin Simpson /* RV410 and R420 can lock up if CP DMA to host memory happens 172*62cdc0c2SCorbin Simpson * while the 2D engine is busy. 173*62cdc0c2SCorbin Simpson * 174*62cdc0c2SCorbin Simpson * The proper workaround is to queue a RESYNC at the beginning 175*62cdc0c2SCorbin Simpson * of the CP init, apparently. 176*62cdc0c2SCorbin Simpson */ 177*62cdc0c2SCorbin Simpson radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch); 178*62cdc0c2SCorbin Simpson radeon_ring_lock(rdev, 8); 179*62cdc0c2SCorbin Simpson radeon_ring_write(rdev, PACKET0(R300_CP_RESYNC_ADDR, 1)); 180*62cdc0c2SCorbin Simpson radeon_ring_write(rdev, rdev->config.r300.resync_scratch); 181*62cdc0c2SCorbin Simpson radeon_ring_write(rdev, 0xDEADBEEF); 182*62cdc0c2SCorbin Simpson radeon_ring_unlock_commit(rdev); 183*62cdc0c2SCorbin Simpson } 184*62cdc0c2SCorbin Simpson 185*62cdc0c2SCorbin Simpson static void r420_cp_errata_fini(struct radeon_device *rdev) 186*62cdc0c2SCorbin Simpson { 187*62cdc0c2SCorbin Simpson /* Catch the RESYNC we dispatched all the way back, 188*62cdc0c2SCorbin Simpson * at the very beginning of the CP init. 189*62cdc0c2SCorbin Simpson */ 190*62cdc0c2SCorbin Simpson radeon_ring_lock(rdev, 8); 191*62cdc0c2SCorbin Simpson radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); 192*62cdc0c2SCorbin Simpson radeon_ring_write(rdev, R300_RB3D_DC_FINISH); 193*62cdc0c2SCorbin Simpson radeon_ring_unlock_commit(rdev); 194*62cdc0c2SCorbin Simpson radeon_scratch_free(rdev, rdev->config.r300.resync_scratch); 195*62cdc0c2SCorbin Simpson } 196*62cdc0c2SCorbin Simpson 197fc30b8efSDave Airlie static int r420_startup(struct radeon_device *rdev) 1989f022ddfSJerome Glisse { 1999f022ddfSJerome Glisse int r; 2009f022ddfSJerome Glisse 20192cde00cSAlex Deucher /* set common regs */ 20292cde00cSAlex Deucher r100_set_common_regs(rdev); 20392cde00cSAlex Deucher /* program mc */ 2049f022ddfSJerome Glisse r300_mc_program(rdev); 205ca6ffc64SJerome Glisse /* Resume clock */ 206ca6ffc64SJerome Glisse r420_clock_resume(rdev); 2079f022ddfSJerome Glisse /* Initialize GART (initialize after TTM so we can allocate 2089f022ddfSJerome Glisse * memory through TTM but finalize after TTM) */ 2094aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCIE) { 2104aac0473SJerome Glisse r = rv370_pcie_gart_enable(rdev); 2114aac0473SJerome Glisse if (r) 2124aac0473SJerome Glisse return r; 2134aac0473SJerome Glisse } 2144aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCI) { 2154aac0473SJerome Glisse r = r100_pci_gart_enable(rdev); 2164aac0473SJerome Glisse if (r) 2179f022ddfSJerome Glisse return r; 2189f022ddfSJerome Glisse } 219771fe6b9SJerome Glisse r420_pipes_init(rdev); 2209f022ddfSJerome Glisse /* Enable IRQ */ 2219f022ddfSJerome Glisse r100_irq_set(rdev); 2229f022ddfSJerome Glisse /* 1M ring buffer */ 2239f022ddfSJerome Glisse r = r100_cp_init(rdev, 1024 * 1024); 2249f022ddfSJerome Glisse if (r) { 2259f022ddfSJerome Glisse dev_err(rdev->dev, "failled initializing CP (%d).\n", r); 2269f022ddfSJerome Glisse return r; 227771fe6b9SJerome Glisse } 228*62cdc0c2SCorbin Simpson r420_cp_errata_init(rdev); 2299f022ddfSJerome Glisse r = r100_wb_init(rdev); 2309f022ddfSJerome Glisse if (r) { 2319f022ddfSJerome Glisse dev_err(rdev->dev, "failled initializing WB (%d).\n", r); 2329f022ddfSJerome Glisse } 2339f022ddfSJerome Glisse r = r100_ib_init(rdev); 2349f022ddfSJerome Glisse if (r) { 2359f022ddfSJerome Glisse dev_err(rdev->dev, "failled initializing IB (%d).\n", r); 2369f022ddfSJerome Glisse return r; 2379f022ddfSJerome Glisse } 2389f022ddfSJerome Glisse return 0; 239771fe6b9SJerome Glisse } 240771fe6b9SJerome Glisse 241fc30b8efSDave Airlie int r420_resume(struct radeon_device *rdev) 242fc30b8efSDave Airlie { 243fc30b8efSDave Airlie /* Make sur GART are not working */ 244fc30b8efSDave Airlie if (rdev->flags & RADEON_IS_PCIE) 245fc30b8efSDave Airlie rv370_pcie_gart_disable(rdev); 246fc30b8efSDave Airlie if (rdev->flags & RADEON_IS_PCI) 247fc30b8efSDave Airlie r100_pci_gart_disable(rdev); 248fc30b8efSDave Airlie /* Resume clock before doing reset */ 249fc30b8efSDave Airlie r420_clock_resume(rdev); 250fc30b8efSDave Airlie /* Reset gpu before posting otherwise ATOM will enter infinite loop */ 251fc30b8efSDave Airlie if (radeon_gpu_reset(rdev)) { 252fc30b8efSDave Airlie dev_warn(rdev->dev, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", 253fc30b8efSDave Airlie RREG32(R_000E40_RBBM_STATUS), 254fc30b8efSDave Airlie RREG32(R_0007C0_CP_STAT)); 255fc30b8efSDave Airlie } 256fc30b8efSDave Airlie /* check if cards are posted or not */ 257fc30b8efSDave Airlie if (rdev->is_atom_bios) { 258fc30b8efSDave Airlie atom_asic_init(rdev->mode_info.atom_context); 259fc30b8efSDave Airlie } else { 260fc30b8efSDave Airlie radeon_combios_asic_init(rdev->ddev); 261fc30b8efSDave Airlie } 262fc30b8efSDave Airlie /* Resume clock after posting */ 263fc30b8efSDave Airlie r420_clock_resume(rdev); 264550e2d92SDave Airlie /* Initialize surface registers */ 265550e2d92SDave Airlie radeon_surface_init(rdev); 266fc30b8efSDave Airlie return r420_startup(rdev); 267fc30b8efSDave Airlie } 268fc30b8efSDave Airlie 2699f022ddfSJerome Glisse int r420_suspend(struct radeon_device *rdev) 270771fe6b9SJerome Glisse { 271*62cdc0c2SCorbin Simpson r420_cp_errata_fini(rdev); 2729f022ddfSJerome Glisse r100_cp_disable(rdev); 2739f022ddfSJerome Glisse r100_wb_disable(rdev); 2749f022ddfSJerome Glisse r100_irq_disable(rdev); 2754aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCIE) 2764aac0473SJerome Glisse rv370_pcie_gart_disable(rdev); 2774aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCI) 2784aac0473SJerome Glisse r100_pci_gart_disable(rdev); 2799f022ddfSJerome Glisse return 0; 280771fe6b9SJerome Glisse } 281771fe6b9SJerome Glisse 2829f022ddfSJerome Glisse void r420_fini(struct radeon_device *rdev) 2839f022ddfSJerome Glisse { 2849f022ddfSJerome Glisse r100_cp_fini(rdev); 2859f022ddfSJerome Glisse r100_wb_fini(rdev); 2869f022ddfSJerome Glisse r100_ib_fini(rdev); 2879f022ddfSJerome Glisse radeon_gem_fini(rdev); 2884aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCIE) 2894aac0473SJerome Glisse rv370_pcie_gart_fini(rdev); 2904aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCI) 2914aac0473SJerome Glisse r100_pci_gart_fini(rdev); 2929f022ddfSJerome Glisse radeon_agp_fini(rdev); 2939f022ddfSJerome Glisse radeon_irq_kms_fini(rdev); 2949f022ddfSJerome Glisse radeon_fence_driver_fini(rdev); 2954c788679SJerome Glisse radeon_bo_fini(rdev); 2969f022ddfSJerome Glisse if (rdev->is_atom_bios) { 2979f022ddfSJerome Glisse radeon_atombios_fini(rdev); 2989f022ddfSJerome Glisse } else { 2999f022ddfSJerome Glisse radeon_combios_fini(rdev); 3009f022ddfSJerome Glisse } 3019f022ddfSJerome Glisse kfree(rdev->bios); 3029f022ddfSJerome Glisse rdev->bios = NULL; 3039f022ddfSJerome Glisse } 3049f022ddfSJerome Glisse 3059f022ddfSJerome Glisse int r420_init(struct radeon_device *rdev) 3069f022ddfSJerome Glisse { 3079f022ddfSJerome Glisse int r; 3089f022ddfSJerome Glisse 3099f022ddfSJerome Glisse /* Initialize scratch registers */ 3109f022ddfSJerome Glisse radeon_scratch_init(rdev); 3119f022ddfSJerome Glisse /* Initialize surface registers */ 3129f022ddfSJerome Glisse radeon_surface_init(rdev); 3139f022ddfSJerome Glisse /* TODO: disable VGA need to use VGA request */ 3149f022ddfSJerome Glisse /* BIOS*/ 3159f022ddfSJerome Glisse if (!radeon_get_bios(rdev)) { 3169f022ddfSJerome Glisse if (ASIC_IS_AVIVO(rdev)) 3179f022ddfSJerome Glisse return -EINVAL; 3189f022ddfSJerome Glisse } 3199f022ddfSJerome Glisse if (rdev->is_atom_bios) { 3209f022ddfSJerome Glisse r = radeon_atombios_init(rdev); 3219f022ddfSJerome Glisse if (r) { 3229f022ddfSJerome Glisse return r; 3239f022ddfSJerome Glisse } 3249f022ddfSJerome Glisse } else { 3259f022ddfSJerome Glisse r = radeon_combios_init(rdev); 3269f022ddfSJerome Glisse if (r) { 3279f022ddfSJerome Glisse return r; 3289f022ddfSJerome Glisse } 3299f022ddfSJerome Glisse } 3309f022ddfSJerome Glisse /* Reset gpu before posting otherwise ATOM will enter infinite loop */ 3319f022ddfSJerome Glisse if (radeon_gpu_reset(rdev)) { 3329f022ddfSJerome Glisse dev_warn(rdev->dev, 3339f022ddfSJerome Glisse "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n", 3349f022ddfSJerome Glisse RREG32(R_000E40_RBBM_STATUS), 3359f022ddfSJerome Glisse RREG32(R_0007C0_CP_STAT)); 3369f022ddfSJerome Glisse } 3379f022ddfSJerome Glisse /* check if cards are posted or not */ 33872542d77SDave Airlie if (radeon_boot_test_post_card(rdev) == false) 33972542d77SDave Airlie return -EINVAL; 34072542d77SDave Airlie 3419f022ddfSJerome Glisse /* Initialize clocks */ 3429f022ddfSJerome Glisse radeon_get_clock_info(rdev->ddev); 3437433874eSRafał Miłecki /* Initialize power management */ 3447433874eSRafał Miłecki radeon_pm_init(rdev); 3459f022ddfSJerome Glisse /* Get vram informations */ 3469f022ddfSJerome Glisse r300_vram_info(rdev); 3479f022ddfSJerome Glisse /* Initialize memory controller (also test AGP) */ 3489f022ddfSJerome Glisse r = r420_mc_init(rdev); 3499f022ddfSJerome Glisse if (r) { 3509f022ddfSJerome Glisse return r; 3519f022ddfSJerome Glisse } 3529f022ddfSJerome Glisse r420_debugfs(rdev); 3539f022ddfSJerome Glisse /* Fence driver */ 3549f022ddfSJerome Glisse r = radeon_fence_driver_init(rdev); 3559f022ddfSJerome Glisse if (r) { 3569f022ddfSJerome Glisse return r; 3579f022ddfSJerome Glisse } 3589f022ddfSJerome Glisse r = radeon_irq_kms_init(rdev); 3599f022ddfSJerome Glisse if (r) { 3609f022ddfSJerome Glisse return r; 3619f022ddfSJerome Glisse } 3629f022ddfSJerome Glisse /* Memory manager */ 3634c788679SJerome Glisse r = radeon_bo_init(rdev); 3649f022ddfSJerome Glisse if (r) { 3659f022ddfSJerome Glisse return r; 3669f022ddfSJerome Glisse } 36717e15b0cSDave Airlie if (rdev->family == CHIP_R420) 36817e15b0cSDave Airlie r100_enable_bm(rdev); 36917e15b0cSDave Airlie 3704aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCIE) { 3714aac0473SJerome Glisse r = rv370_pcie_gart_init(rdev); 3724aac0473SJerome Glisse if (r) 3734aac0473SJerome Glisse return r; 3744aac0473SJerome Glisse } 3754aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCI) { 3764aac0473SJerome Glisse r = r100_pci_gart_init(rdev); 3774aac0473SJerome Glisse if (r) 3784aac0473SJerome Glisse return r; 3794aac0473SJerome Glisse } 3809f022ddfSJerome Glisse r300_set_reg_safe(rdev); 381733289c2SJerome Glisse rdev->accel_working = true; 382fc30b8efSDave Airlie r = r420_startup(rdev); 3839f022ddfSJerome Glisse if (r) { 3849f022ddfSJerome Glisse /* Somethings want wront with the accel init stop accel */ 3859f022ddfSJerome Glisse dev_err(rdev->dev, "Disabling GPU acceleration\n"); 3869f022ddfSJerome Glisse r420_suspend(rdev); 3879f022ddfSJerome Glisse r100_cp_fini(rdev); 3889f022ddfSJerome Glisse r100_wb_fini(rdev); 3899f022ddfSJerome Glisse r100_ib_fini(rdev); 3904aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCIE) 3914aac0473SJerome Glisse rv370_pcie_gart_fini(rdev); 3924aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCI) 3934aac0473SJerome Glisse r100_pci_gart_fini(rdev); 3949f022ddfSJerome Glisse radeon_agp_fini(rdev); 3959f022ddfSJerome Glisse radeon_irq_kms_fini(rdev); 396733289c2SJerome Glisse rdev->accel_working = false; 3979f022ddfSJerome Glisse } 3989f022ddfSJerome Glisse return 0; 3999f022ddfSJerome Glisse } 400771fe6b9SJerome Glisse 401771fe6b9SJerome Glisse /* 402771fe6b9SJerome Glisse * Debugfs info 403771fe6b9SJerome Glisse */ 404771fe6b9SJerome Glisse #if defined(CONFIG_DEBUG_FS) 405771fe6b9SJerome Glisse static int r420_debugfs_pipes_info(struct seq_file *m, void *data) 406771fe6b9SJerome Glisse { 407771fe6b9SJerome Glisse struct drm_info_node *node = (struct drm_info_node *) m->private; 408771fe6b9SJerome Glisse struct drm_device *dev = node->minor->dev; 409771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 410771fe6b9SJerome Glisse uint32_t tmp; 411771fe6b9SJerome Glisse 412771fe6b9SJerome Glisse tmp = RREG32(R400_GB_PIPE_SELECT); 413771fe6b9SJerome Glisse seq_printf(m, "GB_PIPE_SELECT 0x%08x\n", tmp); 414771fe6b9SJerome Glisse tmp = RREG32(R300_GB_TILE_CONFIG); 415771fe6b9SJerome Glisse seq_printf(m, "GB_TILE_CONFIG 0x%08x\n", tmp); 416771fe6b9SJerome Glisse tmp = RREG32(R300_DST_PIPE_CONFIG); 417771fe6b9SJerome Glisse seq_printf(m, "DST_PIPE_CONFIG 0x%08x\n", tmp); 418771fe6b9SJerome Glisse return 0; 419771fe6b9SJerome Glisse } 420771fe6b9SJerome Glisse 421771fe6b9SJerome Glisse static struct drm_info_list r420_pipes_info_list[] = { 422771fe6b9SJerome Glisse {"r420_pipes_info", r420_debugfs_pipes_info, 0, NULL}, 423771fe6b9SJerome Glisse }; 424771fe6b9SJerome Glisse #endif 425771fe6b9SJerome Glisse 426771fe6b9SJerome Glisse int r420_debugfs_pipes_info_init(struct radeon_device *rdev) 427771fe6b9SJerome Glisse { 428771fe6b9SJerome Glisse #if defined(CONFIG_DEBUG_FS) 429771fe6b9SJerome Glisse return radeon_debugfs_add_files(rdev, r420_pipes_info_list, 1); 430771fe6b9SJerome Glisse #else 431771fe6b9SJerome Glisse return 0; 432771fe6b9SJerome Glisse #endif 433771fe6b9SJerome Glisse } 434