1 #include <linux/types.h>
2 #include <linux/delay.h> /* udelay */
11 #include "vb_setmode.h"
18 static const unsigned short XGINew_DDRDRAM_TYPE340
[4][5] = {
19 { 2, 13, 9, 64, 0x45},
20 { 2, 12, 9, 32, 0x35},
21 { 2, 12, 8, 16, 0x31},
22 { 2, 11, 8, 8, 0x21} };
24 static const unsigned short XGINew_DDRDRAM_TYPE20
[12][5] = {
25 { 2, 14, 11, 128, 0x5D},
26 { 2, 14, 10, 64, 0x59},
27 { 2, 13, 11, 64, 0x4D},
28 { 2, 14, 9, 32, 0x55},
29 { 2, 13, 10, 32, 0x49},
30 { 2, 12, 11, 32, 0x3D},
31 { 2, 14, 8, 16, 0x51},
32 { 2, 13, 9, 16, 0x45},
33 { 2, 12, 10, 16, 0x39},
36 { 2, 12, 8, 4, 0x31} };
39 XGINew_GetXG20DRAMType(struct xgi_hw_device_info
*HwDeviceExtension
,
40 struct vb_device_info
*pVBInfo
)
42 unsigned char data
, temp
;
44 if (HwDeviceExtension
->jChipType
< XG20
) {
45 if (*pVBInfo
->pSoftSetting
& SoftDRAMType
) {
46 data
= *pVBInfo
->pSoftSetting
& 0x07;
49 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x39) & 0x02;
51 data
= (xgifb_reg_get(pVBInfo
->P3c4
, 0x3A) &
55 } else if (HwDeviceExtension
->jChipType
== XG27
) {
56 if (*pVBInfo
->pSoftSetting
& SoftDRAMType
) {
57 data
= *pVBInfo
->pSoftSetting
& 0x07;
60 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3B);
61 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
62 if ((temp
& 0x88) == 0x80)
67 } else if (HwDeviceExtension
->jChipType
== XG21
) {
68 /* Independent GPIO control */
69 xgifb_reg_and(pVBInfo
->P3d4
, 0xB4, ~0x02);
71 xgifb_reg_or(pVBInfo
->P3d4
, 0x4A, 0x80); /* Enable GPIOH read */
72 /* GPIOF 0:DVI 1:DVO */
73 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
75 /* for current XG20 & XG21, GPIOH is floating, driver will
76 * fix DDR temporarily */
77 if (temp
& 0x01) /* DVI read GPIOH */
81 /* ~HOTPLUG_SUPPORT */
82 xgifb_reg_or(pVBInfo
->P3d4
, 0xB4, 0x02);
85 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x97) & 0x01;
94 static void XGINew_DDR1x_MRS_340(unsigned long P3c4
,
95 struct vb_device_info
*pVBInfo
)
97 xgifb_reg_set(P3c4
, 0x18, 0x01);
98 xgifb_reg_set(P3c4
, 0x19, 0x20);
99 xgifb_reg_set(P3c4
, 0x16, 0x00);
100 xgifb_reg_set(P3c4
, 0x16, 0x80);
102 if (*pVBInfo
->pXGINew_DRAMTypeDefinition
!= 0x0C) { /* Samsung F Die */
104 xgifb_reg_set(P3c4
, 0x18, 0x00);
105 xgifb_reg_set(P3c4
, 0x19, 0x20);
106 xgifb_reg_set(P3c4
, 0x16, 0x00);
107 xgifb_reg_set(P3c4
, 0x16, 0x80);
113 pVBInfo
->SR15
[2][pVBInfo
->ram_type
]); /* SR18 */
114 xgifb_reg_set(P3c4
, 0x19, 0x01);
115 xgifb_reg_set(P3c4
, 0x16, pVBInfo
->SR16
[0]);
116 xgifb_reg_set(P3c4
, 0x16, pVBInfo
->SR16
[1]);
118 xgifb_reg_set(P3c4
, 0x1B, 0x03);
122 pVBInfo
->SR15
[2][pVBInfo
->ram_type
]); /* SR18 */
123 xgifb_reg_set(P3c4
, 0x19, 0x00);
124 xgifb_reg_set(P3c4
, 0x16, pVBInfo
->SR16
[2]);
125 xgifb_reg_set(P3c4
, 0x16, pVBInfo
->SR16
[3]);
126 xgifb_reg_set(P3c4
, 0x1B, 0x00);
129 static void XGINew_SetMemoryClock(struct xgi_hw_device_info
*HwDeviceExtension
,
130 struct vb_device_info
*pVBInfo
)
133 xgifb_reg_set(pVBInfo
->P3c4
,
135 pVBInfo
->MCLKData
[pVBInfo
->ram_type
].SR28
);
136 xgifb_reg_set(pVBInfo
->P3c4
,
138 pVBInfo
->MCLKData
[pVBInfo
->ram_type
].SR29
);
139 xgifb_reg_set(pVBInfo
->P3c4
,
141 pVBInfo
->MCLKData
[pVBInfo
->ram_type
].SR2A
);
143 xgifb_reg_set(pVBInfo
->P3c4
,
145 pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR2E
);
146 xgifb_reg_set(pVBInfo
->P3c4
,
148 pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR2F
);
149 xgifb_reg_set(pVBInfo
->P3c4
,
151 pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR30
);
153 /* [Vicent] 2004/07/07,
154 * When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */
155 /* [Hsuan] 2004/08/20,
156 * Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz,
157 * Set SR32 D[1:0] = 10b */
158 if (HwDeviceExtension
->jChipType
== XG42
) {
159 if ((pVBInfo
->MCLKData
[pVBInfo
->ram_type
].SR28
== 0x1C) &&
160 (pVBInfo
->MCLKData
[pVBInfo
->ram_type
].SR29
== 0x01) &&
161 (((pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR2E
== 0x1C) &&
162 (pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR2F
== 0x01)) ||
163 ((pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR2E
== 0x22) &&
164 (pVBInfo
->ECLKData
[pVBInfo
->ram_type
].SR2F
== 0x01))))
165 xgifb_reg_set(pVBInfo
->P3c4
,
167 ((unsigned char) xgifb_reg_get(
168 pVBInfo
->P3c4
, 0x32) & 0xFC) | 0x02);
172 static void XGINew_DDRII_Bootup_XG27(
173 struct xgi_hw_device_info
*HwDeviceExtension
,
174 unsigned long P3c4
, struct vb_device_info
*pVBInfo
)
176 unsigned long P3d4
= P3c4
+ 0x10;
177 pVBInfo
->ram_type
= XGINew_GetXG20DRAMType(HwDeviceExtension
, pVBInfo
);
178 XGINew_SetMemoryClock(HwDeviceExtension
, pVBInfo
);
180 /* Set Double Frequency */
181 /* xgifb_reg_set(P3d4, 0x97, 0x11); *//* CR97 */
182 xgifb_reg_set(P3d4
, 0x97, *pVBInfo
->pXGINew_CR97
); /* CR97 */
186 xgifb_reg_set(P3c4
, 0x18, 0x00); /* Set SR18 */ /* EMRS2 */
187 xgifb_reg_set(P3c4
, 0x19, 0x80); /* Set SR19 */
188 xgifb_reg_set(P3c4
, 0x16, 0x20); /* Set SR16 */
190 xgifb_reg_set(P3c4
, 0x16, 0xA0); /* Set SR16 */
193 xgifb_reg_set(P3c4
, 0x18, 0x00); /* Set SR18 */ /* EMRS3 */
194 xgifb_reg_set(P3c4
, 0x19, 0xC0); /* Set SR19 */
195 xgifb_reg_set(P3c4
, 0x16, 0x20); /* Set SR16 */
197 xgifb_reg_set(P3c4
, 0x16, 0xA0); /* Set SR16 */
200 xgifb_reg_set(P3c4
, 0x18, 0x00); /* Set SR18 */ /* EMRS1 */
201 xgifb_reg_set(P3c4
, 0x19, 0x40); /* Set SR19 */
202 xgifb_reg_set(P3c4
, 0x16, 0x20); /* Set SR16 */
204 xgifb_reg_set(P3c4
, 0x16, 0xA0); /* Set SR16 */
207 xgifb_reg_set(P3c4
, 0x18, 0x42); /* Set SR18 */ /* MRS, DLL Enable */
208 xgifb_reg_set(P3c4
, 0x19, 0x0A); /* Set SR19 */
209 xgifb_reg_set(P3c4
, 0x16, 0x00); /* Set SR16 */
211 xgifb_reg_set(P3c4
, 0x16, 0x00); /* Set SR16 */
212 xgifb_reg_set(P3c4
, 0x16, 0x80); /* Set SR16 */
215 xgifb_reg_set(P3c4
, 0x1B, 0x04); /* Set SR1B */
217 xgifb_reg_set(P3c4
, 0x1B, 0x00); /* Set SR1B */
219 xgifb_reg_set(P3c4
, 0x18, 0x42); /* Set SR18 */ /* MRS, DLL Reset */
220 xgifb_reg_set(P3c4
, 0x19, 0x08); /* Set SR19 */
221 xgifb_reg_set(P3c4
, 0x16, 0x00); /* Set SR16 */
224 xgifb_reg_set(P3c4
, 0x16, 0x83); /* Set SR16 */
227 xgifb_reg_set(P3c4
, 0x18, 0x80); /* Set SR18 */ /* MRS, ODT */
228 xgifb_reg_set(P3c4
, 0x19, 0x46); /* Set SR19 */
229 xgifb_reg_set(P3c4
, 0x16, 0x20); /* Set SR16 */
231 xgifb_reg_set(P3c4
, 0x16, 0xA0); /* Set SR16 */
234 xgifb_reg_set(P3c4
, 0x18, 0x00); /* Set SR18 */ /* EMRS */
235 xgifb_reg_set(P3c4
, 0x19, 0x40); /* Set SR19 */
236 xgifb_reg_set(P3c4
, 0x16, 0x20); /* Set SR16 */
238 xgifb_reg_set(P3c4
, 0x16, 0xA0); /* Set SR16 */
241 /* Set SR1B refresh control 000:close; 010:open */
242 xgifb_reg_set(P3c4
, 0x1B, 0x04);
247 static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info
*HwDeviceExtension
,
248 unsigned long P3c4
, struct vb_device_info
*pVBInfo
)
250 unsigned long P3d4
= P3c4
+ 0x10;
252 pVBInfo
->ram_type
= XGINew_GetXG20DRAMType(HwDeviceExtension
, pVBInfo
);
253 XGINew_SetMemoryClock(HwDeviceExtension
, pVBInfo
);
255 xgifb_reg_set(P3d4
, 0x97, 0x11); /* CR97 */
258 xgifb_reg_set(P3c4
, 0x18, 0x00); /* EMRS2 */
259 xgifb_reg_set(P3c4
, 0x19, 0x80);
260 xgifb_reg_set(P3c4
, 0x16, 0x05);
261 xgifb_reg_set(P3c4
, 0x16, 0x85);
263 xgifb_reg_set(P3c4
, 0x18, 0x00); /* EMRS3 */
264 xgifb_reg_set(P3c4
, 0x19, 0xC0);
265 xgifb_reg_set(P3c4
, 0x16, 0x05);
266 xgifb_reg_set(P3c4
, 0x16, 0x85);
268 xgifb_reg_set(P3c4
, 0x18, 0x00); /* EMRS1 */
269 xgifb_reg_set(P3c4
, 0x19, 0x40);
270 xgifb_reg_set(P3c4
, 0x16, 0x05);
271 xgifb_reg_set(P3c4
, 0x16, 0x85);
273 /* xgifb_reg_set(P3c4, 0x18, 0x52); */ /* MRS1 */
274 xgifb_reg_set(P3c4
, 0x18, 0x42); /* MRS1 */
275 xgifb_reg_set(P3c4
, 0x19, 0x02);
276 xgifb_reg_set(P3c4
, 0x16, 0x05);
277 xgifb_reg_set(P3c4
, 0x16, 0x85);
280 xgifb_reg_set(P3c4
, 0x1B, 0x04); /* SR1B */
282 xgifb_reg_set(P3c4
, 0x1B, 0x00); /* SR1B */
285 /* xgifb_reg_set(P3c4 ,0x18, 0x52); */ /* MRS2 */
286 xgifb_reg_set(P3c4
, 0x18, 0x42); /* MRS1 */
287 xgifb_reg_set(P3c4
, 0x19, 0x00);
288 xgifb_reg_set(P3c4
, 0x16, 0x05);
289 xgifb_reg_set(P3c4
, 0x16, 0x85);
294 static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4
,
295 struct vb_device_info
*pVBInfo
)
297 xgifb_reg_set(P3c4
, 0x18, 0x01);
298 xgifb_reg_set(P3c4
, 0x19, 0x40);
299 xgifb_reg_set(P3c4
, 0x16, 0x00);
300 xgifb_reg_set(P3c4
, 0x16, 0x80);
303 xgifb_reg_set(P3c4
, 0x18, 0x00);
304 xgifb_reg_set(P3c4
, 0x19, 0x40);
305 xgifb_reg_set(P3c4
, 0x16, 0x00);
306 xgifb_reg_set(P3c4
, 0x16, 0x80);
310 pVBInfo
->SR15
[2][pVBInfo
->ram_type
]); /* SR18 */
311 /* xgifb_reg_set(P3c4, 0x18, 0x31); */
312 xgifb_reg_set(P3c4
, 0x19, 0x01);
313 xgifb_reg_set(P3c4
, 0x16, 0x03);
314 xgifb_reg_set(P3c4
, 0x16, 0x83);
316 xgifb_reg_set(P3c4
, 0x1B, 0x03);
318 /* xgifb_reg_set(P3c4, 0x18, 0x31); */
321 pVBInfo
->SR15
[2][pVBInfo
->ram_type
]); /* SR18 */
322 xgifb_reg_set(P3c4
, 0x19, 0x00);
323 xgifb_reg_set(P3c4
, 0x16, 0x03);
324 xgifb_reg_set(P3c4
, 0x16, 0x83);
325 xgifb_reg_set(P3c4
, 0x1B, 0x00);
328 static void XGINew_DDR1x_DefaultRegister(
329 struct xgi_hw_device_info
*HwDeviceExtension
,
330 unsigned long Port
, struct vb_device_info
*pVBInfo
)
332 unsigned long P3d4
= Port
, P3c4
= Port
- 0x10;
334 if (HwDeviceExtension
->jChipType
>= XG20
) {
335 XGINew_SetMemoryClock(HwDeviceExtension
, pVBInfo
);
338 pVBInfo
->CR40
[11][pVBInfo
->ram_type
]); /* CR82 */
341 pVBInfo
->CR40
[12][pVBInfo
->ram_type
]); /* CR85 */
344 pVBInfo
->CR40
[13][pVBInfo
->ram_type
]); /* CR86 */
346 xgifb_reg_set(P3d4
, 0x98, 0x01);
347 xgifb_reg_set(P3d4
, 0x9A, 0x02);
349 XGINew_DDR1x_MRS_XG20(P3c4
, pVBInfo
);
351 XGINew_SetMemoryClock(HwDeviceExtension
, pVBInfo
);
353 switch (HwDeviceExtension
->jChipType
) {
359 pVBInfo
->CR40
[11][pVBInfo
->ram_type
]);
363 pVBInfo
->CR40
[12][pVBInfo
->ram_type
]);
367 pVBInfo
->CR40
[13][pVBInfo
->ram_type
]);
370 xgifb_reg_set(P3d4
, 0x82, 0x88);
371 xgifb_reg_set(P3d4
, 0x86, 0x00);
372 /* Insert read command for delay */
373 xgifb_reg_get(P3d4
, 0x86);
374 xgifb_reg_set(P3d4
, 0x86, 0x88);
375 xgifb_reg_get(P3d4
, 0x86);
378 pVBInfo
->CR40
[13][pVBInfo
->ram_type
]);
379 xgifb_reg_set(P3d4
, 0x82, 0x77);
380 xgifb_reg_set(P3d4
, 0x85, 0x00);
382 /* Insert read command for delay */
383 xgifb_reg_get(P3d4
, 0x85);
384 xgifb_reg_set(P3d4
, 0x85, 0x88);
386 /* Insert read command for delay */
387 xgifb_reg_get(P3d4
, 0x85);
391 pVBInfo
->CR40
[12][pVBInfo
->ram_type
]);
395 pVBInfo
->CR40
[11][pVBInfo
->ram_type
]);
399 xgifb_reg_set(P3d4
, 0x97, 0x00);
400 xgifb_reg_set(P3d4
, 0x98, 0x01);
401 xgifb_reg_set(P3d4
, 0x9A, 0x02);
402 XGINew_DDR1x_MRS_340(P3c4
, pVBInfo
);
406 static void XGINew_DDR2_DefaultRegister(
407 struct xgi_hw_device_info
*HwDeviceExtension
,
408 unsigned long Port
, struct vb_device_info
*pVBInfo
)
410 unsigned long P3d4
= Port
, P3c4
= Port
- 0x10;
412 /* keep following setting sequence, each setting in
413 * the same reg insert idle */
414 xgifb_reg_set(P3d4
, 0x82, 0x77);
415 xgifb_reg_set(P3d4
, 0x86, 0x00);
416 xgifb_reg_get(P3d4
, 0x86); /* Insert read command for delay */
417 xgifb_reg_set(P3d4
, 0x86, 0x88);
418 xgifb_reg_get(P3d4
, 0x86); /* Insert read command for delay */
420 xgifb_reg_set(P3d4
, 0x86, pVBInfo
->CR40
[13][pVBInfo
->ram_type
]);
421 xgifb_reg_set(P3d4
, 0x82, 0x77);
422 xgifb_reg_set(P3d4
, 0x85, 0x00);
423 xgifb_reg_get(P3d4
, 0x85); /* Insert read command for delay */
424 xgifb_reg_set(P3d4
, 0x85, 0x88);
425 xgifb_reg_get(P3d4
, 0x85); /* Insert read command for delay */
428 pVBInfo
->CR40
[12][pVBInfo
->ram_type
]); /* CR85 */
429 if (HwDeviceExtension
->jChipType
== XG27
)
431 xgifb_reg_set(P3d4
, 0x82, pVBInfo
->CR40
[11][pVBInfo
->ram_type
]);
433 xgifb_reg_set(P3d4
, 0x82, 0xA8); /* CR82 */
435 xgifb_reg_set(P3d4
, 0x98, 0x01);
436 xgifb_reg_set(P3d4
, 0x9A, 0x02);
437 if (HwDeviceExtension
->jChipType
== XG27
)
438 XGINew_DDRII_Bootup_XG27(HwDeviceExtension
, P3c4
, pVBInfo
);
440 XGINew_DDR2_MRS_XG20(HwDeviceExtension
, P3c4
, pVBInfo
);
443 static void XGINew_SetDRAMDefaultRegister340(
444 struct xgi_hw_device_info
*HwDeviceExtension
,
445 unsigned long Port
, struct vb_device_info
*pVBInfo
)
447 unsigned char temp
, temp1
, temp2
, temp3
, i
, j
, k
;
449 unsigned long P3d4
= Port
, P3c4
= Port
- 0x10;
451 xgifb_reg_set(P3d4
, 0x6D, pVBInfo
->CR40
[8][pVBInfo
->ram_type
]);
452 xgifb_reg_set(P3d4
, 0x68, pVBInfo
->CR40
[5][pVBInfo
->ram_type
]);
453 xgifb_reg_set(P3d4
, 0x69, pVBInfo
->CR40
[6][pVBInfo
->ram_type
]);
454 xgifb_reg_set(P3d4
, 0x6A, pVBInfo
->CR40
[7][pVBInfo
->ram_type
]);
457 for (i
= 0; i
< 4; i
++) {
458 /* CR6B DQS fine tune delay */
459 temp
= pVBInfo
->CR6B
[pVBInfo
->ram_type
][i
];
460 for (j
= 0; j
< 4; j
++) {
461 temp1
= ((temp
>> (2 * j
)) & 0x03) << 2;
463 xgifb_reg_set(P3d4
, 0x6B, temp2
);
464 /* Insert read command for delay */
465 xgifb_reg_get(P3d4
, 0x6B);
472 for (i
= 0; i
< 4; i
++) {
473 /* CR6E DQM fine tune delay */
474 temp
= pVBInfo
->CR6E
[pVBInfo
->ram_type
][i
];
475 for (j
= 0; j
< 4; j
++) {
476 temp1
= ((temp
>> (2 * j
)) & 0x03) << 2;
478 xgifb_reg_set(P3d4
, 0x6E, temp2
);
479 /* Insert read command for delay */
480 xgifb_reg_get(P3d4
, 0x6E);
487 for (k
= 0; k
< 4; k
++) {
488 /* CR6E_D[1:0] select channel */
489 xgifb_reg_and_or(P3d4
, 0x6E, 0xFC, temp3
);
491 for (i
= 0; i
< 8; i
++) {
492 /* CR6F DQ fine tune delay */
493 temp
= pVBInfo
->CR6F
[pVBInfo
->ram_type
][8 * k
+ i
];
494 for (j
= 0; j
< 4; j
++) {
495 temp1
= (temp
>> (2 * j
)) & 0x03;
497 xgifb_reg_set(P3d4
, 0x6F, temp2
);
498 /* Insert read command for delay */
499 xgifb_reg_get(P3d4
, 0x6F);
509 pVBInfo
->CR40
[9][pVBInfo
->ram_type
]); /* CR80 */
512 pVBInfo
->CR40
[10][pVBInfo
->ram_type
]); /* CR81 */
515 /* CR89 terminator type select */
516 temp
= pVBInfo
->CR89
[pVBInfo
->ram_type
][0];
517 for (j
= 0; j
< 4; j
++) {
518 temp1
= (temp
>> (2 * j
)) & 0x03;
520 xgifb_reg_set(P3d4
, 0x89, temp2
);
521 xgifb_reg_get(P3d4
, 0x89); /* Insert read command for delay */
526 temp
= pVBInfo
->CR89
[pVBInfo
->ram_type
][1];
529 xgifb_reg_set(P3d4
, 0x89, temp2
);
531 temp
= pVBInfo
->CR40
[3][pVBInfo
->ram_type
];
533 temp2
= (temp
>> 4) & 0x07;
535 xgifb_reg_set(P3d4
, 0x45, temp1
); /* CR45 */
536 xgifb_reg_set(P3d4
, 0x99, temp2
); /* CR99 */
537 xgifb_reg_or(P3d4
, 0x40, temp3
); /* CR40_D[7] */
540 pVBInfo
->CR40
[0][pVBInfo
->ram_type
]); /* CR41 */
542 if (HwDeviceExtension
->jChipType
== XG27
)
543 xgifb_reg_set(P3d4
, 0x8F, *pVBInfo
->pCR8F
); /* CR8F */
545 for (j
= 0; j
<= 6; j
++) /* CR90 - CR96 */
546 xgifb_reg_set(P3d4
, (0x90 + j
),
547 pVBInfo
->CR40
[14 + j
][pVBInfo
->ram_type
]);
549 for (j
= 0; j
<= 2; j
++) /* CRC3 - CRC5 */
550 xgifb_reg_set(P3d4
, (0xC3 + j
),
551 pVBInfo
->CR40
[21 + j
][pVBInfo
->ram_type
]);
553 for (j
= 0; j
< 2; j
++) /* CR8A - CR8B */
554 xgifb_reg_set(P3d4
, (0x8A + j
),
555 pVBInfo
->CR40
[1 + j
][pVBInfo
->ram_type
]);
557 if ((HwDeviceExtension
->jChipType
== XG41
) ||
558 (HwDeviceExtension
->jChipType
== XG42
))
559 xgifb_reg_set(P3d4
, 0x8C, 0x87);
563 pVBInfo
->CR40
[4][pVBInfo
->ram_type
]); /* CR59 */
565 xgifb_reg_set(P3d4
, 0x83, 0x09); /* CR83 */
566 xgifb_reg_set(P3d4
, 0x87, 0x00); /* CR87 */
567 xgifb_reg_set(P3d4
, 0xCF, *pVBInfo
->pCRCF
); /* CRCF */
568 if (pVBInfo
->ram_type
) {
569 /* xgifb_reg_set(P3c4, 0x17, 0xC0); */ /* SR17 DDRII */
570 xgifb_reg_set(P3c4
, 0x17, 0x80); /* SR17 DDRII */
571 if (HwDeviceExtension
->jChipType
== XG27
)
572 xgifb_reg_set(P3c4
, 0x17, 0x02); /* SR17 DDRII */
575 xgifb_reg_set(P3c4
, 0x17, 0x00); /* SR17 DDR */
577 xgifb_reg_set(P3c4
, 0x1A, 0x87); /* SR1A */
579 temp
= XGINew_GetXG20DRAMType(HwDeviceExtension
, pVBInfo
);
581 XGINew_DDR1x_DefaultRegister(HwDeviceExtension
, P3d4
, pVBInfo
);
583 xgifb_reg_set(P3d4
, 0xB0, 0x80); /* DDRII Dual frequency mode */
584 XGINew_DDR2_DefaultRegister(HwDeviceExtension
, P3d4
, pVBInfo
);
588 pVBInfo
->SR15
[3][pVBInfo
->ram_type
]); /* SR1B */
591 static void XGINew_SetDRAMSizingType(int index
,
592 const unsigned short DRAMTYPE_TABLE
[][5],
593 struct vb_device_info
*pVBInfo
)
597 data
= DRAMTYPE_TABLE
[index
][4];
598 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x13, 0x80, data
);
600 /* should delay 50 ns */
603 static unsigned short XGINew_SetDRAMSizeReg(int index
,
604 const unsigned short DRAMTYPE_TABLE
[][5],
605 struct vb_device_info
*pVBInfo
)
607 unsigned short data
= 0, memsize
= 0;
609 unsigned char ChannelNo
;
611 RankSize
= DRAMTYPE_TABLE
[index
][3] * pVBInfo
->ram_bus
/ 32;
612 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x13);
620 if (pVBInfo
->ram_channel
== 3)
623 ChannelNo
= pVBInfo
->ram_channel
;
625 if (ChannelNo
* RankSize
<= 256) {
626 while ((RankSize
>>= 1) > 0)
631 /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
632 xgifb_reg_set(pVBInfo
->P3c4
,
634 (xgifb_reg_get(pVBInfo
->P3c4
, 0x14) & 0x0F) |
637 /* data |= pVBInfo->ram_channel << 2; */
638 /* data |= (pVBInfo->ram_bus / 64) << 1; */
639 /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */
642 /* XGINew_SetDRAMModeRegister340(pVBInfo); */
647 static unsigned short XGINew_SetDRAMSize20Reg(int index
,
648 const unsigned short DRAMTYPE_TABLE
[][5],
649 struct vb_device_info
*pVBInfo
)
651 unsigned short data
= 0, memsize
= 0;
653 unsigned char ChannelNo
;
655 RankSize
= DRAMTYPE_TABLE
[index
][3] * pVBInfo
->ram_bus
/ 8;
656 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x13);
664 if (pVBInfo
->ram_channel
== 3)
667 ChannelNo
= pVBInfo
->ram_channel
;
669 if (ChannelNo
* RankSize
<= 256) {
670 while ((RankSize
>>= 1) > 0)
675 /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
676 xgifb_reg_set(pVBInfo
->P3c4
,
678 (xgifb_reg_get(pVBInfo
->P3c4
, 0x14) & 0x0F) |
682 /* data |= pVBInfo->ram_channel << 2; */
683 /* data |= (pVBInfo->ram_bus / 64) << 1; */
684 /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */
687 /* XGINew_SetDRAMModeRegister340(pVBInfo); */
692 static int XGINew_ReadWriteRest(unsigned short StopAddr
,
693 unsigned short StartAddr
, struct vb_device_info
*pVBInfo
)
696 unsigned long Position
= 0;
697 void __iomem
*fbaddr
= pVBInfo
->FBAddr
;
699 writel(Position
, fbaddr
+ Position
);
701 for (i
= StartAddr
; i
<= StopAddr
; i
++) {
703 writel(Position
, fbaddr
+ Position
);
706 udelay(500); /* [Vicent] 2004/04/16.
707 Fix #1759 Memory Size error in Multi-Adapter. */
711 if (readl(fbaddr
+ Position
) != Position
)
714 for (i
= StartAddr
; i
<= StopAddr
; i
++) {
716 if (readl(fbaddr
+ Position
) != Position
)
722 static unsigned char XGINew_CheckFrequence(struct vb_device_info
*pVBInfo
)
726 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x97);
728 if ((data
& 0x10) == 0) {
729 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x39);
730 data
= (data
& 0x02) >> 1;
737 static void XGINew_CheckChannel(struct xgi_hw_device_info
*HwDeviceExtension
,
738 struct vb_device_info
*pVBInfo
)
742 switch (HwDeviceExtension
->jChipType
) {
745 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x97);
747 pVBInfo
->ram_channel
= 1; /* XG20 "JUST" one channel */
749 if (data
== 0) { /* Single_32_16 */
751 if ((HwDeviceExtension
->ulVideoMemorySize
- 1)
754 pVBInfo
->ram_bus
= 32; /* 32 bits */
755 /* 22bit + 2 rank + 32bit */
756 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xB1);
757 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x52);
760 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
763 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) >
765 /* 22bit + 1 rank + 32bit */
766 xgifb_reg_set(pVBInfo
->P3c4
,
769 xgifb_reg_set(pVBInfo
->P3c4
,
774 if (XGINew_ReadWriteRest(23,
781 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) >
783 pVBInfo
->ram_bus
= 16; /* 16 bits */
784 /* 22bit + 2 rank + 16bit */
785 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xB1);
786 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x41);
789 if (XGINew_ReadWriteRest(23, 22, pVBInfo
) == 1)
792 xgifb_reg_set(pVBInfo
->P3c4
,
798 } else { /* Dual_16_8 */
799 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) >
801 pVBInfo
->ram_bus
= 16; /* 16 bits */
802 /* (0x31:12x8x2) 22bit + 2 rank */
803 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xB1);
805 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x41);
808 if (XGINew_ReadWriteRest(23, 22, pVBInfo
) == 1)
811 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) >
813 /* (0x31:12x8x2) 22bit + 1 rank */
814 xgifb_reg_set(pVBInfo
->P3c4
,
818 xgifb_reg_set(pVBInfo
->P3c4
,
823 if (XGINew_ReadWriteRest(22,
830 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) >
832 pVBInfo
->ram_bus
= 8; /* 8 bits */
833 /* (0x31:12x8x2) 22bit + 2 rank */
834 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xB1);
836 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x30);
839 if (XGINew_ReadWriteRest(22, 21, pVBInfo
) == 1)
841 else /* (0x31:12x8x2) 22bit + 1 rank */
842 xgifb_reg_set(pVBInfo
->P3c4
,
851 pVBInfo
->ram_bus
= 16; /* 16 bits */
852 pVBInfo
->ram_channel
= 1; /* Single channel */
853 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x51); /* 32Mx16 bit*/
856 if (XGINew_CheckFrequence(pVBInfo
) == 1) {
857 pVBInfo
->ram_bus
= 32; /* 32 bits */
858 pVBInfo
->ram_channel
= 3; /* Quad Channel */
859 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
860 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x4C);
862 if (XGINew_ReadWriteRest(25, 23, pVBInfo
) == 1)
865 pVBInfo
->ram_channel
= 2; /* Dual channels */
866 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x48);
868 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
871 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x49);
873 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
876 pVBInfo
->ram_channel
= 3;
877 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
878 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x3C);
880 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
883 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x38);
885 if (XGINew_ReadWriteRest(8, 4, pVBInfo
) == 1)
888 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x39);
890 pVBInfo
->ram_bus
= 64; /* 64 bits */
891 pVBInfo
->ram_channel
= 2; /* Dual channels */
892 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
893 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x5A);
895 if (XGINew_ReadWriteRest(25, 24, pVBInfo
) == 1)
898 pVBInfo
->ram_channel
= 1; /* Single channels */
899 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x52);
901 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
904 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x53);
906 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
909 pVBInfo
->ram_channel
= 2; /* Dual channels */
910 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
911 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x4A);
913 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
916 pVBInfo
->ram_channel
= 1; /* Single channels */
917 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x42);
919 if (XGINew_ReadWriteRest(8, 4, pVBInfo
) == 1)
922 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x43);
929 XG42 SR14 D[3] Reserve
930 D[2] = 1, Dual Channel
933 It's Different from Other XG40 Series.
935 if (XGINew_CheckFrequence(pVBInfo
) == 1) { /* DDRII, DDR2x */
936 pVBInfo
->ram_bus
= 32; /* 32 bits */
937 pVBInfo
->ram_channel
= 2; /* 2 Channel */
938 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
939 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x44);
941 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
944 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
945 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x34);
946 if (XGINew_ReadWriteRest(23, 22, pVBInfo
) == 1)
949 pVBInfo
->ram_channel
= 1; /* Single Channel */
950 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
951 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x40);
953 if (XGINew_ReadWriteRest(23, 22, pVBInfo
) == 1)
956 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
957 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x30);
960 pVBInfo
->ram_bus
= 64; /* 64 bits */
961 pVBInfo
->ram_channel
= 1; /* 1 channels */
962 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
963 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x52);
965 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
968 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
969 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x42);
977 if (XGINew_CheckFrequence(pVBInfo
) == 1) { /* DDRII */
978 pVBInfo
->ram_bus
= 32; /* 32 bits */
979 pVBInfo
->ram_channel
= 3;
980 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
981 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x4C);
983 if (XGINew_ReadWriteRest(25, 23, pVBInfo
) == 1)
986 pVBInfo
->ram_channel
= 2; /* 2 channels */
987 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x48);
989 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1)
992 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
993 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x3C);
995 if (XGINew_ReadWriteRest(24, 23, pVBInfo
) == 1) {
996 pVBInfo
->ram_channel
= 3; /* 4 channels */
998 pVBInfo
->ram_channel
= 2; /* 2 channels */
999 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x38);
1002 pVBInfo
->ram_bus
= 64; /* 64 bits */
1003 pVBInfo
->ram_channel
= 2; /* 2 channels */
1004 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0xA1);
1005 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x5A);
1007 if (XGINew_ReadWriteRest(25, 24, pVBInfo
) == 1) {
1010 xgifb_reg_set(pVBInfo
->P3c4
, 0x13, 0x21);
1011 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x4A);
1018 static int XGINew_DDRSizing340(struct xgi_hw_device_info
*HwDeviceExtension
,
1019 struct vb_device_info
*pVBInfo
)
1022 unsigned short memsize
, addr
;
1024 xgifb_reg_set(pVBInfo
->P3c4
, 0x15, 0x00); /* noninterleaving */
1025 xgifb_reg_set(pVBInfo
->P3c4
, 0x1C, 0x00); /* nontiling */
1026 XGINew_CheckChannel(HwDeviceExtension
, pVBInfo
);
1028 if (HwDeviceExtension
->jChipType
>= XG20
) {
1029 for (i
= 0; i
< 12; i
++) {
1030 XGINew_SetDRAMSizingType(i
,
1031 XGINew_DDRDRAM_TYPE20
,
1033 memsize
= XGINew_SetDRAMSize20Reg(i
,
1034 XGINew_DDRDRAM_TYPE20
,
1039 addr
= memsize
+ (pVBInfo
->ram_channel
- 2) + 20;
1040 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) <
1041 (unsigned long) (1 << addr
))
1044 if (XGINew_ReadWriteRest(addr
, 5, pVBInfo
) == 1)
1048 for (i
= 0; i
< 4; i
++) {
1049 XGINew_SetDRAMSizingType(i
,
1050 XGINew_DDRDRAM_TYPE340
,
1052 memsize
= XGINew_SetDRAMSizeReg(i
,
1053 XGINew_DDRDRAM_TYPE340
,
1059 addr
= memsize
+ (pVBInfo
->ram_channel
- 2) + 20;
1060 if ((HwDeviceExtension
->ulVideoMemorySize
- 1) <
1061 (unsigned long) (1 << addr
))
1064 if (XGINew_ReadWriteRest(addr
, 9, pVBInfo
) == 1)
1071 static void XGINew_SetDRAMSize_340(struct xgi_hw_device_info
*HwDeviceExtension
,
1072 struct vb_device_info
*pVBInfo
)
1074 unsigned short data
;
1076 pVBInfo
->ROMAddr
= HwDeviceExtension
->pjVirtualRomBase
;
1077 pVBInfo
->FBAddr
= HwDeviceExtension
->pjVideoMemoryAddress
;
1079 XGISetModeNew(HwDeviceExtension
, 0x2e);
1081 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x21);
1082 /* disable read cache */
1083 xgifb_reg_set(pVBInfo
->P3c4
, 0x21, (unsigned short) (data
& 0xDF));
1084 XGI_DisplayOff(HwDeviceExtension
, pVBInfo
);
1086 /* data = xgifb_reg_get(pVBInfo->P3c4, 0x1); */
1087 /* data |= 0x20 ; */
1088 /* xgifb_reg_set(pVBInfo->P3c4, 0x01, data); *//* Turn OFF Display */
1089 XGINew_DDRSizing340(HwDeviceExtension
, pVBInfo
);
1090 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x21);
1091 /* enable read cache */
1092 xgifb_reg_set(pVBInfo
->P3c4
, 0x21, (unsigned short) (data
| 0x20));
1095 static void ReadVBIOSTablData(unsigned char ChipType
,
1096 struct vb_device_info
*pVBInfo
)
1098 volatile unsigned char *pVideoMemory
=
1099 (unsigned char *) pVBInfo
->ROMAddr
;
1102 /* Volari customize data area end */
1104 if (ChipType
== XG21
) {
1105 pVBInfo
->IF_DEF_LVDS
= 0;
1106 if (pVideoMemory
[0x65] & 0x1) {
1107 pVBInfo
->IF_DEF_LVDS
= 1;
1108 i
= pVideoMemory
[0x316] | (pVideoMemory
[0x317] << 8);
1109 j
= pVideoMemory
[i
- 1];
1113 pVBInfo
->XG21_LVDSCapList
[k
].
1116 (pVideoMemory
[i
+ 1] << 8);
1117 pVBInfo
->XG21_LVDSCapList
[k
].LVDSHT
1118 = pVideoMemory
[i
+ 2] |
1119 (pVideoMemory
[i
+ 3] << 8);
1120 pVBInfo
->XG21_LVDSCapList
[k
].LVDSVT
1121 = pVideoMemory
[i
+ 4] |
1122 (pVideoMemory
[i
+ 5] << 8);
1123 pVBInfo
->XG21_LVDSCapList
[k
].LVDSHDE
1124 = pVideoMemory
[i
+ 6] |
1125 (pVideoMemory
[i
+ 7] << 8);
1126 pVBInfo
->XG21_LVDSCapList
[k
].LVDSVDE
1127 = pVideoMemory
[i
+ 8] |
1128 (pVideoMemory
[i
+ 9] << 8);
1129 pVBInfo
->XG21_LVDSCapList
[k
].LVDSHFP
1130 = pVideoMemory
[i
+ 10] |
1131 (pVideoMemory
[i
+ 11] << 8);
1132 pVBInfo
->XG21_LVDSCapList
[k
].LVDSVFP
1133 = pVideoMemory
[i
+ 12] |
1134 (pVideoMemory
[i
+ 13] << 8);
1135 pVBInfo
->XG21_LVDSCapList
[k
].LVDSHSYNC
1136 = pVideoMemory
[i
+ 14] |
1137 (pVideoMemory
[i
+ 15] << 8);
1138 pVBInfo
->XG21_LVDSCapList
[k
].LVDSVSYNC
1139 = pVideoMemory
[i
+ 16] |
1140 (pVideoMemory
[i
+ 17] << 8);
1141 pVBInfo
->XG21_LVDSCapList
[k
].VCLKData1
1142 = pVideoMemory
[i
+ 18];
1143 pVBInfo
->XG21_LVDSCapList
[k
].VCLKData2
1144 = pVideoMemory
[i
+ 19];
1145 pVBInfo
->XG21_LVDSCapList
[k
].PSC_S1
1146 = pVideoMemory
[i
+ 20];
1147 pVBInfo
->XG21_LVDSCapList
[k
].PSC_S2
1148 = pVideoMemory
[i
+ 21];
1149 pVBInfo
->XG21_LVDSCapList
[k
].PSC_S3
1150 = pVideoMemory
[i
+ 22];
1151 pVBInfo
->XG21_LVDSCapList
[k
].PSC_S4
1152 = pVideoMemory
[i
+ 23];
1153 pVBInfo
->XG21_LVDSCapList
[k
].PSC_S5
1154 = pVideoMemory
[i
+ 24];
1159 (k
< (sizeof(XGI21_LCDCapList
) /
1161 XGI21_LVDSCapStruct
))));
1163 pVBInfo
->XG21_LVDSCapList
[0].LVDS_Capability
1165 (pVideoMemory
[i
+ 1] << 8);
1166 pVBInfo
->XG21_LVDSCapList
[0].LVDSHT
1167 = pVideoMemory
[i
+ 2] |
1168 (pVideoMemory
[i
+ 3] << 8);
1169 pVBInfo
->XG21_LVDSCapList
[0].LVDSVT
1170 = pVideoMemory
[i
+ 4] |
1171 (pVideoMemory
[i
+ 5] << 8);
1172 pVBInfo
->XG21_LVDSCapList
[0].LVDSHDE
1173 = pVideoMemory
[i
+ 6] |
1174 (pVideoMemory
[i
+ 7] << 8);
1175 pVBInfo
->XG21_LVDSCapList
[0].LVDSVDE
1176 = pVideoMemory
[i
+ 8] |
1177 (pVideoMemory
[i
+ 9] << 8);
1178 pVBInfo
->XG21_LVDSCapList
[0].LVDSHFP
1179 = pVideoMemory
[i
+ 10] |
1180 (pVideoMemory
[i
+ 11] << 8);
1181 pVBInfo
->XG21_LVDSCapList
[0].LVDSVFP
1182 = pVideoMemory
[i
+ 12] |
1183 (pVideoMemory
[i
+ 13] << 8);
1184 pVBInfo
->XG21_LVDSCapList
[0].LVDSHSYNC
1185 = pVideoMemory
[i
+ 14] |
1186 (pVideoMemory
[i
+ 15] << 8);
1187 pVBInfo
->XG21_LVDSCapList
[0].LVDSVSYNC
1188 = pVideoMemory
[i
+ 16] |
1189 (pVideoMemory
[i
+ 17] << 8);
1190 pVBInfo
->XG21_LVDSCapList
[0].VCLKData1
1191 = pVideoMemory
[i
+ 18];
1192 pVBInfo
->XG21_LVDSCapList
[0].VCLKData2
1193 = pVideoMemory
[i
+ 19];
1194 pVBInfo
->XG21_LVDSCapList
[0].PSC_S1
1195 = pVideoMemory
[i
+ 20];
1196 pVBInfo
->XG21_LVDSCapList
[0].PSC_S2
1197 = pVideoMemory
[i
+ 21];
1198 pVBInfo
->XG21_LVDSCapList
[0].PSC_S3
1199 = pVideoMemory
[i
+ 22];
1200 pVBInfo
->XG21_LVDSCapList
[0].PSC_S4
1201 = pVideoMemory
[i
+ 23];
1202 pVBInfo
->XG21_LVDSCapList
[0].PSC_S5
1203 = pVideoMemory
[i
+ 24];
1209 static void XGINew_ChkSenseStatus(struct xgi_hw_device_info
*HwDeviceExtension
,
1210 struct vb_device_info
*pVBInfo
)
1212 unsigned short tempbx
= 0, temp
, tempcx
, CR3CData
;
1214 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x32);
1216 if (temp
& Monitor1Sense
)
1217 tempbx
|= ActiveCRT1
;
1218 if (temp
& LCDSense
)
1219 tempbx
|= ActiveLCD
;
1220 if (temp
& Monitor2Sense
)
1221 tempbx
|= ActiveCRT2
;
1222 if (temp
& TVSense
) {
1224 if (temp
& AVIDEOSense
)
1225 tempbx
|= (ActiveAVideo
<< 8);
1226 if (temp
& SVIDEOSense
)
1227 tempbx
|= (ActiveSVideo
<< 8);
1228 if (temp
& SCARTSense
)
1229 tempbx
|= (ActiveSCART
<< 8);
1230 if (temp
& HiTVSense
)
1231 tempbx
|= (ActiveHiTV
<< 8);
1232 if (temp
& YPbPrSense
)
1233 tempbx
|= (ActiveYPbPr
<< 8);
1236 tempcx
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3d);
1237 tempcx
|= (xgifb_reg_get(pVBInfo
->P3d4
, 0x3e) << 8);
1239 if (tempbx
& tempcx
) {
1240 CR3CData
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3c);
1241 if (!(CR3CData
& DisplayDeviceFromCMOS
)) {
1243 if (*pVBInfo
->pSoftSetting
& ModeSoftSetting
)
1248 if (*pVBInfo
->pSoftSetting
& ModeSoftSetting
)
1253 xgifb_reg_set(pVBInfo
->P3d4
, 0x3d, (tempbx
& 0x00FF));
1254 xgifb_reg_set(pVBInfo
->P3d4
, 0x3e, ((tempbx
& 0xFF00) >> 8));
1257 static void XGINew_SetModeScratch(struct xgi_hw_device_info
*HwDeviceExtension
,
1258 struct vb_device_info
*pVBInfo
)
1260 unsigned short temp
, tempcl
= 0, tempch
= 0, CR31Data
, CR38Data
;
1262 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3d);
1263 temp
|= xgifb_reg_get(pVBInfo
->P3d4
, 0x3e) << 8;
1264 temp
|= (xgifb_reg_get(pVBInfo
->P3d4
, 0x31) & (DriverMode
>> 8)) << 8;
1266 if (pVBInfo
->IF_DEF_CRT2Monitor
== 1) {
1267 if (temp
& ActiveCRT2
)
1268 tempcl
= SetCRT2ToRAMDAC
;
1271 if (temp
& ActiveLCD
) {
1272 tempcl
|= SetCRT2ToLCD
;
1273 if (temp
& DriverMode
) {
1274 if (temp
& ActiveTV
) {
1275 tempch
= SetToLCDA
| EnableDualEdge
;
1276 temp
^= SetCRT2ToLCD
;
1278 if ((temp
>> 8) & ActiveAVideo
)
1279 tempcl
|= SetCRT2ToAVIDEO
;
1280 if ((temp
>> 8) & ActiveSVideo
)
1281 tempcl
|= SetCRT2ToSVIDEO
;
1282 if ((temp
>> 8) & ActiveSCART
)
1283 tempcl
|= SetCRT2ToSCART
;
1285 if (pVBInfo
->IF_DEF_HiVision
== 1) {
1286 if ((temp
>> 8) & ActiveHiTV
)
1287 tempcl
|= SetCRT2ToHiVisionTV
;
1290 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
1291 if ((temp
>> 8) & ActiveYPbPr
)
1297 if ((temp
>> 8) & ActiveAVideo
)
1298 tempcl
|= SetCRT2ToAVIDEO
;
1299 if ((temp
>> 8) & ActiveSVideo
)
1300 tempcl
|= SetCRT2ToSVIDEO
;
1301 if ((temp
>> 8) & ActiveSCART
)
1302 tempcl
|= SetCRT2ToSCART
;
1304 if (pVBInfo
->IF_DEF_HiVision
== 1) {
1305 if ((temp
>> 8) & ActiveHiTV
)
1306 tempcl
|= SetCRT2ToHiVisionTV
;
1309 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
1310 if ((temp
>> 8) & ActiveYPbPr
)
1315 tempcl
|= SetSimuScanMode
;
1316 if ((!(temp
& ActiveCRT1
)) && ((temp
& ActiveLCD
) || (temp
& ActiveTV
)
1317 || (temp
& ActiveCRT2
)))
1318 tempcl
^= (SetSimuScanMode
| SwitchToCRT2
);
1319 if ((temp
& ActiveLCD
) && (temp
& ActiveTV
))
1320 tempcl
^= (SetSimuScanMode
| SwitchToCRT2
);
1321 xgifb_reg_set(pVBInfo
->P3d4
, 0x30, tempcl
);
1323 CR31Data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
1324 CR31Data
&= ~(SetNotSimuMode
>> 8);
1325 if (!(temp
& ActiveCRT1
))
1326 CR31Data
|= (SetNotSimuMode
>> 8);
1327 CR31Data
&= ~(DisableCRT2Display
>> 8);
1328 if (!((temp
& ActiveLCD
) || (temp
& ActiveTV
) || (temp
& ActiveCRT2
)))
1329 CR31Data
|= (DisableCRT2Display
>> 8);
1330 xgifb_reg_set(pVBInfo
->P3d4
, 0x31, CR31Data
);
1332 CR38Data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
1333 CR38Data
&= ~SetYPbPr
;
1335 xgifb_reg_set(pVBInfo
->P3d4
, 0x38, CR38Data
);
1339 static void XGINew_GetXG21Sense(struct xgi_hw_device_info
*HwDeviceExtension
,
1340 struct vb_device_info
*pVBInfo
)
1343 volatile unsigned char *pVideoMemory
=
1344 (unsigned char *) pVBInfo
->ROMAddr
;
1346 pVBInfo
->IF_DEF_LVDS
= 0;
1349 if ((pVideoMemory
[0x65] & 0x01)) { /* For XG21 LVDS */
1350 pVBInfo
->IF_DEF_LVDS
= 1;
1351 xgifb_reg_or(pVBInfo
->P3d4
, 0x32, LCDSense
);
1353 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x38, ~0xE0, 0xC0);
1356 /* Enable GPIOA/B read */
1357 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x4A, ~0x03, 0x03);
1358 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48) & 0xC0;
1359 if (Temp
== 0xC0) { /* DVI & DVO GPIOA/B pull high */
1360 XGINew_SenseLCD(HwDeviceExtension
, pVBInfo
);
1361 xgifb_reg_or(pVBInfo
->P3d4
, 0x32, LCDSense
);
1362 /* Enable read GPIOF */
1363 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x4A, ~0x20, 0x20);
1364 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48) & 0x04;
1366 xgifb_reg_and_or(pVBInfo
->P3d4
,
1369 0x80); /* TMDS on chip */
1371 xgifb_reg_and_or(pVBInfo
->P3d4
,
1374 0xA0); /* Only DVO on chip */
1375 /* Disable read GPIOF */
1376 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x20);
1383 static void XGINew_GetXG27Sense(struct xgi_hw_device_info
*HwDeviceExtension
,
1384 struct vb_device_info
*pVBInfo
)
1386 unsigned char Temp
, bCR4A
;
1388 pVBInfo
->IF_DEF_LVDS
= 0;
1389 bCR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
1390 /* Enable GPIOA/B/C read */
1391 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x4A, ~0x07, 0x07);
1392 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48) & 0x07;
1393 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, bCR4A
);
1396 pVBInfo
->IF_DEF_LVDS
= 1;
1398 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x38, ~0xE0, 0xC0);
1399 xgifb_reg_set(pVBInfo
->P3d4
, 0x30, 0x21);
1401 /* TMDS/DVO setting */
1402 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x38, ~0xE0, 0xA0);
1404 xgifb_reg_or(pVBInfo
->P3d4
, 0x32, LCDSense
);
1408 static unsigned char GetXG21FPBits(struct vb_device_info
*pVBInfo
)
1410 unsigned char CR38
, CR4A
, temp
;
1412 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
1413 /* enable GPIOE read */
1414 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x4A, ~0x10, 0x10);
1415 CR38
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
1417 if ((CR38
& 0xE0) > 0x80) {
1418 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
1423 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
1428 static unsigned char GetXG27FPBits(struct vb_device_info
*pVBInfo
)
1430 unsigned char CR4A
, temp
;
1432 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
1433 /* enable GPIOA/B/C read */
1434 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x4A, ~0x03, 0x03);
1435 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
1439 temp
= ((temp
& 0x04) >> 1) || ((~temp
) & 0x01);
1441 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
1446 unsigned char XGIInitNew(struct pci_dev
*pdev
)
1448 struct xgifb_video_info
*xgifb_info
= pci_get_drvdata(pdev
);
1449 struct xgi_hw_device_info
*HwDeviceExtension
= &xgifb_info
->hw_info
;
1450 struct vb_device_info VBINF
;
1451 struct vb_device_info
*pVBInfo
= &VBINF
;
1452 unsigned char i
, temp
= 0, temp1
;
1453 /* VBIOSVersion[5]; */
1454 volatile unsigned char *pVideoMemory
;
1456 /* unsigned long j, k; */
1458 pVBInfo
->ROMAddr
= HwDeviceExtension
->pjVirtualRomBase
;
1460 pVBInfo
->FBAddr
= HwDeviceExtension
->pjVideoMemoryAddress
;
1462 pVBInfo
->BaseAddr
= (unsigned long) HwDeviceExtension
->pjIOAddress
;
1464 pVideoMemory
= (unsigned char *) pVBInfo
->ROMAddr
;
1466 /* Newdebugcode(0x99); */
1469 /* if (pVBInfo->ROMAddr == 0) */
1472 if (pVBInfo
->FBAddr
== NULL
) {
1473 printk("\n pVBInfo->FBAddr == 0 ");
1477 if (pVBInfo
->BaseAddr
== 0) {
1478 printk("\npVBInfo->BaseAddr == 0 ");
1483 outb(0x67, (pVBInfo
->BaseAddr
+ 0x12)); /* 3c2 <- 67 ,ynlai */
1485 pVBInfo
->ISXPDOS
= 0;
1490 /* VBIOSVersion[4] = 0x0; */
1492 /* 09/07/99 modify by domao */
1494 pVBInfo
->P3c4
= pVBInfo
->BaseAddr
+ 0x14;
1495 pVBInfo
->P3d4
= pVBInfo
->BaseAddr
+ 0x24;
1496 pVBInfo
->P3c0
= pVBInfo
->BaseAddr
+ 0x10;
1497 pVBInfo
->P3ce
= pVBInfo
->BaseAddr
+ 0x1e;
1498 pVBInfo
->P3c2
= pVBInfo
->BaseAddr
+ 0x12;
1499 pVBInfo
->P3ca
= pVBInfo
->BaseAddr
+ 0x1a;
1500 pVBInfo
->P3c6
= pVBInfo
->BaseAddr
+ 0x16;
1501 pVBInfo
->P3c7
= pVBInfo
->BaseAddr
+ 0x17;
1502 pVBInfo
->P3c8
= pVBInfo
->BaseAddr
+ 0x18;
1503 pVBInfo
->P3c9
= pVBInfo
->BaseAddr
+ 0x19;
1504 pVBInfo
->P3da
= pVBInfo
->BaseAddr
+ 0x2A;
1505 pVBInfo
->Part0Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_00
;
1506 pVBInfo
->Part1Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_04
;
1507 pVBInfo
->Part2Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_10
;
1508 pVBInfo
->Part3Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_12
;
1509 pVBInfo
->Part4Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_14
;
1510 pVBInfo
->Part5Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_14
+ 2;
1513 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 */
1514 /* Run XGI_GetVBType before InitTo330Pointer */
1515 XGI_GetVBType(pVBInfo
);
1517 InitTo330Pointer(HwDeviceExtension
->jChipType
, pVBInfo
);
1520 ReadVBIOSTablData(HwDeviceExtension
->jChipType
, pVBInfo
);
1523 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
1526 /* GetXG21Sense (GPIO) */
1527 if (HwDeviceExtension
->jChipType
== XG21
)
1528 XGINew_GetXG21Sense(HwDeviceExtension
, pVBInfo
);
1530 if (HwDeviceExtension
->jChipType
== XG27
)
1531 XGINew_GetXG27Sense(HwDeviceExtension
, pVBInfo
);
1535 /* 2.Reset Extended register */
1537 for (i
= 0x06; i
< 0x20; i
++)
1538 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0);
1540 for (i
= 0x21; i
<= 0x27; i
++)
1541 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0);
1543 /* for(i = 0x06; i <= 0x27; i++) */
1544 /* xgifb_reg_set(pVBInfo->P3c4, i, 0); */
1548 for (i
= 0x31; i
<= 0x3B; i
++)
1549 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0);
1552 /* [Hsuan] 2004/08/20 Auto over driver for XG42 */
1553 if (HwDeviceExtension
->jChipType
== XG42
)
1554 xgifb_reg_set(pVBInfo
->P3c4
, 0x3B, 0xC0);
1556 /* for (i = 0x30; i <= 0x3F; i++) */
1557 /* xgifb_reg_set(pVBInfo->P3d4, i, 0); */
1559 for (i
= 0x79; i
<= 0x7C; i
++)
1560 xgifb_reg_set(pVBInfo
->P3d4
, i
, 0); /* shampoo 0208 */
1564 if (HwDeviceExtension
->jChipType
>= XG20
)
1565 xgifb_reg_set(pVBInfo
->P3d4
, 0x97, *pVBInfo
->pXGINew_CR97
);
1569 pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
1574 /* 4.SetDefExt1Regs begin */
1575 xgifb_reg_set(pVBInfo
->P3c4
, 0x07, *pVBInfo
->pSR07
);
1576 if (HwDeviceExtension
->jChipType
== XG27
) {
1577 xgifb_reg_set(pVBInfo
->P3c4
, 0x40, *pVBInfo
->pSR40
);
1578 xgifb_reg_set(pVBInfo
->P3c4
, 0x41, *pVBInfo
->pSR41
);
1580 xgifb_reg_set(pVBInfo
->P3c4
, 0x11, 0x0F);
1581 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, *pVBInfo
->pSR1F
);
1582 /* xgifb_reg_set(pVBInfo->P3c4, 0x20, 0x20); */
1583 /* alan, 2001/6/26 Frame buffer can read/write SR20 */
1584 xgifb_reg_set(pVBInfo
->P3c4
, 0x20, 0xA0);
1585 /* Hsuan, 2006/01/01 H/W request for slow corner chip */
1586 xgifb_reg_set(pVBInfo
->P3c4
, 0x36, 0x70);
1587 if (HwDeviceExtension
->jChipType
== XG27
) /* Alan 12/07/2006 */
1588 xgifb_reg_set(pVBInfo
->P3c4
, 0x36, *pVBInfo
->pSR36
);
1591 /* xgifb_reg_set(pVBInfo->P3c4, 0x11, SR11); */
1595 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
1600 temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
1602 if (temp1 == 0x02) {
1603 outl(0x80000000, 0xcf8);
1604 ChipsetID = inl(0x0cfc);
1605 outl(0x8000002C, 0xcf8);
1606 VendorID = inl(0x0cfc);
1607 VendorID &= 0x0000FFFF;
1608 outl(0x8001002C, 0xcf8);
1609 GraphicVendorID = inl(0x0cfc);
1610 GraphicVendorID &= 0x0000FFFF;
1612 if (ChipsetID == 0x7301039)
1613 xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x09);
1615 ChipsetID &= 0x0000FFFF;
1617 if ((ChipsetID == 0x700E) ||
1618 (ChipsetID == 0x1022) ||
1619 (ChipsetID == 0x1106) ||
1620 (ChipsetID == 0x10DE)) {
1621 if (ChipsetID == 0x1106) {
1622 if ((VendorID == 0x1019) &&
1623 (GraphicVendorID == 0x1019))
1624 xgifb_reg_set(pVBInfo->P3d4,
1628 xgifb_reg_set(pVBInfo->P3d4,
1632 xgifb_reg_set(pVBInfo->P3d4,
1642 /* Set AGP customize registers (in SetDefAGPRegs) Start */
1643 for (i
= 0x47; i
<= 0x4C; i
++)
1644 xgifb_reg_set(pVBInfo
->P3d4
,
1646 pVBInfo
->AGPReg
[i
- 0x47]);
1648 for (i
= 0x70; i
<= 0x71; i
++)
1649 xgifb_reg_set(pVBInfo
->P3d4
,
1651 pVBInfo
->AGPReg
[6 + i
- 0x70]);
1653 for (i
= 0x74; i
<= 0x77; i
++)
1654 xgifb_reg_set(pVBInfo
->P3d4
,
1656 pVBInfo
->AGPReg
[8 + i
- 0x74]);
1657 /* Set AGP customize registers (in SetDefAGPRegs) End */
1658 /* [Hsuan]2004/12/14 AGP Input Delay Adjustment on 850 */
1659 /* outl(0x80000000, 0xcf8); */
1660 /* ChipsetID = inl(0x0cfc); */
1661 /* if (ChipsetID == 0x25308086) */
1662 /* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */
1664 pci_read_config_dword(pdev
, 0x50, &Temp
);
1669 xgifb_reg_set(pVBInfo
->P3d4
, 0x48, 0x20); /* CR48 */
1674 xgifb_reg_set(pVBInfo
->P3c4
, 0x23, *pVBInfo
->pSR23
);
1675 xgifb_reg_set(pVBInfo
->P3c4
, 0x24, *pVBInfo
->pSR24
);
1676 xgifb_reg_set(pVBInfo
->P3c4
, 0x25, pVBInfo
->SR25
[0]);
1679 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
1681 XGI_UnLockCRT2(HwDeviceExtension
, pVBInfo
);
1682 /* alan, disable VideoCapture */
1683 xgifb_reg_and_or(pVBInfo
->Part0Port
, 0x3F, 0xEF, 0x00);
1684 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, 0x00);
1685 /* chk if BCLK>=100MHz */
1686 temp1
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x7B);
1687 temp
= (unsigned char) ((temp1
>> 4) & 0x0F);
1689 xgifb_reg_set(pVBInfo
->Part1Port
,
1691 (*pVBInfo
->pCRT2Data_1_2
));
1695 xgifb_reg_set(pVBInfo
->Part1Port
, 0x2E, 0x08); /* use VB */
1698 xgifb_reg_set(pVBInfo
->P3c4
, 0x27, 0x1F);
1700 if ((HwDeviceExtension
->jChipType
== XG42
) &&
1701 XGINew_GetXG20DRAMType(HwDeviceExtension
, pVBInfo
) != 0) {
1703 xgifb_reg_set(pVBInfo
->P3c4
,
1705 (*pVBInfo
->pSR31
& 0x3F) | 0x40);
1706 xgifb_reg_set(pVBInfo
->P3c4
,
1708 (*pVBInfo
->pSR32
& 0xFC) | 0x01);
1710 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, *pVBInfo
->pSR31
);
1711 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, *pVBInfo
->pSR32
);
1713 xgifb_reg_set(pVBInfo
->P3c4
, 0x33, *pVBInfo
->pSR33
);
1717 SetPowerConsume (HwDeviceExtension, pVBInfo->P3c4); */
1719 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
1720 if (XGI_BridgeIsOn(pVBInfo
) == 1) {
1721 if (pVBInfo
->IF_DEF_LVDS
== 0) {
1722 xgifb_reg_set(pVBInfo
->Part2Port
, 0x00, 0x1C);
1723 xgifb_reg_set(pVBInfo
->Part4Port
,
1725 *pVBInfo
->pCRT2Data_4_D
);
1726 xgifb_reg_set(pVBInfo
->Part4Port
,
1728 *pVBInfo
->pCRT2Data_4_E
);
1729 xgifb_reg_set(pVBInfo
->Part4Port
,
1731 *pVBInfo
->pCRT2Data_4_10
);
1732 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0F, 0x3F);
1735 XGI_LockCRT2(HwDeviceExtension
, pVBInfo
);
1744 XGI_SenseCRT1(pVBInfo
);
1747 /* XGINew_DetectMonitor(HwDeviceExtension); */
1748 if (HwDeviceExtension
->jChipType
== XG21
) {
1751 xgifb_reg_and_or(pVBInfo
->P3d4
,
1754 Monitor1Sense
); /* Z9 default has CRT */
1755 temp
= GetXG21FPBits(pVBInfo
);
1756 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x37, ~0x01, temp
);
1760 if (HwDeviceExtension
->jChipType
== XG27
) {
1761 xgifb_reg_and_or(pVBInfo
->P3d4
,
1764 Monitor1Sense
); /* Z9 default has CRT */
1765 temp
= GetXG27FPBits(pVBInfo
);
1766 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x37, ~0x03, temp
);
1770 pVBInfo
->ram_type
= XGINew_GetXG20DRAMType(HwDeviceExtension
, pVBInfo
);
1772 XGINew_SetDRAMDefaultRegister340(HwDeviceExtension
,
1777 XGINew_SetDRAMSize_340(HwDeviceExtension
, pVBInfo
);
1782 /* SetDefExt2Regs begin */
1785 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x3A);
1791 *pVBInfo->pSR21 &= 0xEF;
1793 xgifb_reg_set(pVBInfo->P3c4, 0x21, *pVBInfo->pSR21);
1795 *pVBInfo->pSR22 &= 0x20;
1796 xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22);
1798 /* base = 0x80000000; */
1799 /* OutPortLong(0xcf8, base); */
1800 /* Temp = (InPortLong(0xcfc) & 0xFFFF); */
1801 /* if (Temp == 0x1039) { */
1802 xgifb_reg_set(pVBInfo
->P3c4
,
1804 (unsigned char) ((*pVBInfo
->pSR22
) & 0xFE));
1806 /* xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22); */
1809 xgifb_reg_set(pVBInfo
->P3c4
, 0x21, *pVBInfo
->pSR21
);
1813 XGINew_ChkSenseStatus(HwDeviceExtension
, pVBInfo
);
1814 XGINew_SetModeScratch(HwDeviceExtension
, pVBInfo
);
1818 xgifb_reg_set(pVBInfo
->P3d4
, 0x8c, 0x87);
1819 xgifb_reg_set(pVBInfo
->P3c4
, 0x14, 0x31);