]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
ArmPlatformPkg: create hw-agnostic LcdGraphicsOutputDxe driver
[mirror_edk2.git] / ArmPlatformPkg / Drivers / LcdGraphicsOutputDxe / PL111Lcd.c
index c92dd3d7edf799a154e41d3a3a660c503ca554f9..a9ce60c5b0a6d3ef13e4f59dd4d0909347840a9d 100644 (file)
@@ -1,6 +1,7 @@
 /** @file  PL111Lcd.c\r
 \r
-  Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r
+\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 \r
 **/\r
 \r
-#include <Library/DebugLib.h>\r
 #include <Library/IoLib.h>\r
-#include <Library/LcdPlatformLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-#include <Drivers/PL111Lcd.h>\r
 \r
 #include "LcdGraphicsOutputDxe.h"\r
+#include "PL111Lcd.h"\r
 \r
 /**********************************************************************\r
  *\r
  **********************************************************************/\r
 \r
 EFI_STATUS\r
-PL111Indentify (\r
+LcdIdentify (\r
   VOID\r
   )\r
 {\r
-  // Check if this is a PrimeCell Peripheral\r
-  if (    ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_0 ) != 0x0D )\r
-       || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_1 ) != 0xF0 )\r
-       || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_2 ) != 0x05 )\r
-       || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_3 ) != 0xB1 ) ) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  // Check if this PrimeCell Peripheral is the PL111 LCD\r
-  if (    ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_0 ) != 0x11 )\r
-       || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_1 ) != 0x11 )\r
-       || ( (MmioRead8( PL111_REG_CLCD_PERIPH_ID_2 ) & 0xF) != 0x04 )\r
-       || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_3 ) != 0x00 ) ) {\r
-    return EFI_NOT_FOUND;\r
+  DEBUG ((EFI_D_WARN, "Probing ID registers at 0x%lx for a PL111\n",\r
+    PL111_REG_CLCD_PERIPH_ID_0));\r
+\r
+  // Check if this is a PL111\r
+  if (MmioRead8 (PL111_REG_CLCD_PERIPH_ID_0) == PL111_CLCD_PERIPH_ID_0 &&\r
+      MmioRead8 (PL111_REG_CLCD_PERIPH_ID_1) == PL111_CLCD_PERIPH_ID_1 &&\r
+     (MmioRead8 (PL111_REG_CLCD_PERIPH_ID_2) & 0xf) == PL111_CLCD_PERIPH_ID_2 &&\r
+      MmioRead8 (PL111_REG_CLCD_PERIPH_ID_3) == PL111_CLCD_PERIPH_ID_3 &&\r
+      MmioRead8 (PL111_REG_CLCD_P_CELL_ID_0) == PL111_CLCD_P_CELL_ID_0 &&\r
+      MmioRead8 (PL111_REG_CLCD_P_CELL_ID_1) == PL111_CLCD_P_CELL_ID_1 &&\r
+      MmioRead8 (PL111_REG_CLCD_P_CELL_ID_2) == PL111_CLCD_P_CELL_ID_2 &&\r
+      MmioRead8 (PL111_REG_CLCD_P_CELL_ID_3) == PL111_CLCD_P_CELL_ID_3) {\r
+    return EFI_SUCCESS;\r
   }\r
-\r
-  return EFI_SUCCESS;\r
+  return EFI_NOT_FOUND;\r
 }\r
 \r
 EFI_STATUS\r
@@ -57,14 +52,6 @@ LcdInitialize (
   IN EFI_PHYSICAL_ADDRESS   VramBaseAddress\r
   )\r
 {\r
-  EFI_STATUS  Status = EFI_SUCCESS;\r
-\r
-  // Check if the PL111 is fitted on this motherboard\r
-  Status = PL111Indentify();\r
-  if (EFI_ERROR( Status )) {\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-\r
   // Define start of the VRAM. This never changes for any graphics mode\r
   MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);\r
   MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer\r
@@ -133,8 +120,6 @@ LcdShutdown (
   VOID\r
   )\r
 {\r
-  // Nothing to do in terms of hardware.\r
-  // We could switch off the monitor display if required\r
-\r
-  //TODO: ImplementMe\r
+  // Disable the controller\r
+  MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);\r
 }\r