* [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
@ 2018-03-20 16:11 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:11 ` [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib Girish Pathak
` (15 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:11 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
This fix changes line endings of LcdHwNullLib.c to DOS
style line endings from UNIX style line endings to meet the
EDK2 coding standard. Note it also fixes an end of line
whitespace.
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>
---
ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c | 150 ++++++++++----------
1 file changed, 75 insertions(+), 75 deletions(-)
diff --git a/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c b/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
index 2d31b5183c959c88eb1dab7703ec9b87f03eb50f..50e1c88112db690545979e7d008678c4f8ecd949 100644
--- a/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
+++ b/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
@@ -1,75 +1,75 @@
-/** @file
-
- Copyright (c) 2017, Linaro, Ltd. 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.
-
-**/
-
-#include <Base.h>
-#include <Uefi/UefiBaseType.h>
-#include <Library/DebugLib.h>
-#include <Library/LcdPlatformLib.h>
-
-/**
- Check for presence of display
-
- @retval EFI_SUCCESS Platform implements display.
- @retval EFI_NOT_FOUND Display not found on the platform.
-
-**/
-EFI_STATUS
-LcdIdentify (
- VOID
- )
-{
- return EFI_SUCCESS;
-}
-
-/**
- Initialize display.
-
- @param FrameBaseAddress Address of the frame buffer.
- @retval EFI_SUCCESS Display initialization success.
- @retval !(EFI_SUCCESS) Display initialization failure.
-
-**/
-EFI_STATUS
-LcdInitialize (
- EFI_PHYSICAL_ADDRESS FrameBaseAddress
- )
-{
- return EFI_SUCCESS;
-}
-
-/**
- Set requested mode of the display.
-
- @param ModeNumber Display mode number.
- @retval EFI_SUCCESS Display set mode success.
- @retval EFI_DEVICE_ERROR If mode not found/supported.
-
-**/
-EFI_STATUS
-LcdSetMode (
- IN UINT32 ModeNumber
- )
-{
- return EFI_SUCCESS;
-}
-
-/**
- De-initializes the display.
-**/
-VOID
-LcdShutdown (
- VOID
- )
-{
-}
+/** @file
+
+ Copyright (c) 2017, Linaro, Ltd. 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.
+
+**/
+
+#include <Base.h>
+#include <Uefi/UefiBaseType.h>
+#include <Library/DebugLib.h>
+#include <Library/LcdPlatformLib.h>
+
+/**
+ Check for presence of display
+
+ @retval EFI_SUCCESS Platform implements display.
+ @retval EFI_NOT_FOUND Display not found on the platform.
+
+**/
+EFI_STATUS
+LcdIdentify (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/**
+ Initialize display.
+
+ @param FrameBaseAddress Address of the frame buffer.
+ @retval EFI_SUCCESS Display initialization success.
+ @retval !(EFI_SUCCESS) Display initialization failure.
+
+**/
+EFI_STATUS
+LcdInitialize (
+ EFI_PHYSICAL_ADDRESS FrameBaseAddress
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/**
+ Set requested mode of the display.
+
+ @param ModeNumber Display mode number.
+ @retval EFI_SUCCESS Display set mode success.
+ @retval EFI_DEVICE_ERROR If mode not found/supported.
+
+**/
+EFI_STATUS
+LcdSetMode (
+ IN UINT32 ModeNumber
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/**
+ De-initializes the display.
+**/
+VOID
+LcdShutdown (
+ VOID
+ )
+{
+}
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib
2018-03-20 16:11 ` [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of
> LcdHwNullLib
>
> This fix changes line endings of LcdHwNullLib.c to DOS style line endings
> from UNIX style line endings to meet the
> EDK2 coding standard. Note it also fixes an end of line whitespace.
>
> 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>
> ---
> ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c | 150
> ++++++++++----------
> 1 file changed, 75 insertions(+), 75 deletions(-)
>
> diff --git a/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
> b/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
> index
> 2d31b5183c959c88eb1dab7703ec9b87f03eb50f..50e1c88112db69054597
> 9e7d008678c4f8ecd949 100644
> --- a/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
> +++ b/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c
> @@ -1,75 +1,75 @@
> -/** @file
> -
> - Copyright (c) 2017, Linaro, Ltd. 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.
> -
> -**/
> -
> -#include <Base.h>
> -#include <Uefi/UefiBaseType.h>
> -#include <Library/DebugLib.h>
> -#include <Library/LcdPlatformLib.h>
> -
> -/**
> - Check for presence of display
> -
> - @retval EFI_SUCCESS Platform implements display.
> - @retval EFI_NOT_FOUND Display not found on the platform.
> -
> -**/
> -EFI_STATUS
> -LcdIdentify (
> - VOID
> - )
> -{
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - Initialize display.
> -
> - @param FrameBaseAddress Address of the frame buffer.
> - @retval EFI_SUCCESS Display initialization success.
> - @retval !(EFI_SUCCESS) Display initialization failure.
> -
> -**/
> -EFI_STATUS
> -LcdInitialize (
> - EFI_PHYSICAL_ADDRESS FrameBaseAddress
> - )
> -{
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - Set requested mode of the display.
> -
> - @param ModeNumber Display mode number.
> - @retval EFI_SUCCESS Display set mode success.
> - @retval EFI_DEVICE_ERROR If mode not found/supported.
> -
> -**/
> -EFI_STATUS
> -LcdSetMode (
> - IN UINT32 ModeNumber
> - )
> -{
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - De-initializes the display.
> -**/
> -VOID
> -LcdShutdown (
> - VOID
> - )
> -{
> -}
> +/** @file
> +
> + Copyright (c) 2017, Linaro, Ltd. 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.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Uefi/UefiBaseType.h>
> +#include <Library/DebugLib.h>
> +#include <Library/LcdPlatformLib.h>
> +
> +/**
> + Check for presence of display
> +
> + @retval EFI_SUCCESS Platform implements display.
> + @retval EFI_NOT_FOUND Display not found on the platform.
> +
> +**/
> +EFI_STATUS
> +LcdIdentify (
> + VOID
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Initialize display.
> +
> + @param FrameBaseAddress Address of the frame buffer.
> + @retval EFI_SUCCESS Display initialization success.
> + @retval !(EFI_SUCCESS) Display initialization failure.
> +
> +**/
> +EFI_STATUS
> +LcdInitialize (
> + EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + Set requested mode of the display.
> +
> + @param ModeNumber Display mode number.
> + @retval EFI_SUCCESS Display set mode success.
> + @retval EFI_DEVICE_ERROR If mode not found/supported.
> +
> +**/
> +EFI_STATUS
> +LcdSetMode (
> + IN UINT32 ModeNumber
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + De-initializes the display.
> +**/
> +VOID
> +LcdShutdown (
> + VOID
> + )
> +{
> +}
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
2018-03-20 16:11 ` [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib Girish Pathak
@ 2018-03-20 16:11 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:11 ` [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard Girish Pathak
` (14 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:11 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
This fix changes line endings of LcdPlatformNullLib.c to DOS
style line endings from UNIX style line endings to meet the EDK2
coding standard.
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>
---
ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 184 ++++++++++----------
1 file changed, 92 insertions(+), 92 deletions(-)
diff --git a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
index 071eb5ffd4be895a0ce2ed5144f1f99e8195d1a0..b78d9a3bbd3e1fac4238f2be961a343020360a32 100644
--- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
+++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
@@ -1,92 +1,92 @@
-/** @file
-
- Copyright (c) 2017, Linaro, Ltd. 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.
-
-**/
-
-#include <Base.h>
-#include <Uefi/UefiBaseType.h>
-#include <Library/DebugLib.h>
-#include <Library/LcdPlatformLib.h>
-
-EFI_STATUS
-LcdPlatformInitializeDisplay (
- IN EFI_HANDLE Handle
- )
-{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
-}
-
-EFI_STATUS
-LcdPlatformGetVram (
- OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
- OUT UINTN* VramSize
- )
-{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
-}
-
-UINT32
-LcdPlatformGetMaxMode (
- VOID
- )
-{
- ASSERT (FALSE);
- return 0;
-}
-
-EFI_STATUS
-LcdPlatformSetMode (
- IN UINT32 ModeNumber
- )
-{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
-}
-
-EFI_STATUS
-LcdPlatformQueryMode (
- IN UINT32 ModeNumber,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
- )
-{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
-}
-
-EFI_STATUS
-LcdPlatformGetTimings (
- IN UINT32 ModeNumber,
- OUT UINT32* HRes,
- OUT UINT32* HSync,
- OUT UINT32* HBackPorch,
- OUT UINT32* HFrontPorch,
- OUT UINT32* VRes,
- OUT UINT32* VSync,
- OUT UINT32* VBackPorch,
- OUT UINT32* VFrontPorch
- )
-{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
-}
-
-EFI_STATUS
-LcdPlatformGetBpp (
- IN UINT32 ModeNumber,
- OUT LCD_BPP* Bpp
- )
-{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
-}
+/** @file
+
+ Copyright (c) 2017, Linaro, Ltd. 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.
+
+**/
+
+#include <Base.h>
+#include <Uefi/UefiBaseType.h>
+#include <Library/DebugLib.h>
+#include <Library/LcdPlatformLib.h>
+
+EFI_STATUS
+LcdPlatformInitializeDisplay (
+ IN EFI_HANDLE Handle
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+LcdPlatformGetVram (
+ OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
+ OUT UINTN* VramSize
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+UINT32
+LcdPlatformGetMaxMode (
+ VOID
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+EFI_STATUS
+LcdPlatformSetMode (
+ IN UINT32 ModeNumber
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+LcdPlatformQueryMode (
+ IN UINT32 ModeNumber,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+LcdPlatformGetTimings (
+ IN UINT32 ModeNumber,
+ OUT UINT32* HRes,
+ OUT UINT32* HSync,
+ OUT UINT32* HBackPorch,
+ OUT UINT32* HFrontPorch,
+ OUT UINT32* VRes,
+ OUT UINT32* VSync,
+ OUT UINT32* VBackPorch,
+ OUT UINT32* VFrontPorch
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+LcdPlatformGetBpp (
+ IN UINT32 ModeNumber,
+ OUT LCD_BPP* Bpp
+ )
+{
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+}
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib
2018-03-20 16:11 ` [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of
> LcdPlatformNullLib
>
> This fix changes line endings of LcdPlatformNullLib.c to DOS style line
> endings from UNIX style line endings to meet the EDK2 coding standard.
>
> 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>
> ---
> ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 184
> ++++++++++----------
> 1 file changed, 92 insertions(+), 92 deletions(-)
>
> diff --git
> a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> index
> 071eb5ffd4be895a0ce2ed5144f1f99e8195d1a0..b78d9a3bbd3e1fac4238f2
> be961a343020360a32 100644
> --- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> +++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> @@ -1,92 +1,92 @@
> -/** @file
> -
> - Copyright (c) 2017, Linaro, Ltd. 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.
> -
> -**/
> -
> -#include <Base.h>
> -#include <Uefi/UefiBaseType.h>
> -#include <Library/DebugLib.h>
> -#include <Library/LcdPlatformLib.h>
> -
> -EFI_STATUS
> -LcdPlatformInitializeDisplay (
> - IN EFI_HANDLE Handle
> - )
> -{
> - ASSERT (FALSE);
> - return EFI_UNSUPPORTED;
> -}
> -
> -EFI_STATUS
> -LcdPlatformGetVram (
> - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> - OUT UINTN* VramSize
> - )
> -{
> - ASSERT (FALSE);
> - return EFI_UNSUPPORTED;
> -}
> -
> -UINT32
> -LcdPlatformGetMaxMode (
> - VOID
> - )
> -{
> - ASSERT (FALSE);
> - return 0;
> -}
> -
> -EFI_STATUS
> -LcdPlatformSetMode (
> - IN UINT32 ModeNumber
> - )
> -{
> - ASSERT (FALSE);
> - return EFI_UNSUPPORTED;
> -}
> -
> -EFI_STATUS
> -LcdPlatformQueryMode (
> - IN UINT32 ModeNumber,
> - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> - )
> -{
> - ASSERT (FALSE);
> - return EFI_UNSUPPORTED;
> -}
> -
> -EFI_STATUS
> -LcdPlatformGetTimings (
> - IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> - )
> -{
> - ASSERT (FALSE);
> - return EFI_UNSUPPORTED;
> -}
> -
> -EFI_STATUS
> -LcdPlatformGetBpp (
> - IN UINT32 ModeNumber,
> - OUT LCD_BPP* Bpp
> - )
> -{
> - ASSERT (FALSE);
> - return EFI_UNSUPPORTED;
> -}
> +/** @file
> +
> + Copyright (c) 2017, Linaro, Ltd. 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.
> +
> +**/
> +
> +#include <Base.h>
> +#include <Uefi/UefiBaseType.h>
> +#include <Library/DebugLib.h>
> +#include <Library/LcdPlatformLib.h>
> +
> +EFI_STATUS
> +LcdPlatformInitializeDisplay (
> + IN EFI_HANDLE Handle
> + )
> +{
> + ASSERT (FALSE);
> + return EFI_UNSUPPORTED;
> +}
> +
> +EFI_STATUS
> +LcdPlatformGetVram (
> + OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> + OUT UINTN* VramSize
> + )
> +{
> + ASSERT (FALSE);
> + return EFI_UNSUPPORTED;
> +}
> +
> +UINT32
> +LcdPlatformGetMaxMode (
> + VOID
> + )
> +{
> + ASSERT (FALSE);
> + return 0;
> +}
> +
> +EFI_STATUS
> +LcdPlatformSetMode (
> + IN UINT32 ModeNumber
> + )
> +{
> + ASSERT (FALSE);
> + return EFI_UNSUPPORTED;
> +}
> +
> +EFI_STATUS
> +LcdPlatformQueryMode (
> + IN UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> + )
> +{
> + ASSERT (FALSE);
> + return EFI_UNSUPPORTED;
> +}
> +
> +EFI_STATUS
> +LcdPlatformGetTimings (
> + IN UINT32 ModeNumber,
> + OUT UINT32* HRes,
> + OUT UINT32* HSync,
> + OUT UINT32* HBackPorch,
> + OUT UINT32* HFrontPorch,
> + OUT UINT32* VRes,
> + OUT UINT32* VSync,
> + OUT UINT32* VBackPorch,
> + OUT UINT32* VFrontPorch
> + )
> +{
> + ASSERT (FALSE);
> + return EFI_UNSUPPORTED;
> +}
> +
> +EFI_STATUS
> +LcdPlatformGetBpp (
> + IN UINT32 ModeNumber,
> + OUT LCD_BPP* Bpp
> + )
> +{
> + ASSERT (FALSE);
> + return EFI_UNSUPPORTED;
> +}
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
2018-03-20 16:11 ` [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib Girish Pathak
2018-03-20 16:11 ` [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib Girish Pathak
@ 2018-03-20 16:11 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments Girish Pathak
` (13 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:11 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
There is no functional modification in this change
As preparation for further work, the formatting is corrected to meet
the EDKII coding standard.
Of specific note, some invalid include guards were fixed.
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>
---
Notes:
v3:
- Minor coding style changes [Ard]
Done [Girish]
- Changing one style to the other is just pointless churn [Ard]
Fixing the include guards: is a small improvement.
(Ideally patchcheck should reject these.)
Reducing lines to 80 columns: makes Leif (at least)
happy, and aligns with formatter behaviour. Correcting
Doxygen format comments: prevents Doxygen generating
gibberish. Spaces before '(': Maintains consistency,
and aligns with desired formatter behaviour. [Evan]
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 187 +++++++++++---------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h | 10 +-
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 14 +-
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 88 +++++----
ArmPlatformPkg/Library/HdLcd/HdLcd.h | 21 ++-
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 64 ++++---
6 files changed, 208 insertions(+), 176 deletions(-)
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index b721061fc1df5695092e8c71da97ae0b9af46b3f..905eb26ee01b5037dfbaf3c054a62593837c8b5f 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2018, 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
@@ -9,7 +9,7 @@
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/BaseMemoryLib.h>
@@ -22,12 +22,10 @@
#include "LcdGraphicsOutputDxe.h"
-/**********************************************************************
- *
- * This file implements the Graphics Output protocol on ArmVersatileExpress
- * using the Lcd controller
- *
- **********************************************************************/
+/** This file implements the Graphics Output protocol on ArmVersatileExpress
+ using the Lcd controller
+
+**/
//
// Global variables
@@ -64,7 +62,10 @@ LCD_INSTANCE mLcdTemplate = {
{
{
HARDWARE_DEVICE_PATH, HW_VENDOR_DP,
- { (UINT8) (sizeof(VENDOR_DEVICE_PATH)), (UINT8) ((sizeof(VENDOR_DEVICE_PATH)) >> 8) },
+ {
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ },
},
// Hardware Device Path for Lcd
EFI_CALLER_ID_GUID // Use the driver's GUID
@@ -73,10 +74,13 @@ LCD_INSTANCE mLcdTemplate = {
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 }
+ {
+ sizeof (EFI_DEVICE_PATH_PROTOCOL),
+ 0
+ }
}
},
- (EFI_EVENT) NULL // ExitBootServicesEvent
+ (EFI_EVENT)NULL // ExitBootServicesEvent
};
EFI_STATUS
@@ -86,7 +90,7 @@ LcdInstanceContructor (
{
LCD_INSTANCE* Instance;
- Instance = AllocateCopyPool (sizeof(LCD_INSTANCE), &mLcdTemplate);
+ Instance = AllocateCopyPool (sizeof (LCD_INSTANCE), &mLcdTemplate);
if (Instance == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -113,23 +117,23 @@ InitializeDisplay (
UINTN VramSize;
Status = LcdPlatformGetVram (&VramBaseAddress, &VramSize);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
// Setup the LCD
Status = LcdInitialize (VramBaseAddress);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT_ERROR_LCD_SHUTDOWN;
}
Status = LcdPlatformInitializeDisplay (Instance->Handle);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT_ERROR_LCD_SHUTDOWN;
}
// Setup all the relevant mode information
- Instance->Gop.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ Instance->Gop.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Instance->Gop.Mode->FrameBufferBase = VramBaseAddress;
// Set the flag before changing the mode, to avoid infinite loops
@@ -139,7 +143,8 @@ InitializeDisplay (
goto EXIT;
EXIT_ERROR_LCD_SHUTDOWN:
- DEBUG((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the display. Exit Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the display. Exit Status=%r\n", Status));
+
LcdShutdown ();
EXIT:
@@ -157,40 +162,44 @@ LcdGraphicsOutputDxeInitialize (
LCD_INSTANCE* Instance;
Status = LcdIdentify ();
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
Status = LcdInstanceContructor (&Instance);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
// Install the Graphics Output Protocol and the Device Path
- Status = gBS->InstallMultipleProtocolInterfaces(
- &Instance->Handle,
- &gEfiGraphicsOutputProtocolGuid, &Instance->Gop,
- &gEfiDevicePathProtocolGuid, &Instance->DevicePath,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Instance->Handle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Instance->Gop,
+ &gEfiDevicePathProtocolGuid,
+ &Instance->DevicePath,
+ NULL
+ );
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));
goto EXIT;
}
// Register for an ExitBootServicesEvent
- // When ExitBootServices starts, this function here will make sure that the graphics driver will shut down properly,
- // i.e. it will free up all allocated memory and perform any necessary hardware re-configuration.
+ // When ExitBootServices starts, this function will make sure that the
+ // graphics driver shuts down properly, i.e. it will free up all
+ // allocated memory and perform any necessary hardware re-configuration.
Status = gBS->CreateEvent (
- EVT_SIGNAL_EXIT_BOOT_SERVICES,
- TPL_NOTIFY,
- LcdGraphicsExitBootServicesEvent, NULL,
- &Instance->ExitBootServicesEvent
- );
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_NOTIFY,
+ LcdGraphicsExitBootServicesEvent,
+ NULL,
+ &Instance->ExitBootServicesEvent
+ );
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));
goto EXIT_ERROR_UNINSTALL_PROTOCOL;
}
@@ -198,48 +207,46 @@ LcdGraphicsOutputDxeInitialize (
goto EXIT;
EXIT_ERROR_UNINSTALL_PROTOCOL:
- /* The following function could return an error message,
- * however, to get here something must have gone wrong already,
- * so preserve the original error, i.e. don't change
- * the Status variable, even it fails to uninstall the protocol.
- */
+ // The following function could return an error message,
+ // however, to get here something must have gone wrong already,
+ // so preserve the original error, i.e. don't change
+ // the Status variable, even it fails to uninstall the protocol.
gBS->UninstallMultipleProtocolInterfaces (
- Instance->Handle,
- &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, // Uninstall Graphics Output protocol
- &gEfiDevicePathProtocolGuid, &Instance->DevicePath, // Uninstall device path
- NULL
- );
+ Instance->Handle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Instance->Gop, // Uninstall Graphics Output protocol
+ &gEfiDevicePathProtocolGuid,
+ &Instance->DevicePath, // Uninstall device path
+ NULL
+ );
EXIT:
return Status;
-
}
-/***************************************
- * This function should be called
- * on Event: ExitBootServices
- * to free up memory, stop the driver
- * and uninstall the protocols
- ***************************************/
+/** This function should be called
+ on Event: ExitBootServices
+ to free up memory, stop the driver
+ and uninstall the protocols
+**/
VOID
LcdGraphicsExitBootServicesEvent (
IN EFI_EVENT Event,
IN VOID *Context
)
{
- // By default, this PCD is FALSE. But if a platform starts a predefined OS that
- // does not use a framebuffer then we might want to disable the display controller
- // to avoid to display corrupted information on the screen.
+ // By default, this PCD is FALSE. But if a platform starts a predefined OS
+ // that does not use a framebuffer then we might want to disable the display
+ // controller to avoid to display corrupted information on the screen.
if (FeaturePcdGet (PcdGopDisableOnExitBootServices)) {
// Turn-off the Display controller
LcdShutdown ();
}
}
-/***************************************
- * GraphicsOutput Protocol function, mapping to
- * EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode
- ***************************************/
+/** GraphicsOutput Protocol function, mapping to
+ EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode
+**/
EFI_STATUS
EFIAPI
LcdGraphicsQueryMode (
@@ -252,19 +259,22 @@ LcdGraphicsQueryMode (
EFI_STATUS Status = EFI_SUCCESS;
LCD_INSTANCE *Instance;
- Instance = LCD_INSTANCE_FROM_GOP_THIS(This);
+ Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
// Setup the hardware if not already done
- if( !mDisplayInitialized ) {
- Status = InitializeDisplay(Instance);
- if (EFI_ERROR(Status)) {
+ if (!mDisplayInitialized) {
+ Status = InitializeDisplay (Instance);
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
}
// Error checking
- if ( (This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode) ) {
- DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber ));
+ if ((This == NULL) ||
+ (Info == NULL) ||
+ (SizeOfInfo == NULL) ||
+ (ModeNumber >= This->Mode->MaxMode)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber));
Status = EFI_INVALID_PARAMETER;
goto EXIT;
}
@@ -275,21 +285,20 @@ LcdGraphicsQueryMode (
goto EXIT;
}
- *SizeOfInfo = sizeof( EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- Status = LcdPlatformQueryMode (ModeNumber,*Info);
- if (EFI_ERROR(Status)) {
- FreePool(*Info);
+ Status = LcdPlatformQueryMode (ModeNumber, *Info);
+ if (EFI_ERROR (Status)) {
+ FreePool (*Info);
}
EXIT:
return Status;
}
-/***************************************
- * GraphicsOutput Protocol function, mapping to
- * EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode
- ***************************************/
+/** GraphicsOutput Protocol function, mapping to
+ EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode
+**/
EFI_STATUS
EFIAPI
LcdGraphicsSetMode (
@@ -305,47 +314,48 @@ LcdGraphicsSetMode (
Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
// Setup the hardware if not already done
- if(!mDisplayInitialized) {
+ if (!mDisplayInitialized) {
Status = InitializeDisplay (Instance);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
}
// Check if this mode is supported
- if( ModeNumber >= This->Mode->MaxMode ) {
- DEBUG((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode number %d .\n", ModeNumber ));
+ if (ModeNumber >= This->Mode->MaxMode) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode number %d .\n", ModeNumber));
Status = EFI_UNSUPPORTED;
goto EXIT;
}
// Set the oscillator frequency to support the new mode
Status = LcdPlatformSetMode (ModeNumber);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto EXIT;
}
// Update the UEFI mode information
This->Mode->Mode = ModeNumber;
- LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);
- Status = LcdPlatformGetBpp(ModeNumber, &Bpp);
- if (EFI_ERROR(Status)) {
+ LcdPlatformQueryMode (ModeNumber, &Instance->ModeInfo);
+ Status = LcdPlatformGetBpp (ModeNumber, &Bpp);
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));
goto EXIT;
}
This->Mode->FrameBufferSize = Instance->ModeInfo.VerticalResolution
- * Instance->ModeInfo.PixelsPerScanLine
- * GetBytesPerPixel(Bpp);
+ * Instance->ModeInfo.PixelsPerScanLine
+ * GetBytesPerPixel (Bpp);
// Set the hardware to the new mode
Status = LcdSetMode (ModeNumber);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto EXIT;
}
- // The UEFI spec requires that we now clear the visible portions of the output display to black.
+ // The UEFI spec requires that we now clear the visible portions of the
+ // output display to black.
// Set the fill colour to black
SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
@@ -361,7 +371,8 @@ LcdGraphicsSetMode (
0,
This->Mode->Info->HorizontalResolution,
This->Mode->Info->VerticalResolution,
- 0);
+ 0
+ );
EXIT:
return Status;
@@ -372,7 +383,7 @@ GetBytesPerPixel (
IN LCD_BPP Bpp
)
{
- switch(Bpp) {
+ switch (Bpp) {
case LCD_BITS_PER_PIXEL_24:
return 4;
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
index b66efd34561f655b74a5ecfad8a97281cdd5929d..16d92f45c47948630d6262a63fd1af4e076706d1 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2018, 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
@@ -11,9 +11,8 @@
**/
-#ifndef __ARM_VE_GRAPHICS_DXE_H__
-#define __ARM_VE_GRAPHICS_DXE_H__
-
+#ifndef LCD_GRAPHICS_OUTPUT_DXE_H_
+#define LCD_GRAPHICS_OUTPUT_DXE_H_
#include <Base.h>
@@ -25,7 +24,6 @@
#include <Protocol/DevicePath.h>
-
//
// Device structures
//
@@ -106,4 +104,4 @@ InitializeDisplay (
IN LCD_INSTANCE* Instance
);
-#endif /* __ARM_VE_GRAPHICS_DXE_H__ */
+#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index b9bdf471e2d65dba7a0fcb0f7ecc352bd576b46b..3d13e417972c67cc51ae4410efd548053511e5d1 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2018, 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
@@ -11,8 +11,8 @@
**/
-#ifndef __LCDPLATFORMLIB_H
-#define __LCDPLATFORMLIB_H
+#ifndef LCD_PLATFORM_LIB_H_
+#define LCD_PLATFORM_LIB_H_
#include <Protocol/GraphicsOutput.h>
@@ -158,8 +158,9 @@
#define LCD_12BPP_444_BLUE_MASK 0x0000000F
#define LCD_12BPP_444_RESERVED_MASK 0x0000F000
-
-// The enumeration indexes maps the PL111 LcdBpp values used in the LCD Control Register
+/** The enumeration indexes maps the PL111 LcdBpp values used in the LCD Control
+ Register
+**/
typedef enum {
LCD_BITS_PER_PIXEL_1 = 0,
LCD_BITS_PER_PIXEL_2,
@@ -171,7 +172,6 @@ typedef enum {
LCD_BITS_PER_PIXEL_12_444
} LCD_BPP;
-
EFI_STATUS
LcdPlatformInitializeDisplay (
IN EFI_HANDLE Handle
@@ -218,4 +218,4 @@ LcdPlatformGetBpp (
OUT LCD_BPP* Bpp
);
-#endif
+#endif /* LCD_PLATFORM_LIB_H_ */
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index 24efb68f23e3393a96fc760732d978b6346a2807..2cd1be9d255dd5734176d752d60f06f11a047fcb 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -1,6 +1,6 @@
-/** @file Lcd.c
+/** @file
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2018, 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
@@ -21,12 +21,9 @@
#include "HdLcd.h"
-/**********************************************************************
- *
- * This file contains all the bits of the Lcd that are
- * platform independent.
- *
- **********************************************************************/
+/** This file contains all the bits of the Lcd that are
+ platform independent.
+**/
STATIC
UINTN
@@ -34,7 +31,7 @@ GetBytesPerPixel (
IN LCD_BPP Bpp
)
{
- switch(Bpp) {
+ switch (Bpp) {
case LCD_BITS_PER_PIXEL_24:
return 4;
@@ -60,21 +57,27 @@ LcdInitialize (
)
{
// Disable the controller
- MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
// Disable all interrupts
- MmioWrite32(HDLCD_REG_INT_MASK, 0);
+ MmioWrite32 (HDLCD_REG_INT_MASK, 0);
// Define start of the VRAM. This never changes for any graphics mode
- MmioWrite32(HDLCD_REG_FB_BASE, (UINT32) VramBaseAddress);
+ MmioWrite32 (HDLCD_REG_FB_BASE, (UINT32)VramBaseAddress);
// Setup various registers that never change
- MmioWrite32(HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
- MmioWrite32(HDLCD_REG_POLARITIES, HDLCD_PXCLK_LOW | HDLCD_DATA_HIGH | HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW | HDLCD_VSYNC_HIGH);
- MmioWrite32(HDLCD_REG_PIXEL_FORMAT, HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL);
- MmioWrite32(HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));
- MmioWrite32(HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));
- MmioWrite32(HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));
+ MmioWrite32 (HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
+
+ MmioWrite32 (HDLCD_REG_POLARITIES, HDLCD_DEFAULT_POLARITIES);
+
+ MmioWrite32 (
+ HDLCD_REG_PIXEL_FORMAT,
+ HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL
+ );
+
+ MmioWrite32 (HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));
+ MmioWrite32 (HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));
+ MmioWrite32 (HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));
return EFI_SUCCESS;
}
@@ -96,46 +99,53 @@ LcdSetMode (
UINT32 BytesPerPixel;
LCD_BPP LcdBpp;
-
// Set the video mode timings and other relevant information
- Status = LcdPlatformGetTimings (ModeNumber,
- &HRes,&HSync,&HBackPorch,&HFrontPorch,
- &VRes,&VSync,&VBackPorch,&VFrontPorch);
+ Status = LcdPlatformGetTimings (
+ ModeNumber,
+ &HRes,
+ &HSync,
+ &HBackPorch,
+ &HFrontPorch,
+ &VRes,
+ &VSync,
+ &VBackPorch,
+ &VFrontPorch
+ );
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
+ Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- BytesPerPixel = GetBytesPerPixel(LcdBpp);
+ BytesPerPixel = GetBytesPerPixel (LcdBpp);
// Disable the controller
- MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
// Update the frame buffer information with the new settings
- MmioWrite32(HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
- MmioWrite32(HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
- MmioWrite32(HDLCD_REG_FB_LINE_COUNT, VRes - 1);
+ MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
+ MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
+ MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
// Set the vertical timing information
- MmioWrite32(HDLCD_REG_V_SYNC, VSync);
- MmioWrite32(HDLCD_REG_V_BACK_PORCH, VBackPorch);
- MmioWrite32(HDLCD_REG_V_DATA, VRes - 1);
- MmioWrite32(HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
+ MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
+ MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
+ MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
+ MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
// Set the horizontal timing information
- MmioWrite32(HDLCD_REG_H_SYNC, HSync);
- MmioWrite32(HDLCD_REG_H_BACK_PORCH, HBackPorch);
- MmioWrite32(HDLCD_REG_H_DATA, HRes - 1);
- MmioWrite32(HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
+ MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
+ MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
+ MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
+ MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
// Enable the controller
- MmioWrite32(HDLCD_REG_COMMAND, HDLCD_ENABLE);
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
return EFI_SUCCESS;
}
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.h b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
index 6df97a9dfee60e9fda615cf3bea1b6a164a42333..cd2c0366c7b563d7fb313f82abeef7eb1aa3ef72 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.h
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
@@ -1,6 +1,6 @@
-/** @file HDLcd.h
+/** @file
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2018, 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
@@ -12,13 +12,10 @@
**/
-#ifndef _HDLCD_H_
-#define _HDLCD_H_
+#ifndef HDLCD_H_
+#define HDLCD_H_
-//
// HDLCD Controller Register Offsets
-//
-
#define HDLCD_REG_VERSION ((UINTN)PcdGet32 (PcdArmHdLcdBase) + 0x000)
#define HDLCD_REG_INT_RAWSTAT ((UINTN)PcdGet32 (PcdArmHdLcdBase) + 0x010)
#define HDLCD_REG_INT_CLEAR ((UINTN)PcdGet32 (PcdArmHdLcdBase) + 0x014)
@@ -44,10 +41,7 @@
#define HDLCD_REG_GREEN_SELECT ((UINTN)PcdGet32 (PcdArmHdLcdBase) + 0x248)
#define HDLCD_REG_BLUE_SELECT ((UINTN)PcdGet32 (PcdArmHdLcdBase) + 0x24C)
-
-//
// HDLCD Values of registers
-//
// HDLCD Interrupt mask, clear and status register
#define HDLCD_DMA_END BIT0 /* DMA has finished reading a frame */
@@ -79,6 +73,11 @@
#define HDLCD_DATA_LOW 0
#define HDLCD_PXCLK_LOW 0
+// Default polarities
+#define HDLCD_DEFAULT_POLARITIES (HDLCD_PXCLK_LOW | HDLCD_DATA_HIGH | \
+ HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW | \
+ HDLCD_VSYNC_HIGH)
+
// Pixel Format
#define HDLCD_LITTLE_ENDIAN (0 << 31)
#define HDLCD_BIG_ENDIAN (1 << 31)
@@ -86,4 +85,4 @@
// Number of bytes per pixel
#define HDLCD_4BYTES_PER_PIXEL ((4 - 1) << 3)
-#endif /* _HDLCD_H_ */
+#endif /* HDLCD_H_ */
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index 9b4a02045ab7ca170e0d4362ee0e2bcf1d275bdb..3f3f7019f1d252995eab6d8c3d49db8be8e09e40 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -1,6 +1,6 @@
-/** @file PL111Lcd.c
+/** @file
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2018, 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
@@ -19,13 +19,10 @@
#include "PL111Lcd.h"
-/**********************************************************************
- *
- * This file contains all the bits of the PL111 that are
- * platform independent.
- *
- **********************************************************************/
+/** This file contains all the bits of the PL111 that are
+ platform independent.
+**/
EFI_STATUS
LcdIdentify (
VOID
@@ -54,11 +51,11 @@ LcdInitialize (
)
{
// Define start of the VRAM. This never changes for any graphics mode
- MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);
- MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
+ MmioWrite32 (PL111_REG_LCD_UP_BASE, (UINT32)VramBaseAddress);
+ MmioWrite32 (PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
// Disable all interrupts from the PL111
- MmioWrite32(PL111_REG_LCD_IMSC, 0);
+ MmioWrite32 (PL111_REG_LCD_IMSC, 0);
return EFI_SUCCESS;
}
@@ -81,37 +78,54 @@ LcdSetMode (
LCD_BPP LcdBpp;
// Set the video mode timings and other relevant information
- Status = LcdPlatformGetTimings (ModeNumber,
- &HRes,&HSync,&HBackPorch,&HFrontPorch,
- &VRes,&VSync,&VBackPorch,&VFrontPorch);
+ Status = LcdPlatformGetTimings (
+ ModeNumber,
+ &HRes,
+ &HSync,
+ &HBackPorch,
+ &HFrontPorch,
+ &VRes,
+ &VSync,
+ &VBackPorch,
+ &VFrontPorch
+ );
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
+ Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
// Disable the CLCD_LcdEn bit
- LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);
- MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);
+ LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
+ MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
// Set Timings
- MmioWrite32 (PL111_REG_LCD_TIMING_0, HOR_AXIS_PANEL(HBackPorch, HFrontPorch, HSync, HRes));
- MmioWrite32 (PL111_REG_LCD_TIMING_1, VER_AXIS_PANEL(VBackPorch, VFrontPorch, VSync, VRes));
- MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY(HRes));
+ MmioWrite32 (
+ PL111_REG_LCD_TIMING_0,
+ HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
+ );
+
+ MmioWrite32 (
+ PL111_REG_LCD_TIMING_1,
+ VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
+ );
+
+ MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
// PL111_REG_LCD_CONTROL
- LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
- MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
+ LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
+ PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
+ MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
// Turn on power to the LCD Panel
LcdControl |= PL111_CTRL_LCD_PWR;
- MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
+ MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
return EFI_SUCCESS;
}
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard
2018-03-20 16:11 ` [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding
> standard
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> There is no functional modification in this change As preparation for further
> work, the formatting is corrected to meet the EDKII coding standard.
> Of specific note, some invalid include guards were fixed.
>
> 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>
> ---
>
> Notes:
> v3:
> - Minor coding style changes [Ard]
>
> Done [Girish]
>
> - Changing one style to the other is just pointless churn [Ard]
>
> Fixing the include guards: is a small improvement.
> (Ideally patchcheck should reject these.)
> Reducing lines to 80 columns: makes Leif (at least)
> happy, and aligns with formatter behaviour. Correcting
> Doxygen format comments: prevents Doxygen generating
> gibberish. Spaces before '(': Maintains consistency,
> and aligns with desired formatter behaviour. [Evan]
>
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> | 187 +++++++++++---------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h |
> 10 +-
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 14 +-
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 88 +++++----
> ArmPlatformPkg/Library/HdLcd/HdLcd.h | 21 ++-
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 64 ++++---
> 6 files changed, 208 insertions(+), 176 deletions(-)
>
> diff --git
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> index
> b721061fc1df5695092e8c71da97ae0b9af46b3f..905eb26ee01b5037dfbaf3
> c054a62593837c8b5f 100644
> ---
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> +++
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> @@ -1,6 +1,6 @@
> /** @file
>
> - Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2018, 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 @@ -9,7 +9,7 @@
> 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/BaseMemoryLib.h>
> @@ -22,12 +22,10 @@
>
> #include "LcdGraphicsOutputDxe.h"
>
> -
> /**********************************************************
> ************
> - *
> - * This file implements the Graphics Output protocol on
> ArmVersatileExpress
> - * using the Lcd controller
> - *
> -
> **********************************************************
> ************/
> +/** This file implements the Graphics Output protocol on
> +ArmVersatileExpress
> + using the Lcd controller
> +
> +**/
>
> //
> // Global variables
> @@ -64,7 +62,10 @@ LCD_INSTANCE mLcdTemplate = {
> {
> {
> HARDWARE_DEVICE_PATH, HW_VENDOR_DP,
> - { (UINT8) (sizeof(VENDOR_DEVICE_PATH)), (UINT8)
> ((sizeof(VENDOR_DEVICE_PATH)) >> 8) },
> + {
> + (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
> + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> + },
> },
> // Hardware Device Path for Lcd
> EFI_CALLER_ID_GUID // Use the driver's GUID @@ -73,10 +74,13 @@
> LCD_INSTANCE mLcdTemplate = {
> {
> END_DEVICE_PATH_TYPE,
> END_ENTIRE_DEVICE_PATH_SUBTYPE,
> - { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 }
> + {
> + sizeof (EFI_DEVICE_PATH_PROTOCOL),
> + 0
> + }
> }
> },
> - (EFI_EVENT) NULL // ExitBootServicesEvent
> + (EFI_EVENT)NULL // ExitBootServicesEvent
> };
>
> EFI_STATUS
> @@ -86,7 +90,7 @@ LcdInstanceContructor ( {
> LCD_INSTANCE* Instance;
>
> - Instance = AllocateCopyPool (sizeof(LCD_INSTANCE), &mLcdTemplate);
> + Instance = AllocateCopyPool (sizeof (LCD_INSTANCE), &mLcdTemplate);
> if (Instance == NULL) {
> return EFI_OUT_OF_RESOURCES;
> }
> @@ -113,23 +117,23 @@ InitializeDisplay (
> UINTN VramSize;
>
> Status = LcdPlatformGetVram (&VramBaseAddress, &VramSize);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> return Status;
> }
>
> // Setup the LCD
> Status = LcdInitialize (VramBaseAddress);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT_ERROR_LCD_SHUTDOWN;
> }
>
> Status = LcdPlatformInitializeDisplay (Instance->Handle);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT_ERROR_LCD_SHUTDOWN;
> }
>
> // Setup all the relevant mode information
> - Instance->Gop.Mode->SizeOfInfo =
> sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
> + Instance->Gop.Mode->SizeOfInfo = sizeof
> (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
> Instance->Gop.Mode->FrameBufferBase = VramBaseAddress;
>
> // Set the flag before changing the mode, to avoid infinite loops @@ -
> 139,7 +143,8 @@ InitializeDisplay (
> goto EXIT;
>
> EXIT_ERROR_LCD_SHUTDOWN:
> - DEBUG((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the
> display. Exit Status=%r\n", Status));
> + DEBUG ((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise
> + the display. Exit Status=%r\n", Status));
> +
> LcdShutdown ();
>
> EXIT:
> @@ -157,40 +162,44 @@ LcdGraphicsOutputDxeInitialize (
> LCD_INSTANCE* Instance;
>
> Status = LcdIdentify ();
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
>
> Status = LcdInstanceContructor (&Instance);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
>
> // Install the Graphics Output Protocol and the Device Path
> - Status = gBS->InstallMultipleProtocolInterfaces(
> - &Instance->Handle,
> - &gEfiGraphicsOutputProtocolGuid, &Instance->Gop,
> - &gEfiDevicePathProtocolGuid, &Instance->DevicePath,
> - NULL
> - );
> + Status = gBS->InstallMultipleProtocolInterfaces (
> + &Instance->Handle,
> + &gEfiGraphicsOutputProtocolGuid,
> + &Instance->Gop,
> + &gEfiDevicePathProtocolGuid,
> + &Instance->DevicePath,
> + NULL
> + );
>
> - if (EFI_ERROR(Status)) {
> - DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the
> protocol. Exit Status=%r\n", Status));
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not
> + install the protocol. Exit Status=%r\n", Status));
> goto EXIT;
> }
>
> // Register for an ExitBootServicesEvent
> - // When ExitBootServices starts, this function here will make sure that the
> graphics driver will shut down properly,
> - // i.e. it will free up all allocated memory and perform any necessary
> hardware re-configuration.
> + // When ExitBootServices starts, this function will make sure that
> + the // graphics driver shuts down properly, i.e. it will free up all
> + // allocated memory and perform any necessary hardware re-
> configuration.
> Status = gBS->CreateEvent (
> - EVT_SIGNAL_EXIT_BOOT_SERVICES,
> - TPL_NOTIFY,
> - LcdGraphicsExitBootServicesEvent, NULL,
> - &Instance->ExitBootServicesEvent
> - );
> + EVT_SIGNAL_EXIT_BOOT_SERVICES,
> + TPL_NOTIFY,
> + LcdGraphicsExitBootServicesEvent,
> + NULL,
> + &Instance->ExitBootServicesEvent
> + );
>
> - if (EFI_ERROR(Status)) {
> - DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the
> ExitBootServicesEvent handler. Exit Status=%r\n", Status));
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not
> + install the ExitBootServicesEvent handler. Exit Status=%r\n",
> + Status));
> goto EXIT_ERROR_UNINSTALL_PROTOCOL;
> }
>
> @@ -198,48 +207,46 @@ LcdGraphicsOutputDxeInitialize (
> goto EXIT;
>
> EXIT_ERROR_UNINSTALL_PROTOCOL:
> - /* The following function could return an error message,
> - * however, to get here something must have gone wrong already,
> - * so preserve the original error, i.e. don't change
> - * the Status variable, even it fails to uninstall the protocol.
> - */
> + // The following function could return an error message, // however,
> + to get here something must have gone wrong already, // so preserve
> + the original error, i.e. don't change // the Status variable, even it
> + fails to uninstall the protocol.
> gBS->UninstallMultipleProtocolInterfaces (
> - Instance->Handle,
> - &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, // Uninstall
> Graphics Output protocol
> - &gEfiDevicePathProtocolGuid, &Instance->DevicePath, // Uninstall
> device path
> - NULL
> - );
> + Instance->Handle,
> + &gEfiGraphicsOutputProtocolGuid,
> + &Instance->Gop, // Uninstall Graphics Output protocol
> + &gEfiDevicePathProtocolGuid,
> + &Instance->DevicePath, // Uninstall device path
> + NULL
> + );
>
> EXIT:
> return Status;
> -
> }
>
> -/***************************************
> - * This function should be called
> - * on Event: ExitBootServices
> - * to free up memory, stop the driver
> - * and uninstall the protocols
> - ***************************************/
> +/** This function should be called
> + on Event: ExitBootServices
> + to free up memory, stop the driver
> + and uninstall the protocols
> +**/
> VOID
> LcdGraphicsExitBootServicesEvent (
> IN EFI_EVENT Event,
> IN VOID *Context
> )
> {
> - // By default, this PCD is FALSE. But if a platform starts a predefined OS
> that
> - // does not use a framebuffer then we might want to disable the display
> controller
> - // to avoid to display corrupted information on the screen.
> + // By default, this PCD is FALSE. But if a platform starts a
> + predefined OS // that does not use a framebuffer then we might want
> + to disable the display // controller to avoid to display corrupted
> information on the screen.
> if (FeaturePcdGet (PcdGopDisableOnExitBootServices)) {
> // Turn-off the Display controller
> LcdShutdown ();
> }
> }
>
> -/***************************************
> - * GraphicsOutput Protocol function, mapping to
> - * EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode
> - ***************************************/
> +/** GraphicsOutput Protocol function, mapping to
> + EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode
> +**/
> EFI_STATUS
> EFIAPI
> LcdGraphicsQueryMode (
> @@ -252,19 +259,22 @@ LcdGraphicsQueryMode (
> EFI_STATUS Status = EFI_SUCCESS;
> LCD_INSTANCE *Instance;
>
> - Instance = LCD_INSTANCE_FROM_GOP_THIS(This);
> + Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
>
> // Setup the hardware if not already done
> - if( !mDisplayInitialized ) {
> - Status = InitializeDisplay(Instance);
> - if (EFI_ERROR(Status)) {
> + if (!mDisplayInitialized) {
> + Status = InitializeDisplay (Instance);
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
> }
>
> // Error checking
> - if ( (This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) ||
> (ModeNumber >= This->Mode->MaxMode) ) {
> - DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode
> number %d : Invalid Parameter.\n", ModeNumber ));
> + if ((This == NULL) ||
> + (Info == NULL) ||
> + (SizeOfInfo == NULL) ||
> + (ModeNumber >= This->Mode->MaxMode)) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode
> number
> + %d : Invalid Parameter.\n", ModeNumber));
> Status = EFI_INVALID_PARAMETER;
> goto EXIT;
> }
> @@ -275,21 +285,20 @@ LcdGraphicsQueryMode (
> goto EXIT;
> }
>
> - *SizeOfInfo = sizeof( EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
> + *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
>
> - Status = LcdPlatformQueryMode (ModeNumber,*Info);
> - if (EFI_ERROR(Status)) {
> - FreePool(*Info);
> + Status = LcdPlatformQueryMode (ModeNumber, *Info); if (EFI_ERROR
> + (Status)) {
> + FreePool (*Info);
> }
>
> EXIT:
> return Status;
> }
>
> -/***************************************
> - * GraphicsOutput Protocol function, mapping to
> - * EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode
> - ***************************************/
> +/** GraphicsOutput Protocol function, mapping to
> + EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode
> +**/
> EFI_STATUS
> EFIAPI
> LcdGraphicsSetMode (
> @@ -305,47 +314,48 @@ LcdGraphicsSetMode (
> Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
>
> // Setup the hardware if not already done
> - if(!mDisplayInitialized) {
> + if (!mDisplayInitialized) {
> Status = InitializeDisplay (Instance);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
> }
>
> // Check if this mode is supported
> - if( ModeNumber >= This->Mode->MaxMode ) {
> - DEBUG((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported
> mode number %d .\n", ModeNumber ));
> + if (ModeNumber >= This->Mode->MaxMode) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported
> mode
> + number %d .\n", ModeNumber));
> Status = EFI_UNSUPPORTED;
> goto EXIT;
> }
>
> // Set the oscillator frequency to support the new mode
> Status = LcdPlatformSetMode (ModeNumber);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> Status = EFI_DEVICE_ERROR;
> goto EXIT;
> }
>
> // Update the UEFI mode information
> This->Mode->Mode = ModeNumber;
> - LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);
> - Status = LcdPlatformGetBpp(ModeNumber, &Bpp);
> - if (EFI_ERROR(Status)) {
> + LcdPlatformQueryMode (ModeNumber, &Instance->ModeInfo); Status =
> + LcdPlatformGetBpp (ModeNumber, &Bpp); if (EFI_ERROR (Status)) {
> DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get
> bytes per pixel, status: %r\n", Status));
> goto EXIT;
> }
> This->Mode->FrameBufferSize = Instance->ModeInfo.VerticalResolution
> - * Instance->ModeInfo.PixelsPerScanLine
> - * GetBytesPerPixel(Bpp);
> + * Instance->ModeInfo.PixelsPerScanLine
> + * GetBytesPerPixel (Bpp);
>
> // Set the hardware to the new mode
> Status = LcdSetMode (ModeNumber);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> Status = EFI_DEVICE_ERROR;
> goto EXIT;
> }
>
> - // The UEFI spec requires that we now clear the visible portions of the
> output display to black.
> + // The UEFI spec requires that we now clear the visible portions of
> + the // output display to black.
>
> // Set the fill colour to black
> SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
> @@ -361,7 +371,8 @@ LcdGraphicsSetMode (
> 0,
> This->Mode->Info->HorizontalResolution,
> This->Mode->Info->VerticalResolution,
> - 0);
> + 0
> + );
>
> EXIT:
> return Status;
> @@ -372,7 +383,7 @@ GetBytesPerPixel (
> IN LCD_BPP Bpp
> )
> {
> - switch(Bpp) {
> + switch (Bpp) {
> case LCD_BITS_PER_PIXEL_24:
> return 4;
>
> diff --git
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> h
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> h
> index
> b66efd34561f655b74a5ecfad8a97281cdd5929d..16d92f45c47948630d62
> 62a63fd1af4e076706d1 100644
> ---
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> h
> +++
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> h
> @@ -1,6 +1,6 @@
> /** @file
>
> - Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2018, 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 @@ -11,9 +11,8 @@
>
> **/
>
> -#ifndef __ARM_VE_GRAPHICS_DXE_H__
> -#define __ARM_VE_GRAPHICS_DXE_H__
> -
> +#ifndef LCD_GRAPHICS_OUTPUT_DXE_H_
> +#define LCD_GRAPHICS_OUTPUT_DXE_H_
>
> #include <Base.h>
>
> @@ -25,7 +24,6 @@
>
> #include <Protocol/DevicePath.h>
>
> -
> //
> // Device structures
> //
> @@ -106,4 +104,4 @@ InitializeDisplay (
> IN LCD_INSTANCE* Instance
> );
>
> -#endif /* __ARM_VE_GRAPHICS_DXE_H__ */
> +#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index
> b9bdf471e2d65dba7a0fcb0f7ecc352bd576b46b..3d13e417972c67cc51ae4
> 410efd548053511e5d1 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -1,6 +1,6 @@
> /** @file
>
> - Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2018, 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 @@ -11,8 +11,8 @@
>
> **/
>
> -#ifndef __LCDPLATFORMLIB_H
> -#define __LCDPLATFORMLIB_H
> +#ifndef LCD_PLATFORM_LIB_H_
> +#define LCD_PLATFORM_LIB_H_
>
> #include <Protocol/GraphicsOutput.h>
>
> @@ -158,8 +158,9 @@
> #define LCD_12BPP_444_BLUE_MASK 0x0000000F
> #define LCD_12BPP_444_RESERVED_MASK 0x0000F000
>
> -
> -// The enumeration indexes maps the PL111 LcdBpp values used in the LCD
> Control Register
> +/** The enumeration indexes maps the PL111 LcdBpp values used in the
> +LCD Control
> + Register
> +**/
> typedef enum {
> LCD_BITS_PER_PIXEL_1 = 0,
> LCD_BITS_PER_PIXEL_2,
> @@ -171,7 +172,6 @@ typedef enum {
> LCD_BITS_PER_PIXEL_12_444
> } LCD_BPP;
>
> -
> EFI_STATUS
> LcdPlatformInitializeDisplay (
> IN EFI_HANDLE Handle
> @@ -218,4 +218,4 @@ LcdPlatformGetBpp (
> OUT LCD_BPP* Bpp
> );
>
> -#endif
> +#endif /* LCD_PLATFORM_LIB_H_ */
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> 24efb68f23e3393a96fc760732d978b6346a2807..2cd1be9d255dd5734176
> d752d60f06f11a047fcb 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -1,6 +1,6 @@
> -/** @file Lcd.c
> +/** @file
>
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2018, 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 @@ -21,12 +21,9 @@
>
> #include "HdLcd.h"
>
> -
> /**********************************************************
> ************
> - *
> - * This file contains all the bits of the Lcd that are
> - * platform independent.
> - *
> -
> **********************************************************
> ************/
> +/** This file contains all the bits of the Lcd that are
> + platform independent.
> +**/
>
> STATIC
> UINTN
> @@ -34,7 +31,7 @@ GetBytesPerPixel (
> IN LCD_BPP Bpp
> )
> {
> - switch(Bpp) {
> + switch (Bpp) {
> case LCD_BITS_PER_PIXEL_24:
> return 4;
>
> @@ -60,21 +57,27 @@ LcdInitialize (
> )
> {
> // Disable the controller
> - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
> + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>
> // Disable all interrupts
> - MmioWrite32(HDLCD_REG_INT_MASK, 0);
> + MmioWrite32 (HDLCD_REG_INT_MASK, 0);
>
> // Define start of the VRAM. This never changes for any graphics mode
> - MmioWrite32(HDLCD_REG_FB_BASE, (UINT32) VramBaseAddress);
> + MmioWrite32 (HDLCD_REG_FB_BASE, (UINT32)VramBaseAddress);
>
> // Setup various registers that never change
> - MmioWrite32(HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
> - MmioWrite32(HDLCD_REG_POLARITIES, HDLCD_PXCLK_LOW |
> HDLCD_DATA_HIGH | HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW |
> HDLCD_VSYNC_HIGH);
> - MmioWrite32(HDLCD_REG_PIXEL_FORMAT, HDLCD_LITTLE_ENDIAN |
> HDLCD_4BYTES_PER_PIXEL);
> - MmioWrite32(HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));
> - MmioWrite32(HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));
> - MmioWrite32(HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));
> + MmioWrite32 (HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
> +
> + MmioWrite32 (HDLCD_REG_POLARITIES, HDLCD_DEFAULT_POLARITIES);
> +
> + MmioWrite32 (
> + HDLCD_REG_PIXEL_FORMAT,
> + HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL
> + );
> +
> + MmioWrite32 (HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));
> + MmioWrite32 (HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));
> + MmioWrite32 (HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));
>
> return EFI_SUCCESS;
> }
> @@ -96,46 +99,53 @@ LcdSetMode (
> UINT32 BytesPerPixel;
> LCD_BPP LcdBpp;
>
> -
> // Set the video mode timings and other relevant information
> - Status = LcdPlatformGetTimings (ModeNumber,
> - &HRes,&HSync,&HBackPorch,&HFrontPorch,
> - &VRes,&VSync,&VBackPorch,&VFrontPorch);
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &HRes,
> + &HSync,
> + &HBackPorch,
> + &HFrontPorch,
> + &VRes,
> + &VSync,
> + &VBackPorch,
> + &VFrontPorch
> + );
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> - Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
> + Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> - BytesPerPixel = GetBytesPerPixel(LcdBpp);
> + BytesPerPixel = GetBytesPerPixel (LcdBpp);
>
> // Disable the controller
> - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
> + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>
> // Update the frame buffer information with the new settings
> - MmioWrite32(HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
> - MmioWrite32(HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
> - MmioWrite32(HDLCD_REG_FB_LINE_COUNT, VRes - 1);
> + MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
> + MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
> + MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
>
> // Set the vertical timing information
> - MmioWrite32(HDLCD_REG_V_SYNC, VSync);
> - MmioWrite32(HDLCD_REG_V_BACK_PORCH, VBackPorch);
> - MmioWrite32(HDLCD_REG_V_DATA, VRes - 1);
> - MmioWrite32(HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
> + MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
> + MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
> + MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
> + MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
>
> // Set the horizontal timing information
> - MmioWrite32(HDLCD_REG_H_SYNC, HSync);
> - MmioWrite32(HDLCD_REG_H_BACK_PORCH, HBackPorch);
> - MmioWrite32(HDLCD_REG_H_DATA, HRes - 1);
> - MmioWrite32(HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
> + MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
> + MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
> + MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
> + MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
>
> // Enable the controller
> - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_ENABLE);
> + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> index
> 6df97a9dfee60e9fda615cf3bea1b6a164a42333..cd2c0366c7b563d7fb313f
> 82abeef7eb1aa3ef72 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> @@ -1,6 +1,6 @@
> -/** @file HDLcd.h
> +/** @file
>
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2018, 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 @@ -12,13 +12,10 @@
>
> **/
>
> -#ifndef _HDLCD_H_
> -#define _HDLCD_H_
> +#ifndef HDLCD_H_
> +#define HDLCD_H_
>
> -//
> // HDLCD Controller Register Offsets
> -//
> -
> #define HDLCD_REG_VERSION ((UINTN)PcdGet32
> (PcdArmHdLcdBase) + 0x000)
> #define HDLCD_REG_INT_RAWSTAT ((UINTN)PcdGet32
> (PcdArmHdLcdBase) + 0x010)
> #define HDLCD_REG_INT_CLEAR ((UINTN)PcdGet32
> (PcdArmHdLcdBase) + 0x014)
> @@ -44,10 +41,7 @@
> #define HDLCD_REG_GREEN_SELECT ((UINTN)PcdGet32
> (PcdArmHdLcdBase) + 0x248)
> #define HDLCD_REG_BLUE_SELECT ((UINTN)PcdGet32
> (PcdArmHdLcdBase) + 0x24C)
>
> -
> -//
> // HDLCD Values of registers
> -//
>
> // HDLCD Interrupt mask, clear and status register
> #define HDLCD_DMA_END BIT0 /* DMA has finished reading a
> frame */
> @@ -79,6 +73,11 @@
> #define HDLCD_DATA_LOW 0
> #define HDLCD_PXCLK_LOW 0
>
> +// Default polarities
> +#define HDLCD_DEFAULT_POLARITIES (HDLCD_PXCLK_LOW |
> HDLCD_DATA_HIGH | \
> + HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW | \
> + HDLCD_VSYNC_HIGH)
> +
> // Pixel Format
> #define HDLCD_LITTLE_ENDIAN (0 << 31)
> #define HDLCD_BIG_ENDIAN (1 << 31)
> @@ -86,4 +85,4 @@
> // Number of bytes per pixel
> #define HDLCD_4BYTES_PER_PIXEL ((4 - 1) << 3)
>
> -#endif /* _HDLCD_H_ */
> +#endif /* HDLCD_H_ */
> diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> 9b4a02045ab7ca170e0d4362ee0e2bcf1d275bdb..3f3f7019f1d252995eab6
> d8c3d49db8be8e09e40 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -1,6 +1,6 @@
> -/** @file PL111Lcd.c
> +/** @file
>
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2018, 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 @@ -19,13 +19,10 @@
>
> #include "PL111Lcd.h"
>
> -
> /**********************************************************
> ************
> - *
> - * This file contains all the bits of the PL111 that are
> - * platform independent.
> - *
> -
> **********************************************************
> ************/
> +/** This file contains all the bits of the PL111 that are
> + platform independent.
>
> +**/
> EFI_STATUS
> LcdIdentify (
> VOID
> @@ -54,11 +51,11 @@ LcdInitialize (
> )
> {
> // Define start of the VRAM. This never changes for any graphics mode
> - MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);
> - MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a
> double buffer
> + MmioWrite32 (PL111_REG_LCD_UP_BASE, (UINT32)VramBaseAddress);
> + MmioWrite32 (PL111_REG_LCD_LP_BASE, 0); // We are not using a
> double
> + buffer
>
> // Disable all interrupts from the PL111
> - MmioWrite32(PL111_REG_LCD_IMSC, 0);
> + MmioWrite32 (PL111_REG_LCD_IMSC, 0);
>
> return EFI_SUCCESS;
> }
> @@ -81,37 +78,54 @@ LcdSetMode (
> LCD_BPP LcdBpp;
>
> // Set the video mode timings and other relevant information
> - Status = LcdPlatformGetTimings (ModeNumber,
> - &HRes,&HSync,&HBackPorch,&HFrontPorch,
> - &VRes,&VSync,&VBackPorch,&VFrontPorch);
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &HRes,
> + &HSync,
> + &HBackPorch,
> + &HFrontPorch,
> + &VRes,
> + &VSync,
> + &VBackPorch,
> + &VFrontPorch
> + );
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> - Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
> + Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> // Disable the CLCD_LcdEn bit
> - LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);
> - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);
> + LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
> + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
>
> // Set Timings
> - MmioWrite32 (PL111_REG_LCD_TIMING_0,
> HOR_AXIS_PANEL(HBackPorch, HFrontPorch, HSync, HRes));
> - MmioWrite32 (PL111_REG_LCD_TIMING_1,
> VER_AXIS_PANEL(VBackPorch, VFrontPorch, VSync, VRes));
> - MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY(HRes));
> + MmioWrite32 (
> + PL111_REG_LCD_TIMING_0,
> + HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
> + );
> +
> + MmioWrite32 (
> + PL111_REG_LCD_TIMING_1,
> + VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
> + );
> +
> + MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
> MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
>
> // PL111_REG_LCD_CONTROL
> - LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) |
> PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
> + LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
> + PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> // Turn on power to the LCD Panel
> LcdControl |= PL111_CTRL_LCD_PWR;
> - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
> + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> return EFI_SUCCESS;
> }
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (2 preceding siblings ...)
2018-03-20 16:11 ` [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS Girish Pathak
` (12 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
There is no functional modification in this change
some comments are modified and a few new comments are added.
This is to prevent mixing formatting changes with functional
changes.
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>
---
Notes:
v3:
- Propagated comments to LcdPlatformNullLib
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 20 ++---
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 92 +++++++++++++++-----
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 26 +++++-
ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 65 ++++++++++++++
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 24 ++++-
5 files changed, 189 insertions(+), 38 deletions(-)
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index 905eb26ee01b5037dfbaf3c054a62593837c8b5f..872361cd23fbdf52c5f128d0e172701e76d832b2 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -1,13 +1,14 @@
/** @file
+ This file implements the Graphics Output protocol for Arm platforms
- Copyright (c) 2011-2018, 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
+ Copyright (c) 2011-2018, 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.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
@@ -22,11 +23,6 @@
#include "LcdGraphicsOutputDxe.h"
-/** This file implements the Graphics Output protocol on ArmVersatileExpress
- using the Lcd controller
-
-**/
-
//
// Global variables
//
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index 3d13e417972c67cc51ae4410efd548053511e5d1..e51e78640ae7b1acd51ac333ba3faa8c78aea5a5 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -18,9 +18,7 @@
#define LCD_VRAM_SIZE SIZE_8MB
-//
// Modes definitions
-//
#define VGA 0
#define SVGA 1
#define XGA 2
@@ -29,9 +27,7 @@
#define UXGA 5
#define HD 6
-//
// VGA Mode: 640 x 480
-//
#define VGA_H_RES_PIXELS 640
#define VGA_V_RES_PIXELS 480
#define VGA_OSC_FREQUENCY 23750000 /* 0x016A6570 */
@@ -44,9 +40,7 @@
#define VGA_V_FRONT_PORCH ( 3 - 1)
#define VGA_V_BACK_PORCH ( 13 - 1)
-//
// SVGA Mode: 800 x 600
-//
#define SVGA_H_RES_PIXELS 800
#define SVGA_V_RES_PIXELS 600
#define SVGA_OSC_FREQUENCY 38250000 /* 0x0247A610 */
@@ -59,9 +53,7 @@
#define SVGA_V_FRONT_PORCH ( 3 - 1)
#define SVGA_V_BACK_PORCH ( 17 - 1)
-//
// XGA Mode: 1024 x 768
-//
#define XGA_H_RES_PIXELS 1024
#define XGA_V_RES_PIXELS 768
#define XGA_OSC_FREQUENCY 63500000 /* 0x03C8EEE0 */
@@ -74,9 +66,7 @@
#define XGA_V_FRONT_PORCH ( 3 - 1)
#define XGA_V_BACK_PORCH ( 23 - 1)
-//
// SXGA Mode: 1280 x 1024
-//
#define SXGA_H_RES_PIXELS 1280
#define SXGA_V_RES_PIXELS 1024
#define SXGA_OSC_FREQUENCY 109000000 /* 0x067F3540 */
@@ -89,9 +79,7 @@
#define SXGA_V_FRONT_PORCH ( 3 - 1)
#define SXGA_V_BACK_PORCH ( 29 - 1)
-//
// WSXGA+ Mode: 1680 x 1050
-//
#define WSXGA_H_RES_PIXELS 1680
#define WSXGA_V_RES_PIXELS 1050
#define WSXGA_OSC_FREQUENCY 147000000 /* 0x08C30AC0 */
@@ -104,9 +92,7 @@
#define WSXGA_V_FRONT_PORCH ( 4 - 1)
#define WSXGA_V_BACK_PORCH ( 41 - 1)
-//
// UXGA Mode: 1600 x 1200
-//
#define UXGA_H_RES_PIXELS 1600
#define UXGA_V_RES_PIXELS 1200
#define UXGA_OSC_FREQUENCY 161000000 /* 0x0998AA40 */
@@ -119,9 +105,7 @@
#define UXGA_V_FRONT_PORCH ( 3 - 1)
#define UXGA_V_BACK_PORCH ( 38 - 1)
-//
// HD Mode: 1920 x 1080
-//
#define HD_H_RES_PIXELS 1920
#define HD_V_RES_PIXELS 1080
#define HD_OSC_FREQUENCY 165000000 /* 0x09D5B340 */
@@ -134,10 +118,7 @@
#define HD_V_FRONT_PORCH ( 3 - 1)
#define HD_V_BACK_PORCH ( 32 - 1)
-//
// Colour Masks
-//
-
#define LCD_24BPP_RED_MASK 0x00FF0000
#define LCD_24BPP_GREEN_MASK 0x0000FF00
#define LCD_24BPP_BLUE_MASK 0x000000FF
@@ -158,7 +139,7 @@
#define LCD_12BPP_444_BLUE_MASK 0x0000000F
#define LCD_12BPP_444_RESERVED_MASK 0x0000F000
-/** The enumeration indexes maps the PL111 LcdBpp values used in the LCD Control
+/** The enumeration maps the PL111 LcdBpp values used in the LCD Control
Register
**/
typedef enum {
@@ -172,33 +153,94 @@ typedef enum {
LCD_BITS_PER_PIXEL_12_444
} LCD_BPP;
+/** Platform related initialization function.
+
+ @param[in] Handle Handle to the LCD device instance.
+
+ @retval EFI_SUCCESS Plaform library initialized successfully.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformInitializeDisplay (
IN EFI_HANDLE Handle
);
+/** Allocate VRAM memory in DRAM for the framebuffer
+ (unless it is reserved already).
+
+ The allocated address can be used to set the framebuffer.
+
+ @param[out] VramBaseAddress A pointer to the framebuffer address.
+ @param[out] VramSize A pointer to the size of the frame
+ buffer in bytes
+
+ @retval EFI_SUCCESS Frame buffer memory allocated successfully.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformGetVram (
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
OUT UINTN* VramSize
);
+/** Return total number of modes supported.
+
+ Note: Valid mode numbers are 0 to MaxMode - 1
+ See Section 12.9 of the UEFI Specification 2.7
+
+ @retval UINT32 Mode Number.
+**/
UINT32
LcdPlatformGetMaxMode (
VOID
);
+/** Set the requested display mode.
+
+ @param[in] ModeNumber Mode Number.
+
+ @retval EFI_SUCCESS Mode set successfully.
+ @retval EFI_INVALID_PARAMETER Requested mode not found.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformSetMode (
IN UINT32 ModeNumber
);
+/** Return information for the requested mode number.
+
+ @param[in] ModeNumber Mode Number.
+ @param[out] Info Pointer for returned mode information
+ (on success).
+
+ @retval EFI_SUCCESS Mode information for the requested mode
+ returned successfully.
+ @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformQueryMode (
IN UINT32 ModeNumber,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
);
+/** Return display timing information for the requested mode number.
+
+ @param[in] ModeNumber Mode Number.
+
+ @param[out] HRes Pointer to horizontal resolution.
+ @param[out] HSync Pointer to horizontal sync width.
+ @param[out] HBackPorch Pointer to horizontal back porch.
+ @param[out] HFrontPorch Pointer to horizontal front porch.
+ @param[out] VRes Pointer to vertical resolution.
+ @param[out] VSync Pointer to vertical sync width.
+ @param[out] VBackPorch Pointer to vertical back porch.
+ @param[out] VFrontPorch Pointer to vertical front porch.
+
+ @retval EFI_SUCCESS Display timing information for the requested
+ mode returned successfully.
+ @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
@@ -212,6 +254,16 @@ LcdPlatformGetTimings (
OUT UINT32* VFrontPorch
);
+/** Return bits per pixel information for a mode number.
+
+ @param[in] ModeNumber Mode Number.
+
+ @param[out] Bpp Pointer to value bits per pixel information.
+
+ @retval EFI_SUCCESS Bit per pixel information for the requested
+ mode returned successfully.
+ @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetBpp (
IN UINT32 ModeNumber,
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index 2cd1be9d255dd5734176d752d60f06f11a047fcb..be4ccfdc1f421060faec792c8e8acfcfb3232014 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -1,4 +1,5 @@
/** @file
+ This file contains the platform independent parts of HdLcd
Copyright (c) 2011-2018, ARM Ltd. All rights reserved.<BR>
@@ -21,10 +22,6 @@
#include "HdLcd.h"
-/** This file contains all the bits of the Lcd that are
- platform independent.
-**/
-
STATIC
UINTN
GetBytesPerPixel (
@@ -51,6 +48,12 @@ GetBytesPerPixel (
}
}
+/** Initialize display.
+
+ @param[in] VramBaseAddress Address of the framebuffer.
+
+ @retval EFI_SUCCESS Display initialization successful.
+**/
EFI_STATUS
LcdInitialize (
IN EFI_PHYSICAL_ADDRESS VramBaseAddress
@@ -82,6 +85,14 @@ LcdInitialize (
return EFI_SUCCESS;
}
+/** Set requested mode of the display.
+
+ @param[in] ModeNumber Display mode number.
+
+ @retval EFI_SUCCESS Display mode set successfully.
+ @retval EFI_DEVICE_ERROR Reurns an error if display timing
+ information is not available.
+**/
EFI_STATUS
LcdSetMode (
IN UINT32 ModeNumber
@@ -150,6 +161,8 @@ LcdSetMode (
return EFI_SUCCESS;
}
+/** De-initializes the display.
+**/
VOID
LcdShutdown (
VOID
@@ -159,6 +172,11 @@ LcdShutdown (
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
}
+/** Check for presence of HDLCD.
+
+ @retval EFI_SUCCESS Returns success if platform implements a HDLCD
+ controller.
+**/
EFI_STATUS
LcdIdentify (
VOID
diff --git a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
index b78d9a3bbd3e1fac4238f2be961a343020360a32..b76894c534fb413d87c77c528f0bb7d49862c78f 100644
--- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
+++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
@@ -1,6 +1,7 @@
/** @file
Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+ Copyright (c) 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
@@ -17,6 +18,12 @@
#include <Library/DebugLib.h>
#include <Library/LcdPlatformLib.h>
+/** Platform related initialization function.
+
+ @param[in] Handle Handle to the LCD device instance.
+
+ @retval EFI_UNSUPPORTED Interface is not supported.
+**/
EFI_STATUS
LcdPlatformInitializeDisplay (
IN EFI_HANDLE Handle
@@ -26,6 +33,17 @@ LcdPlatformInitializeDisplay (
return EFI_UNSUPPORTED;
}
+/** Allocate VRAM memory in DRAM for the framebuffer
+ (unless it is reserved already).
+
+ The allocated address can be used to set the framebuffer.
+
+ @param[out] VramBaseAddress A pointer to the framebuffer address.
+ @param[out] VramSize A pointer to the size of the frame
+ buffer in bytes
+
+ @retval EFI_UNSUPPORTED Interface is not supported.
+**/
EFI_STATUS
LcdPlatformGetVram (
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
@@ -36,6 +54,14 @@ LcdPlatformGetVram (
return EFI_UNSUPPORTED;
}
+/** Return total number of modes supported.
+
+ Note: Valid mode numbers are 0 to MaxMode - 1
+ See Section 12.9 of the UEFI Specification 2.7
+
+ @retval UINT32 Zero number of modes supported
+ in a NULL library implementation.
+**/
UINT32
LcdPlatformGetMaxMode (
VOID
@@ -45,6 +71,12 @@ LcdPlatformGetMaxMode (
return 0;
}
+/** Set the requested display mode.
+
+ @param[in] ModeNumber Mode Number.
+
+ @retval EFI_UNSUPPORTED Interface is not supported.
+**/
EFI_STATUS
LcdPlatformSetMode (
IN UINT32 ModeNumber
@@ -54,6 +86,15 @@ LcdPlatformSetMode (
return EFI_UNSUPPORTED;
}
+/** Return information for the requested mode number.
+
+ @param[in] ModeNumber Mode Number.
+ @param[out] Info Pointer for returned mode information
+ (on success).
+
+ @retval EFI_UNSUPPORTED Interface is not supported.
+
+**/
EFI_STATUS
LcdPlatformQueryMode (
IN UINT32 ModeNumber,
@@ -64,6 +105,21 @@ LcdPlatformQueryMode (
return EFI_UNSUPPORTED;
}
+/** Return display timing information for the requested mode number.
+
+ @param[in] ModeNumber Mode Number.
+
+ @param[out] HRes Pointer to horizontal resolution.
+ @param[out] HSync Pointer to horizontal sync width.
+ @param[out] HBackPorch Pointer to horizontal back porch.
+ @param[out] HFrontPorch Pointer to horizontal front porch.
+ @param[out] VRes Pointer to vertical resolution.
+ @param[out] VSync Pointer to vertical sync width.
+ @param[out] VBackPorch Pointer to vertical back porch.
+ @param[out] VFrontPorch Pointer to vertical front porch.
+
+ @retval EFI_UNSUPPORTED Interface is not supported.
+**/
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
@@ -81,6 +137,15 @@ LcdPlatformGetTimings (
return EFI_UNSUPPORTED;
}
+/** Return bits per pixel information for a mode number.
+
+ @param[in] ModeNumber Mode Number.
+
+ @param[out] Bpp Pointer to value bits per pixel information.
+
+ @retval EFI_UNSUPPORTED Interface is not supported.
+
+**/
EFI_STATUS
LcdPlatformGetBpp (
IN UINT32 ModeNumber,
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index 3f3f7019f1d252995eab6d8c3d49db8be8e09e40..ccd7a4d1d43ad5c2f495683ac68236e17f3b55a5 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -1,4 +1,5 @@
/** @file
+ This file contains the platform independent parts of PL111Lcd
Copyright (c) 2011-2018, ARM Ltd. All rights reserved.<BR>
@@ -19,9 +20,12 @@
#include "PL111Lcd.h"
-/** This file contains all the bits of the PL111 that are
- platform independent.
+/** Check for presence of PL111.
+ @retval EFI_SUCCESS Returns success if platform implements a
+ PL111 controller.
+
+ @retval EFI_NOT_FOUND PL111 display controller not found the plaform.
**/
EFI_STATUS
LcdIdentify (
@@ -45,6 +49,12 @@ LcdIdentify (
return EFI_NOT_FOUND;
}
+/** Initialize display.
+
+ @param[in] VramBaseAddress Address of the framebuffer.
+
+ @retval EFI_SUCCESS Initialization of display successful.
+**/
EFI_STATUS
LcdInitialize (
IN EFI_PHYSICAL_ADDRESS VramBaseAddress
@@ -60,6 +70,14 @@ LcdInitialize (
return EFI_SUCCESS;
}
+/** Set requested mode of the display.
+
+ @param[in] ModeNumbe Display mode number.
+
+ @retval EFI_SUCCESS Display mode set successfuly.
+ @retval EFI_DEVICE_ERROR It returns an error if display timing
+ information is not available.
+**/
EFI_STATUS
LcdSetMode (
IN UINT32 ModeNumber
@@ -130,6 +148,8 @@ LcdSetMode (
return EFI_SUCCESS;
}
+/** De-initializes the display.
+*/
VOID
LcdShutdown (
VOID
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments
2018-03-20 16:12 ` [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated
> comments
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> There is no functional modification in this change some comments are
> modified and a few new comments are added.
> This is to prevent mixing formatting changes with functional changes.
>
> 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>
> ---
>
> Notes:
> v3:
> - Propagated comments to LcdPlatformNullLib
>
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> | 20 ++---
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 92
> +++++++++++++++-----
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 26 +++++-
> ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 65
> ++++++++++++++
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 24 ++++-
> 5 files changed, 189 insertions(+), 38 deletions(-)
>
> diff --git
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> index
> 905eb26ee01b5037dfbaf3c054a62593837c8b5f..872361cd23fbdf52c5f128
> d0e172701e76d832b2 100644
> ---
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> +++
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> @@ -1,13 +1,14 @@
> /** @file
> + This file implements the Graphics Output protocol for Arm platforms
>
> - Copyright (c) 2011-2018, 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
> + Copyright (c) 2011-2018, 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.
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
>
> **/
>
> @@ -22,11 +23,6 @@
>
> #include "LcdGraphicsOutputDxe.h"
>
> -/** This file implements the Graphics Output protocol on
> ArmVersatileExpress
> - using the Lcd controller
> -
> -**/
> -
> //
> // Global variables
> //
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index
> 3d13e417972c67cc51ae4410efd548053511e5d1..e51e78640ae7b1acd51a
> c333ba3faa8c78aea5a5 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -18,9 +18,7 @@
>
> #define LCD_VRAM_SIZE SIZE_8MB
>
> -//
> // Modes definitions
> -//
> #define VGA 0
> #define SVGA 1
> #define XGA 2
> @@ -29,9 +27,7 @@
> #define UXGA 5
> #define HD 6
>
> -//
> // VGA Mode: 640 x 480
> -//
> #define VGA_H_RES_PIXELS 640
> #define VGA_V_RES_PIXELS 480
> #define VGA_OSC_FREQUENCY 23750000 /* 0x016A6570 */
> @@ -44,9 +40,7 @@
> #define VGA_V_FRONT_PORCH ( 3 - 1)
> #define VGA_V_BACK_PORCH ( 13 - 1)
>
> -//
> // SVGA Mode: 800 x 600
> -//
> #define SVGA_H_RES_PIXELS 800
> #define SVGA_V_RES_PIXELS 600
> #define SVGA_OSC_FREQUENCY 38250000 /* 0x0247A610 */
> @@ -59,9 +53,7 @@
> #define SVGA_V_FRONT_PORCH ( 3 - 1)
> #define SVGA_V_BACK_PORCH ( 17 - 1)
>
> -//
> // XGA Mode: 1024 x 768
> -//
> #define XGA_H_RES_PIXELS 1024
> #define XGA_V_RES_PIXELS 768
> #define XGA_OSC_FREQUENCY 63500000 /* 0x03C8EEE0 */
> @@ -74,9 +66,7 @@
> #define XGA_V_FRONT_PORCH ( 3 - 1)
> #define XGA_V_BACK_PORCH ( 23 - 1)
>
> -//
> // SXGA Mode: 1280 x 1024
> -//
> #define SXGA_H_RES_PIXELS 1280
> #define SXGA_V_RES_PIXELS 1024
> #define SXGA_OSC_FREQUENCY 109000000 /* 0x067F3540 */
> @@ -89,9 +79,7 @@
> #define SXGA_V_FRONT_PORCH ( 3 - 1)
> #define SXGA_V_BACK_PORCH ( 29 - 1)
>
> -//
> // WSXGA+ Mode: 1680 x 1050
> -//
> #define WSXGA_H_RES_PIXELS 1680
> #define WSXGA_V_RES_PIXELS 1050
> #define WSXGA_OSC_FREQUENCY 147000000 /* 0x08C30AC0 */
> @@ -104,9 +92,7 @@
> #define WSXGA_V_FRONT_PORCH ( 4 - 1)
> #define WSXGA_V_BACK_PORCH ( 41 - 1)
>
> -//
> // UXGA Mode: 1600 x 1200
> -//
> #define UXGA_H_RES_PIXELS 1600
> #define UXGA_V_RES_PIXELS 1200
> #define UXGA_OSC_FREQUENCY 161000000 /* 0x0998AA40 */
> @@ -119,9 +105,7 @@
> #define UXGA_V_FRONT_PORCH ( 3 - 1)
> #define UXGA_V_BACK_PORCH ( 38 - 1)
>
> -//
> // HD Mode: 1920 x 1080
> -//
> #define HD_H_RES_PIXELS 1920
> #define HD_V_RES_PIXELS 1080
> #define HD_OSC_FREQUENCY 165000000 /* 0x09D5B340 */
> @@ -134,10 +118,7 @@
> #define HD_V_FRONT_PORCH ( 3 - 1)
> #define HD_V_BACK_PORCH ( 32 - 1)
>
> -//
> // Colour Masks
> -//
> -
> #define LCD_24BPP_RED_MASK 0x00FF0000
> #define LCD_24BPP_GREEN_MASK 0x0000FF00
> #define LCD_24BPP_BLUE_MASK 0x000000FF
> @@ -158,7 +139,7 @@
> #define LCD_12BPP_444_BLUE_MASK 0x0000000F
> #define LCD_12BPP_444_RESERVED_MASK 0x0000F000
>
> -/** The enumeration indexes maps the PL111 LcdBpp values used in the
> LCD Control
> +/** The enumeration maps the PL111 LcdBpp values used in the LCD
> +Control
> Register
> **/
> typedef enum {
> @@ -172,33 +153,94 @@ typedef enum {
> LCD_BITS_PER_PIXEL_12_444
> } LCD_BPP;
>
> +/** Platform related initialization function.
> +
> + @param[in] Handle Handle to the LCD device instance.
> +
> + @retval EFI_SUCCESS Plaform library initialized successfully.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformInitializeDisplay (
> IN EFI_HANDLE Handle
> );
>
> +/** Allocate VRAM memory in DRAM for the framebuffer
> + (unless it is reserved already).
> +
> + The allocated address can be used to set the framebuffer.
> +
> + @param[out] VramBaseAddress A pointer to the framebuffer address.
> + @param[out] VramSize A pointer to the size of the frame
> + buffer in bytes
> +
> + @retval EFI_SUCCESS Frame buffer memory allocated successfully.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformGetVram (
> OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> OUT UINTN* VramSize
> );
>
> +/** Return total number of modes supported.
> +
> + Note: Valid mode numbers are 0 to MaxMode - 1 See Section 12.9 of
> + the UEFI Specification 2.7
> +
> + @retval UINT32 Mode Number.
> +**/
> UINT32
> LcdPlatformGetMaxMode (
> VOID
> );
>
> +/** Set the requested display mode.
> +
> + @param[in] ModeNumber Mode Number.
> +
> + @retval EFI_SUCCESS Mode set successfully.
> + @retval EFI_INVALID_PARAMETER Requested mode not found.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformSetMode (
> IN UINT32 ModeNumber
> );
>
> +/** Return information for the requested mode number.
> +
> + @param[in] ModeNumber Mode Number.
> + @param[out] Info Pointer for returned mode information
> + (on success).
> +
> + @retval EFI_SUCCESS Mode information for the requested mode
> + returned successfully.
> + @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformQueryMode (
> IN UINT32 ModeNumber,
> OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> );
>
> +/** Return display timing information for the requested mode number.
> +
> + @param[in] ModeNumber Mode Number.
> +
> + @param[out] HRes Pointer to horizontal resolution.
> + @param[out] HSync Pointer to horizontal sync width.
> + @param[out] HBackPorch Pointer to horizontal back porch.
> + @param[out] HFrontPorch Pointer to horizontal front porch.
> + @param[out] VRes Pointer to vertical resolution.
> + @param[out] VSync Pointer to vertical sync width.
> + @param[out] VBackPorch Pointer to vertical back porch.
> + @param[out] VFrontPorch Pointer to vertical front porch.
> +
> + @retval EFI_SUCCESS Display timing information for the requested
> + mode returned successfully.
> + @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> @@ -212,6 +254,16 @@ LcdPlatformGetTimings (
> OUT UINT32* VFrontPorch
> );
>
> +/** Return bits per pixel information for a mode number.
> +
> + @param[in] ModeNumber Mode Number.
> +
> + @param[out] Bpp Pointer to value bits per pixel information.
> +
> + @retval EFI_SUCCESS Bit per pixel information for the requested
> + mode returned successfully.
> + @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetBpp (
> IN UINT32 ModeNumber,
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> 2cd1be9d255dd5734176d752d60f06f11a047fcb..be4ccfdc1f421060faec79
> 2c8e8acfcfb3232014 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -1,4 +1,5 @@
> /** @file
> + This file contains the platform independent parts of HdLcd
>
> Copyright (c) 2011-2018, ARM Ltd. All rights reserved.<BR>
>
> @@ -21,10 +22,6 @@
>
> #include "HdLcd.h"
>
> -/** This file contains all the bits of the Lcd that are
> - platform independent.
> -**/
> -
> STATIC
> UINTN
> GetBytesPerPixel (
> @@ -51,6 +48,12 @@ GetBytesPerPixel (
> }
> }
>
> +/** Initialize display.
> +
> + @param[in] VramBaseAddress Address of the framebuffer.
> +
> + @retval EFI_SUCCESS Display initialization successful.
> +**/
> EFI_STATUS
> LcdInitialize (
> IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> @@ -82,6 +85,14 @@ LcdInitialize (
> return EFI_SUCCESS;
> }
>
> +/** Set requested mode of the display.
> +
> + @param[in] ModeNumber Display mode number.
> +
> + @retval EFI_SUCCESS Display mode set successfully.
> + @retval EFI_DEVICE_ERROR Reurns an error if display timing
> + information is not available.
> +**/
> EFI_STATUS
> LcdSetMode (
> IN UINT32 ModeNumber
> @@ -150,6 +161,8 @@ LcdSetMode (
> return EFI_SUCCESS;
> }
>
> +/** De-initializes the display.
> +**/
> VOID
> LcdShutdown (
> VOID
> @@ -159,6 +172,11 @@ LcdShutdown (
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); }
>
> +/** Check for presence of HDLCD.
> +
> + @retval EFI_SUCCESS Returns success if platform implements a
> HDLCD
> + controller.
> +**/
> EFI_STATUS
> LcdIdentify (
> VOID
> diff --git
> a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> index
> b78d9a3bbd3e1fac4238f2be961a343020360a32..b76894c534fb413d87c7
> 7c528f0bb7d49862c78f 100644
> --- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> +++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> @@ -1,6 +1,7 @@
> /** @file
>
> Copyright (c) 2017, Linaro, Ltd. All rights reserved.
> + Copyright (c) 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 @@ -17,6 +18,12 @@ #include <Library/DebugLib.h>
> #include <Library/LcdPlatformLib.h>
>
> +/** Platform related initialization function.
> +
> + @param[in] Handle Handle to the LCD device instance.
> +
> + @retval EFI_UNSUPPORTED Interface is not supported.
> +**/
> EFI_STATUS
> LcdPlatformInitializeDisplay (
> IN EFI_HANDLE Handle
> @@ -26,6 +33,17 @@ LcdPlatformInitializeDisplay (
> return EFI_UNSUPPORTED;
> }
>
> +/** Allocate VRAM memory in DRAM for the framebuffer
> + (unless it is reserved already).
> +
> + The allocated address can be used to set the framebuffer.
> +
> + @param[out] VramBaseAddress A pointer to the framebuffer address.
> + @param[out] VramSize A pointer to the size of the frame
> + buffer in bytes
> +
> + @retval EFI_UNSUPPORTED Interface is not supported.
> +**/
> EFI_STATUS
> LcdPlatformGetVram (
> OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> @@ -36,6 +54,14 @@ LcdPlatformGetVram (
> return EFI_UNSUPPORTED;
> }
>
> +/** Return total number of modes supported.
> +
> + Note: Valid mode numbers are 0 to MaxMode - 1 See Section 12.9 of
> + the UEFI Specification 2.7
> +
> + @retval UINT32 Zero number of modes supported
> + in a NULL library implementation.
> +**/
> UINT32
> LcdPlatformGetMaxMode (
> VOID
> @@ -45,6 +71,12 @@ LcdPlatformGetMaxMode (
> return 0;
> }
>
> +/** Set the requested display mode.
> +
> + @param[in] ModeNumber Mode Number.
> +
> + @retval EFI_UNSUPPORTED Interface is not supported.
> +**/
> EFI_STATUS
> LcdPlatformSetMode (
> IN UINT32 ModeNumber
> @@ -54,6 +86,15 @@ LcdPlatformSetMode (
> return EFI_UNSUPPORTED;
> }
>
> +/** Return information for the requested mode number.
> +
> + @param[in] ModeNumber Mode Number.
> + @param[out] Info Pointer for returned mode information
> + (on success).
> +
> + @retval EFI_UNSUPPORTED Interface is not supported.
> +
> +**/
> EFI_STATUS
> LcdPlatformQueryMode (
> IN UINT32 ModeNumber,
> @@ -64,6 +105,21 @@ LcdPlatformQueryMode (
> return EFI_UNSUPPORTED;
> }
>
> +/** Return display timing information for the requested mode number.
> +
> + @param[in] ModeNumber Mode Number.
> +
> + @param[out] HRes Pointer to horizontal resolution.
> + @param[out] HSync Pointer to horizontal sync width.
> + @param[out] HBackPorch Pointer to horizontal back porch.
> + @param[out] HFrontPorch Pointer to horizontal front porch.
> + @param[out] VRes Pointer to vertical resolution.
> + @param[out] VSync Pointer to vertical sync width.
> + @param[out] VBackPorch Pointer to vertical back porch.
> + @param[out] VFrontPorch Pointer to vertical front porch.
> +
> + @retval EFI_UNSUPPORTED Interface is not supported.
> +**/
> EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> @@ -81,6 +137,15 @@ LcdPlatformGetTimings (
> return EFI_UNSUPPORTED;
> }
>
> +/** Return bits per pixel information for a mode number.
> +
> + @param[in] ModeNumber Mode Number.
> +
> + @param[out] Bpp Pointer to value bits per pixel information.
> +
> + @retval EFI_UNSUPPORTED Interface is not supported.
> +
> +**/
> EFI_STATUS
> LcdPlatformGetBpp (
> IN UINT32 ModeNumber,
> diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> 3f3f7019f1d252995eab6d8c3d49db8be8e09e40..ccd7a4d1d43ad5c2f4956
> 83ac68236e17f3b55a5 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -1,4 +1,5 @@
> /** @file
> + This file contains the platform independent parts of PL111Lcd
>
> Copyright (c) 2011-2018, ARM Ltd. All rights reserved.<BR>
>
> @@ -19,9 +20,12 @@
>
> #include "PL111Lcd.h"
>
> -/** This file contains all the bits of the PL111 that are
> - platform independent.
> +/** Check for presence of PL111.
>
> + @retval EFI_SUCCESS Returns success if platform implements a
> + PL111 controller.
> +
> + @retval EFI_NOT_FOUND PL111 display controller not found the
> plaform.
> **/
> EFI_STATUS
> LcdIdentify (
> @@ -45,6 +49,12 @@ LcdIdentify (
> return EFI_NOT_FOUND;
> }
>
> +/** Initialize display.
> +
> + @param[in] VramBaseAddress Address of the framebuffer.
> +
> + @retval EFI_SUCCESS Initialization of display successful.
> +**/
> EFI_STATUS
> LcdInitialize (
> IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> @@ -60,6 +70,14 @@ LcdInitialize (
> return EFI_SUCCESS;
> }
>
> +/** Set requested mode of the display.
> +
> + @param[in] ModeNumbe Display mode number.
> +
> + @retval EFI_SUCCESS Display mode set successfuly.
> + @retval EFI_DEVICE_ERROR It returns an error if display timing
> + information is not available.
> +**/
> EFI_STATUS
> LcdSetMode (
> IN UINT32 ModeNumber
> @@ -130,6 +148,8 @@ LcdSetMode (
> return EFI_SUCCESS;
> }
>
> +/** De-initializes the display.
> +*/
> VOID
> LcdShutdown (
> VOID
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (3 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro Girish Pathak
` (11 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
This change moves some ASSERTs in error handling code
to improve efficiency in DEBUG build. This change also
removes redundant error code returns.
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>
---
Notes:
v3:
- Reverted to ASSERT_EFI_ERROR (Status) from ASSERT (FALSE)
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 11 +++++------
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 12 ++++++------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index be4ccfdc1f421060faec792c8e8acfcfb3232014..28306c530e08b5e0fcef4308435045da3c9e093c 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -90,8 +90,7 @@ LcdInitialize (
@param[in] ModeNumber Display mode number.
@retval EFI_SUCCESS Display mode set successfully.
- @retval EFI_DEVICE_ERROR Reurns an error if display timing
- information is not available.
+ @retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
LcdSetMode (
@@ -122,15 +121,15 @@ LcdSetMode (
&VBackPorch,
&VFrontPorch
);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
BytesPerPixel = GetBytesPerPixel (LcdBpp);
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index ccd7a4d1d43ad5c2f495683ac68236e17f3b55a5..cb64c57dd79f3bb1345e4d3dbda7f5b3ce859f40 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -75,8 +75,8 @@ LcdInitialize (
@param[in] ModeNumbe Display mode number.
@retval EFI_SUCCESS Display mode set successfuly.
- @retval EFI_DEVICE_ERROR It returns an error if display timing
- information is not available.
+ @retval !(EFI_SUCCESS) Other errors.
+
**/
EFI_STATUS
LcdSetMode (
@@ -107,15 +107,15 @@ LcdSetMode (
&VBackPorch,
&VFrontPorch
);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Disable the CLCD_LcdEn bit
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS
2018-03-20 16:12 ` [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111:
> Update debug ASSERTS
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change moves some ASSERTs in error handling code to improve
> efficiency in DEBUG build. This change also removes redundant error code
> returns.
>
> 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>
> ---
>
> Notes:
> v3:
> - Reverted to ASSERT_EFI_ERROR (Status) from ASSERT (FALSE)
>
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 11 +++++------
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 12 ++++++------
> 2 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> be4ccfdc1f421060faec792c8e8acfcfb3232014..28306c530e08b5e0fcef430
> 8435045da3c9e093c 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -90,8 +90,7 @@ LcdInitialize (
> @param[in] ModeNumber Display mode number.
>
> @retval EFI_SUCCESS Display mode set successfully.
> - @retval EFI_DEVICE_ERROR Reurns an error if display timing
> - information is not available.
> + @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> LcdSetMode (
> @@ -122,15 +121,15 @@ LcdSetMode (
> &VBackPorch,
> &VFrontPorch
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> BytesPerPixel = GetBytesPerPixel (LcdBpp); diff --git
> a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> ccd7a4d1d43ad5c2f495683ac68236e17f3b55a5..cb64c57dd79f3bb1345e4
> d3dbda7f5b3ce859f40 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -75,8 +75,8 @@ LcdInitialize (
> @param[in] ModeNumbe Display mode number.
>
> @retval EFI_SUCCESS Display mode set successfuly.
> - @retval EFI_DEVICE_ERROR It returns an error if display timing
> - information is not available.
> + @retval !(EFI_SUCCESS) Other errors.
> +
> **/
> EFI_STATUS
> LcdSetMode (
> @@ -107,15 +107,15 @@ LcdSetMode (
> &VBackPorch,
> &VFrontPorch
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> // Disable the CLCD_LcdEn bit
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (4 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:26 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl Girish Pathak
` (10 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
Minor code change, replaces magic number with macro in LCD disable.
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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index cb64c57dd79f3bb1345e4d3dbda7f5b3ce859f40..287e3ca272c0c19f8045a3bf4e69a092d8da6fd8 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -119,8 +119,7 @@ LcdSetMode (
}
// Disable the CLCD_LcdEn bit
- LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
- MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
+ MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
// Set Timings
MmioWrite32 (
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro
2018-03-20 16:12 ` [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro Girish Pathak
@ 2018-03-21 12:26 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:26 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace
> magic number with macro
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> Minor code change, replaces magic number with macro in LCD disable.
>
> 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> cb64c57dd79f3bb1345e4d3dbda7f5b3ce859f40..287e3ca272c0c19f8045a
> 3bf4e69a092d8da6fd8 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -119,8 +119,7 @@ LcdSetMode (
> }
>
> // Disable the CLCD_LcdEn bit
> - LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
> - MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
> + MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
>
> // Set Timings
> MmioWrite32 (
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (5 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:26 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP Girish Pathak
` (9 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
Currenty bit LcdPwr of the LCDControl register is enabled immediately
after setting other bits of the LCDControl register. This two write
sequence is unnecessary. This change removes this extra write by setting
LcdPwr bit along with other bits of the LcdControl register.
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>
---
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index 287e3ca272c0c19f8045a3bf4e69a092d8da6fd8..465cb6845437f57d15f05a271d1b01f634e11b56 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -137,11 +137,7 @@ LcdSetMode (
// PL111_REG_LCD_CONTROL
LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
- PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
- MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
-
- // Turn on power to the LCD Panel
- LcdControl |= PL111_CTRL_LCD_PWR;
+ PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR | PL111_CTRL_BGR;
MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
return EFI_SUCCESS;
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl
2018-03-20 16:12 ` [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl Girish Pathak
@ 2018-03-21 12:26 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:26 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine
> two writes to LCDControl
>
> Currenty bit LcdPwr of the LCDControl register is enabled immediately after
> setting other bits of the LCDControl register. This two write sequence is
> unnecessary. This change removes this extra write by setting LcdPwr bit
> along with other bits of the LcdControl register.
>
> 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>
> ---
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> 287e3ca272c0c19f8045a3bf4e69a092d8da6fd8..465cb6845437f57d15f05
> a271d1b01f634e11b56 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -137,11 +137,7 @@ LcdSetMode (
>
> // PL111_REG_LCD_CONTROL
> LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
> - PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> - MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
> -
> - // Turn on power to the LCD Panel
> - LcdControl |= PL111_CTRL_LCD_PWR;
> + PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR |
> + PL111_CTRL_BGR;
> MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> return EFI_SUCCESS;
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (6 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:26 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function Girish Pathak
` (8 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
LcdIdentify function does not currently check presence of HDLCD
controller.
Implement this functionality by reading HDLCD_REG_VERSION and checking
against the PRODUCT_ID field to detect presence of HDLCD controller.
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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 8 +++++++-
ArmPlatformPkg/Library/HdLcd/HdLcd.h | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index 28306c530e08b5e0fcef4308435045da3c9e093c..039048398c531ec944bc4b43a5551a554a368481 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -175,11 +175,17 @@ LcdShutdown (
@retval EFI_SUCCESS Returns success if platform implements a HDLCD
controller.
+ @retval EFI_NOT_FOUND HDLCD display controller not found on the
+ platform.
**/
EFI_STATUS
LcdIdentify (
VOID
)
{
- return EFI_SUCCESS;
+ if ((MmioRead32 (HDLCD_REG_VERSION) >> 16) == HDLCD_PRODUCT_ID) {
+ return EFI_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
}
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.h b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
index cd2c0366c7b563d7fb313f82abeef7eb1aa3ef72..1efa78eedc3013b3ab4615181a59c7d15b851ab5 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.h
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
@@ -85,4 +85,6 @@
// Number of bytes per pixel
#define HDLCD_4BYTES_PER_PIXEL ((4 - 1) << 3)
+#define HDLCD_PRODUCT_ID 0x1CDC
+
#endif /* HDLCD_H_ */
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP
2018-03-20 16:12 ` [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP Girish Pathak
@ 2018-03-21 12:26 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:26 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify
> function for HDLCD GOP
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> LcdIdentify function does not currently check presence of HDLCD controller.
>
> Implement this functionality by reading HDLCD_REG_VERSION and checking
> against the PRODUCT_ID field to detect presence of HDLCD controller.
>
> 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 8 +++++++-
> ArmPlatformPkg/Library/HdLcd/HdLcd.h | 2 ++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> 28306c530e08b5e0fcef4308435045da3c9e093c..039048398c531ec944bc4
> b43a5551a554a368481 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -175,11 +175,17 @@ LcdShutdown (
>
> @retval EFI_SUCCESS Returns success if platform implements a
> HDLCD
> controller.
> + @retval EFI_NOT_FOUND HDLCD display controller not found on the
> + platform.
> **/
> EFI_STATUS
> LcdIdentify (
> VOID
> )
> {
> - return EFI_SUCCESS;
> + if ((MmioRead32 (HDLCD_REG_VERSION) >> 16) == HDLCD_PRODUCT_ID)
> {
> + return EFI_SUCCESS;
> + }
> +
> + return EFI_NOT_FOUND;
> }
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> index
> cd2c0366c7b563d7fb313f82abeef7eb1aa3ef72..1efa78eedc3013b3ab4615
> 181a59c7d15b851ab5 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.h
> @@ -85,4 +85,6 @@
> // Number of bytes per pixel
> #define HDLCD_4BYTES_PER_PIXEL ((4 - 1) << 3)
>
> +#define HDLCD_PRODUCT_ID 0x1CDC
> +
> #endif /* HDLCD_H_ */
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (7 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format Girish Pathak
` (7 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
The LcdPlatformGetTimings interface function takes similar sets of
multiple parameters for horizontal and vertical timings which can be
aggregated in a common data type. This change defines a structure
SCAN_TIMINGS for this which can be used to describe both horizontal and
vertical scan timings, and accordingly redefines the
LcdPlatformGetTiming interface, greatly reducing the amount of data
passed about.
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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 31 ++++++------
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 50 +++++++++-----------
ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 10 +---
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 43 +++++++++--------
4 files changed, 64 insertions(+), 70 deletions(-)
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index e51e78640ae7b1acd51ac333ba3faa8c78aea5a5..8338b327fd2dd0d6b31653e278e25da5ac850939 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -153,6 +153,14 @@ typedef enum {
LCD_BITS_PER_PIXEL_12_444
} LCD_BPP;
+// Display timing settings.
+typedef struct {
+ UINT32 Resolution;
+ UINT32 Sync;
+ UINT32 BackPorch;
+ UINT32 FrontPorch;
+} SCAN_TIMINGS;
+
/** Platform related initialization function.
@param[in] Handle Handle to the LCD device instance.
@@ -228,14 +236,11 @@ LcdPlatformQueryMode (
@param[in] ModeNumber Mode Number.
- @param[out] HRes Pointer to horizontal resolution.
- @param[out] HSync Pointer to horizontal sync width.
- @param[out] HBackPorch Pointer to horizontal back porch.
- @param[out] HFrontPorch Pointer to horizontal front porch.
- @param[out] VRes Pointer to vertical resolution.
- @param[out] VSync Pointer to vertical sync width.
- @param[out] VBackPorch Pointer to vertical back porch.
- @param[out] VFrontPorch Pointer to vertical front porch.
+ @param[out] Horizontal Pointer to horizontal timing parameters.
+ (Resolution, Sync, Back porch, Front porch)
+ @param[out] Vertical Pointer to vertical timing parameters.
+ (Resolution, Sync, Back porch, Front porch)
+
@retval EFI_SUCCESS Display timing information for the requested
mode returned successfully.
@@ -244,14 +249,8 @@ LcdPlatformQueryMode (
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
- OUT UINT32* HRes,
- OUT UINT32* HSync,
- OUT UINT32* HBackPorch,
- OUT UINT32* HFrontPorch,
- OUT UINT32* VRes,
- OUT UINT32* VSync,
- OUT UINT32* VBackPorch,
- OUT UINT32* VFrontPorch
+ OUT SCAN_TIMINGS **Horizontal,
+ OUT SCAN_TIMINGS **Vertical
);
/** Return bits per pixel information for a mode number.
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index 039048398c531ec944bc4b43a5551a554a368481..f5886848ce582b475b597ccca015c816707ade0e 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -98,34 +98,25 @@ LcdSetMode (
)
{
EFI_STATUS Status;
- UINT32 HRes;
- UINT32 HSync;
- UINT32 HBackPorch;
- UINT32 HFrontPorch;
- UINT32 VRes;
- UINT32 VSync;
- UINT32 VBackPorch;
- UINT32 VFrontPorch;
+ SCAN_TIMINGS *Horizontal;
+ SCAN_TIMINGS *Vertical;
UINT32 BytesPerPixel;
LCD_BPP LcdBpp;
// Set the video mode timings and other relevant information
Status = LcdPlatformGetTimings (
ModeNumber,
- &HRes,
- &HSync,
- &HBackPorch,
- &HFrontPorch,
- &VRes,
- &VSync,
- &VBackPorch,
- &VFrontPorch
+ &Horizontal,
+ &Vertical
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
+
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
@@ -138,21 +129,26 @@ LcdSetMode (
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
// Update the frame buffer information with the new settings
- MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
- MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
- MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
+ MmioWrite32 (
+ HDLCD_REG_FB_LINE_LENGTH,
+ Horizontal->Resolution * BytesPerPixel
+ );
+
+ MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerPixel);
+
+ MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);
// Set the vertical timing information
- MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
- MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
- MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
- MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
+ MmioWrite32 (HDLCD_REG_V_SYNC, Vertical->Sync);
+ MmioWrite32 (HDLCD_REG_V_BACK_PORCH, Vertical->BackPorch);
+ MmioWrite32 (HDLCD_REG_V_DATA, Vertical->Resolution - 1);
+ MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, Vertical->FrontPorch);
// Set the horizontal timing information
- MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
- MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
- MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
- MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
+ MmioWrite32 (HDLCD_REG_H_SYNC, Horizontal->Sync);
+ MmioWrite32 (HDLCD_REG_H_BACK_PORCH, Horizontal->BackPorch);
+ MmioWrite32 (HDLCD_REG_H_DATA, Horizontal->Resolution - 1);
+ MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, Horizontal->FrontPorch);
// Enable the controller
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
diff --git a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
index b76894c534fb413d87c77c528f0bb7d49862c78f..492edd1ba2e57158c21920d6df11eed5673649c1 100644
--- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
+++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
@@ -123,14 +123,8 @@ LcdPlatformQueryMode (
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
- OUT UINT32* HRes,
- OUT UINT32* HSync,
- OUT UINT32* HBackPorch,
- OUT UINT32* HFrontPorch,
- OUT UINT32* VRes,
- OUT UINT32* VSync,
- OUT UINT32* VBackPorch,
- OUT UINT32* VFrontPorch
+ OUT SCAN_TIMINGS **Horizontal,
+ OUT SCAN_TIMINGS **Vertical
)
{
ASSERT (FALSE);
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index 465cb6845437f57d15f05a271d1b01f634e11b56..c9e2736911881fc36b51562b9259b7bccf30747d 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -84,34 +84,25 @@ LcdSetMode (
)
{
EFI_STATUS Status;
- UINT32 HRes;
- UINT32 HSync;
- UINT32 HBackPorch;
- UINT32 HFrontPorch;
- UINT32 VRes;
- UINT32 VSync;
- UINT32 VBackPorch;
- UINT32 VFrontPorch;
+ SCAN_TIMINGS *Horizontal;
+ SCAN_TIMINGS *Vertical;
UINT32 LcdControl;
LCD_BPP LcdBpp;
// Set the video mode timings and other relevant information
Status = LcdPlatformGetTimings (
ModeNumber,
- &HRes,
- &HSync,
- &HBackPorch,
- &HFrontPorch,
- &VRes,
- &VSync,
- &VBackPorch,
- &VFrontPorch
+ &Horizontal,
+ &Vertical
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
+
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
@@ -124,15 +115,29 @@ LcdSetMode (
// Set Timings
MmioWrite32 (
PL111_REG_LCD_TIMING_0,
- HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
+ HOR_AXIS_PANEL (
+ Horizontal->BackPorch,
+ Horizontal->FrontPorch,
+ Horizontal->Sync,
+ Horizontal->Resolution
+ )
);
MmioWrite32 (
PL111_REG_LCD_TIMING_1,
- VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
+ VER_AXIS_PANEL (
+ Vertical->BackPorch,
+ Vertical->FrontPorch,
+ Vertical->Sync,
+ Vertical->Resolution
+ )
+ );
+
+ MmioWrite32 (
+ PL111_REG_LCD_TIMING_2,
+ CLK_SIG_POLARITY (Horizontal->Resolution)
);
- MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
// PL111_REG_LCD_CONTROL
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function
2018-03-20 16:12 ` [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 09/16] ArmPlatformPkg: Redefine
> LcdPlatformGetTimings function
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> The LcdPlatformGetTimings interface function takes similar sets of multiple
> parameters for horizontal and vertical timings which can be aggregated in a
> common data type. This change defines a structure SCAN_TIMINGS for this
> which can be used to describe both horizontal and vertical scan timings,
> and accordingly redefines the LcdPlatformGetTiming interface, greatly
> reducing the amount of data passed about.
>
> 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 31 ++++++----
> --
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 50 +++++++++----
> -------
> ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 10 +---
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 43
> +++++++++--------
> 4 files changed, 64 insertions(+), 70 deletions(-)
>
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index
> e51e78640ae7b1acd51ac333ba3faa8c78aea5a5..8338b327fd2dd0d6b316
> 53e278e25da5ac850939 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -153,6 +153,14 @@ typedef enum {
> LCD_BITS_PER_PIXEL_12_444
> } LCD_BPP;
>
> +// Display timing settings.
> +typedef struct {
> + UINT32 Resolution;
> + UINT32 Sync;
> + UINT32 BackPorch;
> + UINT32 FrontPorch;
> +} SCAN_TIMINGS;
> +
> /** Platform related initialization function.
>
> @param[in] Handle Handle to the LCD device instance.
> @@ -228,14 +236,11 @@ LcdPlatformQueryMode (
>
> @param[in] ModeNumber Mode Number.
>
> - @param[out] HRes Pointer to horizontal resolution.
> - @param[out] HSync Pointer to horizontal sync width.
> - @param[out] HBackPorch Pointer to horizontal back porch.
> - @param[out] HFrontPorch Pointer to horizontal front porch.
> - @param[out] VRes Pointer to vertical resolution.
> - @param[out] VSync Pointer to vertical sync width.
> - @param[out] VBackPorch Pointer to vertical back porch.
> - @param[out] VFrontPorch Pointer to vertical front porch.
> + @param[out] Horizontal Pointer to horizontal timing parameters.
> + (Resolution, Sync, Back porch, Front porch)
> + @param[out] Vertical Pointer to vertical timing parameters.
> + (Resolution, Sync, Back porch, Front
> + porch)
> +
>
> @retval EFI_SUCCESS Display timing information for the requested
> mode returned successfully.
> @@ -244,14 +249,8 @@ LcdPlatformQueryMode ( EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + OUT SCAN_TIMINGS **Horizontal,
> + OUT SCAN_TIMINGS **Vertical
> );
>
> /** Return bits per pixel information for a mode number.
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> 039048398c531ec944bc4b43a5551a554a368481..f5886848ce582b475b5
> 97ccca015c816707ade0e 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -98,34 +98,25 @@ LcdSetMode (
> )
> {
> EFI_STATUS Status;
> - UINT32 HRes;
> - UINT32 HSync;
> - UINT32 HBackPorch;
> - UINT32 HFrontPorch;
> - UINT32 VRes;
> - UINT32 VSync;
> - UINT32 VBackPorch;
> - UINT32 VFrontPorch;
> + SCAN_TIMINGS *Horizontal;
> + SCAN_TIMINGS *Vertical;
> UINT32 BytesPerPixel;
> LCD_BPP LcdBpp;
>
> // Set the video mode timings and other relevant information
> Status = LcdPlatformGetTimings (
> ModeNumber,
> - &HRes,
> - &HSync,
> - &HBackPorch,
> - &HFrontPorch,
> - &VRes,
> - &VSync,
> - &VBackPorch,
> - &VFrontPorch
> + &Horizontal,
> + &Vertical
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> +
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> @@ -138,21 +129,26 @@ LcdSetMode (
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>
> // Update the frame buffer information with the new settings
> - MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
> - MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
> - MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
> + MmioWrite32 (
> + HDLCD_REG_FB_LINE_LENGTH,
> + Horizontal->Resolution * BytesPerPixel
> + );
> +
> + MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution *
> + BytesPerPixel);
> +
> + MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);
>
> // Set the vertical timing information
> - MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
> - MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
> - MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
> - MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
> + MmioWrite32 (HDLCD_REG_V_SYNC, Vertical->Sync);
> + MmioWrite32 (HDLCD_REG_V_BACK_PORCH, Vertical->BackPorch);
> + MmioWrite32 (HDLCD_REG_V_DATA, Vertical->Resolution - 1);
> + MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, Vertical->FrontPorch);
>
> // Set the horizontal timing information
> - MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
> - MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
> - MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
> - MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
> + MmioWrite32 (HDLCD_REG_H_SYNC, Horizontal->Sync);
> + MmioWrite32 (HDLCD_REG_H_BACK_PORCH, Horizontal->BackPorch);
> + MmioWrite32 (HDLCD_REG_H_DATA, Horizontal->Resolution - 1);
> + MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, Horizontal->FrontPorch);
>
> // Enable the controller
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE); diff --git
> a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> index
> b76894c534fb413d87c77c528f0bb7d49862c78f..492edd1ba2e57158c219
> 20d6df11eed5673649c1 100644
> --- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> +++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c
> @@ -123,14 +123,8 @@ LcdPlatformQueryMode ( EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + OUT SCAN_TIMINGS **Horizontal,
> + OUT SCAN_TIMINGS **Vertical
> )
> {
> ASSERT (FALSE);
> diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> 465cb6845437f57d15f05a271d1b01f634e11b56..c9e2736911881fc36b51
> 562b9259b7bccf30747d 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -84,34 +84,25 @@ LcdSetMode (
> )
> {
> EFI_STATUS Status;
> - UINT32 HRes;
> - UINT32 HSync;
> - UINT32 HBackPorch;
> - UINT32 HFrontPorch;
> - UINT32 VRes;
> - UINT32 VSync;
> - UINT32 VBackPorch;
> - UINT32 VFrontPorch;
> + SCAN_TIMINGS *Horizontal;
> + SCAN_TIMINGS *Vertical;
> UINT32 LcdControl;
> LCD_BPP LcdBpp;
>
> // Set the video mode timings and other relevant information
> Status = LcdPlatformGetTimings (
> ModeNumber,
> - &HRes,
> - &HSync,
> - &HBackPorch,
> - &HFrontPorch,
> - &VRes,
> - &VSync,
> - &VBackPorch,
> - &VFrontPorch
> + &Horizontal,
> + &Vertical
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> +
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> @@ -124,15 +115,29 @@ LcdSetMode (
> // Set Timings
> MmioWrite32 (
> PL111_REG_LCD_TIMING_0,
> - HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
> + HOR_AXIS_PANEL (
> + Horizontal->BackPorch,
> + Horizontal->FrontPorch,
> + Horizontal->Sync,
> + Horizontal->Resolution
> + )
> );
>
> MmioWrite32 (
> PL111_REG_LCD_TIMING_1,
> - VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
> + VER_AXIS_PANEL (
> + Vertical->BackPorch,
> + Vertical->FrontPorch,
> + Vertical->Sync,
> + Vertical->Resolution
> + )
> + );
> +
> + MmioWrite32 (
> + PL111_REG_LCD_TIMING_2,
> + CLK_SIG_POLARITY (Horizontal->Resolution)
> );
>
> - MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
> MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
>
> // PL111_REG_LCD_CONTROL
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (8 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD Girish Pathak
` (6 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
Current HDLCD and PL111 platform libraries do not support display modes
with PixelBlueGreenRedReserved8BitPerColor format, i.e. because of
historical confusion, they do not support the UEFI default
PixelBlueGreenRedReserved8BitPerColor format
In LcdPlatformLib for PL111, LcdPlatformQueryMode returns the pixel
format as PixelRedGreenBlueReserved8BitPerColor which is wrong, because
that does not match the display controller's pixel format which is set
to BGR in PL111Lcd LcdHwLib.
Also it is not possible to configure pixel format as RGB/BGR for the
display modes for a platform at build time.
This change adds PcdGopPixelFormat to configure pixel format as
PixelRedGreenBlueReserved8BitPerColor or
PixelBlueGreenRedReserved8BitPerColor or
PixelBitMask.
With this change, pixel format can be selected in the platform specific
.dsc file for all supported display modes.
Support for PixelBitMask is not implemented in PL111 or HDLCD LcdHwLib
libraries, hence HDLCD and PL111 platform libraries will return error
EFI_UNSUPPORTED if PcdGopPixelFormat is set to PixelBitMask. Indeed,
it is not clear what selecting PixelBitMask might mean, but the option
is allowed as it might suit a custom 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 9 +++-
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 54 +++++++-------------
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 15 +++++-
3 files changed, 40 insertions(+), 38 deletions(-)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 7cec775abeee219e6821488a2c5abe88d23bbed1..378bee9cbc9e4bd50c37b38156016424e24cba73 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -1,6 +1,6 @@
#/** @file
#
-# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2018, ARM Limited. All rights reserved.
# Copyright (c) 2015, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials
@@ -97,6 +97,13 @@ [PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
+ # Graphics Output Pixel format
+ # 0 : PixelRedGreenBlueReserved8BitPerColor
+ # 1 : PixelBlueGreenRedReserved8BitPerColor
+ # 2 : PixelBitMask
+ # Default is set to UEFI console font format PixelBlueGreenRedReserved8BitPerColor
+ gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040
+
[PcdsFixedAtBuild.common,PcdsDynamic.common]
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index f5886848ce582b475b597ccca015c816707ade0e..96f2bf437fbabd2509f860c67c5442def5b5f03d 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -22,31 +22,7 @@
#include "HdLcd.h"
-STATIC
-UINTN
-GetBytesPerPixel (
- IN LCD_BPP Bpp
- )
-{
- switch (Bpp) {
- case LCD_BITS_PER_PIXEL_24:
- return 4;
-
- case LCD_BITS_PER_PIXEL_16_565:
- case LCD_BITS_PER_PIXEL_16_555:
- case LCD_BITS_PER_PIXEL_12_444:
- return 2;
-
- case LCD_BITS_PER_PIXEL_8:
- case LCD_BITS_PER_PIXEL_4:
- case LCD_BITS_PER_PIXEL_2:
- case LCD_BITS_PER_PIXEL_1:
- return 1;
-
- default:
- return 0;
- }
-}
+#define BYTES_PER_PIXEL 4
/** Initialize display.
@@ -78,10 +54,6 @@ LcdInitialize (
HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL
);
- MmioWrite32 (HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));
- MmioWrite32 (HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));
- MmioWrite32 (HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));
-
return EFI_SUCCESS;
}
@@ -100,8 +72,8 @@ LcdSetMode (
EFI_STATUS Status;
SCAN_TIMINGS *Horizontal;
SCAN_TIMINGS *Vertical;
- UINT32 BytesPerPixel;
- LCD_BPP LcdBpp;
+
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
// Set the video mode timings and other relevant information
Status = LcdPlatformGetTimings (
@@ -117,13 +89,22 @@ LcdSetMode (
ASSERT (Horizontal != NULL);
ASSERT (Vertical != NULL);
- Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
+ // Get the pixel format information.
+ Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
- BytesPerPixel = GetBytesPerPixel (LcdBpp);
+ if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 16);
+ MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 0);
+ } else {
+ MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 16);
+ MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 0);
+ }
+
+ MmioWrite32 (HDLCD_REG_GREEN_SELECT, (8 << 8) | 8);
// Disable the controller
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
@@ -131,10 +112,13 @@ LcdSetMode (
// Update the frame buffer information with the new settings
MmioWrite32 (
HDLCD_REG_FB_LINE_LENGTH,
- Horizontal->Resolution * BytesPerPixel
+ Horizontal->Resolution * BYTES_PER_PIXEL
);
- MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerPixel);
+ MmioWrite32 (
+ HDLCD_REG_FB_LINE_PITCH,
+ Horizontal->Resolution * BYTES_PER_PIXEL
+ );
MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);
diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
index c9e2736911881fc36b51562b9259b7bccf30747d..0496376fffe514651a70f58a3316894a4b2b319c 100644
--- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
+++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
@@ -76,7 +76,6 @@ LcdInitialize (
@retval EFI_SUCCESS Display mode set successfuly.
@retval !(EFI_SUCCESS) Other errors.
-
**/
EFI_STATUS
LcdSetMode (
@@ -89,6 +88,8 @@ LcdSetMode (
UINT32 LcdControl;
LCD_BPP LcdBpp;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
+
// Set the video mode timings and other relevant information
Status = LcdPlatformGetTimings (
ModeNumber,
@@ -109,6 +110,13 @@ LcdSetMode (
return Status;
}
+ // Get the pixel format information
+ Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
// Disable the CLCD_LcdEn bit
MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
@@ -142,7 +150,10 @@ LcdSetMode (
// PL111_REG_LCD_CONTROL
LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
- PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR | PL111_CTRL_BGR;
+ PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR;
+ if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ LcdControl |= PL111_CTRL_BGR;
+ }
MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
return EFI_SUCCESS;
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format
2018-03-20 16:12 ` [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel
> format
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> Current HDLCD and PL111 platform libraries do not support display modes
> with PixelBlueGreenRedReserved8BitPerColor format, i.e. because of
> historical confusion, they do not support the UEFI default
> PixelBlueGreenRedReserved8BitPerColor format
>
> In LcdPlatformLib for PL111, LcdPlatformQueryMode returns the pixel
> format as PixelRedGreenBlueReserved8BitPerColor which is wrong, because
> that does not match the display controller's pixel format which is set to
> BGR in PL111Lcd LcdHwLib.
>
> Also it is not possible to configure pixel format as RGB/BGR for the display
> modes for a platform at build time.
>
> This change adds PcdGopPixelFormat to configure pixel format as
> PixelRedGreenBlueReserved8BitPerColor or
> PixelBlueGreenRedReserved8BitPerColor or
> PixelBitMask.
> With this change, pixel format can be selected in the platform specific .dsc
> file for all supported display modes.
>
> Support for PixelBitMask is not implemented in PL111 or HDLCD LcdHwLib
> libraries, hence HDLCD and PL111 platform libraries will return error
> EFI_UNSUPPORTED if PcdGopPixelFormat is set to PixelBitMask. Indeed, it
> is not clear what selecting PixelBitMask might mean, but the option is
> allowed as it might suit a custom 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 9 +++-
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 54 +++++++-------------
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 15 +++++-
> 3 files changed, 40 insertions(+), 38 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec
> b/ArmPlatformPkg/ArmPlatformPkg.dec
> index
> 7cec775abeee219e6821488a2c5abe88d23bbed1..378bee9cbc9e4bd50c37
> b38156016424e24cba73 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -1,6 +1,6 @@
> #/** @file
> #
> -# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
> +# Copyright (c) 2011-2018, ARM Limited. All rights reserved.
> # Copyright (c) 2015, Intel Corporation. All rights reserved.
> #
> # This program and the accompanying materials @@ -97,6 +97,13 @@
> [PcdsFixedAtBuild.common]
>
> gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|
> UINT32|0x00000028
>
> gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UI
> NT32|0x00000029
>
> + # Graphics Output Pixel format
> + # 0 : PixelRedGreenBlueReserved8BitPerColor
> + # 1 : PixelBlueGreenRedReserved8BitPerColor
> + # 2 : PixelBitMask
> + # Default is set to UEFI console font format
> + PixelBlueGreenRedReserved8BitPerColor
> +
> +
> gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0
> x00000
> + 040
> +
> [PcdsFixedAtBuild.common,PcdsDynamic.common]
> ## PL031 RealTimeClock
>
> gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> f5886848ce582b475b597ccca015c816707ade0e..96f2bf437fbabd2509f86
> 0c67c5442def5b5f03d 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -22,31 +22,7 @@
>
> #include "HdLcd.h"
>
> -STATIC
> -UINTN
> -GetBytesPerPixel (
> - IN LCD_BPP Bpp
> - )
> -{
> - switch (Bpp) {
> - case LCD_BITS_PER_PIXEL_24:
> - return 4;
> -
> - case LCD_BITS_PER_PIXEL_16_565:
> - case LCD_BITS_PER_PIXEL_16_555:
> - case LCD_BITS_PER_PIXEL_12_444:
> - return 2;
> -
> - case LCD_BITS_PER_PIXEL_8:
> - case LCD_BITS_PER_PIXEL_4:
> - case LCD_BITS_PER_PIXEL_2:
> - case LCD_BITS_PER_PIXEL_1:
> - return 1;
> -
> - default:
> - return 0;
> - }
> -}
> +#define BYTES_PER_PIXEL 4
>
> /** Initialize display.
>
> @@ -78,10 +54,6 @@ LcdInitialize (
> HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL
> );
>
> - MmioWrite32 (HDLCD_REG_RED_SELECT, (0 << 16 | 8 << 8 | 0));
> - MmioWrite32 (HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));
> - MmioWrite32 (HDLCD_REG_BLUE_SELECT, (0 << 16 | 8 << 8 | 16));
> -
> return EFI_SUCCESS;
> }
>
> @@ -100,8 +72,8 @@ LcdSetMode (
> EFI_STATUS Status;
> SCAN_TIMINGS *Horizontal;
> SCAN_TIMINGS *Vertical;
> - UINT32 BytesPerPixel;
> - LCD_BPP LcdBpp;
> +
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
>
> // Set the video mode timings and other relevant information
> Status = LcdPlatformGetTimings (
> @@ -117,13 +89,22 @@ LcdSetMode (
> ASSERT (Horizontal != NULL);
> ASSERT (Vertical != NULL);
>
> - Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> + // Get the pixel format information.
> + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> - BytesPerPixel = GetBytesPerPixel (LcdBpp);
> + if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 16);
> + MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 0); } else {
> + MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 16);
> + MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 0); }
> +
> + MmioWrite32 (HDLCD_REG_GREEN_SELECT, (8 << 8) | 8);
>
> // Disable the controller
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); @@ -131,10
> +112,13 @@ LcdSetMode (
> // Update the frame buffer information with the new settings
> MmioWrite32 (
> HDLCD_REG_FB_LINE_LENGTH,
> - Horizontal->Resolution * BytesPerPixel
> + Horizontal->Resolution * BYTES_PER_PIXEL
> );
>
> - MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution *
> BytesPerPixel);
> + MmioWrite32 (
> + HDLCD_REG_FB_LINE_PITCH,
> + Horizontal->Resolution * BYTES_PER_PIXEL
> + );
>
> MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);
>
> diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> index
> c9e2736911881fc36b51562b9259b7bccf30747d..0496376fffe514651a70f
> 58a3316894a4b2b319c 100644
> --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c
> @@ -76,7 +76,6 @@ LcdInitialize (
>
> @retval EFI_SUCCESS Display mode set successfuly.
> @retval !(EFI_SUCCESS) Other errors.
> -
> **/
> EFI_STATUS
> LcdSetMode (
> @@ -89,6 +88,8 @@ LcdSetMode (
> UINT32 LcdControl;
> LCD_BPP LcdBpp;
>
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
> +
> // Set the video mode timings and other relevant information
> Status = LcdPlatformGetTimings (
> ModeNumber,
> @@ -109,6 +110,13 @@ LcdSetMode (
> return Status;
> }
>
> + // Get the pixel format information
> + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo); if
> (EFI_ERROR
> + (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> // Disable the CLCD_LcdEn bit
> MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
>
> @@ -142,7 +150,10 @@ LcdSetMode (
>
> // PL111_REG_LCD_CONTROL
> LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
> - PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR |
> PL111_CTRL_BGR;
> + PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR; if
> + (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + LcdControl |= PL111_CTRL_BGR;
> + }
> MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> return EFI_SUCCESS;
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (9 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:53 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 12/16] ArmPlatformPkg: Additional display modes Girish Pathak
` (5 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
This change adds a new PCD PcdArmHdlcdSwapBlueRedSelect
to swap values for HDLCD RED_SELECT and BLUE_SELECT registers
on platforms where blue and red hardware lines are swapped.
If set to TRUE in the platform dsc, HDLCD library will swap the values
while setting RED_SELECT and BLUE_SELECT registers. The default
value of the PCD is FALSE.
NOTE: The motive for this is that a discrepancy in the Red/Blue lines
exists between some VersatileExpress platforms. Rather than have
divergent code, this build switch allows a simple, pragmatic solution.
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>
---
Notes:
v3:
- Please don't nest CPP and C conditionals like this.
It is difficult to follow, and results in poor build
time coverage (the non-taken branch at the CPP level
is never seen by the compiler) [Ard]
Done [Girish]
ArmPlatformPkg/ArmPlatformPkg.dec | 3 +++
ArmPlatformPkg/Library/HdLcd/HdLcd.c | 11 ++++++++++-
ArmPlatformPkg/Library/HdLcd/HdLcd.inf | 4 +++-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 378bee9cbc9e4bd50c37b38156016424e24cba73..5231ea822f05c2f281a6190d6eae0fc7d0bc0cb3 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -104,6 +104,9 @@ [PcdsFixedAtBuild.common]
# Default is set to UEFI console font format PixelBlueGreenRedReserved8BitPerColor
gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040
+ ## If set, this will swap settings for HDLCD RED_SELECT and BLUE_SELECT registers
+ gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|FALSE|BOOLEAN|0x00000045
+
[PcdsFixedAtBuild.common,PcdsDynamic.common]
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
index 96f2bf437fbabd2509f860c67c5442def5b5f03d..5396dde3ba6cd147a8333241a9bc71ab05d7fee3 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
@@ -73,6 +73,8 @@ LcdSetMode (
SCAN_TIMINGS *Horizontal;
SCAN_TIMINGS *Vertical;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
// Set the video mode timings and other relevant information
@@ -96,7 +98,14 @@ LcdSetMode (
return Status;
}
- if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ // By default PcdArmHdLcdSwapBlueRedSelect is set to false
+ // However on the Juno platform HW lines for BLUE and RED are swapped
+ // Therefore PcdArmHdLcdSwapBlueRedSelect is set to TRUE for the Juno platform
+ PixelFormat = FixedPcdGetBool (PcdArmHdLcdSwapBlueRedSelect)
+ ? PixelRedGreenBlueReserved8BitPerColor
+ : PixelBlueGreenRedReserved8BitPerColor;
+
+ if (ModeInfo.PixelFormat == PixelFormat) {
MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 16);
MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 0);
} else {
diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.inf b/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
index 67aad05d210b95b2d23b8e52e4392685efcf3795..7f2ba7bf1c602f4c214eacaa6425bf9ec7e6da15 100644
--- a/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
+++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
@@ -2,7 +2,7 @@
#
# Component description file for HDLCD module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-2018, 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
@@ -40,3 +40,5 @@ [LibraryClasses]
[FixedPcd]
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
+ gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect
+
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD
2018-03-20 16:12 ` [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD Girish Pathak
@ 2018-03-21 12:53 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:53 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue
> format for HDLCD
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change adds a new PCD PcdArmHdlcdSwapBlueRedSelect to swap
> values for HDLCD RED_SELECT and BLUE_SELECT registers on platforms
> where blue and red hardware lines are swapped.
>
> If set to TRUE in the platform dsc, HDLCD library will swap the values while
> setting RED_SELECT and BLUE_SELECT registers. The default value of the
> PCD is FALSE.
>
> NOTE: The motive for this is that a discrepancy in the Red/Blue lines exists
> between some VersatileExpress platforms. Rather than have divergent code,
> this build switch allows a simple, pragmatic solution.
>
> 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>
> ---
>
> Notes:
> v3:
> - Please don't nest CPP and C conditionals like this.
> It is difficult to follow, and results in poor build
> time coverage (the non-taken branch at the CPP level
> is never seen by the compiler) [Ard]
>
> Done [Girish]
>
> ArmPlatformPkg/ArmPlatformPkg.dec | 3 +++
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 11 ++++++++++-
> ArmPlatformPkg/Library/HdLcd/HdLcd.inf | 4 +++-
> 3 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec
> b/ArmPlatformPkg/ArmPlatformPkg.dec
> index
> 378bee9cbc9e4bd50c37b38156016424e24cba73..5231ea822f05c2f281a6
> 190d6eae0fc7d0bc0cb3 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -104,6 +104,9 @@ [PcdsFixedAtBuild.common]
> # Default is set to UEFI console font format
> PixelBlueGreenRedReserved8BitPerColor
>
> gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0
> x00000040
>
> + ## If set, this will swap settings for HDLCD RED_SELECT and
> + BLUE_SELECT registers
> +
> +
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|FALSE|BO
> OLEAN|
> + 0x00000045
> +
> [PcdsFixedAtBuild.common,PcdsDynamic.common]
> ## PL031 RealTimeClock
>
> gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> index
> 96f2bf437fbabd2509f860c67c5442def5b5f03d..5396dde3ba6cd147a8333
> 241a9bc71ab05d7fee3 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c
> @@ -73,6 +73,8 @@ LcdSetMode (
> SCAN_TIMINGS *Horizontal;
> SCAN_TIMINGS *Vertical;
>
> + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
>
> // Set the video mode timings and other relevant information @@ -96,7
> +98,14 @@ LcdSetMode (
> return Status;
> }
>
> - if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + // By default PcdArmHdLcdSwapBlueRedSelect is set to false //
> + However on the Juno platform HW lines for BLUE and RED are swapped //
> + Therefore PcdArmHdLcdSwapBlueRedSelect is set to TRUE for the Juno
> + platform PixelFormat = FixedPcdGetBool
> (PcdArmHdLcdSwapBlueRedSelect)
> + ? PixelRedGreenBlueReserved8BitPerColor
> + : PixelBlueGreenRedReserved8BitPerColor;
> +
> + if (ModeInfo.PixelFormat == PixelFormat) {
> MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8) | 16);
> MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 0);
> } else {
> diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
> b/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
> index
> 67aad05d210b95b2d23b8e52e4392685efcf3795..7f2ba7bf1c602f4c214ea
> caa6425bf9ec7e6da15 100644
> --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
> +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.inf
> @@ -2,7 +2,7 @@
> #
> # Component description file for HDLCD module # -# Copyright (c) 2011-
> 2012, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011-2018, 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 @@ -40,3
> +40,5 @@ [LibraryClasses]
>
> [FixedPcd]
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
> + gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect
> +
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 12/16] ArmPlatformPkg: Additional display modes
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (10 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build Girish Pathak
` (4 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
Add definitions for new display modes such as HD 720.
This has no effect on existing display drivers.
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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 60 ++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index 8338b327fd2dd0d6b31653e278e25da5ac850939..cc535f0cd42db5673d418cbec940023927408687 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -26,6 +26,11 @@
#define WSXGA 4
#define UXGA 5
#define HD 6
+#define WVGA 7
+#define QHD 8
+#define WSVGA 9
+#define HD720 10
+#define WXGA 11
// VGA Mode: 640 x 480
#define VGA_H_RES_PIXELS 640
@@ -118,6 +123,61 @@
#define HD_V_FRONT_PORCH ( 3 - 1)
#define HD_V_BACK_PORCH ( 32 - 1)
+// WVGA Mode: 800 x 480
+#define WVGA_H_RES_PIXELS 800
+#define WVGA_V_RES_PIXELS 480
+#define WVGA_OSC_FREQUENCY 29500000 /* 0x01C22260 */
+#define WVGA_H_SYNC ( 72 - 1)
+#define WVGA_H_FRONT_PORCH ( 24 - 1)
+#define WVGA_H_BACK_PORCH ( 96 - 1)
+#define WVGA_V_SYNC ( 7 - 1)
+#define WVGA_V_FRONT_PORCH ( 3 - 1)
+#define WVGA_V_BACK_PORCH ( 10 - 1)
+
+// QHD Mode: 960 x 540
+#define QHD_H_RES_PIXELS 960
+#define QHD_V_RES_PIXELS 540
+#define QHD_OSC_FREQUENCY 40750000 /* 0x026DCBB0 */
+#define QHD_H_SYNC ( 96 - 1)
+#define QHD_H_FRONT_PORCH ( 32 - 1)
+#define QHD_H_BACK_PORCH (128 - 1)
+#define QHD_V_SYNC ( 5 - 1)
+#define QHD_V_FRONT_PORCH ( 3 - 1)
+#define QHD_V_BACK_PORCH ( 14 - 1)
+
+// WSVGA Mode: 1024 x 600
+#define WSVGA_H_RES_PIXELS 1024
+#define WSVGA_V_RES_PIXELS 600
+#define WSVGA_OSC_FREQUENCY 49000000 /* 0x02EBAE40 */
+#define WSVGA_H_SYNC (104 - 1)
+#define WSVGA_H_FRONT_PORCH ( 40 - 1)
+#define WSVGA_H_BACK_PORCH (144 - 1)
+#define WSVGA_V_SYNC ( 10 - 1)
+#define WSVGA_V_FRONT_PORCH ( 3 - 1)
+#define WSVGA_V_BACK_PORCH ( 11 - 1)
+
+// HD720 Mode: 1280 x 720
+#define HD720_H_RES_PIXELS 1280
+#define HD720_V_RES_PIXELS 720
+#define HD720_OSC_FREQUENCY 74500000 /* 0x0470C7A0 */
+#define HD720_H_SYNC (128 - 1)
+#define HD720_H_FRONT_PORCH ( 64 - 1)
+#define HD720_H_BACK_PORCH (192 - 1)
+#define HD720_V_SYNC ( 5 - 1)
+#define HD720_V_FRONT_PORCH ( 3 - 1)
+#define HD720_V_BACK_PORCH ( 20 - 1)
+
+// WXGA Mode: 1280 x 800
+#define WXGA_H_RES_PIXELS 1280
+#define WXGA_V_RES_PIXELS 800
+#define WXGA_OSC_FREQUENCY 83500000 /* 0x04FA1BE0 */
+#define WXGA_H_SYNC (128 - 1)
+#define WXGA_H_FRONT_PORCH ( 72 - 1)
+#define WXGA_H_BACK_PORCH (200 - 1)
+#define WXGA_V_SYNC ( 6 - 1)
+#define WXGA_V_FRONT_PORCH ( 3 - 1)
+#define WXGA_V_BACK_PORCH ( 22 - 1)
+
// Colour Masks
#define LCD_24BPP_RED_MASK 0x00FF0000
#define LCD_24BPP_GREEN_MASK 0x0000FF00
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 12/16] ArmPlatformPkg: Additional display modes
2018-03-20 16:12 ` [PATCH v3 12/16] ArmPlatformPkg: Additional display modes Girish Pathak
@ 2018-03-21 12:54 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:54 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 12/16] ArmPlatformPkg: Additional display
> modes
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> Add definitions for new display modes such as HD 720.
> This has no effect on existing display drivers.
>
> 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 60
> ++++++++++++++++++++
> 1 file changed, 60 insertions(+)
>
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index
> 8338b327fd2dd0d6b31653e278e25da5ac850939..cc535f0cd42db5673d41
> 8cbec940023927408687 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -26,6 +26,11 @@
> #define WSXGA 4
> #define UXGA 5
> #define HD 6
> +#define WVGA 7
> +#define QHD 8
> +#define WSVGA 9
> +#define HD720 10
> +#define WXGA 11
>
> // VGA Mode: 640 x 480
> #define VGA_H_RES_PIXELS 640
> @@ -118,6 +123,61 @@
> #define HD_V_FRONT_PORCH ( 3 - 1)
> #define HD_V_BACK_PORCH ( 32 - 1)
>
> +// WVGA Mode: 800 x 480
> +#define WVGA_H_RES_PIXELS 800
> +#define WVGA_V_RES_PIXELS 480
> +#define WVGA_OSC_FREQUENCY 29500000 /* 0x01C22260 */
> +#define WVGA_H_SYNC ( 72 - 1)
> +#define WVGA_H_FRONT_PORCH ( 24 - 1)
> +#define WVGA_H_BACK_PORCH ( 96 - 1)
> +#define WVGA_V_SYNC ( 7 - 1)
> +#define WVGA_V_FRONT_PORCH ( 3 - 1)
> +#define WVGA_V_BACK_PORCH ( 10 - 1)
> +
> +// QHD Mode: 960 x 540
> +#define QHD_H_RES_PIXELS 960
> +#define QHD_V_RES_PIXELS 540
> +#define QHD_OSC_FREQUENCY 40750000 /* 0x026DCBB0 */
> +#define QHD_H_SYNC ( 96 - 1)
> +#define QHD_H_FRONT_PORCH ( 32 - 1)
> +#define QHD_H_BACK_PORCH (128 - 1)
> +#define QHD_V_SYNC ( 5 - 1)
> +#define QHD_V_FRONT_PORCH ( 3 - 1)
> +#define QHD_V_BACK_PORCH ( 14 - 1)
> +
> +// WSVGA Mode: 1024 x 600
> +#define WSVGA_H_RES_PIXELS 1024
> +#define WSVGA_V_RES_PIXELS 600
> +#define WSVGA_OSC_FREQUENCY 49000000 /* 0x02EBAE40 */
> +#define WSVGA_H_SYNC (104 - 1)
> +#define WSVGA_H_FRONT_PORCH ( 40 - 1)
> +#define WSVGA_H_BACK_PORCH (144 - 1)
> +#define WSVGA_V_SYNC ( 10 - 1)
> +#define WSVGA_V_FRONT_PORCH ( 3 - 1)
> +#define WSVGA_V_BACK_PORCH ( 11 - 1)
> +
> +// HD720 Mode: 1280 x 720
> +#define HD720_H_RES_PIXELS 1280
> +#define HD720_V_RES_PIXELS 720
> +#define HD720_OSC_FREQUENCY 74500000 /* 0x0470C7A0 */
> +#define HD720_H_SYNC (128 - 1)
> +#define HD720_H_FRONT_PORCH ( 64 - 1)
> +#define HD720_H_BACK_PORCH (192 - 1)
> +#define HD720_V_SYNC ( 5 - 1)
> +#define HD720_V_FRONT_PORCH ( 3 - 1)
> +#define HD720_V_BACK_PORCH ( 20 - 1)
> +
> +// WXGA Mode: 1280 x 800
> +#define WXGA_H_RES_PIXELS 1280
> +#define WXGA_V_RES_PIXELS 800
> +#define WXGA_OSC_FREQUENCY 83500000 /* 0x04FA1BE0 */
> +#define WXGA_H_SYNC (128 - 1)
> +#define WXGA_H_FRONT_PORCH ( 72 - 1)
> +#define WXGA_H_BACK_PORCH (200 - 1)
> +#define WXGA_V_SYNC ( 6 - 1)
> +#define WXGA_V_FRONT_PORCH ( 3 - 1)
> +#define WXGA_V_BACK_PORCH ( 22 - 1)
> +
> // Colour Masks
> #define LCD_24BPP_RED_MASK 0x00FF0000
> #define LCD_24BPP_GREEN_MASK 0x0000FF00
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (11 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 12/16] ArmPlatformPkg: Additional display modes Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver Girish Pathak
` (3 subsequent siblings)
16 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
Currently framebuffer memory is either reserved in special VRAM or
dynamically allocated using boot services memory allocation functions.
When allocated using boot services calls the memory has to be allocated
as EfiBootServicesData. Unfortunately failures have been seen with this
case. There is also an unfortunate lack of control on the placement of
the framebuffer.
This change introduces two PCDs, PcdArmLcdFrameBufferBase and
PcdArmLcdFrameBufferSize which enable build time reservation of the
framebuffer, avoiding the need to allocate dynamically. This allows
the framebuffer to appear as "I/O memory" outside of the normal RAM
map, which is similar to the "VRAM" case.
This change has no impact on current code, only enables the option
of build time reservation of framebuffers.
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>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 5231ea822f05c2f281a6190d6eae0fc7d0bc0cb3..5c702718a78a78e6c67ab407e198382e0a0df4be 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -93,6 +93,11 @@ [PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
+ ## Default size for display modes upto 1920x1080 (1920 * 1080 * 4 Bytes Per Pixel)
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x7E9000|UINT32|0x00000043
+ ## If set, framebuffer memory will be reserved and mapped in the system RAM
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000044
+
## PL180 MCI
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build
2018-03-20 16:12 ` [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build Girish Pathak
@ 2018-03-21 12:54 ` Evan Lloyd
0 siblings, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:54 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer
> at build
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> Currently framebuffer memory is either reserved in special VRAM or
> dynamically allocated using boot services memory allocation functions.
> When allocated using boot services calls the memory has to be allocated as
> EfiBootServicesData. Unfortunately failures have been seen with this case.
> There is also an unfortunate lack of control on the placement of the
> framebuffer.
>
> This change introduces two PCDs, PcdArmLcdFrameBufferBase and
> PcdArmLcdFrameBufferSize which enable build time reservation of the
> framebuffer, avoiding the need to allocate dynamically. This allows the
> framebuffer to appear as "I/O memory" outside of the normal RAM map,
> which is similar to the "VRAM" case.
>
> This change has no impact on current code, only enables the option of build
> time reservation of framebuffers.
>
> 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>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec
> b/ArmPlatformPkg/ArmPlatformPkg.dec
> index
> 5231ea822f05c2f281a6190d6eae0fc7d0bc0cb3..5c702718a78a78e6c67ab
> 407e198382e0a0df4be 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -93,6 +93,11 @@ [PcdsFixedAtBuild.common]
>
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x0000002
> 6
>
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x0000002
> 7
>
> + ## Default size for display modes upto 1920x1080 (1920 * 1080 * 4
> + Bytes Per Pixel)
> +
> +
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x7E9000|
> UINT32
> + |0x00000043 ## If set, framebuffer memory will be reserved and
> mapped
> + in the system RAM
> +
> +
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT6
> 4|0x00
> + 000044
> +
> ## PL180 MCI
>
> gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|
> UINT32|0x00000028
>
> gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UI
> NT32|0x00000029
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (12 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
2018-04-23 11:07 ` Leif Lindholm
2018-03-20 16:12 ` [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation Girish Pathak
` (2 subsequent siblings)
16 siblings, 2 replies; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
From: Girish Pathak <girish.pathak at arm.com>
This change adds support for the ARM Mali DP500/DP500/DP650 display
processors using the GOP protocol. It has been tested on FVP base
models + DP550 support. This change adds platform independant LcdHwLib
library. A corresponding platform specific library will be submitted
to edk-platforms/Platform/ARM/VExpressPkg.
This change does not modify functionality provided by PL111 or
HDLCD. This LcdHwLib implementation should be suitable for those
platforms that implement ARM Mali DP500/DP550/DP650 replacing
PL111/HDLCD.
Only graphics layer of the ARM Mali DP is configured for rendering
the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
Other layers e.g. video layers are not configured.
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>
---
Notes:
v3:
- Please add this library as a component to
ArmPlatformPkg.dsc as well, so we can do build testing
on it. [Ard]
Done [Girish]
- Please drop references to edk2-platforms.
This driver should be able to be used independently
from VExpress platform code [Ard]
Done [Girish]
ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +-
ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c | 409 ++++++++++++++++++++
ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h | 243 ++++++++++++
ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf | 43 ++
5 files changed, 702 insertions(+), 1 deletion(-)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 5c702718a78a78e6c67ab407e198382e0a0df4be..28cdc259849da11b172ad52045bccc0276669852 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -98,6 +98,10 @@ [PcdsFixedAtBuild.common]
## If set, framebuffer memory will be reserved and mapped in the system RAM
gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000044
+ ## ARM Mali Display Processor DP500/DP550/DP650
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x00000050
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|UINT32|0x00000051
+
## PL180 MCI
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 82adb9ef8891b7ba1628ede2f8eb124c25c2774a..0013106b94c371f827e01c6d402faa6aa42e4bdd 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -2,7 +2,7 @@
# ARM platform package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2016 - 2017, Linaro Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
@@ -120,3 +120,5 @@ [Components.common]
ArmPlatformPkg/PrePi/PeiMPCore.inf
ArmPlatformPkg/PrePi/PeiUniCore.inf
+
+ ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
new file mode 100644
index 0000000000000000000000000000000000000000..69c88416a448caa506bf8a772432144d8a138495
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
@@ -0,0 +1,409 @@
+/** @file
+
+ ARM Mali DP 500/550/650 display controller driver
+
+ Copyright (c) 2017-2018, Arm Limited. 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 <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/LcdHwLib.h>
+#include <Library/LcdPlatformLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include "ArmMaliDp.h"
+
+// CORE_ID of the MALI DP
+STATIC UINT32 mDpDeviceId;
+
+/** Disable the graphics layer
+
+ This is done by clearing the EN bit of the LG_CONTROL register.
+**/
+STATIC
+VOID
+LayerGraphicsDisable (VOID)
+{
+ MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
+}
+
+/** Enable the graphics layer
+
+ This is done by setting the EN bit of the LG_CONTROL register.
+**/
+STATIC
+VOID
+LayerGraphicsEnable (VOID)
+{
+ MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
+}
+
+/** Set the frame address of the graphics layer.
+
+ @param[in] FrameBaseAddress Address of the data buffer to be used as
+ a framebuffer.
+**/
+STATIC
+VOID
+LayerGraphicsSetFrame (
+ IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
+ )
+{
+ // Disable the graphics layer.
+ LayerGraphicsDisable ();
+
+ // Set up memory address of the data buffer for graphics layer.
+ // write lower bits of the address.
+ MmioWrite32 (
+ DP_BASE + DP_DE_LG_PTR_LOW,
+ DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
+ );
+
+ // Write higher bits of the address.
+ MmioWrite32 (
+ DP_BASE + DP_DE_LG_PTR_HIGH,
+ (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
+ );
+
+ // Enable the graphics layer.
+ LayerGraphicsEnable ();
+}
+
+/** Configures various graphics layer characteristics.
+
+ @param[in] UefiGfxPixelFormat This must be either
+ PixelBlueGreenRedReserved8BitPerColor
+ OR
+ PixelRedGreenBlueReserved8BitPerColor
+ @param[in] HRes Horizontal resolution of the graphics layer.
+ @param[in] VRes Vertical resolution of the graphics layer.
+**/
+STATIC
+VOID
+LayerGraphicsConfig (
+ IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
+ IN CONST UINT32 HRes,
+ IN CONST UINT32 VRes
+ )
+{
+ UINT32 PixelFormat;
+
+ // Disable the graphics layer before configuring any settings.
+ LayerGraphicsDisable ();
+
+ // Setup graphics layer size.
+ MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes, VRes));
+
+ // Setup graphics layer composition size.
+ MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE (HRes, VRes));
+
+ // Setup memory stride (total visible pixels on a line * 4).
+ MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof (UINT32)));
+
+ // Set the format.
+
+ // In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents blue,
+ // byte 1 represents green, byte 2 represents red, and byte 3 is reserved
+ // which is equivalent to XRGB format of the DP500/DP550/DP650. Whereas
+ // PixelRedGreenBlueReserved8BitPerColor is equivalent to XBGR of the
+ // DP500/DP550/DP650.
+ if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ PixelFormat = (mDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XRGB_8888
+ : DP_PIXEL_FORMAT_XRGB_8888;
+ } else {
+ PixelFormat = (mDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XBGR_8888
+ : DP_PIXEL_FORMAT_XBGR_8888;
+ }
+
+ MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
+
+ // Enable graphics layer.
+ LayerGraphicsEnable ();
+}
+
+/** Configure timing information of the display.
+
+ @param[in] Horizontal Pointer to horizontal timing parameters.
+ (Resolution, Sync, Back porch, Front porch)
+ @param[in] Vertical Pointer to vertical timing parameters.
+ (Resolution, Sync, Back porch, Front porch)
+**/
+STATIC
+VOID
+SetDisplayEngineTiming (
+ IN CONST SCAN_TIMINGS * CONST Horizontal,
+ IN CONST SCAN_TIMINGS * CONST Vertical
+ )
+{
+ UINTN RegHIntervals;
+ UINTN RegVIntervals;
+ UINTN RegSyncControl;
+ UINTN RegHVActiveSize;
+
+ if (mDpDeviceId == MALIDP_500) {
+ // MALI DP500 timing registers.
+ RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
+ RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
+ RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
+ RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE;
+ } else {
+ // MALI DP550/DP650 timing registers.
+ RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
+ RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
+ RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
+ RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE;
+ }
+
+ // Horizontal back porch and front porch.
+ MmioWrite32 (
+ RegHIntervals,
+ H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
+ );
+
+ // Vertical back porch and front porch.
+ MmioWrite32 (
+ RegVIntervals,
+ V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
+ );
+
+ // Sync control, Horizontal and Vertical sync.
+ MmioWrite32 (
+ RegSyncControl,
+ SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
+ );
+
+ // Set up Horizontal and Vertical area size.
+ MmioWrite32 (
+ RegHVActiveSize,
+ HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
+ );
+}
+
+/** Return CORE_ID of the ARM Mali DP.
+
+ @retval 0xFFF No Mali DP found.
+ @retval 0x500 Mali DP core id for DP500.
+ @retval 0x550 Mali DP core id for DP550.
+ @retval 0x650 Mali DP core id for DP650.
+**/
+STATIC
+UINT32
+ArmMaliDpGetCoreId (
+ )
+{
+ UINT32 DpCoreId;
+
+ // First check for DP500 as register offset for DP550/DP650 CORE_ID
+ // is beyond 3K/4K register space of the DP500.
+ DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
+ DpCoreId >>= DP_DE_DP500_CORE_ID_SHIFT;
+
+ if (DpCoreId == MALIDP_500) {
+ return DpCoreId;
+ }
+
+ // Check for DP550 or DP650.
+ DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID);
+ DpCoreId >>= DP_DC_CORE_ID_SHIFT;
+
+ if ((DpCoreId == MALIDP_550) || (DpCoreId == MALIDP_650)) {
+ return DpCoreId;
+ }
+
+ return MALIDP_NOT_PRESENT;
+}
+
+/** Check for presence of MALI.
+
+ This function returns success if the platform implements
+ DP500/DP550/DP650 ARM Mali display processor.
+
+ @retval EFI_SUCCESS DP500/DP550/DP650 display processor found
+ on the platform.
+ @retval EFI_NOT_FOUND DP500/DP550/DP650 display processor not found
+ on the platform.
+**/
+EFI_STATUS
+LcdIdentify (VOID)
+{
+ DEBUG ((DEBUG_WARN,
+ "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
+ DP_BASE
+ ));
+
+ if (mDpDeviceId == 0) {
+ mDpDeviceId = ArmMaliDpGetCoreId ();
+ }
+
+ if (mDpDeviceId == MALIDP_NOT_PRESENT) {
+ DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", mDpDeviceId));
+ return EFI_SUCCESS;
+}
+
+/** Initialize platform display.
+
+ @param[in] FrameBaseAddress Address of the frame buffer.
+
+ @retval EFI_SUCCESS Display initialization successful.
+ @retval !(EFI_SUCCESS) Display initialization failure.
+**/
+EFI_STATUS
+LcdInitialize (
+ IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
+ )
+{
+ DEBUG ((DEBUG_WARN, "Framebuffer base address = %p\n", FrameBaseAddress));
+
+ if (mDpDeviceId == 0) {
+ mDpDeviceId = ArmMaliDpGetCoreId ();
+ }
+
+ if (mDpDeviceId == MALIDP_NOT_PRESENT) {
+ DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization failed,"
+ "no ARM Mali DP present\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ // We are using graphics layer of the Mali DP as a main framebuffer.
+ LayerGraphicsSetFrame (FrameBaseAddress);
+
+ return EFI_SUCCESS;
+}
+
+/** Set ARM Mali DP in cofiguration mode.
+
+ The ARM Mali DP must be in the configuration mode for
+ configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
+ and HV_ACTIVESIZE.
+**/
+STATIC
+VOID
+SetConfigurationMode (VOID)
+{
+ // Request configuration Mode.
+ if (mDpDeviceId == MALIDP_500) {
+ MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL, DP_DE_DP500_CONTROL_CONFIG_REQ);
+ } else {
+ MmioOr32 (DP_BASE + DP_DC_CONTROL, DP_DC_CONTROL_CM_ACTIVE);
+ }
+}
+
+/** Set ARM Mali DP in normal mode.
+
+ Normal mode is the main operating mode of the display processor
+ in which display layer data is fetched from framebuffer and
+ displayed.
+**/
+STATIC
+VOID
+SetNormalMode (VOID)
+{
+ // Disable configuration Mode.
+ if (mDpDeviceId == MALIDP_500) {
+ MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL, ~DP_DE_DP500_CONTROL_CONFIG_REQ);
+ } else {
+ MmioAnd32 (DP_BASE + DP_DC_CONTROL, ~DP_DC_CONTROL_CM_ACTIVE);
+ }
+}
+
+/** Set the global configuration valid flag.
+
+ Any new configuration parameters written to the display engine are not
+ activated until the global configuration valid flag is set in the
+ CONFIG_VALID register.
+**/
+STATIC
+VOID
+SetConfigValid (VOID)
+{
+ if (mDpDeviceId == MALIDP_500) {
+ MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID, DP_DC_CONFIG_VALID);
+ } else {
+ MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID, DP_DC_CONFIG_VALID);
+ }
+}
+
+/** Set requested mode of the display.
+
+ @param[in] ModeNumber Display mode number.
+
+ @retval EFI_SUCCESS Display mode set successful.
+ @retval EFI_DEVICE_ERROR Display mode not found/supported.
+**/
+EFI_STATUS
+LcdSetMode (
+ IN CONST UINT32 ModeNumber
+ )
+{
+ EFI_STATUS Status;
+ SCAN_TIMINGS *Horizontal;
+ SCAN_TIMINGS *Vertical;
+
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
+
+ // Get the display mode timings and other relevant information.
+ Status = LcdPlatformGetTimings (
+ ModeNumber,
+ &Horizontal,
+ &Vertical
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
+
+ // Get the pixel format information.
+ Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // Request configuration mode.
+ SetConfigurationMode ();
+
+ // Configure the graphics layer.
+ LayerGraphicsConfig (
+ ModeInfo.PixelFormat,
+ Horizontal->Resolution,
+ Vertical->Resolution
+ );
+
+ // Set the display engine timings.
+ SetDisplayEngineTiming (Horizontal, Vertical);
+
+ // After configuration, set Mali DP in normal mode.
+ SetNormalMode ();
+
+ // Any parameters written to the display engine are not activated until
+ // CONFIG_VALID is set.
+ SetConfigValid ();
+
+ return EFI_SUCCESS;
+}
+
+/** This function de-initializes the display.
+
+**/
+VOID
+LcdShutdown (VOID)
+{
+ // Disable graphics layer.
+ LayerGraphicsDisable ();
+}
diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
new file mode 100644
index 0000000000000000000000000000000000000000..4504c6965bf58b1ac19cf717360c7a603ff2cd61
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
@@ -0,0 +1,243 @@
+/** @file
+
+ This header file contains the platform independent parts of ARM Mali DP
+
+ Copyright (c) 2017-2018, Arm Limited. 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 ARMMALIDP_H_
+#define ARMMALIDP_H_
+
+#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
+
+// MALI DP Ids
+#define MALIDP_NOT_PRESENT 0xFFF
+#define MALIDP_500 0x500
+#define MALIDP_550 0x550
+#define MALIDP_650 0x650
+
+// DP500 Peripheral Ids
+#define DP500_ID_PART_0 0x00
+#define DP500_ID_DES_0 0xB
+#define DP500_ID_PART_1 0x5
+
+#define DP500_ID_REVISION 0x1
+#define DP500_ID_JEDEC 0x1
+#define DP500_ID_DES_1 0x3
+
+#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
+#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4) \
+ | DP500_ID_PART_1)
+#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4) \
+ | (DP500_ID_JEDEC << 3) \
+ | (DP500_ID_DES_1))
+
+// DP550 Peripheral Ids
+#define DP550_ID_PART_0 0x50
+#define DP550_ID_DES_0 0xB
+#define DP550_ID_PART_1 0x5
+
+#define DP550_ID_REVISION 0x0
+#define DP550_ID_JEDEC 0x1
+#define DP550_ID_DES_1 0x3
+
+#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
+#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4) \
+ | DP550_ID_PART_1)
+#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4) \
+ | (DP550_ID_JEDEC << 3) \
+ | (DP550_ID_DES_1))
+
+// DP650 Peripheral Ids
+#define DP650_ID_PART_0 0x50
+#define DP650_ID_DES_0 0xB
+#define DP650_ID_PART_1 0x6
+
+#define DP650_ID_REVISION 0x0
+#define DP650_ID_JEDEC 0x1
+#define DP650_ID_DES_1 0x3
+
+#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
+#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4) \
+ | DP650_ID_PART_1)
+#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4) \
+ | (DP650_ID_JEDEC << 3) \
+ | (DP650_ID_DES_1))
+
+// Display Engine (DE) control register offsets for DP550/DP650
+#define DP_DE_STATUS 0x00000
+#define DP_DE_IRQ_SET 0x00004
+#define DP_DE_IRQ_MASK 0x00008
+#define DP_DE_IRQ_CLEAR 0x0000C
+#define DP_DE_CONTROL 0x00010
+#define DP_DE_PROG_LINE 0x00014
+#define DP_DE_AXI_CONTROL 0x00018
+#define DP_DE_AXI_QOS 0x0001C
+#define DP_DE_DISPLAY_FUNCTION 0x00020
+
+#define DP_DE_H_INTERVALS 0x00030
+#define DP_DE_V_INTERVALS 0x00034
+#define DP_DE_SYNC_CONTROL 0x00038
+#define DP_DE_HV_ACTIVESIZE 0x0003C
+#define DP_DE_DISPLAY_SIDEBAND 0x00040
+#define DP_DE_BACKGROUND_COLOR 0x00044
+#define DP_DE_DISPLAY_SPLIT 0x00048
+#define DP_DE_OUTPUT_DEPTH 0x0004C
+
+// Display Engine (DE) control register offsets for DP500
+#define DP_DE_DP500_CORE_ID 0x00018
+#define DP_DE_DP500_CONTROL 0x0000C
+#define DP_DE_DP500_PROG_LINE 0x00010
+#define DP_DE_DP500_H_INTERVALS 0x00028
+#define DP_DE_DP500_V_INTERVALS 0x0002C
+#define DP_DE_DP500_SYNC_CONTROL 0x00030
+#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
+#define DP_DE_DP500_BG_COLOR_RG 0x0003C
+#define DP_DE_DP500_BG_COLOR_B 0x00040
+
+/* Display Engine (DE) graphics layer (LG) register offsets
+ * NOTE: For DP500 it will be LG2.
+ */
+#define DE_LG_OFFSET 0x00300
+#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
+#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
+#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
+#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
+#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
+#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
+#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
+#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
+#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
+#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
+#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
+#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
+
+// Display core (DC) control register offsets.
+#define DP_DC_OFFSET 0x0C000
+#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
+#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
+#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
+#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
+#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
+#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
+#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
+
+// DP500 has a global configuration register.
+#define DP_DP500_CONFIG_VALID (0xF00)
+
+// Display core ID register offsets.
+#define DP_DC_ID_OFFSET 0x0FF00
+#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
+#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
+#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
+#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
+#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
+#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
+#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
+#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
+#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
+
+#define DP_DP500_ID_OFFSET 0x0F00
+#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET + 0xD0)
+#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET + 0xD4)
+#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET + 0xE0)
+#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET + 0xE4)
+#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET + 0xE8)
+#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET + 0xF0)
+#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET + 0xF4)
+#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET + 0xF8)
+#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET + 0xFC)
+
+// Display status configuration mode activation flag
+#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
+
+// Display core control configuration mode
+#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
+#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
+#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
+
+#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
+#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
+
+// Display core configuration valid register
+#define DP_DC_CONFIG_VALID_CVAL (0x1U)
+
+// DC_CORE_ID
+// Display core version register PRODUCT_ID
+#define DP_DC_CORE_ID_SHIFT 16
+#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
+
+// Timing settings
+#define DP_DE_HBACKPORCH_SHIFT 16
+#define DP_DE_VBACKPORCH_SHIFT 16
+#define DP_DE_VSP_SHIFT 28
+#define DP_DE_VSYNCWIDTH_SHIFT 16
+#define DP_DE_HSP_SHIFT 13
+#define DP_DE_V_ACTIVE_SHIFT 16
+
+// BACKGROUND_COLOR
+#define DP_DE_BG_R_PIXEL_SHIFT 16
+#define DP_DE_BG_G_PIXEL_SHIFT 8
+
+//Graphics layer LG_FORMAT Pixel Format
+#define DP_PIXEL_FORMAT_ARGB_8888 0x8
+#define DP_PIXEL_FORMAT_ABGR_8888 0x9
+#define DP_PIXEL_FORMAT_RGBA_8888 0xA
+#define DP_PIXEL_FORMAT_BGRA_8888 0xB
+#define DP_PIXEL_FORMAT_XRGB_8888 0x10
+#define DP_PIXEL_FORMAT_XBGR_8888 0x11
+#define DP_PIXEL_FORMAT_RGBX_8888 0x12
+#define DP_PIXEL_FORMAT_BGRX_8888 0x13
+#define DP_PIXEL_FORMAT_RGB_888 0x18
+#define DP_PIXEL_FORMAT_BGR_888 0x19
+
+// DP500 format code are different than DP550/DP650
+#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
+#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
+#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
+#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
+
+// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
+#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
+#define DP_DE_LG_PTR_HIGH_SHIFT 32
+
+// Graphics layer LG_CONTROL register characteristics
+#define DP_DE_LG_L_ALPHA_SHIFT 16
+#define DP_DE_LG_CHK_SHIFT 15
+#define DP_DE_LG_PMUL_SHIFT 14
+#define DP_DE_LG_COM_SHIFT 12
+#define DP_DE_LG_VFP_SHIFT 11
+#define DP_DE_LG_HFP_SHIFT 10
+#define DP_DE_LG_ROTATION_SHIFT 8
+
+#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
+#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
+#define DP_DE_LG_LAYER_BLEND_BG 0x2U
+#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
+#define DP_DE_LG_ENABLE 0x1U
+
+// Graphics layer LG_IN_SIZE register characteristics
+#define DP_DE_LG_V_IN_SIZE_SHIFT 16
+
+// Graphics layer LG_CMP_SIZE register characteristics
+#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
+#define DP_DE_LG_V_OFFSET_SHIFT 16
+
+// Helper display timing macro functions.
+#define H_INTERVALS(Hfp, Hbp) ((Hbp << DP_DE_HBACKPORCH_SHIFT) | Hfp)
+#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT) | Vfp)
+#define SYNC_WIDTH(Hsw, Vsw) ((Vsw << DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
+#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) | Hor)
+
+// Helper layer graphics macros.
+#define FRAME_IN_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_IN_SIZE_SHIFT) | Hor)
+#define FRAME_CMP_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
+
+#endif /* ARMMALIDP_H_ */
diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
new file mode 100644
index 0000000000000000000000000000000000000000..4cf020e4c314b17f7944336512ca8688911cf1be
--- /dev/null
+++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
@@ -0,0 +1,43 @@
+#/** @file
+#
+# Component description file for ArmMaliDp module
+#
+# Copyright (c) 2017-2018, Arm Limited. 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 = 0x00010019
+ BASE_NAME = ArmMaliDp
+ FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = LcdHwLib
+
+[Sources.common]
+ ArmMaliDp.c
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ IoLib
+ LcdPlatformLib
+ UefiLib
+
+[FixedPcd]
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
+
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver
2018-03-20 16:12 ` [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver Girish Pathak
@ 2018-03-21 12:54 ` Evan Lloyd
2018-04-23 11:07 ` Leif Lindholm
1 sibling, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:54 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 14/16] ArmPlatformPkg: New
> DP500/DP550/DP650 GOP driver
>
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change adds support for the ARM Mali DP500/DP500/DP650 display
> processors using the GOP protocol. It has been tested on FVP base models
> + DP550 support. This change adds platform independant LcdHwLib library.
> A corresponding platform specific library will be submitted to edk-
> platforms/Platform/ARM/VExpressPkg.
>
> This change does not modify functionality provided by PL111 or HDLCD.
> This LcdHwLib implementation should be suitable for those platforms that
> implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
>
> Only graphics layer of the ARM Mali DP is configured for rendering the
> RGB/BGR format frame buffer to satisfy the UEFI GOP requirements Other
> layers e.g. video layers are not configured.
>
> 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>
> ---
>
> Notes:
> v3:
> - Please add this library as a component to
> ArmPlatformPkg.dsc as well, so we can do build testing
> on it. [Ard]
>
> Done [Girish]
>
> - Please drop references to edk2-platforms.
> This driver should be able to be used independently
> from VExpress platform code [Ard]
>
> Done [Girish]
>
> ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
> ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +-
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c | 409
> ++++++++++++++++++++
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h | 243 ++++++++++++
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf | 43 ++
> 5 files changed, 702 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec
> b/ArmPlatformPkg/ArmPlatformPkg.dec
> index
> 5c702718a78a78e6c67ab407e198382e0a0df4be..28cdc259849da11b172a
> d52045bccc0276669852 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -98,6 +98,10 @@ [PcdsFixedAtBuild.common]
> ## If set, framebuffer memory will be reserved and mapped in the system
> RAM
>
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT6
> 4|0x00000044
>
> + ## ARM Mali Display Processor DP500/DP550/DP650
> +
> gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x000000
> 50
> +
> +
> gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|U
> INT32|0
> + x00000051
> +
> ## PL180 MCI
>
> gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|
> UINT32|0x00000028
>
> gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UI
> NT32|0x00000029
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc
> b/ArmPlatformPkg/ArmPlatformPkg.dsc
> index
> 82adb9ef8891b7ba1628ede2f8eb124c25c2774a..0013106b94c371f827e0
> 1c6d402faa6aa42e4bdd 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dsc
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
> @@ -2,7 +2,7 @@
> # ARM platform package.
> #
> # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR> -#
> Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
> # Copyright (c) 2016 - 2017, Linaro Ltd. All rights reserved.<BR> #
> # This program and the accompanying materials
> @@ -120,3 +120,5 @@ [Components.common]
>
> ArmPlatformPkg/PrePi/PeiMPCore.inf
> ArmPlatformPkg/PrePi/PeiUniCore.inf
> +
> + ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
> b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..69c88416a448caa506
> bf8a772432144d8a138495
> --- /dev/null
> +++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
> @@ -0,0 +1,409 @@
> +/** @file
> +
> + ARM Mali DP 500/550/650 display controller driver
> +
> + Copyright (c) 2017-2018, Arm Limited. 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 <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/LcdHwLib.h>
> +#include <Library/LcdPlatformLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +
> +#include "ArmMaliDp.h"
> +
> +// CORE_ID of the MALI DP
> +STATIC UINT32 mDpDeviceId;
> +
> +/** Disable the graphics layer
> +
> + This is done by clearing the EN bit of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsDisable (VOID)
> +{
> + MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE); }
> +
> +/** Enable the graphics layer
> +
> + This is done by setting the EN bit of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsEnable (VOID)
> +{
> + MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE); }
> +
> +/** Set the frame address of the graphics layer.
> +
> + @param[in] FrameBaseAddress Address of the data buffer to be used
> as
> + a framebuffer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsSetFrame (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + // Disable the graphics layer.
> + LayerGraphicsDisable ();
> +
> + // Set up memory address of the data buffer for graphics layer.
> + // write lower bits of the address.
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_LOW,
> + DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
> + );
> +
> + // Write higher bits of the address.
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_HIGH,
> + (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
> + );
> +
> + // Enable the graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configures various graphics layer characteristics.
> +
> + @param[in] UefiGfxPixelFormat This must be either
> + PixelBlueGreenRedReserved8BitPerColor
> + OR
> + PixelRedGreenBlueReserved8BitPerColor
> + @param[in] HRes Horizontal resolution of the graphics layer.
> + @param[in] VRes Vertical resolution of the graphics layer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsConfig (
> + IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
> + IN CONST UINT32 HRes,
> + IN CONST UINT32 VRes
> + )
> +{
> + UINT32 PixelFormat;
> +
> + // Disable the graphics layer before configuring any settings.
> + LayerGraphicsDisable ();
> +
> + // Setup graphics layer size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes,
> VRes));
> +
> + // Setup graphics layer composition size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE
> (HRes,
> + VRes));
> +
> + // Setup memory stride (total visible pixels on a line * 4).
> + MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof
> (UINT32)));
> +
> + // Set the format.
> +
> + // In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents
> + blue, // byte 1 represents green, byte 2 represents red, and byte 3
> + is reserved // which is equivalent to XRGB format of the
> + DP500/DP550/DP650. Whereas //
> PixelRedGreenBlueReserved8BitPerColor
> + is equivalent to XBGR of the // DP500/DP550/DP650.
> + if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + PixelFormat = (mDpDeviceId == MALIDP_500) ?
> DP_PIXEL_FORMAT_DP500_XRGB_8888
> + : DP_PIXEL_FORMAT_XRGB_8888; } else {
> + PixelFormat = (mDpDeviceId == MALIDP_500) ?
> DP_PIXEL_FORMAT_DP500_XBGR_8888
> + : DP_PIXEL_FORMAT_XBGR_8888; }
> +
> + MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
> +
> + // Enable graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configure timing information of the display.
> +
> + @param[in] Horizontal Pointer to horizontal timing parameters.
> + (Resolution, Sync, Back porch, Front porch)
> + @param[in] Vertical Pointer to vertical timing parameters.
> + (Resolution, Sync, Back porch, Front
> +porch) **/ STATIC VOID SetDisplayEngineTiming (
> + IN CONST SCAN_TIMINGS * CONST Horizontal,
> + IN CONST SCAN_TIMINGS * CONST Vertical
> + )
> +{
> + UINTN RegHIntervals;
> + UINTN RegVIntervals;
> + UINTN RegSyncControl;
> + UINTN RegHVActiveSize;
> +
> + if (mDpDeviceId == MALIDP_500) {
> + // MALI DP500 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE; } else {
> + // MALI DP550/DP650 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE; }
> +
> + // Horizontal back porch and front porch.
> + MmioWrite32 (
> + RegHIntervals,
> + H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
> + );
> +
> + // Vertical back porch and front porch.
> + MmioWrite32 (
> + RegVIntervals,
> + V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
> + );
> +
> + // Sync control, Horizontal and Vertical sync.
> + MmioWrite32 (
> + RegSyncControl,
> + SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
> + );
> +
> + // Set up Horizontal and Vertical area size.
> + MmioWrite32 (
> + RegHVActiveSize,
> + HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
> + );
> +}
> +
> +/** Return CORE_ID of the ARM Mali DP.
> +
> + @retval 0xFFF No Mali DP found.
> + @retval 0x500 Mali DP core id for DP500.
> + @retval 0x550 Mali DP core id for DP550.
> + @retval 0x650 Mali DP core id for DP650.
> +**/
> +STATIC
> +UINT32
> +ArmMaliDpGetCoreId (
> + )
> +{
> + UINT32 DpCoreId;
> +
> + // First check for DP500 as register offset for DP550/DP650 CORE_ID
> + // is beyond 3K/4K register space of the DP500.
> + DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
> DpCoreId >>=
> + DP_DE_DP500_CORE_ID_SHIFT;
> +
> + if (DpCoreId == MALIDP_500) {
> + return DpCoreId;
> + }
> +
> + // Check for DP550 or DP650.
> + DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID); DpCoreId >>=
> + DP_DC_CORE_ID_SHIFT;
> +
> + if ((DpCoreId == MALIDP_550) || (DpCoreId == MALIDP_650)) {
> + return DpCoreId;
> + }
> +
> + return MALIDP_NOT_PRESENT;
> +}
> +
> +/** Check for presence of MALI.
> +
> + This function returns success if the platform implements
> + DP500/DP550/DP650 ARM Mali display processor.
> +
> + @retval EFI_SUCCESS DP500/DP550/DP650 display processor
> found
> + on the platform.
> + @retval EFI_NOT_FOUND DP500/DP550/DP650 display processor
> not found
> + on the platform.
> +**/
> +EFI_STATUS
> +LcdIdentify (VOID)
> +{
> + DEBUG ((DEBUG_WARN,
> + "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
> + DP_BASE
> + ));
> +
> + if (mDpDeviceId == 0) {
> + mDpDeviceId = ArmMaliDpGetCoreId (); }
> +
> + if (mDpDeviceId == MALIDP_NOT_PRESENT) {
> + DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", mDpDeviceId));
> + return EFI_SUCCESS;
> +}
> +
> +/** Initialize platform display.
> +
> + @param[in] FrameBaseAddress Address of the frame buffer.
> +
> + @retval EFI_SUCCESS Display initialization successful.
> + @retval !(EFI_SUCCESS) Display initialization failure.
> +**/
> +EFI_STATUS
> +LcdInitialize (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + DEBUG ((DEBUG_WARN, "Framebuffer base address = %p\n",
> +FrameBaseAddress));
> +
> + if (mDpDeviceId == 0) {
> + mDpDeviceId = ArmMaliDpGetCoreId (); }
> +
> + if (mDpDeviceId == MALIDP_NOT_PRESENT) {
> + DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization failed,"
> + "no ARM Mali DP present\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + // We are using graphics layer of the Mali DP as a main framebuffer.
> + LayerGraphicsSetFrame (FrameBaseAddress);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set ARM Mali DP in cofiguration mode.
> +
> + The ARM Mali DP must be in the configuration mode for
> + configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
> + and HV_ACTIVESIZE.
> +**/
> +STATIC
> +VOID
> +SetConfigurationMode (VOID)
> +{
> + // Request configuration Mode.
> + if (mDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL,
> +DP_DE_DP500_CONTROL_CONFIG_REQ); } else {
> + MmioOr32 (DP_BASE + DP_DC_CONTROL,
> DP_DC_CONTROL_CM_ACTIVE); } }
> +
> +/** Set ARM Mali DP in normal mode.
> +
> + Normal mode is the main operating mode of the display processor
> + in which display layer data is fetched from framebuffer and
> + displayed.
> +**/
> +STATIC
> +VOID
> +SetNormalMode (VOID)
> +{
> + // Disable configuration Mode.
> + if (mDpDeviceId == MALIDP_500) {
> + MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL,
> +~DP_DE_DP500_CONTROL_CONFIG_REQ); } else {
> + MmioAnd32 (DP_BASE + DP_DC_CONTROL,
> ~DP_DC_CONTROL_CM_ACTIVE); } }
> +
> +/** Set the global configuration valid flag.
> +
> + Any new configuration parameters written to the display engine are
> +not
> + activated until the global configuration valid flag is set in the
> + CONFIG_VALID register.
> +**/
> +STATIC
> +VOID
> +SetConfigValid (VOID)
> +{
> + if (mDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID,
> DP_DC_CONFIG_VALID);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID, DP_DC_CONFIG_VALID);
> + }
> +}
> +
> +/** Set requested mode of the display.
> +
> + @param[in] ModeNumber Display mode number.
> +
> + @retval EFI_SUCCESS Display mode set successful.
> + @retval EFI_DEVICE_ERROR Display mode not found/supported.
> +**/
> +EFI_STATUS
> +LcdSetMode (
> + IN CONST UINT32 ModeNumber
> + )
> +{
> + EFI_STATUS Status;
> + SCAN_TIMINGS *Horizontal;
> + SCAN_TIMINGS *Vertical;
> +
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
> +
> + // Get the display mode timings and other relevant information.
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &Horizontal,
> + &Vertical
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> +
> + // Get the pixel format information.
> + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo); if
> (EFI_ERROR
> + (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + // Request configuration mode.
> + SetConfigurationMode ();
> +
> + // Configure the graphics layer.
> + LayerGraphicsConfig (
> + ModeInfo.PixelFormat,
> + Horizontal->Resolution,
> + Vertical->Resolution
> + );
> +
> + // Set the display engine timings.
> + SetDisplayEngineTiming (Horizontal, Vertical);
> +
> + // After configuration, set Mali DP in normal mode.
> + SetNormalMode ();
> +
> + // Any parameters written to the display engine are not activated
> + until // CONFIG_VALID is set.
> + SetConfigValid ();
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** This function de-initializes the display.
> +
> +**/
> +VOID
> +LcdShutdown (VOID)
> +{
> + // Disable graphics layer.
> + LayerGraphicsDisable ();
> +}
> diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
> b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..4504c6965bf58b1ac1
> 9cf717360c7a603ff2cd61
> --- /dev/null
> +++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
> @@ -0,0 +1,243 @@
> +/** @file
> +
> + This header file contains the platform independent parts of ARM Mali
> + DP
> +
> + Copyright (c) 2017-2018, Arm Limited. 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 ARMMALIDP_H_
> +#define ARMMALIDP_H_
> +
> +#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
> +
> +// MALI DP Ids
> +#define MALIDP_NOT_PRESENT 0xFFF
> +#define MALIDP_500 0x500
> +#define MALIDP_550 0x550
> +#define MALIDP_650 0x650
> +
> +// DP500 Peripheral Ids
> +#define DP500_ID_PART_0 0x00
> +#define DP500_ID_DES_0 0xB
> +#define DP500_ID_PART_1 0x5
> +
> +#define DP500_ID_REVISION 0x1
> +#define DP500_ID_JEDEC 0x1
> +#define DP500_ID_DES_1 0x3
> +
> +#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
> +#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4) \
> + | DP500_ID_PART_1)
> +#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4) \
> + | (DP500_ID_JEDEC << 3) \
> + | (DP500_ID_DES_1))
> +
> +// DP550 Peripheral Ids
> +#define DP550_ID_PART_0 0x50
> +#define DP550_ID_DES_0 0xB
> +#define DP550_ID_PART_1 0x5
> +
> +#define DP550_ID_REVISION 0x0
> +#define DP550_ID_JEDEC 0x1
> +#define DP550_ID_DES_1 0x3
> +
> +#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
> +#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4) \
> + | DP550_ID_PART_1)
> +#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4) \
> + | (DP550_ID_JEDEC << 3) \
> + | (DP550_ID_DES_1))
> +
> +// DP650 Peripheral Ids
> +#define DP650_ID_PART_0 0x50
> +#define DP650_ID_DES_0 0xB
> +#define DP650_ID_PART_1 0x6
> +
> +#define DP650_ID_REVISION 0x0
> +#define DP650_ID_JEDEC 0x1
> +#define DP650_ID_DES_1 0x3
> +
> +#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
> +#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4) \
> + | DP650_ID_PART_1)
> +#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4) \
> + | (DP650_ID_JEDEC << 3) \
> + | (DP650_ID_DES_1))
> +
> +// Display Engine (DE) control register offsets for DP550/DP650
> +#define DP_DE_STATUS 0x00000
> +#define DP_DE_IRQ_SET 0x00004
> +#define DP_DE_IRQ_MASK 0x00008
> +#define DP_DE_IRQ_CLEAR 0x0000C
> +#define DP_DE_CONTROL 0x00010
> +#define DP_DE_PROG_LINE 0x00014
> +#define DP_DE_AXI_CONTROL 0x00018
> +#define DP_DE_AXI_QOS 0x0001C
> +#define DP_DE_DISPLAY_FUNCTION 0x00020
> +
> +#define DP_DE_H_INTERVALS 0x00030
> +#define DP_DE_V_INTERVALS 0x00034
> +#define DP_DE_SYNC_CONTROL 0x00038
> +#define DP_DE_HV_ACTIVESIZE 0x0003C
> +#define DP_DE_DISPLAY_SIDEBAND 0x00040
> +#define DP_DE_BACKGROUND_COLOR 0x00044
> +#define DP_DE_DISPLAY_SPLIT 0x00048
> +#define DP_DE_OUTPUT_DEPTH 0x0004C
> +
> +// Display Engine (DE) control register offsets for DP500
> +#define DP_DE_DP500_CORE_ID 0x00018
> +#define DP_DE_DP500_CONTROL 0x0000C
> +#define DP_DE_DP500_PROG_LINE 0x00010
> +#define DP_DE_DP500_H_INTERVALS 0x00028
> +#define DP_DE_DP500_V_INTERVALS 0x0002C
> +#define DP_DE_DP500_SYNC_CONTROL 0x00030
> +#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
> +#define DP_DE_DP500_BG_COLOR_RG 0x0003C
> +#define DP_DE_DP500_BG_COLOR_B 0x00040
> +
> +/* Display Engine (DE) graphics layer (LG) register offsets
> + * NOTE: For DP500 it will be LG2.
> + */
> +#define DE_LG_OFFSET 0x00300
> +#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
> +#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
> +#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
> +#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
> +#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
> +#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
> +#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
> +#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
> +#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
> +#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
> +#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
> +#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
> +
> +// Display core (DC) control register offsets.
> +#define DP_DC_OFFSET 0x0C000
> +#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
> +#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
> +#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
> +#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
> +#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
> +#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
> +#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
> +
> +// DP500 has a global configuration register.
> +#define DP_DP500_CONFIG_VALID (0xF00)
> +
> +// Display core ID register offsets.
> +#define DP_DC_ID_OFFSET 0x0FF00
> +#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
> +#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
> +#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
> +#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
> +#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
> +#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
> +#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
> +#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
> +#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
> +
> +#define DP_DP500_ID_OFFSET 0x0F00
> +#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET +
> 0xD0)
> +#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET +
> 0xD4)
> +#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET + 0xE0)
> +#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET + 0xE4)
> +#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET + 0xE8)
> +#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET +
> 0xF0)
> +#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET +
> 0xF4)
> +#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET +
> 0xF8)
> +#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET +
> 0xFC)
> +
> +// Display status configuration mode activation flag
> +#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
> +
> +// Display core control configuration mode
> +#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
> +#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
> +#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
> +
> +#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
> +#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
> +
> +// Display core configuration valid register
> +#define DP_DC_CONFIG_VALID_CVAL (0x1U)
> +
> +// DC_CORE_ID
> +// Display core version register PRODUCT_ID
> +#define DP_DC_CORE_ID_SHIFT 16
> +#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
> +
> +// Timing settings
> +#define DP_DE_HBACKPORCH_SHIFT 16
> +#define DP_DE_VBACKPORCH_SHIFT 16
> +#define DP_DE_VSP_SHIFT 28
> +#define DP_DE_VSYNCWIDTH_SHIFT 16
> +#define DP_DE_HSP_SHIFT 13
> +#define DP_DE_V_ACTIVE_SHIFT 16
> +
> +// BACKGROUND_COLOR
> +#define DP_DE_BG_R_PIXEL_SHIFT 16
> +#define DP_DE_BG_G_PIXEL_SHIFT 8
> +
> +//Graphics layer LG_FORMAT Pixel Format
> +#define DP_PIXEL_FORMAT_ARGB_8888 0x8
> +#define DP_PIXEL_FORMAT_ABGR_8888 0x9
> +#define DP_PIXEL_FORMAT_RGBA_8888 0xA
> +#define DP_PIXEL_FORMAT_BGRA_8888 0xB
> +#define DP_PIXEL_FORMAT_XRGB_8888 0x10
> +#define DP_PIXEL_FORMAT_XBGR_8888 0x11
> +#define DP_PIXEL_FORMAT_RGBX_8888 0x12
> +#define DP_PIXEL_FORMAT_BGRX_8888 0x13
> +#define DP_PIXEL_FORMAT_RGB_888 0x18
> +#define DP_PIXEL_FORMAT_BGR_888 0x19
> +
> +// DP500 format code are different than DP550/DP650
> +#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
> +#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
> +#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
> +#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
> +
> +// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
> +#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
> +#define DP_DE_LG_PTR_HIGH_SHIFT 32
> +
> +// Graphics layer LG_CONTROL register characteristics
> +#define DP_DE_LG_L_ALPHA_SHIFT 16
> +#define DP_DE_LG_CHK_SHIFT 15
> +#define DP_DE_LG_PMUL_SHIFT 14
> +#define DP_DE_LG_COM_SHIFT 12
> +#define DP_DE_LG_VFP_SHIFT 11
> +#define DP_DE_LG_HFP_SHIFT 10
> +#define DP_DE_LG_ROTATION_SHIFT 8
> +
> +#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
> +#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
> +#define DP_DE_LG_LAYER_BLEND_BG 0x2U
> +#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
> +#define DP_DE_LG_ENABLE 0x1U
> +
> +// Graphics layer LG_IN_SIZE register characteristics
> +#define DP_DE_LG_V_IN_SIZE_SHIFT 16
> +
> +// Graphics layer LG_CMP_SIZE register characteristics
> +#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
> +#define DP_DE_LG_V_OFFSET_SHIFT 16
> +
> +// Helper display timing macro functions.
> +#define H_INTERVALS(Hfp, Hbp) ((Hbp << DP_DE_HBACKPORCH_SHIFT)
> | Hfp)
> +#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT)
> | Vfp)
> +#define SYNC_WIDTH(Hsw, Vsw) ((Vsw <<
> DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
> +#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) |
> Hor)
> +
> +// Helper layer graphics macros.
> +#define FRAME_IN_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_IN_SIZE_SHIFT)
> | Hor)
> +#define FRAME_CMP_SIZE(Hor, Ver) ((Ver <<
> DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
> +
> +#endif /* ARMMALIDP_H_ */
> diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..4cf020e4c314b17f794
> 4336512ca8688911cf1be
> --- /dev/null
> +++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> @@ -0,0 +1,43 @@
> +#/** @file
> +#
> +# Component description file for ArmMaliDp module # # Copyright (c)
> +2017-2018, Arm Limited. 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 = 0x00010019
> + BASE_NAME = ArmMaliDp
> + FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = LcdHwLib
> +
> +[Sources.common]
> + ArmMaliDp.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + IoLib
> + LcdPlatformLib
> + UefiLib
> +
> +[FixedPcd]
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> +
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver
2018-03-20 16:12 ` [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
@ 2018-04-23 11:07 ` Leif Lindholm
1 sibling, 0 replies; 40+ messages in thread
From: Leif Lindholm @ 2018-04-23 11:07 UTC (permalink / raw)
To: Girish Pathak
Cc: edk2-devel, ard.biesheuvel, Matteo.Carlini, Stephanie.Hughes-Fitt,
nd
On Tue, Mar 20, 2018 at 04:12:10PM +0000, Girish Pathak wrote:
> From: Girish Pathak <girish.pathak at arm.com>
>
> This change adds support for the ARM Mali DP500/DP500/DP650 display
> processors using the GOP protocol. It has been tested on FVP base
> models + DP550 support. This change adds platform independant LcdHwLib
> library. A corresponding platform specific library will be submitted
> to edk-platforms/Platform/ARM/VExpressPkg.
>
> This change does not modify functionality provided by PL111 or
> HDLCD. This LcdHwLib implementation should be suitable for those
> platforms that implement ARM Mali DP500/DP550/DP650 replacing
> PL111/HDLCD.
>
> Only graphics layer of the ARM Mali DP is configured for rendering
> the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
> Other layers e.g. video layers are not configured.
>
> 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>
> ---
>
> Notes:
> v3:
> - Please add this library as a component to
> ArmPlatformPkg.dsc as well, so we can do build testing
> on it. [Ard]
>
> Done [Girish]
>
> - Please drop references to edk2-platforms.
> This driver should be able to be used independently
> from VExpress platform code [Ard]
>
> Done [Girish]
>
> ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
> ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +-
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c | 409 ++++++++++++++++++++
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h | 243 ++++++++++++
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf | 43 ++
> 5 files changed, 702 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index 5c702718a78a78e6c67ab407e198382e0a0df4be..28cdc259849da11b172ad52045bccc0276669852 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -98,6 +98,10 @@ [PcdsFixedAtBuild.common]
> ## If set, framebuffer memory will be reserved and mapped in the system RAM
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000044
>
> + ## ARM Mali Display Processor DP500/DP550/DP650
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x00000050
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|UINT32|0x00000051
> +
> ## PL180 MCI
> gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
> gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc
> index 82adb9ef8891b7ba1628ede2f8eb124c25c2774a..0013106b94c371f827e01c6d402faa6aa42e4bdd 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dsc
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
> @@ -2,7 +2,7 @@
> # ARM platform package.
> #
> # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
> -# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
> # Copyright (c) 2016 - 2017, Linaro Ltd. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> @@ -120,3 +120,5 @@ [Components.common]
>
> ArmPlatformPkg/PrePi/PeiMPCore.inf
> ArmPlatformPkg/PrePi/PeiUniCore.inf
> +
> + ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..69c88416a448caa506bf8a772432144d8a138495
> --- /dev/null
> +++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
> @@ -0,0 +1,409 @@
> +/** @file
> +
> + ARM Mali DP 500/550/650 display controller driver
> +
> + Copyright (c) 2017-2018, Arm Limited. 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 <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <Library/LcdHwLib.h>
> +#include <Library/LcdPlatformLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +
> +#include "ArmMaliDp.h"
> +
> +// CORE_ID of the MALI DP
> +STATIC UINT32 mDpDeviceId;
> +
> +/** Disable the graphics layer
> +
> + This is done by clearing the EN bit of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsDisable (VOID)
> +{
> + MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
> +}
> +
> +/** Enable the graphics layer
> +
> + This is done by setting the EN bit of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsEnable (VOID)
> +{
> + MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
> +}
> +
> +/** Set the frame address of the graphics layer.
> +
> + @param[in] FrameBaseAddress Address of the data buffer to be used as
> + a framebuffer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsSetFrame (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + // Disable the graphics layer.
> + LayerGraphicsDisable ();
> +
> + // Set up memory address of the data buffer for graphics layer.
> + // write lower bits of the address.
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_LOW,
> + DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
> + );
> +
> + // Write higher bits of the address.
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_HIGH,
> + (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
> + );
> +
> + // Enable the graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configures various graphics layer characteristics.
> +
> + @param[in] UefiGfxPixelFormat This must be either
> + PixelBlueGreenRedReserved8BitPerColor
> + OR
> + PixelRedGreenBlueReserved8BitPerColor
> + @param[in] HRes Horizontal resolution of the graphics layer.
> + @param[in] VRes Vertical resolution of the graphics layer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsConfig (
> + IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
> + IN CONST UINT32 HRes,
> + IN CONST UINT32 VRes
> + )
> +{
> + UINT32 PixelFormat;
> +
> + // Disable the graphics layer before configuring any settings.
> + LayerGraphicsDisable ();
> +
> + // Setup graphics layer size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes, VRes));
> +
> + // Setup graphics layer composition size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE (HRes, VRes));
> +
> + // Setup memory stride (total visible pixels on a line * 4).
> + MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof (UINT32)));
> +
> + // Set the format.
> +
> + // In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents blue,
> + // byte 1 represents green, byte 2 represents red, and byte 3 is reserved
> + // which is equivalent to XRGB format of the DP500/DP550/DP650. Whereas
> + // PixelRedGreenBlueReserved8BitPerColor is equivalent to XBGR of the
> + // DP500/DP550/DP650.
> + if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + PixelFormat = (mDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XRGB_8888
> + : DP_PIXEL_FORMAT_XRGB_8888;
> + } else {
> + PixelFormat = (mDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XBGR_8888
> + : DP_PIXEL_FORMAT_XBGR_8888;
> + }
> +
> + MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
> +
> + // Enable graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configure timing information of the display.
> +
> + @param[in] Horizontal Pointer to horizontal timing parameters.
> + (Resolution, Sync, Back porch, Front porch)
> + @param[in] Vertical Pointer to vertical timing parameters.
> + (Resolution, Sync, Back porch, Front porch)
> +**/
> +STATIC
> +VOID
> +SetDisplayEngineTiming (
> + IN CONST SCAN_TIMINGS * CONST Horizontal,
> + IN CONST SCAN_TIMINGS * CONST Vertical
> + )
> +{
> + UINTN RegHIntervals;
> + UINTN RegVIntervals;
> + UINTN RegSyncControl;
> + UINTN RegHVActiveSize;
> +
> + if (mDpDeviceId == MALIDP_500) {
> + // MALI DP500 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE;
> + } else {
> + // MALI DP550/DP650 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE;
> + }
> +
> + // Horizontal back porch and front porch.
> + MmioWrite32 (
> + RegHIntervals,
> + H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
> + );
> +
> + // Vertical back porch and front porch.
> + MmioWrite32 (
> + RegVIntervals,
> + V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
> + );
> +
> + // Sync control, Horizontal and Vertical sync.
> + MmioWrite32 (
> + RegSyncControl,
> + SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
> + );
> +
> + // Set up Horizontal and Vertical area size.
> + MmioWrite32 (
> + RegHVActiveSize,
> + HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
> + );
> +}
> +
> +/** Return CORE_ID of the ARM Mali DP.
> +
> + @retval 0xFFF No Mali DP found.
> + @retval 0x500 Mali DP core id for DP500.
> + @retval 0x550 Mali DP core id for DP550.
> + @retval 0x650 Mali DP core id for DP650.
> +**/
> +STATIC
> +UINT32
> +ArmMaliDpGetCoreId (
> + )
> +{
> + UINT32 DpCoreId;
> +
> + // First check for DP500 as register offset for DP550/DP650 CORE_ID
> + // is beyond 3K/4K register space of the DP500.
> + DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
> + DpCoreId >>= DP_DE_DP500_CORE_ID_SHIFT;
> +
> + if (DpCoreId == MALIDP_500) {
> + return DpCoreId;
> + }
> +
> + // Check for DP550 or DP650.
> + DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID);
> + DpCoreId >>= DP_DC_CORE_ID_SHIFT;
> +
> + if ((DpCoreId == MALIDP_550) || (DpCoreId == MALIDP_650)) {
> + return DpCoreId;
> + }
> +
> + return MALIDP_NOT_PRESENT;
> +}
> +
> +/** Check for presence of MALI.
> +
> + This function returns success if the platform implements
> + DP500/DP550/DP650 ARM Mali display processor.
> +
> + @retval EFI_SUCCESS DP500/DP550/DP650 display processor found
> + on the platform.
> + @retval EFI_NOT_FOUND DP500/DP550/DP650 display processor not found
> + on the platform.
> +**/
> +EFI_STATUS
> +LcdIdentify (VOID)
> +{
> + DEBUG ((DEBUG_WARN,
> + "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
> + DP_BASE
> + ));
> +
> + if (mDpDeviceId == 0) {
> + mDpDeviceId = ArmMaliDpGetCoreId ();
> + }
> +
> + if (mDpDeviceId == MALIDP_NOT_PRESENT) {
> + DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", mDpDeviceId));
> + return EFI_SUCCESS;
> +}
> +
> +/** Initialize platform display.
> +
> + @param[in] FrameBaseAddress Address of the frame buffer.
> +
> + @retval EFI_SUCCESS Display initialization successful.
> + @retval !(EFI_SUCCESS) Display initialization failure.
> +**/
> +EFI_STATUS
> +LcdInitialize (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + DEBUG ((DEBUG_WARN, "Framebuffer base address = %p\n", FrameBaseAddress));
> +
> + if (mDpDeviceId == 0) {
> + mDpDeviceId = ArmMaliDpGetCoreId ();
> + }
> +
> + if (mDpDeviceId == MALIDP_NOT_PRESENT) {
> + DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization failed,"
> + "no ARM Mali DP present\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + // We are using graphics layer of the Mali DP as a main framebuffer.
> + LayerGraphicsSetFrame (FrameBaseAddress);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set ARM Mali DP in cofiguration mode.
> +
> + The ARM Mali DP must be in the configuration mode for
> + configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
> + and HV_ACTIVESIZE.
> +**/
> +STATIC
> +VOID
> +SetConfigurationMode (VOID)
> +{
> + // Request configuration Mode.
Incorrect indentation (I'll fix up before pushing).
> + if (mDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL, DP_DE_DP500_CONTROL_CONFIG_REQ);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONTROL, DP_DC_CONTROL_CM_ACTIVE);
> + }
> +}
> +
> +/** Set ARM Mali DP in normal mode.
> +
> + Normal mode is the main operating mode of the display processor
> + in which display layer data is fetched from framebuffer and
> + displayed.
> +**/
> +STATIC
> +VOID
> +SetNormalMode (VOID)
> +{
> + // Disable configuration Mode.
Incorrect indentation (I'll fix up before pushing).
/
Leif
> + if (mDpDeviceId == MALIDP_500) {
> + MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL, ~DP_DE_DP500_CONTROL_CONFIG_REQ);
> + } else {
> + MmioAnd32 (DP_BASE + DP_DC_CONTROL, ~DP_DC_CONTROL_CM_ACTIVE);
> + }
> +}
> +
> +/** Set the global configuration valid flag.
> +
> + Any new configuration parameters written to the display engine are not
> + activated until the global configuration valid flag is set in the
> + CONFIG_VALID register.
> +**/
> +STATIC
> +VOID
> +SetConfigValid (VOID)
> +{
> + if (mDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID, DP_DC_CONFIG_VALID);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID, DP_DC_CONFIG_VALID);
> + }
> +}
> +
> +/** Set requested mode of the display.
> +
> + @param[in] ModeNumber Display mode number.
> +
> + @retval EFI_SUCCESS Display mode set successful.
> + @retval EFI_DEVICE_ERROR Display mode not found/supported.
> +**/
> +EFI_STATUS
> +LcdSetMode (
> + IN CONST UINT32 ModeNumber
> + )
> +{
> + EFI_STATUS Status;
> + SCAN_TIMINGS *Horizontal;
> + SCAN_TIMINGS *Vertical;
> +
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
> +
> + // Get the display mode timings and other relevant information.
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &Horizontal,
> + &Vertical
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> +
> + // Get the pixel format information.
> + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + // Request configuration mode.
> + SetConfigurationMode ();
> +
> + // Configure the graphics layer.
> + LayerGraphicsConfig (
> + ModeInfo.PixelFormat,
> + Horizontal->Resolution,
> + Vertical->Resolution
> + );
> +
> + // Set the display engine timings.
> + SetDisplayEngineTiming (Horizontal, Vertical);
> +
> + // After configuration, set Mali DP in normal mode.
> + SetNormalMode ();
> +
> + // Any parameters written to the display engine are not activated until
> + // CONFIG_VALID is set.
> + SetConfigValid ();
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** This function de-initializes the display.
> +
> +**/
> +VOID
> +LcdShutdown (VOID)
> +{
> + // Disable graphics layer.
> + LayerGraphicsDisable ();
> +}
> diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..4504c6965bf58b1ac19cf717360c7a603ff2cd61
> --- /dev/null
> +++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
> @@ -0,0 +1,243 @@
> +/** @file
> +
> + This header file contains the platform independent parts of ARM Mali DP
> +
> + Copyright (c) 2017-2018, Arm Limited. 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 ARMMALIDP_H_
> +#define ARMMALIDP_H_
> +
> +#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
> +
> +// MALI DP Ids
> +#define MALIDP_NOT_PRESENT 0xFFF
> +#define MALIDP_500 0x500
> +#define MALIDP_550 0x550
> +#define MALIDP_650 0x650
> +
> +// DP500 Peripheral Ids
> +#define DP500_ID_PART_0 0x00
> +#define DP500_ID_DES_0 0xB
> +#define DP500_ID_PART_1 0x5
> +
> +#define DP500_ID_REVISION 0x1
> +#define DP500_ID_JEDEC 0x1
> +#define DP500_ID_DES_1 0x3
> +
> +#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
> +#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4) \
> + | DP500_ID_PART_1)
> +#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4) \
> + | (DP500_ID_JEDEC << 3) \
> + | (DP500_ID_DES_1))
> +
> +// DP550 Peripheral Ids
> +#define DP550_ID_PART_0 0x50
> +#define DP550_ID_DES_0 0xB
> +#define DP550_ID_PART_1 0x5
> +
> +#define DP550_ID_REVISION 0x0
> +#define DP550_ID_JEDEC 0x1
> +#define DP550_ID_DES_1 0x3
> +
> +#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
> +#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4) \
> + | DP550_ID_PART_1)
> +#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4) \
> + | (DP550_ID_JEDEC << 3) \
> + | (DP550_ID_DES_1))
> +
> +// DP650 Peripheral Ids
> +#define DP650_ID_PART_0 0x50
> +#define DP650_ID_DES_0 0xB
> +#define DP650_ID_PART_1 0x6
> +
> +#define DP650_ID_REVISION 0x0
> +#define DP650_ID_JEDEC 0x1
> +#define DP650_ID_DES_1 0x3
> +
> +#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
> +#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4) \
> + | DP650_ID_PART_1)
> +#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4) \
> + | (DP650_ID_JEDEC << 3) \
> + | (DP650_ID_DES_1))
> +
> +// Display Engine (DE) control register offsets for DP550/DP650
> +#define DP_DE_STATUS 0x00000
> +#define DP_DE_IRQ_SET 0x00004
> +#define DP_DE_IRQ_MASK 0x00008
> +#define DP_DE_IRQ_CLEAR 0x0000C
> +#define DP_DE_CONTROL 0x00010
> +#define DP_DE_PROG_LINE 0x00014
> +#define DP_DE_AXI_CONTROL 0x00018
> +#define DP_DE_AXI_QOS 0x0001C
> +#define DP_DE_DISPLAY_FUNCTION 0x00020
> +
> +#define DP_DE_H_INTERVALS 0x00030
> +#define DP_DE_V_INTERVALS 0x00034
> +#define DP_DE_SYNC_CONTROL 0x00038
> +#define DP_DE_HV_ACTIVESIZE 0x0003C
> +#define DP_DE_DISPLAY_SIDEBAND 0x00040
> +#define DP_DE_BACKGROUND_COLOR 0x00044
> +#define DP_DE_DISPLAY_SPLIT 0x00048
> +#define DP_DE_OUTPUT_DEPTH 0x0004C
> +
> +// Display Engine (DE) control register offsets for DP500
> +#define DP_DE_DP500_CORE_ID 0x00018
> +#define DP_DE_DP500_CONTROL 0x0000C
> +#define DP_DE_DP500_PROG_LINE 0x00010
> +#define DP_DE_DP500_H_INTERVALS 0x00028
> +#define DP_DE_DP500_V_INTERVALS 0x0002C
> +#define DP_DE_DP500_SYNC_CONTROL 0x00030
> +#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
> +#define DP_DE_DP500_BG_COLOR_RG 0x0003C
> +#define DP_DE_DP500_BG_COLOR_B 0x00040
> +
> +/* Display Engine (DE) graphics layer (LG) register offsets
> + * NOTE: For DP500 it will be LG2.
> + */
> +#define DE_LG_OFFSET 0x00300
> +#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
> +#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
> +#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
> +#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
> +#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
> +#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
> +#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
> +#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
> +#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
> +#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
> +#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
> +#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
> +
> +// Display core (DC) control register offsets.
> +#define DP_DC_OFFSET 0x0C000
> +#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
> +#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
> +#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
> +#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
> +#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
> +#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
> +#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
> +
> +// DP500 has a global configuration register.
> +#define DP_DP500_CONFIG_VALID (0xF00)
> +
> +// Display core ID register offsets.
> +#define DP_DC_ID_OFFSET 0x0FF00
> +#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
> +#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
> +#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
> +#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
> +#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
> +#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
> +#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
> +#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
> +#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
> +
> +#define DP_DP500_ID_OFFSET 0x0F00
> +#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET + 0xD0)
> +#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET + 0xD4)
> +#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET + 0xE0)
> +#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET + 0xE4)
> +#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET + 0xE8)
> +#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET + 0xF0)
> +#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET + 0xF4)
> +#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET + 0xF8)
> +#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET + 0xFC)
> +
> +// Display status configuration mode activation flag
> +#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
> +
> +// Display core control configuration mode
> +#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
> +#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
> +#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
> +
> +#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
> +#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
> +
> +// Display core configuration valid register
> +#define DP_DC_CONFIG_VALID_CVAL (0x1U)
> +
> +// DC_CORE_ID
> +// Display core version register PRODUCT_ID
> +#define DP_DC_CORE_ID_SHIFT 16
> +#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
> +
> +// Timing settings
> +#define DP_DE_HBACKPORCH_SHIFT 16
> +#define DP_DE_VBACKPORCH_SHIFT 16
> +#define DP_DE_VSP_SHIFT 28
> +#define DP_DE_VSYNCWIDTH_SHIFT 16
> +#define DP_DE_HSP_SHIFT 13
> +#define DP_DE_V_ACTIVE_SHIFT 16
> +
> +// BACKGROUND_COLOR
> +#define DP_DE_BG_R_PIXEL_SHIFT 16
> +#define DP_DE_BG_G_PIXEL_SHIFT 8
> +
> +//Graphics layer LG_FORMAT Pixel Format
> +#define DP_PIXEL_FORMAT_ARGB_8888 0x8
> +#define DP_PIXEL_FORMAT_ABGR_8888 0x9
> +#define DP_PIXEL_FORMAT_RGBA_8888 0xA
> +#define DP_PIXEL_FORMAT_BGRA_8888 0xB
> +#define DP_PIXEL_FORMAT_XRGB_8888 0x10
> +#define DP_PIXEL_FORMAT_XBGR_8888 0x11
> +#define DP_PIXEL_FORMAT_RGBX_8888 0x12
> +#define DP_PIXEL_FORMAT_BGRX_8888 0x13
> +#define DP_PIXEL_FORMAT_RGB_888 0x18
> +#define DP_PIXEL_FORMAT_BGR_888 0x19
> +
> +// DP500 format code are different than DP550/DP650
> +#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
> +#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
> +#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
> +#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
> +
> +// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
> +#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
> +#define DP_DE_LG_PTR_HIGH_SHIFT 32
> +
> +// Graphics layer LG_CONTROL register characteristics
> +#define DP_DE_LG_L_ALPHA_SHIFT 16
> +#define DP_DE_LG_CHK_SHIFT 15
> +#define DP_DE_LG_PMUL_SHIFT 14
> +#define DP_DE_LG_COM_SHIFT 12
> +#define DP_DE_LG_VFP_SHIFT 11
> +#define DP_DE_LG_HFP_SHIFT 10
> +#define DP_DE_LG_ROTATION_SHIFT 8
> +
> +#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
> +#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
> +#define DP_DE_LG_LAYER_BLEND_BG 0x2U
> +#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
> +#define DP_DE_LG_ENABLE 0x1U
> +
> +// Graphics layer LG_IN_SIZE register characteristics
> +#define DP_DE_LG_V_IN_SIZE_SHIFT 16
> +
> +// Graphics layer LG_CMP_SIZE register characteristics
> +#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
> +#define DP_DE_LG_V_OFFSET_SHIFT 16
> +
> +// Helper display timing macro functions.
> +#define H_INTERVALS(Hfp, Hbp) ((Hbp << DP_DE_HBACKPORCH_SHIFT) | Hfp)
> +#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT) | Vfp)
> +#define SYNC_WIDTH(Hsw, Vsw) ((Vsw << DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
> +#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) | Hor)
> +
> +// Helper layer graphics macros.
> +#define FRAME_IN_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_IN_SIZE_SHIFT) | Hor)
> +#define FRAME_CMP_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
> +
> +#endif /* ARMMALIDP_H_ */
> diff --git a/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..4cf020e4c314b17f7944336512ca8688911cf1be
> --- /dev/null
> +++ b/ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
> @@ -0,0 +1,43 @@
> +#/** @file
> +#
> +# Component description file for ArmMaliDp module
> +#
> +# Copyright (c) 2017-2018, Arm Limited. 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 = 0x00010019
> + BASE_NAME = ArmMaliDp
> + FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = LcdHwLib
> +
> +[Sources.common]
> + ArmMaliDp.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + IoLib
> + LcdPlatformLib
> + UefiLib
> +
> +[FixedPcd]
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> +
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (13 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
2018-04-23 11:11 ` Leif Lindholm
2018-03-20 16:12 ` [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol Girish Pathak
2018-04-23 17:11 ` [PATCH v3 00/16] Update GOP Leif Lindholm
16 siblings, 2 replies; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
Upcoming new component ArmPkg/Drivers/ArmScmiDxe is dependent on
platform specific ArmMtlLib library implementation, however in order
to be able to build the ArmScmiDxe component outside of the context of a
particular platform, this change adds Null implementation of the
ArmMtlLib along with ARM MTL library header.
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>
---
ArmPkg/ArmPkg.dec | 3 +-
ArmPkg/Include/Library/ArmMtlLib.h | 137 ++++++++++++++++++++
ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c | 108 +++++++++++++++
ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf | 26 ++++
4 files changed, 273 insertions(+), 1 deletion(-)
diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index a55b6268ff85ffd7da140be813ec875f7f242c4d..881751d81c6384a3eb0b4c180c76d01a58266a74 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved.
+# Copyright (c) 2011 - 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
@@ -40,6 +40,7 @@ [LibraryClasses.common]
ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h
ArmGicArchLib|Include/Library/ArmGicArchLib.h
ArmSvcLib|Include/Library/ArmSvcLib.h
+ ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h
[Guids.common]
gArmTokenSpaceGuid = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }
diff --git a/ArmPkg/Include/Library/ArmMtlLib.h b/ArmPkg/Include/Library/ArmMtlLib.h
new file mode 100644
index 0000000000000000000000000000000000000000..4218a741e5ebddd08022b94354d5ef47576cd3b8
--- /dev/null
+++ b/ArmPkg/Include/Library/ArmMtlLib.h
@@ -0,0 +1,137 @@
+/** @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
+**/
+
+#ifndef ARM_MTL_LIB_H_
+#define ARM_MTL_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+// Ideally we don't need packed struct. However we can't rely on compilers.
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Reserved1;
+ UINT32 ChannelStatus;
+ UINT64 Reserved2;
+ UINT32 Flags;
+ UINT32 Length;
+ UINT32 MessageHeader;
+
+ // NOTE: Since EDK2 does not allow flexible array member [] we declare
+ // here array of 1 element length. However below is used as a variable
+ // length array.
+ UINT32 Payload[1]; // size less object gives offset to payload.
+} MTL_MAILBOX;
+
+#pragma pack()
+
+// Channel Type, Low-priority, and High-priority
+typedef enum {
+ MTL_CHANNEL_TYPE_LOW = 0,
+ MTL_CHANNEL_TYPE_HIGH = 1
+} MTL_CHANNEL_TYPE;
+
+typedef struct {
+ UINT64 PhysicalAddress;
+ UINT32 ModifyMask;
+ UINT32 PreserveMask;
+} MTL_DOORBELL;
+
+typedef struct {
+ MTL_CHANNEL_TYPE ChannelType;
+ MTL_MAILBOX * CONST MailBox;
+ MTL_DOORBELL DoorBell;
+} MTL_CHANNEL;
+
+/** Wait until channel is free.
+
+ @param[in] Channel Pointer to a channel.
+ @param[in] TimeOutInMicroSeconds Time out in micro seconds.
+
+ @retval EFI_SUCCESS Channel is free.
+ @retval EFI_TIMEOUT Time out error.
+**/
+EFI_STATUS
+MtlWaitUntilChannelFree (
+ IN MTL_CHANNEL *Channel,
+ IN UINT64 TimeOutInMicroSeconds
+ );
+
+/** Return the address of the message payload.
+
+ @param[in] Channel Pointer to a channel.
+
+ @retval UINT32* Pointer to the payload.
+**/
+UINT32*
+MtlGetChannelPayload (
+ IN MTL_CHANNEL *Channel
+ );
+
+/** Return pointer to a channel for the requested channel type.
+
+ @param[in] ChannelType ChannelType, Low or High priority channel.
+ MTL_CHANNEL_TYPE_LOW or
+ MTL_CHANNEL_TYPE_HIGH
+
+ @param[out] Channel Holds pointer to the channel.
+
+ @retval EFI_SUCCESS Pointer to channel is returned.
+ @retval EFI_UNSUPPORTED Requested channel type not supported.
+**/
+EFI_STATUS
+MtlGetChannel (
+ IN MTL_CHANNEL_TYPE ChannelType,
+ OUT MTL_CHANNEL **Channel
+ );
+
+/** Mark the channel busy and ring the doorbell.
+
+ @param[in] Channel Pointer to a channel.
+ @param[in] MessageHeader Message header.
+
+ @param[out] PayloadLength Message length.
+
+ @retval EFI_SUCCESS Message sent successfully.
+ @retval EFI_DEVICE_ERROR Channel is busy.
+**/
+EFI_STATUS
+MtlSendMessage (
+ IN MTL_CHANNEL *Channel,
+ IN UINT32 MessageHeader,
+ OUT UINT32 PayloadLength
+ );
+
+/** Wait for a response on a channel.
+
+ If channel is free after sending message, it implies SCP responded
+ with a response on the channel.
+
+ @param[in] Channel Pointer to a channel.
+
+ @retval EFI_SUCCESS Message received successfully.
+ @retval EFI_TIMEOUT Time out error.
+**/
+EFI_STATUS
+MtlReceiveMessage (
+ IN MTL_CHANNEL *Channel,
+ OUT UINT32 *MessageHeader,
+ OUT UINT32 *PayloadLength
+ );
+
+#endif /* ARM_MTL_LIB_H_ */
+
diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
new file mode 100644
index 0000000000000000000000000000000000000000..f1862371113e342e4a4c8059be27884842210d08
--- /dev/null
+++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
@@ -0,0 +1,108 @@
+/** @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 <Library/ArmMtlLib.h>
+#include <Library/DebugLib.h>
+
+/** Wait until channel is free.
+
+ @param[in] Channel Pointer to a channel.
+ @param[in] TimeOutInMicroSeconds Timeout in micro seconds.
+
+ @retval EFI_UNSUPPORTED Interface not implemented.
+**/
+EFI_STATUS
+MtlWaitUntilChannelFree (
+ IN MTL_CHANNEL *Channel,
+ IN UINTN TimeOutInMicroSeconds
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/** Return the address of the message payload.
+
+ @param[in] Channel Pointer to a channel.
+
+ @retval UINT32* Pointer to the payload.
+**/
+UINT32*
+MtlGetChannelPayload (
+ IN MTL_CHANNEL *Channel
+ )
+{
+ ASSERT (FALSE);
+ return NULL;
+}
+
+/** Return pointer to a channel for the requested channel type.
+
+ @param[in] ChannelType ChannelType, Low or High priority channel.
+ MTL_CHANNEL_TYPE_LOW or
+ MTL_CHANNEL_TYPE_HIGH
+
+ @param[out] Channel Holds pointer to the channel.
+
+ @retval EFI_UNSUPPORTED Requested channel type not supported or
+ interface not implemented.
+**/
+EFI_STATUS
+MtlGetChannel (
+ IN MTL_CHANNEL_TYPE ChannelType,
+ OUT MTL_CHANNEL **Channel
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/** Mark the channel busy and ring the doorbell.
+
+ @param[in] Channel Pointer to a channel.
+ @param[in] MessageHeader Message header.
+
+ @param[out] PayloadLength Message length.
+
+ @retval EFI_UNSUPPORTED Interface not implemented.
+**/
+EFI_STATUS
+MtlSendMessage (
+ IN MTL_CHANNEL *Channel,
+ IN UINT32 MessageHeader,
+ OUT UINT32 PayloadLength
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/** Wait for a response on a channel.
+
+ If channel is free after sending message, it implies SCP responded
+ with a response on the channel.
+
+ @param[in] Channel Pointer to a channel.
+
+ @retval EFI_UNSUPPORTED Interface not implemented.
+**/
+EFI_STATUS
+MtlReceiveMessage (
+ IN MTL_CHANNEL *Channel,
+ OUT UINT32 *MessageHeader,
+ OUT UINT32 *PayloadLength
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..9c0426b00e48e791dae9ad11e2f47d248d9c09ce
--- /dev/null
+++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
@@ -0,0 +1,26 @@
+#/** @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.
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010019
+ BASE_NAME = ArmMtlNullLib
+ FILE_GUID = 05810525-FDEC-4006-9F1F-37609B3675FA
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ArmMtlLib
+
+[Sources.common]
+ ArmMtlNullLib.c
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ MdePkg/MdePkg.dec
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation
2018-03-20 16:12 ` [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation Girish Pathak
@ 2018-03-21 12:54 ` Evan Lloyd
2018-04-23 11:11 ` Leif Lindholm
1 sibling, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:54 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 15/16] ArmPkg: MTL Library interface and Null
> library implementation
>
> Upcoming new component ArmPkg/Drivers/ArmScmiDxe is dependent on
> platform specific ArmMtlLib library implementation, however in order to be
> able to build the ArmScmiDxe component outside of the context of a
> particular platform, this change adds Null implementation of the ArmMtlLib
> along with ARM MTL library header.
>
> 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>
> ---
> ArmPkg/ArmPkg.dec | 3 +-
> ArmPkg/Include/Library/ArmMtlLib.h | 137
> ++++++++++++++++++++
> ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c | 108
> +++++++++++++++
> ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf | 26 ++++
> 4 files changed, 273 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index
> a55b6268ff85ffd7da140be813ec875f7f242c4d..881751d81c6384a3eb0b4c
> 180c76d01a58266a74 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -2,7 +2,7 @@
> # ARM processor package.
> #
> # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR> -#
> Copyright (c) 2011 - 2017, ARM Limited. All rights reserved.
> +# Copyright (c) 2011 - 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
> @@ -40,6 +40,7 @@ [LibraryClasses.common]
> ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h
> ArmGicArchLib|Include/Library/ArmGicArchLib.h
> ArmSvcLib|Include/Library/ArmSvcLib.h
> + ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h
>
> [Guids.common]
> gArmTokenSpaceGuid = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6,
> 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }
> diff --git a/ArmPkg/Include/Library/ArmMtlLib.h
> b/ArmPkg/Include/Library/ArmMtlLib.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..4218a741e5ebddd080
> 22b94354d5ef47576cd3b8
> --- /dev/null
> +++ b/ArmPkg/Include/Library/ArmMtlLib.h
> @@ -0,0 +1,137 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_MTL_LIB_H_
> +#define ARM_MTL_LIB_H_
> +
> +#include <Uefi/UefiBaseType.h>
> +
> +// Ideally we don't need packed struct. However we can't rely on compilers.
> +#pragma pack(1)
> +
> +typedef struct {
> + UINT32 Reserved1;
> + UINT32 ChannelStatus;
> + UINT64 Reserved2;
> + UINT32 Flags;
> + UINT32 Length;
> + UINT32 MessageHeader;
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we
> +declare
> + // here array of 1 element length. However below is used as a
> +variable
> + // length array.
> + UINT32 Payload[1]; // size less object gives offset to payload.
> +} MTL_MAILBOX;
> +
> +#pragma pack()
> +
> +// Channel Type, Low-priority, and High-priority typedef enum {
> + MTL_CHANNEL_TYPE_LOW = 0,
> + MTL_CHANNEL_TYPE_HIGH = 1
> +} MTL_CHANNEL_TYPE;
> +
> +typedef struct {
> + UINT64 PhysicalAddress;
> + UINT32 ModifyMask;
> + UINT32 PreserveMask;
> +} MTL_DOORBELL;
> +
> +typedef struct {
> + MTL_CHANNEL_TYPE ChannelType;
> + MTL_MAILBOX * CONST MailBox;
> + MTL_DOORBELL DoorBell;
> +} MTL_CHANNEL;
> +
> +/** Wait until channel is free.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] TimeOutInMicroSeconds Time out in micro seconds.
> +
> + @retval EFI_SUCCESS Channel is free.
> + @retval EFI_TIMEOUT Time out error.
> +**/
> +EFI_STATUS
> +MtlWaitUntilChannelFree (
> + IN MTL_CHANNEL *Channel,
> + IN UINT64 TimeOutInMicroSeconds
> + );
> +
> +/** Return the address of the message payload.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval UINT32* Pointer to the payload.
> +**/
> +UINT32*
> +MtlGetChannelPayload (
> + IN MTL_CHANNEL *Channel
> + );
> +
> +/** Return pointer to a channel for the requested channel type.
> +
> + @param[in] ChannelType ChannelType, Low or High priority channel.
> + MTL_CHANNEL_TYPE_LOW or
> + MTL_CHANNEL_TYPE_HIGH
> +
> + @param[out] Channel Holds pointer to the channel.
> +
> + @retval EFI_SUCCESS Pointer to channel is returned.
> + @retval EFI_UNSUPPORTED Requested channel type not supported.
> +**/
> +EFI_STATUS
> +MtlGetChannel (
> + IN MTL_CHANNEL_TYPE ChannelType,
> + OUT MTL_CHANNEL **Channel
> + );
> +
> +/** Mark the channel busy and ring the doorbell.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] MessageHeader Message header.
> +
> + @param[out] PayloadLength Message length.
> +
> + @retval EFI_SUCCESS Message sent successfully.
> + @retval EFI_DEVICE_ERROR Channel is busy.
> +**/
> +EFI_STATUS
> +MtlSendMessage (
> + IN MTL_CHANNEL *Channel,
> + IN UINT32 MessageHeader,
> + OUT UINT32 PayloadLength
> + );
> +
> +/** Wait for a response on a channel.
> +
> + If channel is free after sending message, it implies SCP responded
> + with a response on the channel.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval EFI_SUCCESS Message received successfully.
> + @retval EFI_TIMEOUT Time out error.
> +**/
> +EFI_STATUS
> +MtlReceiveMessage (
> + IN MTL_CHANNEL *Channel,
> + OUT UINT32 *MessageHeader,
> + OUT UINT32 *PayloadLength
> + );
> +
> +#endif /* ARM_MTL_LIB_H_ */
> +
> diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
> b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..f1862371113e342e4a
> 4c8059be27884842210d08
> --- /dev/null
> +++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
> @@ -0,0 +1,108 @@
> +/** @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 <Library/ArmMtlLib.h>
> +#include <Library/DebugLib.h>
> +
> +/** Wait until channel is free.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] TimeOutInMicroSeconds Timeout in micro seconds.
> +
> + @retval EFI_UNSUPPORTED Interface not implemented.
> +**/
> +EFI_STATUS
> +MtlWaitUntilChannelFree (
> + IN MTL_CHANNEL *Channel,
> + IN UINTN TimeOutInMicroSeconds
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/** Return the address of the message payload.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval UINT32* Pointer to the payload.
> +**/
> +UINT32*
> +MtlGetChannelPayload (
> + IN MTL_CHANNEL *Channel
> + )
> +{
> + ASSERT (FALSE);
> + return NULL;
> +}
> +
> +/** Return pointer to a channel for the requested channel type.
> +
> + @param[in] ChannelType ChannelType, Low or High priority channel.
> + MTL_CHANNEL_TYPE_LOW or
> + MTL_CHANNEL_TYPE_HIGH
> +
> + @param[out] Channel Holds pointer to the channel.
> +
> + @retval EFI_UNSUPPORTED Requested channel type not supported or
> + interface not implemented.
> +**/
> +EFI_STATUS
> +MtlGetChannel (
> + IN MTL_CHANNEL_TYPE ChannelType,
> + OUT MTL_CHANNEL **Channel
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/** Mark the channel busy and ring the doorbell.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] MessageHeader Message header.
> +
> + @param[out] PayloadLength Message length.
> +
> + @retval EFI_UNSUPPORTED Interface not implemented.
> +**/
> +EFI_STATUS
> +MtlSendMessage (
> + IN MTL_CHANNEL *Channel,
> + IN UINT32 MessageHeader,
> + OUT UINT32 PayloadLength
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/** Wait for a response on a channel.
> +
> + If channel is free after sending message, it implies SCP responded
> + with a response on the channel.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval EFI_UNSUPPORTED Interface not implemented.
> +**/
> +EFI_STATUS
> +MtlReceiveMessage (
> + IN MTL_CHANNEL *Channel,
> + OUT UINT32 *MessageHeader,
> + OUT UINT32 *PayloadLength
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..9c0426b00e48e791da
> e9ad11e2f47d248d9c09ce
> --- /dev/null
> +++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> @@ -0,0 +1,26 @@
> +#/** @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.
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010019
> + BASE_NAME = ArmMtlNullLib
> + FILE_GUID = 05810525-FDEC-4006-9F1F-37609B3675FA
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ArmMtlLib
> +
> +[Sources.common]
> + ArmMtlNullLib.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + MdePkg/MdePkg.dec
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation
2018-03-20 16:12 ` [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
@ 2018-04-23 11:11 ` Leif Lindholm
1 sibling, 0 replies; 40+ messages in thread
From: Leif Lindholm @ 2018-04-23 11:11 UTC (permalink / raw)
To: Girish Pathak
Cc: edk2-devel, ard.biesheuvel, Matteo.Carlini, Stephanie.Hughes-Fitt,
nd
On Tue, Mar 20, 2018 at 04:12:11PM +0000, Girish Pathak wrote:
> Upcoming new component ArmPkg/Drivers/ArmScmiDxe is dependent on
> platform specific ArmMtlLib library implementation, however in order
> to be able to build the ArmScmiDxe component outside of the context of a
> particular platform, this change adds Null implementation of the
> ArmMtlLib along with ARM MTL library header.
>
> 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>
> ---
> ArmPkg/ArmPkg.dec | 3 +-
> ArmPkg/Include/Library/ArmMtlLib.h | 137 ++++++++++++++++++++
> ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c | 108 +++++++++++++++
> ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf | 26 ++++
> 4 files changed, 273 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> index a55b6268ff85ffd7da140be813ec875f7f242c4d..881751d81c6384a3eb0b4c180c76d01a58266a74 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -2,7 +2,7 @@
> # ARM processor package.
> #
> # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
> -# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved.
> +# Copyright (c) 2011 - 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
> @@ -40,6 +40,7 @@ [LibraryClasses.common]
> ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h
> ArmGicArchLib|Include/Library/ArmGicArchLib.h
> ArmSvcLib|Include/Library/ArmSvcLib.h
> + ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h
Unless you scream before I get around to pushing, I'm going to move
that line up one step.
/
Leif
>
> [Guids.common]
> gArmTokenSpaceGuid = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }
> diff --git a/ArmPkg/Include/Library/ArmMtlLib.h b/ArmPkg/Include/Library/ArmMtlLib.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..4218a741e5ebddd08022b94354d5ef47576cd3b8
> --- /dev/null
> +++ b/ArmPkg/Include/Library/ArmMtlLib.h
> @@ -0,0 +1,137 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_MTL_LIB_H_
> +#define ARM_MTL_LIB_H_
> +
> +#include <Uefi/UefiBaseType.h>
> +
> +// Ideally we don't need packed struct. However we can't rely on compilers.
> +#pragma pack(1)
> +
> +typedef struct {
> + UINT32 Reserved1;
> + UINT32 ChannelStatus;
> + UINT64 Reserved2;
> + UINT32 Flags;
> + UINT32 Length;
> + UINT32 MessageHeader;
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + UINT32 Payload[1]; // size less object gives offset to payload.
> +} MTL_MAILBOX;
> +
> +#pragma pack()
> +
> +// Channel Type, Low-priority, and High-priority
> +typedef enum {
> + MTL_CHANNEL_TYPE_LOW = 0,
> + MTL_CHANNEL_TYPE_HIGH = 1
> +} MTL_CHANNEL_TYPE;
> +
> +typedef struct {
> + UINT64 PhysicalAddress;
> + UINT32 ModifyMask;
> + UINT32 PreserveMask;
> +} MTL_DOORBELL;
> +
> +typedef struct {
> + MTL_CHANNEL_TYPE ChannelType;
> + MTL_MAILBOX * CONST MailBox;
> + MTL_DOORBELL DoorBell;
> +} MTL_CHANNEL;
> +
> +/** Wait until channel is free.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] TimeOutInMicroSeconds Time out in micro seconds.
> +
> + @retval EFI_SUCCESS Channel is free.
> + @retval EFI_TIMEOUT Time out error.
> +**/
> +EFI_STATUS
> +MtlWaitUntilChannelFree (
> + IN MTL_CHANNEL *Channel,
> + IN UINT64 TimeOutInMicroSeconds
> + );
> +
> +/** Return the address of the message payload.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval UINT32* Pointer to the payload.
> +**/
> +UINT32*
> +MtlGetChannelPayload (
> + IN MTL_CHANNEL *Channel
> + );
> +
> +/** Return pointer to a channel for the requested channel type.
> +
> + @param[in] ChannelType ChannelType, Low or High priority channel.
> + MTL_CHANNEL_TYPE_LOW or
> + MTL_CHANNEL_TYPE_HIGH
> +
> + @param[out] Channel Holds pointer to the channel.
> +
> + @retval EFI_SUCCESS Pointer to channel is returned.
> + @retval EFI_UNSUPPORTED Requested channel type not supported.
> +**/
> +EFI_STATUS
> +MtlGetChannel (
> + IN MTL_CHANNEL_TYPE ChannelType,
> + OUT MTL_CHANNEL **Channel
> + );
> +
> +/** Mark the channel busy and ring the doorbell.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] MessageHeader Message header.
> +
> + @param[out] PayloadLength Message length.
> +
> + @retval EFI_SUCCESS Message sent successfully.
> + @retval EFI_DEVICE_ERROR Channel is busy.
> +**/
> +EFI_STATUS
> +MtlSendMessage (
> + IN MTL_CHANNEL *Channel,
> + IN UINT32 MessageHeader,
> + OUT UINT32 PayloadLength
> + );
> +
> +/** Wait for a response on a channel.
> +
> + If channel is free after sending message, it implies SCP responded
> + with a response on the channel.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval EFI_SUCCESS Message received successfully.
> + @retval EFI_TIMEOUT Time out error.
> +**/
> +EFI_STATUS
> +MtlReceiveMessage (
> + IN MTL_CHANNEL *Channel,
> + OUT UINT32 *MessageHeader,
> + OUT UINT32 *PayloadLength
> + );
> +
> +#endif /* ARM_MTL_LIB_H_ */
> +
> diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..f1862371113e342e4a4c8059be27884842210d08
> --- /dev/null
> +++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
> @@ -0,0 +1,108 @@
> +/** @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 <Library/ArmMtlLib.h>
> +#include <Library/DebugLib.h>
> +
> +/** Wait until channel is free.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] TimeOutInMicroSeconds Timeout in micro seconds.
> +
> + @retval EFI_UNSUPPORTED Interface not implemented.
> +**/
> +EFI_STATUS
> +MtlWaitUntilChannelFree (
> + IN MTL_CHANNEL *Channel,
> + IN UINTN TimeOutInMicroSeconds
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/** Return the address of the message payload.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval UINT32* Pointer to the payload.
> +**/
> +UINT32*
> +MtlGetChannelPayload (
> + IN MTL_CHANNEL *Channel
> + )
> +{
> + ASSERT (FALSE);
> + return NULL;
> +}
> +
> +/** Return pointer to a channel for the requested channel type.
> +
> + @param[in] ChannelType ChannelType, Low or High priority channel.
> + MTL_CHANNEL_TYPE_LOW or
> + MTL_CHANNEL_TYPE_HIGH
> +
> + @param[out] Channel Holds pointer to the channel.
> +
> + @retval EFI_UNSUPPORTED Requested channel type not supported or
> + interface not implemented.
> +**/
> +EFI_STATUS
> +MtlGetChannel (
> + IN MTL_CHANNEL_TYPE ChannelType,
> + OUT MTL_CHANNEL **Channel
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/** Mark the channel busy and ring the doorbell.
> +
> + @param[in] Channel Pointer to a channel.
> + @param[in] MessageHeader Message header.
> +
> + @param[out] PayloadLength Message length.
> +
> + @retval EFI_UNSUPPORTED Interface not implemented.
> +**/
> +EFI_STATUS
> +MtlSendMessage (
> + IN MTL_CHANNEL *Channel,
> + IN UINT32 MessageHeader,
> + OUT UINT32 PayloadLength
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/** Wait for a response on a channel.
> +
> + If channel is free after sending message, it implies SCP responded
> + with a response on the channel.
> +
> + @param[in] Channel Pointer to a channel.
> +
> + @retval EFI_UNSUPPORTED Interface not implemented.
> +**/
> +EFI_STATUS
> +MtlReceiveMessage (
> + IN MTL_CHANNEL *Channel,
> + OUT UINT32 *MessageHeader,
> + OUT UINT32 *PayloadLength
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..9c0426b00e48e791dae9ad11e2f47d248d9c09ce
> --- /dev/null
> +++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> @@ -0,0 +1,26 @@
> +#/** @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.
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010019
> + BASE_NAME = ArmMtlNullLib
> + FILE_GUID = 05810525-FDEC-4006-9F1F-37609B3675FA
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ArmMtlLib
> +
> +[Sources.common]
> + ArmMtlNullLib.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + MdePkg/MdePkg.dec
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (14 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation Girish Pathak
@ 2018-03-20 16:12 ` Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
2018-04-23 11:31 ` Leif Lindholm
2018-04-23 17:11 ` [PATCH v3 00/16] Update GOP Leif Lindholm
16 siblings, 2 replies; 40+ messages in thread
From: Girish Pathak @ 2018-03-20 16:12 UTC (permalink / raw)
To: edk2-devel
Cc: ard.biesheuvel, leif.lindholm, Matteo.Carlini,
Stephanie.Hughes-Fitt, nd
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 93416 bytes --]
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>
---
Notes:
v3:
- Please rename ArmMtl.h to ArmMtlLibi.h, and
declare it as a library class in the package file. [Ard]
Done, however ArmMtlLib.h is now part of earlier commit [Girish]
- Move ArmScmiDxe to ArmPkg from ArmPlatformPkg [Ard]
Done [Girish]
- Declare gArmScmiBaseProtocolGuid and similar
protocols Guids in ArmPkg.dec [Ard]
Done [Girish]
- Replace flexible array member [] with [1] [Ard]
Done [Girish]
- Move protocol init function which are not part of
of protocol like ScmiBaseProtocolInit elsewhere [Ard]
Done [Girish]
- Please don't put stuff in Include/Drivers. [Ard]
Moved headers to Include/Protocol. [Girish]
ArmPkg/ArmPkg.dec | 13 +
ArmPkg/ArmPkg.dsc | 6 +-
ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h | 46 ++
ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 84 ++++
ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf | 53 +++
ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h | 55 +++
ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 262 +++++++++++
ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c | 318 ++++++++++++++
ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 418 ++++++++++++++++++
ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 138 ++++++
ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 41 ++
ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 457 ++++++++++++++++++++
ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h | 174 ++++++++
ArmPkg/Include/Protocol/ArmScmi.h | 27 ++
ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h | 174 ++++++++
ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 218 ++++++++++
ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h | 265 ++++++++++++
17 files changed, 2748 insertions(+), 1 deletion(-)
diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 881751d81c6384a3eb0b4c180c76d01a58266a74..16f7e40046429142b44b526043b61a3d5e089d2c 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -51,6 +51,19 @@ [Guids.common]
gArmGicDxeFileGuid = { 0xde371f7c, 0xdec4, 0x4d21, { 0xad, 0xf1, 0x59, 0x3a, 0xbc, 0xc1, 0x58, 0x82 } }
+[Protocols.common]
+ ## Arm System Control and Management Interface(SCMI) Base protocol
+ ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
+ gArmScmiBaseProtocolGuid = { 0xd7e5abe9, 0x33ab, 0x418e, { 0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } }
+
+ ## Arm System Control and Management Interface(SCMI) Clock management protocol
+ ## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
+ gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
+
+ ## Arm System Control and Management Interface(SCMI) Clock management protocol
+ ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
+ gArmScmiPerformanceProtocolGuid = { 0x9b8ba84, 0x3dd3, 0x49a6, { 0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } }
+
[Ppis]
## Include/Ppi/ArmMpCoreInfo.h
gArmMpCoreInfoPpiGuid = { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d, 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} }
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 526909458e0d80dbc5a65c8ad12ec1095dda48d2..22332090db7111e0668607a16288cefc1bace926 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
-# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
@@ -87,6 +87,8 @@ [LibraryClasses.common]
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+ ArmMtlLib|ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
+
[LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
@@ -144,5 +146,7 @@ [Components.common]
ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+ ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
+
[Components.AARCH64]
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
new file mode 100644
index 0000000000000000000000000000000000000000..79c057d44128008ec276e3d58d8f1098c6a779b2
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
@@ -0,0 +1,46 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
+#define ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
+
+// Return values of BASE_DISCOVER_LIST_PROTOCOLS command.
+typedef struct {
+ UINT32 NumProtocols;
+
+ // Array of four protocols in each element
+ // Total elements = 1 + (NumProtocols-1)/4
+
+ // NOTE: Since EDK2 does not allow flexible array member [] we declare
+ // here array of 1 element length. However below is used as a variable
+ // length array.
+ UINT8 Protocols[1];
+} BASE_DISCOVER_LIST;
+
+/** Initialize Base protocol and install protocol on a given handle.
+
+ @param[in] Handle Handle to install Base protocol.
+
+ @retval EFI_SUCCESS Base protocol interface installed
+ successfully.
+**/
+EFI_STATUS
+ScmiBaseProtocolInit (
+ IN OUT EFI_HANDLE* Handle
+ );
+
+#endif /* ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_ */
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
new file mode 100644
index 0000000000000000000000000000000000000000..71245c16475d4d38d6dc66571b3fe3520c1cf1da
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
@@ -0,0 +1,84 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
+#define ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
+
+#pragma pack(1)
+
+// Clock rate in two 32bit words.
+typedef struct {
+ UINT32 Low;
+ UINT32 High;
+} CLOCK_RATE_DWORD;
+
+// Format of the returned rate array. Linear or Non-linear,.RatesFlag Bit[12]
+#define RATE_FORMAT_SHIFT 12
+#define RATE_FORMAT_MASK 0x0001
+#define RATE_FORMAT(RatesFlags) ((RatesFlags >> RATE_FORMAT_SHIFT) \
+ & RATE_FORMAT_MASK)
+
+// Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
+#define NUM_REMAIN_RATES_SHIFT 16
+#define NUM_REMAIN_RATES(RatesFlags) ((RatesFlags >> NUM_REMAIN_RATES_SHIFT))
+
+// Number of rates that are returned by a call.to the SCP, RatesFlag Bits[11:0]
+#define NUM_RATES_MASK 0x0FFF
+#define NUM_RATES(RatesFlags) (RatesFlags & NUM_RATES_MASK)
+
+// Return values for the CLOCK_DESCRIBER_RATE command.
+typedef struct {
+ UINT32 NumRatesFlags;
+
+ // NOTE: Since EDK2 does not allow flexible array member [] we declare
+ // here array of 1 element length. However below is used as a variable
+ // length array.
+ CLOCK_RATE_DWORD Rates[1];
+} CLOCK_DESCRIBE_RATES;
+
+#define CLOCK_SET_DEFAULT_FLAGS 0
+
+// Message parameters for CLOCK_RATE_SET command.
+typedef struct {
+ UINT32 Flags;
+ UINT32 ClockId;
+ CLOCK_RATE_DWORD Rate;
+} CLOCK_RATE_SET_ATTRIBUTES;
+
+// if ClockAttr Bit[0] is set then clock device is enabled.
+#define CLOCK_ENABLE_MASK 0x1
+#define CLOCK_ENABLED(ClockAttr) ((ClockAttr & CLOCK_ENABLE_MASK) == 1)
+
+typedef struct {
+ UINT32 Attributes;
+ UINT8 ClockName[SCMI_MAX_STR_LEN];
+} CLOCK_ATTRIBUTES;
+
+#pragma pack()
+
+/** Initialize clock management protocol and install protocol on a given handle.
+
+ @param[in] Handle Handle to install clock management protocol.
+
+ @retval EFI_SUCCESS Clock protocol interface installed successfully.
+**/
+EFI_STATUS
+ScmiClockProtocolInit (
+ IN EFI_HANDLE *Handle
+ );
+
+#endif /* ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_ */
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
new file mode 100644
index 0000000000000000000000000000000000000000..05ce9c04ce468d74e5c6d38739f9056f3fc48694
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
@@ -0,0 +1,53 @@
+#/** @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
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010019
+ BASE_NAME = ArmScmiDxe
+ FILE_GUID = 9585984C-F027-45E9-AFDF-ADAA6DFAAAC7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ArmScmiDxeEntryPoint
+
+[Sources.common]
+ Scmi.c
+ ScmiBaseProtocol.c
+ ScmiClockProtocol.c
+ ScmiDxe.c
+ ScmiPerformanceProtocol.c
+
+[Packages]
+ ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ArmLib
+ ArmMtlLib
+ DebugLib
+ IoLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[Protocols]
+ gArmScmiBaseProtocolGuid
+ gArmScmiClockProtocolGuid
+ gArmScmiPerformanceProtocolGuid
+
+[Depex]
+ TRUE
+
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
new file mode 100644
index 0000000000000000000000000000000000000000..4514f45a9f5dd960d2844a19b57a91b93149f1b9
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
@@ -0,0 +1,55 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
+#define ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
+
+#include <Protocol/ArmScmiPerformanceProtocol.h>
+
+// Number of performance levels returned by a call to the SCP, Lvls Bits[11:0]
+#define NUM_PERF_LEVELS_MASK 0x0FFF
+#define NUM_PERF_LEVELS(Lvls) (Lvls & NUM_PERF_LEVELS_MASK)
+
+// Number of performance levels remaining after a call to the SCP, Lvls Bits[31:16]
+#define NUM_REMAIN_PERF_LEVELS_SHIFT 16
+#define NUM_REMAIN_PERF_LEVELS(Lvls) (Lvls >> NUM_REMAIN_PERF_LEVELS_SHIFT)
+
+/** Return values for SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS command.
+ SCMI Spec § 4.5.2.5
+**/
+typedef struct {
+ UINT32 NumLevels;
+
+ // NOTE: Since EDK2 does not allow flexible array member [] we declare
+ // here array of 1 element length. However below is used as a variable
+ // length array.
+ SCMI_PERFORMANCE_LEVEL PerfLevel[1]; // Offset to array of performance levels
+} PERF_DESCRIBE_LEVELS;
+
+/** Initialize performance management protocol and install on a given Handle.
+
+ @param[in] Handle Handle to install performance management
+ protocol.
+
+ @retval EFI_SUCCESS Performance protocol installed successfully.
+**/
+EFI_STATUS
+ScmiPerformanceProtocolInit (
+ IN EFI_HANDLE* Handle
+ );
+
+#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_ */
diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
new file mode 100644
index 0000000000000000000000000000000000000000..1e279f69cf615428dbb6477b8ac7de3258628df3
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
@@ -0,0 +1,262 @@
+/** @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 <Library/ArmMtlLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include "ScmiPrivate.h"
+
+// SCMI Specification 1.0
+#define MAX_PROTOCOLS 6
+
+#define PROTOCOL_MASK 0xF
+
+// Arbitrary timeout value 20ms.
+#define RESPONSE_TIMEOUT 20000
+
+/** Return a pointer to the message payload.
+
+ @param[out] Payload Holds pointer to the message payload.
+
+ @retval EFI_SUCCESS Payload holds a valid message payload pointer.
+ @retval EFI_TIMEOUT Time out error if MTL channel is busy.
+ @retval EFI_UNSUPPORTED If MTL channel is unsupported.
+**/
+EFI_STATUS
+ScmiCommandGetPayload (
+ OUT UINT32** Payload
+ )
+{
+ EFI_STATUS Status;
+ MTL_CHANNEL *Channel;
+
+ // Get handle to the Channel.
+ Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Payload will not be populated until channel is free.
+ Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Get the address of the payload.
+ *Payload = MtlGetChannelPayload (Channel);
+
+ return EFI_SUCCESS;
+}
+
+/** Execute a SCMI command and receive a response.
+
+ This function uses a MTL channel to transfer message to SCP
+ and waits for a response.
+
+ @param[in] Command Pointer to the SCMI command (Protocol ID
+ and Message ID)
+
+ @param[in,out] PayloadLength SCMI command message length.
+
+ @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
+
+ @retval OUT EFI_SUCCESS Command sent and message received successfully.
+ @retval OUT EFI_UNSUPPORTED Channel not supported.
+ @retval OUT EFI_TIMEOUT Timeout on the channel.
+ @retval OUT EFI_DEVICE_ERROR Channel not ready.
+ @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
+ @retval OUT EFI_DEVICE_ERROR SCMI error.
+**/
+EFI_STATUS
+ScmiCommandExecute (
+ IN SCMI_COMMAND *Command,
+ IN OUT UINT32 *PayloadLength,
+ OUT UINT32 **ReturnValues OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ SCMI_MESSAGE_RESPONSE *Response;
+ UINT32 MessageHeader;
+ UINT32 ResponseHeader;
+ MTL_CHANNEL *Channel;
+
+ ASSERT (PayloadLength != NULL);
+
+ Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Fill in message header.
+ MessageHeader = SCMI_MESSAGE_HEADER (
+ Command->MessageId,
+ SCMI_MESSAGE_TYPE_COMMAND,
+ Command->ProtocolId
+ );
+
+ // Send payload using MTL channel.
+ Status = MtlSendMessage (
+ Channel,
+ MessageHeader,
+ *PayloadLength
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Wait for the response on the channel.
+ Status = MtlReceiveMessage (Channel, &ResponseHeader, PayloadLength);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // SCMI must return MessageHeader unmodified.
+ if (MessageHeader != ResponseHeader) {
+ ASSERT (FALSE);
+ return EFI_DEVICE_ERROR;
+ }
+
+ Response = (SCMI_MESSAGE_RESPONSE*)MtlGetChannelPayload (Channel);
+
+ if (Response->Status != SCMI_SUCCESS) {
+ DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId = 0x%x, MessageId = 0x%x, error = %d\n",
+ Command->ProtocolId,
+ Command->MessageId,
+ Response->Status
+ ));
+
+ ASSERT (FALSE);
+ return EFI_DEVICE_ERROR;
+ }
+
+ if (ReturnValues != NULL) {
+ *ReturnValues = Response->ReturnValues;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/** Internal common function useful for common protocol discovery messages.
+
+ @param[in] ProtocolId Protocol Id of the the protocol.
+ @param[in] MesaageId Message Id of the message.
+
+ @param[out] ReturnValues SCMI response return values.
+
+ @retval EFI_SUCCESS Success with valid return values.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ScmiProtocolDiscoveryCommon (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ IN SCMI_MESSAGE_ID MessageId,
+ OUT UINT32 **ReturnValues
+ )
+{
+ SCMI_COMMAND Command;
+ UINT32 PayloadLength = 0;
+
+ Command.ProtocolId = ProtocolId;
+ Command.MessageId = MessageId;
+
+ return ScmiCommandExecute (
+ &Command,
+ &PayloadLength,
+ ReturnValues
+ );
+}
+
+/** Return protocol version from SCP for a given protocol ID.
+
+ @param[in] Protocol ID Protocol ID.
+ @param[out] Version Pointer to version of the protocol.
+
+ @retval EFI_SUCCESS Version holds a valid version received
+ from the SCP.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+ScmiGetProtocolVersion (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ OUT UINT32 *Version
+ )
+{
+ EFI_STATUS Status;
+ UINT32 *ProtocolVersion;
+
+ Status = ScmiProtocolDiscoveryCommon (
+ ProtocolId,
+ SCMI_MESSAGE_ID_PROTOCOL_VERSION,
+ (UINT32**)&ProtocolVersion
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *Version = *ProtocolVersion;
+
+ return EFI_SUCCESS;
+}
+
+/** Return protocol attributes from SCP for a given protocol ID.
+
+ @param[in] Protocol ID Protocol ID.
+ @param[out] ReturnValues Pointer to attributes of the protocol.
+
+ @retval EFI_SUCCESS ReturnValues points to protocol attributes.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+ScmiGetProtocolAttributes (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ OUT UINT32 **ReturnValues
+ )
+{
+ return ScmiProtocolDiscoveryCommon (
+ ProtocolId,
+ SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES,
+ ReturnValues
+ );
+}
+
+/** Return protocol message attributes from SCP for a given protocol ID.
+
+ @param[in] Protocol ID Protocol ID.
+ @param[out] Attributes Pointer to attributes of the protocol.
+
+ @retval EFI_SUCCESS ReturnValues points to protocol message attributes.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+ScmiGetProtocolMessageAttributes (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ OUT UINT32 **ReturnValues
+ )
+{
+ return ScmiProtocolDiscoveryCommon (
+ ProtocolId,
+ SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES,
+ ReturnValues
+ );
+}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
new file mode 100644
index 0000000000000000000000000000000000000000..0829438c82ec5723cfbbf9c411d10fcf22a22d89
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
@@ -0,0 +1,318 @@
+/** @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 <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/ArmScmiBaseProtocol.h>
+
+#include "ArmScmiBaseProtocolPrivate.h"
+#include "ScmiPrivate.h"
+
+/** Return version of the Base protocol supported by SCP firmware.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] Version Version of the supported SCMI Base protocol.
+
+ @retval EFI_SUCCESS The version of the protocol is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+BaseGetVersion (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT32 *Version
+ )
+{
+ return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_BASE, Version);
+}
+
+/** Return total number of SCMI protocols supported by the SCP firmware.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] TotalProtocols Total number of SCMI protocols supported.
+
+ @retval EFI_SUCCESS Total number of protocols supported are returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+BaseGetTotalProtocols (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT32 *TotalProtocols
+ )
+{
+ EFI_STATUS Status;
+ UINT32 *ReturnValues;
+
+ Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_BASE, &ReturnValues);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *TotalProtocols = SCMI_TOTAL_PROTOCOLS (ReturnValues[0]);
+
+ return EFI_SUCCESS;
+}
+
+/** Common function which returns vendor details.
+
+ @param[in] MessageId SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR
+ OR
+ SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR
+
+ @param[out] VendorIdentifier ASCII name of the vendor/subvendor.
+
+ @retval EFI_SUCCESS VendorIdentifier is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+BaseDiscoverVendorDetails (
+ IN SCMI_MESSAGE_ID_BASE MessageId,
+ OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
+ )
+{
+ EFI_STATUS Status;
+ UINT32 *ReturnValues;
+ SCMI_COMMAND Cmd;
+ UINT32 PayloadLength;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
+ Cmd.MessageId = MessageId;
+
+ PayloadLength = 0;
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ &ReturnValues
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ AsciiStrCpyS (
+ (CHAR8*)VendorIdentifier,
+ SCMI_MAX_STR_LEN,
+ (CONST CHAR8*)ReturnValues
+ );
+
+ return EFI_SUCCESS;
+}
+
+/** Return vendor name.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] VendorIdentifier Null terminated ASCII string of up to
+ 16 bytes with a vendor name.
+
+ @retval EFI_SUCCESS VendorIdentifier is returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+BaseDiscoverVendor (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
+ )
+{
+ return BaseDiscoverVendorDetails (
+ SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR,
+ VendorIdentifier
+ );
+}
+
+/** Return sub vendor name.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] VendorIdentifier Null terminated ASCII string of up to
+ 16 bytes with a sub vendor name.
+
+ @retval EFI_SUCCESS VendorIdentifier is returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+BaseDiscoverSubVendor (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
+ )
+{
+ return BaseDiscoverVendorDetails (
+ SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR,
+ VendorIdentifier
+ );
+}
+
+/** Return implementation version.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] ImplementationVersion Vendor specific implementation version.
+
+ @retval EFI_SUCCESS Implementation version is returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+BaseDiscoverImplVersion (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT32 *ImplementationVersion
+ )
+{
+ EFI_STATUS Status;
+ UINT32 *ReturnValues;
+ SCMI_COMMAND Cmd;
+ UINT32 PayloadLength;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION;
+
+ PayloadLength = 0;
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ &ReturnValues
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *ImplementationVersion = ReturnValues[0];
+
+ return EFI_SUCCESS;
+}
+
+/** Return list of protocols.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] ProtocolListSize Size of the ProtocolList.
+
+ @param[out] ProtocolList Protocol list.
+
+ @retval EFI_SUCCESS List of protocols is returned.
+ @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result.
+ It has been updated to the size needed.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+BaseDiscoverListProtocols (
+ IN SCMI_BASE_PROTOCOL *This,
+ IN OUT UINT32 *ProtocolListSize,
+ OUT UINT8 *ProtocolList
+ )
+{
+ EFI_STATUS Status;
+ UINT32 TotalProtocols;
+ UINT32 *MessageParams;
+ BASE_DISCOVER_LIST *DiscoverList;
+ UINT32 Skip;
+ UINT32 Index;
+ SCMI_COMMAND Cmd;
+ UINT32 PayloadLength;
+ UINT32 RequiredSize;
+
+ Status = BaseGetTotalProtocols (This, &TotalProtocols);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ RequiredSize = sizeof (UINT8) * TotalProtocols;
+ if (*ProtocolListSize < RequiredSize) {
+ *ProtocolListSize = RequiredSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS;
+
+ Skip = 0;
+
+ while (Skip < TotalProtocols) {
+
+ *MessageParams = Skip;
+
+ // Note PayloadLength is a IN/OUT parameter.
+ PayloadLength = sizeof (Skip);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ (UINT32**)&DiscoverList
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < DiscoverList->NumProtocols; Index++) {
+ ProtocolList[Skip++] = DiscoverList->Protocols[Index];
+ }
+ }
+
+ *ProtocolListSize = RequiredSize;
+
+ return EFI_SUCCESS;
+}
+
+// Instance of the SCMI Base protocol.
+STATIC CONST SCMI_BASE_PROTOCOL BaseProtocol = {
+ BaseGetVersion,
+ BaseGetTotalProtocols,
+ BaseDiscoverVendor,
+ BaseDiscoverSubVendor,
+ BaseDiscoverImplVersion,
+ BaseDiscoverListProtocols
+};
+
+/** Initialize Base protocol and install protocol on a given handle.
+
+ @param[in] Handle Handle to install Base protocol.
+
+ @retval EFI_SUCCESS Base protocol interface installed
+ successfully.
+**/
+EFI_STATUS
+ScmiBaseProtocolInit (
+ IN OUT EFI_HANDLE* Handle
+ )
+{
+ return gBS->InstallMultipleProtocolInterfaces (
+ Handle,
+ &gArmScmiBaseProtocolGuid,
+ &BaseProtocol,
+ NULL
+ );
+}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
new file mode 100644
index 0000000000000000000000000000000000000000..fe7edd2a8c8b7761fb3008e66d192ef1ee1ade2e
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
@@ -0,0 +1,418 @@
+/** @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 <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/ArmScmiClockProtocol.h>
+
+#include "ArmScmiClockProtocolPrivate.h"
+#include "ScmiPrivate.h"
+
+/** Convert to 64 bit value from two 32 bit words.
+
+ @param[in] Low Lower 32 bits.
+ @param[in] High Higher 32 bits.
+
+ @retval UINT64 64 bit value.
+**/
+STATIC
+UINT64
+ConvertTo64Bit (
+ IN UINT32 Low,
+ IN UINT32 High
+ )
+{
+ return (Low | ((UINT64)High << 32));
+}
+
+/** Return version of the clock management protocol supported by SCP firmware.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+
+ @param[out] Version Version of the supported SCMI Clock management protocol.
+
+ @retval EFI_SUCCESS The version is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ClockGetVersion (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ OUT UINT32 *Version
+ )
+{
+ return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_CLOCK, Version);
+}
+
+/** Return total number of clock devices supported by the clock management
+ protocol.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+
+ @param[out] TotalClocks Total number of clocks supported.
+
+ @retval EFI_SUCCESS Total number of clocks supported is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ClockGetTotalClocks (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ OUT UINT32 *TotalClocks
+ )
+{
+ EFI_STATUS Status;
+ UINT32 *ReturnValues;
+
+ Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK, &ReturnValues);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
+
+ return EFI_SUCCESS;
+}
+
+/** Return attributes of a clock device.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+
+ @param[out] Enabled If TRUE, the clock device is enabled.
+ @param[out] ClockAsciiName A NULL terminated ASCII string with the clock
+ name, of up to 16 bytes.
+
+ @retval EFI_SUCCESS Clock device attributes are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ClockGetClockAttributes (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ OUT BOOLEAN *Enabled,
+ OUT CHAR8 *ClockAsciiName
+ )
+{
+ EFI_STATUS Status;
+
+ UINT32 *MessageParams;
+ CLOCK_ATTRIBUTES *ClockAttributes;
+ SCMI_COMMAND Cmd;
+ UINT32 PayloadLength;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MessageParams = ClockId;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
+ Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES;
+
+ PayloadLength = sizeof (ClockId);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ (UINT32**)&ClockAttributes
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ // TRUE if bit 0 of ClockAttributes->Attributes is set.
+ *Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
+
+ AsciiStrCpyS (
+ ClockAsciiName,
+ SCMI_MAX_STR_LEN,
+ (CONST CHAR8*)ClockAttributes->ClockName
+ );
+
+ return EFI_SUCCESS;
+}
+
+/** Return list of rates supported by a given clock device.
+
+ @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+
+ @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
+ supports range of clock rates which are non-linear.
+
+ SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
+ range of linear clock rates from Min to Max in steps.
+
+ @param[out] TotalRates Total number of rates.
+
+ @param[in,out] RateArraySize Size of the RateArray.
+
+ @param[out] RateArray List of clock rates.
+
+ @retval EFI_SUCCESS List of clock rates is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
+ It has been updated to the size needed.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ClockDescribeRates (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ OUT SCMI_CLOCK_RATE_FORMAT *Format,
+ OUT UINT32 *TotalRates,
+ IN OUT UINT32 *RateArraySize,
+ OUT SCMI_CLOCK_RATE *RateArray
+ )
+{
+ EFI_STATUS Status;
+
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+ UINT32 *MessageParams;
+ CLOCK_DESCRIBE_RATES *DescribeRates;
+ CLOCK_RATE_DWORD *Rate;
+
+ UINT32 RequiredArraySize = 0;
+ UINT32 RateIndex = 0;
+ UINT32 RateNo;
+ UINT32 RateOffset;
+
+ *TotalRates = 0;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
+ Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES;
+
+ *MessageParams++ = ClockId;
+
+ do {
+
+ *MessageParams = RateIndex;
+
+ // Set Payload length, note PayloadLength is a IN/OUT parameter.
+ PayloadLength = sizeof (ClockId) + sizeof (RateIndex);
+
+ // Execute and wait for response on a SCMI channel.
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ (UINT32**)&DescribeRates
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (*TotalRates == 0) {
+ // In the first iteration we will get number of returned rates and number
+ // of remaining rates. With this information calculate required size
+ // for rate array. If provided RateArraySize is less, return an
+ // error.
+
+ *Format = RATE_FORMAT (DescribeRates->NumRatesFlags);
+
+ *TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
+ + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
+
+ if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
+ RequiredArraySize = (*TotalRates) * sizeof (UINT64);
+ } else {
+ // We need to return triplet of 64 bit value for each rate
+ RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
+ }
+
+ if (RequiredArraySize > (*RateArraySize)) {
+ *RateArraySize = RequiredArraySize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ RateOffset = 0;
+
+ if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
+ for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
+ Rate = &DescribeRates->Rates[RateOffset++];
+ // Non-linear discrete rates.
+ RateArray[RateIndex++].Rate = ConvertTo64Bit (Rate->Low, Rate->High);
+ }
+ } else {
+ for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
+ // Linear clock rates from minimum to maximum in steps
+ // Minimum clock rate.
+ Rate = &DescribeRates->Rates[RateOffset++];
+ RateArray[RateIndex].Min = ConvertTo64Bit (Rate->Low, Rate->High);
+
+ Rate = &DescribeRates->Rates[RateOffset++];
+ // Maximum clock rate.
+ RateArray[RateIndex].Max = ConvertTo64Bit (Rate->Low, Rate->High);
+
+ Rate = &DescribeRates->Rates[RateOffset++];
+ // Step.
+ RateArray[RateIndex++].Step = ConvertTo64Bit (Rate->Low, Rate->High);
+ }
+ }
+ } while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
+
+ // Update RateArraySize with RequiredArraySize.
+ *RateArraySize = RequiredArraySize;
+
+ return EFI_SUCCESS;
+}
+
+/** Get clock rate.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+
+ @param[out] Rate Clock rate.
+
+ @retval EFI_SUCCESS Clock rate is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ClockRateGet (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ OUT UINT64 *Rate
+ )
+{
+ EFI_STATUS Status;
+
+ UINT32 *MessageParams;
+ CLOCK_RATE_DWORD *ClockRate;
+ SCMI_COMMAND Cmd;
+
+ UINT32 PayloadLength;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Fill arguments for clock protocol command.
+ *MessageParams = ClockId;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
+ Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_GET;
+
+ PayloadLength = sizeof (ClockId);
+
+ // Execute and wait for response on a SCMI channel.
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ (UINT32**)&ClockRate
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *Rate = ((UINT64)ClockRate->High << 32) | ClockRate->Low;
+
+ return EFI_SUCCESS;
+}
+
+/** Set clock rate.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+ @param[in] Rate Clock rate.
+
+ @retval EFI_SUCCESS Clock rate set success.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+ClockRateSet (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ IN UINT64 Rate
+ )
+{
+ EFI_STATUS Status;
+ CLOCK_RATE_SET_ATTRIBUTES *ClockRateSetAttributes;
+ SCMI_COMMAND Cmd;
+ UINT32 PayloadLength;
+
+ Status = ScmiCommandGetPayload ((UINT32**)&ClockRateSetAttributes);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Fill arguments for clock protocol command.
+ ClockRateSetAttributes->ClockId = ClockId;
+ ClockRateSetAttributes->Flags = CLOCK_SET_DEFAULT_FLAGS;
+ ClockRateSetAttributes->Rate.Low = (UINT32)Rate;
+ ClockRateSetAttributes->Rate.High = (UINT32)(Rate >> 32);
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
+ Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_SET;
+
+ PayloadLength = sizeof (CLOCK_RATE_SET_ATTRIBUTES);
+
+ // Execute and wait for response on a SCMI channel.
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ NULL
+ );
+
+ return Status;
+}
+
+// Instance of the SCMI clock management protocol.
+STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol = {
+ ClockGetVersion,
+ ClockGetTotalClocks,
+ ClockGetClockAttributes,
+ ClockDescribeRates,
+ ClockRateGet,
+ ClockRateSet
+ };
+
+/** Initialize clock management protocol and install protocol on a given handle.
+
+ @param[in] Handle Handle to install clock management protocol.
+
+ @retval EFI_SUCCESS Clock protocol interface installed successfully.
+**/
+EFI_STATUS
+ScmiClockProtocolInit (
+ IN EFI_HANDLE* Handle
+ )
+{
+ return gBS->InstallMultipleProtocolInterfaces (
+ Handle,
+ &gArmScmiClockProtocolGuid,
+ &ScmiClockProtocol,
+ NULL
+ );
+}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
new file mode 100644
index 0000000000000000000000000000000000000000..2920c6f6f33c5bb8ac00c903a0b199ba5f06f4de
--- /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;
+}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
new file mode 100644
index 0000000000000000000000000000000000000000..29cdde173659c701116b021a3c437a92b473e4e5
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
@@ -0,0 +1,41 @@
+/** @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
+**/
+#ifndef SCMI_DXE_H_
+#define SCMI_DXE_H_
+
+#define MAX_PROTOCOLS 6
+#define PROTOCOL_ID_MASK 0xF
+#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
+
+/** Pointer to protocol initialization function.
+
+ @param[in] Handle A pointer to the EFI_HANDLE on which the protocol
+ interface is to be installed.
+
+ @retval EFI_SUCCESS Protocol interface installed successfully.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PROTOCOL_INIT_FXN)(
+ IN EFI_HANDLE *Handle
+ );
+
+typedef struct {
+ SCMI_PROTOCOL_INIT_FXN Init;
+} SCMI_PROTOCOL_INIT_TABLE;
+
+#endif /* SCMI_DXE_H_ */
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
new file mode 100644
index 0000000000000000000000000000000000000000..ac32442ad838040721fd62faa806e82184f2b288
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
@@ -0,0 +1,457 @@
+/** @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 <Library/UefiBootServicesTableLib.h>
+#include <Protocol/ArmScmiPerformanceProtocol.h>
+#include <string.h>
+
+#include "ArmScmiPerformanceProtocolPrivate.h"
+#include "ScmiPrivate.h"
+
+/** Return version of the performance management protocol supported by SCP.
+ firmware.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+
+ @param[out] Version Version of the supported SCMI performance management
+ protocol.
+
+ @retval EFI_SUCCESS The version is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+PerformanceGetVersion (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ OUT UINT32 *Version
+ )
+{
+ return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_PERFORMANCE, Version);
+}
+
+/** Return protocol attributes of the performance management protocol.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+
+ @param[out] Attributes Protocol attributes.
+
+ @retval EFI_SUCCESS Protocol attributes are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+PerformanceGetAttributes (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
+ )
+{
+ EFI_STATUS Status;
+ UINT32* ReturnValues;
+
+ Status = ScmiGetProtocolAttributes (
+ SCMI_PROTOCOL_ID_PERFORMANCE,
+ &ReturnValues
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ memcpy (
+ Attributes,
+ ReturnValues,
+ sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
+ );
+
+ return EFI_SUCCESS;
+}
+
+/** Return performance domain attributes.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] Attributes Performance domain attributes.
+
+ @retval EFI_SUCCESS Domain attributes are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+PerformanceDomainAttributes (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
+ )
+{
+ EFI_STATUS Status;
+ UINT32 *MessageParams;
+ UINT32 *ReturnValues;
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MessageParams = DomainId;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES;
+
+ PayloadLength = sizeof (DomainId);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ &ReturnValues
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ memcpy (
+ DomainAttributes,
+ ReturnValues,
+ sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
+ );
+
+ return EFI_SUCCESS;
+}
+
+/** Return list of performance domain levels of a given domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] NumLevels Total number of levels a domain can support.
+
+ @param[in,out] LevelArraySize Size of the performance level array.
+
+ @param[out] LevelArray Array of the performance levels.
+
+ @retval EFI_SUCCESS Domain levels are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
+ It has been updated to the size needed.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+STATIC
+EFI_STATUS
+PerformanceDescribeLevels (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ OUT UINT32 *NumLevels,
+ IN OUT UINT32 *LevelArraySize,
+ OUT SCMI_PERFORMANCE_LEVEL *LevelArray
+ )
+{
+ EFI_STATUS Status;
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+ UINT32* MessageParams;
+ UINT32 LevelIndex;
+ UINT32 RequiredSize;
+ UINT32 LevelNo;
+ UINT32 ReturnNumLevels;
+ UINT32 ReturnRemainNumLevels;
+
+ PERF_DESCRIBE_LEVELS *Levels;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ LevelIndex = 0;
+ RequiredSize = 0;
+
+ *MessageParams++ = DomainId;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS;
+
+ do {
+
+ *MessageParams = LevelIndex;
+
+ // Note, PayloadLength is an IN/OUT parameter.
+ PayloadLength = sizeof (DomainId) + sizeof (LevelIndex);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ (UINT32**)&Levels
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ReturnNumLevels = NUM_PERF_LEVELS (Levels->NumLevels);
+ ReturnRemainNumLevels = NUM_REMAIN_PERF_LEVELS (Levels->NumLevels);
+
+ if (RequiredSize == 0) {
+ *NumLevels = ReturnNumLevels + ReturnRemainNumLevels;
+
+ RequiredSize = (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL);
+ if (RequiredSize > (*LevelArraySize)) {
+ // Update LevelArraySize with required size.
+ *LevelArraySize = RequiredSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
+ memcpy (
+ &LevelArray[LevelIndex++],
+ &Levels->PerfLevel[LevelNo],
+ sizeof (SCMI_PERFORMANCE_LEVEL)
+ );
+ }
+
+ } while (ReturnRemainNumLevels != 0);
+
+ *LevelArraySize = RequiredSize;
+
+ return EFI_SUCCESS;
+}
+
+/** Set performance limits of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+ @param[in] Limit Performance limit to set.
+
+ @retval EFI_SUCCESS Performance limits set successfully.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+PerformanceLimitsSet (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ IN SCMI_PERFORMANCE_LIMITS *Limits
+ )
+{
+ EFI_STATUS Status;
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+ UINT32 *MessageParams;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MessageParams++ = DomainId;
+ *MessageParams++ = Limits->RangeMax;
+ *MessageParams = Limits->RangeMin;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET;
+
+ PayloadLength = sizeof (DomainId) + sizeof (SCMI_PERFORMANCE_LIMITS);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ NULL
+ );
+
+ return Status;
+}
+
+/** Get performance limits of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] Limit Performance Limits of the domain.
+
+ @retval EFI_SUCCESS Performance limits are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+PerformanceLimitsGet (
+ SCMI_PERFORMANCE_PROTOCOL *This,
+ UINT32 DomainId,
+ SCMI_PERFORMANCE_LIMITS *Limits
+ )
+{
+ EFI_STATUS Status;
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+ UINT32 *MessageParams;
+
+ SCMI_PERFORMANCE_LIMITS *ReturnValues;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MessageParams = DomainId;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET;
+
+ PayloadLength = sizeof (DomainId);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ (UINT32**)&ReturnValues
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Limits->RangeMax = ReturnValues->RangeMax;
+ Limits->RangeMin = ReturnValues->RangeMin;
+
+ return EFI_SUCCESS;
+}
+
+/** Set performance level of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+ @param[in] Level Performance level of the domain.
+
+ @retval EFI_SUCCESS Performance level set successfully.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+PerformanceLevelSet (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ IN UINT32 Level
+ )
+{
+ EFI_STATUS Status;
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+ UINT32 *MessageParams;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MessageParams++ = DomainId;
+ *MessageParams = Level;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET;
+
+ PayloadLength = sizeof (DomainId) + sizeof (Level);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ NULL
+ );
+
+ return Status;
+}
+
+/** Get performance level of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] Level Performance level of the domain.
+
+ @retval EFI_SUCCESS Performance level got successfully.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+PerformanceLevelGet (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ OUT UINT32 *Level
+ )
+{
+ EFI_STATUS Status;
+ UINT32 PayloadLength;
+ SCMI_COMMAND Cmd;
+ UINT32 *ReturnValues;
+ UINT32 *MessageParams;
+
+ Status = ScmiCommandGetPayload (&MessageParams);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *MessageParams = DomainId;
+
+ Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
+ Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET;
+
+ PayloadLength = sizeof (DomainId);
+
+ Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ &ReturnValues
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *Level = *ReturnValues;
+
+ return EFI_SUCCESS;
+}
+
+// Instance of the SCMI performance management protocol.
+STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol = {
+ PerformanceGetVersion,
+ PerformanceGetAttributes,
+ PerformanceDomainAttributes,
+ PerformanceDescribeLevels,
+ PerformanceLimitsSet,
+ PerformanceLimitsGet,
+ PerformanceLevelSet,
+ PerformanceLevelGet
+};
+
+/** Initialize performance management protocol and install on a given Handle.
+
+ @param[in] Handle Handle to install performance management
+ protocol.
+
+ @retval EFI_SUCCESS Performance protocol installed successfully.
+**/
+EFI_STATUS
+ScmiPerformanceProtocolInit (
+ IN EFI_HANDLE* Handle
+ )
+{
+ return gBS->InstallMultipleProtocolInterfaces (
+ Handle,
+ &gArmScmiPerformanceProtocolGuid,
+ &PerformanceProtocol,
+ NULL
+ );
+}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
new file mode 100644
index 0000000000000000000000000000000000000000..df03655b8b021fe5fd63ceab0dd414906d2fb248
--- /dev/null
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
@@ -0,0 +1,174 @@
+/** @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
+**/
+#ifndef SCMI_PRIVATE_H_
+#define SCMI_PRIVATE_H_
+
+// SCMI protocol IDs.
+typedef enum {
+ SCMI_PROTOCOL_ID_BASE = 0x10,
+ SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
+ SCMI_PROTOCOL_ID_SYSTEM_POWER = 0x12,
+ SCMI_PROTOCOL_ID_PERFORMANCE = 0x13,
+ SCMI_PROTOCOL_ID_CLOCK = 0x14,
+ SCMI_PROTOCOL_ID_SENSOR = 0x15
+} SCMI_PROTOCOL_ID;
+
+// SCMI message types.
+typedef enum {
+ SCMI_MESSAGE_TYPE_COMMAND = 0,
+ SCMI_MESSAGE_TYPE_DELAYED_RESPONSE = 2, // Skipping 1 is deliberate.
+ SCMI_MESSAGE_TYPE_NOTIFICATION = 3
+} SCMI_MESSAGE_TYPE;
+
+// SCMI response error codes.
+typedef enum {
+ SCMI_SUCCESS = 0,
+ SCMI_NOT_SUPPORTED = -1,
+ SCMI_INVALID_PARAMETERS = -2,
+ SCMI_DENIED = -3,
+ SCMI_NOT_FOUND = -4,
+ SCMI_OUT_OF_RANGE = -5,
+ SCMI_BUSY = -6,
+ SCMI_COMMS_ERROR = -7,
+ SCMI_GENERIC_ERROR = -8,
+ SCMI_HARDWARE_ERROR = -9,
+ SCMI_PROTOCOL_ERROR = -10
+} SCMI_STATUS;
+
+// SCMI message IDs common to all protocols.
+typedef enum {
+ SCMI_MESSAGE_ID_PROTOCOL_VERSION = 0x0,
+ SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES = 0x1,
+ SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2
+} SCMI_MESSAGE_ID;
+
+// Not defined in SCMI specification but will help to identify a message.
+typedef struct {
+ SCMI_PROTOCOL_ID ProtocolId;
+ UINT32 MessageId;
+} SCMI_COMMAND;
+
+#pragma pack(1)
+
+// Response to a SCMI command.
+typedef struct {
+ INT32 Status;
+ UINT32 ReturnValues[];
+} SCMI_MESSAGE_RESPONSE;
+
+// Message header. MsgId[7:0], MsgType[9:8], ProtocolId[17:10]
+#define MESSAGE_TYPE_SHIFT 8
+#define PROTOCOL_ID_SHIFT 10
+#define SCMI_MESSAGE_HEADER(MsgId, MsgType, ProtocolId) ( \
+ MsgType << MESSAGE_TYPE_SHIFT | \
+ ProtocolId << PROTOCOL_ID_SHIFT | \
+ MsgId \
+ )
+// SCMI message header.
+typedef struct {
+ UINT32 MessageHeader;
+} SCMI_MESSAGE_HEADER;
+
+#pragma pack()
+
+/** Return a pointer to the message payload.
+
+ @param[out] Payload Holds pointer to the message payload.
+
+ @retval EFI_SUCCESS Payload holds a valid message payload pointer.
+ @retval EFI_TIMEOUT Time out error if MTL channel is busy.
+ @retval EFI_UNSUPPORTED If MTL channel is unsupported.
+**/
+EFI_STATUS
+ScmiCommandGetPayload (
+ OUT UINT32** Payload
+ );
+
+/** Execute a SCMI command and receive a response.
+
+ This function uses a MTL channel to transfer message to SCP
+ and waits for a response.
+
+ @param[in] Command Pointer to the SCMI command (Protocol ID
+ and Message ID)
+
+ @param[in,out] PayloadLength SCMI command message length.
+
+ @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
+
+ @retval OUT EFI_SUCCESS Command sent and message received successfully.
+ @retval OUT EFI_UNSUPPORTED Channel not supported.
+ @retval OUT EFI_TIMEOUT Timeout on the channel.
+ @retval OUT EFI_DEVICE_ERROR Channel not ready.
+ @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
+ @retval OUT EFI_DEVICE_ERROR SCMI error.
+**/
+EFI_STATUS
+ScmiCommandExecute (
+ IN SCMI_COMMAND *Command,
+ IN OUT UINT32 *PayloadLength,
+ OUT UINT32 **ReturnValues OPTIONAL
+ );
+
+/** Return protocol version from SCP for a given protocol ID.
+
+ @param[in] Protocol ID Protocol ID.
+ @param[out] Version Pointer to version of the protocol.
+
+ @retval EFI_SUCCESS Version holds a valid version received
+ from the SCP.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+ScmiGetProtocolVersion (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ OUT UINT32 *Version
+ );
+
+/** Return protocol attributes from SCP for a given protocol ID.
+
+ @param[in] Protocol ID Protocol ID.
+ @param[out] ReturnValues Pointer to attributes of the protocol.
+
+ @retval EFI_SUCCESS ReturnValues points to protocol attributes.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+ScmiGetProtocolAttributes (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ OUT UINT32 **ReturnValues
+ );
+
+/** Return protocol message attributes from SCP for a given protocol ID.
+
+ @param[in] Protocol ID Protocol ID.
+
+ @param[out] Attributes Pointer to attributes of the protocol.
+
+ @retval EFI_SUCCESS ReturnValues points to protocol message attributes.
+ @retval EFI_DEVICE_ERROR SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+EFI_STATUS
+ScmiGetProtocolMessageAttributes (
+ IN SCMI_PROTOCOL_ID ProtocolId,
+ OUT UINT32 **ReturnValues
+ );
+
+#endif /* SCMI_PRIVATE_H_ */
diff --git a/ArmPkg/Include/Protocol/ArmScmi.h b/ArmPkg/Include/Protocol/ArmScmi.h
new file mode 100644
index 0000000000000000000000000000000000000000..239abb97064578c949614f79a6a33fe1881c3c68
--- /dev/null
+++ b/ArmPkg/Include/Protocol/ArmScmi.h
@@ -0,0 +1,27 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_H_
+#define ARM_SCMI_H_
+
+/* As per SCMI specification, maximum allowed ASCII string length
+ for various return values/parameters of a SCMI message.
+*/
+#define SCMI_MAX_STR_LEN 16
+
+#endif /* ARM_SCMI_H_ */
+
diff --git a/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
new file mode 100644
index 0000000000000000000000000000000000000000..ecc41f2181ecc9f835950ab46c7cfd2e476a7073
--- /dev/null
+++ b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
@@ -0,0 +1,174 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_BASE_PROTOCOL_H_
+#define ARM_SCMI_BASE_PROTOCOL_H_
+
+#include <Protocol/ArmScmi.h>
+
+#define BASE_PROTOCOL_VERSION 0x10000
+
+#define NUM_PROTOCOL_MASK 0xFFU
+#define NUM_AGENT_MASK 0xFFU
+
+#define NUM_AGENT_SHIFT 0x8
+
+/** Returns total number of protocols that are
+ implemented (excluding the Base protocol)
+*/
+#define SCMI_TOTAL_PROTOCOLS(Attr) (Attr & NUM_PROTOCOL_MASK)
+
+// Returns total number of agents in the system.
+#define SCMI_TOTAL_AGENTS(Attr) ((Attr >> NUM_AGENT_SHIFT) & NUM_AGENT_MASK)
+
+#define ARM_SCMI_BASE_PROTOCOL_GUID { \
+ 0xd7e5abe9, 0x33ab, 0x418e, {0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f} \
+ }
+
+extern EFI_GUID gArmScmiBaseProtocolGuid;
+
+typedef struct _SCMI_BASE_PROTOCOL SCMI_BASE_PROTOCOL;
+
+/** Return version of the Base protocol supported by SCP firmware.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] Version Version of the supported SCMI Base protocol.
+
+ @retval EFI_SUCCESS The version of the protocol is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_BASE_GET_VERSION) (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT32 *Version
+ );
+
+/** Return total number of SCMI protocols supported by the SCP firmware.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] TotalProtocols Total number of SCMI protocols supported.
+
+ @retval EFI_SUCCESS Total number of protocols supported are returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_BASE_GET_TOTAL_PROTOCOLS) (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT32 *TotalProtocols
+ );
+
+/** Return vendor name.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] VendorIdentifier Null terminated ASCII string of up to
+ 16 bytes with a vendor name.
+
+ @retval EFI_SUCCESS VendorIdentifier is returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_BASE_DISCOVER_VENDOR) (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
+ );
+
+/** Return sub vendor name.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] VendorIdentifier Null terminated ASCII string of up to
+ 16 bytes with a vendor name.
+
+ @retval EFI_SUCCESS VendorIdentifier is returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_BASE_DISCOVER_SUB_VENDOR) (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
+ );
+
+/** Return implementation version.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] ImplementationVersion Vendor specific implementation version.
+
+ @retval EFI_SUCCESS Implementation version is returned.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION) (
+ IN SCMI_BASE_PROTOCOL *This,
+ OUT UINT32 *ImplementationVersion
+ );
+
+/** Return list of protocols.
+
+ @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
+
+ @param[out] ProtocolListSize Size of the ProtocolList.
+
+ @param[out] ProtocolList Protocol list.
+
+ @retval EFI_SUCCESS List of protocols is returned.
+ @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result.
+ It has been updated to the size needed.
+ @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_BASE_DISCOVER_LIST_PROTOCOLS) (
+ IN SCMI_BASE_PROTOCOL *This,
+ IN OUT UINT32 *ProtocolListSize,
+ OUT UINT8 *ProtocolList
+ );
+
+// Base protocol.
+typedef struct _SCMI_BASE_PROTOCOL {
+ SCMI_BASE_GET_VERSION GetVersion;
+ SCMI_BASE_GET_TOTAL_PROTOCOLS GetTotalProtocols;
+ SCMI_BASE_DISCOVER_VENDOR DiscoverVendor;
+ SCMI_BASE_DISCOVER_SUB_VENDOR DiscoverSubVendor;
+ SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION DiscoverImplementationVersion;
+ SCMI_BASE_DISCOVER_LIST_PROTOCOLS DiscoverListProtocols;
+} SCMI_BASE_PROTOCOL;
+
+// SCMI Message IDs for Base protocol.
+typedef enum {
+ SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR = 0x3,
+ SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR = 0x4,
+ SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION = 0x5,
+ SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS = 0x6
+} SCMI_MESSAGE_ID_BASE;
+
+#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */
+
diff --git a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
new file mode 100644
index 0000000000000000000000000000000000000000..3db26cb0641c7377c022a8e00be9a51ee5dc7361
--- /dev/null
+++ b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
@@ -0,0 +1,218 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_
+#define ARM_SCMI_CLOCK_PROTOCOL_H_
+
+#include <Protocol/ArmScmi.h>
+
+#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \
+ 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa} \
+ }
+
+extern EFI_GUID gArmScmiClockProtocolGuid;
+
+// Message Type for clock management protocol.
+typedef enum {
+ SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3,
+ SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4,
+ SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5,
+ SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6,
+ SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7
+} SCMI_MESSAGE_ID_CLOCK;
+
+typedef enum {
+ SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range.
+ SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range.
+} SCMI_CLOCK_RATE_FORMAT;
+
+// Clock management protocol version.
+#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000
+
+#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK 0xFFU
+#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16
+#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU
+
+/** Total number of pending asynchronous clock rates changes
+ supported by the SCP, Attr Bits[23:16]
+*/
+#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr) ( \
+ (Attr >> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \
+ SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)
+
+// Total of clock devices supported by the SCP, Attr Bits[15:0]
+#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr & SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)
+
+#pragma pack(1)
+
+/* Depending on the format (linear/non-linear) supported by a clock device
+ either Rate or Min/Max/Step triplet is valid.
+*/
+typedef struct {
+ union {
+ UINT64 Min;
+ UINT64 Rate;
+ };
+ UINT64 Max;
+ UINT64 Step;
+} SCMI_CLOCK_RATE;
+
+#pragma pack()
+
+typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL;
+
+// Protocol Interface functions.
+
+/** Return version of the clock management protocol supported by SCP firmware.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+
+ @param[out] Version Version of the supported SCMI Clock management protocol.
+
+ @retval EFI_SUCCESS The version is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_CLOCK_GET_VERSION) (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ OUT UINT32 *Version
+ );
+
+/** Return total number of clock devices supported by the clock management
+ protocol.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+
+ @param[out] TotalClocks Total number of clocks supported.
+
+ @retval EFI_SUCCESS Total number of clocks supported is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ OUT UINT32 *TotalClocks
+ );
+
+/** Return attributes of a clock device.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+
+ @param[out] Enabled If TRUE, the clock device is enabled.
+ @param[out] ClockAsciiName A NULL terminated ASCII string with the clock
+ name, of up to 16 bytes.
+
+ @retval EFI_SUCCESS Clock device attributes are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ OUT BOOLEAN *Enabled,
+ OUT CHAR8 *ClockAsciiName
+ );
+
+/** Return list of rates supported by a given clock device.
+
+ @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+
+ @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
+ supports range of clock rates which are non-linear.
+
+ SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
+ range of linear clock rates from Min to Max in steps.
+
+ @param[out] TotalRates Total number of rates.
+
+ @param[in,out] RateArraySize Size of the RateArray.
+
+ @param[out] RateArray List of clock rates.
+
+ @retval EFI_SUCCESS List of clock rates are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
+ It has been updated to the size needed.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ OUT SCMI_CLOCK_RATE_FORMAT *Format,
+ OUT UINT32 *TotalRates,
+ IN OUT UINT32 *RateArraySize,
+ OUT SCMI_CLOCK_RATE *RateArray
+ );
+
+/** Get clock rate.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+
+ @param[out] Rate Clock rate.
+
+ @retval EFI_SUCCESS Clock rate is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_CLOCK_RATE_GET) (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ OUT UINT64 *Rate
+ );
+
+/** Set clock rate.
+
+ @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
+ @param[in] ClockId Identifier for the clock device.
+ @param[in] Rate Clock rate.
+
+ @retval EFI_SUCCESS Clock rate set success.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_CLOCK_RATE_SET) (
+ IN SCMI_CLOCK_PROTOCOL *This,
+ IN UINT32 ClockId,
+ IN UINT64 Rate
+ );
+
+typedef struct _SCMI_CLOCK_PROTOCOL {
+ SCMI_CLOCK_GET_VERSION GetVersion;
+ SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks;
+ SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes;
+ SCMI_CLOCK_DESCRIBE_RATES DescribeRates;
+ SCMI_CLOCK_RATE_GET RateGet;
+ SCMI_CLOCK_RATE_SET RateSet;
+} SCMI_CLOCK_PROTOCOL;
+
+#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */
+
diff --git a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d1af6f8bee0c00bbe6b4774036c87c988a4f4af
--- /dev/null
+++ b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
@@ -0,0 +1,265 @@
+/** @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
+**/
+
+#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
+#define ARM_SCMI_PERFORMANCE_PROTOCOL_H_
+
+#include <Protocol/ArmScmi.h>
+
+#define PERFORMANCE_PROTOCOL_VERSION 0x10000
+
+#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \
+ 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad} \
+ }
+
+extern EFI_GUID gArmScmiPerformanceProtocolGuid;
+
+typedef struct _SCMI_PERFORMANCE_PROTOCOL SCMI_PERFORMANCE_PROTOCOL;
+
+#pragma pack(1)
+
+#define POWER_IN_MW_SHIFT 16
+#define POWER_IN_MW_MASK 0x1
+#define NUM_PERF_DOMAINS_MASK 0xFFFF
+
+// Total number of performance domains, Attr Bits [15:0]
+#define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr & NUM_PERF_DOMAINS_MASK)
+
+// A flag to express power values in mW or platform specific way, Attr Bit [16]
+#define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >> POWER_IN_MW_SHIFT) & \
+ POWER_IN_MW_MASK)
+
+// Performance protocol attributes return values.
+typedef struct {
+ UINT32 Attributes;
+ UINT64 StatisticsAddress;
+ UINT32 StatisticsLen;
+} SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES;
+
+#define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28) & 0x1)
+#define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29) & 0x1)
+#define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1)
+#define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1)
+#define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF)
+
+// Performance protocol domain attributes.
+typedef struct {
+ UINT32 Attributes;
+ UINT32 RateLimit;
+ UINT32 SustainedFreq;
+ UINT32 SustainedPerfLevel;
+ UINT8 Name[SCMI_MAX_STR_LEN];
+} SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES;
+
+// Worst case latency in microseconds, Bits[15:0]
+#define PERF_LATENCY_MASK 0xFFFF
+#define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency & PERF_LATENCY_MASK)
+
+// Performance protocol performance level.
+typedef struct {
+ UINT32 Level;
+ UINT32 PowerCost;
+ UINT32 Latency;
+} SCMI_PERFORMANCE_LEVEL;
+
+// Performance protocol performance limit.
+typedef struct {
+ UINT32 RangeMax;
+ UINT32 RangeMin;
+} SCMI_PERFORMANCE_LIMITS;
+
+#pragma pack()
+
+/** Return version of the performance management protocol supported by SCP.
+ firmware.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+
+ @param[out] Version Version of the supported SCMI performance management
+ protocol.
+
+ @retval EFI_SUCCESS The version is returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_GET_VERSION) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ OUT UINT32 *Version
+ );
+
+/** Return protocol attributes of the performance management protocol.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+
+ @param[out] Attributes Protocol attributes.
+
+ @retval EFI_SUCCESS Protocol attributes are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
+
+ );
+
+/** Return performance domain attributes.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] Attributes Performance domain attributes.
+
+ @retval EFI_SUCCESS Domain attributes are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
+ );
+
+/** Return list of performance domain levels of a given domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] NumLevels Total number of levels a domain can support.
+
+ @param[in,out] LevelArraySize Size of the performance level array.
+
+ @param[out] LevelArray Array of the performance levels.
+
+ @retval EFI_SUCCESS Domain levels are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
+ It has been updated to the size needed.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ OUT UINT32 *NumLevels,
+ IN OUT UINT32 *LevelArraySize,
+ OUT SCMI_PERFORMANCE_LEVEL *LevelArray
+ );
+
+/** Set performance limits of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+ @param[in] Limit Performance limit to set.
+
+ @retval EFI_SUCCESS Performance limits set successfully.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ IN SCMI_PERFORMANCE_LIMITS *Limits
+ );
+
+/** Get performance limits of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] Limit Performance Limits of the domain.
+
+ @retval EFI_SUCCESS Performance limits are returned.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) (
+ SCMI_PERFORMANCE_PROTOCOL *This,
+ UINT32 DomainId,
+ SCMI_PERFORMANCE_LIMITS *Limits
+ );
+
+/** Set performance level of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+ @param[in] Level Performance level of the domain.
+
+ @retval EFI_SUCCESS Performance level set successfully.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ IN UINT32 Level
+ );
+
+/** Get performance level of a domain.
+
+ @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+ @param[in] DomainId Identifier for the performance domain.
+
+ @param[out] Level Performance level of the domain.
+
+ @retval EFI_SUCCESS Performance level got successfully.
+ @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
+ @retval !(EFI_SUCCESS) Other errors.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) (
+ IN SCMI_PERFORMANCE_PROTOCOL *This,
+ IN UINT32 DomainId,
+ OUT UINT32 *Level
+ );
+
+typedef struct _SCMI_PERFORMANCE_PROTOCOL {
+ SCMI_PERFORMANCE_GET_VERSION GetVersion;
+ SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes;
+ SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES GetDomainAttributes;
+ SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels;
+ SCMI_PERFORMANCE_LIMITS_SET LimitsSet;
+ SCMI_PERFORMANCE_LIMITS_GET LimitsGet;
+ SCMI_PERFORMANCE_LEVEL_SET LevelSet;
+ SCMI_PERFORMANCE_LEVEL_GET LevelGet;
+} SCMI_PERFORMANCE_PROTOCOL;
+
+typedef enum {
+ SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3,
+ SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4,
+ SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5,
+ SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6,
+ SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7,
+ SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8,
+} SCMI_MESSAGE_ID_PERFORMANCE;
+
+#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
+
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
2018-03-20 16:12 ` [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol Girish Pathak
@ 2018-03-21 12:54 ` Evan Lloyd
2018-04-23 11:31 ` Leif Lindholm
1 sibling, 0 replies; 40+ messages in thread
From: Evan Lloyd @ 2018-03-21 12:54 UTC (permalink / raw)
To: Girish Pathak, edk2-devel@lists.01.org
Cc: nd, Stephanie Hughes-Fitt, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
> -----Original Message-----
> From: edk2-devel <edk2-devel-bounces@lists.01.org> On Behalf Of Girish
> Pathak
> Sent: 20 March 2018 16:12
> To: edk2-devel@lists.01.org
> Cc: nd <nd@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org
> Subject: [edk2] [PATCH v3 16/16] 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>
> ---
>
> Notes:
> v3:
> - Please rename ArmMtl.h to ArmMtlLibi.h, and
> declare it as a library class in the package file. [Ard]
>
> Done, however ArmMtlLib.h is now part of earlier commit [Girish]
>
> - Move ArmScmiDxe to ArmPkg from ArmPlatformPkg [Ard]
>
> Done [Girish]
>
> - Declare gArmScmiBaseProtocolGuid and similar
> protocols Guids in ArmPkg.dec [Ard]
>
> Done [Girish]
>
> - Replace flexible array member [] with [1] [Ard]
>
> Done [Girish]
>
> - Move protocol init function which are not part of
> of protocol like ScmiBaseProtocolInit elsewhere [Ard]
>
> Done [Girish]
>
> - Please don't put stuff in Include/Drivers. [Ard]
>
> Moved headers to Include/Protocol. [Girish]
>
> ArmPkg/ArmPkg.dec | 13 +
> ArmPkg/ArmPkg.dsc | 6 +-
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h | 46 ++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 84
> ++++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf | 53 +++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h | 55
> +++
> ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 262 +++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c | 318
> ++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 418
> ++++++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 138 ++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 41 ++
> ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 457
> ++++++++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h | 174 ++++++++
> ArmPkg/Include/Protocol/ArmScmi.h | 27 ++
> ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h | 174
> ++++++++
> ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 218
> ++++++++++
> ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h | 265
> ++++++++++++
> 17 files changed, 2748 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> index
> 881751d81c6384a3eb0b4c180c76d01a58266a74..16f7e40046429142b44
> b526043b61a3d5e089d2c 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -51,6 +51,19 @@ [Guids.common]
>
> gArmGicDxeFileGuid = { 0xde371f7c, 0xdec4, 0x4d21, { 0xad, 0xf1, 0x59,
> 0x3a, 0xbc, 0xc1, 0x58, 0x82 } }
>
> +[Protocols.common]
> + ## Arm System Control and Management Interface(SCMI) Base protocol
> + ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> + gArmScmiBaseProtocolGuid = { 0xd7e5abe9, 0x33ab, 0x418e, { 0x9f,
> 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } }
> +
> + ## Arm System Control and Management Interface(SCMI) Clock
> management protocol
> + ## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> + gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9,
> 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
> +
> + ## Arm System Control and Management Interface(SCMI) Clock
> management protocol
> + ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> + gArmScmiPerformanceProtocolGuid = { 0x9b8ba84, 0x3dd3, 0x49a6,
> { 0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } }
> +
> [Ppis]
> ## Include/Ppi/ArmMpCoreInfo.h
> gArmMpCoreInfoPpiGuid = { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d,
> 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} }
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> index
> 526909458e0d80dbc5a65c8ad12ec1095dda48d2..22332090db7111e0668
> 607a16288cefc1bace926 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -2,7 +2,7 @@
> # ARM processor package.
> #
> # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
> -# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
> # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> @@ -87,6 +87,8 @@ [LibraryClasses.common]
> ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
> ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
>
> + ArmMtlLib|ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> +
> [LibraryClasses.common.PEIM]
> HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
> @@ -144,5 +146,7 @@ [Components.common]
> ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>
> + ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> +
> [Components.AARCH64]
> ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..79c057d44128008ec2
> 76e3d58d8f1098c6a779b2
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> @@ -0,0 +1,46 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> +#define ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> +
> +// Return values of BASE_DISCOVER_LIST_PROTOCOLS command.
> +typedef struct {
> + UINT32 NumProtocols;
> +
> + // Array of four protocols in each element
> + // Total elements = 1 + (NumProtocols-1)/4
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + UINT8 Protocols[1];
> +} BASE_DISCOVER_LIST;
> +
> +/** Initialize Base protocol and install protocol on a given handle.
> +
> + @param[in] Handle Handle to install Base protocol.
> +
> + @retval EFI_SUCCESS Base protocol interface installed
> + successfully.
> +**/
> +EFI_STATUS
> +ScmiBaseProtocolInit (
> + IN OUT EFI_HANDLE* Handle
> + );
> +
> +#endif /* ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..71245c16475d4d38d6
> dc66571b3fe3520c1cf1da
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> @@ -0,0 +1,84 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
> +#define ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
> +
> +#pragma pack(1)
> +
> +// Clock rate in two 32bit words.
> +typedef struct {
> + UINT32 Low;
> + UINT32 High;
> +} CLOCK_RATE_DWORD;
> +
> +// Format of the returned rate array. Linear or Non-linear,.RatesFlag Bit[12]
> +#define RATE_FORMAT_SHIFT 12
> +#define RATE_FORMAT_MASK 0x0001
> +#define RATE_FORMAT(RatesFlags) ((RatesFlags >>
> RATE_FORMAT_SHIFT) \
> + & RATE_FORMAT_MASK)
> +
> +// Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
> +#define NUM_REMAIN_RATES_SHIFT 16
> +#define NUM_REMAIN_RATES(RatesFlags) ((RatesFlags >>
> NUM_REMAIN_RATES_SHIFT))
> +
> +// Number of rates that are returned by a call.to the SCP, RatesFlag
> Bits[11:0]
> +#define NUM_RATES_MASK 0x0FFF
> +#define NUM_RATES(RatesFlags) (RatesFlags & NUM_RATES_MASK)
> +
> +// Return values for the CLOCK_DESCRIBER_RATE command.
> +typedef struct {
> + UINT32 NumRatesFlags;
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + CLOCK_RATE_DWORD Rates[1];
> +} CLOCK_DESCRIBE_RATES;
> +
> +#define CLOCK_SET_DEFAULT_FLAGS 0
> +
> +// Message parameters for CLOCK_RATE_SET command.
> +typedef struct {
> + UINT32 Flags;
> + UINT32 ClockId;
> + CLOCK_RATE_DWORD Rate;
> +} CLOCK_RATE_SET_ATTRIBUTES;
> +
> +// if ClockAttr Bit[0] is set then clock device is enabled.
> +#define CLOCK_ENABLE_MASK 0x1
> +#define CLOCK_ENABLED(ClockAttr) ((ClockAttr & CLOCK_ENABLE_MASK)
> == 1)
> +
> +typedef struct {
> + UINT32 Attributes;
> + UINT8 ClockName[SCMI_MAX_STR_LEN];
> +} CLOCK_ATTRIBUTES;
> +
> +#pragma pack()
> +
> +/** Initialize clock management protocol and install protocol on a given
> handle.
> +
> + @param[in] Handle Handle to install clock management protocol.
> +
> + @retval EFI_SUCCESS Clock protocol interface installed successfully.
> +**/
> +EFI_STATUS
> +ScmiClockProtocolInit (
> + IN EFI_HANDLE *Handle
> + );
> +
> +#endif /* ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..05ce9c04ce468d74e5c
> 6d38739f9056f3fc48694
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> @@ -0,0 +1,53 @@
> +#/** @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
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010019
> + BASE_NAME = ArmScmiDxe
> + FILE_GUID = 9585984C-F027-45E9-AFDF-ADAA6DFAAAC7
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = ArmScmiDxeEntryPoint
> +
> +[Sources.common]
> + Scmi.c
> + ScmiBaseProtocol.c
> + ScmiClockProtocol.c
> + ScmiDxe.c
> + ScmiPerformanceProtocol.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + ArmMtlLib
> + DebugLib
> + IoLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> +
> +[Protocols]
> + gArmScmiBaseProtocolGuid
> + gArmScmiClockProtocolGuid
> + gArmScmiPerformanceProtocolGuid
> +
> +[Depex]
> + TRUE
> +
> diff --git
> a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..4514f45a9f5dd960d2
> 844a19b57a91b93149f1b9
> --- /dev/null
> +++
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> @@ -0,0 +1,55 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
> +#define ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
> +
> +#include <Protocol/ArmScmiPerformanceProtocol.h>
> +
> +// Number of performance levels returned by a call to the SCP, Lvls
> Bits[11:0]
> +#define NUM_PERF_LEVELS_MASK 0x0FFF
> +#define NUM_PERF_LEVELS(Lvls) (Lvls & NUM_PERF_LEVELS_MASK)
> +
> +// Number of performance levels remaining after a call to the SCP, Lvls
> Bits[31:16]
> +#define NUM_REMAIN_PERF_LEVELS_SHIFT 16
> +#define NUM_REMAIN_PERF_LEVELS(Lvls) (Lvls >>
> NUM_REMAIN_PERF_LEVELS_SHIFT)
> +
> +/** Return values for
> SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS command.
> + SCMI Spec � 4.5.2.5
> +**/
> +typedef struct {
> + UINT32 NumLevels;
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + SCMI_PERFORMANCE_LEVEL PerfLevel[1]; // Offset to array of
> performance levels
> +} PERF_DESCRIBE_LEVELS;
> +
> +/** Initialize performance management protocol and install on a given
> Handle.
> +
> + @param[in] Handle Handle to install performance management
> + protocol.
> +
> + @retval EFI_SUCCESS Performance protocol installed successfully.
> +**/
> +EFI_STATUS
> +ScmiPerformanceProtocolInit (
> + IN EFI_HANDLE* Handle
> + );
> +
> +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..1e279f69cf615428dbb
> 6477b8ac7de3258628df3
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> @@ -0,0 +1,262 @@
> +/** @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 <Library/ArmMtlLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include "ScmiPrivate.h"
> +
> +// SCMI Specification 1.0
> +#define MAX_PROTOCOLS 6
> +
> +#define PROTOCOL_MASK 0xF
> +
> +// Arbitrary timeout value 20ms.
> +#define RESPONSE_TIMEOUT 20000
> +
> +/** Return a pointer to the message payload.
> +
> + @param[out] Payload Holds pointer to the message payload.
> +
> + @retval EFI_SUCCESS Payload holds a valid message payload pointer.
> + @retval EFI_TIMEOUT Time out error if MTL channel is busy.
> + @retval EFI_UNSUPPORTED If MTL channel is unsupported.
> +**/
> +EFI_STATUS
> +ScmiCommandGetPayload (
> + OUT UINT32** Payload
> + )
> +{
> + EFI_STATUS Status;
> + MTL_CHANNEL *Channel;
> +
> + // Get handle to the Channel.
> + Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Payload will not be populated until channel is free.
> + Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Get the address of the payload.
> + *Payload = MtlGetChannelPayload (Channel);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Execute a SCMI command and receive a response.
> +
> + This function uses a MTL channel to transfer message to SCP
> + and waits for a response.
> +
> + @param[in] Command Pointer to the SCMI command (Protocol ID
> + and Message ID)
> +
> + @param[in,out] PayloadLength SCMI command message length.
> +
> + @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
> +
> + @retval OUT EFI_SUCCESS Command sent and message received
> successfully.
> + @retval OUT EFI_UNSUPPORTED Channel not supported.
> + @retval OUT EFI_TIMEOUT Timeout on the channel.
> + @retval OUT EFI_DEVICE_ERROR Channel not ready.
> + @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
> + @retval OUT EFI_DEVICE_ERROR SCMI error.
> +**/
> +EFI_STATUS
> +ScmiCommandExecute (
> + IN SCMI_COMMAND *Command,
> + IN OUT UINT32 *PayloadLength,
> + OUT UINT32 **ReturnValues OPTIONAL
> + )
> +{
> + EFI_STATUS Status;
> + SCMI_MESSAGE_RESPONSE *Response;
> + UINT32 MessageHeader;
> + UINT32 ResponseHeader;
> + MTL_CHANNEL *Channel;
> +
> + ASSERT (PayloadLength != NULL);
> +
> + Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Fill in message header.
> + MessageHeader = SCMI_MESSAGE_HEADER (
> + Command->MessageId,
> + SCMI_MESSAGE_TYPE_COMMAND,
> + Command->ProtocolId
> + );
> +
> + // Send payload using MTL channel.
> + Status = MtlSendMessage (
> + Channel,
> + MessageHeader,
> + *PayloadLength
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Wait for the response on the channel.
> + Status = MtlReceiveMessage (Channel, &ResponseHeader,
> PayloadLength);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // SCMI must return MessageHeader unmodified.
> + if (MessageHeader != ResponseHeader) {
> + ASSERT (FALSE);
> + return EFI_DEVICE_ERROR;
> + }
> +
> + Response = (SCMI_MESSAGE_RESPONSE*)MtlGetChannelPayload
> (Channel);
> +
> + if (Response->Status != SCMI_SUCCESS) {
> + DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId = 0x%x, MessageId =
> 0x%x, error = %d\n",
> + Command->ProtocolId,
> + Command->MessageId,
> + Response->Status
> + ));
> +
> + ASSERT (FALSE);
> + return EFI_DEVICE_ERROR;
> + }
> +
> + if (ReturnValues != NULL) {
> + *ReturnValues = Response->ReturnValues;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Internal common function useful for common protocol discovery
> messages.
> +
> + @param[in] ProtocolId Protocol Id of the the protocol.
> + @param[in] MesaageId Message Id of the message.
> +
> + @param[out] ReturnValues SCMI response return values.
> +
> + @retval EFI_SUCCESS Success with valid return values.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ScmiProtocolDiscoveryCommon (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + IN SCMI_MESSAGE_ID MessageId,
> + OUT UINT32 **ReturnValues
> + )
> +{
> + SCMI_COMMAND Command;
> + UINT32 PayloadLength = 0;
> +
> + Command.ProtocolId = ProtocolId;
> + Command.MessageId = MessageId;
> +
> + return ScmiCommandExecute (
> + &Command,
> + &PayloadLength,
> + ReturnValues
> + );
> +}
> +
> +/** Return protocol version from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] Version Pointer to version of the protocol.
> +
> + @retval EFI_SUCCESS Version holds a valid version received
> + from the SCP.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolVersion (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 *Version
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ProtocolVersion;
> +
> + Status = ScmiProtocolDiscoveryCommon (
> + ProtocolId,
> + SCMI_MESSAGE_ID_PROTOCOL_VERSION,
> + (UINT32**)&ProtocolVersion
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *Version = *ProtocolVersion;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return protocol attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] ReturnValues Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + )
> +{
> + return ScmiProtocolDiscoveryCommon (
> + ProtocolId,
> + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES,
> + ReturnValues
> + );
> +}
> +
> +/** Return protocol message attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] Attributes Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol message
> attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolMessageAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + )
> +{
> + return ScmiProtocolDiscoveryCommon (
> + ProtocolId,
> + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES,
> + ReturnValues
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..0829438c82ec5723cfb
> bf9c411d10fcf22a22d89
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> @@ -0,0 +1,318 @@
> +/** @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 <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/ArmScmiBaseProtocol.h>
> +
> +#include "ArmScmiBaseProtocolPrivate.h"
> +#include "ScmiPrivate.h"
> +
> +/** Return version of the Base protocol supported by SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Base protocol.
> +
> + @retval EFI_SUCCESS The version of the protocol is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseGetVersion (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *Version
> + )
> +{
> + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_BASE, Version);
> +}
> +
> +/** Return total number of SCMI protocols supported by the SCP
> firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] TotalProtocols Total number of SCMI protocols supported.
> +
> + @retval EFI_SUCCESS Total number of protocols supported are
> returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseGetTotalProtocols (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *TotalProtocols
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> +
> + Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_BASE,
> &ReturnValues);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *TotalProtocols = SCMI_TOTAL_PROTOCOLS (ReturnValues[0]);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Common function which returns vendor details.
> +
> + @param[in] MessageId
> SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR
> + OR
> + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR
> +
> + @param[out] VendorIdentifier ASCII name of the vendor/subvendor.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverVendorDetails (
> + IN SCMI_MESSAGE_ID_BASE MessageId,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> + Cmd.MessageId = MessageId;
> +
> + PayloadLength = 0;
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + AsciiStrCpyS (
> + (CHAR8*)VendorIdentifier,
> + SCMI_MAX_STR_LEN,
> + (CONST CHAR8*)ReturnValues
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverVendor (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + )
> +{
> + return BaseDiscoverVendorDetails (
> + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR,
> + VendorIdentifier
> + );
> +}
> +
> +/** Return sub vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a sub vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +BaseDiscoverSubVendor (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + )
> +{
> + return BaseDiscoverVendorDetails (
> + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR,
> + VendorIdentifier
> + );
> +}
> +
> +/** Return implementation version.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ImplementationVersion Vendor specific implementation
> version.
> +
> + @retval EFI_SUCCESS Implementation version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverImplVersion (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *ImplementationVersion
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> + Cmd.MessageId =
> SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION;
> +
> + PayloadLength = 0;
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *ImplementationVersion = ReturnValues[0];
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return list of protocols.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ProtocolListSize Size of the ProtocolList.
> +
> + @param[out] ProtocolList Protocol list.
> +
> + @retval EFI_SUCCESS List of protocols is returned.
> + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the
> result.
> + It has been updated to the size needed.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverListProtocols (
> + IN SCMI_BASE_PROTOCOL *This,
> + IN OUT UINT32 *ProtocolListSize,
> + OUT UINT8 *ProtocolList
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 TotalProtocols;
> + UINT32 *MessageParams;
> + BASE_DISCOVER_LIST *DiscoverList;
> + UINT32 Skip;
> + UINT32 Index;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> + UINT32 RequiredSize;
> +
> + Status = BaseGetTotalProtocols (This, &TotalProtocols);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + RequiredSize = sizeof (UINT8) * TotalProtocols;
> + if (*ProtocolListSize < RequiredSize) {
> + *ProtocolListSize = RequiredSize;
> + return EFI_BUFFER_TOO_SMALL;
> + }
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> + Cmd.MessageId =
> SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS;
> +
> + Skip = 0;
> +
> + while (Skip < TotalProtocols) {
> +
> + *MessageParams = Skip;
> +
> + // Note PayloadLength is a IN/OUT parameter.
> + PayloadLength = sizeof (Skip);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&DiscoverList
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + for (Index = 0; Index < DiscoverList->NumProtocols; Index++) {
> + ProtocolList[Skip++] = DiscoverList->Protocols[Index];
> + }
> + }
> +
> + *ProtocolListSize = RequiredSize;
> +
> + return EFI_SUCCESS;
> +}
> +
> +// Instance of the SCMI Base protocol.
> +STATIC CONST SCMI_BASE_PROTOCOL BaseProtocol = {
> + BaseGetVersion,
> + BaseGetTotalProtocols,
> + BaseDiscoverVendor,
> + BaseDiscoverSubVendor,
> + BaseDiscoverImplVersion,
> + BaseDiscoverListProtocols
> +};
> +
> +/** Initialize Base protocol and install protocol on a given handle.
> +
> + @param[in] Handle Handle to install Base protocol.
> +
> + @retval EFI_SUCCESS Base protocol interface installed
> + successfully.
> +**/
> +EFI_STATUS
> +ScmiBaseProtocolInit (
> + IN OUT EFI_HANDLE* Handle
> + )
> +{
> + return gBS->InstallMultipleProtocolInterfaces (
> + Handle,
> + &gArmScmiBaseProtocolGuid,
> + &BaseProtocol,
> + NULL
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..fe7edd2a8c8b7761fb3
> 008e66d192ef1ee1ade2e
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> @@ -0,0 +1,418 @@
> +/** @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 <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/ArmScmiClockProtocol.h>
> +
> +#include "ArmScmiClockProtocolPrivate.h"
> +#include "ScmiPrivate.h"
> +
> +/** Convert to 64 bit value from two 32 bit words.
> +
> + @param[in] Low Lower 32 bits.
> + @param[in] High Higher 32 bits.
> +
> + @retval UINT64 64 bit value.
> +**/
> +STATIC
> +UINT64
> +ConvertTo64Bit (
> + IN UINT32 Low,
> + IN UINT32 High
> + )
> +{
> + return (Low | ((UINT64)High << 32));
> +}
> +
> +/** Return version of the clock management protocol supported by SCP
> firmware.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Clock management
> protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockGetVersion (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *Version
> + )
> +{
> + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_CLOCK, Version);
> +}
> +
> +/** Return total number of clock devices supported by the clock
> management
> + protocol.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] TotalClocks Total number of clocks supported.
> +
> + @retval EFI_SUCCESS Total number of clocks supported is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockGetTotalClocks (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *TotalClocks
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> +
> + Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK,
> &ReturnValues);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return attributes of a clock device.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Enabled If TRUE, the clock device is enabled.
> + @param[out] ClockAsciiName A NULL terminated ASCII string with the
> clock
> + name, of up to 16 bytes.
> +
> + @retval EFI_SUCCESS Clock device attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockGetClockAttributes (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT BOOLEAN *Enabled,
> + OUT CHAR8 *ClockAsciiName
> + )
> +{
> + EFI_STATUS Status;
> +
> + UINT32 *MessageParams;
> + CLOCK_ATTRIBUTES *ClockAttributes;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = ClockId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES;
> +
> + PayloadLength = sizeof (ClockId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&ClockAttributes
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + // TRUE if bit 0 of ClockAttributes->Attributes is set.
> + *Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
> +
> + AsciiStrCpyS (
> + ClockAsciiName,
> + SCMI_MAX_STR_LEN,
> + (CONST CHAR8*)ClockAttributes->ClockName
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return list of rates supported by a given clock device.
> +
> + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock
> device
> + supports range of clock rates which are non-linear.
> +
> + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device
> supports
> + range of linear clock rates from Min to Max in steps.
> +
> + @param[out] TotalRates Total number of rates.
> +
> + @param[in,out] RateArraySize Size of the RateArray.
> +
> + @param[out] RateArray List of clock rates.
> +
> + @retval EFI_SUCCESS List of clock rates is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the
> result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockDescribeRates (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT SCMI_CLOCK_RATE_FORMAT *Format,
> + OUT UINT32 *TotalRates,
> + IN OUT UINT32 *RateArraySize,
> + OUT SCMI_CLOCK_RATE *RateArray
> + )
> +{
> + EFI_STATUS Status;
> +
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> + CLOCK_DESCRIBE_RATES *DescribeRates;
> + CLOCK_RATE_DWORD *Rate;
> +
> + UINT32 RequiredArraySize = 0;
> + UINT32 RateIndex = 0;
> + UINT32 RateNo;
> + UINT32 RateOffset;
> +
> + *TotalRates = 0;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES;
> +
> + *MessageParams++ = ClockId;
> +
> + do {
> +
> + *MessageParams = RateIndex;
> +
> + // Set Payload length, note PayloadLength is a IN/OUT parameter.
> + PayloadLength = sizeof (ClockId) + sizeof (RateIndex);
> +
> + // Execute and wait for response on a SCMI channel.
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&DescribeRates
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + if (*TotalRates == 0) {
> + // In the first iteration we will get number of returned rates and
> number
> + // of remaining rates. With this information calculate required size
> + // for rate array. If provided RateArraySize is less, return an
> + // error.
> +
> + *Format = RATE_FORMAT (DescribeRates->NumRatesFlags);
> +
> + *TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
> + + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
> +
> + if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
> + RequiredArraySize = (*TotalRates) * sizeof (UINT64);
> + } else {
> + // We need to return triplet of 64 bit value for each rate
> + RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
> + }
> +
> + if (RequiredArraySize > (*RateArraySize)) {
> + *RateArraySize = RequiredArraySize;
> + return EFI_BUFFER_TOO_SMALL;
> + }
> + }
> +
> + RateOffset = 0;
> +
> + if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
> + for (RateNo = 0; RateNo < NUM_RATES (DescribeRates-
> >NumRatesFlags); RateNo++) {
> + Rate = &DescribeRates->Rates[RateOffset++];
> + // Non-linear discrete rates.
> + RateArray[RateIndex++].Rate = ConvertTo64Bit (Rate->Low, Rate-
> >High);
> + }
> + } else {
> + for (RateNo = 0; RateNo < NUM_RATES (DescribeRates-
> >NumRatesFlags); RateNo++) {
> + // Linear clock rates from minimum to maximum in steps
> + // Minimum clock rate.
> + Rate = &DescribeRates->Rates[RateOffset++];
> + RateArray[RateIndex].Min = ConvertTo64Bit (Rate->Low, Rate->High);
> +
> + Rate = &DescribeRates->Rates[RateOffset++];
> + // Maximum clock rate.
> + RateArray[RateIndex].Max = ConvertTo64Bit (Rate->Low, Rate->High);
> +
> + Rate = &DescribeRates->Rates[RateOffset++];
> + // Step.
> + RateArray[RateIndex++].Step = ConvertTo64Bit (Rate->Low, Rate-
> >High);
> + }
> + }
> + } while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
> +
> + // Update RateArraySize with RequiredArraySize.
> + *RateArraySize = RequiredArraySize;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Get clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockRateGet (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT UINT64 *Rate
> + )
> +{
> + EFI_STATUS Status;
> +
> + UINT32 *MessageParams;
> + CLOCK_RATE_DWORD *ClockRate;
> + SCMI_COMMAND Cmd;
> +
> + UINT32 PayloadLength;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Fill arguments for clock protocol command.
> + *MessageParams = ClockId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_GET;
> +
> + PayloadLength = sizeof (ClockId);
> +
> + // Execute and wait for response on a SCMI channel.
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&ClockRate
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *Rate = ((UINT64)ClockRate->High << 32) | ClockRate->Low;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> + @param[in] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate set success.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockRateSet (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + IN UINT64 Rate
> + )
> +{
> + EFI_STATUS Status;
> + CLOCK_RATE_SET_ATTRIBUTES *ClockRateSetAttributes;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Status = ScmiCommandGetPayload
> ((UINT32**)&ClockRateSetAttributes);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Fill arguments for clock protocol command.
> + ClockRateSetAttributes->ClockId = ClockId;
> + ClockRateSetAttributes->Flags = CLOCK_SET_DEFAULT_FLAGS;
> + ClockRateSetAttributes->Rate.Low = (UINT32)Rate;
> + ClockRateSetAttributes->Rate.High = (UINT32)(Rate >> 32);
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_SET;
> +
> + PayloadLength = sizeof (CLOCK_RATE_SET_ATTRIBUTES);
> +
> + // Execute and wait for response on a SCMI channel.
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + NULL
> + );
> +
> + return Status;
> +}
> +
> +// Instance of the SCMI clock management protocol.
> +STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol = {
> + ClockGetVersion,
> + ClockGetTotalClocks,
> + ClockGetClockAttributes,
> + ClockDescribeRates,
> + ClockRateGet,
> + ClockRateSet
> + };
> +
> +/** Initialize clock management protocol and install protocol on a given
> handle.
> +
> + @param[in] Handle Handle to install clock management protocol.
> +
> + @retval EFI_SUCCESS Clock protocol interface installed successfully.
> +**/
> +EFI_STATUS
> +ScmiClockProtocolInit (
> + IN EFI_HANDLE* Handle
> + )
> +{
> + return gBS->InstallMultipleProtocolInterfaces (
> + Handle,
> + &gArmScmiClockProtocolGuid,
> + &ScmiClockProtocol,
> + NULL
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..2920c6f6f33c5bb8ac0
> 0c903a0b199ba5f06f4de
> --- /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;
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..29cdde173659c70111
> 6b021a3c437a92b473e4e5
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> @@ -0,0 +1,41 @@
> +/** @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
> +**/
> +#ifndef SCMI_DXE_H_
> +#define SCMI_DXE_H_
> +
> +#define MAX_PROTOCOLS 6
> +#define PROTOCOL_ID_MASK 0xF
> +#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
> +
> +/** Pointer to protocol initialization function.
> +
> + @param[in] Handle A pointer to the EFI_HANDLE on which the protocol
> + interface is to be installed.
> +
> + @retval EFI_SUCCESS Protocol interface installed successfully.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PROTOCOL_INIT_FXN)(
> + IN EFI_HANDLE *Handle
> + );
> +
> +typedef struct {
> + SCMI_PROTOCOL_INIT_FXN Init;
> +} SCMI_PROTOCOL_INIT_TABLE;
> +
> +#endif /* SCMI_DXE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..ac32442ad838040721
> fd62faa806e82184f2b288
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> @@ -0,0 +1,457 @@
> +/** @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 <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/ArmScmiPerformanceProtocol.h>
> +#include <string.h>
> +
> +#include "ArmScmiPerformanceProtocolPrivate.h"
> +#include "ScmiPrivate.h"
> +
> +/** Return version of the performance management protocol supported
> by SCP.
> + firmware.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> +
> + @param[out] Version Version of the supported SCMI performance
> management
> + protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceGetVersion (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT UINT32 *Version
> + )
> +{
> + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_PERFORMANCE,
> Version);
> +}
> +
> +/** Return protocol attributes of the performance management protocol.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> +
> + @param[out] Attributes Protocol attributes.
> +
> + @retval EFI_SUCCESS Protocol attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceGetAttributes (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
> + )
> +{
> + EFI_STATUS Status;
> + UINT32* ReturnValues;
> +
> + Status = ScmiGetProtocolAttributes (
> + SCMI_PROTOCOL_ID_PERFORMANCE,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + memcpy (
> + Attributes,
> + ReturnValues,
> + sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return performance domain attributes.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Attributes Performance domain attributes.
> +
> + @retval EFI_SUCCESS Domain attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceDomainAttributes (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *MessageParams;
> + UINT32 *ReturnValues;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId =
> SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES;
> +
> + PayloadLength = sizeof (DomainId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + memcpy (
> + DomainAttributes,
> + ReturnValues,
> + sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return list of performance domain levels of a given domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] NumLevels Total number of levels a domain can support.
> +
> + @param[in,out] LevelArraySize Size of the performance level array.
> +
> + @param[out] LevelArray Array of the performance levels.
> +
> + @retval EFI_SUCCESS Domain levels are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the
> result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceDescribeLevels (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *NumLevels,
> + IN OUT UINT32 *LevelArraySize,
> + OUT SCMI_PERFORMANCE_LEVEL *LevelArray
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32* MessageParams;
> + UINT32 LevelIndex;
> + UINT32 RequiredSize;
> + UINT32 LevelNo;
> + UINT32 ReturnNumLevels;
> + UINT32 ReturnRemainNumLevels;
> +
> + PERF_DESCRIBE_LEVELS *Levels;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + LevelIndex = 0;
> + RequiredSize = 0;
> +
> + *MessageParams++ = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId =
> SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS;
> +
> + do {
> +
> + *MessageParams = LevelIndex;
> +
> + // Note, PayloadLength is an IN/OUT parameter.
> + PayloadLength = sizeof (DomainId) + sizeof (LevelIndex);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&Levels
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + ReturnNumLevels = NUM_PERF_LEVELS (Levels->NumLevels);
> + ReturnRemainNumLevels = NUM_REMAIN_PERF_LEVELS (Levels-
> >NumLevels);
> +
> + if (RequiredSize == 0) {
> + *NumLevels = ReturnNumLevels + ReturnRemainNumLevels;
> +
> + RequiredSize = (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL);
> + if (RequiredSize > (*LevelArraySize)) {
> + // Update LevelArraySize with required size.
> + *LevelArraySize = RequiredSize;
> + return EFI_BUFFER_TOO_SMALL;
> + }
> + }
> +
> + for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
> + memcpy (
> + &LevelArray[LevelIndex++],
> + &Levels->PerfLevel[LevelNo],
> + sizeof (SCMI_PERFORMANCE_LEVEL)
> + );
> + }
> +
> + } while (ReturnRemainNumLevels != 0);
> +
> + *LevelArraySize = RequiredSize;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Limit Performance limit to set.
> +
> + @retval EFI_SUCCESS Performance limits set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLimitsSet (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN SCMI_PERFORMANCE_LIMITS *Limits
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams++ = DomainId;
> + *MessageParams++ = Limits->RangeMax;
> + *MessageParams = Limits->RangeMin;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET;
> +
> + PayloadLength = sizeof (DomainId) + sizeof
> (SCMI_PERFORMANCE_LIMITS);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + NULL
> + );
> +
> + return Status;
> +}
> +
> +/** Get performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Limit Performance Limits of the domain.
> +
> + @retval EFI_SUCCESS Performance limits are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLimitsGet (
> + SCMI_PERFORMANCE_PROTOCOL *This,
> + UINT32 DomainId,
> + SCMI_PERFORMANCE_LIMITS *Limits
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> +
> + SCMI_PERFORMANCE_LIMITS *ReturnValues;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET;
> +
> + PayloadLength = sizeof (DomainId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Limits->RangeMax = ReturnValues->RangeMax;
> + Limits->RangeMin = ReturnValues->RangeMin;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLevelSet (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN UINT32 Level
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams++ = DomainId;
> + *MessageParams = Level;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET;
> +
> + PayloadLength = sizeof (DomainId) + sizeof (Level);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + NULL
> + );
> +
> + return Status;
> +}
> +
> +/** Get performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level got successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLevelGet (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *Level
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *ReturnValues;
> + UINT32 *MessageParams;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET;
> +
> + PayloadLength = sizeof (DomainId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *Level = *ReturnValues;
> +
> + return EFI_SUCCESS;
> +}
> +
> +// Instance of the SCMI performance management protocol.
> +STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol = {
> + PerformanceGetVersion,
> + PerformanceGetAttributes,
> + PerformanceDomainAttributes,
> + PerformanceDescribeLevels,
> + PerformanceLimitsSet,
> + PerformanceLimitsGet,
> + PerformanceLevelSet,
> + PerformanceLevelGet
> +};
> +
> +/** Initialize performance management protocol and install on a given
> Handle.
> +
> + @param[in] Handle Handle to install performance management
> + protocol.
> +
> + @retval EFI_SUCCESS Performance protocol installed successfully.
> +**/
> +EFI_STATUS
> +ScmiPerformanceProtocolInit (
> + IN EFI_HANDLE* Handle
> + )
> +{
> + return gBS->InstallMultipleProtocolInterfaces (
> + Handle,
> + &gArmScmiPerformanceProtocolGuid,
> + &PerformanceProtocol,
> + NULL
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..df03655b8b021fe5fd6
> 3ceab0dd414906d2fb248
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> @@ -0,0 +1,174 @@
> +/** @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
> +**/
> +#ifndef SCMI_PRIVATE_H_
> +#define SCMI_PRIVATE_H_
> +
> +// SCMI protocol IDs.
> +typedef enum {
> + SCMI_PROTOCOL_ID_BASE = 0x10,
> + SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
> + SCMI_PROTOCOL_ID_SYSTEM_POWER = 0x12,
> + SCMI_PROTOCOL_ID_PERFORMANCE = 0x13,
> + SCMI_PROTOCOL_ID_CLOCK = 0x14,
> + SCMI_PROTOCOL_ID_SENSOR = 0x15
> +} SCMI_PROTOCOL_ID;
> +
> +// SCMI message types.
> +typedef enum {
> + SCMI_MESSAGE_TYPE_COMMAND = 0,
> + SCMI_MESSAGE_TYPE_DELAYED_RESPONSE = 2, // Skipping 1 is
> deliberate.
> + SCMI_MESSAGE_TYPE_NOTIFICATION = 3
> +} SCMI_MESSAGE_TYPE;
> +
> +// SCMI response error codes.
> +typedef enum {
> + SCMI_SUCCESS = 0,
> + SCMI_NOT_SUPPORTED = -1,
> + SCMI_INVALID_PARAMETERS = -2,
> + SCMI_DENIED = -3,
> + SCMI_NOT_FOUND = -4,
> + SCMI_OUT_OF_RANGE = -5,
> + SCMI_BUSY = -6,
> + SCMI_COMMS_ERROR = -7,
> + SCMI_GENERIC_ERROR = -8,
> + SCMI_HARDWARE_ERROR = -9,
> + SCMI_PROTOCOL_ERROR = -10
> +} SCMI_STATUS;
> +
> +// SCMI message IDs common to all protocols.
> +typedef enum {
> + SCMI_MESSAGE_ID_PROTOCOL_VERSION = 0x0,
> + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES = 0x1,
> + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2
> +} SCMI_MESSAGE_ID;
> +
> +// Not defined in SCMI specification but will help to identify a message.
> +typedef struct {
> + SCMI_PROTOCOL_ID ProtocolId;
> + UINT32 MessageId;
> +} SCMI_COMMAND;
> +
> +#pragma pack(1)
> +
> +// Response to a SCMI command.
> +typedef struct {
> + INT32 Status;
> + UINT32 ReturnValues[];
> +} SCMI_MESSAGE_RESPONSE;
> +
> +// Message header. MsgId[7:0], MsgType[9:8], ProtocolId[17:10]
> +#define MESSAGE_TYPE_SHIFT 8
> +#define PROTOCOL_ID_SHIFT 10
> +#define SCMI_MESSAGE_HEADER(MsgId, MsgType, ProtocolId) ( \
> + MsgType << MESSAGE_TYPE_SHIFT | \
> + ProtocolId << PROTOCOL_ID_SHIFT | \
> + MsgId \
> + )
> +// SCMI message header.
> +typedef struct {
> + UINT32 MessageHeader;
> +} SCMI_MESSAGE_HEADER;
> +
> +#pragma pack()
> +
> +/** Return a pointer to the message payload.
> +
> + @param[out] Payload Holds pointer to the message payload.
> +
> + @retval EFI_SUCCESS Payload holds a valid message payload pointer.
> + @retval EFI_TIMEOUT Time out error if MTL channel is busy.
> + @retval EFI_UNSUPPORTED If MTL channel is unsupported.
> +**/
> +EFI_STATUS
> +ScmiCommandGetPayload (
> + OUT UINT32** Payload
> + );
> +
> +/** Execute a SCMI command and receive a response.
> +
> + This function uses a MTL channel to transfer message to SCP
> + and waits for a response.
> +
> + @param[in] Command Pointer to the SCMI command (Protocol ID
> + and Message ID)
> +
> + @param[in,out] PayloadLength SCMI command message length.
> +
> + @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
> +
> + @retval OUT EFI_SUCCESS Command sent and message received
> successfully.
> + @retval OUT EFI_UNSUPPORTED Channel not supported.
> + @retval OUT EFI_TIMEOUT Timeout on the channel.
> + @retval OUT EFI_DEVICE_ERROR Channel not ready.
> + @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
> + @retval OUT EFI_DEVICE_ERROR SCMI error.
> +**/
> +EFI_STATUS
> +ScmiCommandExecute (
> + IN SCMI_COMMAND *Command,
> + IN OUT UINT32 *PayloadLength,
> + OUT UINT32 **ReturnValues OPTIONAL
> + );
> +
> +/** Return protocol version from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] Version Pointer to version of the protocol.
> +
> + @retval EFI_SUCCESS Version holds a valid version received
> + from the SCP.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolVersion (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 *Version
> + );
> +
> +/** Return protocol attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] ReturnValues Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + );
> +
> +/** Return protocol message attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> +
> + @param[out] Attributes Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol message
> attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolMessageAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + );
> +
> +#endif /* SCMI_PRIVATE_H_ */
> diff --git a/ArmPkg/Include/Protocol/ArmScmi.h
> b/ArmPkg/Include/Protocol/ArmScmi.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..239abb97064578c949
> 614f79a6a33fe1881c3c68
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmi.h
> @@ -0,0 +1,27 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_H_
> +#define ARM_SCMI_H_
> +
> +/* As per SCMI specification, maximum allowed ASCII string length
> + for various return values/parameters of a SCMI message.
> +*/
> +#define SCMI_MAX_STR_LEN 16
> +
> +#endif /* ARM_SCMI_H_ */
> +
> diff --git a/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..ecc41f2181ecc9f8359
> 50ab46c7cfd2e476a7073
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> @@ -0,0 +1,174 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_BASE_PROTOCOL_H_
> +#define ARM_SCMI_BASE_PROTOCOL_H_
> +
> +#include <Protocol/ArmScmi.h>
> +
> +#define BASE_PROTOCOL_VERSION 0x10000
> +
> +#define NUM_PROTOCOL_MASK 0xFFU
> +#define NUM_AGENT_MASK 0xFFU
> +
> +#define NUM_AGENT_SHIFT 0x8
> +
> +/** Returns total number of protocols that are
> + implemented (excluding the Base protocol)
> +*/
> +#define SCMI_TOTAL_PROTOCOLS(Attr) (Attr & NUM_PROTOCOL_MASK)
> +
> +// Returns total number of agents in the system.
> +#define SCMI_TOTAL_AGENTS(Attr) ((Attr >> NUM_AGENT_SHIFT) &
> NUM_AGENT_MASK)
> +
> +#define ARM_SCMI_BASE_PROTOCOL_GUID { \
> + 0xd7e5abe9, 0x33ab, 0x418e, {0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e,
> 0x2f} \
> + }
> +
> +extern EFI_GUID gArmScmiBaseProtocolGuid;
> +
> +typedef struct _SCMI_BASE_PROTOCOL SCMI_BASE_PROTOCOL;
> +
> +/** Return version of the Base protocol supported by SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Base protocol.
> +
> + @retval EFI_SUCCESS The version of the protocol is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_GET_VERSION) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *Version
> + );
> +
> +/** Return total number of SCMI protocols supported by the SCP
> firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] TotalProtocols Total number of SCMI protocols supported.
> +
> + @retval EFI_SUCCESS Total number of protocols supported are
> returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_GET_TOTAL_PROTOCOLS) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *TotalProtocols
> + );
> +
> +/** Return vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_VENDOR) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + );
> +
> +/** Return sub vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_SUB_VENDOR) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + );
> +
> +/** Return implementation version.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ImplementationVersion Vendor specific implementation
> version.
> +
> + @retval EFI_SUCCESS Implementation version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *ImplementationVersion
> + );
> +
> +/** Return list of protocols.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ProtocolListSize Size of the ProtocolList.
> +
> + @param[out] ProtocolList Protocol list.
> +
> + @retval EFI_SUCCESS List of protocols is returned.
> + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the
> result.
> + It has been updated to the size needed.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_LIST_PROTOCOLS) (
> + IN SCMI_BASE_PROTOCOL *This,
> + IN OUT UINT32 *ProtocolListSize,
> + OUT UINT8 *ProtocolList
> + );
> +
> +// Base protocol.
> +typedef struct _SCMI_BASE_PROTOCOL {
> + SCMI_BASE_GET_VERSION GetVersion;
> + SCMI_BASE_GET_TOTAL_PROTOCOLS GetTotalProtocols;
> + SCMI_BASE_DISCOVER_VENDOR DiscoverVendor;
> + SCMI_BASE_DISCOVER_SUB_VENDOR DiscoverSubVendor;
> + SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION
> DiscoverImplementationVersion;
> + SCMI_BASE_DISCOVER_LIST_PROTOCOLS DiscoverListProtocols;
> +} SCMI_BASE_PROTOCOL;
> +
> +// SCMI Message IDs for Base protocol.
> +typedef enum {
> + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR = 0x3,
> + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR = 0x4,
> + SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION = 0x5,
> + SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS = 0x6
> +} SCMI_MESSAGE_ID_BASE;
> +
> +#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */
> +
> diff --git a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..3db26cb0641c7377c0
> 22a8e00be9a51ee5dc7361
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> @@ -0,0 +1,218 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_
> +#define ARM_SCMI_CLOCK_PROTOCOL_H_
> +
> +#include <Protocol/ArmScmi.h>
> +
> +#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \
> + 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e,
> 0xaa} \
> + }
> +
> +extern EFI_GUID gArmScmiClockProtocolGuid;
> +
> +// Message Type for clock management protocol.
> +typedef enum {
> + SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3,
> + SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4,
> + SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5,
> + SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6,
> + SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7
> +} SCMI_MESSAGE_ID_CLOCK;
> +
> +typedef enum {
> + SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range.
> + SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range.
> +} SCMI_CLOCK_RATE_FORMAT;
> +
> +// Clock management protocol version.
> +#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000
> +
> +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK
> 0xFFU
> +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16
> +#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU
> +
> +/** Total number of pending asynchronous clock rates changes
> + supported by the SCP, Attr Bits[23:16]
> +*/
> +#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr)
> ( \
> + (Attr >>
> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \
> + SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)
> +
> +// Total of clock devices supported by the SCP, Attr Bits[15:0]
> +#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr &
> SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)
> +
> +#pragma pack(1)
> +
> +/* Depending on the format (linear/non-linear) supported by a clock
> device
> + either Rate or Min/Max/Step triplet is valid.
> +*/
> +typedef struct {
> + union {
> + UINT64 Min;
> + UINT64 Rate;
> + };
> + UINT64 Max;
> + UINT64 Step;
> +} SCMI_CLOCK_RATE;
> +
> +#pragma pack()
> +
> +typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL;
> +
> +// Protocol Interface functions.
> +
> +/** Return version of the clock management protocol supported by SCP
> firmware.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Clock management
> protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_GET_VERSION) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *Version
> + );
> +
> +/** Return total number of clock devices supported by the clock
> management
> + protocol.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] TotalClocks Total number of clocks supported.
> +
> + @retval EFI_SUCCESS Total number of clocks supported is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *TotalClocks
> + );
> +
> +/** Return attributes of a clock device.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Enabled If TRUE, the clock device is enabled.
> + @param[out] ClockAsciiName A NULL terminated ASCII string with the
> clock
> + name, of up to 16 bytes.
> +
> + @retval EFI_SUCCESS Clock device attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT BOOLEAN *Enabled,
> + OUT CHAR8 *ClockAsciiName
> + );
> +
> +/** Return list of rates supported by a given clock device.
> +
> + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock
> device
> + supports range of clock rates which are non-linear.
> +
> + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device
> supports
> + range of linear clock rates from Min to Max in steps.
> +
> + @param[out] TotalRates Total number of rates.
> +
> + @param[in,out] RateArraySize Size of the RateArray.
> +
> + @param[out] RateArray List of clock rates.
> +
> + @retval EFI_SUCCESS List of clock rates are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the
> result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT SCMI_CLOCK_RATE_FORMAT *Format,
> + OUT UINT32 *TotalRates,
> + IN OUT UINT32 *RateArraySize,
> + OUT SCMI_CLOCK_RATE *RateArray
> + );
> +
> +/** Get clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_RATE_GET) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT UINT64 *Rate
> + );
> +
> +/** Set clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> + @param[in] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate set success.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_RATE_SET) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + IN UINT64 Rate
> + );
> +
> +typedef struct _SCMI_CLOCK_PROTOCOL {
> + SCMI_CLOCK_GET_VERSION GetVersion;
> + SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks;
> + SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes;
> + SCMI_CLOCK_DESCRIBE_RATES DescribeRates;
> + SCMI_CLOCK_RATE_GET RateGet;
> + SCMI_CLOCK_RATE_SET RateSet;
> +} SCMI_CLOCK_PROTOCOL;
> +
> +#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */
> +
> diff --git a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> new file mode 100644
> index
> 0000000000000000000000000000000000000000..1d1af6f8bee0c00bbe6
> b4774036c87c988a4f4af
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> @@ -0,0 +1,265 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
> +#define ARM_SCMI_PERFORMANCE_PROTOCOL_H_
> +
> +#include <Protocol/ArmScmi.h>
> +
> +#define PERFORMANCE_PROTOCOL_VERSION 0x10000
> +
> +#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \
> + 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b,
> 0xad} \
> + }
> +
> +extern EFI_GUID gArmScmiPerformanceProtocolGuid;
> +
> +typedef struct _SCMI_PERFORMANCE_PROTOCOL
> SCMI_PERFORMANCE_PROTOCOL;
> +
> +#pragma pack(1)
> +
> +#define POWER_IN_MW_SHIFT 16
> +#define POWER_IN_MW_MASK 0x1
> +#define NUM_PERF_DOMAINS_MASK 0xFFFF
> +
> +// Total number of performance domains, Attr Bits [15:0]
> +#define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr &
> NUM_PERF_DOMAINS_MASK)
> +
> +// A flag to express power values in mW or platform specific way, Attr Bit
> [16]
> +#define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >>
> POWER_IN_MW_SHIFT) & \
> + POWER_IN_MW_MASK)
> +
> +// Performance protocol attributes return values.
> +typedef struct {
> + UINT32 Attributes;
> + UINT64 StatisticsAddress;
> + UINT32 StatisticsLen;
> +} SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES;
> +
> +#define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28) &
> 0x1)
> +#define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29) &
> 0x1)
> +#define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1)
> +#define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1)
> +#define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF)
> +
> +// Performance protocol domain attributes.
> +typedef struct {
> + UINT32 Attributes;
> + UINT32 RateLimit;
> + UINT32 SustainedFreq;
> + UINT32 SustainedPerfLevel;
> + UINT8 Name[SCMI_MAX_STR_LEN];
> +} SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES;
> +
> +// Worst case latency in microseconds, Bits[15:0]
> +#define PERF_LATENCY_MASK 0xFFFF
> +#define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency &
> PERF_LATENCY_MASK)
> +
> +// Performance protocol performance level.
> +typedef struct {
> + UINT32 Level;
> + UINT32 PowerCost;
> + UINT32 Latency;
> +} SCMI_PERFORMANCE_LEVEL;
> +
> +// Performance protocol performance limit.
> +typedef struct {
> + UINT32 RangeMax;
> + UINT32 RangeMin;
> +} SCMI_PERFORMANCE_LIMITS;
> +
> +#pragma pack()
> +
> +/** Return version of the performance management protocol supported
> by SCP.
> + firmware.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> +
> + @param[out] Version Version of the supported SCMI performance
> management
> + protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_GET_VERSION) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT UINT32 *Version
> + );
> +
> +/** Return protocol attributes of the performance management protocol.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> +
> + @param[out] Attributes Protocol attributes.
> +
> + @retval EFI_SUCCESS Protocol attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
> +
> + );
> +
> +/** Return performance domain attributes.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Attributes Performance domain attributes.
> +
> + @retval EFI_SUCCESS Domain attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
> + );
> +
> +/** Return list of performance domain levels of a given domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] NumLevels Total number of levels a domain can support.
> +
> + @param[in,out] LevelArraySize Size of the performance level array.
> +
> + @param[out] LevelArray Array of the performance levels.
> +
> + @retval EFI_SUCCESS Domain levels are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the
> result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *NumLevels,
> + IN OUT UINT32 *LevelArraySize,
> + OUT SCMI_PERFORMANCE_LEVEL *LevelArray
> + );
> +
> +/** Set performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Limit Performance limit to set.
> +
> + @retval EFI_SUCCESS Performance limits set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN SCMI_PERFORMANCE_LIMITS *Limits
> + );
> +
> +/** Get performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Limit Performance Limits of the domain.
> +
> + @retval EFI_SUCCESS Performance limits are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) (
> + SCMI_PERFORMANCE_PROTOCOL *This,
> + UINT32 DomainId,
> + SCMI_PERFORMANCE_LIMITS *Limits
> + );
> +
> +/** Set performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN UINT32 Level
> + );
> +
> +/** Get performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level got successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *Level
> + );
> +
> +typedef struct _SCMI_PERFORMANCE_PROTOCOL {
> + SCMI_PERFORMANCE_GET_VERSION GetVersion;
> + SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes;
> + SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES GetDomainAttributes;
> + SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels;
> + SCMI_PERFORMANCE_LIMITS_SET LimitsSet;
> + SCMI_PERFORMANCE_LIMITS_GET LimitsGet;
> + SCMI_PERFORMANCE_LEVEL_SET LevelSet;
> + SCMI_PERFORMANCE_LEVEL_GET LevelGet;
> +} SCMI_PERFORMANCE_PROTOCOL;
> +
> +typedef enum {
> + SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3,
> + SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4,
> + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5,
> + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6,
> + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7,
> + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8,
> +} SCMI_MESSAGE_ID_PERFORMANCE;
> +
> +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
> +
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
2018-03-20 16:12 ` [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol Girish Pathak
2018-03-21 12:54 ` Evan Lloyd
@ 2018-04-23 11:31 ` Leif Lindholm
2018-04-23 16:06 ` Girish Pathak
1 sibling, 1 reply; 40+ messages in thread
From: Leif Lindholm @ 2018-04-23 11:31 UTC (permalink / raw)
To: Girish Pathak
Cc: edk2-devel, ard.biesheuvel, Matteo.Carlini, Stephanie.Hughes-Fitt,
nd
Hmm, I did find a few minor things below that I need to hear back on
before pushing.
On Tue, Mar 20, 2018 at 04:12:12PM +0000, Girish Pathak wrote:
> 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>
> ---
>
> Notes:
> v3:
> - Please rename ArmMtl.h to ArmMtlLibi.h, and
> declare it as a library class in the package file. [Ard]
>
> Done, however ArmMtlLib.h is now part of earlier commit [Girish]
>
> - Move ArmScmiDxe to ArmPkg from ArmPlatformPkg [Ard]
>
> Done [Girish]
>
> - Declare gArmScmiBaseProtocolGuid and similar
> protocols Guids in ArmPkg.dec [Ard]
>
> Done [Girish]
>
> - Replace flexible array member [] with [1] [Ard]
>
> Done [Girish]
>
> - Move protocol init function which are not part of
> of protocol like ScmiBaseProtocolInit elsewhere [Ard]
>
> Done [Girish]
>
> - Please don't put stuff in Include/Drivers. [Ard]
>
> Moved headers to Include/Protocol. [Girish]
>
> ArmPkg/ArmPkg.dec | 13 +
> ArmPkg/ArmPkg.dsc | 6 +-
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h | 46 ++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 84 ++++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf | 53 +++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h | 55 +++
> ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 262 +++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c | 318 ++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 418 ++++++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 138 ++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 41 ++
> ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 457 ++++++++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h | 174 ++++++++
> ArmPkg/Include/Protocol/ArmScmi.h | 27 ++
> ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h | 174 ++++++++
> ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 218 ++++++++++
> ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h | 265 ++++++++++++
> 17 files changed, 2748 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> index 881751d81c6384a3eb0b4c180c76d01a58266a74..16f7e40046429142b44b526043b61a3d5e089d2c 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -51,6 +51,19 @@ [Guids.common]
>
> gArmGicDxeFileGuid = { 0xde371f7c, 0xdec4, 0x4d21, { 0xad, 0xf1, 0x59, 0x3a, 0xbc, 0xc1, 0x58, 0x82 } }
>
> +[Protocols.common]
> + ## Arm System Control and Management Interface(SCMI) Base protocol
> + ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> + gArmScmiBaseProtocolGuid = { 0xd7e5abe9, 0x33ab, 0x418e, { 0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } }
> +
> + ## Arm System Control and Management Interface(SCMI) Clock management protocol
> + ## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> + gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
> +
> + ## Arm System Control and Management Interface(SCMI) Clock management protocol
> + ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> + gArmScmiPerformanceProtocolGuid = { 0x9b8ba84, 0x3dd3, 0x49a6, { 0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } }
> +
> [Ppis]
> ## Include/Ppi/ArmMpCoreInfo.h
> gArmMpCoreInfoPpiGuid = { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d, 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} }
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> index 526909458e0d80dbc5a65c8ad12ec1095dda48d2..22332090db7111e0668607a16288cefc1bace926 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -2,7 +2,7 @@
> # ARM processor package.
> #
> # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
> -# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
> # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> @@ -87,6 +87,8 @@ [LibraryClasses.common]
> ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
> ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
>
> + ArmMtlLib|ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> +
> [LibraryClasses.common.PEIM]
> HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
> @@ -144,5 +146,7 @@ [Components.common]
> ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>
> + ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> +
> [Components.AARCH64]
> ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..79c057d44128008ec276e3d58d8f1098c6a779b2
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> @@ -0,0 +1,46 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> +#define ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> +
> +// Return values of BASE_DISCOVER_LIST_PROTOCOLS command.
> +typedef struct {
> + UINT32 NumProtocols;
> +
> + // Array of four protocols in each element
> + // Total elements = 1 + (NumProtocols-1)/4
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + UINT8 Protocols[1];
> +} BASE_DISCOVER_LIST;
> +
> +/** Initialize Base protocol and install protocol on a given handle.
> +
> + @param[in] Handle Handle to install Base protocol.
> +
> + @retval EFI_SUCCESS Base protocol interface installed
> + successfully.
> +**/
> +EFI_STATUS
> +ScmiBaseProtocolInit (
> + IN OUT EFI_HANDLE* Handle
> + );
> +
> +#endif /* ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..71245c16475d4d38d6dc66571b3fe3520c1cf1da
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> @@ -0,0 +1,84 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
> +#define ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
> +
> +#pragma pack(1)
> +
> +// Clock rate in two 32bit words.
> +typedef struct {
> + UINT32 Low;
> + UINT32 High;
> +} CLOCK_RATE_DWORD;
> +
> +// Format of the returned rate array. Linear or Non-linear,.RatesFlag Bit[12]
> +#define RATE_FORMAT_SHIFT 12
> +#define RATE_FORMAT_MASK 0x0001
> +#define RATE_FORMAT(RatesFlags) ((RatesFlags >> RATE_FORMAT_SHIFT) \
> + & RATE_FORMAT_MASK)
I'll decrease indentation of above line by one unless someone objects?
> +
> +// Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
> +#define NUM_REMAIN_RATES_SHIFT 16
> +#define NUM_REMAIN_RATES(RatesFlags) ((RatesFlags >> NUM_REMAIN_RATES_SHIFT))
> +
> +// Number of rates that are returned by a call.to the SCP, RatesFlag Bits[11:0]
> +#define NUM_RATES_MASK 0x0FFF
> +#define NUM_RATES(RatesFlags) (RatesFlags & NUM_RATES_MASK)
> +
> +// Return values for the CLOCK_DESCRIBER_RATE command.
> +typedef struct {
> + UINT32 NumRatesFlags;
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + CLOCK_RATE_DWORD Rates[1];
> +} CLOCK_DESCRIBE_RATES;
> +
> +#define CLOCK_SET_DEFAULT_FLAGS 0
> +
> +// Message parameters for CLOCK_RATE_SET command.
> +typedef struct {
> + UINT32 Flags;
> + UINT32 ClockId;
> + CLOCK_RATE_DWORD Rate;
> +} CLOCK_RATE_SET_ATTRIBUTES;
> +
> +// if ClockAttr Bit[0] is set then clock device is enabled.
> +#define CLOCK_ENABLE_MASK 0x1
> +#define CLOCK_ENABLED(ClockAttr) ((ClockAttr & CLOCK_ENABLE_MASK) == 1)
> +
> +typedef struct {
> + UINT32 Attributes;
> + UINT8 ClockName[SCMI_MAX_STR_LEN];
> +} CLOCK_ATTRIBUTES;
> +
> +#pragma pack()
> +
> +/** Initialize clock management protocol and install protocol on a given handle.
> +
> + @param[in] Handle Handle to install clock management protocol.
> +
> + @retval EFI_SUCCESS Clock protocol interface installed successfully.
> +**/
> +EFI_STATUS
> +ScmiClockProtocolInit (
> + IN EFI_HANDLE *Handle
> + );
> +
> +#endif /* ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..05ce9c04ce468d74e5c6d38739f9056f3fc48694
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> @@ -0,0 +1,53 @@
> +#/** @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
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010019
> + BASE_NAME = ArmScmiDxe
> + FILE_GUID = 9585984C-F027-45E9-AFDF-ADAA6DFAAAC7
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = ArmScmiDxeEntryPoint
> +
> +[Sources.common]
> + Scmi.c
> + ScmiBaseProtocol.c
> + ScmiClockProtocol.c
> + ScmiDxe.c
> + ScmiPerformanceProtocol.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + ArmLib
> + ArmMtlLib
> + DebugLib
> + IoLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> +
> +[Protocols]
> + gArmScmiBaseProtocolGuid
> + gArmScmiClockProtocolGuid
> + gArmScmiPerformanceProtocolGuid
> +
> +[Depex]
> + TRUE
> +
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..4514f45a9f5dd960d2844a19b57a91b93149f1b9
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> @@ -0,0 +1,55 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
> +#define ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
> +
> +#include <Protocol/ArmScmiPerformanceProtocol.h>
> +
> +// Number of performance levels returned by a call to the SCP, Lvls Bits[11:0]
> +#define NUM_PERF_LEVELS_MASK 0x0FFF
> +#define NUM_PERF_LEVELS(Lvls) (Lvls & NUM_PERF_LEVELS_MASK)
> +
> +// Number of performance levels remaining after a call to the SCP, Lvls Bits[31:16]
> +#define NUM_REMAIN_PERF_LEVELS_SHIFT 16
> +#define NUM_REMAIN_PERF_LEVELS(Lvls) (Lvls >> NUM_REMAIN_PERF_LEVELS_SHIFT)
> +
> +/** Return values for SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS command.
> + SCMI Spec ? 4.5.2.5
> +**/
> +typedef struct {
> + UINT32 NumLevels;
> +
> + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> + // here array of 1 element length. However below is used as a variable
> + // length array.
> + SCMI_PERFORMANCE_LEVEL PerfLevel[1]; // Offset to array of performance levels
> +} PERF_DESCRIBE_LEVELS;
> +
> +/** Initialize performance management protocol and install on a given Handle.
> +
> + @param[in] Handle Handle to install performance management
> + protocol.
> +
> + @retval EFI_SUCCESS Performance protocol installed successfully.
> +**/
> +EFI_STATUS
> +ScmiPerformanceProtocolInit (
> + IN EFI_HANDLE* Handle
> + );
> +
> +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..1e279f69cf615428dbb6477b8ac7de3258628df3
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> @@ -0,0 +1,262 @@
> +/** @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 <Library/ArmMtlLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include "ScmiPrivate.h"
> +
> +// SCMI Specification 1.0
> +#define MAX_PROTOCOLS 6
> +
> +#define PROTOCOL_MASK 0xF
> +
> +// Arbitrary timeout value 20ms.
> +#define RESPONSE_TIMEOUT 20000
> +
> +/** Return a pointer to the message payload.
> +
> + @param[out] Payload Holds pointer to the message payload.
> +
> + @retval EFI_SUCCESS Payload holds a valid message payload pointer.
> + @retval EFI_TIMEOUT Time out error if MTL channel is busy.
> + @retval EFI_UNSUPPORTED If MTL channel is unsupported.
> +**/
> +EFI_STATUS
> +ScmiCommandGetPayload (
> + OUT UINT32** Payload
> + )
> +{
> + EFI_STATUS Status;
> + MTL_CHANNEL *Channel;
> +
> + // Get handle to the Channel.
> + Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Payload will not be populated until channel is free.
> + Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Get the address of the payload.
> + *Payload = MtlGetChannelPayload (Channel);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Execute a SCMI command and receive a response.
> +
> + This function uses a MTL channel to transfer message to SCP
> + and waits for a response.
> +
> + @param[in] Command Pointer to the SCMI command (Protocol ID
> + and Message ID)
> +
> + @param[in,out] PayloadLength SCMI command message length.
> +
> + @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
> +
> + @retval OUT EFI_SUCCESS Command sent and message received successfully.
> + @retval OUT EFI_UNSUPPORTED Channel not supported.
> + @retval OUT EFI_TIMEOUT Timeout on the channel.
> + @retval OUT EFI_DEVICE_ERROR Channel not ready.
> + @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
> + @retval OUT EFI_DEVICE_ERROR SCMI error.
> +**/
> +EFI_STATUS
> +ScmiCommandExecute (
> + IN SCMI_COMMAND *Command,
> + IN OUT UINT32 *PayloadLength,
> + OUT UINT32 **ReturnValues OPTIONAL
> + )
> +{
> + EFI_STATUS Status;
> + SCMI_MESSAGE_RESPONSE *Response;
> + UINT32 MessageHeader;
> + UINT32 ResponseHeader;
> + MTL_CHANNEL *Channel;
> +
> + ASSERT (PayloadLength != NULL);
> +
> + Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Fill in message header.
> + MessageHeader = SCMI_MESSAGE_HEADER (
> + Command->MessageId,
> + SCMI_MESSAGE_TYPE_COMMAND,
> + Command->ProtocolId
> + );
> +
> + // Send payload using MTL channel.
> + Status = MtlSendMessage (
> + Channel,
> + MessageHeader,
> + *PayloadLength
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Wait for the response on the channel.
> + Status = MtlReceiveMessage (Channel, &ResponseHeader, PayloadLength);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // SCMI must return MessageHeader unmodified.
> + if (MessageHeader != ResponseHeader) {
> + ASSERT (FALSE);
> + return EFI_DEVICE_ERROR;
> + }
> +
> + Response = (SCMI_MESSAGE_RESPONSE*)MtlGetChannelPayload (Channel);
> +
> + if (Response->Status != SCMI_SUCCESS) {
> + DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId = 0x%x, MessageId = 0x%x, error = %d\n",
> + Command->ProtocolId,
> + Command->MessageId,
> + Response->Status
> + ));
> +
> + ASSERT (FALSE);
> + return EFI_DEVICE_ERROR;
> + }
> +
> + if (ReturnValues != NULL) {
> + *ReturnValues = Response->ReturnValues;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Internal common function useful for common protocol discovery messages.
> +
> + @param[in] ProtocolId Protocol Id of the the protocol.
> + @param[in] MesaageId Message Id of the message.
> +
> + @param[out] ReturnValues SCMI response return values.
> +
> + @retval EFI_SUCCESS Success with valid return values.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ScmiProtocolDiscoveryCommon (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + IN SCMI_MESSAGE_ID MessageId,
> + OUT UINT32 **ReturnValues
> + )
> +{
> + SCMI_COMMAND Command;
> + UINT32 PayloadLength = 0;
> +
> + Command.ProtocolId = ProtocolId;
> + Command.MessageId = MessageId;
> +
> + return ScmiCommandExecute (
> + &Command,
> + &PayloadLength,
> + ReturnValues
> + );
> +}
> +
> +/** Return protocol version from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] Version Pointer to version of the protocol.
> +
> + @retval EFI_SUCCESS Version holds a valid version received
> + from the SCP.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolVersion (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 *Version
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ProtocolVersion;
> +
> + Status = ScmiProtocolDiscoveryCommon (
> + ProtocolId,
> + SCMI_MESSAGE_ID_PROTOCOL_VERSION,
> + (UINT32**)&ProtocolVersion
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *Version = *ProtocolVersion;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return protocol attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] ReturnValues Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + )
> +{
> + return ScmiProtocolDiscoveryCommon (
> + ProtocolId,
> + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES,
> + ReturnValues
> + );
> +}
> +
> +/** Return protocol message attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] Attributes Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol message attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolMessageAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + )
> +{
> + return ScmiProtocolDiscoveryCommon (
> + ProtocolId,
> + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES,
> + ReturnValues
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..0829438c82ec5723cfbbf9c411d10fcf22a22d89
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> @@ -0,0 +1,318 @@
> +/** @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 <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/ArmScmiBaseProtocol.h>
> +
> +#include "ArmScmiBaseProtocolPrivate.h"
> +#include "ScmiPrivate.h"
> +
> +/** Return version of the Base protocol supported by SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Base protocol.
> +
> + @retval EFI_SUCCESS The version of the protocol is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseGetVersion (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *Version
> + )
> +{
> + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_BASE, Version);
> +}
> +
> +/** Return total number of SCMI protocols supported by the SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] TotalProtocols Total number of SCMI protocols supported.
> +
> + @retval EFI_SUCCESS Total number of protocols supported are returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseGetTotalProtocols (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *TotalProtocols
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> +
> + Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_BASE, &ReturnValues);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *TotalProtocols = SCMI_TOTAL_PROTOCOLS (ReturnValues[0]);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Common function which returns vendor details.
> +
> + @param[in] MessageId SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR
> + OR
> + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR
> +
> + @param[out] VendorIdentifier ASCII name of the vendor/subvendor.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverVendorDetails (
> + IN SCMI_MESSAGE_ID_BASE MessageId,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> + Cmd.MessageId = MessageId;
> +
> + PayloadLength = 0;
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + AsciiStrCpyS (
> + (CHAR8*)VendorIdentifier,
> + SCMI_MAX_STR_LEN,
> + (CONST CHAR8*)ReturnValues
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverVendor (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + )
> +{
> + return BaseDiscoverVendorDetails (
> + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR,
> + VendorIdentifier
> + );
> +}
> +
> +/** Return sub vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a sub vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +BaseDiscoverSubVendor (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + )
> +{
> + return BaseDiscoverVendorDetails (
> + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR,
> + VendorIdentifier
> + );
> +}
> +
> +/** Return implementation version.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ImplementationVersion Vendor specific implementation version.
> +
> + @retval EFI_SUCCESS Implementation version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverImplVersion (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *ImplementationVersion
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION;
> +
> + PayloadLength = 0;
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *ImplementationVersion = ReturnValues[0];
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return list of protocols.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ProtocolListSize Size of the ProtocolList.
> +
> + @param[out] ProtocolList Protocol list.
> +
> + @retval EFI_SUCCESS List of protocols is returned.
> + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result.
> + It has been updated to the size needed.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +BaseDiscoverListProtocols (
> + IN SCMI_BASE_PROTOCOL *This,
> + IN OUT UINT32 *ProtocolListSize,
> + OUT UINT8 *ProtocolList
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 TotalProtocols;
> + UINT32 *MessageParams;
> + BASE_DISCOVER_LIST *DiscoverList;
> + UINT32 Skip;
> + UINT32 Index;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> + UINT32 RequiredSize;
> +
> + Status = BaseGetTotalProtocols (This, &TotalProtocols);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + RequiredSize = sizeof (UINT8) * TotalProtocols;
> + if (*ProtocolListSize < RequiredSize) {
> + *ProtocolListSize = RequiredSize;
> + return EFI_BUFFER_TOO_SMALL;
> + }
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS;
> +
> + Skip = 0;
> +
> + while (Skip < TotalProtocols) {
> +
> + *MessageParams = Skip;
> +
> + // Note PayloadLength is a IN/OUT parameter.
> + PayloadLength = sizeof (Skip);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&DiscoverList
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + for (Index = 0; Index < DiscoverList->NumProtocols; Index++) {
> + ProtocolList[Skip++] = DiscoverList->Protocols[Index];
> + }
> + }
> +
> + *ProtocolListSize = RequiredSize;
> +
> + return EFI_SUCCESS;
> +}
> +
> +// Instance of the SCMI Base protocol.
> +STATIC CONST SCMI_BASE_PROTOCOL BaseProtocol = {
> + BaseGetVersion,
> + BaseGetTotalProtocols,
> + BaseDiscoverVendor,
> + BaseDiscoverSubVendor,
> + BaseDiscoverImplVersion,
> + BaseDiscoverListProtocols
> +};
> +
> +/** Initialize Base protocol and install protocol on a given handle.
> +
> + @param[in] Handle Handle to install Base protocol.
> +
> + @retval EFI_SUCCESS Base protocol interface installed
> + successfully.
> +**/
> +EFI_STATUS
> +ScmiBaseProtocolInit (
> + IN OUT EFI_HANDLE* Handle
> + )
> +{
> + return gBS->InstallMultipleProtocolInterfaces (
> + Handle,
> + &gArmScmiBaseProtocolGuid,
> + &BaseProtocol,
> + NULL
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..fe7edd2a8c8b7761fb3008e66d192ef1ee1ade2e
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> @@ -0,0 +1,418 @@
> +/** @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 <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/ArmScmiClockProtocol.h>
> +
> +#include "ArmScmiClockProtocolPrivate.h"
> +#include "ScmiPrivate.h"
> +
> +/** Convert to 64 bit value from two 32 bit words.
> +
> + @param[in] Low Lower 32 bits.
> + @param[in] High Higher 32 bits.
> +
> + @retval UINT64 64 bit value.
> +**/
> +STATIC
> +UINT64
> +ConvertTo64Bit (
> + IN UINT32 Low,
> + IN UINT32 High
> + )
> +{
> + return (Low | ((UINT64)High << 32));
> +}
Suggestion for future improvement: make this a macro in Base.h
The SIGNATURE_64 macro in there would already benefit from it.
> +
> +/** Return version of the clock management protocol supported by SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Clock management protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockGetVersion (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *Version
> + )
> +{
> + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_CLOCK, Version);
> +}
> +
> +/** Return total number of clock devices supported by the clock management
> + protocol.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] TotalClocks Total number of clocks supported.
> +
> + @retval EFI_SUCCESS Total number of clocks supported is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockGetTotalClocks (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *TotalClocks
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *ReturnValues;
> +
> + Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK, &ReturnValues);
> + if (EFI_ERROR (Status)) {
> + return Status;
Missing space (will add before committing).
> + }
> +
> + *TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return attributes of a clock device.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Enabled If TRUE, the clock device is enabled.
> + @param[out] ClockAsciiName A NULL terminated ASCII string with the clock
> + name, of up to 16 bytes.
> +
> + @retval EFI_SUCCESS Clock device attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockGetClockAttributes (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT BOOLEAN *Enabled,
> + OUT CHAR8 *ClockAsciiName
> + )
> +{
> + EFI_STATUS Status;
> +
> + UINT32 *MessageParams;
> + CLOCK_ATTRIBUTES *ClockAttributes;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = ClockId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES;
> +
> + PayloadLength = sizeof (ClockId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&ClockAttributes
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> + // TRUE if bit 0 of ClockAttributes->Attributes is set.
> + *Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
> +
> + AsciiStrCpyS (
> + ClockAsciiName,
> + SCMI_MAX_STR_LEN,
> + (CONST CHAR8*)ClockAttributes->ClockName
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return list of rates supported by a given clock device.
> +
> + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
> + supports range of clock rates which are non-linear.
> +
> + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
> + range of linear clock rates from Min to Max in steps.
> +
> + @param[out] TotalRates Total number of rates.
> +
> + @param[in,out] RateArraySize Size of the RateArray.
> +
> + @param[out] RateArray List of clock rates.
> +
> + @retval EFI_SUCCESS List of clock rates is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockDescribeRates (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT SCMI_CLOCK_RATE_FORMAT *Format,
> + OUT UINT32 *TotalRates,
> + IN OUT UINT32 *RateArraySize,
> + OUT SCMI_CLOCK_RATE *RateArray
> + )
> +{
> + EFI_STATUS Status;
> +
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> + CLOCK_DESCRIBE_RATES *DescribeRates;
> + CLOCK_RATE_DWORD *Rate;
> +
> + UINT32 RequiredArraySize = 0;
> + UINT32 RateIndex = 0;
> + UINT32 RateNo;
> + UINT32 RateOffset;
> +
> + *TotalRates = 0;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES;
> +
> + *MessageParams++ = ClockId;
> +
> + do {
> +
> + *MessageParams = RateIndex;
> +
> + // Set Payload length, note PayloadLength is a IN/OUT parameter.
> + PayloadLength = sizeof (ClockId) + sizeof (RateIndex);
> +
> + // Execute and wait for response on a SCMI channel.
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&DescribeRates
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + if (*TotalRates == 0) {
> + // In the first iteration we will get number of returned rates and number
> + // of remaining rates. With this information calculate required size
> + // for rate array. If provided RateArraySize is less, return an
> + // error.
> +
> + *Format = RATE_FORMAT (DescribeRates->NumRatesFlags);
> +
> + *TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
> + + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
> +
> + if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
> + RequiredArraySize = (*TotalRates) * sizeof (UINT64);
> + } else {
> + // We need to return triplet of 64 bit value for each rate
> + RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
> + }
> +
> + if (RequiredArraySize > (*RateArraySize)) {
> + *RateArraySize = RequiredArraySize;
> + return EFI_BUFFER_TOO_SMALL;
> + }
> + }
> +
> + RateOffset = 0;
> +
> + if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
> + for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
> + Rate = &DescribeRates->Rates[RateOffset++];
> + // Non-linear discrete rates.
> + RateArray[RateIndex++].Rate = ConvertTo64Bit (Rate->Low, Rate->High);
> + }
> + } else {
> + for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
> + // Linear clock rates from minimum to maximum in steps
> + // Minimum clock rate.
> + Rate = &DescribeRates->Rates[RateOffset++];
> + RateArray[RateIndex].Min = ConvertTo64Bit (Rate->Low, Rate->High);
> +
> + Rate = &DescribeRates->Rates[RateOffset++];
> + // Maximum clock rate.
> + RateArray[RateIndex].Max = ConvertTo64Bit (Rate->Low, Rate->High);
> +
> + Rate = &DescribeRates->Rates[RateOffset++];
> + // Step.
> + RateArray[RateIndex++].Step = ConvertTo64Bit (Rate->Low, Rate->High);
> + }
> + }
> + } while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
> +
> + // Update RateArraySize with RequiredArraySize.
> + *RateArraySize = RequiredArraySize;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Get clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockRateGet (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT UINT64 *Rate
> + )
> +{
> + EFI_STATUS Status;
> +
> + UINT32 *MessageParams;
> + CLOCK_RATE_DWORD *ClockRate;
> + SCMI_COMMAND Cmd;
> +
> + UINT32 PayloadLength;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Fill arguments for clock protocol command.
> + *MessageParams = ClockId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_GET;
> +
> + PayloadLength = sizeof (ClockId);
> +
> + // Execute and wait for response on a SCMI channel.
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&ClockRate
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *Rate = ((UINT64)ClockRate->High << 32) | ClockRate->Low;
Should this not use the helper function?
I could fix that up before committing, but would like confirmation on that.
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> + @param[in] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate set success.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockRateSet (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + IN UINT64 Rate
> + )
> +{
> + EFI_STATUS Status;
> + CLOCK_RATE_SET_ATTRIBUTES *ClockRateSetAttributes;
> + SCMI_COMMAND Cmd;
> + UINT32 PayloadLength;
> +
> + Status = ScmiCommandGetPayload ((UINT32**)&ClockRateSetAttributes);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + // Fill arguments for clock protocol command.
> + ClockRateSetAttributes->ClockId = ClockId;
> + ClockRateSetAttributes->Flags = CLOCK_SET_DEFAULT_FLAGS;
> + ClockRateSetAttributes->Rate.Low = (UINT32)Rate;
> + ClockRateSetAttributes->Rate.High = (UINT32)(Rate >> 32);
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_SET;
> +
> + PayloadLength = sizeof (CLOCK_RATE_SET_ATTRIBUTES);
> +
> + // Execute and wait for response on a SCMI channel.
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + NULL
> + );
> +
> + return Status;
> +}
> +
> +// Instance of the SCMI clock management protocol.
> +STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol = {
> + ClockGetVersion,
> + ClockGetTotalClocks,
> + ClockGetClockAttributes,
> + ClockDescribeRates,
> + ClockRateGet,
> + ClockRateSet
> + };
> +
> +/** Initialize clock management protocol and install protocol on a given handle.
> +
> + @param[in] Handle Handle to install clock management protocol.
> +
> + @retval EFI_SUCCESS Clock protocol interface installed successfully.
> +**/
> +EFI_STATUS
> +ScmiClockProtocolInit (
> + IN EFI_HANDLE* Handle
> + )
> +{
> + return gBS->InstallMultipleProtocolInterfaces (
> + Handle,
> + &gArmScmiClockProtocolGuid,
> + &ScmiClockProtocol,
> + NULL
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..2920c6f6f33c5bb8ac00c903a0b199ba5f06f4de
> --- /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;
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..29cdde173659c701116b021a3c437a92b473e4e5
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> @@ -0,0 +1,41 @@
> +/** @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
> +**/
> +#ifndef SCMI_DXE_H_
> +#define SCMI_DXE_H_
> +
> +#define MAX_PROTOCOLS 6
> +#define PROTOCOL_ID_MASK 0xF
> +#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
> +
> +/** Pointer to protocol initialization function.
> +
> + @param[in] Handle A pointer to the EFI_HANDLE on which the protocol
> + interface is to be installed.
> +
> + @retval EFI_SUCCESS Protocol interface installed successfully.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PROTOCOL_INIT_FXN)(
> + IN EFI_HANDLE *Handle
> + );
> +
> +typedef struct {
> + SCMI_PROTOCOL_INIT_FXN Init;
> +} SCMI_PROTOCOL_INIT_TABLE;
> +
> +#endif /* SCMI_DXE_H_ */
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..ac32442ad838040721fd62faa806e82184f2b288
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> @@ -0,0 +1,457 @@
> +/** @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 <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/ArmScmiPerformanceProtocol.h>
> +#include <string.h>
> +
> +#include "ArmScmiPerformanceProtocolPrivate.h"
> +#include "ScmiPrivate.h"
> +
> +/** Return version of the performance management protocol supported by SCP.
> + firmware.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI performance management
> + protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceGetVersion (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT UINT32 *Version
> + )
> +{
> + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_PERFORMANCE, Version);
> +}
> +
> +/** Return protocol attributes of the performance management protocol.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> +
> + @param[out] Attributes Protocol attributes.
> +
> + @retval EFI_SUCCESS Protocol attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceGetAttributes (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
> + )
> +{
> + EFI_STATUS Status;
> + UINT32* ReturnValues;
> +
> + Status = ScmiGetProtocolAttributes (
> + SCMI_PROTOCOL_ID_PERFORMANCE,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + memcpy (
Urgh, missed this one on previous passes.
Surely this should be CopyMem?
> + Attributes,
> + ReturnValues,
> + sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return performance domain attributes.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Attributes Performance domain attributes.
> +
> + @retval EFI_SUCCESS Domain attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceDomainAttributes (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 *MessageParams;
> + UINT32 *ReturnValues;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES;
> +
> + PayloadLength = sizeof (DomainId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + memcpy (
CopyMem?
> + DomainAttributes,
> + ReturnValues,
> + sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
> + );
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return list of performance domain levels of a given domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] NumLevels Total number of levels a domain can support.
> +
> + @param[in,out] LevelArraySize Size of the performance level array.
> +
> + @param[out] LevelArray Array of the performance levels.
> +
> + @retval EFI_SUCCESS Domain levels are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +PerformanceDescribeLevels (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *NumLevels,
> + IN OUT UINT32 *LevelArraySize,
> + OUT SCMI_PERFORMANCE_LEVEL *LevelArray
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32* MessageParams;
> + UINT32 LevelIndex;
> + UINT32 RequiredSize;
> + UINT32 LevelNo;
> + UINT32 ReturnNumLevels;
> + UINT32 ReturnRemainNumLevels;
> +
> + PERF_DESCRIBE_LEVELS *Levels;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + LevelIndex = 0;
> + RequiredSize = 0;
> +
> + *MessageParams++ = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS;
> +
> + do {
> +
> + *MessageParams = LevelIndex;
> +
> + // Note, PayloadLength is an IN/OUT parameter.
> + PayloadLength = sizeof (DomainId) + sizeof (LevelIndex);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&Levels
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + ReturnNumLevels = NUM_PERF_LEVELS (Levels->NumLevels);
> + ReturnRemainNumLevels = NUM_REMAIN_PERF_LEVELS (Levels->NumLevels);
> +
> + if (RequiredSize == 0) {
> + *NumLevels = ReturnNumLevels + ReturnRemainNumLevels;
> +
> + RequiredSize = (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL);
> + if (RequiredSize > (*LevelArraySize)) {
> + // Update LevelArraySize with required size.
> + *LevelArraySize = RequiredSize;
> + return EFI_BUFFER_TOO_SMALL;
> + }
> + }
> +
> + for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
> + memcpy (
CopyMem?
/
Leif
> + &LevelArray[LevelIndex++],
> + &Levels->PerfLevel[LevelNo],
> + sizeof (SCMI_PERFORMANCE_LEVEL)
> + );
> + }
> +
> + } while (ReturnRemainNumLevels != 0);
> +
> + *LevelArraySize = RequiredSize;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Limit Performance limit to set.
> +
> + @retval EFI_SUCCESS Performance limits set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLimitsSet (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN SCMI_PERFORMANCE_LIMITS *Limits
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams++ = DomainId;
> + *MessageParams++ = Limits->RangeMax;
> + *MessageParams = Limits->RangeMin;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET;
> +
> + PayloadLength = sizeof (DomainId) + sizeof (SCMI_PERFORMANCE_LIMITS);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + NULL
> + );
> +
> + return Status;
> +}
> +
> +/** Get performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Limit Performance Limits of the domain.
> +
> + @retval EFI_SUCCESS Performance limits are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLimitsGet (
> + SCMI_PERFORMANCE_PROTOCOL *This,
> + UINT32 DomainId,
> + SCMI_PERFORMANCE_LIMITS *Limits
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> +
> + SCMI_PERFORMANCE_LIMITS *ReturnValues;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET;
> +
> + PayloadLength = sizeof (DomainId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + (UINT32**)&ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Limits->RangeMax = ReturnValues->RangeMax;
> + Limits->RangeMin = ReturnValues->RangeMin;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLevelSet (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN UINT32 Level
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *MessageParams;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams++ = DomainId;
> + *MessageParams = Level;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET;
> +
> + PayloadLength = sizeof (DomainId) + sizeof (Level);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + NULL
> + );
> +
> + return Status;
> +}
> +
> +/** Get performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level got successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +PerformanceLevelGet (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *Level
> + )
> +{
> + EFI_STATUS Status;
> + UINT32 PayloadLength;
> + SCMI_COMMAND Cmd;
> + UINT32 *ReturnValues;
> + UINT32 *MessageParams;
> +
> + Status = ScmiCommandGetPayload (&MessageParams);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *MessageParams = DomainId;
> +
> + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET;
> +
> + PayloadLength = sizeof (DomainId);
> +
> + Status = ScmiCommandExecute (
> + &Cmd,
> + &PayloadLength,
> + &ReturnValues
> + );
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + *Level = *ReturnValues;
> +
> + return EFI_SUCCESS;
> +}
> +
> +// Instance of the SCMI performance management protocol.
> +STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol = {
> + PerformanceGetVersion,
> + PerformanceGetAttributes,
> + PerformanceDomainAttributes,
> + PerformanceDescribeLevels,
> + PerformanceLimitsSet,
> + PerformanceLimitsGet,
> + PerformanceLevelSet,
> + PerformanceLevelGet
> +};
> +
> +/** Initialize performance management protocol and install on a given Handle.
> +
> + @param[in] Handle Handle to install performance management
> + protocol.
> +
> + @retval EFI_SUCCESS Performance protocol installed successfully.
> +**/
> +EFI_STATUS
> +ScmiPerformanceProtocolInit (
> + IN EFI_HANDLE* Handle
> + )
> +{
> + return gBS->InstallMultipleProtocolInterfaces (
> + Handle,
> + &gArmScmiPerformanceProtocolGuid,
> + &PerformanceProtocol,
> + NULL
> + );
> +}
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..df03655b8b021fe5fd63ceab0dd414906d2fb248
> --- /dev/null
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> @@ -0,0 +1,174 @@
> +/** @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
> +**/
> +#ifndef SCMI_PRIVATE_H_
> +#define SCMI_PRIVATE_H_
> +
> +// SCMI protocol IDs.
> +typedef enum {
> + SCMI_PROTOCOL_ID_BASE = 0x10,
> + SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
> + SCMI_PROTOCOL_ID_SYSTEM_POWER = 0x12,
> + SCMI_PROTOCOL_ID_PERFORMANCE = 0x13,
> + SCMI_PROTOCOL_ID_CLOCK = 0x14,
> + SCMI_PROTOCOL_ID_SENSOR = 0x15
> +} SCMI_PROTOCOL_ID;
> +
> +// SCMI message types.
> +typedef enum {
> + SCMI_MESSAGE_TYPE_COMMAND = 0,
> + SCMI_MESSAGE_TYPE_DELAYED_RESPONSE = 2, // Skipping 1 is deliberate.
> + SCMI_MESSAGE_TYPE_NOTIFICATION = 3
> +} SCMI_MESSAGE_TYPE;
> +
> +// SCMI response error codes.
> +typedef enum {
> + SCMI_SUCCESS = 0,
> + SCMI_NOT_SUPPORTED = -1,
> + SCMI_INVALID_PARAMETERS = -2,
> + SCMI_DENIED = -3,
> + SCMI_NOT_FOUND = -4,
> + SCMI_OUT_OF_RANGE = -5,
> + SCMI_BUSY = -6,
> + SCMI_COMMS_ERROR = -7,
> + SCMI_GENERIC_ERROR = -8,
> + SCMI_HARDWARE_ERROR = -9,
> + SCMI_PROTOCOL_ERROR = -10
> +} SCMI_STATUS;
> +
> +// SCMI message IDs common to all protocols.
> +typedef enum {
> + SCMI_MESSAGE_ID_PROTOCOL_VERSION = 0x0,
> + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES = 0x1,
> + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2
> +} SCMI_MESSAGE_ID;
> +
> +// Not defined in SCMI specification but will help to identify a message.
> +typedef struct {
> + SCMI_PROTOCOL_ID ProtocolId;
> + UINT32 MessageId;
> +} SCMI_COMMAND;
> +
> +#pragma pack(1)
> +
> +// Response to a SCMI command.
> +typedef struct {
> + INT32 Status;
> + UINT32 ReturnValues[];
> +} SCMI_MESSAGE_RESPONSE;
> +
> +// Message header. MsgId[7:0], MsgType[9:8], ProtocolId[17:10]
> +#define MESSAGE_TYPE_SHIFT 8
> +#define PROTOCOL_ID_SHIFT 10
> +#define SCMI_MESSAGE_HEADER(MsgId, MsgType, ProtocolId) ( \
> + MsgType << MESSAGE_TYPE_SHIFT | \
> + ProtocolId << PROTOCOL_ID_SHIFT | \
> + MsgId \
> + )
> +// SCMI message header.
> +typedef struct {
> + UINT32 MessageHeader;
> +} SCMI_MESSAGE_HEADER;
> +
> +#pragma pack()
> +
> +/** Return a pointer to the message payload.
> +
> + @param[out] Payload Holds pointer to the message payload.
> +
> + @retval EFI_SUCCESS Payload holds a valid message payload pointer.
> + @retval EFI_TIMEOUT Time out error if MTL channel is busy.
> + @retval EFI_UNSUPPORTED If MTL channel is unsupported.
> +**/
> +EFI_STATUS
> +ScmiCommandGetPayload (
> + OUT UINT32** Payload
> + );
> +
> +/** Execute a SCMI command and receive a response.
> +
> + This function uses a MTL channel to transfer message to SCP
> + and waits for a response.
> +
> + @param[in] Command Pointer to the SCMI command (Protocol ID
> + and Message ID)
> +
> + @param[in,out] PayloadLength SCMI command message length.
> +
> + @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
> +
> + @retval OUT EFI_SUCCESS Command sent and message received successfully.
> + @retval OUT EFI_UNSUPPORTED Channel not supported.
> + @retval OUT EFI_TIMEOUT Timeout on the channel.
> + @retval OUT EFI_DEVICE_ERROR Channel not ready.
> + @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
> + @retval OUT EFI_DEVICE_ERROR SCMI error.
> +**/
> +EFI_STATUS
> +ScmiCommandExecute (
> + IN SCMI_COMMAND *Command,
> + IN OUT UINT32 *PayloadLength,
> + OUT UINT32 **ReturnValues OPTIONAL
> + );
> +
> +/** Return protocol version from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] Version Pointer to version of the protocol.
> +
> + @retval EFI_SUCCESS Version holds a valid version received
> + from the SCP.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolVersion (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 *Version
> + );
> +
> +/** Return protocol attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> + @param[out] ReturnValues Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + );
> +
> +/** Return protocol message attributes from SCP for a given protocol ID.
> +
> + @param[in] Protocol ID Protocol ID.
> +
> + @param[out] Attributes Pointer to attributes of the protocol.
> +
> + @retval EFI_SUCCESS ReturnValues points to protocol message attributes.
> + @retval EFI_DEVICE_ERROR SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +EFI_STATUS
> +ScmiGetProtocolMessageAttributes (
> + IN SCMI_PROTOCOL_ID ProtocolId,
> + OUT UINT32 **ReturnValues
> + );
> +
> +#endif /* SCMI_PRIVATE_H_ */
> diff --git a/ArmPkg/Include/Protocol/ArmScmi.h b/ArmPkg/Include/Protocol/ArmScmi.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..239abb97064578c949614f79a6a33fe1881c3c68
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmi.h
> @@ -0,0 +1,27 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_H_
> +#define ARM_SCMI_H_
> +
> +/* As per SCMI specification, maximum allowed ASCII string length
> + for various return values/parameters of a SCMI message.
> +*/
> +#define SCMI_MAX_STR_LEN 16
> +
> +#endif /* ARM_SCMI_H_ */
> +
> diff --git a/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..ecc41f2181ecc9f835950ab46c7cfd2e476a7073
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> @@ -0,0 +1,174 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_BASE_PROTOCOL_H_
> +#define ARM_SCMI_BASE_PROTOCOL_H_
> +
> +#include <Protocol/ArmScmi.h>
> +
> +#define BASE_PROTOCOL_VERSION 0x10000
> +
> +#define NUM_PROTOCOL_MASK 0xFFU
> +#define NUM_AGENT_MASK 0xFFU
> +
> +#define NUM_AGENT_SHIFT 0x8
> +
> +/** Returns total number of protocols that are
> + implemented (excluding the Base protocol)
> +*/
> +#define SCMI_TOTAL_PROTOCOLS(Attr) (Attr & NUM_PROTOCOL_MASK)
> +
> +// Returns total number of agents in the system.
> +#define SCMI_TOTAL_AGENTS(Attr) ((Attr >> NUM_AGENT_SHIFT) & NUM_AGENT_MASK)
> +
> +#define ARM_SCMI_BASE_PROTOCOL_GUID { \
> + 0xd7e5abe9, 0x33ab, 0x418e, {0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f} \
> + }
> +
> +extern EFI_GUID gArmScmiBaseProtocolGuid;
> +
> +typedef struct _SCMI_BASE_PROTOCOL SCMI_BASE_PROTOCOL;
> +
> +/** Return version of the Base protocol supported by SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Base protocol.
> +
> + @retval EFI_SUCCESS The version of the protocol is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_GET_VERSION) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *Version
> + );
> +
> +/** Return total number of SCMI protocols supported by the SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] TotalProtocols Total number of SCMI protocols supported.
> +
> + @retval EFI_SUCCESS Total number of protocols supported are returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_GET_TOTAL_PROTOCOLS) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *TotalProtocols
> + );
> +
> +/** Return vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_VENDOR) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + );
> +
> +/** Return sub vendor name.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] VendorIdentifier Null terminated ASCII string of up to
> + 16 bytes with a vendor name.
> +
> + @retval EFI_SUCCESS VendorIdentifier is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_SUB_VENDOR) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> + );
> +
> +/** Return implementation version.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ImplementationVersion Vendor specific implementation version.
> +
> + @retval EFI_SUCCESS Implementation version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION) (
> + IN SCMI_BASE_PROTOCOL *This,
> + OUT UINT32 *ImplementationVersion
> + );
> +
> +/** Return list of protocols.
> +
> + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> +
> + @param[out] ProtocolListSize Size of the ProtocolList.
> +
> + @param[out] ProtocolList Protocol list.
> +
> + @retval EFI_SUCCESS List of protocols is returned.
> + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result.
> + It has been updated to the size needed.
> + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_BASE_DISCOVER_LIST_PROTOCOLS) (
> + IN SCMI_BASE_PROTOCOL *This,
> + IN OUT UINT32 *ProtocolListSize,
> + OUT UINT8 *ProtocolList
> + );
> +
> +// Base protocol.
> +typedef struct _SCMI_BASE_PROTOCOL {
> + SCMI_BASE_GET_VERSION GetVersion;
> + SCMI_BASE_GET_TOTAL_PROTOCOLS GetTotalProtocols;
> + SCMI_BASE_DISCOVER_VENDOR DiscoverVendor;
> + SCMI_BASE_DISCOVER_SUB_VENDOR DiscoverSubVendor;
> + SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION DiscoverImplementationVersion;
> + SCMI_BASE_DISCOVER_LIST_PROTOCOLS DiscoverListProtocols;
> +} SCMI_BASE_PROTOCOL;
> +
> +// SCMI Message IDs for Base protocol.
> +typedef enum {
> + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR = 0x3,
> + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR = 0x4,
> + SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION = 0x5,
> + SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS = 0x6
> +} SCMI_MESSAGE_ID_BASE;
> +
> +#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */
> +
> diff --git a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..3db26cb0641c7377c022a8e00be9a51ee5dc7361
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> @@ -0,0 +1,218 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_
> +#define ARM_SCMI_CLOCK_PROTOCOL_H_
> +
> +#include <Protocol/ArmScmi.h>
> +
> +#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \
> + 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa} \
> + }
> +
> +extern EFI_GUID gArmScmiClockProtocolGuid;
> +
> +// Message Type for clock management protocol.
> +typedef enum {
> + SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3,
> + SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4,
> + SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5,
> + SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6,
> + SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7
> +} SCMI_MESSAGE_ID_CLOCK;
> +
> +typedef enum {
> + SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range.
> + SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range.
> +} SCMI_CLOCK_RATE_FORMAT;
> +
> +// Clock management protocol version.
> +#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000
> +
> +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK 0xFFU
> +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16
> +#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU
> +
> +/** Total number of pending asynchronous clock rates changes
> + supported by the SCP, Attr Bits[23:16]
> +*/
> +#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr) ( \
> + (Attr >> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \
> + SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)
> +
> +// Total of clock devices supported by the SCP, Attr Bits[15:0]
> +#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr & SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)
> +
> +#pragma pack(1)
> +
> +/* Depending on the format (linear/non-linear) supported by a clock device
> + either Rate or Min/Max/Step triplet is valid.
> +*/
> +typedef struct {
> + union {
> + UINT64 Min;
> + UINT64 Rate;
> + };
> + UINT64 Max;
> + UINT64 Step;
> +} SCMI_CLOCK_RATE;
> +
> +#pragma pack()
> +
> +typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL;
> +
> +// Protocol Interface functions.
> +
> +/** Return version of the clock management protocol supported by SCP firmware.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI Clock management protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_GET_VERSION) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *Version
> + );
> +
> +/** Return total number of clock devices supported by the clock management
> + protocol.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +
> + @param[out] TotalClocks Total number of clocks supported.
> +
> + @retval EFI_SUCCESS Total number of clocks supported is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + OUT UINT32 *TotalClocks
> + );
> +
> +/** Return attributes of a clock device.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Enabled If TRUE, the clock device is enabled.
> + @param[out] ClockAsciiName A NULL terminated ASCII string with the clock
> + name, of up to 16 bytes.
> +
> + @retval EFI_SUCCESS Clock device attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT BOOLEAN *Enabled,
> + OUT CHAR8 *ClockAsciiName
> + );
> +
> +/** Return list of rates supported by a given clock device.
> +
> + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
> + supports range of clock rates which are non-linear.
> +
> + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
> + range of linear clock rates from Min to Max in steps.
> +
> + @param[out] TotalRates Total number of rates.
> +
> + @param[in,out] RateArraySize Size of the RateArray.
> +
> + @param[out] RateArray List of clock rates.
> +
> + @retval EFI_SUCCESS List of clock rates are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT SCMI_CLOCK_RATE_FORMAT *Format,
> + OUT UINT32 *TotalRates,
> + IN OUT UINT32 *RateArraySize,
> + OUT SCMI_CLOCK_RATE *RateArray
> + );
> +
> +/** Get clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> +
> + @param[out] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_RATE_GET) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + OUT UINT64 *Rate
> + );
> +
> +/** Set clock rate.
> +
> + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> + @param[in] ClockId Identifier for the clock device.
> + @param[in] Rate Clock rate.
> +
> + @retval EFI_SUCCESS Clock rate set success.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_CLOCK_RATE_SET) (
> + IN SCMI_CLOCK_PROTOCOL *This,
> + IN UINT32 ClockId,
> + IN UINT64 Rate
> + );
> +
> +typedef struct _SCMI_CLOCK_PROTOCOL {
> + SCMI_CLOCK_GET_VERSION GetVersion;
> + SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks;
> + SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes;
> + SCMI_CLOCK_DESCRIBE_RATES DescribeRates;
> + SCMI_CLOCK_RATE_GET RateGet;
> + SCMI_CLOCK_RATE_SET RateSet;
> +} SCMI_CLOCK_PROTOCOL;
> +
> +#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */
> +
> diff --git a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..1d1af6f8bee0c00bbe6b4774036c87c988a4f4af
> --- /dev/null
> +++ b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> @@ -0,0 +1,265 @@
> +/** @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
> +**/
> +
> +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
> +#define ARM_SCMI_PERFORMANCE_PROTOCOL_H_
> +
> +#include <Protocol/ArmScmi.h>
> +
> +#define PERFORMANCE_PROTOCOL_VERSION 0x10000
> +
> +#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \
> + 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad} \
> + }
> +
> +extern EFI_GUID gArmScmiPerformanceProtocolGuid;
> +
> +typedef struct _SCMI_PERFORMANCE_PROTOCOL SCMI_PERFORMANCE_PROTOCOL;
> +
> +#pragma pack(1)
> +
> +#define POWER_IN_MW_SHIFT 16
> +#define POWER_IN_MW_MASK 0x1
> +#define NUM_PERF_DOMAINS_MASK 0xFFFF
> +
> +// Total number of performance domains, Attr Bits [15:0]
> +#define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr & NUM_PERF_DOMAINS_MASK)
> +
> +// A flag to express power values in mW or platform specific way, Attr Bit [16]
> +#define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >> POWER_IN_MW_SHIFT) & \
> + POWER_IN_MW_MASK)
> +
> +// Performance protocol attributes return values.
> +typedef struct {
> + UINT32 Attributes;
> + UINT64 StatisticsAddress;
> + UINT32 StatisticsLen;
> +} SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES;
> +
> +#define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28) & 0x1)
> +#define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29) & 0x1)
> +#define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1)
> +#define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1)
> +#define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF)
> +
> +// Performance protocol domain attributes.
> +typedef struct {
> + UINT32 Attributes;
> + UINT32 RateLimit;
> + UINT32 SustainedFreq;
> + UINT32 SustainedPerfLevel;
> + UINT8 Name[SCMI_MAX_STR_LEN];
> +} SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES;
> +
> +// Worst case latency in microseconds, Bits[15:0]
> +#define PERF_LATENCY_MASK 0xFFFF
> +#define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency & PERF_LATENCY_MASK)
> +
> +// Performance protocol performance level.
> +typedef struct {
> + UINT32 Level;
> + UINT32 PowerCost;
> + UINT32 Latency;
> +} SCMI_PERFORMANCE_LEVEL;
> +
> +// Performance protocol performance limit.
> +typedef struct {
> + UINT32 RangeMax;
> + UINT32 RangeMin;
> +} SCMI_PERFORMANCE_LIMITS;
> +
> +#pragma pack()
> +
> +/** Return version of the performance management protocol supported by SCP.
> + firmware.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> +
> + @param[out] Version Version of the supported SCMI performance management
> + protocol.
> +
> + @retval EFI_SUCCESS The version is returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_GET_VERSION) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT UINT32 *Version
> + );
> +
> +/** Return protocol attributes of the performance management protocol.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> +
> + @param[out] Attributes Protocol attributes.
> +
> + @retval EFI_SUCCESS Protocol attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
> +
> + );
> +
> +/** Return performance domain attributes.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Attributes Performance domain attributes.
> +
> + @retval EFI_SUCCESS Domain attributes are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
> + );
> +
> +/** Return list of performance domain levels of a given domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] NumLevels Total number of levels a domain can support.
> +
> + @param[in,out] LevelArraySize Size of the performance level array.
> +
> + @param[out] LevelArray Array of the performance levels.
> +
> + @retval EFI_SUCCESS Domain levels are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
> + It has been updated to the size needed.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *NumLevels,
> + IN OUT UINT32 *LevelArraySize,
> + OUT SCMI_PERFORMANCE_LEVEL *LevelArray
> + );
> +
> +/** Set performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Limit Performance limit to set.
> +
> + @retval EFI_SUCCESS Performance limits set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN SCMI_PERFORMANCE_LIMITS *Limits
> + );
> +
> +/** Get performance limits of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Limit Performance Limits of the domain.
> +
> + @retval EFI_SUCCESS Performance limits are returned.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) (
> + SCMI_PERFORMANCE_PROTOCOL *This,
> + UINT32 DomainId,
> + SCMI_PERFORMANCE_LIMITS *Limits
> + );
> +
> +/** Set performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> + @param[in] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level set successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + IN UINT32 Level
> + );
> +
> +/** Get performance level of a domain.
> +
> + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
> + @param[in] DomainId Identifier for the performance domain.
> +
> + @param[out] Level Performance level of the domain.
> +
> + @retval EFI_SUCCESS Performance level got successfully.
> + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> + @retval !(EFI_SUCCESS) Other errors.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) (
> + IN SCMI_PERFORMANCE_PROTOCOL *This,
> + IN UINT32 DomainId,
> + OUT UINT32 *Level
> + );
> +
> +typedef struct _SCMI_PERFORMANCE_PROTOCOL {
> + SCMI_PERFORMANCE_GET_VERSION GetVersion;
> + SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes;
> + SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES GetDomainAttributes;
> + SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels;
> + SCMI_PERFORMANCE_LIMITS_SET LimitsSet;
> + SCMI_PERFORMANCE_LIMITS_GET LimitsGet;
> + SCMI_PERFORMANCE_LEVEL_SET LevelSet;
> + SCMI_PERFORMANCE_LEVEL_GET LevelGet;
> +} SCMI_PERFORMANCE_PROTOCOL;
> +
> +typedef enum {
> + SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3,
> + SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4,
> + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5,
> + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6,
> + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7,
> + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8,
> +} SCMI_MESSAGE_ID_PERFORMANCE;
> +
> +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
> +
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
2018-04-23 11:31 ` Leif Lindholm
@ 2018-04-23 16:06 ` Girish Pathak
2018-04-23 16:22 ` Leif Lindholm
0 siblings, 1 reply; 40+ messages in thread
From: Girish Pathak @ 2018-04-23 16:06 UTC (permalink / raw)
To: Leif Lindholm
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org,
Matteo Carlini, Stephanie Hughes-Fitt, nd
Hi Leif,
> -----Original Message-----
> From: Leif Lindholm <leif.lindholm@linaro.org>
> Sent: 23 April 2018 12:32
> To: Girish Pathak <Girish.Pathak@arm.com>
> Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org; Matteo Carlini
> <Matteo.Carlini@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; nd <nd@arm.com>
> Subject: Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
>
> Hmm, I did find a few minor things below that I need to hear back on
> before pushing.
Thanks for your comments, We can incorporate all the changes suggested, shall I tidy this up and resubmit the patch series ?
Regards,
Girish
>
> On Tue, Mar 20, 2018 at 04:12:12PM +0000, Girish Pathak wrote:
> > 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>
> > ---
> >
> > Notes:
> > v3:
> > - Please rename ArmMtl.h to ArmMtlLibi.h, and
> > declare it as a library class in the package file. [Ard]
> >
> > Done, however ArmMtlLib.h is now part of earlier commit [Girish]
> >
> > - Move ArmScmiDxe to ArmPkg from ArmPlatformPkg [Ard]
> >
> > Done [Girish]
> >
> > - Declare gArmScmiBaseProtocolGuid and similar
> > protocols Guids in ArmPkg.dec [Ard]
> >
> > Done [Girish]
> >
> > - Replace flexible array member [] with [1] [Ard]
> >
> > Done [Girish]
> >
> > - Move protocol init function which are not part of
> > of protocol like ScmiBaseProtocolInit elsewhere [Ard]
> >
> > Done [Girish]
> >
> > - Please don't put stuff in Include/Drivers. [Ard]
> >
> > Moved headers to Include/Protocol. [Girish]
> >
> > ArmPkg/ArmPkg.dec | 13 +
> > ArmPkg/ArmPkg.dsc | 6 +-
> > ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h | 46 ++
> > ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 84
> ++++
> > ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf | 53 +++
> > ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h |
> 55 +++
> > ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 262 +++++++++++
> > ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c | 318
> ++++++++++++++
> > ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 418
> ++++++++++++++++++
> > ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 138 ++++++
> > ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 41 ++
> > ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 457
> ++++++++++++++++++++
> > ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h | 174 ++++++++
> > ArmPkg/Include/Protocol/ArmScmi.h | 27 ++
> > ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h | 174
> ++++++++
> > ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 218
> ++++++++++
> > ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h | 265
> ++++++++++++
> > 17 files changed, 2748 insertions(+), 1 deletion(-)
> >
> > diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> > index
> 881751d81c6384a3eb0b4c180c76d01a58266a74..16f7e40046429142b44b52604
> 3b61a3d5e089d2c 100644
> > --- a/ArmPkg/ArmPkg.dec
> > +++ b/ArmPkg/ArmPkg.dec
> > @@ -51,6 +51,19 @@ [Guids.common]
> >
> > gArmGicDxeFileGuid = { 0xde371f7c, 0xdec4, 0x4d21, { 0xad, 0xf1, 0x59,
> 0x3a, 0xbc, 0xc1, 0x58, 0x82 } }
> >
> > +[Protocols.common]
> > + ## Arm System Control and Management Interface(SCMI) Base protocol
> > + ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> > + gArmScmiBaseProtocolGuid = { 0xd7e5abe9, 0x33ab, 0x418e, { 0x9f, 0x91,
> 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } }
> > +
> > + ## Arm System Control and Management Interface(SCMI) Clock
> management protocol
> > + ## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> > + gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, 0x9f,
> 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
> > +
> > + ## Arm System Control and Management Interface(SCMI) Clock
> management protocol
> > + ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> > + gArmScmiPerformanceProtocolGuid = { 0x9b8ba84, 0x3dd3, 0x49a6,
> { 0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } }
> > +
> > [Ppis]
> > ## Include/Ppi/ArmMpCoreInfo.h
> > gArmMpCoreInfoPpiGuid = { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d,
> 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} }
> > diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> > index
> 526909458e0d80dbc5a65c8ad12ec1095dda48d2..22332090db7111e0668607a1
> 6288cefc1bace926 100644
> > --- a/ArmPkg/ArmPkg.dsc
> > +++ b/ArmPkg/ArmPkg.dsc
> > @@ -2,7 +2,7 @@
> > # ARM processor package.
> > #
> > # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
> > -# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
> > +# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
> > # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
> > #
> > # This program and the accompanying materials
> > @@ -87,6 +87,8 @@ [LibraryClasses.common]
> > ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
> > ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> >
> > + ArmMtlLib|ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> > +
> > [LibraryClasses.common.PEIM]
> > HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> > PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
> > @@ -144,5 +146,7 @@ [Components.common]
> >
> ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> > ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> >
> > + ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > +
> > [Components.AARCH64]
> > ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..79c057d44128008ec276e3d58
> d8f1098c6a779b2
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> > @@ -0,0 +1,46 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> > +#define ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
> > +
> > +// Return values of BASE_DISCOVER_LIST_PROTOCOLS command.
> > +typedef struct {
> > + UINT32 NumProtocols;
> > +
> > + // Array of four protocols in each element
> > + // Total elements = 1 + (NumProtocols-1)/4
> > +
> > + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> > + // here array of 1 element length. However below is used as a variable
> > + // length array.
> > + UINT8 Protocols[1];
> > +} BASE_DISCOVER_LIST;
> > +
> > +/** Initialize Base protocol and install protocol on a given handle.
> > +
> > + @param[in] Handle Handle to install Base protocol.
> > +
> > + @retval EFI_SUCCESS Base protocol interface installed
> > + successfully.
> > +**/
> > +EFI_STATUS
> > +ScmiBaseProtocolInit (
> > + IN OUT EFI_HANDLE* Handle
> > + );
> > +
> > +#endif /* ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_ */
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..71245c16475d4d38d6dc66571
> b3fe3520c1cf1da
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > @@ -0,0 +1,84 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
> > +#define ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
> > +
> > +#pragma pack(1)
> > +
> > +// Clock rate in two 32bit words.
> > +typedef struct {
> > + UINT32 Low;
> > + UINT32 High;
> > +} CLOCK_RATE_DWORD;
> > +
> > +// Format of the returned rate array. Linear or Non-linear,.RatesFlag Bit[12]
> > +#define RATE_FORMAT_SHIFT 12
> > +#define RATE_FORMAT_MASK 0x0001
> > +#define RATE_FORMAT(RatesFlags) ((RatesFlags >>
> RATE_FORMAT_SHIFT) \
> > + & RATE_FORMAT_MASK)
>
> I'll decrease indentation of above line by one unless someone objects?
>
> > +
> > +// Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
> > +#define NUM_REMAIN_RATES_SHIFT 16
> > +#define NUM_REMAIN_RATES(RatesFlags) ((RatesFlags >>
> NUM_REMAIN_RATES_SHIFT))
> > +
> > +// Number of rates that are returned by a call.to the SCP, RatesFlag
> Bits[11:0]
> > +#define NUM_RATES_MASK 0x0FFF
> > +#define NUM_RATES(RatesFlags) (RatesFlags & NUM_RATES_MASK)
> > +
> > +// Return values for the CLOCK_DESCRIBER_RATE command.
> > +typedef struct {
> > + UINT32 NumRatesFlags;
> > +
> > + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> > + // here array of 1 element length. However below is used as a variable
> > + // length array.
> > + CLOCK_RATE_DWORD Rates[1];
> > +} CLOCK_DESCRIBE_RATES;
> > +
> > +#define CLOCK_SET_DEFAULT_FLAGS 0
> > +
> > +// Message parameters for CLOCK_RATE_SET command.
> > +typedef struct {
> > + UINT32 Flags;
> > + UINT32 ClockId;
> > + CLOCK_RATE_DWORD Rate;
> > +} CLOCK_RATE_SET_ATTRIBUTES;
> > +
> > +// if ClockAttr Bit[0] is set then clock device is enabled.
> > +#define CLOCK_ENABLE_MASK 0x1
> > +#define CLOCK_ENABLED(ClockAttr) ((ClockAttr & CLOCK_ENABLE_MASK)
> == 1)
> > +
> > +typedef struct {
> > + UINT32 Attributes;
> > + UINT8 ClockName[SCMI_MAX_STR_LEN];
> > +} CLOCK_ATTRIBUTES;
> > +
> > +#pragma pack()
> > +
> > +/** Initialize clock management protocol and install protocol on a given
> handle.
> > +
> > + @param[in] Handle Handle to install clock management protocol.
> > +
> > + @retval EFI_SUCCESS Clock protocol interface installed successfully.
> > +**/
> > +EFI_STATUS
> > +ScmiClockProtocolInit (
> > + IN EFI_HANDLE *Handle
> > + );
> > +
> > +#endif /* ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_ */
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..05ce9c04ce468d74e5c6d3873
> 9f9056f3fc48694
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > @@ -0,0 +1,53 @@
> > +#/** @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
> > +#**/
> > +
> > +[Defines]
> > + INF_VERSION = 0x00010019
> > + BASE_NAME = ArmScmiDxe
> > + FILE_GUID = 9585984C-F027-45E9-AFDF-ADAA6DFAAAC7
> > + MODULE_TYPE = DXE_DRIVER
> > + VERSION_STRING = 1.0
> > + ENTRY_POINT = ArmScmiDxeEntryPoint
> > +
> > +[Sources.common]
> > + Scmi.c
> > + ScmiBaseProtocol.c
> > + ScmiClockProtocol.c
> > + ScmiDxe.c
> > + ScmiPerformanceProtocol.c
> > +
> > +[Packages]
> > + ArmPkg/ArmPkg.dec
> > + ArmPlatformPkg/ArmPlatformPkg.dec
> > + MdePkg/MdePkg.dec
> > +
> > +[LibraryClasses]
> > + ArmLib
> > + ArmMtlLib
> > + DebugLib
> > + IoLib
> > + UefiBootServicesTableLib
> > + UefiDriverEntryPoint
> > +
> > +[Protocols]
> > + gArmScmiBaseProtocolGuid
> > + gArmScmiClockProtocolGuid
> > + gArmScmiPerformanceProtocolGuid
> > +
> > +[Depex]
> > + TRUE
> > +
> > diff --git
> a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..4514f45a9f5dd960d2844a19b5
> 7a91b93149f1b9
> > --- /dev/null
> > +++
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> > @@ -0,0 +1,55 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
> > +#define ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
> > +
> > +#include <Protocol/ArmScmiPerformanceProtocol.h>
> > +
> > +// Number of performance levels returned by a call to the SCP, Lvls
> Bits[11:0]
> > +#define NUM_PERF_LEVELS_MASK 0x0FFF
> > +#define NUM_PERF_LEVELS(Lvls) (Lvls & NUM_PERF_LEVELS_MASK)
> > +
> > +// Number of performance levels remaining after a call to the SCP, Lvls
> Bits[31:16]
> > +#define NUM_REMAIN_PERF_LEVELS_SHIFT 16
> > +#define NUM_REMAIN_PERF_LEVELS(Lvls) (Lvls >>
> NUM_REMAIN_PERF_LEVELS_SHIFT)
> > +
> > +/** Return values for
> SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS command.
> > + SCMI Spec ? 4.5.2.5
> > +**/
> > +typedef struct {
> > + UINT32 NumLevels;
> > +
> > + // NOTE: Since EDK2 does not allow flexible array member [] we declare
> > + // here array of 1 element length. However below is used as a variable
> > + // length array.
> > + SCMI_PERFORMANCE_LEVEL PerfLevel[1]; // Offset to array of
> performance levels
> > +} PERF_DESCRIBE_LEVELS;
> > +
> > +/** Initialize performance management protocol and install on a given
> Handle.
> > +
> > + @param[in] Handle Handle to install performance management
> > + protocol.
> > +
> > + @retval EFI_SUCCESS Performance protocol installed successfully.
> > +**/
> > +EFI_STATUS
> > +ScmiPerformanceProtocolInit (
> > + IN EFI_HANDLE* Handle
> > + );
> > +
> > +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_ */
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..1e279f69cf615428dbb6477b8a
> c7de3258628df3
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> > @@ -0,0 +1,262 @@
> > +/** @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 <Library/ArmMtlLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/MemoryAllocationLib.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +
> > +#include "ScmiPrivate.h"
> > +
> > +// SCMI Specification 1.0
> > +#define MAX_PROTOCOLS 6
> > +
> > +#define PROTOCOL_MASK 0xF
> > +
> > +// Arbitrary timeout value 20ms.
> > +#define RESPONSE_TIMEOUT 20000
> > +
> > +/** Return a pointer to the message payload.
> > +
> > + @param[out] Payload Holds pointer to the message payload.
> > +
> > + @retval EFI_SUCCESS Payload holds a valid message payload pointer.
> > + @retval EFI_TIMEOUT Time out error if MTL channel is busy.
> > + @retval EFI_UNSUPPORTED If MTL channel is unsupported.
> > +**/
> > +EFI_STATUS
> > +ScmiCommandGetPayload (
> > + OUT UINT32** Payload
> > + )
> > +{
> > + EFI_STATUS Status;
> > + MTL_CHANNEL *Channel;
> > +
> > + // Get handle to the Channel.
> > + Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // Payload will not be populated until channel is free.
> > + Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // Get the address of the payload.
> > + *Payload = MtlGetChannelPayload (Channel);
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Execute a SCMI command and receive a response.
> > +
> > + This function uses a MTL channel to transfer message to SCP
> > + and waits for a response.
> > +
> > + @param[in] Command Pointer to the SCMI command (Protocol ID
> > + and Message ID)
> > +
> > + @param[in,out] PayloadLength SCMI command message length.
> > +
> > + @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
> > +
> > + @retval OUT EFI_SUCCESS Command sent and message received
> successfully.
> > + @retval OUT EFI_UNSUPPORTED Channel not supported.
> > + @retval OUT EFI_TIMEOUT Timeout on the channel.
> > + @retval OUT EFI_DEVICE_ERROR Channel not ready.
> > + @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
> > + @retval OUT EFI_DEVICE_ERROR SCMI error.
> > +**/
> > +EFI_STATUS
> > +ScmiCommandExecute (
> > + IN SCMI_COMMAND *Command,
> > + IN OUT UINT32 *PayloadLength,
> > + OUT UINT32 **ReturnValues OPTIONAL
> > + )
> > +{
> > + EFI_STATUS Status;
> > + SCMI_MESSAGE_RESPONSE *Response;
> > + UINT32 MessageHeader;
> > + UINT32 ResponseHeader;
> > + MTL_CHANNEL *Channel;
> > +
> > + ASSERT (PayloadLength != NULL);
> > +
> > + Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // Fill in message header.
> > + MessageHeader = SCMI_MESSAGE_HEADER (
> > + Command->MessageId,
> > + SCMI_MESSAGE_TYPE_COMMAND,
> > + Command->ProtocolId
> > + );
> > +
> > + // Send payload using MTL channel.
> > + Status = MtlSendMessage (
> > + Channel,
> > + MessageHeader,
> > + *PayloadLength
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // Wait for the response on the channel.
> > + Status = MtlReceiveMessage (Channel, &ResponseHeader,
> PayloadLength);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // SCMI must return MessageHeader unmodified.
> > + if (MessageHeader != ResponseHeader) {
> > + ASSERT (FALSE);
> > + return EFI_DEVICE_ERROR;
> > + }
> > +
> > + Response = (SCMI_MESSAGE_RESPONSE*)MtlGetChannelPayload
> (Channel);
> > +
> > + if (Response->Status != SCMI_SUCCESS) {
> > + DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId = 0x%x, MessageId =
> 0x%x, error = %d\n",
> > + Command->ProtocolId,
> > + Command->MessageId,
> > + Response->Status
> > + ));
> > +
> > + ASSERT (FALSE);
> > + return EFI_DEVICE_ERROR;
> > + }
> > +
> > + if (ReturnValues != NULL) {
> > + *ReturnValues = Response->ReturnValues;
> > + }
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Internal common function useful for common protocol discovery
> messages.
> > +
> > + @param[in] ProtocolId Protocol Id of the the protocol.
> > + @param[in] MesaageId Message Id of the message.
> > +
> > + @param[out] ReturnValues SCMI response return values.
> > +
> > + @retval EFI_SUCCESS Success with valid return values.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ScmiProtocolDiscoveryCommon (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + IN SCMI_MESSAGE_ID MessageId,
> > + OUT UINT32 **ReturnValues
> > + )
> > +{
> > + SCMI_COMMAND Command;
> > + UINT32 PayloadLength = 0;
> > +
> > + Command.ProtocolId = ProtocolId;
> > + Command.MessageId = MessageId;
> > +
> > + return ScmiCommandExecute (
> > + &Command,
> > + &PayloadLength,
> > + ReturnValues
> > + );
> > +}
> > +
> > +/** Return protocol version from SCP for a given protocol ID.
> > +
> > + @param[in] Protocol ID Protocol ID.
> > + @param[out] Version Pointer to version of the protocol.
> > +
> > + @retval EFI_SUCCESS Version holds a valid version received
> > + from the SCP.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +ScmiGetProtocolVersion (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + OUT UINT32 *Version
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 *ProtocolVersion;
> > +
> > + Status = ScmiProtocolDiscoveryCommon (
> > + ProtocolId,
> > + SCMI_MESSAGE_ID_PROTOCOL_VERSION,
> > + (UINT32**)&ProtocolVersion
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *Version = *ProtocolVersion;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return protocol attributes from SCP for a given protocol ID.
> > +
> > + @param[in] Protocol ID Protocol ID.
> > + @param[out] ReturnValues Pointer to attributes of the protocol.
> > +
> > + @retval EFI_SUCCESS ReturnValues points to protocol attributes.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +ScmiGetProtocolAttributes (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + OUT UINT32 **ReturnValues
> > + )
> > +{
> > + return ScmiProtocolDiscoveryCommon (
> > + ProtocolId,
> > + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES,
> > + ReturnValues
> > + );
> > +}
> > +
> > +/** Return protocol message attributes from SCP for a given protocol ID.
> > +
> > + @param[in] Protocol ID Protocol ID.
> > + @param[out] Attributes Pointer to attributes of the protocol.
> > +
> > + @retval EFI_SUCCESS ReturnValues points to protocol message
> attributes.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +ScmiGetProtocolMessageAttributes (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + OUT UINT32 **ReturnValues
> > + )
> > +{
> > + return ScmiProtocolDiscoveryCommon (
> > + ProtocolId,
> > + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES,
> > + ReturnValues
> > + );
> > +}
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..0829438c82ec5723cfbbf9c411
> d10fcf22a22d89
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> > @@ -0,0 +1,318 @@
> > +/** @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 <Library/BaseLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +#include <Protocol/ArmScmiBaseProtocol.h>
> > +
> > +#include "ArmScmiBaseProtocolPrivate.h"
> > +#include "ScmiPrivate.h"
> > +
> > +/** Return version of the Base protocol supported by SCP firmware.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] Version Version of the supported SCMI Base protocol.
> > +
> > + @retval EFI_SUCCESS The version of the protocol is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +BaseGetVersion (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT32 *Version
> > + )
> > +{
> > + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_BASE, Version);
> > +}
> > +
> > +/** Return total number of SCMI protocols supported by the SCP
> firmware.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] TotalProtocols Total number of SCMI protocols supported.
> > +
> > + @retval EFI_SUCCESS Total number of protocols supported are
> returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +BaseGetTotalProtocols (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT32 *TotalProtocols
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 *ReturnValues;
> > +
> > + Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_BASE,
> &ReturnValues);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *TotalProtocols = SCMI_TOTAL_PROTOCOLS (ReturnValues[0]);
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Common function which returns vendor details.
> > +
> > + @param[in] MessageId
> SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR
> > + OR
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR
> > +
> > + @param[out] VendorIdentifier ASCII name of the vendor/subvendor.
> > +
> > + @retval EFI_SUCCESS VendorIdentifier is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +BaseDiscoverVendorDetails (
> > + IN SCMI_MESSAGE_ID_BASE MessageId,
> > + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 *ReturnValues;
> > + SCMI_COMMAND Cmd;
> > + UINT32 PayloadLength;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> > + Cmd.MessageId = MessageId;
> > +
> > + PayloadLength = 0;
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + &ReturnValues
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + AsciiStrCpyS (
> > + (CHAR8*)VendorIdentifier,
> > + SCMI_MAX_STR_LEN,
> > + (CONST CHAR8*)ReturnValues
> > + );
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return vendor name.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] VendorIdentifier Null terminated ASCII string of up to
> > + 16 bytes with a vendor name.
> > +
> > + @retval EFI_SUCCESS VendorIdentifier is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +BaseDiscoverVendor (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> > + )
> > +{
> > + return BaseDiscoverVendorDetails (
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR,
> > + VendorIdentifier
> > + );
> > +}
> > +
> > +/** Return sub vendor name.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] VendorIdentifier Null terminated ASCII string of up to
> > + 16 bytes with a sub vendor name.
> > +
> > + @retval EFI_SUCCESS VendorIdentifier is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +BaseDiscoverSubVendor (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> > + )
> > +{
> > + return BaseDiscoverVendorDetails (
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR,
> > + VendorIdentifier
> > + );
> > +}
> > +
> > +/** Return implementation version.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] ImplementationVersion Vendor specific implementation
> version.
> > +
> > + @retval EFI_SUCCESS Implementation version is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +BaseDiscoverImplVersion (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT32 *ImplementationVersion
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 *ReturnValues;
> > + SCMI_COMMAND Cmd;
> > + UINT32 PayloadLength;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> > + Cmd.MessageId =
> SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION;
> > +
> > + PayloadLength = 0;
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + &ReturnValues
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *ImplementationVersion = ReturnValues[0];
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return list of protocols.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] ProtocolListSize Size of the ProtocolList.
> > +
> > + @param[out] ProtocolList Protocol list.
> > +
> > + @retval EFI_SUCCESS List of protocols is returned.
> > + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the
> result.
> > + It has been updated to the size needed.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +BaseDiscoverListProtocols (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + IN OUT UINT32 *ProtocolListSize,
> > + OUT UINT8 *ProtocolList
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 TotalProtocols;
> > + UINT32 *MessageParams;
> > + BASE_DISCOVER_LIST *DiscoverList;
> > + UINT32 Skip;
> > + UINT32 Index;
> > + SCMI_COMMAND Cmd;
> > + UINT32 PayloadLength;
> > + UINT32 RequiredSize;
> > +
> > + Status = BaseGetTotalProtocols (This, &TotalProtocols);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + RequiredSize = sizeof (UINT8) * TotalProtocols;
> > + if (*ProtocolListSize < RequiredSize) {
> > + *ProtocolListSize = RequiredSize;
> > + return EFI_BUFFER_TOO_SMALL;
> > + }
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
> > + Cmd.MessageId =
> SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS;
> > +
> > + Skip = 0;
> > +
> > + while (Skip < TotalProtocols) {
> > +
> > + *MessageParams = Skip;
> > +
> > + // Note PayloadLength is a IN/OUT parameter.
> > + PayloadLength = sizeof (Skip);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + (UINT32**)&DiscoverList
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + for (Index = 0; Index < DiscoverList->NumProtocols; Index++) {
> > + ProtocolList[Skip++] = DiscoverList->Protocols[Index];
> > + }
> > + }
> > +
> > + *ProtocolListSize = RequiredSize;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +// Instance of the SCMI Base protocol.
> > +STATIC CONST SCMI_BASE_PROTOCOL BaseProtocol = {
> > + BaseGetVersion,
> > + BaseGetTotalProtocols,
> > + BaseDiscoverVendor,
> > + BaseDiscoverSubVendor,
> > + BaseDiscoverImplVersion,
> > + BaseDiscoverListProtocols
> > +};
> > +
> > +/** Initialize Base protocol and install protocol on a given handle.
> > +
> > + @param[in] Handle Handle to install Base protocol.
> > +
> > + @retval EFI_SUCCESS Base protocol interface installed
> > + successfully.
> > +**/
> > +EFI_STATUS
> > +ScmiBaseProtocolInit (
> > + IN OUT EFI_HANDLE* Handle
> > + )
> > +{
> > + return gBS->InstallMultipleProtocolInterfaces (
> > + Handle,
> > + &gArmScmiBaseProtocolGuid,
> > + &BaseProtocol,
> > + NULL
> > + );
> > +}
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..fe7edd2a8c8b7761fb3008e66
> d192ef1ee1ade2e
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> > @@ -0,0 +1,418 @@
> > +/** @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 <Library/BaseLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +#include <Protocol/ArmScmiClockProtocol.h>
> > +
> > +#include "ArmScmiClockProtocolPrivate.h"
> > +#include "ScmiPrivate.h"
> > +
> > +/** Convert to 64 bit value from two 32 bit words.
> > +
> > + @param[in] Low Lower 32 bits.
> > + @param[in] High Higher 32 bits.
> > +
> > + @retval UINT64 64 bit value.
> > +**/
> > +STATIC
> > +UINT64
> > +ConvertTo64Bit (
> > + IN UINT32 Low,
> > + IN UINT32 High
> > + )
> > +{
> > + return (Low | ((UINT64)High << 32));
> > +}
>
> Suggestion for future improvement: make this a macro in Base.h
> The SIGNATURE_64 macro in there would already benefit from it.
>
> > +
> > +/** Return version of the clock management protocol supported by SCP
> firmware.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > +
> > + @param[out] Version Version of the supported SCMI Clock
> management protocol.
> > +
> > + @retval EFI_SUCCESS The version is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockGetVersion (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + OUT UINT32 *Version
> > + )
> > +{
> > + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_CLOCK, Version);
> > +}
> > +
> > +/** Return total number of clock devices supported by the clock
> management
> > + protocol.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > +
> > + @param[out] TotalClocks Total number of clocks supported.
> > +
> > + @retval EFI_SUCCESS Total number of clocks supported is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockGetTotalClocks (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + OUT UINT32 *TotalClocks
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 *ReturnValues;
> > +
> > + Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK,
> &ReturnValues);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
>
> Missing space (will add before committing).
>
> > + }
> > +
> > + *TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return attributes of a clock device.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > +
> > + @param[out] Enabled If TRUE, the clock device is enabled.
> > + @param[out] ClockAsciiName A NULL terminated ASCII string with the
> clock
> > + name, of up to 16 bytes.
> > +
> > + @retval EFI_SUCCESS Clock device attributes are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockGetClockAttributes (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + OUT BOOLEAN *Enabled,
> > + OUT CHAR8 *ClockAsciiName
> > + )
> > +{
> > + EFI_STATUS Status;
> > +
> > + UINT32 *MessageParams;
> > + CLOCK_ATTRIBUTES *ClockAttributes;
> > + SCMI_COMMAND Cmd;
> > + UINT32 PayloadLength;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *MessageParams = ClockId;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES;
> > +
> > + PayloadLength = sizeof (ClockId);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + (UINT32**)&ClockAttributes
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > + // TRUE if bit 0 of ClockAttributes->Attributes is set.
> > + *Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
> > +
> > + AsciiStrCpyS (
> > + ClockAsciiName,
> > + SCMI_MAX_STR_LEN,
> > + (CONST CHAR8*)ClockAttributes->ClockName
> > + );
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return list of rates supported by a given clock device.
> > +
> > + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > +
> > + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock
> device
> > + supports range of clock rates which are non-linear.
> > +
> > + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
> > + range of linear clock rates from Min to Max in steps.
> > +
> > + @param[out] TotalRates Total number of rates.
> > +
> > + @param[in,out] RateArraySize Size of the RateArray.
> > +
> > + @param[out] RateArray List of clock rates.
> > +
> > + @retval EFI_SUCCESS List of clock rates is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the
> result.
> > + It has been updated to the size needed.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockDescribeRates (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + OUT SCMI_CLOCK_RATE_FORMAT *Format,
> > + OUT UINT32 *TotalRates,
> > + IN OUT UINT32 *RateArraySize,
> > + OUT SCMI_CLOCK_RATE *RateArray
> > + )
> > +{
> > + EFI_STATUS Status;
> > +
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > + UINT32 *MessageParams;
> > + CLOCK_DESCRIBE_RATES *DescribeRates;
> > + CLOCK_RATE_DWORD *Rate;
> > +
> > + UINT32 RequiredArraySize = 0;
> > + UINT32 RateIndex = 0;
> > + UINT32 RateNo;
> > + UINT32 RateOffset;
> > +
> > + *TotalRates = 0;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES;
> > +
> > + *MessageParams++ = ClockId;
> > +
> > + do {
> > +
> > + *MessageParams = RateIndex;
> > +
> > + // Set Payload length, note PayloadLength is a IN/OUT parameter.
> > + PayloadLength = sizeof (ClockId) + sizeof (RateIndex);
> > +
> > + // Execute and wait for response on a SCMI channel.
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + (UINT32**)&DescribeRates
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + if (*TotalRates == 0) {
> > + // In the first iteration we will get number of returned rates and
> number
> > + // of remaining rates. With this information calculate required size
> > + // for rate array. If provided RateArraySize is less, return an
> > + // error.
> > +
> > + *Format = RATE_FORMAT (DescribeRates->NumRatesFlags);
> > +
> > + *TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
> > + + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
> > +
> > + if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
> > + RequiredArraySize = (*TotalRates) * sizeof (UINT64);
> > + } else {
> > + // We need to return triplet of 64 bit value for each rate
> > + RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
> > + }
> > +
> > + if (RequiredArraySize > (*RateArraySize)) {
> > + *RateArraySize = RequiredArraySize;
> > + return EFI_BUFFER_TOO_SMALL;
> > + }
> > + }
> > +
> > + RateOffset = 0;
> > +
> > + if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
> > + for (RateNo = 0; RateNo < NUM_RATES (DescribeRates-
> >NumRatesFlags); RateNo++) {
> > + Rate = &DescribeRates->Rates[RateOffset++];
> > + // Non-linear discrete rates.
> > + RateArray[RateIndex++].Rate = ConvertTo64Bit (Rate->Low, Rate-
> >High);
> > + }
> > + } else {
> > + for (RateNo = 0; RateNo < NUM_RATES (DescribeRates-
> >NumRatesFlags); RateNo++) {
> > + // Linear clock rates from minimum to maximum in steps
> > + // Minimum clock rate.
> > + Rate = &DescribeRates->Rates[RateOffset++];
> > + RateArray[RateIndex].Min = ConvertTo64Bit (Rate->Low, Rate->High);
> > +
> > + Rate = &DescribeRates->Rates[RateOffset++];
> > + // Maximum clock rate.
> > + RateArray[RateIndex].Max = ConvertTo64Bit (Rate->Low, Rate->High);
> > +
> > + Rate = &DescribeRates->Rates[RateOffset++];
> > + // Step.
> > + RateArray[RateIndex++].Step = ConvertTo64Bit (Rate->Low, Rate-
> >High);
> > + }
> > + }
> > + } while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
> > +
> > + // Update RateArraySize with RequiredArraySize.
> > + *RateArraySize = RequiredArraySize;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Get clock rate.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > +
> > + @param[out] Rate Clock rate.
> > +
> > + @retval EFI_SUCCESS Clock rate is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockRateGet (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + OUT UINT64 *Rate
> > + )
> > +{
> > + EFI_STATUS Status;
> > +
> > + UINT32 *MessageParams;
> > + CLOCK_RATE_DWORD *ClockRate;
> > + SCMI_COMMAND Cmd;
> > +
> > + UINT32 PayloadLength;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // Fill arguments for clock protocol command.
> > + *MessageParams = ClockId;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_GET;
> > +
> > + PayloadLength = sizeof (ClockId);
> > +
> > + // Execute and wait for response on a SCMI channel.
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + (UINT32**)&ClockRate
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *Rate = ((UINT64)ClockRate->High << 32) | ClockRate->Low;
>
> Should this not use the helper function?
> I could fix that up before committing, but would like confirmation on that.
>
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Set clock rate.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > + @param[in] Rate Clock rate.
> > +
> > + @retval EFI_SUCCESS Clock rate set success.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockRateSet (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + IN UINT64 Rate
> > + )
> > +{
> > + EFI_STATUS Status;
> > + CLOCK_RATE_SET_ATTRIBUTES *ClockRateSetAttributes;
> > + SCMI_COMMAND Cmd;
> > + UINT32 PayloadLength;
> > +
> > + Status = ScmiCommandGetPayload
> ((UINT32**)&ClockRateSetAttributes);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + // Fill arguments for clock protocol command.
> > + ClockRateSetAttributes->ClockId = ClockId;
> > + ClockRateSetAttributes->Flags = CLOCK_SET_DEFAULT_FLAGS;
> > + ClockRateSetAttributes->Rate.Low = (UINT32)Rate;
> > + ClockRateSetAttributes->Rate.High = (UINT32)(Rate >> 32);
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_SET;
> > +
> > + PayloadLength = sizeof (CLOCK_RATE_SET_ATTRIBUTES);
> > +
> > + // Execute and wait for response on a SCMI channel.
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + NULL
> > + );
> > +
> > + return Status;
> > +}
> > +
> > +// Instance of the SCMI clock management protocol.
> > +STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol = {
> > + ClockGetVersion,
> > + ClockGetTotalClocks,
> > + ClockGetClockAttributes,
> > + ClockDescribeRates,
> > + ClockRateGet,
> > + ClockRateSet
> > + };
> > +
> > +/** Initialize clock management protocol and install protocol on a given
> handle.
> > +
> > + @param[in] Handle Handle to install clock management protocol.
> > +
> > + @retval EFI_SUCCESS Clock protocol interface installed successfully.
> > +**/
> > +EFI_STATUS
> > +ScmiClockProtocolInit (
> > + IN EFI_HANDLE* Handle
> > + )
> > +{
> > + return gBS->InstallMultipleProtocolInterfaces (
> > + Handle,
> > + &gArmScmiClockProtocolGuid,
> > + &ScmiClockProtocol,
> > + NULL
> > + );
> > +}
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..2920c6f6f33c5bb8ac00c903a0
> b199ba5f06f4de
> > --- /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;
> > +}
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..29cdde173659c701116b021a3
> c437a92b473e4e5
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> > @@ -0,0 +1,41 @@
> > +/** @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
> > +**/
> > +#ifndef SCMI_DXE_H_
> > +#define SCMI_DXE_H_
> > +
> > +#define MAX_PROTOCOLS 6
> > +#define PROTOCOL_ID_MASK 0xF
> > +#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
> > +
> > +/** Pointer to protocol initialization function.
> > +
> > + @param[in] Handle A pointer to the EFI_HANDLE on which the protocol
> > + interface is to be installed.
> > +
> > + @retval EFI_SUCCESS Protocol interface installed successfully.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PROTOCOL_INIT_FXN)(
> > + IN EFI_HANDLE *Handle
> > + );
> > +
> > +typedef struct {
> > + SCMI_PROTOCOL_INIT_FXN Init;
> > +} SCMI_PROTOCOL_INIT_TABLE;
> > +
> > +#endif /* SCMI_DXE_H_ */
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..ac32442ad838040721fd62faa8
> 06e82184f2b288
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> > @@ -0,0 +1,457 @@
> > +/** @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 <Library/UefiBootServicesTableLib.h>
> > +#include <Protocol/ArmScmiPerformanceProtocol.h>
> > +#include <string.h>
> > +
> > +#include "ArmScmiPerformanceProtocolPrivate.h"
> > +#include "ScmiPrivate.h"
> > +
> > +/** Return version of the performance management protocol supported
> by SCP.
> > + firmware.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > +
> > + @param[out] Version Version of the supported SCMI performance
> management
> > + protocol.
> > +
> > + @retval EFI_SUCCESS The version is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +PerformanceGetVersion (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + OUT UINT32 *Version
> > + )
> > +{
> > + return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_PERFORMANCE,
> Version);
> > +}
> > +
> > +/** Return protocol attributes of the performance management protocol.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > +
> > + @param[out] Attributes Protocol attributes.
> > +
> > + @retval EFI_SUCCESS Protocol attributes are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +PerformanceGetAttributes (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32* ReturnValues;
> > +
> > + Status = ScmiGetProtocolAttributes (
> > + SCMI_PROTOCOL_ID_PERFORMANCE,
> > + &ReturnValues
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + memcpy (
>
> Urgh, missed this one on previous passes.
> Surely this should be CopyMem?
>
> > + Attributes,
> > + ReturnValues,
> > + sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
> > + );
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return performance domain attributes.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] Attributes Performance domain attributes.
> > +
> > + @retval EFI_SUCCESS Domain attributes are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +PerformanceDomainAttributes (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 *MessageParams;
> > + UINT32 *ReturnValues;
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *MessageParams = DomainId;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> > + Cmd.MessageId =
> SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES;
> > +
> > + PayloadLength = sizeof (DomainId);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + &ReturnValues
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + memcpy (
>
> CopyMem?
>
> > + DomainAttributes,
> > + ReturnValues,
> > + sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
> > + );
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return list of performance domain levels of a given domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] NumLevels Total number of levels a domain can support.
> > +
> > + @param[in,out] LevelArraySize Size of the performance level array.
> > +
> > + @param[out] LevelArray Array of the performance levels.
> > +
> > + @retval EFI_SUCCESS Domain levels are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the
> result.
> > + It has been updated to the size needed.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +PerformanceDescribeLevels (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + OUT UINT32 *NumLevels,
> > + IN OUT UINT32 *LevelArraySize,
> > + OUT SCMI_PERFORMANCE_LEVEL *LevelArray
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > + UINT32* MessageParams;
> > + UINT32 LevelIndex;
> > + UINT32 RequiredSize;
> > + UINT32 LevelNo;
> > + UINT32 ReturnNumLevels;
> > + UINT32 ReturnRemainNumLevels;
> > +
> > + PERF_DESCRIBE_LEVELS *Levels;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + LevelIndex = 0;
> > + RequiredSize = 0;
> > +
> > + *MessageParams++ = DomainId;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> > + Cmd.MessageId =
> SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS;
> > +
> > + do {
> > +
> > + *MessageParams = LevelIndex;
> > +
> > + // Note, PayloadLength is an IN/OUT parameter.
> > + PayloadLength = sizeof (DomainId) + sizeof (LevelIndex);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + (UINT32**)&Levels
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + ReturnNumLevels = NUM_PERF_LEVELS (Levels->NumLevels);
> > + ReturnRemainNumLevels = NUM_REMAIN_PERF_LEVELS (Levels-
> >NumLevels);
> > +
> > + if (RequiredSize == 0) {
> > + *NumLevels = ReturnNumLevels + ReturnRemainNumLevels;
> > +
> > + RequiredSize = (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL);
> > + if (RequiredSize > (*LevelArraySize)) {
> > + // Update LevelArraySize with required size.
> > + *LevelArraySize = RequiredSize;
> > + return EFI_BUFFER_TOO_SMALL;
> > + }
> > + }
> > +
> > + for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
> > + memcpy (
>
> CopyMem?
>
> /
> Leif
>
> > + &LevelArray[LevelIndex++],
> > + &Levels->PerfLevel[LevelNo],
> > + sizeof (SCMI_PERFORMANCE_LEVEL)
> > + );
> > + }
> > +
> > + } while (ReturnRemainNumLevels != 0);
> > +
> > + *LevelArraySize = RequiredSize;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Set performance limits of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > + @param[in] Limit Performance limit to set.
> > +
> > + @retval EFI_SUCCESS Performance limits set successfully.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +PerformanceLimitsSet (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + IN SCMI_PERFORMANCE_LIMITS *Limits
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > + UINT32 *MessageParams;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *MessageParams++ = DomainId;
> > + *MessageParams++ = Limits->RangeMax;
> > + *MessageParams = Limits->RangeMin;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET;
> > +
> > + PayloadLength = sizeof (DomainId) + sizeof
> (SCMI_PERFORMANCE_LIMITS);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + NULL
> > + );
> > +
> > + return Status;
> > +}
> > +
> > +/** Get performance limits of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] Limit Performance Limits of the domain.
> > +
> > + @retval EFI_SUCCESS Performance limits are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +PerformanceLimitsGet (
> > + SCMI_PERFORMANCE_PROTOCOL *This,
> > + UINT32 DomainId,
> > + SCMI_PERFORMANCE_LIMITS *Limits
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > + UINT32 *MessageParams;
> > +
> > + SCMI_PERFORMANCE_LIMITS *ReturnValues;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *MessageParams = DomainId;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET;
> > +
> > + PayloadLength = sizeof (DomainId);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + (UINT32**)&ReturnValues
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + Limits->RangeMax = ReturnValues->RangeMax;
> > + Limits->RangeMin = ReturnValues->RangeMin;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Set performance level of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > + @param[in] Level Performance level of the domain.
> > +
> > + @retval EFI_SUCCESS Performance level set successfully.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +PerformanceLevelSet (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + IN UINT32 Level
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > + UINT32 *MessageParams;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *MessageParams++ = DomainId;
> > + *MessageParams = Level;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET;
> > +
> > + PayloadLength = sizeof (DomainId) + sizeof (Level);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + NULL
> > + );
> > +
> > + return Status;
> > +}
> > +
> > +/** Get performance level of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] Level Performance level of the domain.
> > +
> > + @retval EFI_SUCCESS Performance level got successfully.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +PerformanceLevelGet (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + OUT UINT32 *Level
> > + )
> > +{
> > + EFI_STATUS Status;
> > + UINT32 PayloadLength;
> > + SCMI_COMMAND Cmd;
> > + UINT32 *ReturnValues;
> > + UINT32 *MessageParams;
> > +
> > + Status = ScmiCommandGetPayload (&MessageParams);
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *MessageParams = DomainId;
> > +
> > + Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
> > + Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET;
> > +
> > + PayloadLength = sizeof (DomainId);
> > +
> > + Status = ScmiCommandExecute (
> > + &Cmd,
> > + &PayloadLength,
> > + &ReturnValues
> > + );
> > + if (EFI_ERROR (Status)) {
> > + return Status;
> > + }
> > +
> > + *Level = *ReturnValues;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +// Instance of the SCMI performance management protocol.
> > +STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol =
> {
> > + PerformanceGetVersion,
> > + PerformanceGetAttributes,
> > + PerformanceDomainAttributes,
> > + PerformanceDescribeLevels,
> > + PerformanceLimitsSet,
> > + PerformanceLimitsGet,
> > + PerformanceLevelSet,
> > + PerformanceLevelGet
> > +};
> > +
> > +/** Initialize performance management protocol and install on a given
> Handle.
> > +
> > + @param[in] Handle Handle to install performance management
> > + protocol.
> > +
> > + @retval EFI_SUCCESS Performance protocol installed successfully.
> > +**/
> > +EFI_STATUS
> > +ScmiPerformanceProtocolInit (
> > + IN EFI_HANDLE* Handle
> > + )
> > +{
> > + return gBS->InstallMultipleProtocolInterfaces (
> > + Handle,
> > + &gArmScmiPerformanceProtocolGuid,
> > + &PerformanceProtocol,
> > + NULL
> > + );
> > +}
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..df03655b8b021fe5fd63ceab0
> dd414906d2fb248
> > --- /dev/null
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> > @@ -0,0 +1,174 @@
> > +/** @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
> > +**/
> > +#ifndef SCMI_PRIVATE_H_
> > +#define SCMI_PRIVATE_H_
> > +
> > +// SCMI protocol IDs.
> > +typedef enum {
> > + SCMI_PROTOCOL_ID_BASE = 0x10,
> > + SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
> > + SCMI_PROTOCOL_ID_SYSTEM_POWER = 0x12,
> > + SCMI_PROTOCOL_ID_PERFORMANCE = 0x13,
> > + SCMI_PROTOCOL_ID_CLOCK = 0x14,
> > + SCMI_PROTOCOL_ID_SENSOR = 0x15
> > +} SCMI_PROTOCOL_ID;
> > +
> > +// SCMI message types.
> > +typedef enum {
> > + SCMI_MESSAGE_TYPE_COMMAND = 0,
> > + SCMI_MESSAGE_TYPE_DELAYED_RESPONSE = 2, // Skipping 1 is
> deliberate.
> > + SCMI_MESSAGE_TYPE_NOTIFICATION = 3
> > +} SCMI_MESSAGE_TYPE;
> > +
> > +// SCMI response error codes.
> > +typedef enum {
> > + SCMI_SUCCESS = 0,
> > + SCMI_NOT_SUPPORTED = -1,
> > + SCMI_INVALID_PARAMETERS = -2,
> > + SCMI_DENIED = -3,
> > + SCMI_NOT_FOUND = -4,
> > + SCMI_OUT_OF_RANGE = -5,
> > + SCMI_BUSY = -6,
> > + SCMI_COMMS_ERROR = -7,
> > + SCMI_GENERIC_ERROR = -8,
> > + SCMI_HARDWARE_ERROR = -9,
> > + SCMI_PROTOCOL_ERROR = -10
> > +} SCMI_STATUS;
> > +
> > +// SCMI message IDs common to all protocols.
> > +typedef enum {
> > + SCMI_MESSAGE_ID_PROTOCOL_VERSION = 0x0,
> > + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES = 0x1,
> > + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2
> > +} SCMI_MESSAGE_ID;
> > +
> > +// Not defined in SCMI specification but will help to identify a message.
> > +typedef struct {
> > + SCMI_PROTOCOL_ID ProtocolId;
> > + UINT32 MessageId;
> > +} SCMI_COMMAND;
> > +
> > +#pragma pack(1)
> > +
> > +// Response to a SCMI command.
> > +typedef struct {
> > + INT32 Status;
> > + UINT32 ReturnValues[];
> > +} SCMI_MESSAGE_RESPONSE;
> > +
> > +// Message header. MsgId[7:0], MsgType[9:8], ProtocolId[17:10]
> > +#define MESSAGE_TYPE_SHIFT 8
> > +#define PROTOCOL_ID_SHIFT 10
> > +#define SCMI_MESSAGE_HEADER(MsgId, MsgType, ProtocolId) ( \
> > + MsgType << MESSAGE_TYPE_SHIFT | \
> > + ProtocolId << PROTOCOL_ID_SHIFT | \
> > + MsgId \
> > + )
> > +// SCMI message header.
> > +typedef struct {
> > + UINT32 MessageHeader;
> > +} SCMI_MESSAGE_HEADER;
> > +
> > +#pragma pack()
> > +
> > +/** Return a pointer to the message payload.
> > +
> > + @param[out] Payload Holds pointer to the message payload.
> > +
> > + @retval EFI_SUCCESS Payload holds a valid message payload pointer.
> > + @retval EFI_TIMEOUT Time out error if MTL channel is busy.
> > + @retval EFI_UNSUPPORTED If MTL channel is unsupported.
> > +**/
> > +EFI_STATUS
> > +ScmiCommandGetPayload (
> > + OUT UINT32** Payload
> > + );
> > +
> > +/** Execute a SCMI command and receive a response.
> > +
> > + This function uses a MTL channel to transfer message to SCP
> > + and waits for a response.
> > +
> > + @param[in] Command Pointer to the SCMI command (Protocol ID
> > + and Message ID)
> > +
> > + @param[in,out] PayloadLength SCMI command message length.
> > +
> > + @param[out] OPTIONAL ReturnValues Pointer to SCMI response.
> > +
> > + @retval OUT EFI_SUCCESS Command sent and message received
> successfully.
> > + @retval OUT EFI_UNSUPPORTED Channel not supported.
> > + @retval OUT EFI_TIMEOUT Timeout on the channel.
> > + @retval OUT EFI_DEVICE_ERROR Channel not ready.
> > + @retval OUT EFI_DEVICE_ERROR Message Header corrupted.
> > + @retval OUT EFI_DEVICE_ERROR SCMI error.
> > +**/
> > +EFI_STATUS
> > +ScmiCommandExecute (
> > + IN SCMI_COMMAND *Command,
> > + IN OUT UINT32 *PayloadLength,
> > + OUT UINT32 **ReturnValues OPTIONAL
> > + );
> > +
> > +/** Return protocol version from SCP for a given protocol ID.
> > +
> > + @param[in] Protocol ID Protocol ID.
> > + @param[out] Version Pointer to version of the protocol.
> > +
> > + @retval EFI_SUCCESS Version holds a valid version received
> > + from the SCP.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +ScmiGetProtocolVersion (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + OUT UINT32 *Version
> > + );
> > +
> > +/** Return protocol attributes from SCP for a given protocol ID.
> > +
> > + @param[in] Protocol ID Protocol ID.
> > + @param[out] ReturnValues Pointer to attributes of the protocol.
> > +
> > + @retval EFI_SUCCESS ReturnValues points to protocol attributes.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +ScmiGetProtocolAttributes (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + OUT UINT32 **ReturnValues
> > + );
> > +
> > +/** Return protocol message attributes from SCP for a given protocol ID.
> > +
> > + @param[in] Protocol ID Protocol ID.
> > +
> > + @param[out] Attributes Pointer to attributes of the protocol.
> > +
> > + @retval EFI_SUCCESS ReturnValues points to protocol message
> attributes.
> > + @retval EFI_DEVICE_ERROR SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +EFI_STATUS
> > +ScmiGetProtocolMessageAttributes (
> > + IN SCMI_PROTOCOL_ID ProtocolId,
> > + OUT UINT32 **ReturnValues
> > + );
> > +
> > +#endif /* SCMI_PRIVATE_H_ */
> > diff --git a/ArmPkg/Include/Protocol/ArmScmi.h
> b/ArmPkg/Include/Protocol/ArmScmi.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..239abb97064578c949614f79a6
> a33fe1881c3c68
> > --- /dev/null
> > +++ b/ArmPkg/Include/Protocol/ArmScmi.h
> > @@ -0,0 +1,27 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_H_
> > +#define ARM_SCMI_H_
> > +
> > +/* As per SCMI specification, maximum allowed ASCII string length
> > + for various return values/parameters of a SCMI message.
> > +*/
> > +#define SCMI_MAX_STR_LEN 16
> > +
> > +#endif /* ARM_SCMI_H_ */
> > +
> > diff --git a/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..ecc41f2181ecc9f835950ab46c
> 7cfd2e476a7073
> > --- /dev/null
> > +++ b/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> > @@ -0,0 +1,174 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_BASE_PROTOCOL_H_
> > +#define ARM_SCMI_BASE_PROTOCOL_H_
> > +
> > +#include <Protocol/ArmScmi.h>
> > +
> > +#define BASE_PROTOCOL_VERSION 0x10000
> > +
> > +#define NUM_PROTOCOL_MASK 0xFFU
> > +#define NUM_AGENT_MASK 0xFFU
> > +
> > +#define NUM_AGENT_SHIFT 0x8
> > +
> > +/** Returns total number of protocols that are
> > + implemented (excluding the Base protocol)
> > +*/
> > +#define SCMI_TOTAL_PROTOCOLS(Attr) (Attr & NUM_PROTOCOL_MASK)
> > +
> > +// Returns total number of agents in the system.
> > +#define SCMI_TOTAL_AGENTS(Attr) ((Attr >> NUM_AGENT_SHIFT) &
> NUM_AGENT_MASK)
> > +
> > +#define ARM_SCMI_BASE_PROTOCOL_GUID { \
> > + 0xd7e5abe9, 0x33ab, 0x418e, {0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e,
> 0x2f} \
> > + }
> > +
> > +extern EFI_GUID gArmScmiBaseProtocolGuid;
> > +
> > +typedef struct _SCMI_BASE_PROTOCOL SCMI_BASE_PROTOCOL;
> > +
> > +/** Return version of the Base protocol supported by SCP firmware.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] Version Version of the supported SCMI Base protocol.
> > +
> > + @retval EFI_SUCCESS The version of the protocol is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_BASE_GET_VERSION) (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT32 *Version
> > + );
> > +
> > +/** Return total number of SCMI protocols supported by the SCP
> firmware.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] TotalProtocols Total number of SCMI protocols supported.
> > +
> > + @retval EFI_SUCCESS Total number of protocols supported are
> returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_BASE_GET_TOTAL_PROTOCOLS) (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT32 *TotalProtocols
> > + );
> > +
> > +/** Return vendor name.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] VendorIdentifier Null terminated ASCII string of up to
> > + 16 bytes with a vendor name.
> > +
> > + @retval EFI_SUCCESS VendorIdentifier is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_BASE_DISCOVER_VENDOR) (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> > + );
> > +
> > +/** Return sub vendor name.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] VendorIdentifier Null terminated ASCII string of up to
> > + 16 bytes with a vendor name.
> > +
> > + @retval EFI_SUCCESS VendorIdentifier is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_BASE_DISCOVER_SUB_VENDOR) (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
> > + );
> > +
> > +/** Return implementation version.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] ImplementationVersion Vendor specific implementation
> version.
> > +
> > + @retval EFI_SUCCESS Implementation version is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION) (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + OUT UINT32 *ImplementationVersion
> > + );
> > +
> > +/** Return list of protocols.
> > +
> > + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
> > +
> > + @param[out] ProtocolListSize Size of the ProtocolList.
> > +
> > + @param[out] ProtocolList Protocol list.
> > +
> > + @retval EFI_SUCCESS List of protocols is returned.
> > + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the
> result.
> > + It has been updated to the size needed.
> > + @retval EFI_DEVICE_ERROR SCP returns a SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_BASE_DISCOVER_LIST_PROTOCOLS) (
> > + IN SCMI_BASE_PROTOCOL *This,
> > + IN OUT UINT32 *ProtocolListSize,
> > + OUT UINT8 *ProtocolList
> > + );
> > +
> > +// Base protocol.
> > +typedef struct _SCMI_BASE_PROTOCOL {
> > + SCMI_BASE_GET_VERSION GetVersion;
> > + SCMI_BASE_GET_TOTAL_PROTOCOLS GetTotalProtocols;
> > + SCMI_BASE_DISCOVER_VENDOR DiscoverVendor;
> > + SCMI_BASE_DISCOVER_SUB_VENDOR DiscoverSubVendor;
> > + SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION
> DiscoverImplementationVersion;
> > + SCMI_BASE_DISCOVER_LIST_PROTOCOLS DiscoverListProtocols;
> > +} SCMI_BASE_PROTOCOL;
> > +
> > +// SCMI Message IDs for Base protocol.
> > +typedef enum {
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR = 0x3,
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR = 0x4,
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION =
> 0x5,
> > + SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS = 0x6
> > +} SCMI_MESSAGE_ID_BASE;
> > +
> > +#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */
> > +
> > diff --git a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..3db26cb0641c7377c022a8e00
> be9a51ee5dc7361
> > --- /dev/null
> > +++ b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> > @@ -0,0 +1,218 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_
> > +#define ARM_SCMI_CLOCK_PROTOCOL_H_
> > +
> > +#include <Protocol/ArmScmi.h>
> > +
> > +#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \
> > + 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa}
> \
> > + }
> > +
> > +extern EFI_GUID gArmScmiClockProtocolGuid;
> > +
> > +// Message Type for clock management protocol.
> > +typedef enum {
> > + SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3,
> > + SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4,
> > + SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5,
> > + SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6,
> > + SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7
> > +} SCMI_MESSAGE_ID_CLOCK;
> > +
> > +typedef enum {
> > + SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range.
> > + SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range.
> > +} SCMI_CLOCK_RATE_FORMAT;
> > +
> > +// Clock management protocol version.
> > +#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000
> > +
> > +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK
> 0xFFU
> > +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16
> > +#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU
> > +
> > +/** Total number of pending asynchronous clock rates changes
> > + supported by the SCP, Attr Bits[23:16]
> > +*/
> > +#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr)
> ( \
> > + (Attr >>
> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \
> > + SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)
> > +
> > +// Total of clock devices supported by the SCP, Attr Bits[15:0]
> > +#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr &
> SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)
> > +
> > +#pragma pack(1)
> > +
> > +/* Depending on the format (linear/non-linear) supported by a clock
> device
> > + either Rate or Min/Max/Step triplet is valid.
> > +*/
> > +typedef struct {
> > + union {
> > + UINT64 Min;
> > + UINT64 Rate;
> > + };
> > + UINT64 Max;
> > + UINT64 Step;
> > +} SCMI_CLOCK_RATE;
> > +
> > +#pragma pack()
> > +
> > +typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL;
> > +
> > +// Protocol Interface functions.
> > +
> > +/** Return version of the clock management protocol supported by SCP
> firmware.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > +
> > + @param[out] Version Version of the supported SCMI Clock
> management protocol.
> > +
> > + @retval EFI_SUCCESS The version is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_CLOCK_GET_VERSION) (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + OUT UINT32 *Version
> > + );
> > +
> > +/** Return total number of clock devices supported by the clock
> management
> > + protocol.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > +
> > + @param[out] TotalClocks Total number of clocks supported.
> > +
> > + @retval EFI_SUCCESS Total number of clocks supported is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + OUT UINT32 *TotalClocks
> > + );
> > +
> > +/** Return attributes of a clock device.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > +
> > + @param[out] Enabled If TRUE, the clock device is enabled.
> > + @param[out] ClockAsciiName A NULL terminated ASCII string with the
> clock
> > + name, of up to 16 bytes.
> > +
> > + @retval EFI_SUCCESS Clock device attributes are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + OUT BOOLEAN *Enabled,
> > + OUT CHAR8 *ClockAsciiName
> > + );
> > +
> > +/** Return list of rates supported by a given clock device.
> > +
> > + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > +
> > + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock
> device
> > + supports range of clock rates which are non-linear.
> > +
> > + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
> > + range of linear clock rates from Min to Max in steps.
> > +
> > + @param[out] TotalRates Total number of rates.
> > +
> > + @param[in,out] RateArraySize Size of the RateArray.
> > +
> > + @param[out] RateArray List of clock rates.
> > +
> > + @retval EFI_SUCCESS List of clock rates are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the
> result.
> > + It has been updated to the size needed.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + OUT SCMI_CLOCK_RATE_FORMAT *Format,
> > + OUT UINT32 *TotalRates,
> > + IN OUT UINT32 *RateArraySize,
> > + OUT SCMI_CLOCK_RATE *RateArray
> > + );
> > +
> > +/** Get clock rate.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > +
> > + @param[out] Rate Clock rate.
> > +
> > + @retval EFI_SUCCESS Clock rate is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_CLOCK_RATE_GET) (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + OUT UINT64 *Rate
> > + );
> > +
> > +/** Set clock rate.
> > +
> > + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > + @param[in] ClockId Identifier for the clock device.
> > + @param[in] Rate Clock rate.
> > +
> > + @retval EFI_SUCCESS Clock rate set success.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_CLOCK_RATE_SET) (
> > + IN SCMI_CLOCK_PROTOCOL *This,
> > + IN UINT32 ClockId,
> > + IN UINT64 Rate
> > + );
> > +
> > +typedef struct _SCMI_CLOCK_PROTOCOL {
> > + SCMI_CLOCK_GET_VERSION GetVersion;
> > + SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks;
> > + SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes;
> > + SCMI_CLOCK_DESCRIBE_RATES DescribeRates;
> > + SCMI_CLOCK_RATE_GET RateGet;
> > + SCMI_CLOCK_RATE_SET RateSet;
> > +} SCMI_CLOCK_PROTOCOL;
> > +
> > +#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */
> > +
> > diff --git a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..1d1af6f8bee0c00bbe6b47740
> 36c87c988a4f4af
> > --- /dev/null
> > +++ b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> > @@ -0,0 +1,265 @@
> > +/** @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
> > +**/
> > +
> > +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
> > +#define ARM_SCMI_PERFORMANCE_PROTOCOL_H_
> > +
> > +#include <Protocol/ArmScmi.h>
> > +
> > +#define PERFORMANCE_PROTOCOL_VERSION 0x10000
> > +
> > +#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \
> > + 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b,
> 0xad} \
> > + }
> > +
> > +extern EFI_GUID gArmScmiPerformanceProtocolGuid;
> > +
> > +typedef struct _SCMI_PERFORMANCE_PROTOCOL
> SCMI_PERFORMANCE_PROTOCOL;
> > +
> > +#pragma pack(1)
> > +
> > +#define POWER_IN_MW_SHIFT 16
> > +#define POWER_IN_MW_MASK 0x1
> > +#define NUM_PERF_DOMAINS_MASK 0xFFFF
> > +
> > +// Total number of performance domains, Attr Bits [15:0]
> > +#define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr &
> NUM_PERF_DOMAINS_MASK)
> > +
> > +// A flag to express power values in mW or platform specific way, Attr Bit
> [16]
> > +#define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >>
> POWER_IN_MW_SHIFT) & \
> > + POWER_IN_MW_MASK)
> > +
> > +// Performance protocol attributes return values.
> > +typedef struct {
> > + UINT32 Attributes;
> > + UINT64 StatisticsAddress;
> > + UINT32 StatisticsLen;
> > +} SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES;
> > +
> > +#define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28)
> & 0x1)
> > +#define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29)
> & 0x1)
> > +#define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1)
> > +#define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1)
> > +#define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF)
> > +
> > +// Performance protocol domain attributes.
> > +typedef struct {
> > + UINT32 Attributes;
> > + UINT32 RateLimit;
> > + UINT32 SustainedFreq;
> > + UINT32 SustainedPerfLevel;
> > + UINT8 Name[SCMI_MAX_STR_LEN];
> > +} SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES;
> > +
> > +// Worst case latency in microseconds, Bits[15:0]
> > +#define PERF_LATENCY_MASK 0xFFFF
> > +#define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency &
> PERF_LATENCY_MASK)
> > +
> > +// Performance protocol performance level.
> > +typedef struct {
> > + UINT32 Level;
> > + UINT32 PowerCost;
> > + UINT32 Latency;
> > +} SCMI_PERFORMANCE_LEVEL;
> > +
> > +// Performance protocol performance limit.
> > +typedef struct {
> > + UINT32 RangeMax;
> > + UINT32 RangeMin;
> > +} SCMI_PERFORMANCE_LIMITS;
> > +
> > +#pragma pack()
> > +
> > +/** Return version of the performance management protocol supported
> by SCP.
> > + firmware.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > +
> > + @param[out] Version Version of the supported SCMI performance
> management
> > + protocol.
> > +
> > + @retval EFI_SUCCESS The version is returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_GET_VERSION) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + OUT UINT32 *Version
> > + );
> > +
> > +/** Return protocol attributes of the performance management protocol.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > +
> > + @param[out] Attributes Protocol attributes.
> > +
> > + @retval EFI_SUCCESS Protocol attributes are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
> > +
> > + );
> > +
> > +/** Return performance domain attributes.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] Attributes Performance domain attributes.
> > +
> > + @retval EFI_SUCCESS Domain attributes are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
> > + );
> > +
> > +/** Return list of performance domain levels of a given domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] NumLevels Total number of levels a domain can support.
> > +
> > + @param[in,out] LevelArraySize Size of the performance level array.
> > +
> > + @param[out] LevelArray Array of the performance levels.
> > +
> > + @retval EFI_SUCCESS Domain levels are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the
> result.
> > + It has been updated to the size needed.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + OUT UINT32 *NumLevels,
> > + IN OUT UINT32 *LevelArraySize,
> > + OUT SCMI_PERFORMANCE_LEVEL *LevelArray
> > + );
> > +
> > +/** Set performance limits of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > + @param[in] Limit Performance limit to set.
> > +
> > + @retval EFI_SUCCESS Performance limits set successfully.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + IN SCMI_PERFORMANCE_LIMITS *Limits
> > + );
> > +
> > +/** Get performance limits of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] Limit Performance Limits of the domain.
> > +
> > + @retval EFI_SUCCESS Performance limits are returned.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) (
> > + SCMI_PERFORMANCE_PROTOCOL *This,
> > + UINT32 DomainId,
> > + SCMI_PERFORMANCE_LIMITS *Limits
> > + );
> > +
> > +/** Set performance level of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > + @param[in] Level Performance level of the domain.
> > +
> > + @retval EFI_SUCCESS Performance level set successfully.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + IN UINT32 Level
> > + );
> > +
> > +/** Get performance level of a domain.
> > +
> > + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL
> Instance.
> > + @param[in] DomainId Identifier for the performance domain.
> > +
> > + @param[out] Level Performance level of the domain.
> > +
> > + @retval EFI_SUCCESS Performance level got successfully.
> > + @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > + @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) (
> > + IN SCMI_PERFORMANCE_PROTOCOL *This,
> > + IN UINT32 DomainId,
> > + OUT UINT32 *Level
> > + );
> > +
> > +typedef struct _SCMI_PERFORMANCE_PROTOCOL {
> > + SCMI_PERFORMANCE_GET_VERSION GetVersion;
> > + SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes;
> > + SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES
> GetDomainAttributes;
> > + SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels;
> > + SCMI_PERFORMANCE_LIMITS_SET LimitsSet;
> > + SCMI_PERFORMANCE_LIMITS_GET LimitsGet;
> > + SCMI_PERFORMANCE_LEVEL_SET LevelSet;
> > + SCMI_PERFORMANCE_LEVEL_GET LevelGet;
> > +} SCMI_PERFORMANCE_PROTOCOL;
> > +
> > +typedef enum {
> > + SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3,
> > + SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4,
> > + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5,
> > + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6,
> > + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7,
> > + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8,
> > +} SCMI_MESSAGE_ID_PERFORMANCE;
> > +
> > +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
> > +
> > --
> > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> >
> >
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
2018-04-23 16:06 ` Girish Pathak
@ 2018-04-23 16:22 ` Leif Lindholm
2018-04-23 16:49 ` Girish Pathak
0 siblings, 1 reply; 40+ messages in thread
From: Leif Lindholm @ 2018-04-23 16:22 UTC (permalink / raw)
To: Girish Pathak
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org,
Matteo Carlini, Stephanie Hughes-Fitt, nd
On Mon, Apr 23, 2018 at 04:06:43PM +0000, Girish Pathak wrote:
> > From: Leif Lindholm <leif.lindholm@linaro.org>
> > Sent: 23 April 2018 12:32
> > To: Girish Pathak <Girish.Pathak@arm.com>
> > Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org; Matteo Carlini
> > <Matteo.Carlini@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> > Fitt@arm.com>; nd <nd@arm.com>
> > Subject: Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
> >
> > Hmm, I did find a few minor things below that I need to hear back on
> > before pushing.
>
> Thanks for your comments, We can incorporate all the changes
> suggested, shall I tidy this up and resubmit the patch series ?
Oh God, please don't.
If you're happy with all of my comments on previous patches, can you
just say if you're OK with me folding in the below patch into 16/16
before pushing?:
>From 50294f90db0c3e7b5b19bc2022b5c1d866d0b8e1 Mon Sep 17 00:00:00 2001
From: Leif Lindholm <leif.lindholm@linaro.org>
Date: Mon, 23 Apr 2018 12:36:06 +0100
Subject: [PATCH] fixup scmi
---
ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 2 +-
ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 4 ++--
ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
index 71245c1647..0d1ec6f5ad 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
+++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
@@ -30,7 +30,7 @@ typedef struct {
#define RATE_FORMAT_SHIFT 12
#define RATE_FORMAT_MASK 0x0001
#define RATE_FORMAT(RatesFlags) ((RatesFlags >> RATE_FORMAT_SHIFT) \
- & RATE_FORMAT_MASK)
+ & RATE_FORMAT_MASK)
// Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
#define NUM_REMAIN_RATES_SHIFT 16
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
index fe7edd2a8c..64d2afab72 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
@@ -83,7 +83,7 @@ ClockGetTotalClocks (
Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK, &ReturnValues);
if (EFI_ERROR (Status)) {
- return Status;
+ return Status;
}
*TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
@@ -334,7 +334,7 @@ ClockRateGet (
return Status;
}
- *Rate = ((UINT64)ClockRate->High << 32) | ClockRate->Low;
+ *Rate = ConvertTo64Bit (ClockRate->Low, ClockRate->High);
return EFI_SUCCESS;
}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
index ac32442ad8..e012424a9b 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
@@ -15,9 +15,9 @@
DEN0056A_System_Control_and_Management_Interface.pdf
**/
+#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ArmScmiPerformanceProtocol.h>
-#include <string.h>
#include "ArmScmiPerformanceProtocolPrivate.h"
#include "ScmiPrivate.h"
@@ -72,7 +72,7 @@ PerformanceGetAttributes (
return Status;
}
- memcpy (
+ CopyMem (
Attributes,
ReturnValues,
sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
@@ -127,7 +127,7 @@ PerformanceDomainAttributes (
return Status;
}
- memcpy (
+ CopyMem (
DomainAttributes,
ReturnValues,
sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
@@ -219,7 +219,7 @@ PerformanceDescribeLevels (
}
for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
- memcpy (
+ CopyMem (
&LevelArray[LevelIndex++],
&Levels->PerfLevel[LevelNo],
sizeof (SCMI_PERFORMANCE_LEVEL)
--
2.11.0
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
2018-04-23 16:22 ` Leif Lindholm
@ 2018-04-23 16:49 ` Girish Pathak
0 siblings, 0 replies; 40+ messages in thread
From: Girish Pathak @ 2018-04-23 16:49 UTC (permalink / raw)
To: Leif Lindholm
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org,
Matteo Carlini, Stephanie Hughes-Fitt, nd
Hi Leif,
> -----Original Message-----
> From: Leif Lindholm <leif.lindholm@linaro.org>
> Sent: 23 April 2018 17:22
> To: Girish Pathak <Girish.Pathak@arm.com>
> Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org; Matteo Carlini
> <Matteo.Carlini@arm.com>; Stephanie Hughes-Fitt <Stephanie.Hughes-
> Fitt@arm.com>; nd <nd@arm.com>
> Subject: Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
>
> On Mon, Apr 23, 2018 at 04:06:43PM +0000, Girish Pathak wrote:
> > > From: Leif Lindholm <leif.lindholm@linaro.org>
> > > Sent: 23 April 2018 12:32
> > > To: Girish Pathak <Girish.Pathak@arm.com>
> > > Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org; Matteo
> > > Carlini <Matteo.Carlini@arm.com>; Stephanie Hughes-Fitt
> > > <Stephanie.Hughes- Fitt@arm.com>; nd <nd@arm.com>
> > > Subject: Re: [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol
> > >
> > > Hmm, I did find a few minor things below that I need to hear back on
> > > before pushing.
> >
> > Thanks for your comments, We can incorporate all the changes
> > suggested, shall I tidy this up and resubmit the patch series ?
>
> Oh God, please don't.
>
> If you're happy with all of my comments on previous patches, can you just
> say if you're OK with me folding in the below patch into 16/16 before
> pushing?:
Thanks for this, it's ok to fold it.
Regards,
Girish
>
> From 50294f90db0c3e7b5b19bc2022b5c1d866d0b8e1 Mon Sep 17 00:00:00
> 2001
> From: Leif Lindholm <leif.lindholm@linaro.org>
> Date: Mon, 23 Apr 2018 12:36:06 +0100
> Subject: [PATCH] fixup scmi
>
> ---
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 2 +-
> ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 4 ++--
> ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 8 ++++----
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> index 71245c1647..0d1ec6f5ad 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> @@ -30,7 +30,7 @@ typedef struct {
> #define RATE_FORMAT_SHIFT 12
> #define RATE_FORMAT_MASK 0x0001
> #define RATE_FORMAT(RatesFlags) ((RatesFlags >> RATE_FORMAT_SHIFT)
> \
> - & RATE_FORMAT_MASK)
> + & RATE_FORMAT_MASK)
>
> // Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
> #define NUM_REMAIN_RATES_SHIFT 16
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> index fe7edd2a8c..64d2afab72 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> @@ -83,7 +83,7 @@ ClockGetTotalClocks (
>
> Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK,
> &ReturnValues);
> if (EFI_ERROR (Status)) {
> - return Status;
> + return Status;
> }
>
> *TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
> @@ -334,7 +334,7 @@ ClockRateGet (
> return Status;
> }
>
> - *Rate = ((UINT64)ClockRate->High << 32) | ClockRate->Low;
> + *Rate = ConvertTo64Bit (ClockRate->Low, ClockRate->High);
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> index ac32442ad8..e012424a9b 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> @@ -15,9 +15,9 @@
> DEN0056A_System_Control_and_Management_Interface.pdf
> **/
>
> +#include <Library/BaseMemoryLib.h>
> #include <Library/UefiBootServicesTableLib.h>
> #include <Protocol/ArmScmiPerformanceProtocol.h>
> -#include <string.h>
>
> #include "ArmScmiPerformanceProtocolPrivate.h"
> #include "ScmiPrivate.h"
> @@ -72,7 +72,7 @@ PerformanceGetAttributes (
> return Status;
> }
>
> - memcpy (
> + CopyMem (
> Attributes,
> ReturnValues,
> sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
> @@ -127,7 +127,7 @@ PerformanceDomainAttributes (
> return Status;
> }
>
> - memcpy (
> + CopyMem (
> DomainAttributes,
> ReturnValues,
> sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
> @@ -219,7 +219,7 @@ PerformanceDescribeLevels (
> }
>
> for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
> - memcpy (
> + CopyMem (
> &LevelArray[LevelIndex++],
> &Levels->PerfLevel[LevelNo],
> sizeof (SCMI_PERFORMANCE_LEVEL)
> --
> 2.11.0
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH v3 00/16] Update GOP
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
` (15 preceding siblings ...)
2018-03-20 16:12 ` [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol Girish Pathak
@ 2018-04-23 17:11 ` Leif Lindholm
16 siblings, 0 replies; 40+ messages in thread
From: Leif Lindholm @ 2018-04-23 17:11 UTC (permalink / raw)
To: Girish Pathak
Cc: edk2-devel, ard.biesheuvel, Matteo.Carlini, Stephanie.Hughes-Fitt,
nd
On Tue, Mar 20, 2018 at 04:11:56PM +0000, Girish Pathak wrote:
> This patch series addresses comments on the patch v2
> (https://lists.01.org/pipermail/edk2-devel/2017-December/019389.html)
> reworking of the Graphics Output Protocol code in ArmPlatformPkg.
> It also contains updates for the new SCMI protocol.
>
> Corresponding edk2-platforms changes will follow shortly.
>
For the series:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Pushed as ee4dc24f57..4f2494cf53.
Apologies for the delay in getting this through.
/
Leif
> Code is available for examination at:
> https://github.com/girishpathak/edk2/tree/201_gop_v3
>
> Girish Pathak (16):
> ArmPlatformPkg: Rectify line endings of LcdHwNullLib
> ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib
> ArmPlatformPkg: Tidy Lcd code: Coding standard
> ArmPlatformPkg: Tidy Lcd code: Updated comments
> ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS
> ArmPlatformPkg: PL111Lcd: Replace magic number with macro
> ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl
> ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP
> ArmPlatformPkg: Redefine LcdPlatformGetTimings function
> ArmPlatformPkg: Add PCD to select pixel format
> ArmPlatformPkg: PCD to swap red/blue format for HDLCD
> ArmPlatformPkg: Additional display modes
> ArmPlatformPkg: Reserving framebuffer at build
> ArmPlatformPkg: New DP500/DP550/DP650 GOP driver
> ArmPkg: MTL Library interface and Null library implementation
> ArmPkg: Introduce SCMI protocol
>
> ArmPkg/ArmPkg.dec | 16 +-
> ArmPkg/ArmPkg.dsc | 6 +-
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h | 46 ++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 84 ++++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf | 53 +++
> ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h | 55 +++
> ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 262 +++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c | 318 ++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 418 ++++++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 138 ++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 41 ++
> ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c | 457 ++++++++++++++++++++
> ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h | 174 ++++++++
> ArmPkg/Include/Library/ArmMtlLib.h | 137 ++++++
> ArmPkg/Include/Protocol/ArmScmi.h | 27 ++
> ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h | 174 ++++++++
> ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 218 ++++++++++
> ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h | 265 ++++++++++++
> ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c | 108 +++++
> ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf | 26 ++
> ArmPlatformPkg/ArmPlatformPkg.dec | 21 +-
> ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 197 +++++----
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h | 10 +-
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 177 ++++++--
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c | 409 ++++++++++++++++++
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h | 243 +++++++++++
> ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf | 43 ++
> ArmPlatformPkg/Library/HdLcd/HdLcd.c | 174 ++++----
> ArmPlatformPkg/Library/HdLcd/HdLcd.h | 23 +-
> ArmPlatformPkg/Library/HdLcd/HdLcd.inf | 4 +-
> ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c | 150 +++----
> ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c | 243 +++++++----
> ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 125 ++++--
> 34 files changed, 4413 insertions(+), 433 deletions(-)
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ArmScmiPerformanceProtocolPrivate.h
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/Scmi.c
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ScmiBaseProtocol.c
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
> create mode 100644 ArmPkg/Drivers/ArmScmiDxe/ScmiPrivate.h
> create mode 100644 ArmPkg/Include/Library/ArmMtlLib.h
> create mode 100644 ArmPkg/Include/Protocol/ArmScmi.h
> create mode 100644 ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> create mode 100644 ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> create mode 100644 ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> create mode 100644 ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
> create mode 100644 ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
> create mode 100644 ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.c
> create mode 100644 ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.h
> create mode 100644 ArmPlatformPkg/Library/ArmMaliDp/ArmMaliDp.inf
>
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread