apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1 | #include "vgatypes.h" |
| 2 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 3 | #include <linux/types.h> |
| 4 | #include <linux/delay.h> /* udelay */ |
| 5 | #include "XGIfb.h" |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 6 | |
| 7 | #include "vb_def.h" |
| 8 | #include "vb_struct.h" |
| 9 | #include "vb_util.h" |
| 10 | #include "vb_setmode.h" |
| 11 | #include "vb_init.h" |
| 12 | #include "vb_ext.h" |
| 13 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 14 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 15 | #include <linux/io.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 16 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 17 | static unsigned char XGINew_ChannelAB, XGINew_DataBusWidth; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 18 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 19 | static unsigned short XGINew_DDRDRAM_TYPE340[4][5] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 20 | { 2, 13, 9, 64, 0x45}, |
| 21 | { 2, 12, 9, 32, 0x35}, |
| 22 | { 2, 12, 8, 16, 0x31}, |
| 23 | { 2, 11, 8, 8, 0x21} }; |
| 24 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 25 | static unsigned short XGINew_DDRDRAM_TYPE20[12][5] = { |
Bill Pemberton | 82d6eb5 | 2010-06-17 13:10:46 -0400 | [diff] [blame] | 26 | { 2, 14, 11, 128, 0x5D}, |
| 27 | { 2, 14, 10, 64, 0x59}, |
| 28 | { 2, 13, 11, 64, 0x4D}, |
| 29 | { 2, 14, 9, 32, 0x55}, |
| 30 | { 2, 13, 10, 32, 0x49}, |
| 31 | { 2, 12, 11, 32, 0x3D}, |
| 32 | { 2, 14, 8, 16, 0x51}, |
| 33 | { 2, 13, 9, 16, 0x45}, |
| 34 | { 2, 12, 10, 16, 0x39}, |
| 35 | { 2, 13, 8, 8, 0x41}, |
| 36 | { 2, 12, 9, 8, 0x35}, |
| 37 | { 2, 12, 8, 4, 0x31} }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 38 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 39 | static int XGINew_RAMType; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 40 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 41 | static unsigned char |
| 42 | XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension, |
| 43 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 44 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 45 | unsigned char data, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 46 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 47 | if (HwDeviceExtension->jChipType < XG20) { |
| 48 | if (*pVBInfo->pSoftSetting & SoftDRAMType) { |
| 49 | data = *pVBInfo->pSoftSetting & 0x07; |
| 50 | return data; |
| 51 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 52 | data = xgifb_reg_get(pVBInfo->P3c4, 0x39) & 0x02; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 53 | if (data == 0) |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 54 | data = (xgifb_reg_get(pVBInfo->P3c4, 0x3A) & |
| 55 | 0x02) >> 1; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 56 | return data; |
| 57 | } |
| 58 | } else if (HwDeviceExtension->jChipType == XG27) { |
| 59 | if (*pVBInfo->pSoftSetting & SoftDRAMType) { |
| 60 | data = *pVBInfo->pSoftSetting & 0x07; |
| 61 | return data; |
| 62 | } |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 63 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 64 | /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */ |
| 65 | if ((temp & 0x88) == 0x80) |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 66 | data = 0; /* DDR */ |
| 67 | else |
| 68 | data = 1; /* DDRII */ |
| 69 | return data; |
| 70 | } else if (HwDeviceExtension->jChipType == XG21) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 71 | /* Independent GPIO control */ |
| 72 | xgifb_reg_and(pVBInfo->P3d4, 0xB4, ~0x02); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 73 | udelay(800); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 74 | xgifb_reg_or(pVBInfo->P3d4, 0x4A, 0x80); /* Enable GPIOH read */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 75 | /* GPIOF 0:DVI 1:DVO */ |
| 76 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 77 | /* HOTPLUG_SUPPORT */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 78 | /* for current XG20 & XG21, GPIOH is floating, driver will |
| 79 | * fix DDR temporarily */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 80 | if (temp & 0x01) /* DVI read GPIOH */ |
| 81 | data = 1; /* DDRII */ |
| 82 | else |
| 83 | data = 0; /* DDR */ |
| 84 | /* ~HOTPLUG_SUPPORT */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 85 | xgifb_reg_or(pVBInfo->P3d4, 0xB4, 0x02); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 86 | return data; |
| 87 | } else { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 88 | data = xgifb_reg_get(pVBInfo->P3d4, 0x97) & 0x01; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 89 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 90 | if (data == 1) |
| 91 | data++; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 92 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 93 | return data; |
| 94 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 95 | } |
| 96 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 97 | static void XGINew_DDR1x_MRS_340(unsigned long P3c4, |
| 98 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 99 | { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 100 | xgifb_reg_set(P3c4, 0x18, 0x01); |
| 101 | xgifb_reg_set(P3c4, 0x19, 0x20); |
| 102 | xgifb_reg_set(P3c4, 0x16, 0x00); |
| 103 | xgifb_reg_set(P3c4, 0x16, 0x80); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 104 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 105 | if (*pVBInfo->pXGINew_DRAMTypeDefinition != 0x0C) { /* Samsung F Die */ |
Aaro Koskinen | c83c620 | 2011-03-13 12:26:14 +0200 | [diff] [blame] | 106 | mdelay(3); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 107 | xgifb_reg_set(P3c4, 0x18, 0x00); |
| 108 | xgifb_reg_set(P3c4, 0x19, 0x20); |
| 109 | xgifb_reg_set(P3c4, 0x16, 0x00); |
| 110 | xgifb_reg_set(P3c4, 0x16, 0x80); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 111 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 112 | |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 113 | udelay(60); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 114 | xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ |
| 115 | xgifb_reg_set(P3c4, 0x19, 0x01); |
| 116 | xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[0]); |
| 117 | xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[1]); |
Aaro Koskinen | c83c620 | 2011-03-13 12:26:14 +0200 | [diff] [blame] | 118 | mdelay(1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 119 | xgifb_reg_set(P3c4, 0x1B, 0x03); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 120 | udelay(500); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 121 | xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ |
| 122 | xgifb_reg_set(P3c4, 0x19, 0x00); |
| 123 | xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[2]); |
| 124 | xgifb_reg_set(P3c4, 0x16, pVBInfo->SR16[3]); |
| 125 | xgifb_reg_set(P3c4, 0x1B, 0x00); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 126 | } |
| 127 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 128 | static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension, |
| 129 | struct vb_device_info *pVBInfo) |
| 130 | { |
| 131 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 132 | xgifb_reg_set(pVBInfo->P3c4, |
| 133 | 0x28, |
| 134 | pVBInfo->MCLKData[XGINew_RAMType].SR28); |
| 135 | xgifb_reg_set(pVBInfo->P3c4, |
| 136 | 0x29, |
| 137 | pVBInfo->MCLKData[XGINew_RAMType].SR29); |
| 138 | xgifb_reg_set(pVBInfo->P3c4, |
| 139 | 0x2A, |
| 140 | pVBInfo->MCLKData[XGINew_RAMType].SR2A); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 141 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 142 | xgifb_reg_set(pVBInfo->P3c4, |
| 143 | 0x2E, |
| 144 | pVBInfo->ECLKData[XGINew_RAMType].SR2E); |
| 145 | xgifb_reg_set(pVBInfo->P3c4, |
| 146 | 0x2F, |
| 147 | pVBInfo->ECLKData[XGINew_RAMType].SR2F); |
| 148 | xgifb_reg_set(pVBInfo->P3c4, |
| 149 | 0x30, |
| 150 | pVBInfo->ECLKData[XGINew_RAMType].SR30); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 151 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 152 | /* [Vicent] 2004/07/07, |
| 153 | * When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */ |
| 154 | /* [Hsuan] 2004/08/20, |
| 155 | * Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz, |
| 156 | * Set SR32 D[1:0] = 10b */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 157 | if (HwDeviceExtension->jChipType == XG42) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 158 | if ((pVBInfo->MCLKData[XGINew_RAMType].SR28 == 0x1C) && |
| 159 | (pVBInfo->MCLKData[XGINew_RAMType].SR29 == 0x01) && |
| 160 | (((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x1C) && |
| 161 | (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01)) || |
| 162 | ((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x22) && |
| 163 | (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01)))) |
| 164 | xgifb_reg_set(pVBInfo->P3c4, |
| 165 | 0x32, |
| 166 | ((unsigned char) xgifb_reg_get( |
| 167 | pVBInfo->P3c4, 0x32) & 0xFC) | 0x02); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 171 | static void XGINew_DDRII_Bootup_XG27( |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 172 | struct xgi_hw_device_info *HwDeviceExtension, |
| 173 | unsigned long P3c4, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 174 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 175 | unsigned long P3d4 = P3c4 + 0x10; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 176 | XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, |
| 177 | pVBInfo); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 178 | XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 179 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 180 | /* Set Double Frequency */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 181 | /* xgifb_reg_set(P3d4, 0x97, 0x11); *//* CR97 */ |
| 182 | xgifb_reg_set(P3d4, 0x97, *pVBInfo->pXGINew_CR97); /* CR97 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 183 | |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 184 | udelay(200); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 185 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 189 | udelay(15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 190 | xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 191 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 192 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 196 | udelay(15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 197 | xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 198 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 199 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 203 | udelay(30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 204 | xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 205 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 206 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 210 | udelay(30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 211 | xgifb_reg_set(P3c4, 0x16, 0x00); /* Set SR16 */ |
| 212 | xgifb_reg_set(P3c4, 0x16, 0x80); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 213 | /* udelay(15); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 214 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 215 | xgifb_reg_set(P3c4, 0x1B, 0x04); /* Set SR1B */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 216 | udelay(60); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 217 | xgifb_reg_set(P3c4, 0x1B, 0x00); /* Set SR1B */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 218 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 222 | |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 223 | udelay(30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 224 | xgifb_reg_set(P3c4, 0x16, 0x83); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 225 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 226 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 230 | udelay(30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 231 | xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 232 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 233 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 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 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 237 | udelay(30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 238 | xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 239 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 240 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 241 | /* Set SR1B refresh control 000:close; 010:open */ |
| 242 | xgifb_reg_set(P3c4, 0x1B, 0x04); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 243 | udelay(200); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 244 | |
| 245 | } |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 246 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 247 | static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 248 | unsigned long P3c4, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 249 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 250 | unsigned long P3d4 = P3c4 + 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 251 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 252 | XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, |
| 253 | pVBInfo); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 254 | XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 255 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 256 | xgifb_reg_set(P3d4, 0x97, 0x11); /* CR97 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 257 | |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 258 | udelay(200); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 259 | xgifb_reg_set(P3c4, 0x18, 0x00); /* EMRS2 */ |
| 260 | xgifb_reg_set(P3c4, 0x19, 0x80); |
| 261 | xgifb_reg_set(P3c4, 0x16, 0x05); |
| 262 | xgifb_reg_set(P3c4, 0x16, 0x85); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 263 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 264 | xgifb_reg_set(P3c4, 0x18, 0x00); /* EMRS3 */ |
| 265 | xgifb_reg_set(P3c4, 0x19, 0xC0); |
| 266 | xgifb_reg_set(P3c4, 0x16, 0x05); |
| 267 | xgifb_reg_set(P3c4, 0x16, 0x85); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 268 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 269 | xgifb_reg_set(P3c4, 0x18, 0x00); /* EMRS1 */ |
| 270 | xgifb_reg_set(P3c4, 0x19, 0x40); |
| 271 | xgifb_reg_set(P3c4, 0x16, 0x05); |
| 272 | xgifb_reg_set(P3c4, 0x16, 0x85); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 273 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 274 | /* xgifb_reg_set(P3c4, 0x18, 0x52); */ /* MRS1 */ |
| 275 | xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */ |
| 276 | xgifb_reg_set(P3c4, 0x19, 0x02); |
| 277 | xgifb_reg_set(P3c4, 0x16, 0x05); |
| 278 | xgifb_reg_set(P3c4, 0x16, 0x85); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 279 | |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 280 | udelay(15); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 281 | xgifb_reg_set(P3c4, 0x1B, 0x04); /* SR1B */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 282 | udelay(30); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 283 | xgifb_reg_set(P3c4, 0x1B, 0x00); /* SR1B */ |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 284 | udelay(100); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 285 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 286 | /* xgifb_reg_set(P3c4 ,0x18, 0x52); */ /* MRS2 */ |
| 287 | xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */ |
| 288 | xgifb_reg_set(P3c4, 0x19, 0x00); |
| 289 | xgifb_reg_set(P3c4, 0x16, 0x05); |
| 290 | xgifb_reg_set(P3c4, 0x16, 0x85); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 291 | |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 292 | udelay(200); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 293 | } |
| 294 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 295 | static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4, |
| 296 | struct vb_device_info *pVBInfo) |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 297 | { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 298 | xgifb_reg_set(P3c4, 0x18, 0x01); |
| 299 | xgifb_reg_set(P3c4, 0x19, 0x40); |
| 300 | xgifb_reg_set(P3c4, 0x16, 0x00); |
| 301 | xgifb_reg_set(P3c4, 0x16, 0x80); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 302 | udelay(60); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 303 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 304 | xgifb_reg_set(P3c4, 0x18, 0x00); |
| 305 | xgifb_reg_set(P3c4, 0x19, 0x40); |
| 306 | xgifb_reg_set(P3c4, 0x16, 0x00); |
| 307 | xgifb_reg_set(P3c4, 0x16, 0x80); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 308 | udelay(60); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 309 | xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ |
| 310 | /* xgifb_reg_set(P3c4, 0x18, 0x31); */ |
| 311 | xgifb_reg_set(P3c4, 0x19, 0x01); |
| 312 | xgifb_reg_set(P3c4, 0x16, 0x03); |
| 313 | xgifb_reg_set(P3c4, 0x16, 0x83); |
Aaro Koskinen | c83c620 | 2011-03-13 12:26:14 +0200 | [diff] [blame] | 314 | mdelay(1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 315 | xgifb_reg_set(P3c4, 0x1B, 0x03); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 316 | udelay(500); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 317 | /* xgifb_reg_set(P3c4, 0x18, 0x31); */ |
| 318 | xgifb_reg_set(P3c4, 0x18, pVBInfo->SR15[2][XGINew_RAMType]); /* SR18 */ |
| 319 | xgifb_reg_set(P3c4, 0x19, 0x00); |
| 320 | xgifb_reg_set(P3c4, 0x16, 0x03); |
| 321 | xgifb_reg_set(P3c4, 0x16, 0x83); |
| 322 | xgifb_reg_set(P3c4, 0x1B, 0x00); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 325 | static void XGINew_DDR1x_DefaultRegister( |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 326 | struct xgi_hw_device_info *HwDeviceExtension, |
| 327 | unsigned long Port, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 328 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 329 | unsigned long P3d4 = Port, P3c4 = Port - 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 330 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 331 | if (HwDeviceExtension->jChipType >= XG20) { |
| 332 | XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 333 | xgifb_reg_set(P3d4, |
| 334 | 0x82, |
| 335 | pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */ |
| 336 | xgifb_reg_set(P3d4, |
| 337 | 0x85, |
| 338 | pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */ |
| 339 | xgifb_reg_set(P3d4, |
| 340 | 0x86, |
| 341 | pVBInfo->CR40[13][XGINew_RAMType]); /* CR86 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 342 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 343 | xgifb_reg_set(P3d4, 0x98, 0x01); |
| 344 | xgifb_reg_set(P3d4, 0x9A, 0x02); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 345 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 346 | XGINew_DDR1x_MRS_XG20(P3c4, pVBInfo); |
| 347 | } else { |
| 348 | XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 349 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 350 | switch (HwDeviceExtension->jChipType) { |
| 351 | case XG41: |
| 352 | case XG42: |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 353 | /* CR82 */ |
| 354 | xgifb_reg_set(P3d4, |
| 355 | 0x82, |
| 356 | pVBInfo->CR40[11][XGINew_RAMType]); |
| 357 | /* CR85 */ |
| 358 | xgifb_reg_set(P3d4, |
| 359 | 0x85, |
| 360 | pVBInfo->CR40[12][XGINew_RAMType]); |
| 361 | /* CR86 */ |
| 362 | xgifb_reg_set(P3d4, |
| 363 | 0x86, |
| 364 | pVBInfo->CR40[13][XGINew_RAMType]); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 365 | break; |
| 366 | default: |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 367 | xgifb_reg_set(P3d4, 0x82, 0x88); |
| 368 | xgifb_reg_set(P3d4, 0x86, 0x00); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 369 | /* Insert read command for delay */ |
| 370 | xgifb_reg_get(P3d4, 0x86); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 371 | xgifb_reg_set(P3d4, 0x86, 0x88); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 372 | xgifb_reg_get(P3d4, 0x86); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 373 | xgifb_reg_set(P3d4, |
| 374 | 0x86, |
| 375 | pVBInfo->CR40[13][XGINew_RAMType]); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 376 | xgifb_reg_set(P3d4, 0x82, 0x77); |
| 377 | xgifb_reg_set(P3d4, 0x85, 0x00); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 378 | |
| 379 | /* Insert read command for delay */ |
| 380 | xgifb_reg_get(P3d4, 0x85); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 381 | xgifb_reg_set(P3d4, 0x85, 0x88); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 382 | |
| 383 | /* Insert read command for delay */ |
| 384 | xgifb_reg_get(P3d4, 0x85); |
| 385 | /* CR85 */ |
| 386 | xgifb_reg_set(P3d4, |
| 387 | 0x85, |
| 388 | pVBInfo->CR40[12][XGINew_RAMType]); |
| 389 | /* CR82 */ |
| 390 | xgifb_reg_set(P3d4, |
| 391 | 0x82, |
| 392 | pVBInfo->CR40[11][XGINew_RAMType]); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 393 | break; |
| 394 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 395 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 396 | xgifb_reg_set(P3d4, 0x97, 0x00); |
| 397 | xgifb_reg_set(P3d4, 0x98, 0x01); |
| 398 | xgifb_reg_set(P3d4, 0x9A, 0x02); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 399 | XGINew_DDR1x_MRS_340(P3c4, pVBInfo); |
| 400 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 401 | } |
| 402 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 403 | static void XGINew_DDR2_DefaultRegister( |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 404 | struct xgi_hw_device_info *HwDeviceExtension, |
| 405 | unsigned long Port, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 406 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 407 | unsigned long P3d4 = Port, P3c4 = Port - 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 408 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 409 | /* keep following setting sequence, each setting in |
| 410 | * the same reg insert idle */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 411 | xgifb_reg_set(P3d4, 0x82, 0x77); |
| 412 | xgifb_reg_set(P3d4, 0x86, 0x00); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 413 | xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 414 | xgifb_reg_set(P3d4, 0x86, 0x88); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 415 | xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 416 | /* CR86 */ |
| 417 | xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 418 | xgifb_reg_set(P3d4, 0x82, 0x77); |
| 419 | xgifb_reg_set(P3d4, 0x85, 0x00); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 420 | xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 421 | xgifb_reg_set(P3d4, 0x85, 0x88); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 422 | xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 423 | xgifb_reg_set(P3d4, 0x85, pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 424 | if (HwDeviceExtension->jChipType == XG27) |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 425 | /* CR82 */ |
| 426 | xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 427 | else |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 428 | xgifb_reg_set(P3d4, 0x82, 0xA8); /* CR82 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 429 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 430 | xgifb_reg_set(P3d4, 0x98, 0x01); |
| 431 | xgifb_reg_set(P3d4, 0x9A, 0x02); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 432 | if (HwDeviceExtension->jChipType == XG27) |
| 433 | XGINew_DDRII_Bootup_XG27(HwDeviceExtension, P3c4, pVBInfo); |
| 434 | else |
| 435 | XGINew_DDR2_MRS_XG20(HwDeviceExtension, P3c4, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 436 | } |
| 437 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 438 | static void XGINew_SetDRAMDefaultRegister340( |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 439 | struct xgi_hw_device_info *HwDeviceExtension, |
| 440 | unsigned long Port, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 441 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 442 | unsigned char temp, temp1, temp2, temp3, i, j, k; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 443 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 444 | unsigned long P3d4 = Port, P3c4 = Port - 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 445 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 446 | xgifb_reg_set(P3d4, 0x6D, pVBInfo->CR40[8][XGINew_RAMType]); |
| 447 | xgifb_reg_set(P3d4, 0x68, pVBInfo->CR40[5][XGINew_RAMType]); |
| 448 | xgifb_reg_set(P3d4, 0x69, pVBInfo->CR40[6][XGINew_RAMType]); |
| 449 | xgifb_reg_set(P3d4, 0x6A, pVBInfo->CR40[7][XGINew_RAMType]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 450 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 451 | temp2 = 0; |
| 452 | for (i = 0; i < 4; i++) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 453 | /* CR6B DQS fine tune delay */ |
| 454 | temp = pVBInfo->CR6B[XGINew_RAMType][i]; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 455 | for (j = 0; j < 4; j++) { |
| 456 | temp1 = ((temp >> (2 * j)) & 0x03) << 2; |
| 457 | temp2 |= temp1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 458 | xgifb_reg_set(P3d4, 0x6B, temp2); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 459 | /* Insert read command for delay */ |
| 460 | xgifb_reg_get(P3d4, 0x6B); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 461 | temp2 &= 0xF0; |
| 462 | temp2 += 0x10; |
| 463 | } |
| 464 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 465 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 466 | temp2 = 0; |
| 467 | for (i = 0; i < 4; i++) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 468 | /* CR6E DQM fine tune delay */ |
| 469 | temp = pVBInfo->CR6E[XGINew_RAMType][i]; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 470 | for (j = 0; j < 4; j++) { |
| 471 | temp1 = ((temp >> (2 * j)) & 0x03) << 2; |
| 472 | temp2 |= temp1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 473 | xgifb_reg_set(P3d4, 0x6E, temp2); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 474 | /* Insert read command for delay */ |
| 475 | xgifb_reg_get(P3d4, 0x6E); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 476 | temp2 &= 0xF0; |
| 477 | temp2 += 0x10; |
| 478 | } |
| 479 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 480 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 481 | temp3 = 0; |
| 482 | for (k = 0; k < 4; k++) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 483 | /* CR6E_D[1:0] select channel */ |
| 484 | xgifb_reg_and_or(P3d4, 0x6E, 0xFC, temp3); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 485 | temp2 = 0; |
| 486 | for (i = 0; i < 8; i++) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 487 | /* CR6F DQ fine tune delay */ |
| 488 | temp = pVBInfo->CR6F[XGINew_RAMType][8 * k + i]; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 489 | for (j = 0; j < 4; j++) { |
| 490 | temp1 = (temp >> (2 * j)) & 0x03; |
| 491 | temp2 |= temp1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 492 | xgifb_reg_set(P3d4, 0x6F, temp2); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 493 | /* Insert read command for delay */ |
| 494 | xgifb_reg_get(P3d4, 0x6F); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 495 | temp2 &= 0xF8; |
| 496 | temp2 += 0x08; |
| 497 | } |
| 498 | } |
| 499 | temp3 += 0x01; |
| 500 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 501 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 502 | xgifb_reg_set(P3d4, 0x80, pVBInfo->CR40[9][XGINew_RAMType]); /* CR80 */ |
| 503 | xgifb_reg_set(P3d4, 0x81, pVBInfo->CR40[10][XGINew_RAMType]); /* CR81 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 504 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 505 | temp2 = 0x80; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 506 | /* CR89 terminator type select */ |
| 507 | temp = pVBInfo->CR89[XGINew_RAMType][0]; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 508 | for (j = 0; j < 4; j++) { |
| 509 | temp1 = (temp >> (2 * j)) & 0x03; |
| 510 | temp2 |= temp1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 511 | xgifb_reg_set(P3d4, 0x89, temp2); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 512 | xgifb_reg_get(P3d4, 0x89); /* Insert read command for delay */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 513 | temp2 &= 0xF0; |
| 514 | temp2 += 0x10; |
| 515 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 516 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 517 | temp = pVBInfo->CR89[XGINew_RAMType][1]; |
| 518 | temp1 = temp & 0x03; |
| 519 | temp2 |= temp1; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 520 | xgifb_reg_set(P3d4, 0x89, temp2); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 521 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 522 | temp = pVBInfo->CR40[3][XGINew_RAMType]; |
| 523 | temp1 = temp & 0x0F; |
| 524 | temp2 = (temp >> 4) & 0x07; |
| 525 | temp3 = temp & 0x80; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 526 | xgifb_reg_set(P3d4, 0x45, temp1); /* CR45 */ |
| 527 | xgifb_reg_set(P3d4, 0x99, temp2); /* CR99 */ |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 528 | xgifb_reg_or(P3d4, 0x40, temp3); /* CR40_D[7] */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 529 | xgifb_reg_set(P3d4, 0x41, pVBInfo->CR40[0][XGINew_RAMType]); /* CR41 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 530 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 531 | if (HwDeviceExtension->jChipType == XG27) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 532 | xgifb_reg_set(P3d4, 0x8F, *pVBInfo->pCR8F); /* CR8F */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 533 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 534 | for (j = 0; j <= 6; j++) /* CR90 - CR96 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 535 | xgifb_reg_set(P3d4, (0x90 + j), |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 536 | pVBInfo->CR40[14 + j][XGINew_RAMType]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 537 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 538 | for (j = 0; j <= 2; j++) /* CRC3 - CRC5 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 539 | xgifb_reg_set(P3d4, (0xC3 + j), |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 540 | pVBInfo->CR40[21 + j][XGINew_RAMType]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 541 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 542 | for (j = 0; j < 2; j++) /* CR8A - CR8B */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 543 | xgifb_reg_set(P3d4, (0x8A + j), |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 544 | pVBInfo->CR40[1 + j][XGINew_RAMType]); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 545 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 546 | if ((HwDeviceExtension->jChipType == XG41) || |
| 547 | (HwDeviceExtension->jChipType == XG42)) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 548 | xgifb_reg_set(P3d4, 0x8C, 0x87); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 549 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 550 | xgifb_reg_set(P3d4, 0x59, pVBInfo->CR40[4][XGINew_RAMType]); /* CR59 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 551 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 552 | xgifb_reg_set(P3d4, 0x83, 0x09); /* CR83 */ |
| 553 | xgifb_reg_set(P3d4, 0x87, 0x00); /* CR87 */ |
| 554 | xgifb_reg_set(P3d4, 0xCF, *pVBInfo->pCRCF); /* CRCF */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 555 | if (XGINew_RAMType) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 556 | /* xgifb_reg_set(P3c4, 0x17, 0xC0); */ /* SR17 DDRII */ |
| 557 | xgifb_reg_set(P3c4, 0x17, 0x80); /* SR17 DDRII */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 558 | if (HwDeviceExtension->jChipType == XG27) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 559 | xgifb_reg_set(P3c4, 0x17, 0x02); /* SR17 DDRII */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 560 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 561 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 562 | xgifb_reg_set(P3c4, 0x17, 0x00); /* SR17 DDR */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 563 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 564 | xgifb_reg_set(P3c4, 0x1A, 0x87); /* SR1A */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 565 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 566 | temp = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); |
| 567 | if (temp == 0) { |
| 568 | XGINew_DDR1x_DefaultRegister(HwDeviceExtension, P3d4, pVBInfo); |
| 569 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 570 | xgifb_reg_set(P3d4, 0xB0, 0x80); /* DDRII Dual frequency mode */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 571 | XGINew_DDR2_DefaultRegister(HwDeviceExtension, P3d4, pVBInfo); |
| 572 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 573 | xgifb_reg_set(P3c4, 0x1B, pVBInfo->SR15[3][XGINew_RAMType]); /* SR1B */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 574 | } |
| 575 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 576 | static void XGINew_SetDRAMSizingType(int index, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 577 | unsigned short DRAMTYPE_TABLE[][5], |
| 578 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 579 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 580 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 581 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 582 | data = DRAMTYPE_TABLE[index][4]; |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 583 | xgifb_reg_and_or(pVBInfo->P3c4, 0x13, 0x80, data); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 584 | udelay(15); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 585 | /* should delay 50 ns */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 586 | } |
| 587 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 588 | static unsigned short XGINew_SetDRAMSizeReg(int index, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 589 | unsigned short DRAMTYPE_TABLE[][5], |
| 590 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 591 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 592 | unsigned short data = 0, memsize = 0; |
| 593 | int RankSize; |
| 594 | unsigned char ChannelNo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 595 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 596 | RankSize = DRAMTYPE_TABLE[index][3] * XGINew_DataBusWidth / 32; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 597 | data = xgifb_reg_get(pVBInfo->P3c4, 0x13); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 598 | data &= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 599 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 600 | if (data == 0x80) |
| 601 | RankSize *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 602 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 603 | data = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 604 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 605 | if (XGINew_ChannelAB == 3) |
| 606 | ChannelNo = 4; |
| 607 | else |
| 608 | ChannelNo = XGINew_ChannelAB; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 609 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 610 | if (ChannelNo * RankSize <= 256) { |
| 611 | while ((RankSize >>= 1) > 0) |
| 612 | data += 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 613 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 614 | memsize = data >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 615 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 616 | /* [2004/03/25] Vicent, Fix DRAM Sizing Error */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 617 | xgifb_reg_set(pVBInfo->P3c4, |
| 618 | 0x14, |
| 619 | (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) | |
| 620 | (data & 0xF0)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 621 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 622 | /* data |= XGINew_ChannelAB << 2; */ |
| 623 | /* data |= (XGINew_DataBusWidth / 64) << 1; */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 624 | /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 625 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 626 | /* should delay */ |
| 627 | /* XGINew_SetDRAMModeRegister340(pVBInfo); */ |
| 628 | } |
| 629 | return memsize; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 630 | } |
| 631 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 632 | static unsigned short XGINew_SetDRAMSize20Reg(int index, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 633 | unsigned short DRAMTYPE_TABLE[][5], |
| 634 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 635 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 636 | unsigned short data = 0, memsize = 0; |
| 637 | int RankSize; |
| 638 | unsigned char ChannelNo; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 639 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 640 | RankSize = DRAMTYPE_TABLE[index][3] * XGINew_DataBusWidth / 8; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 641 | data = xgifb_reg_get(pVBInfo->P3c4, 0x13); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 642 | data &= 0x80; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 643 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 644 | if (data == 0x80) |
| 645 | RankSize *= 2; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 646 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 647 | data = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 648 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 649 | if (XGINew_ChannelAB == 3) |
| 650 | ChannelNo = 4; |
| 651 | else |
| 652 | ChannelNo = XGINew_ChannelAB; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 653 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 654 | if (ChannelNo * RankSize <= 256) { |
| 655 | while ((RankSize >>= 1) > 0) |
| 656 | data += 0x10; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 657 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 658 | memsize = data >> 4; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 659 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 660 | /* [2004/03/25] Vicent, Fix DRAM Sizing Error */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 661 | xgifb_reg_set(pVBInfo->P3c4, |
| 662 | 0x14, |
| 663 | (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) | |
| 664 | (data & 0xF0)); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 665 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 666 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 667 | /* data |= XGINew_ChannelAB << 2; */ |
| 668 | /* data |= (XGINew_DataBusWidth / 64) << 1; */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 669 | /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 670 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 671 | /* should delay */ |
| 672 | /* XGINew_SetDRAMModeRegister340(pVBInfo); */ |
| 673 | } |
| 674 | return memsize; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 675 | } |
| 676 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 677 | static int XGINew_ReadWriteRest(unsigned short StopAddr, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 678 | unsigned short StartAddr, struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 679 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 680 | int i; |
| 681 | unsigned long Position = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 682 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 683 | *((unsigned long *) (pVBInfo->FBAddr + Position)) = Position; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 684 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 685 | for (i = StartAddr; i <= StopAddr; i++) { |
| 686 | Position = 1 << i; |
| 687 | *((unsigned long *) (pVBInfo->FBAddr + Position)) = Position; |
| 688 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 689 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 690 | udelay(500); /* [Vicent] 2004/04/16. |
| 691 | Fix #1759 Memory Size error in Multi-Adapter. */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 692 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 693 | Position = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 694 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 695 | if ((*(unsigned long *) (pVBInfo->FBAddr + Position)) != Position) |
Bill Pemberton | fc3678a | 2010-06-17 13:10:44 -0400 | [diff] [blame] | 696 | return 0; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 697 | |
| 698 | for (i = StartAddr; i <= StopAddr; i++) { |
| 699 | Position = 1 << i; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 700 | if ((*(unsigned long *) (pVBInfo->FBAddr + Position)) != |
| 701 | Position) |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 702 | return 0; |
| 703 | } |
| 704 | return 1; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 705 | } |
| 706 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 707 | static unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 708 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 709 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 710 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 711 | data = xgifb_reg_get(pVBInfo->P3d4, 0x97); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 712 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 713 | if ((data & 0x10) == 0) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 714 | data = xgifb_reg_get(pVBInfo->P3c4, 0x39); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 715 | data = (data & 0x02) >> 1; |
| 716 | return data; |
| 717 | } else { |
| 718 | return data & 0x01; |
| 719 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 720 | } |
| 721 | |
Randy Dunlap | 8922967 | 2010-08-10 08:46:44 -0700 | [diff] [blame] | 722 | static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 723 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 724 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 725 | unsigned char data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 726 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 727 | switch (HwDeviceExtension->jChipType) { |
| 728 | case XG20: |
| 729 | case XG21: |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 730 | data = xgifb_reg_get(pVBInfo->P3d4, 0x97); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 731 | data = data & 0x01; |
| 732 | XGINew_ChannelAB = 1; /* XG20 "JUST" one channel */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 733 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 734 | if (data == 0) { /* Single_32_16 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 735 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 736 | if ((HwDeviceExtension->ulVideoMemorySize - 1) |
| 737 | > 0x1000000) { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 738 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 739 | XGINew_DataBusWidth = 32; /* 32 bits */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 740 | /* 22bit + 2 rank + 32bit */ |
| 741 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 742 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 743 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 744 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 745 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 746 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 747 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 748 | if ((HwDeviceExtension->ulVideoMemorySize - 1) > |
| 749 | 0x800000) { |
| 750 | /* 22bit + 1 rank + 32bit */ |
| 751 | xgifb_reg_set(pVBInfo->P3c4, |
| 752 | 0x13, |
| 753 | 0x31); |
| 754 | xgifb_reg_set(pVBInfo->P3c4, |
| 755 | 0x14, |
| 756 | 0x42); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 757 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 758 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 759 | if (XGINew_ReadWriteRest(23, |
| 760 | 23, |
| 761 | pVBInfo) == 1) |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 762 | return; |
| 763 | } |
| 764 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 765 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 766 | if ((HwDeviceExtension->ulVideoMemorySize - 1) > |
| 767 | 0x800000) { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 768 | XGINew_DataBusWidth = 16; /* 16 bits */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 769 | /* 22bit + 2 rank + 16bit */ |
| 770 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 771 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 772 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 773 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 774 | if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1) |
| 775 | return; |
| 776 | else |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 777 | xgifb_reg_set(pVBInfo->P3c4, |
| 778 | 0x13, |
| 779 | 0x31); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 780 | udelay(15); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 781 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 782 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 783 | } else { /* Dual_16_8 */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 784 | if ((HwDeviceExtension->ulVideoMemorySize - 1) > |
| 785 | 0x800000) { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 786 | XGINew_DataBusWidth = 16; /* 16 bits */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 787 | /* (0x31:12x8x2) 22bit + 2 rank */ |
| 788 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); |
| 789 | /* 0x41:16Mx16 bit*/ |
| 790 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 791 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 792 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 793 | if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1) |
| 794 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 795 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 796 | if ((HwDeviceExtension->ulVideoMemorySize - 1) > |
| 797 | 0x400000) { |
| 798 | /* (0x31:12x8x2) 22bit + 1 rank */ |
| 799 | xgifb_reg_set(pVBInfo->P3c4, |
| 800 | 0x13, |
| 801 | 0x31); |
| 802 | /* 0x31:8Mx16 bit*/ |
| 803 | xgifb_reg_set(pVBInfo->P3c4, |
| 804 | 0x14, |
| 805 | 0x31); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 806 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 807 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 808 | if (XGINew_ReadWriteRest(22, |
| 809 | 22, |
| 810 | pVBInfo) == 1) |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 811 | return; |
| 812 | } |
| 813 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 814 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 815 | if ((HwDeviceExtension->ulVideoMemorySize - 1) > |
| 816 | 0x400000) { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 817 | XGINew_DataBusWidth = 8; /* 8 bits */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 818 | /* (0x31:12x8x2) 22bit + 2 rank */ |
| 819 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); |
| 820 | /* 0x30:8Mx8 bit*/ |
| 821 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 822 | udelay(15); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 823 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 824 | if (XGINew_ReadWriteRest(22, 21, pVBInfo) == 1) |
| 825 | return; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 826 | else /* (0x31:12x8x2) 22bit + 1 rank */ |
| 827 | xgifb_reg_set(pVBInfo->P3c4, |
| 828 | 0x13, |
| 829 | 0x31); |
Aaro Koskinen | c45715b | 2011-03-13 12:26:15 +0200 | [diff] [blame] | 830 | udelay(15); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 831 | } |
| 832 | } |
| 833 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 834 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 835 | case XG27: |
| 836 | XGINew_DataBusWidth = 16; /* 16 bits */ |
| 837 | XGINew_ChannelAB = 1; /* Single channel */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 838 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x51); /* 32Mx16 bit*/ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 839 | break; |
| 840 | case XG41: |
| 841 | if (XGINew_CheckFrequence(pVBInfo) == 1) { |
| 842 | XGINew_DataBusWidth = 32; /* 32 bits */ |
| 843 | XGINew_ChannelAB = 3; /* Quad Channel */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 844 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 845 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 846 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 847 | if (XGINew_ReadWriteRest(25, 23, pVBInfo) == 1) |
| 848 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 849 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 850 | XGINew_ChannelAB = 2; /* Dual channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 851 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x48); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 852 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 853 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 854 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 855 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 856 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x49); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 857 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 858 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 859 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 860 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 861 | XGINew_ChannelAB = 3; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 862 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 863 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x3C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 864 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 865 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 866 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 867 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 868 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x38); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 869 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 870 | if (XGINew_ReadWriteRest(8, 4, pVBInfo) == 1) |
| 871 | return; |
| 872 | else |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 873 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x39); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 874 | } else { /* DDR */ |
| 875 | XGINew_DataBusWidth = 64; /* 64 bits */ |
| 876 | XGINew_ChannelAB = 2; /* Dual channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 877 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 878 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 879 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 880 | if (XGINew_ReadWriteRest(25, 24, pVBInfo) == 1) |
| 881 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 882 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 883 | XGINew_ChannelAB = 1; /* Single channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 884 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 885 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 886 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 887 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 888 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 889 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x53); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 890 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 891 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 892 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 893 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 894 | XGINew_ChannelAB = 2; /* Dual channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 895 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 896 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4A); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 897 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 898 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 899 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 900 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 901 | XGINew_ChannelAB = 1; /* Single channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 902 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x42); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 903 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 904 | if (XGINew_ReadWriteRest(8, 4, pVBInfo) == 1) |
| 905 | return; |
| 906 | else |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 907 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x43); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 908 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 909 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 910 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 911 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 912 | case XG42: |
| 913 | /* |
| 914 | XG42 SR14 D[3] Reserve |
| 915 | D[2] = 1, Dual Channel |
| 916 | = 0, Single Channel |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 917 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 918 | It's Different from Other XG40 Series. |
| 919 | */ |
| 920 | if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII, DDR2x */ |
| 921 | XGINew_DataBusWidth = 32; /* 32 bits */ |
| 922 | XGINew_ChannelAB = 2; /* 2 Channel */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 923 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 924 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x44); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 925 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 926 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 927 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 928 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 929 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 930 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x34); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 931 | if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1) |
| 932 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 933 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 934 | XGINew_ChannelAB = 1; /* Single Channel */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 935 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 936 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x40); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 937 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 938 | if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1) |
| 939 | return; |
| 940 | else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 941 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 942 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 943 | } |
| 944 | } else { /* DDR */ |
| 945 | XGINew_DataBusWidth = 64; /* 64 bits */ |
| 946 | XGINew_ChannelAB = 1; /* 1 channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 947 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 948 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 949 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 950 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 951 | return; |
| 952 | else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 953 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 954 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x42); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 955 | } |
| 956 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 957 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 958 | break; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 959 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 960 | default: /* XG40 */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 961 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 962 | if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII */ |
| 963 | XGINew_DataBusWidth = 32; /* 32 bits */ |
| 964 | XGINew_ChannelAB = 3; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 965 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 966 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 967 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 968 | if (XGINew_ReadWriteRest(25, 23, pVBInfo) == 1) |
| 969 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 970 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 971 | XGINew_ChannelAB = 2; /* 2 channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 972 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x48); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 973 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 974 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) |
| 975 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 976 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 977 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 978 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x3C); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 979 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 980 | if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) { |
| 981 | XGINew_ChannelAB = 3; /* 4 channels */ |
| 982 | } else { |
| 983 | XGINew_ChannelAB = 2; /* 2 channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 984 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x38); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 985 | } |
| 986 | } else { /* DDR */ |
| 987 | XGINew_DataBusWidth = 64; /* 64 bits */ |
| 988 | XGINew_ChannelAB = 2; /* 2 channels */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 989 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1); |
| 990 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 991 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 992 | if (XGINew_ReadWriteRest(25, 24, pVBInfo) == 1) { |
| 993 | return; |
| 994 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 995 | xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21); |
| 996 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4A); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 997 | } |
| 998 | } |
| 999 | break; |
| 1000 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1001 | } |
| 1002 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1003 | static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1004 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1005 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1006 | int i; |
| 1007 | unsigned short memsize, addr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1008 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1009 | xgifb_reg_set(pVBInfo->P3c4, 0x15, 0x00); /* noninterleaving */ |
| 1010 | xgifb_reg_set(pVBInfo->P3c4, 0x1C, 0x00); /* nontiling */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1011 | XGINew_CheckChannel(HwDeviceExtension, pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1012 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1013 | if (HwDeviceExtension->jChipType >= XG20) { |
| 1014 | for (i = 0; i < 12; i++) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1015 | XGINew_SetDRAMSizingType(i, |
| 1016 | XGINew_DDRDRAM_TYPE20, |
| 1017 | pVBInfo); |
| 1018 | memsize = XGINew_SetDRAMSize20Reg(i, |
| 1019 | XGINew_DDRDRAM_TYPE20, |
| 1020 | pVBInfo); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1021 | if (memsize == 0) |
| 1022 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1023 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1024 | addr = memsize + (XGINew_ChannelAB - 2) + 20; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1025 | if ((HwDeviceExtension->ulVideoMemorySize - 1) < |
| 1026 | (unsigned long) (1 << addr)) |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1027 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1028 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1029 | if (XGINew_ReadWriteRest(addr, 5, pVBInfo) == 1) |
| 1030 | return 1; |
| 1031 | } |
| 1032 | } else { |
| 1033 | for (i = 0; i < 4; i++) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1034 | XGINew_SetDRAMSizingType(i, |
| 1035 | XGINew_DDRDRAM_TYPE340, |
| 1036 | pVBInfo); |
| 1037 | memsize = XGINew_SetDRAMSizeReg(i, |
| 1038 | XGINew_DDRDRAM_TYPE340, |
| 1039 | pVBInfo); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1040 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1041 | if (memsize == 0) |
| 1042 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1043 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1044 | addr = memsize + (XGINew_ChannelAB - 2) + 20; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1045 | if ((HwDeviceExtension->ulVideoMemorySize - 1) < |
| 1046 | (unsigned long) (1 << addr)) |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1047 | continue; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1048 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1049 | if (XGINew_ReadWriteRest(addr, 9, pVBInfo) == 1) |
| 1050 | return 1; |
| 1051 | } |
| 1052 | } |
| 1053 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1054 | } |
| 1055 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1056 | static void XGINew_SetDRAMSize_340(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1057 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1058 | { |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1059 | unsigned short data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1060 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1061 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; |
| 1062 | pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1063 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1064 | XGISetModeNew(HwDeviceExtension, 0x2e); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1065 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1066 | data = xgifb_reg_get(pVBInfo->P3c4, 0x21); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1067 | /* disable read cache */ |
| 1068 | xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data & 0xDF)); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1069 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
| 1070 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1071 | /* data = xgifb_reg_get(pVBInfo->P3c4, 0x1); */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1072 | /* data |= 0x20 ; */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1073 | /* xgifb_reg_set(pVBInfo->P3c4, 0x01, data); *//* Turn OFF Display */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1074 | XGINew_DDRSizing340(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1075 | data = xgifb_reg_get(pVBInfo->P3c4, 0x21); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1076 | /* enable read cache */ |
| 1077 | xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data | 0x20)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1078 | } |
| 1079 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1080 | static void ReadVBIOSTablData(unsigned char ChipType, |
| 1081 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1082 | { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1083 | volatile unsigned char *pVideoMemory = |
| 1084 | (unsigned char *) pVBInfo->ROMAddr; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1085 | unsigned long i; |
| 1086 | unsigned char j, k; |
| 1087 | /* Volari customize data area end */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1088 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1089 | if (ChipType == XG21) { |
| 1090 | pVBInfo->IF_DEF_LVDS = 0; |
| 1091 | if (pVideoMemory[0x65] & 0x1) { |
| 1092 | pVBInfo->IF_DEF_LVDS = 1; |
| 1093 | i = pVideoMemory[0x316] | (pVideoMemory[0x317] << 8); |
| 1094 | j = pVideoMemory[i - 1]; |
| 1095 | if (j != 0xff) { |
| 1096 | k = 0; |
| 1097 | do { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1098 | pVBInfo->XG21_LVDSCapList[k]. |
| 1099 | LVDS_Capability |
| 1100 | = pVideoMemory[i] | |
| 1101 | (pVideoMemory[i + 1] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1102 | pVBInfo->XG21_LVDSCapList[k].LVDSHT |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1103 | = pVideoMemory[i + 2] | |
| 1104 | (pVideoMemory[i + 3] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1105 | pVBInfo->XG21_LVDSCapList[k].LVDSVT |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1106 | = pVideoMemory[i + 4] | |
| 1107 | (pVideoMemory[i + 5] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1108 | pVBInfo->XG21_LVDSCapList[k].LVDSHDE |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1109 | = pVideoMemory[i + 6] | |
| 1110 | (pVideoMemory[i + 7] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1111 | pVBInfo->XG21_LVDSCapList[k].LVDSVDE |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1112 | = pVideoMemory[i + 8] | |
| 1113 | (pVideoMemory[i + 9] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1114 | pVBInfo->XG21_LVDSCapList[k].LVDSHFP |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1115 | = pVideoMemory[i + 10] | |
| 1116 | (pVideoMemory[i + 11] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1117 | pVBInfo->XG21_LVDSCapList[k].LVDSVFP |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1118 | = pVideoMemory[i + 12] | |
| 1119 | (pVideoMemory[i + 13] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1120 | pVBInfo->XG21_LVDSCapList[k].LVDSHSYNC |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1121 | = pVideoMemory[i + 14] | |
| 1122 | (pVideoMemory[i + 15] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1123 | pVBInfo->XG21_LVDSCapList[k].LVDSVSYNC |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1124 | = pVideoMemory[i + 16] | |
| 1125 | (pVideoMemory[i + 17] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1126 | pVBInfo->XG21_LVDSCapList[k].VCLKData1 |
| 1127 | = pVideoMemory[i + 18]; |
| 1128 | pVBInfo->XG21_LVDSCapList[k].VCLKData2 |
| 1129 | = pVideoMemory[i + 19]; |
| 1130 | pVBInfo->XG21_LVDSCapList[k].PSC_S1 |
| 1131 | = pVideoMemory[i + 20]; |
| 1132 | pVBInfo->XG21_LVDSCapList[k].PSC_S2 |
| 1133 | = pVideoMemory[i + 21]; |
| 1134 | pVBInfo->XG21_LVDSCapList[k].PSC_S3 |
| 1135 | = pVideoMemory[i + 22]; |
| 1136 | pVBInfo->XG21_LVDSCapList[k].PSC_S4 |
| 1137 | = pVideoMemory[i + 23]; |
| 1138 | pVBInfo->XG21_LVDSCapList[k].PSC_S5 |
| 1139 | = pVideoMemory[i + 24]; |
| 1140 | i += 25; |
| 1141 | j--; |
| 1142 | k++; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1143 | } while ((j > 0) && |
| 1144 | (k < (sizeof(XGI21_LCDCapList) / |
| 1145 | sizeof(struct |
| 1146 | XGI21_LVDSCapStruct)))); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1147 | } else { |
| 1148 | pVBInfo->XG21_LVDSCapList[0].LVDS_Capability |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1149 | = pVideoMemory[i] | |
| 1150 | (pVideoMemory[i + 1] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1151 | pVBInfo->XG21_LVDSCapList[0].LVDSHT |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1152 | = pVideoMemory[i + 2] | |
| 1153 | (pVideoMemory[i + 3] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1154 | pVBInfo->XG21_LVDSCapList[0].LVDSVT |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1155 | = pVideoMemory[i + 4] | |
| 1156 | (pVideoMemory[i + 5] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1157 | pVBInfo->XG21_LVDSCapList[0].LVDSHDE |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1158 | = pVideoMemory[i + 6] | |
| 1159 | (pVideoMemory[i + 7] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1160 | pVBInfo->XG21_LVDSCapList[0].LVDSVDE |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1161 | = pVideoMemory[i + 8] | |
| 1162 | (pVideoMemory[i + 9] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1163 | pVBInfo->XG21_LVDSCapList[0].LVDSHFP |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1164 | = pVideoMemory[i + 10] | |
| 1165 | (pVideoMemory[i + 11] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1166 | pVBInfo->XG21_LVDSCapList[0].LVDSVFP |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1167 | = pVideoMemory[i + 12] | |
| 1168 | (pVideoMemory[i + 13] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1169 | pVBInfo->XG21_LVDSCapList[0].LVDSHSYNC |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1170 | = pVideoMemory[i + 14] | |
| 1171 | (pVideoMemory[i + 15] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1172 | pVBInfo->XG21_LVDSCapList[0].LVDSVSYNC |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1173 | = pVideoMemory[i + 16] | |
| 1174 | (pVideoMemory[i + 17] << 8); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1175 | pVBInfo->XG21_LVDSCapList[0].VCLKData1 |
| 1176 | = pVideoMemory[i + 18]; |
| 1177 | pVBInfo->XG21_LVDSCapList[0].VCLKData2 |
| 1178 | = pVideoMemory[i + 19]; |
| 1179 | pVBInfo->XG21_LVDSCapList[0].PSC_S1 |
| 1180 | = pVideoMemory[i + 20]; |
| 1181 | pVBInfo->XG21_LVDSCapList[0].PSC_S2 |
| 1182 | = pVideoMemory[i + 21]; |
| 1183 | pVBInfo->XG21_LVDSCapList[0].PSC_S3 |
| 1184 | = pVideoMemory[i + 22]; |
| 1185 | pVBInfo->XG21_LVDSCapList[0].PSC_S4 |
| 1186 | = pVideoMemory[i + 23]; |
| 1187 | pVBInfo->XG21_LVDSCapList[0].PSC_S5 |
| 1188 | = pVideoMemory[i + 24]; |
| 1189 | } |
| 1190 | } |
| 1191 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1192 | } |
| 1193 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1194 | static void XGINew_ChkSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1195 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1196 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1197 | unsigned short tempbx = 0, temp, tempcx, CR3CData; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1198 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1199 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x32); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1200 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1201 | if (temp & Monitor1Sense) |
| 1202 | tempbx |= ActiveCRT1; |
| 1203 | if (temp & LCDSense) |
| 1204 | tempbx |= ActiveLCD; |
| 1205 | if (temp & Monitor2Sense) |
| 1206 | tempbx |= ActiveCRT2; |
| 1207 | if (temp & TVSense) { |
| 1208 | tempbx |= ActiveTV; |
| 1209 | if (temp & AVIDEOSense) |
| 1210 | tempbx |= (ActiveAVideo << 8); |
| 1211 | if (temp & SVIDEOSense) |
| 1212 | tempbx |= (ActiveSVideo << 8); |
| 1213 | if (temp & SCARTSense) |
| 1214 | tempbx |= (ActiveSCART << 8); |
| 1215 | if (temp & HiTVSense) |
| 1216 | tempbx |= (ActiveHiTV << 8); |
| 1217 | if (temp & YPbPrSense) |
| 1218 | tempbx |= (ActiveYPbPr << 8); |
| 1219 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1220 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1221 | tempcx = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
| 1222 | tempcx |= (xgifb_reg_get(pVBInfo->P3d4, 0x3e) << 8); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1223 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1224 | if (tempbx & tempcx) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1225 | CR3CData = xgifb_reg_get(pVBInfo->P3d4, 0x3c); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1226 | if (!(CR3CData & DisplayDeviceFromCMOS)) { |
| 1227 | tempcx = 0x1FF0; |
| 1228 | if (*pVBInfo->pSoftSetting & ModeSoftSetting) |
| 1229 | tempbx = 0x1FF0; |
| 1230 | } |
| 1231 | } else { |
| 1232 | tempcx = 0x1FF0; |
| 1233 | if (*pVBInfo->pSoftSetting & ModeSoftSetting) |
| 1234 | tempbx = 0x1FF0; |
| 1235 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1236 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1237 | tempbx &= tempcx; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1238 | xgifb_reg_set(pVBInfo->P3d4, 0x3d, (tempbx & 0x00FF)); |
| 1239 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, ((tempbx & 0xFF00) >> 8)); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1240 | } |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1241 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1242 | static void XGINew_SetModeScratch(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1243 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1244 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1245 | unsigned short temp, tempcl = 0, tempch = 0, CR31Data, CR38Data; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1246 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1247 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
| 1248 | temp |= xgifb_reg_get(pVBInfo->P3d4, 0x3e) << 8; |
| 1249 | temp |= (xgifb_reg_get(pVBInfo->P3d4, 0x31) & (DriverMode >> 8)) << 8; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1250 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1251 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
| 1252 | if (temp & ActiveCRT2) |
| 1253 | tempcl = SetCRT2ToRAMDAC; |
| 1254 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1255 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1256 | if (temp & ActiveLCD) { |
| 1257 | tempcl |= SetCRT2ToLCD; |
| 1258 | if (temp & DriverMode) { |
| 1259 | if (temp & ActiveTV) { |
| 1260 | tempch = SetToLCDA | EnableDualEdge; |
| 1261 | temp ^= SetCRT2ToLCD; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1262 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1263 | if ((temp >> 8) & ActiveAVideo) |
| 1264 | tempcl |= SetCRT2ToAVIDEO; |
| 1265 | if ((temp >> 8) & ActiveSVideo) |
| 1266 | tempcl |= SetCRT2ToSVIDEO; |
| 1267 | if ((temp >> 8) & ActiveSCART) |
| 1268 | tempcl |= SetCRT2ToSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1269 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1270 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 1271 | if ((temp >> 8) & ActiveHiTV) |
| 1272 | tempcl |= SetCRT2ToHiVisionTV; |
| 1273 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1274 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1275 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 1276 | if ((temp >> 8) & ActiveYPbPr) |
| 1277 | tempch |= SetYPbPr; |
| 1278 | } |
| 1279 | } |
| 1280 | } |
| 1281 | } else { |
| 1282 | if ((temp >> 8) & ActiveAVideo) |
| 1283 | tempcl |= SetCRT2ToAVIDEO; |
| 1284 | if ((temp >> 8) & ActiveSVideo) |
| 1285 | tempcl |= SetCRT2ToSVIDEO; |
| 1286 | if ((temp >> 8) & ActiveSCART) |
| 1287 | tempcl |= SetCRT2ToSCART; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1288 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1289 | if (pVBInfo->IF_DEF_HiVision == 1) { |
| 1290 | if ((temp >> 8) & ActiveHiTV) |
| 1291 | tempcl |= SetCRT2ToHiVisionTV; |
| 1292 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1293 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1294 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
| 1295 | if ((temp >> 8) & ActiveYPbPr) |
| 1296 | tempch |= SetYPbPr; |
| 1297 | } |
| 1298 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1299 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1300 | tempcl |= SetSimuScanMode; |
| 1301 | if ((!(temp & ActiveCRT1)) && ((temp & ActiveLCD) || (temp & ActiveTV) |
| 1302 | || (temp & ActiveCRT2))) |
| 1303 | tempcl ^= (SetSimuScanMode | SwitchToCRT2); |
| 1304 | if ((temp & ActiveLCD) && (temp & ActiveTV)) |
| 1305 | tempcl ^= (SetSimuScanMode | SwitchToCRT2); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1306 | xgifb_reg_set(pVBInfo->P3d4, 0x30, tempcl); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1307 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1308 | CR31Data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1309 | CR31Data &= ~(SetNotSimuMode >> 8); |
| 1310 | if (!(temp & ActiveCRT1)) |
| 1311 | CR31Data |= (SetNotSimuMode >> 8); |
| 1312 | CR31Data &= ~(DisableCRT2Display >> 8); |
| 1313 | if (!((temp & ActiveLCD) || (temp & ActiveTV) || (temp & ActiveCRT2))) |
| 1314 | CR31Data |= (DisableCRT2Display >> 8); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1315 | xgifb_reg_set(pVBInfo->P3d4, 0x31, CR31Data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1316 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1317 | CR38Data = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1318 | CR38Data &= ~SetYPbPr; |
| 1319 | CR38Data |= tempch; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1320 | xgifb_reg_set(pVBInfo->P3d4, 0x38, CR38Data); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1321 | |
| 1322 | } |
| 1323 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1324 | static void XGINew_GetXG21Sense(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1325 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1326 | { |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1327 | unsigned char Temp; |
| 1328 | volatile unsigned char *pVideoMemory = |
| 1329 | (unsigned char *) pVBInfo->ROMAddr; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1330 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1331 | pVBInfo->IF_DEF_LVDS = 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1332 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1333 | #if 1 |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1334 | if ((pVideoMemory[0x65] & 0x01)) { /* For XG21 LVDS */ |
| 1335 | pVBInfo->IF_DEF_LVDS = 1; |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1336 | xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1337 | /* LVDS on chip */ |
| 1338 | xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1339 | } else { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1340 | #endif |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1341 | /* Enable GPIOA/B read */ |
| 1342 | xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1343 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0xC0; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1344 | if (Temp == 0xC0) { /* DVI & DVO GPIOA/B pull high */ |
| 1345 | XGINew_SenseLCD(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1346 | xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1347 | /* Enable read GPIOF */ |
| 1348 | xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x20, 0x20); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1349 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0x04; |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1350 | if (!Temp) |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1351 | xgifb_reg_and_or(pVBInfo->P3d4, |
| 1352 | 0x38, |
| 1353 | ~0xE0, |
| 1354 | 0x80); /* TMDS on chip */ |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1355 | else |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1356 | xgifb_reg_and_or(pVBInfo->P3d4, |
| 1357 | 0x38, |
| 1358 | ~0xE0, |
| 1359 | 0xA0); /* Only DVO on chip */ |
| 1360 | /* Disable read GPIOF */ |
| 1361 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1362 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1363 | #if 1 |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1364 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1365 | #endif |
| 1366 | } |
| 1367 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1368 | static void XGINew_GetXG27Sense(struct xgi_hw_device_info *HwDeviceExtension, |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1369 | struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1370 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1371 | unsigned char Temp, bCR4A; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1372 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1373 | pVBInfo->IF_DEF_LVDS = 0; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1374 | bCR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1375 | /* Enable GPIOA/B/C read */ |
| 1376 | xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x07, 0x07); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1377 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0x07; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1378 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, bCR4A); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1379 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1380 | if (Temp <= 0x02) { |
| 1381 | pVBInfo->IF_DEF_LVDS = 1; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1382 | /* LVDS setting */ |
| 1383 | xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1384 | xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x21); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1385 | } else { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1386 | /* TMDS/DVO setting */ |
| 1387 | xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xA0); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1388 | } |
Aaro Koskinen | b9bf6e4 | 2011-03-13 12:26:24 +0200 | [diff] [blame] | 1389 | xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1390 | |
| 1391 | } |
| 1392 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1393 | static unsigned char GetXG21FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1394 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1395 | unsigned char CR38, CR4A, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1396 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1397 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1398 | /* enable GPIOE read */ |
| 1399 | xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x10, 0x10); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1400 | CR38 = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1401 | temp = 0; |
| 1402 | if ((CR38 & 0xE0) > 0x80) { |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1403 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1404 | temp &= 0x08; |
| 1405 | temp >>= 3; |
| 1406 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1407 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1408 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1409 | |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1410 | return temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1411 | } |
| 1412 | |
Aaro Koskinen | e0cc8a6 | 2011-03-08 22:16:20 +0200 | [diff] [blame] | 1413 | static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo) |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1414 | { |
Bill Pemberton | 108afbf | 2010-06-17 13:10:47 -0400 | [diff] [blame] | 1415 | unsigned char CR4A, temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1416 | |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1417 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1418 | /* enable GPIOA/B/C read */ |
| 1419 | xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03); |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1420 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1421 | if (temp <= 2) |
| 1422 | temp &= 0x03; |
| 1423 | else |
| 1424 | temp = ((temp & 0x04) >> 1) || ((~temp) & 0x01); |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1425 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1426 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
Prashant P. Shah | a24d60f | 2010-09-02 15:25:38 +0530 | [diff] [blame] | 1427 | |
| 1428 | return temp; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1429 | } |
| 1430 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1431 | unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) |
| 1432 | { |
| 1433 | struct vb_device_info VBINF; |
| 1434 | struct vb_device_info *pVBInfo = &VBINF; |
| 1435 | unsigned char i, temp = 0, temp1; |
| 1436 | /* VBIOSVersion[5]; */ |
| 1437 | volatile unsigned char *pVideoMemory; |
| 1438 | |
| 1439 | /* unsigned long j, k; */ |
| 1440 | |
| 1441 | unsigned long Temp; |
| 1442 | |
| 1443 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; |
| 1444 | |
| 1445 | pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; |
| 1446 | |
| 1447 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; |
| 1448 | |
| 1449 | pVideoMemory = (unsigned char *) pVBInfo->ROMAddr; |
| 1450 | |
| 1451 | /* Newdebugcode(0x99); */ |
| 1452 | |
| 1453 | |
| 1454 | /* if (pVBInfo->ROMAddr == 0) */ |
| 1455 | /* return(0); */ |
| 1456 | |
| 1457 | if (pVBInfo->FBAddr == NULL) { |
| 1458 | printk("\n pVBInfo->FBAddr == 0 "); |
| 1459 | return 0; |
| 1460 | } |
| 1461 | printk("1"); |
| 1462 | if (pVBInfo->BaseAddr == 0) { |
| 1463 | printk("\npVBInfo->BaseAddr == 0 "); |
| 1464 | return 0; |
| 1465 | } |
| 1466 | printk("2"); |
| 1467 | |
Aaro Koskinen | efdf4ee | 2011-03-13 12:26:20 +0200 | [diff] [blame] | 1468 | outb(0x67, (pVBInfo->BaseAddr + 0x12)); /* 3c2 <- 67 ,ynlai */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1469 | |
| 1470 | pVBInfo->ISXPDOS = 0; |
| 1471 | printk("3"); |
| 1472 | |
| 1473 | printk("4"); |
| 1474 | |
| 1475 | /* VBIOSVersion[4] = 0x0; */ |
| 1476 | |
| 1477 | /* 09/07/99 modify by domao */ |
| 1478 | |
| 1479 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; |
| 1480 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; |
| 1481 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; |
| 1482 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; |
| 1483 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; |
| 1484 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; |
| 1485 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; |
| 1486 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; |
| 1487 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; |
| 1488 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; |
| 1489 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; |
| 1490 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; |
| 1491 | pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04; |
| 1492 | pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10; |
| 1493 | pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12; |
| 1494 | pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14; |
| 1495 | pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2; |
| 1496 | printk("5"); |
| 1497 | |
| 1498 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1499 | /* Run XGI_GetVBType before InitTo330Pointer */ |
| 1500 | XGI_GetVBType(pVBInfo); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1501 | |
| 1502 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
| 1503 | |
| 1504 | /* ReadVBIOSData */ |
| 1505 | ReadVBIOSTablData(HwDeviceExtension->jChipType, pVBInfo); |
| 1506 | |
| 1507 | /* 1.Openkey */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1508 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1509 | printk("6"); |
| 1510 | |
| 1511 | /* GetXG21Sense (GPIO) */ |
| 1512 | if (HwDeviceExtension->jChipType == XG21) |
| 1513 | XGINew_GetXG21Sense(HwDeviceExtension, pVBInfo); |
| 1514 | |
| 1515 | if (HwDeviceExtension->jChipType == XG27) |
| 1516 | XGINew_GetXG27Sense(HwDeviceExtension, pVBInfo); |
| 1517 | |
| 1518 | printk("7"); |
| 1519 | |
| 1520 | /* 2.Reset Extended register */ |
| 1521 | |
| 1522 | for (i = 0x06; i < 0x20; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1523 | xgifb_reg_set(pVBInfo->P3c4, i, 0); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1524 | |
| 1525 | for (i = 0x21; i <= 0x27; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1526 | xgifb_reg_set(pVBInfo->P3c4, i, 0); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1527 | |
| 1528 | /* for(i = 0x06; i <= 0x27; i++) */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1529 | /* xgifb_reg_set(pVBInfo->P3c4, i, 0); */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1530 | |
| 1531 | printk("8"); |
| 1532 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1533 | for (i = 0x31; i <= 0x3B; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1534 | xgifb_reg_set(pVBInfo->P3c4, i, 0); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1535 | printk("9"); |
| 1536 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1537 | /* [Hsuan] 2004/08/20 Auto over driver for XG42 */ |
| 1538 | if (HwDeviceExtension->jChipType == XG42) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1539 | xgifb_reg_set(pVBInfo->P3c4, 0x3B, 0xC0); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1540 | |
| 1541 | /* for (i = 0x30; i <= 0x3F; i++) */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1542 | /* xgifb_reg_set(pVBInfo->P3d4, i, 0); */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1543 | |
| 1544 | for (i = 0x79; i <= 0x7C; i++) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1545 | xgifb_reg_set(pVBInfo->P3d4, i, 0); /* shampoo 0208 */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1546 | |
| 1547 | printk("10"); |
| 1548 | |
| 1549 | if (HwDeviceExtension->jChipType >= XG20) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1550 | xgifb_reg_set(pVBInfo->P3d4, 0x97, *pVBInfo->pXGINew_CR97); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1551 | |
| 1552 | /* 3.SetMemoryClock |
| 1553 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1554 | XGINew_RAMType = (int)XGINew_GetXG20DRAMType(HwDeviceExtension, |
| 1555 | pVBInfo); |
Aaro Koskinen | fd0ad47 | 2011-03-13 12:26:09 +0200 | [diff] [blame] | 1556 | */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1557 | |
| 1558 | printk("11"); |
| 1559 | |
| 1560 | /* 4.SetDefExt1Regs begin */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1561 | xgifb_reg_set(pVBInfo->P3c4, 0x07, *pVBInfo->pSR07); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1562 | if (HwDeviceExtension->jChipType == XG27) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1563 | xgifb_reg_set(pVBInfo->P3c4, 0x40, *pVBInfo->pSR40); |
| 1564 | xgifb_reg_set(pVBInfo->P3c4, 0x41, *pVBInfo->pSR41); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1565 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1566 | xgifb_reg_set(pVBInfo->P3c4, 0x11, 0x0F); |
| 1567 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, *pVBInfo->pSR1F); |
| 1568 | /* xgifb_reg_set(pVBInfo->P3c4, 0x20, 0x20); */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1569 | /* alan, 2001/6/26 Frame buffer can read/write SR20 */ |
| 1570 | xgifb_reg_set(pVBInfo->P3c4, 0x20, 0xA0); |
| 1571 | /* Hsuan, 2006/01/01 H/W request for slow corner chip */ |
| 1572 | xgifb_reg_set(pVBInfo->P3c4, 0x36, 0x70); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1573 | if (HwDeviceExtension->jChipType == XG27) /* Alan 12/07/2006 */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1574 | xgifb_reg_set(pVBInfo->P3c4, 0x36, *pVBInfo->pSR36); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1575 | |
| 1576 | /* SR11 = 0x0F; */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1577 | /* xgifb_reg_set(pVBInfo->P3c4, 0x11, SR11); */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1578 | |
| 1579 | printk("12"); |
| 1580 | |
| 1581 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 1582 | /* Set AGP Rate */ |
| 1583 | /* |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1584 | temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1585 | temp1 &= 0x02; |
| 1586 | if (temp1 == 0x02) { |
Aaro Koskinen | 3d2a60a | 2011-03-13 12:26:21 +0200 | [diff] [blame] | 1587 | outl(0x80000000, 0xcf8); |
Aaro Koskinen | f5b571f | 2011-03-13 12:26:19 +0200 | [diff] [blame] | 1588 | ChipsetID = inl(0x0cfc); |
Aaro Koskinen | 3d2a60a | 2011-03-13 12:26:21 +0200 | [diff] [blame] | 1589 | outl(0x8000002C, 0xcf8); |
Aaro Koskinen | f5b571f | 2011-03-13 12:26:19 +0200 | [diff] [blame] | 1590 | VendorID = inl(0x0cfc); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1591 | VendorID &= 0x0000FFFF; |
Aaro Koskinen | 3d2a60a | 2011-03-13 12:26:21 +0200 | [diff] [blame] | 1592 | outl(0x8001002C, 0xcf8); |
Aaro Koskinen | f5b571f | 2011-03-13 12:26:19 +0200 | [diff] [blame] | 1593 | GraphicVendorID = inl(0x0cfc); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1594 | GraphicVendorID &= 0x0000FFFF; |
| 1595 | |
| 1596 | if (ChipsetID == 0x7301039) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1597 | xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x09); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1598 | |
| 1599 | ChipsetID &= 0x0000FFFF; |
| 1600 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1601 | if ((ChipsetID == 0x700E) || |
| 1602 | (ChipsetID == 0x1022) || |
| 1603 | (ChipsetID == 0x1106) || |
| 1604 | (ChipsetID == 0x10DE)) { |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1605 | if (ChipsetID == 0x1106) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1606 | if ((VendorID == 0x1019) && |
| 1607 | (GraphicVendorID == 0x1019)) |
| 1608 | xgifb_reg_set(pVBInfo->P3d4, |
| 1609 | 0x5F, |
| 1610 | 0x0D); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1611 | else |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1612 | xgifb_reg_set(pVBInfo->P3d4, |
| 1613 | 0x5F, |
| 1614 | 0x0B); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1615 | } else { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1616 | xgifb_reg_set(pVBInfo->P3d4, |
| 1617 | 0x5F, |
| 1618 | 0x0B); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1619 | } |
| 1620 | } |
| 1621 | } |
| 1622 | */ |
| 1623 | |
| 1624 | printk("13"); |
| 1625 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1626 | /* Set AGP customize registers (in SetDefAGPRegs) Start */ |
| 1627 | for (i = 0x47; i <= 0x4C; i++) |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1628 | xgifb_reg_set(pVBInfo->P3d4, |
| 1629 | i, |
| 1630 | pVBInfo->AGPReg[i - 0x47]); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1631 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1632 | for (i = 0x70; i <= 0x71; i++) |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1633 | xgifb_reg_set(pVBInfo->P3d4, |
| 1634 | i, |
| 1635 | pVBInfo->AGPReg[6 + i - 0x70]); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1636 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1637 | for (i = 0x74; i <= 0x77; i++) |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1638 | xgifb_reg_set(pVBInfo->P3d4, |
| 1639 | i, |
| 1640 | pVBInfo->AGPReg[8 + i - 0x74]); |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1641 | /* Set AGP customize registers (in SetDefAGPRegs) End */ |
| 1642 | /* [Hsuan]2004/12/14 AGP Input Delay Adjustment on 850 */ |
Aaro Koskinen | 3d2a60a | 2011-03-13 12:26:21 +0200 | [diff] [blame] | 1643 | /* outl(0x80000000, 0xcf8); */ |
Aaro Koskinen | f5b571f | 2011-03-13 12:26:19 +0200 | [diff] [blame] | 1644 | /* ChipsetID = inl(0x0cfc); */ |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1645 | /* if (ChipsetID == 0x25308086) */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1646 | /* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1647 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1648 | HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension, |
| 1649 | 0x50, |
| 1650 | 0, |
| 1651 | &Temp); /* Get */ |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1652 | Temp >>= 20; |
| 1653 | Temp &= 0xF; |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1654 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1655 | if (Temp == 1) |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1656 | xgifb_reg_set(pVBInfo->P3d4, 0x48, 0x20); /* CR48 */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1657 | printk("14"); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1658 | } /* != XG20 */ |
| 1659 | |
| 1660 | /* Set PCI */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1661 | xgifb_reg_set(pVBInfo->P3c4, 0x23, *pVBInfo->pSR23); |
| 1662 | xgifb_reg_set(pVBInfo->P3c4, 0x24, *pVBInfo->pSR24); |
| 1663 | xgifb_reg_set(pVBInfo->P3c4, 0x25, pVBInfo->SR25[0]); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1664 | printk("15"); |
| 1665 | |
| 1666 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 1667 | /* Set VB */ |
| 1668 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1669 | /* alan, disable VideoCapture */ |
| 1670 | xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1671 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1672 | /* chk if BCLK>=100MHz */ |
| 1673 | temp1 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x7B); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1674 | temp = (unsigned char) ((temp1 >> 4) & 0x0F); |
| 1675 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1676 | xgifb_reg_set(pVBInfo->Part1Port, |
| 1677 | 0x02, |
| 1678 | (*pVBInfo->pCRT2Data_1_2)); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1679 | |
| 1680 | printk("16"); |
| 1681 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1682 | xgifb_reg_set(pVBInfo->Part1Port, 0x2E, 0x08); /* use VB */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1683 | } /* != XG20 */ |
| 1684 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1685 | xgifb_reg_set(pVBInfo->P3c4, 0x27, 0x1F); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1686 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1687 | if ((HwDeviceExtension->jChipType == XG42) && |
| 1688 | XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo) != 0) { |
| 1689 | /* Not DDR */ |
| 1690 | xgifb_reg_set(pVBInfo->P3c4, |
| 1691 | 0x31, |
| 1692 | (*pVBInfo->pSR31 & 0x3F) | 0x40); |
| 1693 | xgifb_reg_set(pVBInfo->P3c4, |
| 1694 | 0x32, |
| 1695 | (*pVBInfo->pSR32 & 0xFC) | 0x01); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1696 | } else { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1697 | xgifb_reg_set(pVBInfo->P3c4, 0x31, *pVBInfo->pSR31); |
| 1698 | xgifb_reg_set(pVBInfo->P3c4, 0x32, *pVBInfo->pSR32); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1699 | } |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1700 | xgifb_reg_set(pVBInfo->P3c4, 0x33, *pVBInfo->pSR33); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1701 | printk("17"); |
| 1702 | |
| 1703 | /* |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1704 | SetPowerConsume (HwDeviceExtension, pVBInfo->P3c4); */ |
| 1705 | |
| 1706 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
| 1707 | if (XGI_BridgeIsOn(pVBInfo) == 1) { |
| 1708 | if (pVBInfo->IF_DEF_LVDS == 0) { |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1709 | xgifb_reg_set(pVBInfo->Part2Port, 0x00, 0x1C); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1710 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1711 | 0x0D, |
| 1712 | *pVBInfo->pCRT2Data_4_D); |
| 1713 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1714 | 0x0E, |
| 1715 | *pVBInfo->pCRT2Data_4_E); |
| 1716 | xgifb_reg_set(pVBInfo->Part4Port, |
| 1717 | 0x10, |
| 1718 | *pVBInfo->pCRT2Data_4_10); |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1719 | xgifb_reg_set(pVBInfo->Part4Port, 0x0F, 0x3F); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1720 | } |
| 1721 | |
| 1722 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); |
| 1723 | } |
| 1724 | } /* != XG20 */ |
| 1725 | printk("18"); |
| 1726 | |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1727 | printk("181"); |
| 1728 | |
| 1729 | printk("182"); |
| 1730 | |
| 1731 | XGI_SenseCRT1(pVBInfo); |
| 1732 | |
| 1733 | printk("183"); |
| 1734 | /* XGINew_DetectMonitor(HwDeviceExtension); */ |
| 1735 | pVBInfo->IF_DEF_CH7007 = 0; |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1736 | if ((HwDeviceExtension->jChipType == XG21) && |
| 1737 | (pVBInfo->IF_DEF_CH7007)) { |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1738 | printk("184"); |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1739 | /* sense CRT2 */ |
| 1740 | XGI_GetSenseStatus(HwDeviceExtension, pVBInfo); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1741 | printk("185"); |
| 1742 | |
| 1743 | } |
| 1744 | if (HwDeviceExtension->jChipType == XG21) { |
| 1745 | printk("186"); |
| 1746 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1747 | xgifb_reg_and_or(pVBInfo->P3d4, |
| 1748 | 0x32, |
| 1749 | ~Monitor1Sense, |
| 1750 | Monitor1Sense); /* Z9 default has CRT */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1751 | temp = GetXG21FPBits(pVBInfo); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1752 | xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x01, temp); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1753 | printk("187"); |
| 1754 | |
| 1755 | } |
| 1756 | if (HwDeviceExtension->jChipType == XG27) { |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1757 | xgifb_reg_and_or(pVBInfo->P3d4, |
| 1758 | 0x32, |
| 1759 | ~Monitor1Sense, |
| 1760 | Monitor1Sense); /* Z9 default has CRT */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1761 | temp = GetXG27FPBits(pVBInfo); |
Aaro Koskinen | ec9e5d3 | 2011-03-13 12:26:25 +0200 | [diff] [blame] | 1762 | xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x03, temp); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1763 | } |
| 1764 | printk("19"); |
| 1765 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1766 | XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, |
| 1767 | pVBInfo); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1768 | |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1769 | XGINew_SetDRAMDefaultRegister340(HwDeviceExtension, |
| 1770 | pVBInfo->P3d4, |
| 1771 | pVBInfo); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1772 | |
Aaro Koskinen | 0658733 | 2011-03-13 12:26:10 +0200 | [diff] [blame] | 1773 | printk("20"); |
| 1774 | XGINew_SetDRAMSize_340(HwDeviceExtension, pVBInfo); |
| 1775 | printk("21"); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1776 | |
| 1777 | printk("22"); |
| 1778 | |
| 1779 | /* SetDefExt2Regs begin */ |
| 1780 | /* |
| 1781 | AGP = 1; |
Aaro Koskinen | 58839b0 | 2011-03-13 12:26:23 +0200 | [diff] [blame] | 1782 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x3A); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1783 | temp &= 0x30; |
| 1784 | if (temp == 0x30) |
| 1785 | AGP = 0; |
| 1786 | |
| 1787 | if (AGP == 0) |
| 1788 | *pVBInfo->pSR21 &= 0xEF; |
| 1789 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1790 | xgifb_reg_set(pVBInfo->P3c4, 0x21, *pVBInfo->pSR21); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1791 | if (AGP == 1) |
| 1792 | *pVBInfo->pSR22 &= 0x20; |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1793 | xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1794 | */ |
| 1795 | /* base = 0x80000000; */ |
| 1796 | /* OutPortLong(0xcf8, base); */ |
| 1797 | /* Temp = (InPortLong(0xcfc) & 0xFFFF); */ |
| 1798 | /* if (Temp == 0x1039) { */ |
Kenji Toyama | bf32fcb | 2011-04-23 12:11:16 +0800 | [diff] [blame] | 1799 | xgifb_reg_set(pVBInfo->P3c4, |
| 1800 | 0x22, |
| 1801 | (unsigned char) ((*pVBInfo->pSR22) & 0xFE)); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1802 | /* } else { */ |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1803 | /* xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22); */ |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1804 | /* } */ |
| 1805 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1806 | xgifb_reg_set(pVBInfo->P3c4, 0x21, *pVBInfo->pSR21); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1807 | |
| 1808 | printk("23"); |
| 1809 | |
| 1810 | XGINew_ChkSenseStatus(HwDeviceExtension, pVBInfo); |
| 1811 | XGINew_SetModeScratch(HwDeviceExtension, pVBInfo); |
| 1812 | |
| 1813 | printk("24"); |
| 1814 | |
Aaro Koskinen | 8104e32 | 2011-03-13 12:26:22 +0200 | [diff] [blame] | 1815 | xgifb_reg_set(pVBInfo->P3d4, 0x8c, 0x87); |
| 1816 | xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x31); |
Aaro Koskinen | b9ebf5e | 2011-03-13 12:26:06 +0200 | [diff] [blame] | 1817 | printk("25"); |
| 1818 | |
| 1819 | return 1; |
| 1820 | } /* end of init */ |