From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::143; helo=mail-it1-x143.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x143.google.com (mail-it1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B4CB121962301 for ; Fri, 7 Dec 2018 12:34:43 -0800 (PST) Received: by mail-it1-x143.google.com with SMTP id i145so8854817ita.4 for ; Fri, 07 Dec 2018 12:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C6uNOwh0tqxSa/luCvk3ZIfUi7bhlMVnEF7EK/7zXKQ=; b=Esj3xugZGCoq+RFoY9V+4Kc8PP+FcN8jWu1EUmryiDYtlJev9nuDK7hTzRbHctgRxw Cg4+qX+eapEDLVN/Ka0BzXcMoMuWY4+eom6pgnwA8LKEB8509mxp/GzY1q3+GU34u6eU 60A1hkeR7HZygVESCw60oKf995z+iN/N9+VPk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C6uNOwh0tqxSa/luCvk3ZIfUi7bhlMVnEF7EK/7zXKQ=; b=RWZELbqqaD7zpX/UNKg7htA/qCDm4mVklGC6tc5yGUD03M1B5MK48hVztMVbItK8wu iV5HtGu7B0oz3IzJb1Dn65zBpAqHons9+2K2UdUx+nfWHklW4gcr94ZVspCcHuBYTjqe etMOmXsx4r8COBEjp4EJq0Q0fjbZkIjP0os9bLj3F0aSW2VQzGxiO/+JJnfBISVqcQ9R 9Ltd1LCFHKt67kSI8DYOGT2rGsLOf1OtHMruTdY4cKQ0SrTRn9xBB6MdhcoEcCT1T1mj KCE3CjLd8OWAqN4cyYKR/5xen9RmMbAzixbso9Wwy64LM6ldAh0cNe3TMX5ZJdDoBPBQ M78g== X-Gm-Message-State: AA+aEWY7n52+XHF82o1F9obnozgbQb4nthI5BOmEvetXaK+f7qQb9v41 SGXs9RjKfwBeJL70Eq/Cdu9AuoE4ZqACJIadjfmAEQ== X-Google-Smtp-Source: AFSGD/U6yz6u+v34nfjxASRdYLyFa+PB9ymiSCra1lNa0jX68BOUzYyFjk9kUk4Rq+xwTpbaaaHvT52ow2qwRvT6WSI= X-Received: by 2002:a05:660c:4b:: with SMTP id p11mr3463176itk.71.1544214882475; Fri, 07 Dec 2018 12:34:42 -0800 (PST) MIME-Version: 1.0 References: <1544171327-13025-1-git-send-email-vijayenthiran.subramaniam@arm.com> In-Reply-To: <1544171327-13025-1-git-send-email-vijayenthiran.subramaniam@arm.com> From: Ard Biesheuvel Date: Fri, 7 Dec 2018 21:34:30 +0100 Message-ID: To: vijayenthiran.subramaniam@arm.com Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Thomas Panakamattam Abraham , Girish Pathak Subject: Re: [PATCH v3 edk2-platforms] Platform/ARM/SgiPkg: Add support for HDLCD X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2018 20:34:44 -0000 Content-Type: text/plain; charset="UTF-8" On Fri, 7 Dec 2018 at 09:28, Vijayenthiran Subramaniam wrote: > > Add HDLCD platform library for SGI platform that implements platform > callbacks for the Arm HDLCD driver. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Vijayenthiran Subramaniam > --- > Change from v2: > No code change. Posting patch again with Change-Id removed. > Reviewed-by: Ard Biesheuvel Pushed as 327ff4ae71ae..0eaa50231c02 Thanks! > Platform/ARM/SgiPkg/SgiPlatform.dsc | 6 + > Platform/ARM/SgiPkg/SgiPlatform.fdf | 6 + > Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgiLib.inf | 40 +++ > Platform/ARM/SgiPkg/Include/SgiPlatform.h | 4 + > Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgi.c | 257 ++++++++++++++++++++ > Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 8 +- > 6 files changed, 320 insertions(+), 1 deletion(-) > > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc > index 0c794c6b299d..7995c7d132d6 100644 > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc > @@ -37,6 +37,8 @@ [LibraryClasses.common] > ArmPlatformLib|Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf > BasePathLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf > EfiResetSystemLib|ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf > + LcdHwLib|ArmPlatformPkg/Library/HdLcd/HdLcd.inf > + LcdPlatformLib|Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgiLib.inf > NorFlashPlatformLib|Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf > HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf > TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf > @@ -155,6 +157,9 @@ [PcdsFixedAtBuild.common] > gArmPlatformTokenSpaceGuid.PL011UartInteger|4 > gArmPlatformTokenSpaceGuid.PL011UartFractional|0 > > + ## PL370 - HDLCD1 > + gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x7FF60000 > + > ## PL011 - Serial Debug UART > gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase|0x7FF80000 > gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz|7372800 > @@ -235,6 +240,7 @@ [Components.common] > ArmPkg/Drivers/ArmGic/ArmGicDxe.inf > ArmPkg/Drivers/TimerDxe/TimerDxe.inf > ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf > + ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf > ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf > EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf > EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf b/Platform/ARM/SgiPkg/SgiPlatform.fdf > index ddf1fda5a16e..80c3412fd4ad 100644 > --- a/Platform/ARM/SgiPkg/SgiPlatform.fdf > +++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf > @@ -133,6 +133,9 @@ [FV.FvMain] > # > # Multiple Console IO support > # > + INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf > + INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf > + INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf > INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf > INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf > > @@ -144,6 +147,9 @@ [FV.FvMain] > INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf > INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf > > + # Graphics Output Protocol > + INF ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf > + > INF Platform/ARM/Drivers/BootMonFs/BootMonFs.inf > INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > > diff --git a/Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgiLib.inf b/Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgiLib.inf > new file mode 100644 > index 000000000000..751f0d9288eb > --- /dev/null > +++ b/Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgiLib.inf > @@ -0,0 +1,40 @@ > +# > +# Copyright (c) 2018, ARM Limited. All rights reserved. > +# > +# This program and the accompanying materials are licensed and made available > +# under the terms and conditions of the BSD License which accompanies this > +# distribution. The full text of the license may be found at > +# http://opensource.org/licenses/bsd-license.php > +# > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > +# > + > +[Defines] > + INF_VERSION = 0x0001001A > + BASE_NAME = HdLcdArmSgiLib > + FILE_GUID = 0C77342C-7895-4DE1-A9C8-1DBBFA71AF34 > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = LcdPlatformLib > + > +[Sources.common] > + HdLcdArmSgi.c > + > +[Packages] > + ArmPkg/ArmPkg.dec > + ArmPlatformPkg/ArmPlatformPkg.dec > + MdePkg/MdePkg.dec > + Platform/ARM/SgiPkg/SgiPlatform.dec > + > +[LibraryClasses] > + BaseLib > + > +[FixedPcd] > + gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase > + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase > + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize > + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat > + > +[depex] > + gEfiCpuArchProtocolGuid > diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h b/Platform/ARM/SgiPkg/Include/SgiPlatform.h > index 550189565752..b9a662ae41a1 100644 > --- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h > +++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h > @@ -56,6 +56,10 @@ > #define SGI_SUBSYS_GENERIC_GICR_BASE 0x300C0000 > #define SGI_SUBSYS_GENERIC_GIC_SZ SIZE_1MB > > +// Expansion AXI - Platform Peripherals - HDLCD1 > +#define SGI_EXP_PLAT_PERIPH_HDLCD1_BASE 0x7FF60000 > +#define SGI_EXP_PLAT_PERIPH_HDLCD1_SZ SIZE_64KB > + > // Expansion AXI - Platform Peripherals - UART0 > #define SGI_EXP_PLAT_PERIPH_UART0_BASE 0x7FF70000 > #define SGI_EXP_PLAT_PERIPH_UART0_SZ SIZE_64KB > diff --git a/Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgi.c b/Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgi.c > new file mode 100644 > index 000000000000..55f10f4eb75d > --- /dev/null > +++ b/Platform/ARM/SgiPkg/Library/HdLcdArmSgiLib/HdLcdArmSgi.c > @@ -0,0 +1,257 @@ > +/** @file > +* > +* Copyright (c) 2018, ARM Limited. All rights reserved. > +* > +* This program and the accompanying materials are licensed and made available > +* under the terms and conditions of the BSD License which accompanies this > +* distribution. The full text of the license may be found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > +* > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +typedef struct { > + UINT32 OscFreq; > + SCAN_TIMINGS Horizontal; > + SCAN_TIMINGS Vertical; > +} DISPLAY_MODE; > + > +STATIC DISPLAY_MODE mDisplayModes[] = { > + { > + // SVGA : 800 x 600 x 24 bpp. > + SVGA_OSC_FREQUENCY, > + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH}, > + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH} > + } > +}; > + > +STATIC CONST UINT32 mMaxMode = ARRAY_SIZE (mDisplayModes); > + > +/** HDLCD platform specific initialization function. > + > + @param[in] Handle Handle to the LCD device instance. > + > + @retval EFI_SUCCESS Plaform library initialized successfully. > + @retval EFI_UNSUPPORTED PcdGopPixelFormat must be > + PixelRedGreenBlueReserved8BitPerColor OR > + PixelBlueGreenRedReserved8BitPerColor > + any other format is not supported. > + @retval other Other errors. > +**/ > +EFI_STATUS > +LcdPlatformInitializeDisplay ( > + IN EFI_HANDLE Handle > + ) > +{ > + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; > + > + // PixelBitMask and PixelBltOnly pixel formats are not supported. > + PixelFormat = FixedPcdGet32 (PcdGopPixelFormat); > + if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor && > + PixelFormat != PixelBlueGreenRedReserved8BitPerColor) { > + > + ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor || > + PixelFormat == PixelBlueGreenRedReserved8BitPerColor); > + return EFI_UNSUPPORTED; > + } > + > + return EFI_SUCCESS; > +} > + > +/** Allocate VRAM memory in DRAM for the framebuffer > + > + 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 framebuffer > + in bytes > + > + @retval EFI_SUCCESS Framebuffer memory allocated successfully. > + @retval other Other errors. > +**/ > +EFI_STATUS > +LcdPlatformGetVram ( > + OUT EFI_PHYSICAL_ADDRESS *VramBaseAddress, > + OUT UINTN *VramSize > + ) > +{ > + EFI_STATUS Status; > + EFI_CPU_ARCH_PROTOCOL *Cpu; > + > + ASSERT (VramBaseAddress != NULL); > + ASSERT (VramSize != NULL); > + > + // Set the VRAM size. > + *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize); > + > + // Check if base address is already reserved for the framebuffer. > + *VramBaseAddress = > + (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase); > + > + if (*VramBaseAddress == 0) { > + // If not already reserved, attempt to allocate the VRAM from the DRAM. > + Status = gBS->AllocatePages ( > + AllocateAnyPages, > + EfiReservedMemoryType, > + EFI_SIZE_TO_PAGES (*VramSize), > + VramBaseAddress); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "HdLcdArmSgi: Failed to allocate memory for" > + "frame buffer.\n")); > + ASSERT_EFI_ERROR (Status); > + return Status; > + } > + } > + > + // Ensure the Cpu architectural protocol is already installed > + Status = gBS->LocateProtocol ( > + &gEfiCpuArchProtocolGuid, > + NULL, > + (VOID **)&Cpu); > + ASSERT_EFI_ERROR (Status); > + > + // The VRAM is inside the DRAM, which is cacheable. > + // Mark the VRAM as write-combining (uncached) and non-executable. > + Status = Cpu->SetMemoryAttributes ( > + Cpu, > + *VramBaseAddress, > + *VramSize, > + EFI_MEMORY_WC | EFI_MEMORY_XP); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize)); > + } > + > + return Status; > +} > + > +/** Return total number of modes supported. > + > + @retval UINT32 Mode Number. > +**/ > +UINT32 > +LcdPlatformGetMaxMode (VOID) > +{ > + return mMaxMode; > +} > + > +/** Set the requested display mode. > + > + @param[in] ModeNumber Mode Number. > + > + @retval EFI_SUCCESS Mode set successfully. > + @retval EFI_INVALID_PARAMETER Requested mode not found. > +**/ > +EFI_STATUS > +LcdPlatformSetMode ( > + IN UINT32 ModeNumber > + ) > +{ > + if (ModeNumber >= mMaxMode) { > + return EFI_INVALID_PARAMETER; > + } > + > + return EFI_SUCCESS; > +} > + > +/** 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 > + ) > +{ > + if (ModeNumber >= mMaxMode) { > + return EFI_INVALID_PARAMETER; > + } > + > + ASSERT (Info != NULL); > + > + Info->Version = 0; > + Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution; > + Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution; > + Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution; > + Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat); > + > + return EFI_SUCCESS; > +} > + > +/** Return display timing information for the requested mode number. > + > + @param[in] ModeNumber Mode Number. > + > + @param[out] Horizontal Pointer to horizontal timing parameters. > + (Resolution, Sync, Back porch, Front porch) > + @param[out] Vertical Pointer to vertical timing parameters. > + (Resolution, Sync, Back porch, Front porch) > + > + @retval EFI_SUCCESS Display timing information for the requested > + mode returned successfully. > + @retval EFI_INVALID_PARAMETER Requested mode not found. > +**/ > +EFI_STATUS > +LcdPlatformGetTimings ( > + IN UINT32 ModeNumber, > + OUT SCAN_TIMINGS **Horizontal, > + OUT SCAN_TIMINGS **Vertical > + ) > +{ > + if (ModeNumber >= mMaxMode) { > + return EFI_INVALID_PARAMETER; > + } > + > + ASSERT (Horizontal != NULL); > + ASSERT (Vertical != NULL); > + > + *Horizontal = &mDisplayModes[ModeNumber].Horizontal; > + *Vertical = &mDisplayModes[ModeNumber].Vertical; > + > + // Pretend that clock probing and get timings are successful for SGI FVP > + return EFI_SUCCESS; > +} > + > +/** Return bits per pixel information for a mode number. > + > + @param[in] ModeNumber Mode Number. > + > + @param[out] Bpp Pointer to bits per pixel information. > + > + @retval EFI_SUCCESS Bits per pixel information for the requested > + mode returned successfully. > + @retval EFI_INVALID_PARAMETER Requested mode not found. > +**/ > +EFI_STATUS > +LcdPlatformGetBpp ( > + IN UINT32 ModeNumber, > + OUT LCD_BPP *Bpp > + ) > +{ > + if (ModeNumber >= mMaxMode) { > + return EFI_INVALID_PARAMETER; > + } > + > + ASSERT (Bpp != NULL); > + > + *Bpp = LCD_BITS_PER_PIXEL_24; > + > + return EFI_SUCCESS; > +} > diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c > index 3314a26e8f41..6ec2e8a7096d 100644 > --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c > +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c > @@ -22,7 +22,7 @@ > #include > > // Total number of descriptors, including the final "end-of-table" descriptor. > -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 11 > +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 12 > > /** > Returns the Virtual Memory Map of the platform. > @@ -104,6 +104,12 @@ ArmPlatformGetVirtualMemoryMap ( > VirtualMemoryTable[Index].Length = SGI_SUBSYS_GENERIC_GIC_SZ; > VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; > > + // Expansion AXI - Platform Peripherals - HDLCD1 > + VirtualMemoryTable[++Index].PhysicalBase = SGI_EXP_PLAT_PERIPH_HDLCD1_BASE; > + VirtualMemoryTable[Index].VirtualBase = SGI_EXP_PLAT_PERIPH_HDLCD1_BASE; > + VirtualMemoryTable[Index].Length = SGI_EXP_PLAT_PERIPH_HDLCD1_SZ; > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; > + > // Expansion AXI - Platform Peripherals - UART1 > VirtualMemoryTable[++Index].PhysicalBase = SGI_EXP_PLAT_PERIPH_UART1_BASE; > VirtualMemoryTable[Index].VirtualBase = SGI_EXP_PLAT_PERIPH_UART1_BASE; > -- > 2.7.4 >