public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 07/1 BroxtonPlatformPkg: Add BensonTypeC support
@ 2017-08-24  3:18 Guo, Mang
  0 siblings, 0 replies; only message in thread
From: Guo, Mang @ 2017-08-24  3:18 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Guo Mang <mang.guo@intel.com>
---
 .../BensonGlacier/BoardInitPostMem/BoardInit.c     |   8 -
 .../BensonGlacier/BoardInitPostMem/BoardInit.h     |  15 +-
 .../BoardInitPostMem/BoardInitMiscs.c              |  37 ++-
 .../BoardInitPostMem/BoardInitMiscs.h              |  68 +++--
 .../BoardInitPostMem/BoardInitPostMem.inf          |   6 +-
 .../Board/BensonGlacier/BoardInitPostMem/TypeC.c   | 288 +++++++++++++++++++++
 .../Board/BensonGlacier/BoardInitPostMem/TypeC.h   |  79 ++++++
 7 files changed, 463 insertions(+), 38 deletions(-)
 create mode 100644 Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.c
 create mode 100644 Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.h

diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c
index 7c44a63..729a158 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.c
@@ -13,15 +13,7 @@
 
 **/
 
-#include <PiPei.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/PcdLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Guid/PlatformInfo_Aplk.h>
-#include <Ppi/BoardInitSignalling.h>
 #include "BoardInit.h"
-#include "BoardInitMiscs.h"
 
 EFI_STATUS
 EFIAPI
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.h b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.h
index 0a549c2..870f9c3 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.h
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInit.h
@@ -18,10 +18,21 @@
 #define _BENSON_BOARDINIT_H_
 
 #include <PiPei.h>
-#include <Library/IoLib.h>
+
+#include <Guid/PlatformInfo_Aplk.h>
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
 #include <Library/HobLib.h>
+#include <Library/I2CLib.h>
+#include <Library/IoLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PeiServicesLib.h>
 #include <Library/TimerLib.h>
-#include <Guid/PlatformInfo_Aplk.h>
+
+#include <Ppi/BoardInitSignalling.h>
+
+#include "BoardInitMiscs.h"
 
 VOID BensonGpioTest (VOID);
 
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.c
index e10ab84..49c8b60 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.c
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.c
@@ -15,7 +15,6 @@
 
 #include "BoardInitMiscs.h"
 
