summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
diff options
context:
space:
mode:
authorGirish Pathak <girish.pathak@arm.com>2018-01-15 14:53:26 +0000
committerLeif Lindholm <leif.lindholm@linaro.org>2018-04-23 17:58:28 +0100
commit4f2494cf534a323a7094f8c531f5b9ef51751cfb (patch)
tree2824cb354c64866b4f632d90a54116a8e5af4e87 /ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
parent38a00bae86e56e402130092200c6743dc74faab3 (diff)
downloadedk2-4f2494cf534a323a7094f8c531f5b9ef51751cfb.tar.gz
edk2-4f2494cf534a323a7094f8c531f5b9ef51751cfb.tar.bz2
edk2-4f2494cf534a323a7094f8c531f5b9ef51751cfb.zip
ArmPkg: Introduce SCMI protocol
This change introduces a new SCMI protocol driver for Arm systems. The driver currently supports only clock and performance management protocols. Other protocols will be added as and when needed. Clock management protocol is used to configure various clocks available on the platform e.g. HDLCD clock on the Juno platforms. Whereas performance management protocol allows adjustment of various performance domains. Currently this is used to evaluate performance of the Juno platform. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak <girish.pathak@arm.com> Signed-off-by: Evan Lloyd <evan.lloyd@arm.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c')
-rw-r--r--ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c138
1 files changed, 138 insertions, 0 deletions
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
new file mode 100644
index 0000000000..2920c6f6f3
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
@@ -0,0 +1,138 @@
+/** @file
+
+ Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+
+ 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.
+
+ System Control and Management Interface V1.0
+ http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
+ DEN0056A_System_Control_and_Management_Interface.pdf
+**/
+
+#include <Base.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/ArmScmiBaseProtocol.h>
+#include <Protocol/ArmScmiClockProtocol.h>
+#include <Protocol/ArmScmiPerformanceProtocol.h>
+
+#include "ArmScmiBaseProtocolPrivate.h"
+#include "ArmScmiClockProtocolPrivate.h"
+#include "ArmScmiPerformanceProtocolPrivate.h"
+#include "ScmiDxe.h"
+#include "ScmiPrivate.h"
+
+STATIC CONST SCMI_PROTOCOL_INIT_TABLE ProtocolInitFxns[MAX_PROTOCOLS] = {
+ { ScmiBaseProtocolInit },
+ { NULL },
+ { NULL },
+ { ScmiPerformanceProtocolInit },
+ { ScmiClockProtocolInit },
+ { NULL }
+};
+
+/** ARM SCMI driver entry point function.
+
+ This function installs the SCMI Base protocol and a list of other
+ protocols is queried using the Base protocol. If protocol is supported,
+ driver will call each protocol init function to install the protocol on
+ the ImageHandle.
+
+ @param[in] ImageHandle Handle to this EFI Image which will be used to
+ install Base, Clock and Performance protocols.
+ @param[in] SystemTable A pointer to boot time system table.
+
+ @retval EFI_SUCCESS Driver initalized successfully.
+ @retval EFI_UNSUPPORTED If SCMI base protocol version is not supported.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+EFIAPI
+ArmScmiDxeEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ SCMI_BASE_PROTOCOL *BaseProtocol;
+ UINT32 Version;
+ UINT32 Index;
+ UINT32 NumProtocols;
+ UINT32 ProtocolNo;
+ UINT8 SupportedList[MAX_PROTOCOLS];
+ UINT32 SupportedListSize = sizeof (SupportedList);
+
+ ProtocolNo = SCMI_PROTOCOL_ID_BASE & PROTOCOL_ID_MASK;
+
+ // Every SCMI implementation must implement the base protocol.
+ Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle);
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+
+ Status = gBS->LocateProtocol (
+ &gArmScmiBaseProtocolGuid,
+ NULL,
+ (VOID**)&BaseProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+
+ // Get SCMI Base protocol version.
+ Status = BaseProtocol->GetVersion (BaseProtocol, &Version);
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+
+ if (Version != BASE_PROTOCOL_VERSION) {
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+ }
+
+ // Apart from Base protocol, SCMI may implement various other protocols,
+ // query total protocols implemented by the SCP firmware.
+ NumProtocols = 0;
+ Status = BaseProtocol->GetTotalProtocols (BaseProtocol, &NumProtocols);
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+
+ ASSERT (NumProtocols != 0);
+
+ // Get the list of protocols supported by SCP firmware on the platform.
+ Status = BaseProtocol->DiscoverListProtocols (
+ BaseProtocol,
+ &SupportedListSize,
+ SupportedList
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+
+ // Install supported protocol on ImageHandle.
+ for (Index = 0; Index < NumProtocols; Index++) {
+ ProtocolNo = SupportedList[Index] & PROTOCOL_ID_MASK;
+ if (ProtocolInitFxns[ProtocolNo].Init != NULL) {
+ Status = ProtocolInitFxns[ProtocolNo].Init (&ImageHandle);
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}