[PATCH] xf86-video-ast: Fixed system hanged if disable P2A

Y.C. Chen yacheng600221 at gmail.com
Mon Apr 1 06:09:38 UTC 2019


From: "Y.C. Chen" <yc_chen at aspeedtech.com>

The origianl driver will access BMC configuration through P2A bridge.
It will cause system hanged if P2A bridge is disabled.

Signed-off-by: Y.C. Chen <yc_chen at aspeedtech.com>
---
 src/ast.h         |   1 +
 src/ast_vgatool.c | 184 ++++++++++++++++++++++++++++++------------------------
 2 files changed, 103 insertions(+), 82 deletions(-)

diff --git a/src/ast.h b/src/ast.h
index 1aa58c3..4309a6e 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -255,6 +255,7 @@ typedef struct _ASTRec {
     int			DBGSelect;
     Bool		VGA2Clone;
     Bool		SupportWideScreen;
+    Bool		DisableP2A;
 
     ULONG     		FBPhysAddr;			/* Frame buffer physical address     */
     ULONG     		MMIOPhysAddr;     	/* MMIO region physical address      */
diff --git a/src/ast_vgatool.c b/src/ast_vgatool.c
index 7e967f8..62b1c84 100644
--- a/src/ast_vgatool.c
+++ b/src/ast_vgatool.c
@@ -429,89 +429,101 @@ ASTGetDRAMInfo(ScrnInfoPtr pScrn)
     ULONG ulRefPLL, ulDeNumerator, ulNumerator, ulDivider;
     ULONG ulData, ulData2;
 
-    *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000;
-    *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1;
+    if (pAST->DisableP2A)
+    {
+        pAST->jDRAMType = DRAMTYPE_1Gx16;
+        pAST->ulDRAMBusWidth = 16;
+        if (pAST->jChipType == AST2500)
+            pAST->ulMCLK = 800;
+        else
+            pAST->ulMCLK = 396;
+    }
+    else
+    {
+        *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000;
+        *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1;
 
-    *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000) = 0xFC600309;
-    do {
-       ;
-    } while (*(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x10000) != 0x01);
+        *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000) = 0xFC600309;
+        do {
+           ;
+        } while (*(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x10000) != 0x01);
 
-    ulData = *(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x10004);
+        ulData = *(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x10004);
 
-    /* Get BusWidth */
-    if (ulData & 0x40)
-       pAST->ulDRAMBusWidth = 16;
-    else
-       pAST->ulDRAMBusWidth = 32;
+        /* Get BusWidth */
+        if (ulData & 0x40)
+           pAST->ulDRAMBusWidth = 16;
+        else
+           pAST->ulDRAMBusWidth = 32;
 
-    /* Get DRAM Type */
-    if ((pAST->jChipType == AST2300) || (pAST->jChipType == AST2400) || (pAST->jChipType == AST2500))
-    {
-        switch (ulData & 0x03)
+        /* Get DRAM Type */
+        if ((pAST->jChipType == AST2300) || (pAST->jChipType == AST2400) || (pAST->jChipType == AST2500))
         {
-        case 0x00:
-            pAST->jDRAMType = DRAMTYPE_512Mx16;
-            break;
-        default:
-        case 0x01:
-            pAST->jDRAMType = DRAMTYPE_1Gx16;
-            break;
-        case 0x02:
-            pAST->jDRAMType = DRAMTYPE_2Gx16;
-            break;
-        case 0x03:
-            pAST->jDRAMType = DRAMTYPE_4Gx16;
+            switch (ulData & 0x03)
+            {
+            case 0x00:
+                pAST->jDRAMType = DRAMTYPE_512Mx16;
             break;
+            default:
+            case 0x01:
+                pAST->jDRAMType = DRAMTYPE_1Gx16;
+                break;
+            case 0x02:
+                pAST->jDRAMType = DRAMTYPE_2Gx16;
+                break;
+            case 0x03:
+                pAST->jDRAMType = DRAMTYPE_4Gx16;
+                break;
+            }
         }
-    }
-    else
-    {
-        switch (ulData & 0x0C)
+        else
         {
-        case 0x00:
-        case 0x04:
-            pAST->jDRAMType = DRAMTYPE_512Mx16;
-            break;
-
-        case 0x08:
-            if (ulData & 0x40)		/* 16bits */
-                pAST->jDRAMType = DRAMTYPE_1Gx16;
-            else			/* 32bits */
-                pAST->jDRAMType = DRAMTYPE_512Mx32;
-            break;
-
-        case 0x0C:
-            pAST->jDRAMType = DRAMTYPE_1Gx32;
-            break;
+            switch (ulData & 0x0C)
+            {
+            case 0x00:
+            case 0x04:
+                pAST->jDRAMType = DRAMTYPE_512Mx16;
+                break;
+
+            case 0x08:
+                if (ulData & 0x40)		/* 16bits */
+                    pAST->jDRAMType = DRAMTYPE_1Gx16;
+                else			/* 32bits */
+                    pAST->jDRAMType = DRAMTYPE_512Mx32;
+                break;
+
+            case 0x0C:
+                pAST->jDRAMType = DRAMTYPE_1Gx32;
+                break;
+            }
         }
-    }
 
-    /* Get MCLK */
-    ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10120);
-    ulData2 = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10170);
-    if (ulData2 & 0x2000)
-        ulRefPLL = 14318;
-    else
-        ulRefPLL = 12000;
+        /* Get MCLK */
+        ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10120);
+        ulData2 = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10170);
+        if (ulData2 & 0x2000)
+            ulRefPLL = 14318;
+        else
+            ulRefPLL = 12000;
 
-    ulDeNumerator = ulData & 0x1F;
-    ulNumerator = (ulData & 0x3FE0) >> 5;
+        ulDeNumerator = ulData & 0x1F;
+        ulNumerator = (ulData & 0x3FE0) >> 5;
 
-    ulData = (ulData & 0xC000) >> 14;
-    switch (ulData)
-    {
-    case 0x03:
-        ulDivider = 0x04;
-        break;
-    case 0x02:
-    case 0x01:
-        ulDivider = 0x02;
-        break;
-    default:
-        ulDivider = 0x01;
-    }
-    pAST->ulMCLK = ulRefPLL * (ulNumerator + 2) / ((ulDeNumerator + 2) * ulDivider * 1000);
+        ulData = (ulData & 0xC000) >> 14;
+        switch (ulData)
+        {
+        case 0x03:
+            ulDivider = 0x04;
+            break;
+        case 0x02:
+        case 0x01:
+            ulDivider = 0x02;
+            break;
+        default:
+            ulDivider = 0x01;
+        }
+        pAST->ulMCLK = ulRefPLL * (ulNumerator + 2) / ((ulDeNumerator + 2) * ulDivider * 1000);
+    } /* DisbleP2A */
 
 } /* ASTGetDRAMInfo */
 
@@ -657,6 +669,11 @@ ASTGetScratchOptions(ScrnInfoPtr pScrn)
    ULONG ulData;
    UCHAR jReg;
 
+   /* Check P2A Access */
+   pAST->DisableP2A = FALSE;
+   ulData = *(ULONG *)(pAST->MMIOVirtualAddr + 0xF004);
+   if (ulData == 0xFFFFFFFF) pAST->DisableP2A = TRUE;
+
    /* VGA2 Clone Support */
    GetIndexRegMask(CRTC_PORT, 0x90, 0xFF, jReg);
    if (jReg & 0x10)
@@ -3561,17 +3578,20 @@ Bool ASTInitVGA(ScrnInfoPtr pScrn, ULONG Flags)
        vSetDefVCLK(pScrn);
        vSetDefExtReg(pScrn);
 
-       if (Flags == 0)
-           vGetDefaultSettings(pScrn);
-
-       if (pAST->jChipType == AST2500)
-           vInitAST2500DRAMReg(pScrn);
-       else if ((pAST->jChipType == AST2300) || (pAST->jChipType == AST2400))
-           vInitAST2300DRAMReg(pScrn);
-       else
-           vInitDRAMReg(pScrn);
-
-       vInit3rdTX(pScrn);
+       if (pAST->DisableP2A == FALSE)
+       {
+           if (Flags == 0)
+               vGetDefaultSettings(pScrn);
+
+           if (pAST->jChipType == AST2500)
+               vInitAST2500DRAMReg(pScrn);
+           else if ((pAST->jChipType == AST2300) || (pAST->jChipType == AST2400))
+               vInitAST2300DRAMReg(pScrn);
+           else
+               vInitDRAMReg(pScrn);
+
+           vInit3rdTX(pScrn);
+       } /* Disable P2A */
    }
 
    return (TRUE);
-- 
1.8.3.1



More information about the xorg-devel mailing list