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/console.h> 29771fe6b9SJerome Glisse #include <drm/drmP.h> 30771fe6b9SJerome Glisse #include <drm/drm_crtc_helper.h> 31771fe6b9SJerome Glisse #include <drm/radeon_drm.h> 32771fe6b9SJerome Glisse #include "radeon_reg.h" 33771fe6b9SJerome Glisse #include "radeon.h" 34771fe6b9SJerome Glisse #include "radeon_asic.h" 35771fe6b9SJerome Glisse #include "atom.h" 36771fe6b9SJerome Glisse 37771fe6b9SJerome Glisse /* 38b1e3a6d1SMichel Dänzer * Clear GPU surface registers. 39b1e3a6d1SMichel Dänzer */ 403ce0a23dSJerome Glisse void radeon_surface_init(struct radeon_device *rdev) 41b1e3a6d1SMichel Dänzer { 42b1e3a6d1SMichel Dänzer /* FIXME: check this out */ 43b1e3a6d1SMichel Dänzer if (rdev->family < CHIP_R600) { 44b1e3a6d1SMichel Dänzer int i; 45b1e3a6d1SMichel Dänzer 46b1e3a6d1SMichel Dänzer for (i = 0; i < 8; i++) { 47b1e3a6d1SMichel Dänzer WREG32(RADEON_SURFACE0_INFO + 48b1e3a6d1SMichel Dänzer i * (RADEON_SURFACE1_INFO - RADEON_SURFACE0_INFO), 49b1e3a6d1SMichel Dänzer 0); 50b1e3a6d1SMichel Dänzer } 51e024e110SDave Airlie /* enable surfaces */ 52e024e110SDave Airlie WREG32(RADEON_SURFACE_CNTL, 0); 53b1e3a6d1SMichel Dänzer } 54b1e3a6d1SMichel Dänzer } 55b1e3a6d1SMichel Dänzer 56b1e3a6d1SMichel Dänzer /* 57771fe6b9SJerome Glisse * GPU scratch registers helpers function. 58771fe6b9SJerome Glisse */ 593ce0a23dSJerome Glisse void radeon_scratch_init(struct radeon_device *rdev) 60771fe6b9SJerome Glisse { 61771fe6b9SJerome Glisse int i; 62771fe6b9SJerome Glisse 63771fe6b9SJerome Glisse /* FIXME: check this out */ 64771fe6b9SJerome Glisse if (rdev->family < CHIP_R300) { 65771fe6b9SJerome Glisse rdev->scratch.num_reg = 5; 66771fe6b9SJerome Glisse } else { 67771fe6b9SJerome Glisse rdev->scratch.num_reg = 7; 68771fe6b9SJerome Glisse } 69771fe6b9SJerome Glisse for (i = 0; i < rdev->scratch.num_reg; i++) { 70771fe6b9SJerome Glisse rdev->scratch.free[i] = true; 71771fe6b9SJerome Glisse rdev->scratch.reg[i] = RADEON_SCRATCH_REG0 + (i * 4); 72771fe6b9SJerome Glisse } 73771fe6b9SJerome Glisse } 74771fe6b9SJerome Glisse 75771fe6b9SJerome Glisse int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg) 76771fe6b9SJerome Glisse { 77771fe6b9SJerome Glisse int i; 78771fe6b9SJerome Glisse 79771fe6b9SJerome Glisse for (i = 0; i < rdev->scratch.num_reg; i++) { 80771fe6b9SJerome Glisse if (rdev->scratch.free[i]) { 81771fe6b9SJerome Glisse rdev->scratch.free[i] = false; 82771fe6b9SJerome Glisse *reg = rdev->scratch.reg[i]; 83771fe6b9SJerome Glisse return 0; 84771fe6b9SJerome Glisse } 85771fe6b9SJerome Glisse } 86771fe6b9SJerome Glisse return -EINVAL; 87771fe6b9SJerome Glisse } 88771fe6b9SJerome Glisse 89771fe6b9SJerome Glisse void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg) 90771fe6b9SJerome Glisse { 91771fe6b9SJerome Glisse int i; 92771fe6b9SJerome Glisse 93771fe6b9SJerome Glisse for (i = 0; i < rdev->scratch.num_reg; i++) { 94771fe6b9SJerome Glisse if (rdev->scratch.reg[i] == reg) { 95771fe6b9SJerome Glisse rdev->scratch.free[i] = true; 96771fe6b9SJerome Glisse return; 97771fe6b9SJerome Glisse } 98771fe6b9SJerome Glisse } 99771fe6b9SJerome Glisse } 100771fe6b9SJerome Glisse 101771fe6b9SJerome Glisse /* 102771fe6b9SJerome Glisse * MC common functions 103771fe6b9SJerome Glisse */ 104771fe6b9SJerome Glisse int radeon_mc_setup(struct radeon_device *rdev) 105771fe6b9SJerome Glisse { 106771fe6b9SJerome Glisse uint32_t tmp; 107771fe6b9SJerome Glisse 108771fe6b9SJerome Glisse /* Some chips have an "issue" with the memory controller, the 109771fe6b9SJerome Glisse * location must be aligned to the size. We just align it down, 110771fe6b9SJerome Glisse * too bad if we walk over the top of system memory, we don't 111771fe6b9SJerome Glisse * use DMA without a remapped anyway. 112771fe6b9SJerome Glisse * Affected chips are rv280, all r3xx, and all r4xx, but not IGP 113771fe6b9SJerome Glisse */ 114771fe6b9SJerome Glisse /* FGLRX seems to setup like this, VRAM a 0, then GART. 115771fe6b9SJerome Glisse */ 116771fe6b9SJerome Glisse /* 117771fe6b9SJerome Glisse * Note: from R6xx the address space is 40bits but here we only 118771fe6b9SJerome Glisse * use 32bits (still have to see a card which would exhaust 4G 119771fe6b9SJerome Glisse * address space). 120771fe6b9SJerome Glisse */ 121771fe6b9SJerome Glisse if (rdev->mc.vram_location != 0xFFFFFFFFUL) { 122771fe6b9SJerome Glisse /* vram location was already setup try to put gtt after 123771fe6b9SJerome Glisse * if it fits */ 1247a50f01aSDave Airlie tmp = rdev->mc.vram_location + rdev->mc.mc_vram_size; 125771fe6b9SJerome Glisse tmp = (tmp + rdev->mc.gtt_size - 1) & ~(rdev->mc.gtt_size - 1); 126771fe6b9SJerome Glisse if ((0xFFFFFFFFUL - tmp) >= rdev->mc.gtt_size) { 127771fe6b9SJerome Glisse rdev->mc.gtt_location = tmp; 128771fe6b9SJerome Glisse } else { 129771fe6b9SJerome Glisse if (rdev->mc.gtt_size >= rdev->mc.vram_location) { 130771fe6b9SJerome Glisse printk(KERN_ERR "[drm] GTT too big to fit " 131771fe6b9SJerome Glisse "before or after vram location.\n"); 132771fe6b9SJerome Glisse return -EINVAL; 133771fe6b9SJerome Glisse } 134771fe6b9SJerome Glisse rdev->mc.gtt_location = 0; 135771fe6b9SJerome Glisse } 136771fe6b9SJerome Glisse } else if (rdev->mc.gtt_location != 0xFFFFFFFFUL) { 137771fe6b9SJerome Glisse /* gtt location was already setup try to put vram before 138771fe6b9SJerome Glisse * if it fits */ 1397a50f01aSDave Airlie if (rdev->mc.mc_vram_size < rdev->mc.gtt_location) { 140771fe6b9SJerome Glisse rdev->mc.vram_location = 0; 141771fe6b9SJerome Glisse } else { 142771fe6b9SJerome Glisse tmp = rdev->mc.gtt_location + rdev->mc.gtt_size; 1437a50f01aSDave Airlie tmp += (rdev->mc.mc_vram_size - 1); 1447a50f01aSDave Airlie tmp &= ~(rdev->mc.mc_vram_size - 1); 1457a50f01aSDave Airlie if ((0xFFFFFFFFUL - tmp) >= rdev->mc.mc_vram_size) { 146771fe6b9SJerome Glisse rdev->mc.vram_location = tmp; 147771fe6b9SJerome Glisse } else { 148771fe6b9SJerome Glisse printk(KERN_ERR "[drm] vram too big to fit " 149771fe6b9SJerome Glisse "before or after GTT location.\n"); 150771fe6b9SJerome Glisse return -EINVAL; 151771fe6b9SJerome Glisse } 152771fe6b9SJerome Glisse } 153771fe6b9SJerome Glisse } else { 154771fe6b9SJerome Glisse rdev->mc.vram_location = 0; 15517332925SDave Airlie tmp = rdev->mc.mc_vram_size; 15617332925SDave Airlie tmp = (tmp + rdev->mc.gtt_size - 1) & ~(rdev->mc.gtt_size - 1); 15717332925SDave Airlie rdev->mc.gtt_location = tmp; 158771fe6b9SJerome Glisse } 1599f022ddfSJerome Glisse rdev->mc.vram_start = rdev->mc.vram_location; 1609f022ddfSJerome Glisse rdev->mc.vram_end = rdev->mc.vram_location + rdev->mc.mc_vram_size - 1; 1619f022ddfSJerome Glisse rdev->mc.gtt_start = rdev->mc.gtt_location; 1629f022ddfSJerome Glisse rdev->mc.gtt_end = rdev->mc.gtt_location + rdev->mc.gtt_size - 1; 1633ce0a23dSJerome Glisse DRM_INFO("radeon: VRAM %uM\n", (unsigned)(rdev->mc.mc_vram_size >> 20)); 164771fe6b9SJerome Glisse DRM_INFO("radeon: VRAM from 0x%08X to 0x%08X\n", 1653ce0a23dSJerome Glisse (unsigned)rdev->mc.vram_location, 1663ce0a23dSJerome Glisse (unsigned)(rdev->mc.vram_location + rdev->mc.mc_vram_size - 1)); 1673ce0a23dSJerome Glisse DRM_INFO("radeon: GTT %uM\n", (unsigned)(rdev->mc.gtt_size >> 20)); 168771fe6b9SJerome Glisse DRM_INFO("radeon: GTT from 0x%08X to 0x%08X\n", 1693ce0a23dSJerome Glisse (unsigned)rdev->mc.gtt_location, 1703ce0a23dSJerome Glisse (unsigned)(rdev->mc.gtt_location + rdev->mc.gtt_size - 1)); 171771fe6b9SJerome Glisse return 0; 172771fe6b9SJerome Glisse } 173771fe6b9SJerome Glisse 174771fe6b9SJerome Glisse 175771fe6b9SJerome Glisse /* 176771fe6b9SJerome Glisse * GPU helpers function. 177771fe6b9SJerome Glisse */ 1789f022ddfSJerome Glisse bool radeon_card_posted(struct radeon_device *rdev) 179771fe6b9SJerome Glisse { 180771fe6b9SJerome Glisse uint32_t reg; 181771fe6b9SJerome Glisse 182771fe6b9SJerome Glisse /* first check CRTCs */ 183771fe6b9SJerome Glisse if (ASIC_IS_AVIVO(rdev)) { 184771fe6b9SJerome Glisse reg = RREG32(AVIVO_D1CRTC_CONTROL) | 185771fe6b9SJerome Glisse RREG32(AVIVO_D2CRTC_CONTROL); 186771fe6b9SJerome Glisse if (reg & AVIVO_CRTC_EN) { 187771fe6b9SJerome Glisse return true; 188771fe6b9SJerome Glisse } 189771fe6b9SJerome Glisse } else { 190771fe6b9SJerome Glisse reg = RREG32(RADEON_CRTC_GEN_CNTL) | 191771fe6b9SJerome Glisse RREG32(RADEON_CRTC2_GEN_CNTL); 192771fe6b9SJerome Glisse if (reg & RADEON_CRTC_EN) { 193771fe6b9SJerome Glisse return true; 194771fe6b9SJerome Glisse } 195771fe6b9SJerome Glisse } 196771fe6b9SJerome Glisse 197771fe6b9SJerome Glisse /* then check MEM_SIZE, in case the crtcs are off */ 198771fe6b9SJerome Glisse if (rdev->family >= CHIP_R600) 199771fe6b9SJerome Glisse reg = RREG32(R600_CONFIG_MEMSIZE); 200771fe6b9SJerome Glisse else 201771fe6b9SJerome Glisse reg = RREG32(RADEON_CONFIG_MEMSIZE); 202771fe6b9SJerome Glisse 203771fe6b9SJerome Glisse if (reg) 204771fe6b9SJerome Glisse return true; 205771fe6b9SJerome Glisse 206771fe6b9SJerome Glisse return false; 207771fe6b9SJerome Glisse 208771fe6b9SJerome Glisse } 209771fe6b9SJerome Glisse 2103ce0a23dSJerome Glisse int radeon_dummy_page_init(struct radeon_device *rdev) 2113ce0a23dSJerome Glisse { 2123ce0a23dSJerome Glisse rdev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO); 2133ce0a23dSJerome Glisse if (rdev->dummy_page.page == NULL) 2143ce0a23dSJerome Glisse return -ENOMEM; 2153ce0a23dSJerome Glisse rdev->dummy_page.addr = pci_map_page(rdev->pdev, rdev->dummy_page.page, 2163ce0a23dSJerome Glisse 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 2173ce0a23dSJerome Glisse if (!rdev->dummy_page.addr) { 2183ce0a23dSJerome Glisse __free_page(rdev->dummy_page.page); 2193ce0a23dSJerome Glisse rdev->dummy_page.page = NULL; 2203ce0a23dSJerome Glisse return -ENOMEM; 2213ce0a23dSJerome Glisse } 2223ce0a23dSJerome Glisse return 0; 2233ce0a23dSJerome Glisse } 2243ce0a23dSJerome Glisse 2253ce0a23dSJerome Glisse void radeon_dummy_page_fini(struct radeon_device *rdev) 2263ce0a23dSJerome Glisse { 2273ce0a23dSJerome Glisse if (rdev->dummy_page.page == NULL) 2283ce0a23dSJerome Glisse return; 2293ce0a23dSJerome Glisse pci_unmap_page(rdev->pdev, rdev->dummy_page.addr, 2303ce0a23dSJerome Glisse PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 2313ce0a23dSJerome Glisse __free_page(rdev->dummy_page.page); 2323ce0a23dSJerome Glisse rdev->dummy_page.page = NULL; 2333ce0a23dSJerome Glisse } 2343ce0a23dSJerome Glisse 235771fe6b9SJerome Glisse 236771fe6b9SJerome Glisse /* 237771fe6b9SJerome Glisse * Registers accessors functions. 238771fe6b9SJerome Glisse */ 239771fe6b9SJerome Glisse uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg) 240771fe6b9SJerome Glisse { 241771fe6b9SJerome Glisse DRM_ERROR("Invalid callback to read register 0x%04X\n", reg); 242771fe6b9SJerome Glisse BUG_ON(1); 243771fe6b9SJerome Glisse return 0; 244771fe6b9SJerome Glisse } 245771fe6b9SJerome Glisse 246771fe6b9SJerome Glisse void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) 247771fe6b9SJerome Glisse { 248771fe6b9SJerome Glisse DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n", 249771fe6b9SJerome Glisse reg, v); 250771fe6b9SJerome Glisse BUG_ON(1); 251771fe6b9SJerome Glisse } 252771fe6b9SJerome Glisse 253771fe6b9SJerome Glisse void radeon_register_accessor_init(struct radeon_device *rdev) 254771fe6b9SJerome Glisse { 255771fe6b9SJerome Glisse rdev->mc_rreg = &radeon_invalid_rreg; 256771fe6b9SJerome Glisse rdev->mc_wreg = &radeon_invalid_wreg; 257771fe6b9SJerome Glisse rdev->pll_rreg = &radeon_invalid_rreg; 258771fe6b9SJerome Glisse rdev->pll_wreg = &radeon_invalid_wreg; 259771fe6b9SJerome Glisse rdev->pciep_rreg = &radeon_invalid_rreg; 260771fe6b9SJerome Glisse rdev->pciep_wreg = &radeon_invalid_wreg; 261771fe6b9SJerome Glisse 262771fe6b9SJerome Glisse /* Don't change order as we are overridding accessor. */ 263771fe6b9SJerome Glisse if (rdev->family < CHIP_RV515) { 264de1b2898SDave Airlie rdev->pcie_reg_mask = 0xff; 265de1b2898SDave Airlie } else { 266de1b2898SDave Airlie rdev->pcie_reg_mask = 0x7ff; 267771fe6b9SJerome Glisse } 268771fe6b9SJerome Glisse /* FIXME: not sure here */ 269771fe6b9SJerome Glisse if (rdev->family <= CHIP_R580) { 270771fe6b9SJerome Glisse rdev->pll_rreg = &r100_pll_rreg; 271771fe6b9SJerome Glisse rdev->pll_wreg = &r100_pll_wreg; 272771fe6b9SJerome Glisse } 273905b6822SJerome Glisse if (rdev->family >= CHIP_R420) { 274905b6822SJerome Glisse rdev->mc_rreg = &r420_mc_rreg; 275905b6822SJerome Glisse rdev->mc_wreg = &r420_mc_wreg; 276905b6822SJerome Glisse } 277771fe6b9SJerome Glisse if (rdev->family >= CHIP_RV515) { 278771fe6b9SJerome Glisse rdev->mc_rreg = &rv515_mc_rreg; 279771fe6b9SJerome Glisse rdev->mc_wreg = &rv515_mc_wreg; 280771fe6b9SJerome Glisse } 281771fe6b9SJerome Glisse if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) { 282771fe6b9SJerome Glisse rdev->mc_rreg = &rs400_mc_rreg; 283771fe6b9SJerome Glisse rdev->mc_wreg = &rs400_mc_wreg; 284771fe6b9SJerome Glisse } 285771fe6b9SJerome Glisse if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) { 286771fe6b9SJerome Glisse rdev->mc_rreg = &rs690_mc_rreg; 287771fe6b9SJerome Glisse rdev->mc_wreg = &rs690_mc_wreg; 288771fe6b9SJerome Glisse } 289771fe6b9SJerome Glisse if (rdev->family == CHIP_RS600) { 290771fe6b9SJerome Glisse rdev->mc_rreg = &rs600_mc_rreg; 291771fe6b9SJerome Glisse rdev->mc_wreg = &rs600_mc_wreg; 292771fe6b9SJerome Glisse } 293771fe6b9SJerome Glisse if (rdev->family >= CHIP_R600) { 294771fe6b9SJerome Glisse rdev->pciep_rreg = &r600_pciep_rreg; 295771fe6b9SJerome Glisse rdev->pciep_wreg = &r600_pciep_wreg; 296771fe6b9SJerome Glisse } 297771fe6b9SJerome Glisse } 298771fe6b9SJerome Glisse 299771fe6b9SJerome Glisse 300771fe6b9SJerome Glisse /* 301771fe6b9SJerome Glisse * ASIC 302771fe6b9SJerome Glisse */ 303771fe6b9SJerome Glisse int radeon_asic_init(struct radeon_device *rdev) 304771fe6b9SJerome Glisse { 305771fe6b9SJerome Glisse radeon_register_accessor_init(rdev); 306771fe6b9SJerome Glisse switch (rdev->family) { 307771fe6b9SJerome Glisse case CHIP_R100: 308771fe6b9SJerome Glisse case CHIP_RV100: 309771fe6b9SJerome Glisse case CHIP_RS100: 310771fe6b9SJerome Glisse case CHIP_RV200: 311771fe6b9SJerome Glisse case CHIP_RS200: 312771fe6b9SJerome Glisse case CHIP_R200: 313771fe6b9SJerome Glisse case CHIP_RV250: 314771fe6b9SJerome Glisse case CHIP_RS300: 315771fe6b9SJerome Glisse case CHIP_RV280: 316771fe6b9SJerome Glisse rdev->asic = &r100_asic; 317771fe6b9SJerome Glisse break; 318771fe6b9SJerome Glisse case CHIP_R300: 319771fe6b9SJerome Glisse case CHIP_R350: 320771fe6b9SJerome Glisse case CHIP_RV350: 321771fe6b9SJerome Glisse case CHIP_RV380: 322771fe6b9SJerome Glisse rdev->asic = &r300_asic; 3234aac0473SJerome Glisse if (rdev->flags & RADEON_IS_PCIE) { 3244aac0473SJerome Glisse rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush; 3254aac0473SJerome Glisse rdev->asic->gart_set_page = &rv370_pcie_gart_set_page; 3264aac0473SJerome Glisse } 327771fe6b9SJerome Glisse break; 328771fe6b9SJerome Glisse case CHIP_R420: 329771fe6b9SJerome Glisse case CHIP_R423: 330771fe6b9SJerome Glisse case CHIP_RV410: 331771fe6b9SJerome Glisse rdev->asic = &r420_asic; 332771fe6b9SJerome Glisse break; 333771fe6b9SJerome Glisse case CHIP_RS400: 334771fe6b9SJerome Glisse case CHIP_RS480: 335771fe6b9SJerome Glisse rdev->asic = &rs400_asic; 336771fe6b9SJerome Glisse break; 337771fe6b9SJerome Glisse case CHIP_RS600: 338771fe6b9SJerome Glisse rdev->asic = &rs600_asic; 339771fe6b9SJerome Glisse break; 340771fe6b9SJerome Glisse case CHIP_RS690: 341771fe6b9SJerome Glisse case CHIP_RS740: 342771fe6b9SJerome Glisse rdev->asic = &rs690_asic; 343771fe6b9SJerome Glisse break; 344771fe6b9SJerome Glisse case CHIP_RV515: 345771fe6b9SJerome Glisse rdev->asic = &rv515_asic; 346771fe6b9SJerome Glisse break; 347771fe6b9SJerome Glisse case CHIP_R520: 348771fe6b9SJerome Glisse case CHIP_RV530: 349771fe6b9SJerome Glisse case CHIP_RV560: 350771fe6b9SJerome Glisse case CHIP_RV570: 351771fe6b9SJerome Glisse case CHIP_R580: 352771fe6b9SJerome Glisse rdev->asic = &r520_asic; 353771fe6b9SJerome Glisse break; 354771fe6b9SJerome Glisse case CHIP_R600: 355771fe6b9SJerome Glisse case CHIP_RV610: 356771fe6b9SJerome Glisse case CHIP_RV630: 357771fe6b9SJerome Glisse case CHIP_RV620: 358771fe6b9SJerome Glisse case CHIP_RV635: 359771fe6b9SJerome Glisse case CHIP_RV670: 360771fe6b9SJerome Glisse case CHIP_RS780: 3613ce0a23dSJerome Glisse case CHIP_RS880: 3623ce0a23dSJerome Glisse rdev->asic = &r600_asic; 3633ce0a23dSJerome Glisse break; 364771fe6b9SJerome Glisse case CHIP_RV770: 365771fe6b9SJerome Glisse case CHIP_RV730: 366771fe6b9SJerome Glisse case CHIP_RV710: 3673ce0a23dSJerome Glisse case CHIP_RV740: 3683ce0a23dSJerome Glisse rdev->asic = &rv770_asic; 3693ce0a23dSJerome Glisse break; 370771fe6b9SJerome Glisse default: 371771fe6b9SJerome Glisse /* FIXME: not supported yet */ 372771fe6b9SJerome Glisse return -EINVAL; 373771fe6b9SJerome Glisse } 374771fe6b9SJerome Glisse return 0; 375771fe6b9SJerome Glisse } 376771fe6b9SJerome Glisse 377771fe6b9SJerome Glisse 378771fe6b9SJerome Glisse /* 379771fe6b9SJerome Glisse * Wrapper around modesetting bits. 380771fe6b9SJerome Glisse */ 381771fe6b9SJerome Glisse int radeon_clocks_init(struct radeon_device *rdev) 382771fe6b9SJerome Glisse { 383771fe6b9SJerome Glisse int r; 384771fe6b9SJerome Glisse 385771fe6b9SJerome Glisse r = radeon_static_clocks_init(rdev->ddev); 386771fe6b9SJerome Glisse if (r) { 387771fe6b9SJerome Glisse return r; 388771fe6b9SJerome Glisse } 389771fe6b9SJerome Glisse DRM_INFO("Clocks initialized !\n"); 390771fe6b9SJerome Glisse return 0; 391771fe6b9SJerome Glisse } 392771fe6b9SJerome Glisse 393771fe6b9SJerome Glisse void radeon_clocks_fini(struct radeon_device *rdev) 394771fe6b9SJerome Glisse { 395771fe6b9SJerome Glisse } 396771fe6b9SJerome Glisse 397771fe6b9SJerome Glisse /* ATOM accessor methods */ 398771fe6b9SJerome Glisse static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) 399771fe6b9SJerome Glisse { 400771fe6b9SJerome Glisse struct radeon_device *rdev = info->dev->dev_private; 401771fe6b9SJerome Glisse uint32_t r; 402771fe6b9SJerome Glisse 403771fe6b9SJerome Glisse r = rdev->pll_rreg(rdev, reg); 404771fe6b9SJerome Glisse return r; 405771fe6b9SJerome Glisse } 406771fe6b9SJerome Glisse 407771fe6b9SJerome Glisse static void cail_pll_write(struct card_info *info, uint32_t reg, uint32_t val) 408771fe6b9SJerome Glisse { 409771fe6b9SJerome Glisse struct radeon_device *rdev = info->dev->dev_private; 410771fe6b9SJerome Glisse 411771fe6b9SJerome Glisse rdev->pll_wreg(rdev, reg, val); 412771fe6b9SJerome Glisse } 413771fe6b9SJerome Glisse 414771fe6b9SJerome Glisse static uint32_t cail_mc_read(struct card_info *info, uint32_t reg) 415771fe6b9SJerome Glisse { 416771fe6b9SJerome Glisse struct radeon_device *rdev = info->dev->dev_private; 417771fe6b9SJerome Glisse uint32_t r; 418771fe6b9SJerome Glisse 419771fe6b9SJerome Glisse r = rdev->mc_rreg(rdev, reg); 420771fe6b9SJerome Glisse return r; 421771fe6b9SJerome Glisse } 422771fe6b9SJerome Glisse 423771fe6b9SJerome Glisse static void cail_mc_write(struct card_info *info, uint32_t reg, uint32_t val) 424771fe6b9SJerome Glisse { 425771fe6b9SJerome Glisse struct radeon_device *rdev = info->dev->dev_private; 426771fe6b9SJerome Glisse 427771fe6b9SJerome Glisse rdev->mc_wreg(rdev, reg, val); 428771fe6b9SJerome Glisse } 429771fe6b9SJerome Glisse 430771fe6b9SJerome Glisse static void cail_reg_write(struct card_info *info, uint32_t reg, uint32_t val) 431771fe6b9SJerome Glisse { 432771fe6b9SJerome Glisse struct radeon_device *rdev = info->dev->dev_private; 433771fe6b9SJerome Glisse 434771fe6b9SJerome Glisse WREG32(reg*4, val); 435771fe6b9SJerome Glisse } 436771fe6b9SJerome Glisse 437771fe6b9SJerome Glisse static uint32_t cail_reg_read(struct card_info *info, uint32_t reg) 438771fe6b9SJerome Glisse { 439771fe6b9SJerome Glisse struct radeon_device *rdev = info->dev->dev_private; 440771fe6b9SJerome Glisse uint32_t r; 441771fe6b9SJerome Glisse 442771fe6b9SJerome Glisse r = RREG32(reg*4); 443771fe6b9SJerome Glisse return r; 444771fe6b9SJerome Glisse } 445771fe6b9SJerome Glisse 446771fe6b9SJerome Glisse int radeon_atombios_init(struct radeon_device *rdev) 447771fe6b9SJerome Glisse { 448*61c4b24bSMathias Fröhlich struct card_info *atom_card_info = 449*61c4b24bSMathias Fröhlich kzalloc(sizeof(struct card_info), GFP_KERNEL); 450*61c4b24bSMathias Fröhlich 451*61c4b24bSMathias Fröhlich if (!atom_card_info) 452*61c4b24bSMathias Fröhlich return -ENOMEM; 453*61c4b24bSMathias Fröhlich 454*61c4b24bSMathias Fröhlich rdev->mode_info.atom_card_info = atom_card_info; 455*61c4b24bSMathias Fröhlich atom_card_info->dev = rdev->ddev; 456*61c4b24bSMathias Fröhlich atom_card_info->reg_read = cail_reg_read; 457*61c4b24bSMathias Fröhlich atom_card_info->reg_write = cail_reg_write; 458*61c4b24bSMathias Fröhlich atom_card_info->mc_read = cail_mc_read; 459*61c4b24bSMathias Fröhlich atom_card_info->mc_write = cail_mc_write; 460*61c4b24bSMathias Fröhlich atom_card_info->pll_read = cail_pll_read; 461*61c4b24bSMathias Fröhlich atom_card_info->pll_write = cail_pll_write; 462*61c4b24bSMathias Fröhlich 463*61c4b24bSMathias Fröhlich rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios); 464771fe6b9SJerome Glisse radeon_atom_initialize_bios_scratch_regs(rdev->ddev); 465771fe6b9SJerome Glisse return 0; 466771fe6b9SJerome Glisse } 467771fe6b9SJerome Glisse 468771fe6b9SJerome Glisse void radeon_atombios_fini(struct radeon_device *rdev) 469771fe6b9SJerome Glisse { 470771fe6b9SJerome Glisse kfree(rdev->mode_info.atom_context); 471*61c4b24bSMathias Fröhlich kfree(rdev->mode_info.atom_card_info); 472771fe6b9SJerome Glisse } 473771fe6b9SJerome Glisse 474771fe6b9SJerome Glisse int radeon_combios_init(struct radeon_device *rdev) 475771fe6b9SJerome Glisse { 476771fe6b9SJerome Glisse radeon_combios_initialize_bios_scratch_regs(rdev->ddev); 477771fe6b9SJerome Glisse return 0; 478771fe6b9SJerome Glisse } 479771fe6b9SJerome Glisse 480771fe6b9SJerome Glisse void radeon_combios_fini(struct radeon_device *rdev) 481771fe6b9SJerome Glisse { 482771fe6b9SJerome Glisse } 483771fe6b9SJerome Glisse 484b574f251SJerome Glisse void radeon_agp_disable(struct radeon_device *rdev) 485b574f251SJerome Glisse { 486b574f251SJerome Glisse rdev->flags &= ~RADEON_IS_AGP; 487b574f251SJerome Glisse if (rdev->family >= CHIP_R600) { 488b574f251SJerome Glisse DRM_INFO("Forcing AGP to PCIE mode\n"); 489b574f251SJerome Glisse rdev->flags |= RADEON_IS_PCIE; 490b574f251SJerome Glisse } else if (rdev->family >= CHIP_RV515 || 491b574f251SJerome Glisse rdev->family == CHIP_RV380 || 492b574f251SJerome Glisse rdev->family == CHIP_RV410 || 493b574f251SJerome Glisse rdev->family == CHIP_R423) { 494b574f251SJerome Glisse DRM_INFO("Forcing AGP to PCIE mode\n"); 495b574f251SJerome Glisse rdev->flags |= RADEON_IS_PCIE; 496b574f251SJerome Glisse rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush; 497b574f251SJerome Glisse rdev->asic->gart_set_page = &rv370_pcie_gart_set_page; 498b574f251SJerome Glisse } else { 499b574f251SJerome Glisse DRM_INFO("Forcing AGP to PCI mode\n"); 500b574f251SJerome Glisse rdev->flags |= RADEON_IS_PCI; 501b574f251SJerome Glisse rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush; 502b574f251SJerome Glisse rdev->asic->gart_set_page = &r100_pci_gart_set_page; 503b574f251SJerome Glisse } 504b574f251SJerome Glisse } 505771fe6b9SJerome Glisse 506771fe6b9SJerome Glisse /* 507771fe6b9SJerome Glisse * Radeon device. 508771fe6b9SJerome Glisse */ 509771fe6b9SJerome Glisse int radeon_device_init(struct radeon_device *rdev, 510771fe6b9SJerome Glisse struct drm_device *ddev, 511771fe6b9SJerome Glisse struct pci_dev *pdev, 512771fe6b9SJerome Glisse uint32_t flags) 513771fe6b9SJerome Glisse { 5146cf8a3f5SJerome Glisse int r; 515ad49f501SDave Airlie int dma_bits; 516771fe6b9SJerome Glisse 517771fe6b9SJerome Glisse DRM_INFO("radeon: Initializing kernel modesetting.\n"); 518771fe6b9SJerome Glisse rdev->shutdown = false; 5199f022ddfSJerome Glisse rdev->dev = &pdev->dev; 520771fe6b9SJerome Glisse rdev->ddev = ddev; 521771fe6b9SJerome Glisse rdev->pdev = pdev; 522771fe6b9SJerome Glisse rdev->flags = flags; 523771fe6b9SJerome Glisse rdev->family = flags & RADEON_FAMILY_MASK; 524771fe6b9SJerome Glisse rdev->is_atom_bios = false; 525771fe6b9SJerome Glisse rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT; 526771fe6b9SJerome Glisse rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; 527771fe6b9SJerome Glisse rdev->gpu_lockup = false; 528733289c2SJerome Glisse rdev->accel_working = false; 529771fe6b9SJerome Glisse /* mutex initialization are all done here so we 530771fe6b9SJerome Glisse * can recall function without having locking issues */ 531771fe6b9SJerome Glisse mutex_init(&rdev->cs_mutex); 532771fe6b9SJerome Glisse mutex_init(&rdev->ib_pool.mutex); 533771fe6b9SJerome Glisse mutex_init(&rdev->cp.mutex); 534771fe6b9SJerome Glisse rwlock_init(&rdev->fence_drv.lock); 5359f022ddfSJerome Glisse INIT_LIST_HEAD(&rdev->gem.objects); 536771fe6b9SJerome Glisse 5374aac0473SJerome Glisse /* Set asic functions */ 5384aac0473SJerome Glisse r = radeon_asic_init(rdev); 5394aac0473SJerome Glisse if (r) { 5404aac0473SJerome Glisse return r; 5414aac0473SJerome Glisse } 5424aac0473SJerome Glisse 543771fe6b9SJerome Glisse if (radeon_agpmode == -1) { 544b574f251SJerome Glisse radeon_agp_disable(rdev); 545771fe6b9SJerome Glisse } 546771fe6b9SJerome Glisse 547ad49f501SDave Airlie /* set DMA mask + need_dma32 flags. 548ad49f501SDave Airlie * PCIE - can handle 40-bits. 549ad49f501SDave Airlie * IGP - can handle 40-bits (in theory) 550ad49f501SDave Airlie * AGP - generally dma32 is safest 551ad49f501SDave Airlie * PCI - only dma32 552ad49f501SDave Airlie */ 553ad49f501SDave Airlie rdev->need_dma32 = false; 554ad49f501SDave Airlie if (rdev->flags & RADEON_IS_AGP) 555ad49f501SDave Airlie rdev->need_dma32 = true; 556ad49f501SDave Airlie if (rdev->flags & RADEON_IS_PCI) 557ad49f501SDave Airlie rdev->need_dma32 = true; 558ad49f501SDave Airlie 559ad49f501SDave Airlie dma_bits = rdev->need_dma32 ? 32 : 40; 560ad49f501SDave Airlie r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits)); 561771fe6b9SJerome Glisse if (r) { 562771fe6b9SJerome Glisse printk(KERN_WARNING "radeon: No suitable DMA available.\n"); 563771fe6b9SJerome Glisse } 564771fe6b9SJerome Glisse 565771fe6b9SJerome Glisse /* Registers mapping */ 566771fe6b9SJerome Glisse /* TODO: block userspace mapping of io register */ 567771fe6b9SJerome Glisse rdev->rmmio_base = drm_get_resource_start(rdev->ddev, 2); 568771fe6b9SJerome Glisse rdev->rmmio_size = drm_get_resource_len(rdev->ddev, 2); 569771fe6b9SJerome Glisse rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size); 570771fe6b9SJerome Glisse if (rdev->rmmio == NULL) { 571771fe6b9SJerome Glisse return -ENOMEM; 572771fe6b9SJerome Glisse } 573771fe6b9SJerome Glisse DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)rdev->rmmio_base); 574771fe6b9SJerome Glisse DRM_INFO("register mmio size: %u\n", (unsigned)rdev->rmmio_size); 575771fe6b9SJerome Glisse 5763ce0a23dSJerome Glisse r = radeon_init(rdev); 577b574f251SJerome Glisse if (r) 578b574f251SJerome Glisse return r; 579b574f251SJerome Glisse if (rdev->flags & RADEON_IS_AGP && !rdev->accel_working) { 580b574f251SJerome Glisse /* Acceleration not working on AGP card try again 581b574f251SJerome Glisse * with fallback to PCI or PCIE GART 582b574f251SJerome Glisse */ 5831a029b76SJerome Glisse radeon_gpu_reset(rdev); 584b574f251SJerome Glisse radeon_fini(rdev); 585b574f251SJerome Glisse radeon_agp_disable(rdev); 586b574f251SJerome Glisse r = radeon_init(rdev); 587b574f251SJerome Glisse if (r) 5883ce0a23dSJerome Glisse return r; 5893ce0a23dSJerome Glisse } 590ecc0b326SMichel Dänzer if (radeon_testing) { 591ecc0b326SMichel Dänzer radeon_test_moves(rdev); 592ecc0b326SMichel Dänzer } 593771fe6b9SJerome Glisse if (radeon_benchmarking) { 594771fe6b9SJerome Glisse radeon_benchmark(rdev); 595771fe6b9SJerome Glisse } 5966cf8a3f5SJerome Glisse return 0; 597771fe6b9SJerome Glisse } 598771fe6b9SJerome Glisse 599771fe6b9SJerome Glisse void radeon_device_fini(struct radeon_device *rdev) 600771fe6b9SJerome Glisse { 601771fe6b9SJerome Glisse DRM_INFO("radeon: finishing device.\n"); 602771fe6b9SJerome Glisse rdev->shutdown = true; 603771fe6b9SJerome Glisse /* Order matter so becarefull if you rearrange anythings */ 6043ce0a23dSJerome Glisse radeon_fini(rdev); 605771fe6b9SJerome Glisse iounmap(rdev->rmmio); 606771fe6b9SJerome Glisse rdev->rmmio = NULL; 607771fe6b9SJerome Glisse } 608771fe6b9SJerome Glisse 609771fe6b9SJerome Glisse 610771fe6b9SJerome Glisse /* 611771fe6b9SJerome Glisse * Suspend & resume. 612771fe6b9SJerome Glisse */ 613771fe6b9SJerome Glisse int radeon_suspend_kms(struct drm_device *dev, pm_message_t state) 614771fe6b9SJerome Glisse { 615771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 616771fe6b9SJerome Glisse struct drm_crtc *crtc; 617771fe6b9SJerome Glisse 618771fe6b9SJerome Glisse if (dev == NULL || rdev == NULL) { 619771fe6b9SJerome Glisse return -ENODEV; 620771fe6b9SJerome Glisse } 621771fe6b9SJerome Glisse if (state.event == PM_EVENT_PRETHAW) { 622771fe6b9SJerome Glisse return 0; 623771fe6b9SJerome Glisse } 624771fe6b9SJerome Glisse /* unpin the front buffers */ 625771fe6b9SJerome Glisse list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 626771fe6b9SJerome Glisse struct radeon_framebuffer *rfb = to_radeon_framebuffer(crtc->fb); 627771fe6b9SJerome Glisse struct radeon_object *robj; 628771fe6b9SJerome Glisse 629771fe6b9SJerome Glisse if (rfb == NULL || rfb->obj == NULL) { 630771fe6b9SJerome Glisse continue; 631771fe6b9SJerome Glisse } 632771fe6b9SJerome Glisse robj = rfb->obj->driver_private; 633771fe6b9SJerome Glisse if (robj != rdev->fbdev_robj) { 634771fe6b9SJerome Glisse radeon_object_unpin(robj); 635771fe6b9SJerome Glisse } 636771fe6b9SJerome Glisse } 637771fe6b9SJerome Glisse /* evict vram memory */ 638771fe6b9SJerome Glisse radeon_object_evict_vram(rdev); 639771fe6b9SJerome Glisse /* wait for gpu to finish processing current batch */ 640771fe6b9SJerome Glisse radeon_fence_wait_last(rdev); 641771fe6b9SJerome Glisse 642f657c2a7SYang Zhao radeon_save_bios_scratch_regs(rdev); 643f657c2a7SYang Zhao 6443ce0a23dSJerome Glisse radeon_suspend(rdev); 645771fe6b9SJerome Glisse /* evict remaining vram memory */ 646771fe6b9SJerome Glisse radeon_object_evict_vram(rdev); 647771fe6b9SJerome Glisse 648771fe6b9SJerome Glisse pci_save_state(dev->pdev); 649771fe6b9SJerome Glisse if (state.event == PM_EVENT_SUSPEND) { 650771fe6b9SJerome Glisse /* Shut down the device */ 651771fe6b9SJerome Glisse pci_disable_device(dev->pdev); 652771fe6b9SJerome Glisse pci_set_power_state(dev->pdev, PCI_D3hot); 653771fe6b9SJerome Glisse } 654771fe6b9SJerome Glisse acquire_console_sem(); 655771fe6b9SJerome Glisse fb_set_suspend(rdev->fbdev_info, 1); 656771fe6b9SJerome Glisse release_console_sem(); 657771fe6b9SJerome Glisse return 0; 658771fe6b9SJerome Glisse } 659771fe6b9SJerome Glisse 660771fe6b9SJerome Glisse int radeon_resume_kms(struct drm_device *dev) 661771fe6b9SJerome Glisse { 662771fe6b9SJerome Glisse struct radeon_device *rdev = dev->dev_private; 663771fe6b9SJerome Glisse 664771fe6b9SJerome Glisse acquire_console_sem(); 665771fe6b9SJerome Glisse pci_set_power_state(dev->pdev, PCI_D0); 666771fe6b9SJerome Glisse pci_restore_state(dev->pdev); 667771fe6b9SJerome Glisse if (pci_enable_device(dev->pdev)) { 668771fe6b9SJerome Glisse release_console_sem(); 669771fe6b9SJerome Glisse return -1; 670771fe6b9SJerome Glisse } 671771fe6b9SJerome Glisse pci_set_master(dev->pdev); 6723ce0a23dSJerome Glisse radeon_resume(rdev); 673f657c2a7SYang Zhao radeon_restore_bios_scratch_regs(rdev); 674771fe6b9SJerome Glisse fb_set_suspend(rdev->fbdev_info, 0); 675771fe6b9SJerome Glisse release_console_sem(); 676771fe6b9SJerome Glisse 677771fe6b9SJerome Glisse /* blat the mode back in */ 678771fe6b9SJerome Glisse drm_helper_resume_force_mode(dev); 679771fe6b9SJerome Glisse return 0; 680771fe6b9SJerome Glisse } 681771fe6b9SJerome Glisse 682771fe6b9SJerome Glisse 683771fe6b9SJerome Glisse /* 684771fe6b9SJerome Glisse * Debugfs 685771fe6b9SJerome Glisse */ 686771fe6b9SJerome Glisse struct radeon_debugfs { 687771fe6b9SJerome Glisse struct drm_info_list *files; 688771fe6b9SJerome Glisse unsigned num_files; 689771fe6b9SJerome Glisse }; 690771fe6b9SJerome Glisse static struct radeon_debugfs _radeon_debugfs[RADEON_DEBUGFS_MAX_NUM_FILES]; 691771fe6b9SJerome Glisse static unsigned _radeon_debugfs_count = 0; 692771fe6b9SJerome Glisse 693771fe6b9SJerome Glisse int radeon_debugfs_add_files(struct radeon_device *rdev, 694771fe6b9SJerome Glisse struct drm_info_list *files, 695771fe6b9SJerome Glisse unsigned nfiles) 696771fe6b9SJerome Glisse { 697771fe6b9SJerome Glisse unsigned i; 698771fe6b9SJerome Glisse 699771fe6b9SJerome Glisse for (i = 0; i < _radeon_debugfs_count; i++) { 700771fe6b9SJerome Glisse if (_radeon_debugfs[i].files == files) { 701771fe6b9SJerome Glisse /* Already registered */ 702771fe6b9SJerome Glisse return 0; 703771fe6b9SJerome Glisse } 704771fe6b9SJerome Glisse } 705771fe6b9SJerome Glisse if ((_radeon_debugfs_count + nfiles) > RADEON_DEBUGFS_MAX_NUM_FILES) { 706771fe6b9SJerome Glisse DRM_ERROR("Reached maximum number of debugfs files.\n"); 707771fe6b9SJerome Glisse DRM_ERROR("Report so we increase RADEON_DEBUGFS_MAX_NUM_FILES.\n"); 708771fe6b9SJerome Glisse return -EINVAL; 709771fe6b9SJerome Glisse } 710771fe6b9SJerome Glisse _radeon_debugfs[_radeon_debugfs_count].files = files; 711771fe6b9SJerome Glisse _radeon_debugfs[_radeon_debugfs_count].num_files = nfiles; 712771fe6b9SJerome Glisse _radeon_debugfs_count++; 713771fe6b9SJerome Glisse #if defined(CONFIG_DEBUG_FS) 714771fe6b9SJerome Glisse drm_debugfs_create_files(files, nfiles, 715771fe6b9SJerome Glisse rdev->ddev->control->debugfs_root, 716771fe6b9SJerome Glisse rdev->ddev->control); 717771fe6b9SJerome Glisse drm_debugfs_create_files(files, nfiles, 718771fe6b9SJerome Glisse rdev->ddev->primary->debugfs_root, 719771fe6b9SJerome Glisse rdev->ddev->primary); 720771fe6b9SJerome Glisse #endif 721771fe6b9SJerome Glisse return 0; 722771fe6b9SJerome Glisse } 723771fe6b9SJerome Glisse 724771fe6b9SJerome Glisse #if defined(CONFIG_DEBUG_FS) 725771fe6b9SJerome Glisse int radeon_debugfs_init(struct drm_minor *minor) 726771fe6b9SJerome Glisse { 727771fe6b9SJerome Glisse return 0; 728771fe6b9SJerome Glisse } 729771fe6b9SJerome Glisse 730771fe6b9SJerome Glisse void radeon_debugfs_cleanup(struct drm_minor *minor) 731771fe6b9SJerome Glisse { 732771fe6b9SJerome Glisse unsigned i; 733771fe6b9SJerome Glisse 734771fe6b9SJerome Glisse for (i = 0; i < _radeon_debugfs_count; i++) { 735771fe6b9SJerome Glisse drm_debugfs_remove_files(_radeon_debugfs[i].files, 736771fe6b9SJerome Glisse _radeon_debugfs[i].num_files, minor); 737771fe6b9SJerome Glisse } 738771fe6b9SJerome Glisse } 739771fe6b9SJerome Glisse #endif 740