summaryrefslogtreecommitdiff
path: root/Vlv2TbltDevicePkg/Library/PchPlatformLib
diff options
context:
space:
mode:
authorDavid Wei <david.wei@intel.com>2015-01-12 09:37:20 +0000
committerzwei4 <zwei4@Edk2>2015-01-12 09:37:20 +0000
commit3cbfba02fef9dae07a041fdbf2e89611d72d6f90 (patch)
tree0b3bf0783124d38a191e09736492c0141aa36c15 /Vlv2TbltDevicePkg/Library/PchPlatformLib
parent6f785cfcc304c48ec04e542ee429df95e7b51bc5 (diff)
downloadedk2-platforms-3cbfba02fef9dae07a041fdbf2e89611d72d6f90.tar.xz
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
https://svn.code.sf.net/p/edk2/code/trunk/edk2/, which are for MinnowBoard MAX open source project. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: David Wei <david.wei@intel.com> Reviewed-by: Mike Wu <mike.wu@intel.com> Reviewed-by: Hot Tian <hot.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16599 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Vlv2TbltDevicePkg/Library/PchPlatformLib')
-rw-r--r--Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLib.inf55
-rw-r--r--Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c131
-rw-r--r--Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.h40
3 files changed, 226 insertions, 0 deletions
diff --git a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLib.inf b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLib.inf
new file mode 100644
index 0000000000..48386cb2d4
--- /dev/null
+++ b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLib.inf
@@ -0,0 +1,55 @@
+#
+#
+#/*++
+#
+# Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License that 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.
+#
+#
+# Module Name:
+#
+# PeiDxePchPlatformLib.inf
+#
+# Abstract:
+#
+# Component description file for PEI/DXE PCH Platform Lib
+#
+#--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PchPlatformLib
+ FILE_GUID = 32F89CBC-305D-4bdd-8B2C-9C65592E66AC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PchPlatformLib
+
+[sources.common]
+ PchPlatformLibrary.h
+ PchPlatformLibrary.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PciLib
+ IoLib
+ DebugLib
+
+
+[Pcd.common]
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+
+
+[Protocols]
+
diff --git a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c
new file mode 100644
index 0000000000..c92308f4e9
--- /dev/null
+++ b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c
@@ -0,0 +1,131 @@
+/**
+
+Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that 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.
+
+
+ @file
+ PchPlatformLib.c
+
+ @brief
+ PCH Platform Lib implementation.
+
+**/
+
+#include "PchPlatformLibrary.h"
+
+//
+// Silicon Steppings
+//
+/**
+ Return Pch stepping type
+
+ @param[in] None
+
+ @retval PCH_STEPPING Pch stepping type
+
+**/
+PCH_STEPPING
+EFIAPI
+PchStepping (
+ VOID
+ )
+{
+ UINT8 RevId;
+
+ RevId = MmioRead8 (
+ MmPciAddress (0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_RID_CC)
+ );
+
+ switch (RevId) {
+ case V_PCH_LPC_RID_0:
+ case V_PCH_LPC_RID_1:
+ return PchA0;
+ break;
+
+ case V_PCH_LPC_RID_2:
+ case V_PCH_LPC_RID_3:
+ return PchA1;
+ break;
+
+ case V_PCH_LPC_RID_4:
+ case V_PCH_LPC_RID_5:
+ return PchB0;
+ break;
+
+ case V_PCH_LPC_RID_6:
+ case V_PCH_LPC_RID_7:
+ return PchB1;
+ break;
+
+ case V_PCH_LPC_RID_8:
+ case V_PCH_LPC_RID_9:
+ return PchB2;
+ break;
+
+ case V_PCH_LPC_RID_A:
+ case V_PCH_LPC_RID_B:
+ return PchB3;
+ break;
+
+ case V_PCH_LPC_RID_C:
+ case V_PCH_LPC_RID_D:
+ return PchC0;
+ break;
+
+ default:
+ return PchSteppingMax;
+ break;
+
+ }
+}
+
+/**
+ Determine if PCH is supported
+
+ @param[in] None
+
+ @retval TRUE PCH is supported
+ @retval FALSE PCH is not supported
+
+**/
+BOOLEAN
+IsPchSupported (
+ VOID
+ )
+{
+ UINT32 Identifiers;
+ UINT16 PcuVendorId;
+ UINT16 PcuDeviceId;
+
+ Identifiers = MmioRead32 (
+ MmPciAddress (0,
+ DEFAULT_PCI_BUS_NUMBER_PCH,
+ PCI_DEVICE_NUMBER_PCH_LPC,
+ PCI_FUNCTION_NUMBER_PCH_LPC,
+ R_PCH_LPC_REG_ID)
+ );
+
+ PcuDeviceId = (UINT16) ((Identifiers & B_PCH_LPC_DEVICE_ID) >> 16);
+ PcuVendorId = (UINT16) (Identifiers & B_PCH_LPC_VENDOR_ID);
+
+ //
+ // Verify that this is a supported chipset
+ //
+ if (PcuVendorId != (UINT16) V_PCH_LPC_VENDOR_ID || !IS_PCH_VLV_LPC_DEVICE_ID (PcuDeviceId)) {
+ DEBUG ((EFI_D_ERROR, "VLV SC code doesn't support the PcuDeviceId: 0x%04x!\n", PcuDeviceId));
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.h b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.h
new file mode 100644
index 0000000000..74649003d7
--- /dev/null
+++ b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.h
@@ -0,0 +1,40 @@
+/**
+**/
+/**
+
+Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that 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.
+
+
+ @file
+ PchPlatformLibrary.h
+
+ @brief
+ Header file for PCH Platform Lib implementation.
+
+**/
+
+#ifndef _PCH_PLATFORM_LIBRARY_IMPLEMENTATION_H_
+#define _PCH_PLATFORM_LIBRARY_IMPLEMENTATION_H_
+
+#include "PchAccess.h"
+#ifdef ECP_FLAG
+#include "EdkIIGlueBase.h"
+#include "Library/EdkIIGlueMemoryAllocationLib.h"
+#else
+#include "Library/PciLib.h"
+#include "Library/IoLib.h"
+#include "Library/DebugLib.h"
+#include "Library/PcdLib.h"
+
+#include "PchCommonDefinitions.h"
+#endif
+
+#endif