Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
| 28 | #ifndef __RADEON_H__ |
| 29 | #define __RADEON_H__ |
| 30 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 31 | /* TODO: Here are things that needs to be done : |
| 32 | * - surface allocator & initializer : (bit like scratch reg) should |
| 33 | * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings |
| 34 | * related to surface |
| 35 | * - WB : write back stuff (do it bit like scratch reg things) |
| 36 | * - Vblank : look at Jesse's rework and what we should do |
| 37 | * - r600/r700: gart & cp |
| 38 | * - cs : clean cs ioctl use bitmap & things like that. |
| 39 | * - power management stuff |
| 40 | * - Barrier in gart code |
| 41 | * - Unmappabled vram ? |
| 42 | * - TESTING, TESTING, TESTING |
| 43 | */ |
| 44 | |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 45 | /* Initialization path: |
| 46 | * We expect that acceleration initialization might fail for various |
| 47 | * reasons even thought we work hard to make it works on most |
| 48 | * configurations. In order to still have a working userspace in such |
| 49 | * situation the init path must succeed up to the memory controller |
| 50 | * initialization point. Failure before this point are considered as |
| 51 | * fatal error. Here is the init callchain : |
| 52 | * radeon_device_init perform common structure, mutex initialization |
| 53 | * asic_init setup the GPU memory layout and perform all |
| 54 | * one time initialization (failure in this |
| 55 | * function are considered fatal) |
| 56 | * asic_startup setup the GPU acceleration, in order to |
| 57 | * follow guideline the first thing this |
| 58 | * function should do is setting the GPU |
| 59 | * memory controller (only MC setup failure |
| 60 | * are considered as fatal) |
| 61 | */ |
| 62 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 63 | #include <asm/atomic.h> |
| 64 | #include <linux/wait.h> |
| 65 | #include <linux/list.h> |
| 66 | #include <linux/kref.h> |
| 67 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 68 | #include <ttm/ttm_bo_api.h> |
| 69 | #include <ttm/ttm_bo_driver.h> |
| 70 | #include <ttm/ttm_placement.h> |
| 71 | #include <ttm/ttm_module.h> |
| 72 | |
Dave Airlie | c214271 | 2009-09-22 08:50:10 +1000 | [diff] [blame] | 73 | #include "radeon_family.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 74 | #include "radeon_mode.h" |
| 75 | #include "radeon_reg.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Modules parameters. |
| 79 | */ |
| 80 | extern int radeon_no_wb; |
| 81 | extern int radeon_modeset; |
| 82 | extern int radeon_dynclks; |
| 83 | extern int radeon_r4xx_atom; |
| 84 | extern int radeon_agpmode; |
| 85 | extern int radeon_vram_limit; |
| 86 | extern int radeon_gart_size; |
| 87 | extern int radeon_benchmarking; |
Michel Dänzer | ecc0b32 | 2009-07-21 11:23:57 +0200 | [diff] [blame] | 88 | extern int radeon_testing; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 89 | extern int radeon_connector_table; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 90 | extern int radeon_tv; |
Alex Deucher | b27b637 | 2009-12-09 17:44:25 -0500 | [diff] [blame] | 91 | extern int radeon_new_pll; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 92 | extern int radeon_audio; |
Alex Deucher | f46c012 | 2010-03-31 00:33:27 -0400 | [diff] [blame] | 93 | extern int radeon_disp_priority; |
Alex Deucher | e2b0a8e | 2010-03-17 02:07:37 -0400 | [diff] [blame] | 94 | extern int radeon_hw_i2c; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * Copy from radeon_drv.h so we don't have to include both and have conflicting |
| 98 | * symbol; |
| 99 | */ |
| 100 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 101 | #define RADEON_FENCE_JIFFIES_TIMEOUT (HZ / 2) |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 102 | /* RADEON_IB_POOL_SIZE must be a power of 2 */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 103 | #define RADEON_IB_POOL_SIZE 16 |
| 104 | #define RADEON_DEBUGFS_MAX_NUM_FILES 32 |
| 105 | #define RADEONFB_CONN_LIMIT 4 |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 106 | #define RADEON_BIOS_NUM_SCRATCH 8 |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 107 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 108 | /* |
| 109 | * Errata workarounds. |
| 110 | */ |
| 111 | enum radeon_pll_errata { |
| 112 | CHIP_ERRATA_R300_CG = 0x00000001, |
| 113 | CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002, |
| 114 | CHIP_ERRATA_PLL_DELAY = 0x00000004 |
| 115 | }; |
| 116 | |
| 117 | |
| 118 | struct radeon_device; |
| 119 | |
| 120 | |
| 121 | /* |
| 122 | * BIOS. |
| 123 | */ |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 124 | #define ATRM_BIOS_PAGE 4096 |
| 125 | |
Dave Airlie | 8edb381 | 2010-03-01 21:50:01 +1100 | [diff] [blame] | 126 | #if defined(CONFIG_VGA_SWITCHEROO) |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 127 | bool radeon_atrm_supported(struct pci_dev *pdev); |
| 128 | int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len); |
Dave Airlie | 8edb381 | 2010-03-01 21:50:01 +1100 | [diff] [blame] | 129 | #else |
| 130 | static inline bool radeon_atrm_supported(struct pci_dev *pdev) |
| 131 | { |
| 132 | return false; |
| 133 | } |
| 134 | |
| 135 | static inline int radeon_atrm_get_bios_chunk(uint8_t *bios, int offset, int len){ |
| 136 | return -EINVAL; |
| 137 | } |
| 138 | #endif |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 139 | bool radeon_get_bios(struct radeon_device *rdev); |
| 140 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 141 | |
| 142 | /* |
| 143 | * Dummy page |
| 144 | */ |
| 145 | struct radeon_dummy_page { |
| 146 | struct page *page; |
| 147 | dma_addr_t addr; |
| 148 | }; |
| 149 | int radeon_dummy_page_init(struct radeon_device *rdev); |
| 150 | void radeon_dummy_page_fini(struct radeon_device *rdev); |
| 151 | |
| 152 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 153 | /* |
| 154 | * Clocks |
| 155 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 156 | struct radeon_clock { |
| 157 | struct radeon_pll p1pll; |
| 158 | struct radeon_pll p2pll; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 159 | struct radeon_pll dcpll; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 160 | struct radeon_pll spll; |
| 161 | struct radeon_pll mpll; |
| 162 | /* 10 Khz units */ |
| 163 | uint32_t default_mclk; |
| 164 | uint32_t default_sclk; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 165 | uint32_t default_dispclk; |
| 166 | uint32_t dp_extclk; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 167 | }; |
| 168 | |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 169 | /* |
| 170 | * Power management |
| 171 | */ |
| 172 | int radeon_pm_init(struct radeon_device *rdev); |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 173 | void radeon_pm_fini(struct radeon_device *rdev); |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 174 | void radeon_pm_compute_clocks(struct radeon_device *rdev); |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 175 | void radeon_pm_suspend(struct radeon_device *rdev); |
| 176 | void radeon_pm_resume(struct radeon_device *rdev); |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 177 | void radeon_combios_get_power_modes(struct radeon_device *rdev); |
| 178 | void radeon_atombios_get_power_modes(struct radeon_device *rdev); |
Alex Deucher | 7ac9aa5 | 2010-05-27 19:25:54 -0400 | [diff] [blame] | 179 | void radeon_atom_set_voltage(struct radeon_device *rdev, u16 level); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 180 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 181 | /* |
| 182 | * Fences. |
| 183 | */ |
| 184 | struct radeon_fence_driver { |
| 185 | uint32_t scratch_reg; |
| 186 | atomic_t seq; |
| 187 | uint32_t last_seq; |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 188 | unsigned long last_jiffies; |
| 189 | unsigned long last_timeout; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 190 | wait_queue_head_t queue; |
| 191 | rwlock_t lock; |
| 192 | struct list_head created; |
| 193 | struct list_head emited; |
| 194 | struct list_head signaled; |
Jerome Glisse | 0a0c759 | 2009-12-11 20:36:19 +0100 | [diff] [blame] | 195 | bool initialized; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | struct radeon_fence { |
| 199 | struct radeon_device *rdev; |
| 200 | struct kref kref; |
| 201 | struct list_head list; |
| 202 | /* protected by radeon_fence.lock */ |
| 203 | uint32_t seq; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 204 | bool emited; |
| 205 | bool signaled; |
| 206 | }; |
| 207 | |
| 208 | int radeon_fence_driver_init(struct radeon_device *rdev); |
| 209 | void radeon_fence_driver_fini(struct radeon_device *rdev); |
| 210 | int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence); |
| 211 | int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence); |
| 212 | void radeon_fence_process(struct radeon_device *rdev); |
| 213 | bool radeon_fence_signaled(struct radeon_fence *fence); |
| 214 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); |
| 215 | int radeon_fence_wait_next(struct radeon_device *rdev); |
| 216 | int radeon_fence_wait_last(struct radeon_device *rdev); |
| 217 | struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence); |
| 218 | void radeon_fence_unref(struct radeon_fence **fence); |
| 219 | |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 220 | /* |
| 221 | * Tiling registers |
| 222 | */ |
| 223 | struct radeon_surface_reg { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 224 | struct radeon_bo *bo; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | #define RADEON_GEM_MAX_SURFACES 8 |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 228 | |
| 229 | /* |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 230 | * TTM. |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 231 | */ |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 232 | struct radeon_mman { |
| 233 | struct ttm_bo_global_ref bo_global_ref; |
| 234 | struct ttm_global_reference mem_global_ref; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 235 | struct ttm_bo_device bdev; |
Jerome Glisse | 0a0c759 | 2009-12-11 20:36:19 +0100 | [diff] [blame] | 236 | bool mem_global_referenced; |
| 237 | bool initialized; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 238 | }; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 239 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 240 | struct radeon_bo { |
| 241 | /* Protected by gem.mutex */ |
| 242 | struct list_head list; |
| 243 | /* Protected by tbo.reserved */ |
Jerome Glisse | 312ea8d | 2009-12-07 15:52:58 +0100 | [diff] [blame] | 244 | u32 placements[3]; |
| 245 | struct ttm_placement placement; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 246 | struct ttm_buffer_object tbo; |
| 247 | struct ttm_bo_kmap_obj kmap; |
| 248 | unsigned pin_count; |
| 249 | void *kptr; |
| 250 | u32 tiling_flags; |
| 251 | u32 pitch; |
| 252 | int surface_reg; |
| 253 | /* Constant after initialization */ |
| 254 | struct radeon_device *rdev; |
| 255 | struct drm_gem_object *gobj; |
| 256 | }; |
| 257 | |
| 258 | struct radeon_bo_list { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 259 | struct list_head list; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 260 | struct radeon_bo *bo; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 261 | uint64_t gpu_offset; |
| 262 | unsigned rdomain; |
| 263 | unsigned wdomain; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 264 | u32 tiling_flags; |
Jerome Glisse | e865275 | 2010-05-19 16:05:50 +0200 | [diff] [blame] | 265 | bool reserved; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 266 | }; |
| 267 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 268 | /* |
| 269 | * GEM objects. |
| 270 | */ |
| 271 | struct radeon_gem { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 272 | struct mutex mutex; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 273 | struct list_head objects; |
| 274 | }; |
| 275 | |
| 276 | int radeon_gem_init(struct radeon_device *rdev); |
| 277 | void radeon_gem_fini(struct radeon_device *rdev); |
| 278 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 279 | int alignment, int initial_domain, |
| 280 | bool discardable, bool kernel, |
| 281 | struct drm_gem_object **obj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 282 | int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, |
| 283 | uint64_t *gpu_addr); |
| 284 | void radeon_gem_object_unpin(struct drm_gem_object *obj); |
| 285 | |
| 286 | |
| 287 | /* |
| 288 | * GART structures, functions & helpers |
| 289 | */ |
| 290 | struct radeon_mc; |
| 291 | |
| 292 | struct radeon_gart_table_ram { |
| 293 | volatile uint32_t *ptr; |
| 294 | }; |
| 295 | |
| 296 | struct radeon_gart_table_vram { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 297 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 298 | volatile uint32_t *ptr; |
| 299 | }; |
| 300 | |
| 301 | union radeon_gart_table { |
| 302 | struct radeon_gart_table_ram ram; |
| 303 | struct radeon_gart_table_vram vram; |
| 304 | }; |
| 305 | |
Matt Turner | a77f171 | 2009-10-14 00:34:41 -0400 | [diff] [blame] | 306 | #define RADEON_GPU_PAGE_SIZE 4096 |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 307 | #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1) |
Matt Turner | a77f171 | 2009-10-14 00:34:41 -0400 | [diff] [blame] | 308 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 309 | struct radeon_gart { |
| 310 | dma_addr_t table_addr; |
| 311 | unsigned num_gpu_pages; |
| 312 | unsigned num_cpu_pages; |
| 313 | unsigned table_size; |
| 314 | union radeon_gart_table table; |
| 315 | struct page **pages; |
| 316 | dma_addr_t *pages_addr; |
| 317 | bool ready; |
| 318 | }; |
| 319 | |
| 320 | int radeon_gart_table_ram_alloc(struct radeon_device *rdev); |
| 321 | void radeon_gart_table_ram_free(struct radeon_device *rdev); |
| 322 | int radeon_gart_table_vram_alloc(struct radeon_device *rdev); |
| 323 | void radeon_gart_table_vram_free(struct radeon_device *rdev); |
| 324 | int radeon_gart_init(struct radeon_device *rdev); |
| 325 | void radeon_gart_fini(struct radeon_device *rdev); |
| 326 | void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, |
| 327 | int pages); |
| 328 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, |
| 329 | int pages, struct page **pagelist); |
| 330 | |
| 331 | |
| 332 | /* |
| 333 | * GPU MC structures, functions & helpers |
| 334 | */ |
| 335 | struct radeon_mc { |
| 336 | resource_size_t aper_size; |
| 337 | resource_size_t aper_base; |
| 338 | resource_size_t agp_base; |
Dave Airlie | 7a50f01 | 2009-07-21 20:39:30 +1000 | [diff] [blame] | 339 | /* for some chips with <= 32MB we need to lie |
| 340 | * about vram size near mc fb location */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 341 | u64 mc_vram_size; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 342 | u64 visible_vram_size; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 343 | u64 gtt_size; |
| 344 | u64 gtt_start; |
| 345 | u64 gtt_end; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 346 | u64 vram_start; |
| 347 | u64 vram_end; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 348 | unsigned vram_width; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 349 | u64 real_vram_size; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 350 | int vram_mtrr; |
| 351 | bool vram_is_ddr; |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 352 | bool igp_sideport_enabled; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 353 | }; |
| 354 | |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 355 | bool radeon_combios_sideport_present(struct radeon_device *rdev); |
| 356 | bool radeon_atombios_sideport_present(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 357 | |
| 358 | /* |
| 359 | * GPU scratch registers structures, functions & helpers |
| 360 | */ |
| 361 | struct radeon_scratch { |
| 362 | unsigned num_reg; |
| 363 | bool free[32]; |
| 364 | uint32_t reg[32]; |
| 365 | }; |
| 366 | |
| 367 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg); |
| 368 | void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg); |
| 369 | |
| 370 | |
| 371 | /* |
| 372 | * IRQS. |
| 373 | */ |
| 374 | struct radeon_irq { |
| 375 | bool installed; |
| 376 | bool sw_int; |
| 377 | /* FIXME: use a define max crtc rather than hardcode it */ |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 378 | bool crtc_vblank_int[6]; |
Rafał Miłecki | 73a6d3f | 2010-01-08 00:22:47 +0100 | [diff] [blame] | 379 | wait_queue_head_t vblank_queue; |
Alex Deucher | b500f68 | 2009-12-03 13:08:53 -0500 | [diff] [blame] | 380 | /* FIXME: use defines for max hpd/dacs */ |
| 381 | bool hpd[6]; |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 382 | bool gui_idle; |
| 383 | bool gui_idle_acked; |
| 384 | wait_queue_head_t idle_queue; |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 385 | /* FIXME: use defines for max HDMI blocks */ |
| 386 | bool hdmi[2]; |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 387 | spinlock_t sw_lock; |
| 388 | int sw_refcount; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 389 | }; |
| 390 | |
| 391 | int radeon_irq_kms_init(struct radeon_device *rdev); |
| 392 | void radeon_irq_kms_fini(struct radeon_device *rdev); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 393 | void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev); |
| 394 | void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 395 | |
| 396 | /* |
| 397 | * CP & ring. |
| 398 | */ |
| 399 | struct radeon_ib { |
| 400 | struct list_head list; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 401 | unsigned idx; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 402 | uint64_t gpu_addr; |
| 403 | struct radeon_fence *fence; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 404 | uint32_t *ptr; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 405 | uint32_t length_dw; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 406 | bool free; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 407 | }; |
| 408 | |
Dave Airlie | ecb114a | 2009-09-15 11:12:56 +1000 | [diff] [blame] | 409 | /* |
| 410 | * locking - |
| 411 | * mutex protects scheduled_ibs, ready, alloc_bm |
| 412 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 413 | struct radeon_ib_pool { |
| 414 | struct mutex mutex; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 415 | struct radeon_bo *robj; |
Jerome Glisse | 9f93ed3 | 2010-01-28 18:22:31 +0100 | [diff] [blame] | 416 | struct list_head bogus_ib; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 417 | struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; |
| 418 | bool ready; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 419 | unsigned head_id; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 420 | }; |
| 421 | |
| 422 | struct radeon_cp { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 423 | struct radeon_bo *ring_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 424 | volatile uint32_t *ring; |
| 425 | unsigned rptr; |
| 426 | unsigned wptr; |
| 427 | unsigned wptr_old; |
| 428 | unsigned ring_size; |
| 429 | unsigned ring_free_dw; |
| 430 | int count_dw; |
| 431 | uint64_t gpu_addr; |
| 432 | uint32_t align_mask; |
| 433 | uint32_t ptr_mask; |
| 434 | struct mutex mutex; |
| 435 | bool ready; |
| 436 | }; |
| 437 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 438 | /* |
| 439 | * R6xx+ IH ring |
| 440 | */ |
| 441 | struct r600_ih { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 442 | struct radeon_bo *ring_obj; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 443 | volatile uint32_t *ring; |
| 444 | unsigned rptr; |
| 445 | unsigned wptr; |
| 446 | unsigned wptr_old; |
| 447 | unsigned ring_size; |
| 448 | uint64_t gpu_addr; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 449 | uint32_t ptr_mask; |
| 450 | spinlock_t lock; |
| 451 | bool enabled; |
| 452 | }; |
| 453 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 454 | struct r600_blit { |
Jerome Glisse | ff82f05 | 2010-01-22 15:19:00 +0100 | [diff] [blame] | 455 | struct mutex mutex; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 456 | struct radeon_bo *shader_obj; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 457 | u64 shader_gpu_addr; |
| 458 | u32 vs_offset, ps_offset; |
| 459 | u32 state_offset; |
| 460 | u32 state_len; |
| 461 | u32 vb_used, vb_total; |
| 462 | struct radeon_ib *vb_ib; |
| 463 | }; |
| 464 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 465 | int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib); |
| 466 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); |
| 467 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); |
| 468 | int radeon_ib_pool_init(struct radeon_device *rdev); |
| 469 | void radeon_ib_pool_fini(struct radeon_device *rdev); |
| 470 | int radeon_ib_test(struct radeon_device *rdev); |
Jerome Glisse | 9f93ed3 | 2010-01-28 18:22:31 +0100 | [diff] [blame] | 471 | extern void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 472 | /* Ring access between begin & end cannot sleep */ |
| 473 | void radeon_ring_free_size(struct radeon_device *rdev); |
Matthew Garrett | 91700f3 | 2010-04-30 15:24:17 -0400 | [diff] [blame] | 474 | int radeon_ring_alloc(struct radeon_device *rdev, unsigned ndw); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 475 | int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw); |
Matthew Garrett | 91700f3 | 2010-04-30 15:24:17 -0400 | [diff] [blame] | 476 | void radeon_ring_commit(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 477 | void radeon_ring_unlock_commit(struct radeon_device *rdev); |
| 478 | void radeon_ring_unlock_undo(struct radeon_device *rdev); |
| 479 | int radeon_ring_test(struct radeon_device *rdev); |
| 480 | int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 481 | void radeon_ring_fini(struct radeon_device *rdev); |
| 482 | |
| 483 | |
| 484 | /* |
| 485 | * CS. |
| 486 | */ |
| 487 | struct radeon_cs_reloc { |
| 488 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 489 | struct radeon_bo *robj; |
| 490 | struct radeon_bo_list lobj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 491 | uint32_t handle; |
| 492 | uint32_t flags; |
| 493 | }; |
| 494 | |
| 495 | struct radeon_cs_chunk { |
| 496 | uint32_t chunk_id; |
| 497 | uint32_t length_dw; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 498 | int kpage_idx[2]; |
| 499 | uint32_t *kpage[2]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 500 | uint32_t *kdata; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 501 | void __user *user_ptr; |
| 502 | int last_copied_page; |
| 503 | int last_page_index; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 504 | }; |
| 505 | |
| 506 | struct radeon_cs_parser { |
Jerome Glisse | c8c15ff | 2010-01-18 13:01:36 +0100 | [diff] [blame] | 507 | struct device *dev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 508 | struct radeon_device *rdev; |
| 509 | struct drm_file *filp; |
| 510 | /* chunks */ |
| 511 | unsigned nchunks; |
| 512 | struct radeon_cs_chunk *chunks; |
| 513 | uint64_t *chunks_array; |
| 514 | /* IB */ |
| 515 | unsigned idx; |
| 516 | /* relocations */ |
| 517 | unsigned nrelocs; |
| 518 | struct radeon_cs_reloc *relocs; |
| 519 | struct radeon_cs_reloc **relocs_ptr; |
| 520 | struct list_head validated; |
| 521 | /* indices of various chunks */ |
| 522 | int chunk_ib_idx; |
| 523 | int chunk_relocs_idx; |
| 524 | struct radeon_ib *ib; |
| 525 | void *track; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 526 | unsigned family; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 527 | int parser_error; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 528 | }; |
| 529 | |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 530 | extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx); |
| 531 | extern int radeon_cs_finish_pages(struct radeon_cs_parser *p); |
| 532 | |
| 533 | |
| 534 | static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx) |
| 535 | { |
| 536 | struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx]; |
| 537 | u32 pg_idx, pg_offset; |
| 538 | u32 idx_value = 0; |
| 539 | int new_page; |
| 540 | |
| 541 | pg_idx = (idx * 4) / PAGE_SIZE; |
| 542 | pg_offset = (idx * 4) % PAGE_SIZE; |
| 543 | |
| 544 | if (ibc->kpage_idx[0] == pg_idx) |
| 545 | return ibc->kpage[0][pg_offset/4]; |
| 546 | if (ibc->kpage_idx[1] == pg_idx) |
| 547 | return ibc->kpage[1][pg_offset/4]; |
| 548 | |
| 549 | new_page = radeon_cs_update_pages(p, pg_idx); |
| 550 | if (new_page < 0) { |
| 551 | p->parser_error = new_page; |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | idx_value = ibc->kpage[new_page][pg_offset/4]; |
| 556 | return idx_value; |
| 557 | } |
| 558 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 559 | struct radeon_cs_packet { |
| 560 | unsigned idx; |
| 561 | unsigned type; |
| 562 | unsigned reg; |
| 563 | unsigned opcode; |
| 564 | int count; |
| 565 | unsigned one_reg_wr; |
| 566 | }; |
| 567 | |
| 568 | typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p, |
| 569 | struct radeon_cs_packet *pkt, |
| 570 | unsigned idx, unsigned reg); |
| 571 | typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p, |
| 572 | struct radeon_cs_packet *pkt); |
| 573 | |
| 574 | |
| 575 | /* |
| 576 | * AGP |
| 577 | */ |
| 578 | int radeon_agp_init(struct radeon_device *rdev); |
Dave Airlie | 0ebf171 | 2009-11-05 15:39:10 +1000 | [diff] [blame] | 579 | void radeon_agp_resume(struct radeon_device *rdev); |
Jerome Glisse | 10b0612 | 2010-05-21 18:48:54 +0200 | [diff] [blame] | 580 | void radeon_agp_suspend(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 581 | void radeon_agp_fini(struct radeon_device *rdev); |
| 582 | |
| 583 | |
| 584 | /* |
| 585 | * Writeback |
| 586 | */ |
| 587 | struct radeon_wb { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 588 | struct radeon_bo *wb_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 589 | volatile uint32_t *wb; |
| 590 | uint64_t gpu_addr; |
| 591 | }; |
| 592 | |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 593 | /** |
| 594 | * struct radeon_pm - power management datas |
| 595 | * @max_bandwidth: maximum bandwidth the gpu has (MByte/s) |
| 596 | * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880) |
| 597 | * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880) |
| 598 | * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880) |
| 599 | * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880) |
| 600 | * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP) |
| 601 | * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP) |
| 602 | * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP) |
| 603 | * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP) |
| 604 | * @sclk: GPU clock Mhz (core bandwith depends of this clock) |
| 605 | * @needed_bandwidth: current bandwidth needs |
| 606 | * |
| 607 | * It keeps track of various data needed to take powermanagement decision. |
| 608 | * Bandwith need is used to determine minimun clock of the GPU and memory. |
| 609 | * Equation between gpu/memory clock and available bandwidth is hw dependent |
| 610 | * (type of memory, bus size, efficiency, ...) |
| 611 | */ |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 612 | |
| 613 | enum radeon_pm_method { |
| 614 | PM_METHOD_PROFILE, |
| 615 | PM_METHOD_DYNPM, |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 616 | }; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 617 | |
| 618 | enum radeon_dynpm_state { |
| 619 | DYNPM_STATE_DISABLED, |
| 620 | DYNPM_STATE_MINIMUM, |
| 621 | DYNPM_STATE_PAUSED, |
| 622 | DYNPM_STATE_ACTIVE |
| 623 | }; |
| 624 | enum radeon_dynpm_action { |
| 625 | DYNPM_ACTION_NONE, |
| 626 | DYNPM_ACTION_MINIMUM, |
| 627 | DYNPM_ACTION_DOWNCLOCK, |
| 628 | DYNPM_ACTION_UPCLOCK, |
| 629 | DYNPM_ACTION_DEFAULT |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 630 | }; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 631 | |
| 632 | enum radeon_voltage_type { |
| 633 | VOLTAGE_NONE = 0, |
| 634 | VOLTAGE_GPIO, |
| 635 | VOLTAGE_VDDC, |
| 636 | VOLTAGE_SW |
| 637 | }; |
| 638 | |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 639 | enum radeon_pm_state_type { |
| 640 | POWER_STATE_TYPE_DEFAULT, |
| 641 | POWER_STATE_TYPE_POWERSAVE, |
| 642 | POWER_STATE_TYPE_BATTERY, |
| 643 | POWER_STATE_TYPE_BALANCED, |
| 644 | POWER_STATE_TYPE_PERFORMANCE, |
| 645 | }; |
| 646 | |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 647 | enum radeon_pm_profile_type { |
| 648 | PM_PROFILE_DEFAULT, |
| 649 | PM_PROFILE_AUTO, |
| 650 | PM_PROFILE_LOW, |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame^] | 651 | PM_PROFILE_MID, |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 652 | PM_PROFILE_HIGH, |
| 653 | }; |
| 654 | |
| 655 | #define PM_PROFILE_DEFAULT_IDX 0 |
| 656 | #define PM_PROFILE_LOW_SH_IDX 1 |
Alex Deucher | c9e75b2 | 2010-06-02 17:56:01 -0400 | [diff] [blame^] | 657 | #define PM_PROFILE_MID_SH_IDX 2 |
| 658 | #define PM_PROFILE_HIGH_SH_IDX 3 |
| 659 | #define PM_PROFILE_LOW_MH_IDX 4 |
| 660 | #define PM_PROFILE_MID_MH_IDX 5 |
| 661 | #define PM_PROFILE_HIGH_MH_IDX 6 |
| 662 | #define PM_PROFILE_MAX 7 |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 663 | |
| 664 | struct radeon_pm_profile { |
| 665 | int dpms_off_ps_idx; |
| 666 | int dpms_on_ps_idx; |
| 667 | int dpms_off_cm_idx; |
| 668 | int dpms_on_cm_idx; |
Alex Deucher | 516d0e4 | 2009-12-23 14:28:05 -0500 | [diff] [blame] | 669 | }; |
| 670 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 671 | struct radeon_voltage { |
| 672 | enum radeon_voltage_type type; |
| 673 | /* gpio voltage */ |
| 674 | struct radeon_gpio_rec gpio; |
| 675 | u32 delay; /* delay in usec from voltage drop to sclk change */ |
| 676 | bool active_high; /* voltage drop is active when bit is high */ |
| 677 | /* VDDC voltage */ |
| 678 | u8 vddc_id; /* index into vddc voltage table */ |
| 679 | u8 vddci_id; /* index into vddci voltage table */ |
| 680 | bool vddci_enabled; |
| 681 | /* r6xx+ sw */ |
| 682 | u32 voltage; |
| 683 | }; |
| 684 | |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 685 | /* clock mode flags */ |
| 686 | #define RADEON_PM_MODE_NO_DISPLAY (1 << 0) |
| 687 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 688 | struct radeon_pm_clock_info { |
| 689 | /* memory clock */ |
| 690 | u32 mclk; |
| 691 | /* engine clock */ |
| 692 | u32 sclk; |
| 693 | /* voltage info */ |
| 694 | struct radeon_voltage voltage; |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 695 | /* standardized clock flags */ |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 696 | u32 flags; |
| 697 | }; |
| 698 | |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 699 | /* state flags */ |
Alex Deucher | d731117 | 2010-05-03 01:13:14 -0400 | [diff] [blame] | 700 | #define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0) |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 701 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 702 | struct radeon_power_state { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 703 | enum radeon_pm_state_type type; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 704 | /* XXX: use a define for num clock modes */ |
| 705 | struct radeon_pm_clock_info clock_info[8]; |
| 706 | /* number of valid clock modes in this power state */ |
| 707 | int num_clock_modes; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 708 | struct radeon_pm_clock_info *default_clock_mode; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 709 | /* standardized state flags */ |
| 710 | u32 flags; |
Alex Deucher | 79daedc | 2010-04-22 14:25:19 -0400 | [diff] [blame] | 711 | u32 misc; /* vbios specific flags */ |
| 712 | u32 misc2; /* vbios specific flags */ |
| 713 | int pcie_lanes; /* pcie lanes */ |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 714 | }; |
| 715 | |
Rafał Miłecki | 2745932 | 2010-02-11 22:16:36 +0000 | [diff] [blame] | 716 | /* |
| 717 | * Some modes are overclocked by very low value, accept them |
| 718 | */ |
| 719 | #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */ |
| 720 | |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 721 | struct radeon_pm { |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 722 | struct mutex mutex; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 723 | u32 active_crtcs; |
| 724 | int active_crtc_count; |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 725 | int req_vblank; |
Rafał Miłecki | 839461d | 2010-03-02 22:06:51 +0100 | [diff] [blame] | 726 | bool vblank_sync; |
Alex Deucher | 2031f77 | 2010-04-22 12:52:11 -0400 | [diff] [blame] | 727 | bool gui_idle; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 728 | fixed20_12 max_bandwidth; |
| 729 | fixed20_12 igp_sideport_mclk; |
| 730 | fixed20_12 igp_system_mclk; |
| 731 | fixed20_12 igp_ht_link_clk; |
| 732 | fixed20_12 igp_ht_link_width; |
| 733 | fixed20_12 k8_bandwidth; |
| 734 | fixed20_12 sideport_bandwidth; |
| 735 | fixed20_12 ht_bandwidth; |
| 736 | fixed20_12 core_bandwidth; |
| 737 | fixed20_12 sclk; |
Alex Deucher | f47299c | 2010-03-16 20:54:38 -0400 | [diff] [blame] | 738 | fixed20_12 mclk; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 739 | fixed20_12 needed_bandwidth; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 740 | /* XXX: use a define for num power modes */ |
| 741 | struct radeon_power_state power_state[8]; |
| 742 | /* number of valid power states */ |
| 743 | int num_power_states; |
Alex Deucher | a48b9b4 | 2010-04-22 14:03:55 -0400 | [diff] [blame] | 744 | int current_power_state_index; |
| 745 | int current_clock_mode_index; |
| 746 | int requested_power_state_index; |
| 747 | int requested_clock_mode_index; |
| 748 | int default_power_state_index; |
| 749 | u32 current_sclk; |
| 750 | u32 current_mclk; |
Alex Deucher | 29fb52c | 2010-03-11 10:01:17 -0500 | [diff] [blame] | 751 | struct radeon_i2c_chan *i2c_bus; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 752 | /* selected pm method */ |
| 753 | enum radeon_pm_method pm_method; |
| 754 | /* dynpm power management */ |
| 755 | struct delayed_work dynpm_idle_work; |
| 756 | enum radeon_dynpm_state dynpm_state; |
| 757 | enum radeon_dynpm_action dynpm_planned_action; |
| 758 | unsigned long dynpm_action_timeout; |
| 759 | bool dynpm_can_upclock; |
| 760 | bool dynpm_can_downclock; |
| 761 | /* profile-based power management */ |
| 762 | enum radeon_pm_profile_type profile; |
| 763 | int profile_index; |
| 764 | struct radeon_pm_profile profiles[PM_PROFILE_MAX]; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 765 | }; |
| 766 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 767 | |
| 768 | /* |
| 769 | * Benchmarking |
| 770 | */ |
| 771 | void radeon_benchmark(struct radeon_device *rdev); |
| 772 | |
| 773 | |
| 774 | /* |
Michel Dänzer | ecc0b32 | 2009-07-21 11:23:57 +0200 | [diff] [blame] | 775 | * Testing |
| 776 | */ |
| 777 | void radeon_test_moves(struct radeon_device *rdev); |
| 778 | |
| 779 | |
| 780 | /* |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 781 | * Debugfs |
| 782 | */ |
| 783 | int radeon_debugfs_add_files(struct radeon_device *rdev, |
| 784 | struct drm_info_list *files, |
| 785 | unsigned nfiles); |
| 786 | int radeon_debugfs_fence_init(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 787 | |
| 788 | |
| 789 | /* |
| 790 | * ASIC specific functions. |
| 791 | */ |
| 792 | struct radeon_asic { |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 793 | int (*init)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 794 | void (*fini)(struct radeon_device *rdev); |
| 795 | int (*resume)(struct radeon_device *rdev); |
| 796 | int (*suspend)(struct radeon_device *rdev); |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 797 | void (*vga_set_state)(struct radeon_device *rdev, bool state); |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 798 | bool (*gpu_is_lockup)(struct radeon_device *rdev); |
Jerome Glisse | a2d07b7 | 2010-03-09 14:45:11 +0000 | [diff] [blame] | 799 | int (*asic_reset)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 800 | void (*gart_tlb_flush)(struct radeon_device *rdev); |
| 801 | int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr); |
| 802 | int (*cp_init)(struct radeon_device *rdev, unsigned ring_size); |
| 803 | void (*cp_fini)(struct radeon_device *rdev); |
| 804 | void (*cp_disable)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 805 | void (*cp_commit)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 806 | void (*ring_start)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 807 | int (*ring_test)(struct radeon_device *rdev); |
| 808 | void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 809 | int (*irq_set)(struct radeon_device *rdev); |
| 810 | int (*irq_process)(struct radeon_device *rdev); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 811 | u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 812 | void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence); |
| 813 | int (*cs_parse)(struct radeon_cs_parser *p); |
| 814 | int (*copy_blit)(struct radeon_device *rdev, |
| 815 | uint64_t src_offset, |
| 816 | uint64_t dst_offset, |
| 817 | unsigned num_pages, |
| 818 | struct radeon_fence *fence); |
| 819 | int (*copy_dma)(struct radeon_device *rdev, |
| 820 | uint64_t src_offset, |
| 821 | uint64_t dst_offset, |
| 822 | unsigned num_pages, |
| 823 | struct radeon_fence *fence); |
| 824 | int (*copy)(struct radeon_device *rdev, |
| 825 | uint64_t src_offset, |
| 826 | uint64_t dst_offset, |
| 827 | unsigned num_pages, |
| 828 | struct radeon_fence *fence); |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 829 | uint32_t (*get_engine_clock)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 830 | void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock); |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 831 | uint32_t (*get_memory_clock)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 832 | void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock); |
Alex Deucher | c836a41 | 2009-12-23 10:07:50 -0500 | [diff] [blame] | 833 | int (*get_pcie_lanes)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 834 | void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes); |
| 835 | void (*set_clock_gating)(struct radeon_device *rdev, int enable); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 836 | int (*set_surface_reg)(struct radeon_device *rdev, int reg, |
| 837 | uint32_t tiling_flags, uint32_t pitch, |
| 838 | uint32_t offset, uint32_t obj_size); |
Daniel Vetter | 9479c54 | 2010-03-11 21:19:16 +0000 | [diff] [blame] | 839 | void (*clear_surface_reg)(struct radeon_device *rdev, int reg); |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 840 | void (*bandwidth_update)(struct radeon_device *rdev); |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 841 | void (*hpd_init)(struct radeon_device *rdev); |
| 842 | void (*hpd_fini)(struct radeon_device *rdev); |
| 843 | bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd); |
| 844 | void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd); |
Jerome Glisse | 062b389 | 2010-02-04 20:36:39 +0100 | [diff] [blame] | 845 | /* ioctl hw specific callback. Some hw might want to perform special |
| 846 | * operation on specific ioctl. For instance on wait idle some hw |
| 847 | * might want to perform and HDP flush through MMIO as it seems that |
| 848 | * some R6XX/R7XX hw doesn't take HDP flush into account if programmed |
| 849 | * through ring. |
| 850 | */ |
| 851 | void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo); |
Alex Deucher | def9ba9 | 2010-04-22 12:39:58 -0400 | [diff] [blame] | 852 | bool (*gui_idle)(struct radeon_device *rdev); |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 853 | /* power management */ |
Alex Deucher | 49e02b7 | 2010-04-23 17:57:27 -0400 | [diff] [blame] | 854 | void (*pm_misc)(struct radeon_device *rdev); |
| 855 | void (*pm_prepare)(struct radeon_device *rdev); |
| 856 | void (*pm_finish)(struct radeon_device *rdev); |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 857 | void (*pm_init_profile)(struct radeon_device *rdev); |
| 858 | void (*pm_get_dynpm_state)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 859 | }; |
| 860 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 861 | /* |
| 862 | * Asic structures |
| 863 | */ |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 864 | struct r100_gpu_lockup { |
| 865 | unsigned long last_jiffies; |
| 866 | u32 last_cp_rptr; |
| 867 | }; |
| 868 | |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 869 | struct r100_asic { |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 870 | const unsigned *reg_safe_bm; |
| 871 | unsigned reg_safe_bm_size; |
| 872 | u32 hdp_cntl; |
| 873 | struct r100_gpu_lockup lockup; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 874 | }; |
| 875 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 876 | struct r300_asic { |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 877 | const unsigned *reg_safe_bm; |
| 878 | unsigned reg_safe_bm_size; |
| 879 | u32 resync_scratch; |
| 880 | u32 hdp_cntl; |
| 881 | struct r100_gpu_lockup lockup; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 882 | }; |
| 883 | |
| 884 | struct r600_asic { |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 885 | unsigned max_pipes; |
| 886 | unsigned max_tile_pipes; |
| 887 | unsigned max_simds; |
| 888 | unsigned max_backends; |
| 889 | unsigned max_gprs; |
| 890 | unsigned max_threads; |
| 891 | unsigned max_stack_entries; |
| 892 | unsigned max_hw_contexts; |
| 893 | unsigned max_gs_threads; |
| 894 | unsigned sx_max_export_size; |
| 895 | unsigned sx_max_export_pos_size; |
| 896 | unsigned sx_max_export_smx_size; |
| 897 | unsigned sq_num_cf_insts; |
| 898 | unsigned tiling_nbanks; |
| 899 | unsigned tiling_npipes; |
| 900 | unsigned tiling_group_size; |
| 901 | struct r100_gpu_lockup lockup; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 902 | }; |
| 903 | |
| 904 | struct rv770_asic { |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 905 | unsigned max_pipes; |
| 906 | unsigned max_tile_pipes; |
| 907 | unsigned max_simds; |
| 908 | unsigned max_backends; |
| 909 | unsigned max_gprs; |
| 910 | unsigned max_threads; |
| 911 | unsigned max_stack_entries; |
| 912 | unsigned max_hw_contexts; |
| 913 | unsigned max_gs_threads; |
| 914 | unsigned sx_max_export_size; |
| 915 | unsigned sx_max_export_pos_size; |
| 916 | unsigned sx_max_export_smx_size; |
| 917 | unsigned sq_num_cf_insts; |
| 918 | unsigned sx_num_of_sets; |
| 919 | unsigned sc_prim_fifo_size; |
| 920 | unsigned sc_hiz_tile_fifo_size; |
| 921 | unsigned sc_earlyz_tile_fifo_fize; |
| 922 | unsigned tiling_nbanks; |
| 923 | unsigned tiling_npipes; |
| 924 | unsigned tiling_group_size; |
| 925 | struct r100_gpu_lockup lockup; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 926 | }; |
| 927 | |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 928 | struct evergreen_asic { |
| 929 | unsigned num_ses; |
| 930 | unsigned max_pipes; |
| 931 | unsigned max_tile_pipes; |
| 932 | unsigned max_simds; |
| 933 | unsigned max_backends; |
| 934 | unsigned max_gprs; |
| 935 | unsigned max_threads; |
| 936 | unsigned max_stack_entries; |
| 937 | unsigned max_hw_contexts; |
| 938 | unsigned max_gs_threads; |
| 939 | unsigned sx_max_export_size; |
| 940 | unsigned sx_max_export_pos_size; |
| 941 | unsigned sx_max_export_smx_size; |
| 942 | unsigned sq_num_cf_insts; |
| 943 | unsigned sx_num_of_sets; |
| 944 | unsigned sc_prim_fifo_size; |
| 945 | unsigned sc_hiz_tile_fifo_size; |
| 946 | unsigned sc_earlyz_tile_fifo_size; |
| 947 | unsigned tiling_nbanks; |
| 948 | unsigned tiling_npipes; |
| 949 | unsigned tiling_group_size; |
| 950 | }; |
| 951 | |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 952 | union radeon_asic_config { |
| 953 | struct r300_asic r300; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 954 | struct r100_asic r100; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 955 | struct r600_asic r600; |
| 956 | struct rv770_asic rv770; |
Alex Deucher | 32fcdbf | 2010-03-24 13:33:47 -0400 | [diff] [blame] | 957 | struct evergreen_asic evergreen; |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 958 | }; |
| 959 | |
Daniel Vetter | 0a10c85 | 2010-03-11 21:19:14 +0000 | [diff] [blame] | 960 | /* |
| 961 | * asic initizalization from radeon_asic.c |
| 962 | */ |
| 963 | void radeon_agp_disable(struct radeon_device *rdev); |
| 964 | int radeon_asic_init(struct radeon_device *rdev); |
| 965 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 966 | |
| 967 | /* |
| 968 | * IOCTL. |
| 969 | */ |
| 970 | int radeon_gem_info_ioctl(struct drm_device *dev, void *data, |
| 971 | struct drm_file *filp); |
| 972 | int radeon_gem_create_ioctl(struct drm_device *dev, void *data, |
| 973 | struct drm_file *filp); |
| 974 | int radeon_gem_pin_ioctl(struct drm_device *dev, void *data, |
| 975 | struct drm_file *file_priv); |
| 976 | int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data, |
| 977 | struct drm_file *file_priv); |
| 978 | int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data, |
| 979 | struct drm_file *file_priv); |
| 980 | int radeon_gem_pread_ioctl(struct drm_device *dev, void *data, |
| 981 | struct drm_file *file_priv); |
| 982 | int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, |
| 983 | struct drm_file *filp); |
| 984 | int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, |
| 985 | struct drm_file *filp); |
| 986 | int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, |
| 987 | struct drm_file *filp); |
| 988 | int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, |
| 989 | struct drm_file *filp); |
| 990 | int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 991 | int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, |
| 992 | struct drm_file *filp); |
| 993 | int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, |
| 994 | struct drm_file *filp); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 995 | |
| 996 | |
| 997 | /* |
| 998 | * Core structure, functions and helpers. |
| 999 | */ |
| 1000 | typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); |
| 1001 | typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t); |
| 1002 | |
| 1003 | struct radeon_device { |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1004 | struct device *dev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1005 | struct drm_device *ddev; |
| 1006 | struct pci_dev *pdev; |
| 1007 | /* ASIC */ |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 1008 | union radeon_asic_config config; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1009 | enum radeon_family family; |
| 1010 | unsigned long flags; |
| 1011 | int usec_timeout; |
| 1012 | enum radeon_pll_errata pll_errata; |
| 1013 | int num_gb_pipes; |
Alex Deucher | f779b3e | 2009-08-19 19:11:39 -0400 | [diff] [blame] | 1014 | int num_z_pipes; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1015 | int disp_priority; |
| 1016 | /* BIOS */ |
| 1017 | uint8_t *bios; |
| 1018 | bool is_atom_bios; |
| 1019 | uint16_t bios_header_start; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1020 | struct radeon_bo *stollen_vga_memory; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1021 | /* Register mmio */ |
Dave Airlie | 4c9bc75 | 2009-06-29 18:29:12 +1000 | [diff] [blame] | 1022 | resource_size_t rmmio_base; |
| 1023 | resource_size_t rmmio_size; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1024 | void *rmmio; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1025 | radeon_rreg_t mc_rreg; |
| 1026 | radeon_wreg_t mc_wreg; |
| 1027 | radeon_rreg_t pll_rreg; |
| 1028 | radeon_wreg_t pll_wreg; |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1029 | uint32_t pcie_reg_mask; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1030 | radeon_rreg_t pciep_rreg; |
| 1031 | radeon_wreg_t pciep_wreg; |
| 1032 | struct radeon_clock clock; |
| 1033 | struct radeon_mc mc; |
| 1034 | struct radeon_gart gart; |
| 1035 | struct radeon_mode_info mode_info; |
| 1036 | struct radeon_scratch scratch; |
| 1037 | struct radeon_mman mman; |
| 1038 | struct radeon_fence_driver fence_drv; |
| 1039 | struct radeon_cp cp; |
| 1040 | struct radeon_ib_pool ib_pool; |
| 1041 | struct radeon_irq irq; |
| 1042 | struct radeon_asic *asic; |
| 1043 | struct radeon_gem gem; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 1044 | struct radeon_pm pm; |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 1045 | uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1046 | struct mutex cs_mutex; |
| 1047 | struct radeon_wb wb; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1048 | struct radeon_dummy_page dummy_page; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1049 | bool gpu_lockup; |
| 1050 | bool shutdown; |
| 1051 | bool suspend; |
Dave Airlie | ad49f50 | 2009-07-10 22:36:26 +1000 | [diff] [blame] | 1052 | bool need_dma32; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 1053 | bool accel_working; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 1054 | struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1055 | const struct firmware *me_fw; /* all family ME firmware */ |
| 1056 | const struct firmware *pfp_fw; /* r6/700 PFP firmware */ |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1057 | const struct firmware *rlc_fw; /* r6/700 RLC firmware */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1058 | struct r600_blit r600_blit; |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 1059 | int msi_enabled; /* msi enabled */ |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1060 | struct r600_ih ih; /* r6/700 interrupt ring */ |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 1061 | struct workqueue_struct *wq; |
| 1062 | struct work_struct hotplug_work; |
Alex Deucher | 18917b6 | 2010-02-01 16:02:25 -0500 | [diff] [blame] | 1063 | int num_crtc; /* number of crtcs */ |
Alex Deucher | 40bacf1 | 2009-12-23 03:23:21 -0500 | [diff] [blame] | 1064 | struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */ |
Matthew Garrett | 5876dd2 | 2010-04-26 15:52:20 -0400 | [diff] [blame] | 1065 | struct mutex vram_mutex; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1066 | |
| 1067 | /* audio stuff */ |
| 1068 | struct timer_list audio_timer; |
| 1069 | int audio_channels; |
| 1070 | int audio_rate; |
| 1071 | int audio_bits_per_sample; |
| 1072 | uint8_t audio_status_bits; |
| 1073 | uint8_t audio_category_code; |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 1074 | |
| 1075 | bool powered_down; |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 1076 | struct notifier_block acpi_nb; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1077 | }; |
| 1078 | |
| 1079 | int radeon_device_init(struct radeon_device *rdev, |
| 1080 | struct drm_device *ddev, |
| 1081 | struct pci_dev *pdev, |
| 1082 | uint32_t flags); |
| 1083 | void radeon_device_fini(struct radeon_device *rdev); |
| 1084 | int radeon_gpu_wait_for_idle(struct radeon_device *rdev); |
| 1085 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1086 | /* r600 blit */ |
| 1087 | int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes); |
| 1088 | void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence); |
| 1089 | void r600_kms_blit_copy(struct radeon_device *rdev, |
| 1090 | u64 src_gpu_addr, u64 dst_gpu_addr, |
| 1091 | int size_bytes); |
| 1092 | |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1093 | static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg) |
| 1094 | { |
Alex Deucher | 07bec2d | 2010-01-13 19:09:12 -0500 | [diff] [blame] | 1095 | if (reg < rdev->rmmio_size) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1096 | return readl(((void __iomem *)rdev->rmmio) + reg); |
| 1097 | else { |
| 1098 | writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX); |
| 1099 | return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 1104 | { |
Alex Deucher | 07bec2d | 2010-01-13 19:09:12 -0500 | [diff] [blame] | 1105 | if (reg < rdev->rmmio_size) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1106 | writel(v, ((void __iomem *)rdev->rmmio) + reg); |
| 1107 | else { |
| 1108 | writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX); |
| 1109 | writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA); |
| 1110 | } |
| 1111 | } |
| 1112 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1113 | /* |
| 1114 | * Cast helper |
| 1115 | */ |
| 1116 | #define to_radeon_fence(p) ((struct radeon_fence *)(p)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1117 | |
| 1118 | /* |
| 1119 | * Registers read & write functions. |
| 1120 | */ |
| 1121 | #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) |
| 1122 | #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1123 | #define RREG32(reg) r100_mm_rreg(rdev, (reg)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1124 | #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg))) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1125 | #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1126 | #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
| 1127 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
| 1128 | #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg)) |
| 1129 | #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v)) |
| 1130 | #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg)) |
| 1131 | #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v)) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1132 | #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg)) |
| 1133 | #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v)) |
Rafał Miłecki | aa5120d | 2010-02-18 20:24:28 +0000 | [diff] [blame] | 1134 | #define RREG32_PCIE_P(reg) rdev->pciep_rreg(rdev, (reg)) |
| 1135 | #define WREG32_PCIE_P(reg, v) rdev->pciep_wreg(rdev, (reg), (v)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1136 | #define WREG32_P(reg, val, mask) \ |
| 1137 | do { \ |
| 1138 | uint32_t tmp_ = RREG32(reg); \ |
| 1139 | tmp_ &= (mask); \ |
| 1140 | tmp_ |= ((val) & ~(mask)); \ |
| 1141 | WREG32(reg, tmp_); \ |
| 1142 | } while (0) |
| 1143 | #define WREG32_PLL_P(reg, val, mask) \ |
| 1144 | do { \ |
| 1145 | uint32_t tmp_ = RREG32_PLL(reg); \ |
| 1146 | tmp_ &= (mask); \ |
| 1147 | tmp_ |= ((val) & ~(mask)); \ |
| 1148 | WREG32_PLL(reg, tmp_); \ |
| 1149 | } while (0) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1150 | #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg))) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1151 | |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1152 | /* |
| 1153 | * Indirect registers accessor |
| 1154 | */ |
| 1155 | static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) |
| 1156 | { |
| 1157 | uint32_t r; |
| 1158 | |
| 1159 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
| 1160 | r = RREG32(RADEON_PCIE_DATA); |
| 1161 | return r; |
| 1162 | } |
| 1163 | |
| 1164 | static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 1165 | { |
| 1166 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
| 1167 | WREG32(RADEON_PCIE_DATA, (v)); |
| 1168 | } |
| 1169 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1170 | void r100_pll_errata_after_index(struct radeon_device *rdev); |
| 1171 | |
| 1172 | |
| 1173 | /* |
| 1174 | * ASICs helpers. |
| 1175 | */ |
Dave Airlie | b995e43 | 2009-07-14 02:02:32 +1000 | [diff] [blame] | 1176 | #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \ |
| 1177 | (rdev->pdev->device == 0x5969)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1178 | #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \ |
| 1179 | (rdev->family == CHIP_RV200) || \ |
| 1180 | (rdev->family == CHIP_RS100) || \ |
| 1181 | (rdev->family == CHIP_RS200) || \ |
| 1182 | (rdev->family == CHIP_RV250) || \ |
| 1183 | (rdev->family == CHIP_RV280) || \ |
| 1184 | (rdev->family == CHIP_RS300)) |
| 1185 | #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \ |
| 1186 | (rdev->family == CHIP_RV350) || \ |
| 1187 | (rdev->family == CHIP_R350) || \ |
| 1188 | (rdev->family == CHIP_RV380) || \ |
| 1189 | (rdev->family == CHIP_R420) || \ |
| 1190 | (rdev->family == CHIP_R423) || \ |
| 1191 | (rdev->family == CHIP_RV410) || \ |
| 1192 | (rdev->family == CHIP_RS400) || \ |
| 1193 | (rdev->family == CHIP_RS480)) |
| 1194 | #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600)) |
| 1195 | #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620)) |
| 1196 | #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730)) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1197 | #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1198 | |
| 1199 | /* |
| 1200 | * BIOS helpers. |
| 1201 | */ |
| 1202 | #define RBIOS8(i) (rdev->bios[i]) |
| 1203 | #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8)) |
| 1204 | #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16)) |
| 1205 | |
| 1206 | int radeon_combios_init(struct radeon_device *rdev); |
| 1207 | void radeon_combios_fini(struct radeon_device *rdev); |
| 1208 | int radeon_atombios_init(struct radeon_device *rdev); |
| 1209 | void radeon_atombios_fini(struct radeon_device *rdev); |
| 1210 | |
| 1211 | |
| 1212 | /* |
| 1213 | * RING helpers. |
| 1214 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1215 | static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) |
| 1216 | { |
| 1217 | #if DRM_DEBUG_CODE |
| 1218 | if (rdev->cp.count_dw <= 0) { |
| 1219 | DRM_ERROR("radeon: writting more dword to ring than expected !\n"); |
| 1220 | } |
| 1221 | #endif |
| 1222 | rdev->cp.ring[rdev->cp.wptr++] = v; |
| 1223 | rdev->cp.wptr &= rdev->cp.ptr_mask; |
| 1224 | rdev->cp.count_dw--; |
| 1225 | rdev->cp.ring_free_dw--; |
| 1226 | } |
| 1227 | |
| 1228 | |
| 1229 | /* |
| 1230 | * ASICs macro. |
| 1231 | */ |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 1232 | #define radeon_init(rdev) (rdev)->asic->init((rdev)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1233 | #define radeon_fini(rdev) (rdev)->asic->fini((rdev)) |
| 1234 | #define radeon_resume(rdev) (rdev)->asic->resume((rdev)) |
| 1235 | #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1236 | #define radeon_cs_parse(p) rdev->asic->cs_parse((p)) |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 1237 | #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state)) |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 1238 | #define radeon_gpu_is_lockup(rdev) (rdev)->asic->gpu_is_lockup((rdev)) |
Jerome Glisse | a2d07b7 | 2010-03-09 14:45:11 +0000 | [diff] [blame] | 1239 | #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1240 | #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev)) |
| 1241 | #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1242 | #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1243 | #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1244 | #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev)) |
| 1245 | #define radeon_ring_ib_execute(rdev, ib) (rdev)->asic->ring_ib_execute((rdev), (ib)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1246 | #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) |
| 1247 | #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 1248 | #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1249 | #define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence)) |
| 1250 | #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f)) |
| 1251 | #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f)) |
| 1252 | #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f)) |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 1253 | #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1254 | #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e)) |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 1255 | #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev)) |
Rafał Miłecki | 93e7de7 | 2009-11-04 23:34:10 +0100 | [diff] [blame] | 1256 | #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e)) |
Alex Deucher | c836a41 | 2009-12-23 10:07:50 -0500 | [diff] [blame] | 1257 | #define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1258 | #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l)) |
| 1259 | #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e)) |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 1260 | #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s))) |
| 1261 | #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r))) |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 1262 | #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev)) |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 1263 | #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev)) |
| 1264 | #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev)) |
| 1265 | #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd)) |
| 1266 | #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd)) |
Alex Deucher | def9ba9 | 2010-04-22 12:39:58 -0400 | [diff] [blame] | 1267 | #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev)) |
Alex Deucher | a424816 | 2010-04-24 14:50:23 -0400 | [diff] [blame] | 1268 | #define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev)) |
| 1269 | #define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev)) |
| 1270 | #define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev)) |
Alex Deucher | ce8f537 | 2010-05-07 15:10:16 -0400 | [diff] [blame] | 1271 | #define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev)) |
| 1272 | #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm_get_dynpm_state((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1273 | |
Jerome Glisse | 6cf8a3f5 | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 1274 | /* Common functions */ |
Jerome Glisse | 700a0cc | 2010-01-13 15:16:38 +0100 | [diff] [blame] | 1275 | /* AGP */ |
Jerome Glisse | 90aca4d | 2010-03-09 14:45:12 +0000 | [diff] [blame] | 1276 | extern int radeon_gpu_reset(struct radeon_device *rdev); |
Jerome Glisse | 700a0cc | 2010-01-13 15:16:38 +0100 | [diff] [blame] | 1277 | extern void radeon_agp_disable(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1278 | extern int radeon_gart_table_vram_pin(struct radeon_device *rdev); |
Dave Airlie | 8256856 | 2010-02-05 16:00:07 +1000 | [diff] [blame] | 1279 | extern void radeon_gart_restore(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1280 | extern int radeon_modeset_init(struct radeon_device *rdev); |
| 1281 | extern void radeon_modeset_fini(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1282 | extern bool radeon_card_posted(struct radeon_device *rdev); |
Alex Deucher | f47299c | 2010-03-16 20:54:38 -0400 | [diff] [blame] | 1283 | extern void radeon_update_bandwidth_info(struct radeon_device *rdev); |
Alex Deucher | f46c012 | 2010-03-31 00:33:27 -0400 | [diff] [blame] | 1284 | extern void radeon_update_display_priority(struct radeon_device *rdev); |
Dave Airlie | 72542d7 | 2009-12-01 14:06:31 +1000 | [diff] [blame] | 1285 | extern bool radeon_boot_test_post_card(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1286 | extern int radeon_clocks_init(struct radeon_device *rdev); |
| 1287 | extern void radeon_clocks_fini(struct radeon_device *rdev); |
| 1288 | extern void radeon_scratch_init(struct radeon_device *rdev); |
| 1289 | extern void radeon_surface_init(struct radeon_device *rdev); |
| 1290 | extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1291 | extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1292 | extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable); |
Jerome Glisse | 312ea8d | 2009-12-07 15:52:58 +0100 | [diff] [blame] | 1293 | extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain); |
Jerome Glisse | d03d858 | 2009-12-14 21:02:09 +0100 | [diff] [blame] | 1294 | extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo); |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1295 | extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base); |
| 1296 | extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 1297 | extern int radeon_resume_kms(struct drm_device *dev); |
| 1298 | extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state); |
Jerome Glisse | 6cf8a3f5 | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 1299 | |
Jerome Glisse | a18d7ea | 2009-09-09 22:23:27 +0200 | [diff] [blame] | 1300 | /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */ |
Jerome Glisse | 225758d | 2010-03-09 14:45:10 +0000 | [diff] [blame] | 1301 | extern void r100_gpu_lockup_update(struct r100_gpu_lockup *lockup, struct radeon_cp *cp); |
| 1302 | extern bool r100_gpu_cp_is_lockup(struct radeon_device *rdev, struct r100_gpu_lockup *lockup, struct radeon_cp *cp); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1303 | |
Jerome Glisse | d455090 | 2009-10-01 10:12:06 +0200 | [diff] [blame] | 1304 | /* rv200,rv250,rv280 */ |
| 1305 | extern void r200_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1306 | |
| 1307 | /* r300,r350,rv350,rv370,rv380 */ |
| 1308 | extern void r300_set_reg_safe(struct radeon_device *rdev); |
| 1309 | extern void r300_mc_program(struct radeon_device *rdev); |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1310 | extern void r300_mc_init(struct radeon_device *rdev); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1311 | extern void r300_clock_startup(struct radeon_device *rdev); |
| 1312 | extern int r300_mc_wait_for_idle(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1313 | extern int rv370_pcie_gart_init(struct radeon_device *rdev); |
| 1314 | extern void rv370_pcie_gart_fini(struct radeon_device *rdev); |
| 1315 | extern int rv370_pcie_gart_enable(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1316 | extern void rv370_pcie_gart_disable(struct radeon_device *rdev); |
Jerome Glisse | a18d7ea | 2009-09-09 22:23:27 +0200 | [diff] [blame] | 1317 | |
Jerome Glisse | 905b682 | 2009-09-09 22:24:20 +0200 | [diff] [blame] | 1318 | /* r420,r423,rv410 */ |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1319 | extern u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg); |
| 1320 | extern void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1321 | extern int r420_debugfs_pipes_info_init(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1322 | extern void r420_pipes_init(struct radeon_device *rdev); |
Jerome Glisse | 905b682 | 2009-09-09 22:24:20 +0200 | [diff] [blame] | 1323 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1324 | /* rv515 */ |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1325 | struct rv515_mc_save { |
| 1326 | u32 d1vga_control; |
| 1327 | u32 d2vga_control; |
| 1328 | u32 vga_render_control; |
| 1329 | u32 vga_hdp_control; |
| 1330 | u32 d1crtc_control; |
| 1331 | u32 d2crtc_control; |
| 1332 | }; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1333 | extern void rv515_bandwidth_avivo_update(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1334 | extern void rv515_vga_render_disable(struct radeon_device *rdev); |
| 1335 | extern void rv515_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | f0ed1f6 | 2009-09-28 20:39:19 +0200 | [diff] [blame] | 1336 | extern void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save); |
| 1337 | extern void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save); |
| 1338 | extern void rv515_clock_startup(struct radeon_device *rdev); |
| 1339 | extern void rv515_debugfs(struct radeon_device *rdev); |
| 1340 | extern int rv515_suspend(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1341 | |
Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 1342 | /* rs400 */ |
| 1343 | extern int rs400_gart_init(struct radeon_device *rdev); |
| 1344 | extern int rs400_gart_enable(struct radeon_device *rdev); |
| 1345 | extern void rs400_gart_adjust_size(struct radeon_device *rdev); |
| 1346 | extern void rs400_gart_disable(struct radeon_device *rdev); |
| 1347 | extern void rs400_gart_fini(struct radeon_device *rdev); |
| 1348 | |
| 1349 | /* rs600 */ |
| 1350 | extern void rs600_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 1351 | extern int rs600_irq_set(struct radeon_device *rdev); |
| 1352 | extern void rs600_irq_disable(struct radeon_device *rdev); |
Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 1353 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1354 | /* rs690, rs740 */ |
| 1355 | extern void rs690_line_buffer_adjust(struct radeon_device *rdev, |
| 1356 | struct drm_display_mode *mode1, |
| 1357 | struct drm_display_mode *mode2); |
| 1358 | |
| 1359 | /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */ |
Jerome Glisse | d594e46 | 2010-02-17 21:54:29 +0000 | [diff] [blame] | 1360 | extern void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1361 | extern bool r600_card_posted(struct radeon_device *rdev); |
| 1362 | extern void r600_cp_stop(struct radeon_device *rdev); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1363 | extern int r600_cp_start(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1364 | extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 1365 | extern int r600_cp_resume(struct radeon_device *rdev); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 1366 | extern void r600_cp_fini(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1367 | extern int r600_count_pipe_bits(uint32_t val); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1368 | extern int r600_mc_wait_for_idle(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1369 | extern int r600_pcie_gart_init(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1370 | extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev); |
| 1371 | extern int r600_ib_test(struct radeon_device *rdev); |
| 1372 | extern int r600_ring_test(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1373 | extern void r600_wb_fini(struct radeon_device *rdev); |
Jerome Glisse | 81cc35b | 2009-10-01 18:02:12 +0200 | [diff] [blame] | 1374 | extern int r600_wb_enable(struct radeon_device *rdev); |
| 1375 | extern void r600_wb_disable(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1376 | extern void r600_scratch_init(struct radeon_device *rdev); |
| 1377 | extern int r600_blit_init(struct radeon_device *rdev); |
| 1378 | extern void r600_blit_fini(struct radeon_device *rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1379 | extern int r600_init_microcode(struct radeon_device *rdev); |
Jerome Glisse | a2d07b7 | 2010-03-09 14:45:11 +0000 | [diff] [blame] | 1380 | extern int r600_asic_reset(struct radeon_device *rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1381 | /* r600 irq */ |
| 1382 | extern int r600_irq_init(struct radeon_device *rdev); |
| 1383 | extern void r600_irq_fini(struct radeon_device *rdev); |
| 1384 | extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 1385 | extern int r600_irq_set(struct radeon_device *rdev); |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 1386 | extern void r600_irq_suspend(struct radeon_device *rdev); |
Alex Deucher | 45f9a39 | 2010-03-24 13:55:51 -0400 | [diff] [blame] | 1387 | extern void r600_disable_interrupts(struct radeon_device *rdev); |
| 1388 | extern void r600_rlc_stop(struct radeon_device *rdev); |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 1389 | /* r600 audio */ |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1390 | extern int r600_audio_init(struct radeon_device *rdev); |
| 1391 | extern int r600_audio_tmds_index(struct drm_encoder *encoder); |
| 1392 | extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock); |
Christian König | 58bd086 | 2010-04-05 22:14:55 +0200 | [diff] [blame] | 1393 | extern int r600_audio_channels(struct radeon_device *rdev); |
| 1394 | extern int r600_audio_bits_per_sample(struct radeon_device *rdev); |
| 1395 | extern int r600_audio_rate(struct radeon_device *rdev); |
| 1396 | extern uint8_t r600_audio_status_bits(struct radeon_device *rdev); |
| 1397 | extern uint8_t r600_audio_category_code(struct radeon_device *rdev); |
Christian Koenig | f259493 | 2010-04-10 03:13:16 +0200 | [diff] [blame] | 1398 | extern void r600_audio_schedule_polling(struct radeon_device *rdev); |
Christian König | 58bd086 | 2010-04-05 22:14:55 +0200 | [diff] [blame] | 1399 | extern void r600_audio_enable_polling(struct drm_encoder *encoder); |
| 1400 | extern void r600_audio_disable_polling(struct drm_encoder *encoder); |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1401 | extern void r600_audio_fini(struct radeon_device *rdev); |
| 1402 | extern void r600_hdmi_init(struct drm_encoder *encoder); |
Rafał Miłecki | 2cd6218 | 2010-03-08 22:14:01 +0000 | [diff] [blame] | 1403 | extern void r600_hdmi_enable(struct drm_encoder *encoder); |
| 1404 | extern void r600_hdmi_disable(struct drm_encoder *encoder); |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1405 | extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode); |
| 1406 | extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder); |
Christian König | 58bd086 | 2010-04-05 22:14:55 +0200 | [diff] [blame] | 1407 | extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder); |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1408 | |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1409 | extern void r700_cp_stop(struct radeon_device *rdev); |
| 1410 | extern void r700_cp_fini(struct radeon_device *rdev); |
Alex Deucher | 0ca2ab5 | 2010-02-26 13:57:45 -0500 | [diff] [blame] | 1411 | extern void evergreen_disable_interrupt_state(struct radeon_device *rdev); |
| 1412 | extern int evergreen_irq_set(struct radeon_device *rdev); |
Alex Deucher | fe251e2 | 2010-03-24 13:36:43 -0400 | [diff] [blame] | 1413 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1414 | /* evergreen */ |
| 1415 | struct evergreen_mc_save { |
| 1416 | u32 vga_control[6]; |
| 1417 | u32 vga_render_control; |
| 1418 | u32 vga_hdp_control; |
| 1419 | u32 crtc_control[6]; |
| 1420 | }; |
| 1421 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1422 | #include "radeon_object.h" |
| 1423 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1424 | #endif |