2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
24 * Authors: Dave Airlie
28 #include <linux/seq_file.h>
30 #include "radeon_reg.h"
33 /* r420,r423,rv410 depends on : */
34 void r100_pci_gart_disable(struct radeon_device
*rdev
);
35 void r100_hdp_reset(struct radeon_device
*rdev
);
36 void r100_mc_setup(struct radeon_device
*rdev
);
37 int r100_gui_wait_for_idle(struct radeon_device
*rdev
);
38 void r100_mc_disable_clients(struct radeon_device
*rdev
);
39 void r300_vram_info(struct radeon_device
*rdev
);
40 int r300_mc_wait_for_idle(struct radeon_device
*rdev
);
41 int rv370_pcie_gart_enable(struct radeon_device
*rdev
);
42 void rv370_pcie_gart_disable(struct radeon_device
*rdev
);
44 /* This files gather functions specifics to :
47 * Some of these functions might be used by newer ASICs.
49 void r420_gpu_init(struct radeon_device
*rdev
);
50 int r420_debugfs_pipes_info_init(struct radeon_device
*rdev
);
56 int r420_mc_init(struct radeon_device
*rdev
)
60 if (r100_debugfs_rbbm_init(rdev
)) {
61 DRM_ERROR("Failed to register debugfs file for RBBM !\n");
63 if (r420_debugfs_pipes_info_init(rdev
)) {
64 DRM_ERROR("Failed to register debugfs file for pipes !\n");
68 r100_pci_gart_disable(rdev
);
69 if (rdev
->flags
& RADEON_IS_PCIE
) {
70 rv370_pcie_gart_disable(rdev
);
73 /* Setup GPU memory space */
74 rdev
->mc
.vram_location
= 0xFFFFFFFFUL
;
75 rdev
->mc
.gtt_location
= 0xFFFFFFFFUL
;
76 if (rdev
->flags
& RADEON_IS_AGP
) {
77 r
= radeon_agp_init(rdev
);
79 printk(KERN_WARNING
"[drm] Disabling AGP\n");
80 rdev
->flags
&= ~RADEON_IS_AGP
;
81 rdev
->mc
.gtt_size
= radeon_gart_size
* 1024 * 1024;
83 rdev
->mc
.gtt_location
= rdev
->mc
.agp_base
;
86 r
= radeon_mc_setup(rdev
);
91 /* Program GPU memory space */
92 r100_mc_disable_clients(rdev
);
93 if (r300_mc_wait_for_idle(rdev
)) {
94 printk(KERN_WARNING
"Failed to wait MC idle while "
95 "programming pipes. Bad things might happen.\n");
101 void r420_mc_fini(struct radeon_device
*rdev
)
103 rv370_pcie_gart_disable(rdev
);
104 radeon_gart_table_vram_free(rdev
);
105 radeon_gart_fini(rdev
);
110 * Global GPU functions
112 void r420_errata(struct radeon_device
*rdev
)
114 rdev
->pll_errata
= 0;
117 void r420_pipes_init(struct radeon_device
*rdev
)
120 unsigned gb_pipe_select
;
123 /* GA_ENHANCE workaround TCL deadlock issue */
124 WREG32(0x4274, (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
125 /* get max number of pipes */
126 gb_pipe_select
= RREG32(0x402C);
127 num_pipes
= ((gb_pipe_select
>> 12) & 3) + 1;
128 rdev
->num_gb_pipes
= num_pipes
;
132 /* force to 1 pipe */
147 WREG32(0x42C8, (1 << num_pipes
) - 1);
148 /* Sub pixel 1/12 so we can have 4K rendering according to doc */
149 tmp
|= (1 << 4) | (1 << 0);
151 if (r100_gui_wait_for_idle(rdev
)) {
152 printk(KERN_WARNING
"Failed to wait GUI idle while "
153 "programming pipes. Bad things might happen.\n");
156 tmp
= RREG32(0x170C);
157 WREG32(0x170C, tmp
| (1 << 31));
159 WREG32(R300_RB2D_DSTCACHE_MODE
,
160 RREG32(R300_RB2D_DSTCACHE_MODE
) |
161 R300_DC_AUTOFLUSH_ENABLE
|
162 R300_DC_DC_DISABLE_IGNORE_PE
);
164 if (r100_gui_wait_for_idle(rdev
)) {
165 printk(KERN_WARNING
"Failed to wait GUI idle while "
166 "programming pipes. Bad things might happen.\n");
169 if (rdev
->family
== CHIP_RV530
) {
170 tmp
= RREG32(RV530_GB_PIPE_SELECT2
);
172 rdev
->num_z_pipes
= 2;
174 rdev
->num_z_pipes
= 1;
176 rdev
->num_z_pipes
= 1;
178 DRM_INFO("radeon: %d quad pipes, %d z pipes initialized.\n",
179 rdev
->num_gb_pipes
, rdev
->num_z_pipes
);
182 void r420_gpu_init(struct radeon_device
*rdev
)
184 r100_hdp_reset(rdev
);
185 r420_pipes_init(rdev
);
186 if (r300_mc_wait_for_idle(rdev
)) {
187 printk(KERN_WARNING
"Failed to wait MC idle while "
188 "programming pipes. Bad things might happen.\n");
194 * r420,r423,rv410 VRAM info
196 void r420_vram_info(struct radeon_device
*rdev
)
198 r300_vram_info(rdev
);
205 #if defined(CONFIG_DEBUG_FS)
206 static int r420_debugfs_pipes_info(struct seq_file
*m
, void *data
)
208 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
209 struct drm_device
*dev
= node
->minor
->dev
;
210 struct radeon_device
*rdev
= dev
->dev_private
;
213 tmp
= RREG32(R400_GB_PIPE_SELECT
);
214 seq_printf(m
, "GB_PIPE_SELECT 0x%08x\n", tmp
);
215 tmp
= RREG32(R300_GB_TILE_CONFIG
);
216 seq_printf(m
, "GB_TILE_CONFIG 0x%08x\n", tmp
);
217 tmp
= RREG32(R300_DST_PIPE_CONFIG
);
218 seq_printf(m
, "DST_PIPE_CONFIG 0x%08x\n", tmp
);
222 static struct drm_info_list r420_pipes_info_list
[] = {
223 {"r420_pipes_info", r420_debugfs_pipes_info
, 0, NULL
},
227 int r420_debugfs_pipes_info_init(struct radeon_device
*rdev
)
229 #if defined(CONFIG_DEBUG_FS)
230 return radeon_debugfs_add_files(rdev
, r420_pipes_info_list
, 1);