16 #define REF_FREQ_2595 1432
17 #define REF_DIV_2595 46
19 #define MAX_FREQ_2595 15938
20 #define MIN_FREQ_2595 8000
22 #define ABS_MIN_FREQ_2595 1000
23 #define N_ADJ_2595 257
25 #define STOP_BITS_2595 0x1800
42 static void aty_dac_waste4(
const struct atyfb_par *par)
52 static void aty_StrobeClock(
const struct atyfb_par *par)
79 static int aty_set_dac_514(
const struct fb_info *
info,
91 0, 0x41, 0x03, 0x71, 0x45},
93 0, 0x45, 0x04, 0x0c, 0x01},
95 0, 0x45, 0x06, 0x0e, 0x00},
111 aty_st_514(0x90, 0x00, par);
112 aty_st_514(0x04, tab[i].pixel_dly, par);
113 aty_st_514(0x05, 0x00, par);
114 aty_st_514(0x02, 0x01, par);
115 aty_st_514(0x71, tab[i].misc2_cntl, par);
116 aty_st_514(0x0a, tab[i].pixel_rep, par);
117 aty_st_514(tab[i].pixel_cntl_index, tab[i].pixel_cntl_v1, par);
122 static int aty_var_to_pll_514(
const struct fb_info *
info,
u32 vclk_per,
133 } RGB514_clocks[7] = {
135 8000, (3 << 6) | 20, 9},
137 10000, (1 << 6) | 19, 3},
139 13000, (1 << 6) | 2, 3},
141 14000, (2 << 6) | 8, 7},
143 16000, (1 << 6) | 44, 6},
145 25000, (1 << 6) | 15, 5},
147 50000, (0 << 6) | 53, 7},
151 for (i = 0; i <
ARRAY_SIZE(RGB514_clocks); i++)
152 if (vclk_per <= RGB514_clocks[i].
limit) {
153 pll->
ibm514.m = RGB514_clocks[
i].m;
154 pll->
ibm514.n = RGB514_clocks[
i].n;
160 static u32 aty_pll_514_to_var(
const struct fb_info *info,
164 u8 df, vco_div_count, ref_div_count;
167 vco_div_count = pll->
ibm514.m & 0x3f;
168 ref_div_count = pll->
ibm514.n;
171 (vco_div_count + 65);
174 static void aty_set_pll_514(
const struct fb_info *info,
179 aty_st_514(0x06, 0x02, par);
180 aty_st_514(0x10, 0x01, par);
181 aty_st_514(0x70, 0x01, par);
182 aty_st_514(0x8f, 0x1f, par);
183 aty_st_514(0x03, 0x00, par);
184 aty_st_514(0x05, 0x00, par);
185 aty_st_514(0x20, pll->
ibm514.m, par);
186 aty_st_514(0x21, pll->
ibm514.n, par);
190 .set_dac = aty_set_dac_514,
194 .var_to_pll = aty_var_to_pll_514,
195 .pll_to_var = aty_pll_514_to_var,
196 .set_pll = aty_set_pll_514,
204 static int aty_set_dac_ATI68860_B(
const struct fb_info *info,
264 #define A860_DELAY_L 0x80
279 .set_dac = aty_set_dac_ATI68860_B,
287 static int aty_set_dac_ATT21C498(
const struct fb_info *info,
296 dotClock = 100000000 / pll->
ics2595.period_in_ps;
300 if (dotClock > 8000) {
332 .set_dac = aty_set_dac_ATT21C498,
340 static int aty_var_to_pll_18818(
const struct fb_info *info,
u32 vclk_per,
348 MHz100 = 100000000 / vclk_per;
371 if (program_bits == -1) {
373 switch (post_divider) {
375 program_bits |= 0x0600;
378 program_bits |= 0x0400;
381 program_bits |= 0x0200;
391 pll->
ics2595.program_bits = program_bits;
393 pll->
ics2595.post_divider = post_divider;
394 pll->
ics2595.period_in_ps = vclk_per;
399 static u32 aty_pll_18818_to_var(
const struct fb_info *info,
402 return (pll->
ics2595.period_in_ps);
412 (tmp & ~0x04) | (data << 2), par);
418 aty_StrobeClock(par);
424 aty_StrobeClock(par);
428 static void aty_set_pll18818(
const struct fb_info *info,
438 u8 old_crtc_ext_disp;
449 program_bits = pll->
ics2595.program_bits;
450 locationAddr = pll->
ics2595.locationAddr;
454 aty_StrobeClock(par);
456 aty_StrobeClock(par);
458 aty_ICS2595_put1bit(1, par);
459 aty_ICS2595_put1bit(0, par);
460 aty_ICS2595_put1bit(0, par);
462 for (i = 0; i < 5; i++) {
463 aty_ICS2595_put1bit(locationAddr & 1, par);
467 for (i = 0; i < 8 + 1 + 2 + 2; i++) {
468 aty_ICS2595_put1bit(program_bits & 1, par);
486 .var_to_pll = aty_var_to_pll_18818,
487 .pll_to_var = aty_pll_18818_to_var,
488 .set_pll = aty_set_pll18818,
496 static int aty_var_to_pll_1703(
const struct fb_info *info,
u32 vclk_per,
502 u32 mach64MinFreq, mach64MaxFreq, mach64RefFreq;
504 u16 remainder, preRemainder;
505 short divider = 0, tempA;
508 mhz100 = 100000000 / vclk_per;
517 if (mhz100 < mach64MinFreq)
518 mhz100 = mach64MinFreq;
519 if (mhz100 > mach64MaxFreq)
520 mhz100 = mach64MaxFreq;
523 while (mhz100 < (mach64MinFreq << 3)) {
528 temp = (
unsigned int) (mhz100);
530 temp -= (
short) (mach64RefFreq << 1);
533 preRemainder = 0xffff;
537 remainder = tempB % mach64RefFreq;
538 tempB = tempB / mach64RefFreq;
540 if ((tempB & 0xffff) <= 127
541 && (remainder <= preRemainder)) {
542 preRemainder = remainder;
547 ((tempB & 0xff) << 8);
554 program_bits = divider;
557 pll->
ics2595.program_bits = program_bits;
559 pll->
ics2595.post_divider = divider;
560 pll->
ics2595.period_in_ps = vclk_per;
565 static u32 aty_pll_1703_to_var(
const struct fb_info *info,
568 return (pll->
ics2595.period_in_ps);
571 static void aty_set_pll_1703(
const struct fb_info *info,
578 char old_crtc_ext_disp;
584 program_bits = pll->
ics2595.program_bits;
585 locationAddr = pll->
ics2595.locationAddr;
602 .var_to_pll = aty_var_to_pll_1703,
603 .pll_to_var = aty_pll_1703_to_var,
604 .set_pll = aty_set_pll_1703,
612 static int aty_var_to_pll_8398(
const struct fb_info *info,
u32 vclk_per,
615 u32 tempA, tempB, fOut, longMHz100, diff, preDiff;
620 u32 mach64MinFreq, mach64MaxFreq, mach64RefFreq;
621 u16 m,
n,
k = 0, save_m, save_n, twoToKth;
624 mhz100 = 100000000 / vclk_per;
636 if (mhz100 < mach64MinFreq)
637 mhz100 = mach64MinFreq;
638 if (mhz100 > mach64MaxFreq)
639 mhz100 = mach64MaxFreq;
641 longMHz100 = mhz100 * 256 / 100;
643 while (mhz100 < (mach64MinFreq << 3)) {
650 preDiff = 0xFFFFFFFF;
656 tempB = twoToKth * 256;
658 fOut = tempA / tempB;
660 if (longMHz100 > fOut)
661 diff = longMHz100 - fOut;
663 diff = fOut - longMHz100;
665 if (diff < preDiff) {
673 program_bits = (k << 6) + (save_m) + (save_n << 8);
676 pll->
ics2595.program_bits = program_bits;
679 pll->
ics2595.period_in_ps = vclk_per;
684 static u32 aty_pll_8398_to_var(
const struct fb_info *info,
687 return (pll->
ics2595.period_in_ps);
690 static void aty_set_pll_8398(
const struct fb_info *info,
697 char old_crtc_ext_disp;
704 program_bits = pll->
ics2595.program_bits;
705 locationAddr = pll->
ics2595.locationAddr;
726 .var_to_pll = aty_var_to_pll_8398,
727 .pll_to_var = aty_pll_8398_to_var,
728 .set_pll = aty_set_pll_8398,
736 static int aty_var_to_pll_408(
const struct fb_info *info,
u32 vclk_per,
742 u32 mach64MinFreq, mach64MaxFreq, mach64RefFreq;
744 u16 remainder, preRemainder;
745 short divider = 0, tempA;
748 mhz100 = 100000000 / vclk_per;
757 if (mhz100 < mach64MinFreq)
758 mhz100 = mach64MinFreq;
759 if (mhz100 > mach64MaxFreq)
760 mhz100 = mach64MaxFreq;
762 while (mhz100 < (mach64MinFreq << 3)) {
767 temp = (
unsigned int) mhz100;
769 temp -= ((
short) (mach64RefFreq << 1));
772 preRemainder = 0xFFFF;
776 remainder = tempB % mach64RefFreq;
777 tempB = tempB / mach64RefFreq;
778 if (((tempB & 0xFFFF) <= 255)
779 && (remainder <= preRemainder)) {
780 preRemainder = remainder;
785 ((tempB & 0xFF) << 8);
789 }
while (tempA <= 32);
791 program_bits = divider;
794 pll->
ics2595.program_bits = program_bits;
796 pll->
ics2595.post_divider = divider;
797 pll->
ics2595.period_in_ps = vclk_per;
802 static u32 aty_pll_408_to_var(
const struct fb_info *info,
805 return (pll->
ics2595.period_in_ps);
808 static void aty_set_pll_408(
const struct fb_info *info,
816 char old_crtc_ext_disp;
822 program_bits = pll->
ics2595.program_bits;
823 locationAddr = pll->
ics2595.locationAddr;
841 locationAddr = (locationAddr << 2) + 0x40;
843 tmpA = program_bits >> 8;
848 tmpB = locationAddr + 1;
849 tmpA = (
u8) program_bits;
854 tmpB = locationAddr + 2;
861 tmpA = tmpC & (~(1 | 8));
873 .var_to_pll = aty_var_to_pll_408,
874 .pll_to_var = aty_pll_408_to_var,
875 .set_pll = aty_set_pll_408,
883 static int aty_set_dac_unsupported(
const struct fb_info *info,
897 static int dummy(
void)
903 .set_dac = aty_set_dac_unsupported,
907 .var_to_pll = (
void *)
dummy,
909 .set_pll = (
void *)
dummy,