xref: /linux/drivers/gpu/drm/radeon/radeon_drv.h (revision 70ba2a374704e00df8868a7ac3d7350329d28924)
1c0e09200SDave Airlie /* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
2c0e09200SDave Airlie  *
3c0e09200SDave Airlie  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
4c0e09200SDave Airlie  * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
5c0e09200SDave Airlie  * All rights reserved.
6c0e09200SDave Airlie  *
7c0e09200SDave Airlie  * Permission is hereby granted, free of charge, to any person obtaining a
8c0e09200SDave Airlie  * copy of this software and associated documentation files (the "Software"),
9c0e09200SDave Airlie  * to deal in the Software without restriction, including without limitation
10c0e09200SDave Airlie  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11c0e09200SDave Airlie  * and/or sell copies of the Software, and to permit persons to whom the
12c0e09200SDave Airlie  * Software is furnished to do so, subject to the following conditions:
13c0e09200SDave Airlie  *
14c0e09200SDave Airlie  * The above copyright notice and this permission notice (including the next
15c0e09200SDave Airlie  * paragraph) shall be included in all copies or substantial portions of the
16c0e09200SDave Airlie  * Software.
17c0e09200SDave Airlie  *
18c0e09200SDave Airlie  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19c0e09200SDave Airlie  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20c0e09200SDave Airlie  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21c0e09200SDave Airlie  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22c0e09200SDave Airlie  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23c0e09200SDave Airlie  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24c0e09200SDave Airlie  * DEALINGS IN THE SOFTWARE.
25c0e09200SDave Airlie  *
26c0e09200SDave Airlie  * Authors:
27c0e09200SDave Airlie  *    Kevin E. Martin <martin@valinux.com>
28c0e09200SDave Airlie  *    Gareth Hughes <gareth@valinux.com>
29c0e09200SDave Airlie  */
30c0e09200SDave Airlie 
31c0e09200SDave Airlie #ifndef __RADEON_DRV_H__
32c0e09200SDave Airlie #define __RADEON_DRV_H__
33c0e09200SDave Airlie 
3470967ab9SBen Hutchings #include <linux/firmware.h>
3570967ab9SBen Hutchings #include <linux/platform_device.h>
3670967ab9SBen Hutchings 
37c0e09200SDave Airlie /* General customization:
38c0e09200SDave Airlie  */
39c0e09200SDave Airlie 
40c0e09200SDave Airlie #define DRIVER_AUTHOR		"Gareth Hughes, Keith Whitwell, others."
41c0e09200SDave Airlie 
42c0e09200SDave Airlie #define DRIVER_NAME		"radeon"
43c0e09200SDave Airlie #define DRIVER_DESC		"ATI Radeon"
44c0e09200SDave Airlie #define DRIVER_DATE		"20080528"
45c0e09200SDave Airlie 
46c0e09200SDave Airlie /* Interface history:
47c0e09200SDave Airlie  *
48c0e09200SDave Airlie  * 1.1 - ??
49c0e09200SDave Airlie  * 1.2 - Add vertex2 ioctl (keith)
50c0e09200SDave Airlie  *     - Add stencil capability to clear ioctl (gareth, keith)
51c0e09200SDave Airlie  *     - Increase MAX_TEXTURE_LEVELS (brian)
52c0e09200SDave Airlie  * 1.3 - Add cmdbuf ioctl (keith)
53c0e09200SDave Airlie  *     - Add support for new radeon packets (keith)
54c0e09200SDave Airlie  *     - Add getparam ioctl (keith)
55c0e09200SDave Airlie  *     - Add flip-buffers ioctl, deprecate fullscreen foo (keith).
56c0e09200SDave Airlie  * 1.4 - Add scratch registers to get_param ioctl.
57c0e09200SDave Airlie  * 1.5 - Add r200 packets to cmdbuf ioctl
58c0e09200SDave Airlie  *     - Add r200 function to init ioctl
59c0e09200SDave Airlie  *     - Add 'scalar2' instruction to cmdbuf
60c0e09200SDave Airlie  * 1.6 - Add static GART memory manager
61c0e09200SDave Airlie  *       Add irq handler (won't be turned on unless X server knows to)
62c0e09200SDave Airlie  *       Add irq ioctls and irq_active getparam.
63c0e09200SDave Airlie  *       Add wait command for cmdbuf ioctl
64c0e09200SDave Airlie  *       Add GART offset query for getparam
65c0e09200SDave Airlie  * 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5]
66c0e09200SDave Airlie  *       and R200_PP_CUBIC_OFFSET_F1_[0..5].
67c0e09200SDave Airlie  *       Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
68c0e09200SDave Airlie  *       R200_EMIT_PP_CUBIC_OFFSETS_[0..5].  (brian)
69c0e09200SDave Airlie  * 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
70c0e09200SDave Airlie  *       Add 'GET' queries for starting additional clients on different VT's.
71c0e09200SDave Airlie  * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl.
72c0e09200SDave Airlie  *       Add texture rectangle support for r100.
73c0e09200SDave Airlie  * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which
74c0e09200SDave Airlie  *       clients use to tell the DRM where they think the framebuffer is
75c0e09200SDave Airlie  *       located in the card's address space
76c0e09200SDave Airlie  * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color
77c0e09200SDave Airlie  *       and GL_EXT_blend_[func|equation]_separate on r200
78c0e09200SDave Airlie  * 1.12- Add R300 CP microcode support - this just loads the CP on r300
79c0e09200SDave Airlie  *       (No 3D support yet - just microcode loading).
80c0e09200SDave Airlie  * 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters
81c0e09200SDave Airlie  *     - Add hyperz support, add hyperz flags to clear ioctl.
82c0e09200SDave Airlie  * 1.14- Add support for color tiling
83c0e09200SDave Airlie  *     - Add R100/R200 surface allocation/free support
84c0e09200SDave Airlie  * 1.15- Add support for texture micro tiling
85c0e09200SDave Airlie  *     - Add support for r100 cube maps
86c0e09200SDave Airlie  * 1.16- Add R200_EMIT_PP_TRI_PERF_CNTL packet to support brilinear
87c0e09200SDave Airlie  *       texture filtering on r200
88c0e09200SDave Airlie  * 1.17- Add initial support for R300 (3D).
89c0e09200SDave Airlie  * 1.18- Add support for GL_ATI_fragment_shader, new packets
90c0e09200SDave Airlie  *       R200_EMIT_PP_AFS_0/1, R200_EMIT_PP_TXCTLALL_0-5 (replaces
91c0e09200SDave Airlie  *       R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and R200_EMIT_ATF_TFACTOR
92c0e09200SDave Airlie  *       (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6)
93c0e09200SDave Airlie  * 1.19- Add support for gart table in FB memory and PCIE r300
94c0e09200SDave Airlie  * 1.20- Add support for r300 texrect
95c0e09200SDave Airlie  * 1.21- Add support for card type getparam
96c0e09200SDave Airlie  * 1.22- Add support for texture cache flushes (R300_TX_CNTL)
97c0e09200SDave Airlie  * 1.23- Add new radeon memory map work from benh
98c0e09200SDave Airlie  * 1.24- Add general-purpose packet for manipulating scratch registers (r300)
99c0e09200SDave Airlie  * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL,
100c0e09200SDave Airlie  *       new packet type)
101c0e09200SDave Airlie  * 1.26- Add support for variable size PCI(E) gart aperture
102c0e09200SDave Airlie  * 1.27- Add support for IGP GART
103c0e09200SDave Airlie  * 1.28- Add support for VBL on CRTC2
104c0e09200SDave Airlie  * 1.29- R500 3D cmd buffer support
105e8a13441SMaciej Cencora  * 1.30- Add support for occlusion queries
106f779b3e5SAlex Deucher  * 1.31- Add support for num Z pipes from GET_PARAM
107c0e09200SDave Airlie  */
108c0e09200SDave Airlie #define DRIVER_MAJOR		1
109f779b3e5SAlex Deucher #define DRIVER_MINOR		31
110c0e09200SDave Airlie #define DRIVER_PATCHLEVEL	0
111c0e09200SDave Airlie 
112c0e09200SDave Airlie /*
113c0e09200SDave Airlie  * Radeon chip families
114c0e09200SDave Airlie  */
115c0e09200SDave Airlie enum radeon_family {
116c0e09200SDave Airlie 	CHIP_R100,
117c0e09200SDave Airlie 	CHIP_RV100,
118c0e09200SDave Airlie 	CHIP_RS100,
119c0e09200SDave Airlie 	CHIP_RV200,
120c0e09200SDave Airlie 	CHIP_RS200,
121c0e09200SDave Airlie 	CHIP_R200,
122c0e09200SDave Airlie 	CHIP_RV250,
123c0e09200SDave Airlie 	CHIP_RS300,
124c0e09200SDave Airlie 	CHIP_RV280,
125c0e09200SDave Airlie 	CHIP_R300,
126c0e09200SDave Airlie 	CHIP_R350,
127c0e09200SDave Airlie 	CHIP_RV350,
128c0e09200SDave Airlie 	CHIP_RV380,
129c0e09200SDave Airlie 	CHIP_R420,
130edc6f389SAlex Deucher 	CHIP_R423,
131c0e09200SDave Airlie 	CHIP_RV410,
132b2ceddfaSAlex Deucher 	CHIP_RS400,
133c0e09200SDave Airlie 	CHIP_RS480,
134c1556f71SAlex Deucher 	CHIP_RS600,
135c0e09200SDave Airlie 	CHIP_RS690,
136f0738e92SAlex Deucher 	CHIP_RS740,
137c0e09200SDave Airlie 	CHIP_RV515,
138c0e09200SDave Airlie 	CHIP_R520,
139c0e09200SDave Airlie 	CHIP_RV530,
140c0e09200SDave Airlie 	CHIP_RV560,
141c0e09200SDave Airlie 	CHIP_RV570,
142c0e09200SDave Airlie 	CHIP_R580,
143befb73c2SAlex Deucher 	CHIP_R600,
144befb73c2SAlex Deucher 	CHIP_RV610,
145befb73c2SAlex Deucher 	CHIP_RV630,
146befb73c2SAlex Deucher 	CHIP_RV620,
147befb73c2SAlex Deucher 	CHIP_RV635,
148befb73c2SAlex Deucher 	CHIP_RV670,
149befb73c2SAlex Deucher 	CHIP_RS780,
1506502fbfaSAlex Deucher 	CHIP_RS880,
151befb73c2SAlex Deucher 	CHIP_RV770,
152befb73c2SAlex Deucher 	CHIP_RV730,
153befb73c2SAlex Deucher 	CHIP_RV710,
1542a71ebcdSAlex Deucher 	CHIP_RV740,
155c0e09200SDave Airlie 	CHIP_LAST,
156c0e09200SDave Airlie };
157c0e09200SDave Airlie 
158c0e09200SDave Airlie enum radeon_cp_microcode_version {
159c0e09200SDave Airlie 	UCODE_R100,
160c0e09200SDave Airlie 	UCODE_R200,
161c0e09200SDave Airlie 	UCODE_R300,
162c0e09200SDave Airlie };
163c0e09200SDave Airlie 
164c0e09200SDave Airlie /*
165c0e09200SDave Airlie  * Chip flags
166c0e09200SDave Airlie  */
167c0e09200SDave Airlie enum radeon_chip_flags {
168c0e09200SDave Airlie 	RADEON_FAMILY_MASK = 0x0000ffffUL,
169c0e09200SDave Airlie 	RADEON_FLAGS_MASK = 0xffff0000UL,
170c0e09200SDave Airlie 	RADEON_IS_MOBILITY = 0x00010000UL,
171c0e09200SDave Airlie 	RADEON_IS_IGP = 0x00020000UL,
172c0e09200SDave Airlie 	RADEON_SINGLE_CRTC = 0x00040000UL,
173c0e09200SDave Airlie 	RADEON_IS_AGP = 0x00080000UL,
174c0e09200SDave Airlie 	RADEON_HAS_HIERZ = 0x00100000UL,
175c0e09200SDave Airlie 	RADEON_IS_PCIE = 0x00200000UL,
176c0e09200SDave Airlie 	RADEON_NEW_MEMMAP = 0x00400000UL,
177c0e09200SDave Airlie 	RADEON_IS_PCI = 0x00800000UL,
178c0e09200SDave Airlie 	RADEON_IS_IGPGART = 0x01000000UL,
179c0e09200SDave Airlie };
180c0e09200SDave Airlie 
181c0e09200SDave Airlie typedef struct drm_radeon_freelist {
182c0e09200SDave Airlie 	unsigned int age;
183c0e09200SDave Airlie 	struct drm_buf *buf;
184c0e09200SDave Airlie 	struct drm_radeon_freelist *next;
185c0e09200SDave Airlie 	struct drm_radeon_freelist *prev;
186c0e09200SDave Airlie } drm_radeon_freelist_t;
187c0e09200SDave Airlie 
188c0e09200SDave Airlie typedef struct drm_radeon_ring_buffer {
189c0e09200SDave Airlie 	u32 *start;
190c0e09200SDave Airlie 	u32 *end;
191c0e09200SDave Airlie 	int size;
192c0e09200SDave Airlie 	int size_l2qw;
193c0e09200SDave Airlie 
194c0e09200SDave Airlie 	int rptr_update; /* Double Words */
195c0e09200SDave Airlie 	int rptr_update_l2qw; /* log2 Quad Words */
196c0e09200SDave Airlie 
197c0e09200SDave Airlie 	int fetch_size; /* Double Words */
198c0e09200SDave Airlie 	int fetch_size_l2ow; /* log2 Oct Words */
199c0e09200SDave Airlie 
200c0e09200SDave Airlie 	u32 tail;
201c0e09200SDave Airlie 	u32 tail_mask;
202c0e09200SDave Airlie 	int space;
203c0e09200SDave Airlie 
204c0e09200SDave Airlie 	int high_mark;
205c0e09200SDave Airlie } drm_radeon_ring_buffer_t;
206c0e09200SDave Airlie 
207c0e09200SDave Airlie typedef struct drm_radeon_depth_clear_t {
208c0e09200SDave Airlie 	u32 rb3d_cntl;
209c0e09200SDave Airlie 	u32 rb3d_zstencilcntl;
210c0e09200SDave Airlie 	u32 se_cntl;
211c0e09200SDave Airlie } drm_radeon_depth_clear_t;
212c0e09200SDave Airlie 
213c0e09200SDave Airlie struct drm_radeon_driver_file_fields {
214c0e09200SDave Airlie 	int64_t radeon_fb_delta;
215c0e09200SDave Airlie };
216c0e09200SDave Airlie 
217c0e09200SDave Airlie struct mem_block {
218c0e09200SDave Airlie 	struct mem_block *next;
219c0e09200SDave Airlie 	struct mem_block *prev;
220c0e09200SDave Airlie 	int start;
221c0e09200SDave Airlie 	int size;
222c0e09200SDave Airlie 	struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
223c0e09200SDave Airlie };
224c0e09200SDave Airlie 
225c0e09200SDave Airlie struct radeon_surface {
226c0e09200SDave Airlie 	int refcount;
227c0e09200SDave Airlie 	u32 lower;
228c0e09200SDave Airlie 	u32 upper;
229c0e09200SDave Airlie 	u32 flags;
230c0e09200SDave Airlie };
231c0e09200SDave Airlie 
232c0e09200SDave Airlie struct radeon_virt_surface {
233c0e09200SDave Airlie 	int surface_index;
234c0e09200SDave Airlie 	u32 lower;
235c0e09200SDave Airlie 	u32 upper;
236c0e09200SDave Airlie 	u32 flags;
237c0e09200SDave Airlie 	struct drm_file *file_priv;
2386abf6bb0SDavid Miller #define PCIGART_FILE_PRIV	((void *) -1L)
239c0e09200SDave Airlie };
240c0e09200SDave Airlie 
241b2665030SDavid Miller #define RADEON_FLUSH_EMITED	(1 << 0)
242b2665030SDavid Miller #define RADEON_PURGE_EMITED	(1 << 1)
24354f961a6SJerome Glisse 
2447c1c2871SDave Airlie struct drm_radeon_master_private {
2457c1c2871SDave Airlie 	drm_local_map_t *sarea;
2467c1c2871SDave Airlie 	drm_radeon_sarea_t *sarea_priv;
2477c1c2871SDave Airlie };
2487c1c2871SDave Airlie 
249c0e09200SDave Airlie typedef struct drm_radeon_private {
250c0e09200SDave Airlie 	drm_radeon_ring_buffer_t ring;
251c0e09200SDave Airlie 
252c0e09200SDave Airlie 	u32 fb_location;
253c0e09200SDave Airlie 	u32 fb_size;
254c0e09200SDave Airlie 	int new_memmap;
255c0e09200SDave Airlie 
256c0e09200SDave Airlie 	int gart_size;
257c0e09200SDave Airlie 	u32 gart_vm_start;
258c0e09200SDave Airlie 	unsigned long gart_buffers_offset;
259c0e09200SDave Airlie 
260c0e09200SDave Airlie 	int cp_mode;
261c0e09200SDave Airlie 	int cp_running;
262c0e09200SDave Airlie 
263c0e09200SDave Airlie 	drm_radeon_freelist_t *head;
264c0e09200SDave Airlie 	drm_radeon_freelist_t *tail;
265c0e09200SDave Airlie 	int last_buf;
266c0e09200SDave Airlie 	int writeback_works;
267c0e09200SDave Airlie 
268c0e09200SDave Airlie 	int usec_timeout;
269c0e09200SDave Airlie 
270c0e09200SDave Airlie 	int microcode_version;
271c0e09200SDave Airlie 
272c0e09200SDave Airlie 	struct {
273c0e09200SDave Airlie 		u32 boxes;
274c0e09200SDave Airlie 		int freelist_timeouts;
275c0e09200SDave Airlie 		int freelist_loops;
276c0e09200SDave Airlie 		int requested_bufs;
277c0e09200SDave Airlie 		int last_frame_reads;
278c0e09200SDave Airlie 		int last_clear_reads;
279c0e09200SDave Airlie 		int clears;
280c0e09200SDave Airlie 		int texture_uploads;
281c0e09200SDave Airlie 	} stats;
282c0e09200SDave Airlie 
283c0e09200SDave Airlie 	int do_boxes;
284c0e09200SDave Airlie 	int page_flipping;
285c0e09200SDave Airlie 
286c0e09200SDave Airlie 	u32 color_fmt;
287c0e09200SDave Airlie 	unsigned int front_offset;
288c0e09200SDave Airlie 	unsigned int front_pitch;
289c0e09200SDave Airlie 	unsigned int back_offset;
290c0e09200SDave Airlie 	unsigned int back_pitch;
291c0e09200SDave Airlie 
292c0e09200SDave Airlie 	u32 depth_fmt;
293c0e09200SDave Airlie 	unsigned int depth_offset;
294c0e09200SDave Airlie 	unsigned int depth_pitch;
295c0e09200SDave Airlie 
296c0e09200SDave Airlie 	u32 front_pitch_offset;
297c0e09200SDave Airlie 	u32 back_pitch_offset;
298c0e09200SDave Airlie 	u32 depth_pitch_offset;
299c0e09200SDave Airlie 
300c0e09200SDave Airlie 	drm_radeon_depth_clear_t depth_clear;
301c0e09200SDave Airlie 
302c0e09200SDave Airlie 	unsigned long ring_offset;
303c0e09200SDave Airlie 	unsigned long ring_rptr_offset;
304c0e09200SDave Airlie 	unsigned long buffers_offset;
305c0e09200SDave Airlie 	unsigned long gart_textures_offset;
306c0e09200SDave Airlie 
307c0e09200SDave Airlie 	drm_local_map_t *sarea;
308c0e09200SDave Airlie 	drm_local_map_t *cp_ring;
309c0e09200SDave Airlie 	drm_local_map_t *ring_rptr;
310c0e09200SDave Airlie 	drm_local_map_t *gart_textures;
311c0e09200SDave Airlie 
312c0e09200SDave Airlie 	struct mem_block *gart_heap;
313c0e09200SDave Airlie 	struct mem_block *fb_heap;
314c0e09200SDave Airlie 
315c0e09200SDave Airlie 	/* SW interrupt */
316c0e09200SDave Airlie 	wait_queue_head_t swi_queue;
317c0e09200SDave Airlie 	atomic_t swi_emitted;
318c0e09200SDave Airlie 	int vblank_crtc;
319c0e09200SDave Airlie 	uint32_t irq_enable_reg;
320c0e09200SDave Airlie 	uint32_t r500_disp_irq_reg;
321c0e09200SDave Airlie 
322c0e09200SDave Airlie 	struct radeon_surface surfaces[RADEON_MAX_SURFACES];
323c0e09200SDave Airlie 	struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES];
324c0e09200SDave Airlie 
325c0e09200SDave Airlie 	unsigned long pcigart_offset;
326c0e09200SDave Airlie 	unsigned int pcigart_offset_set;
327c0e09200SDave Airlie 	struct drm_ati_pcigart_info gart_info;
328c0e09200SDave Airlie 
329c0e09200SDave Airlie 	u32 scratch_ages[5];
330c0e09200SDave Airlie 
331c0e09200SDave Airlie 	/* starting from here on, data is preserved accross an open */
332c0e09200SDave Airlie 	uint32_t flags;		/* see radeon_chip_flags */
333d883f7f1SBenjamin Herrenschmidt 	resource_size_t fb_aper_offset;
334c0e09200SDave Airlie 
335c0e09200SDave Airlie 	int num_gb_pipes;
336f779b3e5SAlex Deucher 	int num_z_pipes;
33754f961a6SJerome Glisse 	int track_flush;
33878538bf1SDave Airlie 	drm_local_map_t *mmio;
339befb73c2SAlex Deucher 
340befb73c2SAlex Deucher 	/* r6xx/r7xx pipe/shader config */
341befb73c2SAlex Deucher 	int r600_max_pipes;
342befb73c2SAlex Deucher 	int r600_max_tile_pipes;
343befb73c2SAlex Deucher 	int r600_max_simds;
344befb73c2SAlex Deucher 	int r600_max_backends;
345befb73c2SAlex Deucher 	int r600_max_gprs;
346befb73c2SAlex Deucher 	int r600_max_threads;
347befb73c2SAlex Deucher 	int r600_max_stack_entries;
348befb73c2SAlex Deucher 	int r600_max_hw_contexts;
349befb73c2SAlex Deucher 	int r600_max_gs_threads;
350befb73c2SAlex Deucher 	int r600_sx_max_export_size;
351befb73c2SAlex Deucher 	int r600_sx_max_export_pos_size;
352befb73c2SAlex Deucher 	int r600_sx_max_export_smx_size;
353befb73c2SAlex Deucher 	int r600_sq_num_cf_insts;
354befb73c2SAlex Deucher 	int r700_sx_num_of_sets;
355befb73c2SAlex Deucher 	int r700_sc_prim_fifo_size;
356befb73c2SAlex Deucher 	int r700_sc_hiz_tile_fifo_size;
357befb73c2SAlex Deucher 	int r700_sc_earlyz_tile_fifo_fize;
358befb73c2SAlex Deucher 
3593ce0a23dSJerome Glisse 	struct mutex cs_mutex;
3603ce0a23dSJerome Glisse 	u32 cs_id_scnt;
3613ce0a23dSJerome Glisse 	u32 cs_id_wcnt;
3623ce0a23dSJerome Glisse 	/* r6xx/r7xx drm blit vertex buffer */
3633ce0a23dSJerome Glisse 	struct drm_buf *blit_vb;
3643ce0a23dSJerome Glisse 
36570967ab9SBen Hutchings 	/* firmware */
36670967ab9SBen Hutchings 	const struct firmware *me_fw, *pfp_fw;
367c0e09200SDave Airlie } drm_radeon_private_t;
368c0e09200SDave Airlie 
369c0e09200SDave Airlie typedef struct drm_radeon_buf_priv {
370c0e09200SDave Airlie 	u32 age;
371c0e09200SDave Airlie } drm_radeon_buf_priv_t;
372c0e09200SDave Airlie 
373c0e09200SDave Airlie typedef struct drm_radeon_kcmd_buffer {
374c0e09200SDave Airlie 	int bufsz;
375c0e09200SDave Airlie 	char *buf;
376c0e09200SDave Airlie 	int nbox;
377c0e09200SDave Airlie 	struct drm_clip_rect __user *boxes;
378c0e09200SDave Airlie } drm_radeon_kcmd_buffer_t;
379c0e09200SDave Airlie 
380c0e09200SDave Airlie extern int radeon_no_wb;
381c0e09200SDave Airlie extern struct drm_ioctl_desc radeon_ioctls[];
382c0e09200SDave Airlie extern int radeon_max_ioctl;
383c0e09200SDave Airlie 
384b07fa022SDavid Miller extern u32 radeon_get_ring_head(drm_radeon_private_t *dev_priv);
385b07fa022SDavid Miller extern void radeon_set_ring_head(drm_radeon_private_t *dev_priv, u32 val);
386b07fa022SDavid Miller 
387b07fa022SDavid Miller #define GET_RING_HEAD(dev_priv)	radeon_get_ring_head(dev_priv)
388b07fa022SDavid Miller #define SET_RING_HEAD(dev_priv, val) radeon_set_ring_head(dev_priv, val)
389b07fa022SDavid Miller 
390c0e09200SDave Airlie /* Check whether the given hardware address is inside the framebuffer or the
391c0e09200SDave Airlie  * GART area.
392c0e09200SDave Airlie  */
393c0e09200SDave Airlie static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
394c0e09200SDave Airlie 					  u64 off)
395c0e09200SDave Airlie {
396c0e09200SDave Airlie 	u32 fb_start = dev_priv->fb_location;
397c0e09200SDave Airlie 	u32 fb_end = fb_start + dev_priv->fb_size - 1;
398c0e09200SDave Airlie 	u32 gart_start = dev_priv->gart_vm_start;
399c0e09200SDave Airlie 	u32 gart_end = gart_start + dev_priv->gart_size - 1;
400c0e09200SDave Airlie 
401c0e09200SDave Airlie 	return ((off >= fb_start && off <= fb_end) ||
402c0e09200SDave Airlie 		(off >= gart_start && off <= gart_end));
403c0e09200SDave Airlie }
404c0e09200SDave Airlie 
4053ce0a23dSJerome Glisse /* radeon_state.c */
4063ce0a23dSJerome Glisse extern void radeon_cp_discard_buffer(struct drm_device *dev, struct drm_master *master, struct drm_buf *buf);
4073ce0a23dSJerome Glisse 
408c0e09200SDave Airlie 				/* radeon_cp.c */
409c0e09200SDave Airlie extern int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
410c0e09200SDave Airlie extern int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv);
411c0e09200SDave Airlie extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv);
412c0e09200SDave Airlie extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
413c0e09200SDave Airlie extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv);
414c0e09200SDave Airlie extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv);
415c0e09200SDave Airlie extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
416c0e09200SDave Airlie extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
417c0e09200SDave Airlie extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
418c0e09200SDave Airlie extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv);
419c05ce083SAlex Deucher extern void radeon_write_agp_location(drm_radeon_private_t *dev_priv, u32 agp_loc);
420c05ce083SAlex Deucher extern void radeon_write_agp_base(drm_radeon_private_t *dev_priv, u64 agp_base);
421befb73c2SAlex Deucher extern u32 RADEON_READ_MM(drm_radeon_private_t *dev_priv, int addr);
422c0e09200SDave Airlie 
423c0e09200SDave Airlie extern void radeon_freelist_reset(struct drm_device * dev);
424c0e09200SDave Airlie extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
425c0e09200SDave Airlie 
426c0e09200SDave Airlie extern int radeon_wait_ring(drm_radeon_private_t * dev_priv, int n);
427c0e09200SDave Airlie 
428c0e09200SDave Airlie extern int radeon_do_cp_idle(drm_radeon_private_t * dev_priv);
429c0e09200SDave Airlie 
430c0e09200SDave Airlie extern int radeon_driver_preinit(struct drm_device *dev, unsigned long flags);
431c0e09200SDave Airlie extern int radeon_presetup(struct drm_device *dev);
432c0e09200SDave Airlie extern int radeon_driver_postcleanup(struct drm_device *dev);
433c0e09200SDave Airlie 
434c0e09200SDave Airlie extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
435c0e09200SDave Airlie extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
436c0e09200SDave Airlie extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv);
437c0e09200SDave Airlie extern void radeon_mem_takedown(struct mem_block **heap);
438c0e09200SDave Airlie extern void radeon_mem_release(struct drm_file *file_priv,
439c0e09200SDave Airlie 			       struct mem_block *heap);
440c0e09200SDave Airlie 
441c05ce083SAlex Deucher extern void radeon_enable_bm(struct drm_radeon_private *dev_priv);
442c05ce083SAlex Deucher extern u32 radeon_read_ring_rptr(drm_radeon_private_t *dev_priv, u32 off);
443c05ce083SAlex Deucher extern void radeon_write_ring_rptr(drm_radeon_private_t *dev_priv, u32 off, u32 val);
444c05ce083SAlex Deucher 
445c0e09200SDave Airlie 				/* radeon_irq.c */
4460a3e67a4SJesse Barnes extern void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state);
447c0e09200SDave Airlie extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv);
448c0e09200SDave Airlie extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
449c0e09200SDave Airlie 
450c0e09200SDave Airlie extern void radeon_do_release(struct drm_device * dev);
4510a3e67a4SJesse Barnes extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
4520a3e67a4SJesse Barnes extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
4530a3e67a4SJesse Barnes extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
454c0e09200SDave Airlie extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
455c0e09200SDave Airlie extern void radeon_driver_irq_preinstall(struct drm_device * dev);
4560a3e67a4SJesse Barnes extern int radeon_driver_irq_postinstall(struct drm_device *dev);
457c0e09200SDave Airlie extern void radeon_driver_irq_uninstall(struct drm_device * dev);
458c0e09200SDave Airlie extern void radeon_enable_interrupt(struct drm_device *dev);
459c0e09200SDave Airlie extern int radeon_vblank_crtc_get(struct drm_device *dev);
460c0e09200SDave Airlie extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
461c0e09200SDave Airlie 
462c0e09200SDave Airlie extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
463c0e09200SDave Airlie extern int radeon_driver_unload(struct drm_device *dev);
464c0e09200SDave Airlie extern int radeon_driver_firstopen(struct drm_device *dev);
4650a3e67a4SJesse Barnes extern void radeon_driver_preclose(struct drm_device *dev,
4660a3e67a4SJesse Barnes 				   struct drm_file *file_priv);
4670a3e67a4SJesse Barnes extern void radeon_driver_postclose(struct drm_device *dev,
4680a3e67a4SJesse Barnes 				    struct drm_file *file_priv);
469c0e09200SDave Airlie extern void radeon_driver_lastclose(struct drm_device * dev);
4700a3e67a4SJesse Barnes extern int radeon_driver_open(struct drm_device *dev,
4710a3e67a4SJesse Barnes 			      struct drm_file *file_priv);
472c0e09200SDave Airlie extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
473c0e09200SDave Airlie 				unsigned long arg);
474*70ba2a37SDave Airlie extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd,
475*70ba2a37SDave Airlie 				    unsigned long arg);
476c0e09200SDave Airlie 
4777c1c2871SDave Airlie extern int radeon_master_create(struct drm_device *dev, struct drm_master *master);
4787c1c2871SDave Airlie extern void radeon_master_destroy(struct drm_device *dev, struct drm_master *master);
4797c1c2871SDave Airlie extern void radeon_cp_dispatch_flip(struct drm_device *dev, struct drm_master *master);
480c0e09200SDave Airlie /* r300_cmdbuf.c */
481c0e09200SDave Airlie extern void r300_init_reg_flags(struct drm_device *dev);
482c0e09200SDave Airlie 
483c0e09200SDave Airlie extern int r300_do_cp_cmdbuf(struct drm_device *dev,
484c0e09200SDave Airlie 			     struct drm_file *file_priv,
485c0e09200SDave Airlie 			     drm_radeon_kcmd_buffer_t *cmdbuf);
486c0e09200SDave Airlie 
487c05ce083SAlex Deucher /* r600_cp.c */
488c05ce083SAlex Deucher extern int r600_do_engine_reset(struct drm_device *dev);
489c05ce083SAlex Deucher extern int r600_do_cleanup_cp(struct drm_device *dev);
490c05ce083SAlex Deucher extern int r600_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
491c05ce083SAlex Deucher 			   struct drm_file *file_priv);
492c05ce083SAlex Deucher extern int r600_do_resume_cp(struct drm_device *dev, struct drm_file *file_priv);
493c05ce083SAlex Deucher extern int r600_do_cp_idle(drm_radeon_private_t *dev_priv);
494c05ce083SAlex Deucher extern void r600_do_cp_start(drm_radeon_private_t *dev_priv);
495c05ce083SAlex Deucher extern void r600_do_cp_reset(drm_radeon_private_t *dev_priv);
496c05ce083SAlex Deucher extern void r600_do_cp_stop(drm_radeon_private_t *dev_priv);
497c05ce083SAlex Deucher extern int r600_cp_dispatch_indirect(struct drm_device *dev,
498c05ce083SAlex Deucher 				     struct drm_buf *buf, int start, int end);
499c1556f71SAlex Deucher extern int r600_page_table_init(struct drm_device *dev);
500c1556f71SAlex Deucher extern void r600_page_table_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info);
5013ce0a23dSJerome Glisse extern int r600_cs_legacy_ioctl(struct drm_device *dev, void *data, struct drm_file *fpriv);
5023ce0a23dSJerome Glisse extern void r600_cp_dispatch_swap(struct drm_device *dev, struct drm_file *file_priv);
5033ce0a23dSJerome Glisse extern int r600_cp_dispatch_texture(struct drm_device *dev,
5043ce0a23dSJerome Glisse 				    struct drm_file *file_priv,
5053ce0a23dSJerome Glisse 				    drm_radeon_texture_t *tex,
5063ce0a23dSJerome Glisse 				    drm_radeon_tex_image_t *image);
5073ce0a23dSJerome Glisse /* r600_blit.c */
5083ce0a23dSJerome Glisse extern int r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv);
5093ce0a23dSJerome Glisse extern void r600_done_blit_copy(struct drm_device *dev);
5103ce0a23dSJerome Glisse extern void r600_blit_copy(struct drm_device *dev,
5113ce0a23dSJerome Glisse 			   uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
5123ce0a23dSJerome Glisse 			   int size_bytes);
5133ce0a23dSJerome Glisse extern void r600_blit_swap(struct drm_device *dev,
5143ce0a23dSJerome Glisse 			   uint64_t src_gpu_addr, uint64_t dst_gpu_addr,
5153ce0a23dSJerome Glisse 			   int sx, int sy, int dx, int dy,
5163ce0a23dSJerome Glisse 			   int w, int h, int src_pitch, int dst_pitch, int cpp);
517c05ce083SAlex Deucher 
518c0e09200SDave Airlie /* Flags for stats.boxes
519c0e09200SDave Airlie  */
520c0e09200SDave Airlie #define RADEON_BOX_DMA_IDLE      0x1
521c0e09200SDave Airlie #define RADEON_BOX_RING_FULL     0x2
522c0e09200SDave Airlie #define RADEON_BOX_FLIP          0x4
523c0e09200SDave Airlie #define RADEON_BOX_WAIT_IDLE     0x8
524c0e09200SDave Airlie #define RADEON_BOX_TEXTURE_LOAD  0x10
525c0e09200SDave Airlie 
526c0e09200SDave Airlie /* Register definitions, register access macros and drmAddMap constants
527c0e09200SDave Airlie  * for Radeon kernel driver.
528c0e09200SDave Airlie  */
529befb73c2SAlex Deucher #define RADEON_MM_INDEX		        0x0000
530befb73c2SAlex Deucher #define RADEON_MM_DATA		        0x0004
531c0e09200SDave Airlie 
532c0e09200SDave Airlie #define RADEON_AGP_COMMAND		0x0f60
533c0e09200SDave Airlie #define RADEON_AGP_COMMAND_PCI_CONFIG   0x0060	/* offset in PCI config */
534c0e09200SDave Airlie #	define RADEON_AGP_ENABLE	(1<<8)
535c0e09200SDave Airlie #define RADEON_AUX_SCISSOR_CNTL		0x26f0
536c0e09200SDave Airlie #	define RADEON_EXCLUSIVE_SCISSOR_0	(1 << 24)
537c0e09200SDave Airlie #	define RADEON_EXCLUSIVE_SCISSOR_1	(1 << 25)
538c0e09200SDave Airlie #	define RADEON_EXCLUSIVE_SCISSOR_2	(1 << 26)
539c0e09200SDave Airlie #	define RADEON_SCISSOR_0_ENABLE		(1 << 28)
540c0e09200SDave Airlie #	define RADEON_SCISSOR_1_ENABLE		(1 << 29)
541c0e09200SDave Airlie #	define RADEON_SCISSOR_2_ENABLE		(1 << 30)
542c0e09200SDave Airlie 
543edc6f389SAlex Deucher /*
544edc6f389SAlex Deucher  * PCIE radeons (rv370/rv380, rv410, r423/r430/r480, r5xx)
545edc6f389SAlex Deucher  * don't have an explicit bus mastering disable bit.  It's handled
546edc6f389SAlex Deucher  * by the PCI D-states.  PMI_BM_DIS disables D-state bus master
547edc6f389SAlex Deucher  * handling, not bus mastering itself.
548edc6f389SAlex Deucher  */
549c0e09200SDave Airlie #define RADEON_BUS_CNTL			0x0030
5504e270e9bSAlex Deucher /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
551c0e09200SDave Airlie #	define RADEON_BUS_MASTER_DIS		(1 << 6)
5524e270e9bSAlex Deucher /* rs600/rs690/rs740 */
5534e270e9bSAlex Deucher #	define RS600_BUS_MASTER_DIS		(1 << 14)
5544e270e9bSAlex Deucher #	define RS600_MSI_REARM		        (1 << 20)
5554e270e9bSAlex Deucher /* see RS400_MSI_REARM in AIC_CNTL for rs480 */
556edc6f389SAlex Deucher 
557edc6f389SAlex Deucher #define RADEON_BUS_CNTL1		0x0034
558edc6f389SAlex Deucher #	define RADEON_PMI_BM_DIS		(1 << 2)
559edc6f389SAlex Deucher #	define RADEON_PMI_INT_DIS		(1 << 3)
560edc6f389SAlex Deucher 
561edc6f389SAlex Deucher #define RV370_BUS_CNTL			0x004c
562edc6f389SAlex Deucher #	define RV370_PMI_BM_DIS		        (1 << 5)
563edc6f389SAlex Deucher #	define RV370_PMI_INT_DIS		(1 << 6)
564edc6f389SAlex Deucher 
565edc6f389SAlex Deucher #define RADEON_MSI_REARM_EN		0x0160
566edc6f389SAlex Deucher /* rv370/rv380, rv410, r423/r430/r480, r5xx */
567edc6f389SAlex Deucher #	define RV370_MSI_REARM_EN		(1 << 0)
568c0e09200SDave Airlie 
569c0e09200SDave Airlie #define RADEON_CLOCK_CNTL_DATA		0x000c
570c0e09200SDave Airlie #	define RADEON_PLL_WR_EN			(1 << 7)
571c0e09200SDave Airlie #define RADEON_CLOCK_CNTL_INDEX		0x0008
572c0e09200SDave Airlie #define RADEON_CONFIG_APER_SIZE		0x0108
573c0e09200SDave Airlie #define RADEON_CONFIG_MEMSIZE		0x00f8
574c0e09200SDave Airlie #define RADEON_CRTC_OFFSET		0x0224
575c0e09200SDave Airlie #define RADEON_CRTC_OFFSET_CNTL		0x0228
576c0e09200SDave Airlie #	define RADEON_CRTC_TILE_EN		(1 << 15)
577c0e09200SDave Airlie #	define RADEON_CRTC_OFFSET_FLIP_CNTL	(1 << 16)
578c0e09200SDave Airlie #define RADEON_CRTC2_OFFSET		0x0324
579c0e09200SDave Airlie #define RADEON_CRTC2_OFFSET_CNTL	0x0328
580c0e09200SDave Airlie 
581c0e09200SDave Airlie #define RADEON_PCIE_INDEX               0x0030
582c0e09200SDave Airlie #define RADEON_PCIE_DATA                0x0034
583c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_CNTL	0x10
584c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_EN		(1 << 0)
585c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0 << 1)
586c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO  (1 << 1)
587c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD   (3 << 1)
588c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_MODE_32_128_CACHE	(0 << 3)
589c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE	(1 << 3)
590c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN      (1 << 5)
591c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_INVALIDATE_TLB	(1 << 8)
592c0e09200SDave Airlie #define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11
593c0e09200SDave Airlie #define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12
594c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_BASE	0x13
595c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_START_LO	0x14
596c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_START_HI	0x15
597c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_END_LO	0x16
598c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_END_HI	0x17
599c0e09200SDave Airlie 
600c0e09200SDave Airlie #define RS480_NB_MC_INDEX               0x168
601c0e09200SDave Airlie #	define RS480_NB_MC_IND_WR_EN	(1 << 8)
602c0e09200SDave Airlie #define RS480_NB_MC_DATA                0x16c
603c0e09200SDave Airlie 
604c0e09200SDave Airlie #define RS690_MC_INDEX                  0x78
605c0e09200SDave Airlie #   define RS690_MC_INDEX_MASK          0x1ff
606c0e09200SDave Airlie #   define RS690_MC_INDEX_WR_EN         (1 << 9)
607c0e09200SDave Airlie #   define RS690_MC_INDEX_WR_ACK        0x7f
608c0e09200SDave Airlie #define RS690_MC_DATA                   0x7c
609c0e09200SDave Airlie 
610c0e09200SDave Airlie /* MC indirect registers */
611c0e09200SDave Airlie #define RS480_MC_MISC_CNTL              0x18
612c0e09200SDave Airlie #	define RS480_DISABLE_GTW	(1 << 1)
613c0e09200SDave Airlie /* switch between MCIND GART and MM GART registers. 0 = mmgart, 1 = mcind gart */
614c0e09200SDave Airlie #	define RS480_GART_INDEX_REG_EN	(1 << 12)
615c0e09200SDave Airlie #	define RS690_BLOCK_GFX_D3_EN	(1 << 14)
616c0e09200SDave Airlie #define RS480_K8_FB_LOCATION            0x1e
617c0e09200SDave Airlie #define RS480_GART_FEATURE_ID           0x2b
618c0e09200SDave Airlie #	define RS480_HANG_EN	        (1 << 11)
619c0e09200SDave Airlie #	define RS480_TLB_ENABLE	        (1 << 18)
620c0e09200SDave Airlie #	define RS480_P2P_ENABLE	        (1 << 19)
621c0e09200SDave Airlie #	define RS480_GTW_LAC_EN	        (1 << 25)
622c0e09200SDave Airlie #	define RS480_2LEVEL_GART	(0 << 30)
623c0e09200SDave Airlie #	define RS480_1LEVEL_GART	(1 << 30)
624c0e09200SDave Airlie #	define RS480_PDC_EN	        (1 << 31)
625c0e09200SDave Airlie #define RS480_GART_BASE                 0x2c
626c0e09200SDave Airlie #define RS480_GART_CACHE_CNTRL          0x2e
627c0e09200SDave Airlie #	define RS480_GART_CACHE_INVALIDATE (1 << 0) /* wait for it to clear */
628c0e09200SDave Airlie #define RS480_AGP_ADDRESS_SPACE_SIZE    0x38
629c0e09200SDave Airlie #	define RS480_GART_EN	        (1 << 0)
630c0e09200SDave Airlie #	define RS480_VA_SIZE_32MB	(0 << 1)
631c0e09200SDave Airlie #	define RS480_VA_SIZE_64MB	(1 << 1)
632c0e09200SDave Airlie #	define RS480_VA_SIZE_128MB	(2 << 1)
633c0e09200SDave Airlie #	define RS480_VA_SIZE_256MB	(3 << 1)
634c0e09200SDave Airlie #	define RS480_VA_SIZE_512MB	(4 << 1)
635c0e09200SDave Airlie #	define RS480_VA_SIZE_1GB	(5 << 1)
636c0e09200SDave Airlie #	define RS480_VA_SIZE_2GB	(6 << 1)
637c0e09200SDave Airlie #define RS480_AGP_MODE_CNTL             0x39
638c0e09200SDave Airlie #	define RS480_POST_GART_Q_SIZE	(1 << 18)
639c0e09200SDave Airlie #	define RS480_NONGART_SNOOP	(1 << 19)
640c0e09200SDave Airlie #	define RS480_AGP_RD_BUF_SIZE	(1 << 20)
641c0e09200SDave Airlie #	define RS480_REQ_TYPE_SNOOP_SHIFT 22
642c0e09200SDave Airlie #	define RS480_REQ_TYPE_SNOOP_MASK  0x3
643c0e09200SDave Airlie #	define RS480_REQ_TYPE_SNOOP_DIS	(1 << 24)
644c0e09200SDave Airlie #define RS480_MC_MISC_UMA_CNTL          0x5f
645c0e09200SDave Airlie #define RS480_MC_MCLK_CNTL              0x7a
646c0e09200SDave Airlie #define RS480_MC_UMA_DUALCH_CNTL        0x86
647c0e09200SDave Airlie 
648c0e09200SDave Airlie #define RS690_MC_FB_LOCATION            0x100
649c0e09200SDave Airlie #define RS690_MC_AGP_LOCATION           0x101
650c0e09200SDave Airlie #define RS690_MC_AGP_BASE               0x102
651c0e09200SDave Airlie #define RS690_MC_AGP_BASE_2             0x103
652c0e09200SDave Airlie 
653c1556f71SAlex Deucher #define RS600_MC_INDEX                          0x70
654c1556f71SAlex Deucher #       define RS600_MC_ADDR_MASK               0xffff
655c1556f71SAlex Deucher #       define RS600_MC_IND_SEQ_RBS_0           (1 << 16)
656c1556f71SAlex Deucher #       define RS600_MC_IND_SEQ_RBS_1           (1 << 17)
657c1556f71SAlex Deucher #       define RS600_MC_IND_SEQ_RBS_2           (1 << 18)
658c1556f71SAlex Deucher #       define RS600_MC_IND_SEQ_RBS_3           (1 << 19)
659c1556f71SAlex Deucher #       define RS600_MC_IND_AIC_RBS             (1 << 20)
660c1556f71SAlex Deucher #       define RS600_MC_IND_CITF_ARB0           (1 << 21)
661c1556f71SAlex Deucher #       define RS600_MC_IND_CITF_ARB1           (1 << 22)
662c1556f71SAlex Deucher #       define RS600_MC_IND_WR_EN               (1 << 23)
663c1556f71SAlex Deucher #define RS600_MC_DATA                           0x74
664c1556f71SAlex Deucher 
665c1556f71SAlex Deucher #define RS600_MC_STATUS                         0x0
666c1556f71SAlex Deucher #       define RS600_MC_IDLE                    (1 << 1)
667c1556f71SAlex Deucher #define RS600_MC_FB_LOCATION                    0x4
668c1556f71SAlex Deucher #define RS600_MC_AGP_LOCATION                   0x5
669c1556f71SAlex Deucher #define RS600_AGP_BASE                          0x6
670c1556f71SAlex Deucher #define RS600_AGP_BASE_2                        0x7
671c1556f71SAlex Deucher #define RS600_MC_CNTL1                          0x9
672c1556f71SAlex Deucher #       define RS600_ENABLE_PAGE_TABLES         (1 << 26)
673c1556f71SAlex Deucher #define RS600_MC_PT0_CNTL                       0x100
674c1556f71SAlex Deucher #       define RS600_ENABLE_PT                  (1 << 0)
675c1556f71SAlex Deucher #       define RS600_EFFECTIVE_L2_CACHE_SIZE(x) ((x) << 15)
676c1556f71SAlex Deucher #       define RS600_EFFECTIVE_L2_QUEUE_SIZE(x) ((x) << 21)
677c1556f71SAlex Deucher #       define RS600_INVALIDATE_ALL_L1_TLBS     (1 << 28)
678c1556f71SAlex Deucher #       define RS600_INVALIDATE_L2_CACHE        (1 << 29)
679c1556f71SAlex Deucher #define RS600_MC_PT0_CONTEXT0_CNTL              0x102
680c1556f71SAlex Deucher #       define RS600_ENABLE_PAGE_TABLE          (1 << 0)
681c1556f71SAlex Deucher #       define RS600_PAGE_TABLE_TYPE_FLAT       (0 << 1)
682c1556f71SAlex Deucher #define RS600_MC_PT0_SYSTEM_APERTURE_LOW_ADDR   0x112
683c1556f71SAlex Deucher #define RS600_MC_PT0_SYSTEM_APERTURE_HIGH_ADDR  0x114
684c1556f71SAlex Deucher #define RS600_MC_PT0_CONTEXT0_DEFAULT_READ_ADDR 0x11c
685c1556f71SAlex Deucher #define RS600_MC_PT0_CONTEXT0_FLAT_BASE_ADDR    0x12c
686c1556f71SAlex Deucher #define RS600_MC_PT0_CONTEXT0_FLAT_START_ADDR   0x13c
687c1556f71SAlex Deucher #define RS600_MC_PT0_CONTEXT0_FLAT_END_ADDR     0x14c
688c1556f71SAlex Deucher #define RS600_MC_PT0_CLIENT0_CNTL               0x16c
689c1556f71SAlex Deucher #       define RS600_ENABLE_TRANSLATION_MODE_OVERRIDE       (1 << 0)
690c1556f71SAlex Deucher #       define RS600_TRANSLATION_MODE_OVERRIDE              (1 << 1)
691c1556f71SAlex Deucher #       define RS600_SYSTEM_ACCESS_MODE_MASK                (3 << 8)
692c1556f71SAlex Deucher #       define RS600_SYSTEM_ACCESS_MODE_PA_ONLY             (0 << 8)
693c1556f71SAlex Deucher #       define RS600_SYSTEM_ACCESS_MODE_USE_SYS_MAP         (1 << 8)
694c1556f71SAlex Deucher #       define RS600_SYSTEM_ACCESS_MODE_IN_SYS              (2 << 8)
695c1556f71SAlex Deucher #       define RS600_SYSTEM_ACCESS_MODE_NOT_IN_SYS          (3 << 8)
696c1556f71SAlex Deucher #       define RS600_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASSTHROUGH        (0 << 10)
697c1556f71SAlex Deucher #       define RS600_SYSTEM_APERTURE_UNMAPPED_ACCESS_DEFAULT_PAGE       (1 << 10)
698c1556f71SAlex Deucher #       define RS600_EFFECTIVE_L1_CACHE_SIZE(x) ((x) << 11)
699c1556f71SAlex Deucher #       define RS600_ENABLE_FRAGMENT_PROCESSING (1 << 14)
700c1556f71SAlex Deucher #       define RS600_EFFECTIVE_L1_QUEUE_SIZE(x) ((x) << 15)
701c1556f71SAlex Deucher #       define RS600_INVALIDATE_L1_TLB          (1 << 20)
702c1556f71SAlex Deucher 
703c0e09200SDave Airlie #define R520_MC_IND_INDEX 0x70
704c0e09200SDave Airlie #define R520_MC_IND_WR_EN (1 << 24)
705c0e09200SDave Airlie #define R520_MC_IND_DATA  0x74
706c0e09200SDave Airlie 
707c0e09200SDave Airlie #define RV515_MC_FB_LOCATION 0x01
708c0e09200SDave Airlie #define RV515_MC_AGP_LOCATION 0x02
709c0e09200SDave Airlie #define RV515_MC_AGP_BASE     0x03
710c0e09200SDave Airlie #define RV515_MC_AGP_BASE_2   0x04
711c0e09200SDave Airlie 
712c0e09200SDave Airlie #define R520_MC_FB_LOCATION 0x04
713c0e09200SDave Airlie #define R520_MC_AGP_LOCATION 0x05
714c0e09200SDave Airlie #define R520_MC_AGP_BASE     0x06
715c0e09200SDave Airlie #define R520_MC_AGP_BASE_2   0x07
716c0e09200SDave Airlie 
717c0e09200SDave Airlie #define RADEON_MPP_TB_CONFIG		0x01c0
718c0e09200SDave Airlie #define RADEON_MEM_CNTL			0x0140
719c0e09200SDave Airlie #define RADEON_MEM_SDRAM_MODE_REG	0x0158
720c0e09200SDave Airlie #define RADEON_AGP_BASE_2		0x015c /* r200+ only */
721c0e09200SDave Airlie #define RS480_AGP_BASE_2		0x0164
722c0e09200SDave Airlie #define RADEON_AGP_BASE			0x0170
723c0e09200SDave Airlie 
724c0e09200SDave Airlie /* pipe config regs */
725c0e09200SDave Airlie #define R400_GB_PIPE_SELECT             0x402c
726f779b3e5SAlex Deucher #define RV530_GB_PIPE_SELECT2           0x4124
727c0e09200SDave Airlie #define R500_DYN_SCLK_PWMEM_PIPE        0x000d /* PLL */
728c0e09200SDave Airlie #define R300_GB_TILE_CONFIG             0x4018
729c0e09200SDave Airlie #       define R300_ENABLE_TILING       (1 << 0)
730c0e09200SDave Airlie #       define R300_PIPE_COUNT_RV350    (0 << 1)
731c0e09200SDave Airlie #       define R300_PIPE_COUNT_R300     (3 << 1)
732c0e09200SDave Airlie #       define R300_PIPE_COUNT_R420_3P  (6 << 1)
733c0e09200SDave Airlie #       define R300_PIPE_COUNT_R420     (7 << 1)
734c0e09200SDave Airlie #       define R300_TILE_SIZE_8         (0 << 4)
735c0e09200SDave Airlie #       define R300_TILE_SIZE_16        (1 << 4)
736c0e09200SDave Airlie #       define R300_TILE_SIZE_32        (2 << 4)
737c0e09200SDave Airlie #       define R300_SUBPIXEL_1_12       (0 << 16)
738c0e09200SDave Airlie #       define R300_SUBPIXEL_1_16       (1 << 16)
739c0e09200SDave Airlie #define R300_DST_PIPE_CONFIG            0x170c
740c0e09200SDave Airlie #       define R300_PIPE_AUTO_CONFIG    (1 << 31)
741c0e09200SDave Airlie #define R300_RB2D_DSTCACHE_MODE         0x3428
742c0e09200SDave Airlie #       define R300_DC_AUTOFLUSH_ENABLE (1 << 8)
743c0e09200SDave Airlie #       define R300_DC_DC_DISABLE_IGNORE_PE (1 << 17)
744c0e09200SDave Airlie 
745c0e09200SDave Airlie #define RADEON_RB3D_COLOROFFSET		0x1c40
746c0e09200SDave Airlie #define RADEON_RB3D_COLORPITCH		0x1c48
747c0e09200SDave Airlie 
748c0e09200SDave Airlie #define	RADEON_SRC_X_Y			0x1590
749c0e09200SDave Airlie 
750c0e09200SDave Airlie #define RADEON_DP_GUI_MASTER_CNTL	0x146c
751c0e09200SDave Airlie #	define RADEON_GMC_SRC_PITCH_OFFSET_CNTL	(1 << 0)
752c0e09200SDave Airlie #	define RADEON_GMC_DST_PITCH_OFFSET_CNTL	(1 << 1)
753c0e09200SDave Airlie #	define RADEON_GMC_BRUSH_SOLID_COLOR	(13 << 4)
754c0e09200SDave Airlie #	define RADEON_GMC_BRUSH_NONE		(15 << 4)
755c0e09200SDave Airlie #	define RADEON_GMC_DST_16BPP		(4 << 8)
756c0e09200SDave Airlie #	define RADEON_GMC_DST_24BPP		(5 << 8)
757c0e09200SDave Airlie #	define RADEON_GMC_DST_32BPP		(6 << 8)
758c0e09200SDave Airlie #	define RADEON_GMC_DST_DATATYPE_SHIFT	8
759c0e09200SDave Airlie #	define RADEON_GMC_SRC_DATATYPE_COLOR	(3 << 12)
760c0e09200SDave Airlie #	define RADEON_DP_SRC_SOURCE_MEMORY	(2 << 24)
761c0e09200SDave Airlie #	define RADEON_DP_SRC_SOURCE_HOST_DATA	(3 << 24)
762c0e09200SDave Airlie #	define RADEON_GMC_CLR_CMP_CNTL_DIS	(1 << 28)
763c0e09200SDave Airlie #	define RADEON_GMC_WR_MSK_DIS		(1 << 30)
764c0e09200SDave Airlie #	define RADEON_ROP3_S			0x00cc0000
765c0e09200SDave Airlie #	define RADEON_ROP3_P			0x00f00000
766c0e09200SDave Airlie #define RADEON_DP_WRITE_MASK		0x16cc
767c0e09200SDave Airlie #define RADEON_SRC_PITCH_OFFSET		0x1428
768c0e09200SDave Airlie #define RADEON_DST_PITCH_OFFSET		0x142c
769c0e09200SDave Airlie #define RADEON_DST_PITCH_OFFSET_C	0x1c80
770c0e09200SDave Airlie #	define RADEON_DST_TILE_LINEAR		(0 << 30)
771c0e09200SDave Airlie #	define RADEON_DST_TILE_MACRO		(1 << 30)
772c0e09200SDave Airlie #	define RADEON_DST_TILE_MICRO		(2 << 30)
773c0e09200SDave Airlie #	define RADEON_DST_TILE_BOTH		(3 << 30)
774c0e09200SDave Airlie 
775c0e09200SDave Airlie #define RADEON_SCRATCH_REG0		0x15e0
776c0e09200SDave Airlie #define RADEON_SCRATCH_REG1		0x15e4
777c0e09200SDave Airlie #define RADEON_SCRATCH_REG2		0x15e8
778c0e09200SDave Airlie #define RADEON_SCRATCH_REG3		0x15ec
779c0e09200SDave Airlie #define RADEON_SCRATCH_REG4		0x15f0
780c0e09200SDave Airlie #define RADEON_SCRATCH_REG5		0x15f4
781c0e09200SDave Airlie #define RADEON_SCRATCH_UMSK		0x0770
782c0e09200SDave Airlie #define RADEON_SCRATCH_ADDR		0x0774
783c0e09200SDave Airlie 
784c0e09200SDave Airlie #define RADEON_SCRATCHOFF( x )		(RADEON_SCRATCH_REG_OFFSET + 4*(x))
785c0e09200SDave Airlie 
786b07fa022SDavid Miller extern u32 radeon_get_scratch(drm_radeon_private_t *dev_priv, int index);
787b07fa022SDavid Miller 
788b07fa022SDavid Miller #define GET_SCRATCH(dev_priv, x) radeon_get_scratch(dev_priv, x)
789c0e09200SDave Airlie 
790befb73c2SAlex Deucher #define R600_SCRATCH_REG0		0x8500
791befb73c2SAlex Deucher #define R600_SCRATCH_REG1		0x8504
792befb73c2SAlex Deucher #define R600_SCRATCH_REG2		0x8508
793befb73c2SAlex Deucher #define R600_SCRATCH_REG3		0x850c
794befb73c2SAlex Deucher #define R600_SCRATCH_REG4		0x8510
795befb73c2SAlex Deucher #define R600_SCRATCH_REG5		0x8514
796befb73c2SAlex Deucher #define R600_SCRATCH_REG6		0x8518
797befb73c2SAlex Deucher #define R600_SCRATCH_REG7		0x851c
798befb73c2SAlex Deucher #define R600_SCRATCH_UMSK		0x8540
799befb73c2SAlex Deucher #define R600_SCRATCH_ADDR		0x8544
800befb73c2SAlex Deucher 
801befb73c2SAlex Deucher #define R600_SCRATCHOFF(x)		(R600_SCRATCH_REG_OFFSET + 4*(x))
802befb73c2SAlex Deucher 
803c0e09200SDave Airlie #define RADEON_GEN_INT_CNTL		0x0040
804c0e09200SDave Airlie #	define RADEON_CRTC_VBLANK_MASK		(1 << 0)
805c0e09200SDave Airlie #	define RADEON_CRTC2_VBLANK_MASK		(1 << 9)
806c0e09200SDave Airlie #	define RADEON_GUI_IDLE_INT_ENABLE	(1 << 19)
807c0e09200SDave Airlie #	define RADEON_SW_INT_ENABLE		(1 << 25)
808c0e09200SDave Airlie 
809c0e09200SDave Airlie #define RADEON_GEN_INT_STATUS		0x0044
810c0e09200SDave Airlie #	define RADEON_CRTC_VBLANK_STAT		(1 << 0)
811c0e09200SDave Airlie #	define RADEON_CRTC_VBLANK_STAT_ACK	(1 << 0)
812c0e09200SDave Airlie #	define RADEON_CRTC2_VBLANK_STAT		(1 << 9)
813c0e09200SDave Airlie #	define RADEON_CRTC2_VBLANK_STAT_ACK	(1 << 9)
814c0e09200SDave Airlie #	define RADEON_GUI_IDLE_INT_TEST_ACK     (1 << 19)
815c0e09200SDave Airlie #	define RADEON_SW_INT_TEST		(1 << 25)
816c0e09200SDave Airlie #	define RADEON_SW_INT_TEST_ACK		(1 << 25)
817c0e09200SDave Airlie #	define RADEON_SW_INT_FIRE		(1 << 26)
8180a3e67a4SJesse Barnes #       define R500_DISPLAY_INT_STATUS          (1 << 0)
819c0e09200SDave Airlie 
820c0e09200SDave Airlie #define RADEON_HOST_PATH_CNTL		0x0130
821c0e09200SDave Airlie #	define RADEON_HDP_SOFT_RESET		(1 << 26)
822c0e09200SDave Airlie #	define RADEON_HDP_WC_TIMEOUT_MASK	(7 << 28)
823c0e09200SDave Airlie #	define RADEON_HDP_WC_TIMEOUT_28BCLK	(7 << 28)
824c0e09200SDave Airlie 
825c0e09200SDave Airlie #define RADEON_ISYNC_CNTL		0x1724
826c0e09200SDave Airlie #	define RADEON_ISYNC_ANY2D_IDLE3D	(1 << 0)
827c0e09200SDave Airlie #	define RADEON_ISYNC_ANY3D_IDLE2D	(1 << 1)
828c0e09200SDave Airlie #	define RADEON_ISYNC_TRIG2D_IDLE3D	(1 << 2)
829c0e09200SDave Airlie #	define RADEON_ISYNC_TRIG3D_IDLE2D	(1 << 3)
830c0e09200SDave Airlie #	define RADEON_ISYNC_WAIT_IDLEGUI	(1 << 4)
831c0e09200SDave Airlie #	define RADEON_ISYNC_CPSCRATCH_IDLEGUI	(1 << 5)
832c0e09200SDave Airlie 
833c0e09200SDave Airlie #define RADEON_RBBM_GUICNTL		0x172c
834c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_NONE	(0 << 0)
835c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_16BIT	(1 << 0)
836c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_32BIT	(2 << 0)
837c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_HDW	(3 << 0)
838c0e09200SDave Airlie 
839c0e09200SDave Airlie #define RADEON_MC_AGP_LOCATION		0x014c
840c0e09200SDave Airlie #define RADEON_MC_FB_LOCATION		0x0148
841c0e09200SDave Airlie #define RADEON_MCLK_CNTL		0x0012
842c0e09200SDave Airlie #	define RADEON_FORCEON_MCLKA		(1 << 16)
843c0e09200SDave Airlie #	define RADEON_FORCEON_MCLKB		(1 << 17)
844c0e09200SDave Airlie #	define RADEON_FORCEON_YCLKA		(1 << 18)
845c0e09200SDave Airlie #	define RADEON_FORCEON_YCLKB		(1 << 19)
846c0e09200SDave Airlie #	define RADEON_FORCEON_MC		(1 << 20)
847c0e09200SDave Airlie #	define RADEON_FORCEON_AIC		(1 << 21)
848c0e09200SDave Airlie 
849c0e09200SDave Airlie #define RADEON_PP_BORDER_COLOR_0	0x1d40
850c0e09200SDave Airlie #define RADEON_PP_BORDER_COLOR_1	0x1d44
851c0e09200SDave Airlie #define RADEON_PP_BORDER_COLOR_2	0x1d48
852c0e09200SDave Airlie #define RADEON_PP_CNTL			0x1c38
853c0e09200SDave Airlie #	define RADEON_SCISSOR_ENABLE		(1 <<  1)
854c0e09200SDave Airlie #define RADEON_PP_LUM_MATRIX		0x1d00
855c0e09200SDave Airlie #define RADEON_PP_MISC			0x1c14
856c0e09200SDave Airlie #define RADEON_PP_ROT_MATRIX_0		0x1d58
857c0e09200SDave Airlie #define RADEON_PP_TXFILTER_0		0x1c54
858c0e09200SDave Airlie #define RADEON_PP_TXOFFSET_0		0x1c5c
859c0e09200SDave Airlie #define RADEON_PP_TXFILTER_1		0x1c6c
860c0e09200SDave Airlie #define RADEON_PP_TXFILTER_2		0x1c84
861c0e09200SDave Airlie 
862c0e09200SDave Airlie #define R300_RB2D_DSTCACHE_CTLSTAT	0x342c /* use R300_DSTCACHE_CTLSTAT */
863c0e09200SDave Airlie #define R300_DSTCACHE_CTLSTAT		0x1714
864c0e09200SDave Airlie #	define R300_RB2D_DC_FLUSH		(3 << 0)
865c0e09200SDave Airlie #	define R300_RB2D_DC_FREE		(3 << 2)
866c0e09200SDave Airlie #	define R300_RB2D_DC_FLUSH_ALL		0xf
867c0e09200SDave Airlie #	define R300_RB2D_DC_BUSY		(1 << 31)
868c0e09200SDave Airlie #define RADEON_RB3D_CNTL		0x1c3c
869c0e09200SDave Airlie #	define RADEON_ALPHA_BLEND_ENABLE	(1 << 0)
870c0e09200SDave Airlie #	define RADEON_PLANE_MASK_ENABLE		(1 << 1)
871c0e09200SDave Airlie #	define RADEON_DITHER_ENABLE		(1 << 2)
872c0e09200SDave Airlie #	define RADEON_ROUND_ENABLE		(1 << 3)
873c0e09200SDave Airlie #	define RADEON_SCALE_DITHER_ENABLE	(1 << 4)
874c0e09200SDave Airlie #	define RADEON_DITHER_INIT		(1 << 5)
875c0e09200SDave Airlie #	define RADEON_ROP_ENABLE		(1 << 6)
876c0e09200SDave Airlie #	define RADEON_STENCIL_ENABLE		(1 << 7)
877c0e09200SDave Airlie #	define RADEON_Z_ENABLE			(1 << 8)
878c0e09200SDave Airlie #	define RADEON_ZBLOCK16			(1 << 15)
879c0e09200SDave Airlie #define RADEON_RB3D_DEPTHOFFSET		0x1c24
880c0e09200SDave Airlie #define RADEON_RB3D_DEPTHCLEARVALUE	0x3230
881c0e09200SDave Airlie #define RADEON_RB3D_DEPTHPITCH		0x1c28
882c0e09200SDave Airlie #define RADEON_RB3D_PLANEMASK		0x1d84
883c0e09200SDave Airlie #define RADEON_RB3D_STENCILREFMASK	0x1d7c
884c0e09200SDave Airlie #define RADEON_RB3D_ZCACHE_MODE		0x3250
885c0e09200SDave Airlie #define RADEON_RB3D_ZCACHE_CTLSTAT	0x3254
886c0e09200SDave Airlie #	define RADEON_RB3D_ZC_FLUSH		(1 << 0)
887c0e09200SDave Airlie #	define RADEON_RB3D_ZC_FREE		(1 << 2)
888c0e09200SDave Airlie #	define RADEON_RB3D_ZC_FLUSH_ALL		0x5
889c0e09200SDave Airlie #	define RADEON_RB3D_ZC_BUSY		(1 << 31)
890c0e09200SDave Airlie #define R300_ZB_ZCACHE_CTLSTAT                  0x4f18
891c0e09200SDave Airlie #	define R300_ZC_FLUSH		        (1 << 0)
892c0e09200SDave Airlie #	define R300_ZC_FREE		        (1 << 1)
893c0e09200SDave Airlie #	define R300_ZC_BUSY		        (1 << 31)
894c0e09200SDave Airlie #define RADEON_RB3D_DSTCACHE_CTLSTAT	0x325c
895c0e09200SDave Airlie #	define RADEON_RB3D_DC_FLUSH		(3 << 0)
896c0e09200SDave Airlie #	define RADEON_RB3D_DC_FREE		(3 << 2)
897c0e09200SDave Airlie #	define RADEON_RB3D_DC_FLUSH_ALL		0xf
898c0e09200SDave Airlie #	define RADEON_RB3D_DC_BUSY		(1 << 31)
899c0e09200SDave Airlie #define R300_RB3D_DSTCACHE_CTLSTAT              0x4e4c
90054f961a6SJerome Glisse #	define R300_RB3D_DC_FLUSH		(2 << 0)
90154f961a6SJerome Glisse #	define R300_RB3D_DC_FREE		(2 << 2)
902c0e09200SDave Airlie #	define R300_RB3D_DC_FINISH		(1 << 4)
903c0e09200SDave Airlie #define RADEON_RB3D_ZSTENCILCNTL	0x1c2c
904c0e09200SDave Airlie #	define RADEON_Z_TEST_MASK		(7 << 4)
905c0e09200SDave Airlie #	define RADEON_Z_TEST_ALWAYS		(7 << 4)
906c0e09200SDave Airlie #	define RADEON_Z_HIERARCHY_ENABLE	(1 << 8)
907c0e09200SDave Airlie #	define RADEON_STENCIL_TEST_ALWAYS	(7 << 12)
908c0e09200SDave Airlie #	define RADEON_STENCIL_S_FAIL_REPLACE	(2 << 16)
909c0e09200SDave Airlie #	define RADEON_STENCIL_ZPASS_REPLACE	(2 << 20)
910c0e09200SDave Airlie #	define RADEON_STENCIL_ZFAIL_REPLACE	(2 << 24)
911c0e09200SDave Airlie #	define RADEON_Z_COMPRESSION_ENABLE	(1 << 28)
912c0e09200SDave Airlie #	define RADEON_FORCE_Z_DIRTY		(1 << 29)
913c0e09200SDave Airlie #	define RADEON_Z_WRITE_ENABLE		(1 << 30)
914c0e09200SDave Airlie #	define RADEON_Z_DECOMPRESSION_ENABLE	(1 << 31)
915c0e09200SDave Airlie #define RADEON_RBBM_SOFT_RESET		0x00f0
916c0e09200SDave Airlie #	define RADEON_SOFT_RESET_CP		(1 <<  0)
917c0e09200SDave Airlie #	define RADEON_SOFT_RESET_HI		(1 <<  1)
918c0e09200SDave Airlie #	define RADEON_SOFT_RESET_SE		(1 <<  2)
919c0e09200SDave Airlie #	define RADEON_SOFT_RESET_RE		(1 <<  3)
920c0e09200SDave Airlie #	define RADEON_SOFT_RESET_PP		(1 <<  4)
921c0e09200SDave Airlie #	define RADEON_SOFT_RESET_E2		(1 <<  5)
922c0e09200SDave Airlie #	define RADEON_SOFT_RESET_RB		(1 <<  6)
923c0e09200SDave Airlie #	define RADEON_SOFT_RESET_HDP		(1 <<  7)
924c0e09200SDave Airlie /*
925c0e09200SDave Airlie  *   6:0  Available slots in the FIFO
926c0e09200SDave Airlie  *   8    Host Interface active
927c0e09200SDave Airlie  *   9    CP request active
928c0e09200SDave Airlie  *   10   FIFO request active
929c0e09200SDave Airlie  *   11   Host Interface retry active
930c0e09200SDave Airlie  *   12   CP retry active
931c0e09200SDave Airlie  *   13   FIFO retry active
932c0e09200SDave Airlie  *   14   FIFO pipeline busy
933c0e09200SDave Airlie  *   15   Event engine busy
934c0e09200SDave Airlie  *   16   CP command stream busy
935c0e09200SDave Airlie  *   17   2D engine busy
936c0e09200SDave Airlie  *   18   2D portion of render backend busy
937c0e09200SDave Airlie  *   20   3D setup engine busy
938c0e09200SDave Airlie  *   26   GA engine busy
939c0e09200SDave Airlie  *   27   CBA 2D engine busy
940c0e09200SDave Airlie  *   31   2D engine busy or 3D engine busy or FIFO not empty or CP busy or
941c0e09200SDave Airlie  *           command stream queue not empty or Ring Buffer not empty
942c0e09200SDave Airlie  */
943c0e09200SDave Airlie #define RADEON_RBBM_STATUS		0x0e40
944c0e09200SDave Airlie /* Same as the previous RADEON_RBBM_STATUS; this is a mirror of that register.  */
945c0e09200SDave Airlie /* #define RADEON_RBBM_STATUS		0x1740 */
946c0e09200SDave Airlie /* bits 6:0 are dword slots available in the cmd fifo */
947c0e09200SDave Airlie #	define RADEON_RBBM_FIFOCNT_MASK		0x007f
948c0e09200SDave Airlie #	define RADEON_HIRQ_ON_RBB	(1 <<  8)
949c0e09200SDave Airlie #	define RADEON_CPRQ_ON_RBB	(1 <<  9)
950c0e09200SDave Airlie #	define RADEON_CFRQ_ON_RBB	(1 << 10)
951c0e09200SDave Airlie #	define RADEON_HIRQ_IN_RTBUF	(1 << 11)
952c0e09200SDave Airlie #	define RADEON_CPRQ_IN_RTBUF	(1 << 12)
953c0e09200SDave Airlie #	define RADEON_CFRQ_IN_RTBUF	(1 << 13)
954c0e09200SDave Airlie #	define RADEON_PIPE_BUSY		(1 << 14)
955c0e09200SDave Airlie #	define RADEON_ENG_EV_BUSY	(1 << 15)
956c0e09200SDave Airlie #	define RADEON_CP_CMDSTRM_BUSY	(1 << 16)
957c0e09200SDave Airlie #	define RADEON_E2_BUSY		(1 << 17)
958c0e09200SDave Airlie #	define RADEON_RB2D_BUSY		(1 << 18)
959c0e09200SDave Airlie #	define RADEON_RB3D_BUSY		(1 << 19) /* not used on r300 */
960c0e09200SDave Airlie #	define RADEON_VAP_BUSY		(1 << 20)
961c0e09200SDave Airlie #	define RADEON_RE_BUSY		(1 << 21) /* not used on r300 */
962c0e09200SDave Airlie #	define RADEON_TAM_BUSY		(1 << 22) /* not used on r300 */
963c0e09200SDave Airlie #	define RADEON_TDM_BUSY		(1 << 23) /* not used on r300 */
964c0e09200SDave Airlie #	define RADEON_PB_BUSY		(1 << 24) /* not used on r300 */
965c0e09200SDave Airlie #	define RADEON_TIM_BUSY		(1 << 25) /* not used on r300 */
966c0e09200SDave Airlie #	define RADEON_GA_BUSY		(1 << 26)
967c0e09200SDave Airlie #	define RADEON_CBA2D_BUSY	(1 << 27)
968c0e09200SDave Airlie #	define RADEON_RBBM_ACTIVE	(1 << 31)
969c0e09200SDave Airlie #define RADEON_RE_LINE_PATTERN		0x1cd0
970c0e09200SDave Airlie #define RADEON_RE_MISC			0x26c4
971c0e09200SDave Airlie #define RADEON_RE_TOP_LEFT		0x26c0
972c0e09200SDave Airlie #define RADEON_RE_WIDTH_HEIGHT		0x1c44
973c0e09200SDave Airlie #define RADEON_RE_STIPPLE_ADDR		0x1cc8
974c0e09200SDave Airlie #define RADEON_RE_STIPPLE_DATA		0x1ccc
975c0e09200SDave Airlie 
976c0e09200SDave Airlie #define RADEON_SCISSOR_TL_0		0x1cd8
977c0e09200SDave Airlie #define RADEON_SCISSOR_BR_0		0x1cdc
978c0e09200SDave Airlie #define RADEON_SCISSOR_TL_1		0x1ce0
979c0e09200SDave Airlie #define RADEON_SCISSOR_BR_1		0x1ce4
980c0e09200SDave Airlie #define RADEON_SCISSOR_TL_2		0x1ce8
981c0e09200SDave Airlie #define RADEON_SCISSOR_BR_2		0x1cec
982c0e09200SDave Airlie #define RADEON_SE_COORD_FMT		0x1c50
983c0e09200SDave Airlie #define RADEON_SE_CNTL			0x1c4c
984c0e09200SDave Airlie #	define RADEON_FFACE_CULL_CW		(0 << 0)
985c0e09200SDave Airlie #	define RADEON_BFACE_SOLID		(3 << 1)
986c0e09200SDave Airlie #	define RADEON_FFACE_SOLID		(3 << 3)
987c0e09200SDave Airlie #	define RADEON_FLAT_SHADE_VTX_LAST	(3 << 6)
988c0e09200SDave Airlie #	define RADEON_DIFFUSE_SHADE_FLAT	(1 << 8)
989c0e09200SDave Airlie #	define RADEON_DIFFUSE_SHADE_GOURAUD	(2 << 8)
990c0e09200SDave Airlie #	define RADEON_ALPHA_SHADE_FLAT		(1 << 10)
991c0e09200SDave Airlie #	define RADEON_ALPHA_SHADE_GOURAUD	(2 << 10)
992c0e09200SDave Airlie #	define RADEON_SPECULAR_SHADE_FLAT	(1 << 12)
993c0e09200SDave Airlie #	define RADEON_SPECULAR_SHADE_GOURAUD	(2 << 12)
994c0e09200SDave Airlie #	define RADEON_FOG_SHADE_FLAT		(1 << 14)
995c0e09200SDave Airlie #	define RADEON_FOG_SHADE_GOURAUD		(2 << 14)
996c0e09200SDave Airlie #	define RADEON_VPORT_XY_XFORM_ENABLE	(1 << 24)
997c0e09200SDave Airlie #	define RADEON_VPORT_Z_XFORM_ENABLE	(1 << 25)
998c0e09200SDave Airlie #	define RADEON_VTX_PIX_CENTER_OGL	(1 << 27)
999c0e09200SDave Airlie #	define RADEON_ROUND_MODE_TRUNC		(0 << 28)
1000c0e09200SDave Airlie #	define RADEON_ROUND_PREC_8TH_PIX	(1 << 30)
1001c0e09200SDave Airlie #define RADEON_SE_CNTL_STATUS		0x2140
1002c0e09200SDave Airlie #define RADEON_SE_LINE_WIDTH		0x1db8
1003c0e09200SDave Airlie #define RADEON_SE_VPORT_XSCALE		0x1d98
1004c0e09200SDave Airlie #define RADEON_SE_ZBIAS_FACTOR		0x1db0
1005c0e09200SDave Airlie #define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
1006c0e09200SDave Airlie #define RADEON_SE_TCL_OUTPUT_VTX_FMT         0x2254
1007c0e09200SDave Airlie #define RADEON_SE_TCL_VECTOR_INDX_REG        0x2200
1008c0e09200SDave Airlie #       define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT  16
1009c0e09200SDave Airlie #       define RADEON_VEC_INDX_DWORD_COUNT_SHIFT     28
1010c0e09200SDave Airlie #define RADEON_SE_TCL_VECTOR_DATA_REG       0x2204
1011c0e09200SDave Airlie #define RADEON_SE_TCL_SCALAR_INDX_REG       0x2208
1012c0e09200SDave Airlie #       define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT  16
1013c0e09200SDave Airlie #define RADEON_SE_TCL_SCALAR_DATA_REG       0x220C
1014c0e09200SDave Airlie #define RADEON_SURFACE_ACCESS_FLAGS	0x0bf8
1015c0e09200SDave Airlie #define RADEON_SURFACE_ACCESS_CLR	0x0bfc
1016c0e09200SDave Airlie #define RADEON_SURFACE_CNTL		0x0b00
1017c0e09200SDave Airlie #	define RADEON_SURF_TRANSLATION_DIS	(1 << 8)
1018c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_MASK	(3 << 20)
1019c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_LITTLE	(0 << 20)
1020c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_BIG16	(1 << 20)
1021c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_BIG32	(2 << 20)
1022c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_MASK	(3 << 22)
1023c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_LITTLE	(0 << 22)
1024c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_BIG16	(1 << 22)
1025c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_BIG32	(2 << 22)
1026c0e09200SDave Airlie #define RADEON_SURFACE0_INFO		0x0b0c
1027c0e09200SDave Airlie #	define RADEON_SURF_PITCHSEL_MASK	(0x1ff << 0)
1028c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_MASK	(3 << 16)
1029c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_MACRO	(0 << 16)
1030c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_MICRO	(1 << 16)
1031c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_32BIT_Z	(2 << 16)
1032c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_16BIT_Z	(3 << 16)
1033c0e09200SDave Airlie #define RADEON_SURFACE0_LOWER_BOUND	0x0b04
1034c0e09200SDave Airlie #define RADEON_SURFACE0_UPPER_BOUND	0x0b08
1035c0e09200SDave Airlie #	define RADEON_SURF_ADDRESS_FIXED_MASK	(0x3ff << 0)
1036c0e09200SDave Airlie #define RADEON_SURFACE1_INFO		0x0b1c
1037c0e09200SDave Airlie #define RADEON_SURFACE1_LOWER_BOUND	0x0b14
1038c0e09200SDave Airlie #define RADEON_SURFACE1_UPPER_BOUND	0x0b18
1039c0e09200SDave Airlie #define RADEON_SURFACE2_INFO		0x0b2c
1040c0e09200SDave Airlie #define RADEON_SURFACE2_LOWER_BOUND	0x0b24
1041c0e09200SDave Airlie #define RADEON_SURFACE2_UPPER_BOUND	0x0b28
1042c0e09200SDave Airlie #define RADEON_SURFACE3_INFO		0x0b3c
1043c0e09200SDave Airlie #define RADEON_SURFACE3_LOWER_BOUND	0x0b34
1044c0e09200SDave Airlie #define RADEON_SURFACE3_UPPER_BOUND	0x0b38
1045c0e09200SDave Airlie #define RADEON_SURFACE4_INFO		0x0b4c
1046c0e09200SDave Airlie #define RADEON_SURFACE4_LOWER_BOUND	0x0b44
1047c0e09200SDave Airlie #define RADEON_SURFACE4_UPPER_BOUND	0x0b48
1048c0e09200SDave Airlie #define RADEON_SURFACE5_INFO		0x0b5c
1049c0e09200SDave Airlie #define RADEON_SURFACE5_LOWER_BOUND	0x0b54
1050c0e09200SDave Airlie #define RADEON_SURFACE5_UPPER_BOUND	0x0b58
1051c0e09200SDave Airlie #define RADEON_SURFACE6_INFO		0x0b6c
1052c0e09200SDave Airlie #define RADEON_SURFACE6_LOWER_BOUND	0x0b64
1053c0e09200SDave Airlie #define RADEON_SURFACE6_UPPER_BOUND	0x0b68
1054c0e09200SDave Airlie #define RADEON_SURFACE7_INFO		0x0b7c
1055c0e09200SDave Airlie #define RADEON_SURFACE7_LOWER_BOUND	0x0b74
1056c0e09200SDave Airlie #define RADEON_SURFACE7_UPPER_BOUND	0x0b78
1057c0e09200SDave Airlie #define RADEON_SW_SEMAPHORE		0x013c
1058c0e09200SDave Airlie 
1059c0e09200SDave Airlie #define RADEON_WAIT_UNTIL		0x1720
1060c0e09200SDave Airlie #	define RADEON_WAIT_CRTC_PFLIP		(1 << 0)
1061c0e09200SDave Airlie #	define RADEON_WAIT_2D_IDLE		(1 << 14)
1062c0e09200SDave Airlie #	define RADEON_WAIT_3D_IDLE		(1 << 15)
1063c0e09200SDave Airlie #	define RADEON_WAIT_2D_IDLECLEAN		(1 << 16)
1064c0e09200SDave Airlie #	define RADEON_WAIT_3D_IDLECLEAN		(1 << 17)
1065c0e09200SDave Airlie #	define RADEON_WAIT_HOST_IDLECLEAN	(1 << 18)
1066c0e09200SDave Airlie 
1067c0e09200SDave Airlie #define RADEON_RB3D_ZMASKOFFSET		0x3234
1068c0e09200SDave Airlie #define RADEON_RB3D_ZSTENCILCNTL	0x1c2c
1069c0e09200SDave Airlie #	define RADEON_DEPTH_FORMAT_16BIT_INT_Z	(0 << 0)
1070c0e09200SDave Airlie #	define RADEON_DEPTH_FORMAT_24BIT_INT_Z	(2 << 0)
1071c0e09200SDave Airlie 
1072c0e09200SDave Airlie /* CP registers */
1073c0e09200SDave Airlie #define RADEON_CP_ME_RAM_ADDR		0x07d4
1074c0e09200SDave Airlie #define RADEON_CP_ME_RAM_RADDR		0x07d8
1075c0e09200SDave Airlie #define RADEON_CP_ME_RAM_DATAH		0x07dc
1076c0e09200SDave Airlie #define RADEON_CP_ME_RAM_DATAL		0x07e0
1077c0e09200SDave Airlie 
1078c0e09200SDave Airlie #define RADEON_CP_RB_BASE		0x0700
1079c0e09200SDave Airlie #define RADEON_CP_RB_CNTL		0x0704
1080c0e09200SDave Airlie #	define RADEON_BUF_SWAP_32BIT		(2 << 16)
1081c0e09200SDave Airlie #	define RADEON_RB_NO_UPDATE		(1 << 27)
1082befb73c2SAlex Deucher #	define RADEON_RB_RPTR_WR_ENA		(1 << 31)
1083c0e09200SDave Airlie #define RADEON_CP_RB_RPTR_ADDR		0x070c
1084c0e09200SDave Airlie #define RADEON_CP_RB_RPTR		0x0710
1085c0e09200SDave Airlie #define RADEON_CP_RB_WPTR		0x0714
1086c0e09200SDave Airlie 
1087c0e09200SDave Airlie #define RADEON_CP_RB_WPTR_DELAY		0x0718
1088c0e09200SDave Airlie #	define RADEON_PRE_WRITE_TIMER_SHIFT	0
1089c0e09200SDave Airlie #	define RADEON_PRE_WRITE_LIMIT_SHIFT	23
1090c0e09200SDave Airlie 
1091c0e09200SDave Airlie #define RADEON_CP_IB_BASE		0x0738
1092c0e09200SDave Airlie 
1093c0e09200SDave Airlie #define RADEON_CP_CSQ_CNTL		0x0740
1094c0e09200SDave Airlie #	define RADEON_CSQ_CNT_PRIMARY_MASK	(0xff << 0)
1095c0e09200SDave Airlie #	define RADEON_CSQ_PRIDIS_INDDIS		(0 << 28)
1096c0e09200SDave Airlie #	define RADEON_CSQ_PRIPIO_INDDIS		(1 << 28)
1097c0e09200SDave Airlie #	define RADEON_CSQ_PRIBM_INDDIS		(2 << 28)
1098c0e09200SDave Airlie #	define RADEON_CSQ_PRIPIO_INDBM		(3 << 28)
1099c0e09200SDave Airlie #	define RADEON_CSQ_PRIBM_INDBM		(4 << 28)
1100c0e09200SDave Airlie #	define RADEON_CSQ_PRIPIO_INDPIO		(15 << 28)
1101c0e09200SDave Airlie 
1102c0e09200SDave Airlie #define RADEON_AIC_CNTL			0x01d0
1103c0e09200SDave Airlie #	define RADEON_PCIGART_TRANSLATE_EN	(1 << 0)
11044e270e9bSAlex Deucher #	define RS400_MSI_REARM	                (1 << 3)
1105c0e09200SDave Airlie #define RADEON_AIC_STAT			0x01d4
1106c0e09200SDave Airlie #define RADEON_AIC_PT_BASE		0x01d8
1107c0e09200SDave Airlie #define RADEON_AIC_LO_ADDR		0x01dc
1108c0e09200SDave Airlie #define RADEON_AIC_HI_ADDR		0x01e0
1109c0e09200SDave Airlie #define RADEON_AIC_TLB_ADDR		0x01e4
1110c0e09200SDave Airlie #define RADEON_AIC_TLB_DATA		0x01e8
1111c0e09200SDave Airlie 
1112c0e09200SDave Airlie /* CP command packets */
1113c0e09200SDave Airlie #define RADEON_CP_PACKET0		0x00000000
1114c0e09200SDave Airlie #	define RADEON_ONE_REG_WR		(1 << 15)
1115c0e09200SDave Airlie #define RADEON_CP_PACKET1		0x40000000
1116c0e09200SDave Airlie #define RADEON_CP_PACKET2		0x80000000
1117c0e09200SDave Airlie #define RADEON_CP_PACKET3		0xC0000000
1118c0e09200SDave Airlie #       define RADEON_CP_NOP                    0x00001000
1119c0e09200SDave Airlie #       define RADEON_CP_NEXT_CHAR              0x00001900
1120c0e09200SDave Airlie #       define RADEON_CP_PLY_NEXTSCAN           0x00001D00
1121c0e09200SDave Airlie #       define RADEON_CP_SET_SCISSORS           0x00001E00
1122c0e09200SDave Airlie 	     /* GEN_INDX_PRIM is unsupported starting with R300 */
1123c0e09200SDave Airlie #	define RADEON_3D_RNDR_GEN_INDX_PRIM	0x00002300
1124c0e09200SDave Airlie #	define RADEON_WAIT_FOR_IDLE		0x00002600
1125c0e09200SDave Airlie #	define RADEON_3D_DRAW_VBUF		0x00002800
1126c0e09200SDave Airlie #	define RADEON_3D_DRAW_IMMD		0x00002900
1127c0e09200SDave Airlie #	define RADEON_3D_DRAW_INDX		0x00002A00
1128c0e09200SDave Airlie #       define RADEON_CP_LOAD_PALETTE           0x00002C00
1129c0e09200SDave Airlie #	define RADEON_3D_LOAD_VBPNTR		0x00002F00
1130c0e09200SDave Airlie #	define RADEON_MPEG_IDCT_MACROBLOCK	0x00003000
1131c0e09200SDave Airlie #	define RADEON_MPEG_IDCT_MACROBLOCK_REV	0x00003100
1132c0e09200SDave Airlie #	define RADEON_3D_CLEAR_ZMASK		0x00003200
1133c0e09200SDave Airlie #	define RADEON_CP_INDX_BUFFER		0x00003300
1134c0e09200SDave Airlie #       define RADEON_CP_3D_DRAW_VBUF_2         0x00003400
1135c0e09200SDave Airlie #       define RADEON_CP_3D_DRAW_IMMD_2         0x00003500
1136c0e09200SDave Airlie #       define RADEON_CP_3D_DRAW_INDX_2         0x00003600
1137c0e09200SDave Airlie #	define RADEON_3D_CLEAR_HIZ		0x00003700
1138c0e09200SDave Airlie #       define RADEON_CP_3D_CLEAR_CMASK         0x00003802
1139c0e09200SDave Airlie #	define RADEON_CNTL_HOSTDATA_BLT		0x00009400
1140c0e09200SDave Airlie #	define RADEON_CNTL_PAINT_MULTI		0x00009A00
1141c0e09200SDave Airlie #	define RADEON_CNTL_BITBLT_MULTI		0x00009B00
1142c0e09200SDave Airlie #	define RADEON_CNTL_SET_SCISSORS		0xC0001E00
1143c0e09200SDave Airlie 
11443ce0a23dSJerome Glisse #       define R600_IT_INDIRECT_BUFFER_END      0x00001700
11453ce0a23dSJerome Glisse #       define R600_IT_SET_PREDICATION          0x00002000
11463ce0a23dSJerome Glisse #       define R600_IT_REG_RMW                  0x00002100
11473ce0a23dSJerome Glisse #       define R600_IT_COND_EXEC                0x00002200
11483ce0a23dSJerome Glisse #       define R600_IT_PRED_EXEC                0x00002300
11493ce0a23dSJerome Glisse #       define R600_IT_START_3D_CMDBUF          0x00002400
11503ce0a23dSJerome Glisse #       define R600_IT_DRAW_INDEX_2             0x00002700
11513ce0a23dSJerome Glisse #       define R600_IT_CONTEXT_CONTROL          0x00002800
11523ce0a23dSJerome Glisse #       define R600_IT_DRAW_INDEX_IMMD_BE       0x00002900
11533ce0a23dSJerome Glisse #       define R600_IT_INDEX_TYPE               0x00002A00
11543ce0a23dSJerome Glisse #       define R600_IT_DRAW_INDEX               0x00002B00
11553ce0a23dSJerome Glisse #       define R600_IT_DRAW_INDEX_AUTO          0x00002D00
11563ce0a23dSJerome Glisse #       define R600_IT_DRAW_INDEX_IMMD          0x00002E00
11573ce0a23dSJerome Glisse #       define R600_IT_NUM_INSTANCES            0x00002F00
11583ce0a23dSJerome Glisse #       define R600_IT_STRMOUT_BUFFER_UPDATE    0x00003400
11593ce0a23dSJerome Glisse #       define R600_IT_INDIRECT_BUFFER_MP       0x00003800
11603ce0a23dSJerome Glisse #       define R600_IT_MEM_SEMAPHORE            0x00003900
11613ce0a23dSJerome Glisse #       define R600_IT_MPEG_INDEX               0x00003A00
11623ce0a23dSJerome Glisse #       define R600_IT_WAIT_REG_MEM             0x00003C00
11633ce0a23dSJerome Glisse #       define R600_IT_MEM_WRITE                0x00003D00
1164befb73c2SAlex Deucher #       define R600_IT_INDIRECT_BUFFER          0x00003200
11653ce0a23dSJerome Glisse #       define R600_IT_CP_INTERRUPT             0x00004000
11663ce0a23dSJerome Glisse #       define R600_IT_SURFACE_SYNC             0x00004300
11673ce0a23dSJerome Glisse #              define R600_CB0_DEST_BASE_ENA    (1 << 6)
11683ce0a23dSJerome Glisse #              define R600_TC_ACTION_ENA        (1 << 23)
11693ce0a23dSJerome Glisse #              define R600_VC_ACTION_ENA        (1 << 24)
11703ce0a23dSJerome Glisse #              define R600_CB_ACTION_ENA        (1 << 25)
11713ce0a23dSJerome Glisse #              define R600_DB_ACTION_ENA        (1 << 26)
11723ce0a23dSJerome Glisse #              define R600_SH_ACTION_ENA        (1 << 27)
11733ce0a23dSJerome Glisse #              define R600_SMX_ACTION_ENA       (1 << 28)
1174befb73c2SAlex Deucher #       define R600_IT_ME_INITIALIZE            0x00004400
1175befb73c2SAlex Deucher #	       define R600_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
11763ce0a23dSJerome Glisse #       define R600_IT_COND_WRITE               0x00004500
1177befb73c2SAlex Deucher #       define R600_IT_EVENT_WRITE              0x00004600
11783ce0a23dSJerome Glisse #       define R600_IT_EVENT_WRITE_EOP          0x00004700
11793ce0a23dSJerome Glisse #       define R600_IT_ONE_REG_WRITE            0x00005700
1180befb73c2SAlex Deucher #       define R600_IT_SET_CONFIG_REG           0x00006800
1181befb73c2SAlex Deucher #              define R600_SET_CONFIG_REG_OFFSET 0x00008000
1182befb73c2SAlex Deucher #              define R600_SET_CONFIG_REG_END   0x0000ac00
11833ce0a23dSJerome Glisse #       define R600_IT_SET_CONTEXT_REG          0x00006900
11843ce0a23dSJerome Glisse #              define R600_SET_CONTEXT_REG_OFFSET 0x00028000
11853ce0a23dSJerome Glisse #              define R600_SET_CONTEXT_REG_END  0x00029000
11863ce0a23dSJerome Glisse #       define R600_IT_SET_ALU_CONST            0x00006A00
11873ce0a23dSJerome Glisse #              define R600_SET_ALU_CONST_OFFSET 0x00030000
11883ce0a23dSJerome Glisse #              define R600_SET_ALU_CONST_END    0x00032000
11893ce0a23dSJerome Glisse #       define R600_IT_SET_BOOL_CONST           0x00006B00
11903ce0a23dSJerome Glisse #              define R600_SET_BOOL_CONST_OFFSET 0x0003e380
11913ce0a23dSJerome Glisse #              define R600_SET_BOOL_CONST_END   0x00040000
11923ce0a23dSJerome Glisse #       define R600_IT_SET_LOOP_CONST           0x00006C00
11933ce0a23dSJerome Glisse #              define R600_SET_LOOP_CONST_OFFSET 0x0003e200
11943ce0a23dSJerome Glisse #              define R600_SET_LOOP_CONST_END   0x0003e380
11953ce0a23dSJerome Glisse #       define R600_IT_SET_RESOURCE             0x00006D00
11963ce0a23dSJerome Glisse #              define R600_SET_RESOURCE_OFFSET  0x00038000
11973ce0a23dSJerome Glisse #              define R600_SET_RESOURCE_END     0x0003c000
11983ce0a23dSJerome Glisse #              define R600_SQ_TEX_VTX_INVALID_TEXTURE  0x0
11993ce0a23dSJerome Glisse #              define R600_SQ_TEX_VTX_INVALID_BUFFER   0x1
12003ce0a23dSJerome Glisse #              define R600_SQ_TEX_VTX_VALID_TEXTURE    0x2
12013ce0a23dSJerome Glisse #              define R600_SQ_TEX_VTX_VALID_BUFFER     0x3
12023ce0a23dSJerome Glisse #       define R600_IT_SET_SAMPLER              0x00006E00
12033ce0a23dSJerome Glisse #              define R600_SET_SAMPLER_OFFSET   0x0003c000
12043ce0a23dSJerome Glisse #              define R600_SET_SAMPLER_END      0x0003cff0
12053ce0a23dSJerome Glisse #       define R600_IT_SET_CTL_CONST            0x00006F00
12063ce0a23dSJerome Glisse #              define R600_SET_CTL_CONST_OFFSET 0x0003cff0
12073ce0a23dSJerome Glisse #              define R600_SET_CTL_CONST_END    0x0003e200
12083ce0a23dSJerome Glisse #       define R600_IT_SURFACE_BASE_UPDATE      0x00007300
1209befb73c2SAlex Deucher 
1210c0e09200SDave Airlie #define RADEON_CP_PACKET_MASK		0xC0000000
1211c0e09200SDave Airlie #define RADEON_CP_PACKET_COUNT_MASK	0x3fff0000
1212c0e09200SDave Airlie #define RADEON_CP_PACKET0_REG_MASK	0x000007ff
1213c0e09200SDave Airlie #define RADEON_CP_PACKET1_REG0_MASK	0x000007ff
1214c0e09200SDave Airlie #define RADEON_CP_PACKET1_REG1_MASK	0x003ff800
1215c0e09200SDave Airlie 
1216c0e09200SDave Airlie #define RADEON_VTX_Z_PRESENT			(1 << 31)
1217c0e09200SDave Airlie #define RADEON_VTX_PKCOLOR_PRESENT		(1 << 3)
1218c0e09200SDave Airlie 
1219c0e09200SDave Airlie #define RADEON_PRIM_TYPE_NONE			(0 << 0)
1220c0e09200SDave Airlie #define RADEON_PRIM_TYPE_POINT			(1 << 0)
1221c0e09200SDave Airlie #define RADEON_PRIM_TYPE_LINE			(2 << 0)
1222c0e09200SDave Airlie #define RADEON_PRIM_TYPE_LINE_STRIP		(3 << 0)
1223c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_LIST		(4 << 0)
1224c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_FAN		(5 << 0)
1225c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_STRIP		(6 << 0)
1226c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_TYPE2		(7 << 0)
1227c0e09200SDave Airlie #define RADEON_PRIM_TYPE_RECT_LIST		(8 << 0)
1228c0e09200SDave Airlie #define RADEON_PRIM_TYPE_3VRT_POINT_LIST	(9 << 0)
1229c0e09200SDave Airlie #define RADEON_PRIM_TYPE_3VRT_LINE_LIST		(10 << 0)
1230c0e09200SDave Airlie #define RADEON_PRIM_TYPE_MASK                   0xf
1231c0e09200SDave Airlie #define RADEON_PRIM_WALK_IND			(1 << 4)
1232c0e09200SDave Airlie #define RADEON_PRIM_WALK_LIST			(2 << 4)
1233c0e09200SDave Airlie #define RADEON_PRIM_WALK_RING			(3 << 4)
1234c0e09200SDave Airlie #define RADEON_COLOR_ORDER_BGRA			(0 << 6)
1235c0e09200SDave Airlie #define RADEON_COLOR_ORDER_RGBA			(1 << 6)
1236c0e09200SDave Airlie #define RADEON_MAOS_ENABLE			(1 << 7)
1237c0e09200SDave Airlie #define RADEON_VTX_FMT_R128_MODE		(0 << 8)
1238c0e09200SDave Airlie #define RADEON_VTX_FMT_RADEON_MODE		(1 << 8)
1239c0e09200SDave Airlie #define RADEON_NUM_VERTICES_SHIFT		16
1240c0e09200SDave Airlie 
1241c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_CI8		2
1242c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_ARGB1555	3
1243c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_RGB565	4
1244c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_ARGB8888	6
1245c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_RGB332	7
1246c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_RGB8	9
1247c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_ARGB4444	15
1248c0e09200SDave Airlie 
1249c0e09200SDave Airlie #define RADEON_TXFORMAT_I8		0
1250c0e09200SDave Airlie #define RADEON_TXFORMAT_AI88		1
1251c0e09200SDave Airlie #define RADEON_TXFORMAT_RGB332		2
1252c0e09200SDave Airlie #define RADEON_TXFORMAT_ARGB1555	3
1253c0e09200SDave Airlie #define RADEON_TXFORMAT_RGB565		4
1254c0e09200SDave Airlie #define RADEON_TXFORMAT_ARGB4444	5
1255c0e09200SDave Airlie #define RADEON_TXFORMAT_ARGB8888	6
1256c0e09200SDave Airlie #define RADEON_TXFORMAT_RGBA8888	7
1257c0e09200SDave Airlie #define RADEON_TXFORMAT_Y8		8
1258c0e09200SDave Airlie #define RADEON_TXFORMAT_VYUY422         10
1259c0e09200SDave Airlie #define RADEON_TXFORMAT_YVYU422         11
1260c0e09200SDave Airlie #define RADEON_TXFORMAT_DXT1            12
1261c0e09200SDave Airlie #define RADEON_TXFORMAT_DXT23           14
1262c0e09200SDave Airlie #define RADEON_TXFORMAT_DXT45           15
1263c0e09200SDave Airlie 
1264c0e09200SDave Airlie #define R200_PP_TXCBLEND_0                0x2f00
1265c0e09200SDave Airlie #define R200_PP_TXCBLEND_1                0x2f10
1266c0e09200SDave Airlie #define R200_PP_TXCBLEND_2                0x2f20
1267c0e09200SDave Airlie #define R200_PP_TXCBLEND_3                0x2f30
1268c0e09200SDave Airlie #define R200_PP_TXCBLEND_4                0x2f40
1269c0e09200SDave Airlie #define R200_PP_TXCBLEND_5                0x2f50
1270c0e09200SDave Airlie #define R200_PP_TXCBLEND_6                0x2f60
1271c0e09200SDave Airlie #define R200_PP_TXCBLEND_7                0x2f70
1272c0e09200SDave Airlie #define R200_SE_TCL_LIGHT_MODEL_CTL_0     0x2268
1273c0e09200SDave Airlie #define R200_PP_TFACTOR_0                 0x2ee0
1274c0e09200SDave Airlie #define R200_SE_VTX_FMT_0                 0x2088
1275c0e09200SDave Airlie #define R200_SE_VAP_CNTL                  0x2080
1276c0e09200SDave Airlie #define R200_SE_TCL_MATRIX_SEL_0          0x2230
1277c0e09200SDave Airlie #define R200_SE_TCL_TEX_PROC_CTL_2        0x22a8
1278c0e09200SDave Airlie #define R200_SE_TCL_UCP_VERT_BLEND_CTL    0x22c0
1279c0e09200SDave Airlie #define R200_PP_TXFILTER_5                0x2ca0
1280c0e09200SDave Airlie #define R200_PP_TXFILTER_4                0x2c80
1281c0e09200SDave Airlie #define R200_PP_TXFILTER_3                0x2c60
1282c0e09200SDave Airlie #define R200_PP_TXFILTER_2                0x2c40
1283c0e09200SDave Airlie #define R200_PP_TXFILTER_1                0x2c20
1284c0e09200SDave Airlie #define R200_PP_TXFILTER_0                0x2c00
1285c0e09200SDave Airlie #define R200_PP_TXOFFSET_5                0x2d78
1286c0e09200SDave Airlie #define R200_PP_TXOFFSET_4                0x2d60
1287c0e09200SDave Airlie #define R200_PP_TXOFFSET_3                0x2d48
1288c0e09200SDave Airlie #define R200_PP_TXOFFSET_2                0x2d30
1289c0e09200SDave Airlie #define R200_PP_TXOFFSET_1                0x2d18
1290c0e09200SDave Airlie #define R200_PP_TXOFFSET_0                0x2d00
1291c0e09200SDave Airlie 
1292c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_0             0x2c18
1293c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_1             0x2c38
1294c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_2             0x2c58
1295c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_3             0x2c78
1296c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_4             0x2c98
1297c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_5             0x2cb8
1298c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_0         0x2d04
1299c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_0         0x2d08
1300c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_0         0x2d0c
1301c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_0         0x2d10
1302c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_0         0x2d14
1303c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_1         0x2d1c
1304c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_1         0x2d20
1305c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_1         0x2d24
1306c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_1         0x2d28
1307c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_1         0x2d2c
1308c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_2         0x2d34
1309c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_2         0x2d38
1310c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_2         0x2d3c
1311c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_2         0x2d40
1312c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_2         0x2d44
1313c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_3         0x2d4c
1314c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_3         0x2d50
1315c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_3         0x2d54
1316c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_3         0x2d58
1317c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_3         0x2d5c
1318c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_4         0x2d64
1319c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_4         0x2d68
1320c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_4         0x2d6c
1321c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_4         0x2d70
1322c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_4         0x2d74
1323c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_5         0x2d7c
1324c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_5         0x2d80
1325c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_5         0x2d84
1326c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_5         0x2d88
1327c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_5         0x2d8c
1328c0e09200SDave Airlie 
1329c0e09200SDave Airlie #define R200_RE_AUX_SCISSOR_CNTL          0x26f0
1330c0e09200SDave Airlie #define R200_SE_VTE_CNTL                  0x20b0
1331c0e09200SDave Airlie #define R200_SE_TCL_OUTPUT_VTX_COMP_SEL   0x2250
1332c0e09200SDave Airlie #define R200_PP_TAM_DEBUG3                0x2d9c
1333c0e09200SDave Airlie #define R200_PP_CNTL_X                    0x2cc4
1334c0e09200SDave Airlie #define R200_SE_VAP_CNTL_STATUS           0x2140
1335c0e09200SDave Airlie #define R200_RE_SCISSOR_TL_0              0x1cd8
1336c0e09200SDave Airlie #define R200_RE_SCISSOR_TL_1              0x1ce0
1337c0e09200SDave Airlie #define R200_RE_SCISSOR_TL_2              0x1ce8
1338c0e09200SDave Airlie #define R200_RB3D_DEPTHXY_OFFSET          0x1d60
1339c0e09200SDave Airlie #define R200_RE_AUX_SCISSOR_CNTL          0x26f0
1340c0e09200SDave Airlie #define R200_SE_VTX_STATE_CNTL            0x2180
1341c0e09200SDave Airlie #define R200_RE_POINTSIZE                 0x2648
1342c0e09200SDave Airlie #define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254
1343c0e09200SDave Airlie 
1344c0e09200SDave Airlie #define RADEON_PP_TEX_SIZE_0                0x1d04	/* NPOT */
1345c0e09200SDave Airlie #define RADEON_PP_TEX_SIZE_1                0x1d0c
1346c0e09200SDave Airlie #define RADEON_PP_TEX_SIZE_2                0x1d14
1347c0e09200SDave Airlie 
1348c0e09200SDave Airlie #define RADEON_PP_CUBIC_FACES_0             0x1d24
1349c0e09200SDave Airlie #define RADEON_PP_CUBIC_FACES_1             0x1d28
1350c0e09200SDave Airlie #define RADEON_PP_CUBIC_FACES_2             0x1d2c
1351c0e09200SDave Airlie #define RADEON_PP_CUBIC_OFFSET_T0_0         0x1dd0	/* bits [31:5] */
1352c0e09200SDave Airlie #define RADEON_PP_CUBIC_OFFSET_T1_0         0x1e00
1353c0e09200SDave Airlie #define RADEON_PP_CUBIC_OFFSET_T2_0         0x1e14
1354c0e09200SDave Airlie 
1355c0e09200SDave Airlie #define RADEON_SE_TCL_STATE_FLUSH           0x2284
1356c0e09200SDave Airlie 
1357c0e09200SDave Airlie #define SE_VAP_CNTL__TCL_ENA_MASK                          0x00000001
1358c0e09200SDave Airlie #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK                   0x00010000
1359c0e09200SDave Airlie #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT                 0x00000012
1360c0e09200SDave Airlie #define SE_VTE_CNTL__VTX_XY_FMT_MASK                       0x00000100
1361c0e09200SDave Airlie #define SE_VTE_CNTL__VTX_Z_FMT_MASK                        0x00000200
1362c0e09200SDave Airlie #define SE_VTX_FMT_0__VTX_Z0_PRESENT_MASK                  0x00000001
1363c0e09200SDave Airlie #define SE_VTX_FMT_0__VTX_W0_PRESENT_MASK                  0x00000002
1364c0e09200SDave Airlie #define SE_VTX_FMT_0__VTX_COLOR_0_FMT__SHIFT               0x0000000b
1365c0e09200SDave Airlie #define R200_3D_DRAW_IMMD_2      0xC0003500
1366c0e09200SDave Airlie #define R200_SE_VTX_FMT_1                 0x208c
1367c0e09200SDave Airlie #define R200_RE_CNTL                      0x1c50
1368c0e09200SDave Airlie 
1369c0e09200SDave Airlie #define R200_RB3D_BLENDCOLOR              0x3218
1370c0e09200SDave Airlie 
1371c0e09200SDave Airlie #define R200_SE_TCL_POINT_SPRITE_CNTL     0x22c4
1372c0e09200SDave Airlie 
1373c0e09200SDave Airlie #define R200_PP_TRI_PERF 0x2cf8
1374c0e09200SDave Airlie 
1375c0e09200SDave Airlie #define R200_PP_AFS_0                     0x2f80
1376c0e09200SDave Airlie #define R200_PP_AFS_1                     0x2f00	/* same as txcblend_0 */
1377c0e09200SDave Airlie 
1378c0e09200SDave Airlie #define R200_VAP_PVS_CNTL_1               0x22D0
1379c0e09200SDave Airlie 
13800a3e67a4SJesse Barnes #define RADEON_CRTC_CRNT_FRAME 0x0214
13810a3e67a4SJesse Barnes #define RADEON_CRTC2_CRNT_FRAME 0x0314
13820a3e67a4SJesse Barnes 
1383c0e09200SDave Airlie #define R500_D1CRTC_STATUS 0x609c
1384c0e09200SDave Airlie #define R500_D2CRTC_STATUS 0x689c
1385c0e09200SDave Airlie #define R500_CRTC_V_BLANK (1<<0)
1386c0e09200SDave Airlie 
1387c0e09200SDave Airlie #define R500_D1CRTC_FRAME_COUNT 0x60a4
1388c0e09200SDave Airlie #define R500_D2CRTC_FRAME_COUNT 0x68a4
1389c0e09200SDave Airlie 
1390c0e09200SDave Airlie #define R500_D1MODE_V_COUNTER 0x6530
1391c0e09200SDave Airlie #define R500_D2MODE_V_COUNTER 0x6d30
1392c0e09200SDave Airlie 
1393c0e09200SDave Airlie #define R500_D1MODE_VBLANK_STATUS 0x6534
1394c0e09200SDave Airlie #define R500_D2MODE_VBLANK_STATUS 0x6d34
1395c0e09200SDave Airlie #define R500_VBLANK_OCCURED (1<<0)
1396c0e09200SDave Airlie #define R500_VBLANK_ACK     (1<<4)
1397c0e09200SDave Airlie #define R500_VBLANK_STAT    (1<<12)
1398c0e09200SDave Airlie #define R500_VBLANK_INT     (1<<16)
1399c0e09200SDave Airlie 
1400c0e09200SDave Airlie #define R500_DxMODE_INT_MASK 0x6540
1401c0e09200SDave Airlie #define R500_D1MODE_INT_MASK (1<<0)
1402c0e09200SDave Airlie #define R500_D2MODE_INT_MASK (1<<8)
1403c0e09200SDave Airlie 
1404c0e09200SDave Airlie #define R500_DISP_INTERRUPT_STATUS 0x7edc
1405c0e09200SDave Airlie #define R500_D1_VBLANK_INTERRUPT (1 << 4)
1406c0e09200SDave Airlie #define R500_D2_VBLANK_INTERRUPT (1 << 5)
1407c0e09200SDave Airlie 
1408befb73c2SAlex Deucher /* R6xx/R7xx registers */
1409befb73c2SAlex Deucher #define R600_MC_VM_FB_LOCATION                                 0x2180
1410befb73c2SAlex Deucher #define R600_MC_VM_AGP_TOP                                     0x2184
1411befb73c2SAlex Deucher #define R600_MC_VM_AGP_BOT                                     0x2188
1412befb73c2SAlex Deucher #define R600_MC_VM_AGP_BASE                                    0x218c
1413befb73c2SAlex Deucher #define R600_MC_VM_SYSTEM_APERTURE_LOW_ADDR                    0x2190
1414befb73c2SAlex Deucher #define R600_MC_VM_SYSTEM_APERTURE_HIGH_ADDR                   0x2194
1415befb73c2SAlex Deucher #define R600_MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR                0x2198
1416befb73c2SAlex Deucher 
1417befb73c2SAlex Deucher #define R700_MC_VM_FB_LOCATION                                 0x2024
1418befb73c2SAlex Deucher #define R700_MC_VM_AGP_TOP                                     0x2028
1419befb73c2SAlex Deucher #define R700_MC_VM_AGP_BOT                                     0x202c
1420befb73c2SAlex Deucher #define R700_MC_VM_AGP_BASE                                    0x2030
1421befb73c2SAlex Deucher #define R700_MC_VM_SYSTEM_APERTURE_LOW_ADDR                    0x2034
1422befb73c2SAlex Deucher #define R700_MC_VM_SYSTEM_APERTURE_HIGH_ADDR                   0x2038
1423befb73c2SAlex Deucher #define R700_MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR                0x203c
1424befb73c2SAlex Deucher 
1425befb73c2SAlex Deucher #define R600_MCD_RD_A_CNTL                                     0x219c
1426befb73c2SAlex Deucher #define R600_MCD_RD_B_CNTL                                     0x21a0
1427befb73c2SAlex Deucher 
1428befb73c2SAlex Deucher #define R600_MCD_WR_A_CNTL                                     0x21a4
1429befb73c2SAlex Deucher #define R600_MCD_WR_B_CNTL                                     0x21a8
1430befb73c2SAlex Deucher 
1431befb73c2SAlex Deucher #define R600_MCD_RD_SYS_CNTL                                   0x2200
1432befb73c2SAlex Deucher #define R600_MCD_WR_SYS_CNTL                                   0x2214
1433befb73c2SAlex Deucher 
1434befb73c2SAlex Deucher #define R600_MCD_RD_GFX_CNTL                                   0x21fc
1435befb73c2SAlex Deucher #define R600_MCD_RD_HDP_CNTL                                   0x2204
1436befb73c2SAlex Deucher #define R600_MCD_RD_PDMA_CNTL                                  0x2208
1437befb73c2SAlex Deucher #define R600_MCD_RD_SEM_CNTL                                   0x220c
1438befb73c2SAlex Deucher #define R600_MCD_WR_GFX_CNTL                                   0x2210
1439befb73c2SAlex Deucher #define R600_MCD_WR_HDP_CNTL                                   0x2218
1440befb73c2SAlex Deucher #define R600_MCD_WR_PDMA_CNTL                                  0x221c
1441befb73c2SAlex Deucher #define R600_MCD_WR_SEM_CNTL                                   0x2220
1442befb73c2SAlex Deucher 
1443befb73c2SAlex Deucher #       define R600_MCD_L1_TLB                                 (1 << 0)
1444befb73c2SAlex Deucher #       define R600_MCD_L1_FRAG_PROC                           (1 << 1)
1445befb73c2SAlex Deucher #       define R600_MCD_L1_STRICT_ORDERING                     (1 << 2)
1446befb73c2SAlex Deucher 
1447befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_ACCESS_MODE_MASK                (3 << 6)
1448befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_ACCESS_MODE_PA_ONLY             (0 << 6)
1449befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_ACCESS_MODE_USE_SYS_MAP         (1 << 6)
1450befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_ACCESS_MODE_IN_SYS              (2 << 6)
1451befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_ACCESS_MODE_NOT_IN_SYS          (3 << 6)
1452befb73c2SAlex Deucher 
1453befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU    (0 << 8)
1454befb73c2SAlex Deucher #       define R600_MCD_SYSTEM_APERTURE_UNMAPPED_ACCESS_DEFAULT_PAGE (1 << 8)
1455befb73c2SAlex Deucher 
1456befb73c2SAlex Deucher #       define R600_MCD_SEMAPHORE_MODE                         (1 << 10)
1457befb73c2SAlex Deucher #       define R600_MCD_WAIT_L2_QUERY                          (1 << 11)
1458befb73c2SAlex Deucher #       define R600_MCD_EFFECTIVE_L1_TLB_SIZE(x)               ((x) << 12)
1459befb73c2SAlex Deucher #       define R600_MCD_EFFECTIVE_L1_QUEUE_SIZE(x)             ((x) << 15)
1460befb73c2SAlex Deucher 
1461befb73c2SAlex Deucher #define R700_MC_VM_MD_L1_TLB0_CNTL                             0x2654
1462befb73c2SAlex Deucher #define R700_MC_VM_MD_L1_TLB1_CNTL                             0x2658
1463befb73c2SAlex Deucher #define R700_MC_VM_MD_L1_TLB2_CNTL                             0x265c
1464befb73c2SAlex Deucher 
1465befb73c2SAlex Deucher #define R700_MC_VM_MB_L1_TLB0_CNTL                             0x2234
1466befb73c2SAlex Deucher #define R700_MC_VM_MB_L1_TLB1_CNTL                             0x2238
1467befb73c2SAlex Deucher #define R700_MC_VM_MB_L1_TLB2_CNTL                             0x223c
1468befb73c2SAlex Deucher #define R700_MC_VM_MB_L1_TLB3_CNTL                             0x2240
1469befb73c2SAlex Deucher 
1470befb73c2SAlex Deucher #       define R700_ENABLE_L1_TLB                              (1 << 0)
1471befb73c2SAlex Deucher #       define R700_ENABLE_L1_FRAGMENT_PROCESSING              (1 << 1)
1472befb73c2SAlex Deucher #       define R700_SYSTEM_ACCESS_MODE_IN_SYS                  (2 << 3)
1473befb73c2SAlex Deucher #       define R700_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU  (0 << 5)
1474befb73c2SAlex Deucher #       define R700_EFFECTIVE_L1_TLB_SIZE(x)                   ((x) << 15)
1475befb73c2SAlex Deucher #       define R700_EFFECTIVE_L1_QUEUE_SIZE(x)                 ((x) << 18)
1476befb73c2SAlex Deucher 
1477befb73c2SAlex Deucher #define R700_MC_ARB_RAMCFG                                     0x2760
1478befb73c2SAlex Deucher #       define R700_NOOFBANK_SHIFT                             0
1479befb73c2SAlex Deucher #       define R700_NOOFBANK_MASK                              0x3
1480befb73c2SAlex Deucher #       define R700_NOOFRANK_SHIFT                             2
1481befb73c2SAlex Deucher #       define R700_NOOFRANK_MASK                              0x1
1482befb73c2SAlex Deucher #       define R700_NOOFROWS_SHIFT                             3
1483befb73c2SAlex Deucher #       define R700_NOOFROWS_MASK                              0x7
1484befb73c2SAlex Deucher #       define R700_NOOFCOLS_SHIFT                             6
1485befb73c2SAlex Deucher #       define R700_NOOFCOLS_MASK                              0x3
1486befb73c2SAlex Deucher #       define R700_CHANSIZE_SHIFT                             8
1487befb73c2SAlex Deucher #       define R700_CHANSIZE_MASK                              0x1
1488befb73c2SAlex Deucher #       define R700_BURSTLENGTH_SHIFT                          9
1489befb73c2SAlex Deucher #       define R700_BURSTLENGTH_MASK                           0x1
1490befb73c2SAlex Deucher #define R600_RAMCFG                                            0x2408
1491befb73c2SAlex Deucher #       define R600_NOOFBANK_SHIFT                             0
1492befb73c2SAlex Deucher #       define R600_NOOFBANK_MASK                              0x1
1493befb73c2SAlex Deucher #       define R600_NOOFRANK_SHIFT                             1
1494befb73c2SAlex Deucher #       define R600_NOOFRANK_MASK                              0x1
1495befb73c2SAlex Deucher #       define R600_NOOFROWS_SHIFT                             2
1496befb73c2SAlex Deucher #       define R600_NOOFROWS_MASK                              0x7
1497befb73c2SAlex Deucher #       define R600_NOOFCOLS_SHIFT                             5
1498befb73c2SAlex Deucher #       define R600_NOOFCOLS_MASK                              0x3
1499befb73c2SAlex Deucher #       define R600_CHANSIZE_SHIFT                             7
1500befb73c2SAlex Deucher #       define R600_CHANSIZE_MASK                              0x1
1501befb73c2SAlex Deucher #       define R600_BURSTLENGTH_SHIFT                          8
1502befb73c2SAlex Deucher #       define R600_BURSTLENGTH_MASK                           0x1
1503befb73c2SAlex Deucher 
1504befb73c2SAlex Deucher #define R600_VM_L2_CNTL                                        0x1400
1505befb73c2SAlex Deucher #       define R600_VM_L2_CACHE_EN                             (1 << 0)
1506befb73c2SAlex Deucher #       define R600_VM_L2_FRAG_PROC                            (1 << 1)
1507befb73c2SAlex Deucher #       define R600_VM_ENABLE_PTE_CACHE_LRU_W                  (1 << 9)
1508befb73c2SAlex Deucher #       define R600_VM_L2_CNTL_QUEUE_SIZE(x)                   ((x) << 13)
1509befb73c2SAlex Deucher #       define R700_VM_L2_CNTL_QUEUE_SIZE(x)                   ((x) << 14)
1510befb73c2SAlex Deucher 
1511befb73c2SAlex Deucher #define R600_VM_L2_CNTL2                                       0x1404
1512befb73c2SAlex Deucher #       define R600_VM_L2_CNTL2_INVALIDATE_ALL_L1_TLBS         (1 << 0)
1513befb73c2SAlex Deucher #       define R600_VM_L2_CNTL2_INVALIDATE_L2_CACHE            (1 << 1)
1514befb73c2SAlex Deucher #define R600_VM_L2_CNTL3                                       0x1408
1515befb73c2SAlex Deucher #       define R600_VM_L2_CNTL3_BANK_SELECT_0(x)               ((x) << 0)
1516befb73c2SAlex Deucher #       define R600_VM_L2_CNTL3_BANK_SELECT_1(x)               ((x) << 5)
1517befb73c2SAlex Deucher #       define R600_VM_L2_CNTL3_CACHE_UPDATE_MODE(x)           ((x) << 10)
1518befb73c2SAlex Deucher #       define R700_VM_L2_CNTL3_BANK_SELECT(x)                 ((x) << 0)
1519befb73c2SAlex Deucher #       define R700_VM_L2_CNTL3_CACHE_UPDATE_MODE(x)           ((x) << 6)
1520befb73c2SAlex Deucher 
1521befb73c2SAlex Deucher #define R600_VM_L2_STATUS                                      0x140c
1522befb73c2SAlex Deucher 
1523befb73c2SAlex Deucher #define R600_VM_CONTEXT0_CNTL                                  0x1410
1524befb73c2SAlex Deucher #       define R600_VM_ENABLE_CONTEXT                          (1 << 0)
1525befb73c2SAlex Deucher #       define R600_VM_PAGE_TABLE_DEPTH_FLAT                   (0 << 1)
1526befb73c2SAlex Deucher 
1527befb73c2SAlex Deucher #define R600_VM_CONTEXT0_CNTL2                                 0x1430
1528befb73c2SAlex Deucher #define R600_VM_CONTEXT0_REQUEST_RESPONSE                      0x1470
1529befb73c2SAlex Deucher #define R600_VM_CONTEXT0_INVALIDATION_LOW_ADDR                 0x1490
1530befb73c2SAlex Deucher #define R600_VM_CONTEXT0_INVALIDATION_HIGH_ADDR                0x14b0
1531befb73c2SAlex Deucher #define R600_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR                  0x1574
1532befb73c2SAlex Deucher #define R600_VM_CONTEXT0_PAGE_TABLE_START_ADDR                 0x1594
1533befb73c2SAlex Deucher #define R600_VM_CONTEXT0_PAGE_TABLE_END_ADDR                   0x15b4
1534befb73c2SAlex Deucher 
1535befb73c2SAlex Deucher #define R700_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR                  0x153c
1536befb73c2SAlex Deucher #define R700_VM_CONTEXT0_PAGE_TABLE_START_ADDR                 0x155c
1537befb73c2SAlex Deucher #define R700_VM_CONTEXT0_PAGE_TABLE_END_ADDR                   0x157c
1538befb73c2SAlex Deucher 
1539befb73c2SAlex Deucher #define R600_HDP_HOST_PATH_CNTL                                0x2c00
1540befb73c2SAlex Deucher 
1541befb73c2SAlex Deucher #define R600_GRBM_CNTL                                         0x8000
1542befb73c2SAlex Deucher #       define R600_GRBM_READ_TIMEOUT(x)                       ((x) << 0)
1543befb73c2SAlex Deucher 
1544befb73c2SAlex Deucher #define R600_GRBM_STATUS                                       0x8010
1545befb73c2SAlex Deucher #       define R600_CMDFIFO_AVAIL_MASK                         0x1f
1546befb73c2SAlex Deucher #       define R700_CMDFIFO_AVAIL_MASK                         0xf
1547befb73c2SAlex Deucher #       define R600_GUI_ACTIVE                                 (1 << 31)
1548befb73c2SAlex Deucher #define R600_GRBM_STATUS2                                      0x8014
1549befb73c2SAlex Deucher #define R600_GRBM_SOFT_RESET                                   0x8020
1550befb73c2SAlex Deucher #       define R600_SOFT_RESET_CP                              (1 << 0)
1551befb73c2SAlex Deucher #define R600_WAIT_UNTIL		                               0x8040
1552befb73c2SAlex Deucher 
1553befb73c2SAlex Deucher #define R600_CP_SEM_WAIT_TIMER                                 0x85bc
1554befb73c2SAlex Deucher #define R600_CP_ME_CNTL                                        0x86d8
1555befb73c2SAlex Deucher #       define R600_CP_ME_HALT                                 (1 << 28)
1556befb73c2SAlex Deucher #define R600_CP_QUEUE_THRESHOLDS                               0x8760
1557befb73c2SAlex Deucher #       define R600_ROQ_IB1_START(x)                           ((x) << 0)
1558befb73c2SAlex Deucher #       define R600_ROQ_IB2_START(x)                           ((x) << 8)
1559befb73c2SAlex Deucher #define R600_CP_MEQ_THRESHOLDS                                 0x8764
1560befb73c2SAlex Deucher #       define R700_STQ_SPLIT(x)                               ((x) << 0)
1561befb73c2SAlex Deucher #       define R600_MEQ_END(x)                                 ((x) << 16)
1562befb73c2SAlex Deucher #       define R600_ROQ_END(x)                                 ((x) << 24)
1563befb73c2SAlex Deucher #define R600_CP_PERFMON_CNTL                                   0x87fc
1564befb73c2SAlex Deucher #define R600_CP_RB_BASE                                        0xc100
1565befb73c2SAlex Deucher #define R600_CP_RB_CNTL                                        0xc104
1566befb73c2SAlex Deucher #       define R600_RB_BUFSZ(x)                                ((x) << 0)
1567befb73c2SAlex Deucher #       define R600_RB_BLKSZ(x)                                ((x) << 8)
1568befb73c2SAlex Deucher #       define R600_RB_NO_UPDATE                               (1 << 27)
1569befb73c2SAlex Deucher #       define R600_RB_RPTR_WR_ENA                             (1 << 31)
1570befb73c2SAlex Deucher #define R600_CP_RB_RPTR_WR                                     0xc108
1571befb73c2SAlex Deucher #define R600_CP_RB_RPTR_ADDR                                   0xc10c
1572befb73c2SAlex Deucher #define R600_CP_RB_RPTR_ADDR_HI                                0xc110
1573befb73c2SAlex Deucher #define R600_CP_RB_WPTR                                        0xc114
1574befb73c2SAlex Deucher #define R600_CP_RB_WPTR_ADDR                                   0xc118
1575befb73c2SAlex Deucher #define R600_CP_RB_WPTR_ADDR_HI                                0xc11c
1576befb73c2SAlex Deucher #define R600_CP_RB_RPTR                                        0x8700
1577befb73c2SAlex Deucher #define R600_CP_RB_WPTR_DELAY                                  0x8704
1578befb73c2SAlex Deucher #define R600_CP_PFP_UCODE_ADDR                                 0xc150
1579befb73c2SAlex Deucher #define R600_CP_PFP_UCODE_DATA                                 0xc154
1580befb73c2SAlex Deucher #define R600_CP_ME_RAM_RADDR                                   0xc158
1581befb73c2SAlex Deucher #define R600_CP_ME_RAM_WADDR                                   0xc15c
1582befb73c2SAlex Deucher #define R600_CP_ME_RAM_DATA                                    0xc160
1583befb73c2SAlex Deucher #define R600_CP_DEBUG                                          0xc1fc
1584befb73c2SAlex Deucher 
1585befb73c2SAlex Deucher #define R600_PA_CL_ENHANCE                                     0x8a14
1586befb73c2SAlex Deucher #       define R600_CLIP_VTX_REORDER_ENA                       (1 << 0)
1587befb73c2SAlex Deucher #       define R600_NUM_CLIP_SEQ(x)                            ((x) << 1)
1588befb73c2SAlex Deucher #define R600_PA_SC_LINE_STIPPLE_STATE                          0x8b10
1589befb73c2SAlex Deucher #define R600_PA_SC_MULTI_CHIP_CNTL                             0x8b20
1590befb73c2SAlex Deucher #define R700_PA_SC_FORCE_EOV_MAX_CNTS                          0x8b24
1591befb73c2SAlex Deucher #       define R700_FORCE_EOV_MAX_CLK_CNT(x)                   ((x) << 0)
1592befb73c2SAlex Deucher #       define R700_FORCE_EOV_MAX_REZ_CNT(x)                   ((x) << 16)
1593befb73c2SAlex Deucher #define R600_PA_SC_AA_SAMPLE_LOCS_2S                           0x8b40
1594befb73c2SAlex Deucher #define R600_PA_SC_AA_SAMPLE_LOCS_4S                           0x8b44
1595befb73c2SAlex Deucher #define R600_PA_SC_AA_SAMPLE_LOCS_8S_WD0                       0x8b48
1596befb73c2SAlex Deucher #define R600_PA_SC_AA_SAMPLE_LOCS_8S_WD1                       0x8b4c
1597befb73c2SAlex Deucher #       define R600_S0_X(x)                                    ((x) << 0)
1598befb73c2SAlex Deucher #       define R600_S0_Y(x)                                    ((x) << 4)
1599befb73c2SAlex Deucher #       define R600_S1_X(x)                                    ((x) << 8)
1600befb73c2SAlex Deucher #       define R600_S1_Y(x)                                    ((x) << 12)
1601befb73c2SAlex Deucher #       define R600_S2_X(x)                                    ((x) << 16)
1602befb73c2SAlex Deucher #       define R600_S2_Y(x)                                    ((x) << 20)
1603befb73c2SAlex Deucher #       define R600_S3_X(x)                                    ((x) << 24)
1604befb73c2SAlex Deucher #       define R600_S3_Y(x)                                    ((x) << 28)
1605befb73c2SAlex Deucher #       define R600_S4_X(x)                                    ((x) << 0)
1606befb73c2SAlex Deucher #       define R600_S4_Y(x)                                    ((x) << 4)
1607befb73c2SAlex Deucher #       define R600_S5_X(x)                                    ((x) << 8)
1608befb73c2SAlex Deucher #       define R600_S5_Y(x)                                    ((x) << 12)
1609befb73c2SAlex Deucher #       define R600_S6_X(x)                                    ((x) << 16)
1610befb73c2SAlex Deucher #       define R600_S6_Y(x)                                    ((x) << 20)
1611befb73c2SAlex Deucher #       define R600_S7_X(x)                                    ((x) << 24)
1612befb73c2SAlex Deucher #       define R600_S7_Y(x)                                    ((x) << 28)
1613befb73c2SAlex Deucher #define R600_PA_SC_FIFO_SIZE                                   0x8bd0
1614befb73c2SAlex Deucher #       define R600_SC_PRIM_FIFO_SIZE(x)                       ((x) << 0)
1615befb73c2SAlex Deucher #       define R600_SC_HIZ_TILE_FIFO_SIZE(x)                   ((x) << 8)
1616befb73c2SAlex Deucher #       define R600_SC_EARLYZ_TILE_FIFO_SIZE(x)                ((x) << 16)
1617befb73c2SAlex Deucher #define R700_PA_SC_FIFO_SIZE_R7XX                              0x8bcc
1618befb73c2SAlex Deucher #       define R700_SC_PRIM_FIFO_SIZE(x)                       ((x) << 0)
1619befb73c2SAlex Deucher #       define R700_SC_HIZ_TILE_FIFO_SIZE(x)                   ((x) << 12)
1620befb73c2SAlex Deucher #       define R700_SC_EARLYZ_TILE_FIFO_SIZE(x)                ((x) << 20)
1621befb73c2SAlex Deucher #define R600_PA_SC_ENHANCE                                     0x8bf0
1622befb73c2SAlex Deucher #       define R600_FORCE_EOV_MAX_CLK_CNT(x)                   ((x) << 0)
1623befb73c2SAlex Deucher #       define R600_FORCE_EOV_MAX_TILE_CNT(x)                  ((x) << 12)
1624befb73c2SAlex Deucher #define R600_PA_SC_CLIPRECT_RULE                               0x2820c
1625befb73c2SAlex Deucher #define R700_PA_SC_EDGERULE                                    0x28230
1626befb73c2SAlex Deucher #define R600_PA_SC_LINE_STIPPLE                                0x28a0c
1627befb73c2SAlex Deucher #define R600_PA_SC_MODE_CNTL                                   0x28a4c
1628befb73c2SAlex Deucher #define R600_PA_SC_AA_CONFIG                                   0x28c04
1629befb73c2SAlex Deucher 
1630befb73c2SAlex Deucher #define R600_SX_EXPORT_BUFFER_SIZES                            0x900c
1631befb73c2SAlex Deucher #       define R600_COLOR_BUFFER_SIZE(x)                       ((x) << 0)
1632befb73c2SAlex Deucher #       define R600_POSITION_BUFFER_SIZE(x)                    ((x) << 8)
1633befb73c2SAlex Deucher #       define R600_SMX_BUFFER_SIZE(x)                         ((x) << 16)
1634befb73c2SAlex Deucher #define R600_SX_DEBUG_1                                        0x9054
1635befb73c2SAlex Deucher #       define R600_SMX_EVENT_RELEASE                          (1 << 0)
1636befb73c2SAlex Deucher #       define R600_ENABLE_NEW_SMX_ADDRESS                     (1 << 16)
1637befb73c2SAlex Deucher #define R700_SX_DEBUG_1                                        0x9058
1638befb73c2SAlex Deucher #       define R700_ENABLE_NEW_SMX_ADDRESS                     (1 << 16)
1639befb73c2SAlex Deucher #define R600_SX_MISC                                           0x28350
1640befb73c2SAlex Deucher 
1641befb73c2SAlex Deucher #define R600_DB_DEBUG                                          0x9830
1642befb73c2SAlex Deucher #       define R600_PREZ_MUST_WAIT_FOR_POSTZ_DONE              (1 << 31)
1643befb73c2SAlex Deucher #define R600_DB_WATERMARKS                                     0x9838
1644befb73c2SAlex Deucher #       define R600_DEPTH_FREE(x)                              ((x) << 0)
1645befb73c2SAlex Deucher #       define R600_DEPTH_FLUSH(x)                             ((x) << 5)
1646befb73c2SAlex Deucher #       define R600_DEPTH_PENDING_FREE(x)                      ((x) << 15)
1647befb73c2SAlex Deucher #       define R600_DEPTH_CACHELINE_FREE(x)                    ((x) << 20)
1648befb73c2SAlex Deucher #define R700_DB_DEBUG3                                         0x98b0
1649befb73c2SAlex Deucher #       define R700_DB_CLK_OFF_DELAY(x)                        ((x) << 11)
1650befb73c2SAlex Deucher #define RV700_DB_DEBUG4                                        0x9b8c
1651befb73c2SAlex Deucher #       define RV700_DISABLE_TILE_COVERED_FOR_PS_ITER          (1 << 6)
1652befb73c2SAlex Deucher 
1653befb73c2SAlex Deucher #define R600_VGT_CACHE_INVALIDATION                            0x88c4
1654befb73c2SAlex Deucher #       define R600_CACHE_INVALIDATION(x)                      ((x) << 0)
1655befb73c2SAlex Deucher #       define R600_VC_ONLY                                    0
1656befb73c2SAlex Deucher #       define R600_TC_ONLY                                    1
1657befb73c2SAlex Deucher #       define R600_VC_AND_TC                                  2
1658befb73c2SAlex Deucher #       define R700_AUTO_INVLD_EN(x)                           ((x) << 6)
1659befb73c2SAlex Deucher #       define R700_NO_AUTO                                    0
1660befb73c2SAlex Deucher #       define R700_ES_AUTO                                    1
1661befb73c2SAlex Deucher #       define R700_GS_AUTO                                    2
1662befb73c2SAlex Deucher #       define R700_ES_AND_GS_AUTO                             3
1663befb73c2SAlex Deucher #define R600_VGT_GS_PER_ES                                     0x88c8
1664befb73c2SAlex Deucher #define R600_VGT_ES_PER_GS                                     0x88cc
1665befb73c2SAlex Deucher #define R600_VGT_GS_PER_VS                                     0x88e8
1666befb73c2SAlex Deucher #define R600_VGT_GS_VERTEX_REUSE                               0x88d4
1667befb73c2SAlex Deucher #define R600_VGT_NUM_INSTANCES                                 0x8974
1668befb73c2SAlex Deucher #define R600_VGT_STRMOUT_EN                                    0x28ab0
1669befb73c2SAlex Deucher #define R600_VGT_EVENT_INITIATOR                               0x28a90
1670befb73c2SAlex Deucher #       define R600_CACHE_FLUSH_AND_INV_EVENT                  (0x16 << 0)
1671befb73c2SAlex Deucher #define R600_VGT_VERTEX_REUSE_BLOCK_CNTL                       0x28c58
1672befb73c2SAlex Deucher #       define R600_VTX_REUSE_DEPTH_MASK                       0xff
1673befb73c2SAlex Deucher #define R600_VGT_OUT_DEALLOC_CNTL                              0x28c5c
1674befb73c2SAlex Deucher #       define R600_DEALLOC_DIST_MASK                          0x7f
1675befb73c2SAlex Deucher 
1676befb73c2SAlex Deucher #define R600_CB_COLOR0_BASE                                    0x28040
1677befb73c2SAlex Deucher #define R600_CB_COLOR1_BASE                                    0x28044
1678befb73c2SAlex Deucher #define R600_CB_COLOR2_BASE                                    0x28048
1679befb73c2SAlex Deucher #define R600_CB_COLOR3_BASE                                    0x2804c
1680befb73c2SAlex Deucher #define R600_CB_COLOR4_BASE                                    0x28050
1681befb73c2SAlex Deucher #define R600_CB_COLOR5_BASE                                    0x28054
1682befb73c2SAlex Deucher #define R600_CB_COLOR6_BASE                                    0x28058
1683befb73c2SAlex Deucher #define R600_CB_COLOR7_BASE                                    0x2805c
1684befb73c2SAlex Deucher #define R600_CB_COLOR7_FRAG                                    0x280fc
1685befb73c2SAlex Deucher 
16863ce0a23dSJerome Glisse #define R600_CB_COLOR0_SIZE                                    0x28060
16873ce0a23dSJerome Glisse #define R600_CB_COLOR0_VIEW                                    0x28080
16883ce0a23dSJerome Glisse #define R600_CB_COLOR0_INFO                                    0x280a0
16893ce0a23dSJerome Glisse #define R600_CB_COLOR0_TILE                                    0x280c0
16903ce0a23dSJerome Glisse #define R600_CB_COLOR0_FRAG                                    0x280e0
16913ce0a23dSJerome Glisse #define R600_CB_COLOR0_MASK                                    0x28100
16923ce0a23dSJerome Glisse 
16933ce0a23dSJerome Glisse #define AVIVO_D1MODE_VLINE_START_END                           0x6538
16943ce0a23dSJerome Glisse #define AVIVO_D2MODE_VLINE_START_END                           0x6d38
16953ce0a23dSJerome Glisse #define R600_CP_COHER_BASE                                     0x85f8
16963ce0a23dSJerome Glisse #define R600_DB_DEPTH_BASE                                     0x2800c
16973ce0a23dSJerome Glisse #define R600_SQ_PGM_START_FS                                   0x28894
16983ce0a23dSJerome Glisse #define R600_SQ_PGM_START_ES                                   0x28880
16993ce0a23dSJerome Glisse #define R600_SQ_PGM_START_VS                                   0x28858
17003ce0a23dSJerome Glisse #define R600_SQ_PGM_RESOURCES_VS                               0x28868
17013ce0a23dSJerome Glisse #define R600_SQ_PGM_CF_OFFSET_VS                               0x288d0
17023ce0a23dSJerome Glisse #define R600_SQ_PGM_START_GS                                   0x2886c
17033ce0a23dSJerome Glisse #define R600_SQ_PGM_START_PS                                   0x28840
17043ce0a23dSJerome Glisse #define R600_SQ_PGM_RESOURCES_PS                               0x28850
17053ce0a23dSJerome Glisse #define R600_SQ_PGM_EXPORTS_PS                                 0x28854
17063ce0a23dSJerome Glisse #define R600_SQ_PGM_CF_OFFSET_PS                               0x288cc
17073ce0a23dSJerome Glisse #define R600_VGT_DMA_BASE                                      0x287e8
17083ce0a23dSJerome Glisse #define R600_VGT_DMA_BASE_HI                                   0x287e4
17093ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_0                         0x28b10
17103ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_1                         0x28b14
17113ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_2                         0x28b18
17123ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_3                         0x28b1c
17133ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_HI_0                      0x28b44
17143ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_HI_1                      0x28b48
17153ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_HI_2                      0x28b4c
17163ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BASE_OFFSET_HI_3                      0x28b50
17173ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_BASE_0                         0x28ad8
17183ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_BASE_1                         0x28ae8
17193ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_BASE_2                         0x28af8
17203ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_BASE_3                         0x28b08
17213ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_OFFSET_0                       0x28adc
17223ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_OFFSET_1                       0x28aec
17233ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_OFFSET_2                       0x28afc
17243ce0a23dSJerome Glisse #define R600_VGT_STRMOUT_BUFFER_OFFSET_3                       0x28b0c
17253ce0a23dSJerome Glisse 
17263ce0a23dSJerome Glisse #define R600_VGT_PRIMITIVE_TYPE                                0x8958
17273ce0a23dSJerome Glisse 
17283ce0a23dSJerome Glisse #define R600_PA_SC_SCREEN_SCISSOR_TL                           0x28030
17293ce0a23dSJerome Glisse #define R600_PA_SC_GENERIC_SCISSOR_TL                          0x28240
17303ce0a23dSJerome Glisse #define R600_PA_SC_WINDOW_SCISSOR_TL                           0x28204
17313ce0a23dSJerome Glisse 
1732befb73c2SAlex Deucher #define R600_TC_CNTL                                           0x9608
1733befb73c2SAlex Deucher #       define R600_TC_L2_SIZE(x)                              ((x) << 5)
1734befb73c2SAlex Deucher #       define R600_L2_DISABLE_LATE_HIT                        (1 << 9)
1735befb73c2SAlex Deucher 
1736befb73c2SAlex Deucher #define R600_ARB_POP                                           0x2418
1737befb73c2SAlex Deucher #       define R600_ENABLE_TC128                               (1 << 30)
1738befb73c2SAlex Deucher #define R600_ARB_GDEC_RD_CNTL                                  0x246c
1739befb73c2SAlex Deucher 
1740befb73c2SAlex Deucher #define R600_TA_CNTL_AUX                                       0x9508
1741befb73c2SAlex Deucher #       define R600_DISABLE_CUBE_WRAP                          (1 << 0)
1742befb73c2SAlex Deucher #       define R600_DISABLE_CUBE_ANISO                         (1 << 1)
1743befb73c2SAlex Deucher #       define R700_GETLOD_SELECT(x)                           ((x) << 2)
1744befb73c2SAlex Deucher #       define R600_SYNC_GRADIENT                              (1 << 24)
1745befb73c2SAlex Deucher #       define R600_SYNC_WALKER                                (1 << 25)
1746befb73c2SAlex Deucher #       define R600_SYNC_ALIGNER                               (1 << 26)
1747befb73c2SAlex Deucher #       define R600_BILINEAR_PRECISION_6_BIT                   (0 << 31)
1748befb73c2SAlex Deucher #       define R600_BILINEAR_PRECISION_8_BIT                   (1 << 31)
1749befb73c2SAlex Deucher 
1750befb73c2SAlex Deucher #define R700_TCP_CNTL                                          0x9610
1751befb73c2SAlex Deucher 
1752befb73c2SAlex Deucher #define R600_SMX_DC_CTL0                                       0xa020
1753befb73c2SAlex Deucher #       define R700_USE_HASH_FUNCTION                          (1 << 0)
1754befb73c2SAlex Deucher #       define R700_CACHE_DEPTH(x)                             ((x) << 1)
1755befb73c2SAlex Deucher #       define R700_FLUSH_ALL_ON_EVENT                         (1 << 10)
1756befb73c2SAlex Deucher #       define R700_STALL_ON_EVENT                             (1 << 11)
1757befb73c2SAlex Deucher #define R700_SMX_EVENT_CTL                                     0xa02c
1758befb73c2SAlex Deucher #       define R700_ES_FLUSH_CTL(x)                            ((x) << 0)
1759befb73c2SAlex Deucher #       define R700_GS_FLUSH_CTL(x)                            ((x) << 3)
1760befb73c2SAlex Deucher #       define R700_ACK_FLUSH_CTL(x)                           ((x) << 6)
1761befb73c2SAlex Deucher #       define R700_SYNC_FLUSH_CTL                             (1 << 8)
1762befb73c2SAlex Deucher 
1763befb73c2SAlex Deucher #define R600_SQ_CONFIG                                         0x8c00
1764befb73c2SAlex Deucher #       define R600_VC_ENABLE                                  (1 << 0)
1765befb73c2SAlex Deucher #       define R600_EXPORT_SRC_C                               (1 << 1)
1766befb73c2SAlex Deucher #       define R600_DX9_CONSTS                                 (1 << 2)
1767befb73c2SAlex Deucher #       define R600_ALU_INST_PREFER_VECTOR                     (1 << 3)
1768befb73c2SAlex Deucher #       define R600_DX10_CLAMP                                 (1 << 4)
1769befb73c2SAlex Deucher #       define R600_CLAUSE_SEQ_PRIO(x)                         ((x) << 8)
1770befb73c2SAlex Deucher #       define R600_PS_PRIO(x)                                 ((x) << 24)
1771befb73c2SAlex Deucher #       define R600_VS_PRIO(x)                                 ((x) << 26)
1772befb73c2SAlex Deucher #       define R600_GS_PRIO(x)                                 ((x) << 28)
1773befb73c2SAlex Deucher #       define R600_ES_PRIO(x)                                 ((x) << 30)
1774befb73c2SAlex Deucher #define R600_SQ_GPR_RESOURCE_MGMT_1                            0x8c04
1775befb73c2SAlex Deucher #       define R600_NUM_PS_GPRS(x)                             ((x) << 0)
1776befb73c2SAlex Deucher #       define R600_NUM_VS_GPRS(x)                             ((x) << 16)
1777befb73c2SAlex Deucher #       define R700_DYN_GPR_ENABLE                             (1 << 27)
1778befb73c2SAlex Deucher #       define R600_NUM_CLAUSE_TEMP_GPRS(x)                    ((x) << 28)
1779befb73c2SAlex Deucher #define R600_SQ_GPR_RESOURCE_MGMT_2                            0x8c08
1780befb73c2SAlex Deucher #       define R600_NUM_GS_GPRS(x)                             ((x) << 0)
1781befb73c2SAlex Deucher #       define R600_NUM_ES_GPRS(x)                             ((x) << 16)
1782befb73c2SAlex Deucher #define R600_SQ_THREAD_RESOURCE_MGMT                           0x8c0c
1783befb73c2SAlex Deucher #       define R600_NUM_PS_THREADS(x)                          ((x) << 0)
1784befb73c2SAlex Deucher #       define R600_NUM_VS_THREADS(x)                          ((x) << 8)
1785befb73c2SAlex Deucher #       define R600_NUM_GS_THREADS(x)                          ((x) << 16)
1786befb73c2SAlex Deucher #       define R600_NUM_ES_THREADS(x)                          ((x) << 24)
1787befb73c2SAlex Deucher #define R600_SQ_STACK_RESOURCE_MGMT_1                          0x8c10
1788befb73c2SAlex Deucher #       define R600_NUM_PS_STACK_ENTRIES(x)                    ((x) << 0)
1789befb73c2SAlex Deucher #       define R600_NUM_VS_STACK_ENTRIES(x)                    ((x) << 16)
1790befb73c2SAlex Deucher #define R600_SQ_STACK_RESOURCE_MGMT_2                          0x8c14
1791befb73c2SAlex Deucher #       define R600_NUM_GS_STACK_ENTRIES(x)                    ((x) << 0)
1792befb73c2SAlex Deucher #       define R600_NUM_ES_STACK_ENTRIES(x)                    ((x) << 16)
1793befb73c2SAlex Deucher #define R600_SQ_MS_FIFO_SIZES                                  0x8cf0
1794befb73c2SAlex Deucher #       define R600_CACHE_FIFO_SIZE(x)                         ((x) << 0)
1795befb73c2SAlex Deucher #       define R600_FETCH_FIFO_HIWATER(x)                      ((x) << 8)
1796befb73c2SAlex Deucher #       define R600_DONE_FIFO_HIWATER(x)                       ((x) << 16)
1797befb73c2SAlex Deucher #       define R600_ALU_UPDATE_FIFO_HIWATER(x)                 ((x) << 24)
1798befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_0                         0x8db0
1799befb73c2SAlex Deucher #       define R700_SIMDA_RING0(x)                             ((x) << 0)
1800befb73c2SAlex Deucher #       define R700_SIMDA_RING1(x)                             ((x) << 8)
1801befb73c2SAlex Deucher #       define R700_SIMDB_RING0(x)                             ((x) << 16)
1802befb73c2SAlex Deucher #       define R700_SIMDB_RING1(x)                             ((x) << 24)
1803befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_1                         0x8db4
1804befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_2                         0x8db8
1805befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_3                         0x8dbc
1806befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_4                         0x8dc0
1807befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_5                         0x8dc4
1808befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_6                         0x8dc8
1809befb73c2SAlex Deucher #define R700_SQ_DYN_GPR_SIZE_SIMD_AB_7                         0x8dcc
1810befb73c2SAlex Deucher 
1811befb73c2SAlex Deucher #define R600_SPI_PS_IN_CONTROL_0                               0x286cc
1812befb73c2SAlex Deucher #       define R600_NUM_INTERP(x)                              ((x) << 0)
1813befb73c2SAlex Deucher #       define R600_POSITION_ENA                               (1 << 8)
1814befb73c2SAlex Deucher #       define R600_POSITION_CENTROID                          (1 << 9)
1815befb73c2SAlex Deucher #       define R600_POSITION_ADDR(x)                           ((x) << 10)
1816befb73c2SAlex Deucher #       define R600_PARAM_GEN(x)                               ((x) << 15)
1817befb73c2SAlex Deucher #       define R600_PARAM_GEN_ADDR(x)                          ((x) << 19)
1818befb73c2SAlex Deucher #       define R600_BARYC_SAMPLE_CNTL(x)                       ((x) << 26)
1819befb73c2SAlex Deucher #       define R600_PERSP_GRADIENT_ENA                         (1 << 28)
1820befb73c2SAlex Deucher #       define R600_LINEAR_GRADIENT_ENA                        (1 << 29)
1821befb73c2SAlex Deucher #       define R600_POSITION_SAMPLE                            (1 << 30)
1822befb73c2SAlex Deucher #       define R600_BARYC_AT_SAMPLE_ENA                        (1 << 31)
1823befb73c2SAlex Deucher #define R600_SPI_PS_IN_CONTROL_1                               0x286d0
1824befb73c2SAlex Deucher #       define R600_GEN_INDEX_PIX                              (1 << 0)
1825befb73c2SAlex Deucher #       define R600_GEN_INDEX_PIX_ADDR(x)                      ((x) << 1)
1826befb73c2SAlex Deucher #       define R600_FRONT_FACE_ENA                             (1 << 8)
1827befb73c2SAlex Deucher #       define R600_FRONT_FACE_CHAN(x)                         ((x) << 9)
1828befb73c2SAlex Deucher #       define R600_FRONT_FACE_ALL_BITS                        (1 << 11)
1829befb73c2SAlex Deucher #       define R600_FRONT_FACE_ADDR(x)                         ((x) << 12)
1830befb73c2SAlex Deucher #       define R600_FOG_ADDR(x)                                ((x) << 17)
1831befb73c2SAlex Deucher #       define R600_FIXED_PT_POSITION_ENA                      (1 << 24)
1832befb73c2SAlex Deucher #       define R600_FIXED_PT_POSITION_ADDR(x)                  ((x) << 25)
1833befb73c2SAlex Deucher #       define R700_POSITION_ULC                               (1 << 30)
1834befb73c2SAlex Deucher #define R600_SPI_INPUT_Z                                       0x286d8
1835befb73c2SAlex Deucher 
1836befb73c2SAlex Deucher #define R600_SPI_CONFIG_CNTL                                   0x9100
1837befb73c2SAlex Deucher #       define R600_GPR_WRITE_PRIORITY(x)                      ((x) << 0)
1838befb73c2SAlex Deucher #       define R600_DISABLE_INTERP_1                           (1 << 5)
1839befb73c2SAlex Deucher #define R600_SPI_CONFIG_CNTL_1                                 0x913c
1840befb73c2SAlex Deucher #       define R600_VTX_DONE_DELAY(x)                          ((x) << 0)
1841befb73c2SAlex Deucher #       define R600_INTERP_ONE_PRIM_PER_ROW                    (1 << 4)
1842befb73c2SAlex Deucher 
1843befb73c2SAlex Deucher #define R600_GB_TILING_CONFIG                                  0x98f0
1844befb73c2SAlex Deucher #       define R600_PIPE_TILING(x)                             ((x) << 1)
1845befb73c2SAlex Deucher #       define R600_BANK_TILING(x)                             ((x) << 4)
1846befb73c2SAlex Deucher #       define R600_GROUP_SIZE(x)                              ((x) << 6)
1847befb73c2SAlex Deucher #       define R600_ROW_TILING(x)                              ((x) << 8)
1848befb73c2SAlex Deucher #       define R600_BANK_SWAPS(x)                              ((x) << 11)
1849befb73c2SAlex Deucher #       define R600_SAMPLE_SPLIT(x)                            ((x) << 14)
1850befb73c2SAlex Deucher #       define R600_BACKEND_MAP(x)                             ((x) << 16)
1851befb73c2SAlex Deucher #define R600_DCP_TILING_CONFIG                                 0x6ca0
1852befb73c2SAlex Deucher #define R600_HDP_TILING_CONFIG                                 0x2f3c
1853befb73c2SAlex Deucher 
1854befb73c2SAlex Deucher #define R600_CC_RB_BACKEND_DISABLE                             0x98f4
1855befb73c2SAlex Deucher #define R700_CC_SYS_RB_BACKEND_DISABLE                         0x3f88
1856befb73c2SAlex Deucher #       define R600_BACKEND_DISABLE(x)                         ((x) << 16)
1857befb73c2SAlex Deucher 
1858befb73c2SAlex Deucher #define R600_CC_GC_SHADER_PIPE_CONFIG                          0x8950
1859befb73c2SAlex Deucher #define R600_GC_USER_SHADER_PIPE_CONFIG                        0x8954
1860befb73c2SAlex Deucher #       define R600_INACTIVE_QD_PIPES(x)                       ((x) << 8)
1861befb73c2SAlex Deucher #       define R600_INACTIVE_QD_PIPES_MASK                     (0xff << 8)
1862befb73c2SAlex Deucher #       define R600_INACTIVE_SIMDS(x)                          ((x) << 16)
1863befb73c2SAlex Deucher #       define R600_INACTIVE_SIMDS_MASK                        (0xff << 16)
1864befb73c2SAlex Deucher 
1865befb73c2SAlex Deucher #define R700_CGTS_SYS_TCC_DISABLE                              0x3f90
1866befb73c2SAlex Deucher #define R700_CGTS_USER_SYS_TCC_DISABLE                         0x3f94
1867befb73c2SAlex Deucher #define R700_CGTS_TCC_DISABLE                                  0x9148
1868befb73c2SAlex Deucher #define R700_CGTS_USER_TCC_DISABLE                             0x914c
1869befb73c2SAlex Deucher 
1870c0e09200SDave Airlie /* Constants */
1871c0e09200SDave Airlie #define RADEON_MAX_USEC_TIMEOUT		100000	/* 100 ms */
1872c0e09200SDave Airlie 
1873c0e09200SDave Airlie #define RADEON_LAST_FRAME_REG		RADEON_SCRATCH_REG0
1874c0e09200SDave Airlie #define RADEON_LAST_DISPATCH_REG	RADEON_SCRATCH_REG1
1875c0e09200SDave Airlie #define RADEON_LAST_CLEAR_REG		RADEON_SCRATCH_REG2
1876c0e09200SDave Airlie #define RADEON_LAST_SWI_REG		RADEON_SCRATCH_REG3
1877c0e09200SDave Airlie #define RADEON_LAST_DISPATCH		1
1878c0e09200SDave Airlie 
1879befb73c2SAlex Deucher #define R600_LAST_FRAME_REG		R600_SCRATCH_REG0
1880befb73c2SAlex Deucher #define R600_LAST_DISPATCH_REG	        R600_SCRATCH_REG1
1881befb73c2SAlex Deucher #define R600_LAST_CLEAR_REG		R600_SCRATCH_REG2
1882befb73c2SAlex Deucher #define R600_LAST_SWI_REG		R600_SCRATCH_REG3
1883befb73c2SAlex Deucher 
1884c0e09200SDave Airlie #define RADEON_MAX_VB_AGE		0x7fffffff
1885c0e09200SDave Airlie #define RADEON_MAX_VB_VERTS		(0xffff)
1886c0e09200SDave Airlie 
1887c0e09200SDave Airlie #define RADEON_RING_HIGH_MARK		128
1888c0e09200SDave Airlie 
1889c0e09200SDave Airlie #define RADEON_PCIGART_TABLE_SIZE      (32*1024)
1890c0e09200SDave Airlie 
1891c0e09200SDave Airlie #define RADEON_READ(reg)	DRM_READ32(  dev_priv->mmio, (reg) )
1892befb73c2SAlex Deucher #define RADEON_WRITE(reg, val)                                          \
1893befb73c2SAlex Deucher do {									\
1894befb73c2SAlex Deucher 	if (reg < 0x10000) {				                \
1895befb73c2SAlex Deucher 		DRM_WRITE32(dev_priv->mmio, (reg), (val));		\
1896befb73c2SAlex Deucher 	} else {                                                        \
1897befb73c2SAlex Deucher 		DRM_WRITE32(dev_priv->mmio, RADEON_MM_INDEX, (reg));	\
1898befb73c2SAlex Deucher 		DRM_WRITE32(dev_priv->mmio, RADEON_MM_DATA, (val));	\
1899befb73c2SAlex Deucher 	}                                                               \
1900befb73c2SAlex Deucher } while (0)
1901c0e09200SDave Airlie #define RADEON_READ8(reg)	DRM_READ8(  dev_priv->mmio, (reg) )
1902c0e09200SDave Airlie #define RADEON_WRITE8(reg,val)	DRM_WRITE8( dev_priv->mmio, (reg), (val) )
1903c0e09200SDave Airlie 
1904c0e09200SDave Airlie #define RADEON_WRITE_PLL(addr, val)					\
1905c0e09200SDave Airlie do {									\
1906c0e09200SDave Airlie 	RADEON_WRITE8(RADEON_CLOCK_CNTL_INDEX,				\
1907c0e09200SDave Airlie 		       ((addr) & 0x1f) | RADEON_PLL_WR_EN );		\
1908c0e09200SDave Airlie 	RADEON_WRITE(RADEON_CLOCK_CNTL_DATA, (val));			\
1909c0e09200SDave Airlie } while (0)
1910c0e09200SDave Airlie 
1911c0e09200SDave Airlie #define RADEON_WRITE_PCIE(addr, val)					\
1912c0e09200SDave Airlie do {									\
1913c0e09200SDave Airlie 	RADEON_WRITE8(RADEON_PCIE_INDEX,				\
1914c0e09200SDave Airlie 			((addr) & 0xff));				\
1915c0e09200SDave Airlie 	RADEON_WRITE(RADEON_PCIE_DATA, (val));			\
1916c0e09200SDave Airlie } while (0)
1917c0e09200SDave Airlie 
1918c0e09200SDave Airlie #define R500_WRITE_MCIND(addr, val)					\
1919c0e09200SDave Airlie do {								\
1920c0e09200SDave Airlie 	RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff));	\
1921c0e09200SDave Airlie 	RADEON_WRITE(R520_MC_IND_DATA, (val));			\
1922c0e09200SDave Airlie 	RADEON_WRITE(R520_MC_IND_INDEX, 0);	\
1923c0e09200SDave Airlie } while (0)
1924c0e09200SDave Airlie 
1925c0e09200SDave Airlie #define RS480_WRITE_MCIND(addr, val)				\
1926c0e09200SDave Airlie do {									\
1927c0e09200SDave Airlie 	RADEON_WRITE(RS480_NB_MC_INDEX,				\
1928c0e09200SDave Airlie 			((addr) & 0xff) | RS480_NB_MC_IND_WR_EN);	\
1929c0e09200SDave Airlie 	RADEON_WRITE(RS480_NB_MC_DATA, (val));			\
1930c0e09200SDave Airlie 	RADEON_WRITE(RS480_NB_MC_INDEX, 0xff);			\
1931c0e09200SDave Airlie } while (0)
1932c0e09200SDave Airlie 
1933c0e09200SDave Airlie #define RS690_WRITE_MCIND(addr, val)					\
1934c0e09200SDave Airlie do {								\
1935c0e09200SDave Airlie 	RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_EN | ((addr) & RS690_MC_INDEX_MASK));	\
1936c0e09200SDave Airlie 	RADEON_WRITE(RS690_MC_DATA, val);			\
1937c0e09200SDave Airlie 	RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK);	\
1938c0e09200SDave Airlie } while (0)
1939c0e09200SDave Airlie 
1940c1556f71SAlex Deucher #define RS600_WRITE_MCIND(addr, val)				\
1941c1556f71SAlex Deucher do {							        \
1942c1556f71SAlex Deucher 	RADEON_WRITE(RS600_MC_INDEX, RS600_MC_IND_WR_EN | RS600_MC_IND_CITF_ARB0 | ((addr) & RS600_MC_ADDR_MASK)); \
1943c1556f71SAlex Deucher 	RADEON_WRITE(RS600_MC_DATA, val);                       \
1944c1556f71SAlex Deucher } while (0)
1945c1556f71SAlex Deucher 
1946c0e09200SDave Airlie #define IGP_WRITE_MCIND(addr, val)				\
1947c0e09200SDave Airlie do {									\
1948f0738e92SAlex Deucher 	if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||   \
1949f0738e92SAlex Deucher 	    ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740))      \
1950c0e09200SDave Airlie 		RS690_WRITE_MCIND(addr, val);				\
1951c1556f71SAlex Deucher 	else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS600)  \
1952c1556f71SAlex Deucher 		RS600_WRITE_MCIND(addr, val);				\
1953c0e09200SDave Airlie 	else								\
1954c0e09200SDave Airlie 		RS480_WRITE_MCIND(addr, val);				\
1955c0e09200SDave Airlie } while (0)
1956c0e09200SDave Airlie 
1957c0e09200SDave Airlie #define CP_PACKET0( reg, n )						\
1958c0e09200SDave Airlie 	(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
1959c0e09200SDave Airlie #define CP_PACKET0_TABLE( reg, n )					\
1960c0e09200SDave Airlie 	(RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2))
1961c0e09200SDave Airlie #define CP_PACKET1( reg0, reg1 )					\
1962c0e09200SDave Airlie 	(RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2))
1963c0e09200SDave Airlie #define CP_PACKET2()							\
1964c0e09200SDave Airlie 	(RADEON_CP_PACKET2)
1965c0e09200SDave Airlie #define CP_PACKET3( pkt, n )						\
1966c0e09200SDave Airlie 	(RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
1967c0e09200SDave Airlie 
1968c0e09200SDave Airlie /* ================================================================
1969c0e09200SDave Airlie  * Engine control helper macros
1970c0e09200SDave Airlie  */
1971c0e09200SDave Airlie 
1972c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_2D_IDLE() do {				\
1973c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1974c0e09200SDave Airlie 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
1975c0e09200SDave Airlie 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
1976c0e09200SDave Airlie } while (0)
1977c0e09200SDave Airlie 
1978c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_3D_IDLE() do {				\
1979c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1980c0e09200SDave Airlie 	OUT_RING( (RADEON_WAIT_3D_IDLECLEAN |				\
1981c0e09200SDave Airlie 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
1982c0e09200SDave Airlie } while (0)
1983c0e09200SDave Airlie 
1984c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_IDLE() do {					\
1985c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1986c0e09200SDave Airlie 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
1987c0e09200SDave Airlie 		   RADEON_WAIT_3D_IDLECLEAN |				\
1988c0e09200SDave Airlie 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
1989c0e09200SDave Airlie } while (0)
1990c0e09200SDave Airlie 
1991c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do {				\
1992c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1993c0e09200SDave Airlie 	OUT_RING( RADEON_WAIT_CRTC_PFLIP );				\
1994c0e09200SDave Airlie } while (0)
1995c0e09200SDave Airlie 
1996c0e09200SDave Airlie #define RADEON_FLUSH_CACHE() do {					\
1997c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
1998c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0));	\
1999c0e09200SDave Airlie 		OUT_RING(RADEON_RB3D_DC_FLUSH);				\
2000c0e09200SDave Airlie 	} else {                                                        \
2001c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));	\
200254f961a6SJerome Glisse 		OUT_RING(R300_RB3D_DC_FLUSH);				\
2003c0e09200SDave Airlie 	}                                                               \
2004c0e09200SDave Airlie } while (0)
2005c0e09200SDave Airlie 
2006c0e09200SDave Airlie #define RADEON_PURGE_CACHE() do {					\
2007c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
2008c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0));	\
200954f961a6SJerome Glisse 		OUT_RING(RADEON_RB3D_DC_FLUSH | RADEON_RB3D_DC_FREE);	\
2010c0e09200SDave Airlie 	} else {                                                        \
2011c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));	\
201254f961a6SJerome Glisse 		OUT_RING(R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE);	\
2013c0e09200SDave Airlie 	}                                                               \
2014c0e09200SDave Airlie } while (0)
2015c0e09200SDave Airlie 
2016c0e09200SDave Airlie #define RADEON_FLUSH_ZCACHE() do {					\
2017c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
2018c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0));	\
2019c0e09200SDave Airlie 		OUT_RING(RADEON_RB3D_ZC_FLUSH);				\
2020c0e09200SDave Airlie 	} else {                                                        \
2021c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0));	\
2022c0e09200SDave Airlie 		OUT_RING(R300_ZC_FLUSH);				\
2023c0e09200SDave Airlie 	}                                                               \
2024c0e09200SDave Airlie } while (0)
2025c0e09200SDave Airlie 
2026c0e09200SDave Airlie #define RADEON_PURGE_ZCACHE() do {					\
2027c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
2028c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0));	\
202954f961a6SJerome Glisse 		OUT_RING(RADEON_RB3D_ZC_FLUSH | RADEON_RB3D_ZC_FREE);			\
2030c0e09200SDave Airlie 	} else {                                                        \
203154f961a6SJerome Glisse 		OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0));	\
203254f961a6SJerome Glisse 		OUT_RING(R300_ZC_FLUSH | R300_ZC_FREE);				\
2033c0e09200SDave Airlie 	}                                                               \
2034c0e09200SDave Airlie } while (0)
2035c0e09200SDave Airlie 
2036c0e09200SDave Airlie /* ================================================================
2037c0e09200SDave Airlie  * Misc helper macros
2038c0e09200SDave Airlie  */
2039c0e09200SDave Airlie 
2040c0e09200SDave Airlie /* Perfbox functionality only.
2041c0e09200SDave Airlie  */
2042c0e09200SDave Airlie #define RING_SPACE_TEST_WITH_RETURN( dev_priv )				\
2043c0e09200SDave Airlie do {									\
2044c0e09200SDave Airlie 	if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) {		\
2045c0e09200SDave Airlie 		u32 head = GET_RING_HEAD( dev_priv );			\
2046c0e09200SDave Airlie 		if (head == dev_priv->ring.tail)			\
2047c0e09200SDave Airlie 			dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE;	\
2048c0e09200SDave Airlie 	}								\
2049c0e09200SDave Airlie } while (0)
2050c0e09200SDave Airlie 
2051c0e09200SDave Airlie #define VB_AGE_TEST_WITH_RETURN( dev_priv )				\
2052c0e09200SDave Airlie do {								\
20537c1c2871SDave Airlie 	struct drm_radeon_master_private *master_priv = file_priv->master->driver_priv;	\
20547c1c2871SDave Airlie 	drm_radeon_sarea_t *sarea_priv = master_priv->sarea_priv;	\
2055c0e09200SDave Airlie 	if ( sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE ) {		\
2056c05ce083SAlex Deucher 		int __ret;						\
2057c05ce083SAlex Deucher 		if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) \
2058c05ce083SAlex Deucher 			__ret = r600_do_cp_idle(dev_priv);		\
2059c05ce083SAlex Deucher 		else							\
2060c05ce083SAlex Deucher 			__ret = radeon_do_cp_idle(dev_priv);		\
2061c0e09200SDave Airlie 		if ( __ret ) return __ret;				\
2062c0e09200SDave Airlie 		sarea_priv->last_dispatch = 0;				\
2063c0e09200SDave Airlie 		radeon_freelist_reset( dev );				\
2064c0e09200SDave Airlie 	}								\
2065c0e09200SDave Airlie } while (0)
2066c0e09200SDave Airlie 
2067c0e09200SDave Airlie #define RADEON_DISPATCH_AGE( age ) do {					\
2068c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_LAST_DISPATCH_REG, 0 ) );		\
2069c0e09200SDave Airlie 	OUT_RING( age );						\
2070c0e09200SDave Airlie } while (0)
2071c0e09200SDave Airlie 
2072c0e09200SDave Airlie #define RADEON_FRAME_AGE( age ) do {					\
2073c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_LAST_FRAME_REG, 0 ) );		\
2074c0e09200SDave Airlie 	OUT_RING( age );						\
2075c0e09200SDave Airlie } while (0)
2076c0e09200SDave Airlie 
2077c0e09200SDave Airlie #define RADEON_CLEAR_AGE( age ) do {					\
2078c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_LAST_CLEAR_REG, 0 ) );		\
2079c0e09200SDave Airlie 	OUT_RING( age );						\
2080c0e09200SDave Airlie } while (0)
2081c0e09200SDave Airlie 
2082befb73c2SAlex Deucher #define R600_DISPATCH_AGE(age) do {					\
2083befb73c2SAlex Deucher 	OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1));		\
2084befb73c2SAlex Deucher 	OUT_RING((R600_LAST_DISPATCH_REG - R600_SET_CONFIG_REG_OFFSET) >> 2);  \
2085befb73c2SAlex Deucher 	OUT_RING(age);							\
2086befb73c2SAlex Deucher } while (0)
2087befb73c2SAlex Deucher 
2088befb73c2SAlex Deucher #define R600_FRAME_AGE(age) do {					\
2089befb73c2SAlex Deucher 	OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1));		\
2090befb73c2SAlex Deucher 	OUT_RING((R600_LAST_FRAME_REG - R600_SET_CONFIG_REG_OFFSET) >> 2);  \
2091befb73c2SAlex Deucher 	OUT_RING(age);							\
2092befb73c2SAlex Deucher } while (0)
2093befb73c2SAlex Deucher 
2094befb73c2SAlex Deucher #define R600_CLEAR_AGE(age) do {					\
2095befb73c2SAlex Deucher 	OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG, 1));		\
2096befb73c2SAlex Deucher 	OUT_RING((R600_LAST_CLEAR_REG - R600_SET_CONFIG_REG_OFFSET) >> 2);  \
2097befb73c2SAlex Deucher 	OUT_RING(age);							\
2098befb73c2SAlex Deucher } while (0)
2099befb73c2SAlex Deucher 
2100c0e09200SDave Airlie /* ================================================================
2101c0e09200SDave Airlie  * Ring control
2102c0e09200SDave Airlie  */
2103c0e09200SDave Airlie 
2104c0e09200SDave Airlie #define RADEON_VERBOSE	0
2105c0e09200SDave Airlie 
21064247ca94SDave Airlie #define RING_LOCALS	int write, _nr, _align_nr; unsigned int mask; u32 *ring;
2107c0e09200SDave Airlie 
21089863871bSDave Airlie #define RADEON_RING_ALIGN 16
21099863871bSDave Airlie 
2110c0e09200SDave Airlie #define BEGIN_RING( n ) do {						\
2111c0e09200SDave Airlie 	if ( RADEON_VERBOSE ) {						\
2112c0e09200SDave Airlie 		DRM_INFO( "BEGIN_RING( %d )\n", (n));			\
2113c0e09200SDave Airlie 	}								\
21149863871bSDave Airlie 	_align_nr = RADEON_RING_ALIGN - ((dev_priv->ring.tail + n) & (RADEON_RING_ALIGN-1));	\
21159863871bSDave Airlie 	_align_nr += n;							\
21164247ca94SDave Airlie 	if (dev_priv->ring.space <= (_align_nr * sizeof(u32))) {	\
2117c0e09200SDave Airlie                 COMMIT_RING();						\
21184247ca94SDave Airlie 		radeon_wait_ring( dev_priv, _align_nr * sizeof(u32));	\
2119c0e09200SDave Airlie 	}								\
2120c0e09200SDave Airlie 	_nr = n; dev_priv->ring.space -= (n) * sizeof(u32);		\
2121c0e09200SDave Airlie 	ring = dev_priv->ring.start;					\
2122c0e09200SDave Airlie 	write = dev_priv->ring.tail;					\
2123c0e09200SDave Airlie 	mask = dev_priv->ring.tail_mask;				\
2124c0e09200SDave Airlie } while (0)
2125c0e09200SDave Airlie 
2126c0e09200SDave Airlie #define ADVANCE_RING() do {						\
2127c0e09200SDave Airlie 	if ( RADEON_VERBOSE ) {						\
2128c0e09200SDave Airlie 		DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n",	\
2129c0e09200SDave Airlie 			  write, dev_priv->ring.tail );			\
2130c0e09200SDave Airlie 	}								\
2131c0e09200SDave Airlie 	if (((dev_priv->ring.tail + _nr) & mask) != write) {		\
2132c0e09200SDave Airlie 		DRM_ERROR(						\
2133c0e09200SDave Airlie 			"ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n",	\
2134c0e09200SDave Airlie 			((dev_priv->ring.tail + _nr) & mask),		\
2135c0e09200SDave Airlie 			write, __LINE__);				\
2136c0e09200SDave Airlie 	} else								\
2137c0e09200SDave Airlie 		dev_priv->ring.tail = write;				\
2138c0e09200SDave Airlie } while (0)
2139c0e09200SDave Airlie 
21404247ca94SDave Airlie extern void radeon_commit_ring(drm_radeon_private_t *dev_priv);
21414247ca94SDave Airlie 
2142c0e09200SDave Airlie #define COMMIT_RING() do {						\
21434247ca94SDave Airlie 		radeon_commit_ring(dev_priv);				\
2144c0e09200SDave Airlie 	} while(0)
2145c0e09200SDave Airlie 
2146c0e09200SDave Airlie #define OUT_RING( x ) do {						\
2147c0e09200SDave Airlie 	if ( RADEON_VERBOSE ) {						\
2148c0e09200SDave Airlie 		DRM_INFO( "   OUT_RING( 0x%08x ) at 0x%x\n",		\
2149c0e09200SDave Airlie 			   (unsigned int)(x), write );			\
2150c0e09200SDave Airlie 	}								\
2151c0e09200SDave Airlie 	ring[write++] = (x);						\
2152c0e09200SDave Airlie 	write &= mask;							\
2153c0e09200SDave Airlie } while (0)
2154c0e09200SDave Airlie 
2155c0e09200SDave Airlie #define OUT_RING_REG( reg, val ) do {					\
2156c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( reg, 0 ) );				\
2157c0e09200SDave Airlie 	OUT_RING( val );						\
2158c0e09200SDave Airlie } while (0)
2159c0e09200SDave Airlie 
2160c0e09200SDave Airlie #define OUT_RING_TABLE( tab, sz ) do {					\
2161c0e09200SDave Airlie 	int _size = (sz);					\
2162c0e09200SDave Airlie 	int *_tab = (int *)(tab);				\
2163c0e09200SDave Airlie 								\
2164c0e09200SDave Airlie 	if (write + _size > mask) {				\
2165c0e09200SDave Airlie 		int _i = (mask+1) - write;			\
2166c0e09200SDave Airlie 		_size -= _i;					\
2167c0e09200SDave Airlie 		while (_i > 0 ) {				\
2168c0e09200SDave Airlie 			*(int *)(ring + write) = *_tab++;	\
2169c0e09200SDave Airlie 			write++;				\
2170c0e09200SDave Airlie 			_i--;					\
2171c0e09200SDave Airlie 		}						\
2172c0e09200SDave Airlie 		write = 0;					\
2173c0e09200SDave Airlie 		_tab += _i;					\
2174c0e09200SDave Airlie 	}							\
2175c0e09200SDave Airlie 	while (_size > 0) {					\
2176c0e09200SDave Airlie 		*(ring + write) = *_tab++;			\
2177c0e09200SDave Airlie 		write++;					\
2178c0e09200SDave Airlie 		_size--;					\
2179c0e09200SDave Airlie 	}							\
2180c0e09200SDave Airlie 	write &= mask;						\
2181c0e09200SDave Airlie } while (0)
2182c0e09200SDave Airlie 
2183c0e09200SDave Airlie #endif				/* __RADEON_DRV_H__ */
2184