1522N/A-typedef enum _TX_CHIPTYPE {
1522N/A #define AST_DRIVER_NAME "ast"
1522N/A #define CMD_QUEUE_GUARD_BAND 0x00000020
1522N/A #define DEFAULT_HWC_NUM 0x00000002
1522N/A-/* Customized Info. for DVO */
1522N/A-#define HDMI_TX_I2C_SLAVE_ADDR 0x98
1522N/A #define ABI_VIDEODRV_VERSION_PATCH SET_ABI_VERSION(0, 5)
1522N/A int mon_h_active; /* Monitor Info. */
1522N/A- UCHAR jTxChipType; /* 3rd TX */
1522N/A- UCHAR *pDP501FWBufferVirtualAddress;
1522N/A XF86VideoAdaptorPtr adaptor;
1522N/A Atom xvBrightness, xvContrast, xvColorKey, xvHue, xvSaturation;
1522N/A- if (pAST->pDP501FWBufferVirtualAddress)
1522N/A- free(pAST->pDP501FWBufferVirtualAddress);
1522N/A free(pScrn->driverPrivate);
1522N/A if (pAST->jChipType == AST1180)
1522N/A Flags = ASTGetVGA2EDID(pScrn, DDC_data);
1522N/A- else if (pAST->jTxChipType == Tx_DP501)
1522N/A- Flags = ASTReadEDID_M68K(pScrn, DDC_data);
1522N/A- Flags = ASTGetVGAEDID(pScrn, DDC_data);
1522N/A Flags = ASTGetVGAEDID(pScrn, DDC_data);
1522N/A if (pAST->jChipType == AST1180)
1522N/A Flags = ASTGetVGA2EDID(pScrn, DDC_data);
1522N/A- else if (pAST->jTxChipType == Tx_DP501)
1522N/A- pAST->DP501_MaxVCLK = 0xFF;
1522N/A- Flags = ASTReadEDID_M68K(pScrn, DDC_data);
1522N/A- if (Flags) pAST->DP501_MaxVCLK = ASTGetLinkMaxCLK(pScrn);
1522N/A- Flags = ASTGetVGAEDID(pScrn, DDC_data);
1522N/A Flags = ASTGetVGAEDID(pScrn, DDC_data);
1522N/A- vAST1000DisplayOff(pScrn);
1522N/A vSetStdReg(pScrn, mode, &vgamodeinfo);
1522N/A vSetCRTCReg(pScrn, mode, &vgamodeinfo);
1522N/A vSetOffsetReg(pScrn, mode, &vgamodeinfo);
1634N/A /* clear video buffer to avoid display noise */
1522N/A /* Driver specific headers */
1522N/A __inline ULONG MIndwm(UCHAR *mmiobase, ULONG r)
1522N/A-#define I2C_BASE 0x1e780000
1522N/A-static ULONG GetFWBase(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- mmiobase = pAST->MMIOVirtualAddr;
1522N/A- return (MIndwm(mmiobase, 0x1e6e2104) & 0x7FFFFFFF);
1522N/A-static void send_ack(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- GetIndexRegMask(CRTC_PORT, 0x9b, 0xFF, SendACK);
1522N/A- SetIndexRegMask(CRTC_PORT, 0x9B, 0x00, SendACK);
1522N/A-static void send_nack(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- GetIndexRegMask(CRTC_PORT, 0x9b, 0xFF, SendACK);
1522N/A- SetIndexRegMask(CRTC_PORT, 0x9B, 0x00, SendACK);
1522N/A-static Bool wait_ack(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- GetIndexRegMask(CRTC_PORT, 0xd2, 0xFF, WaitACK);
1522N/A- } while ( (!WaitACK) && (retry++ < 1000) );
1522N/A-static Bool wait_nack(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- GetIndexRegMask(CRTC_PORT, 0xd2, 0xFF, WaitACK);
1522N/A- } while ( (WaitACK) && (retry++ < 1000) );
1522N/A-static void set_cmd_trigger(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- SetIndexRegMask(CRTC_PORT, 0x9B, ~0x40, 0x40);
1522N/A-static void clear_cmd_trigger(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- SetIndexRegMask(CRTC_PORT, 0x9B, ~0x40, 0x00);
1522N/A-static Bool write_cmd(ScrnInfoPtr pScrn, UCHAR data)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- SetIndexRegMask(CRTC_PORT, 0x9a, 0x00, data);
1522N/A-static Bool write_data(ScrnInfoPtr pScrn, UCHAR data)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- SetIndexRegMask(CRTC_PORT, 0x9a, 0x00, data);
1522N/A-static void SetDP501VideoOutput(ScrnInfoPtr pScrn, UCHAR Mode)
1522N/A- DelayMS(10); /* delay 10ms */
1522N/A-} /* SetDP501VideoOutput */
1522N/A-static BOOL BackupM68KFW(ScrnInfoPtr pScrn, UCHAR *addr, ULONG size)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- UCHAR *mmiobase = pAST->MMIOVirtualAddr;
1522N/A- Data = MIndwm(mmiobase, 0x1e6e2100) & 0x01;
1522N/A- if (Data) /* FW had been load */
1522N/A- /* copy image to buffer */
1522N/A- BootAddress = GetFWBase(pScrn);
1522N/A- *(ULONG *)(addr + i) = MIndwm(mmiobase, BootAddress + i);
1522N/A- } /* UEFI Driver Handling */
1522N/A-static BOOL LaunchM68K(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- UCHAR *mmiobase = pAST->MMIOVirtualAddr;
1522N/A- Data = MIndwm(mmiobase, 0x1e6e2100) & 0x03;
1522N/A- if (Data != 0x01) /* UEFI Driver Handling */
1522N/A- MOutdwm(mmiobase, 0x1e6e2100, 0x03);
1522N/A- Data = MIndwm(mmiobase, 0x1e6e2100);
1522N/A- if (pAST->pDP501FWBufferVirtualAddress)
1522N/A- pFWAddr = pAST->pDP501FWBufferVirtualAddress;
1522N/A- pFWAddr = AST_DP501_firmware;
1522N/A- Len = sizeof(AST_DP501_firmware) / sizeof(AST_DP501_firmware[0]);
1522N/A- MOutdwm(mmiobase, 0x1e6e2000, 0x1688a8a8); /* open passwd */
1522N/A- Data = MIndwm(mmiobase, 0x1e6e0004);
1522N/A- BootAddress -= 0x200000; /* - 2MB */
1522N/A- /* copy image to buffer */
1522N/A- Data = *(ULONG *)(pFWAddr + i);
1522N/A- MOutdwm(mmiobase, BootAddress + i, Data);
1522N/A- MOutdwm(mmiobase, 0x1e6e2000, 0x1688a8a8); /* open passwd */
1522N/A- MOutdwm(mmiobase, 0x1e6e2104, 0x80000000 + BootAddress);
1522N/A- MOutdwm(mmiobase, 0x1e6e2100, 1);
1522N/A- Data = MIndwm(mmiobase, 0x1e6e2040) & 0xFFFFF1FF; /* D[11:9] = 100b: UEFI handling */
1522N/A- MOutdwm(mmiobase, 0x1e6e2040, Data);
1522N/A- GetIndexRegMask(CRTC_PORT, 0x99, 0xFC, jReg); /* D[1:0]: Reserved Video Buffer */
1522N/A- SetIndexReg(CRTC_PORT, 0x99, jReg);
1522N/A- } /* UEFI Driver Handling */
1522N/A-Bool ASTReadEDID_M68K(ScrnInfoPtr pScrn, BYTE *pEDIDData)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- ULONG i, BootAddress, Offset, Data;
1522N/A- mmiobase = pAST->MMIOVirtualAddr;
1522N/A- BootAddress = GetFWBase(pScrn);
1522N/A- Data = MIndwm(mmiobase, BootAddress + Offset);
1522N/A- if ((Data & 0xF0) != 0x10) /* version: 1x */
1522N/A- /* validate PnP Monitor */
1522N/A- Data = MIndwm(mmiobase, BootAddress + Offset);
1522N/A- Data = MIndwm(mmiobase, BootAddress + Offset + i);
1522N/A- *(ULONG *)(pEDIDData + i) = Data;
1522N/A-UCHAR ASTGetLinkMaxCLK(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- ULONG BootAddress, Offset, Data;
1522N/A- UCHAR LinkCap[4], LinkRate, LinkLanes, MaxClk = 0xFF;
1522N/A- mmiobase = pAST->MMIOVirtualAddr;
1522N/A- BootAddress = GetFWBase(pScrn);
1522N/A- Data = MIndwm(mmiobase, BootAddress + Offset);
1522N/A- if ((Data & 0xF0) != 0x10) /* version: 1x */
1522N/A- /* Read Link Capability */
1522N/A- *(ULONG *)(LinkCap) = MIndwm(mmiobase, BootAddress + Offset);
1522N/A- if (LinkCap[2] == 0) /* no Max. CLK Assigned */
1522N/A- Data = (LinkRate == 0x0A) ? (90 * LinkLanes): (54 * LinkLanes);
1522N/A- if (Data > 255) Data = 255; /* Max. */
1522N/A ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1) / 8);
1522N/A- if (pAST->jTxChipType == Tx_DP501)
1522N/A- if (ulDCLK > pAST->DP501_MaxVCLK) ulDCLK = pAST->DP501_MaxVCLK;
1522N/A /* Add for AST2100, ycchen@061807 */
1634N/A if ((pAST->jChipType == AST2100) || (pAST->jChipType == AST2200) || (pAST->jChipType == AST2300) || (pAST->jChipType == AST2400) || (pAST->jChipType == AST2500) || (pAST->jChipType == AST1180) )
1522N/A- pAST->pDP501FWBufferVirtualAddress = NULL;
1522N/A- pAST->jTxChipType = Tx_NONE;
1522N/A- /* Get 3rd Tx Info from HW Reg. */
1522N/A- GetIndexRegMask(CRTC_PORT, 0xA3, 0xFF, jReg);
1522N/A- pAST->jTxChipType = Tx_Sil164;
1522N/A- /* Get 3rd Tx Info from BMC Scratch */
1634N/A- if ((pAST->jChipType == AST2300) || (pAST->jChipType == AST2400) || (pAST->jChipType == AST2500))
1522N/A- GetIndexRegMask(CRTC_PORT, 0xD1, 0x0E, jReg);
1522N/A- pAST->jTxChipType = Tx_Sil164;
1522N/A- pAST->pDP501FWBufferVirtualAddress = (UCHAR*) calloc(1, 32*1024);
1522N/A- if (pAST->pDP501FWBufferVirtualAddress)
1522N/A- if (BackupM68KFW(pScrn, pAST->pDP501FWBufferVirtualAddress, 32*1024) == FALSE)
1522N/A- free(pAST->pDP501FWBufferVirtualAddress);
1522N/A- pAST->pDP501FWBufferVirtualAddress = NULL;
1522N/A- pAST->jTxChipType = Tx_DP501;
1522N/A ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- if (pAST->jTxChipType == Tx_DP501)
1522N/A- SetDP501VideoOutput(pScrn, 0);
1522N/A if (pAST->jChipType == AST1180)
1522N/A ReadAST1180SOC(AST1180_GFX_BASE + AST1180_VGA1_CTRL, ulData);
1522N/A SetIndexRegMask(SEQ_PORT,0x01, 0xDF, 0x00);
1522N/A- if (pAST->jTxChipType == Tx_DP501)
1522N/A- SetDP501VideoOutput(pScrn, 1);
1522N/A void ASTBlankScreen(ScrnInfoPtr pScrn, Bool unblack)
1522N/A- if (PowerManagementMode != DPMSModeOn)
1522N/A- if (pAST->jTxChipType == Tx_DP501) SetDP501VideoOutput(pScrn, 0);
1522N/A if (pAST->jChipType == AST1180)
1522N/A ReadAST1180SOC(AST1180_GFX_BASE + AST1180_VGA1_CTRL, ulTemp);
1522N/A SetIndexRegMask(CRTC_PORT,0xB6, 0xFC, CRB6);
1522N/A- if (PowerManagementMode == DPMSModeOn)
1522N/A- if (pAST->jTxChipType == Tx_DP501) SetDP501VideoOutput(pScrn, 1);
1522N/A } /* vGetDefaultSettings */
1522N/A-static Bool InitDVO(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000;
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1;
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12000) = 0x1688A8A8;
1522N/A- GetIndexRegMask(CRTC_PORT, 0xD0, 0xFF, jReg);
1522N/A- if (!(jReg & 0x80)) /* Init SCU DVO Settings */
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12008); /* delay phase */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12008) = ulData;
1522N/A- if (pAST->jChipType == AST2300)
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12084); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12084) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12088); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12088) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12090); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12090) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12088); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12088) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x1208c); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x1208c) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x120a4); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x120a4) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x120a8); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x120a8) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12094); /* multi-pins for DVO single-edge */
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x12094) = ulData;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x1202c);
1522N/A- *(ULONG *) (pAST->MMIOVirtualAddr + 0x1202c) = ulData;
1522N/A- /* Init VGA DVO Settings */
1522N/A- SetIndexRegMask(CRTC_PORT, 0xA3, 0xCF, 0x80); /* enable DVO, single-edge */
1522N/A-static void vInit3rdTX(ScrnInfoPtr pScrn)
1522N/A- ASTRecPtr pAST = ASTPTR(pScrn);
1522N/A- /* Only support on AST2300/2400 */
1634N/A- if ((pAST->jChipType == AST2300) || (pAST->jChipType == AST2400) || (pAST->jChipType == AST2500))
1522N/A- GetIndexRegMask(CRTC_PORT, 0xD1, 0xFF, jReg); /* D[1]: DVO Enable */
1522N/A- switch (jReg & 0x0E) /* D[11:9] */
1522N/A- case 0x08: /* DP501 with VBIOS launch FW */
1522N/A- case 0x0C: /* DP501 with BMC launch FW */
1522N/A- default: /* Force to VGA */
1522N/A- if (pAST->jTxChipType == Tx_Sil164)
1522N/A- *(ULONG *)(pAST->MMIOVirtualAddr + 0x12000) = 0x1688A8A8;
1522N/A- ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x1202c);
1522N/A- *(ULONG *)(pAST->MMIOVirtualAddr) = ulData;
1522N/A * 1: resume from power management
1522N/A *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000 + ((addr) & 0x0000FFFF)) = (data); \
1522N/A-#define DelayUS(x) usleep(x)
1522N/A-#define DelayMS(x) DelayUS(1000*x)