On Tue, Sep 26, 2017 at 09:15:21PM +0100, evan.ll...@arm.com wrote:
> From: Girish Pathak <girish.pat...@arm.com>
> 
> LcdIdentify function does not currently check presence of HDLCD
> controller.
> 
> Implement this functionality by reading HDLCD_REG_VERSION and checking
> against the PRODUCT_ID field to detect presence of HDLCD controller.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Girish Pathak <girish.pat...@arm.com>
> Signed-off-by: Evan Lloyd <evan.ll...@arm.com>
> ---
>  ArmPlatformPkg/Include/Drivers/HdLcd.h              |  4 +++-
>  ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 22 +++++++++++++++++++-
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/ArmPlatformPkg/Include/Drivers/HdLcd.h 
> b/ArmPlatformPkg/Include/Drivers/HdLcd.h
> index 
> 6df97a9dfee60e9fda615cf3bea1b6a164a42333..69b47cd720bae86081753affe2f3fafc8aa6c4d0
>  100644
> --- a/ArmPlatformPkg/Include/Drivers/HdLcd.h
> +++ b/ArmPlatformPkg/Include/Drivers/HdLcd.h
> @@ -1,6 +1,6 @@
>  /** @file  HDLcd.h
>  
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>  
>   This program and the accompanying materials
>   are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -86,4 +86,6 @@
>  // Number of bytes per pixel
>  #define HDLCD_4BYTES_PER_PIXEL           ((4 - 1) << 3)
>  
> +#define HDLCD_PRODUCT_ID                 0x1CDC
> +
>  #endif /* _HDLCD_H_ */
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c 
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 
> a266671a26f01d31e8ddb0cf7cbfe59d2f4dc49c..33c555e75cafaf9affddd0992c4bd9f9289f6703
>  100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -159,6 +159,22 @@ LcdShutdown (
>    MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>  }
>  
> +/** Get the HDLCD Product Id (from the version register).
> +**/
> +STATIC
> +UINT32 GetHdlcdProductId(VOID)
> +{
> +  return ((MmioRead32 (HDLCD_REG_VERSION)) >> 16) ;

I was about to complain that this didn't use the functions from the
common PrimeCell helper library. Then I realised we didn't have one :(
One for the todo list.

Reviewed-by: Leif Lindholm <leif.lindh...@linaro.org>

> +}
> +
> +/** Check if an HDLCD is present.
> +**/
> +STATIC
> +BOOLEAN HdlcdPresent(VOID)
> +{
> +  return (GetHdlcdProductId() == HDLCD_PRODUCT_ID);
> +}
> +
>  /** Check for presence of HDLCD.
>    *
>    * @retval EFI_SUCCESS            Platform implements HDLCD.
> @@ -170,5 +186,9 @@ LcdIdentify (
>    VOID
>    )
>  {
> -  return EFI_SUCCESS;
> +  if (HdlcdPresent()) {
> +    return EFI_SUCCESS;
> +  }
> +
> +  return EFI_NOT_FOUND;
>  }
> -- 
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to