From 519ec079beb7d2b5ba48b0dcb3d1f8de09403d4d Mon Sep 17 00:00:00 2001 From: Stanley Chang Date: Thu, 14 Oct 2021 15:42:44 +0800 Subject: [PATCH] [TGL] Fix S0ix issues This patch fixes three S0ix issues: 1. a regression caused by commit 20889 where the FspsConfig->SerialIoUartMode missed configuring for legacy UART 2. failed s0ix when assigning uart port2 as debug port: root caused by Maurice. He pointed out that several uart properties should not be reset This fixed #1314. 3. conflict with TCC/TSN: In TGL, S0ix should be disabled when either TCC or TSN is enabled. If s0ix is enabled, the patch checks TCC/TSN enabling status and forces turning off S0ix if TCC/TSN is enabled. Signed-off-by: Stanley Chang --- .../CfgData/CfgData_Tcc_Feature.dlt | 2 ++ .../CfgData/CfgData_Tsn_Feature.dlt | 2 ++ .../Stage1BBoardInitLib/Stage1BBoardInitLib.c | 17 ++++++++++++++++- .../Stage2BoardInitLib/Stage2BoardInitLib.c | 9 ++------- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tcc_Feature.dlt b/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tcc_Feature.dlt index 5c3fbeb2..57d1d964 100644 --- a/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tcc_Feature.dlt +++ b/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tcc_Feature.dlt @@ -8,6 +8,8 @@ ## # +FEATURES_CFG_DATA.Features.S0ix | 0 + # Enable TCC config data TCC_CFG_DATA.TccEnable | 1 TCC_CFG_DATA.TccTuning | 1 diff --git a/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tsn_Feature.dlt b/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tsn_Feature.dlt index b007c9c6..6f2c5765 100644 --- a/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tsn_Feature.dlt +++ b/Platform/TigerlakeBoardPkg/CfgData/CfgData_Tsn_Feature.dlt @@ -8,6 +8,8 @@ ## # +FEATURES_CFG_DATA.Features.S0ix | 0 + SILICON_CFG_DATA.PchTsnEnable | 1 SILICON_CFG_DATA.PchTsnLinkSpeed | 3 diff --git a/Platform/TigerlakeBoardPkg/Library/Stage1BBoardInitLib/Stage1BBoardInitLib.c b/Platform/TigerlakeBoardPkg/Library/Stage1BBoardInitLib/Stage1BBoardInitLib.c index f5eddb59..d6dc4f2d 100644 --- a/Platform/TigerlakeBoardPkg/Library/Stage1BBoardInitLib/Stage1BBoardInitLib.c +++ b/Platform/TigerlakeBoardPkg/Library/Stage1BBoardInitLib/Stage1BBoardInitLib.c @@ -97,6 +97,12 @@ TccModePreMemConfig ( FspmUpd->FspmConfig.DsoTuningEnPreMem = TccCfgData->TccTuning; FspmUpd->FspmConfig.TccErrorLogEnPreMem = TccCfgData->TccErrorLog; + // S0ix is disabled if TCC is enabled. + if (PLAT_FEAT.S0ixEnable == 1) { + PLAT_FEAT.S0ixEnable = 0; + DEBUG ((DEBUG_INFO, "S0ix is turned off when TCC is enabled\n")); + } + // Load TCC stream config from container TccStreamBase = NULL; TccStreamSize = 0; @@ -118,6 +124,9 @@ TccModePreMemConfig ( FspmUpd->FspmConfig.PowerDownMode = PolicyConfig->MemPowerDown; FspmUpd->FspmConfig.DisPgCloseIdleTimeout = PolicyConfig->DisPgCloseIdle; PLAT_FEAT.S0ixEnable = PolicyConfig->Sstates; + if (PLAT_FEAT.S0ixEnable == 1) { + DEBUG ((DEBUG_INFO, "S0ix is forced turning on by TCC DSO\n")); + } DEBUG ((DEBUG_INFO, "Dump TCC DSO BIOS settings:\n")); DumpHex (2, 0, sizeof(BIOS_SETTINGS), PolicyConfig); } @@ -503,9 +512,15 @@ UpdateFspConfig ( FeaturesCfgData = (FEATURES_CFG_DATA *) FindConfigDataByTag (CDATA_FEATURES_TAG); if (FeaturesCfgData != NULL) { PLAT_FEAT.S0ixEnable = FeaturesCfgData->Features.S0ix; + + // S0ix is disabled if TSN is enabled. + if ((PLAT_FEAT.S0ixEnable == 1) && (SiCfgData != NULL) && (SiCfgData->PchTsnEnable == 1)) { + PLAT_FEAT.S0ixEnable = 0; + DEBUG ((DEBUG_INFO, "S0ix is turned off when TSN is enabled\n")); + } } - // Update TCC related UPDs if TCC is enabled + // Update TCC related UPDs if TCC is enabled if (FeaturePcdGet (PcdTccEnabled)) { TccModePreMemConfig (FspmUpd); } diff --git a/Platform/TigerlakeBoardPkg/Library/Stage2BoardInitLib/Stage2BoardInitLib.c b/Platform/TigerlakeBoardPkg/Library/Stage2BoardInitLib/Stage2BoardInitLib.c index 321f4afc..fa338b56 100644 --- a/Platform/TigerlakeBoardPkg/Library/Stage2BoardInitLib/Stage2BoardInitLib.c +++ b/Platform/TigerlakeBoardPkg/Library/Stage2BoardInitLib/Stage2BoardInitLib.c @@ -1363,9 +1363,8 @@ UpdateFspConfig ( // Inform FSP to skip debug UART init FspsConfig->SerialIoDebugUartNumber = DebugPort; FspsConfig->SerialIoUartMode[DebugPort] = 0x4; - if (S0IX_STATUS() == 1) { - FspsConfig->SerialIoUartMode[DebugPort] = 1; // Force UART to PCI mode to enable OS to have full control - } + } else if (S0IX_STATUS() == 1) { // legacy UART + FspsConfig->SerialIoUartMode[2] = 1; // Force UART to PCI mode to enable OS to have full control } // @@ -1713,10 +1712,6 @@ UpdateFspConfig ( // PCH SERIAL_UART_CONFIG for (Index = 0; Index < GetPchMaxSerialIoUartControllersNum (); Index++) { - FspsConfig->SerialIoUartParity[Index] = 1; - FspsConfig->SerialIoUartDataBits[Index] = 0x8; - FspsConfig->SerialIoUartStopBits[Index] = 1; - FspsConfig->SerialIoUartAutoFlow[Index] = 1; FspsConfig->SerialIoUartPowerGating[Index] = 2; FspsConfig->SerialIoUartDmaEnable[Index] = 1; FspsConfig->SerialIoUartDbg2[Index] = 0;