summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2016-06-02 13:22:24 +0800
committerHao Wu <hao.a.wu@intel.com>2016-06-07 09:55:23 +0800
commit0bda7b31c570209c772f0cd505df5d5fd68924a7 (patch)
tree473f6b4efa6f70d66a3c1a36d88d025fc4635edd
parent6c272b873425166c7c090bc075f531f0322e5f6a (diff)
downloadedk2-platforms-0bda7b31c570209c772f0cd505df5d5fd68924a7.tar.xz
ChvRefCodePkg: Add CherryviewPpmLib.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
-rw-r--r--ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.c133
-rw-r--r--ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.h38
-rw-r--r--ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.inf33
3 files changed, 204 insertions, 0 deletions
diff --git a/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.c b/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.c
new file mode 100644
index 0000000000..292d1520bc
--- /dev/null
+++ b/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.c
@@ -0,0 +1,133 @@
+/** @file
+ This library contains power management configuration functions for
+ CherryView processors.
+
+ Acronyms:
+ PPM Platform Power Management
+ GV Geyserville
+ TM Thermal Monitor
+ IST Intel(R) Speedstep technology
+ HT Hyper-Threading Technology
+
+ Copyright (c) 1999 - 2015, 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.
+
+**/
+
+//
+// Statements that include other files
+//
+#include <CherryviewPpmLib.h>
+#include "Cherryview.h"
+#include <Library/S3BootScriptLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+
+//
+// Global variables
+//
+
+//
+// CHV iFSB Frequency Table.
+//
+
+CONST UINT16 miFSBFrequencyTable[] = {
+ 100, // 100MHz
+ 100, // 100MHz
+ 133, // 133.4MHz
+ 83, // 83.3MHz
+ 80, // 80MHz
+ 90, // 90MHz
+ 93, // 93.3MHz
+ 100, // 100MHz
+};
+
+UINT32 Isb32Read(UINT8 portid, UINT8 command, UINT16 offset){
+ UINT32 data;
+ MmioWrite32(EC_BASE + 0xD8, 0);
+ MmioWrite32(EC_BASE + 0xD0, (((command << 24) | (portid << 16) | (offset << 8)) + 0xF0));
+ data = MmioRead32(EC_BASE + 0xD4);
+ return data;
+}
+
+/**
+ Determine the processor core frequency
+
+ @param[in] None
+
+ @retval Processor core frequency multiplied by 3
+
+**/
+UINT16
+DetermineiFsbFromMsr (
+ VOID
+ )
+{
+ //
+ // Determine the processor core frequency
+ //
+ UINT16 FrequencyIndex;
+ UINT16 Hpl_Mdiv;
+
+ FrequencyIndex = (Isb32Read(0x14, 0x06, 0x0008) & 0x1C) >> 2 ;
+ DEBUG((EFI_D_INFO, "FrequencyIndex - %x \n", FrequencyIndex));
+ if (FrequencyIndex == 4) {
+ Hpl_Mdiv = Isb32Read(0x14, 0x06, 0x54) & 0x3F;
+ DEBUG((EFI_D_INFO, "Hpl_Mdiv - %x \n", Hpl_Mdiv));
+ if (Hpl_Mdiv == 0x26)
+ return miFSBFrequencyTable[FrequencyIndex];
+ else if (Hpl_Mdiv == 0x19)
+ return miFSBFrequencyTable[FrequencyIndex + 1];
+ else if (Hpl_Mdiv == 0x1A)
+ return miFSBFrequencyTable[FrequencyIndex + 2];
+ }
+ else if (FrequencyIndex == 5) {
+ if ((FrequencyIndex + 3) < (sizeof(miFSBFrequencyTable)/sizeof(miFSBFrequencyTable[0]))) {
+ return miFSBFrequencyTable[FrequencyIndex + 3];
+ }
+ }
+
+ return miFSBFrequencyTable[FrequencyIndex];
+}
+
+/**
+ Determines if MCH is capable of dynamic FSB frequency switching(Bus Geyserville)
+
+ @param[in] None
+
+ @retval FALSE Dynamic FSB frequency switching(Bus Geyserville) is NOT supported.
+ @retval TRUE Dynamic FSB frequency switching(Bus Geyserville) is supported.
+
+**/
+BOOLEAN
+MchSupportDynamicFsbFrequencySwitching (
+ VOID
+ )
+{
+ return FALSE;
+}
+
+/**
+ Enables dynamic FSB frequency switching(Bus Geyserville) on ICH
+
+ @param[in] None
+
+ @retval EFI_SUCCESS Dynamic FSB frequency switching(Bus Geyserville) enabled
+
+**/
+EFI_STATUS
+EnableMchDynamicFsbFrequencySwitching (
+ VOID
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
diff --git a/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.h b/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.h
new file mode 100644
index 0000000000..973d0afb69
--- /dev/null
+++ b/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.h
@@ -0,0 +1,38 @@
+/** @file
+ This library contains power management configuration functions specific to
+ CherryView processors.
+
+ Acronyms:
+ PPM Platform Power Management
+ GV Geyserville
+ TM Thermal Monitor
+ IST Intel(R) Speedstep technology
+ HT Hyper-Threading Technology
+ CMP Core Multi-Processing
+
+ Copyright (c) 1999 - 2015, 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 _CHERRYVIEW_PPM_LIB_H_
+#define _CHERRYVIEW_PPM_LIB_H_
+
+//
+// Statements that include other files
+//
+#include "PiDxe.h"
+//
+// MSR definitions
+//
+#define BSEL_CR_OVERCLOCK_CONTROL 0xCD
+#define FUSE_BSEL_MASK 0x07
+
+#endif
diff --git a/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.inf b/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.inf
new file mode 100644
index 0000000000..b1393a2ece
--- /dev/null
+++ b/ChvRefCodePkg/CherryViewSoc/CPU/PowerManagement/Library/CherryView/Smm/CherryviewPpmLib.inf
@@ -0,0 +1,33 @@
+## @file
+# MCH Power Management Library
+#
+# Provides library services of MCH power management.
+#
+# Copyright (c) 1999 - 2015, 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = CherryviewPpmLib
+ FILE_GUID = 066B21CA-3AED-4ebb-9936-DD6C5CCBAA4D
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = CherryviewPpmLib
+
+[sources.common]
+ CherryviewPpmLib.c
+ CherryviewPpmLib.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ChvRefCodePkg/ChvRefCodePkg.dec
+