TianoCore EDK2 master
Loading...
Searching...
No Matches
PL111Lcd.c
Go to the documentation of this file.
1
9#include <Library/DebugLib.h>
10#include <Library/IoLib.h>
11#include <Library/LcdHwLib.h>
14
15#include "PL111Lcd.h"
16
26 VOID
27 )
28{
29 DEBUG ((
30 DEBUG_WARN,
31 "Probing ID registers at 0x%lx for a PL111\n",
32 PL111_REG_CLCD_PERIPH_ID_0
33 ));
34
35 // Check if this is a PL111
36 if ((MmioRead8 (PL111_REG_CLCD_PERIPH_ID_0) == PL111_CLCD_PERIPH_ID_0) &&
37 (MmioRead8 (PL111_REG_CLCD_PERIPH_ID_1) == PL111_CLCD_PERIPH_ID_1) &&
38 ((MmioRead8 (PL111_REG_CLCD_PERIPH_ID_2) & 0xf) == PL111_CLCD_PERIPH_ID_2) &&
39 (MmioRead8 (PL111_REG_CLCD_PERIPH_ID_3) == PL111_CLCD_PERIPH_ID_3) &&
40 (MmioRead8 (PL111_REG_CLCD_P_CELL_ID_0) == PL111_CLCD_P_CELL_ID_0) &&
41 (MmioRead8 (PL111_REG_CLCD_P_CELL_ID_1) == PL111_CLCD_P_CELL_ID_1) &&
42 (MmioRead8 (PL111_REG_CLCD_P_CELL_ID_2) == PL111_CLCD_P_CELL_ID_2) &&
43 (MmioRead8 (PL111_REG_CLCD_P_CELL_ID_3) == PL111_CLCD_P_CELL_ID_3))
44 {
45 return EFI_SUCCESS;
46 }
47
48 return EFI_NOT_FOUND;
49}
50
59 IN EFI_PHYSICAL_ADDRESS VramBaseAddress
60 )
61{
62 // Define start of the VRAM. This never changes for any graphics mode
63 MmioWrite32 (PL111_REG_LCD_UP_BASE, (UINT32)VramBaseAddress);
64 MmioWrite32 (PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
65
66 // Disable all interrupts from the PL111
67 MmioWrite32 (PL111_REG_LCD_IMSC, 0);
68
69 return EFI_SUCCESS;
70}
71
81 IN UINT32 ModeNumber
82 )
83{
84 EFI_STATUS Status;
85 SCAN_TIMINGS *Horizontal;
86 SCAN_TIMINGS *Vertical;
87 UINT32 LcdControl;
88 LCD_BPP LcdBpp;
89
91
92 // Set the video mode timings and other relevant information
93 Status = LcdPlatformGetTimings (
94 ModeNumber,
95 &Horizontal,
96 &Vertical
97 );
98 if (EFI_ERROR (Status)) {
99 ASSERT_EFI_ERROR (Status);
100 return Status;
101 }
102
103 ASSERT (Horizontal != NULL);
104 ASSERT (Vertical != NULL);
105
106 Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
107 if (EFI_ERROR (Status)) {
108 ASSERT_EFI_ERROR (Status);
109 return Status;
110 }
111
112 // Get the pixel format information
113 Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
114 if (EFI_ERROR (Status)) {
115 ASSERT_EFI_ERROR (Status);
116 return Status;
117 }
118
119 // Disable the CLCD_LcdEn bit
120 MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
121
122 // Set Timings
124 PL111_REG_LCD_TIMING_0,
125 HOR_AXIS_PANEL (
126 Horizontal->BackPorch,
127 Horizontal->FrontPorch,
128 Horizontal->Sync,
129 Horizontal->Resolution
130 )
131 );
132
134 PL111_REG_LCD_TIMING_1,
135 VER_AXIS_PANEL (
136 Vertical->BackPorch,
137 Vertical->FrontPorch,
138 Vertical->Sync,
139 Vertical->Resolution
140 )
141 );
142
144 PL111_REG_LCD_TIMING_2,
145 CLK_SIG_POLARITY (Horizontal->Resolution)
146 );
147
148 MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
149
150 // PL111_REG_LCD_CONTROL
151 LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |
152 PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR;
154 LcdControl |= PL111_CTRL_BGR;
155 }
156
157 MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
158
159 return EFI_SUCCESS;
160}
161
164VOID
166 VOID
167 )
168{
169 // Disable the controller
170 MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
171}
UINT32 EFIAPI MmioAnd32(IN UINTN Address, IN UINT32 AndData)
Definition: IoHighLevel.c:1814
UINT8 EFIAPI MmioRead8(IN UINTN Address)
Definition: IoLib.c:82
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
Definition: IoLib.c:309
EFI_STATUS LcdPlatformQueryMode(IN UINT32 ModeNumber, OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info)
EFI_STATUS LcdPlatformGetBpp(IN UINT32 ModeNumber, OUT LCD_BPP *Bpp)
LCD_BPP
EFI_STATUS LcdPlatformGetTimings(IN UINT32 ModeNumber, OUT SCAN_TIMINGS **Horizontal, OUT SCAN_TIMINGS **Vertical)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
@ PixelBlueGreenRedReserved8BitPerColor
EFI_STATUS LcdSetMode(IN UINT32 ModeNumber)
Definition: PL111Lcd.c:80
VOID LcdShutdown(VOID)
Definition: PL111Lcd.c:165
EFI_STATUS LcdIdentify(VOID)
Definition: PL111Lcd.c:25
EFI_STATUS LcdInitialize(IN EFI_PHYSICAL_ADDRESS VramBaseAddress)
Definition: PL111Lcd.c:58
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat