summaryrefslogtreecommitdiff
path: root/ChvRefCodePkg
diff options
context:
space:
mode:
authorGuo Mang <mang.guo@intel.com>2016-06-02 13:44:12 +0800
committerHao Wu <hao.a.wu@intel.com>2016-06-07 09:55:30 +0800
commit38352447be1688993ecb6b34d4b4599f54baae23 (patch)
treee7367fc512b343444557d969e2c078d9b1947e30 /ChvRefCodePkg
parent1a30d2c0c3836befde6b6d7521a31461c0c3fbea (diff)
downloadedk2-platforms-38352447be1688993ecb6b34d4b4599f54baae23.tar.xz
ChvRefCodePkg: Add ISPDxe.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'ChvRefCodePkg')
-rw-r--r--ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.c119
-rw-r--r--ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.h32
-rw-r--r--ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.inf50
3 files changed, 201 insertions, 0 deletions
diff --git a/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.c b/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.c
new file mode 100644
index 0000000000..ec77b8342e
--- /dev/null
+++ b/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.c
@@ -0,0 +1,119 @@
+/** @file
+ ISP Platform Driver
+
+ Copyright (c) 2012 - 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 <ISPDxe.h>
+
+EFI_HANDLE mImageHandle;
+
+///
+/// ISP reserved memory length
+///
+#define ISP_MEMORY_LENGTH 0x400000
+///
+/// 4M alignment
+///
+#define ISP_MMIO_ALIGNMENT 22
+
+EFI_GLOBAL_NVS_AREA_PROTOCOL *GlobalNvsArea;
+
+STATIC
+VOID
+EFIAPI
+OnReadyToBootISP (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS ISPBase;
+
+ //
+ // Avoid the event will run twice
+ //
+ gBS->CloseEvent (Event);
+ //
+ // Allocated memeory for ISP
+ //
+ ISPBase = 0xFFFFFFFF;
+ Status = gDS->AllocateMemorySpace (
+ EfiGcdAllocateMaxAddressSearchBottomUp,
+ EfiGcdMemoryTypeMemoryMappedIo,
+ ISP_MMIO_ALIGNMENT,
+ ISP_MEMORY_LENGTH,
+ &ISPBase,
+ mImageHandle,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Update ISP Base in GlobalNvs
+ //
+ DEBUG ((EFI_D_ERROR, "=============ISPBase=%x==============\n\n", ISPBase));
+ GlobalNvsArea->Area->ISPAddr = (UINT32) ISPBase;
+ return;
+}
+
+/**
+ Entry point for Acpi platform driver.
+
+ @param[in] ImageHandle - A handle for the image that is initializing this driver.
+ @param[in] SystemTable - A pointer to the EFI system table.
+
+ @retval EFI_SUCCESS - Driver initialized successfully.
+ @retval EFI_LOAD_ERROR - Failed to Initialize or has been loaded.
+ @retval EFI_OUT_OF_RESOURCES - Could not allocate needed resources.
+
+**/
+EFI_STATUS
+EFIAPI
+ISPDxeEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ //
+ // Locate the Global NVS Protocol.
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiGlobalNvsAreaProtocolGuid,
+ NULL,
+ (VOID **) &GlobalNvsArea
+ );
+ //
+ // Return if ISP disabled.
+ //
+ if (GlobalNvsArea->Area->ISPDevSel == 0) {
+ DEBUG ((EFI_D_ERROR, "ISP Feature Disable !!\n\n"));
+ return EFI_SUCCESS;
+ }
+
+ mImageHandle = ImageHandle;
+ //
+ // Update ISP Base Address
+ //
+ if (GlobalNvsArea->Area->ISPDevSel == 1) {
+ Status = EfiCreateEventReadyToBootEx (
+ TPL_NOTIFY,
+ OnReadyToBootISP,
+ NULL,
+ &Event
+ );
+ }
+
+ return Status;
+}
diff --git a/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.h b/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.h
new file mode 100644
index 0000000000..d246d0ba52
--- /dev/null
+++ b/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.h
@@ -0,0 +1,32 @@
+/** @file
+ The header file of ISP driver.
+
+ 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 _ISP_DXE_H_
+#define _ISP_DXE_H_
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/IoLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/S3BootScriptLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Uefi/UefiBaseType.h>
+#include <Protocol/GlobalNvsArea.h>
+#include <ChvAccess.h>
+#include <PchRegs.h>
+
+#endif
diff --git a/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.inf b/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.inf
new file mode 100644
index 0000000000..f2765fee43
--- /dev/null
+++ b/ChvRefCodePkg/CherryViewSoc/NorthCluster/ISPDxe/ISPDxe.inf
@@ -0,0 +1,50 @@
+## @file
+# ISP Dxe Module
+#
+# This module will initialize ISP device and update memory bar
+# information in acpi table.
+#
+# 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 = ISPDxe
+ FILE_GUID = 1502A77D-2FC0-4A14-AA83-838217560CC5
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ISPDxeEntryPoint
+
+[sources.common]
+ ISPDxe.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ChvRefCodePkg/ChvRefCodePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ DxeServicesTableLib
+ UefiLib
+ IoLib
+ DebugLib
+ DxeServicesTableLib
+
+[Protocols]
+ ## CONSUMES
+ gEfiGlobalNvsAreaProtocolGuid
+
+[Depex]
+ gEfiGlobalNvsAreaProtocolGuid
+