3 Copyright (c) 2017-2018, Arm Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 System Control and Management Interface V1.0
14 http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
15 DEN0056A_System_Control_and_Management_Interface.pdf
19 #include <Library/DebugLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Protocol/ArmScmiBaseProtocol.h>
23 #include <Protocol/ArmScmiClockProtocol.h>
24 #include <Protocol/ArmScmiPerformanceProtocol.h>
26 #include "ArmScmiBaseProtocolPrivate.h"
27 #include "ArmScmiClockProtocolPrivate.h"
28 #include "ArmScmiPerformanceProtocolPrivate.h"
30 #include "ScmiPrivate.h"
32 STATIC CONST SCMI_PROTOCOL_ENTRY Protocols
[] = {
33 { SCMI_PROTOCOL_ID_BASE
, ScmiBaseProtocolInit
},
34 { SCMI_PROTOCOL_ID_PERFORMANCE
, ScmiPerformanceProtocolInit
},
35 { SCMI_PROTOCOL_ID_CLOCK
, ScmiClockProtocolInit
}
38 /** ARM SCMI driver entry point function.
40 This function installs the SCMI Base protocol and a list of other
41 protocols is queried using the Base protocol. If protocol is supported,
42 driver will call each protocol init function to install the protocol on
45 @param[in] ImageHandle Handle to this EFI Image which will be used to
46 install Base, Clock and Performance protocols.
47 @param[in] SystemTable A pointer to boot time system table.
49 @retval EFI_SUCCESS Driver initalized successfully.
50 @retval EFI_UNSUPPORTED If SCMI base protocol version is not supported.
51 @retval !(EFI_SUCCESS) Other errors.
55 ArmScmiDxeEntryPoint (
56 IN EFI_HANDLE ImageHandle
,
57 IN EFI_SYSTEM_TABLE
*SystemTable
61 SCMI_BASE_PROTOCOL
*BaseProtocol
;
67 UINT32 SupportedListSize
;
69 // Every SCMI implementation must implement the base protocol.
70 ASSERT (Protocols
[0].Id
== SCMI_PROTOCOL_ID_BASE
);
72 Status
= ScmiBaseProtocolInit (&ImageHandle
);
73 if (EFI_ERROR (Status
)) {
78 Status
= gBS
->LocateProtocol (
79 &gArmScmiBaseProtocolGuid
,
83 if (EFI_ERROR (Status
)) {
88 // Get SCMI Base protocol version.
89 Status
= BaseProtocol
->GetVersion (BaseProtocol
, &Version
);
90 if (EFI_ERROR (Status
)) {
95 if (Version
!= BASE_PROTOCOL_VERSION
) {
97 return EFI_UNSUPPORTED
;
100 // Apart from Base protocol, SCMI may implement various other protocols,
101 // query total protocols implemented by the SCP firmware.
103 Status
= BaseProtocol
->GetTotalProtocols (BaseProtocol
, &NumProtocols
);
104 if (EFI_ERROR (Status
)) {
109 ASSERT (NumProtocols
!= 0);
111 SupportedListSize
= (NumProtocols
* sizeof (*SupportedList
));
113 Status
= gBS
->AllocatePool (
116 (VOID
**)&SupportedList
118 if (EFI_ERROR (Status
)) {
123 // Get the list of protocols supported by SCP firmware on the platform.
124 Status
= BaseProtocol
->DiscoverListProtocols (
129 if (EFI_ERROR (Status
)) {
130 gBS
->FreePool (SupportedList
);
135 // Install supported protocol on ImageHandle.
136 for (ProtocolIndex
= 1; ProtocolIndex
< ARRAY_SIZE (Protocols
);
138 for (Index
= 0; Index
< NumProtocols
; Index
++) {
139 if (Protocols
[ProtocolIndex
].Id
== SupportedList
[Index
]) {
140 Status
= Protocols
[ProtocolIndex
].InitFn (&ImageHandle
);
141 if (EFI_ERROR (Status
)) {
142 ASSERT_EFI_ERROR (Status
);
150 gBS
->FreePool (SupportedList
);