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