]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
ArmPlatformPkg: Minor code changes (comments, misspellings, coding stylei, line endings)
[mirror_edk2.git] / ArmPlatformPkg / Drivers / LcdGraphicsOutputDxe / PL111Lcd.c
1 /** @file PL111Lcd.c
2
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
8
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.
11
12 **/
13
14 #include <Library/IoLib.h>
15 #include <Library/MemoryAllocationLib.h>
16
17 #include <Drivers/PL111Lcd.h>
18
19 #include "LcdGraphicsOutputDxe.h"
20
21 /**********************************************************************
22 *
23 * This file contains all the bits of the PL111 that are
24 * platform independent.
25 *
26 **********************************************************************/
27
28 EFI_STATUS
29 PL111Indentify (
30 VOID
31 )
32 {
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 ) ) {
38 return EFI_NOT_FOUND;
39 }
40
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 ) ) {
46 return EFI_NOT_FOUND;
47 }
48
49 return EFI_SUCCESS;
50 }
51
52 EFI_STATUS
53 LcdInitialize (
54 IN EFI_PHYSICAL_ADDRESS VramBaseAddress
55 )
56 {
57 EFI_STATUS Status = EFI_SUCCESS;
58
59 // Check if the PL111 is fitted on this motherboard
60 Status = PL111Indentify ();
61 if (EFI_ERROR( Status )) {
62 return EFI_DEVICE_ERROR;
63 }
64
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
68
69 // Disable all interrupts from the PL111
70 MmioWrite32(PL111_REG_LCD_IMSC, 0);
71
72 return EFI_SUCCESS;
73 }
74
75 EFI_STATUS
76 LcdSetMode (
77 IN UINT32 ModeNumber
78 )
79 {
80 EFI_STATUS Status;
81 UINT32 HRes;
82 UINT32 HSync;
83 UINT32 HBackPorch;
84 UINT32 HFrontPorch;
85 UINT32 VRes;
86 UINT32 VSync;
87 UINT32 VBackPorch;
88 UINT32 VFrontPorch;
89 UINT32 LcdControl;
90 LCD_BPP LcdBpp;
91
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;
99 }
100
101 Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
102 ASSERT_EFI_ERROR (Status);
103 if (EFI_ERROR( Status )) {
104 return EFI_DEVICE_ERROR;
105 }
106
107 // Disable the CLCD_LcdEn bit
108 LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);
109 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);
110
111 // Set Timings
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);
116
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);
120
121 // Turn on power to the LCD Panel
122 LcdControl |= PL111_CTRL_LCD_PWR;
123 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
124
125 return EFI_SUCCESS;
126 }
127
128 VOID
129 LcdShutdown (
130 VOID
131 )
132 {
133 // Nothing to do in terms of hardware.
134 // We could switch off the monitor display if required
135
136 //TODO: ImplementMe
137 }