summaryrefslogtreecommitdiff
path: root/ChvRefCodePkg/Platform
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2016-06-02 14:08:44 +0800
committerHao Wu <hao.a.wu@intel.com>2016-06-07 09:55:54 +0800
commit92d96f1e85565c61998e2b6a2d0912fce2529204 (patch)
treeb2d7b0aadab66c021e8c4664613c5635c4beedb2 /ChvRefCodePkg/Platform
parent254189fe9b9205536b76294b2e5019c4363a3123 (diff)
downloadedk2-platforms-92d96f1e85565c61998e2b6a2d0912fce2529204.tar.xz
ChvRefCodePkg: Add ChvRefCodePkg platform code.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'ChvRefCodePkg/Platform')
-rw-r--r--ChvRefCodePkg/Platform/DptfBsw/Include/Protocol/DptfPlatformPolicyProtocolBsw.h73
-rw-r--r--ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.c134
-rw-r--r--ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.h41
-rw-r--r--ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.inf80
4 files changed, 328 insertions, 0 deletions
diff --git a/ChvRefCodePkg/Platform/DptfBsw/Include/Protocol/DptfPlatformPolicyProtocolBsw.h b/ChvRefCodePkg/Platform/DptfBsw/Include/Protocol/DptfPlatformPolicyProtocolBsw.h
new file mode 100644
index 0000000000..55db72c589
--- /dev/null
+++ b/ChvRefCodePkg/Platform/DptfBsw/Include/Protocol/DptfPlatformPolicyProtocolBsw.h
@@ -0,0 +1,73 @@
+/** @file
+ Interface definition details between DPTF and platform drivers during DXE phase.
+
+ 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 _DPTF_PLATFORM_POLICY_PROTOCOL_H_
+#define _DPTF_PLATFORM_POLICY_PROTOCOL_H_
+
+//
+// Extern the GUID for protocol users.
+//
+extern EFI_GUID gDxeDptfPlatformPolicyGuid;
+
+//
+// Protocol revision number
+// Any backwards compatible changes to this protocol will result in an update in the revision number
+// Major changes will require publication of a new protocol
+//
+#define DXE_DPTF_PLATFORM_POLICY_PROTOCOL_REVISION 0
+
+//
+// DPTF DXE Platform Policy ==================================================
+//
+
+typedef struct _DXE_DPTF_PLATFORM_POLICY_PROTOCOL {
+ UINT8 Revision;
+ UINT8 EnableDptf; // Option to enable/disable DPTF
+ UINT8 DptfProcessor; // Option to enable/disable Processor Participant
+ UINT16 ProcCriticalTemp; // Processor critical temperature
+ UINT16 ProcPassiveTemp; // Processor passive temperature
+ UINT16 GenericCriticalTemp0; // Critical temperature value for generic sensor0 participant
+ UINT16 GenericPassiveTemp0; // Passive temperature value for generic sensor0 participant
+ UINT16 GenericCriticalTemp1; // Critical temperature value for generic sensor1 participant
+ UINT16 GenericPassiveTemp1; // Passive temperature value for generic sensor1 participant
+ UINT16 GenericCriticalTemp2; // Critical temperature value for generic sensor2 participant
+ UINT16 GenericPassiveTemp2; // Passive temperature value for generic sensor2 participant
+ UINT8 BidirectionalProchotEnable;
+ UINT8 ThermalMonitoring;
+ UINT8 ThermalMonitoringHot;
+ UINT8 ThermalMonitoringSystherm0Hot;
+ UINT8 ThermalMonitoringSystherm1Hot;
+ UINT8 ThermalMonitoringSystherm2Hot;
+
+ UINT16 DptfProcActiveTemperatureSA; // DPTF: Processor active temperature
+ UINT16 DptfProcCriticalTemperatureSA; // DPTF: Processor critical temperature
+ UINT16 DptfProcCR3TemperatureSA; // DPTF: Processor CR3 temperature
+ UINT16 DptfProcHotTemperatureSA; // DPTF: Processor Hot temperature
+ UINT16 DptfProcPassiveTemperatureSA; // DPTF: Processor passive temperature
+ UINT16 DptfGenericActiveTemperature0; // DPTF: Active temperature value for generic sensor0 participant
+ UINT16 DptfGenericCR3Temperature0; // DPTF: CR3 temperature value for generic sensor0 participant
+ UINT16 DptfGenericHotTemperature0; // DPTF: Hot temperature value for generic sensor0 participant
+ UINT16 DptfGenericActiveTemperature1; // DPTF: Active temperature value for generic sensor1 participant
+ UINT16 DptfGenericCR3Temperature1; // DPTF: CR3 temperature value for generic sensor1 participant
+ UINT16 DptfGenericHotTemperature1; // DPTF: Hot temperature value for generic sensor1 participant
+ UINT16 DptfGenericActiveTemperature2; // DPTF: Active temperature value for generic sensor2 participant
+ UINT16 DptfGenericCR3Temperature2; // DPTF: CR3 temperature value for generic sensor2 participant
+ UINT16 DptfGenericHotTemperature2; // DPTF: Hot temperature value for generic sensor2 participant
+ UINT8 EnablePassivePolicy; // DPTF: Passive Policy enable/disable
+ UINT8 EnableCriticalPolicy; // DPTF: Critical Policy enable/disable
+ UINT8 EnableActivePolicy; // DPTF: Active Policy enable/disable
+} DXE_DPTF_PLATFORM_POLICY_PROTOCOL;
+
+#endif
diff --git a/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.c b/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.c
new file mode 100644
index 0000000000..1041cd4068
--- /dev/null
+++ b/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.c
@@ -0,0 +1,134 @@
+/** @file
+ Platform Emmc Dxe driver to perform Emmc DLL Tuning.
+
+ Copyright (c) 2014 - 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.
+
+**/
+
+#include "PlatformEmmcDxe.h"
+
+/**
+ After EFI_EMMC_CARD_INFO_PROTOCOL and PCH_EMMC_TUNING_PROTOCOL installed,
+ configure platform EMMC for HS200/HS400 Tuning and set variable for HS200/HS400 Tuning Data.
+
+ @param[in] Event A pointer to the Event that triggered the callback.
+ @param[in] Context A pointer to private data registered with the callback function.
+
+**/
+VOID
+EFIAPI
+ConfigurePlatformEmmc (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_EMMC_CARD_INFO_PROTOCOL *EfiEmmcApplicationRegister;
+ PCH_EMMC_TUNING_PROTOCOL *PchEmmcTuningProtocol;
+ EMMC_INFO EmmcInfo;
+ EMMC_TUNING_DATA EmmcTuningData;
+ UINT8 PchEmmcTuningProtocolRevision;
+ EFI_STATUS Status;
+
+ PchEmmcTuningProtocolRevision = PCH_SCC_TUNING_PROTOCOL_REVISION;
+
+ DEBUG ((DEBUG_INFO, "ConfigurePlatformEmmc Start()\n"));
+
+ ///
+ /// Closed the event to avoid call twice when launch shell
+ ///
+ gBS->CloseEvent (Event);
+
+ Status = gBS->LocateProtocol (
+ &gEfiEmmcCardInfoProtocolGuid,
+ NULL,
+ (VOID **) &EfiEmmcApplicationRegister
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateProtocol (
+ &gPchSccTuningProtocolGuid,
+ NULL,
+ (VOID **) &PchEmmcTuningProtocol
+ );
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((DEBUG_INFO, " eMMC tuning aborted\n"));
+ return;
+ }
+ //
+ // Return if eMMC device does not support HS200
+ //
+ if (((EfiEmmcApplicationRegister->CardData->ExtCSDRegister.CARD_TYPE & B_EMMC_HS200_12V) == FALSE) &&
+ ((EfiEmmcApplicationRegister->CardData->ExtCSDRegister.CARD_TYPE & B_EMMC_HS200_18V) == FALSE)) {
+ DEBUG ((DEBUG_INFO, " eMMC device does not support HS200, exit!\n"));
+ return;
+ }
+
+ //
+ // Get EmmcInfo from EmmcCardInfoProtocol
+ // EmmcCardInfoProtocol is produced in the driver
+ //
+ EmmcInfo.PartitionHandle = EfiEmmcApplicationRegister->CardData->Partitions->Handle;
+ EmmcInfo.Lba = 0;
+ EmmcInfo.RelativeDevAddress = (EfiEmmcApplicationRegister->CardData->Address << 16);
+
+ if (EfiEmmcApplicationRegister->CardData->CurrentBusWidth == 4) {
+ EmmcInfo.HS200BusWidth = V_EMMC_HS200_BUS_WIDTH_4;
+ } else {
+ EmmcInfo.HS200BusWidth = V_EMMC_HS200_BUS_WIDTH_8;
+ }
+ DEBUG ((DEBUG_INFO, " HS200BusWidth: %d\n", EmmcInfo.HS200BusWidth));
+
+ Status = PchEmmcTuningProtocol->EmmcTune (PchEmmcTuningProtocol, PchEmmcTuningProtocolRevision, &EmmcInfo, &EmmcTuningData);
+
+ DEBUG ((DEBUG_INFO, "ConfigurePlatformEmmc End()\n"));
+
+}
+
+/**
+ Entry point for the driver.
+
+ This routine gets info from the EFI_EMMC_CARD_INFO_PROTOCOL and perform
+ Platform EMMC HS200/HS400 mode tuning.
+
+ @param[in] ImageHandle Image Handle.
+ @param[in] SystemTable EFI System Table.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformEmmcInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT EmmcApplicationRegisterEvent;
+ VOID *EmmcApplicationRegisterEventRegistration;
+
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY) ConfigurePlatformEmmc,
+ NULL,
+ &EmmcApplicationRegisterEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiEmmcCardInfoProtocolGuid,
+ EmmcApplicationRegisterEvent,
+ &EmmcApplicationRegisterEventRegistration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
diff --git a/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.h b/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.h
new file mode 100644
index 0000000000..4108d1a169
--- /dev/null
+++ b/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.h
@@ -0,0 +1,41 @@
+/** @file
+ Header file for Platform eMMC Info Dxe Driver.
+
+ Copyright (c) 2014 - 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 _PLATFORM_EMMC_INFO_DRIVER_H_
+#define _PLATFORM_EMMC_INFO_DRIVER_H_
+
+#include <Uefi.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HobLib.h>
+
+#include <MediaDeviceDriver.h>
+
+#include <PchAccess.h>
+#include <Library/PchPlatformLib.h>
+#include <Protocol/PchPlatformPolicy.h>
+#include <Protocol/PchSccTuning.h>
+#include <Protocol/EmmcCardInfoProtocol.h>
+
+#define B_EMMC_HS400_12V BIT7 ///< HS400 Dual Data Rate eMMC @ 200MHz - 1.2V I/O
+#define B_EMMC_HS400_18V BIT6 ///< HS400 Dual Data Rate eMMC @ 200MHz - 1.8V I/O
+#define B_EMMC_HS200_12V BIT5 ///< HS200 Single Data Rate eMMC @ 200MHz - 1.2V I/O
+#define B_EMMC_HS200_18V BIT4 ///< HS200 Single Data Rate eMMC @ 200MHz - 1.8V I/O
+#define V_EMMC_HS200_BUS_WIDTH_4 1 ///< BUS_WIDTH [183] 4 bit data bus (SDR)
+#define V_EMMC_HS200_BUS_WIDTH_8 2 ///< BUS_WIDTH [183] 8 bit data bus (SDR)
+#endif
diff --git a/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.inf b/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.inf
new file mode 100644
index 0000000000..8240ceff37
--- /dev/null
+++ b/ChvRefCodePkg/Platform/PlatformEmmc/Dxe/PlatformEmmcDxe.inf
@@ -0,0 +1,80 @@
+## @file
+# Component description file for Platform Emmc Info Dxe Driver
+#
+# Copyright (c) 2013 - 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 Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PlatformEmmcDxe
+ FILE_GUID = B13AFF9D-C66D-46AD-8C23-723482EFC841
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PlatformEmmcInit
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+################################################################################
+#
+# Sources Section - list of files that are required for the build to succeed.
+#
+################################################################################
+[Sources]
+ PlatformEmmcDxe.c
+
+################################################################################
+#
+# Package Dependency Section - list of Package files that are required for
+# this module.
+#
+################################################################################
+[Packages]
+ MdePkg/MdePkg.dec
+ ChvRefCodePkg/ChvRefCodePkg.dec
+
+################################################################################
+#
+# Library Class Section - list of Library Classes that are required for
+# this module.
+#
+################################################################################
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ DebugLib
+ HobLib
+ PchPlatformLib
+
+################################################################################
+#
+# Protocol C Name Section - list of Protocol and Protocol Notify C Names
+# that this module uses or produces.
+#
+################################################################################
+[Protocols]
+ ## CONSUMES
+ ## NOTIFY
+ gEfiEmmcCardInfoProtocolGuid
+
+ ## CONSUMES
+ gPchSccTuningProtocolGuid
+
+[Depex]
+ TRUE
+