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; |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 92 | extern int radeon_dynpm; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 93 | extern int radeon_audio; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 94 | |
| 95 | /* |
| 96 | * Copy from radeon_drv.h so we don't have to include both and have conflicting |
| 97 | * symbol; |
| 98 | */ |
| 99 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 100 | /* RADEON_IB_POOL_SIZE must be a power of 2 */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 101 | #define RADEON_IB_POOL_SIZE 16 |
| 102 | #define RADEON_DEBUGFS_MAX_NUM_FILES 32 |
| 103 | #define RADEONFB_CONN_LIMIT 4 |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 104 | #define RADEON_BIOS_NUM_SCRATCH 8 |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 105 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 106 | /* |
| 107 | * Errata workarounds. |
| 108 | */ |
| 109 | enum radeon_pll_errata { |
| 110 | CHIP_ERRATA_R300_CG = 0x00000001, |
| 111 | CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002, |
| 112 | CHIP_ERRATA_PLL_DELAY = 0x00000004 |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | struct radeon_device; |
| 117 | |
| 118 | |
| 119 | /* |
| 120 | * BIOS. |
| 121 | */ |
| 122 | bool radeon_get_bios(struct radeon_device *rdev); |
| 123 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * Dummy page |
| 127 | */ |
| 128 | struct radeon_dummy_page { |
| 129 | struct page *page; |
| 130 | dma_addr_t addr; |
| 131 | }; |
| 132 | int radeon_dummy_page_init(struct radeon_device *rdev); |
| 133 | void radeon_dummy_page_fini(struct radeon_device *rdev); |
| 134 | |
| 135 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 136 | /* |
| 137 | * Clocks |
| 138 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 139 | struct radeon_clock { |
| 140 | struct radeon_pll p1pll; |
| 141 | struct radeon_pll p2pll; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 142 | struct radeon_pll dcpll; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 143 | struct radeon_pll spll; |
| 144 | struct radeon_pll mpll; |
| 145 | /* 10 Khz units */ |
| 146 | uint32_t default_mclk; |
| 147 | uint32_t default_sclk; |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 148 | uint32_t default_dispclk; |
| 149 | uint32_t dp_extclk; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 150 | }; |
| 151 | |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 152 | /* |
| 153 | * Power management |
| 154 | */ |
| 155 | int radeon_pm_init(struct radeon_device *rdev); |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 156 | void radeon_pm_compute_clocks(struct radeon_device *rdev); |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 157 | void radeon_combios_get_power_modes(struct radeon_device *rdev); |
| 158 | void radeon_atombios_get_power_modes(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 159 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 160 | /* |
| 161 | * Fences. |
| 162 | */ |
| 163 | struct radeon_fence_driver { |
| 164 | uint32_t scratch_reg; |
| 165 | atomic_t seq; |
| 166 | uint32_t last_seq; |
| 167 | unsigned long count_timeout; |
| 168 | wait_queue_head_t queue; |
| 169 | rwlock_t lock; |
| 170 | struct list_head created; |
| 171 | struct list_head emited; |
| 172 | struct list_head signaled; |
Jerome Glisse | 0a0c759 | 2009-12-11 20:36:19 +0100 | [diff] [blame] | 173 | bool initialized; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | struct radeon_fence { |
| 177 | struct radeon_device *rdev; |
| 178 | struct kref kref; |
| 179 | struct list_head list; |
| 180 | /* protected by radeon_fence.lock */ |
| 181 | uint32_t seq; |
| 182 | unsigned long timeout; |
| 183 | bool emited; |
| 184 | bool signaled; |
| 185 | }; |
| 186 | |
| 187 | int radeon_fence_driver_init(struct radeon_device *rdev); |
| 188 | void radeon_fence_driver_fini(struct radeon_device *rdev); |
| 189 | int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence); |
| 190 | int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence); |
| 191 | void radeon_fence_process(struct radeon_device *rdev); |
| 192 | bool radeon_fence_signaled(struct radeon_fence *fence); |
| 193 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); |
| 194 | int radeon_fence_wait_next(struct radeon_device *rdev); |
| 195 | int radeon_fence_wait_last(struct radeon_device *rdev); |
| 196 | struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence); |
| 197 | void radeon_fence_unref(struct radeon_fence **fence); |
| 198 | |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 199 | /* |
| 200 | * Tiling registers |
| 201 | */ |
| 202 | struct radeon_surface_reg { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 203 | struct radeon_bo *bo; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | #define RADEON_GEM_MAX_SURFACES 8 |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 207 | |
| 208 | /* |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 209 | * TTM. |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 210 | */ |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 211 | struct radeon_mman { |
| 212 | struct ttm_bo_global_ref bo_global_ref; |
| 213 | struct ttm_global_reference mem_global_ref; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 214 | struct ttm_bo_device bdev; |
Jerome Glisse | 0a0c759 | 2009-12-11 20:36:19 +0100 | [diff] [blame] | 215 | bool mem_global_referenced; |
| 216 | bool initialized; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 217 | }; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 218 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 219 | struct radeon_bo { |
| 220 | /* Protected by gem.mutex */ |
| 221 | struct list_head list; |
| 222 | /* Protected by tbo.reserved */ |
Jerome Glisse | 312ea8d | 2009-12-07 15:52:58 +0100 | [diff] [blame] | 223 | u32 placements[3]; |
| 224 | struct ttm_placement placement; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 225 | struct ttm_buffer_object tbo; |
| 226 | struct ttm_bo_kmap_obj kmap; |
| 227 | unsigned pin_count; |
| 228 | void *kptr; |
| 229 | u32 tiling_flags; |
| 230 | u32 pitch; |
| 231 | int surface_reg; |
| 232 | /* Constant after initialization */ |
| 233 | struct radeon_device *rdev; |
| 234 | struct drm_gem_object *gobj; |
| 235 | }; |
| 236 | |
| 237 | struct radeon_bo_list { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 238 | struct list_head list; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 239 | struct radeon_bo *bo; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 240 | uint64_t gpu_offset; |
| 241 | unsigned rdomain; |
| 242 | unsigned wdomain; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 243 | u32 tiling_flags; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 244 | }; |
| 245 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 246 | /* |
| 247 | * GEM objects. |
| 248 | */ |
| 249 | struct radeon_gem { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 250 | struct mutex mutex; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 251 | struct list_head objects; |
| 252 | }; |
| 253 | |
| 254 | int radeon_gem_init(struct radeon_device *rdev); |
| 255 | void radeon_gem_fini(struct radeon_device *rdev); |
| 256 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 257 | int alignment, int initial_domain, |
| 258 | bool discardable, bool kernel, |
| 259 | struct drm_gem_object **obj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 260 | int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, |
| 261 | uint64_t *gpu_addr); |
| 262 | void radeon_gem_object_unpin(struct drm_gem_object *obj); |
| 263 | |
| 264 | |
| 265 | /* |
| 266 | * GART structures, functions & helpers |
| 267 | */ |
| 268 | struct radeon_mc; |
| 269 | |
| 270 | struct radeon_gart_table_ram { |
| 271 | volatile uint32_t *ptr; |
| 272 | }; |
| 273 | |
| 274 | struct radeon_gart_table_vram { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 275 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 276 | volatile uint32_t *ptr; |
| 277 | }; |
| 278 | |
| 279 | union radeon_gart_table { |
| 280 | struct radeon_gart_table_ram ram; |
| 281 | struct radeon_gart_table_vram vram; |
| 282 | }; |
| 283 | |
Matt Turner | a77f171 | 2009-10-14 00:34:41 -0400 | [diff] [blame] | 284 | #define RADEON_GPU_PAGE_SIZE 4096 |
| 285 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 286 | struct radeon_gart { |
| 287 | dma_addr_t table_addr; |
| 288 | unsigned num_gpu_pages; |
| 289 | unsigned num_cpu_pages; |
| 290 | unsigned table_size; |
| 291 | union radeon_gart_table table; |
| 292 | struct page **pages; |
| 293 | dma_addr_t *pages_addr; |
| 294 | bool ready; |
| 295 | }; |
| 296 | |
| 297 | int radeon_gart_table_ram_alloc(struct radeon_device *rdev); |
| 298 | void radeon_gart_table_ram_free(struct radeon_device *rdev); |
| 299 | int radeon_gart_table_vram_alloc(struct radeon_device *rdev); |
| 300 | void radeon_gart_table_vram_free(struct radeon_device *rdev); |
| 301 | int radeon_gart_init(struct radeon_device *rdev); |
| 302 | void radeon_gart_fini(struct radeon_device *rdev); |
| 303 | void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, |
| 304 | int pages); |
| 305 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, |
| 306 | int pages, struct page **pagelist); |
| 307 | |
| 308 | |
| 309 | /* |
| 310 | * GPU MC structures, functions & helpers |
| 311 | */ |
| 312 | struct radeon_mc { |
| 313 | resource_size_t aper_size; |
| 314 | resource_size_t aper_base; |
| 315 | resource_size_t agp_base; |
Dave Airlie | 7a50f01 | 2009-07-21 20:39:30 +1000 | [diff] [blame] | 316 | /* for some chips with <= 32MB we need to lie |
| 317 | * about vram size near mc fb location */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 318 | u64 mc_vram_size; |
| 319 | u64 gtt_location; |
| 320 | u64 gtt_size; |
| 321 | u64 gtt_start; |
| 322 | u64 gtt_end; |
| 323 | u64 vram_location; |
| 324 | u64 vram_start; |
| 325 | u64 vram_end; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 326 | unsigned vram_width; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 327 | u64 real_vram_size; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 328 | int vram_mtrr; |
| 329 | bool vram_is_ddr; |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 330 | bool igp_sideport_enabled; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 331 | }; |
| 332 | |
| 333 | int radeon_mc_setup(struct radeon_device *rdev); |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame] | 334 | bool radeon_combios_sideport_present(struct radeon_device *rdev); |
| 335 | bool radeon_atombios_sideport_present(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 336 | |
| 337 | /* |
| 338 | * GPU scratch registers structures, functions & helpers |
| 339 | */ |
| 340 | struct radeon_scratch { |
| 341 | unsigned num_reg; |
| 342 | bool free[32]; |
| 343 | uint32_t reg[32]; |
| 344 | }; |
| 345 | |
| 346 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg); |
| 347 | void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg); |
| 348 | |
| 349 | |
| 350 | /* |
| 351 | * IRQS. |
| 352 | */ |
| 353 | struct radeon_irq { |
| 354 | bool installed; |
| 355 | bool sw_int; |
| 356 | /* FIXME: use a define max crtc rather than hardcode it */ |
| 357 | bool crtc_vblank_int[2]; |
Rafał Miłecki | 73a6d3f | 2010-01-08 00:22:47 +0100 | [diff] [blame] | 358 | wait_queue_head_t vblank_queue; |
Alex Deucher | b500f68 | 2009-12-03 13:08:53 -0500 | [diff] [blame] | 359 | /* FIXME: use defines for max hpd/dacs */ |
| 360 | bool hpd[6]; |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 361 | spinlock_t sw_lock; |
| 362 | int sw_refcount; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 363 | }; |
| 364 | |
| 365 | int radeon_irq_kms_init(struct radeon_device *rdev); |
| 366 | void radeon_irq_kms_fini(struct radeon_device *rdev); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 367 | void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev); |
| 368 | void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 369 | |
| 370 | /* |
| 371 | * CP & ring. |
| 372 | */ |
| 373 | struct radeon_ib { |
| 374 | struct list_head list; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 375 | unsigned idx; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 376 | uint64_t gpu_addr; |
| 377 | struct radeon_fence *fence; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 378 | uint32_t *ptr; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 379 | uint32_t length_dw; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 380 | bool free; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 381 | }; |
| 382 | |
Dave Airlie | ecb114a | 2009-09-15 11:12:56 +1000 | [diff] [blame] | 383 | /* |
| 384 | * locking - |
| 385 | * mutex protects scheduled_ibs, ready, alloc_bm |
| 386 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 387 | struct radeon_ib_pool { |
| 388 | struct mutex mutex; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 389 | struct radeon_bo *robj; |
Jerome Glisse | 9f93ed3 | 2010-01-28 18:22:31 +0100 | [diff] [blame] | 390 | struct list_head bogus_ib; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 391 | struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; |
| 392 | bool ready; |
Jerome Glisse | e821767 | 2010-02-15 21:36:13 +0100 | [diff] [blame] | 393 | unsigned head_id; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | struct radeon_cp { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 397 | struct radeon_bo *ring_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 398 | volatile uint32_t *ring; |
| 399 | unsigned rptr; |
| 400 | unsigned wptr; |
| 401 | unsigned wptr_old; |
| 402 | unsigned ring_size; |
| 403 | unsigned ring_free_dw; |
| 404 | int count_dw; |
| 405 | uint64_t gpu_addr; |
| 406 | uint32_t align_mask; |
| 407 | uint32_t ptr_mask; |
| 408 | struct mutex mutex; |
| 409 | bool ready; |
| 410 | }; |
| 411 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 412 | /* |
| 413 | * R6xx+ IH ring |
| 414 | */ |
| 415 | struct r600_ih { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 416 | struct radeon_bo *ring_obj; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 417 | volatile uint32_t *ring; |
| 418 | unsigned rptr; |
| 419 | unsigned wptr; |
| 420 | unsigned wptr_old; |
| 421 | unsigned ring_size; |
| 422 | uint64_t gpu_addr; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 423 | uint32_t ptr_mask; |
| 424 | spinlock_t lock; |
| 425 | bool enabled; |
| 426 | }; |
| 427 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 428 | struct r600_blit { |
Jerome Glisse | ff82f05 | 2010-01-22 15:19:00 +0100 | [diff] [blame] | 429 | struct mutex mutex; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 430 | struct radeon_bo *shader_obj; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 431 | u64 shader_gpu_addr; |
| 432 | u32 vs_offset, ps_offset; |
| 433 | u32 state_offset; |
| 434 | u32 state_len; |
| 435 | u32 vb_used, vb_total; |
| 436 | struct radeon_ib *vb_ib; |
| 437 | }; |
| 438 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 439 | int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib); |
| 440 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); |
| 441 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); |
| 442 | int radeon_ib_pool_init(struct radeon_device *rdev); |
| 443 | void radeon_ib_pool_fini(struct radeon_device *rdev); |
| 444 | int radeon_ib_test(struct radeon_device *rdev); |
Jerome Glisse | 9f93ed3 | 2010-01-28 18:22:31 +0100 | [diff] [blame] | 445 | 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] | 446 | /* Ring access between begin & end cannot sleep */ |
| 447 | void radeon_ring_free_size(struct radeon_device *rdev); |
| 448 | int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw); |
| 449 | void radeon_ring_unlock_commit(struct radeon_device *rdev); |
| 450 | void radeon_ring_unlock_undo(struct radeon_device *rdev); |
| 451 | int radeon_ring_test(struct radeon_device *rdev); |
| 452 | int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 453 | void radeon_ring_fini(struct radeon_device *rdev); |
| 454 | |
| 455 | |
| 456 | /* |
| 457 | * CS. |
| 458 | */ |
| 459 | struct radeon_cs_reloc { |
| 460 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 461 | struct radeon_bo *robj; |
| 462 | struct radeon_bo_list lobj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 463 | uint32_t handle; |
| 464 | uint32_t flags; |
| 465 | }; |
| 466 | |
| 467 | struct radeon_cs_chunk { |
| 468 | uint32_t chunk_id; |
| 469 | uint32_t length_dw; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 470 | int kpage_idx[2]; |
| 471 | uint32_t *kpage[2]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 472 | uint32_t *kdata; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 473 | void __user *user_ptr; |
| 474 | int last_copied_page; |
| 475 | int last_page_index; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 476 | }; |
| 477 | |
| 478 | struct radeon_cs_parser { |
Jerome Glisse | c8c15ff | 2010-01-18 13:01:36 +0100 | [diff] [blame] | 479 | struct device *dev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 480 | struct radeon_device *rdev; |
| 481 | struct drm_file *filp; |
| 482 | /* chunks */ |
| 483 | unsigned nchunks; |
| 484 | struct radeon_cs_chunk *chunks; |
| 485 | uint64_t *chunks_array; |
| 486 | /* IB */ |
| 487 | unsigned idx; |
| 488 | /* relocations */ |
| 489 | unsigned nrelocs; |
| 490 | struct radeon_cs_reloc *relocs; |
| 491 | struct radeon_cs_reloc **relocs_ptr; |
| 492 | struct list_head validated; |
| 493 | /* indices of various chunks */ |
| 494 | int chunk_ib_idx; |
| 495 | int chunk_relocs_idx; |
| 496 | struct radeon_ib *ib; |
| 497 | void *track; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 498 | unsigned family; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 499 | int parser_error; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 500 | }; |
| 501 | |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 502 | extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx); |
| 503 | extern int radeon_cs_finish_pages(struct radeon_cs_parser *p); |
| 504 | |
| 505 | |
| 506 | static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx) |
| 507 | { |
| 508 | struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx]; |
| 509 | u32 pg_idx, pg_offset; |
| 510 | u32 idx_value = 0; |
| 511 | int new_page; |
| 512 | |
| 513 | pg_idx = (idx * 4) / PAGE_SIZE; |
| 514 | pg_offset = (idx * 4) % PAGE_SIZE; |
| 515 | |
| 516 | if (ibc->kpage_idx[0] == pg_idx) |
| 517 | return ibc->kpage[0][pg_offset/4]; |
| 518 | if (ibc->kpage_idx[1] == pg_idx) |
| 519 | return ibc->kpage[1][pg_offset/4]; |
| 520 | |
| 521 | new_page = radeon_cs_update_pages(p, pg_idx); |
| 522 | if (new_page < 0) { |
| 523 | p->parser_error = new_page; |
| 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | idx_value = ibc->kpage[new_page][pg_offset/4]; |
| 528 | return idx_value; |
| 529 | } |
| 530 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 531 | struct radeon_cs_packet { |
| 532 | unsigned idx; |
| 533 | unsigned type; |
| 534 | unsigned reg; |
| 535 | unsigned opcode; |
| 536 | int count; |
| 537 | unsigned one_reg_wr; |
| 538 | }; |
| 539 | |
| 540 | typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p, |
| 541 | struct radeon_cs_packet *pkt, |
| 542 | unsigned idx, unsigned reg); |
| 543 | typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p, |
| 544 | struct radeon_cs_packet *pkt); |
| 545 | |
| 546 | |
| 547 | /* |
| 548 | * AGP |
| 549 | */ |
| 550 | int radeon_agp_init(struct radeon_device *rdev); |
Dave Airlie | 0ebf171 | 2009-11-05 15:39:10 +1000 | [diff] [blame] | 551 | void radeon_agp_resume(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 552 | void radeon_agp_fini(struct radeon_device *rdev); |
| 553 | |
| 554 | |
| 555 | /* |
| 556 | * Writeback |
| 557 | */ |
| 558 | struct radeon_wb { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 559 | struct radeon_bo *wb_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 560 | volatile uint32_t *wb; |
| 561 | uint64_t gpu_addr; |
| 562 | }; |
| 563 | |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 564 | /** |
| 565 | * struct radeon_pm - power management datas |
| 566 | * @max_bandwidth: maximum bandwidth the gpu has (MByte/s) |
| 567 | * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880) |
| 568 | * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880) |
| 569 | * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880) |
| 570 | * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880) |
| 571 | * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP) |
| 572 | * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP) |
| 573 | * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP) |
| 574 | * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP) |
| 575 | * @sclk: GPU clock Mhz (core bandwith depends of this clock) |
| 576 | * @needed_bandwidth: current bandwidth needs |
| 577 | * |
| 578 | * It keeps track of various data needed to take powermanagement decision. |
| 579 | * Bandwith need is used to determine minimun clock of the GPU and memory. |
| 580 | * Equation between gpu/memory clock and available bandwidth is hw dependent |
| 581 | * (type of memory, bus size, efficiency, ...) |
| 582 | */ |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 583 | enum radeon_pm_state { |
| 584 | PM_STATE_DISABLED, |
| 585 | PM_STATE_MINIMUM, |
| 586 | PM_STATE_PAUSED, |
| 587 | PM_STATE_ACTIVE |
| 588 | }; |
| 589 | enum radeon_pm_action { |
| 590 | PM_ACTION_NONE, |
| 591 | PM_ACTION_MINIMUM, |
| 592 | PM_ACTION_DOWNCLOCK, |
| 593 | PM_ACTION_UPCLOCK |
| 594 | }; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 595 | |
| 596 | enum radeon_voltage_type { |
| 597 | VOLTAGE_NONE = 0, |
| 598 | VOLTAGE_GPIO, |
| 599 | VOLTAGE_VDDC, |
| 600 | VOLTAGE_SW |
| 601 | }; |
| 602 | |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 603 | enum radeon_pm_state_type { |
| 604 | POWER_STATE_TYPE_DEFAULT, |
| 605 | POWER_STATE_TYPE_POWERSAVE, |
| 606 | POWER_STATE_TYPE_BATTERY, |
| 607 | POWER_STATE_TYPE_BALANCED, |
| 608 | POWER_STATE_TYPE_PERFORMANCE, |
| 609 | }; |
| 610 | |
Alex Deucher | 516d0e4 | 2009-12-23 14:28:05 -0500 | [diff] [blame] | 611 | enum radeon_pm_clock_mode_type { |
| 612 | POWER_MODE_TYPE_DEFAULT, |
| 613 | POWER_MODE_TYPE_LOW, |
| 614 | POWER_MODE_TYPE_MID, |
| 615 | POWER_MODE_TYPE_HIGH, |
| 616 | }; |
| 617 | |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 618 | struct radeon_voltage { |
| 619 | enum radeon_voltage_type type; |
| 620 | /* gpio voltage */ |
| 621 | struct radeon_gpio_rec gpio; |
| 622 | u32 delay; /* delay in usec from voltage drop to sclk change */ |
| 623 | bool active_high; /* voltage drop is active when bit is high */ |
| 624 | /* VDDC voltage */ |
| 625 | u8 vddc_id; /* index into vddc voltage table */ |
| 626 | u8 vddci_id; /* index into vddci voltage table */ |
| 627 | bool vddci_enabled; |
| 628 | /* r6xx+ sw */ |
| 629 | u32 voltage; |
| 630 | }; |
| 631 | |
| 632 | struct radeon_pm_non_clock_info { |
| 633 | /* pcie lanes */ |
| 634 | int pcie_lanes; |
| 635 | /* standardized non-clock flags */ |
| 636 | u32 flags; |
| 637 | }; |
| 638 | |
| 639 | struct radeon_pm_clock_info { |
| 640 | /* memory clock */ |
| 641 | u32 mclk; |
| 642 | /* engine clock */ |
| 643 | u32 sclk; |
| 644 | /* voltage info */ |
| 645 | struct radeon_voltage voltage; |
| 646 | /* standardized clock flags - not sure we'll need these */ |
| 647 | u32 flags; |
| 648 | }; |
| 649 | |
| 650 | struct radeon_power_state { |
Alex Deucher | 0ec0e74 | 2009-12-23 13:21:58 -0500 | [diff] [blame] | 651 | enum radeon_pm_state_type type; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 652 | /* XXX: use a define for num clock modes */ |
| 653 | struct radeon_pm_clock_info clock_info[8]; |
| 654 | /* number of valid clock modes in this power state */ |
| 655 | int num_clock_modes; |
| 656 | /* currently selected clock mode */ |
| 657 | struct radeon_pm_clock_info *current_clock_mode; |
Alex Deucher | 516d0e4 | 2009-12-23 14:28:05 -0500 | [diff] [blame] | 658 | struct radeon_pm_clock_info *requested_clock_mode; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 659 | struct radeon_pm_clock_info *default_clock_mode; |
| 660 | /* non clock info about this state */ |
| 661 | struct radeon_pm_non_clock_info non_clock_info; |
| 662 | bool voltage_drop_active; |
| 663 | }; |
| 664 | |
Rafał Miłecki | 2745932 | 2010-02-11 22:16:36 +0000 | [diff] [blame^] | 665 | /* |
| 666 | * Some modes are overclocked by very low value, accept them |
| 667 | */ |
| 668 | #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */ |
| 669 | |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 670 | struct radeon_pm { |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 671 | struct mutex mutex; |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 672 | struct delayed_work idle_work; |
| 673 | enum radeon_pm_state state; |
| 674 | enum radeon_pm_action planned_action; |
| 675 | unsigned long action_timeout; |
| 676 | bool downclocked; |
Rafał Miłecki | c913e23 | 2009-12-22 23:02:16 +0100 | [diff] [blame] | 677 | int active_crtcs; |
| 678 | int req_vblank; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 679 | fixed20_12 max_bandwidth; |
| 680 | fixed20_12 igp_sideport_mclk; |
| 681 | fixed20_12 igp_system_mclk; |
| 682 | fixed20_12 igp_ht_link_clk; |
| 683 | fixed20_12 igp_ht_link_width; |
| 684 | fixed20_12 k8_bandwidth; |
| 685 | fixed20_12 sideport_bandwidth; |
| 686 | fixed20_12 ht_bandwidth; |
| 687 | fixed20_12 core_bandwidth; |
| 688 | fixed20_12 sclk; |
| 689 | fixed20_12 needed_bandwidth; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 690 | /* XXX: use a define for num power modes */ |
| 691 | struct radeon_power_state power_state[8]; |
| 692 | /* number of valid power states */ |
| 693 | int num_power_states; |
| 694 | struct radeon_power_state *current_power_state; |
Alex Deucher | 516d0e4 | 2009-12-23 14:28:05 -0500 | [diff] [blame] | 695 | struct radeon_power_state *requested_power_state; |
Alex Deucher | 56278a8 | 2009-12-28 13:58:44 -0500 | [diff] [blame] | 696 | struct radeon_power_state *default_power_state; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 697 | }; |
| 698 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 699 | |
| 700 | /* |
| 701 | * Benchmarking |
| 702 | */ |
| 703 | void radeon_benchmark(struct radeon_device *rdev); |
| 704 | |
| 705 | |
| 706 | /* |
Michel Dänzer | ecc0b32 | 2009-07-21 11:23:57 +0200 | [diff] [blame] | 707 | * Testing |
| 708 | */ |
| 709 | void radeon_test_moves(struct radeon_device *rdev); |
| 710 | |
| 711 | |
| 712 | /* |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 713 | * Debugfs |
| 714 | */ |
| 715 | int radeon_debugfs_add_files(struct radeon_device *rdev, |
| 716 | struct drm_info_list *files, |
| 717 | unsigned nfiles); |
| 718 | int radeon_debugfs_fence_init(struct radeon_device *rdev); |
| 719 | int r100_debugfs_rbbm_init(struct radeon_device *rdev); |
| 720 | int r100_debugfs_cp_init(struct radeon_device *rdev); |
| 721 | |
| 722 | |
| 723 | /* |
| 724 | * ASIC specific functions. |
| 725 | */ |
| 726 | struct radeon_asic { |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 727 | int (*init)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 728 | void (*fini)(struct radeon_device *rdev); |
| 729 | int (*resume)(struct radeon_device *rdev); |
| 730 | int (*suspend)(struct radeon_device *rdev); |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 731 | void (*vga_set_state)(struct radeon_device *rdev, bool state); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 732 | int (*gpu_reset)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 733 | void (*gart_tlb_flush)(struct radeon_device *rdev); |
| 734 | int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr); |
| 735 | int (*cp_init)(struct radeon_device *rdev, unsigned ring_size); |
| 736 | void (*cp_fini)(struct radeon_device *rdev); |
| 737 | void (*cp_disable)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 738 | void (*cp_commit)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 739 | void (*ring_start)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 740 | int (*ring_test)(struct radeon_device *rdev); |
| 741 | void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 742 | int (*irq_set)(struct radeon_device *rdev); |
| 743 | int (*irq_process)(struct radeon_device *rdev); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 744 | u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 745 | void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence); |
| 746 | int (*cs_parse)(struct radeon_cs_parser *p); |
| 747 | int (*copy_blit)(struct radeon_device *rdev, |
| 748 | uint64_t src_offset, |
| 749 | uint64_t dst_offset, |
| 750 | unsigned num_pages, |
| 751 | struct radeon_fence *fence); |
| 752 | int (*copy_dma)(struct radeon_device *rdev, |
| 753 | uint64_t src_offset, |
| 754 | uint64_t dst_offset, |
| 755 | unsigned num_pages, |
| 756 | struct radeon_fence *fence); |
| 757 | int (*copy)(struct radeon_device *rdev, |
| 758 | uint64_t src_offset, |
| 759 | uint64_t dst_offset, |
| 760 | unsigned num_pages, |
| 761 | struct radeon_fence *fence); |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 762 | uint32_t (*get_engine_clock)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 763 | 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] | 764 | uint32_t (*get_memory_clock)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 765 | void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock); |
Alex Deucher | c836a41 | 2009-12-23 10:07:50 -0500 | [diff] [blame] | 766 | int (*get_pcie_lanes)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 767 | void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes); |
| 768 | void (*set_clock_gating)(struct radeon_device *rdev, int enable); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 769 | int (*set_surface_reg)(struct radeon_device *rdev, int reg, |
| 770 | uint32_t tiling_flags, uint32_t pitch, |
| 771 | uint32_t offset, uint32_t obj_size); |
| 772 | int (*clear_surface_reg)(struct radeon_device *rdev, int reg); |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 773 | void (*bandwidth_update)(struct radeon_device *rdev); |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 774 | void (*hpd_init)(struct radeon_device *rdev); |
| 775 | void (*hpd_fini)(struct radeon_device *rdev); |
| 776 | bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd); |
| 777 | 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] | 778 | /* ioctl hw specific callback. Some hw might want to perform special |
| 779 | * operation on specific ioctl. For instance on wait idle some hw |
| 780 | * might want to perform and HDP flush through MMIO as it seems that |
| 781 | * some R6XX/R7XX hw doesn't take HDP flush into account if programmed |
| 782 | * through ring. |
| 783 | */ |
| 784 | void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 785 | }; |
| 786 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 787 | /* |
| 788 | * Asic structures |
| 789 | */ |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 790 | struct r100_asic { |
| 791 | const unsigned *reg_safe_bm; |
| 792 | unsigned reg_safe_bm_size; |
Jerome Glisse | cafe660 | 2010-01-07 12:39:21 +0100 | [diff] [blame] | 793 | u32 hdp_cntl; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 794 | }; |
| 795 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 796 | struct r300_asic { |
| 797 | const unsigned *reg_safe_bm; |
| 798 | unsigned reg_safe_bm_size; |
Corbin Simpson | 62cdc0c | 2010-01-06 19:28:48 +0100 | [diff] [blame] | 799 | u32 resync_scratch; |
Jerome Glisse | cafe660 | 2010-01-07 12:39:21 +0100 | [diff] [blame] | 800 | u32 hdp_cntl; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 801 | }; |
| 802 | |
| 803 | struct r600_asic { |
| 804 | unsigned max_pipes; |
| 805 | unsigned max_tile_pipes; |
| 806 | unsigned max_simds; |
| 807 | unsigned max_backends; |
| 808 | unsigned max_gprs; |
| 809 | unsigned max_threads; |
| 810 | unsigned max_stack_entries; |
| 811 | unsigned max_hw_contexts; |
| 812 | unsigned max_gs_threads; |
| 813 | unsigned sx_max_export_size; |
| 814 | unsigned sx_max_export_pos_size; |
| 815 | unsigned sx_max_export_smx_size; |
| 816 | unsigned sq_num_cf_insts; |
Jerome Glisse | 961fb59 | 2010-02-10 22:30:05 +0000 | [diff] [blame] | 817 | unsigned tiling_nbanks; |
| 818 | unsigned tiling_npipes; |
| 819 | unsigned tiling_group_size; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 820 | }; |
| 821 | |
| 822 | struct rv770_asic { |
| 823 | unsigned max_pipes; |
| 824 | unsigned max_tile_pipes; |
| 825 | unsigned max_simds; |
| 826 | unsigned max_backends; |
| 827 | unsigned max_gprs; |
| 828 | unsigned max_threads; |
| 829 | unsigned max_stack_entries; |
| 830 | unsigned max_hw_contexts; |
| 831 | unsigned max_gs_threads; |
| 832 | unsigned sx_max_export_size; |
| 833 | unsigned sx_max_export_pos_size; |
| 834 | unsigned sx_max_export_smx_size; |
| 835 | unsigned sq_num_cf_insts; |
| 836 | unsigned sx_num_of_sets; |
| 837 | unsigned sc_prim_fifo_size; |
| 838 | unsigned sc_hiz_tile_fifo_size; |
| 839 | unsigned sc_earlyz_tile_fifo_fize; |
Jerome Glisse | 961fb59 | 2010-02-10 22:30:05 +0000 | [diff] [blame] | 840 | unsigned tiling_nbanks; |
| 841 | unsigned tiling_npipes; |
| 842 | unsigned tiling_group_size; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 843 | }; |
| 844 | |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 845 | union radeon_asic_config { |
| 846 | struct r300_asic r300; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 847 | struct r100_asic r100; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 848 | struct r600_asic r600; |
| 849 | struct rv770_asic rv770; |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 850 | }; |
| 851 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 852 | |
| 853 | /* |
| 854 | * IOCTL. |
| 855 | */ |
| 856 | int radeon_gem_info_ioctl(struct drm_device *dev, void *data, |
| 857 | struct drm_file *filp); |
| 858 | int radeon_gem_create_ioctl(struct drm_device *dev, void *data, |
| 859 | struct drm_file *filp); |
| 860 | int radeon_gem_pin_ioctl(struct drm_device *dev, void *data, |
| 861 | struct drm_file *file_priv); |
| 862 | int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data, |
| 863 | struct drm_file *file_priv); |
| 864 | int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data, |
| 865 | struct drm_file *file_priv); |
| 866 | int radeon_gem_pread_ioctl(struct drm_device *dev, void *data, |
| 867 | struct drm_file *file_priv); |
| 868 | int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, |
| 869 | struct drm_file *filp); |
| 870 | int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, |
| 871 | struct drm_file *filp); |
| 872 | int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, |
| 873 | struct drm_file *filp); |
| 874 | int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, |
| 875 | struct drm_file *filp); |
| 876 | 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] | 877 | int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, |
| 878 | struct drm_file *filp); |
| 879 | int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, |
| 880 | struct drm_file *filp); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 881 | |
| 882 | |
| 883 | /* |
| 884 | * Core structure, functions and helpers. |
| 885 | */ |
| 886 | typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); |
| 887 | typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t); |
| 888 | |
| 889 | struct radeon_device { |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 890 | struct device *dev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 891 | struct drm_device *ddev; |
| 892 | struct pci_dev *pdev; |
| 893 | /* ASIC */ |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 894 | union radeon_asic_config config; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 895 | enum radeon_family family; |
| 896 | unsigned long flags; |
| 897 | int usec_timeout; |
| 898 | enum radeon_pll_errata pll_errata; |
| 899 | int num_gb_pipes; |
Alex Deucher | f779b3e | 2009-08-19 19:11:39 -0400 | [diff] [blame] | 900 | int num_z_pipes; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 901 | int disp_priority; |
| 902 | /* BIOS */ |
| 903 | uint8_t *bios; |
| 904 | bool is_atom_bios; |
| 905 | uint16_t bios_header_start; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 906 | struct radeon_bo *stollen_vga_memory; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 907 | struct fb_info *fbdev_info; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 908 | struct radeon_bo *fbdev_rbo; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 909 | struct radeon_framebuffer *fbdev_rfb; |
| 910 | /* Register mmio */ |
Dave Airlie | 4c9bc75 | 2009-06-29 18:29:12 +1000 | [diff] [blame] | 911 | resource_size_t rmmio_base; |
| 912 | resource_size_t rmmio_size; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 913 | void *rmmio; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 914 | radeon_rreg_t mc_rreg; |
| 915 | radeon_wreg_t mc_wreg; |
| 916 | radeon_rreg_t pll_rreg; |
| 917 | radeon_wreg_t pll_wreg; |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 918 | uint32_t pcie_reg_mask; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 919 | radeon_rreg_t pciep_rreg; |
| 920 | radeon_wreg_t pciep_wreg; |
| 921 | struct radeon_clock clock; |
| 922 | struct radeon_mc mc; |
| 923 | struct radeon_gart gart; |
| 924 | struct radeon_mode_info mode_info; |
| 925 | struct radeon_scratch scratch; |
| 926 | struct radeon_mman mman; |
| 927 | struct radeon_fence_driver fence_drv; |
| 928 | struct radeon_cp cp; |
| 929 | struct radeon_ib_pool ib_pool; |
| 930 | struct radeon_irq irq; |
| 931 | struct radeon_asic *asic; |
| 932 | struct radeon_gem gem; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 933 | struct radeon_pm pm; |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 934 | uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 935 | struct mutex cs_mutex; |
| 936 | struct radeon_wb wb; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 937 | struct radeon_dummy_page dummy_page; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 938 | bool gpu_lockup; |
| 939 | bool shutdown; |
| 940 | bool suspend; |
Dave Airlie | ad49f50 | 2009-07-10 22:36:26 +1000 | [diff] [blame] | 941 | bool need_dma32; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 942 | bool accel_working; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 943 | struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 944 | const struct firmware *me_fw; /* all family ME firmware */ |
| 945 | const struct firmware *pfp_fw; /* r6/700 PFP firmware */ |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 946 | const struct firmware *rlc_fw; /* r6/700 RLC firmware */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 947 | struct r600_blit r600_blit; |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 948 | int msi_enabled; /* msi enabled */ |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 949 | struct r600_ih ih; /* r6/700 interrupt ring */ |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 950 | struct workqueue_struct *wq; |
| 951 | struct work_struct hotplug_work; |
Alex Deucher | 18917b6 | 2010-02-01 16:02:25 -0500 | [diff] [blame] | 952 | int num_crtc; /* number of crtcs */ |
Alex Deucher | 40bacf1 | 2009-12-23 03:23:21 -0500 | [diff] [blame] | 953 | struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */ |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 954 | |
| 955 | /* audio stuff */ |
| 956 | struct timer_list audio_timer; |
| 957 | int audio_channels; |
| 958 | int audio_rate; |
| 959 | int audio_bits_per_sample; |
| 960 | uint8_t audio_status_bits; |
| 961 | uint8_t audio_category_code; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 962 | }; |
| 963 | |
| 964 | int radeon_device_init(struct radeon_device *rdev, |
| 965 | struct drm_device *ddev, |
| 966 | struct pci_dev *pdev, |
| 967 | uint32_t flags); |
| 968 | void radeon_device_fini(struct radeon_device *rdev); |
| 969 | int radeon_gpu_wait_for_idle(struct radeon_device *rdev); |
| 970 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 971 | /* r600 blit */ |
| 972 | int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes); |
| 973 | void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence); |
| 974 | void r600_kms_blit_copy(struct radeon_device *rdev, |
| 975 | u64 src_gpu_addr, u64 dst_gpu_addr, |
| 976 | int size_bytes); |
| 977 | |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 978 | static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg) |
| 979 | { |
Alex Deucher | 07bec2d | 2010-01-13 19:09:12 -0500 | [diff] [blame] | 980 | if (reg < rdev->rmmio_size) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 981 | return readl(((void __iomem *)rdev->rmmio) + reg); |
| 982 | else { |
| 983 | writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX); |
| 984 | return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 989 | { |
Alex Deucher | 07bec2d | 2010-01-13 19:09:12 -0500 | [diff] [blame] | 990 | if (reg < rdev->rmmio_size) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 991 | writel(v, ((void __iomem *)rdev->rmmio) + reg); |
| 992 | else { |
| 993 | writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX); |
| 994 | writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA); |
| 995 | } |
| 996 | } |
| 997 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 998 | /* |
| 999 | * Cast helper |
| 1000 | */ |
| 1001 | #define to_radeon_fence(p) ((struct radeon_fence *)(p)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1002 | |
| 1003 | /* |
| 1004 | * Registers read & write functions. |
| 1005 | */ |
| 1006 | #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) |
| 1007 | #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1008 | #define RREG32(reg) r100_mm_rreg(rdev, (reg)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1009 | #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] | 1010 | #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1011 | #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
| 1012 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
| 1013 | #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg)) |
| 1014 | #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v)) |
| 1015 | #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg)) |
| 1016 | #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v)) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1017 | #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg)) |
| 1018 | #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1019 | #define WREG32_P(reg, val, mask) \ |
| 1020 | do { \ |
| 1021 | uint32_t tmp_ = RREG32(reg); \ |
| 1022 | tmp_ &= (mask); \ |
| 1023 | tmp_ |= ((val) & ~(mask)); \ |
| 1024 | WREG32(reg, tmp_); \ |
| 1025 | } while (0) |
| 1026 | #define WREG32_PLL_P(reg, val, mask) \ |
| 1027 | do { \ |
| 1028 | uint32_t tmp_ = RREG32_PLL(reg); \ |
| 1029 | tmp_ &= (mask); \ |
| 1030 | tmp_ |= ((val) & ~(mask)); \ |
| 1031 | WREG32_PLL(reg, tmp_); \ |
| 1032 | } while (0) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1033 | #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] | 1034 | |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 1035 | /* |
| 1036 | * Indirect registers accessor |
| 1037 | */ |
| 1038 | static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) |
| 1039 | { |
| 1040 | uint32_t r; |
| 1041 | |
| 1042 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
| 1043 | r = RREG32(RADEON_PCIE_DATA); |
| 1044 | return r; |
| 1045 | } |
| 1046 | |
| 1047 | static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 1048 | { |
| 1049 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
| 1050 | WREG32(RADEON_PCIE_DATA, (v)); |
| 1051 | } |
| 1052 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1053 | void r100_pll_errata_after_index(struct radeon_device *rdev); |
| 1054 | |
| 1055 | |
| 1056 | /* |
| 1057 | * ASICs helpers. |
| 1058 | */ |
Dave Airlie | b995e43 | 2009-07-14 02:02:32 +1000 | [diff] [blame] | 1059 | #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \ |
| 1060 | (rdev->pdev->device == 0x5969)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1061 | #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \ |
| 1062 | (rdev->family == CHIP_RV200) || \ |
| 1063 | (rdev->family == CHIP_RS100) || \ |
| 1064 | (rdev->family == CHIP_RS200) || \ |
| 1065 | (rdev->family == CHIP_RV250) || \ |
| 1066 | (rdev->family == CHIP_RV280) || \ |
| 1067 | (rdev->family == CHIP_RS300)) |
| 1068 | #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \ |
| 1069 | (rdev->family == CHIP_RV350) || \ |
| 1070 | (rdev->family == CHIP_R350) || \ |
| 1071 | (rdev->family == CHIP_RV380) || \ |
| 1072 | (rdev->family == CHIP_R420) || \ |
| 1073 | (rdev->family == CHIP_R423) || \ |
| 1074 | (rdev->family == CHIP_RV410) || \ |
| 1075 | (rdev->family == CHIP_RS400) || \ |
| 1076 | (rdev->family == CHIP_RS480)) |
| 1077 | #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600)) |
| 1078 | #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620)) |
| 1079 | #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730)) |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1080 | #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1081 | |
| 1082 | /* |
| 1083 | * BIOS helpers. |
| 1084 | */ |
| 1085 | #define RBIOS8(i) (rdev->bios[i]) |
| 1086 | #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8)) |
| 1087 | #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16)) |
| 1088 | |
| 1089 | int radeon_combios_init(struct radeon_device *rdev); |
| 1090 | void radeon_combios_fini(struct radeon_device *rdev); |
| 1091 | int radeon_atombios_init(struct radeon_device *rdev); |
| 1092 | void radeon_atombios_fini(struct radeon_device *rdev); |
| 1093 | |
| 1094 | |
| 1095 | /* |
| 1096 | * RING helpers. |
| 1097 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1098 | static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) |
| 1099 | { |
| 1100 | #if DRM_DEBUG_CODE |
| 1101 | if (rdev->cp.count_dw <= 0) { |
| 1102 | DRM_ERROR("radeon: writting more dword to ring than expected !\n"); |
| 1103 | } |
| 1104 | #endif |
| 1105 | rdev->cp.ring[rdev->cp.wptr++] = v; |
| 1106 | rdev->cp.wptr &= rdev->cp.ptr_mask; |
| 1107 | rdev->cp.count_dw--; |
| 1108 | rdev->cp.ring_free_dw--; |
| 1109 | } |
| 1110 | |
| 1111 | |
| 1112 | /* |
| 1113 | * ASICs macro. |
| 1114 | */ |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 1115 | #define radeon_init(rdev) (rdev)->asic->init((rdev)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1116 | #define radeon_fini(rdev) (rdev)->asic->fini((rdev)) |
| 1117 | #define radeon_resume(rdev) (rdev)->asic->resume((rdev)) |
| 1118 | #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1119 | #define radeon_cs_parse(p) rdev->asic->cs_parse((p)) |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 1120 | #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1121 | #define radeon_gpu_reset(rdev) (rdev)->asic->gpu_reset((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1122 | #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev)) |
| 1123 | #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] | 1124 | #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1125 | #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 1126 | #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev)) |
| 1127 | #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] | 1128 | #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) |
| 1129 | #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 1130 | #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] | 1131 | #define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence)) |
| 1132 | #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f)) |
| 1133 | #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f)) |
| 1134 | #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] | 1135 | #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1136 | #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] | 1137 | #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] | 1138 | #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] | 1139 | #define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1140 | #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l)) |
| 1141 | #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] | 1142 | #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s))) |
| 1143 | #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] | 1144 | #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev)) |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 1145 | #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev)) |
| 1146 | #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev)) |
| 1147 | #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd)) |
| 1148 | #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1149 | |
Jerome Glisse | 6cf8a3f5 | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 1150 | /* Common functions */ |
Jerome Glisse | 700a0cc | 2010-01-13 15:16:38 +0100 | [diff] [blame] | 1151 | /* AGP */ |
| 1152 | extern void radeon_agp_disable(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1153 | extern int radeon_gart_table_vram_pin(struct radeon_device *rdev); |
Dave Airlie | 8256856 | 2010-02-05 16:00:07 +1000 | [diff] [blame] | 1154 | extern void radeon_gart_restore(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1155 | extern int radeon_modeset_init(struct radeon_device *rdev); |
| 1156 | extern void radeon_modeset_fini(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1157 | extern bool radeon_card_posted(struct radeon_device *rdev); |
Dave Airlie | 72542d7 | 2009-12-01 14:06:31 +1000 | [diff] [blame] | 1158 | extern bool radeon_boot_test_post_card(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1159 | extern int radeon_clocks_init(struct radeon_device *rdev); |
| 1160 | extern void radeon_clocks_fini(struct radeon_device *rdev); |
| 1161 | extern void radeon_scratch_init(struct radeon_device *rdev); |
| 1162 | extern void radeon_surface_init(struct radeon_device *rdev); |
| 1163 | 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] | 1164 | 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] | 1165 | 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] | 1166 | 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] | 1167 | extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo); |
Jerome Glisse | 6cf8a3f5 | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 1168 | |
Jerome Glisse | a18d7ea | 2009-09-09 22:23:27 +0200 | [diff] [blame] | 1169 | /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */ |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1170 | struct r100_mc_save { |
| 1171 | u32 GENMO_WT; |
| 1172 | u32 CRTC_EXT_CNTL; |
| 1173 | u32 CRTC_GEN_CNTL; |
| 1174 | u32 CRTC2_GEN_CNTL; |
| 1175 | u32 CUR_OFFSET; |
| 1176 | u32 CUR2_OFFSET; |
| 1177 | }; |
| 1178 | extern void r100_cp_disable(struct radeon_device *rdev); |
| 1179 | extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size); |
| 1180 | extern void r100_cp_fini(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1181 | extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1182 | extern int r100_pci_gart_init(struct radeon_device *rdev); |
| 1183 | extern void r100_pci_gart_fini(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1184 | extern int r100_pci_gart_enable(struct radeon_device *rdev); |
| 1185 | extern void r100_pci_gart_disable(struct radeon_device *rdev); |
| 1186 | extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1187 | extern int r100_debugfs_mc_info_init(struct radeon_device *rdev); |
| 1188 | extern int r100_gui_wait_for_idle(struct radeon_device *rdev); |
| 1189 | extern void r100_ib_fini(struct radeon_device *rdev); |
| 1190 | extern int r100_ib_init(struct radeon_device *rdev); |
| 1191 | extern void r100_irq_disable(struct radeon_device *rdev); |
| 1192 | extern int r100_irq_set(struct radeon_device *rdev); |
| 1193 | extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save); |
| 1194 | extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1195 | extern void r100_vram_init_sizes(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1196 | extern void r100_wb_disable(struct radeon_device *rdev); |
| 1197 | extern void r100_wb_fini(struct radeon_device *rdev); |
| 1198 | extern int r100_wb_init(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1199 | extern void r100_hdp_reset(struct radeon_device *rdev); |
| 1200 | extern int r100_rb2d_reset(struct radeon_device *rdev); |
| 1201 | extern int r100_cp_reset(struct radeon_device *rdev); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1202 | extern void r100_vga_render_disable(struct radeon_device *rdev); |
Jerome Glisse | 207bf9e | 2009-09-30 15:35:32 +0200 | [diff] [blame] | 1203 | extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p, |
| 1204 | struct radeon_cs_packet *pkt, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1205 | struct radeon_bo *robj); |
Jerome Glisse | 207bf9e | 2009-09-30 15:35:32 +0200 | [diff] [blame] | 1206 | extern int r100_cs_parse_packet0(struct radeon_cs_parser *p, |
| 1207 | struct radeon_cs_packet *pkt, |
| 1208 | const unsigned *auth, unsigned n, |
| 1209 | radeon_packet0_check_t check); |
| 1210 | extern int r100_cs_packet_parse(struct radeon_cs_parser *p, |
| 1211 | struct radeon_cs_packet *pkt, |
| 1212 | unsigned idx); |
Dave Airlie | 17e15b0 | 2009-11-05 15:36:53 +1000 | [diff] [blame] | 1213 | extern void r100_enable_bm(struct radeon_device *rdev); |
Alex Deucher | 92cde00 | 2009-12-04 10:55:12 -0500 | [diff] [blame] | 1214 | extern void r100_set_common_regs(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1215 | |
Jerome Glisse | d455090 | 2009-10-01 10:12:06 +0200 | [diff] [blame] | 1216 | /* rv200,rv250,rv280 */ |
| 1217 | extern void r200_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1218 | |
| 1219 | /* r300,r350,rv350,rv370,rv380 */ |
| 1220 | extern void r300_set_reg_safe(struct radeon_device *rdev); |
| 1221 | extern void r300_mc_program(struct radeon_device *rdev); |
| 1222 | extern void r300_vram_info(struct radeon_device *rdev); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1223 | extern void r300_clock_startup(struct radeon_device *rdev); |
| 1224 | extern int r300_mc_wait_for_idle(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1225 | extern int rv370_pcie_gart_init(struct radeon_device *rdev); |
| 1226 | extern void rv370_pcie_gart_fini(struct radeon_device *rdev); |
| 1227 | extern int rv370_pcie_gart_enable(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1228 | extern void rv370_pcie_gart_disable(struct radeon_device *rdev); |
Jerome Glisse | a18d7ea | 2009-09-09 22:23:27 +0200 | [diff] [blame] | 1229 | |
Jerome Glisse | 905b682 | 2009-09-09 22:24:20 +0200 | [diff] [blame] | 1230 | /* r420,r423,rv410 */ |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1231 | extern int r420_mc_init(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1232 | extern u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg); |
| 1233 | 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] | 1234 | extern int r420_debugfs_pipes_info_init(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1235 | extern void r420_pipes_init(struct radeon_device *rdev); |
Jerome Glisse | 905b682 | 2009-09-09 22:24:20 +0200 | [diff] [blame] | 1236 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1237 | /* rv515 */ |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1238 | struct rv515_mc_save { |
| 1239 | u32 d1vga_control; |
| 1240 | u32 d2vga_control; |
| 1241 | u32 vga_render_control; |
| 1242 | u32 vga_hdp_control; |
| 1243 | u32 d1crtc_control; |
| 1244 | u32 d2crtc_control; |
| 1245 | }; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1246 | extern void rv515_bandwidth_avivo_update(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1247 | extern void rv515_vga_render_disable(struct radeon_device *rdev); |
| 1248 | extern void rv515_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | f0ed1f6 | 2009-09-28 20:39:19 +0200 | [diff] [blame] | 1249 | extern void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save); |
| 1250 | extern void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save); |
| 1251 | extern void rv515_clock_startup(struct radeon_device *rdev); |
| 1252 | extern void rv515_debugfs(struct radeon_device *rdev); |
| 1253 | extern int rv515_suspend(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1254 | |
Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 1255 | /* rs400 */ |
| 1256 | extern int rs400_gart_init(struct radeon_device *rdev); |
| 1257 | extern int rs400_gart_enable(struct radeon_device *rdev); |
| 1258 | extern void rs400_gart_adjust_size(struct radeon_device *rdev); |
| 1259 | extern void rs400_gart_disable(struct radeon_device *rdev); |
| 1260 | extern void rs400_gart_fini(struct radeon_device *rdev); |
| 1261 | |
| 1262 | /* rs600 */ |
| 1263 | extern void rs600_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 1264 | extern int rs600_irq_set(struct radeon_device *rdev); |
| 1265 | extern void rs600_irq_disable(struct radeon_device *rdev); |
Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 1266 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1267 | /* rs690, rs740 */ |
| 1268 | extern void rs690_line_buffer_adjust(struct radeon_device *rdev, |
| 1269 | struct drm_display_mode *mode1, |
| 1270 | struct drm_display_mode *mode2); |
| 1271 | |
| 1272 | /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */ |
| 1273 | extern bool r600_card_posted(struct radeon_device *rdev); |
| 1274 | extern void r600_cp_stop(struct radeon_device *rdev); |
| 1275 | extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 1276 | extern int r600_cp_resume(struct radeon_device *rdev); |
Jerome Glisse | 655efd3 | 2010-02-02 11:51:45 +0100 | [diff] [blame] | 1277 | extern void r600_cp_fini(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1278 | extern int r600_count_pipe_bits(uint32_t val); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1279 | extern int r600_mc_wait_for_idle(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1280 | extern int r600_pcie_gart_init(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1281 | extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev); |
| 1282 | extern int r600_ib_test(struct radeon_device *rdev); |
| 1283 | extern int r600_ring_test(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1284 | extern void r600_wb_fini(struct radeon_device *rdev); |
Jerome Glisse | 81cc35b | 2009-10-01 18:02:12 +0200 | [diff] [blame] | 1285 | extern int r600_wb_enable(struct radeon_device *rdev); |
| 1286 | extern void r600_wb_disable(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1287 | extern void r600_scratch_init(struct radeon_device *rdev); |
| 1288 | extern int r600_blit_init(struct radeon_device *rdev); |
| 1289 | extern void r600_blit_fini(struct radeon_device *rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1290 | extern int r600_init_microcode(struct radeon_device *rdev); |
Dave Airlie | fe62e1a | 2009-09-21 14:06:30 +1000 | [diff] [blame] | 1291 | extern int r600_gpu_reset(struct radeon_device *rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1292 | /* r600 irq */ |
| 1293 | extern int r600_irq_init(struct radeon_device *rdev); |
| 1294 | extern void r600_irq_fini(struct radeon_device *rdev); |
| 1295 | extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 1296 | extern int r600_irq_set(struct radeon_device *rdev); |
Jerome Glisse | 0c45249 | 2010-01-15 14:44:37 +0100 | [diff] [blame] | 1297 | extern void r600_irq_suspend(struct radeon_device *rdev); |
| 1298 | /* r600 audio */ |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1299 | extern int r600_audio_init(struct radeon_device *rdev); |
| 1300 | extern int r600_audio_tmds_index(struct drm_encoder *encoder); |
| 1301 | extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock); |
| 1302 | extern void r600_audio_fini(struct radeon_device *rdev); |
| 1303 | extern void r600_hdmi_init(struct drm_encoder *encoder); |
| 1304 | extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable); |
| 1305 | extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode); |
| 1306 | extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder); |
| 1307 | extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder, |
| 1308 | int channels, |
| 1309 | int rate, |
| 1310 | int bps, |
| 1311 | uint8_t status_bits, |
| 1312 | uint8_t category_code); |
| 1313 | |
Alex Deucher | bcc1c2a | 2010-01-12 17:54:34 -0500 | [diff] [blame] | 1314 | /* evergreen */ |
| 1315 | struct evergreen_mc_save { |
| 1316 | u32 vga_control[6]; |
| 1317 | u32 vga_render_control; |
| 1318 | u32 vga_hdp_control; |
| 1319 | u32 crtc_control[6]; |
| 1320 | }; |
| 1321 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1322 | #include "radeon_object.h" |
| 1323 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1324 | #endif |