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/IoLib.h>
15 #include <Library/MemoryAllocationLib.h>
17 #include <Drivers/PL111Lcd.h>
19 #include "LcdGraphicsOutputDxe.h"
21 /**********************************************************************
23 * This file contains all the bits of the PL111 that are
24 * platform independent.
26 **********************************************************************/
33 // Check if this is a PrimeCell Peripheral
34 if ( ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_0
) != 0x0D )
35 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_1
) != 0xF0 )
36 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_2
) != 0x05 )
37 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_3
) != 0xB1 ) ) {
41 // Check if this PrimeCell Peripheral is the PL111 LCD
42 if ( ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_0
) != 0x11 )
43 || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_1
) != 0x11 )
44 || ( (MmioRead8( PL111_REG_CLCD_PERIPH_ID_2
) & 0xF) != 0x04 )
45 || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_3
) != 0x00 ) ) {
54 IN EFI_PHYSICAL_ADDRESS VramBaseAddress
57 EFI_STATUS Status
= EFI_SUCCESS
;
59 // Check if the PL111 is fitted on this motherboard
60 Status
= PL111Indentify ();
61 if (EFI_ERROR( Status
)) {
62 return EFI_DEVICE_ERROR
;
65 // Define start of the VRAM. This never changes for any graphics mode
66 MmioWrite32(PL111_REG_LCD_UP_BASE
, (UINT32
) VramBaseAddress
);
67 MmioWrite32(PL111_REG_LCD_LP_BASE
, 0); // We are not using a double buffer
69 // Disable all interrupts from the PL111
70 MmioWrite32(PL111_REG_LCD_IMSC
, 0);
92 // Set the video mode timings and other relevant information
93 Status
= LcdPlatformGetTimings (ModeNumber
,
94 &HRes
,&HSync
,&HBackPorch
,&HFrontPorch
,
95 &VRes
,&VSync
,&VBackPorch
,&VFrontPorch
);
96 ASSERT_EFI_ERROR (Status
);
97 if (EFI_ERROR( Status
)) {
98 return EFI_DEVICE_ERROR
;
101 Status
= LcdPlatformGetBpp (ModeNumber
,&LcdBpp
);
102 ASSERT_EFI_ERROR (Status
);
103 if (EFI_ERROR( Status
)) {
104 return EFI_DEVICE_ERROR
;
107 // Disable the CLCD_LcdEn bit
108 LcdControl
= MmioRead32( PL111_REG_LCD_CONTROL
);
109 MmioWrite32(PL111_REG_LCD_CONTROL
, LcdControl
& ~1);
112 MmioWrite32 (PL111_REG_LCD_TIMING_0
, HOR_AXIS_PANEL(HBackPorch
, HFrontPorch
, HSync
, HRes
));
113 MmioWrite32 (PL111_REG_LCD_TIMING_1
, VER_AXIS_PANEL(VBackPorch
, VFrontPorch
, VSync
, VRes
));
114 MmioWrite32 (PL111_REG_LCD_TIMING_2
, CLK_SIG_POLARITY(HRes
));
115 MmioWrite32 (PL111_REG_LCD_TIMING_3
, 0);
117 // PL111_REG_LCD_CONTROL
118 LcdControl
= PL111_CTRL_LCD_EN
| PL111_CTRL_LCD_BPP(LcdBpp
) | PL111_CTRL_LCD_TFT
| PL111_CTRL_BGR
;
119 MmioWrite32(PL111_REG_LCD_CONTROL
, LcdControl
);
121 // Turn on power to the LCD Panel
122 LcdControl
|= PL111_CTRL_LCD_PWR
;
123 MmioWrite32(PL111_REG_LCD_CONTROL
, LcdControl
);
133 // Nothing to do in terms of hardware.
134 // We could switch off the monitor display if required