3 Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include <Library/DebugLib.h>
15 #include <Library/IoLib.h>
16 #include <Library/LcdPlatformLib.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/PcdLib.h>
20 #include <Drivers/PL111Lcd.h>
22 #include "LcdGraphicsOutputDxe.h"
24 /**********************************************************************
26 * This file contains all the bits of the PL111 that are
27 * platform independent.
29 **********************************************************************/
36 // Check if this is a PrimeCell Peripheral
37 if ( ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_0
) != 0x0D )
38 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_1
) != 0xF0 )
39 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_2
) != 0x05 )
40 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_3
) != 0xB1 ) ) {
44 // Check if this PrimeCell Peripheral is the PL111 LCD
45 if ( ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_0
) != 0x11 )
46 || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_1
) != 0x11 )
47 || ( (MmioRead8( PL111_REG_CLCD_PERIPH_ID_2
) & 0xF) != 0x04 )
48 || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_3
) != 0x00 ) ) {
57 IN EFI_PHYSICAL_ADDRESS VramBaseAddress
60 EFI_STATUS Status
= EFI_SUCCESS
;
62 // Check if the PL111 is fitted on this motherboard
63 Status
= PL111Indentify();
64 if (EFI_ERROR( Status
)) {
65 return EFI_DEVICE_ERROR
;
68 // Define start of the VRAM. This never changes for any graphics mode
69 MmioWrite32(PL111_REG_LCD_UP_BASE
, (UINT32
) VramBaseAddress
);
70 MmioWrite32(PL111_REG_LCD_LP_BASE
, 0); // We are not using a double buffer
72 // Disable all interrupts from the PL111
73 MmioWrite32(PL111_REG_LCD_IMSC
, 0);
95 // Set the video mode timings and other relevant information
96 Status
= LcdPlatformGetTimings (ModeNumber
,
97 &HRes
,&HSync
,&HBackPorch
,&HFrontPorch
,
98 &VRes
,&VSync
,&VBackPorch
,&VFrontPorch
);
99 ASSERT_EFI_ERROR (Status
);
100 if (EFI_ERROR( Status
)) {
101 return EFI_DEVICE_ERROR
;
104 Status
= LcdPlatformGetBpp (ModeNumber
,&LcdBpp
);
105 ASSERT_EFI_ERROR (Status
);
106 if (EFI_ERROR( Status
)) {
107 return EFI_DEVICE_ERROR
;
110 // Disable the CLCD_LcdEn bit
111 LcdControl
= MmioRead32( PL111_REG_LCD_CONTROL
);
112 MmioWrite32(PL111_REG_LCD_CONTROL
, LcdControl
& ~1);
115 MmioWrite32 (PL111_REG_LCD_TIMING_0
, HOR_AXIS_PANEL(HBackPorch
, HFrontPorch
, HSync
, HRes
));
116 MmioWrite32 (PL111_REG_LCD_TIMING_1
, VER_AXIS_PANEL(VBackPorch
, VFrontPorch
, VSync
, VRes
));
117 MmioWrite32 (PL111_REG_LCD_TIMING_2
, CLK_SIG_POLARITY(HRes
));
118 MmioWrite32 (PL111_REG_LCD_TIMING_3
, 0);
120 // PL111_REG_LCD_CONTROL
121 LcdControl
= PL111_CTRL_LCD_EN
| PL111_CTRL_LCD_BPP(LcdBpp
) | PL111_CTRL_LCD_TFT
| PL111_CTRL_BGR
;
122 MmioWrite32(PL111_REG_LCD_CONTROL
, LcdControl
);
124 // Turn on power to the LCD Panel
125 LcdControl
|= PL111_CTRL_LCD_PWR
;
126 MmioWrite32(PL111_REG_LCD_CONTROL
, LcdControl
);
136 // Nothing to do in terms of hardware.
137 // We could switch off the monitor display if required