summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc1
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Include/VExpressMotherBoard.h23
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfig.c255
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf45
-rw-r--r--ArmPlatformPkg/Include/Library/ArmPlatformSysConfigLib.h55
5 files changed, 379 insertions, 0 deletions
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
index 75362e19da..628c4077cb 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA9x4.dsc
@@ -102,6 +102,7 @@
# ARM PL011 UART Driver
PL011UartLib|ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
+ ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
NorFlashPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/NorFlashArmVExpressLib/NorFlashArmVExpressLib.inf
#
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Include/VExpressMotherBoard.h b/ArmPlatformPkg/ArmVExpressPkg/Include/VExpressMotherBoard.h
index 3fcd74f683..f9273697e3 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Include/VExpressMotherBoard.h
+++ b/ArmPlatformPkg/ArmVExpressPkg/Include/VExpressMotherBoard.h
@@ -73,4 +73,27 @@
#define ARM_VE_DAUGHTERBOARD_1_SITE 1
#define ARM_VE_DAUGHTERBOARD_2_SITE 2
+#define VIRTUAL_SYS_CFG(site,func) (((site) << 24) | (func))
+
+//
+// System Configuration Control Functions
+//
+#define SYS_CFG_OSC 1
+#define SYS_CFG_VOLT 2
+#define SYS_CFG_AMP 3
+#define SYS_CFG_TEMP 4
+#define SYS_CFG_RESET 5
+#define SYS_CFG_SCC 6
+#define SYS_CFG_MUXFPGA 7
+#define SYS_CFG_SHUTDOWN 8
+#define SYS_CFG_REBOOT 9
+#define SYS_CFG_DVIMODE 11
+#define SYS_CFG_POWER 12
+// Oscillator for Site 1
+#define SYS_CFG_OSC_SITE1 VIRTUAL_SYS_CFG(ARM_VE_DAUGHTERBOARD_1_SITE,SYS_CFG_OSC)
+// Oscillator for Site 2
+#define SYS_CFG_OSC_SITE2 VIRTUAL_SYS_CFG(ARM_VE_DAUGHTERBOARD_2_SITE,SYS_CFG_OSC)
+// Can not access the battery backed-up hardware clock on the Versatile Express motherboard
+#define SYS_CFG_RTC VIRTUAL_SYS_CFG(ARM_VE_UNSUPPORTED,1)
+
#endif /* VEXPRESSMOTHERBOARD_H_ */
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfig.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfig.c
new file mode 100644
index 0000000000..27ef0a7c5f
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfig.c
@@ -0,0 +1,255 @@
+/** @file SysCfgArmVExpress.c
+
+ Copyright (c) 2011, ARM Ltd. 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 <PiDxe.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+
+#include <Library/ArmPlatformSysConfigLib.h>
+#include <ArmPlatform.h>
+
+//
+// SYS_CFGCTRL Bits
+//
+#define SYS_CFGCTRL_START BIT31
+#define SYS_CFGCTRL_READ (0 << 30)
+#define SYS_CFGCTRL_WRITE (1 << 30)
+#define SYS_CFGCTRL_FUNCTION(fun) (((fun ) & 0x3F) << 20)
+#define SYS_CFGCTRL_SITE(site) (((site) & 0x3) << 16)
+#define SYS_CFGCTRL_POSITION(pos) (((pos ) & 0xF) << 12)
+#define SYS_CFGCTRL_DEVICE(dev) ((dev ) & 0xFFF)
+
+//
+// SYS_CFGSTAT Bits
+//
+#define SYS_CFGSTAT_ERROR BIT1
+#define SYS_CFGSTAT_COMPLETE BIT0
+
+/****************************************************************************
+ *
+ * This file makes it easier to access the System Configuration Registers
+ * in the ARM Versatile Express motherboard.
+ *
+ ****************************************************************************/
+
+EFI_STATUS
+ArmPlatformSysConfigInitialize (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/***************************************
+ * GENERAL FUNCTION: AccessSysCfgRegister
+ * Interacts with
+ * SYS_CFGSTAT
+ * SYS_CFGDATA
+ * SYS_CFGCTRL
+ * for setting and for reading out values
+ ***************************************/
+
+EFI_STATUS
+AccessSysCfgRegister (
+ IN UINT32 ReadWrite,
+ IN UINT32 Function,
+ IN UINT32 Site,
+ IN UINT32 Position,
+ IN UINT32 Device,
+ IN OUT UINT32* Data
+ )
+{
+ UINT32 SysCfgCtrl;
+
+ // Clear the COMPLETE bit
+ MmioAnd32(ARM_VE_SYS_CFGSTAT_REG, ~SYS_CFGSTAT_COMPLETE);
+
+ // If writing, then set the data value
+ if(ReadWrite == SYS_CFGCTRL_WRITE) {
+ MmioWrite32(ARM_VE_SYS_CFGDATA_REG, *Data);
+ }
+
+ // Set the control value
+ SysCfgCtrl = SYS_CFGCTRL_START | ReadWrite | SYS_CFGCTRL_FUNCTION(Function) | SYS_CFGCTRL_SITE(Site) |
+ SYS_CFGCTRL_POSITION(Position) | SYS_CFGCTRL_DEVICE(Device);
+ MmioWrite32(ARM_VE_SYS_CFGCTRL_REG, SysCfgCtrl);
+
+ // Wait until the COMPLETE bit is set
+ while ((MmioRead32(ARM_VE_SYS_CFGSTAT_REG) & SYS_CFGSTAT_COMPLETE) == 0);
+
+ // Check for errors
+ if(MmioRead32(ARM_VE_SYS_CFGSTAT_REG) & SYS_CFGSTAT_ERROR) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ // If reading then get the data value
+ if(ReadWrite == SYS_CFGCTRL_READ) {
+ *Data = MmioRead32(ARM_VE_SYS_CFGDATA_REG);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ArmPlatformSysConfigGet (
+ IN SYS_CONFIG_FUNCTION Function,
+ OUT UINT32* Value
+ )
+{
+ UINT32 Site;
+ UINT32 Position;
+ UINT32 Device;
+
+ Position = 0;
+ Device = 0;
+
+ // Intercept some functions
+ switch(Function) {
+
+ case SYS_CFG_OSC_SITE1:
+ Function = SYS_CFG_OSC;
+ Site = ARM_VE_DAUGHTERBOARD_1_SITE;
+ break;
+
+ case SYS_CFG_OSC_SITE2:
+ Function = SYS_CFG_OSC;
+ Site = ARM_VE_DAUGHTERBOARD_2_SITE;
+ break;
+
+ case SYS_CFG_MUXFPGA:
+ Site = *Value;
+ break;
+
+ case SYS_CFG_OSC:
+ case SYS_CFG_VOLT:
+ case SYS_CFG_AMP:
+ case SYS_CFG_TEMP:
+ case SYS_CFG_RESET:
+ case SYS_CFG_SCC:
+ case SYS_CFG_DVIMODE:
+ case SYS_CFG_POWER:
+ Site = ARM_VE_MOTHERBOARD_SITE;
+ break;
+
+ case SYS_CFG_SHUTDOWN:
+ case SYS_CFG_REBOOT:
+ case SYS_CFG_RTC:
+ default:
+ return EFI_UNSUPPORTED;
+ }
+
+ return AccessSysCfgRegister (SYS_CFGCTRL_READ, Function, Site, Position, Device, Value);
+}
+
+EFI_STATUS
+ArmPlatformSysConfigSet (
+ IN SYS_CONFIG_FUNCTION Function,
+ IN UINT32 Value
+ )
+{
+ UINT32 Site;
+ UINT32 Position;
+ UINT32 Device;
+
+ Position = 0;
+ Device = 0;
+
+ // Intercept some functions
+ switch(Function) {
+
+ case SYS_CFG_OSC_SITE1:
+ Function = SYS_CFG_OSC;
+ Site = ARM_VE_DAUGHTERBOARD_1_SITE;
+ break;
+
+ case SYS_CFG_OSC_SITE2:
+ Function = SYS_CFG_OSC;
+ Site = ARM_VE_DAUGHTERBOARD_2_SITE;
+ break;
+
+ case SYS_CFG_MUXFPGA:
+ Site = Value;
+ break;
+
+ case SYS_CFG_RESET:
+ case SYS_CFG_SCC:
+ case SYS_CFG_SHUTDOWN:
+ case SYS_CFG_REBOOT:
+ case SYS_CFG_DVIMODE:
+ case SYS_CFG_POWER:
+ Site = ARM_VE_MOTHERBOARD_SITE;
+ break;
+
+ case SYS_CFG_OSC:
+ case SYS_CFG_VOLT:
+ case SYS_CFG_AMP:
+ case SYS_CFG_TEMP:
+ case SYS_CFG_RTC:
+ default:
+ return(EFI_UNSUPPORTED);
+ }
+
+ return AccessSysCfgRegister (SYS_CFGCTRL_WRITE, Function, Site, Position, Device, &Value);
+}
+
+EFI_STATUS
+ArmPlatformSysConfigSetDevice (
+ IN SYS_CONFIG_FUNCTION Function,
+ IN UINT32 Device,
+ IN UINT32 Value
+ )
+{
+ UINT32 Site;
+ UINT32 Position;
+
+ Position = 0;
+
+ // Intercept some functions
+ switch(Function) {
+
+ case SYS_CFG_OSC_SITE1:
+ Function = SYS_CFG_OSC;
+ Site = ARM_VE_DAUGHTERBOARD_1_SITE;
+ break;
+
+ case SYS_CFG_OSC_SITE2:
+ Function = SYS_CFG_OSC;
+ Site = ARM_VE_DAUGHTERBOARD_2_SITE;
+ break;
+
+ case SYS_CFG_MUXFPGA:
+ Site = Value;
+ break;
+
+ case SYS_CFG_RTC:
+ return(EFI_UNSUPPORTED);
+ //break;
+
+ case SYS_CFG_OSC:
+ case SYS_CFG_VOLT:
+ case SYS_CFG_AMP:
+ case SYS_CFG_TEMP:
+ case SYS_CFG_RESET:
+ case SYS_CFG_SCC:
+ case SYS_CFG_SHUTDOWN:
+ case SYS_CFG_REBOOT:
+ case SYS_CFG_DVIMODE:
+ case SYS_CFG_POWER:
+ Site = ARM_VE_MOTHERBOARD_SITE;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ }
+
+ return AccessSysCfgRegister (SYS_CFGCTRL_WRITE, Function, Site, Position, Device, &Value);
+}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
new file mode 100644
index 0000000000..01027cc271
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
@@ -0,0 +1,45 @@
+#/** @file
+#
+# Component discription file for ArmVeGraphicsDxe module
+#
+# Copyright (c) 2011, ARM Ltd. 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 = ArmVExpressSysConfigLib
+ FILE_GUID = a05b5cc0-82d2-11e0-82cb-0002a5d5c51b
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ArmPlatformSysConfigLib
+
+[Sources.common]
+ ArmVExpressSysConfig.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+ BaseLib
+
+[Guids]
+
+[Protocols]
+
+[FeaturePcd]
+
+[FixedPcd.common]
+
+[Pcd.common]
+
+[Depex]
diff --git a/ArmPlatformPkg/Include/Library/ArmPlatformSysConfigLib.h b/ArmPlatformPkg/Include/Library/ArmPlatformSysConfigLib.h
new file mode 100644
index 0000000000..62855832cb
--- /dev/null
+++ b/ArmPlatformPkg/Include/Library/ArmPlatformSysConfigLib.h
@@ -0,0 +1,55 @@
+/** @file ArmPlatformSysConfigLib.h
+
+ Copyright (c) 2011, ARM Ltd. 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 __ARM_PLATFORM_SYS_CONFIG_H__
+#define __ARM_PLATFORM_SYS_CONFIG_H__
+
+#include <Base.h>
+
+/* This header file makes it easier to access the System Configuration Registers
+ * in the ARM Versatile Express motherboard.
+ */
+
+//
+// Typedef
+//
+typedef UINT32 SYS_CONFIG_FUNCTION;
+
+//
+// Functions
+//
+EFI_STATUS
+ArmPlatformSysConfigInitialize (
+ VOID
+ );
+
+EFI_STATUS
+ArmPlatformSysConfigGet (
+ IN SYS_CONFIG_FUNCTION Function,
+ OUT UINT32* Value
+ );
+
+EFI_STATUS
+ArmPlatformSysConfigSet (
+ IN SYS_CONFIG_FUNCTION Function,
+ IN UINT32 Value
+ );
+
+EFI_STATUS
+ArmPlatformSysConfigSetDevice (
+ IN SYS_CONFIG_FUNCTION Function,
+ IN UINT32 Device,
+ IN UINT32 Value
+ );
+
+#endif /* __SYS_CFG_REGISTERS_H__ */