-
 /**
   Configure GPIO group GPE tier.
 
@@ -49,6 +48,7 @@ BensonMultiPlatformInfoInit (
   IN OUT EFI_PLATFORM_INFO_HOB  *PlatformInfoHob
   )
 {
+  UINT8                  Data8;
   EFI_STATUS             Status;
 
 #if (ENBDT_PF_ENABLE == 1)
@@ -128,6 +128,39 @@ BensonMultiPlatformInfoInit (
   Status = BensonInitializeBoardOemId (PeiServices, PlatformInfoHob);
   Status = BensonInitializeBoardSsidSvid (PeiServices, PlatformInfoHob);
 
+  //
+  // TypeC MUX AUX mode
+  //
+
+  //
+  // Set P0-P4 to input mode
+  //
+  Data8  = 0x1F;
+  Status = ByteWriteI2C (0x05, 0x38, 0x03, 1, &Data8);
+  DEBUG ((DEBUG_INFO, "%a(#%d) - Setting button MUX into GPI mode returned %r\n", __FUNCTION__, __LINE__, Status));
+
+  //
+  // Set P0-P4 to inverted mode
+  //
+  Data8  = 0x1F;
+  Status = ByteWriteI2C (0x05, 0x38, 0x02, 1, &Data8);
+  DEBUG ((DEBUG_INFO, "%a(#%d) - Setting button MUX into inverted mode returned %r\n", __FUNCTION__, __LINE__, Status));
+
+  //
+  // Dump switch state
+  //
+  Data8  = 0x00;
+  Status = ByteReadI2C (0x05, 0x38, 0x00, 1, &Data8);
+  DEBUG ((DEBUG_INFO, "%a(#%d) - ByteReadI2C[0] returned %r\n", __FUNCTION__, __LINE__, Status));
+  if (!EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_INFO, "%a(#%d) - Input register         = %02x\n", __FUNCTION__, __LINE__, Data8));
+    DEBUG ((DEBUG_INFO, "%a(#%d) -               Volume + = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT0) ? "Pressed" : "Not pressed"));
+    DEBUG ((DEBUG_INFO, "%a(#%d) -               Volume - = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT1) ? "Pressed" : "Not pressed"));
+    DEBUG ((DEBUG_INFO, "%a(#%d) -                BT Pair = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT2) ? "Pressed" : "Not pressed"));
+    DEBUG ((DEBUG_INFO, "%a(#%d) -               Mic Mute = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT3) ? "Pressed" : "Not pressed"));
+    DEBUG ((DEBUG_INFO, "%a(#%d) -           Speaker Mute = %a\n", __FUNCTION__, __LINE__, (Data8 & BIT4) ? "Pressed" : "Not pressed"));
+  }
+
   return EFI_SUCCESS;
 }
 
@@ -151,7 +184,7 @@ BensonInitializeBoardOemId (
       break;
   }
 
-  PlatformInfoHob->AcpiOemId = OemId;
+  PlatformInfoHob->AcpiOemId      = OemId;
   PlatformInfoHob->AcpiOemTableId = OemTableId;
 
   return  EFI_SUCCESS;
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.h b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.h
index b9844ef..2cf4810 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.h
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitMiscs.h
@@ -27,42 +27,49 @@
 #define RES_IO_LIMIT  0xFFFF
 
 #include <PiDxe.h>
-#include <Library/BaseLib.h>
 #include <FrameworkPei.h>
+
+#include "CMOSMap.h"
+#include "CpuRegs.h"
+#include "Platform.h"
 #include "PlatformBaseAddresses.h"
+#include "PlatformBootMode.h"
 #include "ScAccess.h"
 #include "SetupMode.h"
-#include "PlatformBootMode.h"
-#include "CpuRegs.h"
-#include "Platform.h"
-#include "CMOSMap.h"
-#include <Ppi/Stall.h>
-#include <Guid/SetupVariable.h>
-#include <Ppi/AtaController.h>
-#include <Ppi/BootInRecoveryMode.h>
-#include <Ppi/ReadOnlyVariable2.h>
-#include <Ppi/Capsule.h>
+
+#include <Guid/Capsule.h>
 #include <Guid/EfiVpdData.h>
-#include <Library/DebugLib.h>
+#include <Guid/FirmwareFileSystem.h>
+#include <Guid/GlobalVariable.h>
+#include <Guid/MemoryTypeInformation.h>
+#include <Guid/PlatformInfo_Aplk.h>
+#include <Guid/RecoveryDevice.h>
+#include <Guid/SetupVariable.h>
+
+#include <IndustryStandard/Pci22.h>
+
+#include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/GpioLib.h>
 #include <Library/HobLib.h>
-#include <Library/BaseLib.h>
+#include <Library/I2CLib.h>
+#include <Library/IoLib.h>
+#include <Library/PcdLib.h>
 #include <Library/SteppingLib.h>
-#include <IndustryStandard/Pci22.h>
-#include <Guid/FirmwareFileSystem.h>
-#include <Guid/MemoryTypeInformation.h>
-#include <Ppi/Reset.h>
+#include <Library/TimerLib.h>
+
+#include <Ppi/AtaController.h>
+#include <Ppi/BootInRecoveryMode.h>
+#include <Ppi/Capsule.h>
+#include <Ppi/DeviceRecoveryModule.h>
 #include <Ppi/EndOfPeiPhase.h>
+#include <Ppi/MasterBootMode.h>
 #include <Ppi/MemoryDiscovered.h>
-#include <Guid/GlobalVariable.h>
+#include <Ppi/ReadOnlyVariable2.h>
 #include <Ppi/RecoveryModule.h>
-#include <Ppi/DeviceRecoveryModule.h>
-#include <Guid/Capsule.h>
-#include <Guid/RecoveryDevice.h>
-#include <Ppi/MasterBootMode.h>
-#include <Guid/PlatformInfo_Aplk.h>
+#include <Ppi/Reset.h>
+#include <Ppi/Stall.h>
 
 #define EFI_ACPI_OEM_ID_DEFAULT    SIGNATURE_64('I', 'N', 'T', 'E', 'L', ' ', ' ', ' ')     // max 6 chars
 #define EFI_ACPI_OEM_ID1           SIGNATURE_64('I', 'N', 'T', 'E', 'L', '1', ' ', ' ')     // max 6 chars
@@ -123,5 +130,16 @@ BensonInitializeBoardSsidSvid (
   IN EFI_PLATFORM_INFO_HOB        *PlatformInfoHob
   );
 
+VOID
+DumpMux (
+  VOID
+  );
+
+EFI_STATUS
+EFIAPI
+SetupTypecMuxAux (
+  VOID
+  );
+
 #endif
 
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
index 3b08d2f..def40bf 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/BoardInitPostMem.inf
@@ -2,7 +2,7 @@
 #  Board detected module for Intel(R) Atom(TM) x5 Processor Series.
 #  It will detect the board ID.
 #
-#  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -30,6 +30,8 @@
   PlatformInfoHob.c
   BoardGpios.c
   BoardGpios.h
+  TypeC.c
+  TypeC.h
 
 [LibraryClasses]
   PeiServicesLib
@@ -40,6 +42,8 @@
   IoLib
   SteppingLib
   GpioLib
+  I2cLibPei
+  TimerLib
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.c
new file mode 100644
index 0000000..6bee83e
--- /dev/null
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.c
@@ -0,0 +1,288 @@
+/** @file
+  This file does TypeC initialization.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "TypeC.h"
+
+static MUX_PROGRAMMING_TABLE mBgMuxTable[] = {
+  // Address   Register                Data             String
+  //====================================================================================
+   {A_GENERAL, R_FIRMWARE_VERSION,     MUX_TABLE_NULL, "Firmware Version Number"},
+   {A_STATUS,  R_CC_STATUS_1,          MUX_TABLE_NULL, "CC_Status_1"},
+   {A_STATUS,  R_CC_STATUS_2,          MUX_TABLE_NULL, "CC_Status_2"},
+   {A_STATUS,  R_CC_STATUS_3,          MUX_TABLE_NULL, "CC_Status_3"},
+   {A_STATUS,  R_MUX_HPD_ASSERT,       MUX_TABLE_NULL, "MUX_In_HPD_Assertion"},
+   {A_STATUS,  R_MUX_STATUS,           MUX_TABLE_NULL, "MUX Status"},
+   {A_STATUS,  R_MUX_DP_TRAINING,      MUX_TABLE_NULL, "MUX_DP_Training_Disable"},
+   {A_STATUS,  R_MUX_DP_AUX_INTERCEPT, MUX_TABLE_NULL, "MUX_DP_AUX_Interception_Disable"},
+   {A_STATUS,  R_MUX_DP_EQ_CONFIG,     MUX_TABLE_NULL, "MUX_DP_EQ_Configuration"},
+   {A_STATUS,  R_MUX_DP_OUTPUT_CONFIG, MUX_TABLE_NULL, "MUX_DP_Output_Configuration"}
+};
+
+VOID
+PrintChar (
+  IN UINTN     DebugMask,
+  IN UINTN     Count,
+  IN CHAR16   *Char
+)
+{
+  UINTN Index;
+
+  for (Index = 0; Index < Count; Index++) {
+    DEBUG ((DebugMask, "%s", Char));
+  }
+}
+
+#define DIVIDING_LINE "+----------------------------------------------------+------------------+\n"
+
+VOID
+DumpParagraph (
+  IN   UINTN   DebugMask,
+  IN   VOID   *Ptr,
+  IN   UINTN   Count
+  )
+{
+  CHAR8     AsciiBuffer[17];
+  UINT8    *Data;
+  UINTN     Index;
+  UINTN     Paragraphs;
+  UINTN     PlaceHolder;
+  UINTN     PlaceHolders;
+
+  //
+  // Use a different pointer so that the one passed in doesn't change
+  //
+  Data = (UINT8 *) Ptr;
+  //
+  // Calcualte the number of paragraphs
+  //
+  Paragraphs = Count / 16;
+  if ((Paragraphs * 16) < Count) {
+    Paragraphs++;
+  }
+  //
+  // Calculate the number of columns
+  //
+  PlaceHolder  = Paragraphs;
+  PlaceHolders = 0;
+  while (PlaceHolder > 0) {
+    PlaceHolders++;
+    PlaceHolder >>= 4;
+  }
+
+  //
+  // Dump the buffer
+  //
+  if (Count > 0 ) {
+    //
+    // Print header
+    //
+    PrintChar (DebugMask, PlaceHolders + 5, L" ");
+    DEBUG ((DebugMask, DIVIDING_LINE));
+    PrintChar (DebugMask, PlaceHolders + 5, L" ");
+    DEBUG ((DebugMask, "| x0 x1 x2 x3  x4 x5 x6 x7  x8 x9 xA xB  xC xD xE xF |      String      |\n"));
+    DEBUG ((DebugMask, " +"));
+    PrintChar (DebugMask, PlaceHolders + 3, L"-");
+    DEBUG ((DebugMask, DIVIDING_LINE));
+    //
+    // Print data
+    //
+    for (Index = 0; Index < (Paragraphs * 16); Index++) {
+      //
+      // Print divider
+      //
+      if (Index % 0x10 == 0x00) {
+        if ((Index > 0) && ((Index / 0x10) % 0x04 == 0x00) && (Paragraphs > 6)) {
+          DEBUG ((DebugMask, " +"));
+          PrintChar (DebugMask, PlaceHolders + 3, L"-");
+          DEBUG ((DebugMask, DIVIDING_LINE));
+        }
+        DEBUG ((DebugMask, " | %0*xx | ", PlaceHolders, (Index / 0x10)));
+      }
+      //
+      // Print the data or a filler
+      //
+      if (Index < Count) {
+        DEBUG ((DebugMask, "%02x ", Data[Index]));
+        if ((Data[Index] < 32) || (Data[Index] > 126)) {
+          //
+          // Not printable
+          //
+          AsciiBuffer[(Index % 0x10)] = '.';
+        } else {
+          //
+          // Printable
+          //
+          AsciiBuffer[(Index % 0x10)] = Data[Index];
+        }
+      } else {
+        DEBUG ((DebugMask, "   "));
+        AsciiBuffer[(Index % 0x10)] = ' ';
+      }
+      //
+      // Print break or line end if needed
+      //
+      if (Index % 0x10 == 0x0F) {
+        AsciiBuffer[16] = 0x00;
+        DEBUG ((DebugMask, "| %a |\n", AsciiBuffer));
+      } else if (Index % 0x04 == 0x03) {
+        DEBUG ((DebugMask, " "));
+      }
+    }
+    //
+    // Print footer
+    //
+    DEBUG ((DebugMask, " +"));
+    PrintChar (DebugMask, PlaceHolders + 3, L"-");
+    DEBUG ((DebugMask, DIVIDING_LINE));
+  }
+}
+
+EFI_STATUS
+EFIAPI
+ReadMux (
+  IN   UINT8    SlaveAddress,
+  IN   UINT8    Offset,
+  OUT  UINT8   *Data
+  )
+{
+  UINT8          RetryCount;
+  EFI_STATUS     Status;
+
+  RetryCount = MUX_RETRY_COUNT;
+  do {
+    *Data = 0x00;
+    Status = ByteReadI2C (PARADE_MUX_I2C_BUS, SlaveAddress, Offset, 1, Data);
+  } while ((RetryCount-- > 0) && (EFI_ERROR (Status)));
+
+  return Status;
+}
+
+EFI_STATUS
+EFIAPI
+WriteMux (
+  IN   UINT8    SlaveAddress,
+  IN   UINT8    Offset,
+  OUT  UINT8   *Data
+  )
+{
+  UINT8          RetryCount;
+  EFI_STATUS     Status;
+
+  RetryCount = MUX_RETRY_COUNT;
+  do {
+    Status = ByteWriteI2C (PARADE_MUX_I2C_BUS, SlaveAddress, Offset, 1, Data);
+  } while ((RetryCount-- > 0) && (EFI_ERROR (Status)));
+
+  return Status;
+}
+
+VOID
+DumpMux (
+  VOID
+  )
+{
+  UINT8          Data[256];
+  UINT16         Offset;
+  BXT_CONF_PAD0  padConfg0;
+  BXT_CONF_PAD1  padConfg1;
+  UINT8          SlaveAddress;
+  EFI_STATUS     Status;
+
+  //
+  // Loop thru device and dump it all
+  //
+  DEBUG ((DEBUG_INFO, "\n%a(#%d) - Dump the PS8750 I2C data\n", __FUNCTION__, __LINE__));
+  for (SlaveAddress = 0x08; SlaveAddress <= 0x0E; SlaveAddress++) {
+    for (Offset = 0x00; Offset <= 0xFF; Offset++) {
+      Status = ReadMux (SlaveAddress, (UINT8) Offset, &Data[Offset]);
+      if (EFI_ERROR (Status)) Data[Offset] = 0xFF;
+    }
+    DEBUG ((DEBUG_INFO, "\nSlaveAddress = 0x%02x\n", (SlaveAddress << 1)));
+    DumpParagraph (DEBUG_INFO, Data, 256);
+  }
+  DEBUG ((DEBUG_INFO, "\n"));
+  padConfg0.padCnf0 = GpioPadRead (NW_GPIO_199 + BXT_GPIO_PAD_CONF0_OFFSET);
+  padConfg1.padCnf1 = GpioPadRead (NW_GPIO_199 + BXT_GPIO_PAD_CONF1_OFFSET);
+  DEBUG ((DEBUG_INFO, "%a(#%d) - GPIO_199 (DDI1 HPD) Rx = %d  RxInv = %d\n\n", __FUNCTION__, __LINE__, padConfg0.r.GPIORxState, padConfg0.r.RXINV));
+}
+
+EFI_STATUS
+EFIAPI
+SetupTypecMuxAux (
+  VOID
+  )
+{
+  UINT8            Data8;
+  UINTN            index;
+  MUX_DATA_TABLE   MuxData;
+  BXT_CONF_PAD0    padConfg0;
+  BXT_CONF_PAD1    padConfg1;
+  UINT8            *Ptr;
+  EFI_STATUS       Status;
+
+  //
+  // Read/write MUX info
+  //
+  Ptr = (UINT8 *) &MuxData;
+  for (index = 0; index < (sizeof (mBgMuxTable) / sizeof (mBgMuxTable[0])); index++) {
+    Status = ReadMux (mBgMuxTable[index].Address, mBgMuxTable[index].Register, &Data8);
+    DEBUG ((DEBUG_INFO, "%a(#%d) - %.*a [0x%02x:0x%02x] = 0x%02x (%r)\n", __FUNCTION__, __LINE__, MUX_TABLE_STRING_LENGTH, mBgMuxTable[index].String, (mBgMuxTable[index].Address << 1), mBgMuxTable[index].Register, Data8, Status));
+    Ptr[index] = Data8;
+    if ((mBgMuxTable[index].Data != MUX_TABLE_NULL) && (!EFI_ERROR (Status))) {
+      Data8 = (UINT8) (mBgMuxTable[index].Data & 0x00FF);
+      Status = WriteMux (mBgMuxTable[index].Address, mBgMuxTable[index].Register, &Data8);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a(#%d) - ERROR: ByteWriteI2C returned %r for %a = 0x%02x\n", __FUNCTION__, __LINE__, Status, mBgMuxTable[index].String, Data8));
+      } else {
+        Status = ReadMux (mBgMuxTable[index].Address, mBgMuxTable[index].Register, &Data8);
+        DEBUG ((DEBUG_INFO, "%a(#%d) - %.*a [0x%02x:0x%02x] = 0x%02x (%r)\n", __FUNCTION__, __LINE__, MUX_TABLE_STRING_LENGTH, mBgMuxTable[index].String, (mBgMuxTable[index].Address << 1), mBgMuxTable[index].Register, Data8, Status));
+        Ptr[index] = Data8;
+      }
+    }
+  }
+
+  //
+  // Display HPD
+  //
+  padConfg0.padCnf0 = GpioPadRead (NW_GPIO_199 + BXT_GPIO_PAD_CONF0_OFFSET);
+  padConfg1.padCnf1 = GpioPadRead (NW_GPIO_199 + BXT_GPIO_PAD_CONF1_OFFSET);
+  DEBUG ((DEBUG_INFO, "%a(#%d) - GPIO_199 (DDI1 HPD) Rx = %d  RxInv = %d\n", __FUNCTION__, __LINE__, padConfg0.r.GPIORxState, padConfg0.r.RXINV));
+
+  //
+  // See if we need to assert the HPD on the MUX
+  //
+  if ((MuxData.MuxStatus & BIT7) == BIT7) {
+    //
+    // We are in DP mode
+    //
+    if ((MuxData.HpdAssert & BIT7) != BIT7) {
+      //
+      // We need to assert the MUX HPD
+      //
+      Data8  = MuxData.HpdAssert | BIT7;
+      Status = WriteMux (A_STATUS,  R_MUX_HPD_ASSERT, &Data8);
+
+      //
+      // Display HPD
+      //
+      padConfg0.padCnf0 = GpioPadRead (NW_GPIO_199 + BXT_GPIO_PAD_CONF0_OFFSET);
+      padConfg1.padCnf1 = GpioPadRead (NW_GPIO_199 + BXT_GPIO_PAD_CONF1_OFFSET);
+      DEBUG ((DEBUG_INFO, "%a(#%d) - GPIO_199 (DDI1 HPD) Rx = %d  RxInv = %d\n", __FUNCTION__, __LINE__, padConfg0.r.GPIORxState, padConfg0.r.RXINV));
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.h b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.h
new file mode 100644
index 0000000..c145c69
--- /dev/null
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPostMem/TypeC.h
@@ -0,0 +1,79 @@
+/** @file
+  Multiplatform initialization header file.
+  This file includes package header files, library classes.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _BENSON_TYPEC_LIB_H_
+#define _BENSON_TYPEC_LIB_H_
+
+#include <PiDxe.h>
+#include <FrameworkPei.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/GpioLib.h>
+#include <Library/I2CLib.h>
+
+//
+// Parade Tech PS8750 TypeC MUX
+//
+#define PARADE_MUX_I2C_BUS      0x01
+#define A_GENERAL               0x08
+#define   R_FIRMWARE_VERSION      0x90
+#define A_STATUS                0x09
+#define   R_DP_AUX_SNOOP_BW       0x10
+#define   R_DP_AUX_SNOOP_LC       0x11
+#define   R_DP_AUX_SNOOP_L0       0x12
+#define   R_DP_AUX_SNOOP_L1       0x13
+#define   R_DP_AUX_SNOOP_L2       0x14
+#define   R_DP_AUX_SNOOP_L3       0x15
+#define   R_DP_AUX_SNOOP_D3       0x1E
+#define   R_MUX_STATUS            0x80
+#define   R_MUX_DP_TRAINING       0x83
+#define   R_MUX_DP_AUX_INTERCEPT  0x85
+#define   R_MUX_DP_EQ_CONFIG      0x86
+#define   R_MUX_DP_OUTPUT_CONFIG  0x87
+#define   R_MUX_HPD_ASSERT        0xBC
+#define   R_CC_STATUS_1           0xEC
+#define   R_CC_STATUS_2           0xED
+#define   R_CC_STATUS_3           0xEE
+#define MUX_TABLE_NULL            0xFFFF
+#define MUX_RETRY_COUNT           0x03
+#define MUX_TABLE_STRING_LENGTH   32
+
+typedef struct {
+  UINT8         Address;
+  UINT8         Register;
+  UINT16        Data;
+  CHAR8         String[MUX_TABLE_STRING_LENGTH];
+} MUX_PROGRAMMING_TABLE;
+
+typedef struct {
+  //
+  // These UINT8 elements need to match the MUX_PROGRAMMING_TABLE list so we can use the Index to reference them
+  //
+  UINT8         FirmwareVersion;  // Offset 0
+  UINT8         CcStatus1;        // Offset 1
+  UINT8         CcStatus2;        // Offset 2
+  UINT8         CcStatus3;        // Offset 3
+  UINT8         MuxStatus;        // Offset 4
+  UINT8         HpdAssert;        // Offset 5
+  UINT8         DpTraining;       // Offset 6
+  UINT8         DpAuxIntercept;   // Offset 7
+  UINT8         DpEqConfig;       // Offset 8
+  UINT8         DpOutputConfig;   // Offset 9
+} MUX_DATA_TABLE;
+
+#endif
+
-- 
2.10.1.windows.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-08-24  3:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24  3:18 [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017 07/1 BroxtonPlatformPkg: Add BensonTypeC support Guo, Mang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox