ArmPlatformPkg: Minor code changes (comments, misspellings, coding stylei, line endings)
[mirror_edk2.git] / ArmPlatformPkg / Drivers / LcdGraphicsOutputDxe / PL111Lcd.c
CommitLineData
7d0f2f23 1/** @file PL111Lcd.c\r
2\r
3 Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>\r
4 This program and the accompanying materials\r
5 are licensed and made available under the terms and conditions of the BSD License\r
6 which accompanies this distribution. The full text of the license may be found at\r
7 http://opensource.org/licenses/bsd-license.php\r
8\r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12**/\r
13\r
7d0f2f23 14#include <Library/IoLib.h>\r
7d0f2f23 15#include <Library/MemoryAllocationLib.h>\r
7d0f2f23 16\r
17#include <Drivers/PL111Lcd.h>\r
18\r
19#include "LcdGraphicsOutputDxe.h"\r
20\r
21/**********************************************************************\r
22 *\r
23 * This file contains all the bits of the PL111 that are\r
24 * platform independent.\r
25 *\r
26 **********************************************************************/\r
27\r
28EFI_STATUS\r
29PL111Indentify (\r
30 VOID\r
31 )\r
32{\r
33 // Check if this is a PrimeCell Peripheral\r
34 if ( ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_0 ) != 0x0D )\r
35 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_1 ) != 0xF0 )\r
36 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_2 ) != 0x05 )\r
37 || ( MmioRead8( PL111_REG_CLCD_P_CELL_ID_3 ) != 0xB1 ) ) {\r
38 return EFI_NOT_FOUND;\r
39 }\r
40\r
41 // Check if this PrimeCell Peripheral is the PL111 LCD\r
42 if ( ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_0 ) != 0x11 )\r
43 || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_1 ) != 0x11 )\r
44 || ( (MmioRead8( PL111_REG_CLCD_PERIPH_ID_2 ) & 0xF) != 0x04 )\r
45 || ( MmioRead8( PL111_REG_CLCD_PERIPH_ID_3 ) != 0x00 ) ) {\r
46 return EFI_NOT_FOUND;\r
47 }\r
48\r
49 return EFI_SUCCESS;\r
50}\r
51\r
52EFI_STATUS\r
53LcdInitialize (\r
54 IN EFI_PHYSICAL_ADDRESS VramBaseAddress\r
55 )\r
56{\r
57 EFI_STATUS Status = EFI_SUCCESS;\r
58\r
59 // Check if the PL111 is fitted on this motherboard\r
0db25ccc 60 Status = PL111Indentify ();\r
7d0f2f23 61 if (EFI_ERROR( Status )) {\r
62 return EFI_DEVICE_ERROR;\r
63 }\r
64\r
65 // Define start of the VRAM. This never changes for any graphics mode\r
66 MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);\r
67 MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer\r
68\r
69 // Disable all interrupts from the PL111\r
70 MmioWrite32(PL111_REG_LCD_IMSC, 0);\r
71\r
72 return EFI_SUCCESS;\r
73}\r
74\r
75EFI_STATUS\r
76LcdSetMode (\r
77 IN UINT32 ModeNumber\r
78 )\r
79{\r
80 EFI_STATUS Status;\r
81 UINT32 HRes;\r
82 UINT32 HSync;\r
83 UINT32 HBackPorch;\r
84 UINT32 HFrontPorch;\r
85 UINT32 VRes;\r
86 UINT32 VSync;\r
87 UINT32 VBackPorch;\r
88 UINT32 VFrontPorch;\r
89 UINT32 LcdControl;\r
90 LCD_BPP LcdBpp;\r
91\r
92 // Set the video mode timings and other relevant information\r
93 Status = LcdPlatformGetTimings (ModeNumber,\r
94 &HRes,&HSync,&HBackPorch,&HFrontPorch,\r
95 &VRes,&VSync,&VBackPorch,&VFrontPorch);\r
96 ASSERT_EFI_ERROR (Status);\r
97 if (EFI_ERROR( Status )) {\r
98 return EFI_DEVICE_ERROR;\r
99 }\r
100\r
101 Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);\r
102 ASSERT_EFI_ERROR (Status);\r
103 if (EFI_ERROR( Status )) {\r
104 return EFI_DEVICE_ERROR;\r
105 }\r
106\r
107 // Disable the CLCD_LcdEn bit\r
108 LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);\r
109 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);\r
110\r
111 // Set Timings\r
112 MmioWrite32 (PL111_REG_LCD_TIMING_0, HOR_AXIS_PANEL(HBackPorch, HFrontPorch, HSync, HRes));\r
113 MmioWrite32 (PL111_REG_LCD_TIMING_1, VER_AXIS_PANEL(VBackPorch, VFrontPorch, VSync, VRes));\r
114 MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY(HRes));\r
115 MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);\r
116\r
117 // PL111_REG_LCD_CONTROL\r
118 LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;\r
119 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);\r
120\r
121 // Turn on power to the LCD Panel\r
122 LcdControl |= PL111_CTRL_LCD_PWR;\r
123 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);\r
124\r
125 return EFI_SUCCESS;\r
126}\r
127\r
128VOID\r
129LcdShutdown (\r
130 VOID\r
131 )\r
132{\r
133 // Nothing to do in terms of hardware.\r
134 // We could switch off the monitor display if required\r
135\r
136 //TODO: ImplementMe\r
137}\r