2012-07-06 04:40:36 -06:00
|
|
|
#include <linux/delay.h>
|
2011-12-05 15:10:36 -07:00
|
|
|
#include <linux/vmalloc.h>
|
2011-10-11 12:47:16 -06:00
|
|
|
|
2010-05-19 02:44:14 -06:00
|
|
|
#include "XGIfb.h"
|
|
|
|
#include "vb_def.h"
|
|
|
|
#include "vb_util.h"
|
|
|
|
#include "vb_setmode.h"
|
2012-06-18 05:12:05 -06:00
|
|
|
#include "vb_init.h"
|
2012-06-13 16:21:46 -06:00
|
|
|
static const unsigned short XGINew_DDRDRAM_TYPE340[4][2] = {
|
|
|
|
{ 16, 0x45},
|
|
|
|
{ 8, 0x35},
|
|
|
|
{ 4, 0x31},
|
|
|
|
{ 2, 0x21} };
|
|
|
|
|
|
|
|
static const unsigned short XGINew_DDRDRAM_TYPE20[12][2] = {
|
|
|
|
{ 128, 0x5D},
|
|
|
|
{ 64, 0x59},
|
|
|
|
{ 64, 0x4D},
|
|
|
|
{ 32, 0x55},
|
|
|
|
{ 32, 0x49},
|
|
|
|
{ 32, 0x3D},
|
|
|
|
{ 16, 0x51},
|
|
|
|
{ 16, 0x45},
|
|
|
|
{ 16, 0x39},
|
|
|
|
{ 8, 0x41},
|
|
|
|
{ 8, 0x35},
|
|
|
|
{ 4, 0x31} };
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-12-05 15:10:36 -07:00
|
|
|
#define XGIFB_ROM_SIZE 65536
|
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
static unsigned char
|
|
|
|
XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,
|
|
|
|
struct vb_device_info *pVBInfo)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned char data, temp;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType < XG20) {
|
2012-06-13 16:21:52 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3c4, 0x39) & 0x02;
|
|
|
|
if (data == 0)
|
|
|
|
data = (xgifb_reg_get(pVBInfo->P3c4, 0x3A) &
|
|
|
|
0x02) >> 1;
|
|
|
|
return data;
|
2011-03-13 04:26:06 -06:00
|
|
|
} else if (HwDeviceExtension->jChipType == XG27) {
|
2011-03-13 04:26:23 -06:00
|
|
|
temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
|
2012-03-19 11:50:09 -06:00
|
|
|
if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
|
2011-03-13 04:26:06 -06:00
|
|
|
data = 0; /* DDR */
|
|
|
|
else
|
|
|
|
data = 1; /* DDRII */
|
|
|
|
return data;
|
|
|
|
} else if (HwDeviceExtension->jChipType == XG21) {
|
2011-04-22 22:11:16 -06:00
|
|
|
/* Independent GPIO control */
|
|
|
|
xgifb_reg_and(pVBInfo->P3d4, 0xB4, ~0x02);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(800, 1800);
|
2011-03-13 04:26:24 -06:00
|
|
|
xgifb_reg_or(pVBInfo->P3d4, 0x4A, 0x80); /* Enable GPIOH read */
|
2011-04-22 22:11:16 -06:00
|
|
|
/* GPIOF 0:DVI 1:DVO */
|
2013-05-13 15:41:45 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3d4, 0x48);
|
2016-11-16 20:04:14 -07:00
|
|
|
/*
|
|
|
|
* HOTPLUG_SUPPORT
|
|
|
|
* for current XG20 & XG21, GPIOH is floating, driver will
|
2016-02-14 22:57:38 -07:00
|
|
|
* fix DDR temporarily
|
|
|
|
*/
|
2013-05-13 15:41:45 -06:00
|
|
|
/* DVI read GPIOH */
|
|
|
|
data &= 0x01; /* 1=DDRII, 0=DDR */
|
2011-03-13 04:26:06 -06:00
|
|
|
/* ~HOTPLUG_SUPPORT */
|
2011-03-13 04:26:24 -06:00
|
|
|
xgifb_reg_or(pVBInfo->P3d4, 0xB4, 0x02);
|
2011-03-13 04:26:06 -06:00
|
|
|
return data;
|
2014-09-05 09:09:34 -06:00
|
|
|
}
|
|
|
|
data = xgifb_reg_get(pVBInfo->P3d4, 0x97) & 0x01;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2014-09-05 09:09:34 -06:00
|
|
|
if (data == 1)
|
|
|
|
data++;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2014-09-05 09:09:34 -06:00
|
|
|
return data;
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
static void XGINew_DDR1x_MRS_340(unsigned long P3c4,
|
|
|
|
struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x01);
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x20);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x80);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(3, 1003);
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x20);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x80);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(60, 1060);
|
2013-03-27 15:53:15 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, pVBInfo->SR18[pVBInfo->ram_type]); /* SR18 */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x01);
|
2012-11-04 12:15:04 -07:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x03);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x83);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(1, 1001);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x03);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(500, 1500);
|
2013-03-27 15:53:15 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, pVBInfo->SR18[pVBInfo->ram_type]); /* SR18 */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x00);
|
2012-11-04 12:15:04 -07:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x03);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x83);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x00);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-07-16 14:13:28 -06:00
|
|
|
static void XGINew_SetMemoryClock(struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x28,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->MCLKData[pVBInfo->ram_type].SR28);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x29,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->MCLKData[pVBInfo->ram_type].SR29);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x2A,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->MCLKData[pVBInfo->ram_type].SR2A);
|
2011-04-22 22:11:16 -06:00
|
|
|
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x2E,
|
2012-11-04 12:14:57 -07:00
|
|
|
XGI340_ECLKData[pVBInfo->ram_type].SR2E);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x2F,
|
2012-11-04 12:14:57 -07:00
|
|
|
XGI340_ECLKData[pVBInfo->ram_type].SR2F);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x30,
|
2012-11-04 12:14:57 -07:00
|
|
|
XGI340_ECLKData[pVBInfo->ram_type].SR30);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static void XGINew_DDRII_Bootup_XG27(
|
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
|
|
|
unsigned long P3c4, struct vb_device_info *pVBInfo)
|
|
|
|
{
|
|
|
|
unsigned long P3d4 = P3c4 + 0x10;
|
2014-03-29 21:44:59 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
|
2013-07-16 14:13:28 -06:00
|
|
|
XGINew_SetMemoryClock(pVBInfo);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
/* Set Double Frequency */
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x97, pVBInfo->XGINew_CR97); /* CR97 */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(200, 1200);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* Set SR18 */ /* EMRS2 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x80); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x20); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* Set SR18 */ /* EMRS3 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0xC0); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x20); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* Set SR18 */ /* EMRS1 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x40); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x20); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(30, 1030);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x42); /* Set SR18 */ /* MRS, DLL Enable */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x0A); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(30, 1030);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00); /* Set SR16 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x80); /* Set SR16 */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x04); /* Set SR1B */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(60, 1060);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x00); /* Set SR1B */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x42); /* Set SR18 */ /* MRS, DLL Reset */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x08); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00); /* Set SR16 */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(30, 1030);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x83); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x80); /* Set SR18 */ /* MRS, ODT */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x46); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x20); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(30, 1030);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* Set SR18 */ /* EMRS */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x40); /* Set SR19 */
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x20); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(30, 1030);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
/* Set SR1B refresh control 000:close; 010:open */
|
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x04);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(200, 1200);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
|
2016-11-16 20:04:13 -07:00
|
|
|
unsigned long P3c4,
|
|
|
|
struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
|
|
|
unsigned long P3d4 = P3c4 + 0x10;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
|
2013-07-16 14:13:28 -06:00
|
|
|
XGINew_SetMemoryClock(pVBInfo);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x97, 0x11); /* CR97 */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(200, 1200);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* EMRS2 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x80);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x05);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x85);
|
|
|
|
|
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* EMRS3 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0xC0);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x05);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x85);
|
|
|
|
|
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00); /* EMRS1 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x40);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x05);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x85);
|
|
|
|
|
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x02);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x05);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x85);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x04); /* SR1B */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(30, 1030);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x00); /* SR1B */
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(100, 1100);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x05);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x85);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(200, 1200);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4,
|
|
|
|
struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x01);
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x40);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x80);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(60, 1060);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x40);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x80);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(60, 1060);
|
2013-03-27 15:53:15 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, pVBInfo->SR18[pVBInfo->ram_type]); /* SR18 */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x01);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x03);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x83);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(1, 1001);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x03);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(500, 1500);
|
2013-03-27 15:53:15 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x18, pVBInfo->SR18[pVBInfo->ram_type]); /* SR18 */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x19, 0x00);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x03);
|
|
|
|
xgifb_reg_set(P3c4, 0x16, 0x83);
|
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x00);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static void XGINew_DDR1x_DefaultRegister(
|
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
|
|
|
unsigned long Port, struct vb_device_info *pVBInfo)
|
|
|
|
{
|
|
|
|
unsigned long P3d4 = Port, P3c4 = Port - 0x10;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType >= XG20) {
|
2013-07-16 14:13:28 -06:00
|
|
|
XGINew_SetMemoryClock(pVBInfo);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x82,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[11][pVBInfo->ram_type]); /* CR82 */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x85,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[12][pVBInfo->ram_type]); /* CR85 */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x86,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[13][pVBInfo->ram_type]); /* CR86 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x98, 0x01);
|
|
|
|
xgifb_reg_set(P3d4, 0x9A, 0x02);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
XGINew_DDR1x_MRS_XG20(P3c4, pVBInfo);
|
|
|
|
} else {
|
2013-07-16 14:13:28 -06:00
|
|
|
XGINew_SetMemoryClock(pVBInfo);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
switch (HwDeviceExtension->jChipType) {
|
|
|
|
case XG42:
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR82 */
|
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x82,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[11][pVBInfo->ram_type]);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR85 */
|
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x85,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[12][pVBInfo->ram_type]);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR86 */
|
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x86,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[13][pVBInfo->ram_type]);
|
2011-03-13 04:26:06 -06:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x82, 0x88);
|
|
|
|
xgifb_reg_set(P3d4, 0x86, 0x00);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* Insert read command for delay */
|
|
|
|
xgifb_reg_get(P3d4, 0x86);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x86, 0x88);
|
2011-03-13 04:26:23 -06:00
|
|
|
xgifb_reg_get(P3d4, 0x86);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x86,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[13][pVBInfo->ram_type]);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x82, 0x77);
|
|
|
|
xgifb_reg_set(P3d4, 0x85, 0x00);
|
2011-04-22 22:11:16 -06:00
|
|
|
|
|
|
|
/* Insert read command for delay */
|
|
|
|
xgifb_reg_get(P3d4, 0x85);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x85, 0x88);
|
2011-04-22 22:11:16 -06:00
|
|
|
|
|
|
|
/* Insert read command for delay */
|
|
|
|
xgifb_reg_get(P3d4, 0x85);
|
|
|
|
/* CR85 */
|
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x85,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[12][pVBInfo->ram_type]);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR82 */
|
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x82,
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->CR40[11][pVBInfo->ram_type]);
|
2011-03-13 04:26:06 -06:00
|
|
|
break;
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x97, 0x00);
|
|
|
|
xgifb_reg_set(P3d4, 0x98, 0x01);
|
|
|
|
xgifb_reg_set(P3d4, 0x9A, 0x02);
|
2011-03-13 04:26:06 -06:00
|
|
|
XGINew_DDR1x_MRS_340(P3c4, pVBInfo);
|
|
|
|
}
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static void XGINew_DDR2_DefaultRegister(
|
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
|
|
|
unsigned long Port, struct vb_device_info *pVBInfo)
|
|
|
|
{
|
|
|
|
unsigned long P3d4 = Port, P3c4 = Port - 0x10;
|
2016-11-16 20:04:14 -07:00
|
|
|
/*
|
|
|
|
* keep following setting sequence, each setting in
|
2016-03-29 16:12:40 -06:00
|
|
|
* the same reg insert idle
|
|
|
|
*/
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x82, 0x77);
|
|
|
|
xgifb_reg_set(P3d4, 0x86, 0x00);
|
2011-03-13 04:26:23 -06:00
|
|
|
xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x86, 0x88);
|
2011-03-13 04:26:23 -06:00
|
|
|
xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR86 */
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][pVBInfo->ram_type]);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x82, 0x77);
|
|
|
|
xgifb_reg_set(P3d4, 0x85, 0x00);
|
2011-03-13 04:26:23 -06:00
|
|
|
xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x85, 0x88);
|
2011-03-13 04:26:23 -06:00
|
|
|
xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x85,
|
|
|
|
pVBInfo->CR40[12][pVBInfo->ram_type]); /* CR85 */
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27)
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR82 */
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][pVBInfo->ram_type]);
|
2011-03-13 04:26:06 -06:00
|
|
|
else
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x82, 0xA8); /* CR82 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x98, 0x01);
|
|
|
|
xgifb_reg_set(P3d4, 0x9A, 0x02);
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27)
|
|
|
|
XGINew_DDRII_Bootup_XG27(HwDeviceExtension, P3c4, pVBInfo);
|
|
|
|
else
|
|
|
|
XGINew_DDR2_MRS_XG20(HwDeviceExtension, P3c4, pVBInfo);
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-02-04 16:29:44 -07:00
|
|
|
static void XGI_SetDRAM_Helper(unsigned long P3d4, u8 seed, u8 temp2, u8 reg,
|
2016-11-16 20:04:13 -07:00
|
|
|
u8 shift_factor, u8 mask1, u8 mask2)
|
2013-02-04 16:29:44 -07:00
|
|
|
{
|
|
|
|
u8 j;
|
2014-03-29 21:44:59 -06:00
|
|
|
|
2013-02-04 16:29:44 -07:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
temp2 |= (((seed >> (2 * j)) & 0x03) << shift_factor);
|
|
|
|
xgifb_reg_set(P3d4, reg, temp2);
|
|
|
|
xgifb_reg_get(P3d4, reg);
|
|
|
|
temp2 &= mask1;
|
|
|
|
temp2 += mask2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static void XGINew_SetDRAMDefaultRegister340(
|
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
|
|
|
unsigned long Port, struct vb_device_info *pVBInfo)
|
|
|
|
{
|
2013-02-05 12:38:35 -07:00
|
|
|
unsigned char temp, temp1, temp2, temp3, j, k;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned long P3d4 = Port, P3c4 = Port - 0x10;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x6D, pVBInfo->CR40[8][pVBInfo->ram_type]);
|
|
|
|
xgifb_reg_set(P3d4, 0x68, pVBInfo->CR40[5][pVBInfo->ram_type]);
|
|
|
|
xgifb_reg_set(P3d4, 0x69, pVBInfo->CR40[6][pVBInfo->ram_type]);
|
|
|
|
xgifb_reg_set(P3d4, 0x6A, pVBInfo->CR40[7][pVBInfo->ram_type]);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-02-04 16:29:45 -07:00
|
|
|
/* CR6B DQS fine tune delay */
|
2013-02-05 14:32:33 -07:00
|
|
|
temp = 0xaa;
|
2013-02-04 16:29:45 -07:00
|
|
|
XGI_SetDRAM_Helper(P3d4, temp, 0, 0x6B, 2, 0xF0, 0x10);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-02-04 16:29:45 -07:00
|
|
|
/* CR6E DQM fine tune delay */
|
|
|
|
XGI_SetDRAM_Helper(P3d4, 0, 0, 0x6E, 2, 0xF0, 0x10);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
temp3 = 0;
|
|
|
|
for (k = 0; k < 4; k++) {
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR6E_D[1:0] select channel */
|
|
|
|
xgifb_reg_and_or(P3d4, 0x6E, 0xFC, temp3);
|
2013-02-04 16:29:45 -07:00
|
|
|
XGI_SetDRAM_Helper(P3d4, 0, 0, 0x6F, 0, 0xF8, 0x08);
|
2011-03-13 04:26:06 -06:00
|
|
|
temp3 += 0x01;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x80,
|
|
|
|
pVBInfo->CR40[9][pVBInfo->ram_type]); /* CR80 */
|
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x81,
|
|
|
|
pVBInfo->CR40[10][pVBInfo->ram_type]); /* CR81 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
temp2 = 0x80;
|
2011-04-22 22:11:16 -06:00
|
|
|
/* CR89 terminator type select */
|
2013-02-04 16:29:44 -07:00
|
|
|
XGI_SetDRAM_Helper(P3d4, 0, temp2, 0x89, 0, 0xF0, 0x10);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-11-04 12:14:56 -07:00
|
|
|
temp = 0;
|
2011-03-13 04:26:06 -06:00
|
|
|
temp1 = temp & 0x03;
|
|
|
|
temp2 |= temp1;
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x89, temp2);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
temp = pVBInfo->CR40[3][pVBInfo->ram_type];
|
2011-03-13 04:26:06 -06:00
|
|
|
temp1 = temp & 0x0F;
|
|
|
|
temp2 = (temp >> 4) & 0x07;
|
|
|
|
temp3 = temp & 0x80;
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x45, temp1); /* CR45 */
|
|
|
|
xgifb_reg_set(P3d4, 0x99, temp2); /* CR99 */
|
2011-03-13 04:26:24 -06:00
|
|
|
xgifb_reg_or(P3d4, 0x40, temp3); /* CR40_D[7] */
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x41,
|
|
|
|
pVBInfo->CR40[0][pVBInfo->ram_type]); /* CR41 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27)
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x8F, XG27_CR8F); /* CR8F */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
for (j = 0; j <= 6; j++) /* CR90 - CR96 */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, (0x90 + j),
|
2016-11-16 20:04:13 -07:00
|
|
|
pVBInfo->CR40[14 + j][pVBInfo->ram_type]);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
for (j = 0; j <= 2; j++) /* CRC3 - CRC5 */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, (0xC3 + j),
|
2016-11-16 20:04:13 -07:00
|
|
|
pVBInfo->CR40[21 + j][pVBInfo->ram_type]);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
for (j = 0; j < 2; j++) /* CR8A - CR8B */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, (0x8A + j),
|
2016-11-16 20:04:13 -07:00
|
|
|
pVBInfo->CR40[1 + j][pVBInfo->ram_type]);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-04-06 16:13:51 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG42)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x8C, 0x87);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
xgifb_reg_set(P3d4,
|
|
|
|
0x59,
|
|
|
|
pVBInfo->CR40[4][pVBInfo->ram_type]); /* CR59 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0x83, 0x09); /* CR83 */
|
|
|
|
xgifb_reg_set(P3d4, 0x87, 0x00); /* CR87 */
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(P3d4, 0xCF, XG40_CRCF); /* CRCF */
|
2011-10-11 12:47:31 -06:00
|
|
|
if (pVBInfo->ram_type) {
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x17, 0x80); /* SR17 DDRII */
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x17, 0x02); /* SR17 DDRII */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
} else {
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x17, 0x00); /* SR17 DDR */
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1A, 0x87); /* SR1A */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
temp = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
|
|
|
|
if (temp == 0) {
|
|
|
|
XGINew_DDR1x_DefaultRegister(HwDeviceExtension, P3d4, pVBInfo);
|
|
|
|
} else {
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(P3d4, 0xB0, 0x80); /* DDRII Dual frequency mode */
|
2011-03-13 04:26:06 -06:00
|
|
|
XGINew_DDR2_DefaultRegister(HwDeviceExtension, P3d4, pVBInfo);
|
|
|
|
}
|
2013-03-27 15:53:13 -06:00
|
|
|
xgifb_reg_set(P3c4, 0x1B, 0x03); /* SR1B */
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-06-13 16:21:46 -06:00
|
|
|
static unsigned short XGINew_SetDRAMSize20Reg(
|
|
|
|
unsigned short dram_size,
|
2011-03-13 04:26:06 -06:00
|
|
|
struct vb_device_info *pVBInfo)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned short data = 0, memsize = 0;
|
|
|
|
int RankSize;
|
|
|
|
unsigned char ChannelNo;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-06-13 16:21:46 -06:00
|
|
|
RankSize = dram_size * pVBInfo->ram_bus / 8;
|
2011-03-13 04:26:23 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3c4, 0x13);
|
2011-03-13 04:26:06 -06:00
|
|
|
data &= 0x80;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (data == 0x80)
|
|
|
|
RankSize *= 2;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
data = 0;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-10-11 12:47:32 -06:00
|
|
|
if (pVBInfo->ram_channel == 3)
|
2011-03-13 04:26:06 -06:00
|
|
|
ChannelNo = 4;
|
|
|
|
else
|
2011-10-11 12:47:32 -06:00
|
|
|
ChannelNo = pVBInfo->ram_channel;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (ChannelNo * RankSize <= 256) {
|
|
|
|
while ((RankSize >>= 1) > 0)
|
|
|
|
data += 0x10;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
memsize = data >> 4;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Fix DRAM Sizing Error */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x14,
|
|
|
|
(xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) |
|
|
|
|
(data & 0xF0));
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
|
|
|
return memsize;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static int XGINew_ReadWriteRest(unsigned short StopAddr,
|
2016-11-16 20:04:13 -07:00
|
|
|
unsigned short StartAddr,
|
|
|
|
struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned long Position = 0;
|
2011-09-13 13:49:33 -06:00
|
|
|
void __iomem *fbaddr = pVBInfo->FBAddr;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-09-13 13:49:33 -06:00
|
|
|
writel(Position, fbaddr + Position);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
for (i = StartAddr; i <= StopAddr; i++) {
|
|
|
|
Position = 1 << i;
|
2011-09-13 13:49:33 -06:00
|
|
|
writel(Position, fbaddr + Position);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2016-03-27 13:13:00 -06:00
|
|
|
/* Fix #1759 Memory Size error in Multi-Adapter. */
|
|
|
|
usleep_range(500, 1500);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
Position = 0;
|
|
|
|
|
2011-09-13 13:49:33 -06:00
|
|
|
if (readl(fbaddr + Position) != Position)
|
2011-03-13 04:26:06 -06:00
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
for (i = StartAddr; i <= StopAddr; i++) {
|
|
|
|
Position = 1 << i;
|
2011-09-13 13:49:33 -06:00
|
|
|
if (readl(fbaddr + Position) != Position)
|
2011-03-13 04:26:06 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned char data;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3d4, 0x97);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if ((data & 0x10) == 0) {
|
2011-03-13 04:26:23 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3c4, 0x39);
|
2016-12-23 02:59:46 -07:00
|
|
|
return (data & 0x02) >> 1;
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2014-09-05 09:09:34 -06:00
|
|
|
return data & 0x01;
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension,
|
2016-11-16 20:04:13 -07:00
|
|
|
struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
|
|
|
unsigned char data;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
switch (HwDeviceExtension->jChipType) {
|
|
|
|
case XG20:
|
|
|
|
case XG21:
|
2011-03-13 04:26:23 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3d4, 0x97);
|
2011-03-13 04:26:06 -06:00
|
|
|
data = data & 0x01;
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 1; /* XG20 "JUST" one channel */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (data == 0) { /* Single_32_16 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1)
|
|
|
|
> 0x1000000) {
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 32; /* 32 bits */
|
2011-04-22 22:11:16 -06:00
|
|
|
/* 22bit + 2 rank + 32bit */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
|
|
|
|
return;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1) >
|
|
|
|
0x800000) {
|
|
|
|
/* 22bit + 1 rank + 32bit */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x13,
|
|
|
|
0x31);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x14,
|
|
|
|
0x42);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if (XGINew_ReadWriteRest(23,
|
|
|
|
23,
|
|
|
|
pVBInfo) == 1)
|
2011-03-13 04:26:06 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1) >
|
|
|
|
0x800000) {
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 16; /* 16 bits */
|
2011-04-22 22:11:16 -06:00
|
|
|
/* 22bit + 2 rank + 16bit */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1)
|
|
|
|
return;
|
2014-09-05 09:09:34 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x13,
|
|
|
|
0x31);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
} else { /* Dual_16_8 */
|
2011-04-22 22:11:16 -06:00
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1) >
|
|
|
|
0x800000) {
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 16; /* 16 bits */
|
2011-04-22 22:11:16 -06:00
|
|
|
/* (0x31:12x8x2) 22bit + 2 rank */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
|
2016-11-16 20:04:14 -07:00
|
|
|
/* 0x41:16Mx16 bit */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1)
|
|
|
|
return;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1) >
|
|
|
|
0x400000) {
|
|
|
|
/* (0x31:12x8x2) 22bit + 1 rank */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x13,
|
|
|
|
0x31);
|
2016-11-16 20:04:14 -07:00
|
|
|
/* 0x31:8Mx16 bit */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x14,
|
|
|
|
0x31);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if (XGINew_ReadWriteRest(22,
|
|
|
|
22,
|
|
|
|
pVBInfo) == 1)
|
2011-03-13 04:26:06 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1) >
|
|
|
|
0x400000) {
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 8; /* 8 bits */
|
2011-04-22 22:11:16 -06:00
|
|
|
/* (0x31:12x8x2) 22bit + 2 rank */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
|
2016-11-16 20:04:14 -07:00
|
|
|
/* 0x30:8Mx8 bit */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(22, 21, pVBInfo) == 1)
|
|
|
|
return;
|
2014-09-05 09:09:34 -06:00
|
|
|
|
|
|
|
/* (0x31:12x8x2) 22bit + 1 rank */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x13,
|
|
|
|
0x31);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(15, 1015);
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
|
|
|
}
|
2011-03-13 04:26:06 -06:00
|
|
|
break;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
case XG27:
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 16; /* 16 bits */
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 1; /* Single channel */
|
2016-11-16 20:04:14 -07:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x51); /* 32Mx16 bit */
|
2011-03-13 04:26:06 -06:00
|
|
|
break;
|
|
|
|
case XG42:
|
|
|
|
/*
|
2016-03-29 16:12:40 -06:00
|
|
|
* XG42 SR14 D[3] Reserve
|
|
|
|
* D[2] = 1, Dual Channel
|
|
|
|
* = 0, Single Channel
|
|
|
|
*
|
|
|
|
* It's Different from Other XG40 Series.
|
2011-03-13 04:26:06 -06:00
|
|
|
*/
|
|
|
|
if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII, DDR2x */
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 32; /* 32 bits */
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 2; /* 2 Channel */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x44);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
|
|
|
|
return;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x34);
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1)
|
|
|
|
return;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 1; /* Single Channel */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x40);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1)
|
|
|
|
return;
|
2014-09-05 09:09:34 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30);
|
2011-03-13 04:26:06 -06:00
|
|
|
} else { /* DDR */
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 64; /* 64 bits */
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 1; /* 1 channels */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
|
|
|
|
return;
|
2014-09-05 09:09:34 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x42);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
break;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
default: /* XG40 */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_CheckFrequence(pVBInfo) == 1) { /* DDRII */
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 32; /* 32 bits */
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 3;
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(25, 23, pVBInfo) == 1)
|
|
|
|
return;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 2; /* 2 channels */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x48);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
|
|
|
|
return;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x3C);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1) {
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 3; /* 4 channels */
|
2011-03-13 04:26:06 -06:00
|
|
|
} else {
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 2; /* 2 channels */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x38);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
|
|
|
} else { /* DDR */
|
2011-10-11 12:47:33 -06:00
|
|
|
pVBInfo->ram_bus = 64; /* 64 bits */
|
2011-10-11 12:47:32 -06:00
|
|
|
pVBInfo->ram_channel = 2; /* 2 channels */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2014-09-05 09:09:34 -06:00
|
|
|
if (XGINew_ReadWriteRest(25, 24, pVBInfo) == 1)
|
2011-03-13 04:26:06 -06:00
|
|
|
return;
|
2014-09-05 09:09:34 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4A);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
|
|
|
break;
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension,
|
2016-11-16 20:04:13 -07:00
|
|
|
struct vb_device_info *pVBInfo)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2012-06-13 16:21:44 -06:00
|
|
|
u8 i, size;
|
|
|
|
unsigned short memsize, start_addr;
|
2012-06-13 16:21:46 -06:00
|
|
|
const unsigned short (*dram_table)[2];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x15, 0x00); /* noninterleaving */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x1C, 0x00); /* nontiling */
|
2011-03-13 04:26:06 -06:00
|
|
|
XGINew_CheckChannel(HwDeviceExtension, pVBInfo);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType >= XG20) {
|
2012-06-13 16:21:44 -06:00
|
|
|
dram_table = XGINew_DDRDRAM_TYPE20;
|
|
|
|
size = ARRAY_SIZE(XGINew_DDRDRAM_TYPE20);
|
|
|
|
start_addr = 5;
|
2011-03-13 04:26:06 -06:00
|
|
|
} else {
|
2012-06-13 16:21:44 -06:00
|
|
|
dram_table = XGINew_DDRDRAM_TYPE340;
|
|
|
|
size = ARRAY_SIZE(XGINew_DDRDRAM_TYPE340);
|
|
|
|
start_addr = 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
2012-06-13 16:21:45 -06:00
|
|
|
/* SetDRAMSizingType */
|
2012-06-13 16:21:46 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3c4, 0x13, 0x80, dram_table[i][1]);
|
2015-10-22 08:51:22 -06:00
|
|
|
usleep_range(50, 1050); /* should delay 50 ns */
|
2012-06-13 16:21:45 -06:00
|
|
|
|
2012-06-13 16:21:46 -06:00
|
|
|
memsize = XGINew_SetDRAMSize20Reg(dram_table[i][0], pVBInfo);
|
2012-06-13 16:21:44 -06:00
|
|
|
|
|
|
|
if (memsize == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
memsize += (pVBInfo->ram_channel - 2) + 20;
|
|
|
|
if ((HwDeviceExtension->ulVideoMemorySize - 1) <
|
2015-10-22 10:50:15 -06:00
|
|
|
(unsigned long)(1 << memsize))
|
2012-06-13 16:21:44 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (XGINew_ReadWriteRest(memsize, start_addr, pVBInfo) == 1)
|
|
|
|
return 1;
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2011-03-13 04:26:06 -06:00
|
|
|
return 0;
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-12-05 15:10:45 -07:00
|
|
|
static void XGINew_SetDRAMSize_340(struct xgifb_video_info *xgifb_info,
|
2016-11-16 20:04:13 -07:00
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
|
|
|
struct vb_device_info *pVBInfo)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned short data;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-12-05 15:10:45 -07:00
|
|
|
XGISetModeNew(xgifb_info, HwDeviceExtension, 0x2e);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3c4, 0x21);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* disable read cache */
|
2015-10-22 10:50:15 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short)(data & 0xDF));
|
2011-12-05 15:10:45 -07:00
|
|
|
XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
XGINew_DDRSizing340(HwDeviceExtension, pVBInfo);
|
2011-03-13 04:26:23 -06:00
|
|
|
data = xgifb_reg_get(pVBInfo->P3c4, 0x21);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* enable read cache */
|
2015-10-22 10:50:15 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short)(data | 0x20));
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-12-05 15:10:40 -07:00
|
|
|
static u8 *xgifb_copy_rom(struct pci_dev *dev, size_t *rom_size)
|
2011-12-05 15:10:36 -07:00
|
|
|
{
|
|
|
|
void __iomem *rom_address;
|
2011-12-05 15:10:39 -07:00
|
|
|
u8 *rom_copy;
|
2011-12-05 15:10:36 -07:00
|
|
|
|
2011-12-05 15:10:40 -07:00
|
|
|
rom_address = pci_map_rom(dev, rom_size);
|
2015-10-22 10:48:26 -06:00
|
|
|
if (!rom_address)
|
2011-12-05 15:10:36 -07:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
rom_copy = vzalloc(XGIFB_ROM_SIZE);
|
2015-10-22 10:48:26 -06:00
|
|
|
if (!rom_copy)
|
2011-12-05 15:10:36 -07:00
|
|
|
goto done;
|
|
|
|
|
2011-12-05 15:10:40 -07:00
|
|
|
*rom_size = min_t(size_t, *rom_size, XGIFB_ROM_SIZE);
|
|
|
|
memcpy_fromio(rom_copy, rom_address, *rom_size);
|
2011-12-05 15:10:36 -07:00
|
|
|
|
|
|
|
done:
|
|
|
|
pci_unmap_rom(dev, rom_address);
|
|
|
|
return rom_copy;
|
|
|
|
}
|
|
|
|
|
2013-07-16 14:13:30 -06:00
|
|
|
static bool xgifb_read_vbios(struct pci_dev *pdev)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
2011-12-05 15:10:36 -07:00
|
|
|
struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev);
|
2011-12-05 15:10:39 -07:00
|
|
|
u8 *vbios;
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned long i;
|
2011-12-05 15:10:41 -07:00
|
|
|
unsigned char j;
|
2011-12-05 15:10:34 -07:00
|
|
|
struct XGI21_LVDSCapStruct *lvds;
|
2011-12-05 15:10:40 -07:00
|
|
|
size_t vbios_size;
|
2011-12-05 15:10:41 -07:00
|
|
|
int entry;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-12-05 15:10:40 -07:00
|
|
|
vbios = xgifb_copy_rom(pdev, &vbios_size);
|
2015-10-22 10:48:26 -06:00
|
|
|
if (!vbios) {
|
2012-07-06 04:40:40 -06:00
|
|
|
dev_err(&pdev->dev, "Video BIOS not available\n");
|
2013-03-27 15:53:07 -06:00
|
|
|
return false;
|
2011-12-05 15:10:36 -07:00
|
|
|
}
|
2011-12-05 15:10:40 -07:00
|
|
|
if (vbios_size <= 0x65)
|
|
|
|
goto error;
|
2011-12-05 15:10:48 -07:00
|
|
|
/*
|
|
|
|
* The user can ignore the LVDS bit in the BIOS and force the display
|
|
|
|
* type.
|
|
|
|
*/
|
|
|
|
if (!(vbios[0x65] & 0x1) &&
|
|
|
|
(!xgifb_info->display2_force ||
|
|
|
|
xgifb_info->display2 != XGIFB_DISP_LCD)) {
|
2011-12-05 15:10:36 -07:00
|
|
|
vfree(vbios);
|
2013-03-27 15:53:07 -06:00
|
|
|
return false;
|
2011-12-05 15:10:36 -07:00
|
|
|
}
|
2011-12-05 15:10:40 -07:00
|
|
|
if (vbios_size <= 0x317)
|
|
|
|
goto error;
|
2011-12-05 15:10:33 -07:00
|
|
|
i = vbios[0x316] | (vbios[0x317] << 8);
|
2011-12-05 15:10:40 -07:00
|
|
|
if (vbios_size <= i - 1)
|
|
|
|
goto error;
|
2011-12-05 15:10:33 -07:00
|
|
|
j = vbios[i - 1];
|
2011-12-05 15:10:40 -07:00
|
|
|
if (j == 0)
|
|
|
|
goto error;
|
2011-12-05 15:10:31 -07:00
|
|
|
if (j == 0xff)
|
|
|
|
j = 1;
|
2016-11-16 20:04:14 -07:00
|
|
|
|
|
|
|
/* Read the LVDS table index scratch register set by the BIOS. */
|
|
|
|
|
2011-12-05 15:10:41 -07:00
|
|
|
entry = xgifb_reg_get(xgifb_info->dev_info.P3d4, 0x36);
|
|
|
|
if (entry >= j)
|
|
|
|
entry = 0;
|
|
|
|
i += entry * 25;
|
2011-12-05 15:10:45 -07:00
|
|
|
lvds = &xgifb_info->lvds_data;
|
2011-12-05 15:10:41 -07:00
|
|
|
if (vbios_size <= i + 24)
|
|
|
|
goto error;
|
|
|
|
lvds->LVDS_Capability = vbios[i] | (vbios[i + 1] << 8);
|
|
|
|
lvds->LVDSHT = vbios[i + 2] | (vbios[i + 3] << 8);
|
|
|
|
lvds->LVDSVT = vbios[i + 4] | (vbios[i + 5] << 8);
|
|
|
|
lvds->LVDSHDE = vbios[i + 6] | (vbios[i + 7] << 8);
|
|
|
|
lvds->LVDSVDE = vbios[i + 8] | (vbios[i + 9] << 8);
|
|
|
|
lvds->LVDSHFP = vbios[i + 10] | (vbios[i + 11] << 8);
|
|
|
|
lvds->LVDSVFP = vbios[i + 12] | (vbios[i + 13] << 8);
|
|
|
|
lvds->LVDSHSYNC = vbios[i + 14] | (vbios[i + 15] << 8);
|
|
|
|
lvds->LVDSVSYNC = vbios[i + 16] | (vbios[i + 17] << 8);
|
|
|
|
lvds->VCLKData1 = vbios[i + 18];
|
|
|
|
lvds->VCLKData2 = vbios[i + 19];
|
|
|
|
lvds->PSC_S1 = vbios[i + 20];
|
|
|
|
lvds->PSC_S2 = vbios[i + 21];
|
|
|
|
lvds->PSC_S3 = vbios[i + 22];
|
|
|
|
lvds->PSC_S4 = vbios[i + 23];
|
|
|
|
lvds->PSC_S5 = vbios[i + 24];
|
2011-12-05 15:10:36 -07:00
|
|
|
vfree(vbios);
|
2013-03-27 15:53:07 -06:00
|
|
|
return true;
|
2011-12-05 15:10:40 -07:00
|
|
|
error:
|
2012-07-06 04:40:40 -06:00
|
|
|
dev_err(&pdev->dev, "Video BIOS corrupted\n");
|
2011-12-05 15:10:40 -07:00
|
|
|
vfree(vbios);
|
2013-03-27 15:53:07 -06:00
|
|
|
return false;
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-07-16 14:13:28 -06:00
|
|
|
static void XGINew_ChkSenseStatus(struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
|
|
|
unsigned short tempbx = 0, temp, tempcx, CR3CData;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
temp = xgifb_reg_get(pVBInfo->P3d4, 0x32);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (temp & Monitor1Sense)
|
|
|
|
tempbx |= ActiveCRT1;
|
|
|
|
if (temp & LCDSense)
|
|
|
|
tempbx |= ActiveLCD;
|
|
|
|
if (temp & Monitor2Sense)
|
|
|
|
tempbx |= ActiveCRT2;
|
|
|
|
if (temp & TVSense) {
|
|
|
|
tempbx |= ActiveTV;
|
|
|
|
if (temp & AVIDEOSense)
|
|
|
|
tempbx |= (ActiveAVideo << 8);
|
|
|
|
if (temp & SVIDEOSense)
|
|
|
|
tempbx |= (ActiveSVideo << 8);
|
|
|
|
if (temp & SCARTSense)
|
|
|
|
tempbx |= (ActiveSCART << 8);
|
|
|
|
if (temp & HiTVSense)
|
|
|
|
tempbx |= (ActiveHiTV << 8);
|
|
|
|
if (temp & YPbPrSense)
|
|
|
|
tempbx |= (ActiveYPbPr << 8);
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
tempcx = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
|
|
|
|
tempcx |= (xgifb_reg_get(pVBInfo->P3d4, 0x3e) << 8);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (tempbx & tempcx) {
|
2011-03-13 04:26:23 -06:00
|
|
|
CR3CData = xgifb_reg_get(pVBInfo->P3d4, 0x3c);
|
2012-07-06 04:40:53 -06:00
|
|
|
if (!(CR3CData & DisplayDeviceFromCMOS))
|
2011-03-13 04:26:06 -06:00
|
|
|
tempcx = 0x1FF0;
|
|
|
|
} else {
|
|
|
|
tempcx = 0x1FF0;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
tempbx &= tempcx;
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x3d, (tempbx & 0x00FF));
|
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x3e, ((tempbx & 0xFF00) >> 8));
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-07-16 14:13:28 -06:00
|
|
|
static void XGINew_SetModeScratch(struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
|
|
|
unsigned short temp, tempcl = 0, tempch = 0, CR31Data, CR38Data;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
|
|
|
|
temp |= xgifb_reg_get(pVBInfo->P3d4, 0x3e) << 8;
|
|
|
|
temp |= (xgifb_reg_get(pVBInfo->P3d4, 0x31) & (DriverMode >> 8)) << 8;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
|
|
|
|
if (temp & ActiveCRT2)
|
|
|
|
tempcl = SetCRT2ToRAMDAC;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (temp & ActiveLCD) {
|
|
|
|
tempcl |= SetCRT2ToLCD;
|
|
|
|
if (temp & DriverMode) {
|
|
|
|
if (temp & ActiveTV) {
|
|
|
|
tempch = SetToLCDA | EnableDualEdge;
|
|
|
|
temp ^= SetCRT2ToLCD;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if ((temp >> 8) & ActiveAVideo)
|
|
|
|
tempcl |= SetCRT2ToAVIDEO;
|
|
|
|
if ((temp >> 8) & ActiveSVideo)
|
|
|
|
tempcl |= SetCRT2ToSVIDEO;
|
|
|
|
if ((temp >> 8) & ActiveSCART)
|
|
|
|
tempcl |= SetCRT2ToSCART;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (pVBInfo->IF_DEF_HiVision == 1) {
|
|
|
|
if ((temp >> 8) & ActiveHiTV)
|
2012-02-09 13:11:45 -07:00
|
|
|
tempcl |= SetCRT2ToHiVision;
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (pVBInfo->IF_DEF_YPbPr == 1) {
|
|
|
|
if ((temp >> 8) & ActiveYPbPr)
|
|
|
|
tempch |= SetYPbPr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((temp >> 8) & ActiveAVideo)
|
|
|
|
tempcl |= SetCRT2ToAVIDEO;
|
|
|
|
if ((temp >> 8) & ActiveSVideo)
|
|
|
|
tempcl |= SetCRT2ToSVIDEO;
|
|
|
|
if ((temp >> 8) & ActiveSCART)
|
|
|
|
tempcl |= SetCRT2ToSCART;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (pVBInfo->IF_DEF_HiVision == 1) {
|
|
|
|
if ((temp >> 8) & ActiveHiTV)
|
2012-02-09 13:11:45 -07:00
|
|
|
tempcl |= SetCRT2ToHiVision;
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (pVBInfo->IF_DEF_YPbPr == 1) {
|
|
|
|
if ((temp >> 8) & ActiveYPbPr)
|
|
|
|
tempch |= SetYPbPr;
|
|
|
|
}
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
tempcl |= SetSimuScanMode;
|
2016-11-16 20:04:12 -07:00
|
|
|
if ((!(temp & ActiveCRT1)) && ((temp & ActiveLCD) ||
|
|
|
|
(temp & ActiveTV) ||
|
|
|
|
(temp & ActiveCRT2)))
|
2012-02-09 13:11:46 -07:00
|
|
|
tempcl ^= (SetSimuScanMode | SwitchCRT2);
|
2011-03-13 04:26:06 -06:00
|
|
|
if ((temp & ActiveLCD) && (temp & ActiveTV))
|
2012-02-09 13:11:46 -07:00
|
|
|
tempcl ^= (SetSimuScanMode | SwitchCRT2);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x30, tempcl);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
CR31Data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
|
2011-03-13 04:26:06 -06:00
|
|
|
CR31Data &= ~(SetNotSimuMode >> 8);
|
|
|
|
if (!(temp & ActiveCRT1))
|
|
|
|
CR31Data |= (SetNotSimuMode >> 8);
|
|
|
|
CR31Data &= ~(DisableCRT2Display >> 8);
|
|
|
|
if (!((temp & ActiveLCD) || (temp & ActiveTV) || (temp & ActiveCRT2)))
|
|
|
|
CR31Data |= (DisableCRT2Display >> 8);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x31, CR31Data);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
CR38Data = xgifb_reg_get(pVBInfo->P3d4, 0x38);
|
2011-03-13 04:26:06 -06:00
|
|
|
CR38Data &= ~SetYPbPr;
|
|
|
|
CR38Data |= tempch;
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x38, CR38Data);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-11-12 15:09:25 -07:00
|
|
|
static unsigned short XGINew_SenseLCD(struct xgi_hw_device_info
|
|
|
|
*HwDeviceExtension,
|
|
|
|
struct vb_device_info *pVBInfo)
|
|
|
|
{
|
2013-05-13 15:41:46 -06:00
|
|
|
unsigned short temp = HwDeviceExtension->ulCRT2LCDType;
|
|
|
|
|
|
|
|
switch (HwDeviceExtension->ulCRT2LCDType) {
|
|
|
|
case LCD_640x480:
|
|
|
|
case LCD_1024x600:
|
|
|
|
case LCD_1152x864:
|
|
|
|
case LCD_1280x960:
|
|
|
|
case LCD_1152x768:
|
|
|
|
case LCD_1920x1440:
|
|
|
|
case LCD_2048x1536:
|
|
|
|
temp = 0; /* overwrite used ulCRT2LCDType */
|
|
|
|
break;
|
|
|
|
case LCD_UNKNOWN: /* unknown lcd, do nothing */
|
2011-11-12 15:09:25 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2013-05-13 15:41:46 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x36, 0xF0, temp);
|
|
|
|
return 1;
|
2011-11-12 15:09:25 -07:00
|
|
|
}
|
|
|
|
|
2013-03-27 15:53:07 -06:00
|
|
|
static void XGINew_GetXG21Sense(struct pci_dev *pdev,
|
2016-11-16 20:04:13 -07:00
|
|
|
struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
2013-03-27 15:53:07 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev);
|
2011-03-13 04:26:06 -06:00
|
|
|
unsigned char Temp;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-07-16 14:13:30 -06:00
|
|
|
if (xgifb_read_vbios(pdev)) { /* For XG21 LVDS */
|
2011-03-13 04:26:24 -06:00
|
|
|
xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* LVDS on chip */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0);
|
2011-03-13 04:26:06 -06:00
|
|
|
} else {
|
2016-11-16 20:04:14 -07:00
|
|
|
/* Enable GPIOA/B read */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03);
|
2011-03-13 04:26:23 -06:00
|
|
|
Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0xC0;
|
2011-03-13 04:26:06 -06:00
|
|
|
if (Temp == 0xC0) { /* DVI & DVO GPIOA/B pull high */
|
2013-03-27 15:53:07 -06:00
|
|
|
XGINew_SenseLCD(&xgifb_info->hw_info, pVBInfo);
|
2011-03-13 04:26:24 -06:00
|
|
|
xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* Enable read GPIOF */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x20, 0x20);
|
2013-05-13 15:41:47 -06:00
|
|
|
if (xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0x04)
|
|
|
|
Temp = 0xA0; /* Only DVO on chip */
|
2010-09-02 03:55:38 -06:00
|
|
|
else
|
2013-05-13 15:41:47 -06:00
|
|
|
Temp = 0x80; /* TMDS on chip */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, Temp);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* Disable read GPIOF */
|
|
|
|
xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20);
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-07-16 14:13:28 -06:00
|
|
|
static void XGINew_GetXG27Sense(struct vb_device_info *pVBInfo)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
|
|
|
unsigned char Temp, bCR4A;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
bCR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
|
2016-11-16 20:04:14 -07:00
|
|
|
/* Enable GPIOA/B/C read */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x07, 0x07);
|
2011-03-13 04:26:23 -06:00
|
|
|
Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0x07;
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x4A, bCR4A);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (Temp <= 0x02) {
|
2011-04-22 22:11:16 -06:00
|
|
|
/* LVDS setting */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x21);
|
2011-03-13 04:26:06 -06:00
|
|
|
} else {
|
2011-04-22 22:11:16 -06:00
|
|
|
/* TMDS/DVO setting */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xA0);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2011-03-13 04:26:24 -06:00
|
|
|
xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static unsigned char GetXG21FPBits(struct vb_device_info *pVBInfo)
|
|
|
|
{
|
|
|
|
unsigned char CR38, CR4A, temp;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* enable GPIOE read */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x10, 0x10);
|
2011-03-13 04:26:23 -06:00
|
|
|
CR38 = xgifb_reg_get(pVBInfo->P3d4, 0x38);
|
2011-03-13 04:26:06 -06:00
|
|
|
temp = 0;
|
|
|
|
if ((CR38 & 0xE0) > 0x80) {
|
2011-03-13 04:26:23 -06:00
|
|
|
temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
|
2011-03-13 04:26:06 -06:00
|
|
|
temp &= 0x08;
|
|
|
|
temp >>= 3;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
return temp;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo)
|
|
|
|
{
|
|
|
|
unsigned char CR4A, temp;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:23 -06:00
|
|
|
CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* enable GPIOA/B/C read */
|
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03);
|
2011-03-13 04:26:23 -06:00
|
|
|
temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
|
2013-05-13 15:41:48 -06:00
|
|
|
if (temp > 2)
|
2012-08-14 01:04:45 -06:00
|
|
|
temp = ((temp & 0x04) >> 1) | ((~temp) & 0x01);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
return temp;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-05-29 14:59:00 -06:00
|
|
|
static bool xgifb_bridge_is_on(struct vb_device_info *vb_info)
|
|
|
|
{
|
|
|
|
u8 flag;
|
|
|
|
|
|
|
|
flag = xgifb_reg_get(vb_info->Part4Port, 0x00);
|
|
|
|
return flag == 1 || flag == 2;
|
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:16 -06:00
|
|
|
unsigned char XGIInitNew(struct pci_dev *pdev)
|
2011-03-13 04:26:06 -06:00
|
|
|
{
|
2011-10-11 12:47:18 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev);
|
2011-10-11 12:47:16 -06:00
|
|
|
struct xgi_hw_device_info *HwDeviceExtension = &xgifb_info->hw_info;
|
2011-03-13 04:26:06 -06:00
|
|
|
struct vb_device_info VBINF;
|
|
|
|
struct vb_device_info *pVBInfo = &VBINF;
|
|
|
|
unsigned char i, temp = 0, temp1;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2015-10-22 10:48:26 -06:00
|
|
|
if (!pVBInfo->FBAddr) {
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_dbg(&pdev->dev, "pVBInfo->FBAddr == 0\n");
|
2011-03-13 04:26:06 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2013-01-20 17:57:47 -07:00
|
|
|
XGIRegInit(pVBInfo, xgifb_info->vga_base);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-01-20 17:57:48 -07:00
|
|
|
outb(0x67, pVBInfo->P3c2);
|
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
|
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Openkey */
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
|
2011-03-13 04:26:06 -06:00
|
|
|
|
|
|
|
/* GetXG21Sense (GPIO) */
|
|
|
|
if (HwDeviceExtension->jChipType == XG21)
|
2013-03-27 15:53:07 -06:00
|
|
|
XGINew_GetXG21Sense(pdev, pVBInfo);
|
2011-03-13 04:26:06 -06:00
|
|
|
|
|
|
|
if (HwDeviceExtension->jChipType == XG27)
|
2013-07-16 14:13:28 -06:00
|
|
|
XGINew_GetXG27Sense(pVBInfo);
|
2011-03-13 04:26:06 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Reset Extended register */
|
2011-03-13 04:26:06 -06:00
|
|
|
|
|
|
|
for (i = 0x06; i < 0x20; i++)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, i, 0);
|
2011-03-13 04:26:06 -06:00
|
|
|
|
|
|
|
for (i = 0x21; i <= 0x27; i++)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, i, 0);
|
2011-03-13 04:26:06 -06:00
|
|
|
|
2011-03-13 04:26:10 -06:00
|
|
|
for (i = 0x31; i <= 0x3B; i++)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, i, 0);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Auto over driver for XG42 */
|
2011-04-22 22:11:16 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG42)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x3B, 0xC0);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
for (i = 0x79; i <= 0x7C; i++)
|
2012-07-06 04:40:36 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, i, 0);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType >= XG20)
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x97, pVBInfo->XGINew_CR97);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* SetDefExt1Regs begin */
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x07, XGI330_SR07);
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27) {
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x40, XG27_SR40);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x41, XG27_SR41);
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x11, 0x0F);
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x1F, XGI330_SR1F);
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Frame buffer can read/write SR20 */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x20, 0xA0);
|
2012-07-06 04:40:36 -06:00
|
|
|
/* H/W request for slow corner chip */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x36, 0x70);
|
2012-07-06 04:40:36 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27)
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x36, XG27_SR36);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
if (HwDeviceExtension->jChipType < XG20) {
|
2011-10-11 12:47:16 -06:00
|
|
|
u32 Temp;
|
|
|
|
|
2011-03-13 04:26:10 -06:00
|
|
|
/* Set AGP customize registers (in SetDefAGPRegs) Start */
|
|
|
|
for (i = 0x47; i <= 0x4C; i++)
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4,
|
|
|
|
i,
|
2012-11-04 12:15:05 -07:00
|
|
|
XGI340_AGPReg[i - 0x47]);
|
2011-03-13 04:26:10 -06:00
|
|
|
|
|
|
|
for (i = 0x70; i <= 0x71; i++)
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4,
|
|
|
|
i,
|
2012-11-04 12:15:05 -07:00
|
|
|
XGI340_AGPReg[6 + i - 0x70]);
|
2011-03-13 04:26:10 -06:00
|
|
|
|
|
|
|
for (i = 0x74; i <= 0x77; i++)
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4,
|
|
|
|
i,
|
2012-11-04 12:15:05 -07:00
|
|
|
XGI340_AGPReg[8 + i - 0x74]);
|
2011-03-13 04:26:10 -06:00
|
|
|
|
2011-10-11 12:47:16 -06:00
|
|
|
pci_read_config_dword(pdev, 0x50, &Temp);
|
2011-03-13 04:26:10 -06:00
|
|
|
Temp >>= 20;
|
|
|
|
Temp &= 0xF;
|
|
|
|
|
|
|
|
if (Temp == 1)
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x48, 0x20); /* CR48 */
|
2011-03-13 04:26:06 -06:00
|
|
|
} /* != XG20 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
/* Set PCI */
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x23, XGI330_SR23);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x24, XGI330_SR24);
|
2012-11-04 12:15:02 -07:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x25, 0);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
if (HwDeviceExtension->jChipType < XG20) {
|
2011-03-13 04:26:06 -06:00
|
|
|
/* Set VB */
|
2013-07-16 14:13:28 -06:00
|
|
|
XGI_UnLockCRT2(pVBInfo);
|
2012-07-06 04:40:36 -06:00
|
|
|
/* disable VideoCapture */
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00);
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00);
|
2011-04-22 22:11:16 -06:00
|
|
|
/* chk if BCLK>=100MHz */
|
2013-02-15 12:37:10 -07:00
|
|
|
temp1 = xgifb_reg_get(pVBInfo->P3d4, 0x7B);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->Part1Port,
|
2012-06-13 16:21:52 -06:00
|
|
|
0x02, XGI330_CRT2Data_1_2);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->Part1Port, 0x2E, 0x08); /* use VB */
|
2011-03-13 04:26:06 -06:00
|
|
|
} /* != XG20 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x27, 0x1F);
|
2011-03-13 04:26:06 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
if ((HwDeviceExtension->jChipType == XG42) &&
|
|
|
|
XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo) != 0) {
|
|
|
|
/* Not DDR */
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x31,
|
2012-06-13 16:21:52 -06:00
|
|
|
(XGI330_SR31 & 0x3F) | 0x40);
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4,
|
|
|
|
0x32,
|
2012-06-13 16:21:52 -06:00
|
|
|
(XGI330_SR32 & 0xFC) | 0x01);
|
2010-09-02 03:55:38 -06:00
|
|
|
} else {
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x31, XGI330_SR31);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x32, XGI330_SR32);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2012-06-13 16:21:52 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x33, XGI330_SR33);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
if (HwDeviceExtension->jChipType < XG20) {
|
2013-05-29 14:59:00 -06:00
|
|
|
if (xgifb_bridge_is_on(pVBInfo)) {
|
2013-03-27 15:53:06 -06:00
|
|
|
xgifb_reg_set(pVBInfo->Part2Port, 0x00, 0x1C);
|
|
|
|
xgifb_reg_set(pVBInfo->Part4Port,
|
|
|
|
0x0D, XGI330_CRT2Data_4_D);
|
|
|
|
xgifb_reg_set(pVBInfo->Part4Port,
|
|
|
|
0x0E, XGI330_CRT2Data_4_E);
|
|
|
|
xgifb_reg_set(pVBInfo->Part4Port,
|
|
|
|
0x10, XGI330_CRT2Data_4_10);
|
|
|
|
xgifb_reg_set(pVBInfo->Part4Port, 0x0F, 0x3F);
|
2013-07-16 14:13:28 -06:00
|
|
|
XGI_LockCRT2(pVBInfo);
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2011-03-13 04:26:06 -06:00
|
|
|
} /* != XG20 */
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
XGI_SenseCRT1(pVBInfo);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG21) {
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4,
|
|
|
|
0x32,
|
|
|
|
~Monitor1Sense,
|
|
|
|
Monitor1Sense); /* Z9 default has CRT */
|
2011-03-13 04:26:06 -06:00
|
|
|
temp = GetXG21FPBits(pVBInfo);
|
2011-03-13 04:26:25 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x01, temp);
|
2010-09-02 03:55:38 -06:00
|
|
|
}
|
2011-03-13 04:26:06 -06:00
|
|
|
if (HwDeviceExtension->jChipType == XG27) {
|
2011-04-22 22:11:16 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4,
|
|
|
|
0x32,
|
|
|
|
~Monitor1Sense,
|
|
|
|
Monitor1Sense); /* Z9 default has CRT */
|
2011-03-13 04:26:06 -06:00
|
|
|
temp = GetXG27FPBits(pVBInfo);
|
2011-03-13 04:26:25 -06:00
|
|
|
xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x03, temp);
|
2011-03-13 04:26:06 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:31 -06:00
|
|
|
pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-22 22:11:16 -06:00
|
|
|
XGINew_SetDRAMDefaultRegister340(HwDeviceExtension,
|
|
|
|
pVBInfo->P3d4,
|
|
|
|
pVBInfo);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-12-05 15:10:45 -07:00
|
|
|
XGINew_SetDRAMSize_340(xgifb_info, HwDeviceExtension, pVBInfo);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:15:02 -07:00
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x22, 0xfa);
|
|
|
|
xgifb_reg_set(pVBInfo->P3c4, 0x21, 0xa3);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-07-16 14:13:28 -06:00
|
|
|
XGINew_ChkSenseStatus(pVBInfo);
|
|
|
|
XGINew_SetModeScratch(pVBInfo);
|
2010-09-02 03:55:38 -06:00
|
|
|
|
2011-03-13 04:26:22 -06:00
|
|
|
xgifb_reg_set(pVBInfo->P3d4, 0x8c, 0x87);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-03-13 04:26:06 -06:00
|
|
|
return 1;
|
|
|
|
} /* end of init */
|