From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562361187741.244379507017; Tue, 20 Mar 2018 09:12:41 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 21D3B2264631F; Tue, 20 Mar 2018 09:06:00 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 93E2E22571B57 for ; Tue, 20 Mar 2018 09:05:52 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLp016075; Tue, 20 Mar 2018 16:12:19 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:11:57 +0000 Message-Id: <20180320161212.79120-2-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c | 150 ++++++++++-------= --- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/ArmPlatformPkg/Library/LcdHwNullLib/LcdHwNullLib.c b/ArmPlatfo= rmPkg/Library/LcdHwNullLib/LcdHwNullLib.c index 2d31b5183c959c88eb1dab7703ec9b87f03eb50f..50e1c88112db690545979e7d008= 678c4f8ecd949 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 BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include -#include -#include -#include - -/** - Check for presence of display - =20 - @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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#include +#include +#include +#include + +/** + 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 + ) +{ +} --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562357777219.674020762748; Tue, 20 Mar 2018 09:12:37 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B671B22646301; Tue, 20 Mar 2018 09:05:59 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 91C7622571B52 for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLq016075; Tue, 20 Mar 2018 16:12:19 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:11:58 +0000 Message-Id: <20180320161212.79120-3-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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..b78d9a3bbd3e1fac4238f2be961= a343020360a32 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 BS= D License - which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. - -**/ - -#include -#include -#include -#include - -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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#include +#include +#include +#include + +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; +} --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562381450814.0949806317194; Tue, 20 Mar 2018 09:13:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8495A224BBC2A; Tue, 20 Mar 2018 09:06:02 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9614B22571B59 for ; Tue, 20 Mar 2018 09:05:52 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLr016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:11:59 +0000 Message-Id: <20180320161212.79120-4-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- Notes: v3: - Minor coding style changes [Ard] =20 Done [Girish] =20 - Changing one style to the other is just pointless churn [Ard] =20 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/LcdGraphicsOutputD= xe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c index b721061fc1df5695092e8c71da97ae0b9af46b3f..905eb26ee01b5037dfbaf3c054a= 62593837c8b5f 100644 --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2018, ARM 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 @@ -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 IMPL= IED. =20 - **/ +**/ =20 #include #include @@ -22,12 +22,10 @@ =20 #include "LcdGraphicsOutputDxe.h" =20 -/********************************************************************** - * - * This file implements the Graphics Output protocol on ArmVersatileExpre= ss - * using the Lcd controller - * - **********************************************************************/ +/** This file implements the Graphics Output protocol on ArmVersatileExpre= ss + using the Lcd controller + +**/ =20 // // Global variables @@ -64,7 +62,10 @@ LCD_INSTANCE mLcdTemplate =3D { { { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, - { (UINT8) (sizeof(VENDOR_DEVICE_PATH)), (UINT8) ((sizeof(VENDOR_DE= VICE_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 =3D { { 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 }; =20 EFI_STATUS @@ -86,7 +90,7 @@ LcdInstanceContructor ( { LCD_INSTANCE* Instance; =20 - Instance =3D AllocateCopyPool (sizeof(LCD_INSTANCE), &mLcdTemplate); + Instance =3D AllocateCopyPool (sizeof (LCD_INSTANCE), &mLcdTemplate); if (Instance =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } @@ -113,23 +117,23 @@ InitializeDisplay ( UINTN VramSize; =20 Status =3D LcdPlatformGetVram (&VramBaseAddress, &VramSize); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { return Status; } =20 // Setup the LCD Status =3D LcdInitialize (VramBaseAddress); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { goto EXIT_ERROR_LCD_SHUTDOWN; } =20 Status =3D LcdPlatformInitializeDisplay (Instance->Handle); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { goto EXIT_ERROR_LCD_SHUTDOWN; } =20 // Setup all the relevant mode information - Instance->Gop.Mode->SizeOfInfo =3D sizeof(EFI_GRAPHICS_OUTPUT_MODE_= INFORMATION); + Instance->Gop.Mode->SizeOfInfo =3D sizeof (EFI_GRAPHICS_OUTPUT_MODE= _INFORMATION); Instance->Gop.Mode->FrameBufferBase =3D VramBaseAddress; =20 // Set the flag before changing the mode, to avoid infinite loops @@ -139,7 +143,8 @@ InitializeDisplay ( goto EXIT; =20 EXIT_ERROR_LCD_SHUTDOWN: - DEBUG((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the d= isplay. Exit Status=3D%r\n", Status)); + DEBUG ((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the = display. Exit Status=3D%r\n", Status)); + LcdShutdown (); =20 EXIT: @@ -157,40 +162,44 @@ LcdGraphicsOutputDxeInitialize ( LCD_INSTANCE* Instance; =20 Status =3D LcdIdentify (); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { goto EXIT; } =20 Status =3D LcdInstanceContructor (&Instance); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { goto EXIT; } =20 // Install the Graphics Output Protocol and the Device Path - Status =3D gBS->InstallMultipleProtocolInterfaces( - &Instance->Handle, - &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, - &gEfiDevicePathProtocolGuid, &Instance->DevicePath, - NULL - ); + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Instance->Handle, + &gEfiGraphicsOutputProtocolGuid, + &Instance->Gop, + &gEfiDevicePathProtocolGuid, + &Instance->DevicePath, + NULL + ); =20 - if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the = protocol. Exit Status=3D%r\n", Status)); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install = the protocol. Exit Status=3D%r\n", Status)); goto EXIT; } =20 // 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 h= ardware 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 =3D gBS->CreateEvent ( - EVT_SIGNAL_EXIT_BOOT_SERVICES, - TPL_NOTIFY, - LcdGraphicsExitBootServicesEvent, NULL, - &Instance->ExitBootServicesEvent - ); + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_NOTIFY, + LcdGraphicsExitBootServicesEvent, + NULL, + &Instance->ExitBootServicesEvent + ); =20 - if (EFI_ERROR(Status)) { - DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the = ExitBootServicesEvent handler. Exit Status=3D%r\n", Status)); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install = the ExitBootServicesEvent handler. Exit Status=3D%r\n", Status)); goto EXIT_ERROR_UNINSTALL_PROTOCOL; } =20 @@ -198,48 +207,46 @@ LcdGraphicsOutputDxeInitialize ( goto EXIT; =20 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, // Uninsta= ll device path - NULL - ); + Instance->Handle, + &gEfiGraphicsOutputProtocolGuid, + &Instance->Gop, // Uninstall Graphics Output protocol + &gEfiDevicePathProtocolGuid, + &Instance->DevicePath, // Uninstall device path + NULL + ); =20 EXIT: return Status; - } =20 -/*************************************** - * 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 dis= play + // controller to avoid to display corrupted information on the screen. if (FeaturePcdGet (PcdGopDisableOnExitBootServices)) { // Turn-off the Display controller LcdShutdown (); } } =20 -/*************************************** - * 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 =3D EFI_SUCCESS; LCD_INSTANCE *Instance; =20 - Instance =3D LCD_INSTANCE_FROM_GOP_THIS(This); + Instance =3D LCD_INSTANCE_FROM_GOP_THIS (This); =20 // Setup the hardware if not already done - if( !mDisplayInitialized ) { - Status =3D InitializeDisplay(Instance); - if (EFI_ERROR(Status)) { + if (!mDisplayInitialized) { + Status =3D InitializeDisplay (Instance); + if (EFI_ERROR (Status)) { goto EXIT; } } =20 // Error checking - if ( (This =3D=3D NULL) || (Info =3D=3D NULL) || (SizeOfInfo =3D=3D NULL= ) || (ModeNumber >=3D This->Mode->MaxMode) ) { - DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d = : Invalid Parameter.\n", ModeNumber )); + if ((This =3D=3D NULL) || + (Info =3D=3D NULL) || + (SizeOfInfo =3D=3D NULL) || + (ModeNumber >=3D This->Mode->MaxMode)) { + DEBUG ((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d= : Invalid Parameter.\n", ModeNumber)); Status =3D EFI_INVALID_PARAMETER; goto EXIT; } @@ -275,21 +285,20 @@ LcdGraphicsQueryMode ( goto EXIT; } =20 - *SizeOfInfo =3D sizeof( EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); + *SizeOfInfo =3D sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); =20 - Status =3D LcdPlatformQueryMode (ModeNumber,*Info); - if (EFI_ERROR(Status)) { - FreePool(*Info); + Status =3D LcdPlatformQueryMode (ModeNumber, *Info); + if (EFI_ERROR (Status)) { + FreePool (*Info); } =20 EXIT: return Status; } =20 -/*************************************** - * 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 =3D LCD_INSTANCE_FROM_GOP_THIS (This); =20 // Setup the hardware if not already done - if(!mDisplayInitialized) { + if (!mDisplayInitialized) { Status =3D InitializeDisplay (Instance); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { goto EXIT; } } =20 // Check if this mode is supported - if( ModeNumber >=3D This->Mode->MaxMode ) { - DEBUG((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode numb= er %d .\n", ModeNumber )); + if (ModeNumber >=3D This->Mode->MaxMode) { + DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode num= ber %d .\n", ModeNumber)); Status =3D EFI_UNSUPPORTED; goto EXIT; } =20 // Set the oscillator frequency to support the new mode Status =3D LcdPlatformSetMode (ModeNumber); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { Status =3D EFI_DEVICE_ERROR; goto EXIT; } =20 // Update the UEFI mode information This->Mode->Mode =3D ModeNumber; - LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo); - Status =3D LcdPlatformGetBpp(ModeNumber, &Bpp); - if (EFI_ERROR(Status)) { + LcdPlatformQueryMode (ModeNumber, &Instance->ModeInfo); + Status =3D LcdPlatformGetBpp (ModeNumber, &Bpp); + if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes p= er pixel, status: %r\n", Status)); goto EXIT; } This->Mode->FrameBufferSize =3D Instance->ModeInfo.VerticalResolution - * Instance->ModeInfo.PixelsPerScanLine - * GetBytesPerPixel(Bpp); + * Instance->ModeInfo.PixelsPerScanLine + * GetBytesPerPixel (Bpp); =20 // Set the hardware to the new mode Status =3D LcdSetMode (ModeNumber); - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { Status =3D EFI_DEVICE_ERROR; goto EXIT; } =20 - // 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. =20 // 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 + ); =20 EXIT: return Status; @@ -372,7 +383,7 @@ GetBytesPerPixel ( IN LCD_BPP Bpp ) { - switch(Bpp) { + switch (Bpp) { case LCD_BITS_PER_PIXEL_24: return 4; =20 diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputD= xe.h b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h index b66efd34561f655b74a5ecfad8a97281cdd5929d..16d92f45c47948630d6262a63fd= 1af4e076706d1 100644 --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2011, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -11,9 +11,8 @@ =20 **/ =20 -#ifndef __ARM_VE_GRAPHICS_DXE_H__ -#define __ARM_VE_GRAPHICS_DXE_H__ - +#ifndef LCD_GRAPHICS_OUTPUT_DXE_H_ +#define LCD_GRAPHICS_OUTPUT_DXE_H_ =20 #include =20 @@ -25,7 +24,6 @@ =20 #include =20 - // // Device structures // @@ -106,4 +104,4 @@ InitializeDisplay ( IN LCD_INSTANCE* Instance ); =20 -#endif /* __ARM_VE_GRAPHICS_DXE_H__ */ +#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */ diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformP= kg/Include/Library/LcdPlatformLib.h index b9bdf471e2d65dba7a0fcb0f7ecc352bd576b46b..3d13e417972c67cc51ae4410efd= 548053511e5d1 100644 --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2011, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2018, ARM 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 @@ -11,8 +11,8 @@ =20 **/ =20 -#ifndef __LCDPLATFORMLIB_H -#define __LCDPLATFORMLIB_H +#ifndef LCD_PLATFORM_LIB_H_ +#define LCD_PLATFORM_LIB_H_ =20 #include =20 @@ -158,8 +158,9 @@ #define LCD_12BPP_444_BLUE_MASK 0x0000000F #define LCD_12BPP_444_RESERVED_MASK 0x0000F000 =20 - -// The enumeration indexes maps the PL111 LcdBpp values used in the LCD Co= ntrol Register +/** The enumeration indexes maps the PL111 LcdBpp values used in the LCD C= ontrol + Register +**/ typedef enum { LCD_BITS_PER_PIXEL_1 =3D 0, LCD_BITS_PER_PIXEL_2, @@ -171,7 +172,6 @@ typedef enum { LCD_BITS_PER_PIXEL_12_444 } LCD_BPP; =20 - EFI_STATUS LcdPlatformInitializeDisplay ( IN EFI_HANDLE Handle @@ -218,4 +218,4 @@ LcdPlatformGetBpp ( OUT LCD_BPP* Bpp ); =20 -#endif +#endif /* LCD_PLATFORM_LIB_H_ */ diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.c b/ArmPlatformPkg/Library/= HdLcd/HdLcd.c index 24efb68f23e3393a96fc760732d978b6346a2807..2cd1be9d255dd5734176d752d60= f06f11a047fcb 100644 --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c @@ -1,6 +1,6 @@ -/** @file Lcd.c +/** @file =20 - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -21,12 +21,9 @@ =20 #include "HdLcd.h" =20 -/********************************************************************** - * - * 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. +**/ =20 STATIC UINTN @@ -34,7 +31,7 @@ GetBytesPerPixel ( IN LCD_BPP Bpp ) { - switch(Bpp) { + switch (Bpp) { case LCD_BITS_PER_PIXEL_24: return 4; =20 @@ -60,21 +57,27 @@ LcdInitialize ( ) { // Disable the controller - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE); + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); =20 // Disable all interrupts - MmioWrite32(HDLCD_REG_INT_MASK, 0); + MmioWrite32 (HDLCD_REG_INT_MASK, 0); =20 // 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); =20 // 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_P= ER_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)); =20 return EFI_SUCCESS; } @@ -96,46 +99,53 @@ LcdSetMode ( UINT32 BytesPerPixel; LCD_BPP LcdBpp; =20 - // Set the video mode timings and other relevant information - Status =3D LcdPlatformGetTimings (ModeNumber, - &HRes,&HSync,&HBackPorch,&HFrontPorch, - &VRes,&VSync,&VBackPorch,&VFrontPorch); + Status =3D 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; } =20 - Status =3D LcdPlatformGetBpp (ModeNumber,&LcdBpp); + Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); ASSERT_EFI_ERROR (Status); - if (EFI_ERROR( Status )) { + if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } =20 - BytesPerPixel =3D GetBytesPerPixel(LcdBpp); + BytesPerPixel =3D GetBytesPerPixel (LcdBpp); =20 // Disable the controller - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE); + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); =20 // 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); =20 // 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); =20 // 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); =20 // Enable the controller - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_ENABLE); + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE); =20 return EFI_SUCCESS; } diff --git a/ArmPlatformPkg/Library/HdLcd/HdLcd.h b/ArmPlatformPkg/Library/= HdLcd/HdLcd.h index 6df97a9dfee60e9fda615cf3bea1b6a164a42333..cd2c0366c7b563d7fb313f82abe= ef7eb1aa3ef72 100644 --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.h +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.h @@ -1,6 +1,6 @@ -/** @file HDLcd.h +/** @file =20 - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD= License @@ -12,13 +12,10 @@ =20 **/ =20 -#ifndef _HDLCD_H_ -#define _HDLCD_H_ +#ifndef HDLCD_H_ +#define HDLCD_H_ =20 -// // HDLCD Controller Register Offsets -// - #define HDLCD_REG_VERSION ((UINTN)PcdGet32 (PcdArmHdLcdBas= e) + 0x000) #define HDLCD_REG_INT_RAWSTAT ((UINTN)PcdGet32 (PcdArmHdLcdBas= e) + 0x010) #define HDLCD_REG_INT_CLEAR ((UINTN)PcdGet32 (PcdArmHdLcdBas= e) + 0x014) @@ -44,10 +41,7 @@ #define HDLCD_REG_GREEN_SELECT ((UINTN)PcdGet32 (PcdArmHdLcdBas= e) + 0x248) #define HDLCD_REG_BLUE_SELECT ((UINTN)PcdGet32 (PcdArmHdLcdBas= e) + 0x24C) =20 - -// // HDLCD Values of registers -// =20 // HDLCD Interrupt mask, clear and status register #define HDLCD_DMA_END BIT0 /* DMA has finished read= ing a frame */ @@ -79,6 +73,11 @@ #define HDLCD_DATA_LOW 0 #define HDLCD_PXCLK_LOW 0 =20 +// 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) =20 -#endif /* _HDLCD_H_ */ +#endif /* HDLCD_H_ */ diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Li= brary/PL111Lcd/PL111Lcd.c index 9b4a02045ab7ca170e0d4362ee0e2bcf1d275bdb..3f3f7019f1d252995eab6d8c3d4= 9db8be8e09e40 100644 --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c @@ -1,6 +1,6 @@ -/** @file PL111Lcd.c +/** @file =20 - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -19,13 +19,10 @@ =20 #include "PL111Lcd.h" =20 -/********************************************************************** - * - * 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. =20 +**/ 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 buff= er + MmioWrite32 (PL111_REG_LCD_UP_BASE, (UINT32)VramBaseAddress); + MmioWrite32 (PL111_REG_LCD_LP_BASE, 0); // We are not using a double buf= fer =20 // Disable all interrupts from the PL111 - MmioWrite32(PL111_REG_LCD_IMSC, 0); + MmioWrite32 (PL111_REG_LCD_IMSC, 0); =20 return EFI_SUCCESS; } @@ -81,37 +78,54 @@ LcdSetMode ( LCD_BPP LcdBpp; =20 // Set the video mode timings and other relevant information - Status =3D LcdPlatformGetTimings (ModeNumber, - &HRes,&HSync,&HBackPorch,&HFrontPorch, - &VRes,&VSync,&VBackPorch,&VFrontPorch); + Status =3D 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; } =20 - Status =3D LcdPlatformGetBpp (ModeNumber,&LcdBpp); + Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); ASSERT_EFI_ERROR (Status); - if (EFI_ERROR( Status )) { + if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } =20 // Disable the CLCD_LcdEn bit - LcdControl =3D MmioRead32( PL111_REG_LCD_CONTROL); - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1); + LcdControl =3D MmioRead32 (PL111_REG_LCD_CONTROL); + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1); =20 // Set Timings - MmioWrite32 (PL111_REG_LCD_TIMING_0, HOR_AXIS_PANEL(HBackPorch, HFrontPo= rch, HSync, HRes)); - MmioWrite32 (PL111_REG_LCD_TIMING_1, VER_AXIS_PANEL(VBackPorch, VFrontPo= rch, 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); =20 // PL111_REG_LCD_CONTROL - LcdControl =3D PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) | PL111_CT= RL_LCD_TFT | PL111_CTRL_BGR; - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl); + LcdControl =3D PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) | + PL111_CTRL_LCD_TFT | PL111_CTRL_BGR; + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl); =20 // Turn on power to the LCD Panel LcdControl |=3D PL111_CTRL_LCD_PWR; - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl); + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl); =20 return EFI_SUCCESS; } --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562377698447.07224107544835; Tue, 20 Mar 2018 09:12:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1FFD6224BBC25; Tue, 20 Mar 2018 09:06:02 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 87B24220C2A79 for ; Tue, 20 Mar 2018 09:05:52 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLs016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:00 +0000 Message-Id: <20180320161212.79120-5-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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/LcdGraphicsOutputD= xe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c index 905eb26ee01b5037dfbaf3c054a62593837c8b5f..872361cd23fbdf52c5f128d0e17= 2701e76d832b2 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 =20 - Copyright (c) 2011-2018, ARM 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 + Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php =20 - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPL= IED. + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 **/ =20 @@ -22,11 +23,6 @@ =20 #include "LcdGraphicsOutputDxe.h" =20 -/** This file implements the Graphics Output protocol on ArmVersatileExpre= ss - using the Lcd controller - -**/ - // // Global variables // diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformP= kg/Include/Library/LcdPlatformLib.h index 3d13e417972c67cc51ae4410efd548053511e5d1..e51e78640ae7b1acd51ac333ba3= faa8c78aea5a5 100644 --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h @@ -18,9 +18,7 @@ =20 #define LCD_VRAM_SIZE SIZE_8MB =20 -// // Modes definitions -// #define VGA 0 #define SVGA 1 #define XGA 2 @@ -29,9 +27,7 @@ #define UXGA 5 #define HD 6 =20 -// // 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) =20 -// // 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) =20 -// // 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) =20 -// // 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) =20 -// // 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) =20 -// // 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) =20 -// // 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) =20 -// // 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 =20 -/** The enumeration indexes maps the PL111 LcdBpp values used in the LCD C= ontrol +/** 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; =20 +/** 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 ); =20 +/** 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 successfu= lly. + @retval !(EFI_SUCCESS) Other errors. +**/ EFI_STATUS LcdPlatformGetVram ( OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, OUT UINTN* VramSize ); =20 +/** 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 ); =20 +/** 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 ); =20 +/** 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 ); =20 +/** 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 reque= sted + 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 ); =20 +/** Return bits per pixel information for a mode number. + + @param[in] ModeNumber Mode Number. + + @param[out] Bpp Pointer to value bits per pixel informat= ion. + + @retval EFI_SUCCESS Bit per pixel information for the reques= ted + 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..be4ccfdc1f421060faec792c8e8= acfcfb3232014 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 =20 Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
=20 @@ -21,10 +22,6 @@ =20 #include "HdLcd.h" =20 -/** This file contains all the bits of the Lcd that are - platform independent. -**/ - STATIC UINTN GetBytesPerPixel ( @@ -51,6 +48,12 @@ GetBytesPerPixel ( } } =20 +/** 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; } =20 +/** 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; } =20 +/** De-initializes the display. +**/ VOID LcdShutdown ( VOID @@ -159,6 +172,11 @@ LcdShutdown ( MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); } =20 +/** 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..b76894c534fb413d87c77c528f0= bb7d49862c78f 100644 --- a/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c +++ b/ArmPlatformPkg/Library/LcdPlatformNullLib/LcdPlatformNullLib.c @@ -1,6 +1,7 @@ /** @file =20 Copyright (c) 2017, Linaro, Ltd. All rights reserved. + Copyright (c) 2018, Arm Limited. All rights reserved. =20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -17,6 +18,12 @@ #include #include =20 +/** 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; } =20 +/** 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; } =20 +/** 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; } =20 +/** 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; } =20 +/** 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; } =20 +/** 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; } =20 +/** Return bits per pixel information for a mode number. + + @param[in] ModeNumber Mode Number. + + @param[out] Bpp Pointer to value bits per pixel informat= ion. + + @retval EFI_UNSUPPORTED Interface is not supported. + +**/ EFI_STATUS LcdPlatformGetBpp ( IN UINT32 ModeNumber, diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Li= brary/PL111Lcd/PL111Lcd.c index 3f3f7019f1d252995eab6d8c3d49db8be8e09e40..ccd7a4d1d43ad5c2f495683ac68= 236e17f3b55a5 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 =20 Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
=20 @@ -19,9 +20,12 @@ =20 #include "PL111Lcd.h" =20 -/** This file contains all the bits of the PL111 that are - platform independent. +/** Check for presence of PL111. =20 + @retval EFI_SUCCESS Returns success if platform implements a + PL111 controller. + + @retval EFI_NOT_FOUND PL111 display controller not found the plaf= orm. **/ EFI_STATUS LcdIdentify ( @@ -45,6 +49,12 @@ LcdIdentify ( return EFI_NOT_FOUND; } =20 +/** 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; } =20 +/** 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; } =20 +/** De-initializes the display. +*/ VOID LcdShutdown ( VOID --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562364310441.2863424266234; Tue, 20 Mar 2018 09:12:44 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 85A4C2264D238; Tue, 20 Mar 2018 09:06:00 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 97F3A22571B5A for ; Tue, 20 Mar 2018 09:05:52 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLt016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:01 +0000 Message-Id: <20180320161212.79120-6-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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..28306c530e08b5e0fcef4308435= 045da3c9e093c 100644 --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c @@ -90,8 +90,7 @@ LcdInitialize ( @param[in] ModeNumber Display mode number. =20 @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; } =20 Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + ASSERT_EFI_ERROR (Status); + return Status; } =20 BytesPerPixel =3D GetBytesPerPixel (LcdBpp); diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Li= brary/PL111Lcd/PL111Lcd.c index ccd7a4d1d43ad5c2f495683ac68236e17f3b55a5..cb64c57dd79f3bb1345e4d3dbda= 7f5b3ce859f40 100644 --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c @@ -75,8 +75,8 @@ LcdInitialize ( @param[in] ModeNumbe Display mode number. =20 @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; } =20 Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + ASSERT_EFI_ERROR (Status); + return Status; } =20 // Disable the CLCD_LcdEn bit --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562354656277.1320421180161; Tue, 20 Mar 2018 09:12:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 46CE022603AF4; Tue, 20 Mar 2018 09:05:56 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8C4752253FB7A for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLu016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:02 +0000 Message-Id: <20180320161212.79120-7-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak Minor code change, replaces magic number with macro in LCD disable. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak Signed-off-by: Evan Lloyd Reviewed-by: Ard Biesheuvel Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Li= brary/PL111Lcd/PL111Lcd.c index cb64c57dd79f3bb1345e4d3dbda7f5b3ce859f40..287e3ca272c0c19f8045a3bf4e6= 9a092d8da6fd8 100644 --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c @@ -119,8 +119,7 @@ LcdSetMode ( } =20 // Disable the CLCD_LcdEn bit - LcdControl =3D MmioRead32 (PL111_REG_LCD_CONTROL); - MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1); + MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN); =20 // Set Timings MmioWrite32 ( --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152156235152989.6462811496325; Tue, 20 Mar 2018 09:12:31 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CF04922631488; Tue, 20 Mar 2018 09:05:55 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 89C3F2253FB79 for ; Tue, 20 Mar 2018 09:05:52 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLv016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:03 +0000 Message-Id: <20180320161212.79120-8-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Li= brary/PL111Lcd/PL111Lcd.c index 287e3ca272c0c19f8045a3bf4e69a092d8da6fd8..465cb6845437f57d15f05a271d1= b01f634e11b56 100644 --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c @@ -137,11 +137,7 @@ LcdSetMode ( =20 // PL111_REG_LCD_CONTROL LcdControl =3D 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 |=3D PL111_CTRL_LCD_PWR; + PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR | PL111_CTRL_BGR; MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl); =20 return EFI_SUCCESS; --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562348407250.74208329845055; Tue, 20 Mar 2018 09:12:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6EEE322631482; Tue, 20 Mar 2018 09:05:55 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 85A4520954B8C for ; Tue, 20 Mar 2018 09:05:52 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLw016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:04 +0000 Message-Id: <20180320161212.79120-9-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Ard Biesheuvel Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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..039048398c531ec944bc4b43a55= 51a554a368481 100644 --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c @@ -175,11 +175,17 @@ LcdShutdown ( =20 @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) =3D=3D 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..1efa78eedc3013b3ab4615181a5= 9c7d15b851ab5 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) =20 +#define HDLCD_PRODUCT_ID 0x1CDC + #endif /* HDLCD_H_ */ --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562374573415.2258113222207; Tue, 20 Mar 2018 09:12:54 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AFB2B2264D25E; Tue, 20 Mar 2018 09:06:01 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9A4E922571B5B for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHLx016075; Tue, 20 Mar 2018 16:12:20 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:05 +0000 Message-Id: <20180320161212.79120-10-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Ard Biesheuvel Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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/ArmPlatformP= kg/Include/Library/LcdPlatformLib.h index e51e78640ae7b1acd51ac333ba3faa8c78aea5a5..8338b327fd2dd0d6b31653e278e= 25da5ac850939 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; =20 +// Display timing settings. +typedef struct { + UINT32 Resolution; + UINT32 Sync; + UINT32 BackPorch; + UINT32 FrontPorch; +} SCAN_TIMINGS; + /** Platform related initialization function. =20 @param[in] Handle Handle to the LCD device instance. @@ -228,14 +236,11 @@ LcdPlatformQueryMode ( =20 @param[in] ModeNumber Mode Number. =20 - @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 por= ch) + @param[out] Vertical Pointer to vertical timing parameters. + (Resolution, Sync, Back porch, Front por= ch) + =20 @retval EFI_SUCCESS Display timing information for the reque= sted 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 ); =20 /** 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..f5886848ce582b475b597ccca01= 5c816707ade0e 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; =20 // Set the video mode timings and other relevant information Status =3D LcdPlatformGetTimings ( ModeNumber, - &HRes, - &HSync, - &HBackPorch, - &HFrontPorch, - &VRes, - &VSync, - &VBackPorch, - &VFrontPorch + &Horizontal, + &Vertical ); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); return Status; } =20 + ASSERT (Horizontal !=3D NULL); + ASSERT (Vertical !=3D NULL); + Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); @@ -138,21 +129,26 @@ LcdSetMode ( MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); =20 // 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 * BytesPerP= ixel); + + MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1); =20 // 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); =20 // 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); =20 // 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..492edd1ba2e57158c21920d6df1= 1eed5673649c1 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/Li= brary/PL111Lcd/PL111Lcd.c index 465cb6845437f57d15f05a271d1b01f634e11b56..c9e2736911881fc36b51562b925= 9b7bccf30747d 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; =20 // Set the video mode timings and other relevant information Status =3D LcdPlatformGetTimings ( ModeNumber, - &HRes, - &HSync, - &HBackPorch, - &HFrontPorch, - &VRes, - &VSync, - &VBackPorch, - &VFrontPorch + &Horizontal, + &Vertical ); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); return Status; } =20 + ASSERT (Horizontal !=3D NULL); + ASSERT (Vertical !=3D NULL); + Status =3D 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 + ) ); =20 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) ); =20 - MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes)); MmioWrite32 (PL111_REG_LCD_TIMING_3, 0); =20 // PL111_REG_LCD_CONTROL --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562367829106.31606427058728; Tue, 20 Mar 2018 09:12:47 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F386C2264D247; Tue, 20 Mar 2018 09:06:00 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A07862258AF0B for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM0016075; Tue, 20 Mar 2018 16:12:21 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:06 +0000 Message-Id: <20180320161212.79120-11-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Ard Biesheuvel Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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/ArmPlatform= Pkg.dec index 7cec775abeee219e6821488a2c5abe88d23bbed1..378bee9cbc9e4bd50c37b381560= 16424e24cba73 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|0x= 00000028 gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00= 000029 =20 + # Graphics Output Pixel format + # 0 : PixelRedGreenBlueReserved8BitPerColor + # 1 : PixelBlueGreenRedReserved8BitPerColor + # 2 : PixelBitMask + # Default is set to UEFI console font format PixelBlueGreenRedReserved8B= itPerColor + 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..96f2bf437fbabd2509f860c67c5= 442def5b5f03d 100644 --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c @@ -22,31 +22,7 @@ =20 #include "HdLcd.h" =20 -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 =20 /** Initialize display. =20 @@ -78,10 +54,6 @@ LcdInitialize ( HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL ); =20 - 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; } =20 @@ -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; =20 // Set the video mode timings and other relevant information Status =3D LcdPlatformGetTimings ( @@ -117,13 +89,22 @@ LcdSetMode ( ASSERT (Horizontal !=3D NULL); ASSERT (Vertical !=3D NULL); =20 - Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); + // Get the pixel format information. + Status =3D LcdPlatformQueryMode (ModeNumber, &ModeInfo); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); return Status; } =20 - BytesPerPixel =3D GetBytesPerPixel (LcdBpp); + if (ModeInfo.PixelFormat =3D=3D 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); =20 // 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 ); =20 - MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerP= ixel); + MmioWrite32 ( + HDLCD_REG_FB_LINE_PITCH, + Horizontal->Resolution * BYTES_PER_PIXEL + ); =20 MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1); =20 diff --git a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c b/ArmPlatformPkg/Li= brary/PL111Lcd/PL111Lcd.c index c9e2736911881fc36b51562b9259b7bccf30747d..0496376fffe514651a70f58a331= 6894a4b2b319c 100644 --- a/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c +++ b/ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c @@ -76,7 +76,6 @@ LcdInitialize ( =20 @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; =20 + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo; + // Set the video mode timings and other relevant information Status =3D LcdPlatformGetTimings ( ModeNumber, @@ -109,6 +110,13 @@ LcdSetMode ( return Status; } =20 + // Get the pixel format information + Status =3D 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); =20 @@ -142,7 +150,10 @@ LcdSetMode ( =20 // PL111_REG_LCD_CONTROL LcdControl =3D 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 =3D=3D PixelBlueGreenRedReserved8BitPerColor) { + LcdControl |=3D PL111_CTRL_BGR; + } MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl); =20 return EFI_SUCCESS; --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562371032248.6122285467361; Tue, 20 Mar 2018 09:12:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5BAEB2264D253; Tue, 20 Mar 2018 09:06:01 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D005E22603AEB for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM1016075; Tue, 20 Mar 2018 16:12:21 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:07 +0000 Message-Id: <20180320161212.79120-12-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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] =20 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/ArmPlatform= Pkg.dec index 378bee9cbc9e4bd50c37b38156016424e24cba73..5231ea822f05c2f281a6190d6ea= e0fc7d0bc0cb3 100644 --- a/ArmPlatformPkg/ArmPlatformPkg.dec +++ b/ArmPlatformPkg/ArmPlatformPkg.dec @@ -104,6 +104,9 @@ [PcdsFixedAtBuild.common] # Default is set to UEFI console font format PixelBlueGreenRedReserved8B= itPerColor gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040 =20 + ## If set, this will swap settings for HDLCD RED_SELECT and BLUE_SELECT = registers + gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|FALSE|BOOLEAN|0x= 00000045 + [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..5396dde3ba6cd147a8333241a9b= c71ab05d7fee3 100644 --- a/ArmPlatformPkg/Library/HdLcd/HdLcd.c +++ b/ArmPlatformPkg/Library/HdLcd/HdLcd.c @@ -73,6 +73,8 @@ LcdSetMode ( SCAN_TIMINGS *Horizontal; SCAN_TIMINGS *Vertical; =20 + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo; =20 // Set the video mode timings and other relevant information @@ -96,7 +98,14 @@ LcdSetMode ( return Status; } =20 - if (ModeInfo.PixelFormat =3D=3D 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 pl= atform + PixelFormat =3D FixedPcdGetBool (PcdArmHdLcdSwapBlueRedSelect) + ? PixelRedGreenBlueReserved8BitPerColor + : PixelBlueGreenRedReserved8BitPerColor; + + if (ModeInfo.PixelFormat =3D=3D 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/Librar= y/HdLcd/HdLcd.inf index 67aad05d210b95b2d23b8e52e4392685efcf3795..7f2ba7bf1c602f4c214eacaa642= 5bf9ec7e6da15 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.
+# Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -40,3 +40,5 @@ [LibraryClasses] =20 [FixedPcd] gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase + gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect + --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562384676604.2697812665557; Tue, 20 Mar 2018 09:13:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EB38F224BBC2F; Tue, 20 Mar 2018 09:06:02 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0FC7022603AF4 for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM2016075; Tue, 20 Mar 2018 16:12:21 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:08 +0000 Message-Id: <20180320161212.79120-13-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 12/16] ArmPlatformPkg: Additional display modes X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Ard Biesheuvel Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 60 ++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformP= kg/Include/Library/LcdPlatformLib.h index 8338b327fd2dd0d6b31653e278e25da5ac850939..cc535f0cd42db5673d418cbec94= 0023927408687 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 =20 // 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) =20 +// 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 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562388822329.0248306042232; Tue, 20 Mar 2018 09:13:08 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 498B5224BBC33; Tue, 20 Mar 2018 09:06:03 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6EB1D20954B8C for ; Tue, 20 Mar 2018 09:05:53 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM3016075; Tue, 20 Mar 2018 16:12:21 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:09 +0000 Message-Id: <20180320161212.79120-14-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- ArmPlatformPkg/ArmPlatformPkg.dec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatform= Pkg.dec index 5231ea822f05c2f281a6190d6eae0fc7d0bc0cb3..5c702718a78a78e6c67ab407e19= 8382e0a0df4be 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 =20 + ## Default size for display modes upto 1920x1080 (1920 * 1080 * 4 Bytes = Per Pixel) + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x7E9000|UINT32|0= x00000043 + ## If set, framebuffer memory will be reserved and mapped in the system = RAM + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x0000= 0044 + ## PL180 MCI gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x= 00000028 gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00= 000029 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562392007394.85053900640264; Tue, 20 Mar 2018 09:13:12 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B1E05224BBC38; Tue, 20 Mar 2018 09:06:03 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6EA3F225B02AB for ; Tue, 20 Mar 2018 09:05:54 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM4016075; Tue, 20 Mar 2018 16:12:21 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:10 +0000 Message-Id: <20180320161212.79120-15-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- Notes: v3: - Please add this library as a component to ArmPlatformPkg.dsc as well, so we can do build testing on it. [Ard] =20 Done [Girish] =20 - Please drop references to edk2-platforms. This driver should be able to be used independently from VExpress platform code [Ard] =20 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/ArmPlatform= Pkg.dec index 5c702718a78a78e6c67ab407e198382e0a0df4be..28cdc259849da11b172ad52045b= ccc0276669852 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|0x0000= 0044 =20 + ## ARM Mali Display Processor DP500/DP550/DP650 + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x00000050 + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|UINT32|0x0= 0000051 + ## PL180 MCI gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x= 00000028 gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00= 000029 diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatform= Pkg.dsc index 82adb9ef8891b7ba1628ede2f8eb124c25c2774a..0013106b94c371f827e01c6d402= faa6aa42e4bdd 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.
-# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.
+# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.
# Copyright (c) 2016 - 2017, Linaro Ltd. All rights reserved.
# # This program and the accompanying materials @@ -120,3 +120,5 @@ [Components.common] =20 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..69c88416a448caa506bf8a77243= 2144d8a138495 --- /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.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#include +#include +#include +#include +#include + +#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 lay= er. + @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 bl= ue, + // 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 =3D=3D PixelBlueGreenRedReserved8BitPerColor) { + PixelFormat =3D (mDpDeviceId =3D=3D MALIDP_500) ? DP_PIXEL_FORMAT_DP50= 0_XRGB_8888 + : DP_PIXEL_FORMAT_XRGB_8888; + } else { + PixelFormat =3D (mDpDeviceId =3D=3D MALIDP_500) ? DP_PIXEL_FORMAT_DP50= 0_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 por= ch) + @param[in] Vertical Pointer to vertical timing parameters. + (Resolution, Sync, Back porch, Front por= ch) +**/ +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 =3D=3D MALIDP_500) { + // MALI DP500 timing registers. + RegHIntervals =3D DP_BASE + DP_DE_DP500_H_INTERVALS; + RegVIntervals =3D DP_BASE + DP_DE_DP500_V_INTERVALS; + RegSyncControl =3D DP_BASE + DP_DE_DP500_SYNC_CONTROL; + RegHVActiveSize =3D DP_BASE + DP_DE_DP500_HV_ACTIVESIZE; + } else { + // MALI DP550/DP650 timing registers. + RegHIntervals =3D DP_BASE + DP_DE_H_INTERVALS; + RegVIntervals =3D DP_BASE + DP_DE_V_INTERVALS; + RegSyncControl =3D DP_BASE + DP_DE_SYNC_CONTROL; + RegHVActiveSize =3D 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 =3D MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID); + DpCoreId >>=3D DP_DE_DP500_CORE_ID_SHIFT; + + if (DpCoreId =3D=3D MALIDP_500) { + return DpCoreId; + } + + // Check for DP550 or DP650. + DpCoreId =3D MmioRead32 (DP_BASE + DP_DC_CORE_ID); + DpCoreId >>=3D DP_DC_CORE_ID_SHIFT; + + if ((DpCoreId =3D=3D MALIDP_550) || (DpCoreId =3D=3D 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 fo= und + 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 =3D=3D 0) { + mDpDeviceId =3D ArmMaliDpGetCoreId (); + } + + if (mDpDeviceId =3D=3D 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 =3D %p\n", FrameBaseAddres= s)); + + if (mDpDeviceId =3D=3D 0) { + mDpDeviceId =3D ArmMaliDpGetCoreId (); + } + + if (mDpDeviceId =3D=3D 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 =3D=3D 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 =3D=3D MALIDP_500) { + MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL, ~DP_DE_DP500_CONTROL_CONFIG_R= EQ); + } 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 =3D=3D 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 =3D LcdPlatformGetTimings ( + ModeNumber, + &Horizontal, + &Vertical + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + ASSERT (Horizontal !=3D NULL); + ASSERT (Vertical !=3D NULL); + + // Get the pixel format information. + Status =3D 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..4504c6965bf58b1ac19cf717360= c7a603ff2cd61 --- /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.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ +#ifndef ARMMALIDP_H_ +#define ARMMALIDP_H_ + +#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBas= e)) + +// 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) | Hf= p) +#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT) | Vf= p) +#define SYNC_WIDTH(Hsw, Vsw) ((Vsw << DP_DE_VSYNCWIDTH_SHIFT) | Hs= w) +#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) | Ho= r) + +// 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/ArmPlatformPk= g/Library/ArmMaliDp/ArmMaliDp.inf new file mode 100644 index 0000000000000000000000000000000000000000..4cf020e4c314b17f7944336512c= a8688911cf1be --- /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.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +# +#**/ + +[Defines] + INF_VERSION =3D 0x00010019 + BASE_NAME =3D ArmMaliDp + FILE_GUID =3D E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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 + --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152156239571151.08213881432857; Tue, 20 Mar 2018 09:13:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 15B20224BBC3B; Tue, 20 Mar 2018 09:06:04 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 729A722603B00 for ; Tue, 20 Mar 2018 09:05:54 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM5016075; Tue, 20 Mar 2018 16:12:22 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:11 +0000 Message-Id: <20180320161212.79120-16-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> Subject: [edk2] [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- 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..881751d81c6384a3eb0b4c180c7= 6d01a58266a74 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.
-# 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 =20 [Guids.common] gArmTokenSpaceGuid =3D { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6,= 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } } diff --git a/ArmPkg/Include/Library/ArmMtlLib.h b/ArmPkg/Include/Library/Ar= mMtlLib.h new file mode 100644 index 0000000000000000000000000000000000000000..4218a741e5ebddd08022b94354d= 5ef47576cd3b8 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 + +// 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 =3D 0, + MTL_CHANNEL_TYPE_HIGH =3D 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..f1862371113e342e4a4c8059be2= 7884842210d08 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 +#include + +/** 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/Librar= y/ArmMtlNullLib/ArmMtlNullLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..9c0426b00e48e791dae9ad11e2f= 47d248d9c09ce --- /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 B= SD 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 IM= PLIED. +#**/ + +[Defines] + INF_VERSION =3D 0x00010019 + BASE_NAME =3D ArmMtlNullLib + FILE_GUID =3D 05810525-FDEC-4006-9F1F-37609B3675FA + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ArmMtlLib + +[Sources.common] + ArmMtlNullLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 19:44:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1521562399831265.35010673239753; Tue, 20 Mar 2018 09:13:19 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 64E17224BBC3F; Tue, 20 Mar 2018 09:06:04 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CF5522253FB7A for ; Tue, 20 Mar 2018 09:05:54 -0700 (PDT) Received: from E107875.Emea.Arm.com (e107875.emea.arm.com [10.10.1.104]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w2KGCHM6016075; Tue, 20 Mar 2018 16:12:22 GMT X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=girish.pathak@arm.com; receiver=edk2-devel@lists.01.org From: Girish Pathak To: edk2-devel@lists.01.org Date: Tue, 20 Mar 2018 16:12:12 +0000 Message-Id: <20180320161212.79120-17-girish.pathak@arm.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com> References: <20180320161212.79120-1-girish.pathak@arm.com> MIME-Version: 1.0 Subject: [edk2] [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Stephanie.Hughes-Fitt@arm.com, leif.lindholm@linaro.org, ard.biesheuvel@linaro.org Content-Type: multipart/mixed; boundary="===============4274754219559222770==" Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 --===============4274754219559222770== Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Evan Lloyd Reviewed-by: Evan Lloyd Reviewed-by: Leif Lindholm --- Notes: v3: - Please rename ArmMtl.h to ArmMtlLibi.h, and declare it as a library class in the package file. [Ard] =20 Done, however ArmMtlLib.h is now part of earlier commit [Girish] =20 - Move ArmScmiDxe to ArmPkg from ArmPlatformPkg [Ard] =20 Done [Girish] =20 - Declare gArmScmiBaseProtocolGuid and similar protocols Guids in ArmPkg.dec [Ard] =20 Done [Girish] =20 - Replace flexible array member [] with [1] [Ard] =20 Done [Girish] =20 - Move protocol init function which are not part of of protocol like ScmiBaseProtocolInit elsewhere [Ard] =20 Done [Girish] =20 - Please don't put stuff in Include/Drivers. [Ard] =20 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..16f7e40046429142b44b526043b= 61a3d5e089d2c 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -51,6 +51,19 @@ [Guids.common] =20 gArmGicDxeFileGuid =3D { 0xde371f7c, 0xdec4, 0x4d21, { 0xad, 0xf1, 0x59,= 0x3a, 0xbc, 0xc1, 0x58, 0x82 } } =20 +[Protocols.common] + ## Arm System Control and Management Interface(SCMI) Base protocol + ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h + gArmScmiBaseProtocolGuid =3D { 0xd7e5abe9, 0x33ab, 0x418e, { 0x9f, 0x91,= 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } } + + ## Arm System Control and Management Interface(SCMI) Clock management pr= otocol + ## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h + gArmScmiClockProtocolGuid =3D { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, 0x9f= , 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } } + + ## Arm System Control and Management Interface(SCMI) Clock management pr= otocol + ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h + gArmScmiPerformanceProtocolGuid =3D { 0x9b8ba84, 0x3dd3, 0x49a6, { 0xa0,= 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } } + [Ppis] ## Include/Ppi/ArmMpCoreInfo.h gArmMpCoreInfoPpiGuid =3D { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d, 0xa= b, 0x44, 0xe7, 0x54, 0xa8, 0xfc} } diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index 526909458e0d80dbc5a65c8ad12ec1095dda48d2..22332090db7111e0668607a1628= 8cefc1bace926 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.
-# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.
+# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.
# Copyright (c) 2016, Linaro Ltd. All rights reserved.
# # This program and the accompanying materials @@ -87,6 +87,8 @@ [LibraryClasses.common] ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf =20 + 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 =20 + ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf + [Components.AARCH64] ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h b/ArmPk= g/Drivers/ArmScmiDxe/ArmScmiBaseProtocolPrivate.h new file mode 100644 index 0000000000000000000000000000000000000000..79c057d44128008ec276e3d58d8= f1098c6a779b2 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 =3D 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/ArmP= kg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h new file mode 100644 index 0000000000000000000000000000000000000000..71245c16475d4d38d6dc66571b3= fe3520c1cf1da --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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_SHI= FT)) + +// 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) =3D=3D = 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 h= andle. + + @param[in] Handle Handle to install clock management protoc= ol. + + @retval EFI_SUCCESS Clock protocol interface installed succes= sfully. +**/ +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/ArmS= cmiDxe/ArmScmiDxe.inf new file mode 100644 index 0000000000000000000000000000000000000000..05ce9c04ce468d74e5c6d38739f= 9056f3fc48694 --- /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 B= SD 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 IM= PLIED. +# +# 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 =3D 0x00010019 + BASE_NAME =3D ArmScmiDxe + FILE_GUID =3D 9585984C-F027-45E9-AFDF-ADAA6DFAAAC7 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D 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..4514f45a9f5dd960d2844a19b57= a91b93149f1b9 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 + +// Number of performance levels returned by a call to the SCP, Lvls Bits[1= 1: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 Bi= ts[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 =EF=BF=BD 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 l= evels +} PERF_DESCRIBE_LEVELS; + +/** Initialize performance management protocol and install on a given Hand= le. + + @param[in] Handle Handle to install performance management + protocol. + + @retval EFI_SUCCESS Performance protocol installed successful= ly. +**/ +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/S= cmi.c new file mode 100644 index 0000000000000000000000000000000000000000..1e279f69cf615428dbb6477b8ac= 7de3258628df3 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 +#include +#include +#include + +#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 pointe= r. + @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 =3D MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel); + if (EFI_ERROR (Status)) { + return Status; + } + + // Payload will not be populated until channel is free. + Status =3D MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT); + if (EFI_ERROR (Status)) { + return Status; + } + + // Get the address of the payload. + *Payload =3D 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 successf= ully. + @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 !=3D NULL); + + Status =3D MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel); + if (EFI_ERROR (Status)) { + return Status; + } + + // Fill in message header. + MessageHeader =3D SCMI_MESSAGE_HEADER ( + Command->MessageId, + SCMI_MESSAGE_TYPE_COMMAND, + Command->ProtocolId + ); + + // Send payload using MTL channel. + Status =3D MtlSendMessage ( + Channel, + MessageHeader, + *PayloadLength + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // Wait for the response on the channel. + Status =3D MtlReceiveMessage (Channel, &ResponseHeader, PayloadLength); + if (EFI_ERROR (Status)) { + return Status; + } + + // SCMI must return MessageHeader unmodified. + if (MessageHeader !=3D ResponseHeader) { + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + + Response =3D (SCMI_MESSAGE_RESPONSE*)MtlGetChannelPayload (Channel); + + if (Response->Status !=3D SCMI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId =3D 0x%x, MessageId =3D 0= x%x, error =3D %d\n", + Command->ProtocolId, + Command->MessageId, + Response->Status + )); + + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + + if (ReturnValues !=3D NULL) { + *ReturnValues =3D 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 =3D 0; + + Command.ProtocolId =3D ProtocolId; + Command.MessageId =3D 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 =3D ScmiProtocolDiscoveryCommon ( + ProtocolId, + SCMI_MESSAGE_ID_PROTOCOL_VERSION, + (UINT32**)&ProtocolVersion + ); + if (EFI_ERROR (Status)) { + return Status; + } + + *Version =3D *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 attrib= utes. + @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..0829438c82ec5723cfbbf9c411d= 10fcf22a22d89 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 +#include +#include +#include + +#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 return= ed. + @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 =3D ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_BASE, &ReturnValu= es); + if (EFI_ERROR (Status)) { + return Status; + } + + *TotalProtocols =3D 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 =3D SCMI_PROTOCOL_ID_BASE; + Cmd.MessageId =3D MessageId; + + PayloadLength =3D 0; + + Status =3D 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 =3D SCMI_PROTOCOL_ID_BASE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION; + + PayloadLength =3D 0; + + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + &ReturnValues + ); + if (EFI_ERROR (Status)) { + return Status; + } + + *ImplementationVersion =3D 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 resul= t. + 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 =3D BaseGetTotalProtocols (This, &TotalProtocols); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + RequiredSize =3D sizeof (UINT8) * TotalProtocols; + if (*ProtocolListSize < RequiredSize) { + *ProtocolListSize =3D RequiredSize; + return EFI_BUFFER_TOO_SMALL; + } + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_BASE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS; + + Skip =3D 0; + + while (Skip < TotalProtocols) { + + *MessageParams =3D Skip; + + // Note PayloadLength is a IN/OUT parameter. + PayloadLength =3D sizeof (Skip); + + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + (UINT32**)&DiscoverList + ); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index =3D 0; Index < DiscoverList->NumProtocols; Index++) { + ProtocolList[Skip++] =3D DiscoverList->Protocols[Index]; + } + } + + *ProtocolListSize =3D RequiredSize; + + return EFI_SUCCESS; +} + +// Instance of the SCMI Base protocol. +STATIC CONST SCMI_BASE_PROTOCOL BaseProtocol =3D { + 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..fe7edd2a8c8b7761fb3008e66d1= 92ef1ee1ade2e --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 +#include +#include +#include + +#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 firmw= are. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + + @param[out] Version Version of the supported SCMI Clock management prot= ocol. + + @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 =3D ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK, &ReturnVal= ues); + if (EFI_ERROR (Status)) { + return Status; + } + + *TotalClocks =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + *MessageParams =3D ClockId; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_CLOCK; + Cmd.MessageId =3D SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES; + + PayloadLength =3D sizeof (ClockId); + + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + (UINT32**)&ClockAttributes + ); + if (EFI_ERROR (Status)) { + return Status; + } + // TRUE if bit 0 of ClockAttributes->Attributes is set. + *Enabled =3D 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-line= ar. + + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supp= orts + range of linear clock rates from Min to Max in s= teps. + + @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 =3D 0; + UINT32 RateIndex =3D 0; + UINT32 RateNo; + UINT32 RateOffset; + + *TotalRates =3D 0; + + Status =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_CLOCK; + Cmd.MessageId =3D SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES; + + *MessageParams++ =3D ClockId; + + do { + + *MessageParams =3D RateIndex; + + // Set Payload length, note PayloadLength is a IN/OUT parameter. + PayloadLength =3D sizeof (ClockId) + sizeof (RateIndex); + + // Execute and wait for response on a SCMI channel. + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + (UINT32**)&DescribeRates + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (*TotalRates =3D=3D 0) { + // In the first iteration we will get number of returned rates and n= umber + // of remaining rates. With this information calculate required size + // for rate array. If provided RateArraySize is less, return an + // error. + + *Format =3D RATE_FORMAT (DescribeRates->NumRatesFlags); + + *TotalRates =3D NUM_RATES (DescribeRates->NumRatesFlags) + + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags); + + if (*Format =3D=3D SCMI_CLOCK_RATE_FORMAT_DISCRETE) { + RequiredArraySize =3D (*TotalRates) * sizeof (UINT64); + } else { + // We need to return triplet of 64 bit value for each rate + RequiredArraySize =3D (*TotalRates) * 3 * sizeof (UINT64); + } + + if (RequiredArraySize > (*RateArraySize)) { + *RateArraySize =3D RequiredArraySize; + return EFI_BUFFER_TOO_SMALL; + } + } + + RateOffset =3D 0; + + if (*Format =3D=3D SCMI_CLOCK_RATE_FORMAT_DISCRETE) { + for (RateNo =3D 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags)= ; RateNo++) { + Rate =3D &DescribeRates->Rates[RateOffset++]; + // Non-linear discrete rates. + RateArray[RateIndex++].Rate =3D ConvertTo64Bit (Rate->Low, Rate->H= igh); + } + } else { + for (RateNo =3D 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags)= ; RateNo++) { + // Linear clock rates from minimum to maximum in steps + // Minimum clock rate. + Rate =3D &DescribeRates->Rates[RateOffset++]; + RateArray[RateIndex].Min =3D ConvertTo64Bit (Rate->Low, Rate->High= ); + + Rate =3D &DescribeRates->Rates[RateOffset++]; + // Maximum clock rate. + RateArray[RateIndex].Max =3D ConvertTo64Bit (Rate->Low, Rate->High= ); + + Rate =3D &DescribeRates->Rates[RateOffset++]; + // Step. + RateArray[RateIndex++].Step =3D ConvertTo64Bit (Rate->Low, Rate->H= igh); + } + } + } while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) !=3D 0); + + // Update RateArraySize with RequiredArraySize. + *RateArraySize =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + // Fill arguments for clock protocol command. + *MessageParams =3D ClockId; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_CLOCK; + Cmd.MessageId =3D SCMI_MESSAGE_ID_CLOCK_RATE_GET; + + PayloadLength =3D sizeof (ClockId); + + // Execute and wait for response on a SCMI channel. + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + (UINT32**)&ClockRate + ); + if (EFI_ERROR (Status)) { + return Status; + } + + *Rate =3D ((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 =3D ScmiCommandGetPayload ((UINT32**)&ClockRateSetAttributes); + if (EFI_ERROR (Status)) { + return Status; + } + + // Fill arguments for clock protocol command. + ClockRateSetAttributes->ClockId =3D ClockId; + ClockRateSetAttributes->Flags =3D CLOCK_SET_DEFAULT_FLAGS; + ClockRateSetAttributes->Rate.Low =3D (UINT32)Rate; + ClockRateSetAttributes->Rate.High =3D (UINT32)(Rate >> 32); + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_CLOCK; + Cmd.MessageId =3D SCMI_MESSAGE_ID_CLOCK_RATE_SET; + + PayloadLength =3D sizeof (CLOCK_RATE_SET_ATTRIBUTES); + + // Execute and wait for response on a SCMI channel. + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + NULL + ); + + return Status; +} + +// Instance of the SCMI clock management protocol. +STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol =3D { + ClockGetVersion, + ClockGetTotalClocks, + ClockGetClockAttributes, + ClockDescribeRates, + ClockRateGet, + ClockRateSet + }; + +/** Initialize clock management protocol and install protocol on a given h= andle. + + @param[in] Handle Handle to install clock management protoc= ol. + + @retval EFI_SUCCESS Clock protocol interface installed succes= sfully. +**/ +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/ArmScmiDx= e/ScmiDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..2920c6f6f33c5bb8ac00c903a0b= 199ba5f06f4de --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 +#include +#include +#include +#include +#include +#include + +#include "ArmScmiBaseProtocolPrivate.h" +#include "ArmScmiClockProtocolPrivate.h" +#include "ArmScmiPerformanceProtocolPrivate.h" +#include "ScmiDxe.h" +#include "ScmiPrivate.h" + +STATIC CONST SCMI_PROTOCOL_INIT_TABLE ProtocolInitFxns[MAX_PROTOCOLS] =3D { + { 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 =3D sizeof (SupportedList); + + ProtocolNo =3D SCMI_PROTOCOL_ID_BASE & PROTOCOL_ID_MASK; + + // Every SCMI implementation must implement the base protocol. + Status =3D ProtocolInitFxns[ProtocolNo].Init (&ImageHandle); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + + Status =3D gBS->LocateProtocol ( + &gArmScmiBaseProtocolGuid, + NULL, + (VOID**)&BaseProtocol + ); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + + // Get SCMI Base protocol version. + Status =3D BaseProtocol->GetVersion (BaseProtocol, &Version); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + + if (Version !=3D 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 =3D 0; + Status =3D BaseProtocol->GetTotalProtocols (BaseProtocol, &NumProtocols); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + + ASSERT (NumProtocols !=3D 0); + + // Get the list of protocols supported by SCP firmware on the platform. + Status =3D BaseProtocol->DiscoverListProtocols ( + BaseProtocol, + &SupportedListSize, + SupportedList + ); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + + // Install supported protocol on ImageHandle. + for (Index =3D 0; Index < NumProtocols; Index++) { + ProtocolNo =3D SupportedList[Index] & PROTOCOL_ID_MASK; + if (ProtocolInitFxns[ProtocolNo].Init !=3D NULL) { + Status =3D 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/ArmScmiDx= e/ScmiDxe.h new file mode 100644 index 0000000000000000000000000000000000000000..29cdde173659c701116b021a3c4= 37a92b473e4e5 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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/D= rivers/ArmScmiDxe/ScmiPerformanceProtocol.c new file mode 100644 index 0000000000000000000000000000000000000000..ac32442ad838040721fd62faa80= 6e82184f2b288 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 +#include +#include + +#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 manageme= nt + 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 =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + *MessageParams =3D DomainId; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_PERFORMANCE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES; + + PayloadLength =3D sizeof (DomainId); + + Status =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + LevelIndex =3D 0; + RequiredSize =3D 0; + + *MessageParams++ =3D DomainId; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_PERFORMANCE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS; + + do { + + *MessageParams =3D LevelIndex; + + // Note, PayloadLength is an IN/OUT parameter. + PayloadLength =3D sizeof (DomainId) + sizeof (LevelIndex); + + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + (UINT32**)&Levels + ); + if (EFI_ERROR (Status)) { + return Status; + } + + ReturnNumLevels =3D NUM_PERF_LEVELS (Levels->NumLevels); + ReturnRemainNumLevels =3D NUM_REMAIN_PERF_LEVELS (Levels->NumLevels); + + if (RequiredSize =3D=3D 0) { + *NumLevels =3D ReturnNumLevels + ReturnRemainNumLevels; + + RequiredSize =3D (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL); + if (RequiredSize > (*LevelArraySize)) { + // Update LevelArraySize with required size. + *LevelArraySize =3D RequiredSize; + return EFI_BUFFER_TOO_SMALL; + } + } + + for (LevelNo =3D 0; LevelNo < ReturnNumLevels; LevelNo++) { + memcpy ( + &LevelArray[LevelIndex++], + &Levels->PerfLevel[LevelNo], + sizeof (SCMI_PERFORMANCE_LEVEL) + ); + } + + } while (ReturnRemainNumLevels !=3D 0); + + *LevelArraySize =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + *MessageParams++ =3D DomainId; + *MessageParams++ =3D Limits->RangeMax; + *MessageParams =3D Limits->RangeMin; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_PERFORMANCE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET; + + PayloadLength =3D sizeof (DomainId) + sizeof (SCMI_PERFORMANCE_LIMITS); + + Status =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + *MessageParams =3D DomainId; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_PERFORMANCE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET; + + PayloadLength =3D sizeof (DomainId); + + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + (UINT32**)&ReturnValues + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Limits->RangeMax =3D ReturnValues->RangeMax; + Limits->RangeMin =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + *MessageParams++ =3D DomainId; + *MessageParams =3D Level; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_PERFORMANCE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET; + + PayloadLength =3D sizeof (DomainId) + sizeof (Level); + + Status =3D 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 =3D ScmiCommandGetPayload (&MessageParams); + if (EFI_ERROR (Status)) { + return Status; + } + + *MessageParams =3D DomainId; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_PERFORMANCE; + Cmd.MessageId =3D SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET; + + PayloadLength =3D sizeof (DomainId); + + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + &ReturnValues + ); + if (EFI_ERROR (Status)) { + return Status; + } + + *Level =3D *ReturnValues; + + return EFI_SUCCESS; +} + +// Instance of the SCMI performance management protocol. +STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol =3D { + PerformanceGetVersion, + PerformanceGetAttributes, + PerformanceDomainAttributes, + PerformanceDescribeLevels, + PerformanceLimitsSet, + PerformanceLimitsGet, + PerformanceLevelSet, + PerformanceLevelGet +}; + +/** Initialize performance management protocol and install on a given Hand= le. + + @param[in] Handle Handle to install performance management + protocol. + + @retval EFI_SUCCESS Performance protocol installed successful= ly. +**/ +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/ArmSc= miDxe/ScmiPrivate.h new file mode 100644 index 0000000000000000000000000000000000000000..df03655b8b021fe5fd63ceab0dd= 414906d2fb248 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 =3D 0x10, + SCMI_PROTOCOL_ID_POWER_DOMAIN =3D 0x11, + SCMI_PROTOCOL_ID_SYSTEM_POWER =3D 0x12, + SCMI_PROTOCOL_ID_PERFORMANCE =3D 0x13, + SCMI_PROTOCOL_ID_CLOCK =3D 0x14, + SCMI_PROTOCOL_ID_SENSOR =3D 0x15 +} SCMI_PROTOCOL_ID; + +// SCMI message types. +typedef enum { + SCMI_MESSAGE_TYPE_COMMAND =3D 0, + SCMI_MESSAGE_TYPE_DELAYED_RESPONSE =3D 2, // Skipping 1 is deliberate. + SCMI_MESSAGE_TYPE_NOTIFICATION =3D 3 +} SCMI_MESSAGE_TYPE; + +// SCMI response error codes. +typedef enum { + SCMI_SUCCESS =3D 0, + SCMI_NOT_SUPPORTED =3D -1, + SCMI_INVALID_PARAMETERS =3D -2, + SCMI_DENIED =3D -3, + SCMI_NOT_FOUND =3D -4, + SCMI_OUT_OF_RANGE =3D -5, + SCMI_BUSY =3D -6, + SCMI_COMMS_ERROR =3D -7, + SCMI_GENERIC_ERROR =3D -8, + SCMI_HARDWARE_ERROR =3D -9, + SCMI_PROTOCOL_ERROR =3D -10 +} SCMI_STATUS; + +// SCMI message IDs common to all protocols. +typedef enum { + SCMI_MESSAGE_ID_PROTOCOL_VERSION =3D 0x0, + SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES =3D 0x1, + SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES =3D 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 pointe= r. + @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 successf= ully. + @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 attrib= utes. + @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/Ar= mScmi.h new file mode 100644 index 0000000000000000000000000000000000000000..239abb97064578c949614f79a6a= 33fe1881c3c68 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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..ecc41f2181ecc9f835950ab46c7= cfd2e476a7073 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 + +#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, 0= x2f} \ + } + +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 return= ed. + @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 resul= t. + 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 =3D 0x3, + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR =3D 0x4, + SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION =3D 0x5, + SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS =3D 0x6 +} SCMI_MESSAGE_ID_BASE; + +#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */ + diff --git a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h b/ArmPkg/Includ= e/Protocol/ArmScmiClockProtocol.h new file mode 100644 index 0000000000000000000000000000000000000000..3db26cb0641c7377c022a8e00be= 9a51ee5dc7361 --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 + +#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \ + 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0x= aa} \ + } + +extern EFI_GUID gArmScmiClockProtocolGuid; + +// Message Type for clock management protocol. +typedef enum { + SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES =3D 0x3, + SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES =3D 0x4, + SCMI_MESSAGE_ID_CLOCK_RATE_SET =3D 0x5, + SCMI_MESSAGE_ID_CLOCK_RATE_GET =3D 0x6, + SCMI_MESSAGE_ID_CLOCK_CONFIG_SET =3D 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_N= UM_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 firmw= are. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + + @param[out] Version Version of the supported SCMI Clock management prot= ocol. + + @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-line= ar. + + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supp= orts + range of linear clock rates from Min to Max in s= teps. + + @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..1d1af6f8bee0c00bbe6b4774036= c87c988a4f4af --- /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 BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + + 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 + +#define PERFORMANCE_PROTOCOL_VERSION 0x10000 + +#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \ + 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0x= ad} \ + } + +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 manageme= nt + 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 =3D 0x3, + SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS =3D 0x4, + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET =3D 0x5, + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET =3D 0x6, + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET =3D 0x7, + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET =3D 0x8, +} SCMI_MESSAGE_ID_PERFORMANCE; + +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */ + --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' --===============4274754219559222770== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel --===============4274754219559222770==--