aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-16 01:03:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:44 -0400
commita6c0c37db654444dfce91cd75ad8a56bb15a0d25 (patch)
treea204a42fa6441253f51bd186f6978a4f25492a44 /drivers
parent7c08c9ae0c145807c0dae4a55f240fa3d4fd5262 (diff)
radeonfb: misc cleanup of engine and dst cache handling
Fix a couple of incomplete tests of the chip families in the engine init/reset code and proper initialization of the destination cache mode. The result should better match what the latest X radeon driver does. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: David S. Miller <davem@davemloft.net> Cc: Krzysztof Halasa <khc@pm.waw.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/aty/radeon_accel.c22
-rw-r--r--drivers/video/aty/radeon_base.c13
-rw-r--r--drivers/video/aty/radeonfb.h33
3 files changed, 38 insertions, 30 deletions
diff --git a/drivers/video/aty/radeon_accel.c b/drivers/video/aty/radeon_accel.c
index aa95f8350242..a469a3d6edcb 100644
--- a/drivers/video/aty/radeon_accel.c
+++ b/drivers/video/aty/radeon_accel.c
@@ -211,9 +211,7 @@ void radeonfb_engine_reset(struct radeonfb_info *rinfo)
211 host_path_cntl = INREG(HOST_PATH_CNTL); 211 host_path_cntl = INREG(HOST_PATH_CNTL);
212 rbbm_soft_reset = INREG(RBBM_SOFT_RESET); 212 rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
213 213
214 if (rinfo->family == CHIP_FAMILY_R300 || 214 if (IS_R300_VARIANT(rinfo)) {
215 rinfo->family == CHIP_FAMILY_R350 ||
216 rinfo->family == CHIP_FAMILY_RV350) {
217 u32 tmp; 215 u32 tmp;
218 216
219 OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset | 217 OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
@@ -249,9 +247,7 @@ void radeonfb_engine_reset(struct radeonfb_info *rinfo)
249 INREG(HOST_PATH_CNTL); 247 INREG(HOST_PATH_CNTL);
250 OUTREG(HOST_PATH_CNTL, host_path_cntl); 248 OUTREG(HOST_PATH_CNTL, host_path_cntl);
251 249
252 if (rinfo->family != CHIP_FAMILY_R300 && 250 if (!IS_R300_VARIANT(rinfo))
253 rinfo->family != CHIP_FAMILY_R350 &&
254 rinfo->family != CHIP_FAMILY_RV350)
255 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset); 251 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
256 252
257 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index); 253 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
@@ -268,10 +264,18 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
268 radeonfb_engine_reset(rinfo); 264 radeonfb_engine_reset(rinfo);
269 265
270 radeon_fifo_wait (1); 266 radeon_fifo_wait (1);
271 if ((rinfo->family != CHIP_FAMILY_R300) && 267 if (IS_R300_VARIANT(rinfo)) {
272 (rinfo->family != CHIP_FAMILY_R350) && 268 OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) |
273 (rinfo->family != CHIP_FAMILY_RV350)) 269 RB2D_DC_AUTOFLUSH_ENABLE |
270 RB2D_DC_DC_DISABLE_IGNORE_PE);
271 } else {
272 /* This needs to be double checked with ATI. Latest X driver
273 * completely "forgets" to set this register on < r3xx, and
274 * we used to just write 0 there... I'll keep the 0 and update
275 * that when we have sorted things out on X side.
276 */
274 OUTREG(RB2D_DSTCACHE_MODE, 0); 277 OUTREG(RB2D_DSTCACHE_MODE, 0);
278 }
275 279
276 radeon_fifo_wait (3); 280 radeon_fifo_wait (3);
277 /* We re-read MC_FB_LOCATION from card as it can have been 281 /* We re-read MC_FB_LOCATION from card as it can have been
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 652273e9f5f9..d0f1a7fc2c9d 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -1286,11 +1286,10 @@ static void radeon_write_pll_regs(struct radeonfb_info *rinfo, struct radeon_reg
1286 radeon_pll_errata_after_data(rinfo); 1286 radeon_pll_errata_after_data(rinfo);
1287 1287
1288 /* Set PPLL ref. div */ 1288 /* Set PPLL ref. div */
1289 if (rinfo->family == CHIP_FAMILY_R300 || 1289 if (IS_R300_VARIANT(rinfo) ||
1290 rinfo->family == CHIP_FAMILY_RS300 || 1290 rinfo->family == CHIP_FAMILY_RS300 ||
1291 rinfo->family == CHIP_FAMILY_R350 || 1291 rinfo->family == CHIP_FAMILY_RS400 ||
1292 rinfo->family == CHIP_FAMILY_RV350 || 1292 rinfo->family == CHIP_FAMILY_RS480) {
1293 rinfo->family == CHIP_FAMILY_RV380 ) {
1294 if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) { 1293 if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) {
1295 /* When restoring console mode, use saved PPLL_REF_DIV 1294 /* When restoring console mode, use saved PPLL_REF_DIV
1296 * setting. 1295 * setting.
@@ -1461,10 +1460,7 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
1461 /* Not all chip revs have the same format for this register, 1460 /* Not all chip revs have the same format for this register,
1462 * extract the source selection 1461 * extract the source selection
1463 */ 1462 */
1464 if (rinfo->family == CHIP_FAMILY_R200 || 1463 if (rinfo->family == CHIP_FAMILY_R200 || IS_R300_VARIANT(rinfo)) {
1465 rinfo->family == CHIP_FAMILY_R300 ||
1466 rinfo->family == CHIP_FAMILY_R350 ||
1467 rinfo->family == CHIP_FAMILY_RV350) {
1468 source = (fp2_gen_cntl >> 10) & 0x3; 1464 source = (fp2_gen_cntl >> 10) & 0x3;
1469 /* sourced from transform unit, check for transform unit 1465 /* sourced from transform unit, check for transform unit
1470 * own source 1466 * own source
@@ -2005,6 +2001,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
2005 (rinfo->family == CHIP_FAMILY_RS200) || 2001 (rinfo->family == CHIP_FAMILY_RS200) ||
2006 (rinfo->family == CHIP_FAMILY_RS300) || 2002 (rinfo->family == CHIP_FAMILY_RS300) ||
2007 (rinfo->family == CHIP_FAMILY_RC410) || 2003 (rinfo->family == CHIP_FAMILY_RC410) ||
2004 (rinfo->family == CHIP_FAMILY_RS400) ||
2008 (rinfo->family == CHIP_FAMILY_RS480) ) { 2005 (rinfo->family == CHIP_FAMILY_RS480) ) {
2009 u32 tom = INREG(NB_TOM); 2006 u32 tom = INREG(NB_TOM);
2010 tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024); 2007 tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index ccbfffd12805..3ea1b00fdd22 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -53,6 +53,7 @@ enum radeon_family {
53 CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */ 53 CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */
54 CHIP_FAMILY_R420, /* R420/R423/M18 */ 54 CHIP_FAMILY_R420, /* R420/R423/M18 */
55 CHIP_FAMILY_RC410, 55 CHIP_FAMILY_RC410,
56 CHIP_FAMILY_RS400,
56 CHIP_FAMILY_RS480, 57 CHIP_FAMILY_RS480,
57 CHIP_FAMILY_LAST, 58 CHIP_FAMILY_LAST,
58}; 59};
@@ -533,33 +534,39 @@ static inline u32 radeon_get_dstbpp(u16 depth)
533/* 534/*
534 * 2D Engine helper routines 535 * 2D Engine helper routines
535 */ 536 */
536static inline void radeon_engine_flush (struct radeonfb_info *rinfo) 537
538static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
537{ 539{
538 int i; 540 int i;
539 541
540 /* initiate flush */ 542 for (i=0; i<2000000; i++) {
541 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL, 543 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
542 ~RB2D_DC_FLUSH_ALL);
543
544 for (i=0; i < 2000000; i++) {
545 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
546 return; 544 return;
547 udelay(1); 545 udelay(1);
548 } 546 }
549 printk(KERN_ERR "radeonfb: Flush Timeout !\n"); 547 printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
550} 548}
551 549
552 550static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
553static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
554{ 551{
555 int i; 552 int i;
556 553
557 for (i=0; i<2000000; i++) { 554 /* Initiate flush */
558 if ((INREG(RBBM_STATUS) & 0x7f) >= entries) 555 OUTREGP(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
556 ~RB2D_DC_FLUSH_ALL);
557
558 /* Ensure FIFO is empty, ie, make sure the flush commands
559 * has reached the cache
560 */
561 _radeon_fifo_wait (rinfo, 64);
562
563 /* Wait for the flush to complete */
564 for (i=0; i < 2000000; i++) {
565 if (!(INREG(DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
559 return; 566 return;
560 udelay(1); 567 udelay(1);
561 } 568 }
562 printk(KERN_ERR "radeonfb: FIFO Timeout !\n"); 569 printk(KERN_ERR "radeonfb: Flush Timeout !\n");
563} 570}
564 571
565 572