Lines 1-5
Link Here
|
|
|
1 |
|
1 |
/* |
2 |
/* |
2 |
* drivers/video/radeonfb.c |
3 |
* drivers/video/aty/radeon_base.c |
|
|
4 |
* |
3 |
* framebuffer driver for ATI Radeon chipset video boards |
5 |
* framebuffer driver for ATI Radeon chipset video boards |
4 |
* |
6 |
* |
5 |
* Copyright 2003 Ben. Herrenschmidt <benh@kernel.crashing.org> |
7 |
* Copyright 2003 Ben. Herrenschmidt <benh@kernel.crashing.org> |
Lines 75-81
Link Here
|
75 |
|
77 |
|
76 |
#ifdef CONFIG_PPC_OF |
78 |
#ifdef CONFIG_PPC_OF |
77 |
|
79 |
|
78 |
#include <asm/prom.h> |
|
|
79 |
#include <asm/pci-bridge.h> |
80 |
#include <asm/pci-bridge.h> |
80 |
#include "../macmodes.h" |
81 |
#include "../macmodes.h" |
81 |
|
82 |
|
Lines 150-157
Link Here
|
150 |
CHIP_DEF(PCI_CHIP_RV250_Ig, RV250, CHIP_HAS_CRTC2), |
151 |
CHIP_DEF(PCI_CHIP_RV250_Ig, RV250, CHIP_HAS_CRTC2), |
151 |
/* Mobility 9100 IGP (U3) */ |
152 |
/* Mobility 9100 IGP (U3) */ |
152 |
CHIP_DEF(PCI_CHIP_RS300_5835, RS300, CHIP_HAS_CRTC2 | CHIP_IS_IGP | CHIP_IS_MOBILITY), |
153 |
CHIP_DEF(PCI_CHIP_RS300_5835, RS300, CHIP_HAS_CRTC2 | CHIP_IS_IGP | CHIP_IS_MOBILITY), |
|
|
154 |
CHIP_DEF(PCI_CHIP_RS350_7835, RS300, CHIP_HAS_CRTC2 | CHIP_IS_IGP | CHIP_IS_MOBILITY), |
153 |
/* 9100 IGP (A5) */ |
155 |
/* 9100 IGP (A5) */ |
154 |
CHIP_DEF(PCI_CHIP_RS300_5834, RS300, CHIP_HAS_CRTC2 | CHIP_IS_IGP), |
156 |
CHIP_DEF(PCI_CHIP_RS300_5834, RS300, CHIP_HAS_CRTC2 | CHIP_IS_IGP), |
|
|
157 |
CHIP_DEF(PCI_CHIP_RS350_7834, RS300, CHIP_HAS_CRTC2 | CHIP_IS_IGP), |
155 |
/* Mobility 9200 (M9+) */ |
158 |
/* Mobility 9200 (M9+) */ |
156 |
CHIP_DEF(PCI_CHIP_RV280_5C61, RV280, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
159 |
CHIP_DEF(PCI_CHIP_RV280_5C61, RV280, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
157 |
CHIP_DEF(PCI_CHIP_RV280_5C63, RV280, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
160 |
CHIP_DEF(PCI_CHIP_RV280_5C63, RV280, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
Lines 194-199
Link Here
|
194 |
CHIP_DEF(PCI_CHIP_R350_NI, R350, CHIP_HAS_CRTC2), |
197 |
CHIP_DEF(PCI_CHIP_R350_NI, R350, CHIP_HAS_CRTC2), |
195 |
CHIP_DEF(PCI_CHIP_R360_NJ, R350, CHIP_HAS_CRTC2), |
198 |
CHIP_DEF(PCI_CHIP_R360_NJ, R350, CHIP_HAS_CRTC2), |
196 |
CHIP_DEF(PCI_CHIP_R350_NK, R350, CHIP_HAS_CRTC2), |
199 |
CHIP_DEF(PCI_CHIP_R350_NK, R350, CHIP_HAS_CRTC2), |
|
|
200 |
/* Newer stuff */ |
201 |
CHIP_DEF(PCI_CHIP_RV380_3E50, RV380, CHIP_HAS_CRTC2), |
202 |
CHIP_DEF(PCI_CHIP_RV380_3E54, RV380, CHIP_HAS_CRTC2), |
203 |
CHIP_DEF(PCI_CHIP_RV380_3150, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
204 |
CHIP_DEF(PCI_CHIP_RV380_3154, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
205 |
CHIP_DEF(PCI_CHIP_RV370_5B60, RV380, CHIP_HAS_CRTC2), |
206 |
CHIP_DEF(PCI_CHIP_RV370_5B62, RV380, CHIP_HAS_CRTC2), |
207 |
CHIP_DEF(PCI_CHIP_RV370_5B64, RV380, CHIP_HAS_CRTC2), |
208 |
CHIP_DEF(PCI_CHIP_RV370_5B65, RV380, CHIP_HAS_CRTC2), |
209 |
CHIP_DEF(PCI_CHIP_RV370_5460, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
210 |
CHIP_DEF(PCI_CHIP_RV370_5464, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
211 |
CHIP_DEF(PCI_CHIP_R420_JH, R420, CHIP_HAS_CRTC2), |
212 |
CHIP_DEF(PCI_CHIP_R420_JI, R420, CHIP_HAS_CRTC2), |
213 |
CHIP_DEF(PCI_CHIP_R420_JJ, R420, CHIP_HAS_CRTC2), |
214 |
CHIP_DEF(PCI_CHIP_R420_JK, R420, CHIP_HAS_CRTC2), |
215 |
CHIP_DEF(PCI_CHIP_R420_JL, R420, CHIP_HAS_CRTC2), |
216 |
CHIP_DEF(PCI_CHIP_R420_JM, R420, CHIP_HAS_CRTC2), |
217 |
CHIP_DEF(PCI_CHIP_R420_JN, R420, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
218 |
CHIP_DEF(PCI_CHIP_R420_JP, R420, CHIP_HAS_CRTC2), |
219 |
CHIP_DEF(PCI_CHIP_R423_UH, R420, CHIP_HAS_CRTC2), |
220 |
CHIP_DEF(PCI_CHIP_R423_UI, R420, CHIP_HAS_CRTC2), |
221 |
CHIP_DEF(PCI_CHIP_R423_UJ, R420, CHIP_HAS_CRTC2), |
222 |
CHIP_DEF(PCI_CHIP_R423_UK, R420, CHIP_HAS_CRTC2), |
223 |
CHIP_DEF(PCI_CHIP_R423_UQ, R420, CHIP_HAS_CRTC2), |
224 |
CHIP_DEF(PCI_CHIP_R423_UR, R420, CHIP_HAS_CRTC2), |
225 |
CHIP_DEF(PCI_CHIP_R423_UT, R420, CHIP_HAS_CRTC2), |
226 |
CHIP_DEF(PCI_CHIP_R423_5D57, R420, CHIP_HAS_CRTC2), |
197 |
/* Original Radeon/7200 */ |
227 |
/* Original Radeon/7200 */ |
198 |
CHIP_DEF(PCI_CHIP_RADEON_QD, RADEON, 0), |
228 |
CHIP_DEF(PCI_CHIP_RADEON_QD, RADEON, 0), |
199 |
CHIP_DEF(PCI_CHIP_RADEON_QE, RADEON, 0), |
229 |
CHIP_DEF(PCI_CHIP_RADEON_QE, RADEON, 0), |
Lines 233-238
Link Here
|
233 |
static char *mode_option; |
263 |
static char *mode_option; |
234 |
static char *monitor_layout; |
264 |
static char *monitor_layout; |
235 |
static int noaccel = 0; |
265 |
static int noaccel = 0; |
|
|
266 |
static int default_dynclk = -2; |
236 |
static int nomodeset = 0; |
267 |
static int nomodeset = 0; |
237 |
static int ignore_edid = 0; |
268 |
static int ignore_edid = 0; |
238 |
static int mirror = 0; |
269 |
static int mirror = 0; |
Lines 290-296
Link Here
|
290 |
|
321 |
|
291 |
rom = pci_map_rom(dev, &rom_size); |
322 |
rom = pci_map_rom(dev, &rom_size); |
292 |
if (!rom) { |
323 |
if (!rom) { |
293 |
printk(KERN_ERR "radeonfb: ROM failed to map\n"); |
324 |
printk(KERN_ERR "radeonfb (%s): ROM failed to map\n", |
|
|
325 |
pci_name(rinfo->pdev)); |
294 |
return -ENOMEM; |
326 |
return -ENOMEM; |
295 |
} |
327 |
} |
296 |
|
328 |
|
Lines 298-305
Link Here
|
298 |
|
330 |
|
299 |
/* Very simple test to make sure it appeared */ |
331 |
/* Very simple test to make sure it appeared */ |
300 |
if (BIOS_IN16(0) != 0xaa55) { |
332 |
if (BIOS_IN16(0) != 0xaa55) { |
301 |
printk(KERN_ERR "radeonfb: Invalid ROM signature %x should be 0xaa55\n", |
333 |
printk(KERN_ERR "radeonfb (%s): Invalid ROM signature %x should be" |
302 |
BIOS_IN16(0)); |
334 |
"0xaa55\n", pci_name(rinfo->pdev), BIOS_IN16(0)); |
303 |
goto failed; |
335 |
goto failed; |
304 |
} |
336 |
} |
305 |
/* Look for the PCI data to check the ROM type */ |
337 |
/* Look for the PCI data to check the ROM type */ |
Lines 330-337
Link Here
|
330 |
* } pci_data_t; |
362 |
* } pci_data_t; |
331 |
*/ |
363 |
*/ |
332 |
if (BIOS_IN32(dptr) != (('R' << 24) | ('I' << 16) | ('C' << 8) | 'P')) { |
364 |
if (BIOS_IN32(dptr) != (('R' << 24) | ('I' << 16) | ('C' << 8) | 'P')) { |
333 |
printk(KERN_WARNING "radeonfb: PCI DATA signature in ROM incorrect: %08x\n", |
365 |
printk(KERN_WARNING "radeonfb (%s): PCI DATA signature in ROM" |
334 |
BIOS_IN32(dptr)); |
366 |
"incorrect: %08x\n", pci_name(rinfo->pdev), BIOS_IN32(dptr)); |
335 |
goto anyway; |
367 |
goto anyway; |
336 |
} |
368 |
} |
337 |
rom_type = BIOS_IN8(dptr + 0x14); |
369 |
rom_type = BIOS_IN8(dptr + 0x14); |
Lines 398-411
Link Here
|
398 |
*/ |
430 |
*/ |
399 |
static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo) |
431 |
static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo) |
400 |
{ |
432 |
{ |
401 |
struct device_node *dp; |
433 |
struct device_node *dp = rinfo->of_node; |
402 |
u32 *val; |
434 |
u32 *val; |
403 |
|
435 |
|
404 |
dp = pci_device_to_OF_node(rinfo->pdev); |
436 |
if (dp == NULL) |
405 |
if (dp == NULL) { |
|
|
406 |
printk(KERN_WARNING "radeonfb: Cannot match card to OF node !\n"); |
407 |
return -ENODEV; |
437 |
return -ENODEV; |
408 |
} |
|
|
409 |
val = (u32 *) get_property(dp, "ATY,RefCLK", NULL); |
438 |
val = (u32 *) get_property(dp, "ATY,RefCLK", NULL); |
410 |
if (!val || !*val) { |
439 |
if (!val || !*val) { |
411 |
printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n"); |
440 |
printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n"); |
Lines 488-507
Link Here
|
488 |
denom = 1; |
517 |
denom = 1; |
489 |
break; |
518 |
break; |
490 |
case 1: |
519 |
case 1: |
491 |
n = ((INPLL(X_MPLL_REF_FB_DIV) >> 16) & 0xff); |
520 |
n = ((INPLL(M_SPLL_REF_FB_DIV) >> 16) & 0xff); |
492 |
m = (INPLL(X_MPLL_REF_FB_DIV) & 0xff); |
521 |
m = (INPLL(M_SPLL_REF_FB_DIV) & 0xff); |
493 |
num = 2*n; |
522 |
num = 2*n; |
494 |
denom = 2*m; |
523 |
denom = 2*m; |
495 |
break; |
524 |
break; |
496 |
case 2: |
525 |
case 2: |
497 |
n = ((INPLL(X_MPLL_REF_FB_DIV) >> 8) & 0xff); |
526 |
n = ((INPLL(M_SPLL_REF_FB_DIV) >> 8) & 0xff); |
498 |
m = (INPLL(X_MPLL_REF_FB_DIV) & 0xff); |
527 |
m = (INPLL(M_SPLL_REF_FB_DIV) & 0xff); |
499 |
num = 2*n; |
528 |
num = 2*n; |
500 |
denom = 2*m; |
529 |
denom = 2*m; |
501 |
break; |
530 |
break; |
502 |
} |
531 |
} |
503 |
|
532 |
|
504 |
ppll_div_sel = INREG(CLOCK_CNTL_INDEX + 1) & 0x3; |
533 |
ppll_div_sel = INREG8(CLOCK_CNTL_INDEX + 1) & 0x3; |
505 |
|
534 |
|
506 |
n = (INPLL(PPLL_DIV_0 + ppll_div_sel) & 0x7ff); |
535 |
n = (INPLL(PPLL_DIV_0 + ppll_div_sel) & 0x7ff); |
507 |
m = (INPLL(PPLL_REF_DIV) & 0x3ff); |
536 |
m = (INPLL(PPLL_REF_DIV) & 0x3ff); |
Lines 545-551
Link Here
|
545 |
return -1; |
574 |
return -1; |
546 |
} |
575 |
} |
547 |
|
576 |
|
548 |
tmp = INPLL(X_MPLL_REF_FB_DIV); |
577 |
tmp = INPLL(M_SPLL_REF_FB_DIV); |
549 |
ref_div = INPLL(PPLL_REF_DIV) & 0x3ff; |
578 |
ref_div = INPLL(PPLL_REF_DIV) & 0x3ff; |
550 |
|
579 |
|
551 |
Ns = (tmp & 0xff0000) >> 16; |
580 |
Ns = (tmp & 0xff0000) >> 16; |
Lines 625-631
Link Here
|
625 |
rinfo->pll.ref_clk = 2700; |
654 |
rinfo->pll.ref_clk = 2700; |
626 |
break; |
655 |
break; |
627 |
} |
656 |
} |
628 |
rinfo->pll.ref_div = INPLL(PPLL_REF_DIV) & 0x3ff; |
657 |
rinfo->pll.ref_div = INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK; |
629 |
|
658 |
|
630 |
|
659 |
|
631 |
#ifdef CONFIG_PPC_OF |
660 |
#ifdef CONFIG_PPC_OF |
Lines 906-915
Link Here
|
906 |
} |
935 |
} |
907 |
|
936 |
|
908 |
|
937 |
|
909 |
static int radeon_screen_blank (struct radeonfb_info *rinfo, int blank, int mode_switch) |
938 |
int radeon_screen_blank(struct radeonfb_info *rinfo, int blank, int mode_switch) |
910 |
{ |
939 |
{ |
911 |
u32 val; |
940 |
u32 val; |
912 |
u32 tmp_pix_clks; |
941 |
u32 tmp_pix_clks; |
|
|
942 |
int unblank = 0; |
913 |
|
943 |
|
914 |
if (rinfo->lock_blank) |
944 |
if (rinfo->lock_blank) |
915 |
return 0; |
945 |
return 0; |
Lines 920-928
Link Here
|
920 |
val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | |
950 |
val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS | |
921 |
CRTC_VSYNC_DIS); |
951 |
CRTC_VSYNC_DIS); |
922 |
switch (blank) { |
952 |
switch (blank) { |
923 |
case FB_BLANK_UNBLANK: |
|
|
924 |
case FB_BLANK_NORMAL: |
925 |
break; |
926 |
case FB_BLANK_VSYNC_SUSPEND: |
953 |
case FB_BLANK_VSYNC_SUSPEND: |
927 |
val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS); |
954 |
val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS); |
928 |
break; |
955 |
break; |
Lines 933-974
Link Here
|
933 |
val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | |
960 |
val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS | |
934 |
CRTC_HSYNC_DIS); |
961 |
CRTC_HSYNC_DIS); |
935 |
break; |
962 |
break; |
|
|
963 |
case FB_BLANK_NORMAL: |
964 |
val |= CRTC_DISPLAY_DIS; |
965 |
break; |
966 |
case FB_BLANK_UNBLANK: |
967 |
default: |
968 |
unblank = 1; |
936 |
} |
969 |
} |
937 |
OUTREG(CRTC_EXT_CNTL, val); |
970 |
OUTREG(CRTC_EXT_CNTL, val); |
938 |
|
971 |
|
939 |
|
972 |
|
940 |
switch (rinfo->mon1_type) { |
973 |
switch (rinfo->mon1_type) { |
941 |
case MT_DFP: |
974 |
case MT_DFP: |
942 |
if (mode_switch) |
975 |
if (unblank) |
943 |
break; |
|
|
944 |
if (blank == FB_BLANK_UNBLANK || |
945 |
blank == FB_BLANK_NORMAL) |
946 |
OUTREGP(FP_GEN_CNTL, (FP_FPON | FP_TMDS_EN), |
976 |
OUTREGP(FP_GEN_CNTL, (FP_FPON | FP_TMDS_EN), |
947 |
~(FP_FPON | FP_TMDS_EN)); |
977 |
~(FP_FPON | FP_TMDS_EN)); |
948 |
else |
978 |
else { |
|
|
979 |
if (mode_switch || blank == FB_BLANK_NORMAL) |
980 |
break; |
949 |
OUTREGP(FP_GEN_CNTL, 0, ~(FP_FPON | FP_TMDS_EN)); |
981 |
OUTREGP(FP_GEN_CNTL, 0, ~(FP_FPON | FP_TMDS_EN)); |
|
|
982 |
} |
950 |
break; |
983 |
break; |
951 |
case MT_LCD: |
984 |
case MT_LCD: |
|
|
985 |
del_timer_sync(&rinfo->lvds_timer); |
952 |
val = INREG(LVDS_GEN_CNTL); |
986 |
val = INREG(LVDS_GEN_CNTL); |
953 |
if (blank == FB_BLANK_UNBLANK || |
987 |
if (unblank) { |
954 |
blank == FB_BLANK_NORMAL) { |
|
|
955 |
u32 target_val = (val & ~LVDS_DISPLAY_DIS) | LVDS_BLON | LVDS_ON |
988 |
u32 target_val = (val & ~LVDS_DISPLAY_DIS) | LVDS_BLON | LVDS_ON |
956 |
| LVDS_ON | (rinfo->init_state.lvds_gen_cntl & LVDS_DIGON); |
989 |
| LVDS_EN | (rinfo->init_state.lvds_gen_cntl |
|
|
990 |
& (LVDS_DIGON | LVDS_BL_MOD_EN)); |
957 |
if ((val ^ target_val) == LVDS_DISPLAY_DIS) |
991 |
if ((val ^ target_val) == LVDS_DISPLAY_DIS) |
958 |
OUTREG(LVDS_GEN_CNTL, target_val); |
992 |
OUTREG(LVDS_GEN_CNTL, target_val); |
959 |
else if ((val ^ target_val) != 0) { |
993 |
else if ((val ^ target_val) != 0) { |
960 |
del_timer_sync(&rinfo->lvds_timer); |
994 |
OUTREG(LVDS_GEN_CNTL, target_val |
961 |
OUTREG(LVDS_GEN_CNTL, target_val & ~LVDS_ON); |
995 |
& ~(LVDS_ON | LVDS_BL_MOD_EN)); |
962 |
rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; |
996 |
rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; |
963 |
rinfo->init_state.lvds_gen_cntl |= target_val & LVDS_STATE_MASK; |
997 |
rinfo->init_state.lvds_gen_cntl |= |
|
|
998 |
target_val & LVDS_STATE_MASK; |
964 |
if (mode_switch) { |
999 |
if (mode_switch) { |
965 |
msleep(rinfo->panel_info.pwr_delay); |
1000 |
radeon_msleep(rinfo->panel_info.pwr_delay); |
966 |
OUTREG(LVDS_GEN_CNTL, target_val); |
1001 |
OUTREG(LVDS_GEN_CNTL, target_val); |
967 |
} |
1002 |
} |
968 |
else { |
1003 |
else { |
969 |
rinfo->pending_lvds_gen_cntl = target_val; |
1004 |
rinfo->pending_lvds_gen_cntl = target_val; |
970 |
mod_timer(&rinfo->lvds_timer, |
1005 |
mod_timer(&rinfo->lvds_timer, |
971 |
jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay)); |
1006 |
jiffies + |
|
|
1007 |
msecs_to_jiffies(rinfo->panel_info.pwr_delay)); |
972 |
} |
1008 |
} |
973 |
} |
1009 |
} |
974 |
} else { |
1010 |
} else { |
Lines 976-982
Link Here
|
976 |
OUTREG(LVDS_GEN_CNTL, val); |
1012 |
OUTREG(LVDS_GEN_CNTL, val); |
977 |
|
1013 |
|
978 |
/* We don't do a full switch-off on a simple mode switch */ |
1014 |
/* We don't do a full switch-off on a simple mode switch */ |
979 |
if (mode_switch) |
1015 |
if (mode_switch || blank == FB_BLANK_NORMAL) |
980 |
break; |
1016 |
break; |
981 |
|
1017 |
|
982 |
/* Asic bug, when turning off LVDS_ON, we have to make sure |
1018 |
/* Asic bug, when turning off LVDS_ON, we have to make sure |
Lines 985-992
Link Here
|
985 |
tmp_pix_clks = INPLL(PIXCLKS_CNTL); |
1021 |
tmp_pix_clks = INPLL(PIXCLKS_CNTL); |
986 |
if (rinfo->is_mobility || rinfo->is_IGP) |
1022 |
if (rinfo->is_mobility || rinfo->is_IGP) |
987 |
OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb); |
1023 |
OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb); |
988 |
val &= ~(LVDS_BLON | LVDS_ON); |
1024 |
val &= ~(LVDS_BL_MOD_EN); |
|
|
1025 |
OUTREG(LVDS_GEN_CNTL, val); |
1026 |
udelay(100); |
1027 |
val &= ~(LVDS_ON | LVDS_EN); |
989 |
OUTREG(LVDS_GEN_CNTL, val); |
1028 |
OUTREG(LVDS_GEN_CNTL, val); |
|
|
1029 |
val &= ~LVDS_DIGON; |
1030 |
rinfo->pending_lvds_gen_cntl = val; |
1031 |
mod_timer(&rinfo->lvds_timer, |
1032 |
jiffies + |
1033 |
msecs_to_jiffies(rinfo->panel_info.pwr_delay)); |
990 |
rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; |
1034 |
rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; |
991 |
rinfo->init_state.lvds_gen_cntl |= val & LVDS_STATE_MASK; |
1035 |
rinfo->init_state.lvds_gen_cntl |= val & LVDS_STATE_MASK; |
992 |
if (rinfo->is_mobility || rinfo->is_IGP) |
1036 |
if (rinfo->is_mobility || rinfo->is_IGP) |
Lines 1003-1018
Link Here
|
1003 |
return (blank == FB_BLANK_NORMAL) ? -EINVAL : 0; |
1047 |
return (blank == FB_BLANK_NORMAL) ? -EINVAL : 0; |
1004 |
} |
1048 |
} |
1005 |
|
1049 |
|
1006 |
int radeonfb_blank (int blank, struct fb_info *info) |
1050 |
static int radeonfb_blank (int blank, struct fb_info *info) |
1007 |
{ |
1051 |
{ |
1008 |
struct radeonfb_info *rinfo = info->par; |
1052 |
struct radeonfb_info *rinfo = info->par; |
1009 |
|
1053 |
|
1010 |
if (rinfo->asleep) |
1054 |
if (rinfo->asleep) |
1011 |
return 0; |
1055 |
return 0; |
1012 |
|
1056 |
|
1013 |
radeon_screen_blank(rinfo, blank, 0); |
1057 |
return radeon_screen_blank(rinfo, blank, 0); |
1014 |
|
|
|
1015 |
return 0; |
1016 |
} |
1058 |
} |
1017 |
|
1059 |
|
1018 |
static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green, |
1060 |
static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green, |
Lines 1097-1103
Link Here
|
1097 |
} |
1139 |
} |
1098 |
|
1140 |
|
1099 |
|
1141 |
|
1100 |
static void radeon_save_state (struct radeonfb_info *rinfo, struct radeon_regs *save) |
1142 |
void radeon_save_state (struct radeonfb_info *rinfo, struct radeon_regs *save) |
1101 |
{ |
1143 |
{ |
1102 |
/* CRTC regs */ |
1144 |
/* CRTC regs */ |
1103 |
save->crtc_gen_cntl = INREG(CRTC_GEN_CNTL); |
1145 |
save->crtc_gen_cntl = INREG(CRTC_GEN_CNTL); |
Lines 1121-1128
Link Here
|
1121 |
save->fp_vert_stretch = INREG(FP_VERT_STRETCH); |
1163 |
save->fp_vert_stretch = INREG(FP_VERT_STRETCH); |
1122 |
save->lvds_gen_cntl = INREG(LVDS_GEN_CNTL); |
1164 |
save->lvds_gen_cntl = INREG(LVDS_GEN_CNTL); |
1123 |
save->lvds_pll_cntl = INREG(LVDS_PLL_CNTL); |
1165 |
save->lvds_pll_cntl = INREG(LVDS_PLL_CNTL); |
1124 |
save->tmds_crc = INREG(TMDS_CRC); save->tmds_transmitter_cntl = INREG(TMDS_TRANSMITTER_CNTL); |
1166 |
save->tmds_crc = INREG(TMDS_CRC); |
|
|
1167 |
save->tmds_transmitter_cntl = INREG(TMDS_TRANSMITTER_CNTL); |
1125 |
save->vclk_ecp_cntl = INPLL(VCLK_ECP_CNTL); |
1168 |
save->vclk_ecp_cntl = INPLL(VCLK_ECP_CNTL); |
|
|
1169 |
|
1170 |
/* PLL regs */ |
1171 |
save->clk_cntl_index = INREG(CLOCK_CNTL_INDEX) & ~0x3f; |
1172 |
save->ppll_div_3 = INPLL(PPLL_DIV_3); |
1173 |
save->ppll_ref_div = INPLL(PPLL_REF_DIV); |
1126 |
} |
1174 |
} |
1127 |
|
1175 |
|
1128 |
|
1176 |
|
Lines 1134-1152
Link Here
|
1134 |
|
1182 |
|
1135 |
/* Workaround from XFree */ |
1183 |
/* Workaround from XFree */ |
1136 |
if (rinfo->is_mobility) { |
1184 |
if (rinfo->is_mobility) { |
1137 |
/* A temporal workaround for the occational blanking on certain laptop panels. |
1185 |
/* A temporal workaround for the occational blanking on certain laptop |
1138 |
This appears to related to the PLL divider registers (fail to lock?). |
1186 |
* panels. This appears to related to the PLL divider registers |
1139 |
It occurs even when all dividers are the same with their old settings. |
1187 |
* (fail to lock?). It occurs even when all dividers are the same |
1140 |
In this case we really don't need to fiddle with PLL registers. |
1188 |
* with their old settings. In this case we really don't need to |
1141 |
By doing this we can avoid the blanking problem with some panels. |
1189 |
* fiddle with PLL registers. By doing this we can avoid the blanking |
1142 |
*/ |
1190 |
* problem with some panels. |
|
|
1191 |
*/ |
1143 |
if ((mode->ppll_ref_div == (INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK)) && |
1192 |
if ((mode->ppll_ref_div == (INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK)) && |
1144 |
(mode->ppll_div_3 == (INPLL(PPLL_DIV_3) & |
1193 |
(mode->ppll_div_3 == (INPLL(PPLL_DIV_3) & |
1145 |
(PPLL_POST3_DIV_MASK | PPLL_FB3_DIV_MASK)))) { |
1194 |
(PPLL_POST3_DIV_MASK | PPLL_FB3_DIV_MASK)))) { |
1146 |
/* We still have to force a switch to PPLL div 3 thanks to |
1195 |
/* We still have to force a switch to selected PPLL div thanks to |
1147 |
* an XFree86 driver bug which will switch it away in some cases |
1196 |
* an XFree86 driver bug which will switch it away in some cases |
1148 |
* even when using UseFDev */ |
1197 |
* even when using UseFDev */ |
1149 |
OUTREGP(CLOCK_CNTL_INDEX, PPLL_DIV_SEL_MASK, ~PPLL_DIV_SEL_MASK); |
1198 |
OUTREGP(CLOCK_CNTL_INDEX, |
|
|
1199 |
mode->clk_cntl_index & PPLL_DIV_SEL_MASK, |
1200 |
~PPLL_DIV_SEL_MASK); |
1150 |
return; |
1201 |
return; |
1151 |
} |
1202 |
} |
1152 |
} |
1203 |
} |
Lines 1159-1166
Link Here
|
1159 |
PPLL_RESET | PPLL_ATOMIC_UPDATE_EN | PPLL_VGA_ATOMIC_UPDATE_EN, |
1210 |
PPLL_RESET | PPLL_ATOMIC_UPDATE_EN | PPLL_VGA_ATOMIC_UPDATE_EN, |
1160 |
~(PPLL_RESET | PPLL_ATOMIC_UPDATE_EN | PPLL_VGA_ATOMIC_UPDATE_EN)); |
1211 |
~(PPLL_RESET | PPLL_ATOMIC_UPDATE_EN | PPLL_VGA_ATOMIC_UPDATE_EN)); |
1161 |
|
1212 |
|
1162 |
/* Switch to PPLL div 3 */ |
1213 |
/* Switch to selected PPLL divider */ |
1163 |
OUTREGP(CLOCK_CNTL_INDEX, PPLL_DIV_SEL_MASK, ~PPLL_DIV_SEL_MASK); |
1214 |
OUTREGP(CLOCK_CNTL_INDEX, |
|
|
1215 |
mode->clk_cntl_index & PPLL_DIV_SEL_MASK, |
1216 |
~PPLL_DIV_SEL_MASK); |
1164 |
|
1217 |
|
1165 |
/* Set PPLL ref. div */ |
1218 |
/* Set PPLL ref. div */ |
1166 |
if (rinfo->family == CHIP_FAMILY_R300 || |
1219 |
if (rinfo->family == CHIP_FAMILY_R300 || |
Lines 1205-1211
Link Here
|
1205 |
~(PPLL_RESET | PPLL_SLEEP | PPLL_ATOMIC_UPDATE_EN | PPLL_VGA_ATOMIC_UPDATE_EN)); |
1258 |
~(PPLL_RESET | PPLL_SLEEP | PPLL_ATOMIC_UPDATE_EN | PPLL_VGA_ATOMIC_UPDATE_EN)); |
1206 |
|
1259 |
|
1207 |
/* We may want some locking ... oh well */ |
1260 |
/* We may want some locking ... oh well */ |
1208 |
msleep(5); |
1261 |
radeon_msleep(5); |
1209 |
|
1262 |
|
1210 |
/* Switch back VCLK source to PPLL */ |
1263 |
/* Switch back VCLK source to PPLL */ |
1211 |
OUTPLLP(VCLK_ECP_CNTL, VCLK_SRC_SEL_PPLLCLK, ~VCLK_SRC_SEL_MASK); |
1264 |
OUTPLLP(VCLK_ECP_CNTL, VCLK_SRC_SEL_PPLLCLK, ~VCLK_SRC_SEL_MASK); |
Lines 1218-1238
Link Here
|
1218 |
{ |
1271 |
{ |
1219 |
struct radeonfb_info *rinfo = (struct radeonfb_info *)data; |
1272 |
struct radeonfb_info *rinfo = (struct radeonfb_info *)data; |
1220 |
|
1273 |
|
1221 |
radeon_fifo_wait(3); |
1274 |
radeon_engine_idle(); |
1222 |
|
1275 |
|
1223 |
OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl); |
1276 |
OUTREG(LVDS_GEN_CNTL, rinfo->pending_lvds_gen_cntl); |
1224 |
if (rinfo->pending_pixclks_cntl) { |
|
|
1225 |
OUTPLL(PIXCLKS_CNTL, rinfo->pending_pixclks_cntl); |
1226 |
rinfo->pending_pixclks_cntl = 0; |
1227 |
} |
1228 |
} |
1277 |
} |
1229 |
|
1278 |
|
1230 |
/* |
1279 |
/* |
1231 |
* Apply a video mode. This will apply the whole register set, including |
1280 |
* Apply a video mode. This will apply the whole register set, including |
1232 |
* the PLL registers, to the card |
1281 |
* the PLL registers, to the card |
1233 |
*/ |
1282 |
*/ |
1234 |
static void radeon_write_mode (struct radeonfb_info *rinfo, |
1283 |
void radeon_write_mode (struct radeonfb_info *rinfo, struct radeon_regs *mode, |
1235 |
struct radeon_regs *mode) |
1284 |
int regs_only) |
1236 |
{ |
1285 |
{ |
1237 |
int i; |
1286 |
int i; |
1238 |
int primary_mon = PRIMARY_MONITOR(rinfo); |
1287 |
int primary_mon = PRIMARY_MONITOR(rinfo); |
Lines 1240-1249
Link Here
|
1240 |
if (nomodeset) |
1289 |
if (nomodeset) |
1241 |
return; |
1290 |
return; |
1242 |
|
1291 |
|
1243 |
del_timer_sync(&rinfo->lvds_timer); |
1292 |
if (!regs_only) |
1244 |
|
1293 |
radeon_screen_blank(rinfo, FB_BLANK_NORMAL, 0); |
1245 |
radeon_screen_blank(rinfo, FB_BLANK_POWERDOWN, 1); |
|
|
1246 |
msleep(100); |
1247 |
|
1294 |
|
1248 |
radeon_fifo_wait(31); |
1295 |
radeon_fifo_wait(31); |
1249 |
for (i=0; i<10; i++) |
1296 |
for (i=0; i<10; i++) |
Lines 1285-1291
Link Here
|
1285 |
OUTREG(TMDS_TRANSMITTER_CNTL, mode->tmds_transmitter_cntl); |
1332 |
OUTREG(TMDS_TRANSMITTER_CNTL, mode->tmds_transmitter_cntl); |
1286 |
} |
1333 |
} |
1287 |
|
1334 |
|
1288 |
radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 1); |
1335 |
if (!regs_only) |
|
|
1336 |
radeon_screen_blank(rinfo, FB_BLANK_UNBLANK, 0); |
1289 |
|
1337 |
|
1290 |
radeon_fifo_wait(2); |
1338 |
radeon_fifo_wait(2); |
1291 |
OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl); |
1339 |
OUTPLL(VCLK_ECP_CNTL, mode->vclk_ecp_cntl); |
Lines 1396-1401
Link Here
|
1396 |
rinfo->pll.ref_div, rinfo->pll.ref_clk, |
1444 |
rinfo->pll.ref_div, rinfo->pll.ref_clk, |
1397 |
pll_output_freq); |
1445 |
pll_output_freq); |
1398 |
|
1446 |
|
|
|
1447 |
/* If we fall through the bottom, try the "default value" |
1448 |
given by the terminal post_div->bitvalue */ |
1449 |
if ( !post_div->divider ) { |
1450 |
post_div = &post_divs[post_div->bitvalue]; |
1451 |
pll_output_freq = post_div->divider * freq; |
1452 |
} |
1453 |
RTRACE("ref_div = %d, ref_clk = %d, output_freq = %d\n", |
1454 |
rinfo->pll.ref_div, rinfo->pll.ref_clk, |
1455 |
pll_output_freq); |
1456 |
|
1399 |
fb_div = round_div(rinfo->pll.ref_div*pll_output_freq, |
1457 |
fb_div = round_div(rinfo->pll.ref_div*pll_output_freq, |
1400 |
rinfo->pll.ref_clk); |
1458 |
rinfo->pll.ref_clk); |
1401 |
regs->ppll_ref_div = rinfo->pll.ref_div; |
1459 |
regs->ppll_ref_div = rinfo->pll.ref_div; |
Lines 1406-1427
Link Here
|
1406 |
RTRACE("ppll_div_3 = 0x%x\n", regs->ppll_div_3); |
1464 |
RTRACE("ppll_div_3 = 0x%x\n", regs->ppll_div_3); |
1407 |
} |
1465 |
} |
1408 |
|
1466 |
|
1409 |
int radeonfb_set_par(struct fb_info *info) |
1467 |
static int radeonfb_set_par(struct fb_info *info) |
1410 |
{ |
1468 |
{ |
1411 |
struct radeonfb_info *rinfo = info->par; |
1469 |
struct radeonfb_info *rinfo = info->par; |
1412 |
struct fb_var_screeninfo *mode = &info->var; |
1470 |
struct fb_var_screeninfo *mode = &info->var; |
1413 |
struct radeon_regs newmode; |
1471 |
struct radeon_regs *newmode; |
1414 |
int hTotal, vTotal, hSyncStart, hSyncEnd, |
1472 |
int hTotal, vTotal, hSyncStart, hSyncEnd, |
1415 |
hSyncPol, vSyncStart, vSyncEnd, vSyncPol, cSync; |
1473 |
hSyncPol, vSyncStart, vSyncEnd, vSyncPol, cSync; |
1416 |
u8 hsync_adj_tab[] = {0, 0x12, 9, 9, 6, 5}; |
1474 |
u8 hsync_adj_tab[] = {0, 0x12, 9, 9, 6, 5}; |
1417 |
u8 hsync_fudge_fp[] = {2, 2, 0, 0, 5, 5}; |
1475 |
u8 hsync_fudge_fp[] = {2, 2, 0, 0, 5, 5}; |
1418 |
u32 sync, h_sync_pol, v_sync_pol, dotClock, pixClock; |
1476 |
u32 sync, h_sync_pol, v_sync_pol, dotClock, pixClock; |
1419 |
int i, freq; |
1477 |
int i, freq; |
1420 |
int format = 0; |
1478 |
int format = 0; |
1421 |
int nopllcalc = 0; |
1479 |
int nopllcalc = 0; |
1422 |
int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid; |
1480 |
int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid; |
1423 |
int primary_mon = PRIMARY_MONITOR(rinfo); |
1481 |
int primary_mon = PRIMARY_MONITOR(rinfo); |
1424 |
int depth = var_to_depth(mode); |
1482 |
int depth = var_to_depth(mode); |
|
|
1483 |
int use_rmx = 0; |
1484 |
|
1485 |
newmode = kmalloc(sizeof(struct radeon_regs), GFP_KERNEL); |
1486 |
if (!newmode) |
1487 |
return -ENOMEM; |
1425 |
|
1488 |
|
1426 |
/* We always want engine to be idle on a mode switch, even |
1489 |
/* We always want engine to be idle on a mode switch, even |
1427 |
* if we won't actually change the mode |
1490 |
* if we won't actually change the mode |
Lines 1462-1470
Link Here
|
1462 |
|
1525 |
|
1463 |
if (rinfo->panel_info.use_bios_dividers) { |
1526 |
if (rinfo->panel_info.use_bios_dividers) { |
1464 |
nopllcalc = 1; |
1527 |
nopllcalc = 1; |
1465 |
newmode.ppll_div_3 = rinfo->panel_info.fbk_divider | |
1528 |
newmode->ppll_div_3 = rinfo->panel_info.fbk_divider | |
1466 |
(rinfo->panel_info.post_divider << 16); |
1529 |
(rinfo->panel_info.post_divider << 16); |
1467 |
newmode.ppll_ref_div = rinfo->panel_info.ref_divider; |
1530 |
newmode->ppll_ref_div = rinfo->panel_info.ref_divider; |
1468 |
} |
1531 |
} |
1469 |
} |
1532 |
} |
1470 |
dotClock = 1000000000 / pixClock; |
1533 |
dotClock = 1000000000 / pixClock; |
Lines 1502-1539
Link Here
|
1502 |
|
1565 |
|
1503 |
hsync_start = hSyncStart - 8 + hsync_fudge; |
1566 |
hsync_start = hSyncStart - 8 + hsync_fudge; |
1504 |
|
1567 |
|
1505 |
newmode.crtc_gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN | |
1568 |
newmode->crtc_gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN | |
1506 |
(format << 8); |
1569 |
(format << 8); |
1507 |
|
1570 |
|
1508 |
/* Clear auto-center etc... */ |
1571 |
/* Clear auto-center etc... */ |
1509 |
newmode.crtc_more_cntl = rinfo->init_state.crtc_more_cntl; |
1572 |
newmode->crtc_more_cntl = rinfo->init_state.crtc_more_cntl; |
1510 |
newmode.crtc_more_cntl &= 0xfffffff0; |
1573 |
newmode->crtc_more_cntl &= 0xfffffff0; |
1511 |
|
1574 |
|
1512 |
if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { |
1575 |
if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { |
1513 |
newmode.crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN; |
1576 |
newmode->crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN; |
1514 |
if (mirror) |
1577 |
if (mirror) |
1515 |
newmode.crtc_ext_cntl |= CRTC_CRT_ON; |
1578 |
newmode->crtc_ext_cntl |= CRTC_CRT_ON; |
1516 |
|
1579 |
|
1517 |
newmode.crtc_gen_cntl &= ~(CRTC_DBL_SCAN_EN | |
1580 |
newmode->crtc_gen_cntl &= ~(CRTC_DBL_SCAN_EN | |
1518 |
CRTC_INTERLACE_EN); |
1581 |
CRTC_INTERLACE_EN); |
1519 |
} else { |
1582 |
} else { |
1520 |
newmode.crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN | |
1583 |
newmode->crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN | |
1521 |
CRTC_CRT_ON; |
1584 |
CRTC_CRT_ON; |
1522 |
} |
1585 |
} |
1523 |
|
1586 |
|
1524 |
newmode.dac_cntl = /* INREG(DAC_CNTL) | */ DAC_MASK_ALL | DAC_VGA_ADR_EN | |
1587 |
newmode->dac_cntl = /* INREG(DAC_CNTL) | */ DAC_MASK_ALL | DAC_VGA_ADR_EN | |
1525 |
DAC_8BIT_EN; |
1588 |
DAC_8BIT_EN; |
1526 |
|
1589 |
|
1527 |
newmode.crtc_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff) | |
1590 |
newmode->crtc_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff) | |
1528 |
(((mode->xres / 8) - 1) << 16)); |
1591 |
(((mode->xres / 8) - 1) << 16)); |
1529 |
|
1592 |
|
1530 |
newmode.crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) | |
1593 |
newmode->crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) | |
1531 |
(hsync_wid << 16) | (h_sync_pol << 23)); |
1594 |
(hsync_wid << 16) | (h_sync_pol << 23)); |
1532 |
|
1595 |
|
1533 |
newmode.crtc_v_total_disp = ((vTotal - 1) & 0xffff) | |
1596 |
newmode->crtc_v_total_disp = ((vTotal - 1) & 0xffff) | |
1534 |
((mode->yres - 1) << 16); |
1597 |
((mode->yres - 1) << 16); |
1535 |
|
1598 |
|
1536 |
newmode.crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff) | |
1599 |
newmode->crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff) | |
1537 |
(vsync_wid << 16) | (v_sync_pol << 23)); |
1600 |
(vsync_wid << 16) | (v_sync_pol << 23)); |
1538 |
|
1601 |
|
1539 |
if (!(info->flags & FBINFO_HWACCEL_DISABLED)) { |
1602 |
if (!(info->flags & FBINFO_HWACCEL_DISABLED)) { |
Lines 1542-1559
Link Here
|
1542 |
& ~(0x3f)) >> 6; |
1605 |
& ~(0x3f)) >> 6; |
1543 |
|
1606 |
|
1544 |
/* Then, re-multiply it to get the CRTC pitch */ |
1607 |
/* Then, re-multiply it to get the CRTC pitch */ |
1545 |
newmode.crtc_pitch = (rinfo->pitch << 3) / ((mode->bits_per_pixel + 1) / 8); |
1608 |
newmode->crtc_pitch = (rinfo->pitch << 3) / ((mode->bits_per_pixel + 1) / 8); |
1546 |
} else |
1609 |
} else |
1547 |
newmode.crtc_pitch = (mode->xres_virtual >> 3); |
1610 |
newmode->crtc_pitch = (mode->xres_virtual >> 3); |
1548 |
|
1611 |
|
1549 |
newmode.crtc_pitch |= (newmode.crtc_pitch << 16); |
1612 |
newmode->crtc_pitch |= (newmode->crtc_pitch << 16); |
1550 |
|
1613 |
|
1551 |
/* |
1614 |
/* |
1552 |
* It looks like recent chips have a problem with SURFACE_CNTL, |
1615 |
* It looks like recent chips have a problem with SURFACE_CNTL, |
1553 |
* setting SURF_TRANSLATION_DIS completely disables the |
1616 |
* setting SURF_TRANSLATION_DIS completely disables the |
1554 |
* swapper as well, so we leave it unset now. |
1617 |
* swapper as well, so we leave it unset now. |
1555 |
*/ |
1618 |
*/ |
1556 |
newmode.surface_cntl = 0; |
1619 |
newmode->surface_cntl = 0; |
1557 |
|
1620 |
|
1558 |
#if defined(__BIG_ENDIAN) |
1621 |
#if defined(__BIG_ENDIAN) |
1559 |
|
1622 |
|
Lines 1563-1590
Link Here
|
1563 |
*/ |
1626 |
*/ |
1564 |
switch (mode->bits_per_pixel) { |
1627 |
switch (mode->bits_per_pixel) { |
1565 |
case 16: |
1628 |
case 16: |
1566 |
newmode.surface_cntl |= NONSURF_AP0_SWP_16BPP; |
1629 |
newmode->surface_cntl |= NONSURF_AP0_SWP_16BPP; |
1567 |
newmode.surface_cntl |= NONSURF_AP1_SWP_16BPP; |
1630 |
newmode->surface_cntl |= NONSURF_AP1_SWP_16BPP; |
1568 |
break; |
1631 |
break; |
1569 |
case 24: |
1632 |
case 24: |
1570 |
case 32: |
1633 |
case 32: |
1571 |
newmode.surface_cntl |= NONSURF_AP0_SWP_32BPP; |
1634 |
newmode->surface_cntl |= NONSURF_AP0_SWP_32BPP; |
1572 |
newmode.surface_cntl |= NONSURF_AP1_SWP_32BPP; |
1635 |
newmode->surface_cntl |= NONSURF_AP1_SWP_32BPP; |
1573 |
break; |
1636 |
break; |
1574 |
} |
1637 |
} |
1575 |
#endif |
1638 |
#endif |
1576 |
|
1639 |
|
1577 |
/* Clear surface registers */ |
1640 |
/* Clear surface registers */ |
1578 |
for (i=0; i<8; i++) { |
1641 |
for (i=0; i<8; i++) { |
1579 |
newmode.surf_lower_bound[i] = 0; |
1642 |
newmode->surf_lower_bound[i] = 0; |
1580 |
newmode.surf_upper_bound[i] = 0x1f; |
1643 |
newmode->surf_upper_bound[i] = 0x1f; |
1581 |
newmode.surf_info[i] = 0; |
1644 |
newmode->surf_info[i] = 0; |
1582 |
} |
1645 |
} |
1583 |
|
1646 |
|
1584 |
RTRACE("h_total_disp = 0x%x\t hsync_strt_wid = 0x%x\n", |
1647 |
RTRACE("h_total_disp = 0x%x\t hsync_strt_wid = 0x%x\n", |
1585 |
newmode.crtc_h_total_disp, newmode.crtc_h_sync_strt_wid); |
1648 |
newmode->crtc_h_total_disp, newmode->crtc_h_sync_strt_wid); |
1586 |
RTRACE("v_total_disp = 0x%x\t vsync_strt_wid = 0x%x\n", |
1649 |
RTRACE("v_total_disp = 0x%x\t vsync_strt_wid = 0x%x\n", |
1587 |
newmode.crtc_v_total_disp, newmode.crtc_v_sync_strt_wid); |
1650 |
newmode->crtc_v_total_disp, newmode->crtc_v_sync_strt_wid); |
1588 |
|
1651 |
|
1589 |
rinfo->bpp = mode->bits_per_pixel; |
1652 |
rinfo->bpp = mode->bits_per_pixel; |
1590 |
rinfo->depth = depth; |
1653 |
rinfo->depth = depth; |
Lines 1592-1601
Link Here
|
1592 |
RTRACE("pixclock = %lu\n", (unsigned long)pixClock); |
1655 |
RTRACE("pixclock = %lu\n", (unsigned long)pixClock); |
1593 |
RTRACE("freq = %lu\n", (unsigned long)freq); |
1656 |
RTRACE("freq = %lu\n", (unsigned long)freq); |
1594 |
|
1657 |
|
|
|
1658 |
/* We use PPLL_DIV_3 */ |
1659 |
newmode->clk_cntl_index = 0x300; |
1660 |
|
1661 |
/* Calculate PPLL value if necessary */ |
1595 |
if (!nopllcalc) |
1662 |
if (!nopllcalc) |
1596 |
radeon_calc_pll_regs(rinfo, &newmode, freq); |
1663 |
radeon_calc_pll_regs(rinfo, newmode, freq); |
1597 |
|
1664 |
|
1598 |
newmode.vclk_ecp_cntl = rinfo->init_state.vclk_ecp_cntl; |
1665 |
newmode->vclk_ecp_cntl = rinfo->init_state.vclk_ecp_cntl; |
1599 |
|
1666 |
|
1600 |
if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { |
1667 |
if ((primary_mon == MT_DFP) || (primary_mon == MT_LCD)) { |
1601 |
unsigned int hRatio, vRatio; |
1668 |
unsigned int hRatio, vRatio; |
Lines 1605-1639
Link Here
|
1605 |
if (mode->yres > rinfo->panel_info.yres) |
1672 |
if (mode->yres > rinfo->panel_info.yres) |
1606 |
mode->yres = rinfo->panel_info.yres; |
1673 |
mode->yres = rinfo->panel_info.yres; |
1607 |
|
1674 |
|
1608 |
newmode.fp_horz_stretch = (((rinfo->panel_info.xres / 8) - 1) |
1675 |
newmode->fp_horz_stretch = (((rinfo->panel_info.xres / 8) - 1) |
1609 |
<< HORZ_PANEL_SHIFT); |
1676 |
<< HORZ_PANEL_SHIFT); |
1610 |
newmode.fp_vert_stretch = ((rinfo->panel_info.yres - 1) |
1677 |
newmode->fp_vert_stretch = ((rinfo->panel_info.yres - 1) |
1611 |
<< VERT_PANEL_SHIFT); |
1678 |
<< VERT_PANEL_SHIFT); |
1612 |
|
1679 |
|
1613 |
if (mode->xres != rinfo->panel_info.xres) { |
1680 |
if (mode->xres != rinfo->panel_info.xres) { |
1614 |
hRatio = round_div(mode->xres * HORZ_STRETCH_RATIO_MAX, |
1681 |
hRatio = round_div(mode->xres * HORZ_STRETCH_RATIO_MAX, |
1615 |
rinfo->panel_info.xres); |
1682 |
rinfo->panel_info.xres); |
1616 |
newmode.fp_horz_stretch = (((((unsigned long)hRatio) & HORZ_STRETCH_RATIO_MASK)) | |
1683 |
newmode->fp_horz_stretch = (((((unsigned long)hRatio) & HORZ_STRETCH_RATIO_MASK)) | |
1617 |
(newmode.fp_horz_stretch & |
1684 |
(newmode->fp_horz_stretch & |
1618 |
(HORZ_PANEL_SIZE | HORZ_FP_LOOP_STRETCH | |
1685 |
(HORZ_PANEL_SIZE | HORZ_FP_LOOP_STRETCH | |
1619 |
HORZ_AUTO_RATIO_INC))); |
1686 |
HORZ_AUTO_RATIO_INC))); |
1620 |
newmode.fp_horz_stretch |= (HORZ_STRETCH_BLEND | |
1687 |
newmode->fp_horz_stretch |= (HORZ_STRETCH_BLEND | |
1621 |
HORZ_STRETCH_ENABLE); |
1688 |
HORZ_STRETCH_ENABLE); |
|
|
1689 |
use_rmx = 1; |
1622 |
} |
1690 |
} |
1623 |
newmode.fp_horz_stretch &= ~HORZ_AUTO_RATIO; |
1691 |
newmode->fp_horz_stretch &= ~HORZ_AUTO_RATIO; |
1624 |
|
1692 |
|
1625 |
if (mode->yres != rinfo->panel_info.yres) { |
1693 |
if (mode->yres != rinfo->panel_info.yres) { |
1626 |
vRatio = round_div(mode->yres * VERT_STRETCH_RATIO_MAX, |
1694 |
vRatio = round_div(mode->yres * VERT_STRETCH_RATIO_MAX, |
1627 |
rinfo->panel_info.yres); |
1695 |
rinfo->panel_info.yres); |
1628 |
newmode.fp_vert_stretch = (((((unsigned long)vRatio) & VERT_STRETCH_RATIO_MASK)) | |
1696 |
newmode->fp_vert_stretch = (((((unsigned long)vRatio) & VERT_STRETCH_RATIO_MASK)) | |
1629 |
(newmode.fp_vert_stretch & |
1697 |
(newmode->fp_vert_stretch & |
1630 |
(VERT_PANEL_SIZE | VERT_STRETCH_RESERVED))); |
1698 |
(VERT_PANEL_SIZE | VERT_STRETCH_RESERVED))); |
1631 |
newmode.fp_vert_stretch |= (VERT_STRETCH_BLEND | |
1699 |
newmode->fp_vert_stretch |= (VERT_STRETCH_BLEND | |
1632 |
VERT_STRETCH_ENABLE); |
1700 |
VERT_STRETCH_ENABLE); |
|
|
1701 |
use_rmx = 1; |
1633 |
} |
1702 |
} |
1634 |
newmode.fp_vert_stretch &= ~VERT_AUTO_RATIO_EN; |
1703 |
newmode->fp_vert_stretch &= ~VERT_AUTO_RATIO_EN; |
1635 |
|
1704 |
|
1636 |
newmode.fp_gen_cntl = (rinfo->init_state.fp_gen_cntl & (u32) |
1705 |
newmode->fp_gen_cntl = (rinfo->init_state.fp_gen_cntl & (u32) |
1637 |
~(FP_SEL_CRTC2 | |
1706 |
~(FP_SEL_CRTC2 | |
1638 |
FP_RMX_HVSYNC_CONTROL_EN | |
1707 |
FP_RMX_HVSYNC_CONTROL_EN | |
1639 |
FP_DFP_SYNC_SEL | |
1708 |
FP_DFP_SYNC_SEL | |
Lines 1643-1688
Link Here
|
1643 |
FP_CRTC_USE_SHADOW_VEND | |
1712 |
FP_CRTC_USE_SHADOW_VEND | |
1644 |
FP_CRT_SYNC_ALT)); |
1713 |
FP_CRT_SYNC_ALT)); |
1645 |
|
1714 |
|
1646 |
newmode.fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR | |
1715 |
newmode->fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR | |
1647 |
FP_CRTC_DONT_SHADOW_HEND); |
1716 |
FP_CRTC_DONT_SHADOW_HEND | |
|
|
1717 |
FP_PANEL_FORMAT); |
1718 |
|
1719 |
if (IS_R300_VARIANT(rinfo) || |
1720 |
(rinfo->family == CHIP_FAMILY_R200)) { |
1721 |
newmode->fp_gen_cntl &= ~R200_FP_SOURCE_SEL_MASK; |
1722 |
if (use_rmx) |
1723 |
newmode->fp_gen_cntl |= R200_FP_SOURCE_SEL_RMX; |
1724 |
else |
1725 |
newmode->fp_gen_cntl |= R200_FP_SOURCE_SEL_CRTC1; |
1726 |
} else |
1727 |
newmode->fp_gen_cntl |= FP_SEL_CRTC1; |
1648 |
|
1728 |
|
1649 |
newmode.lvds_gen_cntl = rinfo->init_state.lvds_gen_cntl; |
1729 |
newmode->lvds_gen_cntl = rinfo->init_state.lvds_gen_cntl; |
1650 |
newmode.lvds_pll_cntl = rinfo->init_state.lvds_pll_cntl; |
1730 |
newmode->lvds_pll_cntl = rinfo->init_state.lvds_pll_cntl; |
1651 |
newmode.tmds_crc = rinfo->init_state.tmds_crc; |
1731 |
newmode->tmds_crc = rinfo->init_state.tmds_crc; |
1652 |
newmode.tmds_transmitter_cntl = rinfo->init_state.tmds_transmitter_cntl; |
1732 |
newmode->tmds_transmitter_cntl = rinfo->init_state.tmds_transmitter_cntl; |
1653 |
|
1733 |
|
1654 |
if (primary_mon == MT_LCD) { |
1734 |
if (primary_mon == MT_LCD) { |
1655 |
newmode.lvds_gen_cntl |= (LVDS_ON | LVDS_BLON); |
1735 |
newmode->lvds_gen_cntl |= (LVDS_ON | LVDS_BLON); |
1656 |
newmode.fp_gen_cntl &= ~(FP_FPON | FP_TMDS_EN); |
1736 |
newmode->fp_gen_cntl &= ~(FP_FPON | FP_TMDS_EN); |
1657 |
} else { |
1737 |
} else { |
1658 |
/* DFP */ |
1738 |
/* DFP */ |
1659 |
newmode.fp_gen_cntl |= (FP_FPON | FP_TMDS_EN); |
1739 |
newmode->fp_gen_cntl |= (FP_FPON | FP_TMDS_EN); |
1660 |
newmode.tmds_transmitter_cntl = (TMDS_RAN_PAT_RST | TMDS_ICHCSEL) & |
1740 |
newmode->tmds_transmitter_cntl = (TMDS_RAN_PAT_RST | TMDS_ICHCSEL) & |
1661 |
~(TMDS_PLLRST); |
1741 |
~(TMDS_PLLRST); |
1662 |
/* TMDS_PLL_EN bit is reversed on RV (and mobility) chips */ |
1742 |
/* TMDS_PLL_EN bit is reversed on RV (and mobility) chips */ |
1663 |
if ((rinfo->family == CHIP_FAMILY_R300) || |
1743 |
if (IS_R300_VARIANT(rinfo) || |
1664 |
(rinfo->family == CHIP_FAMILY_R350) || |
|
|
1665 |
(rinfo->family == CHIP_FAMILY_RV350) || |
1666 |
(rinfo->family == CHIP_FAMILY_R200) || !rinfo->has_CRTC2) |
1744 |
(rinfo->family == CHIP_FAMILY_R200) || !rinfo->has_CRTC2) |
1667 |
newmode.tmds_transmitter_cntl &= ~TMDS_PLL_EN; |
1745 |
newmode->tmds_transmitter_cntl &= ~TMDS_PLL_EN; |
1668 |
else |
1746 |
else |
1669 |
newmode.tmds_transmitter_cntl |= TMDS_PLL_EN; |
1747 |
newmode->tmds_transmitter_cntl |= TMDS_PLL_EN; |
1670 |
newmode.crtc_ext_cntl &= ~CRTC_CRT_ON; |
1748 |
newmode->crtc_ext_cntl &= ~CRTC_CRT_ON; |
1671 |
} |
1749 |
} |
1672 |
|
1750 |
|
1673 |
newmode.fp_crtc_h_total_disp = (((rinfo->panel_info.hblank / 8) & 0x3ff) | |
1751 |
newmode->fp_crtc_h_total_disp = (((rinfo->panel_info.hblank / 8) & 0x3ff) | |
1674 |
(((mode->xres / 8) - 1) << 16)); |
1752 |
(((mode->xres / 8) - 1) << 16)); |
1675 |
newmode.fp_crtc_v_total_disp = (rinfo->panel_info.vblank & 0xffff) | |
1753 |
newmode->fp_crtc_v_total_disp = (rinfo->panel_info.vblank & 0xffff) | |
1676 |
((mode->yres - 1) << 16); |
1754 |
((mode->yres - 1) << 16); |
1677 |
newmode.fp_h_sync_strt_wid = ((rinfo->panel_info.hOver_plus & 0x1fff) | |
1755 |
newmode->fp_h_sync_strt_wid = ((rinfo->panel_info.hOver_plus & 0x1fff) | |
1678 |
(hsync_wid << 16) | (h_sync_pol << 23)); |
1756 |
(hsync_wid << 16) | (h_sync_pol << 23)); |
1679 |
newmode.fp_v_sync_strt_wid = ((rinfo->panel_info.vOver_plus & 0xfff) | |
1757 |
newmode->fp_v_sync_strt_wid = ((rinfo->panel_info.vOver_plus & 0xfff) | |
1680 |
(vsync_wid << 16) | (v_sync_pol << 23)); |
1758 |
(vsync_wid << 16) | (v_sync_pol << 23)); |
1681 |
} |
1759 |
} |
1682 |
|
1760 |
|
1683 |
/* do it! */ |
1761 |
/* do it! */ |
1684 |
if (!rinfo->asleep) { |
1762 |
if (!rinfo->asleep) { |
1685 |
radeon_write_mode (rinfo, &newmode); |
1763 |
memcpy(&rinfo->state, newmode, sizeof(*newmode)); |
|
|
1764 |
radeon_write_mode (rinfo, newmode, 0); |
1686 |
/* (re)initialize the engine */ |
1765 |
/* (re)initialize the engine */ |
1687 |
if (!(info->flags & FBINFO_HWACCEL_DISABLED)) |
1766 |
if (!(info->flags & FBINFO_HWACCEL_DISABLED)) |
1688 |
radeonfb_engine_init (rinfo); |
1767 |
radeonfb_engine_init (rinfo); |
Lines 1702-1707
Link Here
|
1702 |
rinfo->depth, info->fix.line_length); |
1781 |
rinfo->depth, info->fix.line_length); |
1703 |
#endif |
1782 |
#endif |
1704 |
|
1783 |
|
|
|
1784 |
kfree(newmode); |
1705 |
return 0; |
1785 |
return 0; |
1706 |
} |
1786 |
} |
1707 |
|
1787 |
|
Lines 1812-1823
Link Here
|
1812 |
if (on && (level > BACKLIGHT_OFF)) { |
1892 |
if (on && (level > BACKLIGHT_OFF)) { |
1813 |
lvds_gen_cntl &= ~LVDS_DISPLAY_DIS; |
1893 |
lvds_gen_cntl &= ~LVDS_DISPLAY_DIS; |
1814 |
if (!(lvds_gen_cntl & LVDS_BLON) || !(lvds_gen_cntl & LVDS_ON)) { |
1894 |
if (!(lvds_gen_cntl & LVDS_BLON) || !(lvds_gen_cntl & LVDS_ON)) { |
1815 |
lvds_gen_cntl |= LVDS_BLON /* | LVDS_EN | LVDS_DIGON */; |
1895 |
lvds_gen_cntl |= (rinfo->init_state.lvds_gen_cntl & LVDS_DIGON); |
|
|
1896 |
lvds_gen_cntl |= LVDS_BLON | LVDS_EN; |
1816 |
OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); |
1897 |
OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); |
1817 |
lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; |
1898 |
lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; |
1818 |
lvds_gen_cntl |= (conv_table[level] << |
1899 |
lvds_gen_cntl |= (conv_table[level] << |
1819 |
LVDS_BL_MOD_LEVEL_SHIFT); |
1900 |
LVDS_BL_MOD_LEVEL_SHIFT); |
1820 |
lvds_gen_cntl |= LVDS_ON; |
1901 |
lvds_gen_cntl |= LVDS_ON; |
|
|
1902 |
lvds_gen_cntl |= (rinfo->init_state.lvds_gen_cntl & LVDS_BL_MOD_EN); |
1821 |
rinfo->pending_lvds_gen_cntl = lvds_gen_cntl; |
1903 |
rinfo->pending_lvds_gen_cntl = lvds_gen_cntl; |
1822 |
mod_timer(&rinfo->lvds_timer, |
1904 |
mod_timer(&rinfo->lvds_timer, |
1823 |
jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay)); |
1905 |
jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay)); |
Lines 1837-1849
Link Here
|
1837 |
tmpPixclksCntl = INPLL(PIXCLKS_CNTL); |
1919 |
tmpPixclksCntl = INPLL(PIXCLKS_CNTL); |
1838 |
if (rinfo->is_mobility || rinfo->is_IGP) |
1920 |
if (rinfo->is_mobility || rinfo->is_IGP) |
1839 |
OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb); |
1921 |
OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb); |
1840 |
lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; |
1922 |
lvds_gen_cntl &= ~(LVDS_BL_MOD_LEVEL_MASK | LVDS_BL_MOD_EN); |
1841 |
lvds_gen_cntl |= (conv_table[0] << |
1923 |
lvds_gen_cntl |= (conv_table[0] << |
1842 |
LVDS_BL_MOD_LEVEL_SHIFT); |
1924 |
LVDS_BL_MOD_LEVEL_SHIFT); |
1843 |
lvds_gen_cntl |= LVDS_DISPLAY_DIS; |
1925 |
lvds_gen_cntl |= LVDS_DISPLAY_DIS; |
1844 |
OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); |
1926 |
OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); |
1845 |
lvds_gen_cntl &= ~(LVDS_ON | LVDS_BLON /* | LVDS_EN | LVDS_DIGON */); |
1927 |
udelay(100); |
|
|
1928 |
lvds_gen_cntl &= ~(LVDS_ON | LVDS_EN); |
1846 |
OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); |
1929 |
OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); |
|
|
1930 |
lvds_gen_cntl &= ~(LVDS_DIGON); |
1931 |
rinfo->pending_lvds_gen_cntl = lvds_gen_cntl; |
1932 |
mod_timer(&rinfo->lvds_timer, |
1933 |
jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay)); |
1847 |
if (rinfo->is_mobility || rinfo->is_IGP) |
1934 |
if (rinfo->is_mobility || rinfo->is_IGP) |
1848 |
OUTPLL(PIXCLKS_CNTL, tmpPixclksCntl); |
1935 |
OUTPLL(PIXCLKS_CNTL, tmpPixclksCntl); |
1849 |
} |
1936 |
} |
Lines 1873-1879
Link Here
|
1873 |
* local (0xe0000000 for now) that will be changed by XFree/DRI anyway |
1960 |
* local (0xe0000000 for now) that will be changed by XFree/DRI anyway |
1874 |
*/ |
1961 |
*/ |
1875 |
#ifdef CONFIG_PPC_OF |
1962 |
#ifdef CONFIG_PPC_OF |
1876 |
#undef SET_MC_FB_FROM_APERTURE |
1963 |
#define SET_MC_FB_FROM_APERTURE |
1877 |
static void fixup_memory_mappings(struct radeonfb_info *rinfo) |
1964 |
static void fixup_memory_mappings(struct radeonfb_info *rinfo) |
1878 |
{ |
1965 |
{ |
1879 |
u32 save_crtc_gen_cntl, save_crtc2_gen_cntl = 0; |
1966 |
u32 save_crtc_gen_cntl, save_crtc2_gen_cntl = 0; |
Lines 1926-1935
Link Here
|
1926 |
OUTREG(DISPLAY_BASE_ADDR, aper_base); |
2013 |
OUTREG(DISPLAY_BASE_ADDR, aper_base); |
1927 |
if (rinfo->has_CRTC2) |
2014 |
if (rinfo->has_CRTC2) |
1928 |
OUTREG(CRTC2_DISPLAY_BASE_ADDR, aper_base); |
2015 |
OUTREG(CRTC2_DISPLAY_BASE_ADDR, aper_base); |
|
|
2016 |
OUTREG(OV0_BASE_ADDR, aper_base); |
1929 |
#else |
2017 |
#else |
1930 |
OUTREG(DISPLAY_BASE_ADDR, 0); |
2018 |
OUTREG(DISPLAY_BASE_ADDR, 0); |
1931 |
if (rinfo->has_CRTC2) |
2019 |
if (rinfo->has_CRTC2) |
1932 |
OUTREG(CRTC2_DISPLAY_BASE_ADDR, 0); |
2020 |
OUTREG(CRTC2_DISPLAY_BASE_ADDR, 0); |
|
|
2021 |
OUTREG(OV0_BASE_ADDR, 0); |
1933 |
#endif |
2022 |
#endif |
1934 |
mdelay(100); |
2023 |
mdelay(100); |
1935 |
|
2024 |
|
Lines 1947-1952
Link Here
|
1947 |
#endif /* CONFIG_PPC_OF */ |
2036 |
#endif /* CONFIG_PPC_OF */ |
1948 |
|
2037 |
|
1949 |
|
2038 |
|
|
|
2039 |
static void radeon_identify_vram(struct radeonfb_info *rinfo) |
2040 |
{ |
2041 |
u32 tmp; |
2042 |
|
2043 |
/* framebuffer size */ |
2044 |
if ((rinfo->family == CHIP_FAMILY_RS100) || |
2045 |
(rinfo->family == CHIP_FAMILY_RS200) || |
2046 |
(rinfo->family == CHIP_FAMILY_RS300)) { |
2047 |
u32 tom = INREG(NB_TOM); |
2048 |
tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024); |
2049 |
|
2050 |
radeon_fifo_wait(6); |
2051 |
OUTREG(MC_FB_LOCATION, tom); |
2052 |
OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); |
2053 |
OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); |
2054 |
OUTREG(OV0_BASE_ADDR, (tom & 0xffff) << 16); |
2055 |
|
2056 |
/* This is supposed to fix the crtc2 noise problem. */ |
2057 |
OUTREG(GRPH2_BUFFER_CNTL, INREG(GRPH2_BUFFER_CNTL) & ~0x7f0000); |
2058 |
|
2059 |
if ((rinfo->family == CHIP_FAMILY_RS100) || |
2060 |
(rinfo->family == CHIP_FAMILY_RS200)) { |
2061 |
/* This is to workaround the asic bug for RMX, some versions |
2062 |
of BIOS dosen't have this register initialized correctly. |
2063 |
*/ |
2064 |
OUTREGP(CRTC_MORE_CNTL, CRTC_H_CUTOFF_ACTIVE_EN, |
2065 |
~CRTC_H_CUTOFF_ACTIVE_EN); |
2066 |
} |
2067 |
} else { |
2068 |
tmp = INREG(CONFIG_MEMSIZE); |
2069 |
} |
2070 |
|
2071 |
/* mem size is bits [28:0], mask off the rest */ |
2072 |
rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK; |
2073 |
|
2074 |
/* |
2075 |
* Hack to get around some busted production M6's |
2076 |
* reporting no ram |
2077 |
*/ |
2078 |
if (rinfo->video_ram == 0) { |
2079 |
switch (rinfo->pdev->device) { |
2080 |
case PCI_CHIP_RADEON_LY: |
2081 |
case PCI_CHIP_RADEON_LZ: |
2082 |
rinfo->video_ram = 8192 * 1024; |
2083 |
break; |
2084 |
default: |
2085 |
break; |
2086 |
} |
2087 |
} |
2088 |
|
2089 |
|
2090 |
/* |
2091 |
* Now try to identify VRAM type |
2092 |
*/ |
2093 |
if (rinfo->is_IGP || (rinfo->family >= CHIP_FAMILY_R300) || |
2094 |
(INREG(MEM_SDRAM_MODE_REG) & (1<<30))) |
2095 |
rinfo->vram_ddr = 1; |
2096 |
else |
2097 |
rinfo->vram_ddr = 0; |
2098 |
|
2099 |
tmp = INREG(MEM_CNTL); |
2100 |
if (IS_R300_VARIANT(rinfo)) { |
2101 |
tmp &= R300_MEM_NUM_CHANNELS_MASK; |
2102 |
switch (tmp) { |
2103 |
case 0: rinfo->vram_width = 64; break; |
2104 |
case 1: rinfo->vram_width = 128; break; |
2105 |
case 2: rinfo->vram_width = 256; break; |
2106 |
default: rinfo->vram_width = 128; break; |
2107 |
} |
2108 |
} else if ((rinfo->family == CHIP_FAMILY_RV100) || |
2109 |
(rinfo->family == CHIP_FAMILY_RS100) || |
2110 |
(rinfo->family == CHIP_FAMILY_RS200)){ |
2111 |
if (tmp & RV100_MEM_HALF_MODE) |
2112 |
rinfo->vram_width = 32; |
2113 |
else |
2114 |
rinfo->vram_width = 64; |
2115 |
} else { |
2116 |
if (tmp & MEM_NUM_CHANNELS_MASK) |
2117 |
rinfo->vram_width = 128; |
2118 |
else |
2119 |
rinfo->vram_width = 64; |
2120 |
} |
2121 |
|
2122 |
/* This may not be correct, as some cards can have half of channel disabled |
2123 |
* ToDo: identify these cases |
2124 |
*/ |
2125 |
|
2126 |
RTRACE("radeonfb (%s): Found %ldk of %s %d bits wide videoram\n", |
2127 |
pci_name(rinfo->pdev), |
2128 |
rinfo->video_ram / 1024, |
2129 |
rinfo->vram_ddr ? "DDR" : "SDRAM", |
2130 |
rinfo->vram_width); |
2131 |
} |
2132 |
|
1950 |
/* |
2133 |
/* |
1951 |
* Sysfs |
2134 |
* Sysfs |
1952 |
*/ |
2135 |
*/ |
Lines 2012-2018
Link Here
|
2012 |
{ |
2195 |
{ |
2013 |
struct fb_info *info; |
2196 |
struct fb_info *info; |
2014 |
struct radeonfb_info *rinfo; |
2197 |
struct radeonfb_info *rinfo; |
2015 |
u32 tmp; |
|
|
2016 |
int ret; |
2198 |
int ret; |
2017 |
|
2199 |
|
2018 |
RTRACE("radeonfb_pci_register BEGIN\n"); |
2200 |
RTRACE("radeonfb_pci_register BEGIN\n"); |
Lines 2020-2032
Link Here
|
2020 |
/* Enable device in PCI config */ |
2202 |
/* Enable device in PCI config */ |
2021 |
ret = pci_enable_device(pdev); |
2203 |
ret = pci_enable_device(pdev); |
2022 |
if (ret < 0) { |
2204 |
if (ret < 0) { |
2023 |
printk(KERN_ERR "radeonfb: Cannot enable PCI device\n"); |
2205 |
printk(KERN_ERR "radeonfb (%s): Cannot enable PCI device\n", |
|
|
2206 |
pci_name(pdev)); |
2024 |
goto err_out; |
2207 |
goto err_out; |
2025 |
} |
2208 |
} |
2026 |
|
2209 |
|
2027 |
info = framebuffer_alloc(sizeof(struct radeonfb_info), &pdev->dev); |
2210 |
info = framebuffer_alloc(sizeof(struct radeonfb_info), &pdev->dev); |
2028 |
if (!info) { |
2211 |
if (!info) { |
2029 |
printk (KERN_ERR "radeonfb: could not allocate memory\n"); |
2212 |
printk (KERN_ERR "radeonfb (%s): could not allocate memory\n", |
|
|
2213 |
pci_name(pdev)); |
2030 |
ret = -ENOMEM; |
2214 |
ret = -ENOMEM; |
2031 |
goto err_disable; |
2215 |
goto err_disable; |
2032 |
} |
2216 |
} |
Lines 2055-2175
Link Here
|
2055 |
/* request the mem regions */ |
2239 |
/* request the mem regions */ |
2056 |
ret = pci_request_regions(pdev, "radeonfb"); |
2240 |
ret = pci_request_regions(pdev, "radeonfb"); |
2057 |
if (ret < 0) { |
2241 |
if (ret < 0) { |
2058 |
printk( KERN_ERR "radeonfb: cannot reserve PCI regions." |
2242 |
printk( KERN_ERR "radeonfb (%s): cannot reserve PCI regions." |
2059 |
" Someone already got them?\n"); |
2243 |
" Someone already got them?\n", pci_name(rinfo->pdev)); |
2060 |
goto err_release_fb; |
2244 |
goto err_release_fb; |
2061 |
} |
2245 |
} |
2062 |
|
2246 |
|
2063 |
/* map the regions */ |
2247 |
/* map the regions */ |
2064 |
rinfo->mmio_base = ioremap(rinfo->mmio_base_phys, RADEON_REGSIZE); |
2248 |
rinfo->mmio_base = ioremap(rinfo->mmio_base_phys, RADEON_REGSIZE); |
2065 |
if (!rinfo->mmio_base) { |
2249 |
if (!rinfo->mmio_base) { |
2066 |
printk(KERN_ERR "radeonfb: cannot map MMIO\n"); |
2250 |
printk(KERN_ERR "radeonfb (%s): cannot map MMIO\n", pci_name(rinfo->pdev)); |
2067 |
ret = -EIO; |
2251 |
ret = -EIO; |
2068 |
goto err_release_pci; |
2252 |
goto err_release_pci; |
2069 |
} |
2253 |
} |
2070 |
|
2254 |
|
|
|
2255 |
rinfo->fb_local_base = INREG(MC_FB_LOCATION) << 16; |
2256 |
|
2257 |
#ifdef CONFIG_PPC_OF |
2258 |
/* On PPC, we obtain the OF device-node pointer to the firmware |
2259 |
* data for this chip |
2260 |
*/ |
2261 |
rinfo->of_node = pci_device_to_OF_node(pdev); |
2262 |
if (rinfo->of_node == NULL) |
2263 |
printk(KERN_WARNING "radeonfb (%s): Cannot match card to OF node !\n", |
2264 |
pci_name(rinfo->pdev)); |
2265 |
|
2071 |
/* On PPC, the firmware sets up a memory mapping that tends |
2266 |
/* On PPC, the firmware sets up a memory mapping that tends |
2072 |
* to cause lockups when enabling the engine. We reconfigure |
2267 |
* to cause lockups when enabling the engine. We reconfigure |
2073 |
* the card internal memory mappings properly |
2268 |
* the card internal memory mappings properly |
2074 |
*/ |
2269 |
*/ |
2075 |
#ifdef CONFIG_PPC_OF |
|
|
2076 |
fixup_memory_mappings(rinfo); |
2270 |
fixup_memory_mappings(rinfo); |
2077 |
#else |
|
|
2078 |
rinfo->fb_local_base = INREG(MC_FB_LOCATION) << 16; |
2079 |
#endif /* CONFIG_PPC_OF */ |
2271 |
#endif /* CONFIG_PPC_OF */ |
2080 |
|
2272 |
|
2081 |
/* framebuffer size */ |
2273 |
/* Get VRAM size and type */ |
2082 |
if ((rinfo->family == CHIP_FAMILY_RS100) || |
2274 |
radeon_identify_vram(rinfo); |
2083 |
(rinfo->family == CHIP_FAMILY_RS200) || |
|
|
2084 |
(rinfo->family == CHIP_FAMILY_RS300)) { |
2085 |
u32 tom = INREG(NB_TOM); |
2086 |
tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024); |
2087 |
|
2088 |
radeon_fifo_wait(6); |
2089 |
OUTREG(MC_FB_LOCATION, tom); |
2090 |
OUTREG(DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); |
2091 |
OUTREG(CRTC2_DISPLAY_BASE_ADDR, (tom & 0xffff) << 16); |
2092 |
OUTREG(OV0_BASE_ADDR, (tom & 0xffff) << 16); |
2093 |
|
2094 |
/* This is supposed to fix the crtc2 noise problem. */ |
2095 |
OUTREG(GRPH2_BUFFER_CNTL, INREG(GRPH2_BUFFER_CNTL) & ~0x7f0000); |
2096 |
|
2097 |
if ((rinfo->family == CHIP_FAMILY_RS100) || |
2098 |
(rinfo->family == CHIP_FAMILY_RS200)) { |
2099 |
/* This is to workaround the asic bug for RMX, some versions |
2100 |
of BIOS dosen't have this register initialized correctly. |
2101 |
*/ |
2102 |
OUTREGP(CRTC_MORE_CNTL, CRTC_H_CUTOFF_ACTIVE_EN, |
2103 |
~CRTC_H_CUTOFF_ACTIVE_EN); |
2104 |
} |
2105 |
} else { |
2106 |
tmp = INREG(CONFIG_MEMSIZE); |
2107 |
} |
2108 |
|
2109 |
/* mem size is bits [28:0], mask off the rest */ |
2110 |
rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK; |
2111 |
|
2112 |
/* ram type */ |
2113 |
tmp = INREG(MEM_SDRAM_MODE_REG); |
2114 |
switch ((MEM_CFG_TYPE & tmp) >> 30) { |
2115 |
case 0: |
2116 |
/* SDR SGRAM (2:1) */ |
2117 |
strcpy(rinfo->ram_type, "SDR SGRAM"); |
2118 |
rinfo->ram.ml = 4; |
2119 |
rinfo->ram.mb = 4; |
2120 |
rinfo->ram.trcd = 1; |
2121 |
rinfo->ram.trp = 2; |
2122 |
rinfo->ram.twr = 1; |
2123 |
rinfo->ram.cl = 2; |
2124 |
rinfo->ram.loop_latency = 16; |
2125 |
rinfo->ram.rloop = 16; |
2126 |
break; |
2127 |
case 1: |
2128 |
/* DDR SGRAM */ |
2129 |
strcpy(rinfo->ram_type, "DDR SGRAM"); |
2130 |
rinfo->ram.ml = 4; |
2131 |
rinfo->ram.mb = 4; |
2132 |
rinfo->ram.trcd = 3; |
2133 |
rinfo->ram.trp = 3; |
2134 |
rinfo->ram.twr = 2; |
2135 |
rinfo->ram.cl = 3; |
2136 |
rinfo->ram.tr2w = 1; |
2137 |
rinfo->ram.loop_latency = 16; |
2138 |
rinfo->ram.rloop = 16; |
2139 |
break; |
2140 |
default: |
2141 |
/* 64-bit SDR SGRAM */ |
2142 |
strcpy(rinfo->ram_type, "SDR SGRAM 64"); |
2143 |
rinfo->ram.ml = 4; |
2144 |
rinfo->ram.mb = 8; |
2145 |
rinfo->ram.trcd = 3; |
2146 |
rinfo->ram.trp = 3; |
2147 |
rinfo->ram.twr = 1; |
2148 |
rinfo->ram.cl = 3; |
2149 |
rinfo->ram.tr2w = 1; |
2150 |
rinfo->ram.loop_latency = 17; |
2151 |
rinfo->ram.rloop = 17; |
2152 |
break; |
2153 |
} |
2154 |
|
2155 |
/* |
2156 |
* Hack to get around some busted production M6's |
2157 |
* reporting no ram |
2158 |
*/ |
2159 |
if (rinfo->video_ram == 0) { |
2160 |
switch (pdev->device) { |
2161 |
case PCI_CHIP_RADEON_LY: |
2162 |
case PCI_CHIP_RADEON_LZ: |
2163 |
rinfo->video_ram = 8192 * 1024; |
2164 |
break; |
2165 |
default: |
2166 |
printk (KERN_ERR "radeonfb: no video RAM reported\n"); |
2167 |
ret = -ENXIO; |
2168 |
goto err_unmap_rom; |
2169 |
} |
2170 |
} |
2171 |
|
2172 |
RTRACE("radeonfb: probed %s %ldk videoram\n", (rinfo->ram_type), (rinfo->video_ram/1024)); |
2173 |
|
2275 |
|
2174 |
rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM, rinfo->video_ram); |
2276 |
rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM, rinfo->video_ram); |
2175 |
|
2277 |
|
Lines 2182-2193
Link Here
|
2182 |
if (rinfo->fb_base) |
2284 |
if (rinfo->fb_base) |
2183 |
memset_io(rinfo->fb_base, 0, rinfo->mapped_vram); |
2285 |
memset_io(rinfo->fb_base, 0, rinfo->mapped_vram); |
2184 |
else { |
2286 |
else { |
2185 |
printk (KERN_ERR "radeonfb: cannot map FB\n"); |
2287 |
printk (KERN_ERR "radeonfb (%s): cannot map FB\n", pci_name(rinfo->pdev)); |
2186 |
ret = -EIO; |
2288 |
ret = -EIO; |
2187 |
goto err_unmap_rom; |
2289 |
goto err_unmap_rom; |
2188 |
} |
2290 |
} |
2189 |
|
2291 |
|
2190 |
RTRACE("radeonfb: mapped %ldk videoram\n", rinfo->mapped_vram/1024); |
2292 |
RTRACE("radeonfb (%s): mapped %ldk videoram\n", pci_name(rinfo->pdev), |
|
|
2293 |
rinfo->mapped_vram/1024); |
2191 |
|
2294 |
|
2192 |
/* |
2295 |
/* |
2193 |
* Check for required workaround for PLL accesses |
2296 |
* Check for required workaround for PLL accesses |
Lines 2254-2274
Link Here
|
2254 |
* so we can restore this upon __exit |
2357 |
* so we can restore this upon __exit |
2255 |
*/ |
2358 |
*/ |
2256 |
radeon_save_state (rinfo, &rinfo->init_state); |
2359 |
radeon_save_state (rinfo, &rinfo->init_state); |
|
|
2360 |
memcpy(&rinfo->state, &rinfo->init_state, sizeof(struct radeon_regs)); |
2257 |
|
2361 |
|
2258 |
pci_set_drvdata(pdev, info); |
2362 |
pci_set_drvdata(pdev, info); |
2259 |
|
2363 |
|
2260 |
/* Enable PM on mobility chips */ |
2364 |
/* Setup Power Management capabilities */ |
2261 |
if (rinfo->is_mobility) { |
2365 |
if (default_dynclk < -1) { |
2262 |
/* Find PM registers in config space */ |
2366 |
/* -2 is special: means ON on mobility chips and do not change on others */ |
2263 |
rinfo->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM); |
2367 |
radeonfb_pm_init(rinfo, rinfo->is_mobility ? 1 : -1); |
2264 |
/* Enable dynamic PM of chip clocks */ |
2368 |
} else |
2265 |
radeon_pm_enable_dynamic_mode(rinfo); |
2369 |
radeonfb_pm_init(rinfo, default_dynclk); |
2266 |
printk("radeonfb: Power Management enabled for Mobility chipsets\n"); |
|
|
2267 |
} |
2268 |
|
2370 |
|
|
|
2371 |
/* Register with fbdev layer */ |
2269 |
ret = register_framebuffer(info); |
2372 |
ret = register_framebuffer(info); |
2270 |
if (ret < 0) { |
2373 |
if (ret < 0) { |
2271 |
printk (KERN_ERR "radeonfb: could not register framebuffer\n"); |
2374 |
printk (KERN_ERR "radeonfb (%s): could not register framebuffer\n", |
|
|
2375 |
pci_name(rinfo->pdev)); |
2272 |
goto err_unmap_fb; |
2376 |
goto err_unmap_fb; |
2273 |
} |
2377 |
} |
2274 |
|
2378 |
|
Lines 2287-2294
Link Here
|
2287 |
} |
2391 |
} |
2288 |
#endif |
2392 |
#endif |
2289 |
|
2393 |
|
2290 |
printk ("radeonfb: %s %s %ld MB\n", rinfo->name, rinfo->ram_type, |
2394 |
printk ("radeonfb (%s): %s\n", pci_name(rinfo->pdev), rinfo->name); |
2291 |
(rinfo->video_ram/(1024*1024))); |
|
|
2292 |
|
2395 |
|
2293 |
if (rinfo->bios_seg) |
2396 |
if (rinfo->bios_seg) |
2294 |
radeon_unmap_ROM(rinfo, pdev); |
2397 |
radeon_unmap_ROM(rinfo, pdev); |
Lines 2331-2342
Link Here
|
2331 |
if (!rinfo) |
2434 |
if (!rinfo) |
2332 |
return; |
2435 |
return; |
2333 |
|
2436 |
|
|
|
2437 |
radeonfb_pm_exit(rinfo); |
2438 |
|
2334 |
/* restore original state |
2439 |
/* restore original state |
2335 |
* |
2440 |
* |
2336 |
* Doesn't quite work yet, possibly because of the PPC hacking |
2441 |
* Doesn't quite work yet, possibly because of the PPC hacking |
2337 |
* I do on startup, disable for now. --BenH |
2442 |
* I do on startup, disable for now. --BenH |
2338 |
*/ |
2443 |
*/ |
2339 |
radeon_write_mode (rinfo, &rinfo->init_state); |
2444 |
radeon_write_mode (rinfo, &rinfo->init_state, 1); |
2340 |
|
2445 |
|
2341 |
del_timer_sync(&rinfo->lvds_timer); |
2446 |
del_timer_sync(&rinfo->lvds_timer); |
2342 |
|
2447 |
|
Lines 2443-2448
Link Here
|
2443 |
MODULE_DESCRIPTION("framebuffer driver for ATI Radeon chipset"); |
2548 |
MODULE_DESCRIPTION("framebuffer driver for ATI Radeon chipset"); |
2444 |
MODULE_LICENSE("GPL"); |
2549 |
MODULE_LICENSE("GPL"); |
2445 |
module_param(noaccel, bool, 0); |
2550 |
module_param(noaccel, bool, 0); |
|
|
2551 |
module_param(default_dynclk, int, -2); |
2552 |
MODULE_PARM_DESC(default_dynclk, "int: -2=enable on mobility only,-1=do not change,0=off,1=on"); |
2446 |
MODULE_PARM_DESC(noaccel, "bool: disable acceleration"); |
2553 |
MODULE_PARM_DESC(noaccel, "bool: disable acceleration"); |
2447 |
module_param(nomodeset, bool, 0); |
2554 |
module_param(nomodeset, bool, 0); |
2448 |
MODULE_PARM_DESC(nomodeset, "bool: disable actual setting of video mode"); |
2555 |
MODULE_PARM_DESC(nomodeset, "bool: disable actual setting of video mode"); |