]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
ArmPlatformPkg/PL180MciDxe: check PrimeCell ID before initializing
[mirror_edk2.git] / ArmPlatformPkg / Drivers / LcdGraphicsOutputDxe / PL111Lcd.c
1 /** @file PL111Lcd.c
2
3 Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
4
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <Library/IoLib.h>
16 #include <Library/MemoryAllocationLib.h>
17
18 #include <Drivers/PL111Lcd.h>
19
20 #include "LcdGraphicsOutputDxe.h"
21
22 /**********************************************************************
23 *
24 * This file contains all the bits of the PL111 that are
25 * platform independent.
26 *
27 **********************************************************************/
28
29 EFI_STATUS
30 LcdInitialize (
31 IN EFI_PHYSICAL_ADDRESS VramBaseAddress
32 )
33 {
34 // Define start of the VRAM. This never changes for any graphics mode
35 MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);
36 MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
37
38 // Disable all interrupts from the PL111
39 MmioWrite32(PL111_REG_LCD_IMSC, 0);
40
41 return EFI_SUCCESS;
42 }
43
44 EFI_STATUS
45 LcdSetMode (
46 IN UINT32 ModeNumber
47 )
48 {
49 EFI_STATUS Status;
50 UINT32 HRes;
51 UINT32 HSync;
52 UINT32 HBackPorch;
53 UINT32 HFrontPorch;
54 UINT32 VRes;
55 UINT32 VSync;
56 UINT32 VBackPorch;
57 UINT32 VFrontPorch;
58 UINT32 LcdControl;
59 LCD_BPP LcdBpp;
60
61 // Set the video mode timings and other relevant information
62 Status = LcdPlatformGetTimings (ModeNumber,
63 &HRes,&HSync,&HBackPorch,&HFrontPorch,
64 &VRes,&VSync,&VBackPorch,&VFrontPorch);
65 ASSERT_EFI_ERROR (Status);
66 if (EFI_ERROR( Status )) {
67 return EFI_DEVICE_ERROR;
68 }
69
70 Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
71 ASSERT_EFI_ERROR (Status);
72 if (EFI_ERROR( Status )) {
73 return EFI_DEVICE_ERROR;
74 }
75
76 // Disable the CLCD_LcdEn bit
77 LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);
78 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);
79
80 // Set Timings
81 MmioWrite32 (PL111_REG_LCD_TIMING_0, HOR_AXIS_PANEL(HBackPorch, HFrontPorch, HSync, HRes));
82 MmioWrite32 (PL111_REG_LCD_TIMING_1, VER_AXIS_PANEL(VBackPorch, VFrontPorch, VSync, VRes));
83 MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY(HRes));
84 MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
85
86 // PL111_REG_LCD_CONTROL
87 LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
88 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
89
90 // Turn on power to the LCD Panel
91 LcdControl |= PL111_CTRL_LCD_PWR;
92 MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
93
94 return EFI_SUCCESS;
95 }
96
97 VOID
98 LcdShutdown (
99 VOID
100 )
101 {
102 // Disable the controller
103 MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
104 }