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>
31 #include "radeon_reg.h"
33 #include "radeon_drm.h"
34 #include "r100_track.h"
37 #include "r300_reg_safe.h"
39 /* This files gather functions specifics to: r300,r350,rv350,rv370,rv380
42 * - HOST_PATH_CNTL: r300 family seems to dislike write to HOST_PATH_CNTL
43 * using MMIO to flush host path read cache, this lead to HARDLOCKUP.
44 * However, scheduling such write to the ring seems harmless, i suspect
45 * the CP read collide with the flush somehow, or maybe the MC, hard to
46 * tell. (Jerome Glisse)
50 * rv370,rv380 PCIE GART
52 static int rv370_debugfs_pcie_gart_info_init(struct radeon_device
*rdev
);
54 void rv370_pcie_gart_tlb_flush(struct radeon_device
*rdev
)
59 /* Workaround HW bug do flush 2 times */
60 for (i
= 0; i
< 2; i
++) {
61 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
);
62 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
, tmp
| RADEON_PCIE_TX_GART_INVALIDATE_TLB
);
63 (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
);
64 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
, tmp
);
69 int rv370_pcie_gart_set_page(struct radeon_device
*rdev
, int i
, uint64_t addr
)
71 void __iomem
*ptr
= (void *)rdev
->gart
.table
.vram
.ptr
;
73 if (i
< 0 || i
> rdev
->gart
.num_gpu_pages
) {
76 addr
= (lower_32_bits(addr
) >> 8) |
77 ((upper_32_bits(addr
) & 0xff) << 24) |
79 /* on x86 we want this to be CPU endian, on powerpc
80 * on powerpc without HW swappers, it'll get swapped on way
81 * into VRAM - so no need for cpu_to_le32 on VRAM tables */
82 writel(addr
, ((void __iomem
*)ptr
) + (i
* 4));
86 int rv370_pcie_gart_init(struct radeon_device
*rdev
)
90 if (rdev
->gart
.table
.vram
.robj
) {
91 WARN(1, "RV370 PCIE GART already initialized.\n");
94 /* Initialize common gart structure */
95 r
= radeon_gart_init(rdev
);
98 r
= rv370_debugfs_pcie_gart_info_init(rdev
);
100 DRM_ERROR("Failed to register debugfs file for PCIE gart !\n");
101 rdev
->gart
.table_size
= rdev
->gart
.num_gpu_pages
* 4;
102 rdev
->asic
->gart_tlb_flush
= &rv370_pcie_gart_tlb_flush
;
103 rdev
->asic
->gart_set_page
= &rv370_pcie_gart_set_page
;
104 return radeon_gart_table_vram_alloc(rdev
);
107 int rv370_pcie_gart_enable(struct radeon_device
*rdev
)
113 if (rdev
->gart
.table
.vram
.robj
== NULL
) {
114 dev_err(rdev
->dev
, "No VRAM object for PCIE GART.\n");
117 r
= radeon_gart_table_vram_pin(rdev
);
120 /* discard memory request outside of configured range */
121 tmp
= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD
;
122 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
, tmp
);
123 WREG32_PCIE(RADEON_PCIE_TX_GART_START_LO
, rdev
->mc
.gtt_location
);
124 tmp
= rdev
->mc
.gtt_location
+ rdev
->mc
.gtt_size
- RADEON_GPU_PAGE_SIZE
;
125 WREG32_PCIE(RADEON_PCIE_TX_GART_END_LO
, tmp
);
126 WREG32_PCIE(RADEON_PCIE_TX_GART_START_HI
, 0);
127 WREG32_PCIE(RADEON_PCIE_TX_GART_END_HI
, 0);
128 table_addr
= rdev
->gart
.table_addr
;
129 WREG32_PCIE(RADEON_PCIE_TX_GART_BASE
, table_addr
);
130 /* FIXME: setup default page */
131 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO
, rdev
->mc
.vram_location
);
132 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_HI
, 0);
134 WREG32_PCIE(0x18, 0);
135 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
);
136 tmp
|= RADEON_PCIE_TX_GART_EN
;
137 tmp
|= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD
;
138 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
, tmp
);
139 rv370_pcie_gart_tlb_flush(rdev
);
140 DRM_INFO("PCIE GART of %uM enabled (table at 0x%08X).\n",
141 (unsigned)(rdev
->mc
.gtt_size
>> 20), table_addr
);
142 rdev
->gart
.ready
= true;
146 void rv370_pcie_gart_disable(struct radeon_device
*rdev
)
151 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
);
152 tmp
|= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD
;
153 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
, tmp
& ~RADEON_PCIE_TX_GART_EN
);
154 if (rdev
->gart
.table
.vram
.robj
) {
155 r
= radeon_bo_reserve(rdev
->gart
.table
.vram
.robj
, false);
156 if (likely(r
== 0)) {
157 radeon_bo_kunmap(rdev
->gart
.table
.vram
.robj
);
158 radeon_bo_unpin(rdev
->gart
.table
.vram
.robj
);
159 radeon_bo_unreserve(rdev
->gart
.table
.vram
.robj
);
164 void rv370_pcie_gart_fini(struct radeon_device
*rdev
)
166 rv370_pcie_gart_disable(rdev
);
167 radeon_gart_table_vram_free(rdev
);
168 radeon_gart_fini(rdev
);
171 void r300_fence_ring_emit(struct radeon_device
*rdev
,
172 struct radeon_fence
*fence
)
174 /* Who ever call radeon_fence_emit should call ring_lock and ask
175 * for enough space (today caller are ib schedule and buffer move) */
176 /* Write SC register so SC & US assert idle */
177 radeon_ring_write(rdev
, PACKET0(0x43E0, 0));
178 radeon_ring_write(rdev
, 0);
179 radeon_ring_write(rdev
, PACKET0(0x43E4, 0));
180 radeon_ring_write(rdev
, 0);
182 radeon_ring_write(rdev
, PACKET0(0x4E4C, 0));
183 radeon_ring_write(rdev
, (2 << 0));
184 radeon_ring_write(rdev
, PACKET0(0x4F18, 0));
185 radeon_ring_write(rdev
, (1 << 0));
186 /* Wait until IDLE & CLEAN */
187 radeon_ring_write(rdev
, PACKET0(0x1720, 0));
188 radeon_ring_write(rdev
, (1 << 17) | (1 << 16) | (1 << 9));
189 radeon_ring_write(rdev
, PACKET0(RADEON_HOST_PATH_CNTL
, 0));
190 radeon_ring_write(rdev
, rdev
->config
.r300
.hdp_cntl
|
191 RADEON_HDP_READ_BUFFER_INVALIDATE
);
192 radeon_ring_write(rdev
, PACKET0(RADEON_HOST_PATH_CNTL
, 0));
193 radeon_ring_write(rdev
, rdev
->config
.r300
.hdp_cntl
);
194 /* Emit fence sequence & fire IRQ */
195 radeon_ring_write(rdev
, PACKET0(rdev
->fence_drv
.scratch_reg
, 0));
196 radeon_ring_write(rdev
, fence
->seq
);
197 radeon_ring_write(rdev
, PACKET0(RADEON_GEN_INT_STATUS
, 0));
198 radeon_ring_write(rdev
, RADEON_SW_INT_FIRE
);
201 int r300_copy_dma(struct radeon_device
*rdev
,
205 struct radeon_fence
*fence
)
212 /* radeon pitch is /64 */
213 size
= num_pages
<< PAGE_SHIFT
;
214 num_loops
= DIV_ROUND_UP(size
, 0x1FFFFF);
215 r
= radeon_ring_lock(rdev
, num_loops
* 4 + 64);
217 DRM_ERROR("radeon: moving bo (%d).\n", r
);
220 /* Must wait for 2D idle & clean before DMA or hangs might happen */
221 radeon_ring_write(rdev
, PACKET0(RADEON_WAIT_UNTIL
, 0 ));
222 radeon_ring_write(rdev
, (1 << 16));
223 for (i
= 0; i
< num_loops
; i
++) {
225 if (cur_size
> 0x1FFFFF) {
229 radeon_ring_write(rdev
, PACKET0(0x720, 2));
230 radeon_ring_write(rdev
, src_offset
);
231 radeon_ring_write(rdev
, dst_offset
);
232 radeon_ring_write(rdev
, cur_size
| (1 << 31) | (1 << 30));
233 src_offset
+= cur_size
;
234 dst_offset
+= cur_size
;
236 radeon_ring_write(rdev
, PACKET0(RADEON_WAIT_UNTIL
, 0));
237 radeon_ring_write(rdev
, RADEON_WAIT_DMA_GUI_IDLE
);
239 r
= radeon_fence_emit(rdev
, fence
);
241 radeon_ring_unlock_commit(rdev
);
245 void r300_ring_start(struct radeon_device
*rdev
)
247 unsigned gb_tile_config
;
250 /* Sub pixel 1/12 so we can have 4K rendering according to doc */
251 gb_tile_config
= (R300_ENABLE_TILING
| R300_TILE_SIZE_16
);
252 switch(rdev
->num_gb_pipes
) {
254 gb_tile_config
|= R300_PIPE_COUNT_R300
;
257 gb_tile_config
|= R300_PIPE_COUNT_R420_3P
;
260 gb_tile_config
|= R300_PIPE_COUNT_R420
;
264 gb_tile_config
|= R300_PIPE_COUNT_RV350
;
268 r
= radeon_ring_lock(rdev
, 64);
272 radeon_ring_write(rdev
, PACKET0(RADEON_ISYNC_CNTL
, 0));
273 radeon_ring_write(rdev
,
274 RADEON_ISYNC_ANY2D_IDLE3D
|
275 RADEON_ISYNC_ANY3D_IDLE2D
|
276 RADEON_ISYNC_WAIT_IDLEGUI
|
277 RADEON_ISYNC_CPSCRATCH_IDLEGUI
);
278 radeon_ring_write(rdev
, PACKET0(R300_GB_TILE_CONFIG
, 0));
279 radeon_ring_write(rdev
, gb_tile_config
);
280 radeon_ring_write(rdev
, PACKET0(RADEON_WAIT_UNTIL
, 0));
281 radeon_ring_write(rdev
,
282 RADEON_WAIT_2D_IDLECLEAN
|
283 RADEON_WAIT_3D_IDLECLEAN
);
284 radeon_ring_write(rdev
, PACKET0(0x170C, 0));
285 radeon_ring_write(rdev
, 1 << 31);
286 radeon_ring_write(rdev
, PACKET0(R300_GB_SELECT
, 0));
287 radeon_ring_write(rdev
, 0);
288 radeon_ring_write(rdev
, PACKET0(R300_GB_ENABLE
, 0));
289 radeon_ring_write(rdev
, 0);
290 radeon_ring_write(rdev
, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT
, 0));
291 radeon_ring_write(rdev
, R300_RB3D_DC_FLUSH
| R300_RB3D_DC_FREE
);
292 radeon_ring_write(rdev
, PACKET0(R300_RB3D_ZCACHE_CTLSTAT
, 0));
293 radeon_ring_write(rdev
, R300_ZC_FLUSH
| R300_ZC_FREE
);
294 radeon_ring_write(rdev
, PACKET0(RADEON_WAIT_UNTIL
, 0));
295 radeon_ring_write(rdev
,
296 RADEON_WAIT_2D_IDLECLEAN
|
297 RADEON_WAIT_3D_IDLECLEAN
);
298 radeon_ring_write(rdev
, PACKET0(R300_GB_AA_CONFIG
, 0));
299 radeon_ring_write(rdev
, 0);
300 radeon_ring_write(rdev
, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT
, 0));
301 radeon_ring_write(rdev
, R300_RB3D_DC_FLUSH
| R300_RB3D_DC_FREE
);
302 radeon_ring_write(rdev
, PACKET0(R300_RB3D_ZCACHE_CTLSTAT
, 0));
303 radeon_ring_write(rdev
, R300_ZC_FLUSH
| R300_ZC_FREE
);
304 radeon_ring_write(rdev
, PACKET0(R300_GB_MSPOS0
, 0));
305 radeon_ring_write(rdev
,
306 ((6 << R300_MS_X0_SHIFT
) |
307 (6 << R300_MS_Y0_SHIFT
) |
308 (6 << R300_MS_X1_SHIFT
) |
309 (6 << R300_MS_Y1_SHIFT
) |
310 (6 << R300_MS_X2_SHIFT
) |
311 (6 << R300_MS_Y2_SHIFT
) |
312 (6 << R300_MSBD0_Y_SHIFT
) |
313 (6 << R300_MSBD0_X_SHIFT
)));
314 radeon_ring_write(rdev
, PACKET0(R300_GB_MSPOS1
, 0));
315 radeon_ring_write(rdev
,
316 ((6 << R300_MS_X3_SHIFT
) |
317 (6 << R300_MS_Y3_SHIFT
) |
318 (6 << R300_MS_X4_SHIFT
) |
319 (6 << R300_MS_Y4_SHIFT
) |
320 (6 << R300_MS_X5_SHIFT
) |
321 (6 << R300_MS_Y5_SHIFT
) |
322 (6 << R300_MSBD1_SHIFT
)));
323 radeon_ring_write(rdev
, PACKET0(R300_GA_ENHANCE
, 0));
324 radeon_ring_write(rdev
, R300_GA_DEADLOCK_CNTL
| R300_GA_FASTSYNC_CNTL
);
325 radeon_ring_write(rdev
, PACKET0(R300_GA_POLY_MODE
, 0));
326 radeon_ring_write(rdev
,
327 R300_FRONT_PTYPE_TRIANGE
| R300_BACK_PTYPE_TRIANGE
);
328 radeon_ring_write(rdev
, PACKET0(R300_GA_ROUND_MODE
, 0));
329 radeon_ring_write(rdev
,
330 R300_GEOMETRY_ROUND_NEAREST
|
331 R300_COLOR_ROUND_NEAREST
);
332 radeon_ring_unlock_commit(rdev
);
335 void r300_errata(struct radeon_device
*rdev
)
337 rdev
->pll_errata
= 0;
339 if (rdev
->family
== CHIP_R300
&&
340 (RREG32(RADEON_CONFIG_CNTL
) & RADEON_CFG_ATI_REV_ID_MASK
) == RADEON_CFG_ATI_REV_A11
) {
341 rdev
->pll_errata
|= CHIP_ERRATA_R300_CG
;
345 int r300_mc_wait_for_idle(struct radeon_device
*rdev
)
350 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
352 tmp
= RREG32(0x0150);
353 if (tmp
& (1 << 4)) {
361 void r300_gpu_init(struct radeon_device
*rdev
)
363 uint32_t gb_tile_config
, tmp
;
365 r100_hdp_reset(rdev
);
366 /* FIXME: rv380 one pipes ? */
367 if ((rdev
->family
== CHIP_R300
) || (rdev
->family
== CHIP_R350
)) {
369 rdev
->num_gb_pipes
= 2;
371 /* rv350,rv370,rv380 */
372 rdev
->num_gb_pipes
= 1;
374 rdev
->num_z_pipes
= 1;
375 gb_tile_config
= (R300_ENABLE_TILING
| R300_TILE_SIZE_16
);
376 switch (rdev
->num_gb_pipes
) {
378 gb_tile_config
|= R300_PIPE_COUNT_R300
;
381 gb_tile_config
|= R300_PIPE_COUNT_R420_3P
;
384 gb_tile_config
|= R300_PIPE_COUNT_R420
;
388 gb_tile_config
|= R300_PIPE_COUNT_RV350
;
391 WREG32(R300_GB_TILE_CONFIG
, gb_tile_config
);
393 if (r100_gui_wait_for_idle(rdev
)) {
394 printk(KERN_WARNING
"Failed to wait GUI idle while "
395 "programming pipes. Bad things might happen.\n");
398 tmp
= RREG32(0x170C);
399 WREG32(0x170C, tmp
| (1 << 31));
401 WREG32(R300_RB2D_DSTCACHE_MODE
,
402 R300_DC_AUTOFLUSH_ENABLE
|
403 R300_DC_DC_DISABLE_IGNORE_PE
);
405 if (r100_gui_wait_for_idle(rdev
)) {
406 printk(KERN_WARNING
"Failed to wait GUI idle while "
407 "programming pipes. Bad things might happen.\n");
409 if (r300_mc_wait_for_idle(rdev
)) {
410 printk(KERN_WARNING
"Failed to wait MC idle while "
411 "programming pipes. Bad things might happen.\n");
413 DRM_INFO("radeon: %d quad pipes, %d Z pipes initialized.\n",
414 rdev
->num_gb_pipes
, rdev
->num_z_pipes
);
417 int r300_ga_reset(struct radeon_device
*rdev
)
423 reinit_cp
= rdev
->cp
.ready
;
424 rdev
->cp
.ready
= false;
425 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
426 WREG32(RADEON_CP_CSQ_MODE
, 0);
427 WREG32(RADEON_CP_CSQ_CNTL
, 0);
428 WREG32(RADEON_RBBM_SOFT_RESET
, 0x32005);
429 (void)RREG32(RADEON_RBBM_SOFT_RESET
);
431 WREG32(RADEON_RBBM_SOFT_RESET
, 0);
432 /* Wait to prevent race in RBBM_STATUS */
434 tmp
= RREG32(RADEON_RBBM_STATUS
);
435 if (tmp
& ((1 << 20) | (1 << 26))) {
436 DRM_ERROR("VAP & CP still busy (RBBM_STATUS=0x%08X)", tmp
);
437 /* GA still busy soft reset it */
438 WREG32(0x429C, 0x200);
439 WREG32(R300_VAP_PVS_STATE_FLUSH_REG
, 0);
444 /* Wait to prevent race in RBBM_STATUS */
446 tmp
= RREG32(RADEON_RBBM_STATUS
);
447 if (!(tmp
& ((1 << 20) | (1 << 26)))) {
451 for (i
= 0; i
< rdev
->usec_timeout
; i
++) {
452 tmp
= RREG32(RADEON_RBBM_STATUS
);
453 if (!(tmp
& ((1 << 20) | (1 << 26)))) {
454 DRM_INFO("GA reset succeed (RBBM_STATUS=0x%08X)\n",
457 return r100_cp_init(rdev
, rdev
->cp
.ring_size
);
463 tmp
= RREG32(RADEON_RBBM_STATUS
);
464 DRM_ERROR("Failed to reset GA ! (RBBM_STATUS=0x%08X)\n", tmp
);
468 int r300_gpu_reset(struct radeon_device
*rdev
)
472 /* reset order likely matter */
473 status
= RREG32(RADEON_RBBM_STATUS
);
475 r100_hdp_reset(rdev
);
477 if (status
& ((1 << 17) | (1 << 18) | (1 << 27))) {
478 r100_rb2d_reset(rdev
);
481 if (status
& ((1 << 20) | (1 << 26))) {
485 status
= RREG32(RADEON_RBBM_STATUS
);
486 if (status
& (1 << 16)) {
489 /* Check if GPU is idle */
490 status
= RREG32(RADEON_RBBM_STATUS
);
491 if (status
& (1 << 31)) {
492 DRM_ERROR("Failed to reset GPU (RBBM_STATUS=0x%08X)\n", status
);
495 DRM_INFO("GPU reset succeed (RBBM_STATUS=0x%08X)\n", status
);
501 * r300,r350,rv350,rv380 VRAM info
503 void r300_vram_info(struct radeon_device
*rdev
)
507 /* DDR for all card after R300 & IGP */
508 rdev
->mc
.vram_is_ddr
= true;
509 tmp
= RREG32(RADEON_MEM_CNTL
);
510 if (tmp
& R300_MEM_NUM_CHANNELS_MASK
) {
511 rdev
->mc
.vram_width
= 128;
513 rdev
->mc
.vram_width
= 64;
516 r100_vram_init_sizes(rdev
);
519 void rv370_set_pcie_lanes(struct radeon_device
*rdev
, int lanes
)
521 uint32_t link_width_cntl
, mask
;
523 if (rdev
->flags
& RADEON_IS_IGP
)
526 if (!(rdev
->flags
& RADEON_IS_PCIE
))
529 /* FIXME wait for idle */
533 mask
= RADEON_PCIE_LC_LINK_WIDTH_X0
;
536 mask
= RADEON_PCIE_LC_LINK_WIDTH_X1
;
539 mask
= RADEON_PCIE_LC_LINK_WIDTH_X2
;
542 mask
= RADEON_PCIE_LC_LINK_WIDTH_X4
;
545 mask
= RADEON_PCIE_LC_LINK_WIDTH_X8
;
548 mask
= RADEON_PCIE_LC_LINK_WIDTH_X12
;
552 mask
= RADEON_PCIE_LC_LINK_WIDTH_X16
;
556 link_width_cntl
= RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL
);
558 if ((link_width_cntl
& RADEON_PCIE_LC_LINK_WIDTH_RD_MASK
) ==
559 (mask
<< RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT
))
562 link_width_cntl
&= ~(RADEON_PCIE_LC_LINK_WIDTH_MASK
|
563 RADEON_PCIE_LC_RECONFIG_NOW
|
564 RADEON_PCIE_LC_RECONFIG_LATER
|
565 RADEON_PCIE_LC_SHORT_RECONFIG_EN
);
566 link_width_cntl
|= mask
;
567 WREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL
, link_width_cntl
);
568 WREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL
, (link_width_cntl
|
569 RADEON_PCIE_LC_RECONFIG_NOW
));
571 /* wait for lane set to complete */
572 link_width_cntl
= RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL
);
573 while (link_width_cntl
== 0xffffffff)
574 link_width_cntl
= RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL
);
578 #if defined(CONFIG_DEBUG_FS)
579 static int rv370_debugfs_pcie_gart_info(struct seq_file
*m
, void *data
)
581 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
582 struct drm_device
*dev
= node
->minor
->dev
;
583 struct radeon_device
*rdev
= dev
->dev_private
;
586 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL
);
587 seq_printf(m
, "PCIE_TX_GART_CNTL 0x%08x\n", tmp
);
588 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_BASE
);
589 seq_printf(m
, "PCIE_TX_GART_BASE 0x%08x\n", tmp
);
590 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_START_LO
);
591 seq_printf(m
, "PCIE_TX_GART_START_LO 0x%08x\n", tmp
);
592 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_START_HI
);
593 seq_printf(m
, "PCIE_TX_GART_START_HI 0x%08x\n", tmp
);
594 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_END_LO
);
595 seq_printf(m
, "PCIE_TX_GART_END_LO 0x%08x\n", tmp
);
596 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_END_HI
);
597 seq_printf(m
, "PCIE_TX_GART_END_HI 0x%08x\n", tmp
);
598 tmp
= RREG32_PCIE(RADEON_PCIE_TX_GART_ERROR
);
599 seq_printf(m
, "PCIE_TX_GART_ERROR 0x%08x\n", tmp
);
603 static struct drm_info_list rv370_pcie_gart_info_list
[] = {
604 {"rv370_pcie_gart_info", rv370_debugfs_pcie_gart_info
, 0, NULL
},
608 static int rv370_debugfs_pcie_gart_info_init(struct radeon_device
*rdev
)
610 #if defined(CONFIG_DEBUG_FS)
611 return radeon_debugfs_add_files(rdev
, rv370_pcie_gart_info_list
, 1);
617 static int r300_packet0_check(struct radeon_cs_parser
*p
,
618 struct radeon_cs_packet
*pkt
,
619 unsigned idx
, unsigned reg
)
621 struct radeon_cs_reloc
*reloc
;
622 struct r100_cs_track
*track
;
623 volatile uint32_t *ib
;
624 uint32_t tmp
, tile_flags
= 0;
630 track
= (struct r100_cs_track
*)p
->track
;
631 idx_value
= radeon_get_ib_value(p
, idx
);
634 case AVIVO_D1MODE_VLINE_START_END
:
635 case RADEON_CRTC_GUI_TRIG_VLINE
:
636 r
= r100_cs_packet_parse_vline(p
);
638 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
640 r100_cs_dump_packet(p
, pkt
);
644 case RADEON_DST_PITCH_OFFSET
:
645 case RADEON_SRC_PITCH_OFFSET
:
646 r
= r100_reloc_pitch_offset(p
, pkt
, idx
, reg
);
650 case R300_RB3D_COLOROFFSET0
:
651 case R300_RB3D_COLOROFFSET1
:
652 case R300_RB3D_COLOROFFSET2
:
653 case R300_RB3D_COLOROFFSET3
:
654 i
= (reg
- R300_RB3D_COLOROFFSET0
) >> 2;
655 r
= r100_cs_packet_next_reloc(p
, &reloc
);
657 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
659 r100_cs_dump_packet(p
, pkt
);
662 track
->cb
[i
].robj
= reloc
->robj
;
663 track
->cb
[i
].offset
= idx_value
;
664 ib
[idx
] = idx_value
+ ((u32
)reloc
->lobj
.gpu_offset
);
666 case R300_ZB_DEPTHOFFSET
:
667 r
= r100_cs_packet_next_reloc(p
, &reloc
);
669 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
671 r100_cs_dump_packet(p
, pkt
);
674 track
->zb
.robj
= reloc
->robj
;
675 track
->zb
.offset
= idx_value
;
676 ib
[idx
] = idx_value
+ ((u32
)reloc
->lobj
.gpu_offset
);
678 case R300_TX_OFFSET_0
:
679 case R300_TX_OFFSET_0
+4:
680 case R300_TX_OFFSET_0
+8:
681 case R300_TX_OFFSET_0
+12:
682 case R300_TX_OFFSET_0
+16:
683 case R300_TX_OFFSET_0
+20:
684 case R300_TX_OFFSET_0
+24:
685 case R300_TX_OFFSET_0
+28:
686 case R300_TX_OFFSET_0
+32:
687 case R300_TX_OFFSET_0
+36:
688 case R300_TX_OFFSET_0
+40:
689 case R300_TX_OFFSET_0
+44:
690 case R300_TX_OFFSET_0
+48:
691 case R300_TX_OFFSET_0
+52:
692 case R300_TX_OFFSET_0
+56:
693 case R300_TX_OFFSET_0
+60:
694 i
= (reg
- R300_TX_OFFSET_0
) >> 2;
695 r
= r100_cs_packet_next_reloc(p
, &reloc
);
697 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
699 r100_cs_dump_packet(p
, pkt
);
703 if (reloc
->lobj
.tiling_flags
& RADEON_TILING_MACRO
)
704 tile_flags
|= R300_TXO_MACRO_TILE
;
705 if (reloc
->lobj
.tiling_flags
& RADEON_TILING_MICRO
)
706 tile_flags
|= R300_TXO_MICRO_TILE
;
708 tmp
= idx_value
+ ((u32
)reloc
->lobj
.gpu_offset
);
711 track
->textures
[i
].robj
= reloc
->robj
;
713 /* Tracked registers */
716 track
->vap_vf_cntl
= idx_value
;
720 track
->vtx_size
= idx_value
& 0x7F;
723 /* VAP_VF_MAX_VTX_INDX */
724 track
->max_indx
= idx_value
& 0x00FFFFFFUL
;
728 track
->maxy
= ((idx_value
>> 13) & 0x1FFF) + 1;
729 if (p
->rdev
->family
< CHIP_RV515
) {
735 track
->num_cb
= ((idx_value
>> 5) & 0x3) + 1;
741 /* RB3D_COLORPITCH0 */
742 /* RB3D_COLORPITCH1 */
743 /* RB3D_COLORPITCH2 */
744 /* RB3D_COLORPITCH3 */
745 r
= r100_cs_packet_next_reloc(p
, &reloc
);
747 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
749 r100_cs_dump_packet(p
, pkt
);
753 if (reloc
->lobj
.tiling_flags
& RADEON_TILING_MACRO
)
754 tile_flags
|= R300_COLOR_TILE_ENABLE
;
755 if (reloc
->lobj
.tiling_flags
& RADEON_TILING_MICRO
)
756 tile_flags
|= R300_COLOR_MICROTILE_ENABLE
;
758 tmp
= idx_value
& ~(0x7 << 16);
762 i
= (reg
- 0x4E38) >> 2;
763 track
->cb
[i
].pitch
= idx_value
& 0x3FFE;
764 switch (((idx_value
>> 21) & 0xF)) {
768 track
->cb
[i
].cpp
= 1;
774 track
->cb
[i
].cpp
= 2;
777 track
->cb
[i
].cpp
= 4;
780 track
->cb
[i
].cpp
= 8;
783 track
->cb
[i
].cpp
= 16;
786 DRM_ERROR("Invalid color buffer format (%d) !\n",
787 ((idx_value
>> 21) & 0xF));
794 track
->z_enabled
= true;
796 track
->z_enabled
= false;
801 switch ((idx_value
& 0xF)) {
810 DRM_ERROR("Invalid z buffer format (%d) !\n",
817 r
= r100_cs_packet_next_reloc(p
, &reloc
);
819 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
821 r100_cs_dump_packet(p
, pkt
);
825 if (reloc
->lobj
.tiling_flags
& RADEON_TILING_MACRO
)
826 tile_flags
|= R300_DEPTHMACROTILE_ENABLE
;
827 if (reloc
->lobj
.tiling_flags
& RADEON_TILING_MICRO
)
828 tile_flags
|= R300_DEPTHMICROTILE_TILED
;;
830 tmp
= idx_value
& ~(0x7 << 16);
834 track
->zb
.pitch
= idx_value
& 0x3FFC;
837 for (i
= 0; i
< 16; i
++) {
840 enabled
= !!(idx_value
& (1 << i
));
841 track
->textures
[i
].enabled
= enabled
;
860 /* TX_FORMAT1_[0-15] */
861 i
= (reg
- 0x44C0) >> 2;
862 tmp
= (idx_value
>> 25) & 0x3;
863 track
->textures
[i
].tex_coord_type
= tmp
;
864 switch ((idx_value
& 0x1F)) {
865 case R300_TX_FORMAT_X8
:
866 case R300_TX_FORMAT_Y4X4
:
867 case R300_TX_FORMAT_Z3Y3X2
:
868 track
->textures
[i
].cpp
= 1;
870 case R300_TX_FORMAT_X16
:
871 case R300_TX_FORMAT_Y8X8
:
872 case R300_TX_FORMAT_Z5Y6X5
:
873 case R300_TX_FORMAT_Z6Y5X5
:
874 case R300_TX_FORMAT_W4Z4Y4X4
:
875 case R300_TX_FORMAT_W1Z5Y5X5
:
876 case R300_TX_FORMAT_D3DMFT_CxV8U8
:
877 case R300_TX_FORMAT_B8G8_B8G8
:
878 case R300_TX_FORMAT_G8R8_G8B8
:
879 track
->textures
[i
].cpp
= 2;
881 case R300_TX_FORMAT_Y16X16
:
882 case R300_TX_FORMAT_Z11Y11X10
:
883 case R300_TX_FORMAT_Z10Y11X11
:
884 case R300_TX_FORMAT_W8Z8Y8X8
:
885 case R300_TX_FORMAT_W2Z10Y10X10
:
887 case R300_TX_FORMAT_FL_I32
:
889 track
->textures
[i
].cpp
= 4;
891 case R300_TX_FORMAT_W16Z16Y16X16
:
892 case R300_TX_FORMAT_FL_R16G16B16A16
:
893 case R300_TX_FORMAT_FL_I32A32
:
894 track
->textures
[i
].cpp
= 8;
896 case R300_TX_FORMAT_FL_R32G32B32A32
:
897 track
->textures
[i
].cpp
= 16;
899 case R300_TX_FORMAT_DXT1
:
900 track
->textures
[i
].cpp
= 1;
901 track
->textures
[i
].compress_format
= R100_TRACK_COMP_DXT1
;
903 case R300_TX_FORMAT_ATI2N
:
904 if (p
->rdev
->family
< CHIP_R420
) {
905 DRM_ERROR("Invalid texture format %u\n",
909 /* The same rules apply as for DXT3/5. */
911 case R300_TX_FORMAT_DXT3
:
912 case R300_TX_FORMAT_DXT5
:
913 track
->textures
[i
].cpp
= 1;
914 track
->textures
[i
].compress_format
= R100_TRACK_COMP_DXT35
;
917 DRM_ERROR("Invalid texture format %u\n",
939 /* TX_FILTER0_[0-15] */
940 i
= (reg
- 0x4400) >> 2;
941 tmp
= idx_value
& 0x7;
942 if (tmp
== 2 || tmp
== 4 || tmp
== 6) {
943 track
->textures
[i
].roundup_w
= false;
945 tmp
= (idx_value
>> 3) & 0x7;
946 if (tmp
== 2 || tmp
== 4 || tmp
== 6) {
947 track
->textures
[i
].roundup_h
= false;
966 /* TX_FORMAT2_[0-15] */
967 i
= (reg
- 0x4500) >> 2;
968 tmp
= idx_value
& 0x3FFF;
969 track
->textures
[i
].pitch
= tmp
+ 1;
970 if (p
->rdev
->family
>= CHIP_RV515
) {
971 tmp
= ((idx_value
>> 15) & 1) << 11;
972 track
->textures
[i
].width_11
= tmp
;
973 tmp
= ((idx_value
>> 16) & 1) << 11;
974 track
->textures
[i
].height_11
= tmp
;
977 if (idx_value
& (1 << 14)) {
978 /* The same rules apply as for DXT1. */
979 track
->textures
[i
].compress_format
=
980 R100_TRACK_COMP_DXT1
;
982 } else if (idx_value
& (1 << 14)) {
983 DRM_ERROR("Forbidden bit TXFORMAT_MSB\n");
1003 /* TX_FORMAT0_[0-15] */
1004 i
= (reg
- 0x4480) >> 2;
1005 tmp
= idx_value
& 0x7FF;
1006 track
->textures
[i
].width
= tmp
+ 1;
1007 tmp
= (idx_value
>> 11) & 0x7FF;
1008 track
->textures
[i
].height
= tmp
+ 1;
1009 tmp
= (idx_value
>> 26) & 0xF;
1010 track
->textures
[i
].num_levels
= tmp
;
1011 tmp
= idx_value
& (1 << 31);
1012 track
->textures
[i
].use_pitch
= !!tmp
;
1013 tmp
= (idx_value
>> 22) & 0xF;
1014 track
->textures
[i
].txdepth
= tmp
;
1016 case R300_ZB_ZPASS_ADDR
:
1017 r
= r100_cs_packet_next_reloc(p
, &reloc
);
1019 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
1021 r100_cs_dump_packet(p
, pkt
);
1024 ib
[idx
] = idx_value
+ ((u32
)reloc
->lobj
.gpu_offset
);
1027 /* RB3D_COLOR_CHANNEL_MASK */
1028 track
->color_channel_mask
= idx_value
;
1032 track
->fastfill
= !!(idx_value
& (1 << 2));
1035 /* RB3D_BLENDCNTL */
1036 track
->blend_read_enable
= !!(idx_value
& (1 << 2));
1039 /* valid register only on RV530 */
1040 if (p
->rdev
->family
== CHIP_RV530
)
1042 /* fallthrough do not move */
1044 printk(KERN_ERR
"Forbidden register 0x%04X in cs at %d\n",
1051 static int r300_packet3_check(struct radeon_cs_parser
*p
,
1052 struct radeon_cs_packet
*pkt
)
1054 struct radeon_cs_reloc
*reloc
;
1055 struct r100_cs_track
*track
;
1056 volatile uint32_t *ib
;
1062 track
= (struct r100_cs_track
*)p
->track
;
1063 switch(pkt
->opcode
) {
1064 case PACKET3_3D_LOAD_VBPNTR
:
1065 r
= r100_packet3_load_vbpntr(p
, pkt
, idx
);
1069 case PACKET3_INDX_BUFFER
:
1070 r
= r100_cs_packet_next_reloc(p
, &reloc
);
1072 DRM_ERROR("No reloc for packet3 %d\n", pkt
->opcode
);
1073 r100_cs_dump_packet(p
, pkt
);
1076 ib
[idx
+1] = radeon_get_ib_value(p
, idx
+ 1) + ((u32
)reloc
->lobj
.gpu_offset
);
1077 r
= r100_cs_track_check_pkt3_indx_buffer(p
, pkt
, reloc
->robj
);
1083 case PACKET3_3D_DRAW_IMMD
:
1084 /* Number of dwords is vtx_size * (num_vertices - 1)
1085 * PRIM_WALK must be equal to 3 vertex data in embedded
1087 if (((radeon_get_ib_value(p
, idx
+ 1) >> 4) & 0x3) != 3) {
1088 DRM_ERROR("PRIM_WALK must be 3 for IMMD draw\n");
1091 track
->vap_vf_cntl
= radeon_get_ib_value(p
, idx
+ 1);
1092 track
->immd_dwords
= pkt
->count
- 1;
1093 r
= r100_cs_track_check(p
->rdev
, track
);
1098 case PACKET3_3D_DRAW_IMMD_2
:
1099 /* Number of dwords is vtx_size * (num_vertices - 1)
1100 * PRIM_WALK must be equal to 3 vertex data in embedded
1102 if (((radeon_get_ib_value(p
, idx
) >> 4) & 0x3) != 3) {
1103 DRM_ERROR("PRIM_WALK must be 3 for IMMD draw\n");
1106 track
->vap_vf_cntl
= radeon_get_ib_value(p
, idx
);
1107 track
->immd_dwords
= pkt
->count
;
1108 r
= r100_cs_track_check(p
->rdev
, track
);
1113 case PACKET3_3D_DRAW_VBUF
:
1114 track
->vap_vf_cntl
= radeon_get_ib_value(p
, idx
+ 1);
1115 r
= r100_cs_track_check(p
->rdev
, track
);
1120 case PACKET3_3D_DRAW_VBUF_2
:
1121 track
->vap_vf_cntl
= radeon_get_ib_value(p
, idx
);
1122 r
= r100_cs_track_check(p
->rdev
, track
);
1127 case PACKET3_3D_DRAW_INDX
:
1128 track
->vap_vf_cntl
= radeon_get_ib_value(p
, idx
+ 1);
1129 r
= r100_cs_track_check(p
->rdev
, track
);
1134 case PACKET3_3D_DRAW_INDX_2
:
1135 track
->vap_vf_cntl
= radeon_get_ib_value(p
, idx
);
1136 r
= r100_cs_track_check(p
->rdev
, track
);
1144 DRM_ERROR("Packet3 opcode %x not supported\n", pkt
->opcode
);
1150 int r300_cs_parse(struct radeon_cs_parser
*p
)
1152 struct radeon_cs_packet pkt
;
1153 struct r100_cs_track
*track
;
1156 track
= kzalloc(sizeof(*track
), GFP_KERNEL
);
1157 r100_cs_track_clear(p
->rdev
, track
);
1160 r
= r100_cs_packet_parse(p
, &pkt
, p
->idx
);
1164 p
->idx
+= pkt
.count
+ 2;
1167 r
= r100_cs_parse_packet0(p
, &pkt
,
1168 p
->rdev
->config
.r300
.reg_safe_bm
,
1169 p
->rdev
->config
.r300
.reg_safe_bm_size
,
1170 &r300_packet0_check
);
1175 r
= r300_packet3_check(p
, &pkt
);
1178 DRM_ERROR("Unknown packet type %d !\n", pkt
.type
);
1184 } while (p
->idx
< p
->chunks
[p
->chunk_ib_idx
].length_dw
);
1188 void r300_set_reg_safe(struct radeon_device
*rdev
)
1190 rdev
->config
.r300
.reg_safe_bm
= r300_reg_safe_bm
;
1191 rdev
->config
.r300
.reg_safe_bm_size
= ARRAY_SIZE(r300_reg_safe_bm
);
1194 void r300_mc_program(struct radeon_device
*rdev
)
1196 struct r100_mc_save save
;
1199 r
= r100_debugfs_mc_info_init(rdev
);
1201 dev_err(rdev
->dev
, "Failed to create r100_mc debugfs file.\n");
1204 /* Stops all mc clients */
1205 r100_mc_stop(rdev
, &save
);
1206 if (rdev
->flags
& RADEON_IS_AGP
) {
1207 WREG32(R_00014C_MC_AGP_LOCATION
,
1208 S_00014C_MC_AGP_START(rdev
->mc
.gtt_start
>> 16) |
1209 S_00014C_MC_AGP_TOP(rdev
->mc
.gtt_end
>> 16));
1210 WREG32(R_000170_AGP_BASE
, lower_32_bits(rdev
->mc
.agp_base
));
1211 WREG32(R_00015C_AGP_BASE_2
,
1212 upper_32_bits(rdev
->mc
.agp_base
) & 0xff);
1214 WREG32(R_00014C_MC_AGP_LOCATION
, 0x0FFFFFFF);
1215 WREG32(R_000170_AGP_BASE
, 0);
1216 WREG32(R_00015C_AGP_BASE_2
, 0);
1218 /* Wait for mc idle */
1219 if (r300_mc_wait_for_idle(rdev
))
1220 DRM_INFO("Failed to wait MC idle before programming MC.\n");
1221 /* Program MC, should be a 32bits limited address space */
1222 WREG32(R_000148_MC_FB_LOCATION
,
1223 S_000148_MC_FB_START(rdev
->mc
.vram_start
>> 16) |
1224 S_000148_MC_FB_TOP(rdev
->mc
.vram_end
>> 16));
1225 r100_mc_resume(rdev
, &save
);
1228 void r300_clock_startup(struct radeon_device
*rdev
)
1232 if (radeon_dynclks
!= -1 && radeon_dynclks
)
1233 radeon_legacy_set_clock_gating(rdev
, 1);
1234 /* We need to force on some of the block */
1235 tmp
= RREG32_PLL(R_00000D_SCLK_CNTL
);
1236 tmp
|= S_00000D_FORCE_CP(1) | S_00000D_FORCE_VIP(1);
1237 if ((rdev
->family
== CHIP_RV350
) || (rdev
->family
== CHIP_RV380
))
1238 tmp
|= S_00000D_FORCE_VAP(1);
1239 WREG32_PLL(R_00000D_SCLK_CNTL
, tmp
);
1242 static int r300_startup(struct radeon_device
*rdev
)
1246 /* set common regs */
1247 r100_set_common_regs(rdev
);
1249 r300_mc_program(rdev
);
1251 r300_clock_startup(rdev
);
1252 /* Initialize GPU configuration (# pipes, ...) */
1253 r300_gpu_init(rdev
);
1254 /* Initialize GART (initialize after TTM so we can allocate
1255 * memory through TTM but finalize after TTM) */
1256 if (rdev
->flags
& RADEON_IS_PCIE
) {
1257 r
= rv370_pcie_gart_enable(rdev
);
1262 if (rdev
->family
== CHIP_R300
||
1263 rdev
->family
== CHIP_R350
||
1264 rdev
->family
== CHIP_RV350
)
1265 r100_enable_bm(rdev
);
1267 if (rdev
->flags
& RADEON_IS_PCI
) {
1268 r
= r100_pci_gart_enable(rdev
);
1274 rdev
->config
.r300
.hdp_cntl
= RREG32(RADEON_HOST_PATH_CNTL
);
1275 /* 1M ring buffer */
1276 r
= r100_cp_init(rdev
, 1024 * 1024);
1278 dev_err(rdev
->dev
, "failled initializing CP (%d).\n", r
);
1281 r
= r100_wb_init(rdev
);
1283 dev_err(rdev
->dev
, "failled initializing WB (%d).\n", r
);
1284 r
= r100_ib_init(rdev
);
1286 dev_err(rdev
->dev
, "failled initializing IB (%d).\n", r
);
1292 int r300_resume(struct radeon_device
*rdev
)
1294 /* Make sur GART are not working */
1295 if (rdev
->flags
& RADEON_IS_PCIE
)
1296 rv370_pcie_gart_disable(rdev
);
1297 if (rdev
->flags
& RADEON_IS_PCI
)
1298 r100_pci_gart_disable(rdev
);
1299 /* Resume clock before doing reset */
1300 r300_clock_startup(rdev
);
1301 /* Reset gpu before posting otherwise ATOM will enter infinite loop */
1302 if (radeon_gpu_reset(rdev
)) {
1303 dev_warn(rdev
->dev
, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
1304 RREG32(R_000E40_RBBM_STATUS
),
1305 RREG32(R_0007C0_CP_STAT
));
1308 radeon_combios_asic_init(rdev
->ddev
);
1309 /* Resume clock after posting */
1310 r300_clock_startup(rdev
);
1311 /* Initialize surface registers */
1312 radeon_surface_init(rdev
);
1313 return r300_startup(rdev
);
1316 int r300_suspend(struct radeon_device
*rdev
)
1318 r100_cp_disable(rdev
);
1319 r100_wb_disable(rdev
);
1320 r100_irq_disable(rdev
);
1321 if (rdev
->flags
& RADEON_IS_PCIE
)
1322 rv370_pcie_gart_disable(rdev
);
1323 if (rdev
->flags
& RADEON_IS_PCI
)
1324 r100_pci_gart_disable(rdev
);
1328 void r300_fini(struct radeon_device
*rdev
)
1334 radeon_gem_fini(rdev
);
1335 if (rdev
->flags
& RADEON_IS_PCIE
)
1336 rv370_pcie_gart_fini(rdev
);
1337 if (rdev
->flags
& RADEON_IS_PCI
)
1338 r100_pci_gart_fini(rdev
);
1339 radeon_agp_fini(rdev
);
1340 radeon_irq_kms_fini(rdev
);
1341 radeon_fence_driver_fini(rdev
);
1342 radeon_bo_fini(rdev
);
1343 radeon_atombios_fini(rdev
);
1348 int r300_init(struct radeon_device
*rdev
)
1353 r100_vga_render_disable(rdev
);
1354 /* Initialize scratch registers */
1355 radeon_scratch_init(rdev
);
1356 /* Initialize surface registers */
1357 radeon_surface_init(rdev
);
1358 /* TODO: disable VGA need to use VGA request */
1360 if (!radeon_get_bios(rdev
)) {
1361 if (ASIC_IS_AVIVO(rdev
))
1364 if (rdev
->is_atom_bios
) {
1365 dev_err(rdev
->dev
, "Expecting combios for RS400/RS480 GPU\n");
1368 r
= radeon_combios_init(rdev
);
1372 /* Reset gpu before posting otherwise ATOM will enter infinite loop */
1373 if (radeon_gpu_reset(rdev
)) {
1375 "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
1376 RREG32(R_000E40_RBBM_STATUS
),
1377 RREG32(R_0007C0_CP_STAT
));
1379 /* check if cards are posted or not */
1380 if (radeon_boot_test_post_card(rdev
) == false)
1382 /* Set asic errata */
1384 /* Initialize clocks */
1385 radeon_get_clock_info(rdev
->ddev
);
1386 /* Initialize power management */
1387 radeon_pm_init(rdev
);
1388 /* Get vram informations */
1389 r300_vram_info(rdev
);
1390 /* Initialize memory controller (also test AGP) */
1391 r
= r420_mc_init(rdev
);
1395 r
= radeon_fence_driver_init(rdev
);
1398 r
= radeon_irq_kms_init(rdev
);
1401 /* Memory manager */
1402 r
= radeon_bo_init(rdev
);
1405 if (rdev
->flags
& RADEON_IS_PCIE
) {
1406 r
= rv370_pcie_gart_init(rdev
);
1410 if (rdev
->flags
& RADEON_IS_PCI
) {
1411 r
= r100_pci_gart_init(rdev
);
1415 r300_set_reg_safe(rdev
);
1416 rdev
->accel_working
= true;
1417 r
= r300_startup(rdev
);
1419 /* Somethings want wront with the accel init stop accel */
1420 dev_err(rdev
->dev
, "Disabling GPU acceleration\n");
1425 if (rdev
->flags
& RADEON_IS_PCIE
)
1426 rv370_pcie_gart_fini(rdev
);
1427 if (rdev
->flags
& RADEON_IS_PCI
)
1428 r100_pci_gart_fini(rdev
);
1429 radeon_irq_kms_fini(rdev
);
1430 rdev
->accel_working
= false